wiki-viewer 2.9.3 → 2.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.next/standalone/.next/BUILD_ID +1 -1
- package/.next/standalone/.next/build-manifest.json +3 -3
- package/.next/standalone/.next/prerender-manifest.json +3 -3
- package/.next/standalone/.next/required-server-files.json +2 -2
- package/.next/standalone/.next/server/app/_global-error.html +1 -1
- package/.next/standalone/.next/server/app/_global-error.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_not-found/page/next-font-manifest.json +38 -1
- package/.next/standalone/.next/server/app/_not-found/page.js +1 -1
- package/.next/standalone/.next/server/app/_not-found/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/api/agent/activity/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/agent/events/[...path]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/agent/files/[...path]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/agent/fs/file/[...path]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/agent/fs/ls/[[...path]]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/agent/fs/move/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/agent/fs/search/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/agent/internal/span/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/agent/settings/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/agent/sidecar/[...path]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/app-proxy/[...path]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/assets/[...path]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/pdf/save/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/share/[token]/asset/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/share/[token]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/share/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/system/browse/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/system/reveal/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/system/workspaces/[id]/branch/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/system/workspaces/[id]/open/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/system/workspaces/[id]/refresh/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/system/workspaces/[id]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/system/workspaces/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/upload/[...path]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/app/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/backlinks/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/content/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/download/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/folder/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/git-branches/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/git-checkout/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/git-diff/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/git-file-info/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/git-history/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/git-pull/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/move/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/new-file/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/outlinks/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/page/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/presence/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/search/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/slugs/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/upload/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/watch/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/page/next-font-manifest.json +38 -1
- package/.next/standalone/.next/server/app/page.js +1 -1
- package/.next/standalone/.next/server/app/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/s/[token]/page/next-font-manifest.json +38 -1
- package/.next/standalone/.next/server/app/s/[token]/page.js +1 -1
- package/.next/standalone/.next/server/app/s/[token]/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/s/[token]/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/signin/page/next-font-manifest.json +38 -1
- package/.next/standalone/.next/server/app/signin/page.js +2 -2
- package/.next/standalone/.next/server/app/signin/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/signin/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__00sn-o5._.js +2 -2
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__05tbv~.._.js +2 -2
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0_5~w8k._.js +2 -2
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0_g-.kr._.js +3 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0mjux2y._.js +1 -1
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__11ltgmp._.js +1 -1
- package/.next/standalone/.next/server/chunks/src_lib_auth_server_ts_00f4e0h._.js +7 -7
- package/.next/standalone/.next/server/chunks/ssr/{0~w0_katex_dist_katex_mjs_018q_uc._.js → 0~w0_katex_dist_katex_mjs_0ezwklf._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__09ut-wj._.js → [root-of-the-server]__0ijphh5._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__0n5kphk._.js → [root-of-the-server]__0v4bxn5._.js} +2 -2
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__12pw.xq._.js +3 -0
- package/.next/standalone/.next/server/chunks/ssr/_0d9d~c~._.js +3 -0
- package/.next/standalone/.next/server/chunks/ssr/_0kkaybx._.js +3 -0
- package/.next/standalone/.next/server/chunks/ssr/_0oq8kwv._.js +21 -23
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0mv0.4i._.js → node_modules__pnpm_02omd8-._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0kkbph0._.js → node_modules__pnpm_02sp547._.js} +2 -2
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0x9-_1d._.js → node_modules__pnpm_02uftns._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0bnc0lk._.js → node_modules__pnpm_03a6alg._.js} +2 -2
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0qmqt0m._.js → node_modules__pnpm_04t9xl-._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0ebvpwi._.js → node_modules__pnpm_067bv9c._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0s1th-1._.js → node_modules__pnpm_07aatdc._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_07bf4mp._.js → node_modules__pnpm_09cxxh9._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0f9vj0~._.js → node_modules__pnpm_09ms74y._.js} +2 -2
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0pv3k.9._.js → node_modules__pnpm_0a~ka8f._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_02yqus6._.js → node_modules__pnpm_0dyz243._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0g21lw4._.js → node_modules__pnpm_0fjns1m._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0fa23-q._.js → node_modules__pnpm_0gp97p7._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0kdk2ot._.js → node_modules__pnpm_0hqvb5v._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0.wgpvp._.js → node_modules__pnpm_0iy87hj._.js} +2 -2
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0a~3f2a._.js → node_modules__pnpm_0pe2rdb._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0q~maar._.js → node_modules__pnpm_0q8v8dz._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0tdnho_._.js → node_modules__pnpm_0usypt0._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_12nfd13._.js → node_modules__pnpm_0v38l5j._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0xq~zku._.js → node_modules__pnpm_0vn1wax._.js} +2 -2
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0dm.meu._.js → node_modules__pnpm_0ybuie9._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_02j0p3a._.js → node_modules__pnpm_0yi0xoe._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0p4w0~q._.js → node_modules__pnpm_0~v9~.c._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0w6oo9l._.js → node_modules__pnpm_11-0pez._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0f.5boy._.js → node_modules__pnpm_11-k0fx._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0nt22aq._.js → node_modules__pnpm_11ya8hu._.js} +2 -2
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0f9vuiw._.js → node_modules__pnpm_124x.i6._.js} +2 -2
- package/.next/standalone/.next/server/chunks/ssr/src_app_s_[token]_page_tsx_0_fzrmd._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/src_app_signin_00yk0vm._.js +1 -1
- package/.next/standalone/.next/server/middleware-build-manifest.js +3 -3
- package/.next/standalone/.next/server/next-font-manifest.js +1 -1
- package/.next/standalone/.next/server/next-font-manifest.json +152 -4
- package/.next/standalone/.next/server/pages/500.html +1 -1
- package/.next/standalone/.next/server/server-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/server-reference-manifest.json +1 -1
- package/.next/standalone/.next/static/chunks/{0fm2eul-wqh2f.js → 02.js-~-mud9y.js} +1 -1
- package/.next/standalone/.next/static/chunks/08a~bt71ve3kk.js +1 -0
- package/.next/standalone/.next/static/chunks/0h1rq-by77vbq.js +1 -0
- package/.next/standalone/.next/static/chunks/0kn46-7d-slsk.css +23 -0
- package/.next/standalone/.next/static/chunks/0m9a~lcgq0h-l.js +170 -0
- package/.next/standalone/.next/static/chunks/0pj~087q91fgk.css +1 -0
- package/.next/standalone/.next/static/chunks/{00_12ekhbvhhp.js → 0wkj8v.ttvxv..js} +1 -1
- package/.next/standalone/.next/static/media/02046ca7e906ed9f-s.1602kxq-59i~c.woff2 +0 -0
- package/.next/standalone/.next/static/media/0797a9ffe47acb65-s.045uve1.n0xw5.woff2 +0 -0
- package/.next/standalone/.next/static/media/08328e320c8f68d1-s.068q2mbkdvzxv.woff2 +0 -0
- package/.next/standalone/.next/static/media/1e239d59b95c7889-s.0y5o_un~q19dn.woff2 +0 -0
- package/.next/standalone/.next/static/media/248e1dc0efc99276-s.p.0ft7o6kv5bp14.woff2 +0 -0
- package/.next/standalone/.next/static/media/2742b3d653a3157b-s.12jcr6dg9go_n.woff2 +0 -0
- package/.next/standalone/.next/static/media/2aec202ebfcf461b-s.0p8pxnvll2h.7.woff2 +0 -0
- package/.next/standalone/.next/static/media/38772d1e0cde909c-s.06sf8d84-9n3w.woff2 +0 -0
- package/.next/standalone/.next/static/media/38df7484fe560b25-s.p.0_h8~hcb-m6kp.woff2 +0 -0
- package/.next/standalone/.next/static/media/3ZLMEXZEQPLTEPMHTQDAUXP5ZZXCZAEN-s.p.0hfk9k1kkjsdy.woff2 +0 -0
- package/.next/standalone/.next/static/media/3c9bd1ad48ccb78c-s.0mbvj~smw3lv4.woff2 +0 -0
- package/.next/standalone/.next/static/media/3ce154ad7d54dc86-s.0n54~jvon9ee5.woff2 +0 -0
- package/.next/standalone/.next/static/media/3e80ce3d3175ff0e-s.0r7j4fqpb_s~7.woff2 +0 -0
- package/.next/standalone/.next/static/media/433XP6QWDVL6KQ5K7ZCOP524TX4LE4RJ-s.p.13or5lok2-922.woff2 +0 -0
- package/.next/standalone/.next/static/media/48e5af244f2769e4-s.p.02pz5pzr7s54d.woff2 +0 -0
- package/.next/standalone/.next/static/media/572c13468b8cff87-s.0k68dgt5gi4w6.woff2 +0 -0
- package/.next/standalone/.next/static/media/574e5b2a8fe8e45b-s.01yactx5t2mij.woff2 +0 -0
- package/.next/standalone/.next/static/media/5b0229109f6656bb-s.1455rc8vwuctw.woff2 +0 -0
- package/.next/standalone/.next/static/media/5c773c73f3b750dc-s.0qis_my1gal~q.woff2 +0 -0
- package/.next/standalone/.next/static/media/62d4b50592542c9f-s.0id408x23fv8q.woff2 +0 -0
- package/.next/standalone/.next/static/media/6KRVTMHEY26GBVOWXYL6F3ZLGUXE5ZD5-s.p.0xh3vtwj392i-.woff2 +0 -0
- package/.next/standalone/.next/static/media/6bbcb5b36acd717c-s.0oz2cuf9udaui.woff2 +0 -0
- package/.next/standalone/.next/static/media/7AHDUZ4A7LFLVFUIFSARGIWCRQJHISQP-s.p.0hq2a81xn4_re.woff2 +0 -0
- package/.next/standalone/.next/static/media/7YY3ZAAE3TRV2LANYOLXNHTPHLXVWTKH-s.p.0aqd04_idyb6d.woff2 +0 -0
- package/.next/standalone/.next/static/media/7a454fa283e484f3-s.p.0quc0xhiv~l2f.woff2 +0 -0
- package/.next/standalone/.next/static/media/7c2c7251ac640798-s.0ci7sidzj82wz.woff2 +0 -0
- package/.next/standalone/.next/static/media/7cdbb9ca823c0a73-s.0g~9kd3dx56ng.woff2 +0 -0
- package/.next/standalone/.next/static/media/89ea96820aa96980-s.p.05i4trv5wh9ym.woff2 +0 -0
- package/.next/standalone/.next/static/media/8c352cd2dd0b7ed3-s.046_rt88lmymv.woff2 +0 -0
- package/.next/standalone/.next/static/media/8fcf71678f67d0c5-s.0kn0u2cosumsr.woff2 +0 -0
- package/.next/standalone/.next/static/media/9de307755bdae5a1-s.p.0h_ujslg0gefa.woff2 +0 -0
- package/.next/standalone/.next/static/media/GHM6WVH6MILNYOOCXHXB5GTSGNTMGXZR-s.p.0yt9gwi-.i49f.woff2 +0 -0
- package/.next/standalone/.next/static/media/J64QX5IPOHK56I2KYUNBQ5M2XWZEYKYX-s.p.0mxjq567rs1on.woff2 +0 -0
- package/.next/standalone/.next/static/media/KFIAZD4RUMEZIYV6FQ3T3GP5PDBDB6JY-s.p.049.kwhs-b7lf.woff2 +0 -0
- package/.next/standalone/.next/static/media/NIQ54PVBBIWVK3PFSOIOUJSXIJ5WTNDP-s.p.0-mpnqa_q7f0-.woff2 +0 -0
- package/.next/standalone/.next/static/media/ODDSCHC7OZCRRQJDJV5LMJKTGF7URFO4-s.p.0ti.-5ju6w580.woff2 +0 -0
- package/.next/standalone/.next/static/media/RMBKFTS6UFOXVBCL3EVCXLWRQBA3PN4K-s.p.0udd26.7.3pmc.woff2 +0 -0
- package/.next/standalone/.next/static/media/RNUZPHMIVMPXFHVACRGCAJ32E6WUEDVU-s.p.0h80ym842138e.woff2 +0 -0
- package/.next/standalone/.next/static/media/SB2OEB6IKZPRR6JT4GFJ2TFT6HBB6AZN-s.p.0rb3ehjtk_okh.woff2 +0 -0
- package/.next/standalone/.next/static/media/SIH66VPT4WS2HIF5PEJNDU4INNUF54LG-s.p.08_1ce4x9brpn.woff2 +0 -0
- package/.next/standalone/.next/static/media/TW4KNQIPR4LNP4I6I6C6HKQ23B2EQAU5-s.p.02kr7k5v_8hxa.woff2 +0 -0
- package/.next/standalone/.next/static/media/UMQTMTAEPCAFNEJDVEURBIXJENGOHOWO-s.p.0~8tz_97dla0z.woff2 +0 -0
- package/.next/standalone/.next/static/media/WNDVG7O66ENLOD43GS7FBUCC4KMT5OM2-s.p.0lx670_9j82xu.woff2 +0 -0
- package/.next/standalone/.next/static/media/a0ffaa6a9384d9d3-s.0rpo5i9-tpup~.woff2 +0 -0
- package/.next/standalone/.next/static/media/a421df443b3f383b-s.0-2a4_vov7hfq.woff2 +0 -0
- package/.next/standalone/.next/static/media/be7780d61d89233b-s.01u0nh~~sr1co.woff2 +0 -0
- package/.next/standalone/.next/static/media/c2873153dc73d9e3-s.0g6heybwh~nbo.woff2 +0 -0
- package/.next/standalone/.next/static/media/ca19bc83075b2625-s.0s0y.-f87v-al.woff2 +0 -0
- package/.next/standalone/.next/static/media/ca31d6821328a4e9-s.p.0w8w9q576xw20.woff2 +0 -0
- package/.next/standalone/.next/static/media/cc6c75d91fb27f62-s.117builj2s2_-.woff2 +0 -0
- package/.next/standalone/.next/static/media/ccee61546c0358b7-s.17kgvx8~8.fj6.woff2 +0 -0
- package/.next/standalone/.next/static/media/ce5b45ab00236ec9-s.0e2v01fdnfw~o.woff2 +0 -0
- package/.next/standalone/.next/static/media/ce62453a442c7f35-s.p.0333ktddfbsxy.woff2 +0 -0
- package/.next/standalone/.next/static/media/cf514f5d0007dafa-s.p.0lok5zj4ubzox.woff2 +0 -0
- package/.next/standalone/.next/static/media/d38a53d0ba90b32d-s.0-z21w-861g1d.woff2 +0 -0
- package/.next/standalone/.next/static/media/datatype_regular-s.p.0j71g.k6bf9dr.woff2 +0 -0
- package/.next/standalone/.next/static/media/eae18db174274e0c-s.018x-x0snqelf.woff2 +0 -0
- package/.next/standalone/.next/static/media/ed5f1f9bced69653-s.p.0t~r0znp74~xb.woff2 +0 -0
- package/.next/standalone/.next/static/media/elms_sans_regular-s.p.0ca_dpt0ytdvz.woff2 +0 -0
- package/.next/standalone/.next/static/media/f5031e7b18bdfbb3-s.p.17530ebvtj~5g.woff2 +0 -0
- package/.next/standalone/.next/static/media/f7d6090e8b3debad-s.00qosz~21_9iq.woff2 +0 -0
- package/.next/standalone/.next/static/media/fad568eea626db0e-s.04s-lri-1fnua.woff2 +0 -0
- package/.next/standalone/.next/static/media/fb4a86a49ba2c1c4-s.0h_5frik6_87y.woff2 +0 -0
- package/.next/standalone/.next/static/media/luciole_bold-s.p.0psnmt9gb4e-1.woff2 +0 -0
- package/.next/standalone/.next/static/media/luciole_bolditalic-s.p.02l.qqox3o-3o.woff2 +0 -0
- package/.next/standalone/.next/static/media/luciole_italic-s.p.0vt.gc9ulxy.p.woff2 +0 -0
- package/.next/standalone/.next/static/media/luciole_regular-s.p.0b_wrlnaatliw.woff2 +0 -0
- package/.next/standalone/.next/static/media/miranda_sans_regular-s.p.0s2lp.tajrx9n.woff2 +0 -0
- package/.next/standalone/.next/static/media/stack_sans_notch_regular-s.p.16v-w3iusmqa0.woff2 +0 -0
- package/.next/standalone/.next/static/media/stack_sans_text_regular-s.p.0-4jeegtdke5b.woff2 +0 -0
- package/.next/standalone/next.config.ts +6 -1
- package/.next/standalone/package.json +1 -1
- package/.next/standalone/public/fonts/datatype/datatype-regular.woff2 +0 -0
- package/.next/standalone/public/fonts/elms-sans/elms-sans-regular.woff2 +0 -0
- package/.next/standalone/public/fonts/gambetta/6KRVTMHEY26GBVOWXYL6F3ZLGUXE5ZD5.woff2 +0 -0
- package/.next/standalone/public/fonts/gambetta/ODDSCHC7OZCRRQJDJV5LMJKTGF7URFO4.woff2 +0 -0
- package/.next/standalone/public/fonts/gambetta/RMBKFTS6UFOXVBCL3EVCXLWRQBA3PN4K.woff2 +0 -0
- package/.next/standalone/public/fonts/gambetta/UMQTMTAEPCAFNEJDVEURBIXJENGOHOWO.woff2 +0 -0
- package/.next/standalone/public/fonts/general-sans/3ZLMEXZEQPLTEPMHTQDAUXP5ZZXCZAEN.woff2 +0 -0
- package/.next/standalone/public/fonts/general-sans/7YY3ZAAE3TRV2LANYOLXNHTPHLXVWTKH.woff2 +0 -0
- package/.next/standalone/public/fonts/general-sans/NIQ54PVBBIWVK3PFSOIOUJSXIJ5WTNDP.woff2 +0 -0
- package/.next/standalone/public/fonts/general-sans/SB2OEB6IKZPRR6JT4GFJ2TFT6HBB6AZN.woff2 +0 -0
- package/.next/standalone/public/fonts/general-sans/TW4KNQIPR4LNP4I6I6C6HKQ23B2EQAU5.woff2 +0 -0
- package/.next/standalone/public/fonts/luciole/luciole-bold.woff2 +0 -0
- package/.next/standalone/public/fonts/luciole/luciole-bolditalic.woff2 +0 -0
- package/.next/standalone/public/fonts/luciole/luciole-italic.woff2 +0 -0
- package/.next/standalone/public/fonts/luciole/luciole-regular.woff2 +0 -0
- package/.next/standalone/public/fonts/miranda-sans/miranda-sans-regular.woff2 +0 -0
- package/.next/standalone/public/fonts/satoshi/7AHDUZ4A7LFLVFUIFSARGIWCRQJHISQP.woff2 +0 -0
- package/.next/standalone/public/fonts/satoshi/GHM6WVH6MILNYOOCXHXB5GTSGNTMGXZR.woff2 +0 -0
- package/.next/standalone/public/fonts/satoshi/J64QX5IPOHK56I2KYUNBQ5M2XWZEYKYX.woff2 +0 -0
- package/.next/standalone/public/fonts/satoshi/KFIAZD4RUMEZIYV6FQ3T3GP5PDBDB6JY.woff2 +0 -0
- package/.next/standalone/public/fonts/satoshi/WNDVG7O66ENLOD43GS7FBUCC4KMT5OM2.woff2 +0 -0
- package/.next/standalone/public/fonts/sentient/433XP6QWDVL6KQ5K7ZCOP524TX4LE4RJ.woff2 +0 -0
- package/.next/standalone/public/fonts/sentient/RNUZPHMIVMPXFHVACRGCAJ32E6WUEDVU.woff2 +0 -0
- package/.next/standalone/public/fonts/sentient/SIH66VPT4WS2HIF5PEJNDU4INNUF54LG.woff2 +0 -0
- package/.next/standalone/public/fonts/stack-sans-notch/stack-sans-notch-regular.woff2 +0 -0
- package/.next/standalone/public/fonts/stack-sans-text/stack-sans-text-regular.woff2 +0 -0
- package/.next/standalone/server.js +1 -1
- package/package.json +1 -1
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0txwwn-._.js +0 -3
- package/.next/standalone/.next/server/chunks/ssr/_00pku9f._.js +0 -3
- package/.next/standalone/.next/server/chunks/ssr/_0_.s7b8._.js +0 -3
- package/.next/standalone/.next/static/chunks/0aeii_m.9~9_t.js +0 -1
- package/.next/standalone/.next/static/chunks/0n7px0u5.eizf.css +0 -9
- package/.next/standalone/.next/static/chunks/0wu_n6m9jg8rn.js +0 -1
- package/.next/standalone/.next/static/chunks/0yixq3fhhpk~9.js +0 -172
- /package/.next/standalone/.next/static/{I6ZpQF8Ua7ytNZMW5ZKWH → AqBflLFmUjqZRSJnyGwXw}/_buildManifest.js +0 -0
- /package/.next/standalone/.next/static/{I6ZpQF8Ua7ytNZMW5ZKWH → AqBflLFmUjqZRSJnyGwXw}/_clientMiddlewareManifest.js +0 -0
- /package/.next/standalone/.next/static/{I6ZpQF8Ua7ytNZMW5ZKWH → AqBflLFmUjqZRSJnyGwXw}/_ssgManifest.js +0 -0
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,292494,(e,t,n)=>{"use strict";Object.defineProperty(n,"__esModule",{value:!0}),Object.defineProperty(n,"BailoutToCSR",{enumerable:!0,get:function(){return i}});let r=e.r(217843);function i({reason:e,children:t}){if("u"<typeof window)throw Object.defineProperty(new r.BailoutToCSRError(e),"__NEXT_ERROR_CODE",{value:"E394",enumerable:!1,configurable:!0});return t}},431865,(e,t,n)=>{"use strict";function r(e){return e.split("/").map(e=>encodeURIComponent(e)).join("/")}Object.defineProperty(n,"__esModule",{value:!0}),Object.defineProperty(n,"encodeURIPath",{enumerable:!0,get:function(){return r}})},811970,(e,t,n)=>{"use strict";Object.defineProperty(n,"__esModule",{value:!0}),Object.defineProperty(n,"PreloadChunks",{enumerable:!0,get:function(){return l}});let r=e.r(44501),i=e.r(380560),s=e.r(55656),o=e.r(431865),a=e.r(406031);function l({moduleIds:e}){if("u">typeof window)return null;let t=s.workAsyncStorage.getStore();if(void 0===t)return null;let n=[];if(t.reactLoadableManifest&&e){let r=t.reactLoadableManifest;for(let t of e){if(!r[t])continue;let e=r[t].files;n.push(...e)}}if(0===n.length)return null;let c=(0,a.getAssetTokenQuery)();return(0,r.jsx)(r.Fragment,{children:n.map(e=>{let n=`${t.assetPrefix}/_next/${(0,o.encodeURIPath)(e)}${c}`;return e.endsWith(".css")?(0,r.jsx)("link",{precedence:"dynamic",href:n,rel:"stylesheet",as:"style",nonce:t.nonce},e):((0,i.preload)(n,{as:"script",fetchPriority:"low",nonce:t.nonce}),null)})})}},885022,(e,t,n)=>{"use strict";Object.defineProperty(n,"__esModule",{value:!0}),Object.defineProperty(n,"default",{enumerable:!0,get:function(){return c}});let r=e.r(44501),i=e.r(101685),s=e.r(292494),o=e.r(811970);function a(e){return{default:e&&"default"in e?e.default:e}}let l={loader:()=>Promise.resolve(a(()=>null)),loading:null,ssr:!0},c=function(e){let t={...l,...e},n=(0,i.lazy)(()=>t.loader().then(a)),c=t.loading;function d(e){let a=c?(0,r.jsx)(c,{isLoading:!0,pastDelay:!0,error:null}):null,l=!t.ssr||!!t.loading,d=l?i.Suspense:i.Fragment,u=t.ssr?(0,r.jsxs)(r.Fragment,{children:["u"<typeof window?(0,r.jsx)(o.PreloadChunks,{moduleIds:t.modules}):null,(0,r.jsx)(n,{...e})]}):(0,r.jsx)(s.BailoutToCSR,{reason:"next/dynamic",children:(0,r.jsx)(n,{...e})});return(0,r.jsx)(d,{...l?{fallback:a}:{},children:u})}return d.displayName="LoadableComponent",d}},75470,(e,t,n)=>{"use strict";Object.defineProperty(n,"__esModule",{value:!0}),Object.defineProperty(n,"default",{enumerable:!0,get:function(){return i}});let r=e.r(481258)._(e.r(885022));function i(e,t){let n={};"function"==typeof e&&(n.loader=e);let i={...n,...t};return(0,r.default)({...i,modules:i.loadableGenerated?.modules})}("function"==typeof n.default||"object"==typeof n.default&&null!==n.default)&&void 0===n.default.__esModule&&(Object.defineProperty(n.default,"__esModule",{value:!0}),Object.assign(n.default,n),t.exports=n.default)},804150,(e,t,n)=>{"use strict";var r=e.r(101685),i="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},s=r.useState,o=r.useEffect,a=r.useLayoutEffect,l=r.useDebugValue;function c(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!i(e,n)}catch(e){return!0}}var d="u"<typeof window||void 0===window.document||void 0===window.document.createElement?function(e,t){return t()}:function(e,t){var n=t(),r=s({inst:{value:n,getSnapshot:t}}),i=r[0].inst,d=r[1];return a(function(){i.value=n,i.getSnapshot=t,c(i)&&d({inst:i})},[e,n,t]),o(function(){return c(i)&&d({inst:i}),e(function(){c(i)&&d({inst:i})})},[e]),l(n),n};n.useSyncExternalStore=void 0!==r.useSyncExternalStore?r.useSyncExternalStore:d},3909,(e,t,n)=>{"use strict";t.exports=e.r(804150)},757890,(e,t,n)=>{"use strict";var r=e.r(101685),i=e.r(3909),s="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},o=i.useSyncExternalStore,a=r.useRef,l=r.useEffect,c=r.useMemo,d=r.useDebugValue;n.useSyncExternalStoreWithSelector=function(e,t,n,r,i){var u=a(null);if(null===u.current){var p={hasValue:!1,value:null};u.current=p}else p=u.current;var h=o(e,(u=c(function(){function e(e){if(!l){if(l=!0,o=e,e=r(e),void 0!==i&&p.hasValue){var t=p.value;if(i(t,e))return a=t}return a=e}if(t=a,s(o,e))return t;var n=r(e);return void 0!==i&&i(t,n)?(o=e,t):(o=e,a=n)}var o,a,l=!1,c=void 0===n?null:n;return[function(){return e(t())},null===c?void 0:function(){return e(c())}]},[t,n,r,i]))[0],u[1]);return l(function(){p.hasValue=!0,p.value=h},[h]),d(h),h}},383835,(e,t,n)=>{"use strict";t.exports=e.r(757890)},454184,(e,t,n)=>{class r{constructor(e){void 0===e.data&&(e.data={}),this.data=e.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}}function i(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function s(e,...t){let n=Object.create(null);for(let t in e)n[t]=e[t];return t.forEach(function(e){for(let t in e)n[t]=e[t]}),n}class o{constructor(e,t){this.buffer="",this.classPrefix=t.classPrefix,e.walk(this)}addText(e){this.buffer+=i(e)}openNode(e){if(!e.scope)return;let t=((e,{prefix:t})=>{if(e.startsWith("language:"))return e.replace("language:","language-");if(e.includes(".")){let n=e.split(".");return[`${t}${n.shift()}`,...n.map((e,t)=>`${e}${"_".repeat(t+1)}`)].join(" ")}return`${t}${e}`})(e.scope,{prefix:this.classPrefix});this.span(t)}closeNode(e){e.scope&&(this.buffer+="</span>")}value(){return this.buffer}span(e){this.buffer+=`<span class="${e}">`}}let a=(e={})=>{let t={children:[]};return Object.assign(t,e),t};class l{constructor(){this.rootNode=a(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(e){this.top.children.push(e)}openNode(e){let t=a({scope:e});this.add(t),this.stack.push(t)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(e){return this.constructor._walk(e,this.rootNode)}static _walk(e,t){return"string"==typeof t?e.addText(t):t.children&&(e.openNode(t),t.children.forEach(t=>this._walk(e,t)),e.closeNode(t)),e}static _collapse(e){"string"==typeof e||e.children&&(e.children.every(e=>"string"==typeof e)?e.children=[e.children.join("")]:e.children.forEach(e=>{l._collapse(e)}))}}class c extends l{constructor(e){super(),this.options=e}addText(e){""!==e&&this.add(e)}startScope(e){this.openNode(e)}endScope(){this.closeNode()}__addSublanguage(e,t){let n=e.root;t&&(n.scope=`language:${t}`),this.add(n)}toHTML(){return new o(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}}function d(e){return e?"string"==typeof e?e:e.source:null}function u(e){return f("(?=",e,")")}function p(e){return f("(?:",e,")*")}function h(e){return f("(?:",e,")?")}function f(...e){return e.map(e=>d(e)).join("")}function m(...e){let t;return"("+(("object"==typeof(t=e[e.length-1])&&t.constructor===Object?(e.splice(e.length-1,1),t):{}).capture?"":"?:")+e.map(e=>d(e)).join("|")+")"}function g(e){return RegExp(e.toString()+"|").exec("").length-1}let b=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function x(e,{joinWith:t}){let n=0;return e.map(e=>{let t=n+=1,r=d(e),i="";for(;r.length>0;){let e=b.exec(r);if(!e){i+=r;break}i+=r.substring(0,e.index),r=r.substring(e.index+e[0].length),"\\"===e[0][0]&&e[1]?i+="\\"+String(Number(e[1])+t):(i+=e[0],"("===e[0]&&n++)}return i}).map(e=>`(${e})`).join(t)}let y="[a-zA-Z]\\w*",v="[a-zA-Z_]\\w*",w="\\b\\d+(\\.\\d+)?",k="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",N="\\b(0b[01]+)",S={begin:"\\\\[\\s\\S]",relevance:0},C=function(e,t,n={}){let r=s({scope:"comment",begin:e,end:t,contains:[]},n);r.contains.push({scope:"doctag",begin:"[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)",end:/(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/,excludeBegin:!0,relevance:0});let i=m("I","a","is","so","us","to","at","if","in","it","on",/[A-Za-z]+['](d|ve|re|ll|t|s|n)/,/[A-Za-z]+[-][a-z]+/,/[A-Za-z][a-z]{2,}/);return r.contains.push({begin:f(/[ ]+/,"(",i,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),r},j=C("//","$"),E=C("/\\*","\\*/"),M=C("#","$");var A=Object.freeze({__proto__:null,APOS_STRING_MODE:{scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[S]},BACKSLASH_ESCAPE:S,BINARY_NUMBER_MODE:{scope:"number",begin:N,relevance:0},BINARY_NUMBER_RE:N,COMMENT:C,C_BLOCK_COMMENT_MODE:E,C_LINE_COMMENT_MODE:j,C_NUMBER_MODE:{scope:"number",begin:k,relevance:0},C_NUMBER_RE:k,END_SAME_AS_BEGIN:function(e){return Object.assign(e,{"on:begin":(e,t)=>{t.data._beginMatch=e[1]},"on:end":(e,t)=>{t.data._beginMatch!==e[1]&&t.ignoreMatch()}})},HASH_COMMENT_MODE:M,IDENT_RE:y,MATCH_NOTHING_RE:/\b\B/,METHOD_GUARD:{begin:"\\.\\s*"+v,relevance:0},NUMBER_MODE:{scope:"number",begin:w,relevance:0},NUMBER_RE:w,PHRASAL_WORDS_MODE:{begin:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/},QUOTE_STRING_MODE:{scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[S]},REGEXP_MODE:{scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[S,{begin:/\[/,end:/\]/,relevance:0,contains:[S]}]},RE_STARTERS_RE:"!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",SHEBANG:(e={})=>{let t=/^#![ ]*\//;return e.binary&&(e.begin=f(t,/.*\b/,e.binary,/\b.*/)),s({scope:"meta",begin:t,end:/$/,relevance:0,"on:begin":(e,t)=>{0!==e.index&&t.ignoreMatch()}},e)},TITLE_MODE:{scope:"title",begin:y,relevance:0},UNDERSCORE_IDENT_RE:v,UNDERSCORE_TITLE_MODE:{scope:"title",begin:v,relevance:0}});function T(e,t){"."===e.input[e.index-1]&&t.ignoreMatch()}function O(e,t){void 0!==e.className&&(e.scope=e.className,delete e.className)}function _(e,t){!t||e.beginKeywords&&(e.begin="\\b("+e.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",e.__beforeBegin=T,e.keywords=e.keywords||e.beginKeywords,delete e.beginKeywords,void 0===e.relevance&&(e.relevance=0))}function D(e,t){Array.isArray(e.illegal)&&(e.illegal=m(...e.illegal))}function R(e,t){if(e.match){if(e.begin||e.end)throw Error("begin & end are not supported with match");e.begin=e.match,delete e.match}}function I(e,t){void 0===e.relevance&&(e.relevance=1)}let L=(e,t)=>{if(!e.beforeMatch)return;if(e.starts)throw Error("beforeMatch cannot be used with starts");let n=Object.assign({},e);Object.keys(e).forEach(t=>{delete e[t]}),e.keywords=n.keywords,e.begin=f(n.beforeMatch,u(n.begin)),e.starts={relevance:0,contains:[Object.assign(n,{endsParent:!0})]},e.relevance=0,delete n.beforeMatch},P=["of","and","for","in","not","or","if","then","parent","list","value"],z={},$=e=>{console.error(e)},B=(e,...t)=>{console.log(`WARN: ${e}`,...t)},F=(e,t)=>{z[`${e}/${t}`]||(console.log(`Deprecated as of ${e}. ${t}`),z[`${e}/${t}`]=!0)},H=Error();function U(e,t,{key:n}){let r=0,i=e[n],s={},o={};for(let e=1;e<=t.length;e++)o[e+r]=i[e],s[e+r]=!0,r+=g(t[e-1]);e[n]=o,e[n]._emit=s,e[n]._multi=!0}function V(e){if(e.scope&&"object"==typeof e.scope&&null!==e.scope&&(e.beginScope=e.scope,delete e.scope),"string"==typeof e.beginScope&&(e.beginScope={_wrap:e.beginScope}),"string"==typeof e.endScope&&(e.endScope={_wrap:e.endScope}),Array.isArray(e.begin)){if(e.skip||e.excludeBegin||e.returnBegin)throw $("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),H;if("object"!=typeof e.beginScope||null===e.beginScope)throw $("beginScope must be object"),H;U(e,e.begin,{key:"beginScope"}),e.begin=x(e.begin,{joinWith:""})}if(Array.isArray(e.end)){if(e.skip||e.excludeEnd||e.returnEnd)throw $("skip, excludeEnd, returnEnd not compatible with endScope: {}"),H;if("object"!=typeof e.endScope||null===e.endScope)throw $("endScope must be object"),H;U(e,e.end,{key:"endScope"}),e.end=x(e.end,{joinWith:""})}}class W extends Error{constructor(e,t){super(e),this.name="HTMLInjectionError",this.html=t}}let q=Symbol("nomatch"),K=function(e){let t=Object.create(null),n=Object.create(null),o=[],a=!0,l="Could not find the language '{}', did you forget to load/include a language module?",b={disableAutodetect:!0,name:"Plain text",contains:[]},y={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:c};function v(e){return y.noHighlightRe.test(e)}function w(e,t,n){let r="",i="";"object"==typeof t?(r=e,n=t.ignoreIllegals,i=t.language):(F("10.7.0","highlight(lang, code, ...args) has been deprecated."),F("10.7.0","Please use highlight(code, options) instead.\nhttps://github.com/highlightjs/highlight.js/issues/2277"),i=e,r=t),void 0===n&&(n=!0);let s={code:r,language:i};z("before:highlight",s);let o=s.result?s.result:k(s.language,s.code,n);return o.code=s.code,z("after:highlight",o),o}function k(e,n,o,c){let u=Object.create(null);function p(){if(!M.keywords)return void T.addText(B);let e=0;M.keywordPatternRe.lastIndex=0;let t=M.keywordPatternRe.exec(B),n="";for(;t;){n+=B.substring(e,t.index);let r=S.case_insensitive?t[0].toLowerCase():t[0],i=M.keywords[r];if(i){let[e,s]=i;if(T.addText(n),n="",u[r]=(u[r]||0)+1,u[r]<=7&&(F+=s),e.startsWith("_"))n+=t[0];else{let n=S.classNameAliases[e]||e;f(t[0],n)}}else n+=t[0];e=M.keywordPatternRe.lastIndex,t=M.keywordPatternRe.exec(B)}n+=B.substring(e),T.addText(n)}function h(){null!=M.subLanguage?function(){if(""===B)return;let e=null;if("string"==typeof M.subLanguage){if(!t[M.subLanguage])return T.addText(B);e=k(M.subLanguage,B,!0,A[M.subLanguage]),A[M.subLanguage]=e._top}else e=N(B,M.subLanguage.length?M.subLanguage:null);M.relevance>0&&(F+=e.relevance),T.__addSublanguage(e._emitter,e.language)}():p(),B=""}function f(e,t){""!==e&&(T.startScope(t),T.addText(e),T.endScope())}function m(e,t){let n=1,r=t.length-1;for(;n<=r;){if(!e._emit[n]){n++;continue}let r=S.classNameAliases[e[n]]||e[n],i=t[n];r?f(i,r):(B=i,p(),B=""),n++}}function b(e,t){return e.scope&&"string"==typeof e.scope&&T.openNode(S.classNameAliases[e.scope]||e.scope),e.beginScope&&(e.beginScope._wrap?(f(B,S.classNameAliases[e.beginScope._wrap]||e.beginScope._wrap),B=""):e.beginScope._multi&&(m(e.beginScope,t),B="")),M=Object.create(e,{parent:{value:M}})}let v={};function w(t,i){let s=i&&i[0];if(B+=t,null==s)return h(),0;if("begin"===v.type&&"end"===i.type&&v.index===i.index&&""===s){if(B+=n.slice(i.index,i.index+1),!a){let t=Error(`0 width match regex (${e})`);throw t.languageName=e,t.badRule=v.rule,t}return 1}if(v=i,"begin"===i.type){let e=i[0],t=i.rule,n=new r(t);for(let r of[t.__beforeBegin,t["on:begin"]])if(r&&(r(i,n),n.isMatchIgnored))return 0===M.matcher.regexIndex?(B+=e[0],1):(W=!0,0);return t.skip?B+=e:(t.excludeBegin&&(B+=e),h(),t.returnBegin||t.excludeBegin||(B=e)),b(t,i),t.returnBegin?0:e.length}if("illegal"!==i.type||o){if("end"===i.type){let e=function(e){let t=e[0],i=n.substring(e.index),s=function e(t,n,i){var s;let o,a=(s=t.endRe,(o=s&&s.exec(i))&&0===o.index);if(a){if(t["on:end"]){let e=new r(t);t["on:end"](n,e),e.isMatchIgnored&&(a=!1)}if(a){for(;t.endsParent&&t.parent;)t=t.parent;return t}}if(t.endsWithParent)return e(t.parent,n,i)}(M,e,i);if(!s)return q;let o=M;M.endScope&&M.endScope._wrap?(h(),f(t,M.endScope._wrap)):M.endScope&&M.endScope._multi?(h(),m(M.endScope,e)):o.skip?B+=t:(o.returnEnd||o.excludeEnd||(B+=t),h(),o.excludeEnd&&(B=t));do M.scope&&T.closeNode(),M.skip||M.subLanguage||(F+=M.relevance),M=M.parent;while(M!==s.parent)return s.starts&&b(s.starts,e),o.returnEnd?0:t.length}(i);if(e!==q)return e}}else{let e=Error('Illegal lexeme "'+s+'" for mode "'+(M.scope||"<unnamed>")+'"');throw e.mode=M,e}if("illegal"===i.type&&""===s)return B+="\n",1;if(U>1e5&&U>3*i.index)throw Error("potential infinite loop, way more iterations than matches");return B+=s,s.length}let S=E(e);if(!S)throw $(l.replace("{}",e)),Error('Unknown language: "'+e+'"');let C=function(e){function t(t,n){return RegExp(d(t),"m"+(e.case_insensitive?"i":"")+(e.unicodeRegex?"u":"")+(n?"g":""))}class n{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(e,t){t.position=this.position++,this.matchIndexes[this.matchAt]=t,this.regexes.push([t,e]),this.matchAt+=g(e)+1}compile(){0===this.regexes.length&&(this.exec=()=>null);let e=this.regexes.map(e=>e[1]);this.matcherRe=t(x(e,{joinWith:"|"}),!0),this.lastIndex=0}exec(e){this.matcherRe.lastIndex=this.lastIndex;let t=this.matcherRe.exec(e);if(!t)return null;let n=t.findIndex((e,t)=>t>0&&void 0!==e),r=this.matchIndexes[n];return t.splice(0,n),Object.assign(t,r)}}class r{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(e){if(this.multiRegexes[e])return this.multiRegexes[e];let t=new n;return this.rules.slice(e).forEach(([e,n])=>t.addRule(e,n)),t.compile(),this.multiRegexes[e]=t,t}resumingScanAtSamePosition(){return 0!==this.regexIndex}considerAll(){this.regexIndex=0}addRule(e,t){this.rules.push([e,t]),"begin"===t.type&&this.count++}exec(e){let t=this.getMatcher(this.regexIndex);t.lastIndex=this.lastIndex;let n=t.exec(e);if(this.resumingScanAtSamePosition())if(n&&n.index===this.lastIndex);else{let t=this.getMatcher(0);t.lastIndex=this.lastIndex+1,n=t.exec(e)}return n&&(this.regexIndex+=n.position+1,this.regexIndex===this.count&&this.considerAll()),n}}if(e.compilerExtensions||(e.compilerExtensions=[]),e.contains&&e.contains.includes("self"))throw Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return e.classNameAliases=s(e.classNameAliases||{}),function n(i,o){let a;if(i.isCompiled)return i;[O,R,V,L].forEach(e=>e(i,o)),e.compilerExtensions.forEach(e=>e(i,o)),i.__beforeBegin=null,[_,D,I].forEach(e=>e(i,o)),i.isCompiled=!0;let l=null;return"object"==typeof i.keywords&&i.keywords.$pattern&&(i.keywords=Object.assign({},i.keywords),l=i.keywords.$pattern,delete i.keywords.$pattern),l=l||/\w+/,i.keywords&&(i.keywords=function e(t,n,r="keyword"){let i=Object.create(null);return"string"==typeof t?s(r,t.split(" ")):Array.isArray(t)?s(r,t):Object.keys(t).forEach(function(r){Object.assign(i,e(t[r],n,r))}),i;function s(e,t){n&&(t=t.map(e=>e.toLowerCase())),t.forEach(function(t){var n,r,s;let o=t.split("|");i[o[0]]=[e,(n=o[0],(r=o[1])?Number(r):+(s=n,!P.includes(s.toLowerCase())))]})}}(i.keywords,e.case_insensitive)),i.keywordPatternRe=t(l,!0),o&&(i.begin||(i.begin=/\B|\b/),i.beginRe=t(i.begin),i.end||i.endsWithParent||(i.end=/\B|\b/),i.end&&(i.endRe=t(i.end)),i.terminatorEnd=d(i.end)||"",i.endsWithParent&&o.terminatorEnd&&(i.terminatorEnd+=(i.end?"|":"")+o.terminatorEnd)),i.illegal&&(i.illegalRe=t(i.illegal)),i.contains||(i.contains=[]),i.contains=[].concat(...i.contains.map(function(e){var t;return((t="self"===e?i:e).variants&&!t.cachedVariants&&(t.cachedVariants=t.variants.map(function(e){return s(t,{variants:null},e)})),t.cachedVariants)?t.cachedVariants:!function e(t){return!!t&&(t.endsWithParent||e(t.starts))}(t)?Object.isFrozen(t)?s(t):t:s(t,{starts:t.starts?s(t.starts):null})})),i.contains.forEach(function(e){n(e,i)}),i.starts&&n(i.starts,o),a=new r,i.contains.forEach(e=>a.addRule(e.begin,{rule:e,type:"begin"})),i.terminatorEnd&&a.addRule(i.terminatorEnd,{type:"end"}),i.illegal&&a.addRule(i.illegal,{type:"illegal"}),i.matcher=a,i}(e)}(S),j="",M=c||C,A={},T=new y.__emitter(y),z=[];for(let e=M;e!==S;e=e.parent)e.scope&&z.unshift(e.scope);z.forEach(e=>T.openNode(e));let B="",F=0,H=0,U=0,W=!1;try{if(S.__emitTokens)S.__emitTokens(n,T);else{for(M.matcher.considerAll();;){U++,W?W=!1:M.matcher.considerAll(),M.matcher.lastIndex=H;let e=M.matcher.exec(n);if(!e)break;let t=n.substring(H,e.index),r=w(t,e);H=e.index+r}w(n.substring(H))}return T.finalize(),j=T.toHTML(),{language:e,value:j,relevance:F,illegal:!1,_emitter:T,_top:M}}catch(t){if(t.message&&t.message.includes("Illegal"))return{language:e,value:i(n),illegal:!0,relevance:0,_illegalBy:{message:t.message,index:H,context:n.slice(H-100,H+100),mode:t.mode,resultSoFar:j},_emitter:T};if(a)return{language:e,value:i(n),illegal:!1,relevance:0,errorRaised:t,_emitter:T,_top:M};throw t}}function N(e,n){let r;n=n||y.languages||Object.keys(t);let s=((r={value:i(e),illegal:!1,relevance:0,_top:b,_emitter:new y.__emitter(y)})._emitter.addText(e),r),o=n.filter(E).filter(T).map(t=>k(t,e,!1));o.unshift(s);let[a,l]=o.sort((e,t)=>{if(e.relevance!==t.relevance)return t.relevance-e.relevance;if(e.language&&t.language){if(E(e.language).supersetOf===t.language)return 1;else if(E(t.language).supersetOf===e.language)return -1}return 0});return a.secondBest=l,a}function S(e){var t;let r,i=function(e){let t=e.className+" ";t+=e.parentNode?e.parentNode.className:"";let n=y.languageDetectRe.exec(t);if(n){let t=E(n[1]);return t||(B(l.replace("{}",n[1])),B("Falling back to no-highlight mode for this block.",e)),t?n[1]:"no-highlight"}return t.split(/\s+/).find(e=>v(e)||E(e))}(e);if(v(i))return;if(z("before:highlightElement",{el:e,language:i}),e.dataset.highlighted)return void console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",e);if(e.children.length>0&&(y.ignoreUnescapedHTML||(console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk."),console.warn("https://github.com/highlightjs/highlight.js/wiki/security"),console.warn("The element with unescaped HTML:"),console.warn(e)),y.throwUnescapedHTML))throw new W("One of your code blocks includes unescaped HTML.",e.innerHTML);let s=e.textContent,o=i?w(s,{language:i,ignoreIllegals:!0}):N(s);e.innerHTML=o.value,e.dataset.highlighted="yes",t=o.language,r=i&&n[i]||t,e.classList.add("hljs"),e.classList.add(`language-${r}`),e.result={language:o.language,re:o.relevance,relevance:o.relevance},o.secondBest&&(e.secondBest={language:o.secondBest.language,relevance:o.secondBest.relevance}),z("after:highlightElement",{el:e,result:o,text:s})}let C=!1;function j(){if("loading"===document.readyState){C||window.addEventListener("DOMContentLoaded",function(){j()},!1),C=!0;return}document.querySelectorAll(y.cssSelector).forEach(S)}function E(e){return t[e=(e||"").toLowerCase()]||t[n[e]]}function M(e,{languageName:t}){"string"==typeof e&&(e=[e]),e.forEach(e=>{n[e.toLowerCase()]=t})}function T(e){let t=E(e);return t&&!t.disableAutodetect}function z(e,t){o.forEach(function(n){n[e]&&n[e](t)})}for(let r in Object.assign(e,{highlight:w,highlightAuto:N,highlightAll:j,highlightElement:S,highlightBlock:function(e){return F("10.7.0","highlightBlock will be removed entirely in v12.0"),F("10.7.0","Please use highlightElement now."),S(e)},configure:function(e){y=s(y,e)},initHighlighting:()=>{j(),F("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")},initHighlightingOnLoad:function(){j(),F("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")},registerLanguage:function(n,r){let i=null;try{i=r(e)}catch(e){if($("Language definition for '{}' could not be registered.".replace("{}",n)),a)$(e);else throw e;i=b}i.name||(i.name=n),t[n]=i,i.rawDefinition=r.bind(null,e),i.aliases&&M(i.aliases,{languageName:n})},unregisterLanguage:function(e){for(let r of(delete t[e],Object.keys(n)))n[r]===e&&delete n[r]},listLanguages:function(){return Object.keys(t)},getLanguage:E,registerAliases:M,autoDetection:T,inherit:s,addPlugin:function(e){var t;(t=e)["before:highlightBlock"]&&!t["before:highlightElement"]&&(t["before:highlightElement"]=e=>{t["before:highlightBlock"](Object.assign({block:e.el},e))}),t["after:highlightBlock"]&&!t["after:highlightElement"]&&(t["after:highlightElement"]=e=>{t["after:highlightBlock"](Object.assign({block:e.el},e))}),o.push(e)},removePlugin:function(e){let t=o.indexOf(e);-1!==t&&o.splice(t,1)}}),e.debugMode=function(){a=!1},e.safeMode=function(){a=!0},e.versionString="11.11.1",e.regex={concat:f,lookahead:u,either:m,optional:h,anyNumberOfTimes:p},A)"object"==typeof A[r]&&function e(t){return t instanceof Map?t.clear=t.delete=t.set=function(){throw Error("map is read-only")}:t instanceof Set&&(t.add=t.clear=t.delete=function(){throw Error("set is read-only")}),Object.freeze(t),Object.getOwnPropertyNames(t).forEach(n=>{let r=t[n],i=typeof r;"object"!==i&&"function"!==i||Object.isFrozen(r)||e(r)}),t}(A[r]);return Object.assign(e,A),e},G=K({});G.newInstance=()=>K({}),t.exports=G,G.HighlightJS=G,G.default=G},952683,e=>{"use strict";let t,n;var r,i,s=e.i(44501),o=e.i(605993);let a=(0,o.default)("bot",[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]]);var l=e.i(764143);let c=(0,o.default)("globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]);var d=e.i(264917),u=e.i(691520);let p=(0,o.default)("panel-left-open",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m14 9 3 3-3 3",key:"8010ee"}]]),h=(0,o.default)("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);var f=e.i(101685),m=e.i(425732),g=e.i(43240);let b=(0,o.default)("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]),x=(0,o.default)("key",[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]]),y=(0,o.default)("rotate-ccw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);var v=e.i(519455),w=e.i(291967),k=e.i(967928),N=e.i(543250),S=e.i(433616),C=e.i(417256),j=e.i(348989),E=e.i(445424),M=e.i(332374),A=e.i(190088),T=e.i(980939),O=e.i(539340),_=e.i(206500),D=e.i(73772),R=e.i(652053),I="Dialog",[L,P]=(0,N.createContextScope)(I),[z,$]=L(I),B=e=>{let{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:o,modal:a=!0}=e,l=f.useRef(null),c=f.useRef(null),[d,u]=(0,C.useControllableState)({prop:r,defaultProp:i??!1,onChange:o,caller:I});return(0,s.jsx)(z,{scope:t,triggerRef:l,contentRef:c,contentId:(0,S.useId)(),titleId:(0,S.useId)(),descriptionId:(0,S.useId)(),open:d,onOpenChange:u,onOpenToggle:f.useCallback(()=>u(e=>!e),[u]),modal:a,children:n})};B.displayName=I;var F="DialogTrigger";f.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=$(F,n),o=(0,k.useComposedRefs)(t,i.triggerRef);return(0,s.jsx)(T.Primitive.button,{type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.contentId,"data-state":ea(i.open),...r,ref:o,onClick:(0,w.composeEventHandlers)(e.onClick,i.onOpenToggle)})}).displayName=F;var H="DialogPortal",[U,V]=L(H,{forceMount:void 0}),W=e=>{let{__scopeDialog:t,forceMount:n,children:r,container:i}=e,o=$(H,t);return(0,s.jsx)(U,{scope:t,forceMount:n,children:f.Children.map(r,e=>(0,s.jsx)(A.Presence,{present:n||o.open,children:(0,s.jsx)(M.Portal,{asChild:!0,container:i,children:e})}))})};W.displayName=H;var q="DialogOverlay",K=f.forwardRef((e,t)=>{let n=V(q,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,o=$(q,e.__scopeDialog);return o.modal?(0,s.jsx)(A.Presence,{present:r||o.open,children:(0,s.jsx)(J,{...i,ref:t})}):null});K.displayName=q;var G=(0,R.createSlot)("DialogOverlay.RemoveScroll"),J=f.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=$(q,n);return(0,s.jsx)(_.RemoveScroll,{as:G,allowPinchZoom:!0,shards:[i.contentRef],children:(0,s.jsx)(T.Primitive.div,{"data-state":ea(i.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),Z="DialogContent",X=f.forwardRef((e,t)=>{let n=V(Z,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,o=$(Z,e.__scopeDialog);return(0,s.jsx)(A.Presence,{present:r||o.open,children:o.modal?(0,s.jsx)(Y,{...i,ref:t}):(0,s.jsx)(Q,{...i,ref:t})})});X.displayName=Z;var Y=f.forwardRef((e,t)=>{let n=$(Z,e.__scopeDialog),r=f.useRef(null),i=(0,k.useComposedRefs)(t,n.contentRef,r);return f.useEffect(()=>{let e=r.current;if(e)return(0,D.hideOthers)(e)},[]),(0,s.jsx)(ee,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:(0,w.composeEventHandlers)(e.onCloseAutoFocus,e=>{e.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:(0,w.composeEventHandlers)(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=0===t.button&&!0===t.ctrlKey;(2===t.button||n)&&e.preventDefault()}),onFocusOutside:(0,w.composeEventHandlers)(e.onFocusOutside,e=>e.preventDefault())})}),Q=f.forwardRef((e,t)=>{let n=$(Z,e.__scopeDialog),r=f.useRef(!1),i=f.useRef(!1);return(0,s.jsx)(ee,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,"pointerdown"===t.detail.originalEvent.type&&(i.current=!0));let s=t.target;n.triggerRef.current?.contains(s)&&t.preventDefault(),"focusin"===t.detail.originalEvent.type&&i.current&&t.preventDefault()}})}),ee=f.forwardRef((e,t)=>{let{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:o,...a}=e,l=$(Z,n),c=f.useRef(null),d=(0,k.useComposedRefs)(t,c);return(0,O.useFocusGuards)(),(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(E.FocusScope,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:o,children:(0,s.jsx)(j.DismissableLayer,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":ea(l.open),...a,ref:d,onDismiss:()=>l.onOpenChange(!1)})}),(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(eu,{titleId:l.titleId}),(0,s.jsx)(ep,{contentRef:c,descriptionId:l.descriptionId})]})]})}),et="DialogTitle",en=f.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=$(et,n);return(0,s.jsx)(T.Primitive.h2,{id:i.titleId,...r,ref:t})});en.displayName=et;var er="DialogDescription",ei=f.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=$(er,n);return(0,s.jsx)(T.Primitive.p,{id:i.descriptionId,...r,ref:t})});ei.displayName=er;var es="DialogClose",eo=f.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=$(es,n);return(0,s.jsx)(T.Primitive.button,{type:"button",...r,ref:t,onClick:(0,w.composeEventHandlers)(e.onClick,()=>i.onOpenChange(!1))})});function ea(e){return e?"open":"closed"}eo.displayName=es;var el="DialogTitleWarning",[ec,ed]=(0,N.createContext)(el,{contentName:Z,titleName:et,docsSlug:"dialog"}),eu=({titleId:e})=>{let t=ed(el),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
2
|
+
|
|
3
|
+
If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
4
|
+
|
|
5
|
+
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return f.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},ep=({contentRef:e,descriptionId:t})=>{let n=ed("DialogDescriptionWarning"),r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${n.contentName}}.`;return f.useEffect(()=>{let n=e.current?.getAttribute("aria-describedby");t&&n&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},eh=e.i(975157);let ef=f.forwardRef(({className:e,...t},n)=>(0,s.jsx)(K,{ref:n,className:(0,eh.cn)("fixed inset-0 z-40 bg-overlay backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t}));ef.displayName="SheetOverlay";let em={bottom:"inset-x-0 bottom-0 data-[state=open]:slide-in-from-bottom data-[state=closed]:slide-out-to-bottom",top:"inset-x-0 top-0 data-[state=open]:slide-in-from-top data-[state=closed]:slide-out-to-top",left:"inset-y-0 left-0 data-[state=open]:slide-in-from-left data-[state=closed]:slide-out-to-left",right:"inset-y-0 right-0 data-[state=open]:slide-in-from-right data-[state=closed]:slide-out-to-right"},eg=f.forwardRef(({side:e="bottom",showClose:t=!1,className:n,overlayClassName:r,children:i,...o},a)=>(0,s.jsxs)(W,{children:[(0,s.jsx)(ef,{className:r}),(0,s.jsxs)(X,{ref:a,className:(0,eh.cn)("fixed z-50 bg-background shadow-golden transition-all ease-in-out","data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-200 data-[state=open]:duration-300",em[e],n),...o,children:[i,t&&(0,s.jsxs)(eo,{className:"absolute right-4 top-4 rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring disabled:pointer-events-none",children:[(0,s.jsx)(h,{className:"h-4 w-4"}),(0,s.jsx)("span",{className:"sr-only",children:"Close"})]})]})]}));eg.displayName="SheetContent",f.forwardRef(({className:e,...t},n)=>(0,s.jsx)(en,{ref:n,className:(0,eh.cn)("text-sm font-medium leading-none tracking-tight",e),...t})).displayName="SheetTitle",f.forwardRef(({className:e,...t},n)=>(0,s.jsx)(ei,{ref:n,className:(0,eh.cn)("text-sm text-muted-foreground",e),...t})).displayName="SheetDescription";var eb=e.i(187014);function ex(e,t){eb.toast.success(e,t)}function ey(e,t){eb.toast.error(e,t)}var ev=e.i(354502),ew=e.i(199075),ek=e.i(755146),eN=e.i(534537);let eS={inter:{id:"inter",label:"Inter",kind:"sans",cssValue:"var(--font-inter), ui-sans-serif, system-ui, -apple-system, sans-serif"},satoshi:{id:"satoshi",label:"Satoshi",kind:"sans",cssValue:"var(--font-satoshi), ui-sans-serif, system-ui, -apple-system, sans-serif"},"general-sans":{id:"general-sans",label:"General Sans",kind:"sans",cssValue:"var(--font-general-sans), ui-sans-serif, system-ui, -apple-system, sans-serif"},roboto:{id:"roboto",label:"Roboto",kind:"sans",cssValue:"var(--font-roboto), ui-sans-serif, system-ui, -apple-system, sans-serif"},"open-sans":{id:"open-sans",label:"Open Sans",kind:"sans",cssValue:"var(--font-open-sans), ui-sans-serif, system-ui, -apple-system, sans-serif"},lexend:{id:"lexend",label:"Lexend",kind:"sans",cssValue:"var(--font-lexend), ui-sans-serif, system-ui, -apple-system, sans-serif"},"atkinson-hyperlegible":{id:"atkinson-hyperlegible",label:"Atkinson Hyperlegible",kind:"sans",cssValue:"var(--font-atkinson-hyperlegible), ui-sans-serif, system-ui, -apple-system, sans-serif"},"elms-sans":{id:"elms-sans",label:"Elms Sans",kind:"sans",cssValue:"var(--font-elms-sans), ui-sans-serif, system-ui, -apple-system, sans-serif"},"stack-sans-notch":{id:"stack-sans-notch",label:"Stack Notch",kind:"sans",cssValue:"var(--font-stack-sans-notch), ui-sans-serif, system-ui, -apple-system, sans-serif"},"stack-sans-text":{id:"stack-sans-text",label:"Stack Text",kind:"sans",cssValue:"var(--font-stack-sans-text), ui-sans-serif, system-ui, -apple-system, sans-serif"},datatype:{id:"datatype",label:"Datatype",kind:"sans",cssValue:"var(--font-datatype), ui-sans-serif, system-ui, -apple-system, sans-serif"},"miranda-sans":{id:"miranda-sans",label:"Miranda Sans",kind:"sans",cssValue:"var(--font-miranda-sans), ui-sans-serif, system-ui, -apple-system, sans-serif"},luciole:{id:"luciole",label:"Luciole",kind:"sans",cssValue:"var(--font-luciole), ui-sans-serif, system-ui, -apple-system, sans-serif"},verdana:{id:"verdana",label:"Verdana",kind:"sans",cssValue:"Verdana, Geneva, Tahoma, sans-serif"},newsreader:{id:"newsreader",label:"Newsreader",kind:"serif",cssValue:"var(--font-newsreader), Georgia, serif"},fraunces:{id:"fraunces",label:"Fraunces",kind:"serif",cssValue:"var(--font-fraunces), Georgia, serif"},sentient:{id:"sentient",label:"Sentient",kind:"serif",cssValue:"var(--font-sentient), Georgia, serif"},gambetta:{id:"gambetta",label:"Gambetta",kind:"serif",cssValue:"var(--font-gambetta), Georgia, serif"},merriweather:{id:"merriweather",label:"Merriweather",kind:"serif",cssValue:"var(--font-merriweather), Georgia, serif"},baskerville:{id:"baskerville",label:"Baskerville",kind:"serif",cssValue:"var(--font-libre-baskerville), Georgia, serif"},palatino:{id:"palatino",label:"Palatino",kind:"serif",cssValue:"Palatino Linotype, Palatino, Book Antiqua, Georgia, serif"}},eC=["inter","satoshi","general-sans","roboto","open-sans","lexend","atkinson-hyperlegible","elms-sans","stack-sans-notch","stack-sans-text","datatype","miranda-sans","luciole","verdana"],ej=["inter","satoshi","general-sans","roboto","open-sans","lexend","atkinson-hyperlegible","elms-sans","stack-sans-notch","stack-sans-text","datatype","miranda-sans","luciole","verdana","newsreader","fraunces","sentient","gambetta","merriweather","baskerville","palatino"],eE={classic:{id:"classic",label:"Classic",description:"Inter, Newsreader, Fraunces — the original pairing",fonts:{ui:"inter",body:"newsreader",heading:"fraunces"}},modern:{id:"modern",label:"Modern",description:"Satoshi, Sentient, Gambetta — clean and contemporary",fonts:{ui:"satoshi",body:"sentient",heading:"gambetta"}},literary:{id:"literary",label:"Literary",description:"General Sans, Merriweather, Baskerville — magazine-style contrast",fonts:{ui:"general-sans",body:"merriweather",heading:"baskerville"}},legible:{id:"legible",label:"Legible",description:"Atkinson Hyperlegible, Lexend — built for accessibility",fonts:{ui:"atkinson-hyperlegible",body:"atkinson-hyperlegible",heading:"lexend"}},warm:{id:"warm",label:"Warm",description:"Luciole, Palatino — humanist and generously proportioned",fonts:{ui:"luciole",body:"palatino",heading:"palatino"}},stack:{id:"stack",label:"Stack",description:"Stack Sans Text/Notch, Sentient — display headings, calm reading",fonts:{ui:"stack-sans-text",body:"sentient",heading:"stack-sans-notch"}}},eM=["classic","modern","literary","legible","warm","stack"],eA=[.8,.9,1,1.1,1.2,1.3,1.4,1.5];function eT(e){return"number"==typeof e&&Number.isFinite(e)&&e>=.5&&e<=2}let eO="wiki-fonts",e_="inter",eD="newsreader",eR="fraunces";function eI(e){return`--font-scale-${e}`}function eL(){let e=document.documentElement,t=e.dataset.fontUi||e_,n=e.dataset.fontBody||eD,r=e.dataset.fontHeading||eR,i=(t,n)=>{let r=e.style.getPropertyValue(eI(t)),i=r?Number.parseFloat(r):NaN;return eT(i)?i:n};return{ui:t,body:n,heading:r,uiScale:i("ui",1),bodyScale:i("body",1),headingScale:i("heading",1)}}let eP=(0,eN.create)(e=>{let t=eL();return{ui:t.ui,body:t.body,heading:t.heading,uiScale:t.uiScale,bodyScale:t.bodyScale,headingScale:t.headingScale,setFont:(t,n)=>{{let e=document.documentElement,r=e.dataset.fontUi||e_,i=e.dataset.fontBody||eD,s=e.dataset.fontHeading||eR,o={...eL(),ui:"ui"===t?n:r,body:"body"===t?n:i,heading:"heading"===t?n:s};localStorage.setItem(eO,JSON.stringify(o)),e.dataset.fontUi=o.ui,e.dataset.fontBody=o.body,e.dataset.fontHeading=o.heading}e(e=>"ui"===t?{...e,ui:n}:"body"===t?{...e,body:n}:"heading"===t?{...e,heading:n}:e)},setScale:(t,n)=>{if(eT(n)){{let e=document.documentElement,r=eL(),i={...r,uiScale:"ui"===t?n:r.uiScale,bodyScale:"body"===t?n:r.bodyScale,headingScale:"heading"===t?n:r.headingScale};localStorage.setItem(eO,JSON.stringify(i)),e.style.setProperty(eI(t),String(n))}e(e=>"ui"===t?{...e,uiScale:n}:"body"===t?{...e,bodyScale:n}:"heading"===t?{...e,headingScale:n}:e)}},applyPreset:t=>{let n=eE[t].fonts;{let e=document.documentElement,t={...eL(),ui:n.ui,body:n.body,heading:n.heading};localStorage.setItem(eO,JSON.stringify(t)),e.dataset.fontUi=n.ui,e.dataset.fontBody=n.body,e.dataset.fontHeading=n.heading}e(e=>({...e,ui:n.ui,body:n.body,heading:n.heading}))}}}),ez=[{id:"focusMode",label:"Focus mode",description:"Dim everything except the block you're reading."},{id:"breadcrumb",label:"Sticky breadcrumb",description:"Current heading trail pinned to the top while you scroll."}],e$="wiki-experiments",eB=(0,eN.create)(e=>({flags:function(){let e=Object.fromEntries(ez.map(e=>[e.id,!1]));try{let t=localStorage.getItem(e$),n=t?JSON.parse(t):{};for(let t of ez)"boolean"==typeof n[t.id]&&(e[t.id]=n[t.id])}catch{}return e}(),toggle:t=>e(e=>{let n={...e.flags,[t]:!e.flags[t]};try{localStorage.setItem(e$,JSON.stringify(n))}catch{}return{flags:n}})}));function eF(e){return eB(t=>t.flags[e])}function eH(e){return e.split(/[\n,]/).map(e=>e.trim()).filter(Boolean)}function eU(){let e=eB(e=>e.flags),t=eB(e=>e.toggle);return(0,s.jsx)("div",{className:"space-y-1.5",children:ez.map(n=>{let r=e[n.id];return(0,s.jsxs)("button",{type:"button",onClick:()=>t(n.id),"aria-pressed":r,className:`flex w-full items-start justify-between gap-3 rounded-md border px-3 py-2 text-left transition-colors ${r?"border-ring bg-accent":"border-border hover:bg-accent/50"}`,children:[(0,s.jsxs)("span",{className:"min-w-0",children:[(0,s.jsx)("span",{className:"block text-sm font-medium",children:n.label}),(0,s.jsx)("span",{className:"block text-xs text-muted-foreground",children:n.description})]}),(0,s.jsx)("span",{"aria-hidden":!0,className:`mt-0.5 flex h-5 w-9 shrink-0 items-center rounded-full px-0.5 transition-colors ${r?"bg-primary":"bg-muted-foreground/30"}`,children:(0,s.jsx)("span",{className:`h-4 w-4 rounded-full bg-background transition-transform ${r?"translate-x-4":"translate-x-0"}`})})]},n.id)})})}function eV(){let{ui:e,body:t,heading:n}=eP(),r=eP(e=>e.applyPreset),i=eM.find(r=>{let i=eE[r].fonts;return i.ui===e&&i.body===t&&i.heading===n}),o=i?eE[i]:null;return(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)("p",{className:"text-xs text-muted-foreground font-medium",children:"Quick presets"}),(0,s.jsxs)(ek.DropdownMenu,{children:[(0,s.jsx)(ek.DropdownMenuTrigger,{asChild:!0,children:(0,s.jsxs)("button",{type:"button",className:"w-full flex items-center justify-between gap-2 rounded-md border border-border px-3 py-2 text-sm text-foreground hover:bg-accent/50 transition-colors",children:[(0,s.jsx)("span",{children:o?o.label:"Custom"}),(0,s.jsx)(b,{className:"h-4 w-4 shrink-0 text-muted-foreground"})]})}),(0,s.jsx)(ek.DropdownMenuContent,{className:"w-64",children:eM.map(e=>{let t=eE[e];return(0,s.jsxs)(ek.DropdownMenuItem,{onClick:()=>r(e),className:"flex-col items-start gap-0.5 py-2",children:[(0,s.jsxs)("span",{className:"flex items-center gap-2 w-full",children:[i===e?(0,s.jsx)(g.Check,{className:"h-3.5 w-3.5 shrink-0"}):(0,s.jsx)("span",{className:"w-3.5 shrink-0"}),(0,s.jsx)("span",{className:"font-medium",children:t.label})]}),(0,s.jsx)("span",{className:"pl-[1.375rem] text-xs text-muted-foreground leading-snug",children:t.description})]},e)})})]})]})}function eW({role:e}){let t=eP(),n="ui"===e?t.uiScale:"body"===e?t.bodyScale:t.headingScale,r=eP(e=>e.setScale);return(0,s.jsxs)(ek.DropdownMenu,{children:[(0,s.jsx)(ek.DropdownMenuTrigger,{asChild:!0,children:(0,s.jsxs)("button",{type:"button","aria-label":"Font size",className:"flex items-center gap-1 rounded-md border border-border px-2 py-2 text-sm text-foreground hover:bg-accent/50 transition-colors shrink-0",children:[(0,s.jsxs)("span",{className:"tabular-nums",children:[Math.round(100*n),"%"]}),(0,s.jsx)(b,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"})]})}),(0,s.jsx)(ek.DropdownMenuContent,{align:"end",className:"w-24",children:eA.map(t=>(0,s.jsx)(ek.DropdownMenuItem,{onClick:()=>r(e,t),className:n===t?"font-medium":"",children:(0,s.jsxs)("span",{className:"flex items-center gap-2 w-full",children:[n===t?(0,s.jsx)(g.Check,{className:"h-3.5 w-3.5 shrink-0"}):(0,s.jsx)("span",{className:"w-3.5 shrink-0"}),(0,s.jsxs)("span",{className:"tabular-nums",children:[Math.round(100*t),"%"]})]})},t))})]})}function eq({role:e,ids:t}){let n=eP(),r="ui"===e?n.ui:"body"===e?n.body:n.heading,i=eP(e=>e.setFont),o="ui"===e?"UI font":"body"===e?"Body font":"Heading font";return(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)("p",{className:"text-xs text-muted-foreground font-medium",children:o}),(0,s.jsxs)("div",{className:"flex gap-1.5",children:[(0,s.jsxs)(ek.DropdownMenu,{children:[(0,s.jsx)(ek.DropdownMenuTrigger,{asChild:!0,children:(0,s.jsxs)("button",{type:"button",className:"flex-1 min-w-0 flex items-center justify-between gap-2 rounded-md border border-border px-3 py-2 text-sm text-foreground hover:bg-accent/50 transition-colors",children:[(0,s.jsx)("span",{className:"truncate",children:eS[r]?.label??"Select font"}),(0,s.jsx)(b,{className:"h-4 w-4 shrink-0 text-muted-foreground"})]})}),(0,s.jsx)(ek.DropdownMenuContent,{className:"w-56",children:t.map(t=>{let n=eS[t];return(0,s.jsx)(ek.DropdownMenuItem,{onClick:()=>i(e,t),className:r===t?"font-medium":"",children:(0,s.jsxs)("span",{className:"flex items-center gap-2 w-full",children:[r===t?(0,s.jsx)(g.Check,{className:"h-3.5 w-3.5 shrink-0"}):(0,s.jsx)("span",{className:"w-3.5 shrink-0"}),(0,s.jsx)("span",{style:{fontFamily:n.cssValue},children:n.label})]})},t)})})]}),(0,s.jsx)(eW,{role:e})]})]})}function eK({open:e,onOpenChange:t}){let[n,r]=(0,f.useState)(!1),[i,o]=(0,f.useState)(!1),[a,l]=(0,f.useState)(null),[c,d]=(0,f.useState)("env"),[p,b]=(0,f.useState)(""),[w,k]=(0,f.useState)(""),[N,S]=(0,f.useState)(null),{data:C}=ew.authClient.useSession(),[j,E]=(0,f.useState)(!1),[M,A]=(0,f.useState)([]),[T,O]=(0,f.useState)([]),[_,D]=(0,f.useState)(null),[R,I]=(0,f.useState)(null),[L,P]=(0,f.useState)(""),[z,$]=(0,f.useState)(""),[F,H]=(0,f.useState)(!1),[U,V]=(0,f.useState)(null),[W,q]=(0,f.useState)(null),[K,G]=(0,f.useState)(!1),[J,Z]=(0,f.useState)(!1),X=(0,f.useCallback)(async()=>{try{let e=await fetch((0,ev.apiUrl)("/api/system/admins"));if(!e.ok)return;let t=await e.json();E(!!t.isAdmin),A(t.admins??[]),O(t.users??[])}catch{}},[]),Y=(0,f.useCallback)(async()=>{r(!0),l(null);try{let e=await fetch((0,ev.apiUrl)("/api/system/auth-settings"));if(!e.ok)throw Error("Failed to load settings");let t=await e.json();b(t.allowedEmails.join("\n")),k(t.allowedDomains.join("\n")),d(t.source),S("number"==typeof t.rateLimit?t.rateLimit:null)}catch(e){l(e instanceof Error?e.message:"Failed to load")}finally{r(!1)}},[]),Q=(0,f.useCallback)(async()=>{try{let e=await fetch((0,ev.apiUrl)("/api/system/api-key"));if(!e.ok)return;let t=await e.json();q(t.key??null)}catch{}},[]);async function ee(){o(!0),l(null);try{let e=await fetch((0,ev.apiUrl)("/api/system/auth-settings"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({allowedEmails:eH(p),allowedDomains:eH(w)})}),n=await e.json();if(!e.ok){l(n.error??"Save failed"),ey(n.error??"Save failed");return}n.source&&d(n.source),t(!1)}catch{l("Save failed")}finally{o(!1)}}(0,f.useEffect)(()=>{e&&(Y(),X(),Q())},[e,Y,X,Q]);let et=0===eH(p).length&&0===eH(w).length;return(0,s.jsx)(B,{open:e,onOpenChange:t,children:(0,s.jsxs)(eg,{side:"right",className:"w-[90vw] max-w-sm md:w-80 sm:max-w-md flex flex-col border-l border-border p-0",overlayClassName:"backdrop-blur-none",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between border-b border-border px-4 py-3 shrink-0",children:[(0,s.jsx)("span",{className:"text-sm font-semibold",children:"Settings"}),(0,s.jsxs)(eo,{className:"flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:bg-accent focus:outline-none focus:ring-2 focus:ring-ring",children:[(0,s.jsx)(h,{className:"h-3.5 w-3.5"}),(0,s.jsx)("span",{className:"sr-only",children:"Close"})]})]}),n?(0,s.jsx)("div",{className:"flex flex-1 items-center justify-center",children:(0,s.jsx)(u.Loader2,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):(0,s.jsxs)("div",{className:"flex-1 space-y-5 overflow-y-auto px-4 py-4",children:[C?.user&&(0,s.jsxs)("section",{className:"space-y-2",children:[(0,s.jsx)("h3",{className:"text-xs font-semibold uppercase tracking-widest text-muted-foreground",children:"Account"}),(0,s.jsxs)("div",{className:"flex items-center justify-between rounded-md border border-border bg-muted/40 p-3",children:[(0,s.jsxs)("div",{className:"text-sm min-w-0",children:[(0,s.jsx)("div",{className:"font-medium truncate",children:C.user.name}),(0,s.jsx)("div",{className:"text-xs text-muted-foreground truncate",children:C.user.email})]}),(0,s.jsx)("button",{type:"button",onClick:async()=>{await ew.authClient.signOut(),window.location.href=(0,ev.apiUrl)("/signin")},className:"ml-2 shrink-0 text-xs px-2 py-1 rounded border border-border hover:bg-accent",children:"Sign out"})]})]}),(0,s.jsxs)("section",{className:"space-y-2",children:[(0,s.jsx)("h3",{className:"text-xs font-semibold uppercase tracking-widest text-muted-foreground",children:"Typography"}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:"Choose fonts for interface chrome, body text, and headings. Mix and match freely, or use a preset."}),(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsx)(eV,{}),(0,s.jsx)(eq,{role:"ui",ids:eC}),(0,s.jsx)(eq,{role:"body",ids:ej}),(0,s.jsx)(eq,{role:"heading",ids:ej})]})]}),(0,s.jsxs)("section",{className:"space-y-2",children:[(0,s.jsx)("h3",{className:"text-xs font-semibold uppercase tracking-widest text-muted-foreground",children:"Lab"}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:"Experimental reading features. Toggle each on or off. Saved on this device."}),(0,s.jsx)(eU,{})]}),(0,s.jsxs)("section",{className:"space-y-2",children:[(0,s.jsx)("h3",{className:"text-xs font-semibold uppercase tracking-widest text-muted-foreground",children:"Signup allowlist"}),(0,s.jsxs)("p",{className:"text-xs leading-relaxed text-muted-foreground",children:["Control who can create an account. Leave both lists empty to allow any email. Saving here overrides the"," ",(0,s.jsx)("code",{className:"bg-muted px-0.5 rounded",children:"AUTH_ALLOWED_EMAILS"})," ","and"," ",(0,s.jsx)("code",{className:"bg-muted px-0.5 rounded",children:"AUTH_ALLOWED_DOMAIN"})," ","environment variables."]}),"env"===c&&(0,s.jsxs)("div",{className:"flex items-start gap-2 rounded-md bg-muted px-3 py-2 text-xs text-muted-foreground",children:[(0,s.jsx)(m.AlertCircle,{className:"h-3.5 w-3.5 shrink-0 mt-0.5"}),(0,s.jsx)("span",{children:"Current values come from environment variables. Saving moves the allowlist into config and takes precedence going forward."})]}),(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)("label",{htmlFor:"allowed-emails",className:"text-sm font-medium",children:"Allowed emails"}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:"One per line (or comma-separated). Exact match, case-insensitive."}),(0,s.jsx)("textarea",{id:"allowed-emails",value:p,onChange:e=>b(e.target.value),spellCheck:!1,rows:5,placeholder:"alice@example.com bob@example.com",className:"w-full resize-y rounded-md border border-border bg-background px-3 py-2 font-mono text-sm outline-none focus:ring-2 focus:ring-primary"})]}),(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)("label",{htmlFor:"allowed-domains",className:"text-sm font-medium",children:"Allowed domains"}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:"One per line (or comma-separated). Matches any email at that domain."}),(0,s.jsx)("textarea",{id:"allowed-domains",value:w,onChange:e=>k(e.target.value),spellCheck:!1,rows:4,placeholder:"example.com trusted.org",className:"w-full resize-y rounded-md border border-border bg-background px-3 py-2 font-mono text-sm outline-none focus:ring-2 focus:ring-primary"})]}),et&&(0,s.jsxs)("div",{className:"flex items-start gap-2 rounded-md bg-warning-soft px-3 py-2 text-xs text-warning-ink",children:[(0,s.jsx)(m.AlertCircle,{className:"h-3.5 w-3.5 shrink-0 mt-0.5"}),(0,s.jsx)("span",{children:"Both lists are empty. Anyone with the signup URL can create an account."})]}),a&&(0,s.jsxs)("div",{className:"flex items-center gap-1.5 text-xs text-destructive",children:[(0,s.jsx)(m.AlertCircle,{className:"h-3.5 w-3.5 shrink-0"}),a]})]}),j&&(0,s.jsxs)("section",{className:"space-y-2",children:[(0,s.jsx)("h3",{className:"text-xs font-semibold uppercase tracking-widest text-muted-foreground",children:"Admins"}),(0,s.jsx)("p",{className:"text-xs leading-relaxed text-muted-foreground",children:"Admins can create workspaces, add users, and manage access."}),_&&(0,s.jsxs)("div",{className:"flex items-center gap-1.5 text-xs text-destructive",children:[(0,s.jsx)(m.AlertCircle,{className:"h-3.5 w-3.5 shrink-0"}),_]}),(0,s.jsxs)("div",{className:"space-y-2 rounded-md border border-border p-3",children:[(0,s.jsx)("div",{className:"text-xs font-medium",children:"Add user"}),U?(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Created ",(0,s.jsx)("span",{className:"font-medium text-foreground",children:U.email}),". Share this temporary password now, it will not be shown again."]}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("code",{className:"flex-1 rounded bg-muted px-2 py-1.5 font-mono text-sm select-all",children:U.tempPassword}),(0,s.jsx)("button",{type:"button",className:"shrink-0 text-xs px-2 py-1 rounded border border-border hover:bg-accent",onClick:()=>void navigator.clipboard?.writeText(U.tempPassword),children:"Copy"})]}),(0,s.jsx)("button",{type:"button",className:"text-xs text-muted-foreground hover:text-foreground",onClick:()=>{V(null),P(""),$(""),X()},children:"Done"})]}):(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)("input",{type:"email",value:L,onChange:e=>P(e.target.value),placeholder:"email@team.com",className:"w-full rounded-md border border-border bg-background px-2 py-1.5 text-sm outline-none focus:ring-2 focus:ring-primary"}),(0,s.jsx)("input",{type:"text",value:z,onChange:e=>$(e.target.value),placeholder:"Name (optional)",className:"w-full rounded-md border border-border bg-background px-2 py-1.5 text-sm outline-none focus:ring-2 focus:ring-primary"}),(0,s.jsxs)(v.Button,{size:"sm",className:"w-full gap-1.5",disabled:F||!L.trim(),onClick:async()=>{H(!0),D(null);try{let e=await fetch((0,ev.apiUrl)("/api/system/users"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:L.trim(),name:z.trim()})}),t=await e.json();e.ok&&t.tempPassword?V({email:t.email??L.trim(),tempPassword:t.tempPassword}):D(t.message??t.error??"Failed to create user")}catch{D("Network error")}finally{H(!1)}},children:[F&&(0,s.jsx)(u.Loader2,{className:"h-3.5 w-3.5 animate-spin"}),"Create user"]})]})]}),(0,s.jsxs)("div",{className:"space-y-1 rounded-md border border-border overflow-hidden",children:[T.map(e=>{let t=M.includes(e.id);return(0,s.jsxs)("div",{className:"flex items-center justify-between px-3 py-2 bg-muted/40 hover:bg-muted/60 transition-colors",children:[(0,s.jsxs)("div",{className:"text-sm min-w-0",children:[(0,s.jsx)("div",{className:"font-medium truncate",children:e.name}),(0,s.jsx)("div",{className:"text-xs text-muted-foreground truncate",children:e.email})]}),(0,s.jsx)("button",{type:"button",disabled:R===e.id,className:"ml-2 shrink-0 text-xs px-2 py-1 rounded border border-border hover:bg-accent disabled:opacity-50",onClick:async()=>{I(e.id),D(null);try{let n=await fetch((0,ev.apiUrl)("/api/system/admins"),{method:t?"DELETE":"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({userId:e.id})}),r=await n.json();n.ok?r.admins&&A(r.admins):D(r.message??r.error??"Failed")}catch{D("Network error")}finally{I(null)}},children:R===e.id?(0,s.jsx)(u.Loader2,{className:"h-3 w-3 animate-spin"}):t?"Demote":"Promote"})]},e.id)}),0===T.length&&(0,s.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:"No users yet."})]})]}),(0,s.jsxs)("section",{className:"space-y-2",children:[(0,s.jsx)("h3",{className:"text-xs font-semibold uppercase tracking-widest text-muted-foreground",children:"API Access"}),(0,s.jsx)("p",{className:"text-xs leading-relaxed text-muted-foreground",children:"Copy this key into external tools (e.g. termyard Settings → Integrations → Wiki-viewer API Key). The key never leaves this machine automatically."}),(0,s.jsxs)("div",{className:"rounded-md border border-border bg-muted/40 p-3 space-y-2",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(x,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),(0,s.jsx)("code",{className:"flex-1 truncate rounded bg-muted px-2 py-1 font-mono text-xs select-all",children:W??"—"}),(0,s.jsx)("button",{type:"button",title:"Copy API key",className:"shrink-0 rounded border border-border px-2 py-1 text-xs hover:bg-accent disabled:opacity-50 flex items-center gap-1",disabled:!W,onClick:()=>{W&&navigator.clipboard?.writeText(W).then(()=>{G(!0),setTimeout(()=>G(!1),2e3)})},children:K?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(g.Check,{className:"h-3 w-3"})," Copied"]}):"Copy"}),(0,s.jsx)("button",{type:"button",title:"Rotate API key — external tools will need the new key",className:"shrink-0 rounded border border-border px-2 py-1 text-xs hover:bg-accent disabled:opacity-50 flex items-center gap-1",disabled:J,onClick:async()=>{if(confirm("Rotate the API key? Any tool using the current key will need to be updated.")){Z(!0);try{let e=await fetch((0,ev.apiUrl)("/api/system/api-key"),{method:"POST"}),t=await e.json();t.key&&q(t.key)}catch{}finally{Z(!1)}}},children:J?(0,s.jsx)(u.Loader2,{className:"h-3 w-3 animate-spin"}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(y,{className:"h-3 w-3"})," Rotate"]})})]}),(0,s.jsxs)("p",{className:"text-[10px] text-muted-foreground/60",children:["Stored at ",(0,s.jsx)("code",{className:"bg-muted px-0.5 rounded",children:"~/.wiki-viewer/api-key"}),". Rotating immediately invalidates the old key."]})]})]}),(0,s.jsxs)("section",{className:"space-y-2",children:[(0,s.jsx)("h3",{className:"text-xs font-semibold uppercase tracking-widest text-muted-foreground",children:"Agent rate limit"}),(0,s.jsxs)("div",{className:"rounded-md border border-border bg-muted/40 p-3 space-y-1.5",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between text-xs",children:[(0,s.jsx)("span",{className:"text-muted-foreground",children:"Per agent"}),(0,s.jsx)("span",{className:"font-mono",children:null!==N?`${N} ops/min`:"--"})]}),(0,s.jsxs)("p",{className:"text-[10px] text-muted-foreground/60",children:["Override with ",(0,s.jsx)("code",{className:"bg-muted px-0.5 rounded",children:"AGENT_RATE_LIMIT"})," env var."]})]})]})]}),(0,s.jsxs)("div",{className:"flex items-center justify-end gap-2 border-t border-border px-4 py-3 shrink-0",children:[(0,s.jsx)(v.Button,{size:"sm",variant:"ghost",onClick:()=>t(!1),disabled:i,children:"Cancel"}),(0,s.jsxs)(v.Button,{size:"sm",onClick:ee,disabled:i||n,className:"gap-1.5",children:[i&&(0,s.jsx)(u.Loader2,{className:"h-3.5 w-3.5 animate-spin"}),"Save"]})]})]})})}let eG=f.forwardRef(({className:e,...t},n)=>(0,s.jsx)(K,{ref:n,className:(0,eh.cn)("fixed inset-0 z-40 bg-overlay backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t}));eG.displayName=K.displayName;let eJ=f.forwardRef(({className:e,children:t,...n},r)=>(0,s.jsxs)(W,{children:[(0,s.jsx)(eG,{}),(0,s.jsxs)(X,{ref:r,className:(0,eh.cn)("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-card p-6 shadow-golden rounded-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%]",e),...n,children:[t,(0,s.jsxs)(eo,{className:"absolute right-4 top-4 rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[(0,s.jsx)(h,{className:"h-4 w-4"}),(0,s.jsx)("span",{className:"sr-only",children:"Close"})]})]})]}));function eZ({className:e,...t}){return(0,s.jsx)("div",{className:(0,eh.cn)("flex flex-col space-y-1.5 text-center sm:text-left min-w-0",e),...t})}function eX({className:e,...t}){return(0,s.jsx)("div",{className:(0,eh.cn)("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t})}eJ.displayName=X.displayName,eZ.displayName="DialogHeader",eX.displayName="DialogFooter";let eY=f.forwardRef(({className:e,...t},n)=>(0,s.jsx)(en,{ref:n,className:(0,eh.cn)("text-lg font-normal leading-none tracking-tight",e),...t}));eY.displayName=en.displayName;let eQ=f.forwardRef(({className:e,...t},n)=>(0,s.jsx)(ei,{ref:n,className:(0,eh.cn)("text-sm text-muted-foreground break-words",e),...t}));function e0({open:e,onOpenChange:t,title:n,description:r,confirmLabel:i="Delete",onConfirm:o,variant:a="destructive"}){return(0,s.jsx)(B,{open:e,onOpenChange:t,children:(0,s.jsxs)(eJ,{className:"sm:max-w-sm",children:[(0,s.jsxs)(eZ,{children:[(0,s.jsx)(eY,{children:n}),(0,s.jsx)(eQ,{children:r})]}),(0,s.jsxs)(eX,{className:"gap-2 sm:gap-0",children:[(0,s.jsx)(v.Button,{variant:"outline",onClick:()=>t(!1),children:"Cancel"}),(0,s.jsx)(v.Button,{variant:a,onClick:()=>{o(),t(!1)},children:i})]})]})})}eQ.displayName=ei.displayName;var e1=e.i(10137);let e2=(0,o.default)("folder",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]),e3=(0,o.default)("folder-open",[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]]),e5=(0,o.default)("git-branch",[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]]),e4=(0,o.default)("hard-drive",[["line",{x1:"22",x2:"2",y1:"12",y2:"12",key:"1y58io"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}],["line",{x1:"6",x2:"6.01",y1:"16",y2:"16",key:"sgf278"}],["line",{x1:"10",x2:"10.01",y1:"16",y2:"16",key:"1l4acy"}]]),e6=(0,o.default)("server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]),e9=(0,o.default)("house",[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"1d0kgt"}]]),e7=(0,o.default)("star",[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]]),e8=(0,o.default)("star-off",[["path",{d:"M8.34 8.34 2 9.27l5 4.87L5.82 21 12 17.77 18.18 21l-.59-3.43",key:"16m0ql"}],["path",{d:"M18.42 12.76 22 9.27l-6.91-1L12 2l-1.44 2.91",key:"1vt8nq"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);function te({onSelect:e}){let[t,n]=(0,f.useState)("local"),[r,i]=(0,f.useState)(null),[o,a]=(0,f.useState)(!0),[l,c]=(0,f.useState)(null),[d,p]=(0,f.useState)(""),[m,g]=(0,f.useState)(!1),[b,y]=(0,f.useState)([]),[w,k]=(0,f.useState)(!1),N=(0,f.useRef)(null),S=(0,f.useRef)(null),[C,j]=(0,f.useState)(""),[E,M]=(0,f.useState)(""),[A,T]=(0,f.useState)(""),[O,_]=(0,f.useState)(""),[D,R]=(0,f.useState)(""),[I,L]=(0,f.useState)(""),[P,z]=(0,f.useState)(!1),[$,B]=(0,f.useState)(null),[F,H]=(0,f.useState)(""),[U,V]=(0,f.useState)(""),[W,q]=(0,f.useState)("agent"),[K,G]=(0,f.useState)(""),[J,Z]=(0,f.useState)(""),[X,Y]=(0,f.useState)(!1),[Q,ee]=(0,f.useState)(""),[et,en]=(0,f.useState)(!1),[er,ei]=(0,f.useState)(null),es=async()=>{let t=F.trim();if(!t)return void ei("SSH target is required (user@host:/path).");if("keyfile"===W&&!K.trim())return void ei("Private key path is required for key-file auth.");if("password"===W&&!J)return void ei("Password is required for password auth.");en(!0),ei(null);try{let n={sshTarget:t,sshAuthMethod:W};U.trim()&&(n.sshPort=Number(U.trim())),"keyfile"===W&&K.trim()&&(n.sshKeyPath=K.trim()),"password"===W&&J&&(n.sshPassword=J),X&&(n.sshReadOnly=!0),Q.trim()&&(n.name=Q.trim());let r=await fetch((0,ev.apiUrl)("/api/system/workspaces"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!r.ok){let e=await r.json();ei(e.error??e.message??"Mount failed.");return}let{workspace:i}=await r.json();Z(""),e(i.id)}catch{ei("Network error.")}finally{en(!1)}},eo=async()=>{let t=C.trim();if(!t)return void B("Repository URL is required.");z(!0),B(null);try{let n={remoteUrl:t};E.trim()&&(n.branch=E.trim()),A.trim()&&(n.subpath=A.trim()),O.trim()&&(n.username=O.trim()),D.trim()&&(n.token=D.trim()),I.trim()&&(n.name=I.trim());let r=await fetch((0,ev.apiUrl)("/api/system/workspaces"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!r.ok){let e=await r.json();B(e.error??e.message??"Clone failed.");return}let{workspace:i}=await r.json();R(""),e(i.id)}catch{B("Network error.")}finally{z(!1)}},ea=(0,f.useCallback)(async(e,t=!0)=>{S.current&&(clearTimeout(S.current),S.current=null),a(!0),c(null);try{let n=await fetch((0,ev.apiUrl)(`/api/system/browse?path=${encodeURIComponent(e)}`));if(!n.ok){let e=await n.json();c(e.error??"Cannot open directory");return}let r=await n.json();i(r),t&&p(r.path)}catch{c("Network error")}finally{a(!1)}},[]);(0,f.useEffect)(()=>{let e=!1;return(async()=>{try{let t=await fetch((0,ev.apiUrl)("/api/system/config"));if(t.ok&&!e){let e=await t.json();y(e.pinnedPaths??[]),await ea(e.lastOpenedPath??"");return}}catch{}e||await ea("")})(),()=>{e=!0}},[]);let el=async t=>{let n=t??r?.path;if(n){g(!0);try{let t=await fetch((0,ev.apiUrl)("/api/system/workspaces"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({rootDir:n})});if(!t.ok){let e=await t.json();c(e.message??e.error??"Cannot use that directory");return}let{workspace:r}=await t.json();e(r.id)}catch{c("Network error")}finally{g(!1)}}},ec=!!r&&b.includes(r.path),ed=async()=>{if(r){k(!0);try{let e=ec?"unpin":"pin";(await fetch((0,ev.apiUrl)("/api/system/pins"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:r.path,action:e})})).ok&&y(t=>"pin"===e?[...t,r.path]:t.filter(e=>e!==r.path))}catch{}finally{k(!1)}}},eu=async e=>{try{(await fetch((0,ev.apiUrl)("/api/system/pins"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e,action:"unpin"})})).ok&&y(t=>t.filter(t=>t!==e))}catch{}},ep=(r?.path??"").split(/[/\\]/).filter(Boolean).reduce((e,t)=>{let n=e[e.length-1]?.path??"/";return e.push({label:t,path:`${"/"===n?"":n}/${t}`}),e},[{label:"/",path:"/"}]);return(0,s.jsx)("div",{className:"flex flex-1 items-center justify-center bg-background p-4",children:(0,s.jsxs)("div",{className:"flex w-full max-w-xl flex-col gap-4",children:[(0,s.jsxs)("div",{className:"text-center space-y-1",children:[(0,s.jsxs)("div",{className:"flex items-center justify-center gap-2 mb-1",children:[(0,s.jsx)("img",{src:(0,ev.apiUrl)("/logo.svg"),alt:"Wiki Viewer",className:"h-8 w-8"}),(0,s.jsx)("span",{className:"text-xl font-semibold tracking-tight",children:"Wiki Viewer"})]}),(0,s.jsx)("h1",{className:"text-xl font-medium",children:"git"===t?"Add a Git repository":"ssh"===t?"Add a remote directory over SSH":"Choose a directory"}),(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:"git"===t?(0,s.jsxs)(s.Fragment,{children:["Clone a remote repo and serve it as a read-only workspace.",(0,s.jsx)("br",{}),"The server clones it, so the URL must be reachable from the server."]}):"ssh"===t?(0,s.jsxs)(s.Fragment,{children:["Mount a remote directory over SSH (sshfs) — no local clone.",(0,s.jsx)("br",{}),"Requires sshfs + FUSE installed on the server."]}):(0,s.jsxs)(s.Fragment,{children:["Select the folder wiki-viewer should serve.",(0,s.jsx)("br",{}),"This directory lives on the server, so use the browser below."]})})]}),(0,s.jsxs)("div",{className:"flex items-center self-center rounded-lg border bg-muted p-0.5 gap-0.5",children:[(0,s.jsxs)(v.Button,{variant:"local"===t?"default":"ghost",size:"sm",className:"h-7 px-3 text-xs gap-1.5",onClick:()=>{n("local"),R(""),B(null)},children:[(0,s.jsx)(e2,{className:"h-3.5 w-3.5"}),"Local folder"]}),(0,s.jsxs)(v.Button,{variant:"git"===t?"default":"ghost",size:"sm",className:"h-7 px-3 text-xs gap-1.5",onClick:()=>n("git"),children:[(0,s.jsx)(e5,{className:"h-3.5 w-3.5"}),"From Git"]}),(0,s.jsxs)(v.Button,{variant:"ssh"===t?"default":"ghost",size:"sm",className:"h-7 px-3 text-xs gap-1.5",onClick:()=>{n("ssh"),ei(null)},children:[(0,s.jsx)(e6,{className:"h-3.5 w-3.5"}),"Over SSH"]})]}),"git"===t&&(0,s.jsxs)("div",{className:"rounded-lg border bg-card shadow-sm overflow-hidden",children:[(0,s.jsxs)("div",{className:"px-4 pt-4 pb-3 flex flex-col gap-3",children:[(0,s.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,s.jsx)("label",{className:"text-xs font-medium",children:"Repository URL"}),(0,s.jsx)("div",{className:"flex items-center gap-2 rounded-md border bg-muted px-3 py-2",children:(0,s.jsx)("input",{className:"flex-1 bg-transparent text-sm outline-none font-mono min-w-0",placeholder:"https://github.com/org/repo.git",value:C,onChange:e=>{j(e.target.value),B(null)},disabled:P,autoComplete:"off",spellCheck:!1})}),(0,s.jsx)("p",{className:"text-[11px] text-muted-foreground",children:"Only https:// URLs are supported."})]}),(0,s.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,s.jsxs)("label",{className:"text-xs font-medium",children:["Branch ",(0,s.jsx)("span",{className:"font-normal text-muted-foreground",children:"(optional)"})]}),(0,s.jsx)("div",{className:"flex items-center gap-2 rounded-md border bg-muted px-3 py-2",children:(0,s.jsx)("input",{className:"flex-1 bg-transparent text-sm outline-none min-w-0",placeholder:"main (default branch if empty)",value:E,onChange:e=>{M(e.target.value),B(null)},disabled:P})})]}),(0,s.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,s.jsxs)("label",{className:"text-xs font-medium",children:["Subdirectory ",(0,s.jsx)("span",{className:"font-normal text-muted-foreground",children:"(optional)"})]}),(0,s.jsx)("div",{className:"flex items-center gap-2 rounded-md border bg-muted px-3 py-2",children:(0,s.jsx)("input",{className:"flex-1 bg-transparent text-sm outline-none font-mono min-w-0",placeholder:"docs (whole repo if empty)",value:A,onChange:e=>{T(e.target.value),B(null)},disabled:P,spellCheck:!1})}),(0,s.jsx)("p",{className:"text-[11px] text-muted-foreground",children:"Serve only this folder from the repo. Faster to clone for large repos with docs in a subfolder."})]}),(0,s.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,s.jsxs)("label",{className:"text-xs font-medium",children:["Username ",(0,s.jsx)("span",{className:"font-normal text-muted-foreground",children:"(optional)"})]}),(0,s.jsx)("div",{className:"flex items-center gap-2 rounded-md border bg-muted px-3 py-2",children:(0,s.jsx)("input",{className:"flex-1 bg-transparent text-sm outline-none min-w-0",placeholder:"x-access-token (default)",value:O,onChange:e=>{_(e.target.value),B(null)},disabled:P,autoComplete:"off"})}),(0,s.jsxs)("p",{className:"text-[11px] text-muted-foreground",children:["GitLab uses ",(0,s.jsx)("code",{className:"font-mono",children:"oauth2"}),"; Bitbucket uses your account username."]})]}),(0,s.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,s.jsxs)("label",{className:"text-xs font-medium",children:["Access token ",(0,s.jsx)("span",{className:"font-normal text-muted-foreground",children:"(optional)"})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2 rounded-md border bg-muted px-3 py-2",children:[(0,s.jsx)(x,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),(0,s.jsx)("input",{type:"password",className:"flex-1 bg-transparent text-sm outline-none min-w-0",placeholder:"Personal access token",value:D,onChange:e=>{R(e.target.value),B(null)},disabled:P,autoComplete:"off"})]}),(0,s.jsx)("p",{className:"text-[11px] text-muted-foreground",children:"Required only for private repos. Stored securely on the server and never shown again."})]}),(0,s.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,s.jsxs)("label",{className:"text-xs font-medium",children:["Display name ",(0,s.jsx)("span",{className:"font-normal text-muted-foreground",children:"(optional)"})]}),(0,s.jsx)("div",{className:"flex items-center gap-2 rounded-md border bg-muted px-3 py-2",children:(0,s.jsx)("input",{className:"flex-1 bg-transparent text-sm outline-none min-w-0",placeholder:"Defaults to the repository name",value:I,onChange:e=>{L(e.target.value),B(null)},disabled:P})})]}),$&&(0,s.jsx)("p",{className:"text-sm text-destructive",children:$})]}),(0,s.jsxs)("div",{className:"border-t px-4 py-3 flex items-center justify-between gap-3 bg-muted",children:[(0,s.jsx)("p",{className:"text-[11px] text-muted-foreground",children:"Git workspaces are read-only, so editing is disabled."}),(0,s.jsx)(v.Button,{size:"sm",className:"shrink-0 gap-1.5",disabled:P,onClick:eo,children:P?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(u.Loader2,{className:"h-3.5 w-3.5 animate-spin"})," Cloning..."]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(e5,{className:"h-3.5 w-3.5"})," Clone and add"]})})]})]}),"ssh"===t&&(0,s.jsxs)("div",{className:"rounded-lg border bg-card shadow-sm overflow-hidden",children:[(0,s.jsxs)("div",{className:"px-4 pt-4 pb-3 flex flex-col gap-3",children:[(0,s.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,s.jsx)("label",{className:"text-xs font-medium",children:"SSH target"}),(0,s.jsx)("div",{className:"flex items-center gap-2 rounded-md border bg-muted px-3 py-2",children:(0,s.jsx)("input",{className:"flex-1 bg-transparent text-sm outline-none font-mono min-w-0",placeholder:"user@host:/abs/path",value:F,onChange:e=>{H(e.target.value),ei(null)},disabled:et,autoComplete:"off",spellCheck:!1})}),(0,s.jsx)("p",{className:"text-[11px] text-muted-foreground",children:"The remote path must be absolute."})]}),(0,s.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,s.jsxs)("label",{className:"text-xs font-medium",children:["Port ",(0,s.jsx)("span",{className:"font-normal text-muted-foreground",children:"(optional)"})]}),(0,s.jsx)("div",{className:"flex items-center gap-2 rounded-md border bg-muted px-3 py-2",children:(0,s.jsx)("input",{className:"flex-1 bg-transparent text-sm outline-none min-w-0",placeholder:"22",inputMode:"numeric",value:U,onChange:e=>{V(e.target.value.replace(/[^0-9]/g,"")),ei(null)},disabled:et})})]}),(0,s.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,s.jsx)("label",{className:"text-xs font-medium",children:"Authentication"}),(0,s.jsx)("div",{className:"flex items-center self-start rounded-lg border bg-muted p-0.5 gap-0.5",children:["agent","keyfile","password"].map(e=>(0,s.jsx)(v.Button,{variant:W===e?"default":"ghost",size:"sm",className:"h-7 px-3 text-xs",onClick:()=>{q(e),ei(null)},disabled:et,children:"agent"===e?"SSH agent":"keyfile"===e?"Key file":"Password"},e))}),(0,s.jsx)("p",{className:"text-[11px] text-muted-foreground",children:"agent"===W?"Uses the server's ssh-agent and default keys (~/.ssh/id_*).":"keyfile"===W?"Uses a specific private key on the server.":"Stored securely on the server and never shown again."})]}),"keyfile"===W&&(0,s.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,s.jsx)("label",{className:"text-xs font-medium",children:"Private key path"}),(0,s.jsxs)("div",{className:"flex items-center gap-2 rounded-md border bg-muted px-3 py-2",children:[(0,s.jsx)(x,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),(0,s.jsx)("input",{className:"flex-1 bg-transparent text-sm outline-none font-mono min-w-0",placeholder:"~/.ssh/id_ed25519",value:K,onChange:e=>{G(e.target.value),ei(null)},disabled:et,autoComplete:"off",spellCheck:!1})]})]}),"password"===W&&(0,s.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,s.jsx)("label",{className:"text-xs font-medium",children:"Password"}),(0,s.jsxs)("div",{className:"flex items-center gap-2 rounded-md border bg-muted px-3 py-2",children:[(0,s.jsx)(x,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),(0,s.jsx)("input",{type:"password",className:"flex-1 bg-transparent text-sm outline-none min-w-0",placeholder:"SSH password",value:J,onChange:e=>{Z(e.target.value),ei(null)},disabled:et,autoComplete:"off"})]})]}),(0,s.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,s.jsxs)("label",{className:"text-xs font-medium",children:["Display name ",(0,s.jsx)("span",{className:"font-normal text-muted-foreground",children:"(optional)"})]}),(0,s.jsx)("div",{className:"flex items-center gap-2 rounded-md border bg-muted px-3 py-2",children:(0,s.jsx)("input",{className:"flex-1 bg-transparent text-sm outline-none min-w-0",placeholder:"Defaults to host:path",value:Q,onChange:e=>{ee(e.target.value),ei(null)},disabled:et})})]}),(0,s.jsxs)("label",{className:"flex items-center gap-2 text-xs font-medium cursor-pointer select-none",children:[(0,s.jsx)("input",{type:"checkbox",checked:X,onChange:e=>Y(e.target.checked),disabled:et}),"Mount read-only"]}),er&&(0,s.jsx)("p",{className:"text-sm text-destructive",children:er})]}),(0,s.jsxs)("div",{className:"border-t px-4 py-3 flex items-center justify-between gap-3 bg-muted",children:[(0,s.jsx)("p",{className:"text-[11px] text-muted-foreground",children:"Served live over SSH — nothing is copied to disk."}),(0,s.jsx)(v.Button,{size:"sm",className:"shrink-0 gap-1.5",disabled:et,onClick:es,children:et?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(u.Loader2,{className:"h-3.5 w-3.5 animate-spin"})," Mounting..."]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(e6,{className:"h-3.5 w-3.5"})," Mount and add"]})})]})]}),"local"===t&&(0,s.jsxs)("div",{className:"rounded-lg border bg-card shadow-sm overflow-hidden",children:[(0,s.jsx)("div",{className:"flex items-center gap-2 border-b px-3 py-2 bg-muted",children:(0,s.jsx)("input",{ref:N,className:"flex-1 bg-transparent text-sm outline-none font-mono min-w-0",value:d,onChange:e=>{let t=e.target.value;p(t),S.current&&clearTimeout(S.current),S.current=setTimeout(()=>{S.current=null,ea(t.trim(),!1)},500)},onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),S.current&&(clearTimeout(S.current),S.current=null),ea(d.trim())),"Escape"===e.key&&(S.current&&(clearTimeout(S.current),S.current=null),p(r?.path??""),N.current?.blur())},spellCheck:!1,placeholder:"Enter a path…"})}),(0,s.jsx)("div",{className:"flex items-center gap-1 border-b px-3 py-1.5 bg-muted/50 overflow-x-auto shrink-0 min-h-[32px]",children:ep.map((e,t)=>(0,s.jsxs)("span",{className:"flex items-center gap-1 shrink-0",children:[t>0&&(0,s.jsx)(e1.ChevronRight,{className:"h-3 w-3 text-muted-foreground/50"}),(0,s.jsx)("button",{type:"button",className:"text-xs hover:text-foreground text-muted-foreground transition-colors rounded px-0.5",onClick:()=>ea(e.path),children:0===t?(0,s.jsx)(e4,{className:"h-3.5 w-3.5"}):e.label})]},e.path))}),(0,s.jsx)("div",{className:"max-h-60 overflow-y-auto",children:o?(0,s.jsx)("div",{className:"flex justify-center py-8",children:(0,s.jsx)(u.Loader2,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):l?(0,s.jsx)("div",{className:"px-4 py-3 text-sm text-destructive",children:l}):(0,s.jsxs)(s.Fragment,{children:[r?.parent&&(0,s.jsxs)("button",{type:"button",className:"flex w-full items-center gap-2.5 px-3 py-2 text-sm text-muted-foreground hover:bg-accent hover:text-accent-foreground transition-colors",onClick:()=>ea(r.parent),children:[(0,s.jsx)(e2,{className:"h-4 w-4 shrink-0"}),(0,s.jsx)("span",{className:"text-xs",children:".."})]}),r?.entries.length===0&&(0,s.jsx)("p",{className:"px-4 py-3 text-sm text-muted-foreground/60",children:"No subdirectories"}),r?.entries.map(e=>(0,s.jsxs)("button",{type:"button",className:"flex w-full items-center gap-2.5 px-3 py-2 text-sm hover:bg-accent hover:text-accent-foreground transition-colors",onClick:()=>ea(e.path),children:[(0,s.jsx)(e2,{className:"h-4 w-4 shrink-0 text-warning"}),(0,s.jsx)("span",{className:"truncate",children:e.name})]},e.path))]})}),(0,s.jsxs)("div",{className:"border-t px-3 py-2 flex items-center justify-between gap-2 bg-muted",children:[(0,s.jsxs)("button",{type:"button",className:(0,eh.cn)("flex items-center gap-1.5 text-xs transition-colors rounded px-1.5 py-1",ec?"text-foreground hover:text-destructive":"text-muted-foreground hover:text-foreground"),title:ec?"Remove from favorites":"Add to favorites for quick access",onClick:ed,disabled:w||!r,children:[w?(0,s.jsx)(u.Loader2,{className:"h-3.5 w-3.5 animate-spin"}):ec?(0,s.jsx)(e8,{className:"h-3.5 w-3.5"}):(0,s.jsx)(e7,{className:"h-3.5 w-3.5"}),ec?"Unfavorite":"Favorite"]}),(0,s.jsxs)(v.Button,{size:"sm",className:"shrink-0 gap-1.5",disabled:!r||m,onClick:()=>el(),children:[m?(0,s.jsx)(u.Loader2,{className:"h-3.5 w-3.5 animate-spin"}):(0,s.jsx)(e3,{className:"h-3.5 w-3.5"}),"Select"]})]})]}),"local"===t&&b.length>0&&(0,s.jsxs)("div",{className:"rounded-lg border bg-card shadow-sm overflow-hidden",children:[(0,s.jsx)("div",{className:"px-3 py-2 border-b bg-muted",children:(0,s.jsxs)("span",{className:"text-xs font-medium text-muted-foreground flex items-center gap-1.5",children:[(0,s.jsx)(e7,{className:"h-3 w-3"})," Pinned"]})}),(0,s.jsx)("div",{className:"max-h-40 overflow-y-auto",children:b.map(e=>(0,s.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5 hover:bg-accent group",children:[(0,s.jsxs)("button",{type:"button",className:"flex-1 flex items-center gap-2 text-sm text-left min-w-0",onClick:()=>ea(e),children:[(0,s.jsx)(e2,{className:"h-4 w-4 shrink-0 text-warning"}),(0,s.jsx)("span",{className:"truncate text-xs",children:e})]}),(0,s.jsx)("button",{type:"button",className:"shrink-0 text-muted-foreground/50 hover:text-destructive opacity-0 group-hover:opacity-100 transition-all",onClick:()=>eu(e),title:"Remove from favorites",children:(0,s.jsx)(h,{className:"h-3.5 w-3.5"})})]},e))})]}),"local"===t&&r?.shortcuts&&r.shortcuts.length>0&&(0,s.jsx)("div",{className:"flex flex-wrap gap-1.5 justify-center",children:r.shortcuts.map(e=>(0,s.jsxs)(v.Button,{variant:"outline",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>ea(e.path),children:["Home"===e.label?(0,s.jsx)(e9,{className:"h-3 w-3"}):(0,s.jsx)(e4,{className:"h-3 w-3"}),e.label]},e.path))})]})})}var tt=e.i(391548),tn=e.i(567776);let tr=(0,o.default)("trash-2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]),ti=(0,o.default)("clock",[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);var ts=e.i(793479),to=e.i(461614),ta="Switch",[tl,tc]=(0,N.createContextScope)(ta),[td,tu]=tl(ta),tp=f.forwardRef((e,t)=>{let{__scopeSwitch:n,name:r,checked:i,defaultChecked:o,required:a,disabled:l,value:c="on",onCheckedChange:d,form:u,...p}=e,[h,m]=f.useState(null),g=(0,k.useComposedRefs)(t,e=>m(e)),b=f.useRef(!1),x=!h||u||!!h.closest("form"),[y,v]=(0,C.useControllableState)({prop:i,defaultProp:o??!1,onChange:d,caller:ta});return(0,s.jsxs)(td,{scope:n,checked:y,disabled:l,children:[(0,s.jsx)(T.Primitive.button,{type:"button",role:"switch","aria-checked":y,"aria-required":a,"data-state":tg(y),"data-disabled":l?"":void 0,disabled:l,value:c,...p,ref:g,onClick:(0,w.composeEventHandlers)(e.onClick,e=>{v(e=>!e),x&&(b.current=e.isPropagationStopped(),b.current||e.stopPropagation())})}),x&&(0,s.jsx)(tm,{control:h,bubbles:!b.current,name:r,value:c,checked:y,required:a,disabled:l,form:u,style:{transform:"translateX(-100%)"}})]})});tp.displayName=ta;var th="SwitchThumb",tf=f.forwardRef((e,t)=>{let{__scopeSwitch:n,...r}=e,i=tu(th,n);return(0,s.jsx)(T.Primitive.span,{"data-state":tg(i.checked),"data-disabled":i.disabled?"":void 0,...r,ref:t})});tf.displayName=th;var tm=f.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...i},o)=>{let a,l=f.useRef(null),c=(0,k.useComposedRefs)(l,o),d=(a=f.useRef({value:n,previous:n}),f.useMemo(()=>(a.current.value!==n&&(a.current.previous=a.current.value,a.current.value=n),a.current.previous),[n])),u=(0,to.useSize)(t);return f.useEffect(()=>{let e=l.current;if(!e)return;let t=Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype,"checked").set;if(d!==n&&t){let i=new Event("click",{bubbles:r});t.call(e,n),e.dispatchEvent(i)}},[d,n,r]),(0,s.jsx)("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...i,tabIndex:-1,ref:c,style:{...i.style,...u,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});function tg(e){return e?"checked":"unchecked"}function tb({className:e,...t}){return(0,s.jsx)(tp,{"data-slot":"switch",className:(0,eh.cn)("peer data-[state=checked]:bg-[var(--switch-checked)] data-[state=unchecked]:bg-input inline-flex h-5 w-9 shrink-0 items-center rounded-sm border-2 border-transparent shadow-e-1 transition-all outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 cursor-pointer",e),...t,children:(0,s.jsx)(tf,{"data-slot":"switch-thumb",className:"bg-background pointer-events-none block size-4 rounded-sm shadow-e-1 ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0"})})}tm.displayName="SwitchBubbleInput";var tx=e.i(380560),ty=e.i(206102),tv=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,t)=>{let n=(0,ty.createSlot)(`Primitive.${t}`),r=f.forwardRef((e,r)=>{let{asChild:i,...o}=e;return"u">typeof window&&(window[Symbol.for("radix-ui")]=!0),(0,s.jsx)(i?n:t,{...o,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{}),tw=f.forwardRef((e,t)=>(0,s.jsx)(tv.label,{...e,ref:t,onMouseDown:t=>{t.target.closest("button, input, select, textarea")||(e.onMouseDown?.(t),!t.defaultPrevented&&t.detail>1&&t.preventDefault())}}));tw.displayName="Label";var tk=e.i(294237);let tN=(0,tk.cva)("text-sm font-normal leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-50"),tS=f.forwardRef(({className:e,...t},n)=>(0,s.jsx)(tw,{ref:n,className:(0,eh.cn)(tN(),e),...t}));tS.displayName=tw.displayName;var tC=e.i(671485);function tj({open:e,onOpenChange:t,filePath:n}){let[r,i]=(0,f.useState)([]),[o,a]=(0,f.useState)(!0),[l,d]=(0,f.useState)(!1),[p,h]=(0,f.useState)(""),[m,b]=(0,f.useState)(!1),[x,y]=(0,f.useState)(!1),[w,k]=(0,f.useState)("7"),[N,S]=(0,f.useState)(null),C=(0,f.useCallback)(async()=>{a(!0);try{let e=await (0,tC.wsFetch)(`/api/share?path=${encodeURIComponent(n)}`);if(e.ok){let t=await e.json();i(t.shares??[])}}catch{}a(!1)},[n]);(0,f.useEffect)(()=>{e&&C()},[e,C]);let j=async()=>{d(!0);try{let e={path:n};if(m&&p.trim()&&(e.password=p.trim()),x&&w){let t=new Date;t.setDate(t.getDate()+Number(w)),e.expiresAt=t.toISOString()}let t=await (0,tC.wsFetch)("/api/share",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok){let e=await t.json();ey(e.error??"Failed to create share link");return}ex("Share link created"),h(""),b(!1),y(!1),k("7"),await C()}catch{ey("Failed to create share link")}finally{d(!1)}},E=async e=>{try{if(!(await fetch((0,ev.apiUrl)(`/api/share/${e}`),{method:"DELETE"})).ok)return void ey("Failed to revoke share link");ex("Share link revoked"),await C()}catch{ey("Failed to revoke share link")}};return(0,s.jsx)(B,{open:e,onOpenChange:t,children:(0,s.jsxs)(eJ,{className:"sm:max-w-md",children:[(0,s.jsxs)(eZ,{children:[(0,s.jsx)(eY,{children:"Share document"}),(0,s.jsx)(eQ,{children:"Create a public link to share this document as read-only."})]}),(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)("div",{className:"rounded-sm border border-border p-3 space-y-3",children:[(0,s.jsx)("h3",{className:"text-sm font-medium",children:"New share link"}),(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsxs)(tS,{htmlFor:"share-pwd",className:"text-xs gap-1.5 flex items-center",children:[(0,s.jsx)(tn.Lock,{className:"h-3 w-3 text-muted-foreground"}),"Password protect"]}),(0,s.jsx)(tb,{id:"share-pwd",checked:m,onCheckedChange:b})]}),m&&(0,s.jsx)(ts.Input,{type:"password",placeholder:"Set a password",value:p,onChange:e=>h(e.target.value)}),(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsxs)(tS,{htmlFor:"share-expiry",className:"text-xs gap-1.5 flex items-center",children:[(0,s.jsx)(ti,{className:"h-3 w-3 text-muted-foreground"}),"Set expiration"]}),(0,s.jsx)(tb,{id:"share-expiry",checked:x,onCheckedChange:y})]}),x&&(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(ts.Input,{type:"number",min:1,max:365,value:w,onChange:e=>k(e.target.value),className:"w-20"}),(0,s.jsx)("span",{className:"text-xs text-muted-foreground",children:"days"})]}),(0,s.jsxs)(v.Button,{size:"sm",className:"w-full gap-1.5",onClick:j,disabled:l,children:[l?(0,s.jsx)(u.Loader2,{className:"h-3.5 w-3.5 animate-spin"}):(0,s.jsx)(c,{className:"h-3.5 w-3.5"}),"Create link"]})]}),(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)("h3",{className:"text-xs font-medium text-muted-foreground",children:r.length>0?`Active links (${r.length})`:o?"Loading...":"No active links"}),o&&(0,s.jsx)("div",{className:"flex justify-center py-2",children:(0,s.jsx)(u.Loader2,{className:"h-4 w-4 animate-spin text-muted-foreground"})}),r.map(e=>(0,s.jsxs)("div",{className:"flex items-center gap-2 rounded-sm border border-border p-2",children:[(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsx)("div",{className:"flex items-center gap-1.5",children:(0,s.jsxs)("span",{className:"text-xs truncate",children:[window.location.origin,"/s/",e.token]})}),(0,s.jsxs)("div",{className:"flex items-center gap-2 mt-0.5",children:[e.hasPassword&&(0,s.jsxs)("span",{className:"flex items-center gap-0.5 text-[10px] text-muted-foreground",children:[(0,s.jsx)(tn.Lock,{className:"h-2.5 w-2.5"}),"pwd"]}),e.expiresAt&&(0,s.jsxs)("span",{className:"flex items-center gap-0.5 text-[10px] text-muted-foreground",children:[(0,s.jsx)(ti,{className:"h-2.5 w-2.5"}),function(e){let t=new Date(e),n=new Date,r=t.getTime()-n.getTime();if(r<=0)return"expired";let i=Math.floor(r/864e5),s=Math.floor(r%864e5/36e5);return i>0?`${i}d`:s>0?`${s}h`:"<1h"}(e.expiresAt)]}),(0,s.jsxs)("span",{className:"text-[10px] text-muted-foreground",children:[e.viewCount," view",1!==e.viewCount?"s":""]}),e.isExpired&&(0,s.jsx)("span",{className:"text-[10px] text-destructive",children:"expired"})]})]}),(0,s.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[(0,s.jsx)(v.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"Copy link",onClick:()=>{var t,n;let r;return t=e.url,n=e.token,r=`${window.location.origin}${t}`,void(navigator.clipboard.writeText(r),S(n),setTimeout(()=>S(null),2e3))},children:N===e.token?(0,s.jsx)(g.Check,{className:"h-3.5 w-3.5 text-success"}):(0,s.jsx)(tt.Copy,{className:"h-3.5 w-3.5"})}),(0,s.jsx)(v.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0 text-destructive hover:text-destructive",title:"Revoke link",onClick:()=>E(e.token),children:(0,s.jsx)(tr,{className:"h-3.5 w-3.5"})})]})]},e.id))]})]})]})})}let tE=(0,o.default)("wifi",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]]);var tM=e.i(412473);let tA=(0,eN.create)(e=>({isOpen:!1,open:()=>e({isOpen:!0}),close:()=>e({isOpen:!1}),toggle:()=>e(e=>({isOpen:!e.isOpen})),clearMessages:()=>{},activity:[],connections:[],hasToken:!1,pollIntervalMs:1e4,rateLimit:null,loadActivity:async()=>{if((0,ev.isLite)())return;let t=localStorage.getItem("wiki-agent-token")??null,n=!!(t&&t.trim());try{let t=await (0,tC.wsFetch)("/api/agent/activity?limit=50",{headers:{}});if(!t.ok)return void e({hasToken:n});let r=(await t.json()).events??[],i=function(e){let t=new Date(Date.now()-3e5).toISOString(),n=new Map;for(let r of e){if(r.at<t)continue;let e=n.get(r.by);e?n.set(r.by,{opCount:e.opCount+1,lastSeen:r.at>e.lastSeen?r.at:e.lastSeen}):n.set(r.by,{opCount:1,lastSeen:r.at})}return Array.from(n.entries()).map(([e,t])=>({by:e,...t})).sort((e,t)=>e.lastSeen<t.lastSeen?1:-1)}(r),s=null;try{let e=await (0,tC.wsFetch)("/api/agent/settings",{headers:{}});e.ok&&(s=(await e.json()).rateLimit??null)}catch{}e({activity:r,connections:i,hasToken:n,rateLimit:s})}catch{e({hasToken:n})}}})),tT=(0,o.default)("circle-check-big",[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]),tO=(0,o.default)("circle-x",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]),t_=(0,o.default)("refresh-cw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);function tD(e){let t=Date.now()-new Date(e).getTime();return t<6e4?"just now":t<36e5?`${Math.floor(t/6e4)}m ago`:t<864e5?`${Math.floor(t/36e5)}h ago`:`${Math.floor(t/864e5)}d ago`}function tR({scope:e}){return(0,s.jsxs)("span",{className:"text-[10px] text-muted-foreground/70 font-mono",children:[e.paths.join(", ")," · ",e.ops.join(",")]})}function tI({reg:e,onApprove:t,onDeny:n}){let[r,i]=(0,f.useState)(!1);async function o(t){i(!0);try{await t(e.registrationId)}finally{i(!1)}}return(0,s.jsxs)("li",{className:"py-1.5 border-b border-border/40 last:border-0",children:[(0,s.jsxs)("div",{className:"flex items-start justify-between gap-1",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("p",{className:"text-xs font-mono truncate",children:e.displayName}),(0,s.jsx)("p",{className:"text-[10px] text-muted-foreground/60 truncate",children:e.agentId}),(0,s.jsx)(tR,{scope:e.requestedScope})]}),(0,s.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[(0,s.jsxs)(v.Button,{size:"sm",variant:"default",className:"h-6 px-2 text-[10px]",disabled:r,onClick:()=>void o(t),title:"Approve",children:[(0,s.jsx)(tT,{className:"h-3 w-3 mr-0.5"}),"Approve"]}),(0,s.jsxs)(v.Button,{size:"sm",variant:"ghost",className:"h-6 px-2 text-[10px] text-destructive hover:text-destructive",disabled:r,onClick:()=>void o(n),title:"Deny",children:[(0,s.jsx)(tO,{className:"h-3 w-3 mr-0.5"}),"Deny"]})]})]}),(0,s.jsxs)("p",{className:"text-[10px] text-muted-foreground/50 mt-0.5",children:["Requested ",tD(e.requestedAt)]})]})}function tL({agent:e,onRevoke:t}){let[n,r]=(0,f.useState)(!1);return(0,s.jsxs)("li",{className:"py-1.5 border-b border-border/40 last:border-0",children:[(0,s.jsxs)("div",{className:"flex items-start justify-between gap-1",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("p",{className:"text-xs font-mono truncate",children:e.displayName}),(0,s.jsx)("p",{className:"text-[10px] text-muted-foreground/60 truncate",children:e.id}),(0,s.jsx)(tR,{scope:e.scope})]}),(0,s.jsx)(v.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0 shrink-0 text-destructive hover:text-destructive",disabled:n,onClick:async()=>{r(!0);try{await t(e.id)}finally{r(!1)}},title:"Revoke agent",children:(0,s.jsx)(tr,{className:"h-3 w-3"})})]}),(0,s.jsxs)("p",{className:"text-[10px] text-muted-foreground/50 mt-0.5",children:["Last seen ",tD(e.lastSeen)]})]})}function tP(){let[e,t]=(0,f.useState)([]),[n,r]=(0,f.useState)([]),[i,o]=(0,f.useState)(!1);(0,f.useEffect)(()=>{fetch((0,ev.apiUrl)("/api/owner/init"),{credentials:"same-origin"}).then(e=>{(e.ok||204===e.status)&&o(!0)}).catch(()=>{o(!0)})},[]);let a=(0,f.useCallback)(async()=>{try{let e=await fetch((0,ev.apiUrl)("/api/agent/admin/registrations"),{credentials:"same-origin"});if(!e.ok)return;let n=await e.json();t(n.pending)}catch{}},[]),l=(0,f.useCallback)(async()=>{try{let e=await fetch((0,ev.apiUrl)("/api/agent/admin/agents"),{credentials:"same-origin"});if(!e.ok)return;let t=await e.json();r(t.agents)}catch{}},[]);(0,f.useEffect)(()=>{if(!i)return;a(),l();let e=setInterval(()=>void a(),5e3),t=setInterval(()=>void l(),3e4);return()=>{clearInterval(e),clearInterval(t)}},[i,a,l]);let c=(0,f.useCallback)(async e=>{(await fetch((0,ev.apiUrl)(`/api/agent/admin/registrations/${e}/approve`),{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/json"},body:"{}"})).ok?(eb.toast.success("Agent approved"),await Promise.all([a(),l()])):eb.toast.error("Failed to approve agent")},[a,l]),d=(0,f.useCallback)(async e=>{(await fetch((0,ev.apiUrl)(`/api/agent/admin/registrations/${e}/deny`),{method:"POST",credentials:"same-origin"})).ok?(eb.toast.success("Registration denied"),await a()):eb.toast.error("Failed to deny registration")},[a]),u=(0,f.useCallback)(async e=>{(await fetch((0,ev.apiUrl)(`/api/agent/admin/agents/${encodeURIComponent(e)}/revoke`),{method:"POST",credentials:"same-origin"})).ok?(eb.toast.success("Agent revoked"),await l()):eb.toast.error("Failed to revoke agent")},[l]);return(0,s.jsxs)("section",{className:"space-y-2",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsx)("h3",{className:"text-xs font-semibold uppercase tracking-widest text-muted-foreground",children:"Agents · approve & manage access"}),(0,s.jsx)(v.Button,{size:"sm",variant:"ghost",className:"h-5 w-5 p-0",title:"Refresh",onClick:()=>void Promise.all([a(),l()]),children:(0,s.jsx)(t_,{className:"h-3 w-3"})})]}),e.length>0&&(0,s.jsxs)("div",{className:"rounded-md border border-amber-500/40 bg-amber-50/10 p-2",children:[(0,s.jsxs)("p",{className:"text-[10px] font-semibold uppercase tracking-widest text-amber-600/80 mb-1 flex items-center gap-1",children:[(0,s.jsx)(ti,{className:"h-3 w-3"}),"Waiting for your approval (",e.length,")"]}),(0,s.jsx)("ul",{children:e.map(e=>(0,s.jsx)(tI,{reg:e,onApprove:c,onDeny:d},e.registrationId))})]}),(0,s.jsx)("div",{className:"rounded-md border border-border bg-muted/40 p-2",children:0===n.length?(0,s.jsxs)("p",{className:"text-xs text-muted-foreground/60 py-1",children:["No assistants connected yet."," ",(0,s.jsx)("span",{className:"text-muted-foreground/40",children:"Connect one above; once it requests access it’ll appear here for you to approve."})]}):(0,s.jsx)("ul",{children:n.map(e=>(0,s.jsx)(tL,{agent:e,onRevoke:u},e.id))})}),(0,s.jsx)("p",{className:"text-[10px] text-muted-foreground/60 leading-relaxed",children:"Each assistant gets its own access that you can revoke anytime. New requests appear above for your approval before they can read or edit anything."})]})}class tz extends Error{status;constructor(e,t){super(e),this.status=t,this.name="FetchPageError"}}async function t$(e,t){let n=await (0,tC.wsFetch)(`/api/wiki/content?path=${encodeURIComponent(e)}`,{signal:t});if(!n.ok)throw new tz(`Failed to fetch page: ${e}`,n.status);let r=await n.json(),i=n.headers.get("X-Wiki-Revision"),s=null!==i?Number(i):null;return{path:e,content:r.content,frontmatter:null,revision:s}}class tB extends Error{currentRevision;serverContent;constructor(e,t){super("File was modified externally. Reloaded with latest content."),this.currentRevision=e,this.serverContent=t,this.name="StaleRevisionError"}}async function tF(e,t,n){let r={path:e,content:t};null!==n&&(r.baseRevision=n);let i=await (0,tC.wsFetch)("/api/wiki/content",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(409===i.status){let n=await i.json(),r=await (0,tC.wsFetch)(`/api/wiki/content?path=${encodeURIComponent(e)}`),s=r.ok?(await r.json()).content:t;throw new tB(n.currentRevision??0,s)}if(!i.ok)throw Error("Failed to save page");return{revision:(await i.json()).revision??null}}async function tH(e,t=""){await tF(e,t,null)}let tU="kb-page-cache",tV=new Map,tW=new Map;function tq(e){if(tV.delete(e.path),tV.set(e.path,e),tV.size>30){let e=tV.keys().next().value;void 0!==e&&tV.delete(e)}}function tK(e){if(tV.has(e)||tW.has(e))return;let t=t$(e).then(e=>(tq(e),e)).finally(()=>{tW.delete(e)});tW.set(e,t),t.catch(()=>{})}function tG(e){try{localStorage.setItem(tU,JSON.stringify(e))}catch{}}let tJ="kb-edit-mode",tZ=null,tX=null,tY=null,tQ=(0,eN.create)((e,t)=>({currentPath:null,content:"",frontmatter:null,saveStatus:"idle",loadStatus:"idle",isDirty:!1,isLoading:!1,lastSavedAt:null,currentRevision:null,editMode:"suggesting"===localStorage.getItem(tJ)?"suggesting":"editing",setEditMode:t=>{localStorage.setItem(tJ,t),e({editMode:t})},loadPage:async n=>{let r,i=t();i.isDirty&&i.currentPath&&i.currentPath!==n&&await t().save(),e({currentPath:n,isLoading:!0,loadStatus:"loading",isDirty:!1,content:"",currentRevision:null});let s=(r=tV.get(n))?(tV.delete(n),tV.set(n,r),r):null,o=s??function(e){try{let t=localStorage.getItem(tU);if(!t)return null;let n=JSON.parse(t);if(n.path!==e)return null;return n}catch{return null}}(n);o&&e({content:o.content,frontmatter:o.frontmatter,isLoading:!1,loadStatus:"ok",...s?{currentRevision:s.revision}:{}});let a=tW.get(n);if(a)try{let r=await a;if(t().currentPath!==n)return;e({content:r.content,frontmatter:r.frontmatter,isLoading:!1,loadStatus:"ok",currentRevision:r.revision}),tG({path:n,content:r.content,frontmatter:r.frontmatter});return}catch{}tY?.abort();let l=new AbortController;tY=l;try{let r=await t$(n,l.signal);if(tq(r),t().currentPath!==n)return;e({content:r.content,frontmatter:r.frontmatter,isLoading:!1,loadStatus:"ok",currentRevision:r.revision}),tG({path:n,content:r.content,frontmatter:r.frontmatter})}catch(r){if(r instanceof DOMException&&"AbortError"===r.name||t().currentPath!==n)return;r instanceof tz&&404===r.status?e({isLoading:!1,loadStatus:"missing",content:""}):e({isLoading:!1,loadStatus:"error"})}},updateContent:n=>{"suggesting"===t().editMode?e({content:n}):(e({content:n,isDirty:!0}),tZ&&clearTimeout(tZ),tZ=setTimeout(()=>{t().save()},500))},updateFrontmatter:n=>{e({frontmatter:{...t().frontmatter,...n},isDirty:!0}),tZ&&clearTimeout(tZ),tZ=setTimeout(()=>{t().save()},500)},save:async()=>{let{currentPath:n,content:r,isDirty:i,currentRevision:s,editMode:o}=t();if(n&&i&&"suggesting"!==o){e({saveStatus:"saving"});try{let i=await tF(n,r,s);e({saveStatus:"saved",isDirty:!1,lastSavedAt:Date.now(),currentRevision:i.revision??s}),tG({path:n,content:r,frontmatter:t().frontmatter}),tq({path:n,content:r,frontmatter:t().frontmatter,revision:i.revision??s}),tX&&clearTimeout(tX),tX=setTimeout(()=>{"saved"===t().saveStatus&&e({saveStatus:"idle"})},2e3)}catch(r){r instanceof tB?(e({content:r.serverContent,isDirty:!1,saveStatus:"error",currentRevision:r.currentRevision}),tG({path:n,content:r.serverContent,frontmatter:t().frontmatter})):e({saveStatus:"error"})}}},createMissingPage:async n=>{let{currentPath:r}=t();if(!r)return;let i=`# ${n}
|
|
6
|
+
|
|
7
|
+
`;try{await tH(`${r}/index.md`,i),e({content:i,isDirty:!1,loadStatus:"ok"}),tG({path:r,content:i,frontmatter:null})}catch{}},clear:()=>{tZ&&clearTimeout(tZ),tX&&clearTimeout(tX),e({currentPath:null,content:"",frontmatter:null,saveStatus:"idle",loadStatus:"idle",isDirty:!1,isLoading:!1,lastSavedAt:null,currentRevision:null})},syncRevision:t=>{e({currentRevision:t})}}));function t0(e){let t=Math.max(0,Math.round((Date.now()-new Date(e).getTime())/1e3));if(t<45)return"just now";let n=t,r="second";for(let[e,t]of[[60,"second"],[60,"minute"],[24,"hour"],[7,"day"]]){if(n<e)break;n=Math.floor(n/e),r=t}return new Intl.RelativeTimeFormat("en",{numeric:"always",style:"short"}).format(-n,r).replace(/\s+/g," ").replace(/\./g,"")}async function t1(e){if(!/\.(md|markdown)$/i.test(e))return 0;for(let t of[`/api/agent/sidecar/${e}`,`/api/agent/files/${e}/pending`,`/api/agent/files/${e}`])try{let e=await (0,tC.wsFetch)(t);if(!e.ok)continue;let n=await e.json();if(Array.isArray(n.pending))return n.pending.length;if(Array.isArray(n.events)&&t.includes("/pending"))return n.events.length;if("number"==typeof n.pendingCount)return n.pendingCount;if("number"==typeof n.count)return n.count;if("number"==typeof n.total)return n.total;if(Array.isArray(n.suggestions)||Array.isArray(n.comments)||n.blockProvenance){let e=Array.isArray(n.suggestions)?n.suggestions.filter(e=>e&&"object"==typeof e&&"pending"===e.status).length:0,t=Array.isArray(n.comments)?n.comments.filter(e=>e&&"object"==typeof e&&!e.resolved).length:0,r=n.blockProvenance&&"object"==typeof n.blockProvenance?Object.keys(n.blockProvenance).length:0;return e+t+r}}catch{}return 0}let t2=(0,f.memo)(function({event:e}){var t,n;let r,i,o,a,l;return(0,s.jsxs)("div",{className:"flex items-start gap-2.5 rounded-md px-2 py-2 hover:bg-background/50",children:[(0,s.jsx)("div",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-full text-[10px] font-semibold shadow-sm ring-1 ring-black/5",style:(r=function(e){let t=0;for(let n=0;n<e.length;n+=1)t=31*t+e.charCodeAt(n)|0;return Math.abs(t)}(e.by)%360,{backgroundColor:`hsl(${r} 72% 42%)`,color:"white"}),title:e.by,"aria-hidden":!0,children:((i=(t=e.by).split(/[:/]/).pop()??t).replace(/[^a-z0-9]/gi,"").slice(0,2)||i.slice(0,2)||"??").toUpperCase()}),(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsx)("p",{className:"truncate text-xs text-foreground/85",children:(o=((n=e.by).split(/[:/]/).pop()??n).replace(/[-_]+/g," ").replace(/^./,e=>e.toUpperCase()),a=e.type,l=Array.isArray(e.refs)?(e.refs??[]).length:+("string"==typeof e.ref),"block.append"===a||"block.inserted"===a&&"end"===e.position?`${o} appended ${l||1} block${1===(l||1)?"":"s"}`:"block.prepend"===a||"block.inserted"===a&&"start"===e.position?`${o} prepended ${l||1} block${1===(l||1)?"":"s"}`:"block.inserted"===a?`${o} inserted ${l||1} block${1===(l||1)?"":"s"}`:"block.replaced"===a||"file.rawWritten"===a?`${o} edited`:"block.deleted"===a?`${o} deleted ${l||1} block${1===(l||1)?"":"s"}`:"suggestion.added"===a?`${o} suggested a change`:"suggestion.accepted"===a?`${o} accepted a suggestion`:"suggestion.rejected"===a?`${o} rejected a suggestion`:"comment.added"===a?`${o} commented`:"comment.replied"===a?`${o} replied`:"comment.resolved"===a?`${o} resolved a comment`:"comment.reopened"===a?`${o} reopened a comment`:"file.externallyEdited"===a?`${o} changed file externally`:`${o} ${a.replace(/^\w+\./,"").replace(/([a-z])([A-Z])/g,"$1 $2")}`)}),(0,s.jsx)("p",{className:"truncate text-[10px] text-muted-foreground",children:t0(e.at)})]})]})});function t3({group:e,reviewCount:t}){let n=tQ(e=>e.loadPage),r=e.events[0];return(0,s.jsxs)("section",{className:"space-y-1.5 rounded-md border border-border/70 bg-background/50 p-2",children:[(0,s.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,s.jsxs)("button",{type:"button",onClick:()=>void n(e.path),className:"min-w-0 text-left",title:e.path,children:[(0,s.jsx)("p",{className:"truncate text-xs font-medium text-foreground/90",children:e.filename}),(0,s.jsx)("p",{className:"truncate text-[10px] text-muted-foreground",children:e.path})]}),(0,s.jsxs)("div",{className:"flex shrink-0 items-center gap-1.5",children:[t>0&&(0,s.jsxs)("button",{type:"button",onClick:()=>void n(e.path),className:"inline-flex items-center rounded-full border border-amber-500/40 bg-amber-500/10 px-2 py-0.5 text-[10px] font-medium text-amber-700 hover:bg-amber-500/15",title:"Open file for review",children:["review ",t]}),(0,s.jsx)("span",{className:"text-[10px] text-muted-foreground",children:t0(r.at)})]})]}),(0,s.jsx)("div",{className:"space-y-0.5",children:e.events.map(e=>(0,s.jsx)(t2,{event:e},`${e.path}-${e.id}`))})]})}function t5({activity:e}){let t=(0,f.useMemo)(()=>(function(e){let t=new Map;for(let n of e){let e=t.get(n.path)??[];e.push(n),t.set(n.path,e)}return Array.from(t.entries()).map(([e,t])=>({path:e,filename:e.split("/").pop()??e,latestAt:t[0]?.at??"",events:t})).sort((e,t)=>e.latestAt<t.latestAt?1:-1)})(e),[e]),[n,r]=(0,f.useState)({});return((0,f.useEffect)(()=>{let e=!1,n=Array.from(new Set(t.map(e=>e.path)));return 0===n.length?(r({}),()=>{e=!0}):((async()=>{let t=await Promise.all(n.map(async e=>[e,await t1(e)]));e||r(Object.fromEntries(t.filter(([,e])=>e>0)))})(),()=>{e=!0})},[t]),0===t.length)?(0,s.jsx)("p",{className:"py-2 text-xs text-muted-foreground/60",children:"No events recorded"}):(0,s.jsx)("div",{className:"space-y-2",children:t.map(e=>(0,s.jsx)(t3,{group:e,reviewCount:n[e.path]??0},e.path))})}let t4="npx skills add anh-chu/wiki-viewer/agents/wiki-viewer-skill";function t6(e){let[t,n]=(0,f.useState)(!1);return{copied:t,copy:(0,f.useCallback)(async()=>{await navigator.clipboard.writeText(e()),n(!0),setTimeout(()=>n(!1),1500)},[e])}}function t9({currentPath:e}){let t=tA(e=>e.isOpen),n=tA(e=>e.close),r=tA(e=>e.activity),i=tA(e=>e.connections),o=tA(e=>e.loadActivity),{copied:l,copy:c}=function(e){let[t,n]=(0,f.useState)(!1);return{copied:t,copy:(0,f.useCallback)(async()=>{let t=window.location.origin,r=`# 1. Register
|
|
8
|
+
REG=$(curl -s -X POST -H 'Content-Type: application/json' \\
|
|
9
|
+
-d '{"id":"ai:claude","displayName":"Claude"}' \\
|
|
10
|
+
${t}/api/agent/register)
|
|
11
|
+
REG_ID=$(echo $REG | jq -r .registrationId)
|
|
12
|
+
|
|
13
|
+
# 2. Approve in AI Panel, then poll:
|
|
14
|
+
curl -s ${t}/api/agent/register/$REG_ID
|
|
15
|
+
# → {"status":"approved","token":"..."}
|
|
16
|
+
TOKEN=<paste token here>
|
|
17
|
+
|
|
18
|
+
# 3. Read snapshot
|
|
19
|
+
curl -s -H "Authorization: Bearer $TOKEN" \\
|
|
20
|
+
-H "X-Agent-Id: ai:claude" \\
|
|
21
|
+
${t}/api/agent/files/${e??"<path/to/file.md>"}`;await navigator.clipboard.writeText(r),n(!0),setTimeout(()=>n(!1),1500)},[e])}}(e??null),[d,u]=(0,f.useState)(""),p=(0,f.useRef)(null),m=window.location.origin,b=(0,f.useCallback)(()=>t4,[]),x=(0,f.useCallback)(()=>d.replace(/\$WIKI_URL/g,m),[d,m]),y=(0,f.useCallback)(()=>`npx wiki-viewer-mcp register --url ${m} --id ai:myagent --name "My Agent"`,[m]),w=(0,f.useCallback)(()=>JSON.stringify({servers:{"wiki-viewer":{command:"npx",args:["wiki-viewer-mcp"],env:{WIKI_VIEWER_URL:m,WIKI_VIEWER_TOKEN:"<token from register>",WIKI_VIEWER_AGENT_ID:"ai:myagent"}}}},null,2),[m]),k=t6(b),N=t6(x),S=t6(y),C=t6(w);return((0,f.useEffect)(()=>{if(t)return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e);function e(e){"Escape"===e.key&&n()}},[t,n]),(0,f.useEffect)(()=>{t&&p.current?.focus()},[t]),(0,f.useEffect)(()=>{if(!t)return;o();let e=setInterval(()=>void o(),1e4);return()=>clearInterval(e)},[t,o]),(0,f.useEffect)(()=>{t&&fetch((0,ev.apiUrl)("/api/agents/install")).then(e=>e.json()).then(e=>{e.bootstrapPrompt&&u(e.bootstrapPrompt)}).catch(()=>void 0)},[t]),t)?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"fixed inset-0 z-40 bg-overlay backdrop-blur-[1px]",onClick:n,"aria-hidden":!0}),(0,s.jsxs)("aside",{ref:p,tabIndex:-1,role:"dialog","aria-modal":"true","aria-label":"AI Agent Panel",className:"fixed right-0 top-0 bottom-0 z-50 flex w-[90vw] max-w-sm md:w-80 flex-col border-l border-border bg-background shadow-xl outline-none",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between border-b border-border px-4 py-3 shrink-0",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(a,{className:"h-4 w-4 text-muted-foreground"}),(0,s.jsx)("span",{className:"text-sm font-semibold",children:"AI Agent"})]}),(0,s.jsx)(v.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:n,title:"Close panel (Esc)",children:(0,s.jsx)(h,{className:"h-3.5 w-3.5"})})]}),(0,s.jsxs)("div",{className:"flex-1 overflow-y-auto space-y-5 px-4 py-4",children:[(0,s.jsxs)("section",{className:"rounded-md border border-border bg-muted/30 p-3",children:[(0,s.jsx)("p",{className:"text-sm font-medium text-foreground",children:"Work with this wiki using AI"}),(0,s.jsxs)("p",{className:"mt-1 text-xs leading-relaxed text-muted-foreground",children:["Connect Claude, Cursor, ChatGPT, and more. Pick by what you want — each option gives a copy-paste setup. You approve every assistant in ",(0,s.jsx)("span",{className:"font-medium text-foreground/80",children:"Agents"})," below before it gets access."]})]}),(0,s.jsxs)("section",{className:"space-y-3",children:[(0,s.jsxs)("div",{className:"rounded-md border border-border bg-muted/40 p-3 space-y-1.5",children:[(0,s.jsx)("p",{className:"text-xs font-semibold text-foreground",children:"Co-write docs with you"}),(0,s.jsx)("p",{className:"text-[10px] text-muted-foreground/70",children:"Edits arrive as suggestions with comments you accept or revert. No MCP needed."}),(0,s.jsx)(v.Button,{size:"sm",variant:"outline",className:"h-7 w-full text-xs gap-1.5",onClick:()=>void N.copy(),disabled:!d,children:N.copied?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(g.Check,{className:"h-3.5 w-3.5 text-green-500"})," Copied!"]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(tt.Copy,{className:"h-3.5 w-3.5"})," Paste into any chatbot"]})}),(0,s.jsxs)("p",{className:"text-[10px] text-muted-foreground/50 pt-1",children:["Or install once so it sticks"," ",(0,s.jsx)("span",{className:"text-muted-foreground/40",children:"· Claude, OpenCode"}),":"]}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("code",{className:"flex-1 text-[10px] font-mono text-foreground/80 truncate bg-muted rounded px-1 py-0.5",children:t4}),(0,s.jsx)(v.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0 shrink-0",title:"Copy this command",onClick:()=>void k.copy(),children:k.copied?(0,s.jsx)(g.Check,{className:"h-3.5 w-3.5 text-green-500"}):(0,s.jsx)(tt.Copy,{className:"h-3.5 w-3.5"})})]})]}),(0,s.jsxs)("div",{className:"rounded-md border border-border bg-muted/40 p-3 space-y-1.5",children:[(0,s.jsxs)("p",{className:"text-xs font-semibold text-foreground",children:["Edit files directly"," ",(0,s.jsx)("span",{className:"font-normal text-muted-foreground/60",children:"· Claude Code, Cursor, Codex"})]}),(0,s.jsx)("p",{className:"text-[10px] text-muted-foreground/70",children:"Native read / search / edit tools over MCP. Run to request access:"}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("code",{className:"flex-1 text-[10px] font-mono text-foreground/80 truncate bg-muted rounded px-1 py-0.5",children:y()}),(0,s.jsx)(v.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0 shrink-0",title:"Copy this command",onClick:()=>void S.copy(),children:S.copied?(0,s.jsx)(g.Check,{className:"h-3.5 w-3.5 text-green-500"}):(0,s.jsx)(tt.Copy,{className:"h-3.5 w-3.5"})})]}),(0,s.jsxs)("p",{className:"text-[10px] text-muted-foreground/50",children:["Approve in ",(0,s.jsx)("span",{className:"font-medium text-foreground/70",children:"Agents"}),", then add to your tool:"]}),(0,s.jsx)(v.Button,{size:"sm",variant:"outline",className:"h-7 w-full text-xs gap-1.5",onClick:()=>void C.copy(),children:C.copied?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(g.Check,{className:"h-3.5 w-3.5 text-green-500"})," Copied!"]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(tt.Copy,{className:"h-3.5 w-3.5"})," Copy config (mcp.json)"]})})]}),(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[(0,s.jsx)("span",{className:"text-[10px] text-muted-foreground/50",children:"For developers:"}),(0,s.jsxs)("button",{type:"button",onClick:()=>void c(),className:"inline-flex items-center gap-1 text-[10px] text-primary hover:underline",children:[l?(0,s.jsx)(g.Check,{className:"h-3 w-3 text-green-500"}):(0,s.jsx)(tt.Copy,{className:"h-3 w-3"})," curl example"]}),(0,s.jsxs)("a",{href:(0,ev.apiUrl)("/api/agents/skill"),target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 text-[10px] text-primary hover:underline",children:[(0,s.jsx)(tM.ExternalLink,{className:"h-3 w-3"})," skill"]}),(0,s.jsxs)("a",{href:(0,ev.apiUrl)("/api/agents/install"),target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 text-[10px] text-primary hover:underline",children:[(0,s.jsx)(tM.ExternalLink,{className:"h-3 w-3"})," install JSON"]})]})]}),(0,s.jsx)(tP,{}),(0,s.jsxs)("section",{className:"space-y-2",children:[(0,s.jsxs)("h3",{className:"text-xs font-semibold uppercase tracking-widest text-muted-foreground",children:["Active Connections"," ",(0,s.jsx)("span",{className:"normal-case font-normal text-muted-foreground/50",children:"(last 5 min)"})]}),(0,s.jsx)("div",{className:"rounded-md border border-border bg-muted/40 p-3",children:0===i.length?(0,s.jsxs)("p",{className:"text-xs text-muted-foreground/60 flex items-center gap-1.5",children:[(0,s.jsx)(tE,{className:"h-3.5 w-3.5"}),"No recent activity"]}):(0,s.jsx)("ul",{className:"space-y-1.5",children:i.map(e=>(0,s.jsxs)("li",{className:"flex items-center justify-between text-xs",children:[(0,s.jsx)("span",{className:"font-mono text-foreground/80 truncate",children:e.by}),(0,s.jsxs)("span",{className:"text-muted-foreground shrink-0",children:[e.opCount," op",1!==e.opCount?"s":""]})]},e.by))})})]}),(0,s.jsxs)("section",{className:"space-y-2",children:[(0,s.jsx)("h3",{className:"text-xs font-semibold uppercase tracking-widest text-muted-foreground",children:"Recent Activity"}),(0,s.jsx)("div",{className:"rounded-md border border-border bg-muted/40 px-3 py-2 max-h-72 overflow-y-auto",children:(0,s.jsx)(t5,{activity:r})})]}),(0,s.jsx)("section",{children:(0,s.jsx)("a",{href:(0,ev.apiUrl)("/docs/agent-collab-plan.md"),target:"_blank",rel:"noreferrer",className:"text-xs text-primary underline hover:no-underline",children:"Agent collaboration docs →"})})]})]})]}):null}var t7=e.i(406347);let t8=(0,o.default)("link",[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]]),ne=(0,o.default)("ellipsis",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]]),nt=(0,o.default)("file",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}]]),nn=(0,o.default)("file-plus",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M9 15h6",key:"cctwl0"}],["path",{d:"M12 18v-6",key:"17g6i2"}]]),nr=(0,o.default)("folder-plus",[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]),ni=(0,o.default)("terminal",[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]]),ns=(0,o.default)("upload",[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]]);function no({pos:e,branches:t,loading:n,busyName:r,disabled:i,onPick:o,onClose:a}){let[l,c]=(0,f.useState)(""),d=(0,f.useRef)(null);if((0,f.useEffect)(()=>{let e=e=>{let t=e.target;d.current?.contains(t)||t?.closest?.("[data-branch-trigger]")||a()},t=e=>{"Escape"===e.key&&a()};return document.addEventListener("mousedown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",t)}},[a]),"u"<typeof document)return null;let p=t.length>8,h=l.trim().toLowerCase(),m=h?t.filter(e=>e.name.toLowerCase().includes(h)):t;return(0,tx.createPortal)((0,s.jsx)("div",{ref:d,"data-branch-portal":!0,style:{position:"fixed",top:e.top,left:e.left},className:"pointer-events-auto z-[9999] flex max-h-72 w-52 flex-col overflow-hidden rounded-md border bg-popover p-1 shadow-md",children:n?(0,s.jsx)("div",{className:"flex justify-center py-2",children:(0,s.jsx)(u.Loader2,{className:"h-3.5 w-3.5 animate-spin text-muted-foreground"})}):0===t.length?(0,s.jsx)("p",{className:"px-2 py-1 text-[10px] text-muted-foreground",children:"No branches"}):(0,s.jsxs)(s.Fragment,{children:[p&&(0,s.jsx)("input",{autoFocus:!0,value:l,onChange:e=>c(e.target.value),placeholder:"Filter branches…",className:"mb-1 w-full shrink-0 rounded border bg-background px-1.5 py-1 text-[11px] outline-none focus:ring-1 focus:ring-ring"}),(0,s.jsx)("div",{className:"min-h-0 flex-1 overflow-auto",children:0===m.length?(0,s.jsx)("p",{className:"px-2 py-1 text-[10px] text-muted-foreground",children:"No match"}):m.map(e=>(0,s.jsxs)("button",{type:"button",disabled:i||e.current,className:(0,eh.cn)("flex w-full items-center gap-1.5 rounded px-2 py-1 text-left text-[11px] hover:bg-muted",e.current?"font-semibold text-foreground":"text-muted-foreground"),onClick:t=>{t.stopPropagation(),e.current||o(e.name)},children:[e.current?(0,s.jsx)(g.Check,{className:"h-3 w-3 shrink-0"}):(0,s.jsx)("span",{className:"w-3 shrink-0"}),(0,s.jsx)("span",{className:"truncate",children:e.name}),r===e.name&&(0,s.jsx)(u.Loader2,{className:"ml-auto h-3 w-3 shrink-0 animate-spin"})]},e.name))})]})}),document.body)}var na=e.i(918552),nl=e.i(136131),nc="ContextMenu",[nd,nu]=(0,N.createContextScope)(nc,[na.createMenuScope]),np=(0,na.createMenuScope)(),[nh,nf]=nd(nc),nm=e=>{let{__scopeContextMenu:t,children:n,onOpenChange:r,dir:i,modal:o=!0}=e,[a,l]=f.useState(!1),c=np(t),d=(0,nl.useCallbackRef)(r),u=f.useCallback(e=>{l(e),d(e)},[d]);return(0,s.jsx)(nh,{scope:t,open:a,onOpenChange:u,modal:o,children:(0,s.jsx)(na.Root,{...c,dir:i,open:a,onOpenChange:u,modal:o,children:n})})};nm.displayName=nc;var ng="ContextMenuTrigger",nb=f.forwardRef((e,t)=>{let{__scopeContextMenu:n,disabled:r=!1,...i}=e,o=nf(ng,n),a=np(n),l=f.useRef({x:0,y:0}),c=f.useRef({getBoundingClientRect:()=>DOMRect.fromRect({width:0,height:0,...l.current})}),d=f.useRef(0),u=f.useCallback(()=>window.clearTimeout(d.current),[]),p=e=>{l.current={x:e.clientX,y:e.clientY},o.onOpenChange(!0)};return f.useEffect(()=>u,[u]),f.useEffect(()=>void(r&&u()),[r,u]),(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(na.Anchor,{...a,virtualRef:c}),(0,s.jsx)(T.Primitive.span,{"data-state":o.open?"open":"closed","data-disabled":r?"":void 0,...i,ref:t,style:{WebkitTouchCallout:"none",...e.style},onContextMenu:r?e.onContextMenu:(0,w.composeEventHandlers)(e.onContextMenu,e=>{u(),p(e),e.preventDefault()}),onPointerDown:r?e.onPointerDown:(0,w.composeEventHandlers)(e.onPointerDown,nA(e=>{u(),d.current=window.setTimeout(()=>p(e),700)})),onPointerMove:r?e.onPointerMove:(0,w.composeEventHandlers)(e.onPointerMove,nA(u)),onPointerCancel:r?e.onPointerCancel:(0,w.composeEventHandlers)(e.onPointerCancel,nA(u)),onPointerUp:r?e.onPointerUp:(0,w.composeEventHandlers)(e.onPointerUp,nA(u))})]})});nb.displayName=ng;var nx=e=>{let{__scopeContextMenu:t,...n}=e,r=np(t);return(0,s.jsx)(na.Portal,{...r,...n})};nx.displayName="ContextMenuPortal";var ny="ContextMenuContent",nv=f.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=nf(ny,n),o=np(n),a=f.useRef(!1);return(0,s.jsx)(na.Content,{...o,...r,ref:t,side:"right",sideOffset:2,align:"start",onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),!t.defaultPrevented&&a.current&&t.preventDefault(),a.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||i.modal||(a.current=!0)},style:{...e.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});nv.displayName=ny,f.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=np(n);return(0,s.jsx)(na.Group,{...i,...r,ref:t})}).displayName="ContextMenuGroup";var nw=f.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=np(n);return(0,s.jsx)(na.Label,{...i,...r,ref:t})});nw.displayName="ContextMenuLabel";var nk=f.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=np(n);return(0,s.jsx)(na.Item,{...i,...r,ref:t})});nk.displayName="ContextMenuItem";var nN=f.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=np(n);return(0,s.jsx)(na.CheckboxItem,{...i,...r,ref:t})});nN.displayName="ContextMenuCheckboxItem",f.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=np(n);return(0,s.jsx)(na.RadioGroup,{...i,...r,ref:t})}).displayName="ContextMenuRadioGroup";var nS=f.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=np(n);return(0,s.jsx)(na.RadioItem,{...i,...r,ref:t})});nS.displayName="ContextMenuRadioItem";var nC=f.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=np(n);return(0,s.jsx)(na.ItemIndicator,{...i,...r,ref:t})});nC.displayName="ContextMenuItemIndicator";var nj=f.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=np(n);return(0,s.jsx)(na.Separator,{...i,...r,ref:t})});nj.displayName="ContextMenuSeparator",f.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=np(n);return(0,s.jsx)(na.Arrow,{...i,...r,ref:t})}).displayName="ContextMenuArrow";var nE=f.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=np(n);return(0,s.jsx)(na.SubTrigger,{...i,...r,ref:t})});nE.displayName="ContextMenuSubTrigger";var nM=f.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=np(n);return(0,s.jsx)(na.SubContent,{...i,...r,ref:t,style:{...e.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});function nA(e){return t=>"mouse"!==t.pointerType?e(t):void 0}nM.displayName="ContextMenuSubContent";var nT=e.i(149427);f.forwardRef(({className:e,inset:t,children:n,...r},i)=>(0,s.jsxs)(nE,{ref:i,className:(0,eh.cn)("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",t&&"pl-8",e),...r,children:[n,(0,s.jsx)(e1.ChevronRight,{className:"ml-auto h-4 w-4"})]})).displayName=nE.displayName,f.forwardRef(({className:e,...t},n)=>(0,s.jsx)(nM,{ref:n,className:(0,eh.cn)("z-50 min-w-[8rem] overflow-hidden rounded-sm border bg-popover p-1 text-popover-foreground shadow-golden data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...t})).displayName=nM.displayName;let nO=f.forwardRef(({className:e,...t},n)=>(0,s.jsx)(nx,{children:(0,s.jsx)(nv,{ref:n,className:(0,eh.cn)("z-50 min-w-[8rem] overflow-hidden rounded-sm border bg-popover p-1 text-popover-foreground shadow-golden data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...t})}));nO.displayName=nv.displayName;let n_=f.forwardRef(({className:e,inset:t,...n},r)=>(0,s.jsx)(nk,{ref:r,className:(0,eh.cn)("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",e),...n}));n_.displayName=nk.displayName,f.forwardRef(({className:e,children:t,checked:n,...r},i)=>(0,s.jsxs)(nN,{ref:i,className:(0,eh.cn)("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),checked:n,...r,children:[(0,s.jsx)("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,s.jsx)(nC,{children:(0,s.jsx)(g.Check,{className:"h-4 w-4"})})}),t]})).displayName=nN.displayName,f.forwardRef(({className:e,children:t,...n},r)=>(0,s.jsxs)(nS,{ref:r,className:(0,eh.cn)("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[(0,s.jsx)("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,s.jsx)(nC,{children:(0,s.jsx)(nT.Circle,{className:"h-2 w-2 fill-current"})})}),t]})).displayName=nS.displayName,f.forwardRef(({className:e,inset:t,...n},r)=>(0,s.jsx)(nw,{ref:r,className:(0,eh.cn)("px-2 py-1.5 text-sm font-normal",t&&"pl-8",e),...n})).displayName=nw.displayName;let nD=f.forwardRef(({className:e,...t},n)=>(0,s.jsx)(nj,{ref:n,className:(0,eh.cn)("-mx-1 my-1 h-px bg-muted",e),...t}));nD.displayName=nj.displayName;let nR="wiki-humanize-names",nI=(0,eN.create)((e,t)=>({humanize:"1"===localStorage.getItem(nR),toggle:()=>{let n=!t().humanize;n?localStorage.setItem(nR,"1"):localStorage.removeItem(nR),e({humanize:n})}})),nL="wiki-show-hidden",nP=(0,eN.create)((e,t)=>({showHidden:"1"===localStorage.getItem(nL),toggle:()=>{let n=!t().showHidden;n?localStorage.setItem(nL,"1"):localStorage.removeItem(nL),e({showHidden:n})}}));function nz(e){return e.split(".").pop()?.toLowerCase()??""}function n$(e,t){if("node-app"===t)return"node-app";if("app"===t)return"app";if("dir"===t)return"fallback";let n=e.split("/").pop()??e;if(n.startsWith(".")&&-1===n.indexOf(".",1))return"source";let r=nz(e);return r?["md","markdown"].includes(r)?"editor":"txt"===r?"text":["csv","tsv"].includes(r)?"csv":"pdf"===r?"pdf":["mmd","mermaid"].includes(r)?"mermaid":"ipynb"===r?"notebook":["png","jpg","jpeg","gif","webp","svg","avif","ico","bmp"].includes(r)?"image":["mp4","webm","mov","m4v","mp3","wav","ogg","m4a","aac"].includes(r)?"media":"docx"===r?"docx":["xlsx","xlsm"].includes(r)?"xlsx":"pptx"===r?"pptx":"html"===r?"html":(["py","js","ts","tsx","jsx","go","rs","java","c","cpp","h","sh","bash","zsh","rb","php","swift","kt","lua","sql","yaml","yml","toml","json","xml","css","scss"].includes(r),"source"):"source"}let nB=new Set(["txt","md","markdown","json","yaml","yml","toml","csv","tsv","xml","html","css","js","ts","tsx","jsx","sh","bash","zsh","rb","py","go","rs","java","c","cpp","h","php","swift","kt","lua","sql","scss","mmd","mermaid","ini","env","log","conf"]);function nF(e){let t=n$(e,"file");return"editor"===t||"text"===t||nB.has(nz(e))}function nH(e){return["md","markdown"].includes(nz(e))}function nU(e){return"image"===n$(e,"file")}function nV(e){return"html"===n$(e,"file")}let nW={contentVisibility:"auto",containIntrinsicSize:"auto 32px"};function nq({node:e,ctx:t,isFavorited:n,activeWorkspaceId:r}){return(0,s.jsxs)(nO,{className:"w-48",children:[(0,s.jsxs)(n_,{onSelect:()=>t.copyPath(e.path),children:[(0,s.jsx)(tt.Copy,{className:"mr-2 h-3.5 w-3.5"}),"Copy path"]}),nH(e.name)&&(0,s.jsxs)(n_,{onSelect:()=>t.copyWikiLink(e.name),children:[(0,s.jsx)(l.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy wiki link"]}),(0,s.jsxs)(n_,{onSelect:()=>t.copyUrl(e.path),children:[(0,s.jsx)(t8,{className:"mr-2 h-3.5 w-3.5"}),"Copy URL"]}),"file"===e.type&&nF(e.name)&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(n_,{onSelect:()=>t.copyRawContent(e.path),children:[(0,s.jsx)(l.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy raw content"]}),(0,s.jsxs)(n_,{onSelect:()=>t.copyFormattedContent(e.path,e.name),children:[(0,s.jsx)(l.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy formatted content"]})]}),(0,s.jsx)(nD,{}),"dir"===e.type&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(n_,{onSelect:()=>{e.expanded||t.toggleFolder(e),t.setNewFileParent(e.path),t.setNewFileName(""),t.setFileCreateError(null)},children:[(0,s.jsx)(nn,{className:"mr-2 h-3.5 w-3.5"}),"New file here"]}),(0,s.jsxs)(n_,{onSelect:()=>t.triggerUpload(e.path),children:[(0,s.jsx)(ns,{className:"mr-2 h-3.5 w-3.5"}),"Upload here"]}),(0,s.jsxs)(n_,{onSelect:()=>{t.setNewFolderParent(e.path),t.setNewFolderName(""),t.setFolderError(null)},children:[(0,s.jsx)(nr,{className:"mr-2 h-3.5 w-3.5"}),"New subfolder"]}),(0,s.jsx)(nD,{})]}),(0,s.jsxs)(n_,{onSelect:()=>t.handleDownload(e),children:[(0,s.jsx)(t7.Download,{className:"mr-2 h-3.5 w-3.5"}),"file"===e.type?"Download":"Download as zip"]}),(0,s.jsxs)(n_,{onSelect:()=>t.toggleFavorite(e,r),children:[(0,s.jsx)(e7,{className:(0,eh.cn)("mr-2 h-3.5 w-3.5",n&&"fill-current text-amber-400")}),n?"Remove from favorites":"Add to favorites"]}),(0,s.jsx)(nD,{}),(0,s.jsxs)(n_,{className:"text-destructive focus:text-destructive",onSelect:()=>{t.setDeletingPath(e.path),t.setDeletingIsDir("file"!==e.type)},children:[(0,s.jsx)(tr,{className:"mr-2 h-3.5 w-3.5"}),"Delete"]})]})}function nK({name:e,type:t}){let n="h-3.5 w-3.5 shrink-0";return"dir"===t?(0,s.jsx)(e2,{className:(0,eh.cn)(n,"text-foreground/70")}):"app"===t?(0,s.jsx)(c,{className:(0,eh.cn)(n,"text-foreground/70")}):"node-app"===t?(0,s.jsx)(ni,{className:(0,eh.cn)(n,"text-emerald-500")}):nV(e)?(0,s.jsx)(c,{className:(0,eh.cn)(n,"text-foreground/60")}):nU(e)?(0,s.jsx)(d.Image,{className:(0,eh.cn)(n,"text-sunshine-700")}):nF(e)?(0,s.jsx)(l.FileText,{className:(0,eh.cn)(n,"text-foreground/70")}):(0,s.jsx)(nt,{className:(0,eh.cn)(n,"text-foreground/60")})}let nG=(0,f.memo)(function({node:e,depth:t,ctx:n,isMobile:r,activeWorkspaceId:i,sidebarScrollRef:o,isActive:a,isDragOver:p,isFavorited:h,isAgentActive:f,isPulling:m,branchOpen:g,branchPos:b,branches:x,branchLoading:y,checkingOut:w,onHoverEnter:k,onHoverLeave:N}){var S;let C,j,E,M,A,T=nI(e=>e.humanize);return(0,s.jsxs)(nm,{children:[(0,s.jsx)(nb,{asChild:!0,children:(0,s.jsxs)("div",{role:"treeitem",tabIndex:0,draggable:!r,onKeyDown:r=>{if("Enter"===r.key||" "===r.key)r.preventDefault(),"dir"===e.type?n.toggleFolder(e):"app"===e.type||"node-app"===e.type?(n.openViewer(e),n.toggleFolder(e)):n.openViewer(e);else if("ArrowDown"===r.key){r.preventDefault();let e=o.current;if(!e)return;let t=Array.from(e.querySelectorAll('[role="treeitem"]')),n=t.indexOf(r.currentTarget);t[n+1]?.focus()}else if("ArrowUp"===r.key){r.preventDefault();let e=o.current;if(!e)return;let t=Array.from(e.querySelectorAll('[role="treeitem"]')),n=t.indexOf(r.currentTarget);t[n-1]?.focus()}else if("ArrowRight"===r.key){if(r.preventDefault(),"dir"===e.type||"app"===e.type||"node-app"===e.type)if(e.expanded){let e=o.current;if(!e)return;let t=Array.from(e.querySelectorAll('[role="treeitem"]')),n=t.indexOf(r.currentTarget);t[n+1]?.focus()}else n.toggleFolder(e)}else if("ArrowLeft"===r.key){if(r.preventDefault(),("dir"===e.type||"app"===e.type||"node-app"===e.type)&&e.expanded)n.toggleFolder(e);else if(t>0){let e=o.current;if(!e)return;let t=Array.from(e.querySelectorAll('[role="treeitem"]')),n=r.currentTarget,i=t.indexOf(n),s=Number.parseInt(n.style.paddingLeft??"0",10);for(let e=i-1;e>=0;e--)if(Number.parseInt(t[e].style.paddingLeft??"0",10)<s){t[e].focus();break}}}},onDragStart:t=>n.handleDragStart(t,e),onDragOver:t=>"dir"===e.type?n.handleDragOver(t,e.path,"dir"):t.preventDefault(),onDragLeave:()=>n.setDragOverPath(null),onDrop:t=>"dir"===e.type?n.handleDropOnFolder(t,e.path):t.preventDefault(),onMouseEnter:()=>k(e),onMouseLeave:N,className:(0,eh.cn)("tree-row-reveal flex items-center gap-1.5 rounded-sm px-2 py-1 text-sm cursor-pointer group transition-colors select-none touch-target",a?"bg-accent-soft text-foreground font-medium":"hover:bg-muted",p&&"ring-2 ring-primary bg-primary-soft",e.name.startsWith(".")&&"opacity-40"),style:{paddingLeft:`${14*t+8}px`,...nW},onClick:()=>{"dir"===e.type?n.toggleFolder(e):("app"===e.type||"node-app"===e.type?(n.openViewer(e),n.toggleFolder(e)):n.openViewer(e),r&&n.setSidebarCollapsed(!0))},children:["dir"===e.type||"app"===e.type||"node-app"===e.type?e.loading?(0,s.jsx)(u.Loader2,{className:"h-3.5 w-3.5 shrink-0 animate-spin text-muted-foreground"}):(0,s.jsx)(e1.ChevronRight,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground transition-transform duration-200 ease-out",style:{transform:e.expanded?"rotate(90deg)":"rotate(0deg)"}}):(0,s.jsx)("span",{className:"w-3.5 shrink-0"}),(0,s.jsx)("span",{className:"",children:"dir"===e.type?e.expanded?(0,s.jsx)(e3,{className:(0,eh.cn)("h-4 w-4 shrink-0",!a&&"text-foreground/70")}):(0,s.jsx)(e2,{className:(0,eh.cn)("h-4 w-4 shrink-0",!a&&"text-foreground/70")}):"app"===e.type?(0,s.jsx)(c,{className:(0,eh.cn)("h-4 w-4 shrink-0",!a&&"text-foreground/70")}):"node-app"===e.type?(0,s.jsx)(ni,{className:(0,eh.cn)("h-4 w-4 shrink-0",!a&&"text-emerald-500")}):nV(e.name)?(0,s.jsx)(c,{className:(0,eh.cn)("h-4 w-4 shrink-0",!a&&"text-foreground/60")}):nU(e.name)?(0,s.jsx)(d.Image,{className:(0,eh.cn)("h-4 w-4 shrink-0",!a&&"text-sunshine-700")}):nF(e.name)?(0,s.jsx)(l.FileText,{className:(0,eh.cn)("h-4 w-4 shrink-0",!a&&"text-foreground/70")}):(0,s.jsx)(nt,{className:(0,eh.cn)("h-4 w-4 shrink-0",!a&&"text-foreground/60")})}),(0,s.jsx)("span",{className:"min-w-0 flex-1 truncate",title:T?e.name:void 0,children:T?(E=(j=(C=(S=e.name).lastIndexOf("."))>0&&C<S.length-1)?S.slice(0,C):S,M=j?S.slice(C):"",(A=E.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").split(/[\s_-]+/).filter(Boolean).map(e=>/^[A-Z0-9]+$/.test(e)?e:e[0].toUpperCase()+e.slice(1))).length?A.join(" ")+M:S):e.name}),e.git&&(0,s.jsxs)("span",{className:"relative flex shrink-0 items-center gap-0.5 rounded-sm bg-muted px-1 py-0.5 text-[10px] text-muted-foreground",children:[(0,s.jsxs)("button",{"data-branch-trigger":!0,type:"button",className:"flex items-center gap-0.5 hover:text-foreground",title:"Switch branch",onClick:t=>{if(t.stopPropagation(),g){n.setBranchDropdownNode(null),n.setBranchDropdownPos(null);return}let r=t.currentTarget.getBoundingClientRect();n.setBranchDropdownPos({top:r.bottom+4,left:r.left}),n.setBranchDropdownNode(e.path),n.loadBranches(e.path)},children:[(0,s.jsx)(e5,{className:"h-2.5 w-2.5"}),e.git.branch,e.git.dirty&&(0,s.jsx)("span",{className:"ml-0.5 text-foreground/70",children:"*"})]}),m?(0,s.jsx)(u.Loader2,{className:"ml-0.5 h-2.5 w-2.5 animate-spin"}):(0,s.jsx)("button",{type:"button",onClick:t=>{t.stopPropagation();let r=e.path.includes("/")?e.path.substring(0,e.path.lastIndexOf("/")):"";n.handleGitPull(e.path,r)},className:"ml-0.5 text-muted-foreground hover:text-foreground",title:"Pull latest",children:(0,s.jsx)(t_,{className:"h-2.5 w-2.5"})}),g&&b&&(0,s.jsx)(no,{pos:b,branches:x,loading:y,busyName:w,disabled:null!==w,onPick:t=>{let r=e.path.includes("/")?e.path.substring(0,e.path.lastIndexOf("/")):"";n.handleCheckout(e.path,t,r)},onClose:()=>{n.setBranchDropdownNode(null),n.setBranchDropdownPos(null)}})]}),f&&(0,s.jsx)("span",{className:"ml-0.5 h-1.5 w-1.5 rounded-full bg-emerald-400 shrink-0 animate-pulse",title:"Agent recently active"}),(0,s.jsx)("div",{className:"hover-reveal flex max-w-0 shrink-0 items-center overflow-hidden opacity-0 transition-all duration-150 group-hover:max-w-7 group-hover:opacity-100 focus-within:max-w-7 focus-within:opacity-100",onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),children:(0,s.jsxs)(ek.DropdownMenu,{children:[(0,s.jsx)(ek.DropdownMenuTrigger,{asChild:!0,children:(0,s.jsx)(v.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0 text-muted-foreground hover:text-foreground",title:"File actions",children:(0,s.jsx)(ne,{className:"h-3.5 w-3.5"})})}),(0,s.jsxs)(ek.DropdownMenuContent,{align:"end",className:"w-48",children:[(0,s.jsxs)(ek.DropdownMenuItem,{onClick:()=>n.copyPath(e.path),children:[(0,s.jsx)(tt.Copy,{className:"mr-2 h-3.5 w-3.5"}),"Copy path"]}),nH(e.name)&&(0,s.jsxs)(ek.DropdownMenuItem,{onClick:()=>n.copyWikiLink(e.name),children:[(0,s.jsx)(l.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy wiki link"]}),(0,s.jsxs)(ek.DropdownMenuItem,{onClick:()=>n.copyUrl(e.path),children:[(0,s.jsx)(t8,{className:"mr-2 h-3.5 w-3.5"}),"Copy URL"]}),"file"===e.type&&nF(e.name)&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(ek.DropdownMenuItem,{onClick:()=>n.copyRawContent(e.path),children:[(0,s.jsx)(l.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy raw content"]}),(0,s.jsxs)(ek.DropdownMenuItem,{onClick:()=>n.copyFormattedContent(e.path,e.name),children:[(0,s.jsx)(l.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy formatted content"]})]}),(0,s.jsx)(ek.DropdownMenuSeparator,{}),"dir"===e.type&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(ek.DropdownMenuItem,{onClick:async()=>{e.expanded||n.toggleFolder(e),n.setNewFileParent(e.path),n.setNewFileName(""),n.setFileCreateError(null)},children:[(0,s.jsx)(nn,{className:"mr-2 h-3.5 w-3.5"}),"New file here"]}),(0,s.jsxs)(ek.DropdownMenuItem,{onClick:()=>n.triggerUpload(e.path),children:[(0,s.jsx)(ns,{className:"mr-2 h-3.5 w-3.5"}),"Upload here"]}),(0,s.jsxs)(ek.DropdownMenuItem,{onClick:()=>{n.setNewFolderParent(e.path),n.setNewFolderName(""),n.setFolderError(null)},children:[(0,s.jsx)(nr,{className:"mr-2 h-3.5 w-3.5"}),"New subfolder"]}),(0,s.jsx)(ek.DropdownMenuSeparator,{})]}),(0,s.jsxs)(ek.DropdownMenuItem,{onClick:()=>n.handleDownload(e),children:[(0,s.jsx)(t7.Download,{className:"mr-2 h-3.5 w-3.5"}),"file"===e.type?"Download":"Download as zip"]}),(0,s.jsxs)(ek.DropdownMenuItem,{onClick:()=>n.toggleFavorite(e,i),children:[(0,s.jsx)(e7,{className:(0,eh.cn)("mr-2 h-3.5 w-3.5",h&&"fill-current text-amber-400")}),h?"Remove from favorites":"Add to favorites"]}),(0,s.jsx)(ek.DropdownMenuSeparator,{}),(0,s.jsxs)(ek.DropdownMenuItem,{className:"text-destructive focus:text-destructive",onClick:()=>{n.setDeletingPath(e.path),n.setDeletingIsDir("file"!==e.type)},children:[(0,s.jsx)(tr,{className:"mr-2 h-3.5 w-3.5"}),"Delete"]})]})]})})]})}),(0,s.jsx)(nq,{node:e,ctx:n,isFavorited:h,activeWorkspaceId:i})]})}),nJ=(0,f.memo)(function(e){let{ctx:t,openPath:n,dragOverPath:r,branchDropdownNode:i,branchDropdownPos:o,nodeBranches:a,branchesLoading:c,checkingOutBranch:d,pullingRepo:u,activePaths:p,favorites:m,isMobile:b,activeWorkspaceId:x,newFileParent:y,newFileName:w,fileCreateError:k,newFolderParent:N,newFolderName:S,folderError:C,sidebarScrollRef:j}=e,E=nP(e=>e.showHidden),M=(0,f.useRef)(null),A=(0,f.useCallback)(e=>{let n=("dir"===e.type||"app"===e.type||"node-app"===e.type)&&!e.expanded&&void 0===e.children;("file"===e.type||n)&&(M.current&&clearTimeout(M.current),M.current=setTimeout(()=>t.prefetch(e),120))},[t]),T=(0,f.useCallback)(()=>{M.current&&(clearTimeout(M.current),M.current=null)},[]),O=(0,f.useMemo)(()=>{let t=[],n=(e,r)=>{for(let i of e)!(!E&&i.name.startsWith("."))&&(t.push({kind:"row",node:i,depth:r}),"dir"===i.type&&(N===i.path&&t.push({kind:"newfolder",node:i,depth:r}),y===i.path&&t.push({kind:"newfile",node:i,depth:r})),("dir"===i.type||"app"===i.type||"node-app"===i.type)&&i.expanded&&(i.children&&i.children.length>0?n(i.children,r+1):i.children?.length===0&&t.push({kind:"empty",node:i,depth:r})))};return n(e.nodes,0),t},[e.nodes,y,N,E]);return(0,s.jsx)(s.Fragment,{children:O.map(e=>{let{node:f,depth:y}=e;if("row"===e.kind){let e=i===f.path;return(0,s.jsx)(nG,{node:f,depth:y,ctx:t,isMobile:b,activeWorkspaceId:x,sidebarScrollRef:j,isActive:n===f.path,isDragOver:r===f.path,isFavorited:m.some(e=>e.path===f.path),isAgentActive:p.has(f.path),isPulling:u===f.path,branchOpen:e,branchPos:e?o:null,branches:f.git?a[f.path]??[]:[],branchLoading:!!f.git&&!!c[f.path],checkingOut:e?d:null,onHoverEnter:A,onHoverLeave:T},f.path)}return"newfolder"===e.kind?(0,s.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1",style:{paddingLeft:`${(y+1)*14+8}px`,...nW},children:[(0,s.jsx)("span",{className:"w-3.5 shrink-0"}),(0,s.jsx)(e2,{className:"h-4 w-4 shrink-0 text-foreground/70"}),(0,s.jsx)("input",{className:"flex-1 bg-transparent text-sm outline-none border-b border-border min-w-0",placeholder:"Folder name",value:S,onChange:e=>t.setNewFolderName(e.target.value),onKeyDown:e=>{"Enter"===e.key&&t.handleCreateFolder(),"Escape"===e.key&&(t.setNewFolderParent(null),t.setNewFolderName(""))}}),C&&(0,s.jsx)("span",{className:"text-xs text-destructive",children:C}),(0,s.jsx)(v.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:t.handleCreateFolder,children:(0,s.jsx)(g.Check,{className:"h-3 w-3"})}),(0,s.jsx)(v.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:()=>{t.setNewFolderParent(null),t.setNewFolderName("")},children:(0,s.jsx)(h,{className:"h-3 w-3"})})]},`nf-${f.path}`):"newfile"===e.kind?(0,s.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1",style:{paddingLeft:`${(y+1)*14+8}px`,...nW},children:[(0,s.jsx)("span",{className:"w-3.5 shrink-0"}),(0,s.jsx)(l.FileText,{className:"h-4 w-4 shrink-0 text-accent"}),(0,s.jsx)("input",{autoFocus:!0,className:"flex-1 bg-transparent text-sm outline-none border-b border-border min-w-0",placeholder:"filename (default .md)",value:w,onChange:e=>t.setNewFileName(e.target.value),onKeyDown:e=>{"Enter"===e.key&&t.handleCreateFile(),"Escape"===e.key&&(t.setNewFileParent(null),t.setNewFileName(""))}}),k&&(0,s.jsx)("span",{className:"text-xs text-destructive",children:k}),(0,s.jsx)(v.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:t.handleCreateFile,children:(0,s.jsx)(g.Check,{className:"h-3 w-3"})}),(0,s.jsx)(v.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:()=>{t.setNewFileParent(null),t.setNewFileName("")},children:(0,s.jsx)(h,{className:"h-3 w-3"})})]},`ff-${f.path}`):(0,s.jsx)("div",{className:"text-xs text-muted-foreground/50 py-0.5",style:{paddingLeft:`${(y+1)*14+8+14+6+16+6}px`,...nW},children:"Empty"},`empty-${f.path}`)})})});function nZ(e){return e?`wiki-pinned-files-${e}`:"wiki-pinned-files"}function nX(e){try{let t=localStorage.getItem(nZ(e));return t?JSON.parse(t):[]}catch{return[]}}let nY=(0,eN.create)((e,t)=>({favorites:[],loadForWorkspace:t=>{e({favorites:nX(t)})},toggle:(t,n)=>{let r=nX(n),i=r.some(e=>e.path===t.path)?r.filter(e=>e.path!==t.path):[...r,t];localStorage.setItem(nZ(n),JSON.stringify(i)),e({favorites:i})},isFavorited:e=>t().favorites.some(t=>t.path===e)}));function nQ({doc:e,node:t,extraItems:n,activeWorkspaceId:r=null}){let i=nY(e=>e.isFavorited(t.path));return(0,s.jsxs)(ek.DropdownMenu,{children:[(0,s.jsx)(ek.DropdownMenuTrigger,{asChild:!0,children:(0,s.jsx)(v.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"File actions",children:(0,s.jsx)(ne,{className:"h-3.5 w-3.5"})})}),(0,s.jsxs)(ek.DropdownMenuContent,{align:"end",className:"w-52",children:[(0,s.jsxs)(ek.DropdownMenuItem,{onClick:()=>{let e=(0,tC.withWs)(`/api/wiki/download?path=${encodeURIComponent(t.path)}`),n=document.createElement("a");n.href=e,n.download=t.name,document.body.appendChild(n),n.click(),n.remove()},children:[(0,s.jsx)(t7.Download,{className:"mr-2 h-3.5 w-3.5"}),"Download"]}),(0,s.jsxs)(ek.DropdownMenuItem,{onClick:()=>{nY.getState().toggle({path:t.path,name:t.name},r)},children:[(0,s.jsx)(e7,{className:(0,eh.cn)("mr-2 h-3.5 w-3.5",i&&"fill-current text-amber-400")}),i?"Remove from favorites":"Add to favorites"]}),(0,s.jsx)(ek.DropdownMenuSeparator,{}),(0,s.jsxs)(ek.DropdownMenuItem,{onClick:()=>e.copyPath(t.path),children:[(0,s.jsx)(tt.Copy,{className:"mr-2 h-3.5 w-3.5"}),"Copy path"]}),nH(t.name)&&(0,s.jsxs)(ek.DropdownMenuItem,{onClick:()=>e.copyWikiLink(t.name),children:[(0,s.jsx)(l.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy wiki link"]}),(0,s.jsx)(ek.DropdownMenuSeparator,{}),(0,s.jsxs)(ek.DropdownMenuItem,{onClick:()=>e.copyUrl(t.path),children:[(0,s.jsx)(t8,{className:"mr-2 h-3.5 w-3.5"}),"Copy URL"]}),nF(t.name)&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(ek.DropdownMenuSeparator,{}),(0,s.jsxs)(ek.DropdownMenuItem,{onClick:()=>void e.copyRawContent(t.path),children:[(0,s.jsx)(l.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy raw content"]}),(0,s.jsxs)(ek.DropdownMenuItem,{onClick:()=>void e.copyFormattedContent(t.path,t.name),children:[(0,s.jsx)(l.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy formatted content"]})]}),n&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(ek.DropdownMenuSeparator,{}),n]})]})]})}let n0=(0,o.default)("align-center",[["path",{d:"M17 12H7",key:"16if0g"}],["path",{d:"M19 18H5",key:"18s9l3"}],["path",{d:"M21 6H3",key:"1jwq7v"}]]);var n1=e.i(409082);let n2=(0,o.default)("panel-left",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]);var n3=e.i(847463),n5=e.i(917356),n4=/[\\\/_+.#"@\[\(\{&]/,n6=/[\\\/_+.#"@\[\(\{&]/g,n9=/[\s-]/,n7=/[\s-]/g;function n8(e){return e.toLowerCase().replace(n7," ")}var re='[cmdk-group=""]',rt='[cmdk-group-items=""]',rn='[cmdk-item=""]',rr=`${rn}:not([aria-disabled="true"])`,ri="cmdk-item-select",rs="data-value",ro=(e,t,n)=>{var r;return r=e,function e(t,n,r,i,s,o,a){if(o===n.length)return s===t.length?1:.99;var l=`${s},${o}`;if(void 0!==a[l])return a[l];for(var c,d,u,p,h=i.charAt(o),f=r.indexOf(h,s),m=0;f>=0;)(c=e(t,n,r,i,f+1,o+1,a))>m&&(f===s?c*=1:n4.test(t.charAt(f-1))?(c*=.8,(u=t.slice(s,f-1).match(n6))&&s>0&&(c*=Math.pow(.999,u.length))):n9.test(t.charAt(f-1))?(c*=.9,(p=t.slice(s,f-1).match(n7))&&s>0&&(c*=Math.pow(.999,p.length))):(c*=.17,s>0&&(c*=Math.pow(.999,f-s))),t.charAt(f)!==n.charAt(o)&&(c*=.9999)),(c<.1&&r.charAt(f-1)===i.charAt(o+1)||i.charAt(o+1)===i.charAt(o)&&r.charAt(f-1)!==i.charAt(o))&&.1*(d=e(t,n,r,i,f+1,o+2,a))>c&&(c=.1*d),c>m&&(m=c),f=r.indexOf(h,f+1);return a[l]=m,m}(r=n&&n.length>0?`${r+" "+n.join(" ")}`:r,t,n8(r),n8(t),0,0,{})},ra=f.createContext(void 0),rl=f.createContext(void 0),rc=f.createContext(void 0),rd=f.forwardRef((e,t)=>{let n=rv(()=>{var t,n;return{search:"",value:null!=(n=null!=(t=e.value)?t:e.defaultValue)?n:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=rv(()=>new Set),i=rv(()=>new Map),s=rv(()=>new Map),o=rv(()=>new Set),a=rx(e),{label:l,children:c,value:d,onValueChange:u,filter:p,shouldFilter:h,loop:m,disablePointerSelection:g=!1,vimBindings:b=!0,...x}=e,y=(0,S.useId)(),v=(0,S.useId)(),w=(0,S.useId)(),k=f.useRef(null),N=rN();ry(()=>{if(void 0!==d){let e=d.trim();n.current.value=e,C.emit()}},[d]),ry(()=>{N(6,O)},[]);let C=f.useMemo(()=>({subscribe:e=>(o.current.add(e),()=>o.current.delete(e)),snapshot:()=>n.current,setState:(e,t,r)=>{var i,s,o,l;if(!Object.is(n.current[e],t)){if(n.current[e]=t,"search"===e)T(),M(),N(1,A);else if("value"===e){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let e=document.getElementById(w);e?e.focus():null==(i=document.getElementById(y))||i.focus()}if(N(7,()=>{var e;n.current.selectedItemId=null==(e=_())?void 0:e.id,C.emit()}),r||N(5,O),(null==(s=a.current)?void 0:s.value)!==void 0){null==(l=(o=a.current).onValueChange)||l.call(o,null!=t?t:"");return}}C.emit()}},emit:()=>{o.current.forEach(e=>e())}}),[]),j=f.useMemo(()=>({value:(e,t,r)=>{var i;t!==(null==(i=s.current.get(e))?void 0:i.value)&&(s.current.set(e,{value:t,keywords:r}),n.current.filtered.items.set(e,E(t,r)),N(2,()=>{M(),C.emit()}))},item:(e,t)=>(r.current.add(e),t&&(i.current.has(t)?i.current.get(t).add(e):i.current.set(t,new Set([e]))),N(3,()=>{T(),M(),n.current.value||A(),C.emit()}),()=>{s.current.delete(e),r.current.delete(e),n.current.filtered.items.delete(e);let t=_();N(4,()=>{T(),(null==t?void 0:t.getAttribute("id"))===e&&A(),C.emit()})}),group:e=>(i.current.has(e)||i.current.set(e,new Set),()=>{s.current.delete(e),i.current.delete(e)}),filter:()=>a.current.shouldFilter,label:l||e["aria-label"],getDisablePointerSelection:()=>a.current.disablePointerSelection,listId:y,inputId:w,labelId:v,listInnerRef:k}),[]);function E(e,t){var r,i;let s=null!=(i=null==(r=a.current)?void 0:r.filter)?i:ro;return e?s(e,n.current.search,t):0}function M(){if(!n.current.search||!1===a.current.shouldFilter)return;let e=n.current.filtered.items,t=[];n.current.filtered.groups.forEach(n=>{let r=i.current.get(n),s=0;r.forEach(t=>{s=Math.max(e.get(t),s)}),t.push([n,s])});let r=k.current;D().sort((t,n)=>{var r,i;let s=t.getAttribute("id"),o=n.getAttribute("id");return(null!=(r=e.get(o))?r:0)-(null!=(i=e.get(s))?i:0)}).forEach(e=>{let t=e.closest(rt);t?t.appendChild(e.parentElement===t?e:e.closest(`${rt} > *`)):r.appendChild(e.parentElement===r?e:e.closest(`${rt} > *`))}),t.sort((e,t)=>t[1]-e[1]).forEach(e=>{var t;let n=null==(t=k.current)?void 0:t.querySelector(`${re}[${rs}="${encodeURIComponent(e[0])}"]`);null==n||n.parentElement.appendChild(n)})}function A(){let e=D().find(e=>"true"!==e.getAttribute("aria-disabled")),t=null==e?void 0:e.getAttribute(rs);C.setState("value",t||void 0)}function T(){var e,t,o,l;if(!n.current.search||!1===a.current.shouldFilter){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let c=0;for(let i of r.current){let r=E(null!=(t=null==(e=s.current.get(i))?void 0:e.value)?t:"",null!=(l=null==(o=s.current.get(i))?void 0:o.keywords)?l:[]);n.current.filtered.items.set(i,r),r>0&&c++}for(let[e,t]of i.current)for(let r of t)if(n.current.filtered.items.get(r)>0){n.current.filtered.groups.add(e);break}n.current.filtered.count=c}function O(){var e,t,n;let r=_();r&&((null==(e=r.parentElement)?void 0:e.firstChild)===r&&(null==(n=null==(t=r.closest(re))?void 0:t.querySelector('[cmdk-group-heading=""]'))||n.scrollIntoView({block:"nearest"})),r.scrollIntoView({block:"nearest"}))}function _(){var e;return null==(e=k.current)?void 0:e.querySelector(`${rn}[aria-selected="true"]`)}function D(){var e;return Array.from((null==(e=k.current)?void 0:e.querySelectorAll(rr))||[])}function R(e){let t=D()[e];t&&C.setState("value",t.getAttribute(rs))}function I(e){var t;let n=_(),r=D(),i=r.findIndex(e=>e===n),s=r[i+e];null!=(t=a.current)&&t.loop&&(s=i+e<0?r[r.length-1]:i+e===r.length?r[0]:r[i+e]),s&&C.setState("value",s.getAttribute(rs))}function L(e){let t=_(),n=null==t?void 0:t.closest(re),r;for(;n&&!r;)r=null==(n=e>0?function(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}(n,re):function(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}(n,re))?void 0:n.querySelector(rr);r?C.setState("value",r.getAttribute(rs)):I(e)}let P=()=>R(D().length-1),z=e=>{e.preventDefault(),e.metaKey?P():e.altKey?L(1):I(1)},$=e=>{e.preventDefault(),e.metaKey?R(0):e.altKey?L(-1):I(-1)};return f.createElement(tv.div,{ref:t,tabIndex:-1,...x,"cmdk-root":"",onKeyDown:e=>{var t;null==(t=x.onKeyDown)||t.call(x,e);let n=e.nativeEvent.isComposing||229===e.keyCode;if(!(e.defaultPrevented||n))switch(e.key){case"n":case"j":b&&e.ctrlKey&&z(e);break;case"ArrowDown":z(e);break;case"p":case"k":b&&e.ctrlKey&&$(e);break;case"ArrowUp":$(e);break;case"Home":e.preventDefault(),R(0);break;case"End":e.preventDefault(),P();break;case"Enter":{e.preventDefault();let t=_();if(t){let e=new Event(ri);t.dispatchEvent(e)}}}}},f.createElement("label",{"cmdk-label":"",htmlFor:j.inputId,id:j.labelId,style:rC},l),rS(e,e=>f.createElement(rl.Provider,{value:C},f.createElement(ra.Provider,{value:j},e))))}),ru=f.forwardRef((e,t)=>{var n,r;let i=(0,S.useId)(),s=f.useRef(null),o=f.useContext(rc),a=f.useContext(ra),l=rx(e),c=null!=(r=null==(n=l.current)?void 0:n.forceMount)?r:null==o?void 0:o.forceMount;ry(()=>{if(!c)return a.item(i,null==o?void 0:o.id)},[c]);let d=rk(i,s,[e.value,e.children,s],e.keywords),u=f.useContext(rl),p=rw(e=>e.value&&e.value===d.current),h=rw(e=>!!c||!1===a.filter()||!e.search||e.filtered.items.get(i)>0);function m(){var e,t;g(),null==(t=(e=l.current).onSelect)||t.call(e,d.current)}function g(){u.setState("value",d.current,!0)}if(f.useEffect(()=>{let t=s.current;if(!(!t||e.disabled))return t.addEventListener(ri,m),()=>t.removeEventListener(ri,m)},[h,e.onSelect,e.disabled]),!h)return null;let{disabled:b,value:x,onSelect:y,forceMount:v,keywords:w,...N}=e;return f.createElement(tv.div,{ref:(0,k.composeRefs)(s,t),...N,id:i,"cmdk-item":"",role:"option","aria-disabled":!!b,"aria-selected":!!p,"data-disabled":!!b,"data-selected":!!p,onPointerMove:b||a.getDisablePointerSelection()?void 0:g,onClick:b?void 0:m},e.children)}),rp=f.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:i,...s}=e,o=(0,S.useId)(),a=f.useRef(null),l=f.useRef(null),c=(0,S.useId)(),d=f.useContext(ra),u=rw(e=>!!i||!1===d.filter()||!e.search||e.filtered.groups.has(o));ry(()=>d.group(o),[]),rk(o,a,[e.value,e.heading,l]);let p=f.useMemo(()=>({id:o,forceMount:i}),[i]);return f.createElement(tv.div,{ref:(0,k.composeRefs)(a,t),...s,"cmdk-group":"",role:"presentation",hidden:!u||void 0},n&&f.createElement("div",{ref:l,"cmdk-group-heading":"","aria-hidden":!0,id:c},n),rS(e,e=>f.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?c:void 0},f.createElement(rc.Provider,{value:p},e))))}),rh=f.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,i=f.useRef(null),s=rw(e=>!e.search);return n||s?f.createElement(tv.div,{ref:(0,k.composeRefs)(i,t),...r,"cmdk-separator":"",role:"separator"}):null}),rf=f.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,i=null!=e.value,s=f.useContext(rl),o=rw(e=>e.search),a=rw(e=>e.selectedItemId),l=f.useContext(ra);return f.useEffect(()=>{null!=e.value&&s.setState("search",e.value)},[e.value]),f.createElement(tv.input,{ref:t,...r,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":l.listId,"aria-labelledby":l.labelId,"aria-activedescendant":a,id:l.inputId,type:"text",value:i?e.value:o,onChange:e=>{i||s.setState("search",e.target.value),null==n||n(e.target.value)}})}),rm=f.forwardRef((e,t)=>{let{children:n,label:r="Suggestions",...i}=e,s=f.useRef(null),o=f.useRef(null),a=rw(e=>e.selectedItemId),l=f.useContext(ra);return f.useEffect(()=>{if(o.current&&s.current){let e=o.current,t=s.current,n,r=new ResizeObserver(()=>{n=requestAnimationFrame(()=>{let n=e.offsetHeight;t.style.setProperty("--cmdk-list-height",n.toFixed(1)+"px")})});return r.observe(e),()=>{cancelAnimationFrame(n),r.unobserve(e)}}},[]),f.createElement(tv.div,{ref:(0,k.composeRefs)(s,t),...i,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":a,"aria-label":r,id:l.listId},rS(e,e=>f.createElement("div",{ref:(0,k.composeRefs)(o,l.listInnerRef),"cmdk-list-sizer":""},e)))}),rg=f.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:i,contentClassName:s,container:o,...a}=e;return f.createElement(B,{open:n,onOpenChange:r},f.createElement(W,{container:o},f.createElement(K,{"cmdk-overlay":"",className:i}),f.createElement(X,{"aria-label":e.label,"cmdk-dialog":"",className:s},f.createElement(rd,{ref:t,...a}))))}),rb=Object.assign(rd,{List:rm,Item:ru,Input:rf,Group:rp,Separator:rh,Dialog:rg,Empty:f.forwardRef((e,t)=>rw(e=>0===e.filtered.count)?f.createElement(tv.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),Loading:f.forwardRef((e,t)=>{let{progress:n,children:r,label:i="Loading...",...s}=e;return f.createElement(tv.div,{ref:t,...s,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},rS(e,e=>f.createElement("div",{"aria-hidden":!0},e)))})});function rx(e){let t=f.useRef(e);return ry(()=>{t.current=e}),t}var ry="u"<typeof window?f.useEffect:f.useLayoutEffect;function rv(e){let t=f.useRef();return void 0===t.current&&(t.current=e()),t}function rw(e){let t=f.useContext(rl),n=()=>e(t.snapshot());return f.useSyncExternalStore(t.subscribe,n,n)}function rk(e,t,n,r=[]){let i=f.useRef(),s=f.useContext(ra);return ry(()=>{var o;let a=(()=>{var e;for(let t of n){if("string"==typeof t)return t.trim();if("object"==typeof t&&"current"in t)return t.current?null==(e=t.current.textContent)?void 0:e.trim():i.current}})(),l=r.map(e=>e.trim());s.value(e,a,l),null==(o=t.current)||o.setAttribute(rs,a),i.current=a}),i}var rN=()=>{let[e,t]=f.useState(),n=rv(()=>new Map);return ry(()=>{n.current.forEach(e=>e()),n.current=new Map},[e]),(e,r)=>{n.current.set(e,r),t({})}};function rS({asChild:e,children:t},n){let r;return e&&f.isValidElement(t)?f.cloneElement("function"==typeof(r=t.type)?r(t.props):"render"in r?r.render(t.props):t,{ref:t.ref},n(t.props.children)):n(t)}var rC={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};let rj=(0,o.default)("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]),rE=f.forwardRef(({className:e,...t},n)=>(0,s.jsx)(rb,{ref:n,className:(0,eh.cn)("flex h-full w-full flex-col overflow-hidden rounded-sm bg-popover text-popover-foreground",e),...t}));function rM({children:e,shouldFilter:t,...n}){return(0,s.jsx)(B,{...n,children:(0,s.jsxs)(eJ,{className:"overflow-hidden p-0 shadow-golden max-w-lg",children:[(0,s.jsx)(eY,{className:"sr-only",children:"Search"}),(0,s.jsx)(rE,{shouldFilter:t,className:"[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-normal [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5",children:e})]})})}rE.displayName=rb.displayName;let rA=f.forwardRef(({className:e,...t},n)=>(0,s.jsxs)("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[(0,s.jsx)(rj,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),(0,s.jsx)(rb.Input,{ref:n,className:(0,eh.cn)("flex h-11 w-full rounded-sm bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",e),...t})]}));rA.displayName=rb.Input.displayName;let rT=f.forwardRef(({className:e,...t},n)=>(0,s.jsx)(rb.List,{ref:n,className:(0,eh.cn)("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));rT.displayName=rb.List.displayName;let rO=f.forwardRef((e,t)=>(0,s.jsx)(rb.Empty,{ref:t,className:"py-6 text-center text-sm text-muted-foreground",...e}));rO.displayName=rb.Empty.displayName;let r_=f.forwardRef(({className:e,...t},n)=>(0,s.jsx)(rb.Group,{ref:n,className:(0,eh.cn)("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-normal [&_[cmdk-group-heading]]:text-muted-foreground",e),...t}));r_.displayName=rb.Group.displayName;let rD=f.forwardRef(({className:e,...t},n)=>(0,s.jsx)(rb.Separator,{ref:n,className:(0,eh.cn)("-mx-1 h-px bg-border",e),...t}));rD.displayName=rb.Separator.displayName;let rR=f.forwardRef(({className:e,...t},n)=>(0,s.jsx)(rb.Item,{ref:n,className:(0,eh.cn)("relative flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",e),...t}));rR.displayName=rb.Item.displayName;let rI=null,rL=null,rP=(0,eN.create)(e=>({query:"",results:[],loading:!1,truncated:!1,open:!1,setQuery:t=>e({query:t}),setOpen:t=>e({open:t}),clear:()=>{rL&&clearTimeout(rL),rI?.abort(),e({query:"",results:[],loading:!1,truncated:!1})},search:t=>(rL&&clearTimeout(rL),t.trim())?(e({loading:!0}),new Promise(n=>{rL=setTimeout(()=>{rz(e,t).finally(n)},150)})):(rI?.abort(),e({results:[],loading:!1,truncated:!1}),Promise.resolve())}));async function rz(e,t){rI?.abort();let n=new AbortController;rI=n;try{let r=await (0,tC.wsFetch)("/api/wiki/search",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:t,limit:30}),signal:n.signal});if(!r.ok)return void e({results:[],loading:!1,truncated:!1});let i=await r.json();if(n.signal.aborted)return;e({results:i.matches??[],truncated:!!i.truncated,loading:!1})}catch(t){"AbortError"!==t.name&&e({loading:!1})}}var r$=e.i(395624);function rB({html:e}){let t=function(e){let t,n=[],r=/<mark>([\s\S]*?)<\/mark>/g,i=0;for(;null!==(t=r.exec(e));)t.index>i&&n.push({text:e.slice(i,t.index),mark:!1}),n.push({text:t[1]??"",mark:!0}),i=t.index+t[0].length;return i<e.length&&n.push({text:e.slice(i),mark:!1}),n}(e);return(0,s.jsx)(s.Fragment,{children:t.map((e,t)=>e.mark?(0,s.jsx)("mark",{className:"bg-yellow-200 dark:bg-yellow-700 rounded-[2px] px-[1px]",children:e.text},t):(0,s.jsx)("span",{children:e.text},t))})}function rF({onOpenFile:e,recents:t=[],onToggleSidebar:n=()=>void 0,onNewFile:r=()=>void 0,onCopyPath:i=()=>void 0}){let o=rP(e=>e.open),l=rP(e=>e.setOpen),c=rP(e=>e.query),d=rP(e=>e.setQuery),u=rP(e=>e.results),p=rP(e=>e.loading),h=rP(e=>e.truncated),m=rP(e=>e.search),{resolvedTheme:g,setTheme:b}=(0,n5.useTheme)(),x=tA(e=>e.toggle),y=(0,r$.useViewWidthStore)(e=>e.width),v=(0,r$.useViewWidthStore)(e=>e.cycle),w=c.trimStart(),k=""===w||w.startsWith(">"),N=""===w&&t.length>0,S=k?"":c;function C(e){e(),l(!1),d("")}(0,f.useEffect)(()=>{function e(e){(e.metaKey||e.ctrlKey)&&"k"===e.key.toLowerCase()&&(e.preventDefault(),l(!o))}return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[o,l]),(0,f.useEffect)(()=>{if(!o||k)return;let e=setTimeout(()=>{m(S)},120);return()=>clearTimeout(e)},[S,k,o,m]);let j=(r$.VIEW_WIDTH_ORDER.indexOf(y)+1)%r$.VIEW_WIDTH_ORDER.length,E=r$.VIEW_WIDTH_LABEL[r$.VIEW_WIDTH_ORDER[j]];return(0,s.jsxs)(rM,{open:o,onOpenChange:e=>{l(e),e||d("")},shouldFilter:!1,children:[(0,s.jsx)(rA,{placeholder:"Search files… ( > for actions )",value:c,onValueChange:d}),(0,s.jsxs)(rT,{children:[N&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(r_,{heading:"Recent",children:t.map(t=>(0,s.jsxs)(rR,{value:`recent:${t.path}`,onSelect:()=>{e(t.path),l(!1),d("")},children:[(0,s.jsx)(ti,{className:"mr-2 h-4 w-4"}),(0,s.jsxs)("div",{className:"flex min-w-0 flex-col gap-0.5",children:[(0,s.jsx)("span",{className:"truncate font-medium",children:t.name}),(0,s.jsx)("span",{className:"truncate text-xs text-muted-foreground",children:t.path})]})]},t.path))}),(0,s.jsx)(rD,{})]}),k&&(0,s.jsxs)(r_,{heading:"Actions",children:[(0,s.jsxs)(rR,{value:"toggle-dark-mode",onSelect:()=>C(()=>b("dark"===g?"light":"dark")),children:["dark"===g?(0,s.jsx)(n3.Sun,{className:"mr-2 h-4 w-4"}):(0,s.jsx)(n1.Moon,{className:"mr-2 h-4 w-4"}),"dark"===g?"Switch to light mode":"Switch to dark mode"]}),(0,s.jsxs)(rR,{value:"toggle-ai-panel",onSelect:()=>C(x),children:[(0,s.jsx)(a,{className:"mr-2 h-4 w-4"}),"Toggle AI panel"]}),(0,s.jsxs)(rR,{value:"toggle-sidebar",onSelect:()=>C(n),children:[(0,s.jsx)(n2,{className:"mr-2 h-4 w-4"}),"Toggle sidebar"]}),(0,s.jsxs)(rR,{value:"new-file",onSelect:()=>C(r),children:[(0,s.jsx)(nn,{className:"mr-2 h-4 w-4"}),"New file"]}),(0,s.jsxs)(rR,{value:"copy-path",onSelect:()=>C(i),children:[(0,s.jsx)(tt.Copy,{className:"mr-2 h-4 w-4"}),"Copy current file path"]}),(0,s.jsxs)(rR,{value:"cycle-view-width",onSelect:()=>C(v),children:[(0,s.jsx)(n0,{className:"mr-2 h-4 w-4"}),(0,s.jsxs)("span",{children:["Change view width"," ",(0,s.jsxs)("span",{className:"text-muted-foreground",children:["(",r$.VIEW_WIDTH_LABEL[y]," → ",E,")"]})]})]})]}),!k&&(0,s.jsxs)(s.Fragment,{children:[p&&(0,s.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:"Searching…"}),!p&&""!==S.trim()&&0===u.length&&(0,s.jsx)(rO,{children:"No matches."}),u.length>0&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(rD,{}),(0,s.jsx)(r_,{heading:h?"Top results (refine query for more)":"Results",children:u.map(t=>(0,s.jsx)(rR,{value:t.path,onSelect:()=>{e(t.path),l(!1),d("")},children:(0,s.jsxs)("div",{className:"flex min-w-0 flex-col gap-0.5",children:[(0,s.jsx)("span",{className:"truncate text-xs",children:t.path}),t.snippet&&(0,s.jsx)("span",{className:"truncate text-xs text-muted-foreground",children:(0,s.jsx)(rB,{html:t.snippet})})]})},t.path))})]})]})]})]})}e.i(335884);let rH=(0,o.default)("cloud-download",[["path",{d:"M12 13v8l-4-4",key:"1f5nwf"}],["path",{d:"m12 21 4-4",key:"1lfcce"}],["path",{d:"M4.393 15.269A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.436 8.284",key:"ui1hmy"}]]);var rU=e.i(301138);let rV=(0,o.default)("eye-off",[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]),rW=(0,o.default)("history",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]),rq=(0,o.default)("panel-left-close",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]]),rK=(0,o.default)("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]),rG=(0,o.default)("settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);var rJ=e.i(109680);function rZ({onOpenFile:e}){let t=rP(e=>e.query),n=rP(e=>e.setQuery),r=rP(e=>e.results),i=rP(e=>e.loading),o=rP(e=>e.search),a=rP(e=>e.clear),[l,c]=(0,f.useState)(0),d=(0,f.useRef)(null);function u(t){let n=r[t];n&&(e(n.path),a())}return(0,f.useEffect)(()=>{c(0)},[r]),(0,f.useEffect)(()=>{let e=d.current?.querySelector(`[data-idx="${l}"]`);e?.scrollIntoView({block:"nearest"})},[l]),(0,s.jsxs)("div",{className:"flex flex-col gap-1 px-2 py-1.5",children:[(0,s.jsxs)("div",{className:"relative",children:[(0,s.jsx)(rj,{className:"pointer-events-none absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 opacity-50"}),(0,s.jsx)("input",{type:"text",className:"w-full rounded-sm bg-muted py-1 pl-7 pr-2 text-xs outline-none focus:ring-1 focus:ring-ring",placeholder:"Search… (⌘K)",value:t,onChange:e=>{n(e.target.value),o(e.target.value)},onKeyDown:e=>{"Escape"===e.key?a():0!==r.length&&("ArrowDown"===e.key?(e.preventDefault(),c(e=>(e+1)%r.length)):"ArrowUp"===e.key?(e.preventDefault(),c(e=>(e-1+r.length)%r.length)):"Enter"===e.key&&(e.preventDefault(),u(l)))}})]}),""!==t.trim()&&(0,s.jsxs)("div",{ref:d,className:"max-h-64 overflow-y-auto rounded-sm border bg-popover",children:[i&&(0,s.jsx)("div",{className:"px-2 py-1 text-xs text-muted-foreground",children:"Searching…"}),!i&&0===r.length&&(0,s.jsx)("div",{className:"px-2 py-1 text-xs text-muted-foreground",children:"No matches"}),r.map((e,t)=>(0,s.jsxs)("button",{type:"button","data-idx":t,onClick:()=>u(t),onMouseEnter:()=>c(t),className:`block w-full px-2 py-1 text-left ${t===l?"bg-accent":"hover:bg-accent"}`,children:[(0,s.jsx)("div",{className:"truncate text-xs",children:e.path}),e.snippet&&(0,s.jsx)("div",{className:"truncate text-[10px] text-muted-foreground",children:(0,s.jsx)(rB,{html:e.snippet})})]},e.path))]})]})}var rX=e.i(515288);function rY(e){let t=new Date(e).getTime();if(!Number.isFinite(t))return"";let n=Math.floor(Math.max(0,Date.now()-t)/1e3);if(n<60)return"just now";let r=Math.floor(n/60);if(r<60)return`${r}m ago`;let i=Math.floor(r/60);return i<24?`${i}h ago`:`${Math.floor(i/24)}d ago`}function rQ({workspaces:e,activeWorkspaceId:t,rootPath:n,isWsAdmin:r,refreshingWsId:i,switchingBranch:o,switchingBranchName:a,wsBranches:l,branchPickerWsId:c,wsBranchPos:d,onSwitchWorkspace:u,onRefreshWorkspace:p,onPromptDeleteWorkspace:h,onAddWorkspace:f,setBranchPickerWsId:m,setWsBranchPos:x,loadWsBranches:y,handleSwitchBranch:w}){return(0,s.jsxs)("div",{className:"border-t px-2 py-2 bg-muted shrink-0",children:[(0,s.jsxs)(ek.DropdownMenu,{modal:!1,onOpenChange:e=>{e||(m(null),x(null))},children:[(0,s.jsx)(ek.DropdownMenuTrigger,{asChild:!0,children:(0,s.jsxs)(v.Button,{size:"sm",variant:"ghost",className:"w-full h-auto justify-between gap-2 px-2 py-1.5 text-left",title:n??"",children:[(0,s.jsxs)("span",{className:"flex flex-col min-w-0",children:[(0,s.jsx)("span",{className:"truncate text-xs font-medium",children:e.find(e=>e.id===t)?.name??"Workspace"}),(0,s.jsx)("span",{className:"truncate text-[10px] text-muted-foreground",children:n??""})]}),(0,s.jsx)(b,{className:"h-3.5 w-3.5 shrink-0 opacity-60"})]})}),(0,s.jsxs)(ek.DropdownMenuContent,{align:"start",className:"w-[var(--radix-dropdown-menu-trigger-width)]",onInteractOutside:e=>{e.target?.closest?.("[data-branch-portal]")&&e.preventDefault()},children:[e.map(e=>(0,s.jsxs)(ek.DropdownMenuItem,{onClick:()=>void u(e.id),onPointerMove:e=>e.preventDefault(),onPointerLeave:e=>e.preventDefault(),className:(0,eh.cn)("gap-2",e.id===t&&"font-medium"),children:[e.id===t?(0,s.jsx)(g.Check,{className:"h-3.5 w-3.5 shrink-0"}):(0,s.jsx)("span",{className:"w-3.5 shrink-0"}),(0,s.jsxs)("span",{className:"flex flex-col min-w-0 flex-1",children:[(0,s.jsxs)("span",{className:"flex items-center gap-1.5 truncate",children:[(0,s.jsx)("span",{className:"truncate",children:e.name}),e.git?r?(0,s.jsxs)("button",{"data-branch-trigger":!0,type:"button",className:"inline-flex items-center gap-0.5 rounded bg-muted px-1.5 text-[10px] text-muted-foreground font-normal shrink-0 hover:bg-accent",title:"Switch branch",disabled:o===e.id,onClick:t=>{if(t.stopPropagation(),t.preventDefault(),c===e.id){m(null),x(null);return}let n=t.currentTarget.getBoundingClientRect();x({top:n.bottom+4,left:n.left}),m(e.id),y(e.id)},children:[(0,s.jsx)(e5,{className:"h-2.5 w-2.5"})," ",e.git.branch??"branch"]}):(0,s.jsxs)("span",{className:"inline-flex items-center gap-0.5 rounded bg-muted px-1.5 text-[10px] text-muted-foreground font-normal shrink-0",children:[(0,s.jsx)(e5,{className:"h-2.5 w-2.5"})," ",e.git.branch??"read-only"]}):e.ssh?(0,s.jsxs)("span",{className:"inline-flex items-center gap-0.5 rounded bg-muted px-1.5 text-[10px] text-muted-foreground font-normal shrink-0",children:[(0,s.jsx)(e6,{className:"h-2.5 w-2.5"})," ",e.ssh.host]}):e.readOnly?(0,s.jsxs)("span",{className:"inline-flex items-center gap-0.5 rounded bg-muted px-1.5 text-[10px] text-muted-foreground font-normal shrink-0",children:[(0,s.jsx)(e5,{className:"h-2.5 w-2.5"})," read-only"]}):null]}),(0,s.jsx)("span",{className:"truncate text-[10px] text-muted-foreground",children:e.rootDir}),e.git?.lastPulledAt&&rY(e.git.lastPulledAt)&&(0,s.jsxs)("span",{className:"text-[10px] text-muted-foreground/70",children:["synced ",rY(e.git.lastPulledAt)]})]}),r&&e.git&&(0,s.jsx)("button",{className:(0,eh.cn)("shrink-0 rounded p-0.5 hover:bg-accent transition-colors",e.git.lastError?"text-destructive":"text-muted-foreground hover:text-foreground"),title:e.git.lastError?`Last refresh failed: ${e.git.lastError}`:"Refresh",disabled:i===e.id,onClick:t=>{t.stopPropagation(),t.preventDefault(),p(e.id)},children:(0,s.jsx)(t_,{className:(0,eh.cn)("h-3.5 w-3.5",i===e.id&&"animate-spin")})}),r&&(0,s.jsx)("button",{className:"shrink-0 rounded p-0.5 text-muted-foreground hover:text-destructive hover:bg-destructive/10 transition-colors",title:"Delete workspace (does not delete files)",onClick:t=>{t.stopPropagation(),h(e.id)},children:(0,s.jsx)(tr,{className:"h-3.5 w-3.5"})})]},e.id)),r&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(ek.DropdownMenuSeparator,{}),(0,s.jsxs)(ek.DropdownMenuItem,{onClick:f,children:[(0,s.jsx)(nr,{className:"mr-2 h-3.5 w-3.5"}),"Add workspace…"]})]})]})]}),(()=>{if(!c||!d)return null;let t=e.find(e=>e.id===c);return t?(0,s.jsx)(no,{pos:d,branches:(l[t.id]??[]).map(e=>({name:e,current:e===t.git?.branch})),loading:!l[t.id],busyName:o===t.id?a:null,disabled:o===t.id,onPick:e=>{w(t.id,e)},onClose:()=>{m(null),x(null)}}):null})()]})}let r0="wiki-sidebar-width";function r1(e){return Number.isNaN(e)?288:Math.min(600,Math.max(200,Math.round(e)))}let r2=(0,eN.create)(e=>({width:function(){let e=localStorage.getItem(r0);if(e){let t=Number.parseInt(e,10);if(!Number.isNaN(t))return r1(t)}return 288}(),setWidth:t=>{let n=r1(t);localStorage.setItem(r0,String(n)),e({width:n})}}));function r3(e){return e.split("/").pop()??e}function r5({workspace:e,doc:t,fileTree:n,upload:r,isMobile:i,hideChrome:o,sidebarCollapsed:c,setSidebarCollapsed:d,sidebarResizing:p,setSidebarResizing:f,sidebarWidth:x,setSidebarWidth:y,collapsed:w,setCollapsed:k,createEntry:N,setCreateEntry:S,handleCreateFile:C,handleCreateFolder:j,dragOverPath:E,setDragOverPath:M,handleDragOver:A,handleDropOnFolder:T,sidebarScrollRef:O,treeCtx:_,favorites:D,recents:R,activePaths:I,setDialogs:L,handleRefreshWorkspace:P}){let{resolvedTheme:z,setTheme:$}=(0,n5.useTheme)(),B=nI(e=>e.humanize),F=nP(e=>e.showHidden);return(0,s.jsxs)(s.Fragment,{children:[!o&&!c&&i&&(0,s.jsx)("div",{className:"fixed inset-0 z-40 bg-overlay backdrop-blur-[1px] md:hidden",onClick:()=>d(!0),"aria-hidden":!0}),!o&&!c&&(0,s.jsxs)(rX.Card,{style:i?void 0:{width:x},className:"fixed inset-y-0 left-0 z-50 w-[85vw] max-w-[20rem] md:relative md:z-auto md:w-auto md:max-w-none flex flex-col shrink-0 overflow-hidden rounded-none border-r border-l-0 border-t-0 border-b-0 bg-sidebar border-sidebar-border text-sidebar-foreground",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between gap-2 px-3 py-2 border-b bg-muted shrink-0",children:[(0,s.jsxs)("div",{className:"flex min-w-0 items-center gap-1.5",title:"Wiki Viewer v2.10.0",children:[(0,s.jsx)("img",{src:(0,ev.apiUrl)("/logo.svg"),alt:"Wiki Viewer",className:"h-5 w-5 shrink-0"}),(0,s.jsx)("span",{className:"truncate text-xs font-semibold leading-5 tracking-tight translate-y-[0.5px]",children:"Wiki Viewer"})]}),(0,s.jsx)(v.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0 shrink-0",title:"Collapse sidebar",onClick:()=>d(!0),children:(0,s.jsx)(rq,{className:"h-3.5 w-3.5"})})]}),(0,s.jsxs)("div",{className:"flex items-center justify-between gap-1 px-3 py-1.5 border-b bg-muted/50 shrink-0",children:[(0,s.jsxs)(ek.DropdownMenu,{children:[(0,s.jsx)(ek.DropdownMenuTrigger,{asChild:!0,children:(0,s.jsxs)(v.Button,{size:"sm",variant:"ghost",className:"h-7 gap-1 px-2 text-xs",disabled:r.uploading,children:[r.uploading?(0,s.jsx)(u.Loader2,{className:"h-3.5 w-3.5 animate-spin"}):(0,s.jsx)(rK,{className:"h-3.5 w-3.5"}),"New",(0,s.jsx)(b,{className:"h-3 w-3 opacity-60"})]})}),(0,s.jsxs)(ek.DropdownMenuContent,{align:"start",className:"w-44",children:[(0,s.jsxs)(ek.DropdownMenuItem,{onClick:()=>S(e=>({...e,file:{...e.file,parent:"",name:"",error:null}})),children:[(0,s.jsx)(nn,{className:"mr-2 h-3.5 w-3.5"}),"New file"]}),(0,s.jsxs)(ek.DropdownMenuItem,{onClick:()=>S(e=>({...e,folder:{...e.folder,parent:"",name:"",error:null}})),children:[(0,s.jsx)(nr,{className:"mr-2 h-3.5 w-3.5"}),"New folder"]}),(0,s.jsxs)(ek.DropdownMenuItem,{onClick:()=>r.triggerUpload(""),disabled:r.uploading,children:[(0,s.jsx)(ns,{className:"mr-2 h-3.5 w-3.5"}),"Upload"]})]})]}),(0,s.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,s.jsx)(v.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"Refresh tree",onClick:()=>void n.refreshTree(),disabled:n.refreshingTree,children:n.refreshingTree?(0,s.jsx)(u.Loader2,{className:"h-3.5 w-3.5 animate-spin"}):(0,s.jsx)(t_,{className:"h-3.5 w-3.5"})}),(0,s.jsx)(v.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"AI Agent panel",onClick:()=>{tA.getState().toggle(),i&&d(!0)},children:(0,s.jsx)(a,{className:"h-3.5 w-3.5"})}),(0,s.jsxs)(ek.DropdownMenu,{children:[(0,s.jsx)(ek.DropdownMenuTrigger,{asChild:!0,children:(0,s.jsx)(v.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"More actions",children:(0,s.jsx)(ne,{className:"h-3.5 w-3.5"})})}),(0,s.jsxs)(ek.DropdownMenuContent,{align:"end",className:"w-48",children:[e.isWsAdmin&&e.workspaces.find(t=>t.id===e.activeWorkspaceId)?.git&&(0,s.jsxs)(ek.DropdownMenuItem,{onClick:()=>{e.activeWorkspaceId&&P(e.activeWorkspaceId)},disabled:e.refreshingWsId===e.activeWorkspaceId,children:[e.refreshingWsId===e.activeWorkspaceId?(0,s.jsx)(u.Loader2,{className:"mr-2 h-3.5 w-3.5 animate-spin"}):(0,s.jsx)(rH,{className:"mr-2 h-3.5 w-3.5"}),"Pull latest"]}),(0,s.jsxs)(ek.DropdownMenuItem,{onClick:()=>nP.getState().toggle(),children:[F?(0,s.jsx)(rV,{className:"mr-2 h-3.5 w-3.5"}):(0,s.jsx)(rU.Eye,{className:"mr-2 h-3.5 w-3.5"}),F?"Hide hidden files":"Show hidden files"]}),(0,s.jsxs)(ek.DropdownMenuItem,{onClick:()=>nI.getState().toggle(),children:[(0,s.jsx)(rJ.Type,{className:"mr-2 h-3.5 w-3.5"}),B?"Raw file names":"Humanize names"]}),(0,s.jsxs)(ek.DropdownMenuItem,{onClick:()=>$("dark"===z?"light":"dark"),children:["dark"===z?(0,s.jsx)(n3.Sun,{className:"mr-2 h-3.5 w-3.5"}):(0,s.jsx)(n1.Moon,{className:"mr-2 h-3.5 w-3.5"}),"dark"===z?"Light mode":"Dark mode"]}),(0,s.jsx)(ek.DropdownMenuSeparator,{}),(0,s.jsxs)(ek.DropdownMenuItem,{onClick:()=>L(e=>({...e,settingsOpen:!0})),children:[(0,s.jsx)(rG,{className:"mr-2 h-3.5 w-3.5"}),"Settings"]})]})]})]})]}),r.uploadError&&(0,s.jsxs)("div",{className:"flex items-center gap-1.5 px-3 py-1.5 text-xs text-destructive bg-destructive/10 shrink-0",children:[(0,s.jsx)(m.AlertCircle,{className:"h-3.5 w-3.5 shrink-0"}),r.uploadError]}),""===N.folder.parent&&(0,s.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1 border-b shrink-0",children:[(0,s.jsx)(e2,{className:"h-4 w-4 shrink-0 text-warning"}),(0,s.jsx)("input",{className:"flex-1 bg-transparent text-sm outline-none border-b border-border min-w-0",placeholder:"Folder name",value:N.folder.name,onChange:e=>S(t=>({...t,folder:{...t.folder,name:e.target.value}})),onKeyDown:e=>{"Enter"===e.key&&j(),"Escape"===e.key&&S(e=>({...e,folder:{...e.folder,parent:null,name:""}}))}}),N.folder.error&&(0,s.jsx)("span",{className:"text-xs text-destructive",children:N.folder.error}),(0,s.jsx)(v.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:j,children:(0,s.jsx)(g.Check,{className:"h-3 w-3"})}),(0,s.jsx)(v.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:()=>S(e=>({...e,folder:{...e.folder,parent:null,name:""}})),children:(0,s.jsx)(h,{className:"h-3 w-3"})})]}),""===N.file.parent&&(0,s.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1 border-b shrink-0",children:[(0,s.jsx)(l.FileText,{className:"h-4 w-4 shrink-0 text-accent"}),(0,s.jsx)("input",{autoFocus:!0,className:"flex-1 bg-transparent text-sm outline-none border-b border-border min-w-0",placeholder:"filename (default .md)",value:N.file.name,onChange:e=>S(t=>({...t,file:{...t.file,name:e.target.value}})),onKeyDown:e=>{"Enter"===e.key&&C(),"Escape"===e.key&&S(e=>({...e,file:{...e.file,parent:null,name:""}}))}}),N.file.error&&(0,s.jsx)("span",{className:"text-xs text-destructive",children:N.file.error}),(0,s.jsx)(v.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:C,children:(0,s.jsx)(g.Check,{className:"h-3 w-3"})}),(0,s.jsx)(v.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:()=>S(e=>({...e,file:{...e.file,parent:null,name:""}})),children:(0,s.jsx)(h,{className:"h-3 w-3"})})]}),(0,s.jsx)("div",{className:"border-b",children:(0,s.jsx)(rZ,{onOpenFile:t.openFromSearch})}),(0,s.jsxs)("div",{ref:O,className:(0,eh.cn)("flex-1 overflow-auto py-1 ",""===E&&"ring-2 ring-inset ring-primary bg-primary/5"),onDragOver:e=>A(e,"","root"),onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||M(null)},onDrop:e=>T(e,""),children:[D.length>0&&(0,s.jsxs)("div",{className:"border-b mb-1",children:[(0,s.jsxs)("button",{type:"button",className:"flex w-full items-center gap-1 px-2 py-1 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground hover:text-foreground",onClick:()=>k(e=>({...e,favorites:!e.favorites})),children:[w.favorites?(0,s.jsx)(e1.ChevronRight,{className:"h-3 w-3"}):(0,s.jsx)(b,{className:"h-3 w-3"}),(0,s.jsx)(e7,{className:"h-3 w-3"}),"Favorites",(0,s.jsx)("span",{className:"ml-auto text-[9px] tabular-nums opacity-60",children:D.length})]}),!w.favorites&&D.map(n=>(0,s.jsxs)(nm,{children:[(0,s.jsx)(nb,{asChild:!0,children:(0,s.jsxs)("div",{role:"button",tabIndex:0,className:(0,eh.cn)("group flex items-center gap-1.5 rounded-sm px-2 py-1 text-sm cursor-pointer transition-colors select-none",t.openFile?.path===n.path?"bg-accent-soft text-foreground font-medium":"hover:bg-muted"),onClick:()=>{t.openFavoriteEntry(n)},onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&(e.preventDefault(),t.openFavoriteEntry(n))},children:[(0,s.jsx)(nK,{name:n.name,type:n.type??"file"}),(0,s.jsx)("span",{className:"min-w-0 flex-1 truncate text-xs",title:B?n.name:void 0,children:B?r3(n.name):n.name}),(0,s.jsx)("span",{className:"max-w-[80px] truncate text-[10px] text-muted-foreground/60",children:n.path.split("/").slice(0,-1).join("/")}),(0,s.jsx)("button",{type:"button",className:"hover-reveal shrink-0 rounded p-0.5 text-muted-foreground/50 opacity-0 transition-colors hover:bg-muted hover:text-amber-400 group-hover:opacity-100 focus:opacity-100",title:"Remove from favorites",onClick:t=>{t.stopPropagation(),nY.getState().toggle({path:n.path,name:n.name},e.activeWorkspaceId)},children:(0,s.jsx)(h,{className:"h-3 w-3"})})]})}),(0,s.jsx)(nq,{node:{path:n.path,name:n.name,type:n.type??"file"},ctx:_,isFavorited:!0,activeWorkspaceId:e.activeWorkspaceId})]},n.path))]}),R.length>0&&(0,s.jsxs)("div",{className:"border-b mb-1",children:[(0,s.jsxs)("button",{type:"button",className:"flex w-full items-center gap-1 px-2 py-1 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground hover:text-foreground",onClick:()=>k(e=>({...e,recent:!e.recent})),children:[w.recent?(0,s.jsx)(e1.ChevronRight,{className:"h-3 w-3"}):(0,s.jsx)(b,{className:"h-3 w-3"}),(0,s.jsx)(rW,{className:"h-3 w-3"}),"Recent",(0,s.jsx)("span",{className:"ml-auto text-[9px] tabular-nums opacity-60",children:R.length})]}),!w.recent&&R.slice(0,8).map(n=>(0,s.jsxs)(nm,{children:[(0,s.jsx)(nb,{asChild:!0,children:(0,s.jsxs)("div",{role:"button",tabIndex:0,className:(0,eh.cn)("flex items-center gap-1.5 rounded-sm px-2 py-1 text-sm cursor-pointer transition-colors select-none",t.openFile?.path===n.path?"bg-accent-soft text-foreground font-medium":"hover:bg-muted"),onClick:()=>{t.openViewer({path:n.path,name:n.name,type:n.type??"file",modifiedAt:""}),i&&d(!0)},onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&(e.preventDefault(),t.openViewer({path:n.path,name:n.name,type:n.type??"file",modifiedAt:""}))},children:[(0,s.jsx)(nK,{name:n.name,type:n.type??"file"}),(0,s.jsx)("span",{className:"flex-1 truncate text-xs",title:B?n.name:void 0,children:B?r3(n.name):n.name}),(0,s.jsx)("span",{className:"text-[10px] text-muted-foreground/60 truncate max-w-[80px]",children:n.path.split("/").slice(0,-1).join("/")})]})}),(0,s.jsx)(nq,{node:{path:n.path,name:n.name,type:n.type??"file"},ctx:_,isFavorited:D.some(e=>e.path===n.path),activeWorkspaceId:e.activeWorkspaceId})]},n.path))]}),n.rootLoading?(0,s.jsx)("div",{className:"flex justify-center py-6",children:(0,s.jsx)(u.Loader2,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):0===n.roots.length?(0,s.jsxs)("div",{className:"flex flex-col items-center gap-3 px-4 py-8 text-center",children:[(0,s.jsx)("div",{className:"rounded-full bg-muted p-3",children:(0,s.jsx)(l.FileText,{className:"h-6 w-6 text-muted-foreground"})}),(0,s.jsxs)("div",{className:"space-y-1",children:[(0,s.jsx)("p",{className:"text-sm font-medium",children:"No files yet"}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:"Upload files or add them to the configured directory"})]}),(0,s.jsxs)(v.Button,{size:"sm",variant:"outline",className:"w-full gap-1.5 max-w-[180px]",onClick:()=>r.triggerUpload(""),disabled:r.uploading,children:[r.uploading?(0,s.jsx)(u.Loader2,{className:"h-3.5 w-3.5 animate-spin"}):(0,s.jsx)(ns,{className:"h-3.5 w-3.5"}),"Upload Files"]})]}):(0,s.jsx)(nJ,{ctx:_,nodes:n.roots,openPath:t.openFile?.path??null,dragOverPath:E,branchDropdownNode:n.branchDropdownNode,branchDropdownPos:n.branchDropdownPos,nodeBranches:n.nodeBranches,branchesLoading:n.branchesLoading,checkingOutBranch:n.checkingOutBranch,pullingRepo:n.pullingRepo,activePaths:I,favorites:D,isMobile:i,activeWorkspaceId:e.activeWorkspaceId,newFileParent:N.file.parent,newFileName:N.file.name,fileCreateError:N.file.error,newFolderParent:N.folder.parent,newFolderName:N.folder.name,folderError:N.folder.error,sidebarScrollRef:O})]}),(0,s.jsx)(rQ,{workspaces:e.workspaces,activeWorkspaceId:e.activeWorkspaceId,rootPath:e.rootPath,isWsAdmin:e.isWsAdmin,refreshingWsId:e.refreshingWsId,switchingBranch:e.switchingBranch,switchingBranchName:e.switchingBranchName,wsBranches:e.wsBranches,branchPickerWsId:e.branchPickerWsId,wsBranchPos:e.wsBranchPos,onSwitchWorkspace:t=>void e.switchWorkspace(t),onRefreshWorkspace:e.handleRefreshWorkspace,onPromptDeleteWorkspace:t=>e.setDeletingWorkspaceId(t),onAddWorkspace:()=>e.setAddingWorkspace(!0),setBranchPickerWsId:e.setBranchPickerWsId,setWsBranchPos:e.setWsBranchPos,loadWsBranches:e.loadWsBranches,handleSwitchBranch:e.handleSwitchBranch}),(0,s.jsx)("div",{role:"separator","aria-orientation":"vertical","aria-label":"Resize sidebar",title:"Drag to resize",onMouseDown:e=>{e.preventDefault();let t=e.clientX;f(!0);let n=document.body.style.cursor,r=document.body.style.userSelect;document.body.style.cursor="col-resize",document.body.style.userSelect="none";let i=e=>{y(x+(e.clientX-t))},s=()=>{f(!1),document.body.style.cursor=n,document.body.style.userSelect=r,window.removeEventListener("mousemove",i),window.removeEventListener("mouseup",s)};window.addEventListener("mousemove",i),window.addEventListener("mouseup",s)},onDoubleClick:()=>y(288),onKeyDown:e=>{"ArrowLeft"===e.key?(e.preventDefault(),y(x-16)):"ArrowRight"===e.key&&(e.preventDefault(),y(x+16))},tabIndex:0,"aria-valuemin":200,"aria-valuemax":600,"aria-valuenow":x,className:(0,eh.cn)("absolute right-0 top-0 z-20 h-full w-1.5 cursor-col-resize -mr-px transition-colors hover:bg-primary/40 focus:bg-primary/40 focus:outline-none hidden md:block",p&&"bg-primary/60")})]})]})}function r4({workspace:e,doc:t,fileTree:n,upload:r,isMobile:i,hideChrome:o,sidebarCollapsed:a,setSidebarCollapsed:l,favorites:c,recents:d,activePaths:u,setDeleting:p,setDialogs:h}){let[m,g]=(0,f.useState)(!1),[b,x]=(0,f.useState)(null),[y,v]=(0,f.useState)({favorites:!1,recent:!0}),[w,k]=(0,f.useState)({file:{parent:null,name:"",error:null},folder:{parent:null,name:"",error:null}}),N=(0,f.useRef)(null),S=(0,f.useRef)(null),C=r2(e=>e.width),j=r2(e=>e.setWidth),E=(0,f.useCallback)(async()=>{let e=w.file.name.trim();if(!e||null===w.file.parent)return;k(e=>({...e,file:{...e.file,error:null}}));let r=e.includes(".")?e:`${e}.md`,i=w.file.parent?`${w.file.parent}/${r}`:r,s=await fetch((0,tC.withWs)("/api/wiki/new-file"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:i})});if(s.ok){let e=w.file.parent;k(e=>({...e,file:{parent:null,name:"",error:null}})),await n.reloadDir(e),t.openViewer({path:i,name:r,type:"file",modifiedAt:new Date().toISOString()})}else{let e=await s.json();k(t=>({...t,file:{...t.file,error:e.error??"Failed"}}))}},[w.file.parent,w.file.name,n,t]),M=(0,f.useCallback)(async()=>{let e=w.folder.name.trim();if(!e||null===w.folder.parent)return;k(e=>({...e,folder:{...e.folder,error:null}}));let t=w.folder.parent?`${w.folder.parent}/${e}`:e,r=await fetch((0,tC.withWs)("/api/wiki/folder"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:t})});if(r.ok){let e=w.folder.parent;k(e=>({...e,folder:{parent:null,name:"",error:null}})),await n.reloadDir(e)}else{let e=await r.json();k(t=>({...t,folder:{...t.folder,error:e.error??"Failed"}}))}},[w.folder.parent,w.folder.name,n]);function A(e,t,n){e.preventDefault(),e.stopPropagation();let r=S.current;if(!r){Array.from(e.dataTransfer.types).includes("Files")&&(e.dataTransfer.dropEffect="copy",x("root"===n?"":t));return}r.path===t||t.startsWith(`${r.path}/`)||(e.dataTransfer.dropEffect="move",x("root"===n?"":t))}async function T(e,i){e.preventDefault(),e.stopPropagation(),x(null);let s=S.current;if(S.current=null,!s){e.dataTransfer.files.length>0&&await r.doUpload(e.dataTransfer.files,i);return}if(s.path===i||i.startsWith(`${s.path}/`))return;let o=i?`${i}/${s.name}`:s.name;if(o!==s.path&&(await fetch((0,tC.withWs)("/api/wiki/move"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({from:s.path,to:o})})).ok){let e=s.path.includes("/")?s.path.split("/").slice(0,-1).join("/"):"";await n.reloadDir(e),i!==e&&await n.reloadDir(i),t.openFile?.path===s.path&&t.openViewer({path:o,name:s.name,type:s.type,modifiedAt:s.modifiedAt})}}let O=(0,f.useRef)(null);O.current={toggleFolder:e=>void n.toggleFolder(e),openViewer:e=>void t.openViewer(e),copyPath:e=>t.copyPath(e),copyWikiLink:e=>t.copyWikiLink(e),copyUrl:e=>t.copyUrl(e),copyRawContent:e=>void t.copyRawContent(e),copyFormattedContent:(e,n)=>void t.copyFormattedContent(e,n),handleDownload:function(e){let t=(0,tC.withWs)(`/api/wiki/download?path=${encodeURIComponent(e.path)}`),n=document.createElement("a");n.href=t,n.download="file"===e.type?e.name:`${e.name}.zip`,document.body.appendChild(n),n.click(),n.remove()},triggerUpload:e=>r.triggerUpload(e),handleCreateFile:E,handleCreateFolder:M,handleDragStart:function(e,t){S.current=t,e.dataTransfer.effectAllowed="move",e.dataTransfer.setData("text/plain",t.path)},handleDragOver:A,handleDropOnFolder:(e,t)=>void T(e,t),handleGitPull:(e,t)=>void n.handleGitPull(e,t),handleCheckout:(e,t,r)=>void n.handleCheckout(e,t,r),loadBranches:e=>void n.loadBranches(e),prefetch:e=>void n.prefetch(e),toggleFavorite:(e,t)=>nY.getState().toggle({path:e.path,name:e.name,type:e.type},t),setDragOverPath:x,setSidebarCollapsed:l,setBranchDropdownNode:e=>n.setBranchDropdownNode(e),setBranchDropdownPos:e=>n.setBranchDropdownPos(e),setNewFileParent:e=>k(t=>({...t,file:{...t.file,parent:e,error:null}})),setNewFileName:e=>k(t=>({...t,file:{...t.file,name:e}})),setFileCreateError:e=>k(t=>({...t,file:{...t.file,error:e}})),setNewFolderParent:e=>k(t=>({...t,folder:{...t.folder,parent:e,error:null}})),setNewFolderName:e=>k(t=>({...t,folder:{...t.folder,name:e}})),setFolderError:e=>k(t=>({...t,folder:{...t.folder,error:e}})),setDeletingPath:e=>p(t=>({...t,path:e})),setDeletingIsDir:e=>p(t=>({...t,isDir:e}))};let _=(0,f.useMemo)(()=>({toggleFolder:e=>O.current.toggleFolder(e),openViewer:e=>O.current.openViewer(e),copyPath:e=>O.current.copyPath(e),copyWikiLink:e=>O.current.copyWikiLink(e),copyUrl:e=>O.current.copyUrl(e),copyRawContent:e=>O.current.copyRawContent(e),copyFormattedContent:(e,t)=>O.current.copyFormattedContent(e,t),handleDownload:e=>O.current.handleDownload(e),triggerUpload:e=>O.current.triggerUpload(e),handleCreateFile:()=>O.current.handleCreateFile(),handleCreateFolder:()=>O.current.handleCreateFolder(),handleDragStart:(e,t)=>O.current.handleDragStart(e,t),handleDragOver:(e,t,n)=>O.current.handleDragOver(e,t,n),handleDropOnFolder:(e,t)=>O.current.handleDropOnFolder(e,t),handleGitPull:(e,t)=>O.current.handleGitPull(e,t),handleCheckout:(e,t,n)=>O.current.handleCheckout(e,t,n),loadBranches:e=>O.current.loadBranches(e),prefetch:e=>O.current.prefetch(e),toggleFavorite:(e,t)=>O.current.toggleFavorite(e,t),setDragOverPath:e=>O.current.setDragOverPath(e),setSidebarCollapsed:e=>O.current.setSidebarCollapsed(e),setBranchDropdownNode:e=>O.current.setBranchDropdownNode(e),setBranchDropdownPos:e=>O.current.setBranchDropdownPos(e),setNewFileParent:e=>O.current.setNewFileParent(e),setNewFileName:e=>O.current.setNewFileName(e),setFileCreateError:e=>O.current.setFileCreateError(e),setNewFolderParent:e=>O.current.setNewFolderParent(e),setNewFolderName:e=>O.current.setNewFolderName(e),setFolderError:e=>O.current.setFolderError(e),setDeletingPath:e=>O.current.setDeletingPath(e),setDeletingIsDir:e=>O.current.setDeletingIsDir(e)}),[]);return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(rF,{onOpenFile:t.openFromSearch,recents:d,onToggleSidebar:()=>l(e=>{let t=!e;return i&&!1===t&&tA.getState().close(),t}),onNewFile:()=>k(e=>({...e,file:{...e.file,parent:""}})),onCopyPath:()=>{t.openFile&&t.copyPath(t.openFile.path)}}),(0,s.jsx)(r5,{workspace:e,doc:t,fileTree:n,upload:r,isMobile:i,hideChrome:o,sidebarCollapsed:a,setSidebarCollapsed:l,sidebarResizing:m,setSidebarResizing:g,sidebarWidth:C,setSidebarWidth:j,collapsed:y,setCollapsed:v,createEntry:w,setCreateEntry:k,handleCreateFile:E,handleCreateFolder:M,dragOverPath:b,setDragOverPath:x,handleDragOver:A,handleDropOnFolder:T,sidebarScrollRef:N,treeCtx:_,favorites:c,recents:d,activePaths:u,setDialogs:h,handleRefreshWorkspace:e.handleRefreshWorkspace})]})}let r6=(0,o.default)("code-xml",[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]]),r9=(0,o.default)("maximize-2",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]]),r7=(0,o.default)("pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]),r8=(0,o.default)("share",[["path",{d:"M12 2v13",key:"1km8f5"}],["path",{d:"m16 6-4-4-4 4",key:"13yo43"}],["path",{d:"M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8",key:"1b2hhj"}]]),ie=(0,o.default)("user",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]);var it=e.i(75470),ir=e.i(801273),ii=e.i(61086);function is(e){let t=[],n="",r=!1,i=[];for(let s=0;s<e.length;s++){let o=e[s],a=e[s+1];r?'"'===o&&'"'===a?(n+='"',s++):'"'===o?r=!1:n+=o:'"'===o?r=!0:","===o?(i.push(n),n=""):"\n"===o||"\r"===o&&"\n"===a?(i.push(n),n="",i.length>0&&t.push(i),i=[],"\r"===o&&s++):n+=o}return i.push(n),i.some(e=>""!==e)&&t.push(i),t}function io(e){return e.map(e=>e.map(e=>e.includes(",")||e.includes('"')||e.includes("\n")?`"${e.replace(/"/g,'""')}"`:e).join(",")).join("\n")}function ia({path:e}){let[t,n]=(0,f.useState)([]),[r,i]=(0,f.useState)(""),[o,a]=(0,f.useState)(!1),[l,c]=(0,f.useState)(!1),[d,u]=(0,f.useState)(!1),[p,h]=(0,f.useState)(null),[m,g]=(0,f.useState)(!1),[b,x]=(0,f.useState)(1e3),y=(0,tC.withWs)(`/api/assets/${e}`);(0,f.useEffect)(()=>{fetch(y).then(e=>e.text()).then(e=>{let t=is(e),r=e.length>2097152||t.length>2e3;i(e),n(t),g(r),a(r),c(!1)})},[y]);let w=(0,f.useCallback)((e,t,r)=>{n(n=>{let i=n.map(e=>[...e]);for(;i.length<=e;)i.push([]);for(;i[e].length<=t;)i[e].push("");return i[e][t]=r,i}),c(!0)},[]),k=async()=>{u(!0);let s=o?r:io(t);try{await (0,tC.wsFetch)(`/api/assets/${e}`,{method:"PUT",headers:{"Content-Type":"text/plain"},body:s}),o?n(is(r)):i(s),c(!1)}catch(e){console.error("Failed to save CSV:",e)}u(!1)},N=t[0]||[],S=t.slice(1),C=m?S.slice(0,b):S,j=m&&b<S.length;return(0,s.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,s.jsxs)(ii.ViewerToolbar,{path:e,badge:`CSV${t.length>0?` (${t.length-1} rows)`:""}`,children:[l&&(0,s.jsxs)(v.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:k,disabled:d,children:[(0,s.jsx)(ir.Save,{className:"h-3.5 w-3.5"}),d?"Saving...":"Save"]}),m&&(0,s.jsxs)("span",{className:"text-[11px] text-amber-600 dark:text-amber-400 px-1",children:["Large file (",(r.length/1048576).toFixed(1)," MB,"," ",t.length.toLocaleString()," rows)"]}),(0,s.jsxs)("button",{onClick:()=>{o?n(is(r)):i(io(t)),a(!o)},className:`flex items-center gap-1.5 px-2.5 py-1 text-[11px] rounded-md transition-colors border border-border ${o?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-accent"}`,children:[(0,s.jsx)(r6,{className:"h-3 w-3"}),o?"Table":"Source"]}),(0,s.jsx)("button",{onClick:()=>window.open(y,"_blank"),className:"inline-flex items-center justify-center rounded-md h-8 w-8 hover:bg-accent hover:text-accent-foreground transition-colors cursor-pointer",title:"Download CSV",children:(0,s.jsx)(t7.Download,{className:"h-4 w-4"})})]}),o?(0,s.jsx)("div",{className:"flex-1 overflow-y-auto p-4",children:(0,s.jsx)("textarea",{value:r,onChange:e=>{i(e.target.value),c(!0)},className:"w-full h-full min-h-[calc(100vh-12rem)] bg-transparent font-mono text-[13px] leading-relaxed resize-none focus:outline-none",spellCheck:!1})}):(0,s.jsxs)("div",{className:"flex-1 overflow-auto",children:[(0,s.jsxs)("table",{className:"w-full border-collapse text-[13px]",children:[(0,s.jsx)("thead",{className:"sticky top-0 z-10",children:(0,s.jsxs)("tr",{className:"bg-muted/80 backdrop-blur-sm",children:[(0,s.jsx)("th",{className:"border border-border px-1 py-1 text-center text-[10px] text-muted-foreground w-8",children:"#"}),N.map((e,t)=>(0,s.jsx)("th",{className:"border border-border px-3 py-1.5 text-left font-medium text-foreground min-w-[100px]",children:p?.r===0&&p?.c===t?(0,s.jsx)("input",{autoFocus:!0,className:"w-full bg-transparent outline-none",value:e,onChange:e=>w(0,t,e.target.value),onBlur:()=>h(null),onKeyDown:e=>{("Enter"===e.key||"Escape"===e.key)&&h(null),"Tab"===e.key&&(e.preventDefault(),h({r:0,c:t+1<N.length?t+1:0}))}}):(0,s.jsx)("span",{className:"cursor-text",onDoubleClick:()=>h({r:0,c:t}),children:e||" "})},t))]})}),(0,s.jsx)("tbody",{children:C.map((e,t)=>{let r=t+1;return(0,s.jsxs)("tr",{className:"hover:bg-accent/30 transition-colors group",children:[(0,s.jsxs)("td",{className:"border border-border px-1 py-1 text-center text-[10px] text-muted-foreground/50",children:[(0,s.jsx)("span",{className:"group-hover:hidden",children:t+1}),(0,s.jsx)("button",{className:"hidden group-hover:inline text-destructive hover:text-destructive/80 text-[10px]",onClick:()=>{n(e=>e.filter((e,t)=>t!==r)),c(!0)},title:"Delete row",children:"×"})]}),N.map((t,n)=>{let i=e[n]??"",o=p?.r===r&&p?.c===n;return(0,s.jsx)("td",{className:"border border-border px-3 py-1.5",children:o?(0,s.jsx)("input",{autoFocus:!0,className:"w-full bg-transparent outline-none",value:i,onChange:e=>w(r,n,e.target.value),onBlur:()=>h(null),onKeyDown:e=>{"Escape"===e.key&&h(null),"Enter"===e.key&&h({r:r+1,c:n}),"Tab"===e.key&&(e.preventDefault(),e.shiftKey?h({r,c:Math.max(0,n-1)}):h({r:n+1>=N.length?r+1:r,c:n+1>=N.length?0:n+1}))}}):(0,s.jsx)("span",{className:"cursor-text",onDoubleClick:()=>h({r,c:n}),children:i||" "})},n)})]},t)})})]}),j&&(0,s.jsxs)("div",{className:"flex items-center gap-3 px-4 py-2 border-t border-border",children:[(0,s.jsxs)("button",{onClick:()=>x(e=>e+1e3),className:"text-[11px] text-foreground hover:bg-accent transition-colors px-2.5 py-1 rounded border border-border",children:["Show"," ",Math.min(1e3,S.length-b).toLocaleString()," ","more rows"]}),(0,s.jsxs)("span",{className:"text-[11px] text-muted-foreground",children:[b.toLocaleString()," /"," ",S.length.toLocaleString()," rows"]})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2 px-4 py-2 border-t border-border",children:[(0,s.jsx)("button",{onClick:()=>{let e=t[0]?.length||1;n(t=>[...t,Array(e).fill("")]),c(!0)},className:"text-[11px] text-muted-foreground hover:text-foreground transition-colors px-2 py-1 rounded hover:bg-accent",children:"+ Add row"}),(0,s.jsx)("button",{onClick:()=>{n(e=>e.map(e=>[...e,""])),c(!0)},className:"text-[11px] text-muted-foreground hover:text-foreground transition-colors px-2 py-1 rounded hover:bg-accent",children:"+ Add column"})]})]})]})}function il(e){this.content=e}il.prototype={constructor:il,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return -1},get:function(e){var t=this.find(e);return -1==t?void 0:this.content[t+1]},update:function(e,t,n){var r=n&&n!=e?this.remove(n):this,i=r.find(e),s=r.content.slice();return -1==i?s.push(n||e,t):(s[i+1]=t,n&&(s[i]=n)),new il(s)},remove:function(e){var t=this.find(e);if(-1==t)return this;var n=this.content.slice();return n.splice(t,2),new il(n)},addToStart:function(e,t){return new il([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new il(n)},addBefore:function(e,t,n){var r=this.remove(t),i=r.content.slice(),s=r.find(e);return i.splice(-1==s?i.length:s,0,t,n),new il(i)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){return(e=il.from(e)).size?new il(e.content.concat(this.subtract(e).content)):this},append:function(e){return(e=il.from(e)).size?new il(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=il.from(e);for(var n=0;n<e.content.length;n+=2)t=t.remove(e.content[n]);return t},toObject:function(){var e={};return this.forEach(function(t,n){e[t]=n}),e},get size(){return this.content.length>>1}},il.from=function(e){if(e instanceof il)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new il(t)};class ic{constructor(e,t){if(this.content=e,this.size=t||0,null==t)for(let t=0;t<e.length;t++)this.size+=e[t].nodeSize}nodesBetween(e,t,n,r=0,i){for(let s=0,o=0;o<t;s++){let a=this.content[s],l=o+a.nodeSize;if(l>e&&!1!==n(a,r+o,i||null,s)&&a.content.size){let i=o+1;a.nodesBetween(Math.max(0,e-i),Math.min(a.content.size,t-i),n,r+i)}o=l}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,r){let i="",s=!0;return this.nodesBetween(e,t,(o,a)=>{let l=o.isText?o.text.slice(Math.max(e,a)-a,t-a):o.isLeaf?r?"function"==typeof r?r(o):r:o.type.spec.leafText?o.type.spec.leafText(o):"":"";o.isBlock&&(o.isLeaf&&l||o.isTextblock)&&n&&(s?s=!1:i+=n),i+=l},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,n=e.firstChild,r=this.content.slice(),i=0;for(t.isText&&t.sameMarkup(n)&&(r[r.length-1]=t.withText(t.text+n.text),i=1);i<e.content.length;i++)r.push(e.content[i]);return new ic(r,this.size+e.size)}cut(e,t=this.size){if(0==e&&t==this.size)return this;let n=[],r=0;if(t>e)for(let i=0,s=0;s<t;i++){let o=this.content[i],a=s+o.nodeSize;a>e&&((s<e||a>t)&&(o=o.isText?o.cut(Math.max(0,e-s),Math.min(o.text.length,t-s)):o.cut(Math.max(0,e-s-1),Math.min(o.content.size,t-s-1))),n.push(o),r+=o.nodeSize),s=a}return new ic(n,r)}cutByIndex(e,t){return e==t?ic.empty:0==e&&t==this.content.length?this:new ic(this.content.slice(e,t))}replaceChild(e,t){let n=this.content[e];if(n==t)return this;let r=this.content.slice(),i=this.size+t.nodeSize-n.nodeSize;return r[e]=t,new ic(r,i)}addToStart(e){return new ic([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new ic(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,n=0;t<this.content.length;t++){let r=this.content[t];e(r,n,t),n+=r.nodeSize}}findDiffStart(e,t=0){return function e(t,n,r){for(let i=0;;i++){if(i==t.childCount||i==n.childCount)return t.childCount==n.childCount?null:r;let s=t.child(i),o=n.child(i);if(s==o){r+=s.nodeSize;continue}if(!s.sameMarkup(o))return r;if(s.isText&&s.text!=o.text){for(let e=0;s.text[e]==o.text[e];e++)r++;return r}if(s.content.size||o.content.size){let t=e(s.content,o.content,r+1);if(null!=t)return t}r+=s.nodeSize}}(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return function e(t,n,r,i){for(let s=t.childCount,o=n.childCount;;){if(0==s||0==o)return s==o?null:{a:r,b:i};let a=t.child(--s),l=n.child(--o),c=a.nodeSize;if(a==l){r-=c,i-=c;continue}if(!a.sameMarkup(l))return{a:r,b:i};if(a.isText&&a.text!=l.text){let e=0,t=Math.min(a.text.length,l.text.length);for(;e<t&&a.text[a.text.length-e-1]==l.text[l.text.length-e-1];)e++,r--,i--;return{a:r,b:i}}if(a.content.size||l.content.size){let t=e(a.content,l.content,r-1,i-1);if(t)return t}r-=c,i-=c}}(this,e,t,n)}findIndex(e){if(0==e)return iu(0,e);if(e==this.size)return iu(this.content.length,e);if(e>this.size||e<0)throw RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,n=0;;t++){let r=n+this.child(t).nodeSize;if(r>=e){if(r==e)return iu(t+1,r);return iu(t,n)}n=r}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return ic.empty;if(!Array.isArray(t))throw RangeError("Invalid input for Fragment.fromJSON");return ic.fromArray(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return ic.empty;let t,n=0;for(let r=0;r<e.length;r++){let i=e[r];n+=i.nodeSize,r&&i.isText&&e[r-1].sameMarkup(i)?(t||(t=e.slice(0,r)),t[t.length-1]=i.withText(t[t.length-1].text+i.text)):t&&t.push(i)}return new ic(t||e,n)}static from(e){if(!e)return ic.empty;if(e instanceof ic)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new ic([e],e.nodeSize);throw RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}ic.empty=new ic([],0);let id={index:0,offset:0};function iu(e,t){return id.index=e,id.offset=t,id}function ip(e,t){if(e===t)return!0;if(!(e&&"object"==typeof e)||!(t&&"object"==typeof t))return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!ip(e[n],t[n]))return!1}else{for(let n in e)if(!(n in t)||!ip(e[n],t[n]))return!1;for(let n in t)if(!(n in e))return!1}return!0}class ih{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(this.eq(i))return e;if(this.type.excludes(i.type))t||(t=e.slice(0,r));else{if(i.type.excludes(this.type))return e;!n&&i.type.rank>this.type.rank&&(t||(t=e.slice(0,r)),t.push(this),n=!0),t&&t.push(i)}}return t||(t=e.slice()),n||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&ip(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw RangeError("Invalid input for Mark.fromJSON");let n=e.marks[t.type];if(!n)throw RangeError(`There is no mark type ${t.type} in this schema`);let r=n.create(t.attrs);return n.checkAttrs(r.attrs),r}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&0==e.length)return ih.none;if(e instanceof ih)return[e];let t=e.slice();return t.sort((e,t)=>e.type.rank-t.type.rank),t}}ih.none=[];class im extends Error{}class ig{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let n=function e(t,n,r,i,s,o){let{index:a,offset:l}=t.findIndex(n),c=t.maybeChild(a);if(l==n||c.isText)return o&&i<=0&&s<=0&&!o.canReplace(a,a,r)?null:t.cut(0,n).append(r).append(t.cut(n));let d=e(c.content,n-l-1,r,0==a?i-1:0,a==t.childCount-1?s-1:0,c);return d&&t.replaceChild(a,c.copy(d))}(this.content,e+this.openStart,t,this.openStart+1,this.openEnd+1);return n&&new ig(n,this.openStart,this.openEnd)}removeBetween(e,t){return new ig(function e(t,n,r){let{index:i,offset:s}=t.findIndex(n),o=t.maybeChild(i),{index:a,offset:l}=t.findIndex(r);if(s==n||o.isText){if(l!=r&&!t.child(a).isText)throw RangeError("Removing non-flat range");return t.cut(0,n).append(t.cut(r))}if(i!=a)throw RangeError("Removing non-flat range");return t.replaceChild(i,o.copy(e(o.content,n-s-1,r-s-1)))}(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return ig.empty;let n=t.openStart||0,r=t.openEnd||0;if("number"!=typeof n||"number"!=typeof r)throw RangeError("Invalid input for Slice.fromJSON");return new ig(ic.fromJSON(e,t.content),n,r)}static maxOpen(e,t=!0){let n=0,r=0;for(let r=e.firstChild;r&&!r.isLeaf&&(t||!r.type.spec.isolating);r=r.firstChild)n++;for(let n=e.lastChild;n&&!n.isLeaf&&(t||!n.type.spec.isolating);n=n.lastChild)r++;return new ig(e,n,r)}}function ib(e,t){if(!t.type.compatibleContent(e.type))throw new im("Cannot join "+t.type.name+" onto "+e.type.name)}function ix(e,t,n){let r=e.node(n);return ib(r,t.node(n)),r}function iy(e,t){let n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function iv(e,t,n,r){let i=(t||e).node(n),s=0,o=t?t.index(n):i.childCount;e&&(s=e.index(n),e.depth>n?s++:e.textOffset&&(iy(e.nodeAfter,r),s++));for(let e=s;e<o;e++)iy(i.child(e),r);t&&t.depth==n&&t.textOffset&&iy(t.nodeBefore,r)}function iw(e,t){return e.type.checkContent(t),e.copy(t)}function ik(e,t,n){let r=[];return iv(null,e,n,r),e.depth>n&&iy(iw(ix(e,t,n+1),ik(e,t,n+1)),r),iv(t,null,n,r),new ic(r)}ig.empty=new ig(ic.empty,0,0);class iN{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return null==e?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[3*this.resolveDepth(e)]}index(e){return this.path[3*this.resolveDepth(e)+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e!=this.depth||this.textOffset?1:0)}start(e){return 0==(e=this.resolveDepth(e))?0:this.path[3*e-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(!(e=this.resolveDepth(e)))throw RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[3*e-1]}after(e){if(!(e=this.resolveDepth(e)))throw RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[3*e-1]+this.path[3*e].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],r=e.child(t);return n?e.child(t).cut(n):r}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):0==e?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[3*t],r=0==t?0:this.path[3*t-1]+1;for(let t=0;t<e;t++)r+=n.child(t).nodeSize;return r}marks(){let e=this.parent,t=this.index();if(0==e.content.size)return ih.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),r=e.maybeChild(t);if(!n){let e=n;n=r,r=e}let i=n.marks;for(var s=0;s<i.length;s++)!1!==i[s].type.spec.inclusive||r&&i[s].isInSet(r.marks)||(i=i[s--].removeFromSet(i));return i}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,r=e.parent.maybeChild(e.index());for(var i=0;i<n.length;i++)!1!==n[i].type.spec.inclusive||r&&n[i].isInSet(r.marks)||(n=n[i--].removeFromSet(n));return n}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new iE(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw RangeError("Position "+t+" out of range");let n=[],r=0,i=t;for(let t=e;;){let{index:e,offset:s}=t.content.findIndex(i),o=i-s;if(n.push(t,e,r+s),!o||(t=t.child(e)).isText)break;i=o-1,r+=s+1}return new iN(t,n,i)}static resolveCached(e,t){let n=ij.get(e);if(n)for(let e=0;e<n.elts.length;e++){let r=n.elts[e];if(r.pos==t)return r}else ij.set(e,n=new iS);let r=n.elts[n.i]=iN.resolve(e,t);return n.i=(n.i+1)%iC,r}}class iS{constructor(){this.elts=[],this.i=0}}let iC=12,ij=new WeakMap;class iE{constructor(e,t,n){this.$from=e,this.$to=t,this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}let iM=Object.create(null);class iA{constructor(e,t,n,r=ih.none){this.type=e,this.attrs=t,this.marks=r,this.content=n||ic.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,n,r=0){this.content.nodesBetween(e,t,n,r,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,n,r){return this.content.textBetween(e,t,n,r)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,n){return this.type==e&&ip(this.attrs,t||e.defaultAttrs||iM)&&ih.sameSet(this.marks,n||ih.none)}copy(e=null){return e==this.content?this:new iA(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new iA(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return 0==e&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,n=!1){if(e==t)return ig.empty;let r=this.resolve(e),i=this.resolve(t),s=n?0:r.sharedDepth(t),o=r.start(s);return new ig(r.node(s).content.cut(r.pos-o,i.pos-o),r.depth-s,i.depth-s)}replace(e,t,n){var r=this.resolve(e),i=this.resolve(t);if(n.openStart>r.depth)throw new im("Inserted content deeper than insertion position");if(r.depth-n.openStart!=i.depth-n.openEnd)throw new im("Inconsistent open depths");return function e(t,n,r,i){let s=t.index(i),o=t.node(i);if(s==n.index(i)&&i<t.depth-r.openStart){let a=e(t,n,r,i+1);return o.copy(o.content.replaceChild(s,a))}if(!r.content.size)return iw(o,ik(t,n,i));if(r.openStart||r.openEnd||t.depth!=i||n.depth!=i){let{start:e,end:s}=function(e,t){let n=t.depth-e.openStart,r=t.node(n).copy(e.content);for(let e=n-1;e>=0;e--)r=t.node(e).copy(ic.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}(r,t);return iw(o,function e(t,n,r,i,s){let o=t.depth>s&&ix(t,n,s+1),a=i.depth>s&&ix(r,i,s+1),l=[];return iv(null,t,s,l),o&&a&&n.index(s)==r.index(s)?(ib(o,a),iy(iw(o,e(t,n,r,i,s+1)),l)):(o&&iy(iw(o,ik(t,n,s+1)),l),iv(n,r,s,l),a&&iy(iw(a,ik(r,i,s+1)),l)),iv(i,null,s,l),new ic(l)}(t,e,s,n,i))}{let e=t.parent,i=e.content;return iw(e,i.cut(0,t.parentOffset).append(r.content).append(i.cut(n.parentOffset)))}}(r,i,n,0)}nodeAt(e){for(let t=this;;){let{index:n,offset:r}=t.content.findIndex(e);if(!(t=t.maybeChild(n)))return null;if(r==e||t.isText)return t;e-=r+1}}childAfter(e){let{index:t,offset:n}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:n}}childBefore(e){if(0==e)return{node:null,index:0,offset:0};let{index:t,offset:n}=this.content.findIndex(e);if(n<e)return{node:this.content.child(t),index:t,offset:n};let r=this.content.child(t-1);return{node:r,index:t-1,offset:n-r.nodeSize}}resolve(e){return iN.resolveCached(this,e)}resolveNoCache(e){return iN.resolve(this,e)}rangeHasMark(e,t,n){let r=!1;return t>e&&this.nodesBetween(e,t,e=>(n.isInSet(e.marks)&&(r=!0),!r)),r}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),iO(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,n=ic.empty,r=0,i=n.childCount){let s=this.contentMatchAt(e).matchFragment(n,r,i),o=s&&s.matchFragment(this.content,t);if(!o||!o.validEnd)return!1;for(let e=r;e<i;e++)if(!this.type.allowsMarks(n.child(e).marks))return!1;return!0}canReplaceWith(e,t,n,r){if(r&&!this.type.allowsMarks(r))return!1;let i=this.contentMatchAt(e).matchType(n),s=i&&i.matchFragment(this.content,t);return!!s&&s.validEnd}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=ih.none;for(let t=0;t<this.marks.length;t++){let n=this.marks[t];n.type.checkAttrs(n.attrs),e=n.addToSet(e)}if(!ih.sameSet(e,this.marks))throw RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(e=>e.type.name)}`);this.content.forEach(e=>e.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(e=>e.toJSON())),e}static fromJSON(e,t){let n;if(!t)throw RangeError("Invalid input for Node.fromJSON");if(t.marks){if(!Array.isArray(t.marks))throw RangeError("Invalid mark data for Node.fromJSON");n=t.marks.map(e.markFromJSON)}if("text"==t.type){if("string"!=typeof t.text)throw RangeError("Invalid text node in JSON");return e.text(t.text,n)}let r=ic.fromJSON(e,t.content),i=e.nodeType(t.type).create(t.attrs,r,n);return i.type.checkAttrs(i.attrs),i}}iA.prototype.text=void 0;class iT extends iA{constructor(e,t,n,r){if(super(e,t,null,r),!n)throw RangeError("Empty text nodes are not allowed");this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):iO(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new iT(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new iT(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return 0==e&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function iO(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+"("+t+")";return t}class i_{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){var n;let r,i=new iD(e,t);if(null==i.next)return i_.empty;let s=function e(t){let n=[];do n.push(function(t){let n=[];do n.push(function(t){let n=function(t){if(t.eat("(")){let n=e(t);return t.eat(")")||t.err("Missing closing paren"),n}if(/\W/.test(t.next))t.err("Unexpected token '"+t.next+"'");else{let e=(function(e,t){let n=e.nodeTypes,r=n[t];if(r)return[r];let i=[];for(let e in n){let r=n[e];r.isInGroup(t)&&i.push(r)}return 0==i.length&&e.err("No node type or group '"+t+"' found"),i})(t,t.next).map(e=>(null==t.inline?t.inline=e.isInline:t.inline!=e.isInline&&t.err("Mixing inline and block content"),{type:"name",value:e}));return t.pos++,1==e.length?e[0]:{type:"choice",exprs:e}}}(t);for(;;)if(t.eat("+"))n={type:"plus",expr:n};else if(t.eat("*"))n={type:"star",expr:n};else if(t.eat("?"))n={type:"opt",expr:n};else if(t.eat("{"))n=function(e,t){let n=iR(e),r=n;return e.eat(",")&&(r="}"!=e.next?iR(e):-1),e.eat("}")||e.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:t}}(t,n);else break;return n}(t));while(t.next&&")"!=t.next&&"|"!=t.next)return 1==n.length?n[0]:{type:"seq",exprs:n}}(t));while(t.eat("|"))return 1==n.length?n[0]:{type:"choice",exprs:n}}(i);i.next&&i.err("Unexpected trailing text");let o=(n=function(e){let t=[[]];return i(function e(t,s){if("choice"==t.type)return t.exprs.reduce((t,n)=>t.concat(e(n,s)),[]);if("seq"==t.type)for(let r=0;;r++){let o=e(t.exprs[r],s);if(r==t.exprs.length-1)return o;i(o,s=n())}else if("star"==t.type){let o=n();return r(s,o),i(e(t.expr,o),o),[r(o)]}else if("plus"==t.type){let o=n();return i(e(t.expr,s),o),i(e(t.expr,o),o),[r(o)]}else if("opt"==t.type)return[r(s)].concat(e(t.expr,s));else if("range"==t.type){let o=s;for(let r=0;r<t.min;r++){let r=n();i(e(t.expr,o),r),o=r}if(-1==t.max)i(e(t.expr,o),o);else for(let s=t.min;s<t.max;s++){let s=n();r(o,s),i(e(t.expr,o),s),o=s}return[r(o)]}else if("name"==t.type)return[r(s,void 0,t.value)];else throw Error("Unknown expr type")}(e,0),n()),t;function n(){return t.push([])-1}function r(e,n,r){let i={term:r,to:n};return t[e].push(i),i}function i(e,t){e.forEach(e=>e.to=t)}}(s),r=Object.create(null),function e(t){let i=[];t.forEach(e=>{n[e].forEach(({term:e,to:t})=>{let r;if(e){for(let t=0;t<i.length;t++)i[t][0]==e&&(r=i[t][1]);iL(n,t).forEach(t=>{r||i.push([e,r=[]]),-1==r.indexOf(t)&&r.push(t)})}})});let s=r[t.join(",")]=new i_(t.indexOf(n.length-1)>-1);for(let t=0;t<i.length;t++){let n=i[t][1].sort(iI);s.next.push({type:i[t][0],next:r[n.join(",")]||e(n)})}return s}(iL(n,0)));return function(e,t){for(let n=0,r=[e];n<r.length;n++){let e=r[n],i=!e.validEnd,s=[];for(let t=0;t<e.next.length;t++){let{type:n,next:o}=e.next[t];s.push(n.name),i&&!(n.isText||n.hasRequiredAttrs())&&(i=!1),-1==r.indexOf(o)&&r.push(o)}i&&t.err("Only non-generatable nodes ("+s.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}(o,i),o}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,n=e.childCount){let r=this;for(let i=t;r&&i<n;i++)r=r.matchType(e.child(i).type);return r}get inlineContent(){return 0!=this.next.length&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}fillBefore(e,t=!1,n=0){let r=[this];return function i(s,o){let a=s.matchFragment(e,n);if(a&&(!t||a.validEnd))return ic.from(o.map(e=>e.createAndFill()));for(let e=0;e<s.next.length;e++){let{type:t,next:n}=s.next[e];if(!(t.isText||t.hasRequiredAttrs())&&-1==r.indexOf(n)){r.push(n);let e=i(n,o.concat(t));if(e)return e}}return null}(this,[])}findWrapping(e){for(let t=0;t<this.wrapCache.length;t+=2)if(this.wrapCache[t]==e)return this.wrapCache[t+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let r=n.shift(),i=r.match;if(i.matchType(e)){let e=[];for(let t=r;t.type;t=t.via)e.push(t.type);return e.reverse()}for(let e=0;e<i.next.length;e++){let{type:s,next:o}=i.next[e];s.isLeaf||s.hasRequiredAttrs()||s.name in t||r.type&&!o.validEnd||(n.push({match:s.contentMatch,type:s,via:r}),t[s.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];return!function t(n){e.push(n);for(let r=0;r<n.next.length;r++)-1==e.indexOf(n.next[r].next)&&t(n.next[r].next)}(this),e.map((t,n)=>{let r=n+(t.validEnd?"*":" ")+" ";for(let n=0;n<t.next.length;n++)r+=(n?", ":"")+t.next[n].type.name+"->"+e.indexOf(t.next[n].next);return r}).join("\n")}}i_.empty=new i_(!0);class iD{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),""==this.tokens[this.tokens.length-1]&&this.tokens.pop(),""==this.tokens[0]&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw SyntaxError(e+" (in content expression '"+this.string+"')")}}function iR(e){/\D/.test(e.next)&&e.err("Expected number, got '"+e.next+"'");let t=Number(e.next);return e.pos++,t}function iI(e,t){return t-e}function iL(e,t){let n=[];return function t(r){let i=e[r];if(1==i.length&&!i[0].term)return t(i[0].to);n.push(r);for(let e=0;e<i.length;e++){let{term:r,to:s}=i[e];r||-1!=n.indexOf(s)||t(s)}}(t),n.sort(iI)}function iP(e){let t=Object.create(null);for(let n in e){let r=e[n];if(!r.hasDefault)return null;t[n]=r.default}return t}function iz(e,t){let n=Object.create(null);for(let r in e){let i=t&&t[r];if(void 0===i){let t=e[r];if(t.hasDefault)i=t.default;else throw RangeError("No value supplied for attribute "+r)}n[r]=i}return n}function i$(e,t,n,r){for(let r in t)if(!(r in e))throw RangeError(`Unsupported attribute ${r} for ${n} of type ${r}`);for(let n in e){let r=e[n];r.validate&&r.validate(t[n])}}function iB(e,t){let n=Object.create(null);if(t)for(let r in t)n[r]=new iH(e,r,t[r]);return n}class iF{constructor(e,t,n){this.name=e,this.schema=t,this.spec=n,this.markSet=null,this.groups=n.group?n.group.split(" "):[],this.attrs=iB(e,n.attrs),this.defaultAttrs=iP(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(n.inline||"text"==e),this.isText="text"==e}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==i_.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:iz(this.attrs,e)}create(e=null,t,n){if(this.isText)throw Error("NodeType.create can't construct text nodes");return new iA(this,this.computeAttrs(e),ic.from(t),ih.setFrom(n))}createChecked(e=null,t,n){return t=ic.from(t),this.checkContent(t),new iA(this,this.computeAttrs(e),t,ih.setFrom(n))}createAndFill(e=null,t,n){if(e=this.computeAttrs(e),(t=ic.from(t)).size){let e=this.contentMatch.fillBefore(t);if(!e)return null;t=e.append(t)}let r=this.contentMatch.matchFragment(t),i=r&&r.fillBefore(ic.empty,!0);return i?new iA(this,e,t.append(i),ih.setFrom(n)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let t=0;t<e.childCount;t++)if(!this.allowsMarks(e.child(t).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){i$(this.attrs,e,"node",this.name)}allowsMarkType(e){return null==this.markSet||this.markSet.indexOf(e)>-1}allowsMarks(e){if(null==this.markSet)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){let t;if(null==this.markSet)return e;for(let n=0;n<e.length;n++)this.allowsMarkType(e[n].type)?t&&t.push(e[n]):t||(t=e.slice(0,n));return t?t.length?t:ih.none:e}static compile(e,t){let n=Object.create(null);e.forEach((e,r)=>n[e]=new iF(e,t,r));let r=t.spec.topNode||"doc";if(!n[r])throw RangeError("Schema is missing its top node type ('"+r+"')");if(!n.text)throw RangeError("Every schema needs a 'text' type");for(let e in n.text.attrs)throw RangeError("The text node type should not have attributes");return n}}class iH{constructor(e,t,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,"default"),this.default=n.default,this.validate="string"==typeof n.validate?function(e,t,n){let r=n.split("|");return n=>{let i=null===n?"null":typeof n;if(0>r.indexOf(i))throw RangeError(`Expected value of type ${r} for attribute ${t} on type ${e}, got ${i}`)}}(e,t,n.validate):n.validate}get isRequired(){return!this.hasDefault}}class iU{constructor(e,t,n,r){this.name=e,this.rank=t,this.schema=n,this.spec=r,this.attrs=iB(e,r.attrs),this.excluded=null;let i=iP(this.attrs);this.instance=i?new ih(this,i):null}create(e=null){return!e&&this.instance?this.instance:new ih(this,iz(this.attrs,e))}static compile(e,t){let n=Object.create(null),r=0;return e.forEach((e,i)=>n[e]=new iU(e,r++,t,i)),n}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){i$(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class iV{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let n in e)t[n]=e[n];t.nodes=il.from(e.nodes),t.marks=il.from(e.marks||{}),this.nodes=iF.compile(this.spec.nodes,this),this.marks=iU.compile(this.spec.marks,this);let n=Object.create(null);for(let e in this.nodes){if(e in this.marks)throw RangeError(e+" can not be both a node and a mark");let t=this.nodes[e],r=t.spec.content||"",i=t.spec.marks;if(t.contentMatch=n[r]||(n[r]=i_.parse(r,this.nodes)),t.inlineContent=t.contentMatch.inlineContent,t.spec.linebreakReplacement){if(this.linebreakReplacement)throw RangeError("Multiple linebreak nodes defined");if(!t.isInline||!t.isLeaf)throw RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=t}t.markSet="_"==i?null:i?iW(this,i.split(" ")):""!=i&&t.inlineContent?null:[]}for(let e in this.marks){let t=this.marks[e],n=t.spec.excludes;t.excluded=null==n?[t]:""==n?[]:iW(this,n.split(" "))}this.nodeFromJSON=e=>iA.fromJSON(this,e),this.markFromJSON=e=>ih.fromJSON(this,e),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,n,r){if("string"==typeof e)e=this.nodeType(e);else if(e instanceof iF){if(e.schema!=this)throw RangeError("Node type from different schema used ("+e.name+")")}else throw RangeError("Invalid node type: "+e);return e.createChecked(t,n,r)}text(e,t){let n=this.nodes.text;return new iT(n,n.defaultAttrs,e,ih.setFrom(t))}mark(e,t){return"string"==typeof e&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw RangeError("Unknown node type: "+e);return t}}function iW(e,t){let n=[];for(let r=0;r<t.length;r++){let i=t[r],s=e.marks[i],o=s;if(s)n.push(s);else for(let t in e.marks){let r=e.marks[t];("_"==i||r.spec.group&&r.spec.group.split(" ").indexOf(i)>-1)&&n.push(o=r)}if(!o)throw SyntaxError("Unknown mark type: '"+t[r]+"'")}return n}class iq{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let n=this.matchedStyles=[];t.forEach(e=>{if(null!=e.tag)this.tags.push(e);else if(null!=e.style){let t=/[^=]*/.exec(e.style)[0];0>n.indexOf(t)&&n.push(t),this.styles.push(e)}}),this.normalizeLists=!this.tags.some(t=>{if(!/^(ul|ol)\b/.test(t.tag)||!t.node)return!1;let n=e.nodes[t.node];return n.contentMatch.matchType(n)})}parse(e,t={}){let n=new iY(this,t,!1);return n.addAll(e,ih.none,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new iY(this,t,!0);return n.addAll(e,ih.none,t.from,t.to),ig.maxOpen(n.finish())}matchTag(e,t,n){for(let s=n?this.tags.indexOf(n)+1:0;s<this.tags.length;s++){var r,i;let n=this.tags[s];if(r=e,i=n.tag,(r.matches||r.msMatchesSelector||r.webkitMatchesSelector||r.mozMatchesSelector).call(r,i)&&(void 0===n.namespace||e.namespaceURI==n.namespace)&&(!n.context||t.matchesContext(n.context))){if(n.getAttrs){let t=n.getAttrs(e);if(!1===t)continue;n.attrs=t||void 0}return n}}}matchStyle(e,t,n,r){for(let i=r?this.styles.indexOf(r)+1:0;i<this.styles.length;i++){let r=this.styles[i],s=r.style;if(0==s.indexOf(e)&&(!r.context||n.matchesContext(r.context))&&(!(s.length>e.length)||61==s.charCodeAt(e.length)&&s.slice(e.length+1)==t)){if(r.getAttrs){let e=r.getAttrs(t);if(!1===e)continue;r.attrs=e||void 0}return r}}}static schemaRules(e){let t=[];function n(e){let n=null==e.priority?50:e.priority,r=0;for(;r<t.length;r++){let e=t[r];if((null==e.priority?50:e.priority)<n)break}t.splice(r,0,e)}for(let t in e.marks){let r=e.marks[t].spec.parseDOM;r&&r.forEach(e=>{n(e=iQ(e)),e.mark||e.ignore||e.clearMark||(e.mark=t)})}for(let t in e.nodes){let r=e.nodes[t].spec.parseDOM;r&&r.forEach(e=>{n(e=iQ(e)),e.node||e.ignore||e.mark||(e.node=t)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new iq(e,iq.schemaRules(e)))}}let iK={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},iG={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},iJ={ol:!0,ul:!0};function iZ(e,t,n){return null!=t?!!t|2*("full"===t):e&&"pre"==e.whitespace?3:-5&n}class iX{constructor(e,t,n,r,i,s){this.type=e,this.attrs=t,this.marks=n,this.solid=r,this.options=s,this.content=[],this.activeMarks=ih.none,this.match=i||(4&s?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(ic.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let t=this.type.contentMatch,n;return(n=t.findWrapping(e.type))?(this.match=t,n):null}}return this.match.findWrapping(e.type)}finish(e){if(!(1&this.options)){let e=this.content[this.content.length-1],t;e&&e.isText&&(t=/[ \t\r\n\u000c]+$/.exec(e.text))&&(e.text.length==t[0].length?this.content.pop():this.content[this.content.length-1]=e.withText(e.text.slice(0,e.text.length-t[0].length)))}let t=ic.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(ic.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!iK.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class iY{constructor(e,t,n){this.parser=e,this.options=t,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let r=t.topNode,i,s=iZ(null,t.preserveWhitespace,0)|4*!!n;i=r?new iX(r.type,r.attrs,ih.none,!0,t.topMatch||r.type.contentMatch,s):n?new iX(null,null,ih.none,!0,null,s):new iX(e.schema.topNodeType,null,ih.none,!0,null,s),this.nodes=[i],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){3==e.nodeType?this.addTextNode(e,t):1==e.nodeType&&this.addElement(e,t)}addTextNode(e,t){let n=e.nodeValue,r=this.top,i=2&r.options?"full":this.localPreserveWS||(1&r.options)>0,{schema:s}=this.parser;if("full"===i||r.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(i)if("full"===i)n=n.replace(/\r\n?/g,"\n");else if(s.linebreakReplacement&&/[\r\n]/.test(n)&&this.top.findWrapping(s.linebreakReplacement.create())){let e=n.split(/\r?\n|\r/);for(let n=0;n<e.length;n++)n&&this.insertNode(s.linebreakReplacement.create(),t,!0),e[n]&&this.insertNode(s.text(e[n]),t,!/\S/.test(e[n]));n=""}else n=n.replace(/\r?\n|\r/g," ");else if(n=n.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let t=r.content[r.content.length-1],i=e.previousSibling;(!t||i&&"BR"==i.nodeName||t.isText&&/[ \t\r\n\u000c]$/.test(t.text))&&(n=n.slice(1))}n&&this.insertNode(s.text(n),t,!/\S/.test(n)),this.findInText(e)}else this.findInside(e)}addElement(e,t,n){let r=this.localPreserveWS,i=this.top;("PRE"==e.tagName||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let s=e.nodeName.toLowerCase(),o;iJ.hasOwnProperty(s)&&this.parser.normalizeLists&&function(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let e=1==t.nodeType?t.nodeName.toLowerCase():null;e&&iJ.hasOwnProperty(e)&&n?(n.appendChild(t),t=n):"li"==e?n=t:e&&(n=null)}}(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(o=this.parser.matchTag(e,this,n));e:if(a?a.ignore:iG.hasOwnProperty(s))this.findInside(e),this.ignoreFallback(e,t);else if(!a||a.skip||a.closeParent){a&&a.closeParent?this.open=Math.max(0,this.open-1):a&&a.skip.nodeType&&(e=a.skip);let n,r=this.needsBlock;if(iK.hasOwnProperty(s))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),n=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}let o=a&&a.skip?t:this.readStyles(e,t);o&&this.addAll(e,o),n&&this.sync(i),this.needsBlock=r}else{let n=this.readStyles(e,t);n&&this.addElementByRule(e,a,n,!1===a.consuming?o:void 0)}this.localPreserveWS=r}leafFallback(e,t){"BR"==e.nodeName&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode("\n"),t)}ignoreFallback(e,t){"BR"!=e.nodeName||this.top.type&&this.top.type.inlineContent||this.findPlace(this.parser.schema.text("-"),t,!0)}readStyles(e,t){let n=e.style;if(n&&n.length)for(let e=0;e<this.parser.matchedStyles.length;e++){let r=this.parser.matchedStyles[e],i=n.getPropertyValue(r);if(i)for(let e;;){let n=this.parser.matchStyle(r,i,this,e);if(!n)break;if(n.ignore)return null;if(t=n.clearMark?t.filter(e=>!n.clearMark(e)):t.concat(this.parser.schema.marks[n.mark].create(n.attrs)),!1===n.consuming)e=n;else break}}return t}addElementByRule(e,t,n,r){let i,s;if(t.node)if((s=this.parser.schema.nodes[t.node]).isLeaf)this.insertNode(s.create(t.attrs),n,"BR"==e.nodeName)||this.leafFallback(e,n);else{let e=this.enter(s,t.attrs||null,n,t.preserveWhitespace);e&&(i=!0,n=e)}else{let e=this.parser.schema.marks[t.mark];n=n.concat(e.create(t.attrs))}let o=this.top;if(s&&s.isLeaf)this.findInside(e);else if(r)this.addElement(e,n,r);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(e=>this.insertNode(e,n,!1));else{let r=e;"string"==typeof t.contentElement?r=e.querySelector(t.contentElement):"function"==typeof t.contentElement?r=t.contentElement(e):t.contentElement&&(r=t.contentElement),this.findAround(e,r,!0),this.addAll(r,n),this.findAround(e,r,!1)}i&&this.sync(o)&&this.open--}addAll(e,t,n,r){let i=n||0;for(let s=n?e.childNodes[n]:e.firstChild,o=null==r?null:e.childNodes[r];s!=o;s=s.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(s,t);this.findAtPoint(e,i)}findPlace(e,t,n){let r,i;for(let t=this.open,s=0;t>=0;t--){let o=this.nodes[t],a=o.findWrapping(e);if(a&&(!r||r.length>a.length+s)&&(r=a,i=o,!a.length))break;if(o.solid){if(n)break;s+=2}}if(!r)return null;this.sync(i);for(let e=0;e<r.length;e++)t=this.enterInner(r[e],null,t,!1);return t}insertNode(e,t,n){if(e.isInline&&this.needsBlock&&!this.top.type){let e=this.textblockFromContext();e&&(t=this.enterInner(e,null,t))}let r=this.findPlace(e,t,n);if(r){this.closeExtra();let t=this.top;t.match&&(t.match=t.match.matchType(e.type));let n=ih.none;for(let i of r.concat(e.marks))(t.type?t.type.allowsMarkType(i.type):i0(i.type,e.type))&&(n=i.addToSet(n));return t.content.push(e.mark(n)),!0}return!1}enter(e,t,n,r){let i=this.findPlace(e.create(t),n,!1);return i&&(i=this.enterInner(e,t,n,!0,r)),i}enterInner(e,t,n,r=!1,i){this.closeExtra();let s=this.top;s.match=s.match&&s.match.matchType(e);let o=iZ(e,i,s.options);4&s.options&&0==s.content.length&&(o|=4);let a=ih.none;return n=n.filter(t=>(s.type?!s.type.allowsMarkType(t.type):!i0(t.type,e))||(a=t.addToSet(a),!1)),this.nodes.push(new iX(e,t,a,r,null,o)),this.open++,n}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--)if(this.nodes[t]==e)return this.open=t,!0;else this.localPreserveWS&&(this.nodes[t].options|=1);return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let n=this.nodes[t].content;for(let t=n.length-1;t>=0;t--)e+=n[t].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&this.find[n].offset==t&&(this.find[n].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)null==this.find[t].pos&&1==e.nodeType&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,n){if(e!=t&&this.find)for(let r=0;r<this.find.length;r++)null==this.find[r].pos&&1==e.nodeType&&e.contains(this.find[r].node)&&t.compareDocumentPosition(this.find[r].node)&(n?2:4)&&(this.find[r].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),n=this.options.context,r=!this.isOpen&&(!n||n.parent.type==this.nodes[0].type),i=-(n?n.depth+1:0)+ +!r,s=(e,o)=>{for(;e>=0;e--){let a=t[e];if(""==a){if(e==t.length-1||0==e)continue;for(;o>=i;o--)if(s(e-1,o))return!0;return!1}{let e=o>0||0==o&&r?this.nodes[o].type:n&&o>=i?n.node(o-i).type:null;if(!e||e.name!=a&&!e.isInGroup(a))return!1;o--}}return!0};return s(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let n=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let e in this.parser.schema.nodes){let t=this.parser.schema.nodes[e];if(t.isTextblock&&t.defaultAttrs)return t}}}function iQ(e){let t={};for(let n in e)t[n]=e[n];return t}function i0(e,t){let n=t.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(e))continue;let s=[],o=e=>{s.push(e);for(let n=0;n<e.edgeCount;n++){let{type:r,next:i}=e.edge(n);if(r==t||0>s.indexOf(i)&&o(i))return!0}};if(o(i.contentMatch))return!0}}class i1{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){n||(n=i3(t).createDocumentFragment());let r=n,i=[];return e.forEach(e=>{if(i.length||e.marks.length){let n=0,s=0;for(;n<i.length&&s<e.marks.length;){let t=e.marks[s];if(!this.marks[t.type.name]){s++;continue}if(!t.eq(i[n][0])||!1===t.type.spec.spanning)break;n++,s++}for(;n<i.length;)r=i.pop()[1];for(;s<e.marks.length;){let n=e.marks[s++],o=this.serializeMark(n,e.isInline,t);o&&(i.push([n,r]),r.appendChild(o.dom),r=o.contentDOM||o.dom)}}r.appendChild(this.serializeNodeInner(e,t))}),n}serializeNodeInner(e,t){if(e.isText)return i3(t).createTextNode(e.text);let{dom:n,contentDOM:r}=i4(i3(t),this.nodes[e.type.name](e),null,e.attrs);if(r){if(e.isLeaf)throw RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,r)}return n}serializeNode(e,t={}){let n=this.serializeNodeInner(e,t);for(let r=e.marks.length-1;r>=0;r--){let i=this.serializeMark(e.marks[r],e.isInline,t);i&&((i.contentDOM||i.dom).appendChild(n),n=i.dom)}return n}serializeMark(e,t,n={}){let r=this.marks[e.type.name];return r&&i4(i3(n),r(e,t),null,e.attrs)}static renderSpec(e,t,n=null,r){return"string"==typeof t?{dom:e.createTextNode(t)}:i4(e,t,n,r)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new i1(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=i2(e.nodes);return t.text||(t.text=e=>e.text),t}static marksFromSchema(e){return i2(e.marks)}}function i2(e){let t={};for(let n in e){let r=e[n].spec.toDOM;r&&(t[n]=r)}return t}function i3(e){return e.document||window.document}let i5=new WeakMap;function i4(e,t,n,r){let i,s,o;if(1==t.nodeType)return{dom:t};if(t.dom&&1==t.dom.nodeType)return t;let a=t[0],l;if("string"!=typeof a)throw RangeError("Invalid array passed to renderSpec");if(r&&(void 0===(s=i5.get(r))&&i5.set(r,(o=null,!function e(t){if(t&&"object"==typeof t)if(Array.isArray(t))if("string"==typeof t[0])o||(o=[]),o.push(t);else for(let n=0;n<t.length;n++)e(t[n]);else for(let n in t)e(t[n])}(r),s=o)),l=s)&&l.indexOf(t)>-1)throw RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let c=a.indexOf(" ");c>0&&(n=a.slice(0,c),a=a.slice(c+1));let d=n?e.createElementNS(n,a):e.createElement(a),u=t[1],p=1;if(u&&"object"==typeof u&&null==u.nodeType&&!Array.isArray(u)){for(let e in p=2,u)if(null!=u[e]){let t=e.indexOf(" ");t>0?d.setAttributeNS(e.slice(0,t),e.slice(t+1),u[e]):"style"==e&&d.style?d.style.cssText=u[e]:d.setAttribute(e,u[e])}}for(let s=p;s<t.length;s++){let o=t[s];if(0===o){if(s<t.length-1||s>p)throw RangeError("Content hole must be the only child of its parent node");return{dom:d,contentDOM:d}}if("string"==typeof o)d.appendChild(e.createTextNode(o));else{let{dom:t,contentDOM:s}=i4(e,o,n,r);if(d.appendChild(t),s){if(i)throw RangeError("Multiple content holes");i=s}}}return{dom:d,contentDOM:i}}class i6{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(8&this.delInfo)>0}get deletedBefore(){return(5&this.delInfo)>0}get deletedAfter(){return(6&this.delInfo)>0}get deletedAcross(){return(4&this.delInfo)>0}}class i9{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&i9.empty)return i9.empty}recover(e){let t=0,n=65535&e;if(!this.inverted)for(let e=0;e<n;e++)t+=this.ranges[3*e+2]-this.ranges[3*e+1];return this.ranges[3*n]+t+(e-(65535&e))/65536}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,n){let r=0,i=this.inverted?2:1,s=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let a=this.ranges[o]-(this.inverted?r:0);if(a>e)break;let l=this.ranges[o+i],c=this.ranges[o+s],d=a+l;if(e<=d){let i=l?e==a?-1:e==d?1:t:t,s=a+r+(i<0?0:c);if(n)return s;let u=e==(t<0?a:d)?null:o/3+(e-a)*65536,p=e==a?2:e==d?1:4;return(t<0?e!=a:e!=d)&&(p|=8),new i6(s,p,u)}r+=c-l}return n?e+r:new i6(e+r,0,null)}touches(e,t){let n=0,r=65535&t,i=this.inverted?2:1,s=this.inverted?1:2;for(let t=0;t<this.ranges.length;t+=3){let o=this.ranges[t]-(this.inverted?n:0);if(o>e)break;let a=this.ranges[t+i];if(e<=o+a&&t==3*r)return!0;n+=this.ranges[t+s]-a}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let r=0,i=0;r<this.ranges.length;r+=3){let s=this.ranges[r],o=s-(this.inverted?i:0),a=s+(this.inverted?0:i),l=this.ranges[r+t],c=this.ranges[r+n];e(o,o+l,a,a+c),i+=c-l}}invert(){return new i9(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return 0==e?i9.empty:new i9(e<0?[0,-e,0]:[0,0,e])}}i9.empty=new i9([]);class i7{constructor(e,t,n=0,r=e?e.length:0){this.mirror=t,this.from=n,this.to=r,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new i7(this._maps,this.mirror,e,t)}appendMap(e,t){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),null!=t&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,n=this._maps.length;t<e._maps.length;t++){let r=e.getMirror(t);this.appendMap(e._maps[t],null!=r&&r<t?n+r:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,n=this._maps.length+e._maps.length;t>=0;t--){let r=e.getMirror(t);this.appendMap(e._maps[t].invert(),null!=r&&r>t?n-r-1:void 0)}}invert(){let e=new i7;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let n=this.from;n<this.to;n++)e=this._maps[n].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,n){let r=0;for(let n=this.from;n<this.to;n++){let i=this._maps[n].mapResult(e,t);if(null!=i.recover){let t=this.getMirror(n);if(null!=t&&t>n&&t<this.to){n=t,e=this._maps[t].recover(i.recover);continue}}r|=i.delInfo,e=i.pos}return n?e:new i6(e,r,null)}}let i8=Object.create(null);class se{getMap(){return i9.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw RangeError("Invalid input for Step.fromJSON");let n=i8[t.stepType];if(!n)throw RangeError(`No step type ${t.stepType} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in i8)throw RangeError("Duplicate use of step JSON ID "+e);return i8[e]=t,t.prototype.jsonID=e,t}}class st{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new st(e,null)}static fail(e){return new st(null,e)}static fromReplace(e,t,n,r){try{return st.ok(e.replace(t,n,r))}catch(e){if(e instanceof im)return st.fail(e.message);throw e}}}function sn(e,t,n){let r=[];for(let i=0;i<e.childCount;i++){let s=e.child(i);s.content.size&&(s=s.copy(sn(s.content,t,s))),s.isInline&&(s=t(s,n,i)),r.push(s)}return ic.fromArray(r)}class sr extends se{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=e.resolve(this.from),r=n.node(n.sharedDepth(this.to)),i=new ig(sn(t.content,(e,t)=>e.isAtom&&t.type.allowsMarkType(this.mark.type)?e.mark(this.mark.addToSet(e.marks)):e,r),t.openStart,t.openEnd);return st.fromReplace(e,this.from,this.to,i)}invert(){return new si(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deleted&&n.deleted||t.pos>=n.pos?null:new sr(t.pos,n.pos,this.mark)}merge(e){return e instanceof sr&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new sr(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to)throw RangeError("Invalid input for AddMarkStep.fromJSON");return new sr(t.from,t.to,e.markFromJSON(t.mark))}}se.jsonID("addMark",sr);class si extends se{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=new ig(sn(t.content,e=>e.mark(this.mark.removeFromSet(e.marks)),e),t.openStart,t.openEnd);return st.fromReplace(e,this.from,this.to,n)}invert(){return new sr(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deleted&&n.deleted||t.pos>=n.pos?null:new si(t.pos,n.pos,this.mark)}merge(e){return e instanceof si&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new si(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to)throw RangeError("Invalid input for RemoveMarkStep.fromJSON");return new si(t.from,t.to,e.markFromJSON(t.mark))}}se.jsonID("removeMark",si);class ss extends se{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return st.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return st.fromReplace(e,this.pos,this.pos+1,new ig(ic.from(n),0,+!t.isLeaf))}invert(e){let t=e.nodeAt(this.pos);if(t){let e=this.mark.addToSet(t.marks);if(e.length==t.marks.length){for(let n=0;n<t.marks.length;n++)if(!t.marks[n].isInSet(e))return new ss(this.pos,t.marks[n]);return new ss(this.pos,this.mark)}}return new so(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new ss(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if("number"!=typeof t.pos)throw RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new ss(t.pos,e.markFromJSON(t.mark))}}se.jsonID("addNodeMark",ss);class so extends se{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return st.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return st.fromReplace(e,this.pos,this.pos+1,new ig(ic.from(n),0,+!t.isLeaf))}invert(e){let t=e.nodeAt(this.pos);return t&&this.mark.isInSet(t.marks)?new ss(this.pos,this.mark):this}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new so(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if("number"!=typeof t.pos)throw RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new so(t.pos,e.markFromJSON(t.mark))}}se.jsonID("removeNodeMark",so);class sa extends se{constructor(e,t,n,r=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=r}apply(e){return this.structure&&sc(e,this.from,this.to)?st.fail("Structure replace would overwrite content"):st.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new i9([this.from,this.to-this.from,this.slice.size])}invert(e){return new sa(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.to,-1),n=this.from==this.to&&sa.MAP_BIAS<0?t:e.mapResult(this.from,1);return n.deletedAcross&&t.deletedAcross?null:new sa(n.pos,Math.max(n.pos,t.pos),this.slice,this.structure)}merge(e){if(!(e instanceof sa)||e.structure||this.structure)return null;if(this.from+this.slice.size!=e.from||this.slice.openEnd||e.slice.openStart)if(e.to!=this.from||this.slice.openStart||e.slice.openEnd)return null;else{let t=this.slice.size+e.slice.size==0?ig.empty:new ig(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new sa(e.from,this.to,t,this.structure)}{let t=this.slice.size+e.slice.size==0?ig.empty:new ig(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new sa(this.from,this.to+(e.to-e.from),t,this.structure)}}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to)throw RangeError("Invalid input for ReplaceStep.fromJSON");return new sa(t.from,t.to,ig.fromJSON(e,t.slice),!!t.structure)}}sa.MAP_BIAS=1,se.jsonID("replace",sa);class sl extends se{constructor(e,t,n,r,i,s,o=!1){super(),this.from=e,this.to=t,this.gapFrom=n,this.gapTo=r,this.slice=i,this.insert=s,this.structure=o}apply(e){if(this.structure&&(sc(e,this.from,this.gapFrom)||sc(e,this.gapTo,this.to)))return st.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return st.fail("Gap is not a flat range");let n=this.slice.insertAt(this.insert,t.content);return n?st.fromReplace(e,this.from,this.to,n):st.fail("Content does not fit in gap")}getMap(){return new i9([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new sl(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1),r=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),i=this.to==this.gapTo?n.pos:e.map(this.gapTo,1);return t.deletedAcross&&n.deletedAcross||r<t.pos||i>n.pos?null:new sl(t.pos,n.pos,r,i,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to||"number"!=typeof t.gapFrom||"number"!=typeof t.gapTo||"number"!=typeof t.insert)throw RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new sl(t.from,t.to,t.gapFrom,t.gapTo,ig.fromJSON(e,t.slice),t.insert,!!t.structure)}}function sc(e,t,n){let r=e.resolve(t),i=n-t,s=r.depth;for(;i>0&&s>0&&r.indexAfter(s)==r.node(s).childCount;)s--,i--;if(i>0){let e=r.node(s).maybeChild(r.indexAfter(s));for(;i>0;){if(!e||e.isLeaf)return!0;e=e.firstChild,i--}}return!1}function sd(e,t,n,r=n.contentMatch,i=!0){let s=e.doc.nodeAt(t),o=[],a=t+1;for(let t=0;t<s.childCount;t++){let l=s.child(t),c=a+l.nodeSize,d=r.matchType(l.type);if(d){r=d;for(let t=0;t<l.marks.length;t++)n.allowsMarkType(l.marks[t].type)||e.step(new si(a,c,l.marks[t]));if(i&&l.isText&&"pre"!=n.whitespace){let e,t=/\r?\n|\r/g,r;for(;e=t.exec(l.text);)r||(r=new ig(ic.from(n.schema.text(" ",n.allowedMarks(l.marks))),0,0)),o.push(new sa(a+e.index,a+e.index+e[0].length,r))}}else o.push(new sa(a,c,ig.empty));a=c}if(!r.validEnd){let t=r.fillBefore(ic.empty,!0);e.replace(a,a,new ig(t,0,0))}for(let t=o.length-1;t>=0;t--)e.step(o[t])}function su(e){let t=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let n=e.depth,r=0,i=0;;--n){let s=e.$from.node(n),o=e.$from.index(n)+r,a=e.$to.indexAfter(n)-i;if(n<e.depth&&s.canReplace(o,a,t))return n;if(0==n||s.type.spec.isolating||!((0==o||s.canReplace(o,s.childCount))&&(a==s.childCount||s.canReplace(0,a))))break;o&&(r=1),a<s.childCount&&(i=1)}return null}function sp(e,t,n=null,r=e){let i=function(e,t){let{parent:n,startIndex:r,endIndex:i}=e,s=n.contentMatchAt(r).findWrapping(t);if(!s)return null;let o=s.length?s[0]:t;return n.canReplaceWith(r,i,o)?s:null}(e,t),s=i&&function(e,t){let{parent:n,startIndex:r,endIndex:i}=e,s=n.child(r),o=t.contentMatch.findWrapping(s.type);if(!o)return null;let a=(o.length?o[o.length-1]:t).contentMatch;for(let e=r;a&&e<i;e++)a=a.matchType(n.child(e).type);return a&&a.validEnd?o:null}(r,t);return s?i.map(sh).concat({type:t,attrs:n}).concat(s.map(sh)):null}function sh(e){return{type:e,attrs:null}}function sf(e,t,n,r){t.forEach((i,s)=>{if(i.isText){let o,a=/\r?\n|\r/g;for(;o=a.exec(i.text);){let i=e.mapping.slice(r).map(n+1+s+o.index);e.replaceWith(i,i+1,t.type.schema.linebreakReplacement.create())}}})}function sm(e,t,n,r){t.forEach((i,s)=>{if(i.type==i.type.schema.linebreakReplacement){let i=e.mapping.slice(r).map(n+1+s);e.replaceWith(i,i+1,t.type.schema.text("\n"))}})}function sg(e,t,n=1,r){let i=e.resolve(t),s=i.depth-n,o=r&&r[r.length-1]||i.parent;if(s<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!o.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let e=i.depth-1,t=n-2;e>s;e--,t--){let n=i.node(e),s=i.index(e);if(n.type.spec.isolating)return!1;let o=n.content.cutByIndex(s,n.childCount),a=r&&r[t+1];a&&(o=o.replaceChild(0,a.type.create(a.attrs)));let l=r&&r[t]||n;if(!n.canReplace(s+1,n.childCount)||!l.type.validContent(o))return!1}let a=i.indexAfter(s),l=r&&r[0];return i.node(s).canReplaceWith(a,a,l?l.type:i.node(s+1).type)}function sb(e,t){let n=e.resolve(t),r=n.index();return sx(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function sx(e,t){return!!(e&&t&&!e.isLeaf&&function(e,t){t.content.size||e.type.compatibleContent(t.type);let n=e.contentMatchAt(e.childCount),{linebreakReplacement:r}=e.type.schema;for(let i=0;i<t.childCount;i++){let s=t.child(i),o=s.type==r?e.type.schema.nodes.text:s.type;if(!(n=n.matchType(o))||!e.type.allowsMarks(s.marks))return!1}return n.validEnd}(e,t))}function sy(e,t,n=-1){let r=e.resolve(t);for(let e=r.depth;;e--){let i,s,o=r.index(e);if(e==r.depth?(i=r.nodeBefore,s=r.nodeAfter):n>0?(i=r.node(e+1),o++,s=r.node(e).maybeChild(o)):(i=r.node(e).maybeChild(o-1),s=r.node(e+1)),i&&!i.isTextblock&&sx(i,s)&&r.node(e).canReplace(o,o+1))return t;if(0==e)break;t=n<0?r.before(e):r.after(e)}}function sv(e,t,n){let r=e.resolve(t);if(!n.content.size)return t;let i=n.content;for(let e=0;e<n.openStart;e++)i=i.firstChild.content;for(let e=1;e<=(0==n.openStart&&n.size?2:1);e++)for(let t=r.depth;t>=0;t--){let n=t==r.depth?0:r.pos<=(r.start(t+1)+r.end(t+1))/2?-1:1,s=r.index(t)+ +(n>0),o=r.node(t),a=!1;if(1==e)a=o.canReplace(s,s,i);else{let e=o.contentMatchAt(s).findWrapping(i.firstChild.type);a=e&&o.canReplaceWith(s,s,e[0])}if(a)return 0==n?r.pos:n<0?r.before(t+1):r.after(t+1)}return null}function sw(e,t,n=t,r=ig.empty){if(t==n&&!r.size)return null;let i=e.resolve(t),s=e.resolve(n);return sk(i,s,r)?new sa(t,n,r):new sN(i,s,r).fit()}function sk(e,t,n){return!n.openStart&&!n.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),n.content)}se.jsonID("replaceAround",sl);class sN{constructor(e,t,n){this.$from=e,this.$to=t,this.unplaced=n,this.frontier=[],this.placed=ic.empty;for(let t=0;t<=e.depth;t++){let n=e.node(t);this.frontier.push({type:n.type,match:n.contentMatchAt(e.indexAfter(t))})}for(let t=e.depth;t>0;t--)this.placed=ic.from(e.node(t).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let e=this.findFittable();e?this.placeNodes(e):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,n=this.$from,r=this.close(e<0?this.$to:n.doc.resolve(e));if(!r)return null;let i=this.placed,s=n.depth,o=r.depth;for(;s&&o&&1==i.childCount;)i=i.firstChild.content,s--,o--;let a=new ig(i,s,o);return e>-1?new sl(n.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||n.pos!=this.$to.pos?new sa(n.pos,r.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,n=0,r=this.unplaced.openEnd;n<e;n++){let i=t.firstChild;if(t.childCount>1&&(r=0),i.type.spec.isolating&&r<=n){e=n;break}t=i.content}for(let t=1;t<=2;t++)for(let n=1==t?e:this.unplaced.openStart;n>=0;n--){let e=null,r=(n?(e=sj(this.unplaced.content,n-1).firstChild).content:this.unplaced.content).firstChild;for(let i=this.depth;i>=0;i--){let{type:s,match:o}=this.frontier[i],a,l=null;if(1==t&&(r?o.matchType(r.type)||(l=o.fillBefore(ic.from(r),!1)):e&&s.compatibleContent(e.type)))return{sliceDepth:n,frontierDepth:i,parent:e,inject:l};if(2==t&&r&&(a=o.findWrapping(r.type)))return{sliceDepth:n,frontierDepth:i,parent:e,wrap:a};if(e&&o.matchType(e.type))break}}}openMore(){let{content:e,openStart:t,openEnd:n}=this.unplaced,r=sj(e,t);return!!r.childCount&&!r.firstChild.isLeaf&&(this.unplaced=new ig(e,t+1,Math.max(n,r.size+t>=e.size-n?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:n}=this.unplaced,r=sj(e,t);if(r.childCount<=1&&t>0){let i=e.size-t<=t+r.size;this.unplaced=new ig(sS(e,t-1,1),t-1,i?t-1:n)}else this.unplaced=new ig(sS(e,t,1),t,n)}placeNodes({sliceDepth:e,frontierDepth:t,parent:n,inject:r,wrap:i}){for(;this.depth>t;)this.closeFrontierNode();if(i)for(let e=0;e<i.length;e++)this.openFrontierNode(i[e]);let s=this.unplaced,o=n?n.content:s.content,a=s.openStart-e,l=0,c=[],{match:d,type:u}=this.frontier[t];if(r){for(let e=0;e<r.childCount;e++)c.push(r.child(e));d=d.matchFragment(r)}let p=o.size+e-(s.content.size-s.openEnd);for(;l<o.childCount;){let e=o.child(l),t=d.matchType(e.type);if(!t)break;(++l>1||0==a||e.content.size)&&(d=t,c.push(function e(t,n,r){if(n<=0)return t;let i=t.content;return n>1&&(i=i.replaceChild(0,e(i.firstChild,n-1,1==i.childCount?r-1:0))),n>0&&(i=t.type.contentMatch.fillBefore(i).append(i),r<=0&&(i=i.append(t.type.contentMatch.matchFragment(i).fillBefore(ic.empty,!0)))),t.copy(i)}(e.mark(u.allowedMarks(e.marks)),1==l?a:0,l==o.childCount?p:-1)))}let h=l==o.childCount;h||(p=-1),this.placed=sC(this.placed,t,ic.from(c)),this.frontier[t].match=d,h&&p<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let e=0,t=o;e<p;e++){let e=t.lastChild;this.frontier.push({type:e.type,match:e.contentMatchAt(e.childCount)}),t=e.content}this.unplaced=h?0==e?ig.empty:new ig(sS(s.content,e-1,1),e-1,p<0?s.openEnd:e-1):new ig(sS(s.content,e,l),s.openStart,s.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return -1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!sE(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return -1;let{depth:n}=this.$to,r=this.$to.after(n);for(;n>1&&r==this.$to.end(--n);)++r;return r}findCloseLevel(e){t:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:n,type:r}=this.frontier[t],i=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),s=sE(e,t,r,n,i);if(s){for(let n=t-1;n>=0;n--){let{match:t,type:r}=this.frontier[n],i=sE(e,n,r,t,!0);if(!i||i.childCount)continue t}return{depth:t,fit:s,move:i?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=sC(this.placed,t.depth,t.fit)),e=t.move;for(let n=t.depth+1;n<=e.depth;n++){let t=e.node(n),r=t.type.contentMatch.fillBefore(t.content,!0,e.index(n));this.openFrontierNode(t.type,t.attrs,r)}return e}openFrontierNode(e,t=null,n){let r=this.frontier[this.depth];r.match=r.match.matchType(e),this.placed=sC(this.placed,this.depth,ic.from(e.create(t,n))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let e=this.frontier.pop().match.fillBefore(ic.empty,!0);e.childCount&&(this.placed=sC(this.placed,this.frontier.length,e))}}function sS(e,t,n){return 0==t?e.cutByIndex(n,e.childCount):e.replaceChild(0,e.firstChild.copy(sS(e.firstChild.content,t-1,n)))}function sC(e,t,n){return 0==t?e.append(n):e.replaceChild(e.childCount-1,e.lastChild.copy(sC(e.lastChild.content,t-1,n)))}function sj(e,t){for(let n=0;n<t;n++)e=e.firstChild.content;return e}function sE(e,t,n,r,i){let s=e.node(t),o=i?e.indexAfter(t):e.index(t);if(o==s.childCount&&!n.compatibleContent(s.type))return null;let a=r.fillBefore(s.content,!0,o);return a&&!function(e,t,n){for(let r=n;r<t.childCount;r++)if(!e.allowsMarks(t.child(r).marks))return!0;return!1}(n,s.content,o)?a:null}function sM(e,t){let n=[],r=Math.min(e.depth,t.depth);for(let i=r;i>=0;i--){let r=e.start(i);if(r<e.pos-(e.depth-i)||t.end(i)>t.pos+(t.depth-i)||e.node(i).type.spec.isolating||t.node(i).type.spec.isolating)break;(r==t.start(i)||i==e.depth&&i==t.depth&&e.parent.inlineContent&&t.parent.inlineContent&&i&&t.start(i-1)==r-1)&&n.push(i)}return n}class sA extends se{constructor(e,t,n){super(),this.pos=e,this.attr=t,this.value=n}apply(e){let t=e.nodeAt(this.pos);if(!t)return st.fail("No node at attribute step's position");let n=Object.create(null);for(let e in t.attrs)n[e]=t.attrs[e];n[this.attr]=this.value;let r=t.type.create(n,null,t.marks);return st.fromReplace(e,this.pos,this.pos+1,new ig(ic.from(r),0,+!t.isLeaf))}getMap(){return i9.empty}invert(e){return new sA(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new sA(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if("number"!=typeof t.pos||"string"!=typeof t.attr)throw RangeError("Invalid input for AttrStep.fromJSON");return new sA(t.pos,t.attr,t.value)}}se.jsonID("attr",sA);class sT extends se{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let n in e.attrs)t[n]=e.attrs[n];t[this.attr]=this.value;let n=e.type.create(t,e.content,e.marks);return st.ok(n)}getMap(){return i9.empty}invert(e){return new sT(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if("string"!=typeof t.attr)throw RangeError("Invalid input for DocAttrStep.fromJSON");return new sT(t.attr,t.value)}}se.jsonID("docAttr",sT);let sO=class extends Error{};(sO=function e(t){let n=Error.call(this,t);return n.__proto__=e.prototype,n}).prototype=Object.create(Error.prototype),sO.prototype.constructor=sO,sO.prototype.name="TransformError";class s_{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new i7}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new sO(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,t=-1e9;for(let n=0;n<this.mapping.maps.length;n++){let r=this.mapping.maps[n];n&&(e=r.map(e,1),t=r.map(t,-1)),r.forEach((n,r,i,s)=>{e=Math.min(e,i),t=Math.max(t,s)})}return 1e9==e?null:{from:e,to:t}}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,n=ig.empty){let r=sw(this.doc,e,t,n);return r&&this.step(r),this}replaceWith(e,t,n){return this.replace(e,t,new ig(ic.from(n),0,0))}delete(e,t){return this.replace(e,t,ig.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,n){return!function(e,t,n,r){if(!r.size)return e.deleteRange(t,n);let i=e.doc.resolve(t),s=e.doc.resolve(n);if(sk(i,s,r))return e.step(new sa(t,n,r));let o=sM(i,s);0==o[o.length-1]&&o.pop();let a=-(i.depth+1);o.unshift(a);for(let e=i.depth,t=i.pos-1;e>0;e--,t--){let n=i.node(e).type.spec;if(n.defining||n.definingAsContext||n.isolating)break;o.indexOf(e)>-1?a=e:i.before(e)==t&&o.splice(1,0,-e)}let l=o.indexOf(a),c=[],d=r.openStart;for(let e=r.content,t=0;;t++){let n=e.firstChild;if(c.push(n),t==r.openStart)break;e=n.content}for(let e=d-1;e>=0;e--){var u;let t=c[e],n=(u=t.type).spec.defining||u.spec.definingForContent;if(n&&!t.sameMarkup(i.node(Math.abs(a)-1)))d=e;else if(n||!t.type.isTextblock)break}for(let t=r.openStart;t>=0;t--){let a=(t+d+1)%(r.openStart+1),u=c[a];if(u)for(let t=0;t<o.length;t++){let c=o[(t+l)%o.length],d=!0;c<0&&(d=!1,c=-c);let p=i.node(c-1),h=i.index(c-1);if(p.canReplaceWith(h,h,u.type,u.marks))return e.replace(i.before(c),d?s.after(c):n,new ig(function e(t,n,r,i,s){if(n<r){let s=t.firstChild;t=t.replaceChild(0,s.copy(e(s.content,n+1,r,i,s)))}if(n>i){let e=s.contentMatchAt(0),n=e.fillBefore(t).append(t);t=n.append(e.matchFragment(n).fillBefore(ic.empty,!0))}return t}(r.content,0,r.openStart,a),a,r.openEnd))}}let p=e.steps.length;for(let a=o.length-1;a>=0&&(e.replace(t,n,r),!(e.steps.length>p));a--){let e=o[a];e<0||(t=i.before(e),n=s.after(e))}}(this,e,t,n),this}replaceRangeWith(e,t,n){var r=e,i=t;if(!n.isInline&&r==i&&this.doc.resolve(r).parent.content.size){let e=function(e,t,n){let r=e.resolve(t);if(r.parent.canReplaceWith(r.index(),r.index(),n))return t;if(0==r.parentOffset)for(let e=r.depth-1;e>=0;e--){let t=r.index(e);if(r.node(e).canReplaceWith(t,t,n))return r.before(e+1);if(t>0)return null}if(r.parentOffset==r.parent.content.size)for(let e=r.depth-1;e>=0;e--){let t=r.indexAfter(e);if(r.node(e).canReplaceWith(t,t,n))return r.after(e+1);if(t<r.node(e).childCount)break}return null}(this.doc,r,n.type);null!=e&&(r=i=e)}return this.replaceRange(r,i,new ig(ic.from(n),0,0)),this}deleteRange(e,t){return!function(e,t,n){let r=e.doc.resolve(t),i=e.doc.resolve(n);if(r.parent.isTextblock&&i.parent.isTextblock&&r.start()!=i.start()&&0==r.parentOffset&&0==i.parentOffset){let s=r.sharedDepth(n),o=!1;for(let e=r.depth;e>s;e--)r.node(e).type.spec.isolating&&(o=!0);for(let e=i.depth;e>s;e--)i.node(e).type.spec.isolating&&(o=!0);if(!o){for(let e=r.depth;e>0&&t==r.start(e);e--)t=r.before(e);for(let e=i.depth;e>0&&n==i.start(e);e--)n=i.before(e);r=e.doc.resolve(t),i=e.doc.resolve(n)}}let s=sM(r,i);for(let t=0;t<s.length;t++){let n=s[t],o=t==s.length-1;if(o&&0==n||r.node(n).type.contentMatch.validEnd)return e.delete(r.start(n),i.end(n));if(n>0&&(o||r.node(n-1).canReplace(r.index(n-1),i.indexAfter(n-1))))return e.delete(r.before(n),i.after(n))}for(let s=1;s<=r.depth&&s<=i.depth;s++)if(t-r.start(s)==r.depth-s&&n>r.end(s)&&i.end(s)-n!=i.depth-s&&r.start(s-1)==i.start(s-1)&&r.node(s-1).canReplace(r.index(s-1),i.index(s-1)))return e.delete(r.before(s),n);e.delete(t,n)}(this,e,t),this}lift(e,t){return!function(e,t,n){let{$from:r,$to:i,depth:s}=t,o=r.before(s+1),a=i.after(s+1),l=o,c=a,d=ic.empty,u=0;for(let e=s,t=!1;e>n;e--)t||r.index(e)>0?(t=!0,d=ic.from(r.node(e).copy(d)),u++):l--;let p=ic.empty,h=0;for(let e=s,t=!1;e>n;e--)t||i.after(e+1)<i.end(e)?(t=!0,p=ic.from(i.node(e).copy(p)),h++):c++;e.step(new sl(l,c,o,a,new ig(d.append(p),u,h),d.size-u,!0))}(this,e,t),this}join(e,t=1){return!function(e,t,n){let r=null,{linebreakReplacement:i}=e.doc.type.schema,s=e.doc.resolve(t-n),o=s.node().type;if(i&&o.inlineContent){let e="pre"==o.whitespace,t=!!o.contentMatch.matchType(i);e&&!t?r=!1:!e&&t&&(r=!0)}let a=e.steps.length;if(!1===r){let r=e.doc.resolve(t+n);sm(e,r.node(),r.before(),a)}o.inlineContent&&sd(e,t+n-1,o,s.node().contentMatchAt(s.index()),null==r);let l=e.mapping.slice(a),c=l.map(t-n);if(e.step(new sa(c,l.map(t+n,-1),ig.empty,!0)),!0===r){let t=e.doc.resolve(c);sf(e,t.node(),t.before(),e.steps.length)}}(this,e,t),this}wrap(e,t){return!function(e,t,n){let r=ic.empty;for(let e=n.length-1;e>=0;e--){if(r.size){let t=n[e].type.contentMatch.matchFragment(r);if(!t||!t.validEnd)throw RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=ic.from(n[e].type.create(n[e].attrs,r))}let i=t.start,s=t.end;e.step(new sl(i,s,i,s,new ig(r,0,0),n.length,!0))}(this,e,t),this}setBlockType(e,t=e,n,r=null){var i=this;if(!n.isTextblock)throw RangeError("Type given to setBlockType should be a textblock");let s=i.steps.length;return i.doc.nodesBetween(e,t,(e,t)=>{var o,a,l;let c,d,u="function"==typeof r?r(e):r;if(e.isTextblock&&!e.hasMarkup(n,u)&&(o=i.doc,a=i.mapping.slice(s).map(t),l=n,d=(c=o.resolve(a)).index(),c.parent.canReplaceWith(d,d+1,l))){let r=null;if(n.schema.linebreakReplacement){let e="pre"==n.whitespace,t=!!n.contentMatch.matchType(n.schema.linebreakReplacement);e&&!t?r=!1:!e&&t&&(r=!0)}!1===r&&sm(i,e,t,s),sd(i,i.mapping.slice(s).map(t,1),n,void 0,null===r);let o=i.mapping.slice(s),a=o.map(t,1),l=o.map(t+e.nodeSize,1);return i.step(new sl(a,l,a+1,l-1,new ig(ic.from(n.create(u,null,e.marks)),0,0),1,!0)),!0===r&&sf(i,e,t,s),!1}}),this}setNodeMarkup(e,t,n=null,r){return!function(e,t,n,r,i){let s=e.doc.nodeAt(t);if(!s)throw RangeError("No node at given position");n||(n=s.type);let o=n.create(r,null,i||s.marks);if(s.isLeaf)return e.replaceWith(t,t+s.nodeSize,o);if(!n.validContent(s.content))throw RangeError("Invalid content for node type "+n.name);e.step(new sl(t,t+s.nodeSize,t+1,t+s.nodeSize-1,new ig(ic.from(o),0,0),1,!0))}(this,e,t,n,r),this}setNodeAttribute(e,t,n){return this.step(new sA(e,t,n)),this}setDocAttribute(e,t){return this.step(new sT(e,t)),this}addNodeMark(e,t){return this.step(new ss(e,t)),this}removeNodeMark(e,t){let n=this.doc.nodeAt(e);if(!n)throw RangeError("No node at position "+e);if(t instanceof ih)t.isInSet(n.marks)&&this.step(new so(e,t));else{let r=n.marks,i,s=[];for(;i=t.isInSet(r);)s.push(new so(e,i)),r=i.removeFromSet(r);for(let e=s.length-1;e>=0;e--)this.step(s[e])}return this}split(e,t=1,n){return!function(e,t,n=1,r){let i=e.doc.resolve(t),s=ic.empty,o=ic.empty;for(let e=i.depth,t=i.depth-n,a=n-1;e>t;e--,a--){s=ic.from(i.node(e).copy(s));let t=r&&r[a];o=ic.from(t?t.type.create(t.attrs,o):i.node(e).copy(o))}e.step(new sa(t,t,new ig(s.append(o),n,n),!0))}(this,e,t,n),this}addMark(e,t,n){var r;let i,s,o,a;return r=this,o=[],a=[],r.doc.nodesBetween(e,t,(r,l,c)=>{if(!r.isInline)return;let d=r.marks;if(!n.isInSet(d)&&c.type.allowsMarkType(n.type)){let c=Math.max(l,e),u=Math.min(l+r.nodeSize,t),p=n.addToSet(d);for(let e=0;e<d.length;e++)d[e].isInSet(p)||(i&&i.to==c&&i.mark.eq(d[e])?i.to=u:o.push(i=new si(c,u,d[e])));s&&s.to==c?s.to=u:a.push(s=new sr(c,u,n))}}),o.forEach(e=>r.step(e)),a.forEach(e=>r.step(e)),this}removeMark(e,t,n){var r;let i,s;return r=this,i=[],s=0,r.doc.nodesBetween(e,t,(r,o)=>{if(!r.isInline)return;s++;let a=null;if(n instanceof iU){let e=r.marks,t;for(;t=n.isInSet(e);)(a||(a=[])).push(t),e=t.removeFromSet(e)}else n?n.isInSet(r.marks)&&(a=[n]):a=r.marks;if(a&&a.length){let n=Math.min(o+r.nodeSize,t);for(let t=0;t<a.length;t++){let r=a[t],l;for(let e=0;e<i.length;e++){let t=i[e];t.step==s-1&&r.eq(i[e].style)&&(l=t)}l?(l.to=n,l.step=s):i.push({style:r,from:Math.max(o,e),to:n,step:s})}}}),i.forEach(e=>r.step(new si(e.from,e.to,e.style))),this}clearIncompatible(e,t,n){return sd(this,e,t,n),this}}let sD=Object.create(null);class sR{constructor(e,t,n){this.$anchor=e,this.$head=t,this.ranges=n||[new sI(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=ig.empty){let n=t.content.lastChild,r=null;for(let e=0;e<t.openEnd;e++)r=n,n=n.lastChild;let i=e.steps.length,s=this.ranges;for(let o=0;o<s.length;o++){let{$from:a,$to:l}=s[o],c=e.mapping.slice(i);e.replaceRange(c.map(a.pos),c.map(l.pos),o?ig.empty:t),0==o&&sW(e,i,(n?n.isInline:r&&r.isTextblock)?-1:1)}}replaceWith(e,t){let n=e.steps.length,r=this.ranges;for(let i=0;i<r.length;i++){let{$from:s,$to:o}=r[i],a=e.mapping.slice(n),l=a.map(s.pos),c=a.map(o.pos);i?e.deleteRange(l,c):(e.replaceRangeWith(l,c,t),sW(e,n,t.isInline?-1:1))}}static findFrom(e,t,n=!1){let r=e.parent.inlineContent?new sz(e):sV(e.node(0),e.parent,e.pos,e.index(),t,n);if(r)return r;for(let r=e.depth-1;r>=0;r--){let i=t<0?sV(e.node(0),e.node(r),e.before(r+1),e.index(r),t,n):sV(e.node(0),e.node(r),e.after(r+1),e.index(r)+1,t,n);if(i)return i}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new sH(e.node(0))}static atStart(e){return sV(e,e,0,0,1)||new sH(e)}static atEnd(e){return sV(e,e,e.content.size,e.childCount,-1)||new sH(e)}static fromJSON(e,t){if(!t||!t.type)throw RangeError("Invalid input for Selection.fromJSON");let n=sD[t.type];if(!n)throw RangeError(`No selection type ${t.type} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in sD)throw RangeError("Duplicate use of selection JSON ID "+e);return sD[e]=t,t.prototype.jsonID=e,t}getBookmark(){return sz.between(this.$anchor,this.$head).getBookmark()}}sR.prototype.visible=!0;class sI{constructor(e,t){this.$from=e,this.$to=t}}let sL=!1;function sP(e){sL||e.parent.inlineContent||(sL=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+e.parent.type.name+")"))}class sz extends sR{constructor(e,t=e){sP(e),sP(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let n=e.resolve(t.map(this.head));if(!n.parent.inlineContent)return sR.near(n);let r=e.resolve(t.map(this.anchor));return new sz(r.parent.inlineContent?r:n,n)}replace(e,t=ig.empty){if(super.replace(e,t),t==ig.empty){let t=this.$from.marksAcross(this.$to);t&&e.ensureMarks(t)}}eq(e){return e instanceof sz&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new s$(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if("number"!=typeof t.anchor||"number"!=typeof t.head)throw RangeError("Invalid input for TextSelection.fromJSON");return new sz(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,n=t){let r=e.resolve(t);return new this(r,n==t?r:e.resolve(n))}static between(e,t,n){let r=e.pos-t.pos;if((!n||r)&&(n=r>=0?1:-1),!t.parent.inlineContent){let e=sR.findFrom(t,n,!0)||sR.findFrom(t,-n,!0);if(!e)return sR.near(t,n);t=e.$head}return e.parent.inlineContent||(0==r?e=t:(e=(sR.findFrom(e,-n,!0)||sR.findFrom(e,n,!0)).$anchor).pos<t.pos!=r<0&&(e=t)),new sz(e,t)}}sR.jsonID("text",sz);class s${constructor(e,t){this.anchor=e,this.head=t}map(e){return new s$(e.map(this.anchor),e.map(this.head))}resolve(e){return sz.between(e.resolve(this.anchor),e.resolve(this.head))}}class sB extends sR{constructor(e){let t=e.nodeAfter,n=e.node(0).resolve(e.pos+t.nodeSize);super(e,n),this.node=t}map(e,t){let{deleted:n,pos:r}=t.mapResult(this.anchor),i=e.resolve(r);return n?sR.near(i):new sB(i)}content(){return new ig(ic.from(this.node),0,0)}eq(e){return e instanceof sB&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new sF(this.anchor)}static fromJSON(e,t){if("number"!=typeof t.anchor)throw RangeError("Invalid input for NodeSelection.fromJSON");return new sB(e.resolve(t.anchor))}static create(e,t){return new sB(e.resolve(t))}static isSelectable(e){return!e.isText&&!1!==e.type.spec.selectable}}sB.prototype.visible=!1,sR.jsonID("node",sB);class sF{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:n}=e.mapResult(this.anchor);return t?new s$(n,n):new sF(n)}resolve(e){let t=e.resolve(this.anchor),n=t.nodeAfter;return n&&sB.isSelectable(n)?new sB(t):sR.near(t)}}class sH extends sR{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=ig.empty){if(t==ig.empty){e.delete(0,e.doc.content.size);let t=sR.atStart(e.doc);t.eq(e.selection)||e.setSelection(t)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new sH(e)}map(e){return new sH(e)}eq(e){return e instanceof sH}getBookmark(){return sU}}sR.jsonID("all",sH);let sU={map(){return this},resolve:e=>new sH(e)};function sV(e,t,n,r,i,s=!1){if(t.inlineContent)return sz.create(e,n);for(let o=r-(i>0?0:1);i>0?o<t.childCount:o>=0;o+=i){let r=t.child(o);if(r.isAtom){if(!s&&sB.isSelectable(r))return sB.create(e,n-(i<0?r.nodeSize:0))}else{let t=sV(e,r,n+i,i<0?r.childCount:0,i,s);if(t)return t}n+=r.nodeSize*i}return null}function sW(e,t,n){let r,i=e.steps.length-1;if(i<t)return;let s=e.steps[i];(s instanceof sa||s instanceof sl)&&(e.mapping.maps[i].forEach((e,t,n,i)=>{null==r&&(r=i)}),e.setSelection(sR.near(e.doc.resolve(r),n)))}class sq extends s_{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(1|this.updated)&-3,this.storedMarks=null,this}get selectionSet(){return(1&this.updated)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=2,this}ensureMarks(e){return ih.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(2&this.updated)>0}addStep(e,t){super.addStep(e,t),this.updated=-3&this.updated,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let n=this.selection;return t&&(e=e.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||ih.none))),n.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,n){let r=this.doc.type.schema;if(null==t)return e?this.replaceSelectionWith(r.text(e),!0):this.deleteSelection();{if(null==n&&(n=t),!e)return this.deleteRange(t,n);let i=this.storedMarks;if(!i){let e=this.doc.resolve(t);i=n==t?e.marks():e.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(t,n,r.text(e,i)),this.selection.empty||this.selection.to!=t+e.length||this.setSelection(sR.near(this.selection.$to)),this}}setMeta(e,t){return this.meta["string"==typeof e?e:e.key]=t,this}getMeta(e){return this.meta["string"==typeof e?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=4,this}get scrolledIntoView(){return(4&this.updated)>0}}function sK(e,t){return t&&e?e.bind(t):e}class sG{constructor(e,t,n){this.name=e,this.init=sK(t.init,n),this.apply=sK(t.apply,n)}}let sJ=[new sG("doc",{init:e=>e.doc||e.schema.topNodeType.createAndFill(),apply:e=>e.doc}),new sG("selection",{init:(e,t)=>e.selection||sR.atStart(t.doc),apply:e=>e.selection}),new sG("storedMarks",{init:e=>e.storedMarks||null,apply:(e,t,n,r)=>r.selection.$cursor?e.storedMarks:null}),new sG("scrollToSelection",{init:()=>0,apply:(e,t)=>e.scrolledIntoView?t+1:t})];class sZ{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=sJ.slice(),t&&t.forEach(e=>{if(this.pluginsByKey[e.key])throw RangeError("Adding different instances of a keyed plugin ("+e.key+")");this.plugins.push(e),this.pluginsByKey[e.key]=e,e.spec.state&&this.fields.push(new sG(e.key,e.spec.state,e))})}}class sX{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let n=0;n<this.config.plugins.length;n++)if(n!=t){let t=this.config.plugins[n];if(t.spec.filterTransaction&&!t.spec.filterTransaction.call(t,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],n=this.applyInner(e),r=null;for(;;){let i=!1;for(let s=0;s<this.config.plugins.length;s++){let o=this.config.plugins[s];if(o.spec.appendTransaction){let a=r?r[s].n:0,l=r?r[s].state:this,c=a<t.length&&o.spec.appendTransaction.call(o,a?t.slice(a):t,l,n);if(c&&n.filterTransaction(c,s)){if(c.setMeta("appendedTransaction",e),!r){r=[];for(let e=0;e<this.config.plugins.length;e++)r.push(e<s?{state:n,n:t.length}:{state:this,n:0})}t.push(c),n=n.applyInner(c),i=!0}r&&(r[s]={state:n,n:t.length})}}if(!i)return{state:n,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw RangeError("Applying a mismatched transaction");let t=new sX(this.config),n=this.config.fields;for(let r=0;r<n.length;r++){let i=n[r];t[i.name]=i.apply(e,this[i.name],this,t)}return t}get tr(){return new sq(this)}static create(e){let t=new sZ(e.doc?e.doc.type.schema:e.schema,e.plugins),n=new sX(t);for(let r=0;r<t.fields.length;r++)n[t.fields[r].name]=t.fields[r].init(e,n);return n}reconfigure(e){let t=new sZ(this.schema,e.plugins),n=t.fields,r=new sX(t);for(let t=0;t<n.length;t++){let i=n[t].name;r[i]=this.hasOwnProperty(i)?this[i]:n[t].init(e,r)}return r}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(e=>e.toJSON())),e&&"object"==typeof e)for(let n in e){if("doc"==n||"selection"==n)throw RangeError("The JSON fields `doc` and `selection` are reserved");let r=e[n],i=r.spec.state;i&&i.toJSON&&(t[n]=i.toJSON.call(r,this[r.key]))}return t}static fromJSON(e,t,n){if(!t)throw RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw RangeError("Required config field 'schema' missing");let r=new sZ(e.schema,e.plugins),i=new sX(r);return r.fields.forEach(r=>{if("doc"==r.name)i.doc=iA.fromJSON(e.schema,t.doc);else if("selection"==r.name)i.selection=sR.fromJSON(i.doc,t.selection);else if("storedMarks"==r.name)t.storedMarks&&(i.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(n)for(let s in n){let o=n[s],a=o.spec.state;if(o.key==r.name&&a&&a.fromJSON&&Object.prototype.hasOwnProperty.call(t,s)){i[r.name]=a.fromJSON.call(o,e,t[s],i);return}}i[r.name]=r.init(e,i)}}),i}}class sY{constructor(e){this.spec=e,this.props={},e.props&&function e(t,n,r){for(let i in t){let s=t[i];s instanceof Function?s=s.bind(n):"handleDOMEvents"==i&&(s=e(s,n,{})),r[i]=s}return r}(e.props,this,this.props),this.key=e.key?e.key.key:s0("plugin")}getState(e){return e[this.key]}}let sQ=Object.create(null);function s0(e){return e in sQ?e+"$"+ ++sQ[e]:(sQ[e]=0,e+"$")}class s1{constructor(e="key"){this.key=s0(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}let s2=function(e){for(var t=0;;t++)if(!(e=e.previousSibling))return t},s3=function(e){let t=e.assignedSlot||e.parentNode;return t&&11==t.nodeType?t.host:t},s5=null,s4=function(e,t,n){let r=s5||(s5=document.createRange());return r.setEnd(e,null==n?e.nodeValue.length:n),r.setStart(e,t||0),r},s6=function(){s5=null},s9=function(e,t,n,r){return n&&(s8(e,t,n,r,-1)||s8(e,t,n,r,1))},s7=/^(img|br|input|textarea|hr)$/i;function s8(e,t,n,r,i){for(var s;;){if(e==n&&t==r)return!0;if(t==(i<0?0:oe(e))){let n=e.parentNode;if(!n||1!=n.nodeType||ot(e)||s7.test(e.nodeName)||"false"==e.contentEditable)return!1;t=s2(e)+(i<0?0:1),e=n}else{if(1!=e.nodeType)return!1;let n=e.childNodes[t+(i<0?-1:0)];if(1==n.nodeType&&"false"==n.contentEditable)if(null==(s=n.pmViewDesc)||!s.ignoreForSelection)return!1;else t+=i;else e=n,t=i<0?oe(e):0}}}function oe(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function ot(e){let t;for(let n=e;n&&!(t=n.pmViewDesc);n=n.parentNode);return t&&t.node&&t.node.isBlock&&(t.dom==e||t.contentDOM==e)}let on=function(e){return e.focusNode&&s9(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)};function or(e,t){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=e,n.key=n.code=t,n}let oi="u">typeof navigator?navigator:null,oo="u">typeof document?document:null,oa=oi&&oi.userAgent||"",ol=/Edge\/(\d+)/.exec(oa),oc=/MSIE \d/.exec(oa),od=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(oa),ou=!!(oc||od||ol),op=oc?document.documentMode:od?+od[1]:ol?+ol[1]:0,oh=!ou&&/gecko\/(\d+)/i.test(oa);oh&&(/Firefox\/(\d+)/.exec(oa)||[0,0])[1];let of=!ou&&/Chrome\/(\d+)/.exec(oa),om=!!of,og=of?+of[1]:0,ob=!ou&&!!oi&&/Apple Computer/.test(oi.vendor),ox=ob&&(/Mobile\/\w+/.test(oa)||!!oi&&oi.maxTouchPoints>2),oy=ox||!!oi&&/Mac/.test(oi.platform),ov=!!oi&&/Win/.test(oi.platform),ow=/Android \d/.test(oa),ok=!!oo&&"webkitFontSmoothing"in oo.documentElement.style,oN=ok?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function oS(e,t){return"number"==typeof e?e:e[t]}function oC(e,t,n){let r=e.someProp("scrollThreshold")||0,i=e.someProp("scrollMargin")||5,s=e.dom.ownerDocument;for(let o=n||e.dom;o;){if(1!=o.nodeType){o=s3(o);continue}let e=o,n=e==s.body,a=n?function(e){let t=e.defaultView&&e.defaultView.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.documentElement.clientWidth,top:0,bottom:e.documentElement.clientHeight}}(s):function(e){let t=e.getBoundingClientRect(),n=t.width/e.offsetWidth||1,r=t.height/e.offsetHeight||1;return{left:t.left,right:t.left+e.clientWidth*n,top:t.top,bottom:t.top+e.clientHeight*r}}(e),l=0,c=0;if(t.top<a.top+oS(r,"top")?c=-(a.top-t.top+oS(i,"top")):t.bottom>a.bottom-oS(r,"bottom")&&(c=t.bottom-t.top>a.bottom-a.top?t.top+oS(i,"top")-a.top:t.bottom-a.bottom+oS(i,"bottom")),t.left<a.left+oS(r,"left")?l=-(a.left-t.left+oS(i,"left")):t.right>a.right-oS(r,"right")&&(l=t.right-a.right+oS(i,"right")),l||c)if(n)s.defaultView.scrollBy(l,c);else{let n=e.scrollLeft,r=e.scrollTop;c&&(e.scrollTop+=c),l&&(e.scrollLeft+=l);let i=e.scrollLeft-n,s=e.scrollTop-r;t={left:t.left-i,top:t.top-s,right:t.right-i,bottom:t.bottom-s}}let d=n?"fixed":getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(d))break;o="absolute"==d?o.offsetParent:s3(o)}}function oj(e){let t=[],n=e.ownerDocument;for(let r=e;r&&(t.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),e!=n);r=s3(r));return t}function oE(e,t){for(let n=0;n<e.length;n++){let{dom:r,top:i,left:s}=e[n];r.scrollTop!=i+t&&(r.scrollTop=i+t),r.scrollLeft!=s&&(r.scrollLeft=s)}}let oM=null;function oA(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function oT(e){return e.top<e.bottom||e.left<e.right}function oO(e,t){let n=e.getClientRects();if(n.length){let e=n[t<0?0:n.length-1];if(oT(e))return e}return Array.prototype.find.call(n,oT)||e.getBoundingClientRect()}let o_=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function oD(e,t,n){let{node:r,offset:i,atom:s}=e.docView.domFromPos(t,n<0?-1:1),o=ok||oh;if(3==r.nodeType)if(o&&(o_.test(r.nodeValue)||(n<0?!i:i==r.nodeValue.length))){let e=oO(s4(r,i,i),n);if(oh&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let t=oO(s4(r,i-1,i-1),-1);if(t.top==e.top){let n=oO(s4(r,i,i+1),-1);if(n.top!=e.top)return oR(n,n.left<t.left)}}return e}else{let e=i,t=i,s=n<0?1:-1;return n<0&&!i?(t++,s=-1):n>=0&&i==r.nodeValue.length?(e--,s=1):n<0?e--:t++,oR(oO(s4(r,e,t),s),s<0)}if(!e.state.doc.resolve(t-(s||0)).parent.inlineContent){if(null==s&&i&&(n<0||i==oe(r))){let e=r.childNodes[i-1];if(1==e.nodeType)return oI(e.getBoundingClientRect(),!1)}if(null==s&&i<oe(r)){let e=r.childNodes[i];if(1==e.nodeType)return oI(e.getBoundingClientRect(),!0)}return oI(r.getBoundingClientRect(),n>=0)}if(null==s&&i&&(n<0||i==oe(r))){let e=r.childNodes[i-1],t=3==e.nodeType?s4(e,oe(e)-!o):1!=e.nodeType||"BR"==e.nodeName&&e.nextSibling?null:e;if(t)return oR(oO(t,1),!1)}if(null==s&&i<oe(r)){let e=r.childNodes[i];for(;e.pmViewDesc&&e.pmViewDesc.ignoreForCoords;)e=e.nextSibling;let t=e?3==e.nodeType?s4(e,0,+!o):1==e.nodeType?e:null:null;if(t)return oR(oO(t,-1),!0)}return oR(oO(3==r.nodeType?s4(r):r,-n),n>=0)}function oR(e,t){if(0==e.width)return e;let n=t?e.left:e.right;return{top:e.top,bottom:e.bottom,left:n,right:n}}function oI(e,t){if(0==e.height)return e;let n=t?e.top:e.bottom;return{top:n,bottom:n,left:e.left,right:e.right}}function oL(e,t,n){let r=e.state,i=e.root.activeElement;r!=t&&e.updateState(t),i!=e.dom&&e.focus();try{return n()}finally{r!=t&&e.updateState(r),i!=e.dom&&i&&i.focus()}}let oP=/[\u0590-\u08ac]/,oz=null,o$=null,oB=!1;class oF{constructor(e,t,n,r){this.parent=e,this.children=t,this.dom=n,this.contentDOM=r,this.dirty=0,n.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,n){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,n=this.posAtStart;;t++){let r=this.children[t];if(r==e)return n;n+=r.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,n){let r;if(this.contentDOM&&this.contentDOM.contains(1==e.nodeType?e:e.parentNode))if(n<0){let n,r;if(e==this.contentDOM)n=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.previousSibling}for(;n&&!((r=n.pmViewDesc)&&r.parent==this);)n=n.previousSibling;return n?this.posBeforeChild(r)+r.size:this.posAtStart}else{let n,r;if(e==this.contentDOM)n=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.nextSibling}for(;n&&!((r=n.pmViewDesc)&&r.parent==this);)n=n.nextSibling;return n?this.posBeforeChild(r):this.posAtEnd}if(e==this.dom&&this.contentDOM)r=t>s2(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))r=2&e.compareDocumentPosition(this.contentDOM);else if(this.dom.firstChild){if(0==t)for(let t=e;;t=t.parentNode){if(t==this.dom){r=!1;break}if(t.previousSibling)break}if(null==r&&t==e.childNodes.length)for(let t=e;;t=t.parentNode){if(t==this.dom){r=!0;break}if(t.nextSibling)break}}return(null==r?n>0:r)?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let n=!0,r=e;r;r=r.parentNode){let i=this.getDesc(r),s;if(i&&(!t||i.node))if(!n||!(s=i.nodeDOM)||(1==s.nodeType?s.contains(1==e.nodeType?e:e.parentNode):s==e))return i;else n=!1}}getDesc(e){let t=e.pmViewDesc;for(let e=t;e;e=e.parent)if(e==this)return t}posFromDOM(e,t,n){for(let r=e;r;r=r.parentNode){let i=this.getDesc(r);if(i)return i.localPosFromDOM(e,t,n)}return -1}descAt(e){for(let t=0,n=0;t<this.children.length;t++){let r=this.children[t],i=n+r.size;if(n==e&&i!=n){for(;!r.border&&r.children.length;)for(let e=0;e<r.children.length;e++){let t=r.children[e];if(t.size){r=t;break}}return r}if(e<i)return r.descAt(e-n-r.border);n=i}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let n=0,r=0;for(let t=0;n<this.children.length;n++){let i=this.children[n],s=t+i.size;if(s>e||i instanceof oG){r=e-t;break}t=s}if(r)return this.children[n].domFromPos(r-this.children[n].border,t);for(let e;n&&!(e=this.children[n-1]).size&&e instanceof oH&&e.side>=0;n--);if(t<=0){let e,r=!0;for(;(e=n?this.children[n-1]:null)&&e.dom.parentNode!=this.contentDOM;n--,r=!1);return e&&t&&r&&!e.border&&!e.domAtom?e.domFromPos(e.size,t):{node:this.contentDOM,offset:e?s2(e.dom)+1:0}}{let e,r=!0;for(;(e=n<this.children.length?this.children[n]:null)&&e.dom.parentNode!=this.contentDOM;n++,r=!1);return e&&r&&!e.border&&!e.domAtom?e.domFromPos(0,t):{node:this.contentDOM,offset:e?s2(e.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,n=0){if(0==this.children.length)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let r=-1,i=-1;for(let s=n,o=0;;o++){let n=this.children[o],a=s+n.size;if(-1==r&&e<=a){let i=s+n.border;if(e>=i&&t<=a-n.border&&n.node&&n.contentDOM&&this.contentDOM.contains(n.contentDOM))return n.parseRange(e,t,i);e=s;for(let t=o;t>0;t--){let n=this.children[t-1];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(1)){r=s2(n.dom)+1;break}e-=n.size}-1==r&&(r=0)}if(r>-1&&(a>t||o==this.children.length-1)){t=a;for(let e=o+1;e<this.children.length;e++){let n=this.children[e];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(-1)){i=s2(n.dom);break}t+=n.size}-1==i&&(i=this.contentDOM.childNodes.length);break}s=a}return{node:this.contentDOM,from:e,to:t,fromOffset:r,toOffset:i}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return 0==t.size||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:n}=this.domFromPos(e,0);if(1!=t.nodeType||n==t.childNodes.length)throw RangeError("No node after pos "+e);return t.childNodes[n]}setSelection(e,t,n,r=!1){let i=Math.min(e,t),s=Math.max(e,t);for(let o=0,a=0;o<this.children.length;o++){let l=this.children[o],c=a+l.size;if(i>a&&s<c)return l.setSelection(e-a-l.border,t-a-l.border,n,r);a=c}let o=this.domFromPos(e,e?-1:1),a=t==e?o:this.domFromPos(t,t?-1:1),l=n.root.getSelection(),c=n.domSelectionRange(),d=!1;if((oh||ob)&&e==t){let{node:e,offset:t}=o;if(3==e.nodeType){if((d=!!(t&&"\n"==e.nodeValue[t-1]))&&t==e.nodeValue.length)for(let t=e,n;t;t=t.parentNode){if(n=t.nextSibling){"BR"==n.nodeName&&(o=a={node:n.parentNode,offset:s2(n)+1});break}let e=t.pmViewDesc;if(e&&e.node&&e.node.isBlock)break}}else{let n=e.childNodes[t-1];d=n&&("BR"==n.nodeName||"false"==n.contentEditable)}}if(oh&&c.focusNode&&c.focusNode!=a.node&&1==c.focusNode.nodeType){let e=c.focusNode.childNodes[c.focusOffset];e&&"false"==e.contentEditable&&(r=!0)}if(!(r||d&&ob)&&s9(o.node,o.offset,c.anchorNode,c.anchorOffset)&&s9(a.node,a.offset,c.focusNode,c.focusOffset))return;let u=!1;if((l.extend||e==t)&&!(d&&oh)){l.collapse(o.node,o.offset);try{e!=t&&l.extend(a.node,a.offset),u=!0}catch(e){}}if(!u){if(e>t){let e=o;o=a,a=e}let n=document.createRange();n.setEnd(a.node,a.offset),n.setStart(o.node,o.offset),l.removeAllRanges(),l.addRange(n)}}ignoreMutation(e){return!this.contentDOM&&"selection"!=e.type}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let n=0,r=0;r<this.children.length;r++){let i=this.children[r],s=n+i.size;if(n==s?e<=s&&t>=n:e<s&&t>n){let r=n+i.border,o=s-i.border;if(e>=r&&t<=o){this.dirty=e==n||t==s?2:1,e==r&&t==o&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=3:i.markDirty(e-r,t-r);return}i.dirty=i.dom!=i.contentDOM||i.dom.parentNode!=this.contentDOM||i.children.length?3:2}n=s}this.dirty=2}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let n=1==e?2:1;t.dirty<n&&(t.dirty=n)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class oH extends oF{constructor(e,t,n,r){let i,s=t.type.toDOM;if("function"==typeof s&&(s=s(n,()=>i?i.parent?i.parent.posBeforeChild(i):void 0:r)),!t.type.spec.raw){if(1!=s.nodeType){let e=document.createElement("span");e.appendChild(s),s=e}s.contentEditable="false",s.classList.add("ProseMirror-widget")}super(e,[],s,null),this.widget=t,this.widget=t,i=this}matchesWidget(e){return 0==this.dirty&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return!!t&&t(e)}ignoreMutation(e){return"selection"!=e.type||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class oU extends oF{constructor(e,t,n,r){super(e,[],t,null),this.textDOM=n,this.text=r}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return"characterData"===e.type&&e.target.nodeValue==e.oldValue}}class oV extends oF{constructor(e,t,n,r,i){super(e,[],n,r),this.mark=t,this.spec=i}static create(e,t,n,r){let i=r.nodeViews[t.type.name],s=i&&i(t,r,n);return s&&s.dom||(s=i1.renderSpec(document,t.type.spec.toDOM(t,n),null,t.attrs)),new oV(e,t,s.dom,s.contentDOM||s.dom,s)}parseRule(){return 3&this.dirty||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return 3!=this.dirty&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),0!=this.dirty){let e=this.parent;for(;!e.node;)e=e.parent;e.dirty<this.dirty&&(e.dirty=this.dirty),this.dirty=0}}slice(e,t,n){let r=oV.create(this.parent,this.mark,!0,n),i=this.children,s=this.size;t<s&&(i=o4(i,t,s,n)),e>0&&(i=o4(i,0,e,n));for(let e=0;e<i.length;e++)i[e].parent=r;return r.children=i,r}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class oW extends oF{constructor(e,t,n,r,i,s,o,a,l){super(e,[],i,s),this.node=t,this.outerDeco=n,this.innerDeco=r,this.nodeDOM=o}static create(e,t,n,r,i,s){let o=i.nodeViews[t.type.name],a,l=o&&o(t,i,()=>a?a.parent?a.parent.posBeforeChild(a):void 0:s,n,r),c=l&&l.dom,d=l&&l.contentDOM;if(t.isText)if(c){if(3!=c.nodeType)throw RangeError("Text must be rendered as a DOM text node")}else c=document.createTextNode(t.text);else if(!c){let e=i1.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs);({dom:c,contentDOM:d}=e)}d||t.isText||"BR"==c.nodeName||(c.hasAttribute("contenteditable")||(c.contentEditable="false"),t.type.spec.draggable&&(c.draggable=!0));let u=c;return(c=o0(c,n,t),l)?a=new oJ(e,t,n,r,c,d||null,u,l,i,s+1):t.isText?new oK(e,t,n,r,c,u,i):new oW(e,t,n,r,c,d||null,u,i,s+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if("pre"==this.node.type.whitespace&&(e.preserveWhitespace="full"),this.contentDOM)if(this.contentLost){for(let t=this.children.length-1;t>=0;t--){let n=this.children[t];if(this.dom.contains(n.dom.parentNode)){e.contentElement=n.dom.parentNode;break}}e.contentElement||(e.getContent=()=>ic.empty)}else e.contentElement=this.contentDOM;else e.getContent=()=>this.node.content;return e}matchesNode(e,t,n){return 0==this.dirty&&e.eq(this.node)&&o1(t,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return+!this.node.isLeaf}updateChildren(e,t){let n=this.node.inlineContent,r=t,i=e.composing?this.localCompositionInfo(e,t):null,s=i&&i.pos>-1?i:null,o=i&&i.pos<0,a=new o3(this,s&&s.node,e);(function(e,t,n,r){let i=t.locals(e),s=0;if(0==i.length){for(let n=0;n<e.childCount;n++){let o=e.child(n);r(o,i,t.forChild(s,o),n),s+=o.nodeSize}return}let o=0,a=[],l=null;for(let c=0;;){let d,u,p,h;for(;o<i.length&&i[o].to==s;){let e=i[o++];e.widget&&(d?(u||(u=[d])).push(e):d=e)}if(d)if(u){u.sort(o5);for(let e=0;e<u.length;e++)n(u[e],c,!!l)}else n(d,c,!!l);if(l)h=-1,p=l,l=null;else if(c<e.childCount)h=c,p=e.child(c++);else break;for(let e=0;e<a.length;e++)a[e].to<=s&&a.splice(e--,1);for(;o<i.length&&i[o].from<=s&&i[o].to>s;)a.push(i[o++]);let f=s+p.nodeSize;if(p.isText){let e=f;o<i.length&&i[o].from<e&&(e=i[o].from);for(let t=0;t<a.length;t++)a[t].to<e&&(e=a[t].to);e<f&&(l=p.cut(e-s),p=p.cut(0,e-s),f=e,h=-1)}else for(;o<i.length&&i[o].to<f;)o++;let m=p.isInline&&!p.isLeaf?a.filter(e=>!e.inline):a.slice();r(p,m,t.forChild(s,p),h),s=f}})(this.node,this.innerDeco,(t,i,s)=>{t.spec.marks?a.syncToMarks(t.spec.marks,n,e,i):t.type.side>=0&&!s&&a.syncToMarks(i==this.node.childCount?ih.none:this.node.child(i).marks,n,e,i),a.placeWidget(t,e,r)},(t,s,l,c)=>{let d;a.syncToMarks(t.marks,n,e,c),a.findNodeMatch(t,s,l,c)||o&&e.state.selection.from>r&&e.state.selection.to<r+t.nodeSize&&(d=a.findIndexWithChild(i.node))>-1&&a.updateNodeAt(t,s,l,d,e)||a.updateNextNode(t,s,l,e,c,r)||a.addNode(t,s,l,e,r),r+=t.nodeSize}),a.syncToMarks([],n,e,0),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||2==this.dirty)&&(s&&this.protectLocalComposition(e,s),function e(t,n,r){let i=t.firstChild,s=!1;for(let o=0;o<n.length;o++){let a=n[o],l=a.dom;if(l.parentNode==t){for(;l!=i;)i=o2(i),s=!0;i=i.nextSibling}else s=!0,t.insertBefore(l,i);if(a instanceof oV){let n=i?i.previousSibling:t.lastChild;e(a.contentDOM,a.children,r),i=n?n.nextSibling:t.firstChild}}for(;i;)i=o2(i),s=!0;s&&r.trackWrites==t&&(r.trackWrites=null)}(this.contentDOM,this.children,e),ox&&function(e){if("UL"==e.nodeName||"OL"==e.nodeName){let t=e.style.cssText;e.style.cssText=t+"; list-style: square !important",window.getComputedStyle(e).listStyle,e.style.cssText=t}}(this.dom))}localCompositionInfo(e,t){let{from:n,to:r}=e.state.selection;if(!(e.state.selection instanceof sz)||n<t||r>t+this.node.content.size)return null;let i=e.input.compositionNode;if(!i||!this.dom.contains(i.parentNode))return null;if(!this.node.inlineContent)return{node:i,pos:-1,text:""};{let e=i.nodeValue,s=function(e,t,n,r){for(let i=0,s=0;i<e.childCount&&s<=r;){let o=e.child(i++),a=s;if(s+=o.nodeSize,!o.isText)continue;let l=o.text;for(;i<e.childCount;){let t=e.child(i++);if(s+=t.nodeSize,!t.isText)break;l+=t.text}if(s>=n){if(s>=r&&l.slice(r-t.length-a,r-a)==t)return r-t.length;let e=a<r?l.lastIndexOf(t,r-a-1):-1;if(e>=0&&e+t.length+a>=n)return a+e;if(n==r&&l.length>=r+t.length-a&&l.slice(r-a,r-a+t.length)==t)return r}}return -1}(this.node.content,e,n-t,r-t);return s<0?null:{node:i,pos:s,text:e}}}protectLocalComposition(e,{node:t,pos:n,text:r}){if(this.getDesc(t))return;let i=t;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&(i.pmViewDesc=void 0)}let s=new oU(this,i,t,r);e.input.compositionNodes.push(s),this.children=o4(this.children,n,n+r.length,e,s)}update(e,t,n,r){return 3!=this.dirty&&!!e.sameMarkup(this.node)&&(this.updateInner(e,t,n,r),!0)}updateInner(e,t,n,r){this.updateOuterDeco(t),this.node=e,this.innerDeco=n,this.contentDOM&&this.updateChildren(r,this.posAtStart),this.dirty=0}updateOuterDeco(e){if(o1(e,this.outerDeco))return;let t=1!=this.nodeDOM.nodeType,n=this.dom;this.dom=oQ(this.dom,this.nodeDOM,oY(this.outerDeco,this.node,t),oY(e,this.node,t)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){1==this.nodeDOM.nodeType&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){1==this.nodeDOM.nodeType&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function oq(e,t,n,r,i){o0(r,t,e);let s=new oW(void 0,e,t,n,r,r,r,i,0);return s.contentDOM&&s.updateChildren(i,0),s}class oK extends oW{constructor(e,t,n,r,i,s,o){super(e,t,n,r,i,null,s,o,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,n,r){return 3!=this.dirty&&(0==this.dirty||!!this.inParent())&&!!e.sameMarkup(this.node)&&(this.updateOuterDeco(t),(0!=this.dirty||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,r.trackWrites==this.nodeDOM&&(r.trackWrites=null)),this.node=e,this.dirty=0,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,n){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,n)}ignoreMutation(e){return"characterData"!=e.type&&"selection"!=e.type}slice(e,t,n){let r=this.node.cut(e,t),i=document.createTextNode(r.text);return new oK(this.parent,r,this.outerDeco,this.innerDeco,i,i,n)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(0==e||t==this.nodeDOM.nodeValue.length)&&(this.dirty=3)}get domAtom(){return!1}isText(e){return this.node.text==e}}class oG extends oF{parseRule(){return{ignore:!0}}matchesHack(e){return 0==this.dirty&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return"IMG"==this.dom.nodeName}}class oJ extends oW{constructor(e,t,n,r,i,s,o,a,l,c){super(e,t,n,r,i,s,o,l,c),this.spec=a}update(e,t,n,r){if(3==this.dirty)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let i=this.spec.update(e,t,n);return i&&this.updateInner(e,t,n,r),i}return(!!this.contentDOM||!!e.isLeaf)&&super.update(e,t,n,r)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,n,r){this.spec.setSelection?this.spec.setSelection(e,t,n.root):super.setSelection(e,t,n,r)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return!!this.spec.stopEvent&&this.spec.stopEvent(e)}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}let oZ=function(e){e&&(this.nodeName=e)};oZ.prototype=Object.create(null);let oX=[new oZ];function oY(e,t,n){if(0==e.length)return oX;let r=n?oX[0]:new oZ,i=[r];for(let s=0;s<e.length;s++){let o=e[s].type.attrs;if(o)for(let e in o.nodeName&&i.push(r=new oZ(o.nodeName)),o){let s=o[e];null!=s&&(n&&1==i.length&&i.push(r=new oZ(t.isInline?"span":"div")),"class"==e?r.class=(r.class?r.class+" ":"")+s:"style"==e?r.style=(r.style?r.style+";":"")+s:"nodeName"!=e&&(r[e]=s))}}return i}function oQ(e,t,n,r){if(n==oX&&r==oX)return t;let i=t;for(let t=0;t<r.length;t++){let s=r[t],o=n[t];if(t){let t;o&&o.nodeName==s.nodeName&&i!=e&&(t=i.parentNode)&&t.nodeName.toLowerCase()==s.nodeName||((t=document.createElement(s.nodeName)).pmIsDeco=!0,t.appendChild(i),o=oX[0]),i=t}!function(e,t,n){for(let r in t)"class"==r||"style"==r||"nodeName"==r||r in n||e.removeAttribute(r);for(let r in n)"class"!=r&&"style"!=r&&"nodeName"!=r&&n[r]!=t[r]&&e.setAttribute(r,n[r]);if(t.class!=n.class){let r=t.class?t.class.split(" ").filter(Boolean):[],i=n.class?n.class.split(" ").filter(Boolean):[];for(let t=0;t<r.length;t++)-1==i.indexOf(r[t])&&e.classList.remove(r[t]);for(let t=0;t<i.length;t++)-1==r.indexOf(i[t])&&e.classList.add(i[t]);0==e.classList.length&&e.removeAttribute("class")}if(t.style!=n.style){if(t.style){let n=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,r;for(;r=n.exec(t.style);)e.style.removeProperty(r[1])}n.style&&(e.style.cssText+=n.style)}}(i,o||oX[0],s)}return i}function o0(e,t,n){return oQ(e,e,oX,oY(t,n,1!=e.nodeType))}function o1(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].type.eq(t[n].type))return!1;return!0}function o2(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}class o3{constructor(e,t,n){this.lock=t,this.view=n,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=function(e,t){let n=t,r=n.children.length,i=e.childCount,s=new Map,o=[];n:for(;i>0;){let a;for(;;)if(r){let e=n.children[r-1];if(e instanceof oV)n=e,r=e.children.length;else{a=e,r--;break}}else if(n==t)break n;else r=n.parent.children.indexOf(n),n=n.parent;let l=a.node;if(l){if(l!=e.child(i-1))break;--i,s.set(a,i),o.push(a)}}return{index:i,matched:s,matches:o.reverse()}}(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let n=e;n<t;n++)this.top.children[n].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,n,r){let i=0,s=this.stack.length>>1,o=Math.min(s,e.length);for(;i<o&&(i==s-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&!1!==e[i].type.spec.spanning;)i++;for(;i<s;)this.destroyRest(),this.top.dirty=0,this.index=this.stack.pop(),this.top=this.stack.pop(),s--;for(;s<e.length;){this.stack.push(this.top,this.index+1);let i=-1,o=this.top.children.length;r<this.preMatch.index&&(o=Math.min(this.index+3,o));for(let t=this.index;t<o;t++){let n=this.top.children[t];if(n.matchesMark(e[s])&&!this.isLocked(n.dom)){i=t;break}}if(i>-1)i>this.index&&(this.changed=!0,this.destroyBetween(this.index,i)),this.top=this.top.children[this.index];else{let r=oV.create(this.top,e[s],t,n);this.top.children.splice(this.index,0,r),this.top=r,this.changed=!0}this.index=0,s++}}findNodeMatch(e,t,n,r){let i=-1,s;if(r>=this.preMatch.index&&(s=this.preMatch.matches[r-this.preMatch.index]).parent==this.top&&s.matchesNode(e,t,n))i=this.top.children.indexOf(s,this.index);else for(let r=this.index,s=Math.min(this.top.children.length,r+5);r<s;r++){let s=this.top.children[r];if(s.matchesNode(e,t,n)&&!this.preMatch.matched.has(s)){i=r;break}}return!(i<0)&&(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(e,t,n,r,i){let s=this.top.children[r];return 3==s.dirty&&s.dom==s.contentDOM&&(s.dirty=2),!!s.update(e,t,n,i)&&(this.destroyBetween(this.index,r),this.index++,!0)}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return -1;if(t==this.top.contentDOM){let t=e.pmViewDesc;if(t){for(let e=this.index;e<this.top.children.length;e++)if(this.top.children[e]==t)return e}return -1}e=t}}updateNextNode(e,t,n,r,i,s){for(let o=this.index;o<this.top.children.length;o++){let a=this.top.children[o];if(a instanceof oW){let l=this.preMatch.matched.get(a);if(null!=l&&l!=i)return!1;let c=a.dom,d,u=this.isLocked(c)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&3!=a.dirty&&o1(t,a.outerDeco));if(!u&&a.update(e,t,n,r))return this.destroyBetween(this.index,o),a.dom!=c&&(this.changed=!0),this.index++,!0;if(!u&&(d=this.recreateWrapper(a,e,t,n,r,s)))return this.destroyBetween(this.index,o),this.top.children[this.index]=d,d.contentDOM&&(d.dirty=2,d.updateChildren(r,s+1),d.dirty=0),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,n,r,i,s){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!o1(n,e.outerDeco)||!r.eq(e.innerDeco))return null;let o=oW.create(this.top,t,n,r,i,s);if(o.contentDOM)for(let t of(o.children=e.children,e.children=[],o.children))t.parent=o;return e.destroy(),o}addNode(e,t,n,r,i){let s=oW.create(this.top,e,t,n,r,i);s.contentDOM&&s.updateChildren(r,i+1),this.top.children.splice(this.index++,0,s),this.changed=!0}placeWidget(e,t,n){let r=this.index<this.top.children.length?this.top.children[this.index]:null;if(r&&r.matchesWidget(e)&&(e==r.widget||!r.widget.type.toDOM.parentNode))this.index++;else{let r=new oH(this.top,e,t,n);this.top.children.splice(this.index++,0,r),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof oV;)e=(t=e).children[t.children.length-1];(!e||!(e instanceof oK)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((ob||om)&&e&&"false"==e.dom.contentEditable&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let n=document.createElement(e);"IMG"==e&&(n.className="ProseMirror-separator",n.alt=""),"BR"==e&&(n.className="ProseMirror-trailingBreak");let r=new oG(this.top,[],n,null);t!=this.top?t.children.push(r):t.children.splice(this.index++,0,r),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||1==e.nodeType&&e.contains(this.lock.parentNode))}}function o5(e,t){return e.type.side-t.type.side}function o4(e,t,n,r,i){let s=[];for(let o=0,a=0;o<e.length;o++){let l=e[o],c=a,d=a+=l.size;c>=n||d<=t?s.push(l):(c<t&&s.push(l.slice(0,t-c,r)),i&&(s.push(i),i=void 0),d>n&&s.push(l.slice(n-c,l.size,r)))}return s}function o6(e,t=null){let n=e.domSelectionRange(),r=e.state.doc;if(!n.focusNode)return null;let i=e.docView.nearestDesc(n.focusNode),s=i&&0==i.size,o=e.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(o<0)return null;let a=r.resolve(o),l,c;if(on(n)){for(l=o;i&&!i.node;)i=i.parent;let e=i.node;if(i&&e.isAtom&&sB.isSelectable(e)&&i.parent&&!(e.isInline&&function(e,t,n){for(let r=0==t,i=t==oe(e);r||i;){if(e==n)return!0;let t=s2(e);if(!(e=e.parentNode))return!1;r=r&&0==t,i=i&&t==oe(e)}}(n.focusNode,n.focusOffset,i.dom))){let e=i.posBefore;c=new sB(o==e?a:r.resolve(e))}}else{if(n instanceof e.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let t=o,i=o;for(let r=0;r<n.rangeCount;r++){let s=n.getRangeAt(r);t=Math.min(t,e.docView.posFromDOM(s.startContainer,s.startOffset,1)),i=Math.max(i,e.docView.posFromDOM(s.endContainer,s.endOffset,-1))}if(t<0)return null;[l,o]=i==e.state.selection.anchor?[i,t]:[t,i],a=r.resolve(o)}else l=e.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(l<0)return null}let d=r.resolve(l);if(!c){let n="pointer"==t||e.state.selection.head<a.pos&&!s?1:-1;c=as(e,d,a,n)}return c}function o9(e){return e.editable?e.hasFocus():aa(e)&&document.activeElement&&document.activeElement.contains(e.dom)}function o7(e,t=!1){let n=e.state.selection;if(ar(e,n),o9(e)){if(!t&&e.input.mouseDown&&e.input.mouseDown.allowDefault&&om){let t=e.domSelectionRange(),n=e.domObserver.currentSelection;if(t.anchorNode&&n.anchorNode&&s9(t.anchorNode,t.anchorOffset,n.anchorNode,n.anchorOffset)){e.input.mouseDown.delayedSelectionSync=!0,e.domObserver.setCurSelection();return}}if(e.domObserver.disconnectSelection(),e.cursorWrapper)!function(e){let t=e.domSelection();if(!t)return;let n=e.cursorWrapper.dom,r="IMG"==n.nodeName;r?t.collapse(n.parentNode,s2(n)+1):t.collapse(n,0),!r&&!e.state.selection.visible&&ou&&op<=11&&(n.disabled=!0,n.disabled=!1)}(e);else{var r;let i,s,o,a,{anchor:l,head:c}=n,d,u;o8&&!(n instanceof sz)&&(n.$from.parent.inlineContent||(d=ae(e,n.from)),n.empty||n.$from.parent.inlineContent||(u=ae(e,n.to))),e.docView.setSelection(l,c,e,t),o8&&(d&&an(d),u&&an(u)),n.visible?e.dom.classList.remove("ProseMirror-hideselection"):(e.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&((i=(r=e).dom.ownerDocument).removeEventListener("selectionchange",r.input.hideSelectionGuard),o=(s=r.domSelectionRange()).anchorNode,a=s.anchorOffset,i.addEventListener("selectionchange",r.input.hideSelectionGuard=()=>{(s.anchorNode!=o||s.anchorOffset!=a)&&(i.removeEventListener("selectionchange",r.input.hideSelectionGuard),setTimeout(()=>{(!o9(r)||r.state.selection.visible)&&r.dom.classList.remove("ProseMirror-hideselection")},20))})))}e.domObserver.setCurSelection(),e.domObserver.connectSelection()}}let o8=ob||om&&og<63;function ae(e,t){let{node:n,offset:r}=e.docView.domFromPos(t,0),i=r<n.childNodes.length?n.childNodes[r]:null,s=r?n.childNodes[r-1]:null;if(ob&&i&&"false"==i.contentEditable)return at(i);if((!i||"false"==i.contentEditable)&&(!s||"false"==s.contentEditable)){if(i)return at(i);else if(s)return at(s)}}function at(e){return e.contentEditable="true",ob&&e.draggable&&(e.draggable=!1,e.wasDraggable=!0),e}function an(e){e.contentEditable="false",e.wasDraggable&&(e.draggable=!0,e.wasDraggable=null)}function ar(e,t){if(t instanceof sB){let n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&(ai(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else ai(e)}function ai(e){e.lastSelectedViewDesc&&(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),e.lastSelectedViewDesc=void 0)}function as(e,t,n,r){return e.someProp("createSelectionBetween",r=>r(e,t,n))||sz.between(t,n,r)}function ao(e){return(!e.editable||!!e.hasFocus())&&aa(e)}function aa(e){let t=e.domSelectionRange();if(!t.anchorNode)return!1;try{return e.dom.contains(3==t.anchorNode.nodeType?t.anchorNode.parentNode:t.anchorNode)&&(e.editable||e.dom.contains(3==t.focusNode.nodeType?t.focusNode.parentNode:t.focusNode))}catch(e){return!1}}function al(e,t){let{$anchor:n,$head:r}=e.selection,i=t>0?n.max(r):n.min(r),s=i.parent.inlineContent?i.depth?e.doc.resolve(t>0?i.after():i.before()):null:i;return s&&sR.findFrom(s,t)}function ac(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function ad(e,t,n){let r=e.state.selection;if(r instanceof sz){if(n.indexOf("s")>-1){let{$head:n}=r,i=n.textOffset?null:t<0?n.nodeBefore:n.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let s=e.state.doc.resolve(n.pos+i.nodeSize*(t<0?-1:1));return ac(e,new sz(r.$anchor,s))}else if(!r.empty)return!1;else if(e.endOfTextblock(t>0?"forward":"backward")){let n=al(e.state,t);return!!n&&n instanceof sB&&ac(e,n)}else if(!(oy&&n.indexOf("m")>-1)){let n=r.$head,i=n.textOffset?null:t<0?n.nodeBefore:n.nodeAfter,s;if(!i||i.isText)return!1;let o=t<0?n.pos-i.nodeSize:n.pos;return!!(i.isAtom||(s=e.docView.descAt(o))&&!s.contentDOM)&&(sB.isSelectable(i)?ac(e,new sB(t<0?e.state.doc.resolve(n.pos-i.nodeSize):n)):!!ok&&ac(e,new sz(e.state.doc.resolve(t<0?o:o+i.nodeSize))))}}else{if(r instanceof sB&&r.node.isInline)return ac(e,new sz(t>0?r.$to:r.$from));let n=al(e.state,t);return!!n&&ac(e,n)}}function au(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function ap(e,t){let n=e.pmViewDesc;return n&&0==n.size&&(t<0||e.nextSibling||"BR"!=e.nodeName)}function ah(e,t){return t<0?function(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let i,s,o=!1;for(oh&&1==n.nodeType&&r<au(n)&&ap(n.childNodes[r],-1)&&(o=!0);;)if(r>0)if(1!=n.nodeType)break;else{let e=n.childNodes[r-1];if(ap(e,-1))i=n,s=--r;else if(3==e.nodeType)r=(n=e).nodeValue.length;else break}else if(af(n))break;else{let t=n.previousSibling;for(;t&&ap(t,-1);)i=n.parentNode,s=s2(t),t=t.previousSibling;if(t)r=au(n=t);else{if((n=n.parentNode)==e.dom)break;r=0}}o?am(e,n,r):i&&am(e,i,s)}(e):function(e){let t,n,r=e.domSelectionRange(),i=r.focusNode,s=r.focusOffset;if(!i)return;let o=au(i);for(;;)if(s<o){if(1!=i.nodeType)break;if(ap(i.childNodes[s],1))t=i,n=++s;else break}else if(af(i))break;else{let r=i.nextSibling;for(;r&&ap(r,1);)t=r.parentNode,n=s2(r)+1,r=r.nextSibling;if(r)s=0,o=au(i=r);else{if((i=i.parentNode)==e.dom)break;s=o=0}}t&&am(e,t,n)}(e)}function af(e){let t=e.pmViewDesc;return t&&t.node&&t.node.isBlock}function am(e,t,n){if(3!=t.nodeType){let e,r;(r=function(e,t){for(;e&&t==e.childNodes.length&&!ot(e);)t=s2(e)+1,e=e.parentNode;for(;e&&t<e.childNodes.length;){let n=e.childNodes[t];if(3==n.nodeType)return n;if(1==n.nodeType&&"false"==n.contentEditable)break;e=n,t=0}}(t,n))?(t=r,n=0):(e=function(e,t){for(;e&&!t&&!ot(e);)t=s2(e),e=e.parentNode;for(;e&&t;){let n=e.childNodes[t-1];if(3==n.nodeType)return n;if(1==n.nodeType&&"false"==n.contentEditable)break;t=(e=n).childNodes.length}}(t,n))&&(t=e,n=e.nodeValue.length)}let r=e.domSelection();if(!r)return;if(on(r)){let e=document.createRange();e.setEnd(t,n),e.setStart(t,n),r.removeAllRanges(),r.addRange(e)}else r.extend&&r.extend(t,n);e.domObserver.setCurSelection();let{state:i}=e;setTimeout(()=>{e.state==i&&o7(e)},50)}function ag(e,t){let n=e.state.doc.resolve(t);if(!(om||ov)&&n.parent.inlineContent){let r=e.coordsAtPos(t);if(t>n.start()){let n=e.coordsAtPos(t-1),i=(n.top+n.bottom)/2;if(i>r.top&&i<r.bottom&&Math.abs(n.left-r.left)>1)return n.left<r.left?"ltr":"rtl"}if(t<n.end()){let n=e.coordsAtPos(t+1),i=(n.top+n.bottom)/2;if(i>r.top&&i<r.bottom&&Math.abs(n.left-r.left)>1)return n.left>r.left?"ltr":"rtl"}}return"rtl"==getComputedStyle(e.dom).direction?"rtl":"ltr"}function ab(e,t,n){let r=e.state.selection;if(r instanceof sz&&!r.empty||n.indexOf("s")>-1||oy&&n.indexOf("m")>-1)return!1;let{$from:i,$to:s}=r;if(!i.parent.inlineContent||e.endOfTextblock(t<0?"up":"down")){let n=al(e.state,t);if(n&&n instanceof sB)return ac(e,n)}if(!i.parent.inlineContent){let n=t<0?i:s,o=r instanceof sH?sR.near(n,t):sR.findFrom(n,t);return!!o&&ac(e,o)}return!1}function ax(e,t){if(!(e.state.selection instanceof sz))return!0;let{$head:n,$anchor:r,empty:i}=e.state.selection;if(!n.sameParent(r))return!0;if(!i)return!1;if(e.endOfTextblock(t>0?"forward":"backward"))return!0;let s=!n.textOffset&&(t<0?n.nodeBefore:n.nodeAfter);if(s&&!s.isText){let r=e.state.tr;return t<0?r.delete(n.pos-s.nodeSize,n.pos):r.delete(n.pos,n.pos+s.nodeSize),e.dispatch(r),!0}return!1}function ay(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function av(e,t){e.someProp("transformCopied",n=>{t=n(t,e)});let n=[],{content:r,openStart:i,openEnd:s}=t;for(;i>1&&s>1&&1==r.childCount&&1==r.firstChild.childCount;){i--,s--;let e=r.firstChild;n.push(e.type.name,e.attrs!=e.type.defaultAttrs?e.attrs:null),r=e.content}let o=e.someProp("clipboardSerializer")||i1.fromSchema(e.state.schema),a=aM(),l=a.createElement("div");l.appendChild(o.serializeFragment(r,{document:a}));let c=l.firstChild,d,u=0;for(;c&&1==c.nodeType&&(d=aj[c.nodeName.toLowerCase()]);){for(let e=d.length-1;e>=0;e--){let t=a.createElement(d[e]);for(;l.firstChild;)t.appendChild(l.firstChild);l.appendChild(t),u++}c=l.firstChild}return c&&1==c.nodeType&&c.setAttribute("data-pm-slice",`${i} ${s}${u?` -${u}`:""} ${JSON.stringify(n)}`),{dom:l,text:e.someProp("clipboardTextSerializer",n=>n(t,e))||t.content.textBetween(0,t.content.size,"\n\n"),slice:t}}function aw(e,t,n,r,i){let s,o,a=i.parent.type.spec.code;if(!n&&!t)return null;let l=!!t&&(r||a||!n);if(l){if(e.someProp("transformPastedText",n=>{t=n(t,a||r,e)}),a)return o=new ig(ic.from(e.state.schema.text(t.replace(/\r\n?/g,"\n"))),0,0),e.someProp("transformPasted",t=>{o=t(o,e,!0)}),o;let n=e.someProp("clipboardTextParser",n=>n(t,i,r,e));if(n)o=n;else{let n=i.marks(),{schema:r}=e.state,o=i1.fromSchema(r);s=document.createElement("div"),t.split(/(?:\r\n?|\n)+/).forEach(e=>{let t=s.appendChild(document.createElement("p"));e&&t.appendChild(o.serializeNode(r.text(e,n)))})}}else e.someProp("transformPastedHTML",t=>{n=t(n,e)}),s=function(e){var t;let n,r=/^(\s*<meta [^>]*>)*/.exec(e);r&&(e=e.slice(r[0].length));let i=aM().createElement("div"),s=/<([a-z][^>\s]+)/i.exec(e),o;if((o=s&&aj[s[1].toLowerCase()])&&(e=o.map(e=>"<"+e+">").join("")+e+o.map(e=>"</"+e+">").reverse().join("")),i.innerHTML=(t=e,(n=window.trustedTypes)?(aA||(aA=n.defaultPolicy||n.createPolicy("ProseMirrorClipboard",{createHTML:e=>e})),aA.createHTML(t)):t),o)for(let e=0;e<o.length;e++)i=i.querySelector(o[e])||i;return i}(n),ok&&function(e){let t=e.querySelectorAll(om?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<t.length;n++){let r=t[n];1==r.childNodes.length&&" "==r.textContent&&r.parentNode&&r.parentNode.replaceChild(e.ownerDocument.createTextNode(" "),r)}}(s);let c=s&&s.querySelector("[data-pm-slice]"),d=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(d&&d[3])for(let e=+d[3];e>0;e--){let e=s.firstChild;for(;e&&1!=e.nodeType;)e=e.nextSibling;if(!e)break;s=e}if(o||(o=(e.someProp("clipboardParser")||e.someProp("domParser")||iq.fromSchema(e.state.schema)).parseSlice(s,{preserveWhitespace:!!(l||d),context:i,ruleFromNode:e=>"BR"!=e.nodeName||e.nextSibling||!e.parentNode||ak.test(e.parentNode.nodeName)?null:{ignore:!0}})),d)o=function(e,t){if(!e.size)return e;let n=e.content.firstChild.type.schema,r;try{r=JSON.parse(t)}catch(t){return e}let{content:i,openStart:s,openEnd:o}=e;for(let e=r.length-2;e>=0;e-=2){let t=n.nodes[r[e]];if(!t||t.hasRequiredAttrs())break;i=ic.from(t.create(r[e+1],i)),s++,o++}return new ig(i,s,o)}(aC(o,+d[1],+d[2]),d[4]);else if((o=ig.maxOpen(function(e,t){if(e.childCount<2)return e;for(let n=t.depth;n>=0;n--){let r=t.node(n).contentMatchAt(t.index(n)),i,s=[];if(e.forEach(e=>{if(!s)return;let t=r.findWrapping(e.type),n;if(!t)return s=null;if(n=s.length&&i.length&&function e(t,n,r,i,s){if(s<t.length&&s<n.length&&t[s]==n[s]){let o=e(t,n,r,i.lastChild,s+1);if(o)return i.copy(i.content.replaceChild(i.childCount-1,o));if(i.contentMatchAt(i.childCount).matchType(s==t.length-1?r.type:t[s+1]))return i.copy(i.content.append(ic.from(aN(r,t,s+1))))}}(t,i,e,s[s.length-1],0))s[s.length-1]=n;else{s.length&&(s[s.length-1]=function e(t,n){if(0==n)return t;let r=t.content.replaceChild(t.childCount-1,e(t.lastChild,n-1)),i=t.contentMatchAt(t.childCount).fillBefore(ic.empty,!0);return t.copy(r.append(i))}(s[s.length-1],i.length));let n=aN(e,t);s.push(n),r=r.matchType(n.type),i=t}}),s)return ic.from(s)}return e}(o.content,i),!0)).openStart||o.openEnd){let e=0,t=0;for(let t=o.content.firstChild;e<o.openStart&&!t.type.spec.isolating;e++,t=t.firstChild);for(let e=o.content.lastChild;t<o.openEnd&&!e.type.spec.isolating;t++,e=e.lastChild);o=aC(o,e,t)}return e.someProp("transformPasted",t=>{o=t(o,e,l)}),o}let ak=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function aN(e,t,n=0){for(let r=t.length-1;r>=n;r--)e=t[r].create(null,ic.from(e));return e}function aS(e,t,n,r,i,s){let o=t<0?e.firstChild:e.lastChild,a=o.content;return e.childCount>1&&(s=0),i<r-1&&(a=aS(a,t,n,r,i+1,s)),i>=n&&(a=t<0?o.contentMatchAt(0).fillBefore(a,s<=i).append(a):a.append(o.contentMatchAt(o.childCount).fillBefore(ic.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,o.copy(a))}function aC(e,t,n){return t<e.openStart&&(e=new ig(aS(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),n<e.openEnd&&(e=new ig(aS(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}let aj={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]},aE=null;function aM(){return aE||(aE=document.implementation.createHTMLDocument("title"))}let aA=null,aT={},aO={},a_={touchstart:!0,touchmove:!0};class aD{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function aR(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function aI(e){e.someProp("handleDOMEvents",t=>{for(let n in t)e.input.eventHandlers[n]||e.dom.addEventListener(n,e.input.eventHandlers[n]=t=>aL(e,t))})}function aL(e,t){return e.someProp("handleDOMEvents",n=>{let r=n[t.type];return!!r&&(r(e,t)||t.defaultPrevented)})}function aP(e){return{left:e.clientX,top:e.clientY}}function az(e,t,n,r,i){if(-1==r)return!1;let s=e.state.doc.resolve(r);for(let r=s.depth+1;r>0;r--)if(e.someProp(t,t=>r>s.depth?t(e,n,s.nodeAfter,s.before(r),i,!0):t(e,n,s.node(r),s.before(r),i,!1)))return!0;return!1}function a$(e,t,n){if(e.focused||e.focus(),e.state.selection.eq(t))return;let r=e.state.tr.setSelection(t);"pointer"==n&&r.setMeta("pointer",!0),e.dispatch(r)}aO.keydown=(e,t)=>{if((e.input.shiftKey=16==t.keyCode||t.shiftKey,!aH(e,t))&&(e.input.lastKeyCode=t.keyCode,e.input.lastKeyCodeTime=Date.now(),!ow||!om||13!=t.keyCode))if(229!=t.keyCode&&e.domObserver.forceFlush(),!ox||13!=t.keyCode||t.ctrlKey||t.altKey||t.metaKey)e.someProp("handleKeyDown",n=>n(e,t))||function(e,t){let n,r=t.keyCode,i=(n="",t.ctrlKey&&(n+="c"),t.metaKey&&(n+="m"),t.altKey&&(n+="a"),t.shiftKey&&(n+="s"),n);if(8==r||oy&&72==r&&"c"==i)return ax(e,-1)||ah(e,-1);if(46==r&&!t.shiftKey||oy&&68==r&&"c"==i)return ax(e,1)||ah(e,1);if(13==r||27==r)return!0;if(37==r||oy&&66==r&&"c"==i){let t=37==r?"ltr"==ag(e,e.state.selection.from)?-1:1:-1;return ad(e,t,i)||ah(e,t)}if(39==r||oy&&70==r&&"c"==i){let t=39==r?"ltr"==ag(e,e.state.selection.from)?1:-1:1;return ad(e,t,i)||ah(e,t)}else if(38==r||oy&&80==r&&"c"==i)return ab(e,-1,i)||ah(e,-1);else if(40==r||oy&&78==r&&"c"==i)return function(e){if(!ob||e.state.selection.$head.parentOffset>0)return!1;let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(t&&1==t.nodeType&&0==n&&t.firstChild&&"false"==t.firstChild.contentEditable){let n=t.firstChild;ay(e,n,"true"),setTimeout(()=>ay(e,n,"false"),20)}return!1}(e)||ab(e,1,i)||ah(e,1);else if(i==(oy?"m":"c")&&(66==r||73==r||89==r||90==r))return!0;return!1}(e,t)?t.preventDefault():aR(e,"key");else{let t=Date.now();e.input.lastIOSEnter=t,e.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{e.input.lastIOSEnter==t&&(e.someProp("handleKeyDown",t=>t(e,or(13,"Enter"))),e.input.lastIOSEnter=0)},200)}},aO.keyup=(e,t)=>{16==t.keyCode&&(e.input.shiftKey=!1)},aO.keypress=(e,t)=>{if(aH(e,t)||!t.charCode||t.ctrlKey&&!t.altKey||oy&&t.metaKey)return;if(e.someProp("handleKeyPress",n=>n(e,t)))return void t.preventDefault();let n=e.state.selection;if(!(n instanceof sz)||!n.$from.sameParent(n.$to)){let r=String.fromCharCode(t.charCode),i=()=>e.state.tr.insertText(r).scrollIntoView();/[\r\n]/.test(r)||e.someProp("handleTextInput",t=>t(e,n.$from.pos,n.$to.pos,r,i))||e.dispatch(i()),t.preventDefault()}};let aB=oy?"metaKey":"ctrlKey";aT.mousedown=(e,t)=>{var n;let r,i;e.input.shiftKey=t.shiftKey;let s=aq(e),o=Date.now(),a="singleClick";o-e.input.lastClick.time<500&&(r=(n=e.input.lastClick).x-t.clientX)*r+(i=n.y-t.clientY)*i<100&&!t[aB]&&e.input.lastClick.button==t.button&&("singleClick"==e.input.lastClick.type?a="doubleClick":"doubleClick"==e.input.lastClick.type&&(a="tripleClick")),e.input.lastClick={time:o,x:t.clientX,y:t.clientY,type:a,button:t.button};let l=e.posAtCoords(aP(t));l&&("singleClick"==a?(e.input.mouseDown&&e.input.mouseDown.done(),e.input.mouseDown=new aF(e,l,t,!!s)):("doubleClick"==a?function(e,t,n,r){return az(e,"handleDoubleClickOn",t,n,r)||e.someProp("handleDoubleClick",n=>n(e,t,r))}:function(e,t,n,r){return az(e,"handleTripleClickOn",t,n,r)||e.someProp("handleTripleClick",n=>n(e,t,r))||function(e,t,n){if(0!=n.button)return!1;let r=e.state.doc;if(-1==t)return!!r.inlineContent&&(a$(e,sz.create(r,0,r.content.size),"pointer"),!0);let i=r.resolve(t);for(let t=i.depth+1;t>0;t--){let n=t>i.depth?i.nodeAfter:i.node(t),s=i.before(t);if(n.inlineContent)a$(e,sz.create(r,s+1,s+1+n.content.size),"pointer");else{if(!sB.isSelectable(n))continue;a$(e,sB.create(r,s),"pointer")}return!0}}(e,n,r)})(e,l.pos,l.inside,t)?t.preventDefault():aR(e,"pointer"))};class aF{constructor(e,t,n,r){let i,s;if(this.view=e,this.pos=t,this.event=n,this.flushed=r,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!n[aB],this.allowDefault=n.shiftKey,t.inside>-1)i=e.state.doc.nodeAt(t.inside),s=t.inside;else{let n=e.state.doc.resolve(t.pos);i=n.parent,s=n.depth?n.before():0}const o=r?null:n.target,a=o?e.docView.nearestDesc(o,!0):null;this.target=a&&1==a.nodeDOM.nodeType?a.nodeDOM:null;let{selection:l}=e.state;0==n.button&&(i.type.spec.draggable&&!1!==i.type.spec.selectable||l instanceof sB&&l.from<=s&&l.to>s)&&(this.mightDrag={node:i,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&oh&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),aR(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>o7(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;if(this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(aP(e))),this.updateAllowDefault(e),this.allowDefault||!t)aR(this.view,"pointer");else{var n,r,i,s;(n=this.view,r=t.pos,i=t.inside,s=this.selectNode,az(n,"handleClickOn",r,i,e)||n.someProp("handleClick",t=>t(n,r,e))||(s?function(e,t){if(-1==t)return!1;let n=e.state.selection,r,i;n instanceof sB&&(r=n.node);let s=e.state.doc.resolve(t);for(let e=s.depth+1;e>0;e--){let t=e>s.depth?s.nodeAfter:s.node(e);if(sB.isSelectable(t)){i=r&&n.$from.depth>0&&e>=n.$from.depth&&s.before(n.$from.depth+1)==n.$from.pos?s.before(n.$from.depth):s.before(e);break}}return null!=i&&(a$(e,sB.create(e.state.doc,i),"pointer"),!0)}(n,i):function(e,t){if(-1==t)return!1;let n=e.state.doc.resolve(t),r=n.nodeAfter;return!!(r&&r.isAtom&&sB.isSelectable(r))&&(a$(e,new sB(n),"pointer"),!0)}(n,i)))?e.preventDefault():0==e.button&&(this.flushed||ob&&this.mightDrag&&!this.mightDrag.node.isAtom||om&&!this.view.state.selection.visible&&2>=Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to)))?(a$(this.view,sR.near(this.view.state.doc.resolve(t.pos)),"pointer"),e.preventDefault()):aR(this.view,"pointer")}}move(e){this.updateAllowDefault(e),aR(this.view,"pointer"),0==e.buttons&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}function aH(e,t){return!!e.composing||!!(ob&&500>Math.abs(t.timeStamp-e.input.compositionEndedAt))&&(e.input.compositionEndedAt=-2e8,!0)}aT.touchstart=e=>{e.input.lastTouch=Date.now(),aq(e),aR(e,"pointer")},aT.touchmove=e=>{e.input.lastTouch=Date.now(),aR(e,"pointer")},aT.contextmenu=e=>aq(e);let aU=ow?5e3:-1;function aV(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout(()=>aq(e),t))}function aW(e){let t;for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=((t=document.createEvent("Event")).initEvent("event",!0,!0),t.timeStamp));e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function aq(e,t=!1){if(!ow||!(e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),aW(e),t||e.docView&&e.docView.dirty){let n=o6(e),r=e.state.selection;return n&&!n.eq(r)?e.dispatch(e.state.tr.setSelection(n)):(e.markCursor||t)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?e.dispatch(e.state.tr.deleteSelection()):e.updateState(e.state),!0}return!1}}aO.compositionstart=aO.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,n=t.selection.$to;if(t.selection instanceof sz&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(e=>!1===e.type.spec.inclusive)||om&&ov&&function(e){let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(!t||1!=t.nodeType||n>=t.childNodes.length)return!1;let r=t.childNodes[n];return 1==r.nodeType&&"false"==r.contentEditable}(e)))e.markCursor=e.state.storedMarks||n.marks(),aq(e,!0),e.markCursor=null;else if(aq(e,!t.selection.empty),oh&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let t=e.domSelectionRange();for(let n=t.focusNode,r=t.focusOffset;n&&1==n.nodeType&&0!=r;){let t=r<0?n.lastChild:n.childNodes[r-1];if(!t)break;if(3==t.nodeType){let n=e.domSelection();n&&n.collapse(t,t.nodeValue.length);break}n=t,r=-1}}e.input.composing=!0}aV(e,aU)},aO.compositionend=(e,t)=>{e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=t.timeStamp,e.input.compositionPendingChanges=e.domObserver.pendingRecords().length?e.input.compositionID:0,e.input.compositionNode=null,e.input.badSafariComposition?e.domObserver.forceFlush():e.input.compositionPendingChanges&&Promise.resolve().then(()=>e.domObserver.flush()),e.input.compositionID++,aV(e,20))};let aK=ou&&op<15||ox&&oN<604;function aG(e,t,n,r,i){let s=aw(e,t,n,r,e.state.selection.$from);if(e.someProp("handlePaste",t=>t(e,i,s||ig.empty)))return!0;if(!s)return!1;let o=0==s.openStart&&0==s.openEnd&&1==s.content.childCount?s.content.firstChild:null,a=o?e.state.tr.replaceSelectionWith(o,r):e.state.tr.replaceSelection(s);return e.dispatch(a.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function aJ(e){let t=e.getData("text/plain")||e.getData("Text");if(t)return t;let n=e.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}aT.copy=aO.cut=(e,t)=>{let n=e.state.selection,r="cut"==t.type;if(n.empty)return;let i=aK?null:t.clipboardData,{dom:s,text:o}=av(e,n.content());i?(t.preventDefault(),i.clearData(),i.setData("text/html",s.innerHTML),i.setData("text/plain",o)):function(e,t){if(!e.dom.parentNode)return;let n=e.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(t),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),i=document.createRange();i.selectNodeContents(t),e.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),e.focus()},50)}(e,s),r&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))},aO.paste=(e,t)=>{if(e.composing&&!ow)return;let n=aK?null:t.clipboardData,r=e.input.shiftKey&&45!=e.input.lastKeyCode;n&&aG(e,aJ(n),n.getData("text/html"),r,t)?t.preventDefault():function(e,t){if(!e.dom.parentNode)return;let n=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,r=e.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let i=e.input.shiftKey&&45!=e.input.lastKeyCode;setTimeout(()=>{e.focus(),r.parentNode&&r.parentNode.removeChild(r),n?aG(e,r.value,null,i,t):aG(e,r.textContent,r.innerHTML,i,t)},50)}(e,t)};class aZ{constructor(e,t,n){this.slice=e,this.move=t,this.node=n}}let aX=oy?"altKey":"ctrlKey";function aY(e,t){let n;return e.someProp("dragCopies",e=>{n=n||e(t)}),null!=n?!n:!t[aX]}for(let e in aT.dragstart=(e,t)=>{let n,r=e.input.mouseDown;if(r&&r.done(),!t.dataTransfer)return;let i=e.state.selection,s=i.empty?null:e.posAtCoords(aP(t));if(s&&s.pos>=i.from&&s.pos<=(i instanceof sB?i.to-1:i.to));else if(r&&r.mightDrag)n=sB.create(e.state.doc,r.mightDrag.pos);else if(t.target&&1==t.target.nodeType){let r=e.docView.nearestDesc(t.target,!0);r&&r.node.type.spec.draggable&&r!=e.docView&&(n=sB.create(e.state.doc,r.posBefore))}let o=(n||e.state.selection).content(),{dom:a,text:l,slice:c}=av(e,o);t.dataTransfer.files.length&&om&&!(og>120)||t.dataTransfer.clearData(),t.dataTransfer.setData(aK?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",aK||t.dataTransfer.setData("text/plain",l),e.dragging=new aZ(c,aY(e,t),n)},aT.dragend=e=>{let t=e.dragging;window.setTimeout(()=>{e.dragging==t&&(e.dragging=null)},50)},aO.dragover=aO.dragenter=(e,t)=>t.preventDefault(),aO.drop=(e,t)=>{try{!function(e,t,n){if(!t.dataTransfer)return;let r=e.posAtCoords(aP(t));if(!r)return;let i=e.state.doc.resolve(r.pos),s=n&&n.slice;s?e.someProp("transformPasted",t=>{s=t(s,e,!1)}):s=aw(e,aJ(t.dataTransfer),aK?null:t.dataTransfer.getData("text/html"),!1,i);let o=!!(n&&aY(e,t));if(e.someProp("handleDrop",n=>n(e,t,s||ig.empty,o)))return t.preventDefault();if(!s)return;t.preventDefault();let a=s?sv(e.state.doc,i.pos,s):i.pos;null==a&&(a=i.pos);let l=e.state.tr;if(o){let{node:e}=n;e?e.replace(l):l.deleteSelection()}let c=l.mapping.map(a),d=0==s.openStart&&0==s.openEnd&&1==s.content.childCount,u=l.doc;if(d?l.replaceRangeWith(c,c,s.content.firstChild):l.replaceRange(c,c,s),l.doc.eq(u))return;let p=l.doc.resolve(c);if(d&&sB.isSelectable(s.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(s.content.firstChild))l.setSelection(new sB(p));else{let t=l.mapping.map(a);l.mapping.maps[l.mapping.maps.length-1].forEach((e,n,r,i)=>t=i),l.setSelection(as(e,p,l.doc.resolve(t)))}e.focus(),e.dispatch(l.setMeta("uiEvent","drop"))}(e,t,e.dragging)}finally{e.dragging=null}},aT.focus=e=>{e.input.lastFocus=Date.now(),e.focused||(e.domObserver.stop(),e.dom.classList.add("ProseMirror-focused"),e.domObserver.start(),e.focused=!0,setTimeout(()=>{e.docView&&e.hasFocus()&&!e.domObserver.currentSelection.eq(e.domSelectionRange())&&o7(e)},20))},aT.blur=(e,t)=>{e.focused&&(e.domObserver.stop(),e.dom.classList.remove("ProseMirror-focused"),e.domObserver.start(),t.relatedTarget&&e.dom.contains(t.relatedTarget)&&e.domObserver.currentSelection.clear(),e.focused=!1)},aT.beforeinput=(e,t)=>{if(om&&ow&&"deleteContentBackward"==t.inputType){e.domObserver.flushSoon();let{domChangeCount:t}=e.input;setTimeout(()=>{if(e.input.domChangeCount!=t||(e.dom.blur(),e.focus(),e.someProp("handleKeyDown",t=>t(e,or(8,"Backspace")))))return;let{$cursor:n}=e.state.selection;n&&n.pos>0&&e.dispatch(e.state.tr.delete(n.pos-1,n.pos).scrollIntoView())},50)}},aO)aT[e]=aO[e];function aQ(e,t){if(e==t)return!0;for(let n in e)if(e[n]!==t[n])return!1;for(let n in t)if(!(n in e))return!1;return!0}class a0{constructor(e,t){this.toDOM=e,this.spec=t||a4,this.side=this.spec.side||0}map(e,t,n,r){let{pos:i,deleted:s}=e.mapResult(t.from+r,this.side<0?-1:1);return s?null:new a3(i-n,i-n,this)}valid(){return!0}eq(e){return this==e||e instanceof a0&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&aQ(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class a1{constructor(e,t){this.attrs=e,this.spec=t||a4}map(e,t,n,r){let i=e.map(t.from+r,this.spec.inclusiveStart?-1:1)-n,s=e.map(t.to+r,this.spec.inclusiveEnd?1:-1)-n;return i>=s?null:new a3(i,s,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof a1&&aQ(this.attrs,e.attrs)&&aQ(this.spec,e.spec)}static is(e){return e.type instanceof a1}destroy(){}}class a2{constructor(e,t){this.attrs=e,this.spec=t||a4}map(e,t,n,r){let i=e.mapResult(t.from+r,1);if(i.deleted)return null;let s=e.mapResult(t.to+r,-1);return s.deleted||s.pos<=i.pos?null:new a3(i.pos-n,s.pos-n,this)}valid(e,t){let{index:n,offset:r}=e.content.findIndex(t.from),i;return r==t.from&&!(i=e.child(n)).isText&&r+i.nodeSize==t.to}eq(e){return this==e||e instanceof a2&&aQ(this.attrs,e.attrs)&&aQ(this.spec,e.spec)}destroy(){}}class a3{constructor(e,t,n){this.from=e,this.to=t,this.type=n}copy(e,t){return new a3(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,n){return this.type.map(e,this,t,n)}static widget(e,t,n){return new a3(e,e,new a0(t,n))}static inline(e,t,n,r){return new a3(e,t,new a1(n,r))}static node(e,t,n,r){return new a3(e,t,new a2(n,r))}get spec(){return this.type.spec}get inline(){return this.type instanceof a1}get widget(){return this.type instanceof a0}}let a5=[],a4={};class a6{constructor(e,t){this.local=e.length?e:a5,this.children=t.length?t:a5}static create(e,t){return t.length?ln(t,e,0,a4):a9}find(e,t,n){let r=[];return this.findInner(null==e?0:e,null==t?1e9:t,r,0,n),r}findInner(e,t,n,r,i){for(let s=0;s<this.local.length;s++){let o=this.local[s];o.from<=t&&o.to>=e&&(!i||i(o.spec))&&n.push(o.copy(o.from+r,o.to+r))}for(let s=0;s<this.children.length;s+=3)if(this.children[s]<t&&this.children[s+1]>e){let o=this.children[s]+1;this.children[s+2].findInner(e-o,t-o,n,r+o,i)}}map(e,t,n){return this==a9||0==e.maps.length?this:this.mapInner(e,t,0,0,n||a4)}mapInner(e,t,n,r,i){let s;for(let o=0;o<this.local.length;o++){let a=this.local[o].map(e,n,r);a&&a.type.valid(t,a)?(s||(s=[])).push(a):i.onRemove&&i.onRemove(this.local[o].spec)}return this.children.length?function(e,t,n,r,i,s,o){let a=e.slice();for(let e=0,t=s;e<n.maps.length;e++){let r=0;n.maps[e].forEach((e,n,i,s)=>{let o=s-i-(n-e);for(let i=0;i<a.length;i+=3){let s=a[i+1];if(s<0||e>s+t-r)continue;let l=a[i]+t-r;n>=l?a[i+1]=e<=l?-2:-1:e>=t&&o&&(a[i]+=o,a[i+1]+=o)}r+=o}),t=n.maps[e].map(t,-1)}let l=!1;for(let t=0;t<a.length;t+=3)if(a[t+1]<0){if(-2==a[t+1]){l=!0,a[t+1]=-1;continue}let c=n.map(e[t]+s),d=c-i;if(d<0||d>=r.content.size){l=!0;continue}let u=n.map(e[t+1]+s,-1)-i,{index:p,offset:h}=r.content.findIndex(d),f=r.maybeChild(p);if(f&&h==d&&h+f.nodeSize==u){let r=a[t+2].mapInner(n,f,c+1,e[t]+s+1,o);r!=a9?(a[t]=d,a[t+1]=u,a[t+2]=r):(a[t+1]=-2,l=!0)}else l=!0}if(l){let l=ln(function(e,t,n,r,i,s,o){for(let a=0;a<e.length;a+=3)-1==e[a+1]&&function e(t,s){for(let e=0;e<t.local.length;e++){let a=t.local[e].map(r,i,s);a?n.push(a):o.onRemove&&o.onRemove(t.local[e].spec)}for(let n=0;n<t.children.length;n+=3)e(t.children[n+2],t.children[n]+s+1)}(e[a+2],t[a]+s+1);return n}(a,e,t,n,i,s,o),r,0,o);t=l.local;for(let e=0;e<a.length;e+=3)a[e+1]<0&&(a.splice(e,3),e-=3);for(let e=0,t=0;e<l.children.length;e+=3){let n=l.children[e];for(;t<a.length&&a[t]<n;)t+=3;a.splice(t,0,l.children[e],l.children[e+1],l.children[e+2])}}return new a6(t.sort(lr),a)}(this.children,s||[],e,t,n,r,i):s?new a6(s.sort(lr),a5):a9}add(e,t){return t.length?this==a9?a6.create(e,t):this.addInner(e,t,0):this}addInner(e,t,n){let r,i=0;e.forEach((e,s)=>{let o=s+n,a;if(a=le(t,e,o)){for(r||(r=this.children.slice());i<r.length&&r[i]<s;)i+=3;r[i]==s?r[i+2]=r[i+2].addInner(e,a,o+1):r.splice(i,0,s,s+e.nodeSize,ln(a,e,o+1,a4)),i+=3}});let s=a8(i?lt(t):t,-n);for(let t=0;t<s.length;t++)s[t].type.valid(e,s[t])||s.splice(t--,1);return new a6(s.length?this.local.concat(s).sort(lr):this.local,r||this.children)}remove(e){return 0==e.length||this==a9?this:this.removeInner(e,0)}removeInner(e,t){let n=this.children,r=this.local;for(let r=0;r<n.length;r+=3){let i,s=n[r]+t,o=n[r+1]+t;for(let t=0,n;t<e.length;t++)(n=e[t])&&n.from>s&&n.to<o&&(e[t]=null,(i||(i=[])).push(n));if(!i)continue;n==this.children&&(n=this.children.slice());let a=n[r+2].removeInner(i,s+1);a!=a9?n[r+2]=a:(n.splice(r,3),r-=3)}if(r.length){for(let n=0,i;n<e.length;n++)if(i=e[n])for(let e=0;e<r.length;e++)r[e].eq(i,t)&&(r==this.local&&(r=this.local.slice()),r.splice(e--,1))}return n==this.children&&r==this.local?this:r.length||n.length?new a6(r,n):a9}forChild(e,t){let n,r;if(this==a9)return this;if(t.isLeaf)return a6.empty;for(let t=0;t<this.children.length;t+=3)if(this.children[t]>=e){this.children[t]==e&&(n=this.children[t+2]);break}let i=e+1,s=i+t.content.size;for(let e=0;e<this.local.length;e++){let t=this.local[e];if(t.from<s&&t.to>i&&t.type instanceof a1){let e=Math.max(i,t.from)-i,n=Math.min(s,t.to)-i;e<n&&(r||(r=[])).push(t.copy(e,n))}}if(r){let e=new a6(r.sort(lr),a5);return n?new a7([e,n]):e}return n||a9}eq(e){if(this==e)return!0;if(!(e instanceof a6)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return li(this.localsInner(e))}localsInner(e){if(this==a9)return a5;if(e.inlineContent||!this.local.some(a1.is))return this.local;let t=[];for(let e=0;e<this.local.length;e++)this.local[e].type instanceof a1||t.push(this.local[e]);return t}forEachSet(e){e(this)}}a6.empty=new a6([],[]),a6.removeOverlap=li;let a9=a6.empty;class a7{constructor(e){this.members=e}map(e,t){let n=this.members.map(n=>n.map(e,t,a4));return a7.from(n)}forChild(e,t){if(t.isLeaf)return a6.empty;let n=[];for(let r=0;r<this.members.length;r++){let i=this.members[r].forChild(e,t);i!=a9&&(i instanceof a7?n=n.concat(i.members):n.push(i))}return a7.from(n)}eq(e){if(!(e instanceof a7)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,n=!0;for(let r=0;r<this.members.length;r++){let i=this.members[r].localsInner(e);if(i.length)if(t){n&&(t=t.slice(),n=!1);for(let e=0;e<i.length;e++)t.push(i[e])}else t=i}return t?li(n?t:t.sort(lr)):a5}static from(e){switch(e.length){case 0:return a9;case 1:return e[0];default:return new a7(e.every(e=>e instanceof a6)?e:e.reduce((e,t)=>e.concat(t instanceof a6?t:t.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function a8(e,t){if(!t||!e.length)return e;let n=[];for(let r=0;r<e.length;r++){let i=e[r];n.push(new a3(i.from+t,i.to+t,i.type))}return n}function le(e,t,n){if(t.isLeaf)return null;let r=n+t.nodeSize,i=null;for(let t=0,s;t<e.length;t++)(s=e[t])&&s.from>n&&s.to<r&&((i||(i=[])).push(s),e[t]=null);return i}function lt(e){let t=[];for(let n=0;n<e.length;n++)null!=e[n]&&t.push(e[n]);return t}function ln(e,t,n,r){let i=[],s=!1;t.forEach((t,o)=>{let a=le(e,t,o+n);if(a){s=!0;let e=ln(a,t,n+o+1,r);e!=a9&&i.push(o,o+t.nodeSize,e)}});let o=a8(s?lt(e):e,-n).sort(lr);for(let e=0;e<o.length;e++)o[e].type.valid(t,o[e])||(r.onRemove&&r.onRemove(o[e].spec),o.splice(e--,1));return o.length||i.length?new a6(o,i):a9}function lr(e,t){return e.from-t.from||e.to-t.to}function li(e){let t=e;for(let n=0;n<t.length-1;n++){let r=t[n];if(r.from!=r.to)for(let i=n+1;i<t.length;i++){let s=t[i];if(s.from==r.from){s.to!=r.to&&(t==e&&(t=e.slice()),t[i]=s.copy(s.from,r.to),ls(t,i+1,s.copy(r.to,s.to)));continue}s.from<r.to&&(t==e&&(t=e.slice()),t[n]=r.copy(r.from,s.from),ls(t,i,r.copy(s.from,r.to)));break}}return t}function ls(e,t,n){for(;t<e.length&&lr(n,e[t])>0;)t++;e.splice(t,0,n)}function lo(e){let t=[];return e.someProp("decorations",n=>{let r=n(e.state);r&&r!=a9&&t.push(r)}),e.cursorWrapper&&t.push(a6.create(e.state.doc,[e.cursorWrapper.deco])),a7.from(t)}let la={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},ll=ou&&op<=11;class lc{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class ld{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new lc,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(t=>{for(let e=0;e<t.length;e++)this.queue.push(t[e]);ou&&op<=11&&t.some(e=>"childList"==e.type&&e.removedNodes.length||"characterData"==e.type&&e.oldValue.length>e.target.nodeValue.length)?this.flushSoon():ob&&e.composing&&t.some(e=>"childList"==e.type&&"TR"==e.target.nodeName)?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),ll&&(this.onCharData=e=>{this.queue.push({target:e.target,type:"characterData",oldValue:e.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,la)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;t<e.length;t++)this.queue.push(e[t]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(ao(this.view)){if(this.suppressingSelectionUpdates)return o7(this.view);if(ou&&op<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&s9(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,n;for(let n=e.focusNode;n;n=s3(n))t.add(n);for(let r=e.anchorNode;r;r=s3(r))if(t.has(r)){n=r;break}let r=n&&this.view.docView.nearestDesc(n);if(r&&r.ignoreMutation({type:"selection",target:3==n.nodeType?n.parentNode:n}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){var e;let{view:t}=this;if(!t.docView||this.flushingSoon>-1)return;let n=this.pendingRecords();n.length&&(this.queue=[]);let r=t.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&ao(t)&&!this.ignoreSelectionChange(r),s=-1,o=-1,a=!1,l=[];if(t.editable)for(let e=0;e<n.length;e++){let t=this.registerMutation(n[e],l);t&&(s=s<0?t.from:Math.min(t.from,s),o=o<0?t.to:Math.max(t.to,o),t.typeOver&&(a=!0))}if(l.some(e=>"BR"==e.nodeName)&&(8==t.input.lastKeyCode||46==t.input.lastKeyCode)){for(let e of l)if("BR"==e.nodeName&&e.parentNode){let t=e.nextSibling;for(;t&&1==t.nodeType;){if("false"==t.contentEditable){e.parentNode.removeChild(e);break}t=t.firstChild}}}else if(oh&&l.length){let e=l.filter(e=>"BR"==e.nodeName);if(2==e.length){let[t,n]=e;t.parentNode&&t.parentNode.parentNode==n.parentNode?n.remove():t.remove()}else{let{focusNode:n}=this.currentSelection;for(let r of e){let e=r.parentNode;e&&"LI"==e.nodeName&&(!n||function(e,t){for(let n=t.parentNode;n&&n!=e.dom;n=n.parentNode){let t=e.docView.nearestDesc(n,!0);if(t&&t.node.isBlock)return n}return null}(t,n)!=e)&&r.remove()}}}let c=null;s<0&&i&&t.input.lastFocus>Date.now()-200&&Math.max(t.input.lastTouch,t.input.lastClick.time)<Date.now()-300&&on(r)&&(c=o6(t))&&c.eq(sR.near(t.state.doc.resolve(0),1))?(t.input.lastFocus=0,o7(t),this.currentSelection.set(r),t.scrollToSelection()):(s>-1||i)&&(s>-1&&(t.docView.markDirty(s,o),e=t,!lu.has(e)&&(lu.set(e,null),-1!==["normal","nowrap","pre-line"].indexOf(getComputedStyle(e.dom).whiteSpace))&&(e.requiresGeckoHackNode=oh,lp||(console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."),lp=!0))),t.input.badSafariComposition&&(t.input.badSafariComposition=!1,function(e,t){var n;let{focusNode:r,focusOffset:i}=e.domSelectionRange();for(let s of t)if((null==(n=s.parentNode)?void 0:n.nodeName)=="TR"){let t=s.nextSibling;for(;t&&"TD"!=t.nodeName&&"TH"!=t.nodeName;)t=t.nextSibling;if(t){let n=t;for(;;){let e=n.firstChild;if(!e||1!=e.nodeType||"false"==e.contentEditable||/^(BR|IMG)$/.test(e.nodeName))break;n=e}n.insertBefore(s,n.firstChild),r==s&&e.domSelection().collapse(s,i)}else s.parentNode.removeChild(s)}}(t,l)),this.handleDOMChange(s,o,a,l),t.docView&&t.docView.dirty?t.updateState(t.state):this.currentSelection.eq(r)||o7(t),this.currentSelection.set(r))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let n=this.view.docView.nearestDesc(e.target);if("attributes"==e.type&&(n==this.view.docView||"contenteditable"==e.attributeName||"style"==e.attributeName&&!e.oldValue&&!e.target.getAttribute("style"))||!n||n.ignoreMutation(e))return null;if("childList"==e.type){for(let n=0;n<e.addedNodes.length;n++){let r=e.addedNodes[n];t.push(r),3==r.nodeType&&(this.lastChangedTextNode=r)}if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(e.target))return{from:n.posBefore,to:n.posAfter};let r=e.previousSibling,i=e.nextSibling;if(ou&&op<=11&&e.addedNodes.length)for(let t=0;t<e.addedNodes.length;t++){let{previousSibling:n,nextSibling:s}=e.addedNodes[t];(!n||0>Array.prototype.indexOf.call(e.addedNodes,n))&&(r=n),(!s||0>Array.prototype.indexOf.call(e.addedNodes,s))&&(i=s)}let s=r&&r.parentNode==e.target?s2(r)+1:0,o=n.localPosFromDOM(e.target,s,-1),a=i&&i.parentNode==e.target?s2(i):e.target.childNodes.length;return{from:o,to:n.localPosFromDOM(e.target,a,1)}}return"attributes"==e.type?{from:n.posAtStart-n.border,to:n.posAtEnd+n.border}:(this.lastChangedTextNode=e.target,{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let lu=new WeakMap,lp=!1;function lh(e,t){let n=t.startContainer,r=t.startOffset,i=t.endContainer,s=t.endOffset,o=e.domAtPos(e.state.selection.anchor);return s9(o.node,o.offset,i,s)&&([n,r,i,s]=[i,s,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:s}}function lf(e){let t=e.pmViewDesc;if(t)return t.parseRule();if("BR"==e.nodeName&&e.parentNode){if(ob&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let e=document.createElement("div");return e.appendChild(document.createElement("li")),{skip:e}}else if(e.parentNode.lastChild==e||ob&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if("IMG"==e.nodeName&&e.getAttribute("mark-placeholder"))return{ignore:!0};return null}let lm=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function lg(e,t,n){return Math.max(n.anchor,n.head)>t.content.size?null:as(e,t.resolve(n.anchor),t.resolve(n.head))}function lb(e,t,n){let r=e.depth,i=t?e.end():e.pos;for(;r>0&&(t||e.indexAfter(r)==e.node(r).childCount);)r--,i++,t=!1;if(n){let t=e.node(r).maybeChild(e.indexAfter(r));for(;t&&!t.isLeaf;)t=t.firstChild,i++}return i}function lx(e){if(2!=e.length)return!1;let t=e.charCodeAt(0),n=e.charCodeAt(1);return t>=56320&&t<=57343&&n>=55296&&n<=56319}class ly{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new aD,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(lS),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):"function"==typeof e?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=lk(this),lw(this),this.nodeViews=lN(this),this.docView=oq(this.state.doc,lv(this),lo(this),this.dom,this),this.domObserver=new ld(this,(e,t,n,r)=>(function(e,t,n,r,i){let s,o,a,l=e.input.compositionPendingChanges||(e.composing?e.input.compositionID:0);if(e.input.compositionPendingChanges=0,t<0){let t=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,n=o6(e,t);if(n&&!e.state.selection.eq(n)){if(om&&ow&&13===e.input.lastKeyCode&&Date.now()-100<e.input.lastKeyCodeTime&&e.someProp("handleKeyDown",t=>t(e,or(13,"Enter"))))return;let r=e.state.tr.setSelection(n);"pointer"==t?r.setMeta("pointer",!0):"key"==t&&r.scrollIntoView(),l&&r.setMeta("composition",l),e.dispatch(r)}return}let c=e.state.doc.resolve(t),d=c.sharedDepth(n);t=c.before(d+1),n=e.state.doc.resolve(n).after(d+1);let u=e.state.selection,p=function(e,t,n){let r,{node:i,fromOffset:s,toOffset:o,from:a,to:l}=e.docView.parseRange(t,n),c=e.domSelectionRange(),d=c.anchorNode;if(d&&e.dom.contains(1==d.nodeType?d:d.parentNode)&&(r=[{node:d,offset:c.anchorOffset}],on(c)||r.push({node:c.focusNode,offset:c.focusOffset})),om&&8===e.input.lastKeyCode)for(let e=o;e>s;e--){let t=i.childNodes[e-1],n=t.pmViewDesc;if("BR"==t.nodeName&&!n){o=e;break}if(!n||n.size)break}let u=e.state.doc,p=e.someProp("domParser")||iq.fromSchema(e.state.schema),h=u.resolve(a),f=null,m=p.parse(i,{topNode:h.parent,topMatch:h.parent.contentMatchAt(h.index()),topOpen:!0,from:s,to:o,preserveWhitespace:"pre"!=h.parent.type.whitespace||"full",findPositions:r,ruleFromNode:lf,context:h});if(r&&null!=r[0].pos){let e=r[0].pos,t=r[1]&&r[1].pos;null==t&&(t=e),f={anchor:e+a,head:t+a}}return{doc:m,sel:f,from:a,to:l}}(e,t,n),h=e.state.doc,f=h.slice(p.from,p.to);8===e.input.lastKeyCode&&Date.now()-100<e.input.lastKeyCodeTime?(s=e.state.selection.to,o="end"):(s=e.state.selection.from,o="start"),e.input.lastKeyCode=null;let m=function(e,t,n,r,i){let s=e.findDiffStart(t,n);if(null==s)return null;let{a:o,b:a}=e.findDiffEnd(t,n+e.size,n+t.size);if("end"==i){let e=Math.max(0,s-Math.min(o,a));r-=o+e-s}if(o<s&&e.size<t.size){let e=r<=s&&r>=o?s-r:0;(s-=e)&&s<t.size&&lx(t.textBetween(s-1,s+1))&&(s+=e?1:-1),a=s+(a-o),o=s}else if(a<s){let t=r<=s&&r>=a?s-r:0;(s-=t)&&s<e.size&&lx(e.textBetween(s-1,s+1))&&(s+=t?1:-1),o=s+(o-a),a=s}return{start:s,endA:o,endB:a}}(f.content,p.doc.content,p.from,s,o);if(m&&e.input.domChangeCount++,(ox&&e.input.lastIOSEnter>Date.now()-225||ow)&&i.some(e=>1==e.nodeType&&!lm.test(e.nodeName))&&(!m||m.endA>=m.endB)&&e.someProp("handleKeyDown",t=>t(e,or(13,"Enter")))){e.input.lastIOSEnter=0;return}if(!m)if(r&&u instanceof sz&&!u.empty&&u.$head.sameParent(u.$anchor)&&!e.composing&&!(p.sel&&p.sel.anchor!=p.sel.head))m={start:u.from,endA:u.to,endB:u.to};else{if(p.sel){let t=lg(e,e.state.doc,p.sel);if(t&&!t.eq(e.state.selection)){let n=e.state.tr.setSelection(t);l&&n.setMeta("composition",l),e.dispatch(n)}}return}e.state.selection.from<e.state.selection.to&&m.start==m.endB&&e.state.selection instanceof sz&&(m.start>e.state.selection.from&&m.start<=e.state.selection.from+2&&e.state.selection.from>=p.from?m.start=e.state.selection.from:m.endA<e.state.selection.to&&m.endA>=e.state.selection.to-2&&e.state.selection.to<=p.to&&(m.endB+=e.state.selection.to-m.endA,m.endA=e.state.selection.to)),ou&&op<=11&&m.endB==m.start+1&&m.endA==m.start&&m.start>p.from&&" "==p.doc.textBetween(m.start-p.from-1,m.start-p.from+1)&&(m.start--,m.endA--,m.endB--);let g=p.doc.resolveNoCache(m.start-p.from),b=p.doc.resolveNoCache(m.endB-p.from),x=h.resolve(m.start),y=g.sameParent(b)&&g.parent.inlineContent&&x.end()>=m.endA;if((ox&&e.input.lastIOSEnter>Date.now()-225&&(!y||i.some(e=>"DIV"==e.nodeName||"P"==e.nodeName))||!y&&g.pos<p.doc.content.size&&(!g.sameParent(b)||!g.parent.inlineContent)&&g.pos<b.pos&&!/\S/.test(p.doc.textBetween(g.pos,b.pos,"","")))&&e.someProp("handleKeyDown",t=>t(e,or(13,"Enter")))){e.input.lastIOSEnter=0;return}if(e.state.selection.anchor>m.start&&function(e,t,n,r,i){if(n-t<=i.pos-r.pos||lb(r,!0,!1)<i.pos)return!1;let s=e.resolve(t);if(!r.parent.isTextblock){let e=s.nodeAfter;return null!=e&&n==t+e.nodeSize}if(s.parentOffset<s.parent.content.size||!s.parent.isTextblock)return!1;let o=e.resolve(lb(s,!0,!0));return!(!o.parent.isTextblock||o.pos>n||lb(o,!0,!1)<n)&&r.parent.content.cut(r.parentOffset).eq(o.parent.content)}(h,m.start,m.endA,g,b)&&e.someProp("handleKeyDown",t=>t(e,or(8,"Backspace")))){ow&&om&&e.domObserver.suppressSelectionUpdates();return}om&&m.endB==m.start&&(e.input.lastChromeDelete=Date.now()),ow&&!y&&g.start()!=b.start()&&0==b.parentOffset&&g.depth==b.depth&&p.sel&&p.sel.anchor==p.sel.head&&p.sel.head==m.endA&&(m.endB-=2,b=p.doc.resolveNoCache(m.endB-p.from),setTimeout(()=>{e.someProp("handleKeyDown",function(t){return t(e,or(13,"Enter"))})},20));let v=m.start,w=m.endA,k=t=>{let n=t||e.state.tr.replace(v,w,p.doc.slice(m.start-p.from,m.endB-p.from));if(p.sel){let t=lg(e,n.doc,p.sel);t&&!(om&&e.composing&&t.empty&&(m.start!=m.endB||e.input.lastChromeDelete<Date.now()-100)&&(t.head==v||t.head==n.mapping.map(w)-1)||ou&&t.empty&&t.head==v)&&n.setSelection(t)}return l&&n.setMeta("composition",l),n.scrollIntoView()};if(y)if(g.pos==b.pos){ou&&op<=11&&0==g.parentOffset&&(e.domObserver.suppressSelectionUpdates(),setTimeout(()=>o7(e),20));let t=k(e.state.tr.delete(v,w)),n=h.resolve(m.start).marksAcross(h.resolve(m.endA));n&&t.ensureMarks(n),e.dispatch(t)}else if(m.endA==m.endB&&(a=function(e,t){let n=e.firstChild.marks,r=t.firstChild.marks,i=n,s=r,o,a,l;for(let e=0;e<r.length;e++)i=r[e].removeFromSet(i);for(let e=0;e<n.length;e++)s=n[e].removeFromSet(s);if(1==i.length&&0==s.length)a=i[0],o="add",l=e=>e.mark(a.addToSet(e.marks));else{if(0!=i.length||1!=s.length)return null;a=s[0],o="remove",l=e=>e.mark(a.removeFromSet(e.marks))}let c=[];for(let e=0;e<t.childCount;e++)c.push(l(t.child(e)));if(ic.from(c).eq(e))return{mark:a,type:o}}(g.parent.content.cut(g.parentOffset,b.parentOffset),x.parent.content.cut(x.parentOffset,m.endA-x.start())))){let t=k(e.state.tr);"add"==a.type?t.addMark(v,w,a.mark):t.removeMark(v,w,a.mark),e.dispatch(t)}else if(g.parent.child(g.index()).isText&&g.index()==b.index()-!b.textOffset){let t=g.parent.textBetween(g.parentOffset,b.parentOffset),n=()=>k(e.state.tr.insertText(t,v,w));e.someProp("handleTextInput",r=>r(e,v,w,t,n))||e.dispatch(n())}else e.dispatch(k());else e.dispatch(k())})(this,e,t,n,r)),this.domObserver.start(),function(e){for(let t in aT){let n=aT[t];e.dom.addEventListener(t,e.input.eventHandlers[t]=t=>{!function(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n=t.target;n!=e.dom;n=n.parentNode)if(!n||11==n.nodeType||n.pmViewDesc&&n.pmViewDesc.stopEvent(t))return!1;return!0}(e,t)||aL(e,t)||!e.editable&&t.type in aO||n(e,t)},a_[t]?{passive:!0}:void 0)}ob&&e.dom.addEventListener("input",()=>null),aI(e)}(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;for(let t in this._props={},e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&aI(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(lS),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let e in this._props)t[e]=this._props[e];for(let n in t.state=this.state,e)t[n]=e[n];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var n,r,i;let s=this.state,o=!1,a=!1;e.storedMarks&&this.composing&&(aW(this),a=!0),this.state=e;let l=s.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let e=lN(this);(function(e,t){let n=0,r=0;for(let r in e){if(e[r]!=t[r])return!0;n++}for(let e in t)r++;return n!=r})(e,this.nodeViews)&&(this.nodeViews=e,o=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&aI(this),this.editable=lk(this),lw(this);let c=lo(this),d=lv(this),u=s.plugins==e.plugins||s.doc.eq(e.doc)?e.scrollToSelection>s.scrollToSelection?"to selection":"preserve":"reset",p=o||!this.docView.matchesNode(e.doc,d,c);(p||!e.selection.eq(s.selection))&&(a=!0);let h="preserve"==u&&a&&null==this.dom.style.overflowAnchor&&function(e){let t,n,r=e.dom.getBoundingClientRect(),i=Math.max(0,r.top);for(let s=(r.left+r.right)/2,o=i+1;o<Math.min(innerHeight,r.bottom);o+=5){let r=e.root.elementFromPoint(s,o);if(!r||r==e.dom||!e.dom.contains(r))continue;let a=r.getBoundingClientRect();if(a.top>=i-20){t=r,n=a.top;break}}return{refDOM:t,refTop:n,stack:oj(e.dom)}}(this);if(a){let t,n,a;this.domObserver.stop();let l=p&&(ou||om)&&!this.composing&&!s.selection.empty&&!e.selection.empty&&(r=s.selection,i=e.selection,a=Math.min(r.$anchor.sharedDepth(r.head),i.$anchor.sharedDepth(i.head)),r.$anchor.start(a)!=i.$anchor.start(a));if(p){let t=om?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=function(e){let t=e.domSelectionRange();if(!t.focusNode)return null;let n=function(e,t){for(;;){if(3==e.nodeType&&t)return e;if(1==e.nodeType&&t>0){if("false"==e.contentEditable)return null;t=oe(e=e.childNodes[t-1])}else{if(!e.parentNode||ot(e))return null;t=s2(e),e=e.parentNode}}}(t.focusNode,t.focusOffset),r=function(e,t){for(;;){if(3==e.nodeType&&t<e.nodeValue.length)return e;if(1==e.nodeType&&t<e.childNodes.length){if("false"==e.contentEditable)return null;e=e.childNodes[t],t=0}else{if(!e.parentNode||ot(e))return null;t=s2(e)+1,e=e.parentNode}}}(t.focusNode,t.focusOffset);if(n&&r&&n!=r){let t=r.pmViewDesc,i=e.domObserver.lastChangedTextNode;if(n==i||r==i)return i;if(!t||!t.isText(r.nodeValue))return r;if(e.input.compositionNode==r){let e=n.pmViewDesc;if(!(!e||!e.isText(n.nodeValue)))return r}}return n||r}(this)),(o||!this.docView.update(e.doc,d,c,this))&&(this.docView.updateOuterDeco(d),this.docView.destroy(),this.docView=oq(e.doc,d,c,this.dom,this)),!t||this.trackWrites&&this.dom.contains(this.trackWrites)||(l=!0)}l||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&(t=this.docView.domFromPos(this.state.selection.anchor,0),n=this.domSelectionRange(),s9(t.node,t.offset,n.anchorNode,n.anchorOffset)))?o7(this,l):(ar(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(s),(null==(n=this.dragging)?void 0:n.node)&&!s.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,s),"reset"==u?this.dom.scrollTop=0:"to selection"==u?this.scrollToSelection():h&&function({refDOM:e,refTop:t,stack:n}){let r=e?e.getBoundingClientRect().top:0;oE(n,0==r?0:r-t)}(h)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(e&&this.dom.contains(1==e.nodeType?e:e.parentNode))if(this.someProp("handleScrollToSelection",e=>e(this)));else if(this.state.selection instanceof sB){let t=this.docView.domAfterPos(this.state.selection.from);1==t.nodeType&&oC(this,t.getBoundingClientRect(),e)}else oC(this,this.coordsAtPos(this.state.selection.head,1),e)}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(e&&e.plugins==this.state.plugins&&this.directPlugins==this.prevDirectPlugins)for(let t=0;t<this.pluginViews.length;t++){let n=this.pluginViews[t];n.update&&n.update(this,e)}else{this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let e=0;e<this.directPlugins.length;e++){let t=this.directPlugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}for(let e=0;e<this.state.plugins.length;e++){let t=this.state.plugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}}}updateDraggedNode(e,t){let n=e.node,r=-1;if(n.from<this.state.doc.content.size&&this.state.doc.nodeAt(n.from)==n.node)r=n.from;else{let e=n.from+(this.state.doc.content.size-t.doc.content.size);(e>0&&e<this.state.doc.content.size&&this.state.doc.nodeAt(e))==n.node&&(r=e)}this.dragging=new aZ(e.slice,e.move,r<0?void 0:sB.create(this.state.doc,r))}someProp(e,t){let n=this._props&&this._props[e],r;if(null!=n&&(r=t?t(n):n))return r;for(let n=0;n<this.directPlugins.length;n++){let i=this.directPlugins[n].props[e];if(null!=i&&(r=t?t(i):i))return r}let i=this.state.plugins;if(i)for(let n=0;n<i.length;n++){let s=i[n].props[e];if(null!=s&&(r=t?t(s):s))return r}}hasFocus(){if(ou){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if("false"==e.contentEditable)return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&function(e){if(e.setActive)return e.setActive();if(oM)return e.focus(oM);let t=oj(e);e.focus(null==oM?{get preventScroll(){return oM={preventScroll:!0},!0}}:void 0),oM||(oM=!1,oE(t,0))}(this.dom),o7(this),this.domObserver.start()}get root(){let e=this._root;if(null==e){for(let e=this.dom.parentNode;e;e=e.parentNode)if(9==e.nodeType||11==e.nodeType&&e.host)return e.getSelection||(Object.getPrototypeOf(e).getSelection=()=>e.ownerDocument.getSelection()),this._root=e}return e||document}updateRoot(){this._root=null}posAtCoords(e){return function(e,t){var n;let r,i,s=e.dom.ownerDocument,o,a=0,l=function(e,t,n){if(e.caretPositionFromPoint)try{let r=e.caretPositionFromPoint(t,n);if(r)return{node:r.offsetNode,offset:Math.min(oe(r.offsetNode),r.offset)}}catch(e){}if(e.caretRangeFromPoint){let r=e.caretRangeFromPoint(t,n);if(r)return{node:r.startContainer,offset:Math.min(oe(r.startContainer),r.startOffset)}}}(s,t.left,t.top);l&&({node:o,offset:a}=l);let c=(e.root.elementFromPoint?e.root:s).elementFromPoint(t.left,t.top);if(!c||!e.dom.contains(1!=c.nodeType?c.parentNode:c)){let n=e.dom.getBoundingClientRect();if(!oA(t,n)||!(c=function e(t,n,r){let i=t.childNodes.length;if(i&&r.top<r.bottom)for(let s=Math.max(0,Math.min(i-1,Math.floor(i*(n.top-r.top)/(r.bottom-r.top))-2)),o=s;;){let r=t.childNodes[o];if(1==r.nodeType){let t=r.getClientRects();for(let i=0;i<t.length;i++){let s=t[i];if(oA(n,s))return e(r,n,s)}}if((o=(o+1)%i)==s)break}return t}(e.dom,t,n)))return null}if(ob)for(let e=c;o&&e;e=s3(e))e.draggable&&(o=void 0);if(c=(r=(n=c).parentNode)&&/^li$/i.test(r.nodeName)&&t.left<n.getBoundingClientRect().left?r:n,o){let n;if(oh&&1==o.nodeType&&(a=Math.min(a,o.childNodes.length))<o.childNodes.length){let e=o.childNodes[a],n;"IMG"==e.nodeName&&(n=e.getBoundingClientRect()).right<=t.left&&n.bottom>t.top&&a++}ok&&a&&1==o.nodeType&&1==(n=o.childNodes[a-1]).nodeType&&"false"==n.contentEditable&&n.getBoundingClientRect().top>=t.top&&a--,o==e.dom&&a==o.childNodes.length-1&&1==o.lastChild.nodeType&&t.top>o.lastChild.getBoundingClientRect().bottom?i=e.state.doc.content.size:(0==a||1!=o.nodeType||"BR"!=o.childNodes[a-1].nodeName)&&(i=function(e,t,n,r){let i=-1;for(let n=t,s=!1;n!=e.dom;){let t=e.docView.nearestDesc(n,!0),o;if(!t)return null;if(1==t.dom.nodeType&&(t.node.isBlock&&t.parent||!t.contentDOM)&&((o=t.dom.getBoundingClientRect()).width||o.height)&&(t.node.isBlock&&t.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(t.dom.nodeName)&&(!s&&o.left>r.left||o.top>r.top?i=t.posBefore:(!s&&o.right<r.left||o.bottom<r.top)&&(i=t.posAfter),s=!0),!t.contentDOM&&i<0&&!t.node.isText))return(t.node.isBlock?r.top<(o.top+o.bottom)/2:r.left<(o.left+o.right)/2)?t.posBefore:t.posAfter;n=t.dom.parentNode}return i>-1?i:e.docView.posFromDOM(t,n,-1)}(e,o,a,t))}null==i&&(i=function(e,t,n){let{node:r,offset:i}=function e(t,n){let r,i,s,o=2e8,a,l=0,c=n.top,d=n.top;for(let e=t.firstChild,u=0;e;e=e.nextSibling,u++){let t;if(1==e.nodeType)t=e.getClientRects();else{if(3!=e.nodeType)continue;t=s4(e).getClientRects()}for(let p=0;p<t.length;p++){let h=t[p];if(h.top<=c&&h.bottom>=d){c=Math.max(h.bottom,c),d=Math.min(h.top,d);let t=h.left>n.left?h.left-n.left:h.right<n.left?n.left-h.right:0;if(t<o){s=e,o=t,a=t&&3==s.nodeType?{left:h.right<n.left?h.right:h.left,top:n.top}:n,1==e.nodeType&&t&&(l=u+ +(n.left>=(h.left+h.right)/2));continue}}else h.top>n.top&&!r&&h.left<=n.left&&h.right>=n.left&&(r=e,i={left:Math.max(h.left,Math.min(h.right,n.left)),top:h.top});!s&&(n.left>=h.right&&n.top>=h.top||n.left>=h.left&&n.top>=h.bottom)&&(l=u+1)}}return(!s&&r&&(s=r,a=i,o=0),s&&3==s.nodeType)?function(e,t){let n=e.nodeValue.length,r=document.createRange(),i;for(let s=0;s<n;s++){r.setEnd(e,s+1),r.setStart(e,s);let n=oO(r,1);if(n.top!=n.bottom&&oA(t,n)){i={node:e,offset:s+ +(t.left>=(n.left+n.right)/2)};break}}return r.detach(),i||{node:e,offset:0}}(s,a):!s||o&&1==s.nodeType?{node:t,offset:l}:e(s,a)}(t,n),s=-1;if(1==r.nodeType&&!r.firstChild){let e=r.getBoundingClientRect();s=e.left!=e.right&&n.left>(e.left+e.right)/2?1:-1}return e.docView.posFromDOM(r,i,s)}(e,c,t));let d=e.docView.nearestDesc(c,!0);return{pos:i,inside:d?d.posAtStart-d.border:-1}}(this,e)}coordsAtPos(e,t=1){return oD(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,n=-1){let r=this.docView.posFromDOM(e,t,n);if(null==r)throw RangeError("DOM position not inside the editor");return r}endOfTextblock(e,t){return function(e,t,n){let r,i;return oz==t&&o$==n?oB:(oz=t,o$=n,oB="up"==n||"down"==n?(r=t.selection,i="up"==n?r.$from:r.$to,oL(e,t,()=>{let{node:t}=e.docView.domFromPos(i.pos,"up"==n?-1:1);for(;;){let n=e.docView.nearestDesc(t,!0);if(!n)break;if(n.node.isBlock){t=n.contentDOM||n.dom;break}t=n.dom.parentNode}let r=oD(e,i.pos,1);for(let e=t.firstChild;e;e=e.nextSibling){let t;if(1==e.nodeType)t=e.getClientRects();else{if(3!=e.nodeType)continue;t=s4(e,0,e.nodeValue.length).getClientRects()}for(let e=0;e<t.length;e++){let i=t[e];if(i.bottom>i.top+1&&("up"==n?r.top-i.top>(i.bottom-r.top)*2:i.bottom-r.bottom>(r.bottom-i.top)*2))return!1}}return!0})):function(e,t,n){let{$head:r}=t.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,s=i==r.parent.content.size,o=e.domSelection();return o?oP.test(r.parent.textContent)&&o.modify?oL(e,t,()=>{let{focusNode:t,focusOffset:i,anchorNode:s,anchorOffset:a}=e.domSelectionRange(),l=o.caretBidiLevel;o.modify("move",n,"character");let c=r.depth?e.docView.domAfterPos(r.before()):e.dom,{focusNode:d,focusOffset:u}=e.domSelectionRange(),p=d&&!c.contains(1==d.nodeType?d:d.parentNode)||t==d&&i==u;try{o.collapse(s,a),t&&(t!=s||i!=a)&&o.extend&&o.extend(t,i)}catch(e){}return null!=l&&(o.caretBidiLevel=l),p}):"left"==n||"backward"==n?!i:s:r.pos==r.start()||r.pos==r.end()}(e,t,n))}(this,t||this.state,e)}pasteHTML(e,t){return aG(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return aG(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return av(this,e)}destroy(){if(this.docView){for(let e in this.domObserver.stop(),this.input.eventHandlers)this.dom.removeEventListener(e,this.input.eventHandlers[e]);clearTimeout(this.input.composingTimeout),clearTimeout(this.input.lastIOSEnterFallbackTimeout),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],lo(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,s6()}}get isDestroyed(){return null==this.docView}dispatchEvent(e){!aL(this,e)&&aT[e.type]&&(this.editable||!(e.type in aO))&&aT[e.type](this,e)}domSelectionRange(){let e=this.domSelection();return e?ob&&11===this.root.nodeType&&function(e){let t=e.activeElement;for(;t&&t.shadowRoot;)t=t.shadowRoot.activeElement;return t}(this.dom.ownerDocument)==this.dom&&function(e,t){let n;if(t.getComposedRanges){let n=t.getComposedRanges(e.root)[0];if(n)return lh(e,n)}function r(e){e.preventDefault(),e.stopImmediatePropagation(),n=e.getTargetRanges()[0]}return e.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),e.dom.removeEventListener("beforeinput",r,!0),n?lh(e,n):null}(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function lv(e){let t=Object.create(null);return t.class="ProseMirror",t.contenteditable=String(e.editable),e.someProp("attributes",n=>{if("function"==typeof n&&(n=n(e.state)),n)for(let e in n)"class"==e?t.class+=" "+n[e]:"style"==e?t.style=(t.style?t.style+";":"")+n[e]:t[e]||"contenteditable"==e||"nodeName"==e||(t[e]=String(n[e]))}),t.translate||(t.translate="no"),[a3.node(0,e.state.doc.content.size,t)]}function lw(e){if(e.markCursor){let t=document.createElement("img");t.className="ProseMirror-separator",t.setAttribute("mark-placeholder","true"),t.setAttribute("alt",""),e.cursorWrapper={dom:t,deco:a3.widget(e.state.selection.from,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function lk(e){return!e.someProp("editable",t=>!1===t(e.state))}function lN(e){let t=Object.create(null);function n(e){for(let n in e)Object.prototype.hasOwnProperty.call(t,n)||(t[n]=e[n])}return e.someProp("nodeViews",n),e.someProp("markViews",n),t}function lS(e){if(e.spec.state||e.spec.filterTransaction||e.spec.appendTransaction)throw RangeError("Plugins passed directly to the view must not have a state component")}ly.prototype.dispatch=function(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))};for(var lC={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:"'"},lj={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},lE="u">typeof navigator&&/Mac/.test(navigator.platform),lM="u">typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),lA=0;lA<10;lA++)lC[48+lA]=lC[96+lA]=String(lA);for(var lA=1;lA<=24;lA++)lC[lA+111]="F"+lA;for(var lA=65;lA<=90;lA++)lC[lA]=String.fromCharCode(lA+32),lj[lA]=String.fromCharCode(lA);for(var lT in lC)lj.hasOwnProperty(lT)||(lj[lT]=lC[lT]);let lO="u">typeof navigator&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),l_="u">typeof navigator&&/Win/.test(navigator.platform);function lD(e,t,n=!0){return t.altKey&&(e="Alt-"+e),t.ctrlKey&&(e="Ctrl-"+e),t.metaKey&&(e="Meta-"+e),n&&t.shiftKey&&(e="Shift-"+e),e}function lR(e){let t=function(e){let t=Object.create(null);for(let n in e)t[function(e){let t,n,r,i,s=e.split(/-(?!$)/),o=s[s.length-1];"Space"==o&&(o=" ");for(let e=0;e<s.length-1;e++){let o=s[e];if(/^(cmd|meta|m)$/i.test(o))i=!0;else if(/^a(lt)?$/i.test(o))t=!0;else if(/^(c|ctrl|control)$/i.test(o))n=!0;else if(/^s(hift)?$/i.test(o))r=!0;else if(/^mod$/i.test(o))lO?i=!0:n=!0;else throw Error("Unrecognized modifier name: "+o)}return t&&(o="Alt-"+o),n&&(o="Ctrl-"+o),i&&(o="Meta-"+o),r&&(o="Shift-"+o),o}(n)]=e[n];return t}(e);return function(e,n){var r;let i=("Esc"==(r=!(lE&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||lM&&n.shiftKey&&n.key&&1==n.key.length||"Unidentified"==n.key)&&n.key||(n.shiftKey?lj:lC)[n.keyCode]||n.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),s,o=t[lD(i,n)];if(o&&o(e.state,e.dispatch,e))return!0;if(1==i.length&&" "!=i){if(n.shiftKey){let r=t[lD(i,n,!1)];if(r&&r(e.state,e.dispatch,e))return!0}if((n.altKey||n.metaKey||n.ctrlKey)&&!(l_&&n.ctrlKey&&n.altKey)&&(s=lC[n.keyCode])&&s!=i){let r=t[lD(s,n)];if(r&&r(e.state,e.dispatch,e))return!0}}return!1}}if("u">typeof WeakMap){let e=new WeakMap;t=t=>e.get(t),n=(t,n)=>(e.set(t,n),n)}else{let e=[],r=0;t=t=>{for(let n=0;n<e.length;n+=2)if(e[n]==t)return e[n+1]},n=(t,n)=>(10==r&&(r=0),e[r++]=t,e[r++]=n)}var lI=class{constructor(e,t,n,r){this.width=e,this.height=t,this.map=n,this.problems=r}findCell(e){for(let t=0;t<this.map.length;t++){let n=this.map[t];if(n!=e)continue;let r=t%this.width,i=t/this.width|0,s=r+1,o=i+1;for(let e=1;s<this.width&&this.map[t+e]==n;e++)s++;for(let e=1;o<this.height&&this.map[t+this.width*e]==n;e++)o++;return{left:r,top:i,right:s,bottom:o}}throw RangeError(`No cell with offset ${e} found`)}colCount(e){for(let t=0;t<this.map.length;t++)if(this.map[t]==e)return t%this.width;throw RangeError(`No cell with offset ${e} found`)}nextCell(e,t,n){let{left:r,right:i,top:s,bottom:o}=this.findCell(e);return"horiz"==t?(n<0?0==r:i==this.width)?null:this.map[s*this.width+(n<0?r-1:i)]:(n<0?0==s:o==this.height)?null:this.map[r+this.width*(n<0?s-1:o)]}rectBetween(e,t){let{left:n,right:r,top:i,bottom:s}=this.findCell(e),{left:o,right:a,top:l,bottom:c}=this.findCell(t);return{left:Math.min(n,o),top:Math.min(i,l),right:Math.max(r,a),bottom:Math.max(s,c)}}cellsInRect(e){let t=[],n={};for(let r=e.top;r<e.bottom;r++)for(let i=e.left;i<e.right;i++){let s=r*this.width+i,o=this.map[s];!n[o]&&(n[o]=!0,i==e.left&&i&&this.map[s-1]==o||r==e.top&&r&&this.map[s-this.width]==o||t.push(o))}return t}positionAt(e,t,n){for(let r=0,i=0;;r++){let s=i+n.child(r).nodeSize;if(r==e){let n=t+e*this.width,r=(e+1)*this.width;for(;n<r&&this.map[n]<i;)n++;return n==r?s-1:this.map[n]}i=s}}static get(e){return t(e)||n(e,function(e){if("table"!=e.type.spec.tableRole)throw RangeError("Not a table node: "+e.type.name);let t=function(e){let t=-1,n=!1;for(let r=0;r<e.childCount;r++){let i=e.child(r),s=0;if(n)for(let t=0;t<r;t++){let n=e.child(t);for(let e=0;e<n.childCount;e++){let i=n.child(e);t+i.attrs.rowspan>r&&(s+=i.attrs.colspan)}}for(let e=0;e<i.childCount;e++){let t=i.child(e);s+=t.attrs.colspan,t.attrs.rowspan>1&&(n=!0)}-1==t?t=s:t!=s&&(t=Math.max(t,s))}return t}(e),n=e.childCount,r=[],i=0,s=null,o=[];for(let e=0,i=t*n;e<i;e++)r[e]=0;for(let a=0,l=0;a<n;a++){let c=e.child(a);l++;for(let e=0;;e++){for(;i<r.length&&0!=r[i];)i++;if(e==c.childCount)break;let d=c.child(e),{colspan:u,rowspan:p,colwidth:h}=d.attrs;for(let e=0;e<p;e++){if(e+a>=n){(s||(s=[])).push({type:"overlong_rowspan",pos:l,n:p-e});break}let c=i+e*t;for(let e=0;e<u;e++){0==r[c+e]?r[c+e]=l:(s||(s=[])).push({type:"collision",row:a,pos:l,n:u-e});let n=h&&h[e];if(n){let r=(c+e)%t*2,i=o[r];null==i||i!=n&&1==o[r+1]?(o[r]=n,o[r+1]=1):i==n&&o[r+1]++}}}i+=u,l+=d.nodeSize}let d=(a+1)*t,u=0;for(;i<d;)0==r[i++]&&u++;u&&(s||(s=[])).push({type:"missing",row:a,n:u}),l++}(0===t||0===n)&&(s||(s=[])).push({type:"zero_sized"});let a=new lI(t,n,r,s),l=!1;for(let e=0;!l&&e<o.length;e+=2)null!=o[e]&&o[e+1]<n&&(l=!0);return l&&function(e,t,n){e.problems||(e.problems=[]);let r={};for(let i=0;i<e.map.length;i++){let s=e.map[i];if(r[s])continue;r[s]=!0;let o=n.nodeAt(s);if(!o)throw RangeError(`No cell with offset ${s} found`);let a=null,l=o.attrs;for(let n=0;n<l.colspan;n++){let r=t[(i+n)%e.width*2];null==r||l.colwidth&&l.colwidth[n]==r||((a||(a=function(e){if(e.colwidth)return e.colwidth.slice();let t=[];for(let n=0;n<e.colspan;n++)t.push(0);return t}(l)))[n]=r)}a&&e.problems.unshift({type:"colwidth mismatch",pos:s,colwidth:a})}}(a,o,e),a}(e))}};function lL(e){let t=e.cached.tableNodeTypes;if(!t)for(let n in t=e.cached.tableNodeTypes={},e.nodes){let r=e.nodes[n],i=r.spec.tableRole;i&&(t[i]=r)}return t}let lP=new s1("selectingCells");function lz(e){for(let t=e.depth-1;t>0;t--)if("row"==e.node(t).type.spec.tableRole)return e.node(0).resolve(e.before(t+1));return null}function l$(e){let t=e.selection.$head;for(let e=t.depth;e>0;e--)if("row"==t.node(e).type.spec.tableRole)return!0;return!1}function lB(e){let t=e.selection;if("$anchorCell"in t&&t.$anchorCell)return t.$anchorCell.pos>t.$headCell.pos?t.$anchorCell:t.$headCell;if("node"in t&&t.node&&"cell"==t.node.type.spec.tableRole)return t.$anchor;let n=lz(t.$head)||function(e){for(let t=e.nodeAfter,n=e.pos;t;t=t.firstChild,n++){let r=t.type.spec.tableRole;if("cell"==r||"header_cell"==r)return e.doc.resolve(n)}for(let t=e.nodeBefore,n=e.pos;t;t=t.lastChild,n--){let r=t.type.spec.tableRole;if("cell"==r||"header_cell"==r)return e.doc.resolve(n-t.nodeSize)}}(t.$head);if(n)return n;throw RangeError(`No cell found around position ${t.head}`)}function lF(e){return"row"==e.parent.type.spec.tableRole&&!!e.nodeAfter}function lH(e,t){return e.depth==t.depth&&e.pos>=t.start(-1)&&e.pos<=t.end(-1)}function lU(e,t,n){let r=e.node(-1),i=lI.get(r),s=e.start(-1),o=i.nextCell(e.pos-s,t,n);return null==o?null:e.node(0).resolve(s+o)}function lV(e,t,n=1){let r={...e,colspan:e.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(t,n),r.colwidth.some(e=>e>0)||(r.colwidth=null)),r}function lW(e,t,n=1){let r={...e,colspan:e.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let e=0;e<n;e++)r.colwidth.splice(t,0,0)}return r}var lq=class e extends sR{constructor(e,t=e){const n=e.node(-1),r=lI.get(n),i=e.start(-1),s=r.rectBetween(e.pos-i,t.pos-i),o=e.node(0),a=r.cellsInRect(s).filter(e=>e!=t.pos-i);a.unshift(t.pos-i);const l=a.map(e=>{let t=n.nodeAt(e);if(!t)throw RangeError(`No cell with offset ${e} found`);let r=i+e+1;return new sI(o.resolve(r),o.resolve(r+t.content.size))});super(l[0].$from,l[0].$to,l),this.$anchorCell=e,this.$headCell=t}map(t,n){let r=t.resolve(n.map(this.$anchorCell.pos)),i=t.resolve(n.map(this.$headCell.pos));if(lF(r)&&lF(i)&&lH(r,i)){let t=this.$anchorCell.node(-1)!=r.node(-1);return t&&this.isRowSelection()?e.rowSelection(r,i):t&&this.isColSelection()?e.colSelection(r,i):new e(r,i)}return sz.between(r,i)}content(){let e=this.$anchorCell.node(-1),t=lI.get(e),n=this.$anchorCell.start(-1),r=t.rectBetween(this.$anchorCell.pos-n,this.$headCell.pos-n),i={},s=[];for(let n=r.top;n<r.bottom;n++){let o=[];for(let s=n*t.width+r.left,a=r.left;a<r.right;a++,s++){let n=t.map[s];if(i[n])continue;i[n]=!0;let a=t.findCell(n),l=e.nodeAt(n);if(!l)throw RangeError(`No cell with offset ${n} found`);let c=r.left-a.left,d=a.right-r.right;if(c>0||d>0){let e=l.attrs;if(c>0&&(e=lV(e,0,c)),d>0&&(e=lV(e,e.colspan-d,d)),a.left<r.left){if(!(l=l.type.createAndFill(e)))throw RangeError(`Could not create cell with attrs ${JSON.stringify(e)}`)}else l=l.type.create(e,l.content)}if(a.top<r.top||a.bottom>r.bottom){let e={...l.attrs,rowspan:Math.min(a.bottom,r.bottom)-Math.max(a.top,r.top)};l=a.top<r.top?l.type.createAndFill(e):l.type.create(e,l.content)}o.push(l)}s.push(e.child(n).copy(ic.from(o)))}let o=this.isColSelection()&&this.isRowSelection()?e:s;return new ig(ic.from(o),1,1)}replace(e,t=ig.empty){let n=e.steps.length,r=this.ranges;for(let i=0;i<r.length;i++){let{$from:s,$to:o}=r[i],a=e.mapping.slice(n);e.replace(a.map(s.pos),a.map(o.pos),i?ig.empty:t)}let i=sR.findFrom(e.doc.resolve(e.mapping.slice(n).map(this.to)),-1);i&&e.setSelection(i)}replaceWith(e,t){this.replace(e,new ig(ic.from(t),0,0))}forEachCell(e){let t=this.$anchorCell.node(-1),n=lI.get(t),r=this.$anchorCell.start(-1),i=n.cellsInRect(n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r));for(let n=0;n<i.length;n++)e(t.nodeAt(i[n]),r+i[n])}isColSelection(){let e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);return!(Math.min(e,t)>0)&&Math.max(e+this.$anchorCell.nodeAfter.attrs.rowspan,t+this.$headCell.nodeAfter.attrs.rowspan)==this.$headCell.node(-1).childCount}static colSelection(t,n=t){let r=t.node(-1),i=lI.get(r),s=t.start(-1),o=i.findCell(t.pos-s),a=i.findCell(n.pos-s),l=t.node(0);return o.top<=a.top?(o.top>0&&(t=l.resolve(s+i.map[o.left])),a.bottom<i.height&&(n=l.resolve(s+i.map[i.width*(i.height-1)+a.right-1]))):(a.top>0&&(n=l.resolve(s+i.map[a.left])),o.bottom<i.height&&(t=l.resolve(s+i.map[i.width*(i.height-1)+o.right-1]))),new e(t,n)}isRowSelection(){let e=this.$anchorCell.node(-1),t=lI.get(e),n=this.$anchorCell.start(-1),r=t.colCount(this.$anchorCell.pos-n),i=t.colCount(this.$headCell.pos-n);return!(Math.min(r,i)>0)&&Math.max(r+this.$anchorCell.nodeAfter.attrs.colspan,i+this.$headCell.nodeAfter.attrs.colspan)==t.width}eq(t){return t instanceof e&&t.$anchorCell.pos==this.$anchorCell.pos&&t.$headCell.pos==this.$headCell.pos}static rowSelection(t,n=t){let r=t.node(-1),i=lI.get(r),s=t.start(-1),o=i.findCell(t.pos-s),a=i.findCell(n.pos-s),l=t.node(0);return o.left<=a.left?(o.left>0&&(t=l.resolve(s+i.map[o.top*i.width])),a.right<i.width&&(n=l.resolve(s+i.map[i.width*(a.top+1)-1]))):(a.left>0&&(n=l.resolve(s+i.map[a.top*i.width])),o.right<i.width&&(t=l.resolve(s+i.map[i.width*(o.top+1)-1]))),new e(t,n)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(t,n){return new e(t.resolve(n.anchor),t.resolve(n.head))}static create(t,n,r=n){return new e(t.resolve(n),t.resolve(r))}getBookmark(){return new lK(this.$anchorCell.pos,this.$headCell.pos)}};lq.prototype.visible=!1,sR.jsonID("cell",lq);var lK=class e{constructor(e,t){this.anchor=e,this.head=t}map(t){return new e(t.map(this.anchor),t.map(this.head))}resolve(e){let t=e.resolve(this.anchor),n=e.resolve(this.head);return"row"==t.parent.type.spec.tableRole&&"row"==n.parent.type.spec.tableRole&&t.index()<t.parent.childCount&&n.index()<n.parent.childCount&&lH(t,n)?new lq(t,n):sR.near(n,1)}};function lG(e){if(!(e.selection instanceof lq))return null;let t=[];return e.selection.forEachCell((e,n)=>{t.push(a3.node(n,n+e.nodeSize,{class:"selectedCell"}))}),a6.create(e.doc,t)}let lJ=new s1("fix-tables");function lZ(e,t){let n,r=(t,r)=>{"table"==t.type.spec.tableRole&&(n=function(e,t,n,r){let i,s,o=lI.get(t);if(!o.problems)return r;r||(r=e.tr);let a=[];for(let e=0;e<o.height;e++)a.push(0);for(let e=0;e<o.problems.length;e++){let i=o.problems[e];if("collision"==i.type){let e=t.nodeAt(i.pos);if(!e)continue;let s=e.attrs;for(let e=0;e<s.rowspan;e++)a[i.row+e]+=i.n;r.setNodeMarkup(r.mapping.map(n+1+i.pos),null,lV(s,s.colspan-i.n,i.n))}else if("missing"==i.type)a[i.row]+=i.n;else if("overlong_rowspan"==i.type){let e=t.nodeAt(i.pos);if(!e)continue;r.setNodeMarkup(r.mapping.map(n+1+i.pos),null,{...e.attrs,rowspan:e.attrs.rowspan-i.n})}else if("colwidth mismatch"==i.type){let e=t.nodeAt(i.pos);if(!e)continue;r.setNodeMarkup(r.mapping.map(n+1+i.pos),null,{...e.attrs,colwidth:i.colwidth})}else if("zero_sized"==i.type){let e=r.mapping.map(n);r.delete(e,e+t.nodeSize)}}for(let e=0;e<a.length;e++)a[e]&&(null==i&&(i=e),s=e);for(let l=0,c=n+1;l<o.height;l++){let n=t.child(l),o=c+n.nodeSize,d=a[l];if(d>0){let t="cell";n.firstChild&&(t=n.firstChild.type.spec.tableRole);let a=[];for(let n=0;n<d;n++){let n=lL(e.schema)[t].createAndFill();n&&a.push(n)}let u=(0==l||i==l-1)&&s==l?c+1:o-1;r.insert(r.mapping.map(u),a)}c=o}return r.setMeta(lJ,{fixTables:!0})}(e,t,r,n))};return t?t.doc!=e.doc&&function e(t,n,r,i){let s=t.childCount,o=n.childCount;n:for(let a=0,l=0;a<o;a++){let o=n.child(a);for(let e=l,n=Math.min(s,a+3);e<n;e++)if(t.child(e)==o){l=e+1,r+=o.nodeSize;continue n}i(o,r),l<s&&t.child(l).sameMarkup(o)?e(t.child(l),o,r+1,i):o.nodesBetween(0,o.content.size,i,r+1),r+=o.nodeSize}}(t.doc,e.doc,0,r):e.doc.descendants(r),n}function lX(e){let t=lI.get(e),n=[],r=t.height,i=t.width;for(let s=0;s<r;s++){let r=[];for(let n=0;n<i;n++){let o=s*i+n,a=t.map[o];if(s>0){let e=o-i;if(a===t.map[e]){r.push(null);continue}}if(n>0){let e=o-1;if(a===t.map[e]){r.push(null);continue}}r.push(e.nodeAt(a))}n.push(r)}return n}function lY(e,t){let n=[],r=lI.get(e),i=r.height,s=r.width;for(let o=0;o<i;o++){let i=e.child(o),a=[];for(let n=0;n<s;n++){let i=t[o][n];if(!i)continue;let s=r.map[o*r.width+n],l=e.nodeAt(s);if(!l)continue;let c=l.type.createChecked(i.attrs,i.content,i.marks);a.push(c)}let l=i.type.createChecked(i.attrs,a,i.marks);n.push(l)}return e.type.createChecked(e.attrs,n,e.marks)}function lQ(e,t,n,r){let i,s=t[0]>n[0]?-1:1,o=e.splice(t[0],t.length),a=+(o.length%2==0);return i=-1===r&&1===s?n[0]-1:1===r&&-1===s?n[n.length-1]-a+1:-1===s?n[0]:n[n.length-1]-a,e.splice(i,0,...o),e}function l0(e){var t=e;for(let e=t.depth;e>=0;e-=1){let n=t.node(e);if((e=>"table"===e.type.spec.tableRole)(n))return{node:n,pos:0===e?0:t.before(e),start:t.start(e),depth:e}}return null}function l1(e,t){let n=l0(t.$from);if(!n)return;let r=lI.get(n.node);if(!(e<0)&&!(e>r.width-1))return r.cellsInRect({left:e,right:e+1,top:0,bottom:r.height}).map(e=>{let t=n.node.nodeAt(e),r=e+n.start;return{pos:r,start:r+1,node:t,depth:n.depth+2}})}function l2(e,t){let n=l0(t.$from);if(!n)return;let r=lI.get(n.node);if(!(e<0)&&!(e>r.height-1))return r.cellsInRect({left:0,right:r.width,top:e,bottom:e+1}).map(e=>{let t=n.node.nodeAt(e),r=e+n.start;return{pos:r,start:r+1,node:t,depth:n.depth+2}})}function l3(e,t,n=t){let r,i=t,s=n;for(let n=t;n>=0;n--){let t=l1(n,e.selection);t&&t.forEach(e=>{let t=e.node.attrs.colspan+n-1;t>=i&&(i=n),t>s&&(s=t)})}for(let n=t;n<=s;n++){let t=l1(n,e.selection);t&&t.forEach(e=>{let t=e.node.attrs.colspan+n-1;e.node.attrs.colspan>1&&t>s&&(s=t)})}let o=[];for(let t=i;t<=s;t++){let n=l1(t,e.selection);n&&n.length>0&&o.push(t)}i=o[0],s=o[o.length-1];let a=l1(i,e.selection),l=l2(0,e.selection);if(!a||!l)return;let c=e.doc.resolve(a[a.length-1].pos);for(let t=s;t>=i;t--){let n=l1(t,e.selection);if(n&&n.length>0){for(let e=l.length-1;e>=0;e--)if(l[e].pos===n[0].pos){r=n[0];break}if(r)break}}if(r)return{$anchor:c,$head:e.doc.resolve(r.pos),indexes:o}}function l5(e,t,n=t){let r,i=t,s=n;for(let n=t;n>=0;n--){let t=l2(n,e.selection);t&&t.forEach(e=>{let t=e.node.attrs.rowspan+n-1;t>=i&&(i=n),t>s&&(s=t)})}for(let n=t;n<=s;n++){let t=l2(n,e.selection);t&&t.forEach(e=>{let t=e.node.attrs.rowspan+n-1;e.node.attrs.rowspan>1&&t>s&&(s=t)})}let o=[];for(let t=i;t<=s;t++){let n=l2(t,e.selection);n&&n.length>0&&o.push(t)}i=o[0],s=o[o.length-1];let a=l2(i,e.selection),l=l1(0,e.selection);if(!a||!l)return;let c=e.doc.resolve(a[a.length-1].pos);for(let t=s;t>=i;t--){let n=l2(t,e.selection);if(n&&n.length>0){for(let e=l.length-1;e>=0;e--)if(l[e].pos===n[0].pos){r=n[0];break}if(r)break}}if(r)return{$anchor:c,$head:e.doc.resolve(r.pos),indexes:o}}function l4(e){return e[0].map((t,n)=>e.map(e=>e[n]))}function l6(e){let t=e.selection,n=lB(e),r=n.node(-1),i=n.start(-1),s=lI.get(r);return{...t instanceof lq?s.rectBetween(t.$anchorCell.pos-i,t.$headCell.pos-i):s.findCell(n.pos-i),tableStart:i,map:s,table:r}}function l9(e,{map:t,tableStart:n,table:r},i){let s=i>0?-1:0;(function(e,t,n){let r=lL(t.type.schema).header_cell;for(let i=0;i<e.height;i++)if(t.nodeAt(e.map[n+i*e.width]).type!=r)return!1;return!0})(t,r,i+s)&&(s=0==i||i==t.width?null:0);for(let o=0;o<t.height;o++){let a=o*t.width+i;if(i>0&&i<t.width&&t.map[a-1]==t.map[a]){let s=t.map[a],l=r.nodeAt(s);e.setNodeMarkup(e.mapping.map(n+s),null,lW(l.attrs,i-t.colCount(s))),o+=l.attrs.rowspan-1}else{let l=null==s?lL(r.type.schema).cell:r.nodeAt(t.map[a+s]).type,c=t.positionAt(o,i,r);e.insert(e.mapping.map(n+c),l.createAndFill())}}return e}function l7(e,{map:t,tableStart:n,table:r},i){let s=n;for(let e=0;e<i;e++)s+=r.child(e).nodeSize;let o=[],a=i>0?-1:0;(function(e,t,n){var r;let i=lL(t.type.schema).header_cell;for(let s=0;s<e.width;s++)if((null==(r=t.nodeAt(e.map[s+n*e.width]))?void 0:r.type)!=i)return!1;return!0})(t,r,i+a)&&(a=0==i||i==t.height?null:0);for(let s=0,c=t.width*i;s<t.width;s++,c++)if(i>0&&i<t.height&&t.map[c]==t.map[c-t.width]){let i=t.map[c],o=r.nodeAt(i).attrs;e.setNodeMarkup(n+i,null,{...o,rowspan:o.rowspan+1}),s+=o.colspan-1}else{var l;let e=null==a?lL(r.type.schema).cell:null==(l=r.nodeAt(t.map[c+a*t.width]))?void 0:l.type,n=null==e?void 0:e.createAndFill();n&&o.push(n)}return e.insert(s,lL(r.type.schema).row.create(null,o)),e}function l8(e){let t=e.content;return 1==t.childCount&&t.child(0).isTextblock&&0==t.child(0).childCount}function ce(e,t){let n=e.selection;if(!(n instanceof lq)||n.$anchorCell.pos==n.$headCell.pos)return!1;let r=l6(e),{map:i}=r;if(function({width:e,height:t,map:n},r){let i=r.top*e+r.left,s=i,o=(r.bottom-1)*e+r.left,a=i+(r.right-r.left-1);for(let t=r.top;t<r.bottom;t++){if(r.left>0&&n[s]==n[s-1]||r.right<e&&n[a]==n[a+1])return!0;s+=e,a+=e}for(let s=r.left;s<r.right;s++){if(r.top>0&&n[i]==n[i-e]||r.bottom<t&&n[o]==n[o+e])return!0;i++,o++}return!1}(i,r))return!1;if(t){let n,s,o=e.tr,a={},l=ic.empty;for(let e=r.top;e<r.bottom;e++)for(let t=r.left;t<r.right;t++){let c=i.map[e*i.width+t],d=r.table.nodeAt(c);if(!a[c]&&d)if(a[c]=!0,null==n)n=c,s=d;else{l8(d)||(l=l.append(d.content));let e=o.mapping.map(c+r.tableStart);o.delete(e,e+d.nodeSize)}}if(null==n||null==s)return!0;if(o.setNodeMarkup(n+r.tableStart,null,{...lW(s.attrs,s.attrs.colspan,r.right-r.left-s.attrs.colspan),rowspan:r.bottom-r.top}),l.size>0){let e=n+1+s.content.size,t=l8(s)?n+1:e;o.replaceWith(t+r.tableStart,e+r.tableStart,l)}o.setSelection(new lq(o.doc.resolve(n+r.tableStart))),t(o)}return!0}function ct(e,t){var n;let r=lL(e.schema);return(n=({node:e})=>r[e.type.spec.tableRole],(e,t)=>{let r,i,s=e.selection;if(s instanceof lq){if(s.$anchorCell.pos!=s.$headCell.pos)return!1;r=s.$anchorCell.nodeAfter,i=s.$anchorCell.pos}else{var o;if(!(r=function(e){for(let t=e.depth;t>0;t--){let n=e.node(t).type.spec.tableRole;if("cell"===n||"header_cell"===n)return e.node(t)}return null}(s.$from)))return!1;i=null==(o=lz(s.$from))?void 0:o.pos}if(null==r||null==i||1==r.attrs.colspan&&1==r.attrs.rowspan)return!1;if(t){let o,a=r.attrs,l=[],c=a.colwidth;a.rowspan>1&&(a={...a,rowspan:1}),a.colspan>1&&(a={...a,colspan:1});let d=l6(e),u=e.tr;for(let e=0;e<d.right-d.left;e++)l.push(c?{...a,colwidth:c&&c[e]?[c[e]]:null}:a);for(let e=d.top;e<d.bottom;e++){let t=d.map.positionAt(e,d.left,d.table);e==d.top&&(t+=r.nodeSize);for(let i=d.left,s=0;i<d.right;i++,s++)(i!=d.left||e!=d.top)&&u.insert(o=u.mapping.map(t+d.tableStart,1),n({node:r,row:e,col:i}).createAndFill(l[s]))}u.setNodeMarkup(i,n({node:r,row:d.top,col:d.left}),l[0]),s instanceof lq&&u.setSelection(new lq(u.doc.resolve(s.$anchorCell.pos),o?u.doc.resolve(o):void 0)),t(u)}return!0})(e,t)}function cn(e,t,n){let r=t.map.cellsInRect({left:0,top:0,right:"row"==e?t.map.width:1,bottom:"column"==e?t.map.height:1});for(let e=0;e<r.length;e++){let i=t.table.nodeAt(r[e]);if(i&&i.type!==n.header_cell)return!1}return!0}function cr(e,t){if((t=t||{useDeprecatedLogic:!1}).useDeprecatedLogic)return function(t,n){if(!l$(t))return!1;if(n){let r=lL(t.schema),i=l6(t),s=t.tr,o=i.map.cellsInRect("column"==e?{left:i.left,top:0,right:i.right,bottom:i.map.height}:"row"==e?{left:0,top:i.top,right:i.map.width,bottom:i.bottom}:i),a=o.map(e=>i.table.nodeAt(e));for(let e=0;e<o.length;e++)a[e].type==r.header_cell&&s.setNodeMarkup(i.tableStart+o[e],r.cell,a[e].attrs);if(0===s.steps.length)for(let e=0;e<o.length;e++)s.setNodeMarkup(i.tableStart+o[e],r.header_cell,a[e].attrs);n(s)}return!0};return function(t,n){if(!l$(t))return!1;if(n){let r=lL(t.schema),i=l6(t),s=t.tr,o=cn("row",i,r),a=cn("column",i,r),l=+("column"===e?!!o:"row"===e&&!!a),c="column"==e?{left:0,top:l,right:1,bottom:i.map.height}:"row"==e?{left:l,top:0,right:i.map.width,bottom:1}:i,d="column"==e?a?r.cell:r.header_cell:"row"==e?o?r.cell:r.header_cell:r.cell;i.map.cellsInRect(c).forEach(e=>{let t=e+i.tableStart,n=s.doc.nodeAt(t);n&&s.setNodeMarkup(t,d,n.attrs)}),n(s)}return!0}}cr("row",{useDeprecatedLogic:!0}),cr("column",{useDeprecatedLogic:!0});let ci=cr("cell",{useDeprecatedLogic:!0});function cs(e){return function(t,n){if(!l$(t))return!1;let r=function(e,t){if(t<0){let t=e.nodeBefore;if(t)return e.pos-t.nodeSize;for(let t=e.index(-1)-1,n=e.before();t>=0;t--){let r=e.node(-1).child(t),i=r.lastChild;if(i)return n-1-i.nodeSize;n-=r.nodeSize}}else{if(e.index()<e.parent.childCount-1)return e.pos+e.nodeAfter.nodeSize;let t=e.node(-1);for(let n=e.indexAfter(-1),r=e.after();n<t.childCount;n++){let e=t.child(n);if(e.childCount)return r+1;r+=e.nodeSize}}return null}(lB(t),e);if(null==r)return!1;if(n){let e=t.doc.resolve(r);n(t.tr.setSelection(sz.between(e,e.node(0).resolve(e.pos+e.nodeAfter.nodeSize))).scrollIntoView())}return!0}}function co(e,t){let n=e.selection;if(!(n instanceof lq))return!1;if(t){let r=e.tr,i=lL(e.schema).cell.createAndFill().content;n.forEachCell((e,t)=>{e.content.eq(i)||r.replace(r.mapping.map(t+1),r.mapping.map(t+e.nodeSize-1),new ig(i,0,0))}),r.docChanged&&t(r)}return!0}function ca(e,t){let n=e.createAndFill();return new s_(n).replace(0,n.content.size,t).doc}function cl(e,t,n,r,i,s,o,a){if(0==o||o==t.height)return!1;let l=!1;for(let c=i;c<s;c++){let i=o*t.width+c,s=t.map[i];if(t.map[i-t.width]==s){l=!0;let i=n.nodeAt(s),{top:d,left:u}=t.findCell(s);e.setNodeMarkup(e.mapping.slice(a).map(s+r),null,{...i.attrs,rowspan:o-d}),e.insert(e.mapping.slice(a).map(t.positionAt(o,u,n)),i.type.createAndFill({...i.attrs,rowspan:d+i.attrs.rowspan-o})),c+=i.attrs.colspan-1}}return l}function cc(e,t,n,r,i,s,o,a){if(0==o||o==t.width)return!1;let l=!1;for(let c=i;c<s;c++){let i=c*t.width+o,s=t.map[i];if(t.map[i-1]==s){l=!0;let i=n.nodeAt(s),d=t.colCount(s),u=e.mapping.slice(a).map(s+r);e.setNodeMarkup(u,null,lV(i.attrs,o-d,i.attrs.colspan-(o-d))),e.insert(u+i.nodeSize,i.type.createAndFill(lV(i.attrs,0,o-d))),c+=i.attrs.rowspan-1}}return l}function cd(e,t,n,r,i){let s=n?e.doc.nodeAt(n-1):e.doc;if(!s)throw Error("No table found");let o=lI.get(s),{top:a,left:l}=r,c=l+i.width,d=a+i.height,u=e.tr,p=0;function h(){if(!(s=n?u.doc.nodeAt(n-1):u.doc))throw Error("No table found");o=lI.get(s),p=u.mapping.maps.length}(function(e,t,n,r,i,s){let o,a,l=lL(e.doc.type.schema);if(i>t.width)for(let s=0,c=0;s<t.height;s++){let d,u=n.child(s);c+=u.nodeSize;let p=[];d=null==u.lastChild||u.lastChild.type==l.cell?o||(o=l.cell.createAndFill()):a||(a=l.header_cell.createAndFill());for(let e=t.width;e<i;e++)p.push(d);e.insert(e.mapping.slice(0).map(c-1+r),p)}if(s>t.height){let c=[];for(let e=0,r=(t.height-1)*t.width;e<Math.max(t.width,i);e++){let i=!(e>=t.width)&&n.nodeAt(t.map[r+e]).type==l.header_cell;c.push(i?a||(a=l.header_cell.createAndFill()):o||(o=l.cell.createAndFill()))}let d=l.row.create(null,ic.from(c)),u=[];for(let e=t.height;e<s;e++)u.push(d);e.insert(e.mapping.slice(0).map(r+n.nodeSize-2),u)}return!!(o||a)})(u,o,s,n,c,d)&&h(),cl(u,o,s,n,l,c,a,p)&&h(),cl(u,o,s,n,l,c,d,p)&&h(),cc(u,o,s,n,a,d,l,p)&&h(),cc(u,o,s,n,a,d,c,p)&&h();for(let e=a;e<d;e++){let t=o.positionAt(e,l,s),r=o.positionAt(e,c,s);u.replace(u.mapping.slice(p).map(t+n),u.mapping.slice(p).map(r+n),new ig(i.rows[e-a],0,0))}h(),u.setSelection(new lq(u.doc.resolve(n+o.positionAt(a,l,s)),u.doc.resolve(n+o.positionAt(d-1,c-1,s)))),t(u)}let cu=lR({ArrowLeft:ch("horiz",-1),ArrowRight:ch("horiz",1),ArrowUp:ch("vert",-1),ArrowDown:ch("vert",1),"Shift-ArrowLeft":cf("horiz",-1),"Shift-ArrowRight":cf("horiz",1),"Shift-ArrowUp":cf("vert",-1),"Shift-ArrowDown":cf("vert",1),Backspace:co,"Mod-Backspace":co,Delete:co,"Mod-Delete":co});function cp(e,t,n){return!n.eq(e.selection)&&(t&&t(e.tr.setSelection(n).scrollIntoView()),!0)}function ch(e,t){return(n,r,i)=>{if(!i)return!1;let s=n.selection;if(s instanceof lq)return cp(n,r,sR.near(s.$headCell,t));if("horiz"!=e&&!s.empty)return!1;let o=cx(i,e,t);if(null==o)return!1;if("horiz"==e)return cp(n,r,sR.near(n.doc.resolve(s.head+t),t));{let i,s=n.doc.resolve(o),a=lU(s,e,t);return i=a?sR.near(a,1):t<0?sR.near(n.doc.resolve(s.before(-1)),-1):sR.near(n.doc.resolve(s.after(-1)),1),cp(n,r,i)}}}function cf(e,t){return(n,r,i)=>{let s;if(!i)return!1;let o=n.selection;if(o instanceof lq)s=o;else{let r=cx(i,e,t);if(null==r)return!1;s=new lq(n.doc.resolve(r))}let a=lU(s.$headCell,e,t);return!!a&&cp(n,r,new lq(s.$anchorCell,a))}}function cm(e,t){let n=lz(e.state.doc.resolve(t));return!!n&&(e.dispatch(e.state.tr.setSelection(new lq(n))),!0)}function cg(e,t,n){if(!l$(e.state))return!1;let r=function(e){if(0===e.size)return null;let{content:t,openStart:n,openEnd:r}=e;for(;1==t.childCount&&(n>0&&r>0||"table"==t.child(0).type.spec.tableRole);)n--,r--,t=t.child(0).content;let i=t.child(0),s=i.type.spec.tableRole,o=i.type.schema,a=[];if("row"==s)for(let e=0;e<t.childCount;e++){let i=t.child(e).content,s=e?0:Math.max(0,n-1),l=e<t.childCount-1?0:Math.max(0,r-1);(s||l)&&(i=ca(lL(o).row,new ig(i,s,l)).content),a.push(i)}else{if("cell"!=s&&"header_cell"!=s)return null;a.push(n||r?ca(lL(o).row,new ig(t,n,r)).content:t)}return function(e,t){let n=[];for(let e=0;e<t.length;e++){let r=t[e];for(let t=r.childCount-1;t>=0;t--){let{rowspan:i,colspan:s}=r.child(t).attrs;for(let t=e;t<e+i;t++)n[t]=(n[t]||0)+s}}let r=0;for(let e=0;e<n.length;e++)r=Math.max(r,n[e]);for(let i=0;i<n.length;i++)if(i>=t.length&&t.push(ic.empty),n[i]<r){let s=lL(e).cell.createAndFill(),o=[];for(let e=n[i];e<r;e++)o.push(s);t[i]=t[i].append(ic.from(o))}return{height:t.length,width:r,rows:t}}(o,a)}(n),i=e.state.selection;if(i instanceof lq){r||(r={width:1,height:1,rows:[ic.from(ca(lL(e.state.schema).cell,n))]});let t=i.$anchorCell.node(-1),s=i.$anchorCell.start(-1),o=lI.get(t).rectBetween(i.$anchorCell.pos-s,i.$headCell.pos-s);return r=function({width:e,height:t,rows:n},r,i){if(e!=r){let t=[],i=[];for(let e=0;e<n.length;e++){let s=n[e],o=[];for(let n=t[e]||0,i=0;n<r;i++){let a=s.child(i%s.childCount);n+a.attrs.colspan>r&&(a=a.type.createChecked(lV(a.attrs,a.attrs.colspan,n+a.attrs.colspan-r),a.content)),o.push(a),n+=a.attrs.colspan;for(let n=1;n<a.attrs.rowspan;n++)t[e+n]=(t[e+n]||0)+a.attrs.colspan}i.push(ic.from(o))}n=i,e=r}if(t!=i){let e=[];for(let r=0,s=0;r<i;r++,s++){let o=[],a=n[s%t];for(let e=0;e<a.childCount;e++){let t=a.child(e);r+t.attrs.rowspan>i&&(t=t.type.create({...t.attrs,rowspan:Math.max(1,i-t.attrs.rowspan)},t.content)),o.push(t)}e.push(ic.from(o))}n=e,t=i}return{width:e,height:t,rows:n}}(r,o.right-o.left,o.bottom-o.top),cd(e.state,e.dispatch,s,o,r),!0}if(!r)return!1;{let t=lB(e.state),n=t.start(-1);return cd(e.state,e.dispatch,n,lI.get(t.node(-1)).findCell(t.pos-n),r),!0}}function cb(e,t){var n;let r;if(0!=t.button||t.ctrlKey||t.metaKey)return;let i=cy(e,t.target);if(t.shiftKey&&e.state.selection instanceof lq)s(e.state.selection.$anchorCell,t),t.preventDefault();else if(t.shiftKey&&i&&null!=(r=lz(e.state.selection.$anchor))&&(null==(n=cv(e,t))?void 0:n.pos)!=r.pos)s(r,t),t.preventDefault();else if(!i)return;function s(t,n){let r=cv(e,n),i=null==lP.getState(e.state);if(!r||!lH(t,r))if(!i)return;else r=t;let s=new lq(t,r);if(i||!e.state.selection.eq(s)){let n=e.state.tr.setSelection(s);i&&n.setMeta(lP,t.pos),e.dispatch(n)}}function o(){e.root.removeEventListener("mouseup",o),e.root.removeEventListener("dragstart",o),e.root.removeEventListener("mousemove",a),null!=lP.getState(e.state)&&e.dispatch(e.state.tr.setMeta(lP,-1))}function a(n){let r,a=lP.getState(e.state);if(null!=a)r=e.state.doc.resolve(a);else if(cy(e,n.target)!=i&&!(r=cv(e,t)))return o();r&&s(r,n)}e.root.addEventListener("mouseup",o),e.root.addEventListener("dragstart",o),e.root.addEventListener("mousemove",a)}function cx(e,t,n){if(!(e.state.selection instanceof sz))return null;let{$head:r}=e.state.selection;for(let i=r.depth-1;i>=0;i--){let s=r.node(i);if((n<0?r.index(i):r.indexAfter(i))!=(n<0?0:s.childCount))break;if("cell"==s.type.spec.tableRole||"header_cell"==s.type.spec.tableRole){let s=r.before(i),o="vert"==t?n>0?"down":"up":n>0?"right":"left";return e.endOfTextblock(o)?s:null}}return null}function cy(e,t){for(;t&&t!=e.dom;t=t.parentNode)if("TD"==t.nodeName||"TH"==t.nodeName)return t;return null}function cv(e,t){let n=e.posAtCoords({left:t.clientX,top:t.clientY});if(!n)return null;let{inside:r,pos:i}=n;return r>=0&&lz(e.state.doc.resolve(r))||lz(e.state.doc.resolve(i))}var cw=class{constructor(e,t){this.node=e,this.defaultCellMinWidth=t,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${t}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),ck(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type==this.node.type&&(this.node=e,ck(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return"attributes"==e.type&&(e.target==this.table||this.colgroup.contains(e.target))}};function ck(e,t,n,r,i,s){let o=0,a=!0,l=t.firstChild,c=e.firstChild;if(c){for(let e=0,n=0;e<c.childCount;e++){let{colspan:d,colwidth:u}=c.child(e).attrs;for(let e=0;e<d;e++,n++){let c=i==n?s:u&&u[e],d=c?c+"px":"";if(o+=c||r,c||(a=!1),l)l.style.width!=d&&(l.style.width=d),l=l.nextSibling;else{let e=document.createElement("col");e.style.width=d,t.appendChild(e)}}}for(;l;){var d;let e=l.nextSibling;null==(d=l.parentNode)||d.removeChild(l),l=e}a?(n.style.width=o+"px",n.style.minWidth=""):(n.style.width="",n.style.minWidth=o+"px")}}let cN=new s1("tableColumnResizing");var cS=class e{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(t){let n=t.getMeta(cN);if(n&&null!=n.setHandle)return new e(n.setHandle,!1);if(n&&void 0!==n.setDragging)return new e(this.activeHandle,n.setDragging);if(this.activeHandle>-1&&t.docChanged){let n=t.mapping.map(this.activeHandle,-1);return lF(t.doc.resolve(n))||(n=-1),new e(n,this.dragging)}return this}};function cC(e,t,n,r){let i=e.posAtCoords({left:t.clientX+("right"==n?-r:r),top:t.clientY});if(!i)return -1;let{pos:s}=i,o=lz(e.state.doc.resolve(s));if(!o)return -1;if("right"==n)return o.pos;let a=lI.get(o.node(-1)),l=o.start(-1),c=a.map.indexOf(o.pos-l);return c%a.width==0?-1:l+a.map[c-1]}function cj(e,t,n){let r=t.clientX-e.startX;return Math.max(n,e.startWidth+r)}function cE(e,t){e.dispatch(e.state.tr.setMeta(cN,{setHandle:t}))}function cM(e,t,n,r){let i=e.state.doc.resolve(t),s=i.node(-1),o=i.start(-1),a=lI.get(s).colCount(i.pos-o)+i.nodeAfter.attrs.colspan-1,l=e.domAtPos(i.start(-1)).node;for(;l&&"TABLE"!=l.nodeName;)l=l.parentNode;l&&ck(s,l.firstChild,l,r,a,n)}var cA=f,cT=e.i(3909);let cO=(e,t)=>!e.selection.empty&&(t&&t(e.tr.deleteSelection().scrollIntoView()),!0);function c_(e,t){let{$cursor:n}=e.selection;return n&&(t?t.endOfTextblock("backward",e):!(n.parentOffset>0))?n:null}let cD=(e,t,n)=>{let r=c_(e,n);if(!r)return!1;let i=cP(r);if(!i){let n=r.blockRange(),i=n&&su(n);return null!=i&&(t&&t(e.tr.lift(n,i).scrollIntoView()),!0)}let s=i.nodeBefore;if(cK(e,i,t,-1))return!0;if(0==r.parent.content.size&&(cI(s,"end")||sB.isSelectable(s)))for(let n=r.depth;;n--){let o=sw(e.doc,r.before(n),r.after(n),ig.empty);if(o&&o.slice.size<o.to-o.from){if(t){let n=e.tr.step(o);n.setSelection(cI(s,"end")?sR.findFrom(n.doc.resolve(n.mapping.map(i.pos,-1)),-1):sB.create(n.doc,i.pos-s.nodeSize)),t(n.scrollIntoView())}return!0}if(1==n||r.node(n-1).childCount>1)break}return!!s.isAtom&&i.depth==r.depth-1&&(t&&t(e.tr.delete(i.pos-s.nodeSize,i.pos).scrollIntoView()),!0)};function cR(e,t,n){let r=t.nodeBefore,i=t.pos-1;for(;!r.isTextblock;i--){if(r.type.spec.isolating)return!1;let e=r.lastChild;if(!e)return!1;r=e}let s=t.nodeAfter,o=t.pos+1;for(;!s.isTextblock;o++){if(s.type.spec.isolating)return!1;let e=s.firstChild;if(!e)return!1;s=e}let a=sw(e.doc,i,o,ig.empty);if(!a||a.from!=i||a instanceof sa&&a.slice.size>=o-i)return!1;if(n){let t=e.tr.step(a);t.setSelection(sz.create(t.doc,i)),n(t.scrollIntoView())}return!0}function cI(e,t,n=!1){for(let r=e;r;r="start"==t?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&1!=r.childCount)break}return!1}let cL=(e,t,n)=>{let{$head:r,empty:i}=e.selection,s=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",e):r.parentOffset>0)return!1;s=cP(r)}let o=s&&s.nodeBefore;return!!o&&!!sB.isSelectable(o)&&(t&&t(e.tr.setSelection(sB.create(e.doc,s.pos-o.nodeSize)).scrollIntoView()),!0)};function cP(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){if(e.index(t)>0)return e.doc.resolve(e.before(t+1));if(e.node(t).type.spec.isolating)break}return null}function cz(e,t){let{$cursor:n}=e.selection;return n&&(t?t.endOfTextblock("forward",e):!(n.parentOffset<n.parent.content.size))?n:null}let c$=(e,t,n)=>{let r=cz(e,n);if(!r)return!1;let i=cF(r);if(!i)return!1;let s=i.nodeAfter;if(cK(e,i,t,1))return!0;if(0==r.parent.content.size&&(cI(s,"start")||sB.isSelectable(s))){let n=sw(e.doc,r.before(),r.after(),ig.empty);if(n&&n.slice.size<n.to-n.from){if(t){let r=e.tr.step(n);r.setSelection(cI(s,"start")?sR.findFrom(r.doc.resolve(r.mapping.map(i.pos)),1):sB.create(r.doc,r.mapping.map(i.pos))),t(r.scrollIntoView())}return!0}}return!!s.isAtom&&i.depth==r.depth-1&&(t&&t(e.tr.delete(i.pos,i.pos+s.nodeSize).scrollIntoView()),!0)},cB=(e,t,n)=>{let{$head:r,empty:i}=e.selection,s=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",e):r.parentOffset<r.parent.content.size)return!1;s=cF(r)}let o=s&&s.nodeAfter;return!!o&&!!sB.isSelectable(o)&&(t&&t(e.tr.setSelection(sB.create(e.doc,s.pos)).scrollIntoView()),!0)};function cF(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){let n=e.node(t);if(e.index(t)+1<n.childCount)return e.doc.resolve(e.after(t+1));if(n.type.spec.isolating)break}return null}let cH=(e,t)=>{let{$head:n,$anchor:r}=e.selection;return!!n.parent.type.spec.code&&!!n.sameParent(r)&&(t&&t(e.tr.insertText("\n").scrollIntoView()),!0)};function cU(e){for(let t=0;t<e.edgeCount;t++){let{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}let cV=(e,t)=>{let{$head:n,$anchor:r}=e.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let i=n.node(-1),s=n.indexAfter(-1),o=cU(i.contentMatchAt(s));if(!o||!i.canReplaceWith(s,s,o))return!1;if(t){let r=n.after(),i=e.tr.replaceWith(r,r,o.createAndFill());i.setSelection(sR.near(i.doc.resolve(r),1)),t(i.scrollIntoView())}return!0},cW=(e,t)=>{let n=e.selection,{$from:r,$to:i}=n;if(n instanceof sH||r.parent.inlineContent||i.parent.inlineContent)return!1;let s=cU(i.parent.contentMatchAt(i.indexAfter()));if(!s||!s.isTextblock)return!1;if(t){let n=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,o=e.tr.insert(n,s.createAndFill());o.setSelection(sz.create(o.doc,n+1)),t(o.scrollIntoView())}return!0},cq=(e,t)=>{let{$cursor:n}=e.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let r=n.before();if(sg(e.doc,r))return t&&t(e.tr.split(r).scrollIntoView()),!0}let r=n.blockRange(),i=r&&su(r);return null!=i&&(t&&t(e.tr.lift(r,i).scrollIntoView()),!0)};function cK(e,t,n,r){let i,s,o,a=t.nodeBefore,l=t.nodeAfter,c,d,u=a.type.spec.isolating||l.type.spec.isolating;if(!u&&(i=t.nodeBefore,s=t.nodeAfter,o=t.index(),i&&s&&i.type.compatibleContent(s.type)&&(!i.content.size&&t.parent.canReplace(o-1,o)?(n&&n(e.tr.delete(t.pos-i.nodeSize,t.pos).scrollIntoView()),!0):!!t.parent.canReplace(o,o+1)&&!!(s.isTextblock||sb(e.doc,t.pos))&&(n&&n(e.tr.join(t.pos).scrollIntoView()),!0))))return!0;let p=!u&&t.parent.canReplace(t.index(),t.index()+1);if(p&&(c=(d=a.contentMatchAt(a.childCount)).findWrapping(l.type))&&d.matchType(c[0]||l.type).validEnd){if(n){let r=t.pos+l.nodeSize,i=ic.empty;for(let e=c.length-1;e>=0;e--)i=ic.from(c[e].create(null,i));i=ic.from(a.copy(i));let s=e.tr.step(new sl(t.pos-1,r,t.pos,r,new ig(i,1,0),c.length,!0)),o=s.doc.resolve(r+2*c.length);o.nodeAfter&&o.nodeAfter.type==a.type&&sb(s.doc,o.pos)&&s.join(o.pos),n(s.scrollIntoView())}return!0}let h=l.type.spec.isolating||r>0&&u?null:sR.findFrom(t,1),f=h&&h.$from.blockRange(h.$to),m=f&&su(f);if(null!=m&&m>=t.depth)return n&&n(e.tr.lift(f,m).scrollIntoView()),!0;if(p&&cI(l,"start",!0)&&cI(a,"end")){let r=a,i=[];for(;i.push(r),!r.isTextblock;)r=r.lastChild;let s=l,o=1;for(;!s.isTextblock;s=s.firstChild)o++;if(r.canReplace(r.childCount,r.childCount,s.content)){if(n){let r=ic.empty;for(let e=i.length-1;e>=0;e--)r=ic.from(i[e].copy(r));n(e.tr.step(new sl(t.pos-i.length,t.pos+l.nodeSize,t.pos+o,t.pos+l.nodeSize-o,new ig(r,i.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function cG(e){return function(t,n){let r=t.selection,i=e<0?r.$from:r.$to,s=i.depth;for(;i.node(s).isInline;){if(!s)return!1;s--}return!!i.node(s).isTextblock&&(n&&n(t.tr.setSelection(sz.create(t.doc,e<0?i.start(s):i.end(s)))),!0)}}let cJ=cG(-1),cZ=cG(1);function cX(e,t=null){return function(n,r){let i=!1;for(let r=0;r<n.selection.ranges.length&&!i;r++){let{$from:{pos:s},$to:{pos:o}}=n.selection.ranges[r];n.doc.nodesBetween(s,o,(r,s)=>{if(i)return!1;if(!(!r.isTextblock||r.hasMarkup(e,t)))if(r.type==e)i=!0;else{let t=n.doc.resolve(s),r=t.index();i=t.parent.canReplaceWith(r,r+1,e)}})}if(!i)return!1;if(r){let i=n.tr;for(let r=0;r<n.selection.ranges.length;r++){let{$from:{pos:s},$to:{pos:o}}=n.selection.ranges[r];i.setBlockType(s,o,e,t)}r(i.scrollIntoView())}return!0}}function cY(...e){return function(t,n,r){for(let i=0;i<e.length;i++)if(e[i](t,n,r))return!0;return!1}}let cQ=cY(cO,cD,cL),c0=cY(cO,c$,cB),c1={Enter:cY(cH,cW,cq,(e,t)=>{let{$from:n,$to:r}=e.selection;if(e.selection instanceof sB&&e.selection.node.isBlock)return!!n.parentOffset&&!!sg(e.doc,n.pos)&&(t&&t(e.tr.split(n.pos).scrollIntoView()),!0);if(!n.depth)return!1;let i=[],s,o,a=!1,l=!1;for(let e=n.depth;;e--){if(n.node(e).isBlock){let t;a=n.end(e)==n.pos+(n.depth-e),l=n.start(e)==n.pos-(n.depth-e),o=cU(n.node(e-1).contentMatchAt(n.indexAfter(e-1)));i.unshift(t||(a&&o?{type:o}:null)),s=e;break}if(1==e)return!1;i.unshift(null)}let c=e.tr;(e.selection instanceof sz||e.selection instanceof sH)&&c.deleteSelection();let d=c.mapping.map(n.pos),u=sg(c.doc,d,i.length,i);if(u||(i[0]=o?{type:o}:null,u=sg(c.doc,d,i.length,i)),!u)return!1;if(c.split(d,i.length,i),!a&&l&&n.node(s).type!=o){let e=c.mapping.map(n.before(s)),t=c.doc.resolve(e);o&&n.node(s-1).canReplaceWith(t.index(),t.index()+1,o)&&c.setNodeMarkup(c.mapping.map(n.before(s)),o)}return t&&t(c.scrollIntoView()),!0}),"Mod-Enter":cV,Backspace:cQ,"Mod-Backspace":cQ,"Shift-Backspace":cQ,Delete:c0,"Mod-Delete":c0,"Mod-a":(e,t)=>(t&&t(e.tr.setSelection(new sH(e.doc))),!0)},c2={"Ctrl-h":c1.Backspace,"Alt-Backspace":c1["Mod-Backspace"],"Ctrl-d":c1.Delete,"Ctrl-Alt-Backspace":c1["Mod-Delete"],"Alt-Delete":c1["Mod-Delete"],"Alt-d":c1["Mod-Delete"],"Ctrl-a":cJ,"Ctrl-e":cZ};for(let e in c1)c2[e]=c1[e];"u">typeof navigator?/Mac|iP(hone|[oa]d)/.test(navigator.platform):"u">typeof os&&os.platform&&os.platform();var c3=Object.defineProperty,c5=(e,t)=>{for(var n in t)c3(e,n,{get:t[n],enumerable:!0})};function c4(e){let{state:t,transaction:n}=e,{selection:r}=n,{doc:i}=n,{storedMarks:s}=n;return{...t,apply:t.apply.bind(t),applyTransaction:t.applyTransaction.bind(t),plugins:t.plugins,schema:t.schema,reconfigure:t.reconfigure.bind(t),toJSON:t.toJSON.bind(t),get storedMarks(){return s},get selection(){return r},get doc(){return i},get tr(){return r=n.selection,i=n.doc,s=n.storedMarks,n}}}var c6=class{constructor(e){this.editor=e.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=e.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){let{rawCommands:e,editor:t,state:n}=this,{view:r}=t,{tr:i}=n,s=this.buildProps(i);return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,(...e)=>{let n=t(...e)(s);return i.getMeta("preventDispatch")||this.hasCustomState||r.dispatch(i),n}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(e,t=!0){let{rawCommands:n,editor:r,state:i}=this,{view:s}=r,o=[],a=!!e,l=e||i.tr,c=()=>(a||!t||l.getMeta("preventDispatch")||this.hasCustomState||s.dispatch(l),o.every(e=>!0===e)),d={...Object.fromEntries(Object.entries(n).map(([e,n])=>[e,(...e)=>{let r=this.buildProps(l,t),i=n(...e)(r);return o.push(i),d}])),run:c};return d}createCan(e){let{rawCommands:t,state:n}=this,r=e||n.tr,i=this.buildProps(r,!1);return{...Object.fromEntries(Object.entries(t).map(([e,t])=>[e,(...e)=>t(...e)({...i,dispatch:void 0})])),chain:()=>this.createChain(r,!1)}}buildProps(e,t=!0){let{rawCommands:n,editor:r,state:i}=this,{view:s}=r,o={tr:e,editor:r,view:s,state:c4({state:i,transaction:e}),dispatch:t?()=>void 0:void 0,chain:()=>this.createChain(e,t),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(n).map(([e,t])=>[e,(...e)=>t(...e)(o)]))}};return o}},c9={};c5(c9,{blur:()=>c7,clearContent:()=>c8,clearNodes:()=>de,command:()=>dt,createParagraphNear:()=>dn,cut:()=>dr,deleteCurrentNode:()=>di,deleteNode:()=>da,deleteRange:()=>dl,deleteSelection:()=>dd,enter:()=>du,exitCode:()=>dp,extendMarkRange:()=>dy,first:()=>dv,focus:()=>dj,forEach:()=>dE,insertContent:()=>dM,insertContentAt:()=>d_,joinBackward:()=>dI,joinDown:()=>dR,joinForward:()=>dL,joinItemBackward:()=>dP,joinItemForward:()=>dz,joinTextblockBackward:()=>d$,joinTextblockForward:()=>dB,joinUp:()=>dD,keyboardShortcut:()=>dH,lift:()=>dV,liftEmptyBlock:()=>dW,liftListItem:()=>dq,newlineInCode:()=>dK,resetAttributes:()=>dZ,scrollIntoView:()=>dX,selectAll:()=>dY,selectNodeBackward:()=>dQ,selectNodeForward:()=>d0,selectParentNode:()=>d1,selectTextblockEnd:()=>d2,selectTextblockStart:()=>d3,setContent:()=>d4,setMark:()=>uD,setMeta:()=>uR,setNode:()=>uI,setNodeSelection:()=>uL,setTextDirection:()=>uP,setTextSelection:()=>uz,sinkListItem:()=>u$,splitBlock:()=>uF,splitListItem:()=>uH,toggleList:()=>uW,toggleMark:()=>uq,toggleNode:()=>uK,toggleWrap:()=>uG,undoInputRule:()=>uJ,unsetAllMarks:()=>uZ,unsetMark:()=>uX,unsetTextDirection:()=>uY,updateAttributes:()=>uQ,wrapIn:()=>u0,wrapInList:()=>u1});var c7=()=>({editor:e,view:t})=>(requestAnimationFrame(()=>{var n;e.isDestroyed||(t.dom.blur(),null==(n=null==window?void 0:window.getSelection())||n.removeAllRanges())}),!0),c8=(e=!0)=>({commands:t})=>t.setContent("",{emitUpdate:e}),de=()=>({state:e,tr:t,dispatch:n})=>{let{selection:r}=t,{ranges:i}=r;return!n||(i.forEach(({$from:n,$to:r})=>{e.doc.nodesBetween(n.pos,r.pos,(e,n)=>{if(e.type.isText)return;let{doc:r,mapping:i}=t,s=r.resolve(i.map(n)),o=r.resolve(i.map(n+e.nodeSize)),a=s.blockRange(o);if(!a)return;let l=su(a);if(e.type.isTextblock){let{defaultType:e}=s.parent.contentMatchAt(s.index());t.setNodeMarkup(a.start,e)}(l||0===l)&&t.lift(a,l)})}),!0)},dt=e=>t=>e(t),dn=()=>({state:e,dispatch:t})=>cW(e,t),dr=(e,t)=>({editor:n,tr:r})=>{let{state:i}=n,s=i.doc.slice(e.from,e.to);r.deleteRange(e.from,e.to);let o=r.mapping.map(t);return r.insert(o,s.content),r.setSelection(new sz(r.doc.resolve(Math.max(o-1,0)))),!0},di=()=>({tr:e,dispatch:t})=>{let{selection:n}=e,r=n.$anchor.node();if(r.content.size>0)return!1;let i=e.selection.$anchor;for(let n=i.depth;n>0;n-=1)if(i.node(n).type===r.type){if(t){let t=i.before(n),r=i.after(n);e.delete(t,r).scrollIntoView()}return!0}return!1};function ds(e,t){if("string"==typeof e){if(!t.nodes[e])throw Error(`There is no node type named '${e}'. Maybe you forgot to add the extension?`);return t.nodes[e]}return e}var da=e=>({tr:t,state:n,dispatch:r})=>{let i=ds(e,n.schema),s=t.selection.$anchor;for(let e=s.depth;e>0;e-=1)if(s.node(e).type===i){if(r){let n=s.before(e),r=s.after(e);t.delete(n,r).scrollIntoView()}return!0}return!1},dl=e=>({tr:t,dispatch:n})=>{let{from:r,to:i}=e;return n&&t.delete(r,i),!0},dc=(e,t,n)=>{var r;return!e.parent.isInline||"left"===n&&e.pos>e.start()||"right"===n&&e.pos<e.end()?e.pos:(r=t.nodes[e.parent.type.name].spec).content&&/^text(\*|\+)/.test(r.content)?"left"===n?e.start()-1:e.end()+1:e.pos},dd=()=>({state:e,dispatch:t})=>{var n;let{$from:r,$to:i}=e.selection;if(e.selection.empty)return!1;let{from:s,to:o}={from:dc(r,n=e.schema,"left"),to:dc(i,n,"right")};return t&&(e.tr.deleteRange(s,o).scrollIntoView(),t(e.tr)),!0},du=()=>({commands:e})=>e.keyboardShortcut("Enter"),dp=()=>({state:e,dispatch:t})=>cV(e,t);function dh(e){return"[object RegExp]"===Object.prototype.toString.call(e)}function df(e,t,n={strict:!0}){let r=Object.keys(t);return!r.length||r.every(r=>n.strict?t[r]===e[r]:dh(t[r])?t[r].test(e[r]):t[r]===e[r])}function dm(e,t,n={}){return e.find(e=>e.type===t&&df(Object.fromEntries(Object.keys(n).map(t=>[t,e.attrs[t]])),n))}function dg(e,t,n={}){return!!dm(e,t,n)}function db(e,t,n){if(!e||!t)return;let r=e.parent.childAfter(e.parentOffset);if(r.node&&r.node.marks.some(e=>e.type===t)||(r=e.parent.childBefore(e.parentOffset)),!r.node||!r.node.marks.some(e=>e.type===t))return;if(!n){let e=r.node.marks.find(e=>e.type===t);e&&(n=e.attrs)}if(!dm([...r.node.marks],t,n))return;let i=r.index,s=e.start()+r.offset,o=i+1,a=s+r.node.nodeSize;for(;i>0&&dg([...e.parent.child(i-1).marks],t,n);)i-=1,s-=e.parent.child(i).nodeSize;for(;o<e.parent.childCount&&dg([...e.parent.child(o).marks],t,n);)a+=e.parent.child(o).nodeSize,o+=1;return{from:s,to:a}}function dx(e,t){if("string"==typeof e){if(!t.marks[e])throw Error(`There is no mark type named '${e}'. Maybe you forgot to add the extension?`);return t.marks[e]}return e}var dy=(e,t)=>({tr:n,state:r,dispatch:i})=>{let s=dx(e,r.schema),{doc:o,selection:a}=n,{$from:l,from:c,to:d}=a;if(i){let e=db(l,s,t);if(e&&e.from<=c&&e.to>=d){let t=sz.create(o,e.from,e.to);n.setSelection(t)}}return!0},dv=e=>t=>{let n="function"==typeof e?e(t):e;for(let e=0;e<n.length;e+=1)if(n[e](t))return!0;return!1};function dw(e){return e instanceof sz}function dk(e=0,t=0,n=0){return Math.min(Math.max(e,t),n)}function dN(e,t=null){if(!t)return null;let n=sR.atStart(e),r=sR.atEnd(e);if("start"===t||!0===t)return n;if("end"===t)return r;let i=n.from,s=r.to;return"all"===t?sz.create(e,dk(0,i,s),dk(e.content.size,i,s)):sz.create(e,dk(t,i,s),dk(t,i,s))}function dS(){return"Android"===navigator.platform||/android/i.test(navigator.userAgent)}function dC(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}var dj=(e=null,t={})=>({editor:n,view:r,tr:i,dispatch:s})=>{t={scrollIntoView:!0,...t};let o=()=>{(dC()||dS())&&r.dom.focus(),"u">typeof navigator&&/^((?!chrome|android).)*safari/i.test(navigator.userAgent)&&!dC()&&!dS()&&r.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{!n.isDestroyed&&(r.focus(),(null==t?void 0:t.scrollIntoView)&&n.commands.scrollIntoView())})};try{if(r.hasFocus()&&null===e||!1===e)return!0}catch{return!1}if(s&&null===e&&!dw(n.state.selection))return o(),!0;let a=dN(i.doc,e)||n.state.selection,l=n.state.selection.eq(a);return s&&(l||i.setSelection(a),l&&i.storedMarks&&i.setStoredMarks(i.storedMarks),o()),!0},dE=(e,t)=>n=>e.every((e,r)=>t(e,{...n,index:r})),dM=(e,t)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},e,t),dA=e=>{let t=e.childNodes;for(let n=t.length-1;n>=0;n-=1){let r=t[n];3===r.nodeType&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?e.removeChild(r):1===r.nodeType&&dA(r)}return e};function dT(e){if("u"<typeof window)throw Error("[tiptap error]: there is no window object available, so this function cannot be used");let t=`<body>${e}</body>`;return dA(new window.DOMParser().parseFromString(t,"text/html").body)}function dO(e,t,n){if(e instanceof iA||e instanceof ic)return e;n={slice:!0,parseOptions:{},...n};let r="object"==typeof e&&null!==e,i="string"==typeof e;if(r)try{if(Array.isArray(e)&&e.length>0)return ic.fromArray(e.map(e=>t.nodeFromJSON(e)));let r=t.nodeFromJSON(e);return n.errorOnInvalidContent&&r.check(),r}catch(r){if(n.errorOnInvalidContent)throw Error("[tiptap error]: Invalid JSON content",{cause:r});return console.warn("[tiptap warn]: Invalid content.","Passed value:",e,"Error:",r),dO("",t,n)}if(i){if(n.errorOnInvalidContent){let r=!1,i="",s=new iV({topNode:t.spec.topNode,marks:t.spec.marks,nodes:t.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:e=>(r=!0,i="string"==typeof e?e:e.outerHTML,null)}]}})});if(n.slice?iq.fromSchema(s).parseSlice(dT(e),n.parseOptions):iq.fromSchema(s).parse(dT(e),n.parseOptions),n.errorOnInvalidContent&&r)throw Error("[tiptap error]: Invalid HTML content",{cause:Error(`Invalid element found: ${i}`)})}let r=iq.fromSchema(t);return n.slice?r.parseSlice(dT(e),n.parseOptions).content:r.parse(dT(e),n.parseOptions)}return dO("",t,n)}var d_=(e,t,n)=>({tr:r,dispatch:i,editor:s})=>{var o;if(i){let i,a;n={parseOptions:s.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let l=e=>{s.emit("contentError",{editor:s,error:e,disableCollaboration:()=>{"collaboration"in s.storage&&"object"==typeof s.storage.collaboration&&s.storage.collaboration&&(s.storage.collaboration.isDisabled=!0)}})},c={preserveWhitespace:"full",...n.parseOptions};if(!n.errorOnInvalidContent&&!s.options.enableContentCheck&&s.options.emitContentError)try{dO(t,s.schema,{parseOptions:c,errorOnInvalidContent:!0})}catch(e){l(e)}try{i=dO(t,s.schema,{parseOptions:c,errorOnInvalidContent:null!=(o=n.errorOnInvalidContent)?o:s.options.enableContentCheck})}catch(e){return l(e),!1}let{from:d,to:u}="number"==typeof e?{from:e,to:e}:{from:e.from,to:e.to},p=!0,h=!0;if((!("type"in i)?i:[i]).forEach(e=>{e.check(),p=!!p&&e.isText&&0===e.marks.length,h=!!h&&e.isBlock}),d===u&&h){let{parent:e}=r.doc.resolve(d);!e.isTextblock||e.type.spec.code||e.childCount||(d-=1,u+=1)}if(p){if(Array.isArray(t))a=t.map(e=>e.text||"").join("");else if(t instanceof ic){let e="";t.forEach(t=>{t.text&&(e+=t.text)}),a=e}else a="object"==typeof t&&t&&t.text?t.text:t;r.insertText(a,d,u)}else{a=i;let e=r.doc.resolve(d),t=e.node(),n=0===e.parentOffset,s=t.isText||t.isTextblock,o=t.content.size>0;n&&s&&o&&h&&(d=Math.max(0,d-1)),r.replaceWith(d,u,a)}n.updateSelection&&function(e,t){let n=e.steps.length-1;if(n<t)return;let r=e.steps[n];if(!(r instanceof sa||r instanceof sl))return;let i=e.mapping.maps[n],s=0;i.forEach((e,t,n,r)=>{0===s&&(s=r)}),e.setSelection(sR.near(e.doc.resolve(s),-1))}(r,r.steps.length-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:d,text:a}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:d,text:a})}return!0},dD=()=>({state:e,dispatch:t})=>((e,t)=>{let n=e.selection,r=n instanceof sB,i;if(r){if(n.node.isTextblock||!sb(e.doc,n.from))return!1;i=n.from}else if(null==(i=sy(e.doc,n.from,-1)))return!1;if(t){let n=e.tr.join(i);r&&n.setSelection(sB.create(n.doc,i-e.doc.resolve(i).nodeBefore.nodeSize)),t(n.scrollIntoView())}return!0})(e,t),dR=()=>({state:e,dispatch:t})=>((e,t)=>{let n=e.selection,r;if(n instanceof sB){if(n.node.isTextblock||!sb(e.doc,n.to))return!1;r=n.to}else if(null==(r=sy(e.doc,n.to,1)))return!1;return t&&t(e.tr.join(r).scrollIntoView()),!0})(e,t),dI=()=>({state:e,dispatch:t})=>cD(e,t),dL=()=>({state:e,dispatch:t})=>c$(e,t),dP=()=>({state:e,dispatch:t,tr:n})=>{try{let r=sy(e.doc,e.selection.$from.pos,-1);if(null==r)return!1;return n.join(r,2),t&&t(n),!0}catch{return!1}},dz=()=>({state:e,dispatch:t,tr:n})=>{try{let r=sy(e.doc,e.selection.$from.pos,1);if(null==r)return!1;return n.join(r,2),t&&t(n),!0}catch{return!1}},d$=()=>({state:e,dispatch:t})=>((e,t,n)=>{let r=c_(e,n);if(!r)return!1;let i=cP(r);return!!i&&cR(e,i,t)})(e,t),dB=()=>({state:e,dispatch:t})=>((e,t,n)=>{let r=cz(e,n);if(!r)return!1;let i=cF(r);return!!i&&cR(e,i,t)})(e,t);function dF(){return"u">typeof navigator&&/Mac/.test(navigator.platform)}var dH=e=>({editor:t,view:n,tr:r,dispatch:i})=>{let s=(function(e){let t,n,r,i,s=e.split(/-(?!$)/),o=s[s.length-1];"Space"===o&&(o=" ");for(let e=0;e<s.length-1;e+=1){let o=s[e];if(/^(cmd|meta|m)$/i.test(o))i=!0;else if(/^a(lt)?$/i.test(o))t=!0;else if(/^(c|ctrl|control)$/i.test(o))n=!0;else if(/^s(hift)?$/i.test(o))r=!0;else if(/^mod$/i.test(o))dC()||dF()?i=!0:n=!0;else throw Error(`Unrecognized modifier name: ${o}`)}return t&&(o=`Alt-${o}`),n&&(o=`Ctrl-${o}`),i&&(o=`Meta-${o}`),r&&(o=`Shift-${o}`),o})(e).split(/-(?!$)/),o=s.find(e=>!["Alt","Ctrl","Meta","Shift"].includes(e)),a=new KeyboardEvent("keydown",{key:"Space"===o?" ":o,altKey:s.includes("Alt"),ctrlKey:s.includes("Ctrl"),metaKey:s.includes("Meta"),shiftKey:s.includes("Shift"),bubbles:!0,cancelable:!0}),l=t.captureTransaction(()=>{n.someProp("handleKeyDown",e=>e(n,a))});return null==l||l.steps.forEach(e=>{let t=e.map(r.mapping);t&&i&&r.maybeStep(t)}),!0};function dU(e,t,n={}){let{from:r,to:i,empty:s}=e.selection,o=t?ds(t,e.schema):null,a=[];e.doc.nodesBetween(r,i,(e,t)=>{if(e.isText)return;let n=Math.max(r,t),s=Math.min(i,t+e.nodeSize);a.push({node:e,from:n,to:s})});let l=i-r,c=a.filter(e=>!o||o.name===e.node.type.name).filter(e=>df(e.node.attrs,n,{strict:!1}));return s?!!c.length:c.reduce((e,t)=>e+t.to-t.from,0)>=l}var dV=(e,t={})=>({state:n,dispatch:r})=>{let i=ds(e,n.schema);return!!dU(n,i,t)&&((e,t)=>{let{$from:n,$to:r}=e.selection,i=n.blockRange(r),s=i&&su(i);return null!=s&&(t&&t(e.tr.lift(i,s).scrollIntoView()),!0)})(n,r)},dW=()=>({state:e,dispatch:t})=>cq(e,t),dq=e=>({state:t,dispatch:n})=>{var r;return(r=ds(e,t.schema),function(e,t){let{$from:n,$to:i}=e.selection,s=n.blockRange(i,e=>e.childCount>0&&e.firstChild.type==r);return!!s&&(!t||(n.node(s.depth-1).type==r?function(e,t,n,r){let i=e.tr,s=r.end,o=r.$to.end(r.depth);s<o&&(i.step(new sl(s-1,o,s,o,new ig(ic.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new iE(i.doc.resolve(r.$from.pos),i.doc.resolve(o),r.depth));let a=su(r);if(null==a)return!1;i.lift(r,a);let l=i.doc.resolve(i.mapping.map(s,-1)-1);return sb(i.doc,l.pos)&&l.nodeBefore.type==l.nodeAfter.type&&i.join(l.pos),t(i.scrollIntoView()),!0}(e,t,r,s):function(e,t,n){let r=e.tr,i=n.parent;for(let e=n.end,t=n.endIndex-1,s=n.startIndex;t>s;t--)e-=i.child(t).nodeSize,r.delete(e-1,e+1);let s=r.doc.resolve(n.start),o=s.nodeAfter;if(r.mapping.map(n.end)!=n.start+s.nodeAfter.nodeSize)return!1;let a=0==n.startIndex,l=n.endIndex==i.childCount,c=s.node(-1),d=s.index(-1);if(!c.canReplace(d+ +!a,d+1,o.content.append(l?ic.empty:ic.from(i))))return!1;let u=s.pos,p=u+o.nodeSize;return r.step(new sl(u-!!a,p+ +!!l,u+1,p-1,new ig((a?ic.empty:ic.from(i.copy(ic.empty))).append(l?ic.empty:ic.from(i.copy(ic.empty))),+!a,+!l),+!a)),t(r.scrollIntoView()),!0}(e,t,s)))})(t,n)},dK=()=>({state:e,dispatch:t})=>cH(e,t);function dG(e,t){return t.nodes[e]?"node":t.marks[e]?"mark":null}function dJ(e,t){let n="string"==typeof t?[t]:t;return Object.keys(e).reduce((t,r)=>(n.includes(r)||(t[r]=e[r]),t),{})}var dZ=(e,t)=>({tr:n,state:r,dispatch:i})=>{let s=null,o=null,a=dG("string"==typeof e?e:e.name,r.schema);if(!a)return!1;"node"===a&&(s=ds(e,r.schema)),"mark"===a&&(o=dx(e,r.schema));let l=!1;return n.selection.ranges.forEach(e=>{r.doc.nodesBetween(e.$from.pos,e.$to.pos,(e,r)=>{s&&s===e.type&&(l=!0,i&&n.setNodeMarkup(r,void 0,dJ(e.attrs,t))),o&&e.marks.length&&e.marks.forEach(s=>{o===s.type&&(l=!0,i&&n.addMark(r,r+e.nodeSize,o.create(dJ(s.attrs,t))))})})}),l},dX=()=>({tr:e,dispatch:t})=>(t&&e.scrollIntoView(),!0),dY=()=>({tr:e,dispatch:t})=>{if(t){let t=new sH(e.doc);e.setSelection(t)}return!0},dQ=()=>({state:e,dispatch:t})=>cL(e,t),d0=()=>({state:e,dispatch:t})=>cB(e,t),d1=()=>({state:e,dispatch:t})=>((e,t)=>{let{$from:n,to:r}=e.selection,i,s=n.sharedDepth(r);return 0!=s&&(i=n.before(s),t&&t(e.tr.setSelection(sB.create(e.doc,i))),!0)})(e,t),d2=()=>({state:e,dispatch:t})=>cZ(e,t),d3=()=>({state:e,dispatch:t})=>cJ(e,t);function d5(e,t,n={},r={}){return dO(e,t,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var d4=(e,{errorOnInvalidContent:t,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:i,tr:s,dispatch:o,commands:a})=>{let{doc:l}=s;if("full"!==r.preserveWhitespace){let a=d5(e,i.schema,r,{errorOnInvalidContent:null!=t?t:i.options.enableContentCheck});return o&&s.replaceWith(0,l.content.size,a).setMeta("preventUpdate",!n),!0}return o&&s.setMeta("preventUpdate",!n),a.insertContentAt({from:0,to:l.content.size},e,{parseOptions:r,errorOnInvalidContent:null!=t?t:i.options.enableContentCheck})};function d6(e,t){let n=dx(t,e.schema),{from:r,to:i,empty:s}=e.selection,o=[];s?(e.storedMarks&&o.push(...e.storedMarks),o.push(...e.selection.$head.marks())):e.doc.nodesBetween(r,i,e=>{o.push(...e.marks)});let a=o.find(e=>e.type.name===n.name);return a?{...a.attrs}:{}}function d9(e,t){let n=new s_(e);return t.forEach(e=>{e.steps.forEach(e=>{n.step(e)})}),n}function d7(e,t){let n=[];return e.descendants((e,r)=>{t(e)&&n.push({node:e,pos:r})}),n}function d8(e,t){for(let n=e.depth;n>0;n-=1){let r=e.node(n);if(t(r))return{pos:n>0?e.before(n):0,start:e.start(n),depth:n,node:r}}}function ue(e){return t=>d8(t.$from,e)}function ut(e,t,n){return void 0===e.config[t]&&e.parent?ut(e.parent,t,n):"function"==typeof e.config[t]?e.config[t].bind({...n,parent:e.parent?ut(e.parent,t,n):null}):e.config[t]}function un(e){return e.map(e=>{let t={name:e.name,options:e.options,storage:e.storage},n=ut(e,"addExtensions",t);return n?[e,...un(n())]:e}).flat(10)}function ur(e,t){let n=i1.fromSchema(t).serializeFragment(e),r=document.implementation.createHTMLDocument().createElement("div");return r.appendChild(n),r.innerHTML}function ui(e){return"function"==typeof e}function us(e,t,...n){return ui(e)?t?e.bind(t)(...n):e(...n):e}function uo(e){let t=e.filter(e=>"extension"===e.type);return{baseExtensions:t,nodeExtensions:e.filter(e=>"node"===e.type),markExtensions:e.filter(e=>"mark"===e.type)}}function ua(e){let t=[],{nodeExtensions:n,markExtensions:r}=uo(e),i=[...n,...r],s={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1},o=n.filter(e=>"text"!==e.name).map(e=>e.name),a=r.map(e=>e.name),l=[...o,...a];return e.forEach(e=>{let n={name:e.name,options:e.options,storage:e.storage,extensions:i},r=ut(e,"addGlobalAttributes",n);r&&r().forEach(e=>{(Array.isArray(e.types)?e.types:"*"===e.types?l:"nodes"===e.types?o:"marks"===e.types?a:[]).forEach(n=>{Object.entries(e.attributes).forEach(([e,r])=>{t.push({type:n,name:e,attribute:{...s,...r}})})})})}),i.forEach(e=>{let n={name:e.name,options:e.options,storage:e.storage},r=ut(e,"addAttributes",n);r&&Object.entries(r()).forEach(([n,r])=>{let i={...s,...r};"function"==typeof(null==i?void 0:i.default)&&(i.default=i.default()),(null==i?void 0:i.isRequired)&&(null==i?void 0:i.default)===void 0&&delete i.default,t.push({type:e.name,name:n,attribute:i})})}),t}function ul(e){let t=[],n=function(e){let t=[],n="",r=!1,i=!1,s=0,o=e.length;for(let a=0;a<o;a+=1){let o=e[a];if("'"===o&&!i){r=!r,n+=o;continue}if('"'===o&&!r){i=!i,n+=o;continue}if(!r&&!i){if("("===o){s+=1,n+=o;continue}if(")"===o&&s>0){s-=1,n+=o;continue}if(";"===o&&0===s){t.push(n),n="";continue}}n+=o}return n&&t.push(n),t}(e||""),r=n.length;for(let e=0;e<r;e+=1){let r=n[e],i=r.indexOf(":");if(-1===i)continue;let s=r.slice(0,i).trim(),o=r.slice(i+1).trim();s&&o&&t.push([s,o])}return t}function uc(...e){return e.filter(e=>!!e).reduce((e,t)=>{let n={...e};return Object.entries(t).forEach(([e,t])=>{if(!n[e]){n[e]=t;return}if("class"===e){let r=t?String(t).split(" "):[],i=n[e]?n[e].split(" "):[],s=r.filter(e=>!i.includes(e));n[e]=[...i,...s].join(" ")}else if("style"===e){let r=new Map([...ul(n[e]),...ul(t)]);n[e]=Array.from(r.entries()).map(([e,t])=>`${e}: ${t}`).join("; ")}else n[e]=t}),n},{})}function ud(e,t){return t.filter(t=>t.type===e.type.name).filter(e=>e.attribute.rendered).map(t=>t.attribute.renderHTML?t.attribute.renderHTML(e.attrs)||{}:{[t.name]:e.attrs[t.name]}).reduce((e,t)=>uc(e,t),{})}function uu(e,t){return"style"in e?e:{...e,getAttrs:n=>{let r=e.getAttrs?e.getAttrs(n):e.attrs;if(!1===r)return!1;let i=t.reduce((e,t)=>{var r;let i=t.attribute.parseHTML?t.attribute.parseHTML(n):"string"!=typeof(r=n.getAttribute(t.name))?r:r.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(r):"true"===r||"false"!==r&&r;return null==i?e:{...e,[t.name]:i}},{});return{...r,...i}}}}function up(e){return Object.fromEntries(Object.entries(e).filter(([e,t])=>!("attrs"===e&&function(e={}){return 0===Object.keys(e).length&&e.constructor===Object}(t))&&null!=t))}function uh(e){var t,n;let r={};return!(null==(t=null==e?void 0:e.attribute)?void 0:t.isRequired)&&"default"in((null==e?void 0:e.attribute)||{})&&(r.default=e.attribute.default),(null==(n=null==e?void 0:e.attribute)?void 0:n.validate)!==void 0&&(r.validate=e.attribute.validate),[e.name,r]}function uf(e){return e.sort((e,t)=>{let n=ut(e,"priority")||100,r=ut(t,"priority")||100;return n>r?-1:+(n<r)})}function um(e){var t;let n=uf(un(e)),r=Array.from(new Set((t=n.map(e=>e.name)).filter((e,n)=>t.indexOf(e)!==n)));return r.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${r.map(e=>`'${e}'`).join(", ")}]. This can lead to issues.`),n}function ug(e,t,n){let{from:r,to:i}=t,{blockSeparator:s="\n\n",textSerializers:o={}}=n||{},a="";return e.nodesBetween(r,i,(e,n,l,c)=>{var d;e.isBlock&&n>r&&(a+=s);let u=null==o?void 0:o[e.type.name];if(u)return l&&(a+=u({node:e,pos:n,parent:l,index:c,range:t})),!1;e.isText&&(a+=null==(d=null==e?void 0:e.text)?void 0:d.slice(Math.max(r,n)-n,i-n))}),a}function ub(e,t){let n={from:0,to:e.content.size};return ug(e,n,t)}function ux(e){return Object.fromEntries(Object.entries(e.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}function uy(e,t){let n=dG("string"==typeof t?t:t.name,e.schema);return"node"===n?function(e,t){let n=ds(t,e.schema),{from:r,to:i}=e.selection,s=[];e.doc.nodesBetween(r,i,e=>{s.push(e)});let o=s.reverse().find(e=>e.type.name===n.name);return o?{...o.attrs}:{}}(e,t):"mark"===n?d6(e,t):{}}function uv(e){let t,{mapping:n,steps:r}=e,i=[];return n.maps.forEach((e,t)=>{let s=[];if(e.ranges.length)e.forEach((e,t)=>{s.push({from:e,to:t})});else{let{from:e,to:n}=r[t];if(void 0===e||void 0===n)return;s.push({from:e,to:n})}s.forEach(({from:e,to:r})=>{let s=n.slice(t).map(e,-1),o=n.slice(t).map(r),a=n.invert().map(s,-1),l=n.invert().map(o);i.push({oldRange:{from:a,to:l},newRange:{from:s,to:o}})})}),1===(t=function(e,t=JSON.stringify){let n={};return e.filter(e=>{let r=t(e);return!Object.prototype.hasOwnProperty.call(n,r)&&(n[r]=!0)})}(i)).length?t:t.filter((e,n)=>!t.filter((e,t)=>t!==n).some(t=>e.oldRange.from>=t.oldRange.from&&e.oldRange.to<=t.oldRange.to&&e.newRange.from>=t.newRange.from&&e.newRange.to<=t.newRange.to))}function uw(e,t,n){let r=[];return e===t?n.resolve(e).marks().forEach(t=>{let i=db(n.resolve(e),t.type);i&&r.push({mark:t,...i})}):n.nodesBetween(e,t,(e,t)=>{e&&(null==e?void 0:e.nodeSize)!==void 0&&r.push(...e.marks.map(n=>({from:t,to:t+e.nodeSize,mark:n})))}),r}function uk(e,t){return t.nodes[e]||t.marks[e]||null}function uN(e,t,n){return Object.fromEntries(Object.entries(n).filter(([n])=>{let r=e.find(e=>e.type===t&&e.name===n);return!!r&&r.attribute.keepOnSplit}))}function uS(e,t,n={}){let{empty:r,ranges:i}=e.selection,s=t?dx(t,e.schema):null;if(r)return!!(e.storedMarks||e.selection.$from.marks()).filter(e=>!s||s.name===e.type.name).find(e=>df(e.attrs,n,{strict:!1}));let o=0,a=[];if(i.forEach(({$from:t,$to:n})=>{let r=t.pos,i=n.pos;e.doc.nodesBetween(r,i,(e,t)=>{if(s&&e.inlineContent&&!e.type.allowsMarkType(s))return!1;if(!e.isText&&!e.marks.length)return;let n=Math.max(r,t),l=Math.min(i,t+e.nodeSize);o+=l-n,a.push(...e.marks.map(e=>({mark:e,from:n,to:l})))})}),0===o)return!1;let l=a.filter(e=>!s||s.name===e.mark.type.name).filter(e=>df(e.mark.attrs,n,{strict:!1})).reduce((e,t)=>e+t.to-t.from,0),c=a.filter(e=>!s||e.mark.type!==s&&e.mark.type.excludes(s)).reduce((e,t)=>e+t.to-t.from,0);return(l>0?l+c:l)>=o}function uC(e,t){return Array.isArray(t)?t.some(t=>("string"==typeof t?t:t.name)===e.name):t}function uj(e,t){let{nodeExtensions:n}=uo(t),r=n.find(t=>t.name===e);if(!r)return!1;let i={name:r.name,options:r.options,storage:r.storage},s=us(ut(r,"group",i));return"string"==typeof s&&s.split(" ").includes("list")}function uE(e,{checkChildren:t=!0,ignoreWhitespace:n=!1}={}){var r;if(n){if("hardBreak"===e.type.name)return!0;if(e.isText)return!/\S/.test(null!=(r=e.text)?r:"")}if(e.isText)return!e.text;if(e.isAtom||e.isLeaf)return!1;if(0===e.content.childCount)return!0;if(t){let r=!0;return e.content.forEach(e=>{!1!==r&&(uE(e,{ignoreWhitespace:n,checkChildren:t})||(r=!1))}),r}return!1}function uM(e){return e instanceof sB}var uA=class e{constructor(e){this.position=e}static fromJSON(t){return new e(t.position)}toJSON(){return{position:this.position}}};function uT(e,t){let n=t.mapping.mapResult(e.position);return{position:new uA(n.pos),mapResult:n}}function uO(e){return new uA(e)}function u_(e,t,n){let r=e.state.doc.content.size,i=dk(t,0,r),s=dk(n,0,r),o=e.coordsAtPos(i),a=e.coordsAtPos(s,-1),l=Math.min(o.top,a.top),c=Math.max(o.bottom,a.bottom),d=Math.min(o.left,a.left),u=Math.max(o.right,a.right),p={top:l,bottom:c,left:d,right:u,width:u-d,height:c-l,x:d,y:l};return{...p,toJSON:()=>p}}var uD=(e,t={})=>({tr:n,state:r,dispatch:i})=>{let{selection:s}=n,{empty:o,ranges:a}=s,l=dx(e,r.schema);if(i)if(o){let e=d6(r,l);n.addStoredMark(l.create({...e,...t}))}else a.forEach(e=>{let i=e.$from.pos,s=e.$to.pos;r.doc.nodesBetween(i,s,(e,r)=>{let o=Math.max(r,i),a=Math.min(r+e.nodeSize,s);e.marks.find(e=>e.type===l)?e.marks.forEach(e=>{l===e.type&&n.addMark(o,a,l.create({...e.attrs,...t}))}):n.addMark(o,a,l.create(t))})});return function(e,t,n){var r;let{selection:i}=t,s=null;if(dw(i)&&(s=i.$cursor),s){let t=null!=(r=e.storedMarks)?r:s.marks();return s.parent.type.allowsMarkType(n)&&(!!n.isInSet(t)||!t.some(e=>e.type.excludes(n)))}let{ranges:o}=i;return o.some(({$from:t,$to:r})=>{let i=0===t.depth&&e.doc.inlineContent&&e.doc.type.allowsMarkType(n);return e.doc.nodesBetween(t.pos,r.pos,(e,t,r)=>{if(i)return!1;if(e.isInline){let t=!r||r.type.allowsMarkType(n),s=!!n.isInSet(e.marks)||!e.marks.some(e=>e.type.excludes(n));i=t&&s}return!i}),i})}(r,n,l)},uR=(e,t)=>({tr:n})=>(n.setMeta(e,t),!0),uI=(e,t={})=>({state:n,dispatch:r,chain:i})=>{let s,o=ds(e,n.schema);return(n.selection.$anchor.sameParent(n.selection.$head)&&(s=n.selection.$anchor.parent.attrs),o.isTextblock)?i().command(({commands:e})=>!!cX(o,{...s,...t})(n)||e.clearNodes()).command(({state:e})=>cX(o,{...s,...t})(e,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},uL=e=>({tr:t,dispatch:n})=>{if(n){let{doc:n}=t,r=dk(e,0,n.content.size),i=sB.create(n,r);t.setSelection(i)}return!0},uP=(e,t)=>({tr:n,state:r,dispatch:i})=>{let s,o,{selection:a}=r;return"number"==typeof t?(s=t,o=t):t&&"from"in t&&"to"in t?(s=t.from,o=t.to):(s=a.from,o=a.to),i&&n.doc.nodesBetween(s,o,(t,r)=>{t.isText||n.setNodeMarkup(r,void 0,{...t.attrs,dir:e})}),!0},uz=e=>({tr:t,dispatch:n})=>{if(n){let{doc:n}=t,{from:r,to:i}="number"==typeof e?{from:e,to:e}:e,s=sz.atStart(n).from,o=sz.atEnd(n).to,a=dk(r,s,o),l=dk(i,s,o),c=sz.create(n,a,l);t.setSelection(c)}return!0},u$=e=>({state:t,dispatch:n})=>{var r;return(r=ds(e,t.schema),function(e,t){let{$from:n,$to:i}=e.selection,s=n.blockRange(i,e=>e.childCount>0&&e.firstChild.type==r);if(!s)return!1;let o=s.startIndex;if(0==o)return!1;let a=s.parent,l=a.child(o-1);if(l.type!=r)return!1;if(t){let n=l.lastChild&&l.lastChild.type==a.type,i=ic.from(n?r.create():null),o=new ig(ic.from(r.create(null,ic.from(a.type.create(null,i)))),n?3:1,0),c=s.start,d=s.end;t(e.tr.step(new sl(c-(n?3:1),d,c,d,o,1,!0)).scrollIntoView())}return!0})(t,n)};function uB(e,t){let n=e.storedMarks||e.selection.$to.parentOffset&&e.selection.$from.marks();if(n){let r=n.filter(e=>null==t?void 0:t.includes(e.type.name));e.tr.ensureMarks(r)}}var uF=({keepMarks:e=!0}={})=>({tr:t,state:n,dispatch:r,editor:i})=>{let{selection:s,doc:o}=t,{$from:a,$to:l}=s,c=uN(i.extensionManager.attributes,a.node().type.name,a.node().attrs);if(s instanceof sB&&s.node.isBlock)return!!a.parentOffset&&!!sg(o,a.pos)&&(r&&(e&&uB(n,i.extensionManager.splittableMarks),t.split(a.pos).scrollIntoView()),!0);if(!a.parent.isBlock)return!1;let d=l.parentOffset===l.parent.content.size,u=0===a.depth?void 0:function(e){for(let t=0;t<e.edgeCount;t+=1){let{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}(a.node(-1).contentMatchAt(a.indexAfter(-1))),p=d&&u?[{type:u,attrs:c}]:void 0,h=sg(t.doc,t.mapping.map(a.pos),1,p);if(!p&&!h&&sg(t.doc,t.mapping.map(a.pos),1,u?[{type:u}]:void 0)&&(h=!0,p=u?[{type:u,attrs:c}]:void 0),r){if(h&&(s instanceof sz&&t.deleteSelection(),t.split(t.mapping.map(a.pos),1,p),u&&!d&&!a.parentOffset&&a.parent.type!==u)){let e=t.mapping.map(a.before()),n=t.doc.resolve(e);a.node(-1).canReplaceWith(n.index(),n.index()+1,u)&&t.setNodeMarkup(t.mapping.map(a.before()),u)}e&&uB(n,i.extensionManager.splittableMarks),t.scrollIntoView()}return h},uH=(e,t={})=>({tr:n,state:r,dispatch:i,editor:s})=>{var o;let a=ds(e,r.schema),{$from:l,$to:c}=r.selection,d=r.selection.node;if(d&&d.isBlock||l.depth<2||!l.sameParent(c))return!1;let u=l.node(-1);if(u.type!==a)return!1;let p=s.extensionManager.attributes;if(0===l.parent.content.size&&l.node(-1).childCount===l.indexAfter(-1)){if(2===l.depth||l.node(-3).type!==a||l.index(-2)!==l.node(-2).childCount-1)return!1;if(i){let e=ic.empty,r=l.index(-1)?1:l.index(-2)?2:3;for(let t=l.depth-r;t>=l.depth-3;t-=1)e=ic.from(l.node(t).copy(e));let i=l.indexAfter(-1)<l.node(-2).childCount?1:l.indexAfter(-2)<l.node(-3).childCount?2:3,s={...uN(p,l.node().type.name,l.node().attrs),...t},c=(null==(o=a.contentMatch.defaultType)?void 0:o.createAndFill(s))||void 0;e=e.append(ic.from(a.createAndFill(null,c)||void 0));let d=l.before(l.depth-(r-1));n.replace(d,l.after(-i),new ig(e,4-r,0));let u=-1;n.doc.nodesBetween(d,n.doc.content.size,(e,t)=>{if(u>-1)return!1;e.isTextblock&&0===e.content.size&&(u=t+1)}),u>-1&&n.setSelection(sz.near(n.doc.resolve(u))),n.scrollIntoView()}return!0}let h=c.pos===l.end()?u.contentMatchAt(0).defaultType:null,f={...uN(p,u.type.name,u.attrs),...t},m={...uN(p,l.node().type.name,l.node().attrs),...t};n.delete(l.pos,c.pos);let g=h?[{type:a,attrs:f},{type:h,attrs:m}]:[{type:a,attrs:f}];if(!sg(n.doc,l.pos,2))return!1;if(i){let{selection:e,storedMarks:t}=r,{splittableMarks:o}=s.extensionManager,a=t||e.$to.parentOffset&&e.$from.marks();if(n.split(l.pos,2,g).scrollIntoView(),!a||!i)return!0;let c=a.filter(e=>o.includes(e.type.name));n.ensureMarks(c)}return!0},uU=(e,t)=>{let n=ue(e=>e.type===t)(e.selection);if(!n)return!0;let r=e.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(void 0===r)return!0;let i=e.doc.nodeAt(r);return!(n.node.type===(null==i?void 0:i.type)&&sb(e.doc,n.pos))||(e.join(n.pos),!0)},uV=(e,t)=>{let n=ue(e=>e.type===t)(e.selection);if(!n)return!0;let r=e.doc.resolve(n.start).after(n.depth);if(void 0===r)return!0;let i=e.doc.nodeAt(r);return!(n.node.type===(null==i?void 0:i.type)&&sb(e.doc,r))||(e.join(r),!0)},uW=(e,t,n,r={})=>({editor:i,tr:s,state:o,dispatch:a,chain:l,commands:c,can:d})=>{let{extensions:u,splittableMarks:p}=i.extensionManager,h=ds(e,o.schema),f=ds(t,o.schema),{selection:m,storedMarks:g}=o,{$from:b,$to:x}=m,y=b.blockRange(x),v=g||m.$to.parentOffset&&m.$from.marks();if(!y)return!1;let w=ue(e=>uj(e.type.name,u))(m),k=0===m.from&&m.to===o.doc.content.size,N=o.doc.content.content,S=1===N.length?N[0]:null,C=k&&S&&uj(S.type.name,u)?{node:S,pos:0,depth:0}:null,j=null!=w?w:C,E=!!w&&y.depth>=1&&y.depth-w.depth<=1,M=!!C;if((E||M)&&j){if(j.node.type===h)return k&&M?l().command(({tr:e,dispatch:t})=>{let n=function(e){let t=e.doc,n=t.firstChild;if(!n)return null;let r=t.resolve(1),i=t.resolve(n.nodeSize-1);return sz.between(r,i)}(e);return!!n&&(e.setSelection(n),t&&t(e),!0)}).liftListItem(f).run():c.liftListItem(f);if(uj(j.node.type.name,u)&&h.validContent(j.node.content))return l().command(()=>(s.setNodeMarkup(j.pos,h),!0)).command(()=>uU(s,h)).command(()=>uV(s,h)).run()}return n&&v&&a?l().command(()=>{let e=d().wrapInList(h,r),t=v.filter(e=>p.includes(e.type.name));return s.ensureMarks(t),!!e||c.clearNodes()}).wrapInList(h,r).command(()=>uU(s,h)).command(()=>uV(s,h)).run():l().command(()=>!!d().wrapInList(h,r)||c.clearNodes()).wrapInList(h,r).command(()=>uU(s,h)).command(()=>uV(s,h)).run()},uq=(e,t={},n={})=>({state:r,commands:i})=>{let{extendEmptyMarkRange:s=!1}=n,o=dx(e,r.schema);return uS(r,o,t)?i.unsetMark(o,{extendEmptyMarkRange:s}):i.setMark(o,t)},uK=(e,t,n={})=>({state:r,commands:i})=>{let s,o=ds(e,r.schema),a=ds(t,r.schema),l=dU(r,o,n);return(r.selection.$anchor.sameParent(r.selection.$head)&&(s=r.selection.$anchor.parent.attrs),l)?i.setNode(a,s):i.setNode(o,{...s,...n})},uG=(e,t={})=>({state:n,commands:r})=>{let i=ds(e,n.schema);return dU(n,i,t)?r.lift(i):r.wrapIn(i,t)},uJ=()=>({state:e,dispatch:t})=>{let n=e.plugins;for(let r=0;r<n.length;r+=1){let i,s=n[r];if(s.spec.isInputRules&&(i=s.getState(e))){if(t){let t=e.tr,n=i.transform;for(let e=n.steps.length-1;e>=0;e-=1)t.step(n.steps[e].invert(n.docs[e]));if(i.text){let n=t.doc.resolve(i.from).marks();t.replaceWith(i.from,i.to,e.schema.text(i.text,n))}else t.delete(i.from,i.to)}return!0}}return!1},uZ=()=>({tr:e,dispatch:t})=>{let{selection:n}=e,{empty:r,ranges:i}=n;return!!r||(t&&i.forEach(t=>{e.removeMark(t.$from.pos,t.$to.pos)}),!0)},uX=(e,t={})=>({tr:n,state:r,dispatch:i})=>{var s;let{extendEmptyMarkRange:o=!1}=t,{selection:a}=n,l=dx(e,r.schema),{$from:c,empty:d,ranges:u}=a;if(!i)return!0;if(d&&o){let{from:e,to:t}=a,r=null==(s=c.marks().find(e=>e.type===l))?void 0:s.attrs,i=db(c,l,r);i&&(e=i.from,t=i.to),n.removeMark(e,t,l)}else u.forEach(e=>{n.removeMark(e.$from.pos,e.$to.pos,l)});return n.removeStoredMark(l),!0},uY=e=>({tr:t,state:n,dispatch:r})=>{let i,s,{selection:o}=n;return"number"==typeof e?(i=e,s=e):e&&"from"in e&&"to"in e?(i=e.from,s=e.to):(i=o.from,s=o.to),r&&t.doc.nodesBetween(i,s,(e,n)=>{if(e.isText)return;let r={...e.attrs};delete r.dir,t.setNodeMarkup(n,void 0,r)}),!0},uQ=(e,t={})=>({tr:n,state:r,dispatch:i})=>{let s=null,o=null,a=dG("string"==typeof e?e:e.name,r.schema);if(!a)return!1;"node"===a&&(s=ds(e,r.schema)),"mark"===a&&(o=dx(e,r.schema));let l=!1;return n.selection.ranges.forEach(e=>{let a,c,d,u,p=e.$from.pos,h=e.$to.pos;n.selection.empty?r.doc.nodesBetween(p,h,(e,t)=>{s&&s===e.type&&(l=!0,d=Math.max(t,p),u=Math.min(t+e.nodeSize,h),a=t,c=e)}):r.doc.nodesBetween(p,h,(e,r)=>{r<p&&s&&s===e.type&&(l=!0,d=Math.max(r,p),u=Math.min(r+e.nodeSize,h),a=r,c=e),r>=p&&r<=h&&(s&&s===e.type&&(l=!0,i&&n.setNodeMarkup(r,void 0,{...e.attrs,...t})),o&&e.marks.length&&e.marks.forEach(s=>{if(o===s.type&&(l=!0,i)){let i=Math.max(r,p),a=Math.min(r+e.nodeSize,h);n.addMark(i,a,o.create({...s.attrs,...t}))}}))}),c&&(void 0!==a&&i&&n.setNodeMarkup(a,void 0,{...c.attrs,...t}),o&&c.marks.length&&c.marks.forEach(e=>{o===e.type&&i&&n.addMark(d,u,o.create({...e.attrs,...t}))}))}),l},u0=(e,t={})=>({state:n,dispatch:r})=>(function(e,t=null){return function(n,r){let{$from:i,$to:s}=n.selection,o=i.blockRange(s),a=o&&sp(o,e,t);return!!a&&(r&&r(n.tr.wrap(o,a).scrollIntoView()),!0)}})(ds(e,n.schema),t)(n,r),u1=(e,t={})=>({state:n,dispatch:r})=>(function(e,t=null){return function(n,r){let{$from:i,$to:s}=n.selection,o=i.blockRange(s);if(!o)return!1;let a=r?n.tr:null;return!!function(e,t,n,r=null){let i=!1,s=t,o=t.$from.doc;if(t.depth>=2&&t.$from.node(t.depth-1).type.compatibleContent(n)&&0==t.startIndex){if(0==t.$from.index(t.depth-1))return!1;let e=o.resolve(t.start-2);s=new iE(e,e,t.depth),t.endIndex<t.parent.childCount&&(t=new iE(t.$from,o.resolve(t.$to.end(t.depth)),t.depth)),i=!0}let a=sp(s,n,r,t);return!!a&&(e&&function(e,t,n,r,i){let s=ic.empty;for(let e=n.length-1;e>=0;e--)s=ic.from(n[e].type.create(n[e].attrs,s));e.step(new sl(t.start-2*!!r,t.end,t.start,t.end,new ig(s,0,0),n.length,!0));let o=0;for(let e=0;e<n.length;e++)n[e].type==i&&(o=e+1);let a=n.length-o,l=t.start+n.length-2*!!r,c=t.parent;for(let n=t.startIndex,r=t.endIndex,i=!0;n<r;n++,i=!1)!i&&sg(e.doc,l,a)&&(e.split(l,a),l+=2*a),l+=c.child(n).nodeSize}(e,t,a,i,n),!0)}(a,o,e,t)&&(r&&r(a.scrollIntoView()),!0)}})(ds(e,n.schema),t)(n,r),u2=class{constructor(){this.callbacks={}}on(e,t){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),this}emit(e,...t){let n=this.callbacks[e];return n&&n.forEach(e=>e.apply(this,t)),this}off(e,t){let n=this.callbacks[e];return n&&(t?this.callbacks[e]=n.filter(e=>e!==t):delete this.callbacks[e]),this}once(e,t){let n=(...r)=>{this.off(e,n),t.apply(this,r)};return this.on(e,n)}removeAllListeners(){this.callbacks={}}},u3=class{constructor(e){var t;this.find=e.find,this.handler=e.handler,this.undoable=null==(t=e.undoable)||t}};function u5(e){var t;let{editor:n,from:r,to:i,text:s,rules:o,plugin:a}=e,{view:l}=n;if(l.composing)return!1;let c=l.state.doc.resolve(r);if(c.parent.type.spec.code||(null==(t=c.nodeBefore||c.nodeAfter)?void 0:t.marks.find(e=>e.type.spec.code)))return!1;let d=!1,u=((e,t=500)=>{let n="",r=e.parentOffset;return e.parent.nodesBetween(Math.max(0,r-t),r,(e,t,i,s)=>{var o,a;let l=(null==(a=(o=e.type.spec).toText)?void 0:a.call(o,{node:e,pos:t,parent:i,index:s}))||e.textContent||"%leaf%";n+=e.isAtom&&!e.isText?l:l.slice(0,Math.max(0,r-t))}),n})(c)+s;return o.forEach(e=>{if(d)return;let t=((e,t)=>{if(dh(t))return t.exec(e);let n=t(e);if(!n)return null;let r=[n.text];return r.index=n.index,r.input=e,r.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(n.replaceWith)),r})(u,e.find);if(!t)return;let o=l.state.tr,c=c4({state:l.state,transaction:o}),p={from:r-(t[0].length-s.length),to:i},{commands:h,chain:f,can:m}=new c6({editor:n,state:c});null!==e.handler({state:c,range:p,match:t,commands:h,chain:f,can:m})&&o.steps.length&&(e.undoable&&o.setMeta(a,{transform:o,from:r,to:i,text:s}),l.dispatch(o),d=!0)}),d}function u4(e){return"Object"===Object.prototype.toString.call(e).slice(8,-1)&&e.constructor===Object&&Object.getPrototypeOf(e)===Object.prototype}var u6=class{constructor(e={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...e},this.name=this.config.name}get options(){return{...us(ut(this,"addOptions",{name:this.name}))}}get storage(){return{...us(ut(this,"addStorage",{name:this.name,options:this.options}))}}configure(e={}){let t=this.extend({...this.config,addOptions:()=>(function e(t,n){let r={...t};return u4(t)&&u4(n)&&Object.keys(n).forEach(i=>{u4(n[i])&&u4(t[i])?r[i]=e(t[i],n[i]):r[i]=n[i]}),r})(this.options,e)});return t.name=this.name,t.parent=this.parent,this.child=null,t}extend(e={}){let t=new this.constructor({...this.config,...e});return t.parent=this,this.child=t,t.name="name"in e?e.name:t.parent.name,t}},u9=class e extends u6{constructor(){super(...arguments),this.type="mark"}static create(t={}){return new e("function"==typeof t?t():t)}static handleExit({editor:e,mark:t}){let{tr:n}=e.state,r=e.state.selection.$from;if(r.pos===r.end()){let i=r.marks();if(!i.find(e=>(null==e?void 0:e.type.name)===t.name))return!1;let s=i.find(e=>(null==e?void 0:e.type.name)===t.name);return s&&n.removeStoredMark(s),n.insertText(" ",r.pos),e.view.dispatch(n),!0}return!1}configure(e){return super.configure(e)}extend(e){let t="function"==typeof e?e():e;return super.extend(t)}},u7=class{constructor(e){this.find=e.find,this.handler=e.handler}},u8=null,pe=class{constructor(e,t){this.splittableMarks=[],this.editor=t,this.baseExtensions=e,this.extensions=um(e),this.schema=function(e,t){var n;let r=ua(e),{nodeExtensions:i,markExtensions:s}=uo(e),o=null==(n=i.find(e=>ut(e,"topNode")))?void 0:n.name;return new iV({topNode:o,nodes:Object.fromEntries(i.map(n=>{let i=r.filter(e=>e.type===n.name),s={name:n.name,options:n.options,storage:n.storage,editor:t},o=up({...e.reduce((e,t)=>{let r=ut(t,"extendNodeSchema",s);return{...e,...r?r(n):{}}},{}),content:us(ut(n,"content",s)),marks:us(ut(n,"marks",s)),group:us(ut(n,"group",s)),inline:us(ut(n,"inline",s)),atom:us(ut(n,"atom",s)),selectable:us(ut(n,"selectable",s)),draggable:us(ut(n,"draggable",s)),code:us(ut(n,"code",s)),whitespace:us(ut(n,"whitespace",s)),linebreakReplacement:us(ut(n,"linebreakReplacement",s)),defining:us(ut(n,"defining",s)),isolating:us(ut(n,"isolating",s)),attrs:Object.fromEntries(i.map(uh))}),a=us(ut(n,"parseHTML",s));a&&(o.parseDOM=a.map(e=>uu(e,i)));let l=ut(n,"renderHTML",s);l&&(o.toDOM=e=>l({node:e,HTMLAttributes:ud(e,i)}));let c=ut(n,"renderText",s);return c&&(o.toText=c),[n.name,o]})),marks:Object.fromEntries(s.map(n=>{let i=r.filter(e=>e.type===n.name),s={name:n.name,options:n.options,storage:n.storage,editor:t},o=up({...e.reduce((e,t)=>{let r=ut(t,"extendMarkSchema",s);return{...e,...r?r(n):{}}},{}),inclusive:us(ut(n,"inclusive",s)),excludes:us(ut(n,"excludes",s)),group:us(ut(n,"group",s)),spanning:us(ut(n,"spanning",s)),code:us(ut(n,"code",s)),attrs:Object.fromEntries(i.map(uh))}),a=us(ut(n,"parseHTML",s));a&&(o.parseDOM=a.map(e=>uu(e,i)));let l=ut(n,"renderHTML",s);return l&&(o.toDOM=e=>l({mark:e,HTMLAttributes:ud(e,i)})),[n.name,o]}))})}(this.extensions,t),this.setupExtensions()}get commands(){return this.extensions.reduce((e,t)=>{let n={name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:this.editor,type:uk(t.name,this.schema)},r=ut(t,"addCommands",n);return r?{...e,...r()}:e},{})}get plugins(){let{editor:e}=this;return uf([...this.extensions].reverse()).flatMap(t=>{let n={name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:e,type:uk(t.name,this.schema)},r=[],i=ut(t,"addKeyboardShortcuts",n),s={};if("mark"===t.type&&ut(t,"exitable",n)&&(s.ArrowRight=()=>u9.handleExit({editor:e,mark:t})),i){let t=Object.fromEntries(Object.entries(i()).map(([t,n])=>[t,()=>n({editor:e})]));s={...s,...t}}let o=new sY({props:{handleKeyDown:lR(s)}});r.push(o);let a=ut(t,"addInputRules",n);if(uC(t,e.options.enableInputRules)&&a){let t=a();if(t&&t.length){let n=function(e){let{editor:t,rules:n}=e,r=new sY({state:{init:()=>null,apply(e,i,s){let o=e.getMeta(r);if(o)return o;let a=e.getMeta("applyInputRules");return a&&setTimeout(()=>{let{text:e}=a;"string"==typeof e||(e=ur(ic.from(e),s.schema));let{from:i}=a,o=i+e.length;u5({editor:t,from:i,to:o,text:e,rules:n,plugin:r})}),e.selectionSet||e.docChanged?null:i}},props:{handleTextInput:(e,i,s,o)=>u5({editor:t,from:i,to:s,text:o,rules:n,plugin:r}),handleDOMEvents:{compositionend:e=>(setTimeout(()=>{let{$cursor:i}=e.state.selection;i&&u5({editor:t,from:i.pos,to:i.pos,text:"",rules:n,plugin:r})}),!1)},handleKeyDown(e,i){if("Enter"!==i.key)return!1;let{$cursor:s}=e.state.selection;return!!s&&u5({editor:t,from:s.pos,to:s.pos,text:"\n",rules:n,plugin:r})}},isInputRules:!0});return r}({editor:e,rules:t}),i=Array.isArray(n)?n:[n];r.push(...i)}}let l=ut(t,"addPasteRules",n);if(uC(t,e.options.enablePasteRules)&&l){let t=l();if(t&&t.length){let n=function(e){let t,{editor:n,rules:r}=e,i=null,s=!1,o=!1,a="u">typeof ClipboardEvent?new ClipboardEvent("paste"):null;try{t="u">typeof DragEvent?new DragEvent("drop"):null}catch{t=null}let l=({state:e,from:r,to:i,rule:s,pasteEvt:o})=>{let l=e.tr;if(function(e){let{editor:t,state:n,from:r,to:i,rule:s,pasteEvent:o,dropEvent:a}=e,{commands:l,chain:c,can:d}=new c6({editor:t,state:n}),u=[];return n.doc.nodesBetween(r,i,(e,t)=>{var p,h,f,m,g;if((null==(h=null==(p=e.type)?void 0:p.spec)?void 0:h.code)||!(e.isText||e.isTextblock||e.isInline))return;let b=null!=(g=null!=(m=null==(f=e.content)?void 0:f.size)?m:e.nodeSize)?g:0,x=Math.max(r,t),y=Math.min(i,t+b);x>=y||((e,t,n)=>{if(dh(t))return[...e.matchAll(t)];let r=t(e,n);return r?r.map(t=>{let n=[t.text];return n.index=t.index,n.input=e,n.data=t.data,t.replaceWith&&(t.text.includes(t.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),n.push(t.replaceWith)),n}):[]})(e.isText?e.text||"":e.textBetween(x-t,y-t,void 0,""),s.find,o).forEach(e=>{if(void 0===e.index)return;let t=x+e.index+1,r=t+e[0].length,i={from:n.tr.mapping.map(t),to:n.tr.mapping.map(r)},p=s.handler({state:n,range:i,match:e,commands:l,chain:c,can:d,pasteEvent:o,dropEvent:a});u.push(p)})}),u.every(e=>null!==e)}({editor:n,state:c4({state:e,transaction:l}),from:Math.max(r-1,0),to:i.b-1,rule:s,pasteEvent:o,dropEvent:t})&&l.steps.length){try{t="u">typeof DragEvent?new DragEvent("drop"):null}catch{t=null}return a="u">typeof ClipboardEvent?new ClipboardEvent("paste"):null,l}};return r.map(e=>new sY({view(e){let t=t=>{var r;(i=(null==(r=e.dom.parentElement)?void 0:r.contains(t.target))?e.dom.parentElement:null)&&(u8=n)},r=()=>{u8&&(u8=null)};return window.addEventListener("dragstart",t),window.addEventListener("dragend",r),{destroy(){window.removeEventListener("dragstart",t),window.removeEventListener("dragend",r)}}},props:{handleDOMEvents:{drop:(e,n)=>{if(o=i===e.dom.parentElement,t=n,!o){let e=u8;(null==e?void 0:e.isEditable)&&setTimeout(()=>{let t=e.state.selection;t&&e.commands.deleteRange({from:t.from,to:t.to})},10)}return!1},paste:(e,t)=>{var n;let r=null==(n=t.clipboardData)?void 0:n.getData("text/html");return a=t,s=!!(null==r?void 0:r.includes("data-pm-slice")),!1}}},appendTransaction:(t,n,r)=>{let i=t[0],c="paste"===i.getMeta("uiEvent")&&!s,d="drop"===i.getMeta("uiEvent")&&!o,u=i.getMeta("applyPasteRules"),p=!!u;if(!c&&!d&&!p)return;if(p){var h,f;let t,{text:n}=u;"string"==typeof n||(n=ur(ic.from(n),r.schema));let{from:i}=u,s=i+n.length;return l({rule:e,state:r,from:i,to:{b:s},pasteEvt:(h=n,null==(f=(t=new ClipboardEvent("paste",{clipboardData:new DataTransfer})).clipboardData)||f.setData("text/html",h),t)})}let m=n.doc.content.findDiffStart(r.doc.content),g=n.doc.content.findDiffEnd(r.doc.content);if("number"==typeof m&&g&&m!==g.b)return l({rule:e,state:r,from:m,to:g,pasteEvt:a})}}))}({editor:e,rules:t});r.push(...n)}}let c=ut(t,"addProseMirrorPlugins",n);if(c){let e=c();r.push(...e)}return r})}get attributes(){return ua(this.extensions)}get nodeViews(){let{editor:e}=this,{nodeExtensions:t}=uo(this.extensions);return Object.fromEntries(t.filter(e=>!!ut(e,"addNodeView")).map(t=>{let n=this.attributes.filter(e=>e.type===t.name),r={name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:e,type:ds(t.name,this.schema)},i=ut(t,"addNodeView",r);if(!i)return[];let s=i();return s?[t.name,(r,i,o,a,l)=>{let c=ud(r,n);return s({node:r,view:i,getPos:o,decorations:a,innerDecorations:l,editor:e,extension:t,HTMLAttributes:c})}]:[]}))}dispatchTransaction(e){let{editor:t}=this;return uf([...this.extensions].reverse()).reduceRight((e,n)=>{let r={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:uk(n.name,this.schema)},i=ut(n,"dispatchTransaction",r);return i?t=>{i.call(r,{transaction:t,next:e})}:e},e)}transformPastedHTML(e){let{editor:t}=this;return uf([...this.extensions]).reduce((e,n)=>{let r={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:uk(n.name,this.schema)},i=ut(n,"transformPastedHTML",r);return i?(t,n)=>{let s=e(t,n);return i.call(r,s)}:e},e||(e=>e))}get markViews(){let{editor:e}=this,{markExtensions:t}=uo(this.extensions);return Object.fromEntries(t.filter(e=>!!ut(e,"addMarkView")).map(t=>{let n=this.attributes.filter(e=>e.type===t.name),r={name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:e,type:dx(t.name,this.schema)},i=ut(t,"addMarkView",r);return i?[t.name,(r,s,o)=>{let a=ud(r,n);return i()({mark:r,view:s,inline:o,editor:e,extension:t,HTMLAttributes:a,updateAttributes:t=>{!function(e,t,n={}){let{state:r}=t,{doc:i,tr:s}=r;i.descendants((t,r)=>{let i=s.mapping.map(r),o=s.mapping.map(r)+t.nodeSize,a=null;if(t.marks.forEach(t=>{if(t!==e)return!1;a=t}),!a)return;let l=!1;if(Object.keys(n).forEach(e=>{n[e]!==a.attrs[e]&&(l=!0)}),l){let t=e.type.create({...e.attrs,...n});s.removeMark(i,o,e.type),s.addMark(i,o,t)}}),s.docChanged&&t.view.dispatch(s)}(r,e,t)}})}]:[]}))}destroy(){this.extensions.forEach(e=>{let t=e;for(;t.parent;){let e=t.parent;e.child===t&&(e.child=null),t=e}}),this.extensions=[],this.baseExtensions=[],this.schema=null,this.editor=null}setupExtensions(){let e=this.extensions;this.editor.extensionStorage=Object.fromEntries(e.map(e=>[e.name,e.storage])),e.forEach(e=>{var t;let n={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:uk(e.name,this.schema)};"mark"===e.type&&(null==(t=us(ut(e,"keepOnSplit",n)))||t)&&this.splittableMarks.push(e.name);let r=ut(e,"onBeforeCreate",n),i=ut(e,"onCreate",n),s=ut(e,"onUpdate",n),o=ut(e,"onSelectionUpdate",n),a=ut(e,"onTransaction",n),l=ut(e,"onFocus",n),c=ut(e,"onBlur",n),d=ut(e,"onDestroy",n);r&&this.editor.on("beforeCreate",r),i&&this.editor.on("create",i),s&&this.editor.on("update",s),o&&this.editor.on("selectionUpdate",o),a&&this.editor.on("transaction",a),l&&this.editor.on("focus",l),c&&this.editor.on("blur",c),d&&this.editor.on("destroy",d)})}};pe.resolve=um,pe.sort=uf,pe.flatten=un,c5({},{ClipboardTextSerializer:()=>pn,Commands:()=>pr,Delete:()=>pi,Drop:()=>ps,Editable:()=>po,FocusEvents:()=>pl,Keymap:()=>pc,Paste:()=>pd,Tabindex:()=>pu,TextDirection:()=>pp,focusEventsPluginKey:()=>pa});var pt=class e extends u6{constructor(){super(...arguments),this.type="extension"}static create(t={}){return new e("function"==typeof t?t():t)}configure(e){return super.configure(e)}extend(e){let t="function"==typeof e?e():e;return super.extend(t)}},pn=pt.create({name:"clipboardTextSerializer",addOptions:()=>({blockSeparator:void 0}),addProseMirrorPlugins(){return[new sY({key:new s1("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{let{editor:e}=this,{state:t,schema:n}=e,{doc:r,selection:i}=t,{ranges:s}=i,o=Math.min(...s.map(e=>e.$from.pos)),a=Math.max(...s.map(e=>e.$to.pos)),l=ux(n);return ug(r,{from:o,to:a},{...void 0!==this.options.blockSeparator?{blockSeparator:this.options.blockSeparator}:{},textSerializers:l})}}})]}}),pr=pt.create({name:"commands",addCommands:()=>({...c9})}),pi=pt.create({name:"delete",onUpdate({transaction:e,appendedTransactions:t}){var n,r,i;let s=()=>{var n,r,i,s;if(null!=(s=null==(i=null==(r=null==(n=this.editor.options.coreExtensionOptions)?void 0:n.delete)?void 0:r.filterTransaction)?void 0:i.call(r,e))?s:e.getMeta("y-sync$"))return;let o=d9(e.before,[e,...t]);uv(o).forEach(t=>{o.mapping.mapResult(t.oldRange.from).deletedAfter&&o.mapping.mapResult(t.oldRange.to).deletedBefore&&o.before.nodesBetween(t.oldRange.from,t.oldRange.to,(n,r)=>{let i=r+n.nodeSize-2,s=t.oldRange.from<=r&&i<=t.oldRange.to;this.editor.emit("delete",{type:"node",node:n,from:r,to:i,newFrom:o.mapping.map(r),newTo:o.mapping.map(i),deletedRange:t.oldRange,newRange:t.newRange,partial:!s,editor:this.editor,transaction:e,combinedTransform:o})})});let a=o.mapping;o.steps.forEach((t,n)=>{var r,i;if(t instanceof si){let s=a.slice(n).map(t.from,-1),l=a.slice(n).map(t.to),c=a.invert().map(s,-1),d=a.invert().map(l),u=s>0&&(null==(r=o.doc.nodeAt(s-1))?void 0:r.marks.some(e=>e.eq(t.mark))),p=null==(i=o.doc.nodeAt(l))?void 0:i.marks.some(e=>e.eq(t.mark));this.editor.emit("delete",{type:"mark",mark:t.mark,from:t.from,to:t.to,deletedRange:{from:c,to:d},newRange:{from:s,to:l},partial:!!(p||u),editor:this.editor,transaction:e,combinedTransform:o})}})};null==(i=null==(r=null==(n=this.editor.options.coreExtensionOptions)?void 0:n.delete)?void 0:r.async)||i?setTimeout(s,0):s()}}),ps=pt.create({name:"drop",addProseMirrorPlugins(){return[new sY({key:new s1("tiptapDrop"),props:{handleDrop:(e,t,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:t,slice:n,moved:r})}}})]}}),po=pt.create({name:"editable",addProseMirrorPlugins(){return[new sY({key:new s1("editable"),props:{editable:()=>this.editor.options.editable}})]}}),pa=new s1("focusEvents"),pl=pt.create({name:"focusEvents",addProseMirrorPlugins(){let{editor:e}=this;return[new sY({key:pa,props:{handleDOMEvents:{focus:(t,n)=>{e.isFocused=!0;let r=e.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return t.dispatch(r),!1},blur:(t,n)=>{e.isFocused=!1;let r=e.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return t.dispatch(r),!1}}}})]}}),pc=pt.create({name:"keymap",addKeyboardShortcuts(){let e=()=>this.editor.commands.first(({commands:e})=>[()=>e.undoInputRule(),()=>e.command(({tr:t})=>{let{selection:n,doc:r}=t,{empty:i,$anchor:s}=n,{pos:o,parent:a}=s,l=s.parent.isTextblock&&o>0?t.doc.resolve(o-1):s,c=l.parent.type.spec.isolating,d=s.pos-s.parentOffset,u=c&&1===l.parent.childCount?d===s.pos:sR.atStart(r).from===o;return!!i&&!!a.type.isTextblock&&!a.textContent.length&&!!u&&(!u||"paragraph"!==s.parent.type.name)&&e.clearNodes()}),()=>e.deleteSelection(),()=>e.joinBackward(),()=>e.selectNodeBackward()]),t=()=>this.editor.commands.first(({commands:e})=>[()=>e.deleteSelection(),()=>e.deleteCurrentNode(),()=>e.joinForward(),()=>e.selectNodeForward()]),n={Enter:()=>this.editor.commands.first(({commands:e})=>[()=>e.newlineInCode(),()=>e.createParagraphNear(),()=>e.liftEmptyBlock(),()=>e.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:e,"Mod-Backspace":e,"Shift-Backspace":e,Delete:t,"Mod-Delete":t,"Mod-a":()=>this.editor.commands.selectAll()},r={...n},i={...n,"Ctrl-h":e,"Alt-Backspace":e,"Ctrl-d":t,"Ctrl-Alt-Backspace":t,"Alt-Delete":t,"Alt-d":t,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return dC()||dF()?i:r},addProseMirrorPlugins(){return[new sY({key:new s1("clearDocument"),appendTransaction:(e,t,n)=>{if(e.some(e=>e.getMeta("composition")))return;let r=e.some(e=>e.docChanged)&&!t.doc.eq(n.doc),i=e.some(e=>e.getMeta("preventClearDocument"));if(!r||i)return;let{empty:s,from:o,to:a}=t.selection,l=sR.atStart(t.doc).from,c=sR.atEnd(t.doc).to;if(s||o!==l||a!==c||!uE(n.doc))return;let d=n.tr,u=c4({state:n,transaction:d}),{commands:p}=new c6({editor:this.editor,state:u});if(p.clearNodes(),d.steps.length)return d}})]}}),pd=pt.create({name:"paste",addProseMirrorPlugins(){return[new sY({key:new s1("tiptapPaste"),props:{handlePaste:(e,t,n)=>{this.editor.emit("paste",{editor:this.editor,event:t,slice:n})}}})]}}),pu=pt.create({name:"tabindex",addOptions:()=>({value:void 0}),addProseMirrorPlugins(){return[new sY({key:new s1("tabindex"),props:{attributes:()=>{var e;return this.editor.isEditable||void 0!==this.options.value?{tabindex:null!=(e=this.options.value)?e:"0"}:{}}}})]}}),pp=pt.create({name:"textDirection",addOptions:()=>({direction:void 0}),addGlobalAttributes(){if(!this.options.direction)return[];let{nodeExtensions:e}=uo(this.extensions);return[{types:e.filter(e=>"text"!==e.name).map(e=>e.name),attributes:{dir:{default:this.options.direction,parseHTML:e=>{let t=e.getAttribute("dir");return t&&("ltr"===t||"rtl"===t||"auto"===t)?t:this.options.direction},renderHTML:e=>e.dir?{dir:e.dir}:{}}}}]},addProseMirrorPlugins(){return[new sY({key:new s1("textDirection"),props:{attributes:()=>{let e=this.options.direction;return e?{dir:e}:{}}}})]}}),ph=class e{constructor(e,t,n=!1,r=null){this.currentNode=null,this.actualDepth=null,this.isBlock=n,this.resolvedPos=e,this.editor=t,this.currentNode=r}get name(){return this.node.type.name}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return null!=(e=this.actualDepth)?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let t=this.from,n=this.to;if(this.isBlock){if(0===this.content.size)return void console.error(`You can\u2019t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);t=this.from+1,n=this.to-1}this.editor.commands.insertContentAt({from:t,to:n},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+ +!this.node.isText}get parent(){if(0===this.depth)return null;let t=this.resolvedPos.start(this.resolvedPos.depth-1);return new e(this.resolvedPos.doc.resolve(t),this.editor)}get before(){let t=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return t.depth!==this.depth&&(t=this.resolvedPos.doc.resolve(this.from-3)),new e(t,this.editor)}get after(){let t=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return t.depth!==this.depth&&(t=this.resolvedPos.doc.resolve(this.to+3)),new e(t,this.editor)}get children(){let t=[];return this.node.content.forEach((n,r)=>{let i=n.isBlock&&!n.isTextblock,s=n.isAtom&&!n.isText,o=n.isInline,a=this.pos+r+ +!s;if(a<0||a>this.resolvedPos.doc.nodeSize-2)return;let l=this.resolvedPos.doc.resolve(a);if(!i&&!o&&l.depth<=this.depth)return;let c=new e(l,this.editor,i,i||o?n:null);i&&(c.actualDepth=this.depth+1),t.push(c)}),t}get firstChild(){return this.children[0]||null}get lastChild(){let e=this.children;return e[e.length-1]||null}closest(e,t={}){let n=null,r=this.parent;for(;r&&!n;){if(r.node.type.name===e)if(Object.keys(t).length>0){let e=r.node.attrs,n=Object.keys(t);for(let r=0;r<n.length;r+=1){let i=n[r];if(e[i]!==t[i])break}}else n=r;r=r.parent}return n}querySelector(e,t={}){return this.querySelectorAll(e,t,!0)[0]||null}querySelectorAll(e,t={},n=!1){let r=[];if(!this.children||0===this.children.length)return r;let i=Object.keys(t);return this.children.forEach(s=>{n&&r.length>0||(s.node.type.name===e&&i.every(e=>t[e]===s.node.attrs[e])&&r.push(s),n&&r.length>0||(r=r.concat(s.querySelectorAll(e,t,n))))}),r}setAttribute(e){let{tr:t}=this.editor.state;t.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(t)}},pf=`.ProseMirror {
|
|
22
|
+
position: relative;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.ProseMirror {
|
|
26
|
+
word-wrap: break-word;
|
|
27
|
+
white-space: pre-wrap;
|
|
28
|
+
white-space: break-spaces;
|
|
29
|
+
-webkit-font-variant-ligatures: none;
|
|
30
|
+
font-variant-ligatures: none;
|
|
31
|
+
font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.ProseMirror [contenteditable="false"] {
|
|
35
|
+
white-space: normal;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.ProseMirror [contenteditable="false"] [contenteditable="true"] {
|
|
39
|
+
white-space: pre-wrap;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.ProseMirror pre {
|
|
43
|
+
white-space: pre-wrap;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
img.ProseMirror-separator {
|
|
47
|
+
display: inline !important;
|
|
48
|
+
border: none !important;
|
|
49
|
+
margin: 0 !important;
|
|
50
|
+
width: 0 !important;
|
|
51
|
+
height: 0 !important;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.ProseMirror-gapcursor {
|
|
55
|
+
display: none;
|
|
56
|
+
pointer-events: none;
|
|
57
|
+
position: absolute;
|
|
58
|
+
margin: 0;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.ProseMirror-gapcursor:after {
|
|
62
|
+
content: "";
|
|
63
|
+
display: block;
|
|
64
|
+
position: absolute;
|
|
65
|
+
top: -2px;
|
|
66
|
+
width: 20px;
|
|
67
|
+
border-top: 1px solid black;
|
|
68
|
+
animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
@keyframes ProseMirror-cursor-blink {
|
|
72
|
+
to {
|
|
73
|
+
visibility: hidden;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.ProseMirror-hideselection *::selection {
|
|
78
|
+
background: transparent;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.ProseMirror-hideselection *::-moz-selection {
|
|
82
|
+
background: transparent;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.ProseMirror-hideselection * {
|
|
86
|
+
caret-color: transparent;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.ProseMirror-focused .ProseMirror-gapcursor {
|
|
90
|
+
display: block;
|
|
91
|
+
}`,pm=class extends u2{constructor(e={}){super(),this.css=null,this.className="tiptap",this.editorView=null,this.isFocused=!1,this.destroyed=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.options={element:"u">typeof document?document.createElement("div"):null,content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,textDirection:void 0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onMount:()=>null,onUnmount:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:e})=>{throw e},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null,enableExtensionDispatchTransaction:!0},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.utils={getUpdatedPosition:uT,createMappablePosition:uO},this.setOptions(e),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("mount",this.options.onMount),this.on("unmount",this.options.onUnmount),this.on("contentError",this.options.onContentError),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:e,slice:t,moved:n})=>this.options.onDrop(e,t,n)),this.on("paste",({event:e,slice:t})=>this.options.onPaste(e,t)),this.on("delete",this.options.onDelete);const t=this.createDoc(),n=dN(t,this.options.autofocus);this.editorState=sX.create({doc:t,schema:this.schema,selection:n||void 0}),this.options.element&&this.mount(this.options.element)}mount(e){if("u"<typeof document)throw Error("[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.");this.createView(e),this.emit("mount",{editor:this}),this.css&&!document.head.contains(this.css)&&document.head.appendChild(this.css),window.setTimeout(()=>{this.isDestroyed||(!1!==this.options.autofocus&&null!==this.options.autofocus&&this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}unmount(){if(this.editorView){let e=this.editorView.dom;(null==e?void 0:e.editor)&&delete e.editor,this.editorView.destroy()}if(this.editorView=null,this.isInitialized=!1,this.css&&!document.querySelectorAll(`.${this.className}`).length)try{"function"==typeof this.css.remove?this.css.remove():this.css.parentNode&&this.css.parentNode.removeChild(this.css)}catch(e){console.warn("Failed to remove CSS element:",e)}this.css=null,this.emit("unmount",{editor:this})}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&"u">typeof document&&(this.css=function(e,t){let n=document.querySelector("style[data-tiptap-style]");if(null!==n)return n;let r=document.createElement("style");return t&&r.setAttribute("nonce",t),r.setAttribute("data-tiptap-style",""),r.innerHTML=e,document.getElementsByTagName("head")[0].appendChild(r),r}(pf,this.options.injectNonce))}setOptions(e={}){this.options={...this.options,...e},this.editorView&&this.state&&!this.isDestroyed&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(e,t=!0){this.setOptions({editable:e}),t&&this.emit("update",{editor:this,transaction:this.state.tr,appendedTransactions:[]})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get view(){return this.editorView?this.editorView:new Proxy({state:this.editorState,updateState:e=>{this.editorState=e},dispatch:e=>{this.dispatchTransaction(e)},composing:!1,dragging:null,editable:!0,isDestroyed:!1},{get:(e,t)=>{if(this.editorView)return this.editorView[t];if("state"===t)return this.editorState;if(t in e)return Reflect.get(e,t);throw Error(`[tiptap error]: The editor view is not available. Cannot access view['${t}']. The editor may not be mounted yet.`)}})}get state(){return this.editorView&&(this.editorState=this.view.state),this.editorState}registerPlugin(e,t){let n=ui(t)?t(e,[...this.state.plugins]):[...this.state.plugins,e],r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}unregisterPlugin(e){if(this.isDestroyed)return;let t=this.state.plugins,n=t;if([].concat(e).forEach(e=>{let t="string"==typeof e?`${e}$`:e.key;n=n.filter(e=>!e.key.startsWith(t))}),t.length===n.length)return;let r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}createExtensionManager(){var e,t,n,r;let i=[...this.options.enableCoreExtensions?[po,pn.configure({blockSeparator:null==(t=null==(e=this.options.coreExtensionOptions)?void 0:e.clipboardTextSerializer)?void 0:t.blockSeparator}),pr,pl,pc,pu.configure({value:null==(r=null==(n=this.options.coreExtensionOptions)?void 0:n.tabindex)?void 0:r.value}),ps,pd,pi,pp.configure({direction:this.options.textDirection})].filter(e=>"object"!=typeof this.options.enableCoreExtensions||!1!==this.options.enableCoreExtensions[e.name]):[],...this.options.extensions].filter(e=>["extension","node","mark"].includes(null==e?void 0:e.type));this.extensionManager=new pe(i,this)}createCommandManager(){this.commandManager=new c6({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let e;try{e=d5(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(t){if(!(t instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(t.message))throw t;this.emit("contentError",{editor:this,error:t,disableCollaboration:()=>{"collaboration"in this.storage&&"object"==typeof this.storage.collaboration&&this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(e=>"collaboration"!==e.name),this.createExtensionManager()}}),e=d5(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return e}createView(e){let{editorProps:t,enableExtensionDispatchTransaction:n}=this.options,r=t.dispatchTransaction||this.dispatchTransaction.bind(this),i=n?this.extensionManager.dispatchTransaction(r):r,s=t.transformPastedHTML,o=this.extensionManager.transformPastedHTML(s);this.editorView=new ly(e,{...t,attributes:{role:"textbox",...null==t?void 0:t.attributes},dispatchTransaction:i,transformPastedHTML:o,state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});let a=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(a),this.prependClass(),this.injectCSS(),this.view.dom.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`${this.className} ${this.view.dom.className}`}captureTransaction(e){this.isCapturingTransaction=!0,e(),this.isCapturingTransaction=!1;let t=this.capturedTransaction;return this.capturedTransaction=null,t}dispatchTransaction(e){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=e;return}e.steps.forEach(e=>{var t;return null==(t=this.capturedTransaction)?void 0:t.step(e)});return}let{state:t,transactions:n}=this.state.applyTransaction(e),r=!this.state.selection.eq(t.selection),i=n.includes(e),s=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:e,nextState:t}),!i)return;this.view.updateState(t),this.emit("transaction",{editor:this,transaction:e,appendedTransactions:n.slice(1)}),r&&this.emit("selectionUpdate",{editor:this,transaction:e});let o=n.findLast(e=>e.getMeta("focus")||e.getMeta("blur")),a=null==o?void 0:o.getMeta("focus"),l=null==o?void 0:o.getMeta("blur");a&&this.emit("focus",{editor:this,event:a.event,transaction:o}),l&&this.emit("blur",{editor:this,event:l.event,transaction:o}),e.getMeta("preventUpdate")||!n.some(e=>e.docChanged)||s.doc.eq(t.doc)||this.emit("update",{editor:this,transaction:e,appendedTransactions:n.slice(1)})}getAttributes(e){return uy(this.state,e)}isActive(e,t){let n="string"==typeof e?e:null,r="string"==typeof e?t:e;return function(e,t,n={}){if(!t)return dU(e,null,n)||uS(e,null,n);let r=dG(t,e.schema);return"node"===r?dU(e,t,n):"mark"===r&&uS(e,t,n)}(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return ur(this.state.doc.content,this.schema)}getText(e){let{blockSeparator:t="\n\n",textSerializers:n={}}=e||{};return ub(this.state.doc,{blockSeparator:t,textSerializers:{...ux(this.schema),...n}})}get isEmpty(){return uE(this.state.doc)}destroy(){this.destroyed||(this.destroyed=!0,this.emit("destroy"),this.unmount(),this.removeAllListeners(),this.extensionManager.destroy(),this.extensionManager=null,this.schema=null,this.commandManager=null,this.extensionStorage={})}get isDestroyed(){var e,t;return null==(t=null==(e=this.editorView)?void 0:e.isDestroyed)||t}$node(e,t){var n;return(null==(n=this.$doc)?void 0:n.querySelector(e,t))||null}$nodes(e,t){var n;return(null==(n=this.$doc)?void 0:n.querySelectorAll(e,t))||null}$pos(e){let t=this.state.doc.resolve(e),n=e>0&&t.nodeAfter&&!t.nodeAfter.isText?t.nodeAfter:null;return new ph(t,this,!1,n)}get $doc(){return this.$pos(0)}};function pg(e){return new u3({find:e.find,handler:({state:t,range:n,match:r})=>{let i=us(e.getAttributes,void 0,r);if(!1===i||null===i)return null;let{tr:s}=t,o=r[r.length-1],a=r[0];if(o){let r=a.search(/\S/),l=n.from+a.indexOf(o),c=l+o.length;if(uw(n.from,n.to,t.doc).filter(t=>t.mark.type.excluded.find(n=>n===e.type&&n!==t.mark.type)).filter(e=>e.to>l).length)return null;c<n.to&&s.delete(c,n.to),l>n.from&&s.delete(n.from+r,l);let d=n.from+r+o.length;s.addMark(n.from+r,d,e.type.create(i||{})),s.removeStoredMark(e.type)}},undoable:e.undoable})}function pb(e){return new u3({find:e.find,handler:({state:t,range:n,match:r})=>{let i=us(e.getAttributes,void 0,r)||{},{tr:s}=t,o=n.from,a=n.to,l=e.type.create(i);if(r[1]){let e=o+r[0].lastIndexOf(r[1]);e>a?e=a:a=e+r[1].length;let t=r[0][r[0].length-1];s.insertText(t,o+r[0].length-1),s.replaceWith(e,a,l)}else if(r[0]){let t=e.type.isInline?o:o-1;s.insert(t,e.type.create(i)).delete(s.mapping.map(o),s.mapping.map(a))}s.scrollIntoView()},undoable:e.undoable})}function px(e){return new u3({find:e.find,handler:({state:t,range:n,match:r})=>{let i=t.doc.resolve(n.from),s=us(e.getAttributes,void 0,r)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),e.type))return null;t.tr.delete(n.from,n.to).setBlockType(n.from,n.from,e.type,s)},undoable:e.undoable})}function py(e){return new u3({find:e.find,handler:({state:t,range:n,match:r,chain:i})=>{let s=us(e.getAttributes,void 0,r)||{},o=t.tr.delete(n.from,n.to),a=o.doc.resolve(n.from).blockRange(),l=a&&sp(a,e.type,s);if(!l)return null;if(o.wrap(a,l),e.keepMarks&&e.editor){let{selection:n,storedMarks:r}=t,{splittableMarks:i}=e.editor.extensionManager,s=r||n.$to.parentOffset&&n.$from.marks();if(s){let e=s.filter(e=>i.includes(e.type.name));o.ensureMarks(e)}}if(e.keepAttributes){let t="bulletList"===e.type.name||"orderedList"===e.type.name?"listItem":"taskList";i().updateAttributes(t,s).run()}let c=o.doc.resolve(n.from-1).nodeBefore;c&&c.type===e.type&&sb(o.doc,n.from-1)&&(!e.joinPredicate||e.joinPredicate(r,c))&&o.join(n.from-1)},undoable:e.undoable})}var pv=class{constructor(e){var t,n,r,i,s,o;this.directions=["bottom-left","bottom-right","top-left","top-right"],this.minSize={height:8,width:8},this.preserveAspectRatio=!1,this.classNames={container:"",wrapper:"",handle:"",resizing:""},this.initialWidth=0,this.initialHeight=0,this.aspectRatio=1,this.isResizing=!1,this.activeHandle=null,this.startX=0,this.startY=0,this.startWidth=0,this.startHeight=0,this.isShiftKeyPressed=!1,this.lastEditableState=void 0,this.handleMap=new Map,this.handleMouseMove=e=>{if(!this.isResizing||!this.activeHandle)return;let t=e.clientX-this.startX,n=e.clientY-this.startY;this.handleResize(t,n)},this.handleTouchMove=e=>{if(!this.isResizing||!this.activeHandle)return;let t=e.touches[0];if(!t)return;let n=t.clientX-this.startX,r=t.clientY-this.startY;this.handleResize(n,r)},this.handleMouseUp=()=>{if(!this.isResizing)return;let e=this.element.offsetWidth,t=this.element.offsetHeight;this.onCommit(e,t),this.isResizing=!1,this.activeHandle=null,this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp)},this.handleKeyDown=e=>{"Shift"===e.key&&(this.isShiftKeyPressed=!0)},this.handleKeyUp=e=>{"Shift"===e.key&&(this.isShiftKeyPressed=!1)},this.node=e.node,this.editor=e.editor,this.element=e.element,this.contentElement=e.contentElement,this.getPos=e.getPos,this.onResize=e.onResize,this.onCommit=e.onCommit,this.onUpdate=e.onUpdate,(null==(t=e.options)?void 0:t.min)&&(this.minSize={...this.minSize,...e.options.min}),(null==(n=e.options)?void 0:n.max)&&(this.maxSize=e.options.max),(null==(r=null==e?void 0:e.options)?void 0:r.directions)&&(this.directions=e.options.directions),(null==(i=e.options)?void 0:i.preserveAspectRatio)&&(this.preserveAspectRatio=e.options.preserveAspectRatio),(null==(s=e.options)?void 0:s.className)&&(this.classNames={container:e.options.className.container||"",wrapper:e.options.className.wrapper||"",handle:e.options.className.handle||"",resizing:e.options.className.resizing||""}),(null==(o=e.options)?void 0:o.createCustomHandle)&&(this.createCustomHandle=e.options.createCustomHandle),this.wrapper=this.createWrapper(),this.container=this.createContainer(),this.applyInitialSize(),this.attachHandles(),this.editor.on("update",this.handleEditorUpdate.bind(this))}get dom(){return this.container}get contentDOM(){var e;return null!=(e=this.contentElement)?e:null}handleEditorUpdate(){let e=this.editor.isEditable;e!==this.lastEditableState&&(this.lastEditableState=e,e?e&&0===this.handleMap.size&&this.attachHandles():this.removeHandles())}update(e,t,n){return e.type===this.node.type&&(this.node=e,!this.onUpdate||this.onUpdate(e,t,n))}destroy(){this.isResizing&&(this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp),this.isResizing=!1,this.activeHandle=null),this.editor.off("update",this.handleEditorUpdate.bind(this)),this.container.remove()}createContainer(){let e=document.createElement("div");return e.dataset.resizeContainer="",e.dataset.node=this.node.type.name,e.style.display=this.node.type.isInline?"inline-flex":"flex",this.classNames.container&&(e.className=this.classNames.container),e.appendChild(this.wrapper),e}createWrapper(){let e=document.createElement("div");return e.style.position="relative",e.style.display="block",e.dataset.resizeWrapper="",this.classNames.wrapper&&(e.className=this.classNames.wrapper),e.appendChild(this.element),e}createHandle(e){let t=document.createElement("div");return t.dataset.resizeHandle=e,t.style.position="absolute",this.classNames.handle&&(t.className=this.classNames.handle),t}positionHandle(e,t){let n=t.includes("top"),r=t.includes("bottom"),i=t.includes("left"),s=t.includes("right");n&&(e.style.top="0"),r&&(e.style.bottom="0"),i&&(e.style.left="0"),s&&(e.style.right="0"),("top"===t||"bottom"===t)&&(e.style.left="0",e.style.right="0"),("left"===t||"right"===t)&&(e.style.top="0",e.style.bottom="0")}attachHandles(){this.directions.forEach(e=>{let t;(t=this.createCustomHandle?this.createCustomHandle(e):this.createHandle(e))instanceof HTMLElement||(console.warn(`[ResizableNodeView] createCustomHandle("${e}") did not return an HTMLElement. Falling back to default handle.`),t=this.createHandle(e)),this.createCustomHandle||this.positionHandle(t,e),t.addEventListener("mousedown",t=>this.handleResizeStart(t,e)),t.addEventListener("touchstart",t=>this.handleResizeStart(t,e)),this.handleMap.set(e,t),this.wrapper.appendChild(t)})}removeHandles(){this.handleMap.forEach(e=>e.remove()),this.handleMap.clear()}applyInitialSize(){let e=this.node.attrs.width,t=this.node.attrs.height;e?(this.element.style.width=`${e}px`,this.initialWidth=e):this.initialWidth=this.element.offsetWidth,t?(this.element.style.height=`${t}px`,this.initialHeight=t):this.initialHeight=this.element.offsetHeight,this.initialWidth>0&&this.initialHeight>0&&(this.aspectRatio=this.initialWidth/this.initialHeight)}handleResizeStart(e,t){e.preventDefault(),e.stopPropagation(),this.isResizing=!0,this.activeHandle=t,"touches"in e?(this.startX=e.touches[0].clientX,this.startY=e.touches[0].clientY):(this.startX=e.clientX,this.startY=e.clientY),this.startWidth=this.element.offsetWidth,this.startHeight=this.element.offsetHeight,this.startWidth>0&&this.startHeight>0&&(this.aspectRatio=this.startWidth/this.startHeight),this.getPos(),this.container.dataset.resizeState="true",this.classNames.resizing&&this.container.classList.add(this.classNames.resizing),document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("touchmove",this.handleTouchMove),document.addEventListener("mouseup",this.handleMouseUp),document.addEventListener("keydown",this.handleKeyDown),document.addEventListener("keyup",this.handleKeyUp)}handleResize(e,t){if(!this.activeHandle)return;let n=this.preserveAspectRatio||this.isShiftKeyPressed,{width:r,height:i}=this.calculateNewDimensions(this.activeHandle,e,t),s=this.applyConstraints(r,i,n);this.element.style.width=`${s.width}px`,this.element.style.height=`${s.height}px`,this.onResize&&this.onResize(s.width,s.height)}calculateNewDimensions(e,t,n){let r=this.startWidth,i=this.startHeight,s=e.includes("right"),o=e.includes("left"),a=e.includes("bottom"),l=e.includes("top");return(s?r=this.startWidth+t:o&&(r=this.startWidth-t),a?i=this.startHeight+n:l&&(i=this.startHeight-n),("right"===e||"left"===e)&&(r=this.startWidth+(s?t:-t)),("top"===e||"bottom"===e)&&(i=this.startHeight+(a?n:-n)),this.preserveAspectRatio||this.isShiftKeyPressed)?this.applyAspectRatio(r,i,e):{width:r,height:i}}applyConstraints(e,t,n){var r,i,s,o;if(!n){let n=Math.max(this.minSize.width,e),s=Math.max(this.minSize.height,t);return(null==(r=this.maxSize)?void 0:r.width)&&(n=Math.min(this.maxSize.width,n)),(null==(i=this.maxSize)?void 0:i.height)&&(s=Math.min(this.maxSize.height,s)),{width:n,height:s}}let a=e,l=t;return a<this.minSize.width&&(l=(a=this.minSize.width)/this.aspectRatio),l<this.minSize.height&&(a=(l=this.minSize.height)*this.aspectRatio),(null==(s=this.maxSize)?void 0:s.width)&&a>this.maxSize.width&&(l=(a=this.maxSize.width)/this.aspectRatio),(null==(o=this.maxSize)?void 0:o.height)&&l>this.maxSize.height&&(a=(l=this.maxSize.height)*this.aspectRatio),{width:a,height:l}}applyAspectRatio(e,t,n){return"left"===n||"right"===n?{width:e,height:e/this.aspectRatio}:"top"===n||"bottom"===n?{width:t*this.aspectRatio,height:t}:{width:e,height:e/this.aspectRatio}}};function pw(e){if(!(null==e?void 0:e.trim()))return{};let t={},n=[],r=e.replace(/["']([^"']*)["']/g,e=>(n.push(e),`__QUOTED_${n.length-1}__`)),i=r.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);i&&(t.class=i.map(e=>e.trim().slice(1)).join(" "));let s=r.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);s&&(t.id=s[1]),Array.from(r.matchAll(/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g)).forEach(([,e,r])=>{var i;let s=n[parseInt((null==(i=r.match(/__QUOTED_(\d+)__/))?void 0:i[1])||"0",10)];s&&(t[e]=s.slice(1,-1))});let o=r.replace(/(?:^|\s)\.([a-zA-Z][\w-]*)/g,"").replace(/(?:^|\s)#([a-zA-Z][\w-]*)/g,"").replace(/([a-zA-Z][\w-]*)\s*=\s*__QUOTED_\d+__/g,"").trim();return o&&o.split(/\s+/).filter(Boolean).forEach(e=>{e.match(/^[a-zA-Z][\w-]*$/)&&(t[e]=!0)}),t}function pk(e){if(!e||0===Object.keys(e).length)return"";let t=[];return e.class&&String(e.class).split(/\s+/).filter(Boolean).forEach(e=>t.push(`.${e}`)),e.id&&t.push(`#${e.id}`),Object.entries(e).forEach(([e,n])=>{"class"!==e&&"id"!==e&&(!0===n?t.push(e):!1!==n&&null!=n&&t.push(`${e}="${String(n)}"`))}),t.join(" ")}function pN(e){let{nodeName:t,name:n,parseAttributes:r=pw,serializeAttributes:i=pk,defaultAttributes:s={},requiredAttributes:o=[],allowedAttributes:a}=e,l=n||t;return{parseMarkdown:(e,n)=>{let r={...s,...e.attributes};return n.createNode(t,r,[])},markdownTokenizer:{name:t,level:"block",start(e){var t;let n=RegExp(`^:::${l}(?:\\s|$)`,"m"),r=null==(t=e.match(n))?void 0:t.index;return void 0!==r?r:-1},tokenize(e,n,i){let s=RegExp(`^:::${l}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),a=e.match(s);if(!a)return;let c=r(a[1]||"");if(!o.find(e=>!(e in c)))return{type:t,raw:a[0],attributes:c}}},renderMarkdown:e=>{let t=i((e=>{if(!a)return e;let t={};return a.forEach(n=>{n in e&&(t[n]=e[n])}),t})(e.attrs||{})),n=t?` {${t}}`:"";return`:::${l}${n} :::`}}}function pS(e){let{nodeName:t,name:n,getContent:r,parseAttributes:i=pw,serializeAttributes:s=pk,defaultAttributes:o={},content:a="block",allowedAttributes:l}=e,c=n||t;return{parseMarkdown:(e,n)=>{let i;if(r){let t=r(e);i="string"==typeof t?[{type:"text",text:t}]:t}else i="block"===a?n.parseChildren(e.tokens||[]):n.parseInline(e.tokens||[]);let s={...o,...e.attributes};return n.createNode(t,s,i)},markdownTokenizer:{name:t,level:"block",start(e){var t;let n=RegExp(`^:::${c}`,"m"),r=null==(t=e.match(n))?void 0:t.index;return void 0!==r?r:-1},tokenize(e,n,r){var s;let o=RegExp(`^:::${c}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),l=e.match(o);if(!l)return;let[d,u=""]=l,p=i(u),h=1,f=d.length,m="",g=/^:::([\w-]*)(\s.*)?/gm,b=e.slice(f);for(g.lastIndex=0;;){let n=g.exec(b);if(null===n)break;let i=n.index,o=n[1];if(null==(s=n[2])||!s.endsWith(":::")){if(o)h+=1;else if(0==(h-=1)){let s=b.slice(0,i);m=s.trim();let o=e.slice(0,f+i+n[0].length),l=[];if(m)if("block"===a)for((l=r.blockTokens(s)).forEach(e=>{e.text&&(!e.tokens||0===e.tokens.length)&&(e.tokens=r.inlineTokens(e.text))});l.length>0;){let e=l[l.length-1];if("paragraph"!==e.type||e.text&&""!==e.text.trim())break;l.pop()}else l=r.inlineTokens(m);return{type:t,raw:o,attributes:p,content:m,tokens:l}}}}}},renderMarkdown:(e,t)=>{let n=s((e=>{if(!l)return e;let t={};return l.forEach(n=>{n in e&&(t[n]=e[n])}),t})(e.attrs||{})),r=n?` {${n}}`:"",i=t.renderChildren(e.content||[],"\n\n");return`:::${c}${r}
|
|
92
|
+
|
|
93
|
+
${i}
|
|
94
|
+
|
|
95
|
+
:::`}}}function pC(e){if(!e.trim())return{};let t={},n=/(\w+)=(?:"([^"]*)"|'([^']*)')/g,r=n.exec(e);for(;null!==r;){let[,i,s,o]=r;t[i]=s||o,r=n.exec(e)}return t}function pj(e){return Object.entries(e).filter(([,e])=>null!=e).map(([e,t])=>`${e}="${t}"`).join(" ")}function pE(e){let{nodeName:t,name:n,getContent:r,parseAttributes:i=pC,serializeAttributes:s=pj,defaultAttributes:o={},selfClosing:a=!1,allowedAttributes:l}=e,c=n||t,d=c.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(e,n)=>{let i={...o,...e.attributes};if(a)return n.createNode(t,i);let s=r?r(e):e.content||"";return s?n.createNode(t,i,[n.createTextNode(s)]):n.createNode(t,i,[])},markdownTokenizer:{name:t,level:"inline",start(e){let t=a?RegExp(`\\[${d}\\s*[^\\]]*\\]`):RegExp(`\\[${d}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${d}\\]`),n=e.match(t),r=null==n?void 0:n.index;return void 0!==r?r:-1},tokenize(e,n,r){let s=a?RegExp(`^\\[${d}\\s*([^\\]]*)\\]`):RegExp(`^\\[${d}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${d}\\]`),o=e.match(s);if(!o)return;let l="",c="";if(a){let[,e]=o;c=e}else{let[,e,t]=o;c=e,l=t||""}let u=i(c.trim());return{type:t,raw:o[0],content:l.trim(),attributes:u}}},renderMarkdown:e=>{let t="";r?t=r(e):e.content&&e.content.length>0&&(t=e.content.filter(e=>"text"===e.type).map(e=>e.text).join(""));let n=s((e=>{if(!l)return e;let t={};return l.forEach(n=>{let r="string"==typeof n?n:n.name,i="string"==typeof n?void 0:n.skipIfDefault;if(r in e){let n=e[r];if(void 0!==i&&n===i)return;t[r]=n}}),t})(e.attrs||{})),i=n?` ${n}`:"";return a?`[${c}${i}]`:`[${c}${i}]${t}[/${c}]`}}}function pM(e,t,n){var r,i,s,o;let a=e.split("\n"),l=[],c="",d=0,u=t.baseIndentSize||2;for(;d<a.length;){let e,p=a[d],h=p.match(t.itemPattern);if(!h)if(l.length>0)break;else{if(""!==p.trim())return;d+=1,c=`${c}${p}
|
|
96
|
+
`;continue}let f=t.extractItemData(h),{indentLevel:m,mainContent:g}=f;c=`${c}${p}
|
|
97
|
+
`;let b=[g];for(d+=1;d<a.length;){let e=a[d];if(""===e.trim()){let t=a.slice(d+1).findIndex(e=>""!==e.trim());if(-1===t)break;if(((null==(i=null==(r=a[d+1+t].match(/^(\s*)/))?void 0:r[1])?void 0:i.length)||0)>m){b.push(e),c=`${c}${e}
|
|
98
|
+
`,d+=1;continue}break}if(((null==(o=null==(s=e.match(/^(\s*)/))?void 0:s[1])?void 0:o.length)||0)>m)b.push(e),c=`${c}${e}
|
|
99
|
+
`,d+=1;else break}let x=b.slice(1);if(x.length>0){let r=x.map(e=>e.slice(m+u)).join("\n");r.trim()&&(e=t.customNestedParser?t.customNestedParser(r):n.blockTokens(r))}let y=t.createToken(f,e);l.push(y)}if(0!==l.length)return{items:l,raw:c}}function pA(e,t,n,r){if(!e||!Array.isArray(e.content))return"";let i="function"==typeof n?n(r):n,[s,...o]=e.content,a=t.renderChildren([s]),l=`${i}${a}`;return o&&o.length>0&&o.forEach((e,n)=>{var r,i;let s=null!=(i=null==(r=t.renderChild)?void 0:r.call(t,e,n+1))?i:t.renderChildren([e]);if(null!=s){let n=s.split("\n").map(e=>e?t.indent(e):t.indent("")).join("\n");l+="paragraph"===e.type?`
|
|
100
|
+
|
|
101
|
+
${n}`:`
|
|
102
|
+
${n}`}}),l}c5({},{createAtomBlockMarkdownSpec:()=>pN,createBlockMarkdownSpec:()=>pS,createInlineMarkdownSpec:()=>pE,parseAttributes:()=>pw,parseIndentedBlocks:()=>pM,renderNestedMarkdownContent:()=>pA,serializeAttributes:()=>pk});var pT=class e extends u6{constructor(){super(...arguments),this.type="node"}static create(t={}){return new e("function"==typeof t?t():t)}configure(e){return super.configure(e)}extend(e){let t="function"==typeof e?e():e;return super.extend(t)}},pO=class{constructor(e,t,n){this.isDragging=!1,this.component=e,this.editor=t.editor,this.options={stopEvent:null,ignoreMutation:null,...n},this.extension=t.extension,this.node=t.node,this.decorations=t.decorations,this.innerDecorations=t.innerDecorations,this.view=t.view,this.HTMLAttributes=t.HTMLAttributes,this.getPos=t.getPos,this.mount()}mount(){}get dom(){return this.editor.view.dom}get contentDOM(){return null}onDragStart(e){var t,n,r,i,s,o,a;let{view:l}=this.editor,c=e.target,d=3===c.nodeType?null==(t=c.parentElement)?void 0:t.closest("[data-drag-handle]"):c.closest("[data-drag-handle]");if(!this.dom||(null==(n=this.contentDOM)?void 0:n.contains(c))||!d)return;let u=0,p=0;if(this.dom!==d){let t=this.dom.getBoundingClientRect(),n=d.getBoundingClientRect(),a=null!=(i=e.offsetX)?i:null==(r=e.nativeEvent)?void 0:r.offsetX,l=null!=(o=e.offsetY)?o:null==(s=e.nativeEvent)?void 0:s.offsetY;u=n.x-t.x+a,p=n.y-t.y+l}let h=this.dom.cloneNode(!0);try{let e=this.dom.getBoundingClientRect();h.style.width=`${Math.round(e.width)}px`,h.style.height=`${Math.round(e.height)}px`,h.style.boxSizing="border-box",h.style.pointerEvents="none"}catch{}let f=null;try{(f=document.createElement("div")).style.position="absolute",f.style.top="-9999px",f.style.left="-9999px",f.style.pointerEvents="none",f.appendChild(h),document.body.appendChild(f),null==(a=e.dataTransfer)||a.setDragImage(h,u,p)}finally{f&&setTimeout(()=>{try{null==f||f.remove()}catch{}},0)}let m=this.getPos();if("number"!=typeof m)return;let g=sB.create(l.state.doc,m),b=l.state.tr.setSelection(g);l.dispatch(b)}stopEvent(e){var t;if(!this.dom)return!1;if("function"==typeof this.options.stopEvent)return this.options.stopEvent({event:e});let n=e.target;if(!(this.dom.contains(n)&&!(null==(t=this.contentDOM)?void 0:t.contains(n))))return!1;let r=e.type.startsWith("drag"),i="dragover"===e.type||"dragenter"===e.type,s="drop"===e.type;if((["INPUT","BUTTON","SELECT","TEXTAREA"].includes(n.tagName)||n.isContentEditable)&&!s&&!r)return!0;let{isEditable:o}=this.editor,{isDragging:a}=this,l=!!this.node.type.spec.draggable,c=sB.isSelectable(this.node),d="copy"===e.type,u="paste"===e.type,p="cut"===e.type,h="mousedown"===e.type;if(!l&&c&&r&&e.target===this.dom&&e.preventDefault(),l&&r&&!a&&e.target===this.dom)return e.preventDefault(),!1;if(l&&o&&!a&&h){let e=n.closest("[data-drag-handle]");e&&(this.dom===e||this.dom.contains(e))&&(this.isDragging=!0,document.addEventListener("dragend",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("drop",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("mouseup",()=>{this.isDragging=!1},{once:!0}))}return!a&&!i&&!s&&!d&&!u&&!p&&(!h||!c)&&!0}ignoreMutation(e){return!this.dom||!this.contentDOM||("function"==typeof this.options.ignoreMutation?this.options.ignoreMutation({mutation:e}):!!this.node.isLeaf||!!this.node.isAtom||!("selection"===e.type||this.dom.contains(e.target)&&"childList"===e.type&&(dC()||dS())&&this.editor.isFocused&&[...Array.from(e.addedNodes),...Array.from(e.removedNodes)].every(e=>e.isContentEditable))&&(this.contentDOM===e.target&&"attributes"===e.type||!this.contentDOM.contains(e.target)))}updateAttributes(e){this.editor.commands.command(({tr:t})=>{let n=this.getPos();return"number"==typeof n&&(t.setNodeMarkup(n,void 0,{...this.node.attrs,...e}),!0)})}deleteNode(){let e=this.getPos();if("number"!=typeof e)return;let t=e+this.node.nodeSize;this.editor.commands.deleteRange({from:e,to:t})}};function p_(e){return new u7({find:e.find,handler:({state:t,range:n,match:r,pasteEvent:i})=>{let s=us(e.getAttributes,void 0,r,i);if(!1===s||null===s)return null;let{tr:o}=t,a=r[r.length-1],l=r[0],c=n.to;if(a){let i=l.search(/\S/),d=n.from+l.indexOf(a),u=d+a.length;if(uw(n.from,n.to,t.doc).filter(t=>t.mark.type.excluded.find(n=>n===e.type&&n!==t.mark.type)).filter(e=>e.to>d).length)return null;u<n.to&&o.delete(u,n.to),d>n.from&&o.delete(n.from+i,d),c=n.from+i+a.length,o.addMark(n.from+i,c,e.type.create(s||{})),void 0!==r.index&&void 0!==r.input&&r.index+r[0].length>=r.input.length||o.removeStoredMark(e.type)}}})}let{getOwnPropertyNames:pD,getOwnPropertySymbols:pR}=Object,{hasOwnProperty:pI}=Object.prototype;function pL(e,t){return function(n,r,i){return e(n,r,i)&&t(n,r,i)}}function pP(e){return function(t,n,r){if(!t||!n||"object"!=typeof t||"object"!=typeof n)return e(t,n,r);let{cache:i}=r,s=i.get(t),o=i.get(n);if(s&&o)return s===n&&o===t;i.set(t,n),i.set(n,t);let a=e(t,n,r);return i.delete(t),i.delete(n),a}}function pz(e){return pD(e).concat(pR(e))}let p$=Object.hasOwn||((e,t)=>pI.call(e,t));function pB(e,t){return e===t||!e&&!t&&e!=e&&t!=t}let{getOwnPropertyDescriptor:pF,keys:pH}=Object;function pU(e,t){return e.byteLength===t.byteLength&&p1(new Uint8Array(e),new Uint8Array(t))}function pV(e,t,n){let r=e.length;if(t.length!==r)return!1;for(;r-- >0;)if(!n.equals(e[r],t[r],r,r,e,t,n))return!1;return!0}function pW(e,t){return e.byteLength===t.byteLength&&p1(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}function pq(e,t){return pB(e.getTime(),t.getTime())}function pK(e,t){return e.name===t.name&&e.message===t.message&&e.cause===t.cause&&e.stack===t.stack}function pG(e,t){return e===t}function pJ(e,t,n){let r,i,s=e.size;if(s!==t.size)return!1;if(!s)return!0;let o=Array(s),a=e.entries(),l=0;for(;(r=a.next())&&!r.done;){let s=t.entries(),a=!1,c=0;for(;(i=s.next())&&!i.done;){if(o[c]){c++;continue}let s=r.value,d=i.value;if(n.equals(s[0],d[0],l,c,e,t,n)&&n.equals(s[1],d[1],s[0],d[0],e,t,n)){a=o[c]=!0;break}c++}if(!a)return!1;l++}return!0}function pZ(e,t,n){let r=pH(e),i=r.length;if(pH(t).length!==i)return!1;for(;i-- >0;)if(!p3(e,t,n,r[i]))return!1;return!0}function pX(e,t,n){let r,i,s,o=pz(e),a=o.length;if(pz(t).length!==a)return!1;for(;a-- >0;)if(!p3(e,t,n,r=o[a])||(i=pF(e,r),s=pF(t,r),(i||s)&&(!i||!s||i.configurable!==s.configurable||i.enumerable!==s.enumerable||i.writable!==s.writable)))return!1;return!0}function pY(e,t){return pB(e.valueOf(),t.valueOf())}function pQ(e,t){return e.source===t.source&&e.flags===t.flags}function p0(e,t,n){let r,i,s=e.size;if(s!==t.size)return!1;if(!s)return!0;let o=Array(s),a=e.values();for(;(r=a.next())&&!r.done;){let s=t.values(),a=!1,l=0;for(;(i=s.next())&&!i.done;){if(!o[l]&&n.equals(r.value,i.value,r.value,i.value,e,t,n)){a=o[l]=!0;break}l++}if(!a)return!1}return!0}function p1(e,t){let n=e.byteLength;if(t.byteLength!==n||e.byteOffset!==t.byteOffset)return!1;for(;n-- >0;)if(e[n]!==t[n])return!1;return!0}function p2(e,t){return e.hostname===t.hostname&&e.pathname===t.pathname&&e.protocol===t.protocol&&e.port===t.port&&e.hash===t.hash&&e.username===t.username&&e.password===t.password}function p3(e,t,n,r){return("_owner"===r||"__o"===r||"__v"===r)&&(!!e.$$typeof||!!t.$$typeof)||p$(t,r)&&n.equals(e[r],t[r],r,r,e,t,n)}let p5={"[object Int8Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0,"[object Int16Array]":!0,"[object Uint16Array]":!0,"[object Int32Array]":!0,"[object Uint32Array]":!0,"[object Float16Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0,"[object BigInt64Array]":!0,"[object BigUint64Array]":!0},p4=Object.prototype.toString,p6=p9();function p9(e={}){let{circular:t=!1,createInternalComparator:n,createState:r,strict:i=!1}=e,s=function({areArrayBuffersEqual:e,areArraysEqual:t,areDataViewsEqual:n,areDatesEqual:r,areErrorsEqual:i,areFunctionsEqual:s,areMapsEqual:o,areNumbersEqual:a,areObjectsEqual:l,arePrimitiveWrappersEqual:c,areRegExpsEqual:d,areSetsEqual:u,areTypedArraysEqual:p,areUrlsEqual:h,unknownTagComparators:f}){return function(m,g,b){if(m===g)return!0;if(null==m||null==g)return!1;let x=typeof m;if(x!==typeof g)return!1;if("object"!==x)return"number"===x?a(m,g,b):"function"===x&&s(m,g,b);let y=m.constructor;if(y!==g.constructor)return!1;if(y===Object)return l(m,g,b);if(Array.isArray(m))return t(m,g,b);if(y===Date)return r(m,g,b);if(y===RegExp)return d(m,g,b);if(y===Map)return o(m,g,b);if(y===Set)return u(m,g,b);let v=p4.call(m);if("[object Date]"===v)return r(m,g,b);if("[object RegExp]"===v)return d(m,g,b);if("[object Map]"===v)return o(m,g,b);if("[object Set]"===v)return u(m,g,b);if("[object Object]"===v)return"function"!=typeof m.then&&"function"!=typeof g.then&&l(m,g,b);if("[object URL]"===v)return h(m,g,b);if("[object Error]"===v)return i(m,g,b);if("[object Arguments]"===v)return l(m,g,b);if(p5[v])return p(m,g,b);if("[object ArrayBuffer]"===v)return e(m,g,b);if("[object DataView]"===v)return n(m,g,b);if("[object Boolean]"===v||"[object Number]"===v||"[object String]"===v)return c(m,g,b);if(f){let e=f[v];if(!e){let t=null!=m?m[Symbol.toStringTag]:void 0;t&&(e=f[t])}if(e)return e(m,g,b)}return!1}}(function({circular:e,createCustomConfig:t,strict:n}){let r={areArrayBuffersEqual:pU,areArraysEqual:n?pX:pV,areDataViewsEqual:pW,areDatesEqual:pq,areErrorsEqual:pK,areFunctionsEqual:pG,areMapsEqual:n?pL(pJ,pX):pJ,areNumbersEqual:pB,areObjectsEqual:n?pX:pZ,arePrimitiveWrappersEqual:pY,areRegExpsEqual:pQ,areSetsEqual:n?pL(p0,pX):p0,areTypedArraysEqual:n?pL(p1,pX):p1,areUrlsEqual:p2,unknownTagComparators:void 0};if(t&&(r=Object.assign({},r,t(r))),e){let e=pP(r.areArraysEqual),t=pP(r.areMapsEqual),n=pP(r.areObjectsEqual),i=pP(r.areSetsEqual);r=Object.assign({},r,{areArraysEqual:e,areMapsEqual:t,areObjectsEqual:n,areSetsEqual:i})}return r}(e)),o=n?n(s):function(e,t,n,r,i,o,a){return s(e,t,a)};return function({circular:e,comparator:t,createState:n,equals:r,strict:i}){if(n)return function(s,o){let{cache:a=e?new WeakMap:void 0,meta:l}=n();return t(s,o,{cache:a,equals:r,meta:l,strict:i})};if(e)return function(e,n){return t(e,n,{cache:new WeakMap,equals:r,meta:void 0,strict:i})};let s={cache:void 0,equals:r,meta:void 0,strict:i};return function(e,n){return t(e,n,s)}}({circular:t,comparator:s,createState:r,equals:o,strict:i})}p9({strict:!0}),p9({circular:!0}),p9({circular:!0,strict:!0}),p9({createInternalComparator:()=>pB}),p9({strict:!0,createInternalComparator:()=>pB}),p9({circular:!0,createInternalComparator:()=>pB}),p9({circular:!0,createInternalComparator:()=>pB,strict:!0});var p7=e.i(383835),p8=({contentComponent:e})=>{let t=(0,cT.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getServerSnapshot);return(0,s.jsx)(s.Fragment,{children:Object.values(t)})},he=class extends cA.default.Component{constructor(e){super(e),this.editorContentRef=cA.default.createRef()}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){var e;let t=this.props.editor;if(t&&!t.isDestroyed&&(null==(e=t.view.dom)?void 0:e.parentNode)){let e,n;if(t.contentComponent)return;let r=this.editorContentRef.current;r.append(...t.view.dom.parentNode.childNodes),t.setOptions({element:r}),e=new Set,n={},t.contentComponent={subscribe:t=>(e.add(t),()=>{e.delete(t)}),getSnapshot:()=>n,getServerSnapshot:()=>n,setRenderer(t,r){n={...n,[t]:tx.default.createPortal(r.reactElement,r.element,t)},e.forEach(e=>e())},removeRenderer(t){let r={...n};delete r[t],n=r,e.forEach(e=>e())}},t.createNodeViews(),t.isEditorContentInitialized=!0,this.forceUpdate()}}componentWillUnmount(){var e;let t=this.props.editor;if(t){t.isEditorContentInitialized=!1,t.isDestroyed||t.view.setProps({nodeViews:{}}),t.contentComponent=null;try{if(!(null==(e=t.view.dom)?void 0:e.parentNode))return;let n=document.createElement("div");n.append(...t.view.dom.parentNode.childNodes),t.setOptions({element:n})}catch{}}}render(){let{editor:e,innerRef:t,...n}=this.props;return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{ref:((...e)=>t=>{e.forEach(e=>{"function"==typeof e?e(t):e&&(e.current=t)})})(t,this.editorContentRef),...n}),(null==e?void 0:e.contentComponent)&&(0,s.jsx)(p8,{contentComponent:e.contentComponent})]})}},ht=(0,cA.forwardRef)((e,t)=>{let n=cA.default.useMemo(()=>Math.floor(0xffffffff*Math.random()).toString(),[e.editor]);return cA.default.createElement(he,{key:n,innerRef:t,...e})}),hn=cA.default.memo(ht),hr="u">typeof window?cA.useLayoutEffect:cA.useEffect,hi=class{constructor(e){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=e,this.lastSnapshot={editor:e,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber||(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber}),this.lastSnapshot}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(e){return this.subscribers.add(e),()=>{this.subscribers.delete(e)}}watch(e){if(this.editor=e,this.editor){let e=()=>{this.transactionNumber+=1,this.subscribers.forEach(e=>e())},t=this.editor;return t.on("transaction",e),()=>{t.off("transaction",e)}}}},hs="u"<typeof window,ho=hs||!!("u">typeof window&&window.next),ha=class e{constructor(e){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId="",this.options=e,this.subscriptions=new Set,this.setEditor(this.getInitialEditor()),this.scheduleDestroy(),this.getEditor=this.getEditor.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.subscribe=this.subscribe.bind(this),this.refreshEditorInstance=this.refreshEditorInstance.bind(this),this.scheduleDestroy=this.scheduleDestroy.bind(this),this.onRender=this.onRender.bind(this),this.createEditor=this.createEditor.bind(this)}setEditor(e){this.editor=e,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach(e=>e())}getInitialEditor(){let e=this.options.current.immediatelyRender,t=null==e||e;return hs?t=!1:ho&&void 0===e&&(t=!1),t?this.createEditor():null}createEditor(){return new pm({...this.options.current,onBeforeCreate:(...e)=>{var t,n;return null==(n=(t=this.options.current).onBeforeCreate)?void 0:n.call(t,...e)},onBlur:(...e)=>{var t,n;return null==(n=(t=this.options.current).onBlur)?void 0:n.call(t,...e)},onCreate:(...e)=>{var t,n;return null==(n=(t=this.options.current).onCreate)?void 0:n.call(t,...e)},onDestroy:(...e)=>{var t,n;return null==(n=(t=this.options.current).onDestroy)?void 0:n.call(t,...e)},onFocus:(...e)=>{var t,n;return null==(n=(t=this.options.current).onFocus)?void 0:n.call(t,...e)},onSelectionUpdate:(...e)=>{var t,n;return null==(n=(t=this.options.current).onSelectionUpdate)?void 0:n.call(t,...e)},onTransaction:(...e)=>{var t,n;return null==(n=(t=this.options.current).onTransaction)?void 0:n.call(t,...e)},onUpdate:(...e)=>{var t,n;return null==(n=(t=this.options.current).onUpdate)?void 0:n.call(t,...e)},onContentError:(...e)=>{var t,n;return null==(n=(t=this.options.current).onContentError)?void 0:n.call(t,...e)},onDrop:(...e)=>{var t,n;return null==(n=(t=this.options.current).onDrop)?void 0:n.call(t,...e)},onPaste:(...e)=>{var t,n;return null==(n=(t=this.options.current).onPaste)?void 0:n.call(t,...e)},onDelete:(...e)=>{var t,n;return null==(n=(t=this.options.current).onDelete)?void 0:n.call(t,...e)}})}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,t){return Object.keys(e).every(n=>!!["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(n)||("extensions"===n&&e.extensions&&t.extensions?e.extensions.length===t.extensions.length&&e.extensions.every((e,n)=>{var r;return e===(null==(r=t.extensions)?void 0:r[n])}):e[n]===t[n]))}onRender(t){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&0===t.length?e.compareOptions(this.options.current,this.editor.options)||this.editor.setOptions({...this.options.current,editable:this.editor.isEditable}):this.refreshEditorInstance(t),()=>{this.isComponentMounted=!1,this.scheduleDestroy()})}refreshEditorInstance(e){if(this.editor&&!this.editor.isDestroyed){if(null===this.previousDeps){this.previousDeps=e;return}if(this.previousDeps.length===e.length&&this.previousDeps.every((t,n)=>t===e[n]))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=e}scheduleDestroy(){let e=this.instanceId,t=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{if(this.isComponentMounted&&this.instanceId===e){t&&t.setOptions(this.options.current);return}t&&!t.isDestroyed&&(t.destroy(),this.instanceId===e&&this.setEditor(null))},1)}},hl=(0,cA.createContext)({editor:null});hl.Consumer;var hc=()=>(0,cA.useContext)(hl),hd=(0,cA.createContext)({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),hu=()=>(0,cA.useContext)(hd);function hp({as:e="div",...t}){let{nodeViewContentRef:n,nodeViewContentChildren:r}=hu();return(0,s.jsx)(e,{...t,ref:n,"data-node-view-content":"",style:{whiteSpace:"pre-wrap",...t.style},children:r})}var hh=cA.default.forwardRef((e,t)=>{let{onDragStart:n}=hu(),r=e.as||"div";return(0,s.jsx)(r,{...e,ref:t,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...e.style}})});function hf(e){return!!("function"==typeof e&&e.prototype&&e.prototype.isReactComponent)}function hm(e){return!!("object"==typeof e&&e.$$typeof&&("Symbol(react.forward_ref)"===e.$$typeof.toString()||"react.forward_ref"===e.$$typeof.description))}var hg=class{constructor(e,{editor:t,props:n={},as:r="div",className:i=""}){this.ref=null,this.destroyed=!1,this.id=Math.floor(0xffffffff*Math.random()).toString(),this.component=e,this.editor=t,this.props=n,this.element=document.createElement(r),this.element.classList.add("react-renderer"),i&&this.element.classList.add(...i.split(" ")),this.editor.isEditorContentInitialized?(0,tx.flushSync)(()=>{this.render()}):queueMicrotask(()=>{this.destroyed||this.render()})}render(){var e;if(this.destroyed)return;let t=this.component,n=this.props,r=this.editor,i=function(){try{if(cA.version)return parseInt(cA.version.split(".")[0],10)>=19}catch{}return!1}(),o=function(e){if(hf(e)||hm(e))return!0;if("object"==typeof e&&e.$$typeof&&("Symbol(react.memo)"===e.$$typeof.toString()||"react.memo"===e.$$typeof.description)){let t=e.type;if(t)return hf(t)||hm(t)}return!1}(t),a={...n};a.ref&&!(i||o)&&delete a.ref,!a.ref&&(i||o)&&(a.ref=e=>{this.ref=e}),this.reactElement=(0,s.jsx)(t,{...a}),null==(e=null==r?void 0:r.contentComponent)||e.setRenderer(this.id,this)}updateProps(e={}){if(this.destroyed)return;let t=!1,n=Object.keys(e);for(let r=0;r<n.length;r+=1){let i=n[r];if(e[i]!==this.props[i]){t=!0;break}}t&&(this.props={...this.props,...e},this.render())}destroy(){var e;this.destroyed=!0;let t=this.editor;null==(e=null==t?void 0:t.contentComponent)||e.removeRenderer(this.id);try{this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element)}catch{}}updateAttributes(e){Object.keys(e).forEach(t=>{this.element.setAttribute(t,e[t])})}};cA.default.createContext({markViewContentRef:()=>{}});var hb=class extends pO{constructor(e,t,n){if(super(e,t,n),this.selectionRafId=null,this.handlePositionUpdate=()=>{let e=this.getPos();"number"==typeof e&&e!==this.currentPos&&(this.currentPos=e,this.renderer.updateProps({getPos:()=>this.getPos()}),"function"==typeof this.options.attrs&&this.updateElementAttributes())},this.cachedExtensionWithSyncedStorage=null,!this.node.isLeaf){this.options.contentDOMElementTag?this.contentDOMElement=document.createElement(this.options.contentDOMElementTag):this.contentDOMElement=document.createElement(this.node.isInline?"span":"div"),this.contentDOMElement.dataset.nodeViewContentReact="",this.contentDOMElement.dataset.nodeViewWrapper="",this.contentDOMElement.style.whiteSpace="inherit";const e=this.dom.querySelector("[data-node-view-content]");if(!e)return;e.appendChild(this.contentDOMElement)}this.options.trackNodeViewPosition&&this.editor.on("update",this.handlePositionUpdate)}get extensionWithSyncedStorage(){if(!this.cachedExtensionWithSyncedStorage){let e=this.editor,t=this.extension;this.cachedExtensionWithSyncedStorage=new Proxy(t,{get(n,r,i){var s;return"storage"===r?null!=(s=e.storage[t.name])?s:{}:Reflect.get(n,r,i)}})}return this.cachedExtensionWithSyncedStorage}mount(){let e={editor:this.editor,node:this.node,decorations:this.decorations,innerDecorations:this.innerDecorations,view:this.view,selected:!1,extension:this.extensionWithSyncedStorage,HTMLAttributes:this.HTMLAttributes,getPos:()=>this.getPos(),updateAttributes:(e={})=>this.updateAttributes(e),deleteNode:()=>this.deleteNode(),ref:(0,cA.createRef)()};if(!this.component.displayName){let e;this.component.displayName=(e=this.extension.name).charAt(0).toUpperCase()+e.substring(1)}let t={onDragStart:this.onDragStart.bind(this),nodeViewContentRef:e=>{e&&this.contentDOMElement&&e.firstChild!==this.contentDOMElement&&(e.hasAttribute("data-node-view-wrapper")&&e.removeAttribute("data-node-view-wrapper"),e.appendChild(this.contentDOMElement))}},n=this.component,r=(0,cA.memo)(e=>(0,s.jsx)(hd.Provider,{value:t,children:(0,cA.createElement)(n,e)}));r.displayName="ReactNodeView";let i=this.node.isInline?"span":"div";this.options.as&&(i=this.options.as);let{className:o=""}=this.options;this.handleSelectionUpdate=this.handleSelectionUpdate.bind(this),this.renderer=new hg(r,{editor:this.editor,props:e,as:i,className:`node-${this.node.type.name} ${o}`.trim()}),this.editor.on("selectionUpdate",this.handleSelectionUpdate),this.updateElementAttributes(),this.currentPos=this.getPos()}get dom(){var e;if(this.renderer.element.firstElementChild&&!(null==(e=this.renderer.element.firstElementChild)?void 0:e.hasAttribute("data-node-view-wrapper")))throw Error("Please use the NodeViewWrapper component for your node view.");return this.renderer.element}get contentDOM(){return this.node.isLeaf?null:this.contentDOMElement}handleSelectionUpdate(){this.selectionRafId&&(cancelAnimationFrame(this.selectionRafId),this.selectionRafId=null),this.selectionRafId=requestAnimationFrame(()=>{this.selectionRafId=null;let e=this.currentPos;if("number"==typeof e)if(function({selection:e,pos:t,nodeSize:n,selectedOnTextSelection:r=!1}){let{from:i,to:s}=e;return!!(i<=t&&s>=t+n||r&&dw(e)&&i>t&&s<t+n)}({selection:this.editor.state.selection,pos:e,nodeSize:this.node.nodeSize,selectedOnTextSelection:this.options.selectedOnTextSelection})){if(this.renderer.props.selected)return;this.selectNode()}else{if(!this.renderer.props.selected)return;this.deselectNode()}})}update(e,t,n){let r=e=>{this.renderer.updateProps(e),"function"==typeof this.options.attrs&&this.updateElementAttributes()};if(e.type!==this.node.type)return!1;if("function"==typeof this.options.update){let i=this.node,s=this.decorations,o=this.innerDecorations;return this.node=e,this.decorations=t,this.innerDecorations=n,this.currentPos=this.getPos(),this.options.update({oldNode:i,oldDecorations:s,newNode:e,newDecorations:t,oldInnerDecorations:o,innerDecorations:n,updateProps:()=>r({node:e,decorations:t,innerDecorations:n,extension:this.extensionWithSyncedStorage})})}if(e===this.node)return this.node=e,this.decorations=t,this.innerDecorations=n,!0;let i=this.getPos();this.node=e,this.decorations=t,this.innerDecorations=n,this.currentPos=i;let s={node:e,decorations:t,innerDecorations:n,extension:this.extensionWithSyncedStorage};return this.options.trackNodeViewPosition&&(s.getPos=()=>this.getPos()),r(s),!0}selectNode(){this.renderer.updateProps({selected:!0}),this.renderer.element.classList.add("ProseMirror-selectednode")}deselectNode(){this.renderer.updateProps({selected:!1}),this.renderer.element.classList.remove("ProseMirror-selectednode")}destroy(){this.renderer.destroy(),this.editor.off("selectionUpdate",this.handleSelectionUpdate),this.options.trackNodeViewPosition&&this.editor.off("update",this.handlePositionUpdate),this.contentDOMElement=null,this.selectionRafId&&(cancelAnimationFrame(this.selectionRafId),this.selectionRafId=null)}updateElementAttributes(){if(this.options.attrs){let e={};if("function"==typeof this.options.attrs){let t=this.editor.extensionManager.attributes,n=ud(this.node,t);e=this.options.attrs({node:this.node,HTMLAttributes:n})}else e=this.options.attrs;this.renderer.updateAttributes(e)}}};function hx(e,t){return n=>n.editor.contentComponent?new hb(e,n,t):{}}var hy=(0,cA.createContext)({get editor(){throw Error("useTiptap must be used within a <Tiptap> provider")}});function hv({editor:e,instance:t,children:n}){let r=null!=e?e:t;if(!r)throw Error("Tiptap: An editor instance is required. Pass a non-null `editor` prop.");let i=(0,cA.useMemo)(()=>({editor:r}),[r]),o=(0,cA.useMemo)(()=>({editor:r}),[r]);return(0,s.jsx)(hl.Provider,{value:o,children:(0,s.jsx)(hy.Provider,{value:i,children:n})})}function hw({...e}){let{editor:t}=(0,cA.useContext)(hy);return(0,s.jsx)(hn,{editor:t,...e})}hy.displayName="TiptapContext",hv.displayName="Tiptap",hw.displayName="Tiptap.Content",Object.assign(hv,{Content:hw});let hk=(0,o.default)("sparkles",[["path",{d:"M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z",key:"4pj2yx"}],["path",{d:"M20 3v4",key:"1olli1"}],["path",{d:"M22 5h-4",key:"1gvqau"}],["path",{d:"M4 17v2",key:"vumght"}],["path",{d:"M5 18H3",key:"zchphs"}]]);var hN=e.i(797715);function hS(e,t){return Array(t+1).join(e)}function hC(e){return e.replace(/^\n*/,"")}function hj(e){for(var t=e.length;t>0&&"\n"===e[t-1];)t--;return e.substring(0,t)}var hE=["ADDRESS","ARTICLE","ASIDE","AUDIO","BLOCKQUOTE","BODY","CANVAS","CENTER","DD","DIR","DIV","DL","DT","FIELDSET","FIGCAPTION","FIGURE","FOOTER","FORM","FRAMESET","H1","H2","H3","H4","H5","H6","HEADER","HGROUP","HR","HTML","ISINDEX","LI","MAIN","MENU","NAV","NOFRAMES","NOSCRIPT","OL","OUTPUT","P","PRE","SECTION","TABLE","TBODY","TD","TFOOT","TH","THEAD","TR","UL"];function hM(e){return h_(e,hE)}var hA=["AREA","BASE","BR","COL","COMMAND","EMBED","HR","IMG","INPUT","KEYGEN","LINK","META","PARAM","SOURCE","TRACK","WBR"];function hT(e){return h_(e,hA)}var hO=["A","TABLE","THEAD","TBODY","TFOOT","TH","TD","IFRAME","SCRIPT","AUDIO","VIDEO"];function h_(e,t){return t.indexOf(e.nodeName)>=0}function hD(e,t){return e.getElementsByTagName&&t.some(function(t){return e.getElementsByTagName(t).length})}var hR=[[/\\/g,"\\\\"],[/\*/g,"\\*"],[/^-/g,"\\-"],[/^\+ /g,"\\+ "],[/^(=+)/g,"\\$1"],[/^(#{1,6}) /g,"\\$1 "],[/`/g,"\\`"],[/^~~~/g,"\\~~~"],[/\[/g,"\\["],[/\]/g,"\\]"],[/^>/g,"\\>"],[/_/g,"\\_"],[/^(\d+)\. /g,"$1\\. "]];function hI(e){return hR.reduce(function(e,t){return e.replace(t[0],t[1])},e)}var hL={};function hP(e){return e?e.replace(/(\n+\s*)+/g,"\n"):""}function hz(e){var t=e.replace(/([<>()])/g,"\\$1");return t.indexOf(" ")>=0?"<"+t+">":t}function h$(e){return e.replace(/"/g,'\\"')}function hB(e){for(var t in this.options=e,this._keep=[],this._remove=[],this.blankRule={replacement:e.blankReplacement},this.keepReplacement=e.keepReplacement,this.defaultRule={replacement:e.defaultReplacement},this.array=[],e.rules)this.array.push(e.rules[t])}function hF(e,t,n){for(var r=0;r<e.length;r++){var i=e[r];if(function(e,t,n){var r=e.filter;if("string"==typeof r){if(r===t.nodeName.toLowerCase())return!0}else if(Array.isArray(r)){if(r.indexOf(t.nodeName.toLowerCase())>-1)return!0}else if("function"==typeof r){if(r.call(e,t,n))return!0}else throw TypeError("`filter` needs to be a string, array, or function")}(i,t,n))return i}}function hH(e){var t=e.nextSibling||e.parentNode;return e.parentNode.removeChild(e),t}function hU(e,t,n){return e&&e.parentNode===t||n(t)?t.nextSibling||t.parentNode:t.firstChild||t.nextSibling||t.parentNode}hL.paragraph={filter:"p",replacement:function(e){return"\n\n"+e+"\n\n"}},hL.lineBreak={filter:"br",replacement:function(e,t,n){return n.br+"\n"}},hL.heading={filter:["h1","h2","h3","h4","h5","h6"],replacement:function(e,t,n){var r=Number(t.nodeName.charAt(1));if("setext"!==n.headingStyle||!(r<3))return"\n\n"+hS("#",r)+" "+e+"\n\n";var i=hS(1===r?"=":"-",e.length);return"\n\n"+e+"\n"+i+"\n\n"}},hL.blockquote={filter:"blockquote",replacement:function(e){return"\n\n"+(e=hj(hC(e)).replace(/^/gm,"> "))+"\n\n"}},hL.list={filter:["ul","ol"],replacement:function(e,t){var n=t.parentNode;return"LI"===n.nodeName&&n.lastElementChild===t?"\n"+e:"\n\n"+e+"\n\n"}},hL.listItem={filter:"li",replacement:function(e,t,n){var r=n.bulletListMarker+" ",i=t.parentNode;if("OL"===i.nodeName){var s=i.getAttribute("start"),o=Array.prototype.indexOf.call(i.children,t);r=(s?Number(s)+o:o+1)+". "}var a=/\n$/.test(e);return e=(e=hj(hC(e))+(a?"\n":"")).replace(/\n/gm,"\n"+" ".repeat(r.length)),r+e+(t.nextSibling?"\n":"")}},hL.indentedCodeBlock={filter:function(e,t){return"indented"===t.codeBlockStyle&&"PRE"===e.nodeName&&e.firstChild&&"CODE"===e.firstChild.nodeName},replacement:function(e,t,n){return"\n\n "+t.firstChild.textContent.replace(/\n/g,"\n ")+"\n\n"}},hL.fencedCodeBlock={filter:function(e,t){return"fenced"===t.codeBlockStyle&&"PRE"===e.nodeName&&e.firstChild&&"CODE"===e.firstChild.nodeName},replacement:function(e,t,n){for(var r,i=((t.firstChild.getAttribute("class")||"").match(/language-(\S+)/)||[null,""])[1],s=t.firstChild.textContent,o=n.fence.charAt(0),a=3,l=RegExp("^"+o+"{3,}","gm");r=l.exec(s);)r[0].length>=a&&(a=r[0].length+1);var c=hS(o,a);return"\n\n"+c+i+"\n"+s.replace(/\n$/,"")+"\n"+c+"\n\n"}},hL.horizontalRule={filter:"hr",replacement:function(e,t,n){return"\n\n"+n.hr+"\n\n"}},hL.inlineLink={filter:function(e,t){return"inlined"===t.linkStyle&&"A"===e.nodeName&&e.getAttribute("href")},replacement:function(e,t){var n=hz(t.getAttribute("href")),r=h$(hP(t.getAttribute("title")));return"["+e+"]("+n+(r?' "'+r+'"':"")+")"}},hL.referenceLink={filter:function(e,t){return"referenced"===t.linkStyle&&"A"===e.nodeName&&e.getAttribute("href")},replacement:function(e,t,n){var r,i,s=hz(t.getAttribute("href")),o=hP(t.getAttribute("title"));switch(o&&(o=' "'+h$(o)+'"'),n.linkReferenceStyle){case"collapsed":r="["+e+"][]",i="["+e+"]: "+s+o;break;case"shortcut":r="["+e+"]",i="["+e+"]: "+s+o;break;default:var a=this.references.length+1;r="["+e+"]["+a+"]",i="["+a+"]: "+s+o}return this.references.push(i),r},references:[],append:function(e){var t="";return this.references.length&&(t="\n\n"+this.references.join("\n")+"\n\n",this.references=[]),t}},hL.emphasis={filter:["em","i"],replacement:function(e,t,n){return e.trim()?n.emDelimiter+e+n.emDelimiter:""}},hL.strong={filter:["strong","b"],replacement:function(e,t,n){return e.trim()?n.strongDelimiter+e+n.strongDelimiter:""}},hL.code={filter:function(e){var t=e.previousSibling||e.nextSibling,n="PRE"===e.parentNode.nodeName&&!t;return"CODE"===e.nodeName&&!n},replacement:function(e){if(!e)return"";e=e.replace(/\r?\n|\r/g," ");for(var t=/^`|^ .*?[^ ].* $|`$/.test(e)?" ":"",n="`",r=e.match(/`+/gm)||[];-1!==r.indexOf(n);)n+="`";return n+t+e+t+n}},hL.image={filter:"img",replacement:function(e,t){var n=hI(hP(t.getAttribute("alt"))),r=hz(t.getAttribute("src")||""),i=hP(t.getAttribute("title")),s=i?' "'+h$(i)+'"':"";return r?"":""}},hB.prototype={add:function(e,t){this.array.unshift(t)},keep:function(e){this._keep.unshift({filter:e,replacement:this.keepReplacement})},remove:function(e){this._remove.unshift({filter:e,replacement:function(){return""}})},forNode:function(e){var t;return e.isBlank?this.blankRule:(t=hF(this.array,e,this.options))||(t=hF(this._keep,e,this.options))||(t=hF(this._remove,e,this.options))?t:this.defaultRule},forEach:function(e){for(var t=0;t<this.array.length;t++)e(this.array[t],t)}};var hV="u">typeof window?window:{},hW=!function(){var e=hV.DOMParser,t=!1;try{new e().parseFromString("","text/html")&&(t=!0)}catch(e){}return t}()?(r=function(){},!function(){var e=!1;try{document.implementation.createHTMLDocument("").open()}catch(t){hV.ActiveXObject&&(e=!0)}return e}()?r.prototype.parseFromString=function(e){var t=document.implementation.createHTMLDocument("");return t.open(),t.write(e),t.close(),t}:r.prototype.parseFromString=function(e){var t=new window.ActiveXObject("htmlfile");return t.designMode="on",t.open(),t.write(e),t.close(),t},r):hV.DOMParser;function hq(e,t){var n;return!function(e){var t=e.element,n=e.isBlock,r=e.isVoid,i=e.isPre||function(e){return"PRE"===e.nodeName};if(!(!t.firstChild||i(t))){for(var s=null,o=!1,a=null,l=hU(null,t,i);l!==t;){if(3===l.nodeType||4===l.nodeType){var c=l.data.replace(/[ \r\n\t]+/g," ");if((!s||/ $/.test(s.data))&&!o&&" "===c[0]&&(c=c.substr(1)),!c){l=hH(l);continue}l.data=c,s=l}else if(1===l.nodeType)n(l)||"BR"===l.nodeName?(s&&(s.data=s.data.replace(/ $/,"")),s=null,o=!1):r(l)||i(l)?(s=null,o=!0):s&&(o=!1);else{l=hH(l);continue}var d=hU(a,l,i);a=l,l=d}s&&(s.data=s.data.replace(/ $/,""),s.data||hH(s))}}({element:n="string"==typeof e?(i=i||new hW).parseFromString('<x-turndown id="turndown-root">'+e+"</x-turndown>","text/html").getElementById("turndown-root"):e.cloneNode(!0),isBlock:hM,isVoid:hT,isPre:t.preformattedCode?hK:null}),n}function hK(e){return"PRE"===e.nodeName||"CODE"===e.nodeName}function hG(e,t){var n;return e.isBlock=hM(e),e.isCode="CODE"===e.nodeName||e.parentNode.isCode,e.isBlank=!hT(n=e)&&!h_(n,hO)&&/^\s*$/i.test(n.textContent)&&!hD(n,hA)&&!hD(n,hO),e.flankingWhitespace=function(e,t){if(e.isBlock||t.preformattedCode&&e.isCode)return{leading:"",trailing:""};var n,r={leading:(n=e.textContent.match(/^(([ \t\r\n]*)(\s*))(?:(?=\S)[\s\S]*\S)?((\s*?)([ \t\r\n]*))$/))[1],leadingAscii:n[2],leadingNonAscii:n[3],trailing:n[4],trailingNonAscii:n[5],trailingAscii:n[6]};return r.leadingAscii&&hJ("left",e,t)&&(r.leading=r.leadingNonAscii),r.trailingAscii&&hJ("right",e,t)&&(r.trailing=r.trailingNonAscii),{leading:r.leading,trailing:r.trailing}}(e,t),e}function hJ(e,t,n){var r,i,s;return"left"===e?(r=t.previousSibling,i=/ $/):(r=t.nextSibling,i=/^ /),r&&(3===r.nodeType?s=i.test(r.nodeValue):n.preformattedCode&&"CODE"===r.nodeName?s=!1:1!==r.nodeType||hM(r)||(s=i.test(r.textContent))),s}var hZ=Array.prototype.reduce;function hX(e){if(!(this instanceof hX))return new hX(e);this.options=function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}({},{rules:hL,headingStyle:"setext",hr:"* * *",bulletListMarker:"*",codeBlockStyle:"indented",fence:"```",emDelimiter:"_",strongDelimiter:"**",linkStyle:"inlined",linkReferenceStyle:"full",br:" ",preformattedCode:!1,blankReplacement:function(e,t){return t.isBlock?"\n\n":""},keepReplacement:function(e,t){return t.isBlock?"\n\n"+t.outerHTML+"\n\n":t.outerHTML},defaultReplacement:function(e,t){return t.isBlock?"\n\n"+e+"\n\n":e}},e),this.rules=new hB(this.options)}function hY(e){var t=this;return hZ.call(e.childNodes,function(e,n){n=new hG(n,t.options);var r="";return 3===n.nodeType?r=n.isCode?n.nodeValue:t.escape(n.nodeValue):1===n.nodeType&&(r=h0.call(t,n)),h1(e,r)},"")}function hQ(e){var t=this;return this.rules.forEach(function(n){"function"==typeof n.append&&(e=h1(e,n.append(t.options)))}),e.replace(/^[\t\r\n]+/,"").replace(/[\t\r\n\s]+$/,"")}function h0(e){var t=this.rules.forNode(e),n=hY.call(this,e),r=e.flankingWhitespace;return(r.leading||r.trailing)&&(n=n.trim()),r.leading+t.replacement(n,e,this.options)+r.trailing}function h1(e,t){var n=hj(e),r=hC(t),i=Math.max(e.length-n.length,t.length-r.length);return n+"\n\n".substring(0,i)+r}hX.prototype={turndown:function(e){var t;if(!(null!=(t=e)&&("string"==typeof t||t.nodeType&&(1===t.nodeType||9===t.nodeType||11===t.nodeType))))throw TypeError(e+" is not a string, or an element/document/fragment node.");return""===e?"":hQ.call(this,hY.call(this,new hq(e,this.options)))},use:function(e){if(Array.isArray(e))for(var t=0;t<e.length;t++)this.use(e[t]);else if("function"==typeof e)e(this);else throw TypeError("plugin must be a Function or an Array of Functions");return this},addRule:function(e,t){return this.rules.add(e,t),this},keep:function(e){return this.rules.keep(e),this},remove:function(e){return this.rules.remove(e),this},escape:function(e){return hI(e)}};var h2=/highlight-(?:text|source)-([a-z0-9]+)/;function h3(e){e.addRule("highlightedCodeBlock",{filter:function(e){var t=e.firstChild;return"DIV"===e.nodeName&&h2.test(e.className)&&t&&"PRE"===t.nodeName},replacement:function(e,t,n){var r=((t.className||"").match(h2)||[null,""])[1];return"\n\n"+n.fence+r+"\n"+t.firstChild.textContent+"\n"+n.fence+"\n\n"}})}function h5(e){e.addRule("strikethrough",{filter:["del","s","strike"],replacement:function(e){return"~"+e+"~"}})}var h4=Array.prototype.indexOf,h6=Array.prototype.every,h9={};function h7(e){var t,n,r=e.parentNode;return"THEAD"===r.nodeName||r.firstChild===e&&("TABLE"===r.nodeName||(n=(t=r).previousSibling,"TBODY"===t.nodeName&&(!n||"THEAD"===n.nodeName&&/^\s*$/i.test(n.textContent))))&&h6.call(e.childNodes,function(e){return"TH"===e.nodeName})}function h8(e,t){var n=h4.call(t.parentNode.childNodes,t),r=" ";return 0===n&&(r="| "),r+e+" |"}function fe(e){for(var t in e.keep(function(e){return"TABLE"===e.nodeName&&!h7(e.rows[0])}),h9)e.addRule(t,h9[t])}function ft(e){e.addRule("taskListItems",{filter:function(e){return"checkbox"===e.type&&"LI"===e.parentNode.nodeName},replacement:function(e,t){return(t.checked?"[x]":"[ ]")+" "}})}h9.tableCell={filter:["th","td"],replacement:function(e,t){return h8(e,t)}},h9.tableRow={filter:"tr",replacement:function(e,t){var n="",r={left:":--",right:"--:",center:":-:"};if(h7(t))for(var i=0;i<t.childNodes.length;i++){var s="---",o=(t.childNodes[i].getAttribute("align")||"").toLowerCase();o&&(s=r[o]||s),n+=h8(s,t.childNodes[i])}return"\n"+e+(n?"\n"+n:"")}},h9.table={filter:function(e){return"TABLE"===e.nodeName&&h7(e.rows[0])},replacement:function(e){return"\n\n"+(e=e.replace("\n\n","\n"))+"\n\n"}},h9.tableSection={filter:["thead","tbody","tfoot"],replacement:function(e){return e}};var fn=e.i(319814);let fr=new hX({headingStyle:"atx",hr:"---",bulletListMarker:"-",codeBlockStyle:"fenced",fence:"```",emDelimiter:"*",strongDelimiter:"**"});for(let e of(fr.use(function(e){e.use([h3,h5,fe,ft])}),fr.addRule("codeBlock",{filter:e=>"PRE"===e.nodeName&&null!==e.firstChild&&"CODE"===e.firstChild.nodeName,replacement:(e,t)=>{let n=t.firstChild,r=n.getAttribute("class")?.replace("language-","")||"",i=n.textContent||"";return`
|
|
103
|
+
\`\`\`${r}
|
|
104
|
+
${i}
|
|
105
|
+
\`\`\`
|
|
106
|
+
`}}),fr.addRule("wikiLink",{filter:e=>"A"===e.nodeName&&"true"===e.getAttribute("data-wiki-link"),replacement:(e,t)=>{let n=t.getAttribute("data-slug")??"",r=t.getAttribute("data-alias"),i=t.getAttribute("data-anchor");return r?`[[${n}|${r}]]`:i?`[[${n}#${i}]]`:`[[${n}]]`}}),fr.addRule("proofSpan",{filter:e=>"PROOF-SPAN"===e.nodeName,replacement:(e,t)=>{let n=[];for(let e of Array.from(t.attributes))n.push(`${e.name}="${e.value.replace(/"/g,""")}"`);return`<proof-span${n.length?" "+n.join(" "):""}>${e}</proof-span>`}}),fr.addRule("styledSpan",{filter:e=>"SPAN"===e.nodeName&&!!e.getAttribute("style"),replacement:(e,t)=>{let n=t.getAttribute("style")??"";return`<span style="${n}">${e}</span>`}}),fr.addRule("lucideIcon",{filter:e=>"SPAN"===e.nodeName&&e.hasAttribute("data-lucide"),replacement:(e,t)=>{let n=t.getAttribute("data-lucide")??"file",r=t.getAttribute("data-color")??"gray";return`<span data-lucide="${n}" data-color="${r}"> </span>`}}),fr.addRule("mark",{filter:"mark",replacement:(e,t)=>{let n=[];for(let e of Array.from(t.attributes))n.push(`${e.name}="${e.value.replace(/"/g,""")}"`);return`<mark${n.length?` ${n.join(" ")}`:""}>${e}</mark>`}}),["u","sub","sup"]))fr.addRule(e,{filter:e,replacement:t=>`<${e}>${t}</${e}>`});function fi(e,t){let n=e.match(/^\/api\/assets\/(.+)$/);if(!n)return e;let r=n[1].replace(/[?#].*$/,"").split("/").map(e=>{try{return decodeURIComponent(e)}catch{return e}}),i=t.lastIndexOf("/"),s=-1===i?[]:t.slice(0,i).split("/"),o=0;for(;o<s.length&&o<r.length&&s[o]===r[o];)o++;let a=s.slice(o).map(()=>"..").concat(r.slice(o)).join("/");return a?a.startsWith(".")?a:`./${a}`:"./"}function fs(e,t){var n;let r=fr.turndown(e);return t?(n=r,t?n=(n=n.replace(/\]\((\/api\/assets\/[^)\s]+)\)/g,(e,n)=>`](${fi(n,t)})`)).replace(/(src|href)="(\/api\/assets\/[^"]+)"/g,(e,n,r)=>`${n}="${fi(r,t)}"`):n):r}fr.addRule("video",{filter:"video",replacement:(e,t)=>{let n=t.getAttribute("src")??"",r=n?(0,fn.detectEmbed)(n):null;if(r&&"video"!==r.provider){let e=r.aspectRatio?` data-aspect-ratio="${r.aspectRatio}"`:"";return`
|
|
107
|
+
<div data-embed="true" data-provider="${r.provider}" data-src="${r.embedUrl}" data-original-url="${r.originalUrl}"${e}><iframe src="${r.embedUrl}" data-embed-provider="${r.provider}" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen" allowfullscreen loading="lazy" frameborder="0"></iframe></div>
|
|
108
|
+
`}let i=[];for(let e of Array.from(t.attributes))i.push(`${e.name}="${e.value.replace(/"/g,""")}"`);return`<video${i.length?` ${i.join(" ")}`:""}></video>`}}),fr.addRule("embedBlock",{filter:e=>"DIV"===e.nodeName&&"true"===e.getAttribute("data-embed"),replacement:(e,t)=>{let n=t.getAttribute("data-provider")??"iframe",r=t.getAttribute("data-src")??"",i=t.getAttribute("data-original-url")??"",s=t.getAttribute("data-aspect-ratio")??"";if("video"===n)return`
|
|
109
|
+
<video src="${r}" controls></video>
|
|
110
|
+
`;let o=['data-embed="true"',`data-provider="${n}"`,`data-src="${r}"`,i?`data-original-url="${i}"`:"",s?`data-aspect-ratio="${s}"`:""].filter(Boolean).join(" ");return`
|
|
111
|
+
<div ${o}><iframe src="${r}" data-embed-provider="${n}" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen" allowfullscreen loading="lazy" frameborder="0"></iframe></div>
|
|
112
|
+
`}}),fr.addRule("twitterEmbed",{filter:e=>"BLOCKQUOTE"===e.nodeName&&e.classList.contains("twitter-tweet"),replacement:(e,t)=>{let n=t.querySelector("a"),r=n?.getAttribute("href")??"";return`
|
|
113
|
+
<blockquote class="twitter-tweet" data-theme="auto"><a href="${r}">${r}</a></blockquote>
|
|
114
|
+
`}}),fr.addRule("sizedImage",{filter:e=>{if("IMG"!==e.nodeName)return!1;let t=e.getAttribute("width")??e.style.width,n=e.getAttribute("data-align");return!!(t||n)},replacement:(e,t)=>{let n=[];for(let e of Array.from(t.attributes))n.push(`${e.name}="${e.value.replace(/"/g,""")}"`);return`<img ${n.join(" ")} />`}}),fr.addRule("resizableImageWrapper",{filter:e=>"DIV"===e.nodeName&&e.classList.contains("resizable-image"),replacement:e=>e}),fr.addRule("inlineMath",{filter:e=>{if("SPAN"!==e.nodeName)return!1;let t=e.getAttribute("data-type");return"inline-math"===t||"inlineMath"===t},replacement:(e,t)=>{let n=t.getAttribute("data-latex")??"";return`$${n}$`}}),fr.addRule("alignedBlock",{filter:e=>{if(!["P","H1","H2","H3","H4","H5","H6"].includes(e.nodeName))return!1;let t=e.getAttribute("style")??"";return/text-align:\s*(center|right|justify)/.test(t)},replacement:(e,t)=>{let n=t.nodeName.toLowerCase(),r=t.getAttribute("style")??"";return`
|
|
115
|
+
<${n} style="${r}">${e}</${n}>
|
|
116
|
+
`}});let fo=/^---\r?\n([\s\S]*?)\r?\n---\r?\n?/;function fa(e){let t=e.trim();if(""===t)return"";if("true"===t)return!0;if("false"===t)return!1;if("null"===t||"~"===t)return null;if(/^-?\d+$/.test(t)||/^-?\d*\.\d+$/.test(t))return Number(t);if(t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'"))return t.slice(1,-1);if(t.startsWith("[")&&t.endsWith("]")){let e=t.slice(1,-1).trim();return""===e?[]:e.split(",").map(e=>fa(e))}return t}let fl=(0,eN.create)((e,t)=>({slugs:new Set,slugDir:new Map,loadedAt:null,loading:!1,load:async()=>{let{loadedAt:n,loading:r}=t();if(!r&&!(null!==n&&Date.now()-n<1e4)){e({loading:!0});try{let t=await (0,tC.wsFetch)("/api/wiki/slugs");if(!t.ok)throw Error("Failed to fetch wiki slugs");let n=await t.json(),r=new Set,i=new Map;for(let e of["entities","concepts","comparisons","root"])for(let t of n[e])r.add(t),i.has(t)||i.set(t,e);e({slugs:r,slugDir:i,loadedAt:Date.now(),loading:!1})}catch{e({loading:!1})}}},has:e=>t().slugs.has(e),getDir:e=>t().slugDir.get(e)??null,invalidate(){e({loadedAt:null})}}));function fc(){return{sidecar:null,snapshotRevision:0,lastEventId:0,snapshotBlocks:[]}}let fd=(0,eN.create)((e,t)=>({byPath:{},loadSidecar:async t=>{let n=encodeURIComponent(t).replace(/%2F/g,"/");try{let r=await (0,tC.wsFetch)(`/api/agent/sidecar/${n}`,{headers:{}});if(!r.ok)return;let i=await r.json();e(e=>({byPath:{...e.byPath,[t]:{...e.byPath[t]??fc(),sidecar:i,snapshotRevision:i.revision,lastEventId:i.nextEventId-1}}}))}catch{}},loadSnapshot:async t=>{let n=encodeURIComponent(t).replace(/%2F/g,"/");try{let r=await (0,tC.wsFetch)(`/api/agent/files/${n}`,{headers:{}});if(!r.ok)return;let i=await r.json();e(e=>({byPath:{...e.byPath,[t]:{...e.byPath[t]??fc(),snapshotBlocks:i.blocks,snapshotRevision:i.revision}}}));let s=tQ.getState();s.currentPath===t&&s.syncRevision(i.revision)}catch{}},pollEvents:async e=>{let n=t().byPath[e]??fc(),r=encodeURIComponent(e).replace(/%2F/g,"/");try{let i=await (0,tC.wsFetch)(`/api/agent/events/${r}?after=${n.lastEventId}`,{headers:{}});if(!i.ok)return;for(let n of(await i.json()).events)t().applyEvent(e,n)}catch{}},applyEvent:(t,n)=>{e(e=>{let r=e.byPath[t]??fc();return{byPath:{...e.byPath,[t]:{...r,lastEventId:Math.max(r.lastEventId,n.id)}}}})},reset:t=>{e(e=>{let n={...e.byPath};return delete n[t],{byPath:n}})}}));var fu=e.i(278928),fp=class{constructor({editor:e,element:t,view:n,pluginKey:r="bubbleMenu",updateDelay:i=250,resizeDelay:s=60,shouldShow:o,appendTo:a,getReferencedVirtualElement:l,options:c}){var d;this.preventHide=!1,this.isVisible=!1,this.scrollTarget=window,this.floatingUIOptions={strategy:"absolute",placement:"top",offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1,onShow:void 0,onHide:void 0,onUpdate:void 0,onDestroy:void 0},this.shouldShow=({view:e,state:t,from:n,to:r})=>{let{doc:i,selection:s}=t,{empty:o}=s,a=!i.textBetween(n,r).length&&dw(t.selection),l=this.element.contains(document.activeElement);return!!(e.hasFocus()||l)&&!o&&!a&&!!this.editor.isEditable},this.mousedownHandler=()=>{this.preventHide=!0},this.dragstartHandler=()=>{this.hide()},this.resizeHandler=()=>{this.resizeDebounceTimer&&clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=window.setTimeout(()=>{this.updatePosition()},this.resizeDelay)},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:e})=>{var t;if(this.editor.isDestroyed)return void this.destroy();if(this.preventHide){this.preventHide=!1;return}(null==e?void 0:e.relatedTarget)&&(null==(t=this.element.parentNode)?void 0:t.contains(e.relatedTarget))||(null==e?void 0:e.relatedTarget)!==this.editor.view.dom&&this.hide()},this.handleDebouncedUpdate=(e,t)=>{let n=!(null==t?void 0:t.selection.eq(e.state.selection)),r=!(null==t?void 0:t.doc.eq(e.state.doc));(n||r)&&(this.updateDebounceTimer&&clearTimeout(this.updateDebounceTimer),this.updateDebounceTimer=window.setTimeout(()=>{this.updateHandler(e,n,r,t)},this.updateDelay))},this.updateHandler=(e,t,n,r)=>{let{composing:i}=e;!i&&(t||n)&&(this.getShouldShow(r)?(this.show(),this.updatePosition()):this.hide())},this.transactionHandler=({transaction:e})=>{let t=e.getMeta(this.pluginKey);"updatePosition"===t?this.updatePosition():t&&"object"==typeof t&&"updateOptions"===t.type?this.updateOptions(t.options):"hide"===t?this.hide():"show"===t&&(this.updatePosition(),this.show())},this.editor=e,this.element=t,this.view=n,this.pluginKey=r,this.updateDelay=i,this.resizeDelay=s,this.appendTo=a,this.scrollTarget=null!=(d=null==c?void 0:c.scrollTarget)?d:window,this.getReferencedVirtualElement=l,this.floatingUIOptions={...this.floatingUIOptions,...c},this.element.tabIndex=0,o&&(this.shouldShow=o),this.element.addEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.addEventListener("dragstart",this.dragstartHandler),this.editor.on("focus",this.focusHandler),this.editor.on("blur",this.blurHandler),this.editor.on("transaction",this.transactionHandler),window.addEventListener("resize",this.resizeHandler),this.scrollTarget.addEventListener("scroll",this.resizeHandler),this.update(n,n.state),this.getShouldShow()&&(this.show(),this.updatePosition())}get middlewares(){let e=[];return this.floatingUIOptions.flip&&e.push((0,fu.flip)("boolean"!=typeof this.floatingUIOptions.flip?this.floatingUIOptions.flip:void 0)),this.floatingUIOptions.shift&&e.push((0,fu.shift)("boolean"!=typeof this.floatingUIOptions.shift?this.floatingUIOptions.shift:void 0)),this.floatingUIOptions.offset&&e.push((0,fu.offset)("boolean"!=typeof this.floatingUIOptions.offset?this.floatingUIOptions.offset:void 0)),this.floatingUIOptions.arrow&&e.push((0,fu.arrow)(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&e.push((0,fu.size)("boolean"!=typeof this.floatingUIOptions.size?this.floatingUIOptions.size:void 0)),this.floatingUIOptions.autoPlacement&&e.push((0,fu.autoPlacement)("boolean"!=typeof this.floatingUIOptions.autoPlacement?this.floatingUIOptions.autoPlacement:void 0)),this.floatingUIOptions.hide&&e.push((0,fu.hide)("boolean"!=typeof this.floatingUIOptions.hide?this.floatingUIOptions.hide:void 0)),this.floatingUIOptions.inline&&e.push((0,fu.inline)("boolean"!=typeof this.floatingUIOptions.inline?this.floatingUIOptions.inline:void 0)),e}get virtualElement(){var e,t,n,r,i;let{selection:s}=this.editor.state,o=null==(e=this.getReferencedVirtualElement)?void 0:e.call(this);if(o)return o;if(!(null==(n=null==(t=this.view)?void 0:t.dom)?void 0:n.parentNode))return;let a=u_(this.view,s.from,s.to),l={getBoundingClientRect:()=>a,getClientRects:()=>[a]};if(s instanceof sB){let e=this.view.nodeDOM(s.from),t=e.dataset.nodeViewWrapper?e:e.querySelector("[data-node-view-wrapper]");t&&(e=t),e&&(l={getBoundingClientRect:()=>e.getBoundingClientRect(),getClientRects:()=>[e.getBoundingClientRect()]})}if(s instanceof lq){let e,t,n,{$anchorCell:o,$headCell:a}=s,c=o?o.pos:a.pos,d=a?a.pos:o.pos,u=this.view.nodeDOM(c),p=this.view.nodeDOM(d);if(!u||!p)return;let h=u===p?u.getBoundingClientRect():(r=u.getBoundingClientRect(),i=p.getBoundingClientRect(),e=Math.min(r.top,i.top),t=Math.max(r.bottom,i.bottom),n=Math.min(r.left,i.left),new DOMRect(n,e,Math.max(r.right,i.right)-n,t-e));l={getBoundingClientRect:()=>h,getClientRects:()=>[h]}}return l}updatePosition(){if(!this.isVisible)return;let e=this.virtualElement;e&&(0,fu.computePosition)(e,this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:e,y:t,strategy:n,middlewareData:r})=>{var i,s;if(this.isVisible&&!this.editor.isDestroyed&&this.element.isConnected){if((null==(i=r.hide)?void 0:i.referenceHidden)||(null==(s=r.hide)?void 0:s.escaped)){this.element.style.visibility="hidden";return}this.element.style.visibility="visible",this.element.style.width="max-content",this.element.style.position=n,this.element.style.left=`${e}px`,this.element.style.top=`${t}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()}})}update(e,t){let{state:n}=e,r=n.selection.from!==n.selection.to;if(this.updateDelay>0&&r)return void this.handleDebouncedUpdate(e,t);let i=!(null==t?void 0:t.selection.eq(e.state.selection)),s=!(null==t?void 0:t.doc.eq(e.state.doc));this.updateHandler(e,i,s,t)}getShouldShow(e){var t;let{state:n}=this.view,{selection:r}=n,{ranges:i}=r,s=Math.min(...i.map(e=>e.$from.pos)),o=Math.max(...i.map(e=>e.$to.pos));return(null==(t=this.shouldShow)?void 0:t.call(this,{editor:this.editor,element:this.element,view:this.view,state:n,oldState:e,from:s,to:o}))||!1}show(){var e;if(this.isVisible)return;this.element.style.visibility="visible",this.element.style.opacity="1";let t="function"==typeof this.appendTo?this.appendTo():this.appendTo;null==(e=null!=t?t:this.view.dom.parentElement)||e.appendChild(this.element),this.floatingUIOptions.onShow&&this.floatingUIOptions.onShow(),this.isVisible=!0}hide(){this.isVisible&&(this.element.style.visibility="hidden",this.element.style.opacity="0",this.element.remove(),this.floatingUIOptions.onHide&&this.floatingUIOptions.onHide(),this.isVisible=!1)}updateOptions(e){var t;if(void 0!==e.updateDelay&&(this.updateDelay=e.updateDelay),void 0!==e.resizeDelay&&(this.resizeDelay=e.resizeDelay),void 0!==e.appendTo&&(this.appendTo=e.appendTo),void 0!==e.getReferencedVirtualElement&&(this.getReferencedVirtualElement=e.getReferencedVirtualElement),void 0!==e.shouldShow&&e.shouldShow&&(this.shouldShow=e.shouldShow),void 0!==e.options){let n=null!=(t=e.options.scrollTarget)?t:window;n!==this.scrollTarget&&(this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.scrollTarget=n,this.scrollTarget.addEventListener("scroll",this.resizeHandler)),this.floatingUIOptions={...this.floatingUIOptions,...e.options}}}destroy(){this.hide(),this.element.removeEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.removeEventListener("dragstart",this.dragstartHandler),window.removeEventListener("resize",this.resizeHandler),this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.editor.off("focus",this.focusHandler),this.editor.off("blur",this.blurHandler),this.editor.off("transaction",this.transactionHandler),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}},fh=e=>new sY({key:"string"==typeof e.pluginKey?new s1(e.pluginKey):e.pluginKey,view:t=>new fp({view:t,...e})});pt.create({name:"bubbleMenu",addOptions:()=>({element:null,pluginKey:"bubbleMenu",updateDelay:void 0,appendTo:void 0,shouldShow:null}),addProseMirrorPlugins(){return this.options.element?[fh({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,updateDelay:this.options.updateDelay,options:this.options.options,appendTo:this.options.appendTo,getReferencedVirtualElement:this.options.getReferencedVirtualElement,shouldShow:this.options.shouldShow})]:[]}});var ff=class{constructor({editor:e,element:t,view:n,pluginKey:r="floatingMenu",updateDelay:i=250,resizeDelay:s=60,options:o,appendTo:a,shouldShow:l}){var c;this.preventHide=!1,this.isVisible=!1,this.scrollTarget=window,this.shouldShow=({view:e,state:t})=>{let{selection:n}=t,{$anchor:r,empty:i}=n,s=1===r.depth,o=r.parent.isTextblock&&!r.parent.type.spec.code&&!r.parent.textContent&&0===r.parent.childCount&&!this.getTextContent(r.parent);return!!e.hasFocus()&&!!i&&!!s&&!!o&&!!this.editor.isEditable},this.floatingUIOptions={strategy:"absolute",placement:"right",offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1},this.updateHandler=(e,t,n,r)=>{let{composing:i}=e;!i&&(t||n)&&(this.getShouldShow(r)?(this.updatePosition(),this.show()):this.hide())},this.mousedownHandler=()=>{this.preventHide=!0},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:e})=>{var t;if(this.preventHide){this.preventHide=!1;return}(null==e?void 0:e.relatedTarget)&&(null==(t=this.element.parentNode)?void 0:t.contains(e.relatedTarget))||(null==e?void 0:e.relatedTarget)!==this.editor.view.dom&&this.hide()},this.transactionHandler=({transaction:e})=>{let t=e.getMeta(this.pluginKey);"updatePosition"===t?this.updatePosition():t&&"object"==typeof t&&"updateOptions"===t.type?this.updateOptions(t.options):"hide"===t?this.hide():"show"===t&&(this.updatePosition(),this.show())},this.resizeHandler=()=>{this.resizeDebounceTimer&&clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=window.setTimeout(()=>{this.updatePosition()},this.resizeDelay)},this.editor=e,this.element=t,this.view=n,this.pluginKey=r,this.updateDelay=i,this.resizeDelay=s,this.appendTo=a,this.scrollTarget=null!=(c=null==o?void 0:o.scrollTarget)?c:window,this.floatingUIOptions={...this.floatingUIOptions,...o},this.element.tabIndex=0,l&&(this.shouldShow=l),this.element.addEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.editor.on("focus",this.focusHandler),this.editor.on("blur",this.blurHandler),this.editor.on("transaction",this.transactionHandler),window.addEventListener("resize",this.resizeHandler),this.scrollTarget.addEventListener("scroll",this.resizeHandler),this.update(n,n.state),this.getShouldShow()&&(this.show(),this.updatePosition())}getTextContent(e){return ub(e,{textSerializers:ux(this.editor.schema)})}get middlewares(){let e=[];return this.floatingUIOptions.flip&&e.push((0,fu.flip)("boolean"!=typeof this.floatingUIOptions.flip?this.floatingUIOptions.flip:void 0)),this.floatingUIOptions.shift&&e.push((0,fu.shift)("boolean"!=typeof this.floatingUIOptions.shift?this.floatingUIOptions.shift:void 0)),this.floatingUIOptions.offset&&e.push((0,fu.offset)("boolean"!=typeof this.floatingUIOptions.offset?this.floatingUIOptions.offset:void 0)),this.floatingUIOptions.arrow&&e.push((0,fu.arrow)(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&e.push((0,fu.size)("boolean"!=typeof this.floatingUIOptions.size?this.floatingUIOptions.size:void 0)),this.floatingUIOptions.autoPlacement&&e.push((0,fu.autoPlacement)("boolean"!=typeof this.floatingUIOptions.autoPlacement?this.floatingUIOptions.autoPlacement:void 0)),this.floatingUIOptions.hide&&e.push((0,fu.hide)("boolean"!=typeof this.floatingUIOptions.hide?this.floatingUIOptions.hide:void 0)),this.floatingUIOptions.inline&&e.push((0,fu.inline)("boolean"!=typeof this.floatingUIOptions.inline?this.floatingUIOptions.inline:void 0)),e}getShouldShow(e){var t;let{state:n}=this.view,{selection:r}=n,{ranges:i}=r,s=Math.min(...i.map(e=>e.$from.pos)),o=Math.max(...i.map(e=>e.$to.pos));return null==(t=this.shouldShow)?void 0:t.call(this,{editor:this.editor,view:this.view,state:n,oldState:e,from:s,to:o})}updateOptions(e){var t;if(void 0!==e.updateDelay&&(this.updateDelay=e.updateDelay),void 0!==e.resizeDelay&&(this.resizeDelay=e.resizeDelay),void 0!==e.appendTo&&(this.appendTo=e.appendTo),void 0!==e.shouldShow&&e.shouldShow&&(this.shouldShow=e.shouldShow),void 0!==e.options){let n=null!=(t=e.options.scrollTarget)?t:window;n!==this.scrollTarget&&(this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.scrollTarget=n,this.scrollTarget.addEventListener("scroll",this.resizeHandler)),this.floatingUIOptions={...this.floatingUIOptions,...e.options}}}updatePosition(){var e,t;if(!(null==(t=null==(e=this.view)?void 0:e.dom)?void 0:t.parentNode))return;let{selection:n}=this.editor.state,r=u_(this.view,n.from,n.to);(0,fu.computePosition)({getBoundingClientRect:()=>r,getClientRects:()=>[r]},this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:e,y:t,strategy:n,middlewareData:r})=>{var i,s;if((null==(i=r.hide)?void 0:i.referenceHidden)||(null==(s=r.hide)?void 0:s.escaped)){this.element.style.visibility="hidden";return}this.element.style.visibility="visible",this.element.style.width="max-content",this.element.style.position=n,this.element.style.left=`${e}px`,this.element.style.top=`${t}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()})}update(e,t){let n=!(null==t?void 0:t.selection.eq(e.state.selection)),r=!(null==t?void 0:t.doc.eq(e.state.doc));this.updateHandler(e,n,r,t)}show(){var e;if(this.isVisible)return;this.element.style.visibility="visible",this.element.style.opacity="1";let t="function"==typeof this.appendTo?this.appendTo():this.appendTo;null==(e=null!=t?t:this.view.dom.parentElement)||e.appendChild(this.element),this.floatingUIOptions.onShow&&this.floatingUIOptions.onShow(),this.isVisible=!0}hide(){this.isVisible&&(this.element.style.visibility="hidden",this.element.style.opacity="0",this.element.remove(),this.floatingUIOptions.onHide&&this.floatingUIOptions.onHide(),this.isVisible=!1)}destroy(){this.hide(),this.element.removeEventListener("mousedown",this.mousedownHandler,{capture:!0}),window.removeEventListener("resize",this.resizeHandler),this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.editor.off("focus",this.focusHandler),this.editor.off("blur",this.blurHandler),this.editor.off("transaction",this.transactionHandler),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}},fm=e=>new sY({key:"string"==typeof e.pluginKey?new s1(e.pluginKey):e.pluginKey,view:t=>new ff({view:t,...e})});function fg(e,t){return null!=e?e:new s1(t)}pt.create({name:"floatingMenu",addOptions:()=>({element:null,options:{},pluginKey:"floatingMenu",updateDelay:void 0,resizeDelay:void 0,appendTo:void 0,shouldShow:null}),addCommands(){return{updateFloatingMenuPosition:()=>({tr:e,dispatch:t})=>(t&&e.setMeta(this.options.pluginKey,"updatePosition"),!0)}},addProseMirrorPlugins(){return this.options.element?[fm({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,updateDelay:this.options.updateDelay,resizeDelay:this.options.resizeDelay,options:this.options.options,appendTo:this.options.appendTo,shouldShow:this.options.shouldShow})]:[]}});var fb="u">typeof window?f.useLayoutEffect:f.useEffect,fx=new Set(["left","opacity","position","top","visibility","width"]),fy=new Set(["animationIterationCount","aspectRatio","borderImageOutset","borderImageSlice","borderImageWidth","columnCount","columns","fillOpacity","flex","flexGrow","flexShrink","fontWeight","gridArea","gridColumn","gridColumnEnd","gridColumnStart","gridRow","gridRowEnd","gridRowStart","lineClamp","lineHeight","opacity","order","orphans","scale","stopOpacity","strokeDasharray","strokeDashoffset","strokeMiterlimit","strokeOpacity","strokeWidth","tabSize","widows","zIndex","zoom"]),fv=new Set(["children","className","style"]),fw=new Set(["tabIndex"]),fk=new Set(["accessKey","autoCapitalize","contentEditable","contextMenu","dir","draggable","enterKeyHint","hidden","id","lang","nonce","role","slot","spellCheck","tabIndex","title","translate"]),fN={Blur:"focusout",DoubleClick:"dblclick",Focus:"focusin",MouseEnter:"mouseenter",MouseLeave:"mouseleave"};function fS(e,t){return/^on[A-Z]/.test(e)&&"function"==typeof t}function fC(e){return e.startsWith("--")?e:e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}function fj(e,t,n){if("tabIndex"===t){e.tabIndex=Number(n);return}e[t]=n}function fE(e,t){let n=(0,f.useRef)({}),r=(0,f.useRef)([]);fb(()=>{var i,s,o;let a,l,c,d=n.current;return!function(e,t,n){if(t!==n){if(n){e.className=n;return}e.removeAttribute("class")}}(e,d.className,t.className),i=d.style,s=t.style,a=null!=i?i:{},l=null!=s?s:{},new Set([...Object.keys(a),...Object.keys(l)]).forEach(t=>{let n=a[t],r=l[t];if(n!==r){if(null==r)return void(!fx.has(t)&&e.style.removeProperty(fC(t)));fx.has(t)||e.style.setProperty(fC(t),"number"!=typeof r||0===r||t.startsWith("--")||fy.has(t)?String(r):`${r}px`)}}),new Set([...Object.keys(d),...Object.keys(t)]).forEach(n=>{if(fv.has(n)||!(n.startsWith("aria-")||n.startsWith("data-")||fk.has(n))||fS(n,d[n])||fS(n,t[n]))return;let r=d[n],i=t[n];if(r===i)return;let s=(n.startsWith("aria-")||n.startsWith("data-"),n);if(null==i||!1===i){fw.has(n)&&function(e,t){if("tabIndex"===t)return e.removeAttribute("tabindex");let n=e[t];if("boolean"==typeof n){e[t]=!1;return}if("number"==typeof n){e[t]=0;return}e[t]=""}(e,n),e.removeAttribute(s);return}if(!0===i){fw.has(n)&&fj(e,n,!0),e.setAttribute(s,"");return}fw.has(n)?fj(e,n,i):e.setAttribute(s,String(i))}),o=r.current,o.forEach(({eventName:t,listener:n,options:r})=>{e.removeEventListener(t,n,r)}),c=[],Object.entries(t).forEach(([t,n])=>{var r;let i,s;if(!fS(t,n))return;let{eventName:o,options:a}={eventName:null!=(r=fN[s=((i=t.endsWith("Capture"))?t.slice(0,-7):t).slice(2)])?r:s.toLowerCase(),options:i?{capture:!0}:void 0},l=t=>{let r,i,s;n((r=t.defaultPrevented,i=!1,Object.defineProperties(s=Object.create(t),{nativeEvent:{value:t},currentTarget:{value:e},target:{value:t.target},persist:{value:()=>void 0},isDefaultPrevented:{value:()=>r},isPropagationStopped:{value:()=>i},preventDefault:{value:()=>{r=!0,t.preventDefault()}},stopPropagation:{value:()=>{i=!0,t.stopPropagation()}}}),s))};e.addEventListener(o,l,a),c.push({eventName:o,listener:l,options:a})}),r.current=c,n.current=t,()=>{r.current.forEach(({eventName:t,listener:n,options:r})=>{e.removeEventListener(t,n,r)}),r.current=[]}},[e,t])}var fM=f.default.forwardRef(({pluginKey:e,editor:t,updateDelay:n,resizeDelay:r,appendTo:i,shouldShow:s=null,getReferencedVirtualElement:o,options:a,children:l,...c},d)=>{let u=(0,f.useRef)(document.createElement("div")),p=(0,f.useRef)(fg(e,"bubbleMenu")).current;fE(u.current,c),"function"==typeof d?d(u.current):d&&(d.current=u.current);let{editor:h}=hc(),m=t||h,g={updateDelay:n,resizeDelay:r,appendTo:i,pluginKey:p,shouldShow:s,getReferencedVirtualElement:o,options:a},b=(0,f.useRef)(g);b.current=g;let[x,y]=(0,f.useState)(!1),v=(0,f.useRef)(!0);return(0,f.useEffect)(()=>{if(null==m?void 0:m.isDestroyed)return;if(!m)return void console.warn("BubbleMenu component is not rendered inside of an editor component or does not have editor prop.");let e=u.current;e.style.visibility="hidden",e.style.position="absolute";let t=fh({...b.current,editor:m,element:e});m.registerPlugin(t);let n=b.current.pluginKey;return v.current=!0,y(!0),()=>{y(!1),m.unregisterPlugin(n),window.requestAnimationFrame(()=>{e.parentNode&&e.parentNode.removeChild(e)})}},[m]),(0,f.useEffect)(()=>{if(x&&m&&!m.isDestroyed){if(v.current){v.current=!1;return}m.view.dispatch(m.state.tr.setMeta(p,{type:"updateOptions",options:b.current}))}},[x,m,n,r,s,a,i,o,p]),(0,tx.createPortal)(l,u.current)});f.default.forwardRef(({pluginKey:e,editor:t,updateDelay:n,resizeDelay:r,appendTo:i,shouldShow:s=null,options:o,children:a,...l},c)=>{let d=(0,f.useRef)(document.createElement("div")),u=(0,f.useRef)(fg(e,"floatingMenu")).current;fE(d.current,l),"function"==typeof c?c(d.current):c&&(c.current=d.current);let{editor:p}=hc(),h=t||p,m={updateDelay:n,resizeDelay:r,appendTo:i,pluginKey:u,shouldShow:s,options:o},g=(0,f.useRef)(m);g.current=m;let[b,x]=(0,f.useState)(!1),y=(0,f.useRef)(!0);return(0,f.useEffect)(()=>{if(null==h?void 0:h.isDestroyed)return;if(!h)return void console.warn("FloatingMenu component is not rendered inside of an editor component or does not have editor prop.");let e=d.current;e.style.visibility="hidden",e.style.position="absolute";let t=fm({...g.current,editor:h,element:e});h.registerPlugin(t);let n=g.current.pluginKey;return y.current=!0,x(!0),()=>{x(!1),h.unregisterPlugin(n),window.requestAnimationFrame(()=>{e.parentNode&&e.parentNode.removeChild(e)})}},[h]),(0,f.useEffect)(()=>{if(b&&h&&!h.isDestroyed){if(y.current){y.current=!1;return}h.view.dispatch(h.state.tr.setMeta(u,{type:"updateOptions",options:g.current}))}},[b,h,n,r,s,o,i,u]),(0,tx.createPortal)(a,d.current)});var fA=e.i(792934);let fT=(0,o.default)("align-left",[["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 18H3",key:"1amg6g"}],["path",{d:"M21 6H3",key:"1jwq7v"}]]),fO=(0,o.default)("align-right",[["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M21 18H7",key:"1ygte8"}],["path",{d:"M21 6H3",key:"1jwq7v"}]]),f_=(0,o.default)("bold",[["path",{d:"M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8",key:"mg9rjx"}]]),fD=(0,o.default)("code",[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]]),fR=(0,o.default)("italic",[["line",{x1:"19",x2:"10",y1:"4",y2:"4",key:"15jd3p"}],["line",{x1:"14",x2:"5",y1:"20",y2:"20",key:"bu0au3"}],["line",{x1:"15",x2:"9",y1:"4",y2:"20",key:"uljnxc"}]]),fI=(0,o.default)("message-circle",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}]]),fL=(0,o.default)("message-square-plus",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"M12 7v6",key:"lw1j43"}],["path",{d:"M9 10h6",key:"9gxzsh"}]]),fP=(0,o.default)("strikethrough",[["path",{d:"M16 4H9a3 3 0 0 0-2.83 4",key:"43sutm"}],["path",{d:"M14 12a4 4 0 0 1 0 8H6",key:"nlfj13"}],["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}]]),fz=(0,o.default)("subscript",[["path",{d:"m4 5 8 8",key:"1eunvl"}],["path",{d:"m12 5-8 8",key:"1ah0jp"}],["path",{d:"M20 19h-4c0-1.5.44-2 1.5-2.5S20 15.33 20 14c0-.47-.17-.93-.48-1.29a2.11 2.11 0 0 0-2.62-.44c-.42.24-.74.62-.9 1.07",key:"e8ta8j"}]]),f$=(0,o.default)("superscript",[["path",{d:"m4 19 8-8",key:"hr47gm"}],["path",{d:"m12 19-8-8",key:"1dhhmo"}],["path",{d:"M20 12h-4c0-1.5.442-2 1.5-2.5S20 8.334 20 7.002c0-.472-.17-.93-.484-1.29a2.105 2.105 0 0 0-2.617-.436c-.42.239-.738.614-.899 1.06",key:"1dfcux"}]]),fB=(0,o.default)("underline",[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]]);function fF({anchor:e,initialUrl:t="",onCancel:n,onApply:r,onRemove:i}){let[o,a]=(0,f.useState)(t);(0,f.useEffect)(()=>{let e=e=>{"Escape"===e.key&&n()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[n]);let l=()=>{let e=o.trim();e?r(e):n()};return(0,s.jsxs)("div",{className:"absolute z-50 w-[340px] bg-popover border border-border rounded-lg shadow-xl overflow-hidden",style:{top:e.top,left:e.left},onMouseDown:e=>e.stopPropagation(),children:[(0,s.jsxs)("div",{className:"flex items-center justify-between px-3 py-2 border-b border-border",children:[(0,s.jsxs)("div",{className:"flex items-center gap-1.5 text-[12px] font-medium",children:[(0,s.jsx)(t8,{className:"w-3.5 h-3.5"}),t?"Edit link":"Add link"]}),(0,s.jsx)("button",{type:"button",onClick:n,className:"text-[11px] text-muted-foreground hover:text-foreground",children:"Cancel"})]}),(0,s.jsxs)("div",{className:"p-3 space-y-2",children:[(0,s.jsx)("input",{type:"url",autoFocus:!0,value:o,placeholder:"https://example.com",onChange:e=>a(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),l())},className:"w-full bg-background border border-border rounded-md px-2.5 py-1.5 text-[12px] focus:outline-none focus:ring-2 focus:ring-primary/30"}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("button",{type:"button",onClick:l,disabled:!o.trim(),className:"flex-1 py-1.5 text-[12px] rounded-md bg-primary text-primary-foreground disabled:opacity-50 hover:bg-primary/90",children:t?"Update":"Add link"}),t&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("a",{href:t,target:"_blank",rel:"noreferrer noopener",className:"p-1.5 rounded-md border border-border hover:bg-accent text-muted-foreground hover:text-foreground",title:"Open link",children:(0,s.jsx)(tM.ExternalLink,{className:"w-3.5 h-3.5"})}),i&&(0,s.jsx)("button",{type:"button",onClick:i,className:"p-1.5 rounded-md border border-border hover:bg-accent text-destructive",title:"Remove link",children:(0,s.jsx)(tr,{className:"w-3.5 h-3.5"})})]})]})]})]})}function fH({editor:e,onSuggestEdit:t,onComment:n,readOnly:r}){let[i,o]=(0,f.useState)(null);if((0,f.useEffect)(()=>{if(!i)return;let e=e=>{let t=e.target;t?.closest("[data-bubble-popover='true']")||o(null)},t=window.setTimeout(()=>window.addEventListener("mousedown",e),10);return()=>{window.clearTimeout(t),window.removeEventListener("mousedown",e)}},[i]),!e)return null;let a=e=>(0,eh.cn)("h-9 w-9 sm:h-7 sm:w-7 flex items-center justify-center rounded hover:bg-accent text-foreground/80 transition-colors",e&&"bg-accent text-foreground"),l=()=>{let{from:t,to:n}=e.state.selection;return{from:t,to:n}},c=t=>e.chain().focus().setTextSelection(t).run(),d=e=>t=>{t.preventDefault(),e()},u=t=>{i?.type==="align"&&(c(i.range),e.chain().focus().setTextAlign(t).run(),o(null))};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(fM,{editor:e,options:{placement:"top",offset:8},className:"flex items-center gap-0.5 px-1 py-1 bg-popover border border-border rounded-sm shadow-lg",children:[!r&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("button",{type:"button",className:a(e.isActive("bold")),onMouseDown:e=>e.preventDefault(),onClick:d(()=>e.chain().focus().toggleBold().run()),"aria-label":"Bold",children:(0,s.jsx)(f_,{className:"w-3.5 h-3.5"})}),(0,s.jsx)("button",{type:"button",className:a(e.isActive("italic")),onMouseDown:e=>e.preventDefault(),onClick:d(()=>e.chain().focus().toggleItalic().run()),"aria-label":"Italic",children:(0,s.jsx)(fR,{className:"w-3.5 h-3.5"})}),(0,s.jsx)("button",{type:"button",className:a(e.isActive("underline")),onMouseDown:e=>e.preventDefault(),onClick:d(()=>e.chain().focus().toggleUnderline().run()),"aria-label":"Underline",children:(0,s.jsx)(fB,{className:"w-3.5 h-3.5"})}),(0,s.jsx)("button",{type:"button",className:a(e.isActive("strike")),onMouseDown:e=>e.preventDefault(),onClick:d(()=>e.chain().focus().toggleStrike().run()),"aria-label":"Strikethrough",children:(0,s.jsx)(fP,{className:"w-3.5 h-3.5"})}),(0,s.jsx)("button",{type:"button",className:a(e.isActive("code")),onMouseDown:e=>e.preventDefault(),onClick:d(()=>e.chain().focus().toggleCode().run()),"aria-label":"Inline code",children:(0,s.jsx)(fD,{className:"w-3.5 h-3.5"})}),(0,s.jsx)("div",{className:"w-px h-5 bg-border mx-1"}),(0,s.jsx)("button",{type:"button",className:a(e.isActive("superscript")),onMouseDown:e=>e.preventDefault(),onClick:d(()=>e.chain().focus().toggleSuperscript().run()),"aria-label":"Superscript",children:(0,s.jsx)(f$,{className:"w-3.5 h-3.5"})}),(0,s.jsx)("button",{type:"button",className:a(e.isActive("subscript")),onMouseDown:e=>e.preventDefault(),onClick:d(()=>e.chain().focus().toggleSubscript().run()),"aria-label":"Subscript",children:(0,s.jsx)(fz,{className:"w-3.5 h-3.5"})}),(0,s.jsx)("div",{className:"w-px h-5 bg-border mx-1"}),(0,s.jsx)("button",{type:"button",className:a(e.isActive("link")),onMouseDown:e=>e.preventDefault(),onClick:t=>{t.preventDefault();let n=e.getAttributes("link")?.href??"",r=t.currentTarget.getBoundingClientRect();o({type:"link",range:l(),existing:n,anchor:{top:r.bottom+6,left:r.left}})},"aria-label":"Link",children:(0,s.jsx)(t8,{className:"w-3.5 h-3.5"})}),(t||n)&&(0,s.jsx)("div",{className:"w-px h-5 bg-border mx-1"}),n&&(0,s.jsx)("button",{type:"button",className:a(!1),onMouseDown:e=>e.preventDefault(),onClick:e=>{e.preventDefault(),n()},"aria-label":"Comment",title:"Comment",children:(0,s.jsx)(fI,{className:"w-3.5 h-3.5"})}),t&&(0,s.jsx)("button",{type:"button",className:a(!1),onMouseDown:e=>e.preventDefault(),onClick:e=>{e.preventDefault(),t()},"aria-label":"Suggest edit",title:"Suggest edit",children:(0,s.jsx)(fL,{className:"w-3.5 h-3.5"})}),(0,s.jsx)("div",{className:"w-px h-5 bg-border mx-1"}),(0,s.jsxs)("div",{className:"relative",children:[(0,s.jsx)("button",{type:"button",className:a(!1),onMouseDown:e=>e.preventDefault(),onClick:e=>{e.preventDefault(),o({type:"align",range:l()})},"aria-label":"Align",children:(0,s.jsx)(fT,{className:"w-3.5 h-3.5"})}),i?.type==="align"&&(0,s.jsxs)("div",{"data-bubble-popover":"true",className:"absolute top-full left-0 mt-1 z-50 bg-popover border border-border rounded-sm shadow-lg p-1 flex gap-0.5",children:[(0,s.jsx)("button",{type:"button",className:a(e.isActive({textAlign:"left"})),onMouseDown:e=>e.preventDefault(),onClick:()=>u("left"),"aria-label":"Align left",children:(0,s.jsx)(fT,{className:"w-3.5 h-3.5"})}),(0,s.jsx)("button",{type:"button",className:a(e.isActive({textAlign:"center"})),onMouseDown:e=>e.preventDefault(),onClick:()=>u("center"),"aria-label":"Align center",children:(0,s.jsx)(n0,{className:"w-3.5 h-3.5"})}),(0,s.jsx)("button",{type:"button",className:a(e.isActive({textAlign:"right"})),onMouseDown:e=>e.preventDefault(),onClick:()=>u("right"),"aria-label":"Align right",children:(0,s.jsx)(fO,{className:"w-3.5 h-3.5"})}),(0,s.jsx)("button",{type:"button",className:a(e.isActive({textAlign:"justify"})),onMouseDown:e=>e.preventDefault(),onClick:()=>u("justify"),"aria-label":"Justify",children:(0,s.jsx)(fA.AlignJustify,{className:"w-3.5 h-3.5"})})]})]})]}),r&&n&&(0,s.jsx)("button",{type:"button",className:a(!1),onMouseDown:e=>e.preventDefault(),onClick:e=>{e.preventDefault(),n()},"aria-label":"Comment",title:"Add comment",children:(0,s.jsx)(fI,{className:"w-3.5 h-3.5"})})]}),i?.type==="link"&&(0,s.jsx)("div",{"data-bubble-popover":"true",style:{position:"fixed",top:i.anchor.top,left:i.anchor.left,zIndex:60},children:(0,s.jsx)(fF,{anchor:{top:0,left:0},initialUrl:i.existing,onCancel:()=>o(null),onApply:t=>{i?.type==="link"&&(c(i.range),e.chain().focus().extendMarkRange("link").setLink({href:t}).run(),o(null))},onRemove:i.existing?()=>{i?.type==="link"&&(c(i.range),e.chain().focus().unsetLink().run(),o(null))}:void 0})})]})}let fU=(0,o.default)("square-check-big",[["path",{d:"M21 10.656V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.344",key:"2acyp4"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]),fV=(0,o.default)("chevron-left",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]),fW=(0,o.default)("file-code",[["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7z",key:"1mlx9k"}]]),fq=(0,o.default)("heading-1",[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"m17 12 3-2v8",key:"1hhhft"}]]),fK=(0,o.default)("heading-2",[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1",key:"9jr5yi"}]]),fG=(0,o.default)("heading-3",[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2",key:"68ncm8"}],["path",{d:"M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2",key:"1ejuhz"}]]);var fJ=e.i(375707),fJ=fJ;let fZ=(0,o.default)("list",[["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 18h.01",key:"1tta3j"}],["path",{d:"M3 6h.01",key:"1rqtza"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 18h13",key:"1lx6n3"}],["path",{d:"M8 6h13",key:"ik3vkj"}]]),fX=(0,o.default)("list-ordered",[["path",{d:"M10 12h11",key:"6m4ad9"}],["path",{d:"M10 18h11",key:"11hvi2"}],["path",{d:"M10 6h11",key:"c7qv1k"}],["path",{d:"M4 10h2",key:"16xx2s"}],["path",{d:"M4 6h1v4",key:"cnovpq"}],["path",{d:"M6 18H4c0-1 2-2 2-3s-1-1.5-2-1",key:"m9a95d"}]]),fY=(0,o.default)("minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]),fQ=(0,o.default)("pilcrow-left",[["path",{d:"M14 3v11",key:"mlfb7b"}],["path",{d:"M14 9h-3a3 3 0 0 1 0-6h9",key:"1ulc19"}],["path",{d:"M18 3v11",key:"1phi0r"}],["path",{d:"M22 18H2l4-4",key:"yt65j9"}],["path",{d:"m6 22-4-4",key:"6jgyf5"}]]),f0=(0,o.default)("pilcrow-right",[["path",{d:"M10 3v11",key:"o3l5kj"}],["path",{d:"M10 9H7a1 1 0 0 1 0-6h8",key:"1wb1nc"}],["path",{d:"M14 3v11",key:"mlfb7b"}],["path",{d:"m18 14 4 4H2",key:"4r8io1"}],["path",{d:"m22 18-4 4",key:"1hjjrd"}]]),f1=(0,o.default)("quote",[["path",{d:"M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"rib7q0"}],["path",{d:"M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"1ymkrd"}]]),f2=(0,o.default)("redo",[["path",{d:"M21 7v6h-6",key:"3ptur4"}],["path",{d:"M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3l3 2.7",key:"1kgawr"}]]),f3=(0,o.default)("undo",[["path",{d:"M3 7v6h6",key:"1v2h90"}],["path",{d:"M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13",key:"1r6uu6"}]]),f5=(0,o.default)("video",[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]]);var f4="horizontal",f6=["horizontal","vertical"],f9=f.forwardRef((e,t)=>{var n;let{decorative:r,orientation:i=f4,...o}=e,a=(n=i,f6.includes(n))?i:f4;return(0,s.jsx)(tv.div,{"data-orientation":a,...r?{role:"none"}:{"aria-orientation":"vertical"===a?a:void 0,role:"separator"},...o,ref:t})});f9.displayName="Separator";let f7=f.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},i)=>(0,s.jsx)(f9,{ref:i,decorative:n,orientation:t,className:(0,eh.cn)("shrink-0 bg-border","horizontal"===t?"h-[1px] w-full":"h-full w-[1px]",e),...r}));f7.displayName=f9.displayName;let f8=(0,o.default)("clipboard",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}]]);async function me(e,t){let n=new FormData;n.append("file",t);try{let t=await (0,tC.wsFetch)(`/api/upload/${e}`,{method:"POST",body:n});if(!t.ok)return null;let r=await t.json();return{url:(0,tC.withWs)(r.url),filename:r.filename}}catch{return null}}function mt({kind:e,pagePath:t,onCancel:n,onInsert:r,anchor:i}){let[o,a]=(0,f.useState)("upload"),[l,c]=(0,f.useState)(""),[d,u]=(0,f.useState)(!1),[p,h]=(0,f.useState)(null),m=(0,f.useRef)(null),g=async e=>{if(e&&0!==e.length){u(!0),h(null);try{let n=e[0],i=await me(t,n);if(!i)return void h("Upload failed.");r({url:i.url,alt:n.name,mimeType:n.type})}finally{u(!1)}}},b=()=>{let e=l.trim();e&&r({url:e})};return(0,s.jsxs)("div",{className:"absolute z-50 w-[360px] bg-popover border border-border rounded-xl shadow-e-4 overflow-hidden",style:{top:i.top,left:i.left},onMouseDown:e=>e.stopPropagation(),children:[(0,s.jsxs)("div",{className:"flex items-center justify-between px-3 py-2 border-b border-border",children:[(0,s.jsx)("div",{className:"text-[12px] font-medium",children:"image"===e?"Insert image":"video"===e?"Insert video":"Attach file"}),(0,s.jsx)("button",{type:"button",onClick:n,className:"text-[11px] text-muted-foreground hover:text-foreground",children:"Cancel"})]}),(0,s.jsxs)("div",{className:"flex border-b border-border bg-muted/30",children:[(0,s.jsxs)("button",{type:"button",onClick:()=>a("upload"),className:(0,eh.cn)("flex-1 py-1.5 text-[11px] flex items-center justify-center gap-1.5 transition-colors","upload"===o?"bg-background text-foreground border-b-2 border-primary":"text-muted-foreground hover:text-foreground"),children:[(0,s.jsx)(ns,{className:"w-3 h-3"})," Upload"]}),(0,s.jsxs)("button",{type:"button",onClick:()=>a("url"),className:(0,eh.cn)("flex-1 py-1.5 text-[11px] flex items-center justify-center gap-1.5 transition-colors","url"===o?"bg-background text-foreground border-b-2 border-primary":"text-muted-foreground hover:text-foreground"),children:[(0,s.jsx)(t8,{className:"w-3 h-3"})," From URL"]})]}),"upload"===o?(0,s.jsxs)("div",{className:"p-4",onDragOver:e=>{e.preventDefault(),e.stopPropagation()},onDrop:e=>{e.preventDefault(),e.stopPropagation(),g(e.dataTransfer.files)},children:[(0,s.jsxs)("button",{type:"button",onClick:()=>m.current?.click(),disabled:d,className:"w-full border-2 border-dashed border-border rounded-sm py-6 flex flex-col items-center justify-center text-muted-foreground hover:bg-accent/30 transition-colors",children:[(0,s.jsx)(ns,{className:"w-5 h-5 mb-1.5"}),(0,s.jsx)("span",{className:"text-[12px] font-medium",children:d?"Uploading…":`Click to upload ${e}`}),(0,s.jsx)("span",{className:"text-[10px] mt-0.5",children:"or drop a file here"})]}),(0,s.jsx)("input",{ref:m,type:"file",accept:"image"===e?"image/*":"video"===e?"video/*":"*/*",className:"hidden",onChange:e=>g(e.target.files)}),p&&(0,s.jsx)("div",{className:"mt-2 text-[11px] text-destructive",children:p})]}):(0,s.jsxs)("div",{className:"p-3 space-y-2",children:[(0,s.jsx)("input",{type:"url",autoFocus:!0,value:l,placeholder:"image"===e?"https://example.com/image.png":"video"===e?"https://example.com/video.mp4":"https://example.com/file",onChange:e=>c(e.target.value),onKeyDown:e=>{"Enter"===e.key?(e.preventDefault(),b()):"Escape"===e.key&&n()},className:"w-full bg-background border border-border rounded-sm px-2.5 py-1.5 text-[12px] focus:outline-none focus:ring-2 focus:ring-primary/30"}),(0,s.jsx)("button",{type:"button",onClick:b,disabled:!l.trim(),className:"w-full py-1.5 text-[12px] rounded-sm bg-primary text-primary-foreground disabled:opacity-50 hover:bg-primary/90",children:"Insert"})]}),(0,s.jsxs)("div",{className:"px-3 py-2 border-t border-border bg-muted/30 text-[10px] text-muted-foreground flex items-start gap-1.5",children:[(0,s.jsx)(f8,{className:"w-3 h-3 shrink-0 mt-[1px]"}),(0,s.jsxs)("span",{children:["Tip: you can also"," ",(0,s.jsx)("strong",{className:"text-foreground/80",children:"paste"})," or"," ",(0,s.jsx)("strong",{className:"text-foreground/80",children:"drag & drop"}),"files directly into the page — they'll be saved alongside this page automatically."]})]})]})}function mn({label:e,icon:t,active:n,disabled:r,style:i,onAction:o}){return(0,s.jsx)("button",{type:"button","aria-label":e,title:e,disabled:r,style:i,onMouseDown:e=>{e.preventDefault()},onClick:e=>{e.preventDefault(),o(e)},className:(0,eh.cn)("h-8 w-8 shrink-0 inline-flex items-center justify-center rounded-md text-foreground/80 hover:bg-accent hover:text-accent-foreground transition-colors disabled:opacity-40",n&&"bg-accent text-accent-foreground ring-1 ring-inset ring-foreground/15"),children:(0,s.jsx)(t,{className:"h-4 w-4"})})}function mr({editor:e}){let t=tQ(e=>e.frontmatter),n=tQ(e=>e.updateFrontmatter),r=tQ(e=>e.currentPath),i=t?.dir==="rtl",[o,a]=(0,f.useState)(null),l=(0,f.useRef)(null),[c,d]=(0,f.useState)(!1),[u,p]=(0,f.useState)(!1),[,h]=(0,f.useState)(0);(0,f.useEffect)(()=>{if(!e)return;let t=()=>h(e=>e+1);return e.on("selectionUpdate",t),e.on("transaction",t),()=>{e.off("selectionUpdate",t),e.off("transaction",t)}},[e]);let m=(0,f.useCallback)(()=>{let e=l.current;e&&(d(e.scrollLeft>4),p(e.scrollLeft+e.clientWidth<e.scrollWidth-4))},[]);(0,f.useEffect)(()=>{if(!e)return;let t=l.current;if(!t)return;let n=requestAnimationFrame(m),r=()=>m();window.addEventListener("resize",r),t.addEventListener("scroll",m);let i=new ResizeObserver(()=>m());for(let e of(i.observe(t),Array.from(t.children)))i.observe(e);return()=>{cancelAnimationFrame(n),window.removeEventListener("resize",r),t.removeEventListener("scroll",m),i.disconnect()}},[e,m]);let g=e=>{let t=l.current;t&&t.scrollBy({left:e*Math.max(160,.6*t.clientWidth),behavior:"smooth"})};if(!e)return null;let b=(t,n)=>{e.chain().focus().setTextSelection(t).run(),n()},x=(t,n)=>{let r=t.currentTarget.getBoundingClientRect();a(n({top:r.bottom+6,left:r.left},(()=>{let{from:t,to:n}=e.state.selection;return{from:t,to:n}})()))},y=[{icon:fq,action:()=>e.chain().focus().toggleHeading({level:1}).run(),isActive:e.isActive("heading",{level:1}),label:"Heading 1"},{icon:fK,action:()=>e.chain().focus().toggleHeading({level:2}).run(),isActive:e.isActive("heading",{level:2}),label:"Heading 2"},{icon:fG,action:()=>e.chain().focus().toggleHeading({level:3}).run(),isActive:e.isActive("heading",{level:3}),label:"Heading 3"},{separator:!0},{icon:f_,action:()=>e.chain().focus().toggleBold().run(),isActive:e.isActive("bold"),label:"Bold"},{icon:fR,action:()=>e.chain().focus().toggleItalic().run(),isActive:e.isActive("italic"),label:"Italic"},{icon:fB,action:()=>e.chain().focus().toggleUnderline().run(),isActive:e.isActive("underline"),label:"Underline"},{icon:fP,action:()=>e.chain().focus().toggleStrike().run(),isActive:e.isActive("strike"),label:"Strikethrough"},{icon:fD,action:()=>e.chain().focus().toggleCode().run(),isActive:e.isActive("code"),label:"Inline code"},{icon:t8,action:t=>{let n=e.getAttributes("link")?.href??"";x(t,(e,t)=>({type:"link",anchor:e,range:t,existing:n}))},isActive:e.isActive("link"),label:"Link"},{separator:!0},{icon:fZ,action:()=>e.chain().focus().toggleBulletList().run(),isActive:e.isActive("bulletList"),label:"Bullet list"},{icon:fX,action:()=>e.chain().focus().toggleOrderedList().run(),isActive:e.isActive("orderedList"),label:"Ordered list"},{icon:f1,action:()=>e.chain().focus().toggleBlockquote().run(),isActive:e.isActive("blockquote"),label:"Blockquote"},{icon:fU,action:()=>e.chain().focus().toggleTaskList().run(),isActive:e.isActive("taskList"),label:"Checklist"},{icon:fW,action:()=>e.chain().focus().toggleCodeBlock().run(),isActive:e.isActive("codeBlock"),label:"Code block"},{icon:fY,action:()=>e.chain().focus().setHorizontalRule().run(),isActive:!1,label:"Divider"}],v=[{icon:fT,action:()=>e.chain().focus().setTextAlign("left").run(),isActive:e.isActive({textAlign:"left"}),label:"Align left"},{icon:n0,action:()=>e.chain().focus().setTextAlign("center").run(),isActive:e.isActive({textAlign:"center"}),label:"Align center"},{icon:fO,action:()=>e.chain().focus().setTextAlign("right").run(),isActive:e.isActive({textAlign:"right"}),label:"Align right"},{icon:fA.AlignJustify,action:()=>e.chain().focus().setTextAlign("justify").run(),isActive:e.isActive({textAlign:"justify"}),label:"Justify"},{separator:!0},{icon:f$,action:()=>e.chain().focus().toggleSuperscript().run(),isActive:e.isActive("superscript"),label:"Superscript"},{icon:fz,action:()=>e.chain().focus().toggleSubscript().run(),isActive:e.isActive("subscript"),label:"Subscript"},{separator:!0},{icon:fJ.default,action:e=>x(e,e=>({type:"media",kind:"image",anchor:e})),isActive:!1,label:"Insert image"},{icon:f5,action:e=>x(e,e=>({type:"media",kind:"video",anchor:e})),isActive:!1,label:"Insert video"},{separator:!0},{icon:f3,action:()=>e.chain().focus().undo().run(),isActive:!1,label:"Undo"},{icon:f2,action:()=>e.chain().focus().redo().run(),isActive:!1,label:"Redo"},{separator:!0},{icon:i?fQ:f0,action:()=>n({dir:i?void 0:"rtl"}),isActive:i,label:i?"Switch to LTR":"Switch to RTL"}];return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"relative border-b border-border bg-background/50",children:[c&&(0,s.jsx)("button",{type:"button","aria-label":"Scroll toolbar left",onMouseDown:e=>e.preventDefault(),onClick:()=>g(-1),className:"absolute left-0 top-0 bottom-0 w-6 z-10 flex items-center justify-start pl-0.5 bg-gradient-to-r from-background via-background/80 to-transparent text-muted-foreground hover:text-foreground transition-colors",children:(0,s.jsx)(fV,{className:"h-4 w-4"})}),u&&(0,s.jsx)("button",{type:"button","aria-label":"Scroll toolbar right",onMouseDown:e=>e.preventDefault(),onClick:()=>g(1),className:"absolute right-0 top-0 bottom-0 w-6 z-10 flex items-center justify-end pr-0.5 bg-gradient-to-l from-background via-background/80 to-transparent text-muted-foreground hover:text-foreground transition-colors",children:(0,s.jsx)(e1.ChevronRight,{className:"h-4 w-4"})}),(0,s.jsx)("div",{ref:l,onWheel:e=>{let t=l.current;t&&Math.abs(e.deltaY)>Math.abs(e.deltaX)&&(t.scrollLeft+=e.deltaY)},className:"flex items-center gap-0.5 px-2 pt-1 pb-1.5 overflow-x-scroll overflow-y-hidden editor-toolbar-scroll",children:[...y,{separator:!0},...v].map((e,t)=>"separator"in e?(0,s.jsx)(f7,{orientation:"vertical",className:"mx-1 h-6 shrink-0"},t):(0,s.jsx)(mn,{label:e.label,icon:e.icon,active:e.isActive,style:e.style,onAction:e.action},t))})]}),o?.type==="link"&&(0,s.jsx)("div",{"data-editor-popover":"true",style:{position:"fixed",top:o.anchor.top,left:o.anchor.left,zIndex:60},children:(0,s.jsx)(fF,{anchor:{top:0,left:0},initialUrl:o.existing,onCancel:()=>a(null),onApply:t=>{o?.type==="link"&&(b(o.range,()=>{e.chain().focus().extendMarkRange("link").setLink({href:t}).run()}),a(null))},onRemove:o.existing?()=>{o?.type==="link"&&(b(o.range,()=>{e.chain().focus().unsetLink().run()}),a(null))}:void 0})}),o?.type==="media"&&r&&(0,s.jsx)("div",{"data-editor-popover":"true",style:{position:"fixed",top:o.anchor.top,left:o.anchor.left,zIndex:60},children:(0,s.jsx)(mt,{kind:o.kind,pagePath:r,anchor:{top:0,left:0},onCancel:()=>a(null),onInsert:t=>((t,n)=>{let{url:r,alt:i,mimeType:s}=n;"image"===t||(s??"").startsWith("image/")||/\.(png|jpe?g|gif|webp|svg|avif)(\?|$)/i.test(r)?e.chain().focus().setImage({src:r,alt:i??""}).run():e.chain().focus().insertContent(`<a href="${r}">${i??r}</a>`).run(),a(null)})(o.kind,t)})}),o&&(0,s.jsx)(mi,{onClose:()=>a(null)})]})}function mi({onClose:e}){return(0,f.useEffect)(()=>{let t=window.setTimeout(()=>{let t=t=>{let n=t.target;n?.closest('[data-editor-popover="true"]')||e()};window.addEventListener("mousedown",t),window.__editorPopClose=()=>window.removeEventListener("mousedown",t)},10);return()=>{window.clearTimeout(t);let e=window;e.__editorPopClose&&(e.__editorPopClose(),e.__editorPopClose=void 0)}},[e]),null}let ms="numeric",mo="ascii",ma="alpha",ml="asciinumeric",mc="alphanumeric",md="domain",mu="emoji",mp="whitespace";function mh(e,t,n){for(let r in t[ms]&&(t[ml]=!0,t[mc]=!0),t[mo]&&(t[ml]=!0,t[ma]=!0),t[ml]&&(t[mc]=!0),t[ma]&&(t[mc]=!0),t[mc]&&(t[md]=!0),t[mu]&&(t[md]=!0),t){let t=(r in n||(n[r]=[]),n[r]);0>t.indexOf(e)&&t.push(e)}}function mf(e=null){this.j={},this.jr=[],this.jd=null,this.t=e}mf.groups={},mf.prototype={accepts(){return!!this.t},go(e){let t=this.j[e];if(t)return t;for(let t=0;t<this.jr.length;t++){let n=this.jr[t][0],r=this.jr[t][1];if(r&&n.test(e))return r}return this.jd},has(e,t=!1){return t?e in this.j:!!this.go(e)},ta(e,t,n,r){for(let i=0;i<e.length;i++)this.tt(e[i],t,n,r)},tr(e,t,n,r){let i;return r=r||mf.groups,t&&t.j?i=t:(i=new mf(t),n&&r&&mh(t,n,r)),this.jr.push([e,i]),i},ts(e,t,n,r){let i=this,s=e.length;if(!s)return i;for(let t=0;t<s-1;t++)i=i.tt(e[t]);return i.tt(e[s-1],t,n,r)},tt(e,t,n,r){if(r=r||mf.groups,t&&t.j)return this.j[e]=t,t;let i,s=this.go(e);return s?(Object.assign((i=new mf).j,s.j),i.jr.push.apply(i.jr,s.jr),i.jd=s.jd,i.t=s.t):i=new mf,t&&(r&&(i.t&&"string"==typeof i.t?mh(t,Object.assign(function(e,t){let n={};for(let r in t)t[r].indexOf(e)>=0&&(n[r]=!0);return n}(i.t,r),n),r):n&&mh(t,n,r)),i.t=t),this.j[e]=i,i}};let mm=(e,t,n,r,i)=>e.ta(t,n,r,i),mg=(e,t,n,r,i)=>e.tr(t,n,r,i),mb=(e,t,n,r,i)=>e.ts(t,n,r,i),mx=(e,t,n,r,i)=>e.tt(t,n,r,i),my="WORD",mv="UWORD",mw="ASCIINUMERICAL",mk="ALPHANUMERICAL",mN="LOCALHOST",mS="UTLD",mC="SCHEME",mj="SLASH_SCHEME",mE="OPENBRACE",mM="CLOSEBRACE",mA="OPENBRACKET",mT="CLOSEBRACKET",mO="OPENPAREN",m_="CLOSEPAREN",mD="OPENANGLEBRACKET",mR="CLOSEANGLEBRACKET",mI="FULLWIDTHLEFTPAREN",mL="FULLWIDTHRIGHTPAREN",mP="LEFTCORNERBRACKET",mz="RIGHTCORNERBRACKET",m$="LEFTWHITECORNERBRACKET",mB="RIGHTWHITECORNERBRACKET",mF="FULLWIDTHLESSTHAN",mH="FULLWIDTHGREATERTHAN",mU="AMPERSAND",mV="APOSTROPHE",mW="ASTERISK",mq="BACKSLASH",mK="BACKTICK",mG="CARET",mJ="COLON",mZ="COMMA",mX="DOLLAR",mY="EQUALS",mQ="EXCLAMATION",m0="HYPHEN",m1="PERCENT",m2="PIPE",m3="PLUS",m5="POUND",m4="QUERY",m6="QUOTE",m9="FULLWIDTHMIDDLEDOT",m7="SEMI",m8="SLASH",ge="TILDE",gt="UNDERSCORE",gn="EMOJI";var gr=Object.freeze({__proto__:null,ALPHANUMERICAL:mk,AMPERSAND:mU,APOSTROPHE:mV,ASCIINUMERICAL:mw,ASTERISK:mW,AT:"AT",BACKSLASH:mq,BACKTICK:mK,CARET:mG,CLOSEANGLEBRACKET:mR,CLOSEBRACE:mM,CLOSEBRACKET:mT,CLOSEPAREN:m_,COLON:mJ,COMMA:mZ,DOLLAR:mX,DOT:"DOT",EMOJI:gn,EQUALS:mY,EXCLAMATION:mQ,FULLWIDTHGREATERTHAN:mH,FULLWIDTHLEFTPAREN:mI,FULLWIDTHLESSTHAN:mF,FULLWIDTHMIDDLEDOT:m9,FULLWIDTHRIGHTPAREN:mL,HYPHEN:m0,LEFTCORNERBRACKET:mP,LEFTWHITECORNERBRACKET:m$,LOCALHOST:mN,NL:"NL",NUM:"NUM",OPENANGLEBRACKET:mD,OPENBRACE:mE,OPENBRACKET:mA,OPENPAREN:mO,PERCENT:m1,PIPE:m2,PLUS:m3,POUND:m5,QUERY:m4,QUOTE:m6,RIGHTCORNERBRACKET:mz,RIGHTWHITECORNERBRACKET:mB,SCHEME:mC,SEMI:m7,SLASH:m8,SLASH_SCHEME:mj,SYM:"SYM",TILDE:ge,TLD:"TLD",UNDERSCORE:gt,UTLD:mS,UWORD:mv,WORD:my,WS:"WS"});let gi=/[a-z]/,gs=/\p{L}/u,go=/\p{Emoji}/u,ga=/\d/,gl=/\s/,gc=null,gd=null;function gu(e,t){let n=function(e){let t=[],n=e.length,r=0;for(;r<n;){let i,s=e.charCodeAt(r),o=s<55296||s>56319||r+1===n||(i=e.charCodeAt(r+1))<56320||i>57343?e[r]:e.slice(r,r+2);t.push(o),r+=o.length}return t}(t.replace(/[A-Z]/g,e=>e.toLowerCase())),r=n.length,i=[],s=0,o=0;for(;o<r;){let a=e,l=null,c=0,d=null,u=-1,p=-1;for(;o<r&&(l=a.go(n[o]));)(a=l).accepts()?(u=0,p=0,d=a):u>=0&&(u+=n[o].length,p++),c+=n[o].length,s+=n[o].length,o++;s-=u,o-=p,c-=u,i.push({t:d.t,v:t.slice(s-c,s),s:s-c,e:s})}return i}function gp(e,t,n,r,i){let s,o=t.length;for(let n=0;n<o-1;n++){let o=t[n];e.j[o]?s=e.j[o]:((s=new mf(r)).jr=i.slice(),e.j[o]=s),e=s}return(s=new mf(n)).jr=i.slice(),e.j[t[o-1]]=s,s}function gh(e){let t=[],n=[],r=0;for(;r<e.length;){let i=0;for(;"0123456789".indexOf(e[r+i])>=0;)i++;if(i>0){t.push(n.join(""));for(let t=parseInt(e.substring(r,r+i),10);t>0;t--)n.pop();r+=i}else n.push(e[r]),r++}return t}let gf={defaultProtocol:"http",events:null,format:gg,formatHref:gg,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function gm(e,t=null){let n=Object.assign({},gf);e&&(n=Object.assign(n,e instanceof gm?e.o:e));let r=n.ignoreTags,i=[];for(let e=0;e<r.length;e++)i.push(r[e].toUpperCase());this.o=n,t&&(this.defaultRender=t),this.ignoreTags=i}function gg(e){return e}function gb(e,t){this.t="token",this.v=e,this.tk=t}function gx(e,t){class n extends gb{constructor(t,n){super(t,n),this.t=e}}for(let e in t)n.prototype[e]=t[e];return n.t=e,n}gm.prototype={o:gf,ignoreTags:[],defaultRender:e=>e,check(e){return this.get("validate",e.toString(),e)},get(e,t,n){let r=null!=t,i=this.o[e];return i&&("object"==typeof i?"function"==typeof(i=n.t in i?i[n.t]:gf[e])&&r&&(i=i(t,n)):"function"==typeof i&&r&&(i=i(t,n.t,n))),i},getObj(e,t,n){let r=this.o[e];return"function"==typeof r&&null!=t&&(r=r(t,n.t,n)),r},render(e){let t=e.render(this);return(this.get("render",null,e)||this.defaultRender)(t,e.t,e)}},gb.prototype={isLink:!1,toString(){return this.v},toHref(e){return this.toString()},toFormattedString(e){let t=this.toString(),n=e.get("truncate",t,this),r=e.get("format",t,this);return n&&r.length>n?r.substring(0,n)+"…":r},toFormattedHref(e){return e.get("formatHref",this.toHref(e.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(e=gf.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(e),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(e){return{type:this.t,value:this.toFormattedString(e),isLink:this.isLink,href:this.toFormattedHref(e),start:this.startIndex(),end:this.endIndex()}},validate(e){return e.get("validate",this.toString(),this)},render(e){let t=this.toHref(e.get("defaultProtocol")),n=e.get("formatHref",t,this),r=e.get("tagName",t,this),i=this.toFormattedString(e),s={},o=e.get("className",t,this),a=e.get("target",t,this),l=e.get("rel",t,this),c=e.getObj("attributes",t,this),d=e.getObj("events",t,this);return s.href=n,o&&(s.class=o),a&&(s.target=a),l&&(s.rel=l),c&&Object.assign(s,c),{tagName:r,attributes:s,content:i,eventListeners:d}}};let gy=gx("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),gv=gx("text"),gw=gx("nl"),gk=gx("url",{isLink:!0,toHref(e=gf.defaultProtocol){return this.hasProtocol()?this.v:`${e}://${this.v}`},hasProtocol(){let e=this.tk;return e.length>=2&&e[0].t!==mN&&e[1].t===mJ}}),gN=e=>new mf(e);function gS(e,t,n){let r=n[0].s,i=n[n.length-1].e;return new e(t.slice(r,i),n)}let gC="u">typeof console&&console&&console.warn||(()=>{}),gj={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function gE(e,t=!1){if(gj.initialized&&gC(`linkifyjs: already initialized - will not register custom scheme "${e}" until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(e))throw Error(`linkifyjs: incorrect scheme format.
|
|
117
|
+
1. Must only contain digits, lowercase ASCII letters or "-"
|
|
118
|
+
2. Cannot start or end with "-"
|
|
119
|
+
3. "-" cannot repeat`);gj.customSchemes.push([e,t])}function gM(e){return gj.initialized||function(){gj.scanner=function(e=[]){let t={};mf.groups=t;let n=new mf;null==gc&&(gc=gh("aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2odyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rck0msd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2oodside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2")),null==gd&&(gd=gh("ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2")),mx(n,"'",mV),mx(n,"{",mE),mx(n,"}",mM),mx(n,"[",mA),mx(n,"]",mT),mx(n,"(",mO),mx(n,")",m_),mx(n,"<",mD),mx(n,">",mR),mx(n,"(",mI),mx(n,")",mL),mx(n,"「",mP),mx(n,"」",mz),mx(n,"『",m$),mx(n,"』",mB),mx(n,"<",mF),mx(n,">",mH),mx(n,"&",mU),mx(n,"*",mW),mx(n,"@","AT"),mx(n,"`",mK),mx(n,"^",mG),mx(n,":",mJ),mx(n,",",mZ),mx(n,"$",mX),mx(n,".","DOT"),mx(n,"=",mY),mx(n,"!",mQ),mx(n,"-",m0),mx(n,"%",m1),mx(n,"|",m2),mx(n,"+",m3),mx(n,"#",m5),mx(n,"?",m4),mx(n,'"',m6),mx(n,"/",m8),mx(n,";",m7),mx(n,"~",ge),mx(n,"_",gt),mx(n,"\\",mq),mx(n,"・",m9);let r=mg(n,ga,"NUM",{[ms]:!0});mg(r,ga,r);let i=mg(r,gi,mw,{[ml]:!0}),s=mg(r,gs,mk,{[mc]:!0}),o=mg(n,gi,my,{[mo]:!0});mg(o,ga,i),mg(o,gi,o),mg(i,ga,i),mg(i,gi,i);let a=mg(n,gs,mv,{[ma]:!0});mg(a,gi),mg(a,ga,s),mg(a,gs,a),mg(s,ga,s),mg(s,gi),mg(s,gs,s);let l=mx(n,"\n","NL",{[mp]:!0}),c=mx(n,"\r","WS",{[mp]:!0}),d=mg(n,gl,"WS",{[mp]:!0});mx(n,"",d),mx(c,"\n",l),mx(c,"",d),mg(c,gl,d),mx(d,"\r"),mx(d,"\n"),mg(d,gl,d),mx(d,"",d);let u=mg(n,go,gn,{[mu]:!0});mx(u,"#"),mg(u,go,u),mx(u,"️",u);let p=mx(u,"");mx(p,"#"),mg(p,go,u);let h=[[gi,o],[ga,i]],f=[[gi,null],[gs,a],[ga,s]];for(let e=0;e<gc.length;e++)gp(n,gc[e],"TLD",my,h);for(let e=0;e<gd.length;e++)gp(n,gd[e],mS,mv,f);mh("TLD",{tld:!0,ascii:!0},t),mh(mS,{utld:!0,alpha:!0},t),gp(n,"file",mC,my,h),gp(n,"mailto",mC,my,h),gp(n,"http",mj,my,h),gp(n,"https",mj,my,h),gp(n,"ftp",mj,my,h),gp(n,"ftps",mj,my,h),mh(mC,{scheme:!0,ascii:!0},t),mh(mj,{slashscheme:!0,ascii:!0},t),e=e.sort((e,t)=>e[0]>t[0]?1:-1);for(let t=0;t<e.length;t++){let r=e[t][0],i=e[t][1]?{scheme:!0}:{slashscheme:!0};r.indexOf("-")>=0?i[md]=!0:gi.test(r)?ga.test(r)?i[ml]=!0:i[mo]=!0:i[ms]=!0,mb(n,r,r,i)}return mb(n,"localhost",mN,{ascii:!0}),n.jd=new mf("SYM"),{start:n,tokens:Object.assign({groups:t},gr)}}(gj.customSchemes);for(let e=0;e<gj.tokenQueue.length;e++)gj.tokenQueue[e][1]({scanner:gj.scanner});gj.parser=function({groups:e}){let t=e.domain.concat([mU,mW,"AT",mq,mK,mG,mX,mY,m0,"NUM",m1,m2,m3,m5,m8,"SYM",ge,gt]),n=[mV,mJ,mZ,"DOT",mQ,m1,m4,m6,m7,mD,mR,mE,mM,mT,mA,mO,m_,mI,mL,mP,mz,m$,mB,mF,mH],r=[mU,mV,mW,mq,mK,mG,mX,mY,m0,mE,mM,m1,m2,m3,m5,m4,m8,"SYM",ge,gt],i=gN(),s=mx(i,ge);mm(s,r,s),mm(s,e.domain,s);let o=gN(),a=gN(),l=gN();mm(i,e.domain,o),mm(i,e.scheme,a),mm(i,e.slashscheme,l),mm(o,r,s),mm(o,e.domain,o);let c=mx(o,"AT");mx(s,"AT",c),mx(a,"AT",c),mx(l,"AT",c);let d=mx(s,"DOT");mm(d,r,s),mm(d,e.domain,s);let u=gN();mm(c,e.domain,u),mm(u,e.domain,u);let p=mx(u,"DOT");mm(p,e.domain,u);let h=gN(gy);mm(p,e.tld,h),mm(p,e.utld,h),mx(c,mN,h);let f=mx(u,m0);mx(f,m0,f),mm(f,e.domain,u),mm(h,e.domain,u),mx(h,"DOT",p),mx(h,m0,f);let m=mx(o,m0),g=mx(o,"DOT");mx(m,m0,m),mm(m,e.domain,o),mm(g,r,s),mm(g,e.domain,o);let b=gN(gk);mm(g,e.tld,b),mm(g,e.utld,b),mm(b,e.domain,o),mm(b,r,s),mx(b,"DOT",g),mx(b,m0,m),mx(b,"AT",c);let x=mx(b,mJ),y=gN(gk);mm(x,e.numeric,y);let v=gN(gk),w=gN();mm(v,t,v),mm(v,n,w),mm(w,t,v),mm(w,n,w),mx(b,m8,v),mx(y,m8,v);let k=mx(a,mJ),N=mx(l,mJ),S=mx(N,m8),C=mx(S,m8);mm(a,e.domain,o),mx(a,"DOT",g),mx(a,m0,m),mm(l,e.domain,o),mx(l,"DOT",g),mx(l,m0,m),mm(k,e.domain,v),mx(k,m8,v),mx(k,m4,v),mm(C,e.domain,v),mm(C,t,v),mx(C,m8,v);let j=[[mE,mM],[mA,mT],[mO,m_],[mD,mR],[mI,mL],[mP,mz],[m$,mB],[mF,mH]];for(let e=0;e<j.length;e++){let[r,i]=j[e],s=mx(v,r);mx(w,r,s);let o=gN(gk);mm(s,t,o);let a=gN();mm(s,n,a),mx(s,i,v),mm(o,t,o),mm(o,n,a),mm(a,t,o),mm(a,n,a),mx(o,i,v),mx(a,i,v)}return mx(i,mN,b),mx(i,"NL",gw),{start:i,tokens:gr}}(gj.scanner.tokens);for(let e=0;e<gj.pluginQueue.length;e++)gj.pluginQueue[e][1]({scanner:gj.scanner,parser:gj.parser});gj.initialized=!0}(),function(e,t,n){let r=n.length,i=0,s=[],o=[];for(;i<r;){let a=e,l=null,c=null,d=0,u=null,p=-1;for(;i<r&&!(l=a.go(n[i].t));)o.push(n[i++]);for(;i<r&&(c=l||a.go(n[i].t));)l=null,(a=c).accepts()?(p=0,u=a):p>=0&&p++,i++,d++;if(p<0)(i-=d)<r&&(o.push(n[i]),i++);else{o.length>0&&(s.push(gS(gv,t,o)),o=[]),i-=p,d-=p;let e=u.t,r=n.slice(i-d,i);s.push(gS(e,t,r))}}return o.length>0&&s.push(gS(gv,t,o)),s}(gj.parser.start,e,gu(gj.scanner.start,e))}function gA(e,t=null,n=null){if(t&&"object"==typeof t){if(n)throw Error(`linkifyjs: Invalid link type ${t}; must be a string`);n=t,t=null}let r=new gm(n),i=gM(e),s=[];for(let e=0;e<i.length;e++){let n=i[e];n.isLink&&(!t||n.t===t)&&r.check(n)&&s.push(n.toFormattedObject(r))}return s}gM.scan=gu;var gT="[\0- -\u2029 ]",gO=new RegExp(gT),g_=RegExp(`${gT}$`),gD=RegExp(gT,"g");function gR(e,t){let n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return t&&t.forEach(e=>{let t="string"==typeof e?e:e.scheme;t&&n.push(t)}),!e||e.replace(gD,"").match(RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var gI=u9.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(e=>{"string"==typeof e?gE(e):gE(e.scheme,e.optionalSlashes)})},onDestroy(){mf.groups={},gj.scanner=null,gj.parser=null,gj.tokenQueue=[],gj.pluginQueue=[],gj.customSchemes=[],gj.initialized=!1},inclusive(){return this.options.autolink},addOptions:()=>({openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(e,t)=>!!gR(e,t.protocols),validate:e=>!!e,shouldAutoLink:e=>{let t=/^[a-z][a-z0-9+.-]*:\/\//i.test(e),n=/^[a-z][a-z0-9+.-]*:/i.test(e);if(t||n&&!e.includes("@"))return!0;let r=(e.includes("@")?e.split("@").pop():e).split(/[/?#:]/)[0];return!/^\d{1,3}(\.\d{1,3}){3}$/.test(r)&&!!/\./.test(r)}}),addAttributes(){return{href:{default:null,parseHTML:e=>e.getAttribute("href")},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class},title:{default:null}}},parseHTML(){return[{tag:"a[href]",getAttrs:e=>{let t=e.getAttribute("href");return!!t&&!!this.options.isAllowedUri(t,{defaultValidate:e=>!!gR(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})&&null}}]},renderHTML({HTMLAttributes:e}){return this.options.isAllowedUri(e.href,{defaultValidate:e=>!!gR(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",uc(this.options.HTMLAttributes,e),0]:["a",uc(this.options.HTMLAttributes,{...e,href:""}),0]},markdownTokenName:"link",parseMarkdown:(e,t)=>t.applyMark("link",t.parseInline(e.tokens||[]),{href:e.href,title:e.title||null}),renderMarkdown:(e,t)=>{var n,r,i,s;let o=null!=(r=null==(n=e.attrs)?void 0:n.href)?r:"",a=null!=(s=null==(i=e.attrs)?void 0:i.title)?s:"",l=t.renderChildren(e);return a?`[${l}](${o} "${a}")`:`[${l}](${o})`},addCommands(){return{setLink:e=>({chain:t})=>{let{href:n}=e;return!!this.options.isAllowedUri(n,{defaultValidate:e=>!!gR(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})&&t().setMark(this.name,e).setMeta("preventAutolink",!0).run()},toggleLink:e=>({chain:t})=>{let{href:n}=e||{};return(!n||!!this.options.isAllowedUri(n,{defaultValidate:e=>!!gR(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol}))&&t().toggleMark(this.name,e,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()},unsetLink:()=>({chain:e})=>e().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[p_({find:e=>{let t=[];if(e){let{protocols:n,defaultProtocol:r}=this.options,i=gA(e).filter(e=>e.isLink&&this.options.isAllowedUri(e.value,{defaultValidate:e=>!!gR(e,n),protocols:n,defaultProtocol:r}));i.length&&i.forEach(e=>{this.options.shouldAutoLink(e.value)&&t.push({text:e.value,data:{href:e.href},index:e.start})})}return t},type:this.type,getAttributes:e=>{var t;return{href:null==(t=e.data)?void 0:t.href}}})]},addProseMirrorPlugins(){var e,t,n;let r=[],{protocols:i,defaultProtocol:s}=this.options;return this.options.autolink&&r.push((e={type:this.type,defaultProtocol:this.options.defaultProtocol,validate:e=>this.options.isAllowedUri(e,{defaultValidate:e=>!!gR(e,i),protocols:i,defaultProtocol:s}),shouldAutoLink:this.options.shouldAutoLink},new sY({key:new s1("autolink"),appendTransaction:(t,n,r)=>{let i=t.some(e=>e.docChanged)&&!n.doc.eq(r.doc),s=t.some(e=>e.getMeta("preventAutolink"));if(!i||s)return;let{tr:o}=r;if(uv(d9(n.doc,[...t])).forEach(({newRange:t})=>{var n,i;let s,a,l,c=(n=r.doc,i=e=>e.isTextblock,l=[],n.nodesBetween(t.from,t.to,(e,t)=>{i(e)&&l.push({node:e,pos:t})}),l);if(c.length>1)s=c[0],a=r.doc.textBetween(s.pos,s.pos+s.node.nodeSize,void 0," ");else if(c.length){let e=r.doc.textBetween(t.from,t.to," "," ");if(!g_.test(e))return;s=c[0],a=r.doc.textBetween(s.pos,t.to,void 0," ")}if(s&&a){let t=a.split(gO).filter(Boolean);if(t.length<=0)return!1;let n=t[t.length-1],i=s.pos+a.lastIndexOf(n);if(!n)return!1;let l=gM(n).map(t=>t.toObject(e.defaultProtocol));if(!(1===l.length?l[0].isLink:3===l.length&&!!l[1].isLink&&["()","[]"].includes(l[0].value+l[2].value)))return!1;l.filter(e=>e.isLink).map(e=>({...e,from:i+e.start+1,to:i+e.end+1})).filter(e=>!r.schema.marks.code||!r.doc.rangeHasMark(e.from,e.to,r.schema.marks.code)).filter(t=>e.validate(t.value)).filter(t=>e.shouldAutoLink(t.value)).forEach(t=>{uw(t.from,t.to,r.doc).some(t=>t.mark.type===e.type)||o.addMark(t.from,t.to,e.type.create({href:t.href}))})}}),o.steps.length)return o}}))),r.push((t={type:this.type,editor:this.editor,openOnClick:"whenNotEditable"===this.options.openOnClick||this.options.openOnClick,enableClickSelection:this.options.enableClickSelection},new sY({key:new s1("handleClickLink"),props:{handleClick:(e,n,r)=>{var i,s;if(0!==r.button||!e.editable)return!1;let o=null;if(r.target instanceof HTMLAnchorElement)o=r.target;else{let e=r.target;if(!e)return!1;let n=t.editor.view.dom;(o=e.closest("a"))&&!n.contains(o)&&(o=null)}if(!o)return!1;let a=!1;if(t.enableClickSelection&&(a=t.editor.commands.extendMarkRange(t.type.name)),t.openOnClick){let n=uy(e.state,t.type.name),r=null!=(i=o.href)?i:n.href,l=null!=(s=o.target)?s:n.target;r&&(window.open(r,l),a=!0)}return a}}}))),this.options.linkOnPaste&&r.push((n={editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink},new sY({key:new s1("handlePasteLink"),props:{handlePaste:(e,t,r)=>{let{shouldAutoLink:i}=n,{state:s}=e,{selection:o}=s,{empty:a}=o;if(a)return!1;let l="";r.content.forEach(e=>{l+=e.textContent});let c=gA(l,{defaultProtocol:n.defaultProtocol}).find(e=>e.isLink&&e.value===l);return!!l&&!!c&&(void 0===i||!!i(c.value))&&n.editor.commands.setMark(n.type,{href:c.href})}}}))),r}});class gL{constructor(e,t){var n;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=null!=(n=t.width)?n:1,this.color=!1===t.color?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map(t=>{let n=e=>{this[t](e)};return e.dom.addEventListener(t,n),{name:t,handler:n}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){null!=this.cursorPos&&t.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,null==e?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e,t,n=this.editorView.state.doc.resolve(this.cursorPos),r=!n.parent.inlineContent,i,s=this.editorView.dom,o=s.getBoundingClientRect(),a=o.width/s.offsetWidth,l=o.height/s.offsetHeight;if(r){let e=n.nodeBefore,t=n.nodeAfter;if(e||t){let n=this.editorView.nodeDOM(this.cursorPos-(e?e.nodeSize:0));if(n){let r=n.getBoundingClientRect(),s=e?r.bottom:r.top;e&&t&&(s=(s+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let o=this.width/2*l;i={left:r.left,right:r.right,top:s-o,bottom:s+o}}}}if(!i){let e=this.editorView.coordsAtPos(this.cursorPos),t=this.width/2*a;i={left:e.left-t,right:e.left+t,top:e.top,bottom:e.bottom}}let c=this.editorView.dom.offsetParent;if(!this.element&&(this.element=c.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",r),this.element.classList.toggle("prosemirror-dropcursor-inline",!r),c&&(c!=document.body||"static"!=getComputedStyle(c).position)){let n=c.getBoundingClientRect(),r=n.width/c.offsetWidth,i=n.height/c.offsetHeight;e=n.left-c.scrollLeft*r,t=n.top-c.scrollTop*i}else e=-pageXOffset,t=-pageYOffset;this.element.style.left=(i.left-e)/a+"px",this.element.style.top=(i.top-t)/l+"px",this.element.style.width=(i.right-i.left)/a+"px",this.element.style.height=(i.bottom-i.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),n=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),r=n&&n.type.spec.disableDropCursor,i="function"==typeof r?r(this.editorView,t,e):r;if(t&&!i){let e=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let t=sv(this.editorView.state.doc,e,this.editorView.dragging.slice);null!=t&&(e=t)}this.setCursor(e),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class gP extends sR{constructor(e){super(e,e)}map(e,t){let n=e.resolve(t.map(this.head));return gP.valid(n)?new gP(n):sR.near(n)}content(){return ig.empty}eq(e){return e instanceof gP&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if("number"!=typeof t.pos)throw RangeError("Invalid input for GapCursor.fromJSON");return new gP(e.resolve(t.pos))}getBookmark(){return new gz(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!function(e){for(let t=e.depth;t>=0;t--){let n=e.index(t),r=e.node(t);if(0==n){if(r.type.spec.isolating)return!0;continue}for(let e=r.child(n-1);;e=e.lastChild){if(0==e.childCount&&!e.inlineContent||g$(e.type))return!0;if(e.inlineContent)return!1}}return!0}(e)||!function(e){for(let t=e.depth;t>=0;t--){let n=e.indexAfter(t),r=e.node(t);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let e=r.child(n);;e=e.firstChild){if(0==e.childCount&&!e.inlineContent||g$(e.type))return!0;if(e.inlineContent)return!1}}return!0}(e))return!1;let n=t.type.spec.allowGapCursor;if(null!=n)return n;let r=t.contentMatchAt(e.index()).defaultType;return r&&r.isTextblock}static findGapCursorFrom(e,t,n=!1){r:for(;;){if(!n&&gP.valid(e))return e;let r=e.pos,i=null;for(let n=e.depth;;n--){let s=e.node(n);if(t>0?e.indexAfter(n)<s.childCount:e.index(n)>0){i=s.child(t>0?e.indexAfter(n):e.index(n)-1);break}if(0==n)return null;r+=t;let o=e.doc.resolve(r);if(gP.valid(o))return o}for(;;){let s=t>0?i.firstChild:i.lastChild;if(!s){if(i.isAtom&&!i.isText&&!sB.isSelectable(i)){e=e.doc.resolve(r+i.nodeSize*t),n=!1;continue r}break}i=s,r+=t;let o=e.doc.resolve(r);if(gP.valid(o))return o}return null}}}gP.prototype.visible=!1,gP.findFrom=gP.findGapCursorFrom,sR.jsonID("gapcursor",gP);class gz{constructor(e){this.pos=e}map(e){return new gz(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return gP.valid(t)?new gP(t):sR.near(t)}}function g$(e){return e.isAtom||e.spec.isolating||e.spec.createGapCursor}let gB=lR({ArrowLeft:gF("horiz",-1),ArrowRight:gF("horiz",1),ArrowUp:gF("vert",-1),ArrowDown:gF("vert",1)});function gF(e,t){let n="vert"==e?t>0?"down":"up":t>0?"right":"left";return function(e,r,i){let s=e.selection,o=t>0?s.$to:s.$from,a=s.empty;if(s instanceof sz){if(!i.endOfTextblock(n)||0==o.depth)return!1;a=!1,o=e.doc.resolve(t>0?o.after():o.before())}let l=gP.findGapCursorFrom(o,t,a);return!!l&&(r&&r(e.tr.setSelection(new gP(l))),!0)}}function gH(e,t,n){if(!e||!e.editable)return!1;let r=e.state.doc.resolve(t);if(!gP.valid(r))return!1;let i=e.posAtCoords({left:n.clientX,top:n.clientY});return!(i&&i.inside>-1&&sB.isSelectable(e.state.doc.nodeAt(i.inside)))&&(e.dispatch(e.state.tr.setSelection(new gP(r))),!0)}function gU(e,t){if("insertCompositionText"!=t.inputType||!(e.state.selection instanceof gP))return!1;let{$from:n}=e.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(e.state.schema.nodes.text);if(!r)return!1;let i=ic.empty;for(let e=r.length-1;e>=0;e--)i=ic.from(r[e].createAndFill(null,i));let s=e.state.tr.replace(n.pos,n.pos,new ig(i,0,0));return s.setSelection(sz.near(s.doc.resolve(n.pos+1))),e.dispatch(s),!1}function gV(e){if(!(e.selection instanceof gP))return null;let t=document.createElement("div");return t.className="ProseMirror-gapcursor",a6.create(e.doc,[a3.widget(e.selection.head,t,{key:"gapcursor"})])}var gW=function(){};gW.prototype.append=function(e){return e.length?(e=gW.from(e),!this.length&&e||e.length<200&&this.leafAppend(e)||this.length<200&&e.leafPrepend(this)||this.appendInner(e)):this},gW.prototype.prepend=function(e){return e.length?gW.from(e).append(this):this},gW.prototype.appendInner=function(e){return new gK(this,e)},gW.prototype.slice=function(e,t){return(void 0===e&&(e=0),void 0===t&&(t=this.length),e>=t)?gW.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},gW.prototype.get=function(e){if(!(e<0)&&!(e>=this.length))return this.getInner(e)},gW.prototype.forEach=function(e,t,n){void 0===t&&(t=0),void 0===n&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)},gW.prototype.map=function(e,t,n){void 0===t&&(t=0),void 0===n&&(n=this.length);var r=[];return this.forEach(function(t,n){return r.push(e(t,n))},t,n),r},gW.from=function(e){return e instanceof gW?e:e&&e.length?new gq(e):gW.empty};var gq=function(e){function t(t){e.call(this),this.values=t}t.__proto__=e,t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(e,n){return 0==e&&n==this.length?this:new t(this.values.slice(e,n))},t.prototype.getInner=function(e){return this.values[e]},t.prototype.forEachInner=function(e,t,n,r){for(var i=t;i<n;i++)if(!1===e(this.values[i],r+i))return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){for(var i=t-1;i>=n;i--)if(!1===e(this.values[i],r+i))return!1},t.prototype.leafAppend=function(e){if(this.length+e.length<=200)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=200)return new t(e.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(t.prototype,n),t}(gW);gW.empty=new gq([]);var gK=function(e){function t(t,n){e.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return t.__proto__=e,t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(e){return e<this.left.length?this.left.get(e):this.right.get(e-this.left.length)},t.prototype.forEachInner=function(e,t,n,r){var i=this.left.length;if(t<i&&!1===this.left.forEachInner(e,t,Math.min(n,i),r)||n>i&&!1===this.right.forEachInner(e,Math.max(t-i,0),Math.min(this.length,n)-i,r+i))return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){var i=this.left.length;if(t>i&&!1===this.right.forEachInvertedInner(e,t-i,Math.max(n,i)-i,r+i)||n<i&&!1===this.left.forEachInvertedInner(e,Math.min(t,i),n,r))return!1},t.prototype.sliceInner=function(e,t){if(0==e&&t==this.length)return this;var n=this.left.length;return t<=n?this.left.slice(e,t):e>=n?this.right.slice(e-n,t-n):this.left.slice(e,n).append(this.right.slice(0,t-n))},t.prototype.leafAppend=function(e){var n=this.right.leafAppend(e);if(n)return new t(this.left,n)},t.prototype.leafPrepend=function(e){var n=this.left.leafPrepend(e);if(n)return new t(n,this.right)},t.prototype.appendInner=function(e){return this.left.depth>=Math.max(this.right.depth,e.depth)+1?new t(this.left,new t(this.right,e)):new t(this,e)},t}(gW);class gG{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){let n,r,i,s;if(0==this.eventCount)return null;let o=this.items.length;for(;;o--)if(this.items.get(o-1).selection){--o;break}t&&(r=(n=this.remapping(o,this.items.length)).maps.length);let a=e.tr,l=[],c=[];return this.items.forEach((e,t)=>{if(!e.step){n||(r=(n=this.remapping(o,t+1)).maps.length),r--,c.push(e);return}if(n){c.push(new gJ(e.map));let t=e.step.map(n.slice(r)),i;t&&a.maybeStep(t).doc&&(i=a.mapping.maps[a.mapping.maps.length-1],l.push(new gJ(i,void 0,void 0,l.length+c.length))),r--,i&&n.appendMap(i,r)}else a.maybeStep(e.step);if(e.selection)return i=n?e.selection.map(n.slice(r)):e.selection,s=new gG(this.items.slice(0,o).append(c.reverse().concat(l)),this.eventCount-1),!1},this.items.length,0),{remaining:s,transform:a,selection:i}}addTransform(e,t,n,r){var i,s;let o,a=[],l=this.eventCount,c=this.items,d=!r&&c.length?c.get(c.length-1):null;for(let n=0;n<e.steps.length;n++){let i=e.steps[n].invert(e.docs[n]),s=new gJ(e.mapping.maps[n],i,t),o;(o=d&&d.merge(s))&&(s=o,n?a.pop():c=c.slice(0,c.length-1)),a.push(s),t&&(l++,t=void 0),r||(d=s)}let u=l-n.depth;return u>gX&&(i=c,s=u,i.forEach((e,t)=>{if(e.selection&&0==s--)return o=t,!1}),c=i.slice(o),l-=u),new gG(c.append(a),l)}remapping(e,t){let n=new i7;return this.items.forEach((t,r)=>{let i=null!=t.mirrorOffset&&r-t.mirrorOffset>=e?n.maps.length-t.mirrorOffset:void 0;n.appendMap(t.map,i)},e,t),n}addMaps(e){return 0==this.eventCount?this:new gG(this.items.append(e.map(e=>new gJ(e))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let n=[],r=Math.max(0,this.items.length-t),i=e.mapping,s=e.steps.length,o=this.eventCount;this.items.forEach(e=>{e.selection&&o--},r);let a=t;this.items.forEach(t=>{let r=i.getMirror(--a);if(null==r)return;s=Math.min(s,r);let l=i.maps[r];if(t.step){let s=e.steps[r].invert(e.docs[r]),c=t.selection&&t.selection.map(i.slice(a+1,r));c&&o++,n.push(new gJ(l,s,c))}else n.push(new gJ(l))},r);let l=[];for(let e=t;e<s;e++)l.push(new gJ(i.maps[e]));let c=new gG(this.items.slice(0,r).append(l).append(n),o);return c.emptyItemCount()>500&&(c=c.compress(this.items.length-n.length)),c}emptyItemCount(){let e=0;return this.items.forEach(t=>{!t.step&&e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),n=t.maps.length,r=[],i=0;return this.items.forEach((s,o)=>{if(o>=e)r.push(s),s.selection&&i++;else if(s.step){let e=s.step.map(t.slice(n)),o=e&&e.getMap();if(n--,o&&t.appendMap(o,n),e){let a=s.selection&&s.selection.map(t.slice(n));a&&i++;let l=new gJ(o.invert(),e,a),c,d=r.length-1;(c=r.length&&r[d].merge(l))?r[d]=c:r.push(l)}}else s.map&&n--},this.items.length,0),new gG(gW.from(r.reverse()),i)}}gG.empty=new gG(gW.empty,0);class gJ{constructor(e,t,n,r){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=r}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new gJ(t.getMap().invert(),t,this.selection)}}}class gZ{constructor(e,t,n,r,i){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=r,this.prevComposition=i}}let gX=20;function gY(e){let t=[];for(let n=e.length-1;n>=0&&0==t.length;n--)e[n].forEach((e,n,r,i)=>t.push(r,i));return t}function gQ(e,t){if(!e)return null;let n=[];for(let r=0;r<e.length;r+=2){let i=t.map(e[r],1),s=t.map(e[r+1],-1);i<=s&&n.push(i,s)}return n}let g0=!1,g1=null;function g2(e){let t=e.plugins;if(g1!=t){g0=!1,g1=t;for(let e=0;e<t.length;e++)if(t[e].spec.historyPreserveItems){g0=!0;break}}return g0}let g3=new s1("history"),g5=new s1("closeHistory");function g4(e,t){return(n,r)=>{let i=g3.getState(n);if(!i||0==(e?i.undone:i.done).eventCount)return!1;if(r){let s=function(e,t,n){let r=g2(t),i=g3.get(t).spec.config,s=(n?e.undone:e.done).popEvent(t,r);if(!s)return null;let o=s.selection.resolve(s.transform.doc),a=(n?e.done:e.undone).addTransform(s.transform,t.selection.getBookmark(),i,r),l=new gZ(n?a:s.remaining,n?s.remaining:a,null,0,-1);return s.transform.setSelection(o).setMeta(g3,{redo:n,historyState:l})}(i,n,e);s&&r(t?s.scrollIntoView():s)}return!0}}let g6=g4(!1,!0),g9=g4(!0,!0);g4(!1,!1),g4(!0,!1),pt.create({name:"characterCount",addOptions:()=>({limit:null,autoTrim:!0,mode:"textSize",textCounter:e=>e.length,wordCounter:e=>e.split(" ").filter(e=>""!==e).length}),addStorage:()=>({characters:()=>0,words:()=>0}),onBeforeCreate(){this.storage.characters=e=>{let t=(null==e?void 0:e.node)||this.editor.state.doc;if("textSize"===((null==e?void 0:e.mode)||this.options.mode)){let e=t.textBetween(0,t.content.size,void 0," ");return this.options.textCounter(e)}return t.nodeSize},this.storage.words=e=>{let t=(null==e?void 0:e.node)||this.editor.state.doc,n=t.textBetween(0,t.content.size," "," ");return this.options.wordCounter(n)}},addProseMirrorPlugins(){let e=!1;return[new sY({key:new s1("characterCount"),appendTransaction:(t,n,r)=>{if(e)return;let i=this.options.limit,s=this.options.autoTrim;if(null==i||0===i||!1===s){e=!0;return}let o=this.storage.characters({node:r.doc});if(o>i){console.warn(`[CharacterCount] Initial content exceeded limit of ${i} characters. Content was automatically trimmed.`);let t=r.tr.deleteRange(0,o-i);return e=!0,t}e=!0},filterTransaction:(e,t)=>{let n=this.options.limit;if(!e.docChanged||0===n||null==n)return!0;let r=this.storage.characters({node:t.doc}),i=this.storage.characters({node:e.doc});if(i<=n||r>n&&i>n&&i<=r)return!0;if(r>n&&i>n&&i>r||!e.getMeta("paste"))return!1;let s=e.selection.$head.pos;return e.deleteRange(s-(i-n),s),!(this.storage.characters({node:e.doc})>n)}})]}});var g7=pt.create({name:"dropCursor",addOptions:()=>({color:"currentColor",width:1,class:void 0}),addProseMirrorPlugins(){return[function(e={}){return new sY({view:t=>new gL(t,e)})}(this.options)]}});pt.create({name:"focus",addOptions:()=>({className:"has-focus",mode:"all"}),addProseMirrorPlugins(){return[new sY({key:new s1("focus"),props:{decorations:({doc:e,selection:t})=>{let{isEditable:n,isFocused:r}=this.editor,{anchor:i}=t,s=[];if(!n||!r)return a6.create(e,[]);let o=0;"deepest"===this.options.mode&&e.descendants((e,t)=>{if(!e.isText){if(!(i>=t&&i<=t+e.nodeSize-1))return!1;o+=1}});let a=0;return e.descendants((e,t)=>!e.isText&&!!(i>=t&&i<=t+e.nodeSize-1)&&((a+=1,"deepest"===this.options.mode&&o-a>0||"shallowest"===this.options.mode&&a>1)?"deepest"===this.options.mode:void s.push(a3.node(t,t+e.nodeSize,{class:this.options.className})))),a6.create(e,s)}}})]}});var g8=pt.create({name:"gapCursor",addProseMirrorPlugins:()=>[new sY({props:{decorations:gV,createSelectionBetween:(e,t,n)=>t.pos==n.pos&&gP.valid(n)?new gP(n):null,handleClick:gH,handleKeyDown:gB,handleDOMEvents:{beforeinput:gU}}})],extendNodeSchema(e){var t;let n={name:e.name,options:e.options,storage:e.storage};return{allowGapCursor:null!=(t=us(ut(e,"allowGapCursor",n)))?t:null}}}),be="placeholder",bt=new s1("tiptap__placeholder");function bn(e){let{editor:t,placeholder:n,dataAttribute:r,pos:i,node:s,isEmptyDoc:o,hasAnchor:a,classes:{emptyNode:l,emptyEditor:c}}=e,d=[l];return o&&d.push(c),a3.node(i,i+s.nodeSize,{class:d.join(" "),[r]:"function"==typeof n?n({editor:t,node:s,pos:i,hasAnchor:a}):n})}var br={init:()=>({topPos:null,bottomPos:null}),apply(e,t){let n=e.getMeta(bt);return(null==n?void 0:n.positions)?{topPos:n.positions.top,bottomPos:n.positions.bottom}:e.docChanged?{topPos:null!==t.topPos?e.mapping.map(t.topPos):null,bottomPos:null!==t.bottomPos?e.mapping.map(t.bottomPos):null}:t}};function bi(e){let t=function(e){let t=e;for(;t;){if(function(e){let t=getComputedStyle(e),n=`${t.overflow} ${t.overflowY} ${t.overflowX}`;return/auto|scroll|overlay/.test(n)}(t))return t;let e=t.parentElement;if(!e){let e=t.getRootNode();if(e instanceof ShadowRoot){t=e.host;continue}break}t=e}return window}(e.dom),n=()=>{let n=function({doc:e,view:t,scrollContainer:n}){let r=t.dom.getBoundingClientRect(),i=n?n===window?{top:0,bottom:window.innerHeight}:n.getBoundingClientRect():{top:0,bottom:window.innerHeight},s=Math.max(r.top,i.top)-200,o=Math.min(r.bottom,i.bottom)+200;if(s>=o)return{top:0,bottom:e.content.size};let a="rtl"===getComputedStyle(t.dom).direction?Math.max(r.right-2,r.left+2):r.left+2,l=t.posAtCoords({left:a,top:s+2}),c=t.posAtCoords({left:a,top:o-2});return{top:l?l.pos:0,bottom:c?c.pos:e.content.size}}({view:e,doc:e.state.doc,scrollContainer:t}),r=bt.getState(e.state);if((null==r?void 0:r.topPos)===n.top&&(null==r?void 0:r.bottomPos)===n.bottom)return;let i=e.state.tr.setMeta(bt,{positions:n});e.dispatch(i)},r=null,i=0,s=()=>{null===r&&(r=requestAnimationFrame(()=>{r=null;let e=performance.now();e-i>=150?(i=e,n()):s()}))};return t.addEventListener("scroll",s,{passive:!0}),n(),{update(t,n){e.state.doc.content.size!==n.doc.content.size&&s()},destroy:()=>{null!==r&&cancelAnimationFrame(r),t.removeEventListener("scroll",s)}}}var bs=pt.create({name:"placeholder",addOptions:()=>({emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:be,placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}),addProseMirrorPlugins(){return[function({editor:e,options:t}){let n=t.dataAttribute?`data-${t.dataAttribute.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}`:`data-${be}`;return new sY({key:bt,state:br,view:bi,props:{decorations:({doc:r,selection:i})=>(function({editor:e,options:t,dataAttribute:n,doc:r,selection:i}){var s,o;if(!(e.isEditable||!t.showOnlyWhenEditable))return null;let{anchor:a}=i,l=[],c=e.isEmpty,d={emptyEditor:t.emptyEditorClass,emptyNode:t.emptyNodeClass};if(t.showOnlyCurrent&&!t.includeChildren){let i=r.resolve(a),s=i.depth>0?i.node(1):i.nodeAfter,o=i.depth>0?i.before(1):a;if(s&&s.type.isTextblock&&uE(s)){let r=a>=o&&a<=o+s.nodeSize;l.push(bn({editor:e,isEmptyDoc:c,dataAttribute:n,hasAnchor:r,placeholder:t.placeholder,classes:d,node:s,pos:o}))}}else{let i=bt.getState(e.state),u=null!=(s=null==i?void 0:i.topPos)?s:0,p=null!=(o=null==i?void 0:i.bottomPos)?o:r.content.size;r.nodesBetween(u,p,(r,i)=>{let s=a>=i&&a<=i+r.nodeSize,o=!r.isLeaf&&uE(r);return r.type.isTextblock&&(s||!t.showOnlyCurrent)&&o&&l.push(bn({editor:e,isEmptyDoc:c,dataAttribute:n,hasAnchor:s,placeholder:t.placeholder,classes:d,node:r,pos:i})),t.includeChildren})}return a6.create(r,l)})({editor:e,options:t,dataAttribute:n,doc:r,selection:i})}})}({editor:this.editor,options:this.options})]}});function bo({types:e,node:t}){return t&&Array.isArray(e)&&e.includes(t.type)||(null==t?void 0:t.type)===e}pt.create({name:"selection",addOptions:()=>({className:"selection"}),addProseMirrorPlugins(){let{editor:e,options:t}=this;return[new sY({key:new s1("selection"),props:{decorations:n=>n.selection.empty||e.isFocused||!e.isEditable||uM(n.selection)||e.view.dragging?null:a6.create(n.doc,[a3.inline(n.selection.from,n.selection.to,{class:t.className})])}})]}});var ba=pt.create({name:"trailingNode",addOptions:()=>({node:void 0,notAfter:[]}),addProseMirrorPlugins(){var e;let t=new s1(this.name),n=this.options.node||(null==(e=this.editor.schema.topNodeType.contentMatch.defaultType)?void 0:e.name)||"paragraph",r=Object.entries(this.editor.schema.nodes).map(([,e])=>e).filter(e=>(this.options.notAfter||[]).concat(n).includes(e.name));return[new sY({key:t,appendTransaction:(e,r,i)=>{let{doc:s,tr:o,schema:a}=i,l=t.getState(i),c=s.content.size,d=a.nodes[n];if(!e.some(e=>e.getMeta("skipTrailingNode"))&&l)return o.insert(c,d.create())},state:{init:(e,t)=>!bo({node:t.tr.doc.lastChild,types:r}),apply:(e,t)=>!e.docChanged||e.getMeta("__uniqueIDTransaction")?t:!bo({node:e.doc.lastChild,types:r})}})]}}),bl=pt.create({name:"undoRedo",addOptions:()=>({depth:100,newGroupDelay:500}),addCommands:()=>({undo:()=>({state:e,dispatch:t})=>g6(e,t),redo:()=>({state:e,dispatch:t})=>g9(e,t)}),addProseMirrorPlugins(){return[function(e={}){return new sY({key:g3,state:{init:()=>new gZ(gG.empty,gG.empty,null,0,-1),apply:(t,n,r)=>(function(e,t,n,r){let i=n.getMeta(g3),s;if(i)return i.historyState;n.getMeta(g5)&&(e=new gZ(e.done,e.undone,null,0,-1));let o=n.getMeta("appendedTransaction");if(0==n.steps.length)return e;if(o&&o.getMeta(g3))if(o.getMeta(g3).redo)return new gZ(e.done.addTransform(n,void 0,r,g2(t)),e.undone,gY(n.mapping.maps),e.prevTime,e.prevComposition);else return new gZ(e.done,e.undone.addTransform(n,void 0,r,g2(t)),null,e.prevTime,e.prevComposition);if(!1===n.getMeta("addToHistory")||o&&!1===o.getMeta("addToHistory"))if(s=n.getMeta("rebased"))return new gZ(e.done.rebased(n,s),e.undone.rebased(n,s),gQ(e.prevRanges,n.mapping),e.prevTime,e.prevComposition);else return new gZ(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),gQ(e.prevRanges,n.mapping),e.prevTime,e.prevComposition);{let i=n.getMeta("composition"),s=0==e.prevTime||!o&&e.prevComposition!=i&&(e.prevTime<(n.time||0)-r.newGroupDelay||!function(e,t){if(!t)return!1;if(!e.docChanged)return!0;let n=!1;return e.mapping.maps[0].forEach((e,r)=>{for(let i=0;i<t.length;i+=2)e<=t[i+1]&&r>=t[i]&&(n=!0)}),n}(n,e.prevRanges)),a=o?gQ(e.prevRanges,n.mapping):gY(n.mapping.maps);return new gZ(e.done.addTransform(n,s?t.selection.getBookmark():void 0,r,g2(t)),gG.empty,a,n.time,null==i?e.prevComposition:i)}})(n,r,t,e)},config:e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,r="historyUndo"==n?g6:"historyRedo"==n?g9:null;return!!r&&!!e.editable&&(t.preventDefault(),r(e.state,e.dispatch))}}}})}(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),bc=u9.create({name:"subscript",addOptions:()=>({HTMLAttributes:{}}),parseHTML:()=>[{tag:"sub"},{style:"vertical-align",getAttrs:e=>"sub"===e&&null}],renderHTML({HTMLAttributes:e}){return["sub",uc(this.options.HTMLAttributes,e),0]},addCommands(){return{setSubscript:()=>({commands:e})=>e.setMark(this.name),toggleSubscript:()=>({commands:e})=>e.toggleMark(this.name),unsetSubscript:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-,":()=>this.editor.commands.toggleSubscript()}}}),bd=u9.create({name:"superscript",addOptions:()=>({HTMLAttributes:{}}),parseHTML:()=>[{tag:"sup"},{style:"vertical-align",getAttrs:e=>"super"===e&&null}],renderHTML({HTMLAttributes:e}){return["sup",uc(this.options.HTMLAttributes,e),0]},addCommands(){return{setSuperscript:()=>({commands:e})=>e.setMark(this.name),toggleSuperscript:()=>({commands:e})=>e.toggleMark(this.name),unsetSuperscript:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-.":()=>this.editor.commands.toggleSuperscript()}}});function bu(e){return"left"===e||"right"===e||"center"===e?e:null}function bp(){return{default:null,parseHTML:e=>{let t,n;return t=(e.style.textAlign||"").trim().toLowerCase(),n=(e.getAttribute("align")||"").trim().toLowerCase(),bu(t||n)},renderHTML:e=>e.align?{style:`text-align: ${e.align}`}:{}}}var bh=pT.create({name:"tableCell",addOptions:()=>({HTMLAttributes:{}}),content:"block+",addAttributes:()=>({colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:e=>{var t,n;let r=e.getAttribute("colwidth"),i=r?r.split(",").map(e=>parseInt(e,10)):null;if(!i){let r=null==(t=e.closest("table"))?void 0:t.querySelectorAll("colgroup > col"),i=Array.from((null==(n=e.parentElement)?void 0:n.children)||[]).indexOf(e);if(i&&i>-1&&r&&r[i]){let e=r[i].getAttribute("width");return e?[parseInt(e,10)]:null}}return i}},align:bp()}),tableRole:"cell",isolating:!0,parseHTML:()=>[{tag:"td"}],renderHTML({HTMLAttributes:e}){return["td",uc(this.options.HTMLAttributes,e),0]}}),bf=pT.create({name:"tableHeader",addOptions:()=>({HTMLAttributes:{}}),content:"block+",addAttributes:()=>({colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:e=>{let t=e.getAttribute("colwidth");return t?t.split(",").map(e=>parseInt(e,10)):null}},align:bp()}),tableRole:"header_cell",isolating:!0,parseHTML:()=>[{tag:"th"}],renderHTML({HTMLAttributes:e}){return["th",uc(this.options.HTMLAttributes,e),0]}}),bm=pT.create({name:"tableRow",addOptions:()=>({HTMLAttributes:{}}),content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML:()=>[{tag:"tr"}],renderHTML({HTMLAttributes:e}){return["tr",uc(this.options.HTMLAttributes,e),0]}});function bg(e,t){return t?["width",`${Math.max(t,e)}px`]:["min-width",`${e}px`]}function bb(e,t,n,r,i,s){var o;let a=0,l=!0,c=t.firstChild,d=e.firstChild;if(null!==d)for(let e=0,n=0;e<d.childCount;e+=1){let{colspan:o,colwidth:u}=d.child(e).attrs;for(let e=0;e<o;e+=1,n+=1){let o=i===n?s:u&&u[e],d=o?`${o}px`:"";if(a+=o||r,o||(l=!1),c){if(c.style.width!==d){let[e,t]=bg(r,o);c.style.setProperty(e,t)}c=c.nextSibling}else{let e=document.createElement("col"),[n,i]=bg(r,o);e.style.setProperty(n,i),t.appendChild(e)}}}for(;c;){let e=c.nextSibling;null==(o=c.parentNode)||o.removeChild(c),c=e}let u=e.attrs.style&&"string"==typeof e.attrs.style&&/\bwidth\s*:/i.test(e.attrs.style);l&&!u?(n.style.width=`${a}px`,n.style.minWidth=""):(n.style.width="",n.style.minWidth=`${a}px`)}var bx=class{constructor(e,t){this.node=e,this.cellMinWidth=t,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),e.attrs.style&&(this.table.style.cssText=e.attrs.style),this.colgroup=this.table.appendChild(document.createElement("colgroup")),bb(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type===this.node.type&&(this.node=e,bb(e,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(e){let t=e.target,n=this.dom.contains(t),r=this.contentDOM.contains(t);return!!n&&!r&&("attributes"===e.type||"childList"===e.type||"characterData"===e.type)}};function by(e,t){return t?e.createChecked(null,t):e.createAndFill()}var bv=({editor:e})=>{let{selection:t}=e.state;if(!(t instanceof lq))return!1;let n=0,r=d8(t.ranges[0].$from,e=>"table"===e.type.name);return null==r||r.node.descendants(e=>{if("table"===e.type.name)return!1;["tableCell","tableHeader"].includes(e.type.name)&&(n+=1)}),n===t.ranges.length&&(e.commands.deleteTable(),!0)},bw=function(e,t,n={}){var r;let i=null!=(r=n.cellLineSeparator)?r:"\x1f";if(!e||!e.content||0===e.content.length)return"";let s=[];e.content.forEach(e=>{let n=[];e.content&&e.content.forEach(e=>{var r;let s=((e.content&&Array.isArray(e.content)&&e.content.length>1?e.content.map(e=>t.renderChildren(e)).join(i):e.content?t.renderChildren(e.content):"")||"").replace(/\s+/g," ").trim(),o="tableHeader"===e.type,a=bu(null==(r=e.attrs)?void 0:r.align);n.push({text:s,isHeader:o,align:a})}),s.push(n)});let o=s.reduce((e,t)=>Math.max(e,t.length),0);if(0===o)return"";let a=Array.from({length:o}).fill(0);s.forEach(e=>{var t;for(let n=0;n<o;n+=1){let r=((null==(t=e[n])?void 0:t.text)||"").length;r>a[n]&&(a[n]=r),a[n]<3&&(a[n]=3)}});let l=(e,t)=>e+" ".repeat(Math.max(0,t-e.length)),c=s[0],d=c.some(e=>e.isHeader),u=Array.from({length:o}).fill(null);s.forEach(e=>{var t;for(let n=0;n<o;n+=1)!u[n]&&(null==(t=e[n])?void 0:t.align)&&(u[n]=e[n].align)});let p="\n",h=Array.from({length:o}).map((e,t)=>d&&c[t]&&c[t].text||"");return p+=`| ${h.map((e,t)=>l(e,a[t])).join(" | ")} |
|
|
120
|
+
| ${a.map((e,t)=>{let n=Math.max(3,e),r=u[t];return"left"===r?`:${"-".repeat(n)}`:"right"===r?`${"-".repeat(n)}:`:"center"===r?`:${"-".repeat(n)}:`:"-".repeat(n)}).join(" | ")} |
|
|
121
|
+
`,(d?s.slice(1):s).forEach(e=>{p+=`| ${Array.from({length:o}).fill(0).map((t,n)=>l(e[n]&&e[n].text||"",a[n])).join(" | ")} |
|
|
122
|
+
`}),p},bk=pT.create({name:"table",addOptions:()=>({HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:bx,lastColumnResizable:!0,allowTableNodeSelection:!1}),content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML:()=>[{tag:"table"}],renderHTML({node:e,HTMLAttributes:t}){let{colgroup:n,tableWidth:r,tableMinWidth:i}=function(e,t){let n=0,r=!0,i=[],s=e.firstChild;if(!s)return{};for(let e=0,o=0;e<s.childCount;e+=1){let{colspan:a,colwidth:l}=s.child(e).attrs;for(let e=0;e<a;e+=1,o+=1){let s=void 0===o?void 0:l&&l[e];n+=s||t,s||(r=!1);let[a,c]=bg(t,s);i.push(["col",{style:`${a}: ${c}`}])}}return{colgroup:["colgroup",{},...i],tableWidth:r?`${n}px`:"",tableMinWidth:r?"":`${n}px`}}(e,this.options.cellMinWidth),s=t.style,o=["table",uc(this.options.HTMLAttributes,t,{style:s||(r?`width: ${r}`:`min-width: ${i}`)}),n,["tbody",0]];return this.options.renderWrapper?["div",{class:"tableWrapper"},o]:o},parseMarkdown:(e,t)=>{let n=[],r=Array.isArray(e.align)?e.align:[];if(e.header){let i=[];e.header.forEach((e,n)=>{var s;let o=bu(null!=(s=r[n])?s:e.align);i.push(t.createNode("tableHeader",o?{align:o}:{},[{type:"paragraph",content:t.parseInline(e.tokens)}]))}),n.push(t.createNode("tableRow",{},i))}return e.rows&&e.rows.forEach(e=>{let i=[];e.forEach((e,n)=>{var s;let o=bu(null!=(s=r[n])?s:e.align);i.push(t.createNode("tableCell",o?{align:o}:{},[{type:"paragraph",content:t.parseInline(e.tokens)}]))}),n.push(t.createNode("tableRow",{},i))}),t.createNode("table",void 0,n)},renderMarkdown:(e,t)=>bw(e,t),addCommands:()=>({insertTable:({rows:e=3,cols:t=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:i,editor:s})=>{let o=function(e,t,n,r){let i=function(e){if(e.cached.tableNodeTypes)return e.cached.tableNodeTypes;let t={};return Object.keys(e.nodes).forEach(n=>{let r=e.nodes[n];r.spec.tableRole&&(t[r.spec.tableRole]=r)}),e.cached.tableNodeTypes=t,t}(e),s=[],o=[];for(let e=0;e<n;e+=1){let e=by(i.cell,void 0);if(e&&o.push(e),r){let e=by(i.header_cell,void 0);e&&s.push(e)}}let a=[];for(let e=0;e<t;e+=1)a.push(i.row.createChecked(null,r&&0===e?s:o));return i.table.createChecked(null,a)}(s.schema,e,t,n);if(i){let e=r.selection.from+1;r.replaceSelectionWith(o).scrollIntoView().setSelection(sz.near(r.doc.resolve(e)))}return!0},addColumnBefore:()=>({state:e,dispatch:t})=>(function(e,t){if(!l$(e))return!1;if(t){let n=l6(e);t(l9(e.tr,n,n.left))}return!0})(e,t),addColumnAfter:()=>({state:e,dispatch:t})=>(function(e,t){if(!l$(e))return!1;if(t){let n=l6(e);t(l9(e.tr,n,n.right))}return!0})(e,t),deleteColumn:()=>({state:e,dispatch:t})=>(function(e,t){if(!l$(e))return!1;if(t){let n=l6(e),r=e.tr;if(0==n.left&&n.right==n.map.width)return!1;for(let e=n.right-1;!function(e,{map:t,table:n,tableStart:r},i){let s=e.mapping.maps.length;for(let o=0;o<t.height;){let a=o*t.width+i,l=t.map[a],c=n.nodeAt(l),d=c.attrs;if(i>0&&t.map[a-1]==l||i<t.width-1&&t.map[a+1]==l)e.setNodeMarkup(e.mapping.slice(s).map(r+l),null,lV(d,i-t.colCount(l)));else{let t=e.mapping.slice(s).map(r+l);e.delete(t,t+c.nodeSize)}o+=d.rowspan}}(r,n,e),e!=n.left;e--){let e=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!e)throw RangeError("No table found");n.table=e,n.map=lI.get(e)}t(r)}return!0})(e,t),addRowBefore:()=>({state:e,dispatch:t})=>(function(e,t){if(!l$(e))return!1;if(t){let n=l6(e);t(l7(e.tr,n,n.top))}return!0})(e,t),addRowAfter:()=>({state:e,dispatch:t})=>(function(e,t){if(!l$(e))return!1;if(t){let n=l6(e);t(l7(e.tr,n,n.bottom))}return!0})(e,t),deleteRow:()=>({state:e,dispatch:t})=>(function(e,t){if(!l$(e))return!1;if(t){let n=l6(e),r=e.tr;if(0==n.top&&n.bottom==n.map.height)return!1;for(let e=n.bottom-1;!function(e,{map:t,table:n,tableStart:r},i){let s=0;for(let e=0;e<i;e++)s+=n.child(e).nodeSize;let o=s+n.child(i).nodeSize,a=e.mapping.maps.length;e.delete(s+r,o+r);let l=new Set;for(let s=0,o=i*t.width;s<t.width;s++,o++){let c=t.map[o];if(!l.has(c)){if(l.add(c),i>0&&c==t.map[o-t.width]){let t=n.nodeAt(c).attrs;e.setNodeMarkup(e.mapping.slice(a).map(c+r),null,{...t,rowspan:t.rowspan-1}),s+=t.colspan-1}else if(i<t.height&&c==t.map[o+t.width]){let o=n.nodeAt(c),l=o.attrs,d=o.type.create({...l,rowspan:o.attrs.rowspan-1},o.content),u=t.positionAt(i+1,s,n);e.insert(e.mapping.slice(a).map(r+u),d),s+=l.colspan-1}}}}(r,n,e),e!=n.top;e--){let e=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!e)throw RangeError("No table found");n.table=e,n.map=lI.get(n.table)}t(r)}return!0})(e,t),deleteTable:()=>({state:e,dispatch:t})=>(function(e,t){let n=e.selection.$anchor;for(let r=n.depth;r>0;r--)if("table"==n.node(r).type.spec.tableRole)return t&&t(e.tr.delete(n.before(r),n.after(r)).scrollIntoView()),!0;return!1})(e,t),mergeCells:()=>({state:e,dispatch:t})=>ce(e,t),splitCell:()=>({state:e,dispatch:t})=>ct(e,t),toggleHeaderColumn:()=>({state:e,dispatch:t})=>cr("column")(e,t),toggleHeaderRow:()=>({state:e,dispatch:t})=>cr("row")(e,t),toggleHeaderCell:()=>({state:e,dispatch:t})=>ci(e,t),mergeOrSplit:()=>({state:e,dispatch:t})=>!!ce(e,t)||ct(e,t),setCellAttribute:(e,t)=>({state:n,dispatch:r})=>(function(n,r){if(!l$(n))return!1;let i=lB(n);if(i.nodeAfter.attrs[e]===t)return!1;if(r){let s=n.tr;n.selection instanceof lq?n.selection.forEachCell((n,r)=>{n.attrs[e]!==t&&s.setNodeMarkup(r,null,{...n.attrs,[e]:t})}):s.setNodeMarkup(i.pos,null,{...i.nodeAfter.attrs,[e]:t}),r(s)}return!0})(n,r),goToNextCell:()=>({state:e,dispatch:t})=>cs(1)(e,t),goToPreviousCell:()=>({state:e,dispatch:t})=>cs(-1)(e,t),fixTables:()=>({state:e,dispatch:t})=>(t&&lZ(e),!0),setCellSelection:e=>({tr:t,dispatch:n})=>{if(n){let n=lq.create(t.doc,e.anchorCell,e.headCell);t.setSelection(n)}return!0}}),addKeyboardShortcuts(){return{Tab:()=>!!this.editor.commands.goToNextCell()||!!this.editor.can().addRowAfter()&&this.editor.chain().addRowAfter().goToNextCell().run(),"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:bv,"Mod-Backspace":bv,Delete:bv,"Mod-Delete":bv}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[function({handleWidth:e=5,cellMinWidth:t=25,defaultCellMinWidth:n=100,View:r=cw,lastColumnResizable:i=!0}={}){let s=new sY({key:cN,state:{init(e,t){var i;let o=null==(i=s.spec)||null==(i=i.props)?void 0:i.nodeViews,a=lL(t.schema).table.name;return r&&o&&(o[a]=(e,t)=>new r(e,n,t)),new cS(-1,!1)},apply:(e,t)=>t.apply(e)},props:{attributes:e=>{let t=cN.getState(e);return t&&t.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(t,n)=>{!function(e,t,n,r){if(!e.editable)return;let i=cN.getState(e.state);if(i&&!i.dragging){let s=function(e){for(;e&&"TD"!=e.nodeName&&"TH"!=e.nodeName;)e=e.classList&&e.classList.contains("ProseMirror")?null:e.parentNode;return e}(t.target),o=-1;if(s){let{left:r,right:i}=s.getBoundingClientRect();t.clientX-r<=n?o=cC(e,t,"left",n):i-t.clientX<=n&&(o=cC(e,t,"right",n))}if(o!=i.activeHandle){if(!r&&-1!==o){let t=e.state.doc.resolve(o),n=t.node(-1),r=lI.get(n),i=t.start(-1);if(r.colCount(t.pos-i)+t.nodeAfter.attrs.colspan-1==r.width-1)return}cE(e,o)}}}(t,n,e,i)},mouseleave:e=>{!function(e){if(!e.editable)return;let t=cN.getState(e.state);t&&t.activeHandle>-1&&!t.dragging&&cE(e,-1)}(e)},mousedown:(e,r)=>{!function(e,t,n,r){var i;if(!e.editable)return;let s=null!=(i=e.dom.ownerDocument.defaultView)?i:window,o=cN.getState(e.state);if(!o||-1==o.activeHandle||o.dragging)return;let a=e.state.doc.nodeAt(o.activeHandle),l=function(e,t,{colspan:n,colwidth:r}){let i=r&&r[r.length-1];if(i)return i;let s=e.domAtPos(t),o=s.node.childNodes[s.offset].offsetWidth,a=n;if(r)for(let e=0;e<n;e++)r[e]&&(o-=r[e],a--);return o/a}(e,o.activeHandle,a.attrs);function c(t){s.removeEventListener("mouseup",c),s.removeEventListener("mousemove",d);let r=cN.getState(e.state);(null==r?void 0:r.dragging)&&(function(e,t,n){let r=e.state.doc.resolve(t),i=r.node(-1),s=lI.get(i),o=r.start(-1),a=s.colCount(r.pos-o)+r.nodeAfter.attrs.colspan-1,l=e.state.tr;for(let e=0;e<s.height;e++){let t=e*s.width+a;if(e&&s.map[t]==s.map[t-s.width])continue;let r=s.map[t],c=i.nodeAt(r).attrs,d=1==c.colspan?0:a-s.colCount(r);if(c.colwidth&&c.colwidth[d]==n)continue;let u=c.colwidth?c.colwidth.slice():Array(c.colspan).fill(0);u[d]=n,l.setNodeMarkup(o+r,null,{...c,colwidth:u})}l.docChanged&&e.dispatch(l)}(e,r.activeHandle,cj(r.dragging,t,n)),e.dispatch(e.state.tr.setMeta(cN,{setDragging:null})))}function d(t){if(!t.which)return c(t);let i=cN.getState(e.state);if(i&&i.dragging){let s=cj(i.dragging,t,n);cM(e,i.activeHandle,s,r)}}e.dispatch(e.state.tr.setMeta(cN,{setDragging:{startX:t.clientX,startWidth:l}})),cM(e,o.activeHandle,l,r),s.addEventListener("mouseup",c),s.addEventListener("mousemove",d),t.preventDefault()}(e,r,t,n)}},decorations:e=>{let t=cN.getState(e);if(t&&t.activeHandle>-1)return function(e,t){let n=[],r=e.doc.resolve(t),i=r.node(-1);if(!i)return a6.empty;let s=lI.get(i),o=r.start(-1),a=s.colCount(r.pos-o)+r.nodeAfter.attrs.colspan-1;for(let t=0;t<s.height;t++){let r=a+t*s.width;if((a==s.width-1||s.map[r]!=s.map[r+1])&&(0==t||s.map[r]!=s.map[r-s.width])){var l;let t=s.map[r],a=o+t+i.nodeAt(t).nodeSize-1,c=document.createElement("div");c.className="column-resize-handle",(null==(l=cN.getState(e))?void 0:l.dragging)&&n.push(a3.node(o+t,o+t+i.nodeAt(t).nodeSize,{class:"column-resize-dragging"})),n.push(a3.widget(a,c))}}return a6.create(e.doc,n)}(e,t.activeHandle)},nodeViews:{}}});return s}({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],function({allowTableNodeSelection:e=!1}={}){return new sY({key:lP,state:{init:()=>null,apply(e,t){let n=e.getMeta(lP);if(null!=n)return -1==n?null:n;if(null==t||!e.docChanged)return t;let{deleted:r,pos:i}=e.mapping.mapResult(t);return r?null:i}},props:{decorations:lG,handleDOMEvents:{mousedown:cb},createSelectionBetween:e=>null!=lP.getState(e.state)?e.state.selection:null,handleTripleClick:cm,handleKeyDown:cu,handlePaste:cg},appendTransaction:(t,n,r)=>(function(e,t,n){let r,i,s=(t||e).selection,o=(t||e).doc;if(s instanceof sB&&(i=s.node.type.spec.tableRole)){if("cell"==i||"header_cell"==i)r=lq.create(o,s.from);else if("row"==i){let e=o.resolve(s.from+1);r=lq.rowSelection(e,e)}else if(!n){let e=lI.get(s.node),t=s.from+1,n=t+e.map[e.width*e.height-1];r=lq.create(o,t+1,n)}}else s instanceof sz&&function({$from:e,$to:t}){if(e.pos==t.pos||e.pos<t.pos-6)return!1;let n=e.pos,r=t.pos,i=e.depth;for(;i>=0&&!(e.after(i+1)<e.end(i));i--,n++);for(let e=t.depth;e>=0&&!(t.before(e+1)>t.start(e));e--,r--);return n==r&&/row|table/.test(e.node(i).type.spec.tableRole)}(s)?r=sz.create(o,s.from):s instanceof sz&&function({$from:e,$to:t}){let n,r;for(let t=e.depth;t>0;t--){let r=e.node(t);if("cell"===r.type.spec.tableRole||"header_cell"===r.type.spec.tableRole){n=r;break}}for(let e=t.depth;e>0;e--){let n=t.node(e);if("cell"===n.type.spec.tableRole||"header_cell"===n.type.spec.tableRole){r=n;break}}return n!==r&&0===t.parentOffset}(s)&&(r=sz.create(o,s.$from.start(),s.$from.end()));return r&&(t||(t=e.tr)).setSelection(r),t})(r,lZ(r,n),e)})}({allowTableNodeSelection:this.options.allowTableNodeSelection})]},addNodeView(){let e=this.options.resizable&&this.editor.isEditable,t=this.options.View;return e||!t?null:({node:e,view:n})=>new t(e,this.options.cellMinWidth,n)},extendNodeSchema(e){let t={name:e.name,options:e.options,storage:e.storage};return{tableRole:us(ut(e,"tableRole",t))}}});pt.create({name:"tableKit",addExtensions(){let e=[];return!1!==this.options.table&&e.push(bk.configure(this.options.table)),!1!==this.options.tableCell&&e.push(bh.configure(this.options.tableCell)),!1!==this.options.tableHeader&&e.push(bf.configure(this.options.tableHeader)),!1!==this.options.tableRow&&e.push(bm.configure(this.options.tableRow)),e}});var bN=Object.defineProperty,bS="textStyle",bC=/^\s*([-+*])\s$/,bj=pT.create({name:"bulletList",addOptions:()=>({itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}),group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML:()=>[{tag:"ul"}],renderHTML({HTMLAttributes:e}){return["ul",uc(this.options.HTMLAttributes,e),0]},markdownTokenName:"list",parseMarkdown:(e,t)=>"list"!==e.type||e.ordered?[]:{type:"bulletList",content:e.items?t.parseChildren(e.items):[]},renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,"\n"):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes("listItem",this.editor.getAttributes(bS)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let e=py({find:bC,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(e=py({find:bC,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(bS),editor:this.editor})),[e]}}),bE=pT.create({name:"listItem",addOptions:()=>({HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}),content:"paragraph block*",defining:!0,parseHTML:()=>[{tag:"li"}],renderHTML({HTMLAttributes:e}){return["li",uc(this.options.HTMLAttributes,e),0]},markdownTokenName:"list_item",parseMarkdown:(e,t)=>{var n,r,i,s;if("list_item"!==e.type)return[];let o=null!=(n=t.parseBlockChildren)?n:t.parseChildren,a=[];if(e.tokens&&e.tokens.length>0){let n;if(n=null==(r=e.tokens)?void 0:r[0],e.text&&(null==(i=e.tokens)?void 0:i.length)===1&&(null==n?void 0:n.type)==="list"&&n.ordered&&n.raw===e.text)return{type:"listItem",content:[{type:"paragraph",content:(s=e.text||"",t.tokenizeInline?t.parseInline(t.tokenizeInline(s)):t.parseInline([{type:"text",raw:s,text:s}]))}]};if(e.tokens.some(e=>"paragraph"===e.type))a=o(e.tokens);else{let n=e.tokens[0];if(n&&"text"===n.type&&n.tokens&&n.tokens.length>0){if(a=[{type:"paragraph",content:t.parseInline(n.tokens)}],e.tokens.length>1){let t=o(e.tokens.slice(1));a.push(...t)}}else a=o(e.tokens)}}return 0===a.length&&(a=[{type:"paragraph",content:[]}]),{type:"listItem",content:a}},renderMarkdown:(e,t,n)=>pA(e,t,e=>{var t,n;if("bulletList"===e.parentType)return"- ";if("orderedList"===e.parentType){let r=(null==(n=null==(t=e.meta)?void 0:t.parentAttrs)?void 0:n.start)||1;return`${r+e.index}. `}return"- "},n),addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),bM={},bA={findListItemPos:()=>bO,getNextListDepth:()=>b_,handleBackspace:()=>bL,handleDelete:()=>b$,hasListBefore:()=>bD,hasListItemAfter:()=>bB,hasListItemBefore:()=>bR,listItemHasSubList:()=>bI,nextListIsDeeper:()=>bP,nextListIsHigher:()=>bz};for(var bT in bA)bN(bM,bT,{get:bA[bT],enumerable:!0});var bO=(e,t)=>{let{$from:n}=t.selection,r=ds(e,t.schema),i=n.depth,s=n.pos,o=null;for(;i>0&&null===o;)n.node(i).type===r?o=i:(i-=1,s-=1);return null===o?null:{$pos:t.doc.resolve(s),depth:o}},b_=(e,t)=>{let n=bO(e,t);if(!n)return!1;let[,r]=((e,t,n,r=20)=>{let i=e.doc.resolve(n),s=r,o=null;for(;s>0&&null===o;){let e=i.node(s);(null==e?void 0:e.type.name)===t?o=e:s-=1}return[o,s]})(t,e,n.$pos.pos+4);return r},bD=(e,t,n)=>{let{$anchor:r}=e.selection,i=Math.max(0,r.pos-2),s=e.doc.resolve(i).node();return!!s&&!!n.includes(s.type.name)},bR=(e,t)=>{var n;let{$anchor:r}=t.selection,i=t.doc.resolve(r.pos-2);return 0!==i.index()&&(null==(n=i.nodeBefore)?void 0:n.type.name)===e},bI=(e,t,n)=>{if(!n)return!1;let r=ds(e,t.schema),i=!1;return n.descendants(e=>{e.type===r&&(i=!0)}),i},bL=(e,t,n)=>{if(e.commands.undoInputRule())return!0;if(e.state.selection.from!==e.state.selection.to)return!1;if(!dU(e.state,t)&&bD(e.state,t,n)){let{$anchor:n}=e.state.selection,r=e.state.doc.resolve(n.before()-1),i=[];r.node().descendants((e,n)=>{e.type.name===t&&i.push({node:e,pos:n})});let s=i.at(-1);if(!s)return!1;let o=e.state.doc.resolve(r.start()+s.pos+1);return e.chain().cut({from:n.start()-1,to:n.end()+1},o.end()).joinForward().run()}if(!dU(e.state,t)||!(e=>{let{$from:t,$to:n}=e.selection;return!(t.parentOffset>0)&&t.pos===n.pos})(e.state))return!1;let r=bO(t,e.state);if(!r)return!1;let i=e.state.doc.resolve(r.$pos.pos-2).node(r.depth),s=bI(t,e.state,i);return bR(t,e.state)&&!s?e.commands.joinItemBackward():e.chain().liftListItem(t).run()},bP=(e,t)=>{let n=b_(e,t),r=bO(e,t);return!!r&&!!n&&n>r.depth},bz=(e,t)=>{let n=b_(e,t),r=bO(e,t);return!!r&&!!n&&n<r.depth},b$=(e,t)=>{if(!dU(e.state,t)||!((e,t)=>{let{$from:n,$to:r,$anchor:i}=e.selection;if(t){let n=ue(e=>e.type.name===t)(e.selection);if(!n)return!1;let r=e.doc.resolve(n.pos+1);return i.pos+1===r.end()}return!(r.parentOffset<r.parent.nodeSize-2)&&n.pos===r.pos})(e.state,t))return!1;let{selection:n}=e.state,{$from:r,$to:i}=n;return!(!n.empty&&r.sameParent(i))&&(bP(t,e.state)?e.chain().focus(e.state.selection.from+4).lift(t).joinBackward().run():bz(t,e.state)?e.chain().joinForward().joinBackward().run():e.commands.joinItemForward())},bB=(e,t)=>{var n;let{$anchor:r}=t.selection,i=t.doc.resolve(r.pos-r.parentOffset-2);return i.index()!==i.parent.childCount-1&&(null==(n=i.nodeAfter)?void 0:n.type.name)===e},bF=pt.create({name:"listKeymap",addOptions:()=>({listTypes:[{itemName:"listItem",wrapperNames:["bulletList","orderedList"]},{itemName:"taskItem",wrapperNames:["taskList"]}]}),addKeyboardShortcuts(){return{Delete:({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n})=>{void 0!==e.state.schema.nodes[n]&&b$(e,n)&&(t=!0)}),t},"Mod-Delete":({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n})=>{void 0!==e.state.schema.nodes[n]&&b$(e,n)&&(t=!0)}),t},Backspace:({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{void 0!==e.state.schema.nodes[n]&&bL(e,n,r)&&(t=!0)}),t},"Mod-Backspace":({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{void 0!==e.state.schema.nodes[n]&&bL(e,n,r)&&(t=!0)}),t}}}}),bH=/^(\s*)(\d+)\.\s+(.*)$/,bU=/^\s/,bV="textStyle",bW=/^(\d+)\.\s$/,bq=pT.create({name:"orderedList",addOptions:()=>({itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}),group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes:()=>({start:{default:1,parseHTML:e=>e.hasAttribute("start")?parseInt(e.getAttribute("start")||"",10):1},type:{default:null,parseHTML:e=>e.getAttribute("type")}}),parseHTML:()=>[{tag:"ol"}],renderHTML({HTMLAttributes:e}){let{start:t,...n}=e;return 1===t?["ol",uc(this.options.HTMLAttributes,n),0]:["ol",uc(this.options.HTMLAttributes,e),0]},markdownTokenName:"list",parseMarkdown:(e,t)=>{var n;if("list"!==e.type||!e.ordered)return[];let r=e.start||1,i=e.items?(n=e.items,n.map(e=>{if("list_item"!==e.type)return t.parseChildren([e])[0];let n=[];return e.tokens&&e.tokens.length>0&&e.tokens.forEach(e=>{if("paragraph"===e.type||"list"===e.type||"blockquote"===e.type||"code"===e.type)n.push(...t.parseChildren([e]));else if("text"===e.type&&e.tokens){let r=t.parseChildren([e]);n.push({type:"paragraph",content:r})}else{let r=t.parseChildren([e]);r.length>0&&n.push(...r)}}),{type:"listItem",content:n}})):[];return 1!==r?{type:"orderedList",attrs:{start:r},content:i}:{type:"orderedList",content:i}},renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,"\n"):"",markdownTokenizer:{name:"orderedList",level:"block",start:e=>{let t=e.match(/^(\s*)(\d+)\.\s+/),n=null==t?void 0:t.index;return void 0!==n?n:-1},tokenize:(e,t,n)=>{var r;let i=e.split("\n"),[s,o]=function(e){let t=[],n=0,r=0;for(;n<e.length;){let i=e[n],s=i.match(bH);if(!s)break;let[,o,a,l]=s,c=o.length,d=[l],u=n+1,p=[i],h=!1;for(;u<e.length;){let t=e[u];if(t.match(bH))break;if(""===t.trim())p.push(t),d.push(""),h=!0,u+=1;else if(t.match(bU))p.push(t),d.push(t.slice(c+2)),u+=1;else{if(h)break;p.push(t),d.push(t),u+=1}}t.push({indent:c,number:parseInt(a,10),content:d.join("\n").trim(),contentLines:d,raw:p.join("\n")}),r=u,n=u}return[t,r]}(i);if(0===s.length)return;let a=function e(t,n,r){let i=[],s=0;for(;s<t.length;){let o=t[s];if(o.indent===n){let{paragraphLines:a,blockLines:l}=function(e){let t=[],n=[],r=!1;return e.forEach(e=>{let i;if(r)return void n.push(e);if(""===e.trim()||t.length>0&&(i=e.trimStart(),/^[-+*]\s+/.test(i)||/^\d+\.\s+/.test(i)||/^>\s?/.test(i)||/^```/.test(i)||/^~~~/.test(i))){r=!0,n.push(e);return}t.push(e)}),{paragraphLines:t,blockLines:n}}(o.contentLines),c=a.join("\n").trim(),d=[];c&&d.push({type:"paragraph",raw:c,tokens:r.inlineTokens(c)});let u=l.join("\n").trim();if(u){let e=r.blockTokens(u);d.push(...e)}let p=s+1,h=[];for(;p<t.length&&t[p].indent>n;)h.push(t[p]),p+=1;if(h.length>0){let t=Math.min(...h.map(e=>e.indent)),n=e(h,t,r);d.push({type:"list",ordered:!0,start:h[0].number,items:n,raw:h.map(e=>e.raw).join("\n")})}i.push({type:"list_item",raw:o.raw,tokens:d}),s=p}else s+=1}return i}(s,0,n);if(0!==a.length)return{type:"list",ordered:!0,start:(null==(r=s[0])?void 0:r.number)||1,items:a,raw:i.slice(0,o).join("\n")}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes("listItem",this.editor.getAttributes(bV)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let e=py({find:bW,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(e=py({find:bW,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(bV)}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1],editor:this.editor})),[e]}}),bK=/^\s*(\[([( |x])?\])\s$/,bG=pT.create({name:"taskItem",addOptions:()=>({nested:!1,HTMLAttributes:{},taskListTypeName:"taskList",a11y:void 0}),content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes:()=>({checked:{default:!1,keepOnSplit:!1,parseHTML:e=>{let t=e.getAttribute("data-checked");return""===t||"true"===t},renderHTML:e=>({"data-checked":e.checked})}}),parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:e,HTMLAttributes:t}){return["li",uc(this.options.HTMLAttributes,t,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:e.attrs.checked?"checked":null}],["span"]],["div",0]]},parseMarkdown:(e,t)=>{let n=[];if(e.tokens&&e.tokens.length>0?n.push(t.createNode("paragraph",{},t.parseInline(e.tokens))):e.text?n.push(t.createNode("paragraph",{},[t.createNode("text",{text:e.text})])):n.push(t.createNode("paragraph",{},[])),e.nestedTokens&&e.nestedTokens.length>0){let r=t.parseChildren(e.nestedTokens);n.push(...r)}return t.createNode("taskItem",{checked:e.checked||!1},n)},renderMarkdown:(e,t)=>{var n;let r=(null==(n=e.attrs)?void 0:n.checked)?"x":" ";return pA(e,t,`- [${r}] `)},addKeyboardShortcuts(){let e={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...e,Tab:()=>this.editor.commands.sinkListItem(this.name)}:e},addNodeView(){return({node:e,HTMLAttributes:t,getPos:n,editor:r})=>{let i=document.createElement("li"),s=document.createElement("label"),o=document.createElement("span"),a=document.createElement("input"),l=document.createElement("div"),c=e=>{var t,n;a.ariaLabel=(null==(n=null==(t=this.options.a11y)?void 0:t.checkboxLabel)?void 0:n.call(t,e,a.checked))||`Task item checkbox for ${e.textContent||"empty task item"}`};c(e),s.contentEditable="false",a.type="checkbox",a.addEventListener("mousedown",e=>e.preventDefault()),a.addEventListener("change",t=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){a.checked=!a.checked;return}let{checked:i}=t.target;r.isEditable&&"function"==typeof n&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:e})=>{let t=n();if("number"!=typeof t)return!1;let r=e.doc.nodeAt(t);return e.setNodeMarkup(t,void 0,{...null==r?void 0:r.attrs,checked:i}),!0}).run(),r.isEditable||!this.options.onReadOnlyChecked||this.options.onReadOnlyChecked(e,i)||(a.checked=!a.checked)}),Object.entries(this.options.HTMLAttributes).forEach(([e,t])=>{i.setAttribute(e,t)}),i.dataset.checked=e.attrs.checked,a.checked=e.attrs.checked,s.append(a,o),i.append(s,l),Object.entries(t).forEach(([e,t])=>{i.setAttribute(e,t)});let d=new Set(Object.keys(t));return{dom:i,contentDOM:l,update:e=>{if(e.type!==this.type)return!1;i.dataset.checked=e.attrs.checked,a.checked=e.attrs.checked,c(e);let t=ud(e,r.extensionManager.attributes),n=new Set(Object.keys(t)),s=this.options.HTMLAttributes;return d.forEach(e=>{n.has(e)||(e in s?i.setAttribute(e,s[e]):i.removeAttribute(e))}),Object.entries(t).forEach(([e,t])=>{null==t?e in s?i.setAttribute(e,s[e]):i.removeAttribute(e):i.setAttribute(e,t)}),d=n,!0}}}},addInputRules(){return[py({find:bK,type:this.type,getAttributes:e=>({checked:"x"===e[e.length-1]})})]}}),bJ=pT.create({name:"taskList",addOptions:()=>({itemTypeName:"taskItem",HTMLAttributes:{}}),group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:e}){return["ul",uc(this.options.HTMLAttributes,e,{"data-type":this.name}),0]},parseMarkdown:(e,t)=>t.createNode("taskList",{},t.parseChildren(e.items||[])),renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,"\n"):"",markdownTokenizer:{name:"taskList",level:"block",start(e){var t;let n=null==(t=e.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))?void 0:t.index;return void 0!==n?n:-1},tokenize(e,t,n){let r=e=>{let t=pM(e,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:e=>({indentLevel:e[1].length,mainContent:e[4],checked:"x"===e[3].toLowerCase()}),createToken:(e,t)=>({type:"taskItem",raw:"",mainContent:e.mainContent,indentLevel:e.indentLevel,checked:e.checked,text:e.mainContent,tokens:n.inlineTokens(e.mainContent),nestedTokens:t}),customNestedParser:r},n);return t?[{type:"taskList",raw:t.raw,items:t.items}]:n.blockTokens(e)},i=pM(e,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:e=>({indentLevel:e[1].length,mainContent:e[4],checked:"x"===e[3].toLowerCase()}),createToken:(e,t)=>({type:"taskItem",raw:"",mainContent:e.mainContent,indentLevel:e.indentLevel,checked:e.checked,text:e.mainContent,tokens:n.inlineTokens(e.mainContent),nestedTokens:t}),customNestedParser:r},n);if(i)return{type:"taskList",raw:i.raw,items:i.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:e})=>e.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});pt.create({name:"listKit",addExtensions(){let e=[];return!1!==this.options.bulletList&&e.push(bj.configure(this.options.bulletList)),!1!==this.options.listItem&&e.push(bE.configure(this.options.listItem)),!1!==this.options.listKeymap&&e.push(bF.configure(this.options.listKeymap)),!1!==this.options.orderedList&&e.push(bq.configure(this.options.orderedList)),!1!==this.options.taskItem&&e.push(bG.configure(this.options.taskItem)),!1!==this.options.taskList&&e.push(bJ.configure(this.options.taskList)),e}});var bZ=pt.create({name:"textAlign",addOptions:()=>({types:[],alignments:["left","center","right","justify"],defaultAlignment:null}),addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:e=>{let t=e.style.textAlign;return this.options.alignments.includes(t)?t:this.options.defaultAlignment},renderHTML:e=>e.textAlign?{style:`text-align: ${e.textAlign}`}:{}}}}]},addCommands(){return{setTextAlign:e=>({commands:t})=>!!this.options.alignments.includes(e)&&this.options.types.map(n=>t.updateAttributes(n,{textAlign:e})).some(e=>e),unsetTextAlign:()=>({commands:e})=>this.options.types.map(t=>e.resetAttributes(t,"textAlign")).some(e=>e),toggleTextAlign:e=>({editor:t,commands:n})=>!!this.options.alignments.includes(e)&&(t.isActive({textAlign:e})?n.unsetTextAlign():n.setTextAlign(e))}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}}),bX=(e,t)=>{if("slot"===e)return 0;if(e instanceof Function)return e(t);let{children:n,...r}=null!=t?t:{};if("svg"===e)throw Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");return[e,r,n]},bY=/^\s*>\s$/,bQ=pT.create({name:"blockquote",addOptions:()=>({HTMLAttributes:{}}),content:"block+",group:"block",defining:!0,parseHTML:()=>[{tag:"blockquote"}],renderHTML({HTMLAttributes:e}){return bX("blockquote",{...uc(this.options.HTMLAttributes,e),children:bX("slot",{})})},parseMarkdown:(e,t)=>{var n;let r=null!=(n=t.parseBlockChildren)?n:t.parseChildren;return t.createNode("blockquote",void 0,r(e.tokens||[]))},renderMarkdown:(e,t)=>{if(!e.content)return"";let n=[];return e.content.forEach((e,r)=>{var i,s;let o=(null!=(s=null==(i=t.renderChild)?void 0:i.call(t,e,r))?s:t.renderChildren([e])).split("\n").map(e=>""===e.trim()?">":`> ${e}`);n.push(o.join("\n"))}),n.join(`
|
|
123
|
+
>
|
|
124
|
+
`)},addCommands(){return{setBlockquote:()=>({commands:e})=>e.wrapIn(this.name),toggleBlockquote:()=>({commands:e})=>e.toggleWrap(this.name),unsetBlockquote:()=>({commands:e})=>e.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[py({find:bY,type:this.type})]}}),b0=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,b1=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,b2=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,b3=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,b5=u9.create({name:"bold",addOptions:()=>({HTMLAttributes:{}}),parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:e=>"normal"!==e.style.fontWeight&&null},{style:"font-weight=400",clearMark:e=>e.type.name===this.name},{style:"font-weight",getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}]},renderHTML({HTMLAttributes:e}){return bX("strong",{...uc(this.options.HTMLAttributes,e),children:bX("slot",{})})},markdownTokenName:"strong",parseMarkdown:(e,t)=>t.applyMark("bold",t.parseInline(e.tokens||[])),markdownOptions:{htmlReopen:{open:"<strong>",close:"</strong>"}},renderMarkdown:(e,t)=>`**${t.renderChildren(e)}**`,addCommands(){return{setBold:()=>({commands:e})=>e.setMark(this.name),toggleBold:()=>({commands:e})=>e.toggleMark(this.name),unsetBold:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[pg({find:b0,type:this.type}),pg({find:b2,type:this.type})]},addPasteRules(){return[p_({find:b1,type:this.type}),p_({find:b3,type:this.type})]}}),b4=/(^|[^`])`([^`]+)`(?!`)$/,b6=/(^|[^`])`([^`]+)`(?!`)/g,b9=u9.create({name:"code",addOptions:()=>({HTMLAttributes:{}}),excludes:"_",code:!0,exitable:!0,parseHTML:()=>[{tag:"code"}],renderHTML({HTMLAttributes:e}){return["code",uc(this.options.HTMLAttributes,e),0]},markdownTokenName:"codespan",parseMarkdown:(e,t)=>t.applyMark("code",[{type:"text",text:e.text||""}]),renderMarkdown:(e,t)=>e.content?`\`${t.renderChildren(e.content)}\``:"",addCommands(){return{setCode:()=>({commands:e})=>e.setMark(this.name),toggleCode:()=>({commands:e})=>e.toggleMark(this.name),unsetCode:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[pg({find:b4,type:this.type})]},addPasteRules(){return[p_({find:b6,type:this.type})]}}),b7=/^```([a-z]+)?[\s\n]$/,b8=/^~~~([a-z]+)?[\s\n]$/,xe=pT.create({name:"codeBlock",addOptions:()=>({languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:4,HTMLAttributes:{}}),content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:e=>{var t;let{languageClassPrefix:n}=this.options;if(!n)return null;let r=[...(null==(t=e.firstElementChild)?void 0:t.classList)||[]].filter(e=>e.startsWith(n)).map(e=>e.replace(n,""))[0];return r||null},rendered:!1}}},parseHTML:()=>[{tag:"pre",preserveWhitespace:"full"}],renderHTML({node:e,HTMLAttributes:t}){return["pre",uc(this.options.HTMLAttributes,t),["code",{class:e.attrs.language?this.options.languageClassPrefix+e.attrs.language:null},0]]},markdownTokenName:"code",parseMarkdown:(e,t)=>{var n,r;return(null==(n=e.raw)?void 0:n.startsWith("```"))===!1&&(null==(r=e.raw)?void 0:r.startsWith("~~~"))===!1&&"indented"!==e.codeBlockStyle?[]:t.createNode("codeBlock",{language:e.lang||null},e.text?[t.createTextNode(e.text)]:[])},renderMarkdown:(e,t)=>{var n;let r=(null==(n=e.attrs)?void 0:n.language)||"";return e.content?[`\`\`\`${r}`,t.renderChildren(e.content),"```"].join("\n"):`\`\`\`${r}
|
|
125
|
+
|
|
126
|
+
\`\`\``},addCommands(){return{setCodeBlock:e=>({commands:t})=>t.setNode(this.name,e),toggleCodeBlock:e=>({commands:t})=>t.toggleNode(this.name,"paragraph",e)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{let{empty:e,$anchor:t}=this.editor.state.selection,n=1===t.pos;return!!e&&t.parent.type.name===this.name&&(!!n||!t.parent.textContent.length)&&this.editor.commands.clearNodes()},Tab:({editor:e})=>{var t;if(!this.options.enableTabIndentation)return!1;let n=null!=(t=this.options.tabSize)?t:4,{state:r}=e,{selection:i}=r,{$from:s,empty:o}=i;if(s.parent.type!==this.type)return!1;let a=" ".repeat(n);return o?e.commands.insertContent(a):e.commands.command(({tr:e})=>{let{from:t,to:n}=i,s=r.doc.textBetween(t,n,"\n","\n").split("\n").map(e=>a+e).join("\n");return e.replaceWith(t,n,r.schema.text(s)),!0})},"Shift-Tab":({editor:e})=>{var t;if(!this.options.enableTabIndentation)return!1;let n=null!=(t=this.options.tabSize)?t:4,{state:r}=e,{selection:i}=r,{$from:s,empty:o}=i;return s.parent.type===this.type&&(o?e.commands.command(({tr:e})=>{var t;let{pos:i}=s,o=s.start(),a=s.end(),l=r.doc.textBetween(o,a,"\n","\n").split("\n"),c=0,d=0,u=i-o;for(let e=0;e<l.length;e+=1){if(d+l[e].length>=u){c=e;break}d+=l[e].length+1}let p=Math.min(((null==(t=l[c].match(/^ */))?void 0:t[0])||"").length,n);if(0===p)return!0;let h=o;for(let e=0;e<c;e+=1)h+=l[e].length+1;return e.delete(h,h+p),i-h<=p&&e.setSelection(sz.create(e.doc,h)),!0}):e.commands.command(({tr:e})=>{let{from:t,to:s}=i,o=r.doc.textBetween(t,s,"\n","\n").split("\n").map(e=>{var t;let r=Math.min(((null==(t=e.match(/^ */))?void 0:t[0])||"").length,n);return e.slice(r)}).join("\n");return e.replaceWith(t,s,r.schema.text(o)),!0}))},Enter:({editor:e})=>{if(!this.options.exitOnTripleEnter)return!1;let{state:t}=e,{selection:n}=t,{$from:r,empty:i}=n;if(!i||r.parent.type!==this.type)return!1;let s=r.parentOffset===r.parent.nodeSize-2,o=r.parent.textContent.endsWith("\n\n");return!!s&&!!o&&e.chain().command(({tr:e})=>(e.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:e})=>{if(!this.options.exitOnArrowDown)return!1;let{state:t}=e,{selection:n,doc:r}=t,{$from:i,empty:s}=n;if(!s||i.parent.type!==this.type||i.parentOffset!==i.parent.nodeSize-2)return!1;let o=i.after();return void 0!==o&&(r.nodeAt(o)?e.commands.command(({tr:e})=>(e.setSelection(sR.near(r.resolve(o))),!0)):e.commands.exitCode())}}},addInputRules(){return[px({find:b7,type:this.type,getAttributes:e=>({language:e[1]})}),px({find:b8,type:this.type,getAttributes:e=>({language:e[1]})})]},addProseMirrorPlugins(){return[new sY({key:new s1("codeBlockVSCodeHandler"),props:{handlePaste:(e,t)=>{if(!t.clipboardData||this.editor.isActive(this.type.name))return!1;let n=t.clipboardData.getData("text/plain"),r=t.clipboardData.getData("vscode-editor-data"),i=r?JSON.parse(r):void 0,s=null==i?void 0:i.mode;if(!n||!s)return!1;let{tr:o,schema:a}=e.state,l=a.text(n.replace(/\r\n?/g,"\n"));return o.replaceSelectionWith(this.type.create({language:s},l)),o.selection.$from.parent.type!==this.type&&o.setSelection(sz.near(o.doc.resolve(Math.max(0,o.selection.from-2)))),o.setMeta("paste",!0),e.dispatch(o),!0}}})]}}),xt=pT.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,"\n\n"):""}),xn=pT.create({name:"hardBreak",markdownTokenName:"br",addOptions:()=>({keepMarks:!0,HTMLAttributes:{}}),inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML:()=>[{tag:"br"}],renderHTML({HTMLAttributes:e}){return["br",uc(this.options.HTMLAttributes,e)]},renderText:()=>"\n",renderMarkdown:()=>`
|
|
127
|
+
`,parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:e,chain:t,state:n,editor:r})=>e.first([()=>e.exitCode(),()=>e.command(()=>{let{selection:e,storedMarks:i}=n;if(e.$from.parent.type.spec.isolating)return!1;let{keepMarks:s}=this.options,{splittableMarks:o}=r.extensionManager,a=i||e.$to.parentOffset&&e.$from.marks();return t().insertContent({type:this.name}).command(({tr:e,dispatch:t})=>{if(t&&a&&s){let t=a.filter(e=>o.includes(e.type.name));e.ensureMarks(t)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),xr=pT.create({name:"heading",addOptions:()=>({levels:[1,2,3,4,5,6],HTMLAttributes:{}}),content:"inline*",group:"block",defining:!0,addAttributes:()=>({level:{default:1,rendered:!1}}),parseHTML(){return this.options.levels.map(e=>({tag:`h${e}`,attrs:{level:e}}))},renderHTML({node:e,HTMLAttributes:t}){let n=this.options.levels.includes(e.attrs.level)?e.attrs.level:this.options.levels[0];return[`h${n}`,uc(this.options.HTMLAttributes,t),0]},parseMarkdown:(e,t)=>t.createNode("heading",{level:e.depth||1},t.parseInline(e.tokens||[])),renderMarkdown:(e,t)=>{var n;let r=(null==(n=e.attrs)?void 0:n.level)?parseInt(e.attrs.level,10):1,i="#".repeat(r);return e.content?`${i} ${t.renderChildren(e.content)}`:""},addCommands(){return{setHeading:e=>({commands:t})=>!!this.options.levels.includes(e.level)&&t.setNode(this.name,e),toggleHeading:e=>({commands:t})=>!!this.options.levels.includes(e.level)&&t.toggleNode(this.name,"paragraph",e)}},addKeyboardShortcuts(){return this.options.levels.reduce((e,t)=>({...e,[`Mod-Alt-${t}`]:()=>this.editor.commands.toggleHeading({level:t})}),{})},addInputRules(){return this.options.levels.map(e=>px({find:RegExp(`^(#{${Math.min(...this.options.levels)},${e}})\\s$`),type:this.type,getAttributes:{level:e}}))}}),xi=pT.create({name:"horizontalRule",addOptions:()=>({HTMLAttributes:{},nextNodeType:"paragraph"}),group:"block",parseHTML:()=>[{tag:"hr"}],renderHTML({HTMLAttributes:e}){return["hr",uc(this.options.HTMLAttributes,e)]},markdownTokenName:"hr",parseMarkdown:(e,t)=>t.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:e,state:t})=>{if(!function(e,t){let{selection:n}=e,{$from:r}=n;if(n instanceof sB){let e=r.index();return r.parent.canReplaceWith(e,e+1,t)}let i=r.depth;for(;i>=0;){let e=r.index(i);if(r.node(i).contentMatchAt(e).matchType(t))return!0;i-=1}return!1}(t,t.schema.nodes[this.name]))return!1;let{selection:n}=t,{$to:r}=n,i=e();return uM(n)?i.insertContentAt(r.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({state:e,tr:t,dispatch:n})=>{if(n){let{$to:n}=t.selection,r=n.end();if(n.nodeAfter)n.nodeAfter.isTextblock?t.setSelection(sz.create(t.doc,n.pos+1)):n.nodeAfter.isBlock?t.setSelection(sB.create(t.doc,n.pos)):t.setSelection(sz.create(t.doc,n.pos));else{let i=e.schema.nodes[this.options.nextNodeType]||n.parent.type.contentMatch.defaultType,s=null==i?void 0:i.create();s&&(t.insert(r,s),t.setSelection(sz.create(t.doc,r+1)))}t.scrollIntoView()}return!0}).run()}}},addInputRules(){return[pb({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),xs=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,xo=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,xa=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,xl=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,xc=u9.create({name:"italic",addOptions:()=>({HTMLAttributes:{}}),parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:e=>"normal"!==e.style.fontStyle&&null},{style:"font-style=normal",clearMark:e=>e.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:e}){return["em",uc(this.options.HTMLAttributes,e),0]},addCommands(){return{setItalic:()=>({commands:e})=>e.setMark(this.name),toggleItalic:()=>({commands:e})=>e.toggleMark(this.name),unsetItalic:()=>({commands:e})=>e.unsetMark(this.name)}},markdownTokenName:"em",parseMarkdown:(e,t)=>t.applyMark("italic",t.parseInline(e.tokens||[])),markdownOptions:{htmlReopen:{open:"<em>",close:"</em>"}},renderMarkdown:(e,t)=>`*${t.renderChildren(e)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[pg({find:xs,type:this.type}),pg({find:xa,type:this.type})]},addPasteRules(){return[p_({find:xo,type:this.type}),p_({find:xl,type:this.type})]}}),xd=" ",xu=pT.create({name:"paragraph",priority:1e3,addOptions:()=>({HTMLAttributes:{}}),group:"block",content:"inline*",parseHTML:()=>[{tag:"p"}],renderHTML({HTMLAttributes:e}){return["p",uc(this.options.HTMLAttributes,e),0]},parseMarkdown:(e,t)=>{let n=e.tokens||[];if(1===n.length&&"image"===n[0].type)return t.parseChildren([n[0]]);let r=t.parseInline(n);return 1===n.length&&"text"===n[0].type&&(n[0].raw===xd||n[0].text===xd||" "===n[0].raw||" "===n[0].text)&&1===r.length&&"text"===r[0].type&&(r[0].text===xd||" "===r[0].text)?t.createNode("paragraph",void 0,[]):t.createNode("paragraph",void 0,r)},renderMarkdown:(e,t,n)=>{var r,i;if(!e)return"";let s=Array.isArray(e.content)?e.content:[];if(0===s.length){let e=Array.isArray(null==(r=null==n?void 0:n.previousNode)?void 0:r.content)?n.previousNode.content:[];return(null==(i=null==n?void 0:n.previousNode)?void 0:i.type)==="paragraph"&&0===e.length?xd:""}return t.renderChildren(s)},addCommands(){return{setParagraph:()=>({commands:e})=>e.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),xp=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,xh=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,xf=u9.create({name:"strike",addOptions:()=>({HTMLAttributes:{}}),parseHTML:()=>[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:e=>!!e.includes("line-through")&&{}}],renderHTML({HTMLAttributes:e}){return["s",uc(this.options.HTMLAttributes,e),0]},markdownTokenName:"del",parseMarkdown:(e,t)=>t.applyMark("strike",t.parseInline(e.tokens||[])),renderMarkdown:(e,t)=>`~~${t.renderChildren(e)}~~`,addCommands(){return{setStrike:()=>({commands:e})=>e.setMark(this.name),toggleStrike:()=>({commands:e})=>e.toggleMark(this.name),unsetStrike:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[pg({find:xp,type:this.type})]},addPasteRules(){return[p_({find:xh,type:this.type})]}}),xm=pT.create({name:"text",group:"inline",parseMarkdown:e=>({type:"text",text:e.text||""}),renderMarkdown:e=>e.text||""}),xg=u9.create({name:"underline",addOptions:()=>({HTMLAttributes:{}}),parseHTML:()=>[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:e=>!!e.includes("underline")&&{}}],renderHTML({HTMLAttributes:e}){return["u",uc(this.options.HTMLAttributes,e),0]},parseMarkdown(e,t){return t.applyMark(this.name||"underline",t.parseInline(e.tokens||[]))},renderMarkdown:(e,t)=>`++${t.renderChildren(e)}++`,markdownTokenizer:{name:"underline",level:"inline",start:e=>e.indexOf("++"),tokenize(e,t,n){let r=/^(\+\+)([\s\S]+?)(\+\+)/.exec(e);if(!r)return;let i=r[2].trim();return{type:"underline",raw:r[0],text:i,tokens:n.inlineTokens(i)}}},addCommands(){return{setUnderline:()=>({commands:e})=>e.setMark(this.name),toggleUnderline:()=>({commands:e})=>e.toggleMark(this.name),unsetUnderline:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),xb=pt.create({name:"starterKit",addExtensions(){var e,t,n,r;let i=[];return!1!==this.options.bold&&i.push(b5.configure(this.options.bold)),!1!==this.options.blockquote&&i.push(bQ.configure(this.options.blockquote)),!1!==this.options.bulletList&&i.push(bj.configure(this.options.bulletList)),!1!==this.options.code&&i.push(b9.configure(this.options.code)),!1!==this.options.codeBlock&&i.push(xe.configure(this.options.codeBlock)),!1!==this.options.document&&i.push(xt.configure(this.options.document)),!1!==this.options.dropcursor&&i.push(g7.configure(this.options.dropcursor)),!1!==this.options.gapcursor&&i.push(g8.configure(this.options.gapcursor)),!1!==this.options.hardBreak&&i.push(xn.configure(this.options.hardBreak)),!1!==this.options.heading&&i.push(xr.configure(this.options.heading)),!1!==this.options.undoRedo&&i.push(bl.configure(this.options.undoRedo)),!1!==this.options.horizontalRule&&i.push(xi.configure(this.options.horizontalRule)),!1!==this.options.italic&&i.push(xc.configure(this.options.italic)),!1!==this.options.listItem&&i.push(bE.configure(this.options.listItem)),!1!==this.options.listKeymap&&i.push(bF.configure(null==(e=this.options)?void 0:e.listKeymap)),!1!==this.options.link&&i.push(gI.configure(null==(t=this.options)?void 0:t.link)),!1!==this.options.orderedList&&i.push(bq.configure(this.options.orderedList)),!1!==this.options.paragraph&&i.push(xu.configure(this.options.paragraph)),!1!==this.options.strike&&i.push(xf.configure(this.options.strike)),!1!==this.options.text&&i.push(xm.configure(this.options.text)),!1!==this.options.underline&&i.push(xg.configure(null==(n=this.options)?void 0:n.underline)),!1!==this.options.trailingNode&&i.push(ba.configure(null==(r=this.options)?void 0:r.trailingNode)),i}});function xx(e){let t=e.regex,n={};Object.assign(n,{className:"variable",variants:[{begin:t.concat(/\$[\w\d#@][\w\d_]*/,"(?![\\w\\d])(?![$])")},{begin:/\$\{/,end:/\}/,contains:["self",{begin:/:-/,contains:[n]}]}]});let r={className:"subst",begin:/\$\(/,end:/\)/,contains:[e.BACKSLASH_ESCAPE]},i=e.inherit(e.COMMENT(),{match:[/(^|\s)/,/#.*$/],scope:{2:"comment"}}),s={begin:/<<-?\s*(?=\w+)/,starts:{contains:[e.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,className:"string"})]}},o={className:"string",begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,n,r]};r.contains.push(o);let a={begin:/\$?\(\(/,end:/\)\)/,contains:[{begin:/\d+#[0-9a-f]+/,className:"number"},e.NUMBER_MODE,n]},l=e.SHEBANG({binary:"(fish|bash|zsh|sh|csh|ksh|tcsh|dash|scsh)",relevance:10}),c={className:"function",begin:/\w[\w\d_]*\s*\(\s*\)\s*\{/,returnBegin:!0,contains:[e.inherit(e.TITLE_MODE,{begin:/\w[\w\d_]*/})],relevance:0};return{name:"Bash",aliases:["sh","zsh"],keywords:{$pattern:/\b[a-z][a-z0-9._-]+\b/,keyword:["if","then","else","elif","fi","time","for","while","until","in","do","done","case","esac","coproc","function","select"],literal:["true","false"],built_in:["break","cd","continue","eval","exec","exit","export","getopts","hash","pwd","readonly","return","shift","test","times","trap","umask","unset","alias","bind","builtin","caller","command","declare","echo","enable","help","let","local","logout","mapfile","printf","read","readarray","source","sudo","type","typeset","ulimit","unalias","set","shopt","autoload","bg","bindkey","bye","cap","chdir","clone","comparguments","compcall","compctl","compdescribe","compfiles","compgroups","compquote","comptags","comptry","compvalues","dirs","disable","disown","echotc","echoti","emulate","fc","fg","float","functions","getcap","getln","history","integer","jobs","kill","limit","log","noglob","popd","print","pushd","pushln","rehash","sched","setcap","setopt","stat","suspend","ttyctl","unfunction","unhash","unlimit","unsetopt","vared","wait","whence","where","which","zcompile","zformat","zftp","zle","zmodload","zparseopts","zprof","zpty","zregexparse","zsocket","zstyle","ztcp","chcon","chgrp","chown","chmod","cp","dd","df","dir","dircolors","ln","ls","mkdir","mkfifo","mknod","mktemp","mv","realpath","rm","rmdir","shred","sync","touch","truncate","vdir","b2sum","base32","base64","cat","cksum","comm","csplit","cut","expand","fmt","fold","head","join","md5sum","nl","numfmt","od","paste","ptx","pr","sha1sum","sha224sum","sha256sum","sha384sum","sha512sum","shuf","sort","split","sum","tac","tail","tr","tsort","unexpand","uniq","wc","arch","basename","chroot","date","dirname","du","echo","env","expr","factor","groups","hostid","id","link","logname","nice","nohup","nproc","pathchk","pinky","printenv","printf","pwd","readlink","runcon","seq","sleep","stat","stdbuf","stty","tee","test","timeout","tty","uname","unlink","uptime","users","who","whoami","yes"]},contains:[l,e.SHEBANG(),c,a,i,s,{match:/(\/[a-z._-]+)+/},o,{match:/\\"/},{className:"string",begin:/'/,end:/'/},{match:/\\'/},n]}}let xy=["a","abbr","address","article","aside","audio","b","blockquote","body","button","canvas","caption","cite","code","dd","del","details","dfn","div","dl","dt","em","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","html","i","iframe","img","input","ins","kbd","label","legend","li","main","mark","menu","nav","object","ol","optgroup","option","p","picture","q","quote","samp","section","select","source","span","strong","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","ul","var","video","defs","g","marker","mask","pattern","svg","switch","symbol","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feFlood","feGaussianBlur","feImage","feMerge","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","linearGradient","radialGradient","stop","circle","ellipse","image","line","path","polygon","polyline","rect","text","use","textPath","tspan","foreignObject","clipPath"],xv=["any-hover","any-pointer","aspect-ratio","color","color-gamut","color-index","device-aspect-ratio","device-height","device-width","display-mode","forced-colors","grid","height","hover","inverted-colors","monochrome","orientation","overflow-block","overflow-inline","pointer","prefers-color-scheme","prefers-contrast","prefers-reduced-motion","prefers-reduced-transparency","resolution","scan","scripting","update","width","min-width","max-width","min-height","max-height"].sort().reverse(),xw=["active","any-link","blank","checked","current","default","defined","dir","disabled","drop","empty","enabled","first","first-child","first-of-type","fullscreen","future","focus","focus-visible","focus-within","has","host","host-context","hover","indeterminate","in-range","invalid","is","lang","last-child","last-of-type","left","link","local-link","not","nth-child","nth-col","nth-last-child","nth-last-col","nth-last-of-type","nth-of-type","only-child","only-of-type","optional","out-of-range","past","placeholder-shown","read-only","read-write","required","right","root","scope","target","target-within","user-invalid","valid","visited","where"].sort().reverse(),xk=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),xN=["accent-color","align-content","align-items","align-self","alignment-baseline","all","anchor-name","animation","animation-composition","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-range","animation-range-end","animation-range-start","animation-timeline","animation-timing-function","appearance","aspect-ratio","backdrop-filter","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-position-x","background-position-y","background-repeat","background-size","baseline-shift","block-size","border","border-block","border-block-color","border-block-end","border-block-end-color","border-block-end-style","border-block-end-width","border-block-start","border-block-start-color","border-block-start-style","border-block-start-width","border-block-style","border-block-width","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-end-end-radius","border-end-start-radius","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-inline","border-inline-color","border-inline-end","border-inline-end-color","border-inline-end-style","border-inline-end-width","border-inline-start","border-inline-start-color","border-inline-start-style","border-inline-start-width","border-inline-style","border-inline-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-start-end-radius","border-start-start-radius","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-align","box-decoration-break","box-direction","box-flex","box-flex-group","box-lines","box-ordinal-group","box-orient","box-pack","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","caret-color","clear","clip","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","color-scheme","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","contain","contain-intrinsic-block-size","contain-intrinsic-height","contain-intrinsic-inline-size","contain-intrinsic-size","contain-intrinsic-width","container","container-name","container-type","content","content-visibility","counter-increment","counter-reset","counter-set","cue","cue-after","cue-before","cursor","cx","cy","direction","display","dominant-baseline","empty-cells","enable-background","field-sizing","fill","fill-opacity","fill-rule","filter","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","flood-color","flood-opacity","flow","font","font-display","font-family","font-feature-settings","font-kerning","font-language-override","font-optical-sizing","font-palette","font-size","font-size-adjust","font-smooth","font-smoothing","font-stretch","font-style","font-synthesis","font-synthesis-position","font-synthesis-small-caps","font-synthesis-style","font-synthesis-weight","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-emoji","font-variant-ligatures","font-variant-numeric","font-variant-position","font-variation-settings","font-weight","forced-color-adjust","gap","glyph-orientation-horizontal","glyph-orientation-vertical","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-rows","grid-column","grid-column-end","grid-column-start","grid-gap","grid-row","grid-row-end","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphenate-character","hyphenate-limit-chars","hyphens","icon","image-orientation","image-rendering","image-resolution","ime-mode","initial-letter","initial-letter-align","inline-size","inset","inset-area","inset-block","inset-block-end","inset-block-start","inset-inline","inset-inline-end","inset-inline-start","isolation","justify-content","justify-items","justify-self","kerning","left","letter-spacing","lighting-color","line-break","line-height","line-height-step","list-style","list-style-image","list-style-position","list-style-type","margin","margin-block","margin-block-end","margin-block-start","margin-bottom","margin-inline","margin-inline-end","margin-inline-start","margin-left","margin-right","margin-top","margin-trim","marker","marker-end","marker-mid","marker-start","marks","mask","mask-border","mask-border-mode","mask-border-outset","mask-border-repeat","mask-border-slice","mask-border-source","mask-border-width","mask-clip","mask-composite","mask-image","mask-mode","mask-origin","mask-position","mask-repeat","mask-size","mask-type","masonry-auto-flow","math-depth","math-shift","math-style","max-block-size","max-height","max-inline-size","max-width","min-block-size","min-height","min-inline-size","min-width","mix-blend-mode","nav-down","nav-index","nav-left","nav-right","nav-up","none","normal","object-fit","object-position","offset","offset-anchor","offset-distance","offset-path","offset-position","offset-rotate","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-anchor","overflow-block","overflow-clip-margin","overflow-inline","overflow-wrap","overflow-x","overflow-y","overlay","overscroll-behavior","overscroll-behavior-block","overscroll-behavior-inline","overscroll-behavior-x","overscroll-behavior-y","padding","padding-block","padding-block-end","padding-block-start","padding-bottom","padding-inline","padding-inline-end","padding-inline-start","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","paint-order","pause","pause-after","pause-before","perspective","perspective-origin","place-content","place-items","place-self","pointer-events","position","position-anchor","position-visibility","print-color-adjust","quotes","r","resize","rest","rest-after","rest-before","right","rotate","row-gap","ruby-align","ruby-position","scale","scroll-behavior","scroll-margin","scroll-margin-block","scroll-margin-block-end","scroll-margin-block-start","scroll-margin-bottom","scroll-margin-inline","scroll-margin-inline-end","scroll-margin-inline-start","scroll-margin-left","scroll-margin-right","scroll-margin-top","scroll-padding","scroll-padding-block","scroll-padding-block-end","scroll-padding-block-start","scroll-padding-bottom","scroll-padding-inline","scroll-padding-inline-end","scroll-padding-inline-start","scroll-padding-left","scroll-padding-right","scroll-padding-top","scroll-snap-align","scroll-snap-stop","scroll-snap-type","scroll-timeline","scroll-timeline-axis","scroll-timeline-name","scrollbar-color","scrollbar-gutter","scrollbar-width","shape-image-threshold","shape-margin","shape-outside","shape-rendering","speak","speak-as","src","stop-color","stop-opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","tab-size","table-layout","text-align","text-align-all","text-align-last","text-anchor","text-combine-upright","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-skip-ink","text-decoration-style","text-decoration-thickness","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-indent","text-justify","text-orientation","text-overflow","text-rendering","text-shadow","text-size-adjust","text-transform","text-underline-offset","text-underline-position","text-wrap","text-wrap-mode","text-wrap-style","timeline-scope","top","touch-action","transform","transform-box","transform-origin","transform-style","transition","transition-behavior","transition-delay","transition-duration","transition-property","transition-timing-function","translate","unicode-bidi","user-modify","user-select","vector-effect","vertical-align","view-timeline","view-timeline-axis","view-timeline-inset","view-timeline-name","view-transition-name","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","white-space","white-space-collapse","widows","width","will-change","word-break","word-spacing","word-wrap","writing-mode","x","y","z-index","zoom"].sort().reverse();function xS(e){let t=e.regex,n={IMPORTANT:{scope:"meta",begin:"!important"},BLOCK_COMMENT:e.C_BLOCK_COMMENT_MODE,HEXCOLOR:{scope:"number",begin:/#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/},FUNCTION_DISPATCH:{className:"built_in",begin:/[\w-]+(?=\()/},ATTRIBUTE_SELECTOR_MODE:{scope:"selector-attr",begin:/\[/,end:/\]/,illegal:"$",contains:[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},CSS_NUMBER_MODE:{scope:"number",begin:e.NUMBER_RE+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",relevance:0},CSS_VARIABLE:{className:"attr",begin:/--[A-Za-z_][A-Za-z0-9_-]*/}},r=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE];return{name:"CSS",case_insensitive:!0,illegal:/[=|'\$]/,keywords:{keyframePosition:"from to"},classNameAliases:{keyframePosition:"selector-tag"},contains:[n.BLOCK_COMMENT,{begin:/-(webkit|moz|ms|o)-(?=[a-z])/},n.CSS_NUMBER_MODE,{className:"selector-id",begin:/#[A-Za-z0-9_-]+/,relevance:0},{className:"selector-class",begin:"\\.[a-zA-Z-][a-zA-Z0-9_-]*",relevance:0},n.ATTRIBUTE_SELECTOR_MODE,{className:"selector-pseudo",variants:[{begin:":("+xw.join("|")+")"},{begin:":(:)?("+xk.join("|")+")"}]},n.CSS_VARIABLE,{className:"attribute",begin:"\\b("+xN.join("|")+")\\b"},{begin:/:/,end:/[;}{]/,contains:[n.BLOCK_COMMENT,n.HEXCOLOR,n.IMPORTANT,n.CSS_NUMBER_MODE,...r,{begin:/(url|data-uri)\(/,end:/\)/,relevance:0,keywords:{built_in:"url data-uri"},contains:[...r,{className:"string",begin:/[^)]/,endsWithParent:!0,excludeEnd:!0}]},n.FUNCTION_DISPATCH]},{begin:t.lookahead(/@/),end:"[{;]",relevance:0,illegal:/:/,contains:[{className:"keyword",begin:/@-?\w[\w]*(-\w+)*/},{begin:/\s/,endsWithParent:!0,excludeEnd:!0,relevance:0,keywords:{$pattern:/[a-z-]+/,keyword:"and or not only",attribute:xv.join(" ")},contains:[{begin:/[a-z-]+(?=:)/,className:"attribute"},...r,n.CSS_NUMBER_MODE]}]},{className:"selector-tag",begin:"\\b("+xy.join("|")+")\\b"}]}}function xC(e){let t={keyword:["break","case","chan","const","continue","default","defer","else","fallthrough","for","func","go","goto","if","import","interface","map","package","range","return","select","struct","switch","type","var"],type:["bool","byte","complex64","complex128","error","float32","float64","int8","int16","int32","int64","string","uint8","uint16","uint32","uint64","int","uint","uintptr","rune"],literal:["true","false","iota","nil"],built_in:["append","cap","close","complex","copy","imag","len","make","new","panic","print","println","real","recover","delete"]};return{name:"Go",aliases:["golang"],keywords:t,illegal:"</",contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,{className:"string",variants:[e.QUOTE_STRING_MODE,e.APOS_STRING_MODE,{begin:"`",end:"`"}]},{className:"number",variants:[{match:/-?\b0[xX]\.[a-fA-F0-9](_?[a-fA-F0-9])*[pP][+-]?\d(_?\d)*i?/,relevance:0},{match:/-?\b0[xX](_?[a-fA-F0-9])+((\.([a-fA-F0-9](_?[a-fA-F0-9])*)?)?[pP][+-]?\d(_?\d)*)?i?/,relevance:0},{match:/-?\b0[oO](_?[0-7])*i?/,relevance:0},{match:/-?\.\d(_?\d)*([eE][+-]?\d(_?\d)*)?i?/,relevance:0},{match:/-?\b\d(_?\d)*(\.(\d(_?\d)*)?)?([eE][+-]?\d(_?\d)*)?i?/,relevance:0}]},{begin:/:=/},{className:"function",beginKeywords:"func",end:"\\s*(\\{|$)",excludeEnd:!0,contains:[e.TITLE_MODE,{className:"params",begin:/\(/,end:/\)/,endsParent:!0,keywords:t,illegal:/["']/}]}]}}let xj="[A-Za-z$_][0-9A-Za-z$_]*",xE=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends","using"],xM=["true","false","null","undefined","NaN","Infinity"],xA=["Object","Function","Boolean","Symbol","Math","Date","Number","BigInt","String","RegExp","Array","Float32Array","Float64Array","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Int32Array","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array","Set","Map","WeakSet","WeakMap","ArrayBuffer","SharedArrayBuffer","Atomics","DataView","JSON","Promise","Generator","GeneratorFunction","AsyncFunction","Reflect","Proxy","Intl","WebAssembly"],xT=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],xO=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],x_=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],xD=[].concat(xO,xA,xT);function xR(e){var t;let n=e.regex,r=/<[A-Za-z0-9\\._:-]+/,i=/\/[A-Za-z0-9\\._:-]+>|\/>/,s={$pattern:xj,keyword:xE,literal:xM,built_in:xD,"variable.language":x_},o="[0-9](_?[0-9])*",a=`\\.(${o})`,l="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",c={className:"number",variants:[{begin:`(\\b(${l})((${a})|\\.)?|(${a}))[eE][+-]?(${o})\\b`},{begin:`\\b(${l})\\b((${a})\\b|\\.)?|(${a})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},d={className:"subst",begin:"\\$\\{",end:"\\}",keywords:s,contains:[]},u={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,d],subLanguage:"xml"}},p={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,d],subLanguage:"css"}},h={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,d],subLanguage:"graphql"}},f={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,d]},m={className:"comment",variants:[e.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:xj+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),e.C_BLOCK_COMMENT_MODE,e.C_LINE_COMMENT_MODE]},g=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,u,p,h,f,{match:/\$\d+/},c];d.contains=g.concat({begin:/\{/,end:/\}/,keywords:s,contains:["self"].concat(g)});let b=[].concat(m,d.contains),x=b.concat([{begin:/(\s*)\(/,end:/\)/,keywords:s,contains:["self"].concat(b)}]),y={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:s,contains:x},v={variants:[{match:[/class/,/\s+/,xj,/\s+/,/extends/,/\s+/,n.concat(xj,"(",n.concat(/\./,xj),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,xj],scope:{1:"keyword",3:"title.class"}}]},w={relevance:0,match:n.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:"title.class",keywords:{_:[...xA,...xT]}},k={match:n.concat(/\b/,(t=[...xO,"super","import"].map(e=>`${e}\\s*\\(`),n.concat("(?!",t.join("|"),")")),xj,n.lookahead(/\s*\(/)),className:"title.function",relevance:0},N={begin:n.concat(/\./,n.lookahead(n.concat(xj,/(?![0-9A-Za-z$_(])/))),end:xj,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},S="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",C={match:[/const|var|let/,/\s+/,xj,/\s*/,/=\s*/,/(async\s*)?/,n.lookahead(S)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[y]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:s,exports:{PARAMS_CONTAINS:x,CLASS_REFERENCE:w},illegal:/#(?![$_A-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),{label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,u,p,h,f,m,{match:/\$\d+/},c,w,{scope:"attr",match:xj+n.lookahead(":"),relevance:0},C,{begin:"("+e.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[m,e.REGEXP_MODE,{className:"function",begin:S,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:e.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:s,contains:x}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:"<>",end:"</>"},{match:/<[A-Za-z0-9\\._:-]+\s*\/>/},{begin:r,"on:begin":(e,t)=>{let n,r=e[0].length+e.index,i=e.input[r];if("<"===i||","===i)return void t.ignoreMatch();">"!==i||((e,{after:t})=>{let n="</"+e[0].slice(1);return -1!==e.input.indexOf(n,t)})(e,{after:r})||t.ignoreMatch();let s=e.input.substring(r);if((n=s.match(/^\s*=/))||(n=s.match(/^\s+extends\s+/))&&0===n.index)return void t.ignoreMatch()},end:i}],subLanguage:"xml",contains:[{begin:r,end:i,skip:!0,contains:["self"]}]}]},{variants:[{match:[/function/,/\s+/,xj,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[y],illegal:/%/},{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+e.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[y,e.inherit(e.TITLE_MODE,{begin:xj,className:"title.function"})]},{match:/\.\.\./,relevance:0},N,{match:"\\$"+xj,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[y]},k,{relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"},v,{match:[/get|set/,/\s+/,xj,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},y]},{match:/\$[(.]/}]}}function xI(e){let t=["true","false","null"],n={scope:"literal",beginKeywords:t.join(" ")};return{name:"JSON",aliases:["jsonc"],keywords:{literal:t},contains:[{className:"attr",begin:/"(\\.|[^\\"\r\n])*"(?=\s*:)/,relevance:1.01},{match:/[{}[\],:]/,className:"punctuation",relevance:0},e.QUOTE_STRING_MODE,n,e.C_NUMBER_MODE,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE],illegal:"\\S"}}function xL(e){let t=e.regex,n={begin:/<\/?[A-Za-z_]/,end:">",subLanguage:"xml",relevance:0},r={variants:[{begin:/\[.+?\]\[.*?\]/,relevance:0},{begin:/\[.+?\]\(((data|javascript|mailto):|(?:http|ftp)s?:\/\/).*?\)/,relevance:2},{begin:t.concat(/\[.+?\]\(/,/[A-Za-z][A-Za-z0-9+.-]*/,/:\/\/.*?\)/),relevance:2},{begin:/\[.+?\]\([./?&#].*?\)/,relevance:1},{begin:/\[.*?\]\(.*?\)/,relevance:0}],returnBegin:!0,contains:[{match:/\[(?=\])/},{className:"string",relevance:0,begin:"\\[",end:"\\]",excludeBegin:!0,returnEnd:!0},{className:"link",relevance:0,begin:"\\]\\(",end:"\\)",excludeBegin:!0,excludeEnd:!0},{className:"symbol",relevance:0,begin:"\\]\\[",end:"\\]",excludeBegin:!0,excludeEnd:!0}]},i={className:"strong",contains:[],variants:[{begin:/_{2}(?!\s)/,end:/_{2}/},{begin:/\*{2}(?!\s)/,end:/\*{2}/}]},s={className:"emphasis",contains:[],variants:[{begin:/\*(?![*\s])/,end:/\*/},{begin:/_(?![_\s])/,end:/_/,relevance:0}]},o=e.inherit(i,{contains:[]}),a=e.inherit(s,{contains:[]});i.contains.push(a),s.contains.push(o);let l=[n,r];return[i,s,o,a].forEach(e=>{e.contains=e.contains.concat(l)}),{name:"Markdown",aliases:["md","mkdown","mkd"],contains:[{className:"section",variants:[{begin:"^#{1,6}",end:"$",contains:l=l.concat(i,s)},{begin:"(?=^.+?\\n[=-]{2,}$)",contains:[{begin:"^[=-]*$"},{begin:"^",end:"\\n",contains:l}]}]},n,{className:"bullet",begin:"^[ ]*([*+-]|(\\d+\\.))(?=\\s+)",end:"\\s+",excludeEnd:!0},i,s,{className:"quote",begin:"^>\\s+",contains:l,end:"$"},{className:"code",variants:[{begin:"(`{3,})[^`](.|\\n)*?\\1`*[ ]*"},{begin:"(~{3,})[^~](.|\\n)*?\\1~*[ ]*"},{begin:"```",end:"```+[ ]*$"},{begin:"~~~",end:"~~~+[ ]*$"},{begin:"`.+?`"},{begin:"(?=^( {4}|\\t))",contains:[{begin:"^( {4}|\\t)",end:"(\\n)$"}],relevance:0}]},{begin:"^[-\\*]{3,}",end:"$"},r,{begin:/^\[[^\n]+\]:/,returnBegin:!0,contains:[{className:"symbol",begin:/\[/,end:/\]/,excludeBegin:!0,excludeEnd:!0},{className:"link",begin:/:\s*/,end:/$/,excludeBegin:!0}]},{scope:"literal",match:/&([a-zA-Z0-9]+|#[0-9]{1,7}|#[Xx][0-9a-fA-F]{1,6});/}]}}function xP(e){let t=e.regex,n=/[\p{XID_Start}_]\p{XID_Continue}*/u,r=["and","as","assert","async","await","break","case","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","match","nonlocal|10","not","or","pass","raise","return","try","while","with","yield"],i={$pattern:/[A-Za-z]\w+|__\w+__/,keyword:r,built_in:["__import__","abs","all","any","ascii","bin","bool","breakpoint","bytearray","bytes","callable","chr","classmethod","compile","complex","delattr","dict","dir","divmod","enumerate","eval","exec","filter","float","format","frozenset","getattr","globals","hasattr","hash","help","hex","id","input","int","isinstance","issubclass","iter","len","list","locals","map","max","memoryview","min","next","object","oct","open","ord","pow","print","property","range","repr","reversed","round","set","setattr","slice","sorted","staticmethod","str","sum","super","tuple","type","vars","zip"],literal:["__debug__","Ellipsis","False","None","NotImplemented","True"],type:["Any","Callable","Coroutine","Dict","List","Literal","Generic","Optional","Sequence","Set","Tuple","Type","Union"]},s={className:"meta",begin:/^(>>>|\.\.\.) /},o={className:"subst",begin:/\{/,end:/\}/,keywords:i,illegal:/#/},a={begin:/\{\{/,relevance:0},l={className:"string",contains:[e.BACKSLASH_ESCAPE],variants:[{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,s],relevance:10},{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,s],relevance:10},{begin:/([fF][rR]|[rR][fF]|[fF])'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,s,a,o]},{begin:/([fF][rR]|[rR][fF]|[fF])"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,s,a,o]},{begin:/([uU]|[rR])'/,end:/'/,relevance:10},{begin:/([uU]|[rR])"/,end:/"/,relevance:10},{begin:/([bB]|[bB][rR]|[rR][bB])'/,end:/'/},{begin:/([bB]|[bB][rR]|[rR][bB])"/,end:/"/},{begin:/([fF][rR]|[rR][fF]|[fF])'/,end:/'/,contains:[e.BACKSLASH_ESCAPE,a,o]},{begin:/([fF][rR]|[rR][fF]|[fF])"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,a,o]},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},c="[0-9](_?[0-9])*",d=`(\\b(${c}))?\\.(${c})|\\b(${c})\\.`,u=`\\b|${r.join("|")}`,p={className:"number",relevance:0,variants:[{begin:`(\\b(${c})|(${d}))[eE][+-]?(${c})[jJ]?(?=${u})`},{begin:`(${d})[jJ]?`},{begin:`\\b([1-9](_?[0-9])*|0+(_?0)*)[lLjJ]?(?=${u})`},{begin:`\\b0[bB](_?[01])+[lL]?(?=${u})`},{begin:`\\b0[oO](_?[0-7])+[lL]?(?=${u})`},{begin:`\\b0[xX](_?[0-9a-fA-F])+[lL]?(?=${u})`},{begin:`\\b(${c})[jJ](?=${u})`}]},h={className:"comment",begin:t.lookahead(/# type:/),end:/$/,keywords:i,contains:[{begin:/# type:/},{begin:/#/,end:/\b\B/,endsWithParent:!0}]},f={className:"params",variants:[{className:"",begin:/\(\s*\)/,skip:!0},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:i,contains:["self",s,p,l,e.HASH_COMMENT_MODE]}]};return o.contains=[l,p,s],{name:"Python",aliases:["py","gyp","ipython"],unicodeRegex:!0,keywords:i,illegal:/(<\/|\?)|=>/,contains:[s,p,{scope:"variable.language",match:/\bself\b/},{beginKeywords:"if",relevance:0},{match:/\bor\b/,scope:"keyword"},l,h,e.HASH_COMMENT_MODE,{match:[/\bdef/,/\s+/,n],scope:{1:"keyword",3:"title.function"},contains:[f]},{variants:[{match:[/\bclass/,/\s+/,n,/\s*/,/\(\s*/,n,/\s*\)/]},{match:[/\bclass/,/\s+/,n]}],scope:{1:"keyword",3:"title.class",6:"title.class.inherited"}},{className:"meta",begin:/^[\t ]*@/,end:/(?=#)|$/,contains:[p,f,l]}]}}function xz(e){let t=e.regex,n=/(r#)?/,r=t.concat(n,e.UNDERSCORE_IDENT_RE),i=t.concat(n,e.IDENT_RE),s={className:"title.function.invoke",relevance:0,begin:t.concat(/\b/,/(?!let|for|while|if|else|match\b)/,i,t.lookahead(/\s*\(/))},o="([ui](8|16|32|64|128|size)|f(32|64))?",a=["drop ","Copy","Send","Sized","Sync","Drop","Fn","FnMut","FnOnce","ToOwned","Clone","Debug","PartialEq","PartialOrd","Eq","Ord","AsRef","AsMut","Into","From","Default","Iterator","Extend","IntoIterator","DoubleEndedIterator","ExactSizeIterator","SliceConcatExt","ToString","assert!","assert_eq!","bitflags!","bytes!","cfg!","col!","concat!","concat_idents!","debug_assert!","debug_assert_eq!","env!","eprintln!","panic!","file!","format!","format_args!","include_bytes!","include_str!","line!","local_data_key!","module_path!","option_env!","print!","println!","select!","stringify!","try!","unimplemented!","unreachable!","vec!","write!","writeln!","macro_rules!","assert_ne!","debug_assert_ne!"],l=["i8","i16","i32","i64","i128","isize","u8","u16","u32","u64","u128","usize","f32","f64","str","char","bool","Box","Option","Result","String","Vec"];return{name:"Rust",aliases:["rs"],keywords:{$pattern:e.IDENT_RE+"!?",type:l,keyword:["abstract","as","async","await","become","box","break","const","continue","crate","do","dyn","else","enum","extern","false","final","fn","for","if","impl","in","let","loop","macro","match","mod","move","mut","override","priv","pub","ref","return","self","Self","static","struct","super","trait","true","try","type","typeof","union","unsafe","unsized","use","virtual","where","while","yield"],literal:["true","false","Some","None","Ok","Err"],built_in:a},illegal:"</",contains:[e.C_LINE_COMMENT_MODE,e.COMMENT("/\\*","\\*/",{contains:["self"]}),e.inherit(e.QUOTE_STRING_MODE,{begin:/b?"/,illegal:null}),{className:"symbol",begin:/'[a-zA-Z_][a-zA-Z0-9_]*(?!')/},{scope:"string",variants:[{begin:/b?r(#*)"(.|\n)*?"\1(?!#)/},{begin:/b?'/,end:/'/,contains:[{scope:"char.escape",match:/\\('|\w|x\w{2}|u\w{4}|U\w{8})/}]}]},{className:"number",variants:[{begin:"\\b0b([01_]+)"+o},{begin:"\\b0o([0-7_]+)"+o},{begin:"\\b0x([A-Fa-f0-9_]+)"+o},{begin:"\\b(\\d[\\d_]*(\\.[0-9_]+)?([eE][+-]?[0-9_]+)?)"+o}],relevance:0},{begin:[/fn/,/\s+/,r],className:{1:"keyword",3:"title.function"}},{className:"meta",begin:"#!?\\[",end:"\\]",contains:[{className:"string",begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE]}]},{begin:[/let/,/\s+/,/(?:mut\s+)?/,r],className:{1:"keyword",3:"keyword",4:"variable"}},{begin:[/for/,/\s+/,r,/\s+/,/in/],className:{1:"keyword",3:"variable",5:"keyword"}},{begin:[/type/,/\s+/,r],className:{1:"keyword",3:"title.class"}},{begin:[/(?:trait|enum|struct|union|impl|for)/,/\s+/,r],className:{1:"keyword",3:"title.class"}},{begin:e.IDENT_RE+"::",keywords:{keyword:"Self",built_in:a,type:l}},{className:"punctuation",begin:"->"},s]}}function x$(e){return{name:"Shell Session",aliases:["console","shellsession"],contains:[{className:"meta.prompt",begin:/^\s{0,3}[/~\w\d[\]()@-]*[>%$#][ ]?/,starts:{end:/[^\\](?=\s*$)/,subLanguage:"bash"}}]}}function xB(e){let t=e.regex,n=e.COMMENT("--","$"),r=["abs","acos","array_agg","asin","atan","avg","cast","ceil","ceiling","coalesce","corr","cos","cosh","count","covar_pop","covar_samp","cume_dist","dense_rank","deref","element","exp","extract","first_value","floor","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","last_value","lead","listagg","ln","log","log10","lower","max","min","mod","nth_value","ntile","nullif","percent_rank","percentile_cont","percentile_disc","position","position_regex","power","rank","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","row_number","sin","sinh","sqrt","stddev_pop","stddev_samp","substring","substring_regex","sum","tan","tanh","translate","translate_regex","treat","trim","trim_array","unnest","upper","value_of","var_pop","var_samp","width_bucket"],i=["abs","acos","all","allocate","alter","and","any","are","array","array_agg","array_max_cardinality","as","asensitive","asin","asymmetric","at","atan","atomic","authorization","avg","begin","begin_frame","begin_partition","between","bigint","binary","blob","boolean","both","by","call","called","cardinality","cascaded","case","cast","ceil","ceiling","char","char_length","character","character_length","check","classifier","clob","close","coalesce","collate","collect","column","commit","condition","connect","constraint","contains","convert","copy","corr","corresponding","cos","cosh","count","covar_pop","covar_samp","create","cross","cube","cume_dist","current","current_catalog","current_date","current_default_transform_group","current_path","current_role","current_row","current_schema","current_time","current_timestamp","current_path","current_role","current_transform_group_for_type","current_user","cursor","cycle","date","day","deallocate","dec","decimal","decfloat","declare","default","define","delete","dense_rank","deref","describe","deterministic","disconnect","distinct","double","drop","dynamic","each","element","else","empty","end","end_frame","end_partition","end-exec","equals","escape","every","except","exec","execute","exists","exp","external","extract","false","fetch","filter","first_value","float","floor","for","foreign","frame_row","free","from","full","function","fusion","get","global","grant","group","grouping","groups","having","hold","hour","identity","in","indicator","initial","inner","inout","insensitive","insert","int","integer","intersect","intersection","interval","into","is","join","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","language","large","last_value","lateral","lead","leading","left","like","like_regex","listagg","ln","local","localtime","localtimestamp","log","log10","lower","match","match_number","match_recognize","matches","max","member","merge","method","min","minute","mod","modifies","module","month","multiset","national","natural","nchar","nclob","new","no","none","normalize","not","nth_value","ntile","null","nullif","numeric","octet_length","occurrences_regex","of","offset","old","omit","on","one","only","open","or","order","out","outer","over","overlaps","overlay","parameter","partition","pattern","per","percent","percent_rank","percentile_cont","percentile_disc","period","portion","position","position_regex","power","precedes","precision","prepare","primary","procedure","ptf","range","rank","reads","real","recursive","ref","references","referencing","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","release","result","return","returns","revoke","right","rollback","rollup","row","row_number","rows","running","savepoint","scope","scroll","search","second","seek","select","sensitive","session_user","set","show","similar","sin","sinh","skip","smallint","some","specific","specifictype","sql","sqlexception","sqlstate","sqlwarning","sqrt","start","static","stddev_pop","stddev_samp","submultiset","subset","substring","substring_regex","succeeds","sum","symmetric","system","system_time","system_user","table","tablesample","tan","tanh","then","time","timestamp","timezone_hour","timezone_minute","to","trailing","translate","translate_regex","translation","treat","trigger","trim","trim_array","true","truncate","uescape","union","unique","unknown","unnest","update","upper","user","using","value","values","value_of","var_pop","var_samp","varbinary","varchar","varying","versioning","when","whenever","where","width_bucket","window","with","within","without","year","add","asc","collation","desc","final","first","last","view"].filter(e=>!r.includes(e)),s={match:t.concat(/\b/,t.either(...r),/\s*\(/),relevance:0,keywords:{built_in:r}};function o(e){return t.concat(/\b/,t.either(...e.map(e=>e.replace(/\s+/,"\\s+"))),/\b/)}let a={scope:"keyword",match:o(["create table","insert into","primary key","foreign key","not null","alter table","add constraint","grouping sets","on overflow","character set","respect nulls","ignore nulls","nulls first","nulls last","depth first","breadth first"]),relevance:0};return{name:"SQL",case_insensitive:!0,illegal:/[{}]|<\//,keywords:{$pattern:/\b[\w\.]+/,keyword:function(e,{exceptions:t,when:n}={}){return t=t||[],e.map(e=>e.match(/\|\d+$/)||t.includes(e)?e:n(e)?`${e}|0`:e)}(i,{when:e=>e.length<3}),literal:["true","false","unknown"],type:["bigint","binary","blob","boolean","char","character","clob","date","dec","decfloat","decimal","float","int","integer","interval","nchar","nclob","national","numeric","real","row","smallint","time","timestamp","varchar","varying","varbinary"],built_in:["current_catalog","current_date","current_default_transform_group","current_path","current_role","current_schema","current_transform_group_for_type","current_user","session_user","system_time","system_user","current_time","localtime","current_timestamp","localtimestamp"]},contains:[{scope:"type",match:o(["double precision","large object","with timezone","without timezone"])},a,s,{scope:"variable",match:/@[a-z0-9][a-z0-9_]*/},{scope:"string",variants:[{begin:/'/,end:/'/,contains:[{match:/''/}]}]},{begin:/"/,end:/"/,contains:[{match:/""/}]},e.C_NUMBER_MODE,e.C_BLOCK_COMMENT_MODE,n,{scope:"operator",match:/[-+*/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?/,relevance:0}]}}let xF="[A-Za-z$_][0-9A-Za-z$_]*",xH=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends","using"],xU=["true","false","null","undefined","NaN","Infinity"],xV=["Object","Function","Boolean","Symbol","Math","Date","Number","BigInt","String","RegExp","Array","Float32Array","Float64Array","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Int32Array","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array","Set","Map","WeakSet","WeakMap","ArrayBuffer","SharedArrayBuffer","Atomics","DataView","JSON","Promise","Generator","GeneratorFunction","AsyncFunction","Reflect","Proxy","Intl","WebAssembly"],xW=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],xq=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],xK=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],xG=[].concat(xq,xV,xW);function xJ(e){var t;let n,r,i,s,o,a,l,c,d,u,p,h,f,m,g,b,x,y,v,w,k,N,S,C,j,E=e.regex,M=(n=e.regex,r=/<[A-Za-z0-9\\._:-]+/,i=/\/[A-Za-z0-9\\._:-]+>|\/>/,s=(e,t)=>{let n,r=e[0].length+e.index,i=e.input[r];if("<"===i||","===i)return void t.ignoreMatch();">"!==i||((e,{after:t})=>{let n="</"+e[0].slice(1);return -1!==e.input.indexOf(n,t)})(e,{after:r})||t.ignoreMatch();let s=e.input.substring(r);if((n=s.match(/^\s*=/))||(n=s.match(/^\s+extends\s+/))&&0===n.index)return void t.ignoreMatch()},o={$pattern:xF,keyword:xH,literal:xU,built_in:xG,"variable.language":xK},a="[0-9](_?[0-9])*",l=`\\.(${a})`,c="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",d={className:"number",variants:[{begin:`(\\b(${c})((${l})|\\.)?|(${l}))[eE][+-]?(${a})\\b`},{begin:`\\b(${c})\\b((${l})\\b|\\.)?|(${l})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},u={className:"subst",begin:"\\$\\{",end:"\\}",keywords:o,contains:[]},p={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,u],subLanguage:"xml"}},h={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,u],subLanguage:"css"}},f={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,u],subLanguage:"graphql"}},m={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,u]},g={className:"comment",variants:[e.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:xF+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),e.C_BLOCK_COMMENT_MODE,e.C_LINE_COMMENT_MODE]},u.contains=(b=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,p,h,f,m,{match:/\$\d+/},d]).concat({begin:/\{/,end:/\}/,keywords:o,contains:["self"].concat(b)}),y=(x=[].concat(g,u.contains)).concat([{begin:/(\s*)\(/,end:/\)/,keywords:o,contains:["self"].concat(x)}]),v={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:o,contains:y},w={variants:[{match:[/class/,/\s+/,xF,/\s+/,/extends/,/\s+/,n.concat(xF,"(",n.concat(/\./,xF),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,xF],scope:{1:"keyword",3:"title.class"}}]},k={relevance:0,match:n.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:"title.class",keywords:{_:[...xV,...xW]}},N={match:n.concat(/\b/,(t=[...xq,"super","import"].map(e=>`${e}\\s*\\(`),n.concat("(?!",t.join("|"),")")),xF,n.lookahead(/\s*\(/)),className:"title.function",relevance:0},S={begin:n.concat(/\./,n.lookahead(n.concat(xF,/(?![0-9A-Za-z$_(])/))),end:xF,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},C="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",j={match:[/const|var|let/,/\s+/,xF,/\s*/,/=\s*/,/(async\s*)?/,n.lookahead(C)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[v]},{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:o,exports:{PARAMS_CONTAINS:y,CLASS_REFERENCE:k},illegal:/#(?![$_A-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),{label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,p,h,f,m,g,{match:/\$\d+/},d,k,{scope:"attr",match:xF+n.lookahead(":"),relevance:0},j,{begin:"("+e.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[g,e.REGEXP_MODE,{className:"function",begin:C,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:e.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:o,contains:y}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:"<>",end:"</>"},{match:/<[A-Za-z0-9\\._:-]+\s*\/>/},{begin:r,"on:begin":s,end:i}],subLanguage:"xml",contains:[{begin:r,end:i,skip:!0,contains:["self"]}]}]},{variants:[{match:[/function/,/\s+/,xF,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[v],illegal:/%/},{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+e.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[v,e.inherit(e.TITLE_MODE,{begin:xF,className:"title.function"})]},{match:/\.\.\./,relevance:0},S,{match:"\\$"+xF,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[v]},N,{relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"},w,{match:[/get|set/,/\s+/,xF,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},v]},{match:/\$[(.]/}]}),A=["any","void","number","boolean","string","object","never","symbol","bigint","unknown"],T={begin:[/namespace/,/\s+/,e.IDENT_RE],beginScope:{1:"keyword",3:"title.class"}},O={beginKeywords:"interface",end:/\{/,excludeEnd:!0,keywords:{keyword:"interface extends",built_in:A},contains:[M.exports.CLASS_REFERENCE]},_={$pattern:xF,keyword:xH.concat(["type","interface","public","private","protected","implements","declare","abstract","readonly","enum","override","satisfies"]),literal:xU,built_in:xG.concat(A),"variable.language":xK},D={className:"meta",begin:"@"+xF},R=(e,t,n)=>{let r=e.contains.findIndex(e=>e.label===t);if(-1===r)throw Error("can not find mode to replace");e.contains.splice(r,1,n)};Object.assign(M.keywords,_),M.exports.PARAMS_CONTAINS.push(D);let I=M.contains.find(e=>"attr"===e.scope),L=Object.assign({},I,{match:E.concat(xF,E.lookahead(/\s*\?:/))});return M.exports.PARAMS_CONTAINS.push([M.exports.CLASS_REFERENCE,I,L]),M.contains=M.contains.concat([D,T,O,L]),R(M,"shebang",e.SHEBANG()),R(M,"use_strict",{className:"meta",relevance:10,begin:/^\s*['"]use strict['"]/}),M.contains.find(e=>"func.def"===e.label).relevance=0,Object.assign(M,{name:"TypeScript",aliases:["ts","tsx","mts","cts"]}),M}function xZ(e){let t=e.regex,n=t.concat(/[\p{L}_]/u,t.optional(/[\p{L}0-9_.-]*:/u),/[\p{L}0-9_.-]*/u),r={className:"symbol",begin:/&[a-z]+;|&#[0-9]+;|&#x[a-f0-9]+;/},i={begin:/\s/,contains:[{className:"keyword",begin:/#?[a-z_][a-z1-9_-]+/,illegal:/\n/}]},s=e.inherit(i,{begin:/\(/,end:/\)/}),o=e.inherit(e.APOS_STRING_MODE,{className:"string"}),a=e.inherit(e.QUOTE_STRING_MODE,{className:"string"}),l={endsWithParent:!0,illegal:/</,relevance:0,contains:[{className:"attr",begin:/[\p{L}0-9._:-]+/u,relevance:0},{begin:/=\s*/,relevance:0,contains:[{className:"string",endsParent:!0,variants:[{begin:/"/,end:/"/,contains:[r]},{begin:/'/,end:/'/,contains:[r]},{begin:/[^\s"'=<>`]+/}]}]}]};return{name:"HTML, XML",aliases:["html","xhtml","rss","atom","xjb","xsd","xsl","plist","wsf","svg"],case_insensitive:!0,unicodeRegex:!0,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,relevance:10,contains:[i,a,o,s,{begin:/\[/,end:/\]/,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,contains:[i,s,a,o]}]}]},e.COMMENT(/<!--/,/-->/,{relevance:10}),{begin:/<!\[CDATA\[/,end:/\]\]>/,relevance:10},r,{className:"meta",end:/\?>/,variants:[{begin:/<\?xml/,relevance:10,contains:[a]},{begin:/<\?[a-z][a-z0-9]+/}]},{className:"tag",begin:/<style(?=\s|>)/,end:/>/,keywords:{name:"style"},contains:[l],starts:{end:/<\/style>/,returnEnd:!0,subLanguage:["css","xml"]}},{className:"tag",begin:/<script(?=\s|>)/,end:/>/,keywords:{name:"script"},contains:[l],starts:{end:/<\/script>/,returnEnd:!0,subLanguage:["javascript","handlebars","xml"]}},{className:"tag",begin:/<>|<\/>/},{className:"tag",begin:t.concat(/</,t.lookahead(t.concat(n,t.either(/\/>/,/>/,/\s/)))),end:/\/?>/,contains:[{className:"name",begin:n,relevance:0,starts:l}]},{className:"tag",begin:t.concat(/<\//,t.lookahead(t.concat(n,/>/))),contains:[{className:"name",begin:n,relevance:0},{begin:/>/,relevance:0,endsParent:!0}]}]}}function xX(e){let t="true false yes no null",n="[\\w#;/?:@&=+$,.~*'()[\\]]+",r={className:"string",relevance:0,variants:[{begin:/"/,end:/"/},{begin:/\S+/}],contains:[e.BACKSLASH_ESCAPE,{className:"template-variable",variants:[{begin:/\{\{/,end:/\}\}/},{begin:/%\{/,end:/\}/}]}]},i=e.inherit(r,{variants:[{begin:/'/,end:/'/,contains:[{begin:/''/,relevance:0}]},{begin:/"/,end:/"/},{begin:/[^\s,{}[\]]+/}]}),s={end:",",endsWithParent:!0,excludeEnd:!0,keywords:t,relevance:0},o=[{className:"attr",variants:[{begin:/[\w*@][\w*@ :()\./-]*:(?=[ \t]|$)/},{begin:/"[\w*@][\w*@ :()\./-]*":(?=[ \t]|$)/},{begin:/'[\w*@][\w*@ :()\./-]*':(?=[ \t]|$)/}]},{className:"meta",begin:"^---\\s*$",relevance:10},{className:"string",begin:"[\\|>]([1-9]?[+-])?[ ]*\\n( +)[^ ][^\\n]*\\n(\\2[^\\n]+\\n?)*"},{begin:"<%[%=-]?",end:"[%-]?%>",subLanguage:"ruby",excludeBegin:!0,excludeEnd:!0,relevance:0},{className:"type",begin:"!\\w+!"+n},{className:"type",begin:"!<"+n+">"},{className:"type",begin:"!"+n},{className:"type",begin:"!!"+n},{className:"meta",begin:"&"+e.UNDERSCORE_IDENT_RE+"$"},{className:"meta",begin:"\\*"+e.UNDERSCORE_IDENT_RE+"$"},{className:"bullet",begin:"-(?=[ ]|$)",relevance:0},e.HASH_COMMENT_MODE,{beginKeywords:t,keywords:{literal:t}},{className:"number",begin:"\\b[0-9]{4}(-[0-9][0-9]){0,2}([Tt \\t][0-9][0-9]?(:[0-9][0-9]){2})?(\\.[0-9]*)?([ \\t])*(Z|[-+][0-9][0-9]?(:[0-9][0-9])?)?\\b"},{className:"number",begin:e.C_NUMBER_RE+"\\b",relevance:0},{begin:/\{/,end:/\}/,contains:[s],illegal:"\\n",relevance:0},{begin:"\\[",end:"\\]",contains:[s],illegal:"\\n",relevance:0},{className:"string",relevance:0,begin:/'/,end:/'/,contains:[{match:/''/,scope:"char.escape",relevance:0}]},r],a=[...o];return a.pop(),a.push(i),s.contains=a,{name:"YAML",case_insensitive:!0,aliases:["yml"],contains:o}}var xY=e.i(897802);let xQ=e.i(454184).default,x0={};function x1(e){let t=xQ.newInstance();return e&&i(e),{highlight:n,highlightAuto:function(e,i){let s;(0,xY.ok)("string"==typeof e,"expected `string` as `value`");let o=(i||x0).subset||r(),a=-1,l=0;for(;++a<o.length;){let r=o[a];if(!t.getLanguage(r))continue;let c=n(r,e,i);c.data&&void 0!==c.data.relevance&&c.data.relevance>l&&(l=c.data.relevance,s=c)}return s||{type:"root",children:[],data:{language:void 0,relevance:l}}},listLanguages:r,register:i,registerAlias:function(e,n){if("string"==typeof e)(0,xY.ok)(void 0!==n),t.registerAliases("string"==typeof n?n:[...n],{languageName:e});else{let n;for(n in e)if(Object.hasOwn(e,n)){let r=e[n];t.registerAliases("string"==typeof r?r:[...r],{languageName:n})}}},registered:function(e){return!!t.getLanguage(e)}};function n(e,n,r){(0,xY.ok)("string"==typeof e,"expected `string` as `name`"),(0,xY.ok)("string"==typeof n,"expected `string` as `value`");let i=r||x0,s="string"==typeof i.prefix?i.prefix:"hljs-";if(!t.getLanguage(e))throw Error("Unknown language: `"+e+"` is not registered");t.configure({__emitter:x2,classPrefix:s});let o=t.highlight(n,{ignoreIllegals:!0,language:e});if(o.errorRaised)throw Error("Could not highlight with `Highlight.js`",{cause:o.errorRaised});let a=o._emitter.root,l=a.data;return l.language=o.language,l.relevance=o.relevance,a}function r(){return t.listLanguages()}function i(e,n){if("string"==typeof e)(0,xY.ok)(void 0!==n,"expected `grammar`"),t.registerLanguage(e,n);else{let n;for(n in e)Object.hasOwn(e,n)&&t.registerLanguage(n,e[n])}}}class x2{constructor(e){this.options=e,this.root={type:"root",children:[],data:{language:void 0,relevance:0}},this.stack=[this.root]}addText(e){if(""===e)return;let t=this.stack[this.stack.length-1],n=t.children[t.children.length-1];n&&"text"===n.type?n.value+=e:t.children.push({type:"text",value:e})}startScope(e){this.openNode(String(e))}endScope(){this.closeNode()}__addSublanguage(e,t){let n=this.stack[this.stack.length-1],r=e.root.children;t?n.children.push({type:"element",tagName:"span",properties:{className:[t]},children:r}):n.children.push(...r)}openNode(e){let t=this,n=e.split(".").map(function(e,n){return n?e+"_".repeat(n):t.options.classPrefix+e}),r=this.stack[this.stack.length-1],i={type:"element",tagName:"span",properties:{className:n},children:[]};r.children.push(i),this.stack.push(i)}closeNode(){this.stack.pop()}finalize(){}toHTML(){return""}}let x3=pT.create({name:"callout",group:"block",content:"block+",defining:!0,addAttributes:()=>({type:{default:"info",parseHTML:e=>e.getAttribute("data-callout-type")||"info",renderHTML:e=>({"data-callout-type":e.type})}}),parseHTML:()=>[{tag:'div[data-callout="true"]'}],renderHTML:({HTMLAttributes:e})=>["div",uc(e,{"data-callout":"true",class:`callout callout-${e["data-callout-type"]||"info"}`}),0]});function x5(e,t,n){let{selection:r,doc:i}=e,s=i.resolve(r.from);for(;s.depth>1;)s=i.resolve(s.before(s.depth));if(0===s.depth)return!1;let o=s.before(1),a=i.nodeAt(o);if(!a)return!1;let l=s.index(0),c="up"===n?l-1:l+1;if(c<0||c>=i.childCount)return!1;let d=i.child(c),u=e.tr,p=o+a.nodeSize,h="up"===n?o-d.nodeSize:p,f="up"===n?o:p+d.nodeSize;if("up"===n)u=(u=(u=u.delete(o,p)).insert(h,a)).setSelection(sB.create(u.doc,h));else{u=u.delete(o,p);let e=f-a.nodeSize;u=(u=u.insert(e,a)).setSelection(sB.create(u.doc,e))}return t&&t(u.scrollIntoView()),!0}let x4="cabinet-drag-handle",x6="cabinet-gutter-add",x9=pt.create({name:"dragHandle",addKeyboardShortcuts:()=>({"Mod-Alt-ArrowUp":({editor:e})=>x5(e.state,e.view.dispatch,"up"),"Mod-Alt-ArrowDown":({editor:e})=>x5(e.state,e.view.dispatch,"down"),"Alt-Shift-ArrowUp":({editor:e})=>x5(e.state,e.view.dispatch,"up"),"Alt-Shift-ArrowDown":({editor:e})=>x5(e.state,e.view.dispatch,"down")}),addProseMirrorPlugins(){let e,t,n=null,r="u">typeof document?((e=document.getElementById(x4))||((e=document.createElement("div")).id=x4,e.setAttribute("data-drag-handle","true"),e.draggable=!0,e.innerHTML='<svg width="10" height="16" viewBox="0 0 10 16" fill="currentColor" xmlns="http://www.w3.org/2000/svg"><circle cx="2.5" cy="3" r="1.2"/><circle cx="2.5" cy="8" r="1.2"/><circle cx="2.5" cy="13" r="1.2"/><circle cx="7.5" cy="3" r="1.2"/><circle cx="7.5" cy="8" r="1.2"/><circle cx="7.5" cy="13" r="1.2"/></svg>',Object.assign(e.style,{position:"absolute",display:"none",cursor:"grab",padding:"2px 4px",borderRadius:"4px",color:"var(--muted-foreground)",opacity:"0.55",zIndex:"40",userSelect:"none",transition:"opacity 120ms ease"}),e.addEventListener("mouseenter",()=>{e&&(e.style.opacity="1")}),e.addEventListener("mouseleave",()=>{e&&(e.style.opacity="0.55")}),document.body.appendChild(e)),e):null,i="u">typeof document?((t=document.getElementById(x6))||((t=document.createElement("button")).id=x6,t.type="button",t.setAttribute("aria-label","Add block"),t.title="Add block",t.innerHTML='<svg width="10" height="10" viewBox="0 0 10 10" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M5 1V9M1 5H9" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/></svg>',Object.assign(t.style,{position:"absolute",display:"none",alignItems:"center",justifyContent:"center",width:"18px",height:"18px",cursor:"pointer",borderRadius:"4px",color:"var(--muted-foreground)",opacity:"0.55",zIndex:"40",transition:"opacity 120ms ease, background 120ms ease",background:"transparent",border:"none",padding:"0"}),t.addEventListener("mouseenter",()=>{t&&(t.style.opacity="1",t.style.background="var(--muted)")}),t.addEventListener("mouseleave",()=>{t&&(t.style.opacity="0.55",t.style.background="transparent")}),document.body.appendChild(t)),t):null,s=()=>{r&&(r.style.display="none"),i&&(i.style.display="none"),n=null};return[new sY({key:new s1("cabinetDragHandle"),view:e=>{if(!r)return{destroy:()=>{}};let t=t=>{if(!e.editable)return;let o=e.dom.getBoundingClientRect();if(t.clientX<o.left-60||t.clientX>o.right+60||t.clientY<o.top||t.clientY>o.bottom)return void s();let a=function(e,t){let n=e.posAtCoords(t);if(!n)return null;let r=e.state.doc.resolve(n.inside>=0?n.inside:n.pos);for(;r.depth>0&&!r.parent.type.isBlock;)r=e.state.doc.resolve(r.before());let i=r.depth;for(;i>1&&"doc"!==e.state.doc.resolve(r.before(i)).parent.type.name;)i-=1;let s=0===i?0:r.before(Math.max(i,1)),o=e.state.doc.nodeAt(s);if(!o)return null;let a=e.nodeDOM(s);return{pos:s,node:o,dom:a}}(e,{left:Math.max(o.left+20,Math.min(o.right-20,t.clientX)),top:t.clientY});if(!a?.dom||!(a.dom instanceof HTMLElement))return void s();n=a;let l=a.dom.getBoundingClientRect();r.style.display="flex",r.style.top=`${window.scrollY+l.top+4}px`,r.style.left=`${window.scrollX+l.left-22}px`,i&&(i.style.display="flex",i.style.top=`${window.scrollY+l.top+4}px`,i.style.left=`${window.scrollX+l.left-44}px`)},o=()=>s(),a=()=>{if(!n)return;let t=n.pos+n.node.nodeSize,r=t<=e.state.doc.content.size,i=e.state.tr;if(r){let n=sz.create(e.state.doc,Math.min(t-1,e.state.doc.content.size));e.dispatch(i.setSelection(n))}e.focus();let s=e.state.tr.split(e.state.selection.from);e.dispatch(s),e.dom.dispatchEvent(new KeyboardEvent("keydown",{key:"/",bubbles:!0,cancelable:!0}))},l=t=>{if(!n||!t.dataTransfer)return;let{pos:r,dom:i}=n,s=e.state.tr.setSelection(sB.create(e.state.doc,r));e.dispatch(s);let o=e.state.selection.content(),a=document.createElement("div");a.appendChild(e.someProp("clipboardSerializer")?.serializeFragment(o.content)??document.createElement("div")),t.dataTransfer.clearData(),t.dataTransfer.setData("text/html",a.innerHTML),t.dataTransfer.setData("text/plain",i.textContent??""),t.dataTransfer.effectAllowed="copyMove",t.dataTransfer.setDragImage(i,0,0),e.dragging={slice:o,move:!0}};return window.addEventListener("mousemove",t),e.dom.addEventListener("mouseleave",o),r.addEventListener("dragstart",l),i&&i.addEventListener("click",a),{destroy(){window.removeEventListener("mousemove",t),e.dom.removeEventListener("mouseleave",o),r.removeEventListener("dragstart",l),i&&i.removeEventListener("click",a),s()}}}})]}}),x7=new s1("headingAnchors");function x8(e){let t=[],n=new Map;return e.descendants((e,r)=>{if("heading"!==e.type.name)return;let i=e.textContent.toLowerCase().replace(/[^\w\s-]/g,"").trim().replace(/\s+/g,"-").replace(/-+/g,"-");if(!i)return;let s=n.get(i)??0;n.set(i,s+1);let o=0===s?i:`${i}-${s}`;t.push(a3.node(r,r+e.nodeSize,{id:o}))}),a6.create(e,t)}let ye=pt.create({name:"headingAnchors",addProseMirrorPlugins:()=>[new sY({key:x7,state:{init:(e,{doc:t})=>x8(t),apply:(e,t)=>e.docChanged?x8(e.doc):t},props:{decorations:e=>x7.getState(e)}})]});function yt(e){return e.value||e.children||[]}function yn({doc:e,name:t,lowlight:n,defaultLanguage:r}){let i=[];return d7(e,e=>e.type.name===t).forEach(e=>{var t;let s=e.pos+1,o=e.node.attrs.language||r,a=n.listLanguages();(function e(t,n=[]){return t.flatMap(t=>{let r=[...n,...t.properties?t.properties.className:[]];return t.children?e(t.children,r):{text:t.value,classes:r}})})(o&&(a.includes(o)||xQ.getLanguage(o)||(null==(t=n.registered)?void 0:t.call(n,o)))?yt(n.highlight(o,e.node.textContent)):yt(n.highlightAuto(e.node.textContent))).forEach(e=>{let t=s+e.text.length;if(e.classes.length){let n=a3.inline(s,t,{class:e.classes.join(" ")});i.push(n)}s=t})}),a6.create(e,i)}var yr=xe.extend({addOptions(){var e;return{...null==(e=this.parent)?void 0:e.call(this),lowlight:{},languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:4,HTMLAttributes:{}}},addProseMirrorPlugins(){var e;return[...(null==(e=this.parent)?void 0:e.call(this))||[],function({name:e,lowlight:t,defaultLanguage:n}){if(!["highlight","highlightAuto","listLanguages"].every(e=>"function"==typeof t[e]))throw Error("You should provide an instance of lowlight to use the code-block-lowlight extension");let r=new sY({key:new s1("lowlight"),state:{init:(r,{doc:i})=>yn({doc:i,name:e,lowlight:t,defaultLanguage:n}),apply:(r,i,s,o)=>{let a=s.selection.$head.parent.type.name,l=o.selection.$head.parent.type.name,c=d7(s.doc,t=>t.type.name===e),d=d7(o.doc,t=>t.type.name===e);return r.docChanged&&([a,l].includes(e)||d.length!==c.length||r.steps.some(e=>void 0!==e.from&&void 0!==e.to&&c.some(t=>t.pos>=e.from&&t.pos+t.node.nodeSize<=e.to)))?yn({doc:r.doc,name:e,lowlight:t,defaultLanguage:n}):i.map(r.mapping,r.doc)}},props:{decorations:e=>r.getState(e)}});return r}({name:this.name,lowlight:this.options.lowlight,defaultLanguage:this.options.defaultLanguage})]}});let yi=(0,o.default)("maximize",[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]]),ys=(0,o.default)("minimize-2",[["path",{d:"m14 10 7-7",key:"oa77jy"}],["path",{d:"M20 10h-6V4",key:"mjg0md"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M4 14h6v6",key:"rmj7iw"}]]),yo=(0,o.default)("zoom-in",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]),ya=(0,o.default)("zoom-out",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]);function yl({svg:e,className:t,allowPlainWheel:n,maxHeight:r,onExpand:i,onClose:o}){let[a,l]=(0,f.useState)(1),[c,d]=(0,f.useState)({x:0,y:0}),[u,p]=(0,f.useState)(!1),[h,m]=(0,f.useState)(r),g=(0,f.useRef)({x:0,y:0,panX:0,panY:0}),b=(0,f.useRef)(null);(0,f.useLayoutEffect)(()=>{if(null==r)return;let e=b.current?.querySelector("svg");if(!e)return;let t=e.getBoundingClientRect().height;t&&m(Math.min(Math.round(t)+32,r))},[e,r]);let x=(0,f.useCallback)(e=>{if(!(n||e.ctrlKey||e.metaKey))return;e.preventDefault();let t=e.deltaY>0?-.25:.25;l(e=>Math.min(Math.max(e+t,.25),5))},[n]),y=(0,f.useCallback)(e=>{0===e.button&&(p(!0),g.current={x:e.clientX,y:e.clientY,panX:c.x,panY:c.y},e.target.setPointerCapture(e.pointerId))},[c]),w=(0,f.useCallback)(e=>{u&&d({x:g.current.panX+(e.clientX-g.current.x),y:g.current.panY+(e.clientY-g.current.y)})},[u]),k=(0,f.useCallback)(()=>p(!1),[]);return(0,s.jsxs)("div",{className:`relative overflow-hidden ${t??""}`,style:{cursor:u?"grabbing":"grab",height:null!=r?h:void 0},onWheel:x,onPointerDown:y,onPointerMove:w,onPointerUp:k,children:[(0,s.jsx)("div",{ref:b,className:"flex items-center justify-center w-full h-full min-h-full p-4 [&_svg]:max-w-full origin-center select-none",style:{transform:`translate(${c.x}px, ${c.y}px) scale(${a})`},dangerouslySetInnerHTML:{__html:e}}),(0,s.jsxs)("div",{className:"absolute top-2 right-2 flex items-center gap-0.5 rounded-md border border-border bg-card/90 backdrop-blur px-1 py-0.5 shadow-sm",contentEditable:!1,children:[(0,s.jsx)(v.Button,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>l(e=>Math.max(e-.25,.25)),title:"Zoom out",children:(0,s.jsx)(ya,{className:"h-3.5 w-3.5"})}),(0,s.jsxs)("button",{type:"button",onClick:()=>{l(1),d({x:0,y:0})},title:"Reset view",className:"text-[11px] text-muted-foreground tabular-nums w-9 text-center select-none hover:text-foreground",children:[Math.round(100*a),"%"]}),(0,s.jsx)(v.Button,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>l(e=>Math.min(e+.25,5)),title:"Zoom in",children:(0,s.jsx)(yo,{className:"h-3.5 w-3.5"})}),i&&(0,s.jsx)(v.Button,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:i,title:"Pop out",children:(0,s.jsx)(yi,{className:"h-3.5 w-3.5"})}),o&&(0,s.jsx)(v.Button,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:o,title:"Close",children:(0,s.jsx)(ys,{className:"h-3.5 w-3.5"})})]})]})}function yc({svg:e,className:t,maxHeight:n}){let[r,i]=(0,f.useState)(!1);return(0,f.useEffect)(()=>{if(!r)return;let e=e=>"Escape"===e.key&&i(!1);return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[r]),(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(yl,{svg:e,className:t,maxHeight:n,onExpand:()=>i(!0)}),r&&"u">typeof document&&(0,tx.createPortal)((0,s.jsx)("div",{className:"fixed inset-0 z-50 bg-background/95 backdrop-blur",children:(0,s.jsx)(yl,{svg:e,className:"w-full h-full",allowPlainWheel:!0,onClose:()=>i(!1)})}),document.body)]})}let yd="rounded-md bg-muted p-4 font-mono text-sm",yu=0;function yp(t){let{node:n,editor:r}=t,i="mermaid"===(n.attrs.language??""),o=n.textContent,[a,l]=(0,f.useState)(""),[c,d]=(0,f.useState)(""),u=(0,f.useRef)(null);if((0,f.useEffect)(()=>{if(!i)return;let t=o.trim();if(!t){l(""),d("");return}return u.current&&clearTimeout(u.current),u.current=setTimeout(async()=>{try{let n=(await e.A(890793)).default;n.initialize({startOnLoad:!1,theme:document.documentElement.classList.contains("dark")?"dark":"default",securityLevel:"loose",suppressErrorRendering:!0}),await n.parse(t);let{svg:r}=await n.render(`mermaid-cb-${++yu}`,t);l(r),d("")}catch(e){document.querySelectorAll('[id^="dmermaid-cb-"]').forEach(e=>e.remove()),d(e instanceof Error?e.message:"Failed to render")}},300),()=>{u.current&&clearTimeout(u.current)}},[i,o]),!i)return(0,s.jsx)(hh,{as:"pre",className:yd,children:(0,s.jsx)(hp,{as:"code"})});let p=r.isEditable,h=a&&(!p||!c);return(0,s.jsxs)(hh,{className:"my-3",children:[(0,s.jsx)("pre",{className:yd,style:{display:!p&&h?"none":void 0},children:(0,s.jsx)(hp,{as:"code"})}),h&&(0,s.jsx)("div",{className:"mermaid-preview rounded-md border border-border bg-card",contentEditable:!1,children:(0,s.jsx)(yc,{svg:a,className:"w-full",maxHeight:600})}),p&&c&&(0,s.jsxs)("div",{className:"rounded-md border border-red-500/30 bg-red-500/5 p-2 text-xs text-red-500",contentEditable:!1,children:["Mermaid error: ",c]})]})}let yh=u9.create({name:"proofSpan",priority:900,inclusive:!1,keepOnSplit:!1,addAttributes:()=>({spanId:{default:null,parseHTML:e=>e.getAttribute("id"),renderHTML:e=>({id:e.spanId})},origin:{default:"ai",parseHTML:e=>e.getAttribute("origin"),renderHTML:e=>({origin:e.origin})},basis:{default:null,parseHTML:e=>e.getAttribute("basis"),renderHTML:e=>({basis:e.basis})},basisDetail:{default:null,parseHTML:e=>e.getAttribute("basis-detail"),renderHTML:e=>({"basis-detail":e.basisDetail})},by:{default:null,parseHTML:e=>e.getAttribute("by"),renderHTML:e=>({by:e.by})},at:{default:null,parseHTML:e=>e.getAttribute("at"),renderHTML:e=>({at:e.at})},inResponseTo:{default:null,parseHTML:e=>e.getAttribute("in-response-to"),renderHTML:e=>({"in-response-to":e.inResponseTo})}}),parseHTML:()=>[{tag:"proof-span"}],renderHTML:({HTMLAttributes:e})=>["proof-span",uc(e,{class:"proof-span"}),0]});var yf=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/;function ym(e){let{node:t,updateAttributes:n,selected:r,editor:i}=e,o=t.attrs,a=(0,f.useRef)(null),l=(0,f.useRef)(null),[c,d]=(0,f.useState)(null),u=o.align??"center",p=(0,f.useCallback)((e,t)=>{if(!i.isEditable)return;e.preventDefault(),e.stopPropagation();let r=a.current,s=l.current;if(!r||!s)return;let o=e.clientX,c=r.getBoundingClientRect().width,u=s.parentElement?.getBoundingClientRect().width??800,p=e=>{d(Math.max(80,Math.min(u,c+("right"===t?e.clientX-o:o-e.clientX))))},h=()=>{window.removeEventListener("pointermove",p),window.removeEventListener("pointerup",h),d(e=>(null!=e&&n({width:Math.round(e)}),null))};window.addEventListener("pointermove",p),window.addEventListener("pointerup",h)},[i.isEditable,n]),h=null!=c?`${Math.round(c)}px`:"number"==typeof o.width?`${o.width}px`:"string"==typeof o.width&&o.width?o.width:void 0,m="left"===u?"mr-auto":"right"===u?"ml-auto":"mx-auto";return(0,s.jsx)(hh,{as:"div",className:`resizable-image my-3 ${m}`,"data-align":u,style:{width:h??"fit-content",maxWidth:"100%"},children:(0,s.jsxs)("div",{ref:l,className:`relative group inline-block max-w-full ${r?"ring-2 ring-primary rounded-md":""}`,contentEditable:!1,children:[(0,s.jsx)("img",{ref:a,src:o.src,alt:o.alt??"",title:o.title??void 0,className:"block rounded-md max-w-full h-auto",style:{width:h},draggable:!1}),i.isEditable&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{"aria-label":"Resize from left",onPointerDown:e=>p(e,"left"),className:"hover-reveal resize-hit absolute left-0 top-0 bottom-0 w-2 cursor-ew-resize opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center",children:(0,s.jsx)("div",{className:"w-1 h-8 bg-card border border-border rounded-full shadow"})}),(0,s.jsx)("div",{"aria-label":"Resize from right",onPointerDown:e=>p(e,"right"),className:"hover-reveal resize-hit absolute right-0 top-0 bottom-0 w-2 cursor-ew-resize opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center",children:(0,s.jsx)("div",{className:"w-1 h-8 bg-card border border-border rounded-full shadow"})}),null!=c&&(0,s.jsxs)("div",{className:"absolute top-1 right-1 text-[10px] px-1.5 py-0.5 rounded bg-primary/80 text-primary-foreground font-mono",children:[Math.round(c),"px"]})]})]})})}let yg=pT.create({name:"image",addOptions:()=>({inline:!1,allowBase64:!1,HTMLAttributes:{},resize:!1}),inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},draggable:!0,addAttributes:()=>({src:{default:null},alt:{default:null},title:{default:null},width:{default:null},height:{default:null}}),parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML({HTMLAttributes:e}){return["img",uc(this.options.HTMLAttributes,e)]},parseMarkdown:(e,t)=>t.createNode("image",{src:e.href,title:e.title,alt:e.text}),renderMarkdown:e=>{var t,n,r,i,s,o;let a=null!=(n=null==(t=e.attrs)?void 0:t.src)?n:"",l=null!=(i=null==(r=e.attrs)?void 0:r.alt)?i:"",c=null!=(o=null==(s=e.attrs)?void 0:s.title)?o:"";return c?``:``},addNodeView(){if(!this.options.resize||!this.options.resize.enabled||"u"<typeof document)return null;let{directions:e,minWidth:t,minHeight:n,alwaysPreserveAspectRatio:r}=this.options.resize;return({node:i,getPos:s,HTMLAttributes:o,editor:a})=>{let l=document.createElement("img");Object.entries(o).forEach(([e,t])=>{if(null!=t)switch(e){case"width":case"height":break;default:l.setAttribute(e,t)}}),l.src=o.src;let c=new pv({element:l,editor:a,node:i,getPos:s,onResize:(e,t)=>{l.style.width=`${e}px`,l.style.height=`${t}px`},onCommit:(e,t)=>{let n=s();void 0!==n&&this.editor.chain().setNodeSelection(n).updateAttributes(this.name,{width:e,height:t}).run()},onUpdate:(e,t,n)=>e.type===i.type,options:{directions:e,min:{width:t,height:n},preserveAspectRatio:!0===r}}),d=c.dom;return d.style.visibility="hidden",d.style.pointerEvents="none",l.onload=()=>{d.style.visibility="",d.style.pointerEvents=""},c}},addCommands(){return{setImage:e=>({commands:t})=>t.insertContent({type:this.name,attrs:e})}},addInputRules(){return[pb({find:yf,type:this.type,getAttributes:e=>{let[,,t,n,r]=e;return{src:n,alt:t,title:r}}})]}}).extend({name:"image",draggable:!0,addAttributes(){return{...this.parent?.(),width:{default:null,parseHTML:e=>{let t=e.getAttribute("width")??e.style.width;if(!t)return null;let n=/^(\d+)(px)?$/.exec(t);return n?Number(n[1]):t},renderHTML:e=>{if(!e.width)return{};let t="number"==typeof e.width?`${e.width}px`:e.width;return{style:`width: ${t}`}}},align:{default:null,parseHTML:e=>e.getAttribute("data-align"),renderHTML:e=>e.align?{"data-align":e.align}:{}}}},addNodeView:()=>hx(ym)}),yb=new s1("wikiLinkDecorator"),yx="wikiLinkDecorator:refresh";function yy(e){let{has:t}=fl.getState(),n=e.schema.marks.wikiLink;if(!n)return a6.empty;let r=[];return e.doc.descendants((e,i)=>{if(!e.isText)return;let s=e.marks.find(e=>e.type===n);if(!s)return;let o=s.attrs.slug;!o||t(o)||r.push(a3.inline(i,i+e.nodeSize,{"data-broken":"true"}))}),a6.create(e.doc,r)}let yv=/\[\[([a-z0-9-]+)(?:\|([^\]#|]+)|#([a-z0-9-]+))?\]\]$/,yw=u9.create({name:"wikiLink",priority:1e3,keepOnSplit:!1,inclusive:!1,addAttributes:()=>({slug:{default:null,parseHTML:e=>e.getAttribute("data-slug"),renderHTML:e=>({"data-slug":e.slug})},alias:{default:null,parseHTML:e=>e.getAttribute("data-alias"),renderHTML:e=>null!=e.alias?{"data-alias":e.alias}:{}},anchor:{default:null,parseHTML:e=>e.getAttribute("data-anchor"),renderHTML:e=>null!=e.anchor?{"data-anchor":e.anchor}:{}}}),parseHTML:()=>[{tag:'a[data-wiki-link="true"]'}],renderHTML({HTMLAttributes:e}){let t=String(e["data-slug"]??""),n=null!=e["data-anchor"]?String(e["data-anchor"]):null;return["a",uc(e,{"data-wiki-link":"true",href:n?`#wiki:${t}#${n}`:`#wiki:${t}`,class:"wiki-link"}),0]},addInputRules(){return[new u3({find:yv,handler:({state:e,range:t,match:n})=>{let r=n[1]??"",i=n[2]??null,s=n[3]??null,o=i??(s?`${r}#${s}`:r),{tr:a}=e;a.replaceWith(t.from,t.to,e.schema.text(o,[this.type.create({slug:r,alias:i,anchor:s})]))}})]},addProseMirrorPlugins:()=>[new sY({key:yb,state:{init:(e,t)=>yy(t),apply:(e,t,n,r)=>e.getMeta(yx)||e.docChanged?yy(r):t.map(e.mapping,e.doc)},props:{decorations:e=>yb.getState(e)??a6.empty},view(e){let t=fl.subscribe(()=>{let t=e.state.tr.setMeta(yx,!0);e.dispatch(t)});return{destroy(){t()}}}})],addCommands(){return{setWikiLink:e=>({commands:t})=>t.setMark(this.name,{slug:e.slug,alias:e.alias??null,anchor:e.anchor??null}),unsetWikiLink:()=>({commands:e})=>e.unsetMark(this.name)}}}),yk=x1({bash:xx,css:xS,go:xC,javascript:xR,json:xI,markdown:xL,python:xP,rust:xz,shell:x$,sql:xB,typescript:xJ,xml:xZ,yaml:xX}),yN=[xb.configure({heading:{levels:[1,2,3,4]},codeBlock:!1,link:!1,underline:!1}),yr.configure({lowlight:yk,HTMLAttributes:{class:yd}}).extend({addNodeView:()=>hx(yp)}),bs.configure({placeholder:"Start writing, or press '/' for commands..."}),yg.configure({HTMLAttributes:{class:"rounded-lg max-w-full"},allowBase64:!1}),bk.configure({resizable:!0,lastColumnResizable:!1,HTMLAttributes:{class:"border-collapse w-full"}}),bm,bh,bf,bJ.configure({HTMLAttributes:{class:"task-list"}}),bG.configure({nested:!0}),gI.configure({openOnClick:!1,HTMLAttributes:{class:"text-primary underline cursor-pointer"}}).extend({parseHTML:()=>[{tag:'a[href]:not([data-wiki-link="true"])'}],addKeyboardShortcuts(){return{"Mod-e":()=>{let{state:e}=this.editor,{from:t,to:n}=e.selection;if(t===n)return!1;let r=this.editor.getAttributes("link").href??"",i=window.prompt("Link URL",r);return null!==i&&(""===i?this.editor.chain().focus().extendMarkRange("link").unsetLink().run():this.editor.chain().focus().extendMarkRange("link").setLink({href:i}).run())}}}}),x3,yh,bZ.configure({types:["heading","paragraph"]}),bc,bd,x9,ye,yw],yS=/\.(md|markdown)$/i;function yC(e){try{return decodeURIComponent(e)}catch{return e}}async function yj(e,t,n){let r=encodeURIComponent(e).replace(/%2F/g,"/"),i=await fetch((0,ev.apiUrl)(`/api/agent/files/${r}`),{method:"POST",headers:{"Content-Type":"application/json","Idempotency-Key":crypto.randomUUID(),...{}},body:JSON.stringify({baseRevision:t,by:"human",ops:[n]})});if(409===i.status){let e=await i.json();return"STALE_REVISION"===e.code&&e.snapshot?.revision!==void 0?{ok:!1,stale:!0,newRevision:e.snapshot.revision}:{ok:!1,stale:!1}}return{ok:i.ok,stale:!1}}async function yE(e){let{path:t,ref:n,kind:r,markdown:i,basisDetail:s,getRevision:o,refresh:a}=e,l={type:"suggestion.add",ref:n,kind:r,basis:"suggested"};"delete"!==r&&(l.markdown=i??""),s&&(l.basisDetail=s);let c=await yj(t,o(),l);return!c.ok&&c.stale&&void 0!==c.newRevision&&(await a(),c=await yj(t,c.newRevision,l)),c.ok}let yM=e=>e.replace(/\s+$/g,"").trimStart(),yA=(0,o.default)("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);function yT({anchorKey:e,anchorLabel:t,comments:n,top:r,left:i,onClick:o}){let a;if(0===n.length)return null;let l=n.filter(e=>!e.resolved);if(0===l.length)a="check";else{let e=l[0].turns.at(-1);a=e?.by.startsWith("ai:")?"dot-ai":"ring-human"}return(0,s.jsxs)("button",{type:"button",onClick:o,style:{position:"absolute",top:r,left:i,transform:"translateY(2px)"},className:"z-10 p-2 sm:p-0.5 -m-1.5 sm:m-0 rounded transition-colors hover:bg-accent focus:outline-none focus-visible:ring-1 focus-visible:ring-ring","aria-label":`Comment thread for ${t??e}`,children:["check"===a&&(0,s.jsx)(yA,{className:"h-3.5 w-3.5 text-muted-foreground/30"}),"dot-ai"===a&&(0,s.jsx)(fI,{className:"h-3.5 w-3.5 fill-primary text-primary"}),"ring-human"===a&&(0,s.jsx)(fI,{className:"h-3.5 w-3.5 text-muted-foreground/70"})]})}var yO=e.i(638154),y_="Popover",[yD,yR]=(0,N.createContextScope)(y_,[yO.createPopperScope]),yI=(0,yO.createPopperScope)(),[yL,yP]=yD(y_),yz=e=>{let{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:o,modal:a=!1}=e,l=yI(t),c=f.useRef(null),[d,u]=f.useState(!1),[p,h]=(0,C.useControllableState)({prop:r,defaultProp:i??!1,onChange:o,caller:y_});return(0,s.jsx)(yO.Root,{...l,children:(0,s.jsx)(yL,{scope:t,contentId:(0,S.useId)(),triggerRef:c,open:p,onOpenChange:h,onOpenToggle:f.useCallback(()=>h(e=>!e),[h]),hasCustomAnchor:d,onCustomAnchorAdd:f.useCallback(()=>u(!0),[]),onCustomAnchorRemove:f.useCallback(()=>u(!1),[]),modal:a,children:n})})};yz.displayName=y_;var y$="PopoverAnchor",yB=f.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=yP(y$,n),o=yI(n),{onCustomAnchorAdd:a,onCustomAnchorRemove:l}=i;return f.useEffect(()=>(a(),()=>l()),[a,l]),(0,s.jsx)(yO.Anchor,{...o,...r,ref:t})});yB.displayName=y$;var yF="PopoverTrigger";f.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=yP(yF,n),o=yI(n),a=(0,k.useComposedRefs)(t,i.triggerRef),l=(0,s.jsx)(T.Primitive.button,{type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.contentId,"data-state":y0(i.open),...r,ref:a,onClick:(0,w.composeEventHandlers)(e.onClick,i.onOpenToggle)});return i.hasCustomAnchor?l:(0,s.jsx)(yO.Anchor,{asChild:!0,...o,children:l})}).displayName=yF;var yH="PopoverPortal",[yU,yV]=yD(yH,{forceMount:void 0}),yW=e=>{let{__scopePopover:t,forceMount:n,children:r,container:i}=e,o=yP(yH,t);return(0,s.jsx)(yU,{scope:t,forceMount:n,children:(0,s.jsx)(A.Presence,{present:n||o.open,children:(0,s.jsx)(M.Portal,{asChild:!0,container:i,children:r})})})};yW.displayName=yH;var yq="PopoverContent",yK=f.forwardRef((e,t)=>{let n=yV(yq,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,o=yP(yq,e.__scopePopover);return(0,s.jsx)(A.Presence,{present:r||o.open,children:o.modal?(0,s.jsx)(yJ,{...i,ref:t}):(0,s.jsx)(yZ,{...i,ref:t})})});yK.displayName=yq;var yG=(0,R.createSlot)("PopoverContent.RemoveScroll"),yJ=f.forwardRef((e,t)=>{let n=yP(yq,e.__scopePopover),r=f.useRef(null),i=(0,k.useComposedRefs)(t,r),o=f.useRef(!1);return f.useEffect(()=>{let e=r.current;if(e)return(0,D.hideOthers)(e)},[]),(0,s.jsx)(_.RemoveScroll,{as:yG,allowPinchZoom:!0,children:(0,s.jsx)(yX,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:(0,w.composeEventHandlers)(e.onCloseAutoFocus,e=>{e.preventDefault(),o.current||n.triggerRef.current?.focus()}),onPointerDownOutside:(0,w.composeEventHandlers)(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=0===t.button&&!0===t.ctrlKey;o.current=2===t.button||n},{checkForDefaultPrevented:!1}),onFocusOutside:(0,w.composeEventHandlers)(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1})})})}),yZ=f.forwardRef((e,t)=>{let n=yP(yq,e.__scopePopover),r=f.useRef(!1),i=f.useRef(!1);return(0,s.jsx)(yX,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,"pointerdown"===t.detail.originalEvent.type&&(i.current=!0));let s=t.target;n.triggerRef.current?.contains(s)&&t.preventDefault(),"focusin"===t.detail.originalEvent.type&&i.current&&t.preventDefault()}})}),yX=f.forwardRef((e,t)=>{let{__scopePopover:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:o,disableOutsidePointerEvents:a,onEscapeKeyDown:l,onPointerDownOutside:c,onFocusOutside:d,onInteractOutside:u,...p}=e,h=yP(yq,n),f=yI(n);return(0,O.useFocusGuards)(),(0,s.jsx)(E.FocusScope,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:o,children:(0,s.jsx)(j.DismissableLayer,{asChild:!0,disableOutsidePointerEvents:a,onInteractOutside:u,onEscapeKeyDown:l,onPointerDownOutside:c,onFocusOutside:d,onDismiss:()=>h.onOpenChange(!1),children:(0,s.jsx)(yO.Content,{"data-state":y0(h.open),role:"dialog",id:h.contentId,...f,...p,ref:t,style:{...p.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),yY="PopoverClose";f.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=yP(yY,n);return(0,s.jsx)(T.Primitive.button,{type:"button",...r,ref:t,onClick:(0,w.composeEventHandlers)(e.onClick,()=>i.onOpenChange(!1))})}).displayName=yY;var yQ=f.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=yI(n);return(0,s.jsx)(yO.Arrow,{...i,...r,ref:t})});function y0(e){return e?"open":"closed"}yQ.displayName="PopoverArrow";let y1=new Intl.RelativeTimeFormat("en",{numeric:"auto"});async function y2(e,t,n,r){let i=encodeURIComponent(e).replace(/%2F/g,"/"),s=await (0,tC.wsFetch)(`/api/agent/files/${i}`,{method:"POST",headers:{"Content-Type":"application/json","Idempotency-Key":crypto.randomUUID(),...{}},body:JSON.stringify({baseRevision:t,by:n,ops:r})});if(409===s.status){let e=await s.json();return"STALE_REVISION"===e.code&&e.snapshot?.revision!==void 0?{ok:!1,stale:!0,newRevision:e.snapshot.revision}:{ok:!1,stale:!1}}return s.ok?{ok:!0,stale:!1}:{ok:!1,stale:!1}}function y3({path:e,anchorKey:t,anchorLabel:n,anchorRef:r,lineAnchor:i,comments:o,anchorEl:a,onClose:l,readOnly:c}){let[d,u]=(0,f.useState)(null),[p,h]=(0,f.useState)(""),[m,g]=(0,f.useState)(!1),b=(0,f.useRef)(null),x=o.filter(e=>!e.resolved),y=x.length>0,v=x[0]??o[0]??null;if((0,f.useEffect)(()=>{if(!a)return void u(null);let e=a.getBoundingClientRect();u({top:e.bottom+4,left:e.left})},[a]),(0,f.useEffect)(()=>{if(!a)return;let e=e=>{"Escape"===e.key&&l()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[a,l]),(0,f.useEffect)(()=>{d&&setTimeout(()=>b.current?.focus(),50)},[d]),!a||!d)return null;function w(){let t=fd.getState().byPath[e];return t?.snapshotRevision??0}async function k(){if(p.trim()&&!m){g(!0);try{let n=v?{type:"comment.reply",commentId:v.id,text:p.trim()}:i?{type:"comment.add",lineAnchor:i,text:p.trim()}:{type:"comment.add",ref:r??t,text:p.trim()},s=w(),o=await y2(e,s,"human",[n]);!o.ok&&o.stale&&void 0!==o.newRevision&&(await fd.getState().loadSidecar(e),s=o.newRevision,o=await y2(e,s,"human",[n])),o.ok&&(await fd.getState().loadSidecar(e),h(""),l())}finally{g(!1)}}}async function N(){if(v&&!m){g(!0);try{let t=v.resolved?"comment.reopen":"comment.resolve",n=w(),r=await y2(e,n,"human",[{type:t,commentId:v.id}]);!r.ok&&r.stale&&void 0!==r.newRevision&&(await fd.getState().loadSidecar(e),n=r.newRevision,r=await y2(e,n,"human",[{type:t,commentId:v.id}])),r.ok&&(await fd.getState().loadSidecar(e),l())}finally{g(!1)}}}let S=o.flatMap(e=>e.turns.map(t=>({...t,resolved:e.resolved,commentId:e.id})));return(0,s.jsxs)(yz,{open:!0,children:[(0,s.jsx)(yB,{asChild:!0,children:(0,s.jsx)("span",{"aria-hidden":"true",style:{position:"fixed",top:d.top,left:d.left,width:0,height:0,pointerEvents:"none"}})}),(0,s.jsx)(yW,{children:(0,s.jsxs)(yK,{side:"bottom",align:"start",sideOffset:4,collisionPadding:8,onInteractOutside:l,className:"z-50 w-[min(18rem,calc(100vw-1rem))] bg-popover border border-border rounded-lg shadow-xl p-3 space-y-2 text-[12px] focus:outline-none",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsx)("span",{className:"text-[11px] font-mono text-muted-foreground/60 truncate",children:n??t}),v&&!c&&(0,s.jsx)("button",{type:"button",disabled:m,onClick:()=>void N(),className:"ml-2 shrink-0 text-[10px] px-1.5 py-0.5 rounded border border-border hover:bg-accent disabled:opacity-50 transition-colors",children:v.resolved?"Reopen":"Resolve"})]}),S.length>0&&(0,s.jsx)("div",{className:"space-y-2 max-h-48 overflow-y-auto pr-1",children:S.map((e,t)=>(0,s.jsxs)("div",{className:"space-y-0.5",children:[(0,s.jsxs)("p",{className:"text-[10px] text-muted-foreground/60",children:[e.by," · ",function(e){let t=Math.round((Date.now()-new Date(e).getTime())/1e3);if(60>Math.abs(t))return y1.format(-t,"second");let n=Math.round(t/60);if(60>Math.abs(n))return y1.format(-n,"minute");let r=Math.round(n/60);return 24>Math.abs(r)?y1.format(-r,"hour"):y1.format(-Math.round(r/24),"day")}(e.at)]}),(0,s.jsx)("p",{className:"text-foreground leading-snug whitespace-pre-wrap",children:e.text})]},t))}),(!v?.resolved||0===o.length)&&(0,s.jsxs)("div",{className:"space-y-1.5 pt-1",children:[(0,s.jsx)("textarea",{ref:b,value:p,onChange:e=>h(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.metaKey||e.ctrlKey)&&k()},placeholder:y?"Reply…":"Add a comment…",rows:2,className:"w-full resize-none rounded-md border border-border bg-background px-2 py-1.5 text-[12px] focus:outline-none focus-visible:ring-1 focus-visible:ring-ring placeholder:text-muted-foreground/40"}),(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsx)("span",{className:"text-[10px] text-muted-foreground/40",children:"⌘↵ send"}),(0,s.jsx)("button",{type:"button",disabled:m||!p.trim(),onClick:()=>void k(),className:"px-2.5 py-1 rounded-md bg-primary text-primary-foreground text-[11px] font-medium hover:bg-primary/90 disabled:opacity-50 transition-colors",children:"Send"})]})]}),(0,s.jsx)(yQ,{className:"fill-border"})]})})]})}function y5({targetEl:e,path:t,onClose:n,onComment:r}){let[i,o]=(0,f.useState)(null),[a,l]=(0,f.useState)(null),[c,d]=(0,f.useState)(!1);if((0,f.useEffect)(()=>{if(!e){o(null),l(null);return}let t=e.getBoundingClientRect();o({top:t.bottom+window.scrollY+4,left:t.left+window.scrollX}),l({spanId:e.getAttribute("id")??"",origin:e.getAttribute("origin"),basis:e.getAttribute("basis"),basisDetail:e.getAttribute("basis-detail"),by:e.getAttribute("by"),at:e.getAttribute("at")})},[e]),(0,f.useEffect)(()=>{if(!e)return;let t=e=>{"Escape"===e.key&&n()};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[e,n]),!e||!i||!a)return null;async function u(e){if(!c&&a){d(!0);try{await (0,tC.wsFetch)("/api/agent/internal/span",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:t,spanId:a.spanId,action:e,idempotencyKey:crypto.randomUUID()})})}finally{d(!1),n()}}}return(0,s.jsxs)(yz,{open:!0,children:[(0,s.jsx)(yB,{asChild:!0,children:(0,s.jsx)("span",{"aria-hidden":"true",style:{position:"fixed",top:i.top,left:i.left,width:0,height:0,pointerEvents:"none"}})}),(0,s.jsx)(yW,{children:(0,s.jsxs)(yK,{side:"bottom",align:"start",sideOffset:4,collisionPadding:8,onInteractOutside:n,className:"z-50 w-[min(16rem,calc(100vw-1rem))] bg-popover border border-border rounded-lg shadow-xl p-3 space-y-2 text-[12px] focus:outline-none",children:[(0,s.jsxs)("div",{className:"space-y-0.5",children:[(0,s.jsxs)("p",{className:"font-medium text-foreground truncate",children:[a.by??"unknown"," · ",a.basis??"—"," · ",function(e){if(!e)return"";let t=Math.floor((Date.now()-new Date(e).getTime())/1e3);if(t<60)return`${t}s ago`;let n=Math.floor(t/60);if(n<60)return`${n}m ago`;let r=Math.floor(n/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}(a.at)]}),a.basisDetail&&(0,s.jsxs)("p",{className:"text-muted-foreground italic truncate",children:["“",a.basisDetail,"”"]}),a.origin&&(0,s.jsxs)("p",{className:"text-muted-foreground/60",children:["origin: ",a.origin]})]}),(0,s.jsxs)("div",{className:"flex items-center gap-1.5 pt-1",children:[(0,s.jsx)("button",{type:"button",disabled:c,onClick:()=>void u("accept"),className:"flex-1 py-1 rounded-md bg-primary text-primary-foreground text-[11px] font-medium hover:bg-primary/90 disabled:opacity-50 transition-colors",children:"Accept"}),(0,s.jsx)("button",{type:"button",disabled:c,onClick:()=>void u("revert"),className:"flex-1 py-1 rounded-md border border-border text-[11px] font-medium hover:bg-accent disabled:opacity-50 transition-colors",children:"Revert"}),(0,s.jsx)("button",{type:"button",disabled:c,onClick:()=>{r?.(),n()},className:"flex-1 py-1 rounded-md border border-border text-[11px] font-medium hover:bg-accent disabled:opacity-50 transition-colors",children:"Comment"})]}),(0,s.jsx)(yQ,{className:"fill-border"})]})})]})}async function y4(e,t,n,r){let i=encodeURIComponent(e).replace(/%2F/g,"/"),s=await (0,tC.wsFetch)(`/api/agent/files/${i}`,{method:"POST",headers:{"Content-Type":"application/json","Idempotency-Key":crypto.randomUUID(),...{}},body:JSON.stringify({baseRevision:t,by:"human",ops:[{type:n,suggestionId:r}]})});return{ok:s.ok,status:s.status}}function y6({suggestion:e,currentMarkdown:t,path:n,baseRevision:r,getLatestRevision:i,top:o,left:a,width:l,onSettled:c,readOnly:d}){let[u,p]=(0,f.useState)(!1);async function h(){if(!u){p(!0);try{let t=await y4(n,r,"suggestion.accept",e.id);t.ok||409!==t.status||(t=await y4(n,i(),"suggestion.accept",e.id))}finally{p(!1),c()}}}async function m(){if(!u){p(!0);try{await y4(n,r,"suggestion.reject",e.id)}finally{p(!1),c()}}}let g="delete"===e.kind,b="insertAfter"===e.kind||"insertBefore"===e.kind;return(0,s.jsxs)("div",{style:{position:"absolute",top:o,left:a,width:l>0?l:void 0,zIndex:30},className:"my-1 rounded-lg border border-border bg-card shadow-md text-[12px] overflow-hidden",role:"region","aria-label":`Suggestion by ${e.by}`,children:[(0,s.jsx)("div",{className:"flex items-center justify-between px-3 py-2 bg-muted/50 border-b border-border",children:(0,s.jsxs)("span",{className:"font-medium text-foreground",children:[(0,s.jsx)("span",{className:"text-primary",children:e.by})," suggests ",(0,s.jsx)("span",{className:"text-muted-foreground",children:function(e){switch(e){case"replace":return"replacing this block";case"insertAfter":return"inserting content after this block";case"insertBefore":return"inserting content before this block";case"delete":return"deleting this block"}}(e.kind)})]})}),(0,s.jsxs)("div",{className:"p-3 space-y-2",children:["replace"===e.kind&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-[10px] uppercase tracking-wider text-muted-foreground/60 mb-1",children:"─ current ─"}),(0,s.jsx)("pre",{className:"whitespace-pre-wrap font-mono text-[11px] text-muted-foreground bg-destructive/5 rounded px-2 py-1",children:t||"(empty)"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-[10px] uppercase tracking-wider text-muted-foreground/60 mb-1",children:"─ proposed ─"}),(0,s.jsx)("pre",{className:"whitespace-pre-wrap font-mono text-[11px] text-foreground bg-primary/5 rounded px-2 py-1",children:e.markdown??"(empty)"})]})]}),b&&(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-[10px] uppercase tracking-wider text-muted-foreground/60 mb-1",children:"─ will be inserted ─"}),(0,s.jsx)("pre",{className:"whitespace-pre-wrap font-mono text-[11px] text-foreground bg-primary/5 rounded px-2 py-1",children:e.markdown??"(empty)"})]}),g&&(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-[10px] uppercase tracking-wider text-muted-foreground/60 mb-1",children:"─ will be deleted ─"}),(0,s.jsx)("pre",{className:"whitespace-pre-wrap font-mono text-[11px] text-muted-foreground line-through bg-destructive/5 rounded px-2 py-1",children:t||"(empty)"})]}),e.basisDetail&&(0,s.jsxs)("p",{className:"italic text-muted-foreground/70 text-[11px]",children:["Reason: ",e.basisDetail]})]}),!d&&(0,s.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 border-t border-border bg-muted/30",children:[(0,s.jsx)("button",{type:"button",disabled:u,onClick:()=>void h(),className:"flex-1 py-1 rounded-md bg-primary text-primary-foreground text-[11px] font-medium hover:bg-primary/90 disabled:opacity-50 transition-colors",children:"Accept"}),(0,s.jsx)("button",{type:"button",disabled:u,onClick:()=>void m(),className:"flex-1 py-1 rounded-md border border-border text-[11px] font-medium hover:bg-accent disabled:opacity-50 transition-colors",children:"Reject"})]})]})}async function y9(e,t,n){let r=encodeURIComponent(e).replace(/%2F/g,"/"),i=await (0,tC.wsFetch)(`/api/agent/files/${r}`,{method:"POST",headers:{"Content-Type":"application/json","Idempotency-Key":crypto.randomUUID(),...{}},body:JSON.stringify({baseRevision:t,by:"human",ops:n})});if(409===i.status){let e=await i.json();return"STALE_REVISION"===e.code&&e.snapshot?.revision!==void 0?{ok:!1,stale:!0,newRevision:e.snapshot.revision}:{ok:!1,stale:!1}}return i.ok?{ok:!0,stale:!1}:{ok:!1,stale:!1}}let y7={replace:"Replace block",insertAfter:"Insert after",insertBefore:"Insert before",delete:"Delete block"};function y8({path:e,blockRef:t,currentMarkdown:n,anchor:r,onClose:i}){let[o,a]=(0,f.useState)("replace"),[l,c]=(0,f.useState)(n),[d,u]=(0,f.useState)(""),[p,h]=(0,f.useState)(!1),m=(0,f.useRef)(null);(0,f.useEffect)(()=>{"replace"===o?c(n):c("")},[o,n]),(0,f.useEffect)(()=>{let e=e=>{"Escape"===e.key&&i()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[i]),(0,f.useEffect)(()=>{setTimeout(()=>m.current?.focus(),50)},[]);let g="delete"!==o,b=!p&&(!g||l.trim().length>0);async function x(){if(b){h(!0);try{let n={type:"suggestion.add",ref:t,kind:o,basis:"suggested"};g&&(n.markdown=l),d.trim()&&(n.basisDetail=d.trim());let r=fd.getState().byPath[e]?.snapshotRevision??0,s=await y9(e,r,[n]);!s.ok&&s.stale&&void 0!==s.newRevision&&(await fd.getState().loadSidecar(e),r=s.newRevision,s=await y9(e,r,[n])),s.ok&&(await fd.getState().loadSidecar(e),await fd.getState().loadSnapshot(e),i())}finally{h(!1)}}}return(0,s.jsxs)(yz,{open:!0,children:[(0,s.jsx)(yB,{asChild:!0,children:(0,s.jsx)("span",{"aria-hidden":"true",style:{position:"fixed",top:r.top,left:r.left,width:0,height:0,pointerEvents:"none"}})}),(0,s.jsx)(yW,{children:(0,s.jsxs)(yK,{side:"bottom",align:"start",sideOffset:4,collisionPadding:8,onInteractOutside:i,className:"z-50 w-[min(20rem,calc(100vw-1rem))] bg-popover border border-border rounded-lg shadow-xl p-3 space-y-2.5 text-[12px] focus:outline-none",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsx)("span",{className:"font-medium text-foreground",children:"Suggest an edit"}),(0,s.jsx)("span",{className:"text-[11px] font-mono text-muted-foreground/60 truncate ml-2",children:t})]}),(0,s.jsx)("div",{className:"flex flex-wrap gap-1",children:Object.keys(y7).map(e=>(0,s.jsx)("button",{type:"button",onClick:()=>a(e),className:`px-2 py-0.5 rounded-md text-[10.5px] border transition-colors ${o===e?"bg-primary text-primary-foreground border-primary":"border-border text-muted-foreground hover:bg-accent"}`,children:y7[e]},e))}),"delete"===o&&(0,s.jsx)("pre",{className:"whitespace-pre-wrap font-mono text-[11px] text-muted-foreground line-through bg-destructive/5 rounded px-2 py-1 max-h-32 overflow-y-auto",children:n||"(empty)"}),g&&(0,s.jsxs)("div",{className:"space-y-1",children:[(0,s.jsx)("p",{className:"text-[10px] uppercase tracking-wider text-muted-foreground/60",children:"replace"===o?"proposed content":"content to insert"}),(0,s.jsx)("textarea",{ref:m,value:l,onChange:e=>c(e.target.value),rows:4,placeholder:"Markdown…",className:"w-full resize-y rounded-md border border-border bg-background px-2 py-1.5 font-mono text-[11px] focus:outline-none focus-visible:ring-1 focus-visible:ring-ring placeholder:text-muted-foreground/40"})]}),(0,s.jsx)("input",{type:"text",value:d,onChange:e=>u(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.metaKey||e.ctrlKey)&&x()},placeholder:"Reason (optional)",className:"w-full rounded-md border border-border bg-background px-2 py-1.5 text-[12px] focus:outline-none focus-visible:ring-1 focus-visible:ring-ring placeholder:text-muted-foreground/40"}),(0,s.jsxs)("div",{className:"flex items-center justify-between pt-0.5",children:[(0,s.jsx)("span",{className:"text-[10px] text-muted-foreground/40",children:"⌘↵ submit"}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("button",{type:"button",disabled:p,onClick:i,className:"px-2.5 py-1 rounded-md border border-border text-[11px] font-medium hover:bg-accent disabled:opacity-50 transition-colors",children:"Cancel"}),(0,s.jsx)("button",{type:"button",disabled:!b,onClick:()=>void x(),className:"px-2.5 py-1 rounded-md bg-primary text-primary-foreground text-[11px] font-medium hover:bg-primary/90 disabled:opacity-50 transition-colors",children:"Suggest"})]})]}),(0,s.jsx)(yQ,{className:"fill-border"})]})})]})}let ve=(0,o.default)("triangle-alert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);var fJ=fJ;let vt=(0,o.default)("info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]),vn=(0,o.default)("sigma",[["path",{d:"M18 7V5a1 1 0 0 0-1-1H6.5a.5.5 0 0 0-.4.8l4.5 6a2 2 0 0 1 0 2.4l-4.5 6a.5.5 0 0 0 .4.8H17a1 1 0 0 0 1-1v-2",key:"wuwx1p"}]]),vr=(0,o.default)("table",[["path",{d:"M12 3v18",key:"108xh3"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}]]),vi=[{label:"Text",icon:rJ.Type,description:"Start writing plain text",category:"basic",action:{type:"direct",run:e=>e.chain().focus().setParagraph().run()}},{label:"Heading 1",icon:fq,description:"Large section heading",category:"basic",action:{type:"direct",run:e=>e.chain().focus().toggleHeading({level:1}).run()}},{label:"Heading 2",icon:fK,description:"Medium section heading",category:"basic",action:{type:"direct",run:e=>e.chain().focus().toggleHeading({level:2}).run()}},{label:"Heading 3",icon:fG,description:"Small section heading",category:"basic",action:{type:"direct",run:e=>e.chain().focus().toggleHeading({level:3}).run()}},{label:"Bullet List",icon:fZ,description:"Create a bullet list",category:"basic",action:{type:"direct",run:e=>e.chain().focus().toggleBulletList().run()}},{label:"Numbered List",icon:fX,description:"Create a numbered list",category:"basic",action:{type:"direct",run:e=>e.chain().focus().toggleOrderedList().run()}},{label:"Checklist",icon:fU,description:"Create a task checklist",category:"basic",action:{type:"direct",run:e=>e.chain().focus().toggleTaskList().run()}},{label:"Code Block",icon:fD,description:"Insert a code block",category:"basic",action:{type:"direct",run:e=>e.chain().focus().toggleCodeBlock().run()}},{label:"Blockquote",icon:f1,description:"Insert a blockquote",category:"basic",action:{type:"direct",run:e=>e.chain().focus().toggleBlockquote().run()}},{label:"Divider",icon:fY,description:"Insert a horizontal rule",category:"basic",action:{type:"direct",run:e=>e.chain().focus().setHorizontalRule().run()}},{label:"Table",icon:vr,description:"Insert a 3x3 table",category:"basic",action:{type:"direct",run:e=>e.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run()}},{label:"Image",icon:fJ.default,description:"Upload, paste URL, or drop an image",category:"media",action:{type:"popover",kind:{type:"media",kind:"image"}}},{label:"Video",icon:f5,description:"Upload or paste a video URL",category:"media",action:{type:"popover",kind:{type:"media",kind:"video"}}},{label:"File",icon:nt,description:"Attach any file to this page",category:"media",action:{type:"popover",kind:{type:"media",kind:"file"}}},{label:"Callout",icon:vt,description:"Insert an info callout",category:"advanced",action:{type:"direct",run:e=>e.chain().focus().wrapIn("callout",{type:"info"}).run()}},{label:"Warning",icon:ve,description:"Insert a warning callout",category:"advanced",action:{type:"direct",run:e=>e.chain().focus().wrapIn("callout",{type:"warning"}).run()}},{label:"Math",icon:vn,description:"Insert a LaTeX math expression",category:"advanced",action:{type:"direct",run:e=>e.chain().focus().insertContent("$x=y$").run()}}];function vs({cmd:e}){switch(e.label){case"Heading 1":return(0,s.jsx)("p",{className:"font-bold text-[18px] leading-tight text-foreground/80 truncate",children:"Heading 1"});case"Heading 2":return(0,s.jsx)("p",{className:"font-semibold text-[14px] leading-tight text-foreground/80 truncate",children:"Heading 2"});case"Heading 3":return(0,s.jsx)("p",{className:"font-medium text-[12px] leading-tight text-foreground/80 truncate",children:"Heading 3"});case"Text":return(0,s.jsx)("p",{className:"text-[11px] text-foreground/60 leading-snug",children:"The quick brown fox jumps over the lazy dog."});case"Bullet List":return(0,s.jsxs)("ul",{className:"list-disc pl-4 text-[10px] text-foreground/60 space-y-0.5",children:[(0,s.jsx)("li",{children:"First item"}),(0,s.jsx)("li",{children:"Second item"}),(0,s.jsx)("li",{children:"Third item"})]});case"Numbered List":return(0,s.jsxs)("ol",{className:"list-decimal pl-4 text-[10px] text-foreground/60 space-y-0.5",children:[(0,s.jsx)("li",{children:"First item"}),(0,s.jsx)("li",{children:"Second item"}),(0,s.jsx)("li",{children:"Third item"})]});case"Checklist":return(0,s.jsxs)("div",{className:"space-y-0.5 text-[10px] text-foreground/60",children:[(0,s.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,s.jsx)("span",{className:"w-3 h-3 border border-foreground/30 rounded-sm inline-block shrink-0"}),"Pending task"]}),(0,s.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,s.jsx)("span",{className:"w-3 h-3 border border-foreground/30 rounded-sm bg-foreground/20 inline-block shrink-0"}),"Done task"]})]});case"Code Block":return(0,s.jsx)("pre",{className:"bg-muted rounded px-2 py-1 text-[10px] font-mono text-foreground/70 leading-snug",children:(0,s.jsx)("code",{children:"const x = 42;"})});case"Blockquote":return(0,s.jsx)("div",{className:"border-l-2 border-foreground/30 pl-2 text-[10px] text-foreground/60 italic",children:"A thought worth quoting."});case"Divider":return(0,s.jsx)("hr",{className:"border-foreground/20 w-full"});case"Table":return(0,s.jsxs)("table",{className:"text-[9px] border-collapse w-full",children:[(0,s.jsx)("thead",{children:(0,s.jsx)("tr",{children:["Col A","Col B","Col C"].map(e=>(0,s.jsx)("th",{className:"border border-foreground/20 px-1.5 py-0.5 text-left font-semibold bg-muted/50 text-foreground/70",children:e},e))})}),(0,s.jsx)("tbody",{children:[["1","2","3"],["4","5","6"]].map((e,t)=>(0,s.jsx)("tr",{children:e.map((e,t)=>(0,s.jsx)("td",{className:"border border-foreground/20 px-1.5 py-0.5 text-foreground/50",children:e},t))},t))})]});case"Image":return(0,s.jsxs)("div",{className:"flex items-center gap-2 text-foreground/50",children:[(0,s.jsx)(fJ.default,{className:"h-8 w-8 text-foreground/20"}),(0,s.jsx)("span",{className:"text-[10px]",children:"image.png"})]});case"Video":return(0,s.jsxs)("div",{className:"flex items-center gap-2 text-foreground/50",children:[(0,s.jsx)(f5,{className:"h-8 w-8 text-foreground/20"}),(0,s.jsx)("span",{className:"text-[10px]",children:"video.mp4"})]});case"File":return(0,s.jsxs)("div",{className:"flex items-center gap-2 text-foreground/50",children:[(0,s.jsx)(nt,{className:"h-8 w-8 text-foreground/20"}),(0,s.jsx)("span",{className:"text-[10px]",children:"attachment.pdf"})]});case"Callout":return(0,s.jsxs)("div",{className:"flex items-start gap-1.5 bg-blue-500/10 border border-blue-500/20 rounded px-2 py-1",children:[(0,s.jsx)(vt,{className:"h-3 w-3 text-blue-500 shrink-0 mt-0.5"}),(0,s.jsx)("span",{className:"text-[10px] text-foreground/60",children:"Info callout"})]});case"Warning":return(0,s.jsxs)("div",{className:"flex items-start gap-1.5 bg-warning/10 border border-warning/20 rounded px-2 py-1",children:[(0,s.jsx)(ve,{className:"h-3 w-3 text-warning shrink-0 mt-0.5"}),(0,s.jsx)("span",{className:"text-[10px] text-foreground/60",children:"Warning callout"})]});case"Math":return(0,s.jsx)("p",{className:"font-mono text-[13px] text-foreground/70",children:"E = mc²"});default:return(0,s.jsx)("p",{className:"text-[10px] text-muted-foreground",children:e.description})}}function vo({editor:e}){let[t,n]=(0,f.useState)(!1),[r,i]=(0,f.useState)(""),[o,a]=(0,f.useState)(0),[l,c]=(0,f.useState)({top:0,left:0}),[d,u]=(0,f.useState)(null),p=(0,f.useRef)(null),h=tQ(e=>e.currentPath),m=vi.filter(e=>e.label.toLowerCase().includes(r.toLowerCase())||e.description.toLowerCase().includes(r.toLowerCase())),g=(0,f.useCallback)(()=>{n(!1),i(""),a(0)},[]),b=(0,f.useCallback)(t=>{if(!e)return;let{from:s}=e.state.selection,o=s-r.length-1;e.chain().focus().deleteRange({from:o,to:s}).run(),"direct"===t.action.type?(t.action.run(e),g()):(u(t.action.kind),n(!1),i(""))},[e,r,g]);if((0,f.useEffect)(()=>{if(!e)return;let s=s=>{if(!t){if("/"===s.key){let{from:t}=e.state.selection,r=e.state.doc.textBetween(Math.max(0,t-1),t);if(1===t||""===r||"\n"===r||" "===r){let r=e.view.coordsAtPos(t),s=e.view.dom.getBoundingClientRect();c({top:r.bottom-s.top+4,left:r.left-s.left}),n(!0),i(""),a(0)}}return}"Escape"===s.key?(s.preventDefault(),g()):"ArrowDown"===s.key?(s.preventDefault(),a(e=>Math.min(e+1,m.length-1))):"ArrowUp"===s.key?(s.preventDefault(),a(e=>Math.max(e-1,0))):"Enter"===s.key?(s.preventDefault(),m[o]&&b(m[o])):"Backspace"===s.key?0===r.length?g():(i(e=>e.slice(0,-1)),a(0)):" "===s.key?g():1!==s.key.length||s.metaKey||s.ctrlKey||(i(e=>e+s.key),a(0))};return window.addEventListener("keydown",s,!0),()=>window.removeEventListener("keydown",s,!0)},[e,t,r,o,m,g,b]),(0,f.useEffect)(()=>{if(!t)return;let e=e=>{p.current&&!p.current.contains(e.target)&&g()};return window.addEventListener("mousedown",e),()=>window.removeEventListener("mousedown",e)},[t,g]),(!t||0===m.length)&&!d)return null;let x=new Map;for(let e of m){let t=x.get(e.category)??[];t.push(e),x.set(e.category,t)}let y=m[o]??null;return(0,s.jsxs)(s.Fragment,{children:[t&&m.length>0&&(0,s.jsxs)("div",{ref:p,className:"absolute z-50 w-[280px] bg-popover border border-border rounded-lg shadow-lg overflow-hidden",style:{top:l.top,left:l.left},children:[(0,s.jsx)("div",{className:"max-h-[300px] overflow-y-auto py-1",children:[{key:"basic",title:"Basic"},{key:"media",title:"Media"},{key:"advanced",title:"Advanced"}].map(e=>{let t=x.get(e.key);return t&&0!==t.length?(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"text-[9px] uppercase tracking-wider text-muted-foreground px-3 pt-2 pb-1",children:e.title}),t.map(e=>{let t=m.indexOf(e),n=e.icon,r=t===o;return(0,s.jsxs)("button",{onMouseDown:t=>{t.preventDefault(),b(e)},onMouseEnter:()=>a(t),className:(0,eh.cn)("flex items-center gap-3 w-full px-3 py-1.5 text-left transition-colors",r?"bg-accent text-accent-foreground ring-1 ring-inset ring-accent-foreground/10":"hover:bg-accent/50"),children:[(0,s.jsx)(n,{className:(0,eh.cn)("h-4 w-4 shrink-0 transition-colors",r?"text-accent-foreground":"text-muted-foreground")}),(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("p",{className:"text-[12px] font-medium truncate",children:e.label}),(0,s.jsx)("p",{className:(0,eh.cn)("text-[10px] truncate transition-colors",r?"text-accent-foreground/70":"text-muted-foreground"),children:e.description})]})]},e.label)})]},e.key):null})}),y&&(0,s.jsx)("div",{className:"border-t border-border bg-muted/30 px-3 py-2 min-h-[52px] flex items-center",children:(0,s.jsx)(vs,{cmd:y})})]}),d&&e?"media"===d.type?h?(0,s.jsx)(mt,{kind:d.kind,pagePath:h,anchor:l,onCancel:()=>u(null),onInsert:t=>((t,n)=>{if(!e)return;let{url:r,alt:i,mimeType:s}=n;"image"===t||(s??"").startsWith("image/")||/\.(png|jpe?g|gif|webp|svg|avif)(\?|$)/i.test(r)?e.chain().focus().setImage({src:r,alt:i??""}).run():e.chain().focus().insertContent(`<a href="${r}">${i??r}</a>`).run(),u(null)})(d.kind,t)}):null:null:null]})}function va(e){let t=[],n=new Map;return e.state.doc.forEach((e,r)=>{if("heading"===e.type.name){let i=e.textContent,s=e.attrs.level,o=i.toLowerCase().replace(/\s+/g,"-").replace(/[^\w-]/g,"")||"heading",a=(n.get(o)??0)+1;n.set(o,a);let l=1===a?o:`${o}-${a}`;t.push({level:s,text:i,pos:r,uid:l})}}),t}function vl(e,t){try{let{node:n}=e.view.domAtPos(t.pos+1);return n.nodeType===Node.ELEMENT_NODE?n.closest("h1,h2,h3,h4,h5,h6")??n:n.parentElement?.closest("h1,h2,h3,h4,h5,h6")??null}catch{return null}}function vc({editor:e,scrollContainerRef:t}){let[n,r]=(0,f.useState)([]),[i,o]=(0,f.useState)(null),[a,l]=(0,f.useState)(!1),[c,d]=(0,f.useState)(0),[u,p]=(0,f.useState)(0),h=(0,f.useRef)([]),m=(0,f.useRef)(null),g=(0,f.useRef)(null);(0,f.useEffect)(()=>{h.current=n},[n]),(0,f.useEffect)(()=>{m.current=i},[i]),(0,f.useEffect)(()=>{if(!e)return;let t=null,n=()=>{t&&clearTimeout(t),t=setTimeout(()=>r(va(e)),250)};return e.on("update",n),r(va(e)),()=>{t&&clearTimeout(t),e.off("update",n)}},[e]),(0,f.useEffect)(()=>{let n=t.current;if(!n)return;let r=0,i=()=>{cancelAnimationFrame(r),r=requestAnimationFrame(()=>{let t=n.scrollHeight-n.clientHeight;d(t>0?Math.min(1,n.scrollTop/t):0);let r=h.current,i=m.current;if(!e||!i||0===r.length)return void p(0);let s=r.findIndex(e=>e.uid===i);if(s<0)return void p(0);let o=r[s],a=r[s+1],l=vl(e,o);if(!l)return void p(0);let c=l.offsetTop,u=Math.max(1,(a?vl(e,a)?.offsetTop??n.scrollHeight:n.scrollHeight)-c);p(Math.max(0,Math.min(1,(n.scrollTop+Math.min(96,.25*n.clientHeight)-c)/u)))})};return n.addEventListener("scroll",i,{passive:!0}),()=>{n.removeEventListener("scroll",i),cancelAnimationFrame(r)}},[e,t]),(0,f.useEffect)(()=>{g.current?.disconnect();let r=t.current;if(!r||!e||0===n.length)return;let i=new IntersectionObserver(e=>{for(let t of e)if(t.isIntersecting){let e=t.target.dataset.outlineId;e&&o(e)}},{root:r,rootMargin:"-8% 0px -72% 0px",threshold:0});for(let t of n)try{let n=vl(e,t);n&&(n.dataset.outlineId=t.uid,i.observe(n))}catch{}return g.current=i,()=>{i.disconnect()}},[n,e,t]);let b=(0,f.useCallback)(t=>{if(!e)return;let n=vl(e,t);n?.scrollIntoView({behavior:"smooth",block:"start"})},[e]),x=n.length>=2,[y,v]=(0,f.useState)(!1),w=(0,s.jsx)(s.Fragment,{children:n.map((e,t)=>(0,s.jsxs)("button",{onClick:()=>{b(e),v(!1)},title:e.text,className:(0,eh.cn)("text-left text-[10.5px] leading-snug py-0.5 rounded truncate transition-colors shrink-0",i===e.uid?"text-primary bg-primary/10 font-medium":"text-muted-foreground/60 hover:text-foreground hover:bg-accent",i===e.uid&&"relative overflow-hidden"),style:{paddingLeft:`${(e.level-1)*8+4}px`},children:[i===e.uid&&(0,s.jsx)("span",{"aria-hidden":!0,className:"absolute left-0 top-0 bottom-0 w-0.5 bg-primary/15",children:(0,s.jsx)("span",{className:"absolute bottom-0 left-0 w-full bg-primary transition-[height] duration-100 ease-out",style:{height:`${100*u}%`}})}),i===e.uid?(0,s.jsx)("span",{className:"relative z-10",children:e.text}):e.text]},`${e.uid}-${t}`))});return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{"aria-hidden":!0,className:"absolute top-0 left-0 right-0 h-0.5 z-30 pointer-events-none",children:(0,s.jsx)("div",{className:"h-full bg-primary/35 transition-[width] duration-100 ease-out",style:{width:`${100*c}%`}})}),x&&(0,s.jsxs)("div",{className:"absolute right-1 top-4 z-20 hidden xl:block w-40",children:[(0,s.jsxs)("button",{onClick:()=>l(e=>!e),className:"flex items-center gap-1 mb-1.5 px-1 py-0.5 rounded text-muted-foreground/40 hover:text-muted-foreground hover:bg-accent transition-colors text-[10px]","aria-label":a?"Expand outline":"Collapse outline",children:[(0,s.jsx)(fZ,{className:"h-3 w-3"}),!a&&(0,s.jsx)("span",{children:"Outline"})]}),!a&&(0,s.jsx)("nav",{"aria-label":"Document outline",className:"flex flex-col gap-px max-h-[50vh] overflow-y-auto pr-1",children:w})]}),x&&(0,s.jsxs)("div",{className:"absolute right-2 top-2 z-30 xl:hidden",children:[(0,s.jsx)("button",{onClick:()=>v(e=>!e),className:"flex items-center gap-1 px-1.5 py-1 rounded bg-background/80 backdrop-blur border border-border/60 text-muted-foreground/60 hover:text-foreground hover:bg-accent transition-colors text-[10px] shadow-sm","aria-label":"Document outline","aria-expanded":y,children:(0,s.jsx)(fZ,{className:"h-3.5 w-3.5"})}),y&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("button",{"aria-hidden":!0,tabIndex:-1,className:"fixed inset-0 z-0 cursor-default",onClick:()=>v(!1)}),(0,s.jsx)("nav",{"aria-label":"Document outline",className:"absolute right-0 top-9 z-10 w-52 max-h-[60vh] overflow-y-auto flex flex-col gap-px rounded-lg border border-border bg-popover p-2 shadow-lg",children:w})]})]})]})}let vd=`
|
|
128
|
+
.tiptap > * {
|
|
129
|
+
transition: opacity .35s ease;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
.tiptap > .exp-focus-dim {
|
|
133
|
+
opacity: .32;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
.tiptap > .exp-focus-active {
|
|
137
|
+
opacity: 1;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.tiptap > .exp-focus-context {
|
|
141
|
+
opacity: .6;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
body.exp-focus-cocoon .editor-toolbar-scroll,
|
|
145
|
+
body.exp-focus-cocoon aside[aria-label="AI Agent Panel"],
|
|
146
|
+
body.exp-focus-cocoon nav[aria-label="Document outline"],
|
|
147
|
+
body.exp-focus-cocoon button[aria-label="Collapse outline"],
|
|
148
|
+
body.exp-focus-cocoon button[aria-label="Expand outline"] {
|
|
149
|
+
opacity: .45;
|
|
150
|
+
transition: opacity .35s ease;
|
|
151
|
+
}
|
|
152
|
+
`;function vu(e){return e instanceof HTMLElement&&/^H[1-6]$/.test(e.tagName)}function vp({editor:e,scrollContainerRef:t}){let n=eF("focusMode"),r=(0,f.useRef)(null),i=(0,f.useRef)(null);return(0,f.useEffect)(()=>{if(!n)return;let s=t.current,o=s?.querySelector(".tiptap");if(!s||!o)return;document.body.classList.add("exp-focus-cocoon");let a=()=>{r.current=null;let e=t.current,n=e?.querySelector(".tiptap");if(!e||!n)return;let s=Array.from(n.children).filter(e=>e instanceof HTMLElement);if(0===s.length)return;let o=e.getBoundingClientRect(),a=o.top+o.height/2,l=0,c=1/0;for(let e=0;e<s.length;e++){let t=s[e].getBoundingClientRect(),n=0;if(a<t.top?n=t.top-a:a>t.bottom&&(n=a-t.bottom),n<c&&(c=n,l=e,0===n))break}if(i.current===l)return;for(let e of(i.current=l,s))e.classList.remove("exp-focus-active","exp-focus-dim","exp-focus-context");let d=Math.max(0,l-1),u=Math.min(s.length-1,l+1),p=s[l],h=vu(p)?p:(()=>{for(let e=l-1;e>=0;e--)if(vu(s[e]))return s[e];return null})(),f=h?s.indexOf(h):-1;for(let e=0;e<s.length;e++){let t=s[e],n=e>=d&&e<=u,r=e===f&&!n;t.classList.toggle("exp-focus-active",n),t.classList.toggle("exp-focus-context",r),t.classList.toggle("exp-focus-dim",!n&&!r)}},l=()=>{null===r.current&&(r.current=requestAnimationFrame(a))};return l(),s.addEventListener("scroll",l,{passive:!0}),window.addEventListener("resize",l),e?.on("update",l),()=>{s.removeEventListener("scroll",l),window.removeEventListener("resize",l),e?.off("update",l),null!==r.current&&(cancelAnimationFrame(r.current),r.current=null);let n=t.current?.querySelector(".tiptap");for(let e of Array.from(n?.children??[]))e.classList.remove("exp-focus-active","exp-focus-dim","exp-focus-context");document.body.classList.remove("exp-focus-cocoon"),i.current=null}},[e,n,t]),n?(0,s.jsx)("style",{children:vd}):null}function vh({editor:e,scrollContainerRef:t}){let[n,r]=(0,f.useState)(0),[i,o]=(0,f.useState)(0),[a,l]=(0,f.useState)({w:0,h:0}),c=(0,f.useRef)(null);(0,f.useEffect)(()=>{if(!e)return;let t=()=>{r(Math.max(1,Math.round((e.state.doc.textContent.match(/\S+/g)?.length??0)/220)))};t();let n=null,i=()=>{n&&clearTimeout(n),n=setTimeout(t,250)};return e.on("update",i),()=>{n&&clearTimeout(n),e.off("update",i)}},[e]),(0,f.useEffect)(()=>{let e=t.current;if(!e)return;let n=()=>{let t=e.scrollHeight-e.clientHeight;o(t<=0?0:Math.min(1,Math.max(0,e.scrollTop/t)))};return n(),e.addEventListener("scroll",n,{passive:!0}),()=>e.removeEventListener("scroll",n)},[t]),(0,f.useEffect)(()=>{let e=c.current;if(!e)return;let t=()=>l({w:e.offsetWidth,h:e.offsetHeight});t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]);let d=Math.max(0,Math.ceil(n*(1-i))),u=i>=.995?"Done":i>.02?`${d} min left`:`${n} min read`;return(0,s.jsxs)("div",{ref:c,className:"absolute bottom-3 left-3 z-20 pointer-events-none rounded-full bg-background/80 text-[11px] text-muted-foreground backdrop-blur shadow-sm",children:[(0,s.jsx)("span",{className:"block px-2.5 pt-[7px] pb-[5px] leading-none tabular-nums",children:u}),a.w>0?(0,s.jsx)("svg",{width:a.w,height:a.h,className:"absolute inset-0 overflow-visible text-primary","aria-hidden":!0,children:(0,s.jsx)("rect",{x:.75,y:.75,width:a.w-1.5,height:a.h-1.5,rx:(a.h-1.5)/2,fill:"none",stroke:"currentColor",strokeWidth:1.5,pathLength:1,strokeDasharray:1,strokeDashoffset:1-i,className:"transition-[stroke-dashoffset] duration-150"})}):null]})}function vf(e){let t=[],n=new Map;return e.state.doc.forEach((e,r)=>{if("heading"===e.type.name){let i=e.textContent,s=e.attrs.level,o=i.toLowerCase().replace(/\s+/g,"-").replace(/[^\w-]/g,"")||"heading",a=(n.get(o)??0)+1;n.set(o,a);let l=1===a?o:`${o}-${a}`;t.push({level:s,text:i,pos:r,uid:l})}}),t}function vm({editor:e,scrollContainerRef:t}){let n=eF("breadcrumb"),[r,i]=(0,f.useState)([]),[o,a]=(0,f.useState)(null),[l,c]=(0,f.useState)(!1),d=(0,f.useRef)(null);(0,f.useEffect)(()=>{if(!n||!e)return;let t=null,r=()=>{t&&clearTimeout(t),t=setTimeout(()=>i(vf(e)),250)};return e.on("update",r),i(vf(e)),()=>{t&&clearTimeout(t),e.off("update",r)}},[n,e]),(0,f.useEffect)(()=>{if(!n)return;let e=t.current;if(!e)return;let r=0,i=()=>{cancelAnimationFrame(r),r=requestAnimationFrame(()=>{c(e.scrollTop>40)})};return e.addEventListener("scroll",i,{passive:!0}),i(),()=>{e.removeEventListener("scroll",i),cancelAnimationFrame(r)}},[n,t]),(0,f.useEffect)(()=>{if(d.current?.disconnect(),!n)return;let i=t.current;if(!i||!e||0===r.length)return;let s=new IntersectionObserver(e=>{for(let t of e)if(t.isIntersecting){let e=t.target.dataset.outlineId;e&&a(e)}},{root:i,rootMargin:"-8% 0px -72% 0px",threshold:0});for(let t of r)try{let{node:n}=e.view.domAtPos(t.pos+1),r=n.nodeType===Node.ELEMENT_NODE?n.closest("h1,h2,h3,h4,h5,h6")??n:n.parentElement?.closest("h1,h2,h3,h4,h5,h6")??null;r&&(r.dataset.outlineId=t.uid,s.observe(r))}catch{}return d.current=s,()=>{s.disconnect()}},[n,e,r,t]);let u=(0,f.useCallback)(t=>{if(e)try{let{node:n}=e.view.domAtPos(t.pos+1),r=n.nodeType===Node.ELEMENT_NODE?n.closest("h1,h2,h3,h4,h5,h6")??n:n.parentElement?.closest("h1,h2,h3,h4,h5,h6")??null;r?.scrollIntoView({behavior:"smooth",block:"start"})}catch{}},[e]),p=(0,f.useMemo)(()=>{if(!o||0===r.length)return[];let e=r.findIndex(e=>e.uid===o);if(e<0)return[];let t=[];for(let n=0;n<=e;n+=1){let e=r[n];for(;t.length>0&&t[t.length-1].level>=e.level;)t.pop();t.push(e)}return t},[o,r]);return n&&l&&0!==p.length?(0,s.jsx)("div",{className:"absolute top-0 inset-x-0 z-20 bg-background/80 backdrop-blur border-b border-border/50 text-xs text-muted-foreground px-4 py-1.5 pr-4 xl:pr-44 pointer-events-none",children:(0,s.jsx)("div",{className:"flex items-center gap-1 overflow-hidden whitespace-nowrap",children:p.map((e,t)=>{let n=t===p.length-1;return(0,s.jsxs)("div",{className:`flex items-center gap-1 ${n?"min-w-0":"shrink-0"}`,children:[t>0&&(0,s.jsx)(e1.ChevronRight,{className:"h-3 w-3 shrink-0 opacity-50"}),(0,s.jsx)("button",{type:"button",onClick:()=>u(e),title:e.text,className:`pointer-events-auto rounded px-1 py-0.5 hover:text-foreground hover:bg-accent/60 transition-colors ${n?"truncate min-w-0":"whitespace-nowrap"}`,children:e.text})]},`${e.uid}-${t}`)})})}):null}let vg=`
|
|
153
|
+
@keyframes exp-anchor-flash {
|
|
154
|
+
0%, 18% {
|
|
155
|
+
background: color-mix(in srgb, var(--primary) 40%, transparent);
|
|
156
|
+
box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 45%, transparent);
|
|
157
|
+
}
|
|
158
|
+
100% {
|
|
159
|
+
background: transparent;
|
|
160
|
+
box-shadow: 0 0 0 2px transparent;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
.tiptap > .exp-anchor-flash {
|
|
165
|
+
animation: exp-anchor-flash 2s ease-out;
|
|
166
|
+
border-radius: 6px;
|
|
167
|
+
}
|
|
168
|
+
`;function vb({scrollContainerRef:e}){return(0,f.useEffect)(()=>{let t=e.current;if(!t)return;let n=new Set,r=new WeakMap,i=null,s=0,o=e=>{e.classList.remove("exp-anchor-flash");let t=r.get(e);t&&(e.removeEventListener("animationend",t),r.delete(e)),n.delete(e)},a=()=>{let e,s;i=null;let a=(()=>{let e=t.getBoundingClientRect().top,n=null,r=1/0;for(let i of t.querySelectorAll(".tiptap > :is(h1,h2,h3,h4,h5,h6)")){let t=Math.abs(i.getBoundingClientRect().top-e-48);t<=14&&t<r&&(n=i,r=t)}return n})();a&&((e=r.get(a))&&(a.removeEventListener("animationend",e),r.delete(a)),a.classList.remove("exp-anchor-flash"),a.offsetWidth,a.classList.add("exp-anchor-flash"),n.add(a),s=()=>o(a),r.set(a,s),a.addEventListener("animationend",s,{once:!0}))},l=()=>{s||(s=requestAnimationFrame(()=>{s=0,i&&clearTimeout(i),i=setTimeout(a,140)}))};return t.addEventListener("scroll",l,{passive:!0}),()=>{for(let e of(t.removeEventListener("scroll",l),s&&cancelAnimationFrame(s),i&&clearTimeout(i),n))o(e)}},[e]),(0,s.jsx)("style",{children:vg})}function vx(e,t){try{let{node:n}=e.view.domAtPos(t+1);if(n.nodeType===Node.ELEMENT_NODE)return n.closest("h1,h2,h3,h4,h5,h6")??n;return n.parentElement?.closest("h1,h2,h3,h4,h5,h6")??null}catch{return null}}function vy(e){let t=e?.querySelector(".tiptap");if(t)for(let e of Array.from(t.children))e.style.display=""}function vv({editor:e,scrollContainerRef:t}){let n=tQ(e=>e.currentPath),[r,i]=(0,f.useState)(!1),[o,a]=(0,f.useState)(new Set),[l,c]=(0,f.useState)(null),[d,u]=(0,f.useState)([]),p=n?`wiki-collapsed:${n}`:"wiki-collapsed:shared",h=t.current;return((0,f.useEffect)(()=>{i(!0)},[]),(0,f.useEffect)(()=>{try{let e=localStorage.getItem(p);if(!e){a(new Set),c(p);return}let t=JSON.parse(e);if(Array.isArray(t)){a(new Set(t.filter(e=>"string"==typeof e))),c(p);return}a(new Set),c(p)}catch{a(new Set),c(p)}},[p]),(0,f.useEffect)(()=>{if(l===p)try{localStorage.setItem(p,JSON.stringify(Array.from(o)))}catch{}},[o,l,p]),(0,f.useEffect)(()=>{if(!e||!r||!h||l!==p){vy(h??null),u([]);return}let t=null,n=0,i=null,s=()=>{let t,n,r,i,s,a,l=(t=[],n=new Map,r=h.getBoundingClientRect(),i=h.querySelector(".tiptap"),a=(s=i?.getBoundingClientRect())?s.right-r.left+h.scrollLeft:r.width,e.state.doc.forEach((i,s)=>{if("heading"!==i.type.name)return;let o=i.textContent,l=i.attrs.level,c=o.toLowerCase().replace(/\s+/g,"-").replace(/[^\w-]/g,"")||"heading",d=(n.get(c)??0)+1;n.set(c,d);let u=1===d?c:`${c}-${d}`,p=vx(e,s);if(!(p instanceof HTMLElement))return;let f=p.offsetTop+p.offsetHeight/2,m=p.offsetLeft;try{let e=document.createRange();e.selectNodeContents(p);let t=e.getBoundingClientRect(),n=p.getBoundingClientRect(),i=0===t.width&&0===t.height?n:t;f=i.top-r.top+h.scrollTop+.6*i.height,m=i.right-r.left+h.scrollLeft+8}catch{let e=p.getBoundingClientRect();f=e.top-r.top+h.scrollTop+e.height/2,m=e.right-r.left+h.scrollLeft+8}t.push({level:l,text:o,pos:s,uid:u,centerY:f,endLeft:m,rootRight:a})}),t);u(l);let c=h.querySelector(".tiptap");if(c)for(let t of(vy(h),l)){if(!o.has(t.uid))continue;let n=vx(e,t.pos);if(!n||!c.contains(n))continue;let r=n.nextElementSibling;for(;r&&r.parentElement===c;){let e=function(e){if(!e)return null;let t=e.tagName.match(/^H([1-6])$/);return t?Number(t[1]):null}(r);if(null!==e&&e<=t.level)break;r.style.display="none",r=r.nextElementSibling}}},a=()=>{t&&clearTimeout(t),t=setTimeout(s,250)};return s(),n=requestAnimationFrame(s),e.on("update",a),"u">typeof ResizeObserver?(i=new ResizeObserver(s)).observe(h):window.addEventListener("resize",s,{passive:!0}),()=>{t&&clearTimeout(t),cancelAnimationFrame(n),e.off("update",a),window.removeEventListener("resize",s),i?.disconnect(),vy(h)}},[o,e,h,l,r,p]),r&&h)?(0,tx.createPortal)((0,s.jsx)("div",{"aria-hidden":!0,className:"absolute inset-0 h-0 pointer-events-none z-20",children:d.map(e=>{let t=o.has(e.uid),n=e.endLeft+20;return(0,s.jsxs)("div",{children:[(0,s.jsx)("button",{type:"button","aria-label":`${t?"Expand":"Collapse"} section: ${e.text}`,"aria-pressed":t,title:e.text,onClick:()=>{a(t=>{let n=new Set(t);return n.has(e.uid)?n.delete(e.uid):n.add(e.uid),n})},className:"pointer-events-auto absolute flex h-4 w-4 -translate-y-1/2 items-center justify-center rounded border border-border/70 bg-background/90 text-muted-foreground shadow-sm backdrop-blur transition-colors hover:bg-accent hover:text-foreground",style:{top:e.centerY,left:e.endLeft},children:t?(0,s.jsx)(e1.ChevronRight,{className:"h-3 w-3"}):(0,s.jsx)(b,{className:"h-3 w-3"})}),t&&e.rootRight-n>8?(0,s.jsx)("span",{"aria-hidden":!0,className:"absolute -translate-y-1/2 border-t border-dashed border-border/70",style:{top:e.centerY,left:n,width:e.rootRight-n}}):null]},e.uid)})}),h):null}function vw(e){return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(vp,{...e}),(0,s.jsx)(vh,{...e}),(0,s.jsx)(vm,{...e}),(0,s.jsx)(vb,{...e}),(0,s.jsx)(vv,{...e})]})}let vk=(0,o.default)("link-2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]),vN=(0,o.default)("unlink",[["path",{d:"m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71",key:"yqzxt4"}],["path",{d:"m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71",key:"4qinb0"}],["line",{x1:"8",x2:"8",y1:"2",y2:"5",key:"1041cp"}],["line",{x1:"2",x2:"5",y1:"8",y2:"8",key:"14m1p5"}],["line",{x1:"16",x2:"16",y1:"19",y2:"22",key:"rzdirn"}],["line",{x1:"19",x2:"22",y1:"16",y2:"16",key:"ox905f"}]]),vS=new Map,vC=new Map,vj=(0,eN.create)((e,t)=>({path:null,backlinks:[],loading:!1,cacheVersion:0,fetch:async n=>{let r;if(!n)return;let i=(r=vS.get(n))?Date.now()-r.loadedAt>6e4?(vS.delete(n),null):r.data:null;if(i)return void e({path:n,backlinks:i,loading:!1});e({path:n,backlinks:[],loading:!0});let s=vC.get(n);if(s){try{let r=await s.promise;if(t().path!==n)return;e({backlinks:r,loading:!1})}catch{t().path===n&&e({loading:!1})}return}let o=new AbortController,a=(async()=>{let e=await (0,tC.wsFetch)(`/api/wiki/backlinks?path=${encodeURIComponent(n)}`,{signal:o.signal});return e.ok?(await e.json()).backlinks??[]:[]})().finally(()=>{vC.delete(n)});vC.set(n,{promise:a,controller:o});try{let r=await a;if(o.signal.aborted)return;if(vS.delete(n),vS.set(n,{data:r,loadedAt:Date.now()}),vS.size>30){let e=vS.keys().next().value;void 0!==e&&vS.delete(e)}if(t().path!==n)return;e({backlinks:r,loading:!1})}catch(r){if("AbortError"===r.name||t().path!==n)return;e({backlinks:[],loading:!1})}},cancel:()=>{let{path:n}=t();n&&vC.get(n)?.controller.abort(),t().loading&&e({loading:!1})},invalidateAll:()=>{vS.clear(),e({cacheVersion:t().cacheVersion+1})}})),vE="kb-backlinks-collapsed";function vM({currentPath:e}){let[t,n]=(0,f.useState)(!1),r=fl(e=>e.has),i=vj(e=>e.path),o=vj(e=>e.backlinks),a=vj(e=>e.loading),l=vj(e=>e.cacheVersion),c=i===e?o:[];return((0,f.useEffect)(()=>{"1"===localStorage.getItem(vE)&&n(!0)},[]),(0,f.useEffect)(()=>{if(t||!e)return;let n=setTimeout(()=>{vj.getState().fetch(e)},200);return()=>{clearTimeout(n),vj.getState().cancel()}},[e,t,l]),t||a||0!==c.length)?(0,s.jsx)("div",{className:"max-w-[var(--editor-max-w,48rem)] mx-auto px-4 sm:px-8 pb-8 pt-1",children:(0,s.jsxs)("div",{className:"border-t border-border/60 pt-4",children:[(0,s.jsxs)("button",{onClick:()=>{let e=!t;n(e);try{localStorage.setItem(vE,e?"1":"0")}catch{}},className:"flex items-center gap-1.5 text-[11px] text-muted-foreground/60 hover:text-muted-foreground transition-colors mb-2","aria-expanded":!t,children:[t?(0,s.jsx)(e1.ChevronRight,{className:"h-3 w-3 shrink-0"}):(0,s.jsx)(b,{className:"h-3 w-3 shrink-0"}),(0,s.jsx)(vk,{className:"h-3 w-3 shrink-0"}),(0,s.jsx)("span",{className:"font-medium",children:"Linked from"}),c.length>0&&(0,s.jsxs)("span",{className:"opacity-50 tabular-nums",children:["(",c.length,")"]}),a&&(0,s.jsx)("span",{className:"opacity-40 ml-1",children:"…"})]}),!t&&c.length>0&&(0,s.jsx)("ul",{className:"flex flex-col gap-1.5",children:c.map(e=>{var t,n;let i,o=r(((t=e.path).split("/").pop()??t).replace(/\.md$/i,""));return(0,s.jsxs)("li",{className:"flex flex-col",children:[(0,s.jsxs)("button",{onClick:()=>o&&tQ.getState().loadPage(e.path),className:o?"text-left text-[12px] text-primary/70 hover:text-primary hover:underline underline-offset-2 truncate transition-colors flex items-center gap-1":"text-left text-[12px] text-muted-foreground/40 truncate cursor-default flex items-center gap-1",title:o?e.path:`${e.path} (file not found)`,children:[!o&&(0,s.jsx)(vN,{className:"h-2.5 w-2.5 shrink-0 text-muted-foreground/30"}),(i=(n=e.path).replace(/\.md$/i,"").split("/")).length>1?i.slice(-2).join(" / "):i[0]??n]}),e.snippet&&(0,s.jsx)("p",{className:o?"text-[10.5px] text-muted-foreground/50 line-clamp-1 mt-0.5":"text-[10.5px] text-muted-foreground/25 line-clamp-1 mt-0.5",children:e.snippet})]},e.path)})})]})}):null}let vA=(0,o.default)("arrow-down",[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]),vT=(0,o.default)("arrow-left",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]),vO=(0,o.default)("arrow-right",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]),v_=(0,o.default)("arrow-up",[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]),vD=(0,o.default)("columns-3",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]]),vR=(0,o.default)("panel-top",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}]]),vI=(0,o.default)("rows-3",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M21 9H3",key:"1338ky"}],["path",{d:"M21 15H3",key:"9uk58r"}]]);function vL({label:e,icon:t,disabled:n,active:r,danger:i,onAction:o}){return(0,s.jsx)("button",{type:"button","aria-label":e,title:e,disabled:n,onMouseDown:e=>e.preventDefault(),onClick:e=>{e.preventDefault(),o()},className:(0,eh.cn)("h-7 w-7 inline-flex items-center justify-center rounded text-foreground/80 hover:bg-accent transition-colors disabled:pointer-events-none disabled:opacity-35",r&&"bg-accent text-foreground",i&&"text-destructive hover:bg-destructive/10"),children:(0,s.jsx)(t,{className:"h-3.5 w-3.5"})})}function vP(){return(0,s.jsx)("div",{className:"mx-1 h-5 w-px bg-border"})}function vz({editor:e}){if(!e)return null;let t=()=>{if(!l$(e.state))return null;try{return l6(e.state)}catch{return null}},n=t=>{t()&&(e.commands.focus(),e.commands.fixTables())},r=n=>{let r=t();if(!r)return;let i=r.top,s=i+n;if(!(s<0)&&!(s>=r.map.height)){var o;(o={from:i,to:s},(e,t)=>{let{from:n,to:r,select:i=!0,pos:s=e.selection.from}=o,a=e.tr;return!!function(e){var t,n,r,i,s;let o,{tr:a,originIndex:l,targetIndex:c,select:d,pos:u}=e,p=l0(a.doc.resolve(u));if(!p)return!1;let h=null==(t=l5(a,l))?void 0:t.indexes,f=null==(n=l5(a,c))?void 0:n.indexes;if(!h||!f||h.includes(c))return!1;let m=(r=p.node,i=h,s=f,o=lX(r),lY(r,o=lQ(o,i,s,0)));if(a.replaceWith(p.pos,p.pos+p.node.nodeSize,m),!d)return!0;let g=lI.get(m),b=p.start,x=g.positionAt(c,g.width-1,m),y=a.doc.resolve(b+x),v=g.positionAt(c,0,m),w=a.doc.resolve(b+v);return a.setSelection(lq.rowSelection(y,w)),!0}({tr:a,originIndex:n,targetIndex:r,select:i,pos:s})&&(null==t||t(a),!0)})(e.state,e.view.dispatch),e.commands.focus()}},i=n=>{let r=t();if(!r)return;let i=r.left,s=i+n;if(!(s<0)&&!(s>=r.map.width)){var o;(o={from:i,to:s},(e,t)=>{let{from:n,to:r,select:i=!0,pos:s=e.selection.from}=o,a=e.tr;return!!function(e){var t,n,r,i,s;let o,{tr:a,originIndex:l,targetIndex:c,select:d,pos:u}=e,p=l0(a.doc.resolve(u));if(!p)return!1;let h=null==(t=l3(a,l))?void 0:t.indexes,f=null==(n=l3(a,c))?void 0:n.indexes;if(!h||!f||h.includes(c))return!1;let m=(r=p.node,i=h,s=f,o=l4(lX(r)),lY(r,o=l4(o=lQ(o,i,s,0))));if(a.replaceWith(p.pos,p.pos+p.node.nodeSize,m),!d)return!0;let g=lI.get(m),b=p.start,x=g.positionAt(g.height-1,c,m),y=a.doc.resolve(b+x),v=g.positionAt(0,c,m),w=a.doc.resolve(b+v);return a.setSelection(lq.colSelection(y,w)),!0}({tr:a,originIndex:n,targetIndex:r,select:i,pos:s})&&(null==t||t(a),!0)})(e.state,e.view.dispatch),e.commands.focus()}},o=t(),a=!!o&&o.top>0,l=!!o&&o.top<o.map.height-1,c=!!o&&o.left>0,d=!!o&&o.left<o.map.width-1;return(0,s.jsxs)(fM,{editor:e,pluginKey:"tableMenu",options:{placement:"top",offset:10},shouldShow:({editor:e})=>e.isActive("table"),className:"flex items-center gap-0.5 rounded-md border border-border bg-popover px-1 py-1 shadow-lg",children:[(0,s.jsx)(vL,{label:"Select cell text",icon:vr,onAction:()=>{let t=lz(e.state.selection.$from),n=t?.nodeAfter;t&&n&&e.chain().focus().setTextSelection({from:t.pos+1,to:t.pos+n.nodeSize-1}).run()}}),(0,s.jsx)(vP,{}),(0,s.jsx)(vL,{label:"Add row above",icon:vI,onAction:()=>n(()=>e.chain().focus().addRowBefore().run())}),(0,s.jsx)(vL,{label:"Add row below",icon:vA,onAction:()=>n(()=>e.chain().focus().addRowAfter().run())}),(0,s.jsx)(vL,{label:"Move row up",icon:v_,disabled:!a,onAction:()=>r(-1)}),(0,s.jsx)(vL,{label:"Move row down",icon:vA,disabled:!l,onAction:()=>r(1)}),(0,s.jsx)(vL,{label:"Delete row",icon:tr,danger:!0,onAction:()=>n(()=>e.chain().focus().deleteRow().run())}),(0,s.jsx)(vP,{}),(0,s.jsx)(vL,{label:"Add column before",icon:vD,onAction:()=>n(()=>e.chain().focus().addColumnBefore().run())}),(0,s.jsx)(vL,{label:"Add column after",icon:vO,onAction:()=>n(()=>e.chain().focus().addColumnAfter().run())}),(0,s.jsx)(vL,{label:"Move column left",icon:vT,disabled:!c,onAction:()=>i(-1)}),(0,s.jsx)(vL,{label:"Move column right",icon:vO,disabled:!d,onAction:()=>i(1)}),(0,s.jsx)(vL,{label:"Delete column",icon:tr,danger:!0,onAction:()=>n(()=>e.chain().focus().deleteColumn().run())}),(0,s.jsx)(vP,{}),(0,s.jsx)(vL,{label:"Toggle header row",icon:vR,onAction:()=>n(()=>e.chain().focus().toggleHeaderRow().run())}),(0,s.jsx)(vL,{label:"Toggle header column",icon:n2,onAction:()=>n(()=>e.chain().focus().toggleHeaderColumn().run())}),(0,s.jsx)(vP,{}),(0,s.jsx)(vL,{label:"Delete table",icon:tr,danger:!0,onAction:()=>e.chain().focus().deleteTable().run()})]})}let v$=["entities","concepts","comparisons"],vB=/^[a-z0-9-]+$/;function vF({editor:e,onCreateRequest:t}){let[n,r]=(0,f.useState)(!1),[i,o]=(0,f.useState)(""),[a,l]=(0,f.useState)(0),[c,d]=(0,f.useState)({top:0,left:0}),u=(0,f.useRef)(null),p=(0,f.useRef)(0),h=fl(e=>e.slugs),m=fl(e=>e.slugDir),g=fl(e=>e.has),b=Array.from(h).sort().filter(e=>!i||e.includes(i.toLowerCase())).slice(0,20),x=i.length>0&&vB.test(i)&&!g(i),y=b.length+ +!!x,v=(0,f.useCallback)(()=>{r(!1),o(""),l(0)},[]),w=(0,f.useCallback)(t=>{if(!e)return;let{from:n}=e.state.selection,r=p.current-2,i=e.state.schema.marks.wikiLink;if(!i)return;let s=i.create({slug:t,alias:null,anchor:null}),o=e.state.schema.text(t,[s]),a=e.state.tr.replaceWith(r,n,o);e.view.dispatch(a),e.commands.focus(),v()},[e,v]),k=(0,f.useCallback)(async n=>{if(e){if(n<b.length)w(b[n]??"");else if(x){let e=await t(i);e.ok?w(e.slug):v()}}},[e,b,x,i,w,t,v]);return((0,f.useEffect)(()=>{if(!e)return;let t=t=>{if(!n){if("["===t.key){let{from:t}=e.state.selection;if("["!==e.state.doc.textBetween(Math.max(0,t-1),t)||e.state.doc.resolve(t).marks().some(e=>"wikiLink"===e.type.name))return;let n=e.view.coordsAtPos(t),i=e.view.dom.getBoundingClientRect();d({top:n.bottom-i.top+4,left:n.left-i.left}),p.current=t+1,r(!0),o(""),l(0)}return}"ArrowDown"===t.key?(t.preventDefault(),l(e=>y>0?(e+1)%y:0)):"ArrowUp"===t.key?(t.preventDefault(),l(e=>y>0?(e-1+y)%y:0)):"Enter"===t.key?(t.preventDefault(),t.stopPropagation(),y>0&&k(a)):"Escape"===t.key||"]"===t.key?v():"Backspace"===t.key?0===i.length?v():(o(e=>e.slice(0,-1)),l(0)):1!==t.key.length||t.metaKey||t.ctrlKey||(o(e=>e+t.key),l(0))};return window.addEventListener("keydown",t,!0),()=>window.removeEventListener("keydown",t,!0)},[e,n,i,a,y,v,k]),(0,f.useEffect)(()=>{if(!n)return;let e=e=>{u.current&&!u.current.contains(e.target)&&v()};return window.addEventListener("mousedown",e),()=>window.removeEventListener("mousedown",e)},[n,v]),n&&0!==y)?(0,s.jsxs)("div",{ref:u,className:"absolute z-50 w-[280px] bg-popover border border-border rounded-lg shadow-lg py-1 overflow-hidden max-h-[300px] overflow-y-auto",style:{top:c.top,left:c.left},children:[b.map((e,t)=>{let n=m.get(e);return(0,s.jsxs)("button",{type:"button",onMouseDown:e=>{e.preventDefault(),k(t)},onMouseEnter:()=>l(t),className:(0,eh.cn)("flex items-center justify-between w-full px-3 py-1.5 text-left text-sm transition-colors",t===a?"bg-accent text-accent-foreground":"hover:bg-accent/50"),children:[(0,s.jsx)("span",{className:"truncate",children:e}),n&&(0,s.jsx)("span",{className:"ml-2 shrink-0 text-[10px] text-muted-foreground bg-muted px-1.5 py-0.5 rounded",children:n})]},e)}),x&&(0,s.jsx)("button",{type:"button",onMouseDown:e=>{e.preventDefault(),k(b.length)},onMouseEnter:()=>l(b.length),className:(0,eh.cn)("flex items-center w-full px-3 py-1.5 text-left text-sm transition-colors",b.length===a?"bg-accent text-accent-foreground":"hover:bg-accent/50"),children:(0,s.jsxs)("span",{className:"text-muted-foreground",children:["+ Create new “",i,"”"]})})]}):null}let vH=(0,tk.cva)("inline-flex items-center rounded-sm border px-2.5 py-0.5 text-xs font-normal transition-colors focus:outline-none focus:ring-2 focus:ring-ring",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground shadow-e-1",secondary:"border-transparent bg-secondary text-secondary-foreground",destructive:"border-transparent bg-destructive text-destructive-foreground shadow-e-1",outline:"text-foreground",accent:"border-transparent bg-accent text-accent-foreground"}},defaultVariants:{variant:"default"}});function vU({className:e,variant:t,...n}){return(0,s.jsx)("div",{className:(0,eh.cn)(vH({variant:t}),e),...n})}let vV=new Set(["title","type","status","created","updated","date","tags","sources","private","supersedes","superseded_by"]);function vW({data:e}){let[t,n]=(0,f.useState)(!1),r=Object.keys(e);if(0===r.length)return null;let i="string"==typeof e.title?e.title:null,o="string"==typeof e.type?e.type:null,a="string"==typeof e.status?e.status:null,l="string"==typeof e.created?e.created:null,c="string"==typeof e.updated?e.updated:null,d=!0===e.private,u=Array.isArray(e.tags)?e.tags:[],p=Array.isArray(e.sources)?e.sources:[],h="string"==typeof e.superseded_by?e.superseded_by:null,m=r.filter(e=>!vV.has(e));return(0,s.jsxs)("div",{className:"mb-6 rounded-sm border bg-card/40 px-4 py-3 text-xs",children:[i&&(0,s.jsx)("div",{className:"mb-2 text-base font-normal text-foreground",children:i}),(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1.5 text-muted-foreground",children:[o&&(0,s.jsx)(vU,{variant:"outline",className:"font-normal",children:o}),a&&(0,s.jsx)(vU,{variant:"outline",className:"font-normal",children:a}),d&&(0,s.jsx)(vU,{variant:"outline",className:"border-warning-ink/40 font-normal text-warning-ink",children:"private"}),h&&(0,s.jsxs)(vU,{variant:"outline",className:"border-destructive/40 font-normal text-destructive",children:["superseded → ",h]}),l&&(0,s.jsxs)("span",{children:[(0,s.jsx)("span",{className:"opacity-60",children:"created"})," ",(0,s.jsx)("span",{className:"text-foreground/80",children:l})]}),c&&c!==l&&(0,s.jsxs)("span",{children:[(0,s.jsx)("span",{className:"opacity-60",children:"updated"})," ",(0,s.jsx)("span",{className:"text-foreground/80",children:c})]})]}),u.length>0&&(0,s.jsx)("div",{className:"mt-2 flex flex-wrap gap-1",children:u.map(e=>(0,s.jsxs)(vU,{variant:"secondary",className:"font-normal text-[11px]",children:["#",e]},e))}),p.length>0&&(0,s.jsxs)("div",{className:"mt-2",children:[(0,s.jsx)("span",{className:"opacity-60",children:"sources:"})," ",(0,s.jsx)("span",{className:"text-foreground/80",children:p.join(", ")})]}),m.length>0&&(0,s.jsxs)("div",{className:"mt-2 border-t pt-2",children:[(0,s.jsxs)("button",{type:"button",onClick:()=>n(e=>!e),className:"flex items-center gap-1 text-muted-foreground hover:text-foreground",children:[t?(0,s.jsx)(b,{className:"h-3 w-3"}):(0,s.jsx)(e1.ChevronRight,{className:"h-3 w-3"}),(0,s.jsxs)("span",{children:[m.length," more field",1===m.length?"":"s"]})]}),t&&(0,s.jsx)("dl",{className:"mt-1.5 grid grid-cols-[max-content_1fr] gap-x-3 gap-y-0.5",children:m.map(t=>(0,s.jsxs)(f.Fragment,{children:[(0,s.jsx)("dt",{className:"opacity-60",children:t}),(0,s.jsx)("dd",{className:"text-foreground/80 break-words",children:function e(t){if(null==t)return"";if("string"==typeof t)return t;if("number"==typeof t||"boolean"==typeof t)return String(t);if(Array.isArray(t))return t.map(e).join(", ");try{return JSON.stringify(t)}catch{return String(t)}}(e[t])})]},t))})]})]})}function vq({containerRef:e,onComment:t,align:n="center"}){let[r,i]=(0,f.useState)(null);return((0,f.useEffect)(()=>{function t(){let t=window.getSelection();if(!t||t.isCollapsed||0===t.rangeCount)return void i(null);let r=t.getRangeAt(0),s=e.current;if(!s||!s.contains(r.commonAncestorContainer))return void i(null);let o=r.getBoundingClientRect();if(0===o.width&&0===o.height)return void i(null);if("left"===n){let e=s.getBoundingClientRect();i({top:o.top,left:e.left+8})}else i({top:o.top-38,left:o.left+o.width/2})}return document.addEventListener("selectionchange",t),()=>document.removeEventListener("selectionchange",t)},[e,n]),r)?(0,s.jsxs)("button",{type:"button",style:{position:"fixed",top:r.top,left:r.left,transform:"left"===n?void 0:"translateX(-50%)",zIndex:50},className:"flex items-center gap-1 px-2 py-1 bg-popover border border-border rounded-sm shadow-lg text-[12px] text-foreground/80 hover:text-foreground hover:bg-accent transition-colors",onMouseDown:e=>e.preventDefault(),onClick:()=>{t(),i(null)},"aria-label":"Add comment",title:"Add comment",children:[(0,s.jsx)(fI,{className:"w-3.5 h-3.5"}),(0,s.jsx)("span",{children:"Comment"})]}):null}async function vK(e,t){let n=new FormData;n.append("file",t);try{let r=await (0,tC.wsFetch)(`/api/upload/${e}`,{method:"POST",body:n});if(!r.ok)return ey(`Upload failed: ${t.name}`),null;let i=await r.json();return i.url?(0,tC.withWs)(i.url):i.url}catch{return ey(`Upload failed: ${t.name}`),null}}function vG({mode:e}={}){let{currentPath:t,content:n,saveStatus:r,frontmatter:i,isLoading:o,loadStatus:a,createMissingPage:l,editMode:c,setEditMode:d}=tQ(),p=e??c,h="viewing"===p,b="suggesting"===p,x=(0,f.useMemo)(()=>h?function(e){let t=fo.exec(e);if(!t)return{data:{},body:e};let n=t[1],r=e.slice(t[0].length),i=n.split(/\r?\n/).find(e=>""!==e.trim())??"";if(/^\s*(#{1,6}\s|<|>|-\s|\*\s|\d+\.\s)/.test(i))return{data:{},body:e};let s={},o=n.split(/\r?\n/),a=0;for(;a<o.length;){let e=o[a];if(!e||/^\s*#/.test(e)){a+=1;continue}let t=/^([A-Za-z_][\w-]*)\s*:\s*(.*)$/.exec(e);if(!t){a+=1;continue}let n=t[1],r=t[2];if(""===r.trim()){let e=[],t=a+1;for(;t<o.length&&/^\s+-\s+/.test(o[t]);){let n=/^\s+-\s+(.*)$/.exec(o[t]);n&&e.push(fa(n[1])),t+=1}if(e.length>0){s[n]=e,a=t;continue}s[n]="",a+=1;continue}s[n]=fa(r),a+=1}return 0===Object.keys(s).length?{data:{},body:e}:{data:s,body:r}}(n):{data:{},body:n},[n,h]),y=(0,r$.useViewWidthStore)(e=>r$.VIEW_WIDTH_CSS[e.width]),w=(0,r$.useViewWidthStore)(e=>r$.VIEW_ALIGN_ML[e.align]),k=h?"rtl"===x.data.dir:i?.dir==="rtl",{open:N,clearMessages:S}=tA(),{open:C,Dialog:j}=function(){let[e,t]=(0,f.useState)(!1),[n,r]=(0,f.useState)({slug:"",dir:"entities",title:""}),[i,o]=(0,f.useState)(!1),a=(0,f.useRef)(null),l=(0,f.useCallback)(e=>(r({slug:e,dir:"entities",title:e.split("-").filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}),t(!0),new Promise(e=>{a.current=e})),[]),c=(0,f.useCallback)(()=>{t(!1),a.current?.({ok:!1,slug:n.slug}),a.current=null},[n.slug]),d=(0,f.useCallback)(async()=>{let{slug:e,dir:r,title:i}=n;o(!0);try{let n=await (0,tC.wsFetch)("/api/wiki/page",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({slug:e,dir:r,title:i.trim()||void 0})});if(n.ok||409===n.status){let n=fl.getState();n.invalidate(),n.load(),t(!1),a.current?.({ok:!0,slug:e,dir:r}),a.current=null}else{let e=await n.json().catch(()=>({})),t=null!==e&&"object"==typeof e&&"error"in e&&"string"==typeof e.error?e.error:"Failed to create page";ey(t)}}catch{ey("Failed to create page")}finally{o(!1)}},[n]);return{open:l,Dialog:(0,s.jsx)(B,{open:e,onOpenChange:e=>{e||c()},children:(0,s.jsxs)(eJ,{children:[(0,s.jsx)(eZ,{children:(0,s.jsx)(eY,{children:"Create wiki page"})}),(0,s.jsxs)("div",{className:"space-y-4 py-2",children:[(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)(tS,{htmlFor:"wiki-create-slug",children:"Slug"}),(0,s.jsx)(ts.Input,{id:"wiki-create-slug",value:n.slug,readOnly:!0,className:"bg-muted cursor-default select-all"})]}),(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)(tS,{children:"Directory"}),(0,s.jsx)("div",{className:"flex gap-4",children:v$.map(e=>(0,s.jsxs)("label",{className:"flex items-center gap-1.5 text-sm cursor-pointer",children:[(0,s.jsx)("input",{type:"radio",name:"wiki-create-dir",value:e,checked:n.dir===e,onChange:()=>r(t=>({...t,dir:e})),className:"accent-primary"}),e]},e))})]}),(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)(tS,{htmlFor:"wiki-create-title",children:"Title (optional)"}),(0,s.jsx)(ts.Input,{id:"wiki-create-title",value:n.title,onChange:e=>r(t=>({...t,title:e.target.value})),placeholder:"Humanized title..."})]})]}),(0,s.jsxs)(eX,{children:[(0,s.jsx)(v.Button,{variant:"outline",onClick:c,disabled:i,children:"Cancel"}),(0,s.jsx)(v.Button,{onClick:()=>void d(),disabled:i,children:i?"Creating...":"Create"})]})]})})}}(),E=(0,f.useRef)(C);E.current=C;let M=(0,f.useRef)(!1),A=(0,f.useRef)(h);A.current=h;let T=(0,f.useRef)(null),[O,_]=(0,f.useState)(!1),[D,R]=(0,f.useState)("");(0,f.useEffect)(()=>{fl.getState().load()},[]),(0,f.useEffect)(()=>{if(!t)return;let e=setTimeout(()=>{fd.getState().loadSidecar(t)},200);return()=>clearTimeout(e)},[t]),function({path:e,mode:t,enabled:n=!0}){let r="viewing"===t;(0,f.useEffect)(()=>{if(!n||!e||r||!/\.(md|markdown)$/i.test(e))return;let t=t=>{(0,tC.wsFetch)("/api/wiki/presence",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e,action:t}),keepalive:"close"===t}).catch(()=>{})},i=!1,s=null,o=()=>{i&&"hidden"===document.visibilityState&&t("heartbeat")},a=setTimeout(()=>{i=!0,t("open"),s=setInterval(()=>t("heartbeat"),3e4),document.addEventListener("visibilitychange",o)},200);return()=>{clearTimeout(a),s&&clearInterval(s),document.removeEventListener("visibilitychange",o),i&&t("close")}},[n,e,r])}({path:t,mode:p,enabled:!0}),function({path:e,isViewingRef:t,enabled:n=!0}){let r=(0,f.useMemo)(()=>{if(!e)return"";let t=e.lastIndexOf("/");return -1===t?"":e.slice(0,t)},[e]),i=(0,tC.getActiveWorkspaceId)(),s=(0,tC.getEphemeralRoot)();(0,f.useEffect)(()=>{if(!n||(0,ev.isLite)()||!e)return;let i=e=>{fd.getState().loadSnapshot(e).then(()=>fd.getState().loadSidecar(e)),t.current&&tQ.getState().loadPage(e)},s=r?`/api/wiki/watch?dir=${encodeURIComponent(r)}`:"/api/wiki/watch",o=new EventSource((0,tC.withWs)(s));return o.onmessage=e=>{try{let t=JSON.parse(e.data),n=tQ.getState().currentPath;if(!n)return;if("rescan"===t.type)return void i(n);("change"===t.type||"add"===t.type)&&t.path===n&&i(n)}catch{}},()=>{o.close()}},[e,r,n,i,s,t])}({path:t,isViewingRef:A});let[I,L]=(0,f.useState)(null),P=(0,f.useRef)(null),[z,$]=(0,f.useState)(new Map),F=fd(e=>t?e.byPath[t]?.snapshotBlocks:void 0),H=fd(e=>t?e.byPath[t]?.sidecar?.suggestions:void 0),U=fd(e=>t?e.byPath[t]?.snapshotRevision??0:0),V=fd(e=>t?e.byPath[t]?.sidecar?.comments:void 0),W=(0,f.useMemo)(()=>F??[],[F]),q=(0,f.useMemo)(()=>V??[],[V]),K=(0,f.useMemo)(()=>H?.filter(e=>"pending"===e.status)??[],[H]),G=(0,f.useMemo)(()=>{let e={};for(let t of q)t.ref&&(e[t.ref]??=[]).push(t);return e},[q]),[J,Z]=(0,f.useState)(null),[X,Y]=(0,f.useState)(null),Q=(0,f.useCallback)(()=>{if(!T.current)return null;let e=T.current.view,{from:t}=e.state.selection,n=tQ.getState().currentPath??"",r=fd.getState().byPath[n]?.snapshotBlocks??[],i=e.state.doc.resolve(t),s=i.depth>0?i.index(0):0,o=P.current?.querySelector(".ProseMirror"),a=(o?Array.from(o.children):[])[s]??null,l=r[s],c=l?.ref??a?.getAttribute("data-block-ref")??null,d=l?.markdown??"";if(!c&&a){let n=e.domAtPos(t),r=n.node.nodeType===Node.ELEMENT_NODE?n.node:n.node.parentElement,i=r?.closest("[data-block-ref]")??null;c=i?.getAttribute("data-block-ref")??null}return c&&a?{blockRef:c,blockEl:a,markdown:d}:null},[]),ee=(0,f.useCallback)(()=>{let e=Q();if(!e)return;let t=e.blockEl.getBoundingClientRect();Y({blockRef:e.blockRef,markdown:e.markdown,anchor:{top:t.bottom+4,left:t.left}})},[Q]),et=(0,f.useCallback)(()=>{let e=Q();e&&Z({blockRef:e.blockRef,el:e.blockEl})},[Q]),{markDirty:en,flush:er,onSelectionUpdate:ei}=function({path:e,editorRef:t,scrollContainerRef:n,isLoadingRef:r,isViewingRef:i,enabled:s=!0}){let o=(0,f.useRef)(!1),a=(0,f.useRef)(!1),l=(0,f.useRef)(null),c=(0,f.useCallback)(async()=>{if(a.current||!s||i.current||"suggesting"!==tQ.getState().editMode||!o.current)return;let l=t.current,c=e??tQ.getState().currentPath;if(!l||!c)return;let d=n.current?.querySelector(".ProseMirror");if(!d)return;let u=Array.from(d.children),p=fd.getState().byPath[c]?.snapshotBlocks??[];if(0!==p.length){a.current=!0,o.current=!1;try{let e=()=>fd.getState().byPath[c]?.snapshotRevision??0,t=async()=>{await fd.getState().loadSnapshot(c),await fd.getState().loadSidecar(c)},n=Math.max(u.length,p.length),i=!1;for(let r=0;r<n;r++){let n=u[r],s=p[r],o=n?fs(n.outerHTML,c).trim():null;if(s&&null!==o){if(yM(o)!==yM(s.markdown)){let n=await yE({path:c,ref:s.ref,kind:"replace",markdown:o,getRevision:e,refresh:t});i=i||n}}else if(s&&null===o){let n=await yE({path:c,ref:s.ref,kind:"delete",getRevision:e,refresh:t});i=i||n}else if(!s&&null!==o&&o.length>0){let n=p[p.length-1]?.ref;if(n){let r=await yE({path:c,ref:n,kind:"insertAfter",markdown:o,getRevision:e,refresh:t});i=i||r}}}if(i){await t();let e=(fd.getState().byPath[c]?.snapshotBlocks??p).map(e=>e.markdown).join("\n\n");r.current=!0;let n=await (0,hN.markdownToHtml)(e,c);l.commands.setContent(n),setTimeout(()=>{r.current=!1},50)}}finally{a.current=!1}}},[s,e,t,n,r,i]),d=(0,f.useCallback)(()=>{!s||i.current||"suggesting"===tQ.getState().editMode&&(o.current=!0)},[s,i]),u=(0,f.useCallback)(e=>{if("suggesting"!==tQ.getState().editMode)return;let{from:t}=e.state.selection,n=e.state.doc.resolve(t),r=n.depth>0?n.index(0):0,i=l.current;l.current=r,null!==i&&i!==r&&o.current&&c()},[c]);return{markDirty:d,flush:c,onSelectionUpdate:u}}({path:t,editorRef:T,scrollContainerRef:P,isLoadingRef:M,isViewingRef:A});(0,f.useEffect)(()=>{if(!t)return;let e=setTimeout(()=>{fd.getState().loadSnapshot(t)},200);return()=>clearTimeout(e)},[t]),(0,f.useEffect)(()=>{if(!t||0===W.length||!P.current)return;let e=P.current,n=e.querySelector(".ProseMirror");if(!n)return;let r=Array.from(n.children),i=e.getBoundingClientRect(),s=new Map;for(let t=0;t<Math.min(r.length,W.length);t++){let n=r[t],o=W[t];n.setAttribute("data-block-ref",o.ref);let a=n.getBoundingClientRect();s.set(o.ref,{top:a.top-i.top+e.scrollTop,left:a.left-i.left,width:a.width,bottom:a.bottom-i.top+e.scrollTop})}$(s)},[t,W]);let es=function(e={},t=[]){let n=(0,cA.useRef)(e);n.current=e;let[r]=(0,cA.useState)(()=>new ha(n)),i=(0,cT.useSyncExternalStore)(r.subscribe,r.getEditor,r.getServerSnapshot);return(0,cA.useDebugValue)(i),(0,cA.useEffect)(r.onRender(t)),!function(e){var t;let[n]=(0,cA.useState)(()=>new hi(e.editor)),r=(0,p7.useSyncExternalStoreWithSelector)(n.subscribe,n.getSnapshot,n.getServerSnapshot,e.selector,null!=(t=e.equalityFn)?t:p6);hr(()=>n.watch(e.editor),[e.editor,n]),(0,cA.useDebugValue)(r)}({editor:i,selector:({transactionNumber:t})=>!1===e.shouldRerenderOnTransaction||void 0===e.shouldRerenderOnTransaction?null:e.immediatelyRender&&0===t?0:t+1}),i}({extensions:yN,content:"",editable:!h,onUpdate:(0,f.useCallback)(({editor:e})=>{if(M.current||A.current||!e)return;en();let t=fs(e.getHTML(),tQ.getState().currentPath??void 0);tQ.getState().updateContent(t)},[]),onBlur:()=>{er()},onSelectionUpdate:({editor:e})=>{ei(e)},editorProps:{attributes:{class:"focus:outline-none min-h-[calc(100vh-12rem)] px-4 sm:px-8 py-6 max-w-[var(--editor-max-w,48rem)] ml-[var(--editor-ml,auto)] mr-auto"},handleKeyDown:(e,t)=>{if((t.metaKey||t.ctrlKey)&&"a"===t.key.toLowerCase()&&l$(e.state)){let n=lz(e.state.selection.$from),r=n?.nodeAfter;if(!n||!r)return!1;let i=n.pos+1,s=n.pos+r.nodeSize-1;return(e.state.selection.from!==i||e.state.selection.to!==s)&&(t.preventDefault(),es?.chain().focus().setTextSelection({from:i,to:s}).run(),!0)}return!1},handleClick:(e,t,n)=>{let r=n.target.closest("a");if(!r)return!1;let i=r.getAttribute("href");if(!i)return!1;if("true"===r.dataset.wikiLink){n.preventDefault(),n.stopPropagation();let e=r.dataset.slug??"",t=r.dataset.anchor??null;if(!e)return!0;let i=fl.getState();if(i.has(e)){let n=i.getDir(e),r=null===n||"root"===n?`${e}.md`:`${n}/${e}.md`;tQ.getState().loadPage(r),t&&setTimeout(()=>{document.querySelector(`[id="${t}"]`)?.scrollIntoView({behavior:"smooth"})},200)}else{if(A.current)return!0;E.current(e).then(e=>{if(e.ok){let t=e.dir??"entities",n=`${t}/${e.slug}.md`;tQ.getState().loadPage(n)}})}return!0}if(/^https?:\/\//.test(i)||i.startsWith("/api/")||i.startsWith("mailto:")||i.startsWith("tel:"))return!1;n.preventDefault(),n.stopPropagation();let s=function(e,t,n){var r;let i;if(!e||/^[a-z][a-z0-9+.-]*:/i.test(e)||e.startsWith("/api/"))return null;let s=e.indexOf("#"),o=s>=0?yC(e.slice(0,s)):yC(e);if(!o)return null;yS.test(o);let a=o.replace(yS,""),l=a.startsWith("/"),c=a.startsWith("./")||a.startsWith("../");if(!l&&!c&&!o.includes("/")&&!o.includes(".")&&n?.has(a)){let e=n.getDir(a);return null===e||"root"===e?`${a}.md`:`${e}/${a}.md`}if(l)i=a.replace(/^\/+/,"");else{let e=t?.includes("/")?t.slice(0,t.lastIndexOf("/")):"";i=e?`${e}/${a.replace(/^\.\/+/,"")}`:a.replace(/^\.\/+/,"")}let d=function(e){let t=e.split("/").filter(e=>e.length>0&&"."!==e),n=[];for(let e of t)if(".."===e){if(0===n.length)return null;n.pop()}else n.push(e);return n.join("/")}(i);return null===d||""===d?null:(r=d.split("/").pop()??d,/\.[^./]+$/.test(r))?d:`${d}.md`}(i,tQ.getState().currentPath,fl.getState());if(s){tQ.getState().loadPage(s);let e=i.includes("#")?i.slice(i.indexOf("#")+1):"";e&&setTimeout(()=>{document.querySelector(`[id="${e}"]`)?.scrollIntoView({behavior:"smooth"})},200)}return!0},handlePaste:(e,t)=>{if(A.current)return!1;let n=t.clipboardData?.files,r=tQ.getState().currentPath;if(n&&n.length>0&&r){for(let e of Array.from(n))vK(r,e).then(t=>{t&&es&&(e.type.startsWith("image/")?es.chain().focus().setImage({src:t,alt:e.name}).run():es.chain().focus().insertContent(`<a href="${t}">${e.name}</a>`).run())});return!0}return!1},handleDrop:(e,t)=>{if(A.current)return!1;let n=t.dataTransfer?.files;if(!n||0===n.length)return!1;let r=tQ.getState().currentPath;if(!r)return!1;for(let e of(t.preventDefault(),Array.from(n)))vK(r,e).then(t=>{t&&es&&(e.type.startsWith("image/")?es.chain().focus().setImage({src:t,alt:e.name}).run():es.chain().focus().insertContent(`<a href="${t}">${e.name}</a>`).run())});return!0}},immediatelyRender:!1});T.current=es,(0,f.useEffect)(()=>{es?.setEditable(!h),h&&_(!1)},[es,h]);let eo=(0,f.useRef)(null),ea=(0,f.useRef)(null),[el,ec]=(0,f.useState)(null);(0,f.useEffect)(()=>{if(!es||null===t||tQ.getState().isDirty&&t===eo.current||o&&""===n)return;let e=x.body,r=`${t} ${e}`;if(ea.current===r){el!==t&&ec(t);return}eo.current=t;let i=!1;return(async()=>{M.current=!0;let n=await (0,hN.markdownToHtml)(e,h?{pagePath:t,sanitize:!0}:t);if(i||tQ.getState().currentPath!==t){M.current=!1;return}es.commands.setContent(n),ea.current=r,ec(t),setTimeout(()=>{M.current=!1},50)})(),()=>{i=!0}},[es,n,t,o,el,x.body,h]),(0,f.useEffect)(()=>{if(!h||!el)return;let e=P.current;e&&e.querySelectorAll('input[type="checkbox"]').forEach(e=>{e.disabled=!0})},[h,el,x.body]);let ed=null!==t&&(o||el!==t),[eu,ep]=(0,f.useState)(!1);if((0,f.useEffect)(()=>{if(!ed)return void ep(!1);let e=setTimeout(()=>ep(!0),150);return()=>clearTimeout(e)},[ed]),null===t)return(0,s.jsx)("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:(0,s.jsxs)("div",{className:"text-center space-y-3",children:[(0,s.jsx)("p",{className:"text-lg font-medium tracking-[-0.02em]",children:"No page selected"}),(0,s.jsx)("p",{className:"text-sm text-muted-foreground/70",children:"Select a page from the sidebar or create a new one"})]})});if("missing"===a){let e=(t.split("/").pop()||t).replace(/[-_]+/g," ").replace(/\b\w/g,e=>e.toUpperCase());return(0,s.jsx)("div",{className:"flex-1 overflow-y-auto",children:(0,s.jsx)("div",{className:"max-w-3xl mx-auto px-6 py-10 space-y-6",children:(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsx)("p",{className:"text-lg font-medium tracking-[-0.02em] text-foreground",children:e}),(0,s.jsx)("p",{className:"text-sm text-muted-foreground/80",children:"This page doesn't exist yet."}),(0,s.jsxs)("button",{onClick:()=>void l(e),className:"inline-flex items-center gap-1.5 rounded-md bg-primary px-3 py-1.5 text-[13px] font-medium text-primary-foreground hover:bg-primary/90 transition-colors",children:[(0,s.jsx)(nn,{className:"h-3.5 w-3.5"}),"Create page"]})]})})})}let eh=async()=>{if(O){if(tQ.getState().updateContent(D),es){M.current=!0;let e=await (0,hN.markdownToHtml)(D,t??void 0);es.commands.setContent(e),setTimeout(()=>{M.current=!1},50)}_(!1)}else R(tQ.getState().content),_(!0)};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[!h&&(0,s.jsxs)("div",{className:"flex items-center min-w-0",children:[(0,s.jsx)("div",{className:"flex-1 min-w-0",children:!O&&(0,s.jsx)(mr,{editor:es})}),(0,s.jsxs)("button",{onClick:eh,className:`flex items-center gap-1.5 px-3 py-1 mr-2 text-[11px] rounded-md transition-colors border border-border ${O?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-accent"}`,children:[(0,s.jsx)(r6,{className:"h-3 w-3"}),O?"Preview":"Markdown"]})]}),O?(0,s.jsx)("div",{className:"flex-1 overflow-y-auto p-4",dir:k?"rtl":void 0,children:(0,s.jsx)("textarea",{value:D,onChange:e=>R(e.target.value),className:"w-full h-full min-h-[calc(100vh-12rem)] bg-transparent font-mono text-[13px] leading-relaxed resize-none focus:outline-none",spellCheck:!1})}):(0,s.jsxs)("div",{className:"flex-1 relative",dir:k?"rtl":void 0,children:[b&&(0,s.jsx)("div",{className:"absolute top-0 inset-x-0 z-20 flex items-center justify-center gap-2 px-3 py-1 bg-primary/10 border-b border-primary/20 text-[11px] text-primary pointer-events-none",children:"Suggesting mode · your edits become suggestions for review"}),(0,s.jsx)(vc,{editor:es,scrollContainerRef:P}),(0,s.jsx)(vw,{editor:es,scrollContainerRef:P}),(0,s.jsxs)("div",{ref:P,className:`absolute inset-0 overflow-y-auto ${b?"pt-7":""}`,style:{"--editor-max-w":y,"--editor-ml":w},"data-editor-scroll":!0,children:[(0,s.jsxs)("div",{"aria-hidden":"true",className:"relative pointer-events-none",style:{height:0},children:[Object.entries(G).map(([e,t])=>{let n=z.get(e);return n?(0,s.jsx)("div",{style:{pointerEvents:"auto"},children:(0,s.jsx)(yT,{anchorKey:e,anchorLabel:e,comments:t,top:n.top+4,left:Math.max(0,n.left-20),onClick:()=>{let t=P.current?.querySelector(`[data-block-ref="${e}"]`);t&&Z({blockRef:e,el:t})}})},`pip-${e}`):null}),t&&K.map(e=>{let n=z.get(e.ref),r=W.find(t=>t.ref===e.ref);if(!n||!r)return null;let i="insertAfter"===e.kind?n.bottom+4:"insertBefore"===e.kind?Math.max(0,n.top-80):n.top;return(0,s.jsx)("div",{style:{pointerEvents:"auto"},children:(0,s.jsx)(y6,{path:t,suggestion:e,currentMarkdown:r.markdown,baseRevision:U,getLatestRevision:()=>fd.getState().byPath[t]?.snapshotRevision??0,top:i,left:n.left,width:n.width,onSettled:()=>{fd.getState().loadSidecar(t),fd.getState().loadSnapshot(t)},readOnly:h})},`sug-${e.id}`)})]}),J&&t&&(0,s.jsx)(y3,{path:t,anchorKey:J.blockRef,anchorRef:J.blockRef,anchorLabel:J.blockRef,comments:G[J.blockRef]??[],anchorEl:J.el,onClose:()=>Z(null),readOnly:h}),X&&t&&(0,s.jsx)(y8,{path:t,blockRef:X.blockRef,currentMarkdown:X.markdown,anchor:X.anchor,onClose:()=>Y(null)}),h&&Object.keys(x.data).length>0&&(0,s.jsx)("div",{className:"max-w-[var(--editor-max-w,48rem)] ml-[var(--editor-ml,auto)] mr-auto px-4 sm:px-8 pt-6",children:(0,s.jsx)(vW,{data:x.data})}),(0,s.jsx)(hn,{editor:es}),t&&/\.(md|markdown)$/i.test(t)&&(0,s.jsx)(vM,{currentPath:t}),(0,s.jsx)("div",{"aria-hidden":"true",className:"contents",onMouseOver:e=>{let t=e.target.closest(".proof-span");t&&t!==I&&L(t)},onMouseOut:e=>{let t=e.relatedTarget;t?.closest(".proof-span")||L(null)}}),t&&(0,s.jsx)(y5,{targetEl:I,path:t,onClose:()=>L(null),onComment:()=>{if(!I)return;let e=I.closest("[data-block-ref]");if(!e)return;let t=e.getAttribute("data-block-ref");t&&Z({blockRef:t,el:e})}}),!h&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(fH,{editor:es,onSuggestEdit:ee,onComment:et}),(0,s.jsx)(vz,{editor:es}),(0,s.jsx)(vo,{editor:es}),(0,s.jsx)(vF,{editor:es,onCreateRequest:E.current})]}),h&&(0,s.jsx)(vq,{containerRef:P,onComment:et}),(0,s.jsxs)("div",{className:"max-w-[var(--editor-max-w,48rem)] ml-[var(--editor-ml,auto)] mr-auto px-8 pb-8 flex items-center gap-4",children:[(0,s.jsxs)("button",{onClick:()=>{S(),N()},className:"group flex items-center gap-2 text-[13px] text-muted-foreground/50 hover:text-muted-foreground transition-colors cursor-pointer",children:[(0,s.jsx)(hk,{className:"h-3.5 w-3.5 group-hover:text-primary transition-colors"}),(0,s.jsx)("span",{children:"Edit with AI"})]}),!h&&(0,s.jsxs)("span",{className:"text-[11px] text-muted-foreground/30 select-none",children:[(0,s.jsx)("kbd",{className:"rounded px-1 py-0.5 font-mono text-[10px] ring-1 ring-foreground/10",children:"/"})," ","for commands"]})]})]}),eu&&(0,s.jsx)("div",{className:"absolute inset-0 flex items-center justify-center bg-background/80 backdrop-blur-md z-20 pointer-events-none","aria-hidden":"true",children:(0,s.jsx)(u.Loader2,{className:"h-5 w-5 animate-spin text-muted-foreground/70"})})]}),!h&&(0,s.jsxs)("div",{className:"flex items-center justify-between px-4 py-1 border-t border-border text-xs text-muted-foreground/60",children:[(0,s.jsxs)("span",{className:"text-[10.5px] text-muted-foreground/30 select-none hidden sm:block",children:[(0,s.jsx)("kbd",{className:"rounded px-1 font-mono text-[9.5px] ring-1 ring-foreground/10",children:"⌘S"})," ","save",(0,s.jsx)("span",{className:"mx-1.5 opacity-40",children:"·"}),(0,s.jsx)("kbd",{className:"rounded px-1 font-mono text-[9.5px] ring-1 ring-foreground/10",children:"/"})," ","commands"]}),(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsxs)("div",{className:"flex items-center rounded-md border border-border overflow-hidden text-[10.5px]",role:"radiogroup","aria-label":"Edit mode",children:[(0,s.jsx)("button",{type:"button",role:"radio","aria-checked":"editing"===c,onClick:()=>d("editing"),className:`px-2 py-0.5 transition-colors ${"editing"===c?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-accent hover:text-accent-foreground"}`,children:"Editing"}),(0,s.jsx)("button",{type:"button",role:"radio","aria-checked":"suggesting"===c,onClick:()=>d("suggesting"),className:`px-2 py-0.5 transition-colors ${"suggesting"===c?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-accent hover:text-accent-foreground"}`,children:"Suggesting"})]}),(0,s.jsxs)("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-[10.5px] transition-all duration-300 ${"idle"===r?"opacity-0 pointer-events-none":"opacity-100"} ${"saving"===r?"bg-muted text-muted-foreground":"saved"===r?"bg-success/10 text-success":"error"===r?"bg-destructive/10 text-destructive":""}`,children:["saving"===r&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(u.Loader2,{className:"h-2.5 w-2.5 animate-spin"}),"Saving…"]}),"saved"===r&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(g.Check,{className:"h-2.5 w-2.5"}),"Saved"]}),"error"===r&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(m.AlertCircle,{className:"h-2.5 w-2.5"}),"Save failed"]})]})]})]})]}),j]})}function vJ({path:e}){let t=(0,tC.withWs)(`/api/assets/${e}`),n=e.split("/").pop()||e,r=n.includes(".")?n.split(".").pop()?.toUpperCase():"",i=async()=>{try{await (0,tC.wsFetch)("/api/system/reveal",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e})})}catch{}};return(0,s.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,s.jsx)(ii.ViewerToolbar,{path:e,badge:r||void 0}),(0,s.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,s.jsxs)("div",{className:"flex flex-col items-center gap-4 text-center max-w-sm",children:[(0,s.jsx)("div",{className:"flex size-16 items-center justify-center rounded-2xl bg-muted",children:(0,s.jsx)(nt,{className:"size-8 text-muted-foreground/50"})}),(0,s.jsxs)("div",{className:"space-y-1",children:[(0,s.jsx)("p",{className:"text-sm font-medium",children:n}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:"This file type can't be previewed in Cabinet."})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsxs)(v.Button,{variant:"outline",size:"sm",className:"gap-2",onClick:i,children:[(0,s.jsx)(e3,{className:"h-4 w-4"}),"Open in Finder"]}),(0,s.jsxs)(v.Button,{variant:"outline",size:"sm",className:"gap-2",onClick:()=>{let e=document.createElement("a");e.href=t,e.download=n,e.click()},children:[(0,s.jsx)(t7.Download,{className:"h-4 w-4"}),"Download"]})]})]})})]})}let vZ=(0,o.default)("file-warning",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);function vX({path:e,size:t,onOpen:n}){let r=(0,tC.withWs)(`/api/assets/${e}`),i=e.split("/").pop()||e,o=i.includes(".")?i.split(".").pop()?.toUpperCase():"",a=async()=>{try{await (0,tC.wsFetch)("/api/system/reveal",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e})})}catch{}};return(0,s.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,s.jsx)(ii.ViewerToolbar,{path:e,badge:o||void 0}),(0,s.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,s.jsxs)("div",{className:"flex flex-col items-center gap-4 text-center max-w-sm",children:[(0,s.jsx)("div",{className:"flex size-16 items-center justify-center rounded-2xl bg-amber-500/10",children:(0,s.jsx)(vZ,{className:"size-8 text-amber-500"})}),(0,s.jsxs)("div",{className:"space-y-1",children:[(0,s.jsx)("p",{className:"text-sm font-medium",children:i}),(0,s.jsxs)("p",{className:"text-xs text-muted-foreground",children:["This file is ",t>=0x40000000?`${(t/0x40000000).toFixed(1)} GB`:t>=1048576?`${(t/1048576).toFixed(1)} MB`:t>=1024?`${Math.round(t/1024)} KB`:`${t} B`,". Opening it in the viewer may freeze the tab while it loads and renders."]})]}),(0,s.jsxs)("div",{className:"flex flex-wrap items-center justify-center gap-2",children:[(0,s.jsx)(v.Button,{variant:"default",size:"sm",className:"gap-2",onClick:n,children:"Open anyway"}),(0,s.jsxs)(v.Button,{variant:"outline",size:"sm",className:"gap-2",onClick:()=>window.open(r,"_blank"),children:[(0,s.jsx)(tM.ExternalLink,{className:"h-4 w-4"}),"Raw"]}),(0,s.jsxs)(v.Button,{variant:"outline",size:"sm",className:"gap-2",onClick:()=>{let e=document.createElement("a");e.href=r,e.download=i,e.click()},children:[(0,s.jsx)(t7.Download,{className:"h-4 w-4"}),"Download"]}),(0,s.jsxs)(v.Button,{variant:"outline",size:"sm",className:"gap-2",onClick:a,children:[(0,s.jsx)(e3,{className:"h-4 w-4"}),"Open in Finder"]})]})]})})]})}function vY({path:e,title:t}){let n=(0,tC.withWs)(`/api/assets/${e}`),r=e.split("/").pop()||e,i=r.includes(".")?r.split(".").pop()?.toUpperCase():"IMG";return(0,s.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,s.jsxs)(ii.ViewerToolbar,{path:e,badge:i,children:[(0,s.jsxs)(v.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>{let e=document.createElement("a");e.href=n,e.download=r,e.click()},children:[(0,s.jsx)(t7.Download,{className:"h-3.5 w-3.5"}),"Download"]}),(0,s.jsxs)(v.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>window.open(n,"_blank"),children:[(0,s.jsx)(tM.ExternalLink,{className:"h-3.5 w-3.5"}),"Open in new tab"]})]}),(0,s.jsx)("div",{className:"flex-1 overflow-auto flex items-center justify-center bg-[#1a1a1a] p-8",children:(0,s.jsx)("img",{src:n,alt:t,className:"max-w-full max-h-full object-contain rounded-md shadow-lg",style:{imageRendering:"auto"}})})]})}function vQ({path:e,type:t}){let n=(0,tC.withWs)(`/api/assets/${e}`),r=e.split("/").pop()||e,i=r.includes(".")?r.split(".").pop()?.toUpperCase():t.toUpperCase();return(0,s.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,s.jsxs)(ii.ViewerToolbar,{path:e,badge:i,children:[(0,s.jsxs)(v.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>{let e=document.createElement("a");e.href=n,e.download=r,e.click()},children:[(0,s.jsx)(t7.Download,{className:"h-3.5 w-3.5"}),"Download"]}),(0,s.jsxs)(v.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>window.open(n,"_blank"),children:[(0,s.jsx)(tM.ExternalLink,{className:"h-3.5 w-3.5"}),"Open in new tab"]})]}),(0,s.jsx)("div",{className:"flex-1 overflow-auto flex items-center justify-center bg-[#1a1a1a] p-8",children:"video"===t?(0,s.jsx)("video",{src:n,controls:!0,className:"max-w-full max-h-full rounded-md shadow-lg",children:"Your browser does not support the video element."}):(0,s.jsxs)("div",{className:"w-full max-w-lg space-y-4",children:[(0,s.jsx)("div",{className:"text-center text-muted-foreground text-sm",children:r}),(0,s.jsx)("audio",{src:n,controls:!0,className:"w-full",children:"Your browser does not support the audio element."})]})})]})}function v0({path:t,title:n}){let[r,i]=(0,f.useState)(""),[o,a]=(0,f.useState)(""),[l,c]=(0,f.useState)(""),[d,u]=(0,f.useState)(!0),[p,h]=(0,f.useState)(!1),[m,b]=(0,f.useState)(!1),x=(0,f.useRef)(0),y=(0,tC.withWs)(`/api/assets/${t}`);t.split("/").pop();let w=(0,f.useCallback)(async()=>{u(!0),c("");try{let t=await (0,tC.wsFetch)(y);if(!t.ok)throw Error("Failed to fetch file");let n=await t.text();i(n);let r=(await e.A(890793)).default;r.initialize({startOnLoad:!1,theme:document.documentElement.classList.contains("dark")?"dark":"default",securityLevel:"loose",suppressErrorRendering:!0}),await r.parse(n.trim());let s=`mermaid-${++x.current}`,{svg:o}=await r.render(s,n.trim());a(o)}catch(e){document.querySelectorAll('[id^="dmermaid-"], [id^="d"]:has(> .error-icon)').forEach(e=>e.remove()),c(e instanceof Error?e.message:"Failed to render diagram")}finally{u(!1)}},[y]);return(0,f.useEffect)(()=>{w()},[w]),(0,s.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,s.jsxs)(ii.ViewerToolbar,{path:t,badge:"MERMAID",children:[(0,s.jsxs)(v.Button,{variant:"ghost",size:"sm",className:`h-7 gap-1.5 text-xs ${p?"bg-muted":""}`,onClick:()=>h(e=>!e),children:[p?(0,s.jsx)(rU.Eye,{className:"h-3.5 w-3.5"}):(0,s.jsx)(r6,{className:"h-3.5 w-3.5"}),p?"Diagram":"Code"]}),(0,s.jsxs)(v.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>{navigator.clipboard.writeText(r),b(!0),setTimeout(()=>b(!1),2e3)},children:[m?(0,s.jsx)(g.Check,{className:"h-3.5 w-3.5 text-green-500"}):(0,s.jsx)(tt.Copy,{className:"h-3.5 w-3.5"}),m?"Copied":"Copy"]}),o&&(0,s.jsxs)(v.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>{if(!o)return;let e=new Blob([o],{type:"image/svg+xml"}),t=URL.createObjectURL(e),r=document.createElement("a");r.href=t,r.download=`${n}.svg`,r.click(),URL.revokeObjectURL(t)},children:[(0,s.jsx)(t7.Download,{className:"h-3.5 w-3.5"}),"SVG"]})]}),(0,s.jsx)("div",{className:"flex-1 overflow-auto",children:d?(0,s.jsx)("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:"Rendering diagram..."}):p?(0,s.jsx)("pre",{className:"p-4 text-[13px] leading-relaxed font-mono bg-[#1e1e1e]",children:(0,s.jsx)("code",{children:r.split("\n").map((e,t)=>(0,s.jsxs)("div",{className:"flex",children:[(0,s.jsx)("span",{className:"inline-block w-12 pr-4 text-right text-[#858585] select-none shrink-0",children:t+1}),(0,s.jsx)("span",{className:"text-[#d4d4d4] flex-1",children:e||"\n"})]},t))})}):l?(0,s.jsxs)("div",{className:"flex flex-col items-center justify-center h-full gap-4 text-sm p-8",children:[(0,s.jsxs)("div",{className:"flex flex-col items-center gap-2",children:[(0,s.jsx)("div",{className:"h-10 w-10 rounded-full bg-red-500/10 flex items-center justify-center",children:(0,s.jsx)(r6,{className:"h-5 w-5 text-red-500"})}),(0,s.jsx)("p",{className:"text-red-500 font-medium",children:"Diagram syntax error"})]}),(0,s.jsx)("pre",{className:"text-muted-foreground text-xs max-w-lg text-left bg-muted rounded-md p-3 overflow-auto whitespace-pre-wrap",children:l}),(0,s.jsx)(v.Button,{variant:"outline",size:"sm",onClick:()=>h(!0),children:"View source to fix"})]}):(0,s.jsx)(yc,{svg:o,className:"w-full h-full"})})]})}var v1=e.i(790070),v2="[0-9](_*[0-9])*",v3=`\\.(${v2})`,v5="[0-9a-fA-F](_*[0-9a-fA-F])*",v4={className:"number",variants:[{begin:`(\\b(${v2})((${v3})|\\.)?|(${v3}))[eE][+-]?(${v2})[fFdD]?\\b`},{begin:`\\b(${v2})((${v3})[fFdD]?\\b|\\.([fFdD]\\b)?)`},{begin:`(${v3})[fFdD]?\\b`},{begin:`\\b(${v2})[fFdD]\\b`},{begin:`\\b0[xX]((${v5})\\.?|(${v5})?\\.(${v5}))[pP][+-]?(${v2})[fFdD]?\\b`},{begin:"\\b(0|[1-9](_*[0-9])*)[lL]?\\b"},{begin:`\\b0[xX](${v5})[lL]?\\b`},{begin:"\\b0(_*[0-7])*[lL]?\\b"},{begin:"\\b0[bB][01](_*[01])*[lL]?\\b"}],relevance:0},v6="[0-9](_*[0-9])*",v9=`\\.(${v6})`,v7="[0-9a-fA-F](_*[0-9a-fA-F])*",v8={className:"number",variants:[{begin:`(\\b(${v6})((${v9})|\\.)?|(${v9}))[eE][+-]?(${v6})[fFdD]?\\b`},{begin:`\\b(${v6})((${v9})[fFdD]?\\b|\\.([fFdD]\\b)?)`},{begin:`(${v9})[fFdD]?\\b`},{begin:`\\b(${v6})[fFdD]\\b`},{begin:`\\b0[xX]((${v7})\\.?|(${v7})?\\.(${v7}))[pP][+-]?(${v6})[fFdD]?\\b`},{begin:"\\b(0|[1-9](_*[0-9])*)[lL]?\\b"},{begin:`\\b0[xX](${v7})[lL]?\\b`},{begin:"\\b0(_*[0-7])*[lL]?\\b"},{begin:"\\b0[bB][01](_*[01])*[lL]?\\b"}],relevance:0};let we=["a","abbr","address","article","aside","audio","b","blockquote","body","button","canvas","caption","cite","code","dd","del","details","dfn","div","dl","dt","em","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","html","i","iframe","img","input","ins","kbd","label","legend","li","main","mark","menu","nav","object","ol","optgroup","option","p","picture","q","quote","samp","section","select","source","span","strong","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","ul","var","video","defs","g","marker","mask","pattern","svg","switch","symbol","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feFlood","feGaussianBlur","feImage","feMerge","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","linearGradient","radialGradient","stop","circle","ellipse","image","line","path","polygon","polyline","rect","text","use","textPath","tspan","foreignObject","clipPath"],wt=["any-hover","any-pointer","aspect-ratio","color","color-gamut","color-index","device-aspect-ratio","device-height","device-width","display-mode","forced-colors","grid","height","hover","inverted-colors","monochrome","orientation","overflow-block","overflow-inline","pointer","prefers-color-scheme","prefers-contrast","prefers-reduced-motion","prefers-reduced-transparency","resolution","scan","scripting","update","width","min-width","max-width","min-height","max-height"].sort().reverse(),wn=["active","any-link","blank","checked","current","default","defined","dir","disabled","drop","empty","enabled","first","first-child","first-of-type","fullscreen","future","focus","focus-visible","focus-within","has","host","host-context","hover","indeterminate","in-range","invalid","is","lang","last-child","last-of-type","left","link","local-link","not","nth-child","nth-col","nth-last-child","nth-last-col","nth-last-of-type","nth-of-type","only-child","only-of-type","optional","out-of-range","past","placeholder-shown","read-only","read-write","required","right","root","scope","target","target-within","user-invalid","valid","visited","where"].sort().reverse(),wr=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),wi=["accent-color","align-content","align-items","align-self","alignment-baseline","all","anchor-name","animation","animation-composition","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-range","animation-range-end","animation-range-start","animation-timeline","animation-timing-function","appearance","aspect-ratio","backdrop-filter","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-position-x","background-position-y","background-repeat","background-size","baseline-shift","block-size","border","border-block","border-block-color","border-block-end","border-block-end-color","border-block-end-style","border-block-end-width","border-block-start","border-block-start-color","border-block-start-style","border-block-start-width","border-block-style","border-block-width","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-end-end-radius","border-end-start-radius","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-inline","border-inline-color","border-inline-end","border-inline-end-color","border-inline-end-style","border-inline-end-width","border-inline-start","border-inline-start-color","border-inline-start-style","border-inline-start-width","border-inline-style","border-inline-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-start-end-radius","border-start-start-radius","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-align","box-decoration-break","box-direction","box-flex","box-flex-group","box-lines","box-ordinal-group","box-orient","box-pack","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","caret-color","clear","clip","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","color-scheme","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","contain","contain-intrinsic-block-size","contain-intrinsic-height","contain-intrinsic-inline-size","contain-intrinsic-size","contain-intrinsic-width","container","container-name","container-type","content","content-visibility","counter-increment","counter-reset","counter-set","cue","cue-after","cue-before","cursor","cx","cy","direction","display","dominant-baseline","empty-cells","enable-background","field-sizing","fill","fill-opacity","fill-rule","filter","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","flood-color","flood-opacity","flow","font","font-display","font-family","font-feature-settings","font-kerning","font-language-override","font-optical-sizing","font-palette","font-size","font-size-adjust","font-smooth","font-smoothing","font-stretch","font-style","font-synthesis","font-synthesis-position","font-synthesis-small-caps","font-synthesis-style","font-synthesis-weight","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-emoji","font-variant-ligatures","font-variant-numeric","font-variant-position","font-variation-settings","font-weight","forced-color-adjust","gap","glyph-orientation-horizontal","glyph-orientation-vertical","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-rows","grid-column","grid-column-end","grid-column-start","grid-gap","grid-row","grid-row-end","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphenate-character","hyphenate-limit-chars","hyphens","icon","image-orientation","image-rendering","image-resolution","ime-mode","initial-letter","initial-letter-align","inline-size","inset","inset-area","inset-block","inset-block-end","inset-block-start","inset-inline","inset-inline-end","inset-inline-start","isolation","justify-content","justify-items","justify-self","kerning","left","letter-spacing","lighting-color","line-break","line-height","line-height-step","list-style","list-style-image","list-style-position","list-style-type","margin","margin-block","margin-block-end","margin-block-start","margin-bottom","margin-inline","margin-inline-end","margin-inline-start","margin-left","margin-right","margin-top","margin-trim","marker","marker-end","marker-mid","marker-start","marks","mask","mask-border","mask-border-mode","mask-border-outset","mask-border-repeat","mask-border-slice","mask-border-source","mask-border-width","mask-clip","mask-composite","mask-image","mask-mode","mask-origin","mask-position","mask-repeat","mask-size","mask-type","masonry-auto-flow","math-depth","math-shift","math-style","max-block-size","max-height","max-inline-size","max-width","min-block-size","min-height","min-inline-size","min-width","mix-blend-mode","nav-down","nav-index","nav-left","nav-right","nav-up","none","normal","object-fit","object-position","offset","offset-anchor","offset-distance","offset-path","offset-position","offset-rotate","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-anchor","overflow-block","overflow-clip-margin","overflow-inline","overflow-wrap","overflow-x","overflow-y","overlay","overscroll-behavior","overscroll-behavior-block","overscroll-behavior-inline","overscroll-behavior-x","overscroll-behavior-y","padding","padding-block","padding-block-end","padding-block-start","padding-bottom","padding-inline","padding-inline-end","padding-inline-start","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","paint-order","pause","pause-after","pause-before","perspective","perspective-origin","place-content","place-items","place-self","pointer-events","position","position-anchor","position-visibility","print-color-adjust","quotes","r","resize","rest","rest-after","rest-before","right","rotate","row-gap","ruby-align","ruby-position","scale","scroll-behavior","scroll-margin","scroll-margin-block","scroll-margin-block-end","scroll-margin-block-start","scroll-margin-bottom","scroll-margin-inline","scroll-margin-inline-end","scroll-margin-inline-start","scroll-margin-left","scroll-margin-right","scroll-margin-top","scroll-padding","scroll-padding-block","scroll-padding-block-end","scroll-padding-block-start","scroll-padding-bottom","scroll-padding-inline","scroll-padding-inline-end","scroll-padding-inline-start","scroll-padding-left","scroll-padding-right","scroll-padding-top","scroll-snap-align","scroll-snap-stop","scroll-snap-type","scroll-timeline","scroll-timeline-axis","scroll-timeline-name","scrollbar-color","scrollbar-gutter","scrollbar-width","shape-image-threshold","shape-margin","shape-outside","shape-rendering","speak","speak-as","src","stop-color","stop-opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","tab-size","table-layout","text-align","text-align-all","text-align-last","text-anchor","text-combine-upright","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-skip-ink","text-decoration-style","text-decoration-thickness","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-indent","text-justify","text-orientation","text-overflow","text-rendering","text-shadow","text-size-adjust","text-transform","text-underline-offset","text-underline-position","text-wrap","text-wrap-mode","text-wrap-style","timeline-scope","top","touch-action","transform","transform-box","transform-origin","transform-style","transition","transition-behavior","transition-delay","transition-duration","transition-property","transition-timing-function","translate","unicode-bidi","user-modify","user-select","vector-effect","vertical-align","view-timeline","view-timeline-axis","view-timeline-inset","view-timeline-name","view-transition-name","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","white-space","white-space-collapse","widows","width","will-change","word-break","word-spacing","word-wrap","writing-mode","x","y","z-index","zoom"].sort().reverse(),ws=wn.concat(wr).sort().reverse(),wo=["a","abbr","address","article","aside","audio","b","blockquote","body","button","canvas","caption","cite","code","dd","del","details","dfn","div","dl","dt","em","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","html","i","iframe","img","input","ins","kbd","label","legend","li","main","mark","menu","nav","object","ol","optgroup","option","p","picture","q","quote","samp","section","select","source","span","strong","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","ul","var","video","defs","g","marker","mask","pattern","svg","switch","symbol","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feFlood","feGaussianBlur","feImage","feMerge","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","linearGradient","radialGradient","stop","circle","ellipse","image","line","path","polygon","polyline","rect","text","use","textPath","tspan","foreignObject","clipPath"],wa=["any-hover","any-pointer","aspect-ratio","color","color-gamut","color-index","device-aspect-ratio","device-height","device-width","display-mode","forced-colors","grid","height","hover","inverted-colors","monochrome","orientation","overflow-block","overflow-inline","pointer","prefers-color-scheme","prefers-contrast","prefers-reduced-motion","prefers-reduced-transparency","resolution","scan","scripting","update","width","min-width","max-width","min-height","max-height"].sort().reverse(),wl=["active","any-link","blank","checked","current","default","defined","dir","disabled","drop","empty","enabled","first","first-child","first-of-type","fullscreen","future","focus","focus-visible","focus-within","has","host","host-context","hover","indeterminate","in-range","invalid","is","lang","last-child","last-of-type","left","link","local-link","not","nth-child","nth-col","nth-last-child","nth-last-col","nth-last-of-type","nth-of-type","only-child","only-of-type","optional","out-of-range","past","placeholder-shown","read-only","read-write","required","right","root","scope","target","target-within","user-invalid","valid","visited","where"].sort().reverse(),wc=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),wd=["accent-color","align-content","align-items","align-self","alignment-baseline","all","anchor-name","animation","animation-composition","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-range","animation-range-end","animation-range-start","animation-timeline","animation-timing-function","appearance","aspect-ratio","backdrop-filter","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-position-x","background-position-y","background-repeat","background-size","baseline-shift","block-size","border","border-block","border-block-color","border-block-end","border-block-end-color","border-block-end-style","border-block-end-width","border-block-start","border-block-start-color","border-block-start-style","border-block-start-width","border-block-style","border-block-width","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-end-end-radius","border-end-start-radius","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-inline","border-inline-color","border-inline-end","border-inline-end-color","border-inline-end-style","border-inline-end-width","border-inline-start","border-inline-start-color","border-inline-start-style","border-inline-start-width","border-inline-style","border-inline-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-start-end-radius","border-start-start-radius","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-align","box-decoration-break","box-direction","box-flex","box-flex-group","box-lines","box-ordinal-group","box-orient","box-pack","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","caret-color","clear","clip","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","color-scheme","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","contain","contain-intrinsic-block-size","contain-intrinsic-height","contain-intrinsic-inline-size","contain-intrinsic-size","contain-intrinsic-width","container","container-name","container-type","content","content-visibility","counter-increment","counter-reset","counter-set","cue","cue-after","cue-before","cursor","cx","cy","direction","display","dominant-baseline","empty-cells","enable-background","field-sizing","fill","fill-opacity","fill-rule","filter","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","flood-color","flood-opacity","flow","font","font-display","font-family","font-feature-settings","font-kerning","font-language-override","font-optical-sizing","font-palette","font-size","font-size-adjust","font-smooth","font-smoothing","font-stretch","font-style","font-synthesis","font-synthesis-position","font-synthesis-small-caps","font-synthesis-style","font-synthesis-weight","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-emoji","font-variant-ligatures","font-variant-numeric","font-variant-position","font-variation-settings","font-weight","forced-color-adjust","gap","glyph-orientation-horizontal","glyph-orientation-vertical","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-rows","grid-column","grid-column-end","grid-column-start","grid-gap","grid-row","grid-row-end","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphenate-character","hyphenate-limit-chars","hyphens","icon","image-orientation","image-rendering","image-resolution","ime-mode","initial-letter","initial-letter-align","inline-size","inset","inset-area","inset-block","inset-block-end","inset-block-start","inset-inline","inset-inline-end","inset-inline-start","isolation","justify-content","justify-items","justify-self","kerning","left","letter-spacing","lighting-color","line-break","line-height","line-height-step","list-style","list-style-image","list-style-position","list-style-type","margin","margin-block","margin-block-end","margin-block-start","margin-bottom","margin-inline","margin-inline-end","margin-inline-start","margin-left","margin-right","margin-top","margin-trim","marker","marker-end","marker-mid","marker-start","marks","mask","mask-border","mask-border-mode","mask-border-outset","mask-border-repeat","mask-border-slice","mask-border-source","mask-border-width","mask-clip","mask-composite","mask-image","mask-mode","mask-origin","mask-position","mask-repeat","mask-size","mask-type","masonry-auto-flow","math-depth","math-shift","math-style","max-block-size","max-height","max-inline-size","max-width","min-block-size","min-height","min-inline-size","min-width","mix-blend-mode","nav-down","nav-index","nav-left","nav-right","nav-up","none","normal","object-fit","object-position","offset","offset-anchor","offset-distance","offset-path","offset-position","offset-rotate","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-anchor","overflow-block","overflow-clip-margin","overflow-inline","overflow-wrap","overflow-x","overflow-y","overlay","overscroll-behavior","overscroll-behavior-block","overscroll-behavior-inline","overscroll-behavior-x","overscroll-behavior-y","padding","padding-block","padding-block-end","padding-block-start","padding-bottom","padding-inline","padding-inline-end","padding-inline-start","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","paint-order","pause","pause-after","pause-before","perspective","perspective-origin","place-content","place-items","place-self","pointer-events","position","position-anchor","position-visibility","print-color-adjust","quotes","r","resize","rest","rest-after","rest-before","right","rotate","row-gap","ruby-align","ruby-position","scale","scroll-behavior","scroll-margin","scroll-margin-block","scroll-margin-block-end","scroll-margin-block-start","scroll-margin-bottom","scroll-margin-inline","scroll-margin-inline-end","scroll-margin-inline-start","scroll-margin-left","scroll-margin-right","scroll-margin-top","scroll-padding","scroll-padding-block","scroll-padding-block-end","scroll-padding-block-start","scroll-padding-bottom","scroll-padding-inline","scroll-padding-inline-end","scroll-padding-inline-start","scroll-padding-left","scroll-padding-right","scroll-padding-top","scroll-snap-align","scroll-snap-stop","scroll-snap-type","scroll-timeline","scroll-timeline-axis","scroll-timeline-name","scrollbar-color","scrollbar-gutter","scrollbar-width","shape-image-threshold","shape-margin","shape-outside","shape-rendering","speak","speak-as","src","stop-color","stop-opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","tab-size","table-layout","text-align","text-align-all","text-align-last","text-anchor","text-combine-upright","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-skip-ink","text-decoration-style","text-decoration-thickness","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-indent","text-justify","text-orientation","text-overflow","text-rendering","text-shadow","text-size-adjust","text-transform","text-underline-offset","text-underline-position","text-wrap","text-wrap-mode","text-wrap-style","timeline-scope","top","touch-action","transform","transform-box","transform-origin","transform-style","transition","transition-behavior","transition-delay","transition-duration","transition-property","transition-timing-function","translate","unicode-bidi","user-modify","user-select","vector-effect","vertical-align","view-timeline","view-timeline-axis","view-timeline-inset","view-timeline-name","view-transition-name","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","white-space","white-space-collapse","widows","width","will-change","word-break","word-spacing","word-wrap","writing-mode","x","y","z-index","zoom"].sort().reverse();function wu(e){return e?"string"==typeof e?e:e.source:null}function wp(e){return wh("(?=",e,")")}function wh(...e){return e.map(e=>wu(e)).join("")}function wf(...e){let t;return"("+(("object"==typeof(t=e[e.length-1])&&t.constructor===Object?(e.splice(e.length-1,1),t):{}).capture?"":"?:")+e.map(e=>wu(e)).join("|")+")"}let wm=e=>wh(/\b/,e,/\w$/.test(e)?/\b/:/\B/),wg=["Protocol","Type"].map(wm),wb=["init","self"].map(wm),wx=["Any","Self"],wy=["actor","any","associatedtype","async","await",/as\?/,/as!/,"as","borrowing","break","case","catch","class","consume","consuming","continue","convenience","copy","default","defer","deinit","didSet","distributed","do","dynamic","each","else","enum","extension","fallthrough",/fileprivate\(set\)/,"fileprivate","final","for","func","get","guard","if","import","indirect","infix",/init\?/,/init!/,"inout",/internal\(set\)/,"internal","in","is","isolated","nonisolated","lazy","let","macro","mutating","nonmutating",/open\(set\)/,"open","operator","optional","override","package","postfix","precedencegroup","prefix",/private\(set\)/,"private","protocol",/public\(set\)/,"public","repeat","required","rethrows","return","set","some","static","struct","subscript","super","switch","throws","throw",/try\?/,/try!/,"try","typealias",/unowned\(safe\)/,/unowned\(unsafe\)/,"unowned","var","weak","where","while","willSet"],wv=["false","nil","true"],ww=["assignment","associativity","higherThan","left","lowerThan","none","right"],wk=["#colorLiteral","#column","#dsohandle","#else","#elseif","#endif","#error","#file","#fileID","#fileLiteral","#filePath","#function","#if","#imageLiteral","#keyPath","#line","#selector","#sourceLocation","#warning"],wN=["abs","all","any","assert","assertionFailure","debugPrint","dump","fatalError","getVaList","isKnownUniquelyReferenced","max","min","numericCast","pointwiseMax","pointwiseMin","precondition","preconditionFailure","print","readLine","repeatElement","sequence","stride","swap","swift_unboxFromSwiftValueWithType","transcode","type","unsafeBitCast","unsafeDowncast","withExtendedLifetime","withUnsafeMutablePointer","withUnsafePointer","withVaList","withoutActuallyEscaping","zip"],wS=wf(/[/=\-+!*%<>&|^~?]/,/[\u00A1-\u00A7]/,/[\u00A9\u00AB]/,/[\u00AC\u00AE]/,/[\u00B0\u00B1]/,/[\u00B6\u00BB\u00BF\u00D7\u00F7]/,/[\u2016-\u2017]/,/[\u2020-\u2027]/,/[\u2030-\u203E]/,/[\u2041-\u2053]/,/[\u2055-\u205E]/,/[\u2190-\u23FF]/,/[\u2500-\u2775]/,/[\u2794-\u2BFF]/,/[\u2E00-\u2E7F]/,/[\u3001-\u3003]/,/[\u3008-\u3020]/,/[\u3030]/),wC=wf(wS,/[\u0300-\u036F]/,/[\u1DC0-\u1DFF]/,/[\u20D0-\u20FF]/,/[\uFE00-\uFE0F]/,/[\uFE20-\uFE2F]/),wj=wh(wS,wC,"*"),wE=wf(/[a-zA-Z_]/,/[\u00A8\u00AA\u00AD\u00AF\u00B2-\u00B5\u00B7-\u00BA]/,/[\u00BC-\u00BE\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF]/,/[\u0100-\u02FF\u0370-\u167F\u1681-\u180D\u180F-\u1DBF]/,/[\u1E00-\u1FFF]/,/[\u200B-\u200D\u202A-\u202E\u203F-\u2040\u2054\u2060-\u206F]/,/[\u2070-\u20CF\u2100-\u218F\u2460-\u24FF\u2776-\u2793]/,/[\u2C00-\u2DFF\u2E80-\u2FFF]/,/[\u3004-\u3007\u3021-\u302F\u3031-\u303F\u3040-\uD7FF]/,/[\uF900-\uFD3D\uFD40-\uFDCF\uFDF0-\uFE1F\uFE30-\uFE44]/,/[\uFE47-\uFEFE\uFF00-\uFFFD]/),wM=wf(wE,/\d/,/[\u0300-\u036F\u1DC0-\u1DFF\u20D0-\u20FF\uFE20-\uFE2F]/),wA=wh(wE,wM,"*"),wT=wh(/[A-Z]/,wM,"*"),wO=["attached","autoclosure",wh(/convention\(/,wf("swift","block","c"),/\)/),"discardableResult","dynamicCallable","dynamicMemberLookup","escaping","freestanding","frozen","GKInspectable","IBAction","IBDesignable","IBInspectable","IBOutlet","IBSegueAction","inlinable","main","nonobjc","NSApplicationMain","NSCopying","NSManaged",wh(/objc\(/,wA,/\)/),"objc","objcMembers","propertyWrapper","requires_stored_property_inits","resultBuilder","Sendable","testable","UIApplicationMain","unchecked","unknown","usableFromInline","warn_unqualified_access"],w_=["iOS","iOSApplicationExtension","macOS","macOSApplicationExtension","macCatalyst","macCatalystApplicationExtension","watchOS","watchOSApplicationExtension","tvOS","tvOSApplicationExtension","swift"],wD={arduino:function(e){let t,n,r,i,s,o,a,l,c,d,u,p,h,f,m,g,b=(t=e.regex,n=e.COMMENT("//","$",{contains:[{begin:/\\\n/}]}),i="[a-zA-Z_]\\w*::",s="(?!struct)("+(r="decltype\\(auto\\)")+"|"+t.optional(i)+"[a-zA-Z_]\\w*"+t.optional("<[^<>]+>")+")",o={className:"type",begin:"\\b[a-z\\d_]*_t\\b"},a={className:"string",variants:[{begin:'(u8?|U|L)?"',end:'"',illegal:"\\n",contains:[e.BACKSLASH_ESCAPE]},{begin:"(u8?|U|L)?'(\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4,8}|[0-7]{3}|\\S)|.)",end:"'",illegal:"."},e.END_SAME_AS_BEGIN({begin:/(?:u8?|U|L)?R"([^()\\ ]{0,16})\(/,end:/\)([^()\\ ]{0,16})"/})]},l={className:"number",variants:[{begin:"[+-]?(?:(?:[0-9](?:'?[0-9])*\\.(?:[0-9](?:'?[0-9])*)?|\\.[0-9](?:'?[0-9])*)(?:[Ee][+-]?[0-9](?:'?[0-9])*)?|[0-9](?:'?[0-9])*[Ee][+-]?[0-9](?:'?[0-9])*|0[Xx](?:[0-9A-Fa-f](?:'?[0-9A-Fa-f])*(?:\\.(?:[0-9A-Fa-f](?:'?[0-9A-Fa-f])*)?)?|\\.[0-9A-Fa-f](?:'?[0-9A-Fa-f])*)[Pp][+-]?[0-9](?:'?[0-9])*)(?:[Ff](?:16|32|64|128)?|(BF|bf)16|[Ll]|)"},{begin:"[+-]?\\b(?:0[Bb][01](?:'?[01])*|0[Xx][0-9A-Fa-f](?:'?[0-9A-Fa-f])*|0(?:'?[0-7])*|[1-9](?:'?[0-9])*)(?:[Uu](?:LL?|ll?)|[Uu][Zz]?|(?:LL?|ll?)[Uu]?|[Zz][Uu]|)"}],relevance:0},c={className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:"if else elif endif define undef warning error line pragma _Pragma ifdef ifndef include"},contains:[{begin:/\\\n/,relevance:0},e.inherit(a,{className:"string"}),{className:"string",begin:/<.*?>/},n,e.C_BLOCK_COMMENT_MODE]},d={className:"title",begin:t.optional(i)+e.IDENT_RE,relevance:0},u=t.optional(i)+e.IDENT_RE+"\\s*\\(",m={variants:[{begin:/=/,end:/;/},{begin:/\(/,end:/\)/},{beginKeywords:"new throw return else",end:/;/}],keywords:p={type:["bool","char","char16_t","char32_t","char8_t","double","float","int","long","short","void","wchar_t","unsigned","signed","const","static"],keyword:["alignas","alignof","and","and_eq","asm","atomic_cancel","atomic_commit","atomic_noexcept","auto","bitand","bitor","break","case","catch","class","co_await","co_return","co_yield","compl","concept","const_cast|10","consteval","constexpr","constinit","continue","decltype","default","delete","do","dynamic_cast|10","else","enum","explicit","export","extern","false","final","for","friend","goto","if","import","inline","module","mutable","namespace","new","noexcept","not","not_eq","nullptr","operator","or","or_eq","override","private","protected","public","reflexpr","register","reinterpret_cast|10","requires","return","sizeof","static_assert","static_cast|10","struct","switch","synchronized","template","this","thread_local","throw","transaction_safe","transaction_safe_dynamic","true","try","typedef","typeid","typename","union","using","virtual","volatile","while","xor","xor_eq"],literal:["NULL","false","nullopt","nullptr","true"],built_in:["_Pragma"],_type_hints:["any","auto_ptr","barrier","binary_semaphore","bitset","complex","condition_variable","condition_variable_any","counting_semaphore","deque","false_type","flat_map","flat_set","future","imaginary","initializer_list","istringstream","jthread","latch","lock_guard","multimap","multiset","mutex","optional","ostringstream","packaged_task","pair","promise","priority_queue","queue","recursive_mutex","recursive_timed_mutex","scoped_lock","set","shared_future","shared_lock","shared_mutex","shared_timed_mutex","shared_ptr","stack","string_view","stringstream","timed_mutex","thread","true_type","tuple","unique_lock","unique_ptr","unordered_map","unordered_multimap","unordered_multiset","unordered_set","variant","vector","weak_ptr","wstring","wstring_view"]},contains:(f=[h={className:"function.dispatch",relevance:0,keywords:{_hint:["abort","abs","acos","apply","as_const","asin","atan","atan2","calloc","ceil","cerr","cin","clog","cos","cosh","cout","declval","endl","exchange","exit","exp","fabs","floor","fmod","forward","fprintf","fputs","free","frexp","fscanf","future","invoke","isalnum","isalpha","iscntrl","isdigit","isgraph","islower","isprint","ispunct","isspace","isupper","isxdigit","labs","launder","ldexp","log","log10","make_pair","make_shared","make_shared_for_overwrite","make_tuple","make_unique","malloc","memchr","memcmp","memcpy","memset","modf","move","pow","printf","putchar","puts","realloc","scanf","sin","sinh","snprintf","sprintf","sqrt","sscanf","std","stderr","stdin","stdout","strcat","strchr","strcmp","strcpy","strcspn","strlen","strncat","strncmp","strncpy","strpbrk","strrchr","strspn","strstr","swap","tan","tanh","terminate","to_underlying","tolower","toupper","vfprintf","visit","vprintf","vsprintf"]},begin:t.concat(/\b/,/(?!decltype)/,/(?!if)/,/(?!for)/,/(?!switch)/,/(?!while)/,e.IDENT_RE,t.lookahead(/(<[^<>]+>|)\s*\(/))},c,o,n,e.C_BLOCK_COMMENT_MODE,l,a]).concat([{begin:/\(/,end:/\)/,keywords:p,contains:f.concat(["self"]),relevance:0}]),relevance:0},g={className:"function",begin:"("+s+"[\\*&\\s]+)+"+u,returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:p,illegal:/[^\w\s\*&:<>.]/,contains:[{begin:r,keywords:p,relevance:0},{begin:u,returnBegin:!0,contains:[d],relevance:0},{begin:/::/,relevance:0},{begin:/:/,endsWithParent:!0,contains:[a,l]},{relevance:0,match:/,/},{className:"params",begin:/\(/,end:/\)/,keywords:p,relevance:0,contains:[n,e.C_BLOCK_COMMENT_MODE,a,l,o,{begin:/\(/,end:/\)/,keywords:p,relevance:0,contains:["self",n,e.C_BLOCK_COMMENT_MODE,a,l,o]}]},o,n,e.C_BLOCK_COMMENT_MODE,c]},{name:"C++",aliases:["cc","c++","h++","hpp","hh","hxx","cxx"],keywords:p,illegal:"</",classNameAliases:{"function.dispatch":"built_in"},contains:[].concat(m,g,h,f,[c,{begin:"\\b(deque|list|queue|priority_queue|pair|stack|vector|map|set|bitset|multiset|multimap|unordered_map|unordered_set|unordered_multiset|unordered_multimap|array|tuple|optional|variant|function|flat_map|flat_set)\\s*<(?!<)",end:">",keywords:p,contains:["self",o]},{begin:e.IDENT_RE+"::",keywords:p},{match:[/\b(?:enum(?:\s+(?:class|struct))?|class|struct|union)/,/\s+/,/\w+/],className:{1:"keyword",3:"title.class"}}])}),x=b.keywords;return x.type=[...x.type,"boolean","byte","word","String"],x.literal=[...x.literal,"DIGITAL_MESSAGE","FIRMATA_STRING","ANALOG_MESSAGE","REPORT_DIGITAL","REPORT_ANALOG","INPUT_PULLUP","SET_PIN_MODE","INTERNAL2V56","SYSTEM_RESET","LED_BUILTIN","INTERNAL1V1","SYSEX_START","INTERNAL","EXTERNAL","DEFAULT","OUTPUT","INPUT","HIGH","LOW"],x.built_in=[...x.built_in,"KeyboardController","MouseController","SoftwareSerial","EthernetServer","EthernetClient","LiquidCrystal","RobotControl","GSMVoiceCall","EthernetUDP","EsploraTFT","HttpClient","RobotMotor","WiFiClient","GSMScanner","FileSystem","Scheduler","GSMServer","YunClient","YunServer","IPAddress","GSMClient","GSMModem","Keyboard","Ethernet","Console","GSMBand","Esplora","Stepper","Process","WiFiUDP","GSM_SMS","Mailbox","USBHost","Firmata","PImage","Client","Server","GSMPIN","FileIO","Bridge","Serial","EEPROM","Stream","Mouse","Audio","Servo","File","Task","GPRS","WiFi","Wire","TFT","GSM","SPI","SD"],x._hints=["setup","loop","runShellCommandAsynchronously","analogWriteResolution","retrieveCallingNumber","printFirmwareVersion","analogReadResolution","sendDigitalPortPair","noListenOnLocalhost","readJoystickButton","setFirmwareVersion","readJoystickSwitch","scrollDisplayRight","getVoiceCallStatus","scrollDisplayLeft","writeMicroseconds","delayMicroseconds","beginTransmission","getSignalStrength","runAsynchronously","getAsynchronously","listenOnLocalhost","getCurrentCarrier","readAccelerometer","messageAvailable","sendDigitalPorts","lineFollowConfig","countryNameWrite","runShellCommand","readStringUntil","rewindDirectory","readTemperature","setClockDivider","readLightSensor","endTransmission","analogReference","detachInterrupt","countryNameRead","attachInterrupt","encryptionType","readBytesUntil","robotNameWrite","readMicrophone","robotNameRead","cityNameWrite","userNameWrite","readJoystickY","readJoystickX","mouseReleased","openNextFile","scanNetworks","noInterrupts","digitalWrite","beginSpeaker","mousePressed","isActionDone","mouseDragged","displayLogos","noAutoscroll","addParameter","remoteNumber","getModifiers","keyboardRead","userNameRead","waitContinue","processInput","parseCommand","printVersion","readNetworks","writeMessage","blinkVersion","cityNameRead","readMessage","setDataMode","parsePacket","isListening","setBitOrder","beginPacket","isDirectory","motorsWrite","drawCompass","digitalRead","clearScreen","serialEvent","rightToLeft","setTextSize","leftToRight","requestFrom","keyReleased","compassRead","analogWrite","interrupts","WiFiServer","disconnect","playMelody","parseFloat","autoscroll","getPINUsed","setPINUsed","setTimeout","sendAnalog","readSlider","analogRead","beginWrite","createChar","motorsStop","keyPressed","tempoWrite","readButton","subnetMask","debugPrint","macAddress","writeGreen","randomSeed","attachGPRS","readString","sendString","remotePort","releaseAll","mouseMoved","background","getXChange","getYChange","answerCall","getResult","voiceCall","endPacket","constrain","getSocket","writeJSON","getButton","available","connected","findUntil","readBytes","exitValue","readGreen","writeBlue","startLoop","IPAddress","isPressed","sendSysex","pauseMode","gatewayIP","setCursor","getOemKey","tuneWrite","noDisplay","loadImage","switchPIN","onRequest","onReceive","changePIN","playFile","noBuffer","parseInt","overflow","checkPIN","knobRead","beginTFT","bitClear","updateIR","bitWrite","position","writeRGB","highByte","writeRed","setSpeed","readBlue","noStroke","remoteIP","transfer","shutdown","hangCall","beginSMS","endWrite","attached","maintain","noCursor","checkReg","checkPUK","shiftOut","isValid","shiftIn","pulseIn","connect","println","localIP","pinMode","getIMEI","display","noBlink","process","getBand","running","beginSD","drawBMP","lowByte","setBand","release","bitRead","prepare","pointTo","readRed","setMode","noFill","remove","listen","stroke","detach","attach","noTone","exists","buffer","height","bitSet","circle","config","cursor","random","IRread","setDNS","endSMS","getKey","micros","millis","begin","print","write","ready","flush","width","isPIN","blink","clear","press","mkdir","rmdir","close","point","yield","image","BSSID","click","delay","read","text","move","peek","beep","rect","line","open","seek","fill","size","turn","stop","home","find","step","tone","sqrt","RSSI","SSID","end","bit","tan","cos","sin","pow","map","abs","max","min","get","run","put"],b.name="Arduino",b.aliases=["ino"],b.supersetOf="cpp",b},bash:xx,c:function(e){let t=e.regex,n=e.COMMENT("//","$",{contains:[{begin:/\\\n/}]}),r="decltype\\(auto\\)",i="[a-zA-Z_]\\w*::",s="("+r+"|"+t.optional(i)+"[a-zA-Z_]\\w*"+t.optional("<[^<>]+>")+")",o={className:"type",variants:[{begin:"\\b[a-z\\d_]*_t\\b"},{match:/\batomic_[a-z]{3,6}\b/}]},a={className:"string",variants:[{begin:'(u8?|U|L)?"',end:'"',illegal:"\\n",contains:[e.BACKSLASH_ESCAPE]},{begin:"(u8?|U|L)?'(\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4,8}|[0-7]{3}|\\S)|.)",end:"'",illegal:"."},e.END_SAME_AS_BEGIN({begin:/(?:u8?|U|L)?R"([^()\\ ]{0,16})\(/,end:/\)([^()\\ ]{0,16})"/})]},l={className:"number",variants:[{match:/\b(0b[01']+)/},{match:/(-?)\b([\d']+(\.[\d']*)?|\.[\d']+)((ll|LL|l|L)(u|U)?|(u|U)(ll|LL|l|L)?|f|F|b|B)/},{match:/(-?)\b(0[xX][a-fA-F0-9]+(?:'[a-fA-F0-9]+)*(?:\.[a-fA-F0-9]*(?:'[a-fA-F0-9]*)*)?(?:[pP][-+]?[0-9]+)?(l|L)?(u|U)?)/},{match:/(-?)\b\d+(?:'\d+)*(?:\.\d*(?:'\d*)*)?(?:[eE][-+]?\d+)?/}],relevance:0},c={className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:"if else elif endif define undef warning error line pragma _Pragma ifdef ifndef elifdef elifndef include"},contains:[{begin:/\\\n/,relevance:0},e.inherit(a,{className:"string"}),{className:"string",begin:/<.*?>/},n,e.C_BLOCK_COMMENT_MODE]},d={className:"title",begin:t.optional(i)+e.IDENT_RE,relevance:0},u=t.optional(i)+e.IDENT_RE+"\\s*\\(",p={keyword:["asm","auto","break","case","continue","default","do","else","enum","extern","for","fortran","goto","if","inline","register","restrict","return","sizeof","typeof","typeof_unqual","struct","switch","typedef","union","volatile","while","_Alignas","_Alignof","_Atomic","_Generic","_Noreturn","_Static_assert","_Thread_local","alignas","alignof","noreturn","static_assert","thread_local","_Pragma"],type:["float","double","signed","unsigned","int","short","long","char","void","_Bool","_BitInt","_Complex","_Imaginary","_Decimal32","_Decimal64","_Decimal96","_Decimal128","_Decimal64x","_Decimal128x","_Float16","_Float32","_Float64","_Float128","_Float32x","_Float64x","_Float128x","const","static","constexpr","complex","bool","imaginary"],literal:"true false NULL",built_in:"std string wstring cin cout cerr clog stdin stdout stderr stringstream istringstream ostringstream auto_ptr deque list queue stack vector map set pair bitset multiset multimap unordered_set unordered_map unordered_multiset unordered_multimap priority_queue make_pair array shared_ptr abort terminate abs acos asin atan2 atan calloc ceil cosh cos exit exp fabs floor fmod fprintf fputs free frexp fscanf future isalnum isalpha iscntrl isdigit isgraph islower isprint ispunct isspace isupper isxdigit tolower toupper labs ldexp log10 log malloc realloc memchr memcmp memcpy memset modf pow printf putchar puts scanf sinh sin snprintf sprintf sqrt sscanf strcat strchr strcmp strcpy strcspn strlen strncat strncmp strncpy strpbrk strrchr strspn strstr tanh tan vfprintf vprintf vsprintf endl initializer_list unique_ptr"},h=[c,o,n,e.C_BLOCK_COMMENT_MODE,l,a],f={variants:[{begin:/=/,end:/;/},{begin:/\(/,end:/\)/},{beginKeywords:"new throw return else",end:/;/}],keywords:p,contains:h.concat([{begin:/\(/,end:/\)/,keywords:p,contains:h.concat(["self"]),relevance:0}]),relevance:0},m={begin:"("+s+"[\\*&\\s]+)+"+u,returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:p,illegal:/[^\w\s\*&:<>.]/,contains:[{begin:r,keywords:p,relevance:0},{begin:u,returnBegin:!0,contains:[e.inherit(d,{className:"title.function"})],relevance:0},{relevance:0,match:/,/},{className:"params",begin:/\(/,end:/\)/,keywords:p,relevance:0,contains:[n,e.C_BLOCK_COMMENT_MODE,a,l,o,{begin:/\(/,end:/\)/,keywords:p,relevance:0,contains:["self",n,e.C_BLOCK_COMMENT_MODE,a,l,o]}]},o,n,e.C_BLOCK_COMMENT_MODE,c]};return{name:"C",aliases:["h"],keywords:p,disableAutodetect:!0,illegal:"</",contains:[].concat(f,m,h,[c,{begin:e.IDENT_RE+"::",keywords:p},{className:"class",beginKeywords:"enum class struct union",end:/[{;:<>=]/,contains:[{beginKeywords:"final class struct"},e.TITLE_MODE]}]),exports:{preprocessor:c,strings:a,keywords:p}}},cpp:function(e){let t=e.regex,n=e.COMMENT("//","$",{contains:[{begin:/\\\n/}]}),r="decltype\\(auto\\)",i="[a-zA-Z_]\\w*::",s="(?!struct)("+r+"|"+t.optional(i)+"[a-zA-Z_]\\w*"+t.optional("<[^<>]+>")+")",o={className:"type",begin:"\\b[a-z\\d_]*_t\\b"},a={className:"string",variants:[{begin:'(u8?|U|L)?"',end:'"',illegal:"\\n",contains:[e.BACKSLASH_ESCAPE]},{begin:"(u8?|U|L)?'(\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4,8}|[0-7]{3}|\\S)|.)",end:"'",illegal:"."},e.END_SAME_AS_BEGIN({begin:/(?:u8?|U|L)?R"([^()\\ ]{0,16})\(/,end:/\)([^()\\ ]{0,16})"/})]},l={className:"number",variants:[{begin:"[+-]?(?:(?:[0-9](?:'?[0-9])*\\.(?:[0-9](?:'?[0-9])*)?|\\.[0-9](?:'?[0-9])*)(?:[Ee][+-]?[0-9](?:'?[0-9])*)?|[0-9](?:'?[0-9])*[Ee][+-]?[0-9](?:'?[0-9])*|0[Xx](?:[0-9A-Fa-f](?:'?[0-9A-Fa-f])*(?:\\.(?:[0-9A-Fa-f](?:'?[0-9A-Fa-f])*)?)?|\\.[0-9A-Fa-f](?:'?[0-9A-Fa-f])*)[Pp][+-]?[0-9](?:'?[0-9])*)(?:[Ff](?:16|32|64|128)?|(BF|bf)16|[Ll]|)"},{begin:"[+-]?\\b(?:0[Bb][01](?:'?[01])*|0[Xx][0-9A-Fa-f](?:'?[0-9A-Fa-f])*|0(?:'?[0-7])*|[1-9](?:'?[0-9])*)(?:[Uu](?:LL?|ll?)|[Uu][Zz]?|(?:LL?|ll?)[Uu]?|[Zz][Uu]|)"}],relevance:0},c={className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:"if else elif endif define undef warning error line pragma _Pragma ifdef ifndef include"},contains:[{begin:/\\\n/,relevance:0},e.inherit(a,{className:"string"}),{className:"string",begin:/<.*?>/},n,e.C_BLOCK_COMMENT_MODE]},d={className:"title",begin:t.optional(i)+e.IDENT_RE,relevance:0},u=t.optional(i)+e.IDENT_RE+"\\s*\\(",p={type:["bool","char","char16_t","char32_t","char8_t","double","float","int","long","short","void","wchar_t","unsigned","signed","const","static"],keyword:["alignas","alignof","and","and_eq","asm","atomic_cancel","atomic_commit","atomic_noexcept","auto","bitand","bitor","break","case","catch","class","co_await","co_return","co_yield","compl","concept","const_cast|10","consteval","constexpr","constinit","continue","decltype","default","delete","do","dynamic_cast|10","else","enum","explicit","export","extern","false","final","for","friend","goto","if","import","inline","module","mutable","namespace","new","noexcept","not","not_eq","nullptr","operator","or","or_eq","override","private","protected","public","reflexpr","register","reinterpret_cast|10","requires","return","sizeof","static_assert","static_cast|10","struct","switch","synchronized","template","this","thread_local","throw","transaction_safe","transaction_safe_dynamic","true","try","typedef","typeid","typename","union","using","virtual","volatile","while","xor","xor_eq"],literal:["NULL","false","nullopt","nullptr","true"],built_in:["_Pragma"],_type_hints:["any","auto_ptr","barrier","binary_semaphore","bitset","complex","condition_variable","condition_variable_any","counting_semaphore","deque","false_type","flat_map","flat_set","future","imaginary","initializer_list","istringstream","jthread","latch","lock_guard","multimap","multiset","mutex","optional","ostringstream","packaged_task","pair","promise","priority_queue","queue","recursive_mutex","recursive_timed_mutex","scoped_lock","set","shared_future","shared_lock","shared_mutex","shared_timed_mutex","shared_ptr","stack","string_view","stringstream","timed_mutex","thread","true_type","tuple","unique_lock","unique_ptr","unordered_map","unordered_multimap","unordered_multiset","unordered_set","variant","vector","weak_ptr","wstring","wstring_view"]},h={className:"function.dispatch",relevance:0,keywords:{_hint:["abort","abs","acos","apply","as_const","asin","atan","atan2","calloc","ceil","cerr","cin","clog","cos","cosh","cout","declval","endl","exchange","exit","exp","fabs","floor","fmod","forward","fprintf","fputs","free","frexp","fscanf","future","invoke","isalnum","isalpha","iscntrl","isdigit","isgraph","islower","isprint","ispunct","isspace","isupper","isxdigit","labs","launder","ldexp","log","log10","make_pair","make_shared","make_shared_for_overwrite","make_tuple","make_unique","malloc","memchr","memcmp","memcpy","memset","modf","move","pow","printf","putchar","puts","realloc","scanf","sin","sinh","snprintf","sprintf","sqrt","sscanf","std","stderr","stdin","stdout","strcat","strchr","strcmp","strcpy","strcspn","strlen","strncat","strncmp","strncpy","strpbrk","strrchr","strspn","strstr","swap","tan","tanh","terminate","to_underlying","tolower","toupper","vfprintf","visit","vprintf","vsprintf"]},begin:t.concat(/\b/,/(?!decltype)/,/(?!if)/,/(?!for)/,/(?!switch)/,/(?!while)/,e.IDENT_RE,t.lookahead(/(<[^<>]+>|)\s*\(/))},f=[h,c,o,n,e.C_BLOCK_COMMENT_MODE,l,a],m={variants:[{begin:/=/,end:/;/},{begin:/\(/,end:/\)/},{beginKeywords:"new throw return else",end:/;/}],keywords:p,contains:f.concat([{begin:/\(/,end:/\)/,keywords:p,contains:f.concat(["self"]),relevance:0}]),relevance:0},g={className:"function",begin:"("+s+"[\\*&\\s]+)+"+u,returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:p,illegal:/[^\w\s\*&:<>.]/,contains:[{begin:r,keywords:p,relevance:0},{begin:u,returnBegin:!0,contains:[d],relevance:0},{begin:/::/,relevance:0},{begin:/:/,endsWithParent:!0,contains:[a,l]},{relevance:0,match:/,/},{className:"params",begin:/\(/,end:/\)/,keywords:p,relevance:0,contains:[n,e.C_BLOCK_COMMENT_MODE,a,l,o,{begin:/\(/,end:/\)/,keywords:p,relevance:0,contains:["self",n,e.C_BLOCK_COMMENT_MODE,a,l,o]}]},o,n,e.C_BLOCK_COMMENT_MODE,c]};return{name:"C++",aliases:["cc","c++","h++","hpp","hh","hxx","cxx"],keywords:p,illegal:"</",classNameAliases:{"function.dispatch":"built_in"},contains:[].concat(m,g,h,f,[c,{begin:"\\b(deque|list|queue|priority_queue|pair|stack|vector|map|set|bitset|multiset|multimap|unordered_map|unordered_set|unordered_multiset|unordered_multimap|array|tuple|optional|variant|function|flat_map|flat_set)\\s*<(?!<)",end:">",keywords:p,contains:["self",o]},{begin:e.IDENT_RE+"::",keywords:p},{match:[/\b(?:enum(?:\s+(?:class|struct))?|class|struct|union)/,/\s+/,/\w+/],className:{1:"keyword",3:"title.class"}}])}},csharp:function(e){let t={keyword:["abstract","as","base","break","case","catch","class","const","continue","do","else","event","explicit","extern","finally","fixed","for","foreach","goto","if","implicit","in","interface","internal","is","lock","namespace","new","operator","out","override","params","private","protected","public","readonly","record","ref","return","scoped","sealed","sizeof","stackalloc","static","struct","switch","this","throw","try","typeof","unchecked","unsafe","using","virtual","void","volatile","while"].concat(["add","alias","and","ascending","args","async","await","by","descending","dynamic","equals","file","from","get","global","group","init","into","join","let","nameof","not","notnull","on","or","orderby","partial","record","remove","required","scoped","select","set","unmanaged","value|0","var","when","where","with","yield"]),built_in:["bool","byte","char","decimal","delegate","double","dynamic","enum","float","int","long","nint","nuint","object","sbyte","short","string","ulong","uint","ushort"],literal:["default","false","null","true"]},n=e.inherit(e.TITLE_MODE,{begin:"[a-zA-Z](\\.?\\w)*"}),r={className:"number",variants:[{begin:"\\b(0b[01']+)"},{begin:"(-?)\\b([\\d']+(\\.[\\d']*)?|\\.[\\d']+)(u|U|l|L|ul|UL|f|F|b|B)"},{begin:"(-?)(\\b0[xX][a-fA-F0-9']+|(\\b[\\d']+(\\.[\\d']*)?|\\.[\\d']+)([eE][-+]?[\\d']+)?)"}],relevance:0},i={className:"string",begin:'@"',end:'"',contains:[{begin:'""'}]},s=e.inherit(i,{illegal:/\n/}),o={className:"subst",begin:/\{/,end:/\}/,keywords:t},a=e.inherit(o,{illegal:/\n/}),l={className:"string",begin:/\$"/,end:'"',illegal:/\n/,contains:[{begin:/\{\{/},{begin:/\}\}/},e.BACKSLASH_ESCAPE,a]},c={className:"string",begin:/\$@"/,end:'"',contains:[{begin:/\{\{/},{begin:/\}\}/},{begin:'""'},o]},d=e.inherit(c,{illegal:/\n/,contains:[{begin:/\{\{/},{begin:/\}\}/},{begin:'""'},a]});o.contains=[c,l,i,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,r,e.C_BLOCK_COMMENT_MODE],a.contains=[d,l,s,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,r,e.inherit(e.C_BLOCK_COMMENT_MODE,{illegal:/\n/})];let u={variants:[{className:"string",begin:/"""("*)(?!")(.|\n)*?"""\1/,relevance:1},c,l,i,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},p={begin:"<",end:">",contains:[{beginKeywords:"in out"},n]},h=e.IDENT_RE+"(<"+e.IDENT_RE+"(\\s*,\\s*"+e.IDENT_RE+")*>)?(\\[\\])?",f={begin:"@"+e.IDENT_RE,relevance:0};return{name:"C#",aliases:["cs","c#"],keywords:t,illegal:/::/,contains:[e.COMMENT("///","$",{returnBegin:!0,contains:[{className:"doctag",variants:[{begin:"///",relevance:0},{begin:"<!--|-->"},{begin:"</?",end:">"}]}]}),e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,{className:"meta",begin:"#",end:"$",keywords:{keyword:"if else elif endif define undef warning error line region endregion pragma checksum"}},u,r,{beginKeywords:"class interface",relevance:0,end:/[{;=]/,illegal:/[^\s:,]/,contains:[{beginKeywords:"where class"},n,p,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{beginKeywords:"namespace",relevance:0,end:/[{;=]/,illegal:/[^\s:]/,contains:[n,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{beginKeywords:"record",relevance:0,end:/[{;=]/,illegal:/[^\s:]/,contains:[n,p,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{className:"meta",begin:"^\\s*\\[(?=[\\w])",excludeBegin:!0,end:"\\]",excludeEnd:!0,contains:[{className:"string",begin:/"/,end:/"/}]},{beginKeywords:"new return throw await else",relevance:0},{className:"function",begin:"("+h+"\\s+)+"+e.IDENT_RE+"\\s*(<[^=]+>\\s*)?\\(",returnBegin:!0,end:/\s*[{;=]/,excludeEnd:!0,keywords:t,contains:[{beginKeywords:"public private protected static internal protected abstract async extern override unsafe virtual new sealed partial",relevance:0},{begin:e.IDENT_RE+"\\s*(<[^=]+>\\s*)?\\(",returnBegin:!0,contains:[e.TITLE_MODE,p],relevance:0},{match:/\(\)/},{className:"params",begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:t,relevance:0,contains:[u,r,e.C_BLOCK_COMMENT_MODE]},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},f]}},css:xS,diff:function(e){let t=e.regex;return{name:"Diff",aliases:["patch"],contains:[{className:"meta",relevance:10,match:t.either(/^@@ +-\d+,\d+ +\+\d+,\d+ +@@/,/^\*\*\* +\d+,\d+ +\*\*\*\*$/,/^--- +\d+,\d+ +----$/)},{className:"comment",variants:[{begin:t.either(/Index: /,/^index/,/={3,}/,/^-{3}/,/^\*{3} /,/^\+{3}/,/^diff --git/),end:/$/},{match:/^\*{15}$/}]},{className:"addition",begin:/^\+/,end:/$/},{className:"deletion",begin:/^-/,end:/$/},{className:"addition",begin:/^!/,end:/$/}]}},go:xC,graphql:function(e){let t=e.regex;return{name:"GraphQL",aliases:["gql"],case_insensitive:!0,disableAutodetect:!1,keywords:{keyword:["query","mutation","subscription","type","input","schema","directive","interface","union","scalar","fragment","enum","on"],literal:["true","false","null"]},contains:[e.HASH_COMMENT_MODE,e.QUOTE_STRING_MODE,e.NUMBER_MODE,{scope:"punctuation",match:/[.]{3}/,relevance:0},{scope:"punctuation",begin:/[\!\(\)\:\=\[\]\{\|\}]{1}/,relevance:0},{scope:"variable",begin:/\$/,end:/\W/,excludeEnd:!0,relevance:0},{scope:"meta",match:/@\w+/,excludeEnd:!0},{scope:"symbol",begin:t.concat(/[_A-Za-z][_0-9A-Za-z]*/,t.lookahead(/\s*:/)),relevance:0}],illegal:[/[;<']/,/BEGIN/]}},ini:function(e){let t=e.regex,n={className:"number",relevance:0,variants:[{begin:/([+-]+)?[\d]+_[\d_]+/},{begin:e.NUMBER_RE}]},r=e.COMMENT();r.variants=[{begin:/;/,end:/$/},{begin:/#/,end:/$/}];let i={className:"variable",variants:[{begin:/\$[\w\d"][\w\d_]*/},{begin:/\$\{(.*?)\}/}]},s={className:"literal",begin:/\bon|off|true|false|yes|no\b/},o={className:"string",contains:[e.BACKSLASH_ESCAPE],variants:[{begin:"'''",end:"'''",relevance:10},{begin:'"""',end:'"""',relevance:10},{begin:'"',end:'"'},{begin:"'",end:"'"}]},a=t.either(/[A-Za-z0-9_-]+/,/"(\\"|[^"])*"/,/'[^']*'/);return{name:"TOML, also INI",aliases:["toml"],case_insensitive:!0,illegal:/\S/,contains:[r,{className:"section",begin:/\[+/,end:/\]+/},{begin:t.concat(a,"(\\s*\\.\\s*",a,")*",t.lookahead(/\s*=\s*[^#\s]/)),className:"attr",starts:{end:/$/,contains:[r,{begin:/\[/,end:/\]/,contains:[r,s,i,o,n,"self"],relevance:0},s,i,o,n]}}]}},java:function(e){let t=e.regex,n="[À-ʸa-zA-Z_$][À-ʸa-zA-Z_$0-9]*",r=n+function e(t,n,r){return -1===r?"":t.replace(n,i=>e(t,n,r-1))}("(?:<"+n+"~~~(?:\\s*,\\s*"+n+"~~~)*>)?",/~~~/g,2),i={keyword:["synchronized","abstract","private","var","static","if","const ","for","while","strictfp","finally","protected","import","native","final","void","enum","else","break","transient","catch","instanceof","volatile","case","assert","package","default","public","try","switch","continue","throws","protected","public","private","module","requires","exports","do","sealed","yield","permits","goto","when"],literal:["false","true","null"],type:["char","boolean","long","float","int","byte","short","double"],built_in:["super","this"]},s={className:"meta",begin:"@"+n,contains:[{begin:/\(/,end:/\)/,contains:["self"]}]},o={className:"params",begin:/\(/,end:/\)/,keywords:i,relevance:0,contains:[e.C_BLOCK_COMMENT_MODE],endsParent:!0};return{name:"Java",aliases:["jsp"],keywords:i,illegal:/<\/|#/,contains:[e.COMMENT("/\\*\\*","\\*/",{relevance:0,contains:[{begin:/\w+@/,relevance:0},{className:"doctag",begin:"@[A-Za-z]+"}]}),{begin:/import java\.[a-z]+\./,keywords:"import",relevance:2},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,{begin:/"""/,end:/"""/,className:"string",contains:[e.BACKSLASH_ESCAPE]},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,{match:[/\b(?:class|interface|enum|extends|implements|new)/,/\s+/,n],className:{1:"keyword",3:"title.class"}},{match:/non-sealed/,scope:"keyword"},{begin:[t.concat(/(?!else)/,n),/\s+/,n,/\s+/,/=(?!=)/],className:{1:"type",3:"variable",5:"operator"}},{begin:[/record/,/\s+/,n],className:{1:"keyword",3:"title.class"},contains:[o,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{beginKeywords:"new throw return else",relevance:0},{begin:["(?:"+r+"\\s+)",e.UNDERSCORE_IDENT_RE,/\s*(?=\()/],className:{2:"title.function"},keywords:i,contains:[{className:"params",begin:/\(/,end:/\)/,keywords:i,relevance:0,contains:[s,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,v4,e.C_BLOCK_COMMENT_MODE]},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},v4,s]}},javascript:xR,json:xI,kotlin:function(e){let t={keyword:"abstract as val var vararg get set class object open private protected public noinline crossinline dynamic final enum if else do while for when throw try catch finally import package is in fun override companion reified inline lateinit init interface annotation data sealed internal infix operator out by constructor super tailrec where const inner suspend typealias external expect actual",built_in:"Byte Short Char Int Long Boolean Float Double Void Unit Nothing",literal:"true false null"},n={className:"symbol",begin:e.UNDERSCORE_IDENT_RE+"@"},r={className:"subst",begin:/\$\{/,end:/\}/,contains:[e.C_NUMBER_MODE]},i={className:"variable",begin:"\\$"+e.UNDERSCORE_IDENT_RE},s={className:"string",variants:[{begin:'"""',end:'"""(?=[^"])',contains:[i,r]},{begin:"'",end:"'",illegal:/\n/,contains:[e.BACKSLASH_ESCAPE]},{begin:'"',end:'"',illegal:/\n/,contains:[e.BACKSLASH_ESCAPE,i,r]}]};r.contains.push(s);let o={className:"meta",begin:"@(?:file|property|field|get|set|receiver|param|setparam|delegate)\\s*:(?:\\s*"+e.UNDERSCORE_IDENT_RE+")?"},a={className:"meta",begin:"@"+e.UNDERSCORE_IDENT_RE,contains:[{begin:/\(/,end:/\)/,contains:[e.inherit(s,{className:"string"}),"self"]}]},l=e.COMMENT("/\\*","\\*/",{contains:[e.C_BLOCK_COMMENT_MODE]}),c={variants:[{className:"type",begin:e.UNDERSCORE_IDENT_RE},{begin:/\(/,end:/\)/,contains:[]}]};return c.variants[1].contains=[c],c.variants[1].contains=[c],{name:"Kotlin",aliases:["kt","kts"],keywords:t,contains:[e.COMMENT("/\\*\\*","\\*/",{relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"}]}),e.C_LINE_COMMENT_MODE,l,{className:"keyword",begin:/\b(break|continue|return|this)\b/,starts:{contains:[{className:"symbol",begin:/@\w+/}]}},n,o,a,{className:"function",beginKeywords:"fun",end:"[(]|$",returnBegin:!0,excludeEnd:!0,keywords:t,relevance:5,contains:[{begin:e.UNDERSCORE_IDENT_RE+"\\s*\\(",returnBegin:!0,relevance:0,contains:[e.UNDERSCORE_TITLE_MODE]},{className:"type",begin:/</,end:/>/,keywords:"reified",relevance:0},{className:"params",begin:/\(/,end:/\)/,endsParent:!0,keywords:t,relevance:0,contains:[{begin:/:/,end:/[=,\/]/,endsWithParent:!0,contains:[c,e.C_LINE_COMMENT_MODE,l],relevance:0},e.C_LINE_COMMENT_MODE,l,o,a,s,e.C_NUMBER_MODE]},l]},{begin:[/class|interface|trait/,/\s+/,e.UNDERSCORE_IDENT_RE],beginScope:{3:"title.class"},keywords:"class interface trait",end:/[:\{(]|$/,excludeEnd:!0,illegal:"extends implements",contains:[{beginKeywords:"public protected internal private constructor"},e.UNDERSCORE_TITLE_MODE,{className:"type",begin:/</,end:/>/,excludeBegin:!0,excludeEnd:!0,relevance:0},{className:"type",begin:/[,:]\s*/,end:/[<\(,){\s]|$/,excludeBegin:!0,returnEnd:!0},o,a]},s,{className:"meta",begin:"^#!/usr/bin/env",end:"$",illegal:"\n"},v8]}},less:function(e){let t={IMPORTANT:{scope:"meta",begin:"!important"},BLOCK_COMMENT:e.C_BLOCK_COMMENT_MODE,HEXCOLOR:{scope:"number",begin:/#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/},FUNCTION_DISPATCH:{className:"built_in",begin:/[\w-]+(?=\()/},ATTRIBUTE_SELECTOR_MODE:{scope:"selector-attr",begin:/\[/,end:/\]/,illegal:"$",contains:[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},CSS_NUMBER_MODE:{scope:"number",begin:e.NUMBER_RE+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",relevance:0},CSS_VARIABLE:{className:"attr",begin:/--[A-Za-z_][A-Za-z0-9_-]*/}},n="[\\w-]+",r="("+n+"|@\\{"+n+"\\})",i=[],s=[],o=function(e){return{className:"string",begin:"~?"+e+".*?"+e}},a=function(e,t,n){return{className:e,begin:t,relevance:n}},l={$pattern:/[a-z-]+/,keyword:"and or not only",attribute:wt.join(" ")};s.push(e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,o("'"),o('"'),t.CSS_NUMBER_MODE,{begin:"(url|data-uri)\\(",starts:{className:"string",end:"[\\)\\n]",excludeEnd:!0}},t.HEXCOLOR,{begin:"\\(",end:"\\)",contains:s,keywords:l,relevance:0},a("variable","@@?"+n,10),a("variable","@\\{"+n+"\\}"),a("built_in","~?`[^`]*?`"),{className:"attribute",begin:n+"\\s*:",end:":",returnBegin:!0,excludeEnd:!0},t.IMPORTANT,{beginKeywords:"and not"},t.FUNCTION_DISPATCH);let c=s.concat({begin:/\{/,end:/\}/,contains:i}),d={beginKeywords:"when",endsWithParent:!0,contains:[{beginKeywords:"and not"}].concat(s)},u={begin:r+"\\s*:",returnBegin:!0,end:/[;}]/,relevance:0,contains:[{begin:/-(webkit|moz|ms|o)-/},t.CSS_VARIABLE,{className:"attribute",begin:"\\b("+wi.join("|")+")\\b",end:/(?=:)/,starts:{endsWithParent:!0,illegal:"[<=$]",relevance:0,contains:s}}]},p={variants:[{begin:"[\\.#:&\\[>]",end:"[;{}]"},{begin:r,end:/\{/}],returnBegin:!0,returnEnd:!0,illegal:"[<='$\"]",relevance:0,contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,d,a("keyword","all\\b"),a("variable","@\\{"+n+"\\}"),{begin:"\\b("+we.join("|")+")\\b",className:"selector-tag"},t.CSS_NUMBER_MODE,a("selector-tag",r,0),a("selector-id","#"+r),a("selector-class","\\."+r,0),a("selector-tag","&",0),t.ATTRIBUTE_SELECTOR_MODE,{className:"selector-pseudo",begin:":("+wn.join("|")+")"},{className:"selector-pseudo",begin:":(:)?("+wr.join("|")+")"},{begin:/\(/,end:/\)/,relevance:0,contains:c},{begin:"!important"},t.FUNCTION_DISPATCH]},h={begin:n+":(:)?"+`(${ws.join("|")})`,returnBegin:!0,contains:[p]};return i.push(e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,{className:"keyword",begin:"@(import|media|charset|font-face|(-[a-z]+-)?keyframes|supports|document|namespace|page|viewport|host)\\b",starts:{end:"[;{}]",keywords:l,returnEnd:!0,contains:s,relevance:0}},{className:"variable",variants:[{begin:"@"+n+"\\s*:",relevance:15},{begin:"@"+n}],starts:{end:"[;}]",returnEnd:!0,contains:c}},h,u,p,d,t.FUNCTION_DISPATCH),{name:"Less",case_insensitive:!0,illegal:"[=>'/<($\"]",contains:i}},lua:function(e){let t="\\[=*\\[",n="\\]=*\\]",r={begin:t,end:n,contains:["self"]},i=[e.COMMENT("--(?!"+t+")","$"),e.COMMENT("--"+t,n,{contains:[r],relevance:10})];return{name:"Lua",aliases:["pluto"],keywords:{$pattern:e.UNDERSCORE_IDENT_RE,literal:"true false nil",keyword:"and break do else elseif end for goto if in local not or repeat return then until while",built_in:"_G _ENV _VERSION __index __newindex __mode __call __metatable __tostring __len __gc __add __sub __mul __div __mod __pow __concat __unm __eq __lt __le assert collectgarbage dofile error getfenv getmetatable ipairs load loadfile loadstring module next pairs pcall print rawequal rawget rawset require select setfenv setmetatable tonumber tostring type unpack xpcall arg self coroutine resume yield status wrap create running debug getupvalue debug sethook getmetatable gethook setmetatable setlocal traceback setfenv getinfo setupvalue getlocal getregistry getfenv io lines write close flush open output type read stderr stdin input stdout popen tmpfile math log max acos huge ldexp pi cos tanh pow deg tan cosh sinh random randomseed frexp ceil floor rad abs sqrt modf asin min mod fmod log10 atan2 exp sin atan os exit setlocale date getenv difftime remove time clock tmpname rename execute package preload loadlib loaded loaders cpath config path seeall string sub upper len gfind rep find match char dump gmatch reverse byte format gsub lower table setn insert getn foreachi maxn foreach concat sort remove"},contains:i.concat([{className:"function",beginKeywords:"function",end:"\\)",contains:[e.inherit(e.TITLE_MODE,{begin:"([_a-zA-Z]\\w*\\.)*([_a-zA-Z]\\w*:)?[_a-zA-Z]\\w*"}),{className:"params",begin:"\\(",endsWithParent:!0,contains:i}].concat(i)},e.C_NUMBER_MODE,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,{className:"string",begin:t,end:n,contains:[r],relevance:5}])}},makefile:function(e){let t={className:"variable",variants:[{begin:"\\$\\("+e.UNDERSCORE_IDENT_RE+"\\)",contains:[e.BACKSLASH_ESCAPE]},{begin:/\$[@%<?\^\+\*]/}]},n={className:"string",begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,t]},r={begin:"^"+e.UNDERSCORE_IDENT_RE+"\\s*(?=[:+?]?=)"};return{name:"Makefile",aliases:["mk","mak","make"],keywords:{$pattern:/[\w-]+/,keyword:"define endef undefine ifdef ifndef ifeq ifneq else endif include -include sinclude override export unexport private vpath"},contains:[e.HASH_COMMENT_MODE,t,n,{className:"variable",begin:/\$\([\w-]+\s/,end:/\)/,keywords:{built_in:"subst patsubst strip findstring filter filter-out sort word wordlist firstword lastword dir notdir suffix basename addsuffix addprefix join wildcard realpath abspath error warning shell origin flavor foreach if or and call eval file value"},contains:[t,n]},r,{className:"meta",begin:/^\.PHONY:/,end:/$/,keywords:{$pattern:/[\.\w]+/,keyword:".PHONY"}},{className:"section",begin:/^[^\s]+:/,end:/$/,contains:[t]}]}},markdown:xL,objectivec:function(e){let t=/[a-zA-Z@][a-zA-Z0-9_]*/,n={$pattern:t,keyword:["@interface","@class","@protocol","@implementation"]};return{name:"Objective-C",aliases:["mm","objc","obj-c","obj-c++","objective-c++"],keywords:{"variable.language":["this","super"],$pattern:t,keyword:["while","export","sizeof","typedef","const","struct","for","union","volatile","static","mutable","if","do","return","goto","enum","else","break","extern","asm","case","default","register","explicit","typename","switch","continue","inline","readonly","assign","readwrite","self","@synchronized","id","typeof","nonatomic","IBOutlet","IBAction","strong","weak","copy","in","out","inout","bycopy","byref","oneway","__strong","__weak","__block","__autoreleasing","@private","@protected","@public","@try","@property","@end","@throw","@catch","@finally","@autoreleasepool","@synthesize","@dynamic","@selector","@optional","@required","@encode","@package","@import","@defs","@compatibility_alias","__bridge","__bridge_transfer","__bridge_retained","__bridge_retain","__covariant","__contravariant","__kindof","_Nonnull","_Nullable","_Null_unspecified","__FUNCTION__","__PRETTY_FUNCTION__","__attribute__","getter","setter","retain","unsafe_unretained","nonnull","nullable","null_unspecified","null_resettable","class","instancetype","NS_DESIGNATED_INITIALIZER","NS_UNAVAILABLE","NS_REQUIRES_SUPER","NS_RETURNS_INNER_POINTER","NS_INLINE","NS_AVAILABLE","NS_DEPRECATED","NS_ENUM","NS_OPTIONS","NS_SWIFT_UNAVAILABLE","NS_ASSUME_NONNULL_BEGIN","NS_ASSUME_NONNULL_END","NS_REFINED_FOR_SWIFT","NS_SWIFT_NAME","NS_SWIFT_NOTHROW","NS_DURING","NS_HANDLER","NS_ENDHANDLER","NS_VALUERETURN","NS_VOIDRETURN"],literal:["false","true","FALSE","TRUE","nil","YES","NO","NULL"],built_in:["dispatch_once_t","dispatch_queue_t","dispatch_sync","dispatch_async","dispatch_once"],type:["int","float","char","unsigned","signed","short","long","double","wchar_t","unichar","void","bool","BOOL","id|0","_Bool"]},illegal:"</",contains:[{className:"built_in",begin:"\\b(AV|CA|CF|CG|CI|CL|CM|CN|CT|MK|MP|MTK|MTL|NS|SCN|SK|UI|WK|XC)\\w+"},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,e.C_NUMBER_MODE,e.QUOTE_STRING_MODE,e.APOS_STRING_MODE,{className:"string",variants:[{begin:'@"',end:'"',illegal:"\\n",contains:[e.BACKSLASH_ESCAPE]}]},{className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:"if else elif endif define undef warning error line pragma ifdef ifndef include"},contains:[{begin:/\\\n/,relevance:0},e.inherit(e.QUOTE_STRING_MODE,{className:"string"}),{className:"string",begin:/<.*?>/,end:/$/,illegal:"\\n"},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{className:"class",begin:"("+n.keyword.join("|")+")\\b",end:/(\{|$)/,excludeEnd:!0,keywords:n,contains:[e.UNDERSCORE_TITLE_MODE]},{begin:"\\."+e.UNDERSCORE_IDENT_RE,relevance:0}]}},perl:function(e){let t=e.regex,n=/[dualxmsipngr]{0,12}/,r={$pattern:/[\w.]+/,keyword:"abs accept alarm and atan2 bind binmode bless break caller chdir chmod chomp chop chown chr chroot class close closedir connect continue cos crypt dbmclose dbmopen defined delete die do dump each else elsif endgrent endhostent endnetent endprotoent endpwent endservent eof eval exec exists exit exp fcntl field fileno flock for foreach fork format formline getc getgrent getgrgid getgrnam gethostbyaddr gethostbyname gethostent getlogin getnetbyaddr getnetbyname getnetent getpeername getpgrp getpriority getprotobyname getprotobynumber getprotoent getpwent getpwnam getpwuid getservbyname getservbyport getservent getsockname getsockopt given glob gmtime goto grep gt hex if index int ioctl join keys kill last lc lcfirst length link listen local localtime log lstat lt ma map method mkdir msgctl msgget msgrcv msgsnd my ne next no not oct open opendir or ord our pack package pipe pop pos print printf prototype push q|0 qq quotemeta qw qx rand read readdir readline readlink readpipe recv redo ref rename require reset return reverse rewinddir rindex rmdir say scalar seek seekdir select semctl semget semop send setgrent sethostent setnetent setpgrp setpriority setprotoent setpwent setservent setsockopt shift shmctl shmget shmread shmwrite shutdown sin sleep socket socketpair sort splice split sprintf sqrt srand stat state study sub substr symlink syscall sysopen sysread sysseek system syswrite tell telldir tie tied time times tr truncate uc ucfirst umask undef unless unlink unpack unshift untie until use utime values vec wait waitpid wantarray warn when while write x|0 xor y|0"},i={className:"subst",begin:"[$@]\\{",end:"\\}",keywords:r},s={begin:/->\{/,end:/\}/},o={scope:"attr",match:/\s+:\s*\w+(\s*\(.*?\))?/},a={scope:"variable",variants:[{begin:/\$\d/},{begin:t.concat(/[$%@](?!")(\^\w\b|#\w+(::\w+)*|\{\w+\}|\w+(::\w*)*)/,"(?![A-Za-z])(?![@$%])")},{begin:/[$%@](?!")[^\s\w{=]|\$=/,relevance:0}],contains:[o]},l={className:"number",variants:[{match:/0?\.[0-9][0-9_]+\b/},{match:/\bv?(0|[1-9][0-9_]*(\.[0-9_]+)?|[1-9][0-9_]*)\b/},{match:/\b0[0-7][0-7_]*\b/},{match:/\b0x[0-9a-fA-F][0-9a-fA-F_]*\b/},{match:/\b0b[0-1][0-1_]*\b/}],relevance:0},c=[e.BACKSLASH_ESCAPE,i,a],d=[/!/,/\//,/\|/,/\?/,/'/,/"/,/#/],u=(e,r,i="\\1")=>{let s="\\1"===i?i:t.concat(i,r);return t.concat(t.concat("(?:",e,")"),r,/(?:\\.|[^\\\/])*?/,s,/(?:\\.|[^\\\/])*?/,i,n)},p=(e,r,i)=>t.concat(t.concat("(?:",e,")"),r,/(?:\\.|[^\\\/])*?/,i,n),h=[a,e.HASH_COMMENT_MODE,e.COMMENT(/^=\w/,/=cut/,{endsWithParent:!0}),s,{className:"string",contains:c,variants:[{begin:"q[qwxr]?\\s*\\(",end:"\\)",relevance:5},{begin:"q[qwxr]?\\s*\\[",end:"\\]",relevance:5},{begin:"q[qwxr]?\\s*\\{",end:"\\}",relevance:5},{begin:"q[qwxr]?\\s*\\|",end:"\\|",relevance:5},{begin:"q[qwxr]?\\s*<",end:">",relevance:5},{begin:"qw\\s+q",end:"q",relevance:5},{begin:"'",end:"'",contains:[e.BACKSLASH_ESCAPE]},{begin:'"',end:'"'},{begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE]},{begin:/\{\w+\}/,relevance:0},{begin:"-?\\w+\\s*=>",relevance:0}]},l,{begin:"(\\/\\/|"+e.RE_STARTERS_RE+"|\\b(split|return|print|reverse|grep)\\b)\\s*",keywords:"split return print reverse grep",relevance:0,contains:[e.HASH_COMMENT_MODE,{className:"regexp",variants:[{begin:u("s|tr|y",t.either(...d,{capture:!0}))},{begin:u("s|tr|y","\\(","\\)")},{begin:u("s|tr|y","\\[","\\]")},{begin:u("s|tr|y","\\{","\\}")}],relevance:2},{className:"regexp",variants:[{begin:/(m|qr)\/\//,relevance:0},{begin:p("(?:m|qr)?",/\//,/\//)},{begin:p("m|qr",t.either(...d,{capture:!0}),/\1/)},{begin:p("m|qr",/\(/,/\)/)},{begin:p("m|qr",/\[/,/\]/)},{begin:p("m|qr",/\{/,/\}/)}]}]},{className:"function",beginKeywords:"sub method",end:"(\\s*\\(.*?\\))?[;{]",excludeEnd:!0,relevance:5,contains:[e.TITLE_MODE,o]},{className:"class",beginKeywords:"class",end:"[;{]",excludeEnd:!0,relevance:5,contains:[e.TITLE_MODE,o,l]},{begin:"-\\w\\b",relevance:0},{begin:"^__DATA__$",end:"^__END__$",subLanguage:"mojolicious",contains:[{begin:"^@@.*",end:"$",className:"comment"}]}];return i.contains=h,s.contains=h,{name:"Perl",aliases:["pl","pm"],keywords:r,contains:h}},php:function(e){let t,n=e.regex,r=/(?![A-Za-z0-9])(?![$])/,i=n.concat(/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/,r),s=n.concat(/(\\?[A-Z][a-z0-9_\x7f-\xff]+|\\?[A-Z]+(?=[A-Z][a-z0-9_\x7f-\xff])){1,}/,r),o=n.concat(/[A-Z]+/,r),a={scope:"variable",match:"\\$+"+i},l={scope:"subst",variants:[{begin:/\$\w+/},{begin:/\{\$/,end:/\}/}]},c=e.inherit(e.APOS_STRING_MODE,{illegal:null}),d=e.inherit(e.QUOTE_STRING_MODE,{illegal:null,contains:e.QUOTE_STRING_MODE.contains.concat(l)}),u={begin:/<<<[ \t]*(?:(\w+)|"(\w+)")\n/,end:/[ \t]*(\w+)\b/,contains:e.QUOTE_STRING_MODE.contains.concat(l),"on:begin":(e,t)=>{t.data._beginMatch=e[1]||e[2]},"on:end":(e,t)=>{t.data._beginMatch!==e[1]&&t.ignoreMatch()}},p=e.END_SAME_AS_BEGIN({begin:/<<<[ \t]*'(\w+)'\n/,end:/[ \t]*(\w+)\b/}),h="[ \n]",f={scope:"string",variants:[d,c,u,p]},m={scope:"number",variants:[{begin:"\\b0[bB][01]+(?:_[01]+)*\\b"},{begin:"\\b0[oO][0-7]+(?:_[0-7]+)*\\b"},{begin:"\\b0[xX][\\da-fA-F]+(?:_[\\da-fA-F]+)*\\b"},{begin:"(?:\\b\\d+(?:_\\d+)*(\\.(?:\\d+(?:_\\d+)*))?|\\B\\.\\d+)(?:[eE][+-]?\\d+)?"}],relevance:0},g=["false","null","true"],b=["__CLASS__","__DIR__","__FILE__","__FUNCTION__","__COMPILER_HALT_OFFSET__","__LINE__","__METHOD__","__NAMESPACE__","__TRAIT__","die","echo","exit","include","include_once","print","require","require_once","array","abstract","and","as","binary","bool","boolean","break","callable","case","catch","class","clone","const","continue","declare","default","do","double","else","elseif","empty","enddeclare","endfor","endforeach","endif","endswitch","endwhile","enum","eval","extends","final","finally","float","for","foreach","from","global","goto","if","implements","instanceof","insteadof","int","integer","interface","isset","iterable","list","match|0","mixed","new","never","object","or","private","protected","public","readonly","real","return","string","switch","throw","trait","try","unset","use","var","void","while","xor","yield"],x=["Error|0","AppendIterator","ArgumentCountError","ArithmeticError","ArrayIterator","ArrayObject","AssertionError","BadFunctionCallException","BadMethodCallException","CachingIterator","CallbackFilterIterator","CompileError","Countable","DirectoryIterator","DivisionByZeroError","DomainException","EmptyIterator","ErrorException","Exception","FilesystemIterator","FilterIterator","GlobIterator","InfiniteIterator","InvalidArgumentException","IteratorIterator","LengthException","LimitIterator","LogicException","MultipleIterator","NoRewindIterator","OutOfBoundsException","OutOfRangeException","OuterIterator","OverflowException","ParentIterator","ParseError","RangeException","RecursiveArrayIterator","RecursiveCachingIterator","RecursiveCallbackFilterIterator","RecursiveDirectoryIterator","RecursiveFilterIterator","RecursiveIterator","RecursiveIteratorIterator","RecursiveRegexIterator","RecursiveTreeIterator","RegexIterator","RuntimeException","SeekableIterator","SplDoublyLinkedList","SplFileInfo","SplFileObject","SplFixedArray","SplHeap","SplMaxHeap","SplMinHeap","SplObjectStorage","SplObserver","SplPriorityQueue","SplQueue","SplStack","SplSubject","SplTempFileObject","TypeError","UnderflowException","UnexpectedValueException","UnhandledMatchError","ArrayAccess","BackedEnum","Closure","Fiber","Generator","Iterator","IteratorAggregate","Serializable","Stringable","Throwable","Traversable","UnitEnum","WeakReference","WeakMap","Directory","__PHP_Incomplete_Class","parent","php_user_filter","self","static","stdClass"],y={keyword:b,literal:(t=[],g.forEach(e=>{t.push(e),e.toLowerCase()===e?t.push(e.toUpperCase()):t.push(e.toLowerCase())}),t),built_in:x},v=e=>e.map(e=>e.replace(/\|\d+$/,"")),w={variants:[{match:[/new/,n.concat(h,"+"),n.concat("(?!",v(x).join("\\b|"),"\\b)"),s],scope:{1:"keyword",4:"title.class"}}]},k=n.concat(i,"\\b(?!\\()"),N={variants:[{match:[n.concat(/::/,n.lookahead(/(?!class\b)/)),k],scope:{2:"variable.constant"}},{match:[/::/,/class/],scope:{2:"variable.language"}},{match:[s,n.concat(/::/,n.lookahead(/(?!class\b)/)),k],scope:{1:"title.class",3:"variable.constant"}},{match:[s,n.concat("::",n.lookahead(/(?!class\b)/))],scope:{1:"title.class"}},{match:[s,/::/,/class/],scope:{1:"title.class",3:"variable.language"}}]},S={scope:"attr",match:n.concat(i,n.lookahead(":"),n.lookahead(/(?!::)/))},C={relevance:0,begin:/\(/,end:/\)/,keywords:y,contains:[S,a,N,e.C_BLOCK_COMMENT_MODE,f,m,w]},j={relevance:0,match:[/\b/,n.concat("(?!fn\\b|function\\b|",v(b).join("\\b|"),"|",v(x).join("\\b|"),"\\b)"),i,n.concat(h,"*"),n.lookahead(/(?=\()/)],scope:{3:"title.function.invoke"},contains:[C]};C.contains.push(j);let E=[S,N,e.C_BLOCK_COMMENT_MODE,f,m,w],M={begin:n.concat(/#\[\s*\\?/,n.either(s,o)),beginScope:"meta",end:/]/,endScope:"meta",keywords:{literal:g,keyword:["new","array"]},contains:[{begin:/\[/,end:/]/,keywords:{literal:g,keyword:["new","array"]},contains:["self",...E]},...E,{scope:"meta",variants:[{match:s},{match:o}]}]};return{case_insensitive:!1,keywords:y,contains:[M,e.HASH_COMMENT_MODE,e.COMMENT("//","$"),e.COMMENT("/\\*","\\*/",{contains:[{scope:"doctag",match:"@[A-Za-z]+"}]}),{match:/__halt_compiler\(\);/,keywords:"__halt_compiler",starts:{scope:"comment",end:e.MATCH_NOTHING_RE,contains:[{match:/\?>/,scope:"meta",endsParent:!0}]}},{scope:"meta",variants:[{begin:/<\?php/,relevance:10},{begin:/<\?=/},{begin:/<\?/,relevance:.1},{begin:/\?>/}]},{scope:"variable.language",match:/\$this\b/},a,j,N,{match:[/const/,/\s/,i],scope:{1:"keyword",3:"variable.constant"}},w,{scope:"function",relevance:0,beginKeywords:"fn function",end:/[;{]/,excludeEnd:!0,illegal:"[$%\\[]",contains:[{beginKeywords:"use"},e.UNDERSCORE_TITLE_MODE,{begin:"=>",endsParent:!0},{scope:"params",begin:"\\(",end:"\\)",excludeBegin:!0,excludeEnd:!0,keywords:y,contains:["self",M,a,N,e.C_BLOCK_COMMENT_MODE,f,m]}]},{scope:"class",variants:[{beginKeywords:"enum",illegal:/[($"]/},{beginKeywords:"class interface trait",illegal:/[:($"]/}],relevance:0,end:/\{/,excludeEnd:!0,contains:[{beginKeywords:"extends implements"},e.UNDERSCORE_TITLE_MODE]},{beginKeywords:"namespace",relevance:0,end:";",illegal:/[.']/,contains:[e.inherit(e.UNDERSCORE_TITLE_MODE,{scope:"title.class"})]},{beginKeywords:"use",relevance:0,end:";",contains:[{match:/\b(as|const|function)\b/,scope:"keyword"},e.UNDERSCORE_TITLE_MODE]},f,m]}},"php-template":function(e){return{name:"PHP template",subLanguage:"xml",contains:[{begin:/<\?(php|=)?/,end:/\?>/,subLanguage:"php",contains:[{begin:"/\\*",end:"\\*/",skip:!0},{begin:'b"',end:'"',skip:!0},{begin:"b'",end:"'",skip:!0},e.inherit(e.APOS_STRING_MODE,{illegal:null,className:null,contains:null,skip:!0}),e.inherit(e.QUOTE_STRING_MODE,{illegal:null,className:null,contains:null,skip:!0})]}]}},plaintext:function(e){return{name:"Plain text",aliases:["text","txt"],disableAutodetect:!0}},python:xP,"python-repl":function(e){return{aliases:["pycon"],contains:[{className:"meta.prompt",starts:{end:/ |$/,starts:{end:"$",subLanguage:"python"}},variants:[{begin:/^>>>(?=[ ]|$)/},{begin:/^\.\.\.(?=[ ]|$)/}]}]}},r:function(e){let t=e.regex,n=/(?:(?:[a-zA-Z]|\.[._a-zA-Z])[._a-zA-Z0-9]*)|\.(?!\d)/,r=t.either(/0[xX][0-9a-fA-F]+\.[0-9a-fA-F]*[pP][+-]?\d+i?/,/0[xX][0-9a-fA-F]+(?:[pP][+-]?\d+)?[Li]?/,/(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?[Li]?/),i=/[=!<>:]=|\|\||&&|:::?|<-|<<-|->>|->|\|>|[-+*\/?!$&|:<=>@^~]|\*\*/,s=t.either(/[()]/,/[{}]/,/\[\[/,/[[\]]/,/\\/,/,/);return{name:"R",keywords:{$pattern:n,keyword:"function if in break next repeat else for while",literal:"NULL NA TRUE FALSE Inf NaN NA_integer_|10 NA_real_|10 NA_character_|10 NA_complex_|10",built_in:"LETTERS letters month.abb month.name pi T F abs acos acosh all any anyNA Arg as.call as.character as.complex as.double as.environment as.integer as.logical as.null.default as.numeric as.raw asin asinh atan atanh attr attributes baseenv browser c call ceiling class Conj cos cosh cospi cummax cummin cumprod cumsum digamma dim dimnames emptyenv exp expression floor forceAndCall gamma gc.time globalenv Im interactive invisible is.array is.atomic is.call is.character is.complex is.double is.environment is.expression is.finite is.function is.infinite is.integer is.language is.list is.logical is.matrix is.na is.name is.nan is.null is.numeric is.object is.pairlist is.raw is.recursive is.single is.symbol lazyLoadDBfetch length lgamma list log max min missing Mod names nargs nzchar oldClass on.exit pos.to.env proc.time prod quote range Re rep retracemem return round seq_along seq_len seq.int sign signif sin sinh sinpi sqrt standardGeneric substitute sum switch tan tanh tanpi tracemem trigamma trunc unclass untracemem UseMethod xtfrm"},contains:[e.COMMENT(/#'/,/$/,{contains:[{scope:"doctag",match:/@examples/,starts:{end:t.lookahead(t.either(/\n^#'\s*(?=@[a-zA-Z]+)/,/\n^(?!#')/)),endsParent:!0}},{scope:"doctag",begin:"@param",end:/$/,contains:[{scope:"variable",variants:[{match:n},{match:/`(?:\\.|[^`\\])+`/}],endsParent:!0}]},{scope:"doctag",match:/@[a-zA-Z]+/},{scope:"keyword",match:/\\[a-zA-Z]+/}]}),e.HASH_COMMENT_MODE,{scope:"string",contains:[e.BACKSLASH_ESCAPE],variants:[e.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\(/,end:/\)(-*)"/}),e.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\{/,end:/\}(-*)"/}),e.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\[/,end:/\](-*)"/}),e.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\(/,end:/\)(-*)'/}),e.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\{/,end:/\}(-*)'/}),e.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\[/,end:/\](-*)'/}),{begin:'"',end:'"',relevance:0},{begin:"'",end:"'",relevance:0}]},{relevance:0,variants:[{scope:{1:"operator",2:"number"},match:[i,r]},{scope:{1:"operator",2:"number"},match:[/%[^%]*%/,r]},{scope:{1:"punctuation",2:"number"},match:[s,r]},{scope:{2:"number"},match:[/[^a-zA-Z0-9._]|^/,r]}]},{scope:{3:"operator"},match:[n,/\s+/,/<-/,/\s+/]},{scope:"operator",relevance:0,variants:[{match:i},{match:/%[^%]*%/}]},{scope:"punctuation",relevance:0,match:s},{begin:"`",end:"`",contains:[{begin:/\\./}]}]}},ruby:function(e){let t=e.regex,n="([a-zA-Z_]\\w*[!?=]?|[-+~]@|<<|>>|=~|===?|<=>|[<>]=?|\\*\\*|[-/+%^&*~`|]|\\[\\]=?)",r=t.either(/\b([A-Z]+[a-z0-9]+)+/,/\b([A-Z]+[a-z0-9]+)+[A-Z]+/),i=t.concat(r,/(::\w+)*/),s={"variable.constant":["__FILE__","__LINE__","__ENCODING__"],"variable.language":["self","super"],keyword:["alias","and","begin","BEGIN","break","case","class","defined","do","else","elsif","end","END","ensure","for","if","in","module","next","not","or","redo","require","rescue","retry","return","then","undef","unless","until","when","while","yield","include","extend","prepend","public","private","protected","raise","throw"],built_in:["proc","lambda","attr_accessor","attr_reader","attr_writer","define_method","private_constant","module_function"],literal:["true","false","nil"]},o={className:"doctag",begin:"@[A-Za-z]+"},a={begin:"#<",end:">"},l=[e.COMMENT("#","$",{contains:[o]}),e.COMMENT("^=begin","^=end",{contains:[o],relevance:10}),e.COMMENT("^__END__",e.MATCH_NOTHING_RE)],c={className:"subst",begin:/#\{/,end:/\}/,keywords:s},d={className:"string",contains:[e.BACKSLASH_ESCAPE,c],variants:[{begin:/'/,end:/'/},{begin:/"/,end:/"/},{begin:/`/,end:/`/},{begin:/%[qQwWx]?\(/,end:/\)/},{begin:/%[qQwWx]?\[/,end:/\]/},{begin:/%[qQwWx]?\{/,end:/\}/},{begin:/%[qQwWx]?</,end:/>/},{begin:/%[qQwWx]?\//,end:/\//},{begin:/%[qQwWx]?%/,end:/%/},{begin:/%[qQwWx]?-/,end:/-/},{begin:/%[qQwWx]?\|/,end:/\|/},{begin:/\B\?(\\\d{1,3})/},{begin:/\B\?(\\x[A-Fa-f0-9]{1,2})/},{begin:/\B\?(\\u\{?[A-Fa-f0-9]{1,6}\}?)/},{begin:/\B\?(\\M-\\C-|\\M-\\c|\\c\\M-|\\M-|\\C-\\M-)[\x20-\x7e]/},{begin:/\B\?\\(c|C-)[\x20-\x7e]/},{begin:/\B\?\\?\S/},{begin:t.concat(/<<[-~]?'?/,t.lookahead(/(\w+)(?=\W)[^\n]*\n(?:[^\n]*\n)*?\s*\1\b/)),contains:[e.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,contains:[e.BACKSLASH_ESCAPE,c]})]}]},u="[0-9](_?[0-9])*",p={className:"number",relevance:0,variants:[{begin:`\\b([1-9](_?[0-9])*|0)(\\.(${u}))?([eE][+-]?(${u})|r)?i?\\b`},{begin:"\\b0[dD][0-9](_?[0-9])*r?i?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*r?i?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*r?i?\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*r?i?\\b"},{begin:"\\b0(_?[0-7])+r?i?\\b"}]},h={variants:[{match:/\(\)/},{className:"params",begin:/\(/,end:/(?=\))/,excludeBegin:!0,endsParent:!0,keywords:s}]},f=[d,{variants:[{match:[/class\s+/,i,/\s+<\s+/,i]},{match:[/\b(class|module)\s+/,i]}],scope:{2:"title.class",4:"title.class.inherited"},keywords:s},{match:[/(include|extend)\s+/,i],scope:{2:"title.class"},keywords:s},{relevance:0,match:[i,/\.new[. (]/],scope:{1:"title.class"}},{relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"},{relevance:0,match:r,scope:"title.class"},{match:[/def/,/\s+/,n],scope:{1:"keyword",3:"title.function"},contains:[h]},{begin:e.IDENT_RE+"::"},{className:"symbol",begin:e.UNDERSCORE_IDENT_RE+"(!|\\?)?:",relevance:0},{className:"symbol",begin:":(?!\\s)",contains:[d,{begin:n}],relevance:0},p,{className:"variable",begin:"(\\$\\W)|((\\$|@@?)(\\w+))(?=[^@$?])(?![A-Za-z])(?![@$?'])"},{className:"params",begin:/\|(?!=)/,end:/\|/,excludeBegin:!0,excludeEnd:!0,relevance:0,keywords:s},{begin:"("+e.RE_STARTERS_RE+"|unless)\\s*",keywords:"unless",contains:[{className:"regexp",contains:[e.BACKSLASH_ESCAPE,c],illegal:/\n/,variants:[{begin:"/",end:"/[a-z]*"},{begin:/%r\{/,end:/\}[a-z]*/},{begin:"%r\\(",end:"\\)[a-z]*"},{begin:"%r!",end:"![a-z]*"},{begin:"%r\\[",end:"\\][a-z]*"}]}].concat(a,l),relevance:0}].concat(a,l);c.contains=f,h.contains=f;let m=[{begin:/^\s*=>/,starts:{end:"$",contains:f}},{className:"meta.prompt",begin:"^([>?]>|[\\w#]+\\(\\w+\\):\\d+:\\d+[>*]|(\\w+-)?\\d+\\.\\d+\\.\\d+(p\\d+)?[^\\d][^>]+>)(?=[ ])",starts:{end:"$",keywords:s,contains:f}}];return l.unshift(a),{name:"Ruby",aliases:["rb","gemspec","podspec","thor","irb"],keywords:s,illegal:/\/\*/,contains:[e.SHEBANG({binary:"ruby"})].concat(m).concat(l).concat(f)}},rust:xz,scss:function(e){let t={IMPORTANT:{scope:"meta",begin:"!important"},BLOCK_COMMENT:e.C_BLOCK_COMMENT_MODE,HEXCOLOR:{scope:"number",begin:/#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/},FUNCTION_DISPATCH:{className:"built_in",begin:/[\w-]+(?=\()/},ATTRIBUTE_SELECTOR_MODE:{scope:"selector-attr",begin:/\[/,end:/\]/,illegal:"$",contains:[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},CSS_NUMBER_MODE:{scope:"number",begin:e.NUMBER_RE+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",relevance:0},CSS_VARIABLE:{className:"attr",begin:/--[A-Za-z_][A-Za-z0-9_-]*/}},n="@[a-z-]+",r={className:"variable",begin:"(\\$[a-zA-Z-][a-zA-Z0-9_-]*)\\b",relevance:0};return{name:"SCSS",case_insensitive:!0,illegal:"[=/|']",contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,t.CSS_NUMBER_MODE,{className:"selector-id",begin:"#[A-Za-z0-9_-]+",relevance:0},{className:"selector-class",begin:"\\.[A-Za-z0-9_-]+",relevance:0},t.ATTRIBUTE_SELECTOR_MODE,{className:"selector-tag",begin:"\\b("+wo.join("|")+")\\b",relevance:0},{className:"selector-pseudo",begin:":("+wl.join("|")+")"},{className:"selector-pseudo",begin:":(:)?("+wc.join("|")+")"},r,{begin:/\(/,end:/\)/,contains:[t.CSS_NUMBER_MODE]},t.CSS_VARIABLE,{className:"attribute",begin:"\\b("+wd.join("|")+")\\b"},{begin:"\\b(whitespace|wait|w-resize|visible|vertical-text|vertical-ideographic|uppercase|upper-roman|upper-alpha|underline|transparent|top|thin|thick|text|text-top|text-bottom|tb-rl|table-header-group|table-footer-group|sw-resize|super|strict|static|square|solid|small-caps|separate|se-resize|scroll|s-resize|rtl|row-resize|ridge|right|repeat|repeat-y|repeat-x|relative|progress|pointer|overline|outside|outset|oblique|nowrap|not-allowed|normal|none|nw-resize|no-repeat|no-drop|newspaper|ne-resize|n-resize|move|middle|medium|ltr|lr-tb|lowercase|lower-roman|lower-alpha|loose|list-item|line|line-through|line-edge|lighter|left|keep-all|justify|italic|inter-word|inter-ideograph|inside|inset|inline|inline-block|inherit|inactive|ideograph-space|ideograph-parenthesis|ideograph-numeric|ideograph-alpha|horizontal|hidden|help|hand|groove|fixed|ellipsis|e-resize|double|dotted|distribute|distribute-space|distribute-letter|distribute-all-lines|disc|disabled|default|decimal|dashed|crosshair|collapse|col-resize|circle|char|center|capitalize|break-word|break-all|bottom|both|bolder|bold|block|bidi-override|below|baseline|auto|always|all-scroll|absolute|table|table-cell)\\b"},{begin:/:/,end:/[;}{]/,relevance:0,contains:[t.BLOCK_COMMENT,r,t.HEXCOLOR,t.CSS_NUMBER_MODE,e.QUOTE_STRING_MODE,e.APOS_STRING_MODE,t.IMPORTANT,t.FUNCTION_DISPATCH]},{begin:"@(page|font-face)",keywords:{$pattern:n,keyword:"@page @font-face"}},{begin:"@",end:"[{;]",returnBegin:!0,keywords:{$pattern:/[a-z-]+/,keyword:"and or not only",attribute:wa.join(" ")},contains:[{begin:n,className:"keyword"},{begin:/[a-z-]+(?=:)/,className:"attribute"},r,e.QUOTE_STRING_MODE,e.APOS_STRING_MODE,t.HEXCOLOR,t.CSS_NUMBER_MODE]},t.FUNCTION_DISPATCH]}},shell:x$,sql:xB,swift:function(e){let t={match:/\s+/,relevance:0},n=e.COMMENT("/\\*","\\*/",{contains:["self"]}),r=[e.C_LINE_COMMENT_MODE,n],i={match:[/\./,wf(...wg,...wb)],className:{2:"keyword"}},s={match:wh(/\./,wf(...wy)),relevance:0},o=wy.filter(e=>"string"==typeof e).concat(["_|0"]),a={variants:[{className:"keyword",match:wf(...wy.filter(e=>"string"!=typeof e).concat(wx).map(wm),...wb)}]},l={$pattern:wf(/\b\w+/,/#\w+/),keyword:o.concat(wk),literal:wv},c=[i,s,a],d=[{match:wh(/\./,wf(...wN)),relevance:0},{className:"built_in",match:wh(/\b/,wf(...wN),/(?=\()/)}],u={match:/->/,relevance:0},p=[u,{className:"operator",relevance:0,variants:[{match:wj},{match:`\\.(\\.|${wC})+`}]}],h="([0-9]_*)+",f="([0-9a-fA-F]_*)+",m={className:"number",relevance:0,variants:[{match:`\\b(${h})(\\.(${h}))?([eE][+-]?(${h}))?\\b`},{match:`\\b0x(${f})(\\.(${f}))?([pP][+-]?(${h}))?\\b`},{match:/\b0o([0-7]_*)+\b/},{match:/\b0b([01]_*)+\b/}]},g=(e="")=>({className:"subst",variants:[{match:wh(/\\/,e,/[0\\tnr"']/)},{match:wh(/\\/,e,/u\{[0-9a-fA-F]{1,8}\}/)}]}),b=(e="")=>({className:"subst",label:"interpol",begin:wh(/\\/,e,/\(/),end:/\)/}),x=(e="")=>({begin:wh(e,/"""/),end:wh(/"""/,e),contains:[g(e),((e="")=>({className:"subst",match:wh(/\\/,e,/[\t ]*(?:[\r\n]|\r\n)/)}))(e),b(e)]}),y=(e="")=>({begin:wh(e,/"/),end:wh(/"/,e),contains:[g(e),b(e)]}),v={className:"string",variants:[x(),x("#"),x("##"),x("###"),y(),y("#"),y("##"),y("###")]},w=[e.BACKSLASH_ESCAPE,{begin:/\[/,end:/\]/,relevance:0,contains:[e.BACKSLASH_ESCAPE]}],k=e=>{let t=wh(e,/\//),n=wh(/\//,e);return{begin:t,end:n,contains:[...w,{scope:"comment",begin:`#(?!.*${n})`,end:/$/}]}},N={scope:"regexp",variants:[k("###"),k("##"),k("#"),{begin:/\/[^\s](?=[^/\n]*\/)/,end:/\//,contains:w}]},S={match:wh(/`/,wA,/`/)},C=[S,{className:"variable",match:/\$\d+/},{className:"variable",match:`\\$${wM}+`}],j=[{match:/(@|#(un)?)available/,scope:"keyword",starts:{contains:[{begin:/\(/,end:/\)/,keywords:w_,contains:[...p,m,v]}]}},{scope:"keyword",match:wh(/@/,wf(...wO),wp(wf(/\(/,/\s+/)))},{scope:"meta",match:wh(/@/,wA)}],E={match:wp(/\b[A-Z]/),relevance:0,contains:[{className:"type",match:wh(/(AV|CA|CF|CG|CI|CL|CM|CN|CT|MK|MP|MTK|MTL|NS|SCN|SK|UI|WK|XC)/,wM,"+")},{className:"type",match:wT,relevance:0},{match:/[?!]+/,relevance:0},{match:/\.\.\./,relevance:0},{match:wh(/\s+&\s+/,wp(wT)),relevance:0}]},M={begin:/</,end:/>/,keywords:l,contains:[...r,...c,...j,u,E]};E.contains.push(M);let A={begin:/\(/,end:/\)/,relevance:0,keywords:l,contains:["self",{match:wh(wA,/\s*:/),keywords:"_|0",relevance:0},...r,N,...c,...d,...p,m,v,...C,...j,E]},T={begin:/</,end:/>/,keywords:"repeat each",contains:[...r,E]},O={begin:/\(/,end:/\)/,keywords:l,contains:[{begin:wf(wp(wh(wA,/\s*:/)),wp(wh(wA,/\s+/,wA,/\s*:/))),end:/:/,relevance:0,contains:[{className:"keyword",match:/\b_\b/},{className:"params",match:wA}]},...r,...c,...p,m,v,...j,E,A],endsParent:!0,illegal:/["']/},_={match:[/(func|macro)/,/\s+/,wf(S.match,wA,wj)],className:{1:"keyword",3:"title.function"},contains:[T,O,t],illegal:[/\[/,/%/]},D={begin:[/precedencegroup/,/\s+/,wT],className:{1:"keyword",3:"title"},contains:[E],keywords:[...ww,...wv],end:/}/},R={begin:[/(struct|protocol|class|extension|enum|actor)/,/\s+/,wA,/\s*/],beginScope:{1:"keyword",3:"title.class"},keywords:l,contains:[T,...c,{begin:/:/,end:/\{/,keywords:l,contains:[{scope:"title.class.inherited",match:wT},...c],relevance:0}]};for(let e of v.variants){let t=e.contains.find(e=>"interpol"===e.label);t.keywords=l;let n=[...c,...d,...p,m,v,...C];t.contains=[...n,{begin:/\(/,end:/\)/,contains:["self",...n]}]}return{name:"Swift",keywords:l,contains:[...r,_,{match:[/\b(?:subscript|init[?!]?)/,/\s*(?=[<(])/],className:{1:"keyword"},contains:[T,O,t],illegal:/\[|%/},{match:[/class\b/,/\s+/,/func\b/,/\s+/,/\b[A-Za-z_][A-Za-z0-9_]*\b/],scope:{1:"keyword",3:"keyword",5:"title.function"}},{match:[/class\b/,/\s+/,/var\b/],scope:{1:"keyword",3:"keyword"}},R,{match:[/operator/,/\s+/,wj],className:{1:"keyword",3:"title"}},D,{beginKeywords:"import",end:/$/,contains:[...r],relevance:0},N,...c,...d,...p,m,v,...C,...j,E,A]}},typescript:xJ,vbnet:function(e){let t=e.regex,n=/\d{1,2}\/\d{1,2}\/\d{4}/,r=/\d{4}-\d{1,2}-\d{1,2}/,i=/(\d|1[012])(:\d+){0,2} *(AM|PM)/,s=/\d{1,2}(:\d{1,2}){1,2}/,o={className:"literal",variants:[{begin:t.concat(/# */,t.either(r,n),/ *#/)},{begin:t.concat(/# */,s,/ *#/)},{begin:t.concat(/# */,i,/ *#/)},{begin:t.concat(/# */,t.either(r,n),/ +/,t.either(i,s),/ *#/)}]},a=e.COMMENT(/'''/,/$/,{contains:[{className:"doctag",begin:/<\/?/,end:/>/}]}),l=e.COMMENT(null,/$/,{variants:[{begin:/'/},{begin:/([\t ]|^)REM(?=\s)/}]});return{name:"Visual Basic .NET",aliases:["vb"],case_insensitive:!0,classNameAliases:{label:"symbol"},keywords:{keyword:"addhandler alias aggregate ansi as async assembly auto binary by byref byval call case catch class compare const continue custom declare default delegate dim distinct do each equals else elseif end enum erase error event exit explicit finally for friend from function get global goto group handles if implements imports in inherits interface into iterator join key let lib loop me mid module mustinherit mustoverride mybase myclass namespace narrowing new next notinheritable notoverridable of off on operator option optional order overloads overridable overrides paramarray partial preserve private property protected public raiseevent readonly redim removehandler resume return select set shadows shared skip static step stop structure strict sub synclock take text then throw to try unicode until using when where while widening with withevents writeonly yield",built_in:"addressof and andalso await directcast gettype getxmlnamespace is isfalse isnot istrue like mod nameof new not or orelse trycast typeof xor cbool cbyte cchar cdate cdbl cdec cint clng cobj csbyte cshort csng cstr cuint culng cushort",type:"boolean byte char date decimal double integer long object sbyte short single string uinteger ulong ushort",literal:"true false nothing"},illegal:"//|\\{|\\}|endif|gosub|variant|wend|^\\$ ",contains:[{className:"string",begin:/"(""|[^/n])"C\b/},{className:"string",begin:/"/,end:/"/,illegal:/\n/,contains:[{begin:/""/}]},o,{className:"number",relevance:0,variants:[{begin:/\b\d[\d_]*((\.[\d_]+(E[+-]?[\d_]+)?)|(E[+-]?[\d_]+))[RFD@!#]?/},{begin:/\b\d[\d_]*((U?[SIL])|[%&])?/},{begin:/&H[\dA-F_]+((U?[SIL])|[%&])?/},{begin:/&O[0-7_]+((U?[SIL])|[%&])?/},{begin:/&B[01_]+((U?[SIL])|[%&])?/}]},{className:"label",begin:/^\w+:/},a,l,{className:"meta",begin:/[\t ]*#(const|disable|else|elseif|enable|end|externalsource|if|region)\b/,end:/$/,keywords:{keyword:"const disable else elseif enable end externalsource if region then"},contains:[l]}]}},wasm:function(e){e.regex;let t=e.COMMENT(/\(;/,/;\)/);return t.contains.push("self"),{name:"WebAssembly",keywords:{$pattern:/[\w.]+/,keyword:["anyfunc","block","br","br_if","br_table","call","call_indirect","data","drop","elem","else","end","export","func","global.get","global.set","local.get","local.set","local.tee","get_global","get_local","global","if","import","local","loop","memory","memory.grow","memory.size","module","mut","nop","offset","param","result","return","select","set_global","set_local","start","table","tee_local","then","type","unreachable"]},contains:[e.COMMENT(/;;/,/$/),t,{match:[/(?:offset|align)/,/\s*/,/=/],className:{1:"keyword",3:"operator"}},{className:"variable",begin:/\$[\w_]+/},{match:/(\((?!;)|\))+/,className:"punctuation",relevance:0},{begin:[/(?:func|call|call_indirect)/,/\s+/,/\$[^\s)]+/],className:{1:"keyword",3:"title.function"}},e.QUOTE_STRING_MODE,{match:/(i32|i64|f32|f64)(?!\.)/,className:"type"},{className:"keyword",match:/\b(f32|f64|i32|i64)(?:\.(?:abs|add|and|ceil|clz|const|convert_[su]\/i(?:32|64)|copysign|ctz|demote\/f64|div(?:_[su])?|eqz?|extend_[su]\/i32|floor|ge(?:_[su])?|gt(?:_[su])?|le(?:_[su])?|load(?:(?:8|16|32)_[su])?|lt(?:_[su])?|max|min|mul|nearest|neg?|or|popcnt|promote\/f32|reinterpret\/[fi](?:32|64)|rem_[su]|rot[lr]|shl|shr_[su]|store(?:8|16|32)?|sqrt|sub|trunc(?:_[su]\/f(?:32|64))?|wrap\/i64|xor))\b/},{className:"number",relevance:0,match:/[+-]?\b(?:\d(?:_?\d)*(?:\.\d(?:_?\d)*)?(?:[eE][+-]?\d(?:_?\d)*)?|0x[\da-fA-F](?:_?[\da-fA-F])*(?:\.[\da-fA-F](?:_?[\da-fA-D])*)?(?:[pP][+-]?\d(?:_?\d)*)?)\b|\binf\b|\bnan(?::0x[\da-fA-F](?:_?[\da-fA-D])*)?\b/}]}},xml:xZ,yaml:xX},wR=x1(wD);function wI(e){return Array.isArray(e)?e.join(""):e??""}let wL=/\x1b\[[0-9;]*[A-Za-z]/g;function wP(e){return e.replace(wL,"")}function wz({output:e}){if("stream"===e.output_type){let t=wP(wI(e.text)),n="stderr"===e.name;return(0,s.jsx)("pre",{className:`whitespace-pre-wrap font-mono text-[12.5px] leading-relaxed px-4 py-3 rounded-md ${n?"bg-[rgba(139,46,62,0.06)] text-[#8B2E3E]":"bg-[#F5EEDC] text-[#2A221B]"}`,children:t})}if("error"===e.output_type){let t=e.traceback.map(wP).join("\n");return(0,s.jsxs)("pre",{className:"whitespace-pre-wrap font-mono text-[12.5px] leading-relaxed px-4 py-3 rounded-md bg-[rgba(139,46,62,0.08)] text-[#8B2E3E] border border-[rgba(139,46,62,0.18)]",children:[(0,s.jsxs)("span",{className:"font-semibold",children:[e.ename,": ",e.evalue]}),t?`
|
|
169
|
+
|
|
170
|
+
${t}`:""]})}let t=e.data||{};if(t["image/png"]){let e=`data:image/png;base64,${wI(t["image/png"]).replace(/\s/g,"")}`;return(0,s.jsx)("img",{src:e,alt:"output",className:"max-w-full rounded-md bg-card p-2"})}if(t["image/jpeg"]){let e=`data:image/jpeg;base64,${wI(t["image/jpeg"]).replace(/\s/g,"")}`;return(0,s.jsx)("img",{src:e,alt:"output",className:"max-w-full rounded-md bg-card p-2"})}if(t["image/svg+xml"]){let e=wI(t["image/svg+xml"]);return(0,s.jsx)("div",{className:"max-w-full rounded-md bg-card p-2 overflow-auto",dangerouslySetInnerHTML:{__html:e}})}if(t["text/html"]){let e=wI(t["text/html"]);return(0,s.jsx)("iframe",{srcDoc:`<!doctype html><html><head><base target="_blank"><style>body{margin:0;padding:8px;font-family:-apple-system,BlinkMacSystemFont,Inter,system-ui,sans-serif;background:#FFF9E9;color:#2A221B;font-size:13px}table{border-collapse:collapse}th,td{border:1px solid #D4C4B0;padding:4px 8px;text-align:left}thead{background:#EFE5CC}</style></head><body>${e}</body></html>`,sandbox:"allow-scripts",className:"w-full bg-[#FFF9E9] rounded-md border border-[#E8DDC5]",style:{height:360}})}return t["text/plain"]?(0,s.jsx)("pre",{className:"whitespace-pre-wrap font-mono text-[12.5px] leading-relaxed px-4 py-3 rounded-md bg-[#F5EEDC] text-[#2A221B]",children:wP(wI(t["text/plain"]))}):null}function w$({cell:e,language:t}){let n=wI(e.source),r=(0,f.useMemo)(()=>(function(e,t){try{let n=t?wR.highlight(t,e):wR.highlightAuto(e);return(0,v1.toHtml)(n)}catch{return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}})(n,t),[n,t]),i=e.execution_count??" ",o=(e.outputs?.length??0)>0;return(0,s.jsxs)("div",{className:"grid grid-cols-[60px_1fr] gap-3 mb-5",children:[(0,s.jsxs)("div",{className:"text-right pt-3 select-none font-mono text-[11px] text-[#8B5E3C]",children:["In [",i,"]:"]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("pre",{className:"whitespace-pre overflow-x-auto font-mono text-[13px] leading-relaxed px-4 py-3 rounded-md bg-[#FFF9E9] border border-[#E8DDC5] text-[#2A221B]",children:(0,s.jsx)("code",{dangerouslySetInnerHTML:{__html:r}})}),o&&(0,s.jsxs)("div",{className:"mt-2 grid grid-cols-[60px_1fr] gap-3",children:[(0,s.jsxs)("div",{className:"text-right pt-3 select-none font-mono text-[11px] text-[#8B2E3E]",children:["Out[",i,"]:"]}),(0,s.jsx)("div",{className:"space-y-2",children:e.outputs?.map((e,t)=>(0,s.jsx)(wz,{output:e},t))})]})]})]})}function wB({cell:e}){let[t,n]=(0,f.useState)("");return(0,f.useEffect)(()=>{let t=!1;return(0,hN.markdownToHtml)(wI(e.source)).then(e=>{t||n(e)}),()=>{t=!0}},[e.source]),(0,s.jsx)("div",{className:"prose prose-sm max-w-none mb-5 px-1 [&_h1]:font-serif [&_h2]:font-serif [&_h3]:font-serif [&_a]:text-[#8B5E3C] [&_a:hover]:underline [&_code]:bg-[#F5EEDC] [&_code]:px-1.5 [&_code]:py-0.5 [&_code]:rounded [&_code]:text-[#8B2E3E]",dangerouslySetInnerHTML:{__html:t}})}function wF({cell:e}){return(0,s.jsx)("pre",{className:"whitespace-pre-wrap font-mono text-[12.5px] leading-relaxed px-4 py-3 rounded-md bg-[#F5EEDC] text-[#2A221B] mb-5",children:wI(e.source)})}function wH({path:e}){let[t,n]=(0,f.useState)(null),[r,i]=(0,f.useState)(!0),[o,a]=(0,f.useState)(null),[l,c]=(0,f.useState)(!1),d=(0,tC.withWs)(`/api/assets/${e}`),u=e.split("/").pop()||e,p=(0,f.useCallback)(async()=>{i(!0),a(null);try{let e=await (0,tC.wsFetch)(d);if(!e.ok)throw Error(`HTTP ${e.status}`);let t=await e.json();n(t)}catch(e){a(e instanceof Error?e.message:"Failed to load notebook")}finally{i(!1)}},[d]);(0,f.useEffect)(()=>{p()},[p]);let h=t?.metadata?.language_info?.name||t?.metadata?.kernelspec?.name||"python",b=t?.cells?.length??0,x=t?.cells?.filter(e=>"code"===e.cell_type).length??0,y=t?.cells?.some(e=>"code"===e.cell_type&&(e.outputs?.length??0)>0)??!1;return(0,s.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,s.jsxs)(ii.ViewerToolbar,{path:e,badge:"IPYNB",sublabel:`${b} cells \xb7 ${x} code \xb7 ${h}`,children:[(0,s.jsxs)(v.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>{navigator.clipboard.writeText(`jupyter lab ${e}`),c(!0),setTimeout(()=>c(!1),2e3)},title:"Copy: jupyter lab <path>",children:[l?(0,s.jsx)(g.Check,{className:"h-3.5 w-3.5 text-green-500"}):(0,s.jsx)(tt.Copy,{className:"h-3.5 w-3.5"}),l?"Copied":"Copy run cmd"]}),(0,s.jsxs)(v.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>{let e=document.createElement("a");e.href=d,e.download=u,e.click()},children:[(0,s.jsx)(t7.Download,{className:"h-3.5 w-3.5"}),"Download"]}),(0,s.jsxs)(v.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>window.open(d,"_blank"),children:[(0,s.jsx)(tM.ExternalLink,{className:"h-3.5 w-3.5"}),"Raw JSON"]})]}),(0,s.jsx)("div",{className:"flex-1 overflow-auto bg-[#F5EEDC]",children:r?(0,s.jsx)("div",{className:"flex items-center justify-center h-full text-[#7A6B5D] text-sm",children:"Loading notebook…"}):o?(0,s.jsxs)("div",{className:"flex items-center justify-center h-full text-[#8B2E3E] text-sm gap-2",children:[(0,s.jsx)(m.AlertCircle,{className:"h-4 w-4"})," ",o]}):t?(0,s.jsxs)("div",{className:"max-w-[1100px] mx-auto py-8 px-6",children:[!y&&x>0&&(0,s.jsxs)("div",{className:"mb-6 rounded-md border border-[#E8DDC5] bg-[#FFF9E9] px-4 py-3 text-[13px] text-[#7A6B5D]",children:[(0,s.jsx)("span",{className:"font-semibold text-[#0c0a09]",children:"This notebook hasn't been run yet."})," ","Code and markdown cells display below; outputs appear once the author runs the notebook in Jupyter (or you do, then re-save)."]}),t.cells?.map((e,t)=>"markdown"===e.cell_type?(0,s.jsx)(wB,{cell:e},t):"raw"===e.cell_type?(0,s.jsx)(wF,{cell:e},t):(0,s.jsx)(w$,{cell:e,language:h},t))]}):null})]})}function wU({path:e,extLabel:t,external:n,hideFinder:r}){let i=(0,tC.withWs)(`/api/assets/${e}`),o=e.split("/").pop()||e,a=async()=>{try{await (0,tC.wsFetch)("/api/system/reveal",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e})})}catch{}};return(0,s.jsxs)(ii.ViewerToolbar,{path:e,badge:t||void 0,children:[n&&(0,s.jsxs)("a",{href:n.href,target:"_blank",rel:"noreferrer noopener",className:"inline-flex items-center gap-1.5 text-[11px] h-7 px-2.5 rounded-md border border-border hover:bg-accent transition-colors",children:[(0,s.jsx)(tM.ExternalLink,{className:"h-3.5 w-3.5"}),n.label]}),!r&&(0,s.jsxs)(v.Button,{variant:"outline",size:"sm",className:"gap-1.5 text-[11px] h-7",onClick:a,title:"Open in Finder",children:[(0,s.jsx)(e3,{className:"h-3.5 w-3.5"}),"Reveal"]}),!r&&(0,s.jsxs)(v.Button,{variant:"outline",size:"sm",className:"gap-1.5 text-[11px] h-7",onClick:()=>{let e=document.createElement("a");e.href=i,e.download=o,e.click()},title:"Download original",children:[(0,s.jsx)(t7.Download,{className:"h-3.5 w-3.5"}),"Download"]})]})}function wV({path:t,title:n}){let r=(0,f.useRef)(null),[i,o]=(0,f.useState)(!0),[a,l]=(0,f.useState)(null);return(0,f.useEffect)(()=>{let n=!1,i=r.current;if(i)return i.innerHTML="",(async()=>{o(!0),l(null);try{let[{renderAsync:r},s]=await Promise.all([e.A(410052),(0,tC.wsFetch)(`/api/assets/${t}`)]);if(n)return;if(!s.ok)throw Error(`Failed to load file (${s.status})`);let a=await s.blob();if(n)return;await r(a,i,void 0,{className:"docx-rendered",inWrapper:!0,ignoreWidth:!1,ignoreHeight:!1,breakPages:!0,renderHeaders:!0,renderFooters:!0,renderFootnotes:!0,experimental:!0,useBase64URL:!0}),n||o(!1)}catch(e){n||(l(e instanceof Error?e.message:"Failed to render document"),o(!1))}})(),()=>{n=!0}},[t]),(0,s.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,s.jsx)(wU,{path:t,title:n,extLabel:"DOCX"}),(0,s.jsxs)("div",{className:"flex-1 overflow-y-auto bg-muted/30",children:[i&&!a&&(0,s.jsxs)("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:[(0,s.jsx)(u.Loader2,{className:"h-5 w-5 animate-spin mr-2"}),"Rendering document…"]}),a&&(0,s.jsx)("div",{className:"h-full flex items-center justify-center",children:(0,s.jsxs)("div",{className:"text-center space-y-2",children:[(0,s.jsx)("p",{className:"text-sm text-destructive",children:a}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:"Try downloading the file and opening it externally."})]})}),(0,s.jsx)("div",{ref:r,className:"docx-viewer-body mx-auto max-w-5xl py-6 px-4"})]})]})}function wW({path:t,title:n}){let r=(0,f.useRef)(null),[i,o]=(0,f.useState)(!0),[a,l]=(0,f.useState)(null);return(0,f.useEffect)(()=>{let n=!1,i=r.current;if(!i)return;i.innerHTML="";let s=null;return(async()=>{o(!0),l(null);try{let[{init:r},a]=await Promise.all([e.A(355350),(0,tC.wsFetch)(`/api/assets/${t}`)]);if(n)return;if(!a.ok)throw Error(`Failed to load file (${a.status})`);let l=await a.arrayBuffer();if(n)return;let c=i.clientWidth||960,d=Math.round(9*c/16);s=r(i,{width:c,height:d,mode:"list"}),await s.preview(l),n||o(!1)}catch(e){n||(l(e instanceof Error?e.message:"Failed to render presentation"),o(!1))}})(),()=>{n=!0;try{s?.destroy?.()}catch{}}},[t]),(0,s.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,s.jsx)(wU,{path:t,title:n,extLabel:"PPTX"}),(0,s.jsxs)("div",{className:"flex-1 overflow-auto bg-muted/30 py-4",children:[i&&!a&&(0,s.jsxs)("div",{className:"h-[60vh] flex items-center justify-center text-muted-foreground",children:[(0,s.jsx)(u.Loader2,{className:"h-5 w-5 animate-spin mr-2"}),"Rendering slides…"]}),a&&(0,s.jsx)("div",{className:"h-[60vh] flex items-center justify-center",children:(0,s.jsxs)("div",{className:"text-center space-y-2",children:[(0,s.jsx)("p",{className:"text-sm text-destructive",children:a}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:"Try downloading the file and opening it externally."})]})}),(0,s.jsx)("div",{ref:r,className:"pptx-viewer-body mx-auto max-w-5xl px-4"})]})]})}function wq({path:t,title:n}){let[r,i]=(0,f.useState)(null),[o,a]=(0,f.useState)(0),[l,c]=(0,f.useState)(!0),[d,p]=(0,f.useState)(null),h=(0,f.useRef)(null);(0,f.useEffect)(()=>{if(!r||!h.current)return;let e=r[o];if(!e||null!==e.html)return;let{wb:t,toHtml:n}=h.current,s=n(t.Sheets[e.name]);i(e=>{if(!e)return e;let t=[...e];return t[o]={...t[o],html:s.html,rows:s.rows,truncated:s.truncated},t})},[r,o]),(0,f.useEffect)(()=>{let n=!1;return c(!0),p(null),i(null),(async()=>{try{let[r,s]=await Promise.all([e.A(432302),(0,tC.wsFetch)(`/api/assets/${t}`)]);if(n)return;if(!s.ok)throw Error(`Failed to load file (${s.status})`);let o=await s.arrayBuffer();if(n)return;let l=r.read(o,{type:"array",cellDates:!0,cellStyles:!0});if(n)return;h.current={wb:l,toHtml:e=>{let t=e["!ref"],n=t?r.utils.decode_range(t):null,i=n?n.e.r-n.s.r+1:0;if(!n||i<=2e3)return{html:r.utils.sheet_to_html(e,{editable:!1}),rows:i,truncated:!1};let s={...e,"!ref":r.utils.encode_range({s:n.s,e:{r:n.s.r+2e3-1,c:n.e.c}})};return{html:r.utils.sheet_to_html(s,{editable:!1}),rows:i,truncated:!0}}},i(l.SheetNames.map(e=>({name:e,html:null,rows:0,truncated:!1}))),a(0),c(!1)}catch(e){n||(p(e instanceof Error?e.message:"Failed to parse spreadsheet"),c(!1))}})(),()=>{n=!0}},[t]);let m=(0,f.useMemo)(()=>r?.[o]??null,[r,o]);return(0,s.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,s.jsx)(wU,{path:t,title:n,extLabel:"XLSX"}),r&&r.length>1&&(0,s.jsx)("div",{className:"flex items-center gap-0.5 border-b border-border bg-muted/40 px-2 overflow-x-auto scrollbar-none",children:r.map((e,t)=>(0,s.jsx)("button",{type:"button",onClick:()=>a(t),className:(0,eh.cn)("px-3 py-1.5 text-[12px] rounded-t whitespace-nowrap transition-colors",t===o?"bg-background text-foreground font-medium border-t border-x border-border -mb-px":"text-muted-foreground hover:text-foreground"),children:e.name},e.name+t))}),(0,s.jsxs)("div",{className:"flex-1 overflow-auto",children:[l&&!d&&(0,s.jsxs)("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:[(0,s.jsx)(u.Loader2,{className:"h-5 w-5 animate-spin mr-2"}),"Parsing spreadsheet…"]}),d&&(0,s.jsx)("div",{className:"h-full flex items-center justify-center",children:(0,s.jsxs)("div",{className:"text-center space-y-2",children:[(0,s.jsx)("p",{className:"text-sm text-destructive",children:d}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:"Try downloading the file and opening it externally."})]})}),m?.truncated&&(0,s.jsxs)("div",{className:"px-3 py-2 text-[11px] text-amber-600 dark:text-amber-400 border-b border-border",children:["Large sheet (",m.rows.toLocaleString()," rows). Showing first"," ",2e3.toLocaleString()," for performance. Download the file to see everything."]}),m?.html!=null&&(0,s.jsx)("div",{className:"xlsx-sheet p-3 text-[12px]",dangerouslySetInnerHTML:{__html:m.html}})]})]})}let wK=(0,o.default)("wrap-text",[["path",{d:"m16 16-2 2 2 2",key:"kkc6pm"}],["path",{d:"M3 12h15a3 3 0 1 1 0 6h-4",key:"1cl7v7"}],["path",{d:"M3 18h7",key:"sq21v6"}],["path",{d:"M3 6h18",key:"d0wm0j"}]]),wG=x1(wD);function wJ(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function wZ(e){return`${e.lineStart}:${e.lineEnd}:${e.textHash}`}function wX(e){return`L${e.lineStart}-${e.lineEnd}`}async function wY(e){return Array.from(new Uint8Array(await crypto.subtle.digest("SHA-256",new TextEncoder().encode(e)))).map(e=>e.toString(16).padStart(2,"0")).join("").slice(0,12)}let wQ={".js":"javascript",".cjs":"javascript",".mjs":"javascript",".ts":"typescript",".tsx":"typescript",".jsx":"javascript",".py":"python",".rb":"ruby",".php":"php",".sh":"bash",".bash":"bash",".zsh":"bash",".ps1":"powershell",".css":"css",".scss":"scss",".html":"xml",".json":"json",".jsonc":"json",".yaml":"yaml",".yml":"yaml",".toml":"ini",".ini":"ini",".xml":"xml",".sql":"sql",".graphql":"graphql",".gql":"graphql",".go":"go",".rs":"rust",".swift":"swift",".java":"java",".kt":"kotlin",".kts":"kotlin",".c":"c",".cpp":"cpp",".h":"c",".env":"bash",".txt":"",".text":"",".log":"",".rst":"",".mdx":"markdown"};function w0({path:e}){let[t,n]=(0,f.useState)(null),[r,i]=(0,f.useState)(0),[o,a]=(0,f.useState)(!1),[l,c]=(0,f.useState)(!0),[d,u]=(0,f.useState)(!1),[p,h]=(0,f.useState)(!1),[m,b]=(0,f.useState)(2e3),[x,y]=(0,f.useState)(new Map),[w,k]=(0,f.useState)(null),N=(0,f.useRef)(null),S=(0,tC.withWs)(`/api/assets/${e}`),C=e.split("/").pop()||e,j=wQ[C.includes(".")?`.${C.split(".").pop()?.toLowerCase()}`:""]??"",E=fd(t=>t.byPath[e]?.sidecar??null),M=E?.comments??[],A=(0,f.useMemo)(()=>t?t.replace(/\r\n/g,"\n").split("\n"):[],[t]),T=(0,f.useCallback)(async()=>{c(!0),a(!1),n(null),i(0);try{let e=await (0,tC.wsFetch)(S);if(e.ok){let t=new Uint8Array(await e.arrayBuffer());!function(e){let t=Math.min(e.length,8192);if(0===t)return!1;let n=0;for(let r=0;r<t;r++){let t=e[r];if(0===t)return!0;(t<9||t>13&&t<32)&&n++}return n/t>.3}(t)?(i(t.length),n(new TextDecoder("utf-8").decode(t))):a(!0)}}catch{}finally{c(!1)}},[S]);(0,f.useEffect)(()=>{T(),fd.getState().loadSidecar(e),b(2e3),k(null)},[T,e]);let O=(0,f.useMemo)(()=>A.length,[A]),_=r>2097152||O>5e3,D=(0,f.useMemo)(()=>{if(!t)return[];if(_)return A.map(wJ);try{let e=j?wG.highlight(j,t):wG.highlightAuto(t);return(0,v1.toHtml)(e).split("\n")}catch{return A.map(wJ)}},[t,j,_,A]),R=_?D.slice(0,m):D,I=_&&m<D.length,L=(0,f.useMemo)(()=>{let e={};for(let t of M){if(!t.lineAnchor)continue;let n=wZ(t.lineAnchor);(e[n]??=[]).push(t)}return e},[M]);(0,f.useEffect)(()=>{if(!t||o||l||!N.current)return void y(new Map);let e=N.current,n=e.getBoundingClientRect(),r=Array.from(e.querySelectorAll("[data-line]")),i=new Map;for(let t of r){let r=Number(t.dataset.line);if(!Number.isFinite(r))continue;let s=t.getBoundingClientRect();i.set(r,{top:s.top-n.top+e.scrollTop,left:s.left-n.left,width:s.width,bottom:s.bottom-n.top+e.scrollTop})}y(i)},[t,o,l,m,d,D]);let P=(0,f.useCallback)(()=>{let e=N.current,t=window.getSelection();if(!e||!t||t.isCollapsed||0===t.rangeCount)return;let n=t.getRangeAt(0);if(!e.contains(n.commonAncestorContainer))return;let r=e=>{let t=e?e.nodeType===Node.ELEMENT_NODE?e:e.parentElement:null;return t?.closest("[data-line]")??null},i=r(n.startContainer),s=r(n.endContainer);if(!i||!s)return;let o=Number(i.dataset.line),a=Number(s.dataset.line);if(!Number.isFinite(o)||!Number.isFinite(a))return;let l=Math.min(o,a),c=Math.max(o,a),d=A.slice(l-1,c).join("\n");(async()=>{let e={lineStart:l,lineEnd:c,textHash:await wY(d)};k({anchorKey:wZ(e),anchorLabel:wX(e),lineAnchor:e,anchorEl:i})})()},[A]),z=(0,f.useCallback)((e,t)=>{k({anchorKey:wZ(e),anchorLabel:wX(e),lineAnchor:e,anchorEl:t})},[]);return o?(0,s.jsx)(vJ,{path:e,title:C}):(0,s.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,s.jsxs)(ii.ViewerToolbar,{path:e,badge:C.includes(".")?C.split(".").pop()?.toUpperCase()??"TEXT":"TEXT",children:[(0,s.jsxs)(v.Button,{variant:"ghost",size:"sm",className:`h-7 gap-1.5 text-xs ${d?"bg-muted":""}`,onClick:()=>u(e=>!e),title:d?"Disable line wrap":"Enable line wrap",children:[(0,s.jsx)(wK,{className:"h-3.5 w-3.5"}),"Wrap"]}),(0,s.jsxs)(v.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>{t&&(navigator.clipboard.writeText(t),h(!0),setTimeout(()=>h(!1),2e3))},title:"Copy file contents",children:[p?(0,s.jsx)(g.Check,{className:"h-3.5 w-3.5 text-green-500"}):(0,s.jsx)(tt.Copy,{className:"h-3.5 w-3.5"}),p?"Copied":"Copy"]}),(0,s.jsxs)(v.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>{let e=document.createElement("a");e.href=S,e.download=C,e.click()},title:"Download file",children:[(0,s.jsx)(t7.Download,{className:"h-3.5 w-3.5"}),"Download"]}),(0,s.jsxs)(v.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>window.open(S,"_blank"),children:[(0,s.jsx)(tM.ExternalLink,{className:"h-3.5 w-3.5"}),"Raw"]})]}),(0,s.jsxs)("div",{ref:N,className:"relative flex-1 overflow-auto source-viewer-code bg-background",children:[!l&&t&&!o&&(0,s.jsx)(vq,{containerRef:N,onComment:P,align:"left"}),(0,s.jsx)("div",{className:"relative pointer-events-none",style:{height:0},children:Object.entries(L).map(([e,t])=>{let n=t[0]?.lineAnchor;if(!n)return null;let r=x.get(n.lineStart);return r?(0,s.jsx)("div",{style:{pointerEvents:"auto"},children:(0,s.jsx)(yT,{anchorKey:e,anchorLabel:wX(n),comments:t,top:r.top+4,left:Math.max(0,r.left-20),onClick:()=>{let e=N.current?.querySelector(`[data-line="${n.lineStart}"]`);e&&z(n,e)}})},`pip-${e}`):null})}),l?(0,s.jsx)("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:"Loading..."}):(0,s.jsxs)(s.Fragment,{children:[_&&(0,s.jsxs)("div",{className:"px-4 py-2 text-[11px] text-amber-700 dark:text-amber-300 bg-amber-500/15 border-b border-amber-500/30 font-sans",children:["Large file (",(r/1048576).toFixed(1)," MB, ",D.length.toLocaleString()," lines). Syntax highlighting disabled for performance. Use Raw or Download for the full file."]}),(0,s.jsx)("div",{className:"text-[13px] leading-relaxed font-mono min-w-max",children:R.map((e,t)=>{let n=w?.lineAnchor,r=n&&t+1>=n.lineStart&&t+1<=n.lineEnd;return(0,s.jsxs)("div",{"data-line":t+1,className:`flex ${r?"bg-amber-400/25":"hover:bg-foreground/5"}`,children:[(0,s.jsx)("span",{className:"w-12 shrink-0 pr-4 text-right text-muted-foreground select-none sticky left-0 bg-muted",children:t+1}),(0,s.jsx)("span",{className:`text-foreground pl-2 ${d?"whitespace-pre-wrap break-all":"whitespace-pre"}`,dangerouslySetInnerHTML:{__html:e||" "}})]},t)})}),I&&(0,s.jsxs)("div",{className:"flex items-center gap-3 px-4 py-3 border-t border-border font-sans",children:[(0,s.jsxs)("button",{onClick:()=>b(e=>e+2e3),className:"text-[11px] text-foreground hover:text-foreground px-2.5 py-1 rounded bg-foreground/10 hover:bg-foreground/20 transition-colors",children:["Show ",Math.min(2e3,D.length-m).toLocaleString()," more"]}),(0,s.jsxs)("span",{className:"text-[11px] text-muted-foreground",children:[m.toLocaleString()," / ",D.length.toLocaleString()," lines"]})]})]}),w&&(0,s.jsx)(y3,{path:e,anchorKey:w.anchorKey,anchorLabel:w.anchorLabel,lineAnchor:w.lineAnchor,comments:L[w.anchorKey]??[],anchorEl:w.anchorEl,onClose:()=>k(null)})]})]})}var w1=e.i(727551),w2=e.i(496366);function w3({path:e,title:t,src:n,fullscreen:r,onExit:i,scriptsEnabled:o,onToggleScripts:a}){let[l,c]=(0,f.useState)(!1),d=o??l,u=(0,tC.withWs)(n??`/api/assets/${e}/index.html`),p=r&&i?(0,s.jsxs)(v.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:i,title:"Exit app",children:[(0,s.jsx)(vT,{className:"h-3.5 w-3.5"}),"Exit app"]}):null;return(0,s.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,s.jsxs)(ii.ViewerToolbar,{path:e,badge:r?"App":void 0,showBreadcrumb:!r,leading:r?(0,s.jsxs)(s.Fragment,{children:[p,(0,s.jsx)("span",{className:"truncate text-[13px] font-medium text-foreground",children:t})]}):null,children:[(0,s.jsx)(v.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:a??(()=>c(e=>!e)),title:d?"Disable scripts (recommended for untrusted content)":"Enable scripts",children:d?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(w2.Ban,{className:"h-3.5 w-3.5"}),"Disable scripts"]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(w1.Play,{className:"h-3.5 w-3.5"}),"Enable scripts"]})}),(0,s.jsxs)(v.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>window.open(u,"_blank"),children:[(0,s.jsx)(tM.ExternalLink,{className:"h-3.5 w-3.5"}),"Open in new tab"]})]}),(0,s.jsx)("iframe",{src:u,className:"flex-1 w-full border-0 bg-card",title:t,sandbox:d?"allow-scripts allow-forms allow-popups allow-top-navigation-by-user-activation":"allow-forms allow-popups allow-top-navigation-by-user-activation"})]})}let w5=(0,o.default)("square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]),w4={stopped:"Stopped",installing:"Installing dependencies…",starting:"Starting…",running:"Running",error:"Error"};function w6({path:e,title:t}){let[n,r]=(0,f.useState)("stopped"),[i,o]=(0,f.useState)(null),[a,l]=(0,f.useState)([]),[c,d]=(0,f.useState)(null),[p,h]=(0,f.useState)(!1),[g,x]=(0,f.useState)(0),[y,w]=(0,f.useState)([]),[k,N]=(0,f.useState)(null),S=(0,f.useRef)(null),C=(0,f.useRef)(null),j=(0,tC.withWs)(`/api/app-proxy/${e}/`),E=()=>{S.current&&(clearInterval(S.current),S.current=null)},M=(0,f.useCallback)(async()=>{try{let t=await (0,tC.wsFetch)(`/api/wiki/app?path=${encodeURIComponent(e)}`);if(!t.ok)return;let n=await t.json();r(n.status),l(n.logs??[]),n.scripts&&w(n.scripts),void 0!==n.defaultScript&&N(n.defaultScript),n.port&&o(n.port),n.error&&d(n.error),("running"===n.status||"stopped"===n.status||"error"===n.status)&&E()}catch{}},[e]);(0,f.useEffect)(()=>("installing"===n||"starting"===n?S.current||(S.current=setInterval(M,800)):E(),E),[n,M]),(0,f.useEffect)(()=>{C.current?.scrollIntoView({behavior:"smooth"})},[a]),(0,f.useEffect)(()=>{M()},[M]);let A=async t=>{d(null),l([]),r("starting");try{let n=await (0,tC.wsFetch)("/api/wiki/app",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e,script:t})}),i=await n.json();if(!n.ok||i.error){r("error"),d(i.error??"Failed to start");return}i.port&&o(i.port),await M()}catch(e){r("error"),d(String(e))}},T=async()=>{await (0,tC.wsFetch)("/api/wiki/app",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e})}),r("stopped"),o(null)},O=async()=>{await T(),await A(),x(e=>e+1)},_=y.filter(e=>e!==k);return(0,s.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,s.jsxs)(ii.ViewerToolbar,{path:e,badge:"Node app",children:["running"===n&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(v.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>x(e=>e+1),children:[(0,s.jsx)(t_,{className:"h-3.5 w-3.5"}),"Refresh"]}),(0,s.jsxs)(v.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>window.open(j,"_blank"),children:[(0,s.jsx)(tM.ExternalLink,{className:"h-3.5 w-3.5"}),"Open in new tab"]}),(0,s.jsxs)(v.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:O,children:[(0,s.jsx)(t_,{className:"h-3.5 w-3.5"}),"Restart"]}),(0,s.jsxs)(v.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs text-destructive hover:text-destructive",onClick:T,children:[(0,s.jsx)(w5,{className:"h-3.5 w-3.5"}),"Stop"]})]}),(0,s.jsxs)(v.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>h(e=>!e),children:[(0,s.jsx)(ni,{className:"h-3.5 w-3.5"}),"Logs"]})]}),p&&(0,s.jsxs)("div",{className:"border-b bg-black/90 text-green-400 font-mono text-xs h-40 overflow-auto p-2 shrink-0",children:[0===a.length?(0,s.jsx)("span",{className:"text-muted-foreground",children:"No output yet."}):a.map((e,t)=>(0,s.jsx)("div",{className:"whitespace-pre-wrap leading-5",children:e},t)),(0,s.jsx)("div",{ref:C})]}),(0,s.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:["stopped"===n&&(0,s.jsxs)("div",{className:"flex-1 flex flex-col items-center justify-center gap-4",children:[(0,s.jsxs)("div",{className:"text-center space-y-1",children:[(0,s.jsx)("p",{className:"text-sm font-medium",children:t}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:"Node.js app — will be started on a local port"})]}),(0,s.jsxs)("div",{className:"inline-flex items-stretch overflow-hidden rounded-full bg-primary text-primary-foreground shadow-e-1",children:[(0,s.jsxs)("button",{type:"button",onClick:()=>A(),className:"inline-flex items-center gap-2 px-4 py-2.5 text-sm font-medium transition-colors hover:bg-primary-foreground/10 focus-visible:outline-none",children:[(0,s.jsx)(w1.Play,{className:"h-4 w-4"}),"Launch app",k&&(0,s.jsxs)("span",{className:"opacity-70",children:["(",k,")"]})]}),_.length>0&&(0,s.jsxs)(ek.DropdownMenu,{children:[(0,s.jsx)(ek.DropdownMenuTrigger,{asChild:!0,children:(0,s.jsx)("button",{type:"button",className:"inline-flex items-center justify-center border-l border-l-primary-foreground/20 px-2 transition-colors hover:bg-primary-foreground/10 focus-visible:outline-none","aria-label":"Choose script to launch",children:(0,s.jsx)(b,{className:"h-4 w-4"})})}),(0,s.jsxs)(ek.DropdownMenuContent,{align:"end",children:[(0,s.jsx)(ek.DropdownMenuLabel,{children:"Run script"}),(0,s.jsx)(ek.DropdownMenuSeparator,{}),y.map(e=>(0,s.jsxs)(ek.DropdownMenuItem,{onSelect:()=>A(e),className:"gap-2 font-mono text-xs",children:[(0,s.jsx)(w1.Play,{className:"h-3.5 w-3.5"}),e,e===k&&(0,s.jsx)("span",{className:"ml-auto text-[10px] text-muted-foreground",children:"default"})]},e))]})]})]})]}),("installing"===n||"starting"===n)&&(0,s.jsxs)("div",{className:"flex-1 flex flex-col items-center justify-center gap-3",children:[(0,s.jsx)(u.Loader2,{className:"h-6 w-6 animate-spin text-muted-foreground"}),(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:w4[n]}),i&&(0,s.jsxs)("p",{className:"text-xs text-muted-foreground/60",children:["port ",i]}),(0,s.jsxs)(v.Button,{onClick:T,variant:"outline",size:"sm",className:"gap-2",children:[(0,s.jsx)(w5,{className:"h-3.5 w-3.5"}),"Cancel"]})]}),"error"===n&&(0,s.jsxs)("div",{className:"flex-1 flex flex-col items-center justify-center gap-4 p-6",children:[(0,s.jsx)(m.AlertCircle,{className:"h-8 w-8 text-destructive"}),(0,s.jsxs)("div",{className:"text-center space-y-1 max-w-md",children:[(0,s.jsx)("p",{className:"text-sm font-medium text-destructive",children:"Failed to start app"}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground break-words",children:c??"Unknown error"})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(v.Button,{onClick:T,variant:"ghost",className:"gap-2",children:"Back"}),(0,s.jsxs)(v.Button,{onClick:O,variant:"outline",className:"gap-2",children:[(0,s.jsx)(t_,{className:"h-4 w-4"}),"Try again"]})]})]}),"running"===n&&(0,s.jsx)("iframe",{src:j,className:"flex-1 w-full border-0 bg-card",title:t,sandbox:"allow-scripts allow-same-origin allow-forms allow-popups allow-modals allow-top-navigation-by-user-activation"},g)]})]})}let w9=(0,it.default)(()=>e.A(810497).then(e=>e.PdfViewer),{loadableGenerated:{modules:[904378]},ssr:!1});function w7(e){let t=new Date(e).getTime();if(!Number.isFinite(t))return"";let n=Math.floor(Math.max(0,Date.now()-t)/1e3);if(n<60)return"just now";let r=Math.floor(n/60);if(r<60)return`${r}m ago`;let i=Math.floor(r/60);return i<24?`${i}h ago`:`${Math.floor(i/24)}d ago`}let w8=new Set(["image","media","pdf","fallback","app","node-app","html"]);function ke({openFile:e,fileContent:t,fileLoading:n,editing:r,setEditing:i,editContent:o,setEditContent:a,saving:p,saveError:m,onSave:b,gitFileInfo:x,showHistory:y,historyLoading:w,historyCommits:k,selectedDiffSha:N,diffContent:S,diffLoading:C,onToggleHistory:j,onSelectDiff:E,gateBypassPath:M,onBypassGate:A,onRefresh:T,onShare:O,onClose:_,renderCopyMenu:D,appKey:R,setAppKey:I,appFullscreen:L,setAppFullscreen:P,viewerKey:z,setViewerKey:$,htmlSourceMode:B,setHtmlSourceMode:F,widthAwareViewer:H,viewWidth:U,viewAlign:V,setViewWidth:W,setViewAlign:q,contentWidthClass:K,contentAlignClass:G,isMobile:J,sidebarCollapsed:Z}){let[X,Y]=(0,f.useState)(null),[Q,ee]=(0,f.useState)(null),[et,en]=(0,f.useState)(!1);(0,f.useEffect)(()=>{en(!1)},[e.path]);let er=n$(e.name,e.nodeType),ei=!w8.has(er)&&(e.size??0)>5242880&&M!==e.path;if("node-app"===er)return(0,s.jsx)(w6,{path:e.path,title:e.name});let es="html"===er?(0,tC.withWs)(`/api/assets/${e.path}`):void 0;return"app"===er||"html"===er?L?(0,s.jsx)(w3,{scriptsEnabled:et,onToggleScripts:()=>en(e=>!e),path:e.path,title:e.name,src:es,fullscreen:!0,onExit:()=>P(!1)}):(0,s.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden min-w-0",children:[(0,s.jsxs)("div",{className:(0,eh.cn)("flex items-center justify-between px-4 py-2 border-b bg-muted shrink-0 ",!J&&Z&&"pl-11"),children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,s.jsx)("span",{className:"hidden md:inline-flex",children:(0,s.jsx)("span",{className:"",children:(0,s.jsx)(c,{className:"h-4 w-4 shrink-0 text-foreground/70"})})}),(0,s.jsx)("span",{className:"hidden md:inline text-sm font-normal truncate",title:e.path,children:e.path}),(0,s.jsx)("div",{ref:e=>{e&&ee(e)},className:"flex items-center gap-1 shrink-0"})]}),(0,s.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[(0,s.jsx)("div",{ref:e=>{e&&Y(e)},className:"flex items-center gap-1 shrink-0"}),D(e,(0,s.jsxs)(s.Fragment,{children:["html"===er&&!r&&(0,s.jsxs)(ek.DropdownMenuItem,{onClick:()=>F(!B),children:[B?(0,s.jsx)(c,{className:"mr-2 h-3.5 w-3.5"}):(0,s.jsx)(r6,{className:"mr-2 h-3.5 w-3.5"}),B?"Show preview":"Show source"]}),(0,s.jsxs)(ek.DropdownMenuItem,{onClick:()=>I(e=>e+1),children:[(0,s.jsx)(t_,{className:"mr-2 h-3.5 w-3.5"}),"Refresh"]}),(0,s.jsxs)(ek.DropdownMenuItem,{onClick:()=>P(!0),children:[(0,s.jsx)(r9,{className:"mr-2 h-3.5 w-3.5"}),"Open fullscreen"]}),(0,s.jsxs)(ek.DropdownMenuItem,{onClick:O,children:[(0,s.jsx)(r8,{className:"mr-2 h-3.5 w-3.5"}),"Share"]})]})),"html"===er&&!r&&null!==t&&(0,s.jsx)(v.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"Edit source",onClick:()=>{i(!0),a(t)},children:(0,s.jsx)(r7,{className:"h-3.5 w-3.5"})}),(0,s.jsx)(v.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:_,children:(0,s.jsx)(h,{className:"h-3.5 w-3.5"})})]})]}),r&&"html"===er?(0,s.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden min-h-0",children:[(0,s.jsx)("textarea",{value:o,onChange:e=>a(e.target.value),spellCheck:!1,className:"flex-1 w-full min-h-0 resize-none bg-background text-foreground px-4 py-3 font-mono text-[13px] leading-relaxed outline-none border-0"}),(0,s.jsxs)("div",{className:"border-t px-4 py-2 flex items-center justify-end gap-2 bg-muted shrink-0",children:[m&&(0,s.jsx)("span",{className:"text-xs text-destructive mr-auto",children:m}),(0,s.jsx)(v.Button,{size:"sm",variant:"ghost",onClick:()=>i(!1),children:"Cancel"}),(0,s.jsxs)(v.Button,{size:"sm",className:"gap-1",onClick:b,disabled:p,children:[p&&(0,s.jsx)(u.Loader2,{className:"h-3 w-3 animate-spin"}),"Save"]})]})]}):B&&"html"===er?(0,s.jsx)(ii.ViewerToolbarBadgeSlotContext.Provider,{value:Q,children:(0,s.jsx)(ii.ViewerToolbarSlotContext.Provider,{value:X,children:(0,s.jsx)(w0,{path:e.path,title:e.name})})}):(0,s.jsx)(ii.ViewerToolbarBadgeSlotContext.Provider,{value:Q,children:(0,s.jsx)(ii.ViewerToolbarSlotContext.Provider,{value:X,children:(0,s.jsx)(w3,{scriptsEnabled:et,onToggleScripts:()=>en(e=>!e),path:e.path,title:e.name,src:es},R)})})]}):(0,s.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden min-w-0",children:[(0,s.jsxs)("div",{className:(0,eh.cn)("flex items-center justify-between px-4 py-2 border-b bg-muted shrink-0 ",!J&&Z&&"pl-11"),children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,s.jsx)("span",{className:"hidden md:inline-flex",children:(0,s.jsx)("span",{className:"",children:nU(e.name)?(0,s.jsx)(d.Image,{className:"h-4 w-4 shrink-0 text-sunshine-700"}):nF(e.name)?(0,s.jsx)(l.FileText,{className:"h-4 w-4 shrink-0 text-foreground/70"}):(0,s.jsx)(nt,{className:"h-4 w-4 shrink-0 text-foreground/60"})})}),(0,s.jsx)("span",{className:"hidden md:inline text-sm font-normal truncate",title:e.path,children:e.path}),(0,s.jsx)("div",{ref:e=>{e&&ee(e)},className:"flex items-center gap-1 shrink-0"}),x&&(0,s.jsxs)("span",{className:"hidden md:flex items-center gap-1 text-[11px] text-muted-foreground shrink-0 ml-1",children:[(0,s.jsx)(ie,{className:"h-3 w-3 shrink-0"}),(0,s.jsx)("span",{className:"truncate max-w-[100px]",children:x.author}),(0,s.jsx)("span",{title:new Date(x.date).toLocaleString(),className:"shrink-0",children:w7(x.date)})]})]}),(0,s.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[(0,s.jsx)("div",{ref:e=>{e&&Y(e)},className:"flex items-center gap-1 shrink-0"}),D(e,(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(ek.DropdownMenuItem,{onClick:j,children:[(0,s.jsx)(rW,{className:"mr-2 h-3.5 w-3.5"}),y?"Hide history":"File history"]}),(0,s.jsxs)(ek.DropdownMenuItem,{onClick:O,children:[(0,s.jsx)(r8,{className:"mr-2 h-3.5 w-3.5"}),"Share"]}),!r&&(0,s.jsxs)(ek.DropdownMenuItem,{onClick:T,disabled:n,children:[n?(0,s.jsx)(u.Loader2,{className:"mr-2 h-3.5 w-3.5 animate-spin"}):(0,s.jsx)(t_,{className:"mr-2 h-3.5 w-3.5"}),"Refresh"]}),H&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(ek.DropdownMenuSeparator,{}),(0,s.jsx)(ek.DropdownMenuLabel,{className:"text-[11px] text-muted-foreground",children:"Width"}),r$.VIEW_WIDTH_ORDER.map(e=>(0,s.jsxs)(ek.DropdownMenuItem,{onClick:()=>W(e),className:"flex items-center justify-between text-xs",children:[r$.VIEW_WIDTH_LABEL[e],e===U&&(0,s.jsx)(g.Check,{className:"h-3.5 w-3.5"})]},e)),(0,s.jsx)(ek.DropdownMenuSeparator,{}),(0,s.jsx)(ek.DropdownMenuLabel,{className:"text-[11px] text-muted-foreground",children:"Alignment"}),r$.VIEW_ALIGN_ORDER.map(e=>(0,s.jsxs)(ek.DropdownMenuItem,{onClick:()=>q(e),className:"flex items-center justify-between text-xs",children:[r$.VIEW_ALIGN_LABEL[e],e===V&&(0,s.jsx)(g.Check,{className:"h-3.5 w-3.5"})]},e))]})]})),nF(e.name)&&!r&&(null!==t||nH(e.name))&&(0,s.jsx)(v.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:()=>{i(!0),a(t??"")},children:(0,s.jsx)(r7,{className:"h-3.5 w-3.5"})}),nF(e.name)&&r&&nH(e.name)&&(0,s.jsx)(v.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"Done editing",onClick:()=>i(!1),children:(0,s.jsx)(rU.Eye,{className:"h-3.5 w-3.5"})}),(0,s.jsx)(v.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:_,children:(0,s.jsx)(h,{className:"h-3.5 w-3.5"})})]})]}),y&&(0,s.jsxs)("div",{className:"border-b bg-muted/30 shrink-0 max-h-[40vh] overflow-auto",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between px-4 py-1.5 border-b",children:[(0,s.jsx)("span",{className:"text-xs font-semibold text-muted-foreground",children:"History"}),(0,s.jsx)("button",{type:"button",className:"text-muted-foreground hover:text-foreground",onClick:j,children:(0,s.jsx)(h,{className:"h-3.5 w-3.5"})})]}),w?(0,s.jsx)("div",{className:"flex justify-center py-4",children:(0,s.jsx)(u.Loader2,{className:"h-4 w-4 animate-spin text-muted-foreground"})}):0===k.length?(0,s.jsx)("p",{className:"px-4 py-3 text-xs text-muted-foreground",children:"No history found."}):(0,s.jsx)("div",{children:k.map(e=>(0,s.jsxs)("div",{children:[(0,s.jsx)("button",{type:"button",className:(0,eh.cn)("w-full text-left px-4 py-2 hover:bg-muted transition-colors",N===e.sha&&"bg-muted"),onClick:()=>E(e.sha),children:(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("code",{className:"text-[11px] font-mono text-muted-foreground shrink-0",children:e.shortSha}),(0,s.jsx)("span",{className:"flex-1 truncate text-xs",children:e.message}),(0,s.jsx)("span",{className:"shrink-0 text-[11px] text-muted-foreground",children:e.author}),(0,s.jsx)("span",{className:"shrink-0 text-[11px] text-muted-foreground",title:new Date(e.date).toLocaleString(),children:w7(e.date)})]})}),N===e.sha&&(0,s.jsx)("div",{className:"border-t",children:C?(0,s.jsx)("div",{className:"flex justify-center py-3",children:(0,s.jsx)(u.Loader2,{className:"h-4 w-4 animate-spin text-muted-foreground"})}):null!==S?(0,s.jsx)("pre",{className:"overflow-auto px-4 py-2 text-[11px] font-mono leading-relaxed whitespace-pre text-foreground/80 max-h-60",children:S}):null})]},e.sha))})]}),ei?(0,s.jsx)(vX,{path:e.path,size:e.size??0,onOpen:A}):r?(0,s.jsx)("div",{className:"flex-1 flex flex-col overflow-hidden min-h-0",children:nH(e.name)?(0,s.jsx)(vG,{}):(0,s.jsx)("textarea",{value:o,onChange:e=>a(e.target.value),spellCheck:!1,className:"flex-1 w-full min-h-0 resize-none bg-background text-foreground px-4 py-3 font-mono text-[13px] leading-relaxed outline-none border-0"})}):nH(e.name)?(0,s.jsx)("div",{className:"flex-1 flex flex-col overflow-hidden min-h-0",children:n?(0,s.jsx)("div",{className:"flex justify-center py-8",children:(0,s.jsx)(u.Loader2,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):(0,s.jsx)(vG,{mode:"viewing"})}):"csv"===er||"pdf"===er||"mermaid"===er||"notebook"===er||"image"===er||"media"===er||"docx"===er||"xlsx"===er||"pptx"===er||"source"===er||"fallback"===er?(0,s.jsx)(ii.ViewerToolbarBadgeSlotContext.Provider,{value:Q,children:(0,s.jsx)(ii.ViewerToolbarSlotContext.Provider,{value:X,children:(0,s.jsx)("div",{className:"flex-1 flex flex-col overflow-hidden min-h-0",children:n?(0,s.jsx)("div",{className:"flex justify-center py-8",children:(0,s.jsx)(u.Loader2,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):"csv"===er?(0,s.jsx)(ia,{path:e.path,title:e.name}):"pdf"===er?(0,s.jsx)(w9,{path:e.path,title:e.name}):"mermaid"===er?(0,s.jsx)(v0,{path:e.path,title:e.name}):"notebook"===er?(0,s.jsx)(wH,{path:e.path,title:e.name}):"image"===er?(0,s.jsx)(vY,{path:e.path,title:e.name}):"media"===er?(0,s.jsx)(vQ,{path:e.path,title:e.name,type:["mp4","webm","mov","m4v"].includes(nz(e.name))?"video":"audio"}):"docx"===er?(0,s.jsx)(wV,{path:e.path,title:e.name}):"xlsx"===er?(0,s.jsx)(wq,{path:e.path,title:e.name}):"pptx"===er?(0,s.jsx)(wW,{path:e.path,title:e.name}):"source"===er?(0,s.jsx)(w0,{path:e.path,title:e.name}):(0,s.jsx)(vJ,{path:e.path,title:e.name})},z)})}):(0,s.jsx)("div",{className:"flex-1 overflow-auto p-4 min-h-0",children:(0,s.jsx)("div",{className:(0,eh.cn)("w-full",G,K),children:n?(0,s.jsx)("div",{className:"flex justify-center py-8",children:(0,s.jsx)(u.Loader2,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):null!==t?(0,s.jsx)("pre",{className:"text-xs font-mono whitespace-pre-wrap break-words leading-relaxed",children:t}):nF(e.name)?(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:"Could not load file."}):(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:"Preview not available for this file type."})})}),r&&!nH(e.name)&&(0,s.jsxs)("div",{className:"border-t px-4 py-2 flex items-center justify-end gap-2 bg-muted shrink-0",children:[m&&(0,s.jsx)("span",{className:"text-xs text-destructive mr-auto",children:m}),(0,s.jsx)(v.Button,{size:"sm",variant:"ghost",onClick:()=>i(!1),children:"Cancel"}),(0,s.jsxs)(v.Button,{size:"sm",className:"gap-1",onClick:b,disabled:p,children:[p&&(0,s.jsx)(u.Loader2,{className:"h-3 w-3 animate-spin"}),"Save"]})]})]})}function kt(e="(max-width: 767px)"){let[t,n]=(0,f.useState)(!1);return(0,f.useEffect)(()=>{let t=window.matchMedia(e),r=()=>n(t.matches);return r(),t.addEventListener("change",r),()=>t.removeEventListener("change",r)},[e]),t}function kn(e){return e?`wiki-recent-files-${e}`:"wiki-recent-files"}function kr(e){try{let t=localStorage.getItem(kn(e));return t?JSON.parse(t):[]}catch{return[]}}let ki=(0,eN.create)(e=>({recents:[],loadForWorkspace:t=>{e({recents:kr(t)})},push:(t,n)=>{let r=kr(n).filter(e=>e.path!==t.path),i=[t,...r].slice(0,15);localStorage.setItem(kn(n),JSON.stringify(i)),e({recents:i})}})),ks=new Map,ko=new Map;async function ka(e){let t=await (0,tC.wsFetch)(`/api/wiki?dir=${encodeURIComponent(e)}`);return t.ok?(await t.json()).entries.map(t=>({name:t.name,path:e?`${e}/${t.name}`:t.name,type:t.type,size:t.size,modifiedAt:t.modifiedAt,expanded:!1,git:t.git})):[]}async function kl(e){let t=ks.get(e);if(t)return ks.delete(e),t;let n=ko.get(e);if(n){let t=await n;return ks.delete(e),t}return null}function kc(e,t,n){return e.map(e=>e.path===t?n(e):e.children?{...e,children:kc(e.children,t,n)}:e)}function kd(e){let t=[];for(let n of e)("dir"===n.type||"app"===n.type||"node-app"===n.type)&&n.expanded&&n.children&&(t.push(n.path),t.push(...kd(n.children)));return t}function ku(e){return e.split("/").pop()??e}e.s(["default",0,function(){let e=function(){let[e,t]=(0,f.useState)(null),[n,r]=(0,f.useState)(null),[i,s]=(0,f.useState)(()=>(0,tC.getActiveWorkspaceId)()),[o,a]=(0,f.useState)([]),[l,c]=(0,f.useState)(!1),[d,u]=(0,f.useState)(!1),[p,h]=(0,f.useState)(null),[m,g]=(0,f.useState)(null),[b,x]=(0,f.useState)({}),[y,v]=(0,f.useState)(null),[w,k]=(0,f.useState)(null),[N,S]=(0,f.useState)(null),[C,j]=(0,f.useState)(null),E=(0,f.useCallback)(async()=>{let e=(0,tC.getEphemeralRoot)();if(e){a([]),c(!1),t(!0),r(e),s(`root:${e}`);return}try{let e=await fetch((0,ev.apiUrl)("/api/system/workspaces"));if(!e.ok)throw Error("Failed");let n=await e.json();if(a(n.workspaces),c(n.isAdmin),n.workspaces.length>0){t(!0);let e=new URLSearchParams(window.location.search).get("ws"),i=e?n.workspaces.find(t=>t.id===e):null,o=i??[...n.workspaces].sort((e,t)=>(t.lastOpenedAt??t.createdAt).localeCompare(e.lastOpenedAt??e.createdAt))[0];if(s(o.id),r(o.rootDir),!i){let e=new URL(location.href);e.searchParams.set("ws",o.id),history.replaceState(null,"",e.toString())}}else t(!1)}catch{t(!1)}},[]);(0,f.useEffect)(()=>{E()},[E]);let M=(0,f.useCallback)(async e=>{if(e===i)return;try{await fetch((0,ev.apiUrl)(`/api/system/workspaces/${e}/open`),{method:"POST"})}catch{}let t=new URL(location.href);t.searchParams.set("ws",e),t.searchParams.delete("path"),history.pushState(null,"",t.toString()),fl.getState().invalidate(),vj.getState().invalidateAll();let n=o.find(t=>t.id===e);n&&r(n.rootDir),s(e)},[i,o]),A=(0,f.useCallback)(async e=>{if(p)try{if(!(await fetch((0,ev.apiUrl)(`/api/system/workspaces/${p}`),{method:"DELETE"})).ok)throw Error("Failed");if(p===i){let n=o.filter(e=>e.id!==p);if(n.length>0){let t=[...n].sort((e,t)=>(t.lastOpenedAt??t.createdAt).localeCompare(e.lastOpenedAt??e.createdAt))[0];await e(t.id)}else t(!1)}await E()}catch{}finally{h(null)}},[p,i,o,E]),T=(0,f.useCallback)(async e=>{if(!m){g(e);try{let t=await fetch((0,ev.apiUrl)(`/api/system/workspaces/${e}/refresh`),{method:"POST"});if(!t.ok){let e=await t.json();ey(e.error??"Refresh failed");return}await E()}catch{ey("Refresh failed")}finally{g(null)}}},[m,E]),O=(0,f.useCallback)(async e=>{if(!b[e])try{let t=await fetch((0,ev.apiUrl)(`/api/system/workspaces/${e}/branch`));if(!t.ok)return;let n=await t.json();x(t=>({...t,[e]:n.branches??[]}))}catch{}},[b]),_=(0,f.useCallback)(async(e,t)=>{if(!y){v(e),k(t);try{let n=await fetch((0,ev.apiUrl)(`/api/system/workspaces/${e}/branch`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({branch:t})});if(!n.ok){let e=await n.json();ey(e.error??"Branch switch failed");return}ex(`Switched to ${t}`),S(null),j(null),await E()}catch{ey("Branch switch failed")}finally{v(null),k(null)}}},[y,E]);return{rootConfigured:e,rootPath:n,activeWorkspaceId:i,workspaces:o,isWsAdmin:l,addingWorkspace:d,setAddingWorkspace:u,setRootConfigured:t,setActiveWorkspaceId:s,deletingWorkspaceId:p,setDeletingWorkspaceId:h,refreshingWsId:m,wsBranches:b,switchingBranch:y,switchingBranchName:w,branchPickerWsId:N,setBranchPickerWsId:S,wsBranchPos:C,setWsBranchPos:j,loadWorkspaces:E,switchWorkspace:M,handleDeleteWorkspace:A,handleRefreshWorkspace:T,loadWsBranches:O,handleSwitchBranch:_}}(),t=(0,f.useRef)(()=>{}),n=function({activeWorkspaceId:e,rootConfigured:t,onExternalChange:n}){let[r,i]=(0,f.useState)([]),[s,o]=(0,f.useState)(!1),[a,l]=(0,f.useState)(!1),c=(0,f.useRef)(!1),[d,u]=(0,f.useState)(!1),[p,h]=(0,f.useState)({}),[m,g]=(0,f.useState)({}),[b,x]=(0,f.useState)(null),[y,v]=(0,f.useState)(null),[w,k]=(0,f.useState)(null),[N,S]=(0,f.useState)(null);(0,f.useEffect)(()=>{i([]),o(!1),c.current=!1,h({}),g({}),x(null),v(null),k(null),S(null)},[e]),(0,f.useEffect)(()=>{!e||s||c.current||(c.current=!0,l(!0),ka("").then(e=>{i(e),o(!0),l(!1)}).catch(()=>{c.current=!1,l(!1)}))},[s,e]);let C=(0,f.useCallback)(async e=>{let t=await ka(e);""===e?i(e=>{let n=new Map(e.map(e=>[e.path,e]));return t.map(e=>{let t=n.get(e.path);return t&&("dir"===t.type||"app"===t.type)?{...e,expanded:t.expanded,children:t.children}:e})}):i(n=>kc(n,e,e=>({...e,children:t,expanded:!0})))},[]),j=(0,f.useCallback)(async e=>{let t=e.split("/");if(t.length<=1)return;let n=[],r="";for(let e=0;e<t.length-1;e++)r=r?`${r}/${t[e]}`:t[e],n.push({prefix:r,children:await ka(r)});i(e=>{let t=e;for(let{prefix:e,children:r}of n)t=kc(t,e,e=>({...e,children:r,expanded:!0}));return t})},[]),E=(0,f.useCallback)(async()=>{u(!0);try{let e=kd(r),t=await ka("");for(let n of(i(t),e)){let e=await ka(n);i(t=>kc(t,n,t=>({...t,children:e,expanded:!0})))}}finally{u(!1)}},[r]),M=(0,f.useCallback)(async e=>{if("dir"===e.type||"app"===e.type||"node-app"===e.type)if(e.expanded)i(t=>kc(t,e.path,e=>({...e,expanded:!1})));else if(void 0===e.children){let t=await kl(e.path);if(t)return void i(n=>kc(n,e.path,e=>({...e,loading:!1,children:t,expanded:!0})));i(t=>kc(t,e.path,e=>({...e,loading:!0})));let n=await ka(e.path);i(t=>kc(t,e.path,e=>({...e,loading:!1,children:n,expanded:!0})))}else i(t=>kc(t,e.path,e=>({...e,expanded:!0})))},[]),A=(0,f.useCallback)(e=>{"file"===e.type?(e.name.endsWith(".md")||e.name.endsWith(".markdown"))&&tK(e.path):function(e){if(ks.has(e)||ko.has(e))return;let t=ka(e).then(t=>(ks.set(e,t),t)).finally(()=>ko.delete(e));ko.set(e,t),t.catch(()=>{})}(e.path)},[]),T=(0,f.useRef)([]);(0,f.useEffect)(()=>{T.current=kd(r)},[r]);let O=(0,f.useMemo)(()=>kd(r).filter(e=>""!==e).slice(0,24).join("\n"),[r]),[_,D]=(0,f.useState)("");(0,f.useEffect)(()=>{let e=setTimeout(()=>D(O),300);return()=>clearTimeout(e)},[O]);let R=(0,f.useRef)(n);(0,f.useEffect)(()=>{R.current=n},[n]),(0,f.useEffect)(()=>{if(!t||(0,ev.isLite)()||!e)return;let n=new Map;function r(e){n.has(e)&&clearTimeout(n.get(e)),n.set(e,setTimeout(()=>{n.delete(e),C(e)},300))}let i=(_?_.split("\n"):[]).map(e=>`dir=${encodeURIComponent(e)}`).join("&"),s=new EventSource((0,tC.withWs)(i?`/api/wiki/watch?${i}`:"/api/wiki/watch"));return s.onmessage=e=>{let t;try{t=JSON.parse(e.data)}catch{return}let{type:i,path:s}=t;if("rescan"===i){for(let e of(vj.getState().invalidateAll(),r(""),T.current))r(e);return}("add"===i||"change"===i||"unlink"===i)&&vj.getState().invalidateAll();let o=s.split("/");if(r(o.length>1?o.slice(0,-1).join("/"):""),"change"===i){let e=`__file__${s}`;n.has(e)&&clearTimeout(n.get(e)),n.set(e,setTimeout(()=>{n.delete(e),R.current?.(s)},400))}},()=>{for(let e of(s.close(),n.values()))clearTimeout(e)}},[t,C,e,_]);let I=(0,f.useCallback)(async e=>{if(!p[e]&&!m[e]){g(t=>({...t,[e]:!0}));try{let t=await (0,tC.wsFetch)(`/api/wiki/git-branches?path=${encodeURIComponent(e)}`);if(!t.ok)return void ey("Could not load branches");let n=await t.json();h(t=>({...t,[e]:n.branches}))}catch{ey("Could not load branches")}finally{g(t=>({...t,[e]:!1}))}}},[p,m]),L=(0,f.useCallback)(async(e,t,n)=>{if(!b){x(t);try{let r=await (0,tC.wsFetch)("/api/wiki/git-checkout",{method:"POST",body:JSON.stringify({path:e,branch:t})});if(409===r.status)return void ey("Repository has uncommitted changes");if(!r.ok){let e=await r.json();ey(e.error??"Checkout failed");return}let i=await r.json();ex(`Switched to ${i.branch}`),k(null),S(null),h(t=>{let n={...t};return delete n[e],n}),await C(n)}catch{ey("Checkout failed")}finally{x(null)}}},[b,C]),P=(0,f.useCallback)(async(e,t)=>{if(!y){v(e);try{let n=await (0,tC.wsFetch)("/api/wiki/git-pull",{method:"POST",body:JSON.stringify({path:e})});if(!n.ok){let e=await n.json();ey(e.message??e.error??"Pull failed");return}let r=await n.json();ex(`Pulled ${e} (${r.branch} @ ${r.sha.slice(0,7)})`),await C(t)}catch{ey("Pull failed")}finally{v(null)}}},[y,C]);return{roots:r,rootLoaded:s,rootLoading:a,refreshingTree:d,refreshTree:E,reloadDir:C,revealPath:j,toggleFolder:M,prefetch:A,nodeBranches:p,branchesLoading:m,checkingOutBranch:b,pullingRepo:y,branchDropdownNode:w,setBranchDropdownNode:k,branchDropdownPos:N,setBranchDropdownPos:S,loadBranches:I,handleCheckout:L,handleGitPull:P}}({activeWorkspaceId:e.activeWorkspaceId,rootConfigured:e.rootConfigured,onExternalChange:(0,f.useCallback)(e=>t.current(e),[])}),r=function({activeWorkspaceId:e,rootPath:t,isMobile:n,setSidebarCollapsed:r,treeApi:i}){let[s,o]=(0,f.useState)(null),[a,l]=(0,f.useState)(null),[c,d]=(0,f.useState)(!1),[u,p]=(0,f.useState)(0),[h,m]=(0,f.useState)(0),[g,b]=(0,f.useState)(null),[x,y]=(0,f.useState)(0),[v,w]=(0,f.useState)(!1),[k,N]=(0,f.useState)(!1),[S,C]=(0,f.useState)(""),[j,E]=(0,f.useState)(!1),[M,A]=(0,f.useState)(!1),[T,O]=(0,f.useState)(null),_=(0,f.useRef)(null),D=(0,f.useRef)(!1);(0,f.useEffect)(()=>{_.current=s},[s]),(0,f.useEffect)(()=>{D.current=k},[k]);let R=(0,f.useMemo)(()=>s?n$(s.name,s.nodeType):null,[s]),I=(0,f.useCallback)(()=>{N(!1),E(!1),O(null),b(null),y(0),l(null)},[]),L=(0,f.useCallback)(async(e,t)=>{var n;if(["editor","text"].includes(t)||nF((n=e).split("/").pop()??n)){w(!0);try{let t=await (0,tC.wsFetch)(`/api/wiki/content?path=${encodeURIComponent(e)}`);if(t.ok){let e=await t.json();b(e.content),y(Number(t.headers.get("X-Wiki-Revision")??0))}}catch{}w(!1)}},[]),P=(0,f.useCallback)(async t=>{if("file"===t.type&&ki.getState().push({path:t.path,name:t.name},e),o({path:t.path,name:t.name,size:t.size,nodeType:"app"===t.type?"app":"node-app"===t.type?"node-app":"file"}),I(),"file"===t.type&&nH(t.name)){w(!0);try{await tQ.getState().loadPage(t.path)}finally{w(!1)}return}let n=n$(t.name,t.type);await L(t.path,n)},[e,I,L]),z=(0,f.useCallback)(()=>{o(null),b(null),N(!1),E(!1),O(null)},[]),$=(0,f.useCallback)(()=>{o(null),b(null),N(!1),E(!1),O(null),y(0)},[]),B=(0,f.useCallback)(e=>{let t=e.split("/").pop()??e;i.revealPath(e),P({path:e,name:t,type:"file",modifiedAt:""})},[P,i]),F=(0,f.useCallback)(async e=>{let t=e.path.split("/").slice(0,-1).join("/"),s=(await ka(t)).find(t=>t.path===e.path);if(s){if("dir"===s.type){await i.revealPath(e.path),await i.toggleFolder(s);return}if("app"===s.type||"node-app"===s.type){await i.revealPath(s.path),P({path:s.path,name:s.name,type:s.type,modifiedAt:s.modifiedAt}),await i.toggleFolder(s),n&&r(!0);return}P({path:s.path,name:s.name,type:s.type,modifiedAt:s.modifiedAt}),n&&r(!0)}},[n,P,r,i]),H=(0,f.useCallback)(async e=>{if(!e)return void o(null);let n=(0,tC.toRootRelative)(e,(0,tC.getEphemeralRoot)()??t);if(null===n||!(e=n))return;let r=e.split("/"),s=r[r.length-1],a=r.slice(0,-1).join("/"),l=(await ka(a)).find(t=>t.path===e);l&&(await i.revealPath(e),P({path:e,name:s,type:l.type,modifiedAt:l.modifiedAt}))},[P,t,i]);(0,f.useEffect)(()=>{let e=new URL(window.location.href);s?e.searchParams.set("path",s.path):e.searchParams.delete("path");let t=e.toString();t!==window.location.href&&window.history.pushState(null,"",t)},[s]),(0,f.useEffect)(()=>{let e=()=>{H(new URLSearchParams(window.location.search).get("path"))};return window.addEventListener("popstate",e),()=>window.removeEventListener("popstate",e)},[H]);let[U,V]=(0,f.useState)(!1);(0,f.useEffect)(()=>{V("1"===new URLSearchParams(window.location.search).get("embed"))},[]),(0,f.useEffect)(()=>{if(!U)return;let e=e=>{e.origin!==window.location.origin?console.warn(`[wiki-viewer] ignored postMessage from untrusted parent origin ${e.origin}.`):e.data&&"open-file"===e.data.type&&"string"==typeof e.data.path&&H(e.data.path)};return window.addEventListener("message",e),()=>window.removeEventListener("message",e)},[U,H]);let W=(0,f.useRef)(new URLSearchParams(window.location.search).get("path")??new URLSearchParams(window.location.search).get("file")),q=(0,f.useRef)(!1),[K,G]=(0,f.useState)(!1),J=(0,f.useCallback)(()=>G(!0),[]);(0,f.useEffect)(()=>{q.current||K&&(q.current=!0,H(W.current))},[K,H]),(0,f.useEffect)(()=>{s&&nH(s.name)&&tQ.getState().currentPath!==s.path&&tQ.getState().loadPage(s.path)},[s]);let Z=(0,f.useCallback)(async()=>{let e=_.current;if(e){if(nH(e.name)){w(!0);try{await tQ.getState().loadPage(e.path)}finally{w(!1)}return}if(["editor","text"].includes(n$(e.name,e.nodeType))||nF(e.name)){w(!0);try{let t=await (0,tC.wsFetch)(`/api/wiki/content?path=${encodeURIComponent(e.path)}`);if(t.ok){let e=await t.json();b(e.content),y(Number(t.headers.get("X-Wiki-Revision")??0))}}catch{}w(!1)}}},[]),X=(0,f.useCallback)(()=>{m(e=>e+1),Z()},[Z]),Y=(0,f.useCallback)(e=>{let t=_.current;t&&t.path===e&&!D.current&&Z()},[Z]),Q=(0,f.useCallback)(async()=>{let e=_.current;if(!e)return;A(!0),O(null);let t=await (0,tC.wsFetch)("/api/wiki/content",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e.path,content:S,baseRevision:x})});if(t.ok){let e=await t.json();"number"==typeof e.revision&&y(e.revision),b(S),N(!1)}else O((await t.json()).error??"Save failed");A(!1)},[S,x]);async function ee(e){let t=_.current;if(t?.path===e&&null!==g)return g;if(tQ.getState().currentPath===e)return tQ.getState().content;let n=await (0,tC.wsFetch)(`/api/wiki/content?path=${encodeURIComponent(e)}`);if(!n.ok)throw Error("Cannot copy content");return(await n.json()).content}return{openFile:s,openFileViewerKind:R,fileContent:g,fileRevision:x,fileLoading:v,editing:k,setEditing:N,editContent:S,setEditContent:C,htmlSourceMode:j,setHtmlSourceMode:E,saving:M,saveError:T,appFullscreen:c,setAppFullscreen:d,appKey:u,setAppKey:p,viewerKey:h,setViewerKey:m,gateBypassPath:a,bypassGate:()=>l(_.current?.path??null),openViewer:P,openFromSearch:B,openFavoriteEntry:F,navigateToPath:H,handleSave:Q,refreshViewer:Z,handleRefresh:X,closeFile:z,clearFile:$,onExternalChange:Y,markRootLoaded:J,copyPath:e=>{navigator.clipboard.writeText(e),ex("Path copied")},copyWikiLink:e=>{let t=e.replace(/\.(md|markdown)$/i,"");navigator.clipboard.writeText(`[[${t}]]`),ex("Wiki link copied")},copyUrl:t=>{let n=new URL(location.href);n.searchParams.set("path",t),e&&n.searchParams.set("ws",e),navigator.clipboard.writeText(n.toString()),ex("URL copied")},copyRawContent:async function(e){try{let t=await ee(e);await navigator.clipboard.writeText(t),ex("Raw content copied")}catch{ey("Could not copy file content")}},copyFormattedContent:async function(e,t){try{let n=await ee(e);if(!nH(t)){await navigator.clipboard.writeText(n),ex("Content copied");return}let r=await (0,hN.markdownToHtml)(n,{pagePath:e,sanitize:!0});"ClipboardItem"in window&&navigator.clipboard.write?await navigator.clipboard.write([new ClipboardItem({"text/html":new Blob([r],{type:"text/html"}),"text/plain":new Blob([n],{type:"text/plain"})})]):await navigator.clipboard.writeText(n),ex("Formatted content copied")}catch{ey("Could not copy formatted content")}}}}({activeWorkspaceId:e.activeWorkspaceId,rootPath:e.rootPath,isMobile:kt(),setSidebarCollapsed:e=>g.current(e),treeApi:{revealPath:n.revealPath,toggleFolder:n.toggleFolder}});(0,f.useEffect)(()=>{t.current=r.onExternalChange},[r.onExternalChange]);let i=kt(),[o,m]=(0,f.useState)(!1),g=(0,f.useRef)(()=>{});g.current=m;let[b,x]=(0,f.useState)({settingsOpen:!1,shareDialogOpen:!1}),[y,w]=(0,f.useState)(!1),[k,N]=(0,f.useState)({path:null,isDir:!1}),S=function({reloadDir:e}){let[t,n]=(0,f.useState)(!1),[r,i]=(0,f.useState)(null),s=(0,f.useRef)(null),o=(0,f.useRef)(""),a=(0,f.useCallback)(async(t,r)=>{void 0!==r&&(o.current=r);let a=Array.from(t);if(a.length){n(!0),i(null);try{for(let e of a){let t=new FormData;t.append("file",e),t.append("dir",o.current);let n=await (0,tC.wsFetch)("/api/wiki/upload",{method:"POST",body:t});if(!n.ok){let e=await n.json();i(e.error??"Upload failed"),ey(e.error??"Upload failed");break}}await e(o.current)}catch{i("Upload failed.")}finally{n(!1),s.current&&(s.current.value="")}}},[e]);return{uploading:t,uploadError:r,fileInputRef:s,triggerUpload:function(e){o.current=e,s.current?.click()},doUpload:a}}({reloadDir:n.reloadDir}),C=function(e){let[t,n]=(0,f.useState)(null),[r,i]=(0,f.useState)(!1),[s,o]=(0,f.useState)([]),[a,l]=(0,f.useState)(!1),[c,d]=(0,f.useState)(null),[u,p]=(0,f.useState)(null),[h,m]=(0,f.useState)(!1),g=e?.path;(0,f.useEffect)(()=>{i(!1),o([]),d(null),p(null)},[g]),(0,f.useEffect)(()=>{if(!g)return void n(null);let e=!1,t=setTimeout(()=>{(async()=>{try{let t=await (0,tC.wsFetch)(`/api/wiki/git-file-info?path=${encodeURIComponent(g)}`);if(e)return;if(!t.ok)return void n(null);let r=await t.json();e||n(r.info)}catch{e||n(null)}})()},200);return()=>{e=!0,clearTimeout(t)}},[g]);let b=(0,f.useCallback)(async()=>{if(!e)return;let t=e.path;i(!0),l(!0),o([]),d(null),p(null);try{let n=await (0,tC.wsFetch)(`/api/wiki/git-history?path=${encodeURIComponent(t)}`);if(!n.ok)return void ey("Could not load history");let r=await n.json();e.path===t&&o(r.commits)}catch{ey("Could not load history")}finally{l(!1)}},[e]),x=(0,f.useCallback)(async t=>{if(!e)return;if(c===t){d(null),p(null);return}let n=e.path;d(t),m(!0),p(null);try{let r=await (0,tC.wsFetch)(`/api/wiki/git-diff?path=${encodeURIComponent(n)}&sha=${encodeURIComponent(t)}`);if(!r.ok)return void ey("Could not load diff");let i=await r.json();e.path===n&&c===t&&p(i.diff)}catch{ey("Could not load diff")}finally{m(!1)}},[e,c]);return{gitFileInfo:t,showHistory:r,setShowHistory:i,historyLoading:a,historyCommits:s,selectedDiffSha:c,setSelectedDiffSha:d,loadHistory:b,diffContent:u,diffLoading:h,selectDiff:x}}(r.openFile),j=nY(e=>e.favorites),E=ki(e=>e.recents),M=tA(e=>e.activity),A=(0,f.useMemo)(()=>{let e=new Date(Date.now()-6e4).toISOString(),t=new Set;for(let n of M)n.at>=e&&n.path&&n.by?.startsWith("ai:")&&t.add(n.path);return t},[M]);async function T(){if(!k.path)return;await fetch((0,tC.withWs)("/api/wiki"),{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:k.path})}),(r.openFile?.path===k.path||r.openFile?.path.startsWith(`${k.path}/`))&&r.closeFile();let e=ku(k.path).includes("/")?k.path.split("/").slice(0,-1).join("/"):"";await n.reloadDir(e),N({path:null,isDir:!1})}(0,f.useEffect)(()=>{let e=new URLSearchParams(window.location.search);w("1"===e.get("embed")&&"1"!==e.get("chrome"))},[]),(0,f.useEffect)(()=>{i&&m(!0)},[i]),(0,f.useEffect)(()=>{fl.getState().load()},[]),(0,f.useEffect)(()=>{let e=()=>{tA.getState().loadActivity()};e();let t=setInterval(e,1e4);return()=>clearInterval(t)},[]),(0,f.useEffect)(()=>{ki.getState().loadForWorkspace(e.activeWorkspaceId),nY.getState().loadForWorkspace(e.activeWorkspaceId)},[e.activeWorkspaceId]),(0,f.useEffect)(()=>{let e=[...j.map(e=>e.path),...E.slice(0,8).map(e=>e.path)].filter((e,t,n)=>nH(e)&&n.indexOf(e)===t).slice(0,12);if(0===e.length)return;let t=("requestIdleCallback"in window?e=>window.requestIdleCallback(e):e=>window.setTimeout(e,400))(()=>{for(let t of e)tK(t)});return()=>{"cancelIdleCallback"in window?window.cancelIdleCallback(t):clearTimeout(t)}},[j,E]),(0,f.useEffect)(()=>{r.clearFile()},[e.activeWorkspaceId,r.clearFile]),(0,f.useEffect)(()=>{n.rootLoaded&&r.markRootLoaded()},[n.rootLoaded,r.markRootLoaded]);let O=(0,r$.useViewWidthStore)(e=>e.width),_=(0,r$.useViewWidthStore)(e=>e.align),D=(0,r$.useViewWidthStore)(e=>e.setWidth),R=(0,r$.useViewWidthStore)(e=>e.setAlign),I=null===r.openFileViewerKind||"editor"===r.openFileViewerKind||"text"===r.openFileViewerKind||"source"===r.openFileViewerKind||"notebook"===r.openFileViewerKind||"fallback"===r.openFileViewerKind,L=I?r$.VIEW_WIDTH_CLASS[O]:"",P=I?r$.VIEW_ALIGN_CLASS[_]:"",z=(0,f.useCallback)((t,n)=>(0,s.jsx)(nQ,{doc:r,node:t,extraItems:n,activeWorkspaceId:e.activeWorkspaceId}),[r,e.activeWorkspaceId]);return(0,s.jsxs)("div",{className:"flex h-screen gap-0 overflow-hidden bg-background",children:[null===e.rootConfigured&&(0,s.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,s.jsx)(u.Loader2,{className:"h-5 w-5 animate-spin text-muted-foreground"})}),!1===e.rootConfigured&&(0,s.jsx)(te,{onSelect:t=>{let n=new URL(location.href);n.searchParams.set("ws",t),n.searchParams.delete("path"),history.replaceState(null,"",n.toString()),e.setRootConfigured(!0),e.setActiveWorkspaceId(t),e.loadWorkspaces()}}),!0===e.rootConfigured&&e.addingWorkspace&&(0,s.jsxs)("div",{className:"flex-1 flex flex-col",children:[(0,s.jsx)("div",{className:"flex items-center justify-end border-b px-3 py-2 bg-muted shrink-0",children:(0,s.jsxs)(v.Button,{size:"sm",variant:"ghost",className:"h-7 gap-1.5 text-xs",onClick:()=>e.setAddingWorkspace(!1),children:[(0,s.jsx)(h,{className:"h-3.5 w-3.5"})," Cancel"]})}),(0,s.jsx)(te,{onSelect:t=>{e.setAddingWorkspace(!1),e.loadWorkspaces(),e.switchWorkspace(t)}})]}),!0===e.rootConfigured&&!e.addingWorkspace&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(r4,{workspace:e,doc:r,fileTree:n,upload:S,isMobile:i,hideChrome:y,sidebarCollapsed:o,setSidebarCollapsed:m,favorites:j,recents:E,activePaths:A,setDeleting:N,setDialogs:x}),(0,s.jsxs)("div",{className:"flex-1 flex flex-col min-w-0 relative",children:[!y&&o&&(0,s.jsx)(v.Button,{size:"sm",variant:"ghost",className:"hidden md:flex absolute left-2 top-2 z-10 h-7 w-7 p-0",title:"Show sidebar",onClick:()=>m(!1),children:(0,s.jsx)(p,{className:"h-3.5 w-3.5"})}),!y&&(0,s.jsxs)("div",{className:"md:hidden flex h-11 shrink-0 items-center justify-between gap-2 border-b bg-muted px-1",children:[(0,s.jsx)(v.Button,{size:"sm",variant:"ghost",className:"h-9 w-9 p-0",title:"Show sidebar",onClick:()=>{m(!1),tA.getState().close()},children:(0,s.jsx)(p,{className:"h-4 w-4"})}),(0,s.jsxs)("span",{className:"flex min-w-0 items-center gap-1.5 text-xs font-semibold tracking-tight text-muted-foreground",title:r.openFile?.path,children:[r.openFile&&(0,s.jsx)("span",{className:"shrink-0",children:"app"===r.openFileViewerKind||"html"===r.openFileViewerKind?(0,s.jsx)(c,{className:"h-4 w-4 text-foreground/70"}):nU(r.openFile.name)?(0,s.jsx)(d.Image,{className:"h-4 w-4 text-sunshine-700"}):nF(r.openFile.name)?(0,s.jsx)(l.FileText,{className:"h-4 w-4 text-foreground/70"}):(0,s.jsx)(l.FileText,{className:"h-4 w-4 text-foreground/60"})}),(0,s.jsx)("span",{className:"truncate",children:r.openFile?r.openFile.name:"Wiki Viewer"})]}),(0,s.jsx)(v.Button,{size:"sm",variant:"ghost",className:"h-9 w-9 p-0",title:"AI Agent panel",onClick:()=>{tA.getState().open(),m(!0)},children:(0,s.jsx)(a,{className:"h-4 w-4"})})]}),r.openFile?(0,s.jsx)(ke,{openFile:r.openFile,fileContent:r.fileContent,fileRevision:r.fileRevision,fileLoading:r.fileLoading,editing:r.editing,setEditing:r.setEditing,editContent:r.editContent,setEditContent:r.setEditContent,saving:r.saving,saveError:r.saveError,onSave:r.handleSave,gitFileInfo:C.gitFileInfo,showHistory:C.showHistory,historyLoading:C.historyLoading,historyCommits:C.historyCommits,selectedDiffSha:C.selectedDiffSha,diffContent:C.diffContent,diffLoading:C.diffLoading,onToggleHistory:()=>C.setShowHistory(e=>!e),onSelectDiff:C.selectDiff,gateBypassPath:r.gateBypassPath,onBypassGate:r.bypassGate,onRefresh:r.handleRefresh,onShare:()=>x(e=>({...e,shareDialogOpen:!0})),onClose:()=>{r.closeFile()},renderCopyMenu:z,appKey:r.appKey,setAppKey:r.setAppKey,appFullscreen:r.appFullscreen,setAppFullscreen:r.setAppFullscreen,viewerKey:r.viewerKey,setViewerKey:r.setViewerKey,htmlSourceMode:r.htmlSourceMode,setHtmlSourceMode:r.setHtmlSourceMode,widthAwareViewer:I,viewWidth:O,viewAlign:_,setViewWidth:D,setViewAlign:R,contentWidthClass:L,contentAlignClass:P,isMobile:i,sidebarCollapsed:o}):(0,s.jsx)("div",{className:"flex-1 flex flex-col items-center justify-center",children:(0,s.jsxs)("div",{className:"flex flex-col items-center gap-2 text-center px-4",children:[(0,s.jsx)(l.FileText,{className:"h-8 w-8 text-muted-foreground"}),(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:"Select a file to view or edit"})]})})]}),(0,s.jsx)(tj,{open:b.shareDialogOpen,onOpenChange:e=>x(t=>({...t,shareDialogOpen:e})),filePath:r.openFile?.path??""}),!(0,ev.isLite)()&&(0,s.jsx)(eK,{open:b.settingsOpen,onOpenChange:e=>x(t=>({...t,settingsOpen:e}))}),(0,s.jsx)(t9,{currentPath:r.openFile?.path}),(0,s.jsx)("input",{ref:S.fileInputRef,type:"file",multiple:!0,className:"hidden",onChange:e=>{e.target.files&&S.doUpload(e.target.files)}}),(0,s.jsx)(e0,{open:!!k.path,onOpenChange:e=>{e||N({path:null,isDir:!1})},title:k.isDir?"Delete folder?":"Delete file?",description:k.isDir?`"${ku(k.path??"")}" and all its contents will be permanently deleted.`:`"${ku(k.path??"")}" will be permanently removed.`,onConfirm:T}),(0,s.jsx)(e0,{open:!!e.deletingWorkspaceId,onOpenChange:t=>{t||e.setDeletingWorkspaceId(null)},title:"Delete workspace?",description:`"${e.workspaces.find(t=>t.id===e.deletingWorkspaceId)?.name??""}" will be removed from the workspace list. Files on disk are NOT deleted.`,onConfirm:()=>void e.handleDeleteWorkspace(async t=>{await e.switchWorkspace(t),r.clearFile()})})]})]},e.activeWorkspaceId??"none")}],952683)}]);
|