@minecraft-docker/mcctl-console 2.12.0 → 2.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.next/standalone/platform/services/mcctl-console/.next/BUILD_ID +1 -1
- package/.next/standalone/platform/services/mcctl-console/.next/app-build-manifest.json +24 -24
- package/.next/standalone/platform/services/mcctl-console/.next/app-path-routes-manifest.json +1 -1
- package/.next/standalone/platform/services/mcctl-console/.next/build-manifest.json +2 -2
- package/.next/standalone/platform/services/mcctl-console/.next/prerender-manifest.json +1 -1
- package/.next/standalone/platform/services/mcctl-console/.next/server/app/(main)/admin/users/page_client-reference-manifest.js +1 -1
- package/.next/standalone/platform/services/mcctl-console/.next/server/app/(main)/audit-logs/page_client-reference-manifest.js +1 -1
- package/.next/standalone/platform/services/mcctl-console/.next/server/app/(main)/backups/page_client-reference-manifest.js +1 -1
- package/.next/standalone/platform/services/mcctl-console/.next/server/app/(main)/dashboard/page.js +1 -1
- package/.next/standalone/platform/services/mcctl-console/.next/server/app/(main)/dashboard/page_client-reference-manifest.js +1 -1
- package/.next/standalone/platform/services/mcctl-console/.next/server/app/(main)/players/page_client-reference-manifest.js +1 -1
- package/.next/standalone/platform/services/mcctl-console/.next/server/app/(main)/routing/page_client-reference-manifest.js +1 -1
- package/.next/standalone/platform/services/mcctl-console/.next/server/app/(main)/servers/[name]/console/page_client-reference-manifest.js +1 -1
- package/.next/standalone/platform/services/mcctl-console/.next/server/app/(main)/servers/[name]/page.js +1 -1
- package/.next/standalone/platform/services/mcctl-console/.next/server/app/(main)/servers/[name]/page_client-reference-manifest.js +1 -1
- package/.next/standalone/platform/services/mcctl-console/.next/server/app/(main)/servers/page_client-reference-manifest.js +1 -1
- package/.next/standalone/platform/services/mcctl-console/.next/server/app/(main)/settings/page_client-reference-manifest.js +1 -1
- package/.next/standalone/platform/services/mcctl-console/.next/server/app/(main)/worlds/page.js +1 -1
- package/.next/standalone/platform/services/mcctl-console/.next/server/app/(main)/worlds/page_client-reference-manifest.js +1 -1
- package/.next/standalone/platform/services/mcctl-console/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next/standalone/platform/services/mcctl-console/.next/server/app/_not-found.html +1 -1
- package/.next/standalone/platform/services/mcctl-console/.next/server/app/_not-found.rsc +1 -1
- package/.next/standalone/platform/services/mcctl-console/.next/server/app/audit-logs.html +1 -1
- package/.next/standalone/platform/services/mcctl-console/.next/server/app/audit-logs.rsc +1 -1
- package/.next/standalone/platform/services/mcctl-console/.next/server/app/backups.html +1 -1
- package/.next/standalone/platform/services/mcctl-console/.next/server/app/backups.rsc +1 -1
- package/.next/standalone/platform/services/mcctl-console/.next/server/app/dashboard.html +1 -1
- package/.next/standalone/platform/services/mcctl-console/.next/server/app/dashboard.rsc +1 -1
- package/.next/standalone/platform/services/mcctl-console/.next/server/app/index.html +1 -1
- package/.next/standalone/platform/services/mcctl-console/.next/server/app/index.rsc +1 -1
- package/.next/standalone/platform/services/mcctl-console/.next/server/app/login/page_client-reference-manifest.js +1 -1
- package/.next/standalone/platform/services/mcctl-console/.next/server/app/login.html +1 -1
- package/.next/standalone/platform/services/mcctl-console/.next/server/app/login.rsc +1 -1
- package/.next/standalone/platform/services/mcctl-console/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/standalone/platform/services/mcctl-console/.next/server/app/players.html +1 -1
- package/.next/standalone/platform/services/mcctl-console/.next/server/app/players.rsc +1 -1
- package/.next/standalone/platform/services/mcctl-console/.next/server/app/routing.html +1 -1
- package/.next/standalone/platform/services/mcctl-console/.next/server/app/routing.rsc +1 -1
- package/.next/standalone/platform/services/mcctl-console/.next/server/app/servers.html +1 -1
- package/.next/standalone/platform/services/mcctl-console/.next/server/app/servers.rsc +1 -1
- package/.next/standalone/platform/services/mcctl-console/.next/server/app/settings.html +1 -1
- package/.next/standalone/platform/services/mcctl-console/.next/server/app/settings.rsc +1 -1
- package/.next/standalone/platform/services/mcctl-console/.next/server/app/signup/page_client-reference-manifest.js +1 -1
- package/.next/standalone/platform/services/mcctl-console/.next/server/app/signup.html +1 -1
- package/.next/standalone/platform/services/mcctl-console/.next/server/app/signup.rsc +1 -1
- package/.next/standalone/platform/services/mcctl-console/.next/server/app/worlds.html +1 -1
- package/.next/standalone/platform/services/mcctl-console/.next/server/app/worlds.rsc +1 -1
- package/.next/standalone/platform/services/mcctl-console/.next/server/app-paths-manifest.json +19 -19
- package/.next/standalone/platform/services/mcctl-console/.next/server/chunks/354.js +1 -1
- package/.next/standalone/platform/services/mcctl-console/.next/server/chunks/5843.js +1 -1
- package/.next/standalone/platform/services/mcctl-console/.next/server/chunks/7573.js +1 -1
- package/.next/standalone/platform/services/mcctl-console/.next/server/chunks/8243.js +1 -1
- package/.next/standalone/platform/services/mcctl-console/.next/server/middleware-manifest.json +5 -5
- package/.next/standalone/platform/services/mcctl-console/.next/server/pages/404.html +1 -1
- package/.next/standalone/platform/services/mcctl-console/.next/server/pages/500.html +1 -1
- package/.next/standalone/platform/services/mcctl-console/.next/server/server-reference-manifest.json +1 -1
- package/package.json +2 -2
- /package/.next/standalone/platform/services/mcctl-console/.next/static/{NgRy0_19ToNR6zn_x3_CA → 7sS9MOwdyyBZ3UoHGY6I6}/_buildManifest.js +0 -0
- /package/.next/standalone/platform/services/mcctl-console/.next/static/{NgRy0_19ToNR6zn_x3_CA → 7sS9MOwdyyBZ3UoHGY6I6}/_ssgManifest.js +0 -0
- /package/.next/static/{NgRy0_19ToNR6zn_x3_CA → 7sS9MOwdyyBZ3UoHGY6I6}/_buildManifest.js +0 -0
- /package/.next/static/{NgRy0_19ToNR6zn_x3_CA → 7sS9MOwdyyBZ3UoHGY6I6}/_ssgManifest.js +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{var e={};e.id=278,e.ids=[278],e.modules={85890:e=>{"use strict";e.exports=require("better-sqlite3")},72934:e=>{"use strict";e.exports=require("next/dist/client/components/action-async-storage.external.js")},54580:e=>{"use strict";e.exports=require("next/dist/client/components/request-async-storage.external.js")},45869:e=>{"use strict";e.exports=require("next/dist/client/components/static-generation-async-storage.external.js")},20399:e=>{"use strict";e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},92048:e=>{"use strict";e.exports=require("fs")},55315:e=>{"use strict";e.exports=require("path")},17360:e=>{"use strict";e.exports=require("url")},61509:(e,t,i)=>{"use strict";i.r(t),i.d(t,{GlobalError:()=>o.a,__next_app__:()=>u,originalPathname:()=>d,pages:()=>c,routeModule:()=>f,tree:()=>h}),i(40579),i(26072),i(82395),i(97759);var n=i(95530),r=i(45086),s=i(13937),o=i.n(s),l=i(45587),a={};for(let e in l)0>["default","tree","pages","GlobalError","originalPathname","__next_app__","routeModule"].indexOf(e)&&(a[e]=()=>l[e]);i.d(t,a);let h=["",{children:["(main)",{children:["servers",{children:["[name]",{children:["__PAGE__",{},{page:[()=>Promise.resolve().then(i.bind(i,40579)),"/home/runner/work/minecraft-server-manager/minecraft-server-manager/platform/services/mcctl-console/src/app/(main)/servers/[name]/page.tsx"]}]},{}]},{}]},{layout:[()=>Promise.resolve().then(i.bind(i,26072)),"/home/runner/work/minecraft-server-manager/minecraft-server-manager/platform/services/mcctl-console/src/app/(main)/layout.tsx"],"not-found":[()=>Promise.resolve().then(i.t.bind(i,82395,23)),"next/dist/client/components/not-found-error"],metadata:{icon:[async e=>(await Promise.resolve().then(i.bind(i,52001))).default(e)],apple:[],openGraph:[],twitter:[],manifest:void 0}}]},{layout:[()=>Promise.resolve().then(i.bind(i,97759)),"/home/runner/work/minecraft-server-manager/minecraft-server-manager/platform/services/mcctl-console/src/app/layout.tsx"],"not-found":[()=>Promise.resolve().then(i.t.bind(i,82395,23)),"next/dist/client/components/not-found-error"],metadata:{icon:[async e=>(await Promise.resolve().then(i.bind(i,52001))).default(e)],apple:[],openGraph:[],twitter:[],manifest:void 0}}],c=["/home/runner/work/minecraft-server-manager/minecraft-server-manager/platform/services/mcctl-console/src/app/(main)/servers/[name]/page.tsx"],d="/(main)/servers/[name]/page",u={require:i,loadChunk:()=>Promise.resolve()},f=new n.AppPageRouteModule({definition:{kind:r.x.APP_PAGE,page:"/(main)/servers/[name]/page",pathname:"/servers/[name]",bundlePath:"",filename:"",appPaths:[]},userland:{loaderTree:h}})},21515:(e,t,i)=>{Promise.resolve().then(i.bind(i,51314))},42902:(e,t,i)=>{"use strict";var n=i(66682);t.Z=void 0;var r=n(i(7750)),s=i(58120);t.Z=(0,r.default)([(0,s.jsx)("path",{d:"M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2M12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8"},"0"),(0,s.jsx)("path",{d:"M12.5 7H11v6l5.25 3.15.75-1.23-4.5-2.67z"},"1")],"AccessTime")},95722:(e,t,i)=>{"use strict";var n=i(66682);t.Z=void 0;var r=n(i(7750)),s=i(58120);t.Z=(0,r.default)((0,s.jsx)("path",{d:"m12 4-1.41 1.41L16.17 11H4v2h12.17l-5.58 5.59L12 20l8-8z"}),"ArrowForward")},26567:(e,t,i)=>{"use strict";var n=i(66682);t.Z=void 0;var r=n(i(7750)),s=i(58120);t.Z=(0,r.default)((0,s.jsx)("path",{d:"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2m-5 14H7v-2h7zm3-4H7v-2h10zm0-4H7V7h10z"}),"Article")},75569:(e,t,i)=>{"use strict";var n=i(66682);t.Z=void 0;var r=n(i(7750)),s=i(58120);t.Z=(0,r.default)((0,s.jsx)("path",{d:"M16.5 6v11.5c0 2.21-1.79 4-4 4s-4-1.79-4-4V5c0-1.38 1.12-2.5 2.5-2.5s2.5 1.12 2.5 2.5v10.5c0 .55-.45 1-1 1s-1-.45-1-1V6H10v9.5c0 1.38 1.12 2.5 2.5 2.5s2.5-1.12 2.5-2.5V5c0-2.21-1.79-4-4-4S7 2.79 7 5v12.5c0 3.04 2.46 5.5 5.5 5.5s5.5-2.46 5.5-5.5V6z"}),"AttachFile")},65757:(e,t,i)=>{"use strict";var n=i(66682);t.Z=void 0;var r=n(i(7750)),s=i(58120);t.Z=(0,r.default)((0,s.jsx)("path",{d:"m22.7 19-9.1-9.1c.9-2.3.4-5-1.5-6.9-2-2-5-2.4-7.4-1.3L9 6 6 9 1.6 4.7C.4 7.1.9 10.1 2.9 12.1c1.9 1.9 4.6 2.4 6.9 1.5l9.1 9.1c.4.4 1 .4 1.4 0l2.3-2.3c.5-.4.5-1.1.1-1.4"}),"Build")},40238:(e,t,i)=>{"use strict";var n=i(66682);t.Z=void 0;var r=n(i(7750)),s=i(58120);t.Z=(0,r.default)((0,s.jsx)("path",{d:"M19.35 10.04C18.67 6.59 15.64 4 12 4 9.11 4 6.6 5.64 5.35 8.04 2.34 8.36 0 10.91 0 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96M14 13v4h-4v-4H7l5-5 5 5z"}),"CloudUpload")},64668:(e,t,i)=>{"use strict";var n=i(66682);t.Z=void 0;var r=n(i(7750)),s=i(58120);t.Z=(0,r.default)((0,s.jsx)("path",{d:"M9.4 16.6 4.8 12l4.6-4.6L8 6l-6 6 6 6zm5.2 0 4.6-4.6-4.6-4.6L16 6l6 6-6 6z"}),"Code")},10937:(e,t,i)=>{"use strict";var n=i(66682);t.Z=void 0;var r=n(i(7750)),s=i(58120);t.Z=(0,r.default)((0,s.jsx)("path",{d:"M20 6h-8l-2-2H4c-1.11 0-1.99.89-1.99 2L2 18c0 1.11.89 2 2 2h16c1.11 0 2-.89 2-2V8c0-1.11-.89-2-2-2m-1 8h-3v3h-2v-3h-3v-2h3V9h2v3h3z"}),"CreateNewFolder")},66147:(e,t,i)=>{"use strict";var n=i(66682);t.Z=void 0;var r=n(i(7750)),s=i(58120);t.Z=(0,r.default)((0,s.jsx)("path",{d:"M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6zm2.46-7.12 1.41-1.41L12 12.59l2.12-2.12 1.41 1.41L13.41 14l2.12 2.12-1.41 1.41L12 15.41l-2.12 2.12-1.41-1.41L10.59 14zM15.5 4l-1-1h-5l-1 1H5v2h14V4z"}),"DeleteForever")},61872:(e,t,i)=>{"use strict";var n=i(66682);t.Z=void 0;var r=n(i(7750)),s=i(58120);t.Z=(0,r.default)((0,s.jsx)("path",{d:"M14 2H6c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8zm2 16H8v-2h8zm0-4H8v-2h8zm-3-5V3.5L18.5 9z"}),"Description")},86202:(e,t,i)=>{"use strict";var n=i(66682);t.Z=void 0;var r=n(i(7750)),s=i(58120);t.Z=(0,r.default)((0,s.jsx)("path",{d:"M5 20h14v-2H5zM19 9h-4V3H9v6H5l7 7z"}),"Download")},92058:(e,t,i)=>{"use strict";var n=i(66682);t.Z=void 0;var r=n(i(7750)),s=i(58120);t.Z=(0,r.default)((0,s.jsx)("path",{d:"M18.41 5.8 17.2 4.59c-.78-.78-2.05-.78-2.83 0l-2.68 2.68L3 15.96V20h4.04l8.74-8.74 2.63-2.63c.79-.78.79-2.05 0-2.83M6.21 18H5v-1.21l8.66-8.66 1.21 1.21zM11 20l4-4h6v4z"}),"DriveFileRenameOutline")},50582:(e,t,i)=>{"use strict";var n=i(66682);t.Z=void 0;var r=n(i(7750)),s=i(58120);t.Z=(0,r.default)((0,s.jsx)("path",{d:"M20.5 11H19V7c0-1.1-.9-2-2-2h-4V3.5C13 2.12 11.88 1 10.5 1S8 2.12 8 3.5V5H4c-1.1 0-1.99.9-1.99 2v3.8H3.5c1.49 0 2.7 1.21 2.7 2.7s-1.21 2.7-2.7 2.7H2V20c0 1.1.9 2 2 2h3.8v-1.5c0-1.49 1.21-2.7 2.7-2.7 1.49 0 2.7 1.21 2.7 2.7V22H17c1.1 0 2-.9 2-2v-4h1.5c1.38 0 2.5-1.12 2.5-2.5S21.88 11 20.5 11"}),"Extension")},19103:(e,t,i)=>{"use strict";var n=i(66682);t.Z=void 0;var r=n(i(7750)),s=i(58120);t.Z=(0,r.default)((0,s.jsx)("path",{d:"M10 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2h-8z"}),"Folder")},46973:(e,t,i)=>{"use strict";var n=i(66682);t.Z=void 0;var r=n(i(7750)),s=i(58120);t.Z=(0,r.default)((0,s.jsx)("path",{d:"M20 6h-8l-2-2H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2m0 12H4V8h16z"}),"FolderOpen")},31620:(e,t,i)=>{"use strict";var n=i(66682);t.Z=void 0;var r=n(i(7750)),s=i(58120);t.Z=(0,r.default)((0,s.jsx)("path",{d:"M10 20v-6h4v6h5v-8h3L12 3 2 12h3v8z"}),"Home")},15348:(e,t,i)=>{"use strict";var n=i(66682);t.Z=void 0;var r=n(i(7750)),s=i(58120);t.Z=(0,r.default)((0,s.jsx)("path",{d:"M6 2c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6zm7 7V3.5L18.5 9z"}),"InsertDriveFile")},54896:(e,t,i)=>{"use strict";var n=i(66682);t.Z=void 0;var r=n(i(7750)),s=i(58120);t.Z=(0,r.default)((0,s.jsx)("path",{d:"M20 2H4c-1 0-2 .9-2 2v3.01c0 .72.43 1.34 1 1.69V20c0 1.1 1.1 2 2 2h14c.9 0 2-.9 2-2V8.7c.57-.35 1-.97 1-1.69V4c0-1.1-1-2-2-2m-5 12H9v-2h6zm5-7H4V4l16-.02z"}),"Inventory")},82538:(e,t,i)=>{"use strict";var n=i(66682);t.Z=void 0;var r=n(i(7750)),s=i(58120);t.Z=(0,r.default)((0,s.jsx)("path",{d:"M7.41 8.59 12 13.17l4.59-4.58L18 10l-6 6-6-6z"}),"KeyboardArrowDown")},75614:(e,t,i)=>{"use strict";var n=i(66682);t.Z=void 0;var r=n(i(7750)),s=i(58120);t.Z=(0,r.default)((0,s.jsx)("path",{d:"M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2m6.93 6h-2.95c-.32-1.25-.78-2.45-1.38-3.56 1.84.63 3.37 1.91 4.33 3.56M12 4.04c.83 1.2 1.48 2.53 1.91 3.96h-3.82c.43-1.43 1.08-2.76 1.91-3.96M4.26 14C4.1 13.36 4 12.69 4 12s.1-1.36.26-2h3.38c-.08.66-.14 1.32-.14 2 0 .68.06 1.34.14 2zm.82 2h2.95c.32 1.25.78 2.45 1.38 3.56-1.84-.63-3.37-1.9-4.33-3.56m2.95-8H5.08c.96-1.66 2.49-2.93 4.33-3.56C8.81 5.55 8.35 6.75 8.03 8M12 19.96c-.83-1.2-1.48-2.53-1.91-3.96h3.82c-.43 1.43-1.08 2.76-1.91 3.96M14.34 14H9.66c-.09-.66-.16-1.32-.16-2 0-.68.07-1.35.16-2h4.68c.09.65.16 1.32.16 2 0 .68-.07 1.34-.16 2m.25 5.56c.6-1.11 1.06-2.31 1.38-3.56h2.95c-.96 1.65-2.49 2.93-4.33 3.56M16.36 14c.08-.66.14-1.32.14-2 0-.68-.06-1.34-.14-2h3.38c.16.64.26 1.31.26 2s-.1 1.36-.26 2z"}),"Language")},61989:(e,t,i)=>{"use strict";var n=i(66682);t.Z=void 0;var r=n(i(7750)),s=i(58120);t.Z=(0,r.default)((0,s.jsx)("path",{d:"M19 5v14H5V5zm1.1-2H3.9c-.5 0-.9.4-.9.9v16.2c0 .4.4.9.9.9h16.2c.4 0 .9-.5.9-.9V3.9c0-.5-.5-.9-.9-.9M11 7h6v2h-6zm0 4h6v2h-6zm0 4h6v2h-6zM7 7h2v2H7zm0 4h2v2H7zm0 4h2v2H7z"}),"ListAlt")},58039:(e,t,i)=>{"use strict";var n=i(66682);t.Z=void 0;var r=n(i(7750)),s=i(58120);t.Z=(0,r.default)((0,s.jsx)("path",{d:"m21.41 11.58-9-9C12.05 2.22 11.55 2 11 2H4c-1.1 0-2 .9-2 2v7c0 .55.22 1.05.59 1.42l9 9c.36.36.86.58 1.41.58.55 0 1.05-.22 1.41-.59l7-7c.37-.36.59-.86.59-1.41 0-.55-.23-1.06-.59-1.42M5.5 7C4.67 7 4 6.33 4 5.5S4.67 4 5.5 4 7 4.67 7 5.5 6.33 7 5.5 7"}),"LocalOffer")},25414:(e,t,i)=>{"use strict";var n=i(66682);t.Z=void 0;var r=n(i(7750)),s=i(58120);t.Z=(0,r.default)((0,s.jsx)("path",{d:"M21 11V3h-8l3.29 3.29-10 10L3 13v8h8l-3.29-3.29 10-10z"}),"OpenInFull")},72419:(e,t,i)=>{"use strict";var n=i(66682);t.Z=void 0;var r=n(i(7750)),s=i(58120);t.Z=(0,r.default)((0,s.jsx)("path",{d:"M9 16h2V8H9zm3-14C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8m1-4h2V8h-2z"}),"PauseCircleOutline")},17820:(e,t,i)=>{"use strict";var n=i(66682);t.Z=void 0;var r=n(i(7750)),s=i(58120);t.Z=(0,r.default)((0,s.jsx)("path",{d:"M12 5V2L8 6l4 4V7c3.31 0 6 2.69 6 6 0 2.97-2.17 5.43-5 5.91v2.02c3.95-.49 7-3.85 7-7.93 0-4.42-3.58-8-8-8m-6 8c0-1.65.67-3.15 1.76-4.24L6.34 7.34C4.9 8.79 4 10.79 4 13c0 4.08 3.05 7.44 7 7.93v-2.02c-2.83-.48-5-2.94-5-5.91"}),"RestartAlt")},11475:(e,t,i)=>{"use strict";var n=i(66682);t.Z=void 0;var r=n(i(7750)),s=i(58120);t.Z=(0,r.default)((0,s.jsx)("path",{d:"M17 3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V7zm-5 16c-1.66 0-3-1.34-3-3s1.34-3 3-3 3 1.34 3 3-1.34 3-3 3m3-10H5V5h10z"}),"Save")},7060:(e,t,i)=>{"use strict";var n=i(66682);t.Z=void 0;var r=n(i(7750)),s=i(58120);t.Z=(0,r.default)((0,s.jsx)("path",{d:"M18 2h-8L4.02 8 4 20c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2m-6 6h-2V4h2zm3 0h-2V4h2zm3 0h-2V4h2z"}),"SdStorage")},93599:(e,t,i)=>{"use strict";var n=i(66682);t.Z=void 0;var r=n(i(7750)),s=i(58120);t.Z=(0,r.default)((0,s.jsx)("path",{d:"M12 1 3 5v6c0 5.55 3.84 10.74 9 12 5.16-1.26 9-6.45 9-12V5z"}),"Shield")},36438:(e,t,i)=>{"use strict";var n=i(66682);t.Z=void 0;var r=n(i(7750)),s=i(58120);t.Z=(0,r.default)((0,s.jsx)("path",{d:"m20.38 8.57-1.23 1.85a8 8 0 0 1-.22 7.58H5.07A8 8 0 0 1 15.58 6.85l1.85-1.23A10 10 0 0 0 3.35 19a2 2 0 0 0 1.72 1h13.85a2 2 0 0 0 1.74-1 10 10 0 0 0-.27-10.44zm-9.79 6.84a2 2 0 0 0 2.83 0l5.66-8.49-8.49 5.66a2 2 0 0 0 0 2.83"}),"Speed")},3470:(e,t,i)=>{"use strict";var n=i(66682);t.Z=void 0;var r=n(i(7750)),s=i(58120);t.Z=(0,r.default)((0,s.jsx)("path",{d:"m21.58 16.09-1.09-7.66C20.21 6.46 18.52 5 16.53 5H7.47C5.48 5 3.79 6.46 3.51 8.43l-1.09 7.66C2.2 17.63 3.39 19 4.94 19c.68 0 1.32-.27 1.8-.75L9 16h6l2.25 2.25c.48.48 1.13.75 1.8.75 1.56 0 2.75-1.37 2.53-2.91M11 11H9v2H8v-2H6v-1h2V8h1v2h2zm4-1c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1m2 3c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1"}),"SportsEsports")},43992:(e,t,i)=>{"use strict";var n=i(66682);t.Z=void 0;var r=n(i(7750)),s=i(58120);t.Z=(0,r.default)((0,s.jsx)("path",{d:"M20 4H4c-1.11 0-2 .9-2 2v12c0 1.1.89 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.89-2-2-2m0 14H4V8h16zm-2-1h-6v-2h6zM7.5 17l-1.41-1.41L8.67 13l-2.59-2.59L7.5 9l4 4z"}),"Terminal")},40768:(e,t,i)=>{"use strict";var n=i(66682);t.Z=void 0;var r=n(i(7750)),s=i(58120);t.Z=(0,r.default)((0,s.jsx)("path",{d:"M3 17v2h6v-2zM3 5v2h10V5zm10 16v-2h8v-2h-8v-2h-2v6zM7 9v2H3v2h4v2h2V9zm14 4v-2H11v2zm-6-4h2V7h4V5h-4V3h-2z"}),"Tune")},34615:(e,t,i)=>{"use strict";var n=i(66682);t.Z=void 0;var r=n(i(7750)),s=i(58120);t.Z=(0,r.default)((0,s.jsx)("path",{d:"M12.5 8c-2.65 0-5.05.99-6.9 2.6L2 7v9h9l-3.62-3.62c1.39-1.16 3.16-1.88 5.12-1.88 3.54 0 6.55 2.31 7.6 5.5l2.37-.78C21.08 11.03 17.15 8 12.5 8"}),"Undo")},80403:(e,t,i)=>{"use strict";var n=i(66682);t.Z=void 0;var r=n(i(7750)),s=i(58120);t.Z=(0,r.default)((0,s.jsx)("path",{d:"M14 2H6c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8zm4 18H6V4h7v5h5zM8 15.01l1.41 1.41L11 14.84V19h2v-4.16l1.59 1.59L16 15.01 12.01 11z"}),"UploadFile")},23090:(e,t,i)=>{"use strict";var n=i(66682);t.Z=void 0;var r=n(i(7750)),s=i(58120);t.Z=(0,r.default)((0,s.jsx)("path",{d:"m18.25 7.6-5.5-3.18c-.46-.27-1.04-.27-1.5 0L5.75 7.6c-.46.27-.75.76-.75 1.3v6.35c0 .54.29 1.03.75 1.3l5.5 3.18c.46.27 1.04.27 1.5 0l5.5-3.18c.46-.27.75-.76.75-1.3V8.9c0-.54-.29-1.03-.75-1.3M7 14.96v-4.62l4 2.32v4.61zm5-4.03L8 8.61l4-2.31 4 2.31zm1 6.34v-4.61l4-2.32v4.62zM7 2H3.5C2.67 2 2 2.67 2 3.5V7h2V4h3zm10 0h3.5c.83 0 1.5.67 1.5 1.5V7h-2V4h-3zM7 22H3.5c-.83 0-1.5-.67-1.5-1.5V17h2v3h3zm10 0h3.5c.83 0 1.5-.67 1.5-1.5V17h-2v3h-3z"}),"ViewInAr")},26518:(e,t,i)=>{"use strict";var n=i(66682);t.Z=void 0;var r=n(i(7750)),s=i(58120);t.Z=(0,r.default)((0,s.jsx)("path",{d:"M1 21h22L12 2zm12-3h-2v-2h2zm0-4h-2v-4h2z"}),"Warning")},61649:(e,t,i)=>{"use strict";var n=i(66682);t.Z=void 0;var r=n(i(7750)),s=i(58120);t.Z=(0,r.default)([(0,s.jsx)("path",{d:"M12 5.99 19.53 19H4.47zM12 2 1 21h22z"},"0"),(0,s.jsx)("path",{d:"M13 16h-2v2h2zm0-6h-2v5h2z"},"1")],"WarningAmber")},664:(e,t,i)=>{"use strict";i.d(t,{Z:()=>x});var n=i(4981),r=i(36885),s=i(36372),o=i(30330),l=i(3693),a=i(9103),h=i(62923),c=i(89206),d=i(7967);function u(e){return(0,d.ZP)("MuiTableContainer",e)}(0,c.Z)("MuiTableContainer",["root"]);var f=i(58120);let p=["className","component"],m=e=>{let{classes:t}=e;return(0,l.Z)({root:["root"]},u,t)},g=(0,h.ZP)("div",{name:"MuiTableContainer",slot:"Root",overridesResolver:(e,t)=>t.root})({width:"100%",overflowX:"auto"}),x=s.forwardRef(function(e,t){let i=(0,a.i)({props:e,name:"MuiTableContainer"}),{className:s,component:l="div"}=i,h=(0,r.Z)(i,p),c=(0,n.Z)({},i,{component:l}),d=m(c);return(0,f.jsx)(g,(0,n.Z)({ref:t,as:l,className:(0,o.Z)(d.root,s),ownerState:c},h))})},51314:(e,t,i)=>{"use strict";let n,r;i.r(t),i.d(t,{default:()=>fv});var s,o,l,a,h=i(58120),c=i(36372),d=i(56539),u=i(49856),f=i(89352),p=i(10257),m=i(54365),g=i(66757),x=i(79943),v=i(68913),y=i(67073),b=i(92797),w=i(2365),k=i(81030),S=i(99634),C=i(63654),j=i(63856),M=i(34443),Z=i(44696),A=i(15539),T=i(51290),O=i(6275),D=i(73100),R=i(95940),P=i(43312),L=i(29553),I=i(54655),E=i(96454),B=i(23090),N=i(58039),z=i(30463),W=i(42902),F=i(48787),V=i(92559),H=i(80336),$=i(62073),q=i(98693),K=i(33615),U=i(36438),_=i(7060),G=i(46973),J=i(25414),X=i(82538),Y=i(43992),Q=i(95223);function ee({value:e,unit:t,label:i,icon:n,progress:r,progressMax:s,color:o="#1bd96a"}){return(0,h.jsxs)(y.Z,{"data-testid":"resource-stat-card",sx:{p:2.5,bgcolor:"background.paper",border:"1px solid",borderColor:"divider",borderRadius:3},children:[(0,h.jsxs)(f.Z,{sx:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:2},children:[(0,h.jsxs)(f.Z,{sx:{display:"flex",alignItems:"baseline",gap:.75,flexWrap:"wrap",minWidth:0},children:[h.jsx(w.Z,{variant:"h4",component:"span",sx:{fontWeight:700,color:"text.primary",letterSpacing:"-0.5px"},children:e}),h.jsx(w.Z,{variant:"body2",component:"span",sx:{color:"text.secondary",fontWeight:500},children:t})]}),h.jsx(f.Z,{sx:{color:"text.secondary",flexShrink:0},children:n})]}),h.jsx(w.Z,{variant:"body2",sx:{color:"text.secondary",fontWeight:500,mt:.5},children:i}),h.jsx(Q.Z,{variant:"determinate",value:Math.min(r/s*100,100),sx:{mt:1,height:6,borderRadius:1.5,bgcolor:"#2a2d3a","& .MuiLinearProgress-bar":{borderRadius:1.5,background:`linear-gradient(90deg, ${o} 0%, ${o}cc 100%)`}}})]})}var et=i(50423),ei=i(6418),en=i(58664),er=i(73091),es=i(98243),eo=i(40611),el=i(95722),ea=i(71438),eh=i(55049),ec=i(15784);function ed({serverName:e}){let{data:t,isLoading:i,error:n}=(0,ec.HZ)(e,{limit:20});if(i)return h.jsx(f.Z,{children:[void 0,void 0,void 0,void 0,void 0].map((e,t)=>(0,h.jsxs)(f.Z,{sx:{display:"flex",gap:2,py:1.5},children:[h.jsx(v.Z,{variant:"rounded",width:60,height:24}),h.jsx(v.Z,{variant:"text",width:"60%"}),h.jsx(v.Z,{variant:"text",width:50})]},t))});if(n)return(0,h.jsxs)(g.Z,{severity:"error",children:["Failed to load activity: ",n.message]});let r=t?.logs??[];if(0===r.length)return h.jsx(w.Z,{variant:"body2",color:"text.secondary",sx:{py:4,textAlign:"center"},children:"No activity recorded for this server yet."});let s=`/audit-logs?targetType=server&targetName=${encodeURIComponent(e)}`;return(0,h.jsxs)(f.Z,{children:[h.jsx(en.Z,{sx:{py:0},children:r.map(e=>{var t;return h.jsx(er.ZP,{sx:{px:0,py:1.5,"&:not(:last-child)":{borderBottom:"1px solid",borderColor:"divider"}},children:h.jsx(j.Z,{primary:(0,h.jsxs)(f.Z,{sx:{display:"flex",alignItems:"center",gap:1},children:[h.jsx(ea.I,{action:e.action,size:"small"}),(0,h.jsxs)(w.Z,{variant:"body2",color:"text.secondary",children:["by ",e.actor.replace("api:","").replace("cli:","")]}),h.jsx(eh.c,{status:e.status,size:"small"})]}),secondary:h.jsx(es.Z,{title:(t=e.timestamp,new Intl.DateTimeFormat(void 0,{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",timeZoneName:"short"}).format(new Date(t))),arrow:!0,children:h.jsx(w.Z,{variant:"caption",component:"span",color:"text.disabled",children:function(e){let t=new Date,i=new Date(e),n=Math.floor((t.getTime()-i.getTime())/6e4),r=Math.floor(n/60);return n<1?"just now":n<60?`${n}m ago`:r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}(e.timestamp)})})})},e.id)})}),h.jsx(f.Z,{sx:{mt:2,textAlign:"center"},children:h.jsx(p.Z,{component:eo.default,href:s,size:"small",endIcon:h.jsx(el.Z,{}),sx:{textTransform:"none"},children:"View Full History"})})]})}var eu=i(60920),ef=i(26518),ep=i(66147),em=i(17820),eg=i(74151),ex=i(23016),ev=i(61960),ey=i(29564),eb=i(11475),ew=i(75614);function ek({serverName:e}){let{data:t,isLoading:i}=(0,eg.Js)(e),n=(0,eg.Bx)(),[r,s]=(0,c.useState)([]),[o,l]=(0,c.useState)(!1),[a,d]=(0,c.useState)(!1),[u,v]=(0,c.useState)(""),[k,S]=(0,c.useState)(""),[C,j]=(0,c.useState)(!1),[M,Z]=(0,c.useState)({open:!1,message:"",severity:"success"}),A=e=>{let t=e.trim().toLowerCase();return t?t.length>253?"Domain exceeds 253 characters":/^[a-z0-9]([a-z0-9\-.]*[a-z0-9])?$/.test(t)?t.endsWith(".local")?"Cannot use .local system domain":t.endsWith(".nip.io")?"Cannot use .nip.io system domain":r.includes(t)?"Domain already exists":"":"Invalid domain format":"Domain cannot be empty"},T=()=>{let e=u.trim().toLowerCase(),t=A(e);if(t){S(t);return}s(t=>[...t,e]),v(""),S(""),d(!1),l(!0)},D=e=>{s(t=>t.filter(t=>t!==e)),l(!0)},R=async()=>{try{await n.mutateAsync({serverName:e,customHostnames:r}),l(!1),j(!0),Z({open:!0,message:"Hostnames saved. Container recreation required to apply changes.",severity:"warning"})}catch(e){Z({open:!0,message:e instanceof Error?e.message:"Failed to save hostnames",severity:"error"})}},P=()=>{d(!1),v(""),S("")};return i?h.jsx(y.Z,{sx:{mb:3,borderRadius:3},children:h.jsx(b.Z,{children:h.jsx(f.Z,{sx:{display:"flex",justifyContent:"center",py:4},children:h.jsx(x.Z,{size:24})})})}):(0,h.jsxs)(h.Fragment,{children:[h.jsx(y.Z,{sx:{mb:3,borderRadius:3},children:(0,h.jsxs)(b.Z,{children:[(0,h.jsxs)(f.Z,{sx:{display:"flex",alignItems:"center",gap:1,mb:1},children:[h.jsx(ew.Z,{color:"primary"}),h.jsx(w.Z,{variant:"h6",fontWeight:600,children:"Hostnames / Domains"})]}),h.jsx(w.Z,{variant:"body2",color:"text.secondary",sx:{mb:2},children:"Manage hostnames used by mc-router to route connections to this server."}),h.jsx(H.Z,{sx:{mb:3}}),t?.systemHostnames&&t.systemHostnames.length>0&&(0,h.jsxs)(f.Z,{sx:{mb:3},children:[h.jsx(w.Z,{variant:"subtitle2",color:"text.secondary",sx:{mb:1},children:"System Hostnames (read-only)"}),h.jsx(ex.Z,{direction:"row",flexWrap:"wrap",gap:1,children:t.systemHostnames.map(e=>h.jsx(F.Z,{icon:h.jsx(ev.Z,{sx:{fontSize:16}}),label:e.hostname,title:e.description,variant:"outlined",color:"default",size:"small"},e.hostname))})]}),(0,h.jsxs)(f.Z,{sx:{mb:2},children:[h.jsx(w.Z,{variant:"subtitle2",color:"text.secondary",sx:{mb:1},children:"Custom Domains"}),0===r.length&&!a&&h.jsx(w.Z,{variant:"body2",color:"text.disabled",sx:{mb:1},children:"No custom domains configured."}),h.jsx(ex.Z,{spacing:1,children:r.map(e=>(0,h.jsxs)(f.Z,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",py:.5,px:1.5,borderRadius:1,bgcolor:"action.hover"},children:[h.jsx(w.Z,{variant:"body2",children:e}),h.jsx(m.Z,{size:"small",color:"error",onClick:()=>D(e),title:"Remove domain",children:h.jsx(E.Z,{fontSize:"small"})})]},e))}),a?(0,h.jsxs)(f.Z,{sx:{display:"flex",alignItems:"flex-start",gap:1,mt:1},children:[h.jsx(O.Z,{size:"small",placeholder:"e.g. play.example.com",value:u,onChange:e=>{v(e.target.value),S("")},onKeyDown:e=>{"Enter"===e.key&&T(),"Escape"===e.key&&P()},error:!!k,helperText:k,autoFocus:!0,sx:{flex:1}}),h.jsx(p.Z,{size:"small",variant:"contained",onClick:T,children:"Add"}),h.jsx(m.Z,{size:"small",onClick:P,children:h.jsx(K.Z,{fontSize:"small"})})]}):h.jsx(p.Z,{size:"small",startIcon:h.jsx(ey.Z,{}),onClick:()=>d(!0),sx:{mt:1},children:"Add Domain"})]}),C&&(0,h.jsxs)(g.Z,{severity:"warning",sx:{mb:2},children:["Container recreation is required for hostname changes to take effect. Run ",h.jsx("code",{children:"docker compose up -d"})," or restart the server from the dashboard."]}),h.jsx(f.Z,{sx:{display:"flex",justifyContent:"flex-end"},children:h.jsx(p.Z,{variant:"contained",size:"small",startIcon:h.jsx(eb.Z,{}),onClick:R,disabled:!o||n.isPending,children:n.isPending?"Saving...":"Save Hostnames"})})]})}),h.jsx(eu.Z,{open:M.open,autoHideDuration:6e3,onClose:()=>Z({...M,open:!1}),anchorOrigin:{vertical:"bottom",horizontal:"right"},children:h.jsx(g.Z,{onClose:()=>Z({...M,open:!1}),severity:M.severity,sx:{width:"100%"},children:M.message})})]})}var eS=i(5374),eC=i(84527),ej=i(73276),eM=i(32486),eZ=i(2200),eA=i(14360),eT=i(16770),eO=i(27767),eD=i(36739);function eR({field:e,value:t,onChange:i}){let[n,r]=(0,c.useState)(!1),s=e.columns??6;return h.jsx(D.ZP,{item:!0,xs:12,sm:s,children:(()=>{switch(e.type){case"boolean":return(0,h.jsxs)(f.Z,{children:[h.jsx(eA.Z,{control:h.jsx(eT.Z,{checked:t??!1,onChange:t=>i(e.key,t.target.checked)}),label:e.label}),e.helperText&&h.jsx(w.Z,{variant:"caption",color:"text.secondary",sx:{ml:4,display:"block"},children:e.helperText})]});case"select":return(0,h.jsxs)(eM.Z,{fullWidth:!0,size:"small",children:[h.jsx(eZ.Z,{children:e.label}),h.jsx(ej.Z,{value:t??e.options?.[0]?.value??"",label:e.label,onChange:t=>i(e.key,t.target.value),children:e.options?.map(e=>h.jsx(S.Z,{value:e.value,children:e.label},e.value))})]});case"number":return h.jsx(O.Z,{fullWidth:!0,size:"small",type:"number",label:e.label,value:t??"",onChange:t=>{let n=t.target.value;i(e.key,""===n?void 0:parseInt(n,10))},inputProps:{min:e.validation?.min,max:e.validation?.max},helperText:e.helperText,InputProps:e.unit?{endAdornment:h.jsx(V.Z,{position:"end",children:h.jsx(w.Z,{variant:"caption",color:"text.secondary",children:e.unit})})}:void 0});case"password":return h.jsx(O.Z,{fullWidth:!0,size:"small",type:n?"text":"password",label:e.label,value:t??"",onChange:t=>i(e.key,t.target.value),helperText:e.helperText,InputProps:{endAdornment:h.jsx(V.Z,{position:"end",children:h.jsx(m.Z,{size:"small",onClick:()=>r(!n),edge:"end",children:n?h.jsx(eD.Z,{fontSize:"small"}):h.jsx(eO.Z,{fontSize:"small"})})})}});default:return h.jsx(O.Z,{fullWidth:!0,size:"small",label:e.label,value:t??"",onChange:t=>i(e.key,t.target.value),helperText:e.helperText})}})()})}function eP({section:e,values:t,onChange:i}){let[n,r]=(0,c.useState)(!1),s=e.icon,o=e.advancedFields.length;return h.jsx(y.Z,{sx:{mb:3,borderRadius:3},children:(0,h.jsxs)(b.Z,{sx:{p:3},children:[(0,h.jsxs)(f.Z,{sx:{display:"flex",alignItems:"center",gap:1.5,mb:1},children:[h.jsx(s,{sx:{fontSize:22,color:"primary.main"}}),h.jsx(w.Z,{variant:"h6",fontWeight:600,children:e.title})]}),h.jsx(w.Z,{variant:"body2",color:"text.secondary",sx:{mb:2},children:e.description}),h.jsx(H.Z,{sx:{mb:3}}),h.jsx(D.ZP,{container:!0,spacing:2.5,children:e.essentialFields.map(e=>h.jsx(eR,{field:e,value:t[e.key],onChange:i},e.key))}),o>0&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(p.Z,{fullWidth:!0,variant:"text",onClick:()=>r(!n),endIcon:h.jsx(eC.Z,{sx:{transform:n?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.3s"}}),sx:{mt:2.5,justifyContent:"flex-start",color:"text.secondary",textTransform:"none",py:1,"&:hover":{bgcolor:"action.hover"}},children:[n?"Hide":"Show"," Advanced Settings (",o,")"]}),h.jsx(eS.Z,{in:n,timeout:300,children:h.jsx(f.Z,{sx:{pt:2,borderTop:"1px dashed",borderColor:"divider"},children:h.jsx(D.ZP,{container:!0,spacing:2.5,children:e.advancedFields.map(e=>h.jsx(eR,{field:e,value:t[e.key],onChange:i},e.key))})})})]})]})})}var eL=i(11999);function eI({hasChanges:e,changedCount:t,hasRestartChanges:i,restartFields:n=[],isSaving:r,onSave:s,onDiscard:o}){return h.jsx(eL.Z,{direction:"up",in:e,mountOnEnter:!0,unmountOnExit:!0,children:(0,h.jsxs)(f.Z,{sx:{position:"sticky",bottom:0,zIndex:1100,bgcolor:"background.paper",borderTop:2,borderColor:"primary.main",px:{xs:2,sm:3},py:2,mx:{xs:-2,sm:-3},mb:{xs:-2,sm:-3},boxShadow:"0 -4px 20px rgba(0,0,0,0.4)",display:"flex",alignItems:"center",justifyContent:"space-between",flexWrap:"wrap",gap:1},children:[(0,h.jsxs)(f.Z,{sx:{display:"flex",alignItems:"center",gap:1},children:[i&&h.jsx(em.Z,{sx:{color:"warning.main",fontSize:20}}),(0,h.jsxs)(w.Z,{variant:"body2",fontWeight:600,children:[t," unsaved change",1!==t?"s":""]}),i&&(0,h.jsxs)(w.Z,{variant:"caption",color:"warning.main",children:["(",n.length>0?n.join(", "):"some fields"," require restart)"]})]}),(0,h.jsxs)(f.Z,{sx:{display:"flex",gap:1},children:[h.jsx(p.Z,{variant:"text",color:"inherit",onClick:o,disabled:r,children:"Discard"}),h.jsx(p.Z,{variant:"contained",startIcon:r?h.jsx(x.Z,{size:16,color:"inherit"}):h.jsx(eb.Z,{}),onClick:s,disabled:r,children:r?"Saving...":`Save Changes (${t})`})]})]})})}function eE({open:e,changedFields:t,onSaveOnly:i,onSaveAndRestart:n,onCancel:r}){return(0,h.jsxs)(M.Z,{open:e,onClose:r,maxWidth:"sm",fullWidth:!0,children:[h.jsx(Z.Z,{children:(0,h.jsxs)(f.Z,{sx:{display:"flex",alignItems:"center",gap:1},children:[h.jsx(em.Z,{color:"warning"}),h.jsx(w.Z,{variant:"h6",fontWeight:600,children:"Restart Required"})]})}),(0,h.jsxs)(A.Z,{children:[h.jsx(w.Z,{variant:"body1",gutterBottom:!0,children:"The following changes require a server restart to take effect:"}),h.jsx(en.Z,{dense:!0,children:t.map(e=>h.jsx(er.ZP,{sx:{py:0},children:h.jsx(j.Z,{primary:e,primaryTypographyProps:{variant:"body2"}})},e))})]}),(0,h.jsxs)(T.Z,{children:[h.jsx(p.Z,{onClick:r,color:"inherit",children:"Cancel"}),h.jsx(p.Z,{onClick:i,variant:"outlined",children:"Save Only"}),h.jsx(p.Z,{onClick:n,variant:"contained",color:"warning",children:"Save & Restart"})]})]})}var eB=i(3470),eN=i(765),ez=i(93599),eW=i(72419),eF=i(77343);let eV=[{id:"gameplay",icon:eB.Z,title:"Gameplay",description:"Core game rules and player experience settings.",essentialFields:[{key:"difficulty",label:"Difficulty",type:"select",options:[{value:"peaceful",label:"Peaceful"},{value:"easy",label:"Easy"},{value:"normal",label:"Normal"},{value:"hard",label:"Hard"}]},{key:"gameMode",label:"Game Mode",type:"select",options:[{value:"survival",label:"Survival"},{value:"creative",label:"Creative"},{value:"adventure",label:"Adventure"},{value:"spectator",label:"Spectator"}]},{key:"maxPlayers",label:"Max Players",type:"number",validation:{min:1,max:1e3}},{key:"pvp",label:"Enable PvP",type:"boolean",helperText:"Allow players to damage each other"}],advancedFields:[{key:"forceGamemode",label:"Force Game Mode",type:"boolean",helperText:"Force game mode when players join"},{key:"hardcore",label:"Hardcore",type:"boolean",helperText:"One life only - world deleted on death"},{key:"allowFlight",label:"Allow Flight",type:"boolean",helperText:"Allow flight in survival mode"},{key:"allowNether",label:"Allow Nether",type:"boolean",helperText:"Enable Nether portal access"},{key:"enableCommandBlock",label:"Command Blocks",type:"boolean",helperText:"Enable command block functionality"},{key:"spawnProtection",label:"Spawn Protection",type:"number",helperText:"Radius around spawn (0 = disabled)",unit:"blocks",validation:{min:0,max:256}},{key:"spawnAnimals",label:"Spawn Animals",type:"boolean",helperText:"Spawn passive mobs (cows, pigs, etc.)"},{key:"spawnMonsters",label:"Spawn Monsters",type:"boolean",helperText:"Spawn hostile mobs (zombies, creepers, etc.)"},{key:"spawnNpcs",label:"Spawn NPCs",type:"boolean",helperText:"Spawn villagers and wandering traders"}]},{id:"world",icon:eN.Z,title:"World",description:"World generation and server identity settings.",essentialFields:[{key:"motd",label:"MOTD (Message of the Day)",type:"string",helperText:"Displayed in the server list",columns:12},{key:"level",label:"World Name",type:"string",helperText:"Save folder name",restartRequired:!0},{key:"levelType",label:"Level Type",type:"select",restartRequired:!0,options:[{value:"default",label:"Default"},{value:"flat",label:"Flat"},{value:"largeBiomes",label:"Large Biomes"},{value:"amplified",label:"Amplified"},{value:"buffet",label:"Buffet"}]},{key:"seed",label:"World Seed",type:"string",helperText:"Only affects new world generation",restartRequired:!0}],advancedFields:[{key:"generateStructures",label:"Generate Structures",type:"boolean",helperText:"Generate villages, temples, etc."},{key:"maxWorldSize",label:"Max World Size",type:"number",unit:"blocks",helperText:"Maximum world radius",validation:{min:1,max:29999984}},{key:"icon",label:"Server Icon URL",type:"string",helperText:"64x64 PNG image URL",columns:12}]},{id:"security",icon:ez.Z,title:"Security",description:"Authentication and access control settings.",essentialFields:[{key:"onlineMode",label:"Online Mode (Mojang Auth)",type:"boolean",helperText:"Disable to allow cracked clients (not recommended)",restartRequired:!0},{key:"enableWhitelist",label:"Enable Whitelist",type:"boolean",helperText:"Only whitelisted players can join",restartRequired:!0}],advancedFields:[{key:"enforceWhitelist",label:"Enforce Whitelist",type:"boolean",helperText:"Kick non-whitelisted players already online",restartRequired:!0},{key:"enforceSecureProfile",label:"Enforce Secure Profile",type:"boolean",helperText:"Require signed chat messages from players",restartRequired:!0}]},{id:"performance",icon:U.Z,title:"Performance & JVM",description:"Memory, view distance, and JVM optimization settings.",essentialFields:[{key:"memory",label:"Memory",type:"string",helperText:"e.g., 2G, 4G, 8G",restartRequired:!0},{key:"useAikarFlags",label:"Aikar's Flags",type:"boolean",helperText:"Optimized GC flags for Paper/Spigot",restartRequired:!0},{key:"viewDistance",label:"View Distance",type:"number",unit:"chunks",validation:{min:2,max:32}}],advancedFields:[{key:"simulationDistance",label:"Simulation Distance",type:"number",unit:"chunks",validation:{min:3,max:32}},{key:"maxTickTime",label:"Max Tick Time",type:"number",unit:"ms",helperText:"-1 to disable watchdog",validation:{min:-1}},{key:"initMemory",label:"Initial Heap",type:"string",helperText:"e.g., 1G (overrides Memory)",restartRequired:!0},{key:"maxMemory",label:"Max Heap",type:"string",helperText:"e.g., 8G (overrides Memory)",restartRequired:!0},{key:"jvmXxOpts",label:"JVM -XX Options",type:"string",helperText:"Additional -XX JVM flags",restartRequired:!0,columns:12}]},{id:"autopause",icon:eW.Z,title:"Auto-pause / Auto-stop",description:"Automatically pause or stop when no players are connected.",essentialFields:[{key:"enableAutopause",label:"Enable Auto-pause",type:"boolean",helperText:"Pause process when no players connected",restartRequired:!0},{key:"autopauseTimeoutEst",label:"Pause Timeout",type:"number",unit:"seconds",helperText:"Wait time after last player leaves",validation:{min:0}}],advancedFields:[{key:"autopauseTimeoutInit",label:"Init Timeout",type:"number",unit:"seconds",helperText:"Timeout after start without connections",validation:{min:0}},{key:"autopausePeriod",label:"Check Period",type:"number",unit:"seconds",helperText:"Status check interval",validation:{min:1}},{key:"enableAutostop",label:"Enable Auto-stop",type:"boolean",helperText:"Stop container when no players connected",restartRequired:!0},{key:"autostopTimeoutEst",label:"Stop Timeout",type:"number",unit:"seconds",helperText:"Wait time before stopping container",validation:{min:0}}]},{id:"system",icon:eF.Z,title:"System",description:"Timezone, resource pack, RCON, and container settings.",essentialFields:[{key:"tz",label:"Timezone",type:"string",helperText:"e.g., Asia/Seoul, UTC",restartRequired:!0},{key:"resourcePack",label:"Resource Pack URL",type:"string",helperText:"Direct download URL for resource pack",columns:12},{key:"enableRcon",label:"Enable RCON",type:"boolean",helperText:"Remote server console access",restartRequired:!0}],advancedFields:[{key:"resourcePackSha1",label:"Resource Pack SHA1",type:"string",helperText:"40-character hex checksum",columns:12},{key:"resourcePackEnforce",label:"Enforce Resource Pack",type:"boolean",helperText:"Kick players who decline"},{key:"resourcePackPrompt",label:"Resource Pack Prompt",type:"string",helperText:"Custom message for resource pack dialog",columns:12},{key:"rconPassword",label:"RCON Password",type:"password",restartRequired:!0},{key:"rconPort",label:"RCON Port",type:"number",validation:{min:1024,max:65535},restartRequired:!0},{key:"stopDuration",label:"Stop Timeout",type:"number",unit:"seconds",helperText:"Graceful shutdown wait time",restartRequired:!0,validation:{min:0}},{key:"uid",label:"User ID (UID)",type:"number",helperText:"Container process UID",restartRequired:!0,validation:{min:0}},{key:"gid",label:"Group ID (GID)",type:"number",helperText:"Container process GID",restartRequired:!0,validation:{min:0}}]}],eH=["memory","initMemory","maxMemory","useAikarFlags","jvmXxOpts","onlineMode","enableWhitelist","enforceWhitelist","enforceSecureProfile","level","seed","levelType","enableAutopause","enableAutostop","enableRcon","rconPassword","rconPort","tz","uid","gid","stopDuration"];function e$({serverName:e,isRunning:t}){let{data:i,isLoading:n}=(0,eg.iC)(e),r=(0,eg.MH)(),s=(0,eg.gx)(),o=(0,eg._I)(),[l,a]=(0,c.useState)({}),[d,u]=(0,c.useState)({}),[m,v]=(0,c.useState)(!1),[k,S]=(0,c.useState)(""),[C,j]=(0,c.useState)(!1),[D,R]=(0,c.useState)({open:!1,message:"",severity:"info"}),P=(0,c.useMemo)(()=>{let e=[];for(let t of Object.keys(l))l[t]!==d[t]&&e.push(t);for(let t of Object.keys(d))l[t]===d[t]||e.includes(t)||e.push(t);return e},[l,d]),L=P.length>0,I=P.filter(e=>eH.includes(e)),E=I.length>0,B=(0,c.useCallback)((e,t)=>{a(i=>({...i,[e]:t}))},[]),N=(0,c.useCallback)(()=>{a(d)},[d]),z=(0,c.useCallback)(async i=>{try{let n=await r.mutateAsync({serverName:e,config:l});if(u(n.config),a(n.config),i&&t)try{await o.mutateAsync(e),R({open:!0,message:"Settings saved. Server is restarting...",severity:"warning"})}catch{R({open:!0,message:"Settings saved, but server restart failed. Please restart manually.",severity:"error"})}else R({open:!0,message:n.restartRequired?"Settings saved. Restart required for some changes to take effect.":"Settings saved successfully.",severity:n.restartRequired?"warning":"success"})}catch(e){R({open:!0,message:e instanceof Error?e.message:"Failed to save settings",severity:"error"})}finally{j(!1)}},[l,e,t,r,o]),W=(0,c.useCallback)(()=>{E&&t?j(!0):z(!1)},[E,t,z]),F=async()=>{if("RESET"!==k){R({open:!0,message:"Please type RESET to confirm",severity:"warning"});return}try{await s.mutateAsync(e),R({open:!0,message:"World reset successfully",severity:"success"}),v(!1),S("")}catch(e){R({open:!0,message:e instanceof Error?e.message:"Failed to reset world",severity:"error"})}};return n?h.jsx(f.Z,{sx:{display:"flex",justifyContent:"center",py:8},children:h.jsx(x.Z,{})}):(0,h.jsxs)(f.Z,{children:[h.jsx(ek,{serverName:e}),eV.map(e=>h.jsx(eP,{section:e,values:l,onChange:B},e.id)),h.jsx(y.Z,{sx:{borderRadius:3,borderColor:"error.main",borderWidth:1,borderStyle:"solid"},children:(0,h.jsxs)(b.Z,{children:[h.jsx(w.Z,{variant:"h6",gutterBottom:!0,fontWeight:600,color:"error",children:"Danger Zone"}),h.jsx(H.Z,{sx:{mb:3}}),(0,h.jsxs)(f.Z,{sx:{mb:3},children:[h.jsx(w.Z,{variant:"subtitle1",fontWeight:600,gutterBottom:!0,children:"Reset World"}),h.jsx(w.Z,{variant:"body2",color:"text.secondary",sx:{mb:2},children:"This will permanently delete the current world and generate a new one. This action cannot be undone."}),h.jsx(p.Z,{variant:"outlined",color:"error",startIcon:h.jsx(em.Z,{}),onClick:()=>v(!0),disabled:t,children:"Reset World"}),t&&h.jsx(w.Z,{variant:"caption",color:"text.secondary",sx:{ml:2},children:"Stop the server first"})]})]})}),h.jsx(eI,{hasChanges:L,changedCount:P.length,hasRestartChanges:E,restartFields:I,isSaving:r.isPending,onSave:W,onDiscard:N}),h.jsx(eE,{open:C,changedFields:I,onSaveOnly:()=>z(!1),onSaveAndRestart:()=>z(!0),onCancel:()=>j(!1)}),(0,h.jsxs)(M.Z,{open:m,onClose:()=>v(!1),maxWidth:"sm",fullWidth:!0,children:[h.jsx(Z.Z,{children:(0,h.jsxs)(f.Z,{sx:{display:"flex",alignItems:"center",gap:1},children:[h.jsx(ef.Z,{color:"error"}),h.jsx(w.Z,{variant:"h6",fontWeight:600,children:"Reset World"})]})}),(0,h.jsxs)(A.Z,{children:[(0,h.jsxs)(w.Z,{variant:"body1",gutterBottom:!0,children:["This will permanently delete the world for ",h.jsx("strong",{children:e})," and generate a new one."]}),h.jsx(w.Z,{variant:"body2",color:"text.secondary",gutterBottom:!0,children:"This action cannot be undone. All player progress and builds will be lost."}),h.jsx(O.Z,{fullWidth:!0,label:"Type RESET to confirm",value:k,onChange:e=>S(e.target.value),sx:{mt:3},autoFocus:!0})]}),(0,h.jsxs)(T.Z,{children:[h.jsx(p.Z,{onClick:()=>v(!1),children:"Cancel"}),h.jsx(p.Z,{variant:"contained",color:"error",onClick:F,disabled:"RESET"!==k||s.isPending,startIcon:s.isPending?h.jsx(x.Z,{size:16}):h.jsx(ep.Z,{}),children:s.isPending?"Resetting...":"Reset World"})]})]}),h.jsx(eu.Z,{open:D.open,autoHideDuration:6e3,onClose:()=>R({...D,open:!1}),anchorOrigin:{vertical:"bottom",horizontal:"right"},children:h.jsx(g.Z,{onClose:()=>R({...D,open:!1}),severity:D.severity,sx:{width:"100%"},children:D.message})})]})}var eq=i(61573),eK=i(45286),eU=i(59615),e_=i(65757),eG=i(9561),eJ=i(79795);let eX={admin:{label:"Owner",color:"primary",variant:"filled"},manage:{label:"Operator",color:"info",variant:"outlined"},view:{label:"Viewer",color:"default",variant:"outlined"}};function eY({permission:e,size:t="medium"}){let i=eX[e];return h.jsx(F.Z,{label:i.label,color:i.color,variant:i.variant,size:t})}var eQ=i(36885),e0=i(4981),e1=i(30330),e2=i(3693),e5=i(93445),e6=i(98925),e4=i(65806);let e3=e=>{let t=c.useRef({});return c.useEffect(()=>{t.current=e}),t.current};var e8=i(49982),e9=i(39119);function e7(e){return void 0!==e.normalize?e.normalize("NFD").replace(/[\u0300-\u036f]/g,""):e}function te(e,t){for(let i=0;i<e.length;i+=1)if(t(e[i]))return i;return -1}let tt=function(e={}){let{ignoreAccents:t=!0,ignoreCase:i=!0,limit:n,matchFrom:r="any",stringify:s,trim:o=!1}=e;return(e,{inputValue:l,getOptionLabel:a})=>{let h=o?l.trim():l;i&&(h=h.toLowerCase()),t&&(h=e7(h));let c=h?e.filter(e=>{let n=(s||a)(e);return i&&(n=n.toLowerCase()),t&&(n=e7(n)),"start"===r?0===n.indexOf(h):n.indexOf(h)>-1}):e;return"number"==typeof n?c.slice(0,n):c}}(),ti=e=>{var t;return null!==e.current&&(null==(t=e.current.parentElement)?void 0:t.contains(document.activeElement))},tn=[],tr=function(e){let{unstable_isActiveElementInListbox:t=ti,unstable_classNamePrefix:i="Mui",autoComplete:n=!1,autoHighlight:r=!1,autoSelect:s=!1,blurOnSelect:o=!1,clearOnBlur:l=!e.freeSolo,clearOnEscape:a=!1,componentName:h="useAutocomplete",defaultValue:d=e.multiple?tn:null,disableClearable:u=!1,disableCloseOnSelect:f=!1,disabled:p,disabledItemsFocusable:m=!1,disableListWrap:g=!1,filterOptions:x=tt,filterSelectedOptions:v=!1,freeSolo:y=!1,getOptionDisabled:b,getOptionKey:w,getOptionLabel:k=e=>{var t;return null!=(t=e.label)?t:e},groupBy:S,handleHomeEndKeys:C=!e.freeSolo,id:j,includeInputInList:M=!1,inputValue:Z,isOptionEqualToValue:A=(e,t)=>e===t,multiple:T=!1,onChange:O,onClose:D,onHighlightChange:R,onInputChange:P,onOpen:L,open:I,openOnFocus:E=!1,options:B,readOnly:N=!1,selectOnFocus:z=!e.freeSolo,value:W}=e,F=(0,e6.Z)(j),V=k;V=e=>{let t=k(e);return"string"!=typeof t?String(t):t};let H=c.useRef(!1),$=c.useRef(!0),q=c.useRef(null),K=c.useRef(null),[U,_]=c.useState(null),[G,J]=c.useState(-1),X=r?0:-1,Y=c.useRef(X),[Q,ee]=(0,e4.Z)({controlled:W,default:d,name:h}),[et,ei]=(0,e4.Z)({controlled:Z,default:"",name:h,state:"inputValue"}),[en,er]=c.useState(!1),es=c.useCallback((e,t)=>{let i;if((T?Q.length<t.length:null!==t)||l){if(T)i="";else if(null==t)i="";else{let e=V(t);i="string"==typeof e?e:""}et!==i&&(ei(i),P&&P(e,i,"reset"))}},[V,et,T,P,ei,l,Q]),[eo,el]=(0,e4.Z)({controlled:I,default:!1,name:h,state:"open"}),[ea,eh]=c.useState(!0),ec=!T&&null!=Q&&et===V(Q),ed=eo&&!N,eu=ed?x(B.filter(e=>!(v&&(T?Q:[Q]).some(t=>null!==t&&A(e,t)))),{inputValue:ec&&ea?"":et,getOptionLabel:V}):[],ef=e3({filteredOptions:eu,value:Q,inputValue:et});c.useEffect(()=>{let e=Q!==ef.value;(!en||e)&&(!y||e)&&es(null,Q)},[Q,es,en,ef.value,y]);let ep=eo&&eu.length>0&&!N,em=(0,e8.Z)(e=>{-1===e?q.current.focus():U.querySelector(`[data-tag-index="${e}"]`).focus()});c.useEffect(()=>{T&&G>Q.length-1&&(J(-1),em(-1))},[Q,T,G,em]);let eg=(0,e8.Z)(({event:e,index:t,reason:n="auto"})=>{if(Y.current=t,-1===t?q.current.removeAttribute("aria-activedescendant"):q.current.setAttribute("aria-activedescendant",`${F}-option-${t}`),R&&R(e,-1===t?null:eu[t],n),!K.current)return;let r=K.current.querySelector(`[role="option"].${i}-focused`);r&&(r.classList.remove(`${i}-focused`),r.classList.remove(`${i}-focusVisible`));let s=K.current;if("listbox"!==K.current.getAttribute("role")&&(s=K.current.parentElement.querySelector('[role="listbox"]')),!s)return;if(-1===t){s.scrollTop=0;return}let o=K.current.querySelector(`[data-option-index="${t}"]`);if(o&&(o.classList.add(`${i}-focused`),"keyboard"===n&&o.classList.add(`${i}-focusVisible`),s.scrollHeight>s.clientHeight&&"mouse"!==n&&"touch"!==n)){let e=s.clientHeight+s.scrollTop,t=o.offsetTop+o.offsetHeight;t>e?s.scrollTop=t-s.clientHeight:o.offsetTop-o.offsetHeight*(S?1.3:0)<s.scrollTop&&(s.scrollTop=o.offsetTop-o.offsetHeight*(S?1.3:0))}}),ex=(0,e8.Z)(({event:e,diff:t,direction:i="next",reason:r="auto"})=>{if(!ed)return;let s=function(e,t){if(!K.current||e<0||e>=eu.length)return -1;let i=e;for(;;){let n=K.current.querySelector(`[data-option-index="${i}"]`),r=!m&&(!n||n.disabled||"true"===n.getAttribute("aria-disabled"));if(n&&n.hasAttribute("tabindex")&&!r)return i;if((i="next"===t?(i+1)%eu.length:(i-1+eu.length)%eu.length)===e)return -1}}((()=>{let e=eu.length-1;if("reset"===t)return X;if("start"===t)return 0;if("end"===t)return e;let i=Y.current+t;return i<0?-1===i&&M?-1:g&&-1!==Y.current||Math.abs(t)>1?0:e:i>e?i===e+1&&M?-1:g||Math.abs(t)>1?e:0:i})(),i);if(eg({index:s,reason:r,event:e}),n&&"reset"!==t){if(-1===s)q.current.value=et;else{let e=V(eu[s]);q.current.value=e,0===e.toLowerCase().indexOf(et.toLowerCase())&&et.length>0&&q.current.setSelectionRange(et.length,e.length)}}}),ev=()=>{var e;if(-1!==Y.current&&ef.filteredOptions&&ef.filteredOptions.length!==eu.length&&ef.inputValue===et&&(T?Q.length===ef.value.length&&ef.value.every((e,t)=>V(Q[t])===V(e)):((e=ef.value)?V(e):"")===(Q?V(Q):""))){let e=ef.filteredOptions[Y.current];if(e)return te(eu,t=>V(t)===V(e))}return -1},ey=c.useCallback(()=>{if(!ed)return;let e=ev();if(-1!==e){Y.current=e;return}let t=T?Q[0]:Q;if(0===eu.length||null==t){ex({diff:"reset"});return}if(K.current){if(null!=t){let e=eu[Y.current];if(T&&e&&-1!==te(Q,t=>A(e,t)))return;let i=te(eu,e=>A(e,t));-1===i?ex({diff:"reset"}):eg({index:i});return}if(Y.current>=eu.length-1){eg({index:eu.length-1});return}eg({index:Y.current})}},[eu.length,!T&&Q,v,ex,eg,ed,et,T]),eb=(0,e8.Z)(e=>{(0,e9.Z)(K,e),e&&ey()});c.useEffect(()=>{ey()},[ey]);let ew=e=>{!eo&&(el(!0),eh(!0),L&&L(e))},ek=(e,t)=>{eo&&(el(!1),D&&D(e,t))},eS=(e,t,i,n)=>{if(T){if(Q.length===t.length&&Q.every((e,i)=>e===t[i]))return}else if(Q===t)return;O&&O(e,t,i,n),ee(t)},eC=c.useRef(!1),ej=(e,t,i="selectOption",n="options")=>{let r=i,s=t;if(T){let e=te(s=Array.isArray(Q)?Q.slice():[],e=>A(t,e));-1===e?s.push(t):"freeSolo"!==n&&(s.splice(e,1),r="removeOption")}es(e,s),eS(e,s,r,{option:t}),f||e&&(e.ctrlKey||e.metaKey)||ek(e,r),(!0===o||"touch"===o&&eC.current||"mouse"===o&&!eC.current)&&q.current.blur()},eM=(e,t)=>{if(!T)return;""===et&&ek(e,"toggleInput");let i=G;-1===G?""===et&&"previous"===t&&(i=Q.length-1):((i+="next"===t?1:-1)<0&&(i=0),i===Q.length&&(i=-1)),J(i=function(e,t){if(-1===e)return -1;let i=e;for(;;){if("next"===t&&i===Q.length||"previous"===t&&-1===i)return -1;let e=U.querySelector(`[data-tag-index="${i}"]`);if(e&&e.hasAttribute("tabindex")&&!e.disabled&&"true"!==e.getAttribute("aria-disabled"))return i;i+="next"===t?1:-1}}(i,t)),em(i)},eZ=e=>{H.current=!0,ei(""),P&&P(e,"","clear"),eS(e,T?[]:null,"clear")},eA=e=>t=>{if(e.onKeyDown&&e.onKeyDown(t),!t.defaultMuiPrevented&&(-1!==G&&-1===["ArrowLeft","ArrowRight"].indexOf(t.key)&&(J(-1),em(-1)),229!==t.which))switch(t.key){case"Home":ed&&C&&(t.preventDefault(),ex({diff:"start",direction:"next",reason:"keyboard",event:t}));break;case"End":ed&&C&&(t.preventDefault(),ex({diff:"end",direction:"previous",reason:"keyboard",event:t}));break;case"PageUp":t.preventDefault(),ex({diff:-5,direction:"previous",reason:"keyboard",event:t}),ew(t);break;case"PageDown":t.preventDefault(),ex({diff:5,direction:"next",reason:"keyboard",event:t}),ew(t);break;case"ArrowDown":t.preventDefault(),ex({diff:1,direction:"next",reason:"keyboard",event:t}),ew(t);break;case"ArrowUp":t.preventDefault(),ex({diff:-1,direction:"previous",reason:"keyboard",event:t}),ew(t);break;case"ArrowLeft":eM(t,"previous");break;case"ArrowRight":eM(t,"next");break;case"Enter":if(-1!==Y.current&&ed){let e=eu[Y.current],i=!!b&&b(e);if(t.preventDefault(),i)return;ej(t,e,"selectOption"),n&&q.current.setSelectionRange(q.current.value.length,q.current.value.length)}else y&&""!==et&&!1===ec&&(T&&t.preventDefault(),ej(t,et,"createOption","freeSolo"));break;case"Escape":ed?(t.preventDefault(),t.stopPropagation(),ek(t,"escape")):a&&(""!==et||T&&Q.length>0)&&(t.preventDefault(),t.stopPropagation(),eZ(t));break;case"Backspace":if(T&&!N&&""===et&&Q.length>0){let e=-1===G?Q.length-1:G,i=Q.slice();i.splice(e,1),eS(t,i,"removeOption",{option:Q[e]})}break;case"Delete":if(T&&!N&&""===et&&Q.length>0&&-1!==G){let e=Q.slice();e.splice(G,1),eS(t,e,"removeOption",{option:Q[G]})}}},eT=e=>{er(!0),E&&!H.current&&ew(e)},eO=e=>{if(t(K)){q.current.focus();return}er(!1),$.current=!0,H.current=!1,s&&-1!==Y.current&&ed?ej(e,eu[Y.current],"blur"):s&&y&&""!==et?ej(e,et,"blur","freeSolo"):l&&es(e,Q),ek(e,"blur")},eD=e=>{let t=e.target.value;et!==t&&(ei(t),eh(!1),P&&P(e,t,"input")),""===t?u||T||eS(e,null,"clear"):ew(e)},eR=e=>{let t=Number(e.currentTarget.getAttribute("data-option-index"));Y.current!==t&&eg({event:e,index:t,reason:"mouse"})},eP=e=>{eg({event:e,index:Number(e.currentTarget.getAttribute("data-option-index")),reason:"touch"}),eC.current=!0},eL=e=>{let t=Number(e.currentTarget.getAttribute("data-option-index"));ej(e,eu[t],"selectOption"),eC.current=!1},eI=e=>t=>{let i=Q.slice();i.splice(e,1),eS(t,i,"removeOption",{option:Q[e]})},eE=e=>{eo?ek(e,"toggleInput"):ew(e)},eB=e=>{e.currentTarget.contains(e.target)&&e.target.getAttribute("id")!==F&&e.preventDefault()},eN=e=>{e.currentTarget.contains(e.target)&&(q.current.focus(),z&&$.current&&q.current.selectionEnd-q.current.selectionStart==0&&q.current.select(),$.current=!1)},ez=e=>{p||""!==et&&eo||eE(e)},eW=y&&et.length>0;eW=eW||(T?Q.length>0:null!==Q);let eF=eu;return S&&(eF=eu.reduce((e,t,i)=>{let n=S(t);return e.length>0&&e[e.length-1].group===n?e[e.length-1].options.push(t):e.push({key:i,index:i,group:n,options:[t]}),e},[])),p&&en&&eO(),{getRootProps:(e={})=>(0,e0.Z)({"aria-owns":ep?`${F}-listbox`:null},e,{onKeyDown:eA(e),onMouseDown:eB,onClick:eN}),getInputLabelProps:()=>({id:`${F}-label`,htmlFor:F}),getInputProps:()=>({id:F,value:et,onBlur:eO,onFocus:eT,onChange:eD,onMouseDown:ez,"aria-activedescendant":ed?"":null,"aria-autocomplete":n?"both":"list","aria-controls":ep?`${F}-listbox`:void 0,"aria-expanded":ep,autoComplete:"off",ref:q,autoCapitalize:"none",spellCheck:"false",role:"combobox",disabled:p}),getClearProps:()=>({tabIndex:-1,type:"button",onClick:eZ}),getPopupIndicatorProps:()=>({tabIndex:-1,type:"button",onClick:eE}),getTagProps:({index:e})=>(0,e0.Z)({key:e,"data-tag-index":e,tabIndex:-1},!N&&{onDelete:eI(e)}),getListboxProps:()=>({role:"listbox",id:`${F}-listbox`,"aria-labelledby":`${F}-label`,ref:eb,onMouseDown:e=>{e.preventDefault()}}),getOptionProps:({index:e,option:t})=>{var i;let n=(T?Q:[Q]).some(e=>null!=e&&A(t,e)),r=!!b&&b(t);return{key:null!=(i=null==w?void 0:w(t))?i:V(t),tabIndex:-1,role:"option",id:`${F}-option-${e}`,onMouseMove:eR,onClick:eL,onTouchStart:eP,"data-option-index":e,"aria-disabled":r,"aria-selected":n}},id:F,inputValue:et,value:Q,dirty:eW,expanded:ed&&U,popupOpen:ed,focused:en||-1!==G,anchorEl:U,setAnchorEl:_,focusedTag:G,groupedOptions:eF}};var ts=i(75109),to=i(62923),tl=i(9103),ta=i(29251),th=i(89206),tc=i(7967);function td(e){return(0,tc.ZP)("MuiListSubheader",e)}(0,th.Z)("MuiListSubheader",["root","colorPrimary","colorInherit","gutters","inset","sticky"]);let tu=["className","color","component","disableGutters","disableSticky","inset"],tf=e=>{let{classes:t,color:i,disableGutters:n,inset:r,disableSticky:s}=e,o={root:["root","default"!==i&&`color${(0,ta.Z)(i)}`,!n&&"gutters",r&&"inset",!s&&"sticky"]};return(0,e2.Z)(o,td,t)},tp=(0,to.ZP)("li",{name:"MuiListSubheader",slot:"Root",overridesResolver:(e,t)=>{let{ownerState:i}=e;return[t.root,"default"!==i.color&&t[`color${(0,ta.Z)(i.color)}`],!i.disableGutters&&t.gutters,i.inset&&t.inset,!i.disableSticky&&t.sticky]}})(({theme:e,ownerState:t})=>(0,e0.Z)({boxSizing:"border-box",lineHeight:"48px",listStyle:"none",color:(e.vars||e).palette.text.secondary,fontFamily:e.typography.fontFamily,fontWeight:e.typography.fontWeightMedium,fontSize:e.typography.pxToRem(14)},"primary"===t.color&&{color:(e.vars||e).palette.primary.main},"inherit"===t.color&&{color:"inherit"},!t.disableGutters&&{paddingLeft:16,paddingRight:16},t.inset&&{paddingLeft:72},!t.disableSticky&&{position:"sticky",top:0,zIndex:1,backgroundColor:(e.vars||e).palette.background.paper})),tm=c.forwardRef(function(e,t){let i=(0,tl.i)({props:e,name:"MuiListSubheader"}),{className:n,color:r="default",component:s="li",disableGutters:o=!1,disableSticky:l=!1,inset:a=!1}=i,c=(0,eQ.Z)(i,tu),d=(0,e0.Z)({},i,{color:r,component:s,disableGutters:o,disableSticky:l,inset:a}),u=tf(d);return(0,h.jsx)(tp,(0,e0.Z)({as:s,className:(0,e1.Z)(u.root,n),ref:t,ownerState:d},c))});tm.muiSkipListHighlight=!0;var tg=i(52329),tx=i(36633),tv=i(41256),ty=i(58631),tb=i(31506),tw=i(59129),tk=i(31776);function tS(e){return(0,tc.ZP)("MuiAutocomplete",e)}let tC=(0,th.Z)("MuiAutocomplete",["root","expanded","fullWidth","focused","focusVisible","tag","tagSizeSmall","tagSizeMedium","hasPopupIcon","hasClearIcon","inputRoot","input","inputFocused","endAdornment","clearIndicator","popupIndicator","popupIndicatorOpen","popper","popperDisablePortal","paper","listbox","loading","noOptions","option","groupLabel","groupUl"]);var tj=i(69473);let tM=["autoComplete","autoHighlight","autoSelect","blurOnSelect","ChipProps","className","clearIcon","clearOnBlur","clearOnEscape","clearText","closeText","componentsProps","defaultValue","disableClearable","disableCloseOnSelect","disabled","disabledItemsFocusable","disableListWrap","disablePortal","filterOptions","filterSelectedOptions","forcePopupIcon","freeSolo","fullWidth","getLimitTagsText","getOptionDisabled","getOptionKey","getOptionLabel","isOptionEqualToValue","groupBy","handleHomeEndKeys","id","includeInputInList","inputValue","limitTags","ListboxComponent","ListboxProps","loading","loadingText","multiple","noOptionsText","onChange","onClose","onHighlightChange","onInputChange","onOpen","open","openOnFocus","openText","options","PaperComponent","PopperComponent","popupIcon","readOnly","renderGroup","renderInput","renderOption","renderTags","selectOnFocus","size","slotProps","value"],tZ=["ref"],tA=["key"],tT=["key"],tO=e=>{let{classes:t,disablePortal:i,expanded:n,focused:r,fullWidth:s,hasClearIcon:o,hasPopupIcon:l,inputFocused:a,popupOpen:h,size:c}=e,d={root:["root",n&&"expanded",r&&"focused",s&&"fullWidth",o&&"hasClearIcon",l&&"hasPopupIcon"],inputRoot:["inputRoot"],input:["input",a&&"inputFocused"],tag:["tag",`tagSize${(0,ta.Z)(c)}`],endAdornment:["endAdornment"],clearIndicator:["clearIndicator"],popupIndicator:["popupIndicator",h&&"popupIndicatorOpen"],popper:["popper",i&&"popperDisablePortal"],paper:["paper"],listbox:["listbox"],loading:["loading"],noOptions:["noOptions"],option:["option"],groupLabel:["groupLabel"],groupUl:["groupUl"]};return(0,e2.Z)(d,tS,t)},tD=(0,to.ZP)("div",{name:"MuiAutocomplete",slot:"Root",overridesResolver:(e,t)=>{let{ownerState:i}=e,{fullWidth:n,hasClearIcon:r,hasPopupIcon:s,inputFocused:o,size:l}=i;return[{[`& .${tC.tag}`]:t.tag},{[`& .${tC.tag}`]:t[`tagSize${(0,ta.Z)(l)}`]},{[`& .${tC.inputRoot}`]:t.inputRoot},{[`& .${tC.input}`]:t.input},{[`& .${tC.input}`]:o&&t.inputFocused},t.root,n&&t.fullWidth,s&&t.hasPopupIcon,r&&t.hasClearIcon]}})({[`&.${tC.focused} .${tC.clearIndicator}`]:{visibility:"visible"},"@media (pointer: fine)":{[`&:hover .${tC.clearIndicator}`]:{visibility:"visible"}},[`& .${tC.tag}`]:{margin:3,maxWidth:"calc(100% - 6px)"},[`& .${tC.inputRoot}`]:{[`.${tC.hasPopupIcon}&, .${tC.hasClearIcon}&`]:{paddingRight:30},[`.${tC.hasPopupIcon}.${tC.hasClearIcon}&`]:{paddingRight:56},[`& .${tC.input}`]:{width:0,minWidth:30}},[`& .${tx.Z.root}`]:{paddingBottom:1,"& .MuiInput-input":{padding:"4px 4px 4px 0px"}},[`& .${tx.Z.root}.${tv.Z.sizeSmall}`]:{[`& .${tx.Z.input}`]:{padding:"2px 4px 3px 0"}},[`& .${ty.Z.root}`]:{padding:9,[`.${tC.hasPopupIcon}&, .${tC.hasClearIcon}&`]:{paddingRight:39},[`.${tC.hasPopupIcon}.${tC.hasClearIcon}&`]:{paddingRight:65},[`& .${tC.input}`]:{padding:"7.5px 4px 7.5px 5px"},[`& .${tC.endAdornment}`]:{right:9}},[`& .${ty.Z.root}.${tv.Z.sizeSmall}`]:{paddingTop:6,paddingBottom:6,paddingLeft:6,[`& .${tC.input}`]:{padding:"2.5px 4px 2.5px 8px"}},[`& .${tb.Z.root}`]:{paddingTop:19,paddingLeft:8,[`.${tC.hasPopupIcon}&, .${tC.hasClearIcon}&`]:{paddingRight:39},[`.${tC.hasPopupIcon}.${tC.hasClearIcon}&`]:{paddingRight:65},[`& .${tb.Z.input}`]:{padding:"7px 4px"},[`& .${tC.endAdornment}`]:{right:9}},[`& .${tb.Z.root}.${tv.Z.sizeSmall}`]:{paddingBottom:1,[`& .${tb.Z.input}`]:{padding:"2.5px 4px"}},[`& .${tv.Z.hiddenLabel}`]:{paddingTop:8},[`& .${tb.Z.root}.${tv.Z.hiddenLabel}`]:{paddingTop:0,paddingBottom:0,[`& .${tC.input}`]:{paddingTop:16,paddingBottom:17}},[`& .${tb.Z.root}.${tv.Z.hiddenLabel}.${tv.Z.sizeSmall}`]:{[`& .${tC.input}`]:{paddingTop:8,paddingBottom:9}},[`& .${tC.input}`]:{flexGrow:1,textOverflow:"ellipsis",opacity:0},variants:[{props:{fullWidth:!0},style:{width:"100%"}},{props:{size:"small"},style:{[`& .${tC.tag}`]:{margin:2,maxWidth:"calc(100% - 4px)"}}},{props:{inputFocused:!0},style:{[`& .${tC.input}`]:{opacity:1}}},{props:{multiple:!0},style:{[`& .${tC.inputRoot}`]:{flexWrap:"wrap"}}}]}),tR=(0,to.ZP)("div",{name:"MuiAutocomplete",slot:"EndAdornment",overridesResolver:(e,t)=>t.endAdornment})({position:"absolute",right:0,top:"50%",transform:"translate(0, -50%)"}),tP=(0,to.ZP)(m.Z,{name:"MuiAutocomplete",slot:"ClearIndicator",overridesResolver:(e,t)=>t.clearIndicator})({marginRight:-2,padding:4,visibility:"hidden"}),tL=(0,to.ZP)(m.Z,{name:"MuiAutocomplete",slot:"PopupIndicator",overridesResolver:({ownerState:e},t)=>(0,e0.Z)({},t.popupIndicator,e.popupOpen&&t.popupIndicatorOpen)})({padding:2,marginRight:-2,variants:[{props:{popupOpen:!0},style:{transform:"rotate(180deg)"}}]}),tI=(0,to.ZP)(ts.Z,{name:"MuiAutocomplete",slot:"Popper",overridesResolver:(e,t)=>{let{ownerState:i}=e;return[{[`& .${tC.option}`]:t.option},t.popper,i.disablePortal&&t.popperDisablePortal]}})(({theme:e})=>({zIndex:(e.vars||e).zIndex.modal,variants:[{props:{disablePortal:!0},style:{position:"absolute"}}]})),tE=(0,to.ZP)(tg.Z,{name:"MuiAutocomplete",slot:"Paper",overridesResolver:(e,t)=>t.paper})(({theme:e})=>(0,e0.Z)({},e.typography.body1,{overflow:"auto"})),tB=(0,to.ZP)("div",{name:"MuiAutocomplete",slot:"Loading",overridesResolver:(e,t)=>t.loading})(({theme:e})=>({color:(e.vars||e).palette.text.secondary,padding:"14px 16px"})),tN=(0,to.ZP)("div",{name:"MuiAutocomplete",slot:"NoOptions",overridesResolver:(e,t)=>t.noOptions})(({theme:e})=>({color:(e.vars||e).palette.text.secondary,padding:"14px 16px"})),tz=(0,to.ZP)("div",{name:"MuiAutocomplete",slot:"Listbox",overridesResolver:(e,t)=>t.listbox})(({theme:e})=>({listStyle:"none",margin:0,padding:"8px 0",maxHeight:"40vh",overflow:"auto",position:"relative",[`& .${tC.option}`]:{minHeight:48,display:"flex",overflow:"hidden",justifyContent:"flex-start",alignItems:"center",cursor:"pointer",paddingTop:6,boxSizing:"border-box",outline:"0",WebkitTapHighlightColor:"transparent",paddingBottom:6,paddingLeft:16,paddingRight:16,[e.breakpoints.up("sm")]:{minHeight:"auto"},[`&.${tC.focused}`]:{backgroundColor:(e.vars||e).palette.action.hover,"@media (hover: none)":{backgroundColor:"transparent"}},'&[aria-disabled="true"]':{opacity:(e.vars||e).palette.action.disabledOpacity,pointerEvents:"none"},[`&.${tC.focusVisible}`]:{backgroundColor:(e.vars||e).palette.action.focus},'&[aria-selected="true"]':{backgroundColor:e.vars?`rgba(${e.vars.palette.primary.mainChannel} / ${e.vars.palette.action.selectedOpacity})`:(0,e5.Fq)(e.palette.primary.main,e.palette.action.selectedOpacity),[`&.${tC.focused}`]:{backgroundColor:e.vars?`rgba(${e.vars.palette.primary.mainChannel} / calc(${e.vars.palette.action.selectedOpacity} + ${e.vars.palette.action.hoverOpacity}))`:(0,e5.Fq)(e.palette.primary.main,e.palette.action.selectedOpacity+e.palette.action.hoverOpacity),"@media (hover: none)":{backgroundColor:(e.vars||e).palette.action.selected}},[`&.${tC.focusVisible}`]:{backgroundColor:e.vars?`rgba(${e.vars.palette.primary.mainChannel} / calc(${e.vars.palette.action.selectedOpacity} + ${e.vars.palette.action.focusOpacity}))`:(0,e5.Fq)(e.palette.primary.main,e.palette.action.selectedOpacity+e.palette.action.focusOpacity)}}}})),tW=(0,to.ZP)(tm,{name:"MuiAutocomplete",slot:"GroupLabel",overridesResolver:(e,t)=>t.groupLabel})(({theme:e})=>({backgroundColor:(e.vars||e).palette.background.paper,top:-8})),tF=(0,to.ZP)("ul",{name:"MuiAutocomplete",slot:"GroupUl",overridesResolver:(e,t)=>t.groupUl})({padding:0,[`& .${tC.option}`]:{paddingLeft:24}}),tV=c.forwardRef(function(e,t){var i,n,r,l;let a;let d=(0,tl.i)({props:e,name:"MuiAutocomplete"}),{autoComplete:u=!1,autoHighlight:f=!1,autoSelect:p=!1,blurOnSelect:m=!1,ChipProps:g,className:x,clearIcon:v=s||(s=(0,h.jsx)(tw.Z,{fontSize:"small"})),clearOnBlur:y=!d.freeSolo,clearOnEscape:b=!1,clearText:w="Clear",closeText:k="Close",componentsProps:S={},defaultValue:C=d.multiple?[]:null,disableClearable:j=!1,disableCloseOnSelect:M=!1,disabled:Z=!1,disabledItemsFocusable:A=!1,disableListWrap:T=!1,disablePortal:O=!1,filterSelectedOptions:D=!1,forcePopupIcon:R="auto",freeSolo:P=!1,fullWidth:L=!1,getLimitTagsText:I=e=>`+${e}`,getOptionLabel:E,groupBy:B,handleHomeEndKeys:N=!d.freeSolo,includeInputInList:z=!1,limitTags:W=-1,ListboxComponent:V="ul",ListboxProps:H,loading:$=!1,loadingText:q="Loading…",multiple:K=!1,noOptionsText:U="No options",openOnFocus:_=!1,openText:G="Open",PaperComponent:J=tg.Z,PopperComponent:X=ts.Z,popupIcon:Y=o||(o=(0,h.jsx)(tk.Z,{})),readOnly:Q=!1,renderGroup:ee,renderInput:et,renderOption:ei,renderTags:en,selectOnFocus:er=!d.freeSolo,size:es="medium",slotProps:eo={}}=d,el=(0,eQ.Z)(d,tM),{getRootProps:ea,getInputProps:eh,getInputLabelProps:ec,getPopupIndicatorProps:ed,getClearProps:eu,getTagProps:ef,getListboxProps:ep,getOptionProps:em,value:eg,dirty:ex,expanded:ev,id:ey,popupOpen:eb,focused:ew,focusedTag:ek,anchorEl:eS,setAnchorEl:eC,inputValue:ej,groupedOptions:eM}=tr((0,e0.Z)({},d,{componentName:"Autocomplete"})),eZ=!j&&!Z&&ex&&!Q,eA=(!P||!0===R)&&!1!==R,{onMouseDown:eT}=eh(),{ref:eO}=null!=H?H:{},eD=ep(),{ref:eR}=eD,eP=(0,eQ.Z)(eD,tZ),eL=(0,tj.Z)(eR,eO),eI=E||(e=>{var t;return null!=(t=e.label)?t:e}),eE=(0,e0.Z)({},d,{disablePortal:O,expanded:ev,focused:ew,fullWidth:L,getOptionLabel:eI,hasClearIcon:eZ,hasPopupIcon:eA,inputFocused:-1===ek,popupOpen:eb,size:es}),eB=tO(eE);if(K&&eg.length>0){let e=e=>(0,e0.Z)({className:eB.tag,disabled:Z},ef(e));a=en?en(eg,e,eE):eg.map((t,i)=>{let n=e({index:i}),{key:r}=n,s=(0,eQ.Z)(n,tA);return(0,h.jsx)(F.Z,(0,e0.Z)({label:eI(t),size:es},s,g),r)})}if(W>-1&&Array.isArray(a)){let e=a.length-W;!ew&&e>0&&(a=a.splice(0,W)).push((0,h.jsx)("span",{className:eB.tag,children:I(e)},a.length))}let eN=ee||(e=>(0,h.jsxs)("li",{children:[(0,h.jsx)(tW,{className:eB.groupLabel,ownerState:eE,component:"div",children:e.group}),(0,h.jsx)(tF,{className:eB.groupUl,ownerState:eE,children:e.children})]},e.key)),ez=ei||((e,t)=>{let{key:i}=e,n=(0,eQ.Z)(e,tT);return(0,h.jsx)("li",(0,e0.Z)({},n,{children:eI(t)}),i)}),eW=(e,t)=>{let i=em({option:e,index:t});return ez((0,e0.Z)({},i,{className:eB.option}),e,{selected:i["aria-selected"],index:t,inputValue:ej},eE)},eF=null!=(i=eo.clearIndicator)?i:S.clearIndicator,eV=null!=(n=eo.paper)?n:S.paper,eH=null!=(r=eo.popper)?r:S.popper,e$=null!=(l=eo.popupIndicator)?l:S.popupIndicator;return(0,h.jsxs)(c.Fragment,{children:[(0,h.jsx)(tD,(0,e0.Z)({ref:t,className:(0,e1.Z)(eB.root,x),ownerState:eE},ea(el),{children:et({id:ey,disabled:Z,fullWidth:!0,size:"small"===es?"small":void 0,InputLabelProps:ec(),InputProps:(0,e0.Z)({ref:eC,className:eB.inputRoot,startAdornment:a,onClick:e=>{e.target===e.currentTarget&&eT(e)}},(eZ||eA)&&{endAdornment:(0,h.jsxs)(tR,{className:eB.endAdornment,ownerState:eE,children:[eZ?(0,h.jsx)(tP,(0,e0.Z)({},eu(),{"aria-label":w,title:w,ownerState:eE},eF,{className:(0,e1.Z)(eB.clearIndicator,null==eF?void 0:eF.className),children:v})):null,eA?(0,h.jsx)(tL,(0,e0.Z)({},ed(),{disabled:Z,"aria-label":eb?k:G,title:eb?k:G,ownerState:eE},e$,{className:(0,e1.Z)(eB.popupIndicator,null==e$?void 0:e$.className),children:Y})):null]})}),inputProps:(0,e0.Z)({className:eB.input,disabled:Z,readOnly:Q},eh())})})),eS?(0,h.jsx)(tI,(0,e0.Z)({as:X,disablePortal:O,style:{width:eS?eS.clientWidth:null},ownerState:eE,role:"presentation",anchorEl:eS,open:eb},eH,{className:(0,e1.Z)(eB.popper,null==eH?void 0:eH.className),children:(0,h.jsxs)(tE,(0,e0.Z)({ownerState:eE,as:J},eV,{className:(0,e1.Z)(eB.paper,null==eV?void 0:eV.className),children:[$&&0===eM.length?(0,h.jsx)(tB,{className:eB.loading,ownerState:eE,children:q}):null,0!==eM.length||P||$?null:(0,h.jsx)(tN,{className:eB.noOptions,ownerState:eE,role:"presentation",onMouseDown:e=>{e.preventDefault()},children:U}),eM.length>0?(0,h.jsx)(tz,(0,e0.Z)({as:V,className:eB.listbox,ownerState:eE},eP,H,{ref:eL,children:eM.map((e,t)=>B?eN({key:e.key,group:e.group,children:e.options.map((t,i)=>eW(t,e.index+i))}):eW(e,t))})):null]}))})):null]})});var tH=i(99943),t$=i(92241),tq=i(61974),tK=i(28872),tU=i(95343),t_=i(20042),tG=i(43137);function tJ({open:e,onClose:t,serverId:i}){var n;let[r,s]=(0,c.useState)(""),[o,l]=(0,c.useState)(null),[a,d]=(0,c.useState)("view"),{data:u,isLoading:m}=(n={enabled:e},(0,tK.a)({queryKey:["users","search",r],queryFn:()=>(0,tG.SC)(`/api/users?q=${encodeURIComponent(r)}`),enabled:n?.enabled!==!1&&r.length>=2,staleTime:3e4})),v=function(){let e=(0,tU.NL)();return(0,t_.D)({mutationFn:e=>(0,tG.SC)("/api/user-servers",{method:"POST",body:JSON.stringify(e)}),onSuccess:(t,i)=>{e.invalidateQueries({queryKey:["user-servers",i.serverId]}),e.invalidateQueries({queryKey:["user-servers"]})}})}(),y=(0,c.useMemo)(()=>u?.users??[],[u]),b=()=>{s(""),l(null),d("view"),v.reset(),t()};return(0,h.jsxs)(M.Z,{open:e,onClose:b,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderRadius:3}},children:[h.jsx(Z.Z,{sx:{fontWeight:600},children:"Add User Access"}),(0,h.jsxs)(A.Z,{sx:{display:"flex",flexDirection:"column",gap:3,pt:"8px !important"},children:[v.isError&&h.jsx(g.Z,{severity:"error",sx:{mb:1},children:v.error?.message||"Failed to grant access"}),h.jsx(tV,{options:y,getOptionLabel:e=>e.name||e.email,isOptionEqualToValue:(e,t)=>e.id===t.id,value:o,onChange:(e,t)=>l(t),inputValue:r,onInputChange:(e,t)=>s(t),loading:m,filterOptions:e=>e,noOptionsText:r.length<2?"Type at least 2 characters":"No users found",renderInput:e=>h.jsx(O.Z,{...e,label:"Search User",placeholder:"Search by name or email...",InputProps:{...e.InputProps,endAdornment:(0,h.jsxs)(h.Fragment,{children:[m&&h.jsx(x.Z,{size:20}),e.InputProps.endAdornment]})}}),renderOption:(e,t)=>{let{key:i,...n}=e;return(0,h.jsxs)(f.Z,{component:"li",...n,sx:{display:"flex",gap:1.5,py:1},children:[h.jsx(eq.Z,{src:t.image??void 0,sx:{width:32,height:32,bgcolor:"primary.main",fontSize:14},children:(t.name?.[0]||t.email?.[0]||"?").toUpperCase()}),(0,h.jsxs)(f.Z,{children:[h.jsx(w.Z,{variant:"body2",fontWeight:500,children:t.name||"Unknown"}),h.jsx(w.Z,{variant:"caption",color:"text.secondary",children:t.email})]})]},i)}}),(0,h.jsxs)(eM.Z,{children:[h.jsx(tH.Z,{sx:{fontWeight:500,mb:1},children:"Permission Level"}),(0,h.jsxs)(t$.Z,{value:a,onChange:e=>d(e.target.value),children:[h.jsx(eA.Z,{value:"view",control:h.jsx(tq.Z,{size:"small"}),label:(0,h.jsxs)(f.Z,{children:[h.jsx(w.Z,{variant:"body2",fontWeight:500,children:"Viewer"}),h.jsx(w.Z,{variant:"caption",color:"text.secondary",children:"Can view server status and logs"})]})}),h.jsx(eA.Z,{value:"manage",control:h.jsx(tq.Z,{size:"small"}),label:(0,h.jsxs)(f.Z,{children:[h.jsx(w.Z,{variant:"body2",fontWeight:500,children:"Operator"}),h.jsx(w.Z,{variant:"caption",color:"text.secondary",children:"Can start, stop, and configure the server"})]})}),h.jsx(eA.Z,{value:"admin",control:h.jsx(tq.Z,{size:"small"}),label:(0,h.jsxs)(f.Z,{children:[h.jsx(w.Z,{variant:"body2",fontWeight:500,children:"Owner"}),h.jsx(w.Z,{variant:"caption",color:"text.secondary",children:"Full control including managing other users"})]})})]})]})]}),(0,h.jsxs)(T.Z,{sx:{px:3,pb:2},children:[h.jsx(p.Z,{onClick:b,color:"inherit",children:"Cancel"}),h.jsx(p.Z,{onClick:()=>{o&&v.mutate({userId:o.id,serverId:i,permission:a},{onSuccess:b})},variant:"contained",disabled:!o||v.isPending,sx:{borderRadius:2},children:v.isPending?"Adding...":"Add User"})]})]})}function tX({serverId:e}){let{data:t,isLoading:i,error:n}=(0,tK.a)({queryKey:["user-servers",e],queryFn:()=>(0,tG.SC)(`/api/user-servers?serverId=${encodeURIComponent(e)}`),enabled:!!e}),r=function(){let e=(0,tU.NL)();return(0,t_.D)({mutationFn:({id:e,permission:t})=>(0,tG.SC)(`/api/user-servers/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify({permission:t})}),onSuccess:()=>{e.invalidateQueries({queryKey:["user-servers"]})}})}(),s=function(){let e=(0,tU.NL)();return(0,t_.D)({mutationFn:e=>(0,tG.SC)(`/api/user-servers/${encodeURIComponent(e)}`,{method:"DELETE"}),onSuccess:()=>{e.invalidateQueries({queryKey:["user-servers"]})}})}(),[o,l]=(0,c.useState)(!1),[a,d]=(0,c.useState)(null),[u,x]=(0,c.useState)(null),M=(e,t)=>{d(e.currentTarget),x(t)},Z=()=>{d(null),x(null)},A=e=>{if(!u||u.permission===e){Z();return}r.mutate({id:u.id,permission:e},{onSettled:Z})},T=t?.users.filter(e=>"admin"===e.permission).length??0,O=u?.permission==="admin"&&T<=1;if(i)return h.jsx(y.Z,{sx:{borderRadius:3},children:(0,h.jsxs)(b.Z,{children:[(0,h.jsxs)(f.Z,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:2},children:[h.jsx(v.Z,{variant:"text",width:"30%",height:32}),h.jsx(v.Z,{variant:"rounded",width:120,height:36,sx:{borderRadius:2}})]}),h.jsx(H.Z,{sx:{mb:2}}),[0,1,2].map(e=>(0,h.jsxs)(f.Z,{sx:{display:"flex",alignItems:"center",gap:2,py:1.5,borderBottom:"1px solid",borderColor:"divider"},children:[h.jsx(v.Z,{variant:"circular",width:40,height:40}),(0,h.jsxs)(f.Z,{sx:{flex:1},children:[h.jsx(v.Z,{variant:"text",width:"40%"}),h.jsx(v.Z,{variant:"text",width:"60%"})]}),h.jsx(v.Z,{variant:"rounded",width:80,height:28,sx:{borderRadius:10}}),h.jsx(v.Z,{variant:"circular",width:32,height:32})]},e))]})});if(n)return(0,h.jsxs)(g.Z,{severity:"error",children:["Failed to load access list: ",n.message]});let D=t?.users??[];return(0,h.jsxs)(h.Fragment,{children:[h.jsx(y.Z,{sx:{borderRadius:3},children:(0,h.jsxs)(b.Z,{children:[(0,h.jsxs)(f.Z,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:2},children:[h.jsx(w.Z,{variant:"h6",fontWeight:600,children:"Server Access"}),h.jsx(p.Z,{variant:"contained",size:"small",startIcon:h.jsx(eK.Z,{}),onClick:()=>l(!0),sx:{borderRadius:2},children:"Add User"})]}),h.jsx(H.Z,{sx:{mb:1}}),0===D.length?h.jsx(f.Z,{sx:{py:4,textAlign:"center"},children:h.jsx(w.Z,{variant:"body2",color:"text.secondary",children:"No users have been granted access to this server yet."})}):D.map(e=>(0,h.jsxs)(f.Z,{sx:{display:"flex",alignItems:"center",gap:2,py:1.5,"&:not(:last-child)":{borderBottom:"1px solid",borderColor:"divider"}},children:[h.jsx(eq.Z,{src:e.user?.image??void 0,sx:{width:40,height:40,bgcolor:"primary.main",fontSize:16},children:(e.user?.name?.[0]||e.user?.email?.[0]||"?").toUpperCase()}),(0,h.jsxs)(f.Z,{sx:{flex:1,minWidth:0},children:[h.jsx(w.Z,{variant:"body2",fontWeight:500,noWrap:!0,children:e.user?.name||"Unknown User"}),h.jsx(w.Z,{variant:"caption",color:"text.secondary",noWrap:!0,children:e.user?.email||e.userId})]}),h.jsx(eY,{permission:e.permission,size:"small"}),h.jsx(m.Z,{size:"small",onClick:t=>M(t,e),sx:{color:"text.secondary"},children:h.jsx(I.Z,{fontSize:"small"})})]},e.id)),(0,h.jsxs)(f.Z,{sx:{display:"flex",alignItems:"center",gap:1,mt:2,pt:1},children:[h.jsx(eJ.Z,{sx:{fontSize:16,color:"text.disabled"}}),h.jsx(w.Z,{variant:"caption",color:"text.disabled",children:"Only platform admins and server owners can manage access."})]})]})}),(0,h.jsxs)(k.Z,{anchorEl:a,open:!!a,onClose:Z,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},disableScrollLock:!0,children:[(0,h.jsxs)(S.Z,{onClick:()=>A("admin"),disabled:u?.permission==="admin",children:[h.jsx(C.Z,{children:h.jsx(eU.Z,{fontSize:"small"})}),h.jsx(j.Z,{children:"Change to Owner"})]}),(0,h.jsxs)(S.Z,{onClick:()=>A("manage"),disabled:u?.permission==="manage"||O,children:[h.jsx(C.Z,{children:h.jsx(e_.Z,{fontSize:"small"})}),h.jsx(j.Z,{children:"Change to Operator"})]}),(0,h.jsxs)(S.Z,{onClick:()=>A("view"),disabled:u?.permission==="view"||O,children:[h.jsx(C.Z,{children:h.jsx(eO.Z,{fontSize:"small"})}),h.jsx(j.Z,{children:"Change to Viewer"})]}),h.jsx(H.Z,{}),(0,h.jsxs)(S.Z,{onClick:()=>{u&&s.mutate(u.id,{onSettled:Z})},disabled:O,sx:{color:"error.main"},children:[h.jsx(C.Z,{children:h.jsx(eG.Z,{fontSize:"small",sx:{color:"error.main"}})}),h.jsx(j.Z,{children:"Remove Access"})]})]}),h.jsx(tJ,{open:o,onClose:()=>l(!1),serverId:e})]})}var tY=i(15934),tQ=i(73802);function t0({label:e,value:t,copyText:i}){return(0,h.jsxs)(f.Z,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",py:1},children:[h.jsx(w.Z,{variant:"body2",color:"text.secondary",children:e}),(0,h.jsxs)(f.Z,{sx:{display:"flex",alignItems:"center"},children:[h.jsx(w.Z,{variant:"body2",sx:{color:i?"text.primary":"text.secondary",wordBreak:"break-all"},children:t}),i&&h.jsx(tQ.q,{text:i,size:16})]})]})}function t1({serverName:e,hostname:t}){let{data:i,isLoading:n}=(0,tY.UW)();if(n)return h.jsx(y.Z,{sx:{borderRadius:3},children:(0,h.jsxs)(b.Z,{children:[h.jsx(v.Z,{variant:"text",width:"40%",height:28,sx:{mb:1}}),h.jsx(v.Z,{variant:"rectangular",height:1,sx:{mb:2}}),(0,h.jsxs)(f.Z,{sx:{display:"flex",justifyContent:"space-between",py:1},children:[h.jsx(v.Z,{variant:"text",width:"30%"}),h.jsx(v.Z,{variant:"text",width:"40%"})]}),(0,h.jsxs)(f.Z,{sx:{display:"flex",justifyContent:"space-between",py:1},children:[h.jsx(v.Z,{variant:"text",width:"30%"}),h.jsx(v.Z,{variant:"text",width:"40%"})]})]})});let r=i?.enabled&&i.servers.length>0,s=i?.servers.find(t=>t.serverName===e),o=s?.playitDomain||"Not configured",l=!!s?.playitDomain;return h.jsx(y.Z,{sx:{borderRadius:3},children:(0,h.jsxs)(b.Z,{children:[h.jsx(w.Z,{variant:"h6",gutterBottom:!0,fontWeight:600,children:"Connection"}),h.jsx(H.Z,{sx:{mb:2}}),(0,h.jsxs)(f.Z,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",py:1,gap:1},children:[h.jsx(w.Z,{variant:"body2",color:"text.secondary",sx:{flexShrink:0},children:"LAN Address"}),t?h.jsx(f.Z,{sx:{minWidth:0},children:h.jsx(tQ.h,{hostname:t,portSuffix:25565,color:"text.primary",showCopyButton:!0})}):h.jsx(w.Z,{variant:"body2",color:"text.secondary",children:"Not configured"})]}),r&&h.jsx(t0,{label:"External Address",value:o,copyText:l?o:void 0})]})})}var t2=i(96468),t5=i(50582),t6=i(86202);function t4({serverName:e}){let{data:t,isLoading:i,error:n}=(0,tK.a)({queryKey:["servers",e,"mods"],queryFn:()=>(0,tG.SC)(`/api/servers/${encodeURIComponent(e)}/mods`),enabled:!!e}),r=function(){let e=(0,tU.NL)();return(0,t_.D)({mutationFn:({serverName:e,slugs:t,source:i})=>(0,tG.SC)(`/api/servers/${encodeURIComponent(e)}/mods`,{method:"POST",body:JSON.stringify({slugs:t,source:i})}),onSuccess:(t,{serverName:i})=>{e.invalidateQueries({queryKey:["servers",i,"mods"]})}})}(),s=function(){let e=(0,tU.NL)();return(0,t_.D)({mutationFn:({serverName:e,slug:t})=>(0,tG.SC)(`/api/servers/${encodeURIComponent(e)}/mods/${encodeURIComponent(t)}`,{method:"DELETE"}),onSuccess:(t,{serverName:i})=>{e.invalidateQueries({queryKey:["servers",i,"mods"]})}})}(),[o,l]=(0,c.useState)(!1),[a,d]=(0,c.useState)(""),[u,v]=(0,c.useState)(""),[k,S]=(0,c.useState)(!1),[C,j]=(0,c.useState)({open:!1,message:"",severity:"info"}),{data:T,isLoading:D}=function(e,t){let i=new URLSearchParams;return e&&i.set("q",e),t?.limit!=null&&i.set("limit",String(t.limit)),t?.offset!=null&&i.set("offset",String(t.offset)),(0,tK.a)({queryKey:["mods","search",e,t?.limit,t?.offset],queryFn:()=>(0,tG.SC)(`/api/mods/search?${i}`),enabled:t?.enabled!==!1&&!!e.trim()})}(u,{limit:10,enabled:o&&u.length>0}),R=(0,c.useCallback)(async t=>{try{await s.mutateAsync({serverName:e,slug:t}),S(!0),j({open:!0,message:`Removed ${t}`,severity:"success"})}catch(e){j({open:!0,message:e instanceof Error?e.message:"Failed to remove mod",severity:"error"})}},[s,e]),P=(0,c.useCallback)(async t=>{try{await r.mutateAsync({serverName:e,slugs:[t]}),S(!0),j({open:!0,message:`Added ${t}`,severity:"success"})}catch(e){j({open:!0,message:e instanceof Error?e.message:"Failed to add mod",severity:"error"})}},[r,e]),L=new Set;if(t?.mods)for(let e of Object.values(t.mods))for(let t of e)L.add(t);if(i)return h.jsx(f.Z,{sx:{display:"flex",justifyContent:"center",py:6},children:h.jsx(x.Z,{})});if(n)return(0,h.jsxs)(g.Z,{severity:"error",sx:{mt:2},children:["Failed to load mods: ",n.message]});let I=L.size>0;return(0,h.jsxs)(f.Z,{children:[k&&h.jsx(g.Z,{severity:"info",sx:{mb:2},children:"Restart the server to apply mod changes."}),h.jsx(y.Z,{sx:{borderRadius:3},children:(0,h.jsxs)(b.Z,{children:[(0,h.jsxs)(f.Z,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:2},children:[h.jsx(w.Z,{variant:"h6",fontWeight:600,children:"Installed Mods"}),h.jsx(p.Z,{variant:"contained",size:"small",startIcon:h.jsx(ey.Z,{}),onClick:()=>{d(""),v(""),l(!0)},children:"Add Mods"})]}),h.jsx(H.Z,{sx:{mb:2}}),I?Object.entries(t.mods).map(([e,t])=>(0,h.jsxs)(f.Z,{sx:{mb:2},children:[h.jsx(w.Z,{variant:"subtitle2",color:"text.secondary",sx:{mb:1,textTransform:"capitalize"},children:e}),h.jsx(f.Z,{sx:{display:"flex",flexWrap:"wrap",gap:1},children:t.map(e=>h.jsx(F.Z,{label:e,icon:h.jsx(t5.Z,{}),onDelete:()=>R(e),deleteIcon:h.jsx(E.Z,{}),variant:"outlined"},e))})]},e)):(0,h.jsxs)(f.Z,{sx:{textAlign:"center",py:4},children:[h.jsx(t5.Z,{sx:{fontSize:48,color:"text.disabled",mb:1}}),h.jsx(w.Z,{variant:"body1",color:"text.secondary",children:"No mods installed"}),h.jsx(w.Z,{variant:"body2",color:"text.disabled",sx:{mt:.5},children:'Click "Add Mods" to search and install mods from Modrinth'})]})]})}),(0,h.jsxs)(M.Z,{open:o,onClose:()=>l(!1),maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{minHeight:400}},children:[(0,h.jsxs)(Z.Z,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:["Search Mods",h.jsx(m.Z,{onClick:()=>l(!1),size:"small",children:h.jsx(K.Z,{})})]}),(0,h.jsxs)(A.Z,{children:[h.jsx(O.Z,{fullWidth:!0,autoFocus:!0,placeholder:"Search Modrinth...",value:a,onChange:e=>d(e.target.value),InputProps:{startAdornment:h.jsx(V.Z,{position:"start",children:h.jsx(t2.Z,{})})},sx:{mb:2}}),D&&h.jsx(f.Z,{sx:{display:"flex",justifyContent:"center",py:4},children:h.jsx(x.Z,{size:28})}),!D&&T&&0===T.hits.length&&u&&(0,h.jsxs)(w.Z,{variant:"body2",color:"text.secondary",sx:{textAlign:"center",py:4},children:['No mods found for "',u,'"']}),!D&&T&&T.hits.length>0&&h.jsx(f.Z,{sx:{display:"flex",flexDirection:"column",gap:1.5},children:T.hits.map(e=>{var t;let i=L.has(e.slug);return h.jsx(y.Z,{variant:"outlined",sx:{borderRadius:2},children:h.jsx(b.Z,{sx:{py:1.5,px:2,"&:last-child":{pb:1.5}},children:(0,h.jsxs)(f.Z,{sx:{display:"flex",gap:1.5,alignItems:"flex-start"},children:[h.jsx(eq.Z,{src:e.iconUrl||void 0,variant:"rounded",sx:{width:40,height:40,bgcolor:"action.hover"},children:h.jsx(t5.Z,{})}),(0,h.jsxs)(f.Z,{sx:{flex:1,minWidth:0},children:[(0,h.jsxs)(f.Z,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[h.jsx(w.Z,{variant:"subtitle2",noWrap:!0,children:e.title}),h.jsx(p.Z,{size:"small",variant:i?"outlined":"contained",disabled:i||r.isPending,onClick:()=>P(e.slug),sx:{ml:1,minWidth:80,flexShrink:0},children:i?"Installed":"Add"})]}),h.jsx(w.Z,{variant:"body2",color:"text.secondary",sx:{mt:.25,overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical"},children:e.description}),(0,h.jsxs)(f.Z,{sx:{display:"flex",alignItems:"center",gap:1,mt:.5},children:[(0,h.jsxs)(f.Z,{sx:{display:"flex",alignItems:"center",gap:.25},children:[h.jsx(t6.Z,{sx:{fontSize:14,color:"text.disabled"}}),h.jsx(w.Z,{variant:"caption",color:"text.disabled",children:(t=e.downloads)>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:String(t)})]}),e.author&&(0,h.jsxs)(w.Z,{variant:"caption",color:"text.disabled",children:["by ",e.author]})]})]})]})})},e.slug)})})]})]}),h.jsx(eu.Z,{open:C.open,autoHideDuration:4e3,onClose:()=>j(e=>({...e,open:!1})),anchorOrigin:{vertical:"bottom",horizontal:"center"},children:h.jsx(g.Z,{onClose:()=>j(e=>({...e,open:!1})),severity:C.severity,variant:"filled",children:C.message})})]})}function t3(e,t){return(0,tK.a)({queryKey:["servers",e,"files","content",t],queryFn:()=>{let i=new URLSearchParams({path:t});return(0,tG.SC)(`/api/servers/${encodeURIComponent(e)}/files/read?${i}`)},enabled:!!e&&!!t})}function t8(e){let t=(0,tU.NL)();return(0,t_.D)({mutationFn:({path:t,content:i})=>{let n=new URLSearchParams({path:t});return(0,tG.SC)(`/api/servers/${encodeURIComponent(e)}/files/write?${n}`,{method:"PUT",body:JSON.stringify({content:i})})},onSuccess:()=>{t.invalidateQueries({queryKey:["servers",e,"files"]})}})}var t9=i(98898),t7=i(42578),ie=i(31620);function it({path:e,onNavigate:t}){let i=e.split("/").filter(Boolean);return(0,h.jsxs)(t9.Z,{sx:{mb:1},children:[(0,h.jsxs)(t7.Z,{component:"button",underline:"hover",color:"inherit",onClick:()=>t("/"),sx:{display:"flex",alignItems:"center",gap:.5,cursor:"pointer"},children:[h.jsx(ie.Z,{sx:{fontSize:18}}),"root"]}),i.map((e,n)=>{let r=n===i.length-1,s="/"+i.slice(0,n+1).join("/");return r?h.jsx(w.Z,{color:"text.primary",sx:{fontWeight:500},children:e},s):h.jsx(t7.Z,{component:"button",underline:"hover",color:"inherit",onClick:()=>t(s),sx:{cursor:"pointer"},children:e},s)})]})}var ii=i(10937),ir=i(66831),is=i(80403);let io=/[/\\]/,il=/\.\./;function ia({open:e,existingNames:t,isPending:i,onConfirm:n,onClose:r}){let[s,o]=(0,c.useState)(""),l=(0,c.useMemo)(()=>s.trim()?io.test(s)?"Name cannot contain / or \\":il.test(s)?'Name cannot contain ".."':s.startsWith(".")?'Name cannot start with "."':null:"Folder name cannot be empty",[s]),a=(0,c.useMemo)(()=>t.some(e=>e.toLowerCase()===s.trim().toLowerCase()),[s,t]),d=!l&&!a&&!!s.trim(),u=(0,c.useCallback)(()=>{d&&(n(s.trim()),o(""))},[d,s,n]),f=(0,c.useCallback)(()=>{o(""),r()},[r]);return(0,h.jsxs)(M.Z,{open:e,onClose:f,maxWidth:"xs",fullWidth:!0,children:[h.jsx(Z.Z,{children:"Create New Folder"}),h.jsx(A.Z,{children:h.jsx(O.Z,{autoFocus:!0,fullWidth:!0,label:"Folder name",value:s,onChange:e=>o(e.target.value),onKeyDown:e=>"Enter"===e.key&&u(),error:!!l&&s.length>0||a,helperText:s.length>0&&l||(a?`"${s.trim()}" already exists`:void 0),sx:{mt:1}})}),(0,h.jsxs)(T.Z,{children:[h.jsx(p.Z,{onClick:f,children:"Cancel"}),h.jsx(p.Z,{onClick:u,variant:"contained",disabled:i||!d,children:"Create"})]})]})}function ih({searchQuery:e,onSearchChange:t,onCreateFolder:i,onUpload:n,onRefresh:r,existingNames:s,disabled:o}){let[l,a]=(0,c.useState)(!1);return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(f.Z,{sx:{display:"flex",gap:1,alignItems:"center",mb:2,flexWrap:"wrap"},children:[h.jsx(O.Z,{size:"small",placeholder:"Search files...",value:e,onChange:e=>t(e.target.value),InputProps:{startAdornment:h.jsx(V.Z,{position:"start",children:h.jsx(t2.Z,{sx:{fontSize:20,color:"text.secondary"}})})},sx:{minWidth:200,flex:{xs:"1 1 100%",sm:"0 1 auto"}}}),(0,h.jsxs)(f.Z,{sx:{display:"flex",gap:1,ml:"auto"},children:[h.jsx(p.Z,{size:"small",startIcon:h.jsx(is.Z,{}),onClick:n,disabled:o,children:"Upload"}),h.jsx(p.Z,{size:"small",startIcon:h.jsx(ii.Z,{}),onClick:()=>a(!0),disabled:o,children:"New Folder"}),h.jsx(p.Z,{size:"small",startIcon:h.jsx(ir.Z,{}),onClick:r,disabled:o,children:"Refresh"})]})]}),h.jsx(ia,{open:l,existingNames:s,isPending:!!o,onConfirm:e=>{i(e),a(!1)},onClose:()=>a(!1)})]})}var ic=i(37891),id=i(88916),iu=i(75698),ip=i(664),im=i(70862),ig=i(59059),ix=i(19103),iv=i(15348),iy=i(61872),ib=i(54896),iw=i(26567),ik=i(75569),iS=i(97441),iC=i(27429),ij=i(92058);function iM(e){return["yml","yaml","json","properties","toml","cfg","conf","ini","txt","md","log","xml","sh","bat","csv"].includes(e.split(".").pop()?.toLowerCase()||"")}function iZ({file:e,currentPath:t,onNavigate:i,onAction:n}){var r;let[s,o]=(0,c.useState)(null),l=()=>{"directory"===e.type?i("/"===t?`/${e.name}`:`${t}/${e.name}`):iM(e.name)&&n("open")};return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(ig.Z,{hover:!0,sx:{cursor:"directory"===e.type||iM(e.name)?"pointer":"default"},onClick:l,children:[h.jsx(iu.Z,{children:(0,h.jsxs)(f.Z,{sx:{display:"flex",alignItems:"center",gap:1},children:[function(e){if("directory"===e.type)return h.jsx(ix.Z,{sx:{color:"#FFB74D"}});let t=e.name.split(".").pop()?.toLowerCase()||"";return["yml","yaml","json","properties","toml","cfg","conf","ini","txt","md"].includes(t)?h.jsx(iy.Z,{sx:{color:"#42A5F5"}}):"jar"===t?h.jsx(ib.Z,{sx:{color:"#AB47BC"}}):"log"===t?h.jsx(iw.Z,{sx:{color:"#78909C"}}):["dat","dat_old","mca","nbt","lock"].includes(t)?h.jsx(ik.Z,{sx:{color:"#8D6E63"}}):h.jsx(iv.Z,{sx:{color:"#90A4AE"}})}(e),h.jsx(w.Z,{variant:"body2",sx:{fontWeight:"directory"===e.type?500:400,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.name})]})}),h.jsx(iu.Z,{sx:{display:{xs:"none",sm:"table-cell"}},children:h.jsx(w.Z,{variant:"body2",color:"text.secondary",children:"directory"===e.type?"-":0===(r=e.size)?"-":r<1024?`${r} B`:r<1048576?`${(r/1024).toFixed(1)} KB`:r<1073741824?`${(r/1024/1024).toFixed(1)} MB`:`${(r/1024/1024/1024).toFixed(1)} GB`})}),h.jsx(iu.Z,{sx:{display:{xs:"none",md:"table-cell"}},children:h.jsx(w.Z,{variant:"body2",color:"text.secondary",children:new Date(e.modifiedAt).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})})}),h.jsx(iu.Z,{children:h.jsx(m.Z,{size:"small",onClick:e=>{e.stopPropagation(),o(e.currentTarget)},children:h.jsx(I.Z,{fontSize:"small"})})})]}),(0,h.jsxs)(k.Z,{anchorEl:s,open:!!s,onClose:()=>o(null),children:["directory"===e.type&&(0,h.jsxs)(S.Z,{onClick:()=>{o(null),l()},children:[h.jsx(C.Z,{children:h.jsx(iS.Z,{fontSize:"small"})}),h.jsx(j.Z,{children:"Open"})]}),"file"===e.type&&iM(e.name)&&(0,h.jsxs)(S.Z,{onClick:()=>{o(null),n("open")},children:[h.jsx(C.Z,{children:h.jsx(iC.Z,{fontSize:"small"})}),h.jsx(j.Z,{children:"Edit"})]}),"file"===e.type&&(0,h.jsxs)(S.Z,{onClick:()=>{o(null),n("download")},children:[h.jsx(C.Z,{children:h.jsx(t6.Z,{fontSize:"small"})}),h.jsx(j.Z,{children:"Download"})]}),(0,h.jsxs)(S.Z,{onClick:()=>{o(null),n("rename")},children:[h.jsx(C.Z,{children:h.jsx(ij.Z,{fontSize:"small"})}),h.jsx(j.Z,{children:"Rename"})]}),(0,h.jsxs)(S.Z,{onClick:()=>{o(null),n("delete")},sx:{color:"error.main"},children:[h.jsx(C.Z,{children:h.jsx(E.Z,{fontSize:"small",color:"error"})}),h.jsx(j.Z,{children:"Delete"})]})]})]})}function iA({files:e,currentPath:t,onNavigate:i,onFileAction:n,searchQuery:r}){let s=r?e.filter(e=>e.name.toLowerCase().includes(r.toLowerCase())):e;return 0===s.length?(0,h.jsxs)(f.Z,{sx:{textAlign:"center",py:6},children:[h.jsx(ix.Z,{sx:{fontSize:48,color:"text.disabled",mb:1}}),h.jsx(w.Z,{variant:"body1",color:"text.secondary",children:r?"No matching files found":"This directory is empty"})]}):h.jsx(ip.Z,{children:(0,h.jsxs)(ic.Z,{size:"small",children:[h.jsx(im.Z,{children:(0,h.jsxs)(ig.Z,{children:[h.jsx(iu.Z,{sx:{fontWeight:600},children:"Name"}),h.jsx(iu.Z,{sx:{fontWeight:600,width:100,display:{xs:"none",sm:"table-cell"}},children:"Size"}),h.jsx(iu.Z,{sx:{fontWeight:600,width:160,display:{xs:"none",md:"table-cell"}},children:"Modified"}),h.jsx(iu.Z,{sx:{width:48}})]})}),h.jsx(id.Z,{children:s.map(e=>h.jsx(iZ,{file:e,currentPath:t,onNavigate:i,onAction:t=>n(t,e)},e.name))})]})})}function iT({language:e,fileSize:t,line:i,col:n,dirty:r}){return(0,h.jsxs)(f.Z,{sx:{display:"flex",alignItems:"center",gap:2,px:2,py:.5,bgcolor:"grey.100",borderTop:1,borderColor:"divider",fontSize:"0.75rem",color:"text.secondary",flexWrap:"wrap",minHeight:28},children:[h.jsx(w.Z,{variant:"caption",sx:{fontWeight:500},children:e}),h.jsx(w.Z,{variant:"caption",children:t<1024?`${t} B`:t<1048576?`${(t/1024).toFixed(1)} KB`:`${(t/1024/1024).toFixed(1)} MB`}),h.jsx(w.Z,{variant:"caption",children:"UTF-8"}),(0,h.jsxs)(w.Z,{variant:"caption",children:["Ln ",i,", Col ",n]}),h.jsx(f.Z,{sx:{flex:1}}),r&&h.jsx(w.Z,{variant:"caption",sx:{color:"warning.main",fontWeight:600},children:"Modified"})]})}function iO({serverName:e,filePath:t,onBack:i}){let n=(0,c.useRef)(null),r=(0,c.useRef)(null),[s,o]=(0,c.useState)(!1),[l,a]=(0,c.useState)({line:1,col:1}),[d,u]=(0,c.useState)(!1),v=t.split("/").pop()||"",{data:k,isLoading:S,error:C}=t3(e,t),j=t8(e),Z=(0,c.useCallback)(()=>{if(!r.current||!t)return;let e=r.current.state.doc.toString();j.mutate({path:t,content:e},{onSuccess:()=>o(!1)})},[t,j]),A=(0,c.useCallback)(()=>{s?u(!0):i()},[s,i]),T=(0,c.useCallback)(()=>{u(!1),o(!1),i()},[i]),O=k&&k.size>5242880;return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(y.Z,{sx:{borderRadius:3,display:"flex",flexDirection:"column",minHeight:600},children:[(0,h.jsxs)(f.Z,{sx:{display:"flex",alignItems:"center",gap:1,px:2,py:1,borderBottom:1,borderColor:"divider"},children:[h.jsx(m.Z,{size:"small",onClick:A,"aria-label":"back",children:h.jsx(P.Z,{})}),h.jsx(iy.Z,{sx:{color:"primary.main"}}),(0,h.jsxs)(w.Z,{variant:"subtitle1",sx:{fontWeight:600,flex:1},noWrap:!0,children:[v,s&&" *"]}),h.jsx(p.Z,{size:"small",variant:"contained",startIcon:j.isPending?h.jsx(x.Z,{size:16,color:"inherit"}):h.jsx(eb.Z,{}),onClick:Z,disabled:!s||j.isPending,children:"Save"})]}),(0,h.jsxs)(b.Z,{sx:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden",p:0,"&:last-child":{pb:0}},children:[S&&h.jsx(f.Z,{sx:{display:"flex",justifyContent:"center",alignItems:"center",flex:1},children:h.jsx(x.Z,{})}),C&&(0,h.jsxs)(g.Z,{severity:"error",sx:{m:2},children:["Failed to load file: ",C.message]}),O&&(0,h.jsxs)(g.Z,{severity:"warning",sx:{m:2},children:["This file is too large to edit (",(k.size/1024/1024).toFixed(1)," MB). Maximum editable size is 5 MB."]}),j.isError&&(0,h.jsxs)(g.Z,{severity:"error",sx:{m:2},children:["Failed to save: ",j.error.message]}),j.isSuccess&&!s&&h.jsx(g.Z,{severity:"success",sx:{m:2},children:"File saved successfully."}),k&&!O&&h.jsx(f.Z,{ref:n,sx:{flex:1,overflow:"hidden"}}),k&&!O&&h.jsx(iT,{language:{json:"JSON",yml:"YAML",yaml:"YAML",xml:"XML",html:"HTML",properties:"Properties",toml:"TOML",cfg:"Config",conf:"Config",ini:"INI",txt:"Plain Text",md:"Markdown",log:"Log",sh:"Shell",bat:"Batch",csv:"CSV"}[v.split(".").pop()?.toLowerCase()||""]||"Plain Text",fileSize:k.size,line:l.line,col:l.col,dirty:s})]})]}),h.jsx(M.Z,{open:d,onClose:()=>u(!1),maxWidth:"xs",fullWidth:!0,children:(0,h.jsxs)(f.Z,{sx:{p:3},children:[h.jsx(w.Z,{variant:"h6",gutterBottom:!0,children:"Unsaved Changes"}),(0,h.jsxs)(w.Z,{variant:"body2",color:"text.secondary",sx:{mb:3},children:["You have unsaved changes in ",h.jsx("strong",{children:v}),". Do you want to discard them?"]}),(0,h.jsxs)(f.Z,{sx:{display:"flex",justifyContent:"flex-end",gap:1},children:[h.jsx(p.Z,{onClick:()=>u(!1),children:"Cancel"}),h.jsx(p.Z,{onClick:T,color:"error",variant:"contained",children:"Discard"})]})]})})]})}var iD=i(54458);let iR=new Set(["world","world_nether","world_the_end","server.jar","server.properties","plugins","mods"]);function iP({target:e,isPending:t,onConfirm:i,onClose:n}){var r;let[s,o]=(0,c.useState)(""),l=!!e&&(r=e.name,iR.has(r.toLowerCase())),a=e?.type==="directory",d=!l||s===e?.name,u=(0,c.useCallback)(()=>{d&&i()},[d,i]);return(0,h.jsxs)(M.Z,{open:!!e,onClose:n,maxWidth:"xs",fullWidth:!0,children:[(0,h.jsxs)(Z.Z,{children:["Delete ",a?"Folder":"File"]}),(0,h.jsxs)(A.Z,{children:[(0,h.jsxs)(iD.Z,{children:["Are you sure you want to delete ",h.jsx("strong",{children:e?.name}),"?",a&&" This will delete all contents inside."," ","This action cannot be undone."]}),l&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(g.Z,{severity:"warning",sx:{mt:2},children:[h.jsx("strong",{children:e?.name})," is a critical server ",a?"folder":"file",". Deleting it may break your server."]}),h.jsx(O.Z,{autoFocus:!0,fullWidth:!0,label:`Type "${e?.name}" to confirm`,value:s,onChange:e=>o(e.target.value),onKeyDown:e=>"Enter"===e.key&&u(),placeholder:e?.name,sx:{mt:2},error:s.length>0&&s!==e?.name})]})]}),(0,h.jsxs)(T.Z,{children:[h.jsx(p.Z,{onClick:n,children:"Cancel"}),h.jsx(p.Z,{onClick:u,color:"error",variant:"contained",disabled:t||!d,children:"Delete"})]})]})}let iL=/[/\\]/,iI=/\.\./;function iE(e){let t=e.lastIndexOf(".");return t>0?e.slice(t):""}function iB({target:e,existingNames:t,isPending:i,onConfirm:n,onClose:r}){let[s,o]=(0,c.useState)(""),l=(0,c.useMemo)(()=>s.trim()?iL.test(s)?"Name cannot contain / or \\":iI.test(s)?'Name cannot contain ".."':s.startsWith(".")?'Name cannot start with "."':null:"Name cannot be empty",[s]),a=(0,c.useMemo)(()=>t.some(t=>t!==e?.name&&t.toLowerCase()===s.trim().toLowerCase()),[s,e?.name,t]),d=(0,c.useMemo)(()=>!!e&&"directory"!==e.type&&iE(e.name)!==iE(s),[e,s]),u=s.trim()===e?.name,f=!l&&!a&&!u&&!!s.trim(),m=(0,c.useCallback)(()=>{f&&n(s.trim())},[f,s,n]);return(0,h.jsxs)(M.Z,{open:!!e,onClose:r,maxWidth:"xs",fullWidth:!0,children:[h.jsx(Z.Z,{children:"Rename"}),(0,h.jsxs)(A.Z,{children:[h.jsx(O.Z,{autoFocus:!0,fullWidth:!0,label:"New name",value:s,onChange:e=>o(e.target.value),onKeyDown:e=>"Enter"===e.key&&m(),error:!!l||a,helperText:l||(a?`"${s.trim()}" already exists`:void 0),sx:{mt:1}}),d&&!l&&!a&&h.jsx(g.Z,{severity:"warning",sx:{mt:2},children:"Changing the file extension may make the file unusable."})]}),(0,h.jsxs)(T.Z,{children:[h.jsx(p.Z,{onClick:r,children:"Cancel"}),h.jsx(p.Z,{onClick:m,variant:"contained",disabled:i||!f,children:"Rename"})]})]})}var iN=i(64668),iz=i(28669),iW=i(54815),iF=i(65465),iV=i(26774),iH=i(48688);let i$={whitelist:{label:"Whitelist Manager",icon:h.jsx(iz.Z,{sx:{color:"primary.main"}})},ops:{label:"Operators Manager",icon:h.jsx(eU.Z,{sx:{color:"primary.main"}})},bans:{label:"Ban List Manager",icon:h.jsx(iW.Z,{sx:{color:"primary.main"}})}};function iq({serverName:e,editorType:t,filePath:i,onBack:n,onSwitchToRaw:r}){let s=i$[t];return(0,h.jsxs)(y.Z,{sx:{borderRadius:3,display:"flex",flexDirection:"column",minHeight:600},children:[(0,h.jsxs)(f.Z,{sx:{display:"flex",alignItems:"center",gap:1,px:2,py:1,borderBottom:1,borderColor:"divider"},children:[h.jsx(m.Z,{size:"small",onClick:n,"aria-label":"back",children:h.jsx(P.Z,{})}),s.icon,h.jsx(w.Z,{variant:"subtitle1",sx:{fontWeight:600,flex:1},noWrap:!0,children:s.label}),i&&h.jsx(p.Z,{size:"small",startIcon:h.jsx(iN.Z,{}),onClick:()=>{n(),r(i)},children:"Raw View"})]}),(0,h.jsxs)(b.Z,{sx:{flex:1,overflow:"auto",p:{xs:1,sm:2},"&:last-child":{pb:2}},children:["whitelist"===t&&h.jsx(iF.Z,{serverName:e}),"ops"===t&&h.jsx(iV.d,{serverName:e}),"bans"===t&&h.jsx(iH.Z,{serverName:e})]})]})}var iK=i(95257),iU=i(95661),i_=i(40768),iG=i(61989),iJ=i(95009),iX=i(4587),iY=i(45912),iQ=i(34615),i0=i(61649);let i1={gameplay:{label:"Gameplay",description:"Game rules, player limits, and core mechanics"},world:{label:"World Generation",description:"World settings, level name, and generation options"},network:{label:"Network & Security",description:"Ports, authentication, RCON, and query settings"},performance:{label:"Performance",description:"View distance, tick settings, and compression"},advanced:{label:"Advanced",description:"Other server properties"}},i2=["gameplay","world","network","performance","advanced"],i5=[{key:"gamemode",type:"enum",category:"gameplay",label:"Game Mode",description:"Default game mode for new players",defaultValue:"survival",options:[{value:"survival",label:"Survival"},{value:"creative",label:"Creative"},{value:"adventure",label:"Adventure"},{value:"spectator",label:"Spectator"}]},{key:"difficulty",type:"enum",category:"gameplay",label:"Difficulty",description:"Server difficulty level",defaultValue:"easy",options:[{value:"peaceful",label:"Peaceful"},{value:"easy",label:"Easy"},{value:"normal",label:"Normal"},{value:"hard",label:"Hard"}]},{key:"hardcore",type:"boolean",category:"gameplay",label:"Hardcore",description:"Players are set to spectator mode on death",defaultValue:"false"},{key:"pvp",type:"boolean",category:"gameplay",label:"PvP",description:"Allow player vs player combat",defaultValue:"true"},{key:"max-players",type:"number",category:"gameplay",label:"Max Players",description:"Maximum number of players on the server",defaultValue:"20",min:0,max:2147483647},{key:"force-gamemode",type:"boolean",category:"gameplay",label:"Force Game Mode",description:"Force players to join in the default game mode",defaultValue:"false"},{key:"allow-flight",type:"boolean",category:"gameplay",label:"Allow Flight",description:"Allow players to use flight in survival mode",defaultValue:"false"},{key:"spawn-protection",type:"number",category:"gameplay",label:"Spawn Protection",description:"Radius of spawn protection area (0 = disabled)",defaultValue:"16",min:0,max:65536},{key:"spawn-animals",type:"boolean",category:"gameplay",label:"Spawn Animals",description:"Allow animals to spawn naturally",defaultValue:"true"},{key:"spawn-monsters",type:"boolean",category:"gameplay",label:"Spawn Monsters",description:"Allow hostile mobs to spawn naturally",defaultValue:"true"},{key:"spawn-npcs",type:"boolean",category:"gameplay",label:"Spawn NPCs",description:"Allow villagers to spawn",defaultValue:"true"},{key:"allow-nether",type:"boolean",category:"gameplay",label:"Allow Nether",description:"Allow players to travel to the Nether",defaultValue:"true"},{key:"enable-command-block",type:"boolean",category:"gameplay",label:"Enable Command Blocks",description:"Allow command blocks to be used",defaultValue:"false"},{key:"player-idle-timeout",type:"number",category:"gameplay",label:"Player Idle Timeout",description:"Kick idle players after N minutes (0 = disabled)",defaultValue:"0",min:0,max:2147483647},{key:"level-name",type:"string",category:"world",label:"Level Name",description:"Name of the world folder",defaultValue:"world"},{key:"level-seed",type:"string",category:"world",label:"Level Seed",description:"Seed for world generation (blank = random)",defaultValue:""},{key:"level-type",type:"enum",category:"world",label:"Level Type",description:"World generation type",defaultValue:"minecraft\\:normal",options:[{value:"minecraft\\:normal",label:"Normal"},{value:"minecraft\\:flat",label:"Flat"},{value:"minecraft\\:large_biomes",label:"Large Biomes"},{value:"minecraft\\:amplified",label:"Amplified"},{value:"minecraft\\:single_biome_surface",label:"Single Biome"}]},{key:"generate-structures",type:"boolean",category:"world",label:"Generate Structures",description:"Generate villages, temples, and other structures",defaultValue:"true"},{key:"max-world-size",type:"number",category:"world",label:"Max World Size",description:"Maximum world border radius in blocks",defaultValue:"29999984",min:1,max:29999984},{key:"generator-settings",type:"string",category:"world",label:"Generator Settings",description:"Custom world generator settings (JSON)",defaultValue:"{}"},{key:"motd",type:"string",category:"world",label:"MOTD",description:"Message displayed in the server list",defaultValue:"A Minecraft Server"},{key:"server-port",type:"readonly",category:"network",label:"Server Port",description:"Port the server listens on (cannot be changed at runtime)",defaultValue:"25565"},{key:"server-ip",type:"readonly",category:"network",label:"Server IP",description:"IP address to bind to (blank = all interfaces)",defaultValue:""},{key:"online-mode",type:"boolean",category:"network",label:"Online Mode",description:"Authenticate players with Mojang servers",defaultValue:"true"},{key:"white-list",type:"boolean",category:"network",label:"Whitelist",description:"Only allow whitelisted players to join",defaultValue:"false"},{key:"enforce-whitelist",type:"boolean",category:"network",label:"Enforce Whitelist",description:"Kick non-whitelisted players when whitelist is reloaded",defaultValue:"false"},{key:"enforce-secure-profile",type:"boolean",category:"network",label:"Enforce Secure Profile",description:"Require players to have a signed key from Mojang",defaultValue:"true"},{key:"enable-rcon",type:"boolean",category:"network",label:"Enable RCON",description:"Enable remote console access",defaultValue:"false"},{key:"rcon.port",type:"number",category:"network",label:"RCON Port",description:"Port for RCON connections",defaultValue:"25575",min:1,max:65535},{key:"rcon.password",type:"string",category:"network",label:"RCON Password",description:"Password for RCON authentication",defaultValue:""},{key:"enable-query",type:"boolean",category:"network",label:"Enable Query",description:"Enable GameSpy4 protocol server listener",defaultValue:"false"},{key:"query.port",type:"number",category:"network",label:"Query Port",description:"Port for query protocol",defaultValue:"25565",min:1,max:65535},{key:"enable-status",type:"boolean",category:"network",label:"Enable Status",description:"Show server in the server list",defaultValue:"true"},{key:"prevent-proxy-connections",type:"boolean",category:"network",label:"Prevent Proxy Connections",description:"Block VPN/proxy connections (requires online-mode)",defaultValue:"false"},{key:"hide-online-players",type:"boolean",category:"network",label:"Hide Online Players",description:"Hide player count and list in server status",defaultValue:"false"},{key:"view-distance",type:"number",category:"performance",label:"View Distance",description:"Render distance in chunks sent to players",defaultValue:"10",min:3,max:32},{key:"simulation-distance",type:"number",category:"performance",label:"Simulation Distance",description:"Distance in chunks for entity simulation",defaultValue:"10",min:3,max:32},{key:"max-tick-time",type:"number",category:"performance",label:"Max Tick Time",description:"Maximum tick duration before watchdog crash (ms, -1 = disabled)",defaultValue:"60000",min:-1,max:2147483647},{key:"network-compression-threshold",type:"number",category:"performance",label:"Network Compression Threshold",description:"Minimum packet size to compress (bytes, -1 = disabled)",defaultValue:"256",min:-1,max:2147483647},{key:"max-chained-neighbor-updates",type:"number",category:"performance",label:"Max Chained Neighbor Updates",description:"Limit for chained block updates (-1 = unlimited)",defaultValue:"1000000",min:-1,max:2147483647},{key:"rate-limit",type:"number",category:"performance",label:"Rate Limit",description:"Max packets per second before kick (0 = disabled)",defaultValue:"0",min:0,max:2147483647},{key:"entity-broadcast-range-percentage",type:"number",category:"performance",label:"Entity Broadcast Range",description:"Percentage of default entity visibility range",defaultValue:"100",min:10,max:1e3},{key:"resource-pack",type:"string",category:"advanced",label:"Resource Pack URL",description:"URL of the server resource pack",defaultValue:""},{key:"resource-pack-sha1",type:"string",category:"advanced",label:"Resource Pack SHA1",description:"SHA1 hash of the resource pack file",defaultValue:""},{key:"require-resource-pack",type:"boolean",category:"advanced",label:"Require Resource Pack",description:"Kick players who decline the resource pack",defaultValue:"false"},{key:"resource-pack-prompt",type:"string",category:"advanced",label:"Resource Pack Prompt",description:"Custom message shown when asking to download resource pack",defaultValue:""},{key:"function-permission-level",type:"enum",category:"advanced",label:"Function Permission Level",description:"OP level required to execute functions",defaultValue:"2",options:[{value:"1",label:"Level 1 - Moderator"},{value:"2",label:"Level 2 - Gamemaster"},{value:"3",label:"Level 3 - Admin"},{value:"4",label:"Level 4 - Owner"}]},{key:"op-permission-level",type:"enum",category:"advanced",label:"OP Permission Level",description:"Default OP level for new operators",defaultValue:"4",options:[{value:"1",label:"Level 1 - Moderator"},{value:"2",label:"Level 2 - Gamemaster"},{value:"3",label:"Level 3 - Admin"},{value:"4",label:"Level 4 - Owner"}]},{key:"text-filtering-config",type:"string",category:"advanced",label:"Text Filtering Config",description:"Text filtering configuration file",defaultValue:""},{key:"log-ips",type:"boolean",category:"advanced",label:"Log IPs",description:"Log player IP addresses in the server log",defaultValue:"true"},{key:"broadcast-console-to-ops",type:"boolean",category:"advanced",label:"Broadcast Console to OPs",description:"Send console output to all OPs",defaultValue:"true"},{key:"broadcast-rcon-to-ops",type:"boolean",category:"advanced",label:"Broadcast RCON to OPs",description:"Send RCON output to all OPs",defaultValue:"true"},{key:"sync-chunk-writes",type:"boolean",category:"advanced",label:"Sync Chunk Writes",description:"Synchronize chunk writes for data safety",defaultValue:"true"},{key:"enable-jmx-monitoring",type:"boolean",category:"advanced",label:"Enable JMX Monitoring",description:"Expose JMX metrics for monitoring",defaultValue:"false"},{key:"use-native-transport",type:"boolean",category:"advanced",label:"Use Native Transport",description:"Use Linux-specific packet optimizations",defaultValue:"true"},{key:"initial-enabled-packs",type:"string",category:"advanced",label:"Initial Enabled Packs",description:"Comma-separated list of initially enabled data packs",defaultValue:"vanilla"},{key:"initial-disabled-packs",type:"string",category:"advanced",label:"Initial Disabled Packs",description:"Comma-separated list of initially disabled data packs",defaultValue:""}],i6=(i5.map(e=>[e.key,e]),h.jsx(F.Z,{label:"modified",size:"small",color:"warning",variant:"outlined"}));function i4({schema:e,value:t,onChange:i,isChanged:n}){let r=n?{"& .MuiInputBase-root":{bgcolor:"action.selected"}}:void 0,s=n?h.jsx(V.Z,{position:"end",children:i6}):void 0;switch(e.type){case"boolean":return(0,h.jsxs)(f.Z,{children:[(0,h.jsxs)(f.Z,{sx:{display:"flex",alignItems:"center",gap:1},children:[h.jsx(eA.Z,{control:h.jsx(eT.Z,{checked:"true"===t,onChange:t=>i(e.key,t.target.checked?"true":"false"),size:"small"}),label:e.label,sx:{mr:0}}),n&&i6]}),h.jsx(w.Z,{variant:"caption",color:"text.secondary",sx:{ml:"48px",display:"block",mt:-.5},children:e.description})]});case"enum":return h.jsx(O.Z,{select:!0,fullWidth:!0,size:"small",label:e.label,helperText:e.description,value:t,onChange:t=>i(e.key,t.target.value),InputProps:{endAdornment:s},sx:r,children:e.options?.map(e=>h.jsx(S.Z,{value:e.value,children:e.label},e.value))});case"number":return h.jsx(O.Z,{fullWidth:!0,size:"small",type:"number",label:e.label,helperText:e.description,value:t,onChange:t=>i(e.key,t.target.value),inputProps:{min:e.min,max:e.max},InputProps:{endAdornment:s},sx:r});case"readonly":return h.jsx(O.Z,{fullWidth:!0,size:"small",label:e.label,helperText:e.description,value:t,disabled:!0,InputProps:{endAdornment:h.jsx(V.Z,{position:"end",children:h.jsx(F.Z,{label:"readonly",size:"small",variant:"outlined"})})}});default:return h.jsx(O.Z,{fullWidth:!0,size:"small",label:e.label,helperText:e.description,value:t,onChange:t=>i(e.key,t.target.value),InputProps:{endAdornment:s},sx:r})}}function i3({serverName:e}){let t="/server.properties",{data:i,isLoading:n,error:r}=t3(e,t),s=t8(e),[o,l]=(0,c.useState)({}),[a,d]=(0,c.useState)({}),[u,m]=(0,c.useState)(""),v=(0,c.useCallback)((e,t)=>{l(i=>({...i,[e]:t}))},[]),y=(0,c.useMemo)(()=>{let e=[];for(let t of Object.keys(o))o[t]!==a[t]&&e.push(t);return e},[o,a]),b=(0,c.useCallback)(()=>{if(!i?.content)return;let e=function(e,t){let i=e.split("\n"),n=new Set,r=i.map(e=>{let i=e.trim();if(!i||i.startsWith("#"))return e;let r=i.indexOf("=");if(-1===r)return e;let s=i.substring(0,r).trim();return(n.add(s),s in t)?`${s}=${t[s]}`:e});for(let[e,i]of Object.entries(t))n.has(e)||r.push(`${e}=${i}`);return r.join("\n")}(i.content,o);s.mutate({path:t,content:e},{onSuccess:()=>{d({...o})}})},[i,o,s]),k=(0,c.useCallback)(()=>{l({...a})},[a]),S=(0,c.useMemo)(()=>{let e=u.toLowerCase(),t={gameplay:[],world:[],network:[],performance:[],advanced:[]};for(let i of i5)(!e||i.key.toLowerCase().includes(e)||i.label.toLowerCase().includes(e)||i.description.toLowerCase().includes(e))&&t[i.category].push(i);let i=new Set(i5.map(e=>e.key));for(let n of Object.keys(o))!i.has(n)&&(!e||n.toLowerCase().includes(e))&&t.advanced.push({key:n,type:"string",category:"advanced",label:n,description:"Custom property (not in standard schema)",defaultValue:""});return t},[u,o]);return n?h.jsx(f.Z,{sx:{display:"flex",justifyContent:"center",alignItems:"center",py:8},children:h.jsx(x.Z,{})}):r?(0,h.jsxs)(g.Z,{severity:"error",sx:{m:2},children:["Failed to load server.properties: ",r.message]}):(0,h.jsxs)(f.Z,{sx:{display:"flex",flexDirection:"column",height:"100%"},children:[h.jsx(g.Z,{severity:"warning",icon:h.jsx(i0.Z,{}),sx:{mx:2,mt:2,mb:1},children:(0,h.jsxs)(w.Z,{variant:"body2",children:[h.jsx("strong",{children:"Warning:"})," Changes are applied directly to the running server file. For persistent settings that survive server recreation, use the ",h.jsx("strong",{children:"Options"})," tab."]})}),(0,h.jsxs)(f.Z,{sx:{display:"flex",alignItems:"center",gap:1,px:2,py:1},children:[h.jsx(O.Z,{size:"small",placeholder:"Search properties...",value:u,onChange:e=>m(e.target.value),InputProps:{startAdornment:h.jsx(V.Z,{position:"start",children:h.jsx(t2.Z,{fontSize:"small"})})},sx:{flex:1,maxWidth:400}}),h.jsx(f.Z,{sx:{flex:1}}),y.length>0&&h.jsx(F.Z,{label:`${y.length} changed`,color:"warning",size:"small"}),h.jsx(p.Z,{size:"small",startIcon:h.jsx(iQ.Z,{}),onClick:k,disabled:0===y.length,children:"Discard"}),h.jsx(p.Z,{size:"small",variant:"contained",startIcon:s.isPending?h.jsx(x.Z,{size:16,color:"inherit"}):h.jsx(eb.Z,{}),onClick:b,disabled:0===y.length||s.isPending,children:"Save"})]}),s.isError&&(0,h.jsxs)(g.Z,{severity:"error",sx:{mx:2,mb:1},children:["Failed to save: ",s.error.message]}),s.isSuccess&&0===y.length&&h.jsx(g.Z,{severity:"success",sx:{mx:2,mb:1},children:"File saved successfully."}),h.jsx(f.Z,{sx:{flex:1,overflow:"auto",px:2,pb:2},children:i2.map(e=>{let t=S[e];if(0===t.length)return null;let i=i1[e],n=t.filter(e=>y.includes(e.key)).length;return(0,h.jsxs)(iJ.Z,{defaultExpanded:"advanced"!==e,disableGutters:!0,children:[h.jsx(iX.Z,{expandIcon:h.jsx(eC.Z,{}),children:(0,h.jsxs)(f.Z,{sx:{display:"flex",alignItems:"center",gap:1,width:"100%"},children:[h.jsx(w.Z,{variant:"subtitle1",sx:{fontWeight:600},children:i.label}),(0,h.jsxs)(w.Z,{variant:"caption",color:"text.secondary",children:["(",t.length,")"]}),n>0&&h.jsx(F.Z,{label:`${n} modified`,size:"small",color:"warning",variant:"outlined"})]})}),(0,h.jsxs)(iY.Z,{children:[h.jsx(w.Z,{variant:"body2",color:"text.secondary",sx:{mb:2},children:i.description}),h.jsx(D.ZP,{container:!0,spacing:2,children:t.map(e=>{let t=o[e.key]??e.defaultValue,i=y.includes(e.key);return h.jsx(D.ZP,{item:!0,xs:12,sm:"boolean"===e.type?6:12,children:h.jsx(i4,{schema:e,value:t,onChange:v,isChanged:i})},e.key)})})]})]},e)})})]})}let i8=[],i9=[];function i7(e){return e>=127462&&e<=127487}function ne(e,t,i){if(t==e.length)return t;t&&ni(e.charCodeAt(t))&&nn(e.charCodeAt(t-1))&&t--;let n=nt(e,t);for(t+=nr(n);t<e.length;){let r=nt(e,t);if(8205==n||8205==r||i&&function(e){if(e<768)return!1;for(let t=0,i=i8.length;;){let n=t+i>>1;if(e<i8[n])i=n;else{if(!(e>=i9[n]))return!0;t=n+1}if(t==i)return!1}}(r))t+=nr(r),n=r;else if(i7(r)){let i=0,n=t-2;for(;n>=0&&i7(nt(e,n));)i++,n-=2;if(i%2==0)break;t+=2}else break}return t}function nt(e,t){let i=e.charCodeAt(t);if(!nn(i)||t+1==e.length)return i;let n=e.charCodeAt(t+1);return ni(n)?(i-55296<<10)+(n-56320)+65536:i}function ni(e){return e>=56320&&e<57344}function nn(e){return e>=55296&&e<56320}function nr(e){return e<65536?1:2}(()=>{let e="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(e=>e?parseInt(e,36):1);for(let t=0,i=0;t<e.length;t++)(t%2?i9:i8).push(i+=e[t])})();class ns{lineAt(e){if(e<0||e>this.length)throw RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,i){[e,t]=nf(this,e,t);let n=[];return this.decompose(0,e,n,2),i.length&&i.decompose(0,i.length,n,3),this.decompose(t,this.length,n,1),nl.from(n,this.length-(t-e)+i.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=nf(this,e,t);let i=[];return this.decompose(e,t,i,0),nl.from(i,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),i=this.length-this.scanIdentical(e,-1),n=new nh(this),r=new nh(e);for(let e=t,s=t;;){if(n.next(e),r.next(e),e=0,n.lineBreak!=r.lineBreak||n.done!=r.done||n.value!=r.value)return!1;if(s+=n.value.length,n.done||s>=i)return!0}}iter(e=1){return new nh(this,e)}iterRange(e,t=this.length){return new nc(this,e,t)}iterLines(e,t){let i;if(null==e)i=this.iter();else{null==t&&(t=this.lines+1);let n=this.line(e).from;i=this.iterRange(n,Math.max(n,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new nd(i)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(0==e.length)throw RangeError("A document must have at least one line");return 1!=e.length||e[0]?e.length<=32?new no(e):nl.from(no.split(e,[])):ns.empty}}class no extends ns{constructor(e,t=function(e){let t=-1;for(let i of e)t+=i.length+1;return t}(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,i,n){for(let r=0;;r++){let s=this.text[r],o=n+s.length;if((t?i:o)>=e)return new nu(n,o,i,s);n=o+1,i++}}decompose(e,t,i,n){let r=e<=0&&t>=this.length?this:new no(na(this.text,[""],e,t),Math.min(t,this.length)-Math.max(0,e));if(1&n){let e=i.pop(),t=na(r.text,e.text.slice(),0,r.length);if(t.length<=32)i.push(new no(t,e.length+r.length));else{let e=t.length>>1;i.push(new no(t.slice(0,e)),new no(t.slice(e)))}}else i.push(r)}replace(e,t,i){if(!(i instanceof no))return super.replace(e,t,i);[e,t]=nf(this,e,t);let n=na(this.text,na(i.text,na(this.text,[""],0,e)),t),r=this.length+i.length-(t-e);return n.length<=32?new no(n,r):nl.from(no.split(n,[]),r)}sliceString(e,t=this.length,i="\n"){[e,t]=nf(this,e,t);let n="";for(let r=0,s=0;r<=t&&s<this.text.length;s++){let o=this.text[s],l=r+o.length;r>e&&s&&(n+=i),e<l&&t>r&&(n+=o.slice(Math.max(0,e-r),t-r)),r=l+1}return n}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let i=[],n=-1;for(let r of e)i.push(r),n+=r.length+1,32==i.length&&(t.push(new no(i,n)),i=[],n=-1);return n>-1&&t.push(new no(i,n)),t}}class nl extends ns{constructor(e,t){for(let i of(super(),this.children=e,this.length=t,this.lines=0,e))this.lines+=i.lines}lineInner(e,t,i,n){for(let r=0;;r++){let s=this.children[r],o=n+s.length,l=i+s.lines-1;if((t?l:o)>=e)return s.lineInner(e,t,i,n);n=o+1,i=l+1}}decompose(e,t,i,n){for(let r=0,s=0;s<=t&&r<this.children.length;r++){let o=this.children[r],l=s+o.length;if(e<=l&&t>=s){let r=n&((s<=e?1:0)|(l>=t?2:0));s>=e&&l<=t&&!r?i.push(o):o.decompose(e-s,t-s,i,r)}s=l+1}}replace(e,t,i){if([e,t]=nf(this,e,t),i.lines<this.lines)for(let n=0,r=0;n<this.children.length;n++){let s=this.children[n],o=r+s.length;if(e>=r&&t<=o){let l=s.replace(e-r,t-r,i),a=this.lines-s.lines+l.lines;if(l.lines<a>>4&&l.lines>a>>6){let r=this.children.slice();return r[n]=l,new nl(r,this.length-(t-e)+i.length)}return super.replace(r,o,l)}r=o+1}return super.replace(e,t,i)}sliceString(e,t=this.length,i="\n"){[e,t]=nf(this,e,t);let n="";for(let r=0,s=0;r<this.children.length&&s<=t;r++){let o=this.children[r],l=s+o.length;s>e&&r&&(n+=i),e<l&&t>s&&(n+=o.sliceString(e-s,t-s,i)),s=l+1}return n}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof nl))return 0;let i=0,[n,r,s,o]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;n+=t,r+=t){if(n==s||r==o)return i;let l=this.children[n],a=e.children[r];if(l!=a)return i+l.scanIdentical(a,t);i+=l.length+1}}static from(e,t=e.reduce((e,t)=>e+t.length+1,-1)){let i=0;for(let t of e)i+=t.lines;if(i<32){let i=[];for(let t of e)t.flatten(i);return new no(i,t)}let n=Math.max(32,i>>5),r=n<<1,s=n>>1,o=[],l=0,a=-1,h=[];function c(){0!=l&&(o.push(1==h.length?h[0]:nl.from(h,a)),a=-1,l=h.length=0)}for(let t of e)!function e(t){let i;if(t.lines>r&&t instanceof nl)for(let i of t.children)e(i);else t.lines>s&&(l>s||!l)?(c(),o.push(t)):t instanceof no&&l&&(i=h[h.length-1])instanceof no&&t.lines+i.lines<=32?(l+=t.lines,a+=t.length+1,h[h.length-1]=new no(i.text.concat(t.text),i.length+1+t.length)):(l+t.lines>n&&c(),l+=t.lines,a+=t.length+1,h.push(t))}(t);return c(),1==o.length?o[0]:new nl(o,t)}}function na(e,t,i=0,n=1e9){for(let r=0,s=0,o=!0;s<e.length&&r<=n;s++){let l=e[s],a=r+l.length;a>=i&&(a>n&&(l=l.slice(0,n-r)),r<i&&(l=l.slice(i-r)),o?(t[t.length-1]+=l,o=!1):t.push(l)),r=a+1}return t}ns.empty=new no([""],0);class nh{constructor(e,t=1){this.dir=t,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[e],this.offsets=[t>0?1:(e instanceof no?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,n=this.nodes[i],r=this.offsets[i],s=r>>1,o=n instanceof no?n.text.length:n.children.length;if(s==(t>0?o:0)){if(0==i)return this.done=!0,this.value="",this;t>0&&this.offsets[i-1]++,this.nodes.pop(),this.offsets.pop()}else if((1&r)==(t>0?0:1)){if(this.offsets[i]+=t,0==e)return this.lineBreak=!0,this.value="\n",this;e--}else if(n instanceof no){let r=n.text[s+(t<0?-1:0)];if(this.offsets[i]+=t,r.length>Math.max(0,e))return this.value=0==e?r:t>0?r.slice(e):r.slice(0,r.length-e),this;e-=r.length}else{let r=n.children[s+(t<0?-1:0)];e>r.length?(e-=r.length,this.offsets[i]+=t):(t<0&&this.offsets[i]--,this.nodes.push(r),this.offsets.push(t>0?1:(r instanceof no?r.text.length:r.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class nc{constructor(e,t,i){this.value="",this.done=!1,this.cursor=new nh(e,t>i?-1:1),this.pos=t>i?e.length:0,this.from=Math.min(t,i),this.to=Math.max(t,i)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let i=t<0?this.pos-this.from:this.to-this.pos;e>i&&(e=i),i-=e;let{value:n}=this.cursor.next(e);return this.pos+=(n.length+e)*t,this.value=n.length<=i?n:t<0?n.slice(n.length-i):n.slice(0,i),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&""!=this.value}}class nd{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:i,value:n}=this.inner.next(e);return t&&this.afterBreak?(this.value="",this.afterBreak=!1):t?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=n,this.afterBreak=!1),this}get lineBreak(){return!1}}"undefined"!=typeof Symbol&&(ns.prototype[Symbol.iterator]=function(){return this.iter()},nh.prototype[Symbol.iterator]=nc.prototype[Symbol.iterator]=nd.prototype[Symbol.iterator]=function(){return this});class nu{constructor(e,t,i,n){this.from=e,this.to=t,this.number=i,this.text=n}get length(){return this.to-this.from}}function nf(e,t,i){return[t=Math.max(0,Math.min(e.length,t)),Math.max(t,Math.min(e.length,i))]}function np(e,t,i=!0,n=!0){return function(e,t,i=!0,n=!0){return(i?ne:function(e,t,i){for(;t>0;){let n=ne(e,t-2,i);if(n<t)return n;t--}return 0})(e,t,n)}(e,t,i,n)}function nm(e,t){let i=e.charCodeAt(t);if(!(i>=55296&&i<56320)||t+1==e.length)return i;let n=e.charCodeAt(t+1);return n>=56320&&n<57344?(i-55296<<10)+(n-56320)+65536:i}function ng(e){return e<65536?1:2}let nx=/\r\n?|\n/;var nv=function(e){return e[e.Simple=0]="Simple",e[e.TrackDel=1]="TrackDel",e[e.TrackBefore=2]="TrackBefore",e[e.TrackAfter=3]="TrackAfter",e}(nv||(nv={}));class ny{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;t<this.sections.length;t+=2)e+=this.sections[t];return e}get newLength(){let e=0;for(let t=0;t<this.sections.length;t+=2){let i=this.sections[t+1];e+=i<0?this.sections[t]:i}return e}get empty(){return 0==this.sections.length||2==this.sections.length&&this.sections[1]<0}iterGaps(e){for(let t=0,i=0,n=0;t<this.sections.length;){let r=this.sections[t++],s=this.sections[t++];s<0?(e(i,n,r),n+=r):n+=s,i+=r}}iterChangedRanges(e,t=!1){nS(this,e,t)}get invertedDesc(){let e=[];for(let t=0;t<this.sections.length;){let i=this.sections[t++],n=this.sections[t++];n<0?e.push(i,n):e.push(n,i)}return new ny(e)}composeDesc(e){return this.empty?e:e.empty?this:nj(this,e)}mapDesc(e,t=!1){return e.empty?this:nC(this,e,t)}mapPos(e,t=-1,i=nv.Simple){let n=0,r=0;for(let s=0;s<this.sections.length;){let o=this.sections[s++],l=this.sections[s++],a=n+o;if(l<0){if(a>e)return r+(e-n);r+=o}else{if(i!=nv.Simple&&a>=e&&(i==nv.TrackDel&&n<e&&a>e||i==nv.TrackBefore&&n<e||i==nv.TrackAfter&&a>e))return null;if(a>e||a==e&&t<0&&!o)return e==n||t<0?r:r+l;r+=l}n=a}if(e>n)throw RangeError(`Position ${e} is out of range for changeset of length ${n}`);return r}touchesRange(e,t=e){for(let i=0,n=0;i<this.sections.length&&n<=t;){let r=this.sections[i++],s=this.sections[i++],o=n+r;if(s>=0&&n<=t&&o>=e)return!(n<e)||!(o>t)||"cover";n=o}return!1}toString(){let e="";for(let t=0;t<this.sections.length;){let i=this.sections[t++],n=this.sections[t++];e+=(e?" ":"")+i+(n>=0?":"+n:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(e=>"number"!=typeof e))throw RangeError("Invalid JSON representation of ChangeDesc");return new ny(e)}static create(e){return new ny(e)}}class nb extends ny{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw RangeError("Applying change set to a document with the wrong length");return nS(this,(t,i,n,r,s)=>e=e.replace(n,n+(i-t),s),!1),e}mapDesc(e,t=!1){return nC(this,e,t,!0)}invert(e){let t=this.sections.slice(),i=[];for(let n=0,r=0;n<t.length;n+=2){let s=t[n],o=t[n+1];if(o>=0){t[n]=o,t[n+1]=s;let l=n>>1;for(;i.length<l;)i.push(ns.empty);i.push(s?e.slice(r,r+s):ns.empty)}r+=s}return new nb(t,i)}compose(e){return this.empty?e:e.empty?this:nj(this,e,!0)}map(e,t=!1){return e.empty?this:nC(this,e,t,!0)}iterChanges(e,t=!1){nS(this,e,t)}get desc(){return ny.create(this.sections)}filter(e){let t=[],i=[],n=[],r=new nM(this);e:for(let s=0,o=0;;){let l=s==e.length?1e9:e[s++];for(;o<l||o==l&&0==r.len;){if(r.done)break e;let e=Math.min(r.len,l-o);nw(n,e,-1);let s=-1==r.ins?-1:0==r.off?r.ins:0;nw(t,e,s),s>0&&nk(i,t,r.text),r.forward(e),o+=e}let a=e[s++];for(;o<a;){if(r.done)break e;let e=Math.min(r.len,a-o);nw(t,e,-1),nw(n,e,-1==r.ins?-1:0==r.off?r.ins:0),r.forward(e),o+=e}}return{changes:new nb(t,i),filtered:ny.create(n)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let i=this.sections[t],n=this.sections[t+1];n<0?e.push(i):0==n?e.push([i]):e.push([i].concat(this.inserted[t>>1].toJSON()))}return e}static of(e,t,i){let n=[],r=[],s=0,o=null;function l(e=!1){if(!e&&!n.length)return;s<t&&nw(n,t-s,-1);let i=new nb(n,r);o=o?o.compose(i.map(o)):i,n=[],r=[],s=0}return function e(a){if(Array.isArray(a))for(let t of a)e(t);else if(a instanceof nb){if(a.length!=t)throw RangeError(`Mismatched change set length (got ${a.length}, expected ${t})`);l(),o=o?o.compose(a.map(o)):a}else{let{from:e,to:o=e,insert:h}=a;if(e>o||e<0||o>t)throw RangeError(`Invalid change range ${e} to ${o} (in doc of length ${t})`);let c=h?"string"==typeof h?ns.of(h.split(i||nx)):h:ns.empty,d=c.length;if(e==o&&0==d)return;e<s&&l(),e>s&&nw(n,e-s,-1),nw(n,o-e,d),nk(r,n,c),s=o}}(e),l(!o),o}static empty(e){return new nb(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw RangeError("Invalid JSON representation of ChangeSet");let t=[],i=[];for(let n=0;n<e.length;n++){let r=e[n];if("number"==typeof r)t.push(r,-1);else if(!Array.isArray(r)||"number"!=typeof r[0]||r.some((e,t)=>t&&"string"!=typeof e))throw RangeError("Invalid JSON representation of ChangeSet");else if(1==r.length)t.push(r[0],0);else{for(;i.length<n;)i.push(ns.empty);i[n]=ns.of(r.slice(1)),t.push(r[0],i[n].length)}}return new nb(t,i)}static createSet(e,t){return new nb(e,t)}}function nw(e,t,i,n=!1){if(0==t&&i<=0)return;let r=e.length-2;r>=0&&i<=0&&i==e[r+1]?e[r]+=t:r>=0&&0==t&&0==e[r]?e[r+1]+=i:n?(e[r]+=t,e[r+1]+=i):e.push(t,i)}function nk(e,t,i){if(0==i.length)return;let n=t.length-2>>1;if(n<e.length)e[e.length-1]=e[e.length-1].append(i);else{for(;e.length<n;)e.push(ns.empty);e.push(i)}}function nS(e,t,i){let n=e.inserted;for(let r=0,s=0,o=0;o<e.sections.length;){let l=e.sections[o++],a=e.sections[o++];if(a<0)r+=l,s+=l;else{let h=r,c=s,d=ns.empty;for(;h+=l,c+=a,a&&n&&(d=d.append(n[o-2>>1])),!i&&o!=e.sections.length&&!(e.sections[o+1]<0);)l=e.sections[o++],a=e.sections[o++];t(r,h,s,c,d),r=h,s=c}}}function nC(e,t,i,n=!1){let r=[],s=n?[]:null,o=new nM(e),l=new nM(t);for(let e=-1;;){if(o.done&&l.len||l.done&&o.len)throw Error("Mismatched change set lengths");if(-1==o.ins&&-1==l.ins){let e=Math.min(o.len,l.len);nw(r,e,-1),o.forward(e),l.forward(e)}else if(l.ins>=0&&(o.ins<0||e==o.i||0==o.off&&(l.len<o.len||l.len==o.len&&!i))){let t=l.len;for(nw(r,l.ins,-1);t;){let i=Math.min(o.len,t);o.ins>=0&&e<o.i&&o.len<=i&&(nw(r,0,o.ins),s&&nk(s,r,o.text),e=o.i),o.forward(i),t-=i}l.next()}else if(o.ins>=0){let t=0,i=o.len;for(;i;)if(-1==l.ins){let e=Math.min(i,l.len);t+=e,i-=e,l.forward(e)}else if(0==l.ins&&l.len<i)i-=l.len,l.next();else break;nw(r,t,e<o.i?o.ins:0),s&&e<o.i&&nk(s,r,o.text),e=o.i,o.forward(o.len-i)}else if(o.done&&l.done)return s?nb.createSet(r,s):ny.create(r);else throw Error("Mismatched change set lengths")}}function nj(e,t,i=!1){let n=[],r=i?[]:null,s=new nM(e),o=new nM(t);for(let e=!1;;){if(s.done&&o.done)return r?nb.createSet(n,r):ny.create(n);if(0==s.ins)nw(n,s.len,0,e),s.next();else if(0!=o.len||o.done){if(s.done||o.done)throw Error("Mismatched change set lengths");{let t=Math.min(s.len2,o.len),i=n.length;if(-1==s.ins){let i=-1==o.ins?-1:o.off?0:o.ins;nw(n,t,i,e),r&&i&&nk(r,n,o.text)}else -1==o.ins?(nw(n,s.off?0:s.len,t,e),r&&nk(r,n,s.textBit(t))):(nw(n,s.off?0:s.len,o.off?0:o.ins,e),r&&!o.off&&nk(r,n,o.text));e=(s.ins>t||o.ins>=0&&o.len>t)&&(e||n.length>i),s.forward2(t),o.forward(t)}}else nw(n,0,o.ins,e),r&&nk(r,n,o.text),o.next()}}class nM{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return -2==this.ins}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,t=this.i-2>>1;return t>=e.length?ns.empty:e[t]}textBit(e){let{inserted:t}=this.set,i=this.i-2>>1;return i>=t.length&&!e?ns.empty:t[i].slice(this.off,null==e?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){-1==this.ins?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class nZ{constructor(e,t,i){this.from=e,this.to=t,this.flags=i}get anchor(){return 32&this.flags?this.to:this.from}get head(){return 32&this.flags?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return 8&this.flags?-1:16&this.flags?1:0}get bidiLevel(){let e=7&this.flags;return 7==e?null:e}get goalColumn(){let e=this.flags>>6;return 16777215==e?void 0:e}map(e,t=-1){let i,n;return this.empty?i=n=e.mapPos(this.from,t):(i=e.mapPos(this.from,1),n=e.mapPos(this.to,-1)),i==this.from&&n==this.to?this:new nZ(i,n,this.flags)}extend(e,t=e){if(e<=this.anchor&&t>=this.anchor)return nA.range(e,t);let i=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return nA.range(this.anchor,i)}eq(e,t=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!t||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||"number"!=typeof e.anchor||"number"!=typeof e.head)throw RangeError("Invalid JSON representation for SelectionRange");return nA.range(e.anchor,e.head)}static create(e,t,i){return new nZ(e,t,i)}}class nA{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:nA.create(this.ranges.map(i=>i.map(e,t)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let i=0;i<this.ranges.length;i++)if(!this.ranges[i].eq(e.ranges[i],t))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return 1==this.ranges.length?this:new nA([this.main],0)}addRange(e,t=!0){return nA.create([e].concat(this.ranges),t?0:this.mainIndex+1)}replaceRange(e,t=this.mainIndex){let i=this.ranges.slice();return i[t]=e,nA.create(i,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||"number"!=typeof e.main||e.main>=e.ranges.length)throw RangeError("Invalid JSON representation for EditorSelection");return new nA(e.ranges.map(e=>nZ.fromJSON(e)),e.main)}static single(e,t=e){return new nA([nA.range(e,t)],0)}static create(e,t=0){if(0==e.length)throw RangeError("A selection needs at least one range");for(let i=0,n=0;n<e.length;n++){let r=e[n];if(r.empty?r.from<=i:r.from<i)return nA.normalized(e.slice(),t);i=r.to}return new nA(e,t)}static cursor(e,t=0,i,n){return nZ.create(e,e,(0==t?0:t<0?8:16)|(null==i?7:Math.min(6,i))|(null!=n?n:16777215)<<6)}static range(e,t,i,n){let r=(null!=i?i:16777215)<<6|(null==n?7:Math.min(6,n));return t<e?nZ.create(t,e,48|r):nZ.create(e,t,(t>e?8:0)|r)}static normalized(e,t=0){let i=e[t];e.sort((e,t)=>e.from-t.from),t=e.indexOf(i);for(let i=1;i<e.length;i++){let n=e[i],r=e[i-1];if(n.empty?n.from<=r.to:n.from<r.to){let s=r.from,o=Math.max(n.to,r.to);i<=t&&t--,e.splice(--i,2,n.anchor>n.head?nA.range(o,s):nA.range(s,o))}}return new nA(e,t)}}function nT(e,t){for(let i of e.ranges)if(i.to>t)throw RangeError("Selection points outside of document")}let nO=0;class nD{constructor(e,t,i,n,r){this.combine=e,this.compareInput=t,this.compare=i,this.isStatic=n,this.id=nO++,this.default=e([]),this.extensions="function"==typeof r?r(this):r}get reader(){return this}static define(e={}){return new nD(e.combine||(e=>e),e.compareInput||((e,t)=>e===t),e.compare||(e.combine?(e,t)=>e===t:nR),!!e.static,e.enables)}of(e){return new nP([],this,0,e)}compute(e,t){if(this.isStatic)throw Error("Can't compute a static facet");return new nP(e,this,1,t)}computeN(e,t){if(this.isStatic)throw Error("Can't compute a static facet");return new nP(e,this,2,t)}from(e,t){return t||(t=e=>e),this.compute([e],i=>t(i.field(e)))}}function nR(e,t){return e==t||e.length==t.length&&e.every((e,i)=>e===t[i])}class nP{constructor(e,t,i,n){this.dependencies=e,this.facet=t,this.type=i,this.value=n,this.id=nO++}dynamicSlot(e){var t;let i=this.value,n=this.facet.compareInput,r=this.id,s=e[r]>>1,o=2==this.type,l=!1,a=!1,h=[];for(let i of this.dependencies)"doc"==i?l=!0:"selection"==i?a=!0:((null!==(t=e[i.id])&&void 0!==t?t:1)&1)==0&&h.push(e[i.id]);return{create:e=>(e.values[s]=i(e),1),update(e,t){if(l&&t.docChanged||a&&(t.docChanged||t.selection)||nI(e,h)){let t=i(e);if(o?!nL(t,e.values[s],n):!n(t,e.values[s]))return e.values[s]=t,1}return 0},reconfigure:(e,t)=>{let l,a=t.config.address[r];if(null!=a){let r=nK(t,a);if(this.dependencies.every(i=>i instanceof nD?t.facet(i)===e.facet(i):!(i instanceof nB)||t.field(i,!1)==e.field(i,!1))||(o?nL(l=i(e),r,n):n(l=i(e),r)))return e.values[s]=r,0}else l=i(e);return e.values[s]=l,1}}}}function nL(e,t,i){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!i(e[n],t[n]))return!1;return!0}function nI(e,t){let i=!1;for(let n of t)1&nq(e,n)&&(i=!0);return i}let nE=nD.define({static:!0});class nB{constructor(e,t,i,n,r){this.id=e,this.createF=t,this.updateF=i,this.compareF=n,this.spec=r,this.provides=void 0}static define(e){let t=new nB(nO++,e.create,e.update,e.compare||((e,t)=>e===t),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(nE).find(e=>e.field==this);return((null==t?void 0:t.create)||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:e=>(e.values[t]=this.create(e),1),update:(e,i)=>{let n=e.values[t],r=this.updateF(n,i);return this.compareF(n,r)?0:(e.values[t]=r,1)},reconfigure:(e,i)=>{let n=e.facet(nE),r=i.facet(nE),s;return(s=n.find(e=>e.field==this))&&s!=r.find(e=>e.field==this)?(e.values[t]=s.create(e),1):null!=i.config.address[this.id]?(e.values[t]=i.field(this),0):(e.values[t]=this.create(e),1)}}}init(e){return[this,nE.of({field:this,create:e})]}get extension(){return this}}let nN={lowest:4,low:3,default:2,high:1,highest:0};function nz(e){return t=>new nF(t,e)}let nW={highest:nz(nN.highest),high:nz(nN.high),default:nz(nN.default),low:nz(nN.low),lowest:nz(nN.lowest)};class nF{constructor(e,t){this.inner=e,this.prec=t}}class nV{of(e){return new nH(this,e)}reconfigure(e){return nV.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class nH{constructor(e,t){this.compartment=e,this.inner=t}}class n${constructor(e,t,i,n,r,s){for(this.base=e,this.compartments=t,this.dynamicSlots=i,this.address=n,this.staticValues=r,this.facets=s,this.statusTemplate=[];this.statusTemplate.length<i.length;)this.statusTemplate.push(0)}staticFacet(e){let t=this.address[e.id];return null==t?e.default:this.staticValues[t>>1]}static resolve(e,t,i){let n,r,s=[],o=Object.create(null),l=new Map;for(let i of(n=[[],[],[],[],[]],r=new Map,function e(i,s){let o=r.get(i);if(null!=o){if(o<=s)return;let e=n[o].indexOf(i);e>-1&&n[o].splice(e,1),i instanceof nH&&l.delete(i.compartment)}if(r.set(i,s),Array.isArray(i))for(let t of i)e(t,s);else if(i instanceof nH){if(l.has(i.compartment))throw RangeError("Duplicate use of compartment in extensions");let n=t.get(i.compartment)||i.inner;l.set(i.compartment,n),e(n,s)}else if(i instanceof nF)e(i.inner,i.prec);else if(i instanceof nB)n[s].push(i),i.provides&&e(i.provides,s);else if(i instanceof nP)n[s].push(i),i.facet.extensions&&e(i.facet.extensions,nN.default);else{let t=i.extension;if(!t)throw Error(`Unrecognized extension value in extension set (${i}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);e(t,s)}}(e,nN.default),n.reduce((e,t)=>e.concat(t))))i instanceof nB?s.push(i):(o[i.facet.id]||(o[i.facet.id]=[])).push(i);let a=Object.create(null),h=[],c=[];for(let e of s)a[e.id]=c.length<<1,c.push(t=>e.slot(t));let d=null==i?void 0:i.config.facets;for(let e in o){let t=o[e],n=t[0].facet,r=d&&d[e]||[];if(t.every(e=>0==e.type)){if(a[n.id]=h.length<<1|1,nR(r,t))h.push(i.facet(n));else{let e=n.combine(t.map(e=>e.value));h.push(i&&n.compare(e,i.facet(n))?i.facet(n):e)}}else{for(let e of t)0==e.type?(a[e.id]=h.length<<1|1,h.push(e.value)):(a[e.id]=c.length<<1,c.push(t=>e.dynamicSlot(t)));a[n.id]=c.length<<1,c.push(e=>(function(e,t,i){let n=i.map(t=>e[t.id]),r=i.map(e=>e.type),s=n.filter(e=>!(1&e)),o=e[t.id]>>1;function l(e){let i=[];for(let t=0;t<n.length;t++){let s=nK(e,n[t]);if(2==r[t])for(let e of s)i.push(e);else i.push(s)}return t.combine(i)}return{create(e){for(let t of n)nq(e,t);return e.values[o]=l(e),1},update(e,i){if(!nI(e,s))return 0;let n=l(e);return t.compare(n,e.values[o])?0:(e.values[o]=n,1)},reconfigure(e,r){let s=nI(e,n),a=r.config.facets[t.id],h=r.facet(t);if(a&&!s&&nR(i,a))return e.values[o]=h,0;let c=l(e);return t.compare(c,h)?(e.values[o]=h,0):(e.values[o]=c,1)}}})(e,n,t))}}return new n$(e,l,c.map(e=>e(a)),a,h,o)}}function nq(e,t){if(1&t)return 2;let i=t>>1,n=e.status[i];if(4==n)throw Error("Cyclic dependency between fields and/or facets");if(2&n)return n;e.status[i]=4;let r=e.computeSlot(e,e.config.dynamicSlots[i]);return e.status[i]=2|r}function nK(e,t){return 1&t?e.config.staticValues[t>>1]:e.values[t>>1]}let nU=nD.define(),n_=nD.define({combine:e=>e.some(e=>e),static:!0}),nG=nD.define({combine:e=>e.length?e[0]:void 0,static:!0}),nJ=nD.define(),nX=nD.define(),nY=nD.define(),nQ=nD.define({combine:e=>!!e.length&&e[0]});class n0{constructor(e,t){this.type=e,this.value=t}static define(){return new n1}}class n1{of(e){return new n0(this,e)}}class n2{constructor(e){this.map=e}of(e){return new n5(this,e)}}class n5{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return void 0===t?void 0:t==this.value?this:new n5(this.type,t)}is(e){return this.type==e}static define(e={}){return new n2(e.map||(e=>e))}static mapEffects(e,t){if(!e.length)return e;let i=[];for(let n of e){let e=n.map(t);e&&i.push(e)}return i}}n5.reconfigure=n5.define(),n5.appendConfig=n5.define();class n6{constructor(e,t,i,n,r,s){this.startState=e,this.changes=t,this.selection=i,this.effects=n,this.annotations=r,this.scrollIntoView=s,this._doc=null,this._state=null,i&&nT(i,t.newLength),r.some(e=>e.type==n6.time)||(this.annotations=r.concat(n6.time.of(Date.now())))}static create(e,t,i,n,r,s){return new n6(e,t,i,n,r,s)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let t=this.annotation(n6.userEvent);return!!(t&&(t==e||t.length>e.length&&t.slice(0,e.length)==e&&"."==t[e.length]))}}function n4(e,t,i){var n;let r,s,o;return i?(r=t.changes,s=nb.empty(t.changes.length),o=e.changes.compose(t.changes)):(r=t.changes.map(e.changes),s=e.changes.mapDesc(t.changes,!0),o=e.changes.compose(r)),{changes:o,selection:t.selection?t.selection.map(s):null===(n=e.selection)||void 0===n?void 0:n.map(r),effects:n5.mapEffects(e.effects,r).concat(n5.mapEffects(t.effects,s)),annotations:e.annotations.length?e.annotations.concat(t.annotations):t.annotations,scrollIntoView:e.scrollIntoView||t.scrollIntoView}}function n3(e,t,i){let n=t.selection,r=n9(t.annotations);return t.userEvent&&(r=r.concat(n6.userEvent.of(t.userEvent))),{changes:t.changes instanceof nb?t.changes:nb.of(t.changes||[],i,e.facet(nG)),selection:n&&(n instanceof nA?n:nA.single(n.anchor,n.head)),effects:n9(t.effects),annotations:r,scrollIntoView:!!t.scrollIntoView}}n6.time=n0.define(),n6.userEvent=n0.define(),n6.addToHistory=n0.define(),n6.remote=n0.define();let n8=[];function n9(e){return null==e?n8:Array.isArray(e)?e:[e]}var n7=function(e){return e[e.Word=0]="Word",e[e.Space=1]="Space",e[e.Other=2]="Other",e}(n7||(n7={}));let re=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;try{n=RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch(e){}class rt{constructor(e,t,i,n,r,s){this.config=e,this.doc=t,this.selection=i,this.values=n,this.status=e.statusTemplate.slice(),this.computeSlot=r,s&&(s._state=this);for(let e=0;e<this.config.dynamicSlots.length;e++)nq(this,e<<1);this.computeSlot=null}field(e,t=!0){let i=this.config.address[e.id];if(null==i){if(t)throw RangeError("Field is not present in this state");return}return nq(this,i),nK(this,i)}update(...e){return function e(t,i,n){let r=n3(t,i.length?i[0]:{},t.doc.length);i.length&&!1===i[0].filter&&(n=!1);for(let e=1;e<i.length;e++){!1===i[e].filter&&(n=!1);let s=!!i[e].sequential;r=n4(r,n3(t,i[e],s?r.changes.newLength:t.doc.length),s)}let s=n6.create(t,r.changes,r.selection,r.effects,r.annotations,r.scrollIntoView);return function(e){let t=e.startState,i=t.facet(nY),n=e;for(let r=i.length-1;r>=0;r--){let s=i[r](e);s&&Object.keys(s).length&&(n=n4(n,n3(t,s,e.changes.newLength),!0))}return n==e?e:n6.create(t,e.changes,e.selection,n.effects,n.annotations,n.scrollIntoView)}(n?function(t){let i=t.startState,n=!0;for(let e of i.facet(nJ)){let i=e(t);if(!1===i){n=!1;break}Array.isArray(i)&&(n=!0===n?i:function(e,t){let i=[];for(let n=0,r=0;;){let s,o;if(n<e.length&&(r==t.length||t[r]>=e[n]))s=e[n++],o=e[n++];else{if(!(r<t.length))return i;s=t[r++],o=t[r++]}!i.length||i[i.length-1]<s?i.push(s,o):i[i.length-1]<o&&(i[i.length-1]=o)}}(n,i))}if(!0!==n){let e,r;if(!1===n)r=t.changes.invertedDesc,e=nb.empty(i.doc.length);else{let i=t.changes.filter(n);e=i.changes,r=i.filtered.mapDesc(i.changes).invertedDesc}t=n6.create(i,e,t.selection&&t.selection.map(r),n5.mapEffects(t.effects,r),t.annotations,t.scrollIntoView)}let r=i.facet(nX);for(let n=r.length-1;n>=0;n--){let s=r[n](t);t=s instanceof n6?s:Array.isArray(s)&&1==s.length&&s[0]instanceof n6?s[0]:e(i,n9(s),!1)}return t}(s):s)}(this,e,!0)}applyTransaction(e){let t,i=this.config,{base:n,compartments:r}=i;for(let t of e.effects)t.is(nV.reconfigure)?(i&&(r=new Map,i.compartments.forEach((e,t)=>r.set(t,e)),i=null),r.set(t.value.compartment,t.value.extension)):t.is(n5.reconfigure)?(i=null,n=t.value):t.is(n5.appendConfig)&&(i=null,n=n9(n).concat(t.value));t=i?e.startState.values.slice():new rt(i=n$.resolve(n,r,this),this.doc,this.selection,i.dynamicSlots.map(()=>null),(e,t)=>t.reconfigure(e,this),null).values;let s=e.startState.facet(n_)?e.newSelection:e.newSelection.asSingle();new rt(i,e.newDoc,s,t,(t,i)=>i.update(t,e),e)}replaceSelection(e){return"string"==typeof e&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:nA.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,i=e(t.ranges[0]),n=this.changes(i.changes),r=[i.range],s=n9(i.effects);for(let i=1;i<t.ranges.length;i++){let o=e(t.ranges[i]),l=this.changes(o.changes),a=l.map(n);for(let e=0;e<i;e++)r[e]=r[e].map(a);let h=n.mapDesc(l,!0);r.push(o.range.map(h)),n=n.compose(a),s=n5.mapEffects(s,a).concat(n5.mapEffects(n9(o.effects),h))}return{changes:n,selection:nA.create(r,t.mainIndex),effects:s}}changes(e=[]){return e instanceof nb?e:nb.of(e,this.doc.length,this.facet(rt.lineSeparator))}toText(e){return ns.of(e.split(this.facet(rt.lineSeparator)||nx))}sliceDoc(e=0,t=this.doc.length){return this.doc.sliceString(e,t,this.lineBreak)}facet(e){let t=this.config.address[e.id];return null==t?e.default:(nq(this,t),nK(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let i in e){let n=e[i];n instanceof nB&&null!=this.config.address[n.id]&&(t[i]=n.spec.toJSON(this.field(e[i]),this))}return t}static fromJSON(e,t={},i){if(!e||"string"!=typeof e.doc)throw RangeError("Invalid JSON representation for EditorState");let n=[];if(i){for(let t in i)if(Object.prototype.hasOwnProperty.call(e,t)){let r=i[t],s=e[t];n.push(r.init(e=>r.spec.fromJSON(s,e)))}}return rt.create({doc:e.doc,selection:nA.fromJSON(e.selection),extensions:t.extensions?n.concat([t.extensions]):n})}static create(e={}){let t=n$.resolve(e.extensions||[],new Map),i=e.doc instanceof ns?e.doc:ns.of((e.doc||"").split(t.staticFacet(rt.lineSeparator)||nx)),n=e.selection?e.selection instanceof nA?e.selection:nA.single(e.selection.anchor,e.selection.head):nA.single(0);return nT(n,i.length),t.staticFacet(n_)||(n=n.asSingle()),new rt(t,i,n,t.dynamicSlots.map(()=>null),(e,t)=>t.create(e),null)}get tabSize(){return this.facet(rt.tabSize)}get lineBreak(){return this.facet(rt.lineSeparator)||"\n"}get readOnly(){return this.facet(nQ)}phrase(e,...t){for(let t of this.facet(rt.phrases))if(Object.prototype.hasOwnProperty.call(t,e)){e=t[e];break}return t.length&&(e=e.replace(/\$(\$|\d*)/g,(e,i)=>{if("$"==i)return"$";let n=+(i||1);return!n||n>t.length?e:t[n-1]})),e}languageDataAt(e,t,i=-1){let n=[];for(let r of this.facet(nU))for(let s of r(this,t,i))Object.prototype.hasOwnProperty.call(s,e)&&n.push(s[e]);return n}charCategorizer(e){var t;let i=this.languageDataAt("wordChars",e);return t=i.length?i[0]:"",e=>{if(!/\S/.test(e))return n7.Space;if(function(e){if(n)return n.test(e);for(let t=0;t<e.length;t++){let i=e[t];if(/\w/.test(i)||i>"\x80"&&(i.toUpperCase()!=i.toLowerCase()||re.test(i)))return!0}return!1}(e))return n7.Word;for(let i=0;i<t.length;i++)if(e.indexOf(t[i])>-1)return n7.Word;return n7.Other}}wordAt(e){let{text:t,from:i,length:n}=this.doc.lineAt(e),r=this.charCategorizer(e),s=e-i,o=e-i;for(;s>0;){let e=np(t,s,!1);if(r(t.slice(e,s))!=n7.Word)break;s=e}for(;o<n;){let e=np(t,o);if(r(t.slice(o,e))!=n7.Word)break;o=e}return s==o?null:nA.range(s+i,o+i)}}function ri(e,t,i={}){let n={};for(let t of e)for(let e of Object.keys(t)){let r=t[e],s=n[e];if(void 0===s)n[e]=r;else if(s===r||void 0===r);else if(Object.hasOwnProperty.call(i,e))n[e]=i[e](s,r);else throw Error("Config merge conflict for field "+e)}for(let e in t)void 0===n[e]&&(n[e]=t[e]);return n}rt.allowMultipleSelections=n_,rt.tabSize=nD.define({combine:e=>e.length?e[0]:4}),rt.lineSeparator=nG,rt.readOnly=nQ,rt.phrases=nD.define({compare(e,t){let i=Object.keys(e),n=Object.keys(t);return i.length==n.length&&i.every(i=>e[i]==t[i])}}),rt.languageData=nU,rt.changeFilter=nJ,rt.transactionFilter=nX,rt.transactionExtender=nY,nV.reconfigure=n5.define();class rn{eq(e){return this==e}range(e,t=e){return rs.create(e,t,this)}}function rr(e,t){return e==t||e.constructor==t.constructor&&e.eq(t)}rn.prototype.startSide=rn.prototype.endSide=0,rn.prototype.point=!1,rn.prototype.mapMode=nv.TrackDel;class rs{constructor(e,t,i){this.from=e,this.to=t,this.value=i}static create(e,t,i){return new rs(e,t,i)}}function ro(e,t){return e.from-t.from||e.value.startSide-t.value.startSide}class rl{constructor(e,t,i,n){this.from=e,this.to=t,this.value=i,this.maxPoint=n}get length(){return this.to[this.to.length-1]}findIndex(e,t,i,n=0){let r=i?this.to:this.from;for(let s=n,o=r.length;;){if(s==o)return s;let n=s+o>>1,l=r[n]-e||(i?this.value[n].endSide:this.value[n].startSide)-t;if(n==s)return l>=0?s:o;l>=0?o=n:s=n+1}}between(e,t,i,n){for(let r=this.findIndex(t,-1e9,!0),s=this.findIndex(i,1e9,!1,r);r<s;r++)if(!1===n(this.from[r]+e,this.to[r]+e,this.value[r]))return!1}map(e,t){let i=[],n=[],r=[],s=-1,o=-1;for(let l=0;l<this.value.length;l++){let a=this.value[l],h=this.from[l]+e,c=this.to[l]+e,d,u;if(h==c){let e=t.mapPos(h,a.startSide,a.mapMode);if(null==e||(d=u=e,a.startSide!=a.endSide&&(u=t.mapPos(h,a.endSide))<d))continue}else if((d=t.mapPos(h,a.startSide))>(u=t.mapPos(c,a.endSide))||d==u&&a.startSide>0&&a.endSide<=0)continue;0>(u-d||a.endSide-a.startSide)||(s<0&&(s=d),a.point&&(o=Math.max(o,u-d)),i.push(a),n.push(d-s),r.push(u-s))}return{mapped:i.length?new rl(n,r,i,o):null,pos:s}}}class ra{constructor(e,t,i,n){this.chunkPos=e,this.chunk=t,this.nextLayer=i,this.maxPoint=n}static create(e,t,i,n){return new ra(e,t,i,n)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let t of this.chunk)e+=t.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:t=[],sort:i=!1,filterFrom:n=0,filterTo:r=this.length}=e,s=e.filter;if(0==t.length&&!s)return this;if(i&&(t=t.slice().sort(ro)),this.isEmpty)return t.length?ra.of(t):this;let o=new rd(this,null,-1).goto(0),l=0,a=[],h=new rh;for(;o.value||l<t.length;)if(l<t.length&&(o.from-t[l].from||o.startSide-t[l].value.startSide)>=0){let e=t[l++];h.addInner(e.from,e.to,e.value)||a.push(e)}else 1==o.rangeIndex&&o.chunkIndex<this.chunk.length&&(l==t.length||this.chunkEnd(o.chunkIndex)<t[l].from)&&(!s||n>this.chunkEnd(o.chunkIndex)||r<this.chunkPos[o.chunkIndex])&&h.addChunk(this.chunkPos[o.chunkIndex],this.chunk[o.chunkIndex])?o.nextChunk():((!s||n>o.to||r<o.from||s(o.from,o.to,o.value))&&!h.addInner(o.from,o.to,o.value)&&a.push(rs.create(o.from,o.to,o.value)),o.next());return h.finishInner(this.nextLayer.isEmpty&&!a.length?ra.empty:this.nextLayer.update({add:a,filter:s,filterFrom:n,filterTo:r}))}map(e){if(e.empty||this.isEmpty)return this;let t=[],i=[],n=-1;for(let r=0;r<this.chunk.length;r++){let s=this.chunkPos[r],o=this.chunk[r],l=e.touchesRange(s,s+o.length);if(!1===l)n=Math.max(n,o.maxPoint),t.push(o),i.push(e.mapPos(s));else if(!0===l){let{mapped:r,pos:l}=o.map(s,e);r&&(n=Math.max(n,r.maxPoint),t.push(r),i.push(l))}}let r=this.nextLayer.map(e);return 0==t.length?r:new ra(i,t,r||ra.empty,n)}between(e,t,i){if(!this.isEmpty){for(let n=0;n<this.chunk.length;n++){let r=this.chunkPos[n],s=this.chunk[n];if(t>=r&&e<=r+s.length&&!1===s.between(r,e-r,t-r,i))return}this.nextLayer.between(e,t,i)}}iter(e=0){return ru.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return ru.from(e).goto(t)}static compare(e,t,i,n,r=-1){let s=e.filter(e=>e.maxPoint>0||!e.isEmpty&&e.maxPoint>=r),o=t.filter(e=>e.maxPoint>0||!e.isEmpty&&e.maxPoint>=r),l=rc(s,o,i),a=new rp(s,l,r),h=new rp(o,l,r);i.iterGaps((e,t,i)=>rm(a,e,h,t,i,n)),i.empty&&0==i.length&&rm(a,0,h,0,0,n)}static eq(e,t,i=0,n){null==n&&(n=999999999);let r=e.filter(e=>!e.isEmpty&&0>t.indexOf(e)),s=t.filter(t=>!t.isEmpty&&0>e.indexOf(t));if(r.length!=s.length)return!1;if(!r.length)return!0;let o=rc(r,s),l=new rp(r,o,0).goto(i),a=new rp(s,o,0).goto(i);for(;;){if(l.to!=a.to||!rg(l.active,a.active)||l.point&&(!a.point||!rr(l.point,a.point)))return!1;if(l.to>n)return!0;l.next(),a.next()}}static spans(e,t,i,n,r=-1){let s=new rp(e,null,r).goto(t),o=t,l=s.openStart;for(;;){let e=Math.min(s.to,i);if(s.point){let i=s.activeForPoint(s.to),r=s.pointFrom<t?i.length+1:s.point.startSide<0?i.length:Math.min(i.length,l);n.point(o,e,s.point,i,r,s.pointRank),l=Math.min(s.openEnd(e),i.length)}else e>o&&(n.span(o,e,s.active,l),l=s.openEnd(e));if(s.to>i)return l+(s.point&&s.to>i?1:0);o=s.to,s.next()}}static of(e,t=!1){let i=new rh;for(let n of e instanceof rs?[e]:t?function(e){if(e.length>1)for(let t=e[0],i=1;i<e.length;i++){let n=e[i];if(ro(t,n)>0)return e.slice().sort(ro);t=n}return e}(e):e)i.add(n.from,n.to,n.value);return i.finish()}static join(e){if(!e.length)return ra.empty;let t=e[e.length-1];for(let i=e.length-2;i>=0;i--)for(let n=e[i];n!=ra.empty;n=n.nextLayer)t=new ra(n.chunkPos,n.chunk,t,Math.max(n.maxPoint,t.maxPoint));return t}}ra.empty=new ra([],[],null,-1),ra.empty.nextLayer=ra.empty;class rh{finishChunk(e){this.chunks.push(new rl(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(e,t,i){this.addInner(e,t,i)||(this.nextLayer||(this.nextLayer=new rh)).add(e,t,i)}addInner(e,t,i){let n=e-this.lastTo||i.startSide-this.last.endSide;if(n<=0&&0>(e-this.lastFrom||i.startSide-this.last.startSide))throw Error("Ranges must be added sorted by `from` position and `startSide`");return!(n<0)&&(250==this.from.length&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(t-this.chunkStart),this.last=i,this.lastFrom=e,this.lastTo=t,this.value.push(i),i.point&&(this.maxPoint=Math.max(this.maxPoint,t-e)),!0)}addChunk(e,t){if(0>(e-this.lastTo||t.value[0].startSide-this.last.endSide))return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,t.maxPoint),this.chunks.push(t),this.chunkPos.push(e);let i=t.value.length-1;return this.last=t.value[i],this.lastFrom=t.from[i]+e,this.lastTo=t.to[i]+e,!0}finish(){return this.finishInner(ra.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),0==this.chunks.length)return e;let t=ra.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}}function rc(e,t,i){let n=new Map;for(let t of e)for(let e=0;e<t.chunk.length;e++)t.chunk[e].maxPoint<=0&&n.set(t.chunk[e],t.chunkPos[e]);let r=new Set;for(let e of t)for(let t=0;t<e.chunk.length;t++){let s=n.get(e.chunk[t]);null==s||(i?i.mapPos(s):s)!=e.chunkPos[t]||(null==i?void 0:i.touchesRange(s,s+e.chunk[t].length))||r.add(e.chunk[t])}return r}class rd{constructor(e,t,i,n=0){this.layer=e,this.skip=t,this.minPoint=i,this.rank=n}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(e,t=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(e,t,!1),this}gotoInner(e,t,i){for(;this.chunkIndex<this.layer.chunk.length;){let t=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(t)||this.layer.chunkEnd(this.chunkIndex)<e||t.maxPoint<this.minPoint))break;this.chunkIndex++,i=!1}if(this.chunkIndex<this.layer.chunk.length){let n=this.layer.chunk[this.chunkIndex].findIndex(e-this.layer.chunkPos[this.chunkIndex],t,!0);(!i||this.rangeIndex<n)&&this.setRangeIndex(n)}this.next()}forward(e,t){0>(this.to-e||this.endSide-t)&&this.gotoInner(e,t,!0)}next(){for(;;){if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}{let e=this.layer.chunkPos[this.chunkIndex],t=this.layer.chunk[this.chunkIndex],i=e+t.from[this.rangeIndex];if(this.from=i,this.to=e+t.to[this.rangeIndex],this.value=t.value[this.rangeIndex],this.setRangeIndex(this.rangeIndex+1),this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]);)this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=e}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(e){return this.from-e.from||this.startSide-e.startSide||this.rank-e.rank||this.to-e.to||this.endSide-e.endSide}}class ru{constructor(e){this.heap=e}static from(e,t=null,i=-1){let n=[];for(let r=0;r<e.length;r++)for(let s=e[r];!s.isEmpty;s=s.nextLayer)s.maxPoint>=i&&n.push(new rd(s,t,i,r));return 1==n.length?n[0]:new ru(n)}get startSide(){return this.value?this.value.startSide:0}goto(e,t=-1e9){for(let i of this.heap)i.goto(e,t);for(let e=this.heap.length>>1;e>=0;e--)rf(this.heap,e);return this.next(),this}forward(e,t){for(let i of this.heap)i.forward(e,t);for(let e=this.heap.length>>1;e>=0;e--)rf(this.heap,e);0>(this.to-e||this.value.endSide-t)&&this.next()}next(){if(0==this.heap.length)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),rf(this.heap,0)}}}function rf(e,t){for(let i=e[t];;){let n=(t<<1)+1;if(n>=e.length)break;let r=e[n];if(n+1<e.length&&r.compare(e[n+1])>=0&&(r=e[n+1],n++),0>i.compare(r))break;e[n]=i,e[t]=r,t=n}}class rp{constructor(e,t,i){this.minPoint=i,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=ru.from(e,t,i)}goto(e,t=-1e9){return this.cursor.goto(e,t),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=t,this.openStart=-1,this.next(),this}forward(e,t){for(;this.minActive>-1&&0>(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-t);)this.removeActive(this.minActive);this.cursor.forward(e,t)}removeActive(e){rx(this.active,e),rx(this.activeTo,e),rx(this.activeRank,e),this.minActive=ry(this.active,this.activeTo)}addActive(e){let t=0,{value:i,to:n,rank:r}=this.cursor;for(;t<this.activeRank.length&&(r-this.activeRank[t]||n-this.activeTo[t])>0;)t++;rv(this.active,t,i),rv(this.activeTo,t,n),rv(this.activeRank,t,r),e&&rv(e,t,this.cursor.from),this.minActive=ry(this.active,this.activeTo)}next(){let e=this.to,t=this.point;this.point=null;let i=this.openStart<0?[]:null;for(;;){let n=this.minActive;if(n>-1&&0>(this.activeTo[n]-this.cursor.from||this.active[n].endSide-this.cursor.startSide)){if(this.activeTo[n]>e){this.to=this.activeTo[n],this.endSide=this.active[n].endSide;break}this.removeActive(n),i&&rx(i,n)}else if(this.cursor.value){if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}{let e=this.cursor.value;if(e.point){if(t&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)this.cursor.next();else{this.point=e,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=e.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}}else this.addActive(i),this.cursor.next()}}else{this.to=this.endSide=1e9;break}}if(i){this.openStart=0;for(let t=i.length-1;t>=0&&i[t]<e;t--)this.openStart++}}activeForPoint(e){if(!this.active.length)return this.active;let t=[];for(let i=this.active.length-1;i>=0&&!(this.activeRank[i]<this.pointRank);i--)(this.activeTo[i]>e||this.activeTo[i]==e&&this.active[i].endSide>=this.point.endSide)&&t.push(this.active[i]);return t.reverse()}openEnd(e){let t=0;for(let i=this.activeTo.length-1;i>=0&&this.activeTo[i]>e;i--)t++;return t}}function rm(e,t,i,n,r,s){e.goto(t),i.goto(n);let o=n+r,l=n,a=n-t,h=!!s.boundChange;for(let t=!1;;){let n=e.to+a-i.to,r=n||e.endSide-i.endSide,c=r<0?e.to+a:i.to,d=Math.min(c,o);if(e.point||i.point?(e.point&&i.point&&rr(e.point,i.point)&&rg(e.activeForPoint(e.to),i.activeForPoint(i.to))||s.comparePoint(l,d,e.point,i.point),t=!1):(t&&s.boundChange(l),d>l&&!rg(e.active,i.active)&&s.compareRange(l,d,e.active,i.active),h&&d<o&&(n||e.openEnd(c)!=i.openEnd(c))&&(t=!0)),c>o)break;l=c,r<=0&&e.next(),r>=0&&i.next()}}function rg(e,t){if(e.length!=t.length)return!1;for(let i=0;i<e.length;i++)if(e[i]!=t[i]&&!rr(e[i],t[i]))return!1;return!0}function rx(e,t){for(let i=t,n=e.length-1;i<n;i++)e[i]=e[i+1];e.pop()}function rv(e,t,i){for(let i=e.length-1;i>=t;i--)e[i+1]=e[i];e[t]=i}function ry(e,t){let i=-1,n=1e9;for(let r=0;r<t.length;r++)0>(t[r]-n||e[r].endSide-e[i].endSide)&&(i=r,n=t[r]);return i}function rb(e,t,i=e.length){let n=0;for(let r=0;r<i&&r<e.length;)9==e.charCodeAt(r)?(n+=t-n%t,r++):(n++,r=np(e,r));return n}function rw(e,t,i,n){for(let n=0,r=0;;){if(r>=t)return n;if(n==e.length)break;r+=9==e.charCodeAt(n)?i-r%i:1,n=np(e,n)}return!0===n?-1:e.length}let rk="undefined"==typeof Symbol?"__ͼ":Symbol.for("ͼ"),rS="undefined"==typeof Symbol?"__styleSet"+Math.floor(1e8*Math.random()):Symbol("styleSet"),rC="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:{};class rj{constructor(e,t){this.rules=[];let{finish:i}=t||{};function n(e){return/^@/.test(e)?[e]:e.split(/,\s*/)}for(let t in e)!function e(t,r,s,o){let l=[],a=/^@(\w+)\b/.exec(t[0]),h=a&&"keyframes"==a[1];if(a&&null==r)return s.push(t[0]+";");for(let i in r){let o=r[i];if(/&/.test(i))e(i.split(/,\s*/).map(e=>t.map(t=>e.replace(/&/,t))).reduce((e,t)=>e.concat(t)),o,s);else if(o&&"object"==typeof o){if(!a)throw RangeError("The value of a property ("+i+") should be a primitive value.");e(n(i),o,l,h)}else null!=o&&l.push(i.replace(/_.*/,"").replace(/[A-Z]/g,e=>"-"+e.toLowerCase())+": "+o+";")}(l.length||h)&&s.push((!i||a||o?t:t.map(i)).join(", ")+" {"+l.join(" ")+"}")}(n(t),e[t],this.rules)}getRules(){return this.rules.join("\n")}static newName(){let e=rC[rk]||1;return rC[rk]=e+1,"ͼ"+e.toString(36)}static mount(e,t,i){let n=e[rS],r=i&&i.nonce;n?r&&n.setNonce(r):n=new rZ(e,r),n.mount(Array.isArray(t)?t:[t],e)}}let rM=new Map;class rZ{constructor(e,t){let i=e.ownerDocument||e,n=i.defaultView;if(!e.head&&e.adoptedStyleSheets&&n.CSSStyleSheet){let t=rM.get(i);if(t)return e[rS]=t;this.sheet=new n.CSSStyleSheet,rM.set(i,this)}else this.styleTag=i.createElement("style"),t&&this.styleTag.setAttribute("nonce",t);this.modules=[],e[rS]=this}mount(e,t){let i=this.sheet,n=0,r=0;for(let t=0;t<e.length;t++){let s=e[t],o=this.modules.indexOf(s);if(o<r&&o>-1&&(this.modules.splice(o,1),r--,o=-1),-1==o){if(this.modules.splice(r++,0,s),i)for(let e=0;e<s.rules.length;e++)i.insertRule(s.rules[e],n++)}else{for(;r<o;)n+=this.modules[r++].rules.length;n+=s.rules.length,r++}}if(i)0>t.adoptedStyleSheets.indexOf(this.sheet)&&(t.adoptedStyleSheets=[this.sheet,...t.adoptedStyleSheets]);else{let e="";for(let t=0;t<this.modules.length;t++)e+=this.modules[t].getRules()+"\n";this.styleTag.textContent=e;let i=t.head||t;this.styleTag.parentNode!=i&&i.insertBefore(this.styleTag,i.firstChild)}}setNonce(e){this.styleTag&&this.styleTag.getAttribute("nonce")!=e&&this.styleTag.setAttribute("nonce",e)}}for(var rA={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:"'"},rT={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},rO="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),rD="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),rR=0;rR<10;rR++)rA[48+rR]=rA[96+rR]=String(rR);for(var rR=1;rR<=24;rR++)rA[rR+111]="F"+rR;for(var rR=65;rR<=90;rR++)rA[rR]=String.fromCharCode(rR+32),rT[rR]=String.fromCharCode(rR);for(var rP in rA)rT.hasOwnProperty(rP)||(rT[rP]=rA[rP]);function rL(){var e=arguments[0];"string"==typeof e&&(e=document.createElement(e));var t=1,i=arguments[1];if(i&&"object"==typeof i&&null==i.nodeType&&!Array.isArray(i)){for(var n in i)if(Object.prototype.hasOwnProperty.call(i,n)){var r=i[n];"string"==typeof r?e.setAttribute(n,r):null!=r&&(e[n]=r)}t++}for(;t<arguments.length;t++)(function e(t,i){if("string"==typeof i)t.appendChild(document.createTextNode(i));else if(null==i);else if(null!=i.nodeType)t.appendChild(i);else if(Array.isArray(i))for(var n=0;n<i.length;n++)e(t,i[n]);else throw RangeError("Unsupported child node: "+i)})(e,arguments[t]);return e}let rI="undefined"!=typeof navigator?navigator:{userAgent:"",vendor:"",platform:""},rE="undefined"!=typeof document?document:{documentElement:{style:{}}},rB=/Edge\/(\d+)/.exec(rI.userAgent),rN=/MSIE \d/.test(rI.userAgent),rz=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(rI.userAgent),rW=!!(rN||rz||rB),rF=!rW&&/gecko\/(\d+)/i.test(rI.userAgent),rV=!rW&&/Chrome\/(\d+)/.exec(rI.userAgent),rH="webkitFontSmoothing"in rE.documentElement.style,r$=!rW&&/Apple Computer/.test(rI.vendor),rq=r$&&(/Mobile\/\w+/.test(rI.userAgent)||rI.maxTouchPoints>2);var rK={mac:rq||/Mac/.test(rI.platform),windows:/Win/.test(rI.platform),linux:/Linux|X11/.test(rI.platform),ie:rW,ie_version:rN?rE.documentMode||6:rz?+rz[1]:rB?+rB[1]:0,gecko:rF,gecko_version:rF?+(/Firefox\/(\d+)/.exec(rI.userAgent)||[0,0])[1]:0,chrome:!!rV,chrome_version:rV?+rV[1]:0,ios:rq,android:/Android\b/.test(rI.userAgent),webkit:rH,webkit_version:rH?+(/\bAppleWebKit\/(\d+)/.exec(rI.userAgent)||[0,0])[1]:0,safari:r$,safari_version:r$?+(/\bVersion\/(\d+(\.\d+)?)/.exec(rI.userAgent)||[0,0])[1]:0,tabSize:null!=rE.documentElement.style.tabSize?"tab-size":"-moz-tab-size"};function rU(e,t){for(let i in e)"class"==i&&t.class?t.class+=" "+e.class:"style"==i&&t.style?t.style+=";"+e.style:t[i]=e[i];return t}let r_=Object.create(null);function rG(e,t,i){if(e==t)return!0;e||(e=r_),t||(t=r_);let n=Object.keys(e),r=Object.keys(t);if(n.length-(i&&n.indexOf(i)>-1?1:0)!=r.length-(i&&r.indexOf(i)>-1?1:0))return!1;for(let s of n)if(s!=i&&(-1==r.indexOf(s)||e[s]!==t[s]))return!1;return!0}function rJ(e,t,i){let n=!1;if(t)for(let r in t)i&&r in i||(n=!0,"style"==r?e.style.cssText="":e.removeAttribute(r));if(i)for(let r in i)t&&t[r]==i[r]||(n=!0,"style"==r?e.style.cssText=i[r]:e.setAttribute(r,i[r]));return n}class rX{eq(e){return!1}updateDOM(e,t){return!1}compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}get estimatedHeight(){return -1}get lineBreaks(){return 0}ignoreEvent(e){return!0}coordsAt(e,t,i){return null}get isHidden(){return!1}get editable(){return!1}destroy(e){}}var rY=function(e){return e[e.Text=0]="Text",e[e.WidgetBefore=1]="WidgetBefore",e[e.WidgetAfter=2]="WidgetAfter",e[e.WidgetRange=3]="WidgetRange",e}(rY||(rY={}));class rQ extends rn{constructor(e,t,i,n){super(),this.startSide=e,this.endSide=t,this.widget=i,this.spec=n}get heightRelevant(){return!1}static mark(e){return new r0(e)}static widget(e){let t=Math.max(-1e4,Math.min(1e4,e.side||0)),i=!!e.block;return t+=i&&!e.inlineOrder?t>0?3e8:-4e8:t>0?1e8:-1e8,new r2(e,t,t,i,e.widget||null,!1)}static replace(e){let t=!!e.block,i,n;if(e.isBlockGap)i=-5e8,n=4e8;else{let{start:r,end:s}=r5(e,t);i=(r?t?-3e8:-1:5e8)-1,n=(s?t?2e8:1:-6e8)+1}return new r2(e,i,n,t,e.widget||null,!0)}static line(e){return new r1(e)}static set(e,t=!1){return ra.of(e,t)}hasHeight(){return!!this.widget&&this.widget.estimatedHeight>-1}}rQ.none=ra.empty;class r0 extends rQ{constructor(e){let{start:t,end:i}=r5(e);super(t?-1:5e8,i?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?rU(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||r_}eq(e){return this==e||e instanceof r0&&this.tagName==e.tagName&&rG(this.attrs,e.attrs)}range(e,t=e){if(e>=t)throw RangeError("Mark decorations may not be empty");return super.range(e,t)}}r0.prototype.point=!1;class r1 extends rQ{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof r1&&this.spec.class==e.spec.class&&rG(this.spec.attributes,e.spec.attributes)}range(e,t=e){if(t!=e)throw RangeError("Line decoration ranges must be zero-length");return super.range(e,t)}}r1.prototype.mapMode=nv.TrackBefore,r1.prototype.point=!0;class r2 extends rQ{constructor(e,t,i,n,r,s){super(t,i,r,e),this.block=n,this.isReplace=s,this.mapMode=n?t<=0?nv.TrackBefore:nv.TrackAfter:nv.TrackDel}get type(){return this.startSide!=this.endSide?rY.WidgetRange:this.startSide<=0?rY.WidgetBefore:rY.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){var t,i;return e instanceof r2&&((t=this.widget)==(i=e.widget)||!!(t&&i&&t.compare(i)))&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,t=e){if(this.isReplace&&(e>t||e==t&&this.startSide>0&&this.endSide<=0))throw RangeError("Invalid range for replacement decoration");if(!this.isReplace&&t!=e)throw RangeError("Widget decorations can only have zero-length ranges");return super.range(e,t)}}function r5(e,t=!1){let{inclusiveStart:i,inclusiveEnd:n}=e;return null==i&&(i=e.inclusive),null==n&&(n=e.inclusive),{start:null!=i?i:t,end:null!=n?n:t}}function r6(e,t,i,n=0){let r=i.length-1;r>=0&&i[r]+n>=e?i[r]=Math.max(i[r],t):i.push(e,t)}r2.prototype.point=!0;class r4 extends rn{constructor(e,t){super(),this.tagName=e,this.attributes=t}eq(e){return e==this||e instanceof r4&&this.tagName==e.tagName&&rG(this.attributes,e.attributes)}static create(e){return new r4(e.tagName,e.attributes||r_)}static set(e,t=!1){return ra.of(e,t)}}function r3(e){return(11==e.nodeType?e.getSelection?e:e.ownerDocument:e).getSelection()}function r8(e,t){return!!t&&(e==t||e.contains(1!=t.nodeType?t.parentNode:t))}function r9(e,t){if(!t.anchorNode)return!1;try{return r8(e,t.anchorNode)}catch(e){return!1}}function r7(e){return 3==e.nodeType?sc(e,0,e.nodeValue.length).getClientRects():1==e.nodeType?e.getClientRects():[]}function se(e,t,i,n){return!!i&&(sn(e,t,i,n,-1)||sn(e,t,i,n,1))}function st(e){for(var t=0;;t++)if(!(e=e.previousSibling))return t}function si(e){return 1==e.nodeType&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(e.nodeName)}function sn(e,t,i,n,r){for(;;){if(e==i&&t==n)return!0;if(t==(r<0?0:sr(e))){if("DIV"==e.nodeName)return!1;let i=e.parentNode;if(!i||1!=i.nodeType)return!1;t=st(e)+(r<0?0:1),e=i}else{if(1!=e.nodeType||1==(e=e.childNodes[t+(r<0?-1:0)]).nodeType&&"false"==e.contentEditable)return!1;t=r<0?sr(e):0}}}function sr(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function ss(e,t){let i=t?e.left:e.right;return{left:i,right:i,top:e.top,bottom:e.bottom}}function so(e,t){let i=t.width/e.offsetWidth,n=t.height/e.offsetHeight;return(i>.995&&i<1.005||!isFinite(i)||1>Math.abs(t.width-e.offsetWidth))&&(i=1),(n>.995&&n<1.005||!isFinite(n)||1>Math.abs(t.height-e.offsetHeight))&&(n=1),{scaleX:i,scaleY:n}}r4.prototype.startSide=r4.prototype.endSide=-1;class sl{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:t,focusNode:i}=e;this.set(t,Math.min(e.anchorOffset,t?sr(t):0),i,Math.min(e.focusOffset,i?sr(i):0))}set(e,t,i,n){this.anchorNode=e,this.anchorOffset=t,this.focusNode=i,this.focusOffset=n}}let sa=null;function sh(e){if(e.setActive)return e.setActive();if(sa)return e.focus(sa);let t=[];for(let i=e;i&&(t.push(i,i.scrollTop,i.scrollLeft),i!=i.ownerDocument);i=i.parentNode);if(e.focus(null==sa?{get preventScroll(){return sa={preventScroll:!0},!0}}:void 0),!sa){sa=!1;for(let e=0;e<t.length;){let i=t[e++],n=t[e++],r=t[e++];i.scrollTop!=n&&(i.scrollTop=n),i.scrollLeft!=r&&(i.scrollLeft=r)}}}function sc(e,t,i=t){let n=r||(r=document.createRange());return n.setEnd(e,i),n.setStart(e,t),n}function sd(e,t,i,n){let r={key:t,code:t,keyCode:i,which:i,cancelable:!0};n&&({altKey:r.altKey,ctrlKey:r.ctrlKey,shiftKey:r.shiftKey,metaKey:r.metaKey}=n);let s=new KeyboardEvent("keydown",r);s.synthetic=!0,e.dispatchEvent(s);let o=new KeyboardEvent("keyup",r);return o.synthetic=!0,e.dispatchEvent(o),s.defaultPrevented||o.defaultPrevented}function su(e){return e.scrollTop>Math.max(1,e.scrollHeight-e.clientHeight-4)}function sf(e,t){for(let i=e,n=t;;){if(3==i.nodeType&&n>0)return{node:i,offset:n};if(1==i.nodeType&&n>0){if("false"==i.contentEditable)return null;n=sr(i=i.childNodes[n-1])}else{if(!i.parentNode||si(i))return null;n=st(i),i=i.parentNode}}}function sp(e,t){for(let i=e,n=t;;){if(3==i.nodeType&&n<i.nodeValue.length)return{node:i,offset:n};if(1==i.nodeType&&n<i.childNodes.length){if("false"==i.contentEditable)return null;i=i.childNodes[n],n=0}else{if(!i.parentNode||si(i))return null;n=st(i)+1,i=i.parentNode}}}rK.safari&&rK.safari_version>=26&&(sa=!1);class sm{constructor(e,t,i=!0){this.node=e,this.offset=t,this.precise=i}static before(e,t){return new sm(e.parentNode,st(e),t)}static after(e,t){return new sm(e.parentNode,st(e)+1,t)}}var sg=function(e){return e[e.LTR=0]="LTR",e[e.RTL=1]="RTL",e}(sg||(sg={}));let sx=sg.LTR,sv=sg.RTL;function sy(e){let t=[];for(let i=0;i<e.length;i++)t.push(1<<+e[i]);return t}let sb=sy("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),sw=sy("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),sk=Object.create(null),sS=[];for(let e of["()","[]","{}"]){let t=e.charCodeAt(0),i=e.charCodeAt(1);sk[t]=i,sk[i]=-t}function sC(e){return e<=247?sb[e]:1424<=e&&e<=1524?2:1536<=e&&e<=1785?sw[e-1536]:1774<=e&&e<=2220?4:8192<=e&&e<=8204?256:64336<=e&&e<=65023?4:1}let sj=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;class sM{get dir(){return this.level%2?sv:sx}constructor(e,t,i){this.from=e,this.to=t,this.level=i}side(e,t){return this.dir==t==e?this.to:this.from}forward(e,t){return e==(this.dir==t)}static find(e,t,i,n){let r=-1;for(let s=0;s<e.length;s++){let o=e[s];if(o.from<=t&&o.to>=t){if(o.level==i)return s;(r<0||(0!=n?n<0?o.from<t:o.to>t:e[r].level>o.level))&&(r=s)}}if(r<0)throw RangeError("Index out of range");return r}}let sZ=[];function sA(e){return[new sM(0,e,0)]}let sT="",sO=nD.define(),sD=nD.define(),sR=nD.define(),sP=nD.define(),sL=nD.define(),sI=nD.define(),sE=nD.define(),sB=nD.define(),sN=nD.define(),sz=nD.define({combine:e=>e.some(e=>e)}),sW=nD.define({combine:e=>e.some(e=>e)}),sF=nD.define();class sV{constructor(e,t="nearest",i="nearest",n=5,r=5,s=!1){this.range=e,this.y=t,this.x=i,this.yMargin=n,this.xMargin=r,this.isSnapshot=s}map(e){return e.empty?this:new sV(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new sV(nA.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}let sH=n5.define({map:(e,t)=>e.map(t)}),s$=n5.define();function sq(e,t,i){let n=e.facet(sP);n.length?n[0](t):window.onerror&&window.onerror(String(t),i,void 0,void 0,t)||(i?console.error(i+":",t):console.error(t))}let sK=nD.define({combine:e=>!e.length||e[0]}),sU=0,s_=nD.define({combine:e=>e.filter((t,i)=>{for(let n=0;n<i;n++)if(e[n].plugin==t.plugin)return!1;return!0})});class sG{constructor(e,t,i,n,r){this.id=e,this.create=t,this.domEventHandlers=i,this.domEventObservers=n,this.baseExtensions=r(this),this.extension=this.baseExtensions.concat(s_.of({plugin:this,arg:void 0}))}of(e){return this.baseExtensions.concat(s_.of({plugin:this,arg:e}))}static define(e,t){let{eventHandlers:i,eventObservers:n,provide:r,decorations:s}=t||{};return new sG(sU++,e,i,n,e=>{let t=[];return s&&t.push(sQ.of(t=>{let i=t.plugin(e);return i?s(i):rQ.none})),r&&t.push(r(e)),t})}static fromClass(e,t){return sG.define((t,i)=>new e(t,i),t)}}class sJ{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(e){if(this.value){if(this.mustUpdate){let e=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(e)}catch(t){if(sq(e.state,t,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch(e){}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(t){sq(e.state,t,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var t;if(null===(t=this.value)||void 0===t?void 0:t.destroy)try{this.value.destroy()}catch(t){sq(e.state,t,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}let sX=nD.define(),sY=nD.define(),sQ=nD.define(),s0=nD.define(),s1=nD.define(),s2=nD.define(),s5=nD.define();function s6(e,t){let i=e.state.facet(s5);if(!i.length)return i;let n=i.map(t=>t instanceof Function?t(e):t),r=[];return ra.spans(n,t.from,t.to,{point(){},span(e,i,n,s){let o=e-t.from,l=i-t.from,a=r;for(let e=n.length-1;e>=0;e--,s--){let i=n[e].spec.bidiIsolate,r;if(null==i&&(i=function(e,t,i){for(let n=t;n<i;n++){let t=sC(e.charCodeAt(n));if(1==t)break;if(2==t||4==t)return sv}return sx}(t.text,o,l)),s>0&&a.length&&(r=a[a.length-1]).to==o&&r.direction==i)r.to=l,a=r.inner;else{let e={from:o,to:l,direction:i,inner:[]};a.push(e),a=e.inner}}}}),r}let s4=nD.define();function s3(e){let t=0,i=0,n=0,r=0;for(let s of e.state.facet(s4)){let o=s(e);o&&(null!=o.left&&(t=Math.max(t,o.left)),null!=o.right&&(i=Math.max(i,o.right)),null!=o.top&&(n=Math.max(n,o.top)),null!=o.bottom&&(r=Math.max(r,o.bottom)))}return{left:t,right:i,top:n,bottom:r}}let s8=nD.define();class s9{constructor(e,t,i,n){this.fromA=e,this.toA=t,this.fromB=i,this.toB=n}join(e){return new s9(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let t=e.length,i=this;for(;t>0;t--){let n=e[t-1];if(!(n.fromA>i.toA)){if(n.toA<i.fromA)break;i=i.join(n),e.splice(t-1,1)}}return e.splice(t,0,i),e}static extendWithRanges(e,t){if(0==t.length)return e;let i=[];for(let n=0,r=0,s=0;;){let o=Math.min(n<e.length?e[n].fromB:1e9,r<t.length?t[r]:1e9);if(1e9==o)break;let l=o+s,a=o,h=l;for(;;)if(r<t.length&&t[r]<=a){let i=t[r+1];r+=2,a=Math.max(a,i);for(let t=n;t<e.length&&e[t].fromB<=a;t++)s=e[t].toA-e[t].toB;h=Math.max(h,i+s)}else if(n<e.length&&e[n].fromB<=a){let t=e[n++];a=Math.max(a,t.toB),h=Math.max(h,t.toA),s=t.toA-t.toB}else break;i.push(new s9(l,h,o,a))}return i}}class s7{constructor(e,t,i){for(let n of(this.view=e,this.state=t,this.transactions=i,this.flags=0,this.startState=e.state,this.changes=nb.empty(this.startState.doc.length),i))this.changes=this.changes.compose(n.changes);let n=[];this.changes.iterChangedRanges((e,t,i,r)=>n.push(new s9(e,t,i,r))),this.changedRanges=n}static create(e,t,i){return new s7(e,t,i)}get viewportChanged(){return(4&this.flags)>0}get viewportMoved(){return(8&this.flags)>0}get heightChanged(){return(2&this.flags)>0}get geometryChanged(){return this.docChanged||(18&this.flags)>0}get focusChanged(){return(1&this.flags)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return 0==this.flags&&0==this.transactions.length}}let oe=[];class ot{constructor(e,t,i=0){this.dom=e,this.length=t,this.flags=i,this.parent=null,e.cmTile=this}get breakAfter(){return 1&this.flags}get children(){return oe}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(e){if(this.flags|=2,4&this.flags){this.flags&=-5;let e=this.domAttrs;e&&function(e,t){for(let i=e.attributes.length-1;i>=0;i--){let n=e.attributes[i].name;null==t[n]&&e.removeAttribute(n)}for(let i in t){let n=t[i];"style"==i?e.style.cssText=n:e.getAttribute(i)!=n&&e.setAttribute(i,n)}}(this.dom,e)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:"")+(this.breakAfter?"#":"")}destroy(){this.parent=null}setDOM(e){this.dom=e,e.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e,t=this.posAtStart){let i=t;for(let t of this.children){if(t==e)return i;i+=t.length+t.breakAfter}throw RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,t){return null}domPosFor(e,t){let i=st(this.dom),n=this.length?e>0:t>0;return new sm(this.parent.dom,i+(n?1:0),0==e||e==this.length)}markDirty(e){this.flags&=-3,e&&(this.flags|=4),this.parent&&2&this.parent.flags&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let e=this;e;e=e.parent)if(e instanceof or)return e;return null}static get(e){return e.cmTile}}class oi extends ot{constructor(e){super(e,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(e){this.children.push(e),e.parent=this}sync(e){if(2&this.flags)return;super.sync(e);let t=this.dom,i=null,n,r=(null==e?void 0:e.node)==t?e:null,s=0;for(let o of this.children){if(o.sync(e),s+=o.length+o.breakAfter,n=i?i.nextSibling:t.firstChild,r&&n!=o.dom&&(r.written=!0),o.dom.parentNode==t)for(;n&&n!=o.dom;)n=on(n);else t.insertBefore(o.dom,n);i=o.dom}for(n=i?i.nextSibling:t.firstChild,r&&n&&(r.written=!0);n;)n=on(n);this.length=s}}function on(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}class or extends oi{constructor(e,t){super(t),this.view=e}owns(e){for(;e;e=e.parent)if(e==this)return!0;return!1}isBlock(){return!0}nearest(e){for(;;){if(!e)return null;let t=ot.get(e);if(t&&this.owns(t))return t;e=e.parentNode}}blockTiles(e){for(let t=[],i=this,n=0,r=0;;)if(n==i.children.length){if(!t.length)return;(i=i.parent).breakAfter&&r++,n=t.pop()}else{let s=i.children[n++];if(s instanceof os)t.push(n),i=s,n=0;else{let t=r+s.length,i=e(s,r);if(void 0!==i)return i;r=t+s.breakAfter}}}resolveBlock(e,t){let i,n=-1,r,s=-1;if(this.blockTiles((o,l)=>{let a=l+o.length;if(e>=l&&e<=a){if(o.isWidget()&&t>=-1&&t<=1){if(32&o.flags)return!0;16&o.flags&&(i=void 0)}(l<e||e==a&&(t<-1?o.length:o.covers(1)))&&(!i||!o.isWidget()&&i.isWidget())&&(i=o,n=e-l),(a>e||e==l&&(t>1?o.length:o.covers(-1)))&&(!r||!o.isWidget()&&r.isWidget())&&(r=o,s=e-l)}}),!i&&!r)throw Error("No tile at position "+e);return i&&t<0||!r?{tile:i,offset:n}:{tile:r,offset:s}}}class os extends oi{constructor(e,t){super(e),this.wrapper=t}isBlock(){return!0}covers(e){return!!this.children.length&&(e<0?this.children[0].covers(-1):this.lastChild.covers(1))}get domAttrs(){return this.wrapper.attributes}static of(e,t){let i=new os(t||document.createElement(e.tagName),e);return t||(i.flags|=4),i}}class oo extends oi{constructor(e,t){super(e),this.attrs=t}isLine(){return!0}static start(e,t,i){let n=new oo(t||document.createElement("div"),e);return t&&i||(n.flags|=4),n}get domAttrs(){return this.attrs}resolveInline(e,t,i){let n=null,r=-1,s=null,o=-1;!function e(l,a){for(let h=0,c=0;h<l.children.length&&c<=a;h++){let d=l.children[h],u=c+d.length;u>=a&&(d.isComposite()?e(d,a-c):(!s||s.isHidden&&(t>0||i&&function(e,t){let i=e.coordsIn(0,1),n=t.coordsIn(0,1);return i&&n&&n.top<i.bottom}(s,d)))&&(u>a||32&d.flags)?(s=d,o=a-c):(c<a||16&d.flags&&!d.isHidden)&&(n=d,r=a-c)),c=u}}(this,e);let l=(t<0?n:s)||n||s;return l?{tile:l,offset:l==n?r:o}:null}coordsIn(e,t){let i=this.resolveInline(e,t,!0);return i?i.tile.coordsIn(Math.max(0,i.offset),t):function(e){let t=e.dom.lastChild;if(!t)return e.dom.getBoundingClientRect();let i=r7(t);return i[i.length-1]||null}(this)}domIn(e,t){let i=this.resolveInline(e,t);if(i){let{tile:e,offset:n}=i;if(this.dom.contains(e.dom))return e.isText()?new sm(e.dom,Math.min(e.dom.nodeValue.length,n)):e.domPosFor(n,16&e.flags?1:32&e.flags?-1:t);let r=i.tile.parent,s=!1;for(let e of r.children){if(s)return new sm(e.dom,0);e==i.tile&&(s=!0)}}return new sm(this.dom,0)}}class ol extends oi{constructor(e,t){super(e),this.mark=t}get domAttrs(){return this.mark.attrs}static of(e,t){let i=new ol(t||document.createElement(e.tagName),e);return t||(i.flags|=4),i}}class oa extends ot{constructor(e,t){super(e,t.length),this.text=t}sync(e){2&this.flags||(super.sync(e),this.dom.nodeValue==this.text||(e&&e.node==this.dom&&(e.written=!0),this.dom.nodeValue=this.text))}isText(){return!0}toString(){return JSON.stringify(this.text)}coordsIn(e,t){let i=this.dom.nodeValue.length;e>i&&(e=i);let n=e,r=e,s=0;0==e&&t<0||e==i&&t>=0?!(rK.chrome||rK.gecko)&&(e?(n--,s=1):r<i&&(r++,s=-1)):t<0?n--:r<i&&r++;let o=sc(this.dom,n,r).getClientRects();if(!o.length)return null;let l=o[(s?s<0:t>=0)?0:o.length-1];return rK.safari&&!s&&0==l.width&&(l=Array.prototype.find.call(o,e=>e.width)||l),s?ss(l,s<0):l||null}static of(e,t){let i=new oa(t||document.createTextNode(e),e);return t||(i.flags|=2),i}}class oh extends ot{constructor(e,t,i,n){super(e,t,n),this.widget=i}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(e){return!(48&this.flags)&&(this.flags&(e<0?64:128))>0}coordsIn(e,t){return this.coordsInWidget(e,t,!1)}coordsInWidget(e,t,i){let n=this.widget.coordsAt(this.dom,e,t);if(n)return n;if(i)return ss(this.dom.getBoundingClientRect(),this.length?0==e:t<=0);{let t=this.dom.getClientRects(),i=null;if(!t.length)return null;let n=!!(16&this.flags)||!(32&this.flags)&&e>0;for(let r=n?t.length-1:0;i=t[r],e>0?0!=r:r!=t.length-1&&!(i.top<i.bottom);r+=n?-1:1);return ss(i,!n)}}get overrideDOMText(){if(!this.length)return ns.empty;let{root:e}=this;if(!e)return ns.empty;let t=this.posAtStart;return e.view.state.doc.slice(t,t+this.length)}destroy(){super.destroy(),this.widget.destroy(this.dom)}static of(e,t,i,n,r){return r||(r=e.toDOM(t),e.editable||(r.contentEditable="false")),new oh(r,i,e,n)}}class oc extends ot{constructor(e){let t=document.createElement("img");t.className="cm-widgetBuffer",t.setAttribute("aria-hidden","true"),super(t,0,e)}get isHidden(){return!0}get overrideDOMText(){return ns.empty}coordsIn(e){return this.dom.getBoundingClientRect()}}class od{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,t,i){let{tile:n,index:r,beforeBreak:s,parents:o}=this;for(;e||t>0;)if(n.isComposite()){if(s){if(!e)break;i&&i.break(),e--,s=!1}else if(r==n.children.length){if(!e&&!o.length)break;i&&i.leave(n),s=!!n.breakAfter,({tile:n,index:r}=o.pop()),r++}else{let l=n.children[r],a=l.breakAfter;(t>0?l.length<=e:l.length<e)&&(!i||!1!==i.skip(l,0,l.length)||!l.isComposite)?(s=!!a,r++,e-=l.length):(o.push({tile:n,index:r}),n=l,r=0,i&&l.isComposite()&&i.enter(l))}}else if(r==n.length)s=!!n.breakAfter,({tile:n,index:r}=o.pop()),r++;else if(e){let t=Math.min(e,n.length-r);i&&i.skip(n,r,r+t),e-=t,r+=t}else break;return this.tile=n,this.index=r,this.beforeBreak=s,this}get root(){return this.parents.length?this.parents[0].tile:this.tile}}class ou{constructor(e,t,i,n){this.from=e,this.to=t,this.wrapper=i,this.rank=n}}class of{constructor(e,t,i){this.cache=e,this.root=t,this.blockWrappers=i,this.curLine=null,this.lastBlock=null,this.afterWidget=null,this.pos=0,this.wrappers=[],this.wrapperPos=0}addText(e,t,i,n){var r;this.flushBuffer();let s=this.ensureMarks(t,i),o=s.lastChild;o&&o.isText()&&!(8&o.flags)&&o.length+e.length<512?(this.cache.reused.set(o,2),(s.children[s.children.length-1]=new oa(o.dom,o.text+e)).parent=s):s.append(n||oa.of(e,null===(r=this.cache.find(oa))||void 0===r?void 0:r.dom)),this.pos+=e.length,this.afterWidget=null}addComposition(e,t){let i=this.curLine;i.dom!=t.line.dom&&(i.setDOM(this.cache.reused.has(t.line)?ob(t.line.dom):t.line.dom),this.cache.reused.set(t.line,2));let n=i;for(let e=t.marks.length-1;e>=0;e--){let i=t.marks[e],r=n.lastChild;if(r instanceof ol&&r.mark.eq(i.mark))r.dom!=i.dom&&r.setDOM(ob(i.dom)),n=r;else{if(this.cache.reused.get(i)){let e=ot.get(i.dom);e&&e.setDOM(ob(i.dom))}let e=ol.of(i.mark,i.dom);n.append(e),n=e}this.cache.reused.set(i,2)}let r=ot.get(e.text);r&&this.cache.reused.set(r,2);let s=new oa(e.text,e.text.nodeValue);s.flags|=8,n.append(s)}addInlineWidget(e,t,i){let n=this.afterWidget&&48&e.flags&&(48&this.afterWidget.flags)==(48&e.flags);n||this.flushBuffer();let r=this.ensureMarks(t,i);n||16&e.flags||r.append(this.getBuffer(1)),r.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,t,i){this.flushBuffer(),this.ensureMarks(t,i).append(e),this.pos+=e.length,this.afterWidget=null}addBlockWidget(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}continueWidget(e){let t=this.afterWidget||this.lastBlock;t.length+=e,this.pos+=e}addLineStart(e,t){var i;e||(e=oy);let n=oo.start(e,t||(null===(i=this.cache.find(oo))||void 0===i?void 0:i.dom),!!t);this.getBlockPos().append(this.lastBlock=this.curLine=n)}addLine(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(e){this.blockPosCovered()||this.addLineStart(e)}ensureLine(e){this.curLine||this.addLineStart(e)}ensureMarks(e,t){var i;let n=this.curLine;for(let r=e.length-1;r>=0;r--){let s=e[r],o;if(t>0&&(o=n.lastChild)&&o instanceof ol&&o.mark.eq(s))n=o,t--;else{let e=ol.of(s,null===(i=this.cache.find(ol,e=>e.mark.eq(s)))||void 0===i?void 0:i.dom);n.append(e),n=e,t=0}}return n}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!ov(this.curLine,!1)||"BR"!=e.dom.nodeName&&e.isWidget()&&!(rK.ios&&ov(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(ok,0,32)||new oh(ok.toDOM(),0,ok,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let e=this.wrappers.length-1;e>=0;e--)this.wrappers[e].to<this.pos&&this.wrappers.splice(e,1);for(let e=this.blockWrappers;e.value&&e.from<=this.pos;e.next())if(e.to>=this.pos){let t=new ou(e.from,e.to,e.value,e.rank),i=this.wrappers.length;for(;i>0&&0>(this.wrappers[i-1].rank-t.rank||this.wrappers[i-1].to-t.to);)i--;this.wrappers.splice(i,0,t)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let t=this.root;for(let i of this.wrappers){let n=t.lastChild;if(i.from<this.pos&&n instanceof os&&n.wrapper.eq(i.wrapper))t=n;else{let n=os.of(i.wrapper,null===(e=this.cache.find(os,e=>e.wrapper.eq(i.wrapper)))||void 0===e?void 0:e.dom);t.append(n),t=n}}return t}blockPosCovered(){let e=this.lastBlock;return null!=e&&!e.breakAfter&&(!e.isWidget()||(160&e.flags)>0)}getBuffer(e){let t=2|(e<0?16:32),i=this.cache.find(oc,void 0,1);return i&&(i.flags=t),i||new oc(t)}flushBuffer(){this.afterWidget&&!(32&this.afterWidget.flags)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class op{constructor(e){this.skipCount=0,this.text="",this.textOff=0,this.cursor=e.iter()}skip(e){this.textOff+e<=this.text.length?this.textOff+=e:(this.skipCount+=e-(this.text.length-this.textOff),this.text="",this.textOff=0)}next(e){if(this.textOff==this.text.length){let{value:t,lineBreak:i,done:n}=this.cursor.next(this.skipCount);if(this.skipCount=0,n)throw Error("Ran out of text content when drawing inline views");this.text=t;let r=this.textOff=Math.min(e,t.length);return i?null:t.slice(0,r)}let t=Math.min(this.text.length,this.textOff+e),i=this.text.slice(this.textOff,t);return this.textOff=t,i}}let om=[oh,oo,oa,ol,oc,os,or];for(let e=0;e<om.length;e++)om[e].bucket=e;class og{constructor(e){this.view=e,this.buckets=om.map(()=>[]),this.index=om.map(()=>0),this.reused=new Map}add(e){let t=e.constructor.bucket,i=this.buckets[t];i.length<6?i.push(e):i[this.index[t]=(this.index[t]+1)%6]=e}find(e,t,i=2){let n=e.bucket,r=this.buckets[n],s=this.index[n];for(let e=r.length-1;e>=0;e--){let o=(e+s)%r.length,l=r[o];if((!t||t(l))&&!this.reused.has(l))return r.splice(o,1),o<s&&this.index[n]--,this.reused.set(l,i),l}return null}findWidget(e,t,i){let n=this.buckets[0];if(n.length)for(let r=0,s=0;;r++){if(r==n.length){if(s)return null;s=1,r=0}let o=n[r];if(!this.reused.has(o)&&(0==s?o.widget.compare(e):o.widget.constructor==e.constructor&&e.updateDOM(o.dom,this.view))){if(n.splice(r,1),r<this.index[0]&&this.index[0]--,o.widget==e&&o.length==t&&(497&o.flags)==i)return this.reused.set(o,1),o;return this.reused.set(o,2),new oh(o.dom,t,e,-498&o.flags|i)}}}reuse(e){return this.reused.set(e,1),e}maybeReuse(e,t=2){if(!this.reused.has(e))return this.reused.set(e,t),e.dom}clear(){for(let e=0;e<this.buckets.length;e++)this.buckets[e].length=this.index[e]=0}}class ox{constructor(e,t,i,n,r){this.view=e,this.decorations=n,this.disallowBlockEffectsFor=r,this.openWidget=!1,this.openMarks=0,this.cache=new og(e),this.text=new op(e.state.doc),this.builder=new of(this.cache,new or(e,e.contentDOM),ra.iter(i)),this.cache.reused.set(t,2),this.old=new od(t),this.reuseWalker={skip:(e,t,i)=>{if(this.cache.add(e),e.isComposite())return!1},enter:e=>this.cache.add(e),leave:()=>{},break:()=>{}}}run(e,t){let i=t&&this.getCompositionContext(t.text);for(let n=0,r=0,s=0;;){let o=s<e.length?e[s++]:null,l=o?o.fromA:this.old.root.length;if(l>n){let e=l-n;this.preserve(e,!s,!o),n=l,r+=e}if(!o)break;t&&o.fromA<=t.range.fromA&&o.toA>=t.range.toA?(this.forward(o.fromA,t.range.fromA,t.range.fromA<t.range.toA?1:-1),this.emit(r,t.range.fromB),this.cache.clear(),this.builder.addComposition(t,i),this.text.skip(t.range.toB-t.range.fromB),this.forward(t.range.fromA,o.toA),this.emit(t.range.toB,o.toB)):(this.forward(o.fromA,o.toA),this.emit(r,o.toB)),r=o.toB,n=o.toA}return this.builder.curLine&&this.builder.endLine(),this.builder.root}preserve(e,t,i){let n=function(e){let t=[];for(let i=e.parents.length;i>1;i--){let n=i==e.parents.length?e.tile:e.parents[i].tile;n instanceof ol&&t.push(n.mark)}return t}(this.old),r=this.openMarks;this.old.advance(e,i?1:-1,{skip:(e,t,i)=>{if(e.isWidget()){if(this.openWidget)this.builder.continueWidget(i-t);else{let s=i>0||t<e.length?oh.of(e.widget,this.view,i-t,496&e.flags,this.cache.maybeReuse(e)):this.cache.reuse(e);256&s.flags?(s.flags&=-2,this.builder.addBlockWidget(s)):(this.builder.ensureLine(null),this.builder.addInlineWidget(s,n,r),r=n.length)}}else if(e.isText())this.builder.ensureLine(null),t||i!=e.length?(this.cache.add(e),this.builder.addText(e.text.slice(t,i),n,r)):this.builder.addText(e.text,n,r,this.cache.reuse(e)),r=n.length;else if(e.isLine())e.flags&=-2,this.cache.reused.set(e,1),this.builder.addLine(e);else if(e instanceof oc)this.cache.add(e);else{if(!(e instanceof ol))return!1;this.builder.ensureLine(null),this.builder.addMark(e,n,r),this.cache.reused.set(e,1),r=n.length}this.openWidget=!1},enter:e=>{e.isLine()?this.builder.addLineStart(e.attrs,this.cache.maybeReuse(e)):(this.cache.add(e),e instanceof ol&&n.unshift(e.mark)),this.openWidget=!1},leave:e=>{e.isLine()?n.length&&(n.length=r=0):e instanceof ol&&(n.shift(),r=Math.min(r,n.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,t){let i=null,n=this.builder,r=0,s=ra.spans(this.decorations,e,t,{point:(e,t,s,o,l,a)=>{var h;if(s instanceof r2){if(this.disallowBlockEffectsFor[a]){if(s.block)throw RangeError("Block decorations may not be specified via plugins");if(t>this.view.state.doc.lineAt(e).to)throw RangeError("Decorations that replace line breaks may not be specified via plugins")}if(r=o.length,l>o.length)n.continueWidget(t-e);else{let r;let a=s.widget||(s.block?ow.block:ow.inline),h=(r=s.isReplace?(s.startSide<0?64:0)|(s.endSide>0?128:0):s.startSide>0?32:16,s.block&&(r|=256),r),c=this.cache.findWidget(a,t-e,h)||oh.of(a,this.view,t-e,h);s.block?(s.startSide>0&&n.addLineStartIfNotCovered(i),n.addBlockWidget(c)):(n.ensureLine(i),n.addInlineWidget(c,o,l))}i=null}else{let e,t;h=i,e=s.spec.attributes,t=s.spec.class,(e||t)&&(h||(h={class:"cm-line"}),e&&rU(e,h),t&&(h.class+=" "+t)),i=h}t>e&&this.text.skip(t-e)},span:(e,t,r,s)=>{for(let o=e;o<t;){let l=this.text.next(Math.min(512,t-o));null==l?(n.addLineStartIfNotCovered(i),n.addBreak(),o++):(n.ensureLine(i),n.addText(l,r,o==e?s:r.length),o+=l.length),i=null}}});n.addLineStartIfNotCovered(i),this.openWidget=s>r,this.openMarks=s}forward(e,t,i=1){t-e<=10?this.old.advance(t-e,i,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(t-e-10,-1),this.old.advance(5,i,this.reuseWalker))}getCompositionContext(e){let t=[],i=null;for(let n=e.parentNode;;n=n.parentNode){let e=ot.get(n);if(n==this.view.contentDOM)break;e instanceof ol?t.push(e):(null==e?void 0:e.isLine())?i=e:"DIV"!=n.nodeName||i||n==this.view.contentDOM?t.push(ol.of(new r0({tagName:n.nodeName.toLowerCase(),attributes:function(e){let t=Object.create(null);for(let i=0;i<e.attributes.length;i++){let n=e.attributes[i];t[n.name]=n.value}return t}(n)}),n)):i=new oo(n,oy)}return{line:i,marks:t}}}function ov(e,t){let i=e=>{for(let n of e.children)if((t?n.isText():n.length)||i(n))return!0;return!1};return i(e)}let oy={class:"cm-line"};function ob(e){let t=ot.get(e);return t&&t.setDOM(e.cloneNode()),e}class ow extends rX{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}ow.inline=new ow("span"),ow.block=new ow("div");let ok=new class extends rX{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class oS{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=rQ.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.updateDeco(),this.tile=new or(e,e.contentDOM),this.updateInner([new s9(0,0,0,e.state.doc.length)],null)}update(e){var t,i,n,r,s,o,l;let a,h,c;let d=e.changedRanges;this.minWidth>0&&d.length&&(d.every(({fromA:e,toA:t})=>t<this.minWidthFrom||e>this.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(e);let u=-1;!(this.view.inputState.composing>=0)||this.view.observer.editContext||((null===(t=this.domChanged)||void 0===t?void 0:t.newSel)?u=this.domChanged.newSel.head:(i=e.changes,n=this.hasComposition,a=!1,n&&i.iterChangedRanges((e,t)=>{e<n.to&&t>n.from&&(a=!0)}),a||e.selectionSet||(u=e.state.selection.main.head)));let f=u>-1?function(e,t,i){let n=oj(e,i);if(!n)return null;let{node:r,from:s,to:o}=n,l=r.nodeValue;if(/[\n\r]/.test(l)||e.state.doc.sliceString(n.from,n.to)!=l)return null;let a=t.invertedDesc;return{range:new s9(a.mapPos(s),a.mapPos(o),s,o),text:r}}(this.view,e.changes,u):null;if(this.domChanged=null,this.hasComposition){let{from:t,to:i}=this.hasComposition;d=new s9(t,i,e.changes.mapPos(t,-1),e.changes.mapPos(i,1)).addToSet(d.slice())}this.hasComposition=f?{from:f.range.fromB,to:f.range.toB}:null,(rK.ie||rK.chrome)&&!f&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let p=this.decorations,m=this.blockWrappers;this.updateDeco();let g=(r=this.decorations,s=e.changes,h=new oM,ra.compare(p,r,s,h),h.changes);g.length&&(d=s9.extendWithRanges(d,g));let x=(o=this.blockWrappers,l=e.changes,c=new oZ,ra.compare(m,o,l,c),c.changes);return x.length&&(d=s9.extendWithRanges(d,x)),f&&!d.some(e=>e.fromA<=f.range.fromA&&e.toA>=f.range.toA)&&(d=f.range.addToSet(d.slice())),(!(2&this.tile.flags)||0!=d.length)&&(this.updateInner(d,f),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t){this.view.viewState.mustMeasureContent=!0;let{observer:i}=this.view;i.ignore(()=>{if(t||e.length){let i=this.tile,n=new ox(this.view,i,this.blockWrappers,this.decorations,this.dynamicDecorationMap);this.tile=n.run(e,t),oC(i,n.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let n=rK.chrome||rK.ios?{node:i.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(n),n&&(n.written||i.selectionRange.focusNode!=n.node||!this.tile.dom.contains(n.node))&&(this.forceSelection=!0),this.tile.dom.style.height=""});let n=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let e of this.tile.children)e.isWidget()&&e.widget instanceof oA&&n.push(e.dom);i.updateGaps(n)}updateEditContextFormatting(e){for(let t of(this.editContextFormatting=this.editContextFormatting.map(e.changes),e.transactions))for(let e of t.effects)e.is(s$)&&(this.editContextFormatting=e.value)}updateSelection(e=!1,t=!1){var i;(e||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange();let{dom:n}=this.tile,r=this.view.root.activeElement,s=r==n,o=!s&&!(this.view.state.facet(sK)||n.tabIndex>-1)&&r9(n,this.view.observer.selectionRange)&&!(r&&n.contains(r));if(!(s||t||o))return;let l=this.forceSelection;this.forceSelection=!1;let a=this.view.state.selection.main,h,c;if(a.empty?c=h=this.inlineDOMNearPos(a.anchor,a.assoc||1):(c=this.inlineDOMNearPos(a.head,a.head==a.from?1:-1),h=this.inlineDOMNearPos(a.anchor,a.anchor==a.from?1:-1)),rK.gecko&&a.empty&&!this.hasComposition&&1==(i=h).node.nodeType&&i.node.firstChild&&(0==i.offset||"false"==i.node.childNodes[i.offset-1].contentEditable)&&(i.offset==i.node.childNodes.length||"false"==i.node.childNodes[i.offset].contentEditable)){let e=document.createTextNode("");this.view.observer.ignore(()=>h.node.insertBefore(e,h.node.childNodes[h.offset]||null)),h=c=new sm(e,0),l=!0}let d=this.view.observer.selectionRange;!l&&d.focusNode&&(se(h.node,h.offset,d.anchorNode,d.anchorOffset)&&se(c.node,c.offset,d.focusNode,d.focusOffset)||this.suppressWidgetCursorChange(d,a))||(this.view.observer.ignore(()=>{rK.android&&rK.chrome&&n.contains(d.focusNode)&&function(e,t){for(let i=e;i&&i!=t;i=i.assignedSlot||i.parentNode)if(1==i.nodeType&&"false"==i.contentEditable)return!0;return!1}(d.focusNode,n)&&(n.blur(),n.focus({preventScroll:!0}));let e=r3(this.view.root);if(e){if(a.empty){if(rK.gecko){var t,i;let e=(t=h.node,i=h.offset,1!=t.nodeType?0:(i&&"false"==t.childNodes[i-1].contentEditable?1:0)|(i<t.childNodes.length&&"false"==t.childNodes[i].contentEditable?2:0));if(e&&3!=e){let t=(1==e?sf:sp)(h.node,h.offset);t&&(h=new sm(t.node,t.offset))}}e.collapse(h.node,h.offset),null!=a.bidiLevel&&void 0!==e.caretBidiLevel&&(e.caretBidiLevel=a.bidiLevel)}else if(e.extend){e.collapse(h.node,h.offset);try{e.extend(c.node,c.offset)}catch(e){}}else{let t=document.createRange();a.anchor>a.head&&([h,c]=[c,h]),t.setEnd(c.node,c.offset),t.setStart(h.node,h.offset),e.removeAllRanges(),e.addRange(t)}}o&&this.view.root.activeElement==n&&(n.blur(),r&&r.focus())}),this.view.observer.setSelectionRange(h,c)),this.impreciseAnchor=h.precise?null:new sm(d.anchorNode,d.anchorOffset),this.impreciseHead=c.precise?null:new sm(d.focusNode,d.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&se(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==t.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,t=e.state.selection.main,i=r3(e.root),{anchorNode:n,anchorOffset:r}=e.observer.selectionRange;if(!i||!t.empty||!t.assoc||!i.modify)return;let s=this.lineAt(t.head,t.assoc);if(!s)return;let o=s.posAtStart;if(t.head==o||t.head==o+s.length)return;let l=this.coordsAt(t.head,-1),a=this.coordsAt(t.head,1);if(!l||!a||l.bottom>a.top)return;let h=this.domAtPos(t.head+t.assoc,t.assoc);i.collapse(h.node,h.offset),i.modify("move",t.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let c=e.observer.selectionRange;e.docView.posFromDOM(c.anchorNode,c.anchorOffset)!=t.from&&i.collapse(n,r)}posFromDOM(e,t){let i=this.tile.nearest(e);if(!i)return 2&this.tile.dom.compareDocumentPosition(e)?0:this.view.state.doc.length;let n=i.posAtStart;if(i.isComposite()){let r;if(e==i.dom)r=i.dom.childNodes[t];else{let n=0==sr(e)?0:0==t?-1:1;for(;;){let t=e.parentNode;if(t==i.dom)break;0==n&&t.firstChild!=t.lastChild&&(n=e==t.firstChild?-1:1),e=t}r=n<0?e:e.nextSibling}if(r==i.dom.firstChild)return n;for(;r&&!ot.get(r);)r=r.nextSibling;if(!r)return n+i.length;for(let e=0,t=n;;e++){let n=i.children[e];if(n.dom==r)return t;t+=n.length+n.breakAfter}}else if(i.isText())return e==i.dom?n+t:n+(t?i.length:0);else return n}domAtPos(e,t){let{tile:i,offset:n}=this.tile.resolveBlock(e,t);return i.isWidget()?i.domPosFor(e,t):i.domIn(n,t)}inlineDOMNearPos(e,t){let i,n=-1,r=!1,s,o=-1,l=!1;return(this.tile.blockTiles((t,a)=>{if(t.isWidget()){if(32&t.flags&&a>=e)return!0;16&t.flags&&(r=!0)}else{let h=a+t.length;if(a<=e&&(i=t,n=e-a,r=h<e),h>=e&&!s&&(s=t,o=e-a,l=a>e),a>e&&s)return!0}}),i||s)?(r&&s?i=null:l&&i&&(s=null),i&&t<0||!s?i.domIn(n,t):s.domIn(o,t)):this.domAtPos(e,t)}coordsAt(e,t){let{tile:i,offset:n}=this.tile.resolveBlock(e,t);return i.isWidget()?i.widget instanceof oA?null:i.coordsInWidget(n,t,!0):i.coordsIn(n,t)}lineAt(e,t){let{tile:i}=this.tile.resolveBlock(e,t);return i.isLine()?i:null}coordsForChar(e){let{tile:t,offset:i}=this.tile.resolveBlock(e,1);return t.isLine()?function e(t,i){if(t.isComposite())for(let n of t.children){if(n.length>=i){let t=e(n,i);if(t)return t}if((i-=n.length)<0)break}else if(t.isText()&&i<t.length){let e=np(t.text,i);if(e==i)return null;let n=sc(t.dom,i,e).getClientRects();for(let e=0;e<n.length;e++){let t=n[e];if(e==n.length-1||t.top<t.bottom&&t.left<t.right)return t}}return null}(t,i):null}measureVisibleLineHeights(e){let t=[],{from:i,to:n}=e,r=this.view.contentDOM.clientWidth,s=r>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,o=-1,l=this.view.textDirection==sg.LTR,a=0,h=(e,c,d)=>{for(let u=0;u<e.children.length&&!(c>n);u++){let n=e.children[u],f=c+n.length,p=n.dom.getBoundingClientRect(),{height:m}=p;if(d&&!u&&(a+=p.top-d.top),n instanceof os)f>i&&h(n,c,p);else if(c>=i&&(a>0&&t.push(-a),t.push(m+a),a=0,s)){let e=n.dom.lastChild,t=e?r7(e):[];if(t.length){let e=t[t.length-1],i=l?e.right-p.left:p.right-e.left;i>o&&(o=i,this.minWidth=r,this.minWidthFrom=c,this.minWidthTo=f)}}d&&u==e.children.length-1&&(a+=d.bottom-p.bottom),c=f+n.breakAfter}};return h(this.tile,0,null),t}textDirectionAt(e){let{tile:t}=this.tile.resolveBlock(e,1);return"rtl"==getComputedStyle(t.dom).direction?sg.RTL:sg.LTR}measureTextSize(){let e=this.tile.blockTiles(e=>{if(e.isLine()&&e.children.length&&e.length<=20){let t=0,i;for(let n of e.children){if(!n.isText()||/[^ -~]/.test(n.text))return;let e=r7(n.dom);if(1!=e.length)return;t+=e[0].width,i=e[0].height}if(t)return{lineHeight:e.dom.getBoundingClientRect().height,charWidth:t/e.length,textHeight:i}}});if(e)return e;let t=document.createElement("div"),i,n,r;return t.className="cm-line",t.style.width="99999px",t.style.position="absolute",t.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(t);let e=r7(t.firstChild)[0];i=t.getBoundingClientRect().height,n=e&&e.width?e.width/27:7,r=e&&e.height?e.height:i,t.remove()}),{lineHeight:i,charWidth:n,textHeight:r}}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let i=0,n=0;;n++){let r=n==t.viewports.length?null:t.viewports[n],s=r?r.from-1:this.view.state.doc.length;if(s>i){let n=(t.lineBlockAt(s).bottom-t.lineBlockAt(i).top)/this.view.scaleY;e.push(rQ.replace({widget:new oA(n),block:!0,inclusive:!0,isBlockGap:!0}).range(i,s))}if(!r)break;i=r.to+1}return rQ.set(e)}updateDeco(){let e=1,t=this.view.state.facet(sQ).map(t=>(this.dynamicDecorationMap[e++]="function"==typeof t)?t(this.view):t),i=!1,n=this.view.state.facet(s1).map((e,t)=>{let n="function"==typeof e;return n&&(i=!0),n?e(this.view):e});for(n.length&&(this.dynamicDecorationMap[e++]=i,t.push(ra.join(n))),this.decorations=[this.editContextFormatting,...t,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];e<this.decorations.length;)this.dynamicDecorationMap[e++]=!1;this.blockWrappers=this.view.state.facet(s0).map(e=>"function"==typeof e?e(this.view):e)}scrollIntoView(e){if(e.isSnapshot){let t=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=t.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let t of this.view.state.facet(sF))try{if(t(this.view,e.range,e))return!0}catch(e){sq(this.view.state,e,"scroll handler")}let{range:t}=e,i=this.coordsAt(t.head,t.empty?t.assoc:t.head>t.anchor?-1:1),n;if(!i)return;!t.empty&&(n=this.coordsAt(t.anchor,t.anchor>t.head?-1:1))&&(i={left:Math.min(i.left,n.left),top:Math.min(i.top,n.top),right:Math.max(i.right,n.right),bottom:Math.max(i.bottom,n.bottom)});let r=s3(this.view),s={left:i.left-r.left,top:i.top-r.top,right:i.right+r.right,bottom:i.bottom+r.bottom},{offsetWidth:o,offsetHeight:l}=this.view.scrollDOM;!function(e,t,i,n,r,s,o,l){let a=e.ownerDocument,h=a.defaultView||window;for(let c=e,d=!1;c&&!d;)if(1==c.nodeType){let e,u=c==a.body,f=1,p=1;if(u)e=function(e){let t=e.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.innerWidth,top:0,bottom:e.innerHeight}}(h);else{if(/^(fixed|sticky)$/.test(getComputedStyle(c).position)&&(d=!0),c.scrollHeight<=c.clientHeight&&c.scrollWidth<=c.clientWidth){c=c.assignedSlot||c.parentNode;continue}let t=c.getBoundingClientRect();({scaleX:f,scaleY:p}=so(c,t)),e={left:t.left,right:t.left+c.clientWidth*f,top:t.top,bottom:t.top+c.clientHeight*p}}let m=0,g=0;if("nearest"==r)t.top<e.top?(g=t.top-(e.top+o),i>0&&t.bottom>e.bottom+g&&(g=t.bottom-e.bottom+o)):t.bottom>e.bottom&&(g=t.bottom-e.bottom+o,i<0&&t.top-g<e.top&&(g=t.top-(e.top+o)));else{let n=t.bottom-t.top,s=e.bottom-e.top;g=("center"==r&&n<=s?t.top+n/2-s/2:"start"==r||"center"==r&&i<0?t.top-o:t.bottom-s+o)-e.top}if("nearest"==n?t.left<e.left?(m=t.left-(e.left+s),i>0&&t.right>e.right+m&&(m=t.right-e.right+s)):t.right>e.right&&(m=t.right-e.right+s,i<0&&t.left<e.left+m&&(m=t.left-(e.left+s))):m=("center"==n?t.left+(t.right-t.left)/2-(e.right-e.left)/2:"start"==n==l?t.left-s:t.right-(e.right-e.left)+s)-e.left,m||g){if(u)h.scrollBy(m,g);else{let e=0,i=0;if(g){let e=c.scrollTop;c.scrollTop+=g/p,i=(c.scrollTop-e)*p}if(m){let t=c.scrollLeft;c.scrollLeft+=m/f,e=(c.scrollLeft-t)*f}t={left:t.left-e,top:t.top-i,right:t.right-e,bottom:t.bottom-i},e&&1>Math.abs(e-m)&&(n="nearest"),i&&1>Math.abs(i-g)&&(r="nearest")}}if(u)break;(t.top<e.top||t.bottom>e.bottom||t.left<e.left||t.right>e.right)&&(t={left:Math.max(t.left,e.left),right:Math.min(t.right,e.right),top:Math.max(t.top,e.top),bottom:Math.min(t.bottom,e.bottom)}),c=c.assignedSlot||c.parentNode}else if(11==c.nodeType)c=c.host;else break}(this.view.scrollDOM,s,t.head<t.anchor?-1:1,e.x,e.y,Math.max(Math.min(e.xMargin,o),-o),Math.max(Math.min(e.yMargin,l),-l),this.view.textDirection==sg.LTR)}lineHasWidget(e){let t=e=>e.isWidget()||e.children.some(t);return t(this.tile.resolveBlock(e,1).tile)}destroy(){oC(this.tile)}}function oC(e,t){let i=null==t?void 0:t.get(e);if(1!=i)for(let n of(null==i&&e.destroy(),e.children))oC(n,t)}function oj(e,t){let i=e.observer.selectionRange;if(!i.focusNode)return null;let n=sf(i.focusNode,i.focusOffset),r=sp(i.focusNode,i.focusOffset),s=n||r;if(r&&n&&r.node!=n.node){let t=ot.get(r.node);if(!t||t.isText()&&t.text!=r.node.nodeValue)s=r;else if(e.docView.lastCompositionAfterCursor){let e=ot.get(n.node);!e||e.isText()&&e.text!=n.node.nodeValue||(s=r)}}if(e.docView.lastCompositionAfterCursor=s!=n,!s)return null;let o=t-s.offset;return{from:o,to:o+s.node.nodeValue.length,node:s.node}}let oM=class{constructor(){this.changes=[]}compareRange(e,t){r6(e,t,this.changes)}comparePoint(e,t){r6(e,t,this.changes)}boundChange(e){r6(e,e,this.changes)}};class oZ{constructor(){this.changes=[]}compareRange(e,t){r6(e,t,this.changes)}comparePoint(){}boundChange(e){r6(e,e,this.changes)}}class oA extends rX{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement("div");return e.className="cm-gap",this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}function oT(e,t,i){let n=e.lineBlockAt(t);if(Array.isArray(n.type)){let e;for(let r of n.type){if(r.from>t)break;if(!(r.to<t)){if(r.from<t&&r.to>t)return r;(!e||r.type==rY.Text&&(e.type!=r.type||(i<0?r.from<t:r.to>t)))&&(e=r)}}return e||n}return n}function oO(e,t,i,n){let r=e.state.doc.lineAt(t.head),s=e.bidiSpans(r),o=e.textDirectionAt(r.from);for(let l=t,a=null;;){let t=function(e,t,i,n,r){var s;let o=n.head-e.from,l=sM.find(t,o,null!==(s=n.bidiLevel)&&void 0!==s?s:-1,n.assoc),a=t[l],h=a.side(r,i);if(o==h){let e=l+=r?1:-1;if(e<0||e>=t.length)return null;o=(a=t[l=e]).side(!r,i),h=a.side(r,i)}let c=np(e.text,o,a.forward(r,i));(c<a.from||c>a.to)&&(c=h),sT=e.text.slice(Math.min(o,c),Math.max(o,c));let d=l==(r?t.length-1:0)?null:t[l+(r?1:-1)];return d&&c==h&&d.level+(r?0:1)<a.level?nA.cursor(d.side(!r,i)+e.from,d.forward(r,i)?1:-1,d.level):nA.cursor(c+e.from,a.forward(r,i)?-1:1,a.level)}(r,s,o,l,i),h=sT;if(!t){if(r.number==(i?e.state.doc.lines:1))return l;h="\n",r=e.state.doc.line(r.number+(i?1:-1)),s=e.bidiSpans(r),t=e.visualLineSide(r,!i)}if(a){if(!a(h))return l}else{if(!n)return t;a=n(h)}l=t}}function oD(e,t,i){for(;;){let n=0;for(let r of e)r.between(t-1,t+1,(e,r,s)=>{if(t>e&&t<r){let s=n||i||(t-e<r-t?-1:1);t=s<0?e:r,n=s}});if(!n)return t}}function oR(e,t){let i=null;for(let n=0;n<t.ranges.length;n++){let r=t.ranges[n],s=null;if(r.empty){let t=oD(e,r.from,0);t!=r.from&&(s=nA.cursor(t,-1))}else{let t=oD(e,r.from,-1),i=oD(e,r.to,1);(t!=r.from||i!=r.to)&&(s=nA.range(r.from==r.anchor?t:i,r.from==r.head?t:i))}s&&(i||(i=t.ranges.slice()),i[n]=s)}return i?nA.create(i,t.mainIndex):t}function oP(e,t,i){let n=oD(e.state.facet(s2).map(t=>t(e)),i.from,t.head>i.from?-1:1);return n==i.from?i:nA.cursor(n,n<i.from?1:-1)}class oL{constructor(e,t){this.pos=e,this.assoc=t}}function oI(e,t,i,n){let r=e.contentDOM.getBoundingClientRect(),s=r.top+e.viewState.paddingTop,{x:o,y:l}=t,a=l-s,h;for(;;){if(a<0)return new oL(0,1);if(a>e.viewState.docHeight)return new oL(e.state.doc.length,-1);if(h=e.elementAtHeight(a),null==n)break;if(h.type==rY.Text){if(n<0?h.to<e.viewport.from:h.from>e.viewport.to)break;let t=e.docView.coordsAt(n<0?h.from:h.to,n>0?-1:1);if(t&&(n<0?t.top<=a+s:t.bottom>=a+s))break}let t=e.viewState.heightOracle.textHeight/2;a=n>0?h.bottom+t:h.top-t}if(e.viewport.from>=h.to||e.viewport.to<=h.from){if(i)return null;if(h.type==rY.Text){let t=function(e,t,i,n,r){let s=Math.round((n-t.left)*e.defaultCharacterWidth);if(e.lineWrapping&&i.height>1.5*e.defaultLineHeight){let t=e.viewState.heightOracle.textHeight;s+=Math.floor((r-i.top-(e.defaultLineHeight-t)*.5)/t)*e.viewState.heightOracle.lineLength}let o=e.state.sliceDoc(i.from,i.to);return i.from+rw(o,s,e.state.tabSize)}(e,r,h,o,l);return new oL(t,t==h.from?1:-1)}}if(h.type!=rY.Text)return a<(h.top+h.bottom)/2?new oL(h.from,1):new oL(h.to,-1);let c=e.docView.lineAt(h.from,2);return c&&c.length==h.length||(c=e.docView.lineAt(h.from,-2)),new oE(e,o,l,e.textDirectionAt(h.from)).scanTile(c,h.from)}class oE{constructor(e,t,i,n){this.view=e,this.x=t,this.y=i,this.baseDir=n,this.line=null,this.spans=null}bidiSpansAt(e){return(!this.line||this.line.from>e||this.line.to<e)&&(this.line=this.view.state.doc.lineAt(e),this.spans=this.view.bidiSpans(this.line)),this}baseDirAt(e,t){let{line:i,spans:n}=this.bidiSpansAt(e);return n[sM.find(n,e-i.from,-1,t)].level==this.baseDir}dirAt(e,t){let{line:i,spans:n}=this.bidiSpansAt(e);return n[sM.find(n,e-i.from,-1,t)].dir}bidiIn(e,t){let{spans:i,line:n}=this.bidiSpansAt(e);return i.length>1||i.length&&(i[0].level!=this.baseDir||i[0].to+n.from<t)}scan(e,t){let i,n,r=0,s=e.length-1,o=new Set,l=this.bidiIn(e[0],e[s]),a=-1,h=1e9,c;for(;r<s;){let d=s-r,u=r+s>>1;t:if(o.has(u)){let e=r+Math.floor(Math.random()*d);for(let t=0;t<d;t++){if(!o.has(e)){u=e;break t}++e==s&&(e=r)}break}o.add(u);let f=t(u);if(f)for(let t=0;t<f.length;t++){let o=f[t],d=0;if(o.bottom<this.y)(!i||i.bottom<o.bottom)&&(i=o),d=1;else if(o.top>this.y)(!n||n.top>o.top)&&(n=o),d=-1;else{let e=o.left>this.x?this.x-o.left:o.right<this.x?this.x-o.right:0,t=Math.abs(e);t<h&&(a=u,h=t,c=o),e&&(d=e<0==(this.baseDir==sg.LTR)?-1:1)}-1==d&&(!l||this.baseDirAt(e[u],1))?s=u:1==d&&(!l||this.baseDirAt(e[u+1],-1))&&(r=u+1)}}if(!c){let r=i&&(!n||this.y-i.bottom<n.top-this.y)?i:n;return this.y=(r.top+r.bottom)/2,this.scan(e,t)}let d=(l?this.dirAt(e[a],1):this.baseDir)==sg.LTR;return{i:a,after:this.x>(c.left+c.right)/2==d}}scanText(e,t){let i=[];for(let n=0;n<e.length;n=np(e.text,n))i.push(t+n);i.push(t+e.length);let n=this.scan(i,n=>{let r=i[n]-t,s=i[n+1]-t;return sc(e.dom,r,s).getClientRects()});return n.after?new oL(i[n.i+1],-1):new oL(i[n.i],1)}scanTile(e,t){if(!e.length)return new oL(t,1);if(1==e.children.length){let i=e.children[0];if(i.isText())return this.scanText(i,t);if(i.isComposite())return this.scanTile(i,t)}let i=[t];for(let n=0,r=t;n<e.children.length;n++)i.push(r+=e.children[n].length);let n=this.scan(i,t=>{let i=e.children[t];return 48&i.flags?null:(1==i.dom.nodeType?i.dom:sc(i.dom,0,i.length)).getClientRects()}),r=e.children[n.i],s=i[n.i];return r.isText()?this.scanText(r,s):r.isComposite()?this.scanTile(r,s):n.after?new oL(i[n.i+1],-1):new oL(s,1)}}class oB{constructor(e,t){this.points=e,this.view=t,this.text="",this.lineSeparator=t.state.facet(rt.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=""}readRange(e,t){if(!e)return this;let i=e.parentNode;for(let n=e;;){this.findPointBefore(i,n);let e=this.text.length;this.readNode(n);let r=ot.get(n),s=n.nextSibling;if(s==t){(null==r?void 0:r.breakAfter)&&!s&&i!=this.view.contentDOM&&this.lineBreak();break}let o=ot.get(s);(r&&o?r.breakAfter:(r?r.breakAfter:si(n))||si(s)&&("BR"!=n.nodeName||(null==r?void 0:r.isWidget()))&&this.text.length>e)&&!function(e,t){let i;for(;e!=t&&e;e=e.nextSibling){let t=ot.get(e);if(!(null==t?void 0:t.isWidget()))return!1;t&&(i||(i=[])).push(t)}if(i)for(let e of i){let t=e.overrideDOMText;if(null==t?void 0:t.length)return!1}return!0}(s,t)&&this.lineBreak(),n=s}return this.findPointBefore(i,t),this}readTextNode(e){let t=e.nodeValue;for(let i of this.points)i.node==e&&(i.pos=this.text.length+Math.min(i.offset,t.length));for(let i=0,n=this.lineSeparator?null:/\r\n?|\n/g;;){let r=-1,s=1,o;if(this.lineSeparator?(r=t.indexOf(this.lineSeparator,i),s=this.lineSeparator.length):(o=n.exec(t))&&(r=o.index,s=o[0].length),this.append(t.slice(i,r<0?t.length:r)),r<0)break;if(this.lineBreak(),s>1)for(let t of this.points)t.node==e&&t.pos>this.text.length&&(t.pos-=s-1);i=r+s}}readNode(e){let t=ot.get(e),i=t&&t.overrideDOMText;if(null!=i){this.findPointInside(e,i.length);for(let e=i.iter();!e.next().done;)e.lineBreak?this.lineBreak():this.append(e.value)}else 3==e.nodeType?this.readTextNode(e):"BR"==e.nodeName?e.nextSibling&&this.lineBreak():1==e.nodeType&&this.readRange(e.firstChild,null)}findPointBefore(e,t){for(let i of this.points)i.node==e&&e.childNodes[i.offset]==t&&(i.pos=this.text.length)}findPointInside(e,t){for(let i of this.points)(3==e.nodeType?i.node==e:e.contains(i.node))&&(i.pos=this.text.length+(!function(e,t,i){for(;;){if(!t||i<sr(t))return!1;if(t==e)return!0;i=st(t)+1,t=t.parentNode}}(e,i.node,i.offset)?0:t))}}class oN{constructor(e,t){this.node=e,this.offset=t,this.pos=-1}}class oz{constructor(e,t,i,n){this.typeOver=n,this.bounds=null,this.text="",this.domChanged=t>-1;let{impreciseHead:r,impreciseAnchor:s}=e.docView;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=function e(t,i,n,r){if(t.isComposite()){let s=-1,o=-1,l=-1,a=-1;for(let h=0,c=r,d=r;h<t.children.length;h++){let r=t.children[h],u=c+r.length;if(c<i&&u>n)return e(r,i,n,c);if(u>=i&&-1==s&&(s=h,o=c),c>n&&r.dom.parentNode==t.dom){l=h,a=d;break}d=u,c=u+r.breakAfter}return{from:o,to:a<0?r+t.length:a,startDOM:(s?t.children[s-1].dom.nextSibling:null)||t.dom.firstChild,endDOM:l<t.children.length&&l>=0?t.children[l].dom:null}}return t.isText()?{from:r,to:r+t.length,startDOM:t.dom,endDOM:t.dom.nextSibling}:null}(e.docView.tile,t,i,0))){let t=r||s?[]:function(e){let t=[];if(e.root.activeElement!=e.contentDOM)return t;let{anchorNode:i,anchorOffset:n,focusNode:r,focusOffset:s}=e.observer.selectionRange;return i&&(t.push(new oN(i,n)),(r!=i||s!=n)&&t.push(new oN(r,s))),t}(e),i=new oB(t,e);i.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=i.text,this.newSel=function(e,t){if(0==e.length)return null;let i=e[0].pos,n=2==e.length?e[1].pos:i;return i>-1&&n>-1?nA.single(i+t,n+t):null}(t,this.bounds.from)}else{let t=e.observer.selectionRange,i=r&&r.node==t.focusNode&&r.offset==t.focusOffset||!r8(e.contentDOM,t.focusNode)?e.state.selection.main.head:e.docView.posFromDOM(t.focusNode,t.focusOffset),n=s&&s.node==t.anchorNode&&s.offset==t.anchorOffset||!r8(e.contentDOM,t.anchorNode)?e.state.selection.main.anchor:e.docView.posFromDOM(t.anchorNode,t.anchorOffset),o=e.viewport;if((rK.ios||rK.chrome)&&e.state.selection.main.empty&&i!=n&&(o.from>0||o.to<e.state.doc.length)){let t=Math.min(i,n),r=Math.max(i,n),s=o.from-t,l=o.to-r;(0==s||1==s||0==t)&&(0==l||-1==l||r==e.state.doc.length)&&(i=0,n=e.state.doc.length)}e.inputState.composing>-1&&e.state.selection.ranges.length>1?this.newSel=e.state.selection.replaceRange(nA.range(n,i)):this.newSel=nA.single(n,i)}}}function oW(e,t){let i;let{newSel:n}=t,r=e.state.selection.main,s=e.inputState.lastKeyTime>Date.now()-100?e.inputState.lastKeyCode:-1;if(t.bounds){let{from:n,to:o}=t.bounds,l=r.from,a=null;(8===s||rK.android&&t.text.length<o-n)&&(l=r.to,a="end");let h=oV(e.state.doc.sliceString(n,o,""),t.text,l-n,a);h&&(rK.chrome&&13==s&&h.toB==h.from+2&&""==t.text.slice(h.from,h.toB)&&h.toB--,i={from:n+h.from,to:n+h.toA,insert:ns.of(t.text.slice(h.from,h.toB).split(""))})}else n&&(!e.hasFocus&&e.state.facet(sK)||oH(n,r))&&(n=null);if(!i&&!n)return!1;if(!i&&t.typeOver&&!r.empty&&n&&n.main.empty?i={from:r.from,to:r.to,insert:e.state.doc.slice(r.from,r.to)}:(rK.mac||rK.android)&&i&&i.from==i.to&&i.from==r.head-1&&/^\. ?$/.test(i.insert.toString())&&"off"==e.contentDOM.getAttribute("autocorrect")?(n&&2==i.insert.length&&(n=nA.single(n.main.anchor-1,n.main.head-1)),i={from:i.from,to:i.to,insert:ns.of([i.insert.toString().replace("."," ")])}):i&&i.from>=r.from&&i.to<=r.to&&(i.from!=r.from||i.to!=r.to)&&r.to-r.from-(i.to-i.from)<=4?i={from:r.from,to:r.to,insert:e.state.doc.slice(r.from,i.from).append(i.insert).append(e.state.doc.slice(i.to,r.to))}:e.state.doc.lineAt(r.from).to<r.to&&e.docView.lineHasWidget(r.to)&&e.inputState.insertingTextAt>Date.now()-50?i={from:r.from,to:r.to,insert:e.state.toText(e.inputState.insertingText)}:rK.chrome&&i&&i.from==i.to&&i.from==r.head&&"\n "==i.insert.toString()&&e.lineWrapping&&(n&&(n=nA.single(n.main.anchor-1,n.main.head-1)),i={from:r.from,to:r.to,insert:ns.of([" "])}),i)return oF(e,i,n,s);if(!n||oH(n,r))return!1;{let t=!1,i="select";return e.inputState.lastSelectionTime>Date.now()-50&&("select"==e.inputState.lastSelectionOrigin&&(t=!0),"select.pointer"==(i=e.inputState.lastSelectionOrigin)&&(n=oR(e.state.facet(s2).map(t=>t(e)),n))),e.dispatch({selection:n,scrollIntoView:t,userEvent:i}),!0}}function oF(e,t,i,n=-1){let r;if(rK.ios&&e.inputState.flushIOSKey(t))return!0;let s=e.state.selection.main;if(rK.android&&(t.to==s.to&&(t.from==s.from||t.from==s.from-1&&" "==e.state.sliceDoc(t.from,s.from))&&1==t.insert.length&&2==t.insert.lines&&sd(e.contentDOM,"Enter",13)||(t.from==s.from-1&&t.to==s.to&&0==t.insert.length||8==n&&t.insert.length<t.to-t.from&&t.to>s.head)&&sd(e.contentDOM,"Backspace",8)||t.from==s.from&&t.to==s.to+1&&0==t.insert.length&&sd(e.contentDOM,"Delete",46)))return!0;let o=t.insert.toString();e.inputState.composing>=0&&e.inputState.composing++;let l=()=>r||(r=function(e,t,i){let n,r=e.state,s=r.selection.main,o=-1;if(t.from==t.to&&t.from<s.from||t.from>s.to){let i=t.from<s.from?-1:1,n=i<0?s.from:s.to,l=oD(r.facet(s2).map(t=>t(e)),n,i);t.from==l&&(o=l)}if(o>-1)n={changes:t,selection:nA.cursor(t.from+t.insert.length,-1)};else if(t.from>=s.from&&t.to<=s.to&&t.to-t.from>=(s.to-s.from)/3&&(!i||i.main.empty&&i.main.from==t.from+t.insert.length)&&e.inputState.composing<0){let i=s.from<t.from?r.sliceDoc(s.from,t.from):"",o=s.to>t.to?r.sliceDoc(t.to,s.to):"";n=r.replaceSelection(e.state.toText(i+t.insert.sliceString(0,void 0,e.state.lineBreak)+o))}else{let o=r.changes(t),l=i&&i.main.to<=o.newLength?i.main:void 0;if(r.selection.ranges.length>1&&(e.inputState.composing>=0||e.inputState.compositionPendingChange)&&t.to<=s.to+10&&t.to>=s.to-10){let a=e.state.sliceDoc(t.from,t.to),h,c=i&&oj(e,i.main.head);if(c){let e=t.insert.length-(t.to-t.from);h={from:c.from,to:c.to-e}}else h=e.state.doc.lineAt(s.head);let d=s.to-t.to;n=r.changeByRange(i=>{if(i.from==s.from&&i.to==s.to)return{changes:o,range:l||i.map(o)};let n=i.to-d,c=n-a.length;if(e.state.sliceDoc(c,n)!=a||n>=h.from&&c<=h.to)return{range:i};let u=r.changes({from:c,to:n,insert:t.insert}),f=i.to-s.to;return{changes:u,range:l?nA.range(Math.max(0,l.anchor+f),Math.max(0,l.head+f)):i.map(u)}})}else n={changes:o,selection:l&&r.selection.replaceRange(l)}}let l="input.type";return(e.composing||e.inputState.compositionPendingChange&&e.inputState.compositionEndedAt>Date.now()-50)&&(e.inputState.compositionPendingChange=!1,l+=".compose",e.inputState.compositionFirstChange&&(l+=".start",e.inputState.compositionFirstChange=!1)),r.update(n,{userEvent:l,scrollIntoView:!0})}(e,t,i));return e.state.facet(sI).some(i=>i(e,t.from,t.to,o,l))||e.dispatch(l()),!0}function oV(e,t,i,n){let r=Math.min(e.length,t.length),s=0;for(;s<r&&e.charCodeAt(s)==t.charCodeAt(s);)s++;if(s==r&&e.length==t.length)return null;let o=e.length,l=t.length;for(;o>0&&l>0&&e.charCodeAt(o-1)==t.charCodeAt(l-1);)o--,l--;if("end"==n){let e=Math.max(0,s-Math.min(o,l));i-=o+e-s}if(o<s&&e.length<t.length){let e=i<=s&&i>=o?s-i:0;s-=e,l=s+(l-o),o=s}else if(l<s){let e=i<=s&&i>=l?s-i:0;s-=e,o=s+(o-l),l=s}return{from:s,toA:o,toB:l}}function oH(e,t){return t.head==e.main.head&&t.anchor==e.main.anchor}class o${setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.pendingIOSKey=void 0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,rK.safari&&e.contentDOM.addEventListener("input",()=>null),rK.gecko&&function(e){ln.has(e)||(ln.add(e),e.addEventListener("copy",()=>{}),e.addEventListener("cut",()=>{}))}(e.contentDOM.ownerDocument)}handleEvent(e){!(!function(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let i=t.target,n;i!=e.contentDOM;i=i.parentNode)if(!i||11==i.nodeType||(n=ot.get(i))&&n.isWidget()&&!n.isHidden&&n.widget.ignoreEvent(t))return!1;return!0}(this.view,e)||this.ignoreDuringComposition(e))&&("keydown"==e.type&&this.keydown(e)||(0!=this.view.updateState?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e)))}runHandlers(e,t){let i=this.handlers[e];if(i){for(let e of i.observers)e(this.view,t);for(let e of i.handlers){if(t.defaultPrevented)break;if(e(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=function(e){let t=Object.create(null);function i(e){return t[e]||(t[e]={observers:[],handlers:[]})}for(let t of e){let e=t.spec,n=e&&e.plugin.domEventHandlers,r=e&&e.plugin.domEventObservers;if(n)for(let e in n){let r=n[e];r&&i(e).handlers.push(oq(t.value,r))}if(r)for(let e in r){let n=r[e];n&&i(e).observers.push(oq(t.value,n))}}for(let e in oX)i(e).handlers.push(oX[e]);for(let e in oY)i(e).observers.push(oY[e]);return t}(e),i=this.handlers,n=this.view.contentDOM;for(let e in t)if("scroll"!=e){let r=!t[e].handlers.length,s=i[e];s&&!s.handlers.length!=r&&(n.removeEventListener(e,this.handleEvent),s=null),s||n.addEventListener(e,this.handleEvent,{passive:r})}for(let e in i)"scroll"==e||t[e]||n.removeEventListener(e,this.handleEvent);this.handlers=t}keydown(e){let t;return this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),!!(9==e.keyCode&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))||((this.tabFocusMode>0&&27!=e.keyCode&&0>o_.indexOf(e.keyCode)&&(this.tabFocusMode=-1),rK.android&&rK.chrome&&!e.synthetic&&(13==e.keyCode||8==e.keyCode))?(this.view.observer.delayAndroidKey(e.key,e.keyCode),!0):rK.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&((t=oK.find(t=>t.keyCode==e.keyCode))&&!e.ctrlKey||oU.indexOf(e.key)>-1&&e.ctrlKey&&!e.shiftKey)?(this.pendingIOSKey=t||e,setTimeout(()=>this.flushIOSKey(),250),!0):(229!=e.keyCode&&this.view.observer.forceFlush(),!1))}flushIOSKey(e){let t=this.pendingIOSKey;return!(!t||"Enter"==t.key&&e&&e.from<e.to&&/^\S+$/.test(e.insert.toString()))&&(this.pendingIOSKey=void 0,sd(this.view.contentDOM,t.key,t.keyCode,t instanceof KeyboardEvent?t:void 0))}ignoreDuringComposition(e){return!!/^key/.test(e.type)&&!e.synthetic&&(this.composing>0||!!(rK.safari&&!rK.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100)&&(this.compositionPendingKey=!1,!0))}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function oq(e,t){return(i,n)=>{try{return t.call(e,n,i)}catch(e){sq(i.state,e)}}}let oK=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],oU="dthko",o_=[16,17,18,20,91,92,224,225];function oG(e){return .7*Math.max(0,e)+8}class oJ{constructor(e,t,i,n){this.view=e,this.startEvent=t,this.style=i,this.mustSelect=n,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParents=function(e){let t=e.ownerDocument,i,n;for(let r=e.parentNode;r&&r!=t.body&&(!i||!n);)if(1==r.nodeType)!n&&r.scrollHeight>r.clientHeight&&(n=r),!i&&r.scrollWidth>r.clientWidth&&(i=r),r=r.assignedSlot||r.parentNode;else if(11==r.nodeType)r=r.host;else break;return{x:i,y:n}}(e.contentDOM),this.atoms=e.state.facet(s2).map(t=>t(e));let r=e.contentDOM.ownerDocument;r.addEventListener("mousemove",this.move=this.move.bind(this)),r.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(rt.allowMultipleSelections)&&function(e,t){let i=e.state.facet(sO);return i.length?i[0](t):rK.mac?t.metaKey:t.ctrlKey}(e,t),this.dragging=!!function(e,t){let{main:i}=e.state.selection;if(i.empty)return!1;let n=r3(e.root);if(!n||0==n.rangeCount)return!0;let r=n.getRangeAt(0).getClientRects();for(let e=0;e<r.length;e++){let i=r[e];if(i.left<=t.clientX&&i.right>=t.clientX&&i.top<=t.clientY&&i.bottom>=t.clientY)return!0}return!1}(e,t)&&1==o8(t)&&null}start(e){!1===this.dragging&&this.select(e)}move(e){var t;if(0==e.buttons)return this.destroy();if(this.dragging||null==this.dragging&&10>Math.max(Math.abs((t=this.startEvent).clientX-e.clientX),Math.abs(t.clientY-e.clientY)))return;this.select(this.lastEvent=e);let i=0,n=0,r=0,s=0,o=this.view.win.innerWidth,l=this.view.win.innerHeight;this.scrollParents.x&&({left:r,right:o}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:s,bottom:l}=this.scrollParents.y.getBoundingClientRect());let a=s3(this.view);e.clientX-a.left<=r+6?i=-oG(r-e.clientX):e.clientX+a.right>=o-6&&(i=oG(e.clientX-o)),e.clientY-a.top<=s+6?n=-oG(s-e.clientY):e.clientY+a.bottom>=l-6&&(n=oG(e.clientY-l)),this.setScrollSpeed(i,n)}up(e){null==this.dragging&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,t){this.scrollSpeed={x:e,y:t},e||t?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:t}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),t&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=t,t=0),(e||t)&&this.view.win.scrollBy(e,t),!1===this.dragging&&this.select(this.lastEvent)}select(e){let{view:t}=this,i=oR(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!i.eq(t.state.selection,!1===this.dragging))&&this.view.dispatch({selection:i,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(e=>e.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}let oX=Object.create(null),oY=Object.create(null),oQ=rK.ie&&rK.ie_version<15||rK.ios&&rK.webkit_version<604;function o0(e,t,i){for(let n of e.facet(t))i=n(i,e);return i}function o1(e,t){t=o0(e.state,sB,t);let{state:i}=e,n,r=1,s=i.toText(t),o=s.lines==i.selection.ranges.length;if(null!=o7&&i.selection.ranges.every(e=>e.empty)&&o7==s.toString()){let e=-1;n=i.changeByRange(n=>{let l=i.doc.lineAt(n.from);if(l.from==e)return{range:n};e=l.from;let a=i.toText((o?s.line(r++).text:t)+i.lineBreak);return{changes:{from:l.from,insert:a},range:nA.cursor(n.from+a.length)}})}else n=o?i.changeByRange(e=>{let t=s.line(r++);return{changes:{from:e.from,to:e.to,insert:t.text},range:nA.cursor(e.from+t.length)}}):i.replaceSelection(s);e.dispatch(n,{userEvent:"input.paste",scrollIntoView:!0})}function o2(e,t,i,n){if(1==n)return nA.cursor(t,i);if(2==n)return function(e,t,i=1){let n=e.charCategorizer(t),r=e.doc.lineAt(t),s=t-r.from;if(0==r.length)return nA.cursor(t);0==s?i=1:s==r.length&&(i=-1);let o=s,l=s;i<0?o=np(r.text,s,!1):l=np(r.text,s);let a=n(r.text.slice(o,l));for(;o>0;){let e=np(r.text,o,!1);if(n(r.text.slice(e,o))!=a)break;o=e}for(;l<r.length;){let e=np(r.text,l);if(n(r.text.slice(l,e))!=a)break;l=e}return nA.range(o+r.from,l+r.from)}(e.state,t,i);{let n=e.docView.lineAt(t,i),r=e.state.doc.lineAt(n?n.posAtEnd:t),s=n?n.posAtStart:r.from,o=n?n.posAtEnd:r.to;return o<e.state.doc.length&&o==r.to&&o++,nA.range(s,o)}}oY.scroll=e=>{e.inputState.lastScrollTop=e.scrollDOM.scrollTop,e.inputState.lastScrollLeft=e.scrollDOM.scrollLeft},oX.keydown=(e,t)=>(e.inputState.setSelectionOrigin("select"),27==t.keyCode&&0!=e.inputState.tabFocusMode&&(e.inputState.tabFocusMode=Date.now()+2e3),!1),oY.touchstart=(e,t)=>{e.inputState.lastTouchTime=Date.now(),e.inputState.setSelectionOrigin("select.pointer")},oY.touchmove=e=>{e.inputState.setSelectionOrigin("select.pointer")},oX.mousedown=(e,t)=>{if(e.observer.flush(),e.inputState.lastTouchTime>Date.now()-2e3)return!1;let i=null;for(let n of e.state.facet(sR))if(i=n(e,t))break;if(i||0!=t.button||(i=function(e,t){let i=e.posAndSideAtCoords({x:t.clientX,y:t.clientY},!1),n=o8(t),r=e.state.selection;return{update(e){e.docChanged&&(i.pos=e.changes.mapPos(i.pos),r=r.map(e.changes))},get(t,s,o){let l=e.posAndSideAtCoords({x:t.clientX,y:t.clientY},!1),a,h=o2(e,l.pos,l.assoc,n);if(i.pos!=l.pos&&!s){let t=o2(e,i.pos,i.assoc,n),r=Math.min(t.from,h.from),s=Math.max(t.to,h.to);h=r<h.from?nA.range(r,s):nA.range(s,r)}return s?r.replaceRange(r.main.extend(h.from,h.to)):o&&1==n&&r.ranges.length>1&&(a=function(e,t){for(let i=0;i<e.ranges.length;i++){let{from:n,to:r}=e.ranges[i];if(n<=t&&r>=t)return nA.create(e.ranges.slice(0,i).concat(e.ranges.slice(i+1)),e.mainIndex==i?0:e.mainIndex-(e.mainIndex>i?1:0))}return null}(r,l.pos))?a:o?r.addRange(h):nA.create([h])}}}(e,t)),i){let n=!e.hasFocus;e.inputState.startMouseSelection(new oJ(e,t,i,n)),n&&e.observer.ignore(()=>{sh(e.contentDOM);let t=e.root.activeElement;t&&!t.contains(e.contentDOM)&&t.blur()});let r=e.inputState.mouseSelection;if(r)return r.start(t),!1===r.dragging}else e.inputState.setSelectionOrigin("select.pointer");return!1};let o5=rK.ie&&rK.ie_version<=11,o6=null,o4=0,o3=0;function o8(e){if(!o5)return e.detail;let t=o6,i=o3;return o6=e,o3=Date.now(),o4=!t||i>Date.now()-400&&2>Math.abs(t.clientX-e.clientX)&&2>Math.abs(t.clientY-e.clientY)?(o4+1)%3:1}function o9(e,t,i,n){let r;if(!(i=o0(e.state,sB,i)))return;let s=e.posAtCoords({x:t.clientX,y:t.clientY},!1),{draggedContent:o}=e.inputState,l=n&&o&&((r=e.state.facet(sD)).length?r[0](t):rK.mac?!t.altKey:!t.ctrlKey)?{from:o.from,to:o.to}:null,a={from:s,insert:i},h=e.state.changes(l?[l,a]:a);e.focus(),e.dispatch({changes:h,selection:{anchor:h.mapPos(s,-1),head:h.mapPos(s,1)},userEvent:l?"move.drop":"input.drop"}),e.inputState.draggedContent=null}oX.dragstart=(e,t)=>{let{selection:{main:i}}=e.state;if(t.target.draggable){let n=e.docView.tile.nearest(t.target);if(n&&n.isWidget()){let e=n.posAtStart,t=e+n.length;(e>=i.to||t<=i.from)&&(i=nA.range(e,t))}}let{inputState:n}=e;return n.mouseSelection&&(n.mouseSelection.dragging=!0),n.draggedContent=i,t.dataTransfer&&(t.dataTransfer.setData("Text",o0(e.state,sN,e.state.sliceDoc(i.from,i.to))),t.dataTransfer.effectAllowed="copyMove"),!1},oX.dragend=e=>(e.inputState.draggedContent=null,!1),oX.drop=(e,t)=>{if(!t.dataTransfer)return!1;if(e.state.readOnly)return!0;let i=t.dataTransfer.files;if(i&&i.length){let n=Array(i.length),r=0,s=()=>{++r==i.length&&o9(e,t,n.filter(e=>null!=e).join(e.state.lineBreak),!1)};for(let e=0;e<i.length;e++){let t=new FileReader;t.onerror=s,t.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(t.result)||(n[e]=t.result),s()},t.readAsText(i[e])}return!0}{let i=t.dataTransfer.getData("Text");if(i)return o9(e,t,i,!0),!0}return!1},oX.paste=(e,t)=>{if(e.state.readOnly)return!0;e.observer.flush();let i=oQ?null:t.clipboardData;return i?(o1(e,i.getData("text/plain")||i.getData("text/uri-list")),!0):(function(e){let t=e.dom.parentNode;if(!t)return;let i=t.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.focus(),setTimeout(()=>{e.focus(),i.remove(),o1(e,i.value)},50)}(e),!1)};let o7=null;oX.copy=oX.cut=(e,t)=>{if(!r9(e.contentDOM,e.observer.selectionRange))return!1;let{text:i,ranges:n,linewise:r}=function(e){let t=[],i=[],n=!1;for(let n of e.selection.ranges)n.empty||(t.push(e.sliceDoc(n.from,n.to)),i.push(n));if(!t.length){let r=-1;for(let{from:n}of e.selection.ranges){let s=e.doc.lineAt(n);s.number>r&&(t.push(s.text),i.push({from:s.from,to:Math.min(e.doc.length,s.to+1)})),r=s.number}n=!0}return{text:o0(e,sN,t.join(e.lineBreak)),ranges:i,linewise:n}}(e.state);if(!i&&!r)return!1;o7=r?i:null,"cut"!=t.type||e.state.readOnly||e.dispatch({changes:n,scrollIntoView:!0,userEvent:"delete.cut"});let s=oQ?null:t.clipboardData;return s?(s.clearData(),s.setData("text/plain",i),!0):(function(e,t){let i=e.dom.parentNode;if(!i)return;let n=i.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.value=t,n.focus(),n.selectionEnd=t.length,n.selectionStart=0,setTimeout(()=>{n.remove(),e.focus()},50)}(e,i),!1)};let le=n0.define();function lt(e,t){let i=[];for(let n of e.facet(sE)){let r=n(e,t);r&&i.push(r)}return i.length?e.update({effects:i,annotations:le.of(!0)}):null}function li(e){setTimeout(()=>{let t=e.hasFocus;if(t!=e.inputState.notifiedFocused){let i=lt(e.state,t);i?e.dispatch(i):e.update([])}},10)}oY.focus=e=>{e.inputState.lastFocusTime=Date.now(),!e.scrollDOM.scrollTop&&(e.inputState.lastScrollTop||e.inputState.lastScrollLeft)&&(e.scrollDOM.scrollTop=e.inputState.lastScrollTop,e.scrollDOM.scrollLeft=e.inputState.lastScrollLeft),li(e)},oY.blur=e=>{e.observer.clearSelectionRange(),li(e)},oY.compositionstart=oY.compositionupdate=e=>{!e.observer.editContext&&(null==e.inputState.compositionFirstChange&&(e.inputState.compositionFirstChange=!0),e.inputState.composing<0&&(e.inputState.composing=0))},oY.compositionend=e=>{e.observer.editContext||(e.inputState.composing=-1,e.inputState.compositionEndedAt=Date.now(),e.inputState.compositionPendingKey=!0,e.inputState.compositionPendingChange=e.observer.pendingRecords().length>0,e.inputState.compositionFirstChange=null,rK.chrome&&rK.android?e.observer.flushSoon():e.inputState.compositionPendingChange?Promise.resolve().then(()=>e.observer.flush()):setTimeout(()=>{e.inputState.composing<0&&e.docView.hasComposition&&e.update([])},50))},oY.contextmenu=e=>{e.inputState.lastContextMenu=Date.now()},oX.beforeinput=(e,t)=>{var i,n;let r;if(("insertText"==t.inputType||"insertCompositionText"==t.inputType)&&(e.inputState.insertingText=t.data,e.inputState.insertingTextAt=Date.now()),"insertReplacementText"==t.inputType&&e.observer.editContext){let n=null===(i=t.dataTransfer)||void 0===i?void 0:i.getData("text/plain"),r=t.getTargetRanges();if(n&&r.length){let t=r[0],i=e.posAtDOM(t.startContainer,t.startOffset),s=e.posAtDOM(t.endContainer,t.endOffset);return oF(e,{from:i,to:s,insert:e.state.toText(n)},null),!0}}if(rK.chrome&&rK.android&&(r=oK.find(e=>e.inputType==t.inputType))&&(e.observer.delayAndroidKey(r.key,r.keyCode),"Backspace"==r.key||"Delete"==r.key)){let t=(null===(n=window.visualViewport)||void 0===n?void 0:n.height)||0;setTimeout(()=>{var i;((null===(i=window.visualViewport)||void 0===i?void 0:i.height)||0)>t+10&&e.hasFocus&&(e.contentDOM.blur(),e.focus())},100)}return rK.ios&&"deleteContentForward"==t.inputType&&e.observer.flushSoon(),rK.safari&&"insertText"==t.inputType&&e.inputState.composing>=0&&setTimeout(()=>oY.compositionend(e,t),20),!1};let ln=new Set,lr=["pre-wrap","normal","pre-line","break-spaces"],ls=!1;class lo{constructor(e){this.lineWrapping=e,this.doc=ns.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,t){let i=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(i+=Math.max(0,Math.ceil((t-e-i*this.lineLength*.5)/this.lineLength))),this.lineHeight*i}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return lr.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let i=0;i<e.length;i++){let n=e[i];n<0?i++:this.heightSamples[Math.floor(10*n)]||(t=!0,this.heightSamples[Math.floor(10*n)]=!0)}return t}refresh(e,t,i,n,r,s){let o=lr.indexOf(e)>-1,l=Math.abs(t-this.lineHeight)>.3||this.lineWrapping!=o||Math.abs(i-this.charWidth)>.1;if(this.lineWrapping=o,this.lineHeight=t,this.charWidth=i,this.textHeight=n,this.lineLength=r,l){this.heightSamples={};for(let e=0;e<s.length;e++){let t=s[e];t<0?e++:this.heightSamples[Math.floor(10*t)]=!0}}return l}}class ll{constructor(e,t){this.from=e,this.heights=t,this.index=0}get more(){return this.index<this.heights.length}}class la{constructor(e,t,i,n,r){this.from=e,this.length=t,this.top=i,this.height=n,this._content=r}get type(){return"number"==typeof this._content?rY.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof r2?this._content.widget:null}get widgetLineBreaks(){return"number"==typeof this._content?this._content:0}join(e){let t=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(e._content)?e._content:[e]);return new la(this.from,this.length+e.length,this.top,this.height+e.height,t)}}var lh=function(e){return e[e.ByPos=0]="ByPos",e[e.ByHeight=1]="ByHeight",e[e.ByPosNoHeight=2]="ByPosNoHeight",e}(lh||(lh={}));class lc{constructor(e,t,i=2){this.length=e,this.height=t,this.flags=i}get outdated(){return(2&this.flags)>0}set outdated(e){this.flags=(e?2:0)|-3&this.flags}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>.001&&(ls=!0),this.height=e)}replace(e,t,i){return lc.of(i)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,i,n){let r=this,s=i.doc;for(let o=n.length-1;o>=0;o--){let{fromA:l,toA:a,fromB:h,toB:c}=n[o],d=r.lineAt(l,lh.ByPosNoHeight,i.setDoc(t),0,0),u=d.to>=a?d:r.lineAt(a,lh.ByPosNoHeight,i,0,0);for(c+=u.to-a,a=u.to;o>0&&d.from<=n[o-1].toA;)l=n[o-1].fromA,h=n[o-1].fromB,o--,l<d.from&&(d=r.lineAt(l,lh.ByPosNoHeight,i,0,0));h+=d.from-l,l=d.from;let f=lv.build(i.setDoc(s),e,h,c);r=ld(r,r.replace(l,a,f))}return r.updateHeight(i,0)}static empty(){return new lp(0,0,0)}static of(e){if(1==e.length)return e[0];let t=0,i=e.length,n=0,r=0;for(;;)if(t==i){if(n>2*r){let r=e[t-1];r.break?e.splice(--t,1,r.left,null,r.right):e.splice(--t,1,r.left,r.right),i+=1+r.break,n-=r.size}else if(r>2*n){let t=e[i];t.break?e.splice(i,1,t.left,null,t.right):e.splice(i,1,t.left,t.right),i+=2+t.break,r-=t.size}else break}else if(n<r){let i=e[t++];i&&(n+=i.size)}else{let t=e[--i];t&&(r+=t.size)}let s=0;return null==e[t-1]?(s=1,t--):null==e[t]&&(s=1,i++),new lg(lc.of(e.slice(0,t)),s,lc.of(e.slice(i)))}}function ld(e,t){return e==t?e:(e.constructor!=t.constructor&&(ls=!0),t)}lc.prototype.size=1;let lu=rQ.replace({});class lf extends lc{constructor(e,t,i){super(e,t),this.deco=i,this.spaceAbove=0}mainBlock(e,t){return new la(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.deco||0)}blockAt(e,t,i,n){return this.spaceAbove&&e<i+this.spaceAbove?new la(n,0,i,this.spaceAbove,lu):this.mainBlock(i,n)}lineAt(e,t,i,n,r){let s=this.mainBlock(n,r);return this.spaceAbove?this.blockAt(0,i,n,r).join(s):s}forEachLine(e,t,i,n,r,s){e<=r+this.length&&t>=r&&s(this.lineAt(0,lh.ByPos,i,n,r))}setMeasuredHeight(e){let t=e.heights[e.index++];t<0?(this.spaceAbove=-t,t=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(t)}updateHeight(e,t=0,i=!1,n){return n&&n.from<=t&&n.more&&this.setMeasuredHeight(n),this.outdated=!1,this}toString(){return`block(${this.length})`}}class lp extends lf{constructor(e,t,i){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=i}mainBlock(e,t){return new la(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,t,i){let n=i[0];return 1==i.length&&(n instanceof lp||n instanceof lm&&4&n.flags)&&10>Math.abs(this.length-n.length)?(n instanceof lm?n=new lp(n.length,this.height,this.spaceAbove):n.height=this.height,this.outdated||(n.outdated=!1),n):lc.of(i)}updateHeight(e,t=0,i=!1,n){return n&&n.from<=t&&n.more?this.setMeasuredHeight(n):(i||this.outdated)&&(this.spaceAbove=0,this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight)),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class lm extends lc{constructor(e){super(e,0)}heightMetrics(e,t){let i=e.doc.lineAt(t).number,n=e.doc.lineAt(t+this.length).number,r=n-i+1,s,o=0;if(e.lineWrapping){let t=Math.min(this.height,e.lineHeight*r);s=t/r,this.length>r+1&&(o=(this.height-t)/(this.length-r-1))}else s=this.height/r;return{firstLine:i,lastLine:n,perLine:s,perChar:o}}blockAt(e,t,i,n){let{firstLine:r,lastLine:s,perLine:o,perChar:l}=this.heightMetrics(t,n);if(t.lineWrapping){let r=n+(e<t.lineHeight?0:Math.round(Math.max(0,Math.min(1,(e-i)/this.height))*this.length)),s=t.doc.lineAt(r),a=o+s.length*l;return new la(s.from,s.length,Math.max(i,e-a/2),a,0)}{let n=Math.max(0,Math.min(s-r,Math.floor((e-i)/o))),{from:l,length:a}=t.doc.line(r+n);return new la(l,a,i+o*n,o,0)}}lineAt(e,t,i,n,r){if(t==lh.ByHeight)return this.blockAt(e,i,n,r);if(t==lh.ByPosNoHeight){let{from:t,to:n}=i.doc.lineAt(e);return new la(t,n-t,0,0,0)}let{firstLine:s,perLine:o,perChar:l}=this.heightMetrics(i,r),a=i.doc.lineAt(e),h=o+a.length*l,c=a.number-s,d=n+o*c+l*(a.from-r-c);return new la(a.from,a.length,Math.max(n,Math.min(d,n+this.height-h)),h,0)}forEachLine(e,t,i,n,r,s){e=Math.max(e,r),t=Math.min(t,r+this.length);let{firstLine:o,perLine:l,perChar:a}=this.heightMetrics(i,r);for(let h=e,c=n;h<=t;){let t=i.doc.lineAt(h);if(h==e){let i=t.number-o;c+=l*i+a*(e-r-i)}let n=l+a*t.length;s(new la(t.from,t.length,c,n,0)),c+=n,h=t.to+1}}replace(e,t,i){let n=this.length-t;if(n>0){let e=i[i.length-1];e instanceof lm?i[i.length-1]=new lm(e.length+n):i.push(null,new lm(n-1))}if(e>0){let t=i[0];t instanceof lm?i[0]=new lm(e+t.length):i.unshift(new lm(e-1),null)}return lc.of(i)}decomposeLeft(e,t){t.push(new lm(e-1),null)}decomposeRight(e,t){t.push(null,new lm(this.length-e-1))}updateHeight(e,t=0,i=!1,n){let r=t+this.length;if(n&&n.from<=t+this.length&&n.more){let i=[],s=Math.max(t,n.from),o=-1;for(n.from>t&&i.push(new lm(n.from-t-1).updateHeight(e,t));s<=r&&n.more;){let t=e.doc.lineAt(s).length;i.length&&i.push(null);let r=n.heights[n.index++],l=0;r<0&&(l=-r,r=n.heights[n.index++]),-1==o?o=r:Math.abs(r-o)>=.001&&(o=-2);let a=new lp(t,r,l);a.outdated=!1,i.push(a),s+=t+1}s<=r&&i.push(null,new lm(r-s).updateHeight(e,s));let l=lc.of(i);return(o<0||Math.abs(l.height-this.height)>=.001||Math.abs(o-this.heightMetrics(e,t).perLine)>=.001)&&(ls=!0),ld(this,l)}return(i||this.outdated)&&(this.setHeight(e.heightForGap(t,t+this.length)),this.outdated=!1),this}toString(){return`gap(${this.length})`}}class lg extends lc{constructor(e,t,i){super(e.length+t+i.length,e.height+i.height,t|(e.outdated||i.outdated?2:0)),this.left=e,this.right=i,this.size=e.size+i.size}get break(){return 1&this.flags}blockAt(e,t,i,n){let r=i+this.left.height;return e<r?this.left.blockAt(e,t,i,n):this.right.blockAt(e,t,r,n+this.left.length+this.break)}lineAt(e,t,i,n,r){let s=n+this.left.height,o=r+this.left.length+this.break,l=t==lh.ByHeight?e<s:e<o,a=l?this.left.lineAt(e,t,i,n,r):this.right.lineAt(e,t,i,s,o);if(this.break||(l?a.to<o:a.from>o))return a;let h=t==lh.ByPosNoHeight?lh.ByPosNoHeight:lh.ByPos;return l?a.join(this.right.lineAt(o,h,i,s,o)):this.left.lineAt(o,h,i,n,r).join(a)}forEachLine(e,t,i,n,r,s){let o=n+this.left.height,l=r+this.left.length+this.break;if(this.break)e<l&&this.left.forEachLine(e,t,i,n,r,s),t>=l&&this.right.forEachLine(e,t,i,o,l,s);else{let a=this.lineAt(l,lh.ByPos,i,n,r);e<a.from&&this.left.forEachLine(e,a.from-1,i,n,r,s),a.to>=e&&a.from<=t&&s(a),t>a.to&&this.right.forEachLine(a.to+1,t,i,o,l,s)}}replace(e,t,i){let n=this.left.length+this.break;if(t<n)return this.balanced(this.left.replace(e,t,i),this.right);if(e>this.left.length)return this.balanced(this.left,this.right.replace(e-n,t-n,i));let r=[];e>0&&this.decomposeLeft(e,r);let s=r.length;for(let e of i)r.push(e);if(e>0&&lx(r,s-1),t<this.length){let e=r.length;this.decomposeRight(t,r),lx(r,e)}return lc.of(r)}decomposeLeft(e,t){let i=this.left.length;if(e<=i)return this.left.decomposeLeft(e,t);t.push(this.left),this.break&&e>=++i&&t.push(null),e>i&&this.right.decomposeLeft(e-i,t)}decomposeRight(e,t){let i=this.left.length,n=i+this.break;if(e>=n)return this.right.decomposeRight(e-n,t);e<i&&this.left.decomposeRight(e,t),this.break&&e<n&&t.push(null),t.push(this.right)}balanced(e,t){return e.size>2*t.size||t.size>2*e.size?lc.of(this.break?[e,null,t]:[e,t]):(this.left=ld(this.left,e),this.right=ld(this.right,t),this.setHeight(e.height+t.height),this.outdated=e.outdated||t.outdated,this.size=e.size+t.size,this.length=e.length+this.break+t.length,this)}updateHeight(e,t=0,i=!1,n){let{left:r,right:s}=this,o=t+r.length+this.break,l=null;return(n&&n.from<=t+r.length&&n.more?l=r=r.updateHeight(e,t,i,n):r.updateHeight(e,t,i),n&&n.from<=o+s.length&&n.more?l=s=s.updateHeight(e,o,i,n):s.updateHeight(e,o,i),l)?this.balanced(r,s):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function lx(e,t){let i,n;null==e[t]&&(i=e[t-1])instanceof lm&&(n=e[t+1])instanceof lm&&e.splice(t-1,3,new lm(i.length+1+n.length))}class lv{constructor(e,t){this.pos=e,this.oracle=t,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,t){if(this.lineStart>-1){let e=Math.min(t,this.lineEnd),i=this.nodes[this.nodes.length-1];i instanceof lp?i.length+=e-this.pos:(e>this.pos||!this.isCovered)&&this.nodes.push(new lp(e-this.pos,-1,0)),this.writtenTo=e,t>e&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,i){if(e<t||i.heightRelevant){let n=i.widget?i.widget.estimatedHeight:0,r=i.widget?i.widget.lineBreaks:0;n<0&&(n=this.oracle.lineHeight);let s=t-e;i.block?this.addBlock(new lf(s,n,i)):(s||r||n>=5)&&this.addLineDeco(n,r,s)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenTo<e&&((this.writtenTo<e-1||null==this.nodes[this.nodes.length-1])&&this.nodes.push(this.blankContent(this.writtenTo,e-1)),this.nodes.push(null)),this.pos>e&&this.nodes.push(new lp(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,t){let i=new lm(t-e);return this.oracle.doc.lineAt(e).to==t&&(i.flags|=4),i}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof lp)return e;let t=new lp(0,-1,0);return this.nodes.push(t),t}addBlock(e){this.enterLine();let t=e.deco;t&&t.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,t&&t.endSide>0&&(this.covering=e)}addLineDeco(e,t,i){let n=this.ensureLine();n.length+=i,n.collapsed+=i,n.widgetHeight=Math.max(n.widgetHeight,e),n.breaks+=t,this.writtenTo=this.pos=this.pos+i}finish(e){let t=0==this.nodes.length?null:this.nodes[this.nodes.length-1];!(this.lineStart>-1)||t instanceof lp||this.isCovered?(this.writtenTo<this.pos||null==t)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos)):this.nodes.push(new lp(0,-1,0));let i=e;for(let e of this.nodes)e instanceof lp&&e.updateHeight(this.oracle,i),i+=e?e.length:1;return this.nodes}static build(e,t,i,n){let r=new lv(i,e);return ra.spans(t,i,n,r,0),r.finish(i)}}class ly{constructor(){this.changes=[]}compareRange(){}comparePoint(e,t,i,n){(e<t||i&&i.heightRelevant||n&&n.heightRelevant)&&r6(e,t,this.changes,5)}}class lb{constructor(e,t,i,n){this.from=e,this.to=t,this.size=i,this.displaySize=n}static same(e,t){if(e.length!=t.length)return!1;for(let i=0;i<e.length;i++){let n=e[i],r=t[i];if(n.from!=r.from||n.to!=r.to||n.size!=r.size)return!1}return!0}draw(e,t){return rQ.replace({widget:new lw(this.displaySize*(t?e.scaleY:e.scaleX),t)}).range(this.from,this.to)}}class lw extends rX{constructor(e,t){super(),this.size=e,this.vertical=t}eq(e){return e.size==this.size&&e.vertical==this.vertical}toDOM(){let e=document.createElement("div");return this.vertical?e.style.height=this.size+"px":(e.style.width=this.size+"px",e.style.height="2px",e.style.display="inline-block"),e}get estimatedHeight(){return this.vertical?this.size:-1}}class lk{constructor(e){this.state=e,this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0},this.inView=!0,this.paddingTop=0,this.paddingBottom=0,this.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.scrollTop=0,this.scrolledToBottom=!1,this.scaleX=1,this.scaleY=1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=lM,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=sg.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let t=e.facet(sY).some(e=>"function"!=typeof e&&"cm-lineWrapping"==e.class);this.heightOracle=new lo(t),this.stateDeco=lZ(e),this.heightMap=lc.empty().applyChanges(this.stateDeco,ns.empty,this.heightOracle.setDoc(e.doc),[new s9(0,0,0,e.doc.length)]);for(let e=0;e<2&&(this.viewport=this.getViewport(0,null),this.updateForViewport());e++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=rQ.set(this.lineGaps.map(e=>e.draw(this,!1))),this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let i=0;i<=1;i++){let n=i?t.head:t.anchor;if(!e.some(({from:e,to:t})=>n>=e&&n<=t)){let{from:t,to:i}=this.lineBlockAt(n);e.push(new lS(t,i))}}return this.viewports=e.sort((e,t)=>e.from-t.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?lM:new lA(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(lT(e,this.scaler))})}update(e,t=null){var i,n;let r;this.state=e.state;let s=this.stateDeco;this.stateDeco=lZ(this.state);let o=e.changedRanges,l=s9.extendWithRanges(o,(i=this.stateDeco,n=e?e.changes:nb.empty(this.state.doc.length),r=new ly,ra.compare(s,i,n,r,0),r.changes)),a=this.heightMap.height,h=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);ls=!1,this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),l),(this.heightMap.height!=a||ls)&&(e.flags|=2),h?(this.scrollAnchorPos=e.changes.mapPos(h.from,-1),this.scrollAnchorHeight=h.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=a);let c=l.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.head<c.from||t.range.head>c.to)||!this.viewportIsAppropriate(c))&&(c=this.getViewport(0,t));let d=c.from!=this.viewport.from||c.to!=this.viewport.to;this.viewport=c,e.flags|=this.updateForViewport(),(d||!e.changes.empty||2&e.flags)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(e.changes),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(sW)&&(this.mustEnforceCursorAssoc=!0)}measure(e){var t;let i,n,r=e.contentDOM,s=window.getComputedStyle(r),o=this.heightOracle,l=s.whiteSpace;this.defaultTextDirection="rtl"==s.direction?sg.RTL:sg.LTR;let a=this.heightOracle.mustRefreshForWrapping(l)||this.mustMeasureContent,h=r.getBoundingClientRect(),c=a||this.mustMeasureContent||this.contentDOMHeight!=h.height;this.contentDOMHeight=h.height,this.mustMeasureContent=!1;let d=0,u=0;if(h.width&&h.height){let{scaleX:e,scaleY:t}=so(r,h);(e>.005&&Math.abs(this.scaleX-e)>.005||t>.005&&Math.abs(this.scaleY-t)>.005)&&(this.scaleX=e,this.scaleY=t,d|=16,a=c=!0)}let f=(parseInt(s.paddingTop)||0)*this.scaleY,p=(parseInt(s.paddingBottom)||0)*this.scaleY;(this.paddingTop!=f||this.paddingBottom!=p)&&(this.paddingTop=f,this.paddingBottom=p,d|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(o.lineWrapping&&(c=!0),this.editorWidth=e.scrollDOM.clientWidth,d|=16);let m=e.scrollDOM.scrollTop*this.scaleY;this.scrollTop!=m&&(this.scrollAnchorHeight=-1,this.scrollTop=m),this.scrolledToBottom=su(e.scrollDOM);let g=(this.printing?function(e,t){let i=e.getBoundingClientRect();return{left:0,right:i.right-i.left,top:t,bottom:i.bottom-(i.top+t)}}:function(e,t){let i=e.getBoundingClientRect(),n=e.ownerDocument,r=n.defaultView||window,s=Math.max(0,i.left),o=Math.min(r.innerWidth,i.right),l=Math.max(0,i.top),a=Math.min(r.innerHeight,i.bottom);for(let t=e.parentNode;t&&t!=n.body;)if(1==t.nodeType){let i=t,n=window.getComputedStyle(i);if((i.scrollHeight>i.clientHeight||i.scrollWidth>i.clientWidth)&&"visible"!=n.overflow){let n=i.getBoundingClientRect();s=Math.max(s,n.left),o=Math.min(o,n.right),l=Math.max(l,n.top),a=Math.min(t==e.parentNode?r.innerHeight:a,n.bottom)}t="absolute"==n.position||"fixed"==n.position?i.offsetParent:i.parentNode}else if(11==t.nodeType)t=t.host;else break;return{left:s-i.left,right:Math.max(s,o)-i.left,top:l-(i.top+t),bottom:Math.max(l,a)-(i.top+t)}})(r,this.paddingTop),x=g.top-this.pixelViewport.top,v=g.bottom-this.pixelViewport.bottom;this.pixelViewport=g;let y=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(y!=this.inView&&(this.inView=y,y&&(c=!0)),!this.inView&&!this.scrollTarget&&(i=(t=e.dom).getBoundingClientRect(),n=t.ownerDocument.defaultView||window,!(i.left<n.innerWidth)||!(i.right>0)||!(i.top<n.innerHeight)||!(i.bottom>0)))return 0;let b=h.width;if((this.contentDOMWidth!=b||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=h.width,this.editorHeight=e.scrollDOM.clientHeight,d|=16),c){let t=e.docView.measureVisibleLineHeights(this.viewport);if(o.mustRefreshForHeights(t)&&(a=!0),a||o.lineWrapping&&Math.abs(b-this.contentDOMWidth)>o.charWidth){let{lineHeight:i,charWidth:n,textHeight:r}=e.docView.measureTextSize();(a=i>0&&o.refresh(l,i,n,r,Math.max(5,b/n),t))&&(e.docView.minWidth=0,d|=16)}for(let i of(x>0&&v>0?u=Math.max(x,v):x<0&&v<0&&(u=Math.min(x,v)),ls=!1,this.viewports)){let n=i.from==this.viewport.from?t:e.docView.measureVisibleLineHeights(i);this.heightMap=(a?lc.empty().applyChanges(this.stateDeco,ns.empty,this.heightOracle,[new s9(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(o,0,a,new ll(i.from,n))}ls&&(d|=2)}let w=!this.viewportIsAppropriate(this.viewport,u)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return w&&(2&d&&(d|=this.updateScaler()),this.viewport=this.getViewport(u,this.scrollTarget),d|=this.updateForViewport()),(2&d||w)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(a?[]:this.lineGaps,e)),d|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),d}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let i=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),n=this.heightMap,r=this.heightOracle,{visibleTop:s,visibleBottom:o}=this,l=new lS(n.lineAt(s-1e3*i,lh.ByHeight,r,0,0).from,n.lineAt(o+(1-i)*1e3,lh.ByHeight,r,0,0).to);if(t){let{head:e}=t.range;if(e<l.from||e>l.to){let i=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),s=n.lineAt(e,lh.ByPos,r,0,0),o;o="center"==t.y?(s.top+s.bottom)/2-i/2:"start"==t.y||"nearest"==t.y&&e<l.from?s.top:s.bottom-i,l=new lS(n.lineAt(o-500,lh.ByHeight,r,0,0).from,n.lineAt(o+i+500,lh.ByHeight,r,0,0).to)}}return l}mapViewport(e,t){let i=t.mapPos(e.from,-1),n=t.mapPos(e.to,1);return new lS(this.heightMap.lineAt(i,lh.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(n,lh.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:e,to:t},i=0){if(!this.inView)return!0;let{top:n}=this.heightMap.lineAt(e,lh.ByPos,this.heightOracle,0,0),{bottom:r}=this.heightMap.lineAt(t,lh.ByPos,this.heightOracle,0,0),{visibleTop:s,visibleBottom:o}=this;return(0==e||n<=s-Math.max(10,Math.min(-i,250)))&&(t==this.state.doc.length||r>=o+Math.max(10,Math.min(i,250)))&&n>s-2e3&&r<o+2e3}mapLineGaps(e,t){if(!e.length||t.empty)return e;let i=[];for(let n of e)t.touchesRange(n.from,n.to)||i.push(new lb(t.mapPos(n.from),t.mapPos(n.to),n.size,n.displaySize));return i}ensureLineGaps(e,t){let i=this.heightOracle.lineWrapping,n=i?1e4:2e3,r=n>>1,s=n<<1;if(this.defaultTextDirection!=sg.LTR&&!i)return[];let o=[],l=(n,s,a,h)=>{if(s-n<r)return;let c=this.state.selection.main,d=[c.from];for(let e of(c.empty||d.push(c.to),d))if(e>n&&e<s){l(n,e-10,a,h),l(e+10,s,a,h);return}let u=function(e,t){for(let i of e)if(t(i))return i}(e,e=>e.from>=a.from&&e.to<=a.to&&Math.abs(e.from-n)<r&&Math.abs(e.to-s)<r&&!d.some(t=>e.from<t&&e.to>t));if(!u){if(s<a.to&&t&&i&&t.visibleRanges.some(e=>e.from<=s&&e.to>=s)){let e=t.moveToLineBoundary(nA.cursor(s),!1,!0).head;e>n&&(s=e)}let e=this.gapSize(a,n,s,h),r=i||e<2e6?e:2e6;u=new lb(n,s,e,r)}o.push(u)},a=t=>{var r,o,a;let h,c,d,u,f;if(t.length<s||t.type!=rY.Text)return;let p=(r=t.from,o=t.to,a=this.stateDeco,d=[],u=r,f=0,ra.spans(a,r,o,{span(){},point(e,t){e>u&&(d.push({from:u,to:e}),f+=e-u),u=t}},20),u<o&&(d.push({from:u,to:o}),f+=o-u),{total:f,ranges:d});if(p.total<s)return;let m=this.scrollTarget?this.scrollTarget.range.head:null;if(i){let e,i,r=n/this.heightOracle.lineLength*this.heightOracle.lineHeight;if(null!=m){let n=lj(p,m),s=((this.visibleBottom-this.visibleTop)/2+r)/t.height;e=n-s,i=n+s}else e=(this.visibleTop-t.top-r)/t.height,i=(this.visibleBottom-t.top+r)/t.height;h=lC(p,e),c=lC(p,i)}else{let i,r,s=p.total*this.heightOracle.charWidth,o=n*this.heightOracle.charWidth,l=0;if(s>2e6)for(let i of e)i.from>=t.from&&i.from<t.to&&i.size!=i.displaySize&&i.from*this.heightOracle.charWidth+l<this.pixelViewport.left&&(l=i.size-i.displaySize);let a=this.pixelViewport.left+l,d=this.pixelViewport.right+l;if(null!=m){let e=lj(p,m),t=((d-a)/2+o)/s;i=e-t,r=e+t}else i=(a-o)/s,r=(d+o)/s;h=lC(p,i),c=lC(p,r)}h>t.from&&l(t.from,h,t,p),c<t.to&&l(c,t.to,t,p)};for(let e of this.viewportLines)Array.isArray(e.type)?e.type.forEach(a):a(e);return o}gapSize(e,t,i,n){let r=lj(n,i)-lj(n,t);return this.heightOracle.lineWrapping?e.height*r:n.total*this.heightOracle.charWidth*r}updateLineGaps(e){lb.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=rQ.set(e.map(e=>e.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let i=[];ra.spans(t,this.viewport.from,this.viewport.to,{span(e,t){i.push({from:e,to:t})},point(){}},20);let n=0;if(i.length!=this.visibleRanges.length)n=12;else for(let t=0;t<i.length&&!(8&n);t++){let r=this.visibleRanges[t],s=i[t];r.from==s.from&&r.to==s.to||(n|=4,e&&e.mapPos(r.from,-1)==s.from&&e.mapPos(r.to,1)==s.to||(n|=8))}return this.visibleRanges=i,n}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||lT(this.heightMap.lineAt(e,lh.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(t=>t.top<=e&&t.bottom>=e)||lT(this.heightMap.lineAt(this.scaler.fromDOM(e),lh.ByHeight,this.heightOracle,0,0),this.scaler)}scrollAnchorAt(e){let t=this.lineBlockAtHeight(e+8);return t.from>=this.viewport.from||this.viewportLines[0].top-e>200?t:this.viewportLines[0]}elementAtHeight(e){return lT(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class lS{constructor(e,t){this.from=e,this.to=t}}function lC({total:e,ranges:t},i){if(i<=0)return t[0].from;if(i>=1)return t[t.length-1].to;let n=Math.floor(e*i);for(let e=0;;e++){let{from:i,to:r}=t[e],s=r-i;if(n<=s)return i+n;n-=s}}function lj(e,t){let i=0;for(let{from:n,to:r}of e.ranges){if(t<=r){i+=t-n;break}i+=r-n}return i/e.total}let lM={toDOM:e=>e,fromDOM:e=>e,scale:1,eq(e){return e==this}};function lZ(e){let t=e.facet(sQ).filter(e=>"function"!=typeof e),i=e.facet(s1).filter(e=>"function"!=typeof e);return i.length&&t.push(ra.join(i)),t}class lA{constructor(e,t,i){let n=0,r=0,s=0;for(let o of(this.viewports=i.map(({from:i,to:r})=>{let s=t.lineAt(i,lh.ByPos,e,0,0).top,o=t.lineAt(r,lh.ByPos,e,0,0).bottom;return n+=o-s,{from:i,to:r,top:s,bottom:o,domTop:0,domBottom:0}}),this.scale=(7e6-n)/(t.height-n),this.viewports))o.domTop=s+(o.top-r)*this.scale,s=o.domBottom=o.domTop+(o.bottom-o.top),r=o.bottom}toDOM(e){for(let t=0,i=0,n=0;;t++){let r=t<this.viewports.length?this.viewports[t]:null;if(!r||e<r.top)return n+(e-i)*this.scale;if(e<=r.bottom)return r.domTop+(e-r.top);i=r.bottom,n=r.domBottom}}fromDOM(e){for(let t=0,i=0,n=0;;t++){let r=t<this.viewports.length?this.viewports[t]:null;if(!r||e<r.domTop)return i+(e-n)/this.scale;if(e<=r.domBottom)return r.top+(e-r.domTop);i=r.bottom,n=r.domBottom}}eq(e){return e instanceof lA&&this.scale==e.scale&&this.viewports.length==e.viewports.length&&this.viewports.every((t,i)=>t.from==e.viewports[i].from&&t.to==e.viewports[i].to)}}function lT(e,t){if(1==t.scale)return e;let i=t.toDOM(e.top),n=t.toDOM(e.bottom);return new la(e.from,e.length,i,n-i,Array.isArray(e._content)?e._content.map(e=>lT(e,t)):e._content)}let lO=nD.define({combine:e=>e.join(" ")}),lD=nD.define({combine:e=>e.indexOf(!0)>-1}),lR=rj.newName(),lP=rj.newName(),lL=rj.newName(),lI={"&light":"."+lP,"&dark":"."+lL};function lE(e,t,i){return new rj(t,{finish:t=>/&/.test(t)?t.replace(/&\w*/,t=>{if("&"==t)return e;if(!i||!i[t])throw RangeError(`Unsupported selector: ${t}`);return i[t]}):e+" "+t})}let lB=lE("."+lR,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{backgroundImage:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",backgroundPosition:"center"},".cm-highlightTab":{backgroundImage:'url(\'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>\')',backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},lI),lN={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},lz=rK.ie&&rK.ie_version<=11;class lW{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new sl,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(t=>{for(let e of t)this.queue.push(e);(rK.ie&&rK.ie_version<=11||rK.ios&&e.composing)&&t.some(e=>"childList"==e.type&&e.removedNodes.length||"characterData"==e.type&&e.oldValue.length>e.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&rK.android&&!1!==e.constructor.EDIT_CONTEXT&&!(rK.chrome&&rK.chrome_version<126)&&(this.editContext=new lH(e),e.state.facet(sK)&&(e.contentDOM.editContext=this.editContext.editContext)),lz&&(this.onCharData=e=>{this.queue.push({target:e.target,type:"characterData",oldValue:e.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),"function"==typeof ResizeObserver&&(this.resizeScroll=new ResizeObserver(()=>{var e;(null===(e=this.view.docView)||void 0===e?void 0:e.lastUpdate)<Date.now()-75&&this.onResize()}),this.resizeScroll.observe(e.scrollDOM)),this.addWindowListeners(this.win=e.win),this.start(),"function"==typeof IntersectionObserver&&(this.intersection=new IntersectionObserver(e=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),e.length>0&&e[e.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(e=>{e.length>0&&e[e.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){("change"!=e.type&&e.type||e.matches)&&(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((t,i)=>t!=e[i]))){for(let t of(this.gapIntersection.disconnect(),e))this.gapIntersection.observe(t);this.gaps=e}}onSelectionChange(e){let t=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:i}=this,n=this.selectionRange;if(i.state.facet(sK)?i.root.activeElement!=this.dom:!r9(this.dom,n))return;let r=n.anchorNode&&i.docView.tile.nearest(n.anchorNode);if(r&&r.isWidget()&&r.widget.ignoreEvent(e)){t||(this.selectionChanged=!1);return}(rK.ie&&rK.ie_version<=11||rK.android&&rK.chrome)&&!i.state.selection.main.empty&&n.focusNode&&se(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=r3(e.root);if(!t)return!1;let i=rK.safari&&11==e.root.nodeType&&e.root.activeElement==this.dom&&function(e,t){if(t.getComposedRanges){let i=t.getComposedRanges(e.root)[0];if(i)return lV(e,i)}let i=null;function n(e){e.preventDefault(),e.stopImmediatePropagation(),i=e.getTargetRanges()[0]}return e.contentDOM.addEventListener("beforeinput",n,!0),e.dom.ownerDocument.execCommand("indent"),e.contentDOM.removeEventListener("beforeinput",n,!0),i?lV(e,i):null}(this.view,t)||t;if(!i||this.selectionRange.eq(i))return!1;let n=r9(this.dom,i);return n&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&function(e,t){let i=t.focusNode,n=t.focusOffset;if(!i||t.anchorNode!=i||t.anchorOffset!=n)return!1;for(n=Math.min(n,sr(i));;)if(n){if(1!=i.nodeType)return!1;let e=i.childNodes[n-1];"false"==e.contentEditable?n--:n=sr(i=e)}else{if(i==e)return!0;n=st(i),i=i.parentNode}}(this.dom,i)?(this.view.inputState.lastFocusTime=0,e.docView.updateSelection(),!1):(this.selectionRange.setRange(i),n&&(this.selectionChanged=!0),!0)}setSelectionRange(e,t){this.selectionRange.set(e.node,e.offset,t.node,t.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let e=0,t=null;for(let i=this.dom;i;)if(1==i.nodeType)!t&&e<this.scrollTargets.length&&this.scrollTargets[e]==i?e++:t||(t=this.scrollTargets.slice(0,e)),t&&t.push(i),i=i.assignedSlot||i.parentNode;else if(11==i.nodeType)i=i.host;else break;if(e<this.scrollTargets.length&&!t&&(t=this.scrollTargets.slice(0,e)),t){for(let e of this.scrollTargets)e.removeEventListener("scroll",this.onScroll);for(let e of this.scrollTargets=t)e.addEventListener("scroll",this.onScroll)}}ignore(e){if(!this.active)return e();try{return this.stop(),e()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,lN),lz&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),lz&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(e,t){var i;this.delayedAndroidKey||(this.flushingAndroidKey=this.view.win.requestAnimationFrame(()=>{let e=this.delayedAndroidKey;e&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=e.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&e.force&&sd(this.dom,e.key,e.keyCode))})),this.delayedAndroidKey&&"Enter"!=e||(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange<Date.now()-50||!!(null===(i=this.delayedAndroidKey)||void 0===i?void 0:i.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame(()=>{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let t=-1,i=-1,n=!1;for(let r of e){let e=this.readMutation(r);e&&(e.typeOver&&(n=!0),-1==t?{from:t,to:i}=e:(t=Math.min(e.from,t),i=Math.max(e.to,i)))}return{from:t,to:i,typeOver:n}}readChange(){let{from:e,to:t,typeOver:i}=this.processRecords(),n=this.selectionChanged&&r9(this.dom,this.selectionRange);if(e<0&&!n)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let r=new oz(this.view,e,t,i);return this.view.docView.domChanged={newSel:r.newSel?r.newSel.main:null},r}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let t=this.readChange();if(!t)return this.view.requestMeasure(),!1;let i=this.view.state,n=oW(this.view,t);return this.view.state==i&&(t.domChanged||t.newSel&&!oH(this.view.state.selection,t.newSel.main))&&this.view.update([]),n}readMutation(e){let t=this.view.docView.tile.nearest(e.target);if(!t||t.isWidget())return null;if(t.markDirty("attributes"==e.type),"childList"==e.type){let i=lF(t,e.previousSibling||e.target.previousSibling,-1),n=lF(t,e.nextSibling||e.target.nextSibling,1);return{from:i?t.posAfter(i):t.posAtStart,to:n?t.posBefore(n):t.posAtEnd,typeOver:!1}}return"characterData"==e.type?{from:t.posAtStart,to:t.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(sK)!=e.state.facet(sK)&&(e.view.contentDOM.editContext=e.state.facet(sK)?this.editContext.editContext:null))}destroy(){var e,t,i;for(let n of(this.stop(),null===(e=this.intersection)||void 0===e||e.disconnect(),null===(t=this.gapIntersection)||void 0===t||t.disconnect(),null===(i=this.resizeScroll)||void 0===i||i.disconnect(),this.scrollTargets))n.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}}function lF(e,t,i){for(;t;){let n=ot.get(t);if(n&&n.parent==e)return n;let r=t.parentNode;t=r!=e.dom?r:i>0?t.nextSibling:t.previousSibling}return null}function lV(e,t){let i=t.startContainer,n=t.startOffset,r=t.endContainer,s=t.endOffset,o=e.docView.domAtPos(e.state.selection.main.anchor,1);return se(o.node,o.offset,r,s)&&([i,n,r,s]=[r,s,i,n]),{anchorNode:i,anchorOffset:n,focusNode:r,focusOffset:s}}class lH{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let t=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});for(let i in this.handlers.textupdate=i=>{let n=e.state.selection.main,{anchor:r,head:s}=n,o=this.toEditorPos(i.updateRangeStart),l=this.toEditorPos(i.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:i.updateRangeStart,editorBase:o,drifted:!1});let a=l-o>i.text.length;o==this.from&&r<this.from?o=r:l==this.to&&r>this.to&&(l=r);let h=oV(e.state.sliceDoc(o,l),i.text,(a?n.from:n.to)-o,a?"end":null);if(!h){let t=nA.single(this.toEditorPos(i.selectionStart),this.toEditorPos(i.selectionEnd));oH(t,n)||e.dispatch({selection:t,userEvent:"select"});return}let c={from:h.from+o,to:h.toA+o,insert:ns.of(i.text.slice(h.from,h.toB).split("\n"))};if((rK.mac||rK.android)&&c.from==s-1&&/^\. ?$/.test(i.text)&&"off"==e.contentDOM.getAttribute("autocorrect")&&(c={from:o,to:l,insert:ns.of([i.text.replace("."," ")])}),this.pendingContextChange=c,!e.state.readOnly){let t=this.to-this.from+(c.to-c.from+c.insert.length);oF(e,c,nA.single(this.toEditorPos(i.selectionStart,t),this.toEditorPos(i.selectionEnd,t)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),c.from<c.to&&!c.insert.length&&e.inputState.composing>=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(t.text.slice(Math.max(0,i.updateRangeStart-1),Math.min(t.text.length,i.updateRangeStart+1)))&&this.handlers.compositionend(i)},this.handlers.characterboundsupdate=i=>{let n=[],r=null;for(let t=this.toEditorPos(i.rangeStart),s=this.toEditorPos(i.rangeEnd);t<s;t++){let i=e.coordsForChar(t);r=i&&new DOMRect(i.left,i.top,i.right-i.left,i.bottom-i.top)||r||new DOMRect,n.push(r)}t.updateCharacterBounds(i.rangeStart,n)},this.handlers.textformatupdate=t=>{let i=[];for(let e of t.getTextFormats()){let t=e.underlineStyle,n=e.underlineThickness;if(!/none/i.test(t)&&!/none/i.test(n)){let r=this.toEditorPos(e.rangeStart),s=this.toEditorPos(e.rangeEnd);if(r<s){let e=`text-decoration: underline ${/^[a-z]/.test(t)?t+" ":"Dashed"==t?"dashed ":"Squiggle"==t?"wavy ":""}${/thin/i.test(n)?1:2}px`;i.push(rQ.mark({attributes:{style:e}}).range(r,s))}}}e.dispatch({effects:s$.of(rQ.set(i))})},this.handlers.compositionstart=()=>{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:t}=this.composing;this.composing=null,t&&this.reset(e.state)}},this.handlers)t.addEventListener(i,this.handlers[i]);this.measureReq={read:e=>{this.editContext.updateControlBounds(e.contentDOM.getBoundingClientRect());let t=r3(e.root);t&&t.rangeCount&&this.editContext.updateSelectionBounds(t.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let t=0,i=!1,n=this.pendingContextChange;return e.changes.iterChanges((r,s,o,l,a)=>{if(i)return;let h=a.length-(s-r);if(n&&s>=n.to){if(n.from==r&&n.to==s&&n.insert.eq(a)){n=this.pendingContextChange=null,t+=h,this.to+=h;return}n=null,this.revertPending(e.state)}if(r+=t,(s+=t)<=this.from)this.from+=h,this.to+=h;else if(r<this.to){if(r<this.from||s>this.to||this.to-this.from+a.length>3e4){i=!0;return}this.editContext.updateText(this.toContextPos(r),this.toContextPos(s),a.toString()),this.to+=h}t+=h}),n&&!i&&this.revertPending(e.state),!i}update(e){let t=this.pendingContextChange,i=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(i.from,i.to)&&e.transactions.some(e=>!e.isUserEvent("input.type")&&e.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):this.applyEdits(e)&&this.rangeIsValid(e.state)?(e.docChanged||e.selectionSet||t)&&this.setSelection(e.state):(this.pendingContextChange=null,this.reset(e.state)),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:t}=e.selection.main;this.from=Math.max(0,t-1e4),this.to=Math.min(e.doc.length,t+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let t=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(t.from),this.toContextPos(t.from+t.insert.length),e.doc.sliceString(t.from,t.to))}setSelection(e){let{main:t}=e.selection,i=this.toContextPos(Math.max(this.from,Math.min(this.to,t.anchor))),n=this.toContextPos(t.head);(this.editContext.selectionStart!=i||this.editContext.selectionEnd!=n)&&this.editContext.updateSelection(i,n)}rangeIsValid(e){let{head:t}=e.selection.main;return!(this.from>0&&t-this.from<500||this.to<e.doc.length&&this.to-t<500||this.to-this.from>3e4)}toEditorPos(e,t=this.to-this.from){e=Math.min(e,t);let i=this.composing;return i&&i.drifted?i.editorBase+(e-i.contextBase):e+this.from}toContextPos(e){let t=this.composing;return t&&t.drifted?t.contextBase+(e-t.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class l${get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var t;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:i}=e;for(let t of(this.dispatchTransactions=e.dispatchTransactions||i&&(e=>e.forEach(e=>i(e,this)))||(e=>this.update(e)),this.dispatch=this.dispatch.bind(this),this._root=e.root||function(e){for(;e;){if(e&&(9==e.nodeType||11==e.nodeType&&e.host))return e;e=e.assignedSlot||e.parentNode}return null}(e.parent)||document,this.viewState=new lk(e.state||rt.create(e)),e.scrollTo&&e.scrollTo.is(sH)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(s_).map(e=>new sJ(e)),this.plugins))t.update(this);this.observer=new lW(this),this.inputState=new o$(this),this.inputState.ensureHandlers(this.plugins),this.docView=new oS(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),(null===(t=document.fonts)||void 0===t?void 0:t.ready)&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent=!0,this.requestMeasure()})}dispatch(...e){let t=1==e.length&&e[0]instanceof n6?e:1==e.length&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(e){if(0!=this.updateState)throw Error("Calls to EditorView.update are not allowed while an update is in progress");let t=!1,i=!1,n,r=this.state;for(let t of e){if(t.startState!=r)throw RangeError("Trying to update state with a transaction that doesn't start from the previous state.");r=t.state}if(this.destroyed){this.viewState.state=r;return}let s=this.hasFocus,o=0,l=null;e.some(e=>e.annotation(le))?(this.inputState.notifiedFocused=s,o=1):s==this.inputState.notifiedFocused||(this.inputState.notifiedFocused=s,(l=lt(r,s))||(o=1));let a=this.observer.delayedAndroidKey,h=null;if(a?(this.observer.clearDelayedAndroidKey(),((h=this.observer.readChange())&&!this.state.doc.eq(r.doc)||!this.state.selection.eq(r.selection))&&(h=null)):this.observer.clear(),r.facet(rt.phrases)!=this.state.facet(rt.phrases))return this.setState(r);n=s7.create(this,r,e),n.flags|=o;let c=this.viewState.scrollTarget;try{for(let t of(this.updateState=2,e)){if(c&&(c=c.map(t.changes)),t.scrollIntoView){let{main:e}=t.state.selection;c=new sV(e.empty?e:nA.cursor(e.head,e.head>e.anchor?-1:1))}for(let e of t.effects)e.is(sH)&&(c=e.value.clip(this.state))}this.viewState.update(n,c),this.bidiCache=lU.update(this.bidiCache,n.changes),n.empty||(this.updatePlugins(n),this.inputState.update(n)),t=this.docView.update(n),this.state.facet(s8)!=this.styleModules&&this.mountStyles(),i=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(t,e.some(e=>e.isUserEvent("select.pointer")))}finally{this.updateState=0}if(n.startState.facet(lO)!=n.state.facet(lO)&&(this.viewState.mustMeasureContent=!0),(t||i||c||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),t&&this.docViewUpdate(),!n.empty)for(let e of this.state.facet(sL))try{e(n)}catch(e){sq(this.state,e,"update listener")}(l||h)&&Promise.resolve().then(()=>{l&&this.state==l.startState&&this.dispatch(l),h&&!oW(this,h)&&a.force&&sd(this.contentDOM,a.key,a.keyCode)})}setState(e){if(0!=this.updateState)throw Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let t=this.hasFocus;try{for(let e of this.plugins)e.destroy(this);for(let t of(this.viewState=new lk(e),this.plugins=e.facet(s_).map(e=>new sJ(e)),this.pluginMap.clear(),this.plugins))t.update(this);this.docView.destroy(),this.docView=new oS(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}t&&this.focus(),this.requestMeasure()}updatePlugins(e){let t=e.startState.facet(s_),i=e.state.facet(s_);if(t!=i){let n=[];for(let r of i){let i=t.indexOf(r);if(i<0)n.push(new sJ(r));else{let t=this.plugins[i];t.mustUpdate=e,n.push(t)}}for(let t of this.plugins)t.mustUpdate!=e&&t.destroy(this);this.plugins=n,this.pluginMap.clear()}else for(let t of this.plugins)t.mustUpdate=e;for(let e=0;e<this.plugins.length;e++)this.plugins[e].update(this);t!=i&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let e of this.plugins){let t=e.value;if(t&&t.docViewUpdate)try{t.docViewUpdate(this)}catch(e){sq(this.state,e,"doc view update listener")}}}measure(e=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,i=this.scrollDOM,n=i.scrollTop*this.scaleY,{scrollAnchorPos:r,scrollAnchorHeight:s}=this.viewState;Math.abs(n-this.viewState.scrollTop)>1&&(s=-1),this.viewState.scrollAnchorHeight=-1;try{for(let e=0;;e++){if(s<0){if(su(i))r=-1,s=this.viewState.heightMap.height;else{let e=this.viewState.scrollAnchorAt(n);r=e.from,s=e.top}}this.updateState=1;let o=this.viewState.measure(this);if(!o&&!this.measureRequests.length&&null==this.viewState.scrollTarget)break;if(e>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let l=[];4&o||([this.measureRequests,l]=[l,this.measureRequests]);let a=l.map(e=>{try{return e.read(this)}catch(e){return sq(this.state,e),lK}}),h=s7.create(this,this.state,[]),c=!1;h.flags|=o,t?t.flags|=o:t=h,this.updateState=2,!h.empty&&(this.updatePlugins(h),this.inputState.update(h),this.updateAttrs(),(c=this.docView.update(h))&&this.docViewUpdate());for(let e=0;e<l.length;e++)if(a[e]!=lK)try{let t=l[e];t.write&&t.write(a[e],this)}catch(e){sq(this.state,e)}if(c&&this.docView.updateSelection(!0),!h.viewportChanged&&0==this.measureRequests.length){if(this.viewState.editorHeight){if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,s=-1;continue}{let e=(r<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(r).top)-s;if(e>1||e<-1){n+=e,i.scrollTop=n/this.scaleY,s=-1;continue}}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let e of this.state.facet(sL))e(t)}get themeClasses(){return lR+" "+(this.state.facet(lD)?lL:lP)+" "+this.state.facet(lO)}updateAttrs(){let e=l_(this,sX,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(sK)?"true":"false",class:"cm-content",style:`${rK.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),l_(this,sY,t);let i=this.observer.ignore(()=>{let i=rJ(this.contentDOM,this.contentAttrs,t),n=rJ(this.dom,this.editorAttrs,e);return i||n});return this.editorAttrs=e,this.contentAttrs=t,i}showAnnouncements(e){let t=!0;for(let i of e)for(let e of i.effects)e.is(l$.announce)&&(t&&(this.announceDOM.textContent=""),t=!1,this.announceDOM.appendChild(document.createElement("div")).textContent=e.value)}mountStyles(){this.styleModules=this.state.facet(s8);let e=this.state.facet(l$.cspNonce);rj.mount(this.root,this.styleModules.concat(lB).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(2==this.updateState)throw Error("Reading the editor layout isn't allowed during an update");0==this.updateState&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e&&!(this.measureRequests.indexOf(e)>-1)){if(null!=e.key){for(let t=0;t<this.measureRequests.length;t++)if(this.measureRequests[t].key===e.key){this.measureRequests[t]=e;return}}this.measureRequests.push(e)}}plugin(e){let t=this.pluginMap.get(e);return(void 0===t||t&&t.plugin!=e)&&this.pluginMap.set(e,t=this.plugins.find(t=>t.plugin==e)||null),t&&t.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,t,i){return oP(this,e,oO(this,e,t,i))}moveByGroup(e,t){return oP(this,e,oO(this,e,t,t=>{var i;let n,r;return i=e.head,r=(n=this.state.charCategorizer(i))(t),e=>{let t=n(e);return r==n7.Space&&(r=t),r==t}}))}visualLineSide(e,t){let i=this.bidiSpans(e),n=this.textDirectionAt(e.from),r=i[t?i.length-1:0];return nA.cursor(r.side(t,n)+e.from,r.forward(!t,n)?1:-1)}moveToLineBoundary(e,t,i=!0){return function(e,t,i,n){let r=oT(e,t.head,t.assoc||-1),s=n&&r.type==rY.Text&&(e.lineWrapping||r.widgetLineBreaks)?e.coordsAtPos(t.assoc<0&&t.head>r.from?t.head-1:t.head):null;if(s){let t=e.dom.getBoundingClientRect(),n=e.textDirectionAt(r.from),o=e.posAtCoords({x:i==(n==sg.LTR)?t.right-1:t.left+1,y:(s.top+s.bottom)/2});if(null!=o)return nA.cursor(o,i?-1:1)}return nA.cursor(i?r.to:r.from,i?-1:1)}(this,e,t,i)}moveVertically(e,t,i){return oP(this,e,function(e,t,i,n){let r=t.head,s=i?1:-1;if(r==(i?e.state.doc.length:0))return nA.cursor(r,t.assoc);let o=t.goalColumn,l,a=e.contentDOM.getBoundingClientRect(),h=e.coordsAtPos(r,(t.empty?t.assoc:0)||(i?1:-1)),c=e.documentTop;if(h)null==o&&(o=h.left-a.left),l=s<0?h.top:h.bottom;else{let t=e.viewState.lineBlockAt(r);null==o&&(o=Math.min(a.right-a.left,e.defaultCharacterWidth*(r-t.from))),l=(s<0?t.top:t.bottom)+c}let d=a.left+o,u=null!=n?n:e.viewState.heightOracle.textHeight>>1,f=oI(e,{x:d,y:l+u*s},!1,s);return nA.cursor(f.pos,f.assoc,void 0,o)}(this,e,t,i))}domAtPos(e,t=1){return this.docView.domAtPos(e,t)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){this.readMeasured();let i=oI(this,e,t);return i&&i.pos}posAndSideAtCoords(e,t=!0){return this.readMeasured(),oI(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let i=this.docView.coordsAt(e,t);if(!i||i.left==i.right)return i;let n=this.state.doc.lineAt(e),r=this.bidiSpans(n);return ss(i,r[sM.find(r,e-n.from,-1,t)].dir==sg.LTR==t>0)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(sz)||e<this.viewport.from||e>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>lq)return sA(e.length);let t=this.textDirectionAt(e.from),i;for(let n of this.bidiCache)if(n.from==e.from&&n.dir==t&&(n.fresh||function e(t,i){if(t.length!=i.length)return!1;for(let n=0;n<t.length;n++){let r=t[n],s=i[n];if(r.from!=s.from||r.to!=s.to||r.direction!=s.direction||!e(r.inner,s.inner))return!1}return!0}(n.isolates,i=s6(this,e))))return n.order;i||(i=s6(this,e));let n=function(e,t,i){if(!e)return[new sM(0,0,t==sv?1:0)];if(t==sx&&!i.length&&!sj.test(e))return sA(e.length);if(i.length)for(;e.length>sZ.length;)sZ[sZ.length]=256;let n=[],r=t==sx?0:1;return function e(t,i,n,r,s,o,l){let a=i%2?2:1;(function(e,t,i,n,r){for(let s=0;s<=n.length;s++){let o=s?n[s-1].to:t,l=s<n.length?n[s].from:i,a=s?256:r;for(let t=o,i=a,n=a;t<l;t++){let r=sC(e.charCodeAt(t));512==r?r=i:8==r&&4==n&&(r=16),sZ[t]=4==r?2:r,7&r&&(n=r),i=r}for(let e=o,t=a,n=a;e<l;e++){let r=sZ[e];if(128==r)e<l-1&&t==sZ[e+1]&&24&t?r=sZ[e]=t:sZ[e]=256;else if(64==r){let r=e+1;for(;r<l&&64==sZ[r];)r++;let s=e&&8==t||r<i&&8==sZ[r]?1==n?1:8:256;for(let t=e;t<r;t++)sZ[t]=s;e=r-1}else 8==r&&1==n&&(sZ[e]=1);t=r,7&r&&(n=r)}}})(t,s,o,r,a),function(e,t,i,n,r){let s=1==r?2:1;for(let o=0,l=0,a=0;o<=n.length;o++){let h=o?n[o-1].to:t,c=o<n.length?n[o].from:i;for(let t=h,i,n,o;t<c;t++)if(n=sk[i=e.charCodeAt(t)]){if(n<0){for(let e=l-3;e>=0;e-=3)if(sS[e+1]==-n){let i=sS[e+2],n=2&i?r:4&i?1&i?s:r:0;n&&(sZ[t]=sZ[sS[e]]=n),l=e;break}}else if(189==sS.length)break;else sS[l++]=t,sS[l++]=i,sS[l++]=a}else if(2==(o=sZ[t])||1==o){let e=o==r;a=e?0:1;for(let t=l-3;t>=0;t-=3){let i=sS[t+2];if(2&i)break;if(e)sS[t+2]|=2;else{if(4&i)break;sS[t+2]|=4}}}}}(t,s,o,r,a),function(e,t,i,n){for(let r=0,s=n;r<=i.length;r++){let o=r?i[r-1].to:e,l=r<i.length?i[r].from:t;for(let a=o;a<l;){let o=sZ[a];if(256==o){let o=a+1;for(;;)if(o==l){if(r==i.length)break;o=i[r++].to,l=r<i.length?i[r].from:t}else if(256==sZ[o])o++;else break;let h=1==s,c=h==((o<t?sZ[o]:n)==1)?h?1:2:n;for(let t=o,n=r,s=n?i[n-1].to:e;t>a;)t==s&&(t=i[--n].from,s=n?i[n-1].to:e),sZ[--t]=c;a=o}else s=o,a++}}}(s,o,r,a),function t(i,n,r,s,o,l,a){let h=s%2?2:1;if(s%2==o%2)for(let c=n,d=0;c<r;){let n=!0,u=!1;if(d==l.length||c<l[d].from){let e=sZ[c];e!=h&&(n=!1,u=16==e)}let f=n||1!=h?null:[],p=n?s:s+1,m=c;i:for(;;)if(d<l.length&&m==l[d].from){if(u)break;let t=l[d];if(!n)for(let e=t.to,i=d+1;;){if(e==r)break i;if(i<l.length&&l[i].from==e)e=l[i++].to;else if(sZ[e]==h)break i;else break}d++,f?f.push(t):(t.from>c&&a.push(new sM(c,t.from,p)),e(i,t.direction==sx!=!(p%2)?s+1:s,o,t.inner,t.from,t.to,a),c=t.to),m=t.to}else if(m==r||(n?sZ[m]!=h:sZ[m]==h))break;else m++;f?t(i,c,m,s+1,o,f,a):c<m&&a.push(new sM(c,m,p)),c=m}else for(let c=r,d=l.length;c>n;){let r=!0,u=!1;if(!d||c>l[d-1].to){let e=sZ[c-1];e!=h&&(r=!1,u=16==e)}let f=r||1!=h?null:[],p=r?s:s+1,m=c;i:for(;;)if(d&&m==l[d-1].to){if(u)break;let t=l[--d];if(!r)for(let e=t.from,i=d;;){if(e==n)break i;if(i&&l[i-1].to==e)e=l[--i].from;else if(sZ[e-1]==h)break i;else break}f?f.push(t):(t.to<c&&a.push(new sM(t.to,c,p)),e(i,t.direction==sx!=!(p%2)?s+1:s,o,t.inner,t.from,t.to,a),c=t.from),m=t.from}else if(m==n||(r?sZ[m-1]!=h:sZ[m-1]==h))break;else m--;f?t(i,m,c,s+1,o,f,a):m<c&&a.push(new sM(m,c,p)),c=m}}(t,s,o,i,n,r,l)}(e,r,r,i,0,e.length,n),n}(e.text,t,i);return this.bidiCache.push(new lU(e.from,e.to,t,i,!0,n)),n}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||rK.safari&&(null===(e=this.inputState)||void 0===e?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{sh(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((9==e.nodeType?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){for(let e of(this.root.activeElement==this.contentDOM&&this.contentDOM.blur(),this.plugins))e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){return sH.of(new sV("number"==typeof e?nA.cursor(e):e,t.y,t.x,t.yMargin,t.xMargin))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,i=this.viewState.scrollAnchorAt(e);return sH.of(new sV(nA.cursor(i.from),"start","start",i.top-e,t,!0))}setTabFocusMode(e){null==e?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:"boolean"==typeof e?this.inputState.tabFocusMode=e?0:-1:0!=this.inputState.tabFocusMode&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return sG.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return sG.define(()=>({}),{eventObservers:e})}static theme(e,t){let i=rj.newName(),n=[lO.of(i),s8.of(lE(`.${i}`,e))];return t&&t.dark&&n.push(lD.of(!0)),n}static baseTheme(e){return nW.lowest(s8.of(lE("."+lR,e,lI)))}static findFromDOM(e){var t;let i=e.querySelector(".cm-content"),n=i&&ot.get(i)||ot.get(e);return(null===(t=null==n?void 0:n.root)||void 0===t?void 0:t.view)||null}}l$.styleModule=s8,l$.inputHandler=sI,l$.clipboardInputFilter=sB,l$.clipboardOutputFilter=sN,l$.scrollHandler=sF,l$.focusChangeEffect=sE,l$.perLineTextDirection=sz,l$.exceptionSink=sP,l$.updateListener=sL,l$.editable=sK,l$.mouseSelectionStyle=sR,l$.dragMovesSelection=sD,l$.clickAddsSelectionRange=sO,l$.decorations=sQ,l$.blockWrappers=s0,l$.outerDecorations=s1,l$.atomicRanges=s2,l$.bidiIsolatedRanges=s5,l$.scrollMargins=s4,l$.darkTheme=lD,l$.cspNonce=nD.define({combine:e=>e.length?e[0]:""}),l$.contentAttributes=sY,l$.editorAttributes=sX,l$.lineWrapping=l$.contentAttributes.of({class:"cm-lineWrapping"}),l$.announce=n5.define();let lq=4096,lK={};class lU{constructor(e,t,i,n,r,s){this.from=e,this.to=t,this.dir=i,this.isolates=n,this.fresh=r,this.order=s}static update(e,t){if(t.empty&&!e.some(e=>e.fresh))return e;let i=[],n=e.length?e[e.length-1].dir:sg.LTR;for(let r=Math.max(0,e.length-10);r<e.length;r++){let s=e[r];s.dir!=n||t.touchesRange(s.from,s.to)||i.push(new lU(t.mapPos(s.from,1),t.mapPos(s.to,-1),s.dir,s.isolates,!1,s.order))}return i}}function l_(e,t,i){for(let n=e.state.facet(t),r=n.length-1;r>=0;r--){let t=n[r],s="function"==typeof t?t(e):t;s&&rU(s,i)}return i}let lG=rK.mac?"mac":rK.windows?"win":rK.linux?"linux":"key";function lJ(e,t,i){return t.altKey&&(e="Alt-"+e),t.ctrlKey&&(e="Ctrl-"+e),t.metaKey&&(e="Meta-"+e),!1!==i&&t.shiftKey&&(e="Shift-"+e),e}let lX=nW.default(l$.domEventHandlers({keydown:(e,t)=>l5(l0(t.state),e,t,"editor")})),lY=nD.define({enables:lX}),lQ=new WeakMap;function l0(e){let t=e.facet(lY),i=lQ.get(t);return i||lQ.set(t,i=function(e,t=lG){let i=Object.create(null),n=Object.create(null),r=(e,t)=>{let i=n[e];if(null==i)n[e]=t;else if(i!=t)throw Error("Key binding "+e+" is used both as a regular binding and as a multi-stroke prefix")},s=(e,n,s,o,l)=>{var a,h;let c=i[e]||(i[e]=Object.create(null)),d=n.split(/ (?!$)/).map(e=>(function(e,t){let i,n,r,s;let o=e.split(/-(?!$)/),l=o[o.length-1];"Space"==l&&(l=" ");for(let e=0;e<o.length-1;++e){let l=o[e];if(/^(cmd|meta|m)$/i.test(l))s=!0;else if(/^a(lt)?$/i.test(l))i=!0;else if(/^(c|ctrl|control)$/i.test(l))n=!0;else if(/^s(hift)?$/i.test(l))r=!0;else if(/^mod$/i.test(l))"mac"==t?s=!0:n=!0;else throw Error("Unrecognized modifier name: "+l)}return i&&(l="Alt-"+l),n&&(l="Ctrl-"+l),s&&(l="Meta-"+l),r&&(l="Shift-"+l),l})(e,t));for(let t=1;t<d.length;t++){let i=d.slice(0,t).join(" ");r(i,!0),c[i]||(c[i]={preventDefault:!0,stopPropagation:!1,run:[t=>{let n=l1={view:t,prefix:i,scope:e};return setTimeout(()=>{l1==n&&(l1=null)},4e3),!0}]})}let u=d.join(" ");r(u,!1);let f=c[u]||(c[u]={preventDefault:!1,stopPropagation:!1,run:(null===(h=null===(a=c._any)||void 0===a?void 0:a.run)||void 0===h?void 0:h.slice())||[]});s&&f.run.push(s),o&&(f.preventDefault=!0),l&&(f.stopPropagation=!0)};for(let n of e){let e=n.scope?n.scope.split(" "):["editor"];if(n.any)for(let t of e){let e=i[t]||(i[t]=Object.create(null));e._any||(e._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:r}=n;for(let t in e)e[t].run.push(e=>r(e,l2))}let r=n[t]||n.key;if(r)for(let t of e)s(t,r,n.run,n.preventDefault,n.stopPropagation),n.shift&&s(t,"Shift-"+r,n.shift,n.preventDefault,n.stopPropagation)}return i}(t.reduce((e,t)=>e.concat(t),[]))),i}let l1=null,l2=null;function l5(e,t,i,n){var r;l2=t;let s=("Esc"==(r=!(rO&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||rD&&t.shiftKey&&t.key&&1==t.key.length||"Unidentified"==t.key)&&t.key||(t.shiftKey?rT:rA)[t.keyCode]||t.key||"Unidentified")&&(r="Escape"),"Del"==r&&(r="Delete"),"Left"==r&&(r="ArrowLeft"),"Up"==r&&(r="ArrowUp"),"Right"==r&&(r="ArrowRight"),"Down"==r&&(r="ArrowDown"),r),o=ng(nm(s,0))==s.length&&" "!=s,l="",a=!1,h=!1,c=!1;l1&&l1.view==i&&l1.scope==n&&(l=l1.prefix+" ",0>o_.indexOf(t.keyCode)&&(h=!0,l1=null));let d=new Set,u=e=>{if(e){for(let t of e.run)if(!d.has(t)&&(d.add(t),t(i)))return e.stopPropagation&&(c=!0),!0;e.preventDefault&&(e.stopPropagation&&(c=!0),h=!0)}return!1},f=e[n],p,m;return f&&(u(f[l+lJ(s,t,!o)])?a=!0:o&&(t.altKey||t.metaKey||t.ctrlKey)&&!(rK.windows&&t.ctrlKey&&t.altKey)&&!(rK.mac&&t.altKey&&!(t.ctrlKey||t.metaKey))&&(p=rA[t.keyCode])&&p!=s?u(f[l+lJ(p,t,!0)])?a=!0:t.shiftKey&&(m=rT[t.keyCode])!=s&&m!=p&&u(f[l+lJ(m,t,!1)])&&(a=!0):o&&t.shiftKey&&u(f[l+lJ(s,t,!0)])&&(a=!0),!a&&u(f._any)&&(a=!0)),h&&(a=!0),a&&c&&t.stopPropagation(),l2=null,a}class l6{constructor(e,t,i,n,r){this.className=e,this.left=t,this.top=i,this.width=n,this.height=r}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,t){return t.className==this.className&&(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",null!=this.width&&(e.style.width=this.width+"px"),e.style.height=this.height+"px"}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(e,t,i){if(!i.empty)return function(e,t,i){if(i.to<=e.viewport.from||i.from>=e.viewport.to)return[];let n=Math.max(i.from,e.viewport.from),r=Math.min(i.to,e.viewport.to),s=e.textDirection==sg.LTR,o=e.contentDOM,l=o.getBoundingClientRect(),a=l4(e),h=o.querySelector(".cm-line"),c=h&&window.getComputedStyle(h),d=l.left+(c?parseInt(c.paddingLeft)+Math.min(0,parseInt(c.textIndent)):0),u=l.right-(c?parseInt(c.paddingRight):0),f=oT(e,n,1),p=oT(e,r,-1),m=f.type==rY.Text?f:null,g=p.type==rY.Text?p:null;if(m&&(e.lineWrapping||f.widgetLineBreaks)&&(m=l3(e,n,1,m)),g&&(e.lineWrapping||p.widgetLineBreaks)&&(g=l3(e,r,-1,g)),m&&g&&m.from==g.from&&m.to==g.to)return v(y(i.from,i.to,m));{let t=m?y(i.from,null,m):b(f,!1),n=g?y(null,i.to,g):b(p,!0),r=[];return(m||f).to<(g||p).from-(m&&g?1:0)||f.widgetLineBreaks>1&&t.bottom+e.defaultLineHeight/2<n.top?r.push(x(d,t.bottom,u,n.top)):t.bottom<n.top&&e.elementAtHeight((t.bottom+n.top)/2).type==rY.Text&&(t.bottom=n.top=(t.bottom+n.top)/2),v(t).concat(r).concat(v(n))}function x(e,i,n,r){return new l6(t,e-a.left,i-a.top,Math.max(0,n-e),r-i)}function v({top:e,bottom:t,horizontal:i}){let n=[];for(let r=0;r<i.length;r+=2)n.push(x(i[r],e,i[r+1],t));return n}function y(t,i,n){let r=1e9,o=-1e9,l=[];function a(t,i,a,h,c){let f=e.coordsAtPos(t,t==n.to?-2:2),p=e.coordsAtPos(a,a==n.from?2:-2);f&&p&&(r=Math.min(f.top,p.top,r),o=Math.max(f.bottom,p.bottom,o),c==sg.LTR?l.push(s&&i?d:f.left,s&&h?u:p.right):l.push(!s&&h?d:p.left,!s&&i?u:f.right))}let h=null!=t?t:n.from,c=null!=i?i:n.to;for(let n of e.visibleRanges)if(n.to>h&&n.from<c)for(let r=Math.max(n.from,h),s=Math.min(n.to,c);;){let n=e.state.doc.lineAt(r);for(let o of e.bidiSpans(n)){let e=o.from+n.from,l=o.to+n.from;if(e>=s)break;l>r&&a(Math.max(e,r),null==t&&e<=h,Math.min(l,s),null==i&&l>=c,o.dir)}if((r=n.to+1)>=s)break}return 0==l.length&&a(h,null==t,c,null==i,e.textDirection),{top:r,bottom:o,horizontal:l}}function b(e,t){let i=l.top+(t?e.top:e.bottom);return{top:i,bottom:i,horizontal:[]}}}(e,t,i);{let n=e.coordsAtPos(i.head,i.assoc||1);if(!n)return[];let r=l4(e);return[new l6(t,n.left-r.left,n.top-r.top,null,n.bottom-n.top)]}}}function l4(e){let t=e.scrollDOM.getBoundingClientRect();return{left:(e.textDirection==sg.LTR?t.left:t.right-e.scrollDOM.clientWidth*e.scaleX)-e.scrollDOM.scrollLeft*e.scaleX,top:t.top-e.scrollDOM.scrollTop*e.scaleY}}function l3(e,t,i,n){let r=e.coordsAtPos(t,2*i);if(!r)return n;let s=e.dom.getBoundingClientRect(),o=(r.top+r.bottom)/2,l=e.posAtCoords({x:s.left+1,y:o}),a=e.posAtCoords({x:s.right-1,y:o});return null==l||null==a?n:{from:Math.max(n.from,Math.min(l,a)),to:Math.min(n.to,Math.max(l,a))}}class l8{constructor(e,t){this.view=e,this.layer=t,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),t.above&&this.dom.classList.add("cm-layer-above"),t.class&&this.dom.classList.add(t.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),t.mount&&t.mount(this.dom,e)}update(e){e.startState.facet(l9)!=e.state.facet(l9)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){!1!==this.layer.updateOnDocViewUpdate&&e.requestMeasure(this.measureReq)}setOrder(e){let t=0,i=e.facet(l9);for(;t<i.length&&i[t]!=this.layer;)t++;this.dom.style.zIndex=String((this.layer.above?150:-1)-t)}measure(){return this.layer.markers(this.view)}scale(){let{scaleX:e,scaleY:t}=this.view;(e!=this.scaleX||t!=this.scaleY)&&(this.scaleX=e,this.scaleY=t,this.dom.style.transform=`scale(${1/e}, ${1/t})`)}draw(e){if(e.length!=this.drawn.length||e.some((e,t)=>{var i;return i=this.drawn[t],!(e.constructor==i.constructor&&e.eq(i))})){let t=this.dom.firstChild,i=0;for(let n of e)n.update&&t&&n.constructor&&this.drawn[i].constructor&&n.update(t,this.drawn[i])?(t=t.nextSibling,i++):this.dom.insertBefore(n.draw(),t);for(;t;){let e=t.nextSibling;t.remove(),t=e}this.drawn=e,rK.safari&&rK.safari_version>=26&&(this.dom.style.display=this.dom.firstChild?"":"none")}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}let l9=nD.define();function l7(e){return[sG.define(t=>new l8(t,e)),l9.of(e)]}let ae=nD.define({combine:e=>ri(e,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})});function at(e){return e.startState.facet(ae)!=e.state.facet(ae)}let ai=l7({above:!0,markers(e){let{state:t}=e,i=t.facet(ae),n=[];for(let r of t.selection.ranges){let s=r==t.selection.main;if(r.empty||i.drawRangeCursor){let t=s?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",i=r.empty?r:nA.cursor(r.head,r.head>r.anchor?-1:1);for(let r of l6.forRange(e,t,i))n.push(r)}}return n},update(e,t){e.transactions.some(e=>e.selection)&&(t.style.animationName="cm-blink"==t.style.animationName?"cm-blink2":"cm-blink");let i=at(e);return i&&an(e.state,t),e.docChanged||e.selectionSet||i},mount(e,t){an(t.state,e)},class:"cm-cursorLayer"});function an(e,t){t.style.animationDuration=e.facet(ae).cursorBlinkRate+"ms"}let ar=l7({above:!1,markers:e=>e.state.selection.ranges.map(t=>t.empty?[]:l6.forRange(e,"cm-selectionBackground",t)).reduce((e,t)=>e.concat(t)),update:(e,t)=>e.docChanged||e.selectionSet||e.viewportChanged||at(e),class:"cm-selectionLayer"}),as=nW.highest(l$.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:"transparent !important"},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}})),ao=n5.define({map:(e,t)=>null==e?null:t.mapPos(e)});function al(e,t,i,n,r){t.lastIndex=0;for(let s=e.iterRange(i,n),o=i,l;!s.next().done;o+=s.value.length)if(!s.lineBreak)for(;l=t.exec(s.value);)r(o+l.index,l)}class aa{constructor(e){let{regexp:t,decoration:i,decorate:n,boundary:r,maxLength:s=1e3}=e;if(!t.global)throw RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=t,n)this.addMatch=(e,t,i,r)=>n(r,i,i+e[0].length,e,t);else if("function"==typeof i)this.addMatch=(e,t,n,r)=>{let s=i(e,t,n);s&&r(n,n+e[0].length,s)};else if(i)this.addMatch=(e,t,n,r)=>r(n,n+e[0].length,i);else throw RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.boundary=r,this.maxLength=s}createDeco(e){let t=new rh,i=t.add.bind(t);for(let{from:t,to:n}of function(e,t){let i=e.visibleRanges;if(1==i.length&&i[0].from==e.viewport.from&&i[0].to==e.viewport.to)return i;let n=[];for(let{from:r,to:s}of i)r=Math.max(e.state.doc.lineAt(r).from,r-t),s=Math.min(e.state.doc.lineAt(s).to,s+t),n.length&&n[n.length-1].to>=r?n[n.length-1].to=s:n.push({from:r,to:s});return n}(e,this.maxLength))al(e.state.doc,this.regexp,t,n,(t,n)=>this.addMatch(n,e,t,i));return t.finish()}updateDeco(e,t){let i=1e9,n=-1;return(e.docChanged&&e.changes.iterChanges((t,r,s,o)=>{o>=e.view.viewport.from&&s<=e.view.viewport.to&&(i=Math.min(s,i),n=Math.max(o,n))}),e.viewportMoved||n-i>1e3)?this.createDeco(e.view):n>-1?this.updateRange(e.view,t.map(e.changes),i,n):t}updateRange(e,t,i,n){for(let r of e.visibleRanges){let s=Math.max(r.from,i),o=Math.min(r.to,n);if(o>=s){let i=e.state.doc.lineAt(s),n=i.to<o?e.state.doc.lineAt(o):i,l=Math.max(r.from,i.from),a=Math.min(r.to,n.to);if(this.boundary){for(;s>i.from;s--)if(this.boundary.test(i.text[s-1-i.from])){l=s;break}for(;o<n.to;o++)if(this.boundary.test(n.text[o-n.from])){a=o;break}}let h=[],c,d=(e,t,i)=>h.push(i.range(e,t));if(i==n)for(this.regexp.lastIndex=l-i.from;(c=this.regexp.exec(i.text))&&c.index<a-i.from;)this.addMatch(c,e,c.index+i.from,d);else al(e.state.doc,this.regexp,l,a,(t,i)=>this.addMatch(i,e,t,d));t=t.update({filterFrom:l,filterTo:a,filter:(e,t)=>e<l||t>a,add:h})}}return t}}let ah=null!=/x/.unicode?"gu":"g",ac=RegExp("[\0-\b\n-\x1f\x7f-\x9f\xad\u2028\u2029\uFEFF-]",ah),ad={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8294:"left-to-right isolate",8295:"right-to-left isolate",8297:"pop directional isolate",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"},au=null,af=nD.define({combine(e){let t=ri(e,{render:null,specialChars:ac,addSpecialChars:null});return(t.replaceTabs=!function(){var e;if(null==au&&"undefined"!=typeof document&&document.body){let t=document.body.style;au=(null!==(e=t.tabSize)&&void 0!==e?e:t.MozTabSize)!=null}return au||!1}())&&(t.specialChars=RegExp(" |"+t.specialChars.source,ah)),t.addSpecialChars&&(t.specialChars=RegExp(t.specialChars.source+"|"+t.addSpecialChars.source,ah)),t}}),ap=null;class am extends rX{constructor(e,t){super(),this.options=e,this.code=t}eq(e){return e.code==this.code}toDOM(e){var t;let i=(t=this.code)>=32?"•":10==t?"":String.fromCharCode(9216+t),n=e.state.phrase("Control character")+" "+(ad[this.code]||"0x"+this.code.toString(16)),r=this.options.render&&this.options.render(this.code,n,i);if(r)return r;let s=document.createElement("span");return s.textContent=i,s.title=n,s.setAttribute("aria-label",n),s.className="cm-specialChar",s}ignoreEvent(){return!1}}class ag extends rX{constructor(e){super(),this.width=e}eq(e){return e.width==this.width}toDOM(){let e=document.createElement("span");return e.textContent=" ",e.className="cm-tab",e.style.width=this.width+"px",e}ignoreEvent(){return!1}}let ax=rQ.line({class:"cm-activeLine"}),av=sG.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.docChanged||e.selectionSet)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=-1,i=[];for(let n of e.state.selection.ranges){let r=e.lineBlockAt(n.head);r.from>t&&(i.push(ax.range(r.from)),t=r.from)}return rQ.set(i)}},{decorations:e=>e.decorations});function ay(e,t){var i;let n,r=e.posAtCoords({x:t.clientX,y:t.clientY},!1),s=e.state.doc.lineAt(r),o=r-s.from,l=o>2e3?-1:o==s.length?(i=t.clientX,(n=e.coordsAtPos(e.viewport.from))?Math.round(Math.abs((n.left-i)/e.defaultCharacterWidth)):-1):rb(s.text,e.state.tabSize,r-s.from);return{line:s.number,col:l,off:o}}let ab="-10000px";class aw{constructor(e,t,i,n){this.facet=t,this.createTooltipView=i,this.removeTooltipView=n,this.input=e.state.facet(t),this.tooltips=this.input.filter(e=>e);let r=null;this.tooltipViews=this.tooltips.map(e=>r=i(e,r))}update(e,t){var i;let n=e.state.facet(this.facet),r=n.filter(e=>e);if(n===this.input){for(let t of this.tooltipViews)t.update&&t.update(e);return!1}let s=[],o=t?[]:null;for(let i=0;i<r.length;i++){let n=r[i],l=-1;if(n){for(let e=0;e<this.tooltips.length;e++){let t=this.tooltips[e];t&&t.create==n.create&&(l=e)}if(l<0)s[i]=this.createTooltipView(n,i?s[i-1]:null),o&&(o[i]=!!n.above);else{let n=s[i]=this.tooltipViews[l];o&&(o[i]=t[l]),n.update&&n.update(e)}}}for(let e of this.tooltipViews)0>s.indexOf(e)&&(this.removeTooltipView(e),null===(i=e.destroy)||void 0===i||i.call(e));return t&&(o.forEach((e,i)=>t[i]=e),t.length=o.length),this.input=n,this.tooltips=r,this.tooltipViews=s,!0}}function ak(e){let t=e.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:t.clientHeight,right:t.clientWidth}}let aS=nD.define({combine:e=>{var t,i,n;return{position:rK.ios?"absolute":(null===(t=e.find(e=>e.position))||void 0===t?void 0:t.position)||"fixed",parent:(null===(i=e.find(e=>e.parent))||void 0===i?void 0:i.parent)||null,tooltipSpace:(null===(n=e.find(e=>e.tooltipSpace))||void 0===n?void 0:n.tooltipSpace)||ak}}}),aC=new WeakMap,aj=sG.fromClass(class{constructor(e){this.view=e,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let t=e.state.facet(aS);this.position=t.position,this.parent=t.parent,this.classes=e.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver="function"==typeof ResizeObserver?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new aw(e,aT,(e,t)=>this.createTooltip(e,t),e=>{this.resizeObserver&&this.resizeObserver.unobserve(e.dom),e.dom.remove()}),this.above=this.manager.tooltips.map(e=>!!e.above),this.intersectionObserver="function"==typeof IntersectionObserver?new IntersectionObserver(e=>{Date.now()>this.lastTransaction-50&&e.length>0&&e[e.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),e.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver)for(let e of(this.intersectionObserver.disconnect(),this.manager.tooltipViews))this.intersectionObserver.observe(e.dom)}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(e){e.transactions.length&&(this.lastTransaction=Date.now());let t=this.manager.update(e,this.above);t&&this.observeIntersection();let i=t||e.geometryChanged,n=e.state.facet(aS);if(n.position!=this.position&&!this.madeAbsolute){for(let e of(this.position=n.position,this.manager.tooltipViews))e.dom.style.position=this.position;i=!0}if(n.parent!=this.parent){for(let e of(this.parent&&this.container.remove(),this.parent=n.parent,this.createContainer(),this.manager.tooltipViews))this.container.appendChild(e.dom);i=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);i&&this.maybeMeasure()}createTooltip(e,t){let i=e.create(this.view),n=t?t.dom:null;if(i.dom.classList.add("cm-tooltip"),e.arrow&&!i.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let e=document.createElement("div");e.className="cm-tooltip-arrow",i.dom.appendChild(e)}return i.dom.style.position=this.position,i.dom.style.top=ab,i.dom.style.left="0px",this.container.insertBefore(i.dom,n),i.mount&&i.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(i.dom),i}destroy(){var e,t,i;for(let t of(this.view.win.removeEventListener("resize",this.measureSoon),this.manager.tooltipViews))t.dom.remove(),null===(e=t.destroy)||void 0===e||e.call(t);this.parent&&this.container.remove(),null===(t=this.resizeObserver)||void 0===t||t.disconnect(),null===(i=this.intersectionObserver)||void 0===i||i.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let e=1,t=1,i=!1;if("fixed"==this.position&&this.manager.tooltipViews.length){let{dom:e}=this.manager.tooltipViews[0];if(rK.safari){let t=e.getBoundingClientRect();i=Math.abs(t.top+1e4)>1||Math.abs(t.left)>1}else i=!!e.offsetParent&&e.offsetParent!=this.container.ownerDocument.body}if(i||"absolute"==this.position){if(this.parent){let i=this.parent.getBoundingClientRect();i.width&&i.height&&(e=i.width/this.parent.offsetWidth,t=i.height/this.parent.offsetHeight)}else({scaleX:e,scaleY:t}=this.view.viewState)}let n=this.view.scrollDOM.getBoundingClientRect(),r=s3(this.view);return{visible:{left:n.left+r.left,top:n.top+r.top,right:n.right-r.right,bottom:n.bottom-r.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((e,t)=>{let i=this.manager.tooltipViews[t];return i.getCoords?i.getCoords(e.pos):this.view.coordsAtPos(e.pos)}),size:this.manager.tooltipViews.map(({dom:e})=>e.getBoundingClientRect()),space:this.view.state.facet(aS).tooltipSpace(this.view),scaleX:e,scaleY:t,makeAbsolute:i}}writeMeasure(e){var t;if(e.makeAbsolute)for(let e of(this.madeAbsolute=!0,this.position="absolute",this.manager.tooltipViews))e.dom.style.position="absolute";let{visible:i,space:n,scaleX:r,scaleY:s}=e,o=[];for(let l=0;l<this.manager.tooltips.length;l++){let a=this.manager.tooltips[l],h=this.manager.tooltipViews[l],{dom:c}=h,d=e.pos[l],u=e.size[l];if(!d||!1!==a.clip&&(d.bottom<=Math.max(i.top,n.top)||d.top>=Math.min(i.bottom,n.bottom)||d.right<Math.max(i.left,n.left)-.1||d.left>Math.min(i.right,n.right)+.1)){c.style.top=ab;continue}let f=a.arrow?h.dom.querySelector(".cm-tooltip-arrow"):null,p=f?7:0,m=u.right-u.left,g=null!==(t=aC.get(h))&&void 0!==t?t:u.bottom-u.top,x=h.offset||aA,v=this.view.textDirection==sg.LTR,y=u.width>n.right-n.left?v?n.left:n.right-u.width:v?Math.max(n.left,Math.min(d.left-(f?14:0)+x.x,n.right-m)):Math.min(Math.max(n.left,d.left-m+(f?14:0)-x.x),n.right-m),b=this.above[l];!a.strictSide&&(b?d.top-g-p-x.y<n.top:d.bottom+g+p+x.y>n.bottom)&&b==n.bottom-d.bottom>d.top-n.top&&(b=this.above[l]=!b);let w=(b?d.top-n.top:n.bottom-d.bottom)-p;if(w<g&&!1!==h.resize){if(w<this.view.defaultLineHeight){c.style.top=ab;continue}aC.set(h,g),c.style.height=(g=w)/s+"px"}else c.style.height&&(c.style.height="");let k=b?d.top-g-p-x.y:d.bottom+p+x.y,S=y+m;if(!0!==h.overlap)for(let e of o)e.left<S&&e.right>y&&e.top<k+g&&e.bottom>k&&(k=b?e.top-g-2-p:e.bottom+p+2);if("absolute"==this.position?(c.style.top=(k-e.parent.top)/s+"px",aM(c,(y-e.parent.left)/r)):(c.style.top=k/s+"px",aM(c,y/r)),f){let e=d.left+(v?x.x:-x.x)-(y+14-7);f.style.left=e/r+"px"}!0!==h.overlap&&o.push({left:y,top:k,right:S,bottom:k+g}),c.classList.toggle("cm-tooltip-above",b),c.classList.toggle("cm-tooltip-below",!b),h.positioned&&h.positioned(e.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let e of this.manager.tooltipViews)e.dom.style.top=ab}},{eventObservers:{scroll(){this.maybeMeasure()}}});function aM(e,t){let i=parseInt(e.style.left,10);(isNaN(i)||Math.abs(t-i)>1)&&(e.style.left=t+"px")}let aZ=l$.baseTheme({".cm-tooltip":{zIndex:500,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:"14px",position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),aA={x:0,y:0},aT=nD.define({enables:[aj,aZ]}),aO=nD.define({combine:e=>e.reduce((e,t)=>e.concat(t),[])});class aD{static create(e){return new aD(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new aw(e,aO,(e,t)=>this.createHostedView(e,t),e=>e.dom.remove())}createHostedView(e,t){let i=e.create(this.view);return i.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(i.dom,t?t.dom.nextSibling:this.dom.firstChild),this.mounted&&i.mount&&i.mount(this.view),i}mount(e){for(let t of this.manager.tooltipViews)t.mount&&t.mount(e);this.mounted=!0}positioned(e){for(let t of this.manager.tooltipViews)t.positioned&&t.positioned(e)}update(e){this.manager.update(e)}destroy(){var e;for(let t of this.manager.tooltipViews)null===(e=t.destroy)||void 0===e||e.call(t)}passProp(e){let t;for(let i of this.manager.tooltipViews){let n=i[e];if(void 0!==n){if(void 0===t)t=n;else if(t!==n)return}}return t}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}}let aR=nD.define({combine(e){let t,i;for(let n of e)t=t||n.topContainer,i=i||n.bottomContainer;return{topContainer:t,bottomContainer:i}}});function aP(e,t){let i=e.plugin(aL),n=i?i.specs.indexOf(t):-1;return n>-1?i.panels[n]:null}let aL=sG.fromClass(class{constructor(e){this.input=e.state.facet(aB),this.specs=this.input.filter(e=>e),this.panels=this.specs.map(t=>t(e));let t=e.state.facet(aR);for(let i of(this.top=new aI(e,!0,t.topContainer),this.bottom=new aI(e,!1,t.bottomContainer),this.top.sync(this.panels.filter(e=>e.top)),this.bottom.sync(this.panels.filter(e=>!e.top)),this.panels))i.dom.classList.add("cm-panel"),i.mount&&i.mount()}update(e){let t=e.state.facet(aR);this.top.container!=t.topContainer&&(this.top.sync([]),this.top=new aI(e.view,!0,t.topContainer)),this.bottom.container!=t.bottomContainer&&(this.bottom.sync([]),this.bottom=new aI(e.view,!1,t.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let i=e.state.facet(aB);if(i!=this.input){let t=i.filter(e=>e),n=[],r=[],s=[],o=[];for(let i of t){let t=this.specs.indexOf(i),l;t<0?(l=i(e.view),o.push(l)):(l=this.panels[t]).update&&l.update(e),n.push(l),(l.top?r:s).push(l)}for(let e of(this.specs=t,this.panels=n,this.top.sync(r),this.bottom.sync(s),o))e.dom.classList.add("cm-panel"),e.mount&&e.mount()}else for(let t of this.panels)t.update&&t.update(e)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:e=>l$.scrollMargins.of(t=>{let i=t.plugin(e);return i&&{top:i.top.scrollMargin(),bottom:i.bottom.scrollMargin()}})});class aI{constructor(e,t,i){this.view=e,this.top=t,this.container=i,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(e){for(let t of this.panels)t.destroy&&0>e.indexOf(t)&&t.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(0==this.panels.length){this.dom&&(this.dom.remove(),this.dom=void 0);return}if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom",this.dom.style[this.top?"top":"bottom"]="0";let e=this.container||this.view.dom;e.insertBefore(this.dom,this.top?e.firstChild:null)}let e=this.dom.firstChild;for(let t of this.panels)if(t.dom.parentNode==this.dom){for(;e!=t.dom;)e=aE(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=aE(e)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(this.container&&this.classes!=this.view.themeClasses){for(let e of this.classes.split(" "))e&&this.container.classList.remove(e);for(let e of(this.classes=this.view.themeClasses).split(" "))e&&this.container.classList.add(e)}}}function aE(e){let t=e.nextSibling;return e.remove(),t}let aB=nD.define({enables:aL}),aN=nB.define({create:()=>[],update(e,t){for(let i of t.effects)i.is(az)?e=[i.value].concat(e):i.is(aW)&&(e=e.filter(e=>e!=i.value));return e},provide:e=>aB.computeN([e],t=>t.field(e))}),az=n5.define(),aW=n5.define();class aF extends rn{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}aF.prototype.elementClass="",aF.prototype.toDOM=void 0,aF.prototype.mapMode=nv.TrackBefore,aF.prototype.startSide=aF.prototype.endSide=-1,aF.prototype.point=!0;let aV=nD.define(),aH=nD.define(),a$={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>ra.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{},side:"before"},aq=nD.define(),aK=nD.define({combine:e=>e.some(e=>e)});function aU(e){let t=[a_];return e&&!1===e.fixed&&t.push(aK.of(!0)),t}let a_=sG.fromClass(class{constructor(e){for(let t of(this.view=e,this.domAfter=null,this.prevViewport=e.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters cm-gutters-before",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=e.state.facet(aq).map(t=>new aY(e,t)),this.fixed=!e.state.facet(aK),this.gutters))"after"==t.config.side?this.getDOMAfter().appendChild(t.dom):this.dom.appendChild(t.dom);this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),e.scrollDOM.insertBefore(this.dom,e.contentDOM)}getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement("div"),this.domAfter.className="cm-gutters cm-gutters-after",this.domAfter.setAttribute("aria-hidden","true"),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.domAfter.style.position=this.fixed?"sticky":"",this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(e){if(this.updateGutters(e)){let t=this.prevViewport,i=e.view.viewport,n=Math.min(t.to,i.to)-Math.max(t.from,i.from);this.syncGutters(n<(i.to-i.from)*.8)}if(e.geometryChanged){let e=this.view.contentHeight/this.view.scaleY+"px";this.dom.style.minHeight=e,this.domAfter&&(this.domAfter.style.minHeight=e)}this.view.state.facet(aK)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=e.view.viewport}syncGutters(e){let t=this.dom.nextSibling;e&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let i=ra.iter(this.view.state.facet(aV),this.view.viewport.from),n=[],r=this.gutters.map(e=>new aX(e,this.view.viewport,-this.view.documentPadding.top));for(let e of this.view.viewportLineBlocks)if(n.length&&(n=[]),Array.isArray(e.type)){let t=!0;for(let s of e.type)if(s.type==rY.Text&&t){for(let e of(aJ(i,n,s.from),r))e.line(this.view,s,n);t=!1}else if(s.widget)for(let e of r)e.widget(this.view,s)}else if(e.type==rY.Text)for(let t of(aJ(i,n,e.from),r))t.line(this.view,e,n);else if(e.widget)for(let t of r)t.widget(this.view,e);for(let e of r)e.finish();e&&(this.view.scrollDOM.insertBefore(this.dom,t),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(e){let t=e.startState.facet(aq),i=e.state.facet(aq),n=e.docChanged||e.heightChanged||e.viewportChanged||!ra.eq(e.startState.facet(aV),e.state.facet(aV),e.view.viewport.from,e.view.viewport.to);if(t==i)for(let t of this.gutters)t.update(e)&&(n=!0);else{n=!0;let r=[];for(let n of i){let i=t.indexOf(n);i<0?r.push(new aY(this.view,n)):(this.gutters[i].update(e),r.push(this.gutters[i]))}for(let e of this.gutters)e.dom.remove(),0>r.indexOf(e)&&e.destroy();for(let e of r)"after"==e.config.side?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.gutters=r}return n}destroy(){for(let e of this.gutters)e.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:e=>l$.scrollMargins.of(t=>{let i=t.plugin(e);if(!i||0==i.gutters.length||!i.fixed)return null;let n=i.dom.offsetWidth*t.scaleX,r=i.domAfter?i.domAfter.offsetWidth*t.scaleX:0;return t.textDirection==sg.LTR?{left:n,right:r}:{right:n,left:r}})});function aG(e){return Array.isArray(e)?e:[e]}function aJ(e,t,i){for(;e.value&&e.from<=i;)e.from==i&&t.push(e.value),e.next()}class aX{constructor(e,t,i){this.gutter=e,this.height=i,this.i=0,this.cursor=ra.iter(e.markers,t.from)}addElement(e,t,i){let{gutter:n}=this,r=(t.top-this.height)/e.scaleY,s=t.height/e.scaleY;if(this.i==n.elements.length){let t=new aQ(e,s,r,i);n.elements.push(t),n.dom.appendChild(t.dom)}else n.elements[this.i].update(e,s,r,i);this.height=t.bottom,this.i++}line(e,t,i){let n=[];aJ(this.cursor,n,t.from),i.length&&(n=n.concat(i));let r=this.gutter.config.lineMarker(e,t,n);r&&n.unshift(r);let s=this.gutter;(0!=n.length||s.config.renderEmptyElements)&&this.addElement(e,t,n)}widget(e,t){let i=this.gutter.config.widgetMarker(e,t.widget,t),n=i?[i]:null;for(let i of e.state.facet(aH)){let r=i(e,t.widget,t);r&&(n||(n=[])).push(r)}n&&this.addElement(e,t,n)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}}class aY{constructor(e,t){for(let i in this.view=e,this.config=t,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:""),t.domEventHandlers)this.dom.addEventListener(i,n=>{let r=n.target,s;if(r!=this.dom&&this.dom.contains(r)){for(;r.parentNode!=this.dom;)r=r.parentNode;let e=r.getBoundingClientRect();s=(e.top+e.bottom)/2}else s=n.clientY;let o=e.lineBlockAtHeight(s-e.documentTop);t.domEventHandlers[i](e,o,n)&&n.preventDefault()});this.markers=aG(t.markers(e)),t.initialSpacer&&(this.spacer=new aQ(e,0,0,[t.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let t=this.markers;if(this.markers=aG(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let t=this.config.updateSpacer(this.spacer.markers[0],e);t!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[t])}let i=e.view.viewport;return!ra.eq(this.markers,t,i.from,i.to)||!!this.config.lineMarkerChange&&this.config.lineMarkerChange(e)}destroy(){for(let e of this.elements)e.destroy()}}class aQ{constructor(e,t,i,n){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,t,i,n)}update(e,t,i,n){this.height!=t&&(this.height=t,this.dom.style.height=t+"px"),this.above!=i&&(this.dom.style.marginTop=(this.above=i)?i+"px":""),!function(e,t){if(e.length!=t.length)return!1;for(let i=0;i<e.length;i++)if(!e[i].compare(t[i]))return!1;return!0}(this.markers,n)&&this.setMarkers(e,n)}setMarkers(e,t){let i="cm-gutterElement",n=this.dom.firstChild;for(let r=0,s=0;;){let o=s,l=r<t.length?t[r++]:null,a=!1;if(l){let e=l.elementClass;e&&(i+=" "+e);for(let e=s;e<this.markers.length;e++)if(this.markers[e].compare(l)){o=e,a=!0;break}}else o=this.markers.length;for(;s<o;){let e=this.markers[s++];if(e.toDOM){e.destroy(n);let t=n.nextSibling;n.remove(),n=t}}if(!l)break;l.toDOM&&(a?n=n.nextSibling:this.dom.insertBefore(l.toDOM(e),n)),a&&s++}this.dom.className=i,this.markers=t}destroy(){this.setMarkers(null,[])}}let a0=nD.define(),a1=nD.define(),a2=nD.define({combine:e=>ri(e,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(e,t){let i=Object.assign({},e);for(let e in t){let n=i[e],r=t[e];i[e]=n?(e,t,i)=>n(e,t,i)||r(e,t,i):r}return i}})});class a5 extends aF{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function a6(e,t){return e.state.facet(a2).formatNumber(t,e.state)}let a4=aq.compute([a2],e=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers:e=>e.state.facet(a0),lineMarker:(e,t,i)=>i.some(e=>e.toDOM)?null:new a5(a6(e,e.state.doc.lineAt(t.from).number)),widgetMarker:(e,t,i)=>{for(let n of e.state.facet(a1)){let r=n(e,t,i);if(r)return r}return null},lineMarkerChange:e=>e.startState.facet(a2)!=e.state.facet(a2),initialSpacer:e=>new a5(a6(e,a3(e.state.doc.lines))),updateSpacer(e,t){let i=a6(t.view,a3(t.view.state.doc.lines));return i==e.number?e:new a5(i)},domEventHandlers:e.facet(a2).domEventHandlers,side:"before"}));function a3(e){let t=9;for(;t<e;)t=10*t+9;return t}let a8=0;class a9{constructor(e,t){this.from=e,this.to=t}}class a7{constructor(e={}){this.id=a8++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw RangeError("Can't add per-node props to node types");return"function"!=typeof e&&(e=hi.match(e)),t=>{let i=e(t);return void 0===i?null:[this,i]}}}a7.closedBy=new a7({deserialize:e=>e.split(" ")}),a7.openedBy=new a7({deserialize:e=>e.split(" ")}),a7.group=new a7({deserialize:e=>e.split(" ")}),a7.isolate=new a7({deserialize:e=>{if(e&&"rtl"!=e&&"ltr"!=e&&"auto"!=e)throw RangeError("Invalid value for isolate: "+e);return e||"auto"}}),a7.contextHash=new a7({perNode:!0}),a7.lookAhead=new a7({perNode:!0}),a7.mounted=new a7({perNode:!0});class he{constructor(e,t,i,n=!1){this.tree=e,this.overlay=t,this.parser=i,this.bracketed=n}static get(e){return e&&e.props&&e.props[a7.mounted.id]}}let ht=Object.create(null);class hi{constructor(e,t,i,n=0){this.name=e,this.props=t,this.id=i,this.flags=n}static define(e){let t=e.props&&e.props.length?Object.create(null):ht,i=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(null==e.name?8:0),n=new hi(e.name||"",t,e.id,i);if(e.props){for(let i of e.props)if(Array.isArray(i)||(i=i(n)),i){if(i[0].perNode)throw RangeError("Can't store a per-node prop on a node type");t[i[0].id]=i[1]}}return n}prop(e){return this.props[e.id]}get isTop(){return(1&this.flags)>0}get isSkipped(){return(2&this.flags)>0}get isError(){return(4&this.flags)>0}get isAnonymous(){return(8&this.flags)>0}is(e){if("string"==typeof e){if(this.name==e)return!0;let t=this.prop(a7.group);return!!t&&t.indexOf(e)>-1}return this.id==e}static match(e){let t=Object.create(null);for(let i in e)for(let n of i.split(" "))t[n]=e[i];return e=>{for(let i=e.prop(a7.group),n=-1;n<(i?i.length:0);n++){let r=t[n<0?e.name:i[n]];if(r)return r}}}}hi.none=new hi("",Object.create(null),0,8);class hn{constructor(e){this.types=e;for(let t=0;t<e.length;t++)if(e[t].id!=t)throw RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...e){let t=[];for(let i of this.types){let n=null;for(let t of e){let e=t(i);if(e){n||(n=Object.assign({},i.props));let t=e[1],r=e[0];r.combine&&r.id in n&&(t=r.combine(n[r.id],t)),n[r.id]=t}}t.push(n?new hi(i.name,n,i.id,i.flags):i)}return new hn(t)}}let hr=new WeakMap,hs=new WeakMap;!function(e){e[e.ExcludeBuffers=1]="ExcludeBuffers",e[e.IncludeAnonymous=2]="IncludeAnonymous",e[e.IgnoreMounts=4]="IgnoreMounts",e[e.IgnoreOverlays=8]="IgnoreOverlays",e[e.EnterBracketed=16]="EnterBracketed"}(l||(l={}));class ho{constructor(e,t,i,n,r){if(this.type=e,this.children=t,this.positions=i,this.length=n,this.props=null,r&&r.length)for(let[e,t]of(this.props=Object.create(null),r))this.props["number"==typeof e?e:e.id]=t}toString(){let e=he.get(this);if(e&&!e.overlay)return e.tree.toString();let t="";for(let e of this.children){let i=e.toString();i&&(t&&(t+=","),t+=i)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?"("+t+")":""):t}cursor(e=0){return new hy(this.topNode,e)}cursorAt(e,t=0,i=0){let n=new hy(hr.get(this)||this.topNode);return n.moveTo(e,t),hr.set(this,n._tree),n}get topNode(){return new hu(this,0,0,null)}resolve(e,t=0){let i=hc(hr.get(this)||this.topNode,e,t,!1);return hr.set(this,i),i}resolveInner(e,t=0){let i=hc(hs.get(this)||this.topNode,e,t,!0);return hs.set(this,i),i}resolveStack(e,t=0){return function(e,t,i){let n=e.resolveInner(t,i),r=null;for(let e=n instanceof hu?n:n.context.parent;e;e=e.parent)if(e.index<0){let s=e.parent;(r||(r=[n])).push(s.resolve(t,i)),e=s}else{let s=he.get(e.tree);if(s&&s.overlay&&s.overlay[0].from<=t&&s.overlay[s.overlay.length-1].to>=t){let o=new hu(s.tree,s.overlay[0].from+e.from,-1,e);(r||(r=[n])).push(hc(o,t,i,!1))}}return r?hx(r):n}(this,e,t)}iterate(e){let{enter:t,leave:i,from:n=0,to:r=this.length}=e,s=e.mode||0,o=(s&l.IncludeAnonymous)>0;for(let e=this.cursor(s|l.IncludeAnonymous);;){let s=!1;if(e.from<=r&&e.to>=n&&(!o&&e.type.isAnonymous||!1!==t(e))){if(e.firstChild())continue;s=!0}for(;s&&i&&(o||!e.type.isAnonymous)&&i(e),!e.nextSibling();){if(!e.parent())return;s=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(e={}){return this.children.length<=8?this:hS(hi.none,this.children,this.positions,0,this.children.length,0,this.length,(e,t,i)=>new ho(this.type,e,t,i,this.propValues),e.makeTree||((e,t,i)=>new ho(hi.none,e,t,i)))}static build(e){return function(e){var t;let{buffer:i,nodeSet:n,maxBufferLength:r=1024,reused:s=[],minRepeatType:o=n.types.length}=e,l=Array.isArray(i)?new hl(i,i.length):i,a=n.types,h=0,c=0;function d(e,t,i,r,s,o,l,a,h){let c=[],d=[];for(;e.length>r;)c.push(e.pop()),d.push(t.pop()+i-s);e.push(u(n.types[l],c,d,o-s,a-o,h)),t.push(s-i)}function u(e,t,i,n,r,s,o){if(s){let e=[a7.contextHash,s];o=o?[e].concat(o):[e]}if(r>25){let e=[a7.lookAhead,r];o=o?[e].concat(o):[e]}return new ho(e,t,i,n,o)}let f=[],p=[];for(;l.pos>0;)!function e(t,i,f,p,m,g){let{id:x,start:v,end:y,size:b}=l,w=c,k=h;if(b<0){if(l.next(),-1==b){let e=s[x];f.push(e),p.push(v-t);return}if(-3==b){h=x;return}if(-4==b){c=x;return}throw RangeError(`Unrecognized record size: ${b}`)}let S=a[x],C,j,M=v-t;if(y-v<=r&&(j=function(e,t){let i=l.fork(),n=0,s=0,a=0,h=i.end-r,c={size:0,start:0,skip:0};n:for(let r=i.pos-e;i.pos>r;){let e=i.size;if(i.id==t&&e>=0){c.size=n,c.start=s,c.skip=a,a+=4,n+=4,i.next();continue}let l=i.pos-e;if(e<0||l<r||i.start<h)break;let d=i.id>=o?4:0,u=i.start;for(i.next();i.pos>l;){if(i.size<0){if(-3==i.size||-4==i.size)d+=4;else break n}else i.id>=o&&(d+=4);i.next()}s=u,n+=e,a+=d}return(t<0||n==e)&&(c.size=n,c.start=s,c.skip=a),c.size>4?c:void 0}(l.pos-i,m))){let e=new Uint16Array(j.size-j.skip),i=l.pos-j.size,r=e.length;for(;l.pos>i;)r=function e(t,i,n){let{id:r,start:s,end:a,size:d}=l;if(l.next(),d>=0&&r<o){let o=n;if(d>4){let r=l.pos-(d-4);for(;l.pos>r;)n=e(t,i,n)}i[--n]=o,i[--n]=a-t,i[--n]=s-t,i[--n]=r}else -3==d?h=r:-4==d&&(c=r);return n}(j.start,e,r);C=new ha(e,y-j.start,n),M=j.start-t}else{let t=l.pos-b;l.next();let i=[],s=[],a=x>=o?x:-1,h=0,c=y;for(;l.pos>t;)a>=0&&l.id==a&&l.size>=0?(l.end<=c-r&&(d(i,s,v,h,l.end,c,a,w,k),h=i.length,c=l.end),l.next()):g>2500?function(e,t,i,s){let o=[],a=0,h=-1;for(;l.pos>t;){let{id:e,start:t,end:i,size:n}=l;if(n>4)l.next();else if(h>-1&&t<h)break;else h<0&&(h=i-r),o.push(e,t,i),a++,l.next()}if(a){let t=new Uint16Array(4*a),r=o[o.length-2];for(let e=o.length-3,i=0;e>=0;e-=3)t[i++]=o[e],t[i++]=o[e+1]-r,t[i++]=o[e+2]-r,t[i++]=i;i.push(new ha(t,o[2]-r,n)),s.push(r-e)}}(v,t,i,s):e(v,t,i,s,a,g+1);if(a>=0&&h>0&&h<i.length&&d(i,s,v,h,v,c,a,w,k),i.reverse(),s.reverse(),a>-1&&h>0){let e=function(e,t){return(i,n,r)=>{let s=0,o=i.length-1,l,a;if(o>=0&&(l=i[o])instanceof ho){if(!o&&l.type==e&&l.length==r)return l;(a=l.prop(a7.lookAhead))&&(s=n[o]+l.length+a)}return u(e,i,n,r,s,t)}}(S,k);C=hS(S,i,s,0,i.length,0,y-v,e,e)}else C=u(S,i,s,y-v,w-y,k)}f.push(C),p.push(M)}(e.start||0,e.bufferStart||0,f,p,-1,0);let m=null!==(t=e.length)&&void 0!==t?t:f.length?p[0]+f[0].length:0;return new ho(a[e.topID],f.reverse(),p.reverse(),m)}(e)}}ho.empty=new ho(hi.none,[],[],0);class hl{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new hl(this.buffer,this.index)}}class ha{constructor(e,t,i){this.buffer=e,this.length=t,this.set=i}get type(){return hi.none}toString(){let e=[];for(let t=0;t<this.buffer.length;)e.push(this.childString(t)),t=this.buffer[t+3];return e.join(",")}childString(e){let t=this.buffer[e],i=this.buffer[e+3],n=this.set.types[t],r=n.name;if(/\W/.test(r)&&!n.isError&&(r=JSON.stringify(r)),i==(e+=4))return r;let s=[];for(;e<i;)s.push(this.childString(e)),e=this.buffer[e+3];return r+"("+s.join(",")+")"}findChild(e,t,i,n,r){let{buffer:s}=this,o=-1;for(let l=e;l!=t&&(!hh(r,n,s[l+1],s[l+2])||(o=l,!(i>0)));l=s[l+3]);return o}slice(e,t,i){let n=this.buffer,r=new Uint16Array(t-e),s=0;for(let o=e,l=0;o<t;){r[l++]=n[o++],r[l++]=n[o++]-i;let t=r[l++]=n[o++]-i;r[l++]=n[o++]-e,s=Math.max(s,t)}return new ha(r,s,this.set)}}function hh(e,t,i,n){switch(e){case -2:return i<t;case -1:return n>=t&&i<t;case 0:return i<t&&n>t;case 1:return i<=t&&n>t;case 2:return n>t;case 4:return!0}}function hc(e,t,i,n){for(var r;e.from==e.to||(i<1?e.from>=t:e.from>t)||(i>-1?e.to<=t:e.to<t);){let t=!n&&e instanceof hu&&e.index<0?null:e.parent;if(!t)return e;e=t}let s=n?0:l.IgnoreOverlays;if(n)for(let n=e,o=n.parent;o;o=(n=o).parent)n instanceof hu&&n.index<0&&(null===(r=o.enter(t,i,s))||void 0===r?void 0:r.from)!=n.from&&(e=o);for(;;){let n=e.enter(t,i,s);if(!n)return e;e=n}}class hd{cursor(e=0){return new hy(this,e)}getChild(e,t=null,i=null){let n=hf(this,e,t,i);return n.length?n[0]:null}getChildren(e,t=null,i=null){return hf(this,e,t,i)}resolve(e,t=0){return hc(this,e,t,!1)}resolveInner(e,t=0){return hc(this,e,t,!0)}matchContext(e){return hp(this.parent,e)}enterUnfinishedNodesBefore(e){let t=this.childBefore(e),i=this;for(;t;){let e=t.lastChild;if(!e||e.to!=t.to)break;e.type.isError&&e.from==e.to?(i=t,t=e.prevSibling):t=e}return i}get node(){return this}get next(){return this.parent}}class hu extends hd{constructor(e,t,i,n){super(),this._tree=e,this.from=t,this.index=i,this._parent=n}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,t,i,n,r=0){for(let s=this;;){for(let{children:o,positions:a}=s._tree,h=t>0?o.length:-1;e!=h;e+=t){let h=o[e],c=a[e]+s.from,d;if(r&l.EnterBracketed&&h instanceof ho&&(d=he.get(h))&&!d.overlay&&d.bracketed&&i>=c&&i<=c+h.length||hh(n,i,c,c+h.length)){if(h instanceof ha){if(r&l.ExcludeBuffers)continue;let o=h.findChild(0,h.buffer.length,t,i-c,n);if(o>-1)return new hg(new hm(s,h,e,c),null,o)}else if(r&l.IncludeAnonymous||!h.type.isAnonymous||hb(h)){let o;if(!(r&l.IgnoreMounts)&&(o=he.get(h))&&!o.overlay)return new hu(o.tree,c,e,s);let a=new hu(h,c,e,s);return r&l.IncludeAnonymous||!a.type.isAnonymous?a:a.nextChild(t<0?h.children.length-1:0,t,i,n,r)}}}if(r&l.IncludeAnonymous||!s.type.isAnonymous||(e=s.index>=0?s.index+t:t<0?-1:s._parent._tree.children.length,!(s=s._parent)))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}prop(e){return this._tree.prop(e)}enter(e,t,i=0){let n;if(!(i&l.IgnoreOverlays)&&(n=he.get(this._tree))&&n.overlay){let r=e-this.from,s=i&l.EnterBracketed&&n.bracketed;for(let{from:e,to:i}of n.overlay)if((t>0||s?e<=r:e<r)&&(t<0||s?i>=r:i>r))return new hu(n.tree,n.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,i)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function hf(e,t,i,n){let r=e.cursor(),s=[];if(!r.firstChild())return s;if(null!=i){for(let e=!1;!e;)if(e=r.type.is(i),!r.nextSibling())return s}for(;;){if(null!=n&&r.type.is(n))return s;if(r.type.is(t)&&s.push(r.node),!r.nextSibling())return null==n?s:[]}}function hp(e,t,i=t.length-1){for(let n=e;i>=0;n=n.parent){if(!n)return!1;if(!n.type.isAnonymous){if(t[i]&&t[i]!=n.name)return!1;i--}}return!0}class hm{constructor(e,t,i,n){this.parent=e,this.buffer=t,this.index=i,this.start=n}}class hg extends hd{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,i){super(),this.context=e,this._parent=t,this.index=i,this.type=e.buffer.set.types[e.buffer.buffer[i]]}child(e,t,i){let{buffer:n}=this.context,r=n.findChild(this.index+4,n.buffer[this.index+3],e,t-this.context.start,i);return r<0?null:new hg(this.context,this,r)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}prop(e){return this.type.prop(e)}enter(e,t,i=0){if(i&l.ExcludeBuffers)return null;let{buffer:n}=this.context,r=n.findChild(this.index+4,n.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return r<0?null:new hg(this.context,this,r)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new hg(this.context,this._parent,t):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,t=this._parent?this._parent.index+4:0;return this.index==t?this.externalSibling(-1):new hg(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:i}=this.context,n=this.index+4,r=i.buffer[this.index+3];if(r>n){let s=i.buffer[this.index+1];e.push(i.slice(n,r,s)),t.push(0)}return new ho(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function hx(e){if(!e.length)return null;let t=0,i=e[0];for(let n=1;n<e.length;n++){let r=e[n];(r.from>i.from||r.to<i.to)&&(i=r,t=n)}let n=i instanceof hu&&i.index<0?null:i.parent,r=e.slice();return n?r[t]=n:r.splice(t,1),new hv(r,i)}class hv{constructor(e,t){this.heads=e,this.node=t}get next(){return hx(this.heads)}}class hy{get name(){return this.type.name}constructor(e,t=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=t&~l.EnterBracketed,e instanceof hu)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let t=e._parent;t;t=t._parent)this.stack.unshift(t.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return!!e&&(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0)}yieldBuf(e,t){this.index=e;let{start:i,buffer:n}=this.buffer;return this.type=t||n.set.types[n.buffer[e]],this.from=i+n.buffer[e+1],this.to=i+n.buffer[e+2],!0}yield(e){return!!e&&(e instanceof hu?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)))}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,i){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,i,this.mode));let{buffer:n}=this.buffer,r=n.findChild(this.index+4,n.buffer[this.index+3],e,t-this.buffer.start,i);return!(r<0)&&(this.stack.push(this.index),this.yieldBuf(r))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,i=this.mode){return this.buffer?!(i&l.ExcludeBuffers)&&this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&l.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&l.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return!!this._tree._parent&&this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode));let{buffer:t}=this.buffer,i=this.stack.length-1;if(e<0){let e=i<0?0:this.stack[i]+4;if(this.index!=e)return this.yieldBuf(t.findChild(e,this.index,-1,0,4))}else{let e=t.buffer[this.index+3];if(e<(i<0?t.buffer.length:t.buffer[this.stack[i]+3]))return this.yieldBuf(e)}return i<0&&this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode))}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,i,{buffer:n}=this;if(n){if(e>0){if(this.index<n.buffer.buffer.length)return!1}else for(let e=0;e<this.index;e++)if(n.buffer.buffer[e+3]<this.index)return!1;({index:t,parent:i}=n)}else({index:t,_parent:i}=this._tree);for(;i;{index:t,_parent:i}=i)if(t>-1)for(let n=t+e,r=e<0?-1:i._tree.children.length;n!=r;n+=e){let e=i._tree.children[n];if(this.mode&l.IncludeAnonymous||e instanceof ha||!e.type.isAnonymous||hb(e))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,t););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,t=null,i=0;if(e&&e.context==this.buffer)n:for(let n=this.index,r=this.stack.length;r>=0;){for(let s=e;s;s=s._parent)if(s.index==n){if(n==this.index)return s;t=s,i=r+1;break n}n=this.stack[--r]}for(let e=i;e<this.stack.length;e++)t=new hg(this.buffer,t,this.stack[e]);return this.bufferNode=new hg(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let i=0;;){let n=!1;if(this.type.isAnonymous||!1!==e(this)){if(this.firstChild()){i++;continue}this.type.isAnonymous||(n=!0)}for(;;){if(n&&t&&t(this),n=this.type.isAnonymous,!i)return;if(this.nextSibling())break;this.parent(),i--,n=!0}}}matchContext(e){if(!this.buffer)return hp(this.node.parent,e);let{buffer:t}=this.buffer,{types:i}=t.set;for(let n=e.length-1,r=this.stack.length-1;n>=0;r--){if(r<0)return hp(this._tree,e,n);let s=i[t.buffer[this.stack[r]]];if(!s.isAnonymous){if(e[n]&&e[n]!=s.name)return!1;n--}}return!0}}function hb(e){return e.children.some(e=>e instanceof ha||!e.type.isAnonymous||hb(e))}let hw=new WeakMap;function hk(e,t){if(!e.isAnonymous||t instanceof ha||t.type!=e)return 1;let i=hw.get(t);if(null==i){for(let n of(i=1,t.children)){if(n.type!=e||!(n instanceof ho)){i=1;break}i+=hk(e,n)}hw.set(t,i)}return i}function hS(e,t,i,n,r,s,o,l,a){let h=0;for(let i=n;i<r;i++)h+=hk(e,t[i]);let c=Math.ceil(1.5*h/8),d=[],u=[];return function t(i,n,r,o,l){for(let h=r;h<o;){let r=h,f=n[h],p=hk(e,i[h]);for(h++;h<o;h++){let t=hk(e,i[h]);if(p+t>=c)break;p+=t}if(h==r+1){if(p>c){let e=i[r];t(e.children,e.positions,0,e.children.length,n[r]+l);continue}d.push(i[r])}else{let t=n[h-1]+i[h-1].length-f;d.push(hS(e,i,n,r,h,f,t,null,a))}u.push(f+l-s)}}(t,i,n,r,0),(l||a)(d,u,o)}class hC{constructor(e,t,i,n,r=!1,s=!1){this.from=e,this.to=t,this.tree=i,this.offset=n,this.open=(r?1:0)|(s?2:0)}get openStart(){return(1&this.open)>0}get openEnd(){return(2&this.open)>0}static addTree(e,t=[],i=!1){let n=[new hC(0,e.length,e,0,!1,i)];for(let i of t)i.to>e.length&&n.push(i);return n}static applyChanges(e,t,i=128){if(!t.length)return e;let n=[],r=1,s=e.length?e[0]:null;for(let o=0,l=0,a=0;;o++){let h=o<t.length?t[o]:null,c=h?h.fromA:1e9;if(c-l>=i)for(;s&&s.from<c;){let t=s;if(l>=t.from||c<=t.to||a){let e=Math.max(t.from,l)-a,i=Math.min(t.to,c)-a;t=e>=i?null:new hC(e,i,t.tree,t.offset+a,o>0,!!h)}if(t&&n.push(t),s.to>c)break;s=r<e.length?e[r++]:null}if(!h)break;l=h.toA,a=h.toA-h.toB}return n}}class hj{startParse(e,t,i){return"string"==typeof e&&(e=new hM(e)),i=i?i.length?i.map(e=>new a9(e.from,e.to)):[new a9(0,0)]:[new a9(0,e.length)],this.createParse(e,t||[],i)}parse(e,t,i){let n=this.startParse(e,t,i);for(;;){let e=n.advance();if(e)return e}}}class hM{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}}let hZ=new a7({perNode:!0});class hA{constructor(e,t){this.offset=t,this.done=!1,this.cursor=e.cursor(l.IncludeAnonymous|l.IgnoreMounts)}moveTo(e){let{cursor:t}=this,i=e-this.offset;for(;!this.done&&t.from<i;)t.to>=e&&t.enter(i,1,l.IgnoreOverlays|l.ExcludeBuffers)||t.next(!1)||(this.done=!0)}hasNode(e){if(this.moveTo(e.from),!this.done&&this.cursor.from+this.offset==e.from&&this.cursor.tree)for(let t=this.cursor.tree;;){if(t==e.tree)return!0;if(t.children.length&&0==t.positions[0]&&t.children[0]instanceof ho)t=t.children[0];else break}return!1}}let hT=0;class hO{constructor(e,t,i,n){this.name=e,this.set=t,this.base=i,this.modified=n,this.id=hT++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(e,t){if(e instanceof hO&&(t=e),null==t?void 0:t.base)throw Error("Can not derive from a modified tag");let i=new hO("string"==typeof e?e:"?",[],null,[]);if(i.set.push(i),t)for(let e of t.set)i.set.push(e);return i}static defineModifier(e){let t=new hR(e);return e=>e.modified.indexOf(t)>-1?e:hR.get(e.base||e,e.modified.concat(t).sort((e,t)=>e.id-t.id))}}let hD=0;class hR{constructor(e){this.name=e,this.instances=[],this.id=hD++}static get(e,t){if(!t.length)return e;let i=t[0].instances.find(i=>{var n;return i.base==e&&(n=i.modified,t.length==n.length&&t.every((e,t)=>e==n[t]))});if(i)return i;let n=[],r=new hO(e.name,n,e,t);for(let e of t)e.instances.push(r);let s=function(e){let t=[[]];for(let i=0;i<e.length;i++)for(let n=0,r=t.length;n<r;n++)t.push(t[n].concat(e[i]));return t.sort((e,t)=>t.length-e.length)}(t);for(let t of e.set)if(!t.modified.length)for(let e of s)n.push(hR.get(t,e));return r}}let hP=new a7({combine(e,t){let i,n,r;for(;e||t;){if(!e||t&&e.depth>=t.depth?(r=t,t=t.next):(r=e,e=e.next),i&&i.mode==r.mode&&!r.context&&!i.context)continue;let s=new hL(r.tags,r.mode,r.context);i?i.next=s:n=s,i=s}return n}});class hL{constructor(e,t,i,n){this.tags=e,this.mode=t,this.context=i,this.next=n}get opaque(){return 0==this.mode}get inherit(){return 1==this.mode}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}}function hI(e,t){let i=Object.create(null);for(let t of e)if(Array.isArray(t.tag))for(let e of t.tag)i[e.id]=t.class;else i[t.tag.id]=t.class;let{scope:n,all:r=null}=t||{};return{style:e=>{let t=r;for(let n of e)for(let e of n.set){let n=i[e.id];if(n){t=t?t+" "+n:n;break}}return t},scope:n}}hL.empty=new hL([],2,null);class hE{constructor(e,t,i){this.at=e,this.highlighters=t,this.span=i,this.class=""}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,i,n,r){let{type:s,from:o,to:l}=e;if(o>=i||l<=t)return;s.isTop&&(r=this.highlighters.filter(e=>!e.scope||e.scope(s)));let a=n,h=function(e){let t=e.type.prop(hP);for(;t&&t.context&&!e.matchContext(t.context);)t=t.next;return t||null}(e)||hL.empty,c=function(e,t){let i=null;for(let n of e){let e=n.style(t);e&&(i=i?i+" "+e:e)}return i}(r,h.tags);if(c&&(a&&(a+=" "),a+=c,1==h.mode&&(n+=(n?" ":"")+c)),this.startSpan(Math.max(t,o),a),h.opaque)return;let d=e.tree&&e.tree.prop(a7.mounted);if(d&&d.overlay){let s=e.node.enter(d.overlay[0].from+o,1),h=this.highlighters.filter(e=>!e.scope||e.scope(d.tree.type)),c=e.firstChild();for(let u=0,f=o;;u++){let p=u<d.overlay.length?d.overlay[u]:null,m=p?p.from+o:l,g=Math.max(t,f),x=Math.min(i,m);if(g<x&&c)for(;e.from<x&&(this.highlightRange(e,g,x,n,r),this.startSpan(Math.min(x,e.to),a),!(e.to>=m)&&e.nextSibling()););if(!p||m>i)break;(f=p.to+o)>t&&(this.highlightRange(s.cursor(),Math.max(t,p.from+o),Math.min(i,f),"",h),this.startSpan(Math.min(i,f),a))}c&&e.parent()}else if(e.firstChild()){d&&(n="");do{if(e.to<=t)continue;if(e.from>=i)break;this.highlightRange(e,t,i,n,r),this.startSpan(Math.min(i,e.to),a)}while(e.nextSibling());e.parent()}}}let hB=hO.define,hN=hB(),hz=hB(),hW=hB(hz),hF=hB(hz),hV=hB(),hH=hB(hV),h$=hB(hV),hq=hB(),hK=hB(hq),hU=hB(),h_=hB(),hG=hB(),hJ=hB(hG),hX=hB(),hY={comment:hN,lineComment:hB(hN),blockComment:hB(hN),docComment:hB(hN),name:hz,variableName:hB(hz),typeName:hW,tagName:hB(hW),propertyName:hF,attributeName:hB(hF),className:hB(hz),labelName:hB(hz),namespace:hB(hz),macroName:hB(hz),literal:hV,string:hH,docString:hB(hH),character:hB(hH),attributeValue:hB(hH),number:h$,integer:hB(h$),float:hB(h$),bool:hB(hV),regexp:hB(hV),escape:hB(hV),color:hB(hV),url:hB(hV),keyword:hU,self:hB(hU),null:hB(hU),atom:hB(hU),unit:hB(hU),modifier:hB(hU),operatorKeyword:hB(hU),controlKeyword:hB(hU),definitionKeyword:hB(hU),moduleKeyword:hB(hU),operator:h_,derefOperator:hB(h_),arithmeticOperator:hB(h_),logicOperator:hB(h_),bitwiseOperator:hB(h_),compareOperator:hB(h_),updateOperator:hB(h_),definitionOperator:hB(h_),typeOperator:hB(h_),controlOperator:hB(h_),punctuation:hG,separator:hB(hG),bracket:hJ,angleBracket:hB(hJ),squareBracket:hB(hJ),paren:hB(hJ),brace:hB(hJ),content:hq,heading:hK,heading1:hB(hK),heading2:hB(hK),heading3:hB(hK),heading4:hB(hK),heading5:hB(hK),heading6:hB(hK),contentSeparator:hB(hq),list:hB(hq),quote:hB(hq),emphasis:hB(hq),strong:hB(hq),link:hB(hq),monospace:hB(hq),strikethrough:hB(hq),inserted:hB(),deleted:hB(),changed:hB(),invalid:hB(),meta:hX,documentMeta:hB(hX),annotation:hB(hX),processingInstruction:hB(hX),definition:hO.defineModifier("definition"),constant:hO.defineModifier("constant"),function:hO.defineModifier("function"),standard:hO.defineModifier("standard"),local:hO.defineModifier("local"),special:hO.defineModifier("special")};for(let e in hY){let t=hY[e];t instanceof hO&&(t.name=e)}hI([{tag:hY.link,class:"tok-link"},{tag:hY.heading,class:"tok-heading"},{tag:hY.emphasis,class:"tok-emphasis"},{tag:hY.strong,class:"tok-strong"},{tag:hY.keyword,class:"tok-keyword"},{tag:hY.atom,class:"tok-atom"},{tag:hY.bool,class:"tok-bool"},{tag:hY.url,class:"tok-url"},{tag:hY.labelName,class:"tok-labelName"},{tag:hY.inserted,class:"tok-inserted"},{tag:hY.deleted,class:"tok-deleted"},{tag:hY.literal,class:"tok-literal"},{tag:hY.string,class:"tok-string"},{tag:hY.number,class:"tok-number"},{tag:[hY.regexp,hY.escape,hY.special(hY.string)],class:"tok-string2"},{tag:hY.variableName,class:"tok-variableName"},{tag:hY.local(hY.variableName),class:"tok-variableName tok-local"},{tag:hY.definition(hY.variableName),class:"tok-variableName tok-definition"},{tag:hY.special(hY.variableName),class:"tok-variableName2"},{tag:hY.definition(hY.propertyName),class:"tok-propertyName tok-definition"},{tag:hY.typeName,class:"tok-typeName"},{tag:hY.namespace,class:"tok-namespace"},{tag:hY.className,class:"tok-className"},{tag:hY.macroName,class:"tok-macroName"},{tag:hY.propertyName,class:"tok-propertyName"},{tag:hY.operator,class:"tok-operator"},{tag:hY.comment,class:"tok-comment"},{tag:hY.meta,class:"tok-meta"},{tag:hY.invalid,class:"tok-invalid"},{tag:hY.punctuation,class:"tok-punctuation"}]);let hQ=new a7,h0=new a7;class h1{constructor(e,t,i=[],n=""){this.data=e,this.name=n,rt.prototype.hasOwnProperty("tree")||Object.defineProperty(rt.prototype,"tree",{get(){return h5(this)}}),this.parser=t,this.extension=[ci.of(this),rt.languageData.of((e,t,i)=>{let n=h2(e,t,i),r=n.type.prop(hQ);if(!r)return[];let s=e.facet(r),o=n.type.prop(h0);if(o){let r=n.resolve(t-n.from,i);for(let t of o)if(t.test(r,e)){let i=e.facet(t.facet);return"replace"==t.type?i:i.concat(s)}}return s})].concat(i)}isActiveAt(e,t,i=-1){return h2(e,t,i).type.prop(hQ)==this.data}findRegions(e){let t=e.facet(ci);if((null==t?void 0:t.data)==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let i=[],n=(e,t)=>{if(e.prop(hQ)==this.data){i.push({from:t,to:t+e.length});return}let r=e.prop(a7.mounted);if(r){if(r.tree.prop(hQ)==this.data){if(r.overlay)for(let e of r.overlay)i.push({from:e.from+t,to:e.to+t});else i.push({from:t,to:t+e.length});return}if(r.overlay){let e=i.length;if(n(r.tree,r.overlay[0].from+t),i.length>e)return}}for(let i=0;i<e.children.length;i++){let r=e.children[i];r instanceof ho&&n(r,e.positions[i]+t)}};return n(h5(e),0),i}get allowsNesting(){return!0}}function h2(e,t,i){let n=e.facet(ci),r=h5(e).topNode;if(!n||n.allowsNesting)for(let e=r;e;e=e.enter(t,i,l.ExcludeBuffers|l.EnterBracketed))e.type.isTop&&(r=e);return r}function h5(e){let t=e.field(h1.state,!1);return t?t.tree:ho.empty}h1.setState=n5.define();class h6{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let i=this.cursorPos-this.string.length;return e<i||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-i,t-i)}}let h4=null;class h3{constructor(e,t,i=[],n,r,s,o,l){this.parser=e,this.state=t,this.fragments=i,this.tree=n,this.treeLen=r,this.viewport=s,this.skipped=o,this.scheduleOn=l,this.parse=null,this.tempSkipped=[]}static create(e,t,i){return new h3(e,t,[],ho.empty,0,i,[],null)}startParse(){return this.parser.startParse(new h6(this.state.doc),this.fragments)}work(e,t){return(null!=t&&t>=this.state.doc.length&&(t=void 0),this.tree!=ho.empty&&this.isDone(null!=t?t:this.state.doc.length))?(this.takeTree(),!0):this.withContext(()=>{var i;if("number"==typeof e){let t=Date.now()+e;e=()=>Date.now()>t}for(this.parse||(this.parse=this.startParse()),null!=t&&(null==this.parse.stoppedAt||this.parse.stoppedAt>t)&&t<this.state.doc.length&&this.parse.stopAt(t);;){let n=this.parse.advance();if(n){if(this.fragments=this.withoutTempSkipped(hC.addTree(n,this.fragments,null!=this.parse.stoppedAt)),this.treeLen=null!==(i=this.parse.stoppedAt)&&void 0!==i?i:this.state.doc.length,this.tree=n,this.parse=null,!(this.treeLen<(null!=t?t:this.state.doc.length)))return!0;this.parse=this.startParse()}if(e())return!1}})}takeTree(){let e,t;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((null==this.parse.stoppedAt||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(hC.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=h4;h4=this;try{return e()}finally{h4=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=h8(e,t.from,t.to);return e}changes(e,t){let{fragments:i,tree:n,treeLen:r,viewport:s,skipped:o}=this;if(this.takeTree(),!e.empty){let t=[];if(e.iterChangedRanges((e,i,n,r)=>t.push({fromA:e,toA:i,fromB:n,toB:r})),i=hC.applyChanges(i,t),n=ho.empty,r=0,s={from:e.mapPos(s.from,-1),to:e.mapPos(s.to,1)},this.skipped.length)for(let t of(o=[],this.skipped)){let i=e.mapPos(t.from,1),n=e.mapPos(t.to,-1);i<n&&o.push({from:i,to:n})}}return new h3(this.parser,t,i,n,r,s,o,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let t=this.skipped.length;for(let t=0;t<this.skipped.length;t++){let{from:i,to:n}=this.skipped[t];i<e.to&&n>e.from&&(this.fragments=h8(this.fragments,i,n),this.skipped.splice(t--,1))}return!(this.skipped.length>=t)&&(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends hj{createParse(t,i,n){let r=n[0].from,s=n[n.length-1].to;return{parsedPos:r,advance(){let t=h4;if(t){for(let e of n)t.tempSkipped.push(e);e&&(t.scheduleOn=t.scheduleOn?Promise.all([t.scheduleOn,e]):e)}return this.parsedPos=s,new ho(hi.none,[],[],s-r)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&0==t[0].from&&t[0].to>=e}static get(){return h4}}function h8(e,t,i){return hC.applyChanges(e,[{fromA:t,toA:i,fromB:t,toB:i}])}class h9{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let t=this.context.changes(e.changes,e.state),i=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,i)||t.takeTree(),new h9(t)}static init(e){let t=Math.min(3e3,e.doc.length),i=h3.create(e.facet(ci).parser,e,{from:0,to:t});return i.work(20,t)||i.takeTree(),new h9(i)}}h1.state=nB.define({create:h9.init,update(e,t){for(let e of t.effects)if(e.is(h1.setState))return e.value;return t.startState.facet(ci)!=t.state.facet(ci)?h9.init(t.state):e.apply(t)}});let h7=e=>{let t=setTimeout(()=>e(),500);return()=>clearTimeout(t)};"undefined"!=typeof requestIdleCallback&&(h7=e=>{let t=-1,i=setTimeout(()=>{t=requestIdleCallback(e,{timeout:400})},100);return()=>t<0?clearTimeout(i):cancelIdleCallback(t)});let ce="undefined"!=typeof navigator&&(null===(a=navigator.scheduling)||void 0===a?void 0:a.isInputPending)?()=>navigator.scheduling.isInputPending():null,ct=sG.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(h1.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(h1.state);t.tree==t.context.tree&&t.context.isDone(e.doc.length)||(this.working=h7(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnd<t&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=t+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:i,viewport:{to:n}}=this.view,r=i.field(h1.state);if(r.tree==r.context.tree&&r.context.isDone(n+1e5))return;let s=Date.now()+Math.min(this.chunkBudget,100,e&&!ce?Math.max(25,e.timeRemaining()-5):1e9),o=r.context.treeLen<n&&i.doc.length>n+1e3,l=r.context.work(()=>ce&&ce()||Date.now()>s,n+(o?0:1e5));this.chunkBudget-=Date.now()-t,(l||this.chunkBudget<=0)&&(r.context.takeTree(),this.view.dispatch({effects:h1.setState.of(new h9(r.context))})),this.chunkBudget>0&&!(l&&!o)&&this.scheduleWork(),this.checkAsyncSchedule(r.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(e=>sq(this.view.state,e)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),ci=nD.define({combine:e=>e.length?e[0]:null,enables:e=>[h1.state,ct,l$.contentAttributes.compute([e],t=>{let i=t.facet(e);return i&&i.name?{"data-language":i.name}:{}})]}),cn=nD.define(),cr=nD.define({combine:e=>{if(!e.length)return" ";let t=e[0];if(!t||/\S/.test(t)||Array.from(t).some(e=>e!=t[0]))throw Error("Invalid indent unit: "+JSON.stringify(e[0]));return t}});function cs(e){let t=e.facet(cr);return 9==t.charCodeAt(0)?e.tabSize*t.length:t.length}function co(e,t){let i="",n=e.tabSize,r=e.facet(cr)[0];if(" "==r){for(;t>=n;)i+=" ",t-=n;r=" "}for(let e=0;e<t;e++)i+=r;return i}function cl(e,t){for(let i of(e instanceof rt&&(e=new ca(e)),e.state.facet(cn))){let n=i(e,t);if(void 0!==n)return n}let i=h5(e.state);return i.length>=t?function(e,t,i){let n=t.resolveStack(i),r=t.resolveInner(i,-1).resolve(i,0).enterUnfinishedNodesBefore(i);if(r!=n.node){let e=[];for(let t=r;t&&!(t.from<n.node.from||t.to>n.node.to||t.from==n.node.from&&t.type==n.node.type);t=t.parent)e.push(t);for(let t=e.length-1;t>=0;t--)n={node:e[t],next:n}}return cc(n,e,i)}(e,i,t):null}class ca{constructor(e,t={}){this.state=e,this.options=t,this.unit=cs(e)}lineAt(e,t=1){let i=this.state.doc.lineAt(e),{simulateBreak:n,simulateDoubleBreak:r}=this.options;return null!=n&&n>=i.from&&n<=i.to?r&&n==e?{text:"",from:e}:(t<0?n<e:n<=e)?{text:i.text.slice(n-i.from),from:n}:{text:i.text.slice(0,n-i.from),from:i.from}:i}textAfterPos(e,t=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return"";let{text:i,from:n}=this.lineAt(e,t);return i.slice(e-n,Math.min(i.length,e+100-n))}column(e,t=1){let{text:i,from:n}=this.lineAt(e,t),r=this.countColumn(i,e-n),s=this.options.overrideIndentation?this.options.overrideIndentation(n):-1;return s>-1&&(r+=s-this.countColumn(i,i.search(/\S|$/))),r}countColumn(e,t=e.length){return rb(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:i,from:n}=this.lineAt(e,t),r=this.options.overrideIndentation;if(r){let e=r(n);if(e>-1)return e}return this.countColumn(i,i.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}let ch=new a7;function cc(e,t,i){for(let n=e;n;n=n.next){let e=function(e){let t=e.type.prop(ch);if(t)return t;let i=e.firstChild,n;if(i&&(n=i.type.prop(a7.closedBy))){let t=e.lastChild,i=t&&n.indexOf(t.name)>-1;return e=>(function(e,t,i,n,r){let s=e.textAfter,o=s.match(/^\s*/)[0].length,l=n&&s.slice(o,o+n.length)==n||r==e.pos+o,a=t?function(e){let t=e.node,i=t.childAfter(t.from),n=t.lastChild;if(!i)return null;let r=e.options.simulateBreak,s=e.state.doc.lineAt(i.from),o=null==r||r<=s.from?s.to:Math.min(s.to,r);for(let e=i.to;;){let r=t.childAfter(e);if(!r||r==n)return null;if(!r.type.isSkipped){if(r.from>=o)return null;let e=/^ */.exec(s.text.slice(i.to-s.from))[0].length;return{from:i.from,to:i.to+e}}e=r.to}}(e):null;return a?l?e.column(a.from):e.column(a.to):e.baseIndent+(l?0:1*e.unit)})(e,!0,1,void 0,i&&!(e.pos==e.options.simulateBreak&&e.options.simulateDoubleBreak)?t.from:void 0)}return null==e.parent?cd:null}(n.node);if(e)return e(cu.create(t,i,n))}return 0}function cd(){return 0}class cu extends ca{constructor(e,t,i){super(e.state,e.options),this.base=e,this.pos=t,this.context=i}get node(){return this.context.node}static create(e,t,i){return new cu(e,t,i)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let i=e.resolve(t.from);for(;i.parent&&i.parent.from==i.from;)i=i.parent;if(function(e,t){for(let i=t;i;i=i.parent)if(e==i)return!0;return!1}(i,e))break;t=this.state.doc.lineAt(i.from)}return this.lineIndent(t.from)}continue(){return cc(this.context.next,this.base,this.pos)}}let cf=nD.define(),cp=new a7;function cm(e,t,i){for(let n of e.facet(cf)){let r=n(e,t,i);if(r)return r}return function(e,t,i){let n=h5(e);if(n.length<i)return null;let r=n.resolveStack(i,1),s=null;for(let o=r;o;o=o.next){let r=o.node;if(r.to<=i||r.from>i)continue;if(s&&r.from<t)break;let l=r.type.prop(cp);if(l&&(r.to<n.length-50||n.length==e.doc.length||!function(e){let t=e.lastChild;return t&&t.to==e.to&&t.type.isError}(r))){let n=l(r,e);n&&n.from<=i&&n.from>=t&&n.to>i&&(s=n)}}return s}(e,t,i)}function cg(e,t){let i=t.mapPos(e.from,1),n=t.mapPos(e.to,-1);return i>=n?void 0:{from:i,to:n}}let cx=n5.define({map:cg}),cv=n5.define({map:cg}),cy=nB.define({create:()=>rQ.none,update(e,t){for(let i of(t.isUserEvent("delete")&&t.changes.iterChangedRanges((t,i)=>e=cb(e,t,i)),e=e.map(t.changes),t.effects))if(i.is(cx)&&!function(e,t,i){let n=!1;return e.between(t,t,(e,r)=>{e==t&&r==i&&(n=!0)}),n}(e,i.value.from,i.value.to)){let{preparePlaceholder:n}=t.state.facet(cS),r=n?rQ.replace({widget:new cM(n(t.state,i.value))}):cj;e=e.update({add:[r.range(i.value.from,i.value.to)]})}else i.is(cv)&&(e=e.update({filter:(e,t)=>i.value.from!=e||i.value.to!=t,filterFrom:i.value.from,filterTo:i.value.to}));return t.selection&&(e=cb(e,t.selection.main.head)),e},provide:e=>l$.decorations.from(e),toJSON(e,t){let i=[];return e.between(0,t.doc.length,(e,t)=>{i.push(e,t)}),i},fromJSON(e){if(!Array.isArray(e)||e.length%2)throw RangeError("Invalid JSON for fold state");let t=[];for(let i=0;i<e.length;){let n=e[i++],r=e[i++];if("number"!=typeof n||"number"!=typeof r)throw RangeError("Invalid JSON for fold state");t.push(cj.range(n,r))}return rQ.set(t,!0)}});function cb(e,t,i=t){let n=!1;return e.between(t,i,(e,r)=>{e<i&&r>t&&(n=!0)}),n?e.update({filterFrom:t,filterTo:i,filter:(e,n)=>e>=i||n<=t}):e}function cw(e,t,i){var n;let r=null;return null===(n=e.field(cy,!1))||void 0===n||n.between(t,i,(e,t)=>{(!r||r.from>e)&&(r={from:e,to:t})}),r}let ck={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},cS=nD.define({combine:e=>ri(e,ck)});function cC(e,t){let{state:i}=e,n=i.facet(cS),r=t=>{let i=e.lineBlockAt(e.posAtDOM(t.target)),n=cw(e.state,i.from,i.to);n&&e.dispatch({effects:cv.of(n)}),t.preventDefault()};if(n.placeholderDOM)return n.placeholderDOM(e,r,t);let s=document.createElement("span");return s.textContent=n.placeholderText,s.setAttribute("aria-label",i.phrase("folded code")),s.title=i.phrase("unfold"),s.className="cm-foldPlaceholder",s.onclick=r,s}let cj=rQ.replace({widget:new class extends rX{toDOM(e){return cC(e,null)}}});class cM extends rX{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return cC(e,this.value)}}let cZ={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class cA extends aF{constructor(e,t){super(),this.config=e,this.open=t}eq(e){return this.config==e.config&&this.open==e.open}toDOM(e){if(this.config.markerDOM)return this.config.markerDOM(this.open);let t=document.createElement("span");return t.textContent=this.open?this.config.openText:this.config.closedText,t.title=e.state.phrase(this.open?"Fold line":"Unfold line"),t}}let cT=l$.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}});class cO{constructor(e,t){let i;function n(e){let t=rj.newName();return(i||(i=Object.create(null)))["."+t]=e,t}this.specs=e;let r="string"==typeof t.all?t.all:t.all?n(t.all):void 0,s=t.scope;this.scope=s instanceof h1?e=>e.prop(hQ)==s.data:s?e=>e==s:void 0,this.style=hI(e.map(e=>({tag:e.tag,class:e.class||n(Object.assign({},e,{tag:null}))})),{all:r}).style,this.module=i?new rj(i):null,this.themeType=t.themeType}static define(e,t){return new cO(e,t||{})}}let cD=nD.define(),cR=nD.define({combine:e=>e.length?[e[0]]:null});function cP(e){let t=e.facet(cD);return t.length?t:e.facet(cR)}function cL(e,t){let i=[cE],n;return e instanceof cO&&(e.module&&i.push(l$.styleModule.of(e.module)),n=e.themeType),(null==t?void 0:t.fallback)?i.push(cR.of(e)):n?i.push(cD.computeN([l$.darkTheme],t=>t.facet(l$.darkTheme)==("dark"==n)?[e]:[])):i.push(cD.of(e)),i}class cI{constructor(e){this.markCache=Object.create(null),this.tree=h5(e.state),this.decorations=this.buildDeco(e,cP(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=h5(e.state),i=cP(e.state),n=i!=cP(e.startState),{viewport:r}=e.view,s=e.changes.mapPos(this.decoratedTo,1);t.length<r.to&&!n&&t.type==this.tree.type&&s>=r.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=s):(t!=this.tree||e.viewportChanged||n)&&(this.tree=t,this.decorations=this.buildDeco(e.view,i),this.decoratedTo=r.to)}buildDeco(e,t){if(!t||!this.tree.length)return rQ.none;let i=new rh;for(let{from:n,to:r}of e.visibleRanges)(function(e,t,i,n=0,r=e.length){let s=new hE(n,Array.isArray(t)?t:[t],i);s.highlightRange(e.cursor(),n,r,"",s.highlighters),s.flush(r)})(this.tree,t,(e,t,n)=>{i.add(e,t,this.markCache[n]||(this.markCache[n]=rQ.mark({class:n})))},n,r);return i.finish()}}let cE=nW.high(sG.fromClass(cI,{decorations:e=>e.decorations})),cB=cO.define([{tag:hY.meta,color:"#404740"},{tag:hY.link,textDecoration:"underline"},{tag:hY.heading,textDecoration:"underline",fontWeight:"bold"},{tag:hY.emphasis,fontStyle:"italic"},{tag:hY.strong,fontWeight:"bold"},{tag:hY.strikethrough,textDecoration:"line-through"},{tag:hY.keyword,color:"#708"},{tag:[hY.atom,hY.bool,hY.url,hY.contentSeparator,hY.labelName],color:"#219"},{tag:[hY.literal,hY.inserted],color:"#164"},{tag:[hY.string,hY.deleted],color:"#a11"},{tag:[hY.regexp,hY.escape,hY.special(hY.string)],color:"#e40"},{tag:hY.definition(hY.variableName),color:"#00f"},{tag:hY.local(hY.variableName),color:"#30a"},{tag:[hY.typeName,hY.namespace],color:"#085"},{tag:hY.className,color:"#167"},{tag:[hY.special(hY.variableName),hY.macroName],color:"#256"},{tag:hY.definition(hY.propertyName),color:"#00c"},{tag:hY.comment,color:"#940"},{tag:hY.invalid,color:"#f00"}]),cN=l$.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),cz="()[]{}",cW=nD.define({combine:e=>ri(e,{afterCursor:!0,brackets:cz,maxScanDistance:1e4,renderMatch:cH})}),cF=rQ.mark({class:"cm-matchingBracket"}),cV=rQ.mark({class:"cm-nonmatchingBracket"});function cH(e){let t=[],i=e.matched?cF:cV;return t.push(i.range(e.start.from,e.start.to)),e.end&&t.push(i.range(e.end.from,e.end.to)),t}let c$=[nB.define({create:()=>rQ.none,update(e,t){if(!t.docChanged&&!t.selection)return e;let i=[],n=t.state.facet(cW);for(let e of t.state.selection.ranges){if(!e.empty)continue;let r=c_(t.state,e.head,-1,n)||e.head>0&&c_(t.state,e.head-1,1,n)||n.afterCursor&&(c_(t.state,e.head,1,n)||e.head<t.state.doc.length&&c_(t.state,e.head+1,-1,n));r&&(i=i.concat(n.renderMatch(r,t.state)))}return rQ.set(i,!0)},provide:e=>l$.decorations.from(e)}),cN],cq=new a7;function cK(e,t,i){let n=e.prop(t<0?a7.openedBy:a7.closedBy);if(n)return n;if(1==e.name.length){let n=i.indexOf(e.name);if(n>-1&&n%2==(t<0?1:0))return[i[n+t]]}return null}function cU(e){let t=e.type.prop(cq);return t?t(e.node):e}function c_(e,t,i,n={}){let r=n.maxScanDistance||1e4,s=n.brackets||cz,o=h5(e),l=o.resolveInner(t,i);for(let e=l;e;e=e.parent){let n=cK(e.type,i,s);if(n&&e.from<e.to){let r=cU(e);if(r&&(i>0?t>=r.from&&t<r.to:t>r.from&&t<=r.to))return function(e,t,i,n,r,s,o){let l=n.parent,a={from:r.from,to:r.to},h=0,c=null==l?void 0:l.cursor();if(c&&(i<0?c.childBefore(n.from):c.childAfter(n.to)))do if(i<0?c.to<=n.from:c.from>=n.to){if(0==h&&s.indexOf(c.type.name)>-1&&c.from<c.to){let e=cU(c);return{start:a,end:e?{from:e.from,to:e.to}:void 0,matched:!0}}if(cK(c.type,i,o))h++;else if(cK(c.type,-i,o)){if(0==h){let e=cU(c);return{start:a,end:e&&e.from<e.to?{from:e.from,to:e.to}:void 0,matched:!1}}h--}}while(i<0?c.prevSibling():c.nextSibling());return{start:a,matched:!1}}(0,0,i,e,r,n,s)}}return function(e,t,i,n,r,s,o){let l=i<0?e.sliceDoc(t-1,t):e.sliceDoc(t,t+1),a=o.indexOf(l);if(a<0||a%2==0!=i>0)return null;let h={from:i<0?t-1:t,to:i>0?t+1:t},c=e.doc.iterRange(t,i>0?e.doc.length:0),d=0;for(let e=0;!c.next().done&&e<=s;){let s=c.value;i<0&&(e+=s.length);let l=t+e*i;for(let e=i>0?0:s.length-1,t=i>0?s.length:-1;e!=t;e+=i){let t=o.indexOf(s[e]);if(!(t<0)&&n.resolveInner(l+e,1).type==r){if(t%2==0==i>0)d++;else{if(1==d)return{start:h,end:{from:l+e,to:l+e+1},matched:t>>1==a>>1};d--}}}i>0&&(e+=s.length)}return c.done?{start:h,matched:!1}:null}(e,t,i,o,l.type,r,s)}let cG=Object.create(null),cJ=[hi.none],cX=[],cY=Object.create(null),cQ=Object.create(null);for(let[e,t]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])cQ[e]=function(e,t){let i=[];for(let n of t.split(" ")){let t=[];for(let i of n.split(".")){let n=e[i]||hY[i];n?"function"==typeof n?t.length?t=t.map(n):c0(i,`Modifier ${i} used at start of tag`):t.length?c0(i,`Tag ${i} used as modifier`):t=Array.isArray(n)?n:[n]:c0(i,`Unknown highlighting tag ${i}`)}for(let e of t)i.push(e)}if(!i.length)return 0;let n=t.replace(/ /g,"_"),r=n+" "+i.map(e=>e.id),s=cY[r];if(s)return s.id;let o=cY[r]=hi.define({id:cJ.length,name:n,props:[function(e){let t=Object.create(null);for(let i in e){let n=e[i];for(let e of(Array.isArray(n)||(n=[n]),i.split(" ")))if(e){let i=[],r=2,s=e;for(let t=0;;){if("..."==s&&t>0&&t+3==e.length){r=1;break}let n=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(s);if(!n)throw RangeError("Invalid path: "+e);if(i.push("*"==n[0]?"":'"'==n[0][0]?JSON.parse(n[0]):n[0]),(t+=n[0].length)==e.length)break;let o=e[t++];if(t==e.length&&"!"==o){r=0;break}if("/"!=o)throw RangeError("Invalid path: "+e);s=e.slice(t)}let o=i.length-1,l=i[o];if(!l)throw RangeError("Invalid path: "+e);let a=new hL(n,r,o>0?i.slice(0,o):null);t[l]=a.sort(t[l])}}return hP.add(t)}({[n]:i})]});return cJ.push(o),o.id}(cG,t);function c0(e,t){cX.indexOf(e)>-1||(cX.push(e),console.warn(t))}function c1(e){return e.length<=4096&&/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/.test(e)}let c2={rtl:rQ.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"rtl"},bidiIsolate:sg.RTL}),ltr:rQ.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"ltr"},bidiIsolate:sg.LTR}),auto:rQ.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"auto"},bidiIsolate:null})};function c5(e,t){return({state:i,dispatch:n})=>{if(i.readOnly)return!1;let r=e(t,i);return!!r&&(n(i.update(r)),!0)}}let c6=c5(function(e,t,i=t.selection.ranges){let n=[],r=-1;r:for(let{from:e,to:s}of i){let i=n.length,o=1e9,l;for(let i=e;i<=s;){let a=t.doc.lineAt(i);if(void 0==l&&!(l=c8(t,a.from).line))continue r;if(a.from>r&&(e==s||s>a.from)){r=a.from;let e=/^\s*/.exec(a.text)[0].length,t=e==a.length,i=a.text.slice(e,e+l.length)==l?e:-1;e<a.text.length&&e<o&&(o=e),n.push({line:a,comment:i,token:l,indent:e,empty:t,single:!1})}i=a.to+1}if(o<1e9)for(let e=i;e<n.length;e++)n[e].indent<n[e].line.text.length&&(n[e].indent=o);n.length==i+1&&(n[i].single=!0)}if(2!=e&&n.some(e=>e.comment<0&&(!e.empty||e.single))){let e=[];for(let{line:t,token:i,indent:r,empty:s,single:o}of n)(o||!s)&&e.push({from:t.from+r,insert:i+" "});let i=t.changes(e);return{changes:i,selection:t.selection.map(i,1)}}if(1!=e&&n.some(e=>e.comment>=0)){let e=[];for(let{line:t,comment:i,token:r}of n)if(i>=0){let n=t.from+i,s=n+r.length;" "==t.text[s-t.from]&&s++,e.push({from:n,to:s})}return{changes:e}}return null},0),c4=c5(c9,0),c3=c5((e,t)=>c9(e,t,function(e){let t=[];for(let i of e.selection.ranges){let n=e.doc.lineAt(i.from),r=i.to<=n.to?n:e.doc.lineAt(i.to);r.from>n.from&&r.from==i.to&&(r=i.to==n.to+1?n:e.doc.lineAt(i.to-1));let s=t.length-1;s>=0&&t[s].to>n.from?t[s].to=r.to:t.push({from:n.from+/^\s*/.exec(n.text)[0].length,to:r.to})}return t}(t)),0);function c8(e,t){let i=e.languageDataAt("commentTokens",t,1);return i.length?i[0]:{}}function c9(e,t,i=t.selection.ranges){let n=i.map(e=>c8(t,e.from).block);if(!n.every(e=>e))return null;let r=i.map((e,i)=>(function(e,{open:t,close:i},n,r){let s,o,l=e.sliceDoc(n-50,n),a=e.sliceDoc(r,r+50),h=/\s*$/.exec(l)[0].length,c=/^\s*/.exec(a)[0].length,d=l.length-h;if(l.slice(d-t.length,d)==t&&a.slice(c,c+i.length)==i)return{open:{pos:n-h,margin:h&&1},close:{pos:r+c,margin:c&&1}};r-n<=100?s=o=e.sliceDoc(n,r):(s=e.sliceDoc(n,n+50),o=e.sliceDoc(r-50,r));let u=/^\s*/.exec(s)[0].length,f=/\s*$/.exec(o)[0].length,p=o.length-f-i.length;return s.slice(u,u+t.length)==t&&o.slice(p,p+i.length)==i?{open:{pos:n+u+t.length,margin:/\s/.test(s.charAt(u+t.length))?1:0},close:{pos:r-f-i.length,margin:/\s/.test(o.charAt(p-1))?1:0}}:null})(t,n[i],e.from,e.to));if(2!=e&&!r.every(e=>e))return{changes:t.changes(i.map((e,t)=>r[t]?[]:[{from:e.from,insert:n[t].open+" "},{from:e.to,insert:" "+n[t].close}]))};if(1!=e&&r.some(e=>e)){let e=[];for(let t=0,i;t<r.length;t++)if(i=r[t]){let r=n[t],{open:s,close:o}=i;e.push({from:s.pos-r.open.length,to:s.pos+s.margin},{from:o.pos-o.margin,to:o.pos+r.close.length})}return{changes:e}}return null}let c7=n0.define(),de=n0.define(),dt=nD.define(),di=nD.define({combine:e=>ri(e,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(i,n)=>e(i,n)||t(i,n)})}),dn=nB.define({create:()=>dx.empty,update(e,t){let i=t.state.facet(di),n=t.annotation(c7);if(n){let r=dc.fromTransaction(t,n.selection),s=n.side,o=0==s?e.undone:e.done;return o=r?dd(o,o.length,i.minDepth,r):dp(o,t.startState.selection),new dx(0==s?n.rest:o,0==s?o:n.rest)}let r=t.annotation(de);if(("full"==r||"before"==r)&&(e=e.isolate()),!1===t.annotation(n6.addToHistory))return t.changes.empty?e:e.addMapping(t.changes.desc);let s=dc.fromTransaction(t),o=t.annotation(n6.time),l=t.annotation(n6.userEvent);return s?e=e.addChanges(s,o,l,i,t):t.selection&&(e=e.addSelection(t.startState.selection,o,l,i.newGroupDelay)),("full"==r||"after"==r)&&(e=e.isolate()),e},toJSON:e=>({done:e.done.map(e=>e.toJSON()),undone:e.undone.map(e=>e.toJSON())}),fromJSON:e=>new dx(e.done.map(dc.fromJSON),e.undone.map(dc.fromJSON))});function dr(e,t){return function({state:i,dispatch:n}){if(!t&&i.readOnly)return!1;let r=i.field(dn,!1);if(!r)return!1;let s=r.pop(e,i,t);return!!s&&(n(s),!0)}}let ds=dr(0,!1),dl=dr(1,!1),da=dr(0,!0),dh=dr(1,!0);class dc{constructor(e,t,i,n,r){this.changes=e,this.effects=t,this.mapped=i,this.startSelection=n,this.selectionsAfter=r}setSelAfter(e){return new dc(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,i;return{changes:null===(e=this.changes)||void 0===e?void 0:e.toJSON(),mapped:null===(t=this.mapped)||void 0===t?void 0:t.toJSON(),startSelection:null===(i=this.startSelection)||void 0===i?void 0:i.toJSON(),selectionsAfter:this.selectionsAfter.map(e=>e.toJSON())}}static fromJSON(e){return new dc(e.changes&&nb.fromJSON(e.changes),[],e.mapped&&ny.fromJSON(e.mapped),e.startSelection&&nA.fromJSON(e.startSelection),e.selectionsAfter.map(nA.fromJSON))}static fromTransaction(e,t){let i=df;for(let t of e.startState.facet(dt)){let n=t(e);n.length&&(i=i.concat(n))}return!i.length&&e.changes.empty?null:new dc(e.changes.invert(e.startState.doc),i,void 0,t||e.startState.selection,df)}static selection(e){return new dc(void 0,df,void 0,void 0,e)}}function dd(e,t,i,n){let r=e.slice(t+1>i+20?t-i-1:0,t);return r.push(n),r}function du(e,t){return e.length?t.length?e.concat(t):e:t}let df=[];function dp(e,t){if(!e.length)return[dc.selection([t])];{let i=e[e.length-1],n=i.selectionsAfter.slice(Math.max(0,i.selectionsAfter.length-200));return n.length&&n[n.length-1].eq(t)?e:(n.push(t),dd(e,e.length-1,1e9,i.setSelAfter(n)))}}function dm(e,t){if(!e.length)return e;let i=e.length,n=df;for(;i;){let r=function(e,t,i){let n=du(e.selectionsAfter.length?e.selectionsAfter.map(e=>e.map(t)):df,i);if(!e.changes)return dc.selection(n);let r=e.changes.map(t),s=t.mapDesc(e.changes,!0),o=e.mapped?e.mapped.composeDesc(s):s;return new dc(r,n5.mapEffects(e.effects,t),o,e.startSelection.map(s),n)}(e[i-1],t,n);if(r.changes&&!r.changes.empty||r.effects.length){let t=e.slice(0,i);return t[i-1]=r,t}t=r.mapped,i--,n=r.selectionsAfter}return n.length?[dc.selection(n)]:df}let dg=/^(input\.type|delete)($|\.)/;class dx{constructor(e,t,i=0,n){this.done=e,this.undone=t,this.prevTime=i,this.prevUserEvent=n}isolate(){return this.prevTime?new dx(this.done,this.undone):this}addChanges(e,t,i,n,r){var s,o;let l,a,h=this.done,c=h[h.length-1];return new dx(h=c&&c.changes&&!c.changes.empty&&e.changes&&(!i||dg.test(i))&&(!c.selectionsAfter.length&&t-this.prevTime<n.newGroupDelay&&n.joinToEvent(r,(s=c.changes,o=e.changes,l=[],a=!1,s.iterChangedRanges((e,t)=>l.push(e,t)),o.iterChangedRanges((e,t,i,n)=>{for(let e=0;e<l.length;){let t=l[e++],r=l[e++];n>=t&&i<=r&&(a=!0)}}),a))||"input.type.compose"==i)?dd(h,h.length-1,n.minDepth,new dc(e.changes.compose(c.changes),du(n5.mapEffects(e.effects,c.changes),c.effects),c.mapped,c.startSelection,df)):dd(h,h.length,n.minDepth,e),df,t,i)}addSelection(e,t,i,n){var r;let s=this.done.length?this.done[this.done.length-1].selectionsAfter:df;return s.length>0&&t-this.prevTime<n&&i==this.prevUserEvent&&i&&/^select($|\.)/.test(i)&&(r=s[s.length-1]).ranges.length==e.ranges.length&&0===r.ranges.filter((t,i)=>t.empty!=e.ranges[i].empty).length?this:new dx(dp(this.done,e),this.undone,t,i)}addMapping(e){return new dx(dm(this.done,e),dm(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,t,i){let n=0==e?this.done:this.undone;if(0==n.length)return null;let r=n[n.length-1],s=r.selectionsAfter[0]||(r.startSelection?r.startSelection.map(r.changes.invertedDesc,1):t.selection);if(i&&r.selectionsAfter.length){let i,o;return t.update({selection:r.selectionsAfter[r.selectionsAfter.length-1],annotations:c7.of({side:e,rest:(i=n[n.length-1],(o=n.slice())[n.length-1]=i.setSelAfter(i.selectionsAfter.slice(0,i.selectionsAfter.length-1)),o),selection:s}),userEvent:0==e?"select.undo":"select.redo",scrollIntoView:!0})}if(!r.changes)return null;{let i=1==n.length?df:n.slice(0,n.length-1);return r.mapped&&(i=dm(i,r.mapped)),t.update({changes:r.changes,selection:r.startSelection,effects:r.effects,annotations:c7.of({side:e,rest:i,selection:s}),filter:!1,userEvent:0==e?"undo":"redo",scrollIntoView:!0})}}}dx.empty=new dx(df,df);let dv=[{key:"Mod-z",run:ds,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:dl,preventDefault:!0},{linux:"Ctrl-Shift-z",run:dl,preventDefault:!0},{key:"Mod-u",run:da,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:dh,preventDefault:!0}];function dy(e,t){return nA.create(e.ranges.map(t),e.mainIndex)}function db(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:"select"})}function dw({state:e,dispatch:t},i){let n=dy(e.selection,i);return!n.eq(e.selection,!0)&&(t(db(e,n)),!0)}function dk(e,t){return nA.cursor(t?e.to:e.from)}function dS(e,t){return dw(e,i=>i.empty?e.moveByChar(i,t):dk(i,t))}function dC(e){return e.textDirectionAt(e.state.selection.main.head)==sg.LTR}let dj=e=>dS(e,!dC(e)),dM=e=>dS(e,dC(e));function dZ(e,t){return dw(e,i=>i.empty?e.moveByGroup(i,t):dk(i,t))}function dA(e,t,i){let n,r,s=h5(e).resolveInner(t.head),o=i?a7.closedBy:a7.openedBy;for(let n=t.head;;){let t=i?s.childAfter(n):s.childBefore(n);if(!t)break;(function(e,t,i){if(t.type.prop(i))return!0;let n=t.to-t.from;return n&&(n>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild})(e,t,o)?s=t:n=i?t.to:t.from}return r=s.type.prop(o)&&(n=i?c_(e,s.from,1):c_(e,s.to,-1))&&n.matched?i?n.end.to:n.end.from:i?s.to:s.from,nA.cursor(r,i?-1:1)}function dT(e,t){return dw(e,i=>{if(!i.empty)return dk(i,t);let n=e.moveVertically(i,t);return n.head!=i.head?n:e.moveToLineBoundary(i,t)})}"undefined"!=typeof Intl&&Intl.Segmenter;let dO=e=>dT(e,!1),dD=e=>dT(e,!0);function dR(e){let t=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,i=0,n=0,r;if(t){for(let t of e.state.facet(l$.scrollMargins)){let r=t(e);(null==r?void 0:r.top)&&(i=Math.max(null==r?void 0:r.top,i)),(null==r?void 0:r.bottom)&&(n=Math.max(null==r?void 0:r.bottom,n))}r=e.scrollDOM.clientHeight-i-n}else r=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:i,marginBottom:n,selfScroll:t,height:Math.max(e.defaultLineHeight,r-5)}}function dP(e,t){let i,n=dR(e),{state:r}=e,s=dy(r.selection,i=>i.empty?e.moveVertically(i,t,n.height):dk(i,t));if(s.eq(r.selection))return!1;if(n.selfScroll){let t=e.coordsAtPos(r.selection.main.head),o=e.scrollDOM.getBoundingClientRect(),l=o.top+n.marginTop,a=o.bottom-n.marginBottom;t&&t.top>l&&t.bottom<a&&(i=l$.scrollIntoView(s.main.head,{y:"start",yMargin:t.top-l}))}return e.dispatch(db(r,s),{effects:i}),!0}let dL=e=>dP(e,!1),dI=e=>dP(e,!0);function dE(e,t,i){let n=e.lineBlockAt(t.head),r=e.moveToLineBoundary(t,i);if(r.head==t.head&&r.head!=(i?n.to:n.from)&&(r=e.moveToLineBoundary(t,i,!1)),!i&&r.head==n.from&&n.length){let i=/^\s*/.exec(e.state.sliceDoc(n.from,Math.min(n.from+100,n.to)))[0].length;i&&t.head!=n.from+i&&(r=nA.cursor(n.from+i))}return r}function dB(e,t){let i=dy(e.state.selection,e=>{let i=t(e);return nA.range(e.anchor,i.head,i.goalColumn,i.bidiLevel||void 0)});return!i.eq(e.state.selection)&&(e.dispatch(db(e.state,i)),!0)}function dN(e,t){return dB(e,i=>e.moveByChar(i,t))}let dz=e=>dN(e,!dC(e)),dW=e=>dN(e,dC(e));function dF(e,t){return dB(e,i=>e.moveByGroup(i,t))}function dV(e,t){return dB(e,i=>e.moveVertically(i,t))}let dH=e=>dV(e,!1),d$=e=>dV(e,!0);function dq(e,t){return dB(e,i=>e.moveVertically(i,t,dR(e).height))}let dK=e=>dq(e,!1),dU=e=>dq(e,!0),d_=({state:e,dispatch:t})=>(t(db(e,{anchor:0})),!0),dG=({state:e,dispatch:t})=>(t(db(e,{anchor:e.doc.length})),!0),dJ=({state:e,dispatch:t})=>(t(db(e,{anchor:e.selection.main.anchor,head:0})),!0),dX=({state:e,dispatch:t})=>(t(db(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0);function dY(e,t){let{state:i}=e,n=i.selection,r=i.selection.ranges.slice();for(let n of i.selection.ranges){let s=i.doc.lineAt(n.head);if(t?s.to<e.state.doc.length:s.from>0)for(let i=n;;){let n=e.moveVertically(i,t);if(n.head<s.from||n.head>s.to){r.some(e=>e.head==n.head)||r.push(n);break}if(n.head==i.head)break;i=n}}return r.length!=n.ranges.length&&(e.dispatch(db(i,nA.create(r,r.length-1))),!0)}function dQ(e,t){if(e.state.readOnly)return!1;let i="delete.selection",{state:n}=e,r=n.changeByRange(n=>{let{from:r,to:s}=n;if(r==s){let o=t(n);o<r?(i="delete.backward",o=d0(e,o,!1)):o>r&&(i="delete.forward",o=d0(e,o,!0)),r=Math.min(r,o),s=Math.max(s,o)}else r=d0(e,r,!1),s=d0(e,s,!0);return r==s?{range:n}:{changes:{from:r,to:s},range:nA.cursor(r,r<n.head?-1:1)}});return!r.changes.empty&&(e.dispatch(n.update(r,{scrollIntoView:!0,userEvent:i,effects:"delete.selection"==i?l$.announce.of(n.phrase("Selection deleted")):void 0})),!0)}function d0(e,t,i){if(e instanceof l$)for(let n of e.state.facet(l$.atomicRanges).map(t=>t(e)))n.between(t,t,(e,n)=>{e<t&&n>t&&(t=i?n:e)});return t}let d1=(e,t,i)=>dQ(e,n=>{let r=n.from,{state:s}=e,o=s.doc.lineAt(r),l,a;if(i&&!t&&r>o.from&&r<o.from+200&&!/[^ \t]/.test(l=o.text.slice(0,r-o.from))){if(" "==l[l.length-1])return r-1;let e=rb(l,s.tabSize)%cs(s)||cs(s);for(let t=0;t<e&&" "==l[l.length-1-t];t++)r--;a=r}else(a=np(o.text,r-o.from,t,t)+o.from)==r&&o.number!=(t?s.doc.lines:1)?a+=t?1:-1:!t&&/[\ufe00-\ufe0f]/.test(o.text.slice(a-o.from,r-o.from))&&(a=np(o.text,a-o.from,!1,!1)+o.from);return a}),d2=e=>d1(e,!1,!0),d5=e=>d1(e,!0,!1),d6=(e,t)=>dQ(e,i=>{let n=i.head,{state:r}=e,s=r.doc.lineAt(n),o=r.charCategorizer(n);for(let e=null;;){if(n==(t?s.to:s.from)){n==i.head&&s.number!=(t?r.doc.lines:1)&&(n+=t?1:-1);break}let l=np(s.text,n-s.from,t)+s.from,a=s.text.slice(Math.min(n,l)-s.from,Math.max(n,l)-s.from),h=o(a);if(null!=e&&h!=e)break;(" "!=a||n!=i.head)&&(e=h),n=l}return n}),d4=e=>d6(e,!1);function d3(e){let t=[],i=-1;for(let n of e.selection.ranges){let r=e.doc.lineAt(n.from),s=e.doc.lineAt(n.to);if(n.empty||n.to!=s.from||(s=e.doc.lineAt(n.to-1)),i>=r.number){let e=t[t.length-1];e.to=s.to,e.ranges.push(n)}else t.push({from:r.from,to:s.to,ranges:[n]});i=s.number+1}return t}function d8(e,t,i){if(e.readOnly)return!1;let n=[],r=[];for(let t of d3(e)){if(i?t.to==e.doc.length:0==t.from)continue;let s=e.doc.lineAt(i?t.to+1:t.from-1),o=s.length+1;if(i)for(let i of(n.push({from:t.to,to:s.to},{from:t.from,insert:s.text+e.lineBreak}),t.ranges))r.push(nA.range(Math.min(e.doc.length,i.anchor+o),Math.min(e.doc.length,i.head+o)));else for(let i of(n.push({from:s.from,to:t.from},{from:t.to,insert:e.lineBreak+s.text}),t.ranges))r.push(nA.range(i.anchor-o,i.head-o))}return!!n.length&&(t(e.update({changes:n,scrollIntoView:!0,selection:nA.create(r,e.selection.mainIndex),userEvent:"move.line"})),!0)}function d9(e,t,i){if(e.readOnly)return!1;let n=[];for(let t of d3(e))i?n.push({from:t.from,insert:e.doc.slice(t.from,t.to)+e.lineBreak}):n.push({from:t.to,insert:e.lineBreak+e.doc.slice(t.from,t.to)});let r=e.changes(n);return t(e.update({changes:r,selection:e.selection.map(r,i?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}let d7=ut(!1),ue=ut(!0);function ut(e){return({state:t,dispatch:i})=>{if(t.readOnly)return!1;let n=t.changeByRange(i=>{let{from:n,to:r}=i,s=t.doc.lineAt(n),o=!e&&n==r&&function(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let i=h5(e).resolveInner(t),n=i.childBefore(t),r=i.childAfter(t),s;return n&&r&&n.to<=t&&r.from>=t&&(s=n.type.prop(a7.closedBy))&&s.indexOf(r.name)>-1&&e.doc.lineAt(n.to).from==e.doc.lineAt(r.from).from&&!/\S/.test(e.sliceDoc(n.to,r.from))?{from:n.to,to:r.from}:null}(t,n);e&&(n=r=(r<=s.to?s:t.doc.lineAt(r)).to);let l=new ca(t,{simulateBreak:n,simulateDoubleBreak:!!o}),a=cl(l,n);for(null==a&&(a=rb(/^\s*/.exec(t.doc.lineAt(n).text)[0],t.tabSize));r<s.to&&/\s/.test(s.text[r-s.from]);)r++;o?{from:n,to:r}=o:n>s.from&&n<s.from+100&&!/\S/.test(s.text.slice(0,n))&&(n=s.from);let h=["",co(t,a)];return o&&h.push(co(t,l.lineIndent(s.from,-1))),{changes:{from:n,to:r,insert:ns.of(h)},range:nA.cursor(n+1+h[1].length)}});return i(t.update(n,{scrollIntoView:!0,userEvent:"input"})),!0}}function ui(e,t){let i=-1;return e.changeByRange(n=>{let r=[];for(let s=n.from;s<=n.to;){let o=e.doc.lineAt(s);o.number>i&&(n.empty||n.to>o.from)&&(t(o,r,n),i=o.number),s=o.to+1}let s=e.changes(r);return{changes:r,range:nA.range(s.mapPos(n.anchor,1),s.mapPos(n.head,1))}})}let un=({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(ui(e,(t,i)=>{i.push({from:t.from,insert:e.facet(cr)})}),{userEvent:"input.indent"})),!0),ur=({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(ui(e,(t,i)=>{let n=/^\s*/.exec(t.text)[0];if(!n)return;let r=rb(n,e.tabSize),s=0,o=co(e,Math.max(0,r-cs(e)));for(;s<n.length&&s<o.length&&n.charCodeAt(s)==o.charCodeAt(s);)s++;i.push({from:t.from+s,to:t.from+n.length,insert:o.slice(s)})}),{userEvent:"delete.dedent"})),!0),us=[{key:"Ctrl-b",run:dj,shift:dz,preventDefault:!0},{key:"Ctrl-f",run:dM,shift:dW},{key:"Ctrl-p",run:dO,shift:dH},{key:"Ctrl-n",run:dD,shift:d$},{key:"Ctrl-a",run:e=>dw(e,t=>nA.cursor(e.lineBlockAt(t.head).from,1)),shift:e=>dB(e,t=>nA.cursor(e.lineBlockAt(t.head).from))},{key:"Ctrl-e",run:e=>dw(e,t=>nA.cursor(e.lineBlockAt(t.head).to,-1)),shift:e=>dB(e,t=>nA.cursor(e.lineBlockAt(t.head).to))},{key:"Ctrl-d",run:d5},{key:"Ctrl-h",run:d2},{key:"Ctrl-k",run:e=>dQ(e,t=>{let i=e.lineBlockAt(t.head).to;return t.head<i?i:Math.min(e.state.doc.length,t.head+1)})},{key:"Ctrl-Alt-h",run:d4},{key:"Ctrl-o",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let i=e.changeByRange(e=>({changes:{from:e.from,to:e.to,insert:ns.of(["",""])},range:nA.cursor(e.from)}));return t(e.update(i,{scrollIntoView:!0,userEvent:"input"})),!0}},{key:"Ctrl-t",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let i=e.changeByRange(t=>{if(!t.empty||0==t.from||t.from==e.doc.length)return{range:t};let i=t.from,n=e.doc.lineAt(i),r=i==n.from?i-1:np(n.text,i-n.from,!1)+n.from,s=i==n.to?i+1:np(n.text,i-n.from,!0)+n.from;return{changes:{from:r,to:s,insert:e.doc.slice(i,s).append(e.doc.slice(r,i))},range:nA.cursor(s)}});return!i.changes.empty&&(t(e.update(i,{scrollIntoView:!0,userEvent:"move.character"})),!0)}},{key:"Ctrl-v",run:dI}],uo=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:e=>dw(e,t=>dA(e.state,t,!dC(e))),shift:e=>dB(e,t=>dA(e.state,t,!dC(e)))},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:e=>dw(e,t=>dA(e.state,t,dC(e))),shift:e=>dB(e,t=>dA(e.state,t,dC(e)))},{key:"Alt-ArrowUp",run:({state:e,dispatch:t})=>d8(e,t,!1)},{key:"Shift-Alt-ArrowUp",run:({state:e,dispatch:t})=>d9(e,t,!1)},{key:"Alt-ArrowDown",run:({state:e,dispatch:t})=>d8(e,t,!0)},{key:"Shift-Alt-ArrowDown",run:({state:e,dispatch:t})=>d9(e,t,!0)},{key:"Mod-Alt-ArrowUp",run:e=>dY(e,!1)},{key:"Mod-Alt-ArrowDown",run:e=>dY(e,!0)},{key:"Escape",run:({state:e,dispatch:t})=>{let i=e.selection,n=null;return i.ranges.length>1?n=nA.create([i.main]):i.main.empty||(n=nA.create([nA.cursor(i.main.head)])),!!n&&(t(db(e,n)),!0)}},{key:"Mod-Enter",run:ue},{key:"Alt-l",mac:"Ctrl-l",run:({state:e,dispatch:t})=>{let i=d3(e).map(({from:t,to:i})=>nA.range(t,Math.min(i+1,e.doc.length)));return t(e.update({selection:nA.create(i),userEvent:"select"})),!0}},{key:"Mod-i",run:({state:e,dispatch:t})=>{let i=dy(e.selection,t=>{let i=h5(e),n=i.resolveStack(t.from,1);if(t.empty){let e=i.resolveStack(t.from,-1);e.node.from>=n.node.from&&e.node.to<=n.node.to&&(n=e)}for(let e=n;e;e=e.next){let{node:i}=e;if((i.from<t.from&&i.to>=t.to||i.to>t.to&&i.from<=t.from)&&e.next)return nA.range(i.to,i.from)}return t});return!i.eq(e.selection)&&(t(db(e,i)),!0)},preventDefault:!0},{key:"Mod-[",run:ur},{key:"Mod-]",run:un},{key:"Mod-Alt-\\",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let i=Object.create(null),n=new ca(e,{overrideIndentation:e=>{let t=i[e];return null==t?-1:t}}),r=ui(e,(t,r,s)=>{let o=cl(n,t.from);if(null==o)return;/\S/.test(t.text)||(o=0);let l=/^\s*/.exec(t.text)[0],a=co(e,o);(l!=a||s.from<t.from+l.length)&&(i[t.from]=o,r.push({from:t.from,to:t.from+l.length,insert:a}))});return r.changes.empty||t(e.update(r,{userEvent:"indent"})),!0}},{key:"Shift-Mod-k",run:e=>{if(e.state.readOnly)return!1;let{state:t}=e,i=t.changes(d3(t).map(({from:e,to:i})=>(e>0?e--:i<t.doc.length&&i++,{from:e,to:i}))),n=dy(t.selection,t=>{let i;if(e.lineWrapping){let n=e.lineBlockAt(t.head),r=e.coordsAtPos(t.head,t.assoc||1);r&&(i=n.bottom+e.documentTop-r.bottom+e.defaultLineHeight/2)}return e.moveVertically(t,!0,i)}).map(i);return e.dispatch({changes:i,selection:n,scrollIntoView:!0,userEvent:"delete.line"}),!0}},{key:"Shift-Mod-\\",run:({state:e,dispatch:t})=>(function(e,t,i){let n=!1,r=dy(e.selection,t=>{let r=c_(e,t.head,-1)||c_(e,t.head,1)||t.head>0&&c_(e,t.head-1,1)||t.head<e.doc.length&&c_(e,t.head+1,-1);if(!r||!r.end)return t;n=!0;let s=r.start.from==t.head?r.end.to:r.end.from;return i?nA.range(t.anchor,s):nA.cursor(s)});return!!n&&(t(db(e,r)),!0)})(e,t,!1)},{key:"Mod-/",run:e=>{let{state:t}=e,i=t.doc.lineAt(t.selection.main.from),n=c8(e.state,i.from);return n.line?c6(e):!!n.block&&c3(e)}},{key:"Alt-A",run:c4},{key:"Ctrl-m",mac:"Shift-Alt-m",run:e=>(e.setTabFocusMode(),!0)}].concat([{key:"ArrowLeft",run:dj,shift:dz,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:e=>dZ(e,!dC(e)),shift:e=>dF(e,!dC(e)),preventDefault:!0},{mac:"Cmd-ArrowLeft",run:e=>dw(e,t=>dE(e,t,!dC(e))),shift:e=>dB(e,t=>dE(e,t,!dC(e))),preventDefault:!0},{key:"ArrowRight",run:dM,shift:dW,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:e=>dZ(e,dC(e)),shift:e=>dF(e,dC(e)),preventDefault:!0},{mac:"Cmd-ArrowRight",run:e=>dw(e,t=>dE(e,t,dC(e))),shift:e=>dB(e,t=>dE(e,t,dC(e))),preventDefault:!0},{key:"ArrowUp",run:dO,shift:dH,preventDefault:!0},{mac:"Cmd-ArrowUp",run:d_,shift:dJ},{mac:"Ctrl-ArrowUp",run:dL,shift:dK},{key:"ArrowDown",run:dD,shift:d$,preventDefault:!0},{mac:"Cmd-ArrowDown",run:dG,shift:dX},{mac:"Ctrl-ArrowDown",run:dI,shift:dU},{key:"PageUp",run:dL,shift:dK},{key:"PageDown",run:dI,shift:dU},{key:"Home",run:e=>dw(e,t=>dE(e,t,!1)),shift:e=>dB(e,t=>dE(e,t,!1)),preventDefault:!0},{key:"Mod-Home",run:d_,shift:dJ},{key:"End",run:e=>dw(e,t=>dE(e,t,!0)),shift:e=>dB(e,t=>dE(e,t,!0)),preventDefault:!0},{key:"Mod-End",run:dG,shift:dX},{key:"Enter",run:d7,shift:d7},{key:"Mod-a",run:({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:"select"})),!0)},{key:"Backspace",run:d2,shift:d2,preventDefault:!0},{key:"Delete",run:d5,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:d4,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:e=>d6(e,!0),preventDefault:!0},{mac:"Mod-Backspace",run:e=>dQ(e,t=>{let i=e.moveToLineBoundary(t,!1).head;return t.head>i?i:Math.max(0,t.head-1)}),preventDefault:!0},{mac:"Mod-Delete",run:e=>dQ(e,t=>{let i=e.moveToLineBoundary(t,!0).head;return t.head<i?i:Math.min(e.state.doc.length,t.head+1)}),preventDefault:!0}].concat(us.map(e=>({mac:e.key,run:e.run,shift:e.shift})))),ul={key:"Tab",run:un,shift:ur},ua="function"==typeof String.prototype.normalize?e=>e.normalize("NFKD"):e=>e;class uh{constructor(e,t,i=0,n=e.length,r,s){this.test=s,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(i,n),this.bufferStart=i,this.normalize=r?e=>r(ua(e)):ua,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return -1;this.bufferPos=0,this.buffer=this.iter.value}return nm(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){var e;let t=this.peek();if(t<0)return this.done=!0,this;let i=(e=t)<=65535?String.fromCharCode(e):String.fromCharCode(((e-=65536)>>10)+55296,(1023&e)+56320),n=this.bufferStart+this.bufferPos;this.bufferPos+=ng(t);let r=this.normalize(i);if(r.length)for(let e=0,t=n;;e++){let s=r.charCodeAt(e),o=this.match(s,t,this.bufferPos+this.bufferStart);if(e==r.length-1){if(o)return this.value=o,this;break}t==n&&e<i.length&&i.charCodeAt(e)==s&&t++}}}match(e,t,i){let n=null;for(let t=0;t<this.matches.length;t+=2){let r=this.matches[t],s=!1;this.query.charCodeAt(r)==e&&(r==this.query.length-1?n={from:this.matches[t+1],to:i}:(this.matches[t]++,s=!0)),s||(this.matches.splice(t,2),t-=2)}return this.query.charCodeAt(0)==e&&(1==this.query.length?n={from:t,to:i}:this.matches.push(1,t)),n&&this.test&&!this.test(n.from,n.to,this.buffer,this.bufferStart)&&(n=null),n}}"undefined"!=typeof Symbol&&(uh.prototype[Symbol.iterator]=function(){return this});let uc={from:-1,to:-1,match:/.*/.exec("")},ud="gm"+(null==/x/.unicode?"":"u");class uu{constructor(e,t,i,n=0,r=e.length){if(this.text=e,this.to=r,this.curLine="",this.done=!1,this.value=uc,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new um(e,t,i,n,r);this.re=new RegExp(t,ud+((null==i?void 0:i.ignoreCase)?"i":"")),this.test=null==i?void 0:i.test,this.iter=e.iter();let s=e.lineAt(n);this.curLineStart=s.from,this.matchPos=ug(e,n),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine="":(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let i=this.curLineStart+t.index,n=i+t[0].length;if(this.matchPos=ug(this.text,n+(i==n?1:0)),i==this.curLineStart+this.curLine.length&&this.nextLine(),(i<n||i>this.value.to)&&(!this.test||this.test(i,n,t)))return this.value={from:i,to:n,match:t},this;e=this.matchPos-this.curLineStart}else{if(!(this.curLineStart+this.curLine.length<this.to))return this.done=!0,this;this.nextLine(),e=0}}}}let uf=new WeakMap;class up{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(e,t,i){let n=uf.get(e);if(!n||n.from>=i||n.to<=t){let n=new up(t,e.sliceString(t,i));return uf.set(e,n),n}if(n.from==t&&n.to==i)return n;let{text:r,from:s}=n;return s>t&&(r=e.sliceString(t,s)+r,s=t),n.to<i&&(r+=e.sliceString(n.to,i)),uf.set(e,new up(s,r)),new up(t,r.slice(t-s,i-s))}}class um{constructor(e,t,i,n,r){this.text=e,this.to=r,this.done=!1,this.value=uc,this.matchPos=ug(e,n),this.re=new RegExp(t,ud+((null==i?void 0:i.ignoreCase)?"i":"")),this.test=null==i?void 0:i.test,this.flat=up.get(e,n,this.chunkEnd(n+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let e=this.flat.from+t.index,i=e+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(e,i,t)))return this.value={from:e,to:i,match:t},this.matchPos=ug(this.text,i+(e==i?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=up.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+2*this.flat.text.length))}}}function ug(e,t){if(t>=e.length)return t;let i=e.lineAt(t),n;for(;t<i.to&&(n=i.text.charCodeAt(t-i.from))>=56320&&n<57344;)t++;return t}"undefined"!=typeof Symbol&&(uu.prototype[Symbol.iterator]=um.prototype[Symbol.iterator]=function(){return this});let ux={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},uv=nD.define({combine:e=>ri(e,ux,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}),uy=rQ.mark({class:"cm-selectionMatch"}),ub=rQ.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function uw(e,t,i,n){return(0==i||e(t.sliceDoc(i-1,i))!=n7.Word)&&(n==t.doc.length||e(t.sliceDoc(n,n+1))!=n7.Word)}let uk=sG.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.selectionSet||e.docChanged||e.viewportChanged)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=e.state.facet(uv),{state:i}=e,n=i.selection;if(n.ranges.length>1)return rQ.none;let r=n.main,s,o=null;if(r.empty){if(!t.highlightWordAroundCursor)return rQ.none;let e=i.wordAt(r.head);if(!e)return rQ.none;o=i.charCategorizer(r.head),s=i.sliceDoc(e.from,e.to)}else{let e=r.to-r.from;if(e<t.minSelectionLength||e>200)return rQ.none;if(t.wholeWords){var l,a,h;if(s=i.sliceDoc(r.from,r.to),!(uw(o=i.charCategorizer(r.head),i,r.from,r.to)&&(l=o,a=r.from,h=r.to,l(i.sliceDoc(a,a+1))==n7.Word&&l(i.sliceDoc(h-1,h))==n7.Word)))return rQ.none}else if(!(s=i.sliceDoc(r.from,r.to)))return rQ.none}let c=[];for(let n of e.visibleRanges){let e=new uh(i.doc,s,n.from,n.to);for(;!e.next().done;){let{from:n,to:s}=e.value;if((!o||uw(o,i,n,s))&&(r.empty&&n<=r.from&&s>=r.to?c.push(ub.range(n,s)):(n>=r.to||s<=r.from)&&c.push(uy.range(n,s)),c.length>t.maxMatches))return rQ.none}}return rQ.set(c)}},{decorations:e=>e.decorations}),uS=l$.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),uC=({state:e,dispatch:t})=>{let{selection:i}=e,n=nA.create(i.ranges.map(t=>e.wordAt(t.head)||nA.cursor(t.head)),i.mainIndex);return!n.eq(i)&&(t(e.update({selection:n})),!0)},uj=nD.define({combine:e=>ri(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new u0(e),scrollToMatch:e=>l$.scrollIntoView(e)})});class uM{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||"",this.valid=!!this.search&&(!this.regexp||function(e){try{return new RegExp(e,ud),!0}catch(e){return!1}}(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(e,t)=>"n"==t?"\n":"r"==t?"\r":"t"==t?" ":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new uP(this):new uT(this)}getCursor(e,t=0,i){let n=e.doc?e:rt.create({doc:e});return null==i&&(i=n.doc.length),this.regexp?uO(this,n,t,i):uA(this,n,t,i)}}class uZ{constructor(e){this.spec=e}}function uA(e,t,i,n){var r,s,o,l;let a;return e.wholeWord&&(r=t.doc,s=t.charCategorizer(t.selection.main.head),a=(e,t,i,n)=>((n>e||n+i.length<t)&&(n=Math.max(0,e-2),i=r.sliceString(n,Math.min(r.length,t+2))),(s(uD(i,e-n))!=n7.Word||s(uR(i,e-n))!=n7.Word)&&(s(uR(i,t-n))!=n7.Word||s(uD(i,t-n))!=n7.Word))),e.test&&(o=e.test,l=a,a=(e,i,n,r)=>(!l||!!l(e,i,n,r))&&o(e>=r&&i<=r+n.length?n.slice(e-r,i-r):t.doc.sliceString(e,i),t,e,i)),new uh(t.doc,e.unquoted,i,n,e.caseSensitive?void 0:e=>e.toLowerCase(),a)}class uT extends uZ{constructor(e){super(e)}nextMatch(e,t,i){let n=uA(this.spec,e,i,e.doc.length).nextOverlapping();if(n.done){let i=Math.min(e.doc.length,t+this.spec.unquoted.length);n=uA(this.spec,e,0,i).nextOverlapping()}return n.done||n.value.from==t&&n.value.to==i?null:n.value}prevMatchInRange(e,t,i){for(let n=i;;){let i=Math.max(t,n-1e4-this.spec.unquoted.length),r=uA(this.spec,e,i,n),s=null;for(;!r.nextOverlapping().done;)s=r.value;if(s)return s;if(i==t)return null;n-=1e4}}prevMatch(e,t,i){let n=this.prevMatchInRange(e,0,t);return n||(n=this.prevMatchInRange(e,Math.max(0,i-this.spec.unquoted.length),e.doc.length)),n&&(n.from!=t||n.to!=i)?n:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let i=uA(this.spec,e,0,e.doc.length),n=[];for(;!i.next().done;){if(n.length>=t)return null;n.push(i.value)}return n}highlight(e,t,i,n){let r=uA(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(i+this.spec.unquoted.length,e.doc.length));for(;!r.next().done;)n(r.value.from,r.value.to)}}function uO(e,t,i,n){var r,s,o;let l;return e.wholeWord&&(r=t.charCategorizer(t.selection.main.head),l=(e,t,i)=>!i[0].length||(r(uD(i.input,i.index))!=n7.Word||r(uR(i.input,i.index))!=n7.Word)&&(r(uR(i.input,i.index+i[0].length))!=n7.Word||r(uD(i.input,i.index+i[0].length))!=n7.Word)),e.test&&(s=e.test,o=l,l=(e,i,n)=>(!o||o(e,i,n))&&s(n[0],t,e,i)),new uu(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:l},i,n)}function uD(e,t){return e.slice(np(e,t,!1),t)}function uR(e,t){return e.slice(t,np(e,t))}class uP extends uZ{nextMatch(e,t,i){let n=uO(this.spec,e,i,e.doc.length).next();return n.done&&(n=uO(this.spec,e,0,t).next()),n.done?null:n.value}prevMatchInRange(e,t,i){for(let n=1;;n++){let r=Math.max(t,i-1e4*n),s=uO(this.spec,e,r,i),o=null;for(;!s.next().done;)o=s.value;if(o&&(r==t||o.from>r+10))return o;if(r==t)return null}}prevMatch(e,t,i){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,i,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,i)=>{if("&"==i)return e.match[0];if("$"==i)return"$";for(let t=i.length;t>0;t--){let n=+i.slice(0,t);if(n>0&&n<e.match.length)return e.match[n]+i.slice(t)}return t})}matchAll(e,t){let i=uO(this.spec,e,0,e.doc.length),n=[];for(;!i.next().done;){if(n.length>=t)return null;n.push(i.value)}return n}highlight(e,t,i,n){let r=uO(this.spec,e,Math.max(0,t-250),Math.min(i+250,e.doc.length));for(;!r.next().done;)n(r.value.from,r.value.to)}}let uL=n5.define(),uI=n5.define(),uE=nB.define({create:e=>new uB(u_(e).create(),null),update(e,t){for(let i of t.effects)i.is(uL)?e=new uB(i.value.create(),e.panel):i.is(uI)&&(e=new uB(e.query,i.value?uU:null));return e},provide:e=>aB.from(e,e=>e.panel)});class uB{constructor(e,t){this.query=e,this.panel=t}}let uN=rQ.mark({class:"cm-searchMatch"}),uz=rQ.mark({class:"cm-searchMatch cm-searchMatch-selected"}),uW=sG.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(uE))}update(e){let t=e.state.field(uE);(t!=e.startState.field(uE)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return rQ.none;let{view:i}=this,n=new rh;for(let t=0,r=i.visibleRanges,s=r.length;t<s;t++){let{from:o,to:l}=r[t];for(;t<s-1&&l>r[t+1].from-500;)l=r[++t].to;e.highlight(i.state,o,l,(e,t)=>{let r=i.state.selection.ranges.some(i=>i.from==e&&i.to==t);n.add(e,t,r?uz:uN)})}return n.finish()}},{decorations:e=>e.decorations});function uF(e){return t=>{let i=t.state.field(uE,!1);return i&&i.query.spec.valid?e(t,i):uX(t)}}let uV=uF((e,{query:t})=>{let{to:i}=e.state.selection.main,n=t.nextMatch(e.state,i,i);if(!n)return!1;let r=nA.single(n.from,n.to),s=e.state.facet(uj);return e.dispatch({selection:r,effects:[u5(e,n),s.scrollToMatch(r.main,e)],userEvent:"select.search"}),uJ(e),!0}),uH=uF((e,{query:t})=>{let{state:i}=e,{from:n}=i.selection.main,r=t.prevMatch(i,n,n);if(!r)return!1;let s=nA.single(r.from,r.to),o=e.state.facet(uj);return e.dispatch({selection:s,effects:[u5(e,r),o.scrollToMatch(s.main,e)],userEvent:"select.search"}),uJ(e),!0}),u$=uF((e,{query:t})=>{let i=t.matchAll(e.state,1e3);return!!i&&!!i.length&&(e.dispatch({selection:nA.create(i.map(e=>nA.range(e.from,e.to))),userEvent:"select.search.matches"}),!0)}),uq=uF((e,{query:t})=>{let{state:i}=e,{from:n,to:r}=i.selection.main;if(i.readOnly)return!1;let s=t.nextMatch(i,n,n);if(!s)return!1;let o=s,l=[],a,h,c=[];o.from==n&&o.to==r&&(h=i.toText(t.getReplacement(o)),l.push({from:o.from,to:o.to,insert:h}),o=t.nextMatch(i,o.from,o.to),c.push(l$.announce.of(i.phrase("replaced match on line $",i.doc.lineAt(n).number)+".")));let d=e.state.changes(l);return o&&(a=nA.single(o.from,o.to).map(d),c.push(u5(e,o)),c.push(i.facet(uj).scrollToMatch(a.main,e))),e.dispatch({changes:d,selection:a,effects:c,userEvent:"input.replace"}),!0}),uK=uF((e,{query:t})=>{if(e.state.readOnly)return!1;let i=t.matchAll(e.state,1e9).map(e=>{let{from:i,to:n}=e;return{from:i,to:n,insert:t.getReplacement(e)}});if(!i.length)return!1;let n=e.state.phrase("replaced $ matches",i.length)+".";return e.dispatch({changes:i,effects:l$.announce.of(n),userEvent:"input.replace.all"}),!0});function uU(e){return e.state.facet(uj).createPanel(e)}function u_(e,t){var i,n,r,s,o;let l=e.selection.main,a=l.empty||l.to>l.from+100?"":e.sliceDoc(l.from,l.to);if(t&&!a)return t;let h=e.facet(uj);return new uM({search:(null!==(i=null==t?void 0:t.literal)&&void 0!==i?i:h.literal)?a:a.replace(/\n/g,"\\n"),caseSensitive:null!==(n=null==t?void 0:t.caseSensitive)&&void 0!==n?n:h.caseSensitive,literal:null!==(r=null==t?void 0:t.literal)&&void 0!==r?r:h.literal,regexp:null!==(s=null==t?void 0:t.regexp)&&void 0!==s?s:h.regexp,wholeWord:null!==(o=null==t?void 0:t.wholeWord)&&void 0!==o?o:h.wholeWord})}function uG(e){let t=aP(e,uU);return t&&t.dom.querySelector("[main-field]")}function uJ(e){let t=uG(e);t&&t==e.root.activeElement&&t.select()}let uX=e=>{let t=e.state.field(uE,!1);if(t&&t.panel){let i=uG(e);if(i&&i!=e.root.activeElement){let n=u_(e.state,t.query.spec);n.valid&&e.dispatch({effects:uL.of(n)}),i.focus(),i.select()}}else e.dispatch({effects:[uI.of(!0),t?uL.of(u_(e.state,t.query.spec)):n5.appendConfig.of(u4)]});return!0},uY=e=>{let t=e.state.field(uE,!1);if(!t||!t.panel)return!1;let i=aP(e,uU);return i&&i.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:uI.of(!1)}),!0},uQ=[{key:"Mod-f",run:uX,scope:"editor search-panel"},{key:"F3",run:uV,shift:uH,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:uV,shift:uH,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:uY,scope:"editor search-panel"},{key:"Mod-Shift-l",run:({state:e,dispatch:t})=>{let i=e.selection;if(i.ranges.length>1||i.main.empty)return!1;let{from:n,to:r}=i.main,s=[],o=0;for(let t=new uh(e.doc,e.sliceDoc(n,r));!t.next().done;){if(s.length>1e3)return!1;t.value.from==n&&(o=s.length),s.push(nA.range(t.value.from,t.value.to))}return t(e.update({selection:nA.create(s,o),userEvent:"select.search.matches"})),!0}},{key:"Mod-Alt-g",run:e=>{let{state:t}=e,i=String(t.doc.lineAt(e.state.selection.main.head).number),{close:n,result:r}=function(e,t){let i;let n=new Promise(e=>i=e),r=e=>(function(e,t,i){let n=t.content?t.content(e,()=>o(null)):null;if(!n){if(n=rL("form"),t.input){let e=rL("input",t.input);/^(text|password|number|email|tel|url)$/.test(e.type)&&e.classList.add("cm-textfield"),e.name||(e.name="input"),n.appendChild(rL("label",(t.label||"")+": ",e))}else n.appendChild(document.createTextNode(t.label||""));n.appendChild(document.createTextNode(" ")),n.appendChild(rL("button",{class:"cm-button",type:"submit"},t.submitLabel||"OK"))}let r="FORM"==n.nodeName?[n]:n.querySelectorAll("form");for(let e=0;e<r.length;e++){let t=r[e];t.addEventListener("keydown",e=>{27==e.keyCode?(e.preventDefault(),o(null)):13==e.keyCode&&(e.preventDefault(),o(t))}),t.addEventListener("submit",e=>{e.preventDefault(),o(t)})}let s=rL("div",n,rL("button",{onclick:()=>o(null),"aria-label":e.state.phrase("close"),class:"cm-dialog-close",type:"button"},["\xd7"]));function o(t){s.contains(s.ownerDocument.activeElement)&&e.focus(),i(t)}return t.class&&(s.className=t.class),s.classList.add("cm-dialog"),{dom:s,top:t.top,mount:()=>{if(t.focus){let e;(e="string"==typeof t.focus?n.querySelector(t.focus):n.querySelector("input")||n.querySelector("button"))&&"select"in e?e.select():e&&"focus"in e&&e.focus()}}}})(e,t,i);e.state.field(aN,!1)?e.dispatch({effects:az.of(r)}):e.dispatch({effects:n5.appendConfig.of(aN.init(()=>[r]))});let s=aW.of(r);return{close:s,result:n.then(t=>((e.win.queueMicrotask||(t=>e.win.setTimeout(t,10)))(()=>{e.state.field(aN).indexOf(r)>-1&&e.dispatch({effects:s})}),t))}}(e,{label:t.phrase("Go to line"),input:{type:"text",name:"line",value:i},focus:!0,submitLabel:t.phrase("go")});return r.then(i=>{let r=i&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(i.elements.line.value);if(!r){e.dispatch({effects:n});return}let s=t.doc.lineAt(t.selection.main.head),[,o,l,a,h]=r,c=a?+a.slice(1):0,d=l?+l:s.number;if(l&&h){let e=d/100;o&&(e=e*("-"==o?-1:1)+s.number/t.doc.lines),d=Math.round(t.doc.lines*e)}else l&&o&&(d=d*("-"==o?-1:1)+s.number);let u=t.doc.line(Math.max(1,Math.min(t.doc.lines,d))),f=nA.cursor(u.from+Math.max(0,Math.min(c,u.length)));e.dispatch({effects:[n,l$.scrollIntoView(f.from,{y:"center"})],selection:f})}),!0}},{key:"Mod-d",run:({state:e,dispatch:t})=>{let{ranges:i}=e.selection;if(i.some(e=>e.from===e.to))return uC({state:e,dispatch:t});let n=e.sliceDoc(i[0].from,i[0].to);if(e.selection.ranges.some(t=>e.sliceDoc(t.from,t.to)!=n))return!1;let r=function(e,t){let{main:i,ranges:n}=e.selection,r=e.wordAt(i.head),s=r&&r.from==i.from&&r.to==i.to;for(let i=!1,r=new uh(e.doc,t,n[n.length-1].to);;)if(r.next(),r.done){if(i)return null;r=new uh(e.doc,t,0,Math.max(0,n[n.length-1].from-1)),i=!0}else{if(i&&n.some(e=>e.from==r.value.from))continue;if(s){let t=e.wordAt(r.value.from);if(!t||t.from!=r.value.from||t.to!=r.value.to)continue}return r.value}}(e,n);return!!r&&(t(e.update({selection:e.selection.addRange(nA.range(r.from,r.to),!1),effects:l$.scrollIntoView(r.to)})),!0)},preventDefault:!0}];class u0{constructor(e){this.view=e;let t=this.query=e.state.field(uE).query.spec;function i(e,t,i){return rL("button",{class:"cm-button",name:e,onclick:t,type:"button"},i)}this.commit=this.commit.bind(this),this.searchField=rL("input",{value:t.search,placeholder:u1(e,"Find"),"aria-label":u1(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=rL("input",{value:t.replace,placeholder:u1(e,"Replace"),"aria-label":u1(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=rL("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=rL("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=rL("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit}),this.dom=rL("div",{onkeydown:e=>this.keydown(e),class:"cm-search"},[this.searchField,i("next",()=>uV(e),[u1(e,"next")]),i("prev",()=>uH(e),[u1(e,"previous")]),i("select",()=>u$(e),[u1(e,"all")]),rL("label",null,[this.caseField,u1(e,"match case")]),rL("label",null,[this.reField,u1(e,"regexp")]),rL("label",null,[this.wordField,u1(e,"by word")]),...e.state.readOnly?[]:[rL("br"),this.replaceField,i("replace",()=>uq(e),[u1(e,"replace")]),i("replaceAll",()=>uK(e),[u1(e,"replace all")])],rL("button",{name:"close",onclick:()=>uY(e),"aria-label":u1(e,"close"),type:"button"},["\xd7"])])}commit(){let e=new uM({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:uL.of(e)}))}keydown(e){var t,i;(t=this.view,i="search-panel",l5(l0(t.state),e,t,i))?e.preventDefault():13==e.keyCode&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?uH:uV)(this.view)):13==e.keyCode&&e.target==this.replaceField&&(e.preventDefault(),uq(this.view))}update(e){for(let t of e.transactions)for(let e of t.effects)e.is(uL)&&!e.value.eq(this.query)&&this.setQuery(e.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(uj).top}}function u1(e,t){return e.state.phrase(t)}let u2=/[\s\.,:;?!]/;function u5(e,{from:t,to:i}){let n=e.state.doc.lineAt(t),r=e.state.doc.lineAt(i).to,s=Math.max(n.from,t-30),o=Math.min(r,i+30),l=e.state.sliceDoc(s,o);if(s!=n.from){for(let e=0;e<30;e++)if(!u2.test(l[e+1])&&u2.test(l[e])){l=l.slice(e);break}}if(o!=r){for(let e=l.length-1;e>l.length-30;e--)if(!u2.test(l[e-1])&&u2.test(l[e])){l=l.slice(0,e);break}}return l$.announce.of(`${e.state.phrase("current match")}. ${l} ${e.state.phrase("on line")} ${n.number}.`)}let u6=l$.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),u4=[uE,nW.low(uW),u6],u3="#e06c75",u8="#abb2bf",u9="#7d8799",u7="#d19a66",fe="#2c313a",ft="#282c34",fi="#353a42",fn="#528bff",fr=[l$.theme({"&":{color:u8,backgroundColor:ft},".cm-content":{caretColor:fn},".cm-cursor, .cm-dropCursor":{borderLeftColor:fn},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:"#3E4451"},".cm-panels":{backgroundColor:"#21252b",color:u8},".cm-panels.cm-panels-top":{borderBottom:"2px solid black"},".cm-panels.cm-panels-bottom":{borderTop:"2px solid black"},".cm-searchMatch":{backgroundColor:"#72a1ff59",outline:"1px solid #457dff"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"#6199ff2f"},".cm-activeLine":{backgroundColor:"#6699ff0b"},".cm-selectionMatch":{backgroundColor:"#aafe661a"},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bad0f847"},".cm-gutters":{backgroundColor:ft,color:u9,border:"none"},".cm-activeLineGutter":{backgroundColor:fe},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:fi},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:fi,borderBottomColor:fi},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:fe,color:u8}}},{dark:!0}),cL(cO.define([{tag:hY.keyword,color:"#c678dd"},{tag:[hY.name,hY.deleted,hY.character,hY.propertyName,hY.macroName],color:u3},{tag:[hY.function(hY.variableName),hY.labelName],color:"#61afef"},{tag:[hY.color,hY.constant(hY.name),hY.standard(hY.name)],color:u7},{tag:[hY.definition(hY.name),hY.separator],color:u8},{tag:[hY.typeName,hY.className,hY.number,hY.changed,hY.annotation,hY.modifier,hY.self,hY.namespace],color:"#e5c07b"},{tag:[hY.operator,hY.operatorKeyword,hY.url,hY.escape,hY.regexp,hY.link,hY.special(hY.string)],color:"#56b6c2"},{tag:[hY.meta,hY.comment],color:u9},{tag:hY.strong,fontWeight:"bold"},{tag:hY.emphasis,fontStyle:"italic"},{tag:hY.strikethrough,textDecoration:"line-through"},{tag:hY.link,color:u9,textDecoration:"underline"},{tag:hY.heading,fontWeight:"bold",color:u3},{tag:[hY.atom,hY.bool,hY.special(hY.variableName)],color:u7},{tag:[hY.processingInstruction,hY.string,hY.inserted],color:"#98c379"},{tag:hY.invalid,color:"#ffffff"}]))],fs=(0,c.forwardRef)(function({serverName:e,filePath:t,onDirtyChange:i},n){let r=(0,c.useRef)(null),s=(0,c.useRef)(null),[o,l]=(0,c.useState)(!1),[a,d]=(0,c.useState)({line:1,col:1}),{data:u,isLoading:p,error:m}=t3(e,t),v=t8(e),y=(0,c.useCallback)(()=>{if(!s.current)return;let e=s.current.state.doc.toString();v.mutate({path:t,content:e},{onSuccess:()=>{l(!1),i(!1)}})},[t,v,i]);return((0,c.useImperativeHandle)(n,()=>({save:y,isDirty:()=>o}),[y,o]),(0,c.useEffect)(()=>{i(o)},[o,i]),(0,c.useEffect)(()=>{let e;if(!r.current||!u)return;s.current&&(s.current.destroy(),s.current=null);let n=lY.of([{key:"Mod-s",run:()=>(setTimeout(()=>{if(!s.current)return;let e=s.current.state.doc.toString();v.mutate({path:t,content:e},{onSuccess:()=>{l(!1),i(!1)}})},0),!0),preventDefault:!0}]),o=l$.updateListener.of(e=>{if(e.docChanged&&l(!0),e.selectionSet||e.docChanged){let t=e.state.selection.main.head,i=e.state.doc.lineAt(t);d({line:i.number,col:t-i.from+1})}}),a=rt.create({doc:u.content,extensions:[function(e={}){return[a2.of(e),aU(),a4]}(),av,function(e={}){return[af.of(e),ap||(ap=sG.fromClass(class{constructor(e){this.view=e,this.decorations=rQ.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(e.state.facet(af)),this.decorations=this.decorator.createDeco(e)}makeDecorator(e){return new aa({regexp:e.specialChars,decoration:(t,i,n)=>{let{doc:r}=i.state,s=nm(t[0],0);if(9==s){let e=r.lineAt(n),t=i.state.tabSize,s=rb(e.text,t,n-e.from);return rQ.replace({widget:new ag((t-s%t)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[s]||(this.decorationCache[s]=rQ.replace({widget:new am(e,s)}))},boundary:e.replaceTabs?void 0:/[^]/})}update(e){let t=e.state.facet(af);e.startState.facet(af)!=t?(this.decorator=this.makeDecorator(t),this.decorations=this.decorator.createDeco(e.view)):this.decorations=this.decorator.updateDeco(e,this.decorations)}},{decorations:e=>e.decorations}))]}(),function(e={}){return[dn,di.of(e),l$.domEventHandlers({beforeinput(e,t){let i="historyUndo"==e.inputType?ds:"historyRedo"==e.inputType?dl:null;return!!i&&(e.preventDefault(),i(t))}})]}(),function(e={}){var t;let i;let n={...cZ,...e},r=new cA(n,!0),s=new cA(n,!1),o=sG.fromClass(class{constructor(e){this.from=e.viewport.from,this.markers=this.buildMarkers(e)}update(e){(e.docChanged||e.viewportChanged||e.startState.facet(ci)!=e.state.facet(ci)||e.startState.field(cy,!1)!=e.state.field(cy,!1)||h5(e.startState)!=h5(e.state)||n.foldingChanged(e))&&(this.markers=this.buildMarkers(e.view))}buildMarkers(e){let t=new rh;for(let i of e.viewportLineBlocks){let n=cw(e.state,i.from,i.to)?s:cm(e.state,i.from,i.to)?r:null;n&&t.add(i.from,i.from,n)}return t.finish()}}),{domEventHandlers:l}=n;return[o,(t={class:"cm-foldGutter",markers(e){var t;return(null===(t=e.plugin(o))||void 0===t?void 0:t.markers)||ra.empty},initialSpacer:()=>new cA(n,!1),domEventHandlers:{...l,click:(e,t,i)=>{if(l.click&&l.click(e,t,i))return!0;let n=cw(e.state,t.from,t.to);if(n)return e.dispatch({effects:cv.of(n)}),!0;let r=cm(e.state,t.from,t.to);return!!r&&(e.dispatch({effects:cx.of(r)}),!0)}}},[aU(),aq.of({...a$,...t})]),i=[cy,cT]]}(),function(e={}){return[ae.of(e),ai,ar,as,sW.of(!0)]}(),(e=e=>e.altKey&&0==e.button,l$.mouseSelectionStyle.of((t,i)=>{let n,r;return e(i)?(n=ay(t,i),r=t.state.selection,n?{update(e){if(e.docChanged){let t=e.changes.mapPos(e.startState.doc.line(n.line).from),i=e.state.doc.lineAt(t);n={line:i.number,col:n.col,off:Math.min(n.off,i.length)},r=r.map(e.changes)}},get(e,i,s){let o=ay(t,e);if(!o)return r;let l=function(e,t,i){let n=Math.min(t.line,i.line),r=Math.max(t.line,i.line),s=[];if(t.off>2e3||i.off>2e3||t.col<0||i.col<0){let o=Math.min(t.off,i.off),l=Math.max(t.off,i.off);for(let t=n;t<=r;t++){let i=e.doc.line(t);i.length<=l&&s.push(nA.range(i.from+o,i.to+l))}}else{let o=Math.min(t.col,i.col),l=Math.max(t.col,i.col);for(let t=n;t<=r;t++){let i=e.doc.line(t),n=rw(i.text,o,e.tabSize,!0);if(n<0)s.push(nA.cursor(i.to));else{let t=rw(i.text,l,e.tabSize);s.push(nA.range(i.from+n,i.from+t))}}}return s}(t.state,n,o);return l.length?s?nA.create(l.concat(r.ranges)):nA.create(l):r}}:null):null})),rt.transactionFilter.of(e=>{if(!e.docChanged||!e.isUserEvent("input.type")&&!e.isUserEvent("input.complete"))return e;let t=e.startState.languageDataAt("indentOnInput",e.startState.selection.main.head);if(!t.length)return e;let i=e.newDoc,{head:n}=e.newSelection.main,r=i.lineAt(n);if(n>r.from+200)return e;let s=i.sliceString(r.from,n);if(!t.some(e=>e.test(s)))return e;let{state:o}=e,l=-1,a=[];for(let{head:e}of o.selection.ranges){let t=o.doc.lineAt(e);if(t.from==l)continue;l=t.from;let i=cl(o,t.from);if(null==i)continue;let n=/^\s*/.exec(t.text)[0],r=co(o,i);n!=r&&a.push({from:t.from,to:t.from+n.length,insert:r})}return a.length?[e,{changes:a,sequential:!0}]:e}),function(e={}){return[cW.of(e),c$]}(),[uS,uk],cL(cB,{fallback:!0}),fr,n,lY.of([...uo,...dv,...uQ,ul]),o,l$.lineWrapping,l$.theme({"&":{height:"100%",fontSize:"13px"},".cm-scroller":{overflow:"auto"},".cm-content":{fontFamily:'"Fira Code", "Cascadia Code", "JetBrains Mono", "Consolas", monospace'},".cm-gutters":{fontFamily:'"Fira Code", "Cascadia Code", "JetBrains Mono", "Consolas", monospace'}})]}),h=new l$({state:a,parent:r.current});return s.current=h,()=>{h.destroy(),s.current=null}},[u,t]),p)?h.jsx(f.Z,{sx:{display:"flex",justifyContent:"center",alignItems:"center",flex:1},children:h.jsx(x.Z,{})}):m?(0,h.jsxs)(g.Z,{severity:"error",sx:{m:2},children:["Failed to load file: ",m.message]}):(0,h.jsxs)(f.Z,{sx:{display:"flex",flexDirection:"column",flex:1,overflow:"hidden"},children:[v.isError&&(0,h.jsxs)(g.Z,{severity:"error",sx:{mx:2,mt:1},children:["Failed to save: ",v.error.message]}),v.isSuccess&&!o&&h.jsx(g.Z,{severity:"success",sx:{mx:2,mt:1},children:"File saved successfully."}),u&&h.jsx(f.Z,{ref:r,sx:{flex:1,overflow:"hidden"}}),u&&h.jsx(iT,{language:"Properties",fileSize:u.size,line:a.line,col:a.col,dirty:o})]})});function fo({serverName:e,onBack:t}){let[i,n]=(0,c.useState)("form"),[r,s]=(0,c.useState)(!1),[o,l]=(0,c.useState)(null),a=(0,c.useRef)(null),d=(0,c.useCallback)((e,t)=>{t&&t!==i&&("raw"===i&&r?l("form"):n(t))},[i,r]),u=(0,c.useCallback)(()=>{"raw"===i&&r?l("back"):t()},[i,r,t]),g=(0,c.useCallback)(()=>{l(null),s(!1),"back"===o?t():"form"===o&&n("form")},[o,t]),x=(0,c.useCallback)(()=>{a.current?.save()},[]);return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(y.Z,{sx:{borderRadius:3,display:"flex",flexDirection:"column",minHeight:600},children:[(0,h.jsxs)(f.Z,{sx:{display:"flex",alignItems:"center",gap:1,px:2,py:1,borderBottom:1,borderColor:"divider"},children:[h.jsx(m.Z,{size:"small",onClick:u,"aria-label":"back",children:h.jsx(P.Z,{})}),h.jsx(i_.Z,{sx:{color:"primary.main"}}),h.jsx(w.Z,{variant:"subtitle1",sx:{fontWeight:600,flex:1},noWrap:!0,children:"server.properties"}),(0,h.jsxs)(iK.Z,{value:i,exclusive:!0,onChange:d,size:"small",children:[(0,h.jsxs)(iU.Z,{value:"form",children:[h.jsx(iG.Z,{fontSize:"small",sx:{mr:.5}}),"Form"]}),(0,h.jsxs)(iU.Z,{value:"raw",children:[h.jsx(iN.Z,{fontSize:"small",sx:{mr:.5}}),"Raw"]})]}),"raw"===i&&h.jsx(p.Z,{size:"small",variant:"contained",startIcon:h.jsx(eb.Z,{}),onClick:x,disabled:!r,children:"Save"})]}),h.jsx(b.Z,{sx:{flex:1,overflow:"auto",p:0,"&:last-child":{pb:0}},children:"form"===i?h.jsx(i3,{serverName:e}):h.jsx(f.Z,{sx:{display:"flex",flexDirection:"column",height:"100%",minHeight:500},children:h.jsx(fs,{ref:a,serverName:e,filePath:"/server.properties",onDirtyChange:s})})})]}),h.jsx(M.Z,{open:null!==o,onClose:()=>l(null),maxWidth:"xs",fullWidth:!0,children:(0,h.jsxs)(f.Z,{sx:{p:3},children:[h.jsx(w.Z,{variant:"h6",gutterBottom:!0,children:"Unsaved Changes"}),h.jsx(w.Z,{variant:"body2",color:"text.secondary",sx:{mb:3},children:"You have unsaved changes in the raw editor. Do you want to discard them?"}),(0,h.jsxs)(f.Z,{sx:{display:"flex",justifyContent:"flex-end",gap:1},children:[h.jsx(p.Z,{onClick:()=>l(null),children:"Cancel"}),h.jsx(p.Z,{onClick:g,color:"error",variant:"contained",children:"Discard"})]})]})})]})}var fl=i(40238);function fa(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:e<1073741824?`${(e/1024/1024).toFixed(1)} MB`:`${(e/1024/1024/1024).toFixed(1)} GB`}function fh({open:e,isPending:t,onUpload:i,onClose:n}){let[r,s]=(0,c.useState)([]),[o,l]=(0,c.useState)(!1),a=(0,c.useRef)(null),d=r.filter(e=>e.size>104857600),u=(0,c.useCallback)(e=>{let t=Array.from(e);s(e=>{let i=new Set(e.map(e=>e.name));return[...e,...t.filter(e=>!i.has(e.name))]})},[]),x=(0,c.useCallback)(e=>{s(t=>t.filter(t=>t.name!==e))},[]),v=(0,c.useCallback)(e=>{e.preventDefault(),l(!1),e.dataTransfer.files.length&&u(e.dataTransfer.files)},[u]),y=(0,c.useCallback)(()=>{r.length>0&&0===d.length&&i(r)},[r,d,i]),b=(0,c.useCallback)(()=>{t||(s([]),n())},[t,n]);return(0,h.jsxs)(M.Z,{open:e,onClose:b,maxWidth:"sm",fullWidth:!0,children:[h.jsx(Z.Z,{children:"Upload Files"}),(0,h.jsxs)(A.Z,{children:[(0,h.jsxs)(f.Z,{onDragOver:e=>{e.preventDefault(),l(!0)},onDragLeave:()=>l(!1),onDrop:v,onClick:()=>a.current?.click(),sx:{border:"2px dashed",borderColor:o?"primary.main":"divider",borderRadius:2,p:4,textAlign:"center",cursor:"pointer",bgcolor:o?"action.hover":"transparent",transition:"all 0.2s","&:hover":{borderColor:"primary.main",bgcolor:"action.hover"}},children:[h.jsx(fl.Z,{sx:{fontSize:48,color:"text.secondary",mb:1}}),h.jsx(w.Z,{variant:"body1",color:"text.secondary",children:"Drag & drop files here, or click to browse"}),(0,h.jsxs)(w.Z,{variant:"caption",color:"text.secondary",children:["Max ",fa(104857600)," per file"]})]}),h.jsx("input",{ref:a,type:"file",multiple:!0,hidden:!0,onChange:e=>{e.target.files?.length&&(u(e.target.files),e.target.value="")}}),r.length>0&&h.jsx(en.Z,{dense:!0,sx:{mt:2},children:r.map(e=>(0,h.jsxs)(er.ZP,{secondaryAction:h.jsx(m.Z,{edge:"end",size:"small",onClick:()=>x(e.name),disabled:t,children:h.jsx(E.Z,{fontSize:"small"})}),children:[h.jsx(C.Z,{children:h.jsx(iv.Z,{})}),h.jsx(j.Z,{primary:e.name,secondary:fa(e.size),primaryTypographyProps:{noWrap:!0,color:e.size>104857600?"error":"text.primary"}})]},e.name))}),d.length>0&&h.jsx(g.Z,{severity:"error",sx:{mt:1},children:1===d.length?`"${d[0].name}" exceeds the ${fa(104857600)} limit`:`${d.length} files exceed the ${fa(104857600)} limit`}),t&&h.jsx(Q.Z,{sx:{mt:2}})]}),(0,h.jsxs)(T.Z,{children:[h.jsx(p.Z,{onClick:b,disabled:t,children:"Cancel"}),(0,h.jsxs)(p.Z,{onClick:y,variant:"contained",startIcon:h.jsx(fl.Z,{}),disabled:t||0===r.length||d.length>0,children:["Upload ",r.length>0?`(${r.length})`:""]})]})]})}function fc({serverName:e}){let[t,i]=(0,c.useState)("/"),[n,r]=(0,c.useState)(""),[s,o]=(0,c.useState)({open:!1,message:"",severity:"info"}),[l,a]=(0,c.useState)(null),[d,u]=(0,c.useState)(null),[f,p]=(0,c.useState)(null),[m,x]=(0,c.useState)(null),[w,k]=(0,c.useState)(null),[S,C]=(0,c.useState)(null),[j,M]=(0,c.useState)(!1),{data:Z,isLoading:A,error:T,refetch:O}=function(e,t="/"){return(0,tK.a)({queryKey:["servers",e,"files",t],queryFn:()=>{let i=new URLSearchParams({path:t});return(0,tG.SC)(`/api/servers/${encodeURIComponent(e)}/files?${i}`)},enabled:!!e})}(e,t),D=function(e){let t=(0,tU.NL)();return(0,t_.D)({mutationFn:({path:t})=>{let i=new URLSearchParams({path:t});return(0,tG.SC)(`/api/servers/${encodeURIComponent(e)}/files?${i}`,{method:"DELETE"})},onSuccess:()=>{t.invalidateQueries({queryKey:["servers",e,"files"]})}})}(e),R=function(e){let t=(0,tU.NL)();return(0,t_.D)({mutationFn:({path:t})=>{let i=new URLSearchParams({path:t});return(0,tG.SC)(`/api/servers/${encodeURIComponent(e)}/files/mkdir?${i}`,{method:"POST"})},onSuccess:()=>{t.invalidateQueries({queryKey:["servers",e,"files"]})}})}(e),P=function(e){let t=(0,tU.NL)();return(0,t_.D)({mutationFn:({oldPath:t,newPath:i})=>(0,tG.SC)(`/api/servers/${encodeURIComponent(e)}/files/rename`,{method:"POST",body:JSON.stringify({oldPath:t,newPath:i})}),onSuccess:()=>{t.invalidateQueries({queryKey:["servers",e,"files"]})}})}(e),L=function(e){let t=(0,tU.NL)();return(0,t_.D)({mutationFn:async({path:t,files:i})=>{let n=new FormData;for(let e of i)n.append("files",e);let r=new URLSearchParams({path:t}),s=await fetch(`/api/servers/${encodeURIComponent(e)}/files/upload?${r}`,{method:"POST",body:n});if(!s.ok){let e=await s.json().catch(()=>({error:"UnknownError",message:s.statusText})),t=Error(e.message);throw t.statusCode=s.status,t.code=e.error,t}return s.json()},onSuccess:()=>{t.invalidateQueries({queryKey:["servers",e,"files"]})}})}(e),I=(0,c.useCallback)((e,t="success")=>{o({open:!0,message:e,severity:t})},[]),E=(0,c.useCallback)(e=>{i(e),r("")},[]),B=(0,c.useCallback)(e=>{let i="/"===t?`/${e}`:`${t}/${e}`;R.mutate({path:i},{onSuccess:()=>I(`Folder "${e}" created`),onError:e=>I(e.message,"error")})},[t,R,I]),N=(0,c.useCallback)((i,n)=>{switch(i){case"delete":a(n);break;case"rename":u(n);break;case"download":!function(e,t){let i=new URLSearchParams({path:t}),n=`/api/servers/${encodeURIComponent(e)}/files/download?${i}`,r=document.createElement("a");r.href=n,r.download="",document.body.appendChild(r),r.click(),document.body.removeChild(r)}(e,"/"===t?`/${n.name}`:`${t}/${n.name}`);break;case"open":{let e="/"===t?`/${n.name}`:`${t}/${n.name}`;if("/"===t&&"server.properties"===n.name)C(e);else{let i="/"===t?function(e){switch(e){case"whitelist.json":return"whitelist";case"ops.json":return"ops";case"banned-players.json":return"bans";default:return null}}(n.name):null;i?(x(i),k(e)):p(e)}}}},[t,e]),z=(0,c.useCallback)(e=>{L.mutate({path:t,files:e},{onSuccess:e=>{I(`${e.files.length} file(s) uploaded`),M(!1)},onError:e=>{I(e.message,"error")}})},[t,L,I]),W=(0,c.useCallback)(()=>{if(!l)return;let e="/"===t?`/${l.name}`:`${t}/${l.name}`;D.mutate({path:e},{onSuccess:()=>{I(`"${l.name}" deleted`),a(null)},onError:e=>{I(e.message,"error"),a(null)}})},[l,t,D,I]),F=(0,c.useCallback)(e=>{if(!d)return;let i="/"===t?`/${d.name}`:`${t}/${d.name}`,n="/"===t?`/${e}`:`${t}/${e}`;P.mutate({oldPath:i,newPath:n},{onSuccess:()=>{I(`Renamed to "${e}"`),u(null)},onError:e=>{I(e.message,"error"),u(null)}})},[d,t,P,I]),V=(0,c.useMemo)(()=>(Z?.files||[]).map(e=>e.name),[Z?.files]);return A?h.jsx(y.Z,{sx:{borderRadius:3},children:(0,h.jsxs)(b.Z,{children:[h.jsx(v.Z,{variant:"text",width:300,height:32,sx:{mb:2}}),h.jsx(v.Z,{variant:"rectangular",height:40,sx:{mb:2}}),[1,2,3,4,5].map(e=>h.jsx(v.Z,{variant:"rectangular",height:48,sx:{mb:.5}},e))]})}):T?(0,h.jsxs)(g.Z,{severity:"error",sx:{borderRadius:3},children:["Failed to load files: ",T.message]}):S?h.jsx(fo,{serverName:e,onBack:()=>C(null)}):f?h.jsx(iO,{serverName:e,filePath:f,onBack:()=>p(null)}):m?h.jsx(iq,{serverName:e,editorType:m,filePath:w,onBack:()=>{x(null),k(null)},onSwitchToRaw:e=>{x(null),k(null),p(e)}}):(0,h.jsxs)(h.Fragment,{children:[h.jsx(y.Z,{sx:{borderRadius:3},children:(0,h.jsxs)(b.Z,{children:[h.jsx(it,{path:t,onNavigate:E}),h.jsx(ih,{searchQuery:n,onSearchChange:r,onCreateFolder:B,onUpload:()=>M(!0),onRefresh:()=>O(),existingNames:V,disabled:R.isPending}),h.jsx(iA,{files:Z?.files||[],currentPath:t,onNavigate:E,onFileAction:N,searchQuery:n})]})}),h.jsx(iP,{target:l,isPending:D.isPending,onConfirm:W,onClose:()=>a(null)}),h.jsx(iB,{target:d,existingNames:V,isPending:P.isPending,onConfirm:F,onClose:()=>u(null)}),h.jsx(fh,{open:j,isPending:L.isPending,onUpload:z,onClose:()=>M(!1)}),h.jsx(eu.Z,{open:s.open,autoHideDuration:4e3,onClose:()=>o(e=>({...e,open:!1})),anchorOrigin:{vertical:"bottom",horizontal:"center"},children:h.jsx(g.Z,{onClose:()=>o(e=>({...e,open:!1})),severity:s.severity,variant:"filled",children:s.message})})]})}let fd=["Overview","Activity","Mods","Files","Backups","Access","Options"];function fu(e){return e.replace(/\x1b\[\?[\d;]*[a-zA-Z]/g,"").replace(/\x1b\[[0-9;]*[a-zA-Z]/g,"").replace(/\x1b=/g,"").replace(/\[\?[\d;]*[a-zA-Z]/g,"").replace(/\[[0-9;]*[a-zA-Z]/g,"").replace(/\[m/g,"").replace(/>\.\.\.\.\r?/g,"").replace(/\r/g,"").trim()}function ff({server:e,onSendCommand:t}){let[i,n]=(0,c.useState)("Overview"),[r,s]=(0,c.useState)(""),[o,l]=(0,c.useState)(!0),[a,d]=(0,c.useState)(!1),u=(0,c.useRef)(null),g=(0,$.Z)(),x=(0,q.Z)(g.breakpoints.down("sm")),{logs:v,isConnected:k}=(0,et.Y)({serverName:e.name}),S=(0,c.useMemo)(()=>v.filter(e=>!e.includes("RCON Listener")&&!e.includes("RCON Client")&&!e.includes("RconClient")),[v]),C=async()=>{r.trim()&&t&&(await t(r.trim()),s(""))},j=e.stats?.cpuPercent??0;e.stats?.memoryUsage&&e.stats.memoryUsage,function(e){if(!e)return;let t=e.match(/^(\d+)\s*(M|G)?$/i);if(t)parseInt(t[1],10),(t[2]||"M").toUpperCase()}(e.memory);let Z=e.stats?.memoryPercent??0;return(0,h.jsxs)(f.Z,{children:[h.jsx(f.Z,{sx:{display:"flex",flexWrap:"wrap",gap:.5,mb:3},children:fd.map(e=>h.jsx(p.Z,{onClick:()=>n(e),sx:{px:2,py:1,borderRadius:5,fontSize:14,fontWeight:500,textTransform:"none",bgcolor:i===e?"primary.main":"transparent",color:i===e?"#0a0e14":"text.secondary","&:hover":{bgcolor:i===e?"primary.main":(0,R.Fq)("#1bd96a",.1)}},children:e},e))}),(0,h.jsxs)(f.Z,{sx:{display:"grid",gridTemplateColumns:{xs:"1fr",sm:"repeat(3, 1fr)"},gap:2,mb:2.5},children:[h.jsx(ee,{value:`${j.toFixed(2)}%`,unit:"/ 100%",label:"CPU usage",icon:h.jsx(U.Z,{sx:{fontSize:28}}),progress:j,progressMax:100,color:"#1bd96a"}),h.jsx(ee,{value:`${Z.toFixed(2)}%`,unit:"/ 100%",label:"Memory usage",icon:h.jsx(_.Z,{sx:{fontSize:28}}),progress:Z,progressMax:100,color:"#1bd96a"}),h.jsx(ee,{value:e.worldSize||"0 B",unit:"/ 10 GB",label:"World size",icon:h.jsx(G.Z,{sx:{fontSize:28}}),progress:function(e){if(!e)return 0;let t=e.match(/^([\d.]+)\s*(B|KB|MB|MiB|GB|GiB)?$/i);if(!t)return 0;let i=parseFloat(t[1]);switch((t[2]||"B").toUpperCase()){case"GB":case"GIB":return 1024*i;case"MB":case"MIB":return i;case"KB":return i/1024;default:return i/1048576}}(e.worldSize),progressMax:10240,color:"#1bd96a"})]}),"Overview"===i&&(0,h.jsxs)(y.Z,{sx:{bgcolor:"background.paper",borderRadius:3,border:"1px solid",borderColor:"divider",overflow:"hidden"},children:[(0,h.jsxs)(f.Z,{sx:{px:3,py:2,borderBottom:"1px solid",borderColor:"divider",display:"flex",alignItems:"center",gap:1.25},children:[h.jsx(w.Z,{variant:"h6",sx:{fontWeight:700,color:"text.primary"},children:"Console"}),h.jsx(f.Z,{sx:{width:10,height:10,borderRadius:"50%",bgcolor:k?"primary.main":"error.main",boxShadow:k?"0 0 8px rgba(27, 217, 106, 0.4)":"0 0 8px rgba(239, 68, 68, 0.4)"}})]}),(0,h.jsxs)(f.Z,{sx:{position:"relative"},children:[h.jsx(f.Z,{ref:u,onScroll:()=>{if(!u.current)return;let{scrollTop:e,scrollHeight:t,clientHeight:i}=u.current;l(t-e-i<30)},sx:{height:{xs:240,sm:360},overflowY:"auto",px:2.5,py:2,fontSize:13,lineHeight:1.85,color:"#b4b6c4",bgcolor:"#0a0a0a",scrollbarWidth:"thin",scrollbarColor:"#3a3d4e #0a0a0a","&::-webkit-scrollbar":{width:8},"&::-webkit-scrollbar-track":{bgcolor:"#0a0a0a"},"&::-webkit-scrollbar-thumb":{bgcolor:"#3a3d4e",borderRadius:4}},children:0===S.length?h.jsx(w.Z,{sx:{color:"text.secondary",textAlign:"center",py:8},children:"Waiting for logs..."}):S.map((e,t)=>{let i=function(e){let t=fu(e).match(/\[(\d{2}:\d{2}:\d{2})\]\s*\[([^/]+)\/(\w+)\]:\s*(.+)/);return t?{time:t[1],thread:t[2],level:t[3]||"INFO",msg:t[4]}:null}(e);return i?(0,h.jsxs)(f.Z,{sx:{display:"flex",gap:0,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:[(0,h.jsxs)(f.Z,{component:"span",sx:{color:"#4a4d60"},children:["[",i.time,"]"]}),(0,h.jsxs)(f.Z,{component:"span",sx:{color:"#4a4d60"},children:["\xa0[",i.thread,"/",h.jsx(f.Z,{component:"span",sx:{color:"WARN"===i.level?"#e8a848":"#6b6e80"},children:i.level}),"]:\xa0"]}),h.jsx(f.Z,{component:"span",sx:{color:"WARN"===i.level?"#c4a45a":"#b4b6c4"},children:i.msg})]},t):h.jsx(f.Z,{sx:{color:"#b4b6c4"},children:fu(e)},t)})}),h.jsx(m.Z,{onClick:()=>d(!0),sx:{position:"absolute",top:12,right:12,width:36,height:36,borderRadius:2,bgcolor:"#282a3a",border:"1px solid #3a3d4e",color:"#8b8da0","&:hover":{bgcolor:"#313440"}},children:h.jsx(J.Z,{sx:{fontSize:18}})}),!o&&h.jsx(m.Z,{onClick:()=>{u.current&&u.current.scrollTo({top:u.current.scrollHeight,behavior:"smooth"})},sx:{position:"absolute",bottom:12,right:12,width:36,height:36,borderRadius:2,bgcolor:"#282a3a",border:"1px solid #3a3d4e",color:"#8b8da0","&:hover":{bgcolor:"#313440"}},children:h.jsx(X.Z,{sx:{fontSize:18}})})]}),h.jsx(f.Z,{sx:{px:2.5,py:1.5,borderTop:"1px solid",borderColor:"divider"},children:h.jsx(O.Z,{fullWidth:!0,size:"small",placeholder:"Send a command",value:r,onChange:e=>s(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),C())},disabled:!k,InputProps:{startAdornment:h.jsx(V.Z,{position:"start",children:h.jsx(Y.Z,{sx:{fontSize:16,color:"#999"}})}),sx:{bgcolor:"#13141c",borderRadius:2,fontSize:14,"& .MuiOutlinedInput-notchedOutline":{borderColor:"#2a2d3e"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"#3a3d4e"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main"}}}})})]}),"Overview"===i&&(0,h.jsxs)(D.ZP,{container:!0,spacing:3,sx:{mt:1},children:[h.jsx(D.ZP,{item:!0,xs:12,md:6,children:h.jsx(y.Z,{sx:{borderRadius:3},children:(0,h.jsxs)(b.Z,{children:[h.jsx(w.Z,{variant:"h6",gutterBottom:!0,fontWeight:600,children:"Server Information"}),h.jsx(H.Z,{sx:{mb:2}}),h.jsx(fp,{label:"Name",value:e.name}),h.jsx(fp,{label:"Container",value:e.container}),h.jsx(fp,{label:"Hostname",value:e.hostname?h.jsx(tQ.h,{hostname:e.hostname,color:"text.primary"}):void 0}),h.jsx(fp,{label:"Type",value:e.type}),h.jsx(fp,{label:"Version",value:e.version}),h.jsx(fp,{label:"Memory",value:e.memory}),h.jsx(fp,{label:"Uptime",value:e.uptime||function(e){if(!e||e<0)return"0s";let t=Math.floor(e/3600),i=Math.floor(e%3600/60),n=e%60;return t>0?`${t}h ${i}m`:i>0?`${i}m ${n}s`:`${n}s`}(e.uptimeSeconds)})]})})}),h.jsx(D.ZP,{item:!0,xs:12,md:6,children:h.jsx(y.Z,{sx:{borderRadius:3},children:(0,h.jsxs)(b.Z,{children:[h.jsx(w.Z,{variant:"h6",gutterBottom:!0,fontWeight:600,children:"Players"}),h.jsx(H.Z,{sx:{mb:2}}),e.players?(0,h.jsxs)(h.Fragment,{children:[h.jsx(fp,{label:"Online",value:`${e.players.online} / ${e.players.max}`}),e.players.players&&e.players.players.length>0&&(0,h.jsxs)(h.Fragment,{children:[h.jsx(w.Z,{variant:"body2",color:"text.secondary",sx:{mt:2,mb:1},children:"Online Players"}),h.jsx(f.Z,{sx:{display:"flex",flexWrap:"wrap",gap:1},children:e.players.players.map(e=>h.jsx(F.Z,{label:e,size:"small"},e))})]})]}):h.jsx(w.Z,{variant:"body2",color:"text.secondary",children:"Player information unavailable"})]})})}),h.jsx(D.ZP,{item:!0,xs:12,md:6,children:h.jsx(t1,{serverName:e.name,hostname:e.hostname})})]}),"Activity"===i&&h.jsx(f.Z,{sx:{mt:3},children:h.jsx(y.Z,{sx:{borderRadius:3},children:(0,h.jsxs)(b.Z,{children:[h.jsx(w.Z,{variant:"h6",gutterBottom:!0,fontWeight:600,children:"Server Activity"}),h.jsx(H.Z,{sx:{mb:2}}),h.jsx(ed,{serverName:e.name})]})})}),"Mods"===i&&h.jsx(f.Z,{sx:{mt:3},children:h.jsx(t4,{serverName:e.name})}),"Files"===i&&h.jsx(f.Z,{sx:{mt:3},children:h.jsx(fc,{serverName:e.name})}),"Backups"===i&&h.jsx(f.Z,{sx:{mt:3},children:h.jsx(w.Z,{variant:"body1",color:"text.secondary",children:"Backup management coming soon"})}),"Access"===i&&h.jsx(f.Z,{sx:{mt:3},children:h.jsx(tX,{serverId:e.name})}),"Options"===i&&h.jsx(f.Z,{sx:{mt:3},children:h.jsx(e$,{serverName:e.name,isRunning:"running"===e.status})}),"Overview"===i&&(0,h.jsxs)(M.Z,{open:a,onClose:()=>d(!1),maxWidth:"xl",fullWidth:!0,fullScreen:x,PaperProps:{sx:{height:x?"100vh":"90vh",bgcolor:"background.paper"}},children:[(0,h.jsxs)(f.Z,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",p:2,borderBottom:1,borderColor:"divider"},children:[(0,h.jsxs)(w.Z,{variant:"h6",sx:{fontFamily:'"Minecraft", sans-serif',fontWeight:400,letterSpacing:"0.05em"},children:["Console - ",e.name]}),h.jsx(m.Z,{onClick:()=>d(!1),"aria-label":"Close console",children:h.jsx(K.Z,{})})]}),h.jsx(A.Z,{sx:{p:0,display:"flex",flexDirection:"column"},children:h.jsx(ei.K,{serverName:e.name})})]})]})}function fp({label:e,value:t}){return t?(0,h.jsxs)(f.Z,{sx:{display:"flex",justifyContent:"space-between",py:1},children:[h.jsx(w.Z,{variant:"body2",color:"text.secondary",children:e}),h.jsx(w.Z,{variant:"body2",component:"div",sx:{fontWeight:500},children:t})]}):null}var fm=i(47893);function fg(){return(0,h.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[h.jsx("circle",{cx:"12",cy:"12",r:"10"}),h.jsx("line",{x1:"8",y1:"12",x2:"16",y2:"12"})]})}function fx(){return(0,h.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[h.jsx("path",{d:"M21 2v6h-6"}),h.jsx("path",{d:"M3 12a9 9 0 0115.36-6.36L21 8"}),h.jsx("path",{d:"M3 22v-6h6"}),h.jsx("path",{d:"M21 12a9 9 0 01-15.36 6.36L3 16"})]})}function fv(){let e=(0,d.useParams)(),t=(0,u.x)(),i=decodeURIComponent(e.name),{data:n,isLoading:r,error:s}=(0,eg.Hy)(i),{status:o,health:l}=function(e){let{serverName:t,onStatusChange:i,enabled:n=!0,reconnectInterval:r=3e3}=e,[s,o]=(0,c.useState)(null),[l,a]=(0,c.useState)(null),h=(0,c.useCallback)(e=>{if("server-status"===e.type){let t=e.data.status,n=e.data.health;o(t),a(n),i?.(t,n)}},[i]),{isConnected:d,reconnect:u,retryCount:f}=(0,fm.D)({url:`/api/sse/servers/${encodeURIComponent(t)}/status`,onMessage:h,enabled:n,reconnectInterval:r});return{status:s,health:l,isConnected:d,reconnect:u,retryCount:f}}({serverName:i,enabled:!!i}),[a,F]=(0,c.useState)(null),[V,H]=(0,c.useState)(!1),[$,q]=(0,c.useState)(""),K=(0,eg.jM)(),U=(0,eg.Aw)(),_=(0,eg._I)(),G=(0,eg.Hq)(),J=async()=>{try{await K.mutateAsync(i)}catch(e){console.error("Failed to start server:",e)}},X=async()=>{try{await U.mutateAsync(i)}catch(e){console.error("Failed to stop server:",e)}},Y=async()=>{try{await _.mutateAsync(i)}catch(e){console.error("Failed to restart server:",e)}},Q=async e=>{try{await fetch(`/api/servers/${encodeURIComponent(i)}/exec`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({command:e})})}catch(e){console.error("Failed to send command:",e)}},ee=o||n?.server.status,et=K.isPending||U.isPending||_.isPending,ei=n?.server;return(0,h.jsxs)(h.Fragment,{children:[s&&(0,h.jsxs)(g.Z,{severity:"error",sx:{mb:3},children:["Failed to load server: ",s.message]}),K.isError&&(0,h.jsxs)(g.Z,{severity:"error",sx:{mb:3},children:["Failed to start server: ",K.error?.message]}),U.isError&&(0,h.jsxs)(g.Z,{severity:"error",sx:{mb:3},children:["Failed to stop server: ",U.error?.message]}),_.isError&&(0,h.jsxs)(g.Z,{severity:"error",sx:{mb:3},children:["Failed to restart server: ",_.error?.message]}),G.isError&&(0,h.jsxs)(g.Z,{severity:"error",sx:{mb:3},children:["Failed to delete server: ",G.error?.message]}),r?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(f.Z,{sx:{display:"flex",alignItems:"center",gap:2,mb:2.5},children:[h.jsx(v.Z,{variant:"rounded",width:64,height:64,sx:{borderRadius:3,flexShrink:0}}),(0,h.jsxs)(f.Z,{sx:{flex:1},children:[h.jsx(v.Z,{variant:"text",width:80,height:18,sx:{mb:.5}}),h.jsx(v.Z,{variant:"text",width:"40%",height:40}),(0,h.jsxs)(f.Z,{sx:{display:"flex",gap:2,mt:.75},children:[h.jsx(v.Z,{variant:"text",width:100}),h.jsx(v.Z,{variant:"text",width:60}),h.jsx(v.Z,{variant:"text",width:140}),h.jsx(v.Z,{variant:"text",width:50})]})]}),(0,h.jsxs)(f.Z,{sx:{display:"flex",gap:1,flexShrink:0},children:[h.jsx(v.Z,{variant:"rounded",width:90,height:40,sx:{borderRadius:2}}),h.jsx(v.Z,{variant:"rounded",width:36,height:36,sx:{borderRadius:2}})]})]}),h.jsx(f.Z,{sx:{display:"flex",gap:.5,mb:3},children:[80,70,65,50,65,65].map((e,t)=>h.jsx(v.Z,{variant:"rounded",width:e,height:36,sx:{borderRadius:5}},t))}),h.jsx(f.Z,{sx:{display:"grid",gridTemplateColumns:{xs:"1fr",sm:"repeat(3, 1fr)"},gap:2,mb:2.5},children:[0,1,2].map(e=>h.jsx(y.Z,{sx:{borderRadius:3},children:(0,h.jsxs)(b.Z,{children:[(0,h.jsxs)(f.Z,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:1.5},children:[h.jsx(v.Z,{variant:"text",width:"50%"}),h.jsx(v.Z,{variant:"circular",width:28,height:28})]}),h.jsx(v.Z,{variant:"text",width:"60%",height:36}),h.jsx(v.Z,{variant:"rounded",width:"100%",height:6,sx:{borderRadius:3,mt:1}})]})},e))}),(0,h.jsxs)(y.Z,{sx:{borderRadius:3,border:"1px solid",borderColor:"divider"},children:[(0,h.jsxs)(f.Z,{sx:{px:3,py:2,borderBottom:"1px solid",borderColor:"divider",display:"flex",alignItems:"center",gap:1.25},children:[h.jsx(v.Z,{variant:"text",width:80,height:28}),h.jsx(v.Z,{variant:"circular",width:10,height:10})]}),h.jsx(v.Z,{variant:"rectangular",height:360,sx:{bgcolor:"#0a0a0a"}}),h.jsx(f.Z,{sx:{px:2.5,py:1.5,borderTop:"1px solid",borderColor:"divider"},children:h.jsx(v.Z,{variant:"rounded",width:"100%",height:40,sx:{borderRadius:2}})})]}),(0,h.jsxs)(D.ZP,{container:!0,spacing:3,sx:{mt:1},children:[h.jsx(D.ZP,{item:!0,xs:12,md:6,children:h.jsx(y.Z,{sx:{borderRadius:3},children:(0,h.jsxs)(b.Z,{children:[h.jsx(v.Z,{variant:"text",width:"40%",height:28,sx:{mb:1}}),h.jsx(v.Z,{variant:"rectangular",height:1,sx:{mb:2}}),[0,1,2,3,4,5,6].map(e=>(0,h.jsxs)(f.Z,{sx:{display:"flex",justifyContent:"space-between",py:1},children:[h.jsx(v.Z,{variant:"text",width:"30%"}),h.jsx(v.Z,{variant:"text",width:"40%"})]},e))]})})}),h.jsx(D.ZP,{item:!0,xs:12,md:6,children:h.jsx(y.Z,{sx:{borderRadius:3},children:(0,h.jsxs)(b.Z,{children:[h.jsx(v.Z,{variant:"text",width:"30%",height:28,sx:{mb:1}}),h.jsx(v.Z,{variant:"rectangular",height:1,sx:{mb:2}}),(0,h.jsxs)(f.Z,{sx:{display:"flex",justifyContent:"space-between",py:1},children:[h.jsx(v.Z,{variant:"text",width:"25%"}),h.jsx(v.Z,{variant:"text",width:"20%"})]})]})})})]})]}):ei?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(f.Z,{sx:{display:"flex",alignItems:"center",gap:2,mb:2.5},children:[h.jsx(f.Z,{sx:{width:64,height:64,borderRadius:3,overflow:"hidden",bgcolor:"background.paper",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,border:"1px solid",borderColor:"divider",fontSize:36},children:function(e){if(!e)return"\uD83C\uDFAE";let t=e.toUpperCase();return["PAPER","SPIGOT","BUKKIT","PURPUR"].includes(t)?"\uD83D\uDD0C":["FORGE","NEOFORGE","FABRIC","QUILT"].includes(t)?"\uD83D\uDD27":"\uD83C\uDFAE"}(ei.type)}),(0,h.jsxs)(f.Z,{sx:{flex:1},children:[(0,h.jsxs)(w.Z,{onClick:()=>t.push("/servers"),sx:{fontSize:12,color:"primary.main",cursor:"pointer",mb:.25,display:"flex",alignItems:"center",gap:.5,"&:hover":{textDecoration:"underline"}},children:[h.jsx(P.Z,{sx:{fontSize:14}})," All servers"]}),h.jsx(w.Z,{variant:"h4",component:"h1",sx:{fontFamily:'"Minecraft", sans-serif',fontWeight:400,color:"text.primary",letterSpacing:"0.5px",m:0,textTransform:"uppercase"},children:i}),(0,h.jsxs)(f.Z,{sx:{display:"flex",alignItems:"center",gap:0,mt:.75,flexWrap:"wrap",fontSize:13,color:"text.secondary"},children:[ei.version&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(f.Z,{sx:{display:"flex",alignItems:"center",gap:.5},children:[h.jsx(B.Z,{sx:{fontSize:14}}),"Minecraft ",ei.version]}),h.jsx(f.Z,{component:"span",sx:{mx:1.25,color:"#3a3d4e"},children:"|"})]}),ei.type&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(f.Z,{sx:{display:"flex",alignItems:"center",gap:.5},children:[h.jsx(N.Z,{sx:{fontSize:14}}),ei.type]}),h.jsx(f.Z,{component:"span",sx:{mx:1.25,color:"#3a3d4e"},children:"|"})]}),ei.hostname&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(f.Z,{sx:{display:"flex",alignItems:"center",gap:.5},children:[h.jsx(z.Z,{sx:{fontSize:14}}),h.jsx(tQ.h,{hostname:ei.hostname,fontSize:13})]}),h.jsx(f.Z,{component:"span",sx:{mx:1.25,color:"#3a3d4e"},children:"|"})]}),(0,h.jsxs)(f.Z,{sx:{display:"flex",alignItems:"center",gap:.5},children:[h.jsx(W.Z,{sx:{fontSize:14}}),ei.uptime||function(e){if(!e||e<0)return"0s";let t=Math.floor(e/3600),i=Math.floor(e%3600/60),n=e%60;return t>0?`${t}h ${i}m`:i>0?`${i}m ${n}s`:`${n}s`}(ei.uptimeSeconds)||"0s"]})]})]}),(0,h.jsxs)(f.Z,{sx:{display:"flex",alignItems:"center",gap:1.25,flexShrink:0},children:[("stopped"===ee||"exited"===ee||"not_created"===ee)&&h.jsx(p.Z,{variant:"contained",color:"success",startIcon:et?h.jsx(x.Z,{size:16,color:"inherit"}):h.jsx(L.Z,{}),onClick:J,disabled:et,sx:{px:2,py:1,borderRadius:2,fontSize:14,fontWeight:600},children:"Start"}),"running"===ee&&(0,h.jsxs)(h.Fragment,{children:[h.jsx(p.Z,{variant:"outlined",startIcon:et?h.jsx(x.Z,{size:16}):h.jsx(fg,{}),onClick:X,disabled:et,sx:{px:2,py:1,borderRadius:2,fontSize:14,fontWeight:500,borderColor:"divider",color:"text.secondary","&:hover":{borderColor:"text.secondary",bgcolor:(0,R.Fq)("#fff",.05)}},children:"Stop"}),h.jsx(p.Z,{variant:"contained",startIcon:et?h.jsx(x.Z,{size:16,color:"inherit"}):h.jsx(fx,{}),onClick:Y,disabled:et,sx:{px:2,py:1,borderRadius:2,fontSize:14,fontWeight:600,bgcolor:"primary.main",color:"#0a0e14","&:hover":{bgcolor:"primary.dark"}},children:"Restart"})]}),h.jsx(m.Z,{onClick:e=>F(e.currentTarget),sx:{width:36,height:36,borderRadius:2,border:"1px solid",borderColor:"divider",color:"text.secondary"},children:h.jsx(I.Z,{sx:{fontSize:18}})}),h.jsx(k.Z,{anchorEl:a,open:!!a,onClose:()=>F(null),children:(0,h.jsxs)(S.Z,{onClick:()=>{F(null),H(!0),q("")},sx:{color:"error.main"},children:[h.jsx(C.Z,{children:h.jsx(E.Z,{fontSize:"small",sx:{color:"error.main"}})}),h.jsx(j.Z,{children:"Delete Server"})]})})]})]}),h.jsx(ff,{server:ei,onSendCommand:Q})]}):h.jsx(g.Z,{severity:"warning",children:"Server not found"}),(0,h.jsxs)(M.Z,{open:V,onClose:()=>{H(!1),q("")},maxWidth:"sm",fullWidth:!0,children:[h.jsx(Z.Z,{children:"Delete Server"}),(0,h.jsxs)(A.Z,{children:[(0,h.jsxs)(w.Z,{sx:{mb:2},children:["This action cannot be undone. Type ",h.jsx("strong",{children:i})," to confirm deletion."]}),h.jsx(O.Z,{label:"Server name",value:$,onChange:e=>q(e.target.value),fullWidth:!0,autoFocus:!0})]}),(0,h.jsxs)(T.Z,{sx:{px:3,pb:2},children:[h.jsx(p.Z,{onClick:()=>{H(!1),q("")},children:"Cancel"}),h.jsx(p.Z,{variant:"contained",color:"error",onClick:()=>{$===i&&G.mutate({name:i,force:!0},{onSuccess:()=>{t.push("/servers")}})},disabled:$!==i||G.isPending,startIcon:G.isPending?h.jsx(x.Z,{size:16}):null,children:G.isPending?"Deleting...":"Delete"})]})]})]})}},71438:(e,t,i)=>{"use strict";i.d(t,{I:()=>o});var n=i(58120),r=i(48787),s=i(39928);function o({action:e,size:t="small"}){let i=s.Lu[e]||"default",o=s.n3[e]||e;return n.jsx(r.Z,{label:o,color:i,size:t,variant:"filled",sx:{fontWeight:600,fontSize:"small"===t?"0.7rem":"0.8rem"}})}},55049:(e,t,i)=>{"use strict";i.d(t,{c:()=>l});var n=i(58120),r=i(48787),s=i(56846),o=i(72690);function l({status:e,size:t="small"}){return n.jsx(r.Z,{icon:"success"===e?n.jsx(s.Z,{}):n.jsx(o.Z,{}),label:"success"===e?"OK":"Error",color:"success"===e?"success":"error",size:t,variant:"outlined",sx:{fontWeight:500,fontSize:"small"===t?"0.7rem":"0.8rem"}})}},6418:(e,t,i)=>{"use strict";i.d(t,{K:()=>Z});var n=i(58120),r=i(36372),s=i(20393),o=i.n(s),l=i(89352),a=i(52329),h=i(6275),c=i(10257),d=i(46456),u=i(54365),f=i(2365),p=i(48787),m=i(14360),g=i(51430),x=i(23016),v=i(80336),y=i(79943),b=i(78150),w=i(73995),k=i(66831),S=i(50423);let C=[{label:"say",template:"say "},{label:"give",template:"give "},{label:"tp",template:"tp "},{label:"gamemode",template:"gamemode "}],j=new(o())({fg:"#aaa",bg:"#000",newline:!1,escapeXML:!0,colors:{0:"#000000",1:"#cc0000",2:"#4e9a06",3:"#c4a000",4:"#3465a4",5:"#75507b",6:"#06989a",7:"#d3d7cf",8:"#555753",9:"#ef2929",10:"#8ae234",11:"#fce94f",12:"#729fcf",13:"#ad7fa8",14:"#34e2e2",15:"#eeeeec"}}),M=(0,r.memo)(function({log:e}){let t=(0,r.useMemo)(()=>(function(e){let t=e.replace(/\x1b\[\?[\d;]*[a-zA-Z]/g,"").replace(/\x1b\[[0-9;]*[KJH]/g,"").replace(/\x1b=/g,"").replace(/\[\?[\d;]*[a-zA-Z]/g,"").replace(/\[[0-9;]*[KJH]/g,"").replace(/\[m/g,"").replace(/\[(\d+)m/g,"\x1b[$1m").replace(/>\.\.\.\.\r?/g,"").replace(/\r/g,"");return j.toHtml(t)})(e),[e]);return n.jsx(l.Z,{sx:{py:.25,whiteSpace:"pre-wrap",wordBreak:"break-all","& span":{}},dangerouslySetInnerHTML:{__html:t}})});function Z({serverName:e}){let[t,i]=(0,r.useState)(""),[s,o]=(0,r.useState)([]),[j,Z]=(0,r.useState)(-1),[A,T]=(0,r.useState)("ALL"),[O,D]=(0,r.useState)(!0),[R,P]=(0,r.useState)(!0),[L,I]=(0,r.useState)(!1),E=(0,r.useRef)(null),B=(0,r.useRef)(null),{logs:N,isConnected:z,clearLogs:W,reconnect:F,retryCount:V}=(0,S.Y)({serverName:e}),H=(0,r.useMemo)(()=>{let e=N;return R&&(e=e.filter(e=>!e.includes("RCON Listener")&&!e.includes("RCON Client")&&!e.includes("RconClient"))),"ALL"!==A&&(e=e.filter(e=>(e.includes("/ERROR]")||e.includes("/ERROR:")?"ERROR":e.includes("/WARN]")||e.includes("/WARN:")?"WARN":(e.includes("/INFO]")||e.includes("/INFO:"),"INFO"))===A)),e},[N,A,R]),$=(0,r.useCallback)(async()=>{let n=t.trim();if(n&&!L){I(!0);try{o(e=>[...e,n]),Z(-1),await fetch(`/api/servers/${encodeURIComponent(e)}/exec`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({command:n})}),i("")}catch(e){console.error("Failed to execute command:",e)}finally{I(!1)}}},[t,e,L]),q=(0,r.useCallback)(e=>{if("Enter"===e.key)e.preventDefault(),$();else if("ArrowUp"===e.key){if(e.preventDefault(),0===s.length)return;let t=-1===j?s.length-1:Math.max(0,j-1);Z(t),i(s[t])}else if("ArrowDown"===e.key){if(e.preventDefault(),-1===j)return;let t=j+1;t>=s.length?(Z(-1),i("")):(Z(t),i(s[t]))}},[s,j,$]),K=(0,r.useCallback)(e=>{i(e),E.current?.focus()},[]),U=z?{text:"Connected",color:"success"}:V>0?{text:`Disconnected (Retry ${V})`,color:"warning"}:{text:"Disconnected",color:"error"};return(0,n.jsxs)(a.Z,{"data-testid":"server-console",sx:{display:"flex",flexDirection:"column",height:"100%",minHeight:400},children:[(0,n.jsxs)(l.Z,{sx:{display:"flex",flexDirection:{xs:"column",sm:"row"},alignItems:{xs:"flex-start",sm:"center"},justifyContent:"space-between",px:2,py:1,gap:1,borderBottom:1,borderColor:"divider"},children:[(0,n.jsxs)(x.Z,{direction:"row",spacing:1,alignItems:"center",children:[n.jsx(f.Z,{variant:"subtitle2",children:"Console"}),n.jsx(p.Z,{"data-testid":"connection-status",label:U.text,color:U.color,size:"small"})]}),(0,n.jsxs)(x.Z,{direction:"row",spacing:1,alignItems:"center",flexWrap:"wrap",useFlexGap:!0,children:[n.jsx(d.Z,{size:"small",variant:"outlined",children:["ALL","INFO","WARN","ERROR"].map(e=>n.jsx(c.Z,{onClick:()=>T(e),variant:A===e?"contained":"outlined",children:e},e))}),n.jsx(m.Z,{control:n.jsx(g.Z,{checked:O,onChange:e=>D(e.target.checked),size:"small",inputProps:{"aria-label":"Auto-scroll"}}),label:"Auto-scroll"}),n.jsx(m.Z,{control:n.jsx(g.Z,{checked:R,onChange:e=>P(e.target.checked),size:"small",inputProps:{"aria-label":"Hide RCON"}}),label:"Hide RCON"}),n.jsx(u.Z,{size:"small",onClick:W,"aria-label":"Clear logs",title:"Clear logs",children:n.jsx(w.Z,{})}),!z&&n.jsx(c.Z,{size:"small",startIcon:n.jsx(k.Z,{}),onClick:F,"aria-label":"Reconnect",children:"Reconnect"})]})]}),n.jsx(l.Z,{ref:B,sx:{flex:1,overflow:"auto",bgcolor:"#1a1a1a",p:1,fontSize:"0.85rem"},children:0===H.length?n.jsx(f.Z,{color:"text.secondary",sx:{textAlign:"center",py:4,color:"#666"},children:"Waiting for logs..."}):H.map((e,t)=>n.jsx(M,{log:e},t))}),n.jsx(v.Z,{}),n.jsx(l.Z,{sx:{px:2,py:1,bgcolor:"background.default"},children:(0,n.jsxs)(x.Z,{direction:"row",spacing:1,children:[n.jsx(f.Z,{variant:"caption",color:"text.secondary",sx:{alignSelf:"center"},children:"Quick:"}),C.map(e=>n.jsx(c.Z,{size:"small",variant:"outlined",onClick:()=>K(e.template),children:e.label},e.label))]})}),n.jsx(v.Z,{}),(0,n.jsxs)(l.Z,{sx:{display:"flex",p:1,gap:1},children:[n.jsx(h.Z,{inputRef:E,fullWidth:!0,size:"small",placeholder:"Enter command...",value:t,onChange:e=>i(e.target.value),onKeyDown:q,disabled:!z||L,InputProps:{}}),n.jsx(c.Z,{variant:"contained",onClick:$,disabled:!t.trim()||!z||L,startIcon:L?n.jsx(y.Z,{size:16}):n.jsx(b.Z,{}),"aria-label":"Send command",children:"Send"})]})]})}},15784:(e,t,i)=>{"use strict";i.d(t,{DM:()=>o,HZ:()=>a,VM:()=>l,hT:()=>s,oL:()=>h});var n=i(28872),r=i(43137);function s(e={},t){let i=function(e){let t=new URLSearchParams;e.action&&t.set("action",e.action),e.actor&&t.set("actor",e.actor),e.targetType&&t.set("targetType",e.targetType),e.targetName&&t.set("targetName",e.targetName),e.status&&t.set("status",e.status),e.from&&t.set("from",e.from),e.to&&t.set("to",e.to),void 0!==e.limit&&t.set("limit",String(e.limit)),void 0!==e.offset&&t.set("offset",String(e.offset)),e.sort&&t.set("sort",e.sort);let i=t.toString();return i?`?${i}`:""}(e);return(0,n.a)({queryKey:["audit-logs",e],queryFn:()=>(0,r.SC)(`/api/audit-logs${i}`),enabled:t?.enabled!==!1})}function o(e){return(0,n.a)({queryKey:["audit-logs","stats"],queryFn:()=>(0,r.SC)("/api/audit-logs/stats"),enabled:e?.enabled!==!1,refetchInterval:3e4})}function l(e,t){return(0,n.a)({queryKey:["audit-logs",e],queryFn:()=>(0,r.SC)(`/api/audit-logs/${encodeURIComponent(e)}`),enabled:t?.enabled!==!1&&!!e})}function a(e,t){return s({targetType:"server",targetName:e,limit:t?.limit??20},{enabled:t?.enabled!==!1&&!!e})}function h(e=10){return s({limit:e,sort:"timestamp:desc"})}},15934:(e,t,i)=>{"use strict";i.d(t,{Bc:()=>a,N$:()=>h,UW:()=>l});var n=i(28872),r=i(95343),s=i(20042),o=i(43137);function l(){return(0,n.a)({queryKey:["playit-status"],queryFn:()=>(0,o.SC)("/api/playit/status"),refetchInterval:3e4})}function a(){let e=(0,r.NL)();return(0,s.D)({mutationFn:()=>(0,o.SC)("/api/playit/start",{method:"POST"}),onSuccess:()=>{e.invalidateQueries({queryKey:["playit-status"]})}})}function h(){let e=(0,r.NL)();return(0,s.D)({mutationFn:()=>(0,o.SC)("/api/playit/stop",{method:"POST"}),onSuccess:()=>{e.invalidateQueries({queryKey:["playit-status"]})}})}},50423:(e,t,i)=>{"use strict";i.d(t,{Y:()=>s});var n=i(36372),r=i(47893);function s(e){let{serverName:t,maxLines:i=500,enabled:s=!0,reconnectInterval:o=3e3}=e,[l,a]=(0,n.useState)([]),h=(0,n.useCallback)(e=>{let t;"server-log"===e.type?t=e.data.log:"log"in e&&"string"==typeof e.log&&(t=e.log),t&&a(e=>{let n=[...e,t];return n.length>i?n.slice(n.length-i):n})},[i]),{isConnected:c,reconnect:d,retryCount:u}=(0,r.D)({url:`/api/sse/servers/${encodeURIComponent(t)}/logs`,onMessage:h,enabled:s,reconnectInterval:o});return{logs:l,isConnected:c,clearLogs:(0,n.useCallback)(()=>{a([])},[]),reconnect:d,retryCount:u}}},39928:(e,t,i)=>{"use strict";i.d(t,{KK:()=>l,Lu:()=>n,Xn:()=>o,n3:()=>r,xg:()=>s});let n={"server.create":"success","server.delete":"error","server.start":"info","server.stop":"warning","server.restart":"secondary","player.whitelist.add":"success","player.whitelist.remove":"warning","player.ban":"error","player.unban":"success","player.op":"info","player.deop":"warning","player.kick":"error","audit.purge":"default"},r={"server.create":"Create","server.delete":"Delete","server.start":"Start","server.stop":"Stop","server.restart":"Restart","player.whitelist.add":"Whitelist Add","player.whitelist.remove":"Whitelist Remove","player.ban":"Ban","player.unban":"Unban","player.op":"Op","player.deop":"Deop","player.kick":"Kick","audit.purge":"Purge"},s=["server.create","server.delete","server.start","server.stop","server.restart","player.whitelist.add","player.whitelist.remove","player.ban","player.unban","player.op","player.deop","player.kick","audit.purge"],o=["server.create","server.delete","server.start","server.stop","server.restart"],l=["player.whitelist.add","player.whitelist.remove","player.ban","player.unban","player.op","player.deop","player.kick"]},40579:(e,t,i)=>{"use strict";i.r(t),i.d(t,{default:()=>n});let n=(0,i(2325).createProxy)(String.raw`/home/runner/work/minecraft-server-manager/minecraft-server-manager/platform/services/mcctl-console/src/app/(main)/servers/[name]/page.tsx#default`)}};var t=require("../../../../webpack-runtime.js");t.C(e);var i=e=>t(t.s=e),n=t.X(0,[9836,1489,6554,3043,8847,7573,8872,4859,6088,8243,8504,4207,1645,8389,1201,8913,2842,7049,3613,354,1088,4479],()=>i(61509));module.exports=n})();
|
|
1
|
+
(()=>{var e={};e.id=278,e.ids=[278],e.modules={85890:e=>{"use strict";e.exports=require("better-sqlite3")},72934:e=>{"use strict";e.exports=require("next/dist/client/components/action-async-storage.external.js")},54580:e=>{"use strict";e.exports=require("next/dist/client/components/request-async-storage.external.js")},45869:e=>{"use strict";e.exports=require("next/dist/client/components/static-generation-async-storage.external.js")},20399:e=>{"use strict";e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},92048:e=>{"use strict";e.exports=require("fs")},55315:e=>{"use strict";e.exports=require("path")},17360:e=>{"use strict";e.exports=require("url")},61509:(e,t,i)=>{"use strict";i.r(t),i.d(t,{GlobalError:()=>o.a,__next_app__:()=>u,originalPathname:()=>d,pages:()=>c,routeModule:()=>f,tree:()=>h}),i(40579),i(26072),i(82395),i(97759);var n=i(95530),r=i(45086),s=i(13937),o=i.n(s),l=i(45587),a={};for(let e in l)0>["default","tree","pages","GlobalError","originalPathname","__next_app__","routeModule"].indexOf(e)&&(a[e]=()=>l[e]);i.d(t,a);let h=["",{children:["(main)",{children:["servers",{children:["[name]",{children:["__PAGE__",{},{page:[()=>Promise.resolve().then(i.bind(i,40579)),"/home/runner/work/minecraft-server-manager/minecraft-server-manager/platform/services/mcctl-console/src/app/(main)/servers/[name]/page.tsx"]}]},{}]},{}]},{layout:[()=>Promise.resolve().then(i.bind(i,26072)),"/home/runner/work/minecraft-server-manager/minecraft-server-manager/platform/services/mcctl-console/src/app/(main)/layout.tsx"],"not-found":[()=>Promise.resolve().then(i.t.bind(i,82395,23)),"next/dist/client/components/not-found-error"],metadata:{icon:[async e=>(await Promise.resolve().then(i.bind(i,52001))).default(e)],apple:[],openGraph:[],twitter:[],manifest:void 0}}]},{layout:[()=>Promise.resolve().then(i.bind(i,97759)),"/home/runner/work/minecraft-server-manager/minecraft-server-manager/platform/services/mcctl-console/src/app/layout.tsx"],"not-found":[()=>Promise.resolve().then(i.t.bind(i,82395,23)),"next/dist/client/components/not-found-error"],metadata:{icon:[async e=>(await Promise.resolve().then(i.bind(i,52001))).default(e)],apple:[],openGraph:[],twitter:[],manifest:void 0}}],c=["/home/runner/work/minecraft-server-manager/minecraft-server-manager/platform/services/mcctl-console/src/app/(main)/servers/[name]/page.tsx"],d="/(main)/servers/[name]/page",u={require:i,loadChunk:()=>Promise.resolve()},f=new n.AppPageRouteModule({definition:{kind:r.x.APP_PAGE,page:"/(main)/servers/[name]/page",pathname:"/servers/[name]",bundlePath:"",filename:"",appPaths:[]},userland:{loaderTree:h}})},21515:(e,t,i)=>{Promise.resolve().then(i.bind(i,51314))},42902:(e,t,i)=>{"use strict";var n=i(66682);t.Z=void 0;var r=n(i(7750)),s=i(58120);t.Z=(0,r.default)([(0,s.jsx)("path",{d:"M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2M12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8"},"0"),(0,s.jsx)("path",{d:"M12.5 7H11v6l5.25 3.15.75-1.23-4.5-2.67z"},"1")],"AccessTime")},95722:(e,t,i)=>{"use strict";var n=i(66682);t.Z=void 0;var r=n(i(7750)),s=i(58120);t.Z=(0,r.default)((0,s.jsx)("path",{d:"m12 4-1.41 1.41L16.17 11H4v2h12.17l-5.58 5.59L12 20l8-8z"}),"ArrowForward")},26567:(e,t,i)=>{"use strict";var n=i(66682);t.Z=void 0;var r=n(i(7750)),s=i(58120);t.Z=(0,r.default)((0,s.jsx)("path",{d:"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2m-5 14H7v-2h7zm3-4H7v-2h10zm0-4H7V7h10z"}),"Article")},75569:(e,t,i)=>{"use strict";var n=i(66682);t.Z=void 0;var r=n(i(7750)),s=i(58120);t.Z=(0,r.default)((0,s.jsx)("path",{d:"M16.5 6v11.5c0 2.21-1.79 4-4 4s-4-1.79-4-4V5c0-1.38 1.12-2.5 2.5-2.5s2.5 1.12 2.5 2.5v10.5c0 .55-.45 1-1 1s-1-.45-1-1V6H10v9.5c0 1.38 1.12 2.5 2.5 2.5s2.5-1.12 2.5-2.5V5c0-2.21-1.79-4-4-4S7 2.79 7 5v12.5c0 3.04 2.46 5.5 5.5 5.5s5.5-2.46 5.5-5.5V6z"}),"AttachFile")},65757:(e,t,i)=>{"use strict";var n=i(66682);t.Z=void 0;var r=n(i(7750)),s=i(58120);t.Z=(0,r.default)((0,s.jsx)("path",{d:"m22.7 19-9.1-9.1c.9-2.3.4-5-1.5-6.9-2-2-5-2.4-7.4-1.3L9 6 6 9 1.6 4.7C.4 7.1.9 10.1 2.9 12.1c1.9 1.9 4.6 2.4 6.9 1.5l9.1 9.1c.4.4 1 .4 1.4 0l2.3-2.3c.5-.4.5-1.1.1-1.4"}),"Build")},40238:(e,t,i)=>{"use strict";var n=i(66682);t.Z=void 0;var r=n(i(7750)),s=i(58120);t.Z=(0,r.default)((0,s.jsx)("path",{d:"M19.35 10.04C18.67 6.59 15.64 4 12 4 9.11 4 6.6 5.64 5.35 8.04 2.34 8.36 0 10.91 0 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96M14 13v4h-4v-4H7l5-5 5 5z"}),"CloudUpload")},64668:(e,t,i)=>{"use strict";var n=i(66682);t.Z=void 0;var r=n(i(7750)),s=i(58120);t.Z=(0,r.default)((0,s.jsx)("path",{d:"M9.4 16.6 4.8 12l4.6-4.6L8 6l-6 6 6 6zm5.2 0 4.6-4.6-4.6-4.6L16 6l6 6-6 6z"}),"Code")},10937:(e,t,i)=>{"use strict";var n=i(66682);t.Z=void 0;var r=n(i(7750)),s=i(58120);t.Z=(0,r.default)((0,s.jsx)("path",{d:"M20 6h-8l-2-2H4c-1.11 0-1.99.89-1.99 2L2 18c0 1.11.89 2 2 2h16c1.11 0 2-.89 2-2V8c0-1.11-.89-2-2-2m-1 8h-3v3h-2v-3h-3v-2h3V9h2v3h3z"}),"CreateNewFolder")},66147:(e,t,i)=>{"use strict";var n=i(66682);t.Z=void 0;var r=n(i(7750)),s=i(58120);t.Z=(0,r.default)((0,s.jsx)("path",{d:"M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6zm2.46-7.12 1.41-1.41L12 12.59l2.12-2.12 1.41 1.41L13.41 14l2.12 2.12-1.41 1.41L12 15.41l-2.12 2.12-1.41-1.41L10.59 14zM15.5 4l-1-1h-5l-1 1H5v2h14V4z"}),"DeleteForever")},61872:(e,t,i)=>{"use strict";var n=i(66682);t.Z=void 0;var r=n(i(7750)),s=i(58120);t.Z=(0,r.default)((0,s.jsx)("path",{d:"M14 2H6c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8zm2 16H8v-2h8zm0-4H8v-2h8zm-3-5V3.5L18.5 9z"}),"Description")},86202:(e,t,i)=>{"use strict";var n=i(66682);t.Z=void 0;var r=n(i(7750)),s=i(58120);t.Z=(0,r.default)((0,s.jsx)("path",{d:"M5 20h14v-2H5zM19 9h-4V3H9v6H5l7 7z"}),"Download")},92058:(e,t,i)=>{"use strict";var n=i(66682);t.Z=void 0;var r=n(i(7750)),s=i(58120);t.Z=(0,r.default)((0,s.jsx)("path",{d:"M18.41 5.8 17.2 4.59c-.78-.78-2.05-.78-2.83 0l-2.68 2.68L3 15.96V20h4.04l8.74-8.74 2.63-2.63c.79-.78.79-2.05 0-2.83M6.21 18H5v-1.21l8.66-8.66 1.21 1.21zM11 20l4-4h6v4z"}),"DriveFileRenameOutline")},50582:(e,t,i)=>{"use strict";var n=i(66682);t.Z=void 0;var r=n(i(7750)),s=i(58120);t.Z=(0,r.default)((0,s.jsx)("path",{d:"M20.5 11H19V7c0-1.1-.9-2-2-2h-4V3.5C13 2.12 11.88 1 10.5 1S8 2.12 8 3.5V5H4c-1.1 0-1.99.9-1.99 2v3.8H3.5c1.49 0 2.7 1.21 2.7 2.7s-1.21 2.7-2.7 2.7H2V20c0 1.1.9 2 2 2h3.8v-1.5c0-1.49 1.21-2.7 2.7-2.7 1.49 0 2.7 1.21 2.7 2.7V22H17c1.1 0 2-.9 2-2v-4h1.5c1.38 0 2.5-1.12 2.5-2.5S21.88 11 20.5 11"}),"Extension")},19103:(e,t,i)=>{"use strict";var n=i(66682);t.Z=void 0;var r=n(i(7750)),s=i(58120);t.Z=(0,r.default)((0,s.jsx)("path",{d:"M10 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2h-8z"}),"Folder")},46973:(e,t,i)=>{"use strict";var n=i(66682);t.Z=void 0;var r=n(i(7750)),s=i(58120);t.Z=(0,r.default)((0,s.jsx)("path",{d:"M20 6h-8l-2-2H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2m0 12H4V8h16z"}),"FolderOpen")},31620:(e,t,i)=>{"use strict";var n=i(66682);t.Z=void 0;var r=n(i(7750)),s=i(58120);t.Z=(0,r.default)((0,s.jsx)("path",{d:"M10 20v-6h4v6h5v-8h3L12 3 2 12h3v8z"}),"Home")},15348:(e,t,i)=>{"use strict";var n=i(66682);t.Z=void 0;var r=n(i(7750)),s=i(58120);t.Z=(0,r.default)((0,s.jsx)("path",{d:"M6 2c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6zm7 7V3.5L18.5 9z"}),"InsertDriveFile")},54896:(e,t,i)=>{"use strict";var n=i(66682);t.Z=void 0;var r=n(i(7750)),s=i(58120);t.Z=(0,r.default)((0,s.jsx)("path",{d:"M20 2H4c-1 0-2 .9-2 2v3.01c0 .72.43 1.34 1 1.69V20c0 1.1 1.1 2 2 2h14c.9 0 2-.9 2-2V8.7c.57-.35 1-.97 1-1.69V4c0-1.1-1-2-2-2m-5 12H9v-2h6zm5-7H4V4l16-.02z"}),"Inventory")},82538:(e,t,i)=>{"use strict";var n=i(66682);t.Z=void 0;var r=n(i(7750)),s=i(58120);t.Z=(0,r.default)((0,s.jsx)("path",{d:"M7.41 8.59 12 13.17l4.59-4.58L18 10l-6 6-6-6z"}),"KeyboardArrowDown")},75614:(e,t,i)=>{"use strict";var n=i(66682);t.Z=void 0;var r=n(i(7750)),s=i(58120);t.Z=(0,r.default)((0,s.jsx)("path",{d:"M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2m6.93 6h-2.95c-.32-1.25-.78-2.45-1.38-3.56 1.84.63 3.37 1.91 4.33 3.56M12 4.04c.83 1.2 1.48 2.53 1.91 3.96h-3.82c.43-1.43 1.08-2.76 1.91-3.96M4.26 14C4.1 13.36 4 12.69 4 12s.1-1.36.26-2h3.38c-.08.66-.14 1.32-.14 2 0 .68.06 1.34.14 2zm.82 2h2.95c.32 1.25.78 2.45 1.38 3.56-1.84-.63-3.37-1.9-4.33-3.56m2.95-8H5.08c.96-1.66 2.49-2.93 4.33-3.56C8.81 5.55 8.35 6.75 8.03 8M12 19.96c-.83-1.2-1.48-2.53-1.91-3.96h3.82c-.43 1.43-1.08 2.76-1.91 3.96M14.34 14H9.66c-.09-.66-.16-1.32-.16-2 0-.68.07-1.35.16-2h4.68c.09.65.16 1.32.16 2 0 .68-.07 1.34-.16 2m.25 5.56c.6-1.11 1.06-2.31 1.38-3.56h2.95c-.96 1.65-2.49 2.93-4.33 3.56M16.36 14c.08-.66.14-1.32.14-2 0-.68-.06-1.34-.14-2h3.38c.16.64.26 1.31.26 2s-.1 1.36-.26 2z"}),"Language")},61989:(e,t,i)=>{"use strict";var n=i(66682);t.Z=void 0;var r=n(i(7750)),s=i(58120);t.Z=(0,r.default)((0,s.jsx)("path",{d:"M19 5v14H5V5zm1.1-2H3.9c-.5 0-.9.4-.9.9v16.2c0 .4.4.9.9.9h16.2c.4 0 .9-.5.9-.9V3.9c0-.5-.5-.9-.9-.9M11 7h6v2h-6zm0 4h6v2h-6zm0 4h6v2h-6zM7 7h2v2H7zm0 4h2v2H7zm0 4h2v2H7z"}),"ListAlt")},58039:(e,t,i)=>{"use strict";var n=i(66682);t.Z=void 0;var r=n(i(7750)),s=i(58120);t.Z=(0,r.default)((0,s.jsx)("path",{d:"m21.41 11.58-9-9C12.05 2.22 11.55 2 11 2H4c-1.1 0-2 .9-2 2v7c0 .55.22 1.05.59 1.42l9 9c.36.36.86.58 1.41.58.55 0 1.05-.22 1.41-.59l7-7c.37-.36.59-.86.59-1.41 0-.55-.23-1.06-.59-1.42M5.5 7C4.67 7 4 6.33 4 5.5S4.67 4 5.5 4 7 4.67 7 5.5 6.33 7 5.5 7"}),"LocalOffer")},25414:(e,t,i)=>{"use strict";var n=i(66682);t.Z=void 0;var r=n(i(7750)),s=i(58120);t.Z=(0,r.default)((0,s.jsx)("path",{d:"M21 11V3h-8l3.29 3.29-10 10L3 13v8h8l-3.29-3.29 10-10z"}),"OpenInFull")},72419:(e,t,i)=>{"use strict";var n=i(66682);t.Z=void 0;var r=n(i(7750)),s=i(58120);t.Z=(0,r.default)((0,s.jsx)("path",{d:"M9 16h2V8H9zm3-14C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8m1-4h2V8h-2z"}),"PauseCircleOutline")},17820:(e,t,i)=>{"use strict";var n=i(66682);t.Z=void 0;var r=n(i(7750)),s=i(58120);t.Z=(0,r.default)((0,s.jsx)("path",{d:"M12 5V2L8 6l4 4V7c3.31 0 6 2.69 6 6 0 2.97-2.17 5.43-5 5.91v2.02c3.95-.49 7-3.85 7-7.93 0-4.42-3.58-8-8-8m-6 8c0-1.65.67-3.15 1.76-4.24L6.34 7.34C4.9 8.79 4 10.79 4 13c0 4.08 3.05 7.44 7 7.93v-2.02c-2.83-.48-5-2.94-5-5.91"}),"RestartAlt")},11475:(e,t,i)=>{"use strict";var n=i(66682);t.Z=void 0;var r=n(i(7750)),s=i(58120);t.Z=(0,r.default)((0,s.jsx)("path",{d:"M17 3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V7zm-5 16c-1.66 0-3-1.34-3-3s1.34-3 3-3 3 1.34 3 3-1.34 3-3 3m3-10H5V5h10z"}),"Save")},7060:(e,t,i)=>{"use strict";var n=i(66682);t.Z=void 0;var r=n(i(7750)),s=i(58120);t.Z=(0,r.default)((0,s.jsx)("path",{d:"M18 2h-8L4.02 8 4 20c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2m-6 6h-2V4h2zm3 0h-2V4h2zm3 0h-2V4h2z"}),"SdStorage")},93599:(e,t,i)=>{"use strict";var n=i(66682);t.Z=void 0;var r=n(i(7750)),s=i(58120);t.Z=(0,r.default)((0,s.jsx)("path",{d:"M12 1 3 5v6c0 5.55 3.84 10.74 9 12 5.16-1.26 9-6.45 9-12V5z"}),"Shield")},36438:(e,t,i)=>{"use strict";var n=i(66682);t.Z=void 0;var r=n(i(7750)),s=i(58120);t.Z=(0,r.default)((0,s.jsx)("path",{d:"m20.38 8.57-1.23 1.85a8 8 0 0 1-.22 7.58H5.07A8 8 0 0 1 15.58 6.85l1.85-1.23A10 10 0 0 0 3.35 19a2 2 0 0 0 1.72 1h13.85a2 2 0 0 0 1.74-1 10 10 0 0 0-.27-10.44zm-9.79 6.84a2 2 0 0 0 2.83 0l5.66-8.49-8.49 5.66a2 2 0 0 0 0 2.83"}),"Speed")},3470:(e,t,i)=>{"use strict";var n=i(66682);t.Z=void 0;var r=n(i(7750)),s=i(58120);t.Z=(0,r.default)((0,s.jsx)("path",{d:"m21.58 16.09-1.09-7.66C20.21 6.46 18.52 5 16.53 5H7.47C5.48 5 3.79 6.46 3.51 8.43l-1.09 7.66C2.2 17.63 3.39 19 4.94 19c.68 0 1.32-.27 1.8-.75L9 16h6l2.25 2.25c.48.48 1.13.75 1.8.75 1.56 0 2.75-1.37 2.53-2.91M11 11H9v2H8v-2H6v-1h2V8h1v2h2zm4-1c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1m2 3c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1"}),"SportsEsports")},43992:(e,t,i)=>{"use strict";var n=i(66682);t.Z=void 0;var r=n(i(7750)),s=i(58120);t.Z=(0,r.default)((0,s.jsx)("path",{d:"M20 4H4c-1.11 0-2 .9-2 2v12c0 1.1.89 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.89-2-2-2m0 14H4V8h16zm-2-1h-6v-2h6zM7.5 17l-1.41-1.41L8.67 13l-2.59-2.59L7.5 9l4 4z"}),"Terminal")},40768:(e,t,i)=>{"use strict";var n=i(66682);t.Z=void 0;var r=n(i(7750)),s=i(58120);t.Z=(0,r.default)((0,s.jsx)("path",{d:"M3 17v2h6v-2zM3 5v2h10V5zm10 16v-2h8v-2h-8v-2h-2v6zM7 9v2H3v2h4v2h2V9zm14 4v-2H11v2zm-6-4h2V7h4V5h-4V3h-2z"}),"Tune")},34615:(e,t,i)=>{"use strict";var n=i(66682);t.Z=void 0;var r=n(i(7750)),s=i(58120);t.Z=(0,r.default)((0,s.jsx)("path",{d:"M12.5 8c-2.65 0-5.05.99-6.9 2.6L2 7v9h9l-3.62-3.62c1.39-1.16 3.16-1.88 5.12-1.88 3.54 0 6.55 2.31 7.6 5.5l2.37-.78C21.08 11.03 17.15 8 12.5 8"}),"Undo")},80403:(e,t,i)=>{"use strict";var n=i(66682);t.Z=void 0;var r=n(i(7750)),s=i(58120);t.Z=(0,r.default)((0,s.jsx)("path",{d:"M14 2H6c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8zm4 18H6V4h7v5h5zM8 15.01l1.41 1.41L11 14.84V19h2v-4.16l1.59 1.59L16 15.01 12.01 11z"}),"UploadFile")},23090:(e,t,i)=>{"use strict";var n=i(66682);t.Z=void 0;var r=n(i(7750)),s=i(58120);t.Z=(0,r.default)((0,s.jsx)("path",{d:"m18.25 7.6-5.5-3.18c-.46-.27-1.04-.27-1.5 0L5.75 7.6c-.46.27-.75.76-.75 1.3v6.35c0 .54.29 1.03.75 1.3l5.5 3.18c.46.27 1.04.27 1.5 0l5.5-3.18c.46-.27.75-.76.75-1.3V8.9c0-.54-.29-1.03-.75-1.3M7 14.96v-4.62l4 2.32v4.61zm5-4.03L8 8.61l4-2.31 4 2.31zm1 6.34v-4.61l4-2.32v4.62zM7 2H3.5C2.67 2 2 2.67 2 3.5V7h2V4h3zm10 0h3.5c.83 0 1.5.67 1.5 1.5V7h-2V4h-3zM7 22H3.5c-.83 0-1.5-.67-1.5-1.5V17h2v3h3zm10 0h3.5c.83 0 1.5-.67 1.5-1.5V17h-2v3h-3z"}),"ViewInAr")},26518:(e,t,i)=>{"use strict";var n=i(66682);t.Z=void 0;var r=n(i(7750)),s=i(58120);t.Z=(0,r.default)((0,s.jsx)("path",{d:"M1 21h22L12 2zm12-3h-2v-2h2zm0-4h-2v-4h2z"}),"Warning")},61649:(e,t,i)=>{"use strict";var n=i(66682);t.Z=void 0;var r=n(i(7750)),s=i(58120);t.Z=(0,r.default)([(0,s.jsx)("path",{d:"M12 5.99 19.53 19H4.47zM12 2 1 21h22z"},"0"),(0,s.jsx)("path",{d:"M13 16h-2v2h2zm0-6h-2v5h2z"},"1")],"WarningAmber")},664:(e,t,i)=>{"use strict";i.d(t,{Z:()=>x});var n=i(4981),r=i(36885),s=i(36372),o=i(30330),l=i(3693),a=i(9103),h=i(62923),c=i(89206),d=i(7967);function u(e){return(0,d.ZP)("MuiTableContainer",e)}(0,c.Z)("MuiTableContainer",["root"]);var f=i(58120);let p=["className","component"],m=e=>{let{classes:t}=e;return(0,l.Z)({root:["root"]},u,t)},g=(0,h.ZP)("div",{name:"MuiTableContainer",slot:"Root",overridesResolver:(e,t)=>t.root})({width:"100%",overflowX:"auto"}),x=s.forwardRef(function(e,t){let i=(0,a.i)({props:e,name:"MuiTableContainer"}),{className:s,component:l="div"}=i,h=(0,r.Z)(i,p),c=(0,n.Z)({},i,{component:l}),d=m(c);return(0,f.jsx)(g,(0,n.Z)({ref:t,as:l,className:(0,o.Z)(d.root,s),ownerState:c},h))})},51314:(e,t,i)=>{"use strict";let n,r;i.r(t),i.d(t,{default:()=>fv});var s,o,l,a,h=i(58120),c=i(36372),d=i(56539),u=i(49856),f=i(89352),p=i(10257),m=i(54365),g=i(66757),x=i(79943),v=i(68913),y=i(67073),b=i(92797),w=i(2365),k=i(81030),S=i(99634),C=i(63654),j=i(63856),M=i(34443),Z=i(44696),A=i(15539),T=i(51290),O=i(6275),D=i(73100),R=i(95940),P=i(43312),L=i(29553),I=i(54655),E=i(96454),B=i(23090),N=i(58039),z=i(30463),W=i(42902),F=i(48787),V=i(92559),H=i(80336),$=i(62073),q=i(98693),K=i(33615),U=i(36438),_=i(7060),G=i(46973),J=i(25414),X=i(82538),Y=i(43992),Q=i(95223);function ee({value:e,unit:t,label:i,icon:n,progress:r,progressMax:s,color:o="#1bd96a"}){return(0,h.jsxs)(y.Z,{"data-testid":"resource-stat-card",sx:{p:2.5,bgcolor:"background.paper",border:"1px solid",borderColor:"divider",borderRadius:3},children:[(0,h.jsxs)(f.Z,{sx:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:2},children:[(0,h.jsxs)(f.Z,{sx:{display:"flex",alignItems:"baseline",gap:.75,flexWrap:"wrap",minWidth:0},children:[h.jsx(w.Z,{variant:"h4",component:"span",sx:{fontWeight:700,color:"text.primary",letterSpacing:"-0.5px"},children:e}),h.jsx(w.Z,{variant:"body2",component:"span",sx:{color:"text.secondary",fontWeight:500},children:t})]}),h.jsx(f.Z,{sx:{color:"text.secondary",flexShrink:0},children:n})]}),h.jsx(w.Z,{variant:"body2",sx:{color:"text.secondary",fontWeight:500,mt:.5},children:i}),h.jsx(Q.Z,{variant:"determinate",value:Math.min(r/s*100,100),sx:{mt:1,height:6,borderRadius:1.5,bgcolor:"#2a2d3a","& .MuiLinearProgress-bar":{borderRadius:1.5,background:`linear-gradient(90deg, ${o} 0%, ${o}cc 100%)`}}})]})}var et=i(50423),ei=i(6418),en=i(58664),er=i(73091),es=i(98243),eo=i(40611),el=i(95722),ea=i(71438),eh=i(55049),ec=i(15784);function ed({serverName:e}){let{data:t,isLoading:i,error:n}=(0,ec.HZ)(e,{limit:20});if(i)return h.jsx(f.Z,{children:[void 0,void 0,void 0,void 0,void 0].map((e,t)=>(0,h.jsxs)(f.Z,{sx:{display:"flex",gap:2,py:1.5},children:[h.jsx(v.Z,{variant:"rounded",width:60,height:24}),h.jsx(v.Z,{variant:"text",width:"60%"}),h.jsx(v.Z,{variant:"text",width:50})]},t))});if(n)return(0,h.jsxs)(g.Z,{severity:"error",children:["Failed to load activity: ",n.message]});let r=t?.logs??[];if(0===r.length)return h.jsx(w.Z,{variant:"body2",color:"text.secondary",sx:{py:4,textAlign:"center"},children:"No activity recorded for this server yet."});let s=`/audit-logs?targetType=server&targetName=${encodeURIComponent(e)}`;return(0,h.jsxs)(f.Z,{children:[h.jsx(en.Z,{sx:{py:0},children:r.map(e=>{var t;return h.jsx(er.ZP,{sx:{px:0,py:1.5,"&:not(:last-child)":{borderBottom:"1px solid",borderColor:"divider"}},children:h.jsx(j.Z,{primary:(0,h.jsxs)(f.Z,{sx:{display:"flex",alignItems:"center",gap:1},children:[h.jsx(ea.I,{action:e.action,size:"small"}),(0,h.jsxs)(w.Z,{variant:"body2",color:"text.secondary",children:["by ",e.actor.replace("api:","").replace("cli:","")]}),h.jsx(eh.c,{status:e.status,size:"small"})]}),secondary:h.jsx(es.Z,{title:(t=e.timestamp,new Intl.DateTimeFormat(void 0,{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",timeZoneName:"short"}).format(new Date(t))),arrow:!0,children:h.jsx(w.Z,{variant:"caption",component:"span",color:"text.disabled",children:function(e){let t=new Date,i=new Date(e),n=Math.floor((t.getTime()-i.getTime())/6e4),r=Math.floor(n/60);return n<1?"just now":n<60?`${n}m ago`:r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}(e.timestamp)})})})},e.id)})}),h.jsx(f.Z,{sx:{mt:2,textAlign:"center"},children:h.jsx(p.Z,{component:eo.default,href:s,size:"small",endIcon:h.jsx(el.Z,{}),sx:{textTransform:"none"},children:"View Full History"})})]})}var eu=i(60920),ef=i(26518),ep=i(66147),em=i(17820),eg=i(74151),ex=i(23016),ev=i(61960),ey=i(29564),eb=i(11475),ew=i(75614);function ek({serverName:e}){let{data:t,isLoading:i}=(0,eg.Js)(e),n=(0,eg.Bx)(),[r,s]=(0,c.useState)([]),[o,l]=(0,c.useState)(!1),[a,d]=(0,c.useState)(!1),[u,v]=(0,c.useState)(""),[k,S]=(0,c.useState)(""),[C,j]=(0,c.useState)(!1),[M,Z]=(0,c.useState)({open:!1,message:"",severity:"success"}),A=e=>{let t=e.trim().toLowerCase();return t?t.length>253?"Domain exceeds 253 characters":/^[a-z0-9]([a-z0-9\-.]*[a-z0-9])?$/.test(t)?t.endsWith(".local")?"Cannot use .local system domain":t.endsWith(".nip.io")?"Cannot use .nip.io system domain":r.includes(t)?"Domain already exists":"":"Invalid domain format":"Domain cannot be empty"},T=()=>{let e=u.trim().toLowerCase(),t=A(e);if(t){S(t);return}s(t=>[...t,e]),v(""),S(""),d(!1),l(!0)},D=e=>{s(t=>t.filter(t=>t!==e)),l(!0)},R=async()=>{try{await n.mutateAsync({serverName:e,customHostnames:r}),l(!1),j(!0),Z({open:!0,message:"Hostnames saved. Container recreation required to apply changes.",severity:"warning"})}catch(e){Z({open:!0,message:e instanceof Error?e.message:"Failed to save hostnames",severity:"error"})}},P=()=>{d(!1),v(""),S("")};return i?h.jsx(y.Z,{sx:{mb:3,borderRadius:3},children:h.jsx(b.Z,{children:h.jsx(f.Z,{sx:{display:"flex",justifyContent:"center",py:4},children:h.jsx(x.Z,{size:24})})})}):(0,h.jsxs)(h.Fragment,{children:[h.jsx(y.Z,{sx:{mb:3,borderRadius:3},children:(0,h.jsxs)(b.Z,{children:[(0,h.jsxs)(f.Z,{sx:{display:"flex",alignItems:"center",gap:1,mb:1},children:[h.jsx(ew.Z,{color:"primary"}),h.jsx(w.Z,{variant:"h6",fontWeight:600,children:"Hostnames / Domains"})]}),h.jsx(w.Z,{variant:"body2",color:"text.secondary",sx:{mb:2},children:"Manage hostnames used by mc-router to route connections to this server."}),h.jsx(H.Z,{sx:{mb:3}}),t?.systemHostnames&&t.systemHostnames.length>0&&(0,h.jsxs)(f.Z,{sx:{mb:3},children:[h.jsx(w.Z,{variant:"subtitle2",color:"text.secondary",sx:{mb:1},children:"System Hostnames (read-only)"}),h.jsx(ex.Z,{direction:"row",flexWrap:"wrap",gap:1,children:t.systemHostnames.map(e=>h.jsx(F.Z,{icon:h.jsx(ev.Z,{sx:{fontSize:16}}),label:e.hostname,title:e.description,variant:"outlined",color:"default",size:"small"},e.hostname))})]}),(0,h.jsxs)(f.Z,{sx:{mb:2},children:[h.jsx(w.Z,{variant:"subtitle2",color:"text.secondary",sx:{mb:1},children:"Custom Domains"}),0===r.length&&!a&&h.jsx(w.Z,{variant:"body2",color:"text.disabled",sx:{mb:1},children:"No custom domains configured."}),h.jsx(ex.Z,{spacing:1,children:r.map(e=>(0,h.jsxs)(f.Z,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",py:.5,px:1.5,borderRadius:1,bgcolor:"action.hover"},children:[h.jsx(w.Z,{variant:"body2",children:e}),h.jsx(m.Z,{size:"small",color:"error",onClick:()=>D(e),title:"Remove domain",children:h.jsx(E.Z,{fontSize:"small"})})]},e))}),a?(0,h.jsxs)(f.Z,{sx:{display:"flex",alignItems:"flex-start",gap:1,mt:1},children:[h.jsx(O.Z,{size:"small",placeholder:"e.g. play.example.com",value:u,onChange:e=>{v(e.target.value),S("")},onKeyDown:e=>{"Enter"===e.key&&T(),"Escape"===e.key&&P()},error:!!k,helperText:k,autoFocus:!0,sx:{flex:1}}),h.jsx(p.Z,{size:"small",variant:"contained",onClick:T,children:"Add"}),h.jsx(m.Z,{size:"small",onClick:P,children:h.jsx(K.Z,{fontSize:"small"})})]}):h.jsx(p.Z,{size:"small",startIcon:h.jsx(ey.Z,{}),onClick:()=>d(!0),sx:{mt:1},children:"Add Domain"})]}),C&&(0,h.jsxs)(g.Z,{severity:"warning",sx:{mb:2},children:["Container recreation is required for hostname changes to take effect. Run ",h.jsx("code",{children:"docker compose up -d"})," or restart the server from the dashboard."]}),h.jsx(f.Z,{sx:{display:"flex",justifyContent:"flex-end"},children:h.jsx(p.Z,{variant:"contained",size:"small",startIcon:h.jsx(eb.Z,{}),onClick:R,disabled:!o||n.isPending,children:n.isPending?"Saving...":"Save Hostnames"})})]})}),h.jsx(eu.Z,{open:M.open,autoHideDuration:6e3,onClose:()=>Z({...M,open:!1}),anchorOrigin:{vertical:"bottom",horizontal:"right"},children:h.jsx(g.Z,{onClose:()=>Z({...M,open:!1}),severity:M.severity,sx:{width:"100%"},children:M.message})})]})}var eS=i(5374),eC=i(84527),ej=i(73276),eM=i(32486),eZ=i(2200),eA=i(14360),eT=i(16770),eO=i(27767),eD=i(36739);function eR({field:e,value:t,onChange:i}){let[n,r]=(0,c.useState)(!1),s=e.columns??6;return h.jsx(D.ZP,{item:!0,xs:12,sm:s,children:(()=>{switch(e.type){case"boolean":return(0,h.jsxs)(f.Z,{children:[h.jsx(eA.Z,{control:h.jsx(eT.Z,{checked:t??!1,onChange:t=>i(e.key,t.target.checked)}),label:e.label}),e.helperText&&h.jsx(w.Z,{variant:"caption",color:"text.secondary",sx:{ml:4,display:"block"},children:e.helperText})]});case"select":return(0,h.jsxs)(eM.Z,{fullWidth:!0,size:"small",children:[h.jsx(eZ.Z,{children:e.label}),h.jsx(ej.Z,{value:t??e.options?.[0]?.value??"",label:e.label,onChange:t=>i(e.key,t.target.value),children:e.options?.map(e=>h.jsx(S.Z,{value:e.value,children:e.label},e.value))})]});case"number":return h.jsx(O.Z,{fullWidth:!0,size:"small",type:"number",label:e.label,value:t??"",onChange:t=>{let n=t.target.value;i(e.key,""===n?void 0:parseInt(n,10))},inputProps:{min:e.validation?.min,max:e.validation?.max},helperText:e.helperText,InputProps:e.unit?{endAdornment:h.jsx(V.Z,{position:"end",children:h.jsx(w.Z,{variant:"caption",color:"text.secondary",children:e.unit})})}:void 0});case"password":return h.jsx(O.Z,{fullWidth:!0,size:"small",type:n?"text":"password",label:e.label,value:t??"",onChange:t=>i(e.key,t.target.value),helperText:e.helperText,InputProps:{endAdornment:h.jsx(V.Z,{position:"end",children:h.jsx(m.Z,{size:"small",onClick:()=>r(!n),edge:"end",children:n?h.jsx(eD.Z,{fontSize:"small"}):h.jsx(eO.Z,{fontSize:"small"})})})}});default:return h.jsx(O.Z,{fullWidth:!0,size:"small",label:e.label,value:t??"",onChange:t=>i(e.key,t.target.value),helperText:e.helperText})}})()})}function eP({section:e,values:t,onChange:i}){let[n,r]=(0,c.useState)(!1),s=e.icon,o=e.advancedFields.length;return h.jsx(y.Z,{sx:{mb:3,borderRadius:3},children:(0,h.jsxs)(b.Z,{sx:{p:3},children:[(0,h.jsxs)(f.Z,{sx:{display:"flex",alignItems:"center",gap:1.5,mb:1},children:[h.jsx(s,{sx:{fontSize:22,color:"primary.main"}}),h.jsx(w.Z,{variant:"h6",fontWeight:600,children:e.title})]}),h.jsx(w.Z,{variant:"body2",color:"text.secondary",sx:{mb:2},children:e.description}),h.jsx(H.Z,{sx:{mb:3}}),h.jsx(D.ZP,{container:!0,spacing:2.5,children:e.essentialFields.map(e=>h.jsx(eR,{field:e,value:t[e.key],onChange:i},e.key))}),o>0&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(p.Z,{fullWidth:!0,variant:"text",onClick:()=>r(!n),endIcon:h.jsx(eC.Z,{sx:{transform:n?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.3s"}}),sx:{mt:2.5,justifyContent:"flex-start",color:"text.secondary",textTransform:"none",py:1,"&:hover":{bgcolor:"action.hover"}},children:[n?"Hide":"Show"," Advanced Settings (",o,")"]}),h.jsx(eS.Z,{in:n,timeout:300,children:h.jsx(f.Z,{sx:{pt:2,borderTop:"1px dashed",borderColor:"divider"},children:h.jsx(D.ZP,{container:!0,spacing:2.5,children:e.advancedFields.map(e=>h.jsx(eR,{field:e,value:t[e.key],onChange:i},e.key))})})})]})]})})}var eL=i(11999);function eI({hasChanges:e,changedCount:t,hasRestartChanges:i,restartFields:n=[],isSaving:r,onSave:s,onDiscard:o}){return h.jsx(eL.Z,{direction:"up",in:e,mountOnEnter:!0,unmountOnExit:!0,children:(0,h.jsxs)(f.Z,{sx:{position:"sticky",bottom:0,zIndex:1100,bgcolor:"background.paper",borderTop:2,borderColor:"primary.main",px:{xs:2,sm:3},py:2,mx:{xs:-2,sm:-3},mb:{xs:-2,sm:-3},boxShadow:"0 -4px 20px rgba(0,0,0,0.4)",display:"flex",alignItems:"center",justifyContent:"space-between",flexWrap:"wrap",gap:1},children:[(0,h.jsxs)(f.Z,{sx:{display:"flex",alignItems:"center",gap:1},children:[i&&h.jsx(em.Z,{sx:{color:"warning.main",fontSize:20}}),(0,h.jsxs)(w.Z,{variant:"body2",fontWeight:600,children:[t," unsaved change",1!==t?"s":""]}),i&&(0,h.jsxs)(w.Z,{variant:"caption",color:"warning.main",children:["(",n.length>0?n.join(", "):"some fields"," require restart)"]})]}),(0,h.jsxs)(f.Z,{sx:{display:"flex",gap:1},children:[h.jsx(p.Z,{variant:"text",color:"inherit",onClick:o,disabled:r,children:"Discard"}),h.jsx(p.Z,{variant:"contained",startIcon:r?h.jsx(x.Z,{size:16,color:"inherit"}):h.jsx(eb.Z,{}),onClick:s,disabled:r,children:r?"Saving...":`Save Changes (${t})`})]})]})})}function eE({open:e,changedFields:t,onSaveOnly:i,onSaveAndRestart:n,onCancel:r}){return(0,h.jsxs)(M.Z,{open:e,onClose:r,maxWidth:"sm",fullWidth:!0,children:[h.jsx(Z.Z,{children:(0,h.jsxs)(f.Z,{sx:{display:"flex",alignItems:"center",gap:1},children:[h.jsx(em.Z,{color:"warning"}),h.jsx(w.Z,{variant:"h6",fontWeight:600,children:"Restart Required"})]})}),(0,h.jsxs)(A.Z,{children:[h.jsx(w.Z,{variant:"body1",gutterBottom:!0,children:"The following changes require a server restart to take effect:"}),h.jsx(en.Z,{dense:!0,children:t.map(e=>h.jsx(er.ZP,{sx:{py:0},children:h.jsx(j.Z,{primary:e,primaryTypographyProps:{variant:"body2"}})},e))})]}),(0,h.jsxs)(T.Z,{children:[h.jsx(p.Z,{onClick:r,color:"inherit",children:"Cancel"}),h.jsx(p.Z,{onClick:i,variant:"outlined",children:"Save Only"}),h.jsx(p.Z,{onClick:n,variant:"contained",color:"warning",children:"Save & Restart"})]})]})}var eB=i(3470),eN=i(1877),ez=i(93599),eW=i(72419),eF=i(77343);let eV=[{id:"gameplay",icon:eB.Z,title:"Gameplay",description:"Core game rules and player experience settings.",essentialFields:[{key:"difficulty",label:"Difficulty",type:"select",options:[{value:"peaceful",label:"Peaceful"},{value:"easy",label:"Easy"},{value:"normal",label:"Normal"},{value:"hard",label:"Hard"}]},{key:"gameMode",label:"Game Mode",type:"select",options:[{value:"survival",label:"Survival"},{value:"creative",label:"Creative"},{value:"adventure",label:"Adventure"},{value:"spectator",label:"Spectator"}]},{key:"maxPlayers",label:"Max Players",type:"number",validation:{min:1,max:1e3}},{key:"pvp",label:"Enable PvP",type:"boolean",helperText:"Allow players to damage each other"}],advancedFields:[{key:"forceGamemode",label:"Force Game Mode",type:"boolean",helperText:"Force game mode when players join"},{key:"hardcore",label:"Hardcore",type:"boolean",helperText:"One life only - world deleted on death"},{key:"allowFlight",label:"Allow Flight",type:"boolean",helperText:"Allow flight in survival mode"},{key:"allowNether",label:"Allow Nether",type:"boolean",helperText:"Enable Nether portal access"},{key:"enableCommandBlock",label:"Command Blocks",type:"boolean",helperText:"Enable command block functionality"},{key:"spawnProtection",label:"Spawn Protection",type:"number",helperText:"Radius around spawn (0 = disabled)",unit:"blocks",validation:{min:0,max:256}},{key:"spawnAnimals",label:"Spawn Animals",type:"boolean",helperText:"Spawn passive mobs (cows, pigs, etc.)"},{key:"spawnMonsters",label:"Spawn Monsters",type:"boolean",helperText:"Spawn hostile mobs (zombies, creepers, etc.)"},{key:"spawnNpcs",label:"Spawn NPCs",type:"boolean",helperText:"Spawn villagers and wandering traders"}]},{id:"world",icon:eN.Z,title:"World",description:"World generation and server identity settings.",essentialFields:[{key:"motd",label:"MOTD (Message of the Day)",type:"string",helperText:"Displayed in the server list",columns:12},{key:"level",label:"World Name",type:"string",helperText:"Save folder name",restartRequired:!0},{key:"levelType",label:"Level Type",type:"select",restartRequired:!0,options:[{value:"default",label:"Default"},{value:"flat",label:"Flat"},{value:"largeBiomes",label:"Large Biomes"},{value:"amplified",label:"Amplified"},{value:"buffet",label:"Buffet"}]},{key:"seed",label:"World Seed",type:"string",helperText:"Only affects new world generation",restartRequired:!0}],advancedFields:[{key:"generateStructures",label:"Generate Structures",type:"boolean",helperText:"Generate villages, temples, etc."},{key:"maxWorldSize",label:"Max World Size",type:"number",unit:"blocks",helperText:"Maximum world radius",validation:{min:1,max:29999984}},{key:"icon",label:"Server Icon URL",type:"string",helperText:"64x64 PNG image URL",columns:12}]},{id:"security",icon:ez.Z,title:"Security",description:"Authentication and access control settings.",essentialFields:[{key:"onlineMode",label:"Online Mode (Mojang Auth)",type:"boolean",helperText:"Disable to allow cracked clients (not recommended)",restartRequired:!0},{key:"enableWhitelist",label:"Enable Whitelist",type:"boolean",helperText:"Only whitelisted players can join",restartRequired:!0}],advancedFields:[{key:"enforceWhitelist",label:"Enforce Whitelist",type:"boolean",helperText:"Kick non-whitelisted players already online",restartRequired:!0},{key:"enforceSecureProfile",label:"Enforce Secure Profile",type:"boolean",helperText:"Require signed chat messages from players",restartRequired:!0}]},{id:"performance",icon:U.Z,title:"Performance & JVM",description:"Memory, view distance, and JVM optimization settings.",essentialFields:[{key:"memory",label:"Memory",type:"string",helperText:"e.g., 2G, 4G, 8G",restartRequired:!0},{key:"useAikarFlags",label:"Aikar's Flags",type:"boolean",helperText:"Optimized GC flags for Paper/Spigot",restartRequired:!0},{key:"viewDistance",label:"View Distance",type:"number",unit:"chunks",validation:{min:2,max:32}}],advancedFields:[{key:"simulationDistance",label:"Simulation Distance",type:"number",unit:"chunks",validation:{min:3,max:32}},{key:"maxTickTime",label:"Max Tick Time",type:"number",unit:"ms",helperText:"-1 to disable watchdog",validation:{min:-1}},{key:"initMemory",label:"Initial Heap",type:"string",helperText:"e.g., 1G (overrides Memory)",restartRequired:!0},{key:"maxMemory",label:"Max Heap",type:"string",helperText:"e.g., 8G (overrides Memory)",restartRequired:!0},{key:"jvmXxOpts",label:"JVM -XX Options",type:"string",helperText:"Additional -XX JVM flags",restartRequired:!0,columns:12}]},{id:"autopause",icon:eW.Z,title:"Auto-pause / Auto-stop",description:"Automatically pause or stop when no players are connected.",essentialFields:[{key:"enableAutopause",label:"Enable Auto-pause",type:"boolean",helperText:"Pause process when no players connected",restartRequired:!0},{key:"autopauseTimeoutEst",label:"Pause Timeout",type:"number",unit:"seconds",helperText:"Wait time after last player leaves",validation:{min:0}}],advancedFields:[{key:"autopauseTimeoutInit",label:"Init Timeout",type:"number",unit:"seconds",helperText:"Timeout after start without connections",validation:{min:0}},{key:"autopausePeriod",label:"Check Period",type:"number",unit:"seconds",helperText:"Status check interval",validation:{min:1}},{key:"enableAutostop",label:"Enable Auto-stop",type:"boolean",helperText:"Stop container when no players connected",restartRequired:!0},{key:"autostopTimeoutEst",label:"Stop Timeout",type:"number",unit:"seconds",helperText:"Wait time before stopping container",validation:{min:0}}]},{id:"system",icon:eF.Z,title:"System",description:"Timezone, resource pack, RCON, and container settings.",essentialFields:[{key:"tz",label:"Timezone",type:"string",helperText:"e.g., Asia/Seoul, UTC",restartRequired:!0},{key:"resourcePack",label:"Resource Pack URL",type:"string",helperText:"Direct download URL for resource pack",columns:12},{key:"enableRcon",label:"Enable RCON",type:"boolean",helperText:"Remote server console access",restartRequired:!0}],advancedFields:[{key:"resourcePackSha1",label:"Resource Pack SHA1",type:"string",helperText:"40-character hex checksum",columns:12},{key:"resourcePackEnforce",label:"Enforce Resource Pack",type:"boolean",helperText:"Kick players who decline"},{key:"resourcePackPrompt",label:"Resource Pack Prompt",type:"string",helperText:"Custom message for resource pack dialog",columns:12},{key:"rconPassword",label:"RCON Password",type:"password",restartRequired:!0},{key:"rconPort",label:"RCON Port",type:"number",validation:{min:1024,max:65535},restartRequired:!0},{key:"stopDuration",label:"Stop Timeout",type:"number",unit:"seconds",helperText:"Graceful shutdown wait time",restartRequired:!0,validation:{min:0}},{key:"uid",label:"User ID (UID)",type:"number",helperText:"Container process UID",restartRequired:!0,validation:{min:0}},{key:"gid",label:"Group ID (GID)",type:"number",helperText:"Container process GID",restartRequired:!0,validation:{min:0}}]}],eH=["memory","initMemory","maxMemory","useAikarFlags","jvmXxOpts","onlineMode","enableWhitelist","enforceWhitelist","enforceSecureProfile","level","seed","levelType","enableAutopause","enableAutostop","enableRcon","rconPassword","rconPort","tz","uid","gid","stopDuration"];function e$({serverName:e,isRunning:t}){let{data:i,isLoading:n}=(0,eg.iC)(e),r=(0,eg.MH)(),s=(0,eg.gx)(),o=(0,eg._I)(),[l,a]=(0,c.useState)({}),[d,u]=(0,c.useState)({}),[m,v]=(0,c.useState)(!1),[k,S]=(0,c.useState)(""),[C,j]=(0,c.useState)(!1),[D,R]=(0,c.useState)({open:!1,message:"",severity:"info"}),P=(0,c.useMemo)(()=>{let e=[];for(let t of Object.keys(l))l[t]!==d[t]&&e.push(t);for(let t of Object.keys(d))l[t]===d[t]||e.includes(t)||e.push(t);return e},[l,d]),L=P.length>0,I=P.filter(e=>eH.includes(e)),E=I.length>0,B=(0,c.useCallback)((e,t)=>{a(i=>({...i,[e]:t}))},[]),N=(0,c.useCallback)(()=>{a(d)},[d]),z=(0,c.useCallback)(async i=>{try{let n=await r.mutateAsync({serverName:e,config:l});if(u(n.config),a(n.config),i&&t)try{await o.mutateAsync(e),R({open:!0,message:"Settings saved. Server is restarting...",severity:"warning"})}catch{R({open:!0,message:"Settings saved, but server restart failed. Please restart manually.",severity:"error"})}else R({open:!0,message:n.restartRequired?"Settings saved. Restart required for some changes to take effect.":"Settings saved successfully.",severity:n.restartRequired?"warning":"success"})}catch(e){R({open:!0,message:e instanceof Error?e.message:"Failed to save settings",severity:"error"})}finally{j(!1)}},[l,e,t,r,o]),W=(0,c.useCallback)(()=>{E&&t?j(!0):z(!1)},[E,t,z]),F=async()=>{if("RESET"!==k){R({open:!0,message:"Please type RESET to confirm",severity:"warning"});return}try{await s.mutateAsync(e),R({open:!0,message:"World reset successfully",severity:"success"}),v(!1),S("")}catch(e){R({open:!0,message:e instanceof Error?e.message:"Failed to reset world",severity:"error"})}};return n?h.jsx(f.Z,{sx:{display:"flex",justifyContent:"center",py:8},children:h.jsx(x.Z,{})}):(0,h.jsxs)(f.Z,{children:[h.jsx(ek,{serverName:e}),eV.map(e=>h.jsx(eP,{section:e,values:l,onChange:B},e.id)),h.jsx(y.Z,{sx:{borderRadius:3,borderColor:"error.main",borderWidth:1,borderStyle:"solid"},children:(0,h.jsxs)(b.Z,{children:[h.jsx(w.Z,{variant:"h6",gutterBottom:!0,fontWeight:600,color:"error",children:"Danger Zone"}),h.jsx(H.Z,{sx:{mb:3}}),(0,h.jsxs)(f.Z,{sx:{mb:3},children:[h.jsx(w.Z,{variant:"subtitle1",fontWeight:600,gutterBottom:!0,children:"Reset World"}),h.jsx(w.Z,{variant:"body2",color:"text.secondary",sx:{mb:2},children:"This will permanently delete the current world and generate a new one. This action cannot be undone."}),h.jsx(p.Z,{variant:"outlined",color:"error",startIcon:h.jsx(em.Z,{}),onClick:()=>v(!0),disabled:t,children:"Reset World"}),t&&h.jsx(w.Z,{variant:"caption",color:"text.secondary",sx:{ml:2},children:"Stop the server first"})]})]})}),h.jsx(eI,{hasChanges:L,changedCount:P.length,hasRestartChanges:E,restartFields:I,isSaving:r.isPending,onSave:W,onDiscard:N}),h.jsx(eE,{open:C,changedFields:I,onSaveOnly:()=>z(!1),onSaveAndRestart:()=>z(!0),onCancel:()=>j(!1)}),(0,h.jsxs)(M.Z,{open:m,onClose:()=>v(!1),maxWidth:"sm",fullWidth:!0,children:[h.jsx(Z.Z,{children:(0,h.jsxs)(f.Z,{sx:{display:"flex",alignItems:"center",gap:1},children:[h.jsx(ef.Z,{color:"error"}),h.jsx(w.Z,{variant:"h6",fontWeight:600,children:"Reset World"})]})}),(0,h.jsxs)(A.Z,{children:[(0,h.jsxs)(w.Z,{variant:"body1",gutterBottom:!0,children:["This will permanently delete the world for ",h.jsx("strong",{children:e})," and generate a new one."]}),h.jsx(w.Z,{variant:"body2",color:"text.secondary",gutterBottom:!0,children:"This action cannot be undone. All player progress and builds will be lost."}),h.jsx(O.Z,{fullWidth:!0,label:"Type RESET to confirm",value:k,onChange:e=>S(e.target.value),sx:{mt:3},autoFocus:!0})]}),(0,h.jsxs)(T.Z,{children:[h.jsx(p.Z,{onClick:()=>v(!1),children:"Cancel"}),h.jsx(p.Z,{variant:"contained",color:"error",onClick:F,disabled:"RESET"!==k||s.isPending,startIcon:s.isPending?h.jsx(x.Z,{size:16}):h.jsx(ep.Z,{}),children:s.isPending?"Resetting...":"Reset World"})]})]}),h.jsx(eu.Z,{open:D.open,autoHideDuration:6e3,onClose:()=>R({...D,open:!1}),anchorOrigin:{vertical:"bottom",horizontal:"right"},children:h.jsx(g.Z,{onClose:()=>R({...D,open:!1}),severity:D.severity,sx:{width:"100%"},children:D.message})})]})}var eq=i(61573),eK=i(45286),eU=i(59615),e_=i(65757),eG=i(9561),eJ=i(79795);let eX={admin:{label:"Owner",color:"primary",variant:"filled"},manage:{label:"Operator",color:"info",variant:"outlined"},view:{label:"Viewer",color:"default",variant:"outlined"}};function eY({permission:e,size:t="medium"}){let i=eX[e];return h.jsx(F.Z,{label:i.label,color:i.color,variant:i.variant,size:t})}var eQ=i(36885),e0=i(4981),e1=i(30330),e2=i(3693),e5=i(93445),e4=i(98925),e6=i(65806);let e3=e=>{let t=c.useRef({});return c.useEffect(()=>{t.current=e}),t.current};var e8=i(49982),e9=i(39119);function e7(e){return void 0!==e.normalize?e.normalize("NFD").replace(/[\u0300-\u036f]/g,""):e}function te(e,t){for(let i=0;i<e.length;i+=1)if(t(e[i]))return i;return -1}let tt=function(e={}){let{ignoreAccents:t=!0,ignoreCase:i=!0,limit:n,matchFrom:r="any",stringify:s,trim:o=!1}=e;return(e,{inputValue:l,getOptionLabel:a})=>{let h=o?l.trim():l;i&&(h=h.toLowerCase()),t&&(h=e7(h));let c=h?e.filter(e=>{let n=(s||a)(e);return i&&(n=n.toLowerCase()),t&&(n=e7(n)),"start"===r?0===n.indexOf(h):n.indexOf(h)>-1}):e;return"number"==typeof n?c.slice(0,n):c}}(),ti=e=>{var t;return null!==e.current&&(null==(t=e.current.parentElement)?void 0:t.contains(document.activeElement))},tn=[],tr=function(e){let{unstable_isActiveElementInListbox:t=ti,unstable_classNamePrefix:i="Mui",autoComplete:n=!1,autoHighlight:r=!1,autoSelect:s=!1,blurOnSelect:o=!1,clearOnBlur:l=!e.freeSolo,clearOnEscape:a=!1,componentName:h="useAutocomplete",defaultValue:d=e.multiple?tn:null,disableClearable:u=!1,disableCloseOnSelect:f=!1,disabled:p,disabledItemsFocusable:m=!1,disableListWrap:g=!1,filterOptions:x=tt,filterSelectedOptions:v=!1,freeSolo:y=!1,getOptionDisabled:b,getOptionKey:w,getOptionLabel:k=e=>{var t;return null!=(t=e.label)?t:e},groupBy:S,handleHomeEndKeys:C=!e.freeSolo,id:j,includeInputInList:M=!1,inputValue:Z,isOptionEqualToValue:A=(e,t)=>e===t,multiple:T=!1,onChange:O,onClose:D,onHighlightChange:R,onInputChange:P,onOpen:L,open:I,openOnFocus:E=!1,options:B,readOnly:N=!1,selectOnFocus:z=!e.freeSolo,value:W}=e,F=(0,e4.Z)(j),V=k;V=e=>{let t=k(e);return"string"!=typeof t?String(t):t};let H=c.useRef(!1),$=c.useRef(!0),q=c.useRef(null),K=c.useRef(null),[U,_]=c.useState(null),[G,J]=c.useState(-1),X=r?0:-1,Y=c.useRef(X),[Q,ee]=(0,e6.Z)({controlled:W,default:d,name:h}),[et,ei]=(0,e6.Z)({controlled:Z,default:"",name:h,state:"inputValue"}),[en,er]=c.useState(!1),es=c.useCallback((e,t)=>{let i;if((T?Q.length<t.length:null!==t)||l){if(T)i="";else if(null==t)i="";else{let e=V(t);i="string"==typeof e?e:""}et!==i&&(ei(i),P&&P(e,i,"reset"))}},[V,et,T,P,ei,l,Q]),[eo,el]=(0,e6.Z)({controlled:I,default:!1,name:h,state:"open"}),[ea,eh]=c.useState(!0),ec=!T&&null!=Q&&et===V(Q),ed=eo&&!N,eu=ed?x(B.filter(e=>!(v&&(T?Q:[Q]).some(t=>null!==t&&A(e,t)))),{inputValue:ec&&ea?"":et,getOptionLabel:V}):[],ef=e3({filteredOptions:eu,value:Q,inputValue:et});c.useEffect(()=>{let e=Q!==ef.value;(!en||e)&&(!y||e)&&es(null,Q)},[Q,es,en,ef.value,y]);let ep=eo&&eu.length>0&&!N,em=(0,e8.Z)(e=>{-1===e?q.current.focus():U.querySelector(`[data-tag-index="${e}"]`).focus()});c.useEffect(()=>{T&&G>Q.length-1&&(J(-1),em(-1))},[Q,T,G,em]);let eg=(0,e8.Z)(({event:e,index:t,reason:n="auto"})=>{if(Y.current=t,-1===t?q.current.removeAttribute("aria-activedescendant"):q.current.setAttribute("aria-activedescendant",`${F}-option-${t}`),R&&R(e,-1===t?null:eu[t],n),!K.current)return;let r=K.current.querySelector(`[role="option"].${i}-focused`);r&&(r.classList.remove(`${i}-focused`),r.classList.remove(`${i}-focusVisible`));let s=K.current;if("listbox"!==K.current.getAttribute("role")&&(s=K.current.parentElement.querySelector('[role="listbox"]')),!s)return;if(-1===t){s.scrollTop=0;return}let o=K.current.querySelector(`[data-option-index="${t}"]`);if(o&&(o.classList.add(`${i}-focused`),"keyboard"===n&&o.classList.add(`${i}-focusVisible`),s.scrollHeight>s.clientHeight&&"mouse"!==n&&"touch"!==n)){let e=s.clientHeight+s.scrollTop,t=o.offsetTop+o.offsetHeight;t>e?s.scrollTop=t-s.clientHeight:o.offsetTop-o.offsetHeight*(S?1.3:0)<s.scrollTop&&(s.scrollTop=o.offsetTop-o.offsetHeight*(S?1.3:0))}}),ex=(0,e8.Z)(({event:e,diff:t,direction:i="next",reason:r="auto"})=>{if(!ed)return;let s=function(e,t){if(!K.current||e<0||e>=eu.length)return -1;let i=e;for(;;){let n=K.current.querySelector(`[data-option-index="${i}"]`),r=!m&&(!n||n.disabled||"true"===n.getAttribute("aria-disabled"));if(n&&n.hasAttribute("tabindex")&&!r)return i;if((i="next"===t?(i+1)%eu.length:(i-1+eu.length)%eu.length)===e)return -1}}((()=>{let e=eu.length-1;if("reset"===t)return X;if("start"===t)return 0;if("end"===t)return e;let i=Y.current+t;return i<0?-1===i&&M?-1:g&&-1!==Y.current||Math.abs(t)>1?0:e:i>e?i===e+1&&M?-1:g||Math.abs(t)>1?e:0:i})(),i);if(eg({index:s,reason:r,event:e}),n&&"reset"!==t){if(-1===s)q.current.value=et;else{let e=V(eu[s]);q.current.value=e,0===e.toLowerCase().indexOf(et.toLowerCase())&&et.length>0&&q.current.setSelectionRange(et.length,e.length)}}}),ev=()=>{var e;if(-1!==Y.current&&ef.filteredOptions&&ef.filteredOptions.length!==eu.length&&ef.inputValue===et&&(T?Q.length===ef.value.length&&ef.value.every((e,t)=>V(Q[t])===V(e)):((e=ef.value)?V(e):"")===(Q?V(Q):""))){let e=ef.filteredOptions[Y.current];if(e)return te(eu,t=>V(t)===V(e))}return -1},ey=c.useCallback(()=>{if(!ed)return;let e=ev();if(-1!==e){Y.current=e;return}let t=T?Q[0]:Q;if(0===eu.length||null==t){ex({diff:"reset"});return}if(K.current){if(null!=t){let e=eu[Y.current];if(T&&e&&-1!==te(Q,t=>A(e,t)))return;let i=te(eu,e=>A(e,t));-1===i?ex({diff:"reset"}):eg({index:i});return}if(Y.current>=eu.length-1){eg({index:eu.length-1});return}eg({index:Y.current})}},[eu.length,!T&&Q,v,ex,eg,ed,et,T]),eb=(0,e8.Z)(e=>{(0,e9.Z)(K,e),e&&ey()});c.useEffect(()=>{ey()},[ey]);let ew=e=>{!eo&&(el(!0),eh(!0),L&&L(e))},ek=(e,t)=>{eo&&(el(!1),D&&D(e,t))},eS=(e,t,i,n)=>{if(T){if(Q.length===t.length&&Q.every((e,i)=>e===t[i]))return}else if(Q===t)return;O&&O(e,t,i,n),ee(t)},eC=c.useRef(!1),ej=(e,t,i="selectOption",n="options")=>{let r=i,s=t;if(T){let e=te(s=Array.isArray(Q)?Q.slice():[],e=>A(t,e));-1===e?s.push(t):"freeSolo"!==n&&(s.splice(e,1),r="removeOption")}es(e,s),eS(e,s,r,{option:t}),f||e&&(e.ctrlKey||e.metaKey)||ek(e,r),(!0===o||"touch"===o&&eC.current||"mouse"===o&&!eC.current)&&q.current.blur()},eM=(e,t)=>{if(!T)return;""===et&&ek(e,"toggleInput");let i=G;-1===G?""===et&&"previous"===t&&(i=Q.length-1):((i+="next"===t?1:-1)<0&&(i=0),i===Q.length&&(i=-1)),J(i=function(e,t){if(-1===e)return -1;let i=e;for(;;){if("next"===t&&i===Q.length||"previous"===t&&-1===i)return -1;let e=U.querySelector(`[data-tag-index="${i}"]`);if(e&&e.hasAttribute("tabindex")&&!e.disabled&&"true"!==e.getAttribute("aria-disabled"))return i;i+="next"===t?1:-1}}(i,t)),em(i)},eZ=e=>{H.current=!0,ei(""),P&&P(e,"","clear"),eS(e,T?[]:null,"clear")},eA=e=>t=>{if(e.onKeyDown&&e.onKeyDown(t),!t.defaultMuiPrevented&&(-1!==G&&-1===["ArrowLeft","ArrowRight"].indexOf(t.key)&&(J(-1),em(-1)),229!==t.which))switch(t.key){case"Home":ed&&C&&(t.preventDefault(),ex({diff:"start",direction:"next",reason:"keyboard",event:t}));break;case"End":ed&&C&&(t.preventDefault(),ex({diff:"end",direction:"previous",reason:"keyboard",event:t}));break;case"PageUp":t.preventDefault(),ex({diff:-5,direction:"previous",reason:"keyboard",event:t}),ew(t);break;case"PageDown":t.preventDefault(),ex({diff:5,direction:"next",reason:"keyboard",event:t}),ew(t);break;case"ArrowDown":t.preventDefault(),ex({diff:1,direction:"next",reason:"keyboard",event:t}),ew(t);break;case"ArrowUp":t.preventDefault(),ex({diff:-1,direction:"previous",reason:"keyboard",event:t}),ew(t);break;case"ArrowLeft":eM(t,"previous");break;case"ArrowRight":eM(t,"next");break;case"Enter":if(-1!==Y.current&&ed){let e=eu[Y.current],i=!!b&&b(e);if(t.preventDefault(),i)return;ej(t,e,"selectOption"),n&&q.current.setSelectionRange(q.current.value.length,q.current.value.length)}else y&&""!==et&&!1===ec&&(T&&t.preventDefault(),ej(t,et,"createOption","freeSolo"));break;case"Escape":ed?(t.preventDefault(),t.stopPropagation(),ek(t,"escape")):a&&(""!==et||T&&Q.length>0)&&(t.preventDefault(),t.stopPropagation(),eZ(t));break;case"Backspace":if(T&&!N&&""===et&&Q.length>0){let e=-1===G?Q.length-1:G,i=Q.slice();i.splice(e,1),eS(t,i,"removeOption",{option:Q[e]})}break;case"Delete":if(T&&!N&&""===et&&Q.length>0&&-1!==G){let e=Q.slice();e.splice(G,1),eS(t,e,"removeOption",{option:Q[G]})}}},eT=e=>{er(!0),E&&!H.current&&ew(e)},eO=e=>{if(t(K)){q.current.focus();return}er(!1),$.current=!0,H.current=!1,s&&-1!==Y.current&&ed?ej(e,eu[Y.current],"blur"):s&&y&&""!==et?ej(e,et,"blur","freeSolo"):l&&es(e,Q),ek(e,"blur")},eD=e=>{let t=e.target.value;et!==t&&(ei(t),eh(!1),P&&P(e,t,"input")),""===t?u||T||eS(e,null,"clear"):ew(e)},eR=e=>{let t=Number(e.currentTarget.getAttribute("data-option-index"));Y.current!==t&&eg({event:e,index:t,reason:"mouse"})},eP=e=>{eg({event:e,index:Number(e.currentTarget.getAttribute("data-option-index")),reason:"touch"}),eC.current=!0},eL=e=>{let t=Number(e.currentTarget.getAttribute("data-option-index"));ej(e,eu[t],"selectOption"),eC.current=!1},eI=e=>t=>{let i=Q.slice();i.splice(e,1),eS(t,i,"removeOption",{option:Q[e]})},eE=e=>{eo?ek(e,"toggleInput"):ew(e)},eB=e=>{e.currentTarget.contains(e.target)&&e.target.getAttribute("id")!==F&&e.preventDefault()},eN=e=>{e.currentTarget.contains(e.target)&&(q.current.focus(),z&&$.current&&q.current.selectionEnd-q.current.selectionStart==0&&q.current.select(),$.current=!1)},ez=e=>{p||""!==et&&eo||eE(e)},eW=y&&et.length>0;eW=eW||(T?Q.length>0:null!==Q);let eF=eu;return S&&(eF=eu.reduce((e,t,i)=>{let n=S(t);return e.length>0&&e[e.length-1].group===n?e[e.length-1].options.push(t):e.push({key:i,index:i,group:n,options:[t]}),e},[])),p&&en&&eO(),{getRootProps:(e={})=>(0,e0.Z)({"aria-owns":ep?`${F}-listbox`:null},e,{onKeyDown:eA(e),onMouseDown:eB,onClick:eN}),getInputLabelProps:()=>({id:`${F}-label`,htmlFor:F}),getInputProps:()=>({id:F,value:et,onBlur:eO,onFocus:eT,onChange:eD,onMouseDown:ez,"aria-activedescendant":ed?"":null,"aria-autocomplete":n?"both":"list","aria-controls":ep?`${F}-listbox`:void 0,"aria-expanded":ep,autoComplete:"off",ref:q,autoCapitalize:"none",spellCheck:"false",role:"combobox",disabled:p}),getClearProps:()=>({tabIndex:-1,type:"button",onClick:eZ}),getPopupIndicatorProps:()=>({tabIndex:-1,type:"button",onClick:eE}),getTagProps:({index:e})=>(0,e0.Z)({key:e,"data-tag-index":e,tabIndex:-1},!N&&{onDelete:eI(e)}),getListboxProps:()=>({role:"listbox",id:`${F}-listbox`,"aria-labelledby":`${F}-label`,ref:eb,onMouseDown:e=>{e.preventDefault()}}),getOptionProps:({index:e,option:t})=>{var i;let n=(T?Q:[Q]).some(e=>null!=e&&A(t,e)),r=!!b&&b(t);return{key:null!=(i=null==w?void 0:w(t))?i:V(t),tabIndex:-1,role:"option",id:`${F}-option-${e}`,onMouseMove:eR,onClick:eL,onTouchStart:eP,"data-option-index":e,"aria-disabled":r,"aria-selected":n}},id:F,inputValue:et,value:Q,dirty:eW,expanded:ed&&U,popupOpen:ed,focused:en||-1!==G,anchorEl:U,setAnchorEl:_,focusedTag:G,groupedOptions:eF}};var ts=i(75109),to=i(62923),tl=i(9103),ta=i(29251),th=i(89206),tc=i(7967);function td(e){return(0,tc.ZP)("MuiListSubheader",e)}(0,th.Z)("MuiListSubheader",["root","colorPrimary","colorInherit","gutters","inset","sticky"]);let tu=["className","color","component","disableGutters","disableSticky","inset"],tf=e=>{let{classes:t,color:i,disableGutters:n,inset:r,disableSticky:s}=e,o={root:["root","default"!==i&&`color${(0,ta.Z)(i)}`,!n&&"gutters",r&&"inset",!s&&"sticky"]};return(0,e2.Z)(o,td,t)},tp=(0,to.ZP)("li",{name:"MuiListSubheader",slot:"Root",overridesResolver:(e,t)=>{let{ownerState:i}=e;return[t.root,"default"!==i.color&&t[`color${(0,ta.Z)(i.color)}`],!i.disableGutters&&t.gutters,i.inset&&t.inset,!i.disableSticky&&t.sticky]}})(({theme:e,ownerState:t})=>(0,e0.Z)({boxSizing:"border-box",lineHeight:"48px",listStyle:"none",color:(e.vars||e).palette.text.secondary,fontFamily:e.typography.fontFamily,fontWeight:e.typography.fontWeightMedium,fontSize:e.typography.pxToRem(14)},"primary"===t.color&&{color:(e.vars||e).palette.primary.main},"inherit"===t.color&&{color:"inherit"},!t.disableGutters&&{paddingLeft:16,paddingRight:16},t.inset&&{paddingLeft:72},!t.disableSticky&&{position:"sticky",top:0,zIndex:1,backgroundColor:(e.vars||e).palette.background.paper})),tm=c.forwardRef(function(e,t){let i=(0,tl.i)({props:e,name:"MuiListSubheader"}),{className:n,color:r="default",component:s="li",disableGutters:o=!1,disableSticky:l=!1,inset:a=!1}=i,c=(0,eQ.Z)(i,tu),d=(0,e0.Z)({},i,{color:r,component:s,disableGutters:o,disableSticky:l,inset:a}),u=tf(d);return(0,h.jsx)(tp,(0,e0.Z)({as:s,className:(0,e1.Z)(u.root,n),ref:t,ownerState:d},c))});tm.muiSkipListHighlight=!0;var tg=i(52329),tx=i(36633),tv=i(41256),ty=i(58631),tb=i(31506),tw=i(59129),tk=i(31776);function tS(e){return(0,tc.ZP)("MuiAutocomplete",e)}let tC=(0,th.Z)("MuiAutocomplete",["root","expanded","fullWidth","focused","focusVisible","tag","tagSizeSmall","tagSizeMedium","hasPopupIcon","hasClearIcon","inputRoot","input","inputFocused","endAdornment","clearIndicator","popupIndicator","popupIndicatorOpen","popper","popperDisablePortal","paper","listbox","loading","noOptions","option","groupLabel","groupUl"]);var tj=i(69473);let tM=["autoComplete","autoHighlight","autoSelect","blurOnSelect","ChipProps","className","clearIcon","clearOnBlur","clearOnEscape","clearText","closeText","componentsProps","defaultValue","disableClearable","disableCloseOnSelect","disabled","disabledItemsFocusable","disableListWrap","disablePortal","filterOptions","filterSelectedOptions","forcePopupIcon","freeSolo","fullWidth","getLimitTagsText","getOptionDisabled","getOptionKey","getOptionLabel","isOptionEqualToValue","groupBy","handleHomeEndKeys","id","includeInputInList","inputValue","limitTags","ListboxComponent","ListboxProps","loading","loadingText","multiple","noOptionsText","onChange","onClose","onHighlightChange","onInputChange","onOpen","open","openOnFocus","openText","options","PaperComponent","PopperComponent","popupIcon","readOnly","renderGroup","renderInput","renderOption","renderTags","selectOnFocus","size","slotProps","value"],tZ=["ref"],tA=["key"],tT=["key"],tO=e=>{let{classes:t,disablePortal:i,expanded:n,focused:r,fullWidth:s,hasClearIcon:o,hasPopupIcon:l,inputFocused:a,popupOpen:h,size:c}=e,d={root:["root",n&&"expanded",r&&"focused",s&&"fullWidth",o&&"hasClearIcon",l&&"hasPopupIcon"],inputRoot:["inputRoot"],input:["input",a&&"inputFocused"],tag:["tag",`tagSize${(0,ta.Z)(c)}`],endAdornment:["endAdornment"],clearIndicator:["clearIndicator"],popupIndicator:["popupIndicator",h&&"popupIndicatorOpen"],popper:["popper",i&&"popperDisablePortal"],paper:["paper"],listbox:["listbox"],loading:["loading"],noOptions:["noOptions"],option:["option"],groupLabel:["groupLabel"],groupUl:["groupUl"]};return(0,e2.Z)(d,tS,t)},tD=(0,to.ZP)("div",{name:"MuiAutocomplete",slot:"Root",overridesResolver:(e,t)=>{let{ownerState:i}=e,{fullWidth:n,hasClearIcon:r,hasPopupIcon:s,inputFocused:o,size:l}=i;return[{[`& .${tC.tag}`]:t.tag},{[`& .${tC.tag}`]:t[`tagSize${(0,ta.Z)(l)}`]},{[`& .${tC.inputRoot}`]:t.inputRoot},{[`& .${tC.input}`]:t.input},{[`& .${tC.input}`]:o&&t.inputFocused},t.root,n&&t.fullWidth,s&&t.hasPopupIcon,r&&t.hasClearIcon]}})({[`&.${tC.focused} .${tC.clearIndicator}`]:{visibility:"visible"},"@media (pointer: fine)":{[`&:hover .${tC.clearIndicator}`]:{visibility:"visible"}},[`& .${tC.tag}`]:{margin:3,maxWidth:"calc(100% - 6px)"},[`& .${tC.inputRoot}`]:{[`.${tC.hasPopupIcon}&, .${tC.hasClearIcon}&`]:{paddingRight:30},[`.${tC.hasPopupIcon}.${tC.hasClearIcon}&`]:{paddingRight:56},[`& .${tC.input}`]:{width:0,minWidth:30}},[`& .${tx.Z.root}`]:{paddingBottom:1,"& .MuiInput-input":{padding:"4px 4px 4px 0px"}},[`& .${tx.Z.root}.${tv.Z.sizeSmall}`]:{[`& .${tx.Z.input}`]:{padding:"2px 4px 3px 0"}},[`& .${ty.Z.root}`]:{padding:9,[`.${tC.hasPopupIcon}&, .${tC.hasClearIcon}&`]:{paddingRight:39},[`.${tC.hasPopupIcon}.${tC.hasClearIcon}&`]:{paddingRight:65},[`& .${tC.input}`]:{padding:"7.5px 4px 7.5px 5px"},[`& .${tC.endAdornment}`]:{right:9}},[`& .${ty.Z.root}.${tv.Z.sizeSmall}`]:{paddingTop:6,paddingBottom:6,paddingLeft:6,[`& .${tC.input}`]:{padding:"2.5px 4px 2.5px 8px"}},[`& .${tb.Z.root}`]:{paddingTop:19,paddingLeft:8,[`.${tC.hasPopupIcon}&, .${tC.hasClearIcon}&`]:{paddingRight:39},[`.${tC.hasPopupIcon}.${tC.hasClearIcon}&`]:{paddingRight:65},[`& .${tb.Z.input}`]:{padding:"7px 4px"},[`& .${tC.endAdornment}`]:{right:9}},[`& .${tb.Z.root}.${tv.Z.sizeSmall}`]:{paddingBottom:1,[`& .${tb.Z.input}`]:{padding:"2.5px 4px"}},[`& .${tv.Z.hiddenLabel}`]:{paddingTop:8},[`& .${tb.Z.root}.${tv.Z.hiddenLabel}`]:{paddingTop:0,paddingBottom:0,[`& .${tC.input}`]:{paddingTop:16,paddingBottom:17}},[`& .${tb.Z.root}.${tv.Z.hiddenLabel}.${tv.Z.sizeSmall}`]:{[`& .${tC.input}`]:{paddingTop:8,paddingBottom:9}},[`& .${tC.input}`]:{flexGrow:1,textOverflow:"ellipsis",opacity:0},variants:[{props:{fullWidth:!0},style:{width:"100%"}},{props:{size:"small"},style:{[`& .${tC.tag}`]:{margin:2,maxWidth:"calc(100% - 4px)"}}},{props:{inputFocused:!0},style:{[`& .${tC.input}`]:{opacity:1}}},{props:{multiple:!0},style:{[`& .${tC.inputRoot}`]:{flexWrap:"wrap"}}}]}),tR=(0,to.ZP)("div",{name:"MuiAutocomplete",slot:"EndAdornment",overridesResolver:(e,t)=>t.endAdornment})({position:"absolute",right:0,top:"50%",transform:"translate(0, -50%)"}),tP=(0,to.ZP)(m.Z,{name:"MuiAutocomplete",slot:"ClearIndicator",overridesResolver:(e,t)=>t.clearIndicator})({marginRight:-2,padding:4,visibility:"hidden"}),tL=(0,to.ZP)(m.Z,{name:"MuiAutocomplete",slot:"PopupIndicator",overridesResolver:({ownerState:e},t)=>(0,e0.Z)({},t.popupIndicator,e.popupOpen&&t.popupIndicatorOpen)})({padding:2,marginRight:-2,variants:[{props:{popupOpen:!0},style:{transform:"rotate(180deg)"}}]}),tI=(0,to.ZP)(ts.Z,{name:"MuiAutocomplete",slot:"Popper",overridesResolver:(e,t)=>{let{ownerState:i}=e;return[{[`& .${tC.option}`]:t.option},t.popper,i.disablePortal&&t.popperDisablePortal]}})(({theme:e})=>({zIndex:(e.vars||e).zIndex.modal,variants:[{props:{disablePortal:!0},style:{position:"absolute"}}]})),tE=(0,to.ZP)(tg.Z,{name:"MuiAutocomplete",slot:"Paper",overridesResolver:(e,t)=>t.paper})(({theme:e})=>(0,e0.Z)({},e.typography.body1,{overflow:"auto"})),tB=(0,to.ZP)("div",{name:"MuiAutocomplete",slot:"Loading",overridesResolver:(e,t)=>t.loading})(({theme:e})=>({color:(e.vars||e).palette.text.secondary,padding:"14px 16px"})),tN=(0,to.ZP)("div",{name:"MuiAutocomplete",slot:"NoOptions",overridesResolver:(e,t)=>t.noOptions})(({theme:e})=>({color:(e.vars||e).palette.text.secondary,padding:"14px 16px"})),tz=(0,to.ZP)("div",{name:"MuiAutocomplete",slot:"Listbox",overridesResolver:(e,t)=>t.listbox})(({theme:e})=>({listStyle:"none",margin:0,padding:"8px 0",maxHeight:"40vh",overflow:"auto",position:"relative",[`& .${tC.option}`]:{minHeight:48,display:"flex",overflow:"hidden",justifyContent:"flex-start",alignItems:"center",cursor:"pointer",paddingTop:6,boxSizing:"border-box",outline:"0",WebkitTapHighlightColor:"transparent",paddingBottom:6,paddingLeft:16,paddingRight:16,[e.breakpoints.up("sm")]:{minHeight:"auto"},[`&.${tC.focused}`]:{backgroundColor:(e.vars||e).palette.action.hover,"@media (hover: none)":{backgroundColor:"transparent"}},'&[aria-disabled="true"]':{opacity:(e.vars||e).palette.action.disabledOpacity,pointerEvents:"none"},[`&.${tC.focusVisible}`]:{backgroundColor:(e.vars||e).palette.action.focus},'&[aria-selected="true"]':{backgroundColor:e.vars?`rgba(${e.vars.palette.primary.mainChannel} / ${e.vars.palette.action.selectedOpacity})`:(0,e5.Fq)(e.palette.primary.main,e.palette.action.selectedOpacity),[`&.${tC.focused}`]:{backgroundColor:e.vars?`rgba(${e.vars.palette.primary.mainChannel} / calc(${e.vars.palette.action.selectedOpacity} + ${e.vars.palette.action.hoverOpacity}))`:(0,e5.Fq)(e.palette.primary.main,e.palette.action.selectedOpacity+e.palette.action.hoverOpacity),"@media (hover: none)":{backgroundColor:(e.vars||e).palette.action.selected}},[`&.${tC.focusVisible}`]:{backgroundColor:e.vars?`rgba(${e.vars.palette.primary.mainChannel} / calc(${e.vars.palette.action.selectedOpacity} + ${e.vars.palette.action.focusOpacity}))`:(0,e5.Fq)(e.palette.primary.main,e.palette.action.selectedOpacity+e.palette.action.focusOpacity)}}}})),tW=(0,to.ZP)(tm,{name:"MuiAutocomplete",slot:"GroupLabel",overridesResolver:(e,t)=>t.groupLabel})(({theme:e})=>({backgroundColor:(e.vars||e).palette.background.paper,top:-8})),tF=(0,to.ZP)("ul",{name:"MuiAutocomplete",slot:"GroupUl",overridesResolver:(e,t)=>t.groupUl})({padding:0,[`& .${tC.option}`]:{paddingLeft:24}}),tV=c.forwardRef(function(e,t){var i,n,r,l;let a;let d=(0,tl.i)({props:e,name:"MuiAutocomplete"}),{autoComplete:u=!1,autoHighlight:f=!1,autoSelect:p=!1,blurOnSelect:m=!1,ChipProps:g,className:x,clearIcon:v=s||(s=(0,h.jsx)(tw.Z,{fontSize:"small"})),clearOnBlur:y=!d.freeSolo,clearOnEscape:b=!1,clearText:w="Clear",closeText:k="Close",componentsProps:S={},defaultValue:C=d.multiple?[]:null,disableClearable:j=!1,disableCloseOnSelect:M=!1,disabled:Z=!1,disabledItemsFocusable:A=!1,disableListWrap:T=!1,disablePortal:O=!1,filterSelectedOptions:D=!1,forcePopupIcon:R="auto",freeSolo:P=!1,fullWidth:L=!1,getLimitTagsText:I=e=>`+${e}`,getOptionLabel:E,groupBy:B,handleHomeEndKeys:N=!d.freeSolo,includeInputInList:z=!1,limitTags:W=-1,ListboxComponent:V="ul",ListboxProps:H,loading:$=!1,loadingText:q="Loading…",multiple:K=!1,noOptionsText:U="No options",openOnFocus:_=!1,openText:G="Open",PaperComponent:J=tg.Z,PopperComponent:X=ts.Z,popupIcon:Y=o||(o=(0,h.jsx)(tk.Z,{})),readOnly:Q=!1,renderGroup:ee,renderInput:et,renderOption:ei,renderTags:en,selectOnFocus:er=!d.freeSolo,size:es="medium",slotProps:eo={}}=d,el=(0,eQ.Z)(d,tM),{getRootProps:ea,getInputProps:eh,getInputLabelProps:ec,getPopupIndicatorProps:ed,getClearProps:eu,getTagProps:ef,getListboxProps:ep,getOptionProps:em,value:eg,dirty:ex,expanded:ev,id:ey,popupOpen:eb,focused:ew,focusedTag:ek,anchorEl:eS,setAnchorEl:eC,inputValue:ej,groupedOptions:eM}=tr((0,e0.Z)({},d,{componentName:"Autocomplete"})),eZ=!j&&!Z&&ex&&!Q,eA=(!P||!0===R)&&!1!==R,{onMouseDown:eT}=eh(),{ref:eO}=null!=H?H:{},eD=ep(),{ref:eR}=eD,eP=(0,eQ.Z)(eD,tZ),eL=(0,tj.Z)(eR,eO),eI=E||(e=>{var t;return null!=(t=e.label)?t:e}),eE=(0,e0.Z)({},d,{disablePortal:O,expanded:ev,focused:ew,fullWidth:L,getOptionLabel:eI,hasClearIcon:eZ,hasPopupIcon:eA,inputFocused:-1===ek,popupOpen:eb,size:es}),eB=tO(eE);if(K&&eg.length>0){let e=e=>(0,e0.Z)({className:eB.tag,disabled:Z},ef(e));a=en?en(eg,e,eE):eg.map((t,i)=>{let n=e({index:i}),{key:r}=n,s=(0,eQ.Z)(n,tA);return(0,h.jsx)(F.Z,(0,e0.Z)({label:eI(t),size:es},s,g),r)})}if(W>-1&&Array.isArray(a)){let e=a.length-W;!ew&&e>0&&(a=a.splice(0,W)).push((0,h.jsx)("span",{className:eB.tag,children:I(e)},a.length))}let eN=ee||(e=>(0,h.jsxs)("li",{children:[(0,h.jsx)(tW,{className:eB.groupLabel,ownerState:eE,component:"div",children:e.group}),(0,h.jsx)(tF,{className:eB.groupUl,ownerState:eE,children:e.children})]},e.key)),ez=ei||((e,t)=>{let{key:i}=e,n=(0,eQ.Z)(e,tT);return(0,h.jsx)("li",(0,e0.Z)({},n,{children:eI(t)}),i)}),eW=(e,t)=>{let i=em({option:e,index:t});return ez((0,e0.Z)({},i,{className:eB.option}),e,{selected:i["aria-selected"],index:t,inputValue:ej},eE)},eF=null!=(i=eo.clearIndicator)?i:S.clearIndicator,eV=null!=(n=eo.paper)?n:S.paper,eH=null!=(r=eo.popper)?r:S.popper,e$=null!=(l=eo.popupIndicator)?l:S.popupIndicator;return(0,h.jsxs)(c.Fragment,{children:[(0,h.jsx)(tD,(0,e0.Z)({ref:t,className:(0,e1.Z)(eB.root,x),ownerState:eE},ea(el),{children:et({id:ey,disabled:Z,fullWidth:!0,size:"small"===es?"small":void 0,InputLabelProps:ec(),InputProps:(0,e0.Z)({ref:eC,className:eB.inputRoot,startAdornment:a,onClick:e=>{e.target===e.currentTarget&&eT(e)}},(eZ||eA)&&{endAdornment:(0,h.jsxs)(tR,{className:eB.endAdornment,ownerState:eE,children:[eZ?(0,h.jsx)(tP,(0,e0.Z)({},eu(),{"aria-label":w,title:w,ownerState:eE},eF,{className:(0,e1.Z)(eB.clearIndicator,null==eF?void 0:eF.className),children:v})):null,eA?(0,h.jsx)(tL,(0,e0.Z)({},ed(),{disabled:Z,"aria-label":eb?k:G,title:eb?k:G,ownerState:eE},e$,{className:(0,e1.Z)(eB.popupIndicator,null==e$?void 0:e$.className),children:Y})):null]})}),inputProps:(0,e0.Z)({className:eB.input,disabled:Z,readOnly:Q},eh())})})),eS?(0,h.jsx)(tI,(0,e0.Z)({as:X,disablePortal:O,style:{width:eS?eS.clientWidth:null},ownerState:eE,role:"presentation",anchorEl:eS,open:eb},eH,{className:(0,e1.Z)(eB.popper,null==eH?void 0:eH.className),children:(0,h.jsxs)(tE,(0,e0.Z)({ownerState:eE,as:J},eV,{className:(0,e1.Z)(eB.paper,null==eV?void 0:eV.className),children:[$&&0===eM.length?(0,h.jsx)(tB,{className:eB.loading,ownerState:eE,children:q}):null,0!==eM.length||P||$?null:(0,h.jsx)(tN,{className:eB.noOptions,ownerState:eE,role:"presentation",onMouseDown:e=>{e.preventDefault()},children:U}),eM.length>0?(0,h.jsx)(tz,(0,e0.Z)({as:V,className:eB.listbox,ownerState:eE},eP,H,{ref:eL,children:eM.map((e,t)=>B?eN({key:e.key,group:e.group,children:e.options.map((t,i)=>eW(t,e.index+i))}):eW(e,t))})):null]}))})):null]})});var tH=i(99943),t$=i(92241),tq=i(61974),tK=i(28872),tU=i(95343),t_=i(20042),tG=i(43137);function tJ({open:e,onClose:t,serverId:i}){var n;let[r,s]=(0,c.useState)(""),[o,l]=(0,c.useState)(null),[a,d]=(0,c.useState)("view"),{data:u,isLoading:m}=(n={enabled:e},(0,tK.a)({queryKey:["users","search",r],queryFn:()=>(0,tG.SC)(`/api/users?q=${encodeURIComponent(r)}`),enabled:n?.enabled!==!1&&r.length>=2,staleTime:3e4})),v=function(){let e=(0,tU.NL)();return(0,t_.D)({mutationFn:e=>(0,tG.SC)("/api/user-servers",{method:"POST",body:JSON.stringify(e)}),onSuccess:(t,i)=>{e.invalidateQueries({queryKey:["user-servers",i.serverId]}),e.invalidateQueries({queryKey:["user-servers"]})}})}(),y=(0,c.useMemo)(()=>u?.users??[],[u]),b=()=>{s(""),l(null),d("view"),v.reset(),t()};return(0,h.jsxs)(M.Z,{open:e,onClose:b,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderRadius:3}},children:[h.jsx(Z.Z,{sx:{fontWeight:600},children:"Add User Access"}),(0,h.jsxs)(A.Z,{sx:{display:"flex",flexDirection:"column",gap:3,pt:"8px !important"},children:[v.isError&&h.jsx(g.Z,{severity:"error",sx:{mb:1},children:v.error?.message||"Failed to grant access"}),h.jsx(tV,{options:y,getOptionLabel:e=>e.name||e.email,isOptionEqualToValue:(e,t)=>e.id===t.id,value:o,onChange:(e,t)=>l(t),inputValue:r,onInputChange:(e,t)=>s(t),loading:m,filterOptions:e=>e,noOptionsText:r.length<2?"Type at least 2 characters":"No users found",renderInput:e=>h.jsx(O.Z,{...e,label:"Search User",placeholder:"Search by name or email...",InputProps:{...e.InputProps,endAdornment:(0,h.jsxs)(h.Fragment,{children:[m&&h.jsx(x.Z,{size:20}),e.InputProps.endAdornment]})}}),renderOption:(e,t)=>{let{key:i,...n}=e;return(0,h.jsxs)(f.Z,{component:"li",...n,sx:{display:"flex",gap:1.5,py:1},children:[h.jsx(eq.Z,{src:t.image??void 0,sx:{width:32,height:32,bgcolor:"primary.main",fontSize:14},children:(t.name?.[0]||t.email?.[0]||"?").toUpperCase()}),(0,h.jsxs)(f.Z,{children:[h.jsx(w.Z,{variant:"body2",fontWeight:500,children:t.name||"Unknown"}),h.jsx(w.Z,{variant:"caption",color:"text.secondary",children:t.email})]})]},i)}}),(0,h.jsxs)(eM.Z,{children:[h.jsx(tH.Z,{sx:{fontWeight:500,mb:1},children:"Permission Level"}),(0,h.jsxs)(t$.Z,{value:a,onChange:e=>d(e.target.value),children:[h.jsx(eA.Z,{value:"view",control:h.jsx(tq.Z,{size:"small"}),label:(0,h.jsxs)(f.Z,{children:[h.jsx(w.Z,{variant:"body2",fontWeight:500,children:"Viewer"}),h.jsx(w.Z,{variant:"caption",color:"text.secondary",children:"Can view server status and logs"})]})}),h.jsx(eA.Z,{value:"manage",control:h.jsx(tq.Z,{size:"small"}),label:(0,h.jsxs)(f.Z,{children:[h.jsx(w.Z,{variant:"body2",fontWeight:500,children:"Operator"}),h.jsx(w.Z,{variant:"caption",color:"text.secondary",children:"Can start, stop, and configure the server"})]})}),h.jsx(eA.Z,{value:"admin",control:h.jsx(tq.Z,{size:"small"}),label:(0,h.jsxs)(f.Z,{children:[h.jsx(w.Z,{variant:"body2",fontWeight:500,children:"Owner"}),h.jsx(w.Z,{variant:"caption",color:"text.secondary",children:"Full control including managing other users"})]})})]})]})]}),(0,h.jsxs)(T.Z,{sx:{px:3,pb:2},children:[h.jsx(p.Z,{onClick:b,color:"inherit",children:"Cancel"}),h.jsx(p.Z,{onClick:()=>{o&&v.mutate({userId:o.id,serverId:i,permission:a},{onSuccess:b})},variant:"contained",disabled:!o||v.isPending,sx:{borderRadius:2},children:v.isPending?"Adding...":"Add User"})]})]})}function tX({serverId:e}){let{data:t,isLoading:i,error:n}=(0,tK.a)({queryKey:["user-servers",e],queryFn:()=>(0,tG.SC)(`/api/user-servers?serverId=${encodeURIComponent(e)}`),enabled:!!e}),r=function(){let e=(0,tU.NL)();return(0,t_.D)({mutationFn:({id:e,permission:t})=>(0,tG.SC)(`/api/user-servers/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify({permission:t})}),onSuccess:()=>{e.invalidateQueries({queryKey:["user-servers"]})}})}(),s=function(){let e=(0,tU.NL)();return(0,t_.D)({mutationFn:e=>(0,tG.SC)(`/api/user-servers/${encodeURIComponent(e)}`,{method:"DELETE"}),onSuccess:()=>{e.invalidateQueries({queryKey:["user-servers"]})}})}(),[o,l]=(0,c.useState)(!1),[a,d]=(0,c.useState)(null),[u,x]=(0,c.useState)(null),M=(e,t)=>{d(e.currentTarget),x(t)},Z=()=>{d(null),x(null)},A=e=>{if(!u||u.permission===e){Z();return}r.mutate({id:u.id,permission:e},{onSettled:Z})},T=t?.users.filter(e=>"admin"===e.permission).length??0,O=u?.permission==="admin"&&T<=1;if(i)return h.jsx(y.Z,{sx:{borderRadius:3},children:(0,h.jsxs)(b.Z,{children:[(0,h.jsxs)(f.Z,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:2},children:[h.jsx(v.Z,{variant:"text",width:"30%",height:32}),h.jsx(v.Z,{variant:"rounded",width:120,height:36,sx:{borderRadius:2}})]}),h.jsx(H.Z,{sx:{mb:2}}),[0,1,2].map(e=>(0,h.jsxs)(f.Z,{sx:{display:"flex",alignItems:"center",gap:2,py:1.5,borderBottom:"1px solid",borderColor:"divider"},children:[h.jsx(v.Z,{variant:"circular",width:40,height:40}),(0,h.jsxs)(f.Z,{sx:{flex:1},children:[h.jsx(v.Z,{variant:"text",width:"40%"}),h.jsx(v.Z,{variant:"text",width:"60%"})]}),h.jsx(v.Z,{variant:"rounded",width:80,height:28,sx:{borderRadius:10}}),h.jsx(v.Z,{variant:"circular",width:32,height:32})]},e))]})});if(n)return(0,h.jsxs)(g.Z,{severity:"error",children:["Failed to load access list: ",n.message]});let D=t?.users??[];return(0,h.jsxs)(h.Fragment,{children:[h.jsx(y.Z,{sx:{borderRadius:3},children:(0,h.jsxs)(b.Z,{children:[(0,h.jsxs)(f.Z,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:2},children:[h.jsx(w.Z,{variant:"h6",fontWeight:600,children:"Server Access"}),h.jsx(p.Z,{variant:"contained",size:"small",startIcon:h.jsx(eK.Z,{}),onClick:()=>l(!0),sx:{borderRadius:2},children:"Add User"})]}),h.jsx(H.Z,{sx:{mb:1}}),0===D.length?h.jsx(f.Z,{sx:{py:4,textAlign:"center"},children:h.jsx(w.Z,{variant:"body2",color:"text.secondary",children:"No users have been granted access to this server yet."})}):D.map(e=>(0,h.jsxs)(f.Z,{sx:{display:"flex",alignItems:"center",gap:2,py:1.5,"&:not(:last-child)":{borderBottom:"1px solid",borderColor:"divider"}},children:[h.jsx(eq.Z,{src:e.user?.image??void 0,sx:{width:40,height:40,bgcolor:"primary.main",fontSize:16},children:(e.user?.name?.[0]||e.user?.email?.[0]||"?").toUpperCase()}),(0,h.jsxs)(f.Z,{sx:{flex:1,minWidth:0},children:[h.jsx(w.Z,{variant:"body2",fontWeight:500,noWrap:!0,children:e.user?.name||"Unknown User"}),h.jsx(w.Z,{variant:"caption",color:"text.secondary",noWrap:!0,children:e.user?.email||e.userId})]}),h.jsx(eY,{permission:e.permission,size:"small"}),h.jsx(m.Z,{size:"small",onClick:t=>M(t,e),sx:{color:"text.secondary"},children:h.jsx(I.Z,{fontSize:"small"})})]},e.id)),(0,h.jsxs)(f.Z,{sx:{display:"flex",alignItems:"center",gap:1,mt:2,pt:1},children:[h.jsx(eJ.Z,{sx:{fontSize:16,color:"text.disabled"}}),h.jsx(w.Z,{variant:"caption",color:"text.disabled",children:"Only platform admins and server owners can manage access."})]})]})}),(0,h.jsxs)(k.Z,{anchorEl:a,open:!!a,onClose:Z,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},disableScrollLock:!0,children:[(0,h.jsxs)(S.Z,{onClick:()=>A("admin"),disabled:u?.permission==="admin",children:[h.jsx(C.Z,{children:h.jsx(eU.Z,{fontSize:"small"})}),h.jsx(j.Z,{children:"Change to Owner"})]}),(0,h.jsxs)(S.Z,{onClick:()=>A("manage"),disabled:u?.permission==="manage"||O,children:[h.jsx(C.Z,{children:h.jsx(e_.Z,{fontSize:"small"})}),h.jsx(j.Z,{children:"Change to Operator"})]}),(0,h.jsxs)(S.Z,{onClick:()=>A("view"),disabled:u?.permission==="view"||O,children:[h.jsx(C.Z,{children:h.jsx(eO.Z,{fontSize:"small"})}),h.jsx(j.Z,{children:"Change to Viewer"})]}),h.jsx(H.Z,{}),(0,h.jsxs)(S.Z,{onClick:()=>{u&&s.mutate(u.id,{onSettled:Z})},disabled:O,sx:{color:"error.main"},children:[h.jsx(C.Z,{children:h.jsx(eG.Z,{fontSize:"small",sx:{color:"error.main"}})}),h.jsx(j.Z,{children:"Remove Access"})]})]}),h.jsx(tJ,{open:o,onClose:()=>l(!1),serverId:e})]})}var tY=i(15934),tQ=i(73802);function t0({label:e,value:t,copyText:i}){return(0,h.jsxs)(f.Z,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",py:1},children:[h.jsx(w.Z,{variant:"body2",color:"text.secondary",children:e}),(0,h.jsxs)(f.Z,{sx:{display:"flex",alignItems:"center"},children:[h.jsx(w.Z,{variant:"body2",sx:{color:i?"text.primary":"text.secondary",wordBreak:"break-all"},children:t}),i&&h.jsx(tQ.q,{text:i,size:16})]})]})}function t1({serverName:e,hostname:t}){let{data:i,isLoading:n}=(0,tY.UW)();if(n)return h.jsx(y.Z,{sx:{borderRadius:3},children:(0,h.jsxs)(b.Z,{children:[h.jsx(v.Z,{variant:"text",width:"40%",height:28,sx:{mb:1}}),h.jsx(v.Z,{variant:"rectangular",height:1,sx:{mb:2}}),(0,h.jsxs)(f.Z,{sx:{display:"flex",justifyContent:"space-between",py:1},children:[h.jsx(v.Z,{variant:"text",width:"30%"}),h.jsx(v.Z,{variant:"text",width:"40%"})]}),(0,h.jsxs)(f.Z,{sx:{display:"flex",justifyContent:"space-between",py:1},children:[h.jsx(v.Z,{variant:"text",width:"30%"}),h.jsx(v.Z,{variant:"text",width:"40%"})]})]})});let r=i?.enabled&&i.servers.length>0,s=i?.servers.find(t=>t.serverName===e),o=s?.playitDomain||"Not configured",l=!!s?.playitDomain;return h.jsx(y.Z,{sx:{borderRadius:3},children:(0,h.jsxs)(b.Z,{children:[h.jsx(w.Z,{variant:"h6",gutterBottom:!0,fontWeight:600,children:"Connection"}),h.jsx(H.Z,{sx:{mb:2}}),(0,h.jsxs)(f.Z,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",py:1,gap:1},children:[h.jsx(w.Z,{variant:"body2",color:"text.secondary",sx:{flexShrink:0},children:"LAN Address"}),t?h.jsx(f.Z,{sx:{minWidth:0},children:h.jsx(tQ.h,{hostname:t,portSuffix:25565,color:"text.primary",showCopyButton:!0})}):h.jsx(w.Z,{variant:"body2",color:"text.secondary",children:"Not configured"})]}),r&&h.jsx(t0,{label:"External Address",value:o,copyText:l?o:void 0})]})})}var t2=i(96468),t5=i(50582),t4=i(86202);function t6({serverName:e}){let{data:t,isLoading:i,error:n}=(0,tK.a)({queryKey:["servers",e,"mods"],queryFn:()=>(0,tG.SC)(`/api/servers/${encodeURIComponent(e)}/mods`),enabled:!!e}),r=function(){let e=(0,tU.NL)();return(0,t_.D)({mutationFn:({serverName:e,slugs:t,source:i})=>(0,tG.SC)(`/api/servers/${encodeURIComponent(e)}/mods`,{method:"POST",body:JSON.stringify({slugs:t,source:i})}),onSuccess:(t,{serverName:i})=>{e.invalidateQueries({queryKey:["servers",i,"mods"]})}})}(),s=function(){let e=(0,tU.NL)();return(0,t_.D)({mutationFn:({serverName:e,slug:t})=>(0,tG.SC)(`/api/servers/${encodeURIComponent(e)}/mods/${encodeURIComponent(t)}`,{method:"DELETE"}),onSuccess:(t,{serverName:i})=>{e.invalidateQueries({queryKey:["servers",i,"mods"]})}})}(),[o,l]=(0,c.useState)(!1),[a,d]=(0,c.useState)(""),[u,v]=(0,c.useState)(""),[k,S]=(0,c.useState)(!1),[C,j]=(0,c.useState)({open:!1,message:"",severity:"info"}),{data:T,isLoading:D}=function(e,t){let i=new URLSearchParams;return e&&i.set("q",e),t?.limit!=null&&i.set("limit",String(t.limit)),t?.offset!=null&&i.set("offset",String(t.offset)),(0,tK.a)({queryKey:["mods","search",e,t?.limit,t?.offset],queryFn:()=>(0,tG.SC)(`/api/mods/search?${i}`),enabled:t?.enabled!==!1&&!!e.trim()})}(u,{limit:10,enabled:o&&u.length>0}),R=(0,c.useCallback)(async t=>{try{await s.mutateAsync({serverName:e,slug:t}),S(!0),j({open:!0,message:`Removed ${t}`,severity:"success"})}catch(e){j({open:!0,message:e instanceof Error?e.message:"Failed to remove mod",severity:"error"})}},[s,e]),P=(0,c.useCallback)(async t=>{try{await r.mutateAsync({serverName:e,slugs:[t]}),S(!0),j({open:!0,message:`Added ${t}`,severity:"success"})}catch(e){j({open:!0,message:e instanceof Error?e.message:"Failed to add mod",severity:"error"})}},[r,e]),L=new Set;if(t?.mods)for(let e of Object.values(t.mods))for(let t of e)L.add(t);if(i)return h.jsx(f.Z,{sx:{display:"flex",justifyContent:"center",py:6},children:h.jsx(x.Z,{})});if(n)return(0,h.jsxs)(g.Z,{severity:"error",sx:{mt:2},children:["Failed to load mods: ",n.message]});let I=L.size>0;return(0,h.jsxs)(f.Z,{children:[k&&h.jsx(g.Z,{severity:"info",sx:{mb:2},children:"Restart the server to apply mod changes."}),h.jsx(y.Z,{sx:{borderRadius:3},children:(0,h.jsxs)(b.Z,{children:[(0,h.jsxs)(f.Z,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:2},children:[h.jsx(w.Z,{variant:"h6",fontWeight:600,children:"Installed Mods"}),h.jsx(p.Z,{variant:"contained",size:"small",startIcon:h.jsx(ey.Z,{}),onClick:()=>{d(""),v(""),l(!0)},children:"Add Mods"})]}),h.jsx(H.Z,{sx:{mb:2}}),I?Object.entries(t.mods).map(([e,t])=>(0,h.jsxs)(f.Z,{sx:{mb:2},children:[h.jsx(w.Z,{variant:"subtitle2",color:"text.secondary",sx:{mb:1,textTransform:"capitalize"},children:e}),h.jsx(f.Z,{sx:{display:"flex",flexWrap:"wrap",gap:1},children:t.map(e=>h.jsx(F.Z,{label:e,icon:h.jsx(t5.Z,{}),onDelete:()=>R(e),deleteIcon:h.jsx(E.Z,{}),variant:"outlined"},e))})]},e)):(0,h.jsxs)(f.Z,{sx:{textAlign:"center",py:4},children:[h.jsx(t5.Z,{sx:{fontSize:48,color:"text.disabled",mb:1}}),h.jsx(w.Z,{variant:"body1",color:"text.secondary",children:"No mods installed"}),h.jsx(w.Z,{variant:"body2",color:"text.disabled",sx:{mt:.5},children:'Click "Add Mods" to search and install mods from Modrinth'})]})]})}),(0,h.jsxs)(M.Z,{open:o,onClose:()=>l(!1),maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{minHeight:400}},children:[(0,h.jsxs)(Z.Z,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:["Search Mods",h.jsx(m.Z,{onClick:()=>l(!1),size:"small",children:h.jsx(K.Z,{})})]}),(0,h.jsxs)(A.Z,{children:[h.jsx(O.Z,{fullWidth:!0,autoFocus:!0,placeholder:"Search Modrinth...",value:a,onChange:e=>d(e.target.value),InputProps:{startAdornment:h.jsx(V.Z,{position:"start",children:h.jsx(t2.Z,{})})},sx:{mb:2}}),D&&h.jsx(f.Z,{sx:{display:"flex",justifyContent:"center",py:4},children:h.jsx(x.Z,{size:28})}),!D&&T&&0===T.hits.length&&u&&(0,h.jsxs)(w.Z,{variant:"body2",color:"text.secondary",sx:{textAlign:"center",py:4},children:['No mods found for "',u,'"']}),!D&&T&&T.hits.length>0&&h.jsx(f.Z,{sx:{display:"flex",flexDirection:"column",gap:1.5},children:T.hits.map(e=>{var t;let i=L.has(e.slug);return h.jsx(y.Z,{variant:"outlined",sx:{borderRadius:2},children:h.jsx(b.Z,{sx:{py:1.5,px:2,"&:last-child":{pb:1.5}},children:(0,h.jsxs)(f.Z,{sx:{display:"flex",gap:1.5,alignItems:"flex-start"},children:[h.jsx(eq.Z,{src:e.iconUrl||void 0,variant:"rounded",sx:{width:40,height:40,bgcolor:"action.hover"},children:h.jsx(t5.Z,{})}),(0,h.jsxs)(f.Z,{sx:{flex:1,minWidth:0},children:[(0,h.jsxs)(f.Z,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[h.jsx(w.Z,{variant:"subtitle2",noWrap:!0,children:e.title}),h.jsx(p.Z,{size:"small",variant:i?"outlined":"contained",disabled:i||r.isPending,onClick:()=>P(e.slug),sx:{ml:1,minWidth:80,flexShrink:0},children:i?"Installed":"Add"})]}),h.jsx(w.Z,{variant:"body2",color:"text.secondary",sx:{mt:.25,overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical"},children:e.description}),(0,h.jsxs)(f.Z,{sx:{display:"flex",alignItems:"center",gap:1,mt:.5},children:[(0,h.jsxs)(f.Z,{sx:{display:"flex",alignItems:"center",gap:.25},children:[h.jsx(t4.Z,{sx:{fontSize:14,color:"text.disabled"}}),h.jsx(w.Z,{variant:"caption",color:"text.disabled",children:(t=e.downloads)>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:String(t)})]}),e.author&&(0,h.jsxs)(w.Z,{variant:"caption",color:"text.disabled",children:["by ",e.author]})]})]})]})})},e.slug)})})]})]}),h.jsx(eu.Z,{open:C.open,autoHideDuration:4e3,onClose:()=>j(e=>({...e,open:!1})),anchorOrigin:{vertical:"bottom",horizontal:"center"},children:h.jsx(g.Z,{onClose:()=>j(e=>({...e,open:!1})),severity:C.severity,variant:"filled",children:C.message})})]})}function t3(e,t){return(0,tK.a)({queryKey:["servers",e,"files","content",t],queryFn:()=>{let i=new URLSearchParams({path:t});return(0,tG.SC)(`/api/servers/${encodeURIComponent(e)}/files/read?${i}`)},enabled:!!e&&!!t})}function t8(e){let t=(0,tU.NL)();return(0,t_.D)({mutationFn:({path:t,content:i})=>{let n=new URLSearchParams({path:t});return(0,tG.SC)(`/api/servers/${encodeURIComponent(e)}/files/write?${n}`,{method:"PUT",body:JSON.stringify({content:i})})},onSuccess:()=>{t.invalidateQueries({queryKey:["servers",e,"files"]})}})}var t9=i(98898),t7=i(42578),ie=i(31620);function it({path:e,onNavigate:t}){let i=e.split("/").filter(Boolean);return(0,h.jsxs)(t9.Z,{sx:{mb:1},children:[(0,h.jsxs)(t7.Z,{component:"button",underline:"hover",color:"inherit",onClick:()=>t("/"),sx:{display:"flex",alignItems:"center",gap:.5,cursor:"pointer"},children:[h.jsx(ie.Z,{sx:{fontSize:18}}),"root"]}),i.map((e,n)=>{let r=n===i.length-1,s="/"+i.slice(0,n+1).join("/");return r?h.jsx(w.Z,{color:"text.primary",sx:{fontWeight:500},children:e},s):h.jsx(t7.Z,{component:"button",underline:"hover",color:"inherit",onClick:()=>t(s),sx:{cursor:"pointer"},children:e},s)})]})}var ii=i(10937),ir=i(66831),is=i(80403);let io=/[/\\]/,il=/\.\./;function ia({open:e,existingNames:t,isPending:i,onConfirm:n,onClose:r}){let[s,o]=(0,c.useState)(""),l=(0,c.useMemo)(()=>s.trim()?io.test(s)?"Name cannot contain / or \\":il.test(s)?'Name cannot contain ".."':s.startsWith(".")?'Name cannot start with "."':null:"Folder name cannot be empty",[s]),a=(0,c.useMemo)(()=>t.some(e=>e.toLowerCase()===s.trim().toLowerCase()),[s,t]),d=!l&&!a&&!!s.trim(),u=(0,c.useCallback)(()=>{d&&(n(s.trim()),o(""))},[d,s,n]),f=(0,c.useCallback)(()=>{o(""),r()},[r]);return(0,h.jsxs)(M.Z,{open:e,onClose:f,maxWidth:"xs",fullWidth:!0,children:[h.jsx(Z.Z,{children:"Create New Folder"}),h.jsx(A.Z,{children:h.jsx(O.Z,{autoFocus:!0,fullWidth:!0,label:"Folder name",value:s,onChange:e=>o(e.target.value),onKeyDown:e=>"Enter"===e.key&&u(),error:!!l&&s.length>0||a,helperText:s.length>0&&l||(a?`"${s.trim()}" already exists`:void 0),sx:{mt:1}})}),(0,h.jsxs)(T.Z,{children:[h.jsx(p.Z,{onClick:f,children:"Cancel"}),h.jsx(p.Z,{onClick:u,variant:"contained",disabled:i||!d,children:"Create"})]})]})}function ih({searchQuery:e,onSearchChange:t,onCreateFolder:i,onUpload:n,onRefresh:r,existingNames:s,disabled:o}){let[l,a]=(0,c.useState)(!1);return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(f.Z,{sx:{display:"flex",gap:1,alignItems:"center",mb:2,flexWrap:"wrap"},children:[h.jsx(O.Z,{size:"small",placeholder:"Search files...",value:e,onChange:e=>t(e.target.value),InputProps:{startAdornment:h.jsx(V.Z,{position:"start",children:h.jsx(t2.Z,{sx:{fontSize:20,color:"text.secondary"}})})},sx:{minWidth:200,flex:{xs:"1 1 100%",sm:"0 1 auto"}}}),(0,h.jsxs)(f.Z,{sx:{display:"flex",gap:1,ml:"auto"},children:[h.jsx(p.Z,{size:"small",startIcon:h.jsx(is.Z,{}),onClick:n,disabled:o,children:"Upload"}),h.jsx(p.Z,{size:"small",startIcon:h.jsx(ii.Z,{}),onClick:()=>a(!0),disabled:o,children:"New Folder"}),h.jsx(p.Z,{size:"small",startIcon:h.jsx(ir.Z,{}),onClick:r,disabled:o,children:"Refresh"})]})]}),h.jsx(ia,{open:l,existingNames:s,isPending:!!o,onConfirm:e=>{i(e),a(!1)},onClose:()=>a(!1)})]})}var ic=i(37891),id=i(88916),iu=i(75698),ip=i(664),im=i(70862),ig=i(59059),ix=i(19103),iv=i(15348),iy=i(61872),ib=i(54896),iw=i(26567),ik=i(75569),iS=i(97441),iC=i(27429),ij=i(92058);function iM(e){return["yml","yaml","json","properties","toml","cfg","conf","ini","txt","md","log","xml","sh","bat","csv"].includes(e.split(".").pop()?.toLowerCase()||"")}function iZ({file:e,currentPath:t,onNavigate:i,onAction:n}){var r;let[s,o]=(0,c.useState)(null),l=()=>{"directory"===e.type?i("/"===t?`/${e.name}`:`${t}/${e.name}`):iM(e.name)&&n("open")};return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(ig.Z,{hover:!0,sx:{cursor:"directory"===e.type||iM(e.name)?"pointer":"default"},onClick:l,children:[h.jsx(iu.Z,{children:(0,h.jsxs)(f.Z,{sx:{display:"flex",alignItems:"center",gap:1},children:[function(e){if("directory"===e.type)return h.jsx(ix.Z,{sx:{color:"#FFB74D"}});let t=e.name.split(".").pop()?.toLowerCase()||"";return["yml","yaml","json","properties","toml","cfg","conf","ini","txt","md"].includes(t)?h.jsx(iy.Z,{sx:{color:"#42A5F5"}}):"jar"===t?h.jsx(ib.Z,{sx:{color:"#AB47BC"}}):"log"===t?h.jsx(iw.Z,{sx:{color:"#78909C"}}):["dat","dat_old","mca","nbt","lock"].includes(t)?h.jsx(ik.Z,{sx:{color:"#8D6E63"}}):h.jsx(iv.Z,{sx:{color:"#90A4AE"}})}(e),h.jsx(w.Z,{variant:"body2",sx:{fontWeight:"directory"===e.type?500:400,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.name})]})}),h.jsx(iu.Z,{sx:{display:{xs:"none",sm:"table-cell"}},children:h.jsx(w.Z,{variant:"body2",color:"text.secondary",children:"directory"===e.type?"-":0===(r=e.size)?"-":r<1024?`${r} B`:r<1048576?`${(r/1024).toFixed(1)} KB`:r<1073741824?`${(r/1024/1024).toFixed(1)} MB`:`${(r/1024/1024/1024).toFixed(1)} GB`})}),h.jsx(iu.Z,{sx:{display:{xs:"none",md:"table-cell"}},children:h.jsx(w.Z,{variant:"body2",color:"text.secondary",children:new Date(e.modifiedAt).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})})}),h.jsx(iu.Z,{children:h.jsx(m.Z,{size:"small",onClick:e=>{e.stopPropagation(),o(e.currentTarget)},children:h.jsx(I.Z,{fontSize:"small"})})})]}),(0,h.jsxs)(k.Z,{anchorEl:s,open:!!s,onClose:()=>o(null),children:["directory"===e.type&&(0,h.jsxs)(S.Z,{onClick:()=>{o(null),l()},children:[h.jsx(C.Z,{children:h.jsx(iS.Z,{fontSize:"small"})}),h.jsx(j.Z,{children:"Open"})]}),"file"===e.type&&iM(e.name)&&(0,h.jsxs)(S.Z,{onClick:()=>{o(null),n("open")},children:[h.jsx(C.Z,{children:h.jsx(iC.Z,{fontSize:"small"})}),h.jsx(j.Z,{children:"Edit"})]}),"file"===e.type&&(0,h.jsxs)(S.Z,{onClick:()=>{o(null),n("download")},children:[h.jsx(C.Z,{children:h.jsx(t4.Z,{fontSize:"small"})}),h.jsx(j.Z,{children:"Download"})]}),(0,h.jsxs)(S.Z,{onClick:()=>{o(null),n("rename")},children:[h.jsx(C.Z,{children:h.jsx(ij.Z,{fontSize:"small"})}),h.jsx(j.Z,{children:"Rename"})]}),(0,h.jsxs)(S.Z,{onClick:()=>{o(null),n("delete")},sx:{color:"error.main"},children:[h.jsx(C.Z,{children:h.jsx(E.Z,{fontSize:"small",color:"error"})}),h.jsx(j.Z,{children:"Delete"})]})]})]})}function iA({files:e,currentPath:t,onNavigate:i,onFileAction:n,searchQuery:r}){let s=r?e.filter(e=>e.name.toLowerCase().includes(r.toLowerCase())):e;return 0===s.length?(0,h.jsxs)(f.Z,{sx:{textAlign:"center",py:6},children:[h.jsx(ix.Z,{sx:{fontSize:48,color:"text.disabled",mb:1}}),h.jsx(w.Z,{variant:"body1",color:"text.secondary",children:r?"No matching files found":"This directory is empty"})]}):h.jsx(ip.Z,{children:(0,h.jsxs)(ic.Z,{size:"small",children:[h.jsx(im.Z,{children:(0,h.jsxs)(ig.Z,{children:[h.jsx(iu.Z,{sx:{fontWeight:600},children:"Name"}),h.jsx(iu.Z,{sx:{fontWeight:600,width:100,display:{xs:"none",sm:"table-cell"}},children:"Size"}),h.jsx(iu.Z,{sx:{fontWeight:600,width:160,display:{xs:"none",md:"table-cell"}},children:"Modified"}),h.jsx(iu.Z,{sx:{width:48}})]})}),h.jsx(id.Z,{children:s.map(e=>h.jsx(iZ,{file:e,currentPath:t,onNavigate:i,onAction:t=>n(t,e)},e.name))})]})})}function iT({language:e,fileSize:t,line:i,col:n,dirty:r}){return(0,h.jsxs)(f.Z,{sx:{display:"flex",alignItems:"center",gap:2,px:2,py:.5,bgcolor:"grey.100",borderTop:1,borderColor:"divider",fontSize:"0.75rem",color:"text.secondary",flexWrap:"wrap",minHeight:28},children:[h.jsx(w.Z,{variant:"caption",sx:{fontWeight:500},children:e}),h.jsx(w.Z,{variant:"caption",children:t<1024?`${t} B`:t<1048576?`${(t/1024).toFixed(1)} KB`:`${(t/1024/1024).toFixed(1)} MB`}),h.jsx(w.Z,{variant:"caption",children:"UTF-8"}),(0,h.jsxs)(w.Z,{variant:"caption",children:["Ln ",i,", Col ",n]}),h.jsx(f.Z,{sx:{flex:1}}),r&&h.jsx(w.Z,{variant:"caption",sx:{color:"warning.main",fontWeight:600},children:"Modified"})]})}function iO({serverName:e,filePath:t,onBack:i}){let n=(0,c.useRef)(null),r=(0,c.useRef)(null),[s,o]=(0,c.useState)(!1),[l,a]=(0,c.useState)({line:1,col:1}),[d,u]=(0,c.useState)(!1),v=t.split("/").pop()||"",{data:k,isLoading:S,error:C}=t3(e,t),j=t8(e),Z=(0,c.useCallback)(()=>{if(!r.current||!t)return;let e=r.current.state.doc.toString();j.mutate({path:t,content:e},{onSuccess:()=>o(!1)})},[t,j]),A=(0,c.useCallback)(()=>{s?u(!0):i()},[s,i]),T=(0,c.useCallback)(()=>{u(!1),o(!1),i()},[i]),O=k&&k.size>5242880;return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(y.Z,{sx:{borderRadius:3,display:"flex",flexDirection:"column",minHeight:600},children:[(0,h.jsxs)(f.Z,{sx:{display:"flex",alignItems:"center",gap:1,px:2,py:1,borderBottom:1,borderColor:"divider"},children:[h.jsx(m.Z,{size:"small",onClick:A,"aria-label":"back",children:h.jsx(P.Z,{})}),h.jsx(iy.Z,{sx:{color:"primary.main"}}),(0,h.jsxs)(w.Z,{variant:"subtitle1",sx:{fontWeight:600,flex:1},noWrap:!0,children:[v,s&&" *"]}),h.jsx(p.Z,{size:"small",variant:"contained",startIcon:j.isPending?h.jsx(x.Z,{size:16,color:"inherit"}):h.jsx(eb.Z,{}),onClick:Z,disabled:!s||j.isPending,children:"Save"})]}),(0,h.jsxs)(b.Z,{sx:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden",p:0,"&:last-child":{pb:0}},children:[S&&h.jsx(f.Z,{sx:{display:"flex",justifyContent:"center",alignItems:"center",flex:1},children:h.jsx(x.Z,{})}),C&&(0,h.jsxs)(g.Z,{severity:"error",sx:{m:2},children:["Failed to load file: ",C.message]}),O&&(0,h.jsxs)(g.Z,{severity:"warning",sx:{m:2},children:["This file is too large to edit (",(k.size/1024/1024).toFixed(1)," MB). Maximum editable size is 5 MB."]}),j.isError&&(0,h.jsxs)(g.Z,{severity:"error",sx:{m:2},children:["Failed to save: ",j.error.message]}),j.isSuccess&&!s&&h.jsx(g.Z,{severity:"success",sx:{m:2},children:"File saved successfully."}),k&&!O&&h.jsx(f.Z,{ref:n,sx:{flex:1,overflow:"hidden"}}),k&&!O&&h.jsx(iT,{language:{json:"JSON",yml:"YAML",yaml:"YAML",xml:"XML",html:"HTML",properties:"Properties",toml:"TOML",cfg:"Config",conf:"Config",ini:"INI",txt:"Plain Text",md:"Markdown",log:"Log",sh:"Shell",bat:"Batch",csv:"CSV"}[v.split(".").pop()?.toLowerCase()||""]||"Plain Text",fileSize:k.size,line:l.line,col:l.col,dirty:s})]})]}),h.jsx(M.Z,{open:d,onClose:()=>u(!1),maxWidth:"xs",fullWidth:!0,children:(0,h.jsxs)(f.Z,{sx:{p:3},children:[h.jsx(w.Z,{variant:"h6",gutterBottom:!0,children:"Unsaved Changes"}),(0,h.jsxs)(w.Z,{variant:"body2",color:"text.secondary",sx:{mb:3},children:["You have unsaved changes in ",h.jsx("strong",{children:v}),". Do you want to discard them?"]}),(0,h.jsxs)(f.Z,{sx:{display:"flex",justifyContent:"flex-end",gap:1},children:[h.jsx(p.Z,{onClick:()=>u(!1),children:"Cancel"}),h.jsx(p.Z,{onClick:T,color:"error",variant:"contained",children:"Discard"})]})]})})]})}var iD=i(54458);let iR=new Set(["world","world_nether","world_the_end","server.jar","server.properties","plugins","mods"]);function iP({target:e,isPending:t,onConfirm:i,onClose:n}){var r;let[s,o]=(0,c.useState)(""),l=!!e&&(r=e.name,iR.has(r.toLowerCase())),a=e?.type==="directory",d=!l||s===e?.name,u=(0,c.useCallback)(()=>{d&&i()},[d,i]);return(0,h.jsxs)(M.Z,{open:!!e,onClose:n,maxWidth:"xs",fullWidth:!0,children:[(0,h.jsxs)(Z.Z,{children:["Delete ",a?"Folder":"File"]}),(0,h.jsxs)(A.Z,{children:[(0,h.jsxs)(iD.Z,{children:["Are you sure you want to delete ",h.jsx("strong",{children:e?.name}),"?",a&&" This will delete all contents inside."," ","This action cannot be undone."]}),l&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(g.Z,{severity:"warning",sx:{mt:2},children:[h.jsx("strong",{children:e?.name})," is a critical server ",a?"folder":"file",". Deleting it may break your server."]}),h.jsx(O.Z,{autoFocus:!0,fullWidth:!0,label:`Type "${e?.name}" to confirm`,value:s,onChange:e=>o(e.target.value),onKeyDown:e=>"Enter"===e.key&&u(),placeholder:e?.name,sx:{mt:2},error:s.length>0&&s!==e?.name})]})]}),(0,h.jsxs)(T.Z,{children:[h.jsx(p.Z,{onClick:n,children:"Cancel"}),h.jsx(p.Z,{onClick:u,color:"error",variant:"contained",disabled:t||!d,children:"Delete"})]})]})}let iL=/[/\\]/,iI=/\.\./;function iE(e){let t=e.lastIndexOf(".");return t>0?e.slice(t):""}function iB({target:e,existingNames:t,isPending:i,onConfirm:n,onClose:r}){let[s,o]=(0,c.useState)(""),l=(0,c.useMemo)(()=>s.trim()?iL.test(s)?"Name cannot contain / or \\":iI.test(s)?'Name cannot contain ".."':s.startsWith(".")?'Name cannot start with "."':null:"Name cannot be empty",[s]),a=(0,c.useMemo)(()=>t.some(t=>t!==e?.name&&t.toLowerCase()===s.trim().toLowerCase()),[s,e?.name,t]),d=(0,c.useMemo)(()=>!!e&&"directory"!==e.type&&iE(e.name)!==iE(s),[e,s]),u=s.trim()===e?.name,f=!l&&!a&&!u&&!!s.trim(),m=(0,c.useCallback)(()=>{f&&n(s.trim())},[f,s,n]);return(0,h.jsxs)(M.Z,{open:!!e,onClose:r,maxWidth:"xs",fullWidth:!0,children:[h.jsx(Z.Z,{children:"Rename"}),(0,h.jsxs)(A.Z,{children:[h.jsx(O.Z,{autoFocus:!0,fullWidth:!0,label:"New name",value:s,onChange:e=>o(e.target.value),onKeyDown:e=>"Enter"===e.key&&m(),error:!!l||a,helperText:l||(a?`"${s.trim()}" already exists`:void 0),sx:{mt:1}}),d&&!l&&!a&&h.jsx(g.Z,{severity:"warning",sx:{mt:2},children:"Changing the file extension may make the file unusable."})]}),(0,h.jsxs)(T.Z,{children:[h.jsx(p.Z,{onClick:r,children:"Cancel"}),h.jsx(p.Z,{onClick:m,variant:"contained",disabled:i||!f,children:"Rename"})]})]})}var iN=i(64668),iz=i(28669),iW=i(54815),iF=i(65465),iV=i(26774),iH=i(48688);let i$={whitelist:{label:"Whitelist Manager",icon:h.jsx(iz.Z,{sx:{color:"primary.main"}})},ops:{label:"Operators Manager",icon:h.jsx(eU.Z,{sx:{color:"primary.main"}})},bans:{label:"Ban List Manager",icon:h.jsx(iW.Z,{sx:{color:"primary.main"}})}};function iq({serverName:e,editorType:t,filePath:i,onBack:n,onSwitchToRaw:r}){let s=i$[t];return(0,h.jsxs)(y.Z,{sx:{borderRadius:3,display:"flex",flexDirection:"column",minHeight:600},children:[(0,h.jsxs)(f.Z,{sx:{display:"flex",alignItems:"center",gap:1,px:2,py:1,borderBottom:1,borderColor:"divider"},children:[h.jsx(m.Z,{size:"small",onClick:n,"aria-label":"back",children:h.jsx(P.Z,{})}),s.icon,h.jsx(w.Z,{variant:"subtitle1",sx:{fontWeight:600,flex:1},noWrap:!0,children:s.label}),i&&h.jsx(p.Z,{size:"small",startIcon:h.jsx(iN.Z,{}),onClick:()=>{n(),r(i)},children:"Raw View"})]}),(0,h.jsxs)(b.Z,{sx:{flex:1,overflow:"auto",p:{xs:1,sm:2},"&:last-child":{pb:2}},children:["whitelist"===t&&h.jsx(iF.Z,{serverName:e}),"ops"===t&&h.jsx(iV.d,{serverName:e}),"bans"===t&&h.jsx(iH.Z,{serverName:e})]})]})}var iK=i(95257),iU=i(95661),i_=i(40768),iG=i(61989),iJ=i(95009),iX=i(4587),iY=i(45912),iQ=i(34615),i0=i(61649);let i1={gameplay:{label:"Gameplay",description:"Game rules, player limits, and core mechanics"},world:{label:"World Generation",description:"World settings, level name, and generation options"},network:{label:"Network & Security",description:"Ports, authentication, RCON, and query settings"},performance:{label:"Performance",description:"View distance, tick settings, and compression"},advanced:{label:"Advanced",description:"Other server properties"}},i2=["gameplay","world","network","performance","advanced"],i5=[{key:"gamemode",type:"enum",category:"gameplay",label:"Game Mode",description:"Default game mode for new players",defaultValue:"survival",options:[{value:"survival",label:"Survival"},{value:"creative",label:"Creative"},{value:"adventure",label:"Adventure"},{value:"spectator",label:"Spectator"}]},{key:"difficulty",type:"enum",category:"gameplay",label:"Difficulty",description:"Server difficulty level",defaultValue:"easy",options:[{value:"peaceful",label:"Peaceful"},{value:"easy",label:"Easy"},{value:"normal",label:"Normal"},{value:"hard",label:"Hard"}]},{key:"hardcore",type:"boolean",category:"gameplay",label:"Hardcore",description:"Players are set to spectator mode on death",defaultValue:"false"},{key:"pvp",type:"boolean",category:"gameplay",label:"PvP",description:"Allow player vs player combat",defaultValue:"true"},{key:"max-players",type:"number",category:"gameplay",label:"Max Players",description:"Maximum number of players on the server",defaultValue:"20",min:0,max:2147483647},{key:"force-gamemode",type:"boolean",category:"gameplay",label:"Force Game Mode",description:"Force players to join in the default game mode",defaultValue:"false"},{key:"allow-flight",type:"boolean",category:"gameplay",label:"Allow Flight",description:"Allow players to use flight in survival mode",defaultValue:"false"},{key:"spawn-protection",type:"number",category:"gameplay",label:"Spawn Protection",description:"Radius of spawn protection area (0 = disabled)",defaultValue:"16",min:0,max:65536},{key:"spawn-animals",type:"boolean",category:"gameplay",label:"Spawn Animals",description:"Allow animals to spawn naturally",defaultValue:"true"},{key:"spawn-monsters",type:"boolean",category:"gameplay",label:"Spawn Monsters",description:"Allow hostile mobs to spawn naturally",defaultValue:"true"},{key:"spawn-npcs",type:"boolean",category:"gameplay",label:"Spawn NPCs",description:"Allow villagers to spawn",defaultValue:"true"},{key:"allow-nether",type:"boolean",category:"gameplay",label:"Allow Nether",description:"Allow players to travel to the Nether",defaultValue:"true"},{key:"enable-command-block",type:"boolean",category:"gameplay",label:"Enable Command Blocks",description:"Allow command blocks to be used",defaultValue:"false"},{key:"player-idle-timeout",type:"number",category:"gameplay",label:"Player Idle Timeout",description:"Kick idle players after N minutes (0 = disabled)",defaultValue:"0",min:0,max:2147483647},{key:"level-name",type:"string",category:"world",label:"Level Name",description:"Name of the world folder",defaultValue:"world"},{key:"level-seed",type:"string",category:"world",label:"Level Seed",description:"Seed for world generation (blank = random)",defaultValue:""},{key:"level-type",type:"enum",category:"world",label:"Level Type",description:"World generation type",defaultValue:"minecraft\\:normal",options:[{value:"minecraft\\:normal",label:"Normal"},{value:"minecraft\\:flat",label:"Flat"},{value:"minecraft\\:large_biomes",label:"Large Biomes"},{value:"minecraft\\:amplified",label:"Amplified"},{value:"minecraft\\:single_biome_surface",label:"Single Biome"}]},{key:"generate-structures",type:"boolean",category:"world",label:"Generate Structures",description:"Generate villages, temples, and other structures",defaultValue:"true"},{key:"max-world-size",type:"number",category:"world",label:"Max World Size",description:"Maximum world border radius in blocks",defaultValue:"29999984",min:1,max:29999984},{key:"generator-settings",type:"string",category:"world",label:"Generator Settings",description:"Custom world generator settings (JSON)",defaultValue:"{}"},{key:"motd",type:"string",category:"world",label:"MOTD",description:"Message displayed in the server list",defaultValue:"A Minecraft Server"},{key:"server-port",type:"readonly",category:"network",label:"Server Port",description:"Port the server listens on (cannot be changed at runtime)",defaultValue:"25565"},{key:"server-ip",type:"readonly",category:"network",label:"Server IP",description:"IP address to bind to (blank = all interfaces)",defaultValue:""},{key:"online-mode",type:"boolean",category:"network",label:"Online Mode",description:"Authenticate players with Mojang servers",defaultValue:"true"},{key:"white-list",type:"boolean",category:"network",label:"Whitelist",description:"Only allow whitelisted players to join",defaultValue:"false"},{key:"enforce-whitelist",type:"boolean",category:"network",label:"Enforce Whitelist",description:"Kick non-whitelisted players when whitelist is reloaded",defaultValue:"false"},{key:"enforce-secure-profile",type:"boolean",category:"network",label:"Enforce Secure Profile",description:"Require players to have a signed key from Mojang",defaultValue:"true"},{key:"enable-rcon",type:"boolean",category:"network",label:"Enable RCON",description:"Enable remote console access",defaultValue:"false"},{key:"rcon.port",type:"number",category:"network",label:"RCON Port",description:"Port for RCON connections",defaultValue:"25575",min:1,max:65535},{key:"rcon.password",type:"string",category:"network",label:"RCON Password",description:"Password for RCON authentication",defaultValue:""},{key:"enable-query",type:"boolean",category:"network",label:"Enable Query",description:"Enable GameSpy4 protocol server listener",defaultValue:"false"},{key:"query.port",type:"number",category:"network",label:"Query Port",description:"Port for query protocol",defaultValue:"25565",min:1,max:65535},{key:"enable-status",type:"boolean",category:"network",label:"Enable Status",description:"Show server in the server list",defaultValue:"true"},{key:"prevent-proxy-connections",type:"boolean",category:"network",label:"Prevent Proxy Connections",description:"Block VPN/proxy connections (requires online-mode)",defaultValue:"false"},{key:"hide-online-players",type:"boolean",category:"network",label:"Hide Online Players",description:"Hide player count and list in server status",defaultValue:"false"},{key:"view-distance",type:"number",category:"performance",label:"View Distance",description:"Render distance in chunks sent to players",defaultValue:"10",min:3,max:32},{key:"simulation-distance",type:"number",category:"performance",label:"Simulation Distance",description:"Distance in chunks for entity simulation",defaultValue:"10",min:3,max:32},{key:"max-tick-time",type:"number",category:"performance",label:"Max Tick Time",description:"Maximum tick duration before watchdog crash (ms, -1 = disabled)",defaultValue:"60000",min:-1,max:2147483647},{key:"network-compression-threshold",type:"number",category:"performance",label:"Network Compression Threshold",description:"Minimum packet size to compress (bytes, -1 = disabled)",defaultValue:"256",min:-1,max:2147483647},{key:"max-chained-neighbor-updates",type:"number",category:"performance",label:"Max Chained Neighbor Updates",description:"Limit for chained block updates (-1 = unlimited)",defaultValue:"1000000",min:-1,max:2147483647},{key:"rate-limit",type:"number",category:"performance",label:"Rate Limit",description:"Max packets per second before kick (0 = disabled)",defaultValue:"0",min:0,max:2147483647},{key:"entity-broadcast-range-percentage",type:"number",category:"performance",label:"Entity Broadcast Range",description:"Percentage of default entity visibility range",defaultValue:"100",min:10,max:1e3},{key:"resource-pack",type:"string",category:"advanced",label:"Resource Pack URL",description:"URL of the server resource pack",defaultValue:""},{key:"resource-pack-sha1",type:"string",category:"advanced",label:"Resource Pack SHA1",description:"SHA1 hash of the resource pack file",defaultValue:""},{key:"require-resource-pack",type:"boolean",category:"advanced",label:"Require Resource Pack",description:"Kick players who decline the resource pack",defaultValue:"false"},{key:"resource-pack-prompt",type:"string",category:"advanced",label:"Resource Pack Prompt",description:"Custom message shown when asking to download resource pack",defaultValue:""},{key:"function-permission-level",type:"enum",category:"advanced",label:"Function Permission Level",description:"OP level required to execute functions",defaultValue:"2",options:[{value:"1",label:"Level 1 - Moderator"},{value:"2",label:"Level 2 - Gamemaster"},{value:"3",label:"Level 3 - Admin"},{value:"4",label:"Level 4 - Owner"}]},{key:"op-permission-level",type:"enum",category:"advanced",label:"OP Permission Level",description:"Default OP level for new operators",defaultValue:"4",options:[{value:"1",label:"Level 1 - Moderator"},{value:"2",label:"Level 2 - Gamemaster"},{value:"3",label:"Level 3 - Admin"},{value:"4",label:"Level 4 - Owner"}]},{key:"text-filtering-config",type:"string",category:"advanced",label:"Text Filtering Config",description:"Text filtering configuration file",defaultValue:""},{key:"log-ips",type:"boolean",category:"advanced",label:"Log IPs",description:"Log player IP addresses in the server log",defaultValue:"true"},{key:"broadcast-console-to-ops",type:"boolean",category:"advanced",label:"Broadcast Console to OPs",description:"Send console output to all OPs",defaultValue:"true"},{key:"broadcast-rcon-to-ops",type:"boolean",category:"advanced",label:"Broadcast RCON to OPs",description:"Send RCON output to all OPs",defaultValue:"true"},{key:"sync-chunk-writes",type:"boolean",category:"advanced",label:"Sync Chunk Writes",description:"Synchronize chunk writes for data safety",defaultValue:"true"},{key:"enable-jmx-monitoring",type:"boolean",category:"advanced",label:"Enable JMX Monitoring",description:"Expose JMX metrics for monitoring",defaultValue:"false"},{key:"use-native-transport",type:"boolean",category:"advanced",label:"Use Native Transport",description:"Use Linux-specific packet optimizations",defaultValue:"true"},{key:"initial-enabled-packs",type:"string",category:"advanced",label:"Initial Enabled Packs",description:"Comma-separated list of initially enabled data packs",defaultValue:"vanilla"},{key:"initial-disabled-packs",type:"string",category:"advanced",label:"Initial Disabled Packs",description:"Comma-separated list of initially disabled data packs",defaultValue:""}],i4=(i5.map(e=>[e.key,e]),h.jsx(F.Z,{label:"modified",size:"small",color:"warning",variant:"outlined"}));function i6({schema:e,value:t,onChange:i,isChanged:n}){let r=n?{"& .MuiInputBase-root":{bgcolor:"action.selected"}}:void 0,s=n?h.jsx(V.Z,{position:"end",children:i4}):void 0;switch(e.type){case"boolean":return(0,h.jsxs)(f.Z,{children:[(0,h.jsxs)(f.Z,{sx:{display:"flex",alignItems:"center",gap:1},children:[h.jsx(eA.Z,{control:h.jsx(eT.Z,{checked:"true"===t,onChange:t=>i(e.key,t.target.checked?"true":"false"),size:"small"}),label:e.label,sx:{mr:0}}),n&&i4]}),h.jsx(w.Z,{variant:"caption",color:"text.secondary",sx:{ml:"48px",display:"block",mt:-.5},children:e.description})]});case"enum":return h.jsx(O.Z,{select:!0,fullWidth:!0,size:"small",label:e.label,helperText:e.description,value:t,onChange:t=>i(e.key,t.target.value),InputProps:{endAdornment:s},sx:r,children:e.options?.map(e=>h.jsx(S.Z,{value:e.value,children:e.label},e.value))});case"number":return h.jsx(O.Z,{fullWidth:!0,size:"small",type:"number",label:e.label,helperText:e.description,value:t,onChange:t=>i(e.key,t.target.value),inputProps:{min:e.min,max:e.max},InputProps:{endAdornment:s},sx:r});case"readonly":return h.jsx(O.Z,{fullWidth:!0,size:"small",label:e.label,helperText:e.description,value:t,disabled:!0,InputProps:{endAdornment:h.jsx(V.Z,{position:"end",children:h.jsx(F.Z,{label:"readonly",size:"small",variant:"outlined"})})}});default:return h.jsx(O.Z,{fullWidth:!0,size:"small",label:e.label,helperText:e.description,value:t,onChange:t=>i(e.key,t.target.value),InputProps:{endAdornment:s},sx:r})}}function i3({serverName:e}){let t="/server.properties",{data:i,isLoading:n,error:r}=t3(e,t),s=t8(e),[o,l]=(0,c.useState)({}),[a,d]=(0,c.useState)({}),[u,m]=(0,c.useState)(""),v=(0,c.useCallback)((e,t)=>{l(i=>({...i,[e]:t}))},[]),y=(0,c.useMemo)(()=>{let e=[];for(let t of Object.keys(o))o[t]!==a[t]&&e.push(t);return e},[o,a]),b=(0,c.useCallback)(()=>{if(!i?.content)return;let e=function(e,t){let i=e.split("\n"),n=new Set,r=i.map(e=>{let i=e.trim();if(!i||i.startsWith("#"))return e;let r=i.indexOf("=");if(-1===r)return e;let s=i.substring(0,r).trim();return(n.add(s),s in t)?`${s}=${t[s]}`:e});for(let[e,i]of Object.entries(t))n.has(e)||r.push(`${e}=${i}`);return r.join("\n")}(i.content,o);s.mutate({path:t,content:e},{onSuccess:()=>{d({...o})}})},[i,o,s]),k=(0,c.useCallback)(()=>{l({...a})},[a]),S=(0,c.useMemo)(()=>{let e=u.toLowerCase(),t={gameplay:[],world:[],network:[],performance:[],advanced:[]};for(let i of i5)(!e||i.key.toLowerCase().includes(e)||i.label.toLowerCase().includes(e)||i.description.toLowerCase().includes(e))&&t[i.category].push(i);let i=new Set(i5.map(e=>e.key));for(let n of Object.keys(o))!i.has(n)&&(!e||n.toLowerCase().includes(e))&&t.advanced.push({key:n,type:"string",category:"advanced",label:n,description:"Custom property (not in standard schema)",defaultValue:""});return t},[u,o]);return n?h.jsx(f.Z,{sx:{display:"flex",justifyContent:"center",alignItems:"center",py:8},children:h.jsx(x.Z,{})}):r?(0,h.jsxs)(g.Z,{severity:"error",sx:{m:2},children:["Failed to load server.properties: ",r.message]}):(0,h.jsxs)(f.Z,{sx:{display:"flex",flexDirection:"column",height:"100%"},children:[h.jsx(g.Z,{severity:"warning",icon:h.jsx(i0.Z,{}),sx:{mx:2,mt:2,mb:1},children:(0,h.jsxs)(w.Z,{variant:"body2",children:[h.jsx("strong",{children:"Warning:"})," Changes are applied directly to the running server file. For persistent settings that survive server recreation, use the ",h.jsx("strong",{children:"Options"})," tab."]})}),(0,h.jsxs)(f.Z,{sx:{display:"flex",alignItems:"center",gap:1,px:2,py:1},children:[h.jsx(O.Z,{size:"small",placeholder:"Search properties...",value:u,onChange:e=>m(e.target.value),InputProps:{startAdornment:h.jsx(V.Z,{position:"start",children:h.jsx(t2.Z,{fontSize:"small"})})},sx:{flex:1,maxWidth:400}}),h.jsx(f.Z,{sx:{flex:1}}),y.length>0&&h.jsx(F.Z,{label:`${y.length} changed`,color:"warning",size:"small"}),h.jsx(p.Z,{size:"small",startIcon:h.jsx(iQ.Z,{}),onClick:k,disabled:0===y.length,children:"Discard"}),h.jsx(p.Z,{size:"small",variant:"contained",startIcon:s.isPending?h.jsx(x.Z,{size:16,color:"inherit"}):h.jsx(eb.Z,{}),onClick:b,disabled:0===y.length||s.isPending,children:"Save"})]}),s.isError&&(0,h.jsxs)(g.Z,{severity:"error",sx:{mx:2,mb:1},children:["Failed to save: ",s.error.message]}),s.isSuccess&&0===y.length&&h.jsx(g.Z,{severity:"success",sx:{mx:2,mb:1},children:"File saved successfully."}),h.jsx(f.Z,{sx:{flex:1,overflow:"auto",px:2,pb:2},children:i2.map(e=>{let t=S[e];if(0===t.length)return null;let i=i1[e],n=t.filter(e=>y.includes(e.key)).length;return(0,h.jsxs)(iJ.Z,{defaultExpanded:"advanced"!==e,disableGutters:!0,children:[h.jsx(iX.Z,{expandIcon:h.jsx(eC.Z,{}),children:(0,h.jsxs)(f.Z,{sx:{display:"flex",alignItems:"center",gap:1,width:"100%"},children:[h.jsx(w.Z,{variant:"subtitle1",sx:{fontWeight:600},children:i.label}),(0,h.jsxs)(w.Z,{variant:"caption",color:"text.secondary",children:["(",t.length,")"]}),n>0&&h.jsx(F.Z,{label:`${n} modified`,size:"small",color:"warning",variant:"outlined"})]})}),(0,h.jsxs)(iY.Z,{children:[h.jsx(w.Z,{variant:"body2",color:"text.secondary",sx:{mb:2},children:i.description}),h.jsx(D.ZP,{container:!0,spacing:2,children:t.map(e=>{let t=o[e.key]??e.defaultValue,i=y.includes(e.key);return h.jsx(D.ZP,{item:!0,xs:12,sm:"boolean"===e.type?6:12,children:h.jsx(i6,{schema:e,value:t,onChange:v,isChanged:i})},e.key)})})]})]},e)})})]})}let i8=[],i9=[];function i7(e){return e>=127462&&e<=127487}function ne(e,t,i){if(t==e.length)return t;t&&ni(e.charCodeAt(t))&&nn(e.charCodeAt(t-1))&&t--;let n=nt(e,t);for(t+=nr(n);t<e.length;){let r=nt(e,t);if(8205==n||8205==r||i&&function(e){if(e<768)return!1;for(let t=0,i=i8.length;;){let n=t+i>>1;if(e<i8[n])i=n;else{if(!(e>=i9[n]))return!0;t=n+1}if(t==i)return!1}}(r))t+=nr(r),n=r;else if(i7(r)){let i=0,n=t-2;for(;n>=0&&i7(nt(e,n));)i++,n-=2;if(i%2==0)break;t+=2}else break}return t}function nt(e,t){let i=e.charCodeAt(t);if(!nn(i)||t+1==e.length)return i;let n=e.charCodeAt(t+1);return ni(n)?(i-55296<<10)+(n-56320)+65536:i}function ni(e){return e>=56320&&e<57344}function nn(e){return e>=55296&&e<56320}function nr(e){return e<65536?1:2}(()=>{let e="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(e=>e?parseInt(e,36):1);for(let t=0,i=0;t<e.length;t++)(t%2?i9:i8).push(i+=e[t])})();class ns{lineAt(e){if(e<0||e>this.length)throw RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,i){[e,t]=nf(this,e,t);let n=[];return this.decompose(0,e,n,2),i.length&&i.decompose(0,i.length,n,3),this.decompose(t,this.length,n,1),nl.from(n,this.length-(t-e)+i.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=nf(this,e,t);let i=[];return this.decompose(e,t,i,0),nl.from(i,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),i=this.length-this.scanIdentical(e,-1),n=new nh(this),r=new nh(e);for(let e=t,s=t;;){if(n.next(e),r.next(e),e=0,n.lineBreak!=r.lineBreak||n.done!=r.done||n.value!=r.value)return!1;if(s+=n.value.length,n.done||s>=i)return!0}}iter(e=1){return new nh(this,e)}iterRange(e,t=this.length){return new nc(this,e,t)}iterLines(e,t){let i;if(null==e)i=this.iter();else{null==t&&(t=this.lines+1);let n=this.line(e).from;i=this.iterRange(n,Math.max(n,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new nd(i)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(0==e.length)throw RangeError("A document must have at least one line");return 1!=e.length||e[0]?e.length<=32?new no(e):nl.from(no.split(e,[])):ns.empty}}class no extends ns{constructor(e,t=function(e){let t=-1;for(let i of e)t+=i.length+1;return t}(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,i,n){for(let r=0;;r++){let s=this.text[r],o=n+s.length;if((t?i:o)>=e)return new nu(n,o,i,s);n=o+1,i++}}decompose(e,t,i,n){let r=e<=0&&t>=this.length?this:new no(na(this.text,[""],e,t),Math.min(t,this.length)-Math.max(0,e));if(1&n){let e=i.pop(),t=na(r.text,e.text.slice(),0,r.length);if(t.length<=32)i.push(new no(t,e.length+r.length));else{let e=t.length>>1;i.push(new no(t.slice(0,e)),new no(t.slice(e)))}}else i.push(r)}replace(e,t,i){if(!(i instanceof no))return super.replace(e,t,i);[e,t]=nf(this,e,t);let n=na(this.text,na(i.text,na(this.text,[""],0,e)),t),r=this.length+i.length-(t-e);return n.length<=32?new no(n,r):nl.from(no.split(n,[]),r)}sliceString(e,t=this.length,i="\n"){[e,t]=nf(this,e,t);let n="";for(let r=0,s=0;r<=t&&s<this.text.length;s++){let o=this.text[s],l=r+o.length;r>e&&s&&(n+=i),e<l&&t>r&&(n+=o.slice(Math.max(0,e-r),t-r)),r=l+1}return n}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let i=[],n=-1;for(let r of e)i.push(r),n+=r.length+1,32==i.length&&(t.push(new no(i,n)),i=[],n=-1);return n>-1&&t.push(new no(i,n)),t}}class nl extends ns{constructor(e,t){for(let i of(super(),this.children=e,this.length=t,this.lines=0,e))this.lines+=i.lines}lineInner(e,t,i,n){for(let r=0;;r++){let s=this.children[r],o=n+s.length,l=i+s.lines-1;if((t?l:o)>=e)return s.lineInner(e,t,i,n);n=o+1,i=l+1}}decompose(e,t,i,n){for(let r=0,s=0;s<=t&&r<this.children.length;r++){let o=this.children[r],l=s+o.length;if(e<=l&&t>=s){let r=n&((s<=e?1:0)|(l>=t?2:0));s>=e&&l<=t&&!r?i.push(o):o.decompose(e-s,t-s,i,r)}s=l+1}}replace(e,t,i){if([e,t]=nf(this,e,t),i.lines<this.lines)for(let n=0,r=0;n<this.children.length;n++){let s=this.children[n],o=r+s.length;if(e>=r&&t<=o){let l=s.replace(e-r,t-r,i),a=this.lines-s.lines+l.lines;if(l.lines<a>>4&&l.lines>a>>6){let r=this.children.slice();return r[n]=l,new nl(r,this.length-(t-e)+i.length)}return super.replace(r,o,l)}r=o+1}return super.replace(e,t,i)}sliceString(e,t=this.length,i="\n"){[e,t]=nf(this,e,t);let n="";for(let r=0,s=0;r<this.children.length&&s<=t;r++){let o=this.children[r],l=s+o.length;s>e&&r&&(n+=i),e<l&&t>s&&(n+=o.sliceString(e-s,t-s,i)),s=l+1}return n}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof nl))return 0;let i=0,[n,r,s,o]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;n+=t,r+=t){if(n==s||r==o)return i;let l=this.children[n],a=e.children[r];if(l!=a)return i+l.scanIdentical(a,t);i+=l.length+1}}static from(e,t=e.reduce((e,t)=>e+t.length+1,-1)){let i=0;for(let t of e)i+=t.lines;if(i<32){let i=[];for(let t of e)t.flatten(i);return new no(i,t)}let n=Math.max(32,i>>5),r=n<<1,s=n>>1,o=[],l=0,a=-1,h=[];function c(){0!=l&&(o.push(1==h.length?h[0]:nl.from(h,a)),a=-1,l=h.length=0)}for(let t of e)!function e(t){let i;if(t.lines>r&&t instanceof nl)for(let i of t.children)e(i);else t.lines>s&&(l>s||!l)?(c(),o.push(t)):t instanceof no&&l&&(i=h[h.length-1])instanceof no&&t.lines+i.lines<=32?(l+=t.lines,a+=t.length+1,h[h.length-1]=new no(i.text.concat(t.text),i.length+1+t.length)):(l+t.lines>n&&c(),l+=t.lines,a+=t.length+1,h.push(t))}(t);return c(),1==o.length?o[0]:new nl(o,t)}}function na(e,t,i=0,n=1e9){for(let r=0,s=0,o=!0;s<e.length&&r<=n;s++){let l=e[s],a=r+l.length;a>=i&&(a>n&&(l=l.slice(0,n-r)),r<i&&(l=l.slice(i-r)),o?(t[t.length-1]+=l,o=!1):t.push(l)),r=a+1}return t}ns.empty=new no([""],0);class nh{constructor(e,t=1){this.dir=t,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[e],this.offsets=[t>0?1:(e instanceof no?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,n=this.nodes[i],r=this.offsets[i],s=r>>1,o=n instanceof no?n.text.length:n.children.length;if(s==(t>0?o:0)){if(0==i)return this.done=!0,this.value="",this;t>0&&this.offsets[i-1]++,this.nodes.pop(),this.offsets.pop()}else if((1&r)==(t>0?0:1)){if(this.offsets[i]+=t,0==e)return this.lineBreak=!0,this.value="\n",this;e--}else if(n instanceof no){let r=n.text[s+(t<0?-1:0)];if(this.offsets[i]+=t,r.length>Math.max(0,e))return this.value=0==e?r:t>0?r.slice(e):r.slice(0,r.length-e),this;e-=r.length}else{let r=n.children[s+(t<0?-1:0)];e>r.length?(e-=r.length,this.offsets[i]+=t):(t<0&&this.offsets[i]--,this.nodes.push(r),this.offsets.push(t>0?1:(r instanceof no?r.text.length:r.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class nc{constructor(e,t,i){this.value="",this.done=!1,this.cursor=new nh(e,t>i?-1:1),this.pos=t>i?e.length:0,this.from=Math.min(t,i),this.to=Math.max(t,i)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let i=t<0?this.pos-this.from:this.to-this.pos;e>i&&(e=i),i-=e;let{value:n}=this.cursor.next(e);return this.pos+=(n.length+e)*t,this.value=n.length<=i?n:t<0?n.slice(n.length-i):n.slice(0,i),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&""!=this.value}}class nd{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:i,value:n}=this.inner.next(e);return t&&this.afterBreak?(this.value="",this.afterBreak=!1):t?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=n,this.afterBreak=!1),this}get lineBreak(){return!1}}"undefined"!=typeof Symbol&&(ns.prototype[Symbol.iterator]=function(){return this.iter()},nh.prototype[Symbol.iterator]=nc.prototype[Symbol.iterator]=nd.prototype[Symbol.iterator]=function(){return this});class nu{constructor(e,t,i,n){this.from=e,this.to=t,this.number=i,this.text=n}get length(){return this.to-this.from}}function nf(e,t,i){return[t=Math.max(0,Math.min(e.length,t)),Math.max(t,Math.min(e.length,i))]}function np(e,t,i=!0,n=!0){return function(e,t,i=!0,n=!0){return(i?ne:function(e,t,i){for(;t>0;){let n=ne(e,t-2,i);if(n<t)return n;t--}return 0})(e,t,n)}(e,t,i,n)}function nm(e,t){let i=e.charCodeAt(t);if(!(i>=55296&&i<56320)||t+1==e.length)return i;let n=e.charCodeAt(t+1);return n>=56320&&n<57344?(i-55296<<10)+(n-56320)+65536:i}function ng(e){return e<65536?1:2}let nx=/\r\n?|\n/;var nv=function(e){return e[e.Simple=0]="Simple",e[e.TrackDel=1]="TrackDel",e[e.TrackBefore=2]="TrackBefore",e[e.TrackAfter=3]="TrackAfter",e}(nv||(nv={}));class ny{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;t<this.sections.length;t+=2)e+=this.sections[t];return e}get newLength(){let e=0;for(let t=0;t<this.sections.length;t+=2){let i=this.sections[t+1];e+=i<0?this.sections[t]:i}return e}get empty(){return 0==this.sections.length||2==this.sections.length&&this.sections[1]<0}iterGaps(e){for(let t=0,i=0,n=0;t<this.sections.length;){let r=this.sections[t++],s=this.sections[t++];s<0?(e(i,n,r),n+=r):n+=s,i+=r}}iterChangedRanges(e,t=!1){nS(this,e,t)}get invertedDesc(){let e=[];for(let t=0;t<this.sections.length;){let i=this.sections[t++],n=this.sections[t++];n<0?e.push(i,n):e.push(n,i)}return new ny(e)}composeDesc(e){return this.empty?e:e.empty?this:nj(this,e)}mapDesc(e,t=!1){return e.empty?this:nC(this,e,t)}mapPos(e,t=-1,i=nv.Simple){let n=0,r=0;for(let s=0;s<this.sections.length;){let o=this.sections[s++],l=this.sections[s++],a=n+o;if(l<0){if(a>e)return r+(e-n);r+=o}else{if(i!=nv.Simple&&a>=e&&(i==nv.TrackDel&&n<e&&a>e||i==nv.TrackBefore&&n<e||i==nv.TrackAfter&&a>e))return null;if(a>e||a==e&&t<0&&!o)return e==n||t<0?r:r+l;r+=l}n=a}if(e>n)throw RangeError(`Position ${e} is out of range for changeset of length ${n}`);return r}touchesRange(e,t=e){for(let i=0,n=0;i<this.sections.length&&n<=t;){let r=this.sections[i++],s=this.sections[i++],o=n+r;if(s>=0&&n<=t&&o>=e)return!(n<e)||!(o>t)||"cover";n=o}return!1}toString(){let e="";for(let t=0;t<this.sections.length;){let i=this.sections[t++],n=this.sections[t++];e+=(e?" ":"")+i+(n>=0?":"+n:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(e=>"number"!=typeof e))throw RangeError("Invalid JSON representation of ChangeDesc");return new ny(e)}static create(e){return new ny(e)}}class nb extends ny{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw RangeError("Applying change set to a document with the wrong length");return nS(this,(t,i,n,r,s)=>e=e.replace(n,n+(i-t),s),!1),e}mapDesc(e,t=!1){return nC(this,e,t,!0)}invert(e){let t=this.sections.slice(),i=[];for(let n=0,r=0;n<t.length;n+=2){let s=t[n],o=t[n+1];if(o>=0){t[n]=o,t[n+1]=s;let l=n>>1;for(;i.length<l;)i.push(ns.empty);i.push(s?e.slice(r,r+s):ns.empty)}r+=s}return new nb(t,i)}compose(e){return this.empty?e:e.empty?this:nj(this,e,!0)}map(e,t=!1){return e.empty?this:nC(this,e,t,!0)}iterChanges(e,t=!1){nS(this,e,t)}get desc(){return ny.create(this.sections)}filter(e){let t=[],i=[],n=[],r=new nM(this);e:for(let s=0,o=0;;){let l=s==e.length?1e9:e[s++];for(;o<l||o==l&&0==r.len;){if(r.done)break e;let e=Math.min(r.len,l-o);nw(n,e,-1);let s=-1==r.ins?-1:0==r.off?r.ins:0;nw(t,e,s),s>0&&nk(i,t,r.text),r.forward(e),o+=e}let a=e[s++];for(;o<a;){if(r.done)break e;let e=Math.min(r.len,a-o);nw(t,e,-1),nw(n,e,-1==r.ins?-1:0==r.off?r.ins:0),r.forward(e),o+=e}}return{changes:new nb(t,i),filtered:ny.create(n)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let i=this.sections[t],n=this.sections[t+1];n<0?e.push(i):0==n?e.push([i]):e.push([i].concat(this.inserted[t>>1].toJSON()))}return e}static of(e,t,i){let n=[],r=[],s=0,o=null;function l(e=!1){if(!e&&!n.length)return;s<t&&nw(n,t-s,-1);let i=new nb(n,r);o=o?o.compose(i.map(o)):i,n=[],r=[],s=0}return function e(a){if(Array.isArray(a))for(let t of a)e(t);else if(a instanceof nb){if(a.length!=t)throw RangeError(`Mismatched change set length (got ${a.length}, expected ${t})`);l(),o=o?o.compose(a.map(o)):a}else{let{from:e,to:o=e,insert:h}=a;if(e>o||e<0||o>t)throw RangeError(`Invalid change range ${e} to ${o} (in doc of length ${t})`);let c=h?"string"==typeof h?ns.of(h.split(i||nx)):h:ns.empty,d=c.length;if(e==o&&0==d)return;e<s&&l(),e>s&&nw(n,e-s,-1),nw(n,o-e,d),nk(r,n,c),s=o}}(e),l(!o),o}static empty(e){return new nb(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw RangeError("Invalid JSON representation of ChangeSet");let t=[],i=[];for(let n=0;n<e.length;n++){let r=e[n];if("number"==typeof r)t.push(r,-1);else if(!Array.isArray(r)||"number"!=typeof r[0]||r.some((e,t)=>t&&"string"!=typeof e))throw RangeError("Invalid JSON representation of ChangeSet");else if(1==r.length)t.push(r[0],0);else{for(;i.length<n;)i.push(ns.empty);i[n]=ns.of(r.slice(1)),t.push(r[0],i[n].length)}}return new nb(t,i)}static createSet(e,t){return new nb(e,t)}}function nw(e,t,i,n=!1){if(0==t&&i<=0)return;let r=e.length-2;r>=0&&i<=0&&i==e[r+1]?e[r]+=t:r>=0&&0==t&&0==e[r]?e[r+1]+=i:n?(e[r]+=t,e[r+1]+=i):e.push(t,i)}function nk(e,t,i){if(0==i.length)return;let n=t.length-2>>1;if(n<e.length)e[e.length-1]=e[e.length-1].append(i);else{for(;e.length<n;)e.push(ns.empty);e.push(i)}}function nS(e,t,i){let n=e.inserted;for(let r=0,s=0,o=0;o<e.sections.length;){let l=e.sections[o++],a=e.sections[o++];if(a<0)r+=l,s+=l;else{let h=r,c=s,d=ns.empty;for(;h+=l,c+=a,a&&n&&(d=d.append(n[o-2>>1])),!i&&o!=e.sections.length&&!(e.sections[o+1]<0);)l=e.sections[o++],a=e.sections[o++];t(r,h,s,c,d),r=h,s=c}}}function nC(e,t,i,n=!1){let r=[],s=n?[]:null,o=new nM(e),l=new nM(t);for(let e=-1;;){if(o.done&&l.len||l.done&&o.len)throw Error("Mismatched change set lengths");if(-1==o.ins&&-1==l.ins){let e=Math.min(o.len,l.len);nw(r,e,-1),o.forward(e),l.forward(e)}else if(l.ins>=0&&(o.ins<0||e==o.i||0==o.off&&(l.len<o.len||l.len==o.len&&!i))){let t=l.len;for(nw(r,l.ins,-1);t;){let i=Math.min(o.len,t);o.ins>=0&&e<o.i&&o.len<=i&&(nw(r,0,o.ins),s&&nk(s,r,o.text),e=o.i),o.forward(i),t-=i}l.next()}else if(o.ins>=0){let t=0,i=o.len;for(;i;)if(-1==l.ins){let e=Math.min(i,l.len);t+=e,i-=e,l.forward(e)}else if(0==l.ins&&l.len<i)i-=l.len,l.next();else break;nw(r,t,e<o.i?o.ins:0),s&&e<o.i&&nk(s,r,o.text),e=o.i,o.forward(o.len-i)}else if(o.done&&l.done)return s?nb.createSet(r,s):ny.create(r);else throw Error("Mismatched change set lengths")}}function nj(e,t,i=!1){let n=[],r=i?[]:null,s=new nM(e),o=new nM(t);for(let e=!1;;){if(s.done&&o.done)return r?nb.createSet(n,r):ny.create(n);if(0==s.ins)nw(n,s.len,0,e),s.next();else if(0!=o.len||o.done){if(s.done||o.done)throw Error("Mismatched change set lengths");{let t=Math.min(s.len2,o.len),i=n.length;if(-1==s.ins){let i=-1==o.ins?-1:o.off?0:o.ins;nw(n,t,i,e),r&&i&&nk(r,n,o.text)}else -1==o.ins?(nw(n,s.off?0:s.len,t,e),r&&nk(r,n,s.textBit(t))):(nw(n,s.off?0:s.len,o.off?0:o.ins,e),r&&!o.off&&nk(r,n,o.text));e=(s.ins>t||o.ins>=0&&o.len>t)&&(e||n.length>i),s.forward2(t),o.forward(t)}}else nw(n,0,o.ins,e),r&&nk(r,n,o.text),o.next()}}class nM{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return -2==this.ins}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,t=this.i-2>>1;return t>=e.length?ns.empty:e[t]}textBit(e){let{inserted:t}=this.set,i=this.i-2>>1;return i>=t.length&&!e?ns.empty:t[i].slice(this.off,null==e?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){-1==this.ins?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class nZ{constructor(e,t,i){this.from=e,this.to=t,this.flags=i}get anchor(){return 32&this.flags?this.to:this.from}get head(){return 32&this.flags?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return 8&this.flags?-1:16&this.flags?1:0}get bidiLevel(){let e=7&this.flags;return 7==e?null:e}get goalColumn(){let e=this.flags>>6;return 16777215==e?void 0:e}map(e,t=-1){let i,n;return this.empty?i=n=e.mapPos(this.from,t):(i=e.mapPos(this.from,1),n=e.mapPos(this.to,-1)),i==this.from&&n==this.to?this:new nZ(i,n,this.flags)}extend(e,t=e){if(e<=this.anchor&&t>=this.anchor)return nA.range(e,t);let i=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return nA.range(this.anchor,i)}eq(e,t=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!t||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||"number"!=typeof e.anchor||"number"!=typeof e.head)throw RangeError("Invalid JSON representation for SelectionRange");return nA.range(e.anchor,e.head)}static create(e,t,i){return new nZ(e,t,i)}}class nA{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:nA.create(this.ranges.map(i=>i.map(e,t)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let i=0;i<this.ranges.length;i++)if(!this.ranges[i].eq(e.ranges[i],t))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return 1==this.ranges.length?this:new nA([this.main],0)}addRange(e,t=!0){return nA.create([e].concat(this.ranges),t?0:this.mainIndex+1)}replaceRange(e,t=this.mainIndex){let i=this.ranges.slice();return i[t]=e,nA.create(i,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||"number"!=typeof e.main||e.main>=e.ranges.length)throw RangeError("Invalid JSON representation for EditorSelection");return new nA(e.ranges.map(e=>nZ.fromJSON(e)),e.main)}static single(e,t=e){return new nA([nA.range(e,t)],0)}static create(e,t=0){if(0==e.length)throw RangeError("A selection needs at least one range");for(let i=0,n=0;n<e.length;n++){let r=e[n];if(r.empty?r.from<=i:r.from<i)return nA.normalized(e.slice(),t);i=r.to}return new nA(e,t)}static cursor(e,t=0,i,n){return nZ.create(e,e,(0==t?0:t<0?8:16)|(null==i?7:Math.min(6,i))|(null!=n?n:16777215)<<6)}static range(e,t,i,n){let r=(null!=i?i:16777215)<<6|(null==n?7:Math.min(6,n));return t<e?nZ.create(t,e,48|r):nZ.create(e,t,(t>e?8:0)|r)}static normalized(e,t=0){let i=e[t];e.sort((e,t)=>e.from-t.from),t=e.indexOf(i);for(let i=1;i<e.length;i++){let n=e[i],r=e[i-1];if(n.empty?n.from<=r.to:n.from<r.to){let s=r.from,o=Math.max(n.to,r.to);i<=t&&t--,e.splice(--i,2,n.anchor>n.head?nA.range(o,s):nA.range(s,o))}}return new nA(e,t)}}function nT(e,t){for(let i of e.ranges)if(i.to>t)throw RangeError("Selection points outside of document")}let nO=0;class nD{constructor(e,t,i,n,r){this.combine=e,this.compareInput=t,this.compare=i,this.isStatic=n,this.id=nO++,this.default=e([]),this.extensions="function"==typeof r?r(this):r}get reader(){return this}static define(e={}){return new nD(e.combine||(e=>e),e.compareInput||((e,t)=>e===t),e.compare||(e.combine?(e,t)=>e===t:nR),!!e.static,e.enables)}of(e){return new nP([],this,0,e)}compute(e,t){if(this.isStatic)throw Error("Can't compute a static facet");return new nP(e,this,1,t)}computeN(e,t){if(this.isStatic)throw Error("Can't compute a static facet");return new nP(e,this,2,t)}from(e,t){return t||(t=e=>e),this.compute([e],i=>t(i.field(e)))}}function nR(e,t){return e==t||e.length==t.length&&e.every((e,i)=>e===t[i])}class nP{constructor(e,t,i,n){this.dependencies=e,this.facet=t,this.type=i,this.value=n,this.id=nO++}dynamicSlot(e){var t;let i=this.value,n=this.facet.compareInput,r=this.id,s=e[r]>>1,o=2==this.type,l=!1,a=!1,h=[];for(let i of this.dependencies)"doc"==i?l=!0:"selection"==i?a=!0:((null!==(t=e[i.id])&&void 0!==t?t:1)&1)==0&&h.push(e[i.id]);return{create:e=>(e.values[s]=i(e),1),update(e,t){if(l&&t.docChanged||a&&(t.docChanged||t.selection)||nI(e,h)){let t=i(e);if(o?!nL(t,e.values[s],n):!n(t,e.values[s]))return e.values[s]=t,1}return 0},reconfigure:(e,t)=>{let l,a=t.config.address[r];if(null!=a){let r=nK(t,a);if(this.dependencies.every(i=>i instanceof nD?t.facet(i)===e.facet(i):!(i instanceof nB)||t.field(i,!1)==e.field(i,!1))||(o?nL(l=i(e),r,n):n(l=i(e),r)))return e.values[s]=r,0}else l=i(e);return e.values[s]=l,1}}}}function nL(e,t,i){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!i(e[n],t[n]))return!1;return!0}function nI(e,t){let i=!1;for(let n of t)1&nq(e,n)&&(i=!0);return i}let nE=nD.define({static:!0});class nB{constructor(e,t,i,n,r){this.id=e,this.createF=t,this.updateF=i,this.compareF=n,this.spec=r,this.provides=void 0}static define(e){let t=new nB(nO++,e.create,e.update,e.compare||((e,t)=>e===t),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(nE).find(e=>e.field==this);return((null==t?void 0:t.create)||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:e=>(e.values[t]=this.create(e),1),update:(e,i)=>{let n=e.values[t],r=this.updateF(n,i);return this.compareF(n,r)?0:(e.values[t]=r,1)},reconfigure:(e,i)=>{let n=e.facet(nE),r=i.facet(nE),s;return(s=n.find(e=>e.field==this))&&s!=r.find(e=>e.field==this)?(e.values[t]=s.create(e),1):null!=i.config.address[this.id]?(e.values[t]=i.field(this),0):(e.values[t]=this.create(e),1)}}}init(e){return[this,nE.of({field:this,create:e})]}get extension(){return this}}let nN={lowest:4,low:3,default:2,high:1,highest:0};function nz(e){return t=>new nF(t,e)}let nW={highest:nz(nN.highest),high:nz(nN.high),default:nz(nN.default),low:nz(nN.low),lowest:nz(nN.lowest)};class nF{constructor(e,t){this.inner=e,this.prec=t}}class nV{of(e){return new nH(this,e)}reconfigure(e){return nV.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class nH{constructor(e,t){this.compartment=e,this.inner=t}}class n${constructor(e,t,i,n,r,s){for(this.base=e,this.compartments=t,this.dynamicSlots=i,this.address=n,this.staticValues=r,this.facets=s,this.statusTemplate=[];this.statusTemplate.length<i.length;)this.statusTemplate.push(0)}staticFacet(e){let t=this.address[e.id];return null==t?e.default:this.staticValues[t>>1]}static resolve(e,t,i){let n,r,s=[],o=Object.create(null),l=new Map;for(let i of(n=[[],[],[],[],[]],r=new Map,function e(i,s){let o=r.get(i);if(null!=o){if(o<=s)return;let e=n[o].indexOf(i);e>-1&&n[o].splice(e,1),i instanceof nH&&l.delete(i.compartment)}if(r.set(i,s),Array.isArray(i))for(let t of i)e(t,s);else if(i instanceof nH){if(l.has(i.compartment))throw RangeError("Duplicate use of compartment in extensions");let n=t.get(i.compartment)||i.inner;l.set(i.compartment,n),e(n,s)}else if(i instanceof nF)e(i.inner,i.prec);else if(i instanceof nB)n[s].push(i),i.provides&&e(i.provides,s);else if(i instanceof nP)n[s].push(i),i.facet.extensions&&e(i.facet.extensions,nN.default);else{let t=i.extension;if(!t)throw Error(`Unrecognized extension value in extension set (${i}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);e(t,s)}}(e,nN.default),n.reduce((e,t)=>e.concat(t))))i instanceof nB?s.push(i):(o[i.facet.id]||(o[i.facet.id]=[])).push(i);let a=Object.create(null),h=[],c=[];for(let e of s)a[e.id]=c.length<<1,c.push(t=>e.slot(t));let d=null==i?void 0:i.config.facets;for(let e in o){let t=o[e],n=t[0].facet,r=d&&d[e]||[];if(t.every(e=>0==e.type)){if(a[n.id]=h.length<<1|1,nR(r,t))h.push(i.facet(n));else{let e=n.combine(t.map(e=>e.value));h.push(i&&n.compare(e,i.facet(n))?i.facet(n):e)}}else{for(let e of t)0==e.type?(a[e.id]=h.length<<1|1,h.push(e.value)):(a[e.id]=c.length<<1,c.push(t=>e.dynamicSlot(t)));a[n.id]=c.length<<1,c.push(e=>(function(e,t,i){let n=i.map(t=>e[t.id]),r=i.map(e=>e.type),s=n.filter(e=>!(1&e)),o=e[t.id]>>1;function l(e){let i=[];for(let t=0;t<n.length;t++){let s=nK(e,n[t]);if(2==r[t])for(let e of s)i.push(e);else i.push(s)}return t.combine(i)}return{create(e){for(let t of n)nq(e,t);return e.values[o]=l(e),1},update(e,i){if(!nI(e,s))return 0;let n=l(e);return t.compare(n,e.values[o])?0:(e.values[o]=n,1)},reconfigure(e,r){let s=nI(e,n),a=r.config.facets[t.id],h=r.facet(t);if(a&&!s&&nR(i,a))return e.values[o]=h,0;let c=l(e);return t.compare(c,h)?(e.values[o]=h,0):(e.values[o]=c,1)}}})(e,n,t))}}return new n$(e,l,c.map(e=>e(a)),a,h,o)}}function nq(e,t){if(1&t)return 2;let i=t>>1,n=e.status[i];if(4==n)throw Error("Cyclic dependency between fields and/or facets");if(2&n)return n;e.status[i]=4;let r=e.computeSlot(e,e.config.dynamicSlots[i]);return e.status[i]=2|r}function nK(e,t){return 1&t?e.config.staticValues[t>>1]:e.values[t>>1]}let nU=nD.define(),n_=nD.define({combine:e=>e.some(e=>e),static:!0}),nG=nD.define({combine:e=>e.length?e[0]:void 0,static:!0}),nJ=nD.define(),nX=nD.define(),nY=nD.define(),nQ=nD.define({combine:e=>!!e.length&&e[0]});class n0{constructor(e,t){this.type=e,this.value=t}static define(){return new n1}}class n1{of(e){return new n0(this,e)}}class n2{constructor(e){this.map=e}of(e){return new n5(this,e)}}class n5{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return void 0===t?void 0:t==this.value?this:new n5(this.type,t)}is(e){return this.type==e}static define(e={}){return new n2(e.map||(e=>e))}static mapEffects(e,t){if(!e.length)return e;let i=[];for(let n of e){let e=n.map(t);e&&i.push(e)}return i}}n5.reconfigure=n5.define(),n5.appendConfig=n5.define();class n4{constructor(e,t,i,n,r,s){this.startState=e,this.changes=t,this.selection=i,this.effects=n,this.annotations=r,this.scrollIntoView=s,this._doc=null,this._state=null,i&&nT(i,t.newLength),r.some(e=>e.type==n4.time)||(this.annotations=r.concat(n4.time.of(Date.now())))}static create(e,t,i,n,r,s){return new n4(e,t,i,n,r,s)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let t=this.annotation(n4.userEvent);return!!(t&&(t==e||t.length>e.length&&t.slice(0,e.length)==e&&"."==t[e.length]))}}function n6(e,t,i){var n;let r,s,o;return i?(r=t.changes,s=nb.empty(t.changes.length),o=e.changes.compose(t.changes)):(r=t.changes.map(e.changes),s=e.changes.mapDesc(t.changes,!0),o=e.changes.compose(r)),{changes:o,selection:t.selection?t.selection.map(s):null===(n=e.selection)||void 0===n?void 0:n.map(r),effects:n5.mapEffects(e.effects,r).concat(n5.mapEffects(t.effects,s)),annotations:e.annotations.length?e.annotations.concat(t.annotations):t.annotations,scrollIntoView:e.scrollIntoView||t.scrollIntoView}}function n3(e,t,i){let n=t.selection,r=n9(t.annotations);return t.userEvent&&(r=r.concat(n4.userEvent.of(t.userEvent))),{changes:t.changes instanceof nb?t.changes:nb.of(t.changes||[],i,e.facet(nG)),selection:n&&(n instanceof nA?n:nA.single(n.anchor,n.head)),effects:n9(t.effects),annotations:r,scrollIntoView:!!t.scrollIntoView}}n4.time=n0.define(),n4.userEvent=n0.define(),n4.addToHistory=n0.define(),n4.remote=n0.define();let n8=[];function n9(e){return null==e?n8:Array.isArray(e)?e:[e]}var n7=function(e){return e[e.Word=0]="Word",e[e.Space=1]="Space",e[e.Other=2]="Other",e}(n7||(n7={}));let re=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;try{n=RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch(e){}class rt{constructor(e,t,i,n,r,s){this.config=e,this.doc=t,this.selection=i,this.values=n,this.status=e.statusTemplate.slice(),this.computeSlot=r,s&&(s._state=this);for(let e=0;e<this.config.dynamicSlots.length;e++)nq(this,e<<1);this.computeSlot=null}field(e,t=!0){let i=this.config.address[e.id];if(null==i){if(t)throw RangeError("Field is not present in this state");return}return nq(this,i),nK(this,i)}update(...e){return function e(t,i,n){let r=n3(t,i.length?i[0]:{},t.doc.length);i.length&&!1===i[0].filter&&(n=!1);for(let e=1;e<i.length;e++){!1===i[e].filter&&(n=!1);let s=!!i[e].sequential;r=n6(r,n3(t,i[e],s?r.changes.newLength:t.doc.length),s)}let s=n4.create(t,r.changes,r.selection,r.effects,r.annotations,r.scrollIntoView);return function(e){let t=e.startState,i=t.facet(nY),n=e;for(let r=i.length-1;r>=0;r--){let s=i[r](e);s&&Object.keys(s).length&&(n=n6(n,n3(t,s,e.changes.newLength),!0))}return n==e?e:n4.create(t,e.changes,e.selection,n.effects,n.annotations,n.scrollIntoView)}(n?function(t){let i=t.startState,n=!0;for(let e of i.facet(nJ)){let i=e(t);if(!1===i){n=!1;break}Array.isArray(i)&&(n=!0===n?i:function(e,t){let i=[];for(let n=0,r=0;;){let s,o;if(n<e.length&&(r==t.length||t[r]>=e[n]))s=e[n++],o=e[n++];else{if(!(r<t.length))return i;s=t[r++],o=t[r++]}!i.length||i[i.length-1]<s?i.push(s,o):i[i.length-1]<o&&(i[i.length-1]=o)}}(n,i))}if(!0!==n){let e,r;if(!1===n)r=t.changes.invertedDesc,e=nb.empty(i.doc.length);else{let i=t.changes.filter(n);e=i.changes,r=i.filtered.mapDesc(i.changes).invertedDesc}t=n4.create(i,e,t.selection&&t.selection.map(r),n5.mapEffects(t.effects,r),t.annotations,t.scrollIntoView)}let r=i.facet(nX);for(let n=r.length-1;n>=0;n--){let s=r[n](t);t=s instanceof n4?s:Array.isArray(s)&&1==s.length&&s[0]instanceof n4?s[0]:e(i,n9(s),!1)}return t}(s):s)}(this,e,!0)}applyTransaction(e){let t,i=this.config,{base:n,compartments:r}=i;for(let t of e.effects)t.is(nV.reconfigure)?(i&&(r=new Map,i.compartments.forEach((e,t)=>r.set(t,e)),i=null),r.set(t.value.compartment,t.value.extension)):t.is(n5.reconfigure)?(i=null,n=t.value):t.is(n5.appendConfig)&&(i=null,n=n9(n).concat(t.value));t=i?e.startState.values.slice():new rt(i=n$.resolve(n,r,this),this.doc,this.selection,i.dynamicSlots.map(()=>null),(e,t)=>t.reconfigure(e,this),null).values;let s=e.startState.facet(n_)?e.newSelection:e.newSelection.asSingle();new rt(i,e.newDoc,s,t,(t,i)=>i.update(t,e),e)}replaceSelection(e){return"string"==typeof e&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:nA.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,i=e(t.ranges[0]),n=this.changes(i.changes),r=[i.range],s=n9(i.effects);for(let i=1;i<t.ranges.length;i++){let o=e(t.ranges[i]),l=this.changes(o.changes),a=l.map(n);for(let e=0;e<i;e++)r[e]=r[e].map(a);let h=n.mapDesc(l,!0);r.push(o.range.map(h)),n=n.compose(a),s=n5.mapEffects(s,a).concat(n5.mapEffects(n9(o.effects),h))}return{changes:n,selection:nA.create(r,t.mainIndex),effects:s}}changes(e=[]){return e instanceof nb?e:nb.of(e,this.doc.length,this.facet(rt.lineSeparator))}toText(e){return ns.of(e.split(this.facet(rt.lineSeparator)||nx))}sliceDoc(e=0,t=this.doc.length){return this.doc.sliceString(e,t,this.lineBreak)}facet(e){let t=this.config.address[e.id];return null==t?e.default:(nq(this,t),nK(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let i in e){let n=e[i];n instanceof nB&&null!=this.config.address[n.id]&&(t[i]=n.spec.toJSON(this.field(e[i]),this))}return t}static fromJSON(e,t={},i){if(!e||"string"!=typeof e.doc)throw RangeError("Invalid JSON representation for EditorState");let n=[];if(i){for(let t in i)if(Object.prototype.hasOwnProperty.call(e,t)){let r=i[t],s=e[t];n.push(r.init(e=>r.spec.fromJSON(s,e)))}}return rt.create({doc:e.doc,selection:nA.fromJSON(e.selection),extensions:t.extensions?n.concat([t.extensions]):n})}static create(e={}){let t=n$.resolve(e.extensions||[],new Map),i=e.doc instanceof ns?e.doc:ns.of((e.doc||"").split(t.staticFacet(rt.lineSeparator)||nx)),n=e.selection?e.selection instanceof nA?e.selection:nA.single(e.selection.anchor,e.selection.head):nA.single(0);return nT(n,i.length),t.staticFacet(n_)||(n=n.asSingle()),new rt(t,i,n,t.dynamicSlots.map(()=>null),(e,t)=>t.create(e),null)}get tabSize(){return this.facet(rt.tabSize)}get lineBreak(){return this.facet(rt.lineSeparator)||"\n"}get readOnly(){return this.facet(nQ)}phrase(e,...t){for(let t of this.facet(rt.phrases))if(Object.prototype.hasOwnProperty.call(t,e)){e=t[e];break}return t.length&&(e=e.replace(/\$(\$|\d*)/g,(e,i)=>{if("$"==i)return"$";let n=+(i||1);return!n||n>t.length?e:t[n-1]})),e}languageDataAt(e,t,i=-1){let n=[];for(let r of this.facet(nU))for(let s of r(this,t,i))Object.prototype.hasOwnProperty.call(s,e)&&n.push(s[e]);return n}charCategorizer(e){var t;let i=this.languageDataAt("wordChars",e);return t=i.length?i[0]:"",e=>{if(!/\S/.test(e))return n7.Space;if(function(e){if(n)return n.test(e);for(let t=0;t<e.length;t++){let i=e[t];if(/\w/.test(i)||i>"\x80"&&(i.toUpperCase()!=i.toLowerCase()||re.test(i)))return!0}return!1}(e))return n7.Word;for(let i=0;i<t.length;i++)if(e.indexOf(t[i])>-1)return n7.Word;return n7.Other}}wordAt(e){let{text:t,from:i,length:n}=this.doc.lineAt(e),r=this.charCategorizer(e),s=e-i,o=e-i;for(;s>0;){let e=np(t,s,!1);if(r(t.slice(e,s))!=n7.Word)break;s=e}for(;o<n;){let e=np(t,o);if(r(t.slice(o,e))!=n7.Word)break;o=e}return s==o?null:nA.range(s+i,o+i)}}function ri(e,t,i={}){let n={};for(let t of e)for(let e of Object.keys(t)){let r=t[e],s=n[e];if(void 0===s)n[e]=r;else if(s===r||void 0===r);else if(Object.hasOwnProperty.call(i,e))n[e]=i[e](s,r);else throw Error("Config merge conflict for field "+e)}for(let e in t)void 0===n[e]&&(n[e]=t[e]);return n}rt.allowMultipleSelections=n_,rt.tabSize=nD.define({combine:e=>e.length?e[0]:4}),rt.lineSeparator=nG,rt.readOnly=nQ,rt.phrases=nD.define({compare(e,t){let i=Object.keys(e),n=Object.keys(t);return i.length==n.length&&i.every(i=>e[i]==t[i])}}),rt.languageData=nU,rt.changeFilter=nJ,rt.transactionFilter=nX,rt.transactionExtender=nY,nV.reconfigure=n5.define();class rn{eq(e){return this==e}range(e,t=e){return rs.create(e,t,this)}}function rr(e,t){return e==t||e.constructor==t.constructor&&e.eq(t)}rn.prototype.startSide=rn.prototype.endSide=0,rn.prototype.point=!1,rn.prototype.mapMode=nv.TrackDel;class rs{constructor(e,t,i){this.from=e,this.to=t,this.value=i}static create(e,t,i){return new rs(e,t,i)}}function ro(e,t){return e.from-t.from||e.value.startSide-t.value.startSide}class rl{constructor(e,t,i,n){this.from=e,this.to=t,this.value=i,this.maxPoint=n}get length(){return this.to[this.to.length-1]}findIndex(e,t,i,n=0){let r=i?this.to:this.from;for(let s=n,o=r.length;;){if(s==o)return s;let n=s+o>>1,l=r[n]-e||(i?this.value[n].endSide:this.value[n].startSide)-t;if(n==s)return l>=0?s:o;l>=0?o=n:s=n+1}}between(e,t,i,n){for(let r=this.findIndex(t,-1e9,!0),s=this.findIndex(i,1e9,!1,r);r<s;r++)if(!1===n(this.from[r]+e,this.to[r]+e,this.value[r]))return!1}map(e,t){let i=[],n=[],r=[],s=-1,o=-1;for(let l=0;l<this.value.length;l++){let a=this.value[l],h=this.from[l]+e,c=this.to[l]+e,d,u;if(h==c){let e=t.mapPos(h,a.startSide,a.mapMode);if(null==e||(d=u=e,a.startSide!=a.endSide&&(u=t.mapPos(h,a.endSide))<d))continue}else if((d=t.mapPos(h,a.startSide))>(u=t.mapPos(c,a.endSide))||d==u&&a.startSide>0&&a.endSide<=0)continue;0>(u-d||a.endSide-a.startSide)||(s<0&&(s=d),a.point&&(o=Math.max(o,u-d)),i.push(a),n.push(d-s),r.push(u-s))}return{mapped:i.length?new rl(n,r,i,o):null,pos:s}}}class ra{constructor(e,t,i,n){this.chunkPos=e,this.chunk=t,this.nextLayer=i,this.maxPoint=n}static create(e,t,i,n){return new ra(e,t,i,n)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let t of this.chunk)e+=t.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:t=[],sort:i=!1,filterFrom:n=0,filterTo:r=this.length}=e,s=e.filter;if(0==t.length&&!s)return this;if(i&&(t=t.slice().sort(ro)),this.isEmpty)return t.length?ra.of(t):this;let o=new rd(this,null,-1).goto(0),l=0,a=[],h=new rh;for(;o.value||l<t.length;)if(l<t.length&&(o.from-t[l].from||o.startSide-t[l].value.startSide)>=0){let e=t[l++];h.addInner(e.from,e.to,e.value)||a.push(e)}else 1==o.rangeIndex&&o.chunkIndex<this.chunk.length&&(l==t.length||this.chunkEnd(o.chunkIndex)<t[l].from)&&(!s||n>this.chunkEnd(o.chunkIndex)||r<this.chunkPos[o.chunkIndex])&&h.addChunk(this.chunkPos[o.chunkIndex],this.chunk[o.chunkIndex])?o.nextChunk():((!s||n>o.to||r<o.from||s(o.from,o.to,o.value))&&!h.addInner(o.from,o.to,o.value)&&a.push(rs.create(o.from,o.to,o.value)),o.next());return h.finishInner(this.nextLayer.isEmpty&&!a.length?ra.empty:this.nextLayer.update({add:a,filter:s,filterFrom:n,filterTo:r}))}map(e){if(e.empty||this.isEmpty)return this;let t=[],i=[],n=-1;for(let r=0;r<this.chunk.length;r++){let s=this.chunkPos[r],o=this.chunk[r],l=e.touchesRange(s,s+o.length);if(!1===l)n=Math.max(n,o.maxPoint),t.push(o),i.push(e.mapPos(s));else if(!0===l){let{mapped:r,pos:l}=o.map(s,e);r&&(n=Math.max(n,r.maxPoint),t.push(r),i.push(l))}}let r=this.nextLayer.map(e);return 0==t.length?r:new ra(i,t,r||ra.empty,n)}between(e,t,i){if(!this.isEmpty){for(let n=0;n<this.chunk.length;n++){let r=this.chunkPos[n],s=this.chunk[n];if(t>=r&&e<=r+s.length&&!1===s.between(r,e-r,t-r,i))return}this.nextLayer.between(e,t,i)}}iter(e=0){return ru.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return ru.from(e).goto(t)}static compare(e,t,i,n,r=-1){let s=e.filter(e=>e.maxPoint>0||!e.isEmpty&&e.maxPoint>=r),o=t.filter(e=>e.maxPoint>0||!e.isEmpty&&e.maxPoint>=r),l=rc(s,o,i),a=new rp(s,l,r),h=new rp(o,l,r);i.iterGaps((e,t,i)=>rm(a,e,h,t,i,n)),i.empty&&0==i.length&&rm(a,0,h,0,0,n)}static eq(e,t,i=0,n){null==n&&(n=999999999);let r=e.filter(e=>!e.isEmpty&&0>t.indexOf(e)),s=t.filter(t=>!t.isEmpty&&0>e.indexOf(t));if(r.length!=s.length)return!1;if(!r.length)return!0;let o=rc(r,s),l=new rp(r,o,0).goto(i),a=new rp(s,o,0).goto(i);for(;;){if(l.to!=a.to||!rg(l.active,a.active)||l.point&&(!a.point||!rr(l.point,a.point)))return!1;if(l.to>n)return!0;l.next(),a.next()}}static spans(e,t,i,n,r=-1){let s=new rp(e,null,r).goto(t),o=t,l=s.openStart;for(;;){let e=Math.min(s.to,i);if(s.point){let i=s.activeForPoint(s.to),r=s.pointFrom<t?i.length+1:s.point.startSide<0?i.length:Math.min(i.length,l);n.point(o,e,s.point,i,r,s.pointRank),l=Math.min(s.openEnd(e),i.length)}else e>o&&(n.span(o,e,s.active,l),l=s.openEnd(e));if(s.to>i)return l+(s.point&&s.to>i?1:0);o=s.to,s.next()}}static of(e,t=!1){let i=new rh;for(let n of e instanceof rs?[e]:t?function(e){if(e.length>1)for(let t=e[0],i=1;i<e.length;i++){let n=e[i];if(ro(t,n)>0)return e.slice().sort(ro);t=n}return e}(e):e)i.add(n.from,n.to,n.value);return i.finish()}static join(e){if(!e.length)return ra.empty;let t=e[e.length-1];for(let i=e.length-2;i>=0;i--)for(let n=e[i];n!=ra.empty;n=n.nextLayer)t=new ra(n.chunkPos,n.chunk,t,Math.max(n.maxPoint,t.maxPoint));return t}}ra.empty=new ra([],[],null,-1),ra.empty.nextLayer=ra.empty;class rh{finishChunk(e){this.chunks.push(new rl(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(e,t,i){this.addInner(e,t,i)||(this.nextLayer||(this.nextLayer=new rh)).add(e,t,i)}addInner(e,t,i){let n=e-this.lastTo||i.startSide-this.last.endSide;if(n<=0&&0>(e-this.lastFrom||i.startSide-this.last.startSide))throw Error("Ranges must be added sorted by `from` position and `startSide`");return!(n<0)&&(250==this.from.length&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(t-this.chunkStart),this.last=i,this.lastFrom=e,this.lastTo=t,this.value.push(i),i.point&&(this.maxPoint=Math.max(this.maxPoint,t-e)),!0)}addChunk(e,t){if(0>(e-this.lastTo||t.value[0].startSide-this.last.endSide))return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,t.maxPoint),this.chunks.push(t),this.chunkPos.push(e);let i=t.value.length-1;return this.last=t.value[i],this.lastFrom=t.from[i]+e,this.lastTo=t.to[i]+e,!0}finish(){return this.finishInner(ra.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),0==this.chunks.length)return e;let t=ra.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}}function rc(e,t,i){let n=new Map;for(let t of e)for(let e=0;e<t.chunk.length;e++)t.chunk[e].maxPoint<=0&&n.set(t.chunk[e],t.chunkPos[e]);let r=new Set;for(let e of t)for(let t=0;t<e.chunk.length;t++){let s=n.get(e.chunk[t]);null==s||(i?i.mapPos(s):s)!=e.chunkPos[t]||(null==i?void 0:i.touchesRange(s,s+e.chunk[t].length))||r.add(e.chunk[t])}return r}class rd{constructor(e,t,i,n=0){this.layer=e,this.skip=t,this.minPoint=i,this.rank=n}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(e,t=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(e,t,!1),this}gotoInner(e,t,i){for(;this.chunkIndex<this.layer.chunk.length;){let t=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(t)||this.layer.chunkEnd(this.chunkIndex)<e||t.maxPoint<this.minPoint))break;this.chunkIndex++,i=!1}if(this.chunkIndex<this.layer.chunk.length){let n=this.layer.chunk[this.chunkIndex].findIndex(e-this.layer.chunkPos[this.chunkIndex],t,!0);(!i||this.rangeIndex<n)&&this.setRangeIndex(n)}this.next()}forward(e,t){0>(this.to-e||this.endSide-t)&&this.gotoInner(e,t,!0)}next(){for(;;){if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}{let e=this.layer.chunkPos[this.chunkIndex],t=this.layer.chunk[this.chunkIndex],i=e+t.from[this.rangeIndex];if(this.from=i,this.to=e+t.to[this.rangeIndex],this.value=t.value[this.rangeIndex],this.setRangeIndex(this.rangeIndex+1),this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]);)this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=e}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(e){return this.from-e.from||this.startSide-e.startSide||this.rank-e.rank||this.to-e.to||this.endSide-e.endSide}}class ru{constructor(e){this.heap=e}static from(e,t=null,i=-1){let n=[];for(let r=0;r<e.length;r++)for(let s=e[r];!s.isEmpty;s=s.nextLayer)s.maxPoint>=i&&n.push(new rd(s,t,i,r));return 1==n.length?n[0]:new ru(n)}get startSide(){return this.value?this.value.startSide:0}goto(e,t=-1e9){for(let i of this.heap)i.goto(e,t);for(let e=this.heap.length>>1;e>=0;e--)rf(this.heap,e);return this.next(),this}forward(e,t){for(let i of this.heap)i.forward(e,t);for(let e=this.heap.length>>1;e>=0;e--)rf(this.heap,e);0>(this.to-e||this.value.endSide-t)&&this.next()}next(){if(0==this.heap.length)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),rf(this.heap,0)}}}function rf(e,t){for(let i=e[t];;){let n=(t<<1)+1;if(n>=e.length)break;let r=e[n];if(n+1<e.length&&r.compare(e[n+1])>=0&&(r=e[n+1],n++),0>i.compare(r))break;e[n]=i,e[t]=r,t=n}}class rp{constructor(e,t,i){this.minPoint=i,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=ru.from(e,t,i)}goto(e,t=-1e9){return this.cursor.goto(e,t),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=t,this.openStart=-1,this.next(),this}forward(e,t){for(;this.minActive>-1&&0>(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-t);)this.removeActive(this.minActive);this.cursor.forward(e,t)}removeActive(e){rx(this.active,e),rx(this.activeTo,e),rx(this.activeRank,e),this.minActive=ry(this.active,this.activeTo)}addActive(e){let t=0,{value:i,to:n,rank:r}=this.cursor;for(;t<this.activeRank.length&&(r-this.activeRank[t]||n-this.activeTo[t])>0;)t++;rv(this.active,t,i),rv(this.activeTo,t,n),rv(this.activeRank,t,r),e&&rv(e,t,this.cursor.from),this.minActive=ry(this.active,this.activeTo)}next(){let e=this.to,t=this.point;this.point=null;let i=this.openStart<0?[]:null;for(;;){let n=this.minActive;if(n>-1&&0>(this.activeTo[n]-this.cursor.from||this.active[n].endSide-this.cursor.startSide)){if(this.activeTo[n]>e){this.to=this.activeTo[n],this.endSide=this.active[n].endSide;break}this.removeActive(n),i&&rx(i,n)}else if(this.cursor.value){if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}{let e=this.cursor.value;if(e.point){if(t&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)this.cursor.next();else{this.point=e,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=e.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}}else this.addActive(i),this.cursor.next()}}else{this.to=this.endSide=1e9;break}}if(i){this.openStart=0;for(let t=i.length-1;t>=0&&i[t]<e;t--)this.openStart++}}activeForPoint(e){if(!this.active.length)return this.active;let t=[];for(let i=this.active.length-1;i>=0&&!(this.activeRank[i]<this.pointRank);i--)(this.activeTo[i]>e||this.activeTo[i]==e&&this.active[i].endSide>=this.point.endSide)&&t.push(this.active[i]);return t.reverse()}openEnd(e){let t=0;for(let i=this.activeTo.length-1;i>=0&&this.activeTo[i]>e;i--)t++;return t}}function rm(e,t,i,n,r,s){e.goto(t),i.goto(n);let o=n+r,l=n,a=n-t,h=!!s.boundChange;for(let t=!1;;){let n=e.to+a-i.to,r=n||e.endSide-i.endSide,c=r<0?e.to+a:i.to,d=Math.min(c,o);if(e.point||i.point?(e.point&&i.point&&rr(e.point,i.point)&&rg(e.activeForPoint(e.to),i.activeForPoint(i.to))||s.comparePoint(l,d,e.point,i.point),t=!1):(t&&s.boundChange(l),d>l&&!rg(e.active,i.active)&&s.compareRange(l,d,e.active,i.active),h&&d<o&&(n||e.openEnd(c)!=i.openEnd(c))&&(t=!0)),c>o)break;l=c,r<=0&&e.next(),r>=0&&i.next()}}function rg(e,t){if(e.length!=t.length)return!1;for(let i=0;i<e.length;i++)if(e[i]!=t[i]&&!rr(e[i],t[i]))return!1;return!0}function rx(e,t){for(let i=t,n=e.length-1;i<n;i++)e[i]=e[i+1];e.pop()}function rv(e,t,i){for(let i=e.length-1;i>=t;i--)e[i+1]=e[i];e[t]=i}function ry(e,t){let i=-1,n=1e9;for(let r=0;r<t.length;r++)0>(t[r]-n||e[r].endSide-e[i].endSide)&&(i=r,n=t[r]);return i}function rb(e,t,i=e.length){let n=0;for(let r=0;r<i&&r<e.length;)9==e.charCodeAt(r)?(n+=t-n%t,r++):(n++,r=np(e,r));return n}function rw(e,t,i,n){for(let n=0,r=0;;){if(r>=t)return n;if(n==e.length)break;r+=9==e.charCodeAt(n)?i-r%i:1,n=np(e,n)}return!0===n?-1:e.length}let rk="undefined"==typeof Symbol?"__ͼ":Symbol.for("ͼ"),rS="undefined"==typeof Symbol?"__styleSet"+Math.floor(1e8*Math.random()):Symbol("styleSet"),rC="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:{};class rj{constructor(e,t){this.rules=[];let{finish:i}=t||{};function n(e){return/^@/.test(e)?[e]:e.split(/,\s*/)}for(let t in e)!function e(t,r,s,o){let l=[],a=/^@(\w+)\b/.exec(t[0]),h=a&&"keyframes"==a[1];if(a&&null==r)return s.push(t[0]+";");for(let i in r){let o=r[i];if(/&/.test(i))e(i.split(/,\s*/).map(e=>t.map(t=>e.replace(/&/,t))).reduce((e,t)=>e.concat(t)),o,s);else if(o&&"object"==typeof o){if(!a)throw RangeError("The value of a property ("+i+") should be a primitive value.");e(n(i),o,l,h)}else null!=o&&l.push(i.replace(/_.*/,"").replace(/[A-Z]/g,e=>"-"+e.toLowerCase())+": "+o+";")}(l.length||h)&&s.push((!i||a||o?t:t.map(i)).join(", ")+" {"+l.join(" ")+"}")}(n(t),e[t],this.rules)}getRules(){return this.rules.join("\n")}static newName(){let e=rC[rk]||1;return rC[rk]=e+1,"ͼ"+e.toString(36)}static mount(e,t,i){let n=e[rS],r=i&&i.nonce;n?r&&n.setNonce(r):n=new rZ(e,r),n.mount(Array.isArray(t)?t:[t],e)}}let rM=new Map;class rZ{constructor(e,t){let i=e.ownerDocument||e,n=i.defaultView;if(!e.head&&e.adoptedStyleSheets&&n.CSSStyleSheet){let t=rM.get(i);if(t)return e[rS]=t;this.sheet=new n.CSSStyleSheet,rM.set(i,this)}else this.styleTag=i.createElement("style"),t&&this.styleTag.setAttribute("nonce",t);this.modules=[],e[rS]=this}mount(e,t){let i=this.sheet,n=0,r=0;for(let t=0;t<e.length;t++){let s=e[t],o=this.modules.indexOf(s);if(o<r&&o>-1&&(this.modules.splice(o,1),r--,o=-1),-1==o){if(this.modules.splice(r++,0,s),i)for(let e=0;e<s.rules.length;e++)i.insertRule(s.rules[e],n++)}else{for(;r<o;)n+=this.modules[r++].rules.length;n+=s.rules.length,r++}}if(i)0>t.adoptedStyleSheets.indexOf(this.sheet)&&(t.adoptedStyleSheets=[this.sheet,...t.adoptedStyleSheets]);else{let e="";for(let t=0;t<this.modules.length;t++)e+=this.modules[t].getRules()+"\n";this.styleTag.textContent=e;let i=t.head||t;this.styleTag.parentNode!=i&&i.insertBefore(this.styleTag,i.firstChild)}}setNonce(e){this.styleTag&&this.styleTag.getAttribute("nonce")!=e&&this.styleTag.setAttribute("nonce",e)}}for(var rA={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:"'"},rT={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},rO="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),rD="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),rR=0;rR<10;rR++)rA[48+rR]=rA[96+rR]=String(rR);for(var rR=1;rR<=24;rR++)rA[rR+111]="F"+rR;for(var rR=65;rR<=90;rR++)rA[rR]=String.fromCharCode(rR+32),rT[rR]=String.fromCharCode(rR);for(var rP in rA)rT.hasOwnProperty(rP)||(rT[rP]=rA[rP]);function rL(){var e=arguments[0];"string"==typeof e&&(e=document.createElement(e));var t=1,i=arguments[1];if(i&&"object"==typeof i&&null==i.nodeType&&!Array.isArray(i)){for(var n in i)if(Object.prototype.hasOwnProperty.call(i,n)){var r=i[n];"string"==typeof r?e.setAttribute(n,r):null!=r&&(e[n]=r)}t++}for(;t<arguments.length;t++)(function e(t,i){if("string"==typeof i)t.appendChild(document.createTextNode(i));else if(null==i);else if(null!=i.nodeType)t.appendChild(i);else if(Array.isArray(i))for(var n=0;n<i.length;n++)e(t,i[n]);else throw RangeError("Unsupported child node: "+i)})(e,arguments[t]);return e}let rI="undefined"!=typeof navigator?navigator:{userAgent:"",vendor:"",platform:""},rE="undefined"!=typeof document?document:{documentElement:{style:{}}},rB=/Edge\/(\d+)/.exec(rI.userAgent),rN=/MSIE \d/.test(rI.userAgent),rz=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(rI.userAgent),rW=!!(rN||rz||rB),rF=!rW&&/gecko\/(\d+)/i.test(rI.userAgent),rV=!rW&&/Chrome\/(\d+)/.exec(rI.userAgent),rH="webkitFontSmoothing"in rE.documentElement.style,r$=!rW&&/Apple Computer/.test(rI.vendor),rq=r$&&(/Mobile\/\w+/.test(rI.userAgent)||rI.maxTouchPoints>2);var rK={mac:rq||/Mac/.test(rI.platform),windows:/Win/.test(rI.platform),linux:/Linux|X11/.test(rI.platform),ie:rW,ie_version:rN?rE.documentMode||6:rz?+rz[1]:rB?+rB[1]:0,gecko:rF,gecko_version:rF?+(/Firefox\/(\d+)/.exec(rI.userAgent)||[0,0])[1]:0,chrome:!!rV,chrome_version:rV?+rV[1]:0,ios:rq,android:/Android\b/.test(rI.userAgent),webkit:rH,webkit_version:rH?+(/\bAppleWebKit\/(\d+)/.exec(rI.userAgent)||[0,0])[1]:0,safari:r$,safari_version:r$?+(/\bVersion\/(\d+(\.\d+)?)/.exec(rI.userAgent)||[0,0])[1]:0,tabSize:null!=rE.documentElement.style.tabSize?"tab-size":"-moz-tab-size"};function rU(e,t){for(let i in e)"class"==i&&t.class?t.class+=" "+e.class:"style"==i&&t.style?t.style+=";"+e.style:t[i]=e[i];return t}let r_=Object.create(null);function rG(e,t,i){if(e==t)return!0;e||(e=r_),t||(t=r_);let n=Object.keys(e),r=Object.keys(t);if(n.length-(i&&n.indexOf(i)>-1?1:0)!=r.length-(i&&r.indexOf(i)>-1?1:0))return!1;for(let s of n)if(s!=i&&(-1==r.indexOf(s)||e[s]!==t[s]))return!1;return!0}function rJ(e,t,i){let n=!1;if(t)for(let r in t)i&&r in i||(n=!0,"style"==r?e.style.cssText="":e.removeAttribute(r));if(i)for(let r in i)t&&t[r]==i[r]||(n=!0,"style"==r?e.style.cssText=i[r]:e.setAttribute(r,i[r]));return n}class rX{eq(e){return!1}updateDOM(e,t){return!1}compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}get estimatedHeight(){return -1}get lineBreaks(){return 0}ignoreEvent(e){return!0}coordsAt(e,t,i){return null}get isHidden(){return!1}get editable(){return!1}destroy(e){}}var rY=function(e){return e[e.Text=0]="Text",e[e.WidgetBefore=1]="WidgetBefore",e[e.WidgetAfter=2]="WidgetAfter",e[e.WidgetRange=3]="WidgetRange",e}(rY||(rY={}));class rQ extends rn{constructor(e,t,i,n){super(),this.startSide=e,this.endSide=t,this.widget=i,this.spec=n}get heightRelevant(){return!1}static mark(e){return new r0(e)}static widget(e){let t=Math.max(-1e4,Math.min(1e4,e.side||0)),i=!!e.block;return t+=i&&!e.inlineOrder?t>0?3e8:-4e8:t>0?1e8:-1e8,new r2(e,t,t,i,e.widget||null,!1)}static replace(e){let t=!!e.block,i,n;if(e.isBlockGap)i=-5e8,n=4e8;else{let{start:r,end:s}=r5(e,t);i=(r?t?-3e8:-1:5e8)-1,n=(s?t?2e8:1:-6e8)+1}return new r2(e,i,n,t,e.widget||null,!0)}static line(e){return new r1(e)}static set(e,t=!1){return ra.of(e,t)}hasHeight(){return!!this.widget&&this.widget.estimatedHeight>-1}}rQ.none=ra.empty;class r0 extends rQ{constructor(e){let{start:t,end:i}=r5(e);super(t?-1:5e8,i?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?rU(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||r_}eq(e){return this==e||e instanceof r0&&this.tagName==e.tagName&&rG(this.attrs,e.attrs)}range(e,t=e){if(e>=t)throw RangeError("Mark decorations may not be empty");return super.range(e,t)}}r0.prototype.point=!1;class r1 extends rQ{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof r1&&this.spec.class==e.spec.class&&rG(this.spec.attributes,e.spec.attributes)}range(e,t=e){if(t!=e)throw RangeError("Line decoration ranges must be zero-length");return super.range(e,t)}}r1.prototype.mapMode=nv.TrackBefore,r1.prototype.point=!0;class r2 extends rQ{constructor(e,t,i,n,r,s){super(t,i,r,e),this.block=n,this.isReplace=s,this.mapMode=n?t<=0?nv.TrackBefore:nv.TrackAfter:nv.TrackDel}get type(){return this.startSide!=this.endSide?rY.WidgetRange:this.startSide<=0?rY.WidgetBefore:rY.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){var t,i;return e instanceof r2&&((t=this.widget)==(i=e.widget)||!!(t&&i&&t.compare(i)))&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,t=e){if(this.isReplace&&(e>t||e==t&&this.startSide>0&&this.endSide<=0))throw RangeError("Invalid range for replacement decoration");if(!this.isReplace&&t!=e)throw RangeError("Widget decorations can only have zero-length ranges");return super.range(e,t)}}function r5(e,t=!1){let{inclusiveStart:i,inclusiveEnd:n}=e;return null==i&&(i=e.inclusive),null==n&&(n=e.inclusive),{start:null!=i?i:t,end:null!=n?n:t}}function r4(e,t,i,n=0){let r=i.length-1;r>=0&&i[r]+n>=e?i[r]=Math.max(i[r],t):i.push(e,t)}r2.prototype.point=!0;class r6 extends rn{constructor(e,t){super(),this.tagName=e,this.attributes=t}eq(e){return e==this||e instanceof r6&&this.tagName==e.tagName&&rG(this.attributes,e.attributes)}static create(e){return new r6(e.tagName,e.attributes||r_)}static set(e,t=!1){return ra.of(e,t)}}function r3(e){return(11==e.nodeType?e.getSelection?e:e.ownerDocument:e).getSelection()}function r8(e,t){return!!t&&(e==t||e.contains(1!=t.nodeType?t.parentNode:t))}function r9(e,t){if(!t.anchorNode)return!1;try{return r8(e,t.anchorNode)}catch(e){return!1}}function r7(e){return 3==e.nodeType?sc(e,0,e.nodeValue.length).getClientRects():1==e.nodeType?e.getClientRects():[]}function se(e,t,i,n){return!!i&&(sn(e,t,i,n,-1)||sn(e,t,i,n,1))}function st(e){for(var t=0;;t++)if(!(e=e.previousSibling))return t}function si(e){return 1==e.nodeType&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(e.nodeName)}function sn(e,t,i,n,r){for(;;){if(e==i&&t==n)return!0;if(t==(r<0?0:sr(e))){if("DIV"==e.nodeName)return!1;let i=e.parentNode;if(!i||1!=i.nodeType)return!1;t=st(e)+(r<0?0:1),e=i}else{if(1!=e.nodeType||1==(e=e.childNodes[t+(r<0?-1:0)]).nodeType&&"false"==e.contentEditable)return!1;t=r<0?sr(e):0}}}function sr(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function ss(e,t){let i=t?e.left:e.right;return{left:i,right:i,top:e.top,bottom:e.bottom}}function so(e,t){let i=t.width/e.offsetWidth,n=t.height/e.offsetHeight;return(i>.995&&i<1.005||!isFinite(i)||1>Math.abs(t.width-e.offsetWidth))&&(i=1),(n>.995&&n<1.005||!isFinite(n)||1>Math.abs(t.height-e.offsetHeight))&&(n=1),{scaleX:i,scaleY:n}}r6.prototype.startSide=r6.prototype.endSide=-1;class sl{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:t,focusNode:i}=e;this.set(t,Math.min(e.anchorOffset,t?sr(t):0),i,Math.min(e.focusOffset,i?sr(i):0))}set(e,t,i,n){this.anchorNode=e,this.anchorOffset=t,this.focusNode=i,this.focusOffset=n}}let sa=null;function sh(e){if(e.setActive)return e.setActive();if(sa)return e.focus(sa);let t=[];for(let i=e;i&&(t.push(i,i.scrollTop,i.scrollLeft),i!=i.ownerDocument);i=i.parentNode);if(e.focus(null==sa?{get preventScroll(){return sa={preventScroll:!0},!0}}:void 0),!sa){sa=!1;for(let e=0;e<t.length;){let i=t[e++],n=t[e++],r=t[e++];i.scrollTop!=n&&(i.scrollTop=n),i.scrollLeft!=r&&(i.scrollLeft=r)}}}function sc(e,t,i=t){let n=r||(r=document.createRange());return n.setEnd(e,i),n.setStart(e,t),n}function sd(e,t,i,n){let r={key:t,code:t,keyCode:i,which:i,cancelable:!0};n&&({altKey:r.altKey,ctrlKey:r.ctrlKey,shiftKey:r.shiftKey,metaKey:r.metaKey}=n);let s=new KeyboardEvent("keydown",r);s.synthetic=!0,e.dispatchEvent(s);let o=new KeyboardEvent("keyup",r);return o.synthetic=!0,e.dispatchEvent(o),s.defaultPrevented||o.defaultPrevented}function su(e){return e.scrollTop>Math.max(1,e.scrollHeight-e.clientHeight-4)}function sf(e,t){for(let i=e,n=t;;){if(3==i.nodeType&&n>0)return{node:i,offset:n};if(1==i.nodeType&&n>0){if("false"==i.contentEditable)return null;n=sr(i=i.childNodes[n-1])}else{if(!i.parentNode||si(i))return null;n=st(i),i=i.parentNode}}}function sp(e,t){for(let i=e,n=t;;){if(3==i.nodeType&&n<i.nodeValue.length)return{node:i,offset:n};if(1==i.nodeType&&n<i.childNodes.length){if("false"==i.contentEditable)return null;i=i.childNodes[n],n=0}else{if(!i.parentNode||si(i))return null;n=st(i)+1,i=i.parentNode}}}rK.safari&&rK.safari_version>=26&&(sa=!1);class sm{constructor(e,t,i=!0){this.node=e,this.offset=t,this.precise=i}static before(e,t){return new sm(e.parentNode,st(e),t)}static after(e,t){return new sm(e.parentNode,st(e)+1,t)}}var sg=function(e){return e[e.LTR=0]="LTR",e[e.RTL=1]="RTL",e}(sg||(sg={}));let sx=sg.LTR,sv=sg.RTL;function sy(e){let t=[];for(let i=0;i<e.length;i++)t.push(1<<+e[i]);return t}let sb=sy("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),sw=sy("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),sk=Object.create(null),sS=[];for(let e of["()","[]","{}"]){let t=e.charCodeAt(0),i=e.charCodeAt(1);sk[t]=i,sk[i]=-t}function sC(e){return e<=247?sb[e]:1424<=e&&e<=1524?2:1536<=e&&e<=1785?sw[e-1536]:1774<=e&&e<=2220?4:8192<=e&&e<=8204?256:64336<=e&&e<=65023?4:1}let sj=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;class sM{get dir(){return this.level%2?sv:sx}constructor(e,t,i){this.from=e,this.to=t,this.level=i}side(e,t){return this.dir==t==e?this.to:this.from}forward(e,t){return e==(this.dir==t)}static find(e,t,i,n){let r=-1;for(let s=0;s<e.length;s++){let o=e[s];if(o.from<=t&&o.to>=t){if(o.level==i)return s;(r<0||(0!=n?n<0?o.from<t:o.to>t:e[r].level>o.level))&&(r=s)}}if(r<0)throw RangeError("Index out of range");return r}}let sZ=[];function sA(e){return[new sM(0,e,0)]}let sT="",sO=nD.define(),sD=nD.define(),sR=nD.define(),sP=nD.define(),sL=nD.define(),sI=nD.define(),sE=nD.define(),sB=nD.define(),sN=nD.define(),sz=nD.define({combine:e=>e.some(e=>e)}),sW=nD.define({combine:e=>e.some(e=>e)}),sF=nD.define();class sV{constructor(e,t="nearest",i="nearest",n=5,r=5,s=!1){this.range=e,this.y=t,this.x=i,this.yMargin=n,this.xMargin=r,this.isSnapshot=s}map(e){return e.empty?this:new sV(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new sV(nA.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}let sH=n5.define({map:(e,t)=>e.map(t)}),s$=n5.define();function sq(e,t,i){let n=e.facet(sP);n.length?n[0](t):window.onerror&&window.onerror(String(t),i,void 0,void 0,t)||(i?console.error(i+":",t):console.error(t))}let sK=nD.define({combine:e=>!e.length||e[0]}),sU=0,s_=nD.define({combine:e=>e.filter((t,i)=>{for(let n=0;n<i;n++)if(e[n].plugin==t.plugin)return!1;return!0})});class sG{constructor(e,t,i,n,r){this.id=e,this.create=t,this.domEventHandlers=i,this.domEventObservers=n,this.baseExtensions=r(this),this.extension=this.baseExtensions.concat(s_.of({plugin:this,arg:void 0}))}of(e){return this.baseExtensions.concat(s_.of({plugin:this,arg:e}))}static define(e,t){let{eventHandlers:i,eventObservers:n,provide:r,decorations:s}=t||{};return new sG(sU++,e,i,n,e=>{let t=[];return s&&t.push(sQ.of(t=>{let i=t.plugin(e);return i?s(i):rQ.none})),r&&t.push(r(e)),t})}static fromClass(e,t){return sG.define((t,i)=>new e(t,i),t)}}class sJ{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(e){if(this.value){if(this.mustUpdate){let e=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(e)}catch(t){if(sq(e.state,t,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch(e){}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(t){sq(e.state,t,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var t;if(null===(t=this.value)||void 0===t?void 0:t.destroy)try{this.value.destroy()}catch(t){sq(e.state,t,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}let sX=nD.define(),sY=nD.define(),sQ=nD.define(),s0=nD.define(),s1=nD.define(),s2=nD.define(),s5=nD.define();function s4(e,t){let i=e.state.facet(s5);if(!i.length)return i;let n=i.map(t=>t instanceof Function?t(e):t),r=[];return ra.spans(n,t.from,t.to,{point(){},span(e,i,n,s){let o=e-t.from,l=i-t.from,a=r;for(let e=n.length-1;e>=0;e--,s--){let i=n[e].spec.bidiIsolate,r;if(null==i&&(i=function(e,t,i){for(let n=t;n<i;n++){let t=sC(e.charCodeAt(n));if(1==t)break;if(2==t||4==t)return sv}return sx}(t.text,o,l)),s>0&&a.length&&(r=a[a.length-1]).to==o&&r.direction==i)r.to=l,a=r.inner;else{let e={from:o,to:l,direction:i,inner:[]};a.push(e),a=e.inner}}}}),r}let s6=nD.define();function s3(e){let t=0,i=0,n=0,r=0;for(let s of e.state.facet(s6)){let o=s(e);o&&(null!=o.left&&(t=Math.max(t,o.left)),null!=o.right&&(i=Math.max(i,o.right)),null!=o.top&&(n=Math.max(n,o.top)),null!=o.bottom&&(r=Math.max(r,o.bottom)))}return{left:t,right:i,top:n,bottom:r}}let s8=nD.define();class s9{constructor(e,t,i,n){this.fromA=e,this.toA=t,this.fromB=i,this.toB=n}join(e){return new s9(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let t=e.length,i=this;for(;t>0;t--){let n=e[t-1];if(!(n.fromA>i.toA)){if(n.toA<i.fromA)break;i=i.join(n),e.splice(t-1,1)}}return e.splice(t,0,i),e}static extendWithRanges(e,t){if(0==t.length)return e;let i=[];for(let n=0,r=0,s=0;;){let o=Math.min(n<e.length?e[n].fromB:1e9,r<t.length?t[r]:1e9);if(1e9==o)break;let l=o+s,a=o,h=l;for(;;)if(r<t.length&&t[r]<=a){let i=t[r+1];r+=2,a=Math.max(a,i);for(let t=n;t<e.length&&e[t].fromB<=a;t++)s=e[t].toA-e[t].toB;h=Math.max(h,i+s)}else if(n<e.length&&e[n].fromB<=a){let t=e[n++];a=Math.max(a,t.toB),h=Math.max(h,t.toA),s=t.toA-t.toB}else break;i.push(new s9(l,h,o,a))}return i}}class s7{constructor(e,t,i){for(let n of(this.view=e,this.state=t,this.transactions=i,this.flags=0,this.startState=e.state,this.changes=nb.empty(this.startState.doc.length),i))this.changes=this.changes.compose(n.changes);let n=[];this.changes.iterChangedRanges((e,t,i,r)=>n.push(new s9(e,t,i,r))),this.changedRanges=n}static create(e,t,i){return new s7(e,t,i)}get viewportChanged(){return(4&this.flags)>0}get viewportMoved(){return(8&this.flags)>0}get heightChanged(){return(2&this.flags)>0}get geometryChanged(){return this.docChanged||(18&this.flags)>0}get focusChanged(){return(1&this.flags)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return 0==this.flags&&0==this.transactions.length}}let oe=[];class ot{constructor(e,t,i=0){this.dom=e,this.length=t,this.flags=i,this.parent=null,e.cmTile=this}get breakAfter(){return 1&this.flags}get children(){return oe}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(e){if(this.flags|=2,4&this.flags){this.flags&=-5;let e=this.domAttrs;e&&function(e,t){for(let i=e.attributes.length-1;i>=0;i--){let n=e.attributes[i].name;null==t[n]&&e.removeAttribute(n)}for(let i in t){let n=t[i];"style"==i?e.style.cssText=n:e.getAttribute(i)!=n&&e.setAttribute(i,n)}}(this.dom,e)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:"")+(this.breakAfter?"#":"")}destroy(){this.parent=null}setDOM(e){this.dom=e,e.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e,t=this.posAtStart){let i=t;for(let t of this.children){if(t==e)return i;i+=t.length+t.breakAfter}throw RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,t){return null}domPosFor(e,t){let i=st(this.dom),n=this.length?e>0:t>0;return new sm(this.parent.dom,i+(n?1:0),0==e||e==this.length)}markDirty(e){this.flags&=-3,e&&(this.flags|=4),this.parent&&2&this.parent.flags&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let e=this;e;e=e.parent)if(e instanceof or)return e;return null}static get(e){return e.cmTile}}class oi extends ot{constructor(e){super(e,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(e){this.children.push(e),e.parent=this}sync(e){if(2&this.flags)return;super.sync(e);let t=this.dom,i=null,n,r=(null==e?void 0:e.node)==t?e:null,s=0;for(let o of this.children){if(o.sync(e),s+=o.length+o.breakAfter,n=i?i.nextSibling:t.firstChild,r&&n!=o.dom&&(r.written=!0),o.dom.parentNode==t)for(;n&&n!=o.dom;)n=on(n);else t.insertBefore(o.dom,n);i=o.dom}for(n=i?i.nextSibling:t.firstChild,r&&n&&(r.written=!0);n;)n=on(n);this.length=s}}function on(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}class or extends oi{constructor(e,t){super(t),this.view=e}owns(e){for(;e;e=e.parent)if(e==this)return!0;return!1}isBlock(){return!0}nearest(e){for(;;){if(!e)return null;let t=ot.get(e);if(t&&this.owns(t))return t;e=e.parentNode}}blockTiles(e){for(let t=[],i=this,n=0,r=0;;)if(n==i.children.length){if(!t.length)return;(i=i.parent).breakAfter&&r++,n=t.pop()}else{let s=i.children[n++];if(s instanceof os)t.push(n),i=s,n=0;else{let t=r+s.length,i=e(s,r);if(void 0!==i)return i;r=t+s.breakAfter}}}resolveBlock(e,t){let i,n=-1,r,s=-1;if(this.blockTiles((o,l)=>{let a=l+o.length;if(e>=l&&e<=a){if(o.isWidget()&&t>=-1&&t<=1){if(32&o.flags)return!0;16&o.flags&&(i=void 0)}(l<e||e==a&&(t<-1?o.length:o.covers(1)))&&(!i||!o.isWidget()&&i.isWidget())&&(i=o,n=e-l),(a>e||e==l&&(t>1?o.length:o.covers(-1)))&&(!r||!o.isWidget()&&r.isWidget())&&(r=o,s=e-l)}}),!i&&!r)throw Error("No tile at position "+e);return i&&t<0||!r?{tile:i,offset:n}:{tile:r,offset:s}}}class os extends oi{constructor(e,t){super(e),this.wrapper=t}isBlock(){return!0}covers(e){return!!this.children.length&&(e<0?this.children[0].covers(-1):this.lastChild.covers(1))}get domAttrs(){return this.wrapper.attributes}static of(e,t){let i=new os(t||document.createElement(e.tagName),e);return t||(i.flags|=4),i}}class oo extends oi{constructor(e,t){super(e),this.attrs=t}isLine(){return!0}static start(e,t,i){let n=new oo(t||document.createElement("div"),e);return t&&i||(n.flags|=4),n}get domAttrs(){return this.attrs}resolveInline(e,t,i){let n=null,r=-1,s=null,o=-1;!function e(l,a){for(let h=0,c=0;h<l.children.length&&c<=a;h++){let d=l.children[h],u=c+d.length;u>=a&&(d.isComposite()?e(d,a-c):(!s||s.isHidden&&(t>0||i&&function(e,t){let i=e.coordsIn(0,1),n=t.coordsIn(0,1);return i&&n&&n.top<i.bottom}(s,d)))&&(u>a||32&d.flags)?(s=d,o=a-c):(c<a||16&d.flags&&!d.isHidden)&&(n=d,r=a-c)),c=u}}(this,e);let l=(t<0?n:s)||n||s;return l?{tile:l,offset:l==n?r:o}:null}coordsIn(e,t){let i=this.resolveInline(e,t,!0);return i?i.tile.coordsIn(Math.max(0,i.offset),t):function(e){let t=e.dom.lastChild;if(!t)return e.dom.getBoundingClientRect();let i=r7(t);return i[i.length-1]||null}(this)}domIn(e,t){let i=this.resolveInline(e,t);if(i){let{tile:e,offset:n}=i;if(this.dom.contains(e.dom))return e.isText()?new sm(e.dom,Math.min(e.dom.nodeValue.length,n)):e.domPosFor(n,16&e.flags?1:32&e.flags?-1:t);let r=i.tile.parent,s=!1;for(let e of r.children){if(s)return new sm(e.dom,0);e==i.tile&&(s=!0)}}return new sm(this.dom,0)}}class ol extends oi{constructor(e,t){super(e),this.mark=t}get domAttrs(){return this.mark.attrs}static of(e,t){let i=new ol(t||document.createElement(e.tagName),e);return t||(i.flags|=4),i}}class oa extends ot{constructor(e,t){super(e,t.length),this.text=t}sync(e){2&this.flags||(super.sync(e),this.dom.nodeValue==this.text||(e&&e.node==this.dom&&(e.written=!0),this.dom.nodeValue=this.text))}isText(){return!0}toString(){return JSON.stringify(this.text)}coordsIn(e,t){let i=this.dom.nodeValue.length;e>i&&(e=i);let n=e,r=e,s=0;0==e&&t<0||e==i&&t>=0?!(rK.chrome||rK.gecko)&&(e?(n--,s=1):r<i&&(r++,s=-1)):t<0?n--:r<i&&r++;let o=sc(this.dom,n,r).getClientRects();if(!o.length)return null;let l=o[(s?s<0:t>=0)?0:o.length-1];return rK.safari&&!s&&0==l.width&&(l=Array.prototype.find.call(o,e=>e.width)||l),s?ss(l,s<0):l||null}static of(e,t){let i=new oa(t||document.createTextNode(e),e);return t||(i.flags|=2),i}}class oh extends ot{constructor(e,t,i,n){super(e,t,n),this.widget=i}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(e){return!(48&this.flags)&&(this.flags&(e<0?64:128))>0}coordsIn(e,t){return this.coordsInWidget(e,t,!1)}coordsInWidget(e,t,i){let n=this.widget.coordsAt(this.dom,e,t);if(n)return n;if(i)return ss(this.dom.getBoundingClientRect(),this.length?0==e:t<=0);{let t=this.dom.getClientRects(),i=null;if(!t.length)return null;let n=!!(16&this.flags)||!(32&this.flags)&&e>0;for(let r=n?t.length-1:0;i=t[r],e>0?0!=r:r!=t.length-1&&!(i.top<i.bottom);r+=n?-1:1);return ss(i,!n)}}get overrideDOMText(){if(!this.length)return ns.empty;let{root:e}=this;if(!e)return ns.empty;let t=this.posAtStart;return e.view.state.doc.slice(t,t+this.length)}destroy(){super.destroy(),this.widget.destroy(this.dom)}static of(e,t,i,n,r){return r||(r=e.toDOM(t),e.editable||(r.contentEditable="false")),new oh(r,i,e,n)}}class oc extends ot{constructor(e){let t=document.createElement("img");t.className="cm-widgetBuffer",t.setAttribute("aria-hidden","true"),super(t,0,e)}get isHidden(){return!0}get overrideDOMText(){return ns.empty}coordsIn(e){return this.dom.getBoundingClientRect()}}class od{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,t,i){let{tile:n,index:r,beforeBreak:s,parents:o}=this;for(;e||t>0;)if(n.isComposite()){if(s){if(!e)break;i&&i.break(),e--,s=!1}else if(r==n.children.length){if(!e&&!o.length)break;i&&i.leave(n),s=!!n.breakAfter,({tile:n,index:r}=o.pop()),r++}else{let l=n.children[r],a=l.breakAfter;(t>0?l.length<=e:l.length<e)&&(!i||!1!==i.skip(l,0,l.length)||!l.isComposite)?(s=!!a,r++,e-=l.length):(o.push({tile:n,index:r}),n=l,r=0,i&&l.isComposite()&&i.enter(l))}}else if(r==n.length)s=!!n.breakAfter,({tile:n,index:r}=o.pop()),r++;else if(e){let t=Math.min(e,n.length-r);i&&i.skip(n,r,r+t),e-=t,r+=t}else break;return this.tile=n,this.index=r,this.beforeBreak=s,this}get root(){return this.parents.length?this.parents[0].tile:this.tile}}class ou{constructor(e,t,i,n){this.from=e,this.to=t,this.wrapper=i,this.rank=n}}class of{constructor(e,t,i){this.cache=e,this.root=t,this.blockWrappers=i,this.curLine=null,this.lastBlock=null,this.afterWidget=null,this.pos=0,this.wrappers=[],this.wrapperPos=0}addText(e,t,i,n){var r;this.flushBuffer();let s=this.ensureMarks(t,i),o=s.lastChild;o&&o.isText()&&!(8&o.flags)&&o.length+e.length<512?(this.cache.reused.set(o,2),(s.children[s.children.length-1]=new oa(o.dom,o.text+e)).parent=s):s.append(n||oa.of(e,null===(r=this.cache.find(oa))||void 0===r?void 0:r.dom)),this.pos+=e.length,this.afterWidget=null}addComposition(e,t){let i=this.curLine;i.dom!=t.line.dom&&(i.setDOM(this.cache.reused.has(t.line)?ob(t.line.dom):t.line.dom),this.cache.reused.set(t.line,2));let n=i;for(let e=t.marks.length-1;e>=0;e--){let i=t.marks[e],r=n.lastChild;if(r instanceof ol&&r.mark.eq(i.mark))r.dom!=i.dom&&r.setDOM(ob(i.dom)),n=r;else{if(this.cache.reused.get(i)){let e=ot.get(i.dom);e&&e.setDOM(ob(i.dom))}let e=ol.of(i.mark,i.dom);n.append(e),n=e}this.cache.reused.set(i,2)}let r=ot.get(e.text);r&&this.cache.reused.set(r,2);let s=new oa(e.text,e.text.nodeValue);s.flags|=8,n.append(s)}addInlineWidget(e,t,i){let n=this.afterWidget&&48&e.flags&&(48&this.afterWidget.flags)==(48&e.flags);n||this.flushBuffer();let r=this.ensureMarks(t,i);n||16&e.flags||r.append(this.getBuffer(1)),r.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,t,i){this.flushBuffer(),this.ensureMarks(t,i).append(e),this.pos+=e.length,this.afterWidget=null}addBlockWidget(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}continueWidget(e){let t=this.afterWidget||this.lastBlock;t.length+=e,this.pos+=e}addLineStart(e,t){var i;e||(e=oy);let n=oo.start(e,t||(null===(i=this.cache.find(oo))||void 0===i?void 0:i.dom),!!t);this.getBlockPos().append(this.lastBlock=this.curLine=n)}addLine(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(e){this.blockPosCovered()||this.addLineStart(e)}ensureLine(e){this.curLine||this.addLineStart(e)}ensureMarks(e,t){var i;let n=this.curLine;for(let r=e.length-1;r>=0;r--){let s=e[r],o;if(t>0&&(o=n.lastChild)&&o instanceof ol&&o.mark.eq(s))n=o,t--;else{let e=ol.of(s,null===(i=this.cache.find(ol,e=>e.mark.eq(s)))||void 0===i?void 0:i.dom);n.append(e),n=e,t=0}}return n}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!ov(this.curLine,!1)||"BR"!=e.dom.nodeName&&e.isWidget()&&!(rK.ios&&ov(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(ok,0,32)||new oh(ok.toDOM(),0,ok,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let e=this.wrappers.length-1;e>=0;e--)this.wrappers[e].to<this.pos&&this.wrappers.splice(e,1);for(let e=this.blockWrappers;e.value&&e.from<=this.pos;e.next())if(e.to>=this.pos){let t=new ou(e.from,e.to,e.value,e.rank),i=this.wrappers.length;for(;i>0&&0>(this.wrappers[i-1].rank-t.rank||this.wrappers[i-1].to-t.to);)i--;this.wrappers.splice(i,0,t)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let t=this.root;for(let i of this.wrappers){let n=t.lastChild;if(i.from<this.pos&&n instanceof os&&n.wrapper.eq(i.wrapper))t=n;else{let n=os.of(i.wrapper,null===(e=this.cache.find(os,e=>e.wrapper.eq(i.wrapper)))||void 0===e?void 0:e.dom);t.append(n),t=n}}return t}blockPosCovered(){let e=this.lastBlock;return null!=e&&!e.breakAfter&&(!e.isWidget()||(160&e.flags)>0)}getBuffer(e){let t=2|(e<0?16:32),i=this.cache.find(oc,void 0,1);return i&&(i.flags=t),i||new oc(t)}flushBuffer(){this.afterWidget&&!(32&this.afterWidget.flags)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class op{constructor(e){this.skipCount=0,this.text="",this.textOff=0,this.cursor=e.iter()}skip(e){this.textOff+e<=this.text.length?this.textOff+=e:(this.skipCount+=e-(this.text.length-this.textOff),this.text="",this.textOff=0)}next(e){if(this.textOff==this.text.length){let{value:t,lineBreak:i,done:n}=this.cursor.next(this.skipCount);if(this.skipCount=0,n)throw Error("Ran out of text content when drawing inline views");this.text=t;let r=this.textOff=Math.min(e,t.length);return i?null:t.slice(0,r)}let t=Math.min(this.text.length,this.textOff+e),i=this.text.slice(this.textOff,t);return this.textOff=t,i}}let om=[oh,oo,oa,ol,oc,os,or];for(let e=0;e<om.length;e++)om[e].bucket=e;class og{constructor(e){this.view=e,this.buckets=om.map(()=>[]),this.index=om.map(()=>0),this.reused=new Map}add(e){let t=e.constructor.bucket,i=this.buckets[t];i.length<6?i.push(e):i[this.index[t]=(this.index[t]+1)%6]=e}find(e,t,i=2){let n=e.bucket,r=this.buckets[n],s=this.index[n];for(let e=r.length-1;e>=0;e--){let o=(e+s)%r.length,l=r[o];if((!t||t(l))&&!this.reused.has(l))return r.splice(o,1),o<s&&this.index[n]--,this.reused.set(l,i),l}return null}findWidget(e,t,i){let n=this.buckets[0];if(n.length)for(let r=0,s=0;;r++){if(r==n.length){if(s)return null;s=1,r=0}let o=n[r];if(!this.reused.has(o)&&(0==s?o.widget.compare(e):o.widget.constructor==e.constructor&&e.updateDOM(o.dom,this.view))){if(n.splice(r,1),r<this.index[0]&&this.index[0]--,o.widget==e&&o.length==t&&(497&o.flags)==i)return this.reused.set(o,1),o;return this.reused.set(o,2),new oh(o.dom,t,e,-498&o.flags|i)}}}reuse(e){return this.reused.set(e,1),e}maybeReuse(e,t=2){if(!this.reused.has(e))return this.reused.set(e,t),e.dom}clear(){for(let e=0;e<this.buckets.length;e++)this.buckets[e].length=this.index[e]=0}}class ox{constructor(e,t,i,n,r){this.view=e,this.decorations=n,this.disallowBlockEffectsFor=r,this.openWidget=!1,this.openMarks=0,this.cache=new og(e),this.text=new op(e.state.doc),this.builder=new of(this.cache,new or(e,e.contentDOM),ra.iter(i)),this.cache.reused.set(t,2),this.old=new od(t),this.reuseWalker={skip:(e,t,i)=>{if(this.cache.add(e),e.isComposite())return!1},enter:e=>this.cache.add(e),leave:()=>{},break:()=>{}}}run(e,t){let i=t&&this.getCompositionContext(t.text);for(let n=0,r=0,s=0;;){let o=s<e.length?e[s++]:null,l=o?o.fromA:this.old.root.length;if(l>n){let e=l-n;this.preserve(e,!s,!o),n=l,r+=e}if(!o)break;t&&o.fromA<=t.range.fromA&&o.toA>=t.range.toA?(this.forward(o.fromA,t.range.fromA,t.range.fromA<t.range.toA?1:-1),this.emit(r,t.range.fromB),this.cache.clear(),this.builder.addComposition(t,i),this.text.skip(t.range.toB-t.range.fromB),this.forward(t.range.fromA,o.toA),this.emit(t.range.toB,o.toB)):(this.forward(o.fromA,o.toA),this.emit(r,o.toB)),r=o.toB,n=o.toA}return this.builder.curLine&&this.builder.endLine(),this.builder.root}preserve(e,t,i){let n=function(e){let t=[];for(let i=e.parents.length;i>1;i--){let n=i==e.parents.length?e.tile:e.parents[i].tile;n instanceof ol&&t.push(n.mark)}return t}(this.old),r=this.openMarks;this.old.advance(e,i?1:-1,{skip:(e,t,i)=>{if(e.isWidget()){if(this.openWidget)this.builder.continueWidget(i-t);else{let s=i>0||t<e.length?oh.of(e.widget,this.view,i-t,496&e.flags,this.cache.maybeReuse(e)):this.cache.reuse(e);256&s.flags?(s.flags&=-2,this.builder.addBlockWidget(s)):(this.builder.ensureLine(null),this.builder.addInlineWidget(s,n,r),r=n.length)}}else if(e.isText())this.builder.ensureLine(null),t||i!=e.length?(this.cache.add(e),this.builder.addText(e.text.slice(t,i),n,r)):this.builder.addText(e.text,n,r,this.cache.reuse(e)),r=n.length;else if(e.isLine())e.flags&=-2,this.cache.reused.set(e,1),this.builder.addLine(e);else if(e instanceof oc)this.cache.add(e);else{if(!(e instanceof ol))return!1;this.builder.ensureLine(null),this.builder.addMark(e,n,r),this.cache.reused.set(e,1),r=n.length}this.openWidget=!1},enter:e=>{e.isLine()?this.builder.addLineStart(e.attrs,this.cache.maybeReuse(e)):(this.cache.add(e),e instanceof ol&&n.unshift(e.mark)),this.openWidget=!1},leave:e=>{e.isLine()?n.length&&(n.length=r=0):e instanceof ol&&(n.shift(),r=Math.min(r,n.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,t){let i=null,n=this.builder,r=0,s=ra.spans(this.decorations,e,t,{point:(e,t,s,o,l,a)=>{var h;if(s instanceof r2){if(this.disallowBlockEffectsFor[a]){if(s.block)throw RangeError("Block decorations may not be specified via plugins");if(t>this.view.state.doc.lineAt(e).to)throw RangeError("Decorations that replace line breaks may not be specified via plugins")}if(r=o.length,l>o.length)n.continueWidget(t-e);else{let r;let a=s.widget||(s.block?ow.block:ow.inline),h=(r=s.isReplace?(s.startSide<0?64:0)|(s.endSide>0?128:0):s.startSide>0?32:16,s.block&&(r|=256),r),c=this.cache.findWidget(a,t-e,h)||oh.of(a,this.view,t-e,h);s.block?(s.startSide>0&&n.addLineStartIfNotCovered(i),n.addBlockWidget(c)):(n.ensureLine(i),n.addInlineWidget(c,o,l))}i=null}else{let e,t;h=i,e=s.spec.attributes,t=s.spec.class,(e||t)&&(h||(h={class:"cm-line"}),e&&rU(e,h),t&&(h.class+=" "+t)),i=h}t>e&&this.text.skip(t-e)},span:(e,t,r,s)=>{for(let o=e;o<t;){let l=this.text.next(Math.min(512,t-o));null==l?(n.addLineStartIfNotCovered(i),n.addBreak(),o++):(n.ensureLine(i),n.addText(l,r,o==e?s:r.length),o+=l.length),i=null}}});n.addLineStartIfNotCovered(i),this.openWidget=s>r,this.openMarks=s}forward(e,t,i=1){t-e<=10?this.old.advance(t-e,i,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(t-e-10,-1),this.old.advance(5,i,this.reuseWalker))}getCompositionContext(e){let t=[],i=null;for(let n=e.parentNode;;n=n.parentNode){let e=ot.get(n);if(n==this.view.contentDOM)break;e instanceof ol?t.push(e):(null==e?void 0:e.isLine())?i=e:"DIV"!=n.nodeName||i||n==this.view.contentDOM?t.push(ol.of(new r0({tagName:n.nodeName.toLowerCase(),attributes:function(e){let t=Object.create(null);for(let i=0;i<e.attributes.length;i++){let n=e.attributes[i];t[n.name]=n.value}return t}(n)}),n)):i=new oo(n,oy)}return{line:i,marks:t}}}function ov(e,t){let i=e=>{for(let n of e.children)if((t?n.isText():n.length)||i(n))return!0;return!1};return i(e)}let oy={class:"cm-line"};function ob(e){let t=ot.get(e);return t&&t.setDOM(e.cloneNode()),e}class ow extends rX{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}ow.inline=new ow("span"),ow.block=new ow("div");let ok=new class extends rX{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class oS{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=rQ.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.updateDeco(),this.tile=new or(e,e.contentDOM),this.updateInner([new s9(0,0,0,e.state.doc.length)],null)}update(e){var t,i,n,r,s,o,l;let a,h,c;let d=e.changedRanges;this.minWidth>0&&d.length&&(d.every(({fromA:e,toA:t})=>t<this.minWidthFrom||e>this.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(e);let u=-1;!(this.view.inputState.composing>=0)||this.view.observer.editContext||((null===(t=this.domChanged)||void 0===t?void 0:t.newSel)?u=this.domChanged.newSel.head:(i=e.changes,n=this.hasComposition,a=!1,n&&i.iterChangedRanges((e,t)=>{e<n.to&&t>n.from&&(a=!0)}),a||e.selectionSet||(u=e.state.selection.main.head)));let f=u>-1?function(e,t,i){let n=oj(e,i);if(!n)return null;let{node:r,from:s,to:o}=n,l=r.nodeValue;if(/[\n\r]/.test(l)||e.state.doc.sliceString(n.from,n.to)!=l)return null;let a=t.invertedDesc;return{range:new s9(a.mapPos(s),a.mapPos(o),s,o),text:r}}(this.view,e.changes,u):null;if(this.domChanged=null,this.hasComposition){let{from:t,to:i}=this.hasComposition;d=new s9(t,i,e.changes.mapPos(t,-1),e.changes.mapPos(i,1)).addToSet(d.slice())}this.hasComposition=f?{from:f.range.fromB,to:f.range.toB}:null,(rK.ie||rK.chrome)&&!f&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let p=this.decorations,m=this.blockWrappers;this.updateDeco();let g=(r=this.decorations,s=e.changes,h=new oM,ra.compare(p,r,s,h),h.changes);g.length&&(d=s9.extendWithRanges(d,g));let x=(o=this.blockWrappers,l=e.changes,c=new oZ,ra.compare(m,o,l,c),c.changes);return x.length&&(d=s9.extendWithRanges(d,x)),f&&!d.some(e=>e.fromA<=f.range.fromA&&e.toA>=f.range.toA)&&(d=f.range.addToSet(d.slice())),(!(2&this.tile.flags)||0!=d.length)&&(this.updateInner(d,f),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t){this.view.viewState.mustMeasureContent=!0;let{observer:i}=this.view;i.ignore(()=>{if(t||e.length){let i=this.tile,n=new ox(this.view,i,this.blockWrappers,this.decorations,this.dynamicDecorationMap);this.tile=n.run(e,t),oC(i,n.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let n=rK.chrome||rK.ios?{node:i.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(n),n&&(n.written||i.selectionRange.focusNode!=n.node||!this.tile.dom.contains(n.node))&&(this.forceSelection=!0),this.tile.dom.style.height=""});let n=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let e of this.tile.children)e.isWidget()&&e.widget instanceof oA&&n.push(e.dom);i.updateGaps(n)}updateEditContextFormatting(e){for(let t of(this.editContextFormatting=this.editContextFormatting.map(e.changes),e.transactions))for(let e of t.effects)e.is(s$)&&(this.editContextFormatting=e.value)}updateSelection(e=!1,t=!1){var i;(e||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange();let{dom:n}=this.tile,r=this.view.root.activeElement,s=r==n,o=!s&&!(this.view.state.facet(sK)||n.tabIndex>-1)&&r9(n,this.view.observer.selectionRange)&&!(r&&n.contains(r));if(!(s||t||o))return;let l=this.forceSelection;this.forceSelection=!1;let a=this.view.state.selection.main,h,c;if(a.empty?c=h=this.inlineDOMNearPos(a.anchor,a.assoc||1):(c=this.inlineDOMNearPos(a.head,a.head==a.from?1:-1),h=this.inlineDOMNearPos(a.anchor,a.anchor==a.from?1:-1)),rK.gecko&&a.empty&&!this.hasComposition&&1==(i=h).node.nodeType&&i.node.firstChild&&(0==i.offset||"false"==i.node.childNodes[i.offset-1].contentEditable)&&(i.offset==i.node.childNodes.length||"false"==i.node.childNodes[i.offset].contentEditable)){let e=document.createTextNode("");this.view.observer.ignore(()=>h.node.insertBefore(e,h.node.childNodes[h.offset]||null)),h=c=new sm(e,0),l=!0}let d=this.view.observer.selectionRange;!l&&d.focusNode&&(se(h.node,h.offset,d.anchorNode,d.anchorOffset)&&se(c.node,c.offset,d.focusNode,d.focusOffset)||this.suppressWidgetCursorChange(d,a))||(this.view.observer.ignore(()=>{rK.android&&rK.chrome&&n.contains(d.focusNode)&&function(e,t){for(let i=e;i&&i!=t;i=i.assignedSlot||i.parentNode)if(1==i.nodeType&&"false"==i.contentEditable)return!0;return!1}(d.focusNode,n)&&(n.blur(),n.focus({preventScroll:!0}));let e=r3(this.view.root);if(e){if(a.empty){if(rK.gecko){var t,i;let e=(t=h.node,i=h.offset,1!=t.nodeType?0:(i&&"false"==t.childNodes[i-1].contentEditable?1:0)|(i<t.childNodes.length&&"false"==t.childNodes[i].contentEditable?2:0));if(e&&3!=e){let t=(1==e?sf:sp)(h.node,h.offset);t&&(h=new sm(t.node,t.offset))}}e.collapse(h.node,h.offset),null!=a.bidiLevel&&void 0!==e.caretBidiLevel&&(e.caretBidiLevel=a.bidiLevel)}else if(e.extend){e.collapse(h.node,h.offset);try{e.extend(c.node,c.offset)}catch(e){}}else{let t=document.createRange();a.anchor>a.head&&([h,c]=[c,h]),t.setEnd(c.node,c.offset),t.setStart(h.node,h.offset),e.removeAllRanges(),e.addRange(t)}}o&&this.view.root.activeElement==n&&(n.blur(),r&&r.focus())}),this.view.observer.setSelectionRange(h,c)),this.impreciseAnchor=h.precise?null:new sm(d.anchorNode,d.anchorOffset),this.impreciseHead=c.precise?null:new sm(d.focusNode,d.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&se(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==t.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,t=e.state.selection.main,i=r3(e.root),{anchorNode:n,anchorOffset:r}=e.observer.selectionRange;if(!i||!t.empty||!t.assoc||!i.modify)return;let s=this.lineAt(t.head,t.assoc);if(!s)return;let o=s.posAtStart;if(t.head==o||t.head==o+s.length)return;let l=this.coordsAt(t.head,-1),a=this.coordsAt(t.head,1);if(!l||!a||l.bottom>a.top)return;let h=this.domAtPos(t.head+t.assoc,t.assoc);i.collapse(h.node,h.offset),i.modify("move",t.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let c=e.observer.selectionRange;e.docView.posFromDOM(c.anchorNode,c.anchorOffset)!=t.from&&i.collapse(n,r)}posFromDOM(e,t){let i=this.tile.nearest(e);if(!i)return 2&this.tile.dom.compareDocumentPosition(e)?0:this.view.state.doc.length;let n=i.posAtStart;if(i.isComposite()){let r;if(e==i.dom)r=i.dom.childNodes[t];else{let n=0==sr(e)?0:0==t?-1:1;for(;;){let t=e.parentNode;if(t==i.dom)break;0==n&&t.firstChild!=t.lastChild&&(n=e==t.firstChild?-1:1),e=t}r=n<0?e:e.nextSibling}if(r==i.dom.firstChild)return n;for(;r&&!ot.get(r);)r=r.nextSibling;if(!r)return n+i.length;for(let e=0,t=n;;e++){let n=i.children[e];if(n.dom==r)return t;t+=n.length+n.breakAfter}}else if(i.isText())return e==i.dom?n+t:n+(t?i.length:0);else return n}domAtPos(e,t){let{tile:i,offset:n}=this.tile.resolveBlock(e,t);return i.isWidget()?i.domPosFor(e,t):i.domIn(n,t)}inlineDOMNearPos(e,t){let i,n=-1,r=!1,s,o=-1,l=!1;return(this.tile.blockTiles((t,a)=>{if(t.isWidget()){if(32&t.flags&&a>=e)return!0;16&t.flags&&(r=!0)}else{let h=a+t.length;if(a<=e&&(i=t,n=e-a,r=h<e),h>=e&&!s&&(s=t,o=e-a,l=a>e),a>e&&s)return!0}}),i||s)?(r&&s?i=null:l&&i&&(s=null),i&&t<0||!s?i.domIn(n,t):s.domIn(o,t)):this.domAtPos(e,t)}coordsAt(e,t){let{tile:i,offset:n}=this.tile.resolveBlock(e,t);return i.isWidget()?i.widget instanceof oA?null:i.coordsInWidget(n,t,!0):i.coordsIn(n,t)}lineAt(e,t){let{tile:i}=this.tile.resolveBlock(e,t);return i.isLine()?i:null}coordsForChar(e){let{tile:t,offset:i}=this.tile.resolveBlock(e,1);return t.isLine()?function e(t,i){if(t.isComposite())for(let n of t.children){if(n.length>=i){let t=e(n,i);if(t)return t}if((i-=n.length)<0)break}else if(t.isText()&&i<t.length){let e=np(t.text,i);if(e==i)return null;let n=sc(t.dom,i,e).getClientRects();for(let e=0;e<n.length;e++){let t=n[e];if(e==n.length-1||t.top<t.bottom&&t.left<t.right)return t}}return null}(t,i):null}measureVisibleLineHeights(e){let t=[],{from:i,to:n}=e,r=this.view.contentDOM.clientWidth,s=r>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,o=-1,l=this.view.textDirection==sg.LTR,a=0,h=(e,c,d)=>{for(let u=0;u<e.children.length&&!(c>n);u++){let n=e.children[u],f=c+n.length,p=n.dom.getBoundingClientRect(),{height:m}=p;if(d&&!u&&(a+=p.top-d.top),n instanceof os)f>i&&h(n,c,p);else if(c>=i&&(a>0&&t.push(-a),t.push(m+a),a=0,s)){let e=n.dom.lastChild,t=e?r7(e):[];if(t.length){let e=t[t.length-1],i=l?e.right-p.left:p.right-e.left;i>o&&(o=i,this.minWidth=r,this.minWidthFrom=c,this.minWidthTo=f)}}d&&u==e.children.length-1&&(a+=d.bottom-p.bottom),c=f+n.breakAfter}};return h(this.tile,0,null),t}textDirectionAt(e){let{tile:t}=this.tile.resolveBlock(e,1);return"rtl"==getComputedStyle(t.dom).direction?sg.RTL:sg.LTR}measureTextSize(){let e=this.tile.blockTiles(e=>{if(e.isLine()&&e.children.length&&e.length<=20){let t=0,i;for(let n of e.children){if(!n.isText()||/[^ -~]/.test(n.text))return;let e=r7(n.dom);if(1!=e.length)return;t+=e[0].width,i=e[0].height}if(t)return{lineHeight:e.dom.getBoundingClientRect().height,charWidth:t/e.length,textHeight:i}}});if(e)return e;let t=document.createElement("div"),i,n,r;return t.className="cm-line",t.style.width="99999px",t.style.position="absolute",t.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(t);let e=r7(t.firstChild)[0];i=t.getBoundingClientRect().height,n=e&&e.width?e.width/27:7,r=e&&e.height?e.height:i,t.remove()}),{lineHeight:i,charWidth:n,textHeight:r}}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let i=0,n=0;;n++){let r=n==t.viewports.length?null:t.viewports[n],s=r?r.from-1:this.view.state.doc.length;if(s>i){let n=(t.lineBlockAt(s).bottom-t.lineBlockAt(i).top)/this.view.scaleY;e.push(rQ.replace({widget:new oA(n),block:!0,inclusive:!0,isBlockGap:!0}).range(i,s))}if(!r)break;i=r.to+1}return rQ.set(e)}updateDeco(){let e=1,t=this.view.state.facet(sQ).map(t=>(this.dynamicDecorationMap[e++]="function"==typeof t)?t(this.view):t),i=!1,n=this.view.state.facet(s1).map((e,t)=>{let n="function"==typeof e;return n&&(i=!0),n?e(this.view):e});for(n.length&&(this.dynamicDecorationMap[e++]=i,t.push(ra.join(n))),this.decorations=[this.editContextFormatting,...t,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];e<this.decorations.length;)this.dynamicDecorationMap[e++]=!1;this.blockWrappers=this.view.state.facet(s0).map(e=>"function"==typeof e?e(this.view):e)}scrollIntoView(e){if(e.isSnapshot){let t=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=t.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let t of this.view.state.facet(sF))try{if(t(this.view,e.range,e))return!0}catch(e){sq(this.view.state,e,"scroll handler")}let{range:t}=e,i=this.coordsAt(t.head,t.empty?t.assoc:t.head>t.anchor?-1:1),n;if(!i)return;!t.empty&&(n=this.coordsAt(t.anchor,t.anchor>t.head?-1:1))&&(i={left:Math.min(i.left,n.left),top:Math.min(i.top,n.top),right:Math.max(i.right,n.right),bottom:Math.max(i.bottom,n.bottom)});let r=s3(this.view),s={left:i.left-r.left,top:i.top-r.top,right:i.right+r.right,bottom:i.bottom+r.bottom},{offsetWidth:o,offsetHeight:l}=this.view.scrollDOM;!function(e,t,i,n,r,s,o,l){let a=e.ownerDocument,h=a.defaultView||window;for(let c=e,d=!1;c&&!d;)if(1==c.nodeType){let e,u=c==a.body,f=1,p=1;if(u)e=function(e){let t=e.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.innerWidth,top:0,bottom:e.innerHeight}}(h);else{if(/^(fixed|sticky)$/.test(getComputedStyle(c).position)&&(d=!0),c.scrollHeight<=c.clientHeight&&c.scrollWidth<=c.clientWidth){c=c.assignedSlot||c.parentNode;continue}let t=c.getBoundingClientRect();({scaleX:f,scaleY:p}=so(c,t)),e={left:t.left,right:t.left+c.clientWidth*f,top:t.top,bottom:t.top+c.clientHeight*p}}let m=0,g=0;if("nearest"==r)t.top<e.top?(g=t.top-(e.top+o),i>0&&t.bottom>e.bottom+g&&(g=t.bottom-e.bottom+o)):t.bottom>e.bottom&&(g=t.bottom-e.bottom+o,i<0&&t.top-g<e.top&&(g=t.top-(e.top+o)));else{let n=t.bottom-t.top,s=e.bottom-e.top;g=("center"==r&&n<=s?t.top+n/2-s/2:"start"==r||"center"==r&&i<0?t.top-o:t.bottom-s+o)-e.top}if("nearest"==n?t.left<e.left?(m=t.left-(e.left+s),i>0&&t.right>e.right+m&&(m=t.right-e.right+s)):t.right>e.right&&(m=t.right-e.right+s,i<0&&t.left<e.left+m&&(m=t.left-(e.left+s))):m=("center"==n?t.left+(t.right-t.left)/2-(e.right-e.left)/2:"start"==n==l?t.left-s:t.right-(e.right-e.left)+s)-e.left,m||g){if(u)h.scrollBy(m,g);else{let e=0,i=0;if(g){let e=c.scrollTop;c.scrollTop+=g/p,i=(c.scrollTop-e)*p}if(m){let t=c.scrollLeft;c.scrollLeft+=m/f,e=(c.scrollLeft-t)*f}t={left:t.left-e,top:t.top-i,right:t.right-e,bottom:t.bottom-i},e&&1>Math.abs(e-m)&&(n="nearest"),i&&1>Math.abs(i-g)&&(r="nearest")}}if(u)break;(t.top<e.top||t.bottom>e.bottom||t.left<e.left||t.right>e.right)&&(t={left:Math.max(t.left,e.left),right:Math.min(t.right,e.right),top:Math.max(t.top,e.top),bottom:Math.min(t.bottom,e.bottom)}),c=c.assignedSlot||c.parentNode}else if(11==c.nodeType)c=c.host;else break}(this.view.scrollDOM,s,t.head<t.anchor?-1:1,e.x,e.y,Math.max(Math.min(e.xMargin,o),-o),Math.max(Math.min(e.yMargin,l),-l),this.view.textDirection==sg.LTR)}lineHasWidget(e){let t=e=>e.isWidget()||e.children.some(t);return t(this.tile.resolveBlock(e,1).tile)}destroy(){oC(this.tile)}}function oC(e,t){let i=null==t?void 0:t.get(e);if(1!=i)for(let n of(null==i&&e.destroy(),e.children))oC(n,t)}function oj(e,t){let i=e.observer.selectionRange;if(!i.focusNode)return null;let n=sf(i.focusNode,i.focusOffset),r=sp(i.focusNode,i.focusOffset),s=n||r;if(r&&n&&r.node!=n.node){let t=ot.get(r.node);if(!t||t.isText()&&t.text!=r.node.nodeValue)s=r;else if(e.docView.lastCompositionAfterCursor){let e=ot.get(n.node);!e||e.isText()&&e.text!=n.node.nodeValue||(s=r)}}if(e.docView.lastCompositionAfterCursor=s!=n,!s)return null;let o=t-s.offset;return{from:o,to:o+s.node.nodeValue.length,node:s.node}}let oM=class{constructor(){this.changes=[]}compareRange(e,t){r4(e,t,this.changes)}comparePoint(e,t){r4(e,t,this.changes)}boundChange(e){r4(e,e,this.changes)}};class oZ{constructor(){this.changes=[]}compareRange(e,t){r4(e,t,this.changes)}comparePoint(){}boundChange(e){r4(e,e,this.changes)}}class oA extends rX{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement("div");return e.className="cm-gap",this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}function oT(e,t,i){let n=e.lineBlockAt(t);if(Array.isArray(n.type)){let e;for(let r of n.type){if(r.from>t)break;if(!(r.to<t)){if(r.from<t&&r.to>t)return r;(!e||r.type==rY.Text&&(e.type!=r.type||(i<0?r.from<t:r.to>t)))&&(e=r)}}return e||n}return n}function oO(e,t,i,n){let r=e.state.doc.lineAt(t.head),s=e.bidiSpans(r),o=e.textDirectionAt(r.from);for(let l=t,a=null;;){let t=function(e,t,i,n,r){var s;let o=n.head-e.from,l=sM.find(t,o,null!==(s=n.bidiLevel)&&void 0!==s?s:-1,n.assoc),a=t[l],h=a.side(r,i);if(o==h){let e=l+=r?1:-1;if(e<0||e>=t.length)return null;o=(a=t[l=e]).side(!r,i),h=a.side(r,i)}let c=np(e.text,o,a.forward(r,i));(c<a.from||c>a.to)&&(c=h),sT=e.text.slice(Math.min(o,c),Math.max(o,c));let d=l==(r?t.length-1:0)?null:t[l+(r?1:-1)];return d&&c==h&&d.level+(r?0:1)<a.level?nA.cursor(d.side(!r,i)+e.from,d.forward(r,i)?1:-1,d.level):nA.cursor(c+e.from,a.forward(r,i)?-1:1,a.level)}(r,s,o,l,i),h=sT;if(!t){if(r.number==(i?e.state.doc.lines:1))return l;h="\n",r=e.state.doc.line(r.number+(i?1:-1)),s=e.bidiSpans(r),t=e.visualLineSide(r,!i)}if(a){if(!a(h))return l}else{if(!n)return t;a=n(h)}l=t}}function oD(e,t,i){for(;;){let n=0;for(let r of e)r.between(t-1,t+1,(e,r,s)=>{if(t>e&&t<r){let s=n||i||(t-e<r-t?-1:1);t=s<0?e:r,n=s}});if(!n)return t}}function oR(e,t){let i=null;for(let n=0;n<t.ranges.length;n++){let r=t.ranges[n],s=null;if(r.empty){let t=oD(e,r.from,0);t!=r.from&&(s=nA.cursor(t,-1))}else{let t=oD(e,r.from,-1),i=oD(e,r.to,1);(t!=r.from||i!=r.to)&&(s=nA.range(r.from==r.anchor?t:i,r.from==r.head?t:i))}s&&(i||(i=t.ranges.slice()),i[n]=s)}return i?nA.create(i,t.mainIndex):t}function oP(e,t,i){let n=oD(e.state.facet(s2).map(t=>t(e)),i.from,t.head>i.from?-1:1);return n==i.from?i:nA.cursor(n,n<i.from?1:-1)}class oL{constructor(e,t){this.pos=e,this.assoc=t}}function oI(e,t,i,n){let r=e.contentDOM.getBoundingClientRect(),s=r.top+e.viewState.paddingTop,{x:o,y:l}=t,a=l-s,h;for(;;){if(a<0)return new oL(0,1);if(a>e.viewState.docHeight)return new oL(e.state.doc.length,-1);if(h=e.elementAtHeight(a),null==n)break;if(h.type==rY.Text){if(n<0?h.to<e.viewport.from:h.from>e.viewport.to)break;let t=e.docView.coordsAt(n<0?h.from:h.to,n>0?-1:1);if(t&&(n<0?t.top<=a+s:t.bottom>=a+s))break}let t=e.viewState.heightOracle.textHeight/2;a=n>0?h.bottom+t:h.top-t}if(e.viewport.from>=h.to||e.viewport.to<=h.from){if(i)return null;if(h.type==rY.Text){let t=function(e,t,i,n,r){let s=Math.round((n-t.left)*e.defaultCharacterWidth);if(e.lineWrapping&&i.height>1.5*e.defaultLineHeight){let t=e.viewState.heightOracle.textHeight;s+=Math.floor((r-i.top-(e.defaultLineHeight-t)*.5)/t)*e.viewState.heightOracle.lineLength}let o=e.state.sliceDoc(i.from,i.to);return i.from+rw(o,s,e.state.tabSize)}(e,r,h,o,l);return new oL(t,t==h.from?1:-1)}}if(h.type!=rY.Text)return a<(h.top+h.bottom)/2?new oL(h.from,1):new oL(h.to,-1);let c=e.docView.lineAt(h.from,2);return c&&c.length==h.length||(c=e.docView.lineAt(h.from,-2)),new oE(e,o,l,e.textDirectionAt(h.from)).scanTile(c,h.from)}class oE{constructor(e,t,i,n){this.view=e,this.x=t,this.y=i,this.baseDir=n,this.line=null,this.spans=null}bidiSpansAt(e){return(!this.line||this.line.from>e||this.line.to<e)&&(this.line=this.view.state.doc.lineAt(e),this.spans=this.view.bidiSpans(this.line)),this}baseDirAt(e,t){let{line:i,spans:n}=this.bidiSpansAt(e);return n[sM.find(n,e-i.from,-1,t)].level==this.baseDir}dirAt(e,t){let{line:i,spans:n}=this.bidiSpansAt(e);return n[sM.find(n,e-i.from,-1,t)].dir}bidiIn(e,t){let{spans:i,line:n}=this.bidiSpansAt(e);return i.length>1||i.length&&(i[0].level!=this.baseDir||i[0].to+n.from<t)}scan(e,t){let i,n,r=0,s=e.length-1,o=new Set,l=this.bidiIn(e[0],e[s]),a=-1,h=1e9,c;for(;r<s;){let d=s-r,u=r+s>>1;t:if(o.has(u)){let e=r+Math.floor(Math.random()*d);for(let t=0;t<d;t++){if(!o.has(e)){u=e;break t}++e==s&&(e=r)}break}o.add(u);let f=t(u);if(f)for(let t=0;t<f.length;t++){let o=f[t],d=0;if(o.bottom<this.y)(!i||i.bottom<o.bottom)&&(i=o),d=1;else if(o.top>this.y)(!n||n.top>o.top)&&(n=o),d=-1;else{let e=o.left>this.x?this.x-o.left:o.right<this.x?this.x-o.right:0,t=Math.abs(e);t<h&&(a=u,h=t,c=o),e&&(d=e<0==(this.baseDir==sg.LTR)?-1:1)}-1==d&&(!l||this.baseDirAt(e[u],1))?s=u:1==d&&(!l||this.baseDirAt(e[u+1],-1))&&(r=u+1)}}if(!c){let r=i&&(!n||this.y-i.bottom<n.top-this.y)?i:n;return this.y=(r.top+r.bottom)/2,this.scan(e,t)}let d=(l?this.dirAt(e[a],1):this.baseDir)==sg.LTR;return{i:a,after:this.x>(c.left+c.right)/2==d}}scanText(e,t){let i=[];for(let n=0;n<e.length;n=np(e.text,n))i.push(t+n);i.push(t+e.length);let n=this.scan(i,n=>{let r=i[n]-t,s=i[n+1]-t;return sc(e.dom,r,s).getClientRects()});return n.after?new oL(i[n.i+1],-1):new oL(i[n.i],1)}scanTile(e,t){if(!e.length)return new oL(t,1);if(1==e.children.length){let i=e.children[0];if(i.isText())return this.scanText(i,t);if(i.isComposite())return this.scanTile(i,t)}let i=[t];for(let n=0,r=t;n<e.children.length;n++)i.push(r+=e.children[n].length);let n=this.scan(i,t=>{let i=e.children[t];return 48&i.flags?null:(1==i.dom.nodeType?i.dom:sc(i.dom,0,i.length)).getClientRects()}),r=e.children[n.i],s=i[n.i];return r.isText()?this.scanText(r,s):r.isComposite()?this.scanTile(r,s):n.after?new oL(i[n.i+1],-1):new oL(s,1)}}class oB{constructor(e,t){this.points=e,this.view=t,this.text="",this.lineSeparator=t.state.facet(rt.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=""}readRange(e,t){if(!e)return this;let i=e.parentNode;for(let n=e;;){this.findPointBefore(i,n);let e=this.text.length;this.readNode(n);let r=ot.get(n),s=n.nextSibling;if(s==t){(null==r?void 0:r.breakAfter)&&!s&&i!=this.view.contentDOM&&this.lineBreak();break}let o=ot.get(s);(r&&o?r.breakAfter:(r?r.breakAfter:si(n))||si(s)&&("BR"!=n.nodeName||(null==r?void 0:r.isWidget()))&&this.text.length>e)&&!function(e,t){let i;for(;e!=t&&e;e=e.nextSibling){let t=ot.get(e);if(!(null==t?void 0:t.isWidget()))return!1;t&&(i||(i=[])).push(t)}if(i)for(let e of i){let t=e.overrideDOMText;if(null==t?void 0:t.length)return!1}return!0}(s,t)&&this.lineBreak(),n=s}return this.findPointBefore(i,t),this}readTextNode(e){let t=e.nodeValue;for(let i of this.points)i.node==e&&(i.pos=this.text.length+Math.min(i.offset,t.length));for(let i=0,n=this.lineSeparator?null:/\r\n?|\n/g;;){let r=-1,s=1,o;if(this.lineSeparator?(r=t.indexOf(this.lineSeparator,i),s=this.lineSeparator.length):(o=n.exec(t))&&(r=o.index,s=o[0].length),this.append(t.slice(i,r<0?t.length:r)),r<0)break;if(this.lineBreak(),s>1)for(let t of this.points)t.node==e&&t.pos>this.text.length&&(t.pos-=s-1);i=r+s}}readNode(e){let t=ot.get(e),i=t&&t.overrideDOMText;if(null!=i){this.findPointInside(e,i.length);for(let e=i.iter();!e.next().done;)e.lineBreak?this.lineBreak():this.append(e.value)}else 3==e.nodeType?this.readTextNode(e):"BR"==e.nodeName?e.nextSibling&&this.lineBreak():1==e.nodeType&&this.readRange(e.firstChild,null)}findPointBefore(e,t){for(let i of this.points)i.node==e&&e.childNodes[i.offset]==t&&(i.pos=this.text.length)}findPointInside(e,t){for(let i of this.points)(3==e.nodeType?i.node==e:e.contains(i.node))&&(i.pos=this.text.length+(!function(e,t,i){for(;;){if(!t||i<sr(t))return!1;if(t==e)return!0;i=st(t)+1,t=t.parentNode}}(e,i.node,i.offset)?0:t))}}class oN{constructor(e,t){this.node=e,this.offset=t,this.pos=-1}}class oz{constructor(e,t,i,n){this.typeOver=n,this.bounds=null,this.text="",this.domChanged=t>-1;let{impreciseHead:r,impreciseAnchor:s}=e.docView;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=function e(t,i,n,r){if(t.isComposite()){let s=-1,o=-1,l=-1,a=-1;for(let h=0,c=r,d=r;h<t.children.length;h++){let r=t.children[h],u=c+r.length;if(c<i&&u>n)return e(r,i,n,c);if(u>=i&&-1==s&&(s=h,o=c),c>n&&r.dom.parentNode==t.dom){l=h,a=d;break}d=u,c=u+r.breakAfter}return{from:o,to:a<0?r+t.length:a,startDOM:(s?t.children[s-1].dom.nextSibling:null)||t.dom.firstChild,endDOM:l<t.children.length&&l>=0?t.children[l].dom:null}}return t.isText()?{from:r,to:r+t.length,startDOM:t.dom,endDOM:t.dom.nextSibling}:null}(e.docView.tile,t,i,0))){let t=r||s?[]:function(e){let t=[];if(e.root.activeElement!=e.contentDOM)return t;let{anchorNode:i,anchorOffset:n,focusNode:r,focusOffset:s}=e.observer.selectionRange;return i&&(t.push(new oN(i,n)),(r!=i||s!=n)&&t.push(new oN(r,s))),t}(e),i=new oB(t,e);i.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=i.text,this.newSel=function(e,t){if(0==e.length)return null;let i=e[0].pos,n=2==e.length?e[1].pos:i;return i>-1&&n>-1?nA.single(i+t,n+t):null}(t,this.bounds.from)}else{let t=e.observer.selectionRange,i=r&&r.node==t.focusNode&&r.offset==t.focusOffset||!r8(e.contentDOM,t.focusNode)?e.state.selection.main.head:e.docView.posFromDOM(t.focusNode,t.focusOffset),n=s&&s.node==t.anchorNode&&s.offset==t.anchorOffset||!r8(e.contentDOM,t.anchorNode)?e.state.selection.main.anchor:e.docView.posFromDOM(t.anchorNode,t.anchorOffset),o=e.viewport;if((rK.ios||rK.chrome)&&e.state.selection.main.empty&&i!=n&&(o.from>0||o.to<e.state.doc.length)){let t=Math.min(i,n),r=Math.max(i,n),s=o.from-t,l=o.to-r;(0==s||1==s||0==t)&&(0==l||-1==l||r==e.state.doc.length)&&(i=0,n=e.state.doc.length)}e.inputState.composing>-1&&e.state.selection.ranges.length>1?this.newSel=e.state.selection.replaceRange(nA.range(n,i)):this.newSel=nA.single(n,i)}}}function oW(e,t){let i;let{newSel:n}=t,r=e.state.selection.main,s=e.inputState.lastKeyTime>Date.now()-100?e.inputState.lastKeyCode:-1;if(t.bounds){let{from:n,to:o}=t.bounds,l=r.from,a=null;(8===s||rK.android&&t.text.length<o-n)&&(l=r.to,a="end");let h=oV(e.state.doc.sliceString(n,o,""),t.text,l-n,a);h&&(rK.chrome&&13==s&&h.toB==h.from+2&&""==t.text.slice(h.from,h.toB)&&h.toB--,i={from:n+h.from,to:n+h.toA,insert:ns.of(t.text.slice(h.from,h.toB).split(""))})}else n&&(!e.hasFocus&&e.state.facet(sK)||oH(n,r))&&(n=null);if(!i&&!n)return!1;if(!i&&t.typeOver&&!r.empty&&n&&n.main.empty?i={from:r.from,to:r.to,insert:e.state.doc.slice(r.from,r.to)}:(rK.mac||rK.android)&&i&&i.from==i.to&&i.from==r.head-1&&/^\. ?$/.test(i.insert.toString())&&"off"==e.contentDOM.getAttribute("autocorrect")?(n&&2==i.insert.length&&(n=nA.single(n.main.anchor-1,n.main.head-1)),i={from:i.from,to:i.to,insert:ns.of([i.insert.toString().replace("."," ")])}):i&&i.from>=r.from&&i.to<=r.to&&(i.from!=r.from||i.to!=r.to)&&r.to-r.from-(i.to-i.from)<=4?i={from:r.from,to:r.to,insert:e.state.doc.slice(r.from,i.from).append(i.insert).append(e.state.doc.slice(i.to,r.to))}:e.state.doc.lineAt(r.from).to<r.to&&e.docView.lineHasWidget(r.to)&&e.inputState.insertingTextAt>Date.now()-50?i={from:r.from,to:r.to,insert:e.state.toText(e.inputState.insertingText)}:rK.chrome&&i&&i.from==i.to&&i.from==r.head&&"\n "==i.insert.toString()&&e.lineWrapping&&(n&&(n=nA.single(n.main.anchor-1,n.main.head-1)),i={from:r.from,to:r.to,insert:ns.of([" "])}),i)return oF(e,i,n,s);if(!n||oH(n,r))return!1;{let t=!1,i="select";return e.inputState.lastSelectionTime>Date.now()-50&&("select"==e.inputState.lastSelectionOrigin&&(t=!0),"select.pointer"==(i=e.inputState.lastSelectionOrigin)&&(n=oR(e.state.facet(s2).map(t=>t(e)),n))),e.dispatch({selection:n,scrollIntoView:t,userEvent:i}),!0}}function oF(e,t,i,n=-1){let r;if(rK.ios&&e.inputState.flushIOSKey(t))return!0;let s=e.state.selection.main;if(rK.android&&(t.to==s.to&&(t.from==s.from||t.from==s.from-1&&" "==e.state.sliceDoc(t.from,s.from))&&1==t.insert.length&&2==t.insert.lines&&sd(e.contentDOM,"Enter",13)||(t.from==s.from-1&&t.to==s.to&&0==t.insert.length||8==n&&t.insert.length<t.to-t.from&&t.to>s.head)&&sd(e.contentDOM,"Backspace",8)||t.from==s.from&&t.to==s.to+1&&0==t.insert.length&&sd(e.contentDOM,"Delete",46)))return!0;let o=t.insert.toString();e.inputState.composing>=0&&e.inputState.composing++;let l=()=>r||(r=function(e,t,i){let n,r=e.state,s=r.selection.main,o=-1;if(t.from==t.to&&t.from<s.from||t.from>s.to){let i=t.from<s.from?-1:1,n=i<0?s.from:s.to,l=oD(r.facet(s2).map(t=>t(e)),n,i);t.from==l&&(o=l)}if(o>-1)n={changes:t,selection:nA.cursor(t.from+t.insert.length,-1)};else if(t.from>=s.from&&t.to<=s.to&&t.to-t.from>=(s.to-s.from)/3&&(!i||i.main.empty&&i.main.from==t.from+t.insert.length)&&e.inputState.composing<0){let i=s.from<t.from?r.sliceDoc(s.from,t.from):"",o=s.to>t.to?r.sliceDoc(t.to,s.to):"";n=r.replaceSelection(e.state.toText(i+t.insert.sliceString(0,void 0,e.state.lineBreak)+o))}else{let o=r.changes(t),l=i&&i.main.to<=o.newLength?i.main:void 0;if(r.selection.ranges.length>1&&(e.inputState.composing>=0||e.inputState.compositionPendingChange)&&t.to<=s.to+10&&t.to>=s.to-10){let a=e.state.sliceDoc(t.from,t.to),h,c=i&&oj(e,i.main.head);if(c){let e=t.insert.length-(t.to-t.from);h={from:c.from,to:c.to-e}}else h=e.state.doc.lineAt(s.head);let d=s.to-t.to;n=r.changeByRange(i=>{if(i.from==s.from&&i.to==s.to)return{changes:o,range:l||i.map(o)};let n=i.to-d,c=n-a.length;if(e.state.sliceDoc(c,n)!=a||n>=h.from&&c<=h.to)return{range:i};let u=r.changes({from:c,to:n,insert:t.insert}),f=i.to-s.to;return{changes:u,range:l?nA.range(Math.max(0,l.anchor+f),Math.max(0,l.head+f)):i.map(u)}})}else n={changes:o,selection:l&&r.selection.replaceRange(l)}}let l="input.type";return(e.composing||e.inputState.compositionPendingChange&&e.inputState.compositionEndedAt>Date.now()-50)&&(e.inputState.compositionPendingChange=!1,l+=".compose",e.inputState.compositionFirstChange&&(l+=".start",e.inputState.compositionFirstChange=!1)),r.update(n,{userEvent:l,scrollIntoView:!0})}(e,t,i));return e.state.facet(sI).some(i=>i(e,t.from,t.to,o,l))||e.dispatch(l()),!0}function oV(e,t,i,n){let r=Math.min(e.length,t.length),s=0;for(;s<r&&e.charCodeAt(s)==t.charCodeAt(s);)s++;if(s==r&&e.length==t.length)return null;let o=e.length,l=t.length;for(;o>0&&l>0&&e.charCodeAt(o-1)==t.charCodeAt(l-1);)o--,l--;if("end"==n){let e=Math.max(0,s-Math.min(o,l));i-=o+e-s}if(o<s&&e.length<t.length){let e=i<=s&&i>=o?s-i:0;s-=e,l=s+(l-o),o=s}else if(l<s){let e=i<=s&&i>=l?s-i:0;s-=e,o=s+(o-l),l=s}return{from:s,toA:o,toB:l}}function oH(e,t){return t.head==e.main.head&&t.anchor==e.main.anchor}class o${setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.pendingIOSKey=void 0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,rK.safari&&e.contentDOM.addEventListener("input",()=>null),rK.gecko&&function(e){ln.has(e)||(ln.add(e),e.addEventListener("copy",()=>{}),e.addEventListener("cut",()=>{}))}(e.contentDOM.ownerDocument)}handleEvent(e){!(!function(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let i=t.target,n;i!=e.contentDOM;i=i.parentNode)if(!i||11==i.nodeType||(n=ot.get(i))&&n.isWidget()&&!n.isHidden&&n.widget.ignoreEvent(t))return!1;return!0}(this.view,e)||this.ignoreDuringComposition(e))&&("keydown"==e.type&&this.keydown(e)||(0!=this.view.updateState?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e)))}runHandlers(e,t){let i=this.handlers[e];if(i){for(let e of i.observers)e(this.view,t);for(let e of i.handlers){if(t.defaultPrevented)break;if(e(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=function(e){let t=Object.create(null);function i(e){return t[e]||(t[e]={observers:[],handlers:[]})}for(let t of e){let e=t.spec,n=e&&e.plugin.domEventHandlers,r=e&&e.plugin.domEventObservers;if(n)for(let e in n){let r=n[e];r&&i(e).handlers.push(oq(t.value,r))}if(r)for(let e in r){let n=r[e];n&&i(e).observers.push(oq(t.value,n))}}for(let e in oX)i(e).handlers.push(oX[e]);for(let e in oY)i(e).observers.push(oY[e]);return t}(e),i=this.handlers,n=this.view.contentDOM;for(let e in t)if("scroll"!=e){let r=!t[e].handlers.length,s=i[e];s&&!s.handlers.length!=r&&(n.removeEventListener(e,this.handleEvent),s=null),s||n.addEventListener(e,this.handleEvent,{passive:r})}for(let e in i)"scroll"==e||t[e]||n.removeEventListener(e,this.handleEvent);this.handlers=t}keydown(e){let t;return this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),!!(9==e.keyCode&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))||((this.tabFocusMode>0&&27!=e.keyCode&&0>o_.indexOf(e.keyCode)&&(this.tabFocusMode=-1),rK.android&&rK.chrome&&!e.synthetic&&(13==e.keyCode||8==e.keyCode))?(this.view.observer.delayAndroidKey(e.key,e.keyCode),!0):rK.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&((t=oK.find(t=>t.keyCode==e.keyCode))&&!e.ctrlKey||oU.indexOf(e.key)>-1&&e.ctrlKey&&!e.shiftKey)?(this.pendingIOSKey=t||e,setTimeout(()=>this.flushIOSKey(),250),!0):(229!=e.keyCode&&this.view.observer.forceFlush(),!1))}flushIOSKey(e){let t=this.pendingIOSKey;return!(!t||"Enter"==t.key&&e&&e.from<e.to&&/^\S+$/.test(e.insert.toString()))&&(this.pendingIOSKey=void 0,sd(this.view.contentDOM,t.key,t.keyCode,t instanceof KeyboardEvent?t:void 0))}ignoreDuringComposition(e){return!!/^key/.test(e.type)&&!e.synthetic&&(this.composing>0||!!(rK.safari&&!rK.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100)&&(this.compositionPendingKey=!1,!0))}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function oq(e,t){return(i,n)=>{try{return t.call(e,n,i)}catch(e){sq(i.state,e)}}}let oK=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],oU="dthko",o_=[16,17,18,20,91,92,224,225];function oG(e){return .7*Math.max(0,e)+8}class oJ{constructor(e,t,i,n){this.view=e,this.startEvent=t,this.style=i,this.mustSelect=n,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParents=function(e){let t=e.ownerDocument,i,n;for(let r=e.parentNode;r&&r!=t.body&&(!i||!n);)if(1==r.nodeType)!n&&r.scrollHeight>r.clientHeight&&(n=r),!i&&r.scrollWidth>r.clientWidth&&(i=r),r=r.assignedSlot||r.parentNode;else if(11==r.nodeType)r=r.host;else break;return{x:i,y:n}}(e.contentDOM),this.atoms=e.state.facet(s2).map(t=>t(e));let r=e.contentDOM.ownerDocument;r.addEventListener("mousemove",this.move=this.move.bind(this)),r.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(rt.allowMultipleSelections)&&function(e,t){let i=e.state.facet(sO);return i.length?i[0](t):rK.mac?t.metaKey:t.ctrlKey}(e,t),this.dragging=!!function(e,t){let{main:i}=e.state.selection;if(i.empty)return!1;let n=r3(e.root);if(!n||0==n.rangeCount)return!0;let r=n.getRangeAt(0).getClientRects();for(let e=0;e<r.length;e++){let i=r[e];if(i.left<=t.clientX&&i.right>=t.clientX&&i.top<=t.clientY&&i.bottom>=t.clientY)return!0}return!1}(e,t)&&1==o8(t)&&null}start(e){!1===this.dragging&&this.select(e)}move(e){var t;if(0==e.buttons)return this.destroy();if(this.dragging||null==this.dragging&&10>Math.max(Math.abs((t=this.startEvent).clientX-e.clientX),Math.abs(t.clientY-e.clientY)))return;this.select(this.lastEvent=e);let i=0,n=0,r=0,s=0,o=this.view.win.innerWidth,l=this.view.win.innerHeight;this.scrollParents.x&&({left:r,right:o}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:s,bottom:l}=this.scrollParents.y.getBoundingClientRect());let a=s3(this.view);e.clientX-a.left<=r+6?i=-oG(r-e.clientX):e.clientX+a.right>=o-6&&(i=oG(e.clientX-o)),e.clientY-a.top<=s+6?n=-oG(s-e.clientY):e.clientY+a.bottom>=l-6&&(n=oG(e.clientY-l)),this.setScrollSpeed(i,n)}up(e){null==this.dragging&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,t){this.scrollSpeed={x:e,y:t},e||t?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:t}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),t&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=t,t=0),(e||t)&&this.view.win.scrollBy(e,t),!1===this.dragging&&this.select(this.lastEvent)}select(e){let{view:t}=this,i=oR(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!i.eq(t.state.selection,!1===this.dragging))&&this.view.dispatch({selection:i,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(e=>e.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}let oX=Object.create(null),oY=Object.create(null),oQ=rK.ie&&rK.ie_version<15||rK.ios&&rK.webkit_version<604;function o0(e,t,i){for(let n of e.facet(t))i=n(i,e);return i}function o1(e,t){t=o0(e.state,sB,t);let{state:i}=e,n,r=1,s=i.toText(t),o=s.lines==i.selection.ranges.length;if(null!=o7&&i.selection.ranges.every(e=>e.empty)&&o7==s.toString()){let e=-1;n=i.changeByRange(n=>{let l=i.doc.lineAt(n.from);if(l.from==e)return{range:n};e=l.from;let a=i.toText((o?s.line(r++).text:t)+i.lineBreak);return{changes:{from:l.from,insert:a},range:nA.cursor(n.from+a.length)}})}else n=o?i.changeByRange(e=>{let t=s.line(r++);return{changes:{from:e.from,to:e.to,insert:t.text},range:nA.cursor(e.from+t.length)}}):i.replaceSelection(s);e.dispatch(n,{userEvent:"input.paste",scrollIntoView:!0})}function o2(e,t,i,n){if(1==n)return nA.cursor(t,i);if(2==n)return function(e,t,i=1){let n=e.charCategorizer(t),r=e.doc.lineAt(t),s=t-r.from;if(0==r.length)return nA.cursor(t);0==s?i=1:s==r.length&&(i=-1);let o=s,l=s;i<0?o=np(r.text,s,!1):l=np(r.text,s);let a=n(r.text.slice(o,l));for(;o>0;){let e=np(r.text,o,!1);if(n(r.text.slice(e,o))!=a)break;o=e}for(;l<r.length;){let e=np(r.text,l);if(n(r.text.slice(l,e))!=a)break;l=e}return nA.range(o+r.from,l+r.from)}(e.state,t,i);{let n=e.docView.lineAt(t,i),r=e.state.doc.lineAt(n?n.posAtEnd:t),s=n?n.posAtStart:r.from,o=n?n.posAtEnd:r.to;return o<e.state.doc.length&&o==r.to&&o++,nA.range(s,o)}}oY.scroll=e=>{e.inputState.lastScrollTop=e.scrollDOM.scrollTop,e.inputState.lastScrollLeft=e.scrollDOM.scrollLeft},oX.keydown=(e,t)=>(e.inputState.setSelectionOrigin("select"),27==t.keyCode&&0!=e.inputState.tabFocusMode&&(e.inputState.tabFocusMode=Date.now()+2e3),!1),oY.touchstart=(e,t)=>{e.inputState.lastTouchTime=Date.now(),e.inputState.setSelectionOrigin("select.pointer")},oY.touchmove=e=>{e.inputState.setSelectionOrigin("select.pointer")},oX.mousedown=(e,t)=>{if(e.observer.flush(),e.inputState.lastTouchTime>Date.now()-2e3)return!1;let i=null;for(let n of e.state.facet(sR))if(i=n(e,t))break;if(i||0!=t.button||(i=function(e,t){let i=e.posAndSideAtCoords({x:t.clientX,y:t.clientY},!1),n=o8(t),r=e.state.selection;return{update(e){e.docChanged&&(i.pos=e.changes.mapPos(i.pos),r=r.map(e.changes))},get(t,s,o){let l=e.posAndSideAtCoords({x:t.clientX,y:t.clientY},!1),a,h=o2(e,l.pos,l.assoc,n);if(i.pos!=l.pos&&!s){let t=o2(e,i.pos,i.assoc,n),r=Math.min(t.from,h.from),s=Math.max(t.to,h.to);h=r<h.from?nA.range(r,s):nA.range(s,r)}return s?r.replaceRange(r.main.extend(h.from,h.to)):o&&1==n&&r.ranges.length>1&&(a=function(e,t){for(let i=0;i<e.ranges.length;i++){let{from:n,to:r}=e.ranges[i];if(n<=t&&r>=t)return nA.create(e.ranges.slice(0,i).concat(e.ranges.slice(i+1)),e.mainIndex==i?0:e.mainIndex-(e.mainIndex>i?1:0))}return null}(r,l.pos))?a:o?r.addRange(h):nA.create([h])}}}(e,t)),i){let n=!e.hasFocus;e.inputState.startMouseSelection(new oJ(e,t,i,n)),n&&e.observer.ignore(()=>{sh(e.contentDOM);let t=e.root.activeElement;t&&!t.contains(e.contentDOM)&&t.blur()});let r=e.inputState.mouseSelection;if(r)return r.start(t),!1===r.dragging}else e.inputState.setSelectionOrigin("select.pointer");return!1};let o5=rK.ie&&rK.ie_version<=11,o4=null,o6=0,o3=0;function o8(e){if(!o5)return e.detail;let t=o4,i=o3;return o4=e,o3=Date.now(),o6=!t||i>Date.now()-400&&2>Math.abs(t.clientX-e.clientX)&&2>Math.abs(t.clientY-e.clientY)?(o6+1)%3:1}function o9(e,t,i,n){let r;if(!(i=o0(e.state,sB,i)))return;let s=e.posAtCoords({x:t.clientX,y:t.clientY},!1),{draggedContent:o}=e.inputState,l=n&&o&&((r=e.state.facet(sD)).length?r[0](t):rK.mac?!t.altKey:!t.ctrlKey)?{from:o.from,to:o.to}:null,a={from:s,insert:i},h=e.state.changes(l?[l,a]:a);e.focus(),e.dispatch({changes:h,selection:{anchor:h.mapPos(s,-1),head:h.mapPos(s,1)},userEvent:l?"move.drop":"input.drop"}),e.inputState.draggedContent=null}oX.dragstart=(e,t)=>{let{selection:{main:i}}=e.state;if(t.target.draggable){let n=e.docView.tile.nearest(t.target);if(n&&n.isWidget()){let e=n.posAtStart,t=e+n.length;(e>=i.to||t<=i.from)&&(i=nA.range(e,t))}}let{inputState:n}=e;return n.mouseSelection&&(n.mouseSelection.dragging=!0),n.draggedContent=i,t.dataTransfer&&(t.dataTransfer.setData("Text",o0(e.state,sN,e.state.sliceDoc(i.from,i.to))),t.dataTransfer.effectAllowed="copyMove"),!1},oX.dragend=e=>(e.inputState.draggedContent=null,!1),oX.drop=(e,t)=>{if(!t.dataTransfer)return!1;if(e.state.readOnly)return!0;let i=t.dataTransfer.files;if(i&&i.length){let n=Array(i.length),r=0,s=()=>{++r==i.length&&o9(e,t,n.filter(e=>null!=e).join(e.state.lineBreak),!1)};for(let e=0;e<i.length;e++){let t=new FileReader;t.onerror=s,t.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(t.result)||(n[e]=t.result),s()},t.readAsText(i[e])}return!0}{let i=t.dataTransfer.getData("Text");if(i)return o9(e,t,i,!0),!0}return!1},oX.paste=(e,t)=>{if(e.state.readOnly)return!0;e.observer.flush();let i=oQ?null:t.clipboardData;return i?(o1(e,i.getData("text/plain")||i.getData("text/uri-list")),!0):(function(e){let t=e.dom.parentNode;if(!t)return;let i=t.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.focus(),setTimeout(()=>{e.focus(),i.remove(),o1(e,i.value)},50)}(e),!1)};let o7=null;oX.copy=oX.cut=(e,t)=>{if(!r9(e.contentDOM,e.observer.selectionRange))return!1;let{text:i,ranges:n,linewise:r}=function(e){let t=[],i=[],n=!1;for(let n of e.selection.ranges)n.empty||(t.push(e.sliceDoc(n.from,n.to)),i.push(n));if(!t.length){let r=-1;for(let{from:n}of e.selection.ranges){let s=e.doc.lineAt(n);s.number>r&&(t.push(s.text),i.push({from:s.from,to:Math.min(e.doc.length,s.to+1)})),r=s.number}n=!0}return{text:o0(e,sN,t.join(e.lineBreak)),ranges:i,linewise:n}}(e.state);if(!i&&!r)return!1;o7=r?i:null,"cut"!=t.type||e.state.readOnly||e.dispatch({changes:n,scrollIntoView:!0,userEvent:"delete.cut"});let s=oQ?null:t.clipboardData;return s?(s.clearData(),s.setData("text/plain",i),!0):(function(e,t){let i=e.dom.parentNode;if(!i)return;let n=i.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.value=t,n.focus(),n.selectionEnd=t.length,n.selectionStart=0,setTimeout(()=>{n.remove(),e.focus()},50)}(e,i),!1)};let le=n0.define();function lt(e,t){let i=[];for(let n of e.facet(sE)){let r=n(e,t);r&&i.push(r)}return i.length?e.update({effects:i,annotations:le.of(!0)}):null}function li(e){setTimeout(()=>{let t=e.hasFocus;if(t!=e.inputState.notifiedFocused){let i=lt(e.state,t);i?e.dispatch(i):e.update([])}},10)}oY.focus=e=>{e.inputState.lastFocusTime=Date.now(),!e.scrollDOM.scrollTop&&(e.inputState.lastScrollTop||e.inputState.lastScrollLeft)&&(e.scrollDOM.scrollTop=e.inputState.lastScrollTop,e.scrollDOM.scrollLeft=e.inputState.lastScrollLeft),li(e)},oY.blur=e=>{e.observer.clearSelectionRange(),li(e)},oY.compositionstart=oY.compositionupdate=e=>{!e.observer.editContext&&(null==e.inputState.compositionFirstChange&&(e.inputState.compositionFirstChange=!0),e.inputState.composing<0&&(e.inputState.composing=0))},oY.compositionend=e=>{e.observer.editContext||(e.inputState.composing=-1,e.inputState.compositionEndedAt=Date.now(),e.inputState.compositionPendingKey=!0,e.inputState.compositionPendingChange=e.observer.pendingRecords().length>0,e.inputState.compositionFirstChange=null,rK.chrome&&rK.android?e.observer.flushSoon():e.inputState.compositionPendingChange?Promise.resolve().then(()=>e.observer.flush()):setTimeout(()=>{e.inputState.composing<0&&e.docView.hasComposition&&e.update([])},50))},oY.contextmenu=e=>{e.inputState.lastContextMenu=Date.now()},oX.beforeinput=(e,t)=>{var i,n;let r;if(("insertText"==t.inputType||"insertCompositionText"==t.inputType)&&(e.inputState.insertingText=t.data,e.inputState.insertingTextAt=Date.now()),"insertReplacementText"==t.inputType&&e.observer.editContext){let n=null===(i=t.dataTransfer)||void 0===i?void 0:i.getData("text/plain"),r=t.getTargetRanges();if(n&&r.length){let t=r[0],i=e.posAtDOM(t.startContainer,t.startOffset),s=e.posAtDOM(t.endContainer,t.endOffset);return oF(e,{from:i,to:s,insert:e.state.toText(n)},null),!0}}if(rK.chrome&&rK.android&&(r=oK.find(e=>e.inputType==t.inputType))&&(e.observer.delayAndroidKey(r.key,r.keyCode),"Backspace"==r.key||"Delete"==r.key)){let t=(null===(n=window.visualViewport)||void 0===n?void 0:n.height)||0;setTimeout(()=>{var i;((null===(i=window.visualViewport)||void 0===i?void 0:i.height)||0)>t+10&&e.hasFocus&&(e.contentDOM.blur(),e.focus())},100)}return rK.ios&&"deleteContentForward"==t.inputType&&e.observer.flushSoon(),rK.safari&&"insertText"==t.inputType&&e.inputState.composing>=0&&setTimeout(()=>oY.compositionend(e,t),20),!1};let ln=new Set,lr=["pre-wrap","normal","pre-line","break-spaces"],ls=!1;class lo{constructor(e){this.lineWrapping=e,this.doc=ns.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,t){let i=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(i+=Math.max(0,Math.ceil((t-e-i*this.lineLength*.5)/this.lineLength))),this.lineHeight*i}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return lr.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let i=0;i<e.length;i++){let n=e[i];n<0?i++:this.heightSamples[Math.floor(10*n)]||(t=!0,this.heightSamples[Math.floor(10*n)]=!0)}return t}refresh(e,t,i,n,r,s){let o=lr.indexOf(e)>-1,l=Math.abs(t-this.lineHeight)>.3||this.lineWrapping!=o||Math.abs(i-this.charWidth)>.1;if(this.lineWrapping=o,this.lineHeight=t,this.charWidth=i,this.textHeight=n,this.lineLength=r,l){this.heightSamples={};for(let e=0;e<s.length;e++){let t=s[e];t<0?e++:this.heightSamples[Math.floor(10*t)]=!0}}return l}}class ll{constructor(e,t){this.from=e,this.heights=t,this.index=0}get more(){return this.index<this.heights.length}}class la{constructor(e,t,i,n,r){this.from=e,this.length=t,this.top=i,this.height=n,this._content=r}get type(){return"number"==typeof this._content?rY.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof r2?this._content.widget:null}get widgetLineBreaks(){return"number"==typeof this._content?this._content:0}join(e){let t=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(e._content)?e._content:[e]);return new la(this.from,this.length+e.length,this.top,this.height+e.height,t)}}var lh=function(e){return e[e.ByPos=0]="ByPos",e[e.ByHeight=1]="ByHeight",e[e.ByPosNoHeight=2]="ByPosNoHeight",e}(lh||(lh={}));class lc{constructor(e,t,i=2){this.length=e,this.height=t,this.flags=i}get outdated(){return(2&this.flags)>0}set outdated(e){this.flags=(e?2:0)|-3&this.flags}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>.001&&(ls=!0),this.height=e)}replace(e,t,i){return lc.of(i)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,i,n){let r=this,s=i.doc;for(let o=n.length-1;o>=0;o--){let{fromA:l,toA:a,fromB:h,toB:c}=n[o],d=r.lineAt(l,lh.ByPosNoHeight,i.setDoc(t),0,0),u=d.to>=a?d:r.lineAt(a,lh.ByPosNoHeight,i,0,0);for(c+=u.to-a,a=u.to;o>0&&d.from<=n[o-1].toA;)l=n[o-1].fromA,h=n[o-1].fromB,o--,l<d.from&&(d=r.lineAt(l,lh.ByPosNoHeight,i,0,0));h+=d.from-l,l=d.from;let f=lv.build(i.setDoc(s),e,h,c);r=ld(r,r.replace(l,a,f))}return r.updateHeight(i,0)}static empty(){return new lp(0,0,0)}static of(e){if(1==e.length)return e[0];let t=0,i=e.length,n=0,r=0;for(;;)if(t==i){if(n>2*r){let r=e[t-1];r.break?e.splice(--t,1,r.left,null,r.right):e.splice(--t,1,r.left,r.right),i+=1+r.break,n-=r.size}else if(r>2*n){let t=e[i];t.break?e.splice(i,1,t.left,null,t.right):e.splice(i,1,t.left,t.right),i+=2+t.break,r-=t.size}else break}else if(n<r){let i=e[t++];i&&(n+=i.size)}else{let t=e[--i];t&&(r+=t.size)}let s=0;return null==e[t-1]?(s=1,t--):null==e[t]&&(s=1,i++),new lg(lc.of(e.slice(0,t)),s,lc.of(e.slice(i)))}}function ld(e,t){return e==t?e:(e.constructor!=t.constructor&&(ls=!0),t)}lc.prototype.size=1;let lu=rQ.replace({});class lf extends lc{constructor(e,t,i){super(e,t),this.deco=i,this.spaceAbove=0}mainBlock(e,t){return new la(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.deco||0)}blockAt(e,t,i,n){return this.spaceAbove&&e<i+this.spaceAbove?new la(n,0,i,this.spaceAbove,lu):this.mainBlock(i,n)}lineAt(e,t,i,n,r){let s=this.mainBlock(n,r);return this.spaceAbove?this.blockAt(0,i,n,r).join(s):s}forEachLine(e,t,i,n,r,s){e<=r+this.length&&t>=r&&s(this.lineAt(0,lh.ByPos,i,n,r))}setMeasuredHeight(e){let t=e.heights[e.index++];t<0?(this.spaceAbove=-t,t=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(t)}updateHeight(e,t=0,i=!1,n){return n&&n.from<=t&&n.more&&this.setMeasuredHeight(n),this.outdated=!1,this}toString(){return`block(${this.length})`}}class lp extends lf{constructor(e,t,i){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=i}mainBlock(e,t){return new la(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,t,i){let n=i[0];return 1==i.length&&(n instanceof lp||n instanceof lm&&4&n.flags)&&10>Math.abs(this.length-n.length)?(n instanceof lm?n=new lp(n.length,this.height,this.spaceAbove):n.height=this.height,this.outdated||(n.outdated=!1),n):lc.of(i)}updateHeight(e,t=0,i=!1,n){return n&&n.from<=t&&n.more?this.setMeasuredHeight(n):(i||this.outdated)&&(this.spaceAbove=0,this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight)),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class lm extends lc{constructor(e){super(e,0)}heightMetrics(e,t){let i=e.doc.lineAt(t).number,n=e.doc.lineAt(t+this.length).number,r=n-i+1,s,o=0;if(e.lineWrapping){let t=Math.min(this.height,e.lineHeight*r);s=t/r,this.length>r+1&&(o=(this.height-t)/(this.length-r-1))}else s=this.height/r;return{firstLine:i,lastLine:n,perLine:s,perChar:o}}blockAt(e,t,i,n){let{firstLine:r,lastLine:s,perLine:o,perChar:l}=this.heightMetrics(t,n);if(t.lineWrapping){let r=n+(e<t.lineHeight?0:Math.round(Math.max(0,Math.min(1,(e-i)/this.height))*this.length)),s=t.doc.lineAt(r),a=o+s.length*l;return new la(s.from,s.length,Math.max(i,e-a/2),a,0)}{let n=Math.max(0,Math.min(s-r,Math.floor((e-i)/o))),{from:l,length:a}=t.doc.line(r+n);return new la(l,a,i+o*n,o,0)}}lineAt(e,t,i,n,r){if(t==lh.ByHeight)return this.blockAt(e,i,n,r);if(t==lh.ByPosNoHeight){let{from:t,to:n}=i.doc.lineAt(e);return new la(t,n-t,0,0,0)}let{firstLine:s,perLine:o,perChar:l}=this.heightMetrics(i,r),a=i.doc.lineAt(e),h=o+a.length*l,c=a.number-s,d=n+o*c+l*(a.from-r-c);return new la(a.from,a.length,Math.max(n,Math.min(d,n+this.height-h)),h,0)}forEachLine(e,t,i,n,r,s){e=Math.max(e,r),t=Math.min(t,r+this.length);let{firstLine:o,perLine:l,perChar:a}=this.heightMetrics(i,r);for(let h=e,c=n;h<=t;){let t=i.doc.lineAt(h);if(h==e){let i=t.number-o;c+=l*i+a*(e-r-i)}let n=l+a*t.length;s(new la(t.from,t.length,c,n,0)),c+=n,h=t.to+1}}replace(e,t,i){let n=this.length-t;if(n>0){let e=i[i.length-1];e instanceof lm?i[i.length-1]=new lm(e.length+n):i.push(null,new lm(n-1))}if(e>0){let t=i[0];t instanceof lm?i[0]=new lm(e+t.length):i.unshift(new lm(e-1),null)}return lc.of(i)}decomposeLeft(e,t){t.push(new lm(e-1),null)}decomposeRight(e,t){t.push(null,new lm(this.length-e-1))}updateHeight(e,t=0,i=!1,n){let r=t+this.length;if(n&&n.from<=t+this.length&&n.more){let i=[],s=Math.max(t,n.from),o=-1;for(n.from>t&&i.push(new lm(n.from-t-1).updateHeight(e,t));s<=r&&n.more;){let t=e.doc.lineAt(s).length;i.length&&i.push(null);let r=n.heights[n.index++],l=0;r<0&&(l=-r,r=n.heights[n.index++]),-1==o?o=r:Math.abs(r-o)>=.001&&(o=-2);let a=new lp(t,r,l);a.outdated=!1,i.push(a),s+=t+1}s<=r&&i.push(null,new lm(r-s).updateHeight(e,s));let l=lc.of(i);return(o<0||Math.abs(l.height-this.height)>=.001||Math.abs(o-this.heightMetrics(e,t).perLine)>=.001)&&(ls=!0),ld(this,l)}return(i||this.outdated)&&(this.setHeight(e.heightForGap(t,t+this.length)),this.outdated=!1),this}toString(){return`gap(${this.length})`}}class lg extends lc{constructor(e,t,i){super(e.length+t+i.length,e.height+i.height,t|(e.outdated||i.outdated?2:0)),this.left=e,this.right=i,this.size=e.size+i.size}get break(){return 1&this.flags}blockAt(e,t,i,n){let r=i+this.left.height;return e<r?this.left.blockAt(e,t,i,n):this.right.blockAt(e,t,r,n+this.left.length+this.break)}lineAt(e,t,i,n,r){let s=n+this.left.height,o=r+this.left.length+this.break,l=t==lh.ByHeight?e<s:e<o,a=l?this.left.lineAt(e,t,i,n,r):this.right.lineAt(e,t,i,s,o);if(this.break||(l?a.to<o:a.from>o))return a;let h=t==lh.ByPosNoHeight?lh.ByPosNoHeight:lh.ByPos;return l?a.join(this.right.lineAt(o,h,i,s,o)):this.left.lineAt(o,h,i,n,r).join(a)}forEachLine(e,t,i,n,r,s){let o=n+this.left.height,l=r+this.left.length+this.break;if(this.break)e<l&&this.left.forEachLine(e,t,i,n,r,s),t>=l&&this.right.forEachLine(e,t,i,o,l,s);else{let a=this.lineAt(l,lh.ByPos,i,n,r);e<a.from&&this.left.forEachLine(e,a.from-1,i,n,r,s),a.to>=e&&a.from<=t&&s(a),t>a.to&&this.right.forEachLine(a.to+1,t,i,o,l,s)}}replace(e,t,i){let n=this.left.length+this.break;if(t<n)return this.balanced(this.left.replace(e,t,i),this.right);if(e>this.left.length)return this.balanced(this.left,this.right.replace(e-n,t-n,i));let r=[];e>0&&this.decomposeLeft(e,r);let s=r.length;for(let e of i)r.push(e);if(e>0&&lx(r,s-1),t<this.length){let e=r.length;this.decomposeRight(t,r),lx(r,e)}return lc.of(r)}decomposeLeft(e,t){let i=this.left.length;if(e<=i)return this.left.decomposeLeft(e,t);t.push(this.left),this.break&&e>=++i&&t.push(null),e>i&&this.right.decomposeLeft(e-i,t)}decomposeRight(e,t){let i=this.left.length,n=i+this.break;if(e>=n)return this.right.decomposeRight(e-n,t);e<i&&this.left.decomposeRight(e,t),this.break&&e<n&&t.push(null),t.push(this.right)}balanced(e,t){return e.size>2*t.size||t.size>2*e.size?lc.of(this.break?[e,null,t]:[e,t]):(this.left=ld(this.left,e),this.right=ld(this.right,t),this.setHeight(e.height+t.height),this.outdated=e.outdated||t.outdated,this.size=e.size+t.size,this.length=e.length+this.break+t.length,this)}updateHeight(e,t=0,i=!1,n){let{left:r,right:s}=this,o=t+r.length+this.break,l=null;return(n&&n.from<=t+r.length&&n.more?l=r=r.updateHeight(e,t,i,n):r.updateHeight(e,t,i),n&&n.from<=o+s.length&&n.more?l=s=s.updateHeight(e,o,i,n):s.updateHeight(e,o,i),l)?this.balanced(r,s):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function lx(e,t){let i,n;null==e[t]&&(i=e[t-1])instanceof lm&&(n=e[t+1])instanceof lm&&e.splice(t-1,3,new lm(i.length+1+n.length))}class lv{constructor(e,t){this.pos=e,this.oracle=t,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,t){if(this.lineStart>-1){let e=Math.min(t,this.lineEnd),i=this.nodes[this.nodes.length-1];i instanceof lp?i.length+=e-this.pos:(e>this.pos||!this.isCovered)&&this.nodes.push(new lp(e-this.pos,-1,0)),this.writtenTo=e,t>e&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,i){if(e<t||i.heightRelevant){let n=i.widget?i.widget.estimatedHeight:0,r=i.widget?i.widget.lineBreaks:0;n<0&&(n=this.oracle.lineHeight);let s=t-e;i.block?this.addBlock(new lf(s,n,i)):(s||r||n>=5)&&this.addLineDeco(n,r,s)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenTo<e&&((this.writtenTo<e-1||null==this.nodes[this.nodes.length-1])&&this.nodes.push(this.blankContent(this.writtenTo,e-1)),this.nodes.push(null)),this.pos>e&&this.nodes.push(new lp(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,t){let i=new lm(t-e);return this.oracle.doc.lineAt(e).to==t&&(i.flags|=4),i}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof lp)return e;let t=new lp(0,-1,0);return this.nodes.push(t),t}addBlock(e){this.enterLine();let t=e.deco;t&&t.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,t&&t.endSide>0&&(this.covering=e)}addLineDeco(e,t,i){let n=this.ensureLine();n.length+=i,n.collapsed+=i,n.widgetHeight=Math.max(n.widgetHeight,e),n.breaks+=t,this.writtenTo=this.pos=this.pos+i}finish(e){let t=0==this.nodes.length?null:this.nodes[this.nodes.length-1];!(this.lineStart>-1)||t instanceof lp||this.isCovered?(this.writtenTo<this.pos||null==t)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos)):this.nodes.push(new lp(0,-1,0));let i=e;for(let e of this.nodes)e instanceof lp&&e.updateHeight(this.oracle,i),i+=e?e.length:1;return this.nodes}static build(e,t,i,n){let r=new lv(i,e);return ra.spans(t,i,n,r,0),r.finish(i)}}class ly{constructor(){this.changes=[]}compareRange(){}comparePoint(e,t,i,n){(e<t||i&&i.heightRelevant||n&&n.heightRelevant)&&r4(e,t,this.changes,5)}}class lb{constructor(e,t,i,n){this.from=e,this.to=t,this.size=i,this.displaySize=n}static same(e,t){if(e.length!=t.length)return!1;for(let i=0;i<e.length;i++){let n=e[i],r=t[i];if(n.from!=r.from||n.to!=r.to||n.size!=r.size)return!1}return!0}draw(e,t){return rQ.replace({widget:new lw(this.displaySize*(t?e.scaleY:e.scaleX),t)}).range(this.from,this.to)}}class lw extends rX{constructor(e,t){super(),this.size=e,this.vertical=t}eq(e){return e.size==this.size&&e.vertical==this.vertical}toDOM(){let e=document.createElement("div");return this.vertical?e.style.height=this.size+"px":(e.style.width=this.size+"px",e.style.height="2px",e.style.display="inline-block"),e}get estimatedHeight(){return this.vertical?this.size:-1}}class lk{constructor(e){this.state=e,this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0},this.inView=!0,this.paddingTop=0,this.paddingBottom=0,this.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.scrollTop=0,this.scrolledToBottom=!1,this.scaleX=1,this.scaleY=1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=lM,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=sg.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let t=e.facet(sY).some(e=>"function"!=typeof e&&"cm-lineWrapping"==e.class);this.heightOracle=new lo(t),this.stateDeco=lZ(e),this.heightMap=lc.empty().applyChanges(this.stateDeco,ns.empty,this.heightOracle.setDoc(e.doc),[new s9(0,0,0,e.doc.length)]);for(let e=0;e<2&&(this.viewport=this.getViewport(0,null),this.updateForViewport());e++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=rQ.set(this.lineGaps.map(e=>e.draw(this,!1))),this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let i=0;i<=1;i++){let n=i?t.head:t.anchor;if(!e.some(({from:e,to:t})=>n>=e&&n<=t)){let{from:t,to:i}=this.lineBlockAt(n);e.push(new lS(t,i))}}return this.viewports=e.sort((e,t)=>e.from-t.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?lM:new lA(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(lT(e,this.scaler))})}update(e,t=null){var i,n;let r;this.state=e.state;let s=this.stateDeco;this.stateDeco=lZ(this.state);let o=e.changedRanges,l=s9.extendWithRanges(o,(i=this.stateDeco,n=e?e.changes:nb.empty(this.state.doc.length),r=new ly,ra.compare(s,i,n,r,0),r.changes)),a=this.heightMap.height,h=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);ls=!1,this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),l),(this.heightMap.height!=a||ls)&&(e.flags|=2),h?(this.scrollAnchorPos=e.changes.mapPos(h.from,-1),this.scrollAnchorHeight=h.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=a);let c=l.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.head<c.from||t.range.head>c.to)||!this.viewportIsAppropriate(c))&&(c=this.getViewport(0,t));let d=c.from!=this.viewport.from||c.to!=this.viewport.to;this.viewport=c,e.flags|=this.updateForViewport(),(d||!e.changes.empty||2&e.flags)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(e.changes),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(sW)&&(this.mustEnforceCursorAssoc=!0)}measure(e){var t;let i,n,r=e.contentDOM,s=window.getComputedStyle(r),o=this.heightOracle,l=s.whiteSpace;this.defaultTextDirection="rtl"==s.direction?sg.RTL:sg.LTR;let a=this.heightOracle.mustRefreshForWrapping(l)||this.mustMeasureContent,h=r.getBoundingClientRect(),c=a||this.mustMeasureContent||this.contentDOMHeight!=h.height;this.contentDOMHeight=h.height,this.mustMeasureContent=!1;let d=0,u=0;if(h.width&&h.height){let{scaleX:e,scaleY:t}=so(r,h);(e>.005&&Math.abs(this.scaleX-e)>.005||t>.005&&Math.abs(this.scaleY-t)>.005)&&(this.scaleX=e,this.scaleY=t,d|=16,a=c=!0)}let f=(parseInt(s.paddingTop)||0)*this.scaleY,p=(parseInt(s.paddingBottom)||0)*this.scaleY;(this.paddingTop!=f||this.paddingBottom!=p)&&(this.paddingTop=f,this.paddingBottom=p,d|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(o.lineWrapping&&(c=!0),this.editorWidth=e.scrollDOM.clientWidth,d|=16);let m=e.scrollDOM.scrollTop*this.scaleY;this.scrollTop!=m&&(this.scrollAnchorHeight=-1,this.scrollTop=m),this.scrolledToBottom=su(e.scrollDOM);let g=(this.printing?function(e,t){let i=e.getBoundingClientRect();return{left:0,right:i.right-i.left,top:t,bottom:i.bottom-(i.top+t)}}:function(e,t){let i=e.getBoundingClientRect(),n=e.ownerDocument,r=n.defaultView||window,s=Math.max(0,i.left),o=Math.min(r.innerWidth,i.right),l=Math.max(0,i.top),a=Math.min(r.innerHeight,i.bottom);for(let t=e.parentNode;t&&t!=n.body;)if(1==t.nodeType){let i=t,n=window.getComputedStyle(i);if((i.scrollHeight>i.clientHeight||i.scrollWidth>i.clientWidth)&&"visible"!=n.overflow){let n=i.getBoundingClientRect();s=Math.max(s,n.left),o=Math.min(o,n.right),l=Math.max(l,n.top),a=Math.min(t==e.parentNode?r.innerHeight:a,n.bottom)}t="absolute"==n.position||"fixed"==n.position?i.offsetParent:i.parentNode}else if(11==t.nodeType)t=t.host;else break;return{left:s-i.left,right:Math.max(s,o)-i.left,top:l-(i.top+t),bottom:Math.max(l,a)-(i.top+t)}})(r,this.paddingTop),x=g.top-this.pixelViewport.top,v=g.bottom-this.pixelViewport.bottom;this.pixelViewport=g;let y=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(y!=this.inView&&(this.inView=y,y&&(c=!0)),!this.inView&&!this.scrollTarget&&(i=(t=e.dom).getBoundingClientRect(),n=t.ownerDocument.defaultView||window,!(i.left<n.innerWidth)||!(i.right>0)||!(i.top<n.innerHeight)||!(i.bottom>0)))return 0;let b=h.width;if((this.contentDOMWidth!=b||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=h.width,this.editorHeight=e.scrollDOM.clientHeight,d|=16),c){let t=e.docView.measureVisibleLineHeights(this.viewport);if(o.mustRefreshForHeights(t)&&(a=!0),a||o.lineWrapping&&Math.abs(b-this.contentDOMWidth)>o.charWidth){let{lineHeight:i,charWidth:n,textHeight:r}=e.docView.measureTextSize();(a=i>0&&o.refresh(l,i,n,r,Math.max(5,b/n),t))&&(e.docView.minWidth=0,d|=16)}for(let i of(x>0&&v>0?u=Math.max(x,v):x<0&&v<0&&(u=Math.min(x,v)),ls=!1,this.viewports)){let n=i.from==this.viewport.from?t:e.docView.measureVisibleLineHeights(i);this.heightMap=(a?lc.empty().applyChanges(this.stateDeco,ns.empty,this.heightOracle,[new s9(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(o,0,a,new ll(i.from,n))}ls&&(d|=2)}let w=!this.viewportIsAppropriate(this.viewport,u)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return w&&(2&d&&(d|=this.updateScaler()),this.viewport=this.getViewport(u,this.scrollTarget),d|=this.updateForViewport()),(2&d||w)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(a?[]:this.lineGaps,e)),d|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),d}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let i=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),n=this.heightMap,r=this.heightOracle,{visibleTop:s,visibleBottom:o}=this,l=new lS(n.lineAt(s-1e3*i,lh.ByHeight,r,0,0).from,n.lineAt(o+(1-i)*1e3,lh.ByHeight,r,0,0).to);if(t){let{head:e}=t.range;if(e<l.from||e>l.to){let i=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),s=n.lineAt(e,lh.ByPos,r,0,0),o;o="center"==t.y?(s.top+s.bottom)/2-i/2:"start"==t.y||"nearest"==t.y&&e<l.from?s.top:s.bottom-i,l=new lS(n.lineAt(o-500,lh.ByHeight,r,0,0).from,n.lineAt(o+i+500,lh.ByHeight,r,0,0).to)}}return l}mapViewport(e,t){let i=t.mapPos(e.from,-1),n=t.mapPos(e.to,1);return new lS(this.heightMap.lineAt(i,lh.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(n,lh.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:e,to:t},i=0){if(!this.inView)return!0;let{top:n}=this.heightMap.lineAt(e,lh.ByPos,this.heightOracle,0,0),{bottom:r}=this.heightMap.lineAt(t,lh.ByPos,this.heightOracle,0,0),{visibleTop:s,visibleBottom:o}=this;return(0==e||n<=s-Math.max(10,Math.min(-i,250)))&&(t==this.state.doc.length||r>=o+Math.max(10,Math.min(i,250)))&&n>s-2e3&&r<o+2e3}mapLineGaps(e,t){if(!e.length||t.empty)return e;let i=[];for(let n of e)t.touchesRange(n.from,n.to)||i.push(new lb(t.mapPos(n.from),t.mapPos(n.to),n.size,n.displaySize));return i}ensureLineGaps(e,t){let i=this.heightOracle.lineWrapping,n=i?1e4:2e3,r=n>>1,s=n<<1;if(this.defaultTextDirection!=sg.LTR&&!i)return[];let o=[],l=(n,s,a,h)=>{if(s-n<r)return;let c=this.state.selection.main,d=[c.from];for(let e of(c.empty||d.push(c.to),d))if(e>n&&e<s){l(n,e-10,a,h),l(e+10,s,a,h);return}let u=function(e,t){for(let i of e)if(t(i))return i}(e,e=>e.from>=a.from&&e.to<=a.to&&Math.abs(e.from-n)<r&&Math.abs(e.to-s)<r&&!d.some(t=>e.from<t&&e.to>t));if(!u){if(s<a.to&&t&&i&&t.visibleRanges.some(e=>e.from<=s&&e.to>=s)){let e=t.moveToLineBoundary(nA.cursor(s),!1,!0).head;e>n&&(s=e)}let e=this.gapSize(a,n,s,h),r=i||e<2e6?e:2e6;u=new lb(n,s,e,r)}o.push(u)},a=t=>{var r,o,a;let h,c,d,u,f;if(t.length<s||t.type!=rY.Text)return;let p=(r=t.from,o=t.to,a=this.stateDeco,d=[],u=r,f=0,ra.spans(a,r,o,{span(){},point(e,t){e>u&&(d.push({from:u,to:e}),f+=e-u),u=t}},20),u<o&&(d.push({from:u,to:o}),f+=o-u),{total:f,ranges:d});if(p.total<s)return;let m=this.scrollTarget?this.scrollTarget.range.head:null;if(i){let e,i,r=n/this.heightOracle.lineLength*this.heightOracle.lineHeight;if(null!=m){let n=lj(p,m),s=((this.visibleBottom-this.visibleTop)/2+r)/t.height;e=n-s,i=n+s}else e=(this.visibleTop-t.top-r)/t.height,i=(this.visibleBottom-t.top+r)/t.height;h=lC(p,e),c=lC(p,i)}else{let i,r,s=p.total*this.heightOracle.charWidth,o=n*this.heightOracle.charWidth,l=0;if(s>2e6)for(let i of e)i.from>=t.from&&i.from<t.to&&i.size!=i.displaySize&&i.from*this.heightOracle.charWidth+l<this.pixelViewport.left&&(l=i.size-i.displaySize);let a=this.pixelViewport.left+l,d=this.pixelViewport.right+l;if(null!=m){let e=lj(p,m),t=((d-a)/2+o)/s;i=e-t,r=e+t}else i=(a-o)/s,r=(d+o)/s;h=lC(p,i),c=lC(p,r)}h>t.from&&l(t.from,h,t,p),c<t.to&&l(c,t.to,t,p)};for(let e of this.viewportLines)Array.isArray(e.type)?e.type.forEach(a):a(e);return o}gapSize(e,t,i,n){let r=lj(n,i)-lj(n,t);return this.heightOracle.lineWrapping?e.height*r:n.total*this.heightOracle.charWidth*r}updateLineGaps(e){lb.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=rQ.set(e.map(e=>e.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let i=[];ra.spans(t,this.viewport.from,this.viewport.to,{span(e,t){i.push({from:e,to:t})},point(){}},20);let n=0;if(i.length!=this.visibleRanges.length)n=12;else for(let t=0;t<i.length&&!(8&n);t++){let r=this.visibleRanges[t],s=i[t];r.from==s.from&&r.to==s.to||(n|=4,e&&e.mapPos(r.from,-1)==s.from&&e.mapPos(r.to,1)==s.to||(n|=8))}return this.visibleRanges=i,n}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||lT(this.heightMap.lineAt(e,lh.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(t=>t.top<=e&&t.bottom>=e)||lT(this.heightMap.lineAt(this.scaler.fromDOM(e),lh.ByHeight,this.heightOracle,0,0),this.scaler)}scrollAnchorAt(e){let t=this.lineBlockAtHeight(e+8);return t.from>=this.viewport.from||this.viewportLines[0].top-e>200?t:this.viewportLines[0]}elementAtHeight(e){return lT(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class lS{constructor(e,t){this.from=e,this.to=t}}function lC({total:e,ranges:t},i){if(i<=0)return t[0].from;if(i>=1)return t[t.length-1].to;let n=Math.floor(e*i);for(let e=0;;e++){let{from:i,to:r}=t[e],s=r-i;if(n<=s)return i+n;n-=s}}function lj(e,t){let i=0;for(let{from:n,to:r}of e.ranges){if(t<=r){i+=t-n;break}i+=r-n}return i/e.total}let lM={toDOM:e=>e,fromDOM:e=>e,scale:1,eq(e){return e==this}};function lZ(e){let t=e.facet(sQ).filter(e=>"function"!=typeof e),i=e.facet(s1).filter(e=>"function"!=typeof e);return i.length&&t.push(ra.join(i)),t}class lA{constructor(e,t,i){let n=0,r=0,s=0;for(let o of(this.viewports=i.map(({from:i,to:r})=>{let s=t.lineAt(i,lh.ByPos,e,0,0).top,o=t.lineAt(r,lh.ByPos,e,0,0).bottom;return n+=o-s,{from:i,to:r,top:s,bottom:o,domTop:0,domBottom:0}}),this.scale=(7e6-n)/(t.height-n),this.viewports))o.domTop=s+(o.top-r)*this.scale,s=o.domBottom=o.domTop+(o.bottom-o.top),r=o.bottom}toDOM(e){for(let t=0,i=0,n=0;;t++){let r=t<this.viewports.length?this.viewports[t]:null;if(!r||e<r.top)return n+(e-i)*this.scale;if(e<=r.bottom)return r.domTop+(e-r.top);i=r.bottom,n=r.domBottom}}fromDOM(e){for(let t=0,i=0,n=0;;t++){let r=t<this.viewports.length?this.viewports[t]:null;if(!r||e<r.domTop)return i+(e-n)/this.scale;if(e<=r.domBottom)return r.top+(e-r.domTop);i=r.bottom,n=r.domBottom}}eq(e){return e instanceof lA&&this.scale==e.scale&&this.viewports.length==e.viewports.length&&this.viewports.every((t,i)=>t.from==e.viewports[i].from&&t.to==e.viewports[i].to)}}function lT(e,t){if(1==t.scale)return e;let i=t.toDOM(e.top),n=t.toDOM(e.bottom);return new la(e.from,e.length,i,n-i,Array.isArray(e._content)?e._content.map(e=>lT(e,t)):e._content)}let lO=nD.define({combine:e=>e.join(" ")}),lD=nD.define({combine:e=>e.indexOf(!0)>-1}),lR=rj.newName(),lP=rj.newName(),lL=rj.newName(),lI={"&light":"."+lP,"&dark":"."+lL};function lE(e,t,i){return new rj(t,{finish:t=>/&/.test(t)?t.replace(/&\w*/,t=>{if("&"==t)return e;if(!i||!i[t])throw RangeError(`Unsupported selector: ${t}`);return i[t]}):e+" "+t})}let lB=lE("."+lR,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{backgroundImage:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",backgroundPosition:"center"},".cm-highlightTab":{backgroundImage:'url(\'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>\')',backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},lI),lN={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},lz=rK.ie&&rK.ie_version<=11;class lW{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new sl,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(t=>{for(let e of t)this.queue.push(e);(rK.ie&&rK.ie_version<=11||rK.ios&&e.composing)&&t.some(e=>"childList"==e.type&&e.removedNodes.length||"characterData"==e.type&&e.oldValue.length>e.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&rK.android&&!1!==e.constructor.EDIT_CONTEXT&&!(rK.chrome&&rK.chrome_version<126)&&(this.editContext=new lH(e),e.state.facet(sK)&&(e.contentDOM.editContext=this.editContext.editContext)),lz&&(this.onCharData=e=>{this.queue.push({target:e.target,type:"characterData",oldValue:e.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),"function"==typeof ResizeObserver&&(this.resizeScroll=new ResizeObserver(()=>{var e;(null===(e=this.view.docView)||void 0===e?void 0:e.lastUpdate)<Date.now()-75&&this.onResize()}),this.resizeScroll.observe(e.scrollDOM)),this.addWindowListeners(this.win=e.win),this.start(),"function"==typeof IntersectionObserver&&(this.intersection=new IntersectionObserver(e=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),e.length>0&&e[e.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(e=>{e.length>0&&e[e.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){("change"!=e.type&&e.type||e.matches)&&(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((t,i)=>t!=e[i]))){for(let t of(this.gapIntersection.disconnect(),e))this.gapIntersection.observe(t);this.gaps=e}}onSelectionChange(e){let t=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:i}=this,n=this.selectionRange;if(i.state.facet(sK)?i.root.activeElement!=this.dom:!r9(this.dom,n))return;let r=n.anchorNode&&i.docView.tile.nearest(n.anchorNode);if(r&&r.isWidget()&&r.widget.ignoreEvent(e)){t||(this.selectionChanged=!1);return}(rK.ie&&rK.ie_version<=11||rK.android&&rK.chrome)&&!i.state.selection.main.empty&&n.focusNode&&se(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=r3(e.root);if(!t)return!1;let i=rK.safari&&11==e.root.nodeType&&e.root.activeElement==this.dom&&function(e,t){if(t.getComposedRanges){let i=t.getComposedRanges(e.root)[0];if(i)return lV(e,i)}let i=null;function n(e){e.preventDefault(),e.stopImmediatePropagation(),i=e.getTargetRanges()[0]}return e.contentDOM.addEventListener("beforeinput",n,!0),e.dom.ownerDocument.execCommand("indent"),e.contentDOM.removeEventListener("beforeinput",n,!0),i?lV(e,i):null}(this.view,t)||t;if(!i||this.selectionRange.eq(i))return!1;let n=r9(this.dom,i);return n&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&function(e,t){let i=t.focusNode,n=t.focusOffset;if(!i||t.anchorNode!=i||t.anchorOffset!=n)return!1;for(n=Math.min(n,sr(i));;)if(n){if(1!=i.nodeType)return!1;let e=i.childNodes[n-1];"false"==e.contentEditable?n--:n=sr(i=e)}else{if(i==e)return!0;n=st(i),i=i.parentNode}}(this.dom,i)?(this.view.inputState.lastFocusTime=0,e.docView.updateSelection(),!1):(this.selectionRange.setRange(i),n&&(this.selectionChanged=!0),!0)}setSelectionRange(e,t){this.selectionRange.set(e.node,e.offset,t.node,t.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let e=0,t=null;for(let i=this.dom;i;)if(1==i.nodeType)!t&&e<this.scrollTargets.length&&this.scrollTargets[e]==i?e++:t||(t=this.scrollTargets.slice(0,e)),t&&t.push(i),i=i.assignedSlot||i.parentNode;else if(11==i.nodeType)i=i.host;else break;if(e<this.scrollTargets.length&&!t&&(t=this.scrollTargets.slice(0,e)),t){for(let e of this.scrollTargets)e.removeEventListener("scroll",this.onScroll);for(let e of this.scrollTargets=t)e.addEventListener("scroll",this.onScroll)}}ignore(e){if(!this.active)return e();try{return this.stop(),e()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,lN),lz&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),lz&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(e,t){var i;this.delayedAndroidKey||(this.flushingAndroidKey=this.view.win.requestAnimationFrame(()=>{let e=this.delayedAndroidKey;e&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=e.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&e.force&&sd(this.dom,e.key,e.keyCode))})),this.delayedAndroidKey&&"Enter"!=e||(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange<Date.now()-50||!!(null===(i=this.delayedAndroidKey)||void 0===i?void 0:i.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame(()=>{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let t=-1,i=-1,n=!1;for(let r of e){let e=this.readMutation(r);e&&(e.typeOver&&(n=!0),-1==t?{from:t,to:i}=e:(t=Math.min(e.from,t),i=Math.max(e.to,i)))}return{from:t,to:i,typeOver:n}}readChange(){let{from:e,to:t,typeOver:i}=this.processRecords(),n=this.selectionChanged&&r9(this.dom,this.selectionRange);if(e<0&&!n)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let r=new oz(this.view,e,t,i);return this.view.docView.domChanged={newSel:r.newSel?r.newSel.main:null},r}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let t=this.readChange();if(!t)return this.view.requestMeasure(),!1;let i=this.view.state,n=oW(this.view,t);return this.view.state==i&&(t.domChanged||t.newSel&&!oH(this.view.state.selection,t.newSel.main))&&this.view.update([]),n}readMutation(e){let t=this.view.docView.tile.nearest(e.target);if(!t||t.isWidget())return null;if(t.markDirty("attributes"==e.type),"childList"==e.type){let i=lF(t,e.previousSibling||e.target.previousSibling,-1),n=lF(t,e.nextSibling||e.target.nextSibling,1);return{from:i?t.posAfter(i):t.posAtStart,to:n?t.posBefore(n):t.posAtEnd,typeOver:!1}}return"characterData"==e.type?{from:t.posAtStart,to:t.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(sK)!=e.state.facet(sK)&&(e.view.contentDOM.editContext=e.state.facet(sK)?this.editContext.editContext:null))}destroy(){var e,t,i;for(let n of(this.stop(),null===(e=this.intersection)||void 0===e||e.disconnect(),null===(t=this.gapIntersection)||void 0===t||t.disconnect(),null===(i=this.resizeScroll)||void 0===i||i.disconnect(),this.scrollTargets))n.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}}function lF(e,t,i){for(;t;){let n=ot.get(t);if(n&&n.parent==e)return n;let r=t.parentNode;t=r!=e.dom?r:i>0?t.nextSibling:t.previousSibling}return null}function lV(e,t){let i=t.startContainer,n=t.startOffset,r=t.endContainer,s=t.endOffset,o=e.docView.domAtPos(e.state.selection.main.anchor,1);return se(o.node,o.offset,r,s)&&([i,n,r,s]=[r,s,i,n]),{anchorNode:i,anchorOffset:n,focusNode:r,focusOffset:s}}class lH{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let t=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});for(let i in this.handlers.textupdate=i=>{let n=e.state.selection.main,{anchor:r,head:s}=n,o=this.toEditorPos(i.updateRangeStart),l=this.toEditorPos(i.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:i.updateRangeStart,editorBase:o,drifted:!1});let a=l-o>i.text.length;o==this.from&&r<this.from?o=r:l==this.to&&r>this.to&&(l=r);let h=oV(e.state.sliceDoc(o,l),i.text,(a?n.from:n.to)-o,a?"end":null);if(!h){let t=nA.single(this.toEditorPos(i.selectionStart),this.toEditorPos(i.selectionEnd));oH(t,n)||e.dispatch({selection:t,userEvent:"select"});return}let c={from:h.from+o,to:h.toA+o,insert:ns.of(i.text.slice(h.from,h.toB).split("\n"))};if((rK.mac||rK.android)&&c.from==s-1&&/^\. ?$/.test(i.text)&&"off"==e.contentDOM.getAttribute("autocorrect")&&(c={from:o,to:l,insert:ns.of([i.text.replace("."," ")])}),this.pendingContextChange=c,!e.state.readOnly){let t=this.to-this.from+(c.to-c.from+c.insert.length);oF(e,c,nA.single(this.toEditorPos(i.selectionStart,t),this.toEditorPos(i.selectionEnd,t)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),c.from<c.to&&!c.insert.length&&e.inputState.composing>=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(t.text.slice(Math.max(0,i.updateRangeStart-1),Math.min(t.text.length,i.updateRangeStart+1)))&&this.handlers.compositionend(i)},this.handlers.characterboundsupdate=i=>{let n=[],r=null;for(let t=this.toEditorPos(i.rangeStart),s=this.toEditorPos(i.rangeEnd);t<s;t++){let i=e.coordsForChar(t);r=i&&new DOMRect(i.left,i.top,i.right-i.left,i.bottom-i.top)||r||new DOMRect,n.push(r)}t.updateCharacterBounds(i.rangeStart,n)},this.handlers.textformatupdate=t=>{let i=[];for(let e of t.getTextFormats()){let t=e.underlineStyle,n=e.underlineThickness;if(!/none/i.test(t)&&!/none/i.test(n)){let r=this.toEditorPos(e.rangeStart),s=this.toEditorPos(e.rangeEnd);if(r<s){let e=`text-decoration: underline ${/^[a-z]/.test(t)?t+" ":"Dashed"==t?"dashed ":"Squiggle"==t?"wavy ":""}${/thin/i.test(n)?1:2}px`;i.push(rQ.mark({attributes:{style:e}}).range(r,s))}}}e.dispatch({effects:s$.of(rQ.set(i))})},this.handlers.compositionstart=()=>{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:t}=this.composing;this.composing=null,t&&this.reset(e.state)}},this.handlers)t.addEventListener(i,this.handlers[i]);this.measureReq={read:e=>{this.editContext.updateControlBounds(e.contentDOM.getBoundingClientRect());let t=r3(e.root);t&&t.rangeCount&&this.editContext.updateSelectionBounds(t.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let t=0,i=!1,n=this.pendingContextChange;return e.changes.iterChanges((r,s,o,l,a)=>{if(i)return;let h=a.length-(s-r);if(n&&s>=n.to){if(n.from==r&&n.to==s&&n.insert.eq(a)){n=this.pendingContextChange=null,t+=h,this.to+=h;return}n=null,this.revertPending(e.state)}if(r+=t,(s+=t)<=this.from)this.from+=h,this.to+=h;else if(r<this.to){if(r<this.from||s>this.to||this.to-this.from+a.length>3e4){i=!0;return}this.editContext.updateText(this.toContextPos(r),this.toContextPos(s),a.toString()),this.to+=h}t+=h}),n&&!i&&this.revertPending(e.state),!i}update(e){let t=this.pendingContextChange,i=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(i.from,i.to)&&e.transactions.some(e=>!e.isUserEvent("input.type")&&e.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):this.applyEdits(e)&&this.rangeIsValid(e.state)?(e.docChanged||e.selectionSet||t)&&this.setSelection(e.state):(this.pendingContextChange=null,this.reset(e.state)),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:t}=e.selection.main;this.from=Math.max(0,t-1e4),this.to=Math.min(e.doc.length,t+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let t=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(t.from),this.toContextPos(t.from+t.insert.length),e.doc.sliceString(t.from,t.to))}setSelection(e){let{main:t}=e.selection,i=this.toContextPos(Math.max(this.from,Math.min(this.to,t.anchor))),n=this.toContextPos(t.head);(this.editContext.selectionStart!=i||this.editContext.selectionEnd!=n)&&this.editContext.updateSelection(i,n)}rangeIsValid(e){let{head:t}=e.selection.main;return!(this.from>0&&t-this.from<500||this.to<e.doc.length&&this.to-t<500||this.to-this.from>3e4)}toEditorPos(e,t=this.to-this.from){e=Math.min(e,t);let i=this.composing;return i&&i.drifted?i.editorBase+(e-i.contextBase):e+this.from}toContextPos(e){let t=this.composing;return t&&t.drifted?t.contextBase+(e-t.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class l${get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var t;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:i}=e;for(let t of(this.dispatchTransactions=e.dispatchTransactions||i&&(e=>e.forEach(e=>i(e,this)))||(e=>this.update(e)),this.dispatch=this.dispatch.bind(this),this._root=e.root||function(e){for(;e;){if(e&&(9==e.nodeType||11==e.nodeType&&e.host))return e;e=e.assignedSlot||e.parentNode}return null}(e.parent)||document,this.viewState=new lk(e.state||rt.create(e)),e.scrollTo&&e.scrollTo.is(sH)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(s_).map(e=>new sJ(e)),this.plugins))t.update(this);this.observer=new lW(this),this.inputState=new o$(this),this.inputState.ensureHandlers(this.plugins),this.docView=new oS(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),(null===(t=document.fonts)||void 0===t?void 0:t.ready)&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent=!0,this.requestMeasure()})}dispatch(...e){let t=1==e.length&&e[0]instanceof n4?e:1==e.length&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(e){if(0!=this.updateState)throw Error("Calls to EditorView.update are not allowed while an update is in progress");let t=!1,i=!1,n,r=this.state;for(let t of e){if(t.startState!=r)throw RangeError("Trying to update state with a transaction that doesn't start from the previous state.");r=t.state}if(this.destroyed){this.viewState.state=r;return}let s=this.hasFocus,o=0,l=null;e.some(e=>e.annotation(le))?(this.inputState.notifiedFocused=s,o=1):s==this.inputState.notifiedFocused||(this.inputState.notifiedFocused=s,(l=lt(r,s))||(o=1));let a=this.observer.delayedAndroidKey,h=null;if(a?(this.observer.clearDelayedAndroidKey(),((h=this.observer.readChange())&&!this.state.doc.eq(r.doc)||!this.state.selection.eq(r.selection))&&(h=null)):this.observer.clear(),r.facet(rt.phrases)!=this.state.facet(rt.phrases))return this.setState(r);n=s7.create(this,r,e),n.flags|=o;let c=this.viewState.scrollTarget;try{for(let t of(this.updateState=2,e)){if(c&&(c=c.map(t.changes)),t.scrollIntoView){let{main:e}=t.state.selection;c=new sV(e.empty?e:nA.cursor(e.head,e.head>e.anchor?-1:1))}for(let e of t.effects)e.is(sH)&&(c=e.value.clip(this.state))}this.viewState.update(n,c),this.bidiCache=lU.update(this.bidiCache,n.changes),n.empty||(this.updatePlugins(n),this.inputState.update(n)),t=this.docView.update(n),this.state.facet(s8)!=this.styleModules&&this.mountStyles(),i=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(t,e.some(e=>e.isUserEvent("select.pointer")))}finally{this.updateState=0}if(n.startState.facet(lO)!=n.state.facet(lO)&&(this.viewState.mustMeasureContent=!0),(t||i||c||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),t&&this.docViewUpdate(),!n.empty)for(let e of this.state.facet(sL))try{e(n)}catch(e){sq(this.state,e,"update listener")}(l||h)&&Promise.resolve().then(()=>{l&&this.state==l.startState&&this.dispatch(l),h&&!oW(this,h)&&a.force&&sd(this.contentDOM,a.key,a.keyCode)})}setState(e){if(0!=this.updateState)throw Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let t=this.hasFocus;try{for(let e of this.plugins)e.destroy(this);for(let t of(this.viewState=new lk(e),this.plugins=e.facet(s_).map(e=>new sJ(e)),this.pluginMap.clear(),this.plugins))t.update(this);this.docView.destroy(),this.docView=new oS(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}t&&this.focus(),this.requestMeasure()}updatePlugins(e){let t=e.startState.facet(s_),i=e.state.facet(s_);if(t!=i){let n=[];for(let r of i){let i=t.indexOf(r);if(i<0)n.push(new sJ(r));else{let t=this.plugins[i];t.mustUpdate=e,n.push(t)}}for(let t of this.plugins)t.mustUpdate!=e&&t.destroy(this);this.plugins=n,this.pluginMap.clear()}else for(let t of this.plugins)t.mustUpdate=e;for(let e=0;e<this.plugins.length;e++)this.plugins[e].update(this);t!=i&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let e of this.plugins){let t=e.value;if(t&&t.docViewUpdate)try{t.docViewUpdate(this)}catch(e){sq(this.state,e,"doc view update listener")}}}measure(e=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,i=this.scrollDOM,n=i.scrollTop*this.scaleY,{scrollAnchorPos:r,scrollAnchorHeight:s}=this.viewState;Math.abs(n-this.viewState.scrollTop)>1&&(s=-1),this.viewState.scrollAnchorHeight=-1;try{for(let e=0;;e++){if(s<0){if(su(i))r=-1,s=this.viewState.heightMap.height;else{let e=this.viewState.scrollAnchorAt(n);r=e.from,s=e.top}}this.updateState=1;let o=this.viewState.measure(this);if(!o&&!this.measureRequests.length&&null==this.viewState.scrollTarget)break;if(e>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let l=[];4&o||([this.measureRequests,l]=[l,this.measureRequests]);let a=l.map(e=>{try{return e.read(this)}catch(e){return sq(this.state,e),lK}}),h=s7.create(this,this.state,[]),c=!1;h.flags|=o,t?t.flags|=o:t=h,this.updateState=2,!h.empty&&(this.updatePlugins(h),this.inputState.update(h),this.updateAttrs(),(c=this.docView.update(h))&&this.docViewUpdate());for(let e=0;e<l.length;e++)if(a[e]!=lK)try{let t=l[e];t.write&&t.write(a[e],this)}catch(e){sq(this.state,e)}if(c&&this.docView.updateSelection(!0),!h.viewportChanged&&0==this.measureRequests.length){if(this.viewState.editorHeight){if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,s=-1;continue}{let e=(r<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(r).top)-s;if(e>1||e<-1){n+=e,i.scrollTop=n/this.scaleY,s=-1;continue}}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let e of this.state.facet(sL))e(t)}get themeClasses(){return lR+" "+(this.state.facet(lD)?lL:lP)+" "+this.state.facet(lO)}updateAttrs(){let e=l_(this,sX,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(sK)?"true":"false",class:"cm-content",style:`${rK.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),l_(this,sY,t);let i=this.observer.ignore(()=>{let i=rJ(this.contentDOM,this.contentAttrs,t),n=rJ(this.dom,this.editorAttrs,e);return i||n});return this.editorAttrs=e,this.contentAttrs=t,i}showAnnouncements(e){let t=!0;for(let i of e)for(let e of i.effects)e.is(l$.announce)&&(t&&(this.announceDOM.textContent=""),t=!1,this.announceDOM.appendChild(document.createElement("div")).textContent=e.value)}mountStyles(){this.styleModules=this.state.facet(s8);let e=this.state.facet(l$.cspNonce);rj.mount(this.root,this.styleModules.concat(lB).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(2==this.updateState)throw Error("Reading the editor layout isn't allowed during an update");0==this.updateState&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e&&!(this.measureRequests.indexOf(e)>-1)){if(null!=e.key){for(let t=0;t<this.measureRequests.length;t++)if(this.measureRequests[t].key===e.key){this.measureRequests[t]=e;return}}this.measureRequests.push(e)}}plugin(e){let t=this.pluginMap.get(e);return(void 0===t||t&&t.plugin!=e)&&this.pluginMap.set(e,t=this.plugins.find(t=>t.plugin==e)||null),t&&t.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,t,i){return oP(this,e,oO(this,e,t,i))}moveByGroup(e,t){return oP(this,e,oO(this,e,t,t=>{var i;let n,r;return i=e.head,r=(n=this.state.charCategorizer(i))(t),e=>{let t=n(e);return r==n7.Space&&(r=t),r==t}}))}visualLineSide(e,t){let i=this.bidiSpans(e),n=this.textDirectionAt(e.from),r=i[t?i.length-1:0];return nA.cursor(r.side(t,n)+e.from,r.forward(!t,n)?1:-1)}moveToLineBoundary(e,t,i=!0){return function(e,t,i,n){let r=oT(e,t.head,t.assoc||-1),s=n&&r.type==rY.Text&&(e.lineWrapping||r.widgetLineBreaks)?e.coordsAtPos(t.assoc<0&&t.head>r.from?t.head-1:t.head):null;if(s){let t=e.dom.getBoundingClientRect(),n=e.textDirectionAt(r.from),o=e.posAtCoords({x:i==(n==sg.LTR)?t.right-1:t.left+1,y:(s.top+s.bottom)/2});if(null!=o)return nA.cursor(o,i?-1:1)}return nA.cursor(i?r.to:r.from,i?-1:1)}(this,e,t,i)}moveVertically(e,t,i){return oP(this,e,function(e,t,i,n){let r=t.head,s=i?1:-1;if(r==(i?e.state.doc.length:0))return nA.cursor(r,t.assoc);let o=t.goalColumn,l,a=e.contentDOM.getBoundingClientRect(),h=e.coordsAtPos(r,(t.empty?t.assoc:0)||(i?1:-1)),c=e.documentTop;if(h)null==o&&(o=h.left-a.left),l=s<0?h.top:h.bottom;else{let t=e.viewState.lineBlockAt(r);null==o&&(o=Math.min(a.right-a.left,e.defaultCharacterWidth*(r-t.from))),l=(s<0?t.top:t.bottom)+c}let d=a.left+o,u=null!=n?n:e.viewState.heightOracle.textHeight>>1,f=oI(e,{x:d,y:l+u*s},!1,s);return nA.cursor(f.pos,f.assoc,void 0,o)}(this,e,t,i))}domAtPos(e,t=1){return this.docView.domAtPos(e,t)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){this.readMeasured();let i=oI(this,e,t);return i&&i.pos}posAndSideAtCoords(e,t=!0){return this.readMeasured(),oI(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let i=this.docView.coordsAt(e,t);if(!i||i.left==i.right)return i;let n=this.state.doc.lineAt(e),r=this.bidiSpans(n);return ss(i,r[sM.find(r,e-n.from,-1,t)].dir==sg.LTR==t>0)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(sz)||e<this.viewport.from||e>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>lq)return sA(e.length);let t=this.textDirectionAt(e.from),i;for(let n of this.bidiCache)if(n.from==e.from&&n.dir==t&&(n.fresh||function e(t,i){if(t.length!=i.length)return!1;for(let n=0;n<t.length;n++){let r=t[n],s=i[n];if(r.from!=s.from||r.to!=s.to||r.direction!=s.direction||!e(r.inner,s.inner))return!1}return!0}(n.isolates,i=s4(this,e))))return n.order;i||(i=s4(this,e));let n=function(e,t,i){if(!e)return[new sM(0,0,t==sv?1:0)];if(t==sx&&!i.length&&!sj.test(e))return sA(e.length);if(i.length)for(;e.length>sZ.length;)sZ[sZ.length]=256;let n=[],r=t==sx?0:1;return function e(t,i,n,r,s,o,l){let a=i%2?2:1;(function(e,t,i,n,r){for(let s=0;s<=n.length;s++){let o=s?n[s-1].to:t,l=s<n.length?n[s].from:i,a=s?256:r;for(let t=o,i=a,n=a;t<l;t++){let r=sC(e.charCodeAt(t));512==r?r=i:8==r&&4==n&&(r=16),sZ[t]=4==r?2:r,7&r&&(n=r),i=r}for(let e=o,t=a,n=a;e<l;e++){let r=sZ[e];if(128==r)e<l-1&&t==sZ[e+1]&&24&t?r=sZ[e]=t:sZ[e]=256;else if(64==r){let r=e+1;for(;r<l&&64==sZ[r];)r++;let s=e&&8==t||r<i&&8==sZ[r]?1==n?1:8:256;for(let t=e;t<r;t++)sZ[t]=s;e=r-1}else 8==r&&1==n&&(sZ[e]=1);t=r,7&r&&(n=r)}}})(t,s,o,r,a),function(e,t,i,n,r){let s=1==r?2:1;for(let o=0,l=0,a=0;o<=n.length;o++){let h=o?n[o-1].to:t,c=o<n.length?n[o].from:i;for(let t=h,i,n,o;t<c;t++)if(n=sk[i=e.charCodeAt(t)]){if(n<0){for(let e=l-3;e>=0;e-=3)if(sS[e+1]==-n){let i=sS[e+2],n=2&i?r:4&i?1&i?s:r:0;n&&(sZ[t]=sZ[sS[e]]=n),l=e;break}}else if(189==sS.length)break;else sS[l++]=t,sS[l++]=i,sS[l++]=a}else if(2==(o=sZ[t])||1==o){let e=o==r;a=e?0:1;for(let t=l-3;t>=0;t-=3){let i=sS[t+2];if(2&i)break;if(e)sS[t+2]|=2;else{if(4&i)break;sS[t+2]|=4}}}}}(t,s,o,r,a),function(e,t,i,n){for(let r=0,s=n;r<=i.length;r++){let o=r?i[r-1].to:e,l=r<i.length?i[r].from:t;for(let a=o;a<l;){let o=sZ[a];if(256==o){let o=a+1;for(;;)if(o==l){if(r==i.length)break;o=i[r++].to,l=r<i.length?i[r].from:t}else if(256==sZ[o])o++;else break;let h=1==s,c=h==((o<t?sZ[o]:n)==1)?h?1:2:n;for(let t=o,n=r,s=n?i[n-1].to:e;t>a;)t==s&&(t=i[--n].from,s=n?i[n-1].to:e),sZ[--t]=c;a=o}else s=o,a++}}}(s,o,r,a),function t(i,n,r,s,o,l,a){let h=s%2?2:1;if(s%2==o%2)for(let c=n,d=0;c<r;){let n=!0,u=!1;if(d==l.length||c<l[d].from){let e=sZ[c];e!=h&&(n=!1,u=16==e)}let f=n||1!=h?null:[],p=n?s:s+1,m=c;i:for(;;)if(d<l.length&&m==l[d].from){if(u)break;let t=l[d];if(!n)for(let e=t.to,i=d+1;;){if(e==r)break i;if(i<l.length&&l[i].from==e)e=l[i++].to;else if(sZ[e]==h)break i;else break}d++,f?f.push(t):(t.from>c&&a.push(new sM(c,t.from,p)),e(i,t.direction==sx!=!(p%2)?s+1:s,o,t.inner,t.from,t.to,a),c=t.to),m=t.to}else if(m==r||(n?sZ[m]!=h:sZ[m]==h))break;else m++;f?t(i,c,m,s+1,o,f,a):c<m&&a.push(new sM(c,m,p)),c=m}else for(let c=r,d=l.length;c>n;){let r=!0,u=!1;if(!d||c>l[d-1].to){let e=sZ[c-1];e!=h&&(r=!1,u=16==e)}let f=r||1!=h?null:[],p=r?s:s+1,m=c;i:for(;;)if(d&&m==l[d-1].to){if(u)break;let t=l[--d];if(!r)for(let e=t.from,i=d;;){if(e==n)break i;if(i&&l[i-1].to==e)e=l[--i].from;else if(sZ[e-1]==h)break i;else break}f?f.push(t):(t.to<c&&a.push(new sM(t.to,c,p)),e(i,t.direction==sx!=!(p%2)?s+1:s,o,t.inner,t.from,t.to,a),c=t.from),m=t.from}else if(m==n||(r?sZ[m-1]!=h:sZ[m-1]==h))break;else m--;f?t(i,m,c,s+1,o,f,a):m<c&&a.push(new sM(m,c,p)),c=m}}(t,s,o,i,n,r,l)}(e,r,r,i,0,e.length,n),n}(e.text,t,i);return this.bidiCache.push(new lU(e.from,e.to,t,i,!0,n)),n}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||rK.safari&&(null===(e=this.inputState)||void 0===e?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{sh(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((9==e.nodeType?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){for(let e of(this.root.activeElement==this.contentDOM&&this.contentDOM.blur(),this.plugins))e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){return sH.of(new sV("number"==typeof e?nA.cursor(e):e,t.y,t.x,t.yMargin,t.xMargin))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,i=this.viewState.scrollAnchorAt(e);return sH.of(new sV(nA.cursor(i.from),"start","start",i.top-e,t,!0))}setTabFocusMode(e){null==e?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:"boolean"==typeof e?this.inputState.tabFocusMode=e?0:-1:0!=this.inputState.tabFocusMode&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return sG.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return sG.define(()=>({}),{eventObservers:e})}static theme(e,t){let i=rj.newName(),n=[lO.of(i),s8.of(lE(`.${i}`,e))];return t&&t.dark&&n.push(lD.of(!0)),n}static baseTheme(e){return nW.lowest(s8.of(lE("."+lR,e,lI)))}static findFromDOM(e){var t;let i=e.querySelector(".cm-content"),n=i&&ot.get(i)||ot.get(e);return(null===(t=null==n?void 0:n.root)||void 0===t?void 0:t.view)||null}}l$.styleModule=s8,l$.inputHandler=sI,l$.clipboardInputFilter=sB,l$.clipboardOutputFilter=sN,l$.scrollHandler=sF,l$.focusChangeEffect=sE,l$.perLineTextDirection=sz,l$.exceptionSink=sP,l$.updateListener=sL,l$.editable=sK,l$.mouseSelectionStyle=sR,l$.dragMovesSelection=sD,l$.clickAddsSelectionRange=sO,l$.decorations=sQ,l$.blockWrappers=s0,l$.outerDecorations=s1,l$.atomicRanges=s2,l$.bidiIsolatedRanges=s5,l$.scrollMargins=s6,l$.darkTheme=lD,l$.cspNonce=nD.define({combine:e=>e.length?e[0]:""}),l$.contentAttributes=sY,l$.editorAttributes=sX,l$.lineWrapping=l$.contentAttributes.of({class:"cm-lineWrapping"}),l$.announce=n5.define();let lq=4096,lK={};class lU{constructor(e,t,i,n,r,s){this.from=e,this.to=t,this.dir=i,this.isolates=n,this.fresh=r,this.order=s}static update(e,t){if(t.empty&&!e.some(e=>e.fresh))return e;let i=[],n=e.length?e[e.length-1].dir:sg.LTR;for(let r=Math.max(0,e.length-10);r<e.length;r++){let s=e[r];s.dir!=n||t.touchesRange(s.from,s.to)||i.push(new lU(t.mapPos(s.from,1),t.mapPos(s.to,-1),s.dir,s.isolates,!1,s.order))}return i}}function l_(e,t,i){for(let n=e.state.facet(t),r=n.length-1;r>=0;r--){let t=n[r],s="function"==typeof t?t(e):t;s&&rU(s,i)}return i}let lG=rK.mac?"mac":rK.windows?"win":rK.linux?"linux":"key";function lJ(e,t,i){return t.altKey&&(e="Alt-"+e),t.ctrlKey&&(e="Ctrl-"+e),t.metaKey&&(e="Meta-"+e),!1!==i&&t.shiftKey&&(e="Shift-"+e),e}let lX=nW.default(l$.domEventHandlers({keydown:(e,t)=>l5(l0(t.state),e,t,"editor")})),lY=nD.define({enables:lX}),lQ=new WeakMap;function l0(e){let t=e.facet(lY),i=lQ.get(t);return i||lQ.set(t,i=function(e,t=lG){let i=Object.create(null),n=Object.create(null),r=(e,t)=>{let i=n[e];if(null==i)n[e]=t;else if(i!=t)throw Error("Key binding "+e+" is used both as a regular binding and as a multi-stroke prefix")},s=(e,n,s,o,l)=>{var a,h;let c=i[e]||(i[e]=Object.create(null)),d=n.split(/ (?!$)/).map(e=>(function(e,t){let i,n,r,s;let o=e.split(/-(?!$)/),l=o[o.length-1];"Space"==l&&(l=" ");for(let e=0;e<o.length-1;++e){let l=o[e];if(/^(cmd|meta|m)$/i.test(l))s=!0;else if(/^a(lt)?$/i.test(l))i=!0;else if(/^(c|ctrl|control)$/i.test(l))n=!0;else if(/^s(hift)?$/i.test(l))r=!0;else if(/^mod$/i.test(l))"mac"==t?s=!0:n=!0;else throw Error("Unrecognized modifier name: "+l)}return i&&(l="Alt-"+l),n&&(l="Ctrl-"+l),s&&(l="Meta-"+l),r&&(l="Shift-"+l),l})(e,t));for(let t=1;t<d.length;t++){let i=d.slice(0,t).join(" ");r(i,!0),c[i]||(c[i]={preventDefault:!0,stopPropagation:!1,run:[t=>{let n=l1={view:t,prefix:i,scope:e};return setTimeout(()=>{l1==n&&(l1=null)},4e3),!0}]})}let u=d.join(" ");r(u,!1);let f=c[u]||(c[u]={preventDefault:!1,stopPropagation:!1,run:(null===(h=null===(a=c._any)||void 0===a?void 0:a.run)||void 0===h?void 0:h.slice())||[]});s&&f.run.push(s),o&&(f.preventDefault=!0),l&&(f.stopPropagation=!0)};for(let n of e){let e=n.scope?n.scope.split(" "):["editor"];if(n.any)for(let t of e){let e=i[t]||(i[t]=Object.create(null));e._any||(e._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:r}=n;for(let t in e)e[t].run.push(e=>r(e,l2))}let r=n[t]||n.key;if(r)for(let t of e)s(t,r,n.run,n.preventDefault,n.stopPropagation),n.shift&&s(t,"Shift-"+r,n.shift,n.preventDefault,n.stopPropagation)}return i}(t.reduce((e,t)=>e.concat(t),[]))),i}let l1=null,l2=null;function l5(e,t,i,n){var r;l2=t;let s=("Esc"==(r=!(rO&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||rD&&t.shiftKey&&t.key&&1==t.key.length||"Unidentified"==t.key)&&t.key||(t.shiftKey?rT:rA)[t.keyCode]||t.key||"Unidentified")&&(r="Escape"),"Del"==r&&(r="Delete"),"Left"==r&&(r="ArrowLeft"),"Up"==r&&(r="ArrowUp"),"Right"==r&&(r="ArrowRight"),"Down"==r&&(r="ArrowDown"),r),o=ng(nm(s,0))==s.length&&" "!=s,l="",a=!1,h=!1,c=!1;l1&&l1.view==i&&l1.scope==n&&(l=l1.prefix+" ",0>o_.indexOf(t.keyCode)&&(h=!0,l1=null));let d=new Set,u=e=>{if(e){for(let t of e.run)if(!d.has(t)&&(d.add(t),t(i)))return e.stopPropagation&&(c=!0),!0;e.preventDefault&&(e.stopPropagation&&(c=!0),h=!0)}return!1},f=e[n],p,m;return f&&(u(f[l+lJ(s,t,!o)])?a=!0:o&&(t.altKey||t.metaKey||t.ctrlKey)&&!(rK.windows&&t.ctrlKey&&t.altKey)&&!(rK.mac&&t.altKey&&!(t.ctrlKey||t.metaKey))&&(p=rA[t.keyCode])&&p!=s?u(f[l+lJ(p,t,!0)])?a=!0:t.shiftKey&&(m=rT[t.keyCode])!=s&&m!=p&&u(f[l+lJ(m,t,!1)])&&(a=!0):o&&t.shiftKey&&u(f[l+lJ(s,t,!0)])&&(a=!0),!a&&u(f._any)&&(a=!0)),h&&(a=!0),a&&c&&t.stopPropagation(),l2=null,a}class l4{constructor(e,t,i,n,r){this.className=e,this.left=t,this.top=i,this.width=n,this.height=r}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,t){return t.className==this.className&&(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",null!=this.width&&(e.style.width=this.width+"px"),e.style.height=this.height+"px"}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(e,t,i){if(!i.empty)return function(e,t,i){if(i.to<=e.viewport.from||i.from>=e.viewport.to)return[];let n=Math.max(i.from,e.viewport.from),r=Math.min(i.to,e.viewport.to),s=e.textDirection==sg.LTR,o=e.contentDOM,l=o.getBoundingClientRect(),a=l6(e),h=o.querySelector(".cm-line"),c=h&&window.getComputedStyle(h),d=l.left+(c?parseInt(c.paddingLeft)+Math.min(0,parseInt(c.textIndent)):0),u=l.right-(c?parseInt(c.paddingRight):0),f=oT(e,n,1),p=oT(e,r,-1),m=f.type==rY.Text?f:null,g=p.type==rY.Text?p:null;if(m&&(e.lineWrapping||f.widgetLineBreaks)&&(m=l3(e,n,1,m)),g&&(e.lineWrapping||p.widgetLineBreaks)&&(g=l3(e,r,-1,g)),m&&g&&m.from==g.from&&m.to==g.to)return v(y(i.from,i.to,m));{let t=m?y(i.from,null,m):b(f,!1),n=g?y(null,i.to,g):b(p,!0),r=[];return(m||f).to<(g||p).from-(m&&g?1:0)||f.widgetLineBreaks>1&&t.bottom+e.defaultLineHeight/2<n.top?r.push(x(d,t.bottom,u,n.top)):t.bottom<n.top&&e.elementAtHeight((t.bottom+n.top)/2).type==rY.Text&&(t.bottom=n.top=(t.bottom+n.top)/2),v(t).concat(r).concat(v(n))}function x(e,i,n,r){return new l4(t,e-a.left,i-a.top,Math.max(0,n-e),r-i)}function v({top:e,bottom:t,horizontal:i}){let n=[];for(let r=0;r<i.length;r+=2)n.push(x(i[r],e,i[r+1],t));return n}function y(t,i,n){let r=1e9,o=-1e9,l=[];function a(t,i,a,h,c){let f=e.coordsAtPos(t,t==n.to?-2:2),p=e.coordsAtPos(a,a==n.from?2:-2);f&&p&&(r=Math.min(f.top,p.top,r),o=Math.max(f.bottom,p.bottom,o),c==sg.LTR?l.push(s&&i?d:f.left,s&&h?u:p.right):l.push(!s&&h?d:p.left,!s&&i?u:f.right))}let h=null!=t?t:n.from,c=null!=i?i:n.to;for(let n of e.visibleRanges)if(n.to>h&&n.from<c)for(let r=Math.max(n.from,h),s=Math.min(n.to,c);;){let n=e.state.doc.lineAt(r);for(let o of e.bidiSpans(n)){let e=o.from+n.from,l=o.to+n.from;if(e>=s)break;l>r&&a(Math.max(e,r),null==t&&e<=h,Math.min(l,s),null==i&&l>=c,o.dir)}if((r=n.to+1)>=s)break}return 0==l.length&&a(h,null==t,c,null==i,e.textDirection),{top:r,bottom:o,horizontal:l}}function b(e,t){let i=l.top+(t?e.top:e.bottom);return{top:i,bottom:i,horizontal:[]}}}(e,t,i);{let n=e.coordsAtPos(i.head,i.assoc||1);if(!n)return[];let r=l6(e);return[new l4(t,n.left-r.left,n.top-r.top,null,n.bottom-n.top)]}}}function l6(e){let t=e.scrollDOM.getBoundingClientRect();return{left:(e.textDirection==sg.LTR?t.left:t.right-e.scrollDOM.clientWidth*e.scaleX)-e.scrollDOM.scrollLeft*e.scaleX,top:t.top-e.scrollDOM.scrollTop*e.scaleY}}function l3(e,t,i,n){let r=e.coordsAtPos(t,2*i);if(!r)return n;let s=e.dom.getBoundingClientRect(),o=(r.top+r.bottom)/2,l=e.posAtCoords({x:s.left+1,y:o}),a=e.posAtCoords({x:s.right-1,y:o});return null==l||null==a?n:{from:Math.max(n.from,Math.min(l,a)),to:Math.min(n.to,Math.max(l,a))}}class l8{constructor(e,t){this.view=e,this.layer=t,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),t.above&&this.dom.classList.add("cm-layer-above"),t.class&&this.dom.classList.add(t.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),t.mount&&t.mount(this.dom,e)}update(e){e.startState.facet(l9)!=e.state.facet(l9)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){!1!==this.layer.updateOnDocViewUpdate&&e.requestMeasure(this.measureReq)}setOrder(e){let t=0,i=e.facet(l9);for(;t<i.length&&i[t]!=this.layer;)t++;this.dom.style.zIndex=String((this.layer.above?150:-1)-t)}measure(){return this.layer.markers(this.view)}scale(){let{scaleX:e,scaleY:t}=this.view;(e!=this.scaleX||t!=this.scaleY)&&(this.scaleX=e,this.scaleY=t,this.dom.style.transform=`scale(${1/e}, ${1/t})`)}draw(e){if(e.length!=this.drawn.length||e.some((e,t)=>{var i;return i=this.drawn[t],!(e.constructor==i.constructor&&e.eq(i))})){let t=this.dom.firstChild,i=0;for(let n of e)n.update&&t&&n.constructor&&this.drawn[i].constructor&&n.update(t,this.drawn[i])?(t=t.nextSibling,i++):this.dom.insertBefore(n.draw(),t);for(;t;){let e=t.nextSibling;t.remove(),t=e}this.drawn=e,rK.safari&&rK.safari_version>=26&&(this.dom.style.display=this.dom.firstChild?"":"none")}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}let l9=nD.define();function l7(e){return[sG.define(t=>new l8(t,e)),l9.of(e)]}let ae=nD.define({combine:e=>ri(e,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})});function at(e){return e.startState.facet(ae)!=e.state.facet(ae)}let ai=l7({above:!0,markers(e){let{state:t}=e,i=t.facet(ae),n=[];for(let r of t.selection.ranges){let s=r==t.selection.main;if(r.empty||i.drawRangeCursor){let t=s?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",i=r.empty?r:nA.cursor(r.head,r.head>r.anchor?-1:1);for(let r of l4.forRange(e,t,i))n.push(r)}}return n},update(e,t){e.transactions.some(e=>e.selection)&&(t.style.animationName="cm-blink"==t.style.animationName?"cm-blink2":"cm-blink");let i=at(e);return i&&an(e.state,t),e.docChanged||e.selectionSet||i},mount(e,t){an(t.state,e)},class:"cm-cursorLayer"});function an(e,t){t.style.animationDuration=e.facet(ae).cursorBlinkRate+"ms"}let ar=l7({above:!1,markers:e=>e.state.selection.ranges.map(t=>t.empty?[]:l4.forRange(e,"cm-selectionBackground",t)).reduce((e,t)=>e.concat(t)),update:(e,t)=>e.docChanged||e.selectionSet||e.viewportChanged||at(e),class:"cm-selectionLayer"}),as=nW.highest(l$.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:"transparent !important"},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}})),ao=n5.define({map:(e,t)=>null==e?null:t.mapPos(e)});function al(e,t,i,n,r){t.lastIndex=0;for(let s=e.iterRange(i,n),o=i,l;!s.next().done;o+=s.value.length)if(!s.lineBreak)for(;l=t.exec(s.value);)r(o+l.index,l)}class aa{constructor(e){let{regexp:t,decoration:i,decorate:n,boundary:r,maxLength:s=1e3}=e;if(!t.global)throw RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=t,n)this.addMatch=(e,t,i,r)=>n(r,i,i+e[0].length,e,t);else if("function"==typeof i)this.addMatch=(e,t,n,r)=>{let s=i(e,t,n);s&&r(n,n+e[0].length,s)};else if(i)this.addMatch=(e,t,n,r)=>r(n,n+e[0].length,i);else throw RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.boundary=r,this.maxLength=s}createDeco(e){let t=new rh,i=t.add.bind(t);for(let{from:t,to:n}of function(e,t){let i=e.visibleRanges;if(1==i.length&&i[0].from==e.viewport.from&&i[0].to==e.viewport.to)return i;let n=[];for(let{from:r,to:s}of i)r=Math.max(e.state.doc.lineAt(r).from,r-t),s=Math.min(e.state.doc.lineAt(s).to,s+t),n.length&&n[n.length-1].to>=r?n[n.length-1].to=s:n.push({from:r,to:s});return n}(e,this.maxLength))al(e.state.doc,this.regexp,t,n,(t,n)=>this.addMatch(n,e,t,i));return t.finish()}updateDeco(e,t){let i=1e9,n=-1;return(e.docChanged&&e.changes.iterChanges((t,r,s,o)=>{o>=e.view.viewport.from&&s<=e.view.viewport.to&&(i=Math.min(s,i),n=Math.max(o,n))}),e.viewportMoved||n-i>1e3)?this.createDeco(e.view):n>-1?this.updateRange(e.view,t.map(e.changes),i,n):t}updateRange(e,t,i,n){for(let r of e.visibleRanges){let s=Math.max(r.from,i),o=Math.min(r.to,n);if(o>=s){let i=e.state.doc.lineAt(s),n=i.to<o?e.state.doc.lineAt(o):i,l=Math.max(r.from,i.from),a=Math.min(r.to,n.to);if(this.boundary){for(;s>i.from;s--)if(this.boundary.test(i.text[s-1-i.from])){l=s;break}for(;o<n.to;o++)if(this.boundary.test(n.text[o-n.from])){a=o;break}}let h=[],c,d=(e,t,i)=>h.push(i.range(e,t));if(i==n)for(this.regexp.lastIndex=l-i.from;(c=this.regexp.exec(i.text))&&c.index<a-i.from;)this.addMatch(c,e,c.index+i.from,d);else al(e.state.doc,this.regexp,l,a,(t,i)=>this.addMatch(i,e,t,d));t=t.update({filterFrom:l,filterTo:a,filter:(e,t)=>e<l||t>a,add:h})}}return t}}let ah=null!=/x/.unicode?"gu":"g",ac=RegExp("[\0-\b\n-\x1f\x7f-\x9f\xad\u2028\u2029\uFEFF-]",ah),ad={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8294:"left-to-right isolate",8295:"right-to-left isolate",8297:"pop directional isolate",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"},au=null,af=nD.define({combine(e){let t=ri(e,{render:null,specialChars:ac,addSpecialChars:null});return(t.replaceTabs=!function(){var e;if(null==au&&"undefined"!=typeof document&&document.body){let t=document.body.style;au=(null!==(e=t.tabSize)&&void 0!==e?e:t.MozTabSize)!=null}return au||!1}())&&(t.specialChars=RegExp(" |"+t.specialChars.source,ah)),t.addSpecialChars&&(t.specialChars=RegExp(t.specialChars.source+"|"+t.addSpecialChars.source,ah)),t}}),ap=null;class am extends rX{constructor(e,t){super(),this.options=e,this.code=t}eq(e){return e.code==this.code}toDOM(e){var t;let i=(t=this.code)>=32?"•":10==t?"":String.fromCharCode(9216+t),n=e.state.phrase("Control character")+" "+(ad[this.code]||"0x"+this.code.toString(16)),r=this.options.render&&this.options.render(this.code,n,i);if(r)return r;let s=document.createElement("span");return s.textContent=i,s.title=n,s.setAttribute("aria-label",n),s.className="cm-specialChar",s}ignoreEvent(){return!1}}class ag extends rX{constructor(e){super(),this.width=e}eq(e){return e.width==this.width}toDOM(){let e=document.createElement("span");return e.textContent=" ",e.className="cm-tab",e.style.width=this.width+"px",e}ignoreEvent(){return!1}}let ax=rQ.line({class:"cm-activeLine"}),av=sG.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.docChanged||e.selectionSet)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=-1,i=[];for(let n of e.state.selection.ranges){let r=e.lineBlockAt(n.head);r.from>t&&(i.push(ax.range(r.from)),t=r.from)}return rQ.set(i)}},{decorations:e=>e.decorations});function ay(e,t){var i;let n,r=e.posAtCoords({x:t.clientX,y:t.clientY},!1),s=e.state.doc.lineAt(r),o=r-s.from,l=o>2e3?-1:o==s.length?(i=t.clientX,(n=e.coordsAtPos(e.viewport.from))?Math.round(Math.abs((n.left-i)/e.defaultCharacterWidth)):-1):rb(s.text,e.state.tabSize,r-s.from);return{line:s.number,col:l,off:o}}let ab="-10000px";class aw{constructor(e,t,i,n){this.facet=t,this.createTooltipView=i,this.removeTooltipView=n,this.input=e.state.facet(t),this.tooltips=this.input.filter(e=>e);let r=null;this.tooltipViews=this.tooltips.map(e=>r=i(e,r))}update(e,t){var i;let n=e.state.facet(this.facet),r=n.filter(e=>e);if(n===this.input){for(let t of this.tooltipViews)t.update&&t.update(e);return!1}let s=[],o=t?[]:null;for(let i=0;i<r.length;i++){let n=r[i],l=-1;if(n){for(let e=0;e<this.tooltips.length;e++){let t=this.tooltips[e];t&&t.create==n.create&&(l=e)}if(l<0)s[i]=this.createTooltipView(n,i?s[i-1]:null),o&&(o[i]=!!n.above);else{let n=s[i]=this.tooltipViews[l];o&&(o[i]=t[l]),n.update&&n.update(e)}}}for(let e of this.tooltipViews)0>s.indexOf(e)&&(this.removeTooltipView(e),null===(i=e.destroy)||void 0===i||i.call(e));return t&&(o.forEach((e,i)=>t[i]=e),t.length=o.length),this.input=n,this.tooltips=r,this.tooltipViews=s,!0}}function ak(e){let t=e.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:t.clientHeight,right:t.clientWidth}}let aS=nD.define({combine:e=>{var t,i,n;return{position:rK.ios?"absolute":(null===(t=e.find(e=>e.position))||void 0===t?void 0:t.position)||"fixed",parent:(null===(i=e.find(e=>e.parent))||void 0===i?void 0:i.parent)||null,tooltipSpace:(null===(n=e.find(e=>e.tooltipSpace))||void 0===n?void 0:n.tooltipSpace)||ak}}}),aC=new WeakMap,aj=sG.fromClass(class{constructor(e){this.view=e,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let t=e.state.facet(aS);this.position=t.position,this.parent=t.parent,this.classes=e.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver="function"==typeof ResizeObserver?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new aw(e,aT,(e,t)=>this.createTooltip(e,t),e=>{this.resizeObserver&&this.resizeObserver.unobserve(e.dom),e.dom.remove()}),this.above=this.manager.tooltips.map(e=>!!e.above),this.intersectionObserver="function"==typeof IntersectionObserver?new IntersectionObserver(e=>{Date.now()>this.lastTransaction-50&&e.length>0&&e[e.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),e.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver)for(let e of(this.intersectionObserver.disconnect(),this.manager.tooltipViews))this.intersectionObserver.observe(e.dom)}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(e){e.transactions.length&&(this.lastTransaction=Date.now());let t=this.manager.update(e,this.above);t&&this.observeIntersection();let i=t||e.geometryChanged,n=e.state.facet(aS);if(n.position!=this.position&&!this.madeAbsolute){for(let e of(this.position=n.position,this.manager.tooltipViews))e.dom.style.position=this.position;i=!0}if(n.parent!=this.parent){for(let e of(this.parent&&this.container.remove(),this.parent=n.parent,this.createContainer(),this.manager.tooltipViews))this.container.appendChild(e.dom);i=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);i&&this.maybeMeasure()}createTooltip(e,t){let i=e.create(this.view),n=t?t.dom:null;if(i.dom.classList.add("cm-tooltip"),e.arrow&&!i.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let e=document.createElement("div");e.className="cm-tooltip-arrow",i.dom.appendChild(e)}return i.dom.style.position=this.position,i.dom.style.top=ab,i.dom.style.left="0px",this.container.insertBefore(i.dom,n),i.mount&&i.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(i.dom),i}destroy(){var e,t,i;for(let t of(this.view.win.removeEventListener("resize",this.measureSoon),this.manager.tooltipViews))t.dom.remove(),null===(e=t.destroy)||void 0===e||e.call(t);this.parent&&this.container.remove(),null===(t=this.resizeObserver)||void 0===t||t.disconnect(),null===(i=this.intersectionObserver)||void 0===i||i.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let e=1,t=1,i=!1;if("fixed"==this.position&&this.manager.tooltipViews.length){let{dom:e}=this.manager.tooltipViews[0];if(rK.safari){let t=e.getBoundingClientRect();i=Math.abs(t.top+1e4)>1||Math.abs(t.left)>1}else i=!!e.offsetParent&&e.offsetParent!=this.container.ownerDocument.body}if(i||"absolute"==this.position){if(this.parent){let i=this.parent.getBoundingClientRect();i.width&&i.height&&(e=i.width/this.parent.offsetWidth,t=i.height/this.parent.offsetHeight)}else({scaleX:e,scaleY:t}=this.view.viewState)}let n=this.view.scrollDOM.getBoundingClientRect(),r=s3(this.view);return{visible:{left:n.left+r.left,top:n.top+r.top,right:n.right-r.right,bottom:n.bottom-r.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((e,t)=>{let i=this.manager.tooltipViews[t];return i.getCoords?i.getCoords(e.pos):this.view.coordsAtPos(e.pos)}),size:this.manager.tooltipViews.map(({dom:e})=>e.getBoundingClientRect()),space:this.view.state.facet(aS).tooltipSpace(this.view),scaleX:e,scaleY:t,makeAbsolute:i}}writeMeasure(e){var t;if(e.makeAbsolute)for(let e of(this.madeAbsolute=!0,this.position="absolute",this.manager.tooltipViews))e.dom.style.position="absolute";let{visible:i,space:n,scaleX:r,scaleY:s}=e,o=[];for(let l=0;l<this.manager.tooltips.length;l++){let a=this.manager.tooltips[l],h=this.manager.tooltipViews[l],{dom:c}=h,d=e.pos[l],u=e.size[l];if(!d||!1!==a.clip&&(d.bottom<=Math.max(i.top,n.top)||d.top>=Math.min(i.bottom,n.bottom)||d.right<Math.max(i.left,n.left)-.1||d.left>Math.min(i.right,n.right)+.1)){c.style.top=ab;continue}let f=a.arrow?h.dom.querySelector(".cm-tooltip-arrow"):null,p=f?7:0,m=u.right-u.left,g=null!==(t=aC.get(h))&&void 0!==t?t:u.bottom-u.top,x=h.offset||aA,v=this.view.textDirection==sg.LTR,y=u.width>n.right-n.left?v?n.left:n.right-u.width:v?Math.max(n.left,Math.min(d.left-(f?14:0)+x.x,n.right-m)):Math.min(Math.max(n.left,d.left-m+(f?14:0)-x.x),n.right-m),b=this.above[l];!a.strictSide&&(b?d.top-g-p-x.y<n.top:d.bottom+g+p+x.y>n.bottom)&&b==n.bottom-d.bottom>d.top-n.top&&(b=this.above[l]=!b);let w=(b?d.top-n.top:n.bottom-d.bottom)-p;if(w<g&&!1!==h.resize){if(w<this.view.defaultLineHeight){c.style.top=ab;continue}aC.set(h,g),c.style.height=(g=w)/s+"px"}else c.style.height&&(c.style.height="");let k=b?d.top-g-p-x.y:d.bottom+p+x.y,S=y+m;if(!0!==h.overlap)for(let e of o)e.left<S&&e.right>y&&e.top<k+g&&e.bottom>k&&(k=b?e.top-g-2-p:e.bottom+p+2);if("absolute"==this.position?(c.style.top=(k-e.parent.top)/s+"px",aM(c,(y-e.parent.left)/r)):(c.style.top=k/s+"px",aM(c,y/r)),f){let e=d.left+(v?x.x:-x.x)-(y+14-7);f.style.left=e/r+"px"}!0!==h.overlap&&o.push({left:y,top:k,right:S,bottom:k+g}),c.classList.toggle("cm-tooltip-above",b),c.classList.toggle("cm-tooltip-below",!b),h.positioned&&h.positioned(e.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let e of this.manager.tooltipViews)e.dom.style.top=ab}},{eventObservers:{scroll(){this.maybeMeasure()}}});function aM(e,t){let i=parseInt(e.style.left,10);(isNaN(i)||Math.abs(t-i)>1)&&(e.style.left=t+"px")}let aZ=l$.baseTheme({".cm-tooltip":{zIndex:500,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:"14px",position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),aA={x:0,y:0},aT=nD.define({enables:[aj,aZ]}),aO=nD.define({combine:e=>e.reduce((e,t)=>e.concat(t),[])});class aD{static create(e){return new aD(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new aw(e,aO,(e,t)=>this.createHostedView(e,t),e=>e.dom.remove())}createHostedView(e,t){let i=e.create(this.view);return i.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(i.dom,t?t.dom.nextSibling:this.dom.firstChild),this.mounted&&i.mount&&i.mount(this.view),i}mount(e){for(let t of this.manager.tooltipViews)t.mount&&t.mount(e);this.mounted=!0}positioned(e){for(let t of this.manager.tooltipViews)t.positioned&&t.positioned(e)}update(e){this.manager.update(e)}destroy(){var e;for(let t of this.manager.tooltipViews)null===(e=t.destroy)||void 0===e||e.call(t)}passProp(e){let t;for(let i of this.manager.tooltipViews){let n=i[e];if(void 0!==n){if(void 0===t)t=n;else if(t!==n)return}}return t}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}}let aR=nD.define({combine(e){let t,i;for(let n of e)t=t||n.topContainer,i=i||n.bottomContainer;return{topContainer:t,bottomContainer:i}}});function aP(e,t){let i=e.plugin(aL),n=i?i.specs.indexOf(t):-1;return n>-1?i.panels[n]:null}let aL=sG.fromClass(class{constructor(e){this.input=e.state.facet(aB),this.specs=this.input.filter(e=>e),this.panels=this.specs.map(t=>t(e));let t=e.state.facet(aR);for(let i of(this.top=new aI(e,!0,t.topContainer),this.bottom=new aI(e,!1,t.bottomContainer),this.top.sync(this.panels.filter(e=>e.top)),this.bottom.sync(this.panels.filter(e=>!e.top)),this.panels))i.dom.classList.add("cm-panel"),i.mount&&i.mount()}update(e){let t=e.state.facet(aR);this.top.container!=t.topContainer&&(this.top.sync([]),this.top=new aI(e.view,!0,t.topContainer)),this.bottom.container!=t.bottomContainer&&(this.bottom.sync([]),this.bottom=new aI(e.view,!1,t.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let i=e.state.facet(aB);if(i!=this.input){let t=i.filter(e=>e),n=[],r=[],s=[],o=[];for(let i of t){let t=this.specs.indexOf(i),l;t<0?(l=i(e.view),o.push(l)):(l=this.panels[t]).update&&l.update(e),n.push(l),(l.top?r:s).push(l)}for(let e of(this.specs=t,this.panels=n,this.top.sync(r),this.bottom.sync(s),o))e.dom.classList.add("cm-panel"),e.mount&&e.mount()}else for(let t of this.panels)t.update&&t.update(e)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:e=>l$.scrollMargins.of(t=>{let i=t.plugin(e);return i&&{top:i.top.scrollMargin(),bottom:i.bottom.scrollMargin()}})});class aI{constructor(e,t,i){this.view=e,this.top=t,this.container=i,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(e){for(let t of this.panels)t.destroy&&0>e.indexOf(t)&&t.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(0==this.panels.length){this.dom&&(this.dom.remove(),this.dom=void 0);return}if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom",this.dom.style[this.top?"top":"bottom"]="0";let e=this.container||this.view.dom;e.insertBefore(this.dom,this.top?e.firstChild:null)}let e=this.dom.firstChild;for(let t of this.panels)if(t.dom.parentNode==this.dom){for(;e!=t.dom;)e=aE(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=aE(e)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(this.container&&this.classes!=this.view.themeClasses){for(let e of this.classes.split(" "))e&&this.container.classList.remove(e);for(let e of(this.classes=this.view.themeClasses).split(" "))e&&this.container.classList.add(e)}}}function aE(e){let t=e.nextSibling;return e.remove(),t}let aB=nD.define({enables:aL}),aN=nB.define({create:()=>[],update(e,t){for(let i of t.effects)i.is(az)?e=[i.value].concat(e):i.is(aW)&&(e=e.filter(e=>e!=i.value));return e},provide:e=>aB.computeN([e],t=>t.field(e))}),az=n5.define(),aW=n5.define();class aF extends rn{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}aF.prototype.elementClass="",aF.prototype.toDOM=void 0,aF.prototype.mapMode=nv.TrackBefore,aF.prototype.startSide=aF.prototype.endSide=-1,aF.prototype.point=!0;let aV=nD.define(),aH=nD.define(),a$={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>ra.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{},side:"before"},aq=nD.define(),aK=nD.define({combine:e=>e.some(e=>e)});function aU(e){let t=[a_];return e&&!1===e.fixed&&t.push(aK.of(!0)),t}let a_=sG.fromClass(class{constructor(e){for(let t of(this.view=e,this.domAfter=null,this.prevViewport=e.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters cm-gutters-before",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=e.state.facet(aq).map(t=>new aY(e,t)),this.fixed=!e.state.facet(aK),this.gutters))"after"==t.config.side?this.getDOMAfter().appendChild(t.dom):this.dom.appendChild(t.dom);this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),e.scrollDOM.insertBefore(this.dom,e.contentDOM)}getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement("div"),this.domAfter.className="cm-gutters cm-gutters-after",this.domAfter.setAttribute("aria-hidden","true"),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.domAfter.style.position=this.fixed?"sticky":"",this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(e){if(this.updateGutters(e)){let t=this.prevViewport,i=e.view.viewport,n=Math.min(t.to,i.to)-Math.max(t.from,i.from);this.syncGutters(n<(i.to-i.from)*.8)}if(e.geometryChanged){let e=this.view.contentHeight/this.view.scaleY+"px";this.dom.style.minHeight=e,this.domAfter&&(this.domAfter.style.minHeight=e)}this.view.state.facet(aK)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=e.view.viewport}syncGutters(e){let t=this.dom.nextSibling;e&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let i=ra.iter(this.view.state.facet(aV),this.view.viewport.from),n=[],r=this.gutters.map(e=>new aX(e,this.view.viewport,-this.view.documentPadding.top));for(let e of this.view.viewportLineBlocks)if(n.length&&(n=[]),Array.isArray(e.type)){let t=!0;for(let s of e.type)if(s.type==rY.Text&&t){for(let e of(aJ(i,n,s.from),r))e.line(this.view,s,n);t=!1}else if(s.widget)for(let e of r)e.widget(this.view,s)}else if(e.type==rY.Text)for(let t of(aJ(i,n,e.from),r))t.line(this.view,e,n);else if(e.widget)for(let t of r)t.widget(this.view,e);for(let e of r)e.finish();e&&(this.view.scrollDOM.insertBefore(this.dom,t),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(e){let t=e.startState.facet(aq),i=e.state.facet(aq),n=e.docChanged||e.heightChanged||e.viewportChanged||!ra.eq(e.startState.facet(aV),e.state.facet(aV),e.view.viewport.from,e.view.viewport.to);if(t==i)for(let t of this.gutters)t.update(e)&&(n=!0);else{n=!0;let r=[];for(let n of i){let i=t.indexOf(n);i<0?r.push(new aY(this.view,n)):(this.gutters[i].update(e),r.push(this.gutters[i]))}for(let e of this.gutters)e.dom.remove(),0>r.indexOf(e)&&e.destroy();for(let e of r)"after"==e.config.side?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.gutters=r}return n}destroy(){for(let e of this.gutters)e.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:e=>l$.scrollMargins.of(t=>{let i=t.plugin(e);if(!i||0==i.gutters.length||!i.fixed)return null;let n=i.dom.offsetWidth*t.scaleX,r=i.domAfter?i.domAfter.offsetWidth*t.scaleX:0;return t.textDirection==sg.LTR?{left:n,right:r}:{right:n,left:r}})});function aG(e){return Array.isArray(e)?e:[e]}function aJ(e,t,i){for(;e.value&&e.from<=i;)e.from==i&&t.push(e.value),e.next()}class aX{constructor(e,t,i){this.gutter=e,this.height=i,this.i=0,this.cursor=ra.iter(e.markers,t.from)}addElement(e,t,i){let{gutter:n}=this,r=(t.top-this.height)/e.scaleY,s=t.height/e.scaleY;if(this.i==n.elements.length){let t=new aQ(e,s,r,i);n.elements.push(t),n.dom.appendChild(t.dom)}else n.elements[this.i].update(e,s,r,i);this.height=t.bottom,this.i++}line(e,t,i){let n=[];aJ(this.cursor,n,t.from),i.length&&(n=n.concat(i));let r=this.gutter.config.lineMarker(e,t,n);r&&n.unshift(r);let s=this.gutter;(0!=n.length||s.config.renderEmptyElements)&&this.addElement(e,t,n)}widget(e,t){let i=this.gutter.config.widgetMarker(e,t.widget,t),n=i?[i]:null;for(let i of e.state.facet(aH)){let r=i(e,t.widget,t);r&&(n||(n=[])).push(r)}n&&this.addElement(e,t,n)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}}class aY{constructor(e,t){for(let i in this.view=e,this.config=t,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:""),t.domEventHandlers)this.dom.addEventListener(i,n=>{let r=n.target,s;if(r!=this.dom&&this.dom.contains(r)){for(;r.parentNode!=this.dom;)r=r.parentNode;let e=r.getBoundingClientRect();s=(e.top+e.bottom)/2}else s=n.clientY;let o=e.lineBlockAtHeight(s-e.documentTop);t.domEventHandlers[i](e,o,n)&&n.preventDefault()});this.markers=aG(t.markers(e)),t.initialSpacer&&(this.spacer=new aQ(e,0,0,[t.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let t=this.markers;if(this.markers=aG(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let t=this.config.updateSpacer(this.spacer.markers[0],e);t!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[t])}let i=e.view.viewport;return!ra.eq(this.markers,t,i.from,i.to)||!!this.config.lineMarkerChange&&this.config.lineMarkerChange(e)}destroy(){for(let e of this.elements)e.destroy()}}class aQ{constructor(e,t,i,n){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,t,i,n)}update(e,t,i,n){this.height!=t&&(this.height=t,this.dom.style.height=t+"px"),this.above!=i&&(this.dom.style.marginTop=(this.above=i)?i+"px":""),!function(e,t){if(e.length!=t.length)return!1;for(let i=0;i<e.length;i++)if(!e[i].compare(t[i]))return!1;return!0}(this.markers,n)&&this.setMarkers(e,n)}setMarkers(e,t){let i="cm-gutterElement",n=this.dom.firstChild;for(let r=0,s=0;;){let o=s,l=r<t.length?t[r++]:null,a=!1;if(l){let e=l.elementClass;e&&(i+=" "+e);for(let e=s;e<this.markers.length;e++)if(this.markers[e].compare(l)){o=e,a=!0;break}}else o=this.markers.length;for(;s<o;){let e=this.markers[s++];if(e.toDOM){e.destroy(n);let t=n.nextSibling;n.remove(),n=t}}if(!l)break;l.toDOM&&(a?n=n.nextSibling:this.dom.insertBefore(l.toDOM(e),n)),a&&s++}this.dom.className=i,this.markers=t}destroy(){this.setMarkers(null,[])}}let a0=nD.define(),a1=nD.define(),a2=nD.define({combine:e=>ri(e,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(e,t){let i=Object.assign({},e);for(let e in t){let n=i[e],r=t[e];i[e]=n?(e,t,i)=>n(e,t,i)||r(e,t,i):r}return i}})});class a5 extends aF{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function a4(e,t){return e.state.facet(a2).formatNumber(t,e.state)}let a6=aq.compute([a2],e=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers:e=>e.state.facet(a0),lineMarker:(e,t,i)=>i.some(e=>e.toDOM)?null:new a5(a4(e,e.state.doc.lineAt(t.from).number)),widgetMarker:(e,t,i)=>{for(let n of e.state.facet(a1)){let r=n(e,t,i);if(r)return r}return null},lineMarkerChange:e=>e.startState.facet(a2)!=e.state.facet(a2),initialSpacer:e=>new a5(a4(e,a3(e.state.doc.lines))),updateSpacer(e,t){let i=a4(t.view,a3(t.view.state.doc.lines));return i==e.number?e:new a5(i)},domEventHandlers:e.facet(a2).domEventHandlers,side:"before"}));function a3(e){let t=9;for(;t<e;)t=10*t+9;return t}let a8=0;class a9{constructor(e,t){this.from=e,this.to=t}}class a7{constructor(e={}){this.id=a8++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw RangeError("Can't add per-node props to node types");return"function"!=typeof e&&(e=hi.match(e)),t=>{let i=e(t);return void 0===i?null:[this,i]}}}a7.closedBy=new a7({deserialize:e=>e.split(" ")}),a7.openedBy=new a7({deserialize:e=>e.split(" ")}),a7.group=new a7({deserialize:e=>e.split(" ")}),a7.isolate=new a7({deserialize:e=>{if(e&&"rtl"!=e&&"ltr"!=e&&"auto"!=e)throw RangeError("Invalid value for isolate: "+e);return e||"auto"}}),a7.contextHash=new a7({perNode:!0}),a7.lookAhead=new a7({perNode:!0}),a7.mounted=new a7({perNode:!0});class he{constructor(e,t,i,n=!1){this.tree=e,this.overlay=t,this.parser=i,this.bracketed=n}static get(e){return e&&e.props&&e.props[a7.mounted.id]}}let ht=Object.create(null);class hi{constructor(e,t,i,n=0){this.name=e,this.props=t,this.id=i,this.flags=n}static define(e){let t=e.props&&e.props.length?Object.create(null):ht,i=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(null==e.name?8:0),n=new hi(e.name||"",t,e.id,i);if(e.props){for(let i of e.props)if(Array.isArray(i)||(i=i(n)),i){if(i[0].perNode)throw RangeError("Can't store a per-node prop on a node type");t[i[0].id]=i[1]}}return n}prop(e){return this.props[e.id]}get isTop(){return(1&this.flags)>0}get isSkipped(){return(2&this.flags)>0}get isError(){return(4&this.flags)>0}get isAnonymous(){return(8&this.flags)>0}is(e){if("string"==typeof e){if(this.name==e)return!0;let t=this.prop(a7.group);return!!t&&t.indexOf(e)>-1}return this.id==e}static match(e){let t=Object.create(null);for(let i in e)for(let n of i.split(" "))t[n]=e[i];return e=>{for(let i=e.prop(a7.group),n=-1;n<(i?i.length:0);n++){let r=t[n<0?e.name:i[n]];if(r)return r}}}}hi.none=new hi("",Object.create(null),0,8);class hn{constructor(e){this.types=e;for(let t=0;t<e.length;t++)if(e[t].id!=t)throw RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...e){let t=[];for(let i of this.types){let n=null;for(let t of e){let e=t(i);if(e){n||(n=Object.assign({},i.props));let t=e[1],r=e[0];r.combine&&r.id in n&&(t=r.combine(n[r.id],t)),n[r.id]=t}}t.push(n?new hi(i.name,n,i.id,i.flags):i)}return new hn(t)}}let hr=new WeakMap,hs=new WeakMap;!function(e){e[e.ExcludeBuffers=1]="ExcludeBuffers",e[e.IncludeAnonymous=2]="IncludeAnonymous",e[e.IgnoreMounts=4]="IgnoreMounts",e[e.IgnoreOverlays=8]="IgnoreOverlays",e[e.EnterBracketed=16]="EnterBracketed"}(l||(l={}));class ho{constructor(e,t,i,n,r){if(this.type=e,this.children=t,this.positions=i,this.length=n,this.props=null,r&&r.length)for(let[e,t]of(this.props=Object.create(null),r))this.props["number"==typeof e?e:e.id]=t}toString(){let e=he.get(this);if(e&&!e.overlay)return e.tree.toString();let t="";for(let e of this.children){let i=e.toString();i&&(t&&(t+=","),t+=i)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?"("+t+")":""):t}cursor(e=0){return new hy(this.topNode,e)}cursorAt(e,t=0,i=0){let n=new hy(hr.get(this)||this.topNode);return n.moveTo(e,t),hr.set(this,n._tree),n}get topNode(){return new hu(this,0,0,null)}resolve(e,t=0){let i=hc(hr.get(this)||this.topNode,e,t,!1);return hr.set(this,i),i}resolveInner(e,t=0){let i=hc(hs.get(this)||this.topNode,e,t,!0);return hs.set(this,i),i}resolveStack(e,t=0){return function(e,t,i){let n=e.resolveInner(t,i),r=null;for(let e=n instanceof hu?n:n.context.parent;e;e=e.parent)if(e.index<0){let s=e.parent;(r||(r=[n])).push(s.resolve(t,i)),e=s}else{let s=he.get(e.tree);if(s&&s.overlay&&s.overlay[0].from<=t&&s.overlay[s.overlay.length-1].to>=t){let o=new hu(s.tree,s.overlay[0].from+e.from,-1,e);(r||(r=[n])).push(hc(o,t,i,!1))}}return r?hx(r):n}(this,e,t)}iterate(e){let{enter:t,leave:i,from:n=0,to:r=this.length}=e,s=e.mode||0,o=(s&l.IncludeAnonymous)>0;for(let e=this.cursor(s|l.IncludeAnonymous);;){let s=!1;if(e.from<=r&&e.to>=n&&(!o&&e.type.isAnonymous||!1!==t(e))){if(e.firstChild())continue;s=!0}for(;s&&i&&(o||!e.type.isAnonymous)&&i(e),!e.nextSibling();){if(!e.parent())return;s=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(e={}){return this.children.length<=8?this:hS(hi.none,this.children,this.positions,0,this.children.length,0,this.length,(e,t,i)=>new ho(this.type,e,t,i,this.propValues),e.makeTree||((e,t,i)=>new ho(hi.none,e,t,i)))}static build(e){return function(e){var t;let{buffer:i,nodeSet:n,maxBufferLength:r=1024,reused:s=[],minRepeatType:o=n.types.length}=e,l=Array.isArray(i)?new hl(i,i.length):i,a=n.types,h=0,c=0;function d(e,t,i,r,s,o,l,a,h){let c=[],d=[];for(;e.length>r;)c.push(e.pop()),d.push(t.pop()+i-s);e.push(u(n.types[l],c,d,o-s,a-o,h)),t.push(s-i)}function u(e,t,i,n,r,s,o){if(s){let e=[a7.contextHash,s];o=o?[e].concat(o):[e]}if(r>25){let e=[a7.lookAhead,r];o=o?[e].concat(o):[e]}return new ho(e,t,i,n,o)}let f=[],p=[];for(;l.pos>0;)!function e(t,i,f,p,m,g){let{id:x,start:v,end:y,size:b}=l,w=c,k=h;if(b<0){if(l.next(),-1==b){let e=s[x];f.push(e),p.push(v-t);return}if(-3==b){h=x;return}if(-4==b){c=x;return}throw RangeError(`Unrecognized record size: ${b}`)}let S=a[x],C,j,M=v-t;if(y-v<=r&&(j=function(e,t){let i=l.fork(),n=0,s=0,a=0,h=i.end-r,c={size:0,start:0,skip:0};n:for(let r=i.pos-e;i.pos>r;){let e=i.size;if(i.id==t&&e>=0){c.size=n,c.start=s,c.skip=a,a+=4,n+=4,i.next();continue}let l=i.pos-e;if(e<0||l<r||i.start<h)break;let d=i.id>=o?4:0,u=i.start;for(i.next();i.pos>l;){if(i.size<0){if(-3==i.size||-4==i.size)d+=4;else break n}else i.id>=o&&(d+=4);i.next()}s=u,n+=e,a+=d}return(t<0||n==e)&&(c.size=n,c.start=s,c.skip=a),c.size>4?c:void 0}(l.pos-i,m))){let e=new Uint16Array(j.size-j.skip),i=l.pos-j.size,r=e.length;for(;l.pos>i;)r=function e(t,i,n){let{id:r,start:s,end:a,size:d}=l;if(l.next(),d>=0&&r<o){let o=n;if(d>4){let r=l.pos-(d-4);for(;l.pos>r;)n=e(t,i,n)}i[--n]=o,i[--n]=a-t,i[--n]=s-t,i[--n]=r}else -3==d?h=r:-4==d&&(c=r);return n}(j.start,e,r);C=new ha(e,y-j.start,n),M=j.start-t}else{let t=l.pos-b;l.next();let i=[],s=[],a=x>=o?x:-1,h=0,c=y;for(;l.pos>t;)a>=0&&l.id==a&&l.size>=0?(l.end<=c-r&&(d(i,s,v,h,l.end,c,a,w,k),h=i.length,c=l.end),l.next()):g>2500?function(e,t,i,s){let o=[],a=0,h=-1;for(;l.pos>t;){let{id:e,start:t,end:i,size:n}=l;if(n>4)l.next();else if(h>-1&&t<h)break;else h<0&&(h=i-r),o.push(e,t,i),a++,l.next()}if(a){let t=new Uint16Array(4*a),r=o[o.length-2];for(let e=o.length-3,i=0;e>=0;e-=3)t[i++]=o[e],t[i++]=o[e+1]-r,t[i++]=o[e+2]-r,t[i++]=i;i.push(new ha(t,o[2]-r,n)),s.push(r-e)}}(v,t,i,s):e(v,t,i,s,a,g+1);if(a>=0&&h>0&&h<i.length&&d(i,s,v,h,v,c,a,w,k),i.reverse(),s.reverse(),a>-1&&h>0){let e=function(e,t){return(i,n,r)=>{let s=0,o=i.length-1,l,a;if(o>=0&&(l=i[o])instanceof ho){if(!o&&l.type==e&&l.length==r)return l;(a=l.prop(a7.lookAhead))&&(s=n[o]+l.length+a)}return u(e,i,n,r,s,t)}}(S,k);C=hS(S,i,s,0,i.length,0,y-v,e,e)}else C=u(S,i,s,y-v,w-y,k)}f.push(C),p.push(M)}(e.start||0,e.bufferStart||0,f,p,-1,0);let m=null!==(t=e.length)&&void 0!==t?t:f.length?p[0]+f[0].length:0;return new ho(a[e.topID],f.reverse(),p.reverse(),m)}(e)}}ho.empty=new ho(hi.none,[],[],0);class hl{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new hl(this.buffer,this.index)}}class ha{constructor(e,t,i){this.buffer=e,this.length=t,this.set=i}get type(){return hi.none}toString(){let e=[];for(let t=0;t<this.buffer.length;)e.push(this.childString(t)),t=this.buffer[t+3];return e.join(",")}childString(e){let t=this.buffer[e],i=this.buffer[e+3],n=this.set.types[t],r=n.name;if(/\W/.test(r)&&!n.isError&&(r=JSON.stringify(r)),i==(e+=4))return r;let s=[];for(;e<i;)s.push(this.childString(e)),e=this.buffer[e+3];return r+"("+s.join(",")+")"}findChild(e,t,i,n,r){let{buffer:s}=this,o=-1;for(let l=e;l!=t&&(!hh(r,n,s[l+1],s[l+2])||(o=l,!(i>0)));l=s[l+3]);return o}slice(e,t,i){let n=this.buffer,r=new Uint16Array(t-e),s=0;for(let o=e,l=0;o<t;){r[l++]=n[o++],r[l++]=n[o++]-i;let t=r[l++]=n[o++]-i;r[l++]=n[o++]-e,s=Math.max(s,t)}return new ha(r,s,this.set)}}function hh(e,t,i,n){switch(e){case -2:return i<t;case -1:return n>=t&&i<t;case 0:return i<t&&n>t;case 1:return i<=t&&n>t;case 2:return n>t;case 4:return!0}}function hc(e,t,i,n){for(var r;e.from==e.to||(i<1?e.from>=t:e.from>t)||(i>-1?e.to<=t:e.to<t);){let t=!n&&e instanceof hu&&e.index<0?null:e.parent;if(!t)return e;e=t}let s=n?0:l.IgnoreOverlays;if(n)for(let n=e,o=n.parent;o;o=(n=o).parent)n instanceof hu&&n.index<0&&(null===(r=o.enter(t,i,s))||void 0===r?void 0:r.from)!=n.from&&(e=o);for(;;){let n=e.enter(t,i,s);if(!n)return e;e=n}}class hd{cursor(e=0){return new hy(this,e)}getChild(e,t=null,i=null){let n=hf(this,e,t,i);return n.length?n[0]:null}getChildren(e,t=null,i=null){return hf(this,e,t,i)}resolve(e,t=0){return hc(this,e,t,!1)}resolveInner(e,t=0){return hc(this,e,t,!0)}matchContext(e){return hp(this.parent,e)}enterUnfinishedNodesBefore(e){let t=this.childBefore(e),i=this;for(;t;){let e=t.lastChild;if(!e||e.to!=t.to)break;e.type.isError&&e.from==e.to?(i=t,t=e.prevSibling):t=e}return i}get node(){return this}get next(){return this.parent}}class hu extends hd{constructor(e,t,i,n){super(),this._tree=e,this.from=t,this.index=i,this._parent=n}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,t,i,n,r=0){for(let s=this;;){for(let{children:o,positions:a}=s._tree,h=t>0?o.length:-1;e!=h;e+=t){let h=o[e],c=a[e]+s.from,d;if(r&l.EnterBracketed&&h instanceof ho&&(d=he.get(h))&&!d.overlay&&d.bracketed&&i>=c&&i<=c+h.length||hh(n,i,c,c+h.length)){if(h instanceof ha){if(r&l.ExcludeBuffers)continue;let o=h.findChild(0,h.buffer.length,t,i-c,n);if(o>-1)return new hg(new hm(s,h,e,c),null,o)}else if(r&l.IncludeAnonymous||!h.type.isAnonymous||hb(h)){let o;if(!(r&l.IgnoreMounts)&&(o=he.get(h))&&!o.overlay)return new hu(o.tree,c,e,s);let a=new hu(h,c,e,s);return r&l.IncludeAnonymous||!a.type.isAnonymous?a:a.nextChild(t<0?h.children.length-1:0,t,i,n,r)}}}if(r&l.IncludeAnonymous||!s.type.isAnonymous||(e=s.index>=0?s.index+t:t<0?-1:s._parent._tree.children.length,!(s=s._parent)))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}prop(e){return this._tree.prop(e)}enter(e,t,i=0){let n;if(!(i&l.IgnoreOverlays)&&(n=he.get(this._tree))&&n.overlay){let r=e-this.from,s=i&l.EnterBracketed&&n.bracketed;for(let{from:e,to:i}of n.overlay)if((t>0||s?e<=r:e<r)&&(t<0||s?i>=r:i>r))return new hu(n.tree,n.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,i)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function hf(e,t,i,n){let r=e.cursor(),s=[];if(!r.firstChild())return s;if(null!=i){for(let e=!1;!e;)if(e=r.type.is(i),!r.nextSibling())return s}for(;;){if(null!=n&&r.type.is(n))return s;if(r.type.is(t)&&s.push(r.node),!r.nextSibling())return null==n?s:[]}}function hp(e,t,i=t.length-1){for(let n=e;i>=0;n=n.parent){if(!n)return!1;if(!n.type.isAnonymous){if(t[i]&&t[i]!=n.name)return!1;i--}}return!0}class hm{constructor(e,t,i,n){this.parent=e,this.buffer=t,this.index=i,this.start=n}}class hg extends hd{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,i){super(),this.context=e,this._parent=t,this.index=i,this.type=e.buffer.set.types[e.buffer.buffer[i]]}child(e,t,i){let{buffer:n}=this.context,r=n.findChild(this.index+4,n.buffer[this.index+3],e,t-this.context.start,i);return r<0?null:new hg(this.context,this,r)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}prop(e){return this.type.prop(e)}enter(e,t,i=0){if(i&l.ExcludeBuffers)return null;let{buffer:n}=this.context,r=n.findChild(this.index+4,n.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return r<0?null:new hg(this.context,this,r)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new hg(this.context,this._parent,t):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,t=this._parent?this._parent.index+4:0;return this.index==t?this.externalSibling(-1):new hg(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:i}=this.context,n=this.index+4,r=i.buffer[this.index+3];if(r>n){let s=i.buffer[this.index+1];e.push(i.slice(n,r,s)),t.push(0)}return new ho(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function hx(e){if(!e.length)return null;let t=0,i=e[0];for(let n=1;n<e.length;n++){let r=e[n];(r.from>i.from||r.to<i.to)&&(i=r,t=n)}let n=i instanceof hu&&i.index<0?null:i.parent,r=e.slice();return n?r[t]=n:r.splice(t,1),new hv(r,i)}class hv{constructor(e,t){this.heads=e,this.node=t}get next(){return hx(this.heads)}}class hy{get name(){return this.type.name}constructor(e,t=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=t&~l.EnterBracketed,e instanceof hu)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let t=e._parent;t;t=t._parent)this.stack.unshift(t.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return!!e&&(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0)}yieldBuf(e,t){this.index=e;let{start:i,buffer:n}=this.buffer;return this.type=t||n.set.types[n.buffer[e]],this.from=i+n.buffer[e+1],this.to=i+n.buffer[e+2],!0}yield(e){return!!e&&(e instanceof hu?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)))}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,i){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,i,this.mode));let{buffer:n}=this.buffer,r=n.findChild(this.index+4,n.buffer[this.index+3],e,t-this.buffer.start,i);return!(r<0)&&(this.stack.push(this.index),this.yieldBuf(r))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,i=this.mode){return this.buffer?!(i&l.ExcludeBuffers)&&this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&l.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&l.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return!!this._tree._parent&&this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode));let{buffer:t}=this.buffer,i=this.stack.length-1;if(e<0){let e=i<0?0:this.stack[i]+4;if(this.index!=e)return this.yieldBuf(t.findChild(e,this.index,-1,0,4))}else{let e=t.buffer[this.index+3];if(e<(i<0?t.buffer.length:t.buffer[this.stack[i]+3]))return this.yieldBuf(e)}return i<0&&this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode))}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,i,{buffer:n}=this;if(n){if(e>0){if(this.index<n.buffer.buffer.length)return!1}else for(let e=0;e<this.index;e++)if(n.buffer.buffer[e+3]<this.index)return!1;({index:t,parent:i}=n)}else({index:t,_parent:i}=this._tree);for(;i;{index:t,_parent:i}=i)if(t>-1)for(let n=t+e,r=e<0?-1:i._tree.children.length;n!=r;n+=e){let e=i._tree.children[n];if(this.mode&l.IncludeAnonymous||e instanceof ha||!e.type.isAnonymous||hb(e))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,t););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,t=null,i=0;if(e&&e.context==this.buffer)n:for(let n=this.index,r=this.stack.length;r>=0;){for(let s=e;s;s=s._parent)if(s.index==n){if(n==this.index)return s;t=s,i=r+1;break n}n=this.stack[--r]}for(let e=i;e<this.stack.length;e++)t=new hg(this.buffer,t,this.stack[e]);return this.bufferNode=new hg(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let i=0;;){let n=!1;if(this.type.isAnonymous||!1!==e(this)){if(this.firstChild()){i++;continue}this.type.isAnonymous||(n=!0)}for(;;){if(n&&t&&t(this),n=this.type.isAnonymous,!i)return;if(this.nextSibling())break;this.parent(),i--,n=!0}}}matchContext(e){if(!this.buffer)return hp(this.node.parent,e);let{buffer:t}=this.buffer,{types:i}=t.set;for(let n=e.length-1,r=this.stack.length-1;n>=0;r--){if(r<0)return hp(this._tree,e,n);let s=i[t.buffer[this.stack[r]]];if(!s.isAnonymous){if(e[n]&&e[n]!=s.name)return!1;n--}}return!0}}function hb(e){return e.children.some(e=>e instanceof ha||!e.type.isAnonymous||hb(e))}let hw=new WeakMap;function hk(e,t){if(!e.isAnonymous||t instanceof ha||t.type!=e)return 1;let i=hw.get(t);if(null==i){for(let n of(i=1,t.children)){if(n.type!=e||!(n instanceof ho)){i=1;break}i+=hk(e,n)}hw.set(t,i)}return i}function hS(e,t,i,n,r,s,o,l,a){let h=0;for(let i=n;i<r;i++)h+=hk(e,t[i]);let c=Math.ceil(1.5*h/8),d=[],u=[];return function t(i,n,r,o,l){for(let h=r;h<o;){let r=h,f=n[h],p=hk(e,i[h]);for(h++;h<o;h++){let t=hk(e,i[h]);if(p+t>=c)break;p+=t}if(h==r+1){if(p>c){let e=i[r];t(e.children,e.positions,0,e.children.length,n[r]+l);continue}d.push(i[r])}else{let t=n[h-1]+i[h-1].length-f;d.push(hS(e,i,n,r,h,f,t,null,a))}u.push(f+l-s)}}(t,i,n,r,0),(l||a)(d,u,o)}class hC{constructor(e,t,i,n,r=!1,s=!1){this.from=e,this.to=t,this.tree=i,this.offset=n,this.open=(r?1:0)|(s?2:0)}get openStart(){return(1&this.open)>0}get openEnd(){return(2&this.open)>0}static addTree(e,t=[],i=!1){let n=[new hC(0,e.length,e,0,!1,i)];for(let i of t)i.to>e.length&&n.push(i);return n}static applyChanges(e,t,i=128){if(!t.length)return e;let n=[],r=1,s=e.length?e[0]:null;for(let o=0,l=0,a=0;;o++){let h=o<t.length?t[o]:null,c=h?h.fromA:1e9;if(c-l>=i)for(;s&&s.from<c;){let t=s;if(l>=t.from||c<=t.to||a){let e=Math.max(t.from,l)-a,i=Math.min(t.to,c)-a;t=e>=i?null:new hC(e,i,t.tree,t.offset+a,o>0,!!h)}if(t&&n.push(t),s.to>c)break;s=r<e.length?e[r++]:null}if(!h)break;l=h.toA,a=h.toA-h.toB}return n}}class hj{startParse(e,t,i){return"string"==typeof e&&(e=new hM(e)),i=i?i.length?i.map(e=>new a9(e.from,e.to)):[new a9(0,0)]:[new a9(0,e.length)],this.createParse(e,t||[],i)}parse(e,t,i){let n=this.startParse(e,t,i);for(;;){let e=n.advance();if(e)return e}}}class hM{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}}let hZ=new a7({perNode:!0});class hA{constructor(e,t){this.offset=t,this.done=!1,this.cursor=e.cursor(l.IncludeAnonymous|l.IgnoreMounts)}moveTo(e){let{cursor:t}=this,i=e-this.offset;for(;!this.done&&t.from<i;)t.to>=e&&t.enter(i,1,l.IgnoreOverlays|l.ExcludeBuffers)||t.next(!1)||(this.done=!0)}hasNode(e){if(this.moveTo(e.from),!this.done&&this.cursor.from+this.offset==e.from&&this.cursor.tree)for(let t=this.cursor.tree;;){if(t==e.tree)return!0;if(t.children.length&&0==t.positions[0]&&t.children[0]instanceof ho)t=t.children[0];else break}return!1}}let hT=0;class hO{constructor(e,t,i,n){this.name=e,this.set=t,this.base=i,this.modified=n,this.id=hT++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(e,t){if(e instanceof hO&&(t=e),null==t?void 0:t.base)throw Error("Can not derive from a modified tag");let i=new hO("string"==typeof e?e:"?",[],null,[]);if(i.set.push(i),t)for(let e of t.set)i.set.push(e);return i}static defineModifier(e){let t=new hR(e);return e=>e.modified.indexOf(t)>-1?e:hR.get(e.base||e,e.modified.concat(t).sort((e,t)=>e.id-t.id))}}let hD=0;class hR{constructor(e){this.name=e,this.instances=[],this.id=hD++}static get(e,t){if(!t.length)return e;let i=t[0].instances.find(i=>{var n;return i.base==e&&(n=i.modified,t.length==n.length&&t.every((e,t)=>e==n[t]))});if(i)return i;let n=[],r=new hO(e.name,n,e,t);for(let e of t)e.instances.push(r);let s=function(e){let t=[[]];for(let i=0;i<e.length;i++)for(let n=0,r=t.length;n<r;n++)t.push(t[n].concat(e[i]));return t.sort((e,t)=>t.length-e.length)}(t);for(let t of e.set)if(!t.modified.length)for(let e of s)n.push(hR.get(t,e));return r}}let hP=new a7({combine(e,t){let i,n,r;for(;e||t;){if(!e||t&&e.depth>=t.depth?(r=t,t=t.next):(r=e,e=e.next),i&&i.mode==r.mode&&!r.context&&!i.context)continue;let s=new hL(r.tags,r.mode,r.context);i?i.next=s:n=s,i=s}return n}});class hL{constructor(e,t,i,n){this.tags=e,this.mode=t,this.context=i,this.next=n}get opaque(){return 0==this.mode}get inherit(){return 1==this.mode}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}}function hI(e,t){let i=Object.create(null);for(let t of e)if(Array.isArray(t.tag))for(let e of t.tag)i[e.id]=t.class;else i[t.tag.id]=t.class;let{scope:n,all:r=null}=t||{};return{style:e=>{let t=r;for(let n of e)for(let e of n.set){let n=i[e.id];if(n){t=t?t+" "+n:n;break}}return t},scope:n}}hL.empty=new hL([],2,null);class hE{constructor(e,t,i){this.at=e,this.highlighters=t,this.span=i,this.class=""}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,i,n,r){let{type:s,from:o,to:l}=e;if(o>=i||l<=t)return;s.isTop&&(r=this.highlighters.filter(e=>!e.scope||e.scope(s)));let a=n,h=function(e){let t=e.type.prop(hP);for(;t&&t.context&&!e.matchContext(t.context);)t=t.next;return t||null}(e)||hL.empty,c=function(e,t){let i=null;for(let n of e){let e=n.style(t);e&&(i=i?i+" "+e:e)}return i}(r,h.tags);if(c&&(a&&(a+=" "),a+=c,1==h.mode&&(n+=(n?" ":"")+c)),this.startSpan(Math.max(t,o),a),h.opaque)return;let d=e.tree&&e.tree.prop(a7.mounted);if(d&&d.overlay){let s=e.node.enter(d.overlay[0].from+o,1),h=this.highlighters.filter(e=>!e.scope||e.scope(d.tree.type)),c=e.firstChild();for(let u=0,f=o;;u++){let p=u<d.overlay.length?d.overlay[u]:null,m=p?p.from+o:l,g=Math.max(t,f),x=Math.min(i,m);if(g<x&&c)for(;e.from<x&&(this.highlightRange(e,g,x,n,r),this.startSpan(Math.min(x,e.to),a),!(e.to>=m)&&e.nextSibling()););if(!p||m>i)break;(f=p.to+o)>t&&(this.highlightRange(s.cursor(),Math.max(t,p.from+o),Math.min(i,f),"",h),this.startSpan(Math.min(i,f),a))}c&&e.parent()}else if(e.firstChild()){d&&(n="");do{if(e.to<=t)continue;if(e.from>=i)break;this.highlightRange(e,t,i,n,r),this.startSpan(Math.min(i,e.to),a)}while(e.nextSibling());e.parent()}}}let hB=hO.define,hN=hB(),hz=hB(),hW=hB(hz),hF=hB(hz),hV=hB(),hH=hB(hV),h$=hB(hV),hq=hB(),hK=hB(hq),hU=hB(),h_=hB(),hG=hB(),hJ=hB(hG),hX=hB(),hY={comment:hN,lineComment:hB(hN),blockComment:hB(hN),docComment:hB(hN),name:hz,variableName:hB(hz),typeName:hW,tagName:hB(hW),propertyName:hF,attributeName:hB(hF),className:hB(hz),labelName:hB(hz),namespace:hB(hz),macroName:hB(hz),literal:hV,string:hH,docString:hB(hH),character:hB(hH),attributeValue:hB(hH),number:h$,integer:hB(h$),float:hB(h$),bool:hB(hV),regexp:hB(hV),escape:hB(hV),color:hB(hV),url:hB(hV),keyword:hU,self:hB(hU),null:hB(hU),atom:hB(hU),unit:hB(hU),modifier:hB(hU),operatorKeyword:hB(hU),controlKeyword:hB(hU),definitionKeyword:hB(hU),moduleKeyword:hB(hU),operator:h_,derefOperator:hB(h_),arithmeticOperator:hB(h_),logicOperator:hB(h_),bitwiseOperator:hB(h_),compareOperator:hB(h_),updateOperator:hB(h_),definitionOperator:hB(h_),typeOperator:hB(h_),controlOperator:hB(h_),punctuation:hG,separator:hB(hG),bracket:hJ,angleBracket:hB(hJ),squareBracket:hB(hJ),paren:hB(hJ),brace:hB(hJ),content:hq,heading:hK,heading1:hB(hK),heading2:hB(hK),heading3:hB(hK),heading4:hB(hK),heading5:hB(hK),heading6:hB(hK),contentSeparator:hB(hq),list:hB(hq),quote:hB(hq),emphasis:hB(hq),strong:hB(hq),link:hB(hq),monospace:hB(hq),strikethrough:hB(hq),inserted:hB(),deleted:hB(),changed:hB(),invalid:hB(),meta:hX,documentMeta:hB(hX),annotation:hB(hX),processingInstruction:hB(hX),definition:hO.defineModifier("definition"),constant:hO.defineModifier("constant"),function:hO.defineModifier("function"),standard:hO.defineModifier("standard"),local:hO.defineModifier("local"),special:hO.defineModifier("special")};for(let e in hY){let t=hY[e];t instanceof hO&&(t.name=e)}hI([{tag:hY.link,class:"tok-link"},{tag:hY.heading,class:"tok-heading"},{tag:hY.emphasis,class:"tok-emphasis"},{tag:hY.strong,class:"tok-strong"},{tag:hY.keyword,class:"tok-keyword"},{tag:hY.atom,class:"tok-atom"},{tag:hY.bool,class:"tok-bool"},{tag:hY.url,class:"tok-url"},{tag:hY.labelName,class:"tok-labelName"},{tag:hY.inserted,class:"tok-inserted"},{tag:hY.deleted,class:"tok-deleted"},{tag:hY.literal,class:"tok-literal"},{tag:hY.string,class:"tok-string"},{tag:hY.number,class:"tok-number"},{tag:[hY.regexp,hY.escape,hY.special(hY.string)],class:"tok-string2"},{tag:hY.variableName,class:"tok-variableName"},{tag:hY.local(hY.variableName),class:"tok-variableName tok-local"},{tag:hY.definition(hY.variableName),class:"tok-variableName tok-definition"},{tag:hY.special(hY.variableName),class:"tok-variableName2"},{tag:hY.definition(hY.propertyName),class:"tok-propertyName tok-definition"},{tag:hY.typeName,class:"tok-typeName"},{tag:hY.namespace,class:"tok-namespace"},{tag:hY.className,class:"tok-className"},{tag:hY.macroName,class:"tok-macroName"},{tag:hY.propertyName,class:"tok-propertyName"},{tag:hY.operator,class:"tok-operator"},{tag:hY.comment,class:"tok-comment"},{tag:hY.meta,class:"tok-meta"},{tag:hY.invalid,class:"tok-invalid"},{tag:hY.punctuation,class:"tok-punctuation"}]);let hQ=new a7,h0=new a7;class h1{constructor(e,t,i=[],n=""){this.data=e,this.name=n,rt.prototype.hasOwnProperty("tree")||Object.defineProperty(rt.prototype,"tree",{get(){return h5(this)}}),this.parser=t,this.extension=[ci.of(this),rt.languageData.of((e,t,i)=>{let n=h2(e,t,i),r=n.type.prop(hQ);if(!r)return[];let s=e.facet(r),o=n.type.prop(h0);if(o){let r=n.resolve(t-n.from,i);for(let t of o)if(t.test(r,e)){let i=e.facet(t.facet);return"replace"==t.type?i:i.concat(s)}}return s})].concat(i)}isActiveAt(e,t,i=-1){return h2(e,t,i).type.prop(hQ)==this.data}findRegions(e){let t=e.facet(ci);if((null==t?void 0:t.data)==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let i=[],n=(e,t)=>{if(e.prop(hQ)==this.data){i.push({from:t,to:t+e.length});return}let r=e.prop(a7.mounted);if(r){if(r.tree.prop(hQ)==this.data){if(r.overlay)for(let e of r.overlay)i.push({from:e.from+t,to:e.to+t});else i.push({from:t,to:t+e.length});return}if(r.overlay){let e=i.length;if(n(r.tree,r.overlay[0].from+t),i.length>e)return}}for(let i=0;i<e.children.length;i++){let r=e.children[i];r instanceof ho&&n(r,e.positions[i]+t)}};return n(h5(e),0),i}get allowsNesting(){return!0}}function h2(e,t,i){let n=e.facet(ci),r=h5(e).topNode;if(!n||n.allowsNesting)for(let e=r;e;e=e.enter(t,i,l.ExcludeBuffers|l.EnterBracketed))e.type.isTop&&(r=e);return r}function h5(e){let t=e.field(h1.state,!1);return t?t.tree:ho.empty}h1.setState=n5.define();class h4{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let i=this.cursorPos-this.string.length;return e<i||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-i,t-i)}}let h6=null;class h3{constructor(e,t,i=[],n,r,s,o,l){this.parser=e,this.state=t,this.fragments=i,this.tree=n,this.treeLen=r,this.viewport=s,this.skipped=o,this.scheduleOn=l,this.parse=null,this.tempSkipped=[]}static create(e,t,i){return new h3(e,t,[],ho.empty,0,i,[],null)}startParse(){return this.parser.startParse(new h4(this.state.doc),this.fragments)}work(e,t){return(null!=t&&t>=this.state.doc.length&&(t=void 0),this.tree!=ho.empty&&this.isDone(null!=t?t:this.state.doc.length))?(this.takeTree(),!0):this.withContext(()=>{var i;if("number"==typeof e){let t=Date.now()+e;e=()=>Date.now()>t}for(this.parse||(this.parse=this.startParse()),null!=t&&(null==this.parse.stoppedAt||this.parse.stoppedAt>t)&&t<this.state.doc.length&&this.parse.stopAt(t);;){let n=this.parse.advance();if(n){if(this.fragments=this.withoutTempSkipped(hC.addTree(n,this.fragments,null!=this.parse.stoppedAt)),this.treeLen=null!==(i=this.parse.stoppedAt)&&void 0!==i?i:this.state.doc.length,this.tree=n,this.parse=null,!(this.treeLen<(null!=t?t:this.state.doc.length)))return!0;this.parse=this.startParse()}if(e())return!1}})}takeTree(){let e,t;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((null==this.parse.stoppedAt||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(hC.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=h6;h6=this;try{return e()}finally{h6=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=h8(e,t.from,t.to);return e}changes(e,t){let{fragments:i,tree:n,treeLen:r,viewport:s,skipped:o}=this;if(this.takeTree(),!e.empty){let t=[];if(e.iterChangedRanges((e,i,n,r)=>t.push({fromA:e,toA:i,fromB:n,toB:r})),i=hC.applyChanges(i,t),n=ho.empty,r=0,s={from:e.mapPos(s.from,-1),to:e.mapPos(s.to,1)},this.skipped.length)for(let t of(o=[],this.skipped)){let i=e.mapPos(t.from,1),n=e.mapPos(t.to,-1);i<n&&o.push({from:i,to:n})}}return new h3(this.parser,t,i,n,r,s,o,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let t=this.skipped.length;for(let t=0;t<this.skipped.length;t++){let{from:i,to:n}=this.skipped[t];i<e.to&&n>e.from&&(this.fragments=h8(this.fragments,i,n),this.skipped.splice(t--,1))}return!(this.skipped.length>=t)&&(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends hj{createParse(t,i,n){let r=n[0].from,s=n[n.length-1].to;return{parsedPos:r,advance(){let t=h6;if(t){for(let e of n)t.tempSkipped.push(e);e&&(t.scheduleOn=t.scheduleOn?Promise.all([t.scheduleOn,e]):e)}return this.parsedPos=s,new ho(hi.none,[],[],s-r)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&0==t[0].from&&t[0].to>=e}static get(){return h6}}function h8(e,t,i){return hC.applyChanges(e,[{fromA:t,toA:i,fromB:t,toB:i}])}class h9{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let t=this.context.changes(e.changes,e.state),i=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,i)||t.takeTree(),new h9(t)}static init(e){let t=Math.min(3e3,e.doc.length),i=h3.create(e.facet(ci).parser,e,{from:0,to:t});return i.work(20,t)||i.takeTree(),new h9(i)}}h1.state=nB.define({create:h9.init,update(e,t){for(let e of t.effects)if(e.is(h1.setState))return e.value;return t.startState.facet(ci)!=t.state.facet(ci)?h9.init(t.state):e.apply(t)}});let h7=e=>{let t=setTimeout(()=>e(),500);return()=>clearTimeout(t)};"undefined"!=typeof requestIdleCallback&&(h7=e=>{let t=-1,i=setTimeout(()=>{t=requestIdleCallback(e,{timeout:400})},100);return()=>t<0?clearTimeout(i):cancelIdleCallback(t)});let ce="undefined"!=typeof navigator&&(null===(a=navigator.scheduling)||void 0===a?void 0:a.isInputPending)?()=>navigator.scheduling.isInputPending():null,ct=sG.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(h1.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(h1.state);t.tree==t.context.tree&&t.context.isDone(e.doc.length)||(this.working=h7(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnd<t&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=t+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:i,viewport:{to:n}}=this.view,r=i.field(h1.state);if(r.tree==r.context.tree&&r.context.isDone(n+1e5))return;let s=Date.now()+Math.min(this.chunkBudget,100,e&&!ce?Math.max(25,e.timeRemaining()-5):1e9),o=r.context.treeLen<n&&i.doc.length>n+1e3,l=r.context.work(()=>ce&&ce()||Date.now()>s,n+(o?0:1e5));this.chunkBudget-=Date.now()-t,(l||this.chunkBudget<=0)&&(r.context.takeTree(),this.view.dispatch({effects:h1.setState.of(new h9(r.context))})),this.chunkBudget>0&&!(l&&!o)&&this.scheduleWork(),this.checkAsyncSchedule(r.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(e=>sq(this.view.state,e)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),ci=nD.define({combine:e=>e.length?e[0]:null,enables:e=>[h1.state,ct,l$.contentAttributes.compute([e],t=>{let i=t.facet(e);return i&&i.name?{"data-language":i.name}:{}})]}),cn=nD.define(),cr=nD.define({combine:e=>{if(!e.length)return" ";let t=e[0];if(!t||/\S/.test(t)||Array.from(t).some(e=>e!=t[0]))throw Error("Invalid indent unit: "+JSON.stringify(e[0]));return t}});function cs(e){let t=e.facet(cr);return 9==t.charCodeAt(0)?e.tabSize*t.length:t.length}function co(e,t){let i="",n=e.tabSize,r=e.facet(cr)[0];if(" "==r){for(;t>=n;)i+=" ",t-=n;r=" "}for(let e=0;e<t;e++)i+=r;return i}function cl(e,t){for(let i of(e instanceof rt&&(e=new ca(e)),e.state.facet(cn))){let n=i(e,t);if(void 0!==n)return n}let i=h5(e.state);return i.length>=t?function(e,t,i){let n=t.resolveStack(i),r=t.resolveInner(i,-1).resolve(i,0).enterUnfinishedNodesBefore(i);if(r!=n.node){let e=[];for(let t=r;t&&!(t.from<n.node.from||t.to>n.node.to||t.from==n.node.from&&t.type==n.node.type);t=t.parent)e.push(t);for(let t=e.length-1;t>=0;t--)n={node:e[t],next:n}}return cc(n,e,i)}(e,i,t):null}class ca{constructor(e,t={}){this.state=e,this.options=t,this.unit=cs(e)}lineAt(e,t=1){let i=this.state.doc.lineAt(e),{simulateBreak:n,simulateDoubleBreak:r}=this.options;return null!=n&&n>=i.from&&n<=i.to?r&&n==e?{text:"",from:e}:(t<0?n<e:n<=e)?{text:i.text.slice(n-i.from),from:n}:{text:i.text.slice(0,n-i.from),from:i.from}:i}textAfterPos(e,t=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return"";let{text:i,from:n}=this.lineAt(e,t);return i.slice(e-n,Math.min(i.length,e+100-n))}column(e,t=1){let{text:i,from:n}=this.lineAt(e,t),r=this.countColumn(i,e-n),s=this.options.overrideIndentation?this.options.overrideIndentation(n):-1;return s>-1&&(r+=s-this.countColumn(i,i.search(/\S|$/))),r}countColumn(e,t=e.length){return rb(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:i,from:n}=this.lineAt(e,t),r=this.options.overrideIndentation;if(r){let e=r(n);if(e>-1)return e}return this.countColumn(i,i.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}let ch=new a7;function cc(e,t,i){for(let n=e;n;n=n.next){let e=function(e){let t=e.type.prop(ch);if(t)return t;let i=e.firstChild,n;if(i&&(n=i.type.prop(a7.closedBy))){let t=e.lastChild,i=t&&n.indexOf(t.name)>-1;return e=>(function(e,t,i,n,r){let s=e.textAfter,o=s.match(/^\s*/)[0].length,l=n&&s.slice(o,o+n.length)==n||r==e.pos+o,a=t?function(e){let t=e.node,i=t.childAfter(t.from),n=t.lastChild;if(!i)return null;let r=e.options.simulateBreak,s=e.state.doc.lineAt(i.from),o=null==r||r<=s.from?s.to:Math.min(s.to,r);for(let e=i.to;;){let r=t.childAfter(e);if(!r||r==n)return null;if(!r.type.isSkipped){if(r.from>=o)return null;let e=/^ */.exec(s.text.slice(i.to-s.from))[0].length;return{from:i.from,to:i.to+e}}e=r.to}}(e):null;return a?l?e.column(a.from):e.column(a.to):e.baseIndent+(l?0:1*e.unit)})(e,!0,1,void 0,i&&!(e.pos==e.options.simulateBreak&&e.options.simulateDoubleBreak)?t.from:void 0)}return null==e.parent?cd:null}(n.node);if(e)return e(cu.create(t,i,n))}return 0}function cd(){return 0}class cu extends ca{constructor(e,t,i){super(e.state,e.options),this.base=e,this.pos=t,this.context=i}get node(){return this.context.node}static create(e,t,i){return new cu(e,t,i)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let i=e.resolve(t.from);for(;i.parent&&i.parent.from==i.from;)i=i.parent;if(function(e,t){for(let i=t;i;i=i.parent)if(e==i)return!0;return!1}(i,e))break;t=this.state.doc.lineAt(i.from)}return this.lineIndent(t.from)}continue(){return cc(this.context.next,this.base,this.pos)}}let cf=nD.define(),cp=new a7;function cm(e,t,i){for(let n of e.facet(cf)){let r=n(e,t,i);if(r)return r}return function(e,t,i){let n=h5(e);if(n.length<i)return null;let r=n.resolveStack(i,1),s=null;for(let o=r;o;o=o.next){let r=o.node;if(r.to<=i||r.from>i)continue;if(s&&r.from<t)break;let l=r.type.prop(cp);if(l&&(r.to<n.length-50||n.length==e.doc.length||!function(e){let t=e.lastChild;return t&&t.to==e.to&&t.type.isError}(r))){let n=l(r,e);n&&n.from<=i&&n.from>=t&&n.to>i&&(s=n)}}return s}(e,t,i)}function cg(e,t){let i=t.mapPos(e.from,1),n=t.mapPos(e.to,-1);return i>=n?void 0:{from:i,to:n}}let cx=n5.define({map:cg}),cv=n5.define({map:cg}),cy=nB.define({create:()=>rQ.none,update(e,t){for(let i of(t.isUserEvent("delete")&&t.changes.iterChangedRanges((t,i)=>e=cb(e,t,i)),e=e.map(t.changes),t.effects))if(i.is(cx)&&!function(e,t,i){let n=!1;return e.between(t,t,(e,r)=>{e==t&&r==i&&(n=!0)}),n}(e,i.value.from,i.value.to)){let{preparePlaceholder:n}=t.state.facet(cS),r=n?rQ.replace({widget:new cM(n(t.state,i.value))}):cj;e=e.update({add:[r.range(i.value.from,i.value.to)]})}else i.is(cv)&&(e=e.update({filter:(e,t)=>i.value.from!=e||i.value.to!=t,filterFrom:i.value.from,filterTo:i.value.to}));return t.selection&&(e=cb(e,t.selection.main.head)),e},provide:e=>l$.decorations.from(e),toJSON(e,t){let i=[];return e.between(0,t.doc.length,(e,t)=>{i.push(e,t)}),i},fromJSON(e){if(!Array.isArray(e)||e.length%2)throw RangeError("Invalid JSON for fold state");let t=[];for(let i=0;i<e.length;){let n=e[i++],r=e[i++];if("number"!=typeof n||"number"!=typeof r)throw RangeError("Invalid JSON for fold state");t.push(cj.range(n,r))}return rQ.set(t,!0)}});function cb(e,t,i=t){let n=!1;return e.between(t,i,(e,r)=>{e<i&&r>t&&(n=!0)}),n?e.update({filterFrom:t,filterTo:i,filter:(e,n)=>e>=i||n<=t}):e}function cw(e,t,i){var n;let r=null;return null===(n=e.field(cy,!1))||void 0===n||n.between(t,i,(e,t)=>{(!r||r.from>e)&&(r={from:e,to:t})}),r}let ck={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},cS=nD.define({combine:e=>ri(e,ck)});function cC(e,t){let{state:i}=e,n=i.facet(cS),r=t=>{let i=e.lineBlockAt(e.posAtDOM(t.target)),n=cw(e.state,i.from,i.to);n&&e.dispatch({effects:cv.of(n)}),t.preventDefault()};if(n.placeholderDOM)return n.placeholderDOM(e,r,t);let s=document.createElement("span");return s.textContent=n.placeholderText,s.setAttribute("aria-label",i.phrase("folded code")),s.title=i.phrase("unfold"),s.className="cm-foldPlaceholder",s.onclick=r,s}let cj=rQ.replace({widget:new class extends rX{toDOM(e){return cC(e,null)}}});class cM extends rX{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return cC(e,this.value)}}let cZ={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class cA extends aF{constructor(e,t){super(),this.config=e,this.open=t}eq(e){return this.config==e.config&&this.open==e.open}toDOM(e){if(this.config.markerDOM)return this.config.markerDOM(this.open);let t=document.createElement("span");return t.textContent=this.open?this.config.openText:this.config.closedText,t.title=e.state.phrase(this.open?"Fold line":"Unfold line"),t}}let cT=l$.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}});class cO{constructor(e,t){let i;function n(e){let t=rj.newName();return(i||(i=Object.create(null)))["."+t]=e,t}this.specs=e;let r="string"==typeof t.all?t.all:t.all?n(t.all):void 0,s=t.scope;this.scope=s instanceof h1?e=>e.prop(hQ)==s.data:s?e=>e==s:void 0,this.style=hI(e.map(e=>({tag:e.tag,class:e.class||n(Object.assign({},e,{tag:null}))})),{all:r}).style,this.module=i?new rj(i):null,this.themeType=t.themeType}static define(e,t){return new cO(e,t||{})}}let cD=nD.define(),cR=nD.define({combine:e=>e.length?[e[0]]:null});function cP(e){let t=e.facet(cD);return t.length?t:e.facet(cR)}function cL(e,t){let i=[cE],n;return e instanceof cO&&(e.module&&i.push(l$.styleModule.of(e.module)),n=e.themeType),(null==t?void 0:t.fallback)?i.push(cR.of(e)):n?i.push(cD.computeN([l$.darkTheme],t=>t.facet(l$.darkTheme)==("dark"==n)?[e]:[])):i.push(cD.of(e)),i}class cI{constructor(e){this.markCache=Object.create(null),this.tree=h5(e.state),this.decorations=this.buildDeco(e,cP(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=h5(e.state),i=cP(e.state),n=i!=cP(e.startState),{viewport:r}=e.view,s=e.changes.mapPos(this.decoratedTo,1);t.length<r.to&&!n&&t.type==this.tree.type&&s>=r.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=s):(t!=this.tree||e.viewportChanged||n)&&(this.tree=t,this.decorations=this.buildDeco(e.view,i),this.decoratedTo=r.to)}buildDeco(e,t){if(!t||!this.tree.length)return rQ.none;let i=new rh;for(let{from:n,to:r}of e.visibleRanges)(function(e,t,i,n=0,r=e.length){let s=new hE(n,Array.isArray(t)?t:[t],i);s.highlightRange(e.cursor(),n,r,"",s.highlighters),s.flush(r)})(this.tree,t,(e,t,n)=>{i.add(e,t,this.markCache[n]||(this.markCache[n]=rQ.mark({class:n})))},n,r);return i.finish()}}let cE=nW.high(sG.fromClass(cI,{decorations:e=>e.decorations})),cB=cO.define([{tag:hY.meta,color:"#404740"},{tag:hY.link,textDecoration:"underline"},{tag:hY.heading,textDecoration:"underline",fontWeight:"bold"},{tag:hY.emphasis,fontStyle:"italic"},{tag:hY.strong,fontWeight:"bold"},{tag:hY.strikethrough,textDecoration:"line-through"},{tag:hY.keyword,color:"#708"},{tag:[hY.atom,hY.bool,hY.url,hY.contentSeparator,hY.labelName],color:"#219"},{tag:[hY.literal,hY.inserted],color:"#164"},{tag:[hY.string,hY.deleted],color:"#a11"},{tag:[hY.regexp,hY.escape,hY.special(hY.string)],color:"#e40"},{tag:hY.definition(hY.variableName),color:"#00f"},{tag:hY.local(hY.variableName),color:"#30a"},{tag:[hY.typeName,hY.namespace],color:"#085"},{tag:hY.className,color:"#167"},{tag:[hY.special(hY.variableName),hY.macroName],color:"#256"},{tag:hY.definition(hY.propertyName),color:"#00c"},{tag:hY.comment,color:"#940"},{tag:hY.invalid,color:"#f00"}]),cN=l$.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),cz="()[]{}",cW=nD.define({combine:e=>ri(e,{afterCursor:!0,brackets:cz,maxScanDistance:1e4,renderMatch:cH})}),cF=rQ.mark({class:"cm-matchingBracket"}),cV=rQ.mark({class:"cm-nonmatchingBracket"});function cH(e){let t=[],i=e.matched?cF:cV;return t.push(i.range(e.start.from,e.start.to)),e.end&&t.push(i.range(e.end.from,e.end.to)),t}let c$=[nB.define({create:()=>rQ.none,update(e,t){if(!t.docChanged&&!t.selection)return e;let i=[],n=t.state.facet(cW);for(let e of t.state.selection.ranges){if(!e.empty)continue;let r=c_(t.state,e.head,-1,n)||e.head>0&&c_(t.state,e.head-1,1,n)||n.afterCursor&&(c_(t.state,e.head,1,n)||e.head<t.state.doc.length&&c_(t.state,e.head+1,-1,n));r&&(i=i.concat(n.renderMatch(r,t.state)))}return rQ.set(i,!0)},provide:e=>l$.decorations.from(e)}),cN],cq=new a7;function cK(e,t,i){let n=e.prop(t<0?a7.openedBy:a7.closedBy);if(n)return n;if(1==e.name.length){let n=i.indexOf(e.name);if(n>-1&&n%2==(t<0?1:0))return[i[n+t]]}return null}function cU(e){let t=e.type.prop(cq);return t?t(e.node):e}function c_(e,t,i,n={}){let r=n.maxScanDistance||1e4,s=n.brackets||cz,o=h5(e),l=o.resolveInner(t,i);for(let e=l;e;e=e.parent){let n=cK(e.type,i,s);if(n&&e.from<e.to){let r=cU(e);if(r&&(i>0?t>=r.from&&t<r.to:t>r.from&&t<=r.to))return function(e,t,i,n,r,s,o){let l=n.parent,a={from:r.from,to:r.to},h=0,c=null==l?void 0:l.cursor();if(c&&(i<0?c.childBefore(n.from):c.childAfter(n.to)))do if(i<0?c.to<=n.from:c.from>=n.to){if(0==h&&s.indexOf(c.type.name)>-1&&c.from<c.to){let e=cU(c);return{start:a,end:e?{from:e.from,to:e.to}:void 0,matched:!0}}if(cK(c.type,i,o))h++;else if(cK(c.type,-i,o)){if(0==h){let e=cU(c);return{start:a,end:e&&e.from<e.to?{from:e.from,to:e.to}:void 0,matched:!1}}h--}}while(i<0?c.prevSibling():c.nextSibling());return{start:a,matched:!1}}(0,0,i,e,r,n,s)}}return function(e,t,i,n,r,s,o){let l=i<0?e.sliceDoc(t-1,t):e.sliceDoc(t,t+1),a=o.indexOf(l);if(a<0||a%2==0!=i>0)return null;let h={from:i<0?t-1:t,to:i>0?t+1:t},c=e.doc.iterRange(t,i>0?e.doc.length:0),d=0;for(let e=0;!c.next().done&&e<=s;){let s=c.value;i<0&&(e+=s.length);let l=t+e*i;for(let e=i>0?0:s.length-1,t=i>0?s.length:-1;e!=t;e+=i){let t=o.indexOf(s[e]);if(!(t<0)&&n.resolveInner(l+e,1).type==r){if(t%2==0==i>0)d++;else{if(1==d)return{start:h,end:{from:l+e,to:l+e+1},matched:t>>1==a>>1};d--}}}i>0&&(e+=s.length)}return c.done?{start:h,matched:!1}:null}(e,t,i,o,l.type,r,s)}let cG=Object.create(null),cJ=[hi.none],cX=[],cY=Object.create(null),cQ=Object.create(null);for(let[e,t]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])cQ[e]=function(e,t){let i=[];for(let n of t.split(" ")){let t=[];for(let i of n.split(".")){let n=e[i]||hY[i];n?"function"==typeof n?t.length?t=t.map(n):c0(i,`Modifier ${i} used at start of tag`):t.length?c0(i,`Tag ${i} used as modifier`):t=Array.isArray(n)?n:[n]:c0(i,`Unknown highlighting tag ${i}`)}for(let e of t)i.push(e)}if(!i.length)return 0;let n=t.replace(/ /g,"_"),r=n+" "+i.map(e=>e.id),s=cY[r];if(s)return s.id;let o=cY[r]=hi.define({id:cJ.length,name:n,props:[function(e){let t=Object.create(null);for(let i in e){let n=e[i];for(let e of(Array.isArray(n)||(n=[n]),i.split(" ")))if(e){let i=[],r=2,s=e;for(let t=0;;){if("..."==s&&t>0&&t+3==e.length){r=1;break}let n=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(s);if(!n)throw RangeError("Invalid path: "+e);if(i.push("*"==n[0]?"":'"'==n[0][0]?JSON.parse(n[0]):n[0]),(t+=n[0].length)==e.length)break;let o=e[t++];if(t==e.length&&"!"==o){r=0;break}if("/"!=o)throw RangeError("Invalid path: "+e);s=e.slice(t)}let o=i.length-1,l=i[o];if(!l)throw RangeError("Invalid path: "+e);let a=new hL(n,r,o>0?i.slice(0,o):null);t[l]=a.sort(t[l])}}return hP.add(t)}({[n]:i})]});return cJ.push(o),o.id}(cG,t);function c0(e,t){cX.indexOf(e)>-1||(cX.push(e),console.warn(t))}function c1(e){return e.length<=4096&&/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/.test(e)}let c2={rtl:rQ.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"rtl"},bidiIsolate:sg.RTL}),ltr:rQ.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"ltr"},bidiIsolate:sg.LTR}),auto:rQ.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"auto"},bidiIsolate:null})};function c5(e,t){return({state:i,dispatch:n})=>{if(i.readOnly)return!1;let r=e(t,i);return!!r&&(n(i.update(r)),!0)}}let c4=c5(function(e,t,i=t.selection.ranges){let n=[],r=-1;r:for(let{from:e,to:s}of i){let i=n.length,o=1e9,l;for(let i=e;i<=s;){let a=t.doc.lineAt(i);if(void 0==l&&!(l=c8(t,a.from).line))continue r;if(a.from>r&&(e==s||s>a.from)){r=a.from;let e=/^\s*/.exec(a.text)[0].length,t=e==a.length,i=a.text.slice(e,e+l.length)==l?e:-1;e<a.text.length&&e<o&&(o=e),n.push({line:a,comment:i,token:l,indent:e,empty:t,single:!1})}i=a.to+1}if(o<1e9)for(let e=i;e<n.length;e++)n[e].indent<n[e].line.text.length&&(n[e].indent=o);n.length==i+1&&(n[i].single=!0)}if(2!=e&&n.some(e=>e.comment<0&&(!e.empty||e.single))){let e=[];for(let{line:t,token:i,indent:r,empty:s,single:o}of n)(o||!s)&&e.push({from:t.from+r,insert:i+" "});let i=t.changes(e);return{changes:i,selection:t.selection.map(i,1)}}if(1!=e&&n.some(e=>e.comment>=0)){let e=[];for(let{line:t,comment:i,token:r}of n)if(i>=0){let n=t.from+i,s=n+r.length;" "==t.text[s-t.from]&&s++,e.push({from:n,to:s})}return{changes:e}}return null},0),c6=c5(c9,0),c3=c5((e,t)=>c9(e,t,function(e){let t=[];for(let i of e.selection.ranges){let n=e.doc.lineAt(i.from),r=i.to<=n.to?n:e.doc.lineAt(i.to);r.from>n.from&&r.from==i.to&&(r=i.to==n.to+1?n:e.doc.lineAt(i.to-1));let s=t.length-1;s>=0&&t[s].to>n.from?t[s].to=r.to:t.push({from:n.from+/^\s*/.exec(n.text)[0].length,to:r.to})}return t}(t)),0);function c8(e,t){let i=e.languageDataAt("commentTokens",t,1);return i.length?i[0]:{}}function c9(e,t,i=t.selection.ranges){let n=i.map(e=>c8(t,e.from).block);if(!n.every(e=>e))return null;let r=i.map((e,i)=>(function(e,{open:t,close:i},n,r){let s,o,l=e.sliceDoc(n-50,n),a=e.sliceDoc(r,r+50),h=/\s*$/.exec(l)[0].length,c=/^\s*/.exec(a)[0].length,d=l.length-h;if(l.slice(d-t.length,d)==t&&a.slice(c,c+i.length)==i)return{open:{pos:n-h,margin:h&&1},close:{pos:r+c,margin:c&&1}};r-n<=100?s=o=e.sliceDoc(n,r):(s=e.sliceDoc(n,n+50),o=e.sliceDoc(r-50,r));let u=/^\s*/.exec(s)[0].length,f=/\s*$/.exec(o)[0].length,p=o.length-f-i.length;return s.slice(u,u+t.length)==t&&o.slice(p,p+i.length)==i?{open:{pos:n+u+t.length,margin:/\s/.test(s.charAt(u+t.length))?1:0},close:{pos:r-f-i.length,margin:/\s/.test(o.charAt(p-1))?1:0}}:null})(t,n[i],e.from,e.to));if(2!=e&&!r.every(e=>e))return{changes:t.changes(i.map((e,t)=>r[t]?[]:[{from:e.from,insert:n[t].open+" "},{from:e.to,insert:" "+n[t].close}]))};if(1!=e&&r.some(e=>e)){let e=[];for(let t=0,i;t<r.length;t++)if(i=r[t]){let r=n[t],{open:s,close:o}=i;e.push({from:s.pos-r.open.length,to:s.pos+s.margin},{from:o.pos-o.margin,to:o.pos+r.close.length})}return{changes:e}}return null}let c7=n0.define(),de=n0.define(),dt=nD.define(),di=nD.define({combine:e=>ri(e,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(i,n)=>e(i,n)||t(i,n)})}),dn=nB.define({create:()=>dx.empty,update(e,t){let i=t.state.facet(di),n=t.annotation(c7);if(n){let r=dc.fromTransaction(t,n.selection),s=n.side,o=0==s?e.undone:e.done;return o=r?dd(o,o.length,i.minDepth,r):dp(o,t.startState.selection),new dx(0==s?n.rest:o,0==s?o:n.rest)}let r=t.annotation(de);if(("full"==r||"before"==r)&&(e=e.isolate()),!1===t.annotation(n4.addToHistory))return t.changes.empty?e:e.addMapping(t.changes.desc);let s=dc.fromTransaction(t),o=t.annotation(n4.time),l=t.annotation(n4.userEvent);return s?e=e.addChanges(s,o,l,i,t):t.selection&&(e=e.addSelection(t.startState.selection,o,l,i.newGroupDelay)),("full"==r||"after"==r)&&(e=e.isolate()),e},toJSON:e=>({done:e.done.map(e=>e.toJSON()),undone:e.undone.map(e=>e.toJSON())}),fromJSON:e=>new dx(e.done.map(dc.fromJSON),e.undone.map(dc.fromJSON))});function dr(e,t){return function({state:i,dispatch:n}){if(!t&&i.readOnly)return!1;let r=i.field(dn,!1);if(!r)return!1;let s=r.pop(e,i,t);return!!s&&(n(s),!0)}}let ds=dr(0,!1),dl=dr(1,!1),da=dr(0,!0),dh=dr(1,!0);class dc{constructor(e,t,i,n,r){this.changes=e,this.effects=t,this.mapped=i,this.startSelection=n,this.selectionsAfter=r}setSelAfter(e){return new dc(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,i;return{changes:null===(e=this.changes)||void 0===e?void 0:e.toJSON(),mapped:null===(t=this.mapped)||void 0===t?void 0:t.toJSON(),startSelection:null===(i=this.startSelection)||void 0===i?void 0:i.toJSON(),selectionsAfter:this.selectionsAfter.map(e=>e.toJSON())}}static fromJSON(e){return new dc(e.changes&&nb.fromJSON(e.changes),[],e.mapped&&ny.fromJSON(e.mapped),e.startSelection&&nA.fromJSON(e.startSelection),e.selectionsAfter.map(nA.fromJSON))}static fromTransaction(e,t){let i=df;for(let t of e.startState.facet(dt)){let n=t(e);n.length&&(i=i.concat(n))}return!i.length&&e.changes.empty?null:new dc(e.changes.invert(e.startState.doc),i,void 0,t||e.startState.selection,df)}static selection(e){return new dc(void 0,df,void 0,void 0,e)}}function dd(e,t,i,n){let r=e.slice(t+1>i+20?t-i-1:0,t);return r.push(n),r}function du(e,t){return e.length?t.length?e.concat(t):e:t}let df=[];function dp(e,t){if(!e.length)return[dc.selection([t])];{let i=e[e.length-1],n=i.selectionsAfter.slice(Math.max(0,i.selectionsAfter.length-200));return n.length&&n[n.length-1].eq(t)?e:(n.push(t),dd(e,e.length-1,1e9,i.setSelAfter(n)))}}function dm(e,t){if(!e.length)return e;let i=e.length,n=df;for(;i;){let r=function(e,t,i){let n=du(e.selectionsAfter.length?e.selectionsAfter.map(e=>e.map(t)):df,i);if(!e.changes)return dc.selection(n);let r=e.changes.map(t),s=t.mapDesc(e.changes,!0),o=e.mapped?e.mapped.composeDesc(s):s;return new dc(r,n5.mapEffects(e.effects,t),o,e.startSelection.map(s),n)}(e[i-1],t,n);if(r.changes&&!r.changes.empty||r.effects.length){let t=e.slice(0,i);return t[i-1]=r,t}t=r.mapped,i--,n=r.selectionsAfter}return n.length?[dc.selection(n)]:df}let dg=/^(input\.type|delete)($|\.)/;class dx{constructor(e,t,i=0,n){this.done=e,this.undone=t,this.prevTime=i,this.prevUserEvent=n}isolate(){return this.prevTime?new dx(this.done,this.undone):this}addChanges(e,t,i,n,r){var s,o;let l,a,h=this.done,c=h[h.length-1];return new dx(h=c&&c.changes&&!c.changes.empty&&e.changes&&(!i||dg.test(i))&&(!c.selectionsAfter.length&&t-this.prevTime<n.newGroupDelay&&n.joinToEvent(r,(s=c.changes,o=e.changes,l=[],a=!1,s.iterChangedRanges((e,t)=>l.push(e,t)),o.iterChangedRanges((e,t,i,n)=>{for(let e=0;e<l.length;){let t=l[e++],r=l[e++];n>=t&&i<=r&&(a=!0)}}),a))||"input.type.compose"==i)?dd(h,h.length-1,n.minDepth,new dc(e.changes.compose(c.changes),du(n5.mapEffects(e.effects,c.changes),c.effects),c.mapped,c.startSelection,df)):dd(h,h.length,n.minDepth,e),df,t,i)}addSelection(e,t,i,n){var r;let s=this.done.length?this.done[this.done.length-1].selectionsAfter:df;return s.length>0&&t-this.prevTime<n&&i==this.prevUserEvent&&i&&/^select($|\.)/.test(i)&&(r=s[s.length-1]).ranges.length==e.ranges.length&&0===r.ranges.filter((t,i)=>t.empty!=e.ranges[i].empty).length?this:new dx(dp(this.done,e),this.undone,t,i)}addMapping(e){return new dx(dm(this.done,e),dm(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,t,i){let n=0==e?this.done:this.undone;if(0==n.length)return null;let r=n[n.length-1],s=r.selectionsAfter[0]||(r.startSelection?r.startSelection.map(r.changes.invertedDesc,1):t.selection);if(i&&r.selectionsAfter.length){let i,o;return t.update({selection:r.selectionsAfter[r.selectionsAfter.length-1],annotations:c7.of({side:e,rest:(i=n[n.length-1],(o=n.slice())[n.length-1]=i.setSelAfter(i.selectionsAfter.slice(0,i.selectionsAfter.length-1)),o),selection:s}),userEvent:0==e?"select.undo":"select.redo",scrollIntoView:!0})}if(!r.changes)return null;{let i=1==n.length?df:n.slice(0,n.length-1);return r.mapped&&(i=dm(i,r.mapped)),t.update({changes:r.changes,selection:r.startSelection,effects:r.effects,annotations:c7.of({side:e,rest:i,selection:s}),filter:!1,userEvent:0==e?"undo":"redo",scrollIntoView:!0})}}}dx.empty=new dx(df,df);let dv=[{key:"Mod-z",run:ds,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:dl,preventDefault:!0},{linux:"Ctrl-Shift-z",run:dl,preventDefault:!0},{key:"Mod-u",run:da,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:dh,preventDefault:!0}];function dy(e,t){return nA.create(e.ranges.map(t),e.mainIndex)}function db(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:"select"})}function dw({state:e,dispatch:t},i){let n=dy(e.selection,i);return!n.eq(e.selection,!0)&&(t(db(e,n)),!0)}function dk(e,t){return nA.cursor(t?e.to:e.from)}function dS(e,t){return dw(e,i=>i.empty?e.moveByChar(i,t):dk(i,t))}function dC(e){return e.textDirectionAt(e.state.selection.main.head)==sg.LTR}let dj=e=>dS(e,!dC(e)),dM=e=>dS(e,dC(e));function dZ(e,t){return dw(e,i=>i.empty?e.moveByGroup(i,t):dk(i,t))}function dA(e,t,i){let n,r,s=h5(e).resolveInner(t.head),o=i?a7.closedBy:a7.openedBy;for(let n=t.head;;){let t=i?s.childAfter(n):s.childBefore(n);if(!t)break;(function(e,t,i){if(t.type.prop(i))return!0;let n=t.to-t.from;return n&&(n>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild})(e,t,o)?s=t:n=i?t.to:t.from}return r=s.type.prop(o)&&(n=i?c_(e,s.from,1):c_(e,s.to,-1))&&n.matched?i?n.end.to:n.end.from:i?s.to:s.from,nA.cursor(r,i?-1:1)}function dT(e,t){return dw(e,i=>{if(!i.empty)return dk(i,t);let n=e.moveVertically(i,t);return n.head!=i.head?n:e.moveToLineBoundary(i,t)})}"undefined"!=typeof Intl&&Intl.Segmenter;let dO=e=>dT(e,!1),dD=e=>dT(e,!0);function dR(e){let t=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,i=0,n=0,r;if(t){for(let t of e.state.facet(l$.scrollMargins)){let r=t(e);(null==r?void 0:r.top)&&(i=Math.max(null==r?void 0:r.top,i)),(null==r?void 0:r.bottom)&&(n=Math.max(null==r?void 0:r.bottom,n))}r=e.scrollDOM.clientHeight-i-n}else r=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:i,marginBottom:n,selfScroll:t,height:Math.max(e.defaultLineHeight,r-5)}}function dP(e,t){let i,n=dR(e),{state:r}=e,s=dy(r.selection,i=>i.empty?e.moveVertically(i,t,n.height):dk(i,t));if(s.eq(r.selection))return!1;if(n.selfScroll){let t=e.coordsAtPos(r.selection.main.head),o=e.scrollDOM.getBoundingClientRect(),l=o.top+n.marginTop,a=o.bottom-n.marginBottom;t&&t.top>l&&t.bottom<a&&(i=l$.scrollIntoView(s.main.head,{y:"start",yMargin:t.top-l}))}return e.dispatch(db(r,s),{effects:i}),!0}let dL=e=>dP(e,!1),dI=e=>dP(e,!0);function dE(e,t,i){let n=e.lineBlockAt(t.head),r=e.moveToLineBoundary(t,i);if(r.head==t.head&&r.head!=(i?n.to:n.from)&&(r=e.moveToLineBoundary(t,i,!1)),!i&&r.head==n.from&&n.length){let i=/^\s*/.exec(e.state.sliceDoc(n.from,Math.min(n.from+100,n.to)))[0].length;i&&t.head!=n.from+i&&(r=nA.cursor(n.from+i))}return r}function dB(e,t){let i=dy(e.state.selection,e=>{let i=t(e);return nA.range(e.anchor,i.head,i.goalColumn,i.bidiLevel||void 0)});return!i.eq(e.state.selection)&&(e.dispatch(db(e.state,i)),!0)}function dN(e,t){return dB(e,i=>e.moveByChar(i,t))}let dz=e=>dN(e,!dC(e)),dW=e=>dN(e,dC(e));function dF(e,t){return dB(e,i=>e.moveByGroup(i,t))}function dV(e,t){return dB(e,i=>e.moveVertically(i,t))}let dH=e=>dV(e,!1),d$=e=>dV(e,!0);function dq(e,t){return dB(e,i=>e.moveVertically(i,t,dR(e).height))}let dK=e=>dq(e,!1),dU=e=>dq(e,!0),d_=({state:e,dispatch:t})=>(t(db(e,{anchor:0})),!0),dG=({state:e,dispatch:t})=>(t(db(e,{anchor:e.doc.length})),!0),dJ=({state:e,dispatch:t})=>(t(db(e,{anchor:e.selection.main.anchor,head:0})),!0),dX=({state:e,dispatch:t})=>(t(db(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0);function dY(e,t){let{state:i}=e,n=i.selection,r=i.selection.ranges.slice();for(let n of i.selection.ranges){let s=i.doc.lineAt(n.head);if(t?s.to<e.state.doc.length:s.from>0)for(let i=n;;){let n=e.moveVertically(i,t);if(n.head<s.from||n.head>s.to){r.some(e=>e.head==n.head)||r.push(n);break}if(n.head==i.head)break;i=n}}return r.length!=n.ranges.length&&(e.dispatch(db(i,nA.create(r,r.length-1))),!0)}function dQ(e,t){if(e.state.readOnly)return!1;let i="delete.selection",{state:n}=e,r=n.changeByRange(n=>{let{from:r,to:s}=n;if(r==s){let o=t(n);o<r?(i="delete.backward",o=d0(e,o,!1)):o>r&&(i="delete.forward",o=d0(e,o,!0)),r=Math.min(r,o),s=Math.max(s,o)}else r=d0(e,r,!1),s=d0(e,s,!0);return r==s?{range:n}:{changes:{from:r,to:s},range:nA.cursor(r,r<n.head?-1:1)}});return!r.changes.empty&&(e.dispatch(n.update(r,{scrollIntoView:!0,userEvent:i,effects:"delete.selection"==i?l$.announce.of(n.phrase("Selection deleted")):void 0})),!0)}function d0(e,t,i){if(e instanceof l$)for(let n of e.state.facet(l$.atomicRanges).map(t=>t(e)))n.between(t,t,(e,n)=>{e<t&&n>t&&(t=i?n:e)});return t}let d1=(e,t,i)=>dQ(e,n=>{let r=n.from,{state:s}=e,o=s.doc.lineAt(r),l,a;if(i&&!t&&r>o.from&&r<o.from+200&&!/[^ \t]/.test(l=o.text.slice(0,r-o.from))){if(" "==l[l.length-1])return r-1;let e=rb(l,s.tabSize)%cs(s)||cs(s);for(let t=0;t<e&&" "==l[l.length-1-t];t++)r--;a=r}else(a=np(o.text,r-o.from,t,t)+o.from)==r&&o.number!=(t?s.doc.lines:1)?a+=t?1:-1:!t&&/[\ufe00-\ufe0f]/.test(o.text.slice(a-o.from,r-o.from))&&(a=np(o.text,a-o.from,!1,!1)+o.from);return a}),d2=e=>d1(e,!1,!0),d5=e=>d1(e,!0,!1),d4=(e,t)=>dQ(e,i=>{let n=i.head,{state:r}=e,s=r.doc.lineAt(n),o=r.charCategorizer(n);for(let e=null;;){if(n==(t?s.to:s.from)){n==i.head&&s.number!=(t?r.doc.lines:1)&&(n+=t?1:-1);break}let l=np(s.text,n-s.from,t)+s.from,a=s.text.slice(Math.min(n,l)-s.from,Math.max(n,l)-s.from),h=o(a);if(null!=e&&h!=e)break;(" "!=a||n!=i.head)&&(e=h),n=l}return n}),d6=e=>d4(e,!1);function d3(e){let t=[],i=-1;for(let n of e.selection.ranges){let r=e.doc.lineAt(n.from),s=e.doc.lineAt(n.to);if(n.empty||n.to!=s.from||(s=e.doc.lineAt(n.to-1)),i>=r.number){let e=t[t.length-1];e.to=s.to,e.ranges.push(n)}else t.push({from:r.from,to:s.to,ranges:[n]});i=s.number+1}return t}function d8(e,t,i){if(e.readOnly)return!1;let n=[],r=[];for(let t of d3(e)){if(i?t.to==e.doc.length:0==t.from)continue;let s=e.doc.lineAt(i?t.to+1:t.from-1),o=s.length+1;if(i)for(let i of(n.push({from:t.to,to:s.to},{from:t.from,insert:s.text+e.lineBreak}),t.ranges))r.push(nA.range(Math.min(e.doc.length,i.anchor+o),Math.min(e.doc.length,i.head+o)));else for(let i of(n.push({from:s.from,to:t.from},{from:t.to,insert:e.lineBreak+s.text}),t.ranges))r.push(nA.range(i.anchor-o,i.head-o))}return!!n.length&&(t(e.update({changes:n,scrollIntoView:!0,selection:nA.create(r,e.selection.mainIndex),userEvent:"move.line"})),!0)}function d9(e,t,i){if(e.readOnly)return!1;let n=[];for(let t of d3(e))i?n.push({from:t.from,insert:e.doc.slice(t.from,t.to)+e.lineBreak}):n.push({from:t.to,insert:e.lineBreak+e.doc.slice(t.from,t.to)});let r=e.changes(n);return t(e.update({changes:r,selection:e.selection.map(r,i?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}let d7=ut(!1),ue=ut(!0);function ut(e){return({state:t,dispatch:i})=>{if(t.readOnly)return!1;let n=t.changeByRange(i=>{let{from:n,to:r}=i,s=t.doc.lineAt(n),o=!e&&n==r&&function(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let i=h5(e).resolveInner(t),n=i.childBefore(t),r=i.childAfter(t),s;return n&&r&&n.to<=t&&r.from>=t&&(s=n.type.prop(a7.closedBy))&&s.indexOf(r.name)>-1&&e.doc.lineAt(n.to).from==e.doc.lineAt(r.from).from&&!/\S/.test(e.sliceDoc(n.to,r.from))?{from:n.to,to:r.from}:null}(t,n);e&&(n=r=(r<=s.to?s:t.doc.lineAt(r)).to);let l=new ca(t,{simulateBreak:n,simulateDoubleBreak:!!o}),a=cl(l,n);for(null==a&&(a=rb(/^\s*/.exec(t.doc.lineAt(n).text)[0],t.tabSize));r<s.to&&/\s/.test(s.text[r-s.from]);)r++;o?{from:n,to:r}=o:n>s.from&&n<s.from+100&&!/\S/.test(s.text.slice(0,n))&&(n=s.from);let h=["",co(t,a)];return o&&h.push(co(t,l.lineIndent(s.from,-1))),{changes:{from:n,to:r,insert:ns.of(h)},range:nA.cursor(n+1+h[1].length)}});return i(t.update(n,{scrollIntoView:!0,userEvent:"input"})),!0}}function ui(e,t){let i=-1;return e.changeByRange(n=>{let r=[];for(let s=n.from;s<=n.to;){let o=e.doc.lineAt(s);o.number>i&&(n.empty||n.to>o.from)&&(t(o,r,n),i=o.number),s=o.to+1}let s=e.changes(r);return{changes:r,range:nA.range(s.mapPos(n.anchor,1),s.mapPos(n.head,1))}})}let un=({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(ui(e,(t,i)=>{i.push({from:t.from,insert:e.facet(cr)})}),{userEvent:"input.indent"})),!0),ur=({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(ui(e,(t,i)=>{let n=/^\s*/.exec(t.text)[0];if(!n)return;let r=rb(n,e.tabSize),s=0,o=co(e,Math.max(0,r-cs(e)));for(;s<n.length&&s<o.length&&n.charCodeAt(s)==o.charCodeAt(s);)s++;i.push({from:t.from+s,to:t.from+n.length,insert:o.slice(s)})}),{userEvent:"delete.dedent"})),!0),us=[{key:"Ctrl-b",run:dj,shift:dz,preventDefault:!0},{key:"Ctrl-f",run:dM,shift:dW},{key:"Ctrl-p",run:dO,shift:dH},{key:"Ctrl-n",run:dD,shift:d$},{key:"Ctrl-a",run:e=>dw(e,t=>nA.cursor(e.lineBlockAt(t.head).from,1)),shift:e=>dB(e,t=>nA.cursor(e.lineBlockAt(t.head).from))},{key:"Ctrl-e",run:e=>dw(e,t=>nA.cursor(e.lineBlockAt(t.head).to,-1)),shift:e=>dB(e,t=>nA.cursor(e.lineBlockAt(t.head).to))},{key:"Ctrl-d",run:d5},{key:"Ctrl-h",run:d2},{key:"Ctrl-k",run:e=>dQ(e,t=>{let i=e.lineBlockAt(t.head).to;return t.head<i?i:Math.min(e.state.doc.length,t.head+1)})},{key:"Ctrl-Alt-h",run:d6},{key:"Ctrl-o",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let i=e.changeByRange(e=>({changes:{from:e.from,to:e.to,insert:ns.of(["",""])},range:nA.cursor(e.from)}));return t(e.update(i,{scrollIntoView:!0,userEvent:"input"})),!0}},{key:"Ctrl-t",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let i=e.changeByRange(t=>{if(!t.empty||0==t.from||t.from==e.doc.length)return{range:t};let i=t.from,n=e.doc.lineAt(i),r=i==n.from?i-1:np(n.text,i-n.from,!1)+n.from,s=i==n.to?i+1:np(n.text,i-n.from,!0)+n.from;return{changes:{from:r,to:s,insert:e.doc.slice(i,s).append(e.doc.slice(r,i))},range:nA.cursor(s)}});return!i.changes.empty&&(t(e.update(i,{scrollIntoView:!0,userEvent:"move.character"})),!0)}},{key:"Ctrl-v",run:dI}],uo=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:e=>dw(e,t=>dA(e.state,t,!dC(e))),shift:e=>dB(e,t=>dA(e.state,t,!dC(e)))},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:e=>dw(e,t=>dA(e.state,t,dC(e))),shift:e=>dB(e,t=>dA(e.state,t,dC(e)))},{key:"Alt-ArrowUp",run:({state:e,dispatch:t})=>d8(e,t,!1)},{key:"Shift-Alt-ArrowUp",run:({state:e,dispatch:t})=>d9(e,t,!1)},{key:"Alt-ArrowDown",run:({state:e,dispatch:t})=>d8(e,t,!0)},{key:"Shift-Alt-ArrowDown",run:({state:e,dispatch:t})=>d9(e,t,!0)},{key:"Mod-Alt-ArrowUp",run:e=>dY(e,!1)},{key:"Mod-Alt-ArrowDown",run:e=>dY(e,!0)},{key:"Escape",run:({state:e,dispatch:t})=>{let i=e.selection,n=null;return i.ranges.length>1?n=nA.create([i.main]):i.main.empty||(n=nA.create([nA.cursor(i.main.head)])),!!n&&(t(db(e,n)),!0)}},{key:"Mod-Enter",run:ue},{key:"Alt-l",mac:"Ctrl-l",run:({state:e,dispatch:t})=>{let i=d3(e).map(({from:t,to:i})=>nA.range(t,Math.min(i+1,e.doc.length)));return t(e.update({selection:nA.create(i),userEvent:"select"})),!0}},{key:"Mod-i",run:({state:e,dispatch:t})=>{let i=dy(e.selection,t=>{let i=h5(e),n=i.resolveStack(t.from,1);if(t.empty){let e=i.resolveStack(t.from,-1);e.node.from>=n.node.from&&e.node.to<=n.node.to&&(n=e)}for(let e=n;e;e=e.next){let{node:i}=e;if((i.from<t.from&&i.to>=t.to||i.to>t.to&&i.from<=t.from)&&e.next)return nA.range(i.to,i.from)}return t});return!i.eq(e.selection)&&(t(db(e,i)),!0)},preventDefault:!0},{key:"Mod-[",run:ur},{key:"Mod-]",run:un},{key:"Mod-Alt-\\",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let i=Object.create(null),n=new ca(e,{overrideIndentation:e=>{let t=i[e];return null==t?-1:t}}),r=ui(e,(t,r,s)=>{let o=cl(n,t.from);if(null==o)return;/\S/.test(t.text)||(o=0);let l=/^\s*/.exec(t.text)[0],a=co(e,o);(l!=a||s.from<t.from+l.length)&&(i[t.from]=o,r.push({from:t.from,to:t.from+l.length,insert:a}))});return r.changes.empty||t(e.update(r,{userEvent:"indent"})),!0}},{key:"Shift-Mod-k",run:e=>{if(e.state.readOnly)return!1;let{state:t}=e,i=t.changes(d3(t).map(({from:e,to:i})=>(e>0?e--:i<t.doc.length&&i++,{from:e,to:i}))),n=dy(t.selection,t=>{let i;if(e.lineWrapping){let n=e.lineBlockAt(t.head),r=e.coordsAtPos(t.head,t.assoc||1);r&&(i=n.bottom+e.documentTop-r.bottom+e.defaultLineHeight/2)}return e.moveVertically(t,!0,i)}).map(i);return e.dispatch({changes:i,selection:n,scrollIntoView:!0,userEvent:"delete.line"}),!0}},{key:"Shift-Mod-\\",run:({state:e,dispatch:t})=>(function(e,t,i){let n=!1,r=dy(e.selection,t=>{let r=c_(e,t.head,-1)||c_(e,t.head,1)||t.head>0&&c_(e,t.head-1,1)||t.head<e.doc.length&&c_(e,t.head+1,-1);if(!r||!r.end)return t;n=!0;let s=r.start.from==t.head?r.end.to:r.end.from;return i?nA.range(t.anchor,s):nA.cursor(s)});return!!n&&(t(db(e,r)),!0)})(e,t,!1)},{key:"Mod-/",run:e=>{let{state:t}=e,i=t.doc.lineAt(t.selection.main.from),n=c8(e.state,i.from);return n.line?c4(e):!!n.block&&c3(e)}},{key:"Alt-A",run:c6},{key:"Ctrl-m",mac:"Shift-Alt-m",run:e=>(e.setTabFocusMode(),!0)}].concat([{key:"ArrowLeft",run:dj,shift:dz,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:e=>dZ(e,!dC(e)),shift:e=>dF(e,!dC(e)),preventDefault:!0},{mac:"Cmd-ArrowLeft",run:e=>dw(e,t=>dE(e,t,!dC(e))),shift:e=>dB(e,t=>dE(e,t,!dC(e))),preventDefault:!0},{key:"ArrowRight",run:dM,shift:dW,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:e=>dZ(e,dC(e)),shift:e=>dF(e,dC(e)),preventDefault:!0},{mac:"Cmd-ArrowRight",run:e=>dw(e,t=>dE(e,t,dC(e))),shift:e=>dB(e,t=>dE(e,t,dC(e))),preventDefault:!0},{key:"ArrowUp",run:dO,shift:dH,preventDefault:!0},{mac:"Cmd-ArrowUp",run:d_,shift:dJ},{mac:"Ctrl-ArrowUp",run:dL,shift:dK},{key:"ArrowDown",run:dD,shift:d$,preventDefault:!0},{mac:"Cmd-ArrowDown",run:dG,shift:dX},{mac:"Ctrl-ArrowDown",run:dI,shift:dU},{key:"PageUp",run:dL,shift:dK},{key:"PageDown",run:dI,shift:dU},{key:"Home",run:e=>dw(e,t=>dE(e,t,!1)),shift:e=>dB(e,t=>dE(e,t,!1)),preventDefault:!0},{key:"Mod-Home",run:d_,shift:dJ},{key:"End",run:e=>dw(e,t=>dE(e,t,!0)),shift:e=>dB(e,t=>dE(e,t,!0)),preventDefault:!0},{key:"Mod-End",run:dG,shift:dX},{key:"Enter",run:d7,shift:d7},{key:"Mod-a",run:({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:"select"})),!0)},{key:"Backspace",run:d2,shift:d2,preventDefault:!0},{key:"Delete",run:d5,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:d6,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:e=>d4(e,!0),preventDefault:!0},{mac:"Mod-Backspace",run:e=>dQ(e,t=>{let i=e.moveToLineBoundary(t,!1).head;return t.head>i?i:Math.max(0,t.head-1)}),preventDefault:!0},{mac:"Mod-Delete",run:e=>dQ(e,t=>{let i=e.moveToLineBoundary(t,!0).head;return t.head<i?i:Math.min(e.state.doc.length,t.head+1)}),preventDefault:!0}].concat(us.map(e=>({mac:e.key,run:e.run,shift:e.shift})))),ul={key:"Tab",run:un,shift:ur},ua="function"==typeof String.prototype.normalize?e=>e.normalize("NFKD"):e=>e;class uh{constructor(e,t,i=0,n=e.length,r,s){this.test=s,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(i,n),this.bufferStart=i,this.normalize=r?e=>r(ua(e)):ua,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return -1;this.bufferPos=0,this.buffer=this.iter.value}return nm(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){var e;let t=this.peek();if(t<0)return this.done=!0,this;let i=(e=t)<=65535?String.fromCharCode(e):String.fromCharCode(((e-=65536)>>10)+55296,(1023&e)+56320),n=this.bufferStart+this.bufferPos;this.bufferPos+=ng(t);let r=this.normalize(i);if(r.length)for(let e=0,t=n;;e++){let s=r.charCodeAt(e),o=this.match(s,t,this.bufferPos+this.bufferStart);if(e==r.length-1){if(o)return this.value=o,this;break}t==n&&e<i.length&&i.charCodeAt(e)==s&&t++}}}match(e,t,i){let n=null;for(let t=0;t<this.matches.length;t+=2){let r=this.matches[t],s=!1;this.query.charCodeAt(r)==e&&(r==this.query.length-1?n={from:this.matches[t+1],to:i}:(this.matches[t]++,s=!0)),s||(this.matches.splice(t,2),t-=2)}return this.query.charCodeAt(0)==e&&(1==this.query.length?n={from:t,to:i}:this.matches.push(1,t)),n&&this.test&&!this.test(n.from,n.to,this.buffer,this.bufferStart)&&(n=null),n}}"undefined"!=typeof Symbol&&(uh.prototype[Symbol.iterator]=function(){return this});let uc={from:-1,to:-1,match:/.*/.exec("")},ud="gm"+(null==/x/.unicode?"":"u");class uu{constructor(e,t,i,n=0,r=e.length){if(this.text=e,this.to=r,this.curLine="",this.done=!1,this.value=uc,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new um(e,t,i,n,r);this.re=new RegExp(t,ud+((null==i?void 0:i.ignoreCase)?"i":"")),this.test=null==i?void 0:i.test,this.iter=e.iter();let s=e.lineAt(n);this.curLineStart=s.from,this.matchPos=ug(e,n),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine="":(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let i=this.curLineStart+t.index,n=i+t[0].length;if(this.matchPos=ug(this.text,n+(i==n?1:0)),i==this.curLineStart+this.curLine.length&&this.nextLine(),(i<n||i>this.value.to)&&(!this.test||this.test(i,n,t)))return this.value={from:i,to:n,match:t},this;e=this.matchPos-this.curLineStart}else{if(!(this.curLineStart+this.curLine.length<this.to))return this.done=!0,this;this.nextLine(),e=0}}}}let uf=new WeakMap;class up{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(e,t,i){let n=uf.get(e);if(!n||n.from>=i||n.to<=t){let n=new up(t,e.sliceString(t,i));return uf.set(e,n),n}if(n.from==t&&n.to==i)return n;let{text:r,from:s}=n;return s>t&&(r=e.sliceString(t,s)+r,s=t),n.to<i&&(r+=e.sliceString(n.to,i)),uf.set(e,new up(s,r)),new up(t,r.slice(t-s,i-s))}}class um{constructor(e,t,i,n,r){this.text=e,this.to=r,this.done=!1,this.value=uc,this.matchPos=ug(e,n),this.re=new RegExp(t,ud+((null==i?void 0:i.ignoreCase)?"i":"")),this.test=null==i?void 0:i.test,this.flat=up.get(e,n,this.chunkEnd(n+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let e=this.flat.from+t.index,i=e+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(e,i,t)))return this.value={from:e,to:i,match:t},this.matchPos=ug(this.text,i+(e==i?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=up.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+2*this.flat.text.length))}}}function ug(e,t){if(t>=e.length)return t;let i=e.lineAt(t),n;for(;t<i.to&&(n=i.text.charCodeAt(t-i.from))>=56320&&n<57344;)t++;return t}"undefined"!=typeof Symbol&&(uu.prototype[Symbol.iterator]=um.prototype[Symbol.iterator]=function(){return this});let ux={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},uv=nD.define({combine:e=>ri(e,ux,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}),uy=rQ.mark({class:"cm-selectionMatch"}),ub=rQ.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function uw(e,t,i,n){return(0==i||e(t.sliceDoc(i-1,i))!=n7.Word)&&(n==t.doc.length||e(t.sliceDoc(n,n+1))!=n7.Word)}let uk=sG.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.selectionSet||e.docChanged||e.viewportChanged)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=e.state.facet(uv),{state:i}=e,n=i.selection;if(n.ranges.length>1)return rQ.none;let r=n.main,s,o=null;if(r.empty){if(!t.highlightWordAroundCursor)return rQ.none;let e=i.wordAt(r.head);if(!e)return rQ.none;o=i.charCategorizer(r.head),s=i.sliceDoc(e.from,e.to)}else{let e=r.to-r.from;if(e<t.minSelectionLength||e>200)return rQ.none;if(t.wholeWords){var l,a,h;if(s=i.sliceDoc(r.from,r.to),!(uw(o=i.charCategorizer(r.head),i,r.from,r.to)&&(l=o,a=r.from,h=r.to,l(i.sliceDoc(a,a+1))==n7.Word&&l(i.sliceDoc(h-1,h))==n7.Word)))return rQ.none}else if(!(s=i.sliceDoc(r.from,r.to)))return rQ.none}let c=[];for(let n of e.visibleRanges){let e=new uh(i.doc,s,n.from,n.to);for(;!e.next().done;){let{from:n,to:s}=e.value;if((!o||uw(o,i,n,s))&&(r.empty&&n<=r.from&&s>=r.to?c.push(ub.range(n,s)):(n>=r.to||s<=r.from)&&c.push(uy.range(n,s)),c.length>t.maxMatches))return rQ.none}}return rQ.set(c)}},{decorations:e=>e.decorations}),uS=l$.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),uC=({state:e,dispatch:t})=>{let{selection:i}=e,n=nA.create(i.ranges.map(t=>e.wordAt(t.head)||nA.cursor(t.head)),i.mainIndex);return!n.eq(i)&&(t(e.update({selection:n})),!0)},uj=nD.define({combine:e=>ri(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new u0(e),scrollToMatch:e=>l$.scrollIntoView(e)})});class uM{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||"",this.valid=!!this.search&&(!this.regexp||function(e){try{return new RegExp(e,ud),!0}catch(e){return!1}}(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(e,t)=>"n"==t?"\n":"r"==t?"\r":"t"==t?" ":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new uP(this):new uT(this)}getCursor(e,t=0,i){let n=e.doc?e:rt.create({doc:e});return null==i&&(i=n.doc.length),this.regexp?uO(this,n,t,i):uA(this,n,t,i)}}class uZ{constructor(e){this.spec=e}}function uA(e,t,i,n){var r,s,o,l;let a;return e.wholeWord&&(r=t.doc,s=t.charCategorizer(t.selection.main.head),a=(e,t,i,n)=>((n>e||n+i.length<t)&&(n=Math.max(0,e-2),i=r.sliceString(n,Math.min(r.length,t+2))),(s(uD(i,e-n))!=n7.Word||s(uR(i,e-n))!=n7.Word)&&(s(uR(i,t-n))!=n7.Word||s(uD(i,t-n))!=n7.Word))),e.test&&(o=e.test,l=a,a=(e,i,n,r)=>(!l||!!l(e,i,n,r))&&o(e>=r&&i<=r+n.length?n.slice(e-r,i-r):t.doc.sliceString(e,i),t,e,i)),new uh(t.doc,e.unquoted,i,n,e.caseSensitive?void 0:e=>e.toLowerCase(),a)}class uT extends uZ{constructor(e){super(e)}nextMatch(e,t,i){let n=uA(this.spec,e,i,e.doc.length).nextOverlapping();if(n.done){let i=Math.min(e.doc.length,t+this.spec.unquoted.length);n=uA(this.spec,e,0,i).nextOverlapping()}return n.done||n.value.from==t&&n.value.to==i?null:n.value}prevMatchInRange(e,t,i){for(let n=i;;){let i=Math.max(t,n-1e4-this.spec.unquoted.length),r=uA(this.spec,e,i,n),s=null;for(;!r.nextOverlapping().done;)s=r.value;if(s)return s;if(i==t)return null;n-=1e4}}prevMatch(e,t,i){let n=this.prevMatchInRange(e,0,t);return n||(n=this.prevMatchInRange(e,Math.max(0,i-this.spec.unquoted.length),e.doc.length)),n&&(n.from!=t||n.to!=i)?n:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let i=uA(this.spec,e,0,e.doc.length),n=[];for(;!i.next().done;){if(n.length>=t)return null;n.push(i.value)}return n}highlight(e,t,i,n){let r=uA(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(i+this.spec.unquoted.length,e.doc.length));for(;!r.next().done;)n(r.value.from,r.value.to)}}function uO(e,t,i,n){var r,s,o;let l;return e.wholeWord&&(r=t.charCategorizer(t.selection.main.head),l=(e,t,i)=>!i[0].length||(r(uD(i.input,i.index))!=n7.Word||r(uR(i.input,i.index))!=n7.Word)&&(r(uR(i.input,i.index+i[0].length))!=n7.Word||r(uD(i.input,i.index+i[0].length))!=n7.Word)),e.test&&(s=e.test,o=l,l=(e,i,n)=>(!o||o(e,i,n))&&s(n[0],t,e,i)),new uu(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:l},i,n)}function uD(e,t){return e.slice(np(e,t,!1),t)}function uR(e,t){return e.slice(t,np(e,t))}class uP extends uZ{nextMatch(e,t,i){let n=uO(this.spec,e,i,e.doc.length).next();return n.done&&(n=uO(this.spec,e,0,t).next()),n.done?null:n.value}prevMatchInRange(e,t,i){for(let n=1;;n++){let r=Math.max(t,i-1e4*n),s=uO(this.spec,e,r,i),o=null;for(;!s.next().done;)o=s.value;if(o&&(r==t||o.from>r+10))return o;if(r==t)return null}}prevMatch(e,t,i){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,i,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,i)=>{if("&"==i)return e.match[0];if("$"==i)return"$";for(let t=i.length;t>0;t--){let n=+i.slice(0,t);if(n>0&&n<e.match.length)return e.match[n]+i.slice(t)}return t})}matchAll(e,t){let i=uO(this.spec,e,0,e.doc.length),n=[];for(;!i.next().done;){if(n.length>=t)return null;n.push(i.value)}return n}highlight(e,t,i,n){let r=uO(this.spec,e,Math.max(0,t-250),Math.min(i+250,e.doc.length));for(;!r.next().done;)n(r.value.from,r.value.to)}}let uL=n5.define(),uI=n5.define(),uE=nB.define({create:e=>new uB(u_(e).create(),null),update(e,t){for(let i of t.effects)i.is(uL)?e=new uB(i.value.create(),e.panel):i.is(uI)&&(e=new uB(e.query,i.value?uU:null));return e},provide:e=>aB.from(e,e=>e.panel)});class uB{constructor(e,t){this.query=e,this.panel=t}}let uN=rQ.mark({class:"cm-searchMatch"}),uz=rQ.mark({class:"cm-searchMatch cm-searchMatch-selected"}),uW=sG.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(uE))}update(e){let t=e.state.field(uE);(t!=e.startState.field(uE)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return rQ.none;let{view:i}=this,n=new rh;for(let t=0,r=i.visibleRanges,s=r.length;t<s;t++){let{from:o,to:l}=r[t];for(;t<s-1&&l>r[t+1].from-500;)l=r[++t].to;e.highlight(i.state,o,l,(e,t)=>{let r=i.state.selection.ranges.some(i=>i.from==e&&i.to==t);n.add(e,t,r?uz:uN)})}return n.finish()}},{decorations:e=>e.decorations});function uF(e){return t=>{let i=t.state.field(uE,!1);return i&&i.query.spec.valid?e(t,i):uX(t)}}let uV=uF((e,{query:t})=>{let{to:i}=e.state.selection.main,n=t.nextMatch(e.state,i,i);if(!n)return!1;let r=nA.single(n.from,n.to),s=e.state.facet(uj);return e.dispatch({selection:r,effects:[u5(e,n),s.scrollToMatch(r.main,e)],userEvent:"select.search"}),uJ(e),!0}),uH=uF((e,{query:t})=>{let{state:i}=e,{from:n}=i.selection.main,r=t.prevMatch(i,n,n);if(!r)return!1;let s=nA.single(r.from,r.to),o=e.state.facet(uj);return e.dispatch({selection:s,effects:[u5(e,r),o.scrollToMatch(s.main,e)],userEvent:"select.search"}),uJ(e),!0}),u$=uF((e,{query:t})=>{let i=t.matchAll(e.state,1e3);return!!i&&!!i.length&&(e.dispatch({selection:nA.create(i.map(e=>nA.range(e.from,e.to))),userEvent:"select.search.matches"}),!0)}),uq=uF((e,{query:t})=>{let{state:i}=e,{from:n,to:r}=i.selection.main;if(i.readOnly)return!1;let s=t.nextMatch(i,n,n);if(!s)return!1;let o=s,l=[],a,h,c=[];o.from==n&&o.to==r&&(h=i.toText(t.getReplacement(o)),l.push({from:o.from,to:o.to,insert:h}),o=t.nextMatch(i,o.from,o.to),c.push(l$.announce.of(i.phrase("replaced match on line $",i.doc.lineAt(n).number)+".")));let d=e.state.changes(l);return o&&(a=nA.single(o.from,o.to).map(d),c.push(u5(e,o)),c.push(i.facet(uj).scrollToMatch(a.main,e))),e.dispatch({changes:d,selection:a,effects:c,userEvent:"input.replace"}),!0}),uK=uF((e,{query:t})=>{if(e.state.readOnly)return!1;let i=t.matchAll(e.state,1e9).map(e=>{let{from:i,to:n}=e;return{from:i,to:n,insert:t.getReplacement(e)}});if(!i.length)return!1;let n=e.state.phrase("replaced $ matches",i.length)+".";return e.dispatch({changes:i,effects:l$.announce.of(n),userEvent:"input.replace.all"}),!0});function uU(e){return e.state.facet(uj).createPanel(e)}function u_(e,t){var i,n,r,s,o;let l=e.selection.main,a=l.empty||l.to>l.from+100?"":e.sliceDoc(l.from,l.to);if(t&&!a)return t;let h=e.facet(uj);return new uM({search:(null!==(i=null==t?void 0:t.literal)&&void 0!==i?i:h.literal)?a:a.replace(/\n/g,"\\n"),caseSensitive:null!==(n=null==t?void 0:t.caseSensitive)&&void 0!==n?n:h.caseSensitive,literal:null!==(r=null==t?void 0:t.literal)&&void 0!==r?r:h.literal,regexp:null!==(s=null==t?void 0:t.regexp)&&void 0!==s?s:h.regexp,wholeWord:null!==(o=null==t?void 0:t.wholeWord)&&void 0!==o?o:h.wholeWord})}function uG(e){let t=aP(e,uU);return t&&t.dom.querySelector("[main-field]")}function uJ(e){let t=uG(e);t&&t==e.root.activeElement&&t.select()}let uX=e=>{let t=e.state.field(uE,!1);if(t&&t.panel){let i=uG(e);if(i&&i!=e.root.activeElement){let n=u_(e.state,t.query.spec);n.valid&&e.dispatch({effects:uL.of(n)}),i.focus(),i.select()}}else e.dispatch({effects:[uI.of(!0),t?uL.of(u_(e.state,t.query.spec)):n5.appendConfig.of(u6)]});return!0},uY=e=>{let t=e.state.field(uE,!1);if(!t||!t.panel)return!1;let i=aP(e,uU);return i&&i.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:uI.of(!1)}),!0},uQ=[{key:"Mod-f",run:uX,scope:"editor search-panel"},{key:"F3",run:uV,shift:uH,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:uV,shift:uH,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:uY,scope:"editor search-panel"},{key:"Mod-Shift-l",run:({state:e,dispatch:t})=>{let i=e.selection;if(i.ranges.length>1||i.main.empty)return!1;let{from:n,to:r}=i.main,s=[],o=0;for(let t=new uh(e.doc,e.sliceDoc(n,r));!t.next().done;){if(s.length>1e3)return!1;t.value.from==n&&(o=s.length),s.push(nA.range(t.value.from,t.value.to))}return t(e.update({selection:nA.create(s,o),userEvent:"select.search.matches"})),!0}},{key:"Mod-Alt-g",run:e=>{let{state:t}=e,i=String(t.doc.lineAt(e.state.selection.main.head).number),{close:n,result:r}=function(e,t){let i;let n=new Promise(e=>i=e),r=e=>(function(e,t,i){let n=t.content?t.content(e,()=>o(null)):null;if(!n){if(n=rL("form"),t.input){let e=rL("input",t.input);/^(text|password|number|email|tel|url)$/.test(e.type)&&e.classList.add("cm-textfield"),e.name||(e.name="input"),n.appendChild(rL("label",(t.label||"")+": ",e))}else n.appendChild(document.createTextNode(t.label||""));n.appendChild(document.createTextNode(" ")),n.appendChild(rL("button",{class:"cm-button",type:"submit"},t.submitLabel||"OK"))}let r="FORM"==n.nodeName?[n]:n.querySelectorAll("form");for(let e=0;e<r.length;e++){let t=r[e];t.addEventListener("keydown",e=>{27==e.keyCode?(e.preventDefault(),o(null)):13==e.keyCode&&(e.preventDefault(),o(t))}),t.addEventListener("submit",e=>{e.preventDefault(),o(t)})}let s=rL("div",n,rL("button",{onclick:()=>o(null),"aria-label":e.state.phrase("close"),class:"cm-dialog-close",type:"button"},["\xd7"]));function o(t){s.contains(s.ownerDocument.activeElement)&&e.focus(),i(t)}return t.class&&(s.className=t.class),s.classList.add("cm-dialog"),{dom:s,top:t.top,mount:()=>{if(t.focus){let e;(e="string"==typeof t.focus?n.querySelector(t.focus):n.querySelector("input")||n.querySelector("button"))&&"select"in e?e.select():e&&"focus"in e&&e.focus()}}}})(e,t,i);e.state.field(aN,!1)?e.dispatch({effects:az.of(r)}):e.dispatch({effects:n5.appendConfig.of(aN.init(()=>[r]))});let s=aW.of(r);return{close:s,result:n.then(t=>((e.win.queueMicrotask||(t=>e.win.setTimeout(t,10)))(()=>{e.state.field(aN).indexOf(r)>-1&&e.dispatch({effects:s})}),t))}}(e,{label:t.phrase("Go to line"),input:{type:"text",name:"line",value:i},focus:!0,submitLabel:t.phrase("go")});return r.then(i=>{let r=i&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(i.elements.line.value);if(!r){e.dispatch({effects:n});return}let s=t.doc.lineAt(t.selection.main.head),[,o,l,a,h]=r,c=a?+a.slice(1):0,d=l?+l:s.number;if(l&&h){let e=d/100;o&&(e=e*("-"==o?-1:1)+s.number/t.doc.lines),d=Math.round(t.doc.lines*e)}else l&&o&&(d=d*("-"==o?-1:1)+s.number);let u=t.doc.line(Math.max(1,Math.min(t.doc.lines,d))),f=nA.cursor(u.from+Math.max(0,Math.min(c,u.length)));e.dispatch({effects:[n,l$.scrollIntoView(f.from,{y:"center"})],selection:f})}),!0}},{key:"Mod-d",run:({state:e,dispatch:t})=>{let{ranges:i}=e.selection;if(i.some(e=>e.from===e.to))return uC({state:e,dispatch:t});let n=e.sliceDoc(i[0].from,i[0].to);if(e.selection.ranges.some(t=>e.sliceDoc(t.from,t.to)!=n))return!1;let r=function(e,t){let{main:i,ranges:n}=e.selection,r=e.wordAt(i.head),s=r&&r.from==i.from&&r.to==i.to;for(let i=!1,r=new uh(e.doc,t,n[n.length-1].to);;)if(r.next(),r.done){if(i)return null;r=new uh(e.doc,t,0,Math.max(0,n[n.length-1].from-1)),i=!0}else{if(i&&n.some(e=>e.from==r.value.from))continue;if(s){let t=e.wordAt(r.value.from);if(!t||t.from!=r.value.from||t.to!=r.value.to)continue}return r.value}}(e,n);return!!r&&(t(e.update({selection:e.selection.addRange(nA.range(r.from,r.to),!1),effects:l$.scrollIntoView(r.to)})),!0)},preventDefault:!0}];class u0{constructor(e){this.view=e;let t=this.query=e.state.field(uE).query.spec;function i(e,t,i){return rL("button",{class:"cm-button",name:e,onclick:t,type:"button"},i)}this.commit=this.commit.bind(this),this.searchField=rL("input",{value:t.search,placeholder:u1(e,"Find"),"aria-label":u1(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=rL("input",{value:t.replace,placeholder:u1(e,"Replace"),"aria-label":u1(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=rL("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=rL("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=rL("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit}),this.dom=rL("div",{onkeydown:e=>this.keydown(e),class:"cm-search"},[this.searchField,i("next",()=>uV(e),[u1(e,"next")]),i("prev",()=>uH(e),[u1(e,"previous")]),i("select",()=>u$(e),[u1(e,"all")]),rL("label",null,[this.caseField,u1(e,"match case")]),rL("label",null,[this.reField,u1(e,"regexp")]),rL("label",null,[this.wordField,u1(e,"by word")]),...e.state.readOnly?[]:[rL("br"),this.replaceField,i("replace",()=>uq(e),[u1(e,"replace")]),i("replaceAll",()=>uK(e),[u1(e,"replace all")])],rL("button",{name:"close",onclick:()=>uY(e),"aria-label":u1(e,"close"),type:"button"},["\xd7"])])}commit(){let e=new uM({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:uL.of(e)}))}keydown(e){var t,i;(t=this.view,i="search-panel",l5(l0(t.state),e,t,i))?e.preventDefault():13==e.keyCode&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?uH:uV)(this.view)):13==e.keyCode&&e.target==this.replaceField&&(e.preventDefault(),uq(this.view))}update(e){for(let t of e.transactions)for(let e of t.effects)e.is(uL)&&!e.value.eq(this.query)&&this.setQuery(e.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(uj).top}}function u1(e,t){return e.state.phrase(t)}let u2=/[\s\.,:;?!]/;function u5(e,{from:t,to:i}){let n=e.state.doc.lineAt(t),r=e.state.doc.lineAt(i).to,s=Math.max(n.from,t-30),o=Math.min(r,i+30),l=e.state.sliceDoc(s,o);if(s!=n.from){for(let e=0;e<30;e++)if(!u2.test(l[e+1])&&u2.test(l[e])){l=l.slice(e);break}}if(o!=r){for(let e=l.length-1;e>l.length-30;e--)if(!u2.test(l[e-1])&&u2.test(l[e])){l=l.slice(0,e);break}}return l$.announce.of(`${e.state.phrase("current match")}. ${l} ${e.state.phrase("on line")} ${n.number}.`)}let u4=l$.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),u6=[uE,nW.low(uW),u4],u3="#e06c75",u8="#abb2bf",u9="#7d8799",u7="#d19a66",fe="#2c313a",ft="#282c34",fi="#353a42",fn="#528bff",fr=[l$.theme({"&":{color:u8,backgroundColor:ft},".cm-content":{caretColor:fn},".cm-cursor, .cm-dropCursor":{borderLeftColor:fn},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:"#3E4451"},".cm-panels":{backgroundColor:"#21252b",color:u8},".cm-panels.cm-panels-top":{borderBottom:"2px solid black"},".cm-panels.cm-panels-bottom":{borderTop:"2px solid black"},".cm-searchMatch":{backgroundColor:"#72a1ff59",outline:"1px solid #457dff"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"#6199ff2f"},".cm-activeLine":{backgroundColor:"#6699ff0b"},".cm-selectionMatch":{backgroundColor:"#aafe661a"},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bad0f847"},".cm-gutters":{backgroundColor:ft,color:u9,border:"none"},".cm-activeLineGutter":{backgroundColor:fe},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:fi},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:fi,borderBottomColor:fi},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:fe,color:u8}}},{dark:!0}),cL(cO.define([{tag:hY.keyword,color:"#c678dd"},{tag:[hY.name,hY.deleted,hY.character,hY.propertyName,hY.macroName],color:u3},{tag:[hY.function(hY.variableName),hY.labelName],color:"#61afef"},{tag:[hY.color,hY.constant(hY.name),hY.standard(hY.name)],color:u7},{tag:[hY.definition(hY.name),hY.separator],color:u8},{tag:[hY.typeName,hY.className,hY.number,hY.changed,hY.annotation,hY.modifier,hY.self,hY.namespace],color:"#e5c07b"},{tag:[hY.operator,hY.operatorKeyword,hY.url,hY.escape,hY.regexp,hY.link,hY.special(hY.string)],color:"#56b6c2"},{tag:[hY.meta,hY.comment],color:u9},{tag:hY.strong,fontWeight:"bold"},{tag:hY.emphasis,fontStyle:"italic"},{tag:hY.strikethrough,textDecoration:"line-through"},{tag:hY.link,color:u9,textDecoration:"underline"},{tag:hY.heading,fontWeight:"bold",color:u3},{tag:[hY.atom,hY.bool,hY.special(hY.variableName)],color:u7},{tag:[hY.processingInstruction,hY.string,hY.inserted],color:"#98c379"},{tag:hY.invalid,color:"#ffffff"}]))],fs=(0,c.forwardRef)(function({serverName:e,filePath:t,onDirtyChange:i},n){let r=(0,c.useRef)(null),s=(0,c.useRef)(null),[o,l]=(0,c.useState)(!1),[a,d]=(0,c.useState)({line:1,col:1}),{data:u,isLoading:p,error:m}=t3(e,t),v=t8(e),y=(0,c.useCallback)(()=>{if(!s.current)return;let e=s.current.state.doc.toString();v.mutate({path:t,content:e},{onSuccess:()=>{l(!1),i(!1)}})},[t,v,i]);return((0,c.useImperativeHandle)(n,()=>({save:y,isDirty:()=>o}),[y,o]),(0,c.useEffect)(()=>{i(o)},[o,i]),(0,c.useEffect)(()=>{let e;if(!r.current||!u)return;s.current&&(s.current.destroy(),s.current=null);let n=lY.of([{key:"Mod-s",run:()=>(setTimeout(()=>{if(!s.current)return;let e=s.current.state.doc.toString();v.mutate({path:t,content:e},{onSuccess:()=>{l(!1),i(!1)}})},0),!0),preventDefault:!0}]),o=l$.updateListener.of(e=>{if(e.docChanged&&l(!0),e.selectionSet||e.docChanged){let t=e.state.selection.main.head,i=e.state.doc.lineAt(t);d({line:i.number,col:t-i.from+1})}}),a=rt.create({doc:u.content,extensions:[function(e={}){return[a2.of(e),aU(),a6]}(),av,function(e={}){return[af.of(e),ap||(ap=sG.fromClass(class{constructor(e){this.view=e,this.decorations=rQ.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(e.state.facet(af)),this.decorations=this.decorator.createDeco(e)}makeDecorator(e){return new aa({regexp:e.specialChars,decoration:(t,i,n)=>{let{doc:r}=i.state,s=nm(t[0],0);if(9==s){let e=r.lineAt(n),t=i.state.tabSize,s=rb(e.text,t,n-e.from);return rQ.replace({widget:new ag((t-s%t)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[s]||(this.decorationCache[s]=rQ.replace({widget:new am(e,s)}))},boundary:e.replaceTabs?void 0:/[^]/})}update(e){let t=e.state.facet(af);e.startState.facet(af)!=t?(this.decorator=this.makeDecorator(t),this.decorations=this.decorator.createDeco(e.view)):this.decorations=this.decorator.updateDeco(e,this.decorations)}},{decorations:e=>e.decorations}))]}(),function(e={}){return[dn,di.of(e),l$.domEventHandlers({beforeinput(e,t){let i="historyUndo"==e.inputType?ds:"historyRedo"==e.inputType?dl:null;return!!i&&(e.preventDefault(),i(t))}})]}(),function(e={}){var t;let i;let n={...cZ,...e},r=new cA(n,!0),s=new cA(n,!1),o=sG.fromClass(class{constructor(e){this.from=e.viewport.from,this.markers=this.buildMarkers(e)}update(e){(e.docChanged||e.viewportChanged||e.startState.facet(ci)!=e.state.facet(ci)||e.startState.field(cy,!1)!=e.state.field(cy,!1)||h5(e.startState)!=h5(e.state)||n.foldingChanged(e))&&(this.markers=this.buildMarkers(e.view))}buildMarkers(e){let t=new rh;for(let i of e.viewportLineBlocks){let n=cw(e.state,i.from,i.to)?s:cm(e.state,i.from,i.to)?r:null;n&&t.add(i.from,i.from,n)}return t.finish()}}),{domEventHandlers:l}=n;return[o,(t={class:"cm-foldGutter",markers(e){var t;return(null===(t=e.plugin(o))||void 0===t?void 0:t.markers)||ra.empty},initialSpacer:()=>new cA(n,!1),domEventHandlers:{...l,click:(e,t,i)=>{if(l.click&&l.click(e,t,i))return!0;let n=cw(e.state,t.from,t.to);if(n)return e.dispatch({effects:cv.of(n)}),!0;let r=cm(e.state,t.from,t.to);return!!r&&(e.dispatch({effects:cx.of(r)}),!0)}}},[aU(),aq.of({...a$,...t})]),i=[cy,cT]]}(),function(e={}){return[ae.of(e),ai,ar,as,sW.of(!0)]}(),(e=e=>e.altKey&&0==e.button,l$.mouseSelectionStyle.of((t,i)=>{let n,r;return e(i)?(n=ay(t,i),r=t.state.selection,n?{update(e){if(e.docChanged){let t=e.changes.mapPos(e.startState.doc.line(n.line).from),i=e.state.doc.lineAt(t);n={line:i.number,col:n.col,off:Math.min(n.off,i.length)},r=r.map(e.changes)}},get(e,i,s){let o=ay(t,e);if(!o)return r;let l=function(e,t,i){let n=Math.min(t.line,i.line),r=Math.max(t.line,i.line),s=[];if(t.off>2e3||i.off>2e3||t.col<0||i.col<0){let o=Math.min(t.off,i.off),l=Math.max(t.off,i.off);for(let t=n;t<=r;t++){let i=e.doc.line(t);i.length<=l&&s.push(nA.range(i.from+o,i.to+l))}}else{let o=Math.min(t.col,i.col),l=Math.max(t.col,i.col);for(let t=n;t<=r;t++){let i=e.doc.line(t),n=rw(i.text,o,e.tabSize,!0);if(n<0)s.push(nA.cursor(i.to));else{let t=rw(i.text,l,e.tabSize);s.push(nA.range(i.from+n,i.from+t))}}}return s}(t.state,n,o);return l.length?s?nA.create(l.concat(r.ranges)):nA.create(l):r}}:null):null})),rt.transactionFilter.of(e=>{if(!e.docChanged||!e.isUserEvent("input.type")&&!e.isUserEvent("input.complete"))return e;let t=e.startState.languageDataAt("indentOnInput",e.startState.selection.main.head);if(!t.length)return e;let i=e.newDoc,{head:n}=e.newSelection.main,r=i.lineAt(n);if(n>r.from+200)return e;let s=i.sliceString(r.from,n);if(!t.some(e=>e.test(s)))return e;let{state:o}=e,l=-1,a=[];for(let{head:e}of o.selection.ranges){let t=o.doc.lineAt(e);if(t.from==l)continue;l=t.from;let i=cl(o,t.from);if(null==i)continue;let n=/^\s*/.exec(t.text)[0],r=co(o,i);n!=r&&a.push({from:t.from,to:t.from+n.length,insert:r})}return a.length?[e,{changes:a,sequential:!0}]:e}),function(e={}){return[cW.of(e),c$]}(),[uS,uk],cL(cB,{fallback:!0}),fr,n,lY.of([...uo,...dv,...uQ,ul]),o,l$.lineWrapping,l$.theme({"&":{height:"100%",fontSize:"13px"},".cm-scroller":{overflow:"auto"},".cm-content":{fontFamily:'"Fira Code", "Cascadia Code", "JetBrains Mono", "Consolas", monospace'},".cm-gutters":{fontFamily:'"Fira Code", "Cascadia Code", "JetBrains Mono", "Consolas", monospace'}})]}),h=new l$({state:a,parent:r.current});return s.current=h,()=>{h.destroy(),s.current=null}},[u,t]),p)?h.jsx(f.Z,{sx:{display:"flex",justifyContent:"center",alignItems:"center",flex:1},children:h.jsx(x.Z,{})}):m?(0,h.jsxs)(g.Z,{severity:"error",sx:{m:2},children:["Failed to load file: ",m.message]}):(0,h.jsxs)(f.Z,{sx:{display:"flex",flexDirection:"column",flex:1,overflow:"hidden"},children:[v.isError&&(0,h.jsxs)(g.Z,{severity:"error",sx:{mx:2,mt:1},children:["Failed to save: ",v.error.message]}),v.isSuccess&&!o&&h.jsx(g.Z,{severity:"success",sx:{mx:2,mt:1},children:"File saved successfully."}),u&&h.jsx(f.Z,{ref:r,sx:{flex:1,overflow:"hidden"}}),u&&h.jsx(iT,{language:"Properties",fileSize:u.size,line:a.line,col:a.col,dirty:o})]})});function fo({serverName:e,onBack:t}){let[i,n]=(0,c.useState)("form"),[r,s]=(0,c.useState)(!1),[o,l]=(0,c.useState)(null),a=(0,c.useRef)(null),d=(0,c.useCallback)((e,t)=>{t&&t!==i&&("raw"===i&&r?l("form"):n(t))},[i,r]),u=(0,c.useCallback)(()=>{"raw"===i&&r?l("back"):t()},[i,r,t]),g=(0,c.useCallback)(()=>{l(null),s(!1),"back"===o?t():"form"===o&&n("form")},[o,t]),x=(0,c.useCallback)(()=>{a.current?.save()},[]);return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(y.Z,{sx:{borderRadius:3,display:"flex",flexDirection:"column",minHeight:600},children:[(0,h.jsxs)(f.Z,{sx:{display:"flex",alignItems:"center",gap:1,px:2,py:1,borderBottom:1,borderColor:"divider"},children:[h.jsx(m.Z,{size:"small",onClick:u,"aria-label":"back",children:h.jsx(P.Z,{})}),h.jsx(i_.Z,{sx:{color:"primary.main"}}),h.jsx(w.Z,{variant:"subtitle1",sx:{fontWeight:600,flex:1},noWrap:!0,children:"server.properties"}),(0,h.jsxs)(iK.Z,{value:i,exclusive:!0,onChange:d,size:"small",children:[(0,h.jsxs)(iU.Z,{value:"form",children:[h.jsx(iG.Z,{fontSize:"small",sx:{mr:.5}}),"Form"]}),(0,h.jsxs)(iU.Z,{value:"raw",children:[h.jsx(iN.Z,{fontSize:"small",sx:{mr:.5}}),"Raw"]})]}),"raw"===i&&h.jsx(p.Z,{size:"small",variant:"contained",startIcon:h.jsx(eb.Z,{}),onClick:x,disabled:!r,children:"Save"})]}),h.jsx(b.Z,{sx:{flex:1,overflow:"auto",p:0,"&:last-child":{pb:0}},children:"form"===i?h.jsx(i3,{serverName:e}):h.jsx(f.Z,{sx:{display:"flex",flexDirection:"column",height:"100%",minHeight:500},children:h.jsx(fs,{ref:a,serverName:e,filePath:"/server.properties",onDirtyChange:s})})})]}),h.jsx(M.Z,{open:null!==o,onClose:()=>l(null),maxWidth:"xs",fullWidth:!0,children:(0,h.jsxs)(f.Z,{sx:{p:3},children:[h.jsx(w.Z,{variant:"h6",gutterBottom:!0,children:"Unsaved Changes"}),h.jsx(w.Z,{variant:"body2",color:"text.secondary",sx:{mb:3},children:"You have unsaved changes in the raw editor. Do you want to discard them?"}),(0,h.jsxs)(f.Z,{sx:{display:"flex",justifyContent:"flex-end",gap:1},children:[h.jsx(p.Z,{onClick:()=>l(null),children:"Cancel"}),h.jsx(p.Z,{onClick:g,color:"error",variant:"contained",children:"Discard"})]})]})})]})}var fl=i(40238);function fa(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:e<1073741824?`${(e/1024/1024).toFixed(1)} MB`:`${(e/1024/1024/1024).toFixed(1)} GB`}function fh({open:e,isPending:t,onUpload:i,onClose:n}){let[r,s]=(0,c.useState)([]),[o,l]=(0,c.useState)(!1),a=(0,c.useRef)(null),d=r.filter(e=>e.size>104857600),u=(0,c.useCallback)(e=>{let t=Array.from(e);s(e=>{let i=new Set(e.map(e=>e.name));return[...e,...t.filter(e=>!i.has(e.name))]})},[]),x=(0,c.useCallback)(e=>{s(t=>t.filter(t=>t.name!==e))},[]),v=(0,c.useCallback)(e=>{e.preventDefault(),l(!1),e.dataTransfer.files.length&&u(e.dataTransfer.files)},[u]),y=(0,c.useCallback)(()=>{r.length>0&&0===d.length&&i(r)},[r,d,i]),b=(0,c.useCallback)(()=>{t||(s([]),n())},[t,n]);return(0,h.jsxs)(M.Z,{open:e,onClose:b,maxWidth:"sm",fullWidth:!0,children:[h.jsx(Z.Z,{children:"Upload Files"}),(0,h.jsxs)(A.Z,{children:[(0,h.jsxs)(f.Z,{onDragOver:e=>{e.preventDefault(),l(!0)},onDragLeave:()=>l(!1),onDrop:v,onClick:()=>a.current?.click(),sx:{border:"2px dashed",borderColor:o?"primary.main":"divider",borderRadius:2,p:4,textAlign:"center",cursor:"pointer",bgcolor:o?"action.hover":"transparent",transition:"all 0.2s","&:hover":{borderColor:"primary.main",bgcolor:"action.hover"}},children:[h.jsx(fl.Z,{sx:{fontSize:48,color:"text.secondary",mb:1}}),h.jsx(w.Z,{variant:"body1",color:"text.secondary",children:"Drag & drop files here, or click to browse"}),(0,h.jsxs)(w.Z,{variant:"caption",color:"text.secondary",children:["Max ",fa(104857600)," per file"]})]}),h.jsx("input",{ref:a,type:"file",multiple:!0,hidden:!0,onChange:e=>{e.target.files?.length&&(u(e.target.files),e.target.value="")}}),r.length>0&&h.jsx(en.Z,{dense:!0,sx:{mt:2},children:r.map(e=>(0,h.jsxs)(er.ZP,{secondaryAction:h.jsx(m.Z,{edge:"end",size:"small",onClick:()=>x(e.name),disabled:t,children:h.jsx(E.Z,{fontSize:"small"})}),children:[h.jsx(C.Z,{children:h.jsx(iv.Z,{})}),h.jsx(j.Z,{primary:e.name,secondary:fa(e.size),primaryTypographyProps:{noWrap:!0,color:e.size>104857600?"error":"text.primary"}})]},e.name))}),d.length>0&&h.jsx(g.Z,{severity:"error",sx:{mt:1},children:1===d.length?`"${d[0].name}" exceeds the ${fa(104857600)} limit`:`${d.length} files exceed the ${fa(104857600)} limit`}),t&&h.jsx(Q.Z,{sx:{mt:2}})]}),(0,h.jsxs)(T.Z,{children:[h.jsx(p.Z,{onClick:b,disabled:t,children:"Cancel"}),(0,h.jsxs)(p.Z,{onClick:y,variant:"contained",startIcon:h.jsx(fl.Z,{}),disabled:t||0===r.length||d.length>0,children:["Upload ",r.length>0?`(${r.length})`:""]})]})]})}function fc({serverName:e}){let[t,i]=(0,c.useState)("/"),[n,r]=(0,c.useState)(""),[s,o]=(0,c.useState)({open:!1,message:"",severity:"info"}),[l,a]=(0,c.useState)(null),[d,u]=(0,c.useState)(null),[f,p]=(0,c.useState)(null),[m,x]=(0,c.useState)(null),[w,k]=(0,c.useState)(null),[S,C]=(0,c.useState)(null),[j,M]=(0,c.useState)(!1),{data:Z,isLoading:A,error:T,refetch:O}=function(e,t="/"){return(0,tK.a)({queryKey:["servers",e,"files",t],queryFn:()=>{let i=new URLSearchParams({path:t});return(0,tG.SC)(`/api/servers/${encodeURIComponent(e)}/files?${i}`)},enabled:!!e})}(e,t),D=function(e){let t=(0,tU.NL)();return(0,t_.D)({mutationFn:({path:t})=>{let i=new URLSearchParams({path:t});return(0,tG.SC)(`/api/servers/${encodeURIComponent(e)}/files?${i}`,{method:"DELETE"})},onSuccess:()=>{t.invalidateQueries({queryKey:["servers",e,"files"]})}})}(e),R=function(e){let t=(0,tU.NL)();return(0,t_.D)({mutationFn:({path:t})=>{let i=new URLSearchParams({path:t});return(0,tG.SC)(`/api/servers/${encodeURIComponent(e)}/files/mkdir?${i}`,{method:"POST"})},onSuccess:()=>{t.invalidateQueries({queryKey:["servers",e,"files"]})}})}(e),P=function(e){let t=(0,tU.NL)();return(0,t_.D)({mutationFn:({oldPath:t,newPath:i})=>(0,tG.SC)(`/api/servers/${encodeURIComponent(e)}/files/rename`,{method:"POST",body:JSON.stringify({oldPath:t,newPath:i})}),onSuccess:()=>{t.invalidateQueries({queryKey:["servers",e,"files"]})}})}(e),L=function(e){let t=(0,tU.NL)();return(0,t_.D)({mutationFn:async({path:t,files:i})=>{let n=new FormData;for(let e of i)n.append("files",e);let r=new URLSearchParams({path:t}),s=await fetch(`/api/servers/${encodeURIComponent(e)}/files/upload?${r}`,{method:"POST",body:n});if(!s.ok){let e=await s.json().catch(()=>({error:"UnknownError",message:s.statusText})),t=Error(e.message);throw t.statusCode=s.status,t.code=e.error,t}return s.json()},onSuccess:()=>{t.invalidateQueries({queryKey:["servers",e,"files"]})}})}(e),I=(0,c.useCallback)((e,t="success")=>{o({open:!0,message:e,severity:t})},[]),E=(0,c.useCallback)(e=>{i(e),r("")},[]),B=(0,c.useCallback)(e=>{let i="/"===t?`/${e}`:`${t}/${e}`;R.mutate({path:i},{onSuccess:()=>I(`Folder "${e}" created`),onError:e=>I(e.message,"error")})},[t,R,I]),N=(0,c.useCallback)((i,n)=>{switch(i){case"delete":a(n);break;case"rename":u(n);break;case"download":!function(e,t){let i=new URLSearchParams({path:t}),n=`/api/servers/${encodeURIComponent(e)}/files/download?${i}`,r=document.createElement("a");r.href=n,r.download="",document.body.appendChild(r),r.click(),document.body.removeChild(r)}(e,"/"===t?`/${n.name}`:`${t}/${n.name}`);break;case"open":{let e="/"===t?`/${n.name}`:`${t}/${n.name}`;if("/"===t&&"server.properties"===n.name)C(e);else{let i="/"===t?function(e){switch(e){case"whitelist.json":return"whitelist";case"ops.json":return"ops";case"banned-players.json":return"bans";default:return null}}(n.name):null;i?(x(i),k(e)):p(e)}}}},[t,e]),z=(0,c.useCallback)(e=>{L.mutate({path:t,files:e},{onSuccess:e=>{I(`${e.files.length} file(s) uploaded`),M(!1)},onError:e=>{I(e.message,"error")}})},[t,L,I]),W=(0,c.useCallback)(()=>{if(!l)return;let e="/"===t?`/${l.name}`:`${t}/${l.name}`;D.mutate({path:e},{onSuccess:()=>{I(`"${l.name}" deleted`),a(null)},onError:e=>{I(e.message,"error"),a(null)}})},[l,t,D,I]),F=(0,c.useCallback)(e=>{if(!d)return;let i="/"===t?`/${d.name}`:`${t}/${d.name}`,n="/"===t?`/${e}`:`${t}/${e}`;P.mutate({oldPath:i,newPath:n},{onSuccess:()=>{I(`Renamed to "${e}"`),u(null)},onError:e=>{I(e.message,"error"),u(null)}})},[d,t,P,I]),V=(0,c.useMemo)(()=>(Z?.files||[]).map(e=>e.name),[Z?.files]);return A?h.jsx(y.Z,{sx:{borderRadius:3},children:(0,h.jsxs)(b.Z,{children:[h.jsx(v.Z,{variant:"text",width:300,height:32,sx:{mb:2}}),h.jsx(v.Z,{variant:"rectangular",height:40,sx:{mb:2}}),[1,2,3,4,5].map(e=>h.jsx(v.Z,{variant:"rectangular",height:48,sx:{mb:.5}},e))]})}):T?(0,h.jsxs)(g.Z,{severity:"error",sx:{borderRadius:3},children:["Failed to load files: ",T.message]}):S?h.jsx(fo,{serverName:e,onBack:()=>C(null)}):f?h.jsx(iO,{serverName:e,filePath:f,onBack:()=>p(null)}):m?h.jsx(iq,{serverName:e,editorType:m,filePath:w,onBack:()=>{x(null),k(null)},onSwitchToRaw:e=>{x(null),k(null),p(e)}}):(0,h.jsxs)(h.Fragment,{children:[h.jsx(y.Z,{sx:{borderRadius:3},children:(0,h.jsxs)(b.Z,{children:[h.jsx(it,{path:t,onNavigate:E}),h.jsx(ih,{searchQuery:n,onSearchChange:r,onCreateFolder:B,onUpload:()=>M(!0),onRefresh:()=>O(),existingNames:V,disabled:R.isPending}),h.jsx(iA,{files:Z?.files||[],currentPath:t,onNavigate:E,onFileAction:N,searchQuery:n})]})}),h.jsx(iP,{target:l,isPending:D.isPending,onConfirm:W,onClose:()=>a(null)}),h.jsx(iB,{target:d,existingNames:V,isPending:P.isPending,onConfirm:F,onClose:()=>u(null)}),h.jsx(fh,{open:j,isPending:L.isPending,onUpload:z,onClose:()=>M(!1)}),h.jsx(eu.Z,{open:s.open,autoHideDuration:4e3,onClose:()=>o(e=>({...e,open:!1})),anchorOrigin:{vertical:"bottom",horizontal:"center"},children:h.jsx(g.Z,{onClose:()=>o(e=>({...e,open:!1})),severity:s.severity,variant:"filled",children:s.message})})]})}let fd=["Overview","Activity","Mods","Files","Backups","Access","Options"];function fu(e){return e.replace(/\x1b\[\?[\d;]*[a-zA-Z]/g,"").replace(/\x1b\[[0-9;]*[a-zA-Z]/g,"").replace(/\x1b=/g,"").replace(/\[\?[\d;]*[a-zA-Z]/g,"").replace(/\[[0-9;]*[a-zA-Z]/g,"").replace(/\[m/g,"").replace(/>\.\.\.\.\r?/g,"").replace(/\r/g,"").trim()}function ff({server:e,onSendCommand:t}){let[i,n]=(0,c.useState)("Overview"),[r,s]=(0,c.useState)(""),[o,l]=(0,c.useState)(!0),[a,d]=(0,c.useState)(!1),u=(0,c.useRef)(null),g=(0,$.Z)(),x=(0,q.Z)(g.breakpoints.down("sm")),{logs:v,isConnected:k}=(0,et.Y)({serverName:e.name}),S=(0,c.useMemo)(()=>v.filter(e=>!e.includes("RCON Listener")&&!e.includes("RCON Client")&&!e.includes("RconClient")),[v]),C=async()=>{r.trim()&&t&&(await t(r.trim()),s(""))},j=e.stats?.cpuPercent??0;e.stats?.memoryUsage&&e.stats.memoryUsage,function(e){if(!e)return;let t=e.match(/^(\d+)\s*(M|G)?$/i);if(t)parseInt(t[1],10),(t[2]||"M").toUpperCase()}(e.memory);let Z=e.stats?.memoryPercent??0;return(0,h.jsxs)(f.Z,{children:[h.jsx(f.Z,{sx:{display:"flex",flexWrap:"wrap",gap:.5,mb:3},children:fd.map(e=>h.jsx(p.Z,{onClick:()=>n(e),sx:{px:2,py:1,borderRadius:5,fontSize:14,fontWeight:500,textTransform:"none",bgcolor:i===e?"primary.main":"transparent",color:i===e?"#0a0e14":"text.secondary","&:hover":{bgcolor:i===e?"primary.main":(0,R.Fq)("#1bd96a",.1)}},children:e},e))}),(0,h.jsxs)(f.Z,{sx:{display:"grid",gridTemplateColumns:{xs:"1fr",sm:"repeat(3, 1fr)"},gap:2,mb:2.5},children:[h.jsx(ee,{value:`${j.toFixed(2)}%`,unit:"/ 100%",label:"CPU usage",icon:h.jsx(U.Z,{sx:{fontSize:28}}),progress:j,progressMax:100,color:"#1bd96a"}),h.jsx(ee,{value:`${Z.toFixed(2)}%`,unit:"/ 100%",label:"Memory usage",icon:h.jsx(_.Z,{sx:{fontSize:28}}),progress:Z,progressMax:100,color:"#1bd96a"}),h.jsx(ee,{value:e.worldSize||"0 B",unit:"/ 10 GB",label:"World size",icon:h.jsx(G.Z,{sx:{fontSize:28}}),progress:function(e){if(!e)return 0;let t=e.match(/^([\d.]+)\s*(B|KB|MB|MiB|GB|GiB)?$/i);if(!t)return 0;let i=parseFloat(t[1]);switch((t[2]||"B").toUpperCase()){case"GB":case"GIB":return 1024*i;case"MB":case"MIB":return i;case"KB":return i/1024;default:return i/1048576}}(e.worldSize),progressMax:10240,color:"#1bd96a"})]}),"Overview"===i&&(0,h.jsxs)(y.Z,{sx:{bgcolor:"background.paper",borderRadius:3,border:"1px solid",borderColor:"divider",overflow:"hidden"},children:[(0,h.jsxs)(f.Z,{sx:{px:3,py:2,borderBottom:"1px solid",borderColor:"divider",display:"flex",alignItems:"center",gap:1.25},children:[h.jsx(w.Z,{variant:"h6",sx:{fontWeight:700,color:"text.primary"},children:"Console"}),h.jsx(f.Z,{sx:{width:10,height:10,borderRadius:"50%",bgcolor:k?"primary.main":"error.main",boxShadow:k?"0 0 8px rgba(27, 217, 106, 0.4)":"0 0 8px rgba(239, 68, 68, 0.4)"}})]}),(0,h.jsxs)(f.Z,{sx:{position:"relative"},children:[h.jsx(f.Z,{ref:u,onScroll:()=>{if(!u.current)return;let{scrollTop:e,scrollHeight:t,clientHeight:i}=u.current;l(t-e-i<30)},sx:{height:{xs:240,sm:360},overflowY:"auto",px:2.5,py:2,fontSize:13,lineHeight:1.85,color:"#b4b6c4",bgcolor:"#0a0a0a",scrollbarWidth:"thin",scrollbarColor:"#3a3d4e #0a0a0a","&::-webkit-scrollbar":{width:8},"&::-webkit-scrollbar-track":{bgcolor:"#0a0a0a"},"&::-webkit-scrollbar-thumb":{bgcolor:"#3a3d4e",borderRadius:4}},children:0===S.length?h.jsx(w.Z,{sx:{color:"text.secondary",textAlign:"center",py:8},children:"Waiting for logs..."}):S.map((e,t)=>{let i=function(e){let t=fu(e).match(/\[(\d{2}:\d{2}:\d{2})\]\s*\[([^/]+)\/(\w+)\]:\s*(.+)/);return t?{time:t[1],thread:t[2],level:t[3]||"INFO",msg:t[4]}:null}(e);return i?(0,h.jsxs)(f.Z,{sx:{display:"flex",gap:0,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:[(0,h.jsxs)(f.Z,{component:"span",sx:{color:"#4a4d60"},children:["[",i.time,"]"]}),(0,h.jsxs)(f.Z,{component:"span",sx:{color:"#4a4d60"},children:["\xa0[",i.thread,"/",h.jsx(f.Z,{component:"span",sx:{color:"WARN"===i.level?"#e8a848":"#6b6e80"},children:i.level}),"]:\xa0"]}),h.jsx(f.Z,{component:"span",sx:{color:"WARN"===i.level?"#c4a45a":"#b4b6c4"},children:i.msg})]},t):h.jsx(f.Z,{sx:{color:"#b4b6c4"},children:fu(e)},t)})}),h.jsx(m.Z,{onClick:()=>d(!0),sx:{position:"absolute",top:12,right:12,width:36,height:36,borderRadius:2,bgcolor:"#282a3a",border:"1px solid #3a3d4e",color:"#8b8da0","&:hover":{bgcolor:"#313440"}},children:h.jsx(J.Z,{sx:{fontSize:18}})}),!o&&h.jsx(m.Z,{onClick:()=>{u.current&&u.current.scrollTo({top:u.current.scrollHeight,behavior:"smooth"})},sx:{position:"absolute",bottom:12,right:12,width:36,height:36,borderRadius:2,bgcolor:"#282a3a",border:"1px solid #3a3d4e",color:"#8b8da0","&:hover":{bgcolor:"#313440"}},children:h.jsx(X.Z,{sx:{fontSize:18}})})]}),h.jsx(f.Z,{sx:{px:2.5,py:1.5,borderTop:"1px solid",borderColor:"divider"},children:h.jsx(O.Z,{fullWidth:!0,size:"small",placeholder:"Send a command",value:r,onChange:e=>s(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),C())},disabled:!k,InputProps:{startAdornment:h.jsx(V.Z,{position:"start",children:h.jsx(Y.Z,{sx:{fontSize:16,color:"#999"}})}),sx:{bgcolor:"#13141c",borderRadius:2,fontSize:14,"& .MuiOutlinedInput-notchedOutline":{borderColor:"#2a2d3e"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"#3a3d4e"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main"}}}})})]}),"Overview"===i&&(0,h.jsxs)(D.ZP,{container:!0,spacing:3,sx:{mt:1},children:[h.jsx(D.ZP,{item:!0,xs:12,md:6,children:h.jsx(y.Z,{sx:{borderRadius:3},children:(0,h.jsxs)(b.Z,{children:[h.jsx(w.Z,{variant:"h6",gutterBottom:!0,fontWeight:600,children:"Server Information"}),h.jsx(H.Z,{sx:{mb:2}}),h.jsx(fp,{label:"Name",value:e.name}),h.jsx(fp,{label:"Container",value:e.container}),h.jsx(fp,{label:"Hostname",value:e.hostname?h.jsx(tQ.h,{hostname:e.hostname,color:"text.primary"}):void 0}),h.jsx(fp,{label:"Type",value:e.type}),h.jsx(fp,{label:"Version",value:e.version}),h.jsx(fp,{label:"Memory",value:e.memory}),h.jsx(fp,{label:"Uptime",value:e.uptime||function(e){if(!e||e<0)return"0s";let t=Math.floor(e/3600),i=Math.floor(e%3600/60),n=e%60;return t>0?`${t}h ${i}m`:i>0?`${i}m ${n}s`:`${n}s`}(e.uptimeSeconds)})]})})}),h.jsx(D.ZP,{item:!0,xs:12,md:6,children:h.jsx(y.Z,{sx:{borderRadius:3},children:(0,h.jsxs)(b.Z,{children:[h.jsx(w.Z,{variant:"h6",gutterBottom:!0,fontWeight:600,children:"Players"}),h.jsx(H.Z,{sx:{mb:2}}),e.players?(0,h.jsxs)(h.Fragment,{children:[h.jsx(fp,{label:"Online",value:`${e.players.online} / ${e.players.max}`}),e.players.players&&e.players.players.length>0&&(0,h.jsxs)(h.Fragment,{children:[h.jsx(w.Z,{variant:"body2",color:"text.secondary",sx:{mt:2,mb:1},children:"Online Players"}),h.jsx(f.Z,{sx:{display:"flex",flexWrap:"wrap",gap:1},children:e.players.players.map(e=>h.jsx(F.Z,{label:e,size:"small"},e))})]})]}):h.jsx(w.Z,{variant:"body2",color:"text.secondary",children:"Player information unavailable"})]})})}),h.jsx(D.ZP,{item:!0,xs:12,md:6,children:h.jsx(t1,{serverName:e.name,hostname:e.hostname})})]}),"Activity"===i&&h.jsx(f.Z,{sx:{mt:3},children:h.jsx(y.Z,{sx:{borderRadius:3},children:(0,h.jsxs)(b.Z,{children:[h.jsx(w.Z,{variant:"h6",gutterBottom:!0,fontWeight:600,children:"Server Activity"}),h.jsx(H.Z,{sx:{mb:2}}),h.jsx(ed,{serverName:e.name})]})})}),"Mods"===i&&h.jsx(f.Z,{sx:{mt:3},children:h.jsx(t6,{serverName:e.name})}),"Files"===i&&h.jsx(f.Z,{sx:{mt:3},children:h.jsx(fc,{serverName:e.name})}),"Backups"===i&&h.jsx(f.Z,{sx:{mt:3},children:h.jsx(w.Z,{variant:"body1",color:"text.secondary",children:"Backup management coming soon"})}),"Access"===i&&h.jsx(f.Z,{sx:{mt:3},children:h.jsx(tX,{serverId:e.name})}),"Options"===i&&h.jsx(f.Z,{sx:{mt:3},children:h.jsx(e$,{serverName:e.name,isRunning:"running"===e.status})}),"Overview"===i&&(0,h.jsxs)(M.Z,{open:a,onClose:()=>d(!1),maxWidth:"xl",fullWidth:!0,fullScreen:x,PaperProps:{sx:{height:x?"100vh":"90vh",bgcolor:"background.paper"}},children:[(0,h.jsxs)(f.Z,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",p:2,borderBottom:1,borderColor:"divider"},children:[(0,h.jsxs)(w.Z,{variant:"h6",sx:{fontFamily:'"Minecraft", sans-serif',fontWeight:400,letterSpacing:"0.05em"},children:["Console - ",e.name]}),h.jsx(m.Z,{onClick:()=>d(!1),"aria-label":"Close console",children:h.jsx(K.Z,{})})]}),h.jsx(A.Z,{sx:{p:0,display:"flex",flexDirection:"column"},children:h.jsx(ei.K,{serverName:e.name})})]})]})}function fp({label:e,value:t}){return t?(0,h.jsxs)(f.Z,{sx:{display:"flex",justifyContent:"space-between",py:1},children:[h.jsx(w.Z,{variant:"body2",color:"text.secondary",children:e}),h.jsx(w.Z,{variant:"body2",component:"div",sx:{fontWeight:500},children:t})]}):null}var fm=i(47893);function fg(){return(0,h.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[h.jsx("circle",{cx:"12",cy:"12",r:"10"}),h.jsx("line",{x1:"8",y1:"12",x2:"16",y2:"12"})]})}function fx(){return(0,h.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[h.jsx("path",{d:"M21 2v6h-6"}),h.jsx("path",{d:"M3 12a9 9 0 0115.36-6.36L21 8"}),h.jsx("path",{d:"M3 22v-6h6"}),h.jsx("path",{d:"M21 12a9 9 0 01-15.36 6.36L3 16"})]})}function fv(){let e=(0,d.useParams)(),t=(0,u.x)(),i=decodeURIComponent(e.name),{data:n,isLoading:r,error:s}=(0,eg.Hy)(i),{status:o,health:l}=function(e){let{serverName:t,onStatusChange:i,enabled:n=!0,reconnectInterval:r=3e3}=e,[s,o]=(0,c.useState)(null),[l,a]=(0,c.useState)(null),h=(0,c.useCallback)(e=>{if("server-status"===e.type){let t=e.data.status,n=e.data.health;o(t),a(n),i?.(t,n)}},[i]),{isConnected:d,reconnect:u,retryCount:f}=(0,fm.D)({url:`/api/sse/servers/${encodeURIComponent(t)}/status`,onMessage:h,enabled:n,reconnectInterval:r});return{status:s,health:l,isConnected:d,reconnect:u,retryCount:f}}({serverName:i,enabled:!!i}),[a,F]=(0,c.useState)(null),[V,H]=(0,c.useState)(!1),[$,q]=(0,c.useState)(""),K=(0,eg.jM)(),U=(0,eg.Aw)(),_=(0,eg._I)(),G=(0,eg.Hq)(),J=async()=>{try{await K.mutateAsync(i)}catch(e){console.error("Failed to start server:",e)}},X=async()=>{try{await U.mutateAsync(i)}catch(e){console.error("Failed to stop server:",e)}},Y=async()=>{try{await _.mutateAsync(i)}catch(e){console.error("Failed to restart server:",e)}},Q=async e=>{try{await fetch(`/api/servers/${encodeURIComponent(i)}/exec`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({command:e})})}catch(e){console.error("Failed to send command:",e)}},ee=o||n?.server.status,et=K.isPending||U.isPending||_.isPending,ei=n?.server;return(0,h.jsxs)(h.Fragment,{children:[s&&(0,h.jsxs)(g.Z,{severity:"error",sx:{mb:3},children:["Failed to load server: ",s.message]}),K.isError&&(0,h.jsxs)(g.Z,{severity:"error",sx:{mb:3},children:["Failed to start server: ",K.error?.message]}),U.isError&&(0,h.jsxs)(g.Z,{severity:"error",sx:{mb:3},children:["Failed to stop server: ",U.error?.message]}),_.isError&&(0,h.jsxs)(g.Z,{severity:"error",sx:{mb:3},children:["Failed to restart server: ",_.error?.message]}),G.isError&&(0,h.jsxs)(g.Z,{severity:"error",sx:{mb:3},children:["Failed to delete server: ",G.error?.message]}),r?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(f.Z,{sx:{display:"flex",alignItems:"center",gap:2,mb:2.5},children:[h.jsx(v.Z,{variant:"rounded",width:64,height:64,sx:{borderRadius:3,flexShrink:0}}),(0,h.jsxs)(f.Z,{sx:{flex:1},children:[h.jsx(v.Z,{variant:"text",width:80,height:18,sx:{mb:.5}}),h.jsx(v.Z,{variant:"text",width:"40%",height:40}),(0,h.jsxs)(f.Z,{sx:{display:"flex",gap:2,mt:.75},children:[h.jsx(v.Z,{variant:"text",width:100}),h.jsx(v.Z,{variant:"text",width:60}),h.jsx(v.Z,{variant:"text",width:140}),h.jsx(v.Z,{variant:"text",width:50})]})]}),(0,h.jsxs)(f.Z,{sx:{display:"flex",gap:1,flexShrink:0},children:[h.jsx(v.Z,{variant:"rounded",width:90,height:40,sx:{borderRadius:2}}),h.jsx(v.Z,{variant:"rounded",width:36,height:36,sx:{borderRadius:2}})]})]}),h.jsx(f.Z,{sx:{display:"flex",gap:.5,mb:3},children:[80,70,65,50,65,65].map((e,t)=>h.jsx(v.Z,{variant:"rounded",width:e,height:36,sx:{borderRadius:5}},t))}),h.jsx(f.Z,{sx:{display:"grid",gridTemplateColumns:{xs:"1fr",sm:"repeat(3, 1fr)"},gap:2,mb:2.5},children:[0,1,2].map(e=>h.jsx(y.Z,{sx:{borderRadius:3},children:(0,h.jsxs)(b.Z,{children:[(0,h.jsxs)(f.Z,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:1.5},children:[h.jsx(v.Z,{variant:"text",width:"50%"}),h.jsx(v.Z,{variant:"circular",width:28,height:28})]}),h.jsx(v.Z,{variant:"text",width:"60%",height:36}),h.jsx(v.Z,{variant:"rounded",width:"100%",height:6,sx:{borderRadius:3,mt:1}})]})},e))}),(0,h.jsxs)(y.Z,{sx:{borderRadius:3,border:"1px solid",borderColor:"divider"},children:[(0,h.jsxs)(f.Z,{sx:{px:3,py:2,borderBottom:"1px solid",borderColor:"divider",display:"flex",alignItems:"center",gap:1.25},children:[h.jsx(v.Z,{variant:"text",width:80,height:28}),h.jsx(v.Z,{variant:"circular",width:10,height:10})]}),h.jsx(v.Z,{variant:"rectangular",height:360,sx:{bgcolor:"#0a0a0a"}}),h.jsx(f.Z,{sx:{px:2.5,py:1.5,borderTop:"1px solid",borderColor:"divider"},children:h.jsx(v.Z,{variant:"rounded",width:"100%",height:40,sx:{borderRadius:2}})})]}),(0,h.jsxs)(D.ZP,{container:!0,spacing:3,sx:{mt:1},children:[h.jsx(D.ZP,{item:!0,xs:12,md:6,children:h.jsx(y.Z,{sx:{borderRadius:3},children:(0,h.jsxs)(b.Z,{children:[h.jsx(v.Z,{variant:"text",width:"40%",height:28,sx:{mb:1}}),h.jsx(v.Z,{variant:"rectangular",height:1,sx:{mb:2}}),[0,1,2,3,4,5,6].map(e=>(0,h.jsxs)(f.Z,{sx:{display:"flex",justifyContent:"space-between",py:1},children:[h.jsx(v.Z,{variant:"text",width:"30%"}),h.jsx(v.Z,{variant:"text",width:"40%"})]},e))]})})}),h.jsx(D.ZP,{item:!0,xs:12,md:6,children:h.jsx(y.Z,{sx:{borderRadius:3},children:(0,h.jsxs)(b.Z,{children:[h.jsx(v.Z,{variant:"text",width:"30%",height:28,sx:{mb:1}}),h.jsx(v.Z,{variant:"rectangular",height:1,sx:{mb:2}}),(0,h.jsxs)(f.Z,{sx:{display:"flex",justifyContent:"space-between",py:1},children:[h.jsx(v.Z,{variant:"text",width:"25%"}),h.jsx(v.Z,{variant:"text",width:"20%"})]})]})})})]})]}):ei?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(f.Z,{sx:{display:"flex",alignItems:"center",gap:2,mb:2.5},children:[h.jsx(f.Z,{sx:{width:64,height:64,borderRadius:3,overflow:"hidden",bgcolor:"background.paper",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,border:"1px solid",borderColor:"divider",fontSize:36},children:function(e){if(!e)return"\uD83C\uDFAE";let t=e.toUpperCase();return["PAPER","SPIGOT","BUKKIT","PURPUR"].includes(t)?"\uD83D\uDD0C":["FORGE","NEOFORGE","FABRIC","QUILT"].includes(t)?"\uD83D\uDD27":"\uD83C\uDFAE"}(ei.type)}),(0,h.jsxs)(f.Z,{sx:{flex:1},children:[(0,h.jsxs)(w.Z,{onClick:()=>t.push("/servers"),sx:{fontSize:12,color:"primary.main",cursor:"pointer",mb:.25,display:"flex",alignItems:"center",gap:.5,"&:hover":{textDecoration:"underline"}},children:[h.jsx(P.Z,{sx:{fontSize:14}})," All servers"]}),h.jsx(w.Z,{variant:"h4",component:"h1",sx:{fontFamily:'"Minecraft", sans-serif',fontWeight:400,color:"text.primary",letterSpacing:"0.5px",m:0,textTransform:"uppercase"},children:i}),(0,h.jsxs)(f.Z,{sx:{display:"flex",alignItems:"center",gap:0,mt:.75,flexWrap:"wrap",fontSize:13,color:"text.secondary"},children:[ei.version&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(f.Z,{sx:{display:"flex",alignItems:"center",gap:.5},children:[h.jsx(B.Z,{sx:{fontSize:14}}),"Minecraft ",ei.version]}),h.jsx(f.Z,{component:"span",sx:{mx:1.25,color:"#3a3d4e"},children:"|"})]}),ei.type&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(f.Z,{sx:{display:"flex",alignItems:"center",gap:.5},children:[h.jsx(N.Z,{sx:{fontSize:14}}),ei.type]}),h.jsx(f.Z,{component:"span",sx:{mx:1.25,color:"#3a3d4e"},children:"|"})]}),ei.hostname&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(f.Z,{sx:{display:"flex",alignItems:"center",gap:.5},children:[h.jsx(z.Z,{sx:{fontSize:14}}),h.jsx(tQ.h,{hostname:ei.hostname,fontSize:13})]}),h.jsx(f.Z,{component:"span",sx:{mx:1.25,color:"#3a3d4e"},children:"|"})]}),(0,h.jsxs)(f.Z,{sx:{display:"flex",alignItems:"center",gap:.5},children:[h.jsx(W.Z,{sx:{fontSize:14}}),ei.uptime||function(e){if(!e||e<0)return"0s";let t=Math.floor(e/3600),i=Math.floor(e%3600/60),n=e%60;return t>0?`${t}h ${i}m`:i>0?`${i}m ${n}s`:`${n}s`}(ei.uptimeSeconds)||"0s"]})]})]}),(0,h.jsxs)(f.Z,{sx:{display:"flex",alignItems:"center",gap:1.25,flexShrink:0},children:[("stopped"===ee||"exited"===ee||"not_created"===ee)&&h.jsx(p.Z,{variant:"contained",color:"success",startIcon:et?h.jsx(x.Z,{size:16,color:"inherit"}):h.jsx(L.Z,{}),onClick:J,disabled:et,sx:{px:2,py:1,borderRadius:2,fontSize:14,fontWeight:600},children:"Start"}),"running"===ee&&(0,h.jsxs)(h.Fragment,{children:[h.jsx(p.Z,{variant:"outlined",startIcon:et?h.jsx(x.Z,{size:16}):h.jsx(fg,{}),onClick:X,disabled:et,sx:{px:2,py:1,borderRadius:2,fontSize:14,fontWeight:500,borderColor:"divider",color:"text.secondary","&:hover":{borderColor:"text.secondary",bgcolor:(0,R.Fq)("#fff",.05)}},children:"Stop"}),h.jsx(p.Z,{variant:"contained",startIcon:et?h.jsx(x.Z,{size:16,color:"inherit"}):h.jsx(fx,{}),onClick:Y,disabled:et,sx:{px:2,py:1,borderRadius:2,fontSize:14,fontWeight:600,bgcolor:"primary.main",color:"#0a0e14","&:hover":{bgcolor:"primary.dark"}},children:"Restart"})]}),h.jsx(m.Z,{onClick:e=>F(e.currentTarget),sx:{width:36,height:36,borderRadius:2,border:"1px solid",borderColor:"divider",color:"text.secondary"},children:h.jsx(I.Z,{sx:{fontSize:18}})}),h.jsx(k.Z,{anchorEl:a,open:!!a,onClose:()=>F(null),children:(0,h.jsxs)(S.Z,{onClick:()=>{F(null),H(!0),q("")},sx:{color:"error.main"},children:[h.jsx(C.Z,{children:h.jsx(E.Z,{fontSize:"small",sx:{color:"error.main"}})}),h.jsx(j.Z,{children:"Delete Server"})]})})]})]}),h.jsx(ff,{server:ei,onSendCommand:Q})]}):h.jsx(g.Z,{severity:"warning",children:"Server not found"}),(0,h.jsxs)(M.Z,{open:V,onClose:()=>{H(!1),q("")},maxWidth:"sm",fullWidth:!0,children:[h.jsx(Z.Z,{children:"Delete Server"}),(0,h.jsxs)(A.Z,{children:[(0,h.jsxs)(w.Z,{sx:{mb:2},children:["This action cannot be undone. Type ",h.jsx("strong",{children:i})," to confirm deletion."]}),h.jsx(O.Z,{label:"Server name",value:$,onChange:e=>q(e.target.value),fullWidth:!0,autoFocus:!0})]}),(0,h.jsxs)(T.Z,{sx:{px:3,pb:2},children:[h.jsx(p.Z,{onClick:()=>{H(!1),q("")},children:"Cancel"}),h.jsx(p.Z,{variant:"contained",color:"error",onClick:()=>{$===i&&G.mutate({name:i,force:!0},{onSuccess:()=>{t.push("/servers")}})},disabled:$!==i||G.isPending,startIcon:G.isPending?h.jsx(x.Z,{size:16}):null,children:G.isPending?"Deleting...":"Delete"})]})]})]})}},71438:(e,t,i)=>{"use strict";i.d(t,{I:()=>o});var n=i(58120),r=i(48787),s=i(39928);function o({action:e,size:t="small"}){let i=s.Lu[e]||"default",o=s.n3[e]||e;return n.jsx(r.Z,{label:o,color:i,size:t,variant:"filled",sx:{fontWeight:600,fontSize:"small"===t?"0.7rem":"0.8rem"}})}},55049:(e,t,i)=>{"use strict";i.d(t,{c:()=>l});var n=i(58120),r=i(48787),s=i(56846),o=i(72690);function l({status:e,size:t="small"}){return n.jsx(r.Z,{icon:"success"===e?n.jsx(s.Z,{}):n.jsx(o.Z,{}),label:"success"===e?"OK":"Error",color:"success"===e?"success":"error",size:t,variant:"outlined",sx:{fontWeight:500,fontSize:"small"===t?"0.7rem":"0.8rem"}})}},6418:(e,t,i)=>{"use strict";i.d(t,{K:()=>Z});var n=i(58120),r=i(36372),s=i(20393),o=i.n(s),l=i(89352),a=i(52329),h=i(6275),c=i(10257),d=i(46456),u=i(54365),f=i(2365),p=i(48787),m=i(14360),g=i(51430),x=i(23016),v=i(80336),y=i(79943),b=i(78150),w=i(73995),k=i(66831),S=i(50423);let C=[{label:"say",template:"say "},{label:"give",template:"give "},{label:"tp",template:"tp "},{label:"gamemode",template:"gamemode "}],j=new(o())({fg:"#aaa",bg:"#000",newline:!1,escapeXML:!0,colors:{0:"#000000",1:"#cc0000",2:"#4e9a06",3:"#c4a000",4:"#3465a4",5:"#75507b",6:"#06989a",7:"#d3d7cf",8:"#555753",9:"#ef2929",10:"#8ae234",11:"#fce94f",12:"#729fcf",13:"#ad7fa8",14:"#34e2e2",15:"#eeeeec"}}),M=(0,r.memo)(function({log:e}){let t=(0,r.useMemo)(()=>(function(e){let t=e.replace(/\x1b\[\?[\d;]*[a-zA-Z]/g,"").replace(/\x1b\[[0-9;]*[KJH]/g,"").replace(/\x1b=/g,"").replace(/\[\?[\d;]*[a-zA-Z]/g,"").replace(/\[[0-9;]*[KJH]/g,"").replace(/\[m/g,"").replace(/\[(\d+)m/g,"\x1b[$1m").replace(/>\.\.\.\.\r?/g,"").replace(/\r/g,"");return j.toHtml(t)})(e),[e]);return n.jsx(l.Z,{sx:{py:.25,whiteSpace:"pre-wrap",wordBreak:"break-all","& span":{}},dangerouslySetInnerHTML:{__html:t}})});function Z({serverName:e}){let[t,i]=(0,r.useState)(""),[s,o]=(0,r.useState)([]),[j,Z]=(0,r.useState)(-1),[A,T]=(0,r.useState)("ALL"),[O,D]=(0,r.useState)(!0),[R,P]=(0,r.useState)(!0),[L,I]=(0,r.useState)(!1),E=(0,r.useRef)(null),B=(0,r.useRef)(null),{logs:N,isConnected:z,clearLogs:W,reconnect:F,retryCount:V}=(0,S.Y)({serverName:e}),H=(0,r.useMemo)(()=>{let e=N;return R&&(e=e.filter(e=>!e.includes("RCON Listener")&&!e.includes("RCON Client")&&!e.includes("RconClient"))),"ALL"!==A&&(e=e.filter(e=>(e.includes("/ERROR]")||e.includes("/ERROR:")?"ERROR":e.includes("/WARN]")||e.includes("/WARN:")?"WARN":(e.includes("/INFO]")||e.includes("/INFO:"),"INFO"))===A)),e},[N,A,R]),$=(0,r.useCallback)(async()=>{let n=t.trim();if(n&&!L){I(!0);try{o(e=>[...e,n]),Z(-1),await fetch(`/api/servers/${encodeURIComponent(e)}/exec`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({command:n})}),i("")}catch(e){console.error("Failed to execute command:",e)}finally{I(!1)}}},[t,e,L]),q=(0,r.useCallback)(e=>{if("Enter"===e.key)e.preventDefault(),$();else if("ArrowUp"===e.key){if(e.preventDefault(),0===s.length)return;let t=-1===j?s.length-1:Math.max(0,j-1);Z(t),i(s[t])}else if("ArrowDown"===e.key){if(e.preventDefault(),-1===j)return;let t=j+1;t>=s.length?(Z(-1),i("")):(Z(t),i(s[t]))}},[s,j,$]),K=(0,r.useCallback)(e=>{i(e),E.current?.focus()},[]),U=z?{text:"Connected",color:"success"}:V>0?{text:`Disconnected (Retry ${V})`,color:"warning"}:{text:"Disconnected",color:"error"};return(0,n.jsxs)(a.Z,{"data-testid":"server-console",sx:{display:"flex",flexDirection:"column",height:"100%",minHeight:400},children:[(0,n.jsxs)(l.Z,{sx:{display:"flex",flexDirection:{xs:"column",sm:"row"},alignItems:{xs:"flex-start",sm:"center"},justifyContent:"space-between",px:2,py:1,gap:1,borderBottom:1,borderColor:"divider"},children:[(0,n.jsxs)(x.Z,{direction:"row",spacing:1,alignItems:"center",children:[n.jsx(f.Z,{variant:"subtitle2",children:"Console"}),n.jsx(p.Z,{"data-testid":"connection-status",label:U.text,color:U.color,size:"small"})]}),(0,n.jsxs)(x.Z,{direction:"row",spacing:1,alignItems:"center",flexWrap:"wrap",useFlexGap:!0,children:[n.jsx(d.Z,{size:"small",variant:"outlined",children:["ALL","INFO","WARN","ERROR"].map(e=>n.jsx(c.Z,{onClick:()=>T(e),variant:A===e?"contained":"outlined",children:e},e))}),n.jsx(m.Z,{control:n.jsx(g.Z,{checked:O,onChange:e=>D(e.target.checked),size:"small",inputProps:{"aria-label":"Auto-scroll"}}),label:"Auto-scroll"}),n.jsx(m.Z,{control:n.jsx(g.Z,{checked:R,onChange:e=>P(e.target.checked),size:"small",inputProps:{"aria-label":"Hide RCON"}}),label:"Hide RCON"}),n.jsx(u.Z,{size:"small",onClick:W,"aria-label":"Clear logs",title:"Clear logs",children:n.jsx(w.Z,{})}),!z&&n.jsx(c.Z,{size:"small",startIcon:n.jsx(k.Z,{}),onClick:F,"aria-label":"Reconnect",children:"Reconnect"})]})]}),n.jsx(l.Z,{ref:B,sx:{flex:1,overflow:"auto",bgcolor:"#1a1a1a",p:1,fontSize:"0.85rem"},children:0===H.length?n.jsx(f.Z,{color:"text.secondary",sx:{textAlign:"center",py:4,color:"#666"},children:"Waiting for logs..."}):H.map((e,t)=>n.jsx(M,{log:e},t))}),n.jsx(v.Z,{}),n.jsx(l.Z,{sx:{px:2,py:1,bgcolor:"background.default"},children:(0,n.jsxs)(x.Z,{direction:"row",spacing:1,children:[n.jsx(f.Z,{variant:"caption",color:"text.secondary",sx:{alignSelf:"center"},children:"Quick:"}),C.map(e=>n.jsx(c.Z,{size:"small",variant:"outlined",onClick:()=>K(e.template),children:e.label},e.label))]})}),n.jsx(v.Z,{}),(0,n.jsxs)(l.Z,{sx:{display:"flex",p:1,gap:1},children:[n.jsx(h.Z,{inputRef:E,fullWidth:!0,size:"small",placeholder:"Enter command...",value:t,onChange:e=>i(e.target.value),onKeyDown:q,disabled:!z||L,InputProps:{}}),n.jsx(c.Z,{variant:"contained",onClick:$,disabled:!t.trim()||!z||L,startIcon:L?n.jsx(y.Z,{size:16}):n.jsx(b.Z,{}),"aria-label":"Send command",children:"Send"})]})]})}},15784:(e,t,i)=>{"use strict";i.d(t,{DM:()=>o,HZ:()=>a,VM:()=>l,hT:()=>s,oL:()=>h});var n=i(28872),r=i(43137);function s(e={},t){let i=function(e){let t=new URLSearchParams;e.action&&t.set("action",e.action),e.actor&&t.set("actor",e.actor),e.targetType&&t.set("targetType",e.targetType),e.targetName&&t.set("targetName",e.targetName),e.status&&t.set("status",e.status),e.from&&t.set("from",e.from),e.to&&t.set("to",e.to),void 0!==e.limit&&t.set("limit",String(e.limit)),void 0!==e.offset&&t.set("offset",String(e.offset)),e.sort&&t.set("sort",e.sort);let i=t.toString();return i?`?${i}`:""}(e);return(0,n.a)({queryKey:["audit-logs",e],queryFn:()=>(0,r.SC)(`/api/audit-logs${i}`),enabled:t?.enabled!==!1})}function o(e){return(0,n.a)({queryKey:["audit-logs","stats"],queryFn:()=>(0,r.SC)("/api/audit-logs/stats"),enabled:e?.enabled!==!1,refetchInterval:3e4})}function l(e,t){return(0,n.a)({queryKey:["audit-logs",e],queryFn:()=>(0,r.SC)(`/api/audit-logs/${encodeURIComponent(e)}`),enabled:t?.enabled!==!1&&!!e})}function a(e,t){return s({targetType:"server",targetName:e,limit:t?.limit??20},{enabled:t?.enabled!==!1&&!!e})}function h(e=10){return s({limit:e,sort:"timestamp:desc"})}},15934:(e,t,i)=>{"use strict";i.d(t,{Bc:()=>a,N$:()=>h,UW:()=>l});var n=i(28872),r=i(95343),s=i(20042),o=i(43137);function l(){return(0,n.a)({queryKey:["playit-status"],queryFn:()=>(0,o.SC)("/api/playit/status"),refetchInterval:3e4})}function a(){let e=(0,r.NL)();return(0,s.D)({mutationFn:()=>(0,o.SC)("/api/playit/start",{method:"POST"}),onSuccess:()=>{e.invalidateQueries({queryKey:["playit-status"]})}})}function h(){let e=(0,r.NL)();return(0,s.D)({mutationFn:()=>(0,o.SC)("/api/playit/stop",{method:"POST"}),onSuccess:()=>{e.invalidateQueries({queryKey:["playit-status"]})}})}},50423:(e,t,i)=>{"use strict";i.d(t,{Y:()=>s});var n=i(36372),r=i(47893);function s(e){let{serverName:t,maxLines:i=500,enabled:s=!0,reconnectInterval:o=3e3}=e,[l,a]=(0,n.useState)([]),h=(0,n.useCallback)(e=>{let t;"server-log"===e.type?t=e.data.log:"log"in e&&"string"==typeof e.log&&(t=e.log),t&&a(e=>{let n=[...e,t];return n.length>i?n.slice(n.length-i):n})},[i]),{isConnected:c,reconnect:d,retryCount:u}=(0,r.D)({url:`/api/sse/servers/${encodeURIComponent(t)}/logs`,onMessage:h,enabled:s,reconnectInterval:o});return{logs:l,isConnected:c,clearLogs:(0,n.useCallback)(()=>{a([])},[]),reconnect:d,retryCount:u}}},39928:(e,t,i)=>{"use strict";i.d(t,{KK:()=>l,Lu:()=>n,Xn:()=>o,n3:()=>r,xg:()=>s});let n={"server.create":"success","server.delete":"error","server.start":"info","server.stop":"warning","server.restart":"secondary","player.whitelist.add":"success","player.whitelist.remove":"warning","player.ban":"error","player.unban":"success","player.op":"info","player.deop":"warning","player.kick":"error","audit.purge":"default"},r={"server.create":"Create","server.delete":"Delete","server.start":"Start","server.stop":"Stop","server.restart":"Restart","player.whitelist.add":"Whitelist Add","player.whitelist.remove":"Whitelist Remove","player.ban":"Ban","player.unban":"Unban","player.op":"Op","player.deop":"Deop","player.kick":"Kick","audit.purge":"Purge"},s=["server.create","server.delete","server.start","server.stop","server.restart","player.whitelist.add","player.whitelist.remove","player.ban","player.unban","player.op","player.deop","player.kick","audit.purge"],o=["server.create","server.delete","server.start","server.stop","server.restart"],l=["player.whitelist.add","player.whitelist.remove","player.ban","player.unban","player.op","player.deop","player.kick"]},40579:(e,t,i)=>{"use strict";i.r(t),i.d(t,{default:()=>n});let n=(0,i(2325).createProxy)(String.raw`/home/runner/work/minecraft-server-manager/minecraft-server-manager/platform/services/mcctl-console/src/app/(main)/servers/[name]/page.tsx#default`)}};var t=require("../../../../webpack-runtime.js");t.C(e);var i=e=>t(t.s=e),n=t.X(0,[9836,1489,6554,3043,8847,7573,8872,4859,6088,8243,8504,4207,1645,8389,1201,8913,2842,7049,3613,354,1088,4479],()=>i(61509));module.exports=n})();
|