wiki-viewer 2.9.3 → 2.9.5
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/.next/standalone/.next/BUILD_ID +1 -1
- package/.next/standalone/.next/build-manifest.json +3 -3
- package/.next/standalone/.next/prerender-manifest.json +3 -3
- package/.next/standalone/.next/required-server-files.json +1 -1
- package/.next/standalone/.next/server/app/_global-error.html +1 -1
- package/.next/standalone/.next/server/app/_global-error.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/api/agent/activity/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/agent/events/[...path]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/agent/files/[...path]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/agent/fs/file/[...path]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/agent/fs/ls/[[...path]]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/agent/fs/move/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/agent/fs/search/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/agent/internal/span/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/agent/settings/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/agent/sidecar/[...path]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/app-proxy/[...path]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/assets/[...path]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/pdf/save/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/share/[token]/asset/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/share/[token]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/share/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/system/reveal/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/system/workspaces/[id]/branch/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/system/workspaces/[id]/open/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/system/workspaces/[id]/refresh/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/system/workspaces/[id]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/system/workspaces/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/upload/[...path]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/app/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/backlinks/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/content/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/download/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/folder/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/git-branches/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/git-checkout/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/git-diff/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/git-file-info/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/git-history/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/git-pull/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/move/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/new-file/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/outlinks/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/page/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/presence/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/search/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/slugs/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/upload/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/watch/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__00sn-o5._.js +2 -2
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__05tbv~.._.js +2 -2
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0_5~w8k._.js +2 -2
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0_g-.kr._.js +3 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0mjux2y._.js +1 -1
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__11ltgmp._.js +1 -1
- package/.next/standalone/.next/server/chunks/src_lib_auth_server_ts_00f4e0h._.js +7 -7
- package/.next/standalone/.next/server/chunks/ssr/_0oq8kwv._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/src_app_signin_00yk0vm._.js +1 -1
- package/.next/standalone/.next/server/middleware-build-manifest.js +3 -3
- package/.next/standalone/.next/server/pages/500.html +1 -1
- package/.next/standalone/.next/server/server-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/server-reference-manifest.json +1 -1
- package/.next/standalone/.next/static/chunks/{0yixq3fhhpk~9.js → 0g6xc2sqjuw.h.js} +1 -1
- package/.next/standalone/package.json +1 -1
- package/.next/standalone/server.js +1 -1
- package/package.json +1 -1
- /package/.next/standalone/.next/static/{I6ZpQF8Ua7ytNZMW5ZKWH → 2qQdcBZEXk0wXjBdvnPD5}/_buildManifest.js +0 -0
- /package/.next/standalone/.next/static/{I6ZpQF8Ua7ytNZMW5ZKWH → 2qQdcBZEXk0wXjBdvnPD5}/_clientMiddlewareManifest.js +0 -0
- /package/.next/standalone/.next/static/{I6ZpQF8Ua7ytNZMW5ZKWH → 2qQdcBZEXk0wXjBdvnPD5}/_ssgManifest.js +0 -0
|
@@ -18,7 +18,7 @@ TOKEN=<paste token here>
|
|
|
18
18
|
# 3. Read snapshot
|
|
19
19
|
curl -s -H "Authorization: Bearer $TOKEN" \\
|
|
20
20
|
-H "X-Agent-Id: ai:claude" \\
|
|
21
|
-
${b}/api/agent/files/${a??"<path/to/file.md>"}`;await navigator.clipboard.writeText(d),c(!0),setTimeout(()=>c(!1),1500)},[a])}}(a??null),[k,l]=(0,p.useState)(""),m=(0,p.useRef)(null),n="http://localhost:3000",q=(0,p.useCallback)(()=>bQ,[]),s=(0,p.useCallback)(()=>k.replace(/\$WIKI_URL/g,n),[k,n]),t=(0,p.useCallback)(()=>`npx wiki-viewer-mcp register --url ${n} --id ai:myagent --name "My Agent"`,[n]),v=(0,p.useCallback)(()=>JSON.stringify({servers:{"wiki-viewer":{command:"npx",args:["wiki-viewer-mcp"],env:{WIKI_VIEWER_URL:n,WIKI_VIEWER_TOKEN:"<token from register>",WIKI_VIEWER_AGENT_ID:"ai:myagent"}}}},null,2),[n]),w=bR(q),x=bR(s),y=bR(t),z=bR(v);return((0,p.useEffect)(()=>{if(b)return document.addEventListener("keydown",a),()=>document.removeEventListener("keydown",a);function a(a){"Escape"===a.key&&c()}},[b,c]),(0,p.useEffect)(()=>{b&&m.current?.focus()},[b]),(0,p.useEffect)(()=>{if(!b)return;f();let a=setInterval(()=>void f(),1e4);return()=>clearInterval(a)},[b,f]),(0,p.useEffect)(()=>{b&&fetch((0,au.apiUrl)("/api/agents/install")).then(a=>a.json()).then(a=>{a.bootstrapPrompt&&l(a.bootstrapPrompt)}).catch(()=>void 0)},[b]),b)?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("div",{className:"fixed inset-0 z-40 bg-overlay backdrop-blur-[1px]",onClick:c,"aria-hidden":!0}),(0,g.jsxs)("aside",{ref:m,tabIndex:-1,role:"dialog","aria-modal":"true","aria-label":"AI Agent Panel",className:"fixed right-0 top-0 bottom-0 z-50 flex w-[90vw] max-w-sm md:w-80 flex-col border-l border-border bg-background shadow-xl outline-none",children:[(0,g.jsxs)("div",{className:"flex items-center justify-between border-b border-border px-4 py-3 shrink-0",children:[(0,g.jsxs)("div",{className:"flex items-center gap-2",children:[(0,g.jsx)(i,{className:"h-4 w-4 text-muted-foreground"}),(0,g.jsx)("span",{className:"text-sm font-semibold",children:"AI Agent"})]}),(0,g.jsx)(u.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:c,title:"Close panel (Esc)",children:(0,g.jsx)(o,{className:"h-3.5 w-3.5"})})]}),(0,g.jsxs)("div",{className:"flex-1 overflow-y-auto space-y-5 px-4 py-4",children:[(0,g.jsxs)("section",{className:"rounded-md border border-border bg-muted/30 p-3",children:[(0,g.jsx)("p",{className:"text-sm font-medium text-foreground",children:"Work with this wiki using AI"}),(0,g.jsxs)("p",{className:"mt-1 text-xs leading-relaxed text-muted-foreground",children:["Connect Claude, Cursor, ChatGPT, and more. Pick by what you want — each option gives a copy-paste setup. You approve every assistant in ",(0,g.jsx)("span",{className:"font-medium text-foreground/80",children:"Agents"})," below before it gets access."]})]}),(0,g.jsxs)("section",{className:"space-y-3",children:[(0,g.jsxs)("div",{className:"rounded-md border border-border bg-muted/40 p-3 space-y-1.5",children:[(0,g.jsx)("p",{className:"text-xs font-semibold text-foreground",children:"Co-write docs with you"}),(0,g.jsx)("p",{className:"text-[10px] text-muted-foreground/70",children:"Edits arrive as suggestions with comments you accept or revert. No MCP needed."}),(0,g.jsx)(u.Button,{size:"sm",variant:"outline",className:"h-7 w-full text-xs gap-1.5",onClick:()=>void x.copy(),disabled:!k,children:x.copied?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(r.Check,{className:"h-3.5 w-3.5 text-green-500"})," Copied!"]}):(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(aY.Copy,{className:"h-3.5 w-3.5"})," Paste into any chatbot"]})}),(0,g.jsxs)("p",{className:"text-[10px] text-muted-foreground/50 pt-1",children:["Or install once so it sticks"," ",(0,g.jsx)("span",{className:"text-muted-foreground/40",children:"· Claude, OpenCode"}),":"]}),(0,g.jsxs)("div",{className:"flex items-center gap-2",children:[(0,g.jsx)("code",{className:"flex-1 text-[10px] font-mono text-foreground/80 truncate bg-muted rounded px-1 py-0.5",children:bQ}),(0,g.jsx)(u.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0 shrink-0",title:"Copy this command",onClick:()=>void w.copy(),children:w.copied?(0,g.jsx)(r.Check,{className:"h-3.5 w-3.5 text-green-500"}):(0,g.jsx)(aY.Copy,{className:"h-3.5 w-3.5"})})]})]}),(0,g.jsxs)("div",{className:"rounded-md border border-border bg-muted/40 p-3 space-y-1.5",children:[(0,g.jsxs)("p",{className:"text-xs font-semibold text-foreground",children:["Edit files directly"," ",(0,g.jsx)("span",{className:"font-normal text-muted-foreground/60",children:"· Claude Code, Cursor, Codex"})]}),(0,g.jsx)("p",{className:"text-[10px] text-muted-foreground/70",children:"Native read / search / edit tools over MCP. Run to request access:"}),(0,g.jsxs)("div",{className:"flex items-center gap-2",children:[(0,g.jsx)("code",{className:"flex-1 text-[10px] font-mono text-foreground/80 truncate bg-muted rounded px-1 py-0.5",children:t()}),(0,g.jsx)(u.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0 shrink-0",title:"Copy this command",onClick:()=>void y.copy(),children:y.copied?(0,g.jsx)(r.Check,{className:"h-3.5 w-3.5 text-green-500"}):(0,g.jsx)(aY.Copy,{className:"h-3.5 w-3.5"})})]}),(0,g.jsxs)("p",{className:"text-[10px] text-muted-foreground/50",children:["Approve in ",(0,g.jsx)("span",{className:"font-medium text-foreground/70",children:"Agents"}),", then add to your tool:"]}),(0,g.jsx)(u.Button,{size:"sm",variant:"outline",className:"h-7 w-full text-xs gap-1.5",onClick:()=>void z.copy(),children:z.copied?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(r.Check,{className:"h-3.5 w-3.5 text-green-500"})," Copied!"]}):(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(aY.Copy,{className:"h-3.5 w-3.5"})," Copy config (mcp.json)"]})})]}),(0,g.jsxs)("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[(0,g.jsx)("span",{className:"text-[10px] text-muted-foreground/50",children:"For developers:"}),(0,g.jsxs)("button",{type:"button",onClick:()=>void j(),className:"inline-flex items-center gap-1 text-[10px] text-primary hover:underline",children:[h?(0,g.jsx)(r.Check,{className:"h-3 w-3 text-green-500"}):(0,g.jsx)(aY.Copy,{className:"h-3 w-3"})," curl example"]}),(0,g.jsxs)("a",{href:(0,au.apiUrl)("/api/agents/skill"),target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 text-[10px] text-primary hover:underline",children:[(0,g.jsx)(bn,{className:"h-3 w-3"})," skill"]}),(0,g.jsxs)("a",{href:(0,au.apiUrl)("/api/agents/install"),target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 text-[10px] text-primary hover:underline",children:[(0,g.jsx)(bn,{className:"h-3 w-3"})," install JSON"]})]})]}),(0,g.jsx)(bw,{}),(0,g.jsxs)("section",{className:"space-y-2",children:[(0,g.jsxs)("h3",{className:"text-xs font-semibold uppercase tracking-widest text-muted-foreground",children:["Active Connections"," ",(0,g.jsx)("span",{className:"normal-case font-normal text-muted-foreground/50",children:"(last 5 min)"})]}),(0,g.jsx)("div",{className:"rounded-md border border-border bg-muted/40 p-3",children:0===e.length?(0,g.jsxs)("p",{className:"text-xs text-muted-foreground/60 flex items-center gap-1.5",children:[(0,g.jsx)(bm,{className:"h-3.5 w-3.5"}),"No recent activity"]}):(0,g.jsx)("ul",{className:"space-y-1.5",children:e.map(a=>(0,g.jsxs)("li",{className:"flex items-center justify-between text-xs",children:[(0,g.jsx)("span",{className:"font-mono text-foreground/80 truncate",children:a.by}),(0,g.jsxs)("span",{className:"text-muted-foreground shrink-0",children:[a.opCount," op",1!==a.opCount?"s":""]})]},a.by))})})]}),(0,g.jsxs)("section",{className:"space-y-2",children:[(0,g.jsx)("h3",{className:"text-xs font-semibold uppercase tracking-widest text-muted-foreground",children:"Recent Activity"}),(0,g.jsx)("div",{className:"rounded-md border border-border bg-muted/40 px-3 py-2 max-h-72 overflow-y-auto",children:(0,g.jsx)(bP,{activity:d})})]}),(0,g.jsx)("section",{children:(0,g.jsx)("a",{href:(0,au.apiUrl)("/docs/agent-collab-plan.md"),target:"_blank",rel:"noreferrer",className:"text-xs text-primary underline hover:no-underline",children:"Agent collaboration docs →"})})]})]})]}):null}let bT=(0,h.default)("link",[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]]),bU=(0,h.default)("ellipsis",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]]);var bV=a.i(335732),bW=a.i(765021);let bX=(0,h.default)("file",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}]]),bY=(0,h.default)("file-plus",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M9 15h6",key:"cctwl0"}],["path",{d:"M12 18v-6",key:"17g6i2"}]]),bZ=(0,h.default)("folder-plus",[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]),b$=(0,h.default)("terminal",[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]]),b_=(0,h.default)("upload",[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]]);function b0({pos:a,branches:b,loading:c,busyName:d,disabled:e,onPick:f,onClose:h}){let[i,j]=(0,p.useState)(""),k=(0,p.useRef)(null);if((0,p.useEffect)(()=>{let a=a=>{let b=a.target;k.current?.contains(b)||b?.closest?.("[data-branch-trigger]")||h()},b=a=>{"Escape"===a.key&&h()};return document.addEventListener("mousedown",a),document.addEventListener("keydown",b),()=>{document.removeEventListener("mousedown",a),document.removeEventListener("keydown",b)}},[h]),"u"<typeof document)return null;let l=b.length>8,n=i.trim().toLowerCase(),o=n?b.filter(a=>a.name.toLowerCase().includes(n)):b;return(0,bd.createPortal)((0,g.jsx)("div",{ref:k,"data-branch-portal":!0,style:{position:"fixed",top:a.top,left:a.left},className:"pointer-events-auto z-[9999] flex max-h-72 w-52 flex-col overflow-hidden rounded-md border bg-popover p-1 shadow-md",children:c?(0,g.jsx)("div",{className:"flex justify-center py-2",children:(0,g.jsx)(m.Loader2,{className:"h-3.5 w-3.5 animate-spin text-muted-foreground"})}):0===b.length?(0,g.jsx)("p",{className:"px-2 py-1 text-[10px] text-muted-foreground",children:"No branches"}):(0,g.jsxs)(g.Fragment,{children:[l&&(0,g.jsx)("input",{autoFocus:!0,value:i,onChange:a=>j(a.target.value),placeholder:"Filter branches…",className:"mb-1 w-full shrink-0 rounded border bg-background px-1.5 py-1 text-[11px] outline-none focus:ring-1 focus:ring-ring"}),(0,g.jsx)("div",{className:"min-h-0 flex-1 overflow-auto",children:0===o.length?(0,g.jsx)("p",{className:"px-2 py-1 text-[10px] text-muted-foreground",children:"No match"}):o.map(a=>(0,g.jsxs)("button",{type:"button",disabled:e||a.current,className:(0,an.cn)("flex w-full items-center gap-1.5 rounded px-2 py-1 text-left text-[11px] hover:bg-muted",a.current?"font-semibold text-foreground":"text-muted-foreground"),onClick:b=>{b.stopPropagation(),a.current||f(a.name)},children:[a.current?(0,g.jsx)(r.Check,{className:"h-3 w-3 shrink-0"}):(0,g.jsx)("span",{className:"w-3 shrink-0"}),(0,g.jsx)("span",{className:"truncate",children:a.name}),d===a.name&&(0,g.jsx)(m.Loader2,{className:"ml-auto h-3 w-3 shrink-0 animate-spin"})]},a.name))})]})}),document.body)}var b1=a.i(280370),b2=a.i(385909),b3="ContextMenu",[b4,b5]=(0,x.createContextScope)(b3,[b1.createMenuScope]),b6=(0,b1.createMenuScope)(),[b7,b8]=b4(b3),b9=a=>{let{__scopeContextMenu:b,children:c,onOpenChange:d,dir:e,modal:f=!0}=a,[h,i]=p.useState(!1),j=b6(b),k=(0,b2.useCallbackRef)(d),l=p.useCallback(a=>{i(a),k(a)},[k]);return(0,g.jsx)(b7,{scope:b,open:h,onOpenChange:l,modal:f,children:(0,g.jsx)(b1.Root,{...j,dir:e,open:h,onOpenChange:l,modal:f,children:c})})};b9.displayName=b3;var ca="ContextMenuTrigger",cb=p.forwardRef((a,b)=>{let{__scopeContextMenu:c,disabled:d=!1,...e}=a,f=b8(ca,c),h=b6(c),i=p.useRef({x:0,y:0}),j=p.useRef({getBoundingClientRect:()=>DOMRect.fromRect({width:0,height:0,...i.current})}),k=p.useRef(0),l=p.useCallback(()=>window.clearTimeout(k.current),[]),m=a=>{i.current={x:a.clientX,y:a.clientY},f.onOpenChange(!0)};return p.useEffect(()=>l,[l]),p.useEffect(()=>void(d&&l()),[d,l]),(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(b1.Anchor,{...h,virtualRef:j}),(0,g.jsx)(E.Primitive.span,{"data-state":f.open?"open":"closed","data-disabled":d?"":void 0,...e,ref:b,style:{WebkitTouchCallout:"none",...a.style},onContextMenu:d?a.onContextMenu:(0,v.composeEventHandlers)(a.onContextMenu,a=>{l(),m(a),a.preventDefault()}),onPointerDown:d?a.onPointerDown:(0,v.composeEventHandlers)(a.onPointerDown,cn(a=>{l(),k.current=window.setTimeout(()=>m(a),700)})),onPointerMove:d?a.onPointerMove:(0,v.composeEventHandlers)(a.onPointerMove,cn(l)),onPointerCancel:d?a.onPointerCancel:(0,v.composeEventHandlers)(a.onPointerCancel,cn(l)),onPointerUp:d?a.onPointerUp:(0,v.composeEventHandlers)(a.onPointerUp,cn(l))})]})});cb.displayName=ca;var cc=a=>{let{__scopeContextMenu:b,...c}=a,d=b6(b);return(0,g.jsx)(b1.Portal,{...d,...c})};cc.displayName="ContextMenuPortal";var cd="ContextMenuContent",ce=p.forwardRef((a,b)=>{let{__scopeContextMenu:c,...d}=a,e=b8(cd,c),f=b6(c),h=p.useRef(!1);return(0,g.jsx)(b1.Content,{...f,...d,ref:b,side:"right",sideOffset:2,align:"start",onCloseAutoFocus:b=>{a.onCloseAutoFocus?.(b),!b.defaultPrevented&&h.current&&b.preventDefault(),h.current=!1},onInteractOutside:b=>{a.onInteractOutside?.(b),b.defaultPrevented||e.modal||(h.current=!0)},style:{...a.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});ce.displayName=cd,p.forwardRef((a,b)=>{let{__scopeContextMenu:c,...d}=a,e=b6(c);return(0,g.jsx)(b1.Group,{...e,...d,ref:b})}).displayName="ContextMenuGroup";var cf=p.forwardRef((a,b)=>{let{__scopeContextMenu:c,...d}=a,e=b6(c);return(0,g.jsx)(b1.Label,{...e,...d,ref:b})});cf.displayName="ContextMenuLabel";var cg=p.forwardRef((a,b)=>{let{__scopeContextMenu:c,...d}=a,e=b6(c);return(0,g.jsx)(b1.Item,{...e,...d,ref:b})});cg.displayName="ContextMenuItem";var ch=p.forwardRef((a,b)=>{let{__scopeContextMenu:c,...d}=a,e=b6(c);return(0,g.jsx)(b1.CheckboxItem,{...e,...d,ref:b})});ch.displayName="ContextMenuCheckboxItem",p.forwardRef((a,b)=>{let{__scopeContextMenu:c,...d}=a,e=b6(c);return(0,g.jsx)(b1.RadioGroup,{...e,...d,ref:b})}).displayName="ContextMenuRadioGroup";var ci=p.forwardRef((a,b)=>{let{__scopeContextMenu:c,...d}=a,e=b6(c);return(0,g.jsx)(b1.RadioItem,{...e,...d,ref:b})});ci.displayName="ContextMenuRadioItem";var cj=p.forwardRef((a,b)=>{let{__scopeContextMenu:c,...d}=a,e=b6(c);return(0,g.jsx)(b1.ItemIndicator,{...e,...d,ref:b})});cj.displayName="ContextMenuItemIndicator";var ck=p.forwardRef((a,b)=>{let{__scopeContextMenu:c,...d}=a,e=b6(c);return(0,g.jsx)(b1.Separator,{...e,...d,ref:b})});ck.displayName="ContextMenuSeparator",p.forwardRef((a,b)=>{let{__scopeContextMenu:c,...d}=a,e=b6(c);return(0,g.jsx)(b1.Arrow,{...e,...d,ref:b})}).displayName="ContextMenuArrow";var cl=p.forwardRef((a,b)=>{let{__scopeContextMenu:c,...d}=a,e=b6(c);return(0,g.jsx)(b1.SubTrigger,{...e,...d,ref:b})});cl.displayName="ContextMenuSubTrigger";var cm=p.forwardRef((a,b)=>{let{__scopeContextMenu:c,...d}=a,e=b6(c);return(0,g.jsx)(b1.SubContent,{...e,...d,ref:b,style:{...a.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});function cn(a){return b=>"mouse"!==b.pointerType?a(b):void 0}cm.displayName="ContextMenuSubContent";var co=a.i(694079);p.forwardRef(({className:a,inset:b,children:c,...d},e)=>(0,g.jsxs)(cl,{ref:e,className:(0,an.cn)("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",b&&"pl-8",a),...d,children:[c,(0,g.jsx)(aO.ChevronRight,{className:"ml-auto h-4 w-4"})]})).displayName=cl.displayName,p.forwardRef(({className:a,...b},c)=>(0,g.jsx)(cm,{ref:c,className:(0,an.cn)("z-50 min-w-[8rem] overflow-hidden rounded-sm border bg-popover p-1 text-popover-foreground shadow-golden data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",a),...b})).displayName=cm.displayName;let cp=p.forwardRef(({className:a,...b},c)=>(0,g.jsx)(cc,{children:(0,g.jsx)(ce,{ref:c,className:(0,an.cn)("z-50 min-w-[8rem] overflow-hidden rounded-sm border bg-popover p-1 text-popover-foreground shadow-golden data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",a),...b})}));cp.displayName=ce.displayName;let cq=p.forwardRef(({className:a,inset:b,...c},d)=>(0,g.jsx)(cg,{ref:d,className:(0,an.cn)("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",b&&"pl-8",a),...c}));cq.displayName=cg.displayName,p.forwardRef(({className:a,children:b,checked:c,...d},e)=>(0,g.jsxs)(ch,{ref:e,className:(0,an.cn)("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",a),checked:c,...d,children:[(0,g.jsx)("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,g.jsx)(cj,{children:(0,g.jsx)(r.Check,{className:"h-4 w-4"})})}),b]})).displayName=ch.displayName,p.forwardRef(({className:a,children:b,...c},d)=>(0,g.jsxs)(ci,{ref:d,className:(0,an.cn)("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",a),...c,children:[(0,g.jsx)("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,g.jsx)(cj,{children:(0,g.jsx)(co.Circle,{className:"h-2 w-2 fill-current"})})}),b]})).displayName=ci.displayName,p.forwardRef(({className:a,inset:b,...c},d)=>(0,g.jsx)(cf,{ref:d,className:(0,an.cn)("px-2 py-1.5 text-sm font-normal",b&&"pl-8",a),...c})).displayName=cf.displayName;let cr=p.forwardRef(({className:a,...b},c)=>(0,g.jsx)(ck,{ref:c,className:(0,an.cn)("-mx-1 my-1 h-px bg-muted",a),...b}));cr.displayName=ck.displayName;let cs=(0,aw.create)((a,b)=>({humanize:!1,toggle:()=>{a({humanize:!b().humanize})}})),ct=(0,aw.create)((a,b)=>({showHidden:!1,toggle:()=>{a({showHidden:!b().showHidden})}}));function cu(a){return a.split(".").pop()?.toLowerCase()??""}function cv(a,b){if("node-app"===b)return"node-app";if("app"===b)return"app";if("dir"===b)return"fallback";let c=a.split("/").pop()??a;if(c.startsWith(".")&&-1===c.indexOf(".",1))return"source";let d=cu(a);return d?["md","markdown"].includes(d)?"editor":"txt"===d?"text":["csv","tsv"].includes(d)?"csv":"pdf"===d?"pdf":["mmd","mermaid"].includes(d)?"mermaid":"ipynb"===d?"notebook":["png","jpg","jpeg","gif","webp","svg","avif","ico","bmp"].includes(d)?"image":["mp4","webm","mov","m4v","mp3","wav","ogg","m4a","aac"].includes(d)?"media":"docx"===d?"docx":["xlsx","xlsm"].includes(d)?"xlsx":"pptx"===d?"pptx":"html"===d?"html":(["py","js","ts","tsx","jsx","go","rs","java","c","cpp","h","sh","bash","zsh","rb","php","swift","kt","lua","sql","yaml","yml","toml","json","xml","css","scss"].includes(d),"source"):"source"}let cw=new Set(["txt","md","markdown","json","yaml","yml","toml","csv","tsv","xml","html","css","js","ts","tsx","jsx","sh","bash","zsh","rb","py","go","rs","java","c","cpp","h","php","swift","kt","lua","sql","scss","mmd","mermaid","ini","env","log","conf"]);function cx(a){let b=cv(a,"file");return"editor"===b||"text"===b||cw.has(cu(a))}function cy(a){return["md","markdown"].includes(cu(a))}function cz(a){return"image"===cv(a,"file")}function cA(a){return"html"===cv(a,"file")}let cB={contentVisibility:"auto",containIntrinsicSize:"auto 32px"};function cC({node:a,ctx:b,isPinned:c,activeWorkspaceId:d}){return(0,g.jsxs)(cp,{className:"w-48",children:[(0,g.jsxs)(cq,{onSelect:()=>b.copyPath(a.path),children:[(0,g.jsx)(aY.Copy,{className:"mr-2 h-3.5 w-3.5"}),"Copy path"]}),cy(a.name)&&(0,g.jsxs)(cq,{onSelect:()=>b.copyWikiLink(a.name),children:[(0,g.jsx)(j.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy wiki link"]}),(0,g.jsxs)(cq,{onSelect:()=>b.copyUrl(a.path),children:[(0,g.jsx)(bT,{className:"mr-2 h-3.5 w-3.5"}),"Copy URL"]}),"file"===a.type&&cx(a.name)&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(cq,{onSelect:()=>b.copyRawContent(a.path),children:[(0,g.jsx)(j.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy raw content"]}),(0,g.jsxs)(cq,{onSelect:()=>b.copyFormattedContent(a.path,a.name),children:[(0,g.jsx)(j.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy formatted content"]})]}),(0,g.jsx)(cr,{}),"dir"===a.type&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(cq,{onSelect:()=>{a.expanded||b.toggleFolder(a),b.setNewFileParent(a.path),b.setNewFileName(""),b.setFileCreateError(null)},children:[(0,g.jsx)(bY,{className:"mr-2 h-3.5 w-3.5"}),"New file here"]}),(0,g.jsxs)(cq,{onSelect:()=>b.triggerUpload(a.path),children:[(0,g.jsx)(b_,{className:"mr-2 h-3.5 w-3.5"}),"Upload here"]}),(0,g.jsxs)(cq,{onSelect:()=>{b.setNewFolderParent(a.path),b.setNewFolderName(""),b.setFolderError(null)},children:[(0,g.jsx)(bZ,{className:"mr-2 h-3.5 w-3.5"}),"New subfolder"]}),(0,g.jsx)(cr,{})]}),(0,g.jsxs)(cq,{onSelect:()=>b.handleDownload(a),children:[(0,g.jsx)(bW.Download,{className:"mr-2 h-3.5 w-3.5"}),"file"===a.type?"Download":"Download as zip"]}),(0,g.jsxs)(cq,{onSelect:()=>b.togglePin(a,d),children:[(0,g.jsx)(aV,{className:(0,an.cn)("mr-2 h-3.5 w-3.5",c&&"fill-current text-amber-400")}),c?"Unpin":"Pin to top"]}),(0,g.jsx)(cr,{}),(0,g.jsxs)(cq,{className:"text-destructive focus:text-destructive",onSelect:()=>{b.setDeletingPath(a.path),b.setDeletingIsDir("file"!==a.type)},children:[(0,g.jsx)(a$,{className:"mr-2 h-3.5 w-3.5"}),"Delete"]})]})}function cD({name:a,type:b}){let c="h-3.5 w-3.5 shrink-0";return"dir"===b?(0,g.jsx)(aP,{className:(0,an.cn)(c,"text-warning")}):"app"===b?(0,g.jsx)(k,{className:(0,an.cn)(c,"text-foreground/70")}):"node-app"===b?(0,g.jsx)(b$,{className:(0,an.cn)(c,"text-emerald-500")}):cA(a)?(0,g.jsx)(k,{className:(0,an.cn)(c,"text-foreground/60")}):cz(a)?(0,g.jsx)(l,{className:(0,an.cn)(c,"text-sunshine-700")}):cx(a)?(0,g.jsx)(j.FileText,{className:(0,an.cn)(c,"text-foreground/70")}):(0,g.jsx)(bX,{className:(0,an.cn)(c,"text-foreground/60")})}let cE=(0,p.memo)(function({node:a,depth:b,ctx:c,isMobile:d,activeWorkspaceId:e,sidebarScrollRef:f,isActive:h,isDragOver:i,isPinned:n,isAgentActive:o,isPulling:p,branchOpen:q,branchPos:r,branches:s,branchLoading:t,checkingOut:v,onHoverEnter:w,onHoverLeave:x}){var y;let z,A,B,C,D,E=cs(a=>a.humanize);return(0,g.jsxs)(b9,{children:[(0,g.jsx)(cb,{asChild:!0,children:(0,g.jsxs)("div",{role:"treeitem",tabIndex:0,draggable:!d,onKeyDown:d=>{if("Enter"===d.key||" "===d.key)d.preventDefault(),"dir"===a.type?c.toggleFolder(a):"app"===a.type||"node-app"===a.type?(c.openViewer(a),c.toggleFolder(a)):c.openViewer(a);else if("ArrowDown"===d.key){d.preventDefault();let a=f.current;if(!a)return;let b=Array.from(a.querySelectorAll('[role="treeitem"]')),c=b.indexOf(d.currentTarget);b[c+1]?.focus()}else if("ArrowUp"===d.key){d.preventDefault();let a=f.current;if(!a)return;let b=Array.from(a.querySelectorAll('[role="treeitem"]')),c=b.indexOf(d.currentTarget);b[c-1]?.focus()}else if("ArrowRight"===d.key){if(d.preventDefault(),"dir"===a.type||"app"===a.type||"node-app"===a.type)if(a.expanded){let a=f.current;if(!a)return;let b=Array.from(a.querySelectorAll('[role="treeitem"]')),c=b.indexOf(d.currentTarget);b[c+1]?.focus()}else c.toggleFolder(a)}else if("ArrowLeft"===d.key){if(d.preventDefault(),("dir"===a.type||"app"===a.type||"node-app"===a.type)&&a.expanded)c.toggleFolder(a);else if(b>0){let a=f.current;if(!a)return;let b=Array.from(a.querySelectorAll('[role="treeitem"]')),c=d.currentTarget,e=b.indexOf(c),g=Number.parseInt(c.style.paddingLeft??"0",10);for(let a=e-1;a>=0;a--)if(Number.parseInt(b[a].style.paddingLeft??"0",10)<g){b[a].focus();break}}}},onDragStart:b=>c.handleDragStart(b,a),onDragOver:b=>"dir"===a.type?c.handleDragOver(b,a.path,"dir"):b.preventDefault(),onDragLeave:()=>c.setDragOverPath(null),onDrop:b=>"dir"===a.type?c.handleDropOnFolder(b,a.path):b.preventDefault(),onMouseEnter:()=>w(a),onMouseLeave:x,className:(0,an.cn)("tree-row-reveal flex items-center gap-1.5 rounded-sm px-2 py-1 text-sm cursor-pointer group transition-colors select-none touch-target",h?"bg-accent-soft text-foreground font-medium":"hover:bg-muted",i&&"ring-2 ring-primary bg-primary-soft",a.name.startsWith(".")&&"opacity-40"),style:{paddingLeft:`${14*b+8}px`,...cB},onClick:()=>{"dir"===a.type?c.toggleFolder(a):("app"===a.type||"node-app"===a.type?(c.openViewer(a),c.toggleFolder(a)):c.openViewer(a),d&&c.setSidebarCollapsed(!0))},children:["dir"===a.type||"app"===a.type||"node-app"===a.type?a.loading?(0,g.jsx)(m.Loader2,{className:"h-3.5 w-3.5 shrink-0 animate-spin text-muted-foreground"}):(0,g.jsx)(aO.ChevronRight,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground transition-transform duration-200 ease-out",style:{transform:a.expanded?"rotate(90deg)":"rotate(0deg)"}}):(0,g.jsx)("span",{className:"w-3.5 shrink-0"}),(0,g.jsx)("span",{className:"editorial-tree-typeicon",children:"dir"===a.type?a.expanded?(0,g.jsx)(aQ,{className:(0,an.cn)("h-4 w-4 shrink-0",!h&&"text-warning")}):(0,g.jsx)(aP,{className:(0,an.cn)("h-4 w-4 shrink-0",!h&&"text-warning")}):"app"===a.type?(0,g.jsx)(k,{className:(0,an.cn)("h-4 w-4 shrink-0",!h&&"text-foreground/70")}):"node-app"===a.type?(0,g.jsx)(b$,{className:(0,an.cn)("h-4 w-4 shrink-0",!h&&"text-emerald-500")}):cA(a.name)?(0,g.jsx)(k,{className:(0,an.cn)("h-4 w-4 shrink-0",!h&&"text-foreground/60")}):cz(a.name)?(0,g.jsx)(l,{className:(0,an.cn)("h-4 w-4 shrink-0",!h&&"text-sunshine-700")}):cx(a.name)?(0,g.jsx)(j.FileText,{className:(0,an.cn)("h-4 w-4 shrink-0",!h&&"text-foreground/70")}):(0,g.jsx)(bX,{className:(0,an.cn)("h-4 w-4 shrink-0",!h&&"text-foreground/60")})}),(0,g.jsx)("span",{className:"min-w-0 flex-1 truncate",title:E?a.name:void 0,children:E?(B=(A=(z=(y=a.name).lastIndexOf("."))>0&&z<y.length-1)?y.slice(0,z):y,C=A?y.slice(z):"",(D=B.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").split(/[\s_-]+/).filter(Boolean).map(a=>/^[A-Z0-9]+$/.test(a)?a:a[0].toUpperCase()+a.slice(1))).length?D.join(" ")+C:y):a.name}),a.git&&(0,g.jsxs)("span",{className:"relative flex shrink-0 items-center gap-0.5 rounded-sm bg-muted px-1 py-0.5 text-[10px] text-muted-foreground",children:[(0,g.jsxs)("button",{"data-branch-trigger":!0,type:"button",className:"flex items-center gap-0.5 hover:text-foreground",title:"Switch branch",onClick:b=>{if(b.stopPropagation(),q){c.setBranchDropdownNode(null),c.setBranchDropdownPos(null);return}let d=b.currentTarget.getBoundingClientRect();c.setBranchDropdownPos({top:d.bottom+4,left:d.left}),c.setBranchDropdownNode(a.path),c.loadBranches(a.path)},children:[(0,g.jsx)(aR,{className:"h-2.5 w-2.5"}),a.git.branch,a.git.dirty&&(0,g.jsx)("span",{className:"ml-0.5 text-warning",children:"*"})]}),p?(0,g.jsx)(m.Loader2,{className:"ml-0.5 h-2.5 w-2.5 animate-spin"}):(0,g.jsx)("button",{type:"button",onClick:b=>{b.stopPropagation();let d=a.path.includes("/")?a.path.substring(0,a.path.lastIndexOf("/")):"";c.handleGitPull(a.path,d)},className:"ml-0.5 text-muted-foreground hover:text-foreground",title:"Pull latest",children:(0,g.jsx)(br,{className:"h-2.5 w-2.5"})}),q&&r&&(0,g.jsx)(b0,{pos:r,branches:s,loading:t,busyName:v,disabled:null!==v,onPick:b=>{let d=a.path.includes("/")?a.path.substring(0,a.path.lastIndexOf("/")):"";c.handleCheckout(a.path,b,d)},onClose:()=>{c.setBranchDropdownNode(null),c.setBranchDropdownPos(null)}})]}),o&&(0,g.jsx)("span",{className:"ml-0.5 h-1.5 w-1.5 rounded-full bg-emerald-400 shrink-0 animate-pulse",title:"Agent recently active"}),(0,g.jsx)("div",{className:"hover-reveal flex max-w-0 shrink-0 items-center overflow-hidden opacity-0 transition-all duration-150 group-hover:max-w-7 group-hover:opacity-100 focus-within:max-w-7 focus-within:opacity-100",onClick:a=>a.stopPropagation(),onKeyDown:a=>a.stopPropagation(),children:(0,g.jsxs)(bV.DropdownMenu,{children:[(0,g.jsx)(bV.DropdownMenuTrigger,{asChild:!0,children:(0,g.jsx)(u.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0 text-muted-foreground hover:text-foreground",title:"File actions",children:(0,g.jsx)(bU,{className:"h-3.5 w-3.5"})})}),(0,g.jsxs)(bV.DropdownMenuContent,{align:"end",className:"w-48",children:[(0,g.jsxs)(bV.DropdownMenuItem,{onClick:()=>c.copyPath(a.path),children:[(0,g.jsx)(aY.Copy,{className:"mr-2 h-3.5 w-3.5"}),"Copy path"]}),cy(a.name)&&(0,g.jsxs)(bV.DropdownMenuItem,{onClick:()=>c.copyWikiLink(a.name),children:[(0,g.jsx)(j.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy wiki link"]}),(0,g.jsxs)(bV.DropdownMenuItem,{onClick:()=>c.copyUrl(a.path),children:[(0,g.jsx)(bT,{className:"mr-2 h-3.5 w-3.5"}),"Copy URL"]}),"file"===a.type&&cx(a.name)&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(bV.DropdownMenuItem,{onClick:()=>c.copyRawContent(a.path),children:[(0,g.jsx)(j.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy raw content"]}),(0,g.jsxs)(bV.DropdownMenuItem,{onClick:()=>c.copyFormattedContent(a.path,a.name),children:[(0,g.jsx)(j.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy formatted content"]})]}),(0,g.jsx)(bV.DropdownMenuSeparator,{}),"dir"===a.type&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(bV.DropdownMenuItem,{onClick:async()=>{a.expanded||c.toggleFolder(a),c.setNewFileParent(a.path),c.setNewFileName(""),c.setFileCreateError(null)},children:[(0,g.jsx)(bY,{className:"mr-2 h-3.5 w-3.5"}),"New file here"]}),(0,g.jsxs)(bV.DropdownMenuItem,{onClick:()=>c.triggerUpload(a.path),children:[(0,g.jsx)(b_,{className:"mr-2 h-3.5 w-3.5"}),"Upload here"]}),(0,g.jsxs)(bV.DropdownMenuItem,{onClick:()=>{c.setNewFolderParent(a.path),c.setNewFolderName(""),c.setFolderError(null)},children:[(0,g.jsx)(bZ,{className:"mr-2 h-3.5 w-3.5"}),"New subfolder"]}),(0,g.jsx)(bV.DropdownMenuSeparator,{})]}),(0,g.jsxs)(bV.DropdownMenuItem,{onClick:()=>c.handleDownload(a),children:[(0,g.jsx)(bW.Download,{className:"mr-2 h-3.5 w-3.5"}),"file"===a.type?"Download":"Download as zip"]}),(0,g.jsxs)(bV.DropdownMenuItem,{onClick:()=>c.togglePin(a,e),children:[(0,g.jsx)(aV,{className:(0,an.cn)("mr-2 h-3.5 w-3.5",n&&"fill-current text-amber-400")}),n?"Unpin":"Pin to top"]}),(0,g.jsx)(bV.DropdownMenuSeparator,{}),(0,g.jsxs)(bV.DropdownMenuItem,{className:"text-destructive focus:text-destructive",onClick:()=>{c.setDeletingPath(a.path),c.setDeletingIsDir("file"!==a.type)},children:[(0,g.jsx)(a$,{className:"mr-2 h-3.5 w-3.5"}),"Delete"]})]})]})})]})}),(0,g.jsx)(cC,{node:a,ctx:c,isPinned:n,activeWorkspaceId:e})]})}),cF=(0,p.memo)(function(a){let{ctx:b,openPath:c,dragOverPath:d,branchDropdownNode:e,branchDropdownPos:f,nodeBranches:h,branchesLoading:i,checkingOutBranch:k,pullingRepo:l,activePaths:m,pins:n,isMobile:q,activeWorkspaceId:s,newFileParent:t,newFileName:v,fileCreateError:w,newFolderParent:x,newFolderName:y,folderError:z,sidebarScrollRef:A}=a,B=ct(a=>a.showHidden),C=(0,p.useRef)(null),D=(0,p.useCallback)(a=>{let c=("dir"===a.type||"app"===a.type||"node-app"===a.type)&&!a.expanded&&void 0===a.children;("file"===a.type||c)&&(C.current&&clearTimeout(C.current),C.current=setTimeout(()=>b.prefetch(a),120))},[b]),E=(0,p.useCallback)(()=>{C.current&&(clearTimeout(C.current),C.current=null)},[]),F=(0,p.useMemo)(()=>{let b=[],c=(a,d)=>{for(let e of a)!(!B&&e.name.startsWith("."))&&(b.push({kind:"row",node:e,depth:d}),"dir"===e.type&&(x===e.path&&b.push({kind:"newfolder",node:e,depth:d}),t===e.path&&b.push({kind:"newfile",node:e,depth:d})),("dir"===e.type||"app"===e.type||"node-app"===e.type)&&e.expanded&&(e.children&&e.children.length>0?c(e.children,d+1):e.children?.length===0&&b.push({kind:"empty",node:e,depth:d})))};return c(a.nodes,0),b},[a.nodes,t,x,B]);return(0,g.jsx)(g.Fragment,{children:F.map(a=>{let{node:p,depth:t}=a;if("row"===a.kind){let a=e===p.path;return(0,g.jsx)(cE,{node:p,depth:t,ctx:b,isMobile:q,activeWorkspaceId:s,sidebarScrollRef:A,isActive:c===p.path,isDragOver:d===p.path,isPinned:n.some(a=>a.path===p.path),isAgentActive:m.has(p.path),isPulling:l===p.path,branchOpen:a,branchPos:a?f:null,branches:p.git?h[p.path]??[]:[],branchLoading:!!p.git&&!!i[p.path],checkingOut:a?k:null,onHoverEnter:D,onHoverLeave:E},p.path)}return"newfolder"===a.kind?(0,g.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1",style:{paddingLeft:`${(t+1)*14+8}px`,...cB},children:[(0,g.jsx)("span",{className:"w-3.5 shrink-0"}),(0,g.jsx)(aP,{className:"h-4 w-4 shrink-0 text-warning"}),(0,g.jsx)("input",{className:"flex-1 bg-transparent text-sm outline-none border-b border-border min-w-0",placeholder:"Folder name",value:y,onChange:a=>b.setNewFolderName(a.target.value),onKeyDown:a=>{"Enter"===a.key&&b.handleCreateFolder(),"Escape"===a.key&&(b.setNewFolderParent(null),b.setNewFolderName(""))}}),z&&(0,g.jsx)("span",{className:"text-xs text-destructive",children:z}),(0,g.jsx)(u.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:b.handleCreateFolder,children:(0,g.jsx)(r.Check,{className:"h-3 w-3"})}),(0,g.jsx)(u.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:()=>{b.setNewFolderParent(null),b.setNewFolderName("")},children:(0,g.jsx)(o,{className:"h-3 w-3"})})]},`nf-${p.path}`):"newfile"===a.kind?(0,g.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1",style:{paddingLeft:`${(t+1)*14+8}px`,...cB},children:[(0,g.jsx)("span",{className:"w-3.5 shrink-0"}),(0,g.jsx)(j.FileText,{className:"h-4 w-4 shrink-0 text-accent"}),(0,g.jsx)("input",{autoFocus:!0,className:"flex-1 bg-transparent text-sm outline-none border-b border-border min-w-0",placeholder:"filename (default .md)",value:v,onChange:a=>b.setNewFileName(a.target.value),onKeyDown:a=>{"Enter"===a.key&&b.handleCreateFile(),"Escape"===a.key&&(b.setNewFileParent(null),b.setNewFileName(""))}}),w&&(0,g.jsx)("span",{className:"text-xs text-destructive",children:w}),(0,g.jsx)(u.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:b.handleCreateFile,children:(0,g.jsx)(r.Check,{className:"h-3 w-3"})}),(0,g.jsx)(u.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:()=>{b.setNewFileParent(null),b.setNewFileName("")},children:(0,g.jsx)(o,{className:"h-3 w-3"})})]},`ff-${p.path}`):(0,g.jsx)("div",{className:"text-xs text-muted-foreground/50 py-0.5",style:{paddingLeft:`${(t+1)*14+8+14+6+16+6}px`,...cB},children:"Empty"},`empty-${p.path}`)})})});function cG({doc:a,node:b,extraItems:c}){return(0,g.jsxs)(bV.DropdownMenu,{children:[(0,g.jsx)(bV.DropdownMenuTrigger,{asChild:!0,children:(0,g.jsx)(u.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"File actions",children:(0,g.jsx)(bU,{className:"h-3.5 w-3.5"})})}),(0,g.jsxs)(bV.DropdownMenuContent,{align:"end",className:"w-52",children:[(0,g.jsxs)(bV.DropdownMenuItem,{onClick:()=>a.copyPath(b.path),children:[(0,g.jsx)(aY.Copy,{className:"mr-2 h-3.5 w-3.5"}),"Copy path"]}),cy(b.name)&&(0,g.jsxs)(bV.DropdownMenuItem,{onClick:()=>a.copyWikiLink(b.name),children:[(0,g.jsx)(j.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy wiki link"]}),(0,g.jsx)(bV.DropdownMenuSeparator,{}),(0,g.jsxs)(bV.DropdownMenuItem,{onClick:()=>a.copyUrl(b.path),children:[(0,g.jsx)(bT,{className:"mr-2 h-3.5 w-3.5"}),"Copy URL"]}),cx(b.name)&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(bV.DropdownMenuSeparator,{}),(0,g.jsxs)(bV.DropdownMenuItem,{onClick:()=>void a.copyRawContent(b.path),children:[(0,g.jsx)(j.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy raw content"]}),(0,g.jsxs)(bV.DropdownMenuItem,{onClick:()=>void a.copyFormattedContent(b.path,b.name),children:[(0,g.jsx)(j.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy formatted content"]})]}),c&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(bV.DropdownMenuSeparator,{}),c]})]})]})}let cH=(0,h.default)("align-center",[["path",{d:"M17 12H7",key:"16if0g"}],["path",{d:"M19 18H5",key:"18s9l3"}],["path",{d:"M21 6H3",key:"1jwq7v"}]]);var cI=a.i(796873);let cJ=(0,h.default)("panel-left",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]);var cK=a.i(453590),cL=a.i(111939),cM=/[\\\/_+.#"@\[\(\{&]/,cN=/[\\\/_+.#"@\[\(\{&]/g,cO=/[\s-]/,cP=/[\s-]/g;function cQ(a){return a.toLowerCase().replace(cP," ")}var cR='[cmdk-group=""]',cS='[cmdk-group-items=""]',cT='[cmdk-item=""]',cU=`${cT}:not([aria-disabled="true"])`,cV="cmdk-item-select",cW="data-value",cX=(a,b,c)=>{var d;return d=a,function a(b,c,d,e,f,g,h){if(g===c.length)return f===b.length?1:.99;var i=`${f},${g}`;if(void 0!==h[i])return h[i];for(var j,k,l,m,n=e.charAt(g),o=d.indexOf(n,f),p=0;o>=0;)(j=a(b,c,d,e,o+1,g+1,h))>p&&(o===f?j*=1:cM.test(b.charAt(o-1))?(j*=.8,(l=b.slice(f,o-1).match(cN))&&f>0&&(j*=Math.pow(.999,l.length))):cO.test(b.charAt(o-1))?(j*=.9,(m=b.slice(f,o-1).match(cP))&&f>0&&(j*=Math.pow(.999,m.length))):(j*=.17,f>0&&(j*=Math.pow(.999,o-f))),b.charAt(o)!==c.charAt(g)&&(j*=.9999)),(j<.1&&d.charAt(o-1)===e.charAt(g+1)||e.charAt(g+1)===e.charAt(g)&&d.charAt(o-1)!==e.charAt(g))&&.1*(k=a(b,c,d,e,o+1,g+2,h))>j&&(j=.1*k),j>p&&(p=j),o=d.indexOf(n,o+1);return h[i]=p,p}(d=c&&c.length>0?`${d+" "+c.join(" ")}`:d,b,cQ(d),cQ(b),0,0,{})},cY=p.createContext(void 0),cZ=p.createContext(void 0),c$=p.createContext(void 0),c_=p.forwardRef((a,b)=>{let c=c9(()=>{var b,c;return{search:"",value:null!=(c=null!=(b=a.value)?b:a.defaultValue)?c:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),d=c9(()=>new Set),e=c9(()=>new Map),f=c9(()=>new Map),g=c9(()=>new Set),h=c7(a),{label:i,children:j,value:k,onValueChange:l,filter:m,shouldFilter:n,loop:o,disablePointerSelection:q=!1,vimBindings:r=!0,...s}=a,t=(0,y.useId)(),u=(0,y.useId)(),v=(0,y.useId)(),w=p.useRef(null),x=dc();c8(()=>{if(void 0!==k){let a=k.trim();c.current.value=a,z.emit()}},[k]),c8(()=>{x(6,F)},[]);let z=p.useMemo(()=>({subscribe:a=>(g.current.add(a),()=>g.current.delete(a)),snapshot:()=>c.current,setState:(a,b,d)=>{var e,f,g,i;if(!Object.is(c.current[a],b)){if(c.current[a]=b,"search"===a)E(),C(),x(1,D);else if("value"===a){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let a=document.getElementById(v);a?a.focus():null==(e=document.getElementById(t))||e.focus()}if(x(7,()=>{var a;c.current.selectedItemId=null==(a=G())?void 0:a.id,z.emit()}),d||x(5,F),(null==(f=h.current)?void 0:f.value)!==void 0){null==(i=(g=h.current).onValueChange)||i.call(g,null!=b?b:"");return}}z.emit()}},emit:()=>{g.current.forEach(a=>a())}}),[]),A=p.useMemo(()=>({value:(a,b,d)=>{var e;b!==(null==(e=f.current.get(a))?void 0:e.value)&&(f.current.set(a,{value:b,keywords:d}),c.current.filtered.items.set(a,B(b,d)),x(2,()=>{C(),z.emit()}))},item:(a,b)=>(d.current.add(a),b&&(e.current.has(b)?e.current.get(b).add(a):e.current.set(b,new Set([a]))),x(3,()=>{E(),C(),c.current.value||D(),z.emit()}),()=>{f.current.delete(a),d.current.delete(a),c.current.filtered.items.delete(a);let b=G();x(4,()=>{E(),(null==b?void 0:b.getAttribute("id"))===a&&D(),z.emit()})}),group:a=>(e.current.has(a)||e.current.set(a,new Set),()=>{f.current.delete(a),e.current.delete(a)}),filter:()=>h.current.shouldFilter,label:i||a["aria-label"],getDisablePointerSelection:()=>h.current.disablePointerSelection,listId:t,inputId:v,labelId:u,listInnerRef:w}),[]);function B(a,b){var d,e;let f=null!=(e=null==(d=h.current)?void 0:d.filter)?e:cX;return a?f(a,c.current.search,b):0}function C(){if(!c.current.search||!1===h.current.shouldFilter)return;let a=c.current.filtered.items,b=[];c.current.filtered.groups.forEach(c=>{let d=e.current.get(c),f=0;d.forEach(b=>{f=Math.max(a.get(b),f)}),b.push([c,f])});let d=w.current;H().sort((b,c)=>{var d,e;let f=b.getAttribute("id"),g=c.getAttribute("id");return(null!=(d=a.get(g))?d:0)-(null!=(e=a.get(f))?e:0)}).forEach(a=>{let b=a.closest(cS);b?b.appendChild(a.parentElement===b?a:a.closest(`${cS} > *`)):d.appendChild(a.parentElement===d?a:a.closest(`${cS} > *`))}),b.sort((a,b)=>b[1]-a[1]).forEach(a=>{var b;let c=null==(b=w.current)?void 0:b.querySelector(`${cR}[${cW}="${encodeURIComponent(a[0])}"]`);null==c||c.parentElement.appendChild(c)})}function D(){let a=H().find(a=>"true"!==a.getAttribute("aria-disabled")),b=null==a?void 0:a.getAttribute(cW);z.setState("value",b||void 0)}function E(){var a,b,g,i;if(!c.current.search||!1===h.current.shouldFilter){c.current.filtered.count=d.current.size;return}c.current.filtered.groups=new Set;let j=0;for(let e of d.current){let d=B(null!=(b=null==(a=f.current.get(e))?void 0:a.value)?b:"",null!=(i=null==(g=f.current.get(e))?void 0:g.keywords)?i:[]);c.current.filtered.items.set(e,d),d>0&&j++}for(let[a,b]of e.current)for(let d of b)if(c.current.filtered.items.get(d)>0){c.current.filtered.groups.add(a);break}c.current.filtered.count=j}function F(){var a,b,c;let d=G();d&&((null==(a=d.parentElement)?void 0:a.firstChild)===d&&(null==(c=null==(b=d.closest(cR))?void 0:b.querySelector('[cmdk-group-heading=""]'))||c.scrollIntoView({block:"nearest"})),d.scrollIntoView({block:"nearest"}))}function G(){var a;return null==(a=w.current)?void 0:a.querySelector(`${cT}[aria-selected="true"]`)}function H(){var a;return Array.from((null==(a=w.current)?void 0:a.querySelectorAll(cU))||[])}function I(a){let b=H()[a];b&&z.setState("value",b.getAttribute(cW))}function J(a){var b;let c=G(),d=H(),e=d.findIndex(a=>a===c),f=d[e+a];null!=(b=h.current)&&b.loop&&(f=e+a<0?d[d.length-1]:e+a===d.length?d[0]:d[e+a]),f&&z.setState("value",f.getAttribute(cW))}function K(a){let b=G(),c=null==b?void 0:b.closest(cR),d;for(;c&&!d;)d=null==(c=a>0?function(a,b){let c=a.nextElementSibling;for(;c;){if(c.matches(b))return c;c=c.nextElementSibling}}(c,cR):function(a,b){let c=a.previousElementSibling;for(;c;){if(c.matches(b))return c;c=c.previousElementSibling}}(c,cR))?void 0:c.querySelector(cU);d?z.setState("value",d.getAttribute(cW)):J(a)}let L=()=>I(H().length-1),M=a=>{a.preventDefault(),a.metaKey?L():a.altKey?K(1):J(1)},N=a=>{a.preventDefault(),a.metaKey?I(0):a.altKey?K(-1):J(-1)};return p.createElement(bf.div,{ref:b,tabIndex:-1,...s,"cmdk-root":"",onKeyDown:a=>{var b;null==(b=s.onKeyDown)||b.call(s,a);let c=a.nativeEvent.isComposing||229===a.keyCode;if(!(a.defaultPrevented||c))switch(a.key){case"n":case"j":r&&a.ctrlKey&&M(a);break;case"ArrowDown":M(a);break;case"p":case"k":r&&a.ctrlKey&&N(a);break;case"ArrowUp":N(a);break;case"Home":a.preventDefault(),I(0);break;case"End":a.preventDefault(),L();break;case"Enter":{a.preventDefault();let b=G();if(b){let a=new Event(cV);b.dispatchEvent(a)}}}}},p.createElement("label",{"cmdk-label":"",htmlFor:A.inputId,id:A.labelId,style:de},i),dd(a,a=>p.createElement(cZ.Provider,{value:z},p.createElement(cY.Provider,{value:A},a))))}),c0=p.forwardRef((a,b)=>{var c,d;let e=(0,y.useId)(),f=p.useRef(null),g=p.useContext(c$),h=p.useContext(cY),i=c7(a),j=null!=(d=null==(c=i.current)?void 0:c.forceMount)?d:null==g?void 0:g.forceMount;c8(()=>{if(!j)return h.item(e,null==g?void 0:g.id)},[j]);let k=db(e,f,[a.value,a.children,f],a.keywords),l=p.useContext(cZ),m=da(a=>a.value&&a.value===k.current),n=da(a=>!!j||!1===h.filter()||!a.search||a.filtered.items.get(e)>0);function o(){var a,b;q(),null==(b=(a=i.current).onSelect)||b.call(a,k.current)}function q(){l.setState("value",k.current,!0)}if(p.useEffect(()=>{let b=f.current;if(!(!b||a.disabled))return b.addEventListener(cV,o),()=>b.removeEventListener(cV,o)},[n,a.onSelect,a.disabled]),!n)return null;let{disabled:r,value:s,onSelect:t,forceMount:u,keywords:v,...x}=a;return p.createElement(bf.div,{ref:(0,w.composeRefs)(f,b),...x,id:e,"cmdk-item":"",role:"option","aria-disabled":!!r,"aria-selected":!!m,"data-disabled":!!r,"data-selected":!!m,onPointerMove:r||h.getDisablePointerSelection()?void 0:q,onClick:r?void 0:o},a.children)}),c1=p.forwardRef((a,b)=>{let{heading:c,children:d,forceMount:e,...f}=a,g=(0,y.useId)(),h=p.useRef(null),i=p.useRef(null),j=(0,y.useId)(),k=p.useContext(cY),l=da(a=>!!e||!1===k.filter()||!a.search||a.filtered.groups.has(g));c8(()=>k.group(g),[]),db(g,h,[a.value,a.heading,i]);let m=p.useMemo(()=>({id:g,forceMount:e}),[e]);return p.createElement(bf.div,{ref:(0,w.composeRefs)(h,b),...f,"cmdk-group":"",role:"presentation",hidden:!l||void 0},c&&p.createElement("div",{ref:i,"cmdk-group-heading":"","aria-hidden":!0,id:j},c),dd(a,a=>p.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":c?j:void 0},p.createElement(c$.Provider,{value:m},a))))}),c2=p.forwardRef((a,b)=>{let{alwaysRender:c,...d}=a,e=p.useRef(null),f=da(a=>!a.search);return c||f?p.createElement(bf.div,{ref:(0,w.composeRefs)(e,b),...d,"cmdk-separator":"",role:"separator"}):null}),c3=p.forwardRef((a,b)=>{let{onValueChange:c,...d}=a,e=null!=a.value,f=p.useContext(cZ),g=da(a=>a.search),h=da(a=>a.selectedItemId),i=p.useContext(cY);return p.useEffect(()=>{null!=a.value&&f.setState("search",a.value)},[a.value]),p.createElement(bf.input,{ref:b,...d,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":i.listId,"aria-labelledby":i.labelId,"aria-activedescendant":h,id:i.inputId,type:"text",value:e?a.value:g,onChange:a=>{e||f.setState("search",a.target.value),null==c||c(a.target.value)}})}),c4=p.forwardRef((a,b)=>{let{children:c,label:d="Suggestions",...e}=a,f=p.useRef(null),g=p.useRef(null),h=da(a=>a.selectedItemId),i=p.useContext(cY);return p.useEffect(()=>{if(g.current&&f.current){let a=g.current,b=f.current,c,d=new ResizeObserver(()=>{c=requestAnimationFrame(()=>{let c=a.offsetHeight;b.style.setProperty("--cmdk-list-height",c.toFixed(1)+"px")})});return d.observe(a),()=>{cancelAnimationFrame(c),d.unobserve(a)}}},[]),p.createElement(bf.div,{ref:(0,w.composeRefs)(f,b),...e,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":h,"aria-label":d,id:i.listId},dd(a,a=>p.createElement("div",{ref:(0,w.composeRefs)(g,i.listInnerRef),"cmdk-list-sizer":""},a)))}),c5=p.forwardRef((a,b)=>{let{open:c,onOpenChange:d,overlayClassName:e,contentClassName:f,container:g,...h}=a;return p.createElement(O,{open:c,onOpenChange:d},p.createElement(T,{container:g},p.createElement(V,{"cmdk-overlay":"",className:e}),p.createElement(Z,{"aria-label":a.label,"cmdk-dialog":"",className:f},p.createElement(c_,{ref:b,...h}))))}),c6=Object.assign(c_,{List:c4,Item:c0,Input:c3,Group:c1,Separator:c2,Dialog:c5,Empty:p.forwardRef((a,b)=>da(a=>0===a.filtered.count)?p.createElement(bf.div,{ref:b,...a,"cmdk-empty":"",role:"presentation"}):null),Loading:p.forwardRef((a,b)=>{let{progress:c,children:d,label:e="Loading...",...f}=a;return p.createElement(bf.div,{ref:b,...f,"cmdk-loading":"",role:"progressbar","aria-valuenow":c,"aria-valuemin":0,"aria-valuemax":100,"aria-label":e},dd(a,a=>p.createElement("div",{"aria-hidden":!0},a)))})});function c7(a){let b=p.useRef(a);return c8(()=>{b.current=a}),b}var c8=p.useEffect;function c9(a){let b=p.useRef();return void 0===b.current&&(b.current=a()),b}function da(a){let b=p.useContext(cZ),c=()=>a(b.snapshot());return p.useSyncExternalStore(b.subscribe,c,c)}function db(a,b,c,d=[]){let e=p.useRef(),f=p.useContext(cY);return c8(()=>{var g;let h=(()=>{var a;for(let b of c){if("string"==typeof b)return b.trim();if("object"==typeof b&&"current"in b)return b.current?null==(a=b.current.textContent)?void 0:a.trim():e.current}})(),i=d.map(a=>a.trim());f.value(a,h,i),null==(g=b.current)||g.setAttribute(cW,h),e.current=h}),e}var dc=()=>{let[a,b]=p.useState(),c=c9(()=>new Map);return c8(()=>{c.current.forEach(a=>a()),c.current=new Map},[a]),(a,d)=>{c.current.set(a,d),b({})}};function dd({asChild:a,children:b},c){let d;return a&&p.isValidElement(b)?p.cloneElement("function"==typeof(d=b.type)?d(b.props):"render"in d?d.render(b.props):b,{ref:b.ref},c(b.props.children)):c(b)}var de={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};let df=(0,h.default)("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]),dg=p.forwardRef(({className:a,...b},c)=>(0,g.jsx)(c6,{ref:c,className:(0,an.cn)("flex h-full w-full flex-col overflow-hidden rounded-sm bg-popover text-popover-foreground",a),...b}));function dh({children:a,shouldFilter:b,...c}){return(0,g.jsx)(O,{...c,children:(0,g.jsxs)(aI,{className:"overflow-hidden p-0 shadow-golden max-w-lg",children:[(0,g.jsx)(aL,{className:"sr-only",children:"Search"}),(0,g.jsx)(dg,{shouldFilter:b,className:"[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-normal [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5",children:a})]})})}dg.displayName=c6.displayName;let di=p.forwardRef(({className:a,...b},c)=>(0,g.jsxs)("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[(0,g.jsx)(df,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),(0,g.jsx)(c6.Input,{ref:c,className:(0,an.cn)("flex h-11 w-full rounded-sm bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",a),...b})]}));di.displayName=c6.Input.displayName;let dj=p.forwardRef(({className:a,...b},c)=>(0,g.jsx)(c6.List,{ref:c,className:(0,an.cn)("max-h-[300px] overflow-y-auto overflow-x-hidden",a),...b}));dj.displayName=c6.List.displayName;let dk=p.forwardRef((a,b)=>(0,g.jsx)(c6.Empty,{ref:b,className:"py-6 text-center text-sm text-muted-foreground",...a}));dk.displayName=c6.Empty.displayName;let dl=p.forwardRef(({className:a,...b},c)=>(0,g.jsx)(c6.Group,{ref:c,className:(0,an.cn)("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-normal [&_[cmdk-group-heading]]:text-muted-foreground",a),...b}));dl.displayName=c6.Group.displayName;let dm=p.forwardRef(({className:a,...b},c)=>(0,g.jsx)(c6.Separator,{ref:c,className:(0,an.cn)("-mx-1 h-px bg-border",a),...b}));dm.displayName=c6.Separator.displayName;let dn=p.forwardRef(({className:a,...b},c)=>(0,g.jsx)(c6.Item,{ref:c,className:(0,an.cn)("relative flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",a),...b}));dn.displayName=c6.Item.displayName;let dp=null,dq=null,dr=(0,aw.create)(a=>({query:"",results:[],loading:!1,truncated:!1,open:!1,setQuery:b=>a({query:b}),setOpen:b=>a({open:b}),clear:()=>{dq&&clearTimeout(dq),dp?.abort(),a({query:"",results:[],loading:!1,truncated:!1})},search:b=>(dq&&clearTimeout(dq),b.trim())?(a({loading:!0}),new Promise(c=>{dq=setTimeout(()=>{ds(a,b).finally(c)},150)})):(dp?.abort(),a({results:[],loading:!1,truncated:!1}),Promise.resolve())}));async function ds(a,b){dp?.abort();let c=new AbortController;dp=c;try{let d=await (0,bk.wsFetch)("/api/wiki/search",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:b,limit:30}),signal:c.signal});if(!d.ok)return void a({results:[],loading:!1,truncated:!1});let e=await d.json();if(c.signal.aborted)return;a({results:e.matches??[],truncated:!!e.truncated,loading:!1})}catch(b){"AbortError"!==b.name&&a({loading:!1})}}var dt=a.i(713033);function du({html:a}){let b=function(a){let b,c=[],d=/<mark>([\s\S]*?)<\/mark>/g,e=0;for(;null!==(b=d.exec(a));)b.index>e&&c.push({text:a.slice(e,b.index),mark:!1}),c.push({text:b[1]??"",mark:!0}),e=b.index+b[0].length;return e<a.length&&c.push({text:a.slice(e),mark:!1}),c}(a);return(0,g.jsx)(g.Fragment,{children:b.map((a,b)=>a.mark?(0,g.jsx)("mark",{className:"bg-yellow-200 dark:bg-yellow-700 rounded-[2px] px-[1px]",children:a.text},b):(0,g.jsx)("span",{children:a.text},b))})}function dv({onOpenFile:a,recents:b=[],onToggleSidebar:c=()=>void 0,onNewFile:d=()=>void 0,onCopyPath:e=()=>void 0}){let f=dr(a=>a.open),h=dr(a=>a.setOpen),j=dr(a=>a.query),k=dr(a=>a.setQuery),l=dr(a=>a.results),m=dr(a=>a.loading),n=dr(a=>a.truncated),o=dr(a=>a.search),{resolvedTheme:q,setTheme:r}=(0,cL.useTheme)(),s=bo(a=>a.toggle),t=(0,dt.useViewWidthStore)(a=>a.width),u=(0,dt.useViewWidthStore)(a=>a.cycle),v=j.trimStart(),w=""===v||v.startsWith(">"),x=""===v&&b.length>0,y=w?"":j;function z(a){a(),h(!1),k("")}(0,p.useEffect)(()=>{function a(a){(a.metaKey||a.ctrlKey)&&"k"===a.key.toLowerCase()&&(a.preventDefault(),h(!f))}return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[f,h]),(0,p.useEffect)(()=>{if(!f||w)return;let a=setTimeout(()=>{o(y)},120);return()=>clearTimeout(a)},[y,w,f,o]);let A=(dt.VIEW_WIDTH_ORDER.indexOf(t)+1)%dt.VIEW_WIDTH_ORDER.length,B=dt.VIEW_WIDTH_LABEL[dt.VIEW_WIDTH_ORDER[A]];return(0,g.jsxs)(dh,{open:f,onOpenChange:a=>{h(a),a||k("")},shouldFilter:!1,children:[(0,g.jsx)(di,{placeholder:"Search files… ( > for actions )",value:j,onValueChange:k}),(0,g.jsxs)(dj,{children:[x&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(dl,{heading:"Recent",children:b.map(b=>(0,g.jsxs)(dn,{value:`recent:${b.path}`,onSelect:()=>{a(b.path),h(!1),k("")},children:[(0,g.jsx)(a_,{className:"mr-2 h-4 w-4"}),(0,g.jsxs)("div",{className:"flex min-w-0 flex-col gap-0.5",children:[(0,g.jsx)("span",{className:"truncate font-medium",children:b.name}),(0,g.jsx)("span",{className:"truncate text-xs text-muted-foreground",children:b.path})]})]},b.path))}),(0,g.jsx)(dm,{})]}),w&&(0,g.jsxs)(dl,{heading:"Actions",children:[(0,g.jsxs)(dn,{value:"toggle-dark-mode",onSelect:()=>z(()=>r("dark"===q?"light":"dark")),children:["dark"===q?(0,g.jsx)(cK.Sun,{className:"mr-2 h-4 w-4"}):(0,g.jsx)(cI.Moon,{className:"mr-2 h-4 w-4"}),"dark"===q?"Switch to light mode":"Switch to dark mode"]}),(0,g.jsxs)(dn,{value:"toggle-ai-panel",onSelect:()=>z(s),children:[(0,g.jsx)(i,{className:"mr-2 h-4 w-4"}),"Toggle AI panel"]}),(0,g.jsxs)(dn,{value:"toggle-sidebar",onSelect:()=>z(c),children:[(0,g.jsx)(cJ,{className:"mr-2 h-4 w-4"}),"Toggle sidebar"]}),(0,g.jsxs)(dn,{value:"new-file",onSelect:()=>z(d),children:[(0,g.jsx)(bY,{className:"mr-2 h-4 w-4"}),"New file"]}),(0,g.jsxs)(dn,{value:"copy-path",onSelect:()=>z(e),children:[(0,g.jsx)(aY.Copy,{className:"mr-2 h-4 w-4"}),"Copy current file path"]}),(0,g.jsxs)(dn,{value:"cycle-view-width",onSelect:()=>z(u),children:[(0,g.jsx)(cH,{className:"mr-2 h-4 w-4"}),(0,g.jsxs)("span",{children:["Change view width"," ",(0,g.jsxs)("span",{className:"text-muted-foreground",children:["(",dt.VIEW_WIDTH_LABEL[t]," → ",B,")"]})]})]})]}),!w&&(0,g.jsxs)(g.Fragment,{children:[m&&(0,g.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:"Searching…"}),!m&&""!==y.trim()&&0===l.length&&(0,g.jsx)(dk,{children:"No matches."}),l.length>0&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(dm,{}),(0,g.jsx)(dl,{heading:n?"Top results (refine query for more)":"Results",children:l.map(b=>(0,g.jsx)(dn,{value:b.path,onSelect:()=>{a(b.path),h(!1),k("")},children:(0,g.jsxs)("div",{className:"flex min-w-0 flex-col gap-0.5",children:[(0,g.jsx)("span",{className:"truncate font-mono text-xs",children:b.path}),b.snippet&&(0,g.jsx)("span",{className:"truncate text-xs text-muted-foreground",children:(0,g.jsx)(du,{html:b.snippet})})]})},b.path))})]})]})]})]})}let dw=(0,h.default)("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]),dx=(0,h.default)("cloud-download",[["path",{d:"M12 13v8l-4-4",key:"1f5nwf"}],["path",{d:"m12 21 4-4",key:"1lfcce"}],["path",{d:"M4.393 15.269A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.436 8.284",key:"ui1hmy"}]]);var dy=a.i(410672);let dz=(0,h.default)("eye-off",[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]),dA=(0,h.default)("history",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]),dB=(0,h.default)("panel-left-close",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]]),dC=(0,h.default)("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]),dD=(0,h.default)("settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]),dE=(0,h.default)("type",[["path",{d:"M12 4v16",key:"1654pz"}],["path",{d:"M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2",key:"e0r10z"}],["path",{d:"M9 20h6",key:"s66wpe"}]]);function dF({onOpenFile:a}){let b=dr(a=>a.query),c=dr(a=>a.setQuery),d=dr(a=>a.results),e=dr(a=>a.loading),f=dr(a=>a.search),h=dr(a=>a.clear),[i,j]=(0,p.useState)(0),k=(0,p.useRef)(null);function l(b){let c=d[b];c&&(a(c.path),h())}return(0,p.useEffect)(()=>{j(0)},[d]),(0,p.useEffect)(()=>{let a=k.current?.querySelector(`[data-idx="${i}"]`);a?.scrollIntoView({block:"nearest"})},[i]),(0,g.jsxs)("div",{className:"flex flex-col gap-1 px-2 py-1.5",children:[(0,g.jsxs)("div",{className:"relative",children:[(0,g.jsx)(df,{className:"pointer-events-none absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 opacity-50"}),(0,g.jsx)("input",{type:"text",className:"w-full rounded-sm border bg-transparent py-1 pl-7 pr-2 text-xs outline-none focus:ring-1 focus:ring-ring",placeholder:"Search… (⌘K)",value:b,onChange:a=>{c(a.target.value),f(a.target.value)},onKeyDown:a=>{"Escape"===a.key?h():0!==d.length&&("ArrowDown"===a.key?(a.preventDefault(),j(a=>(a+1)%d.length)):"ArrowUp"===a.key?(a.preventDefault(),j(a=>(a-1+d.length)%d.length)):"Enter"===a.key&&(a.preventDefault(),l(i)))}})]}),""!==b.trim()&&(0,g.jsxs)("div",{ref:k,className:"max-h-64 overflow-y-auto rounded-sm border bg-popover",children:[e&&(0,g.jsx)("div",{className:"px-2 py-1 text-xs text-muted-foreground",children:"Searching…"}),!e&&0===d.length&&(0,g.jsx)("div",{className:"px-2 py-1 text-xs text-muted-foreground",children:"No matches"}),d.map((a,b)=>(0,g.jsxs)("button",{type:"button","data-idx":b,onClick:()=>l(b),onMouseEnter:()=>j(b),className:`block w-full px-2 py-1 text-left ${b===i?"bg-accent":"hover:bg-accent"}`,children:[(0,g.jsx)("div",{className:"truncate font-mono text-xs",children:a.path}),a.snippet&&(0,g.jsx)("div",{className:"truncate text-[10px] text-muted-foreground",children:(0,g.jsx)(du,{html:a.snippet})})]},a.path))]})]})}var dG=a.i(591119);function dH(a){let b=new Date(a).getTime();if(!Number.isFinite(b))return"";let c=Math.floor(Math.max(0,Date.now()-b)/1e3);if(c<60)return"just now";let d=Math.floor(c/60);if(d<60)return`${d}m ago`;let e=Math.floor(d/60);return e<24?`${e}h ago`:`${Math.floor(e/24)}d ago`}function dI({workspaces:a,activeWorkspaceId:b,rootPath:c,isWsAdmin:d,refreshingWsId:e,switchingBranch:f,switchingBranchName:h,wsBranches:i,branchPickerWsId:j,wsBranchPos:k,onSwitchWorkspace:l,onRefreshWorkspace:m,onPromptDeleteWorkspace:n,onAddWorkspace:o,setBranchPickerWsId:p,setWsBranchPos:q,loadWsBranches:s,handleSwitchBranch:t}){return(0,g.jsxs)("div",{className:"border-t px-2 py-2 bg-muted shrink-0",children:[(0,g.jsxs)(bV.DropdownMenu,{modal:!1,onOpenChange:a=>{a||(p(null),q(null))},children:[(0,g.jsx)(bV.DropdownMenuTrigger,{asChild:!0,children:(0,g.jsxs)(u.Button,{size:"sm",variant:"ghost",className:"w-full h-auto justify-between gap-2 px-2 py-1.5 text-left",title:c??"",children:[(0,g.jsxs)("span",{className:"flex flex-col min-w-0",children:[(0,g.jsx)("span",{className:"truncate text-xs font-medium",children:a.find(a=>a.id===b)?.name??"Workspace"}),(0,g.jsx)("span",{className:"truncate text-[10px] text-muted-foreground font-mono",children:c??""})]}),(0,g.jsx)(dw,{className:"h-3.5 w-3.5 shrink-0 opacity-60"})]})}),(0,g.jsxs)(bV.DropdownMenuContent,{align:"start",className:"w-[var(--radix-dropdown-menu-trigger-width)]",onInteractOutside:a=>{a.target?.closest?.("[data-branch-portal]")&&a.preventDefault()},children:[a.map(a=>(0,g.jsxs)(bV.DropdownMenuItem,{onClick:()=>void l(a.id),onPointerMove:a=>a.preventDefault(),onPointerLeave:a=>a.preventDefault(),className:(0,an.cn)("gap-2",a.id===b&&"font-medium"),children:[a.id===b?(0,g.jsx)(r.Check,{className:"h-3.5 w-3.5 shrink-0"}):(0,g.jsx)("span",{className:"w-3.5 shrink-0"}),(0,g.jsxs)("span",{className:"flex flex-col min-w-0 flex-1",children:[(0,g.jsxs)("span",{className:"flex items-center gap-1.5 truncate",children:[(0,g.jsx)("span",{className:"truncate",children:a.name}),a.git?d?(0,g.jsxs)("button",{"data-branch-trigger":!0,type:"button",className:"inline-flex items-center gap-0.5 rounded bg-muted px-1.5 text-[10px] text-muted-foreground font-normal shrink-0 hover:bg-accent",title:"Switch branch",disabled:f===a.id,onClick:b=>{if(b.stopPropagation(),b.preventDefault(),j===a.id){p(null),q(null);return}let c=b.currentTarget.getBoundingClientRect();q({top:c.bottom+4,left:c.left}),p(a.id),s(a.id)},children:[(0,g.jsx)(aR,{className:"h-2.5 w-2.5"})," ",a.git.branch??"branch"]}):(0,g.jsxs)("span",{className:"inline-flex items-center gap-0.5 rounded bg-muted px-1.5 text-[10px] text-muted-foreground font-normal shrink-0",children:[(0,g.jsx)(aR,{className:"h-2.5 w-2.5"})," ",a.git.branch??"read-only"]}):a.ssh?(0,g.jsxs)("span",{className:"inline-flex items-center gap-0.5 rounded bg-muted px-1.5 text-[10px] text-muted-foreground font-normal shrink-0",children:[(0,g.jsx)(aT,{className:"h-2.5 w-2.5"})," ",a.ssh.host]}):a.readOnly?(0,g.jsxs)("span",{className:"inline-flex items-center gap-0.5 rounded bg-muted px-1.5 text-[10px] text-muted-foreground font-normal shrink-0",children:[(0,g.jsx)(aR,{className:"h-2.5 w-2.5"})," read-only"]}):null]}),(0,g.jsx)("span",{className:"truncate text-[10px] text-muted-foreground font-mono",children:a.rootDir}),a.git?.lastPulledAt&&dH(a.git.lastPulledAt)&&(0,g.jsxs)("span",{className:"text-[10px] text-muted-foreground/70",children:["synced ",dH(a.git.lastPulledAt)]})]}),d&&a.git&&(0,g.jsx)("button",{className:(0,an.cn)("shrink-0 rounded p-0.5 hover:bg-accent transition-colors",a.git.lastError?"text-destructive":"text-muted-foreground hover:text-foreground"),title:a.git.lastError?`Last refresh failed: ${a.git.lastError}`:"Refresh",disabled:e===a.id,onClick:b=>{b.stopPropagation(),b.preventDefault(),m(a.id)},children:(0,g.jsx)(br,{className:(0,an.cn)("h-3.5 w-3.5",e===a.id&&"animate-spin")})}),d&&(0,g.jsx)("button",{className:"shrink-0 rounded p-0.5 text-muted-foreground hover:text-destructive hover:bg-destructive/10 transition-colors",title:"Delete workspace (does not delete files)",onClick:b=>{b.stopPropagation(),n(a.id)},children:(0,g.jsx)(a$,{className:"h-3.5 w-3.5"})})]},a.id)),d&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(bV.DropdownMenuSeparator,{}),(0,g.jsxs)(bV.DropdownMenuItem,{onClick:o,children:[(0,g.jsx)(bZ,{className:"mr-2 h-3.5 w-3.5"}),"Add workspace…"]})]})]})]}),(()=>{if(!j||!k)return null;let b=a.find(a=>a.id===j);return b?(0,g.jsx)(b0,{pos:k,branches:(i[b.id]??[]).map(a=>({name:a,current:a===b.git?.branch})),loading:!i[b.id],busyName:f===b.id?h:null,disabled:f===b.id,onPick:a=>{t(b.id,a)},onClose:()=>{p(null),q(null)}}):null})()]})}let dJ=(0,aw.create)((a,b)=>({pins:[],loadForWorkspace:b=>{a({pins:[]})},toggle:(b,c)=>{let d=[];a({pins:d.some(a=>a.path===b.path)?d.filter(a=>a.path!==b.path):[...d,b]})},isPinned:a=>b().pins.some(b=>b.path===a)})),dK=(0,aw.create)(a=>({width:288,setWidth:b=>{a({width:Number.isNaN(b)?288:Math.min(600,Math.max(200,Math.round(b)))})}}));function dL(a){return a.split("/").pop()??a}function dM({workspace:a,doc:b,fileTree:c,upload:d,isMobile:e,hideChrome:f,sidebarCollapsed:h,setSidebarCollapsed:k,sidebarResizing:l,setSidebarResizing:n,sidebarWidth:p,setSidebarWidth:s,collapsed:t,setCollapsed:v,createEntry:w,setCreateEntry:x,handleCreateFile:y,handleCreateFolder:z,dragOverPath:A,setDragOverPath:B,handleDragOver:C,handleDropOnFolder:D,sidebarScrollRef:E,treeCtx:F,pins:G,recents:H,activePaths:I,setDialogs:J,handleRefreshWorkspace:K}){let{resolvedTheme:L,setTheme:M}=(0,cL.useTheme)(),N=cs(a=>a.humanize),O=ct(a=>a.showHidden);return(0,g.jsxs)(g.Fragment,{children:[!f&&!h&&e&&(0,g.jsx)("div",{className:"fixed inset-0 z-40 bg-overlay backdrop-blur-[1px] md:hidden",onClick:()=>k(!0),"aria-hidden":!0}),!f&&!h&&(0,g.jsxs)(dG.Card,{style:e?void 0:{width:p},className:"fixed inset-y-0 left-0 z-50 w-[85vw] max-w-[20rem] md:relative md:z-auto md:w-auto md:max-w-none flex flex-col shrink-0 overflow-hidden rounded-none border-r border-l-0 border-t-0 border-b-0",children:[(0,g.jsxs)("div",{className:"flex items-center justify-between gap-2 px-3 py-2 border-b bg-muted shrink-0",children:[(0,g.jsxs)("div",{className:"flex min-w-0 items-center gap-1.5",title:"Wiki Viewer v2.9.3",children:[(0,g.jsx)("img",{src:(0,au.apiUrl)("/logo.svg"),alt:"Wiki Viewer",className:"h-5 w-5 shrink-0"}),(0,g.jsx)("span",{className:"truncate text-xs font-semibold leading-5 tracking-tight translate-y-[0.5px]",children:"Wiki Viewer"})]}),(0,g.jsx)(u.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0 shrink-0",title:"Collapse sidebar",onClick:()=>k(!0),children:(0,g.jsx)(dB,{className:"h-3.5 w-3.5"})})]}),(0,g.jsxs)("div",{className:"flex items-center justify-between gap-1 px-3 py-1.5 border-b bg-muted/50 shrink-0",children:[(0,g.jsxs)(bV.DropdownMenu,{children:[(0,g.jsx)(bV.DropdownMenuTrigger,{asChild:!0,children:(0,g.jsxs)(u.Button,{size:"sm",variant:"ghost",className:"h-7 gap-1 px-2 text-xs",disabled:d.uploading,children:[d.uploading?(0,g.jsx)(m.Loader2,{className:"h-3.5 w-3.5 animate-spin"}):(0,g.jsx)(dC,{className:"h-3.5 w-3.5"}),"New",(0,g.jsx)(dw,{className:"h-3 w-3 opacity-60"})]})}),(0,g.jsxs)(bV.DropdownMenuContent,{align:"start",className:"w-44",children:[(0,g.jsxs)(bV.DropdownMenuItem,{onClick:()=>x(a=>({...a,file:{...a.file,parent:"",name:"",error:null}})),children:[(0,g.jsx)(bY,{className:"mr-2 h-3.5 w-3.5"}),"New file"]}),(0,g.jsxs)(bV.DropdownMenuItem,{onClick:()=>x(a=>({...a,folder:{...a.folder,parent:"",name:"",error:null}})),children:[(0,g.jsx)(bZ,{className:"mr-2 h-3.5 w-3.5"}),"New folder"]}),(0,g.jsxs)(bV.DropdownMenuItem,{onClick:()=>d.triggerUpload(""),disabled:d.uploading,children:[(0,g.jsx)(b_,{className:"mr-2 h-3.5 w-3.5"}),"Upload"]})]})]}),(0,g.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,g.jsx)(u.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"Refresh tree",onClick:()=>void c.refreshTree(),disabled:c.refreshingTree,children:c.refreshingTree?(0,g.jsx)(m.Loader2,{className:"h-3.5 w-3.5 animate-spin"}):(0,g.jsx)(br,{className:"h-3.5 w-3.5"})}),(0,g.jsx)(u.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"AI Agent panel",onClick:()=>{bo.getState().toggle(),e&&k(!0)},children:(0,g.jsx)(i,{className:"h-3.5 w-3.5"})}),(0,g.jsxs)(bV.DropdownMenu,{children:[(0,g.jsx)(bV.DropdownMenuTrigger,{asChild:!0,children:(0,g.jsx)(u.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"More actions",children:(0,g.jsx)(bU,{className:"h-3.5 w-3.5"})})}),(0,g.jsxs)(bV.DropdownMenuContent,{align:"end",className:"w-48",children:[a.isWsAdmin&&a.workspaces.find(b=>b.id===a.activeWorkspaceId)?.git&&(0,g.jsxs)(bV.DropdownMenuItem,{onClick:()=>{a.activeWorkspaceId&&K(a.activeWorkspaceId)},disabled:a.refreshingWsId===a.activeWorkspaceId,children:[a.refreshingWsId===a.activeWorkspaceId?(0,g.jsx)(m.Loader2,{className:"mr-2 h-3.5 w-3.5 animate-spin"}):(0,g.jsx)(dx,{className:"mr-2 h-3.5 w-3.5"}),"Pull latest"]}),(0,g.jsxs)(bV.DropdownMenuItem,{onClick:()=>ct.getState().toggle(),children:[O?(0,g.jsx)(dz,{className:"mr-2 h-3.5 w-3.5"}):(0,g.jsx)(dy.Eye,{className:"mr-2 h-3.5 w-3.5"}),O?"Hide hidden files":"Show hidden files"]}),(0,g.jsxs)(bV.DropdownMenuItem,{onClick:()=>cs.getState().toggle(),children:[(0,g.jsx)(dE,{className:"mr-2 h-3.5 w-3.5"}),N?"Raw file names":"Humanize names"]}),(0,g.jsxs)(bV.DropdownMenuItem,{onClick:()=>M("dark"===L?"light":"dark"),children:["dark"===L?(0,g.jsx)(cK.Sun,{className:"mr-2 h-3.5 w-3.5"}):(0,g.jsx)(cI.Moon,{className:"mr-2 h-3.5 w-3.5"}),"dark"===L?"Light mode":"Dark mode"]}),(0,g.jsx)(bV.DropdownMenuSeparator,{}),(0,g.jsxs)(bV.DropdownMenuItem,{onClick:()=>J(a=>({...a,settingsOpen:!0})),children:[(0,g.jsx)(dD,{className:"mr-2 h-3.5 w-3.5"}),"Settings"]})]})]})]})]}),d.uploadError&&(0,g.jsxs)("div",{className:"flex items-center gap-1.5 px-3 py-1.5 text-xs text-destructive bg-destructive/10 shrink-0",children:[(0,g.jsx)(q.AlertCircle,{className:"h-3.5 w-3.5 shrink-0"}),d.uploadError]}),""===w.folder.parent&&(0,g.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1 border-b shrink-0",children:[(0,g.jsx)(aP,{className:"h-4 w-4 shrink-0 text-warning"}),(0,g.jsx)("input",{className:"flex-1 bg-transparent text-sm outline-none border-b border-border min-w-0",placeholder:"Folder name",value:w.folder.name,onChange:a=>x(b=>({...b,folder:{...b.folder,name:a.target.value}})),onKeyDown:a=>{"Enter"===a.key&&z(),"Escape"===a.key&&x(a=>({...a,folder:{...a.folder,parent:null,name:""}}))}}),w.folder.error&&(0,g.jsx)("span",{className:"text-xs text-destructive",children:w.folder.error}),(0,g.jsx)(u.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:z,children:(0,g.jsx)(r.Check,{className:"h-3 w-3"})}),(0,g.jsx)(u.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:()=>x(a=>({...a,folder:{...a.folder,parent:null,name:""}})),children:(0,g.jsx)(o,{className:"h-3 w-3"})})]}),""===w.file.parent&&(0,g.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1 border-b shrink-0",children:[(0,g.jsx)(j.FileText,{className:"h-4 w-4 shrink-0 text-accent"}),(0,g.jsx)("input",{autoFocus:!0,className:"flex-1 bg-transparent text-sm outline-none border-b border-border min-w-0",placeholder:"filename (default .md)",value:w.file.name,onChange:a=>x(b=>({...b,file:{...b.file,name:a.target.value}})),onKeyDown:a=>{"Enter"===a.key&&y(),"Escape"===a.key&&x(a=>({...a,file:{...a.file,parent:null,name:""}}))}}),w.file.error&&(0,g.jsx)("span",{className:"text-xs text-destructive",children:w.file.error}),(0,g.jsx)(u.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:y,children:(0,g.jsx)(r.Check,{className:"h-3 w-3"})}),(0,g.jsx)(u.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:()=>x(a=>({...a,file:{...a.file,parent:null,name:""}})),children:(0,g.jsx)(o,{className:"h-3 w-3"})})]}),(0,g.jsx)("div",{className:"border-b",children:(0,g.jsx)(dF,{onOpenFile:b.openFromSearch})}),(0,g.jsxs)("div",{ref:E,className:(0,an.cn)("flex-1 overflow-auto py-1 editorial-file-tree",""===A&&"ring-2 ring-inset ring-primary bg-primary/5"),onDragOver:a=>C(a,"","root"),onDragLeave:a=>{a.currentTarget.contains(a.relatedTarget)||B(null)},onDrop:a=>D(a,""),children:[G.length>0&&(0,g.jsxs)("div",{className:"border-b mb-1",children:[(0,g.jsxs)("button",{type:"button",className:"flex w-full items-center gap-1 px-2 py-1 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground hover:text-foreground",onClick:()=>v(a=>({...a,pinned:!a.pinned})),children:[t.pinned?(0,g.jsx)(aO.ChevronRight,{className:"h-3 w-3"}):(0,g.jsx)(dw,{className:"h-3 w-3"}),(0,g.jsx)(aV,{className:"h-3 w-3"}),"Pinned",(0,g.jsx)("span",{className:"ml-auto text-[9px] tabular-nums opacity-60",children:G.length})]}),!t.pinned&&G.map(c=>(0,g.jsxs)(b9,{children:[(0,g.jsx)(cb,{asChild:!0,children:(0,g.jsxs)("div",{role:"button",tabIndex:0,className:(0,an.cn)("group flex items-center gap-1.5 rounded-sm px-2 py-1 text-sm cursor-pointer transition-colors select-none",b.openFile?.path===c.path?"bg-accent-soft text-foreground font-medium":"hover:bg-muted"),onClick:()=>{b.openPinnedEntry(c)},onKeyDown:a=>{("Enter"===a.key||" "===a.key)&&(a.preventDefault(),b.openPinnedEntry(c))},children:[(0,g.jsx)(cD,{name:c.name,type:c.type??"file"}),(0,g.jsx)("span",{className:"min-w-0 flex-1 truncate text-xs",title:N?c.name:void 0,children:N?dL(c.name):c.name}),(0,g.jsx)("span",{className:"max-w-[80px] truncate text-[10px] text-muted-foreground/60",children:c.path.split("/").slice(0,-1).join("/")}),(0,g.jsx)("button",{type:"button",className:"hover-reveal shrink-0 rounded p-0.5 text-muted-foreground/50 opacity-0 transition-colors hover:bg-muted hover:text-amber-400 group-hover:opacity-100 focus:opacity-100",title:"Remove from pinned",onClick:b=>{b.stopPropagation(),dJ.getState().toggle({path:c.path,name:c.name},a.activeWorkspaceId)},children:(0,g.jsx)(o,{className:"h-3 w-3"})})]})}),(0,g.jsx)(cC,{node:{path:c.path,name:c.name,type:c.type??"file"},ctx:F,isPinned:!0,activeWorkspaceId:a.activeWorkspaceId})]},c.path))]}),H.length>0&&(0,g.jsxs)("div",{className:"border-b mb-1",children:[(0,g.jsxs)("button",{type:"button",className:"flex w-full items-center gap-1 px-2 py-1 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground hover:text-foreground",onClick:()=>v(a=>({...a,recent:!a.recent})),children:[t.recent?(0,g.jsx)(aO.ChevronRight,{className:"h-3 w-3"}):(0,g.jsx)(dw,{className:"h-3 w-3"}),(0,g.jsx)(dA,{className:"h-3 w-3"}),"Recent",(0,g.jsx)("span",{className:"ml-auto text-[9px] tabular-nums opacity-60",children:H.length})]}),!t.recent&&H.slice(0,8).map(c=>(0,g.jsxs)(b9,{children:[(0,g.jsx)(cb,{asChild:!0,children:(0,g.jsxs)("div",{role:"button",tabIndex:0,className:(0,an.cn)("flex items-center gap-1.5 rounded-sm px-2 py-1 text-sm cursor-pointer transition-colors select-none",b.openFile?.path===c.path?"bg-accent-soft text-foreground font-medium":"hover:bg-muted"),onClick:()=>{b.openViewer({path:c.path,name:c.name,type:c.type??"file",modifiedAt:""}),e&&k(!0)},onKeyDown:a=>{("Enter"===a.key||" "===a.key)&&(a.preventDefault(),b.openViewer({path:c.path,name:c.name,type:c.type??"file",modifiedAt:""}))},children:[(0,g.jsx)(cD,{name:c.name,type:c.type??"file"}),(0,g.jsx)("span",{className:"flex-1 truncate text-xs",title:N?c.name:void 0,children:N?dL(c.name):c.name}),(0,g.jsx)("span",{className:"text-[10px] text-muted-foreground/60 truncate max-w-[80px]",children:c.path.split("/").slice(0,-1).join("/")})]})}),(0,g.jsx)(cC,{node:{path:c.path,name:c.name,type:c.type??"file"},ctx:F,isPinned:G.some(a=>a.path===c.path),activeWorkspaceId:a.activeWorkspaceId})]},c.path))]}),c.rootLoading?(0,g.jsx)("div",{className:"flex justify-center py-6",children:(0,g.jsx)(m.Loader2,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):0===c.roots.length?(0,g.jsxs)("div",{className:"flex flex-col items-center gap-3 px-4 py-8 text-center",children:[(0,g.jsx)("div",{className:"rounded-full bg-muted p-3",children:(0,g.jsx)(j.FileText,{className:"h-6 w-6 text-muted-foreground"})}),(0,g.jsxs)("div",{className:"space-y-1",children:[(0,g.jsx)("p",{className:"text-sm font-medium",children:"No files yet"}),(0,g.jsx)("p",{className:"text-xs text-muted-foreground",children:"Upload files or add them to the configured directory"})]}),(0,g.jsxs)(u.Button,{size:"sm",variant:"outline",className:"w-full gap-1.5 max-w-[180px]",onClick:()=>d.triggerUpload(""),disabled:d.uploading,children:[d.uploading?(0,g.jsx)(m.Loader2,{className:"h-3.5 w-3.5 animate-spin"}):(0,g.jsx)(b_,{className:"h-3.5 w-3.5"}),"Upload Files"]})]}):(0,g.jsx)(cF,{ctx:F,nodes:c.roots,openPath:b.openFile?.path??null,dragOverPath:A,branchDropdownNode:c.branchDropdownNode,branchDropdownPos:c.branchDropdownPos,nodeBranches:c.nodeBranches,branchesLoading:c.branchesLoading,checkingOutBranch:c.checkingOutBranch,pullingRepo:c.pullingRepo,activePaths:I,pins:G,isMobile:e,activeWorkspaceId:a.activeWorkspaceId,newFileParent:w.file.parent,newFileName:w.file.name,fileCreateError:w.file.error,newFolderParent:w.folder.parent,newFolderName:w.folder.name,folderError:w.folder.error,sidebarScrollRef:E})]}),(0,g.jsx)(dI,{workspaces:a.workspaces,activeWorkspaceId:a.activeWorkspaceId,rootPath:a.rootPath,isWsAdmin:a.isWsAdmin,refreshingWsId:a.refreshingWsId,switchingBranch:a.switchingBranch,switchingBranchName:a.switchingBranchName,wsBranches:a.wsBranches,branchPickerWsId:a.branchPickerWsId,wsBranchPos:a.wsBranchPos,onSwitchWorkspace:b=>void a.switchWorkspace(b),onRefreshWorkspace:a.handleRefreshWorkspace,onPromptDeleteWorkspace:b=>a.setDeletingWorkspaceId(b),onAddWorkspace:()=>a.setAddingWorkspace(!0),setBranchPickerWsId:a.setBranchPickerWsId,setWsBranchPos:a.setWsBranchPos,loadWsBranches:a.loadWsBranches,handleSwitchBranch:a.handleSwitchBranch}),(0,g.jsx)("div",{role:"separator","aria-orientation":"vertical","aria-label":"Resize sidebar",title:"Drag to resize",onMouseDown:a=>{a.preventDefault();let b=a.clientX;n(!0);let c=document.body.style.cursor,d=document.body.style.userSelect;document.body.style.cursor="col-resize",document.body.style.userSelect="none";let e=a=>{s(p+(a.clientX-b))},f=()=>{n(!1),document.body.style.cursor=c,document.body.style.userSelect=d,window.removeEventListener("mousemove",e),window.removeEventListener("mouseup",f)};window.addEventListener("mousemove",e),window.addEventListener("mouseup",f)},onDoubleClick:()=>s(288),onKeyDown:a=>{"ArrowLeft"===a.key?(a.preventDefault(),s(p-16)):"ArrowRight"===a.key&&(a.preventDefault(),s(p+16))},tabIndex:0,"aria-valuemin":200,"aria-valuemax":600,"aria-valuenow":p,className:(0,an.cn)("absolute right-0 top-0 z-20 h-full w-1.5 cursor-col-resize -mr-px transition-colors hover:bg-primary/40 focus:bg-primary/40 focus:outline-none hidden md:block",l&&"bg-primary/60")})]})]})}function dN({workspace:a,doc:b,fileTree:c,upload:d,isMobile:e,hideChrome:f,sidebarCollapsed:h,setSidebarCollapsed:i,pins:j,recents:k,activePaths:l,setDeleting:m,setDialogs:n}){let[o,q]=(0,p.useState)(!1),[r,s]=(0,p.useState)(null),[t,u]=(0,p.useState)({pinned:!1,recent:!0}),[v,w]=(0,p.useState)({file:{parent:null,name:"",error:null},folder:{parent:null,name:"",error:null}}),x=(0,p.useRef)(null),y=(0,p.useRef)(null),z=dK(a=>a.width),A=dK(a=>a.setWidth),B=(0,p.useCallback)(async()=>{let a=v.file.name.trim();if(!a||null===v.file.parent)return;w(a=>({...a,file:{...a.file,error:null}}));let d=a.includes(".")?a:`${a}.md`,e=v.file.parent?`${v.file.parent}/${d}`:d,f=await fetch((0,bk.withWs)("/api/wiki/new-file"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e})});if(f.ok){let a=v.file.parent;w(a=>({...a,file:{parent:null,name:"",error:null}})),await c.reloadDir(a),b.openViewer({path:e,name:d,type:"file",modifiedAt:new Date().toISOString()})}else{let a=await f.json();w(b=>({...b,file:{...b.file,error:a.error??"Failed"}}))}},[v.file.parent,v.file.name,c,b]),C=(0,p.useCallback)(async()=>{let a=v.folder.name.trim();if(!a||null===v.folder.parent)return;w(a=>({...a,folder:{...a.folder,error:null}}));let b=v.folder.parent?`${v.folder.parent}/${a}`:a,d=await fetch((0,bk.withWs)("/api/wiki/folder"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:b})});if(d.ok){let a=v.folder.parent;w(a=>({...a,folder:{parent:null,name:"",error:null}})),await c.reloadDir(a)}else{let a=await d.json();w(b=>({...b,folder:{...b.folder,error:a.error??"Failed"}}))}},[v.folder.parent,v.folder.name,c]);function D(a,b,c){a.preventDefault(),a.stopPropagation();let d=y.current;if(!d){Array.from(a.dataTransfer.types).includes("Files")&&(a.dataTransfer.dropEffect="copy",s("root"===c?"":b));return}d.path===b||b.startsWith(`${d.path}/`)||(a.dataTransfer.dropEffect="move",s("root"===c?"":b))}async function E(a,e){a.preventDefault(),a.stopPropagation(),s(null);let f=y.current;if(y.current=null,!f){a.dataTransfer.files.length>0&&await d.doUpload(a.dataTransfer.files,e);return}if(f.path===e||e.startsWith(`${f.path}/`))return;let g=e?`${e}/${f.name}`:f.name;if(g!==f.path&&(await fetch((0,bk.withWs)("/api/wiki/move"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({from:f.path,to:g})})).ok){let a=f.path.includes("/")?f.path.split("/").slice(0,-1).join("/"):"";await c.reloadDir(a),e!==a&&await c.reloadDir(e),b.openFile?.path===f.path&&b.openViewer({path:g,name:f.name,type:f.type,modifiedAt:f.modifiedAt})}}let F=(0,p.useRef)(null);F.current={toggleFolder:a=>void c.toggleFolder(a),openViewer:a=>void b.openViewer(a),copyPath:a=>b.copyPath(a),copyWikiLink:a=>b.copyWikiLink(a),copyUrl:a=>b.copyUrl(a),copyRawContent:a=>void b.copyRawContent(a),copyFormattedContent:(a,c)=>void b.copyFormattedContent(a,c),handleDownload:function(a){let b=(0,bk.withWs)(`/api/wiki/download?path=${encodeURIComponent(a.path)}`),c=document.createElement("a");c.href=b,c.download="file"===a.type?a.name:`${a.name}.zip`,document.body.appendChild(c),c.click(),c.remove()},triggerUpload:a=>d.triggerUpload(a),handleCreateFile:B,handleCreateFolder:C,handleDragStart:function(a,b){y.current=b,a.dataTransfer.effectAllowed="move",a.dataTransfer.setData("text/plain",b.path)},handleDragOver:D,handleDropOnFolder:(a,b)=>void E(a,b),handleGitPull:(a,b)=>void c.handleGitPull(a,b),handleCheckout:(a,b,d)=>void c.handleCheckout(a,b,d),loadBranches:a=>void c.loadBranches(a),prefetch:a=>void c.prefetch(a),togglePin:(a,b)=>dJ.getState().toggle({path:a.path,name:a.name,type:a.type},b),setDragOverPath:s,setSidebarCollapsed:i,setBranchDropdownNode:a=>c.setBranchDropdownNode(a),setBranchDropdownPos:a=>c.setBranchDropdownPos(a),setNewFileParent:a=>w(b=>({...b,file:{...b.file,parent:a,error:null}})),setNewFileName:a=>w(b=>({...b,file:{...b.file,name:a}})),setFileCreateError:a=>w(b=>({...b,file:{...b.file,error:a}})),setNewFolderParent:a=>w(b=>({...b,folder:{...b.folder,parent:a,error:null}})),setNewFolderName:a=>w(b=>({...b,folder:{...b.folder,name:a}})),setFolderError:a=>w(b=>({...b,folder:{...b.folder,error:a}})),setDeletingPath:a=>m(b=>({...b,path:a})),setDeletingIsDir:a=>m(b=>({...b,isDir:a}))};let G=(0,p.useMemo)(()=>({toggleFolder:a=>F.current.toggleFolder(a),openViewer:a=>F.current.openViewer(a),copyPath:a=>F.current.copyPath(a),copyWikiLink:a=>F.current.copyWikiLink(a),copyUrl:a=>F.current.copyUrl(a),copyRawContent:a=>F.current.copyRawContent(a),copyFormattedContent:(a,b)=>F.current.copyFormattedContent(a,b),handleDownload:a=>F.current.handleDownload(a),triggerUpload:a=>F.current.triggerUpload(a),handleCreateFile:()=>F.current.handleCreateFile(),handleCreateFolder:()=>F.current.handleCreateFolder(),handleDragStart:(a,b)=>F.current.handleDragStart(a,b),handleDragOver:(a,b,c)=>F.current.handleDragOver(a,b,c),handleDropOnFolder:(a,b)=>F.current.handleDropOnFolder(a,b),handleGitPull:(a,b)=>F.current.handleGitPull(a,b),handleCheckout:(a,b,c)=>F.current.handleCheckout(a,b,c),loadBranches:a=>F.current.loadBranches(a),prefetch:a=>F.current.prefetch(a),togglePin:(a,b)=>F.current.togglePin(a,b),setDragOverPath:a=>F.current.setDragOverPath(a),setSidebarCollapsed:a=>F.current.setSidebarCollapsed(a),setBranchDropdownNode:a=>F.current.setBranchDropdownNode(a),setBranchDropdownPos:a=>F.current.setBranchDropdownPos(a),setNewFileParent:a=>F.current.setNewFileParent(a),setNewFileName:a=>F.current.setNewFileName(a),setFileCreateError:a=>F.current.setFileCreateError(a),setNewFolderParent:a=>F.current.setNewFolderParent(a),setNewFolderName:a=>F.current.setNewFolderName(a),setFolderError:a=>F.current.setFolderError(a),setDeletingPath:a=>F.current.setDeletingPath(a),setDeletingIsDir:a=>F.current.setDeletingIsDir(a)}),[]);return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(dv,{onOpenFile:b.openFromSearch,recents:k,onToggleSidebar:()=>i(a=>{let b=!a;return e&&!1===b&&bo.getState().close(),b}),onNewFile:()=>w(a=>({...a,file:{...a.file,parent:""}})),onCopyPath:()=>{b.openFile&&b.copyPath(b.openFile.path)}}),(0,g.jsx)(dM,{workspace:a,doc:b,fileTree:c,upload:d,isMobile:e,hideChrome:f,sidebarCollapsed:h,setSidebarCollapsed:i,sidebarResizing:o,setSidebarResizing:q,sidebarWidth:z,setSidebarWidth:A,collapsed:t,setCollapsed:u,createEntry:v,setCreateEntry:w,handleCreateFile:B,handleCreateFolder:C,dragOverPath:r,setDragOverPath:s,handleDragOver:D,handleDropOnFolder:E,sidebarScrollRef:x,treeCtx:G,pins:j,recents:k,activePaths:l,setDialogs:n,handleRefreshWorkspace:a.handleRefreshWorkspace})]})}let dO=(0,h.default)("code-xml",[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]]),dP=(0,h.default)("maximize-2",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]]),dQ=(0,h.default)("pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]),dR=(0,h.default)("share",[["path",{d:"M12 2v13",key:"1km8f5"}],["path",{d:"m16 6-4-4-4 4",key:"13yo43"}],["path",{d:"M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8",key:"1b2hhj"}]]),dS=(0,h.default)("user",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]);var dT=a.i(441218);let dU=(0,h.default)("save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);function dV({path:a,badge:b,sublabel:c,showBreadcrumb:d=!0,leading:e,children:f,className:h}){return(0,g.jsxs)("div",{className:(0,an.cn)("flex shrink-0 items-center justify-between gap-3 border-b border-border bg-background px-4 py-2",h),children:[(0,g.jsxs)("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[e,a&&(0,g.jsx)("span",{className:"text-xs text-muted-foreground truncate",title:a,children:a.split("/").pop()??a}),b&&(0,g.jsx)("span",{className:"shrink-0 rounded bg-muted px-1.5 py-0.5 text-xs text-muted-foreground/50",children:b}),c&&(0,g.jsx)("span",{className:"shrink-0 text-xs text-muted-foreground/40",children:c})]}),(0,g.jsx)("div",{className:"flex shrink-0 items-center gap-1",children:f})]})}function dW(a){let b=[],c="",d=!1,e=[];for(let f=0;f<a.length;f++){let g=a[f],h=a[f+1];d?'"'===g&&'"'===h?(c+='"',f++):'"'===g?d=!1:c+=g:'"'===g?d=!0:","===g?(e.push(c),c=""):"\n"===g||"\r"===g&&"\n"===h?(e.push(c),c="",e.length>0&&b.push(e),e=[],"\r"===g&&f++):c+=g}return e.push(c),e.some(a=>""!==a)&&b.push(e),b}function dX(a){return a.map(a=>a.map(a=>a.includes(",")||a.includes('"')||a.includes("\n")?`"${a.replace(/"/g,'""')}"`:a).join(",")).join("\n")}function dY({path:a}){let[b,c]=(0,p.useState)([]),[d,e]=(0,p.useState)(""),[f,h]=(0,p.useState)(!1),[i,j]=(0,p.useState)(!1),[k,l]=(0,p.useState)(!1),[m,n]=(0,p.useState)(null),[o,q]=(0,p.useState)(!1),[r,s]=(0,p.useState)(1e3),t=(0,bk.withWs)(`/api/assets/${a}`);(0,p.useEffect)(()=>{fetch(t).then(a=>a.text()).then(a=>{let b=dW(a),d=a.length>2097152||b.length>2e3;e(a),c(b),q(d),h(d),j(!1)})},[t]);let v=(0,p.useCallback)((a,b,d)=>{c(c=>{let e=c.map(a=>[...a]);for(;e.length<=a;)e.push([]);for(;e[a].length<=b;)e[a].push("");return e[a][b]=d,e}),j(!0)},[]),w=async()=>{l(!0);let g=f?d:dX(b);try{await (0,bk.wsFetch)(`/api/assets/${a}`,{method:"PUT",headers:{"Content-Type":"text/plain"},body:g}),f?c(dW(d)):e(g),j(!1)}catch(a){console.error("Failed to save CSV:",a)}l(!1)},x=b[0]||[],y=b.slice(1),z=o?y.slice(0,r):y,A=o&&r<y.length;return(0,g.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,g.jsxs)(dV,{path:a,badge:`CSV${b.length>0?` (${b.length-1} rows)`:""}`,children:[i&&(0,g.jsxs)(u.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:w,disabled:k,children:[(0,g.jsx)(dU,{className:"h-3.5 w-3.5"}),k?"Saving...":"Save"]}),o&&(0,g.jsxs)("span",{className:"text-[11px] text-amber-600 dark:text-amber-400 px-1",children:["Large file (",(d.length/1048576).toFixed(1)," MB,"," ",b.length.toLocaleString()," rows)"]}),(0,g.jsxs)("button",{onClick:()=>{f?c(dW(d)):e(dX(b)),h(!f)},className:`flex items-center gap-1.5 px-2.5 py-1 text-[11px] rounded-md transition-colors border border-border ${f?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-accent"}`,children:[(0,g.jsx)(dO,{className:"h-3 w-3"}),f?"Table":"Source"]}),(0,g.jsx)("button",{onClick:()=>window.open(t,"_blank"),className:"inline-flex items-center justify-center rounded-md h-8 w-8 hover:bg-accent hover:text-accent-foreground transition-colors cursor-pointer",title:"Download CSV",children:(0,g.jsx)(bW.Download,{className:"h-4 w-4"})})]}),f?(0,g.jsx)("div",{className:"flex-1 overflow-y-auto p-4",children:(0,g.jsx)("textarea",{value:d,onChange:a=>{e(a.target.value),j(!0)},className:"w-full h-full min-h-[calc(100vh-12rem)] bg-transparent font-mono text-[13px] leading-relaxed resize-none focus:outline-none",spellCheck:!1})}):(0,g.jsxs)("div",{className:"flex-1 overflow-auto",children:[(0,g.jsxs)("table",{className:"w-full border-collapse text-[13px]",children:[(0,g.jsx)("thead",{className:"sticky top-0 z-10",children:(0,g.jsxs)("tr",{className:"bg-muted/80 backdrop-blur-sm",children:[(0,g.jsx)("th",{className:"border border-border px-1 py-1 text-center text-[10px] text-muted-foreground w-8",children:"#"}),x.map((a,b)=>(0,g.jsx)("th",{className:"border border-border px-3 py-1.5 text-left font-medium text-foreground min-w-[100px]",children:m?.r===0&&m?.c===b?(0,g.jsx)("input",{autoFocus:!0,className:"w-full bg-transparent outline-none",value:a,onChange:a=>v(0,b,a.target.value),onBlur:()=>n(null),onKeyDown:a=>{("Enter"===a.key||"Escape"===a.key)&&n(null),"Tab"===a.key&&(a.preventDefault(),n({r:0,c:b+1<x.length?b+1:0}))}}):(0,g.jsx)("span",{className:"cursor-text",onDoubleClick:()=>n({r:0,c:b}),children:a||" "})},b))]})}),(0,g.jsx)("tbody",{children:z.map((a,b)=>{let d=b+1;return(0,g.jsxs)("tr",{className:"hover:bg-accent/30 transition-colors group",children:[(0,g.jsxs)("td",{className:"border border-border px-1 py-1 text-center text-[10px] text-muted-foreground/50",children:[(0,g.jsx)("span",{className:"group-hover:hidden",children:b+1}),(0,g.jsx)("button",{className:"hidden group-hover:inline text-destructive hover:text-destructive/80 text-[10px]",onClick:()=>{c(a=>a.filter((a,b)=>b!==d)),j(!0)},title:"Delete row",children:"×"})]}),x.map((b,c)=>{let e=a[c]??"",f=m?.r===d&&m?.c===c;return(0,g.jsx)("td",{className:"border border-border px-3 py-1.5",children:f?(0,g.jsx)("input",{autoFocus:!0,className:"w-full bg-transparent outline-none",value:e,onChange:a=>v(d,c,a.target.value),onBlur:()=>n(null),onKeyDown:a=>{"Escape"===a.key&&n(null),"Enter"===a.key&&n({r:d+1,c}),"Tab"===a.key&&(a.preventDefault(),a.shiftKey?n({r:d,c:Math.max(0,c-1)}):n({r:c+1>=x.length?d+1:d,c:c+1>=x.length?0:c+1}))}}):(0,g.jsx)("span",{className:"cursor-text",onDoubleClick:()=>n({r:d,c}),children:e||" "})},c)})]},b)})})]}),A&&(0,g.jsxs)("div",{className:"flex items-center gap-3 px-4 py-2 border-t border-border",children:[(0,g.jsxs)("button",{onClick:()=>s(a=>a+1e3),className:"text-[11px] text-foreground hover:bg-accent transition-colors px-2.5 py-1 rounded border border-border",children:["Show"," ",Math.min(1e3,y.length-r).toLocaleString()," ","more rows"]}),(0,g.jsxs)("span",{className:"text-[11px] text-muted-foreground",children:[r.toLocaleString()," /"," ",y.length.toLocaleString()," rows"]})]}),(0,g.jsxs)("div",{className:"flex items-center gap-2 px-4 py-2 border-t border-border",children:[(0,g.jsx)("button",{onClick:()=>{let a=b[0]?.length||1;c(b=>[...b,Array(a).fill("")]),j(!0)},className:"text-[11px] text-muted-foreground hover:text-foreground transition-colors px-2 py-1 rounded hover:bg-accent",children:"+ Add row"}),(0,g.jsx)("button",{onClick:()=>{c(a=>a.map(a=>[...a,""])),j(!0)},className:"text-[11px] text-muted-foreground hover:text-foreground transition-colors px-2 py-1 rounded hover:bg-accent",children:"+ Add column"})]})]})]})}function dZ(a){this.content=a}dZ.prototype={constructor:dZ,find:function(a){for(var b=0;b<this.content.length;b+=2)if(this.content[b]===a)return b;return -1},get:function(a){var b=this.find(a);return -1==b?void 0:this.content[b+1]},update:function(a,b,c){var d=c&&c!=a?this.remove(c):this,e=d.find(a),f=d.content.slice();return -1==e?f.push(c||a,b):(f[e+1]=b,c&&(f[e]=c)),new dZ(f)},remove:function(a){var b=this.find(a);if(-1==b)return this;var c=this.content.slice();return c.splice(b,2),new dZ(c)},addToStart:function(a,b){return new dZ([a,b].concat(this.remove(a).content))},addToEnd:function(a,b){var c=this.remove(a).content.slice();return c.push(a,b),new dZ(c)},addBefore:function(a,b,c){var d=this.remove(b),e=d.content.slice(),f=d.find(a);return e.splice(-1==f?e.length:f,0,b,c),new dZ(e)},forEach:function(a){for(var b=0;b<this.content.length;b+=2)a(this.content[b],this.content[b+1])},prepend:function(a){return(a=dZ.from(a)).size?new dZ(a.content.concat(this.subtract(a).content)):this},append:function(a){return(a=dZ.from(a)).size?new dZ(this.subtract(a).content.concat(a.content)):this},subtract:function(a){var b=this;a=dZ.from(a);for(var c=0;c<a.content.length;c+=2)b=b.remove(a.content[c]);return b},toObject:function(){var a={};return this.forEach(function(b,c){a[b]=c}),a},get size(){return this.content.length>>1}},dZ.from=function(a){if(a instanceof dZ)return a;var b=[];if(a)for(var c in a)b.push(c,a[c]);return new dZ(b)};class d${constructor(a,b){if(this.content=a,this.size=b||0,null==b)for(let b=0;b<a.length;b++)this.size+=a[b].nodeSize}nodesBetween(a,b,c,d=0,e){for(let f=0,g=0;g<b;f++){let h=this.content[f],i=g+h.nodeSize;if(i>a&&!1!==c(h,d+g,e||null,f)&&h.content.size){let e=g+1;h.nodesBetween(Math.max(0,a-e),Math.min(h.content.size,b-e),c,d+e)}g=i}}descendants(a){this.nodesBetween(0,this.size,a)}textBetween(a,b,c,d){let e="",f=!0;return this.nodesBetween(a,b,(g,h)=>{let i=g.isText?g.text.slice(Math.max(a,h)-h,b-h):g.isLeaf?d?"function"==typeof d?d(g):d:g.type.spec.leafText?g.type.spec.leafText(g):"":"";g.isBlock&&(g.isLeaf&&i||g.isTextblock)&&c&&(f?f=!1:e+=c),e+=i},0),e}append(a){if(!a.size)return this;if(!this.size)return a;let b=this.lastChild,c=a.firstChild,d=this.content.slice(),e=0;for(b.isText&&b.sameMarkup(c)&&(d[d.length-1]=b.withText(b.text+c.text),e=1);e<a.content.length;e++)d.push(a.content[e]);return new d$(d,this.size+a.size)}cut(a,b=this.size){if(0==a&&b==this.size)return this;let c=[],d=0;if(b>a)for(let e=0,f=0;f<b;e++){let g=this.content[e],h=f+g.nodeSize;h>a&&((f<a||h>b)&&(g=g.isText?g.cut(Math.max(0,a-f),Math.min(g.text.length,b-f)):g.cut(Math.max(0,a-f-1),Math.min(g.content.size,b-f-1))),c.push(g),d+=g.nodeSize),f=h}return new d$(c,d)}cutByIndex(a,b){return a==b?d$.empty:0==a&&b==this.content.length?this:new d$(this.content.slice(a,b))}replaceChild(a,b){let c=this.content[a];if(c==b)return this;let d=this.content.slice(),e=this.size+b.nodeSize-c.nodeSize;return d[a]=b,new d$(d,e)}addToStart(a){return new d$([a].concat(this.content),this.size+a.nodeSize)}addToEnd(a){return new d$(this.content.concat(a),this.size+a.nodeSize)}eq(a){if(this.content.length!=a.content.length)return!1;for(let b=0;b<this.content.length;b++)if(!this.content[b].eq(a.content[b]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(a){let b=this.content[a];if(!b)throw RangeError("Index "+a+" out of range for "+this);return b}maybeChild(a){return this.content[a]||null}forEach(a){for(let b=0,c=0;b<this.content.length;b++){let d=this.content[b];a(d,c,b),c+=d.nodeSize}}findDiffStart(a,b=0){return function a(b,c,d){for(let e=0;;e++){if(e==b.childCount||e==c.childCount)return b.childCount==c.childCount?null:d;let f=b.child(e),g=c.child(e);if(f==g){d+=f.nodeSize;continue}if(!f.sameMarkup(g))return d;if(f.isText&&f.text!=g.text){for(let a=0;f.text[a]==g.text[a];a++)d++;return d}if(f.content.size||g.content.size){let b=a(f.content,g.content,d+1);if(null!=b)return b}d+=f.nodeSize}}(this,a,b)}findDiffEnd(a,b=this.size,c=a.size){return function a(b,c,d,e){for(let f=b.childCount,g=c.childCount;;){if(0==f||0==g)return f==g?null:{a:d,b:e};let h=b.child(--f),i=c.child(--g),j=h.nodeSize;if(h==i){d-=j,e-=j;continue}if(!h.sameMarkup(i))return{a:d,b:e};if(h.isText&&h.text!=i.text){let a=0,b=Math.min(h.text.length,i.text.length);for(;a<b&&h.text[h.text.length-a-1]==i.text[i.text.length-a-1];)a++,d--,e--;return{a:d,b:e}}if(h.content.size||i.content.size){let b=a(h.content,i.content,d-1,e-1);if(b)return b}d-=j,e-=j}}(this,a,b,c)}findIndex(a){if(0==a)return d0(0,a);if(a==this.size)return d0(this.content.length,a);if(a>this.size||a<0)throw RangeError(`Position ${a} outside of fragment (${this})`);for(let b=0,c=0;;b++){let d=c+this.child(b).nodeSize;if(d>=a){if(d==a)return d0(b+1,d);return d0(b,c)}c=d}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(a=>a.toJSON()):null}static fromJSON(a,b){if(!b)return d$.empty;if(!Array.isArray(b))throw RangeError("Invalid input for Fragment.fromJSON");return d$.fromArray(b.map(a.nodeFromJSON))}static fromArray(a){if(!a.length)return d$.empty;let b,c=0;for(let d=0;d<a.length;d++){let e=a[d];c+=e.nodeSize,d&&e.isText&&a[d-1].sameMarkup(e)?(b||(b=a.slice(0,d)),b[b.length-1]=e.withText(b[b.length-1].text+e.text)):b&&b.push(e)}return new d$(b||a,c)}static from(a){if(!a)return d$.empty;if(a instanceof d$)return a;if(Array.isArray(a))return this.fromArray(a);if(a.attrs)return new d$([a],a.nodeSize);throw RangeError("Can not convert "+a+" to a Fragment"+(a.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}d$.empty=new d$([],0);let d_={index:0,offset:0};function d0(a,b){return d_.index=a,d_.offset=b,d_}function d1(a,b){if(a===b)return!0;if(!(a&&"object"==typeof a)||!(b&&"object"==typeof b))return!1;let c=Array.isArray(a);if(Array.isArray(b)!=c)return!1;if(c){if(a.length!=b.length)return!1;for(let c=0;c<a.length;c++)if(!d1(a[c],b[c]))return!1}else{for(let c in a)if(!(c in b)||!d1(a[c],b[c]))return!1;for(let c in b)if(!(c in a))return!1}return!0}class d2{constructor(a,b){this.type=a,this.attrs=b}addToSet(a){let b,c=!1;for(let d=0;d<a.length;d++){let e=a[d];if(this.eq(e))return a;if(this.type.excludes(e.type))b||(b=a.slice(0,d));else{if(e.type.excludes(this.type))return a;!c&&e.type.rank>this.type.rank&&(b||(b=a.slice(0,d)),b.push(this),c=!0),b&&b.push(e)}}return b||(b=a.slice()),c||b.push(this),b}removeFromSet(a){for(let b=0;b<a.length;b++)if(this.eq(a[b]))return a.slice(0,b).concat(a.slice(b+1));return a}isInSet(a){for(let b=0;b<a.length;b++)if(this.eq(a[b]))return!0;return!1}eq(a){return this==a||this.type==a.type&&d1(this.attrs,a.attrs)}toJSON(){let a={type:this.type.name};for(let b in this.attrs){a.attrs=this.attrs;break}return a}static fromJSON(a,b){if(!b)throw RangeError("Invalid input for Mark.fromJSON");let c=a.marks[b.type];if(!c)throw RangeError(`There is no mark type ${b.type} in this schema`);let d=c.create(b.attrs);return c.checkAttrs(d.attrs),d}static sameSet(a,b){if(a==b)return!0;if(a.length!=b.length)return!1;for(let c=0;c<a.length;c++)if(!a[c].eq(b[c]))return!1;return!0}static setFrom(a){if(!a||Array.isArray(a)&&0==a.length)return d2.none;if(a instanceof d2)return[a];let b=a.slice();return b.sort((a,b)=>a.type.rank-b.type.rank),b}}d2.none=[];class d3 extends Error{}class d4{constructor(a,b,c){this.content=a,this.openStart=b,this.openEnd=c}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(a,b){let c=function a(b,c,d,e,f,g){let{index:h,offset:i}=b.findIndex(c),j=b.maybeChild(h);if(i==c||j.isText)return g&&e<=0&&f<=0&&!g.canReplace(h,h,d)?null:b.cut(0,c).append(d).append(b.cut(c));let k=a(j.content,c-i-1,d,0==h?e-1:0,h==b.childCount-1?f-1:0,j);return k&&b.replaceChild(h,j.copy(k))}(this.content,a+this.openStart,b,this.openStart+1,this.openEnd+1);return c&&new d4(c,this.openStart,this.openEnd)}removeBetween(a,b){return new d4(function a(b,c,d){let{index:e,offset:f}=b.findIndex(c),g=b.maybeChild(e),{index:h,offset:i}=b.findIndex(d);if(f==c||g.isText){if(i!=d&&!b.child(h).isText)throw RangeError("Removing non-flat range");return b.cut(0,c).append(b.cut(d))}if(e!=h)throw RangeError("Removing non-flat range");return b.replaceChild(e,g.copy(a(g.content,c-f-1,d-f-1)))}(this.content,a+this.openStart,b+this.openStart),this.openStart,this.openEnd)}eq(a){return this.content.eq(a.content)&&this.openStart==a.openStart&&this.openEnd==a.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let a={content:this.content.toJSON()};return this.openStart>0&&(a.openStart=this.openStart),this.openEnd>0&&(a.openEnd=this.openEnd),a}static fromJSON(a,b){if(!b)return d4.empty;let c=b.openStart||0,d=b.openEnd||0;if("number"!=typeof c||"number"!=typeof d)throw RangeError("Invalid input for Slice.fromJSON");return new d4(d$.fromJSON(a,b.content),c,d)}static maxOpen(a,b=!0){let c=0,d=0;for(let d=a.firstChild;d&&!d.isLeaf&&(b||!d.type.spec.isolating);d=d.firstChild)c++;for(let c=a.lastChild;c&&!c.isLeaf&&(b||!c.type.spec.isolating);c=c.lastChild)d++;return new d4(a,c,d)}}function d5(a,b){if(!b.type.compatibleContent(a.type))throw new d3("Cannot join "+b.type.name+" onto "+a.type.name)}function d6(a,b,c){let d=a.node(c);return d5(d,b.node(c)),d}function d7(a,b){let c=b.length-1;c>=0&&a.isText&&a.sameMarkup(b[c])?b[c]=a.withText(b[c].text+a.text):b.push(a)}function d8(a,b,c,d){let e=(b||a).node(c),f=0,g=b?b.index(c):e.childCount;a&&(f=a.index(c),a.depth>c?f++:a.textOffset&&(d7(a.nodeAfter,d),f++));for(let a=f;a<g;a++)d7(e.child(a),d);b&&b.depth==c&&b.textOffset&&d7(b.nodeBefore,d)}function d9(a,b){return a.type.checkContent(b),a.copy(b)}function ea(a,b,c){let d=[];return d8(null,a,c,d),a.depth>c&&d7(d9(d6(a,b,c+1),ea(a,b,c+1)),d),d8(b,null,c,d),new d$(d)}d4.empty=new d4(d$.empty,0,0);class eb{constructor(a,b,c){this.pos=a,this.path=b,this.parentOffset=c,this.depth=b.length/3-1}resolveDepth(a){return null==a?this.depth:a<0?this.depth+a:a}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(a){return this.path[3*this.resolveDepth(a)]}index(a){return this.path[3*this.resolveDepth(a)+1]}indexAfter(a){return a=this.resolveDepth(a),this.index(a)+(a!=this.depth||this.textOffset?1:0)}start(a){return 0==(a=this.resolveDepth(a))?0:this.path[3*a-1]+1}end(a){return a=this.resolveDepth(a),this.start(a)+this.node(a).content.size}before(a){if(!(a=this.resolveDepth(a)))throw RangeError("There is no position before the top-level node");return a==this.depth+1?this.pos:this.path[3*a-1]}after(a){if(!(a=this.resolveDepth(a)))throw RangeError("There is no position after the top-level node");return a==this.depth+1?this.pos:this.path[3*a-1]+this.path[3*a].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let a=this.parent,b=this.index(this.depth);if(b==a.childCount)return null;let c=this.pos-this.path[this.path.length-1],d=a.child(b);return c?a.child(b).cut(c):d}get nodeBefore(){let a=this.index(this.depth),b=this.pos-this.path[this.path.length-1];return b?this.parent.child(a).cut(0,b):0==a?null:this.parent.child(a-1)}posAtIndex(a,b){b=this.resolveDepth(b);let c=this.path[3*b],d=0==b?0:this.path[3*b-1]+1;for(let b=0;b<a;b++)d+=c.child(b).nodeSize;return d}marks(){let a=this.parent,b=this.index();if(0==a.content.size)return d2.none;if(this.textOffset)return a.child(b).marks;let c=a.maybeChild(b-1),d=a.maybeChild(b);if(!c){let a=c;c=d,d=a}let e=c.marks;for(var f=0;f<e.length;f++)!1!==e[f].type.spec.inclusive||d&&e[f].isInSet(d.marks)||(e=e[f--].removeFromSet(e));return e}marksAcross(a){let b=this.parent.maybeChild(this.index());if(!b||!b.isInline)return null;let c=b.marks,d=a.parent.maybeChild(a.index());for(var e=0;e<c.length;e++)!1!==c[e].type.spec.inclusive||d&&c[e].isInSet(d.marks)||(c=c[e--].removeFromSet(c));return c}sharedDepth(a){for(let b=this.depth;b>0;b--)if(this.start(b)<=a&&this.end(b)>=a)return b;return 0}blockRange(a=this,b){if(a.pos<this.pos)return a.blockRange(this);for(let c=this.depth-(this.parent.inlineContent||this.pos==a.pos?1:0);c>=0;c--)if(a.pos<=this.end(c)&&(!b||b(this.node(c))))return new ef(this,a,c);return null}sameParent(a){return this.pos-this.parentOffset==a.pos-a.parentOffset}max(a){return a.pos>this.pos?a:this}min(a){return a.pos<this.pos?a:this}toString(){let a="";for(let b=1;b<=this.depth;b++)a+=(a?"/":"")+this.node(b).type.name+"_"+this.index(b-1);return a+":"+this.parentOffset}static resolve(a,b){if(!(b>=0&&b<=a.content.size))throw RangeError("Position "+b+" out of range");let c=[],d=0,e=b;for(let b=a;;){let{index:a,offset:f}=b.content.findIndex(e),g=e-f;if(c.push(b,a,d+f),!g||(b=b.child(a)).isText)break;e=g-1,d+=f+1}return new eb(b,c,e)}static resolveCached(a,b){let c=ee.get(a);if(c)for(let a=0;a<c.elts.length;a++){let d=c.elts[a];if(d.pos==b)return d}else ee.set(a,c=new ec);let d=c.elts[c.i]=eb.resolve(a,b);return c.i=(c.i+1)%ed,d}}class ec{constructor(){this.elts=[],this.i=0}}let ed=12,ee=new WeakMap;class ef{constructor(a,b,c){this.$from=a,this.$to=b,this.depth=c}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}let eg=Object.create(null);class eh{constructor(a,b,c,d=d2.none){this.type=a,this.attrs=b,this.marks=d,this.content=c||d$.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(a){return this.content.child(a)}maybeChild(a){return this.content.maybeChild(a)}forEach(a){this.content.forEach(a)}nodesBetween(a,b,c,d=0){this.content.nodesBetween(a,b,c,d,this)}descendants(a){this.nodesBetween(0,this.content.size,a)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(a,b,c,d){return this.content.textBetween(a,b,c,d)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(a){return this==a||this.sameMarkup(a)&&this.content.eq(a.content)}sameMarkup(a){return this.hasMarkup(a.type,a.attrs,a.marks)}hasMarkup(a,b,c){return this.type==a&&d1(this.attrs,b||a.defaultAttrs||eg)&&d2.sameSet(this.marks,c||d2.none)}copy(a=null){return a==this.content?this:new eh(this.type,this.attrs,a,this.marks)}mark(a){return a==this.marks?this:new eh(this.type,this.attrs,this.content,a)}cut(a,b=this.content.size){return 0==a&&b==this.content.size?this:this.copy(this.content.cut(a,b))}slice(a,b=this.content.size,c=!1){if(a==b)return d4.empty;let d=this.resolve(a),e=this.resolve(b),f=c?0:d.sharedDepth(b),g=d.start(f);return new d4(d.node(f).content.cut(d.pos-g,e.pos-g),d.depth-f,e.depth-f)}replace(a,b,c){var d=this.resolve(a),e=this.resolve(b);if(c.openStart>d.depth)throw new d3("Inserted content deeper than insertion position");if(d.depth-c.openStart!=e.depth-c.openEnd)throw new d3("Inconsistent open depths");return function a(b,c,d,e){let f=b.index(e),g=b.node(e);if(f==c.index(e)&&e<b.depth-d.openStart){let h=a(b,c,d,e+1);return g.copy(g.content.replaceChild(f,h))}if(!d.content.size)return d9(g,ea(b,c,e));if(d.openStart||d.openEnd||b.depth!=e||c.depth!=e){let{start:a,end:f}=function(a,b){let c=b.depth-a.openStart,d=b.node(c).copy(a.content);for(let a=c-1;a>=0;a--)d=b.node(a).copy(d$.from(d));return{start:d.resolveNoCache(a.openStart+c),end:d.resolveNoCache(d.content.size-a.openEnd-c)}}(d,b);return d9(g,function a(b,c,d,e,f){let g=b.depth>f&&d6(b,c,f+1),h=e.depth>f&&d6(d,e,f+1),i=[];return d8(null,b,f,i),g&&h&&c.index(f)==d.index(f)?(d5(g,h),d7(d9(g,a(b,c,d,e,f+1)),i)):(g&&d7(d9(g,ea(b,c,f+1)),i),d8(c,d,f,i),h&&d7(d9(h,ea(d,e,f+1)),i)),d8(e,null,f,i),new d$(i)}(b,a,f,c,e))}{let a=b.parent,e=a.content;return d9(a,e.cut(0,b.parentOffset).append(d.content).append(e.cut(c.parentOffset)))}}(d,e,c,0)}nodeAt(a){for(let b=this;;){let{index:c,offset:d}=b.content.findIndex(a);if(!(b=b.maybeChild(c)))return null;if(d==a||b.isText)return b;a-=d+1}}childAfter(a){let{index:b,offset:c}=this.content.findIndex(a);return{node:this.content.maybeChild(b),index:b,offset:c}}childBefore(a){if(0==a)return{node:null,index:0,offset:0};let{index:b,offset:c}=this.content.findIndex(a);if(c<a)return{node:this.content.child(b),index:b,offset:c};let d=this.content.child(b-1);return{node:d,index:b-1,offset:c-d.nodeSize}}resolve(a){return eb.resolveCached(this,a)}resolveNoCache(a){return eb.resolve(this,a)}rangeHasMark(a,b,c){let d=!1;return b>a&&this.nodesBetween(a,b,a=>(c.isInSet(a.marks)&&(d=!0),!d)),d}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let a=this.type.name;return this.content.size&&(a+="("+this.content.toStringInner()+")"),ej(this.marks,a)}contentMatchAt(a){let b=this.type.contentMatch.matchFragment(this.content,0,a);if(!b)throw Error("Called contentMatchAt on a node with invalid content");return b}canReplace(a,b,c=d$.empty,d=0,e=c.childCount){let f=this.contentMatchAt(a).matchFragment(c,d,e),g=f&&f.matchFragment(this.content,b);if(!g||!g.validEnd)return!1;for(let a=d;a<e;a++)if(!this.type.allowsMarks(c.child(a).marks))return!1;return!0}canReplaceWith(a,b,c,d){if(d&&!this.type.allowsMarks(d))return!1;let e=this.contentMatchAt(a).matchType(c),f=e&&e.matchFragment(this.content,b);return!!f&&f.validEnd}canAppend(a){return a.content.size?this.canReplace(this.childCount,this.childCount,a.content):this.type.compatibleContent(a.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let a=d2.none;for(let b=0;b<this.marks.length;b++){let c=this.marks[b];c.type.checkAttrs(c.attrs),a=c.addToSet(a)}if(!d2.sameSet(a,this.marks))throw RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(a=>a.type.name)}`);this.content.forEach(a=>a.check())}toJSON(){let a={type:this.type.name};for(let b in this.attrs){a.attrs=this.attrs;break}return this.content.size&&(a.content=this.content.toJSON()),this.marks.length&&(a.marks=this.marks.map(a=>a.toJSON())),a}static fromJSON(a,b){let c;if(!b)throw RangeError("Invalid input for Node.fromJSON");if(b.marks){if(!Array.isArray(b.marks))throw RangeError("Invalid mark data for Node.fromJSON");c=b.marks.map(a.markFromJSON)}if("text"==b.type){if("string"!=typeof b.text)throw RangeError("Invalid text node in JSON");return a.text(b.text,c)}let d=d$.fromJSON(a,b.content),e=a.nodeType(b.type).create(b.attrs,d,c);return e.type.checkAttrs(e.attrs),e}}eh.prototype.text=void 0;class ei extends eh{constructor(a,b,c,d){if(super(a,b,null,d),!c)throw RangeError("Empty text nodes are not allowed");this.text=c}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):ej(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(a,b){return this.text.slice(a,b)}get nodeSize(){return this.text.length}mark(a){return a==this.marks?this:new ei(this.type,this.attrs,this.text,a)}withText(a){return a==this.text?this:new ei(this.type,this.attrs,a,this.marks)}cut(a=0,b=this.text.length){return 0==a&&b==this.text.length?this:this.withText(this.text.slice(a,b))}eq(a){return this.sameMarkup(a)&&this.text==a.text}toJSON(){let a=super.toJSON();return a.text=this.text,a}}function ej(a,b){for(let c=a.length-1;c>=0;c--)b=a[c].type.name+"("+b+")";return b}class ek{constructor(a){this.validEnd=a,this.next=[],this.wrapCache=[]}static parse(a,b){var c;let d,e=new el(a,b);if(null==e.next)return ek.empty;let f=function a(b){let c=[];do c.push(function(b){let c=[];do c.push(function(b){let c=function(b){if(b.eat("(")){let c=a(b);return b.eat(")")||b.err("Missing closing paren"),c}if(/\W/.test(b.next))b.err("Unexpected token '"+b.next+"'");else{let a=(function(a,b){let c=a.nodeTypes,d=c[b];if(d)return[d];let e=[];for(let a in c){let d=c[a];d.isInGroup(b)&&e.push(d)}return 0==e.length&&a.err("No node type or group '"+b+"' found"),e})(b,b.next).map(a=>(null==b.inline?b.inline=a.isInline:b.inline!=a.isInline&&b.err("Mixing inline and block content"),{type:"name",value:a}));return b.pos++,1==a.length?a[0]:{type:"choice",exprs:a}}}(b);for(;;)if(b.eat("+"))c={type:"plus",expr:c};else if(b.eat("*"))c={type:"star",expr:c};else if(b.eat("?"))c={type:"opt",expr:c};else if(b.eat("{"))c=function(a,b){let c=em(a),d=c;return a.eat(",")&&(d="}"!=a.next?em(a):-1),a.eat("}")||a.err("Unclosed braced range"),{type:"range",min:c,max:d,expr:b}}(b,c);else break;return c}(b));while(b.next&&")"!=b.next&&"|"!=b.next)return 1==c.length?c[0]:{type:"seq",exprs:c}}(b));while(b.eat("|"))return 1==c.length?c[0]:{type:"choice",exprs:c}}(e);e.next&&e.err("Unexpected trailing text");let g=(c=function(a){let b=[[]];return e(function a(b,f){if("choice"==b.type)return b.exprs.reduce((b,c)=>b.concat(a(c,f)),[]);if("seq"==b.type)for(let d=0;;d++){let g=a(b.exprs[d],f);if(d==b.exprs.length-1)return g;e(g,f=c())}else if("star"==b.type){let g=c();return d(f,g),e(a(b.expr,g),g),[d(g)]}else if("plus"==b.type){let g=c();return e(a(b.expr,f),g),e(a(b.expr,g),g),[d(g)]}else if("opt"==b.type)return[d(f)].concat(a(b.expr,f));else if("range"==b.type){let g=f;for(let d=0;d<b.min;d++){let d=c();e(a(b.expr,g),d),g=d}if(-1==b.max)e(a(b.expr,g),g);else for(let f=b.min;f<b.max;f++){let f=c();d(g,f),e(a(b.expr,g),f),g=f}return[d(g)]}else if("name"==b.type)return[d(f,void 0,b.value)];else throw Error("Unknown expr type")}(a,0),c()),b;function c(){return b.push([])-1}function d(a,c,d){let e={term:d,to:c};return b[a].push(e),e}function e(a,b){a.forEach(a=>a.to=b)}}(f),d=Object.create(null),function a(b){let e=[];b.forEach(a=>{c[a].forEach(({term:a,to:b})=>{let d;if(a){for(let b=0;b<e.length;b++)e[b][0]==a&&(d=e[b][1]);eo(c,b).forEach(b=>{d||e.push([a,d=[]]),-1==d.indexOf(b)&&d.push(b)})}})});let f=d[b.join(",")]=new ek(b.indexOf(c.length-1)>-1);for(let b=0;b<e.length;b++){let c=e[b][1].sort(en);f.next.push({type:e[b][0],next:d[c.join(",")]||a(c)})}return f}(eo(c,0)));return function(a,b){for(let c=0,d=[a];c<d.length;c++){let a=d[c],e=!a.validEnd,f=[];for(let b=0;b<a.next.length;b++){let{type:c,next:g}=a.next[b];f.push(c.name),e&&!(c.isText||c.hasRequiredAttrs())&&(e=!1),-1==d.indexOf(g)&&d.push(g)}e&&b.err("Only non-generatable nodes ("+f.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}(g,e),g}matchType(a){for(let b=0;b<this.next.length;b++)if(this.next[b].type==a)return this.next[b].next;return null}matchFragment(a,b=0,c=a.childCount){let d=this;for(let e=b;d&&e<c;e++)d=d.matchType(a.child(e).type);return d}get inlineContent(){return 0!=this.next.length&&this.next[0].type.isInline}get defaultType(){for(let a=0;a<this.next.length;a++){let{type:b}=this.next[a];if(!(b.isText||b.hasRequiredAttrs()))return b}return null}compatible(a){for(let b=0;b<this.next.length;b++)for(let c=0;c<a.next.length;c++)if(this.next[b].type==a.next[c].type)return!0;return!1}fillBefore(a,b=!1,c=0){let d=[this];return function e(f,g){let h=f.matchFragment(a,c);if(h&&(!b||h.validEnd))return d$.from(g.map(a=>a.createAndFill()));for(let a=0;a<f.next.length;a++){let{type:b,next:c}=f.next[a];if(!(b.isText||b.hasRequiredAttrs())&&-1==d.indexOf(c)){d.push(c);let a=e(c,g.concat(b));if(a)return a}}return null}(this,[])}findWrapping(a){for(let b=0;b<this.wrapCache.length;b+=2)if(this.wrapCache[b]==a)return this.wrapCache[b+1];let b=this.computeWrapping(a);return this.wrapCache.push(a,b),b}computeWrapping(a){let b=Object.create(null),c=[{match:this,type:null,via:null}];for(;c.length;){let d=c.shift(),e=d.match;if(e.matchType(a)){let a=[];for(let b=d;b.type;b=b.via)a.push(b.type);return a.reverse()}for(let a=0;a<e.next.length;a++){let{type:f,next:g}=e.next[a];f.isLeaf||f.hasRequiredAttrs()||f.name in b||d.type&&!g.validEnd||(c.push({match:f.contentMatch,type:f,via:d}),b[f.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(a){if(a>=this.next.length)throw RangeError(`There's no ${a}th edge in this content match`);return this.next[a]}toString(){let a=[];return!function b(c){a.push(c);for(let d=0;d<c.next.length;d++)-1==a.indexOf(c.next[d].next)&&b(c.next[d].next)}(this),a.map((b,c)=>{let d=c+(b.validEnd?"*":" ")+" ";for(let c=0;c<b.next.length;c++)d+=(c?", ":"")+b.next[c].type.name+"->"+a.indexOf(b.next[c].next);return d}).join("\n")}}ek.empty=new ek(!0);class el{constructor(a,b){this.string=a,this.nodeTypes=b,this.inline=null,this.pos=0,this.tokens=a.split(/\s*(?=\b|\W|$)/),""==this.tokens[this.tokens.length-1]&&this.tokens.pop(),""==this.tokens[0]&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(a){return this.next==a&&(this.pos++||!0)}err(a){throw SyntaxError(a+" (in content expression '"+this.string+"')")}}function em(a){/\D/.test(a.next)&&a.err("Expected number, got '"+a.next+"'");let b=Number(a.next);return a.pos++,b}function en(a,b){return b-a}function eo(a,b){let c=[];return function b(d){let e=a[d];if(1==e.length&&!e[0].term)return b(e[0].to);c.push(d);for(let a=0;a<e.length;a++){let{term:d,to:f}=e[a];d||-1!=c.indexOf(f)||b(f)}}(b),c.sort(en)}function ep(a){let b=Object.create(null);for(let c in a){let d=a[c];if(!d.hasDefault)return null;b[c]=d.default}return b}function eq(a,b){let c=Object.create(null);for(let d in a){let e=b&&b[d];if(void 0===e){let b=a[d];if(b.hasDefault)e=b.default;else throw RangeError("No value supplied for attribute "+d)}c[d]=e}return c}function er(a,b,c,d){for(let d in b)if(!(d in a))throw RangeError(`Unsupported attribute ${d} for ${c} of type ${d}`);for(let c in a){let d=a[c];d.validate&&d.validate(b[c])}}function es(a,b){let c=Object.create(null);if(b)for(let d in b)c[d]=new eu(a,d,b[d]);return c}class et{constructor(a,b,c){this.name=a,this.schema=b,this.spec=c,this.markSet=null,this.groups=c.group?c.group.split(" "):[],this.attrs=es(a,c.attrs),this.defaultAttrs=ep(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(c.inline||"text"==a),this.isText="text"==a}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==ek.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(a){return this.groups.indexOf(a)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let a in this.attrs)if(this.attrs[a].isRequired)return!0;return!1}compatibleContent(a){return this==a||this.contentMatch.compatible(a.contentMatch)}computeAttrs(a){return!a&&this.defaultAttrs?this.defaultAttrs:eq(this.attrs,a)}create(a=null,b,c){if(this.isText)throw Error("NodeType.create can't construct text nodes");return new eh(this,this.computeAttrs(a),d$.from(b),d2.setFrom(c))}createChecked(a=null,b,c){return b=d$.from(b),this.checkContent(b),new eh(this,this.computeAttrs(a),b,d2.setFrom(c))}createAndFill(a=null,b,c){if(a=this.computeAttrs(a),(b=d$.from(b)).size){let a=this.contentMatch.fillBefore(b);if(!a)return null;b=a.append(b)}let d=this.contentMatch.matchFragment(b),e=d&&d.fillBefore(d$.empty,!0);return e?new eh(this,a,b.append(e),d2.setFrom(c)):null}validContent(a){let b=this.contentMatch.matchFragment(a);if(!b||!b.validEnd)return!1;for(let b=0;b<a.childCount;b++)if(!this.allowsMarks(a.child(b).marks))return!1;return!0}checkContent(a){if(!this.validContent(a))throw RangeError(`Invalid content for node ${this.name}: ${a.toString().slice(0,50)}`)}checkAttrs(a){er(this.attrs,a,"node",this.name)}allowsMarkType(a){return null==this.markSet||this.markSet.indexOf(a)>-1}allowsMarks(a){if(null==this.markSet)return!0;for(let b=0;b<a.length;b++)if(!this.allowsMarkType(a[b].type))return!1;return!0}allowedMarks(a){let b;if(null==this.markSet)return a;for(let c=0;c<a.length;c++)this.allowsMarkType(a[c].type)?b&&b.push(a[c]):b||(b=a.slice(0,c));return b?b.length?b:d2.none:a}static compile(a,b){let c=Object.create(null);a.forEach((a,d)=>c[a]=new et(a,b,d));let d=b.spec.topNode||"doc";if(!c[d])throw RangeError("Schema is missing its top node type ('"+d+"')");if(!c.text)throw RangeError("Every schema needs a 'text' type");for(let a in c.text.attrs)throw RangeError("The text node type should not have attributes");return c}}class eu{constructor(a,b,c){this.hasDefault=Object.prototype.hasOwnProperty.call(c,"default"),this.default=c.default,this.validate="string"==typeof c.validate?function(a,b,c){let d=c.split("|");return c=>{let e=null===c?"null":typeof c;if(0>d.indexOf(e))throw RangeError(`Expected value of type ${d} for attribute ${b} on type ${a}, got ${e}`)}}(a,b,c.validate):c.validate}get isRequired(){return!this.hasDefault}}class ev{constructor(a,b,c,d){this.name=a,this.rank=b,this.schema=c,this.spec=d,this.attrs=es(a,d.attrs),this.excluded=null;let e=ep(this.attrs);this.instance=e?new d2(this,e):null}create(a=null){return!a&&this.instance?this.instance:new d2(this,eq(this.attrs,a))}static compile(a,b){let c=Object.create(null),d=0;return a.forEach((a,e)=>c[a]=new ev(a,d++,b,e)),c}removeFromSet(a){for(var b=0;b<a.length;b++)a[b].type==this&&(a=a.slice(0,b).concat(a.slice(b+1)),b--);return a}isInSet(a){for(let b=0;b<a.length;b++)if(a[b].type==this)return a[b]}checkAttrs(a){er(this.attrs,a,"mark",this.name)}excludes(a){return this.excluded.indexOf(a)>-1}}class ew{constructor(a){this.linebreakReplacement=null,this.cached=Object.create(null);let b=this.spec={};for(let c in a)b[c]=a[c];b.nodes=dZ.from(a.nodes),b.marks=dZ.from(a.marks||{}),this.nodes=et.compile(this.spec.nodes,this),this.marks=ev.compile(this.spec.marks,this);let c=Object.create(null);for(let a in this.nodes){if(a in this.marks)throw RangeError(a+" can not be both a node and a mark");let b=this.nodes[a],d=b.spec.content||"",e=b.spec.marks;if(b.contentMatch=c[d]||(c[d]=ek.parse(d,this.nodes)),b.inlineContent=b.contentMatch.inlineContent,b.spec.linebreakReplacement){if(this.linebreakReplacement)throw RangeError("Multiple linebreak nodes defined");if(!b.isInline||!b.isLeaf)throw RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=b}b.markSet="_"==e?null:e?ex(this,e.split(" ")):""!=e&&b.inlineContent?null:[]}for(let a in this.marks){let b=this.marks[a],c=b.spec.excludes;b.excluded=null==c?[b]:""==c?[]:ex(this,c.split(" "))}this.nodeFromJSON=a=>eh.fromJSON(this,a),this.markFromJSON=a=>d2.fromJSON(this,a),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(a,b=null,c,d){if("string"==typeof a)a=this.nodeType(a);else if(a instanceof et){if(a.schema!=this)throw RangeError("Node type from different schema used ("+a.name+")")}else throw RangeError("Invalid node type: "+a);return a.createChecked(b,c,d)}text(a,b){let c=this.nodes.text;return new ei(c,c.defaultAttrs,a,d2.setFrom(b))}mark(a,b){return"string"==typeof a&&(a=this.marks[a]),a.create(b)}nodeType(a){let b=this.nodes[a];if(!b)throw RangeError("Unknown node type: "+a);return b}}function ex(a,b){let c=[];for(let d=0;d<b.length;d++){let e=b[d],f=a.marks[e],g=f;if(f)c.push(f);else for(let b in a.marks){let d=a.marks[b];("_"==e||d.spec.group&&d.spec.group.split(" ").indexOf(e)>-1)&&c.push(g=d)}if(!g)throw SyntaxError("Unknown mark type: '"+b[d]+"'")}return c}class ey{constructor(a,b){this.schema=a,this.rules=b,this.tags=[],this.styles=[];let c=this.matchedStyles=[];b.forEach(a=>{if(null!=a.tag)this.tags.push(a);else if(null!=a.style){let b=/[^=]*/.exec(a.style)[0];0>c.indexOf(b)&&c.push(b),this.styles.push(a)}}),this.normalizeLists=!this.tags.some(b=>{if(!/^(ul|ol)\b/.test(b.tag)||!b.node)return!1;let c=a.nodes[b.node];return c.contentMatch.matchType(c)})}parse(a,b={}){let c=new eE(this,b,!1);return c.addAll(a,d2.none,b.from,b.to),c.finish()}parseSlice(a,b={}){let c=new eE(this,b,!0);return c.addAll(a,d2.none,b.from,b.to),d4.maxOpen(c.finish())}matchTag(a,b,c){for(let f=c?this.tags.indexOf(c)+1:0;f<this.tags.length;f++){var d,e;let c=this.tags[f];if(d=a,e=c.tag,(d.matches||d.msMatchesSelector||d.webkitMatchesSelector||d.mozMatchesSelector).call(d,e)&&(void 0===c.namespace||a.namespaceURI==c.namespace)&&(!c.context||b.matchesContext(c.context))){if(c.getAttrs){let b=c.getAttrs(a);if(!1===b)continue;c.attrs=b||void 0}return c}}}matchStyle(a,b,c,d){for(let e=d?this.styles.indexOf(d)+1:0;e<this.styles.length;e++){let d=this.styles[e],f=d.style;if(0==f.indexOf(a)&&(!d.context||c.matchesContext(d.context))&&(!(f.length>a.length)||61==f.charCodeAt(a.length)&&f.slice(a.length+1)==b)){if(d.getAttrs){let a=d.getAttrs(b);if(!1===a)continue;d.attrs=a||void 0}return d}}}static schemaRules(a){let b=[];function c(a){let c=null==a.priority?50:a.priority,d=0;for(;d<b.length;d++){let a=b[d];if((null==a.priority?50:a.priority)<c)break}b.splice(d,0,a)}for(let b in a.marks){let d=a.marks[b].spec.parseDOM;d&&d.forEach(a=>{c(a=eF(a)),a.mark||a.ignore||a.clearMark||(a.mark=b)})}for(let b in a.nodes){let d=a.nodes[b].spec.parseDOM;d&&d.forEach(a=>{c(a=eF(a)),a.node||a.ignore||a.mark||(a.node=b)})}return b}static fromSchema(a){return a.cached.domParser||(a.cached.domParser=new ey(a,ey.schemaRules(a)))}}let ez={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},eA={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},eB={ol:!0,ul:!0};function eC(a,b,c){return null!=b?!!b|2*("full"===b):a&&"pre"==a.whitespace?3:-5&c}class eD{constructor(a,b,c,d,e,f){this.type=a,this.attrs=b,this.marks=c,this.solid=d,this.options=f,this.content=[],this.activeMarks=d2.none,this.match=e||(4&f?null:a.contentMatch)}findWrapping(a){if(!this.match){if(!this.type)return[];let b=this.type.contentMatch.fillBefore(d$.from(a));if(b)this.match=this.type.contentMatch.matchFragment(b);else{let b=this.type.contentMatch,c;return(c=b.findWrapping(a.type))?(this.match=b,c):null}}return this.match.findWrapping(a.type)}finish(a){if(!(1&this.options)){let a=this.content[this.content.length-1],b;a&&a.isText&&(b=/[ \t\r\n\u000c]+$/.exec(a.text))&&(a.text.length==b[0].length?this.content.pop():this.content[this.content.length-1]=a.withText(a.text.slice(0,a.text.length-b[0].length)))}let b=d$.from(this.content);return!a&&this.match&&(b=b.append(this.match.fillBefore(d$.empty,!0))),this.type?this.type.create(this.attrs,b,this.marks):b}inlineContext(a){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:a.parentNode&&!ez.hasOwnProperty(a.parentNode.nodeName.toLowerCase())}}class eE{constructor(a,b,c){this.parser=a,this.options=b,this.isOpen=c,this.open=0,this.localPreserveWS=!1;let d=b.topNode,e,f=eC(null,b.preserveWhitespace,0)|4*!!c;e=d?new eD(d.type,d.attrs,d2.none,!0,b.topMatch||d.type.contentMatch,f):c?new eD(null,null,d2.none,!0,null,f):new eD(a.schema.topNodeType,null,d2.none,!0,null,f),this.nodes=[e],this.find=b.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(a,b){3==a.nodeType?this.addTextNode(a,b):1==a.nodeType&&this.addElement(a,b)}addTextNode(a,b){let c=a.nodeValue,d=this.top,e=2&d.options?"full":this.localPreserveWS||(1&d.options)>0,{schema:f}=this.parser;if("full"===e||d.inlineContext(a)||/[^ \t\r\n\u000c]/.test(c)){if(e)if("full"===e)c=c.replace(/\r\n?/g,"\n");else if(f.linebreakReplacement&&/[\r\n]/.test(c)&&this.top.findWrapping(f.linebreakReplacement.create())){let a=c.split(/\r?\n|\r/);for(let c=0;c<a.length;c++)c&&this.insertNode(f.linebreakReplacement.create(),b,!0),a[c]&&this.insertNode(f.text(a[c]),b,!/\S/.test(a[c]));c=""}else c=c.replace(/\r?\n|\r/g," ");else if(c=c.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(c)&&this.open==this.nodes.length-1){let b=d.content[d.content.length-1],e=a.previousSibling;(!b||e&&"BR"==e.nodeName||b.isText&&/[ \t\r\n\u000c]$/.test(b.text))&&(c=c.slice(1))}c&&this.insertNode(f.text(c),b,!/\S/.test(c)),this.findInText(a)}else this.findInside(a)}addElement(a,b,c){let d=this.localPreserveWS,e=this.top;("PRE"==a.tagName||/pre/.test(a.style&&a.style.whiteSpace))&&(this.localPreserveWS=!0);let f=a.nodeName.toLowerCase(),g;eB.hasOwnProperty(f)&&this.parser.normalizeLists&&function(a){for(let b=a.firstChild,c=null;b;b=b.nextSibling){let a=1==b.nodeType?b.nodeName.toLowerCase():null;a&&eB.hasOwnProperty(a)&&c?(c.appendChild(b),b=c):"li"==a?c=b:a&&(c=null)}}(a);let h=this.options.ruleFromNode&&this.options.ruleFromNode(a)||(g=this.parser.matchTag(a,this,c));b:if(h?h.ignore:eA.hasOwnProperty(f))this.findInside(a),this.ignoreFallback(a,b);else if(!h||h.skip||h.closeParent){h&&h.closeParent?this.open=Math.max(0,this.open-1):h&&h.skip.nodeType&&(a=h.skip);let c,d=this.needsBlock;if(ez.hasOwnProperty(f))e.content.length&&e.content[0].isInline&&this.open&&(this.open--,e=this.top),c=!0,e.type||(this.needsBlock=!0);else if(!a.firstChild){this.leafFallback(a,b);break b}let g=h&&h.skip?b:this.readStyles(a,b);g&&this.addAll(a,g),c&&this.sync(e),this.needsBlock=d}else{let c=this.readStyles(a,b);c&&this.addElementByRule(a,h,c,!1===h.consuming?g:void 0)}this.localPreserveWS=d}leafFallback(a,b){"BR"==a.nodeName&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(a.ownerDocument.createTextNode("\n"),b)}ignoreFallback(a,b){"BR"!=a.nodeName||this.top.type&&this.top.type.inlineContent||this.findPlace(this.parser.schema.text("-"),b,!0)}readStyles(a,b){let c=a.style;if(c&&c.length)for(let a=0;a<this.parser.matchedStyles.length;a++){let d=this.parser.matchedStyles[a],e=c.getPropertyValue(d);if(e)for(let a;;){let c=this.parser.matchStyle(d,e,this,a);if(!c)break;if(c.ignore)return null;if(b=c.clearMark?b.filter(a=>!c.clearMark(a)):b.concat(this.parser.schema.marks[c.mark].create(c.attrs)),!1===c.consuming)a=c;else break}}return b}addElementByRule(a,b,c,d){let e,f;if(b.node)if((f=this.parser.schema.nodes[b.node]).isLeaf)this.insertNode(f.create(b.attrs),c,"BR"==a.nodeName)||this.leafFallback(a,c);else{let a=this.enter(f,b.attrs||null,c,b.preserveWhitespace);a&&(e=!0,c=a)}else{let a=this.parser.schema.marks[b.mark];c=c.concat(a.create(b.attrs))}let g=this.top;if(f&&f.isLeaf)this.findInside(a);else if(d)this.addElement(a,c,d);else if(b.getContent)this.findInside(a),b.getContent(a,this.parser.schema).forEach(a=>this.insertNode(a,c,!1));else{let d=a;"string"==typeof b.contentElement?d=a.querySelector(b.contentElement):"function"==typeof b.contentElement?d=b.contentElement(a):b.contentElement&&(d=b.contentElement),this.findAround(a,d,!0),this.addAll(d,c),this.findAround(a,d,!1)}e&&this.sync(g)&&this.open--}addAll(a,b,c,d){let e=c||0;for(let f=c?a.childNodes[c]:a.firstChild,g=null==d?null:a.childNodes[d];f!=g;f=f.nextSibling,++e)this.findAtPoint(a,e),this.addDOM(f,b);this.findAtPoint(a,e)}findPlace(a,b,c){let d,e;for(let b=this.open,f=0;b>=0;b--){let g=this.nodes[b],h=g.findWrapping(a);if(h&&(!d||d.length>h.length+f)&&(d=h,e=g,!h.length))break;if(g.solid){if(c)break;f+=2}}if(!d)return null;this.sync(e);for(let a=0;a<d.length;a++)b=this.enterInner(d[a],null,b,!1);return b}insertNode(a,b,c){if(a.isInline&&this.needsBlock&&!this.top.type){let a=this.textblockFromContext();a&&(b=this.enterInner(a,null,b))}let d=this.findPlace(a,b,c);if(d){this.closeExtra();let b=this.top;b.match&&(b.match=b.match.matchType(a.type));let c=d2.none;for(let e of d.concat(a.marks))(b.type?b.type.allowsMarkType(e.type):eG(e.type,a.type))&&(c=e.addToSet(c));return b.content.push(a.mark(c)),!0}return!1}enter(a,b,c,d){let e=this.findPlace(a.create(b),c,!1);return e&&(e=this.enterInner(a,b,c,!0,d)),e}enterInner(a,b,c,d=!1,e){this.closeExtra();let f=this.top;f.match=f.match&&f.match.matchType(a);let g=eC(a,e,f.options);4&f.options&&0==f.content.length&&(g|=4);let h=d2.none;return c=c.filter(b=>(f.type?!f.type.allowsMarkType(b.type):!eG(b.type,a))||(h=b.addToSet(h),!1)),this.nodes.push(new eD(a,b,h,d,null,g)),this.open++,c}closeExtra(a=!1){let b=this.nodes.length-1;if(b>this.open){for(;b>this.open;b--)this.nodes[b-1].content.push(this.nodes[b].finish(a));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(a){for(let b=this.open;b>=0;b--)if(this.nodes[b]==a)return this.open=b,!0;else this.localPreserveWS&&(this.nodes[b].options|=1);return!1}get currentPos(){this.closeExtra();let a=0;for(let b=this.open;b>=0;b--){let c=this.nodes[b].content;for(let b=c.length-1;b>=0;b--)a+=c[b].nodeSize;b&&a++}return a}findAtPoint(a,b){if(this.find)for(let c=0;c<this.find.length;c++)this.find[c].node==a&&this.find[c].offset==b&&(this.find[c].pos=this.currentPos)}findInside(a){if(this.find)for(let b=0;b<this.find.length;b++)null==this.find[b].pos&&1==a.nodeType&&a.contains(this.find[b].node)&&(this.find[b].pos=this.currentPos)}findAround(a,b,c){if(a!=b&&this.find)for(let d=0;d<this.find.length;d++)null==this.find[d].pos&&1==a.nodeType&&a.contains(this.find[d].node)&&b.compareDocumentPosition(this.find[d].node)&(c?2:4)&&(this.find[d].pos=this.currentPos)}findInText(a){if(this.find)for(let b=0;b<this.find.length;b++)this.find[b].node==a&&(this.find[b].pos=this.currentPos-(a.nodeValue.length-this.find[b].offset))}matchesContext(a){if(a.indexOf("|")>-1)return a.split(/\s*\|\s*/).some(this.matchesContext,this);let b=a.split("/"),c=this.options.context,d=!this.isOpen&&(!c||c.parent.type==this.nodes[0].type),e=-(c?c.depth+1:0)+ +!d,f=(a,g)=>{for(;a>=0;a--){let h=b[a];if(""==h){if(a==b.length-1||0==a)continue;for(;g>=e;g--)if(f(a-1,g))return!0;return!1}{let a=g>0||0==g&&d?this.nodes[g].type:c&&g>=e?c.node(g-e).type:null;if(!a||a.name!=h&&!a.isInGroup(h))return!1;g--}}return!0};return f(b.length-1,this.open)}textblockFromContext(){let a=this.options.context;if(a)for(let b=a.depth;b>=0;b--){let c=a.node(b).contentMatchAt(a.indexAfter(b)).defaultType;if(c&&c.isTextblock&&c.defaultAttrs)return c}for(let a in this.parser.schema.nodes){let b=this.parser.schema.nodes[a];if(b.isTextblock&&b.defaultAttrs)return b}}}function eF(a){let b={};for(let c in a)b[c]=a[c];return b}function eG(a,b){let c=b.schema.nodes;for(let d in c){let e=c[d];if(!e.allowsMarkType(a))continue;let f=[],g=a=>{f.push(a);for(let c=0;c<a.edgeCount;c++){let{type:d,next:e}=a.edge(c);if(d==b||0>f.indexOf(e)&&g(e))return!0}};if(g(e.contentMatch))return!0}}class eH{constructor(a,b){this.nodes=a,this.marks=b}serializeFragment(a,b={},c){c||(c=eJ(b).createDocumentFragment());let d=c,e=[];return a.forEach(a=>{if(e.length||a.marks.length){let c=0,f=0;for(;c<e.length&&f<a.marks.length;){let b=a.marks[f];if(!this.marks[b.type.name]){f++;continue}if(!b.eq(e[c][0])||!1===b.type.spec.spanning)break;c++,f++}for(;c<e.length;)d=e.pop()[1];for(;f<a.marks.length;){let c=a.marks[f++],g=this.serializeMark(c,a.isInline,b);g&&(e.push([c,d]),d.appendChild(g.dom),d=g.contentDOM||g.dom)}}d.appendChild(this.serializeNodeInner(a,b))}),c}serializeNodeInner(a,b){if(a.isText)return eJ(b).createTextNode(a.text);let{dom:c,contentDOM:d}=eL(eJ(b),this.nodes[a.type.name](a),null,a.attrs);if(d){if(a.isLeaf)throw RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(a.content,b,d)}return c}serializeNode(a,b={}){let c=this.serializeNodeInner(a,b);for(let d=a.marks.length-1;d>=0;d--){let e=this.serializeMark(a.marks[d],a.isInline,b);e&&((e.contentDOM||e.dom).appendChild(c),c=e.dom)}return c}serializeMark(a,b,c={}){let d=this.marks[a.type.name];return d&&eL(eJ(c),d(a,b),null,a.attrs)}static renderSpec(a,b,c=null,d){return"string"==typeof b?{dom:a.createTextNode(b)}:eL(a,b,c,d)}static fromSchema(a){return a.cached.domSerializer||(a.cached.domSerializer=new eH(this.nodesFromSchema(a),this.marksFromSchema(a)))}static nodesFromSchema(a){let b=eI(a.nodes);return b.text||(b.text=a=>a.text),b}static marksFromSchema(a){return eI(a.marks)}}function eI(a){let b={};for(let c in a){let d=a[c].spec.toDOM;d&&(b[c]=d)}return b}function eJ(a){return a.document||window.document}let eK=new WeakMap;function eL(a,b,c,d){let e,f,g;if(1==b.nodeType)return{dom:b};if(b.dom&&1==b.dom.nodeType)return b;let h=b[0],i;if("string"!=typeof h)throw RangeError("Invalid array passed to renderSpec");if(d&&(void 0===(f=eK.get(d))&&eK.set(d,(g=null,!function a(b){if(b&&"object"==typeof b)if(Array.isArray(b))if("string"==typeof b[0])g||(g=[]),g.push(b);else for(let c=0;c<b.length;c++)a(b[c]);else for(let c in b)a(b[c])}(d),f=g)),i=f)&&i.indexOf(b)>-1)throw RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let j=h.indexOf(" ");j>0&&(c=h.slice(0,j),h=h.slice(j+1));let k=c?a.createElementNS(c,h):a.createElement(h),l=b[1],m=1;if(l&&"object"==typeof l&&null==l.nodeType&&!Array.isArray(l)){for(let a in m=2,l)if(null!=l[a]){let b=a.indexOf(" ");b>0?k.setAttributeNS(a.slice(0,b),a.slice(b+1),l[a]):"style"==a&&k.style?k.style.cssText=l[a]:k.setAttribute(a,l[a])}}for(let f=m;f<b.length;f++){let g=b[f];if(0===g){if(f<b.length-1||f>m)throw RangeError("Content hole must be the only child of its parent node");return{dom:k,contentDOM:k}}if("string"==typeof g)k.appendChild(a.createTextNode(g));else{let{dom:b,contentDOM:f}=eL(a,g,c,d);if(k.appendChild(b),f){if(e)throw RangeError("Multiple content holes");e=f}}}return{dom:k,contentDOM:e}}class eM{constructor(a,b,c){this.pos=a,this.delInfo=b,this.recover=c}get deleted(){return(8&this.delInfo)>0}get deletedBefore(){return(5&this.delInfo)>0}get deletedAfter(){return(6&this.delInfo)>0}get deletedAcross(){return(4&this.delInfo)>0}}class eN{constructor(a,b=!1){if(this.ranges=a,this.inverted=b,!a.length&&eN.empty)return eN.empty}recover(a){let b=0,c=65535&a;if(!this.inverted)for(let a=0;a<c;a++)b+=this.ranges[3*a+2]-this.ranges[3*a+1];return this.ranges[3*c]+b+(a-(65535&a))/65536}mapResult(a,b=1){return this._map(a,b,!1)}map(a,b=1){return this._map(a,b,!0)}_map(a,b,c){let d=0,e=this.inverted?2:1,f=this.inverted?1:2;for(let g=0;g<this.ranges.length;g+=3){let h=this.ranges[g]-(this.inverted?d:0);if(h>a)break;let i=this.ranges[g+e],j=this.ranges[g+f],k=h+i;if(a<=k){let e=i?a==h?-1:a==k?1:b:b,f=h+d+(e<0?0:j);if(c)return f;let l=a==(b<0?h:k)?null:g/3+(a-h)*65536,m=a==h?2:a==k?1:4;return(b<0?a!=h:a!=k)&&(m|=8),new eM(f,m,l)}d+=j-i}return c?a+d:new eM(a+d,0,null)}touches(a,b){let c=0,d=65535&b,e=this.inverted?2:1,f=this.inverted?1:2;for(let b=0;b<this.ranges.length;b+=3){let g=this.ranges[b]-(this.inverted?c:0);if(g>a)break;let h=this.ranges[b+e];if(a<=g+h&&b==3*d)return!0;c+=this.ranges[b+f]-h}return!1}forEach(a){let b=this.inverted?2:1,c=this.inverted?1:2;for(let d=0,e=0;d<this.ranges.length;d+=3){let f=this.ranges[d],g=f-(this.inverted?e:0),h=f+(this.inverted?0:e),i=this.ranges[d+b],j=this.ranges[d+c];a(g,g+i,h,h+j),e+=j-i}}invert(){return new eN(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(a){return 0==a?eN.empty:new eN(a<0?[0,-a,0]:[0,0,a])}}eN.empty=new eN([]);class eO{constructor(a,b,c=0,d=a?a.length:0){this.mirror=b,this.from=c,this.to=d,this._maps=a||[],this.ownData=!(a||b)}get maps(){return this._maps}slice(a=0,b=this.maps.length){return new eO(this._maps,this.mirror,a,b)}appendMap(a,b){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(a),null!=b&&this.setMirror(this._maps.length-1,b)}appendMapping(a){for(let b=0,c=this._maps.length;b<a._maps.length;b++){let d=a.getMirror(b);this.appendMap(a._maps[b],null!=d&&d<b?c+d:void 0)}}getMirror(a){if(this.mirror){for(let b=0;b<this.mirror.length;b++)if(this.mirror[b]==a)return this.mirror[b+(b%2?-1:1)]}}setMirror(a,b){this.mirror||(this.mirror=[]),this.mirror.push(a,b)}appendMappingInverted(a){for(let b=a.maps.length-1,c=this._maps.length+a._maps.length;b>=0;b--){let d=a.getMirror(b);this.appendMap(a._maps[b].invert(),null!=d&&d>b?c-d-1:void 0)}}invert(){let a=new eO;return a.appendMappingInverted(this),a}map(a,b=1){if(this.mirror)return this._map(a,b,!0);for(let c=this.from;c<this.to;c++)a=this._maps[c].map(a,b);return a}mapResult(a,b=1){return this._map(a,b,!1)}_map(a,b,c){let d=0;for(let c=this.from;c<this.to;c++){let e=this._maps[c].mapResult(a,b);if(null!=e.recover){let b=this.getMirror(c);if(null!=b&&b>c&&b<this.to){c=b,a=this._maps[b].recover(e.recover);continue}}d|=e.delInfo,a=e.pos}return c?a:new eM(a,d,null)}}let eP=Object.create(null);class eQ{getMap(){return eN.empty}merge(a){return null}static fromJSON(a,b){if(!b||!b.stepType)throw RangeError("Invalid input for Step.fromJSON");let c=eP[b.stepType];if(!c)throw RangeError(`No step type ${b.stepType} defined`);return c.fromJSON(a,b)}static jsonID(a,b){if(a in eP)throw RangeError("Duplicate use of step JSON ID "+a);return eP[a]=b,b.prototype.jsonID=a,b}}class eR{constructor(a,b){this.doc=a,this.failed=b}static ok(a){return new eR(a,null)}static fail(a){return new eR(null,a)}static fromReplace(a,b,c,d){try{return eR.ok(a.replace(b,c,d))}catch(a){if(a instanceof d3)return eR.fail(a.message);throw a}}}function eS(a,b,c){let d=[];for(let e=0;e<a.childCount;e++){let f=a.child(e);f.content.size&&(f=f.copy(eS(f.content,b,f))),f.isInline&&(f=b(f,c,e)),d.push(f)}return d$.fromArray(d)}class eT extends eQ{constructor(a,b,c){super(),this.from=a,this.to=b,this.mark=c}apply(a){let b=a.slice(this.from,this.to),c=a.resolve(this.from),d=c.node(c.sharedDepth(this.to)),e=new d4(eS(b.content,(a,b)=>a.isAtom&&b.type.allowsMarkType(this.mark.type)?a.mark(this.mark.addToSet(a.marks)):a,d),b.openStart,b.openEnd);return eR.fromReplace(a,this.from,this.to,e)}invert(){return new eU(this.from,this.to,this.mark)}map(a){let b=a.mapResult(this.from,1),c=a.mapResult(this.to,-1);return b.deleted&&c.deleted||b.pos>=c.pos?null:new eT(b.pos,c.pos,this.mark)}merge(a){return a instanceof eT&&a.mark.eq(this.mark)&&this.from<=a.to&&this.to>=a.from?new eT(Math.min(this.from,a.from),Math.max(this.to,a.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(a,b){if("number"!=typeof b.from||"number"!=typeof b.to)throw RangeError("Invalid input for AddMarkStep.fromJSON");return new eT(b.from,b.to,a.markFromJSON(b.mark))}}eQ.jsonID("addMark",eT);class eU extends eQ{constructor(a,b,c){super(),this.from=a,this.to=b,this.mark=c}apply(a){let b=a.slice(this.from,this.to),c=new d4(eS(b.content,a=>a.mark(this.mark.removeFromSet(a.marks)),a),b.openStart,b.openEnd);return eR.fromReplace(a,this.from,this.to,c)}invert(){return new eT(this.from,this.to,this.mark)}map(a){let b=a.mapResult(this.from,1),c=a.mapResult(this.to,-1);return b.deleted&&c.deleted||b.pos>=c.pos?null:new eU(b.pos,c.pos,this.mark)}merge(a){return a instanceof eU&&a.mark.eq(this.mark)&&this.from<=a.to&&this.to>=a.from?new eU(Math.min(this.from,a.from),Math.max(this.to,a.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(a,b){if("number"!=typeof b.from||"number"!=typeof b.to)throw RangeError("Invalid input for RemoveMarkStep.fromJSON");return new eU(b.from,b.to,a.markFromJSON(b.mark))}}eQ.jsonID("removeMark",eU);class eV extends eQ{constructor(a,b){super(),this.pos=a,this.mark=b}apply(a){let b=a.nodeAt(this.pos);if(!b)return eR.fail("No node at mark step's position");let c=b.type.create(b.attrs,null,this.mark.addToSet(b.marks));return eR.fromReplace(a,this.pos,this.pos+1,new d4(d$.from(c),0,+!b.isLeaf))}invert(a){let b=a.nodeAt(this.pos);if(b){let a=this.mark.addToSet(b.marks);if(a.length==b.marks.length){for(let c=0;c<b.marks.length;c++)if(!b.marks[c].isInSet(a))return new eV(this.pos,b.marks[c]);return new eV(this.pos,this.mark)}}return new eW(this.pos,this.mark)}map(a){let b=a.mapResult(this.pos,1);return b.deletedAfter?null:new eV(b.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(a,b){if("number"!=typeof b.pos)throw RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new eV(b.pos,a.markFromJSON(b.mark))}}eQ.jsonID("addNodeMark",eV);class eW extends eQ{constructor(a,b){super(),this.pos=a,this.mark=b}apply(a){let b=a.nodeAt(this.pos);if(!b)return eR.fail("No node at mark step's position");let c=b.type.create(b.attrs,null,this.mark.removeFromSet(b.marks));return eR.fromReplace(a,this.pos,this.pos+1,new d4(d$.from(c),0,+!b.isLeaf))}invert(a){let b=a.nodeAt(this.pos);return b&&this.mark.isInSet(b.marks)?new eV(this.pos,this.mark):this}map(a){let b=a.mapResult(this.pos,1);return b.deletedAfter?null:new eW(b.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(a,b){if("number"!=typeof b.pos)throw RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new eW(b.pos,a.markFromJSON(b.mark))}}eQ.jsonID("removeNodeMark",eW);class eX extends eQ{constructor(a,b,c,d=!1){super(),this.from=a,this.to=b,this.slice=c,this.structure=d}apply(a){return this.structure&&eZ(a,this.from,this.to)?eR.fail("Structure replace would overwrite content"):eR.fromReplace(a,this.from,this.to,this.slice)}getMap(){return new eN([this.from,this.to-this.from,this.slice.size])}invert(a){return new eX(this.from,this.from+this.slice.size,a.slice(this.from,this.to))}map(a){let b=a.mapResult(this.to,-1),c=this.from==this.to&&eX.MAP_BIAS<0?b:a.mapResult(this.from,1);return c.deletedAcross&&b.deletedAcross?null:new eX(c.pos,Math.max(c.pos,b.pos),this.slice,this.structure)}merge(a){if(!(a instanceof eX)||a.structure||this.structure)return null;if(this.from+this.slice.size!=a.from||this.slice.openEnd||a.slice.openStart)if(a.to!=this.from||this.slice.openStart||a.slice.openEnd)return null;else{let b=this.slice.size+a.slice.size==0?d4.empty:new d4(a.slice.content.append(this.slice.content),a.slice.openStart,this.slice.openEnd);return new eX(a.from,this.to,b,this.structure)}{let b=this.slice.size+a.slice.size==0?d4.empty:new d4(this.slice.content.append(a.slice.content),this.slice.openStart,a.slice.openEnd);return new eX(this.from,this.to+(a.to-a.from),b,this.structure)}}toJSON(){let a={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(a.slice=this.slice.toJSON()),this.structure&&(a.structure=!0),a}static fromJSON(a,b){if("number"!=typeof b.from||"number"!=typeof b.to)throw RangeError("Invalid input for ReplaceStep.fromJSON");return new eX(b.from,b.to,d4.fromJSON(a,b.slice),!!b.structure)}}eX.MAP_BIAS=1,eQ.jsonID("replace",eX);class eY extends eQ{constructor(a,b,c,d,e,f,g=!1){super(),this.from=a,this.to=b,this.gapFrom=c,this.gapTo=d,this.slice=e,this.insert=f,this.structure=g}apply(a){if(this.structure&&(eZ(a,this.from,this.gapFrom)||eZ(a,this.gapTo,this.to)))return eR.fail("Structure gap-replace would overwrite content");let b=a.slice(this.gapFrom,this.gapTo);if(b.openStart||b.openEnd)return eR.fail("Gap is not a flat range");let c=this.slice.insertAt(this.insert,b.content);return c?eR.fromReplace(a,this.from,this.to,c):eR.fail("Content does not fit in gap")}getMap(){return new eN([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(a){let b=this.gapTo-this.gapFrom;return new eY(this.from,this.from+this.slice.size+b,this.from+this.insert,this.from+this.insert+b,a.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(a){let b=a.mapResult(this.from,1),c=a.mapResult(this.to,-1),d=this.from==this.gapFrom?b.pos:a.map(this.gapFrom,-1),e=this.to==this.gapTo?c.pos:a.map(this.gapTo,1);return b.deletedAcross&&c.deletedAcross||d<b.pos||e>c.pos?null:new eY(b.pos,c.pos,d,e,this.slice,this.insert,this.structure)}toJSON(){let a={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(a.slice=this.slice.toJSON()),this.structure&&(a.structure=!0),a}static fromJSON(a,b){if("number"!=typeof b.from||"number"!=typeof b.to||"number"!=typeof b.gapFrom||"number"!=typeof b.gapTo||"number"!=typeof b.insert)throw RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new eY(b.from,b.to,b.gapFrom,b.gapTo,d4.fromJSON(a,b.slice),b.insert,!!b.structure)}}function eZ(a,b,c){let d=a.resolve(b),e=c-b,f=d.depth;for(;e>0&&f>0&&d.indexAfter(f)==d.node(f).childCount;)f--,e--;if(e>0){let a=d.node(f).maybeChild(d.indexAfter(f));for(;e>0;){if(!a||a.isLeaf)return!0;a=a.firstChild,e--}}return!1}function e$(a,b,c,d=c.contentMatch,e=!0){let f=a.doc.nodeAt(b),g=[],h=b+1;for(let b=0;b<f.childCount;b++){let i=f.child(b),j=h+i.nodeSize,k=d.matchType(i.type);if(k){d=k;for(let b=0;b<i.marks.length;b++)c.allowsMarkType(i.marks[b].type)||a.step(new eU(h,j,i.marks[b]));if(e&&i.isText&&"pre"!=c.whitespace){let a,b=/\r?\n|\r/g,d;for(;a=b.exec(i.text);)d||(d=new d4(d$.from(c.schema.text(" ",c.allowedMarks(i.marks))),0,0)),g.push(new eX(h+a.index,h+a.index+a[0].length,d))}}else g.push(new eX(h,j,d4.empty));h=j}if(!d.validEnd){let b=d.fillBefore(d$.empty,!0);a.replace(h,h,new d4(b,0,0))}for(let b=g.length-1;b>=0;b--)a.step(g[b])}function e_(a){let b=a.parent.content.cutByIndex(a.startIndex,a.endIndex);for(let c=a.depth,d=0,e=0;;--c){let f=a.$from.node(c),g=a.$from.index(c)+d,h=a.$to.indexAfter(c)-e;if(c<a.depth&&f.canReplace(g,h,b))return c;if(0==c||f.type.spec.isolating||!((0==g||f.canReplace(g,f.childCount))&&(h==f.childCount||f.canReplace(0,h))))break;g&&(d=1),h<f.childCount&&(e=1)}return null}function e0(a,b,c=null,d=a){let e=function(a,b){let{parent:c,startIndex:d,endIndex:e}=a,f=c.contentMatchAt(d).findWrapping(b);if(!f)return null;let g=f.length?f[0]:b;return c.canReplaceWith(d,e,g)?f:null}(a,b),f=e&&function(a,b){let{parent:c,startIndex:d,endIndex:e}=a,f=c.child(d),g=b.contentMatch.findWrapping(f.type);if(!g)return null;let h=(g.length?g[g.length-1]:b).contentMatch;for(let a=d;h&&a<e;a++)h=h.matchType(c.child(a).type);return h&&h.validEnd?g:null}(d,b);return f?e.map(e1).concat({type:b,attrs:c}).concat(f.map(e1)):null}function e1(a){return{type:a,attrs:null}}function e2(a,b,c,d){b.forEach((e,f)=>{if(e.isText){let g,h=/\r?\n|\r/g;for(;g=h.exec(e.text);){let e=a.mapping.slice(d).map(c+1+f+g.index);a.replaceWith(e,e+1,b.type.schema.linebreakReplacement.create())}}})}function e3(a,b,c,d){b.forEach((e,f)=>{if(e.type==e.type.schema.linebreakReplacement){let e=a.mapping.slice(d).map(c+1+f);a.replaceWith(e,e+1,b.type.schema.text("\n"))}})}function e4(a,b,c=1,d){let e=a.resolve(b),f=e.depth-c,g=d&&d[d.length-1]||e.parent;if(f<0||e.parent.type.spec.isolating||!e.parent.canReplace(e.index(),e.parent.childCount)||!g.type.validContent(e.parent.content.cutByIndex(e.index(),e.parent.childCount)))return!1;for(let a=e.depth-1,b=c-2;a>f;a--,b--){let c=e.node(a),f=e.index(a);if(c.type.spec.isolating)return!1;let g=c.content.cutByIndex(f,c.childCount),h=d&&d[b+1];h&&(g=g.replaceChild(0,h.type.create(h.attrs)));let i=d&&d[b]||c;if(!c.canReplace(f+1,c.childCount)||!i.type.validContent(g))return!1}let h=e.indexAfter(f),i=d&&d[0];return e.node(f).canReplaceWith(h,h,i?i.type:e.node(f+1).type)}function e5(a,b){let c=a.resolve(b),d=c.index();return e6(c.nodeBefore,c.nodeAfter)&&c.parent.canReplace(d,d+1)}function e6(a,b){return!!(a&&b&&!a.isLeaf&&function(a,b){b.content.size||a.type.compatibleContent(b.type);let c=a.contentMatchAt(a.childCount),{linebreakReplacement:d}=a.type.schema;for(let e=0;e<b.childCount;e++){let f=b.child(e),g=f.type==d?a.type.schema.nodes.text:f.type;if(!(c=c.matchType(g))||!a.type.allowsMarks(f.marks))return!1}return c.validEnd}(a,b))}function e7(a,b,c=-1){let d=a.resolve(b);for(let a=d.depth;;a--){let e,f,g=d.index(a);if(a==d.depth?(e=d.nodeBefore,f=d.nodeAfter):c>0?(e=d.node(a+1),g++,f=d.node(a).maybeChild(g)):(e=d.node(a).maybeChild(g-1),f=d.node(a+1)),e&&!e.isTextblock&&e6(e,f)&&d.node(a).canReplace(g,g+1))return b;if(0==a)break;b=c<0?d.before(a):d.after(a)}}function e8(a,b,c){let d=a.resolve(b);if(!c.content.size)return b;let e=c.content;for(let a=0;a<c.openStart;a++)e=e.firstChild.content;for(let a=1;a<=(0==c.openStart&&c.size?2:1);a++)for(let b=d.depth;b>=0;b--){let c=b==d.depth?0:d.pos<=(d.start(b+1)+d.end(b+1))/2?-1:1,f=d.index(b)+ +(c>0),g=d.node(b),h=!1;if(1==a)h=g.canReplace(f,f,e);else{let a=g.contentMatchAt(f).findWrapping(e.firstChild.type);h=a&&g.canReplaceWith(f,f,a[0])}if(h)return 0==c?d.pos:c<0?d.before(b+1):d.after(b+1)}return null}function e9(a,b,c=b,d=d4.empty){if(b==c&&!d.size)return null;let e=a.resolve(b),f=a.resolve(c);return fa(e,f,d)?new eX(b,c,d):new fb(e,f,d).fit()}function fa(a,b,c){return!c.openStart&&!c.openEnd&&a.start()==b.start()&&a.parent.canReplace(a.index(),b.index(),c.content)}eQ.jsonID("replaceAround",eY);class fb{constructor(a,b,c){this.$from=a,this.$to=b,this.unplaced=c,this.frontier=[],this.placed=d$.empty;for(let b=0;b<=a.depth;b++){let c=a.node(b);this.frontier.push({type:c.type,match:c.contentMatchAt(a.indexAfter(b))})}for(let b=a.depth;b>0;b--)this.placed=d$.from(a.node(b).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let a=this.findFittable();a?this.placeNodes(a):this.openMore()||this.dropNode()}let a=this.mustMoveInline(),b=this.placed.size-this.depth-this.$from.depth,c=this.$from,d=this.close(a<0?this.$to:c.doc.resolve(a));if(!d)return null;let e=this.placed,f=c.depth,g=d.depth;for(;f&&g&&1==e.childCount;)e=e.firstChild.content,f--,g--;let h=new d4(e,f,g);return a>-1?new eY(c.pos,a,this.$to.pos,this.$to.end(),h,b):h.size||c.pos!=this.$to.pos?new eX(c.pos,d.pos,h):null}findFittable(){let a=this.unplaced.openStart;for(let b=this.unplaced.content,c=0,d=this.unplaced.openEnd;c<a;c++){let e=b.firstChild;if(b.childCount>1&&(d=0),e.type.spec.isolating&&d<=c){a=c;break}b=e.content}for(let b=1;b<=2;b++)for(let c=1==b?a:this.unplaced.openStart;c>=0;c--){let a=null,d=(c?(a=fe(this.unplaced.content,c-1).firstChild).content:this.unplaced.content).firstChild;for(let e=this.depth;e>=0;e--){let{type:f,match:g}=this.frontier[e],h,i=null;if(1==b&&(d?g.matchType(d.type)||(i=g.fillBefore(d$.from(d),!1)):a&&f.compatibleContent(a.type)))return{sliceDepth:c,frontierDepth:e,parent:a,inject:i};if(2==b&&d&&(h=g.findWrapping(d.type)))return{sliceDepth:c,frontierDepth:e,parent:a,wrap:h};if(a&&g.matchType(a.type))break}}}openMore(){let{content:a,openStart:b,openEnd:c}=this.unplaced,d=fe(a,b);return!!d.childCount&&!d.firstChild.isLeaf&&(this.unplaced=new d4(a,b+1,Math.max(c,d.size+b>=a.size-c?b+1:0)),!0)}dropNode(){let{content:a,openStart:b,openEnd:c}=this.unplaced,d=fe(a,b);if(d.childCount<=1&&b>0){let e=a.size-b<=b+d.size;this.unplaced=new d4(fc(a,b-1,1),b-1,e?b-1:c)}else this.unplaced=new d4(fc(a,b,1),b,c)}placeNodes({sliceDepth:a,frontierDepth:b,parent:c,inject:d,wrap:e}){for(;this.depth>b;)this.closeFrontierNode();if(e)for(let a=0;a<e.length;a++)this.openFrontierNode(e[a]);let f=this.unplaced,g=c?c.content:f.content,h=f.openStart-a,i=0,j=[],{match:k,type:l}=this.frontier[b];if(d){for(let a=0;a<d.childCount;a++)j.push(d.child(a));k=k.matchFragment(d)}let m=g.size+a-(f.content.size-f.openEnd);for(;i<g.childCount;){let a=g.child(i),b=k.matchType(a.type);if(!b)break;(++i>1||0==h||a.content.size)&&(k=b,j.push(function a(b,c,d){if(c<=0)return b;let e=b.content;return c>1&&(e=e.replaceChild(0,a(e.firstChild,c-1,1==e.childCount?d-1:0))),c>0&&(e=b.type.contentMatch.fillBefore(e).append(e),d<=0&&(e=e.append(b.type.contentMatch.matchFragment(e).fillBefore(d$.empty,!0)))),b.copy(e)}(a.mark(l.allowedMarks(a.marks)),1==i?h:0,i==g.childCount?m:-1)))}let n=i==g.childCount;n||(m=-1),this.placed=fd(this.placed,b,d$.from(j)),this.frontier[b].match=k,n&&m<0&&c&&c.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let a=0,b=g;a<m;a++){let a=b.lastChild;this.frontier.push({type:a.type,match:a.contentMatchAt(a.childCount)}),b=a.content}this.unplaced=n?0==a?d4.empty:new d4(fc(f.content,a-1,1),a-1,m<0?f.openEnd:a-1):new d4(fc(f.content,a,i),f.openStart,f.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return -1;let a=this.frontier[this.depth],b;if(!a.type.isTextblock||!ff(this.$to,this.$to.depth,a.type,a.match,!1)||this.$to.depth==this.depth&&(b=this.findCloseLevel(this.$to))&&b.depth==this.depth)return -1;let{depth:c}=this.$to,d=this.$to.after(c);for(;c>1&&d==this.$to.end(--c);)++d;return d}findCloseLevel(a){c:for(let b=Math.min(this.depth,a.depth);b>=0;b--){let{match:c,type:d}=this.frontier[b],e=b<a.depth&&a.end(b+1)==a.pos+(a.depth-(b+1)),f=ff(a,b,d,c,e);if(f){for(let c=b-1;c>=0;c--){let{match:b,type:d}=this.frontier[c],e=ff(a,c,d,b,!0);if(!e||e.childCount)continue c}return{depth:b,fit:f,move:e?a.doc.resolve(a.after(b+1)):a}}}}close(a){let b=this.findCloseLevel(a);if(!b)return null;for(;this.depth>b.depth;)this.closeFrontierNode();b.fit.childCount&&(this.placed=fd(this.placed,b.depth,b.fit)),a=b.move;for(let c=b.depth+1;c<=a.depth;c++){let b=a.node(c),d=b.type.contentMatch.fillBefore(b.content,!0,a.index(c));this.openFrontierNode(b.type,b.attrs,d)}return a}openFrontierNode(a,b=null,c){let d=this.frontier[this.depth];d.match=d.match.matchType(a),this.placed=fd(this.placed,this.depth,d$.from(a.create(b,c))),this.frontier.push({type:a,match:a.contentMatch})}closeFrontierNode(){let a=this.frontier.pop().match.fillBefore(d$.empty,!0);a.childCount&&(this.placed=fd(this.placed,this.frontier.length,a))}}function fc(a,b,c){return 0==b?a.cutByIndex(c,a.childCount):a.replaceChild(0,a.firstChild.copy(fc(a.firstChild.content,b-1,c)))}function fd(a,b,c){return 0==b?a.append(c):a.replaceChild(a.childCount-1,a.lastChild.copy(fd(a.lastChild.content,b-1,c)))}function fe(a,b){for(let c=0;c<b;c++)a=a.firstChild.content;return a}function ff(a,b,c,d,e){let f=a.node(b),g=e?a.indexAfter(b):a.index(b);if(g==f.childCount&&!c.compatibleContent(f.type))return null;let h=d.fillBefore(f.content,!0,g);return h&&!function(a,b,c){for(let d=c;d<b.childCount;d++)if(!a.allowsMarks(b.child(d).marks))return!0;return!1}(c,f.content,g)?h:null}function fg(a,b){let c=[],d=Math.min(a.depth,b.depth);for(let e=d;e>=0;e--){let d=a.start(e);if(d<a.pos-(a.depth-e)||b.end(e)>b.pos+(b.depth-e)||a.node(e).type.spec.isolating||b.node(e).type.spec.isolating)break;(d==b.start(e)||e==a.depth&&e==b.depth&&a.parent.inlineContent&&b.parent.inlineContent&&e&&b.start(e-1)==d-1)&&c.push(e)}return c}class fh extends eQ{constructor(a,b,c){super(),this.pos=a,this.attr=b,this.value=c}apply(a){let b=a.nodeAt(this.pos);if(!b)return eR.fail("No node at attribute step's position");let c=Object.create(null);for(let a in b.attrs)c[a]=b.attrs[a];c[this.attr]=this.value;let d=b.type.create(c,null,b.marks);return eR.fromReplace(a,this.pos,this.pos+1,new d4(d$.from(d),0,+!b.isLeaf))}getMap(){return eN.empty}invert(a){return new fh(this.pos,this.attr,a.nodeAt(this.pos).attrs[this.attr])}map(a){let b=a.mapResult(this.pos,1);return b.deletedAfter?null:new fh(b.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(a,b){if("number"!=typeof b.pos||"string"!=typeof b.attr)throw RangeError("Invalid input for AttrStep.fromJSON");return new fh(b.pos,b.attr,b.value)}}eQ.jsonID("attr",fh);class fi extends eQ{constructor(a,b){super(),this.attr=a,this.value=b}apply(a){let b=Object.create(null);for(let c in a.attrs)b[c]=a.attrs[c];b[this.attr]=this.value;let c=a.type.create(b,a.content,a.marks);return eR.ok(c)}getMap(){return eN.empty}invert(a){return new fi(this.attr,a.attrs[this.attr])}map(a){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(a,b){if("string"!=typeof b.attr)throw RangeError("Invalid input for DocAttrStep.fromJSON");return new fi(b.attr,b.value)}}eQ.jsonID("docAttr",fi);let fj=class extends Error{};(fj=function a(b){let c=Error.call(this,b);return c.__proto__=a.prototype,c}).prototype=Object.create(Error.prototype),fj.prototype.constructor=fj,fj.prototype.name="TransformError";class fk{constructor(a){this.doc=a,this.steps=[],this.docs=[],this.mapping=new eO}get before(){return this.docs.length?this.docs[0]:this.doc}step(a){let b=this.maybeStep(a);if(b.failed)throw new fj(b.failed);return this}maybeStep(a){let b=a.apply(this.doc);return b.failed||this.addStep(a,b.doc),b}get docChanged(){return this.steps.length>0}changedRange(){let a=1e9,b=-1e9;for(let c=0;c<this.mapping.maps.length;c++){let d=this.mapping.maps[c];c&&(a=d.map(a,1),b=d.map(b,-1)),d.forEach((c,d,e,f)=>{a=Math.min(a,e),b=Math.max(b,f)})}return 1e9==a?null:{from:a,to:b}}addStep(a,b){this.docs.push(this.doc),this.steps.push(a),this.mapping.appendMap(a.getMap()),this.doc=b}replace(a,b=a,c=d4.empty){let d=e9(this.doc,a,b,c);return d&&this.step(d),this}replaceWith(a,b,c){return this.replace(a,b,new d4(d$.from(c),0,0))}delete(a,b){return this.replace(a,b,d4.empty)}insert(a,b){return this.replaceWith(a,a,b)}replaceRange(a,b,c){return!function(a,b,c,d){if(!d.size)return a.deleteRange(b,c);let e=a.doc.resolve(b),f=a.doc.resolve(c);if(fa(e,f,d))return a.step(new eX(b,c,d));let g=fg(e,f);0==g[g.length-1]&&g.pop();let h=-(e.depth+1);g.unshift(h);for(let a=e.depth,b=e.pos-1;a>0;a--,b--){let c=e.node(a).type.spec;if(c.defining||c.definingAsContext||c.isolating)break;g.indexOf(a)>-1?h=a:e.before(a)==b&&g.splice(1,0,-a)}let i=g.indexOf(h),j=[],k=d.openStart;for(let a=d.content,b=0;;b++){let c=a.firstChild;if(j.push(c),b==d.openStart)break;a=c.content}for(let a=k-1;a>=0;a--){var l;let b=j[a],c=(l=b.type).spec.defining||l.spec.definingForContent;if(c&&!b.sameMarkup(e.node(Math.abs(h)-1)))k=a;else if(c||!b.type.isTextblock)break}for(let b=d.openStart;b>=0;b--){let h=(b+k+1)%(d.openStart+1),l=j[h];if(l)for(let b=0;b<g.length;b++){let j=g[(b+i)%g.length],k=!0;j<0&&(k=!1,j=-j);let m=e.node(j-1),n=e.index(j-1);if(m.canReplaceWith(n,n,l.type,l.marks))return a.replace(e.before(j),k?f.after(j):c,new d4(function a(b,c,d,e,f){if(c<d){let f=b.firstChild;b=b.replaceChild(0,f.copy(a(f.content,c+1,d,e,f)))}if(c>e){let a=f.contentMatchAt(0),c=a.fillBefore(b).append(b);b=c.append(a.matchFragment(c).fillBefore(d$.empty,!0))}return b}(d.content,0,d.openStart,h),h,d.openEnd))}}let m=a.steps.length;for(let h=g.length-1;h>=0&&(a.replace(b,c,d),!(a.steps.length>m));h--){let a=g[h];a<0||(b=e.before(a),c=f.after(a))}}(this,a,b,c),this}replaceRangeWith(a,b,c){var d=a,e=b;if(!c.isInline&&d==e&&this.doc.resolve(d).parent.content.size){let a=function(a,b,c){let d=a.resolve(b);if(d.parent.canReplaceWith(d.index(),d.index(),c))return b;if(0==d.parentOffset)for(let a=d.depth-1;a>=0;a--){let b=d.index(a);if(d.node(a).canReplaceWith(b,b,c))return d.before(a+1);if(b>0)return null}if(d.parentOffset==d.parent.content.size)for(let a=d.depth-1;a>=0;a--){let b=d.indexAfter(a);if(d.node(a).canReplaceWith(b,b,c))return d.after(a+1);if(b<d.node(a).childCount)break}return null}(this.doc,d,c.type);null!=a&&(d=e=a)}return this.replaceRange(d,e,new d4(d$.from(c),0,0)),this}deleteRange(a,b){return!function(a,b,c){let d=a.doc.resolve(b),e=a.doc.resolve(c);if(d.parent.isTextblock&&e.parent.isTextblock&&d.start()!=e.start()&&0==d.parentOffset&&0==e.parentOffset){let f=d.sharedDepth(c),g=!1;for(let a=d.depth;a>f;a--)d.node(a).type.spec.isolating&&(g=!0);for(let a=e.depth;a>f;a--)e.node(a).type.spec.isolating&&(g=!0);if(!g){for(let a=d.depth;a>0&&b==d.start(a);a--)b=d.before(a);for(let a=e.depth;a>0&&c==e.start(a);a--)c=e.before(a);d=a.doc.resolve(b),e=a.doc.resolve(c)}}let f=fg(d,e);for(let b=0;b<f.length;b++){let c=f[b],g=b==f.length-1;if(g&&0==c||d.node(c).type.contentMatch.validEnd)return a.delete(d.start(c),e.end(c));if(c>0&&(g||d.node(c-1).canReplace(d.index(c-1),e.indexAfter(c-1))))return a.delete(d.before(c),e.after(c))}for(let f=1;f<=d.depth&&f<=e.depth;f++)if(b-d.start(f)==d.depth-f&&c>d.end(f)&&e.end(f)-c!=e.depth-f&&d.start(f-1)==e.start(f-1)&&d.node(f-1).canReplace(d.index(f-1),e.index(f-1)))return a.delete(d.before(f),c);a.delete(b,c)}(this,a,b),this}lift(a,b){return!function(a,b,c){let{$from:d,$to:e,depth:f}=b,g=d.before(f+1),h=e.after(f+1),i=g,j=h,k=d$.empty,l=0;for(let a=f,b=!1;a>c;a--)b||d.index(a)>0?(b=!0,k=d$.from(d.node(a).copy(k)),l++):i--;let m=d$.empty,n=0;for(let a=f,b=!1;a>c;a--)b||e.after(a+1)<e.end(a)?(b=!0,m=d$.from(e.node(a).copy(m)),n++):j++;a.step(new eY(i,j,g,h,new d4(k.append(m),l,n),k.size-l,!0))}(this,a,b),this}join(a,b=1){return!function(a,b,c){let d=null,{linebreakReplacement:e}=a.doc.type.schema,f=a.doc.resolve(b-c),g=f.node().type;if(e&&g.inlineContent){let a="pre"==g.whitespace,b=!!g.contentMatch.matchType(e);a&&!b?d=!1:!a&&b&&(d=!0)}let h=a.steps.length;if(!1===d){let d=a.doc.resolve(b+c);e3(a,d.node(),d.before(),h)}g.inlineContent&&e$(a,b+c-1,g,f.node().contentMatchAt(f.index()),null==d);let i=a.mapping.slice(h),j=i.map(b-c);if(a.step(new eX(j,i.map(b+c,-1),d4.empty,!0)),!0===d){let b=a.doc.resolve(j);e2(a,b.node(),b.before(),a.steps.length)}}(this,a,b),this}wrap(a,b){return!function(a,b,c){let d=d$.empty;for(let a=c.length-1;a>=0;a--){if(d.size){let b=c[a].type.contentMatch.matchFragment(d);if(!b||!b.validEnd)throw RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}d=d$.from(c[a].type.create(c[a].attrs,d))}let e=b.start,f=b.end;a.step(new eY(e,f,e,f,new d4(d,0,0),c.length,!0))}(this,a,b),this}setBlockType(a,b=a,c,d=null){var e=this;if(!c.isTextblock)throw RangeError("Type given to setBlockType should be a textblock");let f=e.steps.length;return e.doc.nodesBetween(a,b,(a,b)=>{var g,h,i;let j,k,l="function"==typeof d?d(a):d;if(a.isTextblock&&!a.hasMarkup(c,l)&&(g=e.doc,h=e.mapping.slice(f).map(b),i=c,k=(j=g.resolve(h)).index(),j.parent.canReplaceWith(k,k+1,i))){let d=null;if(c.schema.linebreakReplacement){let a="pre"==c.whitespace,b=!!c.contentMatch.matchType(c.schema.linebreakReplacement);a&&!b?d=!1:!a&&b&&(d=!0)}!1===d&&e3(e,a,b,f),e$(e,e.mapping.slice(f).map(b,1),c,void 0,null===d);let g=e.mapping.slice(f),h=g.map(b,1),i=g.map(b+a.nodeSize,1);return e.step(new eY(h,i,h+1,i-1,new d4(d$.from(c.create(l,null,a.marks)),0,0),1,!0)),!0===d&&e2(e,a,b,f),!1}}),this}setNodeMarkup(a,b,c=null,d){return!function(a,b,c,d,e){let f=a.doc.nodeAt(b);if(!f)throw RangeError("No node at given position");c||(c=f.type);let g=c.create(d,null,e||f.marks);if(f.isLeaf)return a.replaceWith(b,b+f.nodeSize,g);if(!c.validContent(f.content))throw RangeError("Invalid content for node type "+c.name);a.step(new eY(b,b+f.nodeSize,b+1,b+f.nodeSize-1,new d4(d$.from(g),0,0),1,!0))}(this,a,b,c,d),this}setNodeAttribute(a,b,c){return this.step(new fh(a,b,c)),this}setDocAttribute(a,b){return this.step(new fi(a,b)),this}addNodeMark(a,b){return this.step(new eV(a,b)),this}removeNodeMark(a,b){let c=this.doc.nodeAt(a);if(!c)throw RangeError("No node at position "+a);if(b instanceof d2)b.isInSet(c.marks)&&this.step(new eW(a,b));else{let d=c.marks,e,f=[];for(;e=b.isInSet(d);)f.push(new eW(a,e)),d=e.removeFromSet(d);for(let a=f.length-1;a>=0;a--)this.step(f[a])}return this}split(a,b=1,c){return!function(a,b,c=1,d){let e=a.doc.resolve(b),f=d$.empty,g=d$.empty;for(let a=e.depth,b=e.depth-c,h=c-1;a>b;a--,h--){f=d$.from(e.node(a).copy(f));let b=d&&d[h];g=d$.from(b?b.type.create(b.attrs,g):e.node(a).copy(g))}a.step(new eX(b,b,new d4(f.append(g),c,c),!0))}(this,a,b,c),this}addMark(a,b,c){var d;let e,f,g,h;return d=this,g=[],h=[],d.doc.nodesBetween(a,b,(d,i,j)=>{if(!d.isInline)return;let k=d.marks;if(!c.isInSet(k)&&j.type.allowsMarkType(c.type)){let j=Math.max(i,a),l=Math.min(i+d.nodeSize,b),m=c.addToSet(k);for(let a=0;a<k.length;a++)k[a].isInSet(m)||(e&&e.to==j&&e.mark.eq(k[a])?e.to=l:g.push(e=new eU(j,l,k[a])));f&&f.to==j?f.to=l:h.push(f=new eT(j,l,c))}}),g.forEach(a=>d.step(a)),h.forEach(a=>d.step(a)),this}removeMark(a,b,c){var d;let e,f;return d=this,e=[],f=0,d.doc.nodesBetween(a,b,(d,g)=>{if(!d.isInline)return;f++;let h=null;if(c instanceof ev){let a=d.marks,b;for(;b=c.isInSet(a);)(h||(h=[])).push(b),a=b.removeFromSet(a)}else c?c.isInSet(d.marks)&&(h=[c]):h=d.marks;if(h&&h.length){let c=Math.min(g+d.nodeSize,b);for(let b=0;b<h.length;b++){let d=h[b],i;for(let a=0;a<e.length;a++){let b=e[a];b.step==f-1&&d.eq(e[a].style)&&(i=b)}i?(i.to=c,i.step=f):e.push({style:d,from:Math.max(g,a),to:c,step:f})}}}),e.forEach(a=>d.step(new eU(a.from,a.to,a.style))),this}clearIncompatible(a,b,c){return e$(this,a,b,c),this}}let fl=Object.create(null);class fm{constructor(a,b,c){this.$anchor=a,this.$head=b,this.ranges=c||[new fn(a.min(b),a.max(b))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let a=this.ranges;for(let b=0;b<a.length;b++)if(a[b].$from.pos!=a[b].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(a,b=d4.empty){let c=b.content.lastChild,d=null;for(let a=0;a<b.openEnd;a++)d=c,c=c.lastChild;let e=a.steps.length,f=this.ranges;for(let g=0;g<f.length;g++){let{$from:h,$to:i}=f[g],j=a.mapping.slice(e);a.replaceRange(j.map(h.pos),j.map(i.pos),g?d4.empty:b),0==g&&fx(a,e,(c?c.isInline:d&&d.isTextblock)?-1:1)}}replaceWith(a,b){let c=a.steps.length,d=this.ranges;for(let e=0;e<d.length;e++){let{$from:f,$to:g}=d[e],h=a.mapping.slice(c),i=h.map(f.pos),j=h.map(g.pos);e?a.deleteRange(i,j):(a.replaceRangeWith(i,j,b),fx(a,c,b.isInline?-1:1))}}static findFrom(a,b,c=!1){let d=a.parent.inlineContent?new fq(a):fw(a.node(0),a.parent,a.pos,a.index(),b,c);if(d)return d;for(let d=a.depth-1;d>=0;d--){let e=b<0?fw(a.node(0),a.node(d),a.before(d+1),a.index(d),b,c):fw(a.node(0),a.node(d),a.after(d+1),a.index(d)+1,b,c);if(e)return e}return null}static near(a,b=1){return this.findFrom(a,b)||this.findFrom(a,-b)||new fu(a.node(0))}static atStart(a){return fw(a,a,0,0,1)||new fu(a)}static atEnd(a){return fw(a,a,a.content.size,a.childCount,-1)||new fu(a)}static fromJSON(a,b){if(!b||!b.type)throw RangeError("Invalid input for Selection.fromJSON");let c=fl[b.type];if(!c)throw RangeError(`No selection type ${b.type} defined`);return c.fromJSON(a,b)}static jsonID(a,b){if(a in fl)throw RangeError("Duplicate use of selection JSON ID "+a);return fl[a]=b,b.prototype.jsonID=a,b}getBookmark(){return fq.between(this.$anchor,this.$head).getBookmark()}}fm.prototype.visible=!0;class fn{constructor(a,b){this.$from=a,this.$to=b}}let fo=!1;function fp(a){fo||a.parent.inlineContent||(fo=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+a.parent.type.name+")"))}class fq extends fm{constructor(a,b=a){fp(a),fp(b),super(a,b)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(a,b){let c=a.resolve(b.map(this.head));if(!c.parent.inlineContent)return fm.near(c);let d=a.resolve(b.map(this.anchor));return new fq(d.parent.inlineContent?d:c,c)}replace(a,b=d4.empty){if(super.replace(a,b),b==d4.empty){let b=this.$from.marksAcross(this.$to);b&&a.ensureMarks(b)}}eq(a){return a instanceof fq&&a.anchor==this.anchor&&a.head==this.head}getBookmark(){return new fr(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(a,b){if("number"!=typeof b.anchor||"number"!=typeof b.head)throw RangeError("Invalid input for TextSelection.fromJSON");return new fq(a.resolve(b.anchor),a.resolve(b.head))}static create(a,b,c=b){let d=a.resolve(b);return new this(d,c==b?d:a.resolve(c))}static between(a,b,c){let d=a.pos-b.pos;if((!c||d)&&(c=d>=0?1:-1),!b.parent.inlineContent){let a=fm.findFrom(b,c,!0)||fm.findFrom(b,-c,!0);if(!a)return fm.near(b,c);b=a.$head}return a.parent.inlineContent||(0==d?a=b:(a=(fm.findFrom(a,-c,!0)||fm.findFrom(a,c,!0)).$anchor).pos<b.pos!=d<0&&(a=b)),new fq(a,b)}}fm.jsonID("text",fq);class fr{constructor(a,b){this.anchor=a,this.head=b}map(a){return new fr(a.map(this.anchor),a.map(this.head))}resolve(a){return fq.between(a.resolve(this.anchor),a.resolve(this.head))}}class fs extends fm{constructor(a){let b=a.nodeAfter,c=a.node(0).resolve(a.pos+b.nodeSize);super(a,c),this.node=b}map(a,b){let{deleted:c,pos:d}=b.mapResult(this.anchor),e=a.resolve(d);return c?fm.near(e):new fs(e)}content(){return new d4(d$.from(this.node),0,0)}eq(a){return a instanceof fs&&a.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new ft(this.anchor)}static fromJSON(a,b){if("number"!=typeof b.anchor)throw RangeError("Invalid input for NodeSelection.fromJSON");return new fs(a.resolve(b.anchor))}static create(a,b){return new fs(a.resolve(b))}static isSelectable(a){return!a.isText&&!1!==a.type.spec.selectable}}fs.prototype.visible=!1,fm.jsonID("node",fs);class ft{constructor(a){this.anchor=a}map(a){let{deleted:b,pos:c}=a.mapResult(this.anchor);return b?new fr(c,c):new ft(c)}resolve(a){let b=a.resolve(this.anchor),c=b.nodeAfter;return c&&fs.isSelectable(c)?new fs(b):fm.near(b)}}class fu extends fm{constructor(a){super(a.resolve(0),a.resolve(a.content.size))}replace(a,b=d4.empty){if(b==d4.empty){a.delete(0,a.doc.content.size);let b=fm.atStart(a.doc);b.eq(a.selection)||a.setSelection(b)}else super.replace(a,b)}toJSON(){return{type:"all"}}static fromJSON(a){return new fu(a)}map(a){return new fu(a)}eq(a){return a instanceof fu}getBookmark(){return fv}}fm.jsonID("all",fu);let fv={map(){return this},resolve:a=>new fu(a)};function fw(a,b,c,d,e,f=!1){if(b.inlineContent)return fq.create(a,c);for(let g=d-(e>0?0:1);e>0?g<b.childCount:g>=0;g+=e){let d=b.child(g);if(d.isAtom){if(!f&&fs.isSelectable(d))return fs.create(a,c-(e<0?d.nodeSize:0))}else{let b=fw(a,d,c+e,e<0?d.childCount:0,e,f);if(b)return b}c+=d.nodeSize*e}return null}function fx(a,b,c){let d,e=a.steps.length-1;if(e<b)return;let f=a.steps[e];(f instanceof eX||f instanceof eY)&&(a.mapping.maps[e].forEach((a,b,c,e)=>{null==d&&(d=e)}),a.setSelection(fm.near(a.doc.resolve(d),c)))}class fy extends fk{constructor(a){super(a.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=a.selection,this.storedMarks=a.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(a){if(a.$from.doc!=this.doc)throw RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=a,this.curSelectionFor=this.steps.length,this.updated=(1|this.updated)&-3,this.storedMarks=null,this}get selectionSet(){return(1&this.updated)>0}setStoredMarks(a){return this.storedMarks=a,this.updated|=2,this}ensureMarks(a){return d2.sameSet(this.storedMarks||this.selection.$from.marks(),a)||this.setStoredMarks(a),this}addStoredMark(a){return this.ensureMarks(a.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(a){return this.ensureMarks(a.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(2&this.updated)>0}addStep(a,b){super.addStep(a,b),this.updated=-3&this.updated,this.storedMarks=null}setTime(a){return this.time=a,this}replaceSelection(a){return this.selection.replace(this,a),this}replaceSelectionWith(a,b=!0){let c=this.selection;return b&&(a=a.mark(this.storedMarks||(c.empty?c.$from.marks():c.$from.marksAcross(c.$to)||d2.none))),c.replaceWith(this,a),this}deleteSelection(){return this.selection.replace(this),this}insertText(a,b,c){let d=this.doc.type.schema;if(null==b)return a?this.replaceSelectionWith(d.text(a),!0):this.deleteSelection();{if(null==c&&(c=b),!a)return this.deleteRange(b,c);let e=this.storedMarks;if(!e){let a=this.doc.resolve(b);e=c==b?a.marks():a.marksAcross(this.doc.resolve(c))}return this.replaceRangeWith(b,c,d.text(a,e)),this.selection.empty||this.selection.to!=b+a.length||this.setSelection(fm.near(this.selection.$to)),this}}setMeta(a,b){return this.meta["string"==typeof a?a:a.key]=b,this}getMeta(a){return this.meta["string"==typeof a?a:a.key]}get isGeneric(){for(let a in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=4,this}get scrolledIntoView(){return(4&this.updated)>0}}function fz(a,b){return b&&a?a.bind(b):a}class fA{constructor(a,b,c){this.name=a,this.init=fz(b.init,c),this.apply=fz(b.apply,c)}}let fB=[new fA("doc",{init:a=>a.doc||a.schema.topNodeType.createAndFill(),apply:a=>a.doc}),new fA("selection",{init:(a,b)=>a.selection||fm.atStart(b.doc),apply:a=>a.selection}),new fA("storedMarks",{init:a=>a.storedMarks||null,apply:(a,b,c,d)=>d.selection.$cursor?a.storedMarks:null}),new fA("scrollToSelection",{init:()=>0,apply:(a,b)=>a.scrolledIntoView?b+1:b})];class fC{constructor(a,b){this.schema=a,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=fB.slice(),b&&b.forEach(a=>{if(this.pluginsByKey[a.key])throw RangeError("Adding different instances of a keyed plugin ("+a.key+")");this.plugins.push(a),this.pluginsByKey[a.key]=a,a.spec.state&&this.fields.push(new fA(a.key,a.spec.state,a))})}}class fD{constructor(a){this.config=a}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(a){return this.applyTransaction(a).state}filterTransaction(a,b=-1){for(let c=0;c<this.config.plugins.length;c++)if(c!=b){let b=this.config.plugins[c];if(b.spec.filterTransaction&&!b.spec.filterTransaction.call(b,a,this))return!1}return!0}applyTransaction(a){if(!this.filterTransaction(a))return{state:this,transactions:[]};let b=[a],c=this.applyInner(a),d=null;for(;;){let e=!1;for(let f=0;f<this.config.plugins.length;f++){let g=this.config.plugins[f];if(g.spec.appendTransaction){let h=d?d[f].n:0,i=d?d[f].state:this,j=h<b.length&&g.spec.appendTransaction.call(g,h?b.slice(h):b,i,c);if(j&&c.filterTransaction(j,f)){if(j.setMeta("appendedTransaction",a),!d){d=[];for(let a=0;a<this.config.plugins.length;a++)d.push(a<f?{state:c,n:b.length}:{state:this,n:0})}b.push(j),c=c.applyInner(j),e=!0}d&&(d[f]={state:c,n:b.length})}}if(!e)return{state:c,transactions:b}}}applyInner(a){if(!a.before.eq(this.doc))throw RangeError("Applying a mismatched transaction");let b=new fD(this.config),c=this.config.fields;for(let d=0;d<c.length;d++){let e=c[d];b[e.name]=e.apply(a,this[e.name],this,b)}return b}get tr(){return new fy(this)}static create(a){let b=new fC(a.doc?a.doc.type.schema:a.schema,a.plugins),c=new fD(b);for(let d=0;d<b.fields.length;d++)c[b.fields[d].name]=b.fields[d].init(a,c);return c}reconfigure(a){let b=new fC(this.schema,a.plugins),c=b.fields,d=new fD(b);for(let b=0;b<c.length;b++){let e=c[b].name;d[e]=this.hasOwnProperty(e)?this[e]:c[b].init(a,d)}return d}toJSON(a){let b={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(b.storedMarks=this.storedMarks.map(a=>a.toJSON())),a&&"object"==typeof a)for(let c in a){if("doc"==c||"selection"==c)throw RangeError("The JSON fields `doc` and `selection` are reserved");let d=a[c],e=d.spec.state;e&&e.toJSON&&(b[c]=e.toJSON.call(d,this[d.key]))}return b}static fromJSON(a,b,c){if(!b)throw RangeError("Invalid input for EditorState.fromJSON");if(!a.schema)throw RangeError("Required config field 'schema' missing");let d=new fC(a.schema,a.plugins),e=new fD(d);return d.fields.forEach(d=>{if("doc"==d.name)e.doc=eh.fromJSON(a.schema,b.doc);else if("selection"==d.name)e.selection=fm.fromJSON(e.doc,b.selection);else if("storedMarks"==d.name)b.storedMarks&&(e.storedMarks=b.storedMarks.map(a.schema.markFromJSON));else{if(c)for(let f in c){let g=c[f],h=g.spec.state;if(g.key==d.name&&h&&h.fromJSON&&Object.prototype.hasOwnProperty.call(b,f)){e[d.name]=h.fromJSON.call(g,a,b[f],e);return}}e[d.name]=d.init(a,e)}}),e}}class fE{constructor(a){this.spec=a,this.props={},a.props&&function a(b,c,d){for(let e in b){let f=b[e];f instanceof Function?f=f.bind(c):"handleDOMEvents"==e&&(f=a(f,c,{})),d[e]=f}return d}(a.props,this,this.props),this.key=a.key?a.key.key:fG("plugin")}getState(a){return a[this.key]}}let fF=Object.create(null);function fG(a){return a in fF?a+"$"+ ++fF[a]:(fF[a]=0,a+"$")}class fH{constructor(a="key"){this.key=fG(a)}get(a){return a.config.pluginsByKey[this.key]}getState(a){return a[this.key]}}let fI=function(a){for(var b=0;;b++)if(!(a=a.previousSibling))return b},fJ=function(a){let b=a.assignedSlot||a.parentNode;return b&&11==b.nodeType?b.host:b},fK=null,fL=function(a,b,c){let d=fK||(fK=document.createRange());return d.setEnd(a,null==c?a.nodeValue.length:c),d.setStart(a,b||0),d},fM=function(){fK=null},fN=function(a,b,c,d){return c&&(fP(a,b,c,d,-1)||fP(a,b,c,d,1))},fO=/^(img|br|input|textarea|hr)$/i;function fP(a,b,c,d,e){for(var f;;){if(a==c&&b==d)return!0;if(b==(e<0?0:fQ(a))){let c=a.parentNode;if(!c||1!=c.nodeType||fR(a)||fO.test(a.nodeName)||"false"==a.contentEditable)return!1;b=fI(a)+(e<0?0:1),a=c}else{if(1!=a.nodeType)return!1;let c=a.childNodes[b+(e<0?-1:0)];if(1==c.nodeType&&"false"==c.contentEditable)if(null==(f=c.pmViewDesc)||!f.ignoreForSelection)return!1;else b+=e;else a=c,b=e<0?fQ(a):0}}}function fQ(a){return 3==a.nodeType?a.nodeValue.length:a.childNodes.length}function fR(a){let b;for(let c=a;c&&!(b=c.pmViewDesc);c=c.parentNode);return b&&b.node&&b.node.isBlock&&(b.dom==a||b.contentDOM==a)}let fS=function(a){return a.focusNode&&fN(a.focusNode,a.focusOffset,a.anchorNode,a.anchorOffset)};function fT(a,b){let c=document.createEvent("Event");return c.initEvent("keydown",!0,!0),c.keyCode=a,c.key=c.code=b,c}let fU="u">typeof navigator?navigator:null,fV="u">typeof document?document:null,fW=fU&&fU.userAgent||"",fX=/Edge\/(\d+)/.exec(fW),fY=/MSIE \d/.exec(fW),fZ=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(fW),f$=!!(fY||fZ||fX),f_=fY?document.documentMode:fZ?+fZ[1]:fX?+fX[1]:0,f0=!f$&&/gecko\/(\d+)/i.test(fW);f0&&(/Firefox\/(\d+)/.exec(fW)||[0,0])[1];let f1=!f$&&/Chrome\/(\d+)/.exec(fW),f2=!!f1,f3=f1?+f1[1]:0,f4=!f$&&!!fU&&/Apple Computer/.test(fU.vendor),f5=f4&&(/Mobile\/\w+/.test(fW)||!!fU&&fU.maxTouchPoints>2),f6=f5||!!fU&&/Mac/.test(fU.platform),f7=!!fU&&/Win/.test(fU.platform),f8=/Android \d/.test(fW),f9=!!fV&&"webkitFontSmoothing"in fV.documentElement.style,ga=f9?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function gb(a,b){return"number"==typeof a?a:a[b]}function gc(a,b,c){let d=a.someProp("scrollThreshold")||0,e=a.someProp("scrollMargin")||5,f=a.dom.ownerDocument;for(let g=c||a.dom;g;){if(1!=g.nodeType){g=fJ(g);continue}let a=g,c=a==f.body,h=c?function(a){let b=a.defaultView&&a.defaultView.visualViewport;return b?{left:0,right:b.width,top:0,bottom:b.height}:{left:0,right:a.documentElement.clientWidth,top:0,bottom:a.documentElement.clientHeight}}(f):function(a){let b=a.getBoundingClientRect(),c=b.width/a.offsetWidth||1,d=b.height/a.offsetHeight||1;return{left:b.left,right:b.left+a.clientWidth*c,top:b.top,bottom:b.top+a.clientHeight*d}}(a),i=0,j=0;if(b.top<h.top+gb(d,"top")?j=-(h.top-b.top+gb(e,"top")):b.bottom>h.bottom-gb(d,"bottom")&&(j=b.bottom-b.top>h.bottom-h.top?b.top+gb(e,"top")-h.top:b.bottom-h.bottom+gb(e,"bottom")),b.left<h.left+gb(d,"left")?i=-(h.left-b.left+gb(e,"left")):b.right>h.right-gb(d,"right")&&(i=b.right-h.right+gb(e,"right")),i||j)if(c)f.defaultView.scrollBy(i,j);else{let c=a.scrollLeft,d=a.scrollTop;j&&(a.scrollTop+=j),i&&(a.scrollLeft+=i);let e=a.scrollLeft-c,f=a.scrollTop-d;b={left:b.left-e,top:b.top-f,right:b.right-e,bottom:b.bottom-f}}let k=c?"fixed":getComputedStyle(g).position;if(/^(fixed|sticky)$/.test(k))break;g="absolute"==k?g.offsetParent:fJ(g)}}function gd(a){let b=[],c=a.ownerDocument;for(let d=a;d&&(b.push({dom:d,top:d.scrollTop,left:d.scrollLeft}),a!=c);d=fJ(d));return b}function ge(a,b){for(let c=0;c<a.length;c++){let{dom:d,top:e,left:f}=a[c];d.scrollTop!=e+b&&(d.scrollTop=e+b),d.scrollLeft!=f&&(d.scrollLeft=f)}}let gf=null;function gg(a,b){return a.left>=b.left-1&&a.left<=b.right+1&&a.top>=b.top-1&&a.top<=b.bottom+1}function gh(a){return a.top<a.bottom||a.left<a.right}function gi(a,b){let c=a.getClientRects();if(c.length){let a=c[b<0?0:c.length-1];if(gh(a))return a}return Array.prototype.find.call(c,gh)||a.getBoundingClientRect()}let gj=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function gk(a,b,c){let{node:d,offset:e,atom:f}=a.docView.domFromPos(b,c<0?-1:1),g=f9||f0;if(3==d.nodeType)if(g&&(gj.test(d.nodeValue)||(c<0?!e:e==d.nodeValue.length))){let a=gi(fL(d,e,e),c);if(f0&&e&&/\s/.test(d.nodeValue[e-1])&&e<d.nodeValue.length){let b=gi(fL(d,e-1,e-1),-1);if(b.top==a.top){let c=gi(fL(d,e,e+1),-1);if(c.top!=a.top)return gl(c,c.left<b.left)}}return a}else{let a=e,b=e,f=c<0?1:-1;return c<0&&!e?(b++,f=-1):c>=0&&e==d.nodeValue.length?(a--,f=1):c<0?a--:b++,gl(gi(fL(d,a,b),f),f<0)}if(!a.state.doc.resolve(b-(f||0)).parent.inlineContent){if(null==f&&e&&(c<0||e==fQ(d))){let a=d.childNodes[e-1];if(1==a.nodeType)return gm(a.getBoundingClientRect(),!1)}if(null==f&&e<fQ(d)){let a=d.childNodes[e];if(1==a.nodeType)return gm(a.getBoundingClientRect(),!0)}return gm(d.getBoundingClientRect(),c>=0)}if(null==f&&e&&(c<0||e==fQ(d))){let a=d.childNodes[e-1],b=3==a.nodeType?fL(a,fQ(a)-!g):1!=a.nodeType||"BR"==a.nodeName&&a.nextSibling?null:a;if(b)return gl(gi(b,1),!1)}if(null==f&&e<fQ(d)){let a=d.childNodes[e];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let b=a?3==a.nodeType?fL(a,0,+!g):1==a.nodeType?a:null:null;if(b)return gl(gi(b,-1),!0)}return gl(gi(3==d.nodeType?fL(d):d,-c),c>=0)}function gl(a,b){if(0==a.width)return a;let c=b?a.left:a.right;return{top:a.top,bottom:a.bottom,left:c,right:c}}function gm(a,b){if(0==a.height)return a;let c=b?a.top:a.bottom;return{top:c,bottom:c,left:a.left,right:a.right}}function gn(a,b,c){let d=a.state,e=a.root.activeElement;d!=b&&a.updateState(b),e!=a.dom&&a.focus();try{return c()}finally{d!=b&&a.updateState(d),e!=a.dom&&e&&e.focus()}}let go=/[\u0590-\u08ac]/,gp=null,gq=null,gr=!1;class gs{constructor(a,b,c,d){this.parent=a,this.children=b,this.dom=c,this.contentDOM=d,this.dirty=0,c.pmViewDesc=this}matchesWidget(a){return!1}matchesMark(a){return!1}matchesNode(a,b,c){return!1}matchesHack(a){return!1}parseRule(){return null}stopEvent(a){return!1}get size(){let a=0;for(let b=0;b<this.children.length;b++)a+=this.children[b].size;return a}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let a=0;a<this.children.length;a++)this.children[a].destroy()}posBeforeChild(a){for(let b=0,c=this.posAtStart;;b++){let d=this.children[b];if(d==a)return c;c+=d.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(a,b,c){let d;if(this.contentDOM&&this.contentDOM.contains(1==a.nodeType?a:a.parentNode))if(c<0){let c,d;if(a==this.contentDOM)c=a.childNodes[b-1];else{for(;a.parentNode!=this.contentDOM;)a=a.parentNode;c=a.previousSibling}for(;c&&!((d=c.pmViewDesc)&&d.parent==this);)c=c.previousSibling;return c?this.posBeforeChild(d)+d.size:this.posAtStart}else{let c,d;if(a==this.contentDOM)c=a.childNodes[b];else{for(;a.parentNode!=this.contentDOM;)a=a.parentNode;c=a.nextSibling}for(;c&&!((d=c.pmViewDesc)&&d.parent==this);)c=c.nextSibling;return c?this.posBeforeChild(d):this.posAtEnd}if(a==this.dom&&this.contentDOM)d=b>fI(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))d=2&a.compareDocumentPosition(this.contentDOM);else if(this.dom.firstChild){if(0==b)for(let b=a;;b=b.parentNode){if(b==this.dom){d=!1;break}if(b.previousSibling)break}if(null==d&&b==a.childNodes.length)for(let b=a;;b=b.parentNode){if(b==this.dom){d=!0;break}if(b.nextSibling)break}}return(null==d?c>0:d)?this.posAtEnd:this.posAtStart}nearestDesc(a,b=!1){for(let c=!0,d=a;d;d=d.parentNode){let e=this.getDesc(d),f;if(e&&(!b||e.node))if(!c||!(f=e.nodeDOM)||(1==f.nodeType?f.contains(1==a.nodeType?a:a.parentNode):f==a))return e;else c=!1}}getDesc(a){let b=a.pmViewDesc;for(let a=b;a;a=a.parent)if(a==this)return b}posFromDOM(a,b,c){for(let d=a;d;d=d.parentNode){let e=this.getDesc(d);if(e)return e.localPosFromDOM(a,b,c)}return -1}descAt(a){for(let b=0,c=0;b<this.children.length;b++){let d=this.children[b],e=c+d.size;if(c==a&&e!=c){for(;!d.border&&d.children.length;)for(let a=0;a<d.children.length;a++){let b=d.children[a];if(b.size){d=b;break}}return d}if(a<e)return d.descAt(a-c-d.border);c=e}}domFromPos(a,b){if(!this.contentDOM)return{node:this.dom,offset:0,atom:a+1};let c=0,d=0;for(let b=0;c<this.children.length;c++){let e=this.children[c],f=b+e.size;if(f>a||e instanceof gz){d=a-b;break}b=f}if(d)return this.children[c].domFromPos(d-this.children[c].border,b);for(let a;c&&!(a=this.children[c-1]).size&&a instanceof gt&&a.side>=0;c--);if(b<=0){let a,d=!0;for(;(a=c?this.children[c-1]:null)&&a.dom.parentNode!=this.contentDOM;c--,d=!1);return a&&b&&d&&!a.border&&!a.domAtom?a.domFromPos(a.size,b):{node:this.contentDOM,offset:a?fI(a.dom)+1:0}}{let a,d=!0;for(;(a=c<this.children.length?this.children[c]:null)&&a.dom.parentNode!=this.contentDOM;c++,d=!1);return a&&d&&!a.border&&!a.domAtom?a.domFromPos(0,b):{node:this.contentDOM,offset:a?fI(a.dom):this.contentDOM.childNodes.length}}}parseRange(a,b,c=0){if(0==this.children.length)return{node:this.contentDOM,from:a,to:b,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let d=-1,e=-1;for(let f=c,g=0;;g++){let c=this.children[g],h=f+c.size;if(-1==d&&a<=h){let e=f+c.border;if(a>=e&&b<=h-c.border&&c.node&&c.contentDOM&&this.contentDOM.contains(c.contentDOM))return c.parseRange(a,b,e);a=f;for(let b=g;b>0;b--){let c=this.children[b-1];if(c.size&&c.dom.parentNode==this.contentDOM&&!c.emptyChildAt(1)){d=fI(c.dom)+1;break}a-=c.size}-1==d&&(d=0)}if(d>-1&&(h>b||g==this.children.length-1)){b=h;for(let a=g+1;a<this.children.length;a++){let c=this.children[a];if(c.size&&c.dom.parentNode==this.contentDOM&&!c.emptyChildAt(-1)){e=fI(c.dom);break}b+=c.size}-1==e&&(e=this.contentDOM.childNodes.length);break}f=h}return{node:this.contentDOM,from:a,to:b,fromOffset:d,toOffset:e}}emptyChildAt(a){if(this.border||!this.contentDOM||!this.children.length)return!1;let b=this.children[a<0?0:this.children.length-1];return 0==b.size||b.emptyChildAt(a)}domAfterPos(a){let{node:b,offset:c}=this.domFromPos(a,0);if(1!=b.nodeType||c==b.childNodes.length)throw RangeError("No node after pos "+a);return b.childNodes[c]}setSelection(a,b,c,d=!1){let e=Math.min(a,b),f=Math.max(a,b);for(let g=0,h=0;g<this.children.length;g++){let i=this.children[g],j=h+i.size;if(e>h&&f<j)return i.setSelection(a-h-i.border,b-h-i.border,c,d);h=j}let g=this.domFromPos(a,a?-1:1),h=b==a?g:this.domFromPos(b,b?-1:1),i=c.root.getSelection(),j=c.domSelectionRange(),k=!1;if((f0||f4)&&a==b){let{node:a,offset:b}=g;if(3==a.nodeType){if((k=!!(b&&"\n"==a.nodeValue[b-1]))&&b==a.nodeValue.length)for(let b=a,c;b;b=b.parentNode){if(c=b.nextSibling){"BR"==c.nodeName&&(g=h={node:c.parentNode,offset:fI(c)+1});break}let a=b.pmViewDesc;if(a&&a.node&&a.node.isBlock)break}}else{let c=a.childNodes[b-1];k=c&&("BR"==c.nodeName||"false"==c.contentEditable)}}if(f0&&j.focusNode&&j.focusNode!=h.node&&1==j.focusNode.nodeType){let a=j.focusNode.childNodes[j.focusOffset];a&&"false"==a.contentEditable&&(d=!0)}if(!(d||k&&f4)&&fN(g.node,g.offset,j.anchorNode,j.anchorOffset)&&fN(h.node,h.offset,j.focusNode,j.focusOffset))return;let l=!1;if((i.extend||a==b)&&!(k&&f0)){i.collapse(g.node,g.offset);try{a!=b&&i.extend(h.node,h.offset),l=!0}catch(a){}}if(!l){if(a>b){let a=g;g=h,h=a}let c=document.createRange();c.setEnd(h.node,h.offset),c.setStart(g.node,g.offset),i.removeAllRanges(),i.addRange(c)}}ignoreMutation(a){return!this.contentDOM&&"selection"!=a.type}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(a,b){for(let c=0,d=0;d<this.children.length;d++){let e=this.children[d],f=c+e.size;if(c==f?a<=f&&b>=c:a<f&&b>c){let d=c+e.border,g=f-e.border;if(a>=d&&b<=g){this.dirty=a==c||b==f?2:1,a==d&&b==g&&(e.contentLost||e.dom.parentNode!=this.contentDOM)?e.dirty=3:e.markDirty(a-d,b-d);return}e.dirty=e.dom!=e.contentDOM||e.dom.parentNode!=this.contentDOM||e.children.length?3:2}c=f}this.dirty=2}markParentsDirty(){let a=1;for(let b=this.parent;b;b=b.parent,a++){let c=1==a?2:1;b.dirty<c&&(b.dirty=c)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(a){return!1}}class gt extends gs{constructor(a,b,c,d){let e,f=b.type.toDOM;if("function"==typeof f&&(f=f(c,()=>e?e.parent?e.parent.posBeforeChild(e):void 0:d)),!b.type.spec.raw){if(1!=f.nodeType){let a=document.createElement("span");a.appendChild(f),f=a}f.contentEditable="false",f.classList.add("ProseMirror-widget")}super(a,[],f,null),this.widget=b,this.widget=b,e=this}matchesWidget(a){return 0==this.dirty&&a.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(a){let b=this.widget.spec.stopEvent;return!!b&&b(a)}ignoreMutation(a){return"selection"!=a.type||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class gu extends gs{constructor(a,b,c,d){super(a,[],b,null),this.textDOM=c,this.text=d}get size(){return this.text.length}localPosFromDOM(a,b){return a!=this.textDOM?this.posAtStart+(b?this.size:0):this.posAtStart+b}domFromPos(a){return{node:this.textDOM,offset:a}}ignoreMutation(a){return"characterData"===a.type&&a.target.nodeValue==a.oldValue}}class gv extends gs{constructor(a,b,c,d,e){super(a,[],c,d),this.mark=b,this.spec=e}static create(a,b,c,d){let e=d.nodeViews[b.type.name],f=e&&e(b,d,c);return f&&f.dom||(f=eH.renderSpec(document,b.type.spec.toDOM(b,c),null,b.attrs)),new gv(a,b,f.dom,f.contentDOM||f.dom,f)}parseRule(){return 3&this.dirty||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(a){return 3!=this.dirty&&this.mark.eq(a)}markDirty(a,b){if(super.markDirty(a,b),0!=this.dirty){let a=this.parent;for(;!a.node;)a=a.parent;a.dirty<this.dirty&&(a.dirty=this.dirty),this.dirty=0}}slice(a,b,c){let d=gv.create(this.parent,this.mark,!0,c),e=this.children,f=this.size;b<f&&(e=gK(e,b,f,c)),a>0&&(e=gK(e,0,a,c));for(let a=0;a<e.length;a++)e[a].parent=d;return d.children=e,d}ignoreMutation(a){return this.spec.ignoreMutation?this.spec.ignoreMutation(a):super.ignoreMutation(a)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class gw extends gs{constructor(a,b,c,d,e,f,g,h,i){super(a,[],e,f),this.node=b,this.outerDeco=c,this.innerDeco=d,this.nodeDOM=g}static create(a,b,c,d,e,f){let g=e.nodeViews[b.type.name],h,i=g&&g(b,e,()=>h?h.parent?h.parent.posBeforeChild(h):void 0:f,c,d),j=i&&i.dom,k=i&&i.contentDOM;if(b.isText)if(j){if(3!=j.nodeType)throw RangeError("Text must be rendered as a DOM text node")}else j=document.createTextNode(b.text);else if(!j){let a=eH.renderSpec(document,b.type.spec.toDOM(b),null,b.attrs);({dom:j,contentDOM:k}=a)}k||b.isText||"BR"==j.nodeName||(j.hasAttribute("contenteditable")||(j.contentEditable="false"),b.type.spec.draggable&&(j.draggable=!0));let l=j;return(j=gF(j,c,b),i)?h=new gA(a,b,c,d,j,k||null,l,i,e,f+1):b.isText?new gy(a,b,c,d,j,l,e):new gw(a,b,c,d,j,k||null,l,e,f+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let a={node:this.node.type.name,attrs:this.node.attrs};if("pre"==this.node.type.whitespace&&(a.preserveWhitespace="full"),this.contentDOM)if(this.contentLost){for(let b=this.children.length-1;b>=0;b--){let c=this.children[b];if(this.dom.contains(c.dom.parentNode)){a.contentElement=c.dom.parentNode;break}}a.contentElement||(a.getContent=()=>d$.empty)}else a.contentElement=this.contentDOM;else a.getContent=()=>this.node.content;return a}matchesNode(a,b,c){return 0==this.dirty&&a.eq(this.node)&&gG(b,this.outerDeco)&&c.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return+!this.node.isLeaf}updateChildren(a,b){let c=this.node.inlineContent,d=b,e=a.composing?this.localCompositionInfo(a,b):null,f=e&&e.pos>-1?e:null,g=e&&e.pos<0,h=new gI(this,f&&f.node,a);(function(a,b,c,d){let e=b.locals(a),f=0;if(0==e.length){for(let c=0;c<a.childCount;c++){let g=a.child(c);d(g,e,b.forChild(f,g),c),f+=g.nodeSize}return}let g=0,h=[],i=null;for(let j=0;;){let k,l,m,n;for(;g<e.length&&e[g].to==f;){let a=e[g++];a.widget&&(k?(l||(l=[k])).push(a):k=a)}if(k)if(l){l.sort(gJ);for(let a=0;a<l.length;a++)c(l[a],j,!!i)}else c(k,j,!!i);if(i)n=-1,m=i,i=null;else if(j<a.childCount)n=j,m=a.child(j++);else break;for(let a=0;a<h.length;a++)h[a].to<=f&&h.splice(a--,1);for(;g<e.length&&e[g].from<=f&&e[g].to>f;)h.push(e[g++]);let o=f+m.nodeSize;if(m.isText){let a=o;g<e.length&&e[g].from<a&&(a=e[g].from);for(let b=0;b<h.length;b++)h[b].to<a&&(a=h[b].to);a<o&&(i=m.cut(a-f),m=m.cut(0,a-f),o=a,n=-1)}else for(;g<e.length&&e[g].to<o;)g++;let p=m.isInline&&!m.isLeaf?h.filter(a=>!a.inline):h.slice();d(m,p,b.forChild(f,m),n),f=o}})(this.node,this.innerDeco,(b,e,f)=>{b.spec.marks?h.syncToMarks(b.spec.marks,c,a,e):b.type.side>=0&&!f&&h.syncToMarks(e==this.node.childCount?d2.none:this.node.child(e).marks,c,a,e),h.placeWidget(b,a,d)},(b,f,i,j)=>{let k;h.syncToMarks(b.marks,c,a,j),h.findNodeMatch(b,f,i,j)||g&&a.state.selection.from>d&&a.state.selection.to<d+b.nodeSize&&(k=h.findIndexWithChild(e.node))>-1&&h.updateNodeAt(b,f,i,k,a)||h.updateNextNode(b,f,i,a,j,d)||h.addNode(b,f,i,a,d),d+=b.nodeSize}),h.syncToMarks([],c,a,0),this.node.isTextblock&&h.addTextblockHacks(),h.destroyRest(),(h.changed||2==this.dirty)&&(f&&this.protectLocalComposition(a,f),function a(b,c,d){let e=b.firstChild,f=!1;for(let g=0;g<c.length;g++){let h=c[g],i=h.dom;if(i.parentNode==b){for(;i!=e;)e=gH(e),f=!0;e=e.nextSibling}else f=!0,b.insertBefore(i,e);if(h instanceof gv){let c=e?e.previousSibling:b.lastChild;a(h.contentDOM,h.children,d),e=c?c.nextSibling:b.firstChild}}for(;e;)e=gH(e),f=!0;f&&d.trackWrites==b&&(d.trackWrites=null)}(this.contentDOM,this.children,a),f5&&function(a){if("UL"==a.nodeName||"OL"==a.nodeName){let b=a.style.cssText;a.style.cssText=b+"; list-style: square !important",window.getComputedStyle(a).listStyle,a.style.cssText=b}}(this.dom))}localCompositionInfo(a,b){let{from:c,to:d}=a.state.selection;if(!(a.state.selection instanceof fq)||c<b||d>b+this.node.content.size)return null;let e=a.input.compositionNode;if(!e||!this.dom.contains(e.parentNode))return null;if(!this.node.inlineContent)return{node:e,pos:-1,text:""};{let a=e.nodeValue,f=function(a,b,c,d){for(let e=0,f=0;e<a.childCount&&f<=d;){let g=a.child(e++),h=f;if(f+=g.nodeSize,!g.isText)continue;let i=g.text;for(;e<a.childCount;){let b=a.child(e++);if(f+=b.nodeSize,!b.isText)break;i+=b.text}if(f>=c){if(f>=d&&i.slice(d-b.length-h,d-h)==b)return d-b.length;let a=h<d?i.lastIndexOf(b,d-h-1):-1;if(a>=0&&a+b.length+h>=c)return h+a;if(c==d&&i.length>=d+b.length-h&&i.slice(d-h,d-h+b.length)==b)return d}}return -1}(this.node.content,a,c-b,d-b);return f<0?null:{node:e,pos:f,text:a}}}protectLocalComposition(a,{node:b,pos:c,text:d}){if(this.getDesc(b))return;let e=b;for(;e.parentNode!=this.contentDOM;e=e.parentNode){for(;e.previousSibling;)e.parentNode.removeChild(e.previousSibling);for(;e.nextSibling;)e.parentNode.removeChild(e.nextSibling);e.pmViewDesc&&(e.pmViewDesc=void 0)}let f=new gu(this,e,b,d);a.input.compositionNodes.push(f),this.children=gK(this.children,c,c+d.length,a,f)}update(a,b,c,d){return 3!=this.dirty&&!!a.sameMarkup(this.node)&&(this.updateInner(a,b,c,d),!0)}updateInner(a,b,c,d){this.updateOuterDeco(b),this.node=a,this.innerDeco=c,this.contentDOM&&this.updateChildren(d,this.posAtStart),this.dirty=0}updateOuterDeco(a){if(gG(a,this.outerDeco))return;let b=1!=this.nodeDOM.nodeType,c=this.dom;this.dom=gE(this.dom,this.nodeDOM,gD(this.outerDeco,this.node,b),gD(a,this.node,b)),this.dom!=c&&(c.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=a}selectNode(){1==this.nodeDOM.nodeType&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){1==this.nodeDOM.nodeType&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function gx(a,b,c,d,e){gF(d,b,a);let f=new gw(void 0,a,b,c,d,d,d,e,0);return f.contentDOM&&f.updateChildren(e,0),f}class gy extends gw{constructor(a,b,c,d,e,f,g){super(a,b,c,d,e,null,f,g,0)}parseRule(){let a=this.nodeDOM.parentNode;for(;a&&a!=this.dom&&!a.pmIsDeco;)a=a.parentNode;return{skip:a||!0}}update(a,b,c,d){return 3!=this.dirty&&(0==this.dirty||!!this.inParent())&&!!a.sameMarkup(this.node)&&(this.updateOuterDeco(b),(0!=this.dirty||a.text!=this.node.text)&&a.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=a.text,d.trackWrites==this.nodeDOM&&(d.trackWrites=null)),this.node=a,this.dirty=0,!0)}inParent(){let a=this.parent.contentDOM;for(let b=this.nodeDOM;b;b=b.parentNode)if(b==a)return!0;return!1}domFromPos(a){return{node:this.nodeDOM,offset:a}}localPosFromDOM(a,b,c){return a==this.nodeDOM?this.posAtStart+Math.min(b,this.node.text.length):super.localPosFromDOM(a,b,c)}ignoreMutation(a){return"characterData"!=a.type&&"selection"!=a.type}slice(a,b,c){let d=this.node.cut(a,b),e=document.createTextNode(d.text);return new gy(this.parent,d,this.outerDeco,this.innerDeco,e,e,c)}markDirty(a,b){super.markDirty(a,b),this.dom!=this.nodeDOM&&(0==a||b==this.nodeDOM.nodeValue.length)&&(this.dirty=3)}get domAtom(){return!1}isText(a){return this.node.text==a}}class gz extends gs{parseRule(){return{ignore:!0}}matchesHack(a){return 0==this.dirty&&this.dom.nodeName==a}get domAtom(){return!0}get ignoreForCoords(){return"IMG"==this.dom.nodeName}}class gA extends gw{constructor(a,b,c,d,e,f,g,h,i,j){super(a,b,c,d,e,f,g,i,j),this.spec=h}update(a,b,c,d){if(3==this.dirty)return!1;if(this.spec.update&&(this.node.type==a.type||this.spec.multiType)){let e=this.spec.update(a,b,c);return e&&this.updateInner(a,b,c,d),e}return(!!this.contentDOM||!!a.isLeaf)&&super.update(a,b,c,d)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(a,b,c,d){this.spec.setSelection?this.spec.setSelection(a,b,c.root):super.setSelection(a,b,c,d)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(a){return!!this.spec.stopEvent&&this.spec.stopEvent(a)}ignoreMutation(a){return this.spec.ignoreMutation?this.spec.ignoreMutation(a):super.ignoreMutation(a)}}let gB=function(a){a&&(this.nodeName=a)};gB.prototype=Object.create(null);let gC=[new gB];function gD(a,b,c){if(0==a.length)return gC;let d=c?gC[0]:new gB,e=[d];for(let f=0;f<a.length;f++){let g=a[f].type.attrs;if(g)for(let a in g.nodeName&&e.push(d=new gB(g.nodeName)),g){let f=g[a];null!=f&&(c&&1==e.length&&e.push(d=new gB(b.isInline?"span":"div")),"class"==a?d.class=(d.class?d.class+" ":"")+f:"style"==a?d.style=(d.style?d.style+";":"")+f:"nodeName"!=a&&(d[a]=f))}}return e}function gE(a,b,c,d){if(c==gC&&d==gC)return b;let e=b;for(let b=0;b<d.length;b++){let f=d[b],g=c[b];if(b){let b;g&&g.nodeName==f.nodeName&&e!=a&&(b=e.parentNode)&&b.nodeName.toLowerCase()==f.nodeName||((b=document.createElement(f.nodeName)).pmIsDeco=!0,b.appendChild(e),g=gC[0]),e=b}!function(a,b,c){for(let d in b)"class"==d||"style"==d||"nodeName"==d||d in c||a.removeAttribute(d);for(let d in c)"class"!=d&&"style"!=d&&"nodeName"!=d&&c[d]!=b[d]&&a.setAttribute(d,c[d]);if(b.class!=c.class){let d=b.class?b.class.split(" ").filter(Boolean):[],e=c.class?c.class.split(" ").filter(Boolean):[];for(let b=0;b<d.length;b++)-1==e.indexOf(d[b])&&a.classList.remove(d[b]);for(let b=0;b<e.length;b++)-1==d.indexOf(e[b])&&a.classList.add(e[b]);0==a.classList.length&&a.removeAttribute("class")}if(b.style!=c.style){if(b.style){let c=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,d;for(;d=c.exec(b.style);)a.style.removeProperty(d[1])}c.style&&(a.style.cssText+=c.style)}}(e,g||gC[0],f)}return e}function gF(a,b,c){return gE(a,a,gC,gD(b,c,1!=a.nodeType))}function gG(a,b){if(a.length!=b.length)return!1;for(let c=0;c<a.length;c++)if(!a[c].type.eq(b[c].type))return!1;return!0}function gH(a){let b=a.nextSibling;return a.parentNode.removeChild(a),b}class gI{constructor(a,b,c){this.lock=b,this.view=c,this.index=0,this.stack=[],this.changed=!1,this.top=a,this.preMatch=function(a,b){let c=b,d=c.children.length,e=a.childCount,f=new Map,g=[];d:for(;e>0;){let h;for(;;)if(d){let a=c.children[d-1];if(a instanceof gv)c=a,d=a.children.length;else{h=a,d--;break}}else if(c==b)break d;else d=c.parent.children.indexOf(c),c=c.parent;let i=h.node;if(i){if(i!=a.child(e-1))break;--e,f.set(h,e),g.push(h)}}return{index:e,matched:f,matches:g.reverse()}}(a.node.content,a)}destroyBetween(a,b){if(a!=b){for(let c=a;c<b;c++)this.top.children[c].destroy();this.top.children.splice(a,b-a),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(a,b,c,d){let e=0,f=this.stack.length>>1,g=Math.min(f,a.length);for(;e<g&&(e==f-1?this.top:this.stack[e+1<<1]).matchesMark(a[e])&&!1!==a[e].type.spec.spanning;)e++;for(;e<f;)this.destroyRest(),this.top.dirty=0,this.index=this.stack.pop(),this.top=this.stack.pop(),f--;for(;f<a.length;){this.stack.push(this.top,this.index+1);let e=-1,g=this.top.children.length;d<this.preMatch.index&&(g=Math.min(this.index+3,g));for(let b=this.index;b<g;b++){let c=this.top.children[b];if(c.matchesMark(a[f])&&!this.isLocked(c.dom)){e=b;break}}if(e>-1)e>this.index&&(this.changed=!0,this.destroyBetween(this.index,e)),this.top=this.top.children[this.index];else{let d=gv.create(this.top,a[f],b,c);this.top.children.splice(this.index,0,d),this.top=d,this.changed=!0}this.index=0,f++}}findNodeMatch(a,b,c,d){let e=-1,f;if(d>=this.preMatch.index&&(f=this.preMatch.matches[d-this.preMatch.index]).parent==this.top&&f.matchesNode(a,b,c))e=this.top.children.indexOf(f,this.index);else for(let d=this.index,f=Math.min(this.top.children.length,d+5);d<f;d++){let f=this.top.children[d];if(f.matchesNode(a,b,c)&&!this.preMatch.matched.has(f)){e=d;break}}return!(e<0)&&(this.destroyBetween(this.index,e),this.index++,!0)}updateNodeAt(a,b,c,d,e){let f=this.top.children[d];return 3==f.dirty&&f.dom==f.contentDOM&&(f.dirty=2),!!f.update(a,b,c,e)&&(this.destroyBetween(this.index,d),this.index++,!0)}findIndexWithChild(a){for(;;){let b=a.parentNode;if(!b)return -1;if(b==this.top.contentDOM){let b=a.pmViewDesc;if(b){for(let a=this.index;a<this.top.children.length;a++)if(this.top.children[a]==b)return a}return -1}a=b}}updateNextNode(a,b,c,d,e,f){for(let g=this.index;g<this.top.children.length;g++){let h=this.top.children[g];if(h instanceof gw){let i=this.preMatch.matched.get(h);if(null!=i&&i!=e)return!1;let j=h.dom,k,l=this.isLocked(j)&&!(a.isText&&h.node&&h.node.isText&&h.nodeDOM.nodeValue==a.text&&3!=h.dirty&&gG(b,h.outerDeco));if(!l&&h.update(a,b,c,d))return this.destroyBetween(this.index,g),h.dom!=j&&(this.changed=!0),this.index++,!0;if(!l&&(k=this.recreateWrapper(h,a,b,c,d,f)))return this.destroyBetween(this.index,g),this.top.children[this.index]=k,k.contentDOM&&(k.dirty=2,k.updateChildren(d,f+1),k.dirty=0),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(a,b,c,d,e,f){if(a.dirty||b.isAtom||!a.children.length||!a.node.content.eq(b.content)||!gG(c,a.outerDeco)||!d.eq(a.innerDeco))return null;let g=gw.create(this.top,b,c,d,e,f);if(g.contentDOM)for(let b of(g.children=a.children,a.children=[],g.children))b.parent=g;return a.destroy(),g}addNode(a,b,c,d,e){let f=gw.create(this.top,a,b,c,d,e);f.contentDOM&&f.updateChildren(d,e+1),this.top.children.splice(this.index++,0,f),this.changed=!0}placeWidget(a,b,c){let d=this.index<this.top.children.length?this.top.children[this.index]:null;if(d&&d.matchesWidget(a)&&(a==d.widget||!d.widget.type.toDOM.parentNode))this.index++;else{let d=new gt(this.top,a,b,c);this.top.children.splice(this.index++,0,d),this.changed=!0}}addTextblockHacks(){let a=this.top.children[this.index-1],b=this.top;for(;a instanceof gv;)a=(b=a).children[b.children.length-1];(!a||!(a instanceof gy)||/\n$/.test(a.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(a.node.text))&&((f4||f2)&&a&&"false"==a.dom.contentEditable&&this.addHackNode("IMG",b),this.addHackNode("BR",this.top))}addHackNode(a,b){if(b==this.top&&this.index<b.children.length&&b.children[this.index].matchesHack(a))this.index++;else{let c=document.createElement(a);"IMG"==a&&(c.className="ProseMirror-separator",c.alt=""),"BR"==a&&(c.className="ProseMirror-trailingBreak");let d=new gz(this.top,[],c,null);b!=this.top?b.children.push(d):b.children.splice(this.index++,0,d),this.changed=!0}}isLocked(a){return this.lock&&(a==this.lock||1==a.nodeType&&a.contains(this.lock.parentNode))}}function gJ(a,b){return a.type.side-b.type.side}function gK(a,b,c,d,e){let f=[];for(let g=0,h=0;g<a.length;g++){let i=a[g],j=h,k=h+=i.size;j>=c||k<=b?f.push(i):(j<b&&f.push(i.slice(0,b-j,d)),e&&(f.push(e),e=void 0),k>c&&f.push(i.slice(c-j,i.size,d)))}return f}function gL(a,b=null){let c=a.domSelectionRange(),d=a.state.doc;if(!c.focusNode)return null;let e=a.docView.nearestDesc(c.focusNode),f=e&&0==e.size,g=a.docView.posFromDOM(c.focusNode,c.focusOffset,1);if(g<0)return null;let h=d.resolve(g),i,j;if(fS(c)){for(i=g;e&&!e.node;)e=e.parent;let a=e.node;if(e&&a.isAtom&&fs.isSelectable(a)&&e.parent&&!(a.isInline&&function(a,b,c){for(let d=0==b,e=b==fQ(a);d||e;){if(a==c)return!0;let b=fI(a);if(!(a=a.parentNode))return!1;d=d&&0==b,e=e&&b==fQ(a)}}(c.focusNode,c.focusOffset,e.dom))){let a=e.posBefore;j=new fs(g==a?h:d.resolve(a))}}else{if(c instanceof a.dom.ownerDocument.defaultView.Selection&&c.rangeCount>1){let b=g,e=g;for(let d=0;d<c.rangeCount;d++){let f=c.getRangeAt(d);b=Math.min(b,a.docView.posFromDOM(f.startContainer,f.startOffset,1)),e=Math.max(e,a.docView.posFromDOM(f.endContainer,f.endOffset,-1))}if(b<0)return null;[i,g]=e==a.state.selection.anchor?[e,b]:[b,e],h=d.resolve(g)}else i=a.docView.posFromDOM(c.anchorNode,c.anchorOffset,1);if(i<0)return null}let k=d.resolve(i);if(!j){let c="pointer"==b||a.state.selection.head<h.pos&&!f?1:-1;j=gU(a,k,h,c)}return j}function gM(a){return a.editable?a.hasFocus():gW(a)&&document.activeElement&&document.activeElement.contains(a.dom)}function gN(a,b=!1){let c=a.state.selection;if(gS(a,c),gM(a)){if(!b&&a.input.mouseDown&&a.input.mouseDown.allowDefault&&f2){let b=a.domSelectionRange(),c=a.domObserver.currentSelection;if(b.anchorNode&&c.anchorNode&&fN(b.anchorNode,b.anchorOffset,c.anchorNode,c.anchorOffset)){a.input.mouseDown.delayedSelectionSync=!0,a.domObserver.setCurSelection();return}}if(a.domObserver.disconnectSelection(),a.cursorWrapper)!function(a){let b=a.domSelection();if(!b)return;let c=a.cursorWrapper.dom,d="IMG"==c.nodeName;d?b.collapse(c.parentNode,fI(c)+1):b.collapse(c,0),!d&&!a.state.selection.visible&&f$&&f_<=11&&(c.disabled=!0,c.disabled=!1)}(a);else{var d;let e,f,g,h,{anchor:i,head:j}=c,k,l;gO&&!(c instanceof fq)&&(c.$from.parent.inlineContent||(k=gP(a,c.from)),c.empty||c.$from.parent.inlineContent||(l=gP(a,c.to))),a.docView.setSelection(i,j,a,b),gO&&(k&&gR(k),l&&gR(l)),c.visible?a.dom.classList.remove("ProseMirror-hideselection"):(a.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&((e=(d=a).dom.ownerDocument).removeEventListener("selectionchange",d.input.hideSelectionGuard),g=(f=d.domSelectionRange()).anchorNode,h=f.anchorOffset,e.addEventListener("selectionchange",d.input.hideSelectionGuard=()=>{(f.anchorNode!=g||f.anchorOffset!=h)&&(e.removeEventListener("selectionchange",d.input.hideSelectionGuard),setTimeout(()=>{(!gM(d)||d.state.selection.visible)&&d.dom.classList.remove("ProseMirror-hideselection")},20))})))}a.domObserver.setCurSelection(),a.domObserver.connectSelection()}}let gO=f4||f2&&f3<63;function gP(a,b){let{node:c,offset:d}=a.docView.domFromPos(b,0),e=d<c.childNodes.length?c.childNodes[d]:null,f=d?c.childNodes[d-1]:null;if(f4&&e&&"false"==e.contentEditable)return gQ(e);if((!e||"false"==e.contentEditable)&&(!f||"false"==f.contentEditable)){if(e)return gQ(e);else if(f)return gQ(f)}}function gQ(a){return a.contentEditable="true",f4&&a.draggable&&(a.draggable=!1,a.wasDraggable=!0),a}function gR(a){a.contentEditable="false",a.wasDraggable&&(a.draggable=!0,a.wasDraggable=null)}function gS(a,b){if(b instanceof fs){let c=a.docView.descAt(b.from);c!=a.lastSelectedViewDesc&&(gT(a),c&&c.selectNode(),a.lastSelectedViewDesc=c)}else gT(a)}function gT(a){a.lastSelectedViewDesc&&(a.lastSelectedViewDesc.parent&&a.lastSelectedViewDesc.deselectNode(),a.lastSelectedViewDesc=void 0)}function gU(a,b,c,d){return a.someProp("createSelectionBetween",d=>d(a,b,c))||fq.between(b,c,d)}function gV(a){return(!a.editable||!!a.hasFocus())&&gW(a)}function gW(a){let b=a.domSelectionRange();if(!b.anchorNode)return!1;try{return a.dom.contains(3==b.anchorNode.nodeType?b.anchorNode.parentNode:b.anchorNode)&&(a.editable||a.dom.contains(3==b.focusNode.nodeType?b.focusNode.parentNode:b.focusNode))}catch(a){return!1}}function gX(a,b){let{$anchor:c,$head:d}=a.selection,e=b>0?c.max(d):c.min(d),f=e.parent.inlineContent?e.depth?a.doc.resolve(b>0?e.after():e.before()):null:e;return f&&fm.findFrom(f,b)}function gY(a,b){return a.dispatch(a.state.tr.setSelection(b).scrollIntoView()),!0}function gZ(a,b,c){let d=a.state.selection;if(d instanceof fq){if(c.indexOf("s")>-1){let{$head:c}=d,e=c.textOffset?null:b<0?c.nodeBefore:c.nodeAfter;if(!e||e.isText||!e.isLeaf)return!1;let f=a.state.doc.resolve(c.pos+e.nodeSize*(b<0?-1:1));return gY(a,new fq(d.$anchor,f))}else if(!d.empty)return!1;else if(a.endOfTextblock(b>0?"forward":"backward")){let c=gX(a.state,b);return!!c&&c instanceof fs&&gY(a,c)}else if(!(f6&&c.indexOf("m")>-1)){let c=d.$head,e=c.textOffset?null:b<0?c.nodeBefore:c.nodeAfter,f;if(!e||e.isText)return!1;let g=b<0?c.pos-e.nodeSize:c.pos;return!!(e.isAtom||(f=a.docView.descAt(g))&&!f.contentDOM)&&(fs.isSelectable(e)?gY(a,new fs(b<0?a.state.doc.resolve(c.pos-e.nodeSize):c)):!!f9&&gY(a,new fq(a.state.doc.resolve(b<0?g:g+e.nodeSize))))}}else{if(d instanceof fs&&d.node.isInline)return gY(a,new fq(b>0?d.$to:d.$from));let c=gX(a.state,b);return!!c&&gY(a,c)}}function g$(a){return 3==a.nodeType?a.nodeValue.length:a.childNodes.length}function g_(a,b){let c=a.pmViewDesc;return c&&0==c.size&&(b<0||a.nextSibling||"BR"!=a.nodeName)}function g0(a,b){return b<0?function(a){let b=a.domSelectionRange(),c=b.focusNode,d=b.focusOffset;if(!c)return;let e,f,g=!1;for(f0&&1==c.nodeType&&d<g$(c)&&g_(c.childNodes[d],-1)&&(g=!0);;)if(d>0)if(1!=c.nodeType)break;else{let a=c.childNodes[d-1];if(g_(a,-1))e=c,f=--d;else if(3==a.nodeType)d=(c=a).nodeValue.length;else break}else if(g1(c))break;else{let b=c.previousSibling;for(;b&&g_(b,-1);)e=c.parentNode,f=fI(b),b=b.previousSibling;if(b)d=g$(c=b);else{if((c=c.parentNode)==a.dom)break;d=0}}g?g2(a,c,d):e&&g2(a,e,f)}(a):function(a){let b,c,d=a.domSelectionRange(),e=d.focusNode,f=d.focusOffset;if(!e)return;let g=g$(e);for(;;)if(f<g){if(1!=e.nodeType)break;if(g_(e.childNodes[f],1))b=e,c=++f;else break}else if(g1(e))break;else{let d=e.nextSibling;for(;d&&g_(d,1);)b=d.parentNode,c=fI(d)+1,d=d.nextSibling;if(d)f=0,g=g$(e=d);else{if((e=e.parentNode)==a.dom)break;f=g=0}}b&&g2(a,b,c)}(a)}function g1(a){let b=a.pmViewDesc;return b&&b.node&&b.node.isBlock}function g2(a,b,c){if(3!=b.nodeType){let a,d;(d=function(a,b){for(;a&&b==a.childNodes.length&&!fR(a);)b=fI(a)+1,a=a.parentNode;for(;a&&b<a.childNodes.length;){let c=a.childNodes[b];if(3==c.nodeType)return c;if(1==c.nodeType&&"false"==c.contentEditable)break;a=c,b=0}}(b,c))?(b=d,c=0):(a=function(a,b){for(;a&&!b&&!fR(a);)b=fI(a),a=a.parentNode;for(;a&&b;){let c=a.childNodes[b-1];if(3==c.nodeType)return c;if(1==c.nodeType&&"false"==c.contentEditable)break;b=(a=c).childNodes.length}}(b,c))&&(b=a,c=a.nodeValue.length)}let d=a.domSelection();if(!d)return;if(fS(d)){let a=document.createRange();a.setEnd(b,c),a.setStart(b,c),d.removeAllRanges(),d.addRange(a)}else d.extend&&d.extend(b,c);a.domObserver.setCurSelection();let{state:e}=a;setTimeout(()=>{a.state==e&&gN(a)},50)}function g3(a,b){let c=a.state.doc.resolve(b);if(!(f2||f7)&&c.parent.inlineContent){let d=a.coordsAtPos(b);if(b>c.start()){let c=a.coordsAtPos(b-1),e=(c.top+c.bottom)/2;if(e>d.top&&e<d.bottom&&Math.abs(c.left-d.left)>1)return c.left<d.left?"ltr":"rtl"}if(b<c.end()){let c=a.coordsAtPos(b+1),e=(c.top+c.bottom)/2;if(e>d.top&&e<d.bottom&&Math.abs(c.left-d.left)>1)return c.left>d.left?"ltr":"rtl"}}return"rtl"==getComputedStyle(a.dom).direction?"rtl":"ltr"}function g4(a,b,c){let d=a.state.selection;if(d instanceof fq&&!d.empty||c.indexOf("s")>-1||f6&&c.indexOf("m")>-1)return!1;let{$from:e,$to:f}=d;if(!e.parent.inlineContent||a.endOfTextblock(b<0?"up":"down")){let c=gX(a.state,b);if(c&&c instanceof fs)return gY(a,c)}if(!e.parent.inlineContent){let c=b<0?e:f,g=d instanceof fu?fm.near(c,b):fm.findFrom(c,b);return!!g&&gY(a,g)}return!1}function g5(a,b){if(!(a.state.selection instanceof fq))return!0;let{$head:c,$anchor:d,empty:e}=a.state.selection;if(!c.sameParent(d))return!0;if(!e)return!1;if(a.endOfTextblock(b>0?"forward":"backward"))return!0;let f=!c.textOffset&&(b<0?c.nodeBefore:c.nodeAfter);if(f&&!f.isText){let d=a.state.tr;return b<0?d.delete(c.pos-f.nodeSize,c.pos):d.delete(c.pos,c.pos+f.nodeSize),a.dispatch(d),!0}return!1}function g6(a,b,c){a.domObserver.stop(),b.contentEditable=c,a.domObserver.start()}function g7(a,b){a.someProp("transformCopied",c=>{b=c(b,a)});let c=[],{content:d,openStart:e,openEnd:f}=b;for(;e>1&&f>1&&1==d.childCount&&1==d.firstChild.childCount;){e--,f--;let a=d.firstChild;c.push(a.type.name,a.attrs!=a.type.defaultAttrs?a.attrs:null),d=a.content}let g=a.someProp("clipboardSerializer")||eH.fromSchema(a.state.schema),h=hf(),i=h.createElement("div");i.appendChild(g.serializeFragment(d,{document:h}));let j=i.firstChild,k,l=0;for(;j&&1==j.nodeType&&(k=hd[j.nodeName.toLowerCase()]);){for(let a=k.length-1;a>=0;a--){let b=h.createElement(k[a]);for(;i.firstChild;)b.appendChild(i.firstChild);i.appendChild(b),l++}j=i.firstChild}return j&&1==j.nodeType&&j.setAttribute("data-pm-slice",`${e} ${f}${l?` -${l}`:""} ${JSON.stringify(c)}`),{dom:i,text:a.someProp("clipboardTextSerializer",c=>c(b,a))||b.content.textBetween(0,b.content.size,"\n\n"),slice:b}}function g8(a,b,c,d,e){let f,g,h=e.parent.type.spec.code;if(!c&&!b)return null;let i=!!b&&(d||h||!c);if(i){if(a.someProp("transformPastedText",c=>{b=c(b,h||d,a)}),h)return g=new d4(d$.from(a.state.schema.text(b.replace(/\r\n?/g,"\n"))),0,0),a.someProp("transformPasted",b=>{g=b(g,a,!0)}),g;let c=a.someProp("clipboardTextParser",c=>c(b,e,d,a));if(c)g=c;else{let c=e.marks(),{schema:d}=a.state,g=eH.fromSchema(d);f=document.createElement("div"),b.split(/(?:\r\n?|\n)+/).forEach(a=>{let b=f.appendChild(document.createElement("p"));a&&b.appendChild(g.serializeNode(d.text(a,c)))})}}else a.someProp("transformPastedHTML",b=>{c=b(c,a)}),f=function(a){var b;let c,d=/^(\s*<meta [^>]*>)*/.exec(a);d&&(a=a.slice(d[0].length));let e=hf().createElement("div"),f=/<([a-z][^>\s]+)/i.exec(a),g;if((g=f&&hd[f[1].toLowerCase()])&&(a=g.map(a=>"<"+a+">").join("")+a+g.map(a=>"</"+a+">").reverse().join("")),e.innerHTML=(b=a,(c=window.trustedTypes)?(hg||(hg=c.defaultPolicy||c.createPolicy("ProseMirrorClipboard",{createHTML:a=>a})),hg.createHTML(b)):b),g)for(let a=0;a<g.length;a++)e=e.querySelector(g[a])||e;return e}(c),f9&&function(a){let b=a.querySelectorAll(f2?"span:not([class]):not([style])":"span.Apple-converted-space");for(let c=0;c<b.length;c++){let d=b[c];1==d.childNodes.length&&" "==d.textContent&&d.parentNode&&d.parentNode.replaceChild(a.ownerDocument.createTextNode(" "),d)}}(f);let j=f&&f.querySelector("[data-pm-slice]"),k=j&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(j.getAttribute("data-pm-slice")||"");if(k&&k[3])for(let a=+k[3];a>0;a--){let a=f.firstChild;for(;a&&1!=a.nodeType;)a=a.nextSibling;if(!a)break;f=a}if(g||(g=(a.someProp("clipboardParser")||a.someProp("domParser")||ey.fromSchema(a.state.schema)).parseSlice(f,{preserveWhitespace:!!(i||k),context:e,ruleFromNode:a=>"BR"!=a.nodeName||a.nextSibling||!a.parentNode||g9.test(a.parentNode.nodeName)?null:{ignore:!0}})),k)g=function(a,b){if(!a.size)return a;let c=a.content.firstChild.type.schema,d;try{d=JSON.parse(b)}catch(b){return a}let{content:e,openStart:f,openEnd:g}=a;for(let a=d.length-2;a>=0;a-=2){let b=c.nodes[d[a]];if(!b||b.hasRequiredAttrs())break;e=d$.from(b.create(d[a+1],e)),f++,g++}return new d4(e,f,g)}(hc(g,+k[1],+k[2]),k[4]);else if((g=d4.maxOpen(function(a,b){if(a.childCount<2)return a;for(let c=b.depth;c>=0;c--){let d=b.node(c).contentMatchAt(b.index(c)),e,f=[];if(a.forEach(a=>{if(!f)return;let b=d.findWrapping(a.type),c;if(!b)return f=null;if(c=f.length&&e.length&&function a(b,c,d,e,f){if(f<b.length&&f<c.length&&b[f]==c[f]){let g=a(b,c,d,e.lastChild,f+1);if(g)return e.copy(e.content.replaceChild(e.childCount-1,g));if(e.contentMatchAt(e.childCount).matchType(f==b.length-1?d.type:b[f+1]))return e.copy(e.content.append(d$.from(ha(d,b,f+1))))}}(b,e,a,f[f.length-1],0))f[f.length-1]=c;else{f.length&&(f[f.length-1]=function a(b,c){if(0==c)return b;let d=b.content.replaceChild(b.childCount-1,a(b.lastChild,c-1)),e=b.contentMatchAt(b.childCount).fillBefore(d$.empty,!0);return b.copy(d.append(e))}(f[f.length-1],e.length));let c=ha(a,b);f.push(c),d=d.matchType(c.type),e=b}}),f)return d$.from(f)}return a}(g.content,e),!0)).openStart||g.openEnd){let a=0,b=0;for(let b=g.content.firstChild;a<g.openStart&&!b.type.spec.isolating;a++,b=b.firstChild);for(let a=g.content.lastChild;b<g.openEnd&&!a.type.spec.isolating;b++,a=a.lastChild);g=hc(g,a,b)}return a.someProp("transformPasted",b=>{g=b(g,a,i)}),g}let g9=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function ha(a,b,c=0){for(let d=b.length-1;d>=c;d--)a=b[d].create(null,d$.from(a));return a}function hb(a,b,c,d,e,f){let g=b<0?a.firstChild:a.lastChild,h=g.content;return a.childCount>1&&(f=0),e<d-1&&(h=hb(h,b,c,d,e+1,f)),e>=c&&(h=b<0?g.contentMatchAt(0).fillBefore(h,f<=e).append(h):h.append(g.contentMatchAt(g.childCount).fillBefore(d$.empty,!0))),a.replaceChild(b<0?0:a.childCount-1,g.copy(h))}function hc(a,b,c){return b<a.openStart&&(a=new d4(hb(a.content,-1,b,a.openStart,0,a.openEnd),b,a.openEnd)),c<a.openEnd&&(a=new d4(hb(a.content,1,c,a.openEnd,0,0),a.openStart,c)),a}let hd={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]},he=null;function hf(){return he||(he=document.implementation.createHTMLDocument("title"))}let hg=null,hh={},hi={},hj={touchstart:!0,touchmove:!0};class hk{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function hl(a,b){a.input.lastSelectionOrigin=b,a.input.lastSelectionTime=Date.now()}function hm(a){a.someProp("handleDOMEvents",b=>{for(let c in b)a.input.eventHandlers[c]||a.dom.addEventListener(c,a.input.eventHandlers[c]=b=>hn(a,b))})}function hn(a,b){return a.someProp("handleDOMEvents",c=>{let d=c[b.type];return!!d&&(d(a,b)||b.defaultPrevented)})}function ho(a){return{left:a.clientX,top:a.clientY}}function hp(a,b,c,d,e){if(-1==d)return!1;let f=a.state.doc.resolve(d);for(let d=f.depth+1;d>0;d--)if(a.someProp(b,b=>d>f.depth?b(a,c,f.nodeAfter,f.before(d),e,!0):b(a,c,f.node(d),f.before(d),e,!1)))return!0;return!1}function hq(a,b,c){if(a.focused||a.focus(),a.state.selection.eq(b))return;let d=a.state.tr.setSelection(b);"pointer"==c&&d.setMeta("pointer",!0),a.dispatch(d)}hi.keydown=(a,b)=>{if((a.input.shiftKey=16==b.keyCode||b.shiftKey,!ht(a,b))&&(a.input.lastKeyCode=b.keyCode,a.input.lastKeyCodeTime=Date.now(),!f8||!f2||13!=b.keyCode))if(229!=b.keyCode&&a.domObserver.forceFlush(),!f5||13!=b.keyCode||b.ctrlKey||b.altKey||b.metaKey)a.someProp("handleKeyDown",c=>c(a,b))||function(a,b){let c,d=b.keyCode,e=(c="",b.ctrlKey&&(c+="c"),b.metaKey&&(c+="m"),b.altKey&&(c+="a"),b.shiftKey&&(c+="s"),c);if(8==d||f6&&72==d&&"c"==e)return g5(a,-1)||g0(a,-1);if(46==d&&!b.shiftKey||f6&&68==d&&"c"==e)return g5(a,1)||g0(a,1);if(13==d||27==d)return!0;if(37==d||f6&&66==d&&"c"==e){let b=37==d?"ltr"==g3(a,a.state.selection.from)?-1:1:-1;return gZ(a,b,e)||g0(a,b)}if(39==d||f6&&70==d&&"c"==e){let b=39==d?"ltr"==g3(a,a.state.selection.from)?1:-1:1;return gZ(a,b,e)||g0(a,b)}else if(38==d||f6&&80==d&&"c"==e)return g4(a,-1,e)||g0(a,-1);else if(40==d||f6&&78==d&&"c"==e)return function(a){if(!f4||a.state.selection.$head.parentOffset>0)return!1;let{focusNode:b,focusOffset:c}=a.domSelectionRange();if(b&&1==b.nodeType&&0==c&&b.firstChild&&"false"==b.firstChild.contentEditable){let c=b.firstChild;g6(a,c,"true"),setTimeout(()=>g6(a,c,"false"),20)}return!1}(a)||g4(a,1,e)||g0(a,1);else if(e==(f6?"m":"c")&&(66==d||73==d||89==d||90==d))return!0;return!1}(a,b)?b.preventDefault():hl(a,"key");else{let b=Date.now();a.input.lastIOSEnter=b,a.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{a.input.lastIOSEnter==b&&(a.someProp("handleKeyDown",b=>b(a,fT(13,"Enter"))),a.input.lastIOSEnter=0)},200)}},hi.keyup=(a,b)=>{16==b.keyCode&&(a.input.shiftKey=!1)},hi.keypress=(a,b)=>{if(ht(a,b)||!b.charCode||b.ctrlKey&&!b.altKey||f6&&b.metaKey)return;if(a.someProp("handleKeyPress",c=>c(a,b)))return void b.preventDefault();let c=a.state.selection;if(!(c instanceof fq)||!c.$from.sameParent(c.$to)){let d=String.fromCharCode(b.charCode),e=()=>a.state.tr.insertText(d).scrollIntoView();/[\r\n]/.test(d)||a.someProp("handleTextInput",b=>b(a,c.$from.pos,c.$to.pos,d,e))||a.dispatch(e()),b.preventDefault()}};let hr=f6?"metaKey":"ctrlKey";hh.mousedown=(a,b)=>{var c;let d,e;a.input.shiftKey=b.shiftKey;let f=hx(a),g=Date.now(),h="singleClick";g-a.input.lastClick.time<500&&(d=(c=a.input.lastClick).x-b.clientX)*d+(e=c.y-b.clientY)*e<100&&!b[hr]&&a.input.lastClick.button==b.button&&("singleClick"==a.input.lastClick.type?h="doubleClick":"doubleClick"==a.input.lastClick.type&&(h="tripleClick")),a.input.lastClick={time:g,x:b.clientX,y:b.clientY,type:h,button:b.button};let i=a.posAtCoords(ho(b));i&&("singleClick"==h?(a.input.mouseDown&&a.input.mouseDown.done(),a.input.mouseDown=new hs(a,i,b,!!f)):("doubleClick"==h?function(a,b,c,d){return hp(a,"handleDoubleClickOn",b,c,d)||a.someProp("handleDoubleClick",c=>c(a,b,d))}:function(a,b,c,d){return hp(a,"handleTripleClickOn",b,c,d)||a.someProp("handleTripleClick",c=>c(a,b,d))||function(a,b,c){if(0!=c.button)return!1;let d=a.state.doc;if(-1==b)return!!d.inlineContent&&(hq(a,fq.create(d,0,d.content.size),"pointer"),!0);let e=d.resolve(b);for(let b=e.depth+1;b>0;b--){let c=b>e.depth?e.nodeAfter:e.node(b),f=e.before(b);if(c.inlineContent)hq(a,fq.create(d,f+1,f+1+c.content.size),"pointer");else{if(!fs.isSelectable(c))continue;hq(a,fs.create(d,f),"pointer")}return!0}}(a,c,d)})(a,i.pos,i.inside,b)?b.preventDefault():hl(a,"pointer"))};class hs{constructor(a,b,c,d){let e,f;if(this.view=a,this.pos=b,this.event=c,this.flushed=d,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=a.state.doc,this.selectNode=!!c[hr],this.allowDefault=c.shiftKey,b.inside>-1)e=a.state.doc.nodeAt(b.inside),f=b.inside;else{let c=a.state.doc.resolve(b.pos);e=c.parent,f=c.depth?c.before():0}const g=d?null:c.target,h=g?a.docView.nearestDesc(g,!0):null;this.target=h&&1==h.nodeDOM.nodeType?h.nodeDOM:null;let{selection:i}=a.state;0==c.button&&(e.type.spec.draggable&&!1!==e.type.spec.selectable||i instanceof fs&&i.from<=f&&i.to>f)&&(this.mightDrag={node:e,pos:f,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&f0&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),a.root.addEventListener("mouseup",this.up=this.up.bind(this)),a.root.addEventListener("mousemove",this.move=this.move.bind(this)),hl(a,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>gN(this.view)),this.view.input.mouseDown=null}up(a){if(this.done(),!this.view.dom.contains(a.target))return;let b=this.pos;if(this.view.state.doc!=this.startDoc&&(b=this.view.posAtCoords(ho(a))),this.updateAllowDefault(a),this.allowDefault||!b)hl(this.view,"pointer");else{var c,d,e,f;(c=this.view,d=b.pos,e=b.inside,f=this.selectNode,hp(c,"handleClickOn",d,e,a)||c.someProp("handleClick",b=>b(c,d,a))||(f?function(a,b){if(-1==b)return!1;let c=a.state.selection,d,e;c instanceof fs&&(d=c.node);let f=a.state.doc.resolve(b);for(let a=f.depth+1;a>0;a--){let b=a>f.depth?f.nodeAfter:f.node(a);if(fs.isSelectable(b)){e=d&&c.$from.depth>0&&a>=c.$from.depth&&f.before(c.$from.depth+1)==c.$from.pos?f.before(c.$from.depth):f.before(a);break}}return null!=e&&(hq(a,fs.create(a.state.doc,e),"pointer"),!0)}(c,e):function(a,b){if(-1==b)return!1;let c=a.state.doc.resolve(b),d=c.nodeAfter;return!!(d&&d.isAtom&&fs.isSelectable(d))&&(hq(a,new fs(c),"pointer"),!0)}(c,e)))?a.preventDefault():0==a.button&&(this.flushed||f4&&this.mightDrag&&!this.mightDrag.node.isAtom||f2&&!this.view.state.selection.visible&&2>=Math.min(Math.abs(b.pos-this.view.state.selection.from),Math.abs(b.pos-this.view.state.selection.to)))?(hq(this.view,fm.near(this.view.state.doc.resolve(b.pos)),"pointer"),a.preventDefault()):hl(this.view,"pointer")}}move(a){this.updateAllowDefault(a),hl(this.view,"pointer"),0==a.buttons&&this.done()}updateAllowDefault(a){!this.allowDefault&&(Math.abs(this.event.x-a.clientX)>4||Math.abs(this.event.y-a.clientY)>4)&&(this.allowDefault=!0)}}function ht(a,b){return!!a.composing||!!(f4&&500>Math.abs(b.timeStamp-a.input.compositionEndedAt))&&(a.input.compositionEndedAt=-2e8,!0)}hh.touchstart=a=>{a.input.lastTouch=Date.now(),hx(a),hl(a,"pointer")},hh.touchmove=a=>{a.input.lastTouch=Date.now(),hl(a,"pointer")},hh.contextmenu=a=>hx(a);let hu=f8?5e3:-1;function hv(a,b){clearTimeout(a.input.composingTimeout),b>-1&&(a.input.composingTimeout=setTimeout(()=>hx(a),b))}function hw(a){let b;for(a.composing&&(a.input.composing=!1,a.input.compositionEndedAt=((b=document.createEvent("Event")).initEvent("event",!0,!0),b.timeStamp));a.input.compositionNodes.length>0;)a.input.compositionNodes.pop().markParentsDirty()}function hx(a,b=!1){if(!f8||!(a.domObserver.flushingSoon>=0)){if(a.domObserver.forceFlush(),hw(a),b||a.docView&&a.docView.dirty){let c=gL(a),d=a.state.selection;return c&&!c.eq(d)?a.dispatch(a.state.tr.setSelection(c)):(a.markCursor||b)&&!d.$from.node(d.$from.sharedDepth(d.to)).inlineContent?a.dispatch(a.state.tr.deleteSelection()):a.updateState(a.state),!0}return!1}}hi.compositionstart=hi.compositionupdate=a=>{if(!a.composing){a.domObserver.flush();let{state:b}=a,c=b.selection.$to;if(b.selection instanceof fq&&(b.storedMarks||!c.textOffset&&c.parentOffset&&c.nodeBefore.marks.some(a=>!1===a.type.spec.inclusive)||f2&&f7&&function(a){let{focusNode:b,focusOffset:c}=a.domSelectionRange();if(!b||1!=b.nodeType||c>=b.childNodes.length)return!1;let d=b.childNodes[c];return 1==d.nodeType&&"false"==d.contentEditable}(a)))a.markCursor=a.state.storedMarks||c.marks(),hx(a,!0),a.markCursor=null;else if(hx(a,!b.selection.empty),f0&&b.selection.empty&&c.parentOffset&&!c.textOffset&&c.nodeBefore.marks.length){let b=a.domSelectionRange();for(let c=b.focusNode,d=b.focusOffset;c&&1==c.nodeType&&0!=d;){let b=d<0?c.lastChild:c.childNodes[d-1];if(!b)break;if(3==b.nodeType){let c=a.domSelection();c&&c.collapse(b,b.nodeValue.length);break}c=b,d=-1}}a.input.composing=!0}hv(a,hu)},hi.compositionend=(a,b)=>{a.composing&&(a.input.composing=!1,a.input.compositionEndedAt=b.timeStamp,a.input.compositionPendingChanges=a.domObserver.pendingRecords().length?a.input.compositionID:0,a.input.compositionNode=null,a.input.badSafariComposition?a.domObserver.forceFlush():a.input.compositionPendingChanges&&Promise.resolve().then(()=>a.domObserver.flush()),a.input.compositionID++,hv(a,20))};let hy=f$&&f_<15||f5&&ga<604;function hz(a,b,c,d,e){let f=g8(a,b,c,d,a.state.selection.$from);if(a.someProp("handlePaste",b=>b(a,e,f||d4.empty)))return!0;if(!f)return!1;let g=0==f.openStart&&0==f.openEnd&&1==f.content.childCount?f.content.firstChild:null,h=g?a.state.tr.replaceSelectionWith(g,d):a.state.tr.replaceSelection(f);return a.dispatch(h.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function hA(a){let b=a.getData("text/plain")||a.getData("Text");if(b)return b;let c=a.getData("text/uri-list");return c?c.replace(/\r?\n/g," "):""}hh.copy=hi.cut=(a,b)=>{let c=a.state.selection,d="cut"==b.type;if(c.empty)return;let e=hy?null:b.clipboardData,{dom:f,text:g}=g7(a,c.content());e?(b.preventDefault(),e.clearData(),e.setData("text/html",f.innerHTML),e.setData("text/plain",g)):function(a,b){if(!a.dom.parentNode)return;let c=a.dom.parentNode.appendChild(document.createElement("div"));c.appendChild(b),c.style.cssText="position: fixed; left: -10000px; top: 10px";let d=getSelection(),e=document.createRange();e.selectNodeContents(b),a.dom.blur(),d.removeAllRanges(),d.addRange(e),setTimeout(()=>{c.parentNode&&c.parentNode.removeChild(c),a.focus()},50)}(a,f),d&&a.dispatch(a.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))},hi.paste=(a,b)=>{if(a.composing&&!f8)return;let c=hy?null:b.clipboardData,d=a.input.shiftKey&&45!=a.input.lastKeyCode;c&&hz(a,hA(c),c.getData("text/html"),d,b)?b.preventDefault():function(a,b){if(!a.dom.parentNode)return;let c=a.input.shiftKey||a.state.selection.$from.parent.type.spec.code,d=a.dom.parentNode.appendChild(document.createElement(c?"textarea":"div"));c||(d.contentEditable="true"),d.style.cssText="position: fixed; left: -10000px; top: 10px",d.focus();let e=a.input.shiftKey&&45!=a.input.lastKeyCode;setTimeout(()=>{a.focus(),d.parentNode&&d.parentNode.removeChild(d),c?hz(a,d.value,null,e,b):hz(a,d.textContent,d.innerHTML,e,b)},50)}(a,b)};class hB{constructor(a,b,c){this.slice=a,this.move=b,this.node=c}}let hC=f6?"altKey":"ctrlKey";function hD(a,b){let c;return a.someProp("dragCopies",a=>{c=c||a(b)}),null!=c?!c:!b[hC]}for(let a in hh.dragstart=(a,b)=>{let c,d=a.input.mouseDown;if(d&&d.done(),!b.dataTransfer)return;let e=a.state.selection,f=e.empty?null:a.posAtCoords(ho(b));if(f&&f.pos>=e.from&&f.pos<=(e instanceof fs?e.to-1:e.to));else if(d&&d.mightDrag)c=fs.create(a.state.doc,d.mightDrag.pos);else if(b.target&&1==b.target.nodeType){let d=a.docView.nearestDesc(b.target,!0);d&&d.node.type.spec.draggable&&d!=a.docView&&(c=fs.create(a.state.doc,d.posBefore))}let g=(c||a.state.selection).content(),{dom:h,text:i,slice:j}=g7(a,g);b.dataTransfer.files.length&&f2&&!(f3>120)||b.dataTransfer.clearData(),b.dataTransfer.setData(hy?"Text":"text/html",h.innerHTML),b.dataTransfer.effectAllowed="copyMove",hy||b.dataTransfer.setData("text/plain",i),a.dragging=new hB(j,hD(a,b),c)},hh.dragend=a=>{let b=a.dragging;window.setTimeout(()=>{a.dragging==b&&(a.dragging=null)},50)},hi.dragover=hi.dragenter=(a,b)=>b.preventDefault(),hi.drop=(a,b)=>{try{!function(a,b,c){if(!b.dataTransfer)return;let d=a.posAtCoords(ho(b));if(!d)return;let e=a.state.doc.resolve(d.pos),f=c&&c.slice;f?a.someProp("transformPasted",b=>{f=b(f,a,!1)}):f=g8(a,hA(b.dataTransfer),hy?null:b.dataTransfer.getData("text/html"),!1,e);let g=!!(c&&hD(a,b));if(a.someProp("handleDrop",c=>c(a,b,f||d4.empty,g)))return b.preventDefault();if(!f)return;b.preventDefault();let h=f?e8(a.state.doc,e.pos,f):e.pos;null==h&&(h=e.pos);let i=a.state.tr;if(g){let{node:a}=c;a?a.replace(i):i.deleteSelection()}let j=i.mapping.map(h),k=0==f.openStart&&0==f.openEnd&&1==f.content.childCount,l=i.doc;if(k?i.replaceRangeWith(j,j,f.content.firstChild):i.replaceRange(j,j,f),i.doc.eq(l))return;let m=i.doc.resolve(j);if(k&&fs.isSelectable(f.content.firstChild)&&m.nodeAfter&&m.nodeAfter.sameMarkup(f.content.firstChild))i.setSelection(new fs(m));else{let b=i.mapping.map(h);i.mapping.maps[i.mapping.maps.length-1].forEach((a,c,d,e)=>b=e),i.setSelection(gU(a,m,i.doc.resolve(b)))}a.focus(),a.dispatch(i.setMeta("uiEvent","drop"))}(a,b,a.dragging)}finally{a.dragging=null}},hh.focus=a=>{a.input.lastFocus=Date.now(),a.focused||(a.domObserver.stop(),a.dom.classList.add("ProseMirror-focused"),a.domObserver.start(),a.focused=!0,setTimeout(()=>{a.docView&&a.hasFocus()&&!a.domObserver.currentSelection.eq(a.domSelectionRange())&&gN(a)},20))},hh.blur=(a,b)=>{a.focused&&(a.domObserver.stop(),a.dom.classList.remove("ProseMirror-focused"),a.domObserver.start(),b.relatedTarget&&a.dom.contains(b.relatedTarget)&&a.domObserver.currentSelection.clear(),a.focused=!1)},hh.beforeinput=(a,b)=>{if(f2&&f8&&"deleteContentBackward"==b.inputType){a.domObserver.flushSoon();let{domChangeCount:b}=a.input;setTimeout(()=>{if(a.input.domChangeCount!=b||(a.dom.blur(),a.focus(),a.someProp("handleKeyDown",b=>b(a,fT(8,"Backspace")))))return;let{$cursor:c}=a.state.selection;c&&c.pos>0&&a.dispatch(a.state.tr.delete(c.pos-1,c.pos).scrollIntoView())},50)}},hi)hh[a]=hi[a];function hE(a,b){if(a==b)return!0;for(let c in a)if(a[c]!==b[c])return!1;for(let c in b)if(!(c in a))return!1;return!0}class hF{constructor(a,b){this.toDOM=a,this.spec=b||hK,this.side=this.spec.side||0}map(a,b,c,d){let{pos:e,deleted:f}=a.mapResult(b.from+d,this.side<0?-1:1);return f?null:new hI(e-c,e-c,this)}valid(){return!0}eq(a){return this==a||a instanceof hF&&(this.spec.key&&this.spec.key==a.spec.key||this.toDOM==a.toDOM&&hE(this.spec,a.spec))}destroy(a){this.spec.destroy&&this.spec.destroy(a)}}class hG{constructor(a,b){this.attrs=a,this.spec=b||hK}map(a,b,c,d){let e=a.map(b.from+d,this.spec.inclusiveStart?-1:1)-c,f=a.map(b.to+d,this.spec.inclusiveEnd?1:-1)-c;return e>=f?null:new hI(e,f,this)}valid(a,b){return b.from<b.to}eq(a){return this==a||a instanceof hG&&hE(this.attrs,a.attrs)&&hE(this.spec,a.spec)}static is(a){return a.type instanceof hG}destroy(){}}class hH{constructor(a,b){this.attrs=a,this.spec=b||hK}map(a,b,c,d){let e=a.mapResult(b.from+d,1);if(e.deleted)return null;let f=a.mapResult(b.to+d,-1);return f.deleted||f.pos<=e.pos?null:new hI(e.pos-c,f.pos-c,this)}valid(a,b){let{index:c,offset:d}=a.content.findIndex(b.from),e;return d==b.from&&!(e=a.child(c)).isText&&d+e.nodeSize==b.to}eq(a){return this==a||a instanceof hH&&hE(this.attrs,a.attrs)&&hE(this.spec,a.spec)}destroy(){}}class hI{constructor(a,b,c){this.from=a,this.to=b,this.type=c}copy(a,b){return new hI(a,b,this.type)}eq(a,b=0){return this.type.eq(a.type)&&this.from+b==a.from&&this.to+b==a.to}map(a,b,c){return this.type.map(a,this,b,c)}static widget(a,b,c){return new hI(a,a,new hF(b,c))}static inline(a,b,c,d){return new hI(a,b,new hG(c,d))}static node(a,b,c,d){return new hI(a,b,new hH(c,d))}get spec(){return this.type.spec}get inline(){return this.type instanceof hG}get widget(){return this.type instanceof hF}}let hJ=[],hK={};class hL{constructor(a,b){this.local=a.length?a:hJ,this.children=b.length?b:hJ}static create(a,b){return b.length?hR(b,a,0,hK):hM}find(a,b,c){let d=[];return this.findInner(null==a?0:a,null==b?1e9:b,d,0,c),d}findInner(a,b,c,d,e){for(let f=0;f<this.local.length;f++){let g=this.local[f];g.from<=b&&g.to>=a&&(!e||e(g.spec))&&c.push(g.copy(g.from+d,g.to+d))}for(let f=0;f<this.children.length;f+=3)if(this.children[f]<b&&this.children[f+1]>a){let g=this.children[f]+1;this.children[f+2].findInner(a-g,b-g,c,d+g,e)}}map(a,b,c){return this==hM||0==a.maps.length?this:this.mapInner(a,b,0,0,c||hK)}mapInner(a,b,c,d,e){let f;for(let g=0;g<this.local.length;g++){let h=this.local[g].map(a,c,d);h&&h.type.valid(b,h)?(f||(f=[])).push(h):e.onRemove&&e.onRemove(this.local[g].spec)}return this.children.length?function(a,b,c,d,e,f,g){let h=a.slice();for(let a=0,b=f;a<c.maps.length;a++){let d=0;c.maps[a].forEach((a,c,e,f)=>{let g=f-e-(c-a);for(let e=0;e<h.length;e+=3){let f=h[e+1];if(f<0||a>f+b-d)continue;let i=h[e]+b-d;c>=i?h[e+1]=a<=i?-2:-1:a>=b&&g&&(h[e]+=g,h[e+1]+=g)}d+=g}),b=c.maps[a].map(b,-1)}let i=!1;for(let b=0;b<h.length;b+=3)if(h[b+1]<0){if(-2==h[b+1]){i=!0,h[b+1]=-1;continue}let j=c.map(a[b]+f),k=j-e;if(k<0||k>=d.content.size){i=!0;continue}let l=c.map(a[b+1]+f,-1)-e,{index:m,offset:n}=d.content.findIndex(k),o=d.maybeChild(m);if(o&&n==k&&n+o.nodeSize==l){let d=h[b+2].mapInner(c,o,j+1,a[b]+f+1,g);d!=hM?(h[b]=k,h[b+1]=l,h[b+2]=d):(h[b+1]=-2,i=!0)}else i=!0}if(i){let i=hR(function(a,b,c,d,e,f,g){for(let h=0;h<a.length;h+=3)-1==a[h+1]&&function a(b,f){for(let a=0;a<b.local.length;a++){let h=b.local[a].map(d,e,f);h?c.push(h):g.onRemove&&g.onRemove(b.local[a].spec)}for(let c=0;c<b.children.length;c+=3)a(b.children[c+2],b.children[c]+f+1)}(a[h+2],b[h]+f+1);return c}(h,a,b,c,e,f,g),d,0,g);b=i.local;for(let a=0;a<h.length;a+=3)h[a+1]<0&&(h.splice(a,3),a-=3);for(let a=0,b=0;a<i.children.length;a+=3){let c=i.children[a];for(;b<h.length&&h[b]<c;)b+=3;h.splice(b,0,i.children[a],i.children[a+1],i.children[a+2])}}return new hL(b.sort(hS),h)}(this.children,f||[],a,b,c,d,e):f?new hL(f.sort(hS),hJ):hM}add(a,b){return b.length?this==hM?hL.create(a,b):this.addInner(a,b,0):this}addInner(a,b,c){let d,e=0;a.forEach((a,f)=>{let g=f+c,h;if(h=hP(b,a,g)){for(d||(d=this.children.slice());e<d.length&&d[e]<f;)e+=3;d[e]==f?d[e+2]=d[e+2].addInner(a,h,g+1):d.splice(e,0,f,f+a.nodeSize,hR(h,a,g+1,hK)),e+=3}});let f=hO(e?hQ(b):b,-c);for(let b=0;b<f.length;b++)f[b].type.valid(a,f[b])||f.splice(b--,1);return new hL(f.length?this.local.concat(f).sort(hS):this.local,d||this.children)}remove(a){return 0==a.length||this==hM?this:this.removeInner(a,0)}removeInner(a,b){let c=this.children,d=this.local;for(let d=0;d<c.length;d+=3){let e,f=c[d]+b,g=c[d+1]+b;for(let b=0,c;b<a.length;b++)(c=a[b])&&c.from>f&&c.to<g&&(a[b]=null,(e||(e=[])).push(c));if(!e)continue;c==this.children&&(c=this.children.slice());let h=c[d+2].removeInner(e,f+1);h!=hM?c[d+2]=h:(c.splice(d,3),d-=3)}if(d.length){for(let c=0,e;c<a.length;c++)if(e=a[c])for(let a=0;a<d.length;a++)d[a].eq(e,b)&&(d==this.local&&(d=this.local.slice()),d.splice(a--,1))}return c==this.children&&d==this.local?this:d.length||c.length?new hL(d,c):hM}forChild(a,b){let c,d;if(this==hM)return this;if(b.isLeaf)return hL.empty;for(let b=0;b<this.children.length;b+=3)if(this.children[b]>=a){this.children[b]==a&&(c=this.children[b+2]);break}let e=a+1,f=e+b.content.size;for(let a=0;a<this.local.length;a++){let b=this.local[a];if(b.from<f&&b.to>e&&b.type instanceof hG){let a=Math.max(e,b.from)-e,c=Math.min(f,b.to)-e;a<c&&(d||(d=[])).push(b.copy(a,c))}}if(d){let a=new hL(d.sort(hS),hJ);return c?new hN([a,c]):a}return c||hM}eq(a){if(this==a)return!0;if(!(a instanceof hL)||this.local.length!=a.local.length||this.children.length!=a.children.length)return!1;for(let b=0;b<this.local.length;b++)if(!this.local[b].eq(a.local[b]))return!1;for(let b=0;b<this.children.length;b+=3)if(this.children[b]!=a.children[b]||this.children[b+1]!=a.children[b+1]||!this.children[b+2].eq(a.children[b+2]))return!1;return!0}locals(a){return hT(this.localsInner(a))}localsInner(a){if(this==hM)return hJ;if(a.inlineContent||!this.local.some(hG.is))return this.local;let b=[];for(let a=0;a<this.local.length;a++)this.local[a].type instanceof hG||b.push(this.local[a]);return b}forEachSet(a){a(this)}}hL.empty=new hL([],[]),hL.removeOverlap=hT;let hM=hL.empty;class hN{constructor(a){this.members=a}map(a,b){let c=this.members.map(c=>c.map(a,b,hK));return hN.from(c)}forChild(a,b){if(b.isLeaf)return hL.empty;let c=[];for(let d=0;d<this.members.length;d++){let e=this.members[d].forChild(a,b);e!=hM&&(e instanceof hN?c=c.concat(e.members):c.push(e))}return hN.from(c)}eq(a){if(!(a instanceof hN)||a.members.length!=this.members.length)return!1;for(let b=0;b<this.members.length;b++)if(!this.members[b].eq(a.members[b]))return!1;return!0}locals(a){let b,c=!0;for(let d=0;d<this.members.length;d++){let e=this.members[d].localsInner(a);if(e.length)if(b){c&&(b=b.slice(),c=!1);for(let a=0;a<e.length;a++)b.push(e[a])}else b=e}return b?hT(c?b:b.sort(hS)):hJ}static from(a){switch(a.length){case 0:return hM;case 1:return a[0];default:return new hN(a.every(a=>a instanceof hL)?a:a.reduce((a,b)=>a.concat(b instanceof hL?b:b.members),[]))}}forEachSet(a){for(let b=0;b<this.members.length;b++)this.members[b].forEachSet(a)}}function hO(a,b){if(!b||!a.length)return a;let c=[];for(let d=0;d<a.length;d++){let e=a[d];c.push(new hI(e.from+b,e.to+b,e.type))}return c}function hP(a,b,c){if(b.isLeaf)return null;let d=c+b.nodeSize,e=null;for(let b=0,f;b<a.length;b++)(f=a[b])&&f.from>c&&f.to<d&&((e||(e=[])).push(f),a[b]=null);return e}function hQ(a){let b=[];for(let c=0;c<a.length;c++)null!=a[c]&&b.push(a[c]);return b}function hR(a,b,c,d){let e=[],f=!1;b.forEach((b,g)=>{let h=hP(a,b,g+c);if(h){f=!0;let a=hR(h,b,c+g+1,d);a!=hM&&e.push(g,g+b.nodeSize,a)}});let g=hO(f?hQ(a):a,-c).sort(hS);for(let a=0;a<g.length;a++)g[a].type.valid(b,g[a])||(d.onRemove&&d.onRemove(g[a].spec),g.splice(a--,1));return g.length||e.length?new hL(g,e):hM}function hS(a,b){return a.from-b.from||a.to-b.to}function hT(a){let b=a;for(let c=0;c<b.length-1;c++){let d=b[c];if(d.from!=d.to)for(let e=c+1;e<b.length;e++){let f=b[e];if(f.from==d.from){f.to!=d.to&&(b==a&&(b=a.slice()),b[e]=f.copy(f.from,d.to),hU(b,e+1,f.copy(d.to,f.to)));continue}f.from<d.to&&(b==a&&(b=a.slice()),b[c]=d.copy(d.from,f.from),hU(b,e,d.copy(f.from,d.to)));break}}return b}function hU(a,b,c){for(;b<a.length&&hS(c,a[b])>0;)b++;a.splice(b,0,c)}function hV(a){let b=[];return a.someProp("decorations",c=>{let d=c(a.state);d&&d!=hM&&b.push(d)}),a.cursorWrapper&&b.push(hL.create(a.state.doc,[a.cursorWrapper.deco])),hN.from(b)}let hW={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},hX=f$&&f_<=11;class hY{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(a){this.anchorNode=a.anchorNode,this.anchorOffset=a.anchorOffset,this.focusNode=a.focusNode,this.focusOffset=a.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(a){return a.anchorNode==this.anchorNode&&a.anchorOffset==this.anchorOffset&&a.focusNode==this.focusNode&&a.focusOffset==this.focusOffset}}class hZ{constructor(a,b){this.view=a,this.handleDOMChange=b,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new hY,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(b=>{for(let a=0;a<b.length;a++)this.queue.push(b[a]);f$&&f_<=11&&b.some(a=>"childList"==a.type&&a.removedNodes.length||"characterData"==a.type&&a.oldValue.length>a.target.nodeValue.length)?this.flushSoon():f4&&a.composing&&b.some(a=>"childList"==a.type&&"TR"==a.target.nodeName)?(a.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),hX&&(this.onCharData=a=>{this.queue.push({target:a.target,type:"characterData",oldValue:a.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,hW)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let a=this.observer.takeRecords();if(a.length){for(let b=0;b<a.length;b++)this.queue.push(a[b]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(gV(this.view)){if(this.suppressingSelectionUpdates)return gN(this.view);if(f$&&f_<=11&&!this.view.state.selection.empty){let a=this.view.domSelectionRange();if(a.focusNode&&fN(a.focusNode,a.focusOffset,a.anchorNode,a.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(a){if(!a.focusNode)return!0;let b=new Set,c;for(let c=a.focusNode;c;c=fJ(c))b.add(c);for(let d=a.anchorNode;d;d=fJ(d))if(b.has(d)){c=d;break}let d=c&&this.view.docView.nearestDesc(c);if(d&&d.ignoreMutation({type:"selection",target:3==c.nodeType?c.parentNode:c}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let a of this.observer.takeRecords())this.queue.push(a);return this.queue}flush(){var a;let{view:b}=this;if(!b.docView||this.flushingSoon>-1)return;let c=this.pendingRecords();c.length&&(this.queue=[]);let d=b.domSelectionRange(),e=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(d)&&gV(b)&&!this.ignoreSelectionChange(d),f=-1,g=-1,h=!1,i=[];if(b.editable)for(let a=0;a<c.length;a++){let b=this.registerMutation(c[a],i);b&&(f=f<0?b.from:Math.min(b.from,f),g=g<0?b.to:Math.max(b.to,g),b.typeOver&&(h=!0))}if(i.some(a=>"BR"==a.nodeName)&&(8==b.input.lastKeyCode||46==b.input.lastKeyCode)){for(let a of i)if("BR"==a.nodeName&&a.parentNode){let b=a.nextSibling;for(;b&&1==b.nodeType;){if("false"==b.contentEditable){a.parentNode.removeChild(a);break}b=b.firstChild}}}else if(f0&&i.length){let a=i.filter(a=>"BR"==a.nodeName);if(2==a.length){let[b,c]=a;b.parentNode&&b.parentNode.parentNode==c.parentNode?c.remove():b.remove()}else{let{focusNode:c}=this.currentSelection;for(let d of a){let a=d.parentNode;a&&"LI"==a.nodeName&&(!c||function(a,b){for(let c=b.parentNode;c&&c!=a.dom;c=c.parentNode){let b=a.docView.nearestDesc(c,!0);if(b&&b.node.isBlock)return c}return null}(b,c)!=a)&&d.remove()}}}let j=null;f<0&&e&&b.input.lastFocus>Date.now()-200&&Math.max(b.input.lastTouch,b.input.lastClick.time)<Date.now()-300&&fS(d)&&(j=gL(b))&&j.eq(fm.near(b.state.doc.resolve(0),1))?(b.input.lastFocus=0,gN(b),this.currentSelection.set(d),b.scrollToSelection()):(f>-1||e)&&(f>-1&&(b.docView.markDirty(f,g),a=b,!h$.has(a)&&(h$.set(a,null),-1!==["normal","nowrap","pre-line"].indexOf(getComputedStyle(a.dom).whiteSpace))&&(a.requiresGeckoHackNode=f0,h_||(console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."),h_=!0))),b.input.badSafariComposition&&(b.input.badSafariComposition=!1,function(a,b){var c;let{focusNode:d,focusOffset:e}=a.domSelectionRange();for(let f of b)if((null==(c=f.parentNode)?void 0:c.nodeName)=="TR"){let b=f.nextSibling;for(;b&&"TD"!=b.nodeName&&"TH"!=b.nodeName;)b=b.nextSibling;if(b){let c=b;for(;;){let a=c.firstChild;if(!a||1!=a.nodeType||"false"==a.contentEditable||/^(BR|IMG)$/.test(a.nodeName))break;c=a}c.insertBefore(f,c.firstChild),d==f&&a.domSelection().collapse(f,e)}else f.parentNode.removeChild(f)}}(b,i)),this.handleDOMChange(f,g,h,i),b.docView&&b.docView.dirty?b.updateState(b.state):this.currentSelection.eq(d)||gN(b),this.currentSelection.set(d))}registerMutation(a,b){if(b.indexOf(a.target)>-1)return null;let c=this.view.docView.nearestDesc(a.target);if("attributes"==a.type&&(c==this.view.docView||"contenteditable"==a.attributeName||"style"==a.attributeName&&!a.oldValue&&!a.target.getAttribute("style"))||!c||c.ignoreMutation(a))return null;if("childList"==a.type){for(let c=0;c<a.addedNodes.length;c++){let d=a.addedNodes[c];b.push(d),3==d.nodeType&&(this.lastChangedTextNode=d)}if(c.contentDOM&&c.contentDOM!=c.dom&&!c.contentDOM.contains(a.target))return{from:c.posBefore,to:c.posAfter};let d=a.previousSibling,e=a.nextSibling;if(f$&&f_<=11&&a.addedNodes.length)for(let b=0;b<a.addedNodes.length;b++){let{previousSibling:c,nextSibling:f}=a.addedNodes[b];(!c||0>Array.prototype.indexOf.call(a.addedNodes,c))&&(d=c),(!f||0>Array.prototype.indexOf.call(a.addedNodes,f))&&(e=f)}let f=d&&d.parentNode==a.target?fI(d)+1:0,g=c.localPosFromDOM(a.target,f,-1),h=e&&e.parentNode==a.target?fI(e):a.target.childNodes.length;return{from:g,to:c.localPosFromDOM(a.target,h,1)}}return"attributes"==a.type?{from:c.posAtStart-c.border,to:c.posAtEnd+c.border}:(this.lastChangedTextNode=a.target,{from:c.posAtStart,to:c.posAtEnd,typeOver:a.target.nodeValue==a.oldValue})}}let h$=new WeakMap,h_=!1;function h0(a,b){let c=b.startContainer,d=b.startOffset,e=b.endContainer,f=b.endOffset,g=a.domAtPos(a.state.selection.anchor);return fN(g.node,g.offset,e,f)&&([c,d,e,f]=[e,f,c,d]),{anchorNode:c,anchorOffset:d,focusNode:e,focusOffset:f}}function h1(a){let b=a.pmViewDesc;if(b)return b.parseRule();if("BR"==a.nodeName&&a.parentNode){if(f4&&/^(ul|ol)$/i.test(a.parentNode.nodeName)){let a=document.createElement("div");return a.appendChild(document.createElement("li")),{skip:a}}else if(a.parentNode.lastChild==a||f4&&/^(tr|table)$/i.test(a.parentNode.nodeName))return{ignore:!0}}else if("IMG"==a.nodeName&&a.getAttribute("mark-placeholder"))return{ignore:!0};return null}let h2=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function h3(a,b,c){return Math.max(c.anchor,c.head)>b.content.size?null:gU(a,b.resolve(c.anchor),b.resolve(c.head))}function h4(a,b,c){let d=a.depth,e=b?a.end():a.pos;for(;d>0&&(b||a.indexAfter(d)==a.node(d).childCount);)d--,e++,b=!1;if(c){let b=a.node(d).maybeChild(a.indexAfter(d));for(;b&&!b.isLeaf;)b=b.firstChild,e++}return e}function h5(a){if(2!=a.length)return!1;let b=a.charCodeAt(0),c=a.charCodeAt(1);return b>=56320&&b<=57343&&c>=55296&&c<=56319}class h6{constructor(a,b){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new hk,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=b,this.state=b.state,this.directPlugins=b.plugins||[],this.directPlugins.forEach(ib),this.dispatch=this.dispatch.bind(this),this.dom=a&&a.mount||document.createElement("div"),a&&(a.appendChild?a.appendChild(this.dom):"function"==typeof a?a(this.dom):a.mount&&(this.mounted=!0)),this.editable=h9(this),h8(this),this.nodeViews=ia(this),this.docView=gx(this.state.doc,h7(this),hV(this),this.dom,this),this.domObserver=new hZ(this,(a,b,c,d)=>(function(a,b,c,d,e){let f,g,h,i=a.input.compositionPendingChanges||(a.composing?a.input.compositionID:0);if(a.input.compositionPendingChanges=0,b<0){let b=a.input.lastSelectionTime>Date.now()-50?a.input.lastSelectionOrigin:null,c=gL(a,b);if(c&&!a.state.selection.eq(c)){if(f2&&f8&&13===a.input.lastKeyCode&&Date.now()-100<a.input.lastKeyCodeTime&&a.someProp("handleKeyDown",b=>b(a,fT(13,"Enter"))))return;let d=a.state.tr.setSelection(c);"pointer"==b?d.setMeta("pointer",!0):"key"==b&&d.scrollIntoView(),i&&d.setMeta("composition",i),a.dispatch(d)}return}let j=a.state.doc.resolve(b),k=j.sharedDepth(c);b=j.before(k+1),c=a.state.doc.resolve(c).after(k+1);let l=a.state.selection,m=function(a,b,c){let d,{node:e,fromOffset:f,toOffset:g,from:h,to:i}=a.docView.parseRange(b,c),j=a.domSelectionRange(),k=j.anchorNode;if(k&&a.dom.contains(1==k.nodeType?k:k.parentNode)&&(d=[{node:k,offset:j.anchorOffset}],fS(j)||d.push({node:j.focusNode,offset:j.focusOffset})),f2&&8===a.input.lastKeyCode)for(let a=g;a>f;a--){let b=e.childNodes[a-1],c=b.pmViewDesc;if("BR"==b.nodeName&&!c){g=a;break}if(!c||c.size)break}let l=a.state.doc,m=a.someProp("domParser")||ey.fromSchema(a.state.schema),n=l.resolve(h),o=null,p=m.parse(e,{topNode:n.parent,topMatch:n.parent.contentMatchAt(n.index()),topOpen:!0,from:f,to:g,preserveWhitespace:"pre"!=n.parent.type.whitespace||"full",findPositions:d,ruleFromNode:h1,context:n});if(d&&null!=d[0].pos){let a=d[0].pos,b=d[1]&&d[1].pos;null==b&&(b=a),o={anchor:a+h,head:b+h}}return{doc:p,sel:o,from:h,to:i}}(a,b,c),n=a.state.doc,o=n.slice(m.from,m.to);8===a.input.lastKeyCode&&Date.now()-100<a.input.lastKeyCodeTime?(f=a.state.selection.to,g="end"):(f=a.state.selection.from,g="start"),a.input.lastKeyCode=null;let p=function(a,b,c,d,e){let f=a.findDiffStart(b,c);if(null==f)return null;let{a:g,b:h}=a.findDiffEnd(b,c+a.size,c+b.size);if("end"==e){let a=Math.max(0,f-Math.min(g,h));d-=g+a-f}if(g<f&&a.size<b.size){let a=d<=f&&d>=g?f-d:0;(f-=a)&&f<b.size&&h5(b.textBetween(f-1,f+1))&&(f+=a?1:-1),h=f+(h-g),g=f}else if(h<f){let b=d<=f&&d>=h?f-d:0;(f-=b)&&f<a.size&&h5(a.textBetween(f-1,f+1))&&(f+=b?1:-1),g=f+(g-h),h=f}return{start:f,endA:g,endB:h}}(o.content,m.doc.content,m.from,f,g);if(p&&a.input.domChangeCount++,(f5&&a.input.lastIOSEnter>Date.now()-225||f8)&&e.some(a=>1==a.nodeType&&!h2.test(a.nodeName))&&(!p||p.endA>=p.endB)&&a.someProp("handleKeyDown",b=>b(a,fT(13,"Enter")))){a.input.lastIOSEnter=0;return}if(!p)if(d&&l instanceof fq&&!l.empty&&l.$head.sameParent(l.$anchor)&&!a.composing&&!(m.sel&&m.sel.anchor!=m.sel.head))p={start:l.from,endA:l.to,endB:l.to};else{if(m.sel){let b=h3(a,a.state.doc,m.sel);if(b&&!b.eq(a.state.selection)){let c=a.state.tr.setSelection(b);i&&c.setMeta("composition",i),a.dispatch(c)}}return}a.state.selection.from<a.state.selection.to&&p.start==p.endB&&a.state.selection instanceof fq&&(p.start>a.state.selection.from&&p.start<=a.state.selection.from+2&&a.state.selection.from>=m.from?p.start=a.state.selection.from:p.endA<a.state.selection.to&&p.endA>=a.state.selection.to-2&&a.state.selection.to<=m.to&&(p.endB+=a.state.selection.to-p.endA,p.endA=a.state.selection.to)),f$&&f_<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>m.from&&" "==m.doc.textBetween(p.start-m.from-1,p.start-m.from+1)&&(p.start--,p.endA--,p.endB--);let q=m.doc.resolveNoCache(p.start-m.from),r=m.doc.resolveNoCache(p.endB-m.from),s=n.resolve(p.start),t=q.sameParent(r)&&q.parent.inlineContent&&s.end()>=p.endA;if((f5&&a.input.lastIOSEnter>Date.now()-225&&(!t||e.some(a=>"DIV"==a.nodeName||"P"==a.nodeName))||!t&&q.pos<m.doc.content.size&&(!q.sameParent(r)||!q.parent.inlineContent)&&q.pos<r.pos&&!/\S/.test(m.doc.textBetween(q.pos,r.pos,"","")))&&a.someProp("handleKeyDown",b=>b(a,fT(13,"Enter")))){a.input.lastIOSEnter=0;return}if(a.state.selection.anchor>p.start&&function(a,b,c,d,e){if(c-b<=e.pos-d.pos||h4(d,!0,!1)<e.pos)return!1;let f=a.resolve(b);if(!d.parent.isTextblock){let a=f.nodeAfter;return null!=a&&c==b+a.nodeSize}if(f.parentOffset<f.parent.content.size||!f.parent.isTextblock)return!1;let g=a.resolve(h4(f,!0,!0));return!(!g.parent.isTextblock||g.pos>c||h4(g,!0,!1)<c)&&d.parent.content.cut(d.parentOffset).eq(g.parent.content)}(n,p.start,p.endA,q,r)&&a.someProp("handleKeyDown",b=>b(a,fT(8,"Backspace")))){f8&&f2&&a.domObserver.suppressSelectionUpdates();return}f2&&p.endB==p.start&&(a.input.lastChromeDelete=Date.now()),f8&&!t&&q.start()!=r.start()&&0==r.parentOffset&&q.depth==r.depth&&m.sel&&m.sel.anchor==m.sel.head&&m.sel.head==p.endA&&(p.endB-=2,r=m.doc.resolveNoCache(p.endB-m.from),setTimeout(()=>{a.someProp("handleKeyDown",function(b){return b(a,fT(13,"Enter"))})},20));let u=p.start,v=p.endA,w=b=>{let c=b||a.state.tr.replace(u,v,m.doc.slice(p.start-m.from,p.endB-m.from));if(m.sel){let b=h3(a,c.doc,m.sel);b&&!(f2&&a.composing&&b.empty&&(p.start!=p.endB||a.input.lastChromeDelete<Date.now()-100)&&(b.head==u||b.head==c.mapping.map(v)-1)||f$&&b.empty&&b.head==u)&&c.setSelection(b)}return i&&c.setMeta("composition",i),c.scrollIntoView()};if(t)if(q.pos==r.pos){f$&&f_<=11&&0==q.parentOffset&&(a.domObserver.suppressSelectionUpdates(),setTimeout(()=>gN(a),20));let b=w(a.state.tr.delete(u,v)),c=n.resolve(p.start).marksAcross(n.resolve(p.endA));c&&b.ensureMarks(c),a.dispatch(b)}else if(p.endA==p.endB&&(h=function(a,b){let c=a.firstChild.marks,d=b.firstChild.marks,e=c,f=d,g,h,i;for(let a=0;a<d.length;a++)e=d[a].removeFromSet(e);for(let a=0;a<c.length;a++)f=c[a].removeFromSet(f);if(1==e.length&&0==f.length)h=e[0],g="add",i=a=>a.mark(h.addToSet(a.marks));else{if(0!=e.length||1!=f.length)return null;h=f[0],g="remove",i=a=>a.mark(h.removeFromSet(a.marks))}let j=[];for(let a=0;a<b.childCount;a++)j.push(i(b.child(a)));if(d$.from(j).eq(a))return{mark:h,type:g}}(q.parent.content.cut(q.parentOffset,r.parentOffset),s.parent.content.cut(s.parentOffset,p.endA-s.start())))){let b=w(a.state.tr);"add"==h.type?b.addMark(u,v,h.mark):b.removeMark(u,v,h.mark),a.dispatch(b)}else if(q.parent.child(q.index()).isText&&q.index()==r.index()-!r.textOffset){let b=q.parent.textBetween(q.parentOffset,r.parentOffset),c=()=>w(a.state.tr.insertText(b,u,v));a.someProp("handleTextInput",d=>d(a,u,v,b,c))||a.dispatch(c())}else a.dispatch(w());else a.dispatch(w())})(this,a,b,c,d)),this.domObserver.start(),function(a){for(let b in hh){let c=hh[b];a.dom.addEventListener(b,a.input.eventHandlers[b]=b=>{!function(a,b){if(!b.bubbles)return!0;if(b.defaultPrevented)return!1;for(let c=b.target;c!=a.dom;c=c.parentNode)if(!c||11==c.nodeType||c.pmViewDesc&&c.pmViewDesc.stopEvent(b))return!1;return!0}(a,b)||hn(a,b)||!a.editable&&b.type in hi||c(a,b)},hj[b]?{passive:!0}:void 0)}f4&&a.dom.addEventListener("input",()=>null),hm(a)}(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let a=this._props;for(let b in this._props={},a)this._props[b]=a[b];this._props.state=this.state}return this._props}update(a){a.handleDOMEvents!=this._props.handleDOMEvents&&hm(this);let b=this._props;this._props=a,a.plugins&&(a.plugins.forEach(ib),this.directPlugins=a.plugins),this.updateStateInner(a.state,b)}setProps(a){let b={};for(let a in this._props)b[a]=this._props[a];for(let c in b.state=this.state,a)b[c]=a[c];this.update(b)}updateState(a){this.updateStateInner(a,this._props)}updateStateInner(a,b){var c,d,e;let f=this.state,g=!1,h=!1;a.storedMarks&&this.composing&&(hw(this),h=!0),this.state=a;let i=f.plugins!=a.plugins||this._props.plugins!=b.plugins;if(i||this._props.plugins!=b.plugins||this._props.nodeViews!=b.nodeViews){let a=ia(this);(function(a,b){let c=0,d=0;for(let d in a){if(a[d]!=b[d])return!0;c++}for(let a in b)d++;return c!=d})(a,this.nodeViews)&&(this.nodeViews=a,g=!0)}(i||b.handleDOMEvents!=this._props.handleDOMEvents)&&hm(this),this.editable=h9(this),h8(this);let j=hV(this),k=h7(this),l=f.plugins==a.plugins||f.doc.eq(a.doc)?a.scrollToSelection>f.scrollToSelection?"to selection":"preserve":"reset",m=g||!this.docView.matchesNode(a.doc,k,j);(m||!a.selection.eq(f.selection))&&(h=!0);let n="preserve"==l&&h&&null==this.dom.style.overflowAnchor&&function(a){let b,c,d=a.dom.getBoundingClientRect(),e=Math.max(0,d.top);for(let f=(d.left+d.right)/2,g=e+1;g<Math.min(innerHeight,d.bottom);g+=5){let d=a.root.elementFromPoint(f,g);if(!d||d==a.dom||!a.dom.contains(d))continue;let h=d.getBoundingClientRect();if(h.top>=e-20){b=d,c=h.top;break}}return{refDOM:b,refTop:c,stack:gd(a.dom)}}(this);if(h){let b,c,h;this.domObserver.stop();let i=m&&(f$||f2)&&!this.composing&&!f.selection.empty&&!a.selection.empty&&(d=f.selection,e=a.selection,h=Math.min(d.$anchor.sharedDepth(d.head),e.$anchor.sharedDepth(e.head)),d.$anchor.start(h)!=e.$anchor.start(h));if(m){let b=f2?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=function(a){let b=a.domSelectionRange();if(!b.focusNode)return null;let c=function(a,b){for(;;){if(3==a.nodeType&&b)return a;if(1==a.nodeType&&b>0){if("false"==a.contentEditable)return null;b=fQ(a=a.childNodes[b-1])}else{if(!a.parentNode||fR(a))return null;b=fI(a),a=a.parentNode}}}(b.focusNode,b.focusOffset),d=function(a,b){for(;;){if(3==a.nodeType&&b<a.nodeValue.length)return a;if(1==a.nodeType&&b<a.childNodes.length){if("false"==a.contentEditable)return null;a=a.childNodes[b],b=0}else{if(!a.parentNode||fR(a))return null;b=fI(a)+1,a=a.parentNode}}}(b.focusNode,b.focusOffset);if(c&&d&&c!=d){let b=d.pmViewDesc,e=a.domObserver.lastChangedTextNode;if(c==e||d==e)return e;if(!b||!b.isText(d.nodeValue))return d;if(a.input.compositionNode==d){let a=c.pmViewDesc;if(!(!a||!a.isText(c.nodeValue)))return d}}return c||d}(this)),(g||!this.docView.update(a.doc,k,j,this))&&(this.docView.updateOuterDeco(k),this.docView.destroy(),this.docView=gx(a.doc,k,j,this.dom,this)),!b||this.trackWrites&&this.dom.contains(this.trackWrites)||(i=!0)}i||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&(b=this.docView.domFromPos(this.state.selection.anchor,0),c=this.domSelectionRange(),fN(b.node,b.offset,c.anchorNode,c.anchorOffset)))?gN(this,i):(gS(this,a.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(f),(null==(c=this.dragging)?void 0:c.node)&&!f.doc.eq(a.doc)&&this.updateDraggedNode(this.dragging,f),"reset"==l?this.dom.scrollTop=0:"to selection"==l?this.scrollToSelection():n&&function({refDOM:a,refTop:b,stack:c}){let d=a?a.getBoundingClientRect().top:0;ge(c,0==d?0:d-b)}(n)}scrollToSelection(){let a=this.domSelectionRange().focusNode;if(a&&this.dom.contains(1==a.nodeType?a:a.parentNode))if(this.someProp("handleScrollToSelection",a=>a(this)));else if(this.state.selection instanceof fs){let b=this.docView.domAfterPos(this.state.selection.from);1==b.nodeType&&gc(this,b.getBoundingClientRect(),a)}else gc(this,this.coordsAtPos(this.state.selection.head,1),a)}destroyPluginViews(){let a;for(;a=this.pluginViews.pop();)a.destroy&&a.destroy()}updatePluginViews(a){if(a&&a.plugins==this.state.plugins&&this.directPlugins==this.prevDirectPlugins)for(let b=0;b<this.pluginViews.length;b++){let c=this.pluginViews[b];c.update&&c.update(this,a)}else{this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let a=0;a<this.directPlugins.length;a++){let b=this.directPlugins[a];b.spec.view&&this.pluginViews.push(b.spec.view(this))}for(let a=0;a<this.state.plugins.length;a++){let b=this.state.plugins[a];b.spec.view&&this.pluginViews.push(b.spec.view(this))}}}updateDraggedNode(a,b){let c=a.node,d=-1;if(c.from<this.state.doc.content.size&&this.state.doc.nodeAt(c.from)==c.node)d=c.from;else{let a=c.from+(this.state.doc.content.size-b.doc.content.size);(a>0&&a<this.state.doc.content.size&&this.state.doc.nodeAt(a))==c.node&&(d=a)}this.dragging=new hB(a.slice,a.move,d<0?void 0:fs.create(this.state.doc,d))}someProp(a,b){let c=this._props&&this._props[a],d;if(null!=c&&(d=b?b(c):c))return d;for(let c=0;c<this.directPlugins.length;c++){let e=this.directPlugins[c].props[a];if(null!=e&&(d=b?b(e):e))return d}let e=this.state.plugins;if(e)for(let c=0;c<e.length;c++){let f=e[c].props[a];if(null!=f&&(d=b?b(f):f))return d}}hasFocus(){if(f$){let a=this.root.activeElement;if(a==this.dom)return!0;if(!a||!this.dom.contains(a))return!1;for(;a&&this.dom!=a&&this.dom.contains(a);){if("false"==a.contentEditable)return!1;a=a.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&function(a){if(a.setActive)return a.setActive();if(gf)return a.focus(gf);let b=gd(a);a.focus(null==gf?{get preventScroll(){return gf={preventScroll:!0},!0}}:void 0),gf||(gf=!1,ge(b,0))}(this.dom),gN(this),this.domObserver.start()}get root(){let a=this._root;if(null==a){for(let a=this.dom.parentNode;a;a=a.parentNode)if(9==a.nodeType||11==a.nodeType&&a.host)return a.getSelection||(Object.getPrototypeOf(a).getSelection=()=>a.ownerDocument.getSelection()),this._root=a}return a||document}updateRoot(){this._root=null}posAtCoords(a){return function(a,b){var c;let d,e,f=a.dom.ownerDocument,g,h=0,i=function(a,b,c){if(a.caretPositionFromPoint)try{let d=a.caretPositionFromPoint(b,c);if(d)return{node:d.offsetNode,offset:Math.min(fQ(d.offsetNode),d.offset)}}catch(a){}if(a.caretRangeFromPoint){let d=a.caretRangeFromPoint(b,c);if(d)return{node:d.startContainer,offset:Math.min(fQ(d.startContainer),d.startOffset)}}}(f,b.left,b.top);i&&({node:g,offset:h}=i);let j=(a.root.elementFromPoint?a.root:f).elementFromPoint(b.left,b.top);if(!j||!a.dom.contains(1!=j.nodeType?j.parentNode:j)){let c=a.dom.getBoundingClientRect();if(!gg(b,c)||!(j=function a(b,c,d){let e=b.childNodes.length;if(e&&d.top<d.bottom)for(let f=Math.max(0,Math.min(e-1,Math.floor(e*(c.top-d.top)/(d.bottom-d.top))-2)),g=f;;){let d=b.childNodes[g];if(1==d.nodeType){let b=d.getClientRects();for(let e=0;e<b.length;e++){let f=b[e];if(gg(c,f))return a(d,c,f)}}if((g=(g+1)%e)==f)break}return b}(a.dom,b,c)))return null}if(f4)for(let a=j;g&&a;a=fJ(a))a.draggable&&(g=void 0);if(j=(d=(c=j).parentNode)&&/^li$/i.test(d.nodeName)&&b.left<c.getBoundingClientRect().left?d:c,g){let c;if(f0&&1==g.nodeType&&(h=Math.min(h,g.childNodes.length))<g.childNodes.length){let a=g.childNodes[h],c;"IMG"==a.nodeName&&(c=a.getBoundingClientRect()).right<=b.left&&c.bottom>b.top&&h++}f9&&h&&1==g.nodeType&&1==(c=g.childNodes[h-1]).nodeType&&"false"==c.contentEditable&&c.getBoundingClientRect().top>=b.top&&h--,g==a.dom&&h==g.childNodes.length-1&&1==g.lastChild.nodeType&&b.top>g.lastChild.getBoundingClientRect().bottom?e=a.state.doc.content.size:(0==h||1!=g.nodeType||"BR"!=g.childNodes[h-1].nodeName)&&(e=function(a,b,c,d){let e=-1;for(let c=b,f=!1;c!=a.dom;){let b=a.docView.nearestDesc(c,!0),g;if(!b)return null;if(1==b.dom.nodeType&&(b.node.isBlock&&b.parent||!b.contentDOM)&&((g=b.dom.getBoundingClientRect()).width||g.height)&&(b.node.isBlock&&b.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(b.dom.nodeName)&&(!f&&g.left>d.left||g.top>d.top?e=b.posBefore:(!f&&g.right<d.left||g.bottom<d.top)&&(e=b.posAfter),f=!0),!b.contentDOM&&e<0&&!b.node.isText))return(b.node.isBlock?d.top<(g.top+g.bottom)/2:d.left<(g.left+g.right)/2)?b.posBefore:b.posAfter;c=b.dom.parentNode}return e>-1?e:a.docView.posFromDOM(b,c,-1)}(a,g,h,b))}null==e&&(e=function(a,b,c){let{node:d,offset:e}=function a(b,c){let d,e,f,g=2e8,h,i=0,j=c.top,k=c.top;for(let a=b.firstChild,l=0;a;a=a.nextSibling,l++){let b;if(1==a.nodeType)b=a.getClientRects();else{if(3!=a.nodeType)continue;b=fL(a).getClientRects()}for(let m=0;m<b.length;m++){let n=b[m];if(n.top<=j&&n.bottom>=k){j=Math.max(n.bottom,j),k=Math.min(n.top,k);let b=n.left>c.left?n.left-c.left:n.right<c.left?c.left-n.right:0;if(b<g){f=a,g=b,h=b&&3==f.nodeType?{left:n.right<c.left?n.right:n.left,top:c.top}:c,1==a.nodeType&&b&&(i=l+ +(c.left>=(n.left+n.right)/2));continue}}else n.top>c.top&&!d&&n.left<=c.left&&n.right>=c.left&&(d=a,e={left:Math.max(n.left,Math.min(n.right,c.left)),top:n.top});!f&&(c.left>=n.right&&c.top>=n.top||c.left>=n.left&&c.top>=n.bottom)&&(i=l+1)}}return(!f&&d&&(f=d,h=e,g=0),f&&3==f.nodeType)?function(a,b){let c=a.nodeValue.length,d=document.createRange(),e;for(let f=0;f<c;f++){d.setEnd(a,f+1),d.setStart(a,f);let c=gi(d,1);if(c.top!=c.bottom&&gg(b,c)){e={node:a,offset:f+ +(b.left>=(c.left+c.right)/2)};break}}return d.detach(),e||{node:a,offset:0}}(f,h):!f||g&&1==f.nodeType?{node:b,offset:i}:a(f,h)}(b,c),f=-1;if(1==d.nodeType&&!d.firstChild){let a=d.getBoundingClientRect();f=a.left!=a.right&&c.left>(a.left+a.right)/2?1:-1}return a.docView.posFromDOM(d,e,f)}(a,j,b));let k=a.docView.nearestDesc(j,!0);return{pos:e,inside:k?k.posAtStart-k.border:-1}}(this,a)}coordsAtPos(a,b=1){return gk(this,a,b)}domAtPos(a,b=0){return this.docView.domFromPos(a,b)}nodeDOM(a){let b=this.docView.descAt(a);return b?b.nodeDOM:null}posAtDOM(a,b,c=-1){let d=this.docView.posFromDOM(a,b,c);if(null==d)throw RangeError("DOM position not inside the editor");return d}endOfTextblock(a,b){return function(a,b,c){let d,e;return gp==b&&gq==c?gr:(gp=b,gq=c,gr="up"==c||"down"==c?(d=b.selection,e="up"==c?d.$from:d.$to,gn(a,b,()=>{let{node:b}=a.docView.domFromPos(e.pos,"up"==c?-1:1);for(;;){let c=a.docView.nearestDesc(b,!0);if(!c)break;if(c.node.isBlock){b=c.contentDOM||c.dom;break}b=c.dom.parentNode}let d=gk(a,e.pos,1);for(let a=b.firstChild;a;a=a.nextSibling){let b;if(1==a.nodeType)b=a.getClientRects();else{if(3!=a.nodeType)continue;b=fL(a,0,a.nodeValue.length).getClientRects()}for(let a=0;a<b.length;a++){let e=b[a];if(e.bottom>e.top+1&&("up"==c?d.top-e.top>(e.bottom-d.top)*2:e.bottom-d.bottom>(d.bottom-e.top)*2))return!1}}return!0})):function(a,b,c){let{$head:d}=b.selection;if(!d.parent.isTextblock)return!1;let e=d.parentOffset,f=e==d.parent.content.size,g=a.domSelection();return g?go.test(d.parent.textContent)&&g.modify?gn(a,b,()=>{let{focusNode:b,focusOffset:e,anchorNode:f,anchorOffset:h}=a.domSelectionRange(),i=g.caretBidiLevel;g.modify("move",c,"character");let j=d.depth?a.docView.domAfterPos(d.before()):a.dom,{focusNode:k,focusOffset:l}=a.domSelectionRange(),m=k&&!j.contains(1==k.nodeType?k:k.parentNode)||b==k&&e==l;try{g.collapse(f,h),b&&(b!=f||e!=h)&&g.extend&&g.extend(b,e)}catch(a){}return null!=i&&(g.caretBidiLevel=i),m}):"left"==c||"backward"==c?!e:f:d.pos==d.start()||d.pos==d.end()}(a,b,c))}(this,b||this.state,a)}pasteHTML(a,b){return hz(this,"",a,!1,b||new ClipboardEvent("paste"))}pasteText(a,b){return hz(this,a,null,!0,b||new ClipboardEvent("paste"))}serializeForClipboard(a){return g7(this,a)}destroy(){if(this.docView){for(let a in this.domObserver.stop(),this.input.eventHandlers)this.dom.removeEventListener(a,this.input.eventHandlers[a]);clearTimeout(this.input.composingTimeout),clearTimeout(this.input.lastIOSEnterFallbackTimeout),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],hV(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,fM()}}get isDestroyed(){return null==this.docView}dispatchEvent(a){!hn(this,a)&&hh[a.type]&&(this.editable||!(a.type in hi))&&hh[a.type](this,a)}domSelectionRange(){let a=this.domSelection();return a?f4&&11===this.root.nodeType&&function(a){let b=a.activeElement;for(;b&&b.shadowRoot;)b=b.shadowRoot.activeElement;return b}(this.dom.ownerDocument)==this.dom&&function(a,b){let c;if(b.getComposedRanges){let c=b.getComposedRanges(a.root)[0];if(c)return h0(a,c)}function d(a){a.preventDefault(),a.stopImmediatePropagation(),c=a.getTargetRanges()[0]}return a.dom.addEventListener("beforeinput",d,!0),document.execCommand("indent"),a.dom.removeEventListener("beforeinput",d,!0),c?h0(a,c):null}(this,a)||a:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function h7(a){let b=Object.create(null);return b.class="ProseMirror",b.contenteditable=String(a.editable),a.someProp("attributes",c=>{if("function"==typeof c&&(c=c(a.state)),c)for(let a in c)"class"==a?b.class+=" "+c[a]:"style"==a?b.style=(b.style?b.style+";":"")+c[a]:b[a]||"contenteditable"==a||"nodeName"==a||(b[a]=String(c[a]))}),b.translate||(b.translate="no"),[hI.node(0,a.state.doc.content.size,b)]}function h8(a){if(a.markCursor){let b=document.createElement("img");b.className="ProseMirror-separator",b.setAttribute("mark-placeholder","true"),b.setAttribute("alt",""),a.cursorWrapper={dom:b,deco:hI.widget(a.state.selection.from,b,{raw:!0,marks:a.markCursor})}}else a.cursorWrapper=null}function h9(a){return!a.someProp("editable",b=>!1===b(a.state))}function ia(a){let b=Object.create(null);function c(a){for(let c in a)Object.prototype.hasOwnProperty.call(b,c)||(b[c]=a[c])}return a.someProp("nodeViews",c),a.someProp("markViews",c),b}function ib(a){if(a.spec.state||a.spec.filterTransaction||a.spec.appendTransaction)throw RangeError("Plugins passed directly to the view must not have a state component")}h6.prototype.dispatch=function(a){let b=this._props.dispatchTransaction;b?b.call(this,a):this.updateState(this.state.apply(a))};for(var ic={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},id={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},ie="u">typeof navigator&&/Mac/.test(navigator.platform),ig="u">typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),ih=0;ih<10;ih++)ic[48+ih]=ic[96+ih]=String(ih);for(var ih=1;ih<=24;ih++)ic[ih+111]="F"+ih;for(var ih=65;ih<=90;ih++)ic[ih]=String.fromCharCode(ih+32),id[ih]=String.fromCharCode(ih);for(var ii in ic)id.hasOwnProperty(ii)||(id[ii]=ic[ii]);let ij="u">typeof navigator&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),ik="u">typeof navigator&&/Win/.test(navigator.platform);function il(a,b,c=!0){return b.altKey&&(a="Alt-"+a),b.ctrlKey&&(a="Ctrl-"+a),b.metaKey&&(a="Meta-"+a),c&&b.shiftKey&&(a="Shift-"+a),a}function im(a){let b=function(a){let b=Object.create(null);for(let c in a)b[function(a){let b,c,d,e,f=a.split(/-(?!$)/),g=f[f.length-1];"Space"==g&&(g=" ");for(let a=0;a<f.length-1;a++){let g=f[a];if(/^(cmd|meta|m)$/i.test(g))e=!0;else if(/^a(lt)?$/i.test(g))b=!0;else if(/^(c|ctrl|control)$/i.test(g))c=!0;else if(/^s(hift)?$/i.test(g))d=!0;else if(/^mod$/i.test(g))ij?e=!0:c=!0;else throw Error("Unrecognized modifier name: "+g)}return b&&(g="Alt-"+g),c&&(g="Ctrl-"+g),e&&(g="Meta-"+g),d&&(g="Shift-"+g),g}(c)]=a[c];return b}(a);return function(a,c){var d;let e=("Esc"==(d=!(ie&&c.metaKey&&c.shiftKey&&!c.ctrlKey&&!c.altKey||ig&&c.shiftKey&&c.key&&1==c.key.length||"Unidentified"==c.key)&&c.key||(c.shiftKey?id:ic)[c.keyCode]||c.key||"Unidentified")&&(d="Escape"),"Del"==d&&(d="Delete"),"Left"==d&&(d="ArrowLeft"),"Up"==d&&(d="ArrowUp"),"Right"==d&&(d="ArrowRight"),"Down"==d&&(d="ArrowDown"),d),f,g=b[il(e,c)];if(g&&g(a.state,a.dispatch,a))return!0;if(1==e.length&&" "!=e){if(c.shiftKey){let d=b[il(e,c,!1)];if(d&&d(a.state,a.dispatch,a))return!0}if((c.altKey||c.metaKey||c.ctrlKey)&&!(ik&&c.ctrlKey&&c.altKey)&&(f=ic[c.keyCode])&&f!=e){let d=b[il(f,c)];if(d&&d(a.state,a.dispatch,a))return!0}}return!1}}if("u">typeof WeakMap){let a=new WeakMap;b=b=>a.get(b),c=(b,c)=>(a.set(b,c),c)}else{let a=[],d=0;b=b=>{for(let c=0;c<a.length;c+=2)if(a[c]==b)return a[c+1]},c=(b,c)=>(10==d&&(d=0),a[d++]=b,a[d++]=c)}var io=class{constructor(a,b,c,d){this.width=a,this.height=b,this.map=c,this.problems=d}findCell(a){for(let b=0;b<this.map.length;b++){let c=this.map[b];if(c!=a)continue;let d=b%this.width,e=b/this.width|0,f=d+1,g=e+1;for(let a=1;f<this.width&&this.map[b+a]==c;a++)f++;for(let a=1;g<this.height&&this.map[b+this.width*a]==c;a++)g++;return{left:d,top:e,right:f,bottom:g}}throw RangeError(`No cell with offset ${a} found`)}colCount(a){for(let b=0;b<this.map.length;b++)if(this.map[b]==a)return b%this.width;throw RangeError(`No cell with offset ${a} found`)}nextCell(a,b,c){let{left:d,right:e,top:f,bottom:g}=this.findCell(a);return"horiz"==b?(c<0?0==d:e==this.width)?null:this.map[f*this.width+(c<0?d-1:e)]:(c<0?0==f:g==this.height)?null:this.map[d+this.width*(c<0?f-1:g)]}rectBetween(a,b){let{left:c,right:d,top:e,bottom:f}=this.findCell(a),{left:g,right:h,top:i,bottom:j}=this.findCell(b);return{left:Math.min(c,g),top:Math.min(e,i),right:Math.max(d,h),bottom:Math.max(f,j)}}cellsInRect(a){let b=[],c={};for(let d=a.top;d<a.bottom;d++)for(let e=a.left;e<a.right;e++){let f=d*this.width+e,g=this.map[f];!c[g]&&(c[g]=!0,e==a.left&&e&&this.map[f-1]==g||d==a.top&&d&&this.map[f-this.width]==g||b.push(g))}return b}positionAt(a,b,c){for(let d=0,e=0;;d++){let f=e+c.child(d).nodeSize;if(d==a){let c=b+a*this.width,d=(a+1)*this.width;for(;c<d&&this.map[c]<e;)c++;return c==d?f-1:this.map[c]}e=f}}static get(a){return b(a)||c(a,function(a){if("table"!=a.type.spec.tableRole)throw RangeError("Not a table node: "+a.type.name);let b=function(a){let b=-1,c=!1;for(let d=0;d<a.childCount;d++){let e=a.child(d),f=0;if(c)for(let b=0;b<d;b++){let c=a.child(b);for(let a=0;a<c.childCount;a++){let e=c.child(a);b+e.attrs.rowspan>d&&(f+=e.attrs.colspan)}}for(let a=0;a<e.childCount;a++){let b=e.child(a);f+=b.attrs.colspan,b.attrs.rowspan>1&&(c=!0)}-1==b?b=f:b!=f&&(b=Math.max(b,f))}return b}(a),c=a.childCount,d=[],e=0,f=null,g=[];for(let a=0,e=b*c;a<e;a++)d[a]=0;for(let h=0,i=0;h<c;h++){let j=a.child(h);i++;for(let a=0;;a++){for(;e<d.length&&0!=d[e];)e++;if(a==j.childCount)break;let k=j.child(a),{colspan:l,rowspan:m,colwidth:n}=k.attrs;for(let a=0;a<m;a++){if(a+h>=c){(f||(f=[])).push({type:"overlong_rowspan",pos:i,n:m-a});break}let j=e+a*b;for(let a=0;a<l;a++){0==d[j+a]?d[j+a]=i:(f||(f=[])).push({type:"collision",row:h,pos:i,n:l-a});let c=n&&n[a];if(c){let d=(j+a)%b*2,e=g[d];null==e||e!=c&&1==g[d+1]?(g[d]=c,g[d+1]=1):e==c&&g[d+1]++}}}e+=l,i+=k.nodeSize}let k=(h+1)*b,l=0;for(;e<k;)0==d[e++]&&l++;l&&(f||(f=[])).push({type:"missing",row:h,n:l}),i++}(0===b||0===c)&&(f||(f=[])).push({type:"zero_sized"});let h=new io(b,c,d,f),i=!1;for(let a=0;!i&&a<g.length;a+=2)null!=g[a]&&g[a+1]<c&&(i=!0);return i&&function(a,b,c){a.problems||(a.problems=[]);let d={};for(let e=0;e<a.map.length;e++){let f=a.map[e];if(d[f])continue;d[f]=!0;let g=c.nodeAt(f);if(!g)throw RangeError(`No cell with offset ${f} found`);let h=null,i=g.attrs;for(let c=0;c<i.colspan;c++){let d=b[(e+c)%a.width*2];null==d||i.colwidth&&i.colwidth[c]==d||((h||(h=function(a){if(a.colwidth)return a.colwidth.slice();let b=[];for(let c=0;c<a.colspan;c++)b.push(0);return b}(i)))[c]=d)}h&&a.problems.unshift({type:"colwidth mismatch",pos:f,colwidth:h})}}(h,g,a),h}(a))}};function ip(a){let b=a.cached.tableNodeTypes;if(!b)for(let c in b=a.cached.tableNodeTypes={},a.nodes){let d=a.nodes[c],e=d.spec.tableRole;e&&(b[e]=d)}return b}let iq=new fH("selectingCells");function ir(a){for(let b=a.depth-1;b>0;b--)if("row"==a.node(b).type.spec.tableRole)return a.node(0).resolve(a.before(b+1));return null}function is(a){let b=a.selection.$head;for(let a=b.depth;a>0;a--)if("row"==b.node(a).type.spec.tableRole)return!0;return!1}function it(a){let b=a.selection;if("$anchorCell"in b&&b.$anchorCell)return b.$anchorCell.pos>b.$headCell.pos?b.$anchorCell:b.$headCell;if("node"in b&&b.node&&"cell"==b.node.type.spec.tableRole)return b.$anchor;let c=ir(b.$head)||function(a){for(let b=a.nodeAfter,c=a.pos;b;b=b.firstChild,c++){let d=b.type.spec.tableRole;if("cell"==d||"header_cell"==d)return a.doc.resolve(c)}for(let b=a.nodeBefore,c=a.pos;b;b=b.lastChild,c--){let d=b.type.spec.tableRole;if("cell"==d||"header_cell"==d)return a.doc.resolve(c-b.nodeSize)}}(b.$head);if(c)return c;throw RangeError(`No cell found around position ${b.head}`)}function iu(a){return"row"==a.parent.type.spec.tableRole&&!!a.nodeAfter}function iv(a,b){return a.depth==b.depth&&a.pos>=b.start(-1)&&a.pos<=b.end(-1)}function iw(a,b,c){let d=a.node(-1),e=io.get(d),f=a.start(-1),g=e.nextCell(a.pos-f,b,c);return null==g?null:a.node(0).resolve(f+g)}function ix(a,b,c=1){let d={...a,colspan:a.colspan-c};return d.colwidth&&(d.colwidth=d.colwidth.slice(),d.colwidth.splice(b,c),d.colwidth.some(a=>a>0)||(d.colwidth=null)),d}function iy(a,b,c=1){let d={...a,colspan:a.colspan+c};if(d.colwidth){d.colwidth=d.colwidth.slice();for(let a=0;a<c;a++)d.colwidth.splice(b,0,0)}return d}var iz=class a extends fm{constructor(a,b=a){const c=a.node(-1),d=io.get(c),e=a.start(-1),f=d.rectBetween(a.pos-e,b.pos-e),g=a.node(0),h=d.cellsInRect(f).filter(a=>a!=b.pos-e);h.unshift(b.pos-e);const i=h.map(a=>{let b=c.nodeAt(a);if(!b)throw RangeError(`No cell with offset ${a} found`);let d=e+a+1;return new fn(g.resolve(d),g.resolve(d+b.content.size))});super(i[0].$from,i[0].$to,i),this.$anchorCell=a,this.$headCell=b}map(b,c){let d=b.resolve(c.map(this.$anchorCell.pos)),e=b.resolve(c.map(this.$headCell.pos));if(iu(d)&&iu(e)&&iv(d,e)){let b=this.$anchorCell.node(-1)!=d.node(-1);return b&&this.isRowSelection()?a.rowSelection(d,e):b&&this.isColSelection()?a.colSelection(d,e):new a(d,e)}return fq.between(d,e)}content(){let a=this.$anchorCell.node(-1),b=io.get(a),c=this.$anchorCell.start(-1),d=b.rectBetween(this.$anchorCell.pos-c,this.$headCell.pos-c),e={},f=[];for(let c=d.top;c<d.bottom;c++){let g=[];for(let f=c*b.width+d.left,h=d.left;h<d.right;h++,f++){let c=b.map[f];if(e[c])continue;e[c]=!0;let h=b.findCell(c),i=a.nodeAt(c);if(!i)throw RangeError(`No cell with offset ${c} found`);let j=d.left-h.left,k=h.right-d.right;if(j>0||k>0){let a=i.attrs;if(j>0&&(a=ix(a,0,j)),k>0&&(a=ix(a,a.colspan-k,k)),h.left<d.left){if(!(i=i.type.createAndFill(a)))throw RangeError(`Could not create cell with attrs ${JSON.stringify(a)}`)}else i=i.type.create(a,i.content)}if(h.top<d.top||h.bottom>d.bottom){let a={...i.attrs,rowspan:Math.min(h.bottom,d.bottom)-Math.max(h.top,d.top)};i=h.top<d.top?i.type.createAndFill(a):i.type.create(a,i.content)}g.push(i)}f.push(a.child(c).copy(d$.from(g)))}let g=this.isColSelection()&&this.isRowSelection()?a:f;return new d4(d$.from(g),1,1)}replace(a,b=d4.empty){let c=a.steps.length,d=this.ranges;for(let e=0;e<d.length;e++){let{$from:f,$to:g}=d[e],h=a.mapping.slice(c);a.replace(h.map(f.pos),h.map(g.pos),e?d4.empty:b)}let e=fm.findFrom(a.doc.resolve(a.mapping.slice(c).map(this.to)),-1);e&&a.setSelection(e)}replaceWith(a,b){this.replace(a,new d4(d$.from(b),0,0))}forEachCell(a){let b=this.$anchorCell.node(-1),c=io.get(b),d=this.$anchorCell.start(-1),e=c.cellsInRect(c.rectBetween(this.$anchorCell.pos-d,this.$headCell.pos-d));for(let c=0;c<e.length;c++)a(b.nodeAt(e[c]),d+e[c])}isColSelection(){let a=this.$anchorCell.index(-1),b=this.$headCell.index(-1);return!(Math.min(a,b)>0)&&Math.max(a+this.$anchorCell.nodeAfter.attrs.rowspan,b+this.$headCell.nodeAfter.attrs.rowspan)==this.$headCell.node(-1).childCount}static colSelection(b,c=b){let d=b.node(-1),e=io.get(d),f=b.start(-1),g=e.findCell(b.pos-f),h=e.findCell(c.pos-f),i=b.node(0);return g.top<=h.top?(g.top>0&&(b=i.resolve(f+e.map[g.left])),h.bottom<e.height&&(c=i.resolve(f+e.map[e.width*(e.height-1)+h.right-1]))):(h.top>0&&(c=i.resolve(f+e.map[h.left])),g.bottom<e.height&&(b=i.resolve(f+e.map[e.width*(e.height-1)+g.right-1]))),new a(b,c)}isRowSelection(){let a=this.$anchorCell.node(-1),b=io.get(a),c=this.$anchorCell.start(-1),d=b.colCount(this.$anchorCell.pos-c),e=b.colCount(this.$headCell.pos-c);return!(Math.min(d,e)>0)&&Math.max(d+this.$anchorCell.nodeAfter.attrs.colspan,e+this.$headCell.nodeAfter.attrs.colspan)==b.width}eq(b){return b instanceof a&&b.$anchorCell.pos==this.$anchorCell.pos&&b.$headCell.pos==this.$headCell.pos}static rowSelection(b,c=b){let d=b.node(-1),e=io.get(d),f=b.start(-1),g=e.findCell(b.pos-f),h=e.findCell(c.pos-f),i=b.node(0);return g.left<=h.left?(g.left>0&&(b=i.resolve(f+e.map[g.top*e.width])),h.right<e.width&&(c=i.resolve(f+e.map[e.width*(h.top+1)-1]))):(h.left>0&&(c=i.resolve(f+e.map[h.top*e.width])),g.right<e.width&&(b=i.resolve(f+e.map[e.width*(g.top+1)-1]))),new a(b,c)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(b,c){return new a(b.resolve(c.anchor),b.resolve(c.head))}static create(b,c,d=c){return new a(b.resolve(c),b.resolve(d))}getBookmark(){return new iA(this.$anchorCell.pos,this.$headCell.pos)}};iz.prototype.visible=!1,fm.jsonID("cell",iz);var iA=class a{constructor(a,b){this.anchor=a,this.head=b}map(b){return new a(b.map(this.anchor),b.map(this.head))}resolve(a){let b=a.resolve(this.anchor),c=a.resolve(this.head);return"row"==b.parent.type.spec.tableRole&&"row"==c.parent.type.spec.tableRole&&b.index()<b.parent.childCount&&c.index()<c.parent.childCount&&iv(b,c)?new iz(b,c):fm.near(c,1)}};function iB(a){if(!(a.selection instanceof iz))return null;let b=[];return a.selection.forEachCell((a,c)=>{b.push(hI.node(c,c+a.nodeSize,{class:"selectedCell"}))}),hL.create(a.doc,b)}let iC=new fH("fix-tables");function iD(a,b){let c,d=(b,d)=>{"table"==b.type.spec.tableRole&&(c=function(a,b,c,d){let e,f,g=io.get(b);if(!g.problems)return d;d||(d=a.tr);let h=[];for(let a=0;a<g.height;a++)h.push(0);for(let a=0;a<g.problems.length;a++){let e=g.problems[a];if("collision"==e.type){let a=b.nodeAt(e.pos);if(!a)continue;let f=a.attrs;for(let a=0;a<f.rowspan;a++)h[e.row+a]+=e.n;d.setNodeMarkup(d.mapping.map(c+1+e.pos),null,ix(f,f.colspan-e.n,e.n))}else if("missing"==e.type)h[e.row]+=e.n;else if("overlong_rowspan"==e.type){let a=b.nodeAt(e.pos);if(!a)continue;d.setNodeMarkup(d.mapping.map(c+1+e.pos),null,{...a.attrs,rowspan:a.attrs.rowspan-e.n})}else if("colwidth mismatch"==e.type){let a=b.nodeAt(e.pos);if(!a)continue;d.setNodeMarkup(d.mapping.map(c+1+e.pos),null,{...a.attrs,colwidth:e.colwidth})}else if("zero_sized"==e.type){let a=d.mapping.map(c);d.delete(a,a+b.nodeSize)}}for(let a=0;a<h.length;a++)h[a]&&(null==e&&(e=a),f=a);for(let i=0,j=c+1;i<g.height;i++){let c=b.child(i),g=j+c.nodeSize,k=h[i];if(k>0){let b="cell";c.firstChild&&(b=c.firstChild.type.spec.tableRole);let h=[];for(let c=0;c<k;c++){let c=ip(a.schema)[b].createAndFill();c&&h.push(c)}let l=(0==i||e==i-1)&&f==i?j+1:g-1;d.insert(d.mapping.map(l),h)}j=g}return d.setMeta(iC,{fixTables:!0})}(a,b,d,c))};return b?b.doc!=a.doc&&function a(b,c,d,e){let f=b.childCount,g=c.childCount;d:for(let h=0,i=0;h<g;h++){let g=c.child(h);for(let a=i,c=Math.min(f,h+3);a<c;a++)if(b.child(a)==g){i=a+1,d+=g.nodeSize;continue d}e(g,d),i<f&&b.child(i).sameMarkup(g)?a(b.child(i),g,d+1,e):g.nodesBetween(0,g.content.size,e,d+1),d+=g.nodeSize}}(b.doc,a.doc,0,d):a.doc.descendants(d),c}function iE(a){let b=io.get(a),c=[],d=b.height,e=b.width;for(let f=0;f<d;f++){let d=[];for(let c=0;c<e;c++){let g=f*e+c,h=b.map[g];if(f>0){let a=g-e;if(h===b.map[a]){d.push(null);continue}}if(c>0){let a=g-1;if(h===b.map[a]){d.push(null);continue}}d.push(a.nodeAt(h))}c.push(d)}return c}function iF(a,b){let c=[],d=io.get(a),e=d.height,f=d.width;for(let g=0;g<e;g++){let e=a.child(g),h=[];for(let c=0;c<f;c++){let e=b[g][c];if(!e)continue;let f=d.map[g*d.width+c],i=a.nodeAt(f);if(!i)continue;let j=i.type.createChecked(e.attrs,e.content,e.marks);h.push(j)}let i=e.type.createChecked(e.attrs,h,e.marks);c.push(i)}return a.type.createChecked(a.attrs,c,a.marks)}function iG(a,b,c,d){let e,f=b[0]>c[0]?-1:1,g=a.splice(b[0],b.length),h=+(g.length%2==0);return e=-1===d&&1===f?c[0]-1:1===d&&-1===f?c[c.length-1]-h+1:-1===f?c[0]:c[c.length-1]-h,a.splice(e,0,...g),a}function iH(a){var b=a;for(let a=b.depth;a>=0;a-=1){let c=b.node(a);if((a=>"table"===a.type.spec.tableRole)(c))return{node:c,pos:0===a?0:b.before(a),start:b.start(a),depth:a}}return null}function iI(a,b){let c=iH(b.$from);if(!c)return;let d=io.get(c.node);if(!(a<0)&&!(a>d.width-1))return d.cellsInRect({left:a,right:a+1,top:0,bottom:d.height}).map(a=>{let b=c.node.nodeAt(a),d=a+c.start;return{pos:d,start:d+1,node:b,depth:c.depth+2}})}function iJ(a,b){let c=iH(b.$from);if(!c)return;let d=io.get(c.node);if(!(a<0)&&!(a>d.height-1))return d.cellsInRect({left:0,right:d.width,top:a,bottom:a+1}).map(a=>{let b=c.node.nodeAt(a),d=a+c.start;return{pos:d,start:d+1,node:b,depth:c.depth+2}})}function iK(a,b,c=b){let d,e=b,f=c;for(let c=b;c>=0;c--){let b=iI(c,a.selection);b&&b.forEach(a=>{let b=a.node.attrs.colspan+c-1;b>=e&&(e=c),b>f&&(f=b)})}for(let c=b;c<=f;c++){let b=iI(c,a.selection);b&&b.forEach(a=>{let b=a.node.attrs.colspan+c-1;a.node.attrs.colspan>1&&b>f&&(f=b)})}let g=[];for(let b=e;b<=f;b++){let c=iI(b,a.selection);c&&c.length>0&&g.push(b)}e=g[0],f=g[g.length-1];let h=iI(e,a.selection),i=iJ(0,a.selection);if(!h||!i)return;let j=a.doc.resolve(h[h.length-1].pos);for(let b=f;b>=e;b--){let c=iI(b,a.selection);if(c&&c.length>0){for(let a=i.length-1;a>=0;a--)if(i[a].pos===c[0].pos){d=c[0];break}if(d)break}}if(d)return{$anchor:j,$head:a.doc.resolve(d.pos),indexes:g}}function iL(a,b,c=b){let d,e=b,f=c;for(let c=b;c>=0;c--){let b=iJ(c,a.selection);b&&b.forEach(a=>{let b=a.node.attrs.rowspan+c-1;b>=e&&(e=c),b>f&&(f=b)})}for(let c=b;c<=f;c++){let b=iJ(c,a.selection);b&&b.forEach(a=>{let b=a.node.attrs.rowspan+c-1;a.node.attrs.rowspan>1&&b>f&&(f=b)})}let g=[];for(let b=e;b<=f;b++){let c=iJ(b,a.selection);c&&c.length>0&&g.push(b)}e=g[0],f=g[g.length-1];let h=iJ(e,a.selection),i=iI(0,a.selection);if(!h||!i)return;let j=a.doc.resolve(h[h.length-1].pos);for(let b=f;b>=e;b--){let c=iJ(b,a.selection);if(c&&c.length>0){for(let a=i.length-1;a>=0;a--)if(i[a].pos===c[0].pos){d=c[0];break}if(d)break}}if(d)return{$anchor:j,$head:a.doc.resolve(d.pos),indexes:g}}function iM(a){return a[0].map((b,c)=>a.map(a=>a[c]))}function iN(a){let b=a.selection,c=it(a),d=c.node(-1),e=c.start(-1),f=io.get(d);return{...b instanceof iz?f.rectBetween(b.$anchorCell.pos-e,b.$headCell.pos-e):f.findCell(c.pos-e),tableStart:e,map:f,table:d}}function iO(a,{map:b,tableStart:c,table:d},e){let f=e>0?-1:0;(function(a,b,c){let d=ip(b.type.schema).header_cell;for(let e=0;e<a.height;e++)if(b.nodeAt(a.map[c+e*a.width]).type!=d)return!1;return!0})(b,d,e+f)&&(f=0==e||e==b.width?null:0);for(let g=0;g<b.height;g++){let h=g*b.width+e;if(e>0&&e<b.width&&b.map[h-1]==b.map[h]){let f=b.map[h],i=d.nodeAt(f);a.setNodeMarkup(a.mapping.map(c+f),null,iy(i.attrs,e-b.colCount(f))),g+=i.attrs.rowspan-1}else{let i=null==f?ip(d.type.schema).cell:d.nodeAt(b.map[h+f]).type,j=b.positionAt(g,e,d);a.insert(a.mapping.map(c+j),i.createAndFill())}}return a}function iP(a,{map:b,tableStart:c,table:d},e){let f=c;for(let a=0;a<e;a++)f+=d.child(a).nodeSize;let g=[],h=e>0?-1:0;(function(a,b,c){var d;let e=ip(b.type.schema).header_cell;for(let f=0;f<a.width;f++)if((null==(d=b.nodeAt(a.map[f+c*a.width]))?void 0:d.type)!=e)return!1;return!0})(b,d,e+h)&&(h=0==e||e==b.height?null:0);for(let f=0,j=b.width*e;f<b.width;f++,j++)if(e>0&&e<b.height&&b.map[j]==b.map[j-b.width]){let e=b.map[j],g=d.nodeAt(e).attrs;a.setNodeMarkup(c+e,null,{...g,rowspan:g.rowspan+1}),f+=g.colspan-1}else{var i;let a=null==h?ip(d.type.schema).cell:null==(i=d.nodeAt(b.map[j+h*b.width]))?void 0:i.type,c=null==a?void 0:a.createAndFill();c&&g.push(c)}return a.insert(f,ip(d.type.schema).row.create(null,g)),a}function iQ(a){let b=a.content;return 1==b.childCount&&b.child(0).isTextblock&&0==b.child(0).childCount}function iR(a,b){let c=a.selection;if(!(c instanceof iz)||c.$anchorCell.pos==c.$headCell.pos)return!1;let d=iN(a),{map:e}=d;if(function({width:a,height:b,map:c},d){let e=d.top*a+d.left,f=e,g=(d.bottom-1)*a+d.left,h=e+(d.right-d.left-1);for(let b=d.top;b<d.bottom;b++){if(d.left>0&&c[f]==c[f-1]||d.right<a&&c[h]==c[h+1])return!0;f+=a,h+=a}for(let f=d.left;f<d.right;f++){if(d.top>0&&c[e]==c[e-a]||d.bottom<b&&c[g]==c[g+a])return!0;e++,g++}return!1}(e,d))return!1;if(b){let c,f,g=a.tr,h={},i=d$.empty;for(let a=d.top;a<d.bottom;a++)for(let b=d.left;b<d.right;b++){let j=e.map[a*e.width+b],k=d.table.nodeAt(j);if(!h[j]&&k)if(h[j]=!0,null==c)c=j,f=k;else{iQ(k)||(i=i.append(k.content));let a=g.mapping.map(j+d.tableStart);g.delete(a,a+k.nodeSize)}}if(null==c||null==f)return!0;if(g.setNodeMarkup(c+d.tableStart,null,{...iy(f.attrs,f.attrs.colspan,d.right-d.left-f.attrs.colspan),rowspan:d.bottom-d.top}),i.size>0){let a=c+1+f.content.size,b=iQ(f)?c+1:a;g.replaceWith(b+d.tableStart,a+d.tableStart,i)}g.setSelection(new iz(g.doc.resolve(c+d.tableStart))),b(g)}return!0}function iS(a,b){var c;let d=ip(a.schema);return(c=({node:a})=>d[a.type.spec.tableRole],(a,b)=>{let d,e,f=a.selection;if(f instanceof iz){if(f.$anchorCell.pos!=f.$headCell.pos)return!1;d=f.$anchorCell.nodeAfter,e=f.$anchorCell.pos}else{var g;if(!(d=function(a){for(let b=a.depth;b>0;b--){let c=a.node(b).type.spec.tableRole;if("cell"===c||"header_cell"===c)return a.node(b)}return null}(f.$from)))return!1;e=null==(g=ir(f.$from))?void 0:g.pos}if(null==d||null==e||1==d.attrs.colspan&&1==d.attrs.rowspan)return!1;if(b){let g,h=d.attrs,i=[],j=h.colwidth;h.rowspan>1&&(h={...h,rowspan:1}),h.colspan>1&&(h={...h,colspan:1});let k=iN(a),l=a.tr;for(let a=0;a<k.right-k.left;a++)i.push(j?{...h,colwidth:j&&j[a]?[j[a]]:null}:h);for(let a=k.top;a<k.bottom;a++){let b=k.map.positionAt(a,k.left,k.table);a==k.top&&(b+=d.nodeSize);for(let e=k.left,f=0;e<k.right;e++,f++)(e!=k.left||a!=k.top)&&l.insert(g=l.mapping.map(b+k.tableStart,1),c({node:d,row:a,col:e}).createAndFill(i[f]))}l.setNodeMarkup(e,c({node:d,row:k.top,col:k.left}),i[0]),f instanceof iz&&l.setSelection(new iz(l.doc.resolve(f.$anchorCell.pos),g?l.doc.resolve(g):void 0)),b(l)}return!0})(a,b)}function iT(a,b,c){let d=b.map.cellsInRect({left:0,top:0,right:"row"==a?b.map.width:1,bottom:"column"==a?b.map.height:1});for(let a=0;a<d.length;a++){let e=b.table.nodeAt(d[a]);if(e&&e.type!==c.header_cell)return!1}return!0}function iU(a,b){if((b=b||{useDeprecatedLogic:!1}).useDeprecatedLogic)return function(b,c){if(!is(b))return!1;if(c){let d=ip(b.schema),e=iN(b),f=b.tr,g=e.map.cellsInRect("column"==a?{left:e.left,top:0,right:e.right,bottom:e.map.height}:"row"==a?{left:0,top:e.top,right:e.map.width,bottom:e.bottom}:e),h=g.map(a=>e.table.nodeAt(a));for(let a=0;a<g.length;a++)h[a].type==d.header_cell&&f.setNodeMarkup(e.tableStart+g[a],d.cell,h[a].attrs);if(0===f.steps.length)for(let a=0;a<g.length;a++)f.setNodeMarkup(e.tableStart+g[a],d.header_cell,h[a].attrs);c(f)}return!0};return function(b,c){if(!is(b))return!1;if(c){let d=ip(b.schema),e=iN(b),f=b.tr,g=iT("row",e,d),h=iT("column",e,d),i=+("column"===a?!!g:"row"===a&&!!h),j="column"==a?{left:0,top:i,right:1,bottom:e.map.height}:"row"==a?{left:i,top:0,right:e.map.width,bottom:1}:e,k="column"==a?h?d.cell:d.header_cell:"row"==a?g?d.cell:d.header_cell:d.cell;e.map.cellsInRect(j).forEach(a=>{let b=a+e.tableStart,c=f.doc.nodeAt(b);c&&f.setNodeMarkup(b,k,c.attrs)}),c(f)}return!0}}iU("row",{useDeprecatedLogic:!0}),iU("column",{useDeprecatedLogic:!0});let iV=iU("cell",{useDeprecatedLogic:!0});function iW(a){return function(b,c){if(!is(b))return!1;let d=function(a,b){if(b<0){let b=a.nodeBefore;if(b)return a.pos-b.nodeSize;for(let b=a.index(-1)-1,c=a.before();b>=0;b--){let d=a.node(-1).child(b),e=d.lastChild;if(e)return c-1-e.nodeSize;c-=d.nodeSize}}else{if(a.index()<a.parent.childCount-1)return a.pos+a.nodeAfter.nodeSize;let b=a.node(-1);for(let c=a.indexAfter(-1),d=a.after();c<b.childCount;c++){let a=b.child(c);if(a.childCount)return d+1;d+=a.nodeSize}}return null}(it(b),a);if(null==d)return!1;if(c){let a=b.doc.resolve(d);c(b.tr.setSelection(fq.between(a,a.node(0).resolve(a.pos+a.nodeAfter.nodeSize))).scrollIntoView())}return!0}}function iX(a,b){let c=a.selection;if(!(c instanceof iz))return!1;if(b){let d=a.tr,e=ip(a.schema).cell.createAndFill().content;c.forEachCell((a,b)=>{a.content.eq(e)||d.replace(d.mapping.map(b+1),d.mapping.map(b+a.nodeSize-1),new d4(e,0,0))}),d.docChanged&&b(d)}return!0}function iY(a,b){let c=a.createAndFill();return new fk(c).replace(0,c.content.size,b).doc}function iZ(a,b,c,d,e,f,g,h){if(0==g||g==b.height)return!1;let i=!1;for(let j=e;j<f;j++){let e=g*b.width+j,f=b.map[e];if(b.map[e-b.width]==f){i=!0;let e=c.nodeAt(f),{top:k,left:l}=b.findCell(f);a.setNodeMarkup(a.mapping.slice(h).map(f+d),null,{...e.attrs,rowspan:g-k}),a.insert(a.mapping.slice(h).map(b.positionAt(g,l,c)),e.type.createAndFill({...e.attrs,rowspan:k+e.attrs.rowspan-g})),j+=e.attrs.colspan-1}}return i}function i$(a,b,c,d,e,f,g,h){if(0==g||g==b.width)return!1;let i=!1;for(let j=e;j<f;j++){let e=j*b.width+g,f=b.map[e];if(b.map[e-1]==f){i=!0;let e=c.nodeAt(f),k=b.colCount(f),l=a.mapping.slice(h).map(f+d);a.setNodeMarkup(l,null,ix(e.attrs,g-k,e.attrs.colspan-(g-k))),a.insert(l+e.nodeSize,e.type.createAndFill(ix(e.attrs,0,g-k))),j+=e.attrs.rowspan-1}}return i}function i_(a,b,c,d,e){let f=c?a.doc.nodeAt(c-1):a.doc;if(!f)throw Error("No table found");let g=io.get(f),{top:h,left:i}=d,j=i+e.width,k=h+e.height,l=a.tr,m=0;function n(){if(!(f=c?l.doc.nodeAt(c-1):l.doc))throw Error("No table found");g=io.get(f),m=l.mapping.maps.length}(function(a,b,c,d,e,f){let g,h,i=ip(a.doc.type.schema);if(e>b.width)for(let f=0,j=0;f<b.height;f++){let k,l=c.child(f);j+=l.nodeSize;let m=[];k=null==l.lastChild||l.lastChild.type==i.cell?g||(g=i.cell.createAndFill()):h||(h=i.header_cell.createAndFill());for(let a=b.width;a<e;a++)m.push(k);a.insert(a.mapping.slice(0).map(j-1+d),m)}if(f>b.height){let j=[];for(let a=0,d=(b.height-1)*b.width;a<Math.max(b.width,e);a++){let e=!(a>=b.width)&&c.nodeAt(b.map[d+a]).type==i.header_cell;j.push(e?h||(h=i.header_cell.createAndFill()):g||(g=i.cell.createAndFill()))}let k=i.row.create(null,d$.from(j)),l=[];for(let a=b.height;a<f;a++)l.push(k);a.insert(a.mapping.slice(0).map(d+c.nodeSize-2),l)}return!!(g||h)})(l,g,f,c,j,k)&&n(),iZ(l,g,f,c,i,j,h,m)&&n(),iZ(l,g,f,c,i,j,k,m)&&n(),i$(l,g,f,c,h,k,i,m)&&n(),i$(l,g,f,c,h,k,j,m)&&n();for(let a=h;a<k;a++){let b=g.positionAt(a,i,f),d=g.positionAt(a,j,f);l.replace(l.mapping.slice(m).map(b+c),l.mapping.slice(m).map(d+c),new d4(e.rows[a-h],0,0))}n(),l.setSelection(new iz(l.doc.resolve(c+g.positionAt(h,i,f)),l.doc.resolve(c+g.positionAt(k-1,j-1,f)))),b(l)}let i0=im({ArrowLeft:i2("horiz",-1),ArrowRight:i2("horiz",1),ArrowUp:i2("vert",-1),ArrowDown:i2("vert",1),"Shift-ArrowLeft":i3("horiz",-1),"Shift-ArrowRight":i3("horiz",1),"Shift-ArrowUp":i3("vert",-1),"Shift-ArrowDown":i3("vert",1),Backspace:iX,"Mod-Backspace":iX,Delete:iX,"Mod-Delete":iX});function i1(a,b,c){return!c.eq(a.selection)&&(b&&b(a.tr.setSelection(c).scrollIntoView()),!0)}function i2(a,b){return(c,d,e)=>{if(!e)return!1;let f=c.selection;if(f instanceof iz)return i1(c,d,fm.near(f.$headCell,b));if("horiz"!=a&&!f.empty)return!1;let g=i7(e,a,b);if(null==g)return!1;if("horiz"==a)return i1(c,d,fm.near(c.doc.resolve(f.head+b),b));{let e,f=c.doc.resolve(g),h=iw(f,a,b);return e=h?fm.near(h,1):b<0?fm.near(c.doc.resolve(f.before(-1)),-1):fm.near(c.doc.resolve(f.after(-1)),1),i1(c,d,e)}}}function i3(a,b){return(c,d,e)=>{let f;if(!e)return!1;let g=c.selection;if(g instanceof iz)f=g;else{let d=i7(e,a,b);if(null==d)return!1;f=new iz(c.doc.resolve(d))}let h=iw(f.$headCell,a,b);return!!h&&i1(c,d,new iz(f.$anchorCell,h))}}function i4(a,b){let c=ir(a.state.doc.resolve(b));return!!c&&(a.dispatch(a.state.tr.setSelection(new iz(c))),!0)}function i5(a,b,c){if(!is(a.state))return!1;let d=function(a){if(0===a.size)return null;let{content:b,openStart:c,openEnd:d}=a;for(;1==b.childCount&&(c>0&&d>0||"table"==b.child(0).type.spec.tableRole);)c--,d--,b=b.child(0).content;let e=b.child(0),f=e.type.spec.tableRole,g=e.type.schema,h=[];if("row"==f)for(let a=0;a<b.childCount;a++){let e=b.child(a).content,f=a?0:Math.max(0,c-1),i=a<b.childCount-1?0:Math.max(0,d-1);(f||i)&&(e=iY(ip(g).row,new d4(e,f,i)).content),h.push(e)}else{if("cell"!=f&&"header_cell"!=f)return null;h.push(c||d?iY(ip(g).row,new d4(b,c,d)).content:b)}return function(a,b){let c=[];for(let a=0;a<b.length;a++){let d=b[a];for(let b=d.childCount-1;b>=0;b--){let{rowspan:e,colspan:f}=d.child(b).attrs;for(let b=a;b<a+e;b++)c[b]=(c[b]||0)+f}}let d=0;for(let a=0;a<c.length;a++)d=Math.max(d,c[a]);for(let e=0;e<c.length;e++)if(e>=b.length&&b.push(d$.empty),c[e]<d){let f=ip(a).cell.createAndFill(),g=[];for(let a=c[e];a<d;a++)g.push(f);b[e]=b[e].append(d$.from(g))}return{height:b.length,width:d,rows:b}}(g,h)}(c),e=a.state.selection;if(e instanceof iz){d||(d={width:1,height:1,rows:[d$.from(iY(ip(a.state.schema).cell,c))]});let b=e.$anchorCell.node(-1),f=e.$anchorCell.start(-1),g=io.get(b).rectBetween(e.$anchorCell.pos-f,e.$headCell.pos-f);return d=function({width:a,height:b,rows:c},d,e){if(a!=d){let b=[],e=[];for(let a=0;a<c.length;a++){let f=c[a],g=[];for(let c=b[a]||0,e=0;c<d;e++){let h=f.child(e%f.childCount);c+h.attrs.colspan>d&&(h=h.type.createChecked(ix(h.attrs,h.attrs.colspan,c+h.attrs.colspan-d),h.content)),g.push(h),c+=h.attrs.colspan;for(let c=1;c<h.attrs.rowspan;c++)b[a+c]=(b[a+c]||0)+h.attrs.colspan}e.push(d$.from(g))}c=e,a=d}if(b!=e){let a=[];for(let d=0,f=0;d<e;d++,f++){let g=[],h=c[f%b];for(let a=0;a<h.childCount;a++){let b=h.child(a);d+b.attrs.rowspan>e&&(b=b.type.create({...b.attrs,rowspan:Math.max(1,e-b.attrs.rowspan)},b.content)),g.push(b)}a.push(d$.from(g))}c=a,b=e}return{width:a,height:b,rows:c}}(d,g.right-g.left,g.bottom-g.top),i_(a.state,a.dispatch,f,g,d),!0}if(!d)return!1;{let b=it(a.state),c=b.start(-1);return i_(a.state,a.dispatch,c,io.get(b.node(-1)).findCell(b.pos-c),d),!0}}function i6(a,b){var c;let d;if(0!=b.button||b.ctrlKey||b.metaKey)return;let e=i8(a,b.target);if(b.shiftKey&&a.state.selection instanceof iz)f(a.state.selection.$anchorCell,b),b.preventDefault();else if(b.shiftKey&&e&&null!=(d=ir(a.state.selection.$anchor))&&(null==(c=i9(a,b))?void 0:c.pos)!=d.pos)f(d,b),b.preventDefault();else if(!e)return;function f(b,c){let d=i9(a,c),e=null==iq.getState(a.state);if(!d||!iv(b,d))if(!e)return;else d=b;let f=new iz(b,d);if(e||!a.state.selection.eq(f)){let c=a.state.tr.setSelection(f);e&&c.setMeta(iq,b.pos),a.dispatch(c)}}function g(){a.root.removeEventListener("mouseup",g),a.root.removeEventListener("dragstart",g),a.root.removeEventListener("mousemove",h),null!=iq.getState(a.state)&&a.dispatch(a.state.tr.setMeta(iq,-1))}function h(c){let d,h=iq.getState(a.state);if(null!=h)d=a.state.doc.resolve(h);else if(i8(a,c.target)!=e&&!(d=i9(a,b)))return g();d&&f(d,c)}a.root.addEventListener("mouseup",g),a.root.addEventListener("dragstart",g),a.root.addEventListener("mousemove",h)}function i7(a,b,c){if(!(a.state.selection instanceof fq))return null;let{$head:d}=a.state.selection;for(let e=d.depth-1;e>=0;e--){let f=d.node(e);if((c<0?d.index(e):d.indexAfter(e))!=(c<0?0:f.childCount))break;if("cell"==f.type.spec.tableRole||"header_cell"==f.type.spec.tableRole){let f=d.before(e),g="vert"==b?c>0?"down":"up":c>0?"right":"left";return a.endOfTextblock(g)?f:null}}return null}function i8(a,b){for(;b&&b!=a.dom;b=b.parentNode)if("TD"==b.nodeName||"TH"==b.nodeName)return b;return null}function i9(a,b){let c=a.posAtCoords({left:b.clientX,top:b.clientY});if(!c)return null;let{inside:d,pos:e}=c;return d>=0&&ir(a.state.doc.resolve(d))||ir(a.state.doc.resolve(e))}var ja=class{constructor(a,b){this.node=a,this.defaultCellMinWidth=b,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${b}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),jb(a,this.colgroup,this.table,b),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(a){return a.type==this.node.type&&(this.node=a,jb(a,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(a){return"attributes"==a.type&&(a.target==this.table||this.colgroup.contains(a.target))}};function jb(a,b,c,d,e,f){let g=0,h=!0,i=b.firstChild,j=a.firstChild;if(j){for(let a=0,c=0;a<j.childCount;a++){let{colspan:k,colwidth:l}=j.child(a).attrs;for(let a=0;a<k;a++,c++){let j=e==c?f:l&&l[a],k=j?j+"px":"";if(g+=j||d,j||(h=!1),i)i.style.width!=k&&(i.style.width=k),i=i.nextSibling;else{let a=document.createElement("col");a.style.width=k,b.appendChild(a)}}}for(;i;){var k;let a=i.nextSibling;null==(k=i.parentNode)||k.removeChild(i),i=a}h?(c.style.width=g+"px",c.style.minWidth=""):(c.style.width="",c.style.minWidth=g+"px")}}let jc=new fH("tableColumnResizing");var jd=class a{constructor(a,b){this.activeHandle=a,this.dragging=b}apply(b){let c=b.getMeta(jc);if(c&&null!=c.setHandle)return new a(c.setHandle,!1);if(c&&void 0!==c.setDragging)return new a(this.activeHandle,c.setDragging);if(this.activeHandle>-1&&b.docChanged){let c=b.mapping.map(this.activeHandle,-1);return iu(b.doc.resolve(c))||(c=-1),new a(c,this.dragging)}return this}};function je(a,b,c,d){let e=a.posAtCoords({left:b.clientX+("right"==c?-d:d),top:b.clientY});if(!e)return -1;let{pos:f}=e,g=ir(a.state.doc.resolve(f));if(!g)return -1;if("right"==c)return g.pos;let h=io.get(g.node(-1)),i=g.start(-1),j=h.map.indexOf(g.pos-i);return j%h.width==0?-1:i+h.map[j-1]}function jf(a,b,c){let d=b.clientX-a.startX;return Math.max(c,a.startWidth+d)}function jg(a,b){a.dispatch(a.state.tr.setMeta(jc,{setHandle:b}))}function jh(a,b,c,d){let e=a.state.doc.resolve(b),f=e.node(-1),g=e.start(-1),h=io.get(f).colCount(e.pos-g)+e.nodeAfter.attrs.colspan-1,i=a.domAtPos(e.start(-1)).node;for(;i&&"TABLE"!=i.nodeName;)i=i.parentNode;i&&jb(f,i.firstChild,i,d,h,c)}var ji=p,jj=a.i(985209);let jk=(a,b)=>!a.selection.empty&&(b&&b(a.tr.deleteSelection().scrollIntoView()),!0);function jl(a,b){let{$cursor:c}=a.selection;return c&&(b?b.endOfTextblock("backward",a):!(c.parentOffset>0))?c:null}let jm=(a,b,c)=>{let d=jl(a,c);if(!d)return!1;let e=jq(d);if(!e){let c=d.blockRange(),e=c&&e_(c);return null!=e&&(b&&b(a.tr.lift(c,e).scrollIntoView()),!0)}let f=e.nodeBefore;if(jA(a,e,b,-1))return!0;if(0==d.parent.content.size&&(jo(f,"end")||fs.isSelectable(f)))for(let c=d.depth;;c--){let g=e9(a.doc,d.before(c),d.after(c),d4.empty);if(g&&g.slice.size<g.to-g.from){if(b){let c=a.tr.step(g);c.setSelection(jo(f,"end")?fm.findFrom(c.doc.resolve(c.mapping.map(e.pos,-1)),-1):fs.create(c.doc,e.pos-f.nodeSize)),b(c.scrollIntoView())}return!0}if(1==c||d.node(c-1).childCount>1)break}return!!f.isAtom&&e.depth==d.depth-1&&(b&&b(a.tr.delete(e.pos-f.nodeSize,e.pos).scrollIntoView()),!0)};function jn(a,b,c){let d=b.nodeBefore,e=b.pos-1;for(;!d.isTextblock;e--){if(d.type.spec.isolating)return!1;let a=d.lastChild;if(!a)return!1;d=a}let f=b.nodeAfter,g=b.pos+1;for(;!f.isTextblock;g++){if(f.type.spec.isolating)return!1;let a=f.firstChild;if(!a)return!1;f=a}let h=e9(a.doc,e,g,d4.empty);if(!h||h.from!=e||h instanceof eX&&h.slice.size>=g-e)return!1;if(c){let b=a.tr.step(h);b.setSelection(fq.create(b.doc,e)),c(b.scrollIntoView())}return!0}function jo(a,b,c=!1){for(let d=a;d;d="start"==b?d.firstChild:d.lastChild){if(d.isTextblock)return!0;if(c&&1!=d.childCount)break}return!1}let jp=(a,b,c)=>{let{$head:d,empty:e}=a.selection,f=d;if(!e)return!1;if(d.parent.isTextblock){if(c?!c.endOfTextblock("backward",a):d.parentOffset>0)return!1;f=jq(d)}let g=f&&f.nodeBefore;return!!g&&!!fs.isSelectable(g)&&(b&&b(a.tr.setSelection(fs.create(a.doc,f.pos-g.nodeSize)).scrollIntoView()),!0)};function jq(a){if(!a.parent.type.spec.isolating)for(let b=a.depth-1;b>=0;b--){if(a.index(b)>0)return a.doc.resolve(a.before(b+1));if(a.node(b).type.spec.isolating)break}return null}function jr(a,b){let{$cursor:c}=a.selection;return c&&(b?b.endOfTextblock("forward",a):!(c.parentOffset<c.parent.content.size))?c:null}let js=(a,b,c)=>{let d=jr(a,c);if(!d)return!1;let e=ju(d);if(!e)return!1;let f=e.nodeAfter;if(jA(a,e,b,1))return!0;if(0==d.parent.content.size&&(jo(f,"start")||fs.isSelectable(f))){let c=e9(a.doc,d.before(),d.after(),d4.empty);if(c&&c.slice.size<c.to-c.from){if(b){let d=a.tr.step(c);d.setSelection(jo(f,"start")?fm.findFrom(d.doc.resolve(d.mapping.map(e.pos)),1):fs.create(d.doc,d.mapping.map(e.pos))),b(d.scrollIntoView())}return!0}}return!!f.isAtom&&e.depth==d.depth-1&&(b&&b(a.tr.delete(e.pos,e.pos+f.nodeSize).scrollIntoView()),!0)},jt=(a,b,c)=>{let{$head:d,empty:e}=a.selection,f=d;if(!e)return!1;if(d.parent.isTextblock){if(c?!c.endOfTextblock("forward",a):d.parentOffset<d.parent.content.size)return!1;f=ju(d)}let g=f&&f.nodeAfter;return!!g&&!!fs.isSelectable(g)&&(b&&b(a.tr.setSelection(fs.create(a.doc,f.pos)).scrollIntoView()),!0)};function ju(a){if(!a.parent.type.spec.isolating)for(let b=a.depth-1;b>=0;b--){let c=a.node(b);if(a.index(b)+1<c.childCount)return a.doc.resolve(a.after(b+1));if(c.type.spec.isolating)break}return null}let jv=(a,b)=>{let{$head:c,$anchor:d}=a.selection;return!!c.parent.type.spec.code&&!!c.sameParent(d)&&(b&&b(a.tr.insertText("\n").scrollIntoView()),!0)};function jw(a){for(let b=0;b<a.edgeCount;b++){let{type:c}=a.edge(b);if(c.isTextblock&&!c.hasRequiredAttrs())return c}return null}let jx=(a,b)=>{let{$head:c,$anchor:d}=a.selection;if(!c.parent.type.spec.code||!c.sameParent(d))return!1;let e=c.node(-1),f=c.indexAfter(-1),g=jw(e.contentMatchAt(f));if(!g||!e.canReplaceWith(f,f,g))return!1;if(b){let d=c.after(),e=a.tr.replaceWith(d,d,g.createAndFill());e.setSelection(fm.near(e.doc.resolve(d),1)),b(e.scrollIntoView())}return!0},jy=(a,b)=>{let c=a.selection,{$from:d,$to:e}=c;if(c instanceof fu||d.parent.inlineContent||e.parent.inlineContent)return!1;let f=jw(e.parent.contentMatchAt(e.indexAfter()));if(!f||!f.isTextblock)return!1;if(b){let c=(!d.parentOffset&&e.index()<e.parent.childCount?d:e).pos,g=a.tr.insert(c,f.createAndFill());g.setSelection(fq.create(g.doc,c+1)),b(g.scrollIntoView())}return!0},jz=(a,b)=>{let{$cursor:c}=a.selection;if(!c||c.parent.content.size)return!1;if(c.depth>1&&c.after()!=c.end(-1)){let d=c.before();if(e4(a.doc,d))return b&&b(a.tr.split(d).scrollIntoView()),!0}let d=c.blockRange(),e=d&&e_(d);return null!=e&&(b&&b(a.tr.lift(d,e).scrollIntoView()),!0)};function jA(a,b,c,d){let e,f,g,h=b.nodeBefore,i=b.nodeAfter,j,k,l=h.type.spec.isolating||i.type.spec.isolating;if(!l&&(e=b.nodeBefore,f=b.nodeAfter,g=b.index(),e&&f&&e.type.compatibleContent(f.type)&&(!e.content.size&&b.parent.canReplace(g-1,g)?(c&&c(a.tr.delete(b.pos-e.nodeSize,b.pos).scrollIntoView()),!0):!!b.parent.canReplace(g,g+1)&&!!(f.isTextblock||e5(a.doc,b.pos))&&(c&&c(a.tr.join(b.pos).scrollIntoView()),!0))))return!0;let m=!l&&b.parent.canReplace(b.index(),b.index()+1);if(m&&(j=(k=h.contentMatchAt(h.childCount)).findWrapping(i.type))&&k.matchType(j[0]||i.type).validEnd){if(c){let d=b.pos+i.nodeSize,e=d$.empty;for(let a=j.length-1;a>=0;a--)e=d$.from(j[a].create(null,e));e=d$.from(h.copy(e));let f=a.tr.step(new eY(b.pos-1,d,b.pos,d,new d4(e,1,0),j.length,!0)),g=f.doc.resolve(d+2*j.length);g.nodeAfter&&g.nodeAfter.type==h.type&&e5(f.doc,g.pos)&&f.join(g.pos),c(f.scrollIntoView())}return!0}let n=i.type.spec.isolating||d>0&&l?null:fm.findFrom(b,1),o=n&&n.$from.blockRange(n.$to),p=o&&e_(o);if(null!=p&&p>=b.depth)return c&&c(a.tr.lift(o,p).scrollIntoView()),!0;if(m&&jo(i,"start",!0)&&jo(h,"end")){let d=h,e=[];for(;e.push(d),!d.isTextblock;)d=d.lastChild;let f=i,g=1;for(;!f.isTextblock;f=f.firstChild)g++;if(d.canReplace(d.childCount,d.childCount,f.content)){if(c){let d=d$.empty;for(let a=e.length-1;a>=0;a--)d=d$.from(e[a].copy(d));c(a.tr.step(new eY(b.pos-e.length,b.pos+i.nodeSize,b.pos+g,b.pos+i.nodeSize-g,new d4(d,e.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function jB(a){return function(b,c){let d=b.selection,e=a<0?d.$from:d.$to,f=e.depth;for(;e.node(f).isInline;){if(!f)return!1;f--}return!!e.node(f).isTextblock&&(c&&c(b.tr.setSelection(fq.create(b.doc,a<0?e.start(f):e.end(f)))),!0)}}let jC=jB(-1),jD=jB(1);function jE(a,b=null){return function(c,d){let e=!1;for(let d=0;d<c.selection.ranges.length&&!e;d++){let{$from:{pos:f},$to:{pos:g}}=c.selection.ranges[d];c.doc.nodesBetween(f,g,(d,f)=>{if(e)return!1;if(!(!d.isTextblock||d.hasMarkup(a,b)))if(d.type==a)e=!0;else{let b=c.doc.resolve(f),d=b.index();e=b.parent.canReplaceWith(d,d+1,a)}})}if(!e)return!1;if(d){let e=c.tr;for(let d=0;d<c.selection.ranges.length;d++){let{$from:{pos:f},$to:{pos:g}}=c.selection.ranges[d];e.setBlockType(f,g,a,b)}d(e.scrollIntoView())}return!0}}function jF(...a){return function(b,c,d){for(let e=0;e<a.length;e++)if(a[e](b,c,d))return!0;return!1}}let jG=jF(jk,jm,jp),jH=jF(jk,js,jt),jI={Enter:jF(jv,jy,jz,(a,b)=>{let{$from:c,$to:d}=a.selection;if(a.selection instanceof fs&&a.selection.node.isBlock)return!!c.parentOffset&&!!e4(a.doc,c.pos)&&(b&&b(a.tr.split(c.pos).scrollIntoView()),!0);if(!c.depth)return!1;let e=[],f,g,h=!1,i=!1;for(let a=c.depth;;a--){if(c.node(a).isBlock){let b;h=c.end(a)==c.pos+(c.depth-a),i=c.start(a)==c.pos-(c.depth-a),g=jw(c.node(a-1).contentMatchAt(c.indexAfter(a-1)));e.unshift(b||(h&&g?{type:g}:null)),f=a;break}if(1==a)return!1;e.unshift(null)}let j=a.tr;(a.selection instanceof fq||a.selection instanceof fu)&&j.deleteSelection();let k=j.mapping.map(c.pos),l=e4(j.doc,k,e.length,e);if(l||(e[0]=g?{type:g}:null,l=e4(j.doc,k,e.length,e)),!l)return!1;if(j.split(k,e.length,e),!h&&i&&c.node(f).type!=g){let a=j.mapping.map(c.before(f)),b=j.doc.resolve(a);g&&c.node(f-1).canReplaceWith(b.index(),b.index()+1,g)&&j.setNodeMarkup(j.mapping.map(c.before(f)),g)}return b&&b(j.scrollIntoView()),!0}),"Mod-Enter":jx,Backspace:jG,"Mod-Backspace":jG,"Shift-Backspace":jG,Delete:jH,"Mod-Delete":jH,"Mod-a":(a,b)=>(b&&b(a.tr.setSelection(new fu(a.doc))),!0)},jJ={"Ctrl-h":jI.Backspace,"Alt-Backspace":jI["Mod-Backspace"],"Ctrl-d":jI.Delete,"Ctrl-Alt-Backspace":jI["Mod-Delete"],"Alt-Delete":jI["Mod-Delete"],"Alt-d":jI["Mod-Delete"],"Ctrl-a":jC,"Ctrl-e":jD};for(let a in jI)jJ[a]=jI[a];"u">typeof navigator?/Mac|iP(hone|[oa]d)/.test(navigator.platform):"u">typeof os&&os.platform&&os.platform();var jK=Object.defineProperty,jL=(a,b)=>{for(var c in b)jK(a,c,{get:b[c],enumerable:!0})};function jM(a){let{state:b,transaction:c}=a,{selection:d}=c,{doc:e}=c,{storedMarks:f}=c;return{...b,apply:b.apply.bind(b),applyTransaction:b.applyTransaction.bind(b),plugins:b.plugins,schema:b.schema,reconfigure:b.reconfigure.bind(b),toJSON:b.toJSON.bind(b),get storedMarks(){return f},get selection(){return d},get doc(){return e},get tr(){return d=c.selection,e=c.doc,f=c.storedMarks,c}}}var jN=class{constructor(a){this.editor=a.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=a.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){let{rawCommands:a,editor:b,state:c}=this,{view:d}=b,{tr:e}=c,f=this.buildProps(e);return Object.fromEntries(Object.entries(a).map(([a,b])=>[a,(...a)=>{let c=b(...a)(f);return e.getMeta("preventDispatch")||this.hasCustomState||d.dispatch(e),c}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(a,b=!0){let{rawCommands:c,editor:d,state:e}=this,{view:f}=d,g=[],h=!!a,i=a||e.tr,j=()=>(h||!b||i.getMeta("preventDispatch")||this.hasCustomState||f.dispatch(i),g.every(a=>!0===a)),k={...Object.fromEntries(Object.entries(c).map(([a,c])=>[a,(...a)=>{let d=this.buildProps(i,b),e=c(...a)(d);return g.push(e),k}])),run:j};return k}createCan(a){let{rawCommands:b,state:c}=this,d=a||c.tr,e=this.buildProps(d,!1);return{...Object.fromEntries(Object.entries(b).map(([a,b])=>[a,(...a)=>b(...a)({...e,dispatch:void 0})])),chain:()=>this.createChain(d,!1)}}buildProps(a,b=!0){let{rawCommands:c,editor:d,state:e}=this,{view:f}=d,g={tr:a,editor:d,view:f,state:jM({state:e,transaction:a}),dispatch:b?()=>void 0:void 0,chain:()=>this.createChain(a,b),can:()=>this.createCan(a),get commands(){return Object.fromEntries(Object.entries(c).map(([a,b])=>[a,(...a)=>b(...a)(g)]))}};return g}},jO={};jL(jO,{blur:()=>jP,clearContent:()=>jQ,clearNodes:()=>jR,command:()=>jS,createParagraphNear:()=>jT,cut:()=>jU,deleteCurrentNode:()=>jV,deleteNode:()=>jX,deleteRange:()=>jY,deleteSelection:()=>j$,enter:()=>j_,exitCode:()=>j0,extendMarkRange:()=>j7,first:()=>j8,focus:()=>ke,forEach:()=>kf,insertContent:()=>kg,insertContentAt:()=>kj,joinBackward:()=>km,joinDown:()=>kl,joinForward:()=>kn,joinItemBackward:()=>ko,joinItemForward:()=>kp,joinTextblockBackward:()=>kq,joinTextblockForward:()=>kr,joinUp:()=>kk,keyboardShortcut:()=>kt,lift:()=>kv,liftEmptyBlock:()=>kw,liftListItem:()=>kx,newlineInCode:()=>ky,resetAttributes:()=>kB,scrollIntoView:()=>kC,selectAll:()=>kD,selectNodeBackward:()=>kE,selectNodeForward:()=>kF,selectParentNode:()=>kG,selectTextblockEnd:()=>kH,selectTextblockStart:()=>kI,setContent:()=>kK,setMark:()=>lk,setMeta:()=>ll,setNode:()=>lm,setNodeSelection:()=>ln,setTextDirection:()=>lo,setTextSelection:()=>lp,sinkListItem:()=>lq,splitBlock:()=>ls,splitListItem:()=>lt,toggleList:()=>lw,toggleMark:()=>lx,toggleNode:()=>ly,toggleWrap:()=>lz,undoInputRule:()=>lA,unsetAllMarks:()=>lB,unsetMark:()=>lC,unsetTextDirection:()=>lD,updateAttributes:()=>lE,wrapIn:()=>lF,wrapInList:()=>lG});var jP=()=>({editor:a,view:b})=>(requestAnimationFrame(()=>{var c;a.isDestroyed||(b.dom.blur(),null==(c=null==window?void 0:window.getSelection())||c.removeAllRanges())}),!0),jQ=(a=!0)=>({commands:b})=>b.setContent("",{emitUpdate:a}),jR=()=>({state:a,tr:b,dispatch:c})=>{let{selection:d}=b,{ranges:e}=d;return!c||(e.forEach(({$from:c,$to:d})=>{a.doc.nodesBetween(c.pos,d.pos,(a,c)=>{if(a.type.isText)return;let{doc:d,mapping:e}=b,f=d.resolve(e.map(c)),g=d.resolve(e.map(c+a.nodeSize)),h=f.blockRange(g);if(!h)return;let i=e_(h);if(a.type.isTextblock){let{defaultType:a}=f.parent.contentMatchAt(f.index());b.setNodeMarkup(h.start,a)}(i||0===i)&&b.lift(h,i)})}),!0)},jS=a=>b=>a(b),jT=()=>({state:a,dispatch:b})=>jy(a,b),jU=(a,b)=>({editor:c,tr:d})=>{let{state:e}=c,f=e.doc.slice(a.from,a.to);d.deleteRange(a.from,a.to);let g=d.mapping.map(b);return d.insert(g,f.content),d.setSelection(new fq(d.doc.resolve(Math.max(g-1,0)))),!0},jV=()=>({tr:a,dispatch:b})=>{let{selection:c}=a,d=c.$anchor.node();if(d.content.size>0)return!1;let e=a.selection.$anchor;for(let c=e.depth;c>0;c-=1)if(e.node(c).type===d.type){if(b){let b=e.before(c),d=e.after(c);a.delete(b,d).scrollIntoView()}return!0}return!1};function jW(a,b){if("string"==typeof a){if(!b.nodes[a])throw Error(`There is no node type named '${a}'. Maybe you forgot to add the extension?`);return b.nodes[a]}return a}var jX=a=>({tr:b,state:c,dispatch:d})=>{let e=jW(a,c.schema),f=b.selection.$anchor;for(let a=f.depth;a>0;a-=1)if(f.node(a).type===e){if(d){let c=f.before(a),d=f.after(a);b.delete(c,d).scrollIntoView()}return!0}return!1},jY=a=>({tr:b,dispatch:c})=>{let{from:d,to:e}=a;return c&&b.delete(d,e),!0},jZ=(a,b,c)=>{var d;return!a.parent.isInline||"left"===c&&a.pos>a.start()||"right"===c&&a.pos<a.end()?a.pos:(d=b.nodes[a.parent.type.name].spec).content&&/^text(\*|\+)/.test(d.content)?"left"===c?a.start()-1:a.end()+1:a.pos},j$=()=>({state:a,dispatch:b})=>{var c;let{$from:d,$to:e}=a.selection;if(a.selection.empty)return!1;let{from:f,to:g}={from:jZ(d,c=a.schema,"left"),to:jZ(e,c,"right")};return b&&(a.tr.deleteRange(f,g).scrollIntoView(),b(a.tr)),!0},j_=()=>({commands:a})=>a.keyboardShortcut("Enter"),j0=()=>({state:a,dispatch:b})=>jx(a,b);function j1(a){return"[object RegExp]"===Object.prototype.toString.call(a)}function j2(a,b,c={strict:!0}){let d=Object.keys(b);return!d.length||d.every(d=>c.strict?b[d]===a[d]:j1(b[d])?b[d].test(a[d]):b[d]===a[d])}function j3(a,b,c={}){return a.find(a=>a.type===b&&j2(Object.fromEntries(Object.keys(c).map(b=>[b,a.attrs[b]])),c))}function j4(a,b,c={}){return!!j3(a,b,c)}function j5(a,b,c){if(!a||!b)return;let d=a.parent.childAfter(a.parentOffset);if(d.node&&d.node.marks.some(a=>a.type===b)||(d=a.parent.childBefore(a.parentOffset)),!d.node||!d.node.marks.some(a=>a.type===b))return;if(!c){let a=d.node.marks.find(a=>a.type===b);a&&(c=a.attrs)}if(!j3([...d.node.marks],b,c))return;let e=d.index,f=a.start()+d.offset,g=e+1,h=f+d.node.nodeSize;for(;e>0&&j4([...a.parent.child(e-1).marks],b,c);)e-=1,f-=a.parent.child(e).nodeSize;for(;g<a.parent.childCount&&j4([...a.parent.child(g).marks],b,c);)h+=a.parent.child(g).nodeSize,g+=1;return{from:f,to:h}}function j6(a,b){if("string"==typeof a){if(!b.marks[a])throw Error(`There is no mark type named '${a}'. Maybe you forgot to add the extension?`);return b.marks[a]}return a}var j7=(a,b)=>({tr:c,state:d,dispatch:e})=>{let f=j6(a,d.schema),{doc:g,selection:h}=c,{$from:i,from:j,to:k}=h;if(e){let a=j5(i,f,b);if(a&&a.from<=j&&a.to>=k){let b=fq.create(g,a.from,a.to);c.setSelection(b)}}return!0},j8=a=>b=>{let c="function"==typeof a?a(b):a;for(let a=0;a<c.length;a+=1)if(c[a](b))return!0;return!1};function j9(a){return a instanceof fq}function ka(a=0,b=0,c=0){return Math.min(Math.max(a,b),c)}function kb(a,b=null){if(!b)return null;let c=fm.atStart(a),d=fm.atEnd(a);if("start"===b||!0===b)return c;if("end"===b)return d;let e=c.from,f=d.to;return"all"===b?fq.create(a,ka(0,e,f),ka(a.content.size,e,f)):fq.create(a,ka(b,e,f),ka(b,e,f))}function kc(){return"Android"===navigator.platform||/android/i.test(navigator.userAgent)}function kd(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}var ke=(a=null,b={})=>({editor:c,view:d,tr:e,dispatch:f})=>{b={scrollIntoView:!0,...b};let g=()=>{(kd()||kc())&&d.dom.focus(),"u">typeof navigator&&/^((?!chrome|android).)*safari/i.test(navigator.userAgent)&&!kd()&&!kc()&&d.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{!c.isDestroyed&&(d.focus(),(null==b?void 0:b.scrollIntoView)&&c.commands.scrollIntoView())})};try{if(d.hasFocus()&&null===a||!1===a)return!0}catch{return!1}if(f&&null===a&&!j9(c.state.selection))return g(),!0;let h=kb(e.doc,a)||c.state.selection,i=c.state.selection.eq(h);return f&&(i||e.setSelection(h),i&&e.storedMarks&&e.setStoredMarks(e.storedMarks),g()),!0},kf=(a,b)=>c=>a.every((a,d)=>b(a,{...c,index:d})),kg=(a,b)=>({tr:c,commands:d})=>d.insertContentAt({from:c.selection.from,to:c.selection.to},a,b);function kh(a){throw Error("[tiptap error]: there is no window object available, so this function cannot be used")}function ki(a,b,c){if(a instanceof eh||a instanceof d$)return a;c={slice:!0,parseOptions:{},...c};let d="object"==typeof a&&null!==a,e="string"==typeof a;if(d)try{if(Array.isArray(a)&&a.length>0)return d$.fromArray(a.map(a=>b.nodeFromJSON(a)));let d=b.nodeFromJSON(a);return c.errorOnInvalidContent&&d.check(),d}catch(d){if(c.errorOnInvalidContent)throw Error("[tiptap error]: Invalid JSON content",{cause:d});return console.warn("[tiptap warn]: Invalid content.","Passed value:",a,"Error:",d),ki("",b,c)}if(e){if(c.errorOnInvalidContent){let d=!1,e="",f=new ew({topNode:b.spec.topNode,marks:b.spec.marks,nodes:b.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:a=>(d=!0,e="string"==typeof a?a:a.outerHTML,null)}]}})});if(c.slice?ey.fromSchema(f).parseSlice(kh(a),c.parseOptions):ey.fromSchema(f).parse(kh(a),c.parseOptions),c.errorOnInvalidContent&&d)throw Error("[tiptap error]: Invalid HTML content",{cause:Error(`Invalid element found: ${e}`)})}let d=ey.fromSchema(b);return c.slice?d.parseSlice(kh(a),c.parseOptions).content:d.parse(kh(a),c.parseOptions)}return ki("",b,c)}var kj=(a,b,c)=>({tr:d,dispatch:e,editor:f})=>{var g;if(e){let e,h;c={parseOptions:f.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...c};let i=a=>{f.emit("contentError",{editor:f,error:a,disableCollaboration:()=>{"collaboration"in f.storage&&"object"==typeof f.storage.collaboration&&f.storage.collaboration&&(f.storage.collaboration.isDisabled=!0)}})},j={preserveWhitespace:"full",...c.parseOptions};if(!c.errorOnInvalidContent&&!f.options.enableContentCheck&&f.options.emitContentError)try{ki(b,f.schema,{parseOptions:j,errorOnInvalidContent:!0})}catch(a){i(a)}try{e=ki(b,f.schema,{parseOptions:j,errorOnInvalidContent:null!=(g=c.errorOnInvalidContent)?g:f.options.enableContentCheck})}catch(a){return i(a),!1}let{from:k,to:l}="number"==typeof a?{from:a,to:a}:{from:a.from,to:a.to},m=!0,n=!0;if((!("type"in e)?e:[e]).forEach(a=>{a.check(),m=!!m&&a.isText&&0===a.marks.length,n=!!n&&a.isBlock}),k===l&&n){let{parent:a}=d.doc.resolve(k);!a.isTextblock||a.type.spec.code||a.childCount||(k-=1,l+=1)}if(m){if(Array.isArray(b))h=b.map(a=>a.text||"").join("");else if(b instanceof d$){let a="";b.forEach(b=>{b.text&&(a+=b.text)}),h=a}else h="object"==typeof b&&b&&b.text?b.text:b;d.insertText(h,k,l)}else{h=e;let a=d.doc.resolve(k),b=a.node(),c=0===a.parentOffset,f=b.isText||b.isTextblock,g=b.content.size>0;c&&f&&g&&n&&(k=Math.max(0,k-1)),d.replaceWith(k,l,h)}c.updateSelection&&function(a,b){let c=a.steps.length-1;if(c<b)return;let d=a.steps[c];if(!(d instanceof eX||d instanceof eY))return;let e=a.mapping.maps[c],f=0;e.forEach((a,b,c,d)=>{0===f&&(f=d)}),a.setSelection(fm.near(a.doc.resolve(f),-1))}(d,d.steps.length-1),c.applyInputRules&&d.setMeta("applyInputRules",{from:k,text:h}),c.applyPasteRules&&d.setMeta("applyPasteRules",{from:k,text:h})}return!0},kk=()=>({state:a,dispatch:b})=>((a,b)=>{let c=a.selection,d=c instanceof fs,e;if(d){if(c.node.isTextblock||!e5(a.doc,c.from))return!1;e=c.from}else if(null==(e=e7(a.doc,c.from,-1)))return!1;if(b){let c=a.tr.join(e);d&&c.setSelection(fs.create(c.doc,e-a.doc.resolve(e).nodeBefore.nodeSize)),b(c.scrollIntoView())}return!0})(a,b),kl=()=>({state:a,dispatch:b})=>((a,b)=>{let c=a.selection,d;if(c instanceof fs){if(c.node.isTextblock||!e5(a.doc,c.to))return!1;d=c.to}else if(null==(d=e7(a.doc,c.to,1)))return!1;return b&&b(a.tr.join(d).scrollIntoView()),!0})(a,b),km=()=>({state:a,dispatch:b})=>jm(a,b),kn=()=>({state:a,dispatch:b})=>js(a,b),ko=()=>({state:a,dispatch:b,tr:c})=>{try{let d=e7(a.doc,a.selection.$from.pos,-1);if(null==d)return!1;return c.join(d,2),b&&b(c),!0}catch{return!1}},kp=()=>({state:a,dispatch:b,tr:c})=>{try{let d=e7(a.doc,a.selection.$from.pos,1);if(null==d)return!1;return c.join(d,2),b&&b(c),!0}catch{return!1}},kq=()=>({state:a,dispatch:b})=>((a,b,c)=>{let d=jl(a,c);if(!d)return!1;let e=jq(d);return!!e&&jn(a,e,b)})(a,b),kr=()=>({state:a,dispatch:b})=>((a,b,c)=>{let d=jr(a,c);if(!d)return!1;let e=ju(d);return!!e&&jn(a,e,b)})(a,b);function ks(){return"u">typeof navigator&&/Mac/.test(navigator.platform)}var kt=a=>({editor:b,view:c,tr:d,dispatch:e})=>{let f=(function(a){let b,c,d,e,f=a.split(/-(?!$)/),g=f[f.length-1];"Space"===g&&(g=" ");for(let a=0;a<f.length-1;a+=1){let g=f[a];if(/^(cmd|meta|m)$/i.test(g))e=!0;else if(/^a(lt)?$/i.test(g))b=!0;else if(/^(c|ctrl|control)$/i.test(g))c=!0;else if(/^s(hift)?$/i.test(g))d=!0;else if(/^mod$/i.test(g))kd()||ks()?e=!0:c=!0;else throw Error(`Unrecognized modifier name: ${g}`)}return b&&(g=`Alt-${g}`),c&&(g=`Ctrl-${g}`),e&&(g=`Meta-${g}`),d&&(g=`Shift-${g}`),g})(a).split(/-(?!$)/),g=f.find(a=>!["Alt","Ctrl","Meta","Shift"].includes(a)),h=new KeyboardEvent("keydown",{key:"Space"===g?" ":g,altKey:f.includes("Alt"),ctrlKey:f.includes("Ctrl"),metaKey:f.includes("Meta"),shiftKey:f.includes("Shift"),bubbles:!0,cancelable:!0}),i=b.captureTransaction(()=>{c.someProp("handleKeyDown",a=>a(c,h))});return null==i||i.steps.forEach(a=>{let b=a.map(d.mapping);b&&e&&d.maybeStep(b)}),!0};function ku(a,b,c={}){let{from:d,to:e,empty:f}=a.selection,g=b?jW(b,a.schema):null,h=[];a.doc.nodesBetween(d,e,(a,b)=>{if(a.isText)return;let c=Math.max(d,b),f=Math.min(e,b+a.nodeSize);h.push({node:a,from:c,to:f})});let i=e-d,j=h.filter(a=>!g||g.name===a.node.type.name).filter(a=>j2(a.node.attrs,c,{strict:!1}));return f?!!j.length:j.reduce((a,b)=>a+b.to-b.from,0)>=i}var kv=(a,b={})=>({state:c,dispatch:d})=>{let e=jW(a,c.schema);return!!ku(c,e,b)&&((a,b)=>{let{$from:c,$to:d}=a.selection,e=c.blockRange(d),f=e&&e_(e);return null!=f&&(b&&b(a.tr.lift(e,f).scrollIntoView()),!0)})(c,d)},kw=()=>({state:a,dispatch:b})=>jz(a,b),kx=a=>({state:b,dispatch:c})=>{var d;return(d=jW(a,b.schema),function(a,b){let{$from:c,$to:e}=a.selection,f=c.blockRange(e,a=>a.childCount>0&&a.firstChild.type==d);return!!f&&(!b||(c.node(f.depth-1).type==d?function(a,b,c,d){let e=a.tr,f=d.end,g=d.$to.end(d.depth);f<g&&(e.step(new eY(f-1,g,f,g,new d4(d$.from(c.create(null,d.parent.copy())),1,0),1,!0)),d=new ef(e.doc.resolve(d.$from.pos),e.doc.resolve(g),d.depth));let h=e_(d);if(null==h)return!1;e.lift(d,h);let i=e.doc.resolve(e.mapping.map(f,-1)-1);return e5(e.doc,i.pos)&&i.nodeBefore.type==i.nodeAfter.type&&e.join(i.pos),b(e.scrollIntoView()),!0}(a,b,d,f):function(a,b,c){let d=a.tr,e=c.parent;for(let a=c.end,b=c.endIndex-1,f=c.startIndex;b>f;b--)a-=e.child(b).nodeSize,d.delete(a-1,a+1);let f=d.doc.resolve(c.start),g=f.nodeAfter;if(d.mapping.map(c.end)!=c.start+f.nodeAfter.nodeSize)return!1;let h=0==c.startIndex,i=c.endIndex==e.childCount,j=f.node(-1),k=f.index(-1);if(!j.canReplace(k+ +!h,k+1,g.content.append(i?d$.empty:d$.from(e))))return!1;let l=f.pos,m=l+g.nodeSize;return d.step(new eY(l-!!h,m+ +!!i,l+1,m-1,new d4((h?d$.empty:d$.from(e.copy(d$.empty))).append(i?d$.empty:d$.from(e.copy(d$.empty))),+!h,+!i),+!h)),b(d.scrollIntoView()),!0}(a,b,f)))})(b,c)},ky=()=>({state:a,dispatch:b})=>jv(a,b);function kz(a,b){return b.nodes[a]?"node":b.marks[a]?"mark":null}function kA(a,b){let c="string"==typeof b?[b]:b;return Object.keys(a).reduce((b,d)=>(c.includes(d)||(b[d]=a[d]),b),{})}var kB=(a,b)=>({tr:c,state:d,dispatch:e})=>{let f=null,g=null,h=kz("string"==typeof a?a:a.name,d.schema);if(!h)return!1;"node"===h&&(f=jW(a,d.schema)),"mark"===h&&(g=j6(a,d.schema));let i=!1;return c.selection.ranges.forEach(a=>{d.doc.nodesBetween(a.$from.pos,a.$to.pos,(a,d)=>{f&&f===a.type&&(i=!0,e&&c.setNodeMarkup(d,void 0,kA(a.attrs,b))),g&&a.marks.length&&a.marks.forEach(f=>{g===f.type&&(i=!0,e&&c.addMark(d,d+a.nodeSize,g.create(kA(f.attrs,b))))})})}),i},kC=()=>({tr:a,dispatch:b})=>(b&&a.scrollIntoView(),!0),kD=()=>({tr:a,dispatch:b})=>{if(b){let b=new fu(a.doc);a.setSelection(b)}return!0},kE=()=>({state:a,dispatch:b})=>jp(a,b),kF=()=>({state:a,dispatch:b})=>jt(a,b),kG=()=>({state:a,dispatch:b})=>((a,b)=>{let{$from:c,to:d}=a.selection,e,f=c.sharedDepth(d);return 0!=f&&(e=c.before(f),b&&b(a.tr.setSelection(fs.create(a.doc,e))),!0)})(a,b),kH=()=>({state:a,dispatch:b})=>jD(a,b),kI=()=>({state:a,dispatch:b})=>jC(a,b);function kJ(a,b,c={},d={}){return ki(a,b,{slice:!1,parseOptions:c,errorOnInvalidContent:d.errorOnInvalidContent})}var kK=(a,{errorOnInvalidContent:b,emitUpdate:c=!0,parseOptions:d={}}={})=>({editor:e,tr:f,dispatch:g,commands:h})=>{let{doc:i}=f;if("full"!==d.preserveWhitespace){let h=kJ(a,e.schema,d,{errorOnInvalidContent:null!=b?b:e.options.enableContentCheck});return g&&f.replaceWith(0,i.content.size,h).setMeta("preventUpdate",!c),!0}return g&&f.setMeta("preventUpdate",!c),h.insertContentAt({from:0,to:i.content.size},a,{parseOptions:d,errorOnInvalidContent:null!=b?b:e.options.enableContentCheck})};function kL(a,b){let c=j6(b,a.schema),{from:d,to:e,empty:f}=a.selection,g=[];f?(a.storedMarks&&g.push(...a.storedMarks),g.push(...a.selection.$head.marks())):a.doc.nodesBetween(d,e,a=>{g.push(...a.marks)});let h=g.find(a=>a.type.name===c.name);return h?{...h.attrs}:{}}function kM(a,b){let c=new fk(a);return b.forEach(a=>{a.steps.forEach(a=>{c.step(a)})}),c}function kN(a,b){let c=[];return a.descendants((a,d)=>{b(a)&&c.push({node:a,pos:d})}),c}function kO(a,b){for(let c=a.depth;c>0;c-=1){let d=a.node(c);if(b(d))return{pos:c>0?a.before(c):0,start:a.start(c),depth:c,node:d}}}function kP(a){return b=>kO(b.$from,a)}function kQ(a,b,c){return void 0===a.config[b]&&a.parent?kQ(a.parent,b,c):"function"==typeof a.config[b]?a.config[b].bind({...c,parent:a.parent?kQ(a.parent,b,c):null}):a.config[b]}function kR(a){return a.map(a=>{let b={name:a.name,options:a.options,storage:a.storage},c=kQ(a,"addExtensions",b);return c?[a,...kR(c())]:a}).flat(10)}function kS(a,b){let c=eH.fromSchema(b).serializeFragment(a),d=document.implementation.createHTMLDocument().createElement("div");return d.appendChild(c),d.innerHTML}function kT(a){return"function"==typeof a}function kU(a,b,...c){return kT(a)?b?a.bind(b)(...c):a(...c):a}function kV(a){let b=a.filter(a=>"extension"===a.type);return{baseExtensions:b,nodeExtensions:a.filter(a=>"node"===a.type),markExtensions:a.filter(a=>"mark"===a.type)}}function kW(a){let b=[],{nodeExtensions:c,markExtensions:d}=kV(a),e=[...c,...d],f={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1},g=c.filter(a=>"text"!==a.name).map(a=>a.name),h=d.map(a=>a.name),i=[...g,...h];return a.forEach(a=>{let c={name:a.name,options:a.options,storage:a.storage,extensions:e},d=kQ(a,"addGlobalAttributes",c);d&&d().forEach(a=>{(Array.isArray(a.types)?a.types:"*"===a.types?i:"nodes"===a.types?g:"marks"===a.types?h:[]).forEach(c=>{Object.entries(a.attributes).forEach(([a,d])=>{b.push({type:c,name:a,attribute:{...f,...d}})})})})}),e.forEach(a=>{let c={name:a.name,options:a.options,storage:a.storage},d=kQ(a,"addAttributes",c);d&&Object.entries(d()).forEach(([c,d])=>{let e={...f,...d};"function"==typeof(null==e?void 0:e.default)&&(e.default=e.default()),(null==e?void 0:e.isRequired)&&(null==e?void 0:e.default)===void 0&&delete e.default,b.push({type:a.name,name:c,attribute:e})})}),b}function kX(a){let b=[],c=function(a){let b=[],c="",d=!1,e=!1,f=0,g=a.length;for(let h=0;h<g;h+=1){let g=a[h];if("'"===g&&!e){d=!d,c+=g;continue}if('"'===g&&!d){e=!e,c+=g;continue}if(!d&&!e){if("("===g){f+=1,c+=g;continue}if(")"===g&&f>0){f-=1,c+=g;continue}if(";"===g&&0===f){b.push(c),c="";continue}}c+=g}return c&&b.push(c),b}(a||""),d=c.length;for(let a=0;a<d;a+=1){let d=c[a],e=d.indexOf(":");if(-1===e)continue;let f=d.slice(0,e).trim(),g=d.slice(e+1).trim();f&&g&&b.push([f,g])}return b}function kY(...a){return a.filter(a=>!!a).reduce((a,b)=>{let c={...a};return Object.entries(b).forEach(([a,b])=>{if(!c[a]){c[a]=b;return}if("class"===a){let d=b?String(b).split(" "):[],e=c[a]?c[a].split(" "):[],f=d.filter(a=>!e.includes(a));c[a]=[...e,...f].join(" ")}else if("style"===a){let d=new Map([...kX(c[a]),...kX(b)]);c[a]=Array.from(d.entries()).map(([a,b])=>`${a}: ${b}`).join("; ")}else c[a]=b}),c},{})}function kZ(a,b){return b.filter(b=>b.type===a.type.name).filter(a=>a.attribute.rendered).map(b=>b.attribute.renderHTML?b.attribute.renderHTML(a.attrs)||{}:{[b.name]:a.attrs[b.name]}).reduce((a,b)=>kY(a,b),{})}function k$(a,b){return"style"in a?a:{...a,getAttrs:c=>{let d=a.getAttrs?a.getAttrs(c):a.attrs;if(!1===d)return!1;let e=b.reduce((a,b)=>{var d;let e=b.attribute.parseHTML?b.attribute.parseHTML(c):"string"!=typeof(d=c.getAttribute(b.name))?d:d.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(d):"true"===d||"false"!==d&&d;return null==e?a:{...a,[b.name]:e}},{});return{...d,...e}}}}function k_(a){return Object.fromEntries(Object.entries(a).filter(([a,b])=>!("attrs"===a&&function(a={}){return 0===Object.keys(a).length&&a.constructor===Object}(b))&&null!=b))}function k0(a){var b,c;let d={};return!(null==(b=null==a?void 0:a.attribute)?void 0:b.isRequired)&&"default"in((null==a?void 0:a.attribute)||{})&&(d.default=a.attribute.default),(null==(c=null==a?void 0:a.attribute)?void 0:c.validate)!==void 0&&(d.validate=a.attribute.validate),[a.name,d]}function k1(a){return a.sort((a,b)=>{let c=kQ(a,"priority")||100,d=kQ(b,"priority")||100;return c>d?-1:+(c<d)})}function k2(a){var b;let c=k1(kR(a)),d=Array.from(new Set((b=c.map(a=>a.name)).filter((a,c)=>b.indexOf(a)!==c)));return d.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${d.map(a=>`'${a}'`).join(", ")}]. This can lead to issues.`),c}function k3(a,b,c){let{from:d,to:e}=b,{blockSeparator:f="\n\n",textSerializers:g={}}=c||{},h="";return a.nodesBetween(d,e,(a,c,i,j)=>{var k;a.isBlock&&c>d&&(h+=f);let l=null==g?void 0:g[a.type.name];if(l)return i&&(h+=l({node:a,pos:c,parent:i,index:j,range:b})),!1;a.isText&&(h+=null==(k=null==a?void 0:a.text)?void 0:k.slice(Math.max(d,c)-c,e-c))}),h}function k4(a,b){let c={from:0,to:a.content.size};return k3(a,c,b)}function k5(a){return Object.fromEntries(Object.entries(a.nodes).filter(([,a])=>a.spec.toText).map(([a,b])=>[a,b.spec.toText]))}function k6(a,b){let c=kz("string"==typeof b?b:b.name,a.schema);return"node"===c?function(a,b){let c=jW(b,a.schema),{from:d,to:e}=a.selection,f=[];a.doc.nodesBetween(d,e,a=>{f.push(a)});let g=f.reverse().find(a=>a.type.name===c.name);return g?{...g.attrs}:{}}(a,b):"mark"===c?kL(a,b):{}}function k7(a){let b,{mapping:c,steps:d}=a,e=[];return c.maps.forEach((a,b)=>{let f=[];if(a.ranges.length)a.forEach((a,b)=>{f.push({from:a,to:b})});else{let{from:a,to:c}=d[b];if(void 0===a||void 0===c)return;f.push({from:a,to:c})}f.forEach(({from:a,to:d})=>{let f=c.slice(b).map(a,-1),g=c.slice(b).map(d),h=c.invert().map(f,-1),i=c.invert().map(g);e.push({oldRange:{from:h,to:i},newRange:{from:f,to:g}})})}),1===(b=function(a,b=JSON.stringify){let c={};return a.filter(a=>{let d=b(a);return!Object.prototype.hasOwnProperty.call(c,d)&&(c[d]=!0)})}(e)).length?b:b.filter((a,c)=>!b.filter((a,b)=>b!==c).some(b=>a.oldRange.from>=b.oldRange.from&&a.oldRange.to<=b.oldRange.to&&a.newRange.from>=b.newRange.from&&a.newRange.to<=b.newRange.to))}function k8(a,b,c){let d=[];return a===b?c.resolve(a).marks().forEach(b=>{let e=j5(c.resolve(a),b.type);e&&d.push({mark:b,...e})}):c.nodesBetween(a,b,(a,b)=>{a&&(null==a?void 0:a.nodeSize)!==void 0&&d.push(...a.marks.map(c=>({from:b,to:b+a.nodeSize,mark:c})))}),d}function k9(a,b){return b.nodes[a]||b.marks[a]||null}function la(a,b,c){return Object.fromEntries(Object.entries(c).filter(([c])=>{let d=a.find(a=>a.type===b&&a.name===c);return!!d&&d.attribute.keepOnSplit}))}function lb(a,b,c={}){let{empty:d,ranges:e}=a.selection,f=b?j6(b,a.schema):null;if(d)return!!(a.storedMarks||a.selection.$from.marks()).filter(a=>!f||f.name===a.type.name).find(a=>j2(a.attrs,c,{strict:!1}));let g=0,h=[];if(e.forEach(({$from:b,$to:c})=>{let d=b.pos,e=c.pos;a.doc.nodesBetween(d,e,(a,b)=>{if(f&&a.inlineContent&&!a.type.allowsMarkType(f))return!1;if(!a.isText&&!a.marks.length)return;let c=Math.max(d,b),i=Math.min(e,b+a.nodeSize);g+=i-c,h.push(...a.marks.map(a=>({mark:a,from:c,to:i})))})}),0===g)return!1;let i=h.filter(a=>!f||f.name===a.mark.type.name).filter(a=>j2(a.mark.attrs,c,{strict:!1})).reduce((a,b)=>a+b.to-b.from,0),j=h.filter(a=>!f||a.mark.type!==f&&a.mark.type.excludes(f)).reduce((a,b)=>a+b.to-b.from,0);return(i>0?i+j:i)>=g}function lc(a,b){return Array.isArray(b)?b.some(b=>("string"==typeof b?b:b.name)===a.name):b}function ld(a,b){let{nodeExtensions:c}=kV(b),d=c.find(b=>b.name===a);if(!d)return!1;let e={name:d.name,options:d.options,storage:d.storage},f=kU(kQ(d,"group",e));return"string"==typeof f&&f.split(" ").includes("list")}function le(a,{checkChildren:b=!0,ignoreWhitespace:c=!1}={}){var d;if(c){if("hardBreak"===a.type.name)return!0;if(a.isText)return!/\S/.test(null!=(d=a.text)?d:"")}if(a.isText)return!a.text;if(a.isAtom||a.isLeaf)return!1;if(0===a.content.childCount)return!0;if(b){let d=!0;return a.content.forEach(a=>{!1!==d&&(le(a,{ignoreWhitespace:c,checkChildren:b})||(d=!1))}),d}return!1}function lf(a){return a instanceof fs}var lg=class a{constructor(a){this.position=a}static fromJSON(b){return new a(b.position)}toJSON(){return{position:this.position}}};function lh(a,b){let c=b.mapping.mapResult(a.position);return{position:new lg(c.pos),mapResult:c}}function li(a){return new lg(a)}function lj(a,b,c){let d=a.state.doc.content.size,e=ka(b,0,d),f=ka(c,0,d),g=a.coordsAtPos(e),h=a.coordsAtPos(f,-1),i=Math.min(g.top,h.top),j=Math.max(g.bottom,h.bottom),k=Math.min(g.left,h.left),l=Math.max(g.right,h.right),m={top:i,bottom:j,left:k,right:l,width:l-k,height:j-i,x:k,y:i};return{...m,toJSON:()=>m}}var lk=(a,b={})=>({tr:c,state:d,dispatch:e})=>{let{selection:f}=c,{empty:g,ranges:h}=f,i=j6(a,d.schema);if(e)if(g){let a=kL(d,i);c.addStoredMark(i.create({...a,...b}))}else h.forEach(a=>{let e=a.$from.pos,f=a.$to.pos;d.doc.nodesBetween(e,f,(a,d)=>{let g=Math.max(d,e),h=Math.min(d+a.nodeSize,f);a.marks.find(a=>a.type===i)?a.marks.forEach(a=>{i===a.type&&c.addMark(g,h,i.create({...a.attrs,...b}))}):c.addMark(g,h,i.create(b))})});return function(a,b,c){var d;let{selection:e}=b,f=null;if(j9(e)&&(f=e.$cursor),f){let b=null!=(d=a.storedMarks)?d:f.marks();return f.parent.type.allowsMarkType(c)&&(!!c.isInSet(b)||!b.some(a=>a.type.excludes(c)))}let{ranges:g}=e;return g.some(({$from:b,$to:d})=>{let e=0===b.depth&&a.doc.inlineContent&&a.doc.type.allowsMarkType(c);return a.doc.nodesBetween(b.pos,d.pos,(a,b,d)=>{if(e)return!1;if(a.isInline){let b=!d||d.type.allowsMarkType(c),f=!!c.isInSet(a.marks)||!a.marks.some(a=>a.type.excludes(c));e=b&&f}return!e}),e})}(d,c,i)},ll=(a,b)=>({tr:c})=>(c.setMeta(a,b),!0),lm=(a,b={})=>({state:c,dispatch:d,chain:e})=>{let f,g=jW(a,c.schema);return(c.selection.$anchor.sameParent(c.selection.$head)&&(f=c.selection.$anchor.parent.attrs),g.isTextblock)?e().command(({commands:a})=>!!jE(g,{...f,...b})(c)||a.clearNodes()).command(({state:a})=>jE(g,{...f,...b})(a,d)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},ln=a=>({tr:b,dispatch:c})=>{if(c){let{doc:c}=b,d=ka(a,0,c.content.size),e=fs.create(c,d);b.setSelection(e)}return!0},lo=(a,b)=>({tr:c,state:d,dispatch:e})=>{let f,g,{selection:h}=d;return"number"==typeof b?(f=b,g=b):b&&"from"in b&&"to"in b?(f=b.from,g=b.to):(f=h.from,g=h.to),e&&c.doc.nodesBetween(f,g,(b,d)=>{b.isText||c.setNodeMarkup(d,void 0,{...b.attrs,dir:a})}),!0},lp=a=>({tr:b,dispatch:c})=>{if(c){let{doc:c}=b,{from:d,to:e}="number"==typeof a?{from:a,to:a}:a,f=fq.atStart(c).from,g=fq.atEnd(c).to,h=ka(d,f,g),i=ka(e,f,g),j=fq.create(c,h,i);b.setSelection(j)}return!0},lq=a=>({state:b,dispatch:c})=>{var d;return(d=jW(a,b.schema),function(a,b){let{$from:c,$to:e}=a.selection,f=c.blockRange(e,a=>a.childCount>0&&a.firstChild.type==d);if(!f)return!1;let g=f.startIndex;if(0==g)return!1;let h=f.parent,i=h.child(g-1);if(i.type!=d)return!1;if(b){let c=i.lastChild&&i.lastChild.type==h.type,e=d$.from(c?d.create():null),g=new d4(d$.from(d.create(null,d$.from(h.type.create(null,e)))),c?3:1,0),j=f.start,k=f.end;b(a.tr.step(new eY(j-(c?3:1),k,j,k,g,1,!0)).scrollIntoView())}return!0})(b,c)};function lr(a,b){let c=a.storedMarks||a.selection.$to.parentOffset&&a.selection.$from.marks();if(c){let d=c.filter(a=>null==b?void 0:b.includes(a.type.name));a.tr.ensureMarks(d)}}var ls=({keepMarks:a=!0}={})=>({tr:b,state:c,dispatch:d,editor:e})=>{let{selection:f,doc:g}=b,{$from:h,$to:i}=f,j=la(e.extensionManager.attributes,h.node().type.name,h.node().attrs);if(f instanceof fs&&f.node.isBlock)return!!h.parentOffset&&!!e4(g,h.pos)&&(d&&(a&&lr(c,e.extensionManager.splittableMarks),b.split(h.pos).scrollIntoView()),!0);if(!h.parent.isBlock)return!1;let k=i.parentOffset===i.parent.content.size,l=0===h.depth?void 0:function(a){for(let b=0;b<a.edgeCount;b+=1){let{type:c}=a.edge(b);if(c.isTextblock&&!c.hasRequiredAttrs())return c}return null}(h.node(-1).contentMatchAt(h.indexAfter(-1))),m=k&&l?[{type:l,attrs:j}]:void 0,n=e4(b.doc,b.mapping.map(h.pos),1,m);if(!m&&!n&&e4(b.doc,b.mapping.map(h.pos),1,l?[{type:l}]:void 0)&&(n=!0,m=l?[{type:l,attrs:j}]:void 0),d){if(n&&(f instanceof fq&&b.deleteSelection(),b.split(b.mapping.map(h.pos),1,m),l&&!k&&!h.parentOffset&&h.parent.type!==l)){let a=b.mapping.map(h.before()),c=b.doc.resolve(a);h.node(-1).canReplaceWith(c.index(),c.index()+1,l)&&b.setNodeMarkup(b.mapping.map(h.before()),l)}a&&lr(c,e.extensionManager.splittableMarks),b.scrollIntoView()}return n},lt=(a,b={})=>({tr:c,state:d,dispatch:e,editor:f})=>{var g;let h=jW(a,d.schema),{$from:i,$to:j}=d.selection,k=d.selection.node;if(k&&k.isBlock||i.depth<2||!i.sameParent(j))return!1;let l=i.node(-1);if(l.type!==h)return!1;let m=f.extensionManager.attributes;if(0===i.parent.content.size&&i.node(-1).childCount===i.indexAfter(-1)){if(2===i.depth||i.node(-3).type!==h||i.index(-2)!==i.node(-2).childCount-1)return!1;if(e){let a=d$.empty,d=i.index(-1)?1:i.index(-2)?2:3;for(let b=i.depth-d;b>=i.depth-3;b-=1)a=d$.from(i.node(b).copy(a));let e=i.indexAfter(-1)<i.node(-2).childCount?1:i.indexAfter(-2)<i.node(-3).childCount?2:3,f={...la(m,i.node().type.name,i.node().attrs),...b},j=(null==(g=h.contentMatch.defaultType)?void 0:g.createAndFill(f))||void 0;a=a.append(d$.from(h.createAndFill(null,j)||void 0));let k=i.before(i.depth-(d-1));c.replace(k,i.after(-e),new d4(a,4-d,0));let l=-1;c.doc.nodesBetween(k,c.doc.content.size,(a,b)=>{if(l>-1)return!1;a.isTextblock&&0===a.content.size&&(l=b+1)}),l>-1&&c.setSelection(fq.near(c.doc.resolve(l))),c.scrollIntoView()}return!0}let n=j.pos===i.end()?l.contentMatchAt(0).defaultType:null,o={...la(m,l.type.name,l.attrs),...b},p={...la(m,i.node().type.name,i.node().attrs),...b};c.delete(i.pos,j.pos);let q=n?[{type:h,attrs:o},{type:n,attrs:p}]:[{type:h,attrs:o}];if(!e4(c.doc,i.pos,2))return!1;if(e){let{selection:a,storedMarks:b}=d,{splittableMarks:g}=f.extensionManager,h=b||a.$to.parentOffset&&a.$from.marks();if(c.split(i.pos,2,q).scrollIntoView(),!h||!e)return!0;let j=h.filter(a=>g.includes(a.type.name));c.ensureMarks(j)}return!0},lu=(a,b)=>{let c=kP(a=>a.type===b)(a.selection);if(!c)return!0;let d=a.doc.resolve(Math.max(0,c.pos-1)).before(c.depth);if(void 0===d)return!0;let e=a.doc.nodeAt(d);return!(c.node.type===(null==e?void 0:e.type)&&e5(a.doc,c.pos))||(a.join(c.pos),!0)},lv=(a,b)=>{let c=kP(a=>a.type===b)(a.selection);if(!c)return!0;let d=a.doc.resolve(c.start).after(c.depth);if(void 0===d)return!0;let e=a.doc.nodeAt(d);return!(c.node.type===(null==e?void 0:e.type)&&e5(a.doc,d))||(a.join(d),!0)},lw=(a,b,c,d={})=>({editor:e,tr:f,state:g,dispatch:h,chain:i,commands:j,can:k})=>{let{extensions:l,splittableMarks:m}=e.extensionManager,n=jW(a,g.schema),o=jW(b,g.schema),{selection:p,storedMarks:q}=g,{$from:r,$to:s}=p,t=r.blockRange(s),u=q||p.$to.parentOffset&&p.$from.marks();if(!t)return!1;let v=kP(a=>ld(a.type.name,l))(p),w=0===p.from&&p.to===g.doc.content.size,x=g.doc.content.content,y=1===x.length?x[0]:null,z=w&&y&&ld(y.type.name,l)?{node:y,pos:0,depth:0}:null,A=null!=v?v:z,B=!!v&&t.depth>=1&&t.depth-v.depth<=1,C=!!z;if((B||C)&&A){if(A.node.type===n)return w&&C?i().command(({tr:a,dispatch:b})=>{let c=function(a){let b=a.doc,c=b.firstChild;if(!c)return null;let d=b.resolve(1),e=b.resolve(c.nodeSize-1);return fq.between(d,e)}(a);return!!c&&(a.setSelection(c),b&&b(a),!0)}).liftListItem(o).run():j.liftListItem(o);if(ld(A.node.type.name,l)&&n.validContent(A.node.content))return i().command(()=>(f.setNodeMarkup(A.pos,n),!0)).command(()=>lu(f,n)).command(()=>lv(f,n)).run()}return c&&u&&h?i().command(()=>{let a=k().wrapInList(n,d),b=u.filter(a=>m.includes(a.type.name));return f.ensureMarks(b),!!a||j.clearNodes()}).wrapInList(n,d).command(()=>lu(f,n)).command(()=>lv(f,n)).run():i().command(()=>!!k().wrapInList(n,d)||j.clearNodes()).wrapInList(n,d).command(()=>lu(f,n)).command(()=>lv(f,n)).run()},lx=(a,b={},c={})=>({state:d,commands:e})=>{let{extendEmptyMarkRange:f=!1}=c,g=j6(a,d.schema);return lb(d,g,b)?e.unsetMark(g,{extendEmptyMarkRange:f}):e.setMark(g,b)},ly=(a,b,c={})=>({state:d,commands:e})=>{let f,g=jW(a,d.schema),h=jW(b,d.schema),i=ku(d,g,c);return(d.selection.$anchor.sameParent(d.selection.$head)&&(f=d.selection.$anchor.parent.attrs),i)?e.setNode(h,f):e.setNode(g,{...f,...c})},lz=(a,b={})=>({state:c,commands:d})=>{let e=jW(a,c.schema);return ku(c,e,b)?d.lift(e):d.wrapIn(e,b)},lA=()=>({state:a,dispatch:b})=>{let c=a.plugins;for(let d=0;d<c.length;d+=1){let e,f=c[d];if(f.spec.isInputRules&&(e=f.getState(a))){if(b){let b=a.tr,c=e.transform;for(let a=c.steps.length-1;a>=0;a-=1)b.step(c.steps[a].invert(c.docs[a]));if(e.text){let c=b.doc.resolve(e.from).marks();b.replaceWith(e.from,e.to,a.schema.text(e.text,c))}else b.delete(e.from,e.to)}return!0}}return!1},lB=()=>({tr:a,dispatch:b})=>{let{selection:c}=a,{empty:d,ranges:e}=c;return!!d||(b&&e.forEach(b=>{a.removeMark(b.$from.pos,b.$to.pos)}),!0)},lC=(a,b={})=>({tr:c,state:d,dispatch:e})=>{var f;let{extendEmptyMarkRange:g=!1}=b,{selection:h}=c,i=j6(a,d.schema),{$from:j,empty:k,ranges:l}=h;if(!e)return!0;if(k&&g){let{from:a,to:b}=h,d=null==(f=j.marks().find(a=>a.type===i))?void 0:f.attrs,e=j5(j,i,d);e&&(a=e.from,b=e.to),c.removeMark(a,b,i)}else l.forEach(a=>{c.removeMark(a.$from.pos,a.$to.pos,i)});return c.removeStoredMark(i),!0},lD=a=>({tr:b,state:c,dispatch:d})=>{let e,f,{selection:g}=c;return"number"==typeof a?(e=a,f=a):a&&"from"in a&&"to"in a?(e=a.from,f=a.to):(e=g.from,f=g.to),d&&b.doc.nodesBetween(e,f,(a,c)=>{if(a.isText)return;let d={...a.attrs};delete d.dir,b.setNodeMarkup(c,void 0,d)}),!0},lE=(a,b={})=>({tr:c,state:d,dispatch:e})=>{let f=null,g=null,h=kz("string"==typeof a?a:a.name,d.schema);if(!h)return!1;"node"===h&&(f=jW(a,d.schema)),"mark"===h&&(g=j6(a,d.schema));let i=!1;return c.selection.ranges.forEach(a=>{let h,j,k,l,m=a.$from.pos,n=a.$to.pos;c.selection.empty?d.doc.nodesBetween(m,n,(a,b)=>{f&&f===a.type&&(i=!0,k=Math.max(b,m),l=Math.min(b+a.nodeSize,n),h=b,j=a)}):d.doc.nodesBetween(m,n,(a,d)=>{d<m&&f&&f===a.type&&(i=!0,k=Math.max(d,m),l=Math.min(d+a.nodeSize,n),h=d,j=a),d>=m&&d<=n&&(f&&f===a.type&&(i=!0,e&&c.setNodeMarkup(d,void 0,{...a.attrs,...b})),g&&a.marks.length&&a.marks.forEach(f=>{if(g===f.type&&(i=!0,e)){let e=Math.max(d,m),h=Math.min(d+a.nodeSize,n);c.addMark(e,h,g.create({...f.attrs,...b}))}}))}),j&&(void 0!==h&&e&&c.setNodeMarkup(h,void 0,{...j.attrs,...b}),g&&j.marks.length&&j.marks.forEach(a=>{g===a.type&&e&&c.addMark(k,l,g.create({...a.attrs,...b}))}))}),i},lF=(a,b={})=>({state:c,dispatch:d})=>(function(a,b=null){return function(c,d){let{$from:e,$to:f}=c.selection,g=e.blockRange(f),h=g&&e0(g,a,b);return!!h&&(d&&d(c.tr.wrap(g,h).scrollIntoView()),!0)}})(jW(a,c.schema),b)(c,d),lG=(a,b={})=>({state:c,dispatch:d})=>(function(a,b=null){return function(c,d){let{$from:e,$to:f}=c.selection,g=e.blockRange(f);if(!g)return!1;let h=d?c.tr:null;return!!function(a,b,c,d=null){let e=!1,f=b,g=b.$from.doc;if(b.depth>=2&&b.$from.node(b.depth-1).type.compatibleContent(c)&&0==b.startIndex){if(0==b.$from.index(b.depth-1))return!1;let a=g.resolve(b.start-2);f=new ef(a,a,b.depth),b.endIndex<b.parent.childCount&&(b=new ef(b.$from,g.resolve(b.$to.end(b.depth)),b.depth)),e=!0}let h=e0(f,c,d,b);return!!h&&(a&&function(a,b,c,d,e){let f=d$.empty;for(let a=c.length-1;a>=0;a--)f=d$.from(c[a].type.create(c[a].attrs,f));a.step(new eY(b.start-2*!!d,b.end,b.start,b.end,new d4(f,0,0),c.length,!0));let g=0;for(let a=0;a<c.length;a++)c[a].type==e&&(g=a+1);let h=c.length-g,i=b.start+c.length-2*!!d,j=b.parent;for(let c=b.startIndex,d=b.endIndex,e=!0;c<d;c++,e=!1)!e&&e4(a.doc,i,h)&&(a.split(i,h),i+=2*h),i+=j.child(c).nodeSize}(a,b,h,e,c),!0)}(h,g,a,b)&&(d&&d(h.scrollIntoView()),!0)}})(jW(a,c.schema),b)(c,d),lH=class{constructor(){this.callbacks={}}on(a,b){return this.callbacks[a]||(this.callbacks[a]=[]),this.callbacks[a].push(b),this}emit(a,...b){let c=this.callbacks[a];return c&&c.forEach(a=>a.apply(this,b)),this}off(a,b){let c=this.callbacks[a];return c&&(b?this.callbacks[a]=c.filter(a=>a!==b):delete this.callbacks[a]),this}once(a,b){let c=(...d)=>{this.off(a,c),b.apply(this,d)};return this.on(a,c)}removeAllListeners(){this.callbacks={}}},lI=class{constructor(a){var b;this.find=a.find,this.handler=a.handler,this.undoable=null==(b=a.undoable)||b}};function lJ(a){var b;let{editor:c,from:d,to:e,text:f,rules:g,plugin:h}=a,{view:i}=c;if(i.composing)return!1;let j=i.state.doc.resolve(d);if(j.parent.type.spec.code||(null==(b=j.nodeBefore||j.nodeAfter)?void 0:b.marks.find(a=>a.type.spec.code)))return!1;let k=!1,l=((a,b=500)=>{let c="",d=a.parentOffset;return a.parent.nodesBetween(Math.max(0,d-b),d,(a,b,e,f)=>{var g,h;let i=(null==(h=(g=a.type.spec).toText)?void 0:h.call(g,{node:a,pos:b,parent:e,index:f}))||a.textContent||"%leaf%";c+=a.isAtom&&!a.isText?i:i.slice(0,Math.max(0,d-b))}),c})(j)+f;return g.forEach(a=>{if(k)return;let b=((a,b)=>{if(j1(b))return b.exec(a);let c=b(a);if(!c)return null;let d=[c.text];return d.index=c.index,d.input=a,d.data=c.data,c.replaceWith&&(c.text.includes(c.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),d.push(c.replaceWith)),d})(l,a.find);if(!b)return;let g=i.state.tr,j=jM({state:i.state,transaction:g}),m={from:d-(b[0].length-f.length),to:e},{commands:n,chain:o,can:p}=new jN({editor:c,state:j});null!==a.handler({state:j,range:m,match:b,commands:n,chain:o,can:p})&&g.steps.length&&(a.undoable&&g.setMeta(h,{transform:g,from:d,to:e,text:f}),i.dispatch(g),k=!0)}),k}function lK(a){return"Object"===Object.prototype.toString.call(a).slice(8,-1)&&a.constructor===Object&&Object.getPrototypeOf(a)===Object.prototype}var lL=class{constructor(a={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...a},this.name=this.config.name}get options(){return{...kU(kQ(this,"addOptions",{name:this.name}))}}get storage(){return{...kU(kQ(this,"addStorage",{name:this.name,options:this.options}))}}configure(a={}){let b=this.extend({...this.config,addOptions:()=>(function a(b,c){let d={...b};return lK(b)&&lK(c)&&Object.keys(c).forEach(e=>{lK(c[e])&&lK(b[e])?d[e]=a(b[e],c[e]):d[e]=c[e]}),d})(this.options,a)});return b.name=this.name,b.parent=this.parent,this.child=null,b}extend(a={}){let b=new this.constructor({...this.config,...a});return b.parent=this,this.child=b,b.name="name"in a?a.name:b.parent.name,b}},lM=class a extends lL{constructor(){super(...arguments),this.type="mark"}static create(b={}){return new a("function"==typeof b?b():b)}static handleExit({editor:a,mark:b}){let{tr:c}=a.state,d=a.state.selection.$from;if(d.pos===d.end()){let e=d.marks();if(!e.find(a=>(null==a?void 0:a.type.name)===b.name))return!1;let f=e.find(a=>(null==a?void 0:a.type.name)===b.name);return f&&c.removeStoredMark(f),c.insertText(" ",d.pos),a.view.dispatch(c),!0}return!1}configure(a){return super.configure(a)}extend(a){let b="function"==typeof a?a():a;return super.extend(b)}},lN=class{constructor(a){this.find=a.find,this.handler=a.handler}},lO=null,lP=class{constructor(a,b){this.splittableMarks=[],this.editor=b,this.baseExtensions=a,this.extensions=k2(a),this.schema=function(a,b){var c;let d=kW(a),{nodeExtensions:e,markExtensions:f}=kV(a),g=null==(c=e.find(a=>kQ(a,"topNode")))?void 0:c.name;return new ew({topNode:g,nodes:Object.fromEntries(e.map(c=>{let e=d.filter(a=>a.type===c.name),f={name:c.name,options:c.options,storage:c.storage,editor:b},g=k_({...a.reduce((a,b)=>{let d=kQ(b,"extendNodeSchema",f);return{...a,...d?d(c):{}}},{}),content:kU(kQ(c,"content",f)),marks:kU(kQ(c,"marks",f)),group:kU(kQ(c,"group",f)),inline:kU(kQ(c,"inline",f)),atom:kU(kQ(c,"atom",f)),selectable:kU(kQ(c,"selectable",f)),draggable:kU(kQ(c,"draggable",f)),code:kU(kQ(c,"code",f)),whitespace:kU(kQ(c,"whitespace",f)),linebreakReplacement:kU(kQ(c,"linebreakReplacement",f)),defining:kU(kQ(c,"defining",f)),isolating:kU(kQ(c,"isolating",f)),attrs:Object.fromEntries(e.map(k0))}),h=kU(kQ(c,"parseHTML",f));h&&(g.parseDOM=h.map(a=>k$(a,e)));let i=kQ(c,"renderHTML",f);i&&(g.toDOM=a=>i({node:a,HTMLAttributes:kZ(a,e)}));let j=kQ(c,"renderText",f);return j&&(g.toText=j),[c.name,g]})),marks:Object.fromEntries(f.map(c=>{let e=d.filter(a=>a.type===c.name),f={name:c.name,options:c.options,storage:c.storage,editor:b},g=k_({...a.reduce((a,b)=>{let d=kQ(b,"extendMarkSchema",f);return{...a,...d?d(c):{}}},{}),inclusive:kU(kQ(c,"inclusive",f)),excludes:kU(kQ(c,"excludes",f)),group:kU(kQ(c,"group",f)),spanning:kU(kQ(c,"spanning",f)),code:kU(kQ(c,"code",f)),attrs:Object.fromEntries(e.map(k0))}),h=kU(kQ(c,"parseHTML",f));h&&(g.parseDOM=h.map(a=>k$(a,e)));let i=kQ(c,"renderHTML",f);return i&&(g.toDOM=a=>i({mark:a,HTMLAttributes:kZ(a,e)})),[c.name,g]}))})}(this.extensions,b),this.setupExtensions()}get commands(){return this.extensions.reduce((a,b)=>{let c={name:b.name,options:b.options,storage:this.editor.extensionStorage[b.name],editor:this.editor,type:k9(b.name,this.schema)},d=kQ(b,"addCommands",c);return d?{...a,...d()}:a},{})}get plugins(){let{editor:a}=this;return k1([...this.extensions].reverse()).flatMap(b=>{let c={name:b.name,options:b.options,storage:this.editor.extensionStorage[b.name],editor:a,type:k9(b.name,this.schema)},d=[],e=kQ(b,"addKeyboardShortcuts",c),f={};if("mark"===b.type&&kQ(b,"exitable",c)&&(f.ArrowRight=()=>lM.handleExit({editor:a,mark:b})),e){let b=Object.fromEntries(Object.entries(e()).map(([b,c])=>[b,()=>c({editor:a})]));f={...f,...b}}let g=new fE({props:{handleKeyDown:im(f)}});d.push(g);let h=kQ(b,"addInputRules",c);if(lc(b,a.options.enableInputRules)&&h){let b=h();if(b&&b.length){let c=function(a){let{editor:b,rules:c}=a,d=new fE({state:{init:()=>null,apply(a,e,f){let g=a.getMeta(d);if(g)return g;let h=a.getMeta("applyInputRules");return h&&setTimeout(()=>{let{text:a}=h;"string"==typeof a||(a=kS(d$.from(a),f.schema));let{from:e}=h,g=e+a.length;lJ({editor:b,from:e,to:g,text:a,rules:c,plugin:d})}),a.selectionSet||a.docChanged?null:e}},props:{handleTextInput:(a,e,f,g)=>lJ({editor:b,from:e,to:f,text:g,rules:c,plugin:d}),handleDOMEvents:{compositionend:a=>(setTimeout(()=>{let{$cursor:e}=a.state.selection;e&&lJ({editor:b,from:e.pos,to:e.pos,text:"",rules:c,plugin:d})}),!1)},handleKeyDown(a,e){if("Enter"!==e.key)return!1;let{$cursor:f}=a.state.selection;return!!f&&lJ({editor:b,from:f.pos,to:f.pos,text:"\n",rules:c,plugin:d})}},isInputRules:!0});return d}({editor:a,rules:b}),e=Array.isArray(c)?c:[c];d.push(...e)}}let i=kQ(b,"addPasteRules",c);if(lc(b,a.options.enablePasteRules)&&i){let b=i();if(b&&b.length){let c=function(a){let b,{editor:c,rules:d}=a,e=null,f=!1,g=!1,h="u">typeof ClipboardEvent?new ClipboardEvent("paste"):null;try{b="u">typeof DragEvent?new DragEvent("drop"):null}catch{b=null}let i=({state:a,from:d,to:e,rule:f,pasteEvt:g})=>{let i=a.tr;if(function(a){let{editor:b,state:c,from:d,to:e,rule:f,pasteEvent:g,dropEvent:h}=a,{commands:i,chain:j,can:k}=new jN({editor:b,state:c}),l=[];return c.doc.nodesBetween(d,e,(a,b)=>{var m,n,o,p,q;if((null==(n=null==(m=a.type)?void 0:m.spec)?void 0:n.code)||!(a.isText||a.isTextblock||a.isInline))return;let r=null!=(q=null!=(p=null==(o=a.content)?void 0:o.size)?p:a.nodeSize)?q:0,s=Math.max(d,b),t=Math.min(e,b+r);s>=t||((a,b,c)=>{if(j1(b))return[...a.matchAll(b)];let d=b(a,c);return d?d.map(b=>{let c=[b.text];return c.index=b.index,c.input=a,c.data=b.data,b.replaceWith&&(b.text.includes(b.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),c.push(b.replaceWith)),c}):[]})(a.isText?a.text||"":a.textBetween(s-b,t-b,void 0,""),f.find,g).forEach(a=>{if(void 0===a.index)return;let b=s+a.index+1,d=b+a[0].length,e={from:c.tr.mapping.map(b),to:c.tr.mapping.map(d)},m=f.handler({state:c,range:e,match:a,commands:i,chain:j,can:k,pasteEvent:g,dropEvent:h});l.push(m)})}),l.every(a=>null!==a)}({editor:c,state:jM({state:a,transaction:i}),from:Math.max(d-1,0),to:e.b-1,rule:f,pasteEvent:g,dropEvent:b})&&i.steps.length){try{b="u">typeof DragEvent?new DragEvent("drop"):null}catch{b=null}return h="u">typeof ClipboardEvent?new ClipboardEvent("paste"):null,i}};return d.map(a=>new fE({view(a){let b=b=>{var d;(e=(null==(d=a.dom.parentElement)?void 0:d.contains(b.target))?a.dom.parentElement:null)&&(lO=c)},d=()=>{lO&&(lO=null)};return window.addEventListener("dragstart",b),window.addEventListener("dragend",d),{destroy(){window.removeEventListener("dragstart",b),window.removeEventListener("dragend",d)}}},props:{handleDOMEvents:{drop:(a,c)=>{if(g=e===a.dom.parentElement,b=c,!g){let a=lO;(null==a?void 0:a.isEditable)&&setTimeout(()=>{let b=a.state.selection;b&&a.commands.deleteRange({from:b.from,to:b.to})},10)}return!1},paste:(a,b)=>{var c;let d=null==(c=b.clipboardData)?void 0:c.getData("text/html");return h=b,f=!!(null==d?void 0:d.includes("data-pm-slice")),!1}}},appendTransaction:(b,c,d)=>{let e=b[0],j="paste"===e.getMeta("uiEvent")&&!f,k="drop"===e.getMeta("uiEvent")&&!g,l=e.getMeta("applyPasteRules"),m=!!l;if(!j&&!k&&!m)return;if(m){var n,o;let b,{text:c}=l;"string"==typeof c||(c=kS(d$.from(c),d.schema));let{from:e}=l,f=e+c.length;return i({rule:a,state:d,from:e,to:{b:f},pasteEvt:(n=c,null==(o=(b=new ClipboardEvent("paste",{clipboardData:new DataTransfer})).clipboardData)||o.setData("text/html",n),b)})}let p=c.doc.content.findDiffStart(d.doc.content),q=c.doc.content.findDiffEnd(d.doc.content);if("number"==typeof p&&q&&p!==q.b)return i({rule:a,state:d,from:p,to:q,pasteEvt:h})}}))}({editor:a,rules:b});d.push(...c)}}let j=kQ(b,"addProseMirrorPlugins",c);if(j){let a=j();d.push(...a)}return d})}get attributes(){return kW(this.extensions)}get nodeViews(){let{editor:a}=this,{nodeExtensions:b}=kV(this.extensions);return Object.fromEntries(b.filter(a=>!!kQ(a,"addNodeView")).map(b=>{let c=this.attributes.filter(a=>a.type===b.name),d={name:b.name,options:b.options,storage:this.editor.extensionStorage[b.name],editor:a,type:jW(b.name,this.schema)},e=kQ(b,"addNodeView",d);if(!e)return[];let f=e();return f?[b.name,(d,e,g,h,i)=>{let j=kZ(d,c);return f({node:d,view:e,getPos:g,decorations:h,innerDecorations:i,editor:a,extension:b,HTMLAttributes:j})}]:[]}))}dispatchTransaction(a){let{editor:b}=this;return k1([...this.extensions].reverse()).reduceRight((a,c)=>{let d={name:c.name,options:c.options,storage:this.editor.extensionStorage[c.name],editor:b,type:k9(c.name,this.schema)},e=kQ(c,"dispatchTransaction",d);return e?b=>{e.call(d,{transaction:b,next:a})}:a},a)}transformPastedHTML(a){let{editor:b}=this;return k1([...this.extensions]).reduce((a,c)=>{let d={name:c.name,options:c.options,storage:this.editor.extensionStorage[c.name],editor:b,type:k9(c.name,this.schema)},e=kQ(c,"transformPastedHTML",d);return e?(b,c)=>{let f=a(b,c);return e.call(d,f)}:a},a||(a=>a))}get markViews(){let{editor:a}=this,{markExtensions:b}=kV(this.extensions);return Object.fromEntries(b.filter(a=>!!kQ(a,"addMarkView")).map(b=>{let c=this.attributes.filter(a=>a.type===b.name),d={name:b.name,options:b.options,storage:this.editor.extensionStorage[b.name],editor:a,type:j6(b.name,this.schema)},e=kQ(b,"addMarkView",d);return e?[b.name,(d,f,g)=>{let h=kZ(d,c);return e()({mark:d,view:f,inline:g,editor:a,extension:b,HTMLAttributes:h,updateAttributes:b=>{!function(a,b,c={}){let{state:d}=b,{doc:e,tr:f}=d;e.descendants((b,d)=>{let e=f.mapping.map(d),g=f.mapping.map(d)+b.nodeSize,h=null;if(b.marks.forEach(b=>{if(b!==a)return!1;h=b}),!h)return;let i=!1;if(Object.keys(c).forEach(a=>{c[a]!==h.attrs[a]&&(i=!0)}),i){let b=a.type.create({...a.attrs,...c});f.removeMark(e,g,a.type),f.addMark(e,g,b)}}),f.docChanged&&b.view.dispatch(f)}(d,a,b)}})}]:[]}))}destroy(){this.extensions.forEach(a=>{let b=a;for(;b.parent;){let a=b.parent;a.child===b&&(a.child=null),b=a}}),this.extensions=[],this.baseExtensions=[],this.schema=null,this.editor=null}setupExtensions(){let a=this.extensions;this.editor.extensionStorage=Object.fromEntries(a.map(a=>[a.name,a.storage])),a.forEach(a=>{var b;let c={name:a.name,options:a.options,storage:this.editor.extensionStorage[a.name],editor:this.editor,type:k9(a.name,this.schema)};"mark"===a.type&&(null==(b=kU(kQ(a,"keepOnSplit",c)))||b)&&this.splittableMarks.push(a.name);let d=kQ(a,"onBeforeCreate",c),e=kQ(a,"onCreate",c),f=kQ(a,"onUpdate",c),g=kQ(a,"onSelectionUpdate",c),h=kQ(a,"onTransaction",c),i=kQ(a,"onFocus",c),j=kQ(a,"onBlur",c),k=kQ(a,"onDestroy",c);d&&this.editor.on("beforeCreate",d),e&&this.editor.on("create",e),f&&this.editor.on("update",f),g&&this.editor.on("selectionUpdate",g),h&&this.editor.on("transaction",h),i&&this.editor.on("focus",i),j&&this.editor.on("blur",j),k&&this.editor.on("destroy",k)})}};lP.resolve=k2,lP.sort=k1,lP.flatten=kR,jL({},{ClipboardTextSerializer:()=>lR,Commands:()=>lS,Delete:()=>lT,Drop:()=>lU,Editable:()=>lV,FocusEvents:()=>lX,Keymap:()=>lY,Paste:()=>lZ,Tabindex:()=>l$,TextDirection:()=>l_,focusEventsPluginKey:()=>lW});var lQ=class a extends lL{constructor(){super(...arguments),this.type="extension"}static create(b={}){return new a("function"==typeof b?b():b)}configure(a){return super.configure(a)}extend(a){let b="function"==typeof a?a():a;return super.extend(b)}},lR=lQ.create({name:"clipboardTextSerializer",addOptions:()=>({blockSeparator:void 0}),addProseMirrorPlugins(){return[new fE({key:new fH("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{let{editor:a}=this,{state:b,schema:c}=a,{doc:d,selection:e}=b,{ranges:f}=e,g=Math.min(...f.map(a=>a.$from.pos)),h=Math.max(...f.map(a=>a.$to.pos)),i=k5(c);return k3(d,{from:g,to:h},{...void 0!==this.options.blockSeparator?{blockSeparator:this.options.blockSeparator}:{},textSerializers:i})}}})]}}),lS=lQ.create({name:"commands",addCommands:()=>({...jO})}),lT=lQ.create({name:"delete",onUpdate({transaction:a,appendedTransactions:b}){var c,d,e;let f=()=>{var c,d,e,f;if(null!=(f=null==(e=null==(d=null==(c=this.editor.options.coreExtensionOptions)?void 0:c.delete)?void 0:d.filterTransaction)?void 0:e.call(d,a))?f:a.getMeta("y-sync$"))return;let g=kM(a.before,[a,...b]);k7(g).forEach(b=>{g.mapping.mapResult(b.oldRange.from).deletedAfter&&g.mapping.mapResult(b.oldRange.to).deletedBefore&&g.before.nodesBetween(b.oldRange.from,b.oldRange.to,(c,d)=>{let e=d+c.nodeSize-2,f=b.oldRange.from<=d&&e<=b.oldRange.to;this.editor.emit("delete",{type:"node",node:c,from:d,to:e,newFrom:g.mapping.map(d),newTo:g.mapping.map(e),deletedRange:b.oldRange,newRange:b.newRange,partial:!f,editor:this.editor,transaction:a,combinedTransform:g})})});let h=g.mapping;g.steps.forEach((b,c)=>{var d,e;if(b instanceof eU){let f=h.slice(c).map(b.from,-1),i=h.slice(c).map(b.to),j=h.invert().map(f,-1),k=h.invert().map(i),l=f>0&&(null==(d=g.doc.nodeAt(f-1))?void 0:d.marks.some(a=>a.eq(b.mark))),m=null==(e=g.doc.nodeAt(i))?void 0:e.marks.some(a=>a.eq(b.mark));this.editor.emit("delete",{type:"mark",mark:b.mark,from:b.from,to:b.to,deletedRange:{from:j,to:k},newRange:{from:f,to:i},partial:!!(m||l),editor:this.editor,transaction:a,combinedTransform:g})}})};null==(e=null==(d=null==(c=this.editor.options.coreExtensionOptions)?void 0:c.delete)?void 0:d.async)||e?setTimeout(f,0):f()}}),lU=lQ.create({name:"drop",addProseMirrorPlugins(){return[new fE({key:new fH("tiptapDrop"),props:{handleDrop:(a,b,c,d)=>{this.editor.emit("drop",{editor:this.editor,event:b,slice:c,moved:d})}}})]}}),lV=lQ.create({name:"editable",addProseMirrorPlugins(){return[new fE({key:new fH("editable"),props:{editable:()=>this.editor.options.editable}})]}}),lW=new fH("focusEvents"),lX=lQ.create({name:"focusEvents",addProseMirrorPlugins(){let{editor:a}=this;return[new fE({key:lW,props:{handleDOMEvents:{focus:(b,c)=>{a.isFocused=!0;let d=a.state.tr.setMeta("focus",{event:c}).setMeta("addToHistory",!1);return b.dispatch(d),!1},blur:(b,c)=>{a.isFocused=!1;let d=a.state.tr.setMeta("blur",{event:c}).setMeta("addToHistory",!1);return b.dispatch(d),!1}}}})]}}),lY=lQ.create({name:"keymap",addKeyboardShortcuts(){let a=()=>this.editor.commands.first(({commands:a})=>[()=>a.undoInputRule(),()=>a.command(({tr:b})=>{let{selection:c,doc:d}=b,{empty:e,$anchor:f}=c,{pos:g,parent:h}=f,i=f.parent.isTextblock&&g>0?b.doc.resolve(g-1):f,j=i.parent.type.spec.isolating,k=f.pos-f.parentOffset,l=j&&1===i.parent.childCount?k===f.pos:fm.atStart(d).from===g;return!!e&&!!h.type.isTextblock&&!h.textContent.length&&!!l&&(!l||"paragraph"!==f.parent.type.name)&&a.clearNodes()}),()=>a.deleteSelection(),()=>a.joinBackward(),()=>a.selectNodeBackward()]),b=()=>this.editor.commands.first(({commands:a})=>[()=>a.deleteSelection(),()=>a.deleteCurrentNode(),()=>a.joinForward(),()=>a.selectNodeForward()]),c={Enter:()=>this.editor.commands.first(({commands:a})=>[()=>a.newlineInCode(),()=>a.createParagraphNear(),()=>a.liftEmptyBlock(),()=>a.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:a,"Mod-Backspace":a,"Shift-Backspace":a,Delete:b,"Mod-Delete":b,"Mod-a":()=>this.editor.commands.selectAll()},d={...c},e={...c,"Ctrl-h":a,"Alt-Backspace":a,"Ctrl-d":b,"Ctrl-Alt-Backspace":b,"Alt-Delete":b,"Alt-d":b,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return kd()||ks()?e:d},addProseMirrorPlugins(){return[new fE({key:new fH("clearDocument"),appendTransaction:(a,b,c)=>{if(a.some(a=>a.getMeta("composition")))return;let d=a.some(a=>a.docChanged)&&!b.doc.eq(c.doc),e=a.some(a=>a.getMeta("preventClearDocument"));if(!d||e)return;let{empty:f,from:g,to:h}=b.selection,i=fm.atStart(b.doc).from,j=fm.atEnd(b.doc).to;if(f||g!==i||h!==j||!le(c.doc))return;let k=c.tr,l=jM({state:c,transaction:k}),{commands:m}=new jN({editor:this.editor,state:l});if(m.clearNodes(),k.steps.length)return k}})]}}),lZ=lQ.create({name:"paste",addProseMirrorPlugins(){return[new fE({key:new fH("tiptapPaste"),props:{handlePaste:(a,b,c)=>{this.editor.emit("paste",{editor:this.editor,event:b,slice:c})}}})]}}),l$=lQ.create({name:"tabindex",addOptions:()=>({value:void 0}),addProseMirrorPlugins(){return[new fE({key:new fH("tabindex"),props:{attributes:()=>{var a;return this.editor.isEditable||void 0!==this.options.value?{tabindex:null!=(a=this.options.value)?a:"0"}:{}}}})]}}),l_=lQ.create({name:"textDirection",addOptions:()=>({direction:void 0}),addGlobalAttributes(){if(!this.options.direction)return[];let{nodeExtensions:a}=kV(this.extensions);return[{types:a.filter(a=>"text"!==a.name).map(a=>a.name),attributes:{dir:{default:this.options.direction,parseHTML:a=>{let b=a.getAttribute("dir");return b&&("ltr"===b||"rtl"===b||"auto"===b)?b:this.options.direction},renderHTML:a=>a.dir?{dir:a.dir}:{}}}}]},addProseMirrorPlugins(){return[new fE({key:new fH("textDirection"),props:{attributes:()=>{let a=this.options.direction;return a?{dir:a}:{}}}})]}}),l0=class a{constructor(a,b,c=!1,d=null){this.currentNode=null,this.actualDepth=null,this.isBlock=c,this.resolvedPos=a,this.editor=b,this.currentNode=d}get name(){return this.node.type.name}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var a;return null!=(a=this.actualDepth)?a:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(a){let b=this.from,c=this.to;if(this.isBlock){if(0===this.content.size)return void console.error(`You can\u2019t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);b=this.from+1,c=this.to-1}this.editor.commands.insertContentAt({from:b,to:c},a)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+ +!this.node.isText}get parent(){if(0===this.depth)return null;let b=this.resolvedPos.start(this.resolvedPos.depth-1);return new a(this.resolvedPos.doc.resolve(b),this.editor)}get before(){let b=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return b.depth!==this.depth&&(b=this.resolvedPos.doc.resolve(this.from-3)),new a(b,this.editor)}get after(){let b=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return b.depth!==this.depth&&(b=this.resolvedPos.doc.resolve(this.to+3)),new a(b,this.editor)}get children(){let b=[];return this.node.content.forEach((c,d)=>{let e=c.isBlock&&!c.isTextblock,f=c.isAtom&&!c.isText,g=c.isInline,h=this.pos+d+ +!f;if(h<0||h>this.resolvedPos.doc.nodeSize-2)return;let i=this.resolvedPos.doc.resolve(h);if(!e&&!g&&i.depth<=this.depth)return;let j=new a(i,this.editor,e,e||g?c:null);e&&(j.actualDepth=this.depth+1),b.push(j)}),b}get firstChild(){return this.children[0]||null}get lastChild(){let a=this.children;return a[a.length-1]||null}closest(a,b={}){let c=null,d=this.parent;for(;d&&!c;){if(d.node.type.name===a)if(Object.keys(b).length>0){let a=d.node.attrs,c=Object.keys(b);for(let d=0;d<c.length;d+=1){let e=c[d];if(a[e]!==b[e])break}}else c=d;d=d.parent}return c}querySelector(a,b={}){return this.querySelectorAll(a,b,!0)[0]||null}querySelectorAll(a,b={},c=!1){let d=[];if(!this.children||0===this.children.length)return d;let e=Object.keys(b);return this.children.forEach(f=>{c&&d.length>0||(f.node.type.name===a&&e.every(a=>b[a]===f.node.attrs[a])&&d.push(f),c&&d.length>0||(d=d.concat(f.querySelectorAll(a,b,c))))}),d}setAttribute(a){let{tr:b}=this.editor.state;b.setNodeMarkup(this.from,void 0,{...this.node.attrs,...a}),this.editor.view.dispatch(b)}},l1=`.ProseMirror {
|
|
21
|
+
${b}/api/agent/files/${a??"<path/to/file.md>"}`;await navigator.clipboard.writeText(d),c(!0),setTimeout(()=>c(!1),1500)},[a])}}(a??null),[k,l]=(0,p.useState)(""),m=(0,p.useRef)(null),n="http://localhost:3000",q=(0,p.useCallback)(()=>bQ,[]),s=(0,p.useCallback)(()=>k.replace(/\$WIKI_URL/g,n),[k,n]),t=(0,p.useCallback)(()=>`npx wiki-viewer-mcp register --url ${n} --id ai:myagent --name "My Agent"`,[n]),v=(0,p.useCallback)(()=>JSON.stringify({servers:{"wiki-viewer":{command:"npx",args:["wiki-viewer-mcp"],env:{WIKI_VIEWER_URL:n,WIKI_VIEWER_TOKEN:"<token from register>",WIKI_VIEWER_AGENT_ID:"ai:myagent"}}}},null,2),[n]),w=bR(q),x=bR(s),y=bR(t),z=bR(v);return((0,p.useEffect)(()=>{if(b)return document.addEventListener("keydown",a),()=>document.removeEventListener("keydown",a);function a(a){"Escape"===a.key&&c()}},[b,c]),(0,p.useEffect)(()=>{b&&m.current?.focus()},[b]),(0,p.useEffect)(()=>{if(!b)return;f();let a=setInterval(()=>void f(),1e4);return()=>clearInterval(a)},[b,f]),(0,p.useEffect)(()=>{b&&fetch((0,au.apiUrl)("/api/agents/install")).then(a=>a.json()).then(a=>{a.bootstrapPrompt&&l(a.bootstrapPrompt)}).catch(()=>void 0)},[b]),b)?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("div",{className:"fixed inset-0 z-40 bg-overlay backdrop-blur-[1px]",onClick:c,"aria-hidden":!0}),(0,g.jsxs)("aside",{ref:m,tabIndex:-1,role:"dialog","aria-modal":"true","aria-label":"AI Agent Panel",className:"fixed right-0 top-0 bottom-0 z-50 flex w-[90vw] max-w-sm md:w-80 flex-col border-l border-border bg-background shadow-xl outline-none",children:[(0,g.jsxs)("div",{className:"flex items-center justify-between border-b border-border px-4 py-3 shrink-0",children:[(0,g.jsxs)("div",{className:"flex items-center gap-2",children:[(0,g.jsx)(i,{className:"h-4 w-4 text-muted-foreground"}),(0,g.jsx)("span",{className:"text-sm font-semibold",children:"AI Agent"})]}),(0,g.jsx)(u.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:c,title:"Close panel (Esc)",children:(0,g.jsx)(o,{className:"h-3.5 w-3.5"})})]}),(0,g.jsxs)("div",{className:"flex-1 overflow-y-auto space-y-5 px-4 py-4",children:[(0,g.jsxs)("section",{className:"rounded-md border border-border bg-muted/30 p-3",children:[(0,g.jsx)("p",{className:"text-sm font-medium text-foreground",children:"Work with this wiki using AI"}),(0,g.jsxs)("p",{className:"mt-1 text-xs leading-relaxed text-muted-foreground",children:["Connect Claude, Cursor, ChatGPT, and more. Pick by what you want — each option gives a copy-paste setup. You approve every assistant in ",(0,g.jsx)("span",{className:"font-medium text-foreground/80",children:"Agents"})," below before it gets access."]})]}),(0,g.jsxs)("section",{className:"space-y-3",children:[(0,g.jsxs)("div",{className:"rounded-md border border-border bg-muted/40 p-3 space-y-1.5",children:[(0,g.jsx)("p",{className:"text-xs font-semibold text-foreground",children:"Co-write docs with you"}),(0,g.jsx)("p",{className:"text-[10px] text-muted-foreground/70",children:"Edits arrive as suggestions with comments you accept or revert. No MCP needed."}),(0,g.jsx)(u.Button,{size:"sm",variant:"outline",className:"h-7 w-full text-xs gap-1.5",onClick:()=>void x.copy(),disabled:!k,children:x.copied?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(r.Check,{className:"h-3.5 w-3.5 text-green-500"})," Copied!"]}):(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(aY.Copy,{className:"h-3.5 w-3.5"})," Paste into any chatbot"]})}),(0,g.jsxs)("p",{className:"text-[10px] text-muted-foreground/50 pt-1",children:["Or install once so it sticks"," ",(0,g.jsx)("span",{className:"text-muted-foreground/40",children:"· Claude, OpenCode"}),":"]}),(0,g.jsxs)("div",{className:"flex items-center gap-2",children:[(0,g.jsx)("code",{className:"flex-1 text-[10px] font-mono text-foreground/80 truncate bg-muted rounded px-1 py-0.5",children:bQ}),(0,g.jsx)(u.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0 shrink-0",title:"Copy this command",onClick:()=>void w.copy(),children:w.copied?(0,g.jsx)(r.Check,{className:"h-3.5 w-3.5 text-green-500"}):(0,g.jsx)(aY.Copy,{className:"h-3.5 w-3.5"})})]})]}),(0,g.jsxs)("div",{className:"rounded-md border border-border bg-muted/40 p-3 space-y-1.5",children:[(0,g.jsxs)("p",{className:"text-xs font-semibold text-foreground",children:["Edit files directly"," ",(0,g.jsx)("span",{className:"font-normal text-muted-foreground/60",children:"· Claude Code, Cursor, Codex"})]}),(0,g.jsx)("p",{className:"text-[10px] text-muted-foreground/70",children:"Native read / search / edit tools over MCP. Run to request access:"}),(0,g.jsxs)("div",{className:"flex items-center gap-2",children:[(0,g.jsx)("code",{className:"flex-1 text-[10px] font-mono text-foreground/80 truncate bg-muted rounded px-1 py-0.5",children:t()}),(0,g.jsx)(u.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0 shrink-0",title:"Copy this command",onClick:()=>void y.copy(),children:y.copied?(0,g.jsx)(r.Check,{className:"h-3.5 w-3.5 text-green-500"}):(0,g.jsx)(aY.Copy,{className:"h-3.5 w-3.5"})})]}),(0,g.jsxs)("p",{className:"text-[10px] text-muted-foreground/50",children:["Approve in ",(0,g.jsx)("span",{className:"font-medium text-foreground/70",children:"Agents"}),", then add to your tool:"]}),(0,g.jsx)(u.Button,{size:"sm",variant:"outline",className:"h-7 w-full text-xs gap-1.5",onClick:()=>void z.copy(),children:z.copied?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(r.Check,{className:"h-3.5 w-3.5 text-green-500"})," Copied!"]}):(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(aY.Copy,{className:"h-3.5 w-3.5"})," Copy config (mcp.json)"]})})]}),(0,g.jsxs)("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[(0,g.jsx)("span",{className:"text-[10px] text-muted-foreground/50",children:"For developers:"}),(0,g.jsxs)("button",{type:"button",onClick:()=>void j(),className:"inline-flex items-center gap-1 text-[10px] text-primary hover:underline",children:[h?(0,g.jsx)(r.Check,{className:"h-3 w-3 text-green-500"}):(0,g.jsx)(aY.Copy,{className:"h-3 w-3"})," curl example"]}),(0,g.jsxs)("a",{href:(0,au.apiUrl)("/api/agents/skill"),target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 text-[10px] text-primary hover:underline",children:[(0,g.jsx)(bn,{className:"h-3 w-3"})," skill"]}),(0,g.jsxs)("a",{href:(0,au.apiUrl)("/api/agents/install"),target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 text-[10px] text-primary hover:underline",children:[(0,g.jsx)(bn,{className:"h-3 w-3"})," install JSON"]})]})]}),(0,g.jsx)(bw,{}),(0,g.jsxs)("section",{className:"space-y-2",children:[(0,g.jsxs)("h3",{className:"text-xs font-semibold uppercase tracking-widest text-muted-foreground",children:["Active Connections"," ",(0,g.jsx)("span",{className:"normal-case font-normal text-muted-foreground/50",children:"(last 5 min)"})]}),(0,g.jsx)("div",{className:"rounded-md border border-border bg-muted/40 p-3",children:0===e.length?(0,g.jsxs)("p",{className:"text-xs text-muted-foreground/60 flex items-center gap-1.5",children:[(0,g.jsx)(bm,{className:"h-3.5 w-3.5"}),"No recent activity"]}):(0,g.jsx)("ul",{className:"space-y-1.5",children:e.map(a=>(0,g.jsxs)("li",{className:"flex items-center justify-between text-xs",children:[(0,g.jsx)("span",{className:"font-mono text-foreground/80 truncate",children:a.by}),(0,g.jsxs)("span",{className:"text-muted-foreground shrink-0",children:[a.opCount," op",1!==a.opCount?"s":""]})]},a.by))})})]}),(0,g.jsxs)("section",{className:"space-y-2",children:[(0,g.jsx)("h3",{className:"text-xs font-semibold uppercase tracking-widest text-muted-foreground",children:"Recent Activity"}),(0,g.jsx)("div",{className:"rounded-md border border-border bg-muted/40 px-3 py-2 max-h-72 overflow-y-auto",children:(0,g.jsx)(bP,{activity:d})})]}),(0,g.jsx)("section",{children:(0,g.jsx)("a",{href:(0,au.apiUrl)("/docs/agent-collab-plan.md"),target:"_blank",rel:"noreferrer",className:"text-xs text-primary underline hover:no-underline",children:"Agent collaboration docs →"})})]})]})]}):null}let bT=(0,h.default)("link",[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]]),bU=(0,h.default)("ellipsis",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]]);var bV=a.i(335732),bW=a.i(765021);let bX=(0,h.default)("file",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}]]),bY=(0,h.default)("file-plus",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M9 15h6",key:"cctwl0"}],["path",{d:"M12 18v-6",key:"17g6i2"}]]),bZ=(0,h.default)("folder-plus",[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]),b$=(0,h.default)("terminal",[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]]),b_=(0,h.default)("upload",[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]]);function b0({pos:a,branches:b,loading:c,busyName:d,disabled:e,onPick:f,onClose:h}){let[i,j]=(0,p.useState)(""),k=(0,p.useRef)(null);if((0,p.useEffect)(()=>{let a=a=>{let b=a.target;k.current?.contains(b)||b?.closest?.("[data-branch-trigger]")||h()},b=a=>{"Escape"===a.key&&h()};return document.addEventListener("mousedown",a),document.addEventListener("keydown",b),()=>{document.removeEventListener("mousedown",a),document.removeEventListener("keydown",b)}},[h]),"u"<typeof document)return null;let l=b.length>8,n=i.trim().toLowerCase(),o=n?b.filter(a=>a.name.toLowerCase().includes(n)):b;return(0,bd.createPortal)((0,g.jsx)("div",{ref:k,"data-branch-portal":!0,style:{position:"fixed",top:a.top,left:a.left},className:"pointer-events-auto z-[9999] flex max-h-72 w-52 flex-col overflow-hidden rounded-md border bg-popover p-1 shadow-md",children:c?(0,g.jsx)("div",{className:"flex justify-center py-2",children:(0,g.jsx)(m.Loader2,{className:"h-3.5 w-3.5 animate-spin text-muted-foreground"})}):0===b.length?(0,g.jsx)("p",{className:"px-2 py-1 text-[10px] text-muted-foreground",children:"No branches"}):(0,g.jsxs)(g.Fragment,{children:[l&&(0,g.jsx)("input",{autoFocus:!0,value:i,onChange:a=>j(a.target.value),placeholder:"Filter branches…",className:"mb-1 w-full shrink-0 rounded border bg-background px-1.5 py-1 text-[11px] outline-none focus:ring-1 focus:ring-ring"}),(0,g.jsx)("div",{className:"min-h-0 flex-1 overflow-auto",children:0===o.length?(0,g.jsx)("p",{className:"px-2 py-1 text-[10px] text-muted-foreground",children:"No match"}):o.map(a=>(0,g.jsxs)("button",{type:"button",disabled:e||a.current,className:(0,an.cn)("flex w-full items-center gap-1.5 rounded px-2 py-1 text-left text-[11px] hover:bg-muted",a.current?"font-semibold text-foreground":"text-muted-foreground"),onClick:b=>{b.stopPropagation(),a.current||f(a.name)},children:[a.current?(0,g.jsx)(r.Check,{className:"h-3 w-3 shrink-0"}):(0,g.jsx)("span",{className:"w-3 shrink-0"}),(0,g.jsx)("span",{className:"truncate",children:a.name}),d===a.name&&(0,g.jsx)(m.Loader2,{className:"ml-auto h-3 w-3 shrink-0 animate-spin"})]},a.name))})]})}),document.body)}var b1=a.i(280370),b2=a.i(385909),b3="ContextMenu",[b4,b5]=(0,x.createContextScope)(b3,[b1.createMenuScope]),b6=(0,b1.createMenuScope)(),[b7,b8]=b4(b3),b9=a=>{let{__scopeContextMenu:b,children:c,onOpenChange:d,dir:e,modal:f=!0}=a,[h,i]=p.useState(!1),j=b6(b),k=(0,b2.useCallbackRef)(d),l=p.useCallback(a=>{i(a),k(a)},[k]);return(0,g.jsx)(b7,{scope:b,open:h,onOpenChange:l,modal:f,children:(0,g.jsx)(b1.Root,{...j,dir:e,open:h,onOpenChange:l,modal:f,children:c})})};b9.displayName=b3;var ca="ContextMenuTrigger",cb=p.forwardRef((a,b)=>{let{__scopeContextMenu:c,disabled:d=!1,...e}=a,f=b8(ca,c),h=b6(c),i=p.useRef({x:0,y:0}),j=p.useRef({getBoundingClientRect:()=>DOMRect.fromRect({width:0,height:0,...i.current})}),k=p.useRef(0),l=p.useCallback(()=>window.clearTimeout(k.current),[]),m=a=>{i.current={x:a.clientX,y:a.clientY},f.onOpenChange(!0)};return p.useEffect(()=>l,[l]),p.useEffect(()=>void(d&&l()),[d,l]),(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(b1.Anchor,{...h,virtualRef:j}),(0,g.jsx)(E.Primitive.span,{"data-state":f.open?"open":"closed","data-disabled":d?"":void 0,...e,ref:b,style:{WebkitTouchCallout:"none",...a.style},onContextMenu:d?a.onContextMenu:(0,v.composeEventHandlers)(a.onContextMenu,a=>{l(),m(a),a.preventDefault()}),onPointerDown:d?a.onPointerDown:(0,v.composeEventHandlers)(a.onPointerDown,cn(a=>{l(),k.current=window.setTimeout(()=>m(a),700)})),onPointerMove:d?a.onPointerMove:(0,v.composeEventHandlers)(a.onPointerMove,cn(l)),onPointerCancel:d?a.onPointerCancel:(0,v.composeEventHandlers)(a.onPointerCancel,cn(l)),onPointerUp:d?a.onPointerUp:(0,v.composeEventHandlers)(a.onPointerUp,cn(l))})]})});cb.displayName=ca;var cc=a=>{let{__scopeContextMenu:b,...c}=a,d=b6(b);return(0,g.jsx)(b1.Portal,{...d,...c})};cc.displayName="ContextMenuPortal";var cd="ContextMenuContent",ce=p.forwardRef((a,b)=>{let{__scopeContextMenu:c,...d}=a,e=b8(cd,c),f=b6(c),h=p.useRef(!1);return(0,g.jsx)(b1.Content,{...f,...d,ref:b,side:"right",sideOffset:2,align:"start",onCloseAutoFocus:b=>{a.onCloseAutoFocus?.(b),!b.defaultPrevented&&h.current&&b.preventDefault(),h.current=!1},onInteractOutside:b=>{a.onInteractOutside?.(b),b.defaultPrevented||e.modal||(h.current=!0)},style:{...a.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});ce.displayName=cd,p.forwardRef((a,b)=>{let{__scopeContextMenu:c,...d}=a,e=b6(c);return(0,g.jsx)(b1.Group,{...e,...d,ref:b})}).displayName="ContextMenuGroup";var cf=p.forwardRef((a,b)=>{let{__scopeContextMenu:c,...d}=a,e=b6(c);return(0,g.jsx)(b1.Label,{...e,...d,ref:b})});cf.displayName="ContextMenuLabel";var cg=p.forwardRef((a,b)=>{let{__scopeContextMenu:c,...d}=a,e=b6(c);return(0,g.jsx)(b1.Item,{...e,...d,ref:b})});cg.displayName="ContextMenuItem";var ch=p.forwardRef((a,b)=>{let{__scopeContextMenu:c,...d}=a,e=b6(c);return(0,g.jsx)(b1.CheckboxItem,{...e,...d,ref:b})});ch.displayName="ContextMenuCheckboxItem",p.forwardRef((a,b)=>{let{__scopeContextMenu:c,...d}=a,e=b6(c);return(0,g.jsx)(b1.RadioGroup,{...e,...d,ref:b})}).displayName="ContextMenuRadioGroup";var ci=p.forwardRef((a,b)=>{let{__scopeContextMenu:c,...d}=a,e=b6(c);return(0,g.jsx)(b1.RadioItem,{...e,...d,ref:b})});ci.displayName="ContextMenuRadioItem";var cj=p.forwardRef((a,b)=>{let{__scopeContextMenu:c,...d}=a,e=b6(c);return(0,g.jsx)(b1.ItemIndicator,{...e,...d,ref:b})});cj.displayName="ContextMenuItemIndicator";var ck=p.forwardRef((a,b)=>{let{__scopeContextMenu:c,...d}=a,e=b6(c);return(0,g.jsx)(b1.Separator,{...e,...d,ref:b})});ck.displayName="ContextMenuSeparator",p.forwardRef((a,b)=>{let{__scopeContextMenu:c,...d}=a,e=b6(c);return(0,g.jsx)(b1.Arrow,{...e,...d,ref:b})}).displayName="ContextMenuArrow";var cl=p.forwardRef((a,b)=>{let{__scopeContextMenu:c,...d}=a,e=b6(c);return(0,g.jsx)(b1.SubTrigger,{...e,...d,ref:b})});cl.displayName="ContextMenuSubTrigger";var cm=p.forwardRef((a,b)=>{let{__scopeContextMenu:c,...d}=a,e=b6(c);return(0,g.jsx)(b1.SubContent,{...e,...d,ref:b,style:{...a.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});function cn(a){return b=>"mouse"!==b.pointerType?a(b):void 0}cm.displayName="ContextMenuSubContent";var co=a.i(694079);p.forwardRef(({className:a,inset:b,children:c,...d},e)=>(0,g.jsxs)(cl,{ref:e,className:(0,an.cn)("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",b&&"pl-8",a),...d,children:[c,(0,g.jsx)(aO.ChevronRight,{className:"ml-auto h-4 w-4"})]})).displayName=cl.displayName,p.forwardRef(({className:a,...b},c)=>(0,g.jsx)(cm,{ref:c,className:(0,an.cn)("z-50 min-w-[8rem] overflow-hidden rounded-sm border bg-popover p-1 text-popover-foreground shadow-golden data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",a),...b})).displayName=cm.displayName;let cp=p.forwardRef(({className:a,...b},c)=>(0,g.jsx)(cc,{children:(0,g.jsx)(ce,{ref:c,className:(0,an.cn)("z-50 min-w-[8rem] overflow-hidden rounded-sm border bg-popover p-1 text-popover-foreground shadow-golden data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",a),...b})}));cp.displayName=ce.displayName;let cq=p.forwardRef(({className:a,inset:b,...c},d)=>(0,g.jsx)(cg,{ref:d,className:(0,an.cn)("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",b&&"pl-8",a),...c}));cq.displayName=cg.displayName,p.forwardRef(({className:a,children:b,checked:c,...d},e)=>(0,g.jsxs)(ch,{ref:e,className:(0,an.cn)("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",a),checked:c,...d,children:[(0,g.jsx)("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,g.jsx)(cj,{children:(0,g.jsx)(r.Check,{className:"h-4 w-4"})})}),b]})).displayName=ch.displayName,p.forwardRef(({className:a,children:b,...c},d)=>(0,g.jsxs)(ci,{ref:d,className:(0,an.cn)("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",a),...c,children:[(0,g.jsx)("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,g.jsx)(cj,{children:(0,g.jsx)(co.Circle,{className:"h-2 w-2 fill-current"})})}),b]})).displayName=ci.displayName,p.forwardRef(({className:a,inset:b,...c},d)=>(0,g.jsx)(cf,{ref:d,className:(0,an.cn)("px-2 py-1.5 text-sm font-normal",b&&"pl-8",a),...c})).displayName=cf.displayName;let cr=p.forwardRef(({className:a,...b},c)=>(0,g.jsx)(ck,{ref:c,className:(0,an.cn)("-mx-1 my-1 h-px bg-muted",a),...b}));cr.displayName=ck.displayName;let cs=(0,aw.create)((a,b)=>({humanize:!1,toggle:()=>{a({humanize:!b().humanize})}})),ct=(0,aw.create)((a,b)=>({showHidden:!1,toggle:()=>{a({showHidden:!b().showHidden})}}));function cu(a){return a.split(".").pop()?.toLowerCase()??""}function cv(a,b){if("node-app"===b)return"node-app";if("app"===b)return"app";if("dir"===b)return"fallback";let c=a.split("/").pop()??a;if(c.startsWith(".")&&-1===c.indexOf(".",1))return"source";let d=cu(a);return d?["md","markdown"].includes(d)?"editor":"txt"===d?"text":["csv","tsv"].includes(d)?"csv":"pdf"===d?"pdf":["mmd","mermaid"].includes(d)?"mermaid":"ipynb"===d?"notebook":["png","jpg","jpeg","gif","webp","svg","avif","ico","bmp"].includes(d)?"image":["mp4","webm","mov","m4v","mp3","wav","ogg","m4a","aac"].includes(d)?"media":"docx"===d?"docx":["xlsx","xlsm"].includes(d)?"xlsx":"pptx"===d?"pptx":"html"===d?"html":(["py","js","ts","tsx","jsx","go","rs","java","c","cpp","h","sh","bash","zsh","rb","php","swift","kt","lua","sql","yaml","yml","toml","json","xml","css","scss"].includes(d),"source"):"source"}let cw=new Set(["txt","md","markdown","json","yaml","yml","toml","csv","tsv","xml","html","css","js","ts","tsx","jsx","sh","bash","zsh","rb","py","go","rs","java","c","cpp","h","php","swift","kt","lua","sql","scss","mmd","mermaid","ini","env","log","conf"]);function cx(a){let b=cv(a,"file");return"editor"===b||"text"===b||cw.has(cu(a))}function cy(a){return["md","markdown"].includes(cu(a))}function cz(a){return"image"===cv(a,"file")}function cA(a){return"html"===cv(a,"file")}let cB={contentVisibility:"auto",containIntrinsicSize:"auto 32px"};function cC({node:a,ctx:b,isPinned:c,activeWorkspaceId:d}){return(0,g.jsxs)(cp,{className:"w-48",children:[(0,g.jsxs)(cq,{onSelect:()=>b.copyPath(a.path),children:[(0,g.jsx)(aY.Copy,{className:"mr-2 h-3.5 w-3.5"}),"Copy path"]}),cy(a.name)&&(0,g.jsxs)(cq,{onSelect:()=>b.copyWikiLink(a.name),children:[(0,g.jsx)(j.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy wiki link"]}),(0,g.jsxs)(cq,{onSelect:()=>b.copyUrl(a.path),children:[(0,g.jsx)(bT,{className:"mr-2 h-3.5 w-3.5"}),"Copy URL"]}),"file"===a.type&&cx(a.name)&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(cq,{onSelect:()=>b.copyRawContent(a.path),children:[(0,g.jsx)(j.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy raw content"]}),(0,g.jsxs)(cq,{onSelect:()=>b.copyFormattedContent(a.path,a.name),children:[(0,g.jsx)(j.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy formatted content"]})]}),(0,g.jsx)(cr,{}),"dir"===a.type&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(cq,{onSelect:()=>{a.expanded||b.toggleFolder(a),b.setNewFileParent(a.path),b.setNewFileName(""),b.setFileCreateError(null)},children:[(0,g.jsx)(bY,{className:"mr-2 h-3.5 w-3.5"}),"New file here"]}),(0,g.jsxs)(cq,{onSelect:()=>b.triggerUpload(a.path),children:[(0,g.jsx)(b_,{className:"mr-2 h-3.5 w-3.5"}),"Upload here"]}),(0,g.jsxs)(cq,{onSelect:()=>{b.setNewFolderParent(a.path),b.setNewFolderName(""),b.setFolderError(null)},children:[(0,g.jsx)(bZ,{className:"mr-2 h-3.5 w-3.5"}),"New subfolder"]}),(0,g.jsx)(cr,{})]}),(0,g.jsxs)(cq,{onSelect:()=>b.handleDownload(a),children:[(0,g.jsx)(bW.Download,{className:"mr-2 h-3.5 w-3.5"}),"file"===a.type?"Download":"Download as zip"]}),(0,g.jsxs)(cq,{onSelect:()=>b.togglePin(a,d),children:[(0,g.jsx)(aV,{className:(0,an.cn)("mr-2 h-3.5 w-3.5",c&&"fill-current text-amber-400")}),c?"Unpin":"Pin to top"]}),(0,g.jsx)(cr,{}),(0,g.jsxs)(cq,{className:"text-destructive focus:text-destructive",onSelect:()=>{b.setDeletingPath(a.path),b.setDeletingIsDir("file"!==a.type)},children:[(0,g.jsx)(a$,{className:"mr-2 h-3.5 w-3.5"}),"Delete"]})]})}function cD({name:a,type:b}){let c="h-3.5 w-3.5 shrink-0";return"dir"===b?(0,g.jsx)(aP,{className:(0,an.cn)(c,"text-warning")}):"app"===b?(0,g.jsx)(k,{className:(0,an.cn)(c,"text-foreground/70")}):"node-app"===b?(0,g.jsx)(b$,{className:(0,an.cn)(c,"text-emerald-500")}):cA(a)?(0,g.jsx)(k,{className:(0,an.cn)(c,"text-foreground/60")}):cz(a)?(0,g.jsx)(l,{className:(0,an.cn)(c,"text-sunshine-700")}):cx(a)?(0,g.jsx)(j.FileText,{className:(0,an.cn)(c,"text-foreground/70")}):(0,g.jsx)(bX,{className:(0,an.cn)(c,"text-foreground/60")})}let cE=(0,p.memo)(function({node:a,depth:b,ctx:c,isMobile:d,activeWorkspaceId:e,sidebarScrollRef:f,isActive:h,isDragOver:i,isPinned:n,isAgentActive:o,isPulling:p,branchOpen:q,branchPos:r,branches:s,branchLoading:t,checkingOut:v,onHoverEnter:w,onHoverLeave:x}){var y;let z,A,B,C,D,E=cs(a=>a.humanize);return(0,g.jsxs)(b9,{children:[(0,g.jsx)(cb,{asChild:!0,children:(0,g.jsxs)("div",{role:"treeitem",tabIndex:0,draggable:!d,onKeyDown:d=>{if("Enter"===d.key||" "===d.key)d.preventDefault(),"dir"===a.type?c.toggleFolder(a):"app"===a.type||"node-app"===a.type?(c.openViewer(a),c.toggleFolder(a)):c.openViewer(a);else if("ArrowDown"===d.key){d.preventDefault();let a=f.current;if(!a)return;let b=Array.from(a.querySelectorAll('[role="treeitem"]')),c=b.indexOf(d.currentTarget);b[c+1]?.focus()}else if("ArrowUp"===d.key){d.preventDefault();let a=f.current;if(!a)return;let b=Array.from(a.querySelectorAll('[role="treeitem"]')),c=b.indexOf(d.currentTarget);b[c-1]?.focus()}else if("ArrowRight"===d.key){if(d.preventDefault(),"dir"===a.type||"app"===a.type||"node-app"===a.type)if(a.expanded){let a=f.current;if(!a)return;let b=Array.from(a.querySelectorAll('[role="treeitem"]')),c=b.indexOf(d.currentTarget);b[c+1]?.focus()}else c.toggleFolder(a)}else if("ArrowLeft"===d.key){if(d.preventDefault(),("dir"===a.type||"app"===a.type||"node-app"===a.type)&&a.expanded)c.toggleFolder(a);else if(b>0){let a=f.current;if(!a)return;let b=Array.from(a.querySelectorAll('[role="treeitem"]')),c=d.currentTarget,e=b.indexOf(c),g=Number.parseInt(c.style.paddingLeft??"0",10);for(let a=e-1;a>=0;a--)if(Number.parseInt(b[a].style.paddingLeft??"0",10)<g){b[a].focus();break}}}},onDragStart:b=>c.handleDragStart(b,a),onDragOver:b=>"dir"===a.type?c.handleDragOver(b,a.path,"dir"):b.preventDefault(),onDragLeave:()=>c.setDragOverPath(null),onDrop:b=>"dir"===a.type?c.handleDropOnFolder(b,a.path):b.preventDefault(),onMouseEnter:()=>w(a),onMouseLeave:x,className:(0,an.cn)("tree-row-reveal flex items-center gap-1.5 rounded-sm px-2 py-1 text-sm cursor-pointer group transition-colors select-none touch-target",h?"bg-accent-soft text-foreground font-medium":"hover:bg-muted",i&&"ring-2 ring-primary bg-primary-soft",a.name.startsWith(".")&&"opacity-40"),style:{paddingLeft:`${14*b+8}px`,...cB},onClick:()=>{"dir"===a.type?c.toggleFolder(a):("app"===a.type||"node-app"===a.type?(c.openViewer(a),c.toggleFolder(a)):c.openViewer(a),d&&c.setSidebarCollapsed(!0))},children:["dir"===a.type||"app"===a.type||"node-app"===a.type?a.loading?(0,g.jsx)(m.Loader2,{className:"h-3.5 w-3.5 shrink-0 animate-spin text-muted-foreground"}):(0,g.jsx)(aO.ChevronRight,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground transition-transform duration-200 ease-out",style:{transform:a.expanded?"rotate(90deg)":"rotate(0deg)"}}):(0,g.jsx)("span",{className:"w-3.5 shrink-0"}),(0,g.jsx)("span",{className:"editorial-tree-typeicon",children:"dir"===a.type?a.expanded?(0,g.jsx)(aQ,{className:(0,an.cn)("h-4 w-4 shrink-0",!h&&"text-warning")}):(0,g.jsx)(aP,{className:(0,an.cn)("h-4 w-4 shrink-0",!h&&"text-warning")}):"app"===a.type?(0,g.jsx)(k,{className:(0,an.cn)("h-4 w-4 shrink-0",!h&&"text-foreground/70")}):"node-app"===a.type?(0,g.jsx)(b$,{className:(0,an.cn)("h-4 w-4 shrink-0",!h&&"text-emerald-500")}):cA(a.name)?(0,g.jsx)(k,{className:(0,an.cn)("h-4 w-4 shrink-0",!h&&"text-foreground/60")}):cz(a.name)?(0,g.jsx)(l,{className:(0,an.cn)("h-4 w-4 shrink-0",!h&&"text-sunshine-700")}):cx(a.name)?(0,g.jsx)(j.FileText,{className:(0,an.cn)("h-4 w-4 shrink-0",!h&&"text-foreground/70")}):(0,g.jsx)(bX,{className:(0,an.cn)("h-4 w-4 shrink-0",!h&&"text-foreground/60")})}),(0,g.jsx)("span",{className:"min-w-0 flex-1 truncate",title:E?a.name:void 0,children:E?(B=(A=(z=(y=a.name).lastIndexOf("."))>0&&z<y.length-1)?y.slice(0,z):y,C=A?y.slice(z):"",(D=B.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").split(/[\s_-]+/).filter(Boolean).map(a=>/^[A-Z0-9]+$/.test(a)?a:a[0].toUpperCase()+a.slice(1))).length?D.join(" ")+C:y):a.name}),a.git&&(0,g.jsxs)("span",{className:"relative flex shrink-0 items-center gap-0.5 rounded-sm bg-muted px-1 py-0.5 text-[10px] text-muted-foreground",children:[(0,g.jsxs)("button",{"data-branch-trigger":!0,type:"button",className:"flex items-center gap-0.5 hover:text-foreground",title:"Switch branch",onClick:b=>{if(b.stopPropagation(),q){c.setBranchDropdownNode(null),c.setBranchDropdownPos(null);return}let d=b.currentTarget.getBoundingClientRect();c.setBranchDropdownPos({top:d.bottom+4,left:d.left}),c.setBranchDropdownNode(a.path),c.loadBranches(a.path)},children:[(0,g.jsx)(aR,{className:"h-2.5 w-2.5"}),a.git.branch,a.git.dirty&&(0,g.jsx)("span",{className:"ml-0.5 text-warning",children:"*"})]}),p?(0,g.jsx)(m.Loader2,{className:"ml-0.5 h-2.5 w-2.5 animate-spin"}):(0,g.jsx)("button",{type:"button",onClick:b=>{b.stopPropagation();let d=a.path.includes("/")?a.path.substring(0,a.path.lastIndexOf("/")):"";c.handleGitPull(a.path,d)},className:"ml-0.5 text-muted-foreground hover:text-foreground",title:"Pull latest",children:(0,g.jsx)(br,{className:"h-2.5 w-2.5"})}),q&&r&&(0,g.jsx)(b0,{pos:r,branches:s,loading:t,busyName:v,disabled:null!==v,onPick:b=>{let d=a.path.includes("/")?a.path.substring(0,a.path.lastIndexOf("/")):"";c.handleCheckout(a.path,b,d)},onClose:()=>{c.setBranchDropdownNode(null),c.setBranchDropdownPos(null)}})]}),o&&(0,g.jsx)("span",{className:"ml-0.5 h-1.5 w-1.5 rounded-full bg-emerald-400 shrink-0 animate-pulse",title:"Agent recently active"}),(0,g.jsx)("div",{className:"hover-reveal flex max-w-0 shrink-0 items-center overflow-hidden opacity-0 transition-all duration-150 group-hover:max-w-7 group-hover:opacity-100 focus-within:max-w-7 focus-within:opacity-100",onClick:a=>a.stopPropagation(),onKeyDown:a=>a.stopPropagation(),children:(0,g.jsxs)(bV.DropdownMenu,{children:[(0,g.jsx)(bV.DropdownMenuTrigger,{asChild:!0,children:(0,g.jsx)(u.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0 text-muted-foreground hover:text-foreground",title:"File actions",children:(0,g.jsx)(bU,{className:"h-3.5 w-3.5"})})}),(0,g.jsxs)(bV.DropdownMenuContent,{align:"end",className:"w-48",children:[(0,g.jsxs)(bV.DropdownMenuItem,{onClick:()=>c.copyPath(a.path),children:[(0,g.jsx)(aY.Copy,{className:"mr-2 h-3.5 w-3.5"}),"Copy path"]}),cy(a.name)&&(0,g.jsxs)(bV.DropdownMenuItem,{onClick:()=>c.copyWikiLink(a.name),children:[(0,g.jsx)(j.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy wiki link"]}),(0,g.jsxs)(bV.DropdownMenuItem,{onClick:()=>c.copyUrl(a.path),children:[(0,g.jsx)(bT,{className:"mr-2 h-3.5 w-3.5"}),"Copy URL"]}),"file"===a.type&&cx(a.name)&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(bV.DropdownMenuItem,{onClick:()=>c.copyRawContent(a.path),children:[(0,g.jsx)(j.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy raw content"]}),(0,g.jsxs)(bV.DropdownMenuItem,{onClick:()=>c.copyFormattedContent(a.path,a.name),children:[(0,g.jsx)(j.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy formatted content"]})]}),(0,g.jsx)(bV.DropdownMenuSeparator,{}),"dir"===a.type&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(bV.DropdownMenuItem,{onClick:async()=>{a.expanded||c.toggleFolder(a),c.setNewFileParent(a.path),c.setNewFileName(""),c.setFileCreateError(null)},children:[(0,g.jsx)(bY,{className:"mr-2 h-3.5 w-3.5"}),"New file here"]}),(0,g.jsxs)(bV.DropdownMenuItem,{onClick:()=>c.triggerUpload(a.path),children:[(0,g.jsx)(b_,{className:"mr-2 h-3.5 w-3.5"}),"Upload here"]}),(0,g.jsxs)(bV.DropdownMenuItem,{onClick:()=>{c.setNewFolderParent(a.path),c.setNewFolderName(""),c.setFolderError(null)},children:[(0,g.jsx)(bZ,{className:"mr-2 h-3.5 w-3.5"}),"New subfolder"]}),(0,g.jsx)(bV.DropdownMenuSeparator,{})]}),(0,g.jsxs)(bV.DropdownMenuItem,{onClick:()=>c.handleDownload(a),children:[(0,g.jsx)(bW.Download,{className:"mr-2 h-3.5 w-3.5"}),"file"===a.type?"Download":"Download as zip"]}),(0,g.jsxs)(bV.DropdownMenuItem,{onClick:()=>c.togglePin(a,e),children:[(0,g.jsx)(aV,{className:(0,an.cn)("mr-2 h-3.5 w-3.5",n&&"fill-current text-amber-400")}),n?"Unpin":"Pin to top"]}),(0,g.jsx)(bV.DropdownMenuSeparator,{}),(0,g.jsxs)(bV.DropdownMenuItem,{className:"text-destructive focus:text-destructive",onClick:()=>{c.setDeletingPath(a.path),c.setDeletingIsDir("file"!==a.type)},children:[(0,g.jsx)(a$,{className:"mr-2 h-3.5 w-3.5"}),"Delete"]})]})]})})]})}),(0,g.jsx)(cC,{node:a,ctx:c,isPinned:n,activeWorkspaceId:e})]})}),cF=(0,p.memo)(function(a){let{ctx:b,openPath:c,dragOverPath:d,branchDropdownNode:e,branchDropdownPos:f,nodeBranches:h,branchesLoading:i,checkingOutBranch:k,pullingRepo:l,activePaths:m,pins:n,isMobile:q,activeWorkspaceId:s,newFileParent:t,newFileName:v,fileCreateError:w,newFolderParent:x,newFolderName:y,folderError:z,sidebarScrollRef:A}=a,B=ct(a=>a.showHidden),C=(0,p.useRef)(null),D=(0,p.useCallback)(a=>{let c=("dir"===a.type||"app"===a.type||"node-app"===a.type)&&!a.expanded&&void 0===a.children;("file"===a.type||c)&&(C.current&&clearTimeout(C.current),C.current=setTimeout(()=>b.prefetch(a),120))},[b]),E=(0,p.useCallback)(()=>{C.current&&(clearTimeout(C.current),C.current=null)},[]),F=(0,p.useMemo)(()=>{let b=[],c=(a,d)=>{for(let e of a)!(!B&&e.name.startsWith("."))&&(b.push({kind:"row",node:e,depth:d}),"dir"===e.type&&(x===e.path&&b.push({kind:"newfolder",node:e,depth:d}),t===e.path&&b.push({kind:"newfile",node:e,depth:d})),("dir"===e.type||"app"===e.type||"node-app"===e.type)&&e.expanded&&(e.children&&e.children.length>0?c(e.children,d+1):e.children?.length===0&&b.push({kind:"empty",node:e,depth:d})))};return c(a.nodes,0),b},[a.nodes,t,x,B]);return(0,g.jsx)(g.Fragment,{children:F.map(a=>{let{node:p,depth:t}=a;if("row"===a.kind){let a=e===p.path;return(0,g.jsx)(cE,{node:p,depth:t,ctx:b,isMobile:q,activeWorkspaceId:s,sidebarScrollRef:A,isActive:c===p.path,isDragOver:d===p.path,isPinned:n.some(a=>a.path===p.path),isAgentActive:m.has(p.path),isPulling:l===p.path,branchOpen:a,branchPos:a?f:null,branches:p.git?h[p.path]??[]:[],branchLoading:!!p.git&&!!i[p.path],checkingOut:a?k:null,onHoverEnter:D,onHoverLeave:E},p.path)}return"newfolder"===a.kind?(0,g.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1",style:{paddingLeft:`${(t+1)*14+8}px`,...cB},children:[(0,g.jsx)("span",{className:"w-3.5 shrink-0"}),(0,g.jsx)(aP,{className:"h-4 w-4 shrink-0 text-warning"}),(0,g.jsx)("input",{className:"flex-1 bg-transparent text-sm outline-none border-b border-border min-w-0",placeholder:"Folder name",value:y,onChange:a=>b.setNewFolderName(a.target.value),onKeyDown:a=>{"Enter"===a.key&&b.handleCreateFolder(),"Escape"===a.key&&(b.setNewFolderParent(null),b.setNewFolderName(""))}}),z&&(0,g.jsx)("span",{className:"text-xs text-destructive",children:z}),(0,g.jsx)(u.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:b.handleCreateFolder,children:(0,g.jsx)(r.Check,{className:"h-3 w-3"})}),(0,g.jsx)(u.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:()=>{b.setNewFolderParent(null),b.setNewFolderName("")},children:(0,g.jsx)(o,{className:"h-3 w-3"})})]},`nf-${p.path}`):"newfile"===a.kind?(0,g.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1",style:{paddingLeft:`${(t+1)*14+8}px`,...cB},children:[(0,g.jsx)("span",{className:"w-3.5 shrink-0"}),(0,g.jsx)(j.FileText,{className:"h-4 w-4 shrink-0 text-accent"}),(0,g.jsx)("input",{autoFocus:!0,className:"flex-1 bg-transparent text-sm outline-none border-b border-border min-w-0",placeholder:"filename (default .md)",value:v,onChange:a=>b.setNewFileName(a.target.value),onKeyDown:a=>{"Enter"===a.key&&b.handleCreateFile(),"Escape"===a.key&&(b.setNewFileParent(null),b.setNewFileName(""))}}),w&&(0,g.jsx)("span",{className:"text-xs text-destructive",children:w}),(0,g.jsx)(u.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:b.handleCreateFile,children:(0,g.jsx)(r.Check,{className:"h-3 w-3"})}),(0,g.jsx)(u.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:()=>{b.setNewFileParent(null),b.setNewFileName("")},children:(0,g.jsx)(o,{className:"h-3 w-3"})})]},`ff-${p.path}`):(0,g.jsx)("div",{className:"text-xs text-muted-foreground/50 py-0.5",style:{paddingLeft:`${(t+1)*14+8+14+6+16+6}px`,...cB},children:"Empty"},`empty-${p.path}`)})})});function cG({doc:a,node:b,extraItems:c}){return(0,g.jsxs)(bV.DropdownMenu,{children:[(0,g.jsx)(bV.DropdownMenuTrigger,{asChild:!0,children:(0,g.jsx)(u.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"File actions",children:(0,g.jsx)(bU,{className:"h-3.5 w-3.5"})})}),(0,g.jsxs)(bV.DropdownMenuContent,{align:"end",className:"w-52",children:[(0,g.jsxs)(bV.DropdownMenuItem,{onClick:()=>a.copyPath(b.path),children:[(0,g.jsx)(aY.Copy,{className:"mr-2 h-3.5 w-3.5"}),"Copy path"]}),cy(b.name)&&(0,g.jsxs)(bV.DropdownMenuItem,{onClick:()=>a.copyWikiLink(b.name),children:[(0,g.jsx)(j.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy wiki link"]}),(0,g.jsx)(bV.DropdownMenuSeparator,{}),(0,g.jsxs)(bV.DropdownMenuItem,{onClick:()=>a.copyUrl(b.path),children:[(0,g.jsx)(bT,{className:"mr-2 h-3.5 w-3.5"}),"Copy URL"]}),cx(b.name)&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(bV.DropdownMenuSeparator,{}),(0,g.jsxs)(bV.DropdownMenuItem,{onClick:()=>void a.copyRawContent(b.path),children:[(0,g.jsx)(j.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy raw content"]}),(0,g.jsxs)(bV.DropdownMenuItem,{onClick:()=>void a.copyFormattedContent(b.path,b.name),children:[(0,g.jsx)(j.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy formatted content"]})]}),c&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(bV.DropdownMenuSeparator,{}),c]})]})]})}let cH=(0,h.default)("align-center",[["path",{d:"M17 12H7",key:"16if0g"}],["path",{d:"M19 18H5",key:"18s9l3"}],["path",{d:"M21 6H3",key:"1jwq7v"}]]);var cI=a.i(796873);let cJ=(0,h.default)("panel-left",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]);var cK=a.i(453590),cL=a.i(111939),cM=/[\\\/_+.#"@\[\(\{&]/,cN=/[\\\/_+.#"@\[\(\{&]/g,cO=/[\s-]/,cP=/[\s-]/g;function cQ(a){return a.toLowerCase().replace(cP," ")}var cR='[cmdk-group=""]',cS='[cmdk-group-items=""]',cT='[cmdk-item=""]',cU=`${cT}:not([aria-disabled="true"])`,cV="cmdk-item-select",cW="data-value",cX=(a,b,c)=>{var d;return d=a,function a(b,c,d,e,f,g,h){if(g===c.length)return f===b.length?1:.99;var i=`${f},${g}`;if(void 0!==h[i])return h[i];for(var j,k,l,m,n=e.charAt(g),o=d.indexOf(n,f),p=0;o>=0;)(j=a(b,c,d,e,o+1,g+1,h))>p&&(o===f?j*=1:cM.test(b.charAt(o-1))?(j*=.8,(l=b.slice(f,o-1).match(cN))&&f>0&&(j*=Math.pow(.999,l.length))):cO.test(b.charAt(o-1))?(j*=.9,(m=b.slice(f,o-1).match(cP))&&f>0&&(j*=Math.pow(.999,m.length))):(j*=.17,f>0&&(j*=Math.pow(.999,o-f))),b.charAt(o)!==c.charAt(g)&&(j*=.9999)),(j<.1&&d.charAt(o-1)===e.charAt(g+1)||e.charAt(g+1)===e.charAt(g)&&d.charAt(o-1)!==e.charAt(g))&&.1*(k=a(b,c,d,e,o+1,g+2,h))>j&&(j=.1*k),j>p&&(p=j),o=d.indexOf(n,o+1);return h[i]=p,p}(d=c&&c.length>0?`${d+" "+c.join(" ")}`:d,b,cQ(d),cQ(b),0,0,{})},cY=p.createContext(void 0),cZ=p.createContext(void 0),c$=p.createContext(void 0),c_=p.forwardRef((a,b)=>{let c=c9(()=>{var b,c;return{search:"",value:null!=(c=null!=(b=a.value)?b:a.defaultValue)?c:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),d=c9(()=>new Set),e=c9(()=>new Map),f=c9(()=>new Map),g=c9(()=>new Set),h=c7(a),{label:i,children:j,value:k,onValueChange:l,filter:m,shouldFilter:n,loop:o,disablePointerSelection:q=!1,vimBindings:r=!0,...s}=a,t=(0,y.useId)(),u=(0,y.useId)(),v=(0,y.useId)(),w=p.useRef(null),x=dc();c8(()=>{if(void 0!==k){let a=k.trim();c.current.value=a,z.emit()}},[k]),c8(()=>{x(6,F)},[]);let z=p.useMemo(()=>({subscribe:a=>(g.current.add(a),()=>g.current.delete(a)),snapshot:()=>c.current,setState:(a,b,d)=>{var e,f,g,i;if(!Object.is(c.current[a],b)){if(c.current[a]=b,"search"===a)E(),C(),x(1,D);else if("value"===a){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let a=document.getElementById(v);a?a.focus():null==(e=document.getElementById(t))||e.focus()}if(x(7,()=>{var a;c.current.selectedItemId=null==(a=G())?void 0:a.id,z.emit()}),d||x(5,F),(null==(f=h.current)?void 0:f.value)!==void 0){null==(i=(g=h.current).onValueChange)||i.call(g,null!=b?b:"");return}}z.emit()}},emit:()=>{g.current.forEach(a=>a())}}),[]),A=p.useMemo(()=>({value:(a,b,d)=>{var e;b!==(null==(e=f.current.get(a))?void 0:e.value)&&(f.current.set(a,{value:b,keywords:d}),c.current.filtered.items.set(a,B(b,d)),x(2,()=>{C(),z.emit()}))},item:(a,b)=>(d.current.add(a),b&&(e.current.has(b)?e.current.get(b).add(a):e.current.set(b,new Set([a]))),x(3,()=>{E(),C(),c.current.value||D(),z.emit()}),()=>{f.current.delete(a),d.current.delete(a),c.current.filtered.items.delete(a);let b=G();x(4,()=>{E(),(null==b?void 0:b.getAttribute("id"))===a&&D(),z.emit()})}),group:a=>(e.current.has(a)||e.current.set(a,new Set),()=>{f.current.delete(a),e.current.delete(a)}),filter:()=>h.current.shouldFilter,label:i||a["aria-label"],getDisablePointerSelection:()=>h.current.disablePointerSelection,listId:t,inputId:v,labelId:u,listInnerRef:w}),[]);function B(a,b){var d,e;let f=null!=(e=null==(d=h.current)?void 0:d.filter)?e:cX;return a?f(a,c.current.search,b):0}function C(){if(!c.current.search||!1===h.current.shouldFilter)return;let a=c.current.filtered.items,b=[];c.current.filtered.groups.forEach(c=>{let d=e.current.get(c),f=0;d.forEach(b=>{f=Math.max(a.get(b),f)}),b.push([c,f])});let d=w.current;H().sort((b,c)=>{var d,e;let f=b.getAttribute("id"),g=c.getAttribute("id");return(null!=(d=a.get(g))?d:0)-(null!=(e=a.get(f))?e:0)}).forEach(a=>{let b=a.closest(cS);b?b.appendChild(a.parentElement===b?a:a.closest(`${cS} > *`)):d.appendChild(a.parentElement===d?a:a.closest(`${cS} > *`))}),b.sort((a,b)=>b[1]-a[1]).forEach(a=>{var b;let c=null==(b=w.current)?void 0:b.querySelector(`${cR}[${cW}="${encodeURIComponent(a[0])}"]`);null==c||c.parentElement.appendChild(c)})}function D(){let a=H().find(a=>"true"!==a.getAttribute("aria-disabled")),b=null==a?void 0:a.getAttribute(cW);z.setState("value",b||void 0)}function E(){var a,b,g,i;if(!c.current.search||!1===h.current.shouldFilter){c.current.filtered.count=d.current.size;return}c.current.filtered.groups=new Set;let j=0;for(let e of d.current){let d=B(null!=(b=null==(a=f.current.get(e))?void 0:a.value)?b:"",null!=(i=null==(g=f.current.get(e))?void 0:g.keywords)?i:[]);c.current.filtered.items.set(e,d),d>0&&j++}for(let[a,b]of e.current)for(let d of b)if(c.current.filtered.items.get(d)>0){c.current.filtered.groups.add(a);break}c.current.filtered.count=j}function F(){var a,b,c;let d=G();d&&((null==(a=d.parentElement)?void 0:a.firstChild)===d&&(null==(c=null==(b=d.closest(cR))?void 0:b.querySelector('[cmdk-group-heading=""]'))||c.scrollIntoView({block:"nearest"})),d.scrollIntoView({block:"nearest"}))}function G(){var a;return null==(a=w.current)?void 0:a.querySelector(`${cT}[aria-selected="true"]`)}function H(){var a;return Array.from((null==(a=w.current)?void 0:a.querySelectorAll(cU))||[])}function I(a){let b=H()[a];b&&z.setState("value",b.getAttribute(cW))}function J(a){var b;let c=G(),d=H(),e=d.findIndex(a=>a===c),f=d[e+a];null!=(b=h.current)&&b.loop&&(f=e+a<0?d[d.length-1]:e+a===d.length?d[0]:d[e+a]),f&&z.setState("value",f.getAttribute(cW))}function K(a){let b=G(),c=null==b?void 0:b.closest(cR),d;for(;c&&!d;)d=null==(c=a>0?function(a,b){let c=a.nextElementSibling;for(;c;){if(c.matches(b))return c;c=c.nextElementSibling}}(c,cR):function(a,b){let c=a.previousElementSibling;for(;c;){if(c.matches(b))return c;c=c.previousElementSibling}}(c,cR))?void 0:c.querySelector(cU);d?z.setState("value",d.getAttribute(cW)):J(a)}let L=()=>I(H().length-1),M=a=>{a.preventDefault(),a.metaKey?L():a.altKey?K(1):J(1)},N=a=>{a.preventDefault(),a.metaKey?I(0):a.altKey?K(-1):J(-1)};return p.createElement(bf.div,{ref:b,tabIndex:-1,...s,"cmdk-root":"",onKeyDown:a=>{var b;null==(b=s.onKeyDown)||b.call(s,a);let c=a.nativeEvent.isComposing||229===a.keyCode;if(!(a.defaultPrevented||c))switch(a.key){case"n":case"j":r&&a.ctrlKey&&M(a);break;case"ArrowDown":M(a);break;case"p":case"k":r&&a.ctrlKey&&N(a);break;case"ArrowUp":N(a);break;case"Home":a.preventDefault(),I(0);break;case"End":a.preventDefault(),L();break;case"Enter":{a.preventDefault();let b=G();if(b){let a=new Event(cV);b.dispatchEvent(a)}}}}},p.createElement("label",{"cmdk-label":"",htmlFor:A.inputId,id:A.labelId,style:de},i),dd(a,a=>p.createElement(cZ.Provider,{value:z},p.createElement(cY.Provider,{value:A},a))))}),c0=p.forwardRef((a,b)=>{var c,d;let e=(0,y.useId)(),f=p.useRef(null),g=p.useContext(c$),h=p.useContext(cY),i=c7(a),j=null!=(d=null==(c=i.current)?void 0:c.forceMount)?d:null==g?void 0:g.forceMount;c8(()=>{if(!j)return h.item(e,null==g?void 0:g.id)},[j]);let k=db(e,f,[a.value,a.children,f],a.keywords),l=p.useContext(cZ),m=da(a=>a.value&&a.value===k.current),n=da(a=>!!j||!1===h.filter()||!a.search||a.filtered.items.get(e)>0);function o(){var a,b;q(),null==(b=(a=i.current).onSelect)||b.call(a,k.current)}function q(){l.setState("value",k.current,!0)}if(p.useEffect(()=>{let b=f.current;if(!(!b||a.disabled))return b.addEventListener(cV,o),()=>b.removeEventListener(cV,o)},[n,a.onSelect,a.disabled]),!n)return null;let{disabled:r,value:s,onSelect:t,forceMount:u,keywords:v,...x}=a;return p.createElement(bf.div,{ref:(0,w.composeRefs)(f,b),...x,id:e,"cmdk-item":"",role:"option","aria-disabled":!!r,"aria-selected":!!m,"data-disabled":!!r,"data-selected":!!m,onPointerMove:r||h.getDisablePointerSelection()?void 0:q,onClick:r?void 0:o},a.children)}),c1=p.forwardRef((a,b)=>{let{heading:c,children:d,forceMount:e,...f}=a,g=(0,y.useId)(),h=p.useRef(null),i=p.useRef(null),j=(0,y.useId)(),k=p.useContext(cY),l=da(a=>!!e||!1===k.filter()||!a.search||a.filtered.groups.has(g));c8(()=>k.group(g),[]),db(g,h,[a.value,a.heading,i]);let m=p.useMemo(()=>({id:g,forceMount:e}),[e]);return p.createElement(bf.div,{ref:(0,w.composeRefs)(h,b),...f,"cmdk-group":"",role:"presentation",hidden:!l||void 0},c&&p.createElement("div",{ref:i,"cmdk-group-heading":"","aria-hidden":!0,id:j},c),dd(a,a=>p.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":c?j:void 0},p.createElement(c$.Provider,{value:m},a))))}),c2=p.forwardRef((a,b)=>{let{alwaysRender:c,...d}=a,e=p.useRef(null),f=da(a=>!a.search);return c||f?p.createElement(bf.div,{ref:(0,w.composeRefs)(e,b),...d,"cmdk-separator":"",role:"separator"}):null}),c3=p.forwardRef((a,b)=>{let{onValueChange:c,...d}=a,e=null!=a.value,f=p.useContext(cZ),g=da(a=>a.search),h=da(a=>a.selectedItemId),i=p.useContext(cY);return p.useEffect(()=>{null!=a.value&&f.setState("search",a.value)},[a.value]),p.createElement(bf.input,{ref:b,...d,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":i.listId,"aria-labelledby":i.labelId,"aria-activedescendant":h,id:i.inputId,type:"text",value:e?a.value:g,onChange:a=>{e||f.setState("search",a.target.value),null==c||c(a.target.value)}})}),c4=p.forwardRef((a,b)=>{let{children:c,label:d="Suggestions",...e}=a,f=p.useRef(null),g=p.useRef(null),h=da(a=>a.selectedItemId),i=p.useContext(cY);return p.useEffect(()=>{if(g.current&&f.current){let a=g.current,b=f.current,c,d=new ResizeObserver(()=>{c=requestAnimationFrame(()=>{let c=a.offsetHeight;b.style.setProperty("--cmdk-list-height",c.toFixed(1)+"px")})});return d.observe(a),()=>{cancelAnimationFrame(c),d.unobserve(a)}}},[]),p.createElement(bf.div,{ref:(0,w.composeRefs)(f,b),...e,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":h,"aria-label":d,id:i.listId},dd(a,a=>p.createElement("div",{ref:(0,w.composeRefs)(g,i.listInnerRef),"cmdk-list-sizer":""},a)))}),c5=p.forwardRef((a,b)=>{let{open:c,onOpenChange:d,overlayClassName:e,contentClassName:f,container:g,...h}=a;return p.createElement(O,{open:c,onOpenChange:d},p.createElement(T,{container:g},p.createElement(V,{"cmdk-overlay":"",className:e}),p.createElement(Z,{"aria-label":a.label,"cmdk-dialog":"",className:f},p.createElement(c_,{ref:b,...h}))))}),c6=Object.assign(c_,{List:c4,Item:c0,Input:c3,Group:c1,Separator:c2,Dialog:c5,Empty:p.forwardRef((a,b)=>da(a=>0===a.filtered.count)?p.createElement(bf.div,{ref:b,...a,"cmdk-empty":"",role:"presentation"}):null),Loading:p.forwardRef((a,b)=>{let{progress:c,children:d,label:e="Loading...",...f}=a;return p.createElement(bf.div,{ref:b,...f,"cmdk-loading":"",role:"progressbar","aria-valuenow":c,"aria-valuemin":0,"aria-valuemax":100,"aria-label":e},dd(a,a=>p.createElement("div",{"aria-hidden":!0},a)))})});function c7(a){let b=p.useRef(a);return c8(()=>{b.current=a}),b}var c8=p.useEffect;function c9(a){let b=p.useRef();return void 0===b.current&&(b.current=a()),b}function da(a){let b=p.useContext(cZ),c=()=>a(b.snapshot());return p.useSyncExternalStore(b.subscribe,c,c)}function db(a,b,c,d=[]){let e=p.useRef(),f=p.useContext(cY);return c8(()=>{var g;let h=(()=>{var a;for(let b of c){if("string"==typeof b)return b.trim();if("object"==typeof b&&"current"in b)return b.current?null==(a=b.current.textContent)?void 0:a.trim():e.current}})(),i=d.map(a=>a.trim());f.value(a,h,i),null==(g=b.current)||g.setAttribute(cW,h),e.current=h}),e}var dc=()=>{let[a,b]=p.useState(),c=c9(()=>new Map);return c8(()=>{c.current.forEach(a=>a()),c.current=new Map},[a]),(a,d)=>{c.current.set(a,d),b({})}};function dd({asChild:a,children:b},c){let d;return a&&p.isValidElement(b)?p.cloneElement("function"==typeof(d=b.type)?d(b.props):"render"in d?d.render(b.props):b,{ref:b.ref},c(b.props.children)):c(b)}var de={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};let df=(0,h.default)("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]),dg=p.forwardRef(({className:a,...b},c)=>(0,g.jsx)(c6,{ref:c,className:(0,an.cn)("flex h-full w-full flex-col overflow-hidden rounded-sm bg-popover text-popover-foreground",a),...b}));function dh({children:a,shouldFilter:b,...c}){return(0,g.jsx)(O,{...c,children:(0,g.jsxs)(aI,{className:"overflow-hidden p-0 shadow-golden max-w-lg",children:[(0,g.jsx)(aL,{className:"sr-only",children:"Search"}),(0,g.jsx)(dg,{shouldFilter:b,className:"[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-normal [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5",children:a})]})})}dg.displayName=c6.displayName;let di=p.forwardRef(({className:a,...b},c)=>(0,g.jsxs)("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[(0,g.jsx)(df,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),(0,g.jsx)(c6.Input,{ref:c,className:(0,an.cn)("flex h-11 w-full rounded-sm bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",a),...b})]}));di.displayName=c6.Input.displayName;let dj=p.forwardRef(({className:a,...b},c)=>(0,g.jsx)(c6.List,{ref:c,className:(0,an.cn)("max-h-[300px] overflow-y-auto overflow-x-hidden",a),...b}));dj.displayName=c6.List.displayName;let dk=p.forwardRef((a,b)=>(0,g.jsx)(c6.Empty,{ref:b,className:"py-6 text-center text-sm text-muted-foreground",...a}));dk.displayName=c6.Empty.displayName;let dl=p.forwardRef(({className:a,...b},c)=>(0,g.jsx)(c6.Group,{ref:c,className:(0,an.cn)("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-normal [&_[cmdk-group-heading]]:text-muted-foreground",a),...b}));dl.displayName=c6.Group.displayName;let dm=p.forwardRef(({className:a,...b},c)=>(0,g.jsx)(c6.Separator,{ref:c,className:(0,an.cn)("-mx-1 h-px bg-border",a),...b}));dm.displayName=c6.Separator.displayName;let dn=p.forwardRef(({className:a,...b},c)=>(0,g.jsx)(c6.Item,{ref:c,className:(0,an.cn)("relative flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",a),...b}));dn.displayName=c6.Item.displayName;let dp=null,dq=null,dr=(0,aw.create)(a=>({query:"",results:[],loading:!1,truncated:!1,open:!1,setQuery:b=>a({query:b}),setOpen:b=>a({open:b}),clear:()=>{dq&&clearTimeout(dq),dp?.abort(),a({query:"",results:[],loading:!1,truncated:!1})},search:b=>(dq&&clearTimeout(dq),b.trim())?(a({loading:!0}),new Promise(c=>{dq=setTimeout(()=>{ds(a,b).finally(c)},150)})):(dp?.abort(),a({results:[],loading:!1,truncated:!1}),Promise.resolve())}));async function ds(a,b){dp?.abort();let c=new AbortController;dp=c;try{let d=await (0,bk.wsFetch)("/api/wiki/search",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:b,limit:30}),signal:c.signal});if(!d.ok)return void a({results:[],loading:!1,truncated:!1});let e=await d.json();if(c.signal.aborted)return;a({results:e.matches??[],truncated:!!e.truncated,loading:!1})}catch(b){"AbortError"!==b.name&&a({loading:!1})}}var dt=a.i(713033);function du({html:a}){let b=function(a){let b,c=[],d=/<mark>([\s\S]*?)<\/mark>/g,e=0;for(;null!==(b=d.exec(a));)b.index>e&&c.push({text:a.slice(e,b.index),mark:!1}),c.push({text:b[1]??"",mark:!0}),e=b.index+b[0].length;return e<a.length&&c.push({text:a.slice(e),mark:!1}),c}(a);return(0,g.jsx)(g.Fragment,{children:b.map((a,b)=>a.mark?(0,g.jsx)("mark",{className:"bg-yellow-200 dark:bg-yellow-700 rounded-[2px] px-[1px]",children:a.text},b):(0,g.jsx)("span",{children:a.text},b))})}function dv({onOpenFile:a,recents:b=[],onToggleSidebar:c=()=>void 0,onNewFile:d=()=>void 0,onCopyPath:e=()=>void 0}){let f=dr(a=>a.open),h=dr(a=>a.setOpen),j=dr(a=>a.query),k=dr(a=>a.setQuery),l=dr(a=>a.results),m=dr(a=>a.loading),n=dr(a=>a.truncated),o=dr(a=>a.search),{resolvedTheme:q,setTheme:r}=(0,cL.useTheme)(),s=bo(a=>a.toggle),t=(0,dt.useViewWidthStore)(a=>a.width),u=(0,dt.useViewWidthStore)(a=>a.cycle),v=j.trimStart(),w=""===v||v.startsWith(">"),x=""===v&&b.length>0,y=w?"":j;function z(a){a(),h(!1),k("")}(0,p.useEffect)(()=>{function a(a){(a.metaKey||a.ctrlKey)&&"k"===a.key.toLowerCase()&&(a.preventDefault(),h(!f))}return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[f,h]),(0,p.useEffect)(()=>{if(!f||w)return;let a=setTimeout(()=>{o(y)},120);return()=>clearTimeout(a)},[y,w,f,o]);let A=(dt.VIEW_WIDTH_ORDER.indexOf(t)+1)%dt.VIEW_WIDTH_ORDER.length,B=dt.VIEW_WIDTH_LABEL[dt.VIEW_WIDTH_ORDER[A]];return(0,g.jsxs)(dh,{open:f,onOpenChange:a=>{h(a),a||k("")},shouldFilter:!1,children:[(0,g.jsx)(di,{placeholder:"Search files… ( > for actions )",value:j,onValueChange:k}),(0,g.jsxs)(dj,{children:[x&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(dl,{heading:"Recent",children:b.map(b=>(0,g.jsxs)(dn,{value:`recent:${b.path}`,onSelect:()=>{a(b.path),h(!1),k("")},children:[(0,g.jsx)(a_,{className:"mr-2 h-4 w-4"}),(0,g.jsxs)("div",{className:"flex min-w-0 flex-col gap-0.5",children:[(0,g.jsx)("span",{className:"truncate font-medium",children:b.name}),(0,g.jsx)("span",{className:"truncate text-xs text-muted-foreground",children:b.path})]})]},b.path))}),(0,g.jsx)(dm,{})]}),w&&(0,g.jsxs)(dl,{heading:"Actions",children:[(0,g.jsxs)(dn,{value:"toggle-dark-mode",onSelect:()=>z(()=>r("dark"===q?"light":"dark")),children:["dark"===q?(0,g.jsx)(cK.Sun,{className:"mr-2 h-4 w-4"}):(0,g.jsx)(cI.Moon,{className:"mr-2 h-4 w-4"}),"dark"===q?"Switch to light mode":"Switch to dark mode"]}),(0,g.jsxs)(dn,{value:"toggle-ai-panel",onSelect:()=>z(s),children:[(0,g.jsx)(i,{className:"mr-2 h-4 w-4"}),"Toggle AI panel"]}),(0,g.jsxs)(dn,{value:"toggle-sidebar",onSelect:()=>z(c),children:[(0,g.jsx)(cJ,{className:"mr-2 h-4 w-4"}),"Toggle sidebar"]}),(0,g.jsxs)(dn,{value:"new-file",onSelect:()=>z(d),children:[(0,g.jsx)(bY,{className:"mr-2 h-4 w-4"}),"New file"]}),(0,g.jsxs)(dn,{value:"copy-path",onSelect:()=>z(e),children:[(0,g.jsx)(aY.Copy,{className:"mr-2 h-4 w-4"}),"Copy current file path"]}),(0,g.jsxs)(dn,{value:"cycle-view-width",onSelect:()=>z(u),children:[(0,g.jsx)(cH,{className:"mr-2 h-4 w-4"}),(0,g.jsxs)("span",{children:["Change view width"," ",(0,g.jsxs)("span",{className:"text-muted-foreground",children:["(",dt.VIEW_WIDTH_LABEL[t]," → ",B,")"]})]})]})]}),!w&&(0,g.jsxs)(g.Fragment,{children:[m&&(0,g.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:"Searching…"}),!m&&""!==y.trim()&&0===l.length&&(0,g.jsx)(dk,{children:"No matches."}),l.length>0&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(dm,{}),(0,g.jsx)(dl,{heading:n?"Top results (refine query for more)":"Results",children:l.map(b=>(0,g.jsx)(dn,{value:b.path,onSelect:()=>{a(b.path),h(!1),k("")},children:(0,g.jsxs)("div",{className:"flex min-w-0 flex-col gap-0.5",children:[(0,g.jsx)("span",{className:"truncate font-mono text-xs",children:b.path}),b.snippet&&(0,g.jsx)("span",{className:"truncate text-xs text-muted-foreground",children:(0,g.jsx)(du,{html:b.snippet})})]})},b.path))})]})]})]})]})}let dw=(0,h.default)("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]),dx=(0,h.default)("cloud-download",[["path",{d:"M12 13v8l-4-4",key:"1f5nwf"}],["path",{d:"m12 21 4-4",key:"1lfcce"}],["path",{d:"M4.393 15.269A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.436 8.284",key:"ui1hmy"}]]);var dy=a.i(410672);let dz=(0,h.default)("eye-off",[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]),dA=(0,h.default)("history",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]),dB=(0,h.default)("panel-left-close",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]]),dC=(0,h.default)("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]),dD=(0,h.default)("settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]),dE=(0,h.default)("type",[["path",{d:"M12 4v16",key:"1654pz"}],["path",{d:"M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2",key:"e0r10z"}],["path",{d:"M9 20h6",key:"s66wpe"}]]);function dF({onOpenFile:a}){let b=dr(a=>a.query),c=dr(a=>a.setQuery),d=dr(a=>a.results),e=dr(a=>a.loading),f=dr(a=>a.search),h=dr(a=>a.clear),[i,j]=(0,p.useState)(0),k=(0,p.useRef)(null);function l(b){let c=d[b];c&&(a(c.path),h())}return(0,p.useEffect)(()=>{j(0)},[d]),(0,p.useEffect)(()=>{let a=k.current?.querySelector(`[data-idx="${i}"]`);a?.scrollIntoView({block:"nearest"})},[i]),(0,g.jsxs)("div",{className:"flex flex-col gap-1 px-2 py-1.5",children:[(0,g.jsxs)("div",{className:"relative",children:[(0,g.jsx)(df,{className:"pointer-events-none absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 opacity-50"}),(0,g.jsx)("input",{type:"text",className:"w-full rounded-sm border bg-transparent py-1 pl-7 pr-2 text-xs outline-none focus:ring-1 focus:ring-ring",placeholder:"Search… (⌘K)",value:b,onChange:a=>{c(a.target.value),f(a.target.value)},onKeyDown:a=>{"Escape"===a.key?h():0!==d.length&&("ArrowDown"===a.key?(a.preventDefault(),j(a=>(a+1)%d.length)):"ArrowUp"===a.key?(a.preventDefault(),j(a=>(a-1+d.length)%d.length)):"Enter"===a.key&&(a.preventDefault(),l(i)))}})]}),""!==b.trim()&&(0,g.jsxs)("div",{ref:k,className:"max-h-64 overflow-y-auto rounded-sm border bg-popover",children:[e&&(0,g.jsx)("div",{className:"px-2 py-1 text-xs text-muted-foreground",children:"Searching…"}),!e&&0===d.length&&(0,g.jsx)("div",{className:"px-2 py-1 text-xs text-muted-foreground",children:"No matches"}),d.map((a,b)=>(0,g.jsxs)("button",{type:"button","data-idx":b,onClick:()=>l(b),onMouseEnter:()=>j(b),className:`block w-full px-2 py-1 text-left ${b===i?"bg-accent":"hover:bg-accent"}`,children:[(0,g.jsx)("div",{className:"truncate font-mono text-xs",children:a.path}),a.snippet&&(0,g.jsx)("div",{className:"truncate text-[10px] text-muted-foreground",children:(0,g.jsx)(du,{html:a.snippet})})]},a.path))]})]})}var dG=a.i(591119);function dH(a){let b=new Date(a).getTime();if(!Number.isFinite(b))return"";let c=Math.floor(Math.max(0,Date.now()-b)/1e3);if(c<60)return"just now";let d=Math.floor(c/60);if(d<60)return`${d}m ago`;let e=Math.floor(d/60);return e<24?`${e}h ago`:`${Math.floor(e/24)}d ago`}function dI({workspaces:a,activeWorkspaceId:b,rootPath:c,isWsAdmin:d,refreshingWsId:e,switchingBranch:f,switchingBranchName:h,wsBranches:i,branchPickerWsId:j,wsBranchPos:k,onSwitchWorkspace:l,onRefreshWorkspace:m,onPromptDeleteWorkspace:n,onAddWorkspace:o,setBranchPickerWsId:p,setWsBranchPos:q,loadWsBranches:s,handleSwitchBranch:t}){return(0,g.jsxs)("div",{className:"border-t px-2 py-2 bg-muted shrink-0",children:[(0,g.jsxs)(bV.DropdownMenu,{modal:!1,onOpenChange:a=>{a||(p(null),q(null))},children:[(0,g.jsx)(bV.DropdownMenuTrigger,{asChild:!0,children:(0,g.jsxs)(u.Button,{size:"sm",variant:"ghost",className:"w-full h-auto justify-between gap-2 px-2 py-1.5 text-left",title:c??"",children:[(0,g.jsxs)("span",{className:"flex flex-col min-w-0",children:[(0,g.jsx)("span",{className:"truncate text-xs font-medium",children:a.find(a=>a.id===b)?.name??"Workspace"}),(0,g.jsx)("span",{className:"truncate text-[10px] text-muted-foreground font-mono",children:c??""})]}),(0,g.jsx)(dw,{className:"h-3.5 w-3.5 shrink-0 opacity-60"})]})}),(0,g.jsxs)(bV.DropdownMenuContent,{align:"start",className:"w-[var(--radix-dropdown-menu-trigger-width)]",onInteractOutside:a=>{a.target?.closest?.("[data-branch-portal]")&&a.preventDefault()},children:[a.map(a=>(0,g.jsxs)(bV.DropdownMenuItem,{onClick:()=>void l(a.id),onPointerMove:a=>a.preventDefault(),onPointerLeave:a=>a.preventDefault(),className:(0,an.cn)("gap-2",a.id===b&&"font-medium"),children:[a.id===b?(0,g.jsx)(r.Check,{className:"h-3.5 w-3.5 shrink-0"}):(0,g.jsx)("span",{className:"w-3.5 shrink-0"}),(0,g.jsxs)("span",{className:"flex flex-col min-w-0 flex-1",children:[(0,g.jsxs)("span",{className:"flex items-center gap-1.5 truncate",children:[(0,g.jsx)("span",{className:"truncate",children:a.name}),a.git?d?(0,g.jsxs)("button",{"data-branch-trigger":!0,type:"button",className:"inline-flex items-center gap-0.5 rounded bg-muted px-1.5 text-[10px] text-muted-foreground font-normal shrink-0 hover:bg-accent",title:"Switch branch",disabled:f===a.id,onClick:b=>{if(b.stopPropagation(),b.preventDefault(),j===a.id){p(null),q(null);return}let c=b.currentTarget.getBoundingClientRect();q({top:c.bottom+4,left:c.left}),p(a.id),s(a.id)},children:[(0,g.jsx)(aR,{className:"h-2.5 w-2.5"})," ",a.git.branch??"branch"]}):(0,g.jsxs)("span",{className:"inline-flex items-center gap-0.5 rounded bg-muted px-1.5 text-[10px] text-muted-foreground font-normal shrink-0",children:[(0,g.jsx)(aR,{className:"h-2.5 w-2.5"})," ",a.git.branch??"read-only"]}):a.ssh?(0,g.jsxs)("span",{className:"inline-flex items-center gap-0.5 rounded bg-muted px-1.5 text-[10px] text-muted-foreground font-normal shrink-0",children:[(0,g.jsx)(aT,{className:"h-2.5 w-2.5"})," ",a.ssh.host]}):a.readOnly?(0,g.jsxs)("span",{className:"inline-flex items-center gap-0.5 rounded bg-muted px-1.5 text-[10px] text-muted-foreground font-normal shrink-0",children:[(0,g.jsx)(aR,{className:"h-2.5 w-2.5"})," read-only"]}):null]}),(0,g.jsx)("span",{className:"truncate text-[10px] text-muted-foreground font-mono",children:a.rootDir}),a.git?.lastPulledAt&&dH(a.git.lastPulledAt)&&(0,g.jsxs)("span",{className:"text-[10px] text-muted-foreground/70",children:["synced ",dH(a.git.lastPulledAt)]})]}),d&&a.git&&(0,g.jsx)("button",{className:(0,an.cn)("shrink-0 rounded p-0.5 hover:bg-accent transition-colors",a.git.lastError?"text-destructive":"text-muted-foreground hover:text-foreground"),title:a.git.lastError?`Last refresh failed: ${a.git.lastError}`:"Refresh",disabled:e===a.id,onClick:b=>{b.stopPropagation(),b.preventDefault(),m(a.id)},children:(0,g.jsx)(br,{className:(0,an.cn)("h-3.5 w-3.5",e===a.id&&"animate-spin")})}),d&&(0,g.jsx)("button",{className:"shrink-0 rounded p-0.5 text-muted-foreground hover:text-destructive hover:bg-destructive/10 transition-colors",title:"Delete workspace (does not delete files)",onClick:b=>{b.stopPropagation(),n(a.id)},children:(0,g.jsx)(a$,{className:"h-3.5 w-3.5"})})]},a.id)),d&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(bV.DropdownMenuSeparator,{}),(0,g.jsxs)(bV.DropdownMenuItem,{onClick:o,children:[(0,g.jsx)(bZ,{className:"mr-2 h-3.5 w-3.5"}),"Add workspace…"]})]})]})]}),(()=>{if(!j||!k)return null;let b=a.find(a=>a.id===j);return b?(0,g.jsx)(b0,{pos:k,branches:(i[b.id]??[]).map(a=>({name:a,current:a===b.git?.branch})),loading:!i[b.id],busyName:f===b.id?h:null,disabled:f===b.id,onPick:a=>{t(b.id,a)},onClose:()=>{p(null),q(null)}}):null})()]})}let dJ=(0,aw.create)((a,b)=>({pins:[],loadForWorkspace:b=>{a({pins:[]})},toggle:(b,c)=>{let d=[];a({pins:d.some(a=>a.path===b.path)?d.filter(a=>a.path!==b.path):[...d,b]})},isPinned:a=>b().pins.some(b=>b.path===a)})),dK=(0,aw.create)(a=>({width:288,setWidth:b=>{a({width:Number.isNaN(b)?288:Math.min(600,Math.max(200,Math.round(b)))})}}));function dL(a){return a.split("/").pop()??a}function dM({workspace:a,doc:b,fileTree:c,upload:d,isMobile:e,hideChrome:f,sidebarCollapsed:h,setSidebarCollapsed:k,sidebarResizing:l,setSidebarResizing:n,sidebarWidth:p,setSidebarWidth:s,collapsed:t,setCollapsed:v,createEntry:w,setCreateEntry:x,handleCreateFile:y,handleCreateFolder:z,dragOverPath:A,setDragOverPath:B,handleDragOver:C,handleDropOnFolder:D,sidebarScrollRef:E,treeCtx:F,pins:G,recents:H,activePaths:I,setDialogs:J,handleRefreshWorkspace:K}){let{resolvedTheme:L,setTheme:M}=(0,cL.useTheme)(),N=cs(a=>a.humanize),O=ct(a=>a.showHidden);return(0,g.jsxs)(g.Fragment,{children:[!f&&!h&&e&&(0,g.jsx)("div",{className:"fixed inset-0 z-40 bg-overlay backdrop-blur-[1px] md:hidden",onClick:()=>k(!0),"aria-hidden":!0}),!f&&!h&&(0,g.jsxs)(dG.Card,{style:e?void 0:{width:p},className:"fixed inset-y-0 left-0 z-50 w-[85vw] max-w-[20rem] md:relative md:z-auto md:w-auto md:max-w-none flex flex-col shrink-0 overflow-hidden rounded-none border-r border-l-0 border-t-0 border-b-0",children:[(0,g.jsxs)("div",{className:"flex items-center justify-between gap-2 px-3 py-2 border-b bg-muted shrink-0",children:[(0,g.jsxs)("div",{className:"flex min-w-0 items-center gap-1.5",title:"Wiki Viewer v2.9.5",children:[(0,g.jsx)("img",{src:(0,au.apiUrl)("/logo.svg"),alt:"Wiki Viewer",className:"h-5 w-5 shrink-0"}),(0,g.jsx)("span",{className:"truncate text-xs font-semibold leading-5 tracking-tight translate-y-[0.5px]",children:"Wiki Viewer"})]}),(0,g.jsx)(u.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0 shrink-0",title:"Collapse sidebar",onClick:()=>k(!0),children:(0,g.jsx)(dB,{className:"h-3.5 w-3.5"})})]}),(0,g.jsxs)("div",{className:"flex items-center justify-between gap-1 px-3 py-1.5 border-b bg-muted/50 shrink-0",children:[(0,g.jsxs)(bV.DropdownMenu,{children:[(0,g.jsx)(bV.DropdownMenuTrigger,{asChild:!0,children:(0,g.jsxs)(u.Button,{size:"sm",variant:"ghost",className:"h-7 gap-1 px-2 text-xs",disabled:d.uploading,children:[d.uploading?(0,g.jsx)(m.Loader2,{className:"h-3.5 w-3.5 animate-spin"}):(0,g.jsx)(dC,{className:"h-3.5 w-3.5"}),"New",(0,g.jsx)(dw,{className:"h-3 w-3 opacity-60"})]})}),(0,g.jsxs)(bV.DropdownMenuContent,{align:"start",className:"w-44",children:[(0,g.jsxs)(bV.DropdownMenuItem,{onClick:()=>x(a=>({...a,file:{...a.file,parent:"",name:"",error:null}})),children:[(0,g.jsx)(bY,{className:"mr-2 h-3.5 w-3.5"}),"New file"]}),(0,g.jsxs)(bV.DropdownMenuItem,{onClick:()=>x(a=>({...a,folder:{...a.folder,parent:"",name:"",error:null}})),children:[(0,g.jsx)(bZ,{className:"mr-2 h-3.5 w-3.5"}),"New folder"]}),(0,g.jsxs)(bV.DropdownMenuItem,{onClick:()=>d.triggerUpload(""),disabled:d.uploading,children:[(0,g.jsx)(b_,{className:"mr-2 h-3.5 w-3.5"}),"Upload"]})]})]}),(0,g.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,g.jsx)(u.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"Refresh tree",onClick:()=>void c.refreshTree(),disabled:c.refreshingTree,children:c.refreshingTree?(0,g.jsx)(m.Loader2,{className:"h-3.5 w-3.5 animate-spin"}):(0,g.jsx)(br,{className:"h-3.5 w-3.5"})}),(0,g.jsx)(u.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"AI Agent panel",onClick:()=>{bo.getState().toggle(),e&&k(!0)},children:(0,g.jsx)(i,{className:"h-3.5 w-3.5"})}),(0,g.jsxs)(bV.DropdownMenu,{children:[(0,g.jsx)(bV.DropdownMenuTrigger,{asChild:!0,children:(0,g.jsx)(u.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"More actions",children:(0,g.jsx)(bU,{className:"h-3.5 w-3.5"})})}),(0,g.jsxs)(bV.DropdownMenuContent,{align:"end",className:"w-48",children:[a.isWsAdmin&&a.workspaces.find(b=>b.id===a.activeWorkspaceId)?.git&&(0,g.jsxs)(bV.DropdownMenuItem,{onClick:()=>{a.activeWorkspaceId&&K(a.activeWorkspaceId)},disabled:a.refreshingWsId===a.activeWorkspaceId,children:[a.refreshingWsId===a.activeWorkspaceId?(0,g.jsx)(m.Loader2,{className:"mr-2 h-3.5 w-3.5 animate-spin"}):(0,g.jsx)(dx,{className:"mr-2 h-3.5 w-3.5"}),"Pull latest"]}),(0,g.jsxs)(bV.DropdownMenuItem,{onClick:()=>ct.getState().toggle(),children:[O?(0,g.jsx)(dz,{className:"mr-2 h-3.5 w-3.5"}):(0,g.jsx)(dy.Eye,{className:"mr-2 h-3.5 w-3.5"}),O?"Hide hidden files":"Show hidden files"]}),(0,g.jsxs)(bV.DropdownMenuItem,{onClick:()=>cs.getState().toggle(),children:[(0,g.jsx)(dE,{className:"mr-2 h-3.5 w-3.5"}),N?"Raw file names":"Humanize names"]}),(0,g.jsxs)(bV.DropdownMenuItem,{onClick:()=>M("dark"===L?"light":"dark"),children:["dark"===L?(0,g.jsx)(cK.Sun,{className:"mr-2 h-3.5 w-3.5"}):(0,g.jsx)(cI.Moon,{className:"mr-2 h-3.5 w-3.5"}),"dark"===L?"Light mode":"Dark mode"]}),(0,g.jsx)(bV.DropdownMenuSeparator,{}),(0,g.jsxs)(bV.DropdownMenuItem,{onClick:()=>J(a=>({...a,settingsOpen:!0})),children:[(0,g.jsx)(dD,{className:"mr-2 h-3.5 w-3.5"}),"Settings"]})]})]})]})]}),d.uploadError&&(0,g.jsxs)("div",{className:"flex items-center gap-1.5 px-3 py-1.5 text-xs text-destructive bg-destructive/10 shrink-0",children:[(0,g.jsx)(q.AlertCircle,{className:"h-3.5 w-3.5 shrink-0"}),d.uploadError]}),""===w.folder.parent&&(0,g.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1 border-b shrink-0",children:[(0,g.jsx)(aP,{className:"h-4 w-4 shrink-0 text-warning"}),(0,g.jsx)("input",{className:"flex-1 bg-transparent text-sm outline-none border-b border-border min-w-0",placeholder:"Folder name",value:w.folder.name,onChange:a=>x(b=>({...b,folder:{...b.folder,name:a.target.value}})),onKeyDown:a=>{"Enter"===a.key&&z(),"Escape"===a.key&&x(a=>({...a,folder:{...a.folder,parent:null,name:""}}))}}),w.folder.error&&(0,g.jsx)("span",{className:"text-xs text-destructive",children:w.folder.error}),(0,g.jsx)(u.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:z,children:(0,g.jsx)(r.Check,{className:"h-3 w-3"})}),(0,g.jsx)(u.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:()=>x(a=>({...a,folder:{...a.folder,parent:null,name:""}})),children:(0,g.jsx)(o,{className:"h-3 w-3"})})]}),""===w.file.parent&&(0,g.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1 border-b shrink-0",children:[(0,g.jsx)(j.FileText,{className:"h-4 w-4 shrink-0 text-accent"}),(0,g.jsx)("input",{autoFocus:!0,className:"flex-1 bg-transparent text-sm outline-none border-b border-border min-w-0",placeholder:"filename (default .md)",value:w.file.name,onChange:a=>x(b=>({...b,file:{...b.file,name:a.target.value}})),onKeyDown:a=>{"Enter"===a.key&&y(),"Escape"===a.key&&x(a=>({...a,file:{...a.file,parent:null,name:""}}))}}),w.file.error&&(0,g.jsx)("span",{className:"text-xs text-destructive",children:w.file.error}),(0,g.jsx)(u.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:y,children:(0,g.jsx)(r.Check,{className:"h-3 w-3"})}),(0,g.jsx)(u.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:()=>x(a=>({...a,file:{...a.file,parent:null,name:""}})),children:(0,g.jsx)(o,{className:"h-3 w-3"})})]}),(0,g.jsx)("div",{className:"border-b",children:(0,g.jsx)(dF,{onOpenFile:b.openFromSearch})}),(0,g.jsxs)("div",{ref:E,className:(0,an.cn)("flex-1 overflow-auto py-1 editorial-file-tree",""===A&&"ring-2 ring-inset ring-primary bg-primary/5"),onDragOver:a=>C(a,"","root"),onDragLeave:a=>{a.currentTarget.contains(a.relatedTarget)||B(null)},onDrop:a=>D(a,""),children:[G.length>0&&(0,g.jsxs)("div",{className:"border-b mb-1",children:[(0,g.jsxs)("button",{type:"button",className:"flex w-full items-center gap-1 px-2 py-1 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground hover:text-foreground",onClick:()=>v(a=>({...a,pinned:!a.pinned})),children:[t.pinned?(0,g.jsx)(aO.ChevronRight,{className:"h-3 w-3"}):(0,g.jsx)(dw,{className:"h-3 w-3"}),(0,g.jsx)(aV,{className:"h-3 w-3"}),"Pinned",(0,g.jsx)("span",{className:"ml-auto text-[9px] tabular-nums opacity-60",children:G.length})]}),!t.pinned&&G.map(c=>(0,g.jsxs)(b9,{children:[(0,g.jsx)(cb,{asChild:!0,children:(0,g.jsxs)("div",{role:"button",tabIndex:0,className:(0,an.cn)("group flex items-center gap-1.5 rounded-sm px-2 py-1 text-sm cursor-pointer transition-colors select-none",b.openFile?.path===c.path?"bg-accent-soft text-foreground font-medium":"hover:bg-muted"),onClick:()=>{b.openPinnedEntry(c)},onKeyDown:a=>{("Enter"===a.key||" "===a.key)&&(a.preventDefault(),b.openPinnedEntry(c))},children:[(0,g.jsx)(cD,{name:c.name,type:c.type??"file"}),(0,g.jsx)("span",{className:"min-w-0 flex-1 truncate text-xs",title:N?c.name:void 0,children:N?dL(c.name):c.name}),(0,g.jsx)("span",{className:"max-w-[80px] truncate text-[10px] text-muted-foreground/60",children:c.path.split("/").slice(0,-1).join("/")}),(0,g.jsx)("button",{type:"button",className:"hover-reveal shrink-0 rounded p-0.5 text-muted-foreground/50 opacity-0 transition-colors hover:bg-muted hover:text-amber-400 group-hover:opacity-100 focus:opacity-100",title:"Remove from pinned",onClick:b=>{b.stopPropagation(),dJ.getState().toggle({path:c.path,name:c.name},a.activeWorkspaceId)},children:(0,g.jsx)(o,{className:"h-3 w-3"})})]})}),(0,g.jsx)(cC,{node:{path:c.path,name:c.name,type:c.type??"file"},ctx:F,isPinned:!0,activeWorkspaceId:a.activeWorkspaceId})]},c.path))]}),H.length>0&&(0,g.jsxs)("div",{className:"border-b mb-1",children:[(0,g.jsxs)("button",{type:"button",className:"flex w-full items-center gap-1 px-2 py-1 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground hover:text-foreground",onClick:()=>v(a=>({...a,recent:!a.recent})),children:[t.recent?(0,g.jsx)(aO.ChevronRight,{className:"h-3 w-3"}):(0,g.jsx)(dw,{className:"h-3 w-3"}),(0,g.jsx)(dA,{className:"h-3 w-3"}),"Recent",(0,g.jsx)("span",{className:"ml-auto text-[9px] tabular-nums opacity-60",children:H.length})]}),!t.recent&&H.slice(0,8).map(c=>(0,g.jsxs)(b9,{children:[(0,g.jsx)(cb,{asChild:!0,children:(0,g.jsxs)("div",{role:"button",tabIndex:0,className:(0,an.cn)("flex items-center gap-1.5 rounded-sm px-2 py-1 text-sm cursor-pointer transition-colors select-none",b.openFile?.path===c.path?"bg-accent-soft text-foreground font-medium":"hover:bg-muted"),onClick:()=>{b.openViewer({path:c.path,name:c.name,type:c.type??"file",modifiedAt:""}),e&&k(!0)},onKeyDown:a=>{("Enter"===a.key||" "===a.key)&&(a.preventDefault(),b.openViewer({path:c.path,name:c.name,type:c.type??"file",modifiedAt:""}))},children:[(0,g.jsx)(cD,{name:c.name,type:c.type??"file"}),(0,g.jsx)("span",{className:"flex-1 truncate text-xs",title:N?c.name:void 0,children:N?dL(c.name):c.name}),(0,g.jsx)("span",{className:"text-[10px] text-muted-foreground/60 truncate max-w-[80px]",children:c.path.split("/").slice(0,-1).join("/")})]})}),(0,g.jsx)(cC,{node:{path:c.path,name:c.name,type:c.type??"file"},ctx:F,isPinned:G.some(a=>a.path===c.path),activeWorkspaceId:a.activeWorkspaceId})]},c.path))]}),c.rootLoading?(0,g.jsx)("div",{className:"flex justify-center py-6",children:(0,g.jsx)(m.Loader2,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):0===c.roots.length?(0,g.jsxs)("div",{className:"flex flex-col items-center gap-3 px-4 py-8 text-center",children:[(0,g.jsx)("div",{className:"rounded-full bg-muted p-3",children:(0,g.jsx)(j.FileText,{className:"h-6 w-6 text-muted-foreground"})}),(0,g.jsxs)("div",{className:"space-y-1",children:[(0,g.jsx)("p",{className:"text-sm font-medium",children:"No files yet"}),(0,g.jsx)("p",{className:"text-xs text-muted-foreground",children:"Upload files or add them to the configured directory"})]}),(0,g.jsxs)(u.Button,{size:"sm",variant:"outline",className:"w-full gap-1.5 max-w-[180px]",onClick:()=>d.triggerUpload(""),disabled:d.uploading,children:[d.uploading?(0,g.jsx)(m.Loader2,{className:"h-3.5 w-3.5 animate-spin"}):(0,g.jsx)(b_,{className:"h-3.5 w-3.5"}),"Upload Files"]})]}):(0,g.jsx)(cF,{ctx:F,nodes:c.roots,openPath:b.openFile?.path??null,dragOverPath:A,branchDropdownNode:c.branchDropdownNode,branchDropdownPos:c.branchDropdownPos,nodeBranches:c.nodeBranches,branchesLoading:c.branchesLoading,checkingOutBranch:c.checkingOutBranch,pullingRepo:c.pullingRepo,activePaths:I,pins:G,isMobile:e,activeWorkspaceId:a.activeWorkspaceId,newFileParent:w.file.parent,newFileName:w.file.name,fileCreateError:w.file.error,newFolderParent:w.folder.parent,newFolderName:w.folder.name,folderError:w.folder.error,sidebarScrollRef:E})]}),(0,g.jsx)(dI,{workspaces:a.workspaces,activeWorkspaceId:a.activeWorkspaceId,rootPath:a.rootPath,isWsAdmin:a.isWsAdmin,refreshingWsId:a.refreshingWsId,switchingBranch:a.switchingBranch,switchingBranchName:a.switchingBranchName,wsBranches:a.wsBranches,branchPickerWsId:a.branchPickerWsId,wsBranchPos:a.wsBranchPos,onSwitchWorkspace:b=>void a.switchWorkspace(b),onRefreshWorkspace:a.handleRefreshWorkspace,onPromptDeleteWorkspace:b=>a.setDeletingWorkspaceId(b),onAddWorkspace:()=>a.setAddingWorkspace(!0),setBranchPickerWsId:a.setBranchPickerWsId,setWsBranchPos:a.setWsBranchPos,loadWsBranches:a.loadWsBranches,handleSwitchBranch:a.handleSwitchBranch}),(0,g.jsx)("div",{role:"separator","aria-orientation":"vertical","aria-label":"Resize sidebar",title:"Drag to resize",onMouseDown:a=>{a.preventDefault();let b=a.clientX;n(!0);let c=document.body.style.cursor,d=document.body.style.userSelect;document.body.style.cursor="col-resize",document.body.style.userSelect="none";let e=a=>{s(p+(a.clientX-b))},f=()=>{n(!1),document.body.style.cursor=c,document.body.style.userSelect=d,window.removeEventListener("mousemove",e),window.removeEventListener("mouseup",f)};window.addEventListener("mousemove",e),window.addEventListener("mouseup",f)},onDoubleClick:()=>s(288),onKeyDown:a=>{"ArrowLeft"===a.key?(a.preventDefault(),s(p-16)):"ArrowRight"===a.key&&(a.preventDefault(),s(p+16))},tabIndex:0,"aria-valuemin":200,"aria-valuemax":600,"aria-valuenow":p,className:(0,an.cn)("absolute right-0 top-0 z-20 h-full w-1.5 cursor-col-resize -mr-px transition-colors hover:bg-primary/40 focus:bg-primary/40 focus:outline-none hidden md:block",l&&"bg-primary/60")})]})]})}function dN({workspace:a,doc:b,fileTree:c,upload:d,isMobile:e,hideChrome:f,sidebarCollapsed:h,setSidebarCollapsed:i,pins:j,recents:k,activePaths:l,setDeleting:m,setDialogs:n}){let[o,q]=(0,p.useState)(!1),[r,s]=(0,p.useState)(null),[t,u]=(0,p.useState)({pinned:!1,recent:!0}),[v,w]=(0,p.useState)({file:{parent:null,name:"",error:null},folder:{parent:null,name:"",error:null}}),x=(0,p.useRef)(null),y=(0,p.useRef)(null),z=dK(a=>a.width),A=dK(a=>a.setWidth),B=(0,p.useCallback)(async()=>{let a=v.file.name.trim();if(!a||null===v.file.parent)return;w(a=>({...a,file:{...a.file,error:null}}));let d=a.includes(".")?a:`${a}.md`,e=v.file.parent?`${v.file.parent}/${d}`:d,f=await fetch((0,bk.withWs)("/api/wiki/new-file"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e})});if(f.ok){let a=v.file.parent;w(a=>({...a,file:{parent:null,name:"",error:null}})),await c.reloadDir(a),b.openViewer({path:e,name:d,type:"file",modifiedAt:new Date().toISOString()})}else{let a=await f.json();w(b=>({...b,file:{...b.file,error:a.error??"Failed"}}))}},[v.file.parent,v.file.name,c,b]),C=(0,p.useCallback)(async()=>{let a=v.folder.name.trim();if(!a||null===v.folder.parent)return;w(a=>({...a,folder:{...a.folder,error:null}}));let b=v.folder.parent?`${v.folder.parent}/${a}`:a,d=await fetch((0,bk.withWs)("/api/wiki/folder"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:b})});if(d.ok){let a=v.folder.parent;w(a=>({...a,folder:{parent:null,name:"",error:null}})),await c.reloadDir(a)}else{let a=await d.json();w(b=>({...b,folder:{...b.folder,error:a.error??"Failed"}}))}},[v.folder.parent,v.folder.name,c]);function D(a,b,c){a.preventDefault(),a.stopPropagation();let d=y.current;if(!d){Array.from(a.dataTransfer.types).includes("Files")&&(a.dataTransfer.dropEffect="copy",s("root"===c?"":b));return}d.path===b||b.startsWith(`${d.path}/`)||(a.dataTransfer.dropEffect="move",s("root"===c?"":b))}async function E(a,e){a.preventDefault(),a.stopPropagation(),s(null);let f=y.current;if(y.current=null,!f){a.dataTransfer.files.length>0&&await d.doUpload(a.dataTransfer.files,e);return}if(f.path===e||e.startsWith(`${f.path}/`))return;let g=e?`${e}/${f.name}`:f.name;if(g!==f.path&&(await fetch((0,bk.withWs)("/api/wiki/move"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({from:f.path,to:g})})).ok){let a=f.path.includes("/")?f.path.split("/").slice(0,-1).join("/"):"";await c.reloadDir(a),e!==a&&await c.reloadDir(e),b.openFile?.path===f.path&&b.openViewer({path:g,name:f.name,type:f.type,modifiedAt:f.modifiedAt})}}let F=(0,p.useRef)(null);F.current={toggleFolder:a=>void c.toggleFolder(a),openViewer:a=>void b.openViewer(a),copyPath:a=>b.copyPath(a),copyWikiLink:a=>b.copyWikiLink(a),copyUrl:a=>b.copyUrl(a),copyRawContent:a=>void b.copyRawContent(a),copyFormattedContent:(a,c)=>void b.copyFormattedContent(a,c),handleDownload:function(a){let b=(0,bk.withWs)(`/api/wiki/download?path=${encodeURIComponent(a.path)}`),c=document.createElement("a");c.href=b,c.download="file"===a.type?a.name:`${a.name}.zip`,document.body.appendChild(c),c.click(),c.remove()},triggerUpload:a=>d.triggerUpload(a),handleCreateFile:B,handleCreateFolder:C,handleDragStart:function(a,b){y.current=b,a.dataTransfer.effectAllowed="move",a.dataTransfer.setData("text/plain",b.path)},handleDragOver:D,handleDropOnFolder:(a,b)=>void E(a,b),handleGitPull:(a,b)=>void c.handleGitPull(a,b),handleCheckout:(a,b,d)=>void c.handleCheckout(a,b,d),loadBranches:a=>void c.loadBranches(a),prefetch:a=>void c.prefetch(a),togglePin:(a,b)=>dJ.getState().toggle({path:a.path,name:a.name,type:a.type},b),setDragOverPath:s,setSidebarCollapsed:i,setBranchDropdownNode:a=>c.setBranchDropdownNode(a),setBranchDropdownPos:a=>c.setBranchDropdownPos(a),setNewFileParent:a=>w(b=>({...b,file:{...b.file,parent:a,error:null}})),setNewFileName:a=>w(b=>({...b,file:{...b.file,name:a}})),setFileCreateError:a=>w(b=>({...b,file:{...b.file,error:a}})),setNewFolderParent:a=>w(b=>({...b,folder:{...b.folder,parent:a,error:null}})),setNewFolderName:a=>w(b=>({...b,folder:{...b.folder,name:a}})),setFolderError:a=>w(b=>({...b,folder:{...b.folder,error:a}})),setDeletingPath:a=>m(b=>({...b,path:a})),setDeletingIsDir:a=>m(b=>({...b,isDir:a}))};let G=(0,p.useMemo)(()=>({toggleFolder:a=>F.current.toggleFolder(a),openViewer:a=>F.current.openViewer(a),copyPath:a=>F.current.copyPath(a),copyWikiLink:a=>F.current.copyWikiLink(a),copyUrl:a=>F.current.copyUrl(a),copyRawContent:a=>F.current.copyRawContent(a),copyFormattedContent:(a,b)=>F.current.copyFormattedContent(a,b),handleDownload:a=>F.current.handleDownload(a),triggerUpload:a=>F.current.triggerUpload(a),handleCreateFile:()=>F.current.handleCreateFile(),handleCreateFolder:()=>F.current.handleCreateFolder(),handleDragStart:(a,b)=>F.current.handleDragStart(a,b),handleDragOver:(a,b,c)=>F.current.handleDragOver(a,b,c),handleDropOnFolder:(a,b)=>F.current.handleDropOnFolder(a,b),handleGitPull:(a,b)=>F.current.handleGitPull(a,b),handleCheckout:(a,b,c)=>F.current.handleCheckout(a,b,c),loadBranches:a=>F.current.loadBranches(a),prefetch:a=>F.current.prefetch(a),togglePin:(a,b)=>F.current.togglePin(a,b),setDragOverPath:a=>F.current.setDragOverPath(a),setSidebarCollapsed:a=>F.current.setSidebarCollapsed(a),setBranchDropdownNode:a=>F.current.setBranchDropdownNode(a),setBranchDropdownPos:a=>F.current.setBranchDropdownPos(a),setNewFileParent:a=>F.current.setNewFileParent(a),setNewFileName:a=>F.current.setNewFileName(a),setFileCreateError:a=>F.current.setFileCreateError(a),setNewFolderParent:a=>F.current.setNewFolderParent(a),setNewFolderName:a=>F.current.setNewFolderName(a),setFolderError:a=>F.current.setFolderError(a),setDeletingPath:a=>F.current.setDeletingPath(a),setDeletingIsDir:a=>F.current.setDeletingIsDir(a)}),[]);return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(dv,{onOpenFile:b.openFromSearch,recents:k,onToggleSidebar:()=>i(a=>{let b=!a;return e&&!1===b&&bo.getState().close(),b}),onNewFile:()=>w(a=>({...a,file:{...a.file,parent:""}})),onCopyPath:()=>{b.openFile&&b.copyPath(b.openFile.path)}}),(0,g.jsx)(dM,{workspace:a,doc:b,fileTree:c,upload:d,isMobile:e,hideChrome:f,sidebarCollapsed:h,setSidebarCollapsed:i,sidebarResizing:o,setSidebarResizing:q,sidebarWidth:z,setSidebarWidth:A,collapsed:t,setCollapsed:u,createEntry:v,setCreateEntry:w,handleCreateFile:B,handleCreateFolder:C,dragOverPath:r,setDragOverPath:s,handleDragOver:D,handleDropOnFolder:E,sidebarScrollRef:x,treeCtx:G,pins:j,recents:k,activePaths:l,setDialogs:n,handleRefreshWorkspace:a.handleRefreshWorkspace})]})}let dO=(0,h.default)("code-xml",[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]]),dP=(0,h.default)("maximize-2",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]]),dQ=(0,h.default)("pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]),dR=(0,h.default)("share",[["path",{d:"M12 2v13",key:"1km8f5"}],["path",{d:"m16 6-4-4-4 4",key:"13yo43"}],["path",{d:"M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8",key:"1b2hhj"}]]),dS=(0,h.default)("user",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]);var dT=a.i(441218);let dU=(0,h.default)("save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);function dV({path:a,badge:b,sublabel:c,showBreadcrumb:d=!0,leading:e,children:f,className:h}){return(0,g.jsxs)("div",{className:(0,an.cn)("flex shrink-0 items-center justify-between gap-3 border-b border-border bg-background px-4 py-2",h),children:[(0,g.jsxs)("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[e,a&&(0,g.jsx)("span",{className:"text-xs text-muted-foreground truncate",title:a,children:a.split("/").pop()??a}),b&&(0,g.jsx)("span",{className:"shrink-0 rounded bg-muted px-1.5 py-0.5 text-xs text-muted-foreground/50",children:b}),c&&(0,g.jsx)("span",{className:"shrink-0 text-xs text-muted-foreground/40",children:c})]}),(0,g.jsx)("div",{className:"flex shrink-0 items-center gap-1",children:f})]})}function dW(a){let b=[],c="",d=!1,e=[];for(let f=0;f<a.length;f++){let g=a[f],h=a[f+1];d?'"'===g&&'"'===h?(c+='"',f++):'"'===g?d=!1:c+=g:'"'===g?d=!0:","===g?(e.push(c),c=""):"\n"===g||"\r"===g&&"\n"===h?(e.push(c),c="",e.length>0&&b.push(e),e=[],"\r"===g&&f++):c+=g}return e.push(c),e.some(a=>""!==a)&&b.push(e),b}function dX(a){return a.map(a=>a.map(a=>a.includes(",")||a.includes('"')||a.includes("\n")?`"${a.replace(/"/g,'""')}"`:a).join(",")).join("\n")}function dY({path:a}){let[b,c]=(0,p.useState)([]),[d,e]=(0,p.useState)(""),[f,h]=(0,p.useState)(!1),[i,j]=(0,p.useState)(!1),[k,l]=(0,p.useState)(!1),[m,n]=(0,p.useState)(null),[o,q]=(0,p.useState)(!1),[r,s]=(0,p.useState)(1e3),t=(0,bk.withWs)(`/api/assets/${a}`);(0,p.useEffect)(()=>{fetch(t).then(a=>a.text()).then(a=>{let b=dW(a),d=a.length>2097152||b.length>2e3;e(a),c(b),q(d),h(d),j(!1)})},[t]);let v=(0,p.useCallback)((a,b,d)=>{c(c=>{let e=c.map(a=>[...a]);for(;e.length<=a;)e.push([]);for(;e[a].length<=b;)e[a].push("");return e[a][b]=d,e}),j(!0)},[]),w=async()=>{l(!0);let g=f?d:dX(b);try{await (0,bk.wsFetch)(`/api/assets/${a}`,{method:"PUT",headers:{"Content-Type":"text/plain"},body:g}),f?c(dW(d)):e(g),j(!1)}catch(a){console.error("Failed to save CSV:",a)}l(!1)},x=b[0]||[],y=b.slice(1),z=o?y.slice(0,r):y,A=o&&r<y.length;return(0,g.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,g.jsxs)(dV,{path:a,badge:`CSV${b.length>0?` (${b.length-1} rows)`:""}`,children:[i&&(0,g.jsxs)(u.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:w,disabled:k,children:[(0,g.jsx)(dU,{className:"h-3.5 w-3.5"}),k?"Saving...":"Save"]}),o&&(0,g.jsxs)("span",{className:"text-[11px] text-amber-600 dark:text-amber-400 px-1",children:["Large file (",(d.length/1048576).toFixed(1)," MB,"," ",b.length.toLocaleString()," rows)"]}),(0,g.jsxs)("button",{onClick:()=>{f?c(dW(d)):e(dX(b)),h(!f)},className:`flex items-center gap-1.5 px-2.5 py-1 text-[11px] rounded-md transition-colors border border-border ${f?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-accent"}`,children:[(0,g.jsx)(dO,{className:"h-3 w-3"}),f?"Table":"Source"]}),(0,g.jsx)("button",{onClick:()=>window.open(t,"_blank"),className:"inline-flex items-center justify-center rounded-md h-8 w-8 hover:bg-accent hover:text-accent-foreground transition-colors cursor-pointer",title:"Download CSV",children:(0,g.jsx)(bW.Download,{className:"h-4 w-4"})})]}),f?(0,g.jsx)("div",{className:"flex-1 overflow-y-auto p-4",children:(0,g.jsx)("textarea",{value:d,onChange:a=>{e(a.target.value),j(!0)},className:"w-full h-full min-h-[calc(100vh-12rem)] bg-transparent font-mono text-[13px] leading-relaxed resize-none focus:outline-none",spellCheck:!1})}):(0,g.jsxs)("div",{className:"flex-1 overflow-auto",children:[(0,g.jsxs)("table",{className:"w-full border-collapse text-[13px]",children:[(0,g.jsx)("thead",{className:"sticky top-0 z-10",children:(0,g.jsxs)("tr",{className:"bg-muted/80 backdrop-blur-sm",children:[(0,g.jsx)("th",{className:"border border-border px-1 py-1 text-center text-[10px] text-muted-foreground w-8",children:"#"}),x.map((a,b)=>(0,g.jsx)("th",{className:"border border-border px-3 py-1.5 text-left font-medium text-foreground min-w-[100px]",children:m?.r===0&&m?.c===b?(0,g.jsx)("input",{autoFocus:!0,className:"w-full bg-transparent outline-none",value:a,onChange:a=>v(0,b,a.target.value),onBlur:()=>n(null),onKeyDown:a=>{("Enter"===a.key||"Escape"===a.key)&&n(null),"Tab"===a.key&&(a.preventDefault(),n({r:0,c:b+1<x.length?b+1:0}))}}):(0,g.jsx)("span",{className:"cursor-text",onDoubleClick:()=>n({r:0,c:b}),children:a||" "})},b))]})}),(0,g.jsx)("tbody",{children:z.map((a,b)=>{let d=b+1;return(0,g.jsxs)("tr",{className:"hover:bg-accent/30 transition-colors group",children:[(0,g.jsxs)("td",{className:"border border-border px-1 py-1 text-center text-[10px] text-muted-foreground/50",children:[(0,g.jsx)("span",{className:"group-hover:hidden",children:b+1}),(0,g.jsx)("button",{className:"hidden group-hover:inline text-destructive hover:text-destructive/80 text-[10px]",onClick:()=>{c(a=>a.filter((a,b)=>b!==d)),j(!0)},title:"Delete row",children:"×"})]}),x.map((b,c)=>{let e=a[c]??"",f=m?.r===d&&m?.c===c;return(0,g.jsx)("td",{className:"border border-border px-3 py-1.5",children:f?(0,g.jsx)("input",{autoFocus:!0,className:"w-full bg-transparent outline-none",value:e,onChange:a=>v(d,c,a.target.value),onBlur:()=>n(null),onKeyDown:a=>{"Escape"===a.key&&n(null),"Enter"===a.key&&n({r:d+1,c}),"Tab"===a.key&&(a.preventDefault(),a.shiftKey?n({r:d,c:Math.max(0,c-1)}):n({r:c+1>=x.length?d+1:d,c:c+1>=x.length?0:c+1}))}}):(0,g.jsx)("span",{className:"cursor-text",onDoubleClick:()=>n({r:d,c}),children:e||" "})},c)})]},b)})})]}),A&&(0,g.jsxs)("div",{className:"flex items-center gap-3 px-4 py-2 border-t border-border",children:[(0,g.jsxs)("button",{onClick:()=>s(a=>a+1e3),className:"text-[11px] text-foreground hover:bg-accent transition-colors px-2.5 py-1 rounded border border-border",children:["Show"," ",Math.min(1e3,y.length-r).toLocaleString()," ","more rows"]}),(0,g.jsxs)("span",{className:"text-[11px] text-muted-foreground",children:[r.toLocaleString()," /"," ",y.length.toLocaleString()," rows"]})]}),(0,g.jsxs)("div",{className:"flex items-center gap-2 px-4 py-2 border-t border-border",children:[(0,g.jsx)("button",{onClick:()=>{let a=b[0]?.length||1;c(b=>[...b,Array(a).fill("")]),j(!0)},className:"text-[11px] text-muted-foreground hover:text-foreground transition-colors px-2 py-1 rounded hover:bg-accent",children:"+ Add row"}),(0,g.jsx)("button",{onClick:()=>{c(a=>a.map(a=>[...a,""])),j(!0)},className:"text-[11px] text-muted-foreground hover:text-foreground transition-colors px-2 py-1 rounded hover:bg-accent",children:"+ Add column"})]})]})]})}function dZ(a){this.content=a}dZ.prototype={constructor:dZ,find:function(a){for(var b=0;b<this.content.length;b+=2)if(this.content[b]===a)return b;return -1},get:function(a){var b=this.find(a);return -1==b?void 0:this.content[b+1]},update:function(a,b,c){var d=c&&c!=a?this.remove(c):this,e=d.find(a),f=d.content.slice();return -1==e?f.push(c||a,b):(f[e+1]=b,c&&(f[e]=c)),new dZ(f)},remove:function(a){var b=this.find(a);if(-1==b)return this;var c=this.content.slice();return c.splice(b,2),new dZ(c)},addToStart:function(a,b){return new dZ([a,b].concat(this.remove(a).content))},addToEnd:function(a,b){var c=this.remove(a).content.slice();return c.push(a,b),new dZ(c)},addBefore:function(a,b,c){var d=this.remove(b),e=d.content.slice(),f=d.find(a);return e.splice(-1==f?e.length:f,0,b,c),new dZ(e)},forEach:function(a){for(var b=0;b<this.content.length;b+=2)a(this.content[b],this.content[b+1])},prepend:function(a){return(a=dZ.from(a)).size?new dZ(a.content.concat(this.subtract(a).content)):this},append:function(a){return(a=dZ.from(a)).size?new dZ(this.subtract(a).content.concat(a.content)):this},subtract:function(a){var b=this;a=dZ.from(a);for(var c=0;c<a.content.length;c+=2)b=b.remove(a.content[c]);return b},toObject:function(){var a={};return this.forEach(function(b,c){a[b]=c}),a},get size(){return this.content.length>>1}},dZ.from=function(a){if(a instanceof dZ)return a;var b=[];if(a)for(var c in a)b.push(c,a[c]);return new dZ(b)};class d${constructor(a,b){if(this.content=a,this.size=b||0,null==b)for(let b=0;b<a.length;b++)this.size+=a[b].nodeSize}nodesBetween(a,b,c,d=0,e){for(let f=0,g=0;g<b;f++){let h=this.content[f],i=g+h.nodeSize;if(i>a&&!1!==c(h,d+g,e||null,f)&&h.content.size){let e=g+1;h.nodesBetween(Math.max(0,a-e),Math.min(h.content.size,b-e),c,d+e)}g=i}}descendants(a){this.nodesBetween(0,this.size,a)}textBetween(a,b,c,d){let e="",f=!0;return this.nodesBetween(a,b,(g,h)=>{let i=g.isText?g.text.slice(Math.max(a,h)-h,b-h):g.isLeaf?d?"function"==typeof d?d(g):d:g.type.spec.leafText?g.type.spec.leafText(g):"":"";g.isBlock&&(g.isLeaf&&i||g.isTextblock)&&c&&(f?f=!1:e+=c),e+=i},0),e}append(a){if(!a.size)return this;if(!this.size)return a;let b=this.lastChild,c=a.firstChild,d=this.content.slice(),e=0;for(b.isText&&b.sameMarkup(c)&&(d[d.length-1]=b.withText(b.text+c.text),e=1);e<a.content.length;e++)d.push(a.content[e]);return new d$(d,this.size+a.size)}cut(a,b=this.size){if(0==a&&b==this.size)return this;let c=[],d=0;if(b>a)for(let e=0,f=0;f<b;e++){let g=this.content[e],h=f+g.nodeSize;h>a&&((f<a||h>b)&&(g=g.isText?g.cut(Math.max(0,a-f),Math.min(g.text.length,b-f)):g.cut(Math.max(0,a-f-1),Math.min(g.content.size,b-f-1))),c.push(g),d+=g.nodeSize),f=h}return new d$(c,d)}cutByIndex(a,b){return a==b?d$.empty:0==a&&b==this.content.length?this:new d$(this.content.slice(a,b))}replaceChild(a,b){let c=this.content[a];if(c==b)return this;let d=this.content.slice(),e=this.size+b.nodeSize-c.nodeSize;return d[a]=b,new d$(d,e)}addToStart(a){return new d$([a].concat(this.content),this.size+a.nodeSize)}addToEnd(a){return new d$(this.content.concat(a),this.size+a.nodeSize)}eq(a){if(this.content.length!=a.content.length)return!1;for(let b=0;b<this.content.length;b++)if(!this.content[b].eq(a.content[b]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(a){let b=this.content[a];if(!b)throw RangeError("Index "+a+" out of range for "+this);return b}maybeChild(a){return this.content[a]||null}forEach(a){for(let b=0,c=0;b<this.content.length;b++){let d=this.content[b];a(d,c,b),c+=d.nodeSize}}findDiffStart(a,b=0){return function a(b,c,d){for(let e=0;;e++){if(e==b.childCount||e==c.childCount)return b.childCount==c.childCount?null:d;let f=b.child(e),g=c.child(e);if(f==g){d+=f.nodeSize;continue}if(!f.sameMarkup(g))return d;if(f.isText&&f.text!=g.text){for(let a=0;f.text[a]==g.text[a];a++)d++;return d}if(f.content.size||g.content.size){let b=a(f.content,g.content,d+1);if(null!=b)return b}d+=f.nodeSize}}(this,a,b)}findDiffEnd(a,b=this.size,c=a.size){return function a(b,c,d,e){for(let f=b.childCount,g=c.childCount;;){if(0==f||0==g)return f==g?null:{a:d,b:e};let h=b.child(--f),i=c.child(--g),j=h.nodeSize;if(h==i){d-=j,e-=j;continue}if(!h.sameMarkup(i))return{a:d,b:e};if(h.isText&&h.text!=i.text){let a=0,b=Math.min(h.text.length,i.text.length);for(;a<b&&h.text[h.text.length-a-1]==i.text[i.text.length-a-1];)a++,d--,e--;return{a:d,b:e}}if(h.content.size||i.content.size){let b=a(h.content,i.content,d-1,e-1);if(b)return b}d-=j,e-=j}}(this,a,b,c)}findIndex(a){if(0==a)return d0(0,a);if(a==this.size)return d0(this.content.length,a);if(a>this.size||a<0)throw RangeError(`Position ${a} outside of fragment (${this})`);for(let b=0,c=0;;b++){let d=c+this.child(b).nodeSize;if(d>=a){if(d==a)return d0(b+1,d);return d0(b,c)}c=d}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(a=>a.toJSON()):null}static fromJSON(a,b){if(!b)return d$.empty;if(!Array.isArray(b))throw RangeError("Invalid input for Fragment.fromJSON");return d$.fromArray(b.map(a.nodeFromJSON))}static fromArray(a){if(!a.length)return d$.empty;let b,c=0;for(let d=0;d<a.length;d++){let e=a[d];c+=e.nodeSize,d&&e.isText&&a[d-1].sameMarkup(e)?(b||(b=a.slice(0,d)),b[b.length-1]=e.withText(b[b.length-1].text+e.text)):b&&b.push(e)}return new d$(b||a,c)}static from(a){if(!a)return d$.empty;if(a instanceof d$)return a;if(Array.isArray(a))return this.fromArray(a);if(a.attrs)return new d$([a],a.nodeSize);throw RangeError("Can not convert "+a+" to a Fragment"+(a.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}d$.empty=new d$([],0);let d_={index:0,offset:0};function d0(a,b){return d_.index=a,d_.offset=b,d_}function d1(a,b){if(a===b)return!0;if(!(a&&"object"==typeof a)||!(b&&"object"==typeof b))return!1;let c=Array.isArray(a);if(Array.isArray(b)!=c)return!1;if(c){if(a.length!=b.length)return!1;for(let c=0;c<a.length;c++)if(!d1(a[c],b[c]))return!1}else{for(let c in a)if(!(c in b)||!d1(a[c],b[c]))return!1;for(let c in b)if(!(c in a))return!1}return!0}class d2{constructor(a,b){this.type=a,this.attrs=b}addToSet(a){let b,c=!1;for(let d=0;d<a.length;d++){let e=a[d];if(this.eq(e))return a;if(this.type.excludes(e.type))b||(b=a.slice(0,d));else{if(e.type.excludes(this.type))return a;!c&&e.type.rank>this.type.rank&&(b||(b=a.slice(0,d)),b.push(this),c=!0),b&&b.push(e)}}return b||(b=a.slice()),c||b.push(this),b}removeFromSet(a){for(let b=0;b<a.length;b++)if(this.eq(a[b]))return a.slice(0,b).concat(a.slice(b+1));return a}isInSet(a){for(let b=0;b<a.length;b++)if(this.eq(a[b]))return!0;return!1}eq(a){return this==a||this.type==a.type&&d1(this.attrs,a.attrs)}toJSON(){let a={type:this.type.name};for(let b in this.attrs){a.attrs=this.attrs;break}return a}static fromJSON(a,b){if(!b)throw RangeError("Invalid input for Mark.fromJSON");let c=a.marks[b.type];if(!c)throw RangeError(`There is no mark type ${b.type} in this schema`);let d=c.create(b.attrs);return c.checkAttrs(d.attrs),d}static sameSet(a,b){if(a==b)return!0;if(a.length!=b.length)return!1;for(let c=0;c<a.length;c++)if(!a[c].eq(b[c]))return!1;return!0}static setFrom(a){if(!a||Array.isArray(a)&&0==a.length)return d2.none;if(a instanceof d2)return[a];let b=a.slice();return b.sort((a,b)=>a.type.rank-b.type.rank),b}}d2.none=[];class d3 extends Error{}class d4{constructor(a,b,c){this.content=a,this.openStart=b,this.openEnd=c}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(a,b){let c=function a(b,c,d,e,f,g){let{index:h,offset:i}=b.findIndex(c),j=b.maybeChild(h);if(i==c||j.isText)return g&&e<=0&&f<=0&&!g.canReplace(h,h,d)?null:b.cut(0,c).append(d).append(b.cut(c));let k=a(j.content,c-i-1,d,0==h?e-1:0,h==b.childCount-1?f-1:0,j);return k&&b.replaceChild(h,j.copy(k))}(this.content,a+this.openStart,b,this.openStart+1,this.openEnd+1);return c&&new d4(c,this.openStart,this.openEnd)}removeBetween(a,b){return new d4(function a(b,c,d){let{index:e,offset:f}=b.findIndex(c),g=b.maybeChild(e),{index:h,offset:i}=b.findIndex(d);if(f==c||g.isText){if(i!=d&&!b.child(h).isText)throw RangeError("Removing non-flat range");return b.cut(0,c).append(b.cut(d))}if(e!=h)throw RangeError("Removing non-flat range");return b.replaceChild(e,g.copy(a(g.content,c-f-1,d-f-1)))}(this.content,a+this.openStart,b+this.openStart),this.openStart,this.openEnd)}eq(a){return this.content.eq(a.content)&&this.openStart==a.openStart&&this.openEnd==a.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let a={content:this.content.toJSON()};return this.openStart>0&&(a.openStart=this.openStart),this.openEnd>0&&(a.openEnd=this.openEnd),a}static fromJSON(a,b){if(!b)return d4.empty;let c=b.openStart||0,d=b.openEnd||0;if("number"!=typeof c||"number"!=typeof d)throw RangeError("Invalid input for Slice.fromJSON");return new d4(d$.fromJSON(a,b.content),c,d)}static maxOpen(a,b=!0){let c=0,d=0;for(let d=a.firstChild;d&&!d.isLeaf&&(b||!d.type.spec.isolating);d=d.firstChild)c++;for(let c=a.lastChild;c&&!c.isLeaf&&(b||!c.type.spec.isolating);c=c.lastChild)d++;return new d4(a,c,d)}}function d5(a,b){if(!b.type.compatibleContent(a.type))throw new d3("Cannot join "+b.type.name+" onto "+a.type.name)}function d6(a,b,c){let d=a.node(c);return d5(d,b.node(c)),d}function d7(a,b){let c=b.length-1;c>=0&&a.isText&&a.sameMarkup(b[c])?b[c]=a.withText(b[c].text+a.text):b.push(a)}function d8(a,b,c,d){let e=(b||a).node(c),f=0,g=b?b.index(c):e.childCount;a&&(f=a.index(c),a.depth>c?f++:a.textOffset&&(d7(a.nodeAfter,d),f++));for(let a=f;a<g;a++)d7(e.child(a),d);b&&b.depth==c&&b.textOffset&&d7(b.nodeBefore,d)}function d9(a,b){return a.type.checkContent(b),a.copy(b)}function ea(a,b,c){let d=[];return d8(null,a,c,d),a.depth>c&&d7(d9(d6(a,b,c+1),ea(a,b,c+1)),d),d8(b,null,c,d),new d$(d)}d4.empty=new d4(d$.empty,0,0);class eb{constructor(a,b,c){this.pos=a,this.path=b,this.parentOffset=c,this.depth=b.length/3-1}resolveDepth(a){return null==a?this.depth:a<0?this.depth+a:a}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(a){return this.path[3*this.resolveDepth(a)]}index(a){return this.path[3*this.resolveDepth(a)+1]}indexAfter(a){return a=this.resolveDepth(a),this.index(a)+(a!=this.depth||this.textOffset?1:0)}start(a){return 0==(a=this.resolveDepth(a))?0:this.path[3*a-1]+1}end(a){return a=this.resolveDepth(a),this.start(a)+this.node(a).content.size}before(a){if(!(a=this.resolveDepth(a)))throw RangeError("There is no position before the top-level node");return a==this.depth+1?this.pos:this.path[3*a-1]}after(a){if(!(a=this.resolveDepth(a)))throw RangeError("There is no position after the top-level node");return a==this.depth+1?this.pos:this.path[3*a-1]+this.path[3*a].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let a=this.parent,b=this.index(this.depth);if(b==a.childCount)return null;let c=this.pos-this.path[this.path.length-1],d=a.child(b);return c?a.child(b).cut(c):d}get nodeBefore(){let a=this.index(this.depth),b=this.pos-this.path[this.path.length-1];return b?this.parent.child(a).cut(0,b):0==a?null:this.parent.child(a-1)}posAtIndex(a,b){b=this.resolveDepth(b);let c=this.path[3*b],d=0==b?0:this.path[3*b-1]+1;for(let b=0;b<a;b++)d+=c.child(b).nodeSize;return d}marks(){let a=this.parent,b=this.index();if(0==a.content.size)return d2.none;if(this.textOffset)return a.child(b).marks;let c=a.maybeChild(b-1),d=a.maybeChild(b);if(!c){let a=c;c=d,d=a}let e=c.marks;for(var f=0;f<e.length;f++)!1!==e[f].type.spec.inclusive||d&&e[f].isInSet(d.marks)||(e=e[f--].removeFromSet(e));return e}marksAcross(a){let b=this.parent.maybeChild(this.index());if(!b||!b.isInline)return null;let c=b.marks,d=a.parent.maybeChild(a.index());for(var e=0;e<c.length;e++)!1!==c[e].type.spec.inclusive||d&&c[e].isInSet(d.marks)||(c=c[e--].removeFromSet(c));return c}sharedDepth(a){for(let b=this.depth;b>0;b--)if(this.start(b)<=a&&this.end(b)>=a)return b;return 0}blockRange(a=this,b){if(a.pos<this.pos)return a.blockRange(this);for(let c=this.depth-(this.parent.inlineContent||this.pos==a.pos?1:0);c>=0;c--)if(a.pos<=this.end(c)&&(!b||b(this.node(c))))return new ef(this,a,c);return null}sameParent(a){return this.pos-this.parentOffset==a.pos-a.parentOffset}max(a){return a.pos>this.pos?a:this}min(a){return a.pos<this.pos?a:this}toString(){let a="";for(let b=1;b<=this.depth;b++)a+=(a?"/":"")+this.node(b).type.name+"_"+this.index(b-1);return a+":"+this.parentOffset}static resolve(a,b){if(!(b>=0&&b<=a.content.size))throw RangeError("Position "+b+" out of range");let c=[],d=0,e=b;for(let b=a;;){let{index:a,offset:f}=b.content.findIndex(e),g=e-f;if(c.push(b,a,d+f),!g||(b=b.child(a)).isText)break;e=g-1,d+=f+1}return new eb(b,c,e)}static resolveCached(a,b){let c=ee.get(a);if(c)for(let a=0;a<c.elts.length;a++){let d=c.elts[a];if(d.pos==b)return d}else ee.set(a,c=new ec);let d=c.elts[c.i]=eb.resolve(a,b);return c.i=(c.i+1)%ed,d}}class ec{constructor(){this.elts=[],this.i=0}}let ed=12,ee=new WeakMap;class ef{constructor(a,b,c){this.$from=a,this.$to=b,this.depth=c}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}let eg=Object.create(null);class eh{constructor(a,b,c,d=d2.none){this.type=a,this.attrs=b,this.marks=d,this.content=c||d$.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(a){return this.content.child(a)}maybeChild(a){return this.content.maybeChild(a)}forEach(a){this.content.forEach(a)}nodesBetween(a,b,c,d=0){this.content.nodesBetween(a,b,c,d,this)}descendants(a){this.nodesBetween(0,this.content.size,a)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(a,b,c,d){return this.content.textBetween(a,b,c,d)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(a){return this==a||this.sameMarkup(a)&&this.content.eq(a.content)}sameMarkup(a){return this.hasMarkup(a.type,a.attrs,a.marks)}hasMarkup(a,b,c){return this.type==a&&d1(this.attrs,b||a.defaultAttrs||eg)&&d2.sameSet(this.marks,c||d2.none)}copy(a=null){return a==this.content?this:new eh(this.type,this.attrs,a,this.marks)}mark(a){return a==this.marks?this:new eh(this.type,this.attrs,this.content,a)}cut(a,b=this.content.size){return 0==a&&b==this.content.size?this:this.copy(this.content.cut(a,b))}slice(a,b=this.content.size,c=!1){if(a==b)return d4.empty;let d=this.resolve(a),e=this.resolve(b),f=c?0:d.sharedDepth(b),g=d.start(f);return new d4(d.node(f).content.cut(d.pos-g,e.pos-g),d.depth-f,e.depth-f)}replace(a,b,c){var d=this.resolve(a),e=this.resolve(b);if(c.openStart>d.depth)throw new d3("Inserted content deeper than insertion position");if(d.depth-c.openStart!=e.depth-c.openEnd)throw new d3("Inconsistent open depths");return function a(b,c,d,e){let f=b.index(e),g=b.node(e);if(f==c.index(e)&&e<b.depth-d.openStart){let h=a(b,c,d,e+1);return g.copy(g.content.replaceChild(f,h))}if(!d.content.size)return d9(g,ea(b,c,e));if(d.openStart||d.openEnd||b.depth!=e||c.depth!=e){let{start:a,end:f}=function(a,b){let c=b.depth-a.openStart,d=b.node(c).copy(a.content);for(let a=c-1;a>=0;a--)d=b.node(a).copy(d$.from(d));return{start:d.resolveNoCache(a.openStart+c),end:d.resolveNoCache(d.content.size-a.openEnd-c)}}(d,b);return d9(g,function a(b,c,d,e,f){let g=b.depth>f&&d6(b,c,f+1),h=e.depth>f&&d6(d,e,f+1),i=[];return d8(null,b,f,i),g&&h&&c.index(f)==d.index(f)?(d5(g,h),d7(d9(g,a(b,c,d,e,f+1)),i)):(g&&d7(d9(g,ea(b,c,f+1)),i),d8(c,d,f,i),h&&d7(d9(h,ea(d,e,f+1)),i)),d8(e,null,f,i),new d$(i)}(b,a,f,c,e))}{let a=b.parent,e=a.content;return d9(a,e.cut(0,b.parentOffset).append(d.content).append(e.cut(c.parentOffset)))}}(d,e,c,0)}nodeAt(a){for(let b=this;;){let{index:c,offset:d}=b.content.findIndex(a);if(!(b=b.maybeChild(c)))return null;if(d==a||b.isText)return b;a-=d+1}}childAfter(a){let{index:b,offset:c}=this.content.findIndex(a);return{node:this.content.maybeChild(b),index:b,offset:c}}childBefore(a){if(0==a)return{node:null,index:0,offset:0};let{index:b,offset:c}=this.content.findIndex(a);if(c<a)return{node:this.content.child(b),index:b,offset:c};let d=this.content.child(b-1);return{node:d,index:b-1,offset:c-d.nodeSize}}resolve(a){return eb.resolveCached(this,a)}resolveNoCache(a){return eb.resolve(this,a)}rangeHasMark(a,b,c){let d=!1;return b>a&&this.nodesBetween(a,b,a=>(c.isInSet(a.marks)&&(d=!0),!d)),d}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let a=this.type.name;return this.content.size&&(a+="("+this.content.toStringInner()+")"),ej(this.marks,a)}contentMatchAt(a){let b=this.type.contentMatch.matchFragment(this.content,0,a);if(!b)throw Error("Called contentMatchAt on a node with invalid content");return b}canReplace(a,b,c=d$.empty,d=0,e=c.childCount){let f=this.contentMatchAt(a).matchFragment(c,d,e),g=f&&f.matchFragment(this.content,b);if(!g||!g.validEnd)return!1;for(let a=d;a<e;a++)if(!this.type.allowsMarks(c.child(a).marks))return!1;return!0}canReplaceWith(a,b,c,d){if(d&&!this.type.allowsMarks(d))return!1;let e=this.contentMatchAt(a).matchType(c),f=e&&e.matchFragment(this.content,b);return!!f&&f.validEnd}canAppend(a){return a.content.size?this.canReplace(this.childCount,this.childCount,a.content):this.type.compatibleContent(a.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let a=d2.none;for(let b=0;b<this.marks.length;b++){let c=this.marks[b];c.type.checkAttrs(c.attrs),a=c.addToSet(a)}if(!d2.sameSet(a,this.marks))throw RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(a=>a.type.name)}`);this.content.forEach(a=>a.check())}toJSON(){let a={type:this.type.name};for(let b in this.attrs){a.attrs=this.attrs;break}return this.content.size&&(a.content=this.content.toJSON()),this.marks.length&&(a.marks=this.marks.map(a=>a.toJSON())),a}static fromJSON(a,b){let c;if(!b)throw RangeError("Invalid input for Node.fromJSON");if(b.marks){if(!Array.isArray(b.marks))throw RangeError("Invalid mark data for Node.fromJSON");c=b.marks.map(a.markFromJSON)}if("text"==b.type){if("string"!=typeof b.text)throw RangeError("Invalid text node in JSON");return a.text(b.text,c)}let d=d$.fromJSON(a,b.content),e=a.nodeType(b.type).create(b.attrs,d,c);return e.type.checkAttrs(e.attrs),e}}eh.prototype.text=void 0;class ei extends eh{constructor(a,b,c,d){if(super(a,b,null,d),!c)throw RangeError("Empty text nodes are not allowed");this.text=c}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):ej(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(a,b){return this.text.slice(a,b)}get nodeSize(){return this.text.length}mark(a){return a==this.marks?this:new ei(this.type,this.attrs,this.text,a)}withText(a){return a==this.text?this:new ei(this.type,this.attrs,a,this.marks)}cut(a=0,b=this.text.length){return 0==a&&b==this.text.length?this:this.withText(this.text.slice(a,b))}eq(a){return this.sameMarkup(a)&&this.text==a.text}toJSON(){let a=super.toJSON();return a.text=this.text,a}}function ej(a,b){for(let c=a.length-1;c>=0;c--)b=a[c].type.name+"("+b+")";return b}class ek{constructor(a){this.validEnd=a,this.next=[],this.wrapCache=[]}static parse(a,b){var c;let d,e=new el(a,b);if(null==e.next)return ek.empty;let f=function a(b){let c=[];do c.push(function(b){let c=[];do c.push(function(b){let c=function(b){if(b.eat("(")){let c=a(b);return b.eat(")")||b.err("Missing closing paren"),c}if(/\W/.test(b.next))b.err("Unexpected token '"+b.next+"'");else{let a=(function(a,b){let c=a.nodeTypes,d=c[b];if(d)return[d];let e=[];for(let a in c){let d=c[a];d.isInGroup(b)&&e.push(d)}return 0==e.length&&a.err("No node type or group '"+b+"' found"),e})(b,b.next).map(a=>(null==b.inline?b.inline=a.isInline:b.inline!=a.isInline&&b.err("Mixing inline and block content"),{type:"name",value:a}));return b.pos++,1==a.length?a[0]:{type:"choice",exprs:a}}}(b);for(;;)if(b.eat("+"))c={type:"plus",expr:c};else if(b.eat("*"))c={type:"star",expr:c};else if(b.eat("?"))c={type:"opt",expr:c};else if(b.eat("{"))c=function(a,b){let c=em(a),d=c;return a.eat(",")&&(d="}"!=a.next?em(a):-1),a.eat("}")||a.err("Unclosed braced range"),{type:"range",min:c,max:d,expr:b}}(b,c);else break;return c}(b));while(b.next&&")"!=b.next&&"|"!=b.next)return 1==c.length?c[0]:{type:"seq",exprs:c}}(b));while(b.eat("|"))return 1==c.length?c[0]:{type:"choice",exprs:c}}(e);e.next&&e.err("Unexpected trailing text");let g=(c=function(a){let b=[[]];return e(function a(b,f){if("choice"==b.type)return b.exprs.reduce((b,c)=>b.concat(a(c,f)),[]);if("seq"==b.type)for(let d=0;;d++){let g=a(b.exprs[d],f);if(d==b.exprs.length-1)return g;e(g,f=c())}else if("star"==b.type){let g=c();return d(f,g),e(a(b.expr,g),g),[d(g)]}else if("plus"==b.type){let g=c();return e(a(b.expr,f),g),e(a(b.expr,g),g),[d(g)]}else if("opt"==b.type)return[d(f)].concat(a(b.expr,f));else if("range"==b.type){let g=f;for(let d=0;d<b.min;d++){let d=c();e(a(b.expr,g),d),g=d}if(-1==b.max)e(a(b.expr,g),g);else for(let f=b.min;f<b.max;f++){let f=c();d(g,f),e(a(b.expr,g),f),g=f}return[d(g)]}else if("name"==b.type)return[d(f,void 0,b.value)];else throw Error("Unknown expr type")}(a,0),c()),b;function c(){return b.push([])-1}function d(a,c,d){let e={term:d,to:c};return b[a].push(e),e}function e(a,b){a.forEach(a=>a.to=b)}}(f),d=Object.create(null),function a(b){let e=[];b.forEach(a=>{c[a].forEach(({term:a,to:b})=>{let d;if(a){for(let b=0;b<e.length;b++)e[b][0]==a&&(d=e[b][1]);eo(c,b).forEach(b=>{d||e.push([a,d=[]]),-1==d.indexOf(b)&&d.push(b)})}})});let f=d[b.join(",")]=new ek(b.indexOf(c.length-1)>-1);for(let b=0;b<e.length;b++){let c=e[b][1].sort(en);f.next.push({type:e[b][0],next:d[c.join(",")]||a(c)})}return f}(eo(c,0)));return function(a,b){for(let c=0,d=[a];c<d.length;c++){let a=d[c],e=!a.validEnd,f=[];for(let b=0;b<a.next.length;b++){let{type:c,next:g}=a.next[b];f.push(c.name),e&&!(c.isText||c.hasRequiredAttrs())&&(e=!1),-1==d.indexOf(g)&&d.push(g)}e&&b.err("Only non-generatable nodes ("+f.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}(g,e),g}matchType(a){for(let b=0;b<this.next.length;b++)if(this.next[b].type==a)return this.next[b].next;return null}matchFragment(a,b=0,c=a.childCount){let d=this;for(let e=b;d&&e<c;e++)d=d.matchType(a.child(e).type);return d}get inlineContent(){return 0!=this.next.length&&this.next[0].type.isInline}get defaultType(){for(let a=0;a<this.next.length;a++){let{type:b}=this.next[a];if(!(b.isText||b.hasRequiredAttrs()))return b}return null}compatible(a){for(let b=0;b<this.next.length;b++)for(let c=0;c<a.next.length;c++)if(this.next[b].type==a.next[c].type)return!0;return!1}fillBefore(a,b=!1,c=0){let d=[this];return function e(f,g){let h=f.matchFragment(a,c);if(h&&(!b||h.validEnd))return d$.from(g.map(a=>a.createAndFill()));for(let a=0;a<f.next.length;a++){let{type:b,next:c}=f.next[a];if(!(b.isText||b.hasRequiredAttrs())&&-1==d.indexOf(c)){d.push(c);let a=e(c,g.concat(b));if(a)return a}}return null}(this,[])}findWrapping(a){for(let b=0;b<this.wrapCache.length;b+=2)if(this.wrapCache[b]==a)return this.wrapCache[b+1];let b=this.computeWrapping(a);return this.wrapCache.push(a,b),b}computeWrapping(a){let b=Object.create(null),c=[{match:this,type:null,via:null}];for(;c.length;){let d=c.shift(),e=d.match;if(e.matchType(a)){let a=[];for(let b=d;b.type;b=b.via)a.push(b.type);return a.reverse()}for(let a=0;a<e.next.length;a++){let{type:f,next:g}=e.next[a];f.isLeaf||f.hasRequiredAttrs()||f.name in b||d.type&&!g.validEnd||(c.push({match:f.contentMatch,type:f,via:d}),b[f.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(a){if(a>=this.next.length)throw RangeError(`There's no ${a}th edge in this content match`);return this.next[a]}toString(){let a=[];return!function b(c){a.push(c);for(let d=0;d<c.next.length;d++)-1==a.indexOf(c.next[d].next)&&b(c.next[d].next)}(this),a.map((b,c)=>{let d=c+(b.validEnd?"*":" ")+" ";for(let c=0;c<b.next.length;c++)d+=(c?", ":"")+b.next[c].type.name+"->"+a.indexOf(b.next[c].next);return d}).join("\n")}}ek.empty=new ek(!0);class el{constructor(a,b){this.string=a,this.nodeTypes=b,this.inline=null,this.pos=0,this.tokens=a.split(/\s*(?=\b|\W|$)/),""==this.tokens[this.tokens.length-1]&&this.tokens.pop(),""==this.tokens[0]&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(a){return this.next==a&&(this.pos++||!0)}err(a){throw SyntaxError(a+" (in content expression '"+this.string+"')")}}function em(a){/\D/.test(a.next)&&a.err("Expected number, got '"+a.next+"'");let b=Number(a.next);return a.pos++,b}function en(a,b){return b-a}function eo(a,b){let c=[];return function b(d){let e=a[d];if(1==e.length&&!e[0].term)return b(e[0].to);c.push(d);for(let a=0;a<e.length;a++){let{term:d,to:f}=e[a];d||-1!=c.indexOf(f)||b(f)}}(b),c.sort(en)}function ep(a){let b=Object.create(null);for(let c in a){let d=a[c];if(!d.hasDefault)return null;b[c]=d.default}return b}function eq(a,b){let c=Object.create(null);for(let d in a){let e=b&&b[d];if(void 0===e){let b=a[d];if(b.hasDefault)e=b.default;else throw RangeError("No value supplied for attribute "+d)}c[d]=e}return c}function er(a,b,c,d){for(let d in b)if(!(d in a))throw RangeError(`Unsupported attribute ${d} for ${c} of type ${d}`);for(let c in a){let d=a[c];d.validate&&d.validate(b[c])}}function es(a,b){let c=Object.create(null);if(b)for(let d in b)c[d]=new eu(a,d,b[d]);return c}class et{constructor(a,b,c){this.name=a,this.schema=b,this.spec=c,this.markSet=null,this.groups=c.group?c.group.split(" "):[],this.attrs=es(a,c.attrs),this.defaultAttrs=ep(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(c.inline||"text"==a),this.isText="text"==a}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==ek.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(a){return this.groups.indexOf(a)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let a in this.attrs)if(this.attrs[a].isRequired)return!0;return!1}compatibleContent(a){return this==a||this.contentMatch.compatible(a.contentMatch)}computeAttrs(a){return!a&&this.defaultAttrs?this.defaultAttrs:eq(this.attrs,a)}create(a=null,b,c){if(this.isText)throw Error("NodeType.create can't construct text nodes");return new eh(this,this.computeAttrs(a),d$.from(b),d2.setFrom(c))}createChecked(a=null,b,c){return b=d$.from(b),this.checkContent(b),new eh(this,this.computeAttrs(a),b,d2.setFrom(c))}createAndFill(a=null,b,c){if(a=this.computeAttrs(a),(b=d$.from(b)).size){let a=this.contentMatch.fillBefore(b);if(!a)return null;b=a.append(b)}let d=this.contentMatch.matchFragment(b),e=d&&d.fillBefore(d$.empty,!0);return e?new eh(this,a,b.append(e),d2.setFrom(c)):null}validContent(a){let b=this.contentMatch.matchFragment(a);if(!b||!b.validEnd)return!1;for(let b=0;b<a.childCount;b++)if(!this.allowsMarks(a.child(b).marks))return!1;return!0}checkContent(a){if(!this.validContent(a))throw RangeError(`Invalid content for node ${this.name}: ${a.toString().slice(0,50)}`)}checkAttrs(a){er(this.attrs,a,"node",this.name)}allowsMarkType(a){return null==this.markSet||this.markSet.indexOf(a)>-1}allowsMarks(a){if(null==this.markSet)return!0;for(let b=0;b<a.length;b++)if(!this.allowsMarkType(a[b].type))return!1;return!0}allowedMarks(a){let b;if(null==this.markSet)return a;for(let c=0;c<a.length;c++)this.allowsMarkType(a[c].type)?b&&b.push(a[c]):b||(b=a.slice(0,c));return b?b.length?b:d2.none:a}static compile(a,b){let c=Object.create(null);a.forEach((a,d)=>c[a]=new et(a,b,d));let d=b.spec.topNode||"doc";if(!c[d])throw RangeError("Schema is missing its top node type ('"+d+"')");if(!c.text)throw RangeError("Every schema needs a 'text' type");for(let a in c.text.attrs)throw RangeError("The text node type should not have attributes");return c}}class eu{constructor(a,b,c){this.hasDefault=Object.prototype.hasOwnProperty.call(c,"default"),this.default=c.default,this.validate="string"==typeof c.validate?function(a,b,c){let d=c.split("|");return c=>{let e=null===c?"null":typeof c;if(0>d.indexOf(e))throw RangeError(`Expected value of type ${d} for attribute ${b} on type ${a}, got ${e}`)}}(a,b,c.validate):c.validate}get isRequired(){return!this.hasDefault}}class ev{constructor(a,b,c,d){this.name=a,this.rank=b,this.schema=c,this.spec=d,this.attrs=es(a,d.attrs),this.excluded=null;let e=ep(this.attrs);this.instance=e?new d2(this,e):null}create(a=null){return!a&&this.instance?this.instance:new d2(this,eq(this.attrs,a))}static compile(a,b){let c=Object.create(null),d=0;return a.forEach((a,e)=>c[a]=new ev(a,d++,b,e)),c}removeFromSet(a){for(var b=0;b<a.length;b++)a[b].type==this&&(a=a.slice(0,b).concat(a.slice(b+1)),b--);return a}isInSet(a){for(let b=0;b<a.length;b++)if(a[b].type==this)return a[b]}checkAttrs(a){er(this.attrs,a,"mark",this.name)}excludes(a){return this.excluded.indexOf(a)>-1}}class ew{constructor(a){this.linebreakReplacement=null,this.cached=Object.create(null);let b=this.spec={};for(let c in a)b[c]=a[c];b.nodes=dZ.from(a.nodes),b.marks=dZ.from(a.marks||{}),this.nodes=et.compile(this.spec.nodes,this),this.marks=ev.compile(this.spec.marks,this);let c=Object.create(null);for(let a in this.nodes){if(a in this.marks)throw RangeError(a+" can not be both a node and a mark");let b=this.nodes[a],d=b.spec.content||"",e=b.spec.marks;if(b.contentMatch=c[d]||(c[d]=ek.parse(d,this.nodes)),b.inlineContent=b.contentMatch.inlineContent,b.spec.linebreakReplacement){if(this.linebreakReplacement)throw RangeError("Multiple linebreak nodes defined");if(!b.isInline||!b.isLeaf)throw RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=b}b.markSet="_"==e?null:e?ex(this,e.split(" ")):""!=e&&b.inlineContent?null:[]}for(let a in this.marks){let b=this.marks[a],c=b.spec.excludes;b.excluded=null==c?[b]:""==c?[]:ex(this,c.split(" "))}this.nodeFromJSON=a=>eh.fromJSON(this,a),this.markFromJSON=a=>d2.fromJSON(this,a),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(a,b=null,c,d){if("string"==typeof a)a=this.nodeType(a);else if(a instanceof et){if(a.schema!=this)throw RangeError("Node type from different schema used ("+a.name+")")}else throw RangeError("Invalid node type: "+a);return a.createChecked(b,c,d)}text(a,b){let c=this.nodes.text;return new ei(c,c.defaultAttrs,a,d2.setFrom(b))}mark(a,b){return"string"==typeof a&&(a=this.marks[a]),a.create(b)}nodeType(a){let b=this.nodes[a];if(!b)throw RangeError("Unknown node type: "+a);return b}}function ex(a,b){let c=[];for(let d=0;d<b.length;d++){let e=b[d],f=a.marks[e],g=f;if(f)c.push(f);else for(let b in a.marks){let d=a.marks[b];("_"==e||d.spec.group&&d.spec.group.split(" ").indexOf(e)>-1)&&c.push(g=d)}if(!g)throw SyntaxError("Unknown mark type: '"+b[d]+"'")}return c}class ey{constructor(a,b){this.schema=a,this.rules=b,this.tags=[],this.styles=[];let c=this.matchedStyles=[];b.forEach(a=>{if(null!=a.tag)this.tags.push(a);else if(null!=a.style){let b=/[^=]*/.exec(a.style)[0];0>c.indexOf(b)&&c.push(b),this.styles.push(a)}}),this.normalizeLists=!this.tags.some(b=>{if(!/^(ul|ol)\b/.test(b.tag)||!b.node)return!1;let c=a.nodes[b.node];return c.contentMatch.matchType(c)})}parse(a,b={}){let c=new eE(this,b,!1);return c.addAll(a,d2.none,b.from,b.to),c.finish()}parseSlice(a,b={}){let c=new eE(this,b,!0);return c.addAll(a,d2.none,b.from,b.to),d4.maxOpen(c.finish())}matchTag(a,b,c){for(let f=c?this.tags.indexOf(c)+1:0;f<this.tags.length;f++){var d,e;let c=this.tags[f];if(d=a,e=c.tag,(d.matches||d.msMatchesSelector||d.webkitMatchesSelector||d.mozMatchesSelector).call(d,e)&&(void 0===c.namespace||a.namespaceURI==c.namespace)&&(!c.context||b.matchesContext(c.context))){if(c.getAttrs){let b=c.getAttrs(a);if(!1===b)continue;c.attrs=b||void 0}return c}}}matchStyle(a,b,c,d){for(let e=d?this.styles.indexOf(d)+1:0;e<this.styles.length;e++){let d=this.styles[e],f=d.style;if(0==f.indexOf(a)&&(!d.context||c.matchesContext(d.context))&&(!(f.length>a.length)||61==f.charCodeAt(a.length)&&f.slice(a.length+1)==b)){if(d.getAttrs){let a=d.getAttrs(b);if(!1===a)continue;d.attrs=a||void 0}return d}}}static schemaRules(a){let b=[];function c(a){let c=null==a.priority?50:a.priority,d=0;for(;d<b.length;d++){let a=b[d];if((null==a.priority?50:a.priority)<c)break}b.splice(d,0,a)}for(let b in a.marks){let d=a.marks[b].spec.parseDOM;d&&d.forEach(a=>{c(a=eF(a)),a.mark||a.ignore||a.clearMark||(a.mark=b)})}for(let b in a.nodes){let d=a.nodes[b].spec.parseDOM;d&&d.forEach(a=>{c(a=eF(a)),a.node||a.ignore||a.mark||(a.node=b)})}return b}static fromSchema(a){return a.cached.domParser||(a.cached.domParser=new ey(a,ey.schemaRules(a)))}}let ez={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},eA={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},eB={ol:!0,ul:!0};function eC(a,b,c){return null!=b?!!b|2*("full"===b):a&&"pre"==a.whitespace?3:-5&c}class eD{constructor(a,b,c,d,e,f){this.type=a,this.attrs=b,this.marks=c,this.solid=d,this.options=f,this.content=[],this.activeMarks=d2.none,this.match=e||(4&f?null:a.contentMatch)}findWrapping(a){if(!this.match){if(!this.type)return[];let b=this.type.contentMatch.fillBefore(d$.from(a));if(b)this.match=this.type.contentMatch.matchFragment(b);else{let b=this.type.contentMatch,c;return(c=b.findWrapping(a.type))?(this.match=b,c):null}}return this.match.findWrapping(a.type)}finish(a){if(!(1&this.options)){let a=this.content[this.content.length-1],b;a&&a.isText&&(b=/[ \t\r\n\u000c]+$/.exec(a.text))&&(a.text.length==b[0].length?this.content.pop():this.content[this.content.length-1]=a.withText(a.text.slice(0,a.text.length-b[0].length)))}let b=d$.from(this.content);return!a&&this.match&&(b=b.append(this.match.fillBefore(d$.empty,!0))),this.type?this.type.create(this.attrs,b,this.marks):b}inlineContext(a){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:a.parentNode&&!ez.hasOwnProperty(a.parentNode.nodeName.toLowerCase())}}class eE{constructor(a,b,c){this.parser=a,this.options=b,this.isOpen=c,this.open=0,this.localPreserveWS=!1;let d=b.topNode,e,f=eC(null,b.preserveWhitespace,0)|4*!!c;e=d?new eD(d.type,d.attrs,d2.none,!0,b.topMatch||d.type.contentMatch,f):c?new eD(null,null,d2.none,!0,null,f):new eD(a.schema.topNodeType,null,d2.none,!0,null,f),this.nodes=[e],this.find=b.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(a,b){3==a.nodeType?this.addTextNode(a,b):1==a.nodeType&&this.addElement(a,b)}addTextNode(a,b){let c=a.nodeValue,d=this.top,e=2&d.options?"full":this.localPreserveWS||(1&d.options)>0,{schema:f}=this.parser;if("full"===e||d.inlineContext(a)||/[^ \t\r\n\u000c]/.test(c)){if(e)if("full"===e)c=c.replace(/\r\n?/g,"\n");else if(f.linebreakReplacement&&/[\r\n]/.test(c)&&this.top.findWrapping(f.linebreakReplacement.create())){let a=c.split(/\r?\n|\r/);for(let c=0;c<a.length;c++)c&&this.insertNode(f.linebreakReplacement.create(),b,!0),a[c]&&this.insertNode(f.text(a[c]),b,!/\S/.test(a[c]));c=""}else c=c.replace(/\r?\n|\r/g," ");else if(c=c.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(c)&&this.open==this.nodes.length-1){let b=d.content[d.content.length-1],e=a.previousSibling;(!b||e&&"BR"==e.nodeName||b.isText&&/[ \t\r\n\u000c]$/.test(b.text))&&(c=c.slice(1))}c&&this.insertNode(f.text(c),b,!/\S/.test(c)),this.findInText(a)}else this.findInside(a)}addElement(a,b,c){let d=this.localPreserveWS,e=this.top;("PRE"==a.tagName||/pre/.test(a.style&&a.style.whiteSpace))&&(this.localPreserveWS=!0);let f=a.nodeName.toLowerCase(),g;eB.hasOwnProperty(f)&&this.parser.normalizeLists&&function(a){for(let b=a.firstChild,c=null;b;b=b.nextSibling){let a=1==b.nodeType?b.nodeName.toLowerCase():null;a&&eB.hasOwnProperty(a)&&c?(c.appendChild(b),b=c):"li"==a?c=b:a&&(c=null)}}(a);let h=this.options.ruleFromNode&&this.options.ruleFromNode(a)||(g=this.parser.matchTag(a,this,c));b:if(h?h.ignore:eA.hasOwnProperty(f))this.findInside(a),this.ignoreFallback(a,b);else if(!h||h.skip||h.closeParent){h&&h.closeParent?this.open=Math.max(0,this.open-1):h&&h.skip.nodeType&&(a=h.skip);let c,d=this.needsBlock;if(ez.hasOwnProperty(f))e.content.length&&e.content[0].isInline&&this.open&&(this.open--,e=this.top),c=!0,e.type||(this.needsBlock=!0);else if(!a.firstChild){this.leafFallback(a,b);break b}let g=h&&h.skip?b:this.readStyles(a,b);g&&this.addAll(a,g),c&&this.sync(e),this.needsBlock=d}else{let c=this.readStyles(a,b);c&&this.addElementByRule(a,h,c,!1===h.consuming?g:void 0)}this.localPreserveWS=d}leafFallback(a,b){"BR"==a.nodeName&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(a.ownerDocument.createTextNode("\n"),b)}ignoreFallback(a,b){"BR"!=a.nodeName||this.top.type&&this.top.type.inlineContent||this.findPlace(this.parser.schema.text("-"),b,!0)}readStyles(a,b){let c=a.style;if(c&&c.length)for(let a=0;a<this.parser.matchedStyles.length;a++){let d=this.parser.matchedStyles[a],e=c.getPropertyValue(d);if(e)for(let a;;){let c=this.parser.matchStyle(d,e,this,a);if(!c)break;if(c.ignore)return null;if(b=c.clearMark?b.filter(a=>!c.clearMark(a)):b.concat(this.parser.schema.marks[c.mark].create(c.attrs)),!1===c.consuming)a=c;else break}}return b}addElementByRule(a,b,c,d){let e,f;if(b.node)if((f=this.parser.schema.nodes[b.node]).isLeaf)this.insertNode(f.create(b.attrs),c,"BR"==a.nodeName)||this.leafFallback(a,c);else{let a=this.enter(f,b.attrs||null,c,b.preserveWhitespace);a&&(e=!0,c=a)}else{let a=this.parser.schema.marks[b.mark];c=c.concat(a.create(b.attrs))}let g=this.top;if(f&&f.isLeaf)this.findInside(a);else if(d)this.addElement(a,c,d);else if(b.getContent)this.findInside(a),b.getContent(a,this.parser.schema).forEach(a=>this.insertNode(a,c,!1));else{let d=a;"string"==typeof b.contentElement?d=a.querySelector(b.contentElement):"function"==typeof b.contentElement?d=b.contentElement(a):b.contentElement&&(d=b.contentElement),this.findAround(a,d,!0),this.addAll(d,c),this.findAround(a,d,!1)}e&&this.sync(g)&&this.open--}addAll(a,b,c,d){let e=c||0;for(let f=c?a.childNodes[c]:a.firstChild,g=null==d?null:a.childNodes[d];f!=g;f=f.nextSibling,++e)this.findAtPoint(a,e),this.addDOM(f,b);this.findAtPoint(a,e)}findPlace(a,b,c){let d,e;for(let b=this.open,f=0;b>=0;b--){let g=this.nodes[b],h=g.findWrapping(a);if(h&&(!d||d.length>h.length+f)&&(d=h,e=g,!h.length))break;if(g.solid){if(c)break;f+=2}}if(!d)return null;this.sync(e);for(let a=0;a<d.length;a++)b=this.enterInner(d[a],null,b,!1);return b}insertNode(a,b,c){if(a.isInline&&this.needsBlock&&!this.top.type){let a=this.textblockFromContext();a&&(b=this.enterInner(a,null,b))}let d=this.findPlace(a,b,c);if(d){this.closeExtra();let b=this.top;b.match&&(b.match=b.match.matchType(a.type));let c=d2.none;for(let e of d.concat(a.marks))(b.type?b.type.allowsMarkType(e.type):eG(e.type,a.type))&&(c=e.addToSet(c));return b.content.push(a.mark(c)),!0}return!1}enter(a,b,c,d){let e=this.findPlace(a.create(b),c,!1);return e&&(e=this.enterInner(a,b,c,!0,d)),e}enterInner(a,b,c,d=!1,e){this.closeExtra();let f=this.top;f.match=f.match&&f.match.matchType(a);let g=eC(a,e,f.options);4&f.options&&0==f.content.length&&(g|=4);let h=d2.none;return c=c.filter(b=>(f.type?!f.type.allowsMarkType(b.type):!eG(b.type,a))||(h=b.addToSet(h),!1)),this.nodes.push(new eD(a,b,h,d,null,g)),this.open++,c}closeExtra(a=!1){let b=this.nodes.length-1;if(b>this.open){for(;b>this.open;b--)this.nodes[b-1].content.push(this.nodes[b].finish(a));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(a){for(let b=this.open;b>=0;b--)if(this.nodes[b]==a)return this.open=b,!0;else this.localPreserveWS&&(this.nodes[b].options|=1);return!1}get currentPos(){this.closeExtra();let a=0;for(let b=this.open;b>=0;b--){let c=this.nodes[b].content;for(let b=c.length-1;b>=0;b--)a+=c[b].nodeSize;b&&a++}return a}findAtPoint(a,b){if(this.find)for(let c=0;c<this.find.length;c++)this.find[c].node==a&&this.find[c].offset==b&&(this.find[c].pos=this.currentPos)}findInside(a){if(this.find)for(let b=0;b<this.find.length;b++)null==this.find[b].pos&&1==a.nodeType&&a.contains(this.find[b].node)&&(this.find[b].pos=this.currentPos)}findAround(a,b,c){if(a!=b&&this.find)for(let d=0;d<this.find.length;d++)null==this.find[d].pos&&1==a.nodeType&&a.contains(this.find[d].node)&&b.compareDocumentPosition(this.find[d].node)&(c?2:4)&&(this.find[d].pos=this.currentPos)}findInText(a){if(this.find)for(let b=0;b<this.find.length;b++)this.find[b].node==a&&(this.find[b].pos=this.currentPos-(a.nodeValue.length-this.find[b].offset))}matchesContext(a){if(a.indexOf("|")>-1)return a.split(/\s*\|\s*/).some(this.matchesContext,this);let b=a.split("/"),c=this.options.context,d=!this.isOpen&&(!c||c.parent.type==this.nodes[0].type),e=-(c?c.depth+1:0)+ +!d,f=(a,g)=>{for(;a>=0;a--){let h=b[a];if(""==h){if(a==b.length-1||0==a)continue;for(;g>=e;g--)if(f(a-1,g))return!0;return!1}{let a=g>0||0==g&&d?this.nodes[g].type:c&&g>=e?c.node(g-e).type:null;if(!a||a.name!=h&&!a.isInGroup(h))return!1;g--}}return!0};return f(b.length-1,this.open)}textblockFromContext(){let a=this.options.context;if(a)for(let b=a.depth;b>=0;b--){let c=a.node(b).contentMatchAt(a.indexAfter(b)).defaultType;if(c&&c.isTextblock&&c.defaultAttrs)return c}for(let a in this.parser.schema.nodes){let b=this.parser.schema.nodes[a];if(b.isTextblock&&b.defaultAttrs)return b}}}function eF(a){let b={};for(let c in a)b[c]=a[c];return b}function eG(a,b){let c=b.schema.nodes;for(let d in c){let e=c[d];if(!e.allowsMarkType(a))continue;let f=[],g=a=>{f.push(a);for(let c=0;c<a.edgeCount;c++){let{type:d,next:e}=a.edge(c);if(d==b||0>f.indexOf(e)&&g(e))return!0}};if(g(e.contentMatch))return!0}}class eH{constructor(a,b){this.nodes=a,this.marks=b}serializeFragment(a,b={},c){c||(c=eJ(b).createDocumentFragment());let d=c,e=[];return a.forEach(a=>{if(e.length||a.marks.length){let c=0,f=0;for(;c<e.length&&f<a.marks.length;){let b=a.marks[f];if(!this.marks[b.type.name]){f++;continue}if(!b.eq(e[c][0])||!1===b.type.spec.spanning)break;c++,f++}for(;c<e.length;)d=e.pop()[1];for(;f<a.marks.length;){let c=a.marks[f++],g=this.serializeMark(c,a.isInline,b);g&&(e.push([c,d]),d.appendChild(g.dom),d=g.contentDOM||g.dom)}}d.appendChild(this.serializeNodeInner(a,b))}),c}serializeNodeInner(a,b){if(a.isText)return eJ(b).createTextNode(a.text);let{dom:c,contentDOM:d}=eL(eJ(b),this.nodes[a.type.name](a),null,a.attrs);if(d){if(a.isLeaf)throw RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(a.content,b,d)}return c}serializeNode(a,b={}){let c=this.serializeNodeInner(a,b);for(let d=a.marks.length-1;d>=0;d--){let e=this.serializeMark(a.marks[d],a.isInline,b);e&&((e.contentDOM||e.dom).appendChild(c),c=e.dom)}return c}serializeMark(a,b,c={}){let d=this.marks[a.type.name];return d&&eL(eJ(c),d(a,b),null,a.attrs)}static renderSpec(a,b,c=null,d){return"string"==typeof b?{dom:a.createTextNode(b)}:eL(a,b,c,d)}static fromSchema(a){return a.cached.domSerializer||(a.cached.domSerializer=new eH(this.nodesFromSchema(a),this.marksFromSchema(a)))}static nodesFromSchema(a){let b=eI(a.nodes);return b.text||(b.text=a=>a.text),b}static marksFromSchema(a){return eI(a.marks)}}function eI(a){let b={};for(let c in a){let d=a[c].spec.toDOM;d&&(b[c]=d)}return b}function eJ(a){return a.document||window.document}let eK=new WeakMap;function eL(a,b,c,d){let e,f,g;if(1==b.nodeType)return{dom:b};if(b.dom&&1==b.dom.nodeType)return b;let h=b[0],i;if("string"!=typeof h)throw RangeError("Invalid array passed to renderSpec");if(d&&(void 0===(f=eK.get(d))&&eK.set(d,(g=null,!function a(b){if(b&&"object"==typeof b)if(Array.isArray(b))if("string"==typeof b[0])g||(g=[]),g.push(b);else for(let c=0;c<b.length;c++)a(b[c]);else for(let c in b)a(b[c])}(d),f=g)),i=f)&&i.indexOf(b)>-1)throw RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let j=h.indexOf(" ");j>0&&(c=h.slice(0,j),h=h.slice(j+1));let k=c?a.createElementNS(c,h):a.createElement(h),l=b[1],m=1;if(l&&"object"==typeof l&&null==l.nodeType&&!Array.isArray(l)){for(let a in m=2,l)if(null!=l[a]){let b=a.indexOf(" ");b>0?k.setAttributeNS(a.slice(0,b),a.slice(b+1),l[a]):"style"==a&&k.style?k.style.cssText=l[a]:k.setAttribute(a,l[a])}}for(let f=m;f<b.length;f++){let g=b[f];if(0===g){if(f<b.length-1||f>m)throw RangeError("Content hole must be the only child of its parent node");return{dom:k,contentDOM:k}}if("string"==typeof g)k.appendChild(a.createTextNode(g));else{let{dom:b,contentDOM:f}=eL(a,g,c,d);if(k.appendChild(b),f){if(e)throw RangeError("Multiple content holes");e=f}}}return{dom:k,contentDOM:e}}class eM{constructor(a,b,c){this.pos=a,this.delInfo=b,this.recover=c}get deleted(){return(8&this.delInfo)>0}get deletedBefore(){return(5&this.delInfo)>0}get deletedAfter(){return(6&this.delInfo)>0}get deletedAcross(){return(4&this.delInfo)>0}}class eN{constructor(a,b=!1){if(this.ranges=a,this.inverted=b,!a.length&&eN.empty)return eN.empty}recover(a){let b=0,c=65535&a;if(!this.inverted)for(let a=0;a<c;a++)b+=this.ranges[3*a+2]-this.ranges[3*a+1];return this.ranges[3*c]+b+(a-(65535&a))/65536}mapResult(a,b=1){return this._map(a,b,!1)}map(a,b=1){return this._map(a,b,!0)}_map(a,b,c){let d=0,e=this.inverted?2:1,f=this.inverted?1:2;for(let g=0;g<this.ranges.length;g+=3){let h=this.ranges[g]-(this.inverted?d:0);if(h>a)break;let i=this.ranges[g+e],j=this.ranges[g+f],k=h+i;if(a<=k){let e=i?a==h?-1:a==k?1:b:b,f=h+d+(e<0?0:j);if(c)return f;let l=a==(b<0?h:k)?null:g/3+(a-h)*65536,m=a==h?2:a==k?1:4;return(b<0?a!=h:a!=k)&&(m|=8),new eM(f,m,l)}d+=j-i}return c?a+d:new eM(a+d,0,null)}touches(a,b){let c=0,d=65535&b,e=this.inverted?2:1,f=this.inverted?1:2;for(let b=0;b<this.ranges.length;b+=3){let g=this.ranges[b]-(this.inverted?c:0);if(g>a)break;let h=this.ranges[b+e];if(a<=g+h&&b==3*d)return!0;c+=this.ranges[b+f]-h}return!1}forEach(a){let b=this.inverted?2:1,c=this.inverted?1:2;for(let d=0,e=0;d<this.ranges.length;d+=3){let f=this.ranges[d],g=f-(this.inverted?e:0),h=f+(this.inverted?0:e),i=this.ranges[d+b],j=this.ranges[d+c];a(g,g+i,h,h+j),e+=j-i}}invert(){return new eN(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(a){return 0==a?eN.empty:new eN(a<0?[0,-a,0]:[0,0,a])}}eN.empty=new eN([]);class eO{constructor(a,b,c=0,d=a?a.length:0){this.mirror=b,this.from=c,this.to=d,this._maps=a||[],this.ownData=!(a||b)}get maps(){return this._maps}slice(a=0,b=this.maps.length){return new eO(this._maps,this.mirror,a,b)}appendMap(a,b){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(a),null!=b&&this.setMirror(this._maps.length-1,b)}appendMapping(a){for(let b=0,c=this._maps.length;b<a._maps.length;b++){let d=a.getMirror(b);this.appendMap(a._maps[b],null!=d&&d<b?c+d:void 0)}}getMirror(a){if(this.mirror){for(let b=0;b<this.mirror.length;b++)if(this.mirror[b]==a)return this.mirror[b+(b%2?-1:1)]}}setMirror(a,b){this.mirror||(this.mirror=[]),this.mirror.push(a,b)}appendMappingInverted(a){for(let b=a.maps.length-1,c=this._maps.length+a._maps.length;b>=0;b--){let d=a.getMirror(b);this.appendMap(a._maps[b].invert(),null!=d&&d>b?c-d-1:void 0)}}invert(){let a=new eO;return a.appendMappingInverted(this),a}map(a,b=1){if(this.mirror)return this._map(a,b,!0);for(let c=this.from;c<this.to;c++)a=this._maps[c].map(a,b);return a}mapResult(a,b=1){return this._map(a,b,!1)}_map(a,b,c){let d=0;for(let c=this.from;c<this.to;c++){let e=this._maps[c].mapResult(a,b);if(null!=e.recover){let b=this.getMirror(c);if(null!=b&&b>c&&b<this.to){c=b,a=this._maps[b].recover(e.recover);continue}}d|=e.delInfo,a=e.pos}return c?a:new eM(a,d,null)}}let eP=Object.create(null);class eQ{getMap(){return eN.empty}merge(a){return null}static fromJSON(a,b){if(!b||!b.stepType)throw RangeError("Invalid input for Step.fromJSON");let c=eP[b.stepType];if(!c)throw RangeError(`No step type ${b.stepType} defined`);return c.fromJSON(a,b)}static jsonID(a,b){if(a in eP)throw RangeError("Duplicate use of step JSON ID "+a);return eP[a]=b,b.prototype.jsonID=a,b}}class eR{constructor(a,b){this.doc=a,this.failed=b}static ok(a){return new eR(a,null)}static fail(a){return new eR(null,a)}static fromReplace(a,b,c,d){try{return eR.ok(a.replace(b,c,d))}catch(a){if(a instanceof d3)return eR.fail(a.message);throw a}}}function eS(a,b,c){let d=[];for(let e=0;e<a.childCount;e++){let f=a.child(e);f.content.size&&(f=f.copy(eS(f.content,b,f))),f.isInline&&(f=b(f,c,e)),d.push(f)}return d$.fromArray(d)}class eT extends eQ{constructor(a,b,c){super(),this.from=a,this.to=b,this.mark=c}apply(a){let b=a.slice(this.from,this.to),c=a.resolve(this.from),d=c.node(c.sharedDepth(this.to)),e=new d4(eS(b.content,(a,b)=>a.isAtom&&b.type.allowsMarkType(this.mark.type)?a.mark(this.mark.addToSet(a.marks)):a,d),b.openStart,b.openEnd);return eR.fromReplace(a,this.from,this.to,e)}invert(){return new eU(this.from,this.to,this.mark)}map(a){let b=a.mapResult(this.from,1),c=a.mapResult(this.to,-1);return b.deleted&&c.deleted||b.pos>=c.pos?null:new eT(b.pos,c.pos,this.mark)}merge(a){return a instanceof eT&&a.mark.eq(this.mark)&&this.from<=a.to&&this.to>=a.from?new eT(Math.min(this.from,a.from),Math.max(this.to,a.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(a,b){if("number"!=typeof b.from||"number"!=typeof b.to)throw RangeError("Invalid input for AddMarkStep.fromJSON");return new eT(b.from,b.to,a.markFromJSON(b.mark))}}eQ.jsonID("addMark",eT);class eU extends eQ{constructor(a,b,c){super(),this.from=a,this.to=b,this.mark=c}apply(a){let b=a.slice(this.from,this.to),c=new d4(eS(b.content,a=>a.mark(this.mark.removeFromSet(a.marks)),a),b.openStart,b.openEnd);return eR.fromReplace(a,this.from,this.to,c)}invert(){return new eT(this.from,this.to,this.mark)}map(a){let b=a.mapResult(this.from,1),c=a.mapResult(this.to,-1);return b.deleted&&c.deleted||b.pos>=c.pos?null:new eU(b.pos,c.pos,this.mark)}merge(a){return a instanceof eU&&a.mark.eq(this.mark)&&this.from<=a.to&&this.to>=a.from?new eU(Math.min(this.from,a.from),Math.max(this.to,a.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(a,b){if("number"!=typeof b.from||"number"!=typeof b.to)throw RangeError("Invalid input for RemoveMarkStep.fromJSON");return new eU(b.from,b.to,a.markFromJSON(b.mark))}}eQ.jsonID("removeMark",eU);class eV extends eQ{constructor(a,b){super(),this.pos=a,this.mark=b}apply(a){let b=a.nodeAt(this.pos);if(!b)return eR.fail("No node at mark step's position");let c=b.type.create(b.attrs,null,this.mark.addToSet(b.marks));return eR.fromReplace(a,this.pos,this.pos+1,new d4(d$.from(c),0,+!b.isLeaf))}invert(a){let b=a.nodeAt(this.pos);if(b){let a=this.mark.addToSet(b.marks);if(a.length==b.marks.length){for(let c=0;c<b.marks.length;c++)if(!b.marks[c].isInSet(a))return new eV(this.pos,b.marks[c]);return new eV(this.pos,this.mark)}}return new eW(this.pos,this.mark)}map(a){let b=a.mapResult(this.pos,1);return b.deletedAfter?null:new eV(b.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(a,b){if("number"!=typeof b.pos)throw RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new eV(b.pos,a.markFromJSON(b.mark))}}eQ.jsonID("addNodeMark",eV);class eW extends eQ{constructor(a,b){super(),this.pos=a,this.mark=b}apply(a){let b=a.nodeAt(this.pos);if(!b)return eR.fail("No node at mark step's position");let c=b.type.create(b.attrs,null,this.mark.removeFromSet(b.marks));return eR.fromReplace(a,this.pos,this.pos+1,new d4(d$.from(c),0,+!b.isLeaf))}invert(a){let b=a.nodeAt(this.pos);return b&&this.mark.isInSet(b.marks)?new eV(this.pos,this.mark):this}map(a){let b=a.mapResult(this.pos,1);return b.deletedAfter?null:new eW(b.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(a,b){if("number"!=typeof b.pos)throw RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new eW(b.pos,a.markFromJSON(b.mark))}}eQ.jsonID("removeNodeMark",eW);class eX extends eQ{constructor(a,b,c,d=!1){super(),this.from=a,this.to=b,this.slice=c,this.structure=d}apply(a){return this.structure&&eZ(a,this.from,this.to)?eR.fail("Structure replace would overwrite content"):eR.fromReplace(a,this.from,this.to,this.slice)}getMap(){return new eN([this.from,this.to-this.from,this.slice.size])}invert(a){return new eX(this.from,this.from+this.slice.size,a.slice(this.from,this.to))}map(a){let b=a.mapResult(this.to,-1),c=this.from==this.to&&eX.MAP_BIAS<0?b:a.mapResult(this.from,1);return c.deletedAcross&&b.deletedAcross?null:new eX(c.pos,Math.max(c.pos,b.pos),this.slice,this.structure)}merge(a){if(!(a instanceof eX)||a.structure||this.structure)return null;if(this.from+this.slice.size!=a.from||this.slice.openEnd||a.slice.openStart)if(a.to!=this.from||this.slice.openStart||a.slice.openEnd)return null;else{let b=this.slice.size+a.slice.size==0?d4.empty:new d4(a.slice.content.append(this.slice.content),a.slice.openStart,this.slice.openEnd);return new eX(a.from,this.to,b,this.structure)}{let b=this.slice.size+a.slice.size==0?d4.empty:new d4(this.slice.content.append(a.slice.content),this.slice.openStart,a.slice.openEnd);return new eX(this.from,this.to+(a.to-a.from),b,this.structure)}}toJSON(){let a={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(a.slice=this.slice.toJSON()),this.structure&&(a.structure=!0),a}static fromJSON(a,b){if("number"!=typeof b.from||"number"!=typeof b.to)throw RangeError("Invalid input for ReplaceStep.fromJSON");return new eX(b.from,b.to,d4.fromJSON(a,b.slice),!!b.structure)}}eX.MAP_BIAS=1,eQ.jsonID("replace",eX);class eY extends eQ{constructor(a,b,c,d,e,f,g=!1){super(),this.from=a,this.to=b,this.gapFrom=c,this.gapTo=d,this.slice=e,this.insert=f,this.structure=g}apply(a){if(this.structure&&(eZ(a,this.from,this.gapFrom)||eZ(a,this.gapTo,this.to)))return eR.fail("Structure gap-replace would overwrite content");let b=a.slice(this.gapFrom,this.gapTo);if(b.openStart||b.openEnd)return eR.fail("Gap is not a flat range");let c=this.slice.insertAt(this.insert,b.content);return c?eR.fromReplace(a,this.from,this.to,c):eR.fail("Content does not fit in gap")}getMap(){return new eN([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(a){let b=this.gapTo-this.gapFrom;return new eY(this.from,this.from+this.slice.size+b,this.from+this.insert,this.from+this.insert+b,a.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(a){let b=a.mapResult(this.from,1),c=a.mapResult(this.to,-1),d=this.from==this.gapFrom?b.pos:a.map(this.gapFrom,-1),e=this.to==this.gapTo?c.pos:a.map(this.gapTo,1);return b.deletedAcross&&c.deletedAcross||d<b.pos||e>c.pos?null:new eY(b.pos,c.pos,d,e,this.slice,this.insert,this.structure)}toJSON(){let a={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(a.slice=this.slice.toJSON()),this.structure&&(a.structure=!0),a}static fromJSON(a,b){if("number"!=typeof b.from||"number"!=typeof b.to||"number"!=typeof b.gapFrom||"number"!=typeof b.gapTo||"number"!=typeof b.insert)throw RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new eY(b.from,b.to,b.gapFrom,b.gapTo,d4.fromJSON(a,b.slice),b.insert,!!b.structure)}}function eZ(a,b,c){let d=a.resolve(b),e=c-b,f=d.depth;for(;e>0&&f>0&&d.indexAfter(f)==d.node(f).childCount;)f--,e--;if(e>0){let a=d.node(f).maybeChild(d.indexAfter(f));for(;e>0;){if(!a||a.isLeaf)return!0;a=a.firstChild,e--}}return!1}function e$(a,b,c,d=c.contentMatch,e=!0){let f=a.doc.nodeAt(b),g=[],h=b+1;for(let b=0;b<f.childCount;b++){let i=f.child(b),j=h+i.nodeSize,k=d.matchType(i.type);if(k){d=k;for(let b=0;b<i.marks.length;b++)c.allowsMarkType(i.marks[b].type)||a.step(new eU(h,j,i.marks[b]));if(e&&i.isText&&"pre"!=c.whitespace){let a,b=/\r?\n|\r/g,d;for(;a=b.exec(i.text);)d||(d=new d4(d$.from(c.schema.text(" ",c.allowedMarks(i.marks))),0,0)),g.push(new eX(h+a.index,h+a.index+a[0].length,d))}}else g.push(new eX(h,j,d4.empty));h=j}if(!d.validEnd){let b=d.fillBefore(d$.empty,!0);a.replace(h,h,new d4(b,0,0))}for(let b=g.length-1;b>=0;b--)a.step(g[b])}function e_(a){let b=a.parent.content.cutByIndex(a.startIndex,a.endIndex);for(let c=a.depth,d=0,e=0;;--c){let f=a.$from.node(c),g=a.$from.index(c)+d,h=a.$to.indexAfter(c)-e;if(c<a.depth&&f.canReplace(g,h,b))return c;if(0==c||f.type.spec.isolating||!((0==g||f.canReplace(g,f.childCount))&&(h==f.childCount||f.canReplace(0,h))))break;g&&(d=1),h<f.childCount&&(e=1)}return null}function e0(a,b,c=null,d=a){let e=function(a,b){let{parent:c,startIndex:d,endIndex:e}=a,f=c.contentMatchAt(d).findWrapping(b);if(!f)return null;let g=f.length?f[0]:b;return c.canReplaceWith(d,e,g)?f:null}(a,b),f=e&&function(a,b){let{parent:c,startIndex:d,endIndex:e}=a,f=c.child(d),g=b.contentMatch.findWrapping(f.type);if(!g)return null;let h=(g.length?g[g.length-1]:b).contentMatch;for(let a=d;h&&a<e;a++)h=h.matchType(c.child(a).type);return h&&h.validEnd?g:null}(d,b);return f?e.map(e1).concat({type:b,attrs:c}).concat(f.map(e1)):null}function e1(a){return{type:a,attrs:null}}function e2(a,b,c,d){b.forEach((e,f)=>{if(e.isText){let g,h=/\r?\n|\r/g;for(;g=h.exec(e.text);){let e=a.mapping.slice(d).map(c+1+f+g.index);a.replaceWith(e,e+1,b.type.schema.linebreakReplacement.create())}}})}function e3(a,b,c,d){b.forEach((e,f)=>{if(e.type==e.type.schema.linebreakReplacement){let e=a.mapping.slice(d).map(c+1+f);a.replaceWith(e,e+1,b.type.schema.text("\n"))}})}function e4(a,b,c=1,d){let e=a.resolve(b),f=e.depth-c,g=d&&d[d.length-1]||e.parent;if(f<0||e.parent.type.spec.isolating||!e.parent.canReplace(e.index(),e.parent.childCount)||!g.type.validContent(e.parent.content.cutByIndex(e.index(),e.parent.childCount)))return!1;for(let a=e.depth-1,b=c-2;a>f;a--,b--){let c=e.node(a),f=e.index(a);if(c.type.spec.isolating)return!1;let g=c.content.cutByIndex(f,c.childCount),h=d&&d[b+1];h&&(g=g.replaceChild(0,h.type.create(h.attrs)));let i=d&&d[b]||c;if(!c.canReplace(f+1,c.childCount)||!i.type.validContent(g))return!1}let h=e.indexAfter(f),i=d&&d[0];return e.node(f).canReplaceWith(h,h,i?i.type:e.node(f+1).type)}function e5(a,b){let c=a.resolve(b),d=c.index();return e6(c.nodeBefore,c.nodeAfter)&&c.parent.canReplace(d,d+1)}function e6(a,b){return!!(a&&b&&!a.isLeaf&&function(a,b){b.content.size||a.type.compatibleContent(b.type);let c=a.contentMatchAt(a.childCount),{linebreakReplacement:d}=a.type.schema;for(let e=0;e<b.childCount;e++){let f=b.child(e),g=f.type==d?a.type.schema.nodes.text:f.type;if(!(c=c.matchType(g))||!a.type.allowsMarks(f.marks))return!1}return c.validEnd}(a,b))}function e7(a,b,c=-1){let d=a.resolve(b);for(let a=d.depth;;a--){let e,f,g=d.index(a);if(a==d.depth?(e=d.nodeBefore,f=d.nodeAfter):c>0?(e=d.node(a+1),g++,f=d.node(a).maybeChild(g)):(e=d.node(a).maybeChild(g-1),f=d.node(a+1)),e&&!e.isTextblock&&e6(e,f)&&d.node(a).canReplace(g,g+1))return b;if(0==a)break;b=c<0?d.before(a):d.after(a)}}function e8(a,b,c){let d=a.resolve(b);if(!c.content.size)return b;let e=c.content;for(let a=0;a<c.openStart;a++)e=e.firstChild.content;for(let a=1;a<=(0==c.openStart&&c.size?2:1);a++)for(let b=d.depth;b>=0;b--){let c=b==d.depth?0:d.pos<=(d.start(b+1)+d.end(b+1))/2?-1:1,f=d.index(b)+ +(c>0),g=d.node(b),h=!1;if(1==a)h=g.canReplace(f,f,e);else{let a=g.contentMatchAt(f).findWrapping(e.firstChild.type);h=a&&g.canReplaceWith(f,f,a[0])}if(h)return 0==c?d.pos:c<0?d.before(b+1):d.after(b+1)}return null}function e9(a,b,c=b,d=d4.empty){if(b==c&&!d.size)return null;let e=a.resolve(b),f=a.resolve(c);return fa(e,f,d)?new eX(b,c,d):new fb(e,f,d).fit()}function fa(a,b,c){return!c.openStart&&!c.openEnd&&a.start()==b.start()&&a.parent.canReplace(a.index(),b.index(),c.content)}eQ.jsonID("replaceAround",eY);class fb{constructor(a,b,c){this.$from=a,this.$to=b,this.unplaced=c,this.frontier=[],this.placed=d$.empty;for(let b=0;b<=a.depth;b++){let c=a.node(b);this.frontier.push({type:c.type,match:c.contentMatchAt(a.indexAfter(b))})}for(let b=a.depth;b>0;b--)this.placed=d$.from(a.node(b).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let a=this.findFittable();a?this.placeNodes(a):this.openMore()||this.dropNode()}let a=this.mustMoveInline(),b=this.placed.size-this.depth-this.$from.depth,c=this.$from,d=this.close(a<0?this.$to:c.doc.resolve(a));if(!d)return null;let e=this.placed,f=c.depth,g=d.depth;for(;f&&g&&1==e.childCount;)e=e.firstChild.content,f--,g--;let h=new d4(e,f,g);return a>-1?new eY(c.pos,a,this.$to.pos,this.$to.end(),h,b):h.size||c.pos!=this.$to.pos?new eX(c.pos,d.pos,h):null}findFittable(){let a=this.unplaced.openStart;for(let b=this.unplaced.content,c=0,d=this.unplaced.openEnd;c<a;c++){let e=b.firstChild;if(b.childCount>1&&(d=0),e.type.spec.isolating&&d<=c){a=c;break}b=e.content}for(let b=1;b<=2;b++)for(let c=1==b?a:this.unplaced.openStart;c>=0;c--){let a=null,d=(c?(a=fe(this.unplaced.content,c-1).firstChild).content:this.unplaced.content).firstChild;for(let e=this.depth;e>=0;e--){let{type:f,match:g}=this.frontier[e],h,i=null;if(1==b&&(d?g.matchType(d.type)||(i=g.fillBefore(d$.from(d),!1)):a&&f.compatibleContent(a.type)))return{sliceDepth:c,frontierDepth:e,parent:a,inject:i};if(2==b&&d&&(h=g.findWrapping(d.type)))return{sliceDepth:c,frontierDepth:e,parent:a,wrap:h};if(a&&g.matchType(a.type))break}}}openMore(){let{content:a,openStart:b,openEnd:c}=this.unplaced,d=fe(a,b);return!!d.childCount&&!d.firstChild.isLeaf&&(this.unplaced=new d4(a,b+1,Math.max(c,d.size+b>=a.size-c?b+1:0)),!0)}dropNode(){let{content:a,openStart:b,openEnd:c}=this.unplaced,d=fe(a,b);if(d.childCount<=1&&b>0){let e=a.size-b<=b+d.size;this.unplaced=new d4(fc(a,b-1,1),b-1,e?b-1:c)}else this.unplaced=new d4(fc(a,b,1),b,c)}placeNodes({sliceDepth:a,frontierDepth:b,parent:c,inject:d,wrap:e}){for(;this.depth>b;)this.closeFrontierNode();if(e)for(let a=0;a<e.length;a++)this.openFrontierNode(e[a]);let f=this.unplaced,g=c?c.content:f.content,h=f.openStart-a,i=0,j=[],{match:k,type:l}=this.frontier[b];if(d){for(let a=0;a<d.childCount;a++)j.push(d.child(a));k=k.matchFragment(d)}let m=g.size+a-(f.content.size-f.openEnd);for(;i<g.childCount;){let a=g.child(i),b=k.matchType(a.type);if(!b)break;(++i>1||0==h||a.content.size)&&(k=b,j.push(function a(b,c,d){if(c<=0)return b;let e=b.content;return c>1&&(e=e.replaceChild(0,a(e.firstChild,c-1,1==e.childCount?d-1:0))),c>0&&(e=b.type.contentMatch.fillBefore(e).append(e),d<=0&&(e=e.append(b.type.contentMatch.matchFragment(e).fillBefore(d$.empty,!0)))),b.copy(e)}(a.mark(l.allowedMarks(a.marks)),1==i?h:0,i==g.childCount?m:-1)))}let n=i==g.childCount;n||(m=-1),this.placed=fd(this.placed,b,d$.from(j)),this.frontier[b].match=k,n&&m<0&&c&&c.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let a=0,b=g;a<m;a++){let a=b.lastChild;this.frontier.push({type:a.type,match:a.contentMatchAt(a.childCount)}),b=a.content}this.unplaced=n?0==a?d4.empty:new d4(fc(f.content,a-1,1),a-1,m<0?f.openEnd:a-1):new d4(fc(f.content,a,i),f.openStart,f.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return -1;let a=this.frontier[this.depth],b;if(!a.type.isTextblock||!ff(this.$to,this.$to.depth,a.type,a.match,!1)||this.$to.depth==this.depth&&(b=this.findCloseLevel(this.$to))&&b.depth==this.depth)return -1;let{depth:c}=this.$to,d=this.$to.after(c);for(;c>1&&d==this.$to.end(--c);)++d;return d}findCloseLevel(a){c:for(let b=Math.min(this.depth,a.depth);b>=0;b--){let{match:c,type:d}=this.frontier[b],e=b<a.depth&&a.end(b+1)==a.pos+(a.depth-(b+1)),f=ff(a,b,d,c,e);if(f){for(let c=b-1;c>=0;c--){let{match:b,type:d}=this.frontier[c],e=ff(a,c,d,b,!0);if(!e||e.childCount)continue c}return{depth:b,fit:f,move:e?a.doc.resolve(a.after(b+1)):a}}}}close(a){let b=this.findCloseLevel(a);if(!b)return null;for(;this.depth>b.depth;)this.closeFrontierNode();b.fit.childCount&&(this.placed=fd(this.placed,b.depth,b.fit)),a=b.move;for(let c=b.depth+1;c<=a.depth;c++){let b=a.node(c),d=b.type.contentMatch.fillBefore(b.content,!0,a.index(c));this.openFrontierNode(b.type,b.attrs,d)}return a}openFrontierNode(a,b=null,c){let d=this.frontier[this.depth];d.match=d.match.matchType(a),this.placed=fd(this.placed,this.depth,d$.from(a.create(b,c))),this.frontier.push({type:a,match:a.contentMatch})}closeFrontierNode(){let a=this.frontier.pop().match.fillBefore(d$.empty,!0);a.childCount&&(this.placed=fd(this.placed,this.frontier.length,a))}}function fc(a,b,c){return 0==b?a.cutByIndex(c,a.childCount):a.replaceChild(0,a.firstChild.copy(fc(a.firstChild.content,b-1,c)))}function fd(a,b,c){return 0==b?a.append(c):a.replaceChild(a.childCount-1,a.lastChild.copy(fd(a.lastChild.content,b-1,c)))}function fe(a,b){for(let c=0;c<b;c++)a=a.firstChild.content;return a}function ff(a,b,c,d,e){let f=a.node(b),g=e?a.indexAfter(b):a.index(b);if(g==f.childCount&&!c.compatibleContent(f.type))return null;let h=d.fillBefore(f.content,!0,g);return h&&!function(a,b,c){for(let d=c;d<b.childCount;d++)if(!a.allowsMarks(b.child(d).marks))return!0;return!1}(c,f.content,g)?h:null}function fg(a,b){let c=[],d=Math.min(a.depth,b.depth);for(let e=d;e>=0;e--){let d=a.start(e);if(d<a.pos-(a.depth-e)||b.end(e)>b.pos+(b.depth-e)||a.node(e).type.spec.isolating||b.node(e).type.spec.isolating)break;(d==b.start(e)||e==a.depth&&e==b.depth&&a.parent.inlineContent&&b.parent.inlineContent&&e&&b.start(e-1)==d-1)&&c.push(e)}return c}class fh extends eQ{constructor(a,b,c){super(),this.pos=a,this.attr=b,this.value=c}apply(a){let b=a.nodeAt(this.pos);if(!b)return eR.fail("No node at attribute step's position");let c=Object.create(null);for(let a in b.attrs)c[a]=b.attrs[a];c[this.attr]=this.value;let d=b.type.create(c,null,b.marks);return eR.fromReplace(a,this.pos,this.pos+1,new d4(d$.from(d),0,+!b.isLeaf))}getMap(){return eN.empty}invert(a){return new fh(this.pos,this.attr,a.nodeAt(this.pos).attrs[this.attr])}map(a){let b=a.mapResult(this.pos,1);return b.deletedAfter?null:new fh(b.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(a,b){if("number"!=typeof b.pos||"string"!=typeof b.attr)throw RangeError("Invalid input for AttrStep.fromJSON");return new fh(b.pos,b.attr,b.value)}}eQ.jsonID("attr",fh);class fi extends eQ{constructor(a,b){super(),this.attr=a,this.value=b}apply(a){let b=Object.create(null);for(let c in a.attrs)b[c]=a.attrs[c];b[this.attr]=this.value;let c=a.type.create(b,a.content,a.marks);return eR.ok(c)}getMap(){return eN.empty}invert(a){return new fi(this.attr,a.attrs[this.attr])}map(a){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(a,b){if("string"!=typeof b.attr)throw RangeError("Invalid input for DocAttrStep.fromJSON");return new fi(b.attr,b.value)}}eQ.jsonID("docAttr",fi);let fj=class extends Error{};(fj=function a(b){let c=Error.call(this,b);return c.__proto__=a.prototype,c}).prototype=Object.create(Error.prototype),fj.prototype.constructor=fj,fj.prototype.name="TransformError";class fk{constructor(a){this.doc=a,this.steps=[],this.docs=[],this.mapping=new eO}get before(){return this.docs.length?this.docs[0]:this.doc}step(a){let b=this.maybeStep(a);if(b.failed)throw new fj(b.failed);return this}maybeStep(a){let b=a.apply(this.doc);return b.failed||this.addStep(a,b.doc),b}get docChanged(){return this.steps.length>0}changedRange(){let a=1e9,b=-1e9;for(let c=0;c<this.mapping.maps.length;c++){let d=this.mapping.maps[c];c&&(a=d.map(a,1),b=d.map(b,-1)),d.forEach((c,d,e,f)=>{a=Math.min(a,e),b=Math.max(b,f)})}return 1e9==a?null:{from:a,to:b}}addStep(a,b){this.docs.push(this.doc),this.steps.push(a),this.mapping.appendMap(a.getMap()),this.doc=b}replace(a,b=a,c=d4.empty){let d=e9(this.doc,a,b,c);return d&&this.step(d),this}replaceWith(a,b,c){return this.replace(a,b,new d4(d$.from(c),0,0))}delete(a,b){return this.replace(a,b,d4.empty)}insert(a,b){return this.replaceWith(a,a,b)}replaceRange(a,b,c){return!function(a,b,c,d){if(!d.size)return a.deleteRange(b,c);let e=a.doc.resolve(b),f=a.doc.resolve(c);if(fa(e,f,d))return a.step(new eX(b,c,d));let g=fg(e,f);0==g[g.length-1]&&g.pop();let h=-(e.depth+1);g.unshift(h);for(let a=e.depth,b=e.pos-1;a>0;a--,b--){let c=e.node(a).type.spec;if(c.defining||c.definingAsContext||c.isolating)break;g.indexOf(a)>-1?h=a:e.before(a)==b&&g.splice(1,0,-a)}let i=g.indexOf(h),j=[],k=d.openStart;for(let a=d.content,b=0;;b++){let c=a.firstChild;if(j.push(c),b==d.openStart)break;a=c.content}for(let a=k-1;a>=0;a--){var l;let b=j[a],c=(l=b.type).spec.defining||l.spec.definingForContent;if(c&&!b.sameMarkup(e.node(Math.abs(h)-1)))k=a;else if(c||!b.type.isTextblock)break}for(let b=d.openStart;b>=0;b--){let h=(b+k+1)%(d.openStart+1),l=j[h];if(l)for(let b=0;b<g.length;b++){let j=g[(b+i)%g.length],k=!0;j<0&&(k=!1,j=-j);let m=e.node(j-1),n=e.index(j-1);if(m.canReplaceWith(n,n,l.type,l.marks))return a.replace(e.before(j),k?f.after(j):c,new d4(function a(b,c,d,e,f){if(c<d){let f=b.firstChild;b=b.replaceChild(0,f.copy(a(f.content,c+1,d,e,f)))}if(c>e){let a=f.contentMatchAt(0),c=a.fillBefore(b).append(b);b=c.append(a.matchFragment(c).fillBefore(d$.empty,!0))}return b}(d.content,0,d.openStart,h),h,d.openEnd))}}let m=a.steps.length;for(let h=g.length-1;h>=0&&(a.replace(b,c,d),!(a.steps.length>m));h--){let a=g[h];a<0||(b=e.before(a),c=f.after(a))}}(this,a,b,c),this}replaceRangeWith(a,b,c){var d=a,e=b;if(!c.isInline&&d==e&&this.doc.resolve(d).parent.content.size){let a=function(a,b,c){let d=a.resolve(b);if(d.parent.canReplaceWith(d.index(),d.index(),c))return b;if(0==d.parentOffset)for(let a=d.depth-1;a>=0;a--){let b=d.index(a);if(d.node(a).canReplaceWith(b,b,c))return d.before(a+1);if(b>0)return null}if(d.parentOffset==d.parent.content.size)for(let a=d.depth-1;a>=0;a--){let b=d.indexAfter(a);if(d.node(a).canReplaceWith(b,b,c))return d.after(a+1);if(b<d.node(a).childCount)break}return null}(this.doc,d,c.type);null!=a&&(d=e=a)}return this.replaceRange(d,e,new d4(d$.from(c),0,0)),this}deleteRange(a,b){return!function(a,b,c){let d=a.doc.resolve(b),e=a.doc.resolve(c);if(d.parent.isTextblock&&e.parent.isTextblock&&d.start()!=e.start()&&0==d.parentOffset&&0==e.parentOffset){let f=d.sharedDepth(c),g=!1;for(let a=d.depth;a>f;a--)d.node(a).type.spec.isolating&&(g=!0);for(let a=e.depth;a>f;a--)e.node(a).type.spec.isolating&&(g=!0);if(!g){for(let a=d.depth;a>0&&b==d.start(a);a--)b=d.before(a);for(let a=e.depth;a>0&&c==e.start(a);a--)c=e.before(a);d=a.doc.resolve(b),e=a.doc.resolve(c)}}let f=fg(d,e);for(let b=0;b<f.length;b++){let c=f[b],g=b==f.length-1;if(g&&0==c||d.node(c).type.contentMatch.validEnd)return a.delete(d.start(c),e.end(c));if(c>0&&(g||d.node(c-1).canReplace(d.index(c-1),e.indexAfter(c-1))))return a.delete(d.before(c),e.after(c))}for(let f=1;f<=d.depth&&f<=e.depth;f++)if(b-d.start(f)==d.depth-f&&c>d.end(f)&&e.end(f)-c!=e.depth-f&&d.start(f-1)==e.start(f-1)&&d.node(f-1).canReplace(d.index(f-1),e.index(f-1)))return a.delete(d.before(f),c);a.delete(b,c)}(this,a,b),this}lift(a,b){return!function(a,b,c){let{$from:d,$to:e,depth:f}=b,g=d.before(f+1),h=e.after(f+1),i=g,j=h,k=d$.empty,l=0;for(let a=f,b=!1;a>c;a--)b||d.index(a)>0?(b=!0,k=d$.from(d.node(a).copy(k)),l++):i--;let m=d$.empty,n=0;for(let a=f,b=!1;a>c;a--)b||e.after(a+1)<e.end(a)?(b=!0,m=d$.from(e.node(a).copy(m)),n++):j++;a.step(new eY(i,j,g,h,new d4(k.append(m),l,n),k.size-l,!0))}(this,a,b),this}join(a,b=1){return!function(a,b,c){let d=null,{linebreakReplacement:e}=a.doc.type.schema,f=a.doc.resolve(b-c),g=f.node().type;if(e&&g.inlineContent){let a="pre"==g.whitespace,b=!!g.contentMatch.matchType(e);a&&!b?d=!1:!a&&b&&(d=!0)}let h=a.steps.length;if(!1===d){let d=a.doc.resolve(b+c);e3(a,d.node(),d.before(),h)}g.inlineContent&&e$(a,b+c-1,g,f.node().contentMatchAt(f.index()),null==d);let i=a.mapping.slice(h),j=i.map(b-c);if(a.step(new eX(j,i.map(b+c,-1),d4.empty,!0)),!0===d){let b=a.doc.resolve(j);e2(a,b.node(),b.before(),a.steps.length)}}(this,a,b),this}wrap(a,b){return!function(a,b,c){let d=d$.empty;for(let a=c.length-1;a>=0;a--){if(d.size){let b=c[a].type.contentMatch.matchFragment(d);if(!b||!b.validEnd)throw RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}d=d$.from(c[a].type.create(c[a].attrs,d))}let e=b.start,f=b.end;a.step(new eY(e,f,e,f,new d4(d,0,0),c.length,!0))}(this,a,b),this}setBlockType(a,b=a,c,d=null){var e=this;if(!c.isTextblock)throw RangeError("Type given to setBlockType should be a textblock");let f=e.steps.length;return e.doc.nodesBetween(a,b,(a,b)=>{var g,h,i;let j,k,l="function"==typeof d?d(a):d;if(a.isTextblock&&!a.hasMarkup(c,l)&&(g=e.doc,h=e.mapping.slice(f).map(b),i=c,k=(j=g.resolve(h)).index(),j.parent.canReplaceWith(k,k+1,i))){let d=null;if(c.schema.linebreakReplacement){let a="pre"==c.whitespace,b=!!c.contentMatch.matchType(c.schema.linebreakReplacement);a&&!b?d=!1:!a&&b&&(d=!0)}!1===d&&e3(e,a,b,f),e$(e,e.mapping.slice(f).map(b,1),c,void 0,null===d);let g=e.mapping.slice(f),h=g.map(b,1),i=g.map(b+a.nodeSize,1);return e.step(new eY(h,i,h+1,i-1,new d4(d$.from(c.create(l,null,a.marks)),0,0),1,!0)),!0===d&&e2(e,a,b,f),!1}}),this}setNodeMarkup(a,b,c=null,d){return!function(a,b,c,d,e){let f=a.doc.nodeAt(b);if(!f)throw RangeError("No node at given position");c||(c=f.type);let g=c.create(d,null,e||f.marks);if(f.isLeaf)return a.replaceWith(b,b+f.nodeSize,g);if(!c.validContent(f.content))throw RangeError("Invalid content for node type "+c.name);a.step(new eY(b,b+f.nodeSize,b+1,b+f.nodeSize-1,new d4(d$.from(g),0,0),1,!0))}(this,a,b,c,d),this}setNodeAttribute(a,b,c){return this.step(new fh(a,b,c)),this}setDocAttribute(a,b){return this.step(new fi(a,b)),this}addNodeMark(a,b){return this.step(new eV(a,b)),this}removeNodeMark(a,b){let c=this.doc.nodeAt(a);if(!c)throw RangeError("No node at position "+a);if(b instanceof d2)b.isInSet(c.marks)&&this.step(new eW(a,b));else{let d=c.marks,e,f=[];for(;e=b.isInSet(d);)f.push(new eW(a,e)),d=e.removeFromSet(d);for(let a=f.length-1;a>=0;a--)this.step(f[a])}return this}split(a,b=1,c){return!function(a,b,c=1,d){let e=a.doc.resolve(b),f=d$.empty,g=d$.empty;for(let a=e.depth,b=e.depth-c,h=c-1;a>b;a--,h--){f=d$.from(e.node(a).copy(f));let b=d&&d[h];g=d$.from(b?b.type.create(b.attrs,g):e.node(a).copy(g))}a.step(new eX(b,b,new d4(f.append(g),c,c),!0))}(this,a,b,c),this}addMark(a,b,c){var d;let e,f,g,h;return d=this,g=[],h=[],d.doc.nodesBetween(a,b,(d,i,j)=>{if(!d.isInline)return;let k=d.marks;if(!c.isInSet(k)&&j.type.allowsMarkType(c.type)){let j=Math.max(i,a),l=Math.min(i+d.nodeSize,b),m=c.addToSet(k);for(let a=0;a<k.length;a++)k[a].isInSet(m)||(e&&e.to==j&&e.mark.eq(k[a])?e.to=l:g.push(e=new eU(j,l,k[a])));f&&f.to==j?f.to=l:h.push(f=new eT(j,l,c))}}),g.forEach(a=>d.step(a)),h.forEach(a=>d.step(a)),this}removeMark(a,b,c){var d;let e,f;return d=this,e=[],f=0,d.doc.nodesBetween(a,b,(d,g)=>{if(!d.isInline)return;f++;let h=null;if(c instanceof ev){let a=d.marks,b;for(;b=c.isInSet(a);)(h||(h=[])).push(b),a=b.removeFromSet(a)}else c?c.isInSet(d.marks)&&(h=[c]):h=d.marks;if(h&&h.length){let c=Math.min(g+d.nodeSize,b);for(let b=0;b<h.length;b++){let d=h[b],i;for(let a=0;a<e.length;a++){let b=e[a];b.step==f-1&&d.eq(e[a].style)&&(i=b)}i?(i.to=c,i.step=f):e.push({style:d,from:Math.max(g,a),to:c,step:f})}}}),e.forEach(a=>d.step(new eU(a.from,a.to,a.style))),this}clearIncompatible(a,b,c){return e$(this,a,b,c),this}}let fl=Object.create(null);class fm{constructor(a,b,c){this.$anchor=a,this.$head=b,this.ranges=c||[new fn(a.min(b),a.max(b))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let a=this.ranges;for(let b=0;b<a.length;b++)if(a[b].$from.pos!=a[b].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(a,b=d4.empty){let c=b.content.lastChild,d=null;for(let a=0;a<b.openEnd;a++)d=c,c=c.lastChild;let e=a.steps.length,f=this.ranges;for(let g=0;g<f.length;g++){let{$from:h,$to:i}=f[g],j=a.mapping.slice(e);a.replaceRange(j.map(h.pos),j.map(i.pos),g?d4.empty:b),0==g&&fx(a,e,(c?c.isInline:d&&d.isTextblock)?-1:1)}}replaceWith(a,b){let c=a.steps.length,d=this.ranges;for(let e=0;e<d.length;e++){let{$from:f,$to:g}=d[e],h=a.mapping.slice(c),i=h.map(f.pos),j=h.map(g.pos);e?a.deleteRange(i,j):(a.replaceRangeWith(i,j,b),fx(a,c,b.isInline?-1:1))}}static findFrom(a,b,c=!1){let d=a.parent.inlineContent?new fq(a):fw(a.node(0),a.parent,a.pos,a.index(),b,c);if(d)return d;for(let d=a.depth-1;d>=0;d--){let e=b<0?fw(a.node(0),a.node(d),a.before(d+1),a.index(d),b,c):fw(a.node(0),a.node(d),a.after(d+1),a.index(d)+1,b,c);if(e)return e}return null}static near(a,b=1){return this.findFrom(a,b)||this.findFrom(a,-b)||new fu(a.node(0))}static atStart(a){return fw(a,a,0,0,1)||new fu(a)}static atEnd(a){return fw(a,a,a.content.size,a.childCount,-1)||new fu(a)}static fromJSON(a,b){if(!b||!b.type)throw RangeError("Invalid input for Selection.fromJSON");let c=fl[b.type];if(!c)throw RangeError(`No selection type ${b.type} defined`);return c.fromJSON(a,b)}static jsonID(a,b){if(a in fl)throw RangeError("Duplicate use of selection JSON ID "+a);return fl[a]=b,b.prototype.jsonID=a,b}getBookmark(){return fq.between(this.$anchor,this.$head).getBookmark()}}fm.prototype.visible=!0;class fn{constructor(a,b){this.$from=a,this.$to=b}}let fo=!1;function fp(a){fo||a.parent.inlineContent||(fo=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+a.parent.type.name+")"))}class fq extends fm{constructor(a,b=a){fp(a),fp(b),super(a,b)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(a,b){let c=a.resolve(b.map(this.head));if(!c.parent.inlineContent)return fm.near(c);let d=a.resolve(b.map(this.anchor));return new fq(d.parent.inlineContent?d:c,c)}replace(a,b=d4.empty){if(super.replace(a,b),b==d4.empty){let b=this.$from.marksAcross(this.$to);b&&a.ensureMarks(b)}}eq(a){return a instanceof fq&&a.anchor==this.anchor&&a.head==this.head}getBookmark(){return new fr(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(a,b){if("number"!=typeof b.anchor||"number"!=typeof b.head)throw RangeError("Invalid input for TextSelection.fromJSON");return new fq(a.resolve(b.anchor),a.resolve(b.head))}static create(a,b,c=b){let d=a.resolve(b);return new this(d,c==b?d:a.resolve(c))}static between(a,b,c){let d=a.pos-b.pos;if((!c||d)&&(c=d>=0?1:-1),!b.parent.inlineContent){let a=fm.findFrom(b,c,!0)||fm.findFrom(b,-c,!0);if(!a)return fm.near(b,c);b=a.$head}return a.parent.inlineContent||(0==d?a=b:(a=(fm.findFrom(a,-c,!0)||fm.findFrom(a,c,!0)).$anchor).pos<b.pos!=d<0&&(a=b)),new fq(a,b)}}fm.jsonID("text",fq);class fr{constructor(a,b){this.anchor=a,this.head=b}map(a){return new fr(a.map(this.anchor),a.map(this.head))}resolve(a){return fq.between(a.resolve(this.anchor),a.resolve(this.head))}}class fs extends fm{constructor(a){let b=a.nodeAfter,c=a.node(0).resolve(a.pos+b.nodeSize);super(a,c),this.node=b}map(a,b){let{deleted:c,pos:d}=b.mapResult(this.anchor),e=a.resolve(d);return c?fm.near(e):new fs(e)}content(){return new d4(d$.from(this.node),0,0)}eq(a){return a instanceof fs&&a.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new ft(this.anchor)}static fromJSON(a,b){if("number"!=typeof b.anchor)throw RangeError("Invalid input for NodeSelection.fromJSON");return new fs(a.resolve(b.anchor))}static create(a,b){return new fs(a.resolve(b))}static isSelectable(a){return!a.isText&&!1!==a.type.spec.selectable}}fs.prototype.visible=!1,fm.jsonID("node",fs);class ft{constructor(a){this.anchor=a}map(a){let{deleted:b,pos:c}=a.mapResult(this.anchor);return b?new fr(c,c):new ft(c)}resolve(a){let b=a.resolve(this.anchor),c=b.nodeAfter;return c&&fs.isSelectable(c)?new fs(b):fm.near(b)}}class fu extends fm{constructor(a){super(a.resolve(0),a.resolve(a.content.size))}replace(a,b=d4.empty){if(b==d4.empty){a.delete(0,a.doc.content.size);let b=fm.atStart(a.doc);b.eq(a.selection)||a.setSelection(b)}else super.replace(a,b)}toJSON(){return{type:"all"}}static fromJSON(a){return new fu(a)}map(a){return new fu(a)}eq(a){return a instanceof fu}getBookmark(){return fv}}fm.jsonID("all",fu);let fv={map(){return this},resolve:a=>new fu(a)};function fw(a,b,c,d,e,f=!1){if(b.inlineContent)return fq.create(a,c);for(let g=d-(e>0?0:1);e>0?g<b.childCount:g>=0;g+=e){let d=b.child(g);if(d.isAtom){if(!f&&fs.isSelectable(d))return fs.create(a,c-(e<0?d.nodeSize:0))}else{let b=fw(a,d,c+e,e<0?d.childCount:0,e,f);if(b)return b}c+=d.nodeSize*e}return null}function fx(a,b,c){let d,e=a.steps.length-1;if(e<b)return;let f=a.steps[e];(f instanceof eX||f instanceof eY)&&(a.mapping.maps[e].forEach((a,b,c,e)=>{null==d&&(d=e)}),a.setSelection(fm.near(a.doc.resolve(d),c)))}class fy extends fk{constructor(a){super(a.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=a.selection,this.storedMarks=a.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(a){if(a.$from.doc!=this.doc)throw RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=a,this.curSelectionFor=this.steps.length,this.updated=(1|this.updated)&-3,this.storedMarks=null,this}get selectionSet(){return(1&this.updated)>0}setStoredMarks(a){return this.storedMarks=a,this.updated|=2,this}ensureMarks(a){return d2.sameSet(this.storedMarks||this.selection.$from.marks(),a)||this.setStoredMarks(a),this}addStoredMark(a){return this.ensureMarks(a.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(a){return this.ensureMarks(a.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(2&this.updated)>0}addStep(a,b){super.addStep(a,b),this.updated=-3&this.updated,this.storedMarks=null}setTime(a){return this.time=a,this}replaceSelection(a){return this.selection.replace(this,a),this}replaceSelectionWith(a,b=!0){let c=this.selection;return b&&(a=a.mark(this.storedMarks||(c.empty?c.$from.marks():c.$from.marksAcross(c.$to)||d2.none))),c.replaceWith(this,a),this}deleteSelection(){return this.selection.replace(this),this}insertText(a,b,c){let d=this.doc.type.schema;if(null==b)return a?this.replaceSelectionWith(d.text(a),!0):this.deleteSelection();{if(null==c&&(c=b),!a)return this.deleteRange(b,c);let e=this.storedMarks;if(!e){let a=this.doc.resolve(b);e=c==b?a.marks():a.marksAcross(this.doc.resolve(c))}return this.replaceRangeWith(b,c,d.text(a,e)),this.selection.empty||this.selection.to!=b+a.length||this.setSelection(fm.near(this.selection.$to)),this}}setMeta(a,b){return this.meta["string"==typeof a?a:a.key]=b,this}getMeta(a){return this.meta["string"==typeof a?a:a.key]}get isGeneric(){for(let a in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=4,this}get scrolledIntoView(){return(4&this.updated)>0}}function fz(a,b){return b&&a?a.bind(b):a}class fA{constructor(a,b,c){this.name=a,this.init=fz(b.init,c),this.apply=fz(b.apply,c)}}let fB=[new fA("doc",{init:a=>a.doc||a.schema.topNodeType.createAndFill(),apply:a=>a.doc}),new fA("selection",{init:(a,b)=>a.selection||fm.atStart(b.doc),apply:a=>a.selection}),new fA("storedMarks",{init:a=>a.storedMarks||null,apply:(a,b,c,d)=>d.selection.$cursor?a.storedMarks:null}),new fA("scrollToSelection",{init:()=>0,apply:(a,b)=>a.scrolledIntoView?b+1:b})];class fC{constructor(a,b){this.schema=a,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=fB.slice(),b&&b.forEach(a=>{if(this.pluginsByKey[a.key])throw RangeError("Adding different instances of a keyed plugin ("+a.key+")");this.plugins.push(a),this.pluginsByKey[a.key]=a,a.spec.state&&this.fields.push(new fA(a.key,a.spec.state,a))})}}class fD{constructor(a){this.config=a}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(a){return this.applyTransaction(a).state}filterTransaction(a,b=-1){for(let c=0;c<this.config.plugins.length;c++)if(c!=b){let b=this.config.plugins[c];if(b.spec.filterTransaction&&!b.spec.filterTransaction.call(b,a,this))return!1}return!0}applyTransaction(a){if(!this.filterTransaction(a))return{state:this,transactions:[]};let b=[a],c=this.applyInner(a),d=null;for(;;){let e=!1;for(let f=0;f<this.config.plugins.length;f++){let g=this.config.plugins[f];if(g.spec.appendTransaction){let h=d?d[f].n:0,i=d?d[f].state:this,j=h<b.length&&g.spec.appendTransaction.call(g,h?b.slice(h):b,i,c);if(j&&c.filterTransaction(j,f)){if(j.setMeta("appendedTransaction",a),!d){d=[];for(let a=0;a<this.config.plugins.length;a++)d.push(a<f?{state:c,n:b.length}:{state:this,n:0})}b.push(j),c=c.applyInner(j),e=!0}d&&(d[f]={state:c,n:b.length})}}if(!e)return{state:c,transactions:b}}}applyInner(a){if(!a.before.eq(this.doc))throw RangeError("Applying a mismatched transaction");let b=new fD(this.config),c=this.config.fields;for(let d=0;d<c.length;d++){let e=c[d];b[e.name]=e.apply(a,this[e.name],this,b)}return b}get tr(){return new fy(this)}static create(a){let b=new fC(a.doc?a.doc.type.schema:a.schema,a.plugins),c=new fD(b);for(let d=0;d<b.fields.length;d++)c[b.fields[d].name]=b.fields[d].init(a,c);return c}reconfigure(a){let b=new fC(this.schema,a.plugins),c=b.fields,d=new fD(b);for(let b=0;b<c.length;b++){let e=c[b].name;d[e]=this.hasOwnProperty(e)?this[e]:c[b].init(a,d)}return d}toJSON(a){let b={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(b.storedMarks=this.storedMarks.map(a=>a.toJSON())),a&&"object"==typeof a)for(let c in a){if("doc"==c||"selection"==c)throw RangeError("The JSON fields `doc` and `selection` are reserved");let d=a[c],e=d.spec.state;e&&e.toJSON&&(b[c]=e.toJSON.call(d,this[d.key]))}return b}static fromJSON(a,b,c){if(!b)throw RangeError("Invalid input for EditorState.fromJSON");if(!a.schema)throw RangeError("Required config field 'schema' missing");let d=new fC(a.schema,a.plugins),e=new fD(d);return d.fields.forEach(d=>{if("doc"==d.name)e.doc=eh.fromJSON(a.schema,b.doc);else if("selection"==d.name)e.selection=fm.fromJSON(e.doc,b.selection);else if("storedMarks"==d.name)b.storedMarks&&(e.storedMarks=b.storedMarks.map(a.schema.markFromJSON));else{if(c)for(let f in c){let g=c[f],h=g.spec.state;if(g.key==d.name&&h&&h.fromJSON&&Object.prototype.hasOwnProperty.call(b,f)){e[d.name]=h.fromJSON.call(g,a,b[f],e);return}}e[d.name]=d.init(a,e)}}),e}}class fE{constructor(a){this.spec=a,this.props={},a.props&&function a(b,c,d){for(let e in b){let f=b[e];f instanceof Function?f=f.bind(c):"handleDOMEvents"==e&&(f=a(f,c,{})),d[e]=f}return d}(a.props,this,this.props),this.key=a.key?a.key.key:fG("plugin")}getState(a){return a[this.key]}}let fF=Object.create(null);function fG(a){return a in fF?a+"$"+ ++fF[a]:(fF[a]=0,a+"$")}class fH{constructor(a="key"){this.key=fG(a)}get(a){return a.config.pluginsByKey[this.key]}getState(a){return a[this.key]}}let fI=function(a){for(var b=0;;b++)if(!(a=a.previousSibling))return b},fJ=function(a){let b=a.assignedSlot||a.parentNode;return b&&11==b.nodeType?b.host:b},fK=null,fL=function(a,b,c){let d=fK||(fK=document.createRange());return d.setEnd(a,null==c?a.nodeValue.length:c),d.setStart(a,b||0),d},fM=function(){fK=null},fN=function(a,b,c,d){return c&&(fP(a,b,c,d,-1)||fP(a,b,c,d,1))},fO=/^(img|br|input|textarea|hr)$/i;function fP(a,b,c,d,e){for(var f;;){if(a==c&&b==d)return!0;if(b==(e<0?0:fQ(a))){let c=a.parentNode;if(!c||1!=c.nodeType||fR(a)||fO.test(a.nodeName)||"false"==a.contentEditable)return!1;b=fI(a)+(e<0?0:1),a=c}else{if(1!=a.nodeType)return!1;let c=a.childNodes[b+(e<0?-1:0)];if(1==c.nodeType&&"false"==c.contentEditable)if(null==(f=c.pmViewDesc)||!f.ignoreForSelection)return!1;else b+=e;else a=c,b=e<0?fQ(a):0}}}function fQ(a){return 3==a.nodeType?a.nodeValue.length:a.childNodes.length}function fR(a){let b;for(let c=a;c&&!(b=c.pmViewDesc);c=c.parentNode);return b&&b.node&&b.node.isBlock&&(b.dom==a||b.contentDOM==a)}let fS=function(a){return a.focusNode&&fN(a.focusNode,a.focusOffset,a.anchorNode,a.anchorOffset)};function fT(a,b){let c=document.createEvent("Event");return c.initEvent("keydown",!0,!0),c.keyCode=a,c.key=c.code=b,c}let fU="u">typeof navigator?navigator:null,fV="u">typeof document?document:null,fW=fU&&fU.userAgent||"",fX=/Edge\/(\d+)/.exec(fW),fY=/MSIE \d/.exec(fW),fZ=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(fW),f$=!!(fY||fZ||fX),f_=fY?document.documentMode:fZ?+fZ[1]:fX?+fX[1]:0,f0=!f$&&/gecko\/(\d+)/i.test(fW);f0&&(/Firefox\/(\d+)/.exec(fW)||[0,0])[1];let f1=!f$&&/Chrome\/(\d+)/.exec(fW),f2=!!f1,f3=f1?+f1[1]:0,f4=!f$&&!!fU&&/Apple Computer/.test(fU.vendor),f5=f4&&(/Mobile\/\w+/.test(fW)||!!fU&&fU.maxTouchPoints>2),f6=f5||!!fU&&/Mac/.test(fU.platform),f7=!!fU&&/Win/.test(fU.platform),f8=/Android \d/.test(fW),f9=!!fV&&"webkitFontSmoothing"in fV.documentElement.style,ga=f9?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function gb(a,b){return"number"==typeof a?a:a[b]}function gc(a,b,c){let d=a.someProp("scrollThreshold")||0,e=a.someProp("scrollMargin")||5,f=a.dom.ownerDocument;for(let g=c||a.dom;g;){if(1!=g.nodeType){g=fJ(g);continue}let a=g,c=a==f.body,h=c?function(a){let b=a.defaultView&&a.defaultView.visualViewport;return b?{left:0,right:b.width,top:0,bottom:b.height}:{left:0,right:a.documentElement.clientWidth,top:0,bottom:a.documentElement.clientHeight}}(f):function(a){let b=a.getBoundingClientRect(),c=b.width/a.offsetWidth||1,d=b.height/a.offsetHeight||1;return{left:b.left,right:b.left+a.clientWidth*c,top:b.top,bottom:b.top+a.clientHeight*d}}(a),i=0,j=0;if(b.top<h.top+gb(d,"top")?j=-(h.top-b.top+gb(e,"top")):b.bottom>h.bottom-gb(d,"bottom")&&(j=b.bottom-b.top>h.bottom-h.top?b.top+gb(e,"top")-h.top:b.bottom-h.bottom+gb(e,"bottom")),b.left<h.left+gb(d,"left")?i=-(h.left-b.left+gb(e,"left")):b.right>h.right-gb(d,"right")&&(i=b.right-h.right+gb(e,"right")),i||j)if(c)f.defaultView.scrollBy(i,j);else{let c=a.scrollLeft,d=a.scrollTop;j&&(a.scrollTop+=j),i&&(a.scrollLeft+=i);let e=a.scrollLeft-c,f=a.scrollTop-d;b={left:b.left-e,top:b.top-f,right:b.right-e,bottom:b.bottom-f}}let k=c?"fixed":getComputedStyle(g).position;if(/^(fixed|sticky)$/.test(k))break;g="absolute"==k?g.offsetParent:fJ(g)}}function gd(a){let b=[],c=a.ownerDocument;for(let d=a;d&&(b.push({dom:d,top:d.scrollTop,left:d.scrollLeft}),a!=c);d=fJ(d));return b}function ge(a,b){for(let c=0;c<a.length;c++){let{dom:d,top:e,left:f}=a[c];d.scrollTop!=e+b&&(d.scrollTop=e+b),d.scrollLeft!=f&&(d.scrollLeft=f)}}let gf=null;function gg(a,b){return a.left>=b.left-1&&a.left<=b.right+1&&a.top>=b.top-1&&a.top<=b.bottom+1}function gh(a){return a.top<a.bottom||a.left<a.right}function gi(a,b){let c=a.getClientRects();if(c.length){let a=c[b<0?0:c.length-1];if(gh(a))return a}return Array.prototype.find.call(c,gh)||a.getBoundingClientRect()}let gj=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function gk(a,b,c){let{node:d,offset:e,atom:f}=a.docView.domFromPos(b,c<0?-1:1),g=f9||f0;if(3==d.nodeType)if(g&&(gj.test(d.nodeValue)||(c<0?!e:e==d.nodeValue.length))){let a=gi(fL(d,e,e),c);if(f0&&e&&/\s/.test(d.nodeValue[e-1])&&e<d.nodeValue.length){let b=gi(fL(d,e-1,e-1),-1);if(b.top==a.top){let c=gi(fL(d,e,e+1),-1);if(c.top!=a.top)return gl(c,c.left<b.left)}}return a}else{let a=e,b=e,f=c<0?1:-1;return c<0&&!e?(b++,f=-1):c>=0&&e==d.nodeValue.length?(a--,f=1):c<0?a--:b++,gl(gi(fL(d,a,b),f),f<0)}if(!a.state.doc.resolve(b-(f||0)).parent.inlineContent){if(null==f&&e&&(c<0||e==fQ(d))){let a=d.childNodes[e-1];if(1==a.nodeType)return gm(a.getBoundingClientRect(),!1)}if(null==f&&e<fQ(d)){let a=d.childNodes[e];if(1==a.nodeType)return gm(a.getBoundingClientRect(),!0)}return gm(d.getBoundingClientRect(),c>=0)}if(null==f&&e&&(c<0||e==fQ(d))){let a=d.childNodes[e-1],b=3==a.nodeType?fL(a,fQ(a)-!g):1!=a.nodeType||"BR"==a.nodeName&&a.nextSibling?null:a;if(b)return gl(gi(b,1),!1)}if(null==f&&e<fQ(d)){let a=d.childNodes[e];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let b=a?3==a.nodeType?fL(a,0,+!g):1==a.nodeType?a:null:null;if(b)return gl(gi(b,-1),!0)}return gl(gi(3==d.nodeType?fL(d):d,-c),c>=0)}function gl(a,b){if(0==a.width)return a;let c=b?a.left:a.right;return{top:a.top,bottom:a.bottom,left:c,right:c}}function gm(a,b){if(0==a.height)return a;let c=b?a.top:a.bottom;return{top:c,bottom:c,left:a.left,right:a.right}}function gn(a,b,c){let d=a.state,e=a.root.activeElement;d!=b&&a.updateState(b),e!=a.dom&&a.focus();try{return c()}finally{d!=b&&a.updateState(d),e!=a.dom&&e&&e.focus()}}let go=/[\u0590-\u08ac]/,gp=null,gq=null,gr=!1;class gs{constructor(a,b,c,d){this.parent=a,this.children=b,this.dom=c,this.contentDOM=d,this.dirty=0,c.pmViewDesc=this}matchesWidget(a){return!1}matchesMark(a){return!1}matchesNode(a,b,c){return!1}matchesHack(a){return!1}parseRule(){return null}stopEvent(a){return!1}get size(){let a=0;for(let b=0;b<this.children.length;b++)a+=this.children[b].size;return a}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let a=0;a<this.children.length;a++)this.children[a].destroy()}posBeforeChild(a){for(let b=0,c=this.posAtStart;;b++){let d=this.children[b];if(d==a)return c;c+=d.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(a,b,c){let d;if(this.contentDOM&&this.contentDOM.contains(1==a.nodeType?a:a.parentNode))if(c<0){let c,d;if(a==this.contentDOM)c=a.childNodes[b-1];else{for(;a.parentNode!=this.contentDOM;)a=a.parentNode;c=a.previousSibling}for(;c&&!((d=c.pmViewDesc)&&d.parent==this);)c=c.previousSibling;return c?this.posBeforeChild(d)+d.size:this.posAtStart}else{let c,d;if(a==this.contentDOM)c=a.childNodes[b];else{for(;a.parentNode!=this.contentDOM;)a=a.parentNode;c=a.nextSibling}for(;c&&!((d=c.pmViewDesc)&&d.parent==this);)c=c.nextSibling;return c?this.posBeforeChild(d):this.posAtEnd}if(a==this.dom&&this.contentDOM)d=b>fI(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))d=2&a.compareDocumentPosition(this.contentDOM);else if(this.dom.firstChild){if(0==b)for(let b=a;;b=b.parentNode){if(b==this.dom){d=!1;break}if(b.previousSibling)break}if(null==d&&b==a.childNodes.length)for(let b=a;;b=b.parentNode){if(b==this.dom){d=!0;break}if(b.nextSibling)break}}return(null==d?c>0:d)?this.posAtEnd:this.posAtStart}nearestDesc(a,b=!1){for(let c=!0,d=a;d;d=d.parentNode){let e=this.getDesc(d),f;if(e&&(!b||e.node))if(!c||!(f=e.nodeDOM)||(1==f.nodeType?f.contains(1==a.nodeType?a:a.parentNode):f==a))return e;else c=!1}}getDesc(a){let b=a.pmViewDesc;for(let a=b;a;a=a.parent)if(a==this)return b}posFromDOM(a,b,c){for(let d=a;d;d=d.parentNode){let e=this.getDesc(d);if(e)return e.localPosFromDOM(a,b,c)}return -1}descAt(a){for(let b=0,c=0;b<this.children.length;b++){let d=this.children[b],e=c+d.size;if(c==a&&e!=c){for(;!d.border&&d.children.length;)for(let a=0;a<d.children.length;a++){let b=d.children[a];if(b.size){d=b;break}}return d}if(a<e)return d.descAt(a-c-d.border);c=e}}domFromPos(a,b){if(!this.contentDOM)return{node:this.dom,offset:0,atom:a+1};let c=0,d=0;for(let b=0;c<this.children.length;c++){let e=this.children[c],f=b+e.size;if(f>a||e instanceof gz){d=a-b;break}b=f}if(d)return this.children[c].domFromPos(d-this.children[c].border,b);for(let a;c&&!(a=this.children[c-1]).size&&a instanceof gt&&a.side>=0;c--);if(b<=0){let a,d=!0;for(;(a=c?this.children[c-1]:null)&&a.dom.parentNode!=this.contentDOM;c--,d=!1);return a&&b&&d&&!a.border&&!a.domAtom?a.domFromPos(a.size,b):{node:this.contentDOM,offset:a?fI(a.dom)+1:0}}{let a,d=!0;for(;(a=c<this.children.length?this.children[c]:null)&&a.dom.parentNode!=this.contentDOM;c++,d=!1);return a&&d&&!a.border&&!a.domAtom?a.domFromPos(0,b):{node:this.contentDOM,offset:a?fI(a.dom):this.contentDOM.childNodes.length}}}parseRange(a,b,c=0){if(0==this.children.length)return{node:this.contentDOM,from:a,to:b,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let d=-1,e=-1;for(let f=c,g=0;;g++){let c=this.children[g],h=f+c.size;if(-1==d&&a<=h){let e=f+c.border;if(a>=e&&b<=h-c.border&&c.node&&c.contentDOM&&this.contentDOM.contains(c.contentDOM))return c.parseRange(a,b,e);a=f;for(let b=g;b>0;b--){let c=this.children[b-1];if(c.size&&c.dom.parentNode==this.contentDOM&&!c.emptyChildAt(1)){d=fI(c.dom)+1;break}a-=c.size}-1==d&&(d=0)}if(d>-1&&(h>b||g==this.children.length-1)){b=h;for(let a=g+1;a<this.children.length;a++){let c=this.children[a];if(c.size&&c.dom.parentNode==this.contentDOM&&!c.emptyChildAt(-1)){e=fI(c.dom);break}b+=c.size}-1==e&&(e=this.contentDOM.childNodes.length);break}f=h}return{node:this.contentDOM,from:a,to:b,fromOffset:d,toOffset:e}}emptyChildAt(a){if(this.border||!this.contentDOM||!this.children.length)return!1;let b=this.children[a<0?0:this.children.length-1];return 0==b.size||b.emptyChildAt(a)}domAfterPos(a){let{node:b,offset:c}=this.domFromPos(a,0);if(1!=b.nodeType||c==b.childNodes.length)throw RangeError("No node after pos "+a);return b.childNodes[c]}setSelection(a,b,c,d=!1){let e=Math.min(a,b),f=Math.max(a,b);for(let g=0,h=0;g<this.children.length;g++){let i=this.children[g],j=h+i.size;if(e>h&&f<j)return i.setSelection(a-h-i.border,b-h-i.border,c,d);h=j}let g=this.domFromPos(a,a?-1:1),h=b==a?g:this.domFromPos(b,b?-1:1),i=c.root.getSelection(),j=c.domSelectionRange(),k=!1;if((f0||f4)&&a==b){let{node:a,offset:b}=g;if(3==a.nodeType){if((k=!!(b&&"\n"==a.nodeValue[b-1]))&&b==a.nodeValue.length)for(let b=a,c;b;b=b.parentNode){if(c=b.nextSibling){"BR"==c.nodeName&&(g=h={node:c.parentNode,offset:fI(c)+1});break}let a=b.pmViewDesc;if(a&&a.node&&a.node.isBlock)break}}else{let c=a.childNodes[b-1];k=c&&("BR"==c.nodeName||"false"==c.contentEditable)}}if(f0&&j.focusNode&&j.focusNode!=h.node&&1==j.focusNode.nodeType){let a=j.focusNode.childNodes[j.focusOffset];a&&"false"==a.contentEditable&&(d=!0)}if(!(d||k&&f4)&&fN(g.node,g.offset,j.anchorNode,j.anchorOffset)&&fN(h.node,h.offset,j.focusNode,j.focusOffset))return;let l=!1;if((i.extend||a==b)&&!(k&&f0)){i.collapse(g.node,g.offset);try{a!=b&&i.extend(h.node,h.offset),l=!0}catch(a){}}if(!l){if(a>b){let a=g;g=h,h=a}let c=document.createRange();c.setEnd(h.node,h.offset),c.setStart(g.node,g.offset),i.removeAllRanges(),i.addRange(c)}}ignoreMutation(a){return!this.contentDOM&&"selection"!=a.type}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(a,b){for(let c=0,d=0;d<this.children.length;d++){let e=this.children[d],f=c+e.size;if(c==f?a<=f&&b>=c:a<f&&b>c){let d=c+e.border,g=f-e.border;if(a>=d&&b<=g){this.dirty=a==c||b==f?2:1,a==d&&b==g&&(e.contentLost||e.dom.parentNode!=this.contentDOM)?e.dirty=3:e.markDirty(a-d,b-d);return}e.dirty=e.dom!=e.contentDOM||e.dom.parentNode!=this.contentDOM||e.children.length?3:2}c=f}this.dirty=2}markParentsDirty(){let a=1;for(let b=this.parent;b;b=b.parent,a++){let c=1==a?2:1;b.dirty<c&&(b.dirty=c)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(a){return!1}}class gt extends gs{constructor(a,b,c,d){let e,f=b.type.toDOM;if("function"==typeof f&&(f=f(c,()=>e?e.parent?e.parent.posBeforeChild(e):void 0:d)),!b.type.spec.raw){if(1!=f.nodeType){let a=document.createElement("span");a.appendChild(f),f=a}f.contentEditable="false",f.classList.add("ProseMirror-widget")}super(a,[],f,null),this.widget=b,this.widget=b,e=this}matchesWidget(a){return 0==this.dirty&&a.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(a){let b=this.widget.spec.stopEvent;return!!b&&b(a)}ignoreMutation(a){return"selection"!=a.type||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class gu extends gs{constructor(a,b,c,d){super(a,[],b,null),this.textDOM=c,this.text=d}get size(){return this.text.length}localPosFromDOM(a,b){return a!=this.textDOM?this.posAtStart+(b?this.size:0):this.posAtStart+b}domFromPos(a){return{node:this.textDOM,offset:a}}ignoreMutation(a){return"characterData"===a.type&&a.target.nodeValue==a.oldValue}}class gv extends gs{constructor(a,b,c,d,e){super(a,[],c,d),this.mark=b,this.spec=e}static create(a,b,c,d){let e=d.nodeViews[b.type.name],f=e&&e(b,d,c);return f&&f.dom||(f=eH.renderSpec(document,b.type.spec.toDOM(b,c),null,b.attrs)),new gv(a,b,f.dom,f.contentDOM||f.dom,f)}parseRule(){return 3&this.dirty||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(a){return 3!=this.dirty&&this.mark.eq(a)}markDirty(a,b){if(super.markDirty(a,b),0!=this.dirty){let a=this.parent;for(;!a.node;)a=a.parent;a.dirty<this.dirty&&(a.dirty=this.dirty),this.dirty=0}}slice(a,b,c){let d=gv.create(this.parent,this.mark,!0,c),e=this.children,f=this.size;b<f&&(e=gK(e,b,f,c)),a>0&&(e=gK(e,0,a,c));for(let a=0;a<e.length;a++)e[a].parent=d;return d.children=e,d}ignoreMutation(a){return this.spec.ignoreMutation?this.spec.ignoreMutation(a):super.ignoreMutation(a)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class gw extends gs{constructor(a,b,c,d,e,f,g,h,i){super(a,[],e,f),this.node=b,this.outerDeco=c,this.innerDeco=d,this.nodeDOM=g}static create(a,b,c,d,e,f){let g=e.nodeViews[b.type.name],h,i=g&&g(b,e,()=>h?h.parent?h.parent.posBeforeChild(h):void 0:f,c,d),j=i&&i.dom,k=i&&i.contentDOM;if(b.isText)if(j){if(3!=j.nodeType)throw RangeError("Text must be rendered as a DOM text node")}else j=document.createTextNode(b.text);else if(!j){let a=eH.renderSpec(document,b.type.spec.toDOM(b),null,b.attrs);({dom:j,contentDOM:k}=a)}k||b.isText||"BR"==j.nodeName||(j.hasAttribute("contenteditable")||(j.contentEditable="false"),b.type.spec.draggable&&(j.draggable=!0));let l=j;return(j=gF(j,c,b),i)?h=new gA(a,b,c,d,j,k||null,l,i,e,f+1):b.isText?new gy(a,b,c,d,j,l,e):new gw(a,b,c,d,j,k||null,l,e,f+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let a={node:this.node.type.name,attrs:this.node.attrs};if("pre"==this.node.type.whitespace&&(a.preserveWhitespace="full"),this.contentDOM)if(this.contentLost){for(let b=this.children.length-1;b>=0;b--){let c=this.children[b];if(this.dom.contains(c.dom.parentNode)){a.contentElement=c.dom.parentNode;break}}a.contentElement||(a.getContent=()=>d$.empty)}else a.contentElement=this.contentDOM;else a.getContent=()=>this.node.content;return a}matchesNode(a,b,c){return 0==this.dirty&&a.eq(this.node)&&gG(b,this.outerDeco)&&c.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return+!this.node.isLeaf}updateChildren(a,b){let c=this.node.inlineContent,d=b,e=a.composing?this.localCompositionInfo(a,b):null,f=e&&e.pos>-1?e:null,g=e&&e.pos<0,h=new gI(this,f&&f.node,a);(function(a,b,c,d){let e=b.locals(a),f=0;if(0==e.length){for(let c=0;c<a.childCount;c++){let g=a.child(c);d(g,e,b.forChild(f,g),c),f+=g.nodeSize}return}let g=0,h=[],i=null;for(let j=0;;){let k,l,m,n;for(;g<e.length&&e[g].to==f;){let a=e[g++];a.widget&&(k?(l||(l=[k])).push(a):k=a)}if(k)if(l){l.sort(gJ);for(let a=0;a<l.length;a++)c(l[a],j,!!i)}else c(k,j,!!i);if(i)n=-1,m=i,i=null;else if(j<a.childCount)n=j,m=a.child(j++);else break;for(let a=0;a<h.length;a++)h[a].to<=f&&h.splice(a--,1);for(;g<e.length&&e[g].from<=f&&e[g].to>f;)h.push(e[g++]);let o=f+m.nodeSize;if(m.isText){let a=o;g<e.length&&e[g].from<a&&(a=e[g].from);for(let b=0;b<h.length;b++)h[b].to<a&&(a=h[b].to);a<o&&(i=m.cut(a-f),m=m.cut(0,a-f),o=a,n=-1)}else for(;g<e.length&&e[g].to<o;)g++;let p=m.isInline&&!m.isLeaf?h.filter(a=>!a.inline):h.slice();d(m,p,b.forChild(f,m),n),f=o}})(this.node,this.innerDeco,(b,e,f)=>{b.spec.marks?h.syncToMarks(b.spec.marks,c,a,e):b.type.side>=0&&!f&&h.syncToMarks(e==this.node.childCount?d2.none:this.node.child(e).marks,c,a,e),h.placeWidget(b,a,d)},(b,f,i,j)=>{let k;h.syncToMarks(b.marks,c,a,j),h.findNodeMatch(b,f,i,j)||g&&a.state.selection.from>d&&a.state.selection.to<d+b.nodeSize&&(k=h.findIndexWithChild(e.node))>-1&&h.updateNodeAt(b,f,i,k,a)||h.updateNextNode(b,f,i,a,j,d)||h.addNode(b,f,i,a,d),d+=b.nodeSize}),h.syncToMarks([],c,a,0),this.node.isTextblock&&h.addTextblockHacks(),h.destroyRest(),(h.changed||2==this.dirty)&&(f&&this.protectLocalComposition(a,f),function a(b,c,d){let e=b.firstChild,f=!1;for(let g=0;g<c.length;g++){let h=c[g],i=h.dom;if(i.parentNode==b){for(;i!=e;)e=gH(e),f=!0;e=e.nextSibling}else f=!0,b.insertBefore(i,e);if(h instanceof gv){let c=e?e.previousSibling:b.lastChild;a(h.contentDOM,h.children,d),e=c?c.nextSibling:b.firstChild}}for(;e;)e=gH(e),f=!0;f&&d.trackWrites==b&&(d.trackWrites=null)}(this.contentDOM,this.children,a),f5&&function(a){if("UL"==a.nodeName||"OL"==a.nodeName){let b=a.style.cssText;a.style.cssText=b+"; list-style: square !important",window.getComputedStyle(a).listStyle,a.style.cssText=b}}(this.dom))}localCompositionInfo(a,b){let{from:c,to:d}=a.state.selection;if(!(a.state.selection instanceof fq)||c<b||d>b+this.node.content.size)return null;let e=a.input.compositionNode;if(!e||!this.dom.contains(e.parentNode))return null;if(!this.node.inlineContent)return{node:e,pos:-1,text:""};{let a=e.nodeValue,f=function(a,b,c,d){for(let e=0,f=0;e<a.childCount&&f<=d;){let g=a.child(e++),h=f;if(f+=g.nodeSize,!g.isText)continue;let i=g.text;for(;e<a.childCount;){let b=a.child(e++);if(f+=b.nodeSize,!b.isText)break;i+=b.text}if(f>=c){if(f>=d&&i.slice(d-b.length-h,d-h)==b)return d-b.length;let a=h<d?i.lastIndexOf(b,d-h-1):-1;if(a>=0&&a+b.length+h>=c)return h+a;if(c==d&&i.length>=d+b.length-h&&i.slice(d-h,d-h+b.length)==b)return d}}return -1}(this.node.content,a,c-b,d-b);return f<0?null:{node:e,pos:f,text:a}}}protectLocalComposition(a,{node:b,pos:c,text:d}){if(this.getDesc(b))return;let e=b;for(;e.parentNode!=this.contentDOM;e=e.parentNode){for(;e.previousSibling;)e.parentNode.removeChild(e.previousSibling);for(;e.nextSibling;)e.parentNode.removeChild(e.nextSibling);e.pmViewDesc&&(e.pmViewDesc=void 0)}let f=new gu(this,e,b,d);a.input.compositionNodes.push(f),this.children=gK(this.children,c,c+d.length,a,f)}update(a,b,c,d){return 3!=this.dirty&&!!a.sameMarkup(this.node)&&(this.updateInner(a,b,c,d),!0)}updateInner(a,b,c,d){this.updateOuterDeco(b),this.node=a,this.innerDeco=c,this.contentDOM&&this.updateChildren(d,this.posAtStart),this.dirty=0}updateOuterDeco(a){if(gG(a,this.outerDeco))return;let b=1!=this.nodeDOM.nodeType,c=this.dom;this.dom=gE(this.dom,this.nodeDOM,gD(this.outerDeco,this.node,b),gD(a,this.node,b)),this.dom!=c&&(c.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=a}selectNode(){1==this.nodeDOM.nodeType&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){1==this.nodeDOM.nodeType&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function gx(a,b,c,d,e){gF(d,b,a);let f=new gw(void 0,a,b,c,d,d,d,e,0);return f.contentDOM&&f.updateChildren(e,0),f}class gy extends gw{constructor(a,b,c,d,e,f,g){super(a,b,c,d,e,null,f,g,0)}parseRule(){let a=this.nodeDOM.parentNode;for(;a&&a!=this.dom&&!a.pmIsDeco;)a=a.parentNode;return{skip:a||!0}}update(a,b,c,d){return 3!=this.dirty&&(0==this.dirty||!!this.inParent())&&!!a.sameMarkup(this.node)&&(this.updateOuterDeco(b),(0!=this.dirty||a.text!=this.node.text)&&a.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=a.text,d.trackWrites==this.nodeDOM&&(d.trackWrites=null)),this.node=a,this.dirty=0,!0)}inParent(){let a=this.parent.contentDOM;for(let b=this.nodeDOM;b;b=b.parentNode)if(b==a)return!0;return!1}domFromPos(a){return{node:this.nodeDOM,offset:a}}localPosFromDOM(a,b,c){return a==this.nodeDOM?this.posAtStart+Math.min(b,this.node.text.length):super.localPosFromDOM(a,b,c)}ignoreMutation(a){return"characterData"!=a.type&&"selection"!=a.type}slice(a,b,c){let d=this.node.cut(a,b),e=document.createTextNode(d.text);return new gy(this.parent,d,this.outerDeco,this.innerDeco,e,e,c)}markDirty(a,b){super.markDirty(a,b),this.dom!=this.nodeDOM&&(0==a||b==this.nodeDOM.nodeValue.length)&&(this.dirty=3)}get domAtom(){return!1}isText(a){return this.node.text==a}}class gz extends gs{parseRule(){return{ignore:!0}}matchesHack(a){return 0==this.dirty&&this.dom.nodeName==a}get domAtom(){return!0}get ignoreForCoords(){return"IMG"==this.dom.nodeName}}class gA extends gw{constructor(a,b,c,d,e,f,g,h,i,j){super(a,b,c,d,e,f,g,i,j),this.spec=h}update(a,b,c,d){if(3==this.dirty)return!1;if(this.spec.update&&(this.node.type==a.type||this.spec.multiType)){let e=this.spec.update(a,b,c);return e&&this.updateInner(a,b,c,d),e}return(!!this.contentDOM||!!a.isLeaf)&&super.update(a,b,c,d)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(a,b,c,d){this.spec.setSelection?this.spec.setSelection(a,b,c.root):super.setSelection(a,b,c,d)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(a){return!!this.spec.stopEvent&&this.spec.stopEvent(a)}ignoreMutation(a){return this.spec.ignoreMutation?this.spec.ignoreMutation(a):super.ignoreMutation(a)}}let gB=function(a){a&&(this.nodeName=a)};gB.prototype=Object.create(null);let gC=[new gB];function gD(a,b,c){if(0==a.length)return gC;let d=c?gC[0]:new gB,e=[d];for(let f=0;f<a.length;f++){let g=a[f].type.attrs;if(g)for(let a in g.nodeName&&e.push(d=new gB(g.nodeName)),g){let f=g[a];null!=f&&(c&&1==e.length&&e.push(d=new gB(b.isInline?"span":"div")),"class"==a?d.class=(d.class?d.class+" ":"")+f:"style"==a?d.style=(d.style?d.style+";":"")+f:"nodeName"!=a&&(d[a]=f))}}return e}function gE(a,b,c,d){if(c==gC&&d==gC)return b;let e=b;for(let b=0;b<d.length;b++){let f=d[b],g=c[b];if(b){let b;g&&g.nodeName==f.nodeName&&e!=a&&(b=e.parentNode)&&b.nodeName.toLowerCase()==f.nodeName||((b=document.createElement(f.nodeName)).pmIsDeco=!0,b.appendChild(e),g=gC[0]),e=b}!function(a,b,c){for(let d in b)"class"==d||"style"==d||"nodeName"==d||d in c||a.removeAttribute(d);for(let d in c)"class"!=d&&"style"!=d&&"nodeName"!=d&&c[d]!=b[d]&&a.setAttribute(d,c[d]);if(b.class!=c.class){let d=b.class?b.class.split(" ").filter(Boolean):[],e=c.class?c.class.split(" ").filter(Boolean):[];for(let b=0;b<d.length;b++)-1==e.indexOf(d[b])&&a.classList.remove(d[b]);for(let b=0;b<e.length;b++)-1==d.indexOf(e[b])&&a.classList.add(e[b]);0==a.classList.length&&a.removeAttribute("class")}if(b.style!=c.style){if(b.style){let c=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,d;for(;d=c.exec(b.style);)a.style.removeProperty(d[1])}c.style&&(a.style.cssText+=c.style)}}(e,g||gC[0],f)}return e}function gF(a,b,c){return gE(a,a,gC,gD(b,c,1!=a.nodeType))}function gG(a,b){if(a.length!=b.length)return!1;for(let c=0;c<a.length;c++)if(!a[c].type.eq(b[c].type))return!1;return!0}function gH(a){let b=a.nextSibling;return a.parentNode.removeChild(a),b}class gI{constructor(a,b,c){this.lock=b,this.view=c,this.index=0,this.stack=[],this.changed=!1,this.top=a,this.preMatch=function(a,b){let c=b,d=c.children.length,e=a.childCount,f=new Map,g=[];d:for(;e>0;){let h;for(;;)if(d){let a=c.children[d-1];if(a instanceof gv)c=a,d=a.children.length;else{h=a,d--;break}}else if(c==b)break d;else d=c.parent.children.indexOf(c),c=c.parent;let i=h.node;if(i){if(i!=a.child(e-1))break;--e,f.set(h,e),g.push(h)}}return{index:e,matched:f,matches:g.reverse()}}(a.node.content,a)}destroyBetween(a,b){if(a!=b){for(let c=a;c<b;c++)this.top.children[c].destroy();this.top.children.splice(a,b-a),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(a,b,c,d){let e=0,f=this.stack.length>>1,g=Math.min(f,a.length);for(;e<g&&(e==f-1?this.top:this.stack[e+1<<1]).matchesMark(a[e])&&!1!==a[e].type.spec.spanning;)e++;for(;e<f;)this.destroyRest(),this.top.dirty=0,this.index=this.stack.pop(),this.top=this.stack.pop(),f--;for(;f<a.length;){this.stack.push(this.top,this.index+1);let e=-1,g=this.top.children.length;d<this.preMatch.index&&(g=Math.min(this.index+3,g));for(let b=this.index;b<g;b++){let c=this.top.children[b];if(c.matchesMark(a[f])&&!this.isLocked(c.dom)){e=b;break}}if(e>-1)e>this.index&&(this.changed=!0,this.destroyBetween(this.index,e)),this.top=this.top.children[this.index];else{let d=gv.create(this.top,a[f],b,c);this.top.children.splice(this.index,0,d),this.top=d,this.changed=!0}this.index=0,f++}}findNodeMatch(a,b,c,d){let e=-1,f;if(d>=this.preMatch.index&&(f=this.preMatch.matches[d-this.preMatch.index]).parent==this.top&&f.matchesNode(a,b,c))e=this.top.children.indexOf(f,this.index);else for(let d=this.index,f=Math.min(this.top.children.length,d+5);d<f;d++){let f=this.top.children[d];if(f.matchesNode(a,b,c)&&!this.preMatch.matched.has(f)){e=d;break}}return!(e<0)&&(this.destroyBetween(this.index,e),this.index++,!0)}updateNodeAt(a,b,c,d,e){let f=this.top.children[d];return 3==f.dirty&&f.dom==f.contentDOM&&(f.dirty=2),!!f.update(a,b,c,e)&&(this.destroyBetween(this.index,d),this.index++,!0)}findIndexWithChild(a){for(;;){let b=a.parentNode;if(!b)return -1;if(b==this.top.contentDOM){let b=a.pmViewDesc;if(b){for(let a=this.index;a<this.top.children.length;a++)if(this.top.children[a]==b)return a}return -1}a=b}}updateNextNode(a,b,c,d,e,f){for(let g=this.index;g<this.top.children.length;g++){let h=this.top.children[g];if(h instanceof gw){let i=this.preMatch.matched.get(h);if(null!=i&&i!=e)return!1;let j=h.dom,k,l=this.isLocked(j)&&!(a.isText&&h.node&&h.node.isText&&h.nodeDOM.nodeValue==a.text&&3!=h.dirty&&gG(b,h.outerDeco));if(!l&&h.update(a,b,c,d))return this.destroyBetween(this.index,g),h.dom!=j&&(this.changed=!0),this.index++,!0;if(!l&&(k=this.recreateWrapper(h,a,b,c,d,f)))return this.destroyBetween(this.index,g),this.top.children[this.index]=k,k.contentDOM&&(k.dirty=2,k.updateChildren(d,f+1),k.dirty=0),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(a,b,c,d,e,f){if(a.dirty||b.isAtom||!a.children.length||!a.node.content.eq(b.content)||!gG(c,a.outerDeco)||!d.eq(a.innerDeco))return null;let g=gw.create(this.top,b,c,d,e,f);if(g.contentDOM)for(let b of(g.children=a.children,a.children=[],g.children))b.parent=g;return a.destroy(),g}addNode(a,b,c,d,e){let f=gw.create(this.top,a,b,c,d,e);f.contentDOM&&f.updateChildren(d,e+1),this.top.children.splice(this.index++,0,f),this.changed=!0}placeWidget(a,b,c){let d=this.index<this.top.children.length?this.top.children[this.index]:null;if(d&&d.matchesWidget(a)&&(a==d.widget||!d.widget.type.toDOM.parentNode))this.index++;else{let d=new gt(this.top,a,b,c);this.top.children.splice(this.index++,0,d),this.changed=!0}}addTextblockHacks(){let a=this.top.children[this.index-1],b=this.top;for(;a instanceof gv;)a=(b=a).children[b.children.length-1];(!a||!(a instanceof gy)||/\n$/.test(a.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(a.node.text))&&((f4||f2)&&a&&"false"==a.dom.contentEditable&&this.addHackNode("IMG",b),this.addHackNode("BR",this.top))}addHackNode(a,b){if(b==this.top&&this.index<b.children.length&&b.children[this.index].matchesHack(a))this.index++;else{let c=document.createElement(a);"IMG"==a&&(c.className="ProseMirror-separator",c.alt=""),"BR"==a&&(c.className="ProseMirror-trailingBreak");let d=new gz(this.top,[],c,null);b!=this.top?b.children.push(d):b.children.splice(this.index++,0,d),this.changed=!0}}isLocked(a){return this.lock&&(a==this.lock||1==a.nodeType&&a.contains(this.lock.parentNode))}}function gJ(a,b){return a.type.side-b.type.side}function gK(a,b,c,d,e){let f=[];for(let g=0,h=0;g<a.length;g++){let i=a[g],j=h,k=h+=i.size;j>=c||k<=b?f.push(i):(j<b&&f.push(i.slice(0,b-j,d)),e&&(f.push(e),e=void 0),k>c&&f.push(i.slice(c-j,i.size,d)))}return f}function gL(a,b=null){let c=a.domSelectionRange(),d=a.state.doc;if(!c.focusNode)return null;let e=a.docView.nearestDesc(c.focusNode),f=e&&0==e.size,g=a.docView.posFromDOM(c.focusNode,c.focusOffset,1);if(g<0)return null;let h=d.resolve(g),i,j;if(fS(c)){for(i=g;e&&!e.node;)e=e.parent;let a=e.node;if(e&&a.isAtom&&fs.isSelectable(a)&&e.parent&&!(a.isInline&&function(a,b,c){for(let d=0==b,e=b==fQ(a);d||e;){if(a==c)return!0;let b=fI(a);if(!(a=a.parentNode))return!1;d=d&&0==b,e=e&&b==fQ(a)}}(c.focusNode,c.focusOffset,e.dom))){let a=e.posBefore;j=new fs(g==a?h:d.resolve(a))}}else{if(c instanceof a.dom.ownerDocument.defaultView.Selection&&c.rangeCount>1){let b=g,e=g;for(let d=0;d<c.rangeCount;d++){let f=c.getRangeAt(d);b=Math.min(b,a.docView.posFromDOM(f.startContainer,f.startOffset,1)),e=Math.max(e,a.docView.posFromDOM(f.endContainer,f.endOffset,-1))}if(b<0)return null;[i,g]=e==a.state.selection.anchor?[e,b]:[b,e],h=d.resolve(g)}else i=a.docView.posFromDOM(c.anchorNode,c.anchorOffset,1);if(i<0)return null}let k=d.resolve(i);if(!j){let c="pointer"==b||a.state.selection.head<h.pos&&!f?1:-1;j=gU(a,k,h,c)}return j}function gM(a){return a.editable?a.hasFocus():gW(a)&&document.activeElement&&document.activeElement.contains(a.dom)}function gN(a,b=!1){let c=a.state.selection;if(gS(a,c),gM(a)){if(!b&&a.input.mouseDown&&a.input.mouseDown.allowDefault&&f2){let b=a.domSelectionRange(),c=a.domObserver.currentSelection;if(b.anchorNode&&c.anchorNode&&fN(b.anchorNode,b.anchorOffset,c.anchorNode,c.anchorOffset)){a.input.mouseDown.delayedSelectionSync=!0,a.domObserver.setCurSelection();return}}if(a.domObserver.disconnectSelection(),a.cursorWrapper)!function(a){let b=a.domSelection();if(!b)return;let c=a.cursorWrapper.dom,d="IMG"==c.nodeName;d?b.collapse(c.parentNode,fI(c)+1):b.collapse(c,0),!d&&!a.state.selection.visible&&f$&&f_<=11&&(c.disabled=!0,c.disabled=!1)}(a);else{var d;let e,f,g,h,{anchor:i,head:j}=c,k,l;gO&&!(c instanceof fq)&&(c.$from.parent.inlineContent||(k=gP(a,c.from)),c.empty||c.$from.parent.inlineContent||(l=gP(a,c.to))),a.docView.setSelection(i,j,a,b),gO&&(k&&gR(k),l&&gR(l)),c.visible?a.dom.classList.remove("ProseMirror-hideselection"):(a.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&((e=(d=a).dom.ownerDocument).removeEventListener("selectionchange",d.input.hideSelectionGuard),g=(f=d.domSelectionRange()).anchorNode,h=f.anchorOffset,e.addEventListener("selectionchange",d.input.hideSelectionGuard=()=>{(f.anchorNode!=g||f.anchorOffset!=h)&&(e.removeEventListener("selectionchange",d.input.hideSelectionGuard),setTimeout(()=>{(!gM(d)||d.state.selection.visible)&&d.dom.classList.remove("ProseMirror-hideselection")},20))})))}a.domObserver.setCurSelection(),a.domObserver.connectSelection()}}let gO=f4||f2&&f3<63;function gP(a,b){let{node:c,offset:d}=a.docView.domFromPos(b,0),e=d<c.childNodes.length?c.childNodes[d]:null,f=d?c.childNodes[d-1]:null;if(f4&&e&&"false"==e.contentEditable)return gQ(e);if((!e||"false"==e.contentEditable)&&(!f||"false"==f.contentEditable)){if(e)return gQ(e);else if(f)return gQ(f)}}function gQ(a){return a.contentEditable="true",f4&&a.draggable&&(a.draggable=!1,a.wasDraggable=!0),a}function gR(a){a.contentEditable="false",a.wasDraggable&&(a.draggable=!0,a.wasDraggable=null)}function gS(a,b){if(b instanceof fs){let c=a.docView.descAt(b.from);c!=a.lastSelectedViewDesc&&(gT(a),c&&c.selectNode(),a.lastSelectedViewDesc=c)}else gT(a)}function gT(a){a.lastSelectedViewDesc&&(a.lastSelectedViewDesc.parent&&a.lastSelectedViewDesc.deselectNode(),a.lastSelectedViewDesc=void 0)}function gU(a,b,c,d){return a.someProp("createSelectionBetween",d=>d(a,b,c))||fq.between(b,c,d)}function gV(a){return(!a.editable||!!a.hasFocus())&&gW(a)}function gW(a){let b=a.domSelectionRange();if(!b.anchorNode)return!1;try{return a.dom.contains(3==b.anchorNode.nodeType?b.anchorNode.parentNode:b.anchorNode)&&(a.editable||a.dom.contains(3==b.focusNode.nodeType?b.focusNode.parentNode:b.focusNode))}catch(a){return!1}}function gX(a,b){let{$anchor:c,$head:d}=a.selection,e=b>0?c.max(d):c.min(d),f=e.parent.inlineContent?e.depth?a.doc.resolve(b>0?e.after():e.before()):null:e;return f&&fm.findFrom(f,b)}function gY(a,b){return a.dispatch(a.state.tr.setSelection(b).scrollIntoView()),!0}function gZ(a,b,c){let d=a.state.selection;if(d instanceof fq){if(c.indexOf("s")>-1){let{$head:c}=d,e=c.textOffset?null:b<0?c.nodeBefore:c.nodeAfter;if(!e||e.isText||!e.isLeaf)return!1;let f=a.state.doc.resolve(c.pos+e.nodeSize*(b<0?-1:1));return gY(a,new fq(d.$anchor,f))}else if(!d.empty)return!1;else if(a.endOfTextblock(b>0?"forward":"backward")){let c=gX(a.state,b);return!!c&&c instanceof fs&&gY(a,c)}else if(!(f6&&c.indexOf("m")>-1)){let c=d.$head,e=c.textOffset?null:b<0?c.nodeBefore:c.nodeAfter,f;if(!e||e.isText)return!1;let g=b<0?c.pos-e.nodeSize:c.pos;return!!(e.isAtom||(f=a.docView.descAt(g))&&!f.contentDOM)&&(fs.isSelectable(e)?gY(a,new fs(b<0?a.state.doc.resolve(c.pos-e.nodeSize):c)):!!f9&&gY(a,new fq(a.state.doc.resolve(b<0?g:g+e.nodeSize))))}}else{if(d instanceof fs&&d.node.isInline)return gY(a,new fq(b>0?d.$to:d.$from));let c=gX(a.state,b);return!!c&&gY(a,c)}}function g$(a){return 3==a.nodeType?a.nodeValue.length:a.childNodes.length}function g_(a,b){let c=a.pmViewDesc;return c&&0==c.size&&(b<0||a.nextSibling||"BR"!=a.nodeName)}function g0(a,b){return b<0?function(a){let b=a.domSelectionRange(),c=b.focusNode,d=b.focusOffset;if(!c)return;let e,f,g=!1;for(f0&&1==c.nodeType&&d<g$(c)&&g_(c.childNodes[d],-1)&&(g=!0);;)if(d>0)if(1!=c.nodeType)break;else{let a=c.childNodes[d-1];if(g_(a,-1))e=c,f=--d;else if(3==a.nodeType)d=(c=a).nodeValue.length;else break}else if(g1(c))break;else{let b=c.previousSibling;for(;b&&g_(b,-1);)e=c.parentNode,f=fI(b),b=b.previousSibling;if(b)d=g$(c=b);else{if((c=c.parentNode)==a.dom)break;d=0}}g?g2(a,c,d):e&&g2(a,e,f)}(a):function(a){let b,c,d=a.domSelectionRange(),e=d.focusNode,f=d.focusOffset;if(!e)return;let g=g$(e);for(;;)if(f<g){if(1!=e.nodeType)break;if(g_(e.childNodes[f],1))b=e,c=++f;else break}else if(g1(e))break;else{let d=e.nextSibling;for(;d&&g_(d,1);)b=d.parentNode,c=fI(d)+1,d=d.nextSibling;if(d)f=0,g=g$(e=d);else{if((e=e.parentNode)==a.dom)break;f=g=0}}b&&g2(a,b,c)}(a)}function g1(a){let b=a.pmViewDesc;return b&&b.node&&b.node.isBlock}function g2(a,b,c){if(3!=b.nodeType){let a,d;(d=function(a,b){for(;a&&b==a.childNodes.length&&!fR(a);)b=fI(a)+1,a=a.parentNode;for(;a&&b<a.childNodes.length;){let c=a.childNodes[b];if(3==c.nodeType)return c;if(1==c.nodeType&&"false"==c.contentEditable)break;a=c,b=0}}(b,c))?(b=d,c=0):(a=function(a,b){for(;a&&!b&&!fR(a);)b=fI(a),a=a.parentNode;for(;a&&b;){let c=a.childNodes[b-1];if(3==c.nodeType)return c;if(1==c.nodeType&&"false"==c.contentEditable)break;b=(a=c).childNodes.length}}(b,c))&&(b=a,c=a.nodeValue.length)}let d=a.domSelection();if(!d)return;if(fS(d)){let a=document.createRange();a.setEnd(b,c),a.setStart(b,c),d.removeAllRanges(),d.addRange(a)}else d.extend&&d.extend(b,c);a.domObserver.setCurSelection();let{state:e}=a;setTimeout(()=>{a.state==e&&gN(a)},50)}function g3(a,b){let c=a.state.doc.resolve(b);if(!(f2||f7)&&c.parent.inlineContent){let d=a.coordsAtPos(b);if(b>c.start()){let c=a.coordsAtPos(b-1),e=(c.top+c.bottom)/2;if(e>d.top&&e<d.bottom&&Math.abs(c.left-d.left)>1)return c.left<d.left?"ltr":"rtl"}if(b<c.end()){let c=a.coordsAtPos(b+1),e=(c.top+c.bottom)/2;if(e>d.top&&e<d.bottom&&Math.abs(c.left-d.left)>1)return c.left>d.left?"ltr":"rtl"}}return"rtl"==getComputedStyle(a.dom).direction?"rtl":"ltr"}function g4(a,b,c){let d=a.state.selection;if(d instanceof fq&&!d.empty||c.indexOf("s")>-1||f6&&c.indexOf("m")>-1)return!1;let{$from:e,$to:f}=d;if(!e.parent.inlineContent||a.endOfTextblock(b<0?"up":"down")){let c=gX(a.state,b);if(c&&c instanceof fs)return gY(a,c)}if(!e.parent.inlineContent){let c=b<0?e:f,g=d instanceof fu?fm.near(c,b):fm.findFrom(c,b);return!!g&&gY(a,g)}return!1}function g5(a,b){if(!(a.state.selection instanceof fq))return!0;let{$head:c,$anchor:d,empty:e}=a.state.selection;if(!c.sameParent(d))return!0;if(!e)return!1;if(a.endOfTextblock(b>0?"forward":"backward"))return!0;let f=!c.textOffset&&(b<0?c.nodeBefore:c.nodeAfter);if(f&&!f.isText){let d=a.state.tr;return b<0?d.delete(c.pos-f.nodeSize,c.pos):d.delete(c.pos,c.pos+f.nodeSize),a.dispatch(d),!0}return!1}function g6(a,b,c){a.domObserver.stop(),b.contentEditable=c,a.domObserver.start()}function g7(a,b){a.someProp("transformCopied",c=>{b=c(b,a)});let c=[],{content:d,openStart:e,openEnd:f}=b;for(;e>1&&f>1&&1==d.childCount&&1==d.firstChild.childCount;){e--,f--;let a=d.firstChild;c.push(a.type.name,a.attrs!=a.type.defaultAttrs?a.attrs:null),d=a.content}let g=a.someProp("clipboardSerializer")||eH.fromSchema(a.state.schema),h=hf(),i=h.createElement("div");i.appendChild(g.serializeFragment(d,{document:h}));let j=i.firstChild,k,l=0;for(;j&&1==j.nodeType&&(k=hd[j.nodeName.toLowerCase()]);){for(let a=k.length-1;a>=0;a--){let b=h.createElement(k[a]);for(;i.firstChild;)b.appendChild(i.firstChild);i.appendChild(b),l++}j=i.firstChild}return j&&1==j.nodeType&&j.setAttribute("data-pm-slice",`${e} ${f}${l?` -${l}`:""} ${JSON.stringify(c)}`),{dom:i,text:a.someProp("clipboardTextSerializer",c=>c(b,a))||b.content.textBetween(0,b.content.size,"\n\n"),slice:b}}function g8(a,b,c,d,e){let f,g,h=e.parent.type.spec.code;if(!c&&!b)return null;let i=!!b&&(d||h||!c);if(i){if(a.someProp("transformPastedText",c=>{b=c(b,h||d,a)}),h)return g=new d4(d$.from(a.state.schema.text(b.replace(/\r\n?/g,"\n"))),0,0),a.someProp("transformPasted",b=>{g=b(g,a,!0)}),g;let c=a.someProp("clipboardTextParser",c=>c(b,e,d,a));if(c)g=c;else{let c=e.marks(),{schema:d}=a.state,g=eH.fromSchema(d);f=document.createElement("div"),b.split(/(?:\r\n?|\n)+/).forEach(a=>{let b=f.appendChild(document.createElement("p"));a&&b.appendChild(g.serializeNode(d.text(a,c)))})}}else a.someProp("transformPastedHTML",b=>{c=b(c,a)}),f=function(a){var b;let c,d=/^(\s*<meta [^>]*>)*/.exec(a);d&&(a=a.slice(d[0].length));let e=hf().createElement("div"),f=/<([a-z][^>\s]+)/i.exec(a),g;if((g=f&&hd[f[1].toLowerCase()])&&(a=g.map(a=>"<"+a+">").join("")+a+g.map(a=>"</"+a+">").reverse().join("")),e.innerHTML=(b=a,(c=window.trustedTypes)?(hg||(hg=c.defaultPolicy||c.createPolicy("ProseMirrorClipboard",{createHTML:a=>a})),hg.createHTML(b)):b),g)for(let a=0;a<g.length;a++)e=e.querySelector(g[a])||e;return e}(c),f9&&function(a){let b=a.querySelectorAll(f2?"span:not([class]):not([style])":"span.Apple-converted-space");for(let c=0;c<b.length;c++){let d=b[c];1==d.childNodes.length&&" "==d.textContent&&d.parentNode&&d.parentNode.replaceChild(a.ownerDocument.createTextNode(" "),d)}}(f);let j=f&&f.querySelector("[data-pm-slice]"),k=j&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(j.getAttribute("data-pm-slice")||"");if(k&&k[3])for(let a=+k[3];a>0;a--){let a=f.firstChild;for(;a&&1!=a.nodeType;)a=a.nextSibling;if(!a)break;f=a}if(g||(g=(a.someProp("clipboardParser")||a.someProp("domParser")||ey.fromSchema(a.state.schema)).parseSlice(f,{preserveWhitespace:!!(i||k),context:e,ruleFromNode:a=>"BR"!=a.nodeName||a.nextSibling||!a.parentNode||g9.test(a.parentNode.nodeName)?null:{ignore:!0}})),k)g=function(a,b){if(!a.size)return a;let c=a.content.firstChild.type.schema,d;try{d=JSON.parse(b)}catch(b){return a}let{content:e,openStart:f,openEnd:g}=a;for(let a=d.length-2;a>=0;a-=2){let b=c.nodes[d[a]];if(!b||b.hasRequiredAttrs())break;e=d$.from(b.create(d[a+1],e)),f++,g++}return new d4(e,f,g)}(hc(g,+k[1],+k[2]),k[4]);else if((g=d4.maxOpen(function(a,b){if(a.childCount<2)return a;for(let c=b.depth;c>=0;c--){let d=b.node(c).contentMatchAt(b.index(c)),e,f=[];if(a.forEach(a=>{if(!f)return;let b=d.findWrapping(a.type),c;if(!b)return f=null;if(c=f.length&&e.length&&function a(b,c,d,e,f){if(f<b.length&&f<c.length&&b[f]==c[f]){let g=a(b,c,d,e.lastChild,f+1);if(g)return e.copy(e.content.replaceChild(e.childCount-1,g));if(e.contentMatchAt(e.childCount).matchType(f==b.length-1?d.type:b[f+1]))return e.copy(e.content.append(d$.from(ha(d,b,f+1))))}}(b,e,a,f[f.length-1],0))f[f.length-1]=c;else{f.length&&(f[f.length-1]=function a(b,c){if(0==c)return b;let d=b.content.replaceChild(b.childCount-1,a(b.lastChild,c-1)),e=b.contentMatchAt(b.childCount).fillBefore(d$.empty,!0);return b.copy(d.append(e))}(f[f.length-1],e.length));let c=ha(a,b);f.push(c),d=d.matchType(c.type),e=b}}),f)return d$.from(f)}return a}(g.content,e),!0)).openStart||g.openEnd){let a=0,b=0;for(let b=g.content.firstChild;a<g.openStart&&!b.type.spec.isolating;a++,b=b.firstChild);for(let a=g.content.lastChild;b<g.openEnd&&!a.type.spec.isolating;b++,a=a.lastChild);g=hc(g,a,b)}return a.someProp("transformPasted",b=>{g=b(g,a,i)}),g}let g9=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function ha(a,b,c=0){for(let d=b.length-1;d>=c;d--)a=b[d].create(null,d$.from(a));return a}function hb(a,b,c,d,e,f){let g=b<0?a.firstChild:a.lastChild,h=g.content;return a.childCount>1&&(f=0),e<d-1&&(h=hb(h,b,c,d,e+1,f)),e>=c&&(h=b<0?g.contentMatchAt(0).fillBefore(h,f<=e).append(h):h.append(g.contentMatchAt(g.childCount).fillBefore(d$.empty,!0))),a.replaceChild(b<0?0:a.childCount-1,g.copy(h))}function hc(a,b,c){return b<a.openStart&&(a=new d4(hb(a.content,-1,b,a.openStart,0,a.openEnd),b,a.openEnd)),c<a.openEnd&&(a=new d4(hb(a.content,1,c,a.openEnd,0,0),a.openStart,c)),a}let hd={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]},he=null;function hf(){return he||(he=document.implementation.createHTMLDocument("title"))}let hg=null,hh={},hi={},hj={touchstart:!0,touchmove:!0};class hk{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function hl(a,b){a.input.lastSelectionOrigin=b,a.input.lastSelectionTime=Date.now()}function hm(a){a.someProp("handleDOMEvents",b=>{for(let c in b)a.input.eventHandlers[c]||a.dom.addEventListener(c,a.input.eventHandlers[c]=b=>hn(a,b))})}function hn(a,b){return a.someProp("handleDOMEvents",c=>{let d=c[b.type];return!!d&&(d(a,b)||b.defaultPrevented)})}function ho(a){return{left:a.clientX,top:a.clientY}}function hp(a,b,c,d,e){if(-1==d)return!1;let f=a.state.doc.resolve(d);for(let d=f.depth+1;d>0;d--)if(a.someProp(b,b=>d>f.depth?b(a,c,f.nodeAfter,f.before(d),e,!0):b(a,c,f.node(d),f.before(d),e,!1)))return!0;return!1}function hq(a,b,c){if(a.focused||a.focus(),a.state.selection.eq(b))return;let d=a.state.tr.setSelection(b);"pointer"==c&&d.setMeta("pointer",!0),a.dispatch(d)}hi.keydown=(a,b)=>{if((a.input.shiftKey=16==b.keyCode||b.shiftKey,!ht(a,b))&&(a.input.lastKeyCode=b.keyCode,a.input.lastKeyCodeTime=Date.now(),!f8||!f2||13!=b.keyCode))if(229!=b.keyCode&&a.domObserver.forceFlush(),!f5||13!=b.keyCode||b.ctrlKey||b.altKey||b.metaKey)a.someProp("handleKeyDown",c=>c(a,b))||function(a,b){let c,d=b.keyCode,e=(c="",b.ctrlKey&&(c+="c"),b.metaKey&&(c+="m"),b.altKey&&(c+="a"),b.shiftKey&&(c+="s"),c);if(8==d||f6&&72==d&&"c"==e)return g5(a,-1)||g0(a,-1);if(46==d&&!b.shiftKey||f6&&68==d&&"c"==e)return g5(a,1)||g0(a,1);if(13==d||27==d)return!0;if(37==d||f6&&66==d&&"c"==e){let b=37==d?"ltr"==g3(a,a.state.selection.from)?-1:1:-1;return gZ(a,b,e)||g0(a,b)}if(39==d||f6&&70==d&&"c"==e){let b=39==d?"ltr"==g3(a,a.state.selection.from)?1:-1:1;return gZ(a,b,e)||g0(a,b)}else if(38==d||f6&&80==d&&"c"==e)return g4(a,-1,e)||g0(a,-1);else if(40==d||f6&&78==d&&"c"==e)return function(a){if(!f4||a.state.selection.$head.parentOffset>0)return!1;let{focusNode:b,focusOffset:c}=a.domSelectionRange();if(b&&1==b.nodeType&&0==c&&b.firstChild&&"false"==b.firstChild.contentEditable){let c=b.firstChild;g6(a,c,"true"),setTimeout(()=>g6(a,c,"false"),20)}return!1}(a)||g4(a,1,e)||g0(a,1);else if(e==(f6?"m":"c")&&(66==d||73==d||89==d||90==d))return!0;return!1}(a,b)?b.preventDefault():hl(a,"key");else{let b=Date.now();a.input.lastIOSEnter=b,a.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{a.input.lastIOSEnter==b&&(a.someProp("handleKeyDown",b=>b(a,fT(13,"Enter"))),a.input.lastIOSEnter=0)},200)}},hi.keyup=(a,b)=>{16==b.keyCode&&(a.input.shiftKey=!1)},hi.keypress=(a,b)=>{if(ht(a,b)||!b.charCode||b.ctrlKey&&!b.altKey||f6&&b.metaKey)return;if(a.someProp("handleKeyPress",c=>c(a,b)))return void b.preventDefault();let c=a.state.selection;if(!(c instanceof fq)||!c.$from.sameParent(c.$to)){let d=String.fromCharCode(b.charCode),e=()=>a.state.tr.insertText(d).scrollIntoView();/[\r\n]/.test(d)||a.someProp("handleTextInput",b=>b(a,c.$from.pos,c.$to.pos,d,e))||a.dispatch(e()),b.preventDefault()}};let hr=f6?"metaKey":"ctrlKey";hh.mousedown=(a,b)=>{var c;let d,e;a.input.shiftKey=b.shiftKey;let f=hx(a),g=Date.now(),h="singleClick";g-a.input.lastClick.time<500&&(d=(c=a.input.lastClick).x-b.clientX)*d+(e=c.y-b.clientY)*e<100&&!b[hr]&&a.input.lastClick.button==b.button&&("singleClick"==a.input.lastClick.type?h="doubleClick":"doubleClick"==a.input.lastClick.type&&(h="tripleClick")),a.input.lastClick={time:g,x:b.clientX,y:b.clientY,type:h,button:b.button};let i=a.posAtCoords(ho(b));i&&("singleClick"==h?(a.input.mouseDown&&a.input.mouseDown.done(),a.input.mouseDown=new hs(a,i,b,!!f)):("doubleClick"==h?function(a,b,c,d){return hp(a,"handleDoubleClickOn",b,c,d)||a.someProp("handleDoubleClick",c=>c(a,b,d))}:function(a,b,c,d){return hp(a,"handleTripleClickOn",b,c,d)||a.someProp("handleTripleClick",c=>c(a,b,d))||function(a,b,c){if(0!=c.button)return!1;let d=a.state.doc;if(-1==b)return!!d.inlineContent&&(hq(a,fq.create(d,0,d.content.size),"pointer"),!0);let e=d.resolve(b);for(let b=e.depth+1;b>0;b--){let c=b>e.depth?e.nodeAfter:e.node(b),f=e.before(b);if(c.inlineContent)hq(a,fq.create(d,f+1,f+1+c.content.size),"pointer");else{if(!fs.isSelectable(c))continue;hq(a,fs.create(d,f),"pointer")}return!0}}(a,c,d)})(a,i.pos,i.inside,b)?b.preventDefault():hl(a,"pointer"))};class hs{constructor(a,b,c,d){let e,f;if(this.view=a,this.pos=b,this.event=c,this.flushed=d,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=a.state.doc,this.selectNode=!!c[hr],this.allowDefault=c.shiftKey,b.inside>-1)e=a.state.doc.nodeAt(b.inside),f=b.inside;else{let c=a.state.doc.resolve(b.pos);e=c.parent,f=c.depth?c.before():0}const g=d?null:c.target,h=g?a.docView.nearestDesc(g,!0):null;this.target=h&&1==h.nodeDOM.nodeType?h.nodeDOM:null;let{selection:i}=a.state;0==c.button&&(e.type.spec.draggable&&!1!==e.type.spec.selectable||i instanceof fs&&i.from<=f&&i.to>f)&&(this.mightDrag={node:e,pos:f,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&f0&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),a.root.addEventListener("mouseup",this.up=this.up.bind(this)),a.root.addEventListener("mousemove",this.move=this.move.bind(this)),hl(a,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>gN(this.view)),this.view.input.mouseDown=null}up(a){if(this.done(),!this.view.dom.contains(a.target))return;let b=this.pos;if(this.view.state.doc!=this.startDoc&&(b=this.view.posAtCoords(ho(a))),this.updateAllowDefault(a),this.allowDefault||!b)hl(this.view,"pointer");else{var c,d,e,f;(c=this.view,d=b.pos,e=b.inside,f=this.selectNode,hp(c,"handleClickOn",d,e,a)||c.someProp("handleClick",b=>b(c,d,a))||(f?function(a,b){if(-1==b)return!1;let c=a.state.selection,d,e;c instanceof fs&&(d=c.node);let f=a.state.doc.resolve(b);for(let a=f.depth+1;a>0;a--){let b=a>f.depth?f.nodeAfter:f.node(a);if(fs.isSelectable(b)){e=d&&c.$from.depth>0&&a>=c.$from.depth&&f.before(c.$from.depth+1)==c.$from.pos?f.before(c.$from.depth):f.before(a);break}}return null!=e&&(hq(a,fs.create(a.state.doc,e),"pointer"),!0)}(c,e):function(a,b){if(-1==b)return!1;let c=a.state.doc.resolve(b),d=c.nodeAfter;return!!(d&&d.isAtom&&fs.isSelectable(d))&&(hq(a,new fs(c),"pointer"),!0)}(c,e)))?a.preventDefault():0==a.button&&(this.flushed||f4&&this.mightDrag&&!this.mightDrag.node.isAtom||f2&&!this.view.state.selection.visible&&2>=Math.min(Math.abs(b.pos-this.view.state.selection.from),Math.abs(b.pos-this.view.state.selection.to)))?(hq(this.view,fm.near(this.view.state.doc.resolve(b.pos)),"pointer"),a.preventDefault()):hl(this.view,"pointer")}}move(a){this.updateAllowDefault(a),hl(this.view,"pointer"),0==a.buttons&&this.done()}updateAllowDefault(a){!this.allowDefault&&(Math.abs(this.event.x-a.clientX)>4||Math.abs(this.event.y-a.clientY)>4)&&(this.allowDefault=!0)}}function ht(a,b){return!!a.composing||!!(f4&&500>Math.abs(b.timeStamp-a.input.compositionEndedAt))&&(a.input.compositionEndedAt=-2e8,!0)}hh.touchstart=a=>{a.input.lastTouch=Date.now(),hx(a),hl(a,"pointer")},hh.touchmove=a=>{a.input.lastTouch=Date.now(),hl(a,"pointer")},hh.contextmenu=a=>hx(a);let hu=f8?5e3:-1;function hv(a,b){clearTimeout(a.input.composingTimeout),b>-1&&(a.input.composingTimeout=setTimeout(()=>hx(a),b))}function hw(a){let b;for(a.composing&&(a.input.composing=!1,a.input.compositionEndedAt=((b=document.createEvent("Event")).initEvent("event",!0,!0),b.timeStamp));a.input.compositionNodes.length>0;)a.input.compositionNodes.pop().markParentsDirty()}function hx(a,b=!1){if(!f8||!(a.domObserver.flushingSoon>=0)){if(a.domObserver.forceFlush(),hw(a),b||a.docView&&a.docView.dirty){let c=gL(a),d=a.state.selection;return c&&!c.eq(d)?a.dispatch(a.state.tr.setSelection(c)):(a.markCursor||b)&&!d.$from.node(d.$from.sharedDepth(d.to)).inlineContent?a.dispatch(a.state.tr.deleteSelection()):a.updateState(a.state),!0}return!1}}hi.compositionstart=hi.compositionupdate=a=>{if(!a.composing){a.domObserver.flush();let{state:b}=a,c=b.selection.$to;if(b.selection instanceof fq&&(b.storedMarks||!c.textOffset&&c.parentOffset&&c.nodeBefore.marks.some(a=>!1===a.type.spec.inclusive)||f2&&f7&&function(a){let{focusNode:b,focusOffset:c}=a.domSelectionRange();if(!b||1!=b.nodeType||c>=b.childNodes.length)return!1;let d=b.childNodes[c];return 1==d.nodeType&&"false"==d.contentEditable}(a)))a.markCursor=a.state.storedMarks||c.marks(),hx(a,!0),a.markCursor=null;else if(hx(a,!b.selection.empty),f0&&b.selection.empty&&c.parentOffset&&!c.textOffset&&c.nodeBefore.marks.length){let b=a.domSelectionRange();for(let c=b.focusNode,d=b.focusOffset;c&&1==c.nodeType&&0!=d;){let b=d<0?c.lastChild:c.childNodes[d-1];if(!b)break;if(3==b.nodeType){let c=a.domSelection();c&&c.collapse(b,b.nodeValue.length);break}c=b,d=-1}}a.input.composing=!0}hv(a,hu)},hi.compositionend=(a,b)=>{a.composing&&(a.input.composing=!1,a.input.compositionEndedAt=b.timeStamp,a.input.compositionPendingChanges=a.domObserver.pendingRecords().length?a.input.compositionID:0,a.input.compositionNode=null,a.input.badSafariComposition?a.domObserver.forceFlush():a.input.compositionPendingChanges&&Promise.resolve().then(()=>a.domObserver.flush()),a.input.compositionID++,hv(a,20))};let hy=f$&&f_<15||f5&&ga<604;function hz(a,b,c,d,e){let f=g8(a,b,c,d,a.state.selection.$from);if(a.someProp("handlePaste",b=>b(a,e,f||d4.empty)))return!0;if(!f)return!1;let g=0==f.openStart&&0==f.openEnd&&1==f.content.childCount?f.content.firstChild:null,h=g?a.state.tr.replaceSelectionWith(g,d):a.state.tr.replaceSelection(f);return a.dispatch(h.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function hA(a){let b=a.getData("text/plain")||a.getData("Text");if(b)return b;let c=a.getData("text/uri-list");return c?c.replace(/\r?\n/g," "):""}hh.copy=hi.cut=(a,b)=>{let c=a.state.selection,d="cut"==b.type;if(c.empty)return;let e=hy?null:b.clipboardData,{dom:f,text:g}=g7(a,c.content());e?(b.preventDefault(),e.clearData(),e.setData("text/html",f.innerHTML),e.setData("text/plain",g)):function(a,b){if(!a.dom.parentNode)return;let c=a.dom.parentNode.appendChild(document.createElement("div"));c.appendChild(b),c.style.cssText="position: fixed; left: -10000px; top: 10px";let d=getSelection(),e=document.createRange();e.selectNodeContents(b),a.dom.blur(),d.removeAllRanges(),d.addRange(e),setTimeout(()=>{c.parentNode&&c.parentNode.removeChild(c),a.focus()},50)}(a,f),d&&a.dispatch(a.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))},hi.paste=(a,b)=>{if(a.composing&&!f8)return;let c=hy?null:b.clipboardData,d=a.input.shiftKey&&45!=a.input.lastKeyCode;c&&hz(a,hA(c),c.getData("text/html"),d,b)?b.preventDefault():function(a,b){if(!a.dom.parentNode)return;let c=a.input.shiftKey||a.state.selection.$from.parent.type.spec.code,d=a.dom.parentNode.appendChild(document.createElement(c?"textarea":"div"));c||(d.contentEditable="true"),d.style.cssText="position: fixed; left: -10000px; top: 10px",d.focus();let e=a.input.shiftKey&&45!=a.input.lastKeyCode;setTimeout(()=>{a.focus(),d.parentNode&&d.parentNode.removeChild(d),c?hz(a,d.value,null,e,b):hz(a,d.textContent,d.innerHTML,e,b)},50)}(a,b)};class hB{constructor(a,b,c){this.slice=a,this.move=b,this.node=c}}let hC=f6?"altKey":"ctrlKey";function hD(a,b){let c;return a.someProp("dragCopies",a=>{c=c||a(b)}),null!=c?!c:!b[hC]}for(let a in hh.dragstart=(a,b)=>{let c,d=a.input.mouseDown;if(d&&d.done(),!b.dataTransfer)return;let e=a.state.selection,f=e.empty?null:a.posAtCoords(ho(b));if(f&&f.pos>=e.from&&f.pos<=(e instanceof fs?e.to-1:e.to));else if(d&&d.mightDrag)c=fs.create(a.state.doc,d.mightDrag.pos);else if(b.target&&1==b.target.nodeType){let d=a.docView.nearestDesc(b.target,!0);d&&d.node.type.spec.draggable&&d!=a.docView&&(c=fs.create(a.state.doc,d.posBefore))}let g=(c||a.state.selection).content(),{dom:h,text:i,slice:j}=g7(a,g);b.dataTransfer.files.length&&f2&&!(f3>120)||b.dataTransfer.clearData(),b.dataTransfer.setData(hy?"Text":"text/html",h.innerHTML),b.dataTransfer.effectAllowed="copyMove",hy||b.dataTransfer.setData("text/plain",i),a.dragging=new hB(j,hD(a,b),c)},hh.dragend=a=>{let b=a.dragging;window.setTimeout(()=>{a.dragging==b&&(a.dragging=null)},50)},hi.dragover=hi.dragenter=(a,b)=>b.preventDefault(),hi.drop=(a,b)=>{try{!function(a,b,c){if(!b.dataTransfer)return;let d=a.posAtCoords(ho(b));if(!d)return;let e=a.state.doc.resolve(d.pos),f=c&&c.slice;f?a.someProp("transformPasted",b=>{f=b(f,a,!1)}):f=g8(a,hA(b.dataTransfer),hy?null:b.dataTransfer.getData("text/html"),!1,e);let g=!!(c&&hD(a,b));if(a.someProp("handleDrop",c=>c(a,b,f||d4.empty,g)))return b.preventDefault();if(!f)return;b.preventDefault();let h=f?e8(a.state.doc,e.pos,f):e.pos;null==h&&(h=e.pos);let i=a.state.tr;if(g){let{node:a}=c;a?a.replace(i):i.deleteSelection()}let j=i.mapping.map(h),k=0==f.openStart&&0==f.openEnd&&1==f.content.childCount,l=i.doc;if(k?i.replaceRangeWith(j,j,f.content.firstChild):i.replaceRange(j,j,f),i.doc.eq(l))return;let m=i.doc.resolve(j);if(k&&fs.isSelectable(f.content.firstChild)&&m.nodeAfter&&m.nodeAfter.sameMarkup(f.content.firstChild))i.setSelection(new fs(m));else{let b=i.mapping.map(h);i.mapping.maps[i.mapping.maps.length-1].forEach((a,c,d,e)=>b=e),i.setSelection(gU(a,m,i.doc.resolve(b)))}a.focus(),a.dispatch(i.setMeta("uiEvent","drop"))}(a,b,a.dragging)}finally{a.dragging=null}},hh.focus=a=>{a.input.lastFocus=Date.now(),a.focused||(a.domObserver.stop(),a.dom.classList.add("ProseMirror-focused"),a.domObserver.start(),a.focused=!0,setTimeout(()=>{a.docView&&a.hasFocus()&&!a.domObserver.currentSelection.eq(a.domSelectionRange())&&gN(a)},20))},hh.blur=(a,b)=>{a.focused&&(a.domObserver.stop(),a.dom.classList.remove("ProseMirror-focused"),a.domObserver.start(),b.relatedTarget&&a.dom.contains(b.relatedTarget)&&a.domObserver.currentSelection.clear(),a.focused=!1)},hh.beforeinput=(a,b)=>{if(f2&&f8&&"deleteContentBackward"==b.inputType){a.domObserver.flushSoon();let{domChangeCount:b}=a.input;setTimeout(()=>{if(a.input.domChangeCount!=b||(a.dom.blur(),a.focus(),a.someProp("handleKeyDown",b=>b(a,fT(8,"Backspace")))))return;let{$cursor:c}=a.state.selection;c&&c.pos>0&&a.dispatch(a.state.tr.delete(c.pos-1,c.pos).scrollIntoView())},50)}},hi)hh[a]=hi[a];function hE(a,b){if(a==b)return!0;for(let c in a)if(a[c]!==b[c])return!1;for(let c in b)if(!(c in a))return!1;return!0}class hF{constructor(a,b){this.toDOM=a,this.spec=b||hK,this.side=this.spec.side||0}map(a,b,c,d){let{pos:e,deleted:f}=a.mapResult(b.from+d,this.side<0?-1:1);return f?null:new hI(e-c,e-c,this)}valid(){return!0}eq(a){return this==a||a instanceof hF&&(this.spec.key&&this.spec.key==a.spec.key||this.toDOM==a.toDOM&&hE(this.spec,a.spec))}destroy(a){this.spec.destroy&&this.spec.destroy(a)}}class hG{constructor(a,b){this.attrs=a,this.spec=b||hK}map(a,b,c,d){let e=a.map(b.from+d,this.spec.inclusiveStart?-1:1)-c,f=a.map(b.to+d,this.spec.inclusiveEnd?1:-1)-c;return e>=f?null:new hI(e,f,this)}valid(a,b){return b.from<b.to}eq(a){return this==a||a instanceof hG&&hE(this.attrs,a.attrs)&&hE(this.spec,a.spec)}static is(a){return a.type instanceof hG}destroy(){}}class hH{constructor(a,b){this.attrs=a,this.spec=b||hK}map(a,b,c,d){let e=a.mapResult(b.from+d,1);if(e.deleted)return null;let f=a.mapResult(b.to+d,-1);return f.deleted||f.pos<=e.pos?null:new hI(e.pos-c,f.pos-c,this)}valid(a,b){let{index:c,offset:d}=a.content.findIndex(b.from),e;return d==b.from&&!(e=a.child(c)).isText&&d+e.nodeSize==b.to}eq(a){return this==a||a instanceof hH&&hE(this.attrs,a.attrs)&&hE(this.spec,a.spec)}destroy(){}}class hI{constructor(a,b,c){this.from=a,this.to=b,this.type=c}copy(a,b){return new hI(a,b,this.type)}eq(a,b=0){return this.type.eq(a.type)&&this.from+b==a.from&&this.to+b==a.to}map(a,b,c){return this.type.map(a,this,b,c)}static widget(a,b,c){return new hI(a,a,new hF(b,c))}static inline(a,b,c,d){return new hI(a,b,new hG(c,d))}static node(a,b,c,d){return new hI(a,b,new hH(c,d))}get spec(){return this.type.spec}get inline(){return this.type instanceof hG}get widget(){return this.type instanceof hF}}let hJ=[],hK={};class hL{constructor(a,b){this.local=a.length?a:hJ,this.children=b.length?b:hJ}static create(a,b){return b.length?hR(b,a,0,hK):hM}find(a,b,c){let d=[];return this.findInner(null==a?0:a,null==b?1e9:b,d,0,c),d}findInner(a,b,c,d,e){for(let f=0;f<this.local.length;f++){let g=this.local[f];g.from<=b&&g.to>=a&&(!e||e(g.spec))&&c.push(g.copy(g.from+d,g.to+d))}for(let f=0;f<this.children.length;f+=3)if(this.children[f]<b&&this.children[f+1]>a){let g=this.children[f]+1;this.children[f+2].findInner(a-g,b-g,c,d+g,e)}}map(a,b,c){return this==hM||0==a.maps.length?this:this.mapInner(a,b,0,0,c||hK)}mapInner(a,b,c,d,e){let f;for(let g=0;g<this.local.length;g++){let h=this.local[g].map(a,c,d);h&&h.type.valid(b,h)?(f||(f=[])).push(h):e.onRemove&&e.onRemove(this.local[g].spec)}return this.children.length?function(a,b,c,d,e,f,g){let h=a.slice();for(let a=0,b=f;a<c.maps.length;a++){let d=0;c.maps[a].forEach((a,c,e,f)=>{let g=f-e-(c-a);for(let e=0;e<h.length;e+=3){let f=h[e+1];if(f<0||a>f+b-d)continue;let i=h[e]+b-d;c>=i?h[e+1]=a<=i?-2:-1:a>=b&&g&&(h[e]+=g,h[e+1]+=g)}d+=g}),b=c.maps[a].map(b,-1)}let i=!1;for(let b=0;b<h.length;b+=3)if(h[b+1]<0){if(-2==h[b+1]){i=!0,h[b+1]=-1;continue}let j=c.map(a[b]+f),k=j-e;if(k<0||k>=d.content.size){i=!0;continue}let l=c.map(a[b+1]+f,-1)-e,{index:m,offset:n}=d.content.findIndex(k),o=d.maybeChild(m);if(o&&n==k&&n+o.nodeSize==l){let d=h[b+2].mapInner(c,o,j+1,a[b]+f+1,g);d!=hM?(h[b]=k,h[b+1]=l,h[b+2]=d):(h[b+1]=-2,i=!0)}else i=!0}if(i){let i=hR(function(a,b,c,d,e,f,g){for(let h=0;h<a.length;h+=3)-1==a[h+1]&&function a(b,f){for(let a=0;a<b.local.length;a++){let h=b.local[a].map(d,e,f);h?c.push(h):g.onRemove&&g.onRemove(b.local[a].spec)}for(let c=0;c<b.children.length;c+=3)a(b.children[c+2],b.children[c]+f+1)}(a[h+2],b[h]+f+1);return c}(h,a,b,c,e,f,g),d,0,g);b=i.local;for(let a=0;a<h.length;a+=3)h[a+1]<0&&(h.splice(a,3),a-=3);for(let a=0,b=0;a<i.children.length;a+=3){let c=i.children[a];for(;b<h.length&&h[b]<c;)b+=3;h.splice(b,0,i.children[a],i.children[a+1],i.children[a+2])}}return new hL(b.sort(hS),h)}(this.children,f||[],a,b,c,d,e):f?new hL(f.sort(hS),hJ):hM}add(a,b){return b.length?this==hM?hL.create(a,b):this.addInner(a,b,0):this}addInner(a,b,c){let d,e=0;a.forEach((a,f)=>{let g=f+c,h;if(h=hP(b,a,g)){for(d||(d=this.children.slice());e<d.length&&d[e]<f;)e+=3;d[e]==f?d[e+2]=d[e+2].addInner(a,h,g+1):d.splice(e,0,f,f+a.nodeSize,hR(h,a,g+1,hK)),e+=3}});let f=hO(e?hQ(b):b,-c);for(let b=0;b<f.length;b++)f[b].type.valid(a,f[b])||f.splice(b--,1);return new hL(f.length?this.local.concat(f).sort(hS):this.local,d||this.children)}remove(a){return 0==a.length||this==hM?this:this.removeInner(a,0)}removeInner(a,b){let c=this.children,d=this.local;for(let d=0;d<c.length;d+=3){let e,f=c[d]+b,g=c[d+1]+b;for(let b=0,c;b<a.length;b++)(c=a[b])&&c.from>f&&c.to<g&&(a[b]=null,(e||(e=[])).push(c));if(!e)continue;c==this.children&&(c=this.children.slice());let h=c[d+2].removeInner(e,f+1);h!=hM?c[d+2]=h:(c.splice(d,3),d-=3)}if(d.length){for(let c=0,e;c<a.length;c++)if(e=a[c])for(let a=0;a<d.length;a++)d[a].eq(e,b)&&(d==this.local&&(d=this.local.slice()),d.splice(a--,1))}return c==this.children&&d==this.local?this:d.length||c.length?new hL(d,c):hM}forChild(a,b){let c,d;if(this==hM)return this;if(b.isLeaf)return hL.empty;for(let b=0;b<this.children.length;b+=3)if(this.children[b]>=a){this.children[b]==a&&(c=this.children[b+2]);break}let e=a+1,f=e+b.content.size;for(let a=0;a<this.local.length;a++){let b=this.local[a];if(b.from<f&&b.to>e&&b.type instanceof hG){let a=Math.max(e,b.from)-e,c=Math.min(f,b.to)-e;a<c&&(d||(d=[])).push(b.copy(a,c))}}if(d){let a=new hL(d.sort(hS),hJ);return c?new hN([a,c]):a}return c||hM}eq(a){if(this==a)return!0;if(!(a instanceof hL)||this.local.length!=a.local.length||this.children.length!=a.children.length)return!1;for(let b=0;b<this.local.length;b++)if(!this.local[b].eq(a.local[b]))return!1;for(let b=0;b<this.children.length;b+=3)if(this.children[b]!=a.children[b]||this.children[b+1]!=a.children[b+1]||!this.children[b+2].eq(a.children[b+2]))return!1;return!0}locals(a){return hT(this.localsInner(a))}localsInner(a){if(this==hM)return hJ;if(a.inlineContent||!this.local.some(hG.is))return this.local;let b=[];for(let a=0;a<this.local.length;a++)this.local[a].type instanceof hG||b.push(this.local[a]);return b}forEachSet(a){a(this)}}hL.empty=new hL([],[]),hL.removeOverlap=hT;let hM=hL.empty;class hN{constructor(a){this.members=a}map(a,b){let c=this.members.map(c=>c.map(a,b,hK));return hN.from(c)}forChild(a,b){if(b.isLeaf)return hL.empty;let c=[];for(let d=0;d<this.members.length;d++){let e=this.members[d].forChild(a,b);e!=hM&&(e instanceof hN?c=c.concat(e.members):c.push(e))}return hN.from(c)}eq(a){if(!(a instanceof hN)||a.members.length!=this.members.length)return!1;for(let b=0;b<this.members.length;b++)if(!this.members[b].eq(a.members[b]))return!1;return!0}locals(a){let b,c=!0;for(let d=0;d<this.members.length;d++){let e=this.members[d].localsInner(a);if(e.length)if(b){c&&(b=b.slice(),c=!1);for(let a=0;a<e.length;a++)b.push(e[a])}else b=e}return b?hT(c?b:b.sort(hS)):hJ}static from(a){switch(a.length){case 0:return hM;case 1:return a[0];default:return new hN(a.every(a=>a instanceof hL)?a:a.reduce((a,b)=>a.concat(b instanceof hL?b:b.members),[]))}}forEachSet(a){for(let b=0;b<this.members.length;b++)this.members[b].forEachSet(a)}}function hO(a,b){if(!b||!a.length)return a;let c=[];for(let d=0;d<a.length;d++){let e=a[d];c.push(new hI(e.from+b,e.to+b,e.type))}return c}function hP(a,b,c){if(b.isLeaf)return null;let d=c+b.nodeSize,e=null;for(let b=0,f;b<a.length;b++)(f=a[b])&&f.from>c&&f.to<d&&((e||(e=[])).push(f),a[b]=null);return e}function hQ(a){let b=[];for(let c=0;c<a.length;c++)null!=a[c]&&b.push(a[c]);return b}function hR(a,b,c,d){let e=[],f=!1;b.forEach((b,g)=>{let h=hP(a,b,g+c);if(h){f=!0;let a=hR(h,b,c+g+1,d);a!=hM&&e.push(g,g+b.nodeSize,a)}});let g=hO(f?hQ(a):a,-c).sort(hS);for(let a=0;a<g.length;a++)g[a].type.valid(b,g[a])||(d.onRemove&&d.onRemove(g[a].spec),g.splice(a--,1));return g.length||e.length?new hL(g,e):hM}function hS(a,b){return a.from-b.from||a.to-b.to}function hT(a){let b=a;for(let c=0;c<b.length-1;c++){let d=b[c];if(d.from!=d.to)for(let e=c+1;e<b.length;e++){let f=b[e];if(f.from==d.from){f.to!=d.to&&(b==a&&(b=a.slice()),b[e]=f.copy(f.from,d.to),hU(b,e+1,f.copy(d.to,f.to)));continue}f.from<d.to&&(b==a&&(b=a.slice()),b[c]=d.copy(d.from,f.from),hU(b,e,d.copy(f.from,d.to)));break}}return b}function hU(a,b,c){for(;b<a.length&&hS(c,a[b])>0;)b++;a.splice(b,0,c)}function hV(a){let b=[];return a.someProp("decorations",c=>{let d=c(a.state);d&&d!=hM&&b.push(d)}),a.cursorWrapper&&b.push(hL.create(a.state.doc,[a.cursorWrapper.deco])),hN.from(b)}let hW={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},hX=f$&&f_<=11;class hY{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(a){this.anchorNode=a.anchorNode,this.anchorOffset=a.anchorOffset,this.focusNode=a.focusNode,this.focusOffset=a.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(a){return a.anchorNode==this.anchorNode&&a.anchorOffset==this.anchorOffset&&a.focusNode==this.focusNode&&a.focusOffset==this.focusOffset}}class hZ{constructor(a,b){this.view=a,this.handleDOMChange=b,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new hY,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(b=>{for(let a=0;a<b.length;a++)this.queue.push(b[a]);f$&&f_<=11&&b.some(a=>"childList"==a.type&&a.removedNodes.length||"characterData"==a.type&&a.oldValue.length>a.target.nodeValue.length)?this.flushSoon():f4&&a.composing&&b.some(a=>"childList"==a.type&&"TR"==a.target.nodeName)?(a.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),hX&&(this.onCharData=a=>{this.queue.push({target:a.target,type:"characterData",oldValue:a.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,hW)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let a=this.observer.takeRecords();if(a.length){for(let b=0;b<a.length;b++)this.queue.push(a[b]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(gV(this.view)){if(this.suppressingSelectionUpdates)return gN(this.view);if(f$&&f_<=11&&!this.view.state.selection.empty){let a=this.view.domSelectionRange();if(a.focusNode&&fN(a.focusNode,a.focusOffset,a.anchorNode,a.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(a){if(!a.focusNode)return!0;let b=new Set,c;for(let c=a.focusNode;c;c=fJ(c))b.add(c);for(let d=a.anchorNode;d;d=fJ(d))if(b.has(d)){c=d;break}let d=c&&this.view.docView.nearestDesc(c);if(d&&d.ignoreMutation({type:"selection",target:3==c.nodeType?c.parentNode:c}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let a of this.observer.takeRecords())this.queue.push(a);return this.queue}flush(){var a;let{view:b}=this;if(!b.docView||this.flushingSoon>-1)return;let c=this.pendingRecords();c.length&&(this.queue=[]);let d=b.domSelectionRange(),e=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(d)&&gV(b)&&!this.ignoreSelectionChange(d),f=-1,g=-1,h=!1,i=[];if(b.editable)for(let a=0;a<c.length;a++){let b=this.registerMutation(c[a],i);b&&(f=f<0?b.from:Math.min(b.from,f),g=g<0?b.to:Math.max(b.to,g),b.typeOver&&(h=!0))}if(i.some(a=>"BR"==a.nodeName)&&(8==b.input.lastKeyCode||46==b.input.lastKeyCode)){for(let a of i)if("BR"==a.nodeName&&a.parentNode){let b=a.nextSibling;for(;b&&1==b.nodeType;){if("false"==b.contentEditable){a.parentNode.removeChild(a);break}b=b.firstChild}}}else if(f0&&i.length){let a=i.filter(a=>"BR"==a.nodeName);if(2==a.length){let[b,c]=a;b.parentNode&&b.parentNode.parentNode==c.parentNode?c.remove():b.remove()}else{let{focusNode:c}=this.currentSelection;for(let d of a){let a=d.parentNode;a&&"LI"==a.nodeName&&(!c||function(a,b){for(let c=b.parentNode;c&&c!=a.dom;c=c.parentNode){let b=a.docView.nearestDesc(c,!0);if(b&&b.node.isBlock)return c}return null}(b,c)!=a)&&d.remove()}}}let j=null;f<0&&e&&b.input.lastFocus>Date.now()-200&&Math.max(b.input.lastTouch,b.input.lastClick.time)<Date.now()-300&&fS(d)&&(j=gL(b))&&j.eq(fm.near(b.state.doc.resolve(0),1))?(b.input.lastFocus=0,gN(b),this.currentSelection.set(d),b.scrollToSelection()):(f>-1||e)&&(f>-1&&(b.docView.markDirty(f,g),a=b,!h$.has(a)&&(h$.set(a,null),-1!==["normal","nowrap","pre-line"].indexOf(getComputedStyle(a.dom).whiteSpace))&&(a.requiresGeckoHackNode=f0,h_||(console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."),h_=!0))),b.input.badSafariComposition&&(b.input.badSafariComposition=!1,function(a,b){var c;let{focusNode:d,focusOffset:e}=a.domSelectionRange();for(let f of b)if((null==(c=f.parentNode)?void 0:c.nodeName)=="TR"){let b=f.nextSibling;for(;b&&"TD"!=b.nodeName&&"TH"!=b.nodeName;)b=b.nextSibling;if(b){let c=b;for(;;){let a=c.firstChild;if(!a||1!=a.nodeType||"false"==a.contentEditable||/^(BR|IMG)$/.test(a.nodeName))break;c=a}c.insertBefore(f,c.firstChild),d==f&&a.domSelection().collapse(f,e)}else f.parentNode.removeChild(f)}}(b,i)),this.handleDOMChange(f,g,h,i),b.docView&&b.docView.dirty?b.updateState(b.state):this.currentSelection.eq(d)||gN(b),this.currentSelection.set(d))}registerMutation(a,b){if(b.indexOf(a.target)>-1)return null;let c=this.view.docView.nearestDesc(a.target);if("attributes"==a.type&&(c==this.view.docView||"contenteditable"==a.attributeName||"style"==a.attributeName&&!a.oldValue&&!a.target.getAttribute("style"))||!c||c.ignoreMutation(a))return null;if("childList"==a.type){for(let c=0;c<a.addedNodes.length;c++){let d=a.addedNodes[c];b.push(d),3==d.nodeType&&(this.lastChangedTextNode=d)}if(c.contentDOM&&c.contentDOM!=c.dom&&!c.contentDOM.contains(a.target))return{from:c.posBefore,to:c.posAfter};let d=a.previousSibling,e=a.nextSibling;if(f$&&f_<=11&&a.addedNodes.length)for(let b=0;b<a.addedNodes.length;b++){let{previousSibling:c,nextSibling:f}=a.addedNodes[b];(!c||0>Array.prototype.indexOf.call(a.addedNodes,c))&&(d=c),(!f||0>Array.prototype.indexOf.call(a.addedNodes,f))&&(e=f)}let f=d&&d.parentNode==a.target?fI(d)+1:0,g=c.localPosFromDOM(a.target,f,-1),h=e&&e.parentNode==a.target?fI(e):a.target.childNodes.length;return{from:g,to:c.localPosFromDOM(a.target,h,1)}}return"attributes"==a.type?{from:c.posAtStart-c.border,to:c.posAtEnd+c.border}:(this.lastChangedTextNode=a.target,{from:c.posAtStart,to:c.posAtEnd,typeOver:a.target.nodeValue==a.oldValue})}}let h$=new WeakMap,h_=!1;function h0(a,b){let c=b.startContainer,d=b.startOffset,e=b.endContainer,f=b.endOffset,g=a.domAtPos(a.state.selection.anchor);return fN(g.node,g.offset,e,f)&&([c,d,e,f]=[e,f,c,d]),{anchorNode:c,anchorOffset:d,focusNode:e,focusOffset:f}}function h1(a){let b=a.pmViewDesc;if(b)return b.parseRule();if("BR"==a.nodeName&&a.parentNode){if(f4&&/^(ul|ol)$/i.test(a.parentNode.nodeName)){let a=document.createElement("div");return a.appendChild(document.createElement("li")),{skip:a}}else if(a.parentNode.lastChild==a||f4&&/^(tr|table)$/i.test(a.parentNode.nodeName))return{ignore:!0}}else if("IMG"==a.nodeName&&a.getAttribute("mark-placeholder"))return{ignore:!0};return null}let h2=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function h3(a,b,c){return Math.max(c.anchor,c.head)>b.content.size?null:gU(a,b.resolve(c.anchor),b.resolve(c.head))}function h4(a,b,c){let d=a.depth,e=b?a.end():a.pos;for(;d>0&&(b||a.indexAfter(d)==a.node(d).childCount);)d--,e++,b=!1;if(c){let b=a.node(d).maybeChild(a.indexAfter(d));for(;b&&!b.isLeaf;)b=b.firstChild,e++}return e}function h5(a){if(2!=a.length)return!1;let b=a.charCodeAt(0),c=a.charCodeAt(1);return b>=56320&&b<=57343&&c>=55296&&c<=56319}class h6{constructor(a,b){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new hk,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=b,this.state=b.state,this.directPlugins=b.plugins||[],this.directPlugins.forEach(ib),this.dispatch=this.dispatch.bind(this),this.dom=a&&a.mount||document.createElement("div"),a&&(a.appendChild?a.appendChild(this.dom):"function"==typeof a?a(this.dom):a.mount&&(this.mounted=!0)),this.editable=h9(this),h8(this),this.nodeViews=ia(this),this.docView=gx(this.state.doc,h7(this),hV(this),this.dom,this),this.domObserver=new hZ(this,(a,b,c,d)=>(function(a,b,c,d,e){let f,g,h,i=a.input.compositionPendingChanges||(a.composing?a.input.compositionID:0);if(a.input.compositionPendingChanges=0,b<0){let b=a.input.lastSelectionTime>Date.now()-50?a.input.lastSelectionOrigin:null,c=gL(a,b);if(c&&!a.state.selection.eq(c)){if(f2&&f8&&13===a.input.lastKeyCode&&Date.now()-100<a.input.lastKeyCodeTime&&a.someProp("handleKeyDown",b=>b(a,fT(13,"Enter"))))return;let d=a.state.tr.setSelection(c);"pointer"==b?d.setMeta("pointer",!0):"key"==b&&d.scrollIntoView(),i&&d.setMeta("composition",i),a.dispatch(d)}return}let j=a.state.doc.resolve(b),k=j.sharedDepth(c);b=j.before(k+1),c=a.state.doc.resolve(c).after(k+1);let l=a.state.selection,m=function(a,b,c){let d,{node:e,fromOffset:f,toOffset:g,from:h,to:i}=a.docView.parseRange(b,c),j=a.domSelectionRange(),k=j.anchorNode;if(k&&a.dom.contains(1==k.nodeType?k:k.parentNode)&&(d=[{node:k,offset:j.anchorOffset}],fS(j)||d.push({node:j.focusNode,offset:j.focusOffset})),f2&&8===a.input.lastKeyCode)for(let a=g;a>f;a--){let b=e.childNodes[a-1],c=b.pmViewDesc;if("BR"==b.nodeName&&!c){g=a;break}if(!c||c.size)break}let l=a.state.doc,m=a.someProp("domParser")||ey.fromSchema(a.state.schema),n=l.resolve(h),o=null,p=m.parse(e,{topNode:n.parent,topMatch:n.parent.contentMatchAt(n.index()),topOpen:!0,from:f,to:g,preserveWhitespace:"pre"!=n.parent.type.whitespace||"full",findPositions:d,ruleFromNode:h1,context:n});if(d&&null!=d[0].pos){let a=d[0].pos,b=d[1]&&d[1].pos;null==b&&(b=a),o={anchor:a+h,head:b+h}}return{doc:p,sel:o,from:h,to:i}}(a,b,c),n=a.state.doc,o=n.slice(m.from,m.to);8===a.input.lastKeyCode&&Date.now()-100<a.input.lastKeyCodeTime?(f=a.state.selection.to,g="end"):(f=a.state.selection.from,g="start"),a.input.lastKeyCode=null;let p=function(a,b,c,d,e){let f=a.findDiffStart(b,c);if(null==f)return null;let{a:g,b:h}=a.findDiffEnd(b,c+a.size,c+b.size);if("end"==e){let a=Math.max(0,f-Math.min(g,h));d-=g+a-f}if(g<f&&a.size<b.size){let a=d<=f&&d>=g?f-d:0;(f-=a)&&f<b.size&&h5(b.textBetween(f-1,f+1))&&(f+=a?1:-1),h=f+(h-g),g=f}else if(h<f){let b=d<=f&&d>=h?f-d:0;(f-=b)&&f<a.size&&h5(a.textBetween(f-1,f+1))&&(f+=b?1:-1),g=f+(g-h),h=f}return{start:f,endA:g,endB:h}}(o.content,m.doc.content,m.from,f,g);if(p&&a.input.domChangeCount++,(f5&&a.input.lastIOSEnter>Date.now()-225||f8)&&e.some(a=>1==a.nodeType&&!h2.test(a.nodeName))&&(!p||p.endA>=p.endB)&&a.someProp("handleKeyDown",b=>b(a,fT(13,"Enter")))){a.input.lastIOSEnter=0;return}if(!p)if(d&&l instanceof fq&&!l.empty&&l.$head.sameParent(l.$anchor)&&!a.composing&&!(m.sel&&m.sel.anchor!=m.sel.head))p={start:l.from,endA:l.to,endB:l.to};else{if(m.sel){let b=h3(a,a.state.doc,m.sel);if(b&&!b.eq(a.state.selection)){let c=a.state.tr.setSelection(b);i&&c.setMeta("composition",i),a.dispatch(c)}}return}a.state.selection.from<a.state.selection.to&&p.start==p.endB&&a.state.selection instanceof fq&&(p.start>a.state.selection.from&&p.start<=a.state.selection.from+2&&a.state.selection.from>=m.from?p.start=a.state.selection.from:p.endA<a.state.selection.to&&p.endA>=a.state.selection.to-2&&a.state.selection.to<=m.to&&(p.endB+=a.state.selection.to-p.endA,p.endA=a.state.selection.to)),f$&&f_<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>m.from&&" "==m.doc.textBetween(p.start-m.from-1,p.start-m.from+1)&&(p.start--,p.endA--,p.endB--);let q=m.doc.resolveNoCache(p.start-m.from),r=m.doc.resolveNoCache(p.endB-m.from),s=n.resolve(p.start),t=q.sameParent(r)&&q.parent.inlineContent&&s.end()>=p.endA;if((f5&&a.input.lastIOSEnter>Date.now()-225&&(!t||e.some(a=>"DIV"==a.nodeName||"P"==a.nodeName))||!t&&q.pos<m.doc.content.size&&(!q.sameParent(r)||!q.parent.inlineContent)&&q.pos<r.pos&&!/\S/.test(m.doc.textBetween(q.pos,r.pos,"","")))&&a.someProp("handleKeyDown",b=>b(a,fT(13,"Enter")))){a.input.lastIOSEnter=0;return}if(a.state.selection.anchor>p.start&&function(a,b,c,d,e){if(c-b<=e.pos-d.pos||h4(d,!0,!1)<e.pos)return!1;let f=a.resolve(b);if(!d.parent.isTextblock){let a=f.nodeAfter;return null!=a&&c==b+a.nodeSize}if(f.parentOffset<f.parent.content.size||!f.parent.isTextblock)return!1;let g=a.resolve(h4(f,!0,!0));return!(!g.parent.isTextblock||g.pos>c||h4(g,!0,!1)<c)&&d.parent.content.cut(d.parentOffset).eq(g.parent.content)}(n,p.start,p.endA,q,r)&&a.someProp("handleKeyDown",b=>b(a,fT(8,"Backspace")))){f8&&f2&&a.domObserver.suppressSelectionUpdates();return}f2&&p.endB==p.start&&(a.input.lastChromeDelete=Date.now()),f8&&!t&&q.start()!=r.start()&&0==r.parentOffset&&q.depth==r.depth&&m.sel&&m.sel.anchor==m.sel.head&&m.sel.head==p.endA&&(p.endB-=2,r=m.doc.resolveNoCache(p.endB-m.from),setTimeout(()=>{a.someProp("handleKeyDown",function(b){return b(a,fT(13,"Enter"))})},20));let u=p.start,v=p.endA,w=b=>{let c=b||a.state.tr.replace(u,v,m.doc.slice(p.start-m.from,p.endB-m.from));if(m.sel){let b=h3(a,c.doc,m.sel);b&&!(f2&&a.composing&&b.empty&&(p.start!=p.endB||a.input.lastChromeDelete<Date.now()-100)&&(b.head==u||b.head==c.mapping.map(v)-1)||f$&&b.empty&&b.head==u)&&c.setSelection(b)}return i&&c.setMeta("composition",i),c.scrollIntoView()};if(t)if(q.pos==r.pos){f$&&f_<=11&&0==q.parentOffset&&(a.domObserver.suppressSelectionUpdates(),setTimeout(()=>gN(a),20));let b=w(a.state.tr.delete(u,v)),c=n.resolve(p.start).marksAcross(n.resolve(p.endA));c&&b.ensureMarks(c),a.dispatch(b)}else if(p.endA==p.endB&&(h=function(a,b){let c=a.firstChild.marks,d=b.firstChild.marks,e=c,f=d,g,h,i;for(let a=0;a<d.length;a++)e=d[a].removeFromSet(e);for(let a=0;a<c.length;a++)f=c[a].removeFromSet(f);if(1==e.length&&0==f.length)h=e[0],g="add",i=a=>a.mark(h.addToSet(a.marks));else{if(0!=e.length||1!=f.length)return null;h=f[0],g="remove",i=a=>a.mark(h.removeFromSet(a.marks))}let j=[];for(let a=0;a<b.childCount;a++)j.push(i(b.child(a)));if(d$.from(j).eq(a))return{mark:h,type:g}}(q.parent.content.cut(q.parentOffset,r.parentOffset),s.parent.content.cut(s.parentOffset,p.endA-s.start())))){let b=w(a.state.tr);"add"==h.type?b.addMark(u,v,h.mark):b.removeMark(u,v,h.mark),a.dispatch(b)}else if(q.parent.child(q.index()).isText&&q.index()==r.index()-!r.textOffset){let b=q.parent.textBetween(q.parentOffset,r.parentOffset),c=()=>w(a.state.tr.insertText(b,u,v));a.someProp("handleTextInput",d=>d(a,u,v,b,c))||a.dispatch(c())}else a.dispatch(w());else a.dispatch(w())})(this,a,b,c,d)),this.domObserver.start(),function(a){for(let b in hh){let c=hh[b];a.dom.addEventListener(b,a.input.eventHandlers[b]=b=>{!function(a,b){if(!b.bubbles)return!0;if(b.defaultPrevented)return!1;for(let c=b.target;c!=a.dom;c=c.parentNode)if(!c||11==c.nodeType||c.pmViewDesc&&c.pmViewDesc.stopEvent(b))return!1;return!0}(a,b)||hn(a,b)||!a.editable&&b.type in hi||c(a,b)},hj[b]?{passive:!0}:void 0)}f4&&a.dom.addEventListener("input",()=>null),hm(a)}(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let a=this._props;for(let b in this._props={},a)this._props[b]=a[b];this._props.state=this.state}return this._props}update(a){a.handleDOMEvents!=this._props.handleDOMEvents&&hm(this);let b=this._props;this._props=a,a.plugins&&(a.plugins.forEach(ib),this.directPlugins=a.plugins),this.updateStateInner(a.state,b)}setProps(a){let b={};for(let a in this._props)b[a]=this._props[a];for(let c in b.state=this.state,a)b[c]=a[c];this.update(b)}updateState(a){this.updateStateInner(a,this._props)}updateStateInner(a,b){var c,d,e;let f=this.state,g=!1,h=!1;a.storedMarks&&this.composing&&(hw(this),h=!0),this.state=a;let i=f.plugins!=a.plugins||this._props.plugins!=b.plugins;if(i||this._props.plugins!=b.plugins||this._props.nodeViews!=b.nodeViews){let a=ia(this);(function(a,b){let c=0,d=0;for(let d in a){if(a[d]!=b[d])return!0;c++}for(let a in b)d++;return c!=d})(a,this.nodeViews)&&(this.nodeViews=a,g=!0)}(i||b.handleDOMEvents!=this._props.handleDOMEvents)&&hm(this),this.editable=h9(this),h8(this);let j=hV(this),k=h7(this),l=f.plugins==a.plugins||f.doc.eq(a.doc)?a.scrollToSelection>f.scrollToSelection?"to selection":"preserve":"reset",m=g||!this.docView.matchesNode(a.doc,k,j);(m||!a.selection.eq(f.selection))&&(h=!0);let n="preserve"==l&&h&&null==this.dom.style.overflowAnchor&&function(a){let b,c,d=a.dom.getBoundingClientRect(),e=Math.max(0,d.top);for(let f=(d.left+d.right)/2,g=e+1;g<Math.min(innerHeight,d.bottom);g+=5){let d=a.root.elementFromPoint(f,g);if(!d||d==a.dom||!a.dom.contains(d))continue;let h=d.getBoundingClientRect();if(h.top>=e-20){b=d,c=h.top;break}}return{refDOM:b,refTop:c,stack:gd(a.dom)}}(this);if(h){let b,c,h;this.domObserver.stop();let i=m&&(f$||f2)&&!this.composing&&!f.selection.empty&&!a.selection.empty&&(d=f.selection,e=a.selection,h=Math.min(d.$anchor.sharedDepth(d.head),e.$anchor.sharedDepth(e.head)),d.$anchor.start(h)!=e.$anchor.start(h));if(m){let b=f2?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=function(a){let b=a.domSelectionRange();if(!b.focusNode)return null;let c=function(a,b){for(;;){if(3==a.nodeType&&b)return a;if(1==a.nodeType&&b>0){if("false"==a.contentEditable)return null;b=fQ(a=a.childNodes[b-1])}else{if(!a.parentNode||fR(a))return null;b=fI(a),a=a.parentNode}}}(b.focusNode,b.focusOffset),d=function(a,b){for(;;){if(3==a.nodeType&&b<a.nodeValue.length)return a;if(1==a.nodeType&&b<a.childNodes.length){if("false"==a.contentEditable)return null;a=a.childNodes[b],b=0}else{if(!a.parentNode||fR(a))return null;b=fI(a)+1,a=a.parentNode}}}(b.focusNode,b.focusOffset);if(c&&d&&c!=d){let b=d.pmViewDesc,e=a.domObserver.lastChangedTextNode;if(c==e||d==e)return e;if(!b||!b.isText(d.nodeValue))return d;if(a.input.compositionNode==d){let a=c.pmViewDesc;if(!(!a||!a.isText(c.nodeValue)))return d}}return c||d}(this)),(g||!this.docView.update(a.doc,k,j,this))&&(this.docView.updateOuterDeco(k),this.docView.destroy(),this.docView=gx(a.doc,k,j,this.dom,this)),!b||this.trackWrites&&this.dom.contains(this.trackWrites)||(i=!0)}i||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&(b=this.docView.domFromPos(this.state.selection.anchor,0),c=this.domSelectionRange(),fN(b.node,b.offset,c.anchorNode,c.anchorOffset)))?gN(this,i):(gS(this,a.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(f),(null==(c=this.dragging)?void 0:c.node)&&!f.doc.eq(a.doc)&&this.updateDraggedNode(this.dragging,f),"reset"==l?this.dom.scrollTop=0:"to selection"==l?this.scrollToSelection():n&&function({refDOM:a,refTop:b,stack:c}){let d=a?a.getBoundingClientRect().top:0;ge(c,0==d?0:d-b)}(n)}scrollToSelection(){let a=this.domSelectionRange().focusNode;if(a&&this.dom.contains(1==a.nodeType?a:a.parentNode))if(this.someProp("handleScrollToSelection",a=>a(this)));else if(this.state.selection instanceof fs){let b=this.docView.domAfterPos(this.state.selection.from);1==b.nodeType&&gc(this,b.getBoundingClientRect(),a)}else gc(this,this.coordsAtPos(this.state.selection.head,1),a)}destroyPluginViews(){let a;for(;a=this.pluginViews.pop();)a.destroy&&a.destroy()}updatePluginViews(a){if(a&&a.plugins==this.state.plugins&&this.directPlugins==this.prevDirectPlugins)for(let b=0;b<this.pluginViews.length;b++){let c=this.pluginViews[b];c.update&&c.update(this,a)}else{this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let a=0;a<this.directPlugins.length;a++){let b=this.directPlugins[a];b.spec.view&&this.pluginViews.push(b.spec.view(this))}for(let a=0;a<this.state.plugins.length;a++){let b=this.state.plugins[a];b.spec.view&&this.pluginViews.push(b.spec.view(this))}}}updateDraggedNode(a,b){let c=a.node,d=-1;if(c.from<this.state.doc.content.size&&this.state.doc.nodeAt(c.from)==c.node)d=c.from;else{let a=c.from+(this.state.doc.content.size-b.doc.content.size);(a>0&&a<this.state.doc.content.size&&this.state.doc.nodeAt(a))==c.node&&(d=a)}this.dragging=new hB(a.slice,a.move,d<0?void 0:fs.create(this.state.doc,d))}someProp(a,b){let c=this._props&&this._props[a],d;if(null!=c&&(d=b?b(c):c))return d;for(let c=0;c<this.directPlugins.length;c++){let e=this.directPlugins[c].props[a];if(null!=e&&(d=b?b(e):e))return d}let e=this.state.plugins;if(e)for(let c=0;c<e.length;c++){let f=e[c].props[a];if(null!=f&&(d=b?b(f):f))return d}}hasFocus(){if(f$){let a=this.root.activeElement;if(a==this.dom)return!0;if(!a||!this.dom.contains(a))return!1;for(;a&&this.dom!=a&&this.dom.contains(a);){if("false"==a.contentEditable)return!1;a=a.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&function(a){if(a.setActive)return a.setActive();if(gf)return a.focus(gf);let b=gd(a);a.focus(null==gf?{get preventScroll(){return gf={preventScroll:!0},!0}}:void 0),gf||(gf=!1,ge(b,0))}(this.dom),gN(this),this.domObserver.start()}get root(){let a=this._root;if(null==a){for(let a=this.dom.parentNode;a;a=a.parentNode)if(9==a.nodeType||11==a.nodeType&&a.host)return a.getSelection||(Object.getPrototypeOf(a).getSelection=()=>a.ownerDocument.getSelection()),this._root=a}return a||document}updateRoot(){this._root=null}posAtCoords(a){return function(a,b){var c;let d,e,f=a.dom.ownerDocument,g,h=0,i=function(a,b,c){if(a.caretPositionFromPoint)try{let d=a.caretPositionFromPoint(b,c);if(d)return{node:d.offsetNode,offset:Math.min(fQ(d.offsetNode),d.offset)}}catch(a){}if(a.caretRangeFromPoint){let d=a.caretRangeFromPoint(b,c);if(d)return{node:d.startContainer,offset:Math.min(fQ(d.startContainer),d.startOffset)}}}(f,b.left,b.top);i&&({node:g,offset:h}=i);let j=(a.root.elementFromPoint?a.root:f).elementFromPoint(b.left,b.top);if(!j||!a.dom.contains(1!=j.nodeType?j.parentNode:j)){let c=a.dom.getBoundingClientRect();if(!gg(b,c)||!(j=function a(b,c,d){let e=b.childNodes.length;if(e&&d.top<d.bottom)for(let f=Math.max(0,Math.min(e-1,Math.floor(e*(c.top-d.top)/(d.bottom-d.top))-2)),g=f;;){let d=b.childNodes[g];if(1==d.nodeType){let b=d.getClientRects();for(let e=0;e<b.length;e++){let f=b[e];if(gg(c,f))return a(d,c,f)}}if((g=(g+1)%e)==f)break}return b}(a.dom,b,c)))return null}if(f4)for(let a=j;g&&a;a=fJ(a))a.draggable&&(g=void 0);if(j=(d=(c=j).parentNode)&&/^li$/i.test(d.nodeName)&&b.left<c.getBoundingClientRect().left?d:c,g){let c;if(f0&&1==g.nodeType&&(h=Math.min(h,g.childNodes.length))<g.childNodes.length){let a=g.childNodes[h],c;"IMG"==a.nodeName&&(c=a.getBoundingClientRect()).right<=b.left&&c.bottom>b.top&&h++}f9&&h&&1==g.nodeType&&1==(c=g.childNodes[h-1]).nodeType&&"false"==c.contentEditable&&c.getBoundingClientRect().top>=b.top&&h--,g==a.dom&&h==g.childNodes.length-1&&1==g.lastChild.nodeType&&b.top>g.lastChild.getBoundingClientRect().bottom?e=a.state.doc.content.size:(0==h||1!=g.nodeType||"BR"!=g.childNodes[h-1].nodeName)&&(e=function(a,b,c,d){let e=-1;for(let c=b,f=!1;c!=a.dom;){let b=a.docView.nearestDesc(c,!0),g;if(!b)return null;if(1==b.dom.nodeType&&(b.node.isBlock&&b.parent||!b.contentDOM)&&((g=b.dom.getBoundingClientRect()).width||g.height)&&(b.node.isBlock&&b.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(b.dom.nodeName)&&(!f&&g.left>d.left||g.top>d.top?e=b.posBefore:(!f&&g.right<d.left||g.bottom<d.top)&&(e=b.posAfter),f=!0),!b.contentDOM&&e<0&&!b.node.isText))return(b.node.isBlock?d.top<(g.top+g.bottom)/2:d.left<(g.left+g.right)/2)?b.posBefore:b.posAfter;c=b.dom.parentNode}return e>-1?e:a.docView.posFromDOM(b,c,-1)}(a,g,h,b))}null==e&&(e=function(a,b,c){let{node:d,offset:e}=function a(b,c){let d,e,f,g=2e8,h,i=0,j=c.top,k=c.top;for(let a=b.firstChild,l=0;a;a=a.nextSibling,l++){let b;if(1==a.nodeType)b=a.getClientRects();else{if(3!=a.nodeType)continue;b=fL(a).getClientRects()}for(let m=0;m<b.length;m++){let n=b[m];if(n.top<=j&&n.bottom>=k){j=Math.max(n.bottom,j),k=Math.min(n.top,k);let b=n.left>c.left?n.left-c.left:n.right<c.left?c.left-n.right:0;if(b<g){f=a,g=b,h=b&&3==f.nodeType?{left:n.right<c.left?n.right:n.left,top:c.top}:c,1==a.nodeType&&b&&(i=l+ +(c.left>=(n.left+n.right)/2));continue}}else n.top>c.top&&!d&&n.left<=c.left&&n.right>=c.left&&(d=a,e={left:Math.max(n.left,Math.min(n.right,c.left)),top:n.top});!f&&(c.left>=n.right&&c.top>=n.top||c.left>=n.left&&c.top>=n.bottom)&&(i=l+1)}}return(!f&&d&&(f=d,h=e,g=0),f&&3==f.nodeType)?function(a,b){let c=a.nodeValue.length,d=document.createRange(),e;for(let f=0;f<c;f++){d.setEnd(a,f+1),d.setStart(a,f);let c=gi(d,1);if(c.top!=c.bottom&&gg(b,c)){e={node:a,offset:f+ +(b.left>=(c.left+c.right)/2)};break}}return d.detach(),e||{node:a,offset:0}}(f,h):!f||g&&1==f.nodeType?{node:b,offset:i}:a(f,h)}(b,c),f=-1;if(1==d.nodeType&&!d.firstChild){let a=d.getBoundingClientRect();f=a.left!=a.right&&c.left>(a.left+a.right)/2?1:-1}return a.docView.posFromDOM(d,e,f)}(a,j,b));let k=a.docView.nearestDesc(j,!0);return{pos:e,inside:k?k.posAtStart-k.border:-1}}(this,a)}coordsAtPos(a,b=1){return gk(this,a,b)}domAtPos(a,b=0){return this.docView.domFromPos(a,b)}nodeDOM(a){let b=this.docView.descAt(a);return b?b.nodeDOM:null}posAtDOM(a,b,c=-1){let d=this.docView.posFromDOM(a,b,c);if(null==d)throw RangeError("DOM position not inside the editor");return d}endOfTextblock(a,b){return function(a,b,c){let d,e;return gp==b&&gq==c?gr:(gp=b,gq=c,gr="up"==c||"down"==c?(d=b.selection,e="up"==c?d.$from:d.$to,gn(a,b,()=>{let{node:b}=a.docView.domFromPos(e.pos,"up"==c?-1:1);for(;;){let c=a.docView.nearestDesc(b,!0);if(!c)break;if(c.node.isBlock){b=c.contentDOM||c.dom;break}b=c.dom.parentNode}let d=gk(a,e.pos,1);for(let a=b.firstChild;a;a=a.nextSibling){let b;if(1==a.nodeType)b=a.getClientRects();else{if(3!=a.nodeType)continue;b=fL(a,0,a.nodeValue.length).getClientRects()}for(let a=0;a<b.length;a++){let e=b[a];if(e.bottom>e.top+1&&("up"==c?d.top-e.top>(e.bottom-d.top)*2:e.bottom-d.bottom>(d.bottom-e.top)*2))return!1}}return!0})):function(a,b,c){let{$head:d}=b.selection;if(!d.parent.isTextblock)return!1;let e=d.parentOffset,f=e==d.parent.content.size,g=a.domSelection();return g?go.test(d.parent.textContent)&&g.modify?gn(a,b,()=>{let{focusNode:b,focusOffset:e,anchorNode:f,anchorOffset:h}=a.domSelectionRange(),i=g.caretBidiLevel;g.modify("move",c,"character");let j=d.depth?a.docView.domAfterPos(d.before()):a.dom,{focusNode:k,focusOffset:l}=a.domSelectionRange(),m=k&&!j.contains(1==k.nodeType?k:k.parentNode)||b==k&&e==l;try{g.collapse(f,h),b&&(b!=f||e!=h)&&g.extend&&g.extend(b,e)}catch(a){}return null!=i&&(g.caretBidiLevel=i),m}):"left"==c||"backward"==c?!e:f:d.pos==d.start()||d.pos==d.end()}(a,b,c))}(this,b||this.state,a)}pasteHTML(a,b){return hz(this,"",a,!1,b||new ClipboardEvent("paste"))}pasteText(a,b){return hz(this,a,null,!0,b||new ClipboardEvent("paste"))}serializeForClipboard(a){return g7(this,a)}destroy(){if(this.docView){for(let a in this.domObserver.stop(),this.input.eventHandlers)this.dom.removeEventListener(a,this.input.eventHandlers[a]);clearTimeout(this.input.composingTimeout),clearTimeout(this.input.lastIOSEnterFallbackTimeout),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],hV(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,fM()}}get isDestroyed(){return null==this.docView}dispatchEvent(a){!hn(this,a)&&hh[a.type]&&(this.editable||!(a.type in hi))&&hh[a.type](this,a)}domSelectionRange(){let a=this.domSelection();return a?f4&&11===this.root.nodeType&&function(a){let b=a.activeElement;for(;b&&b.shadowRoot;)b=b.shadowRoot.activeElement;return b}(this.dom.ownerDocument)==this.dom&&function(a,b){let c;if(b.getComposedRanges){let c=b.getComposedRanges(a.root)[0];if(c)return h0(a,c)}function d(a){a.preventDefault(),a.stopImmediatePropagation(),c=a.getTargetRanges()[0]}return a.dom.addEventListener("beforeinput",d,!0),document.execCommand("indent"),a.dom.removeEventListener("beforeinput",d,!0),c?h0(a,c):null}(this,a)||a:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function h7(a){let b=Object.create(null);return b.class="ProseMirror",b.contenteditable=String(a.editable),a.someProp("attributes",c=>{if("function"==typeof c&&(c=c(a.state)),c)for(let a in c)"class"==a?b.class+=" "+c[a]:"style"==a?b.style=(b.style?b.style+";":"")+c[a]:b[a]||"contenteditable"==a||"nodeName"==a||(b[a]=String(c[a]))}),b.translate||(b.translate="no"),[hI.node(0,a.state.doc.content.size,b)]}function h8(a){if(a.markCursor){let b=document.createElement("img");b.className="ProseMirror-separator",b.setAttribute("mark-placeholder","true"),b.setAttribute("alt",""),a.cursorWrapper={dom:b,deco:hI.widget(a.state.selection.from,b,{raw:!0,marks:a.markCursor})}}else a.cursorWrapper=null}function h9(a){return!a.someProp("editable",b=>!1===b(a.state))}function ia(a){let b=Object.create(null);function c(a){for(let c in a)Object.prototype.hasOwnProperty.call(b,c)||(b[c]=a[c])}return a.someProp("nodeViews",c),a.someProp("markViews",c),b}function ib(a){if(a.spec.state||a.spec.filterTransaction||a.spec.appendTransaction)throw RangeError("Plugins passed directly to the view must not have a state component")}h6.prototype.dispatch=function(a){let b=this._props.dispatchTransaction;b?b.call(this,a):this.updateState(this.state.apply(a))};for(var ic={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},id={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},ie="u">typeof navigator&&/Mac/.test(navigator.platform),ig="u">typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),ih=0;ih<10;ih++)ic[48+ih]=ic[96+ih]=String(ih);for(var ih=1;ih<=24;ih++)ic[ih+111]="F"+ih;for(var ih=65;ih<=90;ih++)ic[ih]=String.fromCharCode(ih+32),id[ih]=String.fromCharCode(ih);for(var ii in ic)id.hasOwnProperty(ii)||(id[ii]=ic[ii]);let ij="u">typeof navigator&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),ik="u">typeof navigator&&/Win/.test(navigator.platform);function il(a,b,c=!0){return b.altKey&&(a="Alt-"+a),b.ctrlKey&&(a="Ctrl-"+a),b.metaKey&&(a="Meta-"+a),c&&b.shiftKey&&(a="Shift-"+a),a}function im(a){let b=function(a){let b=Object.create(null);for(let c in a)b[function(a){let b,c,d,e,f=a.split(/-(?!$)/),g=f[f.length-1];"Space"==g&&(g=" ");for(let a=0;a<f.length-1;a++){let g=f[a];if(/^(cmd|meta|m)$/i.test(g))e=!0;else if(/^a(lt)?$/i.test(g))b=!0;else if(/^(c|ctrl|control)$/i.test(g))c=!0;else if(/^s(hift)?$/i.test(g))d=!0;else if(/^mod$/i.test(g))ij?e=!0:c=!0;else throw Error("Unrecognized modifier name: "+g)}return b&&(g="Alt-"+g),c&&(g="Ctrl-"+g),e&&(g="Meta-"+g),d&&(g="Shift-"+g),g}(c)]=a[c];return b}(a);return function(a,c){var d;let e=("Esc"==(d=!(ie&&c.metaKey&&c.shiftKey&&!c.ctrlKey&&!c.altKey||ig&&c.shiftKey&&c.key&&1==c.key.length||"Unidentified"==c.key)&&c.key||(c.shiftKey?id:ic)[c.keyCode]||c.key||"Unidentified")&&(d="Escape"),"Del"==d&&(d="Delete"),"Left"==d&&(d="ArrowLeft"),"Up"==d&&(d="ArrowUp"),"Right"==d&&(d="ArrowRight"),"Down"==d&&(d="ArrowDown"),d),f,g=b[il(e,c)];if(g&&g(a.state,a.dispatch,a))return!0;if(1==e.length&&" "!=e){if(c.shiftKey){let d=b[il(e,c,!1)];if(d&&d(a.state,a.dispatch,a))return!0}if((c.altKey||c.metaKey||c.ctrlKey)&&!(ik&&c.ctrlKey&&c.altKey)&&(f=ic[c.keyCode])&&f!=e){let d=b[il(f,c)];if(d&&d(a.state,a.dispatch,a))return!0}}return!1}}if("u">typeof WeakMap){let a=new WeakMap;b=b=>a.get(b),c=(b,c)=>(a.set(b,c),c)}else{let a=[],d=0;b=b=>{for(let c=0;c<a.length;c+=2)if(a[c]==b)return a[c+1]},c=(b,c)=>(10==d&&(d=0),a[d++]=b,a[d++]=c)}var io=class{constructor(a,b,c,d){this.width=a,this.height=b,this.map=c,this.problems=d}findCell(a){for(let b=0;b<this.map.length;b++){let c=this.map[b];if(c!=a)continue;let d=b%this.width,e=b/this.width|0,f=d+1,g=e+1;for(let a=1;f<this.width&&this.map[b+a]==c;a++)f++;for(let a=1;g<this.height&&this.map[b+this.width*a]==c;a++)g++;return{left:d,top:e,right:f,bottom:g}}throw RangeError(`No cell with offset ${a} found`)}colCount(a){for(let b=0;b<this.map.length;b++)if(this.map[b]==a)return b%this.width;throw RangeError(`No cell with offset ${a} found`)}nextCell(a,b,c){let{left:d,right:e,top:f,bottom:g}=this.findCell(a);return"horiz"==b?(c<0?0==d:e==this.width)?null:this.map[f*this.width+(c<0?d-1:e)]:(c<0?0==f:g==this.height)?null:this.map[d+this.width*(c<0?f-1:g)]}rectBetween(a,b){let{left:c,right:d,top:e,bottom:f}=this.findCell(a),{left:g,right:h,top:i,bottom:j}=this.findCell(b);return{left:Math.min(c,g),top:Math.min(e,i),right:Math.max(d,h),bottom:Math.max(f,j)}}cellsInRect(a){let b=[],c={};for(let d=a.top;d<a.bottom;d++)for(let e=a.left;e<a.right;e++){let f=d*this.width+e,g=this.map[f];!c[g]&&(c[g]=!0,e==a.left&&e&&this.map[f-1]==g||d==a.top&&d&&this.map[f-this.width]==g||b.push(g))}return b}positionAt(a,b,c){for(let d=0,e=0;;d++){let f=e+c.child(d).nodeSize;if(d==a){let c=b+a*this.width,d=(a+1)*this.width;for(;c<d&&this.map[c]<e;)c++;return c==d?f-1:this.map[c]}e=f}}static get(a){return b(a)||c(a,function(a){if("table"!=a.type.spec.tableRole)throw RangeError("Not a table node: "+a.type.name);let b=function(a){let b=-1,c=!1;for(let d=0;d<a.childCount;d++){let e=a.child(d),f=0;if(c)for(let b=0;b<d;b++){let c=a.child(b);for(let a=0;a<c.childCount;a++){let e=c.child(a);b+e.attrs.rowspan>d&&(f+=e.attrs.colspan)}}for(let a=0;a<e.childCount;a++){let b=e.child(a);f+=b.attrs.colspan,b.attrs.rowspan>1&&(c=!0)}-1==b?b=f:b!=f&&(b=Math.max(b,f))}return b}(a),c=a.childCount,d=[],e=0,f=null,g=[];for(let a=0,e=b*c;a<e;a++)d[a]=0;for(let h=0,i=0;h<c;h++){let j=a.child(h);i++;for(let a=0;;a++){for(;e<d.length&&0!=d[e];)e++;if(a==j.childCount)break;let k=j.child(a),{colspan:l,rowspan:m,colwidth:n}=k.attrs;for(let a=0;a<m;a++){if(a+h>=c){(f||(f=[])).push({type:"overlong_rowspan",pos:i,n:m-a});break}let j=e+a*b;for(let a=0;a<l;a++){0==d[j+a]?d[j+a]=i:(f||(f=[])).push({type:"collision",row:h,pos:i,n:l-a});let c=n&&n[a];if(c){let d=(j+a)%b*2,e=g[d];null==e||e!=c&&1==g[d+1]?(g[d]=c,g[d+1]=1):e==c&&g[d+1]++}}}e+=l,i+=k.nodeSize}let k=(h+1)*b,l=0;for(;e<k;)0==d[e++]&&l++;l&&(f||(f=[])).push({type:"missing",row:h,n:l}),i++}(0===b||0===c)&&(f||(f=[])).push({type:"zero_sized"});let h=new io(b,c,d,f),i=!1;for(let a=0;!i&&a<g.length;a+=2)null!=g[a]&&g[a+1]<c&&(i=!0);return i&&function(a,b,c){a.problems||(a.problems=[]);let d={};for(let e=0;e<a.map.length;e++){let f=a.map[e];if(d[f])continue;d[f]=!0;let g=c.nodeAt(f);if(!g)throw RangeError(`No cell with offset ${f} found`);let h=null,i=g.attrs;for(let c=0;c<i.colspan;c++){let d=b[(e+c)%a.width*2];null==d||i.colwidth&&i.colwidth[c]==d||((h||(h=function(a){if(a.colwidth)return a.colwidth.slice();let b=[];for(let c=0;c<a.colspan;c++)b.push(0);return b}(i)))[c]=d)}h&&a.problems.unshift({type:"colwidth mismatch",pos:f,colwidth:h})}}(h,g,a),h}(a))}};function ip(a){let b=a.cached.tableNodeTypes;if(!b)for(let c in b=a.cached.tableNodeTypes={},a.nodes){let d=a.nodes[c],e=d.spec.tableRole;e&&(b[e]=d)}return b}let iq=new fH("selectingCells");function ir(a){for(let b=a.depth-1;b>0;b--)if("row"==a.node(b).type.spec.tableRole)return a.node(0).resolve(a.before(b+1));return null}function is(a){let b=a.selection.$head;for(let a=b.depth;a>0;a--)if("row"==b.node(a).type.spec.tableRole)return!0;return!1}function it(a){let b=a.selection;if("$anchorCell"in b&&b.$anchorCell)return b.$anchorCell.pos>b.$headCell.pos?b.$anchorCell:b.$headCell;if("node"in b&&b.node&&"cell"==b.node.type.spec.tableRole)return b.$anchor;let c=ir(b.$head)||function(a){for(let b=a.nodeAfter,c=a.pos;b;b=b.firstChild,c++){let d=b.type.spec.tableRole;if("cell"==d||"header_cell"==d)return a.doc.resolve(c)}for(let b=a.nodeBefore,c=a.pos;b;b=b.lastChild,c--){let d=b.type.spec.tableRole;if("cell"==d||"header_cell"==d)return a.doc.resolve(c-b.nodeSize)}}(b.$head);if(c)return c;throw RangeError(`No cell found around position ${b.head}`)}function iu(a){return"row"==a.parent.type.spec.tableRole&&!!a.nodeAfter}function iv(a,b){return a.depth==b.depth&&a.pos>=b.start(-1)&&a.pos<=b.end(-1)}function iw(a,b,c){let d=a.node(-1),e=io.get(d),f=a.start(-1),g=e.nextCell(a.pos-f,b,c);return null==g?null:a.node(0).resolve(f+g)}function ix(a,b,c=1){let d={...a,colspan:a.colspan-c};return d.colwidth&&(d.colwidth=d.colwidth.slice(),d.colwidth.splice(b,c),d.colwidth.some(a=>a>0)||(d.colwidth=null)),d}function iy(a,b,c=1){let d={...a,colspan:a.colspan+c};if(d.colwidth){d.colwidth=d.colwidth.slice();for(let a=0;a<c;a++)d.colwidth.splice(b,0,0)}return d}var iz=class a extends fm{constructor(a,b=a){const c=a.node(-1),d=io.get(c),e=a.start(-1),f=d.rectBetween(a.pos-e,b.pos-e),g=a.node(0),h=d.cellsInRect(f).filter(a=>a!=b.pos-e);h.unshift(b.pos-e);const i=h.map(a=>{let b=c.nodeAt(a);if(!b)throw RangeError(`No cell with offset ${a} found`);let d=e+a+1;return new fn(g.resolve(d),g.resolve(d+b.content.size))});super(i[0].$from,i[0].$to,i),this.$anchorCell=a,this.$headCell=b}map(b,c){let d=b.resolve(c.map(this.$anchorCell.pos)),e=b.resolve(c.map(this.$headCell.pos));if(iu(d)&&iu(e)&&iv(d,e)){let b=this.$anchorCell.node(-1)!=d.node(-1);return b&&this.isRowSelection()?a.rowSelection(d,e):b&&this.isColSelection()?a.colSelection(d,e):new a(d,e)}return fq.between(d,e)}content(){let a=this.$anchorCell.node(-1),b=io.get(a),c=this.$anchorCell.start(-1),d=b.rectBetween(this.$anchorCell.pos-c,this.$headCell.pos-c),e={},f=[];for(let c=d.top;c<d.bottom;c++){let g=[];for(let f=c*b.width+d.left,h=d.left;h<d.right;h++,f++){let c=b.map[f];if(e[c])continue;e[c]=!0;let h=b.findCell(c),i=a.nodeAt(c);if(!i)throw RangeError(`No cell with offset ${c} found`);let j=d.left-h.left,k=h.right-d.right;if(j>0||k>0){let a=i.attrs;if(j>0&&(a=ix(a,0,j)),k>0&&(a=ix(a,a.colspan-k,k)),h.left<d.left){if(!(i=i.type.createAndFill(a)))throw RangeError(`Could not create cell with attrs ${JSON.stringify(a)}`)}else i=i.type.create(a,i.content)}if(h.top<d.top||h.bottom>d.bottom){let a={...i.attrs,rowspan:Math.min(h.bottom,d.bottom)-Math.max(h.top,d.top)};i=h.top<d.top?i.type.createAndFill(a):i.type.create(a,i.content)}g.push(i)}f.push(a.child(c).copy(d$.from(g)))}let g=this.isColSelection()&&this.isRowSelection()?a:f;return new d4(d$.from(g),1,1)}replace(a,b=d4.empty){let c=a.steps.length,d=this.ranges;for(let e=0;e<d.length;e++){let{$from:f,$to:g}=d[e],h=a.mapping.slice(c);a.replace(h.map(f.pos),h.map(g.pos),e?d4.empty:b)}let e=fm.findFrom(a.doc.resolve(a.mapping.slice(c).map(this.to)),-1);e&&a.setSelection(e)}replaceWith(a,b){this.replace(a,new d4(d$.from(b),0,0))}forEachCell(a){let b=this.$anchorCell.node(-1),c=io.get(b),d=this.$anchorCell.start(-1),e=c.cellsInRect(c.rectBetween(this.$anchorCell.pos-d,this.$headCell.pos-d));for(let c=0;c<e.length;c++)a(b.nodeAt(e[c]),d+e[c])}isColSelection(){let a=this.$anchorCell.index(-1),b=this.$headCell.index(-1);return!(Math.min(a,b)>0)&&Math.max(a+this.$anchorCell.nodeAfter.attrs.rowspan,b+this.$headCell.nodeAfter.attrs.rowspan)==this.$headCell.node(-1).childCount}static colSelection(b,c=b){let d=b.node(-1),e=io.get(d),f=b.start(-1),g=e.findCell(b.pos-f),h=e.findCell(c.pos-f),i=b.node(0);return g.top<=h.top?(g.top>0&&(b=i.resolve(f+e.map[g.left])),h.bottom<e.height&&(c=i.resolve(f+e.map[e.width*(e.height-1)+h.right-1]))):(h.top>0&&(c=i.resolve(f+e.map[h.left])),g.bottom<e.height&&(b=i.resolve(f+e.map[e.width*(e.height-1)+g.right-1]))),new a(b,c)}isRowSelection(){let a=this.$anchorCell.node(-1),b=io.get(a),c=this.$anchorCell.start(-1),d=b.colCount(this.$anchorCell.pos-c),e=b.colCount(this.$headCell.pos-c);return!(Math.min(d,e)>0)&&Math.max(d+this.$anchorCell.nodeAfter.attrs.colspan,e+this.$headCell.nodeAfter.attrs.colspan)==b.width}eq(b){return b instanceof a&&b.$anchorCell.pos==this.$anchorCell.pos&&b.$headCell.pos==this.$headCell.pos}static rowSelection(b,c=b){let d=b.node(-1),e=io.get(d),f=b.start(-1),g=e.findCell(b.pos-f),h=e.findCell(c.pos-f),i=b.node(0);return g.left<=h.left?(g.left>0&&(b=i.resolve(f+e.map[g.top*e.width])),h.right<e.width&&(c=i.resolve(f+e.map[e.width*(h.top+1)-1]))):(h.left>0&&(c=i.resolve(f+e.map[h.top*e.width])),g.right<e.width&&(b=i.resolve(f+e.map[e.width*(g.top+1)-1]))),new a(b,c)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(b,c){return new a(b.resolve(c.anchor),b.resolve(c.head))}static create(b,c,d=c){return new a(b.resolve(c),b.resolve(d))}getBookmark(){return new iA(this.$anchorCell.pos,this.$headCell.pos)}};iz.prototype.visible=!1,fm.jsonID("cell",iz);var iA=class a{constructor(a,b){this.anchor=a,this.head=b}map(b){return new a(b.map(this.anchor),b.map(this.head))}resolve(a){let b=a.resolve(this.anchor),c=a.resolve(this.head);return"row"==b.parent.type.spec.tableRole&&"row"==c.parent.type.spec.tableRole&&b.index()<b.parent.childCount&&c.index()<c.parent.childCount&&iv(b,c)?new iz(b,c):fm.near(c,1)}};function iB(a){if(!(a.selection instanceof iz))return null;let b=[];return a.selection.forEachCell((a,c)=>{b.push(hI.node(c,c+a.nodeSize,{class:"selectedCell"}))}),hL.create(a.doc,b)}let iC=new fH("fix-tables");function iD(a,b){let c,d=(b,d)=>{"table"==b.type.spec.tableRole&&(c=function(a,b,c,d){let e,f,g=io.get(b);if(!g.problems)return d;d||(d=a.tr);let h=[];for(let a=0;a<g.height;a++)h.push(0);for(let a=0;a<g.problems.length;a++){let e=g.problems[a];if("collision"==e.type){let a=b.nodeAt(e.pos);if(!a)continue;let f=a.attrs;for(let a=0;a<f.rowspan;a++)h[e.row+a]+=e.n;d.setNodeMarkup(d.mapping.map(c+1+e.pos),null,ix(f,f.colspan-e.n,e.n))}else if("missing"==e.type)h[e.row]+=e.n;else if("overlong_rowspan"==e.type){let a=b.nodeAt(e.pos);if(!a)continue;d.setNodeMarkup(d.mapping.map(c+1+e.pos),null,{...a.attrs,rowspan:a.attrs.rowspan-e.n})}else if("colwidth mismatch"==e.type){let a=b.nodeAt(e.pos);if(!a)continue;d.setNodeMarkup(d.mapping.map(c+1+e.pos),null,{...a.attrs,colwidth:e.colwidth})}else if("zero_sized"==e.type){let a=d.mapping.map(c);d.delete(a,a+b.nodeSize)}}for(let a=0;a<h.length;a++)h[a]&&(null==e&&(e=a),f=a);for(let i=0,j=c+1;i<g.height;i++){let c=b.child(i),g=j+c.nodeSize,k=h[i];if(k>0){let b="cell";c.firstChild&&(b=c.firstChild.type.spec.tableRole);let h=[];for(let c=0;c<k;c++){let c=ip(a.schema)[b].createAndFill();c&&h.push(c)}let l=(0==i||e==i-1)&&f==i?j+1:g-1;d.insert(d.mapping.map(l),h)}j=g}return d.setMeta(iC,{fixTables:!0})}(a,b,d,c))};return b?b.doc!=a.doc&&function a(b,c,d,e){let f=b.childCount,g=c.childCount;d:for(let h=0,i=0;h<g;h++){let g=c.child(h);for(let a=i,c=Math.min(f,h+3);a<c;a++)if(b.child(a)==g){i=a+1,d+=g.nodeSize;continue d}e(g,d),i<f&&b.child(i).sameMarkup(g)?a(b.child(i),g,d+1,e):g.nodesBetween(0,g.content.size,e,d+1),d+=g.nodeSize}}(b.doc,a.doc,0,d):a.doc.descendants(d),c}function iE(a){let b=io.get(a),c=[],d=b.height,e=b.width;for(let f=0;f<d;f++){let d=[];for(let c=0;c<e;c++){let g=f*e+c,h=b.map[g];if(f>0){let a=g-e;if(h===b.map[a]){d.push(null);continue}}if(c>0){let a=g-1;if(h===b.map[a]){d.push(null);continue}}d.push(a.nodeAt(h))}c.push(d)}return c}function iF(a,b){let c=[],d=io.get(a),e=d.height,f=d.width;for(let g=0;g<e;g++){let e=a.child(g),h=[];for(let c=0;c<f;c++){let e=b[g][c];if(!e)continue;let f=d.map[g*d.width+c],i=a.nodeAt(f);if(!i)continue;let j=i.type.createChecked(e.attrs,e.content,e.marks);h.push(j)}let i=e.type.createChecked(e.attrs,h,e.marks);c.push(i)}return a.type.createChecked(a.attrs,c,a.marks)}function iG(a,b,c,d){let e,f=b[0]>c[0]?-1:1,g=a.splice(b[0],b.length),h=+(g.length%2==0);return e=-1===d&&1===f?c[0]-1:1===d&&-1===f?c[c.length-1]-h+1:-1===f?c[0]:c[c.length-1]-h,a.splice(e,0,...g),a}function iH(a){var b=a;for(let a=b.depth;a>=0;a-=1){let c=b.node(a);if((a=>"table"===a.type.spec.tableRole)(c))return{node:c,pos:0===a?0:b.before(a),start:b.start(a),depth:a}}return null}function iI(a,b){let c=iH(b.$from);if(!c)return;let d=io.get(c.node);if(!(a<0)&&!(a>d.width-1))return d.cellsInRect({left:a,right:a+1,top:0,bottom:d.height}).map(a=>{let b=c.node.nodeAt(a),d=a+c.start;return{pos:d,start:d+1,node:b,depth:c.depth+2}})}function iJ(a,b){let c=iH(b.$from);if(!c)return;let d=io.get(c.node);if(!(a<0)&&!(a>d.height-1))return d.cellsInRect({left:0,right:d.width,top:a,bottom:a+1}).map(a=>{let b=c.node.nodeAt(a),d=a+c.start;return{pos:d,start:d+1,node:b,depth:c.depth+2}})}function iK(a,b,c=b){let d,e=b,f=c;for(let c=b;c>=0;c--){let b=iI(c,a.selection);b&&b.forEach(a=>{let b=a.node.attrs.colspan+c-1;b>=e&&(e=c),b>f&&(f=b)})}for(let c=b;c<=f;c++){let b=iI(c,a.selection);b&&b.forEach(a=>{let b=a.node.attrs.colspan+c-1;a.node.attrs.colspan>1&&b>f&&(f=b)})}let g=[];for(let b=e;b<=f;b++){let c=iI(b,a.selection);c&&c.length>0&&g.push(b)}e=g[0],f=g[g.length-1];let h=iI(e,a.selection),i=iJ(0,a.selection);if(!h||!i)return;let j=a.doc.resolve(h[h.length-1].pos);for(let b=f;b>=e;b--){let c=iI(b,a.selection);if(c&&c.length>0){for(let a=i.length-1;a>=0;a--)if(i[a].pos===c[0].pos){d=c[0];break}if(d)break}}if(d)return{$anchor:j,$head:a.doc.resolve(d.pos),indexes:g}}function iL(a,b,c=b){let d,e=b,f=c;for(let c=b;c>=0;c--){let b=iJ(c,a.selection);b&&b.forEach(a=>{let b=a.node.attrs.rowspan+c-1;b>=e&&(e=c),b>f&&(f=b)})}for(let c=b;c<=f;c++){let b=iJ(c,a.selection);b&&b.forEach(a=>{let b=a.node.attrs.rowspan+c-1;a.node.attrs.rowspan>1&&b>f&&(f=b)})}let g=[];for(let b=e;b<=f;b++){let c=iJ(b,a.selection);c&&c.length>0&&g.push(b)}e=g[0],f=g[g.length-1];let h=iJ(e,a.selection),i=iI(0,a.selection);if(!h||!i)return;let j=a.doc.resolve(h[h.length-1].pos);for(let b=f;b>=e;b--){let c=iJ(b,a.selection);if(c&&c.length>0){for(let a=i.length-1;a>=0;a--)if(i[a].pos===c[0].pos){d=c[0];break}if(d)break}}if(d)return{$anchor:j,$head:a.doc.resolve(d.pos),indexes:g}}function iM(a){return a[0].map((b,c)=>a.map(a=>a[c]))}function iN(a){let b=a.selection,c=it(a),d=c.node(-1),e=c.start(-1),f=io.get(d);return{...b instanceof iz?f.rectBetween(b.$anchorCell.pos-e,b.$headCell.pos-e):f.findCell(c.pos-e),tableStart:e,map:f,table:d}}function iO(a,{map:b,tableStart:c,table:d},e){let f=e>0?-1:0;(function(a,b,c){let d=ip(b.type.schema).header_cell;for(let e=0;e<a.height;e++)if(b.nodeAt(a.map[c+e*a.width]).type!=d)return!1;return!0})(b,d,e+f)&&(f=0==e||e==b.width?null:0);for(let g=0;g<b.height;g++){let h=g*b.width+e;if(e>0&&e<b.width&&b.map[h-1]==b.map[h]){let f=b.map[h],i=d.nodeAt(f);a.setNodeMarkup(a.mapping.map(c+f),null,iy(i.attrs,e-b.colCount(f))),g+=i.attrs.rowspan-1}else{let i=null==f?ip(d.type.schema).cell:d.nodeAt(b.map[h+f]).type,j=b.positionAt(g,e,d);a.insert(a.mapping.map(c+j),i.createAndFill())}}return a}function iP(a,{map:b,tableStart:c,table:d},e){let f=c;for(let a=0;a<e;a++)f+=d.child(a).nodeSize;let g=[],h=e>0?-1:0;(function(a,b,c){var d;let e=ip(b.type.schema).header_cell;for(let f=0;f<a.width;f++)if((null==(d=b.nodeAt(a.map[f+c*a.width]))?void 0:d.type)!=e)return!1;return!0})(b,d,e+h)&&(h=0==e||e==b.height?null:0);for(let f=0,j=b.width*e;f<b.width;f++,j++)if(e>0&&e<b.height&&b.map[j]==b.map[j-b.width]){let e=b.map[j],g=d.nodeAt(e).attrs;a.setNodeMarkup(c+e,null,{...g,rowspan:g.rowspan+1}),f+=g.colspan-1}else{var i;let a=null==h?ip(d.type.schema).cell:null==(i=d.nodeAt(b.map[j+h*b.width]))?void 0:i.type,c=null==a?void 0:a.createAndFill();c&&g.push(c)}return a.insert(f,ip(d.type.schema).row.create(null,g)),a}function iQ(a){let b=a.content;return 1==b.childCount&&b.child(0).isTextblock&&0==b.child(0).childCount}function iR(a,b){let c=a.selection;if(!(c instanceof iz)||c.$anchorCell.pos==c.$headCell.pos)return!1;let d=iN(a),{map:e}=d;if(function({width:a,height:b,map:c},d){let e=d.top*a+d.left,f=e,g=(d.bottom-1)*a+d.left,h=e+(d.right-d.left-1);for(let b=d.top;b<d.bottom;b++){if(d.left>0&&c[f]==c[f-1]||d.right<a&&c[h]==c[h+1])return!0;f+=a,h+=a}for(let f=d.left;f<d.right;f++){if(d.top>0&&c[e]==c[e-a]||d.bottom<b&&c[g]==c[g+a])return!0;e++,g++}return!1}(e,d))return!1;if(b){let c,f,g=a.tr,h={},i=d$.empty;for(let a=d.top;a<d.bottom;a++)for(let b=d.left;b<d.right;b++){let j=e.map[a*e.width+b],k=d.table.nodeAt(j);if(!h[j]&&k)if(h[j]=!0,null==c)c=j,f=k;else{iQ(k)||(i=i.append(k.content));let a=g.mapping.map(j+d.tableStart);g.delete(a,a+k.nodeSize)}}if(null==c||null==f)return!0;if(g.setNodeMarkup(c+d.tableStart,null,{...iy(f.attrs,f.attrs.colspan,d.right-d.left-f.attrs.colspan),rowspan:d.bottom-d.top}),i.size>0){let a=c+1+f.content.size,b=iQ(f)?c+1:a;g.replaceWith(b+d.tableStart,a+d.tableStart,i)}g.setSelection(new iz(g.doc.resolve(c+d.tableStart))),b(g)}return!0}function iS(a,b){var c;let d=ip(a.schema);return(c=({node:a})=>d[a.type.spec.tableRole],(a,b)=>{let d,e,f=a.selection;if(f instanceof iz){if(f.$anchorCell.pos!=f.$headCell.pos)return!1;d=f.$anchorCell.nodeAfter,e=f.$anchorCell.pos}else{var g;if(!(d=function(a){for(let b=a.depth;b>0;b--){let c=a.node(b).type.spec.tableRole;if("cell"===c||"header_cell"===c)return a.node(b)}return null}(f.$from)))return!1;e=null==(g=ir(f.$from))?void 0:g.pos}if(null==d||null==e||1==d.attrs.colspan&&1==d.attrs.rowspan)return!1;if(b){let g,h=d.attrs,i=[],j=h.colwidth;h.rowspan>1&&(h={...h,rowspan:1}),h.colspan>1&&(h={...h,colspan:1});let k=iN(a),l=a.tr;for(let a=0;a<k.right-k.left;a++)i.push(j?{...h,colwidth:j&&j[a]?[j[a]]:null}:h);for(let a=k.top;a<k.bottom;a++){let b=k.map.positionAt(a,k.left,k.table);a==k.top&&(b+=d.nodeSize);for(let e=k.left,f=0;e<k.right;e++,f++)(e!=k.left||a!=k.top)&&l.insert(g=l.mapping.map(b+k.tableStart,1),c({node:d,row:a,col:e}).createAndFill(i[f]))}l.setNodeMarkup(e,c({node:d,row:k.top,col:k.left}),i[0]),f instanceof iz&&l.setSelection(new iz(l.doc.resolve(f.$anchorCell.pos),g?l.doc.resolve(g):void 0)),b(l)}return!0})(a,b)}function iT(a,b,c){let d=b.map.cellsInRect({left:0,top:0,right:"row"==a?b.map.width:1,bottom:"column"==a?b.map.height:1});for(let a=0;a<d.length;a++){let e=b.table.nodeAt(d[a]);if(e&&e.type!==c.header_cell)return!1}return!0}function iU(a,b){if((b=b||{useDeprecatedLogic:!1}).useDeprecatedLogic)return function(b,c){if(!is(b))return!1;if(c){let d=ip(b.schema),e=iN(b),f=b.tr,g=e.map.cellsInRect("column"==a?{left:e.left,top:0,right:e.right,bottom:e.map.height}:"row"==a?{left:0,top:e.top,right:e.map.width,bottom:e.bottom}:e),h=g.map(a=>e.table.nodeAt(a));for(let a=0;a<g.length;a++)h[a].type==d.header_cell&&f.setNodeMarkup(e.tableStart+g[a],d.cell,h[a].attrs);if(0===f.steps.length)for(let a=0;a<g.length;a++)f.setNodeMarkup(e.tableStart+g[a],d.header_cell,h[a].attrs);c(f)}return!0};return function(b,c){if(!is(b))return!1;if(c){let d=ip(b.schema),e=iN(b),f=b.tr,g=iT("row",e,d),h=iT("column",e,d),i=+("column"===a?!!g:"row"===a&&!!h),j="column"==a?{left:0,top:i,right:1,bottom:e.map.height}:"row"==a?{left:i,top:0,right:e.map.width,bottom:1}:e,k="column"==a?h?d.cell:d.header_cell:"row"==a?g?d.cell:d.header_cell:d.cell;e.map.cellsInRect(j).forEach(a=>{let b=a+e.tableStart,c=f.doc.nodeAt(b);c&&f.setNodeMarkup(b,k,c.attrs)}),c(f)}return!0}}iU("row",{useDeprecatedLogic:!0}),iU("column",{useDeprecatedLogic:!0});let iV=iU("cell",{useDeprecatedLogic:!0});function iW(a){return function(b,c){if(!is(b))return!1;let d=function(a,b){if(b<0){let b=a.nodeBefore;if(b)return a.pos-b.nodeSize;for(let b=a.index(-1)-1,c=a.before();b>=0;b--){let d=a.node(-1).child(b),e=d.lastChild;if(e)return c-1-e.nodeSize;c-=d.nodeSize}}else{if(a.index()<a.parent.childCount-1)return a.pos+a.nodeAfter.nodeSize;let b=a.node(-1);for(let c=a.indexAfter(-1),d=a.after();c<b.childCount;c++){let a=b.child(c);if(a.childCount)return d+1;d+=a.nodeSize}}return null}(it(b),a);if(null==d)return!1;if(c){let a=b.doc.resolve(d);c(b.tr.setSelection(fq.between(a,a.node(0).resolve(a.pos+a.nodeAfter.nodeSize))).scrollIntoView())}return!0}}function iX(a,b){let c=a.selection;if(!(c instanceof iz))return!1;if(b){let d=a.tr,e=ip(a.schema).cell.createAndFill().content;c.forEachCell((a,b)=>{a.content.eq(e)||d.replace(d.mapping.map(b+1),d.mapping.map(b+a.nodeSize-1),new d4(e,0,0))}),d.docChanged&&b(d)}return!0}function iY(a,b){let c=a.createAndFill();return new fk(c).replace(0,c.content.size,b).doc}function iZ(a,b,c,d,e,f,g,h){if(0==g||g==b.height)return!1;let i=!1;for(let j=e;j<f;j++){let e=g*b.width+j,f=b.map[e];if(b.map[e-b.width]==f){i=!0;let e=c.nodeAt(f),{top:k,left:l}=b.findCell(f);a.setNodeMarkup(a.mapping.slice(h).map(f+d),null,{...e.attrs,rowspan:g-k}),a.insert(a.mapping.slice(h).map(b.positionAt(g,l,c)),e.type.createAndFill({...e.attrs,rowspan:k+e.attrs.rowspan-g})),j+=e.attrs.colspan-1}}return i}function i$(a,b,c,d,e,f,g,h){if(0==g||g==b.width)return!1;let i=!1;for(let j=e;j<f;j++){let e=j*b.width+g,f=b.map[e];if(b.map[e-1]==f){i=!0;let e=c.nodeAt(f),k=b.colCount(f),l=a.mapping.slice(h).map(f+d);a.setNodeMarkup(l,null,ix(e.attrs,g-k,e.attrs.colspan-(g-k))),a.insert(l+e.nodeSize,e.type.createAndFill(ix(e.attrs,0,g-k))),j+=e.attrs.rowspan-1}}return i}function i_(a,b,c,d,e){let f=c?a.doc.nodeAt(c-1):a.doc;if(!f)throw Error("No table found");let g=io.get(f),{top:h,left:i}=d,j=i+e.width,k=h+e.height,l=a.tr,m=0;function n(){if(!(f=c?l.doc.nodeAt(c-1):l.doc))throw Error("No table found");g=io.get(f),m=l.mapping.maps.length}(function(a,b,c,d,e,f){let g,h,i=ip(a.doc.type.schema);if(e>b.width)for(let f=0,j=0;f<b.height;f++){let k,l=c.child(f);j+=l.nodeSize;let m=[];k=null==l.lastChild||l.lastChild.type==i.cell?g||(g=i.cell.createAndFill()):h||(h=i.header_cell.createAndFill());for(let a=b.width;a<e;a++)m.push(k);a.insert(a.mapping.slice(0).map(j-1+d),m)}if(f>b.height){let j=[];for(let a=0,d=(b.height-1)*b.width;a<Math.max(b.width,e);a++){let e=!(a>=b.width)&&c.nodeAt(b.map[d+a]).type==i.header_cell;j.push(e?h||(h=i.header_cell.createAndFill()):g||(g=i.cell.createAndFill()))}let k=i.row.create(null,d$.from(j)),l=[];for(let a=b.height;a<f;a++)l.push(k);a.insert(a.mapping.slice(0).map(d+c.nodeSize-2),l)}return!!(g||h)})(l,g,f,c,j,k)&&n(),iZ(l,g,f,c,i,j,h,m)&&n(),iZ(l,g,f,c,i,j,k,m)&&n(),i$(l,g,f,c,h,k,i,m)&&n(),i$(l,g,f,c,h,k,j,m)&&n();for(let a=h;a<k;a++){let b=g.positionAt(a,i,f),d=g.positionAt(a,j,f);l.replace(l.mapping.slice(m).map(b+c),l.mapping.slice(m).map(d+c),new d4(e.rows[a-h],0,0))}n(),l.setSelection(new iz(l.doc.resolve(c+g.positionAt(h,i,f)),l.doc.resolve(c+g.positionAt(k-1,j-1,f)))),b(l)}let i0=im({ArrowLeft:i2("horiz",-1),ArrowRight:i2("horiz",1),ArrowUp:i2("vert",-1),ArrowDown:i2("vert",1),"Shift-ArrowLeft":i3("horiz",-1),"Shift-ArrowRight":i3("horiz",1),"Shift-ArrowUp":i3("vert",-1),"Shift-ArrowDown":i3("vert",1),Backspace:iX,"Mod-Backspace":iX,Delete:iX,"Mod-Delete":iX});function i1(a,b,c){return!c.eq(a.selection)&&(b&&b(a.tr.setSelection(c).scrollIntoView()),!0)}function i2(a,b){return(c,d,e)=>{if(!e)return!1;let f=c.selection;if(f instanceof iz)return i1(c,d,fm.near(f.$headCell,b));if("horiz"!=a&&!f.empty)return!1;let g=i7(e,a,b);if(null==g)return!1;if("horiz"==a)return i1(c,d,fm.near(c.doc.resolve(f.head+b),b));{let e,f=c.doc.resolve(g),h=iw(f,a,b);return e=h?fm.near(h,1):b<0?fm.near(c.doc.resolve(f.before(-1)),-1):fm.near(c.doc.resolve(f.after(-1)),1),i1(c,d,e)}}}function i3(a,b){return(c,d,e)=>{let f;if(!e)return!1;let g=c.selection;if(g instanceof iz)f=g;else{let d=i7(e,a,b);if(null==d)return!1;f=new iz(c.doc.resolve(d))}let h=iw(f.$headCell,a,b);return!!h&&i1(c,d,new iz(f.$anchorCell,h))}}function i4(a,b){let c=ir(a.state.doc.resolve(b));return!!c&&(a.dispatch(a.state.tr.setSelection(new iz(c))),!0)}function i5(a,b,c){if(!is(a.state))return!1;let d=function(a){if(0===a.size)return null;let{content:b,openStart:c,openEnd:d}=a;for(;1==b.childCount&&(c>0&&d>0||"table"==b.child(0).type.spec.tableRole);)c--,d--,b=b.child(0).content;let e=b.child(0),f=e.type.spec.tableRole,g=e.type.schema,h=[];if("row"==f)for(let a=0;a<b.childCount;a++){let e=b.child(a).content,f=a?0:Math.max(0,c-1),i=a<b.childCount-1?0:Math.max(0,d-1);(f||i)&&(e=iY(ip(g).row,new d4(e,f,i)).content),h.push(e)}else{if("cell"!=f&&"header_cell"!=f)return null;h.push(c||d?iY(ip(g).row,new d4(b,c,d)).content:b)}return function(a,b){let c=[];for(let a=0;a<b.length;a++){let d=b[a];for(let b=d.childCount-1;b>=0;b--){let{rowspan:e,colspan:f}=d.child(b).attrs;for(let b=a;b<a+e;b++)c[b]=(c[b]||0)+f}}let d=0;for(let a=0;a<c.length;a++)d=Math.max(d,c[a]);for(let e=0;e<c.length;e++)if(e>=b.length&&b.push(d$.empty),c[e]<d){let f=ip(a).cell.createAndFill(),g=[];for(let a=c[e];a<d;a++)g.push(f);b[e]=b[e].append(d$.from(g))}return{height:b.length,width:d,rows:b}}(g,h)}(c),e=a.state.selection;if(e instanceof iz){d||(d={width:1,height:1,rows:[d$.from(iY(ip(a.state.schema).cell,c))]});let b=e.$anchorCell.node(-1),f=e.$anchorCell.start(-1),g=io.get(b).rectBetween(e.$anchorCell.pos-f,e.$headCell.pos-f);return d=function({width:a,height:b,rows:c},d,e){if(a!=d){let b=[],e=[];for(let a=0;a<c.length;a++){let f=c[a],g=[];for(let c=b[a]||0,e=0;c<d;e++){let h=f.child(e%f.childCount);c+h.attrs.colspan>d&&(h=h.type.createChecked(ix(h.attrs,h.attrs.colspan,c+h.attrs.colspan-d),h.content)),g.push(h),c+=h.attrs.colspan;for(let c=1;c<h.attrs.rowspan;c++)b[a+c]=(b[a+c]||0)+h.attrs.colspan}e.push(d$.from(g))}c=e,a=d}if(b!=e){let a=[];for(let d=0,f=0;d<e;d++,f++){let g=[],h=c[f%b];for(let a=0;a<h.childCount;a++){let b=h.child(a);d+b.attrs.rowspan>e&&(b=b.type.create({...b.attrs,rowspan:Math.max(1,e-b.attrs.rowspan)},b.content)),g.push(b)}a.push(d$.from(g))}c=a,b=e}return{width:a,height:b,rows:c}}(d,g.right-g.left,g.bottom-g.top),i_(a.state,a.dispatch,f,g,d),!0}if(!d)return!1;{let b=it(a.state),c=b.start(-1);return i_(a.state,a.dispatch,c,io.get(b.node(-1)).findCell(b.pos-c),d),!0}}function i6(a,b){var c;let d;if(0!=b.button||b.ctrlKey||b.metaKey)return;let e=i8(a,b.target);if(b.shiftKey&&a.state.selection instanceof iz)f(a.state.selection.$anchorCell,b),b.preventDefault();else if(b.shiftKey&&e&&null!=(d=ir(a.state.selection.$anchor))&&(null==(c=i9(a,b))?void 0:c.pos)!=d.pos)f(d,b),b.preventDefault();else if(!e)return;function f(b,c){let d=i9(a,c),e=null==iq.getState(a.state);if(!d||!iv(b,d))if(!e)return;else d=b;let f=new iz(b,d);if(e||!a.state.selection.eq(f)){let c=a.state.tr.setSelection(f);e&&c.setMeta(iq,b.pos),a.dispatch(c)}}function g(){a.root.removeEventListener("mouseup",g),a.root.removeEventListener("dragstart",g),a.root.removeEventListener("mousemove",h),null!=iq.getState(a.state)&&a.dispatch(a.state.tr.setMeta(iq,-1))}function h(c){let d,h=iq.getState(a.state);if(null!=h)d=a.state.doc.resolve(h);else if(i8(a,c.target)!=e&&!(d=i9(a,b)))return g();d&&f(d,c)}a.root.addEventListener("mouseup",g),a.root.addEventListener("dragstart",g),a.root.addEventListener("mousemove",h)}function i7(a,b,c){if(!(a.state.selection instanceof fq))return null;let{$head:d}=a.state.selection;for(let e=d.depth-1;e>=0;e--){let f=d.node(e);if((c<0?d.index(e):d.indexAfter(e))!=(c<0?0:f.childCount))break;if("cell"==f.type.spec.tableRole||"header_cell"==f.type.spec.tableRole){let f=d.before(e),g="vert"==b?c>0?"down":"up":c>0?"right":"left";return a.endOfTextblock(g)?f:null}}return null}function i8(a,b){for(;b&&b!=a.dom;b=b.parentNode)if("TD"==b.nodeName||"TH"==b.nodeName)return b;return null}function i9(a,b){let c=a.posAtCoords({left:b.clientX,top:b.clientY});if(!c)return null;let{inside:d,pos:e}=c;return d>=0&&ir(a.state.doc.resolve(d))||ir(a.state.doc.resolve(e))}var ja=class{constructor(a,b){this.node=a,this.defaultCellMinWidth=b,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${b}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),jb(a,this.colgroup,this.table,b),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(a){return a.type==this.node.type&&(this.node=a,jb(a,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(a){return"attributes"==a.type&&(a.target==this.table||this.colgroup.contains(a.target))}};function jb(a,b,c,d,e,f){let g=0,h=!0,i=b.firstChild,j=a.firstChild;if(j){for(let a=0,c=0;a<j.childCount;a++){let{colspan:k,colwidth:l}=j.child(a).attrs;for(let a=0;a<k;a++,c++){let j=e==c?f:l&&l[a],k=j?j+"px":"";if(g+=j||d,j||(h=!1),i)i.style.width!=k&&(i.style.width=k),i=i.nextSibling;else{let a=document.createElement("col");a.style.width=k,b.appendChild(a)}}}for(;i;){var k;let a=i.nextSibling;null==(k=i.parentNode)||k.removeChild(i),i=a}h?(c.style.width=g+"px",c.style.minWidth=""):(c.style.width="",c.style.minWidth=g+"px")}}let jc=new fH("tableColumnResizing");var jd=class a{constructor(a,b){this.activeHandle=a,this.dragging=b}apply(b){let c=b.getMeta(jc);if(c&&null!=c.setHandle)return new a(c.setHandle,!1);if(c&&void 0!==c.setDragging)return new a(this.activeHandle,c.setDragging);if(this.activeHandle>-1&&b.docChanged){let c=b.mapping.map(this.activeHandle,-1);return iu(b.doc.resolve(c))||(c=-1),new a(c,this.dragging)}return this}};function je(a,b,c,d){let e=a.posAtCoords({left:b.clientX+("right"==c?-d:d),top:b.clientY});if(!e)return -1;let{pos:f}=e,g=ir(a.state.doc.resolve(f));if(!g)return -1;if("right"==c)return g.pos;let h=io.get(g.node(-1)),i=g.start(-1),j=h.map.indexOf(g.pos-i);return j%h.width==0?-1:i+h.map[j-1]}function jf(a,b,c){let d=b.clientX-a.startX;return Math.max(c,a.startWidth+d)}function jg(a,b){a.dispatch(a.state.tr.setMeta(jc,{setHandle:b}))}function jh(a,b,c,d){let e=a.state.doc.resolve(b),f=e.node(-1),g=e.start(-1),h=io.get(f).colCount(e.pos-g)+e.nodeAfter.attrs.colspan-1,i=a.domAtPos(e.start(-1)).node;for(;i&&"TABLE"!=i.nodeName;)i=i.parentNode;i&&jb(f,i.firstChild,i,d,h,c)}var ji=p,jj=a.i(985209);let jk=(a,b)=>!a.selection.empty&&(b&&b(a.tr.deleteSelection().scrollIntoView()),!0);function jl(a,b){let{$cursor:c}=a.selection;return c&&(b?b.endOfTextblock("backward",a):!(c.parentOffset>0))?c:null}let jm=(a,b,c)=>{let d=jl(a,c);if(!d)return!1;let e=jq(d);if(!e){let c=d.blockRange(),e=c&&e_(c);return null!=e&&(b&&b(a.tr.lift(c,e).scrollIntoView()),!0)}let f=e.nodeBefore;if(jA(a,e,b,-1))return!0;if(0==d.parent.content.size&&(jo(f,"end")||fs.isSelectable(f)))for(let c=d.depth;;c--){let g=e9(a.doc,d.before(c),d.after(c),d4.empty);if(g&&g.slice.size<g.to-g.from){if(b){let c=a.tr.step(g);c.setSelection(jo(f,"end")?fm.findFrom(c.doc.resolve(c.mapping.map(e.pos,-1)),-1):fs.create(c.doc,e.pos-f.nodeSize)),b(c.scrollIntoView())}return!0}if(1==c||d.node(c-1).childCount>1)break}return!!f.isAtom&&e.depth==d.depth-1&&(b&&b(a.tr.delete(e.pos-f.nodeSize,e.pos).scrollIntoView()),!0)};function jn(a,b,c){let d=b.nodeBefore,e=b.pos-1;for(;!d.isTextblock;e--){if(d.type.spec.isolating)return!1;let a=d.lastChild;if(!a)return!1;d=a}let f=b.nodeAfter,g=b.pos+1;for(;!f.isTextblock;g++){if(f.type.spec.isolating)return!1;let a=f.firstChild;if(!a)return!1;f=a}let h=e9(a.doc,e,g,d4.empty);if(!h||h.from!=e||h instanceof eX&&h.slice.size>=g-e)return!1;if(c){let b=a.tr.step(h);b.setSelection(fq.create(b.doc,e)),c(b.scrollIntoView())}return!0}function jo(a,b,c=!1){for(let d=a;d;d="start"==b?d.firstChild:d.lastChild){if(d.isTextblock)return!0;if(c&&1!=d.childCount)break}return!1}let jp=(a,b,c)=>{let{$head:d,empty:e}=a.selection,f=d;if(!e)return!1;if(d.parent.isTextblock){if(c?!c.endOfTextblock("backward",a):d.parentOffset>0)return!1;f=jq(d)}let g=f&&f.nodeBefore;return!!g&&!!fs.isSelectable(g)&&(b&&b(a.tr.setSelection(fs.create(a.doc,f.pos-g.nodeSize)).scrollIntoView()),!0)};function jq(a){if(!a.parent.type.spec.isolating)for(let b=a.depth-1;b>=0;b--){if(a.index(b)>0)return a.doc.resolve(a.before(b+1));if(a.node(b).type.spec.isolating)break}return null}function jr(a,b){let{$cursor:c}=a.selection;return c&&(b?b.endOfTextblock("forward",a):!(c.parentOffset<c.parent.content.size))?c:null}let js=(a,b,c)=>{let d=jr(a,c);if(!d)return!1;let e=ju(d);if(!e)return!1;let f=e.nodeAfter;if(jA(a,e,b,1))return!0;if(0==d.parent.content.size&&(jo(f,"start")||fs.isSelectable(f))){let c=e9(a.doc,d.before(),d.after(),d4.empty);if(c&&c.slice.size<c.to-c.from){if(b){let d=a.tr.step(c);d.setSelection(jo(f,"start")?fm.findFrom(d.doc.resolve(d.mapping.map(e.pos)),1):fs.create(d.doc,d.mapping.map(e.pos))),b(d.scrollIntoView())}return!0}}return!!f.isAtom&&e.depth==d.depth-1&&(b&&b(a.tr.delete(e.pos,e.pos+f.nodeSize).scrollIntoView()),!0)},jt=(a,b,c)=>{let{$head:d,empty:e}=a.selection,f=d;if(!e)return!1;if(d.parent.isTextblock){if(c?!c.endOfTextblock("forward",a):d.parentOffset<d.parent.content.size)return!1;f=ju(d)}let g=f&&f.nodeAfter;return!!g&&!!fs.isSelectable(g)&&(b&&b(a.tr.setSelection(fs.create(a.doc,f.pos)).scrollIntoView()),!0)};function ju(a){if(!a.parent.type.spec.isolating)for(let b=a.depth-1;b>=0;b--){let c=a.node(b);if(a.index(b)+1<c.childCount)return a.doc.resolve(a.after(b+1));if(c.type.spec.isolating)break}return null}let jv=(a,b)=>{let{$head:c,$anchor:d}=a.selection;return!!c.parent.type.spec.code&&!!c.sameParent(d)&&(b&&b(a.tr.insertText("\n").scrollIntoView()),!0)};function jw(a){for(let b=0;b<a.edgeCount;b++){let{type:c}=a.edge(b);if(c.isTextblock&&!c.hasRequiredAttrs())return c}return null}let jx=(a,b)=>{let{$head:c,$anchor:d}=a.selection;if(!c.parent.type.spec.code||!c.sameParent(d))return!1;let e=c.node(-1),f=c.indexAfter(-1),g=jw(e.contentMatchAt(f));if(!g||!e.canReplaceWith(f,f,g))return!1;if(b){let d=c.after(),e=a.tr.replaceWith(d,d,g.createAndFill());e.setSelection(fm.near(e.doc.resolve(d),1)),b(e.scrollIntoView())}return!0},jy=(a,b)=>{let c=a.selection,{$from:d,$to:e}=c;if(c instanceof fu||d.parent.inlineContent||e.parent.inlineContent)return!1;let f=jw(e.parent.contentMatchAt(e.indexAfter()));if(!f||!f.isTextblock)return!1;if(b){let c=(!d.parentOffset&&e.index()<e.parent.childCount?d:e).pos,g=a.tr.insert(c,f.createAndFill());g.setSelection(fq.create(g.doc,c+1)),b(g.scrollIntoView())}return!0},jz=(a,b)=>{let{$cursor:c}=a.selection;if(!c||c.parent.content.size)return!1;if(c.depth>1&&c.after()!=c.end(-1)){let d=c.before();if(e4(a.doc,d))return b&&b(a.tr.split(d).scrollIntoView()),!0}let d=c.blockRange(),e=d&&e_(d);return null!=e&&(b&&b(a.tr.lift(d,e).scrollIntoView()),!0)};function jA(a,b,c,d){let e,f,g,h=b.nodeBefore,i=b.nodeAfter,j,k,l=h.type.spec.isolating||i.type.spec.isolating;if(!l&&(e=b.nodeBefore,f=b.nodeAfter,g=b.index(),e&&f&&e.type.compatibleContent(f.type)&&(!e.content.size&&b.parent.canReplace(g-1,g)?(c&&c(a.tr.delete(b.pos-e.nodeSize,b.pos).scrollIntoView()),!0):!!b.parent.canReplace(g,g+1)&&!!(f.isTextblock||e5(a.doc,b.pos))&&(c&&c(a.tr.join(b.pos).scrollIntoView()),!0))))return!0;let m=!l&&b.parent.canReplace(b.index(),b.index()+1);if(m&&(j=(k=h.contentMatchAt(h.childCount)).findWrapping(i.type))&&k.matchType(j[0]||i.type).validEnd){if(c){let d=b.pos+i.nodeSize,e=d$.empty;for(let a=j.length-1;a>=0;a--)e=d$.from(j[a].create(null,e));e=d$.from(h.copy(e));let f=a.tr.step(new eY(b.pos-1,d,b.pos,d,new d4(e,1,0),j.length,!0)),g=f.doc.resolve(d+2*j.length);g.nodeAfter&&g.nodeAfter.type==h.type&&e5(f.doc,g.pos)&&f.join(g.pos),c(f.scrollIntoView())}return!0}let n=i.type.spec.isolating||d>0&&l?null:fm.findFrom(b,1),o=n&&n.$from.blockRange(n.$to),p=o&&e_(o);if(null!=p&&p>=b.depth)return c&&c(a.tr.lift(o,p).scrollIntoView()),!0;if(m&&jo(i,"start",!0)&&jo(h,"end")){let d=h,e=[];for(;e.push(d),!d.isTextblock;)d=d.lastChild;let f=i,g=1;for(;!f.isTextblock;f=f.firstChild)g++;if(d.canReplace(d.childCount,d.childCount,f.content)){if(c){let d=d$.empty;for(let a=e.length-1;a>=0;a--)d=d$.from(e[a].copy(d));c(a.tr.step(new eY(b.pos-e.length,b.pos+i.nodeSize,b.pos+g,b.pos+i.nodeSize-g,new d4(d,e.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function jB(a){return function(b,c){let d=b.selection,e=a<0?d.$from:d.$to,f=e.depth;for(;e.node(f).isInline;){if(!f)return!1;f--}return!!e.node(f).isTextblock&&(c&&c(b.tr.setSelection(fq.create(b.doc,a<0?e.start(f):e.end(f)))),!0)}}let jC=jB(-1),jD=jB(1);function jE(a,b=null){return function(c,d){let e=!1;for(let d=0;d<c.selection.ranges.length&&!e;d++){let{$from:{pos:f},$to:{pos:g}}=c.selection.ranges[d];c.doc.nodesBetween(f,g,(d,f)=>{if(e)return!1;if(!(!d.isTextblock||d.hasMarkup(a,b)))if(d.type==a)e=!0;else{let b=c.doc.resolve(f),d=b.index();e=b.parent.canReplaceWith(d,d+1,a)}})}if(!e)return!1;if(d){let e=c.tr;for(let d=0;d<c.selection.ranges.length;d++){let{$from:{pos:f},$to:{pos:g}}=c.selection.ranges[d];e.setBlockType(f,g,a,b)}d(e.scrollIntoView())}return!0}}function jF(...a){return function(b,c,d){for(let e=0;e<a.length;e++)if(a[e](b,c,d))return!0;return!1}}let jG=jF(jk,jm,jp),jH=jF(jk,js,jt),jI={Enter:jF(jv,jy,jz,(a,b)=>{let{$from:c,$to:d}=a.selection;if(a.selection instanceof fs&&a.selection.node.isBlock)return!!c.parentOffset&&!!e4(a.doc,c.pos)&&(b&&b(a.tr.split(c.pos).scrollIntoView()),!0);if(!c.depth)return!1;let e=[],f,g,h=!1,i=!1;for(let a=c.depth;;a--){if(c.node(a).isBlock){let b;h=c.end(a)==c.pos+(c.depth-a),i=c.start(a)==c.pos-(c.depth-a),g=jw(c.node(a-1).contentMatchAt(c.indexAfter(a-1)));e.unshift(b||(h&&g?{type:g}:null)),f=a;break}if(1==a)return!1;e.unshift(null)}let j=a.tr;(a.selection instanceof fq||a.selection instanceof fu)&&j.deleteSelection();let k=j.mapping.map(c.pos),l=e4(j.doc,k,e.length,e);if(l||(e[0]=g?{type:g}:null,l=e4(j.doc,k,e.length,e)),!l)return!1;if(j.split(k,e.length,e),!h&&i&&c.node(f).type!=g){let a=j.mapping.map(c.before(f)),b=j.doc.resolve(a);g&&c.node(f-1).canReplaceWith(b.index(),b.index()+1,g)&&j.setNodeMarkup(j.mapping.map(c.before(f)),g)}return b&&b(j.scrollIntoView()),!0}),"Mod-Enter":jx,Backspace:jG,"Mod-Backspace":jG,"Shift-Backspace":jG,Delete:jH,"Mod-Delete":jH,"Mod-a":(a,b)=>(b&&b(a.tr.setSelection(new fu(a.doc))),!0)},jJ={"Ctrl-h":jI.Backspace,"Alt-Backspace":jI["Mod-Backspace"],"Ctrl-d":jI.Delete,"Ctrl-Alt-Backspace":jI["Mod-Delete"],"Alt-Delete":jI["Mod-Delete"],"Alt-d":jI["Mod-Delete"],"Ctrl-a":jC,"Ctrl-e":jD};for(let a in jI)jJ[a]=jI[a];"u">typeof navigator?/Mac|iP(hone|[oa]d)/.test(navigator.platform):"u">typeof os&&os.platform&&os.platform();var jK=Object.defineProperty,jL=(a,b)=>{for(var c in b)jK(a,c,{get:b[c],enumerable:!0})};function jM(a){let{state:b,transaction:c}=a,{selection:d}=c,{doc:e}=c,{storedMarks:f}=c;return{...b,apply:b.apply.bind(b),applyTransaction:b.applyTransaction.bind(b),plugins:b.plugins,schema:b.schema,reconfigure:b.reconfigure.bind(b),toJSON:b.toJSON.bind(b),get storedMarks(){return f},get selection(){return d},get doc(){return e},get tr(){return d=c.selection,e=c.doc,f=c.storedMarks,c}}}var jN=class{constructor(a){this.editor=a.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=a.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){let{rawCommands:a,editor:b,state:c}=this,{view:d}=b,{tr:e}=c,f=this.buildProps(e);return Object.fromEntries(Object.entries(a).map(([a,b])=>[a,(...a)=>{let c=b(...a)(f);return e.getMeta("preventDispatch")||this.hasCustomState||d.dispatch(e),c}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(a,b=!0){let{rawCommands:c,editor:d,state:e}=this,{view:f}=d,g=[],h=!!a,i=a||e.tr,j=()=>(h||!b||i.getMeta("preventDispatch")||this.hasCustomState||f.dispatch(i),g.every(a=>!0===a)),k={...Object.fromEntries(Object.entries(c).map(([a,c])=>[a,(...a)=>{let d=this.buildProps(i,b),e=c(...a)(d);return g.push(e),k}])),run:j};return k}createCan(a){let{rawCommands:b,state:c}=this,d=a||c.tr,e=this.buildProps(d,!1);return{...Object.fromEntries(Object.entries(b).map(([a,b])=>[a,(...a)=>b(...a)({...e,dispatch:void 0})])),chain:()=>this.createChain(d,!1)}}buildProps(a,b=!0){let{rawCommands:c,editor:d,state:e}=this,{view:f}=d,g={tr:a,editor:d,view:f,state:jM({state:e,transaction:a}),dispatch:b?()=>void 0:void 0,chain:()=>this.createChain(a,b),can:()=>this.createCan(a),get commands(){return Object.fromEntries(Object.entries(c).map(([a,b])=>[a,(...a)=>b(...a)(g)]))}};return g}},jO={};jL(jO,{blur:()=>jP,clearContent:()=>jQ,clearNodes:()=>jR,command:()=>jS,createParagraphNear:()=>jT,cut:()=>jU,deleteCurrentNode:()=>jV,deleteNode:()=>jX,deleteRange:()=>jY,deleteSelection:()=>j$,enter:()=>j_,exitCode:()=>j0,extendMarkRange:()=>j7,first:()=>j8,focus:()=>ke,forEach:()=>kf,insertContent:()=>kg,insertContentAt:()=>kj,joinBackward:()=>km,joinDown:()=>kl,joinForward:()=>kn,joinItemBackward:()=>ko,joinItemForward:()=>kp,joinTextblockBackward:()=>kq,joinTextblockForward:()=>kr,joinUp:()=>kk,keyboardShortcut:()=>kt,lift:()=>kv,liftEmptyBlock:()=>kw,liftListItem:()=>kx,newlineInCode:()=>ky,resetAttributes:()=>kB,scrollIntoView:()=>kC,selectAll:()=>kD,selectNodeBackward:()=>kE,selectNodeForward:()=>kF,selectParentNode:()=>kG,selectTextblockEnd:()=>kH,selectTextblockStart:()=>kI,setContent:()=>kK,setMark:()=>lk,setMeta:()=>ll,setNode:()=>lm,setNodeSelection:()=>ln,setTextDirection:()=>lo,setTextSelection:()=>lp,sinkListItem:()=>lq,splitBlock:()=>ls,splitListItem:()=>lt,toggleList:()=>lw,toggleMark:()=>lx,toggleNode:()=>ly,toggleWrap:()=>lz,undoInputRule:()=>lA,unsetAllMarks:()=>lB,unsetMark:()=>lC,unsetTextDirection:()=>lD,updateAttributes:()=>lE,wrapIn:()=>lF,wrapInList:()=>lG});var jP=()=>({editor:a,view:b})=>(requestAnimationFrame(()=>{var c;a.isDestroyed||(b.dom.blur(),null==(c=null==window?void 0:window.getSelection())||c.removeAllRanges())}),!0),jQ=(a=!0)=>({commands:b})=>b.setContent("",{emitUpdate:a}),jR=()=>({state:a,tr:b,dispatch:c})=>{let{selection:d}=b,{ranges:e}=d;return!c||(e.forEach(({$from:c,$to:d})=>{a.doc.nodesBetween(c.pos,d.pos,(a,c)=>{if(a.type.isText)return;let{doc:d,mapping:e}=b,f=d.resolve(e.map(c)),g=d.resolve(e.map(c+a.nodeSize)),h=f.blockRange(g);if(!h)return;let i=e_(h);if(a.type.isTextblock){let{defaultType:a}=f.parent.contentMatchAt(f.index());b.setNodeMarkup(h.start,a)}(i||0===i)&&b.lift(h,i)})}),!0)},jS=a=>b=>a(b),jT=()=>({state:a,dispatch:b})=>jy(a,b),jU=(a,b)=>({editor:c,tr:d})=>{let{state:e}=c,f=e.doc.slice(a.from,a.to);d.deleteRange(a.from,a.to);let g=d.mapping.map(b);return d.insert(g,f.content),d.setSelection(new fq(d.doc.resolve(Math.max(g-1,0)))),!0},jV=()=>({tr:a,dispatch:b})=>{let{selection:c}=a,d=c.$anchor.node();if(d.content.size>0)return!1;let e=a.selection.$anchor;for(let c=e.depth;c>0;c-=1)if(e.node(c).type===d.type){if(b){let b=e.before(c),d=e.after(c);a.delete(b,d).scrollIntoView()}return!0}return!1};function jW(a,b){if("string"==typeof a){if(!b.nodes[a])throw Error(`There is no node type named '${a}'. Maybe you forgot to add the extension?`);return b.nodes[a]}return a}var jX=a=>({tr:b,state:c,dispatch:d})=>{let e=jW(a,c.schema),f=b.selection.$anchor;for(let a=f.depth;a>0;a-=1)if(f.node(a).type===e){if(d){let c=f.before(a),d=f.after(a);b.delete(c,d).scrollIntoView()}return!0}return!1},jY=a=>({tr:b,dispatch:c})=>{let{from:d,to:e}=a;return c&&b.delete(d,e),!0},jZ=(a,b,c)=>{var d;return!a.parent.isInline||"left"===c&&a.pos>a.start()||"right"===c&&a.pos<a.end()?a.pos:(d=b.nodes[a.parent.type.name].spec).content&&/^text(\*|\+)/.test(d.content)?"left"===c?a.start()-1:a.end()+1:a.pos},j$=()=>({state:a,dispatch:b})=>{var c;let{$from:d,$to:e}=a.selection;if(a.selection.empty)return!1;let{from:f,to:g}={from:jZ(d,c=a.schema,"left"),to:jZ(e,c,"right")};return b&&(a.tr.deleteRange(f,g).scrollIntoView(),b(a.tr)),!0},j_=()=>({commands:a})=>a.keyboardShortcut("Enter"),j0=()=>({state:a,dispatch:b})=>jx(a,b);function j1(a){return"[object RegExp]"===Object.prototype.toString.call(a)}function j2(a,b,c={strict:!0}){let d=Object.keys(b);return!d.length||d.every(d=>c.strict?b[d]===a[d]:j1(b[d])?b[d].test(a[d]):b[d]===a[d])}function j3(a,b,c={}){return a.find(a=>a.type===b&&j2(Object.fromEntries(Object.keys(c).map(b=>[b,a.attrs[b]])),c))}function j4(a,b,c={}){return!!j3(a,b,c)}function j5(a,b,c){if(!a||!b)return;let d=a.parent.childAfter(a.parentOffset);if(d.node&&d.node.marks.some(a=>a.type===b)||(d=a.parent.childBefore(a.parentOffset)),!d.node||!d.node.marks.some(a=>a.type===b))return;if(!c){let a=d.node.marks.find(a=>a.type===b);a&&(c=a.attrs)}if(!j3([...d.node.marks],b,c))return;let e=d.index,f=a.start()+d.offset,g=e+1,h=f+d.node.nodeSize;for(;e>0&&j4([...a.parent.child(e-1).marks],b,c);)e-=1,f-=a.parent.child(e).nodeSize;for(;g<a.parent.childCount&&j4([...a.parent.child(g).marks],b,c);)h+=a.parent.child(g).nodeSize,g+=1;return{from:f,to:h}}function j6(a,b){if("string"==typeof a){if(!b.marks[a])throw Error(`There is no mark type named '${a}'. Maybe you forgot to add the extension?`);return b.marks[a]}return a}var j7=(a,b)=>({tr:c,state:d,dispatch:e})=>{let f=j6(a,d.schema),{doc:g,selection:h}=c,{$from:i,from:j,to:k}=h;if(e){let a=j5(i,f,b);if(a&&a.from<=j&&a.to>=k){let b=fq.create(g,a.from,a.to);c.setSelection(b)}}return!0},j8=a=>b=>{let c="function"==typeof a?a(b):a;for(let a=0;a<c.length;a+=1)if(c[a](b))return!0;return!1};function j9(a){return a instanceof fq}function ka(a=0,b=0,c=0){return Math.min(Math.max(a,b),c)}function kb(a,b=null){if(!b)return null;let c=fm.atStart(a),d=fm.atEnd(a);if("start"===b||!0===b)return c;if("end"===b)return d;let e=c.from,f=d.to;return"all"===b?fq.create(a,ka(0,e,f),ka(a.content.size,e,f)):fq.create(a,ka(b,e,f),ka(b,e,f))}function kc(){return"Android"===navigator.platform||/android/i.test(navigator.userAgent)}function kd(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}var ke=(a=null,b={})=>({editor:c,view:d,tr:e,dispatch:f})=>{b={scrollIntoView:!0,...b};let g=()=>{(kd()||kc())&&d.dom.focus(),"u">typeof navigator&&/^((?!chrome|android).)*safari/i.test(navigator.userAgent)&&!kd()&&!kc()&&d.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{!c.isDestroyed&&(d.focus(),(null==b?void 0:b.scrollIntoView)&&c.commands.scrollIntoView())})};try{if(d.hasFocus()&&null===a||!1===a)return!0}catch{return!1}if(f&&null===a&&!j9(c.state.selection))return g(),!0;let h=kb(e.doc,a)||c.state.selection,i=c.state.selection.eq(h);return f&&(i||e.setSelection(h),i&&e.storedMarks&&e.setStoredMarks(e.storedMarks),g()),!0},kf=(a,b)=>c=>a.every((a,d)=>b(a,{...c,index:d})),kg=(a,b)=>({tr:c,commands:d})=>d.insertContentAt({from:c.selection.from,to:c.selection.to},a,b);function kh(a){throw Error("[tiptap error]: there is no window object available, so this function cannot be used")}function ki(a,b,c){if(a instanceof eh||a instanceof d$)return a;c={slice:!0,parseOptions:{},...c};let d="object"==typeof a&&null!==a,e="string"==typeof a;if(d)try{if(Array.isArray(a)&&a.length>0)return d$.fromArray(a.map(a=>b.nodeFromJSON(a)));let d=b.nodeFromJSON(a);return c.errorOnInvalidContent&&d.check(),d}catch(d){if(c.errorOnInvalidContent)throw Error("[tiptap error]: Invalid JSON content",{cause:d});return console.warn("[tiptap warn]: Invalid content.","Passed value:",a,"Error:",d),ki("",b,c)}if(e){if(c.errorOnInvalidContent){let d=!1,e="",f=new ew({topNode:b.spec.topNode,marks:b.spec.marks,nodes:b.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:a=>(d=!0,e="string"==typeof a?a:a.outerHTML,null)}]}})});if(c.slice?ey.fromSchema(f).parseSlice(kh(a),c.parseOptions):ey.fromSchema(f).parse(kh(a),c.parseOptions),c.errorOnInvalidContent&&d)throw Error("[tiptap error]: Invalid HTML content",{cause:Error(`Invalid element found: ${e}`)})}let d=ey.fromSchema(b);return c.slice?d.parseSlice(kh(a),c.parseOptions).content:d.parse(kh(a),c.parseOptions)}return ki("",b,c)}var kj=(a,b,c)=>({tr:d,dispatch:e,editor:f})=>{var g;if(e){let e,h;c={parseOptions:f.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...c};let i=a=>{f.emit("contentError",{editor:f,error:a,disableCollaboration:()=>{"collaboration"in f.storage&&"object"==typeof f.storage.collaboration&&f.storage.collaboration&&(f.storage.collaboration.isDisabled=!0)}})},j={preserveWhitespace:"full",...c.parseOptions};if(!c.errorOnInvalidContent&&!f.options.enableContentCheck&&f.options.emitContentError)try{ki(b,f.schema,{parseOptions:j,errorOnInvalidContent:!0})}catch(a){i(a)}try{e=ki(b,f.schema,{parseOptions:j,errorOnInvalidContent:null!=(g=c.errorOnInvalidContent)?g:f.options.enableContentCheck})}catch(a){return i(a),!1}let{from:k,to:l}="number"==typeof a?{from:a,to:a}:{from:a.from,to:a.to},m=!0,n=!0;if((!("type"in e)?e:[e]).forEach(a=>{a.check(),m=!!m&&a.isText&&0===a.marks.length,n=!!n&&a.isBlock}),k===l&&n){let{parent:a}=d.doc.resolve(k);!a.isTextblock||a.type.spec.code||a.childCount||(k-=1,l+=1)}if(m){if(Array.isArray(b))h=b.map(a=>a.text||"").join("");else if(b instanceof d$){let a="";b.forEach(b=>{b.text&&(a+=b.text)}),h=a}else h="object"==typeof b&&b&&b.text?b.text:b;d.insertText(h,k,l)}else{h=e;let a=d.doc.resolve(k),b=a.node(),c=0===a.parentOffset,f=b.isText||b.isTextblock,g=b.content.size>0;c&&f&&g&&n&&(k=Math.max(0,k-1)),d.replaceWith(k,l,h)}c.updateSelection&&function(a,b){let c=a.steps.length-1;if(c<b)return;let d=a.steps[c];if(!(d instanceof eX||d instanceof eY))return;let e=a.mapping.maps[c],f=0;e.forEach((a,b,c,d)=>{0===f&&(f=d)}),a.setSelection(fm.near(a.doc.resolve(f),-1))}(d,d.steps.length-1),c.applyInputRules&&d.setMeta("applyInputRules",{from:k,text:h}),c.applyPasteRules&&d.setMeta("applyPasteRules",{from:k,text:h})}return!0},kk=()=>({state:a,dispatch:b})=>((a,b)=>{let c=a.selection,d=c instanceof fs,e;if(d){if(c.node.isTextblock||!e5(a.doc,c.from))return!1;e=c.from}else if(null==(e=e7(a.doc,c.from,-1)))return!1;if(b){let c=a.tr.join(e);d&&c.setSelection(fs.create(c.doc,e-a.doc.resolve(e).nodeBefore.nodeSize)),b(c.scrollIntoView())}return!0})(a,b),kl=()=>({state:a,dispatch:b})=>((a,b)=>{let c=a.selection,d;if(c instanceof fs){if(c.node.isTextblock||!e5(a.doc,c.to))return!1;d=c.to}else if(null==(d=e7(a.doc,c.to,1)))return!1;return b&&b(a.tr.join(d).scrollIntoView()),!0})(a,b),km=()=>({state:a,dispatch:b})=>jm(a,b),kn=()=>({state:a,dispatch:b})=>js(a,b),ko=()=>({state:a,dispatch:b,tr:c})=>{try{let d=e7(a.doc,a.selection.$from.pos,-1);if(null==d)return!1;return c.join(d,2),b&&b(c),!0}catch{return!1}},kp=()=>({state:a,dispatch:b,tr:c})=>{try{let d=e7(a.doc,a.selection.$from.pos,1);if(null==d)return!1;return c.join(d,2),b&&b(c),!0}catch{return!1}},kq=()=>({state:a,dispatch:b})=>((a,b,c)=>{let d=jl(a,c);if(!d)return!1;let e=jq(d);return!!e&&jn(a,e,b)})(a,b),kr=()=>({state:a,dispatch:b})=>((a,b,c)=>{let d=jr(a,c);if(!d)return!1;let e=ju(d);return!!e&&jn(a,e,b)})(a,b);function ks(){return"u">typeof navigator&&/Mac/.test(navigator.platform)}var kt=a=>({editor:b,view:c,tr:d,dispatch:e})=>{let f=(function(a){let b,c,d,e,f=a.split(/-(?!$)/),g=f[f.length-1];"Space"===g&&(g=" ");for(let a=0;a<f.length-1;a+=1){let g=f[a];if(/^(cmd|meta|m)$/i.test(g))e=!0;else if(/^a(lt)?$/i.test(g))b=!0;else if(/^(c|ctrl|control)$/i.test(g))c=!0;else if(/^s(hift)?$/i.test(g))d=!0;else if(/^mod$/i.test(g))kd()||ks()?e=!0:c=!0;else throw Error(`Unrecognized modifier name: ${g}`)}return b&&(g=`Alt-${g}`),c&&(g=`Ctrl-${g}`),e&&(g=`Meta-${g}`),d&&(g=`Shift-${g}`),g})(a).split(/-(?!$)/),g=f.find(a=>!["Alt","Ctrl","Meta","Shift"].includes(a)),h=new KeyboardEvent("keydown",{key:"Space"===g?" ":g,altKey:f.includes("Alt"),ctrlKey:f.includes("Ctrl"),metaKey:f.includes("Meta"),shiftKey:f.includes("Shift"),bubbles:!0,cancelable:!0}),i=b.captureTransaction(()=>{c.someProp("handleKeyDown",a=>a(c,h))});return null==i||i.steps.forEach(a=>{let b=a.map(d.mapping);b&&e&&d.maybeStep(b)}),!0};function ku(a,b,c={}){let{from:d,to:e,empty:f}=a.selection,g=b?jW(b,a.schema):null,h=[];a.doc.nodesBetween(d,e,(a,b)=>{if(a.isText)return;let c=Math.max(d,b),f=Math.min(e,b+a.nodeSize);h.push({node:a,from:c,to:f})});let i=e-d,j=h.filter(a=>!g||g.name===a.node.type.name).filter(a=>j2(a.node.attrs,c,{strict:!1}));return f?!!j.length:j.reduce((a,b)=>a+b.to-b.from,0)>=i}var kv=(a,b={})=>({state:c,dispatch:d})=>{let e=jW(a,c.schema);return!!ku(c,e,b)&&((a,b)=>{let{$from:c,$to:d}=a.selection,e=c.blockRange(d),f=e&&e_(e);return null!=f&&(b&&b(a.tr.lift(e,f).scrollIntoView()),!0)})(c,d)},kw=()=>({state:a,dispatch:b})=>jz(a,b),kx=a=>({state:b,dispatch:c})=>{var d;return(d=jW(a,b.schema),function(a,b){let{$from:c,$to:e}=a.selection,f=c.blockRange(e,a=>a.childCount>0&&a.firstChild.type==d);return!!f&&(!b||(c.node(f.depth-1).type==d?function(a,b,c,d){let e=a.tr,f=d.end,g=d.$to.end(d.depth);f<g&&(e.step(new eY(f-1,g,f,g,new d4(d$.from(c.create(null,d.parent.copy())),1,0),1,!0)),d=new ef(e.doc.resolve(d.$from.pos),e.doc.resolve(g),d.depth));let h=e_(d);if(null==h)return!1;e.lift(d,h);let i=e.doc.resolve(e.mapping.map(f,-1)-1);return e5(e.doc,i.pos)&&i.nodeBefore.type==i.nodeAfter.type&&e.join(i.pos),b(e.scrollIntoView()),!0}(a,b,d,f):function(a,b,c){let d=a.tr,e=c.parent;for(let a=c.end,b=c.endIndex-1,f=c.startIndex;b>f;b--)a-=e.child(b).nodeSize,d.delete(a-1,a+1);let f=d.doc.resolve(c.start),g=f.nodeAfter;if(d.mapping.map(c.end)!=c.start+f.nodeAfter.nodeSize)return!1;let h=0==c.startIndex,i=c.endIndex==e.childCount,j=f.node(-1),k=f.index(-1);if(!j.canReplace(k+ +!h,k+1,g.content.append(i?d$.empty:d$.from(e))))return!1;let l=f.pos,m=l+g.nodeSize;return d.step(new eY(l-!!h,m+ +!!i,l+1,m-1,new d4((h?d$.empty:d$.from(e.copy(d$.empty))).append(i?d$.empty:d$.from(e.copy(d$.empty))),+!h,+!i),+!h)),b(d.scrollIntoView()),!0}(a,b,f)))})(b,c)},ky=()=>({state:a,dispatch:b})=>jv(a,b);function kz(a,b){return b.nodes[a]?"node":b.marks[a]?"mark":null}function kA(a,b){let c="string"==typeof b?[b]:b;return Object.keys(a).reduce((b,d)=>(c.includes(d)||(b[d]=a[d]),b),{})}var kB=(a,b)=>({tr:c,state:d,dispatch:e})=>{let f=null,g=null,h=kz("string"==typeof a?a:a.name,d.schema);if(!h)return!1;"node"===h&&(f=jW(a,d.schema)),"mark"===h&&(g=j6(a,d.schema));let i=!1;return c.selection.ranges.forEach(a=>{d.doc.nodesBetween(a.$from.pos,a.$to.pos,(a,d)=>{f&&f===a.type&&(i=!0,e&&c.setNodeMarkup(d,void 0,kA(a.attrs,b))),g&&a.marks.length&&a.marks.forEach(f=>{g===f.type&&(i=!0,e&&c.addMark(d,d+a.nodeSize,g.create(kA(f.attrs,b))))})})}),i},kC=()=>({tr:a,dispatch:b})=>(b&&a.scrollIntoView(),!0),kD=()=>({tr:a,dispatch:b})=>{if(b){let b=new fu(a.doc);a.setSelection(b)}return!0},kE=()=>({state:a,dispatch:b})=>jp(a,b),kF=()=>({state:a,dispatch:b})=>jt(a,b),kG=()=>({state:a,dispatch:b})=>((a,b)=>{let{$from:c,to:d}=a.selection,e,f=c.sharedDepth(d);return 0!=f&&(e=c.before(f),b&&b(a.tr.setSelection(fs.create(a.doc,e))),!0)})(a,b),kH=()=>({state:a,dispatch:b})=>jD(a,b),kI=()=>({state:a,dispatch:b})=>jC(a,b);function kJ(a,b,c={},d={}){return ki(a,b,{slice:!1,parseOptions:c,errorOnInvalidContent:d.errorOnInvalidContent})}var kK=(a,{errorOnInvalidContent:b,emitUpdate:c=!0,parseOptions:d={}}={})=>({editor:e,tr:f,dispatch:g,commands:h})=>{let{doc:i}=f;if("full"!==d.preserveWhitespace){let h=kJ(a,e.schema,d,{errorOnInvalidContent:null!=b?b:e.options.enableContentCheck});return g&&f.replaceWith(0,i.content.size,h).setMeta("preventUpdate",!c),!0}return g&&f.setMeta("preventUpdate",!c),h.insertContentAt({from:0,to:i.content.size},a,{parseOptions:d,errorOnInvalidContent:null!=b?b:e.options.enableContentCheck})};function kL(a,b){let c=j6(b,a.schema),{from:d,to:e,empty:f}=a.selection,g=[];f?(a.storedMarks&&g.push(...a.storedMarks),g.push(...a.selection.$head.marks())):a.doc.nodesBetween(d,e,a=>{g.push(...a.marks)});let h=g.find(a=>a.type.name===c.name);return h?{...h.attrs}:{}}function kM(a,b){let c=new fk(a);return b.forEach(a=>{a.steps.forEach(a=>{c.step(a)})}),c}function kN(a,b){let c=[];return a.descendants((a,d)=>{b(a)&&c.push({node:a,pos:d})}),c}function kO(a,b){for(let c=a.depth;c>0;c-=1){let d=a.node(c);if(b(d))return{pos:c>0?a.before(c):0,start:a.start(c),depth:c,node:d}}}function kP(a){return b=>kO(b.$from,a)}function kQ(a,b,c){return void 0===a.config[b]&&a.parent?kQ(a.parent,b,c):"function"==typeof a.config[b]?a.config[b].bind({...c,parent:a.parent?kQ(a.parent,b,c):null}):a.config[b]}function kR(a){return a.map(a=>{let b={name:a.name,options:a.options,storage:a.storage},c=kQ(a,"addExtensions",b);return c?[a,...kR(c())]:a}).flat(10)}function kS(a,b){let c=eH.fromSchema(b).serializeFragment(a),d=document.implementation.createHTMLDocument().createElement("div");return d.appendChild(c),d.innerHTML}function kT(a){return"function"==typeof a}function kU(a,b,...c){return kT(a)?b?a.bind(b)(...c):a(...c):a}function kV(a){let b=a.filter(a=>"extension"===a.type);return{baseExtensions:b,nodeExtensions:a.filter(a=>"node"===a.type),markExtensions:a.filter(a=>"mark"===a.type)}}function kW(a){let b=[],{nodeExtensions:c,markExtensions:d}=kV(a),e=[...c,...d],f={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1},g=c.filter(a=>"text"!==a.name).map(a=>a.name),h=d.map(a=>a.name),i=[...g,...h];return a.forEach(a=>{let c={name:a.name,options:a.options,storage:a.storage,extensions:e},d=kQ(a,"addGlobalAttributes",c);d&&d().forEach(a=>{(Array.isArray(a.types)?a.types:"*"===a.types?i:"nodes"===a.types?g:"marks"===a.types?h:[]).forEach(c=>{Object.entries(a.attributes).forEach(([a,d])=>{b.push({type:c,name:a,attribute:{...f,...d}})})})})}),e.forEach(a=>{let c={name:a.name,options:a.options,storage:a.storage},d=kQ(a,"addAttributes",c);d&&Object.entries(d()).forEach(([c,d])=>{let e={...f,...d};"function"==typeof(null==e?void 0:e.default)&&(e.default=e.default()),(null==e?void 0:e.isRequired)&&(null==e?void 0:e.default)===void 0&&delete e.default,b.push({type:a.name,name:c,attribute:e})})}),b}function kX(a){let b=[],c=function(a){let b=[],c="",d=!1,e=!1,f=0,g=a.length;for(let h=0;h<g;h+=1){let g=a[h];if("'"===g&&!e){d=!d,c+=g;continue}if('"'===g&&!d){e=!e,c+=g;continue}if(!d&&!e){if("("===g){f+=1,c+=g;continue}if(")"===g&&f>0){f-=1,c+=g;continue}if(";"===g&&0===f){b.push(c),c="";continue}}c+=g}return c&&b.push(c),b}(a||""),d=c.length;for(let a=0;a<d;a+=1){let d=c[a],e=d.indexOf(":");if(-1===e)continue;let f=d.slice(0,e).trim(),g=d.slice(e+1).trim();f&&g&&b.push([f,g])}return b}function kY(...a){return a.filter(a=>!!a).reduce((a,b)=>{let c={...a};return Object.entries(b).forEach(([a,b])=>{if(!c[a]){c[a]=b;return}if("class"===a){let d=b?String(b).split(" "):[],e=c[a]?c[a].split(" "):[],f=d.filter(a=>!e.includes(a));c[a]=[...e,...f].join(" ")}else if("style"===a){let d=new Map([...kX(c[a]),...kX(b)]);c[a]=Array.from(d.entries()).map(([a,b])=>`${a}: ${b}`).join("; ")}else c[a]=b}),c},{})}function kZ(a,b){return b.filter(b=>b.type===a.type.name).filter(a=>a.attribute.rendered).map(b=>b.attribute.renderHTML?b.attribute.renderHTML(a.attrs)||{}:{[b.name]:a.attrs[b.name]}).reduce((a,b)=>kY(a,b),{})}function k$(a,b){return"style"in a?a:{...a,getAttrs:c=>{let d=a.getAttrs?a.getAttrs(c):a.attrs;if(!1===d)return!1;let e=b.reduce((a,b)=>{var d;let e=b.attribute.parseHTML?b.attribute.parseHTML(c):"string"!=typeof(d=c.getAttribute(b.name))?d:d.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(d):"true"===d||"false"!==d&&d;return null==e?a:{...a,[b.name]:e}},{});return{...d,...e}}}}function k_(a){return Object.fromEntries(Object.entries(a).filter(([a,b])=>!("attrs"===a&&function(a={}){return 0===Object.keys(a).length&&a.constructor===Object}(b))&&null!=b))}function k0(a){var b,c;let d={};return!(null==(b=null==a?void 0:a.attribute)?void 0:b.isRequired)&&"default"in((null==a?void 0:a.attribute)||{})&&(d.default=a.attribute.default),(null==(c=null==a?void 0:a.attribute)?void 0:c.validate)!==void 0&&(d.validate=a.attribute.validate),[a.name,d]}function k1(a){return a.sort((a,b)=>{let c=kQ(a,"priority")||100,d=kQ(b,"priority")||100;return c>d?-1:+(c<d)})}function k2(a){var b;let c=k1(kR(a)),d=Array.from(new Set((b=c.map(a=>a.name)).filter((a,c)=>b.indexOf(a)!==c)));return d.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${d.map(a=>`'${a}'`).join(", ")}]. This can lead to issues.`),c}function k3(a,b,c){let{from:d,to:e}=b,{blockSeparator:f="\n\n",textSerializers:g={}}=c||{},h="";return a.nodesBetween(d,e,(a,c,i,j)=>{var k;a.isBlock&&c>d&&(h+=f);let l=null==g?void 0:g[a.type.name];if(l)return i&&(h+=l({node:a,pos:c,parent:i,index:j,range:b})),!1;a.isText&&(h+=null==(k=null==a?void 0:a.text)?void 0:k.slice(Math.max(d,c)-c,e-c))}),h}function k4(a,b){let c={from:0,to:a.content.size};return k3(a,c,b)}function k5(a){return Object.fromEntries(Object.entries(a.nodes).filter(([,a])=>a.spec.toText).map(([a,b])=>[a,b.spec.toText]))}function k6(a,b){let c=kz("string"==typeof b?b:b.name,a.schema);return"node"===c?function(a,b){let c=jW(b,a.schema),{from:d,to:e}=a.selection,f=[];a.doc.nodesBetween(d,e,a=>{f.push(a)});let g=f.reverse().find(a=>a.type.name===c.name);return g?{...g.attrs}:{}}(a,b):"mark"===c?kL(a,b):{}}function k7(a){let b,{mapping:c,steps:d}=a,e=[];return c.maps.forEach((a,b)=>{let f=[];if(a.ranges.length)a.forEach((a,b)=>{f.push({from:a,to:b})});else{let{from:a,to:c}=d[b];if(void 0===a||void 0===c)return;f.push({from:a,to:c})}f.forEach(({from:a,to:d})=>{let f=c.slice(b).map(a,-1),g=c.slice(b).map(d),h=c.invert().map(f,-1),i=c.invert().map(g);e.push({oldRange:{from:h,to:i},newRange:{from:f,to:g}})})}),1===(b=function(a,b=JSON.stringify){let c={};return a.filter(a=>{let d=b(a);return!Object.prototype.hasOwnProperty.call(c,d)&&(c[d]=!0)})}(e)).length?b:b.filter((a,c)=>!b.filter((a,b)=>b!==c).some(b=>a.oldRange.from>=b.oldRange.from&&a.oldRange.to<=b.oldRange.to&&a.newRange.from>=b.newRange.from&&a.newRange.to<=b.newRange.to))}function k8(a,b,c){let d=[];return a===b?c.resolve(a).marks().forEach(b=>{let e=j5(c.resolve(a),b.type);e&&d.push({mark:b,...e})}):c.nodesBetween(a,b,(a,b)=>{a&&(null==a?void 0:a.nodeSize)!==void 0&&d.push(...a.marks.map(c=>({from:b,to:b+a.nodeSize,mark:c})))}),d}function k9(a,b){return b.nodes[a]||b.marks[a]||null}function la(a,b,c){return Object.fromEntries(Object.entries(c).filter(([c])=>{let d=a.find(a=>a.type===b&&a.name===c);return!!d&&d.attribute.keepOnSplit}))}function lb(a,b,c={}){let{empty:d,ranges:e}=a.selection,f=b?j6(b,a.schema):null;if(d)return!!(a.storedMarks||a.selection.$from.marks()).filter(a=>!f||f.name===a.type.name).find(a=>j2(a.attrs,c,{strict:!1}));let g=0,h=[];if(e.forEach(({$from:b,$to:c})=>{let d=b.pos,e=c.pos;a.doc.nodesBetween(d,e,(a,b)=>{if(f&&a.inlineContent&&!a.type.allowsMarkType(f))return!1;if(!a.isText&&!a.marks.length)return;let c=Math.max(d,b),i=Math.min(e,b+a.nodeSize);g+=i-c,h.push(...a.marks.map(a=>({mark:a,from:c,to:i})))})}),0===g)return!1;let i=h.filter(a=>!f||f.name===a.mark.type.name).filter(a=>j2(a.mark.attrs,c,{strict:!1})).reduce((a,b)=>a+b.to-b.from,0),j=h.filter(a=>!f||a.mark.type!==f&&a.mark.type.excludes(f)).reduce((a,b)=>a+b.to-b.from,0);return(i>0?i+j:i)>=g}function lc(a,b){return Array.isArray(b)?b.some(b=>("string"==typeof b?b:b.name)===a.name):b}function ld(a,b){let{nodeExtensions:c}=kV(b),d=c.find(b=>b.name===a);if(!d)return!1;let e={name:d.name,options:d.options,storage:d.storage},f=kU(kQ(d,"group",e));return"string"==typeof f&&f.split(" ").includes("list")}function le(a,{checkChildren:b=!0,ignoreWhitespace:c=!1}={}){var d;if(c){if("hardBreak"===a.type.name)return!0;if(a.isText)return!/\S/.test(null!=(d=a.text)?d:"")}if(a.isText)return!a.text;if(a.isAtom||a.isLeaf)return!1;if(0===a.content.childCount)return!0;if(b){let d=!0;return a.content.forEach(a=>{!1!==d&&(le(a,{ignoreWhitespace:c,checkChildren:b})||(d=!1))}),d}return!1}function lf(a){return a instanceof fs}var lg=class a{constructor(a){this.position=a}static fromJSON(b){return new a(b.position)}toJSON(){return{position:this.position}}};function lh(a,b){let c=b.mapping.mapResult(a.position);return{position:new lg(c.pos),mapResult:c}}function li(a){return new lg(a)}function lj(a,b,c){let d=a.state.doc.content.size,e=ka(b,0,d),f=ka(c,0,d),g=a.coordsAtPos(e),h=a.coordsAtPos(f,-1),i=Math.min(g.top,h.top),j=Math.max(g.bottom,h.bottom),k=Math.min(g.left,h.left),l=Math.max(g.right,h.right),m={top:i,bottom:j,left:k,right:l,width:l-k,height:j-i,x:k,y:i};return{...m,toJSON:()=>m}}var lk=(a,b={})=>({tr:c,state:d,dispatch:e})=>{let{selection:f}=c,{empty:g,ranges:h}=f,i=j6(a,d.schema);if(e)if(g){let a=kL(d,i);c.addStoredMark(i.create({...a,...b}))}else h.forEach(a=>{let e=a.$from.pos,f=a.$to.pos;d.doc.nodesBetween(e,f,(a,d)=>{let g=Math.max(d,e),h=Math.min(d+a.nodeSize,f);a.marks.find(a=>a.type===i)?a.marks.forEach(a=>{i===a.type&&c.addMark(g,h,i.create({...a.attrs,...b}))}):c.addMark(g,h,i.create(b))})});return function(a,b,c){var d;let{selection:e}=b,f=null;if(j9(e)&&(f=e.$cursor),f){let b=null!=(d=a.storedMarks)?d:f.marks();return f.parent.type.allowsMarkType(c)&&(!!c.isInSet(b)||!b.some(a=>a.type.excludes(c)))}let{ranges:g}=e;return g.some(({$from:b,$to:d})=>{let e=0===b.depth&&a.doc.inlineContent&&a.doc.type.allowsMarkType(c);return a.doc.nodesBetween(b.pos,d.pos,(a,b,d)=>{if(e)return!1;if(a.isInline){let b=!d||d.type.allowsMarkType(c),f=!!c.isInSet(a.marks)||!a.marks.some(a=>a.type.excludes(c));e=b&&f}return!e}),e})}(d,c,i)},ll=(a,b)=>({tr:c})=>(c.setMeta(a,b),!0),lm=(a,b={})=>({state:c,dispatch:d,chain:e})=>{let f,g=jW(a,c.schema);return(c.selection.$anchor.sameParent(c.selection.$head)&&(f=c.selection.$anchor.parent.attrs),g.isTextblock)?e().command(({commands:a})=>!!jE(g,{...f,...b})(c)||a.clearNodes()).command(({state:a})=>jE(g,{...f,...b})(a,d)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},ln=a=>({tr:b,dispatch:c})=>{if(c){let{doc:c}=b,d=ka(a,0,c.content.size),e=fs.create(c,d);b.setSelection(e)}return!0},lo=(a,b)=>({tr:c,state:d,dispatch:e})=>{let f,g,{selection:h}=d;return"number"==typeof b?(f=b,g=b):b&&"from"in b&&"to"in b?(f=b.from,g=b.to):(f=h.from,g=h.to),e&&c.doc.nodesBetween(f,g,(b,d)=>{b.isText||c.setNodeMarkup(d,void 0,{...b.attrs,dir:a})}),!0},lp=a=>({tr:b,dispatch:c})=>{if(c){let{doc:c}=b,{from:d,to:e}="number"==typeof a?{from:a,to:a}:a,f=fq.atStart(c).from,g=fq.atEnd(c).to,h=ka(d,f,g),i=ka(e,f,g),j=fq.create(c,h,i);b.setSelection(j)}return!0},lq=a=>({state:b,dispatch:c})=>{var d;return(d=jW(a,b.schema),function(a,b){let{$from:c,$to:e}=a.selection,f=c.blockRange(e,a=>a.childCount>0&&a.firstChild.type==d);if(!f)return!1;let g=f.startIndex;if(0==g)return!1;let h=f.parent,i=h.child(g-1);if(i.type!=d)return!1;if(b){let c=i.lastChild&&i.lastChild.type==h.type,e=d$.from(c?d.create():null),g=new d4(d$.from(d.create(null,d$.from(h.type.create(null,e)))),c?3:1,0),j=f.start,k=f.end;b(a.tr.step(new eY(j-(c?3:1),k,j,k,g,1,!0)).scrollIntoView())}return!0})(b,c)};function lr(a,b){let c=a.storedMarks||a.selection.$to.parentOffset&&a.selection.$from.marks();if(c){let d=c.filter(a=>null==b?void 0:b.includes(a.type.name));a.tr.ensureMarks(d)}}var ls=({keepMarks:a=!0}={})=>({tr:b,state:c,dispatch:d,editor:e})=>{let{selection:f,doc:g}=b,{$from:h,$to:i}=f,j=la(e.extensionManager.attributes,h.node().type.name,h.node().attrs);if(f instanceof fs&&f.node.isBlock)return!!h.parentOffset&&!!e4(g,h.pos)&&(d&&(a&&lr(c,e.extensionManager.splittableMarks),b.split(h.pos).scrollIntoView()),!0);if(!h.parent.isBlock)return!1;let k=i.parentOffset===i.parent.content.size,l=0===h.depth?void 0:function(a){for(let b=0;b<a.edgeCount;b+=1){let{type:c}=a.edge(b);if(c.isTextblock&&!c.hasRequiredAttrs())return c}return null}(h.node(-1).contentMatchAt(h.indexAfter(-1))),m=k&&l?[{type:l,attrs:j}]:void 0,n=e4(b.doc,b.mapping.map(h.pos),1,m);if(!m&&!n&&e4(b.doc,b.mapping.map(h.pos),1,l?[{type:l}]:void 0)&&(n=!0,m=l?[{type:l,attrs:j}]:void 0),d){if(n&&(f instanceof fq&&b.deleteSelection(),b.split(b.mapping.map(h.pos),1,m),l&&!k&&!h.parentOffset&&h.parent.type!==l)){let a=b.mapping.map(h.before()),c=b.doc.resolve(a);h.node(-1).canReplaceWith(c.index(),c.index()+1,l)&&b.setNodeMarkup(b.mapping.map(h.before()),l)}a&&lr(c,e.extensionManager.splittableMarks),b.scrollIntoView()}return n},lt=(a,b={})=>({tr:c,state:d,dispatch:e,editor:f})=>{var g;let h=jW(a,d.schema),{$from:i,$to:j}=d.selection,k=d.selection.node;if(k&&k.isBlock||i.depth<2||!i.sameParent(j))return!1;let l=i.node(-1);if(l.type!==h)return!1;let m=f.extensionManager.attributes;if(0===i.parent.content.size&&i.node(-1).childCount===i.indexAfter(-1)){if(2===i.depth||i.node(-3).type!==h||i.index(-2)!==i.node(-2).childCount-1)return!1;if(e){let a=d$.empty,d=i.index(-1)?1:i.index(-2)?2:3;for(let b=i.depth-d;b>=i.depth-3;b-=1)a=d$.from(i.node(b).copy(a));let e=i.indexAfter(-1)<i.node(-2).childCount?1:i.indexAfter(-2)<i.node(-3).childCount?2:3,f={...la(m,i.node().type.name,i.node().attrs),...b},j=(null==(g=h.contentMatch.defaultType)?void 0:g.createAndFill(f))||void 0;a=a.append(d$.from(h.createAndFill(null,j)||void 0));let k=i.before(i.depth-(d-1));c.replace(k,i.after(-e),new d4(a,4-d,0));let l=-1;c.doc.nodesBetween(k,c.doc.content.size,(a,b)=>{if(l>-1)return!1;a.isTextblock&&0===a.content.size&&(l=b+1)}),l>-1&&c.setSelection(fq.near(c.doc.resolve(l))),c.scrollIntoView()}return!0}let n=j.pos===i.end()?l.contentMatchAt(0).defaultType:null,o={...la(m,l.type.name,l.attrs),...b},p={...la(m,i.node().type.name,i.node().attrs),...b};c.delete(i.pos,j.pos);let q=n?[{type:h,attrs:o},{type:n,attrs:p}]:[{type:h,attrs:o}];if(!e4(c.doc,i.pos,2))return!1;if(e){let{selection:a,storedMarks:b}=d,{splittableMarks:g}=f.extensionManager,h=b||a.$to.parentOffset&&a.$from.marks();if(c.split(i.pos,2,q).scrollIntoView(),!h||!e)return!0;let j=h.filter(a=>g.includes(a.type.name));c.ensureMarks(j)}return!0},lu=(a,b)=>{let c=kP(a=>a.type===b)(a.selection);if(!c)return!0;let d=a.doc.resolve(Math.max(0,c.pos-1)).before(c.depth);if(void 0===d)return!0;let e=a.doc.nodeAt(d);return!(c.node.type===(null==e?void 0:e.type)&&e5(a.doc,c.pos))||(a.join(c.pos),!0)},lv=(a,b)=>{let c=kP(a=>a.type===b)(a.selection);if(!c)return!0;let d=a.doc.resolve(c.start).after(c.depth);if(void 0===d)return!0;let e=a.doc.nodeAt(d);return!(c.node.type===(null==e?void 0:e.type)&&e5(a.doc,d))||(a.join(d),!0)},lw=(a,b,c,d={})=>({editor:e,tr:f,state:g,dispatch:h,chain:i,commands:j,can:k})=>{let{extensions:l,splittableMarks:m}=e.extensionManager,n=jW(a,g.schema),o=jW(b,g.schema),{selection:p,storedMarks:q}=g,{$from:r,$to:s}=p,t=r.blockRange(s),u=q||p.$to.parentOffset&&p.$from.marks();if(!t)return!1;let v=kP(a=>ld(a.type.name,l))(p),w=0===p.from&&p.to===g.doc.content.size,x=g.doc.content.content,y=1===x.length?x[0]:null,z=w&&y&&ld(y.type.name,l)?{node:y,pos:0,depth:0}:null,A=null!=v?v:z,B=!!v&&t.depth>=1&&t.depth-v.depth<=1,C=!!z;if((B||C)&&A){if(A.node.type===n)return w&&C?i().command(({tr:a,dispatch:b})=>{let c=function(a){let b=a.doc,c=b.firstChild;if(!c)return null;let d=b.resolve(1),e=b.resolve(c.nodeSize-1);return fq.between(d,e)}(a);return!!c&&(a.setSelection(c),b&&b(a),!0)}).liftListItem(o).run():j.liftListItem(o);if(ld(A.node.type.name,l)&&n.validContent(A.node.content))return i().command(()=>(f.setNodeMarkup(A.pos,n),!0)).command(()=>lu(f,n)).command(()=>lv(f,n)).run()}return c&&u&&h?i().command(()=>{let a=k().wrapInList(n,d),b=u.filter(a=>m.includes(a.type.name));return f.ensureMarks(b),!!a||j.clearNodes()}).wrapInList(n,d).command(()=>lu(f,n)).command(()=>lv(f,n)).run():i().command(()=>!!k().wrapInList(n,d)||j.clearNodes()).wrapInList(n,d).command(()=>lu(f,n)).command(()=>lv(f,n)).run()},lx=(a,b={},c={})=>({state:d,commands:e})=>{let{extendEmptyMarkRange:f=!1}=c,g=j6(a,d.schema);return lb(d,g,b)?e.unsetMark(g,{extendEmptyMarkRange:f}):e.setMark(g,b)},ly=(a,b,c={})=>({state:d,commands:e})=>{let f,g=jW(a,d.schema),h=jW(b,d.schema),i=ku(d,g,c);return(d.selection.$anchor.sameParent(d.selection.$head)&&(f=d.selection.$anchor.parent.attrs),i)?e.setNode(h,f):e.setNode(g,{...f,...c})},lz=(a,b={})=>({state:c,commands:d})=>{let e=jW(a,c.schema);return ku(c,e,b)?d.lift(e):d.wrapIn(e,b)},lA=()=>({state:a,dispatch:b})=>{let c=a.plugins;for(let d=0;d<c.length;d+=1){let e,f=c[d];if(f.spec.isInputRules&&(e=f.getState(a))){if(b){let b=a.tr,c=e.transform;for(let a=c.steps.length-1;a>=0;a-=1)b.step(c.steps[a].invert(c.docs[a]));if(e.text){let c=b.doc.resolve(e.from).marks();b.replaceWith(e.from,e.to,a.schema.text(e.text,c))}else b.delete(e.from,e.to)}return!0}}return!1},lB=()=>({tr:a,dispatch:b})=>{let{selection:c}=a,{empty:d,ranges:e}=c;return!!d||(b&&e.forEach(b=>{a.removeMark(b.$from.pos,b.$to.pos)}),!0)},lC=(a,b={})=>({tr:c,state:d,dispatch:e})=>{var f;let{extendEmptyMarkRange:g=!1}=b,{selection:h}=c,i=j6(a,d.schema),{$from:j,empty:k,ranges:l}=h;if(!e)return!0;if(k&&g){let{from:a,to:b}=h,d=null==(f=j.marks().find(a=>a.type===i))?void 0:f.attrs,e=j5(j,i,d);e&&(a=e.from,b=e.to),c.removeMark(a,b,i)}else l.forEach(a=>{c.removeMark(a.$from.pos,a.$to.pos,i)});return c.removeStoredMark(i),!0},lD=a=>({tr:b,state:c,dispatch:d})=>{let e,f,{selection:g}=c;return"number"==typeof a?(e=a,f=a):a&&"from"in a&&"to"in a?(e=a.from,f=a.to):(e=g.from,f=g.to),d&&b.doc.nodesBetween(e,f,(a,c)=>{if(a.isText)return;let d={...a.attrs};delete d.dir,b.setNodeMarkup(c,void 0,d)}),!0},lE=(a,b={})=>({tr:c,state:d,dispatch:e})=>{let f=null,g=null,h=kz("string"==typeof a?a:a.name,d.schema);if(!h)return!1;"node"===h&&(f=jW(a,d.schema)),"mark"===h&&(g=j6(a,d.schema));let i=!1;return c.selection.ranges.forEach(a=>{let h,j,k,l,m=a.$from.pos,n=a.$to.pos;c.selection.empty?d.doc.nodesBetween(m,n,(a,b)=>{f&&f===a.type&&(i=!0,k=Math.max(b,m),l=Math.min(b+a.nodeSize,n),h=b,j=a)}):d.doc.nodesBetween(m,n,(a,d)=>{d<m&&f&&f===a.type&&(i=!0,k=Math.max(d,m),l=Math.min(d+a.nodeSize,n),h=d,j=a),d>=m&&d<=n&&(f&&f===a.type&&(i=!0,e&&c.setNodeMarkup(d,void 0,{...a.attrs,...b})),g&&a.marks.length&&a.marks.forEach(f=>{if(g===f.type&&(i=!0,e)){let e=Math.max(d,m),h=Math.min(d+a.nodeSize,n);c.addMark(e,h,g.create({...f.attrs,...b}))}}))}),j&&(void 0!==h&&e&&c.setNodeMarkup(h,void 0,{...j.attrs,...b}),g&&j.marks.length&&j.marks.forEach(a=>{g===a.type&&e&&c.addMark(k,l,g.create({...a.attrs,...b}))}))}),i},lF=(a,b={})=>({state:c,dispatch:d})=>(function(a,b=null){return function(c,d){let{$from:e,$to:f}=c.selection,g=e.blockRange(f),h=g&&e0(g,a,b);return!!h&&(d&&d(c.tr.wrap(g,h).scrollIntoView()),!0)}})(jW(a,c.schema),b)(c,d),lG=(a,b={})=>({state:c,dispatch:d})=>(function(a,b=null){return function(c,d){let{$from:e,$to:f}=c.selection,g=e.blockRange(f);if(!g)return!1;let h=d?c.tr:null;return!!function(a,b,c,d=null){let e=!1,f=b,g=b.$from.doc;if(b.depth>=2&&b.$from.node(b.depth-1).type.compatibleContent(c)&&0==b.startIndex){if(0==b.$from.index(b.depth-1))return!1;let a=g.resolve(b.start-2);f=new ef(a,a,b.depth),b.endIndex<b.parent.childCount&&(b=new ef(b.$from,g.resolve(b.$to.end(b.depth)),b.depth)),e=!0}let h=e0(f,c,d,b);return!!h&&(a&&function(a,b,c,d,e){let f=d$.empty;for(let a=c.length-1;a>=0;a--)f=d$.from(c[a].type.create(c[a].attrs,f));a.step(new eY(b.start-2*!!d,b.end,b.start,b.end,new d4(f,0,0),c.length,!0));let g=0;for(let a=0;a<c.length;a++)c[a].type==e&&(g=a+1);let h=c.length-g,i=b.start+c.length-2*!!d,j=b.parent;for(let c=b.startIndex,d=b.endIndex,e=!0;c<d;c++,e=!1)!e&&e4(a.doc,i,h)&&(a.split(i,h),i+=2*h),i+=j.child(c).nodeSize}(a,b,h,e,c),!0)}(h,g,a,b)&&(d&&d(h.scrollIntoView()),!0)}})(jW(a,c.schema),b)(c,d),lH=class{constructor(){this.callbacks={}}on(a,b){return this.callbacks[a]||(this.callbacks[a]=[]),this.callbacks[a].push(b),this}emit(a,...b){let c=this.callbacks[a];return c&&c.forEach(a=>a.apply(this,b)),this}off(a,b){let c=this.callbacks[a];return c&&(b?this.callbacks[a]=c.filter(a=>a!==b):delete this.callbacks[a]),this}once(a,b){let c=(...d)=>{this.off(a,c),b.apply(this,d)};return this.on(a,c)}removeAllListeners(){this.callbacks={}}},lI=class{constructor(a){var b;this.find=a.find,this.handler=a.handler,this.undoable=null==(b=a.undoable)||b}};function lJ(a){var b;let{editor:c,from:d,to:e,text:f,rules:g,plugin:h}=a,{view:i}=c;if(i.composing)return!1;let j=i.state.doc.resolve(d);if(j.parent.type.spec.code||(null==(b=j.nodeBefore||j.nodeAfter)?void 0:b.marks.find(a=>a.type.spec.code)))return!1;let k=!1,l=((a,b=500)=>{let c="",d=a.parentOffset;return a.parent.nodesBetween(Math.max(0,d-b),d,(a,b,e,f)=>{var g,h;let i=(null==(h=(g=a.type.spec).toText)?void 0:h.call(g,{node:a,pos:b,parent:e,index:f}))||a.textContent||"%leaf%";c+=a.isAtom&&!a.isText?i:i.slice(0,Math.max(0,d-b))}),c})(j)+f;return g.forEach(a=>{if(k)return;let b=((a,b)=>{if(j1(b))return b.exec(a);let c=b(a);if(!c)return null;let d=[c.text];return d.index=c.index,d.input=a,d.data=c.data,c.replaceWith&&(c.text.includes(c.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),d.push(c.replaceWith)),d})(l,a.find);if(!b)return;let g=i.state.tr,j=jM({state:i.state,transaction:g}),m={from:d-(b[0].length-f.length),to:e},{commands:n,chain:o,can:p}=new jN({editor:c,state:j});null!==a.handler({state:j,range:m,match:b,commands:n,chain:o,can:p})&&g.steps.length&&(a.undoable&&g.setMeta(h,{transform:g,from:d,to:e,text:f}),i.dispatch(g),k=!0)}),k}function lK(a){return"Object"===Object.prototype.toString.call(a).slice(8,-1)&&a.constructor===Object&&Object.getPrototypeOf(a)===Object.prototype}var lL=class{constructor(a={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...a},this.name=this.config.name}get options(){return{...kU(kQ(this,"addOptions",{name:this.name}))}}get storage(){return{...kU(kQ(this,"addStorage",{name:this.name,options:this.options}))}}configure(a={}){let b=this.extend({...this.config,addOptions:()=>(function a(b,c){let d={...b};return lK(b)&&lK(c)&&Object.keys(c).forEach(e=>{lK(c[e])&&lK(b[e])?d[e]=a(b[e],c[e]):d[e]=c[e]}),d})(this.options,a)});return b.name=this.name,b.parent=this.parent,this.child=null,b}extend(a={}){let b=new this.constructor({...this.config,...a});return b.parent=this,this.child=b,b.name="name"in a?a.name:b.parent.name,b}},lM=class a extends lL{constructor(){super(...arguments),this.type="mark"}static create(b={}){return new a("function"==typeof b?b():b)}static handleExit({editor:a,mark:b}){let{tr:c}=a.state,d=a.state.selection.$from;if(d.pos===d.end()){let e=d.marks();if(!e.find(a=>(null==a?void 0:a.type.name)===b.name))return!1;let f=e.find(a=>(null==a?void 0:a.type.name)===b.name);return f&&c.removeStoredMark(f),c.insertText(" ",d.pos),a.view.dispatch(c),!0}return!1}configure(a){return super.configure(a)}extend(a){let b="function"==typeof a?a():a;return super.extend(b)}},lN=class{constructor(a){this.find=a.find,this.handler=a.handler}},lO=null,lP=class{constructor(a,b){this.splittableMarks=[],this.editor=b,this.baseExtensions=a,this.extensions=k2(a),this.schema=function(a,b){var c;let d=kW(a),{nodeExtensions:e,markExtensions:f}=kV(a),g=null==(c=e.find(a=>kQ(a,"topNode")))?void 0:c.name;return new ew({topNode:g,nodes:Object.fromEntries(e.map(c=>{let e=d.filter(a=>a.type===c.name),f={name:c.name,options:c.options,storage:c.storage,editor:b},g=k_({...a.reduce((a,b)=>{let d=kQ(b,"extendNodeSchema",f);return{...a,...d?d(c):{}}},{}),content:kU(kQ(c,"content",f)),marks:kU(kQ(c,"marks",f)),group:kU(kQ(c,"group",f)),inline:kU(kQ(c,"inline",f)),atom:kU(kQ(c,"atom",f)),selectable:kU(kQ(c,"selectable",f)),draggable:kU(kQ(c,"draggable",f)),code:kU(kQ(c,"code",f)),whitespace:kU(kQ(c,"whitespace",f)),linebreakReplacement:kU(kQ(c,"linebreakReplacement",f)),defining:kU(kQ(c,"defining",f)),isolating:kU(kQ(c,"isolating",f)),attrs:Object.fromEntries(e.map(k0))}),h=kU(kQ(c,"parseHTML",f));h&&(g.parseDOM=h.map(a=>k$(a,e)));let i=kQ(c,"renderHTML",f);i&&(g.toDOM=a=>i({node:a,HTMLAttributes:kZ(a,e)}));let j=kQ(c,"renderText",f);return j&&(g.toText=j),[c.name,g]})),marks:Object.fromEntries(f.map(c=>{let e=d.filter(a=>a.type===c.name),f={name:c.name,options:c.options,storage:c.storage,editor:b},g=k_({...a.reduce((a,b)=>{let d=kQ(b,"extendMarkSchema",f);return{...a,...d?d(c):{}}},{}),inclusive:kU(kQ(c,"inclusive",f)),excludes:kU(kQ(c,"excludes",f)),group:kU(kQ(c,"group",f)),spanning:kU(kQ(c,"spanning",f)),code:kU(kQ(c,"code",f)),attrs:Object.fromEntries(e.map(k0))}),h=kU(kQ(c,"parseHTML",f));h&&(g.parseDOM=h.map(a=>k$(a,e)));let i=kQ(c,"renderHTML",f);return i&&(g.toDOM=a=>i({mark:a,HTMLAttributes:kZ(a,e)})),[c.name,g]}))})}(this.extensions,b),this.setupExtensions()}get commands(){return this.extensions.reduce((a,b)=>{let c={name:b.name,options:b.options,storage:this.editor.extensionStorage[b.name],editor:this.editor,type:k9(b.name,this.schema)},d=kQ(b,"addCommands",c);return d?{...a,...d()}:a},{})}get plugins(){let{editor:a}=this;return k1([...this.extensions].reverse()).flatMap(b=>{let c={name:b.name,options:b.options,storage:this.editor.extensionStorage[b.name],editor:a,type:k9(b.name,this.schema)},d=[],e=kQ(b,"addKeyboardShortcuts",c),f={};if("mark"===b.type&&kQ(b,"exitable",c)&&(f.ArrowRight=()=>lM.handleExit({editor:a,mark:b})),e){let b=Object.fromEntries(Object.entries(e()).map(([b,c])=>[b,()=>c({editor:a})]));f={...f,...b}}let g=new fE({props:{handleKeyDown:im(f)}});d.push(g);let h=kQ(b,"addInputRules",c);if(lc(b,a.options.enableInputRules)&&h){let b=h();if(b&&b.length){let c=function(a){let{editor:b,rules:c}=a,d=new fE({state:{init:()=>null,apply(a,e,f){let g=a.getMeta(d);if(g)return g;let h=a.getMeta("applyInputRules");return h&&setTimeout(()=>{let{text:a}=h;"string"==typeof a||(a=kS(d$.from(a),f.schema));let{from:e}=h,g=e+a.length;lJ({editor:b,from:e,to:g,text:a,rules:c,plugin:d})}),a.selectionSet||a.docChanged?null:e}},props:{handleTextInput:(a,e,f,g)=>lJ({editor:b,from:e,to:f,text:g,rules:c,plugin:d}),handleDOMEvents:{compositionend:a=>(setTimeout(()=>{let{$cursor:e}=a.state.selection;e&&lJ({editor:b,from:e.pos,to:e.pos,text:"",rules:c,plugin:d})}),!1)},handleKeyDown(a,e){if("Enter"!==e.key)return!1;let{$cursor:f}=a.state.selection;return!!f&&lJ({editor:b,from:f.pos,to:f.pos,text:"\n",rules:c,plugin:d})}},isInputRules:!0});return d}({editor:a,rules:b}),e=Array.isArray(c)?c:[c];d.push(...e)}}let i=kQ(b,"addPasteRules",c);if(lc(b,a.options.enablePasteRules)&&i){let b=i();if(b&&b.length){let c=function(a){let b,{editor:c,rules:d}=a,e=null,f=!1,g=!1,h="u">typeof ClipboardEvent?new ClipboardEvent("paste"):null;try{b="u">typeof DragEvent?new DragEvent("drop"):null}catch{b=null}let i=({state:a,from:d,to:e,rule:f,pasteEvt:g})=>{let i=a.tr;if(function(a){let{editor:b,state:c,from:d,to:e,rule:f,pasteEvent:g,dropEvent:h}=a,{commands:i,chain:j,can:k}=new jN({editor:b,state:c}),l=[];return c.doc.nodesBetween(d,e,(a,b)=>{var m,n,o,p,q;if((null==(n=null==(m=a.type)?void 0:m.spec)?void 0:n.code)||!(a.isText||a.isTextblock||a.isInline))return;let r=null!=(q=null!=(p=null==(o=a.content)?void 0:o.size)?p:a.nodeSize)?q:0,s=Math.max(d,b),t=Math.min(e,b+r);s>=t||((a,b,c)=>{if(j1(b))return[...a.matchAll(b)];let d=b(a,c);return d?d.map(b=>{let c=[b.text];return c.index=b.index,c.input=a,c.data=b.data,b.replaceWith&&(b.text.includes(b.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),c.push(b.replaceWith)),c}):[]})(a.isText?a.text||"":a.textBetween(s-b,t-b,void 0,""),f.find,g).forEach(a=>{if(void 0===a.index)return;let b=s+a.index+1,d=b+a[0].length,e={from:c.tr.mapping.map(b),to:c.tr.mapping.map(d)},m=f.handler({state:c,range:e,match:a,commands:i,chain:j,can:k,pasteEvent:g,dropEvent:h});l.push(m)})}),l.every(a=>null!==a)}({editor:c,state:jM({state:a,transaction:i}),from:Math.max(d-1,0),to:e.b-1,rule:f,pasteEvent:g,dropEvent:b})&&i.steps.length){try{b="u">typeof DragEvent?new DragEvent("drop"):null}catch{b=null}return h="u">typeof ClipboardEvent?new ClipboardEvent("paste"):null,i}};return d.map(a=>new fE({view(a){let b=b=>{var d;(e=(null==(d=a.dom.parentElement)?void 0:d.contains(b.target))?a.dom.parentElement:null)&&(lO=c)},d=()=>{lO&&(lO=null)};return window.addEventListener("dragstart",b),window.addEventListener("dragend",d),{destroy(){window.removeEventListener("dragstart",b),window.removeEventListener("dragend",d)}}},props:{handleDOMEvents:{drop:(a,c)=>{if(g=e===a.dom.parentElement,b=c,!g){let a=lO;(null==a?void 0:a.isEditable)&&setTimeout(()=>{let b=a.state.selection;b&&a.commands.deleteRange({from:b.from,to:b.to})},10)}return!1},paste:(a,b)=>{var c;let d=null==(c=b.clipboardData)?void 0:c.getData("text/html");return h=b,f=!!(null==d?void 0:d.includes("data-pm-slice")),!1}}},appendTransaction:(b,c,d)=>{let e=b[0],j="paste"===e.getMeta("uiEvent")&&!f,k="drop"===e.getMeta("uiEvent")&&!g,l=e.getMeta("applyPasteRules"),m=!!l;if(!j&&!k&&!m)return;if(m){var n,o;let b,{text:c}=l;"string"==typeof c||(c=kS(d$.from(c),d.schema));let{from:e}=l,f=e+c.length;return i({rule:a,state:d,from:e,to:{b:f},pasteEvt:(n=c,null==(o=(b=new ClipboardEvent("paste",{clipboardData:new DataTransfer})).clipboardData)||o.setData("text/html",n),b)})}let p=c.doc.content.findDiffStart(d.doc.content),q=c.doc.content.findDiffEnd(d.doc.content);if("number"==typeof p&&q&&p!==q.b)return i({rule:a,state:d,from:p,to:q,pasteEvt:h})}}))}({editor:a,rules:b});d.push(...c)}}let j=kQ(b,"addProseMirrorPlugins",c);if(j){let a=j();d.push(...a)}return d})}get attributes(){return kW(this.extensions)}get nodeViews(){let{editor:a}=this,{nodeExtensions:b}=kV(this.extensions);return Object.fromEntries(b.filter(a=>!!kQ(a,"addNodeView")).map(b=>{let c=this.attributes.filter(a=>a.type===b.name),d={name:b.name,options:b.options,storage:this.editor.extensionStorage[b.name],editor:a,type:jW(b.name,this.schema)},e=kQ(b,"addNodeView",d);if(!e)return[];let f=e();return f?[b.name,(d,e,g,h,i)=>{let j=kZ(d,c);return f({node:d,view:e,getPos:g,decorations:h,innerDecorations:i,editor:a,extension:b,HTMLAttributes:j})}]:[]}))}dispatchTransaction(a){let{editor:b}=this;return k1([...this.extensions].reverse()).reduceRight((a,c)=>{let d={name:c.name,options:c.options,storage:this.editor.extensionStorage[c.name],editor:b,type:k9(c.name,this.schema)},e=kQ(c,"dispatchTransaction",d);return e?b=>{e.call(d,{transaction:b,next:a})}:a},a)}transformPastedHTML(a){let{editor:b}=this;return k1([...this.extensions]).reduce((a,c)=>{let d={name:c.name,options:c.options,storage:this.editor.extensionStorage[c.name],editor:b,type:k9(c.name,this.schema)},e=kQ(c,"transformPastedHTML",d);return e?(b,c)=>{let f=a(b,c);return e.call(d,f)}:a},a||(a=>a))}get markViews(){let{editor:a}=this,{markExtensions:b}=kV(this.extensions);return Object.fromEntries(b.filter(a=>!!kQ(a,"addMarkView")).map(b=>{let c=this.attributes.filter(a=>a.type===b.name),d={name:b.name,options:b.options,storage:this.editor.extensionStorage[b.name],editor:a,type:j6(b.name,this.schema)},e=kQ(b,"addMarkView",d);return e?[b.name,(d,f,g)=>{let h=kZ(d,c);return e()({mark:d,view:f,inline:g,editor:a,extension:b,HTMLAttributes:h,updateAttributes:b=>{!function(a,b,c={}){let{state:d}=b,{doc:e,tr:f}=d;e.descendants((b,d)=>{let e=f.mapping.map(d),g=f.mapping.map(d)+b.nodeSize,h=null;if(b.marks.forEach(b=>{if(b!==a)return!1;h=b}),!h)return;let i=!1;if(Object.keys(c).forEach(a=>{c[a]!==h.attrs[a]&&(i=!0)}),i){let b=a.type.create({...a.attrs,...c});f.removeMark(e,g,a.type),f.addMark(e,g,b)}}),f.docChanged&&b.view.dispatch(f)}(d,a,b)}})}]:[]}))}destroy(){this.extensions.forEach(a=>{let b=a;for(;b.parent;){let a=b.parent;a.child===b&&(a.child=null),b=a}}),this.extensions=[],this.baseExtensions=[],this.schema=null,this.editor=null}setupExtensions(){let a=this.extensions;this.editor.extensionStorage=Object.fromEntries(a.map(a=>[a.name,a.storage])),a.forEach(a=>{var b;let c={name:a.name,options:a.options,storage:this.editor.extensionStorage[a.name],editor:this.editor,type:k9(a.name,this.schema)};"mark"===a.type&&(null==(b=kU(kQ(a,"keepOnSplit",c)))||b)&&this.splittableMarks.push(a.name);let d=kQ(a,"onBeforeCreate",c),e=kQ(a,"onCreate",c),f=kQ(a,"onUpdate",c),g=kQ(a,"onSelectionUpdate",c),h=kQ(a,"onTransaction",c),i=kQ(a,"onFocus",c),j=kQ(a,"onBlur",c),k=kQ(a,"onDestroy",c);d&&this.editor.on("beforeCreate",d),e&&this.editor.on("create",e),f&&this.editor.on("update",f),g&&this.editor.on("selectionUpdate",g),h&&this.editor.on("transaction",h),i&&this.editor.on("focus",i),j&&this.editor.on("blur",j),k&&this.editor.on("destroy",k)})}};lP.resolve=k2,lP.sort=k1,lP.flatten=kR,jL({},{ClipboardTextSerializer:()=>lR,Commands:()=>lS,Delete:()=>lT,Drop:()=>lU,Editable:()=>lV,FocusEvents:()=>lX,Keymap:()=>lY,Paste:()=>lZ,Tabindex:()=>l$,TextDirection:()=>l_,focusEventsPluginKey:()=>lW});var lQ=class a extends lL{constructor(){super(...arguments),this.type="extension"}static create(b={}){return new a("function"==typeof b?b():b)}configure(a){return super.configure(a)}extend(a){let b="function"==typeof a?a():a;return super.extend(b)}},lR=lQ.create({name:"clipboardTextSerializer",addOptions:()=>({blockSeparator:void 0}),addProseMirrorPlugins(){return[new fE({key:new fH("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{let{editor:a}=this,{state:b,schema:c}=a,{doc:d,selection:e}=b,{ranges:f}=e,g=Math.min(...f.map(a=>a.$from.pos)),h=Math.max(...f.map(a=>a.$to.pos)),i=k5(c);return k3(d,{from:g,to:h},{...void 0!==this.options.blockSeparator?{blockSeparator:this.options.blockSeparator}:{},textSerializers:i})}}})]}}),lS=lQ.create({name:"commands",addCommands:()=>({...jO})}),lT=lQ.create({name:"delete",onUpdate({transaction:a,appendedTransactions:b}){var c,d,e;let f=()=>{var c,d,e,f;if(null!=(f=null==(e=null==(d=null==(c=this.editor.options.coreExtensionOptions)?void 0:c.delete)?void 0:d.filterTransaction)?void 0:e.call(d,a))?f:a.getMeta("y-sync$"))return;let g=kM(a.before,[a,...b]);k7(g).forEach(b=>{g.mapping.mapResult(b.oldRange.from).deletedAfter&&g.mapping.mapResult(b.oldRange.to).deletedBefore&&g.before.nodesBetween(b.oldRange.from,b.oldRange.to,(c,d)=>{let e=d+c.nodeSize-2,f=b.oldRange.from<=d&&e<=b.oldRange.to;this.editor.emit("delete",{type:"node",node:c,from:d,to:e,newFrom:g.mapping.map(d),newTo:g.mapping.map(e),deletedRange:b.oldRange,newRange:b.newRange,partial:!f,editor:this.editor,transaction:a,combinedTransform:g})})});let h=g.mapping;g.steps.forEach((b,c)=>{var d,e;if(b instanceof eU){let f=h.slice(c).map(b.from,-1),i=h.slice(c).map(b.to),j=h.invert().map(f,-1),k=h.invert().map(i),l=f>0&&(null==(d=g.doc.nodeAt(f-1))?void 0:d.marks.some(a=>a.eq(b.mark))),m=null==(e=g.doc.nodeAt(i))?void 0:e.marks.some(a=>a.eq(b.mark));this.editor.emit("delete",{type:"mark",mark:b.mark,from:b.from,to:b.to,deletedRange:{from:j,to:k},newRange:{from:f,to:i},partial:!!(m||l),editor:this.editor,transaction:a,combinedTransform:g})}})};null==(e=null==(d=null==(c=this.editor.options.coreExtensionOptions)?void 0:c.delete)?void 0:d.async)||e?setTimeout(f,0):f()}}),lU=lQ.create({name:"drop",addProseMirrorPlugins(){return[new fE({key:new fH("tiptapDrop"),props:{handleDrop:(a,b,c,d)=>{this.editor.emit("drop",{editor:this.editor,event:b,slice:c,moved:d})}}})]}}),lV=lQ.create({name:"editable",addProseMirrorPlugins(){return[new fE({key:new fH("editable"),props:{editable:()=>this.editor.options.editable}})]}}),lW=new fH("focusEvents"),lX=lQ.create({name:"focusEvents",addProseMirrorPlugins(){let{editor:a}=this;return[new fE({key:lW,props:{handleDOMEvents:{focus:(b,c)=>{a.isFocused=!0;let d=a.state.tr.setMeta("focus",{event:c}).setMeta("addToHistory",!1);return b.dispatch(d),!1},blur:(b,c)=>{a.isFocused=!1;let d=a.state.tr.setMeta("blur",{event:c}).setMeta("addToHistory",!1);return b.dispatch(d),!1}}}})]}}),lY=lQ.create({name:"keymap",addKeyboardShortcuts(){let a=()=>this.editor.commands.first(({commands:a})=>[()=>a.undoInputRule(),()=>a.command(({tr:b})=>{let{selection:c,doc:d}=b,{empty:e,$anchor:f}=c,{pos:g,parent:h}=f,i=f.parent.isTextblock&&g>0?b.doc.resolve(g-1):f,j=i.parent.type.spec.isolating,k=f.pos-f.parentOffset,l=j&&1===i.parent.childCount?k===f.pos:fm.atStart(d).from===g;return!!e&&!!h.type.isTextblock&&!h.textContent.length&&!!l&&(!l||"paragraph"!==f.parent.type.name)&&a.clearNodes()}),()=>a.deleteSelection(),()=>a.joinBackward(),()=>a.selectNodeBackward()]),b=()=>this.editor.commands.first(({commands:a})=>[()=>a.deleteSelection(),()=>a.deleteCurrentNode(),()=>a.joinForward(),()=>a.selectNodeForward()]),c={Enter:()=>this.editor.commands.first(({commands:a})=>[()=>a.newlineInCode(),()=>a.createParagraphNear(),()=>a.liftEmptyBlock(),()=>a.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:a,"Mod-Backspace":a,"Shift-Backspace":a,Delete:b,"Mod-Delete":b,"Mod-a":()=>this.editor.commands.selectAll()},d={...c},e={...c,"Ctrl-h":a,"Alt-Backspace":a,"Ctrl-d":b,"Ctrl-Alt-Backspace":b,"Alt-Delete":b,"Alt-d":b,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return kd()||ks()?e:d},addProseMirrorPlugins(){return[new fE({key:new fH("clearDocument"),appendTransaction:(a,b,c)=>{if(a.some(a=>a.getMeta("composition")))return;let d=a.some(a=>a.docChanged)&&!b.doc.eq(c.doc),e=a.some(a=>a.getMeta("preventClearDocument"));if(!d||e)return;let{empty:f,from:g,to:h}=b.selection,i=fm.atStart(b.doc).from,j=fm.atEnd(b.doc).to;if(f||g!==i||h!==j||!le(c.doc))return;let k=c.tr,l=jM({state:c,transaction:k}),{commands:m}=new jN({editor:this.editor,state:l});if(m.clearNodes(),k.steps.length)return k}})]}}),lZ=lQ.create({name:"paste",addProseMirrorPlugins(){return[new fE({key:new fH("tiptapPaste"),props:{handlePaste:(a,b,c)=>{this.editor.emit("paste",{editor:this.editor,event:b,slice:c})}}})]}}),l$=lQ.create({name:"tabindex",addOptions:()=>({value:void 0}),addProseMirrorPlugins(){return[new fE({key:new fH("tabindex"),props:{attributes:()=>{var a;return this.editor.isEditable||void 0!==this.options.value?{tabindex:null!=(a=this.options.value)?a:"0"}:{}}}})]}}),l_=lQ.create({name:"textDirection",addOptions:()=>({direction:void 0}),addGlobalAttributes(){if(!this.options.direction)return[];let{nodeExtensions:a}=kV(this.extensions);return[{types:a.filter(a=>"text"!==a.name).map(a=>a.name),attributes:{dir:{default:this.options.direction,parseHTML:a=>{let b=a.getAttribute("dir");return b&&("ltr"===b||"rtl"===b||"auto"===b)?b:this.options.direction},renderHTML:a=>a.dir?{dir:a.dir}:{}}}}]},addProseMirrorPlugins(){return[new fE({key:new fH("textDirection"),props:{attributes:()=>{let a=this.options.direction;return a?{dir:a}:{}}}})]}}),l0=class a{constructor(a,b,c=!1,d=null){this.currentNode=null,this.actualDepth=null,this.isBlock=c,this.resolvedPos=a,this.editor=b,this.currentNode=d}get name(){return this.node.type.name}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var a;return null!=(a=this.actualDepth)?a:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(a){let b=this.from,c=this.to;if(this.isBlock){if(0===this.content.size)return void console.error(`You can\u2019t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);b=this.from+1,c=this.to-1}this.editor.commands.insertContentAt({from:b,to:c},a)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+ +!this.node.isText}get parent(){if(0===this.depth)return null;let b=this.resolvedPos.start(this.resolvedPos.depth-1);return new a(this.resolvedPos.doc.resolve(b),this.editor)}get before(){let b=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return b.depth!==this.depth&&(b=this.resolvedPos.doc.resolve(this.from-3)),new a(b,this.editor)}get after(){let b=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return b.depth!==this.depth&&(b=this.resolvedPos.doc.resolve(this.to+3)),new a(b,this.editor)}get children(){let b=[];return this.node.content.forEach((c,d)=>{let e=c.isBlock&&!c.isTextblock,f=c.isAtom&&!c.isText,g=c.isInline,h=this.pos+d+ +!f;if(h<0||h>this.resolvedPos.doc.nodeSize-2)return;let i=this.resolvedPos.doc.resolve(h);if(!e&&!g&&i.depth<=this.depth)return;let j=new a(i,this.editor,e,e||g?c:null);e&&(j.actualDepth=this.depth+1),b.push(j)}),b}get firstChild(){return this.children[0]||null}get lastChild(){let a=this.children;return a[a.length-1]||null}closest(a,b={}){let c=null,d=this.parent;for(;d&&!c;){if(d.node.type.name===a)if(Object.keys(b).length>0){let a=d.node.attrs,c=Object.keys(b);for(let d=0;d<c.length;d+=1){let e=c[d];if(a[e]!==b[e])break}}else c=d;d=d.parent}return c}querySelector(a,b={}){return this.querySelectorAll(a,b,!0)[0]||null}querySelectorAll(a,b={},c=!1){let d=[];if(!this.children||0===this.children.length)return d;let e=Object.keys(b);return this.children.forEach(f=>{c&&d.length>0||(f.node.type.name===a&&e.every(a=>b[a]===f.node.attrs[a])&&d.push(f),c&&d.length>0||(d=d.concat(f.querySelectorAll(a,b,c))))}),d}setAttribute(a){let{tr:b}=this.editor.state;b.setNodeMarkup(this.from,void 0,{...this.node.attrs,...a}),this.editor.view.dispatch(b)}},l1=`.ProseMirror {
|
|
22
22
|
position: relative;
|
|
23
23
|
}
|
|
24
24
|
|