const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["https://assets-proxy.anthropic.com/claude-ai/v2/assets/v1/vendor-ant-cds-G1fENYYx.css","https://assets-proxy.anthropic.com/claude-ai/v2/assets/v1/c818056db-BjS1Z-Ak.css","https://assets-proxy.anthropic.com/claude-ai/v2/assets/v1/c0632795f-BhNFJsPB.css"])))=>i.map(i=>d[i]);
import{r as e,j as t,_ as n,a as r,g as s,R as i,s as o,w as a,c as l}from"./vendor-react-RSDKEZ60.js";import{bb as c,h as d,m as u,AP as p,fg as h,a3 as f,AQ as m,ae as g,AR as b,AS as y,ex as v,eM as w,AT as x,AU as k,et as S,AV as E,AW as M,tz as _,df as N,AX as C,an as O,AY as A,I as T,y as I,he as D,AZ as R,wR as L,A_ as P,A$ as j,B0 as B,B1 as z,B2 as $,B3 as F,B4 as H,B5 as U,B6 as q,B7 as V,B8 as K,B9 as W,Ba as G,Bb as J,w as Z,x as Q,Bc as X,ev as Y,Bd as ee,Be as te,fO as ne,hW as re,m4 as se,Bf as ie,L as oe,Bg as ae,Bh as le,Bi as ce,Bj as de,Bk as ue,a6 as pe,Bl as he,Bm as fe,Bn as me,Bo as ge,Bp as be,hV as ye,Bq as ve,Br as we,h5 as xe,Bs as ke,Bt as Se,Bu as Ee,Bv as Me,Bw as _e,k as Ne,b as Ce,fZ as Oe,hJ as Ae,m5 as Te,Bx as Ie,By as De,Bz as Re,b8 as Le,BA as Pe,BB as je,BC as Be,BD as ze,BE as $e,BF as Fe,BG as He,BH as Ue,BI as qe,BJ as Ve,BK as Ke,iJ as We,BL as Ge,BM as Je,BN as Ze,BO as Qe,BP as Xe,BQ as Ye,pi as et,f as tt,U as nt,X as rt,BR as st,BS as it,o as ot,Q as at,zv as lt,at as ct,BT as dt,mb as ut,BU as pt,q as ht,BV as ft,q_ as mt,BW as gt,ca as bt,tu as yt,c6 as vt,ht as wt,hu as xt,aq as kt,BX as St,BY as Et,BZ as Mt,eg as _t,a9 as Nt,B_ as Ct,dS as Ot,dM as At,aC as Tt,bR as It,a0 as Dt,ga as Rt,cY as Lt,gW as Pt,ba as jt,B$ as Bt,C0 as zt,C1 as $t,ma as Ft,C as Ht,eL as Ut,C2 as qt,oM as Vt,jx as Kt,jy as Wt,gD as Gt,b_ as Jt,gG as Zt,gI as Qt,gJ as Xt,xn as Yt,xm as en,xp as tn,xq as nn,gH as rn,b9 as sn,g1 as on,C3 as an,h4 as ln,fd as cn,C4 as dn,m2 as un,C5 as pn,C6 as hn,C7 as fn,bN as mn,cX as gn,C8 as bn,C9 as yn,Ca as vn,u as wn,pf as xn,Cb as kn,Cc as Sn,Cd as En,Ce as Mn,Cf as _n,Cg as Nn,qZ as Cn,Ch as On,mR as An,p3 as Tn,ay as In,Ci as Dn,cM as Rn,ez as Ln,Cj as Pn,v_ as jn,Ck as Bn,en as zn,jv as $n,ui as Fn,Cl as Hn,rA as Un,A as qn,S as Vn,$ as Kn,N as Wn}from"./c818056db-BBpc4u6S.js";import{s as Gn,c as Jn,p as Zn,u as Qn}from"./vendor-zustand-IIUY2Tf-.js";import{u as Xn,f as Yn,c as er}from"./vendor-query-AdjnXGiH.js";import{H as tr,I as nr}from"./vendor-lodash-wKOE1Xsv.js";import{o as rr,n as sr,b as ir,r as or,s as ar,u as lr,i as cr,j as dr}from"./vendor-zod-D1-NLVm9.js";import{u as ur,M as pr}from"./vendor-intl-BNW8a19h.js";import{b as hr}from"./vendor-icons-CjJMeNuY.js";import{T as fr,P as mr,B as gr,m as br,n as yr,I as vr,a as wr,M as xr,d as kr,C as Sr,U as Er,f as Mr,w as _r}from"./vendor-ant-cds-CBh5POw1.js";import{u as Nr,x as Cr,y as Or,t as Ar,z as Tr,v as Ir,r as Dr,a0 as Rr,a1 as Lr,a2 as Pr,a3 as jr,a4 as Br,a5 as zr,a6 as $r,a7 as Fr,a8 as Hr,a9 as Ur,aa as qr}from"./vendor-radix-qP6Vhe7Y.js";import{a1 as Vr,a8 as Kr,a2 as Wr,a3 as Gr,a4 as Jr}from"./vendor-base-ui-DCHlJbY9.js";import{C as Zr}from"./c5669b8e4-Crc1rGjx.js";const Qr=["mousedown","touchstart"];function Xr(t,n,r){const s=e.useRef(null);return e.useEffect(()=>{const e=e=>{const{target:n}=e??{};if(Array.isArray(r)){const s=n?.hasAttribute("data-ignore-outside-clicks")||!document.body.contains(n)&&"HTML"!==n.tagName;r.every(t=>!!t&&!e.composedPath().includes(t))&&!s&&t()}else s.current&&!s.current.contains(n)&&t()};return(n||Qr).forEach(t=>document.addEventListener(t,e)),()=>{(n||Qr).forEach(t=>document.removeEventListener(t,e))}},[s,t,r]),s}const Yr={x:0,y:0,width:0,height:0,top:0,left:0,bottom:0,right:0};function es(t){const n=e.useRef(0),r=e.useRef(null),[s,i]=e.useState(Yr),o=e.useMemo(()=>"undefined"!=typeof window?new ResizeObserver(e=>{const t=e[0];t&&(cancelAnimationFrame(n.current),n.current=requestAnimationFrame(()=>{if(r.current){const e=t.borderBoxSize?.[0]||t.contentBoxSize?.[0];if(e){const n=e.inlineSize,r=e.blockSize;i({width:n,height:r,x:t.contentRect.x,y:t.contentRect.y,top:t.contentRect.top,left:t.contentRect.left,bottom:t.contentRect.bottom,right:t.contentRect.right})}else i(t.contentRect)}}))}):null,[]);return e.useEffect(()=>(r.current&&o?.observe(r.current,t),()=>{o?.disconnect(),n.current&&cancelAnimationFrame(n.current)}),[r.current]),[r,s]}function ts(t){const n=e.useRef(void 0);return e.useEffect(()=>{n.current=t},[t]),n.current}const ns=e=>t.jsx(c,{...e,children:t.jsx("path",{d:"M6.068 2.161a2.72 2.72 0 0 1 3.524 1.533l3.206 8.14a1.61 1.61 0 0 1-.907 2.087l-.076.03a1.61 1.61 0 0 1-2.087-.908L8.027 8.726a.5.5 0 0 1 .93-.367l1.702 4.318a.61.61 0 0 0 .79.343l.076-.03a.61.61 0 0 0 .343-.79L8.662 4.06a1.72 1.72 0 0 0-2.227-.968l-.154.06a1.72 1.72 0 0 0-.97 2.228l3.87 9.821a2.826 2.826 0 0 0 3.665 1.594l.23-.09a2.83 2.83 0 0 0 1.595-3.666l-2.363-6a.5.5 0 1 1 .93-.366l2.363 6a3.826 3.826 0 0 1-2.158 4.962l-.23.09a3.827 3.827 0 0 1-4.963-2.157L4.382 5.747a2.72 2.72 0 0 1 1.532-3.525z"})});function rs(e){if(!e)return null;const t=e.match(/^https?:\/\/([^/]+)\/([^/]+)\/([^/?#]+?)(?:\.git)?(?:[?#]|$)/);if(!(t&&t[1]&&t[2]&&t[3]))return null;const n=t[1],r={name:t[3],owner:{login:t[2]},default_branch:"main"};return"github.com"!==n&&"www.github.com"!==n&&(r.ghe={host:`https://${n}`,configuration_id:0}),r}const ss={prompt:"",workerId:"",repos:[],actAsClaudeBot:!1,autofixOnPrCreate:void 0,model:null};function is(e){if(!e)return ss;const t=e.ccr,n=t?.environment_id||t?.self_hosted_runner_pool_id||"",r=t?.events,s=(Array.isArray(r)?r.find(e=>e?.data?.message):void 0)?.data,i=s?.message,o=i?.content;let a="";if("string"==typeof o)a=o;else if(Array.isArray(o)){const e=[];for(const t of o)"object"==typeof t&&null!==t&&"text"in t&&"string"==typeof t.text&&e.push(t.text);a=e.join("\n")}const l=t?.session_context,c=l?.sources??[],d=[];for(const f of c)if(f.git_repository?.url){const e=rs(f.git_repository.url);e&&d.push(e)}const u=l?.model??null,p=!0===l?.act_as_claude_bot,h=l?.autofix_on_pr_create;return{prompt:a,workerId:n,repos:d,actAsClaudeBot:p,autofixOnPrCreate:h,model:u}}const as={name:"Default",kind:"anthropic_cloud",description:"Default - trusted network access",config:{environment_type:"anthropic",cwd:"/home/user",init_script:null,environment:{},languages:[{name:"python",version:"3.11"},{name:"node",version:"20"}],network_config:{allowed_hosts:[],allow_default_hosts:!0}}},ls=e=>"/code"===e||e.startsWith("/code/")||e.startsWith(y)||e.startsWith(v),cs=(e=!0)=>{const{activeOrganization:t}=d(),n=t?.uuid,r=u("3540182858"),s=p(ls),i=h("tengu_ccr_bridge_environment_polling_interval_ms","value",6e4,b);return f(`/v1/environment_providers/private/organizations/${n||""}/environments?limit=1000`,{queryKey:[m,{orgUuid:n}],enabled:Boolean(n)&&e,staleTime:6e4,refetchOnWindowFocus:"always",refetchInterval:!!(s&&r&&i>0)&&Math.max(i,3e4),meta:{noToast:!0}})},ds=(t=!0)=>{const{data:n}=cs(t),[r,s]=e.useReducer((e,t)=>{const n=t.filter(t=>"bridge"===t.kind&&!e.has(t.environment_id));if(0===n.length)return e;const r=new Set(e);for(const s of n)r.add(s.environment_id);return r},new Set);return e.useEffect(()=>{n?.environments&&s(n.environments)},[n?.environments]),r},us=(e,t=!0)=>{const{activeOrganization:n}=d(),r=n?.uuid;return f(`/v1/environment_providers/private/organizations/${r||""}/environments/${e}`,{queryKey:[m,{orgUuid:r,environmentId:e}],enabled:Boolean(r)&&Boolean(e)&&t,staleTime:6e4,meta:{noToast:!0}})},ps=e=>{const{activeOrganization:t}=d(),n=t?.uuid,r=Xn();return g(`/v1/environment_providers/private/organizations/${n||""}/cloud/create`,"POST",{onSuccess:t=>{r.setQueryData([m,{orgUuid:n}],e=>e?{...e,environments:[t,...e.environments??[]]}:e),r.invalidateQueries({queryKey:[m]}),e?.onSuccess?.(t)},onError:e?.onError})},hs=(e,t)=>{const{activeOrganization:n}=d(),r=n?.uuid,s=Xn();return g(`/v1/environment_providers/private/organizations/${r||""}/environments/${e}`,"POST",{onSuccess:()=>{s.invalidateQueries({queryKey:[m]}),s.invalidateQueries({queryKey:[m,{orgUuid:r,environmentId:e}]}),t?.onSuccess?.()},onError:t?.onError})},fs=(e,t)=>{const{activeOrganization:n}=d(),r=n?.uuid,s=Xn();return g(`/v1/environment_providers/private/organizations/${r||""}/environments/${e}/archive`,"POST",{onSuccess:()=>{s.invalidateQueries({queryKey:[m]}),t?.onSuccess?.()},onError:t?.onError})};function ms(e,t){return`${e}/${t}`.toLowerCase()}function gs(e){const t=e.repoInfo;if(t)return t.owner?ms(t.owner,t.name):"local"===e.type&&e.cwd?e.cwd.replace(/[/\\]+$/,""):t.name}function bs(e){if("bridge"!==e.kind||"active"!==e.state)return;const{git_repo_url:t}=e.bridge_info??{},n=t?x(t):void 0;if(!n)return;const[r,s]=n.split("/");return{key:ms(r,s),name:s,owner:r,localPath:null,latestTimestamp:new Date(e.created_at).getTime()||0,environmentId:e.environment_id}}const ys=[];function vs(t,n="recent",r=ys){const{data:s}=cs(),i=s?.environments;return e.useMemo(()=>{const e=Array.isArray(r)?r:ys,s=new Map;for(const t of i??[]){const e=bs(t);e&&!s.has(e.key)&&s.set(e.key,{...e,hasActive:!1})}for(const n of t){const e=gs(n);if(!e)continue;const t="running"===n.sessionStatus||"requires_action"===n.sessionStatus,r=new Date(n.timestamp).getTime(),i=s.get(e);if(i)t&&(i.hasActive=!0),r>i.latestTimestamp&&(i.latestTimestamp=r),"local"===n.type&&n.cwd&&!i.localPath&&(i.localPath=w(n.cwd,n.homePath));else{const i=n.repoInfo,o=i?.owner||null,a="local"===n.type&&n.cwd?w(n.cwd,n.homePath):null;s.set(e,{hasActive:t,name:i?.name??e,owner:o,localPath:a,latestTimestamp:r})}}const o=new Map;for(const t of s.values())o.set(t.name,(o.get(t.name)??0)+1);const a=[];for(const[t,n]of s){const e=(o.get(n.name)??0)>1,r=!!n.owner;let s=null;if(e)if(r)s=n.owner;else if(n.localPath){const e=Math.max(n.localPath.lastIndexOf("/"),n.localPath.lastIndexOf("\\"));s=e>0?n.localPath.slice(0,e):n.localPath}a.push({key:t,name:n.name,isRepo:r,hasActiveSessions:n.hasActive,disambiguationText:s,environmentId:n.environmentId,latestTimestamp:n.latestTimestamp})}if("name"===n)a.sort((e,t)=>e.name.localeCompare(t.name)||(e.disambiguationText??"").localeCompare(t.disambiguationText??""));else if("manual"===n&&e.length>0){const t=new Map(e.map((e,t)=>[e,t]));a.sort((e,n)=>{const r=t.get(e.key),s=t.get(n.key);return void 0===r&&void 0===s?n.latestTimestamp-e.latestTimestamp:void 0===r?1:void 0===s?-1:r-s})}else a.sort((e,t)=>t.latestTimestamp-e.latestTimestamp);return a},[t,i,n,r])}function ws(e){let t=null,n=!1;const r=t=>e?.accountScoped?t:`persisted.${t}`,s=e=>{if(!e||"undefined"==typeof window)return null;try{const t=window.localStorage.getItem(e);return t?JSON.parse(t):null}catch{return null}},i=(i,o)=>{const a=o??s(r(i))??s(i)??s(e?.legacyLocalStorageKey);return t=a?.state??null,n=!0,a};return{getItem:e=>k.isSettled()?i(e,k.read(e)):new Promise(t=>{const n=k.subscribe(()=>{k.isSettled()&&(n(),t(i(e,k.read(e))))})}),setItem:(e,s)=>{if(n&&(null===t||!Gn(t,s.state))&&(t=s.state,k.write(e,s),"undefined"!=typeof window))try{window.localStorage.setItem(r(e),JSON.stringify(s))}catch{}},removeItem:e=>{if(t=null,k.write(e,void 0),"undefined"!=typeof window)try{window.localStorage.removeItem(r(e)),window.localStorage.removeItem(e)}catch{}}}}function xs(e){const t=/^([^/\\:]+)\/([^/\\]+)$/.exec(e);return t?ms(t[1],t[2]):e}const ks=Jn()(Zn(()=>({sessions:[],isInitialized:!1,draftSession:null,draftInheritedContext:null,selectedProjects:[]}),{name:"ccd-sessions-filter",storage:ws({accountScoped:!0}),partialize:e=>({selectedProjects:e.selectedProjects}),merge:(e,t)=>{const n=e??{};return{...t,selectedProjects:Array.isArray(n.selectedProjects)?(r=n.selectedProjects,Array.from(new Set(r.filter(e=>"string"==typeof e).map(xs)))):t.selectedProjects};var r}}));function Ss(e,t){ks.setState({selectedProjects:e,draftInheritedContext:t})}function Es(){return ks(e=>e.selectedProjects)}function Ms(){const e=`draft_${crypto.randomUUID()}`,{draftInheritedContext:t}=ks.getState();return ks.setState({draftSession:{id:e,projectKey:t?.projectKey??null,inheritedContext:t,createdAt:(new Date).toISOString()}}),e}function _s(){ks.setState({draftSession:null})}function Ns(){return ks(e=>e.draftSession)}function Cs(){const{setWorker:e,setSelectedFolder:t,setHostKey:n,applyLocalFolderPick:r}=N.getState();N.setState({currentHostKey:void 0,trustedSelectedFolder:null});const{selectedProjects:s,draftInheritedContext:i}=ks.getState();0!==s.length&&i?"local"===i.sessionType?i.folder?r(i.folder):(e({type:"environment",id:C}),n("local"),t(null)):(i.environmentId&&e({type:"environment",id:i.environmentId}),t(null)):t(null)}const Os=new Set,As=new Map;function Ts(e,t){if(Os.has(e.sessionId))return;const n=As.get(e.sessionId);As.delete(e.sessionId);const r=void 0===e.title&&!t?.allowTitleClear;ks.setState(t=>{const s=t.sessions.findIndex(t=>t.sessionId===e.sessionId);if(s>=0){const i=t.sessions[s],o="number"==typeof i.lastActivityAt&&(e.lastActivityAt??0)<i.lastActivityAt,a=r?n??i.title:void 0,l=function(e,t){if(!e||!t||e.length<2)return;const n=new Map(t.map((e,t)=>[e.id,t])),r=[...e].sort((e,t)=>(n.get(e.id)??Number.MAX_SAFE_INTEGER)-(n.get(t.id)??Number.MAX_SAFE_INTEGER));return r.some((t,n)=>t.id!==e[n]?.id)?r:void 0}(e.backgroundTaskSuggestions,i.backgroundTaskSuggestions),c=o||l||void 0!==a?{...e,...o&&{lastActivityAt:i.lastActivityAt},...void 0!==a&&{title:a},...l&&{backgroundTaskSuggestions:l}}:e;if(tr(i,c))return t;const d=[...t.sessions];return d[s]=c,{sessions:d}}return{sessions:[...t.sessions,r&&void 0!==n?{...e,title:n}:e]}})}function Is(e,t){const n=ks.getState().sessions.findIndex(t=>t.sessionId===e);n<0?"string"!=typeof t.title||""===t.title||Os.has(e)||As.set(e,t.title):ks.setState(e=>{const r={...e.sessions[n],...t};if(tr(e.sessions[n],r))return e;const s=[...e.sessions];return s[n]=r,{sessions:s}})}function Ds(e){const t=_(e);return ks.getState().sessions.find(e=>e.bridgeSessionId&&_(e.bridgeSessionId)===t||(e.bridgeSessionIds?.some(e=>_(e)===t)??!1))?.sessionId}function Rs(e){const t=ks.getState().sessions.find(t=>t.sessionId===e);if(!t)return[];const n=new Set;return Ls(t,n),[...n]}function Ls(e,t){e.bridgeSessionId&&t.add(_(e.bridgeSessionId));for(const n of e.bridgeSessionIds??[])t.add(_(n))}function Ps(e){Os.add(e)}function js(e){return Os.has(e)}function Bs(e){Os.delete(e)}function zs(e){Os.add(e),As.delete(e),ks.setState(t=>{const n=t.sessions.filter(t=>t.sessionId!==e);return n.length===t.sessions.length?t:{sessions:n}}),E.getState().clearSession(e),M.getState().removePrsForSession(e)}async function $s(e=!1){if(!S?.getAll)return Hs=null,void ks.setState({isInitialized:!0});try{const t=performance.now(),r=await S.getAll(),s=0===As.size?r:r.map(e=>{const t=As.get(e.sessionId);return void 0===t?e:(As.delete(e.sessionId),void 0===e.title?{...e,title:t}:e)});ks.setState({sessions:s,isInitialized:!0});const i=performance.now()-(Hs??t);Hs=null;const{performanceMetrics:o}=await n(async()=>{const{performanceMetrics:e}=await import("./c818056db-BBpc4u6S.js").then(e=>e.a1a);return{performanceMetrics:e}},__vite__mapDeps([0,1]),import.meta.url);o.trackSessionListReady(i,{session_count:r.length,is_reinit:e})}catch{Hs=null,ks.setState({isInitialized:!0})}}let Fs=!1,Hs=null;function Us(){Fs||(Fs=!0,Hs=performance.now(),$s(),S?.onOnEvent&&S.onOnEvent(e=>{const{type:t,sessionId:n}=e;switch(t){case"session_updated":case"close":case"error":case"start":case"cleared":case"stopped":case"paused":case"tool_permission_request":case"tool_permission_resolved":{const r={allowTitleClear:"cleared"===t};e.session?Ts(e.session,r):n&&async function(e,t){if(S?.getSession)try{const n=await S.getSession(e);n&&Ts(n,t)}catch{}}(n,r);break}case"archived":n&&function(e){Os.add(e),ks.setState(t=>{const n=t.sessions.findIndex(t=>t.sessionId===e);if(n<0)return t;const r=[...t.sessions];return r[n]={...r[n],isArchived:!0,worktreePath:void 0,worktreeName:void 0},{sessions:r}}),E.getState().clearSession(e),M.getState().removePrsForSession(e)}(n);break;case"unarchived":n&&(!function(e){Bs(e),Is(e,{isArchived:!1})}(n),e.session&&Ts(e.session));break;case"deleted":n&&zs(n);break;case"initialized":$s(!0)}}))}function qs(){const t=ks(e=>e.sessions),n=ks(e=>e.isInitialized);return e.useMemo(()=>n?t.filter(e=>!e.isArchived).sort((e,t)=>{const n=e.lastActivityAt??e.createdAt??0;return(t.lastActivityAt??t.createdAt??0)-n}):[],[t,n])}function Vs(e){return ks(t=>e?t.sessions.find(t=>t.sessionId===e)?.title:void 0)}function Ks(){const t=ks(e=>e.sessions),n=ks(e=>e.isInitialized);return e.useMemo(()=>n?[...t].sort((e,t)=>{const n=e.lastActivityAt??e.createdAt??0;return(t.lastActivityAt??t.createdAt??0)-n}):[],[t,n])}function Ws(e){return ks(t=>e?t.sessions.reduce((t,n)=>n.isArchived||n.cwd!==e?t:t+1,0):0)}function Gs(){return ks(e=>e.isInitialized)}const Js=rr({enabled:ir().catch(!1),pollBaseMs:sr().min(5e3).max(36e5).catch(3e4),pollCapMs:sr().min(1e4).max(864e5).catch(3e5)}).catch({enabled:!1,pollBaseMs:3e4,pollCapMs:3e5}).transform(e=>({...e,pollCapMs:Math.max(e.pollCapMs,e.pollBaseMs)})),Zs=Js.parse(null);function Qs(){return O("amber_harbor_lantern",Zs,Js)}const Xs=6e5;let Ys;function ei(){return Ys??=5e3*Math.random(),Ys}function ti(e){if("running"===e.session_status)return!0;if("pending"!==e.session_status)return!1;const t="number"==typeof e.created_at?e.created_at:Date.parse(e.created_at??""),n=Date.now()-t;return Number.isFinite(n)&&n<Xs}function ni(e,t,n,r){return t?n:Math.min(2*e,r)}function ri({enabled:t,inFlight:n,telemetryTag:r,emitTelemetry:s=!0}){const i=Qs(),o=t&&i.enabled,a=T(),{track:l}=I(),[c,d]=e.useState(!0),[u,p]=e.useState(()=>Yn.isFocused()),h=e.useRef(l),f=e.useRef(r),m=e.useRef(s);e.useEffect(()=>{h.current=l,f.current=r,m.current=s},[l,r,s]);const g=e.useRef(!1),b=a?"desktop":"web",y=e.useRef(null);e.useEffect(()=>{if(o)return p(Yn.isFocused()),Yn.subscribe(p)},[o]),e.useEffect(()=>{if(!o||!c||u||n)return;const e=D?.getVisibility,t=D?.onVisibilityChanged;if(!e||!t)return;let r=!1,s=!1;const i=()=>{s||(s=!0,null===y.current&&(y.current=Date.now(),g.current=m.current,m.current&&h.current({event_key:"claudeai.television.sessions_watch.demand_suppressed",watch_tags:f.current,platform:b})),d(!1))},a=()=>function(e,t,n){let r;try{r=e()}catch{return void(t()||n())}Promise.resolve(r).then(e=>{e||t()||n()},()=>{t()||n()})}(e,()=>r,i);a();const l=t(e=>{e||a()});return()=>{r=!0,l()}},[o,c,u,n,b]),e.useEffect(()=>{c||o&&!u&&!n||d(!0)},[o,c,u,n]);const v=function(t,{delayMs:n,immediate:r}){const[s,i]=e.useState(t);return e.useEffect(()=>{if(!t||r)return void i(t);if(s)return;const e=setTimeout(()=>i(!0),n());return()=>clearTimeout(e)},[t,r,s,n]),s}(c,{delayMs:ei,immediate:n||!o}),w=!o||v,x=e.useRef(w);return e.useEffect(()=>{if(x.current===w)return;if(x.current=w,!w)return;const e=y.current;y.current=null;const t=g.current;g.current=!1,null!==e&&t&&h.current({event_key:"claudeai.television.sessions_watch.demand_restored",watch_tags:f.current,platform:b,suppressed_duration_ms:Date.now()-e,trigger:o?n?"in_flight":"focus":"gate_off"})},[w,o,n,b]),w}function si({enabled:t,telemetryTag:n,emitTelemetry:r=!0}){const s=A();return ri({enabled:t,inFlight:e.useMemo(()=>s?.some(ti)??!1,[s]),telemetryTag:n,emitTelemetry:r})}const ii="__warming__",oi="undefined"!=typeof Intl&&"Segmenter"in Intl?new Intl.Segmenter(void 0,{granularity:"grapheme"}):null;function ai(e,t){if(e.length<=t)return e;if(!oi)return e.slice(0,t);let n=0;for(const{segment:r}of oi.segment(e)){if(n+r.length>t)break;n+=r.length}return e.slice(0,n)}const li=new Set(["low","medium","high","xhigh","max"]),ci=new Map;function di(e,t){const n=t.then(()=>{},()=>{});ci.set(e,n),n.finally(()=>{ci.get(e)===n&&ci.delete(e)})}function ui(e){return ci.get(e)??Promise.resolve()}const pi=new Set,hi=new Map,fi=new Map;function mi(e,t){const n=R(e),r=fi.get(n)??new Set;return r.add(t),fi.set(n,r),()=>{r.delete(t),0===r.size&&fi.delete(n)}}function gi(e){const t=R(e.sessionId),n=hi.get(t);return!(!n||!n.committed)&&(hi.delete(t),(n.model===e.sessionModel||void 0===n.warmModel||n.warmModel===e.sessionModel)&&((void 0===e.lastSentModelRef.current||e.lastSentModelRef.current===e.sessionModel||e.lastSentModelRef.current===n.model)&&(e.lastSentModelRef.current=n.model,e.lastCommittedModelRef.current=n.model,n.model!==e.sessionModel&&e.patchSessionModel(n.model),!0)))}const bi=new Map,yi=new Map;function vi(e,t){const n=R(e),r=yi.get(n)??new Set;return r.add(t),yi.set(n,r),()=>{r.delete(t),0===r.size&&yi.delete(n)}}function wi(e){const t=R(e.sessionId),n=bi.get(t);return!(!n||!n.committed)&&(bi.delete(t),(n.effort===e.sessionEffort||void 0===n.warmEffort||n.warmEffort===e.sessionEffort)&&((void 0===e.lastSentEffortRef.current||e.lastSentEffortRef.current===e.sessionEffort||e.lastSentEffortRef.current===n.effort)&&(e.lastSentEffortRef.current=n.effort,e.lastCommittedEffortRef.current=n.effort,n.effort!==e.sessionEffort&&e.patchSessionEffort(n.effort),!0)))}function xi(e){return pi.has(R(e))}async function ki(e,t,n){const r=W(),s=await e.rawFetch(`/api/organizations/${e.orgUuid}/cowork/sessions`,{method:"POST",body:JSON.stringify({title:ii,...t.model&&{model:t.model},...t.effortLevel&&{effort_level:t.effortLevel},...t.localMcps?.length?{local_mcps:t.localMcps}:{},...t.projectUuid?{project_uuid:t.projectUuid}:{},...t.hasSpace?{has_space:!0}:{},...r&&{computer_tools:r},...n?{bind_attestation:{kid:n.kid,signature:n.signature,issued_at:n.issuedAt}}:{}})});if(!s.ok)throw new Error(`warmRemoteCoworkSession: HTTP ${s.status}`);const{session:i}=await s.json();if(!i?.id)throw new Error("warmRemoteCoworkSession: no session id in response");return G("warmRemoteCoworkSession",n,i.bound_device_uuid),n&&(i.bound_device_uuid===n.rowPk?J(i.id,n.rowPk):i.bound_device_uuid?Z.error(Q.LOCAL_SESSION,"warm bind: server bound a different device than attested; not recording"):Z.warn(Q.LOCAL_SESSION,"warm bind requested but server created session unbound; staying td-v1")),X(i.id,0),{sessionId:i.id}}async function Si(e,t,n,r,s){const i=n.messageUuid??L(),o=[],a=n.model&&n.model!==r.model?n.model:void 0;a&&function(e,t){hi.set(R(e),t)}(t,{model:a,warmModel:r.model,committed:!1});const l=n.effortLevel&&n.effortLevel!==r.effortLevel&&li.has(n.effortLevel)?n.effortLevel:void 0;l&&function(e,t){bi.set(R(e),t)}(t,{effort:l,warmEffort:r.effortLevel,committed:!1});const c=n.message?.split("<")[0]?.trim(),d=c&&ai(c,80)||s?.defaultTitle||"New task",u=n.title?.trim();P(t,u||function(e){if(!e)return;const t=ai(e,28);if(t===e)return e;const n=t.lastIndexOf(" ");return(n>8?t.slice(0,n):t).trimEnd()+"\u2026"}(c)||s?.defaultTitle||"New task");let p=!0;const h=void 0===n.localMcps?r.localMcps:n.localMcps;if(j(h)!==j(r.localMcps))try{await B(e,t,h??void 0),o.push("mcp")}catch{p=!1}const f=[];n.permissionMode&&"default"!==n.permissionMode&&f.push({payload:{type:"control_request",request_id:`set-perm-mode-${L()}`,request:{subtype:"set_permission_mode",mode:n.permissionMode}}});for(const[b,y]of Object.entries(n.mcpPermissionModeOverrides??{}))f.push({payload:{type:"control_request",request_id:`mcp-perm-override-${L()}`,request:{subtype:"set_mcp_permission_mode_override",serverName:b,mode:y}}});a&&(o.push("model"),f.push({payload:{type:"control_request",request_id:`set-model-${L()}`,request:{subtype:"set_model",model:a}}})),l&&(o.push("effortLevel"),f.push({payload:{type:"control_request",request_id:`set-effort-${L()}`,request:{subtype:"apply_flag_settings",settings:{effortLevel:l}}}})),void 0!==n.extendedThinkingEnabled&&f.push({payload:{type:"control_request",request_id:`set-thinking-${L()}`,request:{subtype:"set_max_thinking_tokens",max_thinking_tokens:n.extendedThinkingEnabled?z:0}}});let m=!1;for(const[b,y]of Object.entries(n.builtinServers??{}))y||(m||(o.push("builtin_servers"),m=!0),f.push({payload:{type:"control_request",request_id:`mcp-toggle-${L()}`,request:{subtype:"mcp_toggle",serverName:b,enabled:!1}}}));for(const b of n.systemReminders??[])f.push({payload:{type:"user",uuid:L(),session_id:t,parent_tool_use_id:null,shouldQuery:!1,message:{role:"user",content:`<system-reminder>${b}</system-reminder>`}}});f.push({payload:{type:"user",uuid:i,session_id:t,parent_tool_use_id:null,message:{role:"user",content:$(n.message??"",n.images)},...n.fileAttachments&&n.fileAttachments.length>0?{file_attachments:n.fileAttachments}:{}},userDeclaredUrls:n.userDeclaredUrls});try{await F(e.rawFetch,e.orgUuid,t,f,{sign:e.signClientEvent,makeDeviceAttestationHeader:H(e,t)})}catch(g){throw U(t),function(e){hi.delete(R(e))}(t),function(e){bi.delete(R(e))}(t),g}if(a&&function(e){const t=R(e),n=hi.get(t);if(!n)return;n.committed=!0;const r=[...fi.get(t)??[]];for(const s of r)s()}(t),l&&function(e){const t=R(e),n=bi.get(t);if(!n)return;n.committed=!0;const r=[...yi.get(t)??[]];for(const s of r)s()}(t),u)await q(()=>xi(t)?Promise.resolve():V(e,t,u,{skipCliLatch:!0}),{action:"cowork_warm_title_write"}).catch(()=>{});else{let r;Promise.race([Promise.resolve(n.titlePromise).catch(()=>{}),new Promise(e=>{r=setTimeout(()=>e(void 0),1e4)})]).then(n=>{clearTimeout(r);const s=n?.title?.trim()||d;return q(()=>xi(t)?Promise.resolve():V(e,t,s,{skipCliLatch:!0}),{action:"cowork_warm_title_write"})}).catch(()=>{})}return{sessionId:t,openingMessageUuid:i,mcpPutOk:p,reconciled:o}}async function Ei(e,t){U(t),await K(e,t).catch(()=>{})}const Mi=Jn()(()=>({bySessionId:{}}));function _i(e){return Mi(t=>t.bySessionId[_(e)])}const Ni=Object.freeze([]),Ci=[];async function Oi(e,t){const n=R(e);ae.acquireMutationGuard(n);try{return await t()}finally{ae.releaseMutationGuard(n)}}const Ai=Promise.resolve([]);function Ti(e,t){return[...ie(e),t]}function Ii(t=!0){const{orgAvailable:n}=ne(),r=Y(),s=Xn(),{activeOrganization:i}=d(),o=i?.uuid,a=t&&n&&!!o,{data:l,isPending:c}=er({queryKey:Ti(o,n),enabled:a,staleTime:3e4,refetchInterval:3e4,refetchOnWindowFocus:!0,queryFn:async()=>{if(!o)return Ni;const e={rawFetch:r,orgUuid:o},[t]=await Promise.allSettled([n?ve(e):Ai]),i=new Set,a=[],l="fulfilled"===t.status?t.value:[];for(const n of l)i.has(n.sessionId)||(i.add(n.sessionId),a.push(fe(n)));if(0===a.length&&"rejected"===t.status)throw t.reason;var c;return c=l,Mi.setState(e=>{const t=new Set(c.map(e=>_(e.sessionId)));let n=!1;const r={};for(const[s,i]of Object.entries(e.bySessionId))t.has(s)?r[s]=i:n=!0;for(const{sessionId:s,taskSummary:i}of c){if(!i)continue;const e=_(s);r[e]!==i&&(r[e]=i,n=!0)}return n?{bySessionId:r}:e}),we(),function(e,t){if(!t||0===t.length)return e;const n=new Map(t.map(e=>[R(e.sessionId),e]));let r=!1;const s=e.map(e=>{const t=n.get(R(e.sessionId));if(!t)return e;if(e.isArchived||t.isArchived)return e;if((t.lastActivityAt??0)<=(e.lastActivityAt??0))return e;r=!0;const s=void 0!==t.liveStatus?t:e;return{...e,isRunning:t.isRunning,liveStatus:s.liveStatus,rawSessionStatus:s.rawSessionStatus}});return r?s:e}(a,s.getQueryData(Ti(o,n)))}}),u=me(e=>e.bySessionId),p=ge(e=>e.starredIds);return{sessions:e.useMemo(()=>{if(!l||0===l.length)return Ci;let e=!1;const t=l.map(t=>{const n=be(u,t.sessionId),r=p.includes(t.sessionId);return n||r?(e=!0,{...t,spaceId:n?.spaceId??t.spaceId,userSelectedFolders:n?.folders.length?n.folders:t.userSelectedFolders,isStarred:r||t.isStarred}):t});return e?t:l},[l,u,p]),isLoading:a&&c,hasData:!a||void 0!==l}}function Di(){const t=Xn(),{activeOrganization:n}=d(),r=n?.uuid;return e.useCallback((e,n)=>{if(!r)return;const s=R(e);t.setQueriesData({queryKey:ie(r)},e=>{if(!e)return;let t=!1;const r=e.map(e=>{if(R(e.sessionId)!==s)return e;if(e.isArchived)return e;const r="awaiting"!==n&&!!e.pendingToolPermissions?.length;return e.liveStatus===n&&!r&&function(e,t){if(void 0===e.rawSessionStatus)return!0;const n=ti({session_status:e.rawSessionStatus,created_at:e.createdAt});return n===("running"===t)}(e,n)?e:(t=!0,{...e,...Fi(n),...r?{pendingToolPermissions:void 0}:{}})});return t?r:void 0})},[t,r])}function Ri(){const t=Di();return e.useCallback((e,n)=>t(e,Se(n)),[t])}function Li(e,t){return e?"requires_action":t?"running":"idle"}const Pi=[_e],ji="cowork_sessions_watch_killswitch",Bi=new Map;function zi(e){const t=Bi.get(R(e));return void 0!==t&&Date.now()-t<15e3}const $i=e=>{if(e.isArchived)return!1;const{rawSessionStatus:t,liveStatus:n}=e;return void 0!==t?ti({session_status:t,created_at:e.createdAt}):"running"===n};function Fi(e){return{liveStatus:e,rawSessionStatus:void 0,isRunning:"idle"!==e}}function Hi(t){const[n,r]=e.useReducer(e=>e+1,0),s=t.some($i);return e.useEffect(()=>{const e=function(e,t){let n=1/0;for(const r of e){if(r.isArchived||"pending"!==r.rawSessionStatus)continue;const e=("number"==typeof r.createdAt?r.createdAt:NaN)+Xs;Number.isFinite(e)&&e>t&&e<n&&(n=e)}return Number.isFinite(n)?n:void 0}(t,Date.now());if(void 0===e)return;const n=setTimeout(r,Math.min(e-Date.now()+1,2147483647));return()=>clearTimeout(n)},[t,n]),s}function Ui(t=!0){const{orgAvailable:n}=ne(),{activeOrganization:r}=d(),s=r?.uuid,{isLoading:i,sessions:o}=Ii(t),a=u(ji),l=o.length>0,c=t&&!a&&n&&!!s&&!i&&l,p=ri({enabled:c,inFlight:Hi(o),telemetryTag:"cowork-remote"}),h=Xn(),f=u("ccr_sessions_skip_reconnect_refetch"),m=e.useCallback(e=>{if(!s)return;const t=R(e.id);ae.isMutationPending(t)||e.title!==ii&&h.setQueriesData({queryKey:ie(s)},n=>{if(void 0===n)return;const r=n,s=r.findIndex(e=>R(e.sessionId)===t),i=function(e,t){const n=e.created_at?Date.parse(e.created_at):void 0,r=e.updated_at?Date.parse(e.updated_at):void 0,s=t?.sessionId??e.id.replace(/^session_/,"cse_"),i=Se(e.session_status);return{...t??{sessionId:s,cwd:"",userSelectedFolders:[]},sessionId:s,liveStatus:i,rawSessionStatus:e.session_status,isRunning:"idle"!==i,isArchived:"archived"===e.session_status||!!t?.isArchived&&zi(e.id),title:e.title&&e.title!==ii?e.title:t?.title,createdAt:n??t?.createdAt,lastActivityAt:r??t?.lastActivityAt,model:e.session_context?.model??t?.model,effortLevel:t?.effortLevel??e.session_context?.effort_level,scheduledTaskId:e.trigger_id??t?.scheduledTaskId,sessionType:t?.sessionType,boundDeviceId:e.bound_device_id||t?.boundDeviceId}}(e,s>=0?r[s]:void 0);if(s>=0){if(o=r[s],a=i,o.liveStatus===a.liveStatus&&o.rawSessionStatus===a.rawSessionStatus&&o.isArchived===a.isArchived&&o.title===a.title&&o.createdAt===a.createdAt&&o.lastActivityAt===a.lastActivityAt&&o.model===a.model&&o.effortLevel===a.effortLevel&&o.boundDeviceId===a.boundDeviceId&&o.scheduledTaskId===a.scheduledTaskId)return;const e=r.slice();return e[s]=i,e}var o,a;return[i,...r]})},[h,s]),g=e.useCallback(e=>{if(!s)return;const t=R(e);ae.isMutationPending(t)||h.setQueriesData({queryKey:ie(s)},e=>{if(!e)return;const n=e.filter(e=>R(e.sessionId)!==t);return n.length===e.length?void 0:n})},[h,s]),b=e.useRef(0),y=e.useRef(Date.now()),v=e.useCallback(e=>{if(!s)return;const t=Date.now();b.current>t&&(b.current=t),y.current>t&&(y.current=t);t-(e?Math.max(b.current,y.current):b.current)<Ee||(b.current=t,h.refetchQueries({queryKey:ie(s)},{cancelRefetch:!1}))},[h,s]),w=e.useCallback(()=>v(!1),[v]),x=e.useCallback(()=>v(!0),[v]);Me({enabled:c&&p,tags:Pi,onUpsert:m,onDelete:g,onReconnect:f?void 0:w,onResumeStale:f?void 0:x})}function qi(e,t){return(t.lastActivityAt??t.createdAt??0)-(e.lastActivityAt??e.createdAt??0)}function Vi(t=!0){const n=he(),{sessions:r}=Ii(t);return e.useMemo(()=>0===r.length?n:[...n,...r.filter(e=>!e.isArchived)].sort(qi),[n,r])}function Ki(t,n=!0){const r=ke(t),{sessions:s}=Ii(n);return e.useMemo(()=>0===s.length?r:[...r,...s],[r,s])}function Wi(){const t=Xn(),{orgAvailable:n}=ne(),{activeOrganization:r}=d(),s=r?.uuid;return e.useCallback(e=>{const r=ye.getState().sessions.find(t=>t.sessionId===e);return r||t.getQueryData(Ti(s,n))?.find(t=>t.sessionId===e)},[t,s,n])}function Gi(e){const t=re(e),n=ye(n=>e&&"local"===t?n.sessions.find(t=>t.sessionId===e):void 0),{sessions:r}=Ii("ccr"===t);return"ccr"===t?r.find(t=>t.sessionId===e):n}function Ji(t,{collapseScheduledRuns:n=!0}={}){const r=Vi(),s=JSON.stringify("string"==typeof t?t?[t]:[]:t??[]);return e.useMemo(()=>{const e=JSON.parse(s);if(0===e.length)return Ci;const t=[],i=new Set;for(const s of r)if(e.some(e=>s.userSelectedProjectUuids?.includes(e))&&"dispatch_child"!==s.sessionType){if(n&&s.scheduledTaskId){if(i.has(s.scheduledTaskId))continue;i.add(s.scheduledTaskId)}t.push(s)}return t.length>0?t:Ci},[r,s,n])}function Zi(){const e=pe(),{isLoading:t}=Ii();return e&&!t}const Qi=oe?.archive,Xi=oe?.delete,Yi=oe?.updateSession,eo=new Set;function to(e){return xe(e)}function no(){const t=Xn(),n=Y(),r=ee(),s=te(),{activeOrganization:i}=d(),o=i?.uuid,{orgAvailable:a}=ne(),l=a&&!!o,c=e.useCallback(async(e,n)=>{if(!o)return;const r=ie(o);await t.cancelQueries({queryKey:r}),t.setQueriesData({queryKey:r},(t=[])=>{if("deleted"===n)return t.filter(t=>t.sessionId!==e);const r="string"==typeof n?{isArchived:"archived"===n}:"title"in n?{title:n.title}:{userSelectedProjectUuids:n.projectUuid?[n.projectUuid]:void 0};return t.map(t=>t.sessionId===e?{...t,...r}:t)})},[t,o]),u=e.useCallback(e=>{if(!o)return;const n=ie(o);for(const[,r]of t.getQueriesData({queryKey:n})){const t=r?.find(t=>t.sessionId===e);if(t)return t.userSelectedProjectUuids?.[0]??null}},[t,o]),p=e.useMemo(()=>{if(Qi||l)return async(e,t)=>{switch(re(e)){case"ccr":if(!l||!o)throw new Error("Session archive unavailable");return Oi(e,async()=>{await ue({rawFetch:n,orgUuid:o,signForSessionHeader:e=>s(o,e)},e),await c(e,"archived"),function(e){const t=Date.now();for(const[n,r]of Bi)t-r>=15e3&&Bi.delete(n);Bi.set(R(e),t)}(e),oe?.releaseRemoteCuLock?.(e,null)});case"local":if(!Qi)throw new Error("Local cowork archive unavailable");await Qi(e,t)}}},[l,o,n,s,c]),h=e.useMemo(()=>{if(l)return async e=>{switch(re(e)){case"ccr":if(!o)throw new Error("Session unarchive unavailable");return Oi(e,async()=>{await de({rawFetch:n,orgUuid:o},e),await c(e,"unarchived"),Bi.delete(R(e))});case"local":throw new Error("Local cowork unarchive unavailable")}}},[l,o,n,c]),f=e.useMemo(()=>{if(Xi||l)return async e=>{switch(re(e)){case"ccr":if(!l||!o)throw new Error("Session delete unavailable");return Oi(e,async()=>{await K({rawFetch:n,orgUuid:o},e),await c(e,"deleted"),ce(e),function(e){Mi.setState(t=>{const n=_(e);if(!(n in t.bySessionId))return t;const r={...t.bySessionId};return delete r[n],{bySessionId:r}})}(e),oe?.releaseRemoteCuLock?.(e,null)});case"local":if(!Xi)throw new Error("Local cowork delete unavailable");await Xi(e)}}},[l,o,n,c]),m=e.useMemo(()=>{if(Yi||l)return async(e,t,i)=>{switch("auto"!==i?.source&&eo.delete(e),re(e)){case"ccr":{if(!l||!o)throw new Error("Session rename unavailable");const a="auto"!==i?.source&&!xi(e);return a&&function(e){pi.add(R(e))}(e),Oi(e,async()=>{try{await V({rawFetch:n,orgUuid:o,signClientEvent:r,signForSessionHeader:e=>s(o,e)},e,t,{skipCliLatch:"auto"===i?.source})}catch(l){throw a&&function(e){pi.delete(R(e))}(e),l}await c(e,{title:t})})}case"local":if(!Yi)throw new Error("Local cowork rename unavailable");await Yi(e,{title:t,...i?.source&&{titleSource:i.source}})}}},[l,o,n,r,s,c]),g=se(),b=l&&g;return{archive:p,unarchive:h,delete:f,rename:m,setProject:e.useMemo(()=>{if(b)return async(e,t)=>{switch(re(e)){case"ccr":{if(!o)throw new Error("Session set-project unavailable");const r=u(e);return(void 0===r||r!==t)&&Oi(e,async()=>{await c(e,{projectUuid:t});try{await le({rawFetch:n,orgUuid:o},e,t)}catch(s){throw void 0!==r&&u(e)===t&&await c(e,{projectUuid:r}),s}return!0})}case"local":throw new Error("setProject: local sessions use spaceId, not projectUuid")}}},[b,o,n,c,u])}}async function ro(e,t,n){const r=R(n.sessionId),s=ie(t),i=e.getQueriesData({queryKey:s}).some(([,e])=>void 0!==e);await e.cancelQueries({queryKey:s}),e.setQueriesData({queryKey:s},(e=[])=>[fe(n),...e.filter(e=>R(e.sessionId)!==r)]),i||e.refetchQueries({queryKey:s},{cancelRefetch:!1})}function so(){const t=Xn(),{activeOrganization:n}=d(),r=n?.uuid;return e.useCallback(async()=>{r&&await t.refetchQueries({queryKey:ie(r)})},[t,r])}var io=(e=>(e[e.HIGH=30]="HIGH",e[e.MEDIUM=20]="MEDIUM",e[e.LOW=10]="LOW",e[e.NONE=0]="NONE",e))(io||{});const oo=e.createContext(null);function ao({children:n}){const[r,s]=e.useState({items:{},currentlyShowing:null}),[i,o]=e.useState(!1),a=Ne(),{account:l}=d(),c=a?.startsWith("/onboarding"),u=e.useMemo(()=>{if(!l?.created_at)return!0;return Date.now()-new Date(l.created_at).getTime()<864e5},[l?.created_at]),p=e.useCallback((e,t)=>{s(n=>{if(n.items[e])return n;const r={...n.items,[e]:t};return{items:r,currentlyShowing:lo(r,!0)}})},[]),h=e.useCallback(e=>{s(t=>{const{[e]:n,...r}=t.items;return{items:r,currentlyShowing:t.currentlyShowing===e?lo(r):t.currentlyShowing}})},[]),f=e.useCallback(e=>{o(e),e||s(e=>({...e,currentlyShowing:lo(e.items)}))},[]),m=e.useMemo(()=>({items:r.items,currentlyShowing:i||c||u?null:r.currentlyShowing,registerNux:p,unregisterNux:h,setSpotlightActive:f}),[r.items,r.currentlyShowing,i,c,u,p,h,f]);return t.jsx(oo.Provider,{value:m,children:n})}function lo(e,t){const n=Object.entries(e).sort((e,t)=>{const n=e[1].priority||0,r=t[1].priority||0;return n!==r?r-n:new Date(t[1].dateAdded).getTime()-new Date(e[1].dateAdded).getTime()});if(t)return n[0]?.[0]??null;for(const[r,s]of n)if(s.showAfterOthersDismiss)return r;return null}function co(t,{dateAdded:n,priority:r,showAfterOthersDismiss:s},{enabled:i=!0}={}){const o=e.useContext(oo),{dismiss:a,isDismissed:l}=Ce();if(!o)throw new Error("useNux must be used within a NuxProvider");const{registerNux:c,unregisterNux:d,currentlyShowing:u}=o;e.useEffect(()=>{if(i&&!l(t))return c(t,{dateAdded:n,priority:r,showAfterOthersDismiss:s}),()=>d(t)},[t,n,r,s,i,l,c,d]);return{shouldShow:i&&u===t&&!l(t),dismiss:()=>{a(t),d(t),localStorage.removeItem(t)}}}const uo=Jn((e,t)=>({type:null,nuxTitle:null,nuxText:null,nuxBadgeText:null,cta:null,onDismiss:null,setChatTooltip:(t,n,r)=>e({type:t,nuxText:n,nuxTitle:r?.title??null,nuxBadgeText:r?.badgeText??null,cta:r?.cta??null,onDismiss:r?.onDismiss??null}),clearChatTooltip:n=>{n||t().onDismiss?.(),e({type:null,nuxTitle:null,nuxText:null,nuxBadgeText:null,cta:null,onDismiss:null})}}));var po,ho={exports:{}};function fo(){const e=Oe("taint:claude_code_zdr"),t=Oe("taint:cmek"),n=Ae();return!e&&!t&&!n}function mo(t,n,r){const[s,i]=e.useState([]),[o,a]=e.useState(t??!1),[l,c]=e.useState(!1),d=e.useRef(r);d.current=r;const u=e.useRef(()=>Promise.resolve()),p=e.useRef(void 0);e.useEffect(()=>{if(!t)return void a(!1);a(!0),p.current!==n&&(p.current=void 0,i([])),c(!1);let e=!1;const r=async()=>{if(n?.getAllScheduledTasks)try{const t=await n.getAllScheduledTasks();if(e)return;p.current=n,i(t),c(!0)}catch{}finally{e||a(!1)}else e||a(!1)};u.current=r,r();const s=n?.onOnScheduledTaskEvent?.(e=>{r(),d.current?.(e)});return()=>{e=!0,s?.()}},[t,n]);return{scheduledTasks:s,isLoading:o,didResolve:l,refetch:e.useCallback(()=>u.current(),[])}}function go(e){const{prompt:t,model:n}=is(e.job_config);return{...Ve(e),prompt:t||void 0,model:n??void 0,permissionMode:qe(e.job_config),displayName:e.name?Ue(e.name):void 0,projectUuid:He("claude_proj",e.chat_project_id),source:"remote"}}function bo(e){return{id:e,enabled:!1,createdAt:0,filePath:""}}function yo(){const{isRemote:e,isLoading:t,orgAvailable:n}=ne(),r=u("yukon_silver_dramatic_shrimp_clocks"),s=fo();return!t&&e&&n&&r&&s}function vo(){const{orgAvailable:e,canChooseBackend:t,forcedLocalOverride:n,isLoading:r}=ne(),s=u("yukon_silver_dramatic_shrimp_clocks"),i=fo();return!!Te?.createScheduledTask&&!r&&e&&s&&i&&t&&!n}const wo=new Set;function xo(e,t){for(const n of wo)n({type:e,scheduledTask:t})}function ko(e){xo("fired",bo(e))}function So(e){xo("created",bo(e))}function Eo(){const{orgAvailable:t}=ne(),n=t,r=u("yukon_silver_dramatic_shrimp_clocks"),s=!!Te?.createScheduledTask||r,i=yo(),o=e.useRef(i);e.useEffect(()=>{o.current=i},[i]);const a=so(),l=e.useRef(a);e.useEffect(()=>{l.current=a},[a]);const c=Y(),{activeOrganization:p}=d(),h=p?.uuid,f=e.useMemo(()=>{if(!h)return;const e={rawFetch:c,orgUuid:h},t=Te,n=async()=>(await(t?.getAllScheduledTasks?.())??[]).map(e=>({...e,source:"local"})),r=async()=>(await Ke(e)).map(go);return{getAllScheduledTasks:async()=>{const[e,t]=await Promise.allSettled([n(),r()]);return function(e,t){const n=[..."fulfilled"===e.status?e.value:[],..."fulfilled"===t.status?t.value:[]];if(0===n.length){if("rejected"===e.status)throw e.reason;if("rejected"===t.status)throw t.reason}return n}(t,e)},onOnScheduledTaskEvent:e=>{wo.add(e);const n=t?.onOnScheduledTaskEvent?.(e);return()=>{wo.delete(e),n?.()}},createScheduledTask:s?async(n,r)=>{if(!(r?"remote"===r:o.current))return await(t?.createScheduledTask?.(n))??null;const s=go(await Ie(e,De(n,Re())));return xo("created",s),s}:void 0,deleteScheduledTask:async(n,r)=>{"remote"===r?(await $e(e,n),xo("deleted",bo(n))):await(t?.updateScheduledTaskStatus?.(n,"deleted"))},runScheduledTask:async(t,n)=>{xo("fired",go(await Fe(e,t,n))),l.current()},updateScheduledTaskStatus:async(n,r,s,i)=>{if("remote"!==i)return await(t?.updateScheduledTaskStatus?.(n,r,s))??!1;if("deleted"===r)return await $e(e,n),xo("deleted",bo(n)),!0;if("enabled"===r||"disabled"===r){return xo("updated",go(await Be(e,n,{enabled:"enabled"===r}))),!0}throw new Error(`updateScheduledTaskStatus: ${r} not supported for remote tasks`)},updateScheduledTask:async(n,r)=>{if("remote"!==r)return await(t?.updateScheduledTask?.(n))??null;const s=go(await Be(e,n.scheduledTaskId,ze(n)));return xo("updated",s),s},migrateScheduledTask:async n=>{if("remote"===n.source||!n.prompt)throw new Error("migrateScheduledTask: task is not a local task");const r=await Ie(e,De({name:n.displayName??Le(n.id),prompt:n.prompt,description:n.description??"",cronExpression:n.cronExpression,fireAt:n.fireAt,model:n.model,permissionMode:n.permissionMode},Re())),s=r.id;if(!s)throw new Error("migrateScheduledTask: create returned no id");const i=[],o=(n.approvedPermissions??[]).filter(e=>!e.ruleContent).map(e=>e.toolName).filter(Pe);if(o.length>0)try{await je(e,s,o)}catch(a){console.warn("[coworkRemote] migrate: grant-tools failed",a),i.push("approvals")}try{!0!==await(t?.updateScheduledTaskStatus?.(n.id,"disabled"))&&i.push("disable_local")}catch(a){console.warn("[coworkRemote] migrate: disable-local failed",a),i.push("disable_local")}return xo("created",go(r)),{remoteId:s,warnings:i}}}},[c,h,s]);return n?f??Te:Te}function Mo(e,t){return mo(e,Eo(),t)}function _o({status:t,scheduledTasks:n,isLoadingScheduledTasks:r}){return e.useMemo(()=>{if(!t.loading)return t.enabled?r?void 0:new Set(n.map(e=>e.id)):new Set},[t.loading,t.enabled,r,n])}function No(t){const{scheduledTasks:n}=Mo(Boolean(t));return e.useMemo(()=>{if(t)return n.find(e=>e.id===t)?.displayName??Le(t)},[t,n])}const Co=[];function Oo(e){return(e??[]).filter(e=>"always_allow"===e.permission_policy).map(e=>({toolName:e.name}))}function Ao(t,n){const r=Y(),{activeOrganization:s}=d(),i=s?.uuid,[o,a]=e.useState(void 0),l=e.useRef(0),c=n&&t&&i?`${t}|${i}`:null,[u,p]=e.useState(null);e.useEffect(()=>{if(a(void 0),p(null),!c||!t||!i)return;const e=l,n=++e.current;return(async()=>{try{const s=await Ge({rawFetch:r,orgUuid:i},t);if(n!==e.current)return;a(Oo(s.tool_policy_overrides))}catch(s){if(n!==e.current)return;console.warn("[useCoworkScheduledTaskRemoteGrants] fetch failed",s),a([])}finally{n===e.current&&p(c)}})(),()=>{e.current++}},[c,r,i,t]);const h=e.useCallback(async e=>{if(!t||!i)return;const n=l.current;if(await Je({rawFetch:r,orgUuid:i},t,e),n===l.current){a(t=>t?.filter(t=>t.toolName!==e));try{const e=await Ge({rawFetch:r,orgUuid:i},t);if(n!==l.current)return;a(Oo(e.tool_policy_overrides))}catch(s){console.warn("[useCoworkScheduledTaskRemoteGrants] refetch failed",s)}}},[r,i,t]);return{approvedPermissions:o,isLoading:null!==c&&u!==c,removeGrant:h}}const To=new Set(["start","session_updated","close","error","tool_permission_request","tool_permission_resolved","archived","deleted","initialized"]);function Io(t,n,r){const{orgAvailable:s}=ne(),i=void 0===t?void 0:n??(t.startsWith("trig_")?"remote":"local"),o=function(t,n){const[r,s]=e.useState([]),i=n&&t?t:null,[o,a]=e.useState(null);return e.useEffect(()=>{if(!i||!t)return s([]),void a(null);s([]),a(null);let e=!1,n=0;const r=async()=>{const r=++n;if(oe?.getSessionsForScheduledTask)try{const i=await oe.getSessionsForScheduledTask(t);e||r!==n||s(i)}catch{}finally{e||r!==n||a(i)}else e||r!==n||a(i)};r();const o=oe?.onOnEvent?.(e=>{e&&"object"==typeof e&&"type"in e&&To.has(e.type)&&r()});return()=>{e=!0,o?.()}},[i,t]),{sessions:i===o?r:Co,isLoading:null!==i&&i!==o}}(t,"local"===i),a=function(t,n){const r=Y(),{activeOrganization:s}=d(),i=s?.uuid,[o,a]=e.useState([]),l=n&&t&&i?`${t}|${i}`:null,[c,u]=e.useState(null);return e.useEffect(()=>{if(!l||!t||!i)return a([]),void u(null);a([]),u(null);let e=!1,n=0;const s={rawFetch:r,orgUuid:i},o=async()=>{const r=++n;try{const{data:i}=await Ze(s,t,{limit:50});if(e||r!==n)return;a(i.flatMap(e=>{const t=Qe(e);return t?[fe(t)]:[]}))}catch(i){if(e||r!==n)return;console.error("[coworkRemote] listCoworkScheduledTaskRuns",i)}finally{e||r!==n||u(l)}};o();const c=e=>{"fired"===e.type&&e.scheduledTask.id===t&&o()};return wo.add(c),()=>{e=!0,wo.delete(c)}},[l,t,i,r]),{sessions:l===c?o:Co,isLoading:null!==l&&l!==c}}(t,"remote"===i&&!0===r&&s);return"remote"===i?void 0===r?{sessions:Co,isLoading:!0}:a:"local"===i?o:{sessions:Co,isLoading:!1}}function Do(e,t){return mo(e,We,t)}function Ro(e){return Xe(Qn(t=>{if(t.sessionContext?.sessionId!==e)return;const n=Ye(t.sessionContext?.messages);return n?{originalModel:n.originalModel,fallbackModel:n.fallbackModel,apiRefusalCategory:n.apiRefusalCategory,messageUuid:n.messageUuid}:void 0}))}const Lo="/upgrade?feature=cowork&hide_free=true&returnTo=%2Ftask%2Fnew";function Po(e){const t=jo(e=>e.tip),n=jo(e=>e.dismissed);return!!e&&!!t&&t.conversationUuid===e&&!n.has(e)}const jo=Jn((e,t)=>({tip:null,dismissed:new Set,viewed:new Set,markViewed:n=>{const r=t().viewed;if(r.has(n))return!1;const s=new Set(r);if(s.add(n),s.size>50){const e=s.values().next().value;void 0!==e&&e!==n&&s.delete(e)}return e({viewed:s}),!0},publish:n=>{const r=t().tip;r?.conversationUuid===n.conversationUuid&&r.prompt===n.prompt&&r.ctaMode===n.ctaMode&&r.cadenceForAnalytics===n.cadenceForAnalytics&&r.initialName===n.initialName&&r.localNameFallback===n.localNameFallback&&r.initialDescription===n.initialDescription&&r.initialFrequency===n.initialFrequency&&r.initialHour===n.initialHour&&r.initialMinute===n.initialMinute&&r.initialDayOfWeek===n.initialDayOfWeek||e({tip:n})},dismiss:n=>{const r=new Set(t().dismissed);if(r.add(n),r.size>50){const e=r.values().next().value;void 0!==e&&r.delete(e)}e({dismissed:r})},clearIfNotConversation:n=>{const r=t().tip;r&&r.conversationUuid!==n&&e({tip:null})}})),Bo=e.createContext(!1);function zo({children:n,actionButton:r,title:s,minimalUi:i,icon:o,dangerText:a,allowSendAttempt:l,...c}){const d=ur(),{hasBlockingWarning:u,setHasBlockingWarning:p}=et(e=>({hasBlockingWarning:e.hasBlockingWarning,setHasBlockingWarning:e.setHasBlockingWarning}));return e.useEffect(()=>{if(!l)return p(!0),()=>{p(!1)}},[l,u,p]),t.jsx("div",{...c,className:"w-full",children:t.jsxs("div",{className:"flex w-full flex-col items-center gap-2 md:flex-row md:items-center md:gap-x-6",children:[t.jsxs("div",{className:tt("flex min-w-0 flex-row items-center gap-2 md:w-full",a?"text-danger-000":i||o?"text-text-300":"text-danger-000"),children:[i?null:o??t.jsx(hr,{className:"h-4 w-4 shrink-0",weight:"regular",role:"img","aria-label":d.formatMessage({defaultMessage:"Warning",id:"3SVI5pV99B"})}),t.jsxs("div",{className:"min-w-0 break-words",children:[s&&t.jsx("div",{className:"text-sm font-medium",children:s}),t.jsx("div",{className:"text-sm",children:n})]})]}),!!r&&t.jsx("div",{className:"w-full whitespace-nowrap text-sm md:w-fit",children:r})]})})}function $o(e="",t){const n=nt(e||""),r=n?.chat_messages?.at(-1),s=rt(e=>r?e.messageByUuid[r.uuid]?.stop_details:void 0),i=r?.stop_details??s??st(e,r?.uuid),o=Ko({stopReason:r?.stop_reason,stopDetails:i,model:t}),a=r?.parent_message_uuid?n?.chat_messages?.find(e=>e.uuid===r.parent_message_uuid&&"human"===e.sender):void 0;return!r||"assistant"!==r.sender||"prompt_injection_risk"!==r.stop_reason&&"refusal"!==r.stop_reason?null:{stopReason:r.stop_reason,lastMessage:r,blockedHumanMessage:a,stopDetails:i,fallback:o}}const Fo=or(ar(),rr({fallbackModelName:ar(),displayName:ar()})),Ho={},Uo={fallbackModelName:"claude-sonnet-4-6",displayName:"Sonnet 4.6"},qo=Uo,Vo={fallbackModelName:"claude-haiku-4-5-20251001",displayName:"Haiku 4.5"};function Ko({stopReason:e,stopDetails:t,model:n}){const{nameFor:r}=ot("chat"),s=h("holdup","modelFallbacks",Ho,Fo),i=h("holdup","cyberModelFallbacks",Ho,Fo),o=at("cai_kiwano","refusal"===e);if(!n||!e)return;const a=t?.retry_suggestion;if(a&&lt(a.model)!==lt(n))return{fallbackModelName:a.model,displayName:r(a.model).replace(/^Claude /,"")};const l=e=>o&&e.fallbackModelName===n?Vo:e;if("cyber"===t?.category)return i[n]??l(Uo);const c=s[n];return c&&"refusal"===e?c:o?l(qo):void 0}function Wo(e){const n=it("push"),r=()=>{n()},s=e=>t.jsx(ct,{onClick:r,children:e});return t.jsx(zo,{actionButton:null,children:t.jsx("div",{className:"text-text-200 flex w-full items-center justify-between",children:t.jsx("div",{className:"flex items-center gap-1",children:t.jsx("span",{children:"refusal"===e.stopReason?t.jsx(pr,{defaultMessage:"Claude is unable to respond to this request, which appears to violate our <policyLink>Usage Policy</policyLink>. Please <newChat>start a new chat</newChat>.",id:"JQtAKVGSTL",values:{policyLink:e=>t.jsx("a",{href:"https://www.anthropic.com/legal/aup",target:"_blank",className:"underline cursor-pointer",children:e}),newChat:s}}):t.jsx(pr,{defaultMessage:"Claude is unable to respond to this request. Please <newChat>start a new chat</newChat>.",id:"VZKromeiwV",values:{newChat:s}})})})})})}function Go(e){this.content=e}function Jo(e,t,n){for(let r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:n;let s=e.child(r),i=t.child(r);if(s!=i){if(!s.sameMarkup(i))return n;if(s.isText&&s.text!=i.text){for(let e=0;s.text[e]==i.text[e];e++)n++;return n}if(s.content.size||i.content.size){let e=Jo(s.content,i.content,n+1);if(null!=e)return e}n+=s.nodeSize}else n+=s.nodeSize}}function Zo(e,t,n,r){for(let s=e.childCount,i=t.childCount;;){if(0==s||0==i)return s==i?null:{a:n,b:r};let o=e.child(--s),a=t.child(--i),l=o.nodeSize;if(o!=a){if(!o.sameMarkup(a))return{a:n,b:r};if(o.isText&&o.text!=a.text){let e=0,t=Math.min(o.text.length,a.text.length);for(;e<t&&o.text[o.text.length-e-1]==a.text[a.text.length-e-1];)e++,n--,r--;return{a:n,b:r}}if(o.content.size||a.content.size){let e=Zo(o.content,a.content,n-1,r-1);if(e)return e}n-=l,r-=l}else n-=l,r-=l}}Go.prototype={constructor:Go,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,s=r.find(e),i=r.content.slice();return-1==s?i.push(n||e,t):(i[s+1]=t,n&&(i[s]=n)),new Go(i)},remove:function(e){var t=this.find(e);if(-1==t)return this;var n=this.content.slice();return n.splice(t,2),new Go(n)},addToStart:function(e,t){return new Go([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new Go(n)},addBefore:function(e,t,n){var r=this.remove(t),s=r.content.slice(),i=r.find(e);return s.splice(-1==i?s.length:i,0,t,n),new Go(s)},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=Go.from(e)).size?new Go(e.content.concat(this.subtract(e).content)):this},append:function(e){return(e=Go.from(e)).size?new Go(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=Go.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}},Go.from=function(e){if(e instanceof Go)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new Go(t)};class Qo{constructor(e,t){if(this.content=e,this.size=t||0,null==t)for(let n=0;n<e.length;n++)this.size+=e[n].nodeSize}nodesBetween(e,t,n,r=0,s){for(let i=0,o=0;o<t;i++){let a=this.content[i],l=o+a.nodeSize;if(l>e&&!1!==n(a,r+o,s||null,i)&&a.content.size){let s=o+1;a.nodesBetween(Math.max(0,e-s),Math.min(a.content.size,t-s),n,r+s)}o=l}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,r){let s="",i=!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&&(i?i=!1:s+=n),s+=l},0),s}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,n=e.firstChild,r=this.content.slice(),s=0;for(t.isText&&t.sameMarkup(n)&&(r[r.length-1]=t.withText(t.text+n.text),s=1);s<e.content.length;s++)r.push(e.content[s]);return new Qo(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 s=0,i=0;i<t;s++){let o=this.content[s],a=i+o.nodeSize;a>e&&((i<e||a>t)&&(o=o.isText?o.cut(Math.max(0,e-i),Math.min(o.text.length,t-i)):o.cut(Math.max(0,e-i-1),Math.min(o.content.size,t-i-1))),n.push(o),r+=o.nodeSize),i=a}return new Qo(n,r)}cutByIndex(e,t){return e==t?Qo.empty:0==e&&t==this.content.length?this:new Qo(this.content.slice(e,t))}replaceChild(e,t){let n=this.content[e];if(n==t)return this;let r=this.content.slice(),s=this.size+t.nodeSize-n.nodeSize;return r[e]=t,new Qo(r,s)}addToStart(e){return new Qo([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new Qo(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 new 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 Jo(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return Zo(this,e,t,n)}findIndex(e){if(0==e)return Yo(0,e);if(e==this.size)return Yo(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,n=0;;t++){let r=n+this.child(t).nodeSize;if(r>=e)return r==e?Yo(t+1,r):Yo(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 Qo.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new Qo(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return Qo.empty;let t,n=0;for(let r=0;r<e.length;r++){let s=e[r];n+=s.nodeSize,r&&s.isText&&e[r-1].sameMarkup(s)?(t||(t=e.slice(0,r)),t[t.length-1]=s.withText(t[t.length-1].text+s.text)):t&&t.push(s)}return new Qo(t||e,n)}static from(e){if(!e)return Qo.empty;if(e instanceof Qo)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new Qo([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}Qo.empty=new Qo([],0);const Xo={index:0,offset:0};function Yo(e,t){return Xo.index=e,Xo.offset=t,Xo}function ea(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(!ea(e[n],t[n]))return!1}else{for(let n in e)if(!(n in t)||!ea(e[n],t[n]))return!1;for(let n in t)if(!(n in e))return!1}return!0}let ta=class e{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let r=0;r<e.length;r++){let s=e[r];if(this.eq(s))return e;if(this.type.excludes(s.type))t||(t=e.slice(0,r));else{if(s.type.excludes(this.type))return e;!n&&s.type.rank>this.type.rank&&(t||(t=e.slice(0,r)),t.push(this),n=!0),t&&t.push(s)}}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&&ea(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 new RangeError("Invalid input for Mark.fromJSON");let n=e.marks[t.type];if(!n)throw new 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(t){if(!t||Array.isArray(t)&&0==t.length)return e.none;if(t instanceof e)return[t];let n=t.slice();return n.sort((e,t)=>e.type.rank-t.type.rank),n}};ta.none=[];class na extends Error{}class ra{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=ia(this.content,e+this.openStart,t);return n&&new ra(n,this.openStart,this.openEnd)}removeBetween(e,t){return new ra(sa(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 ra.empty;let n=t.openStart||0,r=t.openEnd||0;if("number"!=typeof n||"number"!=typeof r)throw new RangeError("Invalid input for Slice.fromJSON");return new ra(Qo.fromJSON(e,t.content),n,r)}static maxOpen(e,t=!0){let n=0,r=0;for(let s=e.firstChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.firstChild)n++;for(let s=e.lastChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.lastChild)r++;return new ra(e,n,r)}}function sa(e,t,n){let{index:r,offset:s}=e.findIndex(t),i=e.maybeChild(r),{index:o,offset:a}=e.findIndex(n);if(s==t||i.isText){if(a!=n&&!e.child(o).isText)throw new RangeError("Removing non-flat range");return e.cut(0,t).append(e.cut(n))}if(r!=o)throw new RangeError("Removing non-flat range");return e.replaceChild(r,i.copy(sa(i.content,t-s-1,n-s-1)))}function ia(e,t,n,r){let{index:s,offset:i}=e.findIndex(t),o=e.maybeChild(s);if(i==t||o.isText)return r&&!r.canReplace(s,s,n)?null:e.cut(0,t).append(n).append(e.cut(t));let a=ia(o.content,t-i-1,n,o);return a&&e.replaceChild(s,o.copy(a))}function oa(e,t,n){if(n.openStart>e.depth)throw new na("Inserted content deeper than insertion position");if(e.depth-n.openStart!=t.depth-n.openEnd)throw new na("Inconsistent open depths");return aa(e,t,n,0)}function aa(e,t,n,r){let s=e.index(r),i=e.node(r);if(s==t.index(r)&&r<e.depth-n.openStart){let o=aa(e,t,n,r+1);return i.copy(i.content.replaceChild(s,o))}if(n.content.size){if(n.openStart||n.openEnd||e.depth!=r||t.depth!=r){let{start:s,end:o}=function(e,t){let n=t.depth-e.openStart,r=t.node(n).copy(e.content);for(let s=n-1;s>=0;s--)r=t.node(s).copy(Qo.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}(n,e);return pa(i,ha(e,s,o,t,r))}{let r=e.parent,s=r.content;return pa(r,s.cut(0,e.parentOffset).append(n.content).append(s.cut(t.parentOffset)))}}return pa(i,fa(e,t,r))}function la(e,t){if(!t.type.compatibleContent(e.type))throw new na("Cannot join "+t.type.name+" onto "+e.type.name)}function ca(e,t,n){let r=e.node(n);return la(r,t.node(n)),r}function da(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 ua(e,t,n,r){let s=(t||e).node(n),i=0,o=t?t.index(n):s.childCount;e&&(i=e.index(n),e.depth>n?i++:e.textOffset&&(da(e.nodeAfter,r),i++));for(let a=i;a<o;a++)da(s.child(a),r);t&&t.depth==n&&t.textOffset&&da(t.nodeBefore,r)}function pa(e,t){return e.type.checkContent(t),e.copy(t)}function ha(e,t,n,r,s){let i=e.depth>s&&ca(e,t,s+1),o=r.depth>s&&ca(n,r,s+1),a=[];return ua(null,e,s,a),i&&o&&t.index(s)==n.index(s)?(la(i,o),da(pa(i,ha(e,t,n,r,s+1)),a)):(i&&da(pa(i,fa(e,t,s+1)),a),ua(t,n,s,a),o&&da(pa(o,fa(n,r,s+1)),a)),ua(r,null,s,a),new Qo(a)}function fa(e,t,n){let r=[];if(ua(null,e,n,r),e.depth>n){da(pa(ca(e,t,n+1),fa(e,t,n+1)),r)}return ua(t,null,n,r),new Qo(r)}ra.empty=new ra(Qo.empty,0,0);class ma{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 new 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 new 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 s=0;s<e;s++)r+=n.child(s).nodeSize;return r}marks(){let e=this.parent,t=this.index();if(0==e.content.size)return ta.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 s=n.marks;for(var i=0;i<s.length;i++)!1!==s[i].type.spec.inclusive||r&&s[i].isInSet(r.marks)||(s=s[i--].removeFromSet(s));return s}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 s=0;s<n.length;s++)!1!==n[s].type.spec.inclusive||r&&n[s].isInSet(r.marks)||(n=n[s--].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 va(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 new RangeError("Position "+t+" out of range");let n=[],r=0,s=t;for(let i=e;;){let{index:e,offset:t}=i.content.findIndex(s),o=s-t;if(n.push(i,e,r+t),!o)break;if(i=i.child(e),i.isText)break;s=o-1,r+=t+1}return new ma(t,n,s)}static resolveCached(e,t){let n=ya.get(e);if(n)for(let s=0;s<n.elts.length;s++){let e=n.elts[s];if(e.pos==t)return e}else ya.set(e,n=new ga);let r=n.elts[n.i]=ma.resolve(e,t);return n.i=(n.i+1)%ba,r}}class ga{constructor(){this.elts=[],this.i=0}}const ba=12,ya=new WeakMap;class va{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)}}const wa=Object.create(null);class xa{constructor(e,t,n,r=ta.none){this.type=e,this.attrs=t,this.marks=r,this.content=n||Qo.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&&ea(this.attrs,t||e.defaultAttrs||wa)&&ta.sameSet(this.marks,n||ta.none)}copy(e=null){return e==this.content?this:new xa(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new xa(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 ra.empty;let r=this.resolve(e),s=this.resolve(t),i=n?0:r.sharedDepth(t),o=r.start(i),a=r.node(i).content.cut(r.pos-o,s.pos-o);return new ra(a,r.depth-i,s.depth-i)}replace(e,t,n){return oa(this.resolve(e),this.resolve(t),n)}nodeAt(e){for(let t=this;;){let{index:n,offset:r}=t.content.findIndex(e);if(t=t.maybeChild(n),!t)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 ma.resolveCached(this,e)}resolveNoCache(e){return ma.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()+")"),Sa(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,n=Qo.empty,r=0,s=n.childCount){let i=this.contentMatchAt(e).matchFragment(n,r,s),o=i&&i.matchFragment(this.content,t);if(!o||!o.validEnd)return!1;for(let a=r;a<s;a++)if(!this.type.allowsMarks(n.child(a).marks))return!1;return!0}canReplaceWith(e,t,n,r){if(r&&!this.type.allowsMarks(r))return!1;let s=this.contentMatchAt(e).matchType(n),i=s&&s.matchFragment(this.content,t);return!!i&&i.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=ta.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(!ta.sameSet(e,this.marks))throw new 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){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let n;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");n=t.marks.map(e.markFromJSON)}if("text"==t.type){if("string"!=typeof t.text)throw new RangeError("Invalid text node in JSON");return e.text(t.text,n)}let r=Qo.fromJSON(e,t.content),s=e.nodeType(t.type).create(t.attrs,r,n);return s.type.checkAttrs(s.attrs),s}}xa.prototype.text=void 0;class ka extends xa{constructor(e,t,n,r){if(super(e,t,null,r),!n)throw new RangeError("Empty text nodes are not allowed");this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Sa(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 ka(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new ka(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 Sa(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+"("+t+")";return t}class Ea{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let n=new Ma(e,t);if(null==n.next)return Ea.empty;let r=_a(n);n.next&&n.err("Unexpected trailing text");let s=function(e){let t=Object.create(null);return n(Ia(e,0));function n(r){let s=[];r.forEach(t=>{e[t].forEach(({term:t,to:n})=>{if(!t)return;let r;for(let e=0;e<s.length;e++)s[e][0]==t&&(r=s[e][1]);Ia(e,n).forEach(e=>{r||s.push([t,r=[]]),-1==r.indexOf(e)&&r.push(e)})})});let i=t[r.join(",")]=new Ea(r.indexOf(e.length-1)>-1);for(let e=0;e<s.length;e++){let r=s[e][1].sort(Ta);i.next.push({type:s[e][0],next:t[r.join(",")]||n(r)})}return i}}(function(e){let t=[[]];return s(i(e,0),n()),t;function n(){return t.push([])-1}function r(e,n,r){let s={term:r,to:n};return t[e].push(s),s}function s(e,t){e.forEach(e=>e.to=t)}function i(e,t){if("choice"==e.type)return e.exprs.reduce((e,n)=>e.concat(i(n,t)),[]);if("seq"!=e.type){if("star"==e.type){let o=n();return r(t,o),s(i(e.expr,o),o),[r(o)]}if("plus"==e.type){let o=n();return s(i(e.expr,t),o),s(i(e.expr,o),o),[r(o)]}if("opt"==e.type)return[r(t)].concat(i(e.expr,t));if("range"==e.type){let o=t;for(let t=0;t<e.min;t++){let t=n();s(i(e.expr,o),t),o=t}if(-1==e.max)s(i(e.expr,o),o);else for(let t=e.min;t<e.max;t++){let t=n();r(o,t),s(i(e.expr,o),t),o=t}return[r(o)]}if("name"==e.type)return[r(t,void 0,e.value)];throw new Error("Unknown expr type")}for(let r=0;;r++){let o=i(e.exprs[r],t);if(r==e.exprs.length-1)return o;s(o,t=n())}}}(r));return function(e,t){for(let n=0,r=[e];n<r.length;n++){let e=r[n],s=!e.validEnd,i=[];for(let t=0;t<e.next.length;t++){let{type:n,next:o}=e.next[t];i.push(n.name),!s||n.isText||n.hasRequiredAttrs()||(s=!1),-1==r.indexOf(o)&&r.push(o)}s&&t.err("Only non-generatable nodes ("+i.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}(s,n),s}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 s=t;r&&s<n;s++)r=r.matchType(e.child(s).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 s(i,o){let a=i.matchFragment(e,n);if(a&&(!t||a.validEnd))return Qo.from(o.map(e=>e.createAndFill()));for(let e=0;e<i.next.length;e++){let{type:t,next:n}=i.next[e];if(!t.isText&&!t.hasRequiredAttrs()&&-1==r.indexOf(n)){r.push(n);let e=s(n,o.concat(t));if(e)return e}}return null}(this,[])}findWrapping(e){for(let n=0;n<this.wrapCache.length;n+=2)if(this.wrapCache[n]==e)return this.wrapCache[n+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(),s=r.match;if(s.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<s.next.length;e++){let{type:i,next:o}=s.next[e];i.isLeaf||i.hasRequiredAttrs()||i.name in t||r.type&&!o.validEnd||(n.push({match:i.contentMatch,type:i,via:r}),t[i.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new 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 s=0;s<t.next.length;s++)r+=(s?", ":"")+t.next[s].type.name+"->"+e.indexOf(t.next[s].next);return r}).join("\n")}}Ea.empty=new Ea(!0);class Ma{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 new SyntaxError(e+" (in content expression '"+this.string+"')")}}function _a(e){let t=[];do{t.push(Na(e))}while(e.eat("|"));return 1==t.length?t[0]:{type:"choice",exprs:t}}function Na(e){let t=[];do{t.push(Ca(e))}while(e.next&&")"!=e.next&&"|"!=e.next);return 1==t.length?t[0]:{type:"seq",exprs:t}}function Ca(e){let t=function(e){if(e.eat("(")){let t=_a(e);return e.eat(")")||e.err("Missing closing paren"),t}if(!/\W/.test(e.next)){let t=function(e,t){let n=e.nodeTypes,r=n[t];if(r)return[r];let s=[];for(let i in n){let e=n[i];e.isInGroup(t)&&s.push(e)}0==s.length&&e.err("No node type or group '"+t+"' found");return s}(e,e.next).map(t=>(null==e.inline?e.inline=t.isInline:e.inline!=t.isInline&&e.err("Mixing inline and block content"),{type:"name",value:t}));return e.pos++,1==t.length?t[0]:{type:"choice",exprs:t}}e.err("Unexpected token '"+e.next+"'")}(e);for(;;)if(e.eat("+"))t={type:"plus",expr:t};else if(e.eat("*"))t={type:"star",expr:t};else if(e.eat("?"))t={type:"opt",expr:t};else{if(!e.eat("{"))break;t=Aa(e,t)}return t}function Oa(e){/\D/.test(e.next)&&e.err("Expected number, got '"+e.next+"'");let t=Number(e.next);return e.pos++,t}function Aa(e,t){let n=Oa(e),r=n;return e.eat(",")&&(r="}"!=e.next?Oa(e):-1),e.eat("}")||e.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:t}}function Ta(e,t){return t-e}function Ia(e,t){let n=[];return function t(r){let s=e[r];if(1==s.length&&!s[0].term)return t(s[0].to);n.push(r);for(let e=0;e<s.length;e++){let{term:r,to:i}=s[e];r||-1!=n.indexOf(i)||t(i)}}(t),n.sort(Ta)}function Da(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 Ra(e,t){let n=Object.create(null);for(let r in e){let s=t&&t[r];if(void 0===s){let t=e[r];if(!t.hasDefault)throw new RangeError("No value supplied for attribute "+r);s=t.default}n[r]=s}return n}function La(e,t,n,r){for(let s in t)if(!(s in e))throw new RangeError(`Unsupported attribute ${s} for ${n} of type ${s}`);for(let s in e){let n=e[s];n.validate&&n.validate(t[s])}}function Pa(e,t){let n=Object.create(null);if(t)for(let r in t)n[r]=new Ba(e,r,t[r]);return n}let ja=class e{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=Pa(e,n.attrs),this.defaultAttrs=Da(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==Ea.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:Ra(this.attrs,e)}create(e=null,t,n){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new xa(this,this.computeAttrs(e),Qo.from(t),ta.setFrom(n))}createChecked(e=null,t,n){return t=Qo.from(t),this.checkContent(t),new xa(this,this.computeAttrs(e),t,ta.setFrom(n))}createAndFill(e=null,t,n){if(e=this.computeAttrs(e),(t=Qo.from(t)).size){let e=this.contentMatch.fillBefore(t);if(!e)return null;t=e.append(t)}let r=this.contentMatch.matchFragment(t),s=r&&r.fillBefore(Qo.empty,!0);return s?new xa(this,e,t.append(s),ta.setFrom(n)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let n=0;n<e.childCount;n++)if(!this.allowsMarks(e.child(n).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){La(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){if(null==this.markSet)return e;let t;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:ta.none:e}static compile(t,n){let r=Object.create(null);t.forEach((t,s)=>r[t]=new e(t,n,s));let s=n.spec.topNode||"doc";if(!r[s])throw new RangeError("Schema is missing its top node type ('"+s+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let e in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};class Ba{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 s=null===n?"null":typeof n;if(r.indexOf(s)<0)throw new RangeError(`Expected value of type ${r} for attribute ${t} on type ${e}, got ${s}`)}}(e,t,n.validate):n.validate}get isRequired(){return!this.hasDefault}}class za{constructor(e,t,n,r){this.name=e,this.rank=t,this.schema=n,this.spec=r,this.attrs=Pa(e,r.attrs),this.excluded=null;let s=Da(this.attrs);this.instance=s?new ta(this,s):null}create(e=null){return!e&&this.instance?this.instance:new ta(this,Ra(this.attrs,e))}static compile(e,t){let n=Object.create(null),r=0;return e.forEach((e,s)=>n[e]=new za(e,r++,t,s)),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){La(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class $a{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let r in e)t[r]=e[r];t.nodes=Go.from(e.nodes),t.marks=Go.from(e.marks||{}),this.nodes=ja.compile(this.spec.nodes,this),this.marks=za.compile(this.spec.marks,this);let n=Object.create(null);for(let r in this.nodes){if(r in this.marks)throw new RangeError(r+" can not be both a node and a mark");let e=this.nodes[r],t=e.spec.content||"",s=e.spec.marks;if(e.contentMatch=n[t]||(n[t]=Ea.parse(t,this.nodes)),e.inlineContent=e.contentMatch.inlineContent,e.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!e.isInline||!e.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=e}e.markSet="_"==s?null:s?Fa(this,s.split(" ")):""!=s&&e.inlineContent?null:[]}for(let r in this.marks){let e=this.marks[r],t=e.spec.excludes;e.excluded=null==t?[e]:""==t?[]:Fa(this,t.split(" "))}this.nodeFromJSON=e=>xa.fromJSON(this,e),this.markFromJSON=e=>ta.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 ja))throw new RangeError("Invalid node type: "+e);if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}return e.createChecked(t,n,r)}text(e,t){let n=this.nodes.text;return new ka(n,n.defaultAttrs,e,ta.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 new RangeError("Unknown node type: "+e);return t}}function Fa(e,t){let n=[];for(let r=0;r<t.length;r++){let s=t[r],i=e.marks[s],o=i;if(i)n.push(i);else for(let t in e.marks){let r=e.marks[t];("_"==s||r.spec.group&&r.spec.group.split(" ").indexOf(s)>-1)&&n.push(o=r)}if(!o)throw new SyntaxError("Unknown mark type: '"+t[r]+"'")}return n}class Ha{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let n=this.matchedStyles=[];t.forEach(e=>{if(function(e){return null!=e.tag}(e))this.tags.push(e);else if(function(e){return null!=e.style}(e)){let t=/[^=]*/.exec(e.style)[0];n.indexOf(t)<0&&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 Ga(this,t,!1);return n.addAll(e,ta.none,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new Ga(this,t,!0);return n.addAll(e,ta.none,t.from,t.to),ra.maxOpen(n.finish())}matchTag(e,t,n){for(let r=n?this.tags.indexOf(n)+1:0;r<this.tags.length;r++){let n=this.tags[r];if(Ja(e,n.tag)&&(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 s=r?this.styles.indexOf(r)+1:0;s<this.styles.length;s++){let r=this.styles[s],i=r.style;if(!(0!=i.indexOf(e)||r.context&&!n.matchesContext(r.context)||i.length>e.length&&(61!=i.charCodeAt(e.length)||i.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 r in e.marks){let t=e.marks[r].spec.parseDOM;t&&t.forEach(e=>{n(e=Za(e)),e.mark||e.ignore||e.clearMark||(e.mark=r)})}for(let r in e.nodes){let t=e.nodes[r].spec.parseDOM;t&&t.forEach(e=>{n(e=Za(e)),e.node||e.ignore||e.mark||(e.node=r)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Ha(e,Ha.schemaRules(e)))}}const Ua={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},qa={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Va={ol:!0,ul:!0};function Ka(e,t,n){return null!=t?(t?1:0)|("full"===t?2:0):e&&"pre"==e.whitespace?3:-5&n}class Wa{constructor(e,t,n,r,s,i){this.type=e,this.attrs=t,this.marks=n,this.solid=r,this.options=i,this.content=[],this.activeMarks=ta.none,this.match=s||(4&i?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(Qo.from(e));if(!t){let t,n=this.type.contentMatch;return(t=n.findWrapping(e.type))?(this.match=n,t):null}this.match=this.type.contentMatch.matchFragment(t)}return this.match.findWrapping(e.type)}finish(e){if(!(1&this.options)){let e,t=this.content[this.content.length-1];if(t&&t.isText&&(e=/[ \t\r\n\u000c]+$/.exec(t.text))){let n=t;t.text.length==e[0].length?this.content.pop():this.content[this.content.length-1]=n.withText(n.text.slice(0,n.text.length-e[0].length))}}let t=Qo.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(Qo.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&&!Ua.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class Ga{constructor(e,t,n){this.parser=e,this.options=t,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let r,s=t.topNode,i=Ka(null,t.preserveWhitespace,0)|(n?4:0);r=s?new Wa(s.type,s.attrs,ta.none,!0,t.topMatch||s.type.contentMatch,i):new Wa(n?null:e.schema.topNodeType,null,ta.none,!0,null,i),this.nodes=[r],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,s=2&r.options?"full":this.localPreserveWS||(1&r.options)>0;if("full"===s||r.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(s)n="full"!==s?n.replace(/\r?\n|\r/g," "):n.replace(/\r\n?/g,"\n");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],s=e.previousSibling;(!t||s&&"BR"==s.nodeName||t.isText&&/[ \t\r\n\u000c]$/.test(t.text))&&(n=n.slice(1))}n&&this.insertNode(this.parser.schema.text(n),t,!/\S/.test(n)),this.findInText(e)}else this.findInside(e)}addElement(e,t,n){let r=this.localPreserveWS,s=this.top;("PRE"==e.tagName||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let i,o=e.nodeName.toLowerCase();Va.hasOwnProperty(o)&&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&&Va.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)||(i=this.parser.matchTag(e,this,n));e:if(a?a.ignore:qa.hasOwnProperty(o))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(Ua.hasOwnProperty(o))s.content.length&&s.content[0].isInline&&this.open&&(this.open--,s=this.top),n=!0,s.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}let i=a&&a.skip?t:this.readStyles(e,t);i&&this.addAll(e,i),n&&this.sync(s),this.needsBlock=r}else{let n=this.readStyles(e,t);n&&this.addElementByRule(e,a,n,!1===a.consuming?i: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 r=0;r<this.parser.matchedStyles.length;r++){let e=this.parser.matchedStyles[r],s=n.getPropertyValue(e);if(s)for(let n;;){let r=this.parser.matchStyle(e,s,this,n);if(!r)break;if(r.ignore)return null;if(t=r.clearMark?t.filter(e=>!r.clearMark(e)):t.concat(this.parser.schema.marks[r.mark].create(r.attrs)),!1!==r.consuming)break;n=r}}return t}addElementByRule(e,t,n,r){let s,i;if(t.node)if(i=this.parser.schema.nodes[t.node],i.isLeaf)this.insertNode(i.create(t.attrs),n,"BR"==e.nodeName)||this.leafFallback(e,n);else{let e=this.enter(i,t.attrs||null,n,t.preserveWhitespace);e&&(s=!0,n=e)}else{let e=this.parser.schema.marks[t.mark];n=n.concat(e.create(t.attrs))}let o=this.top;if(i&&i.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)}s&&this.sync(o)&&this.open--}addAll(e,t,n,r){let s=n||0;for(let i=n?e.childNodes[n]:e.firstChild,o=null==r?null:e.childNodes[r];i!=o;i=i.nextSibling,++s)this.findAtPoint(e,s),this.addDOM(i,t);this.findAtPoint(e,s)}findPlace(e,t,n){let r,s;for(let i=this.open,o=0;i>=0;i--){let t=this.nodes[i],a=t.findWrapping(e);if(a&&(!r||r.length>a.length+o)&&(r=a,s=t,!a.length))break;if(t.solid){if(n)break;o+=2}}if(!r)return null;this.sync(s);for(let i=0;i<r.length;i++)t=this.enterInner(r[i],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=ta.none;for(let s of r.concat(e.marks))(t.type?t.type.allowsMarkType(s.type):Qa(s.type,e.type))&&(n=s.addToSet(n));return t.content.push(e.mark(n)),!0}return!1}enter(e,t,n,r){let s=this.findPlace(e.create(t),n,!1);return s&&(s=this.enterInner(e,t,n,!0,r)),s}enterInner(e,t,n,r=!1,s){this.closeExtra();let i=this.top;i.match=i.match&&i.match.matchType(e);let o=Ka(e,s,i.options);4&i.options&&0==i.content.length&&(o|=4);let a=ta.none;return n=n.filter(t=>!(i.type?i.type.allowsMarkType(t.type):Qa(t.type,e))||(a=t.addToSet(a),!1)),this.nodes.push(new Wa(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;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++)if(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),s=-(n?n.depth+1:0)+(r?0:1),i=(e,o)=>{for(;e>=0;e--){let a=t[e];if(""==a){if(e==t.length-1||0==e)continue;for(;o>=s;o--)if(i(e-1,o))return!0;return!1}{let e=o>0||0==o&&r?this.nodes[o].type:n&&o>=s?n.node(o-s).type:null;if(!e||e.name!=a&&!e.isInGroup(a))return!1;o--}}return!0};return i(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 t in this.parser.schema.nodes){let e=this.parser.schema.nodes[t];if(e.isTextblock&&e.defaultAttrs)return e}}}function Ja(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function Za(e){let t={};for(let n in e)t[n]=e[n];return t}function Qa(e,t){let n=t.schema.nodes;for(let r in n){let s=n[r];if(!s.allowsMarkType(e))continue;let i=[],o=e=>{i.push(e);for(let n=0;n<e.edgeCount;n++){let{type:r,next:s}=e.edge(n);if(r==t)return!0;if(i.indexOf(s)<0&&o(s))return!0}};if(o(s.contentMatch))return!0}}class Xa{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){n||(n=el(t).createDocumentFragment());let r=n,s=[];return e.forEach(e=>{if(s.length||e.marks.length){let n=0,i=0;for(;n<s.length&&i<e.marks.length;){let t=e.marks[i];if(this.marks[t.type.name]){if(!t.eq(s[n][0])||!1===t.type.spec.spanning)break;n++,i++}else i++}for(;n<s.length;)r=s.pop()[1];for(;i<e.marks.length;){let n=e.marks[i++],o=this.serializeMark(n,e.isInline,t);o&&(s.push([n,r]),r.appendChild(o.dom),r=o.contentDOM||o.dom)}}r.appendChild(this.serializeNodeInner(e,t))}),n}serializeNodeInner(e,t){let{dom:n,contentDOM:r}=rl(el(t),this.nodes[e.type.name](e),null,e.attrs);if(r){if(e.isLeaf)throw new 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 s=this.serializeMark(e.marks[r],e.isInline,t);s&&((s.contentDOM||s.dom).appendChild(n),n=s.dom)}return n}serializeMark(e,t,n={}){let r=this.marks[e.type.name];return r&&rl(el(n),r(e,t),null,e.attrs)}static renderSpec(e,t,n=null,r){return rl(e,t,n,r)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Xa(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=Ya(e.nodes);return t.text||(t.text=e=>e.text),t}static marksFromSchema(e){return Ya(e.marks)}}function Ya(e){let t={};for(let n in e){let r=e[n].spec.toDOM;r&&(t[n]=r)}return t}function el(e){return e.document||window.document}const tl=new WeakMap;function nl(e){let t=tl.get(e);return void 0===t&&tl.set(e,t=function(e){let t=null;function n(e){if(e&&"object"==typeof e)if(Array.isArray(e))if("string"==typeof e[0])t||(t=[]),t.push(e);else for(let t=0;t<e.length;t++)n(e[t]);else for(let t in e)n(e[t])}return n(e),t}(e)),t}function rl(e,t,n,r){if("string"==typeof t)return{dom:e.createTextNode(t)};if(null!=t.nodeType)return{dom:t};if(t.dom&&null!=t.dom.nodeType)return t;let s,i=t[0];if("string"!=typeof i)throw new RangeError("Invalid array passed to renderSpec");if(r&&(s=nl(r))&&s.indexOf(t)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let o,a=i.indexOf(" ");a>0&&(n=i.slice(0,a),i=i.slice(a+1));let l=n?e.createElementNS(n,i):e.createElement(i),c=t[1],d=1;if(c&&"object"==typeof c&&null==c.nodeType&&!Array.isArray(c)){d=2;for(let e in c)if(null!=c[e]){let t=e.indexOf(" ");t>0?l.setAttributeNS(e.slice(0,t),e.slice(t+1),c[e]):"style"==e&&l.style?l.style.cssText=c[e]:l.setAttribute(e,c[e])}}for(let u=d;u<t.length;u++){let s=t[u];if(0===s){if(u<t.length-1||u>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:l,contentDOM:l}}{let{dom:t,contentDOM:i}=rl(e,s,n,r);if(l.appendChild(t),i){if(o)throw new RangeError("Multiple content holes");o=i}}}return{dom:l,contentDOM:o}}const sl=Math.pow(2,16);function il(e,t){return e+t*sl}function ol(e){return 65535&e}class al{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 ll{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&ll.empty)return ll.empty}recover(e){let t=0,n=ol(e);if(!this.inverted)for(let r=0;r<n;r++)t+=this.ranges[3*r+2]-this.ranges[3*r+1];return this.ranges[3*n]+t+function(e){return(e-(65535&e))/sl}(e)}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,s=this.inverted?2:1,i=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+s],c=this.ranges[o+i],d=a+l;if(e<=d){let s=a+r+((l?e==a?-1:e==d?1:t:t)<0?0:c);if(n)return s;let i=e==(t<0?a:d)?null:il(o/3,e-a),u=e==a?2:e==d?1:4;return(t<0?e!=a:e!=d)&&(u|=8),new al(s,u,i)}r+=c-l}return n?e+r:new al(e+r,0,null)}touches(e,t){let n=0,r=ol(t),s=this.inverted?2:1,i=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let t=this.ranges[o]-(this.inverted?n:0);if(t>e)break;let a=this.ranges[o+s];if(e<=t+a&&o==3*r)return!0;n+=this.ranges[o+i]-a}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let r=0,s=0;r<this.ranges.length;r+=3){let i=this.ranges[r],o=i-(this.inverted?s:0),a=i+(this.inverted?0:s),l=this.ranges[r+t],c=this.ranges[r+n];e(o,o+l,a,a+c),s+=c-l}}invert(){return new ll(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return 0==e?ll.empty:new ll(e<0?[0,-e,0]:[0,0,e])}}ll.empty=new ll([]);class cl{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 cl(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 cl;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 s=this.from;s<this.to;s++){let n=this._maps[s].mapResult(e,t);if(null!=n.recover){let t=this.getMirror(s);if(null!=t&&t>s&&t<this.to){s=t,e=this._maps[t].recover(n.recover);continue}}r|=n.delInfo,e=n.pos}return n?e:new al(e,r,null)}}const dl=Object.create(null);class ul{getMap(){return ll.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let n=dl[t.stepType];if(!n)throw new RangeError(`No step type ${t.stepType} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in dl)throw new RangeError("Duplicate use of step JSON ID "+e);return dl[e]=t,t.prototype.jsonID=e,t}}class pl{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new pl(e,null)}static fail(e){return new pl(null,e)}static fromReplace(e,t,n,r){try{return pl.ok(e.replace(t,n,r))}catch(s){if(s instanceof na)return pl.fail(s.message);throw s}}}function hl(e,t,n){let r=[];for(let s=0;s<e.childCount;s++){let i=e.child(s);i.content.size&&(i=i.copy(hl(i.content,t,i))),i.isInline&&(i=t(i,n,s)),r.push(i)}return Qo.fromArray(r)}class fl extends ul{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)),s=new ra(hl(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 pl.fromReplace(e,this.from,this.to,s)}invert(){return new ml(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 fl(t.pos,n.pos,this.mark)}merge(e){return e instanceof fl&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new fl(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 new RangeError("Invalid input for AddMarkStep.fromJSON");return new fl(t.from,t.to,e.markFromJSON(t.mark))}}ul.jsonID("addMark",fl);class ml extends ul{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 ra(hl(t.content,e=>e.mark(this.mark.removeFromSet(e.marks)),e),t.openStart,t.openEnd);return pl.fromReplace(e,this.from,this.to,n)}invert(){return new fl(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 ml(t.pos,n.pos,this.mark)}merge(e){return e instanceof ml&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new ml(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 new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new ml(t.from,t.to,e.markFromJSON(t.mark))}}ul.jsonID("removeMark",ml);class gl extends ul{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return pl.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return pl.fromReplace(e,this.pos,this.pos+1,new ra(Qo.from(n),0,t.isLeaf?0:1))}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 gl(this.pos,t.marks[n]);return new gl(this.pos,this.mark)}}return new bl(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new gl(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 new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new gl(t.pos,e.markFromJSON(t.mark))}}ul.jsonID("addNodeMark",gl);class bl extends ul{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return pl.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return pl.fromReplace(e,this.pos,this.pos+1,new ra(Qo.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return t&&this.mark.isInSet(t.marks)?new gl(this.pos,this.mark):this}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new bl(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 new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new bl(t.pos,e.markFromJSON(t.mark))}}ul.jsonID("removeNodeMark",bl);class yl extends ul{constructor(e,t,n,r=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=r}apply(e){return this.structure&&wl(e,this.from,this.to)?pl.fail("Structure replace would overwrite content"):pl.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new ll([this.from,this.to-this.from,this.slice.size])}invert(e){return new yl(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deletedAcross&&n.deletedAcross?null:new yl(t.pos,Math.max(t.pos,n.pos),this.slice,this.structure)}merge(e){if(!(e instanceof yl)||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;{let t=this.slice.size+e.slice.size==0?ra.empty:new ra(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new yl(e.from,this.to,t,this.structure)}}{let t=this.slice.size+e.slice.size==0?ra.empty:new ra(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new yl(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 new RangeError("Invalid input for ReplaceStep.fromJSON");return new yl(t.from,t.to,ra.fromJSON(e,t.slice),!!t.structure)}}ul.jsonID("replace",yl);class vl extends ul{constructor(e,t,n,r,s,i,o=!1){super(),this.from=e,this.to=t,this.gapFrom=n,this.gapTo=r,this.slice=s,this.insert=i,this.structure=o}apply(e){if(this.structure&&(wl(e,this.from,this.gapFrom)||wl(e,this.gapTo,this.to)))return pl.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return pl.fail("Gap is not a flat range");let n=this.slice.insertAt(this.insert,t.content);return n?pl.fromReplace(e,this.from,this.to,n):pl.fail("Content does not fit in gap")}getMap(){return new ll([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 vl(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),s=this.to==this.gapTo?n.pos:e.map(this.gapTo,1);return t.deletedAcross&&n.deletedAcross||r<t.pos||s>n.pos?null:new vl(t.pos,n.pos,r,s,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 new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new vl(t.from,t.to,t.gapFrom,t.gapTo,ra.fromJSON(e,t.slice),t.insert,!!t.structure)}}function wl(e,t,n){let r=e.resolve(t),s=n-t,i=r.depth;for(;s>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,s--;if(s>0){let e=r.node(i).maybeChild(r.indexAfter(i));for(;s>0;){if(!e||e.isLeaf)return!0;e=e.firstChild,s--}}return!1}function xl(e,t,n,r=n.contentMatch,s=!0){let i=e.doc.nodeAt(t),o=[],a=t+1;for(let l=0;l<i.childCount;l++){let t=i.child(l),c=a+t.nodeSize,d=r.matchType(t.type);if(d){r=d;for(let r=0;r<t.marks.length;r++)n.allowsMarkType(t.marks[r].type)||e.step(new ml(a,c,t.marks[r]));if(s&&t.isText&&"pre"!=n.whitespace){let e,r,s=/\r?\n|\r/g;for(;e=s.exec(t.text);)r||(r=new ra(Qo.from(n.schema.text(" ",n.allowedMarks(t.marks))),0,0)),o.push(new yl(a+e.index,a+e.index+e[0].length,r))}}else o.push(new yl(a,c,ra.empty));a=c}if(!r.validEnd){let t=r.fillBefore(Qo.empty,!0);e.replace(a,a,new ra(t,0,0))}for(let l=o.length-1;l>=0;l--)e.step(o[l])}function kl(e,t,n){return(0==t||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function Sl(e){let t=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let n=e.depth;;--n){let r=e.$from.node(n),s=e.$from.index(n),i=e.$to.indexAfter(n);if(n<e.depth&&r.canReplace(s,i,t))return n;if(0==n||r.type.spec.isolating||!kl(r,s,i))break}return null}function El(e,t,n=null,r=e){let s=function(e,t){let{parent:n,startIndex:r,endIndex:s}=e,i=n.contentMatchAt(r).findWrapping(t);if(!i)return null;let o=i.length?i[0]:t;return n.canReplaceWith(r,s,o)?i:null}(e,t),i=s&&function(e,t){let{parent:n,startIndex:r,endIndex:s}=e,i=n.child(r),o=t.contentMatch.findWrapping(i.type);if(!o)return null;let a=(o.length?o[o.length-1]:t).contentMatch;for(let l=r;a&&l<s;l++)a=a.matchType(n.child(l).type);return a&&a.validEnd?o:null}(r,t);return i?s.map(Ml).concat({type:t,attrs:n}).concat(i.map(Ml)):null}function Ml(e){return{type:e,attrs:null}}function _l(e,t,n,r){t.forEach((s,i)=>{if(s.isText){let o,a=/\r?\n|\r/g;for(;o=a.exec(s.text);){let s=e.mapping.slice(r).map(n+1+i+o.index);e.replaceWith(s,s+1,t.type.schema.linebreakReplacement.create())}}})}function Nl(e,t,n,r){t.forEach((s,i)=>{if(s.type==s.type.schema.linebreakReplacement){let s=e.mapping.slice(r).map(n+1+i);e.replaceWith(s,s+1,t.type.schema.text("\n"))}})}function Cl(e,t,n=1,r){let s=e.resolve(t),i=s.depth-n,o=r&&r[r.length-1]||s.parent;if(i<0||s.parent.type.spec.isolating||!s.parent.canReplace(s.index(),s.parent.childCount)||!o.type.validContent(s.parent.content.cutByIndex(s.index(),s.parent.childCount)))return!1;for(let c=s.depth-1,d=n-2;c>i;c--,d--){let e=s.node(c),t=s.index(c);if(e.type.spec.isolating)return!1;let n=e.content.cutByIndex(t,e.childCount),i=r&&r[d+1];i&&(n=n.replaceChild(0,i.type.create(i.attrs)));let o=r&&r[d]||e;if(!e.canReplace(t+1,e.childCount)||!o.type.validContent(n))return!1}let a=s.indexAfter(i),l=r&&r[0];return s.node(i).canReplaceWith(a,a,l?l.type:s.node(i+1).type)}function Ol(e,t){let n=e.resolve(t),r=n.index();return Al(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function Al(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 s=0;s<t.childCount;s++){let i=t.child(s),o=i.type==r?e.type.schema.nodes.text:i.type;if(n=n.matchType(o),!n)return!1;if(!e.type.allowsMarks(i.marks))return!1}return n.validEnd}(e,t))}function Tl(e,t,n=-1){let r=e.resolve(t);for(let s=r.depth;;s--){let e,i,o=r.index(s);if(s==r.depth?(e=r.nodeBefore,i=r.nodeAfter):n>0?(e=r.node(s+1),o++,i=r.node(s).maybeChild(o)):(e=r.node(s).maybeChild(o-1),i=r.node(s+1)),e&&!e.isTextblock&&Al(e,i)&&r.node(s).canReplace(o,o+1))return t;if(0==s)break;t=n<0?r.before(s):r.after(s)}}function Il(e,t,n){let r=e.resolve(t);if(!n.content.size)return t;let s=n.content;for(let i=0;i<n.openStart;i++)s=s.firstChild.content;for(let i=1;i<=(0==n.openStart&&n.size?2:1);i++)for(let e=r.depth;e>=0;e--){let t=e==r.depth?0:r.pos<=(r.start(e+1)+r.end(e+1))/2?-1:1,n=r.index(e)+(t>0?1:0),o=r.node(e),a=!1;if(1==i)a=o.canReplace(n,n,s);else{let e=o.contentMatchAt(n).findWrapping(s.firstChild.type);a=e&&o.canReplaceWith(n,n,e[0])}if(a)return 0==t?r.pos:t<0?r.before(e+1):r.after(e+1)}return null}function Dl(e,t,n=t,r=ra.empty){if(t==n&&!r.size)return null;let s=e.resolve(t),i=e.resolve(n);return Rl(s,i,r)?new yl(t,n,r):new Ll(s,i,r).fit()}function Rl(e,t,n){return!n.openStart&&!n.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),n.content)}ul.jsonID("replaceAround",vl);class Ll{constructor(e,t,n){this.$from=e,this.$to=t,this.unplaced=n,this.frontier=[],this.placed=Qo.empty;for(let r=0;r<=e.depth;r++){let t=e.node(r);this.frontier.push({type:t.type,match:t.contentMatchAt(e.indexAfter(r))})}for(let r=e.depth;r>0;r--)this.placed=Qo.from(e.node(r).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 s=this.placed,i=n.depth,o=r.depth;for(;i&&o&&1==s.childCount;)s=s.firstChild.content,i--,o--;let a=new ra(s,i,o);return e>-1?new vl(n.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||n.pos!=this.$to.pos?new yl(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 s=t.firstChild;if(t.childCount>1&&(r=0),s.type.spec.isolating&&r<=n){e=n;break}t=s.content}for(let t=1;t<=2;t++)for(let n=1==t?e:this.unplaced.openStart;n>=0;n--){let e,r=null;n?(r=Bl(this.unplaced.content,n-1).firstChild,e=r.content):e=this.unplaced.content;let s=e.firstChild;for(let i=this.depth;i>=0;i--){let e,{type:o,match:a}=this.frontier[i],l=null;if(1==t&&(s?a.matchType(s.type)||(l=a.fillBefore(Qo.from(s),!1)):r&&o.compatibleContent(r.type)))return{sliceDepth:n,frontierDepth:i,parent:r,inject:l};if(2==t&&s&&(e=a.findWrapping(s.type)))return{sliceDepth:n,frontierDepth:i,parent:r,wrap:e};if(r&&a.matchType(r.type))break}}}openMore(){let{content:e,openStart:t,openEnd:n}=this.unplaced,r=Bl(e,t);return!(!r.childCount||r.firstChild.isLeaf)&&(this.unplaced=new ra(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=Bl(e,t);if(r.childCount<=1&&t>0){let s=e.size-t<=t+r.size;this.unplaced=new ra(Pl(e,t-1,1),t-1,s?t-1:n)}else this.unplaced=new ra(Pl(e,t,1),t,n)}placeNodes({sliceDepth:e,frontierDepth:t,parent:n,inject:r,wrap:s}){for(;this.depth>t;)this.closeFrontierNode();if(s)for(let f=0;f<s.length;f++)this.openFrontierNode(s[f]);let i=this.unplaced,o=n?n.content:i.content,a=i.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-(i.content.size-i.openEnd);for(;l<o.childCount;){let e=o.child(l),t=d.matchType(e.type);if(!t)break;l++,(l>1||0==a||e.content.size)&&(d=t,c.push(zl(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=jl(this.placed,t,Qo.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 f=0,m=o;f<p;f++){let e=m.lastChild;this.frontier.push({type:e.type,match:e.contentMatchAt(e.childCount)}),m=e.content}this.unplaced=h?0==e?ra.empty:new ra(Pl(i.content,e-1,1),e-1,p<0?i.openEnd:e-1):new ra(Pl(i.content,e,l),i.openStart,i.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e,t=this.frontier[this.depth];if(!t.type.isTextblock||!$l(this.$to,this.$to.depth,t.type,t.match,!1)||this.$to.depth==this.depth&&(e=this.findCloseLevel(this.$to))&&e.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){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:n,type:r}=this.frontier[t],s=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),i=$l(e,t,r,n,s);if(i){for(let n=t-1;n>=0;n--){let{match:t,type:r}=this.frontier[n],s=$l(e,n,r,t,!0);if(!s||s.childCount)continue e}return{depth:t,fit:i,move:s?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=jl(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=jl(this.placed,this.depth,Qo.from(e.create(t,n))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let e=this.frontier.pop().match.fillBefore(Qo.empty,!0);e.childCount&&(this.placed=jl(this.placed,this.frontier.length,e))}}function Pl(e,t,n){return 0==t?e.cutByIndex(n,e.childCount):e.replaceChild(0,e.firstChild.copy(Pl(e.firstChild.content,t-1,n)))}function jl(e,t,n){return 0==t?e.append(n):e.replaceChild(e.childCount-1,e.lastChild.copy(jl(e.lastChild.content,t-1,n)))}function Bl(e,t){for(let n=0;n<t;n++)e=e.firstChild.content;return e}function zl(e,t,n){if(t<=0)return e;let r=e.content;return t>1&&(r=r.replaceChild(0,zl(r.firstChild,t-1,1==r.childCount?n-1:0))),t>0&&(r=e.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(e.type.contentMatch.matchFragment(r).fillBefore(Qo.empty,!0)))),e.copy(r)}function $l(e,t,n,r,s){let i=e.node(t),o=s?e.indexAfter(t):e.index(t);if(o==i.childCount&&!n.compatibleContent(i.type))return null;let a=r.fillBefore(i.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,i.content,o)?a:null}function Fl(e){return e.spec.defining||e.spec.definingForContent}function Hl(e,t,n,r,s){if(t<n){let s=e.firstChild;e=e.replaceChild(0,s.copy(Hl(s.content,t+1,n,r,s)))}if(t>r){let t=s.contentMatchAt(0),n=t.fillBefore(e).append(e);e=n.append(t.matchFragment(n).fillBefore(Qo.empty,!0))}return e}function Ul(e,t){let n=[];for(let r=Math.min(e.depth,t.depth);r>=0;r--){let s=e.start(r);if(s<e.pos-(e.depth-r)||t.end(r)>t.pos+(t.depth-r)||e.node(r).type.spec.isolating||t.node(r).type.spec.isolating)break;(s==t.start(r)||r==e.depth&&r==t.depth&&e.parent.inlineContent&&t.parent.inlineContent&&r&&t.start(r-1)==s-1)&&n.push(r)}return n}class ql extends ul{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 pl.fail("No node at attribute step's position");let n=Object.create(null);for(let s in t.attrs)n[s]=t.attrs[s];n[this.attr]=this.value;let r=t.type.create(n,null,t.marks);return pl.fromReplace(e,this.pos,this.pos+1,new ra(Qo.from(r),0,t.isLeaf?0:1))}getMap(){return ll.empty}invert(e){return new ql(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 ql(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 new RangeError("Invalid input for AttrStep.fromJSON");return new ql(t.pos,t.attr,t.value)}}ul.jsonID("attr",ql);class Vl extends ul{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let r in e.attrs)t[r]=e.attrs[r];t[this.attr]=this.value;let n=e.type.create(t,e.content,e.marks);return pl.ok(n)}getMap(){return ll.empty}invert(e){return new Vl(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 new RangeError("Invalid input for DocAttrStep.fromJSON");return new Vl(t.attr,t.value)}}ul.jsonID("docAttr",Vl);let Kl=class extends Error{};Kl=function e(t){let n=Error.call(this,t);return n.__proto__=e.prototype,n},(Kl.prototype=Object.create(Error.prototype)).constructor=Kl,Kl.prototype.name="TransformError";class Wl{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new cl}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new Kl(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}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=ra.empty){let r=Dl(this.doc,e,t,n);return r&&this.step(r),this}replaceWith(e,t,n){return this.replace(e,t,new ra(Qo.from(n),0,0))}delete(e,t){return this.replace(e,t,ra.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 s=e.doc.resolve(t),i=e.doc.resolve(n);if(Rl(s,i,r))return e.step(new yl(t,n,r));let o=Ul(s,e.doc.resolve(n));0==o[o.length-1]&&o.pop();let a=-(s.depth+1);o.unshift(a);for(let p=s.depth,h=s.pos-1;p>0;p--,h--){let e=s.node(p).type.spec;if(e.defining||e.definingAsContext||e.isolating)break;o.indexOf(p)>-1?a=p:s.before(p)==h&&o.splice(1,0,-p)}let l=o.indexOf(a),c=[],d=r.openStart;for(let p=r.content,h=0;;h++){let e=p.firstChild;if(c.push(e),h==r.openStart)break;p=e.content}for(let p=d-1;p>=0;p--){let e=c[p],t=Fl(e.type);if(t&&!e.sameMarkup(s.node(Math.abs(a)-1)))d=p;else if(t||!e.type.isTextblock)break}for(let p=r.openStart;p>=0;p--){let t=(p+d+1)%(r.openStart+1),a=c[t];if(a)for(let c=0;c<o.length;c++){let d=o[(c+l)%o.length],u=!0;d<0&&(u=!1,d=-d);let p=s.node(d-1),h=s.index(d-1);if(p.canReplaceWith(h,h,a.type,a.marks))return e.replace(s.before(d),u?i.after(d):n,new ra(Hl(r.content,0,r.openStart,t),t,r.openEnd))}}let u=e.steps.length;for(let p=o.length-1;p>=0&&(e.replace(t,n,r),!(e.steps.length>u));p--){let e=o[p];e<0||(t=s.before(e),n=i.after(e))}}(this,e,t,n),this}replaceRangeWith(e,t,n){return function(e,t,n,r){if(!r.isInline&&t==n&&e.doc.resolve(t).parent.content.size){let s=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 s=r.depth-1;s>=0;s--){let e=r.index(s);if(r.node(s).canReplaceWith(e,e,n))return r.before(s+1);if(e>0)return null}if(r.parentOffset==r.parent.content.size)for(let s=r.depth-1;s>=0;s--){let e=r.indexAfter(s);if(r.node(s).canReplaceWith(e,e,n))return r.after(s+1);if(e<r.node(s).childCount)return null}return null}(e.doc,t,r.type);null!=s&&(t=n=s)}e.replaceRange(t,n,new ra(Qo.from(r),0,0))}(this,e,t,n),this}deleteRange(e,t){return function(e,t,n){let r=e.doc.resolve(t),s=e.doc.resolve(n),i=Ul(r,s);for(let o=0;o<i.length;o++){let t=i[o],n=o==i.length-1;if(n&&0==t||r.node(t).type.contentMatch.validEnd)return e.delete(r.start(t),s.end(t));if(t>0&&(n||r.node(t-1).canReplace(r.index(t-1),s.indexAfter(t-1))))return e.delete(r.before(t),s.after(t))}for(let o=1;o<=r.depth&&o<=s.depth;o++)if(t-r.start(o)==r.depth-o&&n>r.end(o)&&s.end(o)-n!=s.depth-o&&r.start(o-1)==s.start(o-1)&&r.node(o-1).canReplace(r.index(o-1),s.index(o-1)))return e.delete(r.before(o),n);e.delete(t,n)}(this,e,t),this}lift(e,t){return function(e,t,n){let{$from:r,$to:s,depth:i}=t,o=r.before(i+1),a=s.after(i+1),l=o,c=a,d=Qo.empty,u=0;for(let f=i,m=!1;f>n;f--)m||r.index(f)>0?(m=!0,d=Qo.from(r.node(f).copy(d)),u++):l--;let p=Qo.empty,h=0;for(let f=i,m=!1;f>n;f--)m||s.after(f+1)<s.end(f)?(m=!0,p=Qo.from(s.node(f).copy(p)),h++):c++;e.step(new vl(l,c,o,a,new ra(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:s}=e.doc.type.schema,i=e.doc.resolve(t-n),o=i.node().type;if(s&&o.inlineContent){let e="pre"==o.whitespace,t=!!o.contentMatch.matchType(s);e&&!t?r=!1:!e&&t&&(r=!0)}let a=e.steps.length;if(!1===r){let r=e.doc.resolve(t+n);Nl(e,r.node(),r.before(),a)}o.inlineContent&&xl(e,t+n-1,o,i.node().contentMatchAt(i.index()),null==r);let l=e.mapping.slice(a),c=l.map(t-n);if(e.step(new yl(c,l.map(t+n,-1),ra.empty,!0)),!0===r){let t=e.doc.resolve(c);_l(e,t.node(),t.before(),e.steps.length)}}(this,e,t),this}wrap(e,t){return function(e,t,n){let r=Qo.empty;for(let o=n.length-1;o>=0;o--){if(r.size){let e=n[o].type.contentMatch.matchFragment(r);if(!e||!e.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=Qo.from(n[o].type.create(n[o].attrs,r))}let s=t.start,i=t.end;e.step(new vl(s,i,s,i,new ra(r,0,0),n.length,!0))}(this,e,t),this}setBlockType(e,t=e,n,r=null){return function(e,t,n,r,s){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let i=e.steps.length;e.doc.nodesBetween(t,n,(t,n)=>{let o="function"==typeof s?s(t):s;if(t.isTextblock&&!t.hasMarkup(r,o)&&function(e,t,n){let r=e.resolve(t),s=r.index();return r.parent.canReplaceWith(s,s+1,n)}(e.doc,e.mapping.slice(i).map(n),r)){let s=null;if(r.schema.linebreakReplacement){let e="pre"==r.whitespace,t=!!r.contentMatch.matchType(r.schema.linebreakReplacement);e&&!t?s=!1:!e&&t&&(s=!0)}!1===s&&Nl(e,t,n,i),xl(e,e.mapping.slice(i).map(n,1),r,void 0,null===s);let a=e.mapping.slice(i),l=a.map(n,1),c=a.map(n+t.nodeSize,1);return e.step(new vl(l,c,l+1,c-1,new ra(Qo.from(r.create(o,null,t.marks)),0,0),1,!0)),!0===s&&_l(e,t,n,i),!1}})}(this,e,t,n,r),this}setNodeMarkup(e,t,n=null,r){return function(e,t,n,r,s){let i=e.doc.nodeAt(t);if(!i)throw new RangeError("No node at given position");n||(n=i.type);let o=n.create(r,null,s||i.marks);if(i.isLeaf)return e.replaceWith(t,t+i.nodeSize,o);if(!n.validContent(i.content))throw new RangeError("Invalid content for node type "+n.name);e.step(new vl(t,t+i.nodeSize,t+1,t+i.nodeSize-1,new ra(Qo.from(o),0,0),1,!0))}(this,e,t,n,r),this}setNodeAttribute(e,t,n){return this.step(new ql(e,t,n)),this}setDocAttribute(e,t){return this.step(new Vl(e,t)),this}addNodeMark(e,t){return this.step(new gl(e,t)),this}removeNodeMark(e,t){let n=this.doc.nodeAt(e);if(!n)throw new RangeError("No node at position "+e);if(t instanceof ta)t.isInSet(n.marks)&&this.step(new bl(e,t));else{let r,s=n.marks,i=[];for(;r=t.isInSet(s);)i.push(new bl(e,r)),s=r.removeFromSet(s);for(let e=i.length-1;e>=0;e--)this.step(i[e])}return this}split(e,t=1,n){return function(e,t,n=1,r){let s=e.doc.resolve(t),i=Qo.empty,o=Qo.empty;for(let a=s.depth,l=s.depth-n,c=n-1;a>l;a--,c--){i=Qo.from(s.node(a).copy(i));let e=r&&r[c];o=Qo.from(e?e.type.create(e.attrs,o):s.node(a).copy(o))}e.step(new yl(t,t,new ra(i.append(o),n,n),!0))}(this,e,t,n),this}addMark(e,t,n){return function(e,t,n,r){let s,i,o=[],a=[];e.doc.nodesBetween(t,n,(e,l,c)=>{if(!e.isInline)return;let d=e.marks;if(!r.isInSet(d)&&c.type.allowsMarkType(r.type)){let c=Math.max(l,t),u=Math.min(l+e.nodeSize,n),p=r.addToSet(d);for(let e=0;e<d.length;e++)d[e].isInSet(p)||(s&&s.to==c&&s.mark.eq(d[e])?s.to=u:o.push(s=new ml(c,u,d[e])));i&&i.to==c?i.to=u:a.push(i=new fl(c,u,r))}}),o.forEach(t=>e.step(t)),a.forEach(t=>e.step(t))}(this,e,t,n),this}removeMark(e,t,n){return function(e,t,n,r){let s=[],i=0;e.doc.nodesBetween(t,n,(e,o)=>{if(!e.isInline)return;i++;let a=null;if(r instanceof za){let t,n=e.marks;for(;t=r.isInSet(n);)(a||(a=[])).push(t),n=t.removeFromSet(n)}else r?r.isInSet(e.marks)&&(a=[r]):a=e.marks;if(a&&a.length){let r=Math.min(o+e.nodeSize,n);for(let e=0;e<a.length;e++){let n,l=a[e];for(let e=0;e<s.length;e++){let t=s[e];t.step==i-1&&l.eq(s[e].style)&&(n=t)}n?(n.to=r,n.step=i):s.push({style:l,from:Math.max(o,t),to:r,step:i})}}}),s.forEach(t=>e.step(new ml(t.from,t.to,t.style)))}(this,e,t,n),this}clearIncompatible(e,t,n){return xl(this,e,t,n),this}}const Gl=Object.create(null);class Jl{constructor(e,t,n){this.$anchor=e,this.$head=t,this.ranges=n||[new Zl(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=ra.empty){let n=t.content.lastChild,r=null;for(let o=0;o<t.openEnd;o++)r=n,n=n.lastChild;let s=e.steps.length,i=this.ranges;for(let o=0;o<i.length;o++){let{$from:a,$to:l}=i[o],c=e.mapping.slice(s);e.replaceRange(c.map(a.pos),c.map(l.pos),o?ra.empty:t),0==o&&oc(e,s,(n?n.isInline:r&&r.isTextblock)?-1:1)}}replaceWith(e,t){let n=e.steps.length,r=this.ranges;for(let s=0;s<r.length;s++){let{$from:i,$to:o}=r[s],a=e.mapping.slice(n),l=a.map(i.pos),c=a.map(o.pos);s?e.deleteRange(l,c):(e.replaceRangeWith(l,c,t),oc(e,n,t.isInline?-1:1))}}static findFrom(e,t,n=!1){let r=e.parent.inlineContent?new Yl(e):ic(e.node(0),e.parent,e.pos,e.index(),t,n);if(r)return r;for(let s=e.depth-1;s>=0;s--){let r=t<0?ic(e.node(0),e.node(s),e.before(s+1),e.index(s),t,n):ic(e.node(0),e.node(s),e.after(s+1),e.index(s)+1,t,n);if(r)return r}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new rc(e.node(0))}static atStart(e){return ic(e,e,0,0,1)||new rc(e)}static atEnd(e){return ic(e,e,e.content.size,e.childCount,-1)||new rc(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=Gl[t.type];if(!n)throw new RangeError(`No selection type ${t.type} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in Gl)throw new RangeError("Duplicate use of selection JSON ID "+e);return Gl[e]=t,t.prototype.jsonID=e,t}getBookmark(){return Yl.between(this.$anchor,this.$head).getBookmark()}}Jl.prototype.visible=!0;class Zl{constructor(e,t){this.$from=e,this.$to=t}}let Ql=!1;function Xl(e){Ql||e.parent.inlineContent||(Ql=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+e.parent.type.name+")"))}class Yl extends Jl{constructor(e,t=e){Xl(e),Xl(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 Jl.near(n);let r=e.resolve(t.map(this.anchor));return new Yl(r.parent.inlineContent?r:n,n)}replace(e,t=ra.empty){if(super.replace(e,t),t==ra.empty){let t=this.$from.marksAcross(this.$to);t&&e.ensureMarks(t)}}eq(e){return e instanceof Yl&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new ec(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 new RangeError("Invalid input for TextSelection.fromJSON");return new Yl(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=Jl.findFrom(t,n,!0)||Jl.findFrom(t,-n,!0);if(!e)return Jl.near(t,n);t=e.$head}return e.parent.inlineContent||(0==r||(e=(Jl.findFrom(e,-n,!0)||Jl.findFrom(e,n,!0)).$anchor).pos<t.pos!=r<0)&&(e=t),new Yl(e,t)}}Jl.jsonID("text",Yl);class ec{constructor(e,t){this.anchor=e,this.head=t}map(e){return new ec(e.map(this.anchor),e.map(this.head))}resolve(e){return Yl.between(e.resolve(this.anchor),e.resolve(this.head))}}class tc extends Jl{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),s=e.resolve(r);return n?Jl.near(s):new tc(s)}content(){return new ra(Qo.from(this.node),0,0)}eq(e){return e instanceof tc&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new nc(this.anchor)}static fromJSON(e,t){if("number"!=typeof t.anchor)throw new RangeError("Invalid input for NodeSelection.fromJSON");return new tc(e.resolve(t.anchor))}static create(e,t){return new tc(e.resolve(t))}static isSelectable(e){return!e.isText&&!1!==e.type.spec.selectable}}tc.prototype.visible=!1,Jl.jsonID("node",tc);class nc{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:n}=e.mapResult(this.anchor);return t?new ec(n,n):new nc(n)}resolve(e){let t=e.resolve(this.anchor),n=t.nodeAfter;return n&&tc.isSelectable(n)?new tc(t):Jl.near(t)}}class rc extends Jl{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=ra.empty){if(t==ra.empty){e.delete(0,e.doc.content.size);let t=Jl.atStart(e.doc);t.eq(e.selection)||e.setSelection(t)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new rc(e)}map(e){return new rc(e)}eq(e){return e instanceof rc}getBookmark(){return sc}}Jl.jsonID("all",rc);const sc={map(){return this},resolve:e=>new rc(e)};function ic(e,t,n,r,s,i=!1){if(t.inlineContent)return Yl.create(e,n);for(let o=r-(s>0?0:1);s>0?o<t.childCount:o>=0;o+=s){let r=t.child(o);if(r.isAtom){if(!i&&tc.isSelectable(r))return tc.create(e,n-(s<0?r.nodeSize:0))}else{let t=ic(e,r,n+s,s<0?r.childCount:0,s,i);if(t)return t}n+=r.nodeSize*s}return null}function oc(e,t,n){let r=e.steps.length-1;if(r<t)return;let s,i=e.steps[r];(i instanceof yl||i instanceof vl)&&(e.mapping.maps[r].forEach((e,t,n,r)=>{null==s&&(s=r)}),e.setSelection(Jl.near(e.doc.resolve(s),n)))}class ac extends Wl{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 new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=-3&this.updated|1,this.storedMarks=null,this}get selectionSet(){return(1&this.updated)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=2,this}ensureMarks(e){return ta.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)||ta.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),n=null==n?t:n,!e)return this.deleteRange(t,n);let s=this.storedMarks;if(!s){let e=this.doc.resolve(t);s=n==t?e.marks():e.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(t,n,r.text(e,s)),this.selection.empty||this.setSelection(Jl.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 lc(e,t){return t&&e?e.bind(t):e}class cc{constructor(e,t,n){this.name=e,this.init=lc(t.init,n),this.apply=lc(t.apply,n)}}const dc=[new cc("doc",{init:e=>e.doc||e.schema.topNodeType.createAndFill(),apply:e=>e.doc}),new cc("selection",{init:(e,t)=>e.selection||Jl.atStart(t.doc),apply:e=>e.selection}),new cc("storedMarks",{init:e=>e.storedMarks||null,apply:(e,t,n,r)=>r.selection.$cursor?e.storedMarks:null}),new cc("scrollToSelection",{init:()=>0,apply:(e,t)=>e.scrolledIntoView?t+1:t})];class uc{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=dc.slice(),t&&t.forEach(e=>{if(this.pluginsByKey[e.key])throw new 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 cc(e.key,e.spec.state,e))})}}class pc{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 s=!1;for(let i=0;i<this.config.plugins.length;i++){let o=this.config.plugins[i];if(o.spec.appendTransaction){let a=r?r[i].n:0,l=r?r[i].state:this,c=a<t.length&&o.spec.appendTransaction.call(o,a?t.slice(a):t,l,n);if(c&&n.filterTransaction(c,i)){if(c.setMeta("appendedTransaction",e),!r){r=[];for(let e=0;e<this.config.plugins.length;e++)r.push(e<i?{state:n,n:t.length}:{state:this,n:0})}t.push(c),n=n.applyInner(c),s=!0}r&&(r[i]={state:n,n:t.length})}}if(!s)return{state:n,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new pc(this.config),n=this.config.fields;for(let r=0;r<n.length;r++){let s=n[r];t[s.name]=s.apply(e,this[s.name],this,t)}return t}get tr(){return new ac(this)}static create(e){let t=new uc(e.doc?e.doc.type.schema:e.schema,e.plugins),n=new pc(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 uc(this.schema,e.plugins),n=t.fields,r=new pc(t);for(let s=0;s<n.length;s++){let t=n[s].name;r[t]=this.hasOwnProperty(t)?this[t]:n[s].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 new RangeError("The JSON fields `doc` and `selection` are reserved");let r=e[n],s=r.spec.state;s&&s.toJSON&&(t[n]=s.toJSON.call(r,this[r.key]))}return t}static fromJSON(e,t,n){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let r=new uc(e.schema,e.plugins),s=new pc(r);return r.fields.forEach(r=>{if("doc"==r.name)s.doc=xa.fromJSON(e.schema,t.doc);else if("selection"==r.name)s.selection=Jl.fromJSON(s.doc,t.selection);else if("storedMarks"==r.name)t.storedMarks&&(s.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(n)for(let i in n){let o=n[i],a=o.spec.state;if(o.key==r.name&&a&&a.fromJSON&&Object.prototype.hasOwnProperty.call(t,i))return void(s[r.name]=a.fromJSON.call(o,e,t[i],s))}s[r.name]=r.init(e,s)}}),s}}function hc(e,t,n){for(let r in e){let s=e[r];s instanceof Function?s=s.bind(t):"handleDOMEvents"==r&&(s=hc(s,t,{})),n[r]=s}return n}class fc{constructor(e){this.spec=e,this.props={},e.props&&hc(e.props,this,this.props),this.key=e.key?e.key.key:gc("plugin")}getState(e){return e[this.key]}}const mc=Object.create(null);function gc(e){return e in mc?e+"$"+ ++mc[e]:(mc[e]=0,e+"$")}class bc{constructor(e="key"){this.key=gc(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}let yc=0;const vc=Jn(e=>({retryRequest:null,requestRetry:(t,n,r="rewind")=>e({retryRequest:{sessionId:t,modelOverride:n,kind:r,seq:yc++}}),clearRetryRequest:()=>e({retryRequest:null})}));function wc(){const t=ht(),n=Xe(e=>e.sessionContext?.sessionId),r=!!n&&xe(n),{count:s,firstText:i,hasOlder:o}=Xe(Qn(e=>r?{...ft(e.sessionContext?.messages),hasOlder:!1!==e.sessionContext?.historyHasOlder}:{count:0,firstText:void 0,hasOlder:!0})),{track:a}=I(),l=e.useCallback(e=>{void 0===e&&a({event_key:"claudeai.cowork.refusal_fallback.start_new_session_clicked",session_id:n??""});const r=new URLSearchParams({q:i??""});void 0!==e&&r.set("model",e),t.push(`${mt}?${r.toString()}`)},[t,i,n,a]);return r&&!o&&1===s&&i?l:null}function xc(){const e=Xe(e=>e.sessionContext?.sessionId),t=Xe(e=>e.sessionContext?.scheduledTaskId),n=Xe(e=>e.sessionContext?.rewindSession),r=dt(),s=!!e&&xe(e),i=!(!e||s||t||r||!oe?.rewind||!oe?.setModel),o=s&&!t&&!r&&void 0!==n,a=at("cowork_rewind_dramatic_shrimp",o),l=i||o&&a,c=at("cowork_edit_message_button",l),d=l&&c,u=wc(),p=l?null:u,{track:h}=I(),f=Xe(e=>e.sessionContext?.sessionData?.session_context?.model),m=f&&ut(f),g=Ro(e??null),b=g?.originalModel??f,y=Xe(Qn(e=>{const t=pt(e.sessionContext?.messages);return t?{hasDetails:!!t.stopDetails,category:t.stopDetails?.category??null,explanation:t.stopDetails?.explanation??null,messageUuid:t.messageUuid,apiMessageId:t.apiMessageId}:null})),v=y?.hasDetails?{type:"refusal",category:y.category,explanation:y.explanation}:null,w=Ko({stopReason:y?"refusal":void 0,stopDetails:v,model:m}),{hasModel:x,isNonSelectable:k}=ot("cowork"),S=!!w&&x(w.fallbackModelName)&&!k(w.fallbackModelName);if(!(e&&y&&m&&w&&S))return null;const E=w.fallbackModelName;return{model:m,fallback:w,stopDetails:v,retry:p||l?()=>{h({event_key:"claudeai.cowork.refusal_fallback.continue_clicked",session_id:e,original_model:b??"",fallback_model:E}),p?p(E):vc.getState().requestRetry(e,E)}:void 0,refusedMessage:y.messageUuid?{uuid:y.messageUuid,apiMessageId:y.apiMessageId}:void 0,editRetry:d&&b?()=>{h({event_key:"claudeai.cowork.refusal_fallback.edit_retry_clicked",session_id:e,original_model:b,fallback_model:E,source:"hard_block"}),vc.getState().requestRetry(e,b,"edit")}:void 0,editRetryModel:d?b:void 0,doubleBlock:g?{category:g.apiRefusalCategory}:void 0,originalModelId:g?.originalModel??f??m,startNewSession:p?()=>p():void 0}}function kc(t,n){const r=ur();return e.useMemo(()=>{const e=r.formatMessage({defaultMessage:"Skill",id:"em6C1j+D5L",description:"Label for a slash skill chip type"});if("mcp"===n?.source||t&&null!==gt(t)){return`${n?.mcpServerName||r.formatMessage({defaultMessage:"Connector",id:"r+vX03quWa",description:"Generic origin label for a connector-served skill chip"})}  \xb7  ${e}`}return t&&t.includes(":")?`${bt(yt(t))}  \xb7  ${e}`:e},[t,n,r])}var Sc=(e=>(e.User="user",e.Admin="admin",e.Anthropic="anthropic",e.Shared="shared",e.Plugin="plugin",e))(Sc||{});const Ec=e.memo(({addedBy:e,addedByName:n,lastUpdated:r,userInvocable:s,hideAddedBy:i=!1})=>{const o=ur();return t.jsxs("div",{className:"flex flex-wrap gap-x-8 gap-y-3",children:[!i&&t.jsxs("div",{className:"flex min-w-0 max-w-full flex-col gap-1",children:[t.jsx("span",{className:"font-small text-text-500 whitespace-nowrap",children:t.jsx(pr,{defaultMessage:"Added by",id:"mGXoWbZIBO"})}),t.jsx("span",{className:"font-base text-text-100 [overflow-wrap:anywhere]",children:n||t.jsx(Mc,{source:e})})]}),r&&t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsx("span",{className:"font-small text-text-500 whitespace-nowrap",children:t.jsx(pr,{defaultMessage:"Last updated",id:"0ICwq5Kcsu"})}),t.jsx("span",{className:"font-base text-text-100 whitespace-nowrap",children:r})]}),void 0!==s&&t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsx("span",{className:"font-small text-text-500 whitespace-nowrap",children:t.jsx(pr,{defaultMessage:"Trigger",id:"B3Q5mz5Qnl"})}),t.jsx(fr,{multiline:!0,className:"[overflow-wrap:anywhere]",content:!1===s?o.formatMessage({defaultMessage:"Claude runs this skill automatically when it's relevant to your request.",id:"TE9B6ZPGgR"}):o.formatMessage({defaultMessage:"Appears in the / menu. Claude can also run it automatically when relevant.",id:"eFWPHBACre"}),children:t.jsx("span",{className:"font-base text-text-100 whitespace-nowrap cursor-help underline decoration-dotted decoration-border-300 underline-offset-4",tabIndex:0,children:!1===s?t.jsx(pr,{defaultMessage:"Auto",id:"NXI/XLSYwc"}):t.jsx(pr,{defaultMessage:"Slash command + auto",id:"BSG7BDwEdL"})})})]})]})});Ec.displayName="CustomizeDetailMetadataProperties";const Mc=e.memo(({source:e})=>{switch(e){case"user":return t.jsx(pr,{defaultMessage:"You",id:"kJ5W29okWR"});case"admin":return t.jsx(pr,{defaultMessage:"Your admin",id:"AHXAjK1m4h"});case"anthropic":return t.jsx(pr,{defaultMessage:"Anthropic",id:"LftgYRq5hB"});case"shared":return t.jsx(pr,{defaultMessage:"Shared with you",id:"7fx3MwRt4t"});case"plugin":return t.jsx(pr,{defaultMessage:"Plugin",id:"mVkTZZgH2a"})}});Mc.displayName="AddedByLabel";const _c=e.createContext(null),Nc=e.memo(({description:e,tooltip:n,hideTooltip:r=!1})=>t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsxs("div",{className:"flex items-center gap-0.5",children:[t.jsx("h3",{className:"font-small text-text-500",children:t.jsx(pr,{defaultMessage:"Description",id:"Q8Qw5BZ1VA"})}),!r&&t.jsx(fr,{multiline:!0,className:"[overflow-wrap:anywhere]",content:n,children:t.jsx("span",{className:"flex items-center cursor-default",children:t.jsx(kt,{className:"w-4 h-4 text-text-500"})})})]}),t.jsx("p",{className:"font-base text-text-300 whitespace-pre-wrap [overflow-wrap:anywhere]",children:e.replace(/\\n/g,"\n")})]}));Nc.displayName="DescriptionRow";const Cc=e.memo(({description:n,onSeeMore:r})=>{const s=e.useRef(null),[i,o]=e.useState(!1);return e.useLayoutEffect(()=>{const e=s.current;if(!e)return;const t=()=>{o(e.scrollHeight>e.clientHeight+1)};t();const n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[n]),t.jsxs("p",{ref:s,className:"line-clamp-2 text-caption text-primary",children:[i&&t.jsxs(t.Fragment,{children:[t.jsx("span",{"aria-hidden":!0,className:"float-right h-[1lh] w-0"}),t.jsx("button",{type:"button",onClick:r,className:"float-right clear-right ml-1 text-accent hover:underline",children:t.jsx(pr,{defaultMessage:"See more",id:"yoLwRWw99S"})})]}),n.replace(/\\n/g," ")]})});Cc.displayName="ClampedDescription";const Oc=e.memo(({name:n,actionsSlot:s,notice:i,addedBy:o,addedByName:a,addedByPluginName:l,lastUpdated:c,userInvocable:d,description:u,detailsInPopover:p=!1,children:h})=>{const f=ur(),m=vt(),g=wt(),b=e.useContext(_c),y=Boolean(o||u),v=e=>y?t.jsxs(t.Fragment,{children:[o&&(!e||Boolean(c)||void 0!==d)&&t.jsx(Ec,{addedBy:o,addedByName:a||l,lastUpdated:c,userInvocable:d,hideAddedBy:e}),u&&t.jsx(Nc,{description:u.content,tooltip:u.tooltip,hideTooltip:e})]}):null,[w,x]=e.useState(!1),k=Boolean(u||c)||void 0!==d,S=p&&y&&k?t.jsxs(mr.Root,{open:w,onOpenChange:x,children:[t.jsx(mr.Trigger,{render:t.jsx(gr,{iconOnly:!0,icon:"Info",variant:"ghost",size:"sm","aria-label":f.formatMessage({defaultMessage:"Details",id:"Lv0zJuL1jH"})})}),t.jsx(mr.Popup,{side:"bottom",align:"start",className:"w-[360px] max-w-[calc(100vw-2rem)] max-h-[min(480px,var(--available-height))] flex flex-col",children:t.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto overflow-x-hidden scroll-fade-y scroll-fade-size-6 flex flex-col gap-3 rounded-[inherit]",children:v(!0)})})]}):null,E=p&&o?t.jsx("p",{className:"text-caption text-secondary leading-tight truncate",title:a&&l?`${a} \xb7 ${l}`:a||l||void 0,children:a&&l?t.jsx(pr,{defaultMessage:"by {author} \xb7 {plugin} plugin",id:"MdRfhHTINi",values:{author:t.jsx("span",{className:"inline-block max-w-[50%] truncate align-bottom",children:a}),plugin:l}}):!a&&l?t.jsx(pr,{defaultMessage:"from {plugin} plugin",id:"2gROhKIfoB",values:{plugin:l}}):t.jsx(pr,{defaultMessage:"by {source}",id:"jRIK21N5nj",values:{source:(o===Sc.Plugin?void 0:a)||t.jsx(Mc,{source:o})}})}):null,M=p&&u?t.jsx(Cc,{description:u.content,onSeeMore:()=>x(!0)}):null,_=S?t.jsxs("span",{className:"flex items-center gap-1",children:[S,s]}):s;return t.jsxs("div",{className:"flex flex-col h-full px-6 pb-6 gap-3",children:[null===b?t.jsxs("div",{className:tt("flex justify-between min-h-14",g?"items-center py-3 sticky top-0 z-[1] bg-bg-100":m?"items-center py-3 -mr-6 pr-md":"items-start pt-4 pb-3",g&&xt.header),children:[t.jsxs("div",{className:"flex flex-1 flex-col min-w-0",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-xs",children:[t.jsx("h2",{className:"min-w-0 font-large-bold text-primary truncate",children:n}),S&&t.jsx("div",{className:"shrink-0",children:S})]}),E]}),s]}):t.jsxs(t.Fragment,{children:[_&&b.actionsContainer&&r.createPortal(_,b.actionsContainer),E]}),M,i,!p&&v(!1),t.jsx("div",{className:tt("flex-1 min-h-0 flex flex-col gap-3",!p&&"mt-2"),children:h})]})});function Ac(e,t={}){const{enabled:n=!0}=t,{data:r,isLoading:s,error:i}=_t(n?e:void 0);return{files:r?.files??[],isLoading:s,error:i?.message??null}}function Tc(e,t,n={}){const{enabled:r=!0,isLegacyCommand:s=!1,backendPluginId:i}=n,o=St(),{data:a,isLoading:l}=Et(e,t,{enabled:r&&!s}),c=o&&void 0!==a&&!a.success,d=!o||c&&!!i,{data:u,isLoading:p,error:h}=Mt(i,t,{enabled:r&&d});if(d)return{files:(u?.files??[]).map(e=>({path:e.path,content:e.content})),isLoading:p,error:h?.message??null};if(!a)return{files:[],isLoading:l,error:null};if(!a.success)return{files:[],isLoading:!1,error:a.error??"Failed to load skill files"};return{files:(a.files??[]).map(e=>({path:e.path,content:e.content,contentsOmitted:e.contentsOmitted,size:e.size})),isLoading:!1,error:null}}function Ic(){return t.jsx("div",{className:"p-6",children:t.jsx(Lt,{width:"100%",height:320,rounded:"lg"})})}function Dc(e){return Rt(e,{loading:Ic})}Oc.displayName="CustomizeDetailPanel";const Rc=Dc(()=>n(()=>import("./c4313ee9e-DA3LZFNF.js"),__vite__mapDeps([0,1,2]),import.meta.url).then(e=>e.SkillDetailPanel)),Lc=Dc(()=>n(()=>import("./c71860c77-DbRxNoWX.js").then(e=>e.a),__vite__mapDeps([0,1]),import.meta.url).then(e=>e.BuiltInSkillDetailPanel)),Pc=Dc(()=>n(()=>import("./cdce3f745-DQ4sqPSd.js").then(e=>e.c),__vite__mapDeps([0,1,2]),import.meta.url).then(e=>e.PluginSkillDetailView)),jc=e.memo(({isOpen:e,onClose:n,info:r})=>e?r.skillId?t.jsx(zc,{isOpen:e,onClose:n,skillId:r.skillId,displayName:r.displayName}):r.pluginId&&r.pluginSkillName?t.jsx(Fc,{isOpen:e,onClose:n,pluginId:r.pluginId,pluginSkillName:r.pluginSkillName,displayName:r.displayName}):"mcp"===r.source?t.jsx($c,{isOpen:e,onClose:n,displayName:r.displayName,children:t.jsx(Bc,{displayName:r.displayName,description:r.description,serverName:r.mcpServerName})}):t.jsx($c,{isOpen:e,onClose:n,displayName:r.displayName,children:t.jsx(Lc,{skill:{name:r.displayName,description:r.description},hideTryButton:!0})}):null);jc.displayName="SkillChipDetailsModal";const Bc=e.memo(({displayName:e,description:n,serverName:r})=>t.jsxs("div",{className:"flex flex-col gap-4 p-6",children:[t.jsx("div",{className:"text-body text-muted",children:t.jsx(pr,{defaultMessage:"Served by the {serverName} connector. The name and description below are supplied by that connector, not by Anthropic.",id:"qSQBGIG7at",values:{serverName:t.jsx("span",{className:"text-primary font-medium",children:r??e})}})}),t.jsx("div",{className:"text-body text-secondary whitespace-pre-wrap",children:n})]}));Bc.displayName="McpSkillDetailBody";const zc=e.memo(({isOpen:n,onClose:r,skillId:s,displayName:i})=>{const o=ur(),{addError:a}=Nt(),l=Ct(),{skills:c,isLoading:d}=Ot(),u=e.useMemo(()=>c.find(e=>e.skillId===s),[c,s]),p=e.useCallback(e=>a(o.formatMessage({defaultMessage:"Something went wrong managing this skill.",id:"6GqxtDrr3Z"}),{error:e}),[a,o]);return u?t.jsx($c,{isOpen:n,onClose:r,displayName:i,children:t.jsx(Rc,{skill:u,selectedFilePath:null,showFileTree:!0,wiggleEnabled:l,onError:p,onDeleted:r,onRenamed:r},u.skillId)}):d?null:t.jsx(Hc,{isOpen:n,onClose:r,displayName:i})});zc.displayName="AccountSkillModal";const $c=e.memo(({isOpen:n,onClose:r,displayName:s,children:i})=>{const[o,a]=e.useState(null),l=e.useMemo(()=>({actionsContainer:o}),[o]);return t.jsx(Tt,{isOpen:n,onClose:r,title:`/${s}`,modalSize:"2xl",hasCloseButton:!0,autoFocusOnOpen:!1,prependBeforeCloseButton:t.jsx("span",{ref:a,className:"flex items-center"}),children:t.jsx("div",{className:"-mx-4 -mb-4 md:-mx-6 md:-mb-6 mt-2 h-[calc(100vh-12rem)] overflow-y-auto",children:t.jsx(_c.Provider,{value:l,children:i})})})});$c.displayName="PanelModal";const Fc=e.memo(({isOpen:n,onClose:r,pluginId:s,pluginSkillName:i,displayName:o})=>{const{data:a,isLoading:l}=At(s),c=e.useMemo(()=>a?.skills.find(e=>e.name===i),[a,i]),{files:d,isLoading:u,error:p}=Tc(s,i,{enabled:!!c,isLegacyCommand:"legacy-commands"===c?.source,backendPluginId:a?.backendId});return a&&c?t.jsx($c,{isOpen:n,onClose:r,displayName:o,children:t.jsx(Pc,{plugin:a,skill:c,isLocal:"local"===a.source,selectedFilePath:null,showFileTree:!0,files:d,isLoadingFiles:u,filesError:p},c.name)}):l?null:t.jsx(Hc,{isOpen:n,onClose:r,displayName:o})});Fc.displayName="PluginSkillModal";const Hc=e.memo(({isOpen:e,onClose:n,displayName:r})=>t.jsxs(Tt,{isOpen:e,onClose:n,title:`/${r}`,children:[t.jsx("p",{className:"text-secondary font-base",children:t.jsx(pr,{defaultMessage:"This skill is no longer available.",id:"cAf7oZvsgh"})}),t.jsx(It,{layout:"right",children:t.jsx(Dt,{variant:"secondary",onClick:n,children:t.jsx(pr,{defaultMessage:"Close",id:"rbrahOGMC3"})})})]}));function Uc({displayName:e,selectNone:n}){return t.jsxs("span",{className:"relative pl-2",children:[t.jsx("span",{"aria-hidden":!0,className:tt("absolute top-1/2 -translate-y-1/2 left-0","w-2 h-5 flex items-center justify-center","font-base-bold opacity-50",n&&"select-none"),children:"/"}),t.jsx("span",{className:tt(n&&"select-none"),children:e})]})}Hc.displayName="NotAvailableModal";const qc=e.memo(({children:n,description:r,subtitle:s,href:i,onOpenChange:o,onChipClick:a})=>{const[l,c]=e.useState(!1),d=Pt(i??""),u=e.useCallback(e=>{c(e),o?.(e)},[o]),p=e.useCallback(e=>{!a||"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),e.stopPropagation(),u(!1),a())},[a,u]),h=e.useCallback(e=>{e.preventDefault(),e.stopPropagation(),a&&(u(!1),a())},[a,u]);return t.jsxs(Vr,{open:l,onOpenChange:u,children:[t.jsx(Kr,{openOnHover:!0,delay:300,render:e=>t.jsx("span",{...e,role:a?"button":void 0,tabIndex:a?0:void 0,onMouseDown:e=>{e.preventDefault(),e.stopPropagation()},onClick:h,onKeyDown:p,className:tt("inline-flex relative cursor-pointer",a&&"can-focus rounded-lg"),children:n})}),l&&t.jsx(Wr,{children:t.jsx(Gr,{side:"top",sideOffset:8,align:"start",children:t.jsxs(Jr,{render:i?e=>t.jsx(jt,{...e,href:i,onClick:d}):void 0,className:tt("rounded-xl border-0.5 border-border-300","bg-bg-000 shadow-lg font-base","w-[178px] p-2","flex flex-col gap-2",i&&"cursor-pointer hover:bg-bg-100 transition-colors"),children:[r&&t.jsx("div",{className:tt("text-text-500 font-small","bg-bg-100 rounded-lg","p-2"),children:t.jsx("p",{className:"line-clamp-5",children:r})}),s&&t.jsx("div",{className:"text-text-500 font-small",children:s})]})})})]})});qc.displayName="SlashChipHoverCard";const Vc=e.createContext(null),Kc=e.memo(({chipId:n,description:r,subtitle:s,href:i,selected:o=!1,children:a,onChipClick:l})=>{const[c,d]=e.useState(!1),[u,p]=e.useState(!1),h=e.useContext(Vc)??qc,f=c||u;return t.jsx("span",{className:tt("inline-flex relative cursor-pointer",o?"text-accent-000":"text-accent-100"),onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),children:t.jsxs(h,{chipId:n,description:r,subtitle:s,href:i,onOpenChange:p,onChipClick:l,children:[t.jsx("span",{className:tt("absolute -inset-y-0.5 -left-0.5 -right-1 rounded-md pointer-events-none",o&&"bg-accent-900",f&&!o&&"bg-accent-900/50")}),a]})})});function Wc({id:n,info:r}){const s=kc(n,r),[i,o]=e.useState(!1),a=e.useCallback(()=>o(!0),[]),l=e.useCallback(()=>o(!1),[]);return r.unresolved?t.jsx(Kc,{description:r.description,subtitle:s,children:t.jsx(Uc,{displayName:r.displayName})}):t.jsxs(t.Fragment,{children:[t.jsx(Kc,{description:r.description,subtitle:s,href:r.href,onChipClick:a,children:t.jsx(Uc,{displayName:r.displayName})}),t.jsx(jc,{isOpen:i,onClose:l,info:r})]})}Kc.displayName="SlashCommandChip";const Gc=function(e){for(var t=0;;t++)if(!(e=e.previousSibling))return t},Jc=function(e){let t=e.assignedSlot||e.parentNode;return t&&11==t.nodeType?t.host:t};let Zc=null;const Qc=function(e,t,n){let r=Zc||(Zc=document.createRange());return r.setEnd(e,null==n?e.nodeValue.length:n),r.setStart(e,t||0),r},Xc=function(e,t,n,r){return n&&(ed(e,t,n,r,-1)||ed(e,t,n,r,1))},Yc=/^(img|br|input|textarea|hr)$/i;function ed(e,t,n,r,s){for(var i;;){if(e==n&&t==r)return!0;if(t==(s<0?0:td(e))){let n=e.parentNode;if(!n||1!=n.nodeType||nd(e)||Yc.test(e.nodeName)||"false"==e.contentEditable)return!1;t=Gc(e)+(s<0?0:1),e=n}else{if(1!=e.nodeType)return!1;{let n=e.childNodes[t+(s<0?-1:0)];if(1==n.nodeType&&"false"==n.contentEditable){if(!(null===(i=n.pmViewDesc)||void 0===i?void 0:i.ignoreForSelection))return!1;t+=s}else e=n,t=s<0?td(e):0}}}}function td(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function nd(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)}const rd=function(e){return e.focusNode&&Xc(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)};function sd(e,t){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=e,n.key=n.code=t,n}const id="undefined"!=typeof navigator?navigator:null,od="undefined"!=typeof document?document:null,ad=id&&id.userAgent||"",ld=/Edge\/(\d+)/.exec(ad),cd=/MSIE \d/.exec(ad),dd=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(ad),ud=!!(cd||dd||ld),pd=cd?document.documentMode:dd?+dd[1]:ld?+ld[1]:0,hd=!ud&&/gecko\/(\d+)/i.test(ad);hd&&(/Firefox\/(\d+)/.exec(ad)||[0,0])[1];const fd=!ud&&/Chrome\/(\d+)/.exec(ad),md=!!fd,gd=fd?+fd[1]:0,bd=!ud&&!!id&&/Apple Computer/.test(id.vendor),yd=bd&&(/Mobile\/\w+/.test(ad)||!!id&&id.maxTouchPoints>2),vd=yd||!!id&&/Mac/.test(id.platform),wd=!!id&&/Win/.test(id.platform),xd=/Android \d/.test(ad),kd=!!od&&"webkitFontSmoothing"in od.documentElement.style,Sd=kd?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Ed(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}}function Md(e,t){return"number"==typeof e?e:e[t]}function _d(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}}function Nd(e,t,n){let r=e.someProp("scrollThreshold")||0,s=e.someProp("scrollMargin")||5,i=e.dom.ownerDocument;for(let o=n||e.dom;o;){if(1!=o.nodeType){o=Jc(o);continue}let e=o,n=e==i.body,a=n?Ed(i):_d(e),l=0,c=0;if(t.top<a.top+Md(r,"top")?c=-(a.top-t.top+Md(s,"top")):t.bottom>a.bottom-Md(r,"bottom")&&(c=t.bottom-t.top>a.bottom-a.top?t.top+Md(s,"top")-a.top:t.bottom-a.bottom+Md(s,"bottom")),t.left<a.left+Md(r,"left")?l=-(a.left-t.left+Md(s,"left")):t.right>a.right-Md(r,"right")&&(l=t.right-a.right+Md(s,"right")),l||c)if(n)i.defaultView.scrollBy(l,c);else{let n=e.scrollLeft,r=e.scrollTop;c&&(e.scrollTop+=c),l&&(e.scrollLeft+=l);let s=e.scrollLeft-n,i=e.scrollTop-r;t={left:t.left-s,top:t.top-i,right:t.right-s,bottom:t.bottom-i}}let d=n?"fixed":getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(d))break;o="absolute"==d?o.offsetParent:Jc(o)}}function Cd(e){let t=[],n=e.ownerDocument;for(let r=e;r&&(t.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),e!=n);r=Jc(r));return t}function Od(e,t){for(let n=0;n<e.length;n++){let{dom:r,top:s,left:i}=e[n];r.scrollTop!=s+t&&(r.scrollTop=s+t),r.scrollLeft!=i&&(r.scrollLeft=i)}}let Ad=null;function Td(e,t){let n,r,s,i,o=2e8,a=0,l=t.top,c=t.top;for(let d=e.firstChild,u=0;d;d=d.nextSibling,u++){let e;if(1==d.nodeType)e=d.getClientRects();else{if(3!=d.nodeType)continue;e=Qc(d).getClientRects()}for(let p=0;p<e.length;p++){let h=e[p];if(h.top<=l&&h.bottom>=c){l=Math.max(h.bottom,l),c=Math.min(h.top,c);let e=h.left>t.left?h.left-t.left:h.right<t.left?t.left-h.right:0;if(e<o){n=d,o=e,r=e&&3==n.nodeType?{left:h.right<t.left?h.right:h.left,top:t.top}:t,1==d.nodeType&&e&&(a=u+(t.left>=(h.left+h.right)/2?1:0));continue}}else h.top>t.top&&!s&&h.left<=t.left&&h.right>=t.left&&(s=d,i={left:Math.max(h.left,Math.min(h.right,t.left)),top:h.top});!n&&(t.left>=h.right&&t.top>=h.top||t.left>=h.left&&t.top>=h.bottom)&&(a=u+1)}}return!n&&s&&(n=s,r=i,o=0),n&&3==n.nodeType?function(e,t){let n=e.nodeValue.length,r=document.createRange();for(let s=0;s<n;s++){r.setEnd(e,s+1),r.setStart(e,s);let n=Pd(r,1);if(n.top!=n.bottom&&Id(t,n))return{node:e,offset:s+(t.left>=(n.left+n.right)/2?1:0)}}return{node:e,offset:0}}(n,r):!n||o&&1==n.nodeType?{node:e,offset:a}:Td(n,r)}function Id(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function Dd(e,t,n){let r=e.childNodes.length;if(r&&n.top<n.bottom)for(let s=Math.max(0,Math.min(r-1,Math.floor(r*(t.top-n.top)/(n.bottom-n.top))-2)),i=s;;){let n=e.childNodes[i];if(1==n.nodeType){let e=n.getClientRects();for(let r=0;r<e.length;r++){let s=e[r];if(Id(t,s))return Dd(n,t,s)}}if((i=(i+1)%r)==s)break}return e}function Rd(e,t){let n,r=e.dom.ownerDocument,s=0,i=function(e,t,n){if(e.caretPositionFromPoint)try{let r=e.caretPositionFromPoint(t,n);if(r)return{node:r.offsetNode,offset:Math.min(td(r.offsetNode),r.offset)}}catch(r){}if(e.caretRangeFromPoint){let r=e.caretRangeFromPoint(t,n);if(r)return{node:r.startContainer,offset:Math.min(td(r.startContainer),r.startOffset)}}}(r,t.left,t.top);i&&({node:n,offset:s}=i);let o,a=(e.root.elementFromPoint?e.root:r).elementFromPoint(t.left,t.top);if(!a||!e.dom.contains(1!=a.nodeType?a.parentNode:a)){let n=e.dom.getBoundingClientRect();if(!Id(t,n))return null;if(a=Dd(e.dom,t,n),!a)return null}if(bd)for(let c=a;n&&c;c=Jc(c))c.draggable&&(n=void 0);if(a=function(e,t){let n=e.parentNode;return n&&/^li$/i.test(n.nodeName)&&t.left<e.getBoundingClientRect().left?n:e}(a,t),n){if(hd&&1==n.nodeType&&(s=Math.min(s,n.childNodes.length),s<n.childNodes.length)){let e,r=n.childNodes[s];"IMG"==r.nodeName&&(e=r.getBoundingClientRect()).right<=t.left&&e.bottom>t.top&&s++}let r;kd&&s&&1==n.nodeType&&1==(r=n.childNodes[s-1]).nodeType&&"false"==r.contentEditable&&r.getBoundingClientRect().top>=t.top&&s--,n==e.dom&&s==n.childNodes.length-1&&1==n.lastChild.nodeType&&t.top>n.lastChild.getBoundingClientRect().bottom?o=e.state.doc.content.size:0!=s&&1==n.nodeType&&"BR"==n.childNodes[s-1].nodeName||(o=function(e,t,n,r){let s=-1;for(let i=t,o=!1;i!=e.dom;){let t,n=e.docView.nearestDesc(i,!0);if(!n)return null;if(1==n.dom.nodeType&&(n.node.isBlock&&n.parent||!n.contentDOM)&&((t=n.dom.getBoundingClientRect()).width||t.height)&&(n.node.isBlock&&n.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(n.dom.nodeName)&&(!o&&t.left>r.left||t.top>r.top?s=n.posBefore:(!o&&t.right<r.left||t.bottom<r.top)&&(s=n.posAfter),o=!0),!n.contentDOM&&s<0&&!n.node.isText))return(n.node.isBlock?r.top<(t.top+t.bottom)/2:r.left<(t.left+t.right)/2)?n.posBefore:n.posAfter;i=n.dom.parentNode}return s>-1?s:e.docView.posFromDOM(t,n,-1)}(e,n,s,t))}null==o&&(o=function(e,t,n){let{node:r,offset:s}=Td(t,n),i=-1;if(1==r.nodeType&&!r.firstChild){let e=r.getBoundingClientRect();i=e.left!=e.right&&n.left>(e.left+e.right)/2?1:-1}return e.docView.posFromDOM(r,s,i)}(e,a,t));let l=e.docView.nearestDesc(a,!0);return{pos:o,inside:l?l.posAtStart-l.border:-1}}function Ld(e){return e.top<e.bottom||e.left<e.right}function Pd(e,t){let n=e.getClientRects();if(n.length){let e=n[t<0?0:n.length-1];if(Ld(e))return e}return Array.prototype.find.call(n,Ld)||e.getBoundingClientRect()}const jd=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Bd(e,t,n){let{node:r,offset:s,atom:i}=e.docView.domFromPos(t,n<0?-1:1),o=kd||hd;if(3==r.nodeType){if(!o||!jd.test(r.nodeValue)&&(n<0?s:s!=r.nodeValue.length)){let e=s,t=s,i=n<0?1:-1;return n<0&&!s?(t++,i=-1):n>=0&&s==r.nodeValue.length?(e--,i=1):n<0?e--:t++,zd(Pd(Qc(r,e,t),i),i<0)}{let e=Pd(Qc(r,s,s),n);if(hd&&s&&/\s/.test(r.nodeValue[s-1])&&s<r.nodeValue.length){let t=Pd(Qc(r,s-1,s-1),-1);if(t.top==e.top){let n=Pd(Qc(r,s,s+1),-1);if(n.top!=e.top)return zd(n,n.left<t.left)}}return e}}if(!e.state.doc.resolve(t-(i||0)).parent.inlineContent){if(null==i&&s&&(n<0||s==td(r))){let e=r.childNodes[s-1];if(1==e.nodeType)return $d(e.getBoundingClientRect(),!1)}if(null==i&&s<td(r)){let e=r.childNodes[s];if(1==e.nodeType)return $d(e.getBoundingClientRect(),!0)}return $d(r.getBoundingClientRect(),n>=0)}if(null==i&&s&&(n<0||s==td(r))){let e=r.childNodes[s-1],t=3==e.nodeType?Qc(e,td(e)-(o?0:1)):1!=e.nodeType||"BR"==e.nodeName&&e.nextSibling?null:e;if(t)return zd(Pd(t,1),!1)}if(null==i&&s<td(r)){let e=r.childNodes[s];for(;e.pmViewDesc&&e.pmViewDesc.ignoreForCoords;)e=e.nextSibling;let t=e?3==e.nodeType?Qc(e,0,o?0:1):1==e.nodeType?e:null:null;if(t)return zd(Pd(t,-1),!0)}return zd(Pd(3==r.nodeType?Qc(r):r,-n),n>=0)}function zd(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 $d(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 Fd(e,t,n){let r=e.state,s=e.root.activeElement;r!=t&&e.updateState(t),s!=e.dom&&e.focus();try{return n()}finally{r!=t&&e.updateState(r),s!=e.dom&&s&&s.focus()}}const Hd=/[\u0590-\u08ac]/;let Ud=null,qd=null,Vd=!1;function Kd(e,t,n){return Ud==t&&qd==n?Vd:(Ud=t,qd=n,Vd="up"==n||"down"==n?function(e,t,n){let r=t.selection,s="up"==n?r.$from:r.$to;return Fd(e,t,()=>{let{node:t}=e.docView.domFromPos(s.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=Bd(e,s.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=Qc(e,0,e.nodeValue.length).getClientRects()}for(let e=0;e<t.length;e++){let s=t[e];if(s.bottom>s.top+1&&("up"==n?r.top-s.top>2*(s.bottom-r.top):s.bottom-r.bottom>2*(r.bottom-s.top)))return!1}}return!0})}(e,t,n):function(e,t,n){let{$head:r}=t.selection;if(!r.parent.isTextblock)return!1;let s=r.parentOffset,i=!s,o=s==r.parent.content.size,a=e.domSelection();return a?Hd.test(r.parent.textContent)&&a.modify?Fd(e,t,()=>{let{focusNode:t,focusOffset:s,anchorNode:i,anchorOffset:o}=e.domSelectionRange(),l=a.caretBidiLevel;a.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&&s==u;try{a.collapse(i,o),t&&(t!=i||s!=o)&&a.extend&&a.extend(t,s)}catch(h){}return null!=l&&(a.caretBidiLevel=l),p}):"left"==n||"backward"==n?i:o:r.pos==r.start()||r.pos==r.end()}(e,t,n))}class Wd{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){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}{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}}let r;if(e==this.dom&&this.contentDOM)r=t>Gc(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 s,i=this.getDesc(r);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;n=!1}}}getDesc(e){let t=e.pmViewDesc;for(let n=t;n;n=n.parent)if(n==this)return t}posFromDOM(e,t,n){for(let r=e;r;r=r.parentNode){let s=this.getDesc(r);if(s)return s.localPosFromDOM(e,t,n)}return-1}descAt(e){for(let t=0,n=0;t<this.children.length;t++){let r=this.children[t],s=n+r.size;if(n==e&&s!=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<s)return r.descAt(e-n-r.border);n=s}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let n=0,r=0;for(let s=0;n<this.children.length;n++){let t=this.children[n],i=s+t.size;if(i>e||t instanceof eu){r=e-s;break}s=i}if(r)return this.children[n].domFromPos(r-this.children[n].border,t);for(let s;n&&!(s=this.children[n-1]).size&&s instanceof Gd&&s.side>=0;n--);if(t<=0){let e,r=!0;for(;e=n?this.children[n-1]:null,e&&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?Gc(e.dom)+1:0}}{let e,r=!0;for(;e=n<this.children.length?this.children[n]:null,e&&e.dom.parentNode!=this.contentDOM;n++,r=!1);return e&&r&&!e.border&&!e.domAtom?e.domFromPos(0,t):{node:this.contentDOM,offset:e?Gc(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,s=-1;for(let i=n,o=0;;o++){let n=this.children[o],a=i+n.size;if(-1==r&&e<=a){let s=i+n.border;if(e>=s&&t<=a-n.border&&n.node&&n.contentDOM&&this.contentDOM.contains(n.contentDOM))return n.parseRange(e,t,s);e=i;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=Gc(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)){s=Gc(n.dom);break}t+=n.size}-1==s&&(s=this.contentDOM.childNodes.length);break}i=a}return{node:this.contentDOM,from:e,to:t,fromOffset:r,toOffset:s}}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 new RangeError("No node after pos "+e);return t.childNodes[n]}setSelection(e,t,n,r=!1){let s=Math.min(e,t),i=Math.max(e,t);for(let h=0,f=0;h<this.children.length;h++){let o=this.children[h],a=f+o.size;if(s>f&&i<a)return o.setSelection(e-f-o.border,t-f-o.border,n,r);f=a}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((hd||bd)&&e==t){let{node:e,offset:t}=o;if(3==e.nodeType){if(d=!(!t||"\n"!=e.nodeValue[t-1]),d&&t==e.nodeValue.length)for(let n,r=e;r;r=r.parentNode){if(n=r.nextSibling){"BR"==n.nodeName&&(o=a={node:n.parentNode,offset:Gc(n)+1});break}let e=r.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(hd&&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&&bd)&&Xc(o.node,o.offset,c.anchorNode,c.anchorOffset)&&Xc(a.node,a.offset,c.focusNode,c.focusOffset))return;let u=!1;if((l.extend||e==t)&&(!d||!hd)){l.collapse(o.node,o.offset);try{e!=t&&l.extend(a.node,a.offset),u=!0}catch(p){}}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 s=this.children[r],i=n+s.size;if(n==i?e<=i&&t>=n:e<i&&t>n){let r=n+s.border,o=i-s.border;if(e>=r&&t<=o)return this.dirty=e==n||t==i?2:1,void(e!=r||t!=o||!s.contentLost&&s.dom.parentNode==this.contentDOM?s.markDirty(e-r,t-r):s.dirty=3);s.dirty=s.dom!=s.contentDOM||s.dom.parentNode!=this.contentDOM||s.children.length?3:2}n=i}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 Gd extends Wd{constructor(e,t,n,r){let s,i=t.type.toDOM;if("function"==typeof i&&(i=i(n,()=>s?s.parent?s.parent.posBeforeChild(s):void 0:r)),!t.type.spec.raw){if(1!=i.nodeType){let e=document.createElement("span");e.appendChild(i),i=e}i.contentEditable="false",i.classList.add("ProseMirror-widget")}super(e,[],i,null),this.widget=t,this.widget=t,s=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 Jd extends Wd{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 Zd extends Wd{constructor(e,t,n,r,s){super(e,[],n,r),this.mark=t,this.spec=s}static create(e,t,n,r){let s=r.nodeViews[t.type.name],i=s&&s(t,r,n);return i&&i.dom||(i=Xa.renderSpec(document,t.type.spec.toDOM(t,n),null,t.attrs)),new Zd(e,t,i.dom,i.contentDOM||i.dom,i)}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=Zd.create(this.parent,this.mark,!0,n),s=this.children,i=this.size;t<i&&(s=hu(s,t,i,n)),e>0&&(s=hu(s,0,e,n));for(let o=0;o<s.length;o++)s[o].parent=r;return r.children=s,r}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class Qd extends Wd{constructor(e,t,n,r,s,i,o,a,l){super(e,[],s,i),this.node=t,this.outerDeco=n,this.innerDeco=r,this.nodeDOM=o}static create(e,t,n,r,s,i){let o,a=s.nodeViews[t.type.name],l=a&&a(t,s,()=>o?o.parent?o.parent.posBeforeChild(o):void 0:i,n,r),c=l&&l.dom,d=l&&l.contentDOM;if(t.isText)if(c){if(3!=c.nodeType)throw new RangeError("Text must be rendered as a DOM text node")}else c=document.createTextNode(t.text);else if(!c){let e=Xa.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=lu(c,n,t),l?o=new tu(e,t,n,r,c,d||null,u,l,s,i+1):t.isText?new Yd(e,t,n,r,c,u,s):new Qd(e,t,n,r,c,d||null,u,s,i+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=()=>Qo.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)&&cu(t,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let n=this.node.inlineContent,r=t,s=e.composing?this.localCompositionInfo(e,t):null,i=s&&s.pos>-1?s:null,o=s&&s.pos<0,a=new uu(this,i&&i.node,e);!function(e,t,n,r){let s=t.locals(e),i=0;if(0==s.length){for(let n=0;n<e.childCount;n++){let o=e.child(n);r(o,s,t.forChild(i,o),n),i+=o.nodeSize}return}let o=0,a=[],l=null;for(let c=0;;){let d,u,p,h;for(;o<s.length&&s[o].to==i;){let e=s[o++];e.widget&&(d?(u||(u=[d])).push(e):d=e)}if(d)if(u){u.sort(pu);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))break;h=c,p=e.child(c++)}for(let e=0;e<a.length;e++)a[e].to<=i&&a.splice(e--,1);for(;o<s.length&&s[o].from<=i&&s[o].to>i;)a.push(s[o++]);let f=i+p.nodeSize;if(p.isText){let e=f;o<s.length&&s[o].from<e&&(e=s[o].from);for(let t=0;t<a.length;t++)a[t].to<e&&(e=a[t].to);e<f&&(l=p.cut(e-i),p=p.cut(0,e-i),f=e,h=-1)}else for(;o<s.length&&s[o].to<f;)o++;r(p,p.isInline&&!p.isLeaf?a.filter(e=>!e.inline):a.slice(),t.forChild(i,p),h),i=f}}(this.node,this.innerDeco,(t,s,i)=>{t.spec.marks?a.syncToMarks(t.spec.marks,n,e):t.type.side>=0&&!i&&a.syncToMarks(s==this.node.childCount?ta.none:this.node.child(s).marks,n,e),a.placeWidget(t,e,r)},(t,i,l,c)=>{let d;a.syncToMarks(t.marks,n,e),a.findNodeMatch(t,i,l,c)||o&&e.state.selection.from>r&&e.state.selection.to<r+t.nodeSize&&(d=a.findIndexWithChild(s.node))>-1&&a.updateNodeAt(t,i,l,d,e)||a.updateNextNode(t,i,l,e,c,r)||a.addNode(t,i,l,e,r),r+=t.nodeSize}),a.syncToMarks([],n,e),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||2==this.dirty)&&(i&&this.protectLocalComposition(e,i),nu(this.contentDOM,this.children,e),yd&&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 Yl)||n<t||r>t+this.node.content.size)return null;let s=e.input.compositionNode;if(!s||!this.dom.contains(s.parentNode))return null;if(this.node.inlineContent){let e=s.nodeValue,i=function(e,t,n,r){for(let s=0,i=0;s<e.childCount&&i<=r;){let o=e.child(s++),a=i;if(i+=o.nodeSize,!o.isText)continue;let l=o.text;for(;s<e.childCount;){let t=e.child(s++);if(i+=t.nodeSize,!t.isText)break;l+=t.text}if(i>=n){if(i>=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 i<0?null:{node:s,pos:i,text:e}}return{node:s,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:n,text:r}){if(this.getDesc(t))return;let s=t;for(;s.parentNode!=this.contentDOM;s=s.parentNode){for(;s.previousSibling;)s.parentNode.removeChild(s.previousSibling);for(;s.nextSibling;)s.parentNode.removeChild(s.nextSibling);s.pmViewDesc&&(s.pmViewDesc=void 0)}let i=new Jd(this,s,t,r);e.input.compositionNodes.push(i),this.children=hu(this.children,n,n+r.length,e,i)}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(cu(e,this.outerDeco))return;let t=1!=this.nodeDOM.nodeType,n=this.dom;this.dom=ou(this.dom,this.nodeDOM,iu(this.outerDeco,this.node,t),iu(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 Xd(e,t,n,r,s){lu(r,t,e);let i=new Qd(void 0,e,t,n,r,r,r,s,0);return i.contentDOM&&i.updateChildren(s,0),i}class Yd extends Qd{constructor(e,t,n,r,s,i,o){super(e,t,n,r,s,null,i,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),s=document.createTextNode(r.text);return new Yd(this.parent,r,this.outerDeco,this.innerDeco,s,s,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 eu extends Wd{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 tu extends Qd{constructor(e,t,n,r,s,i,o,a,l,c){super(e,t,n,r,s,i,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 s=this.spec.update(e,t,n);return s&&this.updateInner(e,t,n,r),s}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)}}function nu(e,t,n){let r=e.firstChild,s=!1;for(let i=0;i<t.length;i++){let o=t[i],a=o.dom;if(a.parentNode==e){for(;a!=r;)r=du(r),s=!0;r=r.nextSibling}else s=!0,e.insertBefore(a,r);if(o instanceof Zd){let t=r?r.previousSibling:e.lastChild;nu(o.contentDOM,o.children,n),r=t?t.nextSibling:e.firstChild}}for(;r;)r=du(r),s=!0;s&&n.trackWrites==e&&(n.trackWrites=null)}const ru=function(e){e&&(this.nodeName=e)};ru.prototype=Object.create(null);const su=[new ru];function iu(e,t,n){if(0==e.length)return su;let r=n?su[0]:new ru,s=[r];for(let i=0;i<e.length;i++){let o=e[i].type.attrs;if(o){o.nodeName&&s.push(r=new ru(o.nodeName));for(let e in o){let i=o[e];null!=i&&(n&&1==s.length&&s.push(r=new ru(t.isInline?"span":"div")),"class"==e?r.class=(r.class?r.class+" ":"")+i:"style"==e?r.style=(r.style?r.style+";":"")+i:"nodeName"!=e&&(r[e]=i))}}}return s}function ou(e,t,n,r){if(n==su&&r==su)return t;let s=t;for(let i=0;i<r.length;i++){let t=r[i],o=n[i];if(i){let n;o&&o.nodeName==t.nodeName&&s!=e&&(n=s.parentNode)&&n.nodeName.toLowerCase()==t.nodeName||(n=document.createElement(t.nodeName),n.pmIsDeco=!0,n.appendChild(s),o=su[0]),s=n}au(s,o||su[0],t)}return s}function au(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):[],s=n.class?n.class.split(" ").filter(Boolean):[];for(let t=0;t<r.length;t++)-1==s.indexOf(r[t])&&e.classList.remove(r[t]);for(let t=0;t<s.length;t++)-1==r.indexOf(s[t])&&e.classList.add(s[t]);0==e.classList.length&&e.removeAttribute("class")}if(t.style!=n.style){if(t.style){let n,r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g;for(;n=r.exec(t.style);)e.style.removeProperty(n[1])}n.style&&(e.style.cssText+=n.style)}}function lu(e,t,n){return ou(e,e,su,iu(t,n,1!=e.nodeType))}function cu(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 du(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}class uu{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,s=e.childCount,i=new Map,o=[];e:for(;s>0;){let a;for(;;)if(r){let e=n.children[r-1];if(!(e instanceof Zd)){a=e,r--;break}n=e,r=e.children.length}else{if(n==t)break e;r=n.parent.children.indexOf(n),n=n.parent}let l=a.node;if(l){if(l!=e.child(s-1))break;--s,i.set(a,s),o.push(a)}}return{index:s,matched:i,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){let r=0,s=this.stack.length>>1,i=Math.min(s,e.length);for(;r<i&&(r==s-1?this.top:this.stack[r+1<<1]).matchesMark(e[r])&&!1!==e[r].type.spec.spanning;)r++;for(;r<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 r=-1;for(let t=this.index;t<Math.min(this.index+3,this.top.children.length);t++){let n=this.top.children[t];if(n.matchesMark(e[s])&&!this.isLocked(n.dom)){r=t;break}}if(r>-1)r>this.index&&(this.changed=!0,this.destroyBetween(this.index,r)),this.top=this.top.children[this.index];else{let r=Zd.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 s,i=-1;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 o=this.index,a=Math.min(this.top.children.length,o+5);o<a;o++){let r=this.top.children[o];if(r.matchesNode(e,t,n)&&!this.preMatch.matched.has(r)){i=o;break}}return!(i<0)&&(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(e,t,n,r,s){let i=this.top.children[r];return 3==i.dirty&&i.dom==i.contentDOM&&(i.dirty=2),!!i.update(e,t,n,s)&&(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,s,i){for(let o=this.index;o<this.top.children.length;o++){let a=this.top.children[o];if(a instanceof Qd){let l=this.preMatch.matched.get(a);if(null!=l&&l!=s)return!1;let c,d=a.dom,u=this.isLocked(d)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&3!=a.dirty&&cu(t,a.outerDeco));if(!u&&a.update(e,t,n,r))return this.destroyBetween(this.index,o),a.dom!=d&&(this.changed=!0),this.index++,!0;if(!u&&(c=this.recreateWrapper(a,e,t,n,r,i)))return this.destroyBetween(this.index,o),this.top.children[this.index]=c,c.contentDOM&&(c.dirty=2,c.updateChildren(r,i+1),c.dirty=0),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,n,r,s,i){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!cu(n,e.outerDeco)||!r.eq(e.innerDeco))return null;let o=Qd.create(this.top,t,n,r,s,i);if(o.contentDOM){o.children=e.children,e.children=[];for(let e of o.children)e.parent=o}return e.destroy(),o}addNode(e,t,n,r,s){let i=Qd.create(this.top,e,t,n,r,s);i.contentDOM&&i.updateChildren(r,s+1),this.top.children.splice(this.index++,0,i),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){let r=new Gd(this.top,e,t,n);this.top.children.splice(this.index++,0,r),this.changed=!0}else this.index++}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof Zd;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof Yd)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((bd||md)&&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 eu(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 pu(e,t){return e.type.side-t.type.side}function hu(e,t,n,r,s){let i=[];for(let o=0,a=0;o<e.length;o++){let l=e[o],c=a,d=a+=l.size;c>=n||d<=t?i.push(l):(c<t&&i.push(l.slice(0,t-c,r)),s&&(i.push(s),s=void 0),d>n&&i.push(l.slice(n-c,l.size,r)))}return i}function fu(e,t=null){let n=e.domSelectionRange(),r=e.state.doc;if(!n.focusNode)return null;let s=e.docView.nearestDesc(n.focusNode),i=s&&0==s.size,o=e.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(o<0)return null;let a,l,c=r.resolve(o);if(rd(n)){for(a=o;s&&!s.node;)s=s.parent;let e=s.node;if(s&&e.isAtom&&tc.isSelectable(e)&&s.parent&&(!e.isInline||!function(e,t,n){for(let r=0==t,s=t==td(e);r||s;){if(e==n)return!0;let t=Gc(e);if(!(e=e.parentNode))return!1;r=r&&0==t,s=s&&t==td(e)}}(n.focusNode,n.focusOffset,s.dom))){let e=s.posBefore;l=new tc(o==e?c:r.resolve(e))}}else{if(n instanceof e.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let t=o,s=o;for(let r=0;r<n.rangeCount;r++){let i=n.getRangeAt(r);t=Math.min(t,e.docView.posFromDOM(i.startContainer,i.startOffset,1)),s=Math.max(s,e.docView.posFromDOM(i.endContainer,i.endOffset,-1))}if(t<0)return null;[a,o]=s==e.state.selection.anchor?[s,t]:[t,s],c=r.resolve(o)}else a=e.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(a<0)return null}let d=r.resolve(a);if(!l){l=Su(e,d,c,"pointer"==t||e.state.selection.head<c.pos&&!i?1:-1)}return l}function mu(e){return e.editable?e.hasFocus():Mu(e)&&document.activeElement&&document.activeElement.contains(e.dom)}function gu(e,t=!1){let n=e.state.selection;if(xu(e,n),mu(e)){if(!t&&e.input.mouseDown&&e.input.mouseDown.allowDefault&&md){let t=e.domSelectionRange(),n=e.domObserver.currentSelection;if(t.anchorNode&&n.anchorNode&&Xc(t.anchorNode,t.anchorOffset,n.anchorNode,n.anchorOffset))return e.input.mouseDown.delayedSelectionSync=!0,void e.domObserver.setCurSelection()}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,Gc(n)+1):t.collapse(n,0);!r&&!e.state.selection.visible&&ud&&pd<=11&&(n.disabled=!0,n.disabled=!1)}(e);else{let r,s,{anchor:i,head:o}=n;!bu||n instanceof Yl||(n.$from.parent.inlineContent||(r=yu(e,n.from)),n.empty||n.$from.parent.inlineContent||(s=yu(e,n.to))),e.docView.setSelection(i,o,e,t),bu&&(r&&wu(r),s&&wu(s)),n.visible?e.dom.classList.remove("ProseMirror-hideselection"):(e.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&function(e){let t=e.dom.ownerDocument;t.removeEventListener("selectionchange",e.input.hideSelectionGuard);let n=e.domSelectionRange(),r=n.anchorNode,s=n.anchorOffset;t.addEventListener("selectionchange",e.input.hideSelectionGuard=()=>{n.anchorNode==r&&n.anchorOffset==s||(t.removeEventListener("selectionchange",e.input.hideSelectionGuard),setTimeout(()=>{mu(e)&&!e.state.selection.visible||e.dom.classList.remove("ProseMirror-hideselection")},20))})}(e))}e.domObserver.setCurSelection(),e.domObserver.connectSelection()}}const bu=bd||md&&gd<63;function yu(e,t){let{node:n,offset:r}=e.docView.domFromPos(t,0),s=r<n.childNodes.length?n.childNodes[r]:null,i=r?n.childNodes[r-1]:null;if(bd&&s&&"false"==s.contentEditable)return vu(s);if(!(s&&"false"!=s.contentEditable||i&&"false"!=i.contentEditable)){if(s)return vu(s);if(i)return vu(i)}}function vu(e){return e.contentEditable="true",bd&&e.draggable&&(e.draggable=!1,e.wasDraggable=!0),e}function wu(e){e.contentEditable="false",e.wasDraggable&&(e.draggable=!0,e.wasDraggable=null)}function xu(e,t){if(t instanceof tc){let n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&(ku(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else ku(e)}function ku(e){e.lastSelectedViewDesc&&(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),e.lastSelectedViewDesc=void 0)}function Su(e,t,n,r){return e.someProp("createSelectionBetween",r=>r(e,t,n))||Yl.between(t,n,r)}function Eu(e){return!(e.editable&&!e.hasFocus())&&Mu(e)}function Mu(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(n){return!1}}function _u(e,t){let{$anchor:n,$head:r}=e.selection,s=t>0?n.max(r):n.min(r),i=s.parent.inlineContent?s.depth?e.doc.resolve(t>0?s.after():s.before()):null:s;return i&&Jl.findFrom(i,t)}function Nu(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function Cu(e,t,n){let r=e.state.selection;if(!(r instanceof Yl)){if(r instanceof tc&&r.node.isInline)return Nu(e,new Yl(t>0?r.$to:r.$from));{let n=_u(e.state,t);return!!n&&Nu(e,n)}}if(n.indexOf("s")>-1){let{$head:n}=r,s=n.textOffset?null:t<0?n.nodeBefore:n.nodeAfter;if(!s||s.isText||!s.isLeaf)return!1;let i=e.state.doc.resolve(n.pos+s.nodeSize*(t<0?-1:1));return Nu(e,new Yl(r.$anchor,i))}if(!r.empty)return!1;if(e.endOfTextblock(t>0?"forward":"backward")){let n=_u(e.state,t);return!!(n&&n instanceof tc)&&Nu(e,n)}if(!(vd&&n.indexOf("m")>-1)){let n,s=r.$head,i=s.textOffset?null:t<0?s.nodeBefore:s.nodeAfter;if(!i||i.isText)return!1;let o=t<0?s.pos-i.nodeSize:s.pos;return!!(i.isAtom||(n=e.docView.descAt(o))&&!n.contentDOM)&&(tc.isSelectable(i)?Nu(e,new tc(t<0?e.state.doc.resolve(s.pos-i.nodeSize):s)):!!kd&&Nu(e,new Yl(e.state.doc.resolve(t<0?o:o+i.nodeSize))))}}function Ou(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function Au(e,t){let n=e.pmViewDesc;return n&&0==n.size&&(t<0||e.nextSibling||"BR"!=e.nodeName)}function Tu(e,t){return t<0?function(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let s,i,o=!1;hd&&1==n.nodeType&&r<Ou(n)&&Au(n.childNodes[r],-1)&&(o=!0);for(;;)if(r>0){if(1!=n.nodeType)break;{let e=n.childNodes[r-1];if(Au(e,-1))s=n,i=--r;else{if(3!=e.nodeType)break;n=e,r=n.nodeValue.length}}}else{if(Iu(n))break;{let t=n.previousSibling;for(;t&&Au(t,-1);)s=n.parentNode,i=Gc(t),t=t.previousSibling;if(t)n=t,r=Ou(n);else{if(n=n.parentNode,n==e.dom)break;r=0}}}o?Du(e,n,r):s&&Du(e,s,i)}(e):function(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let s,i,o=Ou(n);for(;;)if(r<o){if(1!=n.nodeType)break;if(!Au(n.childNodes[r],1))break;s=n,i=++r}else{if(Iu(n))break;{let t=n.nextSibling;for(;t&&Au(t,1);)s=t.parentNode,i=Gc(t)+1,t=t.nextSibling;if(t)n=t,r=0,o=Ou(n);else{if(n=n.parentNode,n==e.dom)break;r=o=0}}}s&&Du(e,s,i)}(e)}function Iu(e){let t=e.pmViewDesc;return t&&t.node&&t.node.isBlock}function Du(e,t,n){if(3!=t.nodeType){let e,r;(r=function(e,t){for(;e&&t==e.childNodes.length&&!nd(e);)t=Gc(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&&!nd(e);)t=Gc(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(rd(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:s}=e;setTimeout(()=>{e.state==s&&gu(e)},50)}function Ru(e,t){let n=e.state.doc.resolve(t);if(!md&&!wd&&n.parent.inlineContent){let r=e.coordsAtPos(t);if(t>n.start()){let n=e.coordsAtPos(t-1),s=(n.top+n.bottom)/2;if(s>r.top&&s<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),s=(n.top+n.bottom)/2;if(s>r.top&&s<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 Lu(e,t,n){let r=e.state.selection;if(r instanceof Yl&&!r.empty||n.indexOf("s")>-1)return!1;if(vd&&n.indexOf("m")>-1)return!1;let{$from:s,$to:i}=r;if(!s.parent.inlineContent||e.endOfTextblock(t<0?"up":"down")){let n=_u(e.state,t);if(n&&n instanceof tc)return Nu(e,n)}if(!s.parent.inlineContent){let n=t<0?s:i,o=r instanceof rc?Jl.near(n,t):Jl.findFrom(n,t);return!!o&&Nu(e,o)}return!1}function Pu(e,t){if(!(e.state.selection instanceof Yl))return!0;let{$head:n,$anchor:r,empty:s}=e.state.selection;if(!n.sameParent(r))return!0;if(!s)return!1;if(e.endOfTextblock(t>0?"forward":"backward"))return!0;let i=!n.textOffset&&(t<0?n.nodeBefore:n.nodeAfter);if(i&&!i.isText){let r=e.state.tr;return t<0?r.delete(n.pos-i.nodeSize,n.pos):r.delete(n.pos,n.pos+i.nodeSize),e.dispatch(r),!0}return!1}function ju(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function Bu(e,t){let n=t.keyCode,r=function(e){let t="";return e.ctrlKey&&(t+="c"),e.metaKey&&(t+="m"),e.altKey&&(t+="a"),e.shiftKey&&(t+="s"),t}(t);if(8==n||vd&&72==n&&"c"==r)return Pu(e,-1)||Tu(e,-1);if(46==n&&!t.shiftKey||vd&&68==n&&"c"==r)return Pu(e,1)||Tu(e,1);if(13==n||27==n)return!0;if(37==n||vd&&66==n&&"c"==r){let t=37==n?"ltr"==Ru(e,e.state.selection.from)?-1:1:-1;return Cu(e,t,r)||Tu(e,t)}if(39==n||vd&&70==n&&"c"==r){let t=39==n?"ltr"==Ru(e,e.state.selection.from)?1:-1:1;return Cu(e,t,r)||Tu(e,t)}return 38==n||vd&&80==n&&"c"==r?Lu(e,-1,r)||Tu(e,-1):40==n||vd&&78==n&&"c"==r?function(e){if(!bd||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;ju(e,n,"true"),setTimeout(()=>ju(e,n,"false"),20)}return!1}(e)||Lu(e,1,r)||Tu(e,1):r==(vd?"m":"c")&&(66==n||73==n||89==n||90==n)}function zu(e,t){e.someProp("transformCopied",n=>{t=n(t,e)});let n=[],{content:r,openStart:s,openEnd:i}=t;for(;s>1&&i>1&&1==r.childCount&&1==r.firstChild.childCount;){s--,i--;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")||Xa.fromSchema(e.state.schema),a=Ju(),l=a.createElement("div");l.appendChild(o.serializeFragment(r,{document:a}));let c,d=l.firstChild,u=0;for(;d&&1==d.nodeType&&(c=Wu[d.nodeName.toLowerCase()]);){for(let e=c.length-1;e>=0;e--){let t=a.createElement(c[e]);for(;l.firstChild;)t.appendChild(l.firstChild);l.appendChild(t),u++}d=l.firstChild}return d&&1==d.nodeType&&d.setAttribute("data-pm-slice",`${s} ${i}${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 $u(e,t,n,r,s){let i,o,a=s.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 ra(Qo.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,s,r,e));if(n)o=n;else{let n=s.marks(),{schema:r}=e.state,o=Xa.fromSchema(r);i=document.createElement("div"),t.split(/(?:\r\n?|\n)+/).forEach(e=>{let t=i.appendChild(document.createElement("p"));e&&t.appendChild(o.serializeNode(r.text(e,n)))})}}else e.someProp("transformPastedHTML",t=>{n=t(n,e)}),i=function(e){let t=/^(\s*<meta [^>]*>)*/.exec(e);t&&(e=e.slice(t[0].length));let n,r=Ju().createElement("div"),s=/<([a-z][^>\s]+)/i.exec(e);(n=s&&Wu[s[1].toLowerCase()])&&(e=n.map(e=>"<"+e+">").join("")+e+n.map(e=>"</"+e+">").reverse().join(""));if(r.innerHTML=function(e){let t=window.trustedTypes;if(!t)return e;Zu||(Zu=t.defaultPolicy||t.createPolicy("ProseMirrorClipboard",{createHTML:e=>e}));return Zu.createHTML(e)}(e),n)for(let i=0;i<n.length;i++)r=r.querySelector(n[i])||r;return r}(n),kd&&function(e){let t=e.querySelectorAll(md?"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&&"\xa0"==r.textContent&&r.parentNode&&r.parentNode.replaceChild(e.ownerDocument.createTextNode(" "),r)}}(i);let c=i&&i.querySelector("[data-pm-slice]"),d=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(d&&d[3])for(let u=+d[3];u>0;u--){let e=i.firstChild;for(;e&&1!=e.nodeType;)e=e.nextSibling;if(!e)break;i=e}if(!o){let t=e.someProp("clipboardParser")||e.someProp("domParser")||Ha.fromSchema(e.state.schema);o=t.parseSlice(i,{preserveWhitespace:!(!l&&!d),context:s,ruleFromNode:e=>"BR"!=e.nodeName||e.nextSibling||!e.parentNode||Fu.test(e.parentNode.nodeName)?null:{ignore:!0}})}if(d)o=function(e,t){if(!e.size)return e;let n,r=e.content.firstChild.type.schema;try{n=JSON.parse(t)}catch(a){return e}let{content:s,openStart:i,openEnd:o}=e;for(let l=n.length-2;l>=0;l-=2){let e=r.nodes[n[l]];if(!e||e.hasRequiredAttrs())break;s=Qo.from(e.create(n[l+1],s)),i++,o++}return new ra(s,i,o)}(Ku(o,+d[1],+d[2]),d[4]);else if(o=ra.maxOpen(function(e,t){if(e.childCount<2)return e;for(let n=t.depth;n>=0;n--){let r,s=t.node(n).contentMatchAt(t.index(n)),i=[];if(e.forEach(e=>{if(!i)return;let t,n=s.findWrapping(e.type);if(!n)return i=null;if(t=i.length&&r.length&&Uu(n,r,e,i[i.length-1],0))i[i.length-1]=t;else{i.length&&(i[i.length-1]=qu(i[i.length-1],r.length));let t=Hu(e,n);i.push(t),s=s.matchType(t.type),r=n}}),i)return Qo.from(i)}return e}(o.content,s),!0),o.openStart||o.openEnd){let e=0,t=0;for(let n=o.content.firstChild;e<o.openStart&&!n.type.spec.isolating;e++,n=n.firstChild);for(let n=o.content.lastChild;t<o.openEnd&&!n.type.spec.isolating;t++,n=n.lastChild);o=Ku(o,e,t)}return e.someProp("transformPasted",t=>{o=t(o,e,l)}),o}const Fu=/^(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 Hu(e,t,n=0){for(let r=t.length-1;r>=n;r--)e=t[r].create(null,Qo.from(e));return e}function Uu(e,t,n,r,s){if(s<e.length&&s<t.length&&e[s]==t[s]){let i=Uu(e,t,n,r.lastChild,s+1);if(i)return r.copy(r.content.replaceChild(r.childCount-1,i));if(r.contentMatchAt(r.childCount).matchType(s==e.length-1?n.type:e[s+1]))return r.copy(r.content.append(Qo.from(Hu(n,e,s+1))))}}function qu(e,t){if(0==t)return e;let n=e.content.replaceChild(e.childCount-1,qu(e.lastChild,t-1)),r=e.contentMatchAt(e.childCount).fillBefore(Qo.empty,!0);return e.copy(n.append(r))}function Vu(e,t,n,r,s,i){let o=t<0?e.firstChild:e.lastChild,a=o.content;return e.childCount>1&&(i=0),s<r-1&&(a=Vu(a,t,n,r,s+1,i)),s>=n&&(a=t<0?o.contentMatchAt(0).fillBefore(a,i<=s).append(a):a.append(o.contentMatchAt(o.childCount).fillBefore(Qo.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,o.copy(a))}function Ku(e,t,n){return t<e.openStart&&(e=new ra(Vu(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),n<e.openEnd&&(e=new ra(Vu(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}const Wu={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let Gu=null;function Ju(){return Gu||(Gu=document.implementation.createHTMLDocument("title"))}let Zu=null;const Qu={},Xu={},Yu={touchstart:!0,touchmove:!0};class ep{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.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function tp(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function np(e){e.someProp("handleDOMEvents",t=>{for(let n in t)e.input.eventHandlers[n]||e.dom.addEventListener(n,e.input.eventHandlers[n]=t=>rp(e,t))})}function rp(e,t){return e.someProp("handleDOMEvents",n=>{let r=n[t.type];return!!r&&(r(e,t)||t.defaultPrevented)})}function sp(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}function ip(e){return{left:e.clientX,top:e.clientY}}function op(e,t,n,r,s){if(-1==r)return!1;let i=e.state.doc.resolve(r);for(let o=i.depth+1;o>0;o--)if(e.someProp(t,t=>o>i.depth?t(e,n,i.nodeAfter,i.before(o),s,!0):t(e,n,i.node(o),i.before(o),s,!1)))return!0;return!1}function ap(e,t,n){if(e.focused||e.focus(),e.state.selection.eq(t))return;let r=e.state.tr.setSelection(t);r.setMeta("pointer",!0),e.dispatch(r)}function lp(e,t,n,r,s){return op(e,"handleClickOn",t,n,r)||e.someProp("handleClick",n=>n(e,t,r))||(s?function(e,t){if(-1==t)return!1;let n,r,s=e.state.selection;s instanceof tc&&(n=s.node);let i=e.state.doc.resolve(t);for(let o=i.depth+1;o>0;o--){let e=o>i.depth?i.nodeAfter:i.node(o);if(tc.isSelectable(e)){r=n&&s.$from.depth>0&&o>=s.$from.depth&&i.before(s.$from.depth+1)==s.$from.pos?i.before(s.$from.depth):i.before(o);break}}return null!=r&&(ap(e,tc.create(e.state.doc,r)),!0)}(e,n):function(e,t){if(-1==t)return!1;let n=e.state.doc.resolve(t),r=n.nodeAfter;return!!(r&&r.isAtom&&tc.isSelectable(r))&&(ap(e,new tc(n)),!0)}(e,n))}function cp(e,t,n,r){return op(e,"handleDoubleClickOn",t,n,r)||e.someProp("handleDoubleClick",n=>n(e,t,r))}function dp(e,t,n,r){return op(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&&(ap(e,Yl.create(r,0,r.content.size)),!0);let s=r.resolve(t);for(let i=s.depth+1;i>0;i--){let t=i>s.depth?s.nodeAfter:s.node(i),n=s.before(i);if(t.inlineContent)ap(e,Yl.create(r,n+1,n+1+t.content.size));else{if(!tc.isSelectable(t))continue;ap(e,tc.create(r,n))}return!0}}(e,n,r)}function up(e){return vp(e)}Xu.keydown=(e,t)=>{let n=t;if(e.input.shiftKey=16==n.keyCode||n.shiftKey,!fp(e,n)&&(e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),!xd||!md||13!=n.keyCode))if(229!=n.keyCode&&e.domObserver.forceFlush(),!yd||13!=n.keyCode||n.ctrlKey||n.altKey||n.metaKey)e.someProp("handleKeyDown",t=>t(e,n))||Bu(e,n)?n.preventDefault():tp(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,sd(13,"Enter"))),e.input.lastIOSEnter=0)},200)}},Xu.keyup=(e,t)=>{16==t.keyCode&&(e.input.shiftKey=!1)},Xu.keypress=(e,t)=>{let n=t;if(fp(e,n)||!n.charCode||n.ctrlKey&&!n.altKey||vd&&n.metaKey)return;if(e.someProp("handleKeyPress",t=>t(e,n)))return void n.preventDefault();let r=e.state.selection;if(!(r instanceof Yl&&r.$from.sameParent(r.$to))){let t=String.fromCharCode(n.charCode),s=()=>e.state.tr.insertText(t).scrollIntoView();/[\r\n]/.test(t)||e.someProp("handleTextInput",n=>n(e,r.$from.pos,r.$to.pos,t,s))||e.dispatch(s()),n.preventDefault()}};const pp=vd?"metaKey":"ctrlKey";Qu.mousedown=(e,t)=>{let n=t;e.input.shiftKey=n.shiftKey;let r=up(e),s=Date.now(),i="singleClick";s-e.input.lastClick.time<500&&function(e,t){let n=t.x-e.clientX,r=t.y-e.clientY;return n*n+r*r<100}(n,e.input.lastClick)&&!n[pp]&&e.input.lastClick.button==n.button&&("singleClick"==e.input.lastClick.type?i="doubleClick":"doubleClick"==e.input.lastClick.type&&(i="tripleClick")),e.input.lastClick={time:s,x:n.clientX,y:n.clientY,type:i,button:n.button};let o=e.posAtCoords(ip(n));o&&("singleClick"==i?(e.input.mouseDown&&e.input.mouseDown.done(),e.input.mouseDown=new hp(e,o,n,!!r)):("doubleClick"==i?cp:dp)(e,o.pos,o.inside,n)?n.preventDefault():tp(e,"pointer"))};class hp{constructor(e,t,n,r){let s,i;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[pp],this.allowDefault=n.shiftKey,t.inside>-1)s=e.state.doc.nodeAt(t.inside),i=t.inside;else{let n=e.state.doc.resolve(t.pos);s=n.parent,i=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&&s.type.spec.draggable&&!1!==s.type.spec.selectable||l instanceof tc&&l.from<=i&&l.to>i)&&(this.mightDrag={node:s,pos:i,addAttr:!(!this.target||this.target.draggable),setUneditable:!(!this.target||!hd||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)),tp(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(()=>gu(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(ip(e))),this.updateAllowDefault(e),this.allowDefault||!t?tp(this.view,"pointer"):lp(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():0==e.button&&(this.flushed||bd&&this.mightDrag&&!this.mightDrag.node.isAtom||md&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(ap(this.view,Jl.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):tp(this.view,"pointer")}move(e){this.updateAllowDefault(e),tp(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 fp(e,t){return!!e.composing||!!(bd&&Math.abs(t.timeStamp-e.input.compositionEndedAt)<500)&&(e.input.compositionEndedAt=-2e8,!0)}Qu.touchstart=e=>{e.input.lastTouch=Date.now(),up(e),tp(e,"pointer")},Qu.touchmove=e=>{e.input.lastTouch=Date.now(),tp(e,"pointer")},Qu.contextmenu=e=>up(e);const mp=xd?5e3:-1;function gp(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout(()=>vp(e),t))}function bp(e){for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=function(){let e=document.createEvent("Event");return e.initEvent("event",!0,!0),e.timeStamp}());e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function yp(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=td(e=e.childNodes[t-1])}else{if(!e.parentNode||nd(e))return null;t=Gc(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||nd(e))return null;t=Gc(e)+1,e=e.parentNode}}}(t.focusNode,t.focusOffset);if(n&&r&&n!=r){let t=r.pmViewDesc,s=e.domObserver.lastChangedTextNode;if(n==s||r==s)return s;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}function vp(e,t=!1){if(!(xd&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),bp(e),t||e.docView&&e.docView.dirty){let n=fu(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.updateState(e.state):e.dispatch(e.state.tr.deleteSelection()),!0}return!1}}Xu.compositionstart=Xu.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,n=t.selection.$to;if(t.selection instanceof Yl&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(e=>!1===e.type.spec.inclusive)))e.markCursor=e.state.storedMarks||n.marks(),vp(e,!0),e.markCursor=null;else if(vp(e,!t.selection.empty),hd&&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}gp(e,mp)},Xu.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.compositionPendingChanges&&Promise.resolve().then(()=>e.domObserver.flush()),e.input.compositionID++,gp(e,20))};const wp=ud&&pd<15||yd&&Sd<604;function xp(e,t,n,r,s){let i=$u(e,t,n,r,e.state.selection.$from);if(e.someProp("handlePaste",t=>t(e,s,i||ra.empty)))return!0;if(!i)return!1;let o=function(e){return 0==e.openStart&&0==e.openEnd&&1==e.content.childCount?e.content.firstChild:null}(i),a=o?e.state.tr.replaceSelectionWith(o,r):e.state.tr.replaceSelection(i);return e.dispatch(a.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function kp(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," "):""}Qu.copy=Xu.cut=(e,t)=>{let n=t,r=e.state.selection,s="cut"==n.type;if(r.empty)return;let i=wp?null:n.clipboardData,o=r.content(),{dom:a,text:l}=zu(e,o);i?(n.preventDefault(),i.clearData(),i.setData("text/html",a.innerHTML),i.setData("text/plain",l)):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(),s=document.createRange();s.selectNodeContents(t),e.dom.blur(),r.removeAllRanges(),r.addRange(s),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),e.focus()},50)}(e,a),s&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))},Xu.paste=(e,t)=>{let n=t;if(e.composing&&!xd)return;let r=wp?null:n.clipboardData,s=e.input.shiftKey&&45!=e.input.lastKeyCode;r&&xp(e,kp(r),r.getData("text/html"),s,n)?n.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 s=e.input.shiftKey&&45!=e.input.lastKeyCode;setTimeout(()=>{e.focus(),r.parentNode&&r.parentNode.removeChild(r),n?xp(e,r.value,null,s,t):xp(e,r.textContent,r.innerHTML,s,t)},50)}(e,n)};class Sp{constructor(e,t,n){this.slice=e,this.move=t,this.node=n}}const Ep=vd?"altKey":"ctrlKey";function Mp(e,t){let n=e.someProp("dragCopies",e=>!e(t));return null!=n?n:!t[Ep]}Qu.dragstart=(e,t)=>{let n=t,r=e.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let s,i=e.state.selection,o=i.empty?null:e.posAtCoords(ip(n));if(o&&o.pos>=i.from&&o.pos<=(i instanceof tc?i.to-1:i.to));else if(r&&r.mightDrag)s=tc.create(e.state.doc,r.mightDrag.pos);else if(n.target&&1==n.target.nodeType){let t=e.docView.nearestDesc(n.target,!0);t&&t.node.type.spec.draggable&&t!=e.docView&&(s=tc.create(e.state.doc,t.posBefore))}let a=(s||e.state.selection).content(),{dom:l,text:c,slice:d}=zu(e,a);(!n.dataTransfer.files.length||!md||gd>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(wp?"Text":"text/html",l.innerHTML),n.dataTransfer.effectAllowed="copyMove",wp||n.dataTransfer.setData("text/plain",c),e.dragging=new Sp(d,Mp(e,n),s)},Qu.dragend=e=>{let t=e.dragging;window.setTimeout(()=>{e.dragging==t&&(e.dragging=null)},50)},Xu.dragover=Xu.dragenter=(e,t)=>t.preventDefault(),Xu.drop=(e,t)=>{let n=t,r=e.dragging;if(e.dragging=null,!n.dataTransfer)return;let s=e.posAtCoords(ip(n));if(!s)return;let i=e.state.doc.resolve(s.pos),o=r&&r.slice;o?e.someProp("transformPasted",t=>{o=t(o,e,!1)}):o=$u(e,kp(n.dataTransfer),wp?null:n.dataTransfer.getData("text/html"),!1,i);let a=!(!r||!Mp(e,n));if(e.someProp("handleDrop",t=>t(e,n,o||ra.empty,a)))return void n.preventDefault();if(!o)return;n.preventDefault();let l=o?Il(e.state.doc,i.pos,o):i.pos;null==l&&(l=i.pos);let c=e.state.tr;if(a){let{node:e}=r;e?e.replace(c):c.deleteSelection()}let d=c.mapping.map(l),u=0==o.openStart&&0==o.openEnd&&1==o.content.childCount,p=c.doc;if(u?c.replaceRangeWith(d,d,o.content.firstChild):c.replaceRange(d,d,o),c.doc.eq(p))return;let h=c.doc.resolve(d);if(u&&tc.isSelectable(o.content.firstChild)&&h.nodeAfter&&h.nodeAfter.sameMarkup(o.content.firstChild))c.setSelection(new tc(h));else{let t=c.mapping.map(l);c.mapping.maps[c.mapping.maps.length-1].forEach((e,n,r,s)=>t=s),c.setSelection(Su(e,h,c.doc.resolve(t)))}e.focus(),e.dispatch(c.setMeta("uiEvent","drop"))},Qu.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())&&gu(e)},20))},Qu.blur=(e,t)=>{let n=t;e.focused&&(e.domObserver.stop(),e.dom.classList.remove("ProseMirror-focused"),e.domObserver.start(),n.relatedTarget&&e.dom.contains(n.relatedTarget)&&e.domObserver.currentSelection.clear(),e.focused=!1)},Qu.beforeinput=(e,t)=>{if(md&&xd&&"deleteContentBackward"==t.inputType){e.domObserver.flushSoon();let{domChangeCount:t}=e.input;setTimeout(()=>{if(e.input.domChangeCount!=t)return;if(e.dom.blur(),e.focus(),e.someProp("handleKeyDown",t=>t(e,sd(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)}};for(let os in Xu)Qu[os]=Xu[os];function _p(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 Np{constructor(e,t){this.toDOM=e,this.spec=t||Ip,this.side=this.spec.side||0}map(e,t,n,r){let{pos:s,deleted:i}=e.mapResult(t.from+r,this.side<0?-1:1);return i?null:new Ap(s-n,s-n,this)}valid(){return!0}eq(e){return this==e||e instanceof Np&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&_p(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Cp{constructor(e,t){this.attrs=e,this.spec=t||Ip}map(e,t,n,r){let s=e.map(t.from+r,this.spec.inclusiveStart?-1:1)-n,i=e.map(t.to+r,this.spec.inclusiveEnd?1:-1)-n;return s>=i?null:new Ap(s,i,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof Cp&&_p(this.attrs,e.attrs)&&_p(this.spec,e.spec)}static is(e){return e.type instanceof Cp}destroy(){}}class Op{constructor(e,t){this.attrs=e,this.spec=t||Ip}map(e,t,n,r){let s=e.mapResult(t.from+r,1);if(s.deleted)return null;let i=e.mapResult(t.to+r,-1);return i.deleted||i.pos<=s.pos?null:new Ap(s.pos-n,i.pos-n,this)}valid(e,t){let n,{index:r,offset:s}=e.content.findIndex(t.from);return s==t.from&&!(n=e.child(r)).isText&&s+n.nodeSize==t.to}eq(e){return this==e||e instanceof Op&&_p(this.attrs,e.attrs)&&_p(this.spec,e.spec)}destroy(){}}class Ap{constructor(e,t,n){this.from=e,this.to=t,this.type=n}copy(e,t){return new Ap(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 Ap(e,e,new Np(t,n))}static inline(e,t,n,r){return new Ap(e,t,new Cp(n,r))}static node(e,t,n,r){return new Ap(e,t,new Op(n,r))}get spec(){return this.type.spec}get inline(){return this.type instanceof Cp}get widget(){return this.type instanceof Np}}const Tp=[],Ip={};class Dp{constructor(e,t){this.local=e.length?e:Tp,this.children=t.length?t:Tp}static create(e,t){return t.length?zp(t,e,0,Ip):Rp}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,s){for(let i=0;i<this.local.length;i++){let o=this.local[i];o.from<=t&&o.to>=e&&(!s||s(o.spec))&&n.push(o.copy(o.from+r,o.to+r))}for(let i=0;i<this.children.length;i+=3)if(this.children[i]<t&&this.children[i+1]>e){let o=this.children[i]+1;this.children[i+2].findInner(e-o,t-o,n,r+o,s)}}map(e,t,n){return this==Rp||0==e.maps.length?this:this.mapInner(e,t,0,0,n||Ip)}mapInner(e,t,n,r,s){let i;for(let o=0;o<this.local.length;o++){let a=this.local[o].map(e,n,r);a&&a.type.valid(t,a)?(i||(i=[])).push(a):s.onRemove&&s.onRemove(this.local[o].spec)}return this.children.length?function(e,t,n,r,s,i,o){let a=e.slice();for(let c=0,d=i;c<n.maps.length;c++){let e=0;n.maps[c].forEach((t,n,r,s)=>{let i=s-r-(n-t);for(let o=0;o<a.length;o+=3){let r=a[o+1];if(r<0||t>r+d-e)continue;let s=a[o]+d-e;n>=s?a[o+1]=t<=s?-2:-1:t>=d&&i&&(a[o]+=i,a[o+1]+=i)}e+=i}),d=n.maps[c].map(d,-1)}let l=!1;for(let c=0;c<a.length;c+=3)if(a[c+1]<0){if(-2==a[c+1]){l=!0,a[c+1]=-1;continue}let t=n.map(e[c]+i),d=t-s;if(d<0||d>=r.content.size){l=!0;continue}let u=n.map(e[c+1]+i,-1)-s,{index:p,offset:h}=r.content.findIndex(d),f=r.maybeChild(p);if(f&&h==d&&h+f.nodeSize==u){let r=a[c+2].mapInner(n,f,t+1,e[c]+i+1,o);r!=Rp?(a[c]=d,a[c+1]=u,a[c+2]=r):(a[c+1]=-2,l=!0)}else l=!0}if(l){let l=function(e,t,n,r,s,i,o){function a(e,t){for(let i=0;i<e.local.length;i++){let a=e.local[i].map(r,s,t);a?n.push(a):o.onRemove&&o.onRemove(e.local[i].spec)}for(let n=0;n<e.children.length;n+=3)a(e.children[n+2],e.children[n]+t+1)}for(let l=0;l<e.length;l+=3)-1==e[l+1]&&a(e[l+2],t[l]+i+1);return n}(a,e,t,n,s,i,o),c=zp(l,r,0,o);t=c.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<c.children.length;e+=3){let n=c.children[e];for(;t<a.length&&a[t]<n;)t+=3;a.splice(t,0,c.children[e],c.children[e+1],c.children[e+2])}}return new Dp(t.sort($p),a)}(this.children,i||[],e,t,n,r,s):i?new Dp(i.sort($p),Tp):Rp}add(e,t){return t.length?this==Rp?Dp.create(e,t):this.addInner(e,t,0):this}addInner(e,t,n){let r,s=0;e.forEach((e,i)=>{let o,a=i+n;if(o=jp(t,e,a)){for(r||(r=this.children.slice());s<r.length&&r[s]<i;)s+=3;r[s]==i?r[s+2]=r[s+2].addInner(e,o,a+1):r.splice(s,0,i,i+e.nodeSize,zp(o,e,a+1,Ip)),s+=3}});let i=Pp(s?Bp(t):t,-n);for(let o=0;o<i.length;o++)i[o].type.valid(e,i[o])||i.splice(o--,1);return new Dp(i.length?this.local.concat(i).sort($p):this.local,r||this.children)}remove(e){return 0==e.length||this==Rp?this:this.removeInner(e,0)}removeInner(e,t){let n=this.children,r=this.local;for(let s=0;s<n.length;s+=3){let r,i=n[s]+t,o=n[s+1]+t;for(let t,n=0;n<e.length;n++)(t=e[n])&&t.from>i&&t.to<o&&(e[n]=null,(r||(r=[])).push(t));if(!r)continue;n==this.children&&(n=this.children.slice());let a=n[s+2].removeInner(r,i+1);a!=Rp?n[s+2]=a:(n.splice(s,3),s-=3)}if(r.length)for(let s,i=0;i<e.length;i++)if(s=e[i])for(let e=0;e<r.length;e++)r[e].eq(s,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 Dp(r,n):Rp}forChild(e,t){if(this==Rp)return this;if(t.isLeaf)return Dp.empty;let n,r;for(let o=0;o<this.children.length;o+=3)if(this.children[o]>=e){this.children[o]==e&&(n=this.children[o+2]);break}let s=e+1,i=s+t.content.size;for(let o=0;o<this.local.length;o++){let e=this.local[o];if(e.from<i&&e.to>s&&e.type instanceof Cp){let t=Math.max(s,e.from)-s,n=Math.min(i,e.to)-s;t<n&&(r||(r=[])).push(e.copy(t,n))}}if(r){let e=new Dp(r.sort($p),Tp);return n?new Lp([e,n]):e}return n||Rp}eq(e){if(this==e)return!0;if(!(e instanceof Dp)||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 Fp(this.localsInner(e))}localsInner(e){if(this==Rp)return Tp;if(e.inlineContent||!this.local.some(Cp.is))return this.local;let t=[];for(let n=0;n<this.local.length;n++)this.local[n].type instanceof Cp||t.push(this.local[n]);return t}forEachSet(e){e(this)}}Dp.empty=new Dp([],[]),Dp.removeOverlap=Fp;const Rp=Dp.empty;class Lp{constructor(e){this.members=e}map(e,t){const n=this.members.map(n=>n.map(e,t,Ip));return Lp.from(n)}forChild(e,t){if(t.isLeaf)return Dp.empty;let n=[];for(let r=0;r<this.members.length;r++){let s=this.members[r].forChild(e,t);s!=Rp&&(s instanceof Lp?n=n.concat(s.members):n.push(s))}return Lp.from(n)}eq(e){if(!(e instanceof Lp)||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 s=this.members[r].localsInner(e);if(s.length)if(t){n&&(t=t.slice(),n=!1);for(let e=0;e<s.length;e++)t.push(s[e])}else t=s}return t?Fp(n?t:t.sort($p)):Tp}static from(e){switch(e.length){case 0:return Rp;case 1:return e[0];default:return new Lp(e.every(e=>e instanceof Dp)?e:e.reduce((e,t)=>e.concat(t instanceof Dp?t:t.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function Pp(e,t){if(!t||!e.length)return e;let n=[];for(let r=0;r<e.length;r++){let s=e[r];n.push(new Ap(s.from+t,s.to+t,s.type))}return n}function jp(e,t,n){if(t.isLeaf)return null;let r=n+t.nodeSize,s=null;for(let i,o=0;o<e.length;o++)(i=e[o])&&i.from>n&&i.to<r&&((s||(s=[])).push(i),e[o]=null);return s}function Bp(e){let t=[];for(let n=0;n<e.length;n++)null!=e[n]&&t.push(e[n]);return t}function zp(e,t,n,r){let s=[],i=!1;t.forEach((t,o)=>{let a=jp(e,t,o+n);if(a){i=!0;let e=zp(a,t,n+o+1,r);e!=Rp&&s.push(o,o+t.nodeSize,e)}});let o=Pp(i?Bp(e):e,-n).sort($p);for(let a=0;a<o.length;a++)o[a].type.valid(t,o[a])||(r.onRemove&&r.onRemove(o[a].spec),o.splice(a--,1));return o.length||s.length?new Dp(o,s):Rp}function $p(e,t){return e.from-t.from||e.to-t.to}function Fp(e){let t=e;for(let n=0;n<t.length-1;n++){let r=t[n];if(r.from!=r.to)for(let s=n+1;s<t.length;s++){let i=t[s];if(i.from!=r.from){i.from<r.to&&(t==e&&(t=e.slice()),t[n]=r.copy(r.from,i.from),Hp(t,s,r.copy(i.from,r.to)));break}i.to!=r.to&&(t==e&&(t=e.slice()),t[s]=i.copy(i.from,r.to),Hp(t,s+1,i.copy(r.to,i.to)))}}return t}function Hp(e,t,n){for(;t<e.length&&$p(n,e[t])>0;)t++;e.splice(t,0,n)}function Up(e){let t=[];return e.someProp("decorations",n=>{let r=n(e.state);r&&r!=Rp&&t.push(r)}),e.cursorWrapper&&t.push(Dp.create(e.state.doc,[e.cursorWrapper.deco])),Lp.from(t)}const qp={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Vp=ud&&pd<=11;class Kp{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 Wp{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Kp,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(e=>{for(let t=0;t<e.length;t++)this.queue.push(e[t]);ud&&pd<=11&&e.some(e=>"childList"==e.type&&e.removedNodes.length||"characterData"==e.type&&e.oldValue.length>e.target.nodeValue.length)?this.flushSoon():this.flush()}),Vp&&(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,qp)),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(Eu(this.view)){if(this.suppressingSelectionUpdates)return gu(this.view);if(ud&&pd<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Xc(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,n=new Set;for(let s=e.focusNode;s;s=Jc(s))n.add(s);for(let s=e.anchorNode;s;s=Jc(s))if(n.has(s)){t=s;break}let r=t&&this.view.docView.nearestDesc(t);return r&&r.ignoreMutation({type:"selection",target:3==t.nodeType?t.parentNode:t})?(this.setCurSelection(),!0):void 0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let n=e.domSelectionRange(),r=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&Eu(e)&&!this.ignoreSelectionChange(n),s=-1,i=-1,o=!1,a=[];if(e.editable)for(let c=0;c<t.length;c++){let e=this.registerMutation(t[c],a);e&&(s=s<0?e.from:Math.min(e.from,s),i=i<0?e.to:Math.max(e.to,i),e.typeOver&&(o=!0))}if(hd&&a.length){let t=a.filter(e=>"BR"==e.nodeName);if(2==t.length){let[e,n]=t;e.parentNode&&e.parentNode.parentNode==n.parentNode?n.remove():e.remove()}else{let{focusNode:n}=this.currentSelection;for(let r of t){let t=r.parentNode;!t||"LI"!=t.nodeName||n&&Qp(e,n)==t||r.remove()}}}let l=null;s<0&&r&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&rd(n)&&(l=fu(e))&&l.eq(Jl.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,gu(e),this.currentSelection.set(n),e.scrollToSelection()):(s>-1||r)&&(s>-1&&(e.docView.markDirty(s,i),function(e){if(Gp.has(e))return;if(Gp.set(e,null),-1!==["normal","nowrap","pre-line"].indexOf(getComputedStyle(e.dom).whiteSpace)){if(e.requiresGeckoHackNode=hd,Jp)return;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."),Jp=!0}}(e)),this.handleDOMChange(s,i,o,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(n)||gu(e),this.currentSelection.set(n))}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")))return null;if(!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,s=e.nextSibling;if(ud&&pd<=11&&e.addedNodes.length)for(let t=0;t<e.addedNodes.length;t++){let{previousSibling:n,nextSibling:i}=e.addedNodes[t];(!n||Array.prototype.indexOf.call(e.addedNodes,n)<0)&&(r=n),(!i||Array.prototype.indexOf.call(e.addedNodes,i)<0)&&(s=i)}let i=r&&r.parentNode==e.target?Gc(r)+1:0,o=n.localPosFromDOM(e.target,i,-1),a=s&&s.parentNode==e.target?Gc(s):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 Gp=new WeakMap,Jp=!1;function Zp(e,t){let n=t.startContainer,r=t.startOffset,s=t.endContainer,i=t.endOffset,o=e.domAtPos(e.state.selection.anchor);return Xc(o.node,o.offset,s,i)&&([n,r,s,i]=[s,i,n,r]),{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:i}}function Qp(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}function Xp(e){let t=e.pmViewDesc;if(t)return t.parseRule();if("BR"==e.nodeName&&e.parentNode){if(bd&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let e=document.createElement("div");return e.appendChild(document.createElement("li")),{skip:e}}if(e.parentNode.lastChild==e||bd&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if("IMG"==e.nodeName&&e.getAttribute("mark-placeholder"))return{ignore:!0};return null}const Yp=/^(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 eh(e,t,n,r,s){let i=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=fu(e,t);if(n&&!e.state.selection.eq(n)){if(md&&xd&&13===e.input.lastKeyCode&&Date.now()-100<e.input.lastKeyCodeTime&&e.someProp("handleKeyDown",t=>t(e,sd(13,"Enter"))))return;let r=e.state.tr.setSelection(n);"pointer"==t?r.setMeta("pointer",!0):"key"==t&&r.scrollIntoView(),i&&r.setMeta("composition",i),e.dispatch(r)}return}let o=e.state.doc.resolve(t),a=o.sharedDepth(n);t=o.before(a+1),n=e.state.doc.resolve(n).after(a+1);let l,c,d=e.state.selection,u=function(e,t,n){let r,{node:s,fromOffset:i,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}],rd(c)||r.push({node:c.focusNode,offset:c.focusOffset})),md&&8===e.input.lastKeyCode)for(let g=o;g>i;g--){let e=s.childNodes[g-1],t=e.pmViewDesc;if("BR"==e.nodeName&&!t){o=g;break}if(!t||t.size)break}let u=e.state.doc,p=e.someProp("domParser")||Ha.fromSchema(e.state.schema),h=u.resolve(a),f=null,m=p.parse(s,{topNode:h.parent,topMatch:h.parent.contentMatchAt(h.index()),topOpen:!0,from:i,to:o,preserveWhitespace:"pre"!=h.parent.type.whitespace||"full",findPositions:r,ruleFromNode:Xp,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),p=e.state.doc,h=p.slice(u.from,u.to);8===e.input.lastKeyCode&&Date.now()-100<e.input.lastKeyCodeTime?(l=e.state.selection.to,c="end"):(l=e.state.selection.from,c="start"),e.input.lastKeyCode=null;let f=function(e,t,n,r,s){let i=e.findDiffStart(t,n);if(null==i)return null;let{a:o,b:a}=e.findDiffEnd(t,n+e.size,n+t.size);if("end"==s){r-=o+Math.max(0,i-Math.min(o,a))-i}if(o<i&&e.size<t.size){let e=r<=i&&r>=o?i-r:0;i-=e,i&&i<t.size&&rh(t.textBetween(i-1,i+1))&&(i+=e?1:-1),a=i+(a-o),o=i}else if(a<i){let t=r<=i&&r>=a?i-r:0;i-=t,i&&i<e.size&&rh(e.textBetween(i-1,i+1))&&(i+=t?1:-1),o=i+(o-a),a=i}return{start:i,endA:o,endB:a}}(h.content,u.doc.content,u.from,l,c);if(f&&e.input.domChangeCount++,(yd&&e.input.lastIOSEnter>Date.now()-225||xd)&&s.some(e=>1==e.nodeType&&!Yp.test(e.nodeName))&&(!f||f.endA>=f.endB)&&e.someProp("handleKeyDown",t=>t(e,sd(13,"Enter"))))return void(e.input.lastIOSEnter=0);if(!f){if(!(r&&d instanceof Yl&&!d.empty&&d.$head.sameParent(d.$anchor))||e.composing||u.sel&&u.sel.anchor!=u.sel.head){if(u.sel){let t=th(e,e.state.doc,u.sel);if(t&&!t.eq(e.state.selection)){let n=e.state.tr.setSelection(t);i&&n.setMeta("composition",i),e.dispatch(n)}}return}f={start:d.from,endA:d.to,endB:d.to}}e.state.selection.from<e.state.selection.to&&f.start==f.endB&&e.state.selection instanceof Yl&&(f.start>e.state.selection.from&&f.start<=e.state.selection.from+2&&e.state.selection.from>=u.from?f.start=e.state.selection.from:f.endA<e.state.selection.to&&f.endA>=e.state.selection.to-2&&e.state.selection.to<=u.to&&(f.endB+=e.state.selection.to-f.endA,f.endA=e.state.selection.to)),ud&&pd<=11&&f.endB==f.start+1&&f.endA==f.start&&f.start>u.from&&" \xa0"==u.doc.textBetween(f.start-u.from-1,f.start-u.from+1)&&(f.start--,f.endA--,f.endB--);let m=u.doc.resolveNoCache(f.start-u.from),g=u.doc.resolveNoCache(f.endB-u.from),b=p.resolve(f.start),y=m.sameParent(g)&&m.parent.inlineContent&&b.end()>=f.endA;if((yd&&e.input.lastIOSEnter>Date.now()-225&&(!y||s.some(e=>"DIV"==e.nodeName||"P"==e.nodeName))||!y&&m.pos<u.doc.content.size&&(!m.sameParent(g)||!m.parent.inlineContent)&&m.pos<g.pos&&!/\S/.test(u.doc.textBetween(m.pos,g.pos,"","")))&&e.someProp("handleKeyDown",t=>t(e,sd(13,"Enter"))))return void(e.input.lastIOSEnter=0);if(e.state.selection.anchor>f.start&&function(e,t,n,r,s){if(n-t<=s.pos-r.pos||nh(r,!0,!1)<s.pos)return!1;let i=e.resolve(t);if(!r.parent.isTextblock){let e=i.nodeAfter;return null!=e&&n==t+e.nodeSize}if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;let o=e.resolve(nh(i,!0,!0));return!(!o.parent.isTextblock||o.pos>n||nh(o,!0,!1)<n)&&r.parent.content.cut(r.parentOffset).eq(o.parent.content)}(p,f.start,f.endA,m,g)&&e.someProp("handleKeyDown",t=>t(e,sd(8,"Backspace"))))return void(xd&&md&&e.domObserver.suppressSelectionUpdates());md&&f.endB==f.start&&(e.input.lastChromeDelete=Date.now()),xd&&!y&&m.start()!=g.start()&&0==g.parentOffset&&m.depth==g.depth&&u.sel&&u.sel.anchor==u.sel.head&&u.sel.head==f.endA&&(f.endB-=2,g=u.doc.resolveNoCache(f.endB-u.from),setTimeout(()=>{e.someProp("handleKeyDown",function(t){return t(e,sd(13,"Enter"))})},20));let v,w=f.start,x=f.endA,k=t=>{let n=t||e.state.tr.replace(w,x,u.doc.slice(f.start-u.from,f.endB-u.from));if(u.sel){let t=th(e,n.doc,u.sel);t&&!(md&&e.composing&&t.empty&&(f.start!=f.endB||e.input.lastChromeDelete<Date.now()-100)&&(t.head==w||t.head==n.mapping.map(x)-1)||ud&&t.empty&&t.head==w)&&n.setSelection(t)}return i&&n.setMeta("composition",i),n.scrollIntoView()};if(y)if(m.pos==g.pos){ud&&pd<=11&&0==m.parentOffset&&(e.domObserver.suppressSelectionUpdates(),setTimeout(()=>gu(e),20));let t=k(e.state.tr.delete(w,x)),n=p.resolve(f.start).marksAcross(p.resolve(f.endA));n&&t.ensureMarks(n),e.dispatch(t)}else if(f.endA==f.endB&&(v=function(e,t){let n,r,s,i=e.firstChild.marks,o=t.firstChild.marks,a=i,l=o;for(let d=0;d<o.length;d++)a=o[d].removeFromSet(a);for(let d=0;d<i.length;d++)l=i[d].removeFromSet(l);if(1==a.length&&0==l.length)r=a[0],n="add",s=e=>e.mark(r.addToSet(e.marks));else{if(0!=a.length||1!=l.length)return null;r=l[0],n="remove",s=e=>e.mark(r.removeFromSet(e.marks))}let c=[];for(let d=0;d<t.childCount;d++)c.push(s(t.child(d)));if(Qo.from(c).eq(e))return{mark:r,type:n}}(m.parent.content.cut(m.parentOffset,g.parentOffset),b.parent.content.cut(b.parentOffset,f.endA-b.start())))){let t=k(e.state.tr);"add"==v.type?t.addMark(w,x,v.mark):t.removeMark(w,x,v.mark),e.dispatch(t)}else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let t=m.parent.textBetween(m.parentOffset,g.parentOffset),n=()=>k(e.state.tr.insertText(t,w,x));e.someProp("handleTextInput",r=>r(e,w,x,t,n))||e.dispatch(n())}else e.dispatch(k());else e.dispatch(k())}function th(e,t,n){return Math.max(n.anchor,n.head)>t.content.size?null:Su(e,t.resolve(n.anchor),t.resolve(n.head))}function nh(e,t,n){let r=e.depth,s=t?e.end():e.pos;for(;r>0&&(t||e.indexAfter(r)==e.node(r).childCount);)r--,s++,t=!1;if(n){let t=e.node(r).maybeChild(e.indexAfter(r));for(;t&&!t.isLeaf;)t=t.firstChild,s++}return s}function rh(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 sh{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 ep,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(ch),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=ah(this),oh(this),this.nodeViews=lh(this),this.docView=Xd(this.state.doc,ih(this),Up(this),this.dom,this),this.domObserver=new Wp(this,(e,t,n,r)=>eh(this,e,t,n,r)),this.domObserver.start(),function(e){for(let t in Qu){let n=Qu[t];e.dom.addEventListener(t,e.input.eventHandlers[t]=t=>{!sp(e,t)||rp(e,t)||!e.editable&&t.type in Xu||n(e,t)},Yu[t]?{passive:!0}:void 0)}bd&&e.dom.addEventListener("input",()=>null),np(e)}(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&np(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(ch),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let n in this._props)t[n]=this._props[n];t.state=this.state;for(let n in e)t[n]=e[n];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var n;let r=this.state,s=!1,i=!1;e.storedMarks&&this.composing&&(bp(this),i=!0),this.state=e;let o=r.plugins!=e.plugins||this._props.plugins!=t.plugins;if(o||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let e=lh(this);(function(e,t){let n=0,r=0;for(let s in e){if(e[s]!=t[s])return!0;n++}for(let s in t)r++;return n!=r})(e,this.nodeViews)&&(this.nodeViews=e,s=!0)}(o||t.handleDOMEvents!=this._props.handleDOMEvents)&&np(this),this.editable=ah(this),oh(this);let a=Up(this),l=ih(this),c=r.plugins==e.plugins||r.doc.eq(e.doc)?e.scrollToSelection>r.scrollToSelection?"to selection":"preserve":"reset",d=s||!this.docView.matchesNode(e.doc,l,a);!d&&e.selection.eq(r.selection)||(i=!0);let u="preserve"==c&&i&&null==this.dom.style.overflowAnchor&&function(e){let t,n,r=e.dom.getBoundingClientRect(),s=Math.max(0,r.top);for(let i=(r.left+r.right)/2,o=s+1;o<Math.min(innerHeight,r.bottom);o+=5){let r=e.root.elementFromPoint(i,o);if(!r||r==e.dom||!e.dom.contains(r))continue;let a=r.getBoundingClientRect();if(a.top>=s-20){t=r,n=a.top;break}}return{refDOM:t,refTop:n,stack:Cd(e.dom)}}(this);if(i){this.domObserver.stop();let t=d&&(ud||md)&&!this.composing&&!r.selection.empty&&!e.selection.empty&&function(e,t){let n=Math.min(e.$anchor.sharedDepth(e.head),t.$anchor.sharedDepth(t.head));return e.$anchor.start(n)!=t.$anchor.start(n)}(r.selection,e.selection);if(d){let n=md?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=yp(this)),!s&&this.docView.update(e.doc,l,a,this)||(this.docView.updateOuterDeco(l),this.docView.destroy(),this.docView=Xd(e.doc,l,a,this.dom,this)),n&&!this.trackWrites&&(t=!0)}t||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&function(e){let t=e.docView.domFromPos(e.state.selection.anchor,0),n=e.domSelectionRange();return Xc(t.node,t.offset,n.anchorNode,n.anchorOffset)}(this))?gu(this,t):(xu(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(r),(null===(n=this.dragging)||void 0===n?void 0:n.node)&&!r.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,r),"reset"==c?this.dom.scrollTop=0:"to selection"==c?this.scrollToSelection():u&&function({refDOM:e,refTop:t,stack:n}){let r=e?e.getBoundingClientRect().top:0;Od(n,0==r?0:r-t)}(u)}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 tc){let t=this.docView.domAfterPos(this.state.selection.from);1==t.nodeType&&Nd(this,t.getBoundingClientRect(),e)}else Nd(this,this.coordsAtPos(this.state.selection.head,1),e);else;}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(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&&this.state.doc.nodeAt(e))==n.node&&(r=e)}this.dragging=new Sp(e.slice,e.move,r<0?void 0:tc.create(this.state.doc,r))}someProp(e,t){let n,r=this._props&&this._props[e];if(null!=r&&(n=t?t(r):r))return n;for(let i=0;i<this.directPlugins.length;i++){let r=this.directPlugins[i].props[e];if(null!=r&&(n=t?t(r):r))return n}let s=this.state.plugins;if(s)for(let i=0;i<s.length;i++){let r=s[i].props[e];if(null!=r&&(n=t?t(r):r))return n}}hasFocus(){if(ud){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(Ad)return e.focus(Ad);let t=Cd(e);e.focus(null==Ad?{get preventScroll(){return Ad={preventScroll:!0},!0}}:void 0),Ad||(Ad=!1,Od(t,0))}(this.dom),gu(this),this.domObserver.start()}get root(){let e=this._root;if(null==e)for(let t=this.dom.parentNode;t;t=t.parentNode)if(9==t.nodeType||11==t.nodeType&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection()),this._root=t;return e||document}updateRoot(){this._root=null}posAtCoords(e){return Rd(this,e)}coordsAtPos(e,t=1){return Bd(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 new RangeError("DOM position not inside the editor");return r}endOfTextblock(e,t){return Kd(this,t||this.state,e)}pasteHTML(e,t){return xp(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return xp(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return zu(this,e)}destroy(){this.docView&&(!function(e){e.domObserver.stop();for(let t in e.input.eventHandlers)e.dom.removeEventListener(t,e.input.eventHandlers[t]);clearTimeout(e.input.composingTimeout),clearTimeout(e.input.lastIOSEnterFallbackTimeout)}(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Up(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Zc=null)}get isDestroyed(){return null==this.docView}dispatchEvent(e){return function(e,t){rp(e,t)||!Qu[t.type]||!e.editable&&t.type in Xu||Qu[t.type](e,t)}(this,e)}domSelectionRange(){let e=this.domSelection();return e?bd&&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){if(t.getComposedRanges){let n=t.getComposedRanges(e.root)[0];if(n)return Zp(e,n)}let 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?Zp(e,n):null}(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function ih(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"),[Ap.node(0,e.state.doc.content.size,t)]}function oh(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:Ap.widget(e.state.selection.from,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function ah(e){return!e.someProp("editable",t=>!1===t(e.state))}function lh(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 ch(e){if(e.spec.state||e.spec.filterTransaction||e.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}sh.prototype.dispatch=function(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))};for(var dh={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:"'"},uh={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},ph="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),hh="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),fh=0;fh<10;fh++)dh[48+fh]=dh[96+fh]=String(fh);for(fh=1;fh<=24;fh++)dh[fh+111]="F"+fh;for(fh=65;fh<=90;fh++)dh[fh]=String.fromCharCode(fh+32),uh[fh]=String.fromCharCode(fh);for(var mh in dh)uh.hasOwnProperty(mh)||(uh[mh]=dh[mh]);function gh(e){var t=!(ph&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||hh&&e.shiftKey&&e.key&&1==e.key.length||"Unidentified"==e.key)&&e.key||(e.shiftKey?uh:dh)[e.keyCode]||e.key||"Unidentified";return"Esc"==t&&(t="Escape"),"Del"==t&&(t="Delete"),"Left"==t&&(t="ArrowLeft"),"Up"==t&&(t="ArrowUp"),"Right"==t&&(t="ArrowRight"),"Down"==t&&(t="ArrowDown"),t}const bh="undefined"!=typeof navigator&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),yh="undefined"!=typeof navigator&&/Win/.test(navigator.platform);function vh(e){let t,n,r,s,i=e.split(/-(?!$)/),o=i[i.length-1];"Space"==o&&(o=" ");for(let a=0;a<i.length-1;a++){let e=i[a];if(/^(cmd|meta|m)$/i.test(e))s=!0;else if(/^a(lt)?$/i.test(e))t=!0;else if(/^(c|ctrl|control)$/i.test(e))n=!0;else if(/^s(hift)?$/i.test(e))r=!0;else{if(!/^mod$/i.test(e))throw new Error("Unrecognized modifier name: "+e);bh?s=!0:n=!0}}return t&&(o="Alt-"+o),n&&(o="Ctrl-"+o),s&&(o="Meta-"+o),r&&(o="Shift-"+o),o}function wh(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 xh(e){let t=function(e){let t=Object.create(null);for(let n in e)t[vh(n)]=e[n];return t}(e);return function(e,n){let r,s=gh(n),i=t[wh(s,n)];if(i&&i(e.state,e.dispatch,e))return!0;if(1==s.length&&" "!=s){if(n.shiftKey){let r=t[wh(s,n,!1)];if(r&&r(e.state,e.dispatch,e))return!0}if((n.altKey||n.metaKey||n.ctrlKey)&&!(yh&&n.ctrlKey&&n.altKey)&&(r=dh[n.keyCode])&&r!=s){let s=t[wh(r,n)];if(s&&s(e.state,e.dispatch,e))return!0}}return!1}}const kh=(e,t)=>!e.selection.empty&&(t&&t(e.tr.deleteSelection().scrollIntoView()),!0);function Sh(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock("backward",e):n.parentOffset>0)?null:n}const Eh=(e,t,n)=>{let r=Sh(e,n);if(!r)return!1;let s=Ch(r);if(!s){let n=r.blockRange(),s=n&&Sl(n);return null!=s&&(t&&t(e.tr.lift(n,s).scrollIntoView()),!0)}let i=s.nodeBefore;if(Bh(e,s,t,-1))return!0;if(0==r.parent.content.size&&(_h(i,"end")||tc.isSelectable(i)))for(let o=r.depth;;o--){let n=Dl(e.doc,r.before(o),r.after(o),ra.empty);if(n&&n.slice.size<n.to-n.from){if(t){let r=e.tr.step(n);r.setSelection(_h(i,"end")?Jl.findFrom(r.doc.resolve(r.mapping.map(s.pos,-1)),-1):tc.create(r.doc,s.pos-i.nodeSize)),t(r.scrollIntoView())}return!0}if(1==o||r.node(o-1).childCount>1)break}return!(!i.isAtom||s.depth!=r.depth-1)&&(t&&t(e.tr.delete(s.pos-i.nodeSize,s.pos).scrollIntoView()),!0)};function Mh(e,t,n){let r=t.nodeBefore,s=t.pos-1;for(;!r.isTextblock;s--){if(r.type.spec.isolating)return!1;let e=r.lastChild;if(!e)return!1;r=e}let i=t.nodeAfter,o=t.pos+1;for(;!i.isTextblock;o++){if(i.type.spec.isolating)return!1;let e=i.firstChild;if(!e)return!1;i=e}let a=Dl(e.doc,s,o,ra.empty);if(!a||a.from!=s||a instanceof yl&&a.slice.size>=o-s)return!1;if(n){let t=e.tr.step(a);t.setSelection(Yl.create(t.doc,s)),n(t.scrollIntoView())}return!0}function _h(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)return!1}return!1}const Nh=(e,t,n)=>{let{$head:r,empty:s}=e.selection,i=r;if(!s)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",e):r.parentOffset>0)return!1;i=Ch(r)}let o=i&&i.nodeBefore;return!(!o||!tc.isSelectable(o))&&(t&&t(e.tr.setSelection(tc.create(e.doc,i.pos-o.nodeSize)).scrollIntoView()),!0)};function Ch(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 Oh(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock("forward",e):n.parentOffset<n.parent.content.size)?null:n}const Ah=(e,t,n)=>{let r=Oh(e,n);if(!r)return!1;let s=Ih(r);if(!s)return!1;let i=s.nodeAfter;if(Bh(e,s,t,1))return!0;if(0==r.parent.content.size&&(_h(i,"start")||tc.isSelectable(i))){let n=Dl(e.doc,r.before(),r.after(),ra.empty);if(n&&n.slice.size<n.to-n.from){if(t){let r=e.tr.step(n);r.setSelection(_h(i,"start")?Jl.findFrom(r.doc.resolve(r.mapping.map(s.pos)),1):tc.create(r.doc,r.mapping.map(s.pos))),t(r.scrollIntoView())}return!0}}return!(!i.isAtom||s.depth!=r.depth-1)&&(t&&t(e.tr.delete(s.pos,s.pos+i.nodeSize).scrollIntoView()),!0)},Th=(e,t,n)=>{let{$head:r,empty:s}=e.selection,i=r;if(!s)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",e):r.parentOffset<r.parent.content.size)return!1;i=Ih(r)}let o=i&&i.nodeAfter;return!(!o||!tc.isSelectable(o))&&(t&&t(e.tr.setSelection(tc.create(e.doc,i.pos)).scrollIntoView()),!0)};function Ih(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}const Dh=(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 Rh(e){for(let t=0;t<e.edgeCount;t++){let{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}const Lh=(e,t)=>{let n=e.selection,{$from:r,$to:s}=n;if(n instanceof rc||r.parent.inlineContent||s.parent.inlineContent)return!1;let i=Rh(s.parent.contentMatchAt(s.indexAfter()));if(!i||!i.isTextblock)return!1;if(t){let n=(!r.parentOffset&&s.index()<s.parent.childCount?r:s).pos,o=e.tr.insert(n,i.createAndFill());o.setSelection(Yl.create(o.doc,n+1)),t(o.scrollIntoView())}return!0},Ph=(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(Cl(e.doc,r))return t&&t(e.tr.split(r).scrollIntoView()),!0}let r=n.blockRange(),s=r&&Sl(r);return null!=s&&(t&&t(e.tr.lift(r,s).scrollIntoView()),!0)};const jh=(e,t)=>{let{$from:n,$to:r}=e.selection;if(e.selection instanceof tc&&e.selection.node.isBlock)return!(!n.parentOffset||!Cl(e.doc,n.pos)||(t&&t(e.tr.split(n.pos).scrollIntoView()),0));if(!n.depth)return!1;let s,i,o=[],a=!1,l=!1;for(let p=n.depth;;p--){if(n.node(p).isBlock){a=n.end(p)==n.pos+(n.depth-p),l=n.start(p)==n.pos-(n.depth-p),i=Rh(n.node(p-1).contentMatchAt(n.indexAfter(p-1))),o.unshift(a&&i?{type:i}:null),s=p;break}if(1==p)return!1;o.unshift(null)}let c=e.tr;(e.selection instanceof Yl||e.selection instanceof rc)&&c.deleteSelection();let d=c.mapping.map(n.pos),u=Cl(c.doc,d,o.length,o);if(u||(o[0]=i?{type:i}:null,u=Cl(c.doc,d,o.length,o)),!u)return!1;if(c.split(d,o.length,o),!a&&l&&n.node(s).type!=i){let e=c.mapping.map(n.before(s)),t=c.doc.resolve(e);i&&n.node(s-1).canReplaceWith(t.index(),t.index()+1,i)&&c.setNodeMarkup(c.mapping.map(n.before(s)),i)}return t&&t(c.scrollIntoView()),!0};function Bh(e,t,n,r){let s,i,o=t.nodeBefore,a=t.nodeAfter,l=o.type.spec.isolating||a.type.spec.isolating;if(!l&&function(e,t,n){let r=t.nodeBefore,s=t.nodeAfter,i=t.index();return!(!(r&&s&&r.type.compatibleContent(s.type))||(!r.content.size&&t.parent.canReplace(i-1,i)?(n&&n(e.tr.delete(t.pos-r.nodeSize,t.pos).scrollIntoView()),0):!t.parent.canReplace(i,i+1)||!s.isTextblock&&!Ol(e.doc,t.pos)||(n&&n(e.tr.join(t.pos).scrollIntoView()),0)))}(e,t,n))return!0;let c=!l&&t.parent.canReplace(t.index(),t.index()+1);if(c&&(s=(i=o.contentMatchAt(o.childCount)).findWrapping(a.type))&&i.matchType(s[0]||a.type).validEnd){if(n){let r=t.pos+a.nodeSize,i=Qo.empty;for(let e=s.length-1;e>=0;e--)i=Qo.from(s[e].create(null,i));i=Qo.from(o.copy(i));let l=e.tr.step(new vl(t.pos-1,r,t.pos,r,new ra(i,1,0),s.length,!0)),c=l.doc.resolve(r+2*s.length);c.nodeAfter&&c.nodeAfter.type==o.type&&Ol(l.doc,c.pos)&&l.join(c.pos),n(l.scrollIntoView())}return!0}let d=a.type.spec.isolating||r>0&&l?null:Jl.findFrom(t,1),u=d&&d.$from.blockRange(d.$to),p=u&&Sl(u);if(null!=p&&p>=t.depth)return n&&n(e.tr.lift(u,p).scrollIntoView()),!0;if(c&&_h(a,"start",!0)&&_h(o,"end")){let r=o,s=[];for(;s.push(r),!r.isTextblock;)r=r.lastChild;let i=a,l=1;for(;!i.isTextblock;i=i.firstChild)l++;if(r.canReplace(r.childCount,r.childCount,i.content)){if(n){let r=Qo.empty;for(let e=s.length-1;e>=0;e--)r=Qo.from(s[e].copy(r));n(e.tr.step(new vl(t.pos-s.length,t.pos+a.nodeSize,t.pos+l,t.pos+a.nodeSize-l,new ra(r,s.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function zh(e){return function(t,n){let r=t.selection,s=e<0?r.$from:r.$to,i=s.depth;for(;s.node(i).isInline;){if(!i)return!1;i--}return!!s.node(i).isTextblock&&(n&&n(t.tr.setSelection(Yl.create(t.doc,e<0?s.start(i):s.end(i)))),!0)}}const $h=zh(-1),Fh=zh(1);function Hh(e,t=null){return function(n,r){let s=!1;for(let i=0;i<n.selection.ranges.length&&!s;i++){let{$from:{pos:r},$to:{pos:o}}=n.selection.ranges[i];n.doc.nodesBetween(r,o,(r,i)=>{if(s)return!1;if(r.isTextblock&&!r.hasMarkup(e,t))if(r.type==e)s=!0;else{let t=n.doc.resolve(i),r=t.index();s=t.parent.canReplaceWith(r,r+1,e)}})}if(!s)return!1;if(r){let s=n.tr;for(let r=0;r<n.selection.ranges.length;r++){let{$from:{pos:i},$to:{pos:o}}=n.selection.ranges[r];s.setBlockType(i,o,e,t)}r(s.scrollIntoView())}return!0}}function Uh(...e){return function(t,n,r){for(let s=0;s<e.length;s++)if(e[s](t,n,r))return!0;return!1}}function qh(e,t=null){return function(n,r){let{$from:s,$to:i}=n.selection,o=s.blockRange(i);if(!o)return!1;let a=r?n.tr:null;return!!function(e,t,n,r=null){let s=!1,i=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);i=new va(e,e,t.depth),t.endIndex<t.parent.childCount&&(t=new va(t.$from,o.resolve(t.$to.end(t.depth)),t.depth)),s=!0}let a=El(i,n,r,t);if(!a)return!1;e&&function(e,t,n,r,s){let i=Qo.empty;for(let d=n.length-1;d>=0;d--)i=Qo.from(n[d].type.create(n[d].attrs,i));e.step(new vl(t.start-(r?2:0),t.end,t.start,t.end,new ra(i,0,0),n.length,!0));let o=0;for(let d=0;d<n.length;d++)n[d].type==s&&(o=d+1);let a=n.length-o,l=t.start+n.length-(r?2:0),c=t.parent;for(let d=t.startIndex,u=t.endIndex,p=!0;d<u;d++,p=!1)!p&&Cl(e.doc,l,a)&&(e.split(l,a),l+=2*a),l+=c.child(d).nodeSize}(e,t,a,s,n);return!0}(a,o,e,t)&&(r&&r(a.scrollIntoView()),!0)}}function Vh(e){return function(t,n){let{$from:r,$to:s}=t.selection,i=r.blockRange(s,t=>t.childCount>0&&t.firstChild.type==e);return!!i&&(!n||(r.node(i.depth-1).type==e?function(e,t,n,r){let s=e.tr,i=r.end,o=r.$to.end(r.depth);i<o&&(s.step(new vl(i-1,o,i,o,new ra(Qo.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new va(s.doc.resolve(r.$from.pos),s.doc.resolve(o),r.depth));const a=Sl(r);if(null==a)return!1;s.lift(r,a);let l=s.doc.resolve(s.mapping.map(i,-1)-1);Ol(s.doc,l.pos)&&l.nodeBefore.type==l.nodeAfter.type&&s.join(l.pos);return t(s.scrollIntoView()),!0}(t,n,e,i):function(e,t,n){let r=e.tr,s=n.parent;for(let h=n.end,f=n.endIndex-1,m=n.startIndex;f>m;f--)h-=s.child(f).nodeSize,r.delete(h-1,h+1);let i=r.doc.resolve(n.start),o=i.nodeAfter;if(r.mapping.map(n.end)!=n.start+i.nodeAfter.nodeSize)return!1;let a=0==n.startIndex,l=n.endIndex==s.childCount,c=i.node(-1),d=i.index(-1);if(!c.canReplace(d+(a?0:1),d+1,o.content.append(l?Qo.empty:Qo.from(s))))return!1;let u=i.pos,p=u+o.nodeSize;return r.step(new vl(u-(a?1:0),p+(l?1:0),u+1,p-1,new ra((a?Qo.empty:Qo.from(s.copy(Qo.empty))).append(l?Qo.empty:Qo.from(s.copy(Qo.empty))),a?0:1,l?0:1),a?0:1)),t(r.scrollIntoView()),!0}(t,n,i)))}}Uh(kh,Eh,Nh),Uh(kh,Ah,Th),Uh(Dh,Lh,Ph,jh),"undefined"!=typeof navigator?/Mac|iP(hone|[oa]d)/.test(navigator.platform):"undefined"!=typeof os&&os.platform&&os.platform();var Kh=Object.defineProperty,Wh=(e,t)=>{for(var n in t)Kh(e,n,{get:t[n],enumerable:!0})};function Gh(e){const{state:t,transaction:n}=e;let{selection:r}=n,{doc:s}=n,{storedMarks:i}=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 i},get selection(){return r},get doc(){return s},get tr(){return r=n.selection,s=n.doc,i=n.storedMarks,n}}}var Jh=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(){const{rawCommands:e,editor:t,state:n}=this,{view:r}=t,{tr:s}=n,i=this.buildProps(s);return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,(...e)=>{const n=t(...e)(i);return s.getMeta("preventDispatch")||this.hasCustomState||r.dispatch(s),n}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(e,t=!0){const{rawCommands:n,editor:r,state:s}=this,{view:i}=r,o=[],a=!!e,l=e||s.tr,c={...Object.fromEntries(Object.entries(n).map(([e,n])=>[e,(...e)=>{const r=this.buildProps(l,t),s=n(...e)(r);return o.push(s),c}])),run:()=>(a||!t||l.getMeta("preventDispatch")||this.hasCustomState||i.dispatch(l),o.every(e=>!0===e))};return c}createCan(e){const{rawCommands:t,state:n}=this,r=!1,s=e||n.tr,i=this.buildProps(s,r);return{...Object.fromEntries(Object.entries(t).map(([e,t])=>[e,(...e)=>t(...e)({...i,dispatch:void 0})])),chain:()=>this.createChain(s,r)}}buildProps(e,t=!0){const{rawCommands:n,editor:r,state:s}=this,{view:i}=r,o={tr:e,editor:r,view:i,state:Gh({state:s,transaction:e}),dispatch:t?()=>{}: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}},Zh=class{constructor(){this.callbacks={}}on(e,t){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),this}emit(e,...t){const n=this.callbacks[e];return n&&n.forEach(e=>e.apply(this,t)),this}off(e,t){const n=this.callbacks[e];return n&&(t?this.callbacks[e]=n.filter(e=>e!==t):delete this.callbacks[e]),this}once(e,t){const n=(...r)=>{this.off(e,n),t.apply(this,r)};return this.on(e,n)}removeAllListeners(){this.callbacks={}}};function Qh(e,t){const n=new Wl(e);return t.forEach(e=>{e.steps.forEach(e=>{n.step(e)})}),n}var Xh=e=>{const t=e.childNodes;for(let n=t.length-1;n>=0;n-=1){const r=t[n];3===r.nodeType&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?e.removeChild(r):1===r.nodeType&&Xh(r)}return e};function Yh(e){if("undefined"==typeof window)throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");const t=`<body>${e}</body>`,n=(new window.DOMParser).parseFromString(t,"text/html").body;return Xh(n)}function ef(e,t,n){if(e instanceof xa||e instanceof Qo)return e;n={slice:!0,parseOptions:{},...n};const r="string"==typeof e;if("object"==typeof e&&null!==e)try{if(Array.isArray(e)&&e.length>0)return Qo.fromArray(e.map(e=>t.nodeFromJSON(e)));const r=t.nodeFromJSON(e);return n.errorOnInvalidContent&&r.check(),r}catch(s){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:s});return console.warn("[tiptap warn]: Invalid content.","Passed value:",e,"Error:",s),ef("",t,n)}if(r){if(n.errorOnInvalidContent){let r=!1,s="";const i=new $a({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,s="string"==typeof e?e:e.outerHTML,null)}]}})});if(n.slice?Ha.fromSchema(i).parseSlice(Yh(e),n.parseOptions):Ha.fromSchema(i).parse(Yh(e),n.parseOptions),n.errorOnInvalidContent&&r)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${s}`)})}const r=Ha.fromSchema(t);return n.slice?r.parseSlice(Yh(e),n.parseOptions).content:r.parse(Yh(e),n.parseOptions)}return ef("",t,n)}function tf(e,t,n={},r={}){return ef(e,t,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}function nf(e,t){const n=[];return e.descendants((e,r)=>{t(e)&&n.push({node:e,pos:r})}),n}function rf(e){return t=>function(e,t){for(let n=e.depth;n>0;n-=1){const r=e.node(n);if(t(r))return{pos:n>0?e.before(n):0,start:e.start(n),depth:n,node:r}}}(t.$from,e)}function sf(e,t,n){if(void 0===e.config[t]&&e.parent)return sf(e.parent,t,n);if("function"==typeof e.config[t]){return e.config[t].bind({...n,parent:e.parent?sf(e.parent,t,n):null})}return e.config[t]}function of(e){return e.map(e=>{const t=sf(e,"addExtensions",{name:e.name,options:e.options,storage:e.storage});return t?[e,...of(t())]:e}).flat(10)}function af(e,t){const n=Xa.fromSchema(t).serializeFragment(e),r=document.implementation.createHTMLDocument().createElement("div");return r.appendChild(n),r.innerHTML}function lf(e){return"function"==typeof e}function cf(e,t=void 0,...n){return lf(e)?t?e.bind(t)(...n):e(...n):e}function df(e){return{baseExtensions:e.filter(e=>"extension"===e.type),nodeExtensions:e.filter(e=>"node"===e.type),markExtensions:e.filter(e=>"mark"===e.type)}}function uf(e){const t=[],{nodeExtensions:n,markExtensions:r}=df(e),s=[...n,...r],i={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return e.forEach(e=>{const n=sf(e,"addGlobalAttributes",{name:e.name,options:e.options,storage:e.storage,extensions:s});if(!n)return;n().forEach(e=>{e.types.forEach(n=>{Object.entries(e.attributes).forEach(([e,r])=>{t.push({type:n,name:e,attribute:{...i,...r}})})})})}),s.forEach(e=>{const n={name:e.name,options:e.options,storage:e.storage},r=sf(e,"addAttributes",n);if(!r)return;const s=r();Object.entries(s).forEach(([n,r])=>{const s={...i,...r};"function"==typeof(null==s?void 0:s.default)&&(s.default=s.default()),(null==s?void 0:s.isRequired)&&void 0===(null==s?void 0:s.default)&&delete s.default,t.push({type:e.name,name:n,attribute:s})})}),t}function pf(...e){return e.filter(e=>!!e).reduce((e,t)=>{const n={...e};return Object.entries(t).forEach(([e,t])=>{if(n[e])if("class"===e){const r=t?String(t).split(" "):[],s=n[e]?n[e].split(" "):[],i=r.filter(e=>!s.includes(e));n[e]=[...s,...i].join(" ")}else if("style"===e){const r=t?t.split(";").map(e=>e.trim()).filter(Boolean):[],s=n[e]?n[e].split(";").map(e=>e.trim()).filter(Boolean):[],i=new Map;s.forEach(e=>{const[t,n]=e.split(":").map(e=>e.trim());i.set(t,n)}),r.forEach(e=>{const[t,n]=e.split(":").map(e=>e.trim());i.set(t,n)}),n[e]=Array.from(i.entries()).map(([e,t])=>`${e}: ${t}`).join("; ")}else n[e]=t;else n[e]=t}),n},{})}function hf(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)=>pf(e,t),{})}function ff(e,t){return"style"in e?e:{...e,getAttrs:n=>{const r=e.getAttrs?e.getAttrs(n):e.attrs;if(!1===r)return!1;const s=t.reduce((e,t)=>{const r=t.attribute.parseHTML?t.attribute.parseHTML(n):function(e){return"string"!=typeof e?e:e.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(e):"true"===e||"false"!==e&&e}(n.getAttribute(t.name));return null==r?e:{...e,[t.name]:r}},{});return{...r,...s}}}}function mf(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 gf(e){return e.sort((e,t)=>{const n=sf(e,"priority")||100,r=sf(t,"priority")||100;return n>r?-1:n<r?1:0})}function bf(e){const t=gf(of(e)),n=function(e){const t=e.filter((t,n)=>e.indexOf(t)!==n);return Array.from(new Set(t))}(t.map(e=>e.name));return n.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map(e=>`'${e}'`).join(", ")}]. This can lead to issues.`),t}function yf(e,t,n){const{from:r,to:s}=t,{blockSeparator:i="\n\n",textSerializers:o={}}=n||{};let a="";return e.nodesBetween(r,s,(e,n,l,c)=>{var d;e.isBlock&&n>r&&(a+=i);const 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,s-n))}),a}function vf(e,t){return yf(e,{from:0,to:e.content.size},t)}function wf(e){return Object.fromEntries(Object.entries(e.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}function xf(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}function kf(e,t){const n=xf(t,e.schema),{from:r,to:s,empty:i}=e.selection,o=[];i?(e.storedMarks&&o.push(...e.storedMarks),o.push(...e.selection.$head.marks())):e.doc.nodesBetween(r,s,e=>{o.push(...e.marks)});const a=o.find(e=>e.type.name===n.name);return a?{...a.attrs}:{}}function Sf(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}function Ef(e,t){return t.nodes[e]?"node":t.marks[e]?"mark":null}function Mf(e,t){const n=Ef("string"==typeof t?t:t.name,e.schema);return"node"===n?function(e,t){const n=Sf(t,e.schema),{from:r,to:s}=e.selection,i=[];e.doc.nodesBetween(r,s,e=>{i.push(e)});const o=i.reverse().find(e=>e.type.name===n.name);return o?{...o.attrs}:{}}(e,t):"mark"===n?kf(e,t):{}}function _f(e){const t=function(e,t=JSON.stringify){const n={};return e.filter(e=>{const r=t(e);return!Object.prototype.hasOwnProperty.call(n,r)&&(n[r]=!0)})}(e);return 1===t.length?t:t.filter((e,n)=>{const r=t.filter((e,t)=>t!==n);return!r.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 Nf(e){const{mapping:t,steps:n}=e,r=[];return t.maps.forEach((e,s)=>{const i=[];if(e.ranges.length)e.forEach((e,t)=>{i.push({from:e,to:t})});else{const{from:e,to:t}=n[s];if(void 0===e||void 0===t)return;i.push({from:e,to:t})}i.forEach(({from:e,to:n})=>{const i=t.slice(s).map(e,-1),o=t.slice(s).map(n),a=t.invert().map(i,-1),l=t.invert().map(o);r.push({oldRange:{from:a,to:l},newRange:{from:i,to:o}})})}),_f(r)}function Cf(e){return"[object RegExp]"===Object.prototype.toString.call(e)}function Of(e,t,n={strict:!0}){const r=Object.keys(t);return!r.length||r.every(r=>n.strict?t[r]===e[r]:Cf(t[r])?t[r].test(e[r]):t[r]===e[r])}function Af(e,t,n={}){return e.find(e=>e.type===t&&Of(Object.fromEntries(Object.keys(n).map(t=>[t,e.attrs[t]])),n))}function Tf(e,t,n={}){return!!Af(e,t,n)}function If(e,t,n){var r;if(!e||!t)return;let s=e.parent.childAfter(e.parentOffset);if(s.node&&s.node.marks.some(e=>e.type===t)||(s=e.parent.childBefore(e.parentOffset)),!s.node||!s.node.marks.some(e=>e.type===t))return;n=n||(null==(r=s.node.marks[0])?void 0:r.attrs);if(!Af([...s.node.marks],t,n))return;let i=s.index,o=e.start()+s.offset,a=i+1,l=o+s.node.nodeSize;for(;i>0&&Tf([...e.parent.child(i-1).marks],t,n);)i-=1,o-=e.parent.child(i).nodeSize;for(;a<e.parent.childCount&&Tf([...e.parent.child(a).marks],t,n);)l+=e.parent.child(a).nodeSize,a+=1;return{from:o,to:l}}function Df(e,t,n){const r=[];return e===t?n.resolve(e).marks().forEach(t=>{const s=If(n.resolve(e),t.type);s&&r.push({mark:t,...s})}):n.nodesBetween(e,t,(e,t)=>{e&&void 0!==(null==e?void 0:e.nodeSize)&&r.push(...e.marks.map(n=>({from:t,to:t+e.nodeSize,mark:n})))}),r}function Rf(e,t){return t.nodes[e]||t.marks[e]||null}function Lf(e,t,n){return Object.fromEntries(Object.entries(n).filter(([n])=>{const r=e.find(e=>e.type===t&&e.name===n);return!!r&&r.attribute.keepOnSplit}))}function Pf(e,t,n={}){const{empty:r,ranges:s}=e.selection,i=t?xf(t,e.schema):null;if(r)return!!(e.storedMarks||e.selection.$from.marks()).filter(e=>!i||i.name===e.type.name).find(e=>Of(e.attrs,n,{strict:!1}));let o=0;const a=[];if(s.forEach(({$from:t,$to:n})=>{const r=t.pos,s=n.pos;e.doc.nodesBetween(r,s,(e,t)=>{if(!e.isText&&!e.marks.length)return;const n=Math.max(r,t),i=Math.min(s,t+e.nodeSize);o+=i-n,a.push(...e.marks.map(e=>({mark:e,from:n,to:i})))})}),0===o)return!1;const l=a.filter(e=>!i||i.name===e.mark.type.name).filter(e=>Of(e.mark.attrs,n,{strict:!1})).reduce((e,t)=>e+t.to-t.from,0),c=a.filter(e=>!i||e.mark.type!==i&&e.mark.type.excludes(i)).reduce((e,t)=>e+t.to-t.from,0);return(l>0?l+c:l)>=o}function jf(e,t,n={}){const{from:r,to:s,empty:i}=e.selection,o=t?Sf(t,e.schema):null,a=[];e.doc.nodesBetween(r,s,(e,t)=>{if(e.isText)return;const n=Math.max(r,t),i=Math.min(s,t+e.nodeSize);a.push({node:e,from:n,to:i})});const l=s-r,c=a.filter(e=>!o||o.name===e.node.type.name).filter(e=>Of(e.node.attrs,n,{strict:!1}));if(i)return!!c.length;return c.reduce((e,t)=>e+t.to-t.from,0)>=l}function Bf(e,t){return Array.isArray(t)?t.some(t=>("string"==typeof t?t:t.name)===e.name):t}function zf(e,t){const{nodeExtensions:n}=df(t),r=n.find(t=>t.name===e);if(!r)return!1;const s=cf(sf(r,"group",{name:r.name,options:r.options,storage:r.storage}));return"string"==typeof s&&s.split(" ").includes("list")}function $f(e,{checkChildren:t=!0,ignoreWhitespace:n=!1}={}){var r;if(n){if("hardBreak"===e.type.name)return!0;if(e.isText)return/^\s*$/m.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&&($f(e,{ignoreWhitespace:n,checkChildren:t})||(r=!1))}),r}return!1}function Ff(e){return e instanceof tc}function Hf(e){return e instanceof Yl}function Uf(e=0,t=0,n=0){return Math.min(Math.max(e,t),n)}function qf(e,t,n){const r=e.state.doc.content.size,s=Uf(t,0,r),i=Uf(n,0,r),o=e.coordsAtPos(s),a=e.coordsAtPos(i,-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}}function Vf(e,t=null){if(!t)return null;const n=Jl.atStart(e),r=Jl.atEnd(e);if("start"===t||!0===t)return n;if("end"===t)return r;const s=n.from,i=r.to;return"all"===t?Yl.create(e,Uf(0,s,i),Uf(e.content.size,s,i)):Yl.create(e,Uf(t,s,i),Uf(t,s,i))}var Kf=class{constructor(e){var t;this.find=e.find,this.handler=e.handler,this.undoable=null==(t=e.undoable)||t}};function Wf(e){var t;const{editor:n,from:r,to:s,text:i,rules:o,plugin:a}=e,{view:l}=n;if(l.composing)return!1;const 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;const u=((e,t=500)=>{let n="";const r=e.parentOffset;return e.parent.nodesBetween(Math.max(0,r-t),r,(e,t,s,i)=>{var o,a;const l=(null==(a=(o=e.type.spec).toText)?void 0:a.call(o,{node:e,pos:t,parent:s,index:i}))||e.textContent||"%leaf%";n+=e.isAtom&&!e.isText?l:l.slice(0,Math.max(0,r-t))}),n})(c)+i;return o.forEach(e=>{if(d)return;const t=((e,t)=>{if(Cf(t))return t.exec(e);const n=t(e);if(!n)return null;const 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;const o=l.state.tr,c=Gh({state:l.state,transaction:o}),p={from:r-(t[0].length-i.length),to:s},{commands:h,chain:f,can:m}=new Jh({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:s,text:i}),l.dispatch(o),d=!0)}),d}function Gf(e){return"Object"===function(e){return Object.prototype.toString.call(e).slice(8,-1)}(e)&&(e.constructor===Object&&Object.getPrototypeOf(e)===Object.prototype)}function Jf(e,t){const n={...e};return Gf(e)&&Gf(t)&&Object.keys(t).forEach(r=>{Gf(t[r])&&Gf(e[r])?n[r]=Jf(e[r],t[r]):n[r]=t[r]}),n}var Zf=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{...cf(sf(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...cf(sf(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(e={}){const t=this.extend({...this.config,addOptions:()=>Jf(this.options,e)});return t.name=this.name,t.parent=this.parent,t}extend(e={}){const 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}},Qf=class e extends Zf{constructor(){super(...arguments),this.type="mark"}static create(t={}){const n="function"==typeof t?t():t;return new e(n)}static handleExit({editor:e,mark:t}){const{tr:n}=e.state,r=e.state.selection.$from;if(r.pos===r.end()){const s=r.marks();if(!!!s.find(e=>(null==e?void 0:e.type.name)===t.name))return!1;const i=s.find(e=>(null==e?void 0:e.type.name)===t.name);return i&&n.removeStoredMark(i),n.insertText(" ",r.pos),e.view.dispatch(n),!0}return!1}configure(e){return super.configure(e)}extend(e){const t="function"==typeof e?e():e;return super.extend(t)}};var Xf=class{constructor(e){this.find=e.find,this.handler=e.handler}};function Yf(e){const{editor:t,state:n,from:r,to:s,rule:i,pasteEvent:o,dropEvent:a}=e,{commands:l,chain:c,can:d}=new Jh({editor:t,state:n}),u=[];n.doc.nodesBetween(r,s,(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;const b=null!=(g=null!=(m=null==(f=e.content)?void 0:f.size)?m:e.nodeSize)?g:0,y=Math.max(r,t),v=Math.min(s,t+b);if(y>=v)return;((e,t,n)=>{if(Cf(t))return[...e.matchAll(t)];const r=t(e,n);return r?r.map(t=>{const 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(y-t,v-t,void 0,"\ufffc"),i.find,o).forEach(e=>{if(void 0===e.index)return;const t=y+e.index+1,r=t+e[0].length,s={from:n.tr.mapping.map(t),to:n.tr.mapping.map(r)},p=i.handler({state:n,range:s,match:e,commands:l,chain:c,can:d,pasteEvent:o,dropEvent:a});u.push(p)})});return u.every(e=>null!==e)}var em=null;function tm(e){const{editor:t,rules:n}=e;let r,s=null,i=!1,o=!1,a="undefined"!=typeof ClipboardEvent?new ClipboardEvent("paste"):null;try{r="undefined"!=typeof DragEvent?new DragEvent("drop"):null}catch{r=null}const l=({state:e,from:n,to:s,rule:i,pasteEvt:o})=>{const l=e.tr,c=Gh({state:e,transaction:l});if(Yf({editor:t,state:c,from:Math.max(n-1,0),to:s.b-1,rule:i,pasteEvent:o,dropEvent:r})&&l.steps.length){try{r="undefined"!=typeof DragEvent?new DragEvent("drop"):null}catch{r=null}return a="undefined"!=typeof ClipboardEvent?new ClipboardEvent("paste"):null,l}};return n.map(e=>new fc({view(e){const n=n=>{var r;s=(null==(r=e.dom.parentElement)?void 0:r.contains(n.target))?e.dom.parentElement:null,s&&(em=t)},r=()=>{em&&(em=null)};return window.addEventListener("dragstart",n),window.addEventListener("dragend",r),{destroy(){window.removeEventListener("dragstart",n),window.removeEventListener("dragend",r)}}},props:{handleDOMEvents:{drop:(e,t)=>{if(o=s===e.dom.parentElement,r=t,!o){const e=em;(null==e?void 0:e.isEditable)&&setTimeout(()=>{const t=e.state.selection;t&&e.commands.deleteRange({from:t.from,to:t.to})},10)}return!1},paste:(e,t)=>{var n;const r=null==(n=t.clipboardData)?void 0:n.getData("text/html");return a=t,i=!!(null==r?void 0:r.includes("data-pm-slice")),!1}}},appendTransaction:(t,n,r)=>{const s=t[0],c="paste"===s.getMeta("uiEvent")&&!i,d="drop"===s.getMeta("uiEvent")&&!o,u=s.getMeta("applyPasteRules"),p=!!u;if(!c&&!d&&!p)return;if(p){let{text:t}=u;"string"==typeof t||(t=af(Qo.from(t),r.schema));const{from:n}=u,s=n+t.length,i=(e=>{var t;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return null==(t=n.clipboardData)||t.setData("text/html",e),n})(t);return l({rule:e,state:r,from:n,to:{b:s},pasteEvt:i})}const h=n.doc.content.findDiffStart(r.doc.content),f=n.doc.content.findDiffEnd(r.doc.content);return"number"==typeof h&&f&&h!==f.b?l({rule:e,state:r,from:h,to:f,pasteEvt:a}):void 0}}))}var nm=class{constructor(e,t){this.splittableMarks=[],this.editor=t,this.extensions=bf(e),this.schema=function(e,t){var n;const r=uf(e),{nodeExtensions:s,markExtensions:i}=df(e),o=null==(n=s.find(e=>sf(e,"topNode")))?void 0:n.name,a=Object.fromEntries(s.map(n=>{const s=r.filter(e=>e.type===n.name),i={name:n.name,options:n.options,storage:n.storage,editor:t},o=mf({...e.reduce((e,t)=>{const r=sf(t,"extendNodeSchema",i);return{...e,...r?r(n):{}}},{}),content:cf(sf(n,"content",i)),marks:cf(sf(n,"marks",i)),group:cf(sf(n,"group",i)),inline:cf(sf(n,"inline",i)),atom:cf(sf(n,"atom",i)),selectable:cf(sf(n,"selectable",i)),draggable:cf(sf(n,"draggable",i)),code:cf(sf(n,"code",i)),whitespace:cf(sf(n,"whitespace",i)),linebreakReplacement:cf(sf(n,"linebreakReplacement",i)),defining:cf(sf(n,"defining",i)),isolating:cf(sf(n,"isolating",i)),attrs:Object.fromEntries(s.map(e=>{var t,n;return[e.name,{default:null==(t=null==e?void 0:e.attribute)?void 0:t.default,validate:null==(n=null==e?void 0:e.attribute)?void 0:n.validate}]}))}),a=cf(sf(n,"parseHTML",i));a&&(o.parseDOM=a.map(e=>ff(e,s)));const l=sf(n,"renderHTML",i);l&&(o.toDOM=e=>l({node:e,HTMLAttributes:hf(e,s)}));const c=sf(n,"renderText",i);return c&&(o.toText=c),[n.name,o]})),l=Object.fromEntries(i.map(n=>{const s=r.filter(e=>e.type===n.name),i={name:n.name,options:n.options,storage:n.storage,editor:t},o=mf({...e.reduce((e,t)=>{const r=sf(t,"extendMarkSchema",i);return{...e,...r?r(n):{}}},{}),inclusive:cf(sf(n,"inclusive",i)),excludes:cf(sf(n,"excludes",i)),group:cf(sf(n,"group",i)),spanning:cf(sf(n,"spanning",i)),code:cf(sf(n,"code",i)),attrs:Object.fromEntries(s.map(e=>{var t,n;return[e.name,{default:null==(t=null==e?void 0:e.attribute)?void 0:t.default,validate:null==(n=null==e?void 0:e.attribute)?void 0:n.validate}]}))}),a=cf(sf(n,"parseHTML",i));a&&(o.parseDOM=a.map(e=>ff(e,s)));const l=sf(n,"renderHTML",i);return l&&(o.toDOM=e=>l({mark:e,HTMLAttributes:hf(e,s)})),[n.name,o]}));return new $a({topNode:o,nodes:a,marks:l})}(this.extensions,t),this.setupExtensions()}get commands(){return this.extensions.reduce((e,t)=>{const n=sf(t,"addCommands",{name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:this.editor,type:Rf(t.name,this.schema)});return n?{...e,...n()}:e},{})}get plugins(){const{editor:e}=this;return gf([...this.extensions].reverse()).flatMap(t=>{const n={name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:e,type:Rf(t.name,this.schema)},r=[],s=sf(t,"addKeyboardShortcuts",n);let i={};if("mark"===t.type&&sf(t,"exitable",n)&&(i.ArrowRight=()=>Qf.handleExit({editor:e,mark:t})),s){const t=Object.fromEntries(Object.entries(s()).map(([t,n])=>[t,()=>n({editor:e})]));i={...i,...t}}const o=new fc({props:{handleKeyDown:xh(i)}});r.push(o);const a=sf(t,"addInputRules",n);if(Bf(t,e.options.enableInputRules)&&a){const t=a();if(t&&t.length){const n=function(e){const{editor:t,rules:n}=e,r=new fc({state:{init:()=>null,apply(e,s,i){const o=e.getMeta(r);if(o)return o;const a=e.getMeta("applyInputRules");return!!a&&setTimeout(()=>{let{text:e}=a;"string"==typeof e||(e=af(Qo.from(e),i.schema));const{from:s}=a,o=s+e.length;Wf({editor:t,from:s,to:o,text:e,rules:n,plugin:r})}),e.selectionSet||e.docChanged?null:s}},props:{handleTextInput:(e,s,i,o)=>Wf({editor:t,from:s,to:i,text:o,rules:n,plugin:r}),handleDOMEvents:{compositionend:e=>(setTimeout(()=>{const{$cursor:s}=e.state.selection;s&&Wf({editor:t,from:s.pos,to:s.pos,text:"",rules:n,plugin:r})}),!1)},handleKeyDown(e,s){if("Enter"!==s.key)return!1;const{$cursor:i}=e.state.selection;return!!i&&Wf({editor:t,from:i.pos,to:i.pos,text:"\n",rules:n,plugin:r})}},isInputRules:!0});return r}({editor:e,rules:t}),s=Array.isArray(n)?n:[n];r.push(...s)}}const l=sf(t,"addPasteRules",n);if(Bf(t,e.options.enablePasteRules)&&l){const t=l();if(t&&t.length){const n=tm({editor:e,rules:t});r.push(...n)}}const c=sf(t,"addProseMirrorPlugins",n);if(c){const e=c();r.push(...e)}return r})}get attributes(){return uf(this.extensions)}get nodeViews(){const{editor:e}=this,{nodeExtensions:t}=df(this.extensions);return Object.fromEntries(t.filter(e=>!!sf(e,"addNodeView")).map(t=>{const 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:Sf(t.name,this.schema)},s=sf(t,"addNodeView",r);if(!s)return[];return[t.name,(r,i,o,a,l)=>{const c=hf(r,n);return s()({node:r,view:i,getPos:o,decorations:a,innerDecorations:l,editor:e,extension:t,HTMLAttributes:c})}]}))}get markViews(){const{editor:e}=this,{markExtensions:t}=df(this.extensions);return Object.fromEntries(t.filter(e=>!!sf(e,"addMarkView")).map(t=>{const 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:xf(t.name,this.schema)},s=sf(t,"addMarkView",r);if(!s)return[];return[t.name,(r,i,o)=>{const a=hf(r,n);return s()({mark:r,view:i,inline:o,editor:e,extension:t,HTMLAttributes:a,updateAttributes:t=>{!function(e,t,n={}){const{state:r}=t,{doc:s,tr:i}=r,o=e;s.descendants((t,r)=>{const s=i.mapping.map(r),a=i.mapping.map(r)+t.nodeSize;let l=null;if(t.marks.forEach(e=>{if(e!==o)return!1;l=e}),!l)return;let c=!1;if(Object.keys(n).forEach(e=>{n[e]!==l.attrs[e]&&(c=!0)}),c){const t=e.type.create({...e.attrs,...n});i.removeMark(s,a,e.type),i.addMark(s,a,t)}}),i.docChanged&&t.view.dispatch(i)}(r,e,t)}})}]}))}setupExtensions(){const e=this.extensions;this.editor.extensionStorage=Object.fromEntries(e.map(e=>[e.name,e.storage])),e.forEach(e=>{var t;const n={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:Rf(e.name,this.schema)};if("mark"===e.type){(null==(t=cf(sf(e,"keepOnSplit",n)))||t)&&this.splittableMarks.push(e.name)}const r=sf(e,"onBeforeCreate",n),s=sf(e,"onCreate",n),i=sf(e,"onUpdate",n),o=sf(e,"onSelectionUpdate",n),a=sf(e,"onTransaction",n),l=sf(e,"onFocus",n),c=sf(e,"onBlur",n),d=sf(e,"onDestroy",n);r&&this.editor.on("beforeCreate",r),s&&this.editor.on("create",s),i&&this.editor.on("update",i),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)})}};nm.resolve=bf,nm.sort=gf,nm.flatten=of;Wh({},{ClipboardTextSerializer:()=>sm,Commands:()=>bg,Delete:()=>yg,Drop:()=>vg,Editable:()=>wg,FocusEvents:()=>kg,Keymap:()=>Sg,Paste:()=>Eg,Tabindex:()=>Mg,focusEventsPluginKey:()=>xg});var rm=class e extends Zf{constructor(){super(...arguments),this.type="extension"}static create(t={}){const n="function"==typeof t?t():t;return new e(n)}configure(e){return super.configure(e)}extend(e){const t="function"==typeof e?e():e;return super.extend(t)}},sm=rm.create({name:"clipboardTextSerializer",addOptions:()=>({blockSeparator:void 0}),addProseMirrorPlugins(){return[new fc({key:new bc("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:e}=this,{state:t,schema:n}=e,{doc:r,selection:s}=t,{ranges:i}=s,o=Math.min(...i.map(e=>e.$from.pos)),a=Math.max(...i.map(e=>e.$to.pos)),l=wf(n);return yf(r,{from:o,to:a},{...void 0!==this.options.blockSeparator?{blockSeparator:this.options.blockSeparator}:{},textSerializers:l})}}})]}}),im={};Wh(im,{blur:()=>om,clearContent:()=>am,clearNodes:()=>lm,command:()=>cm,createParagraphNear:()=>dm,cut:()=>um,deleteCurrentNode:()=>pm,deleteNode:()=>hm,deleteRange:()=>fm,deleteSelection:()=>mm,enter:()=>gm,exitCode:()=>bm,extendMarkRange:()=>ym,first:()=>vm,focus:()=>km,forEach:()=>Sm,insertContent:()=>Em,insertContentAt:()=>Mm,joinBackward:()=>Cm,joinDown:()=>Nm,joinForward:()=>Om,joinItemBackward:()=>Am,joinItemForward:()=>Tm,joinTextblockBackward:()=>Im,joinTextblockForward:()=>Dm,joinUp:()=>_m,keyboardShortcut:()=>Lm,lift:()=>Pm,liftEmptyBlock:()=>jm,liftListItem:()=>Bm,newlineInCode:()=>zm,resetAttributes:()=>Fm,scrollIntoView:()=>Hm,selectAll:()=>Um,selectNodeBackward:()=>qm,selectNodeForward:()=>Vm,selectParentNode:()=>Km,selectTextblockEnd:()=>Wm,selectTextblockStart:()=>Gm,setContent:()=>Jm,setMark:()=>Zm,setMeta:()=>Qm,setNode:()=>Xm,setNodeSelection:()=>Ym,setTextSelection:()=>eg,sinkListItem:()=>tg,splitBlock:()=>rg,splitListItem:()=>sg,toggleList:()=>ag,toggleMark:()=>lg,toggleNode:()=>cg,toggleWrap:()=>dg,undoInputRule:()=>ug,unsetAllMarks:()=>pg,unsetMark:()=>hg,updateAttributes:()=>fg,wrapIn:()=>mg,wrapInList:()=>gg});var om=()=>({editor:e,view:t})=>(requestAnimationFrame(()=>{var n;e.isDestroyed||(t.dom.blur(),null==(n=null==window?void 0:window.getSelection())||n.removeAllRanges())}),!0),am=(e=!0)=>({commands:t})=>t.setContent("",{emitUpdate:e}),lm=()=>({state:e,tr:t,dispatch:n})=>{const{selection:r}=t,{ranges:s}=r;return!n||(s.forEach(({$from:n,$to:r})=>{e.doc.nodesBetween(n.pos,r.pos,(e,n)=>{if(e.type.isText)return;const{doc:r,mapping:s}=t,i=r.resolve(s.map(n)),o=r.resolve(s.map(n+e.nodeSize)),a=i.blockRange(o);if(!a)return;const l=Sl(a);if(e.type.isTextblock){const{defaultType:e}=i.parent.contentMatchAt(i.index());t.setNodeMarkup(a.start,e)}(l||0===l)&&t.lift(a,l)})}),!0)},cm=e=>t=>e(t),dm=()=>({state:e,dispatch:t})=>Lh(e,t),um=(e,t)=>({editor:n,tr:r})=>{const{state:s}=n,i=s.doc.slice(e.from,e.to);r.deleteRange(e.from,e.to);const o=r.mapping.map(t);return r.insert(o,i.content),r.setSelection(new Yl(r.doc.resolve(Math.max(o-1,0)))),!0},pm=()=>({tr:e,dispatch:t})=>{const{selection:n}=e,r=n.$anchor.node();if(r.content.size>0)return!1;const s=e.selection.$anchor;for(let i=s.depth;i>0;i-=1){if(s.node(i).type===r.type){if(t){const t=s.before(i),n=s.after(i);e.delete(t,n).scrollIntoView()}return!0}}return!1},hm=e=>({tr:t,state:n,dispatch:r})=>{const s=Sf(e,n.schema),i=t.selection.$anchor;for(let e=i.depth;e>0;e-=1){if(i.node(e).type===s){if(r){const n=i.before(e),r=i.after(e);t.delete(n,r).scrollIntoView()}return!0}}return!1},fm=e=>({tr:t,dispatch:n})=>{const{from:r,to:s}=e;return n&&t.delete(r,s),!0},mm=()=>({state:e,dispatch:t})=>kh(e,t),gm=()=>({commands:e})=>e.keyboardShortcut("Enter"),bm=()=>({state:e,dispatch:t})=>((e,t)=>{let{$head:n,$anchor:r}=e.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let s=n.node(-1),i=n.indexAfter(-1),o=Rh(s.contentMatchAt(i));if(!o||!s.canReplaceWith(i,i,o))return!1;if(t){let r=n.after(),s=e.tr.replaceWith(r,r,o.createAndFill());s.setSelection(Jl.near(s.doc.resolve(r),1)),t(s.scrollIntoView())}return!0})(e,t),ym=(e,t={})=>({tr:n,state:r,dispatch:s})=>{const i=xf(e,r.schema),{doc:o,selection:a}=n,{$from:l,from:c,to:d}=a;if(s){const e=If(l,i,t);if(e&&e.from<=c&&e.to>=d){const t=Yl.create(o,e.from,e.to);n.setSelection(t)}}return!0},vm=e=>t=>{const 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 wm(){return"Android"===navigator.platform||/android/i.test(navigator.userAgent)}function xm(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}var km=(e=null,t={})=>({editor:n,view:r,tr:s,dispatch:i})=>{t={scrollIntoView:!0,...t};const o=()=>{(xm()||wm())&&r.dom.focus(),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),(null==t?void 0:t.scrollIntoView)&&n.commands.scrollIntoView())})};if(r.hasFocus()&&null===e||!1===e)return!0;if(i&&null===e&&!Hf(n.state.selection))return o(),!0;const a=Vf(s.doc,e)||n.state.selection,l=n.state.selection.eq(a);return i&&(l||s.setSelection(a),l&&s.storedMarks&&s.setStoredMarks(s.storedMarks),o()),!0},Sm=(e,t)=>n=>e.every((e,r)=>t(e,{...n,index:r})),Em=(e,t)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},e,t),Mm=(e,t,n)=>({tr:r,dispatch:s,editor:i})=>{var o;if(s){let s;const l=e=>{i.emit("contentError",{editor:i,error:e,disableCollaboration:()=>{"collaboration"in i.storage&&"object"==typeof i.storage.collaboration&&i.storage.collaboration&&(i.storage.collaboration.isDisabled=!0)}})},c={preserveWhitespace:"full",...(n={parseOptions:i.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n}).parseOptions};if(!n.errorOnInvalidContent&&!i.options.enableContentCheck&&i.options.emitContentError)try{ef(t,i.schema,{parseOptions:c,errorOnInvalidContent:!0})}catch(a){l(a)}try{s=ef(t,i.schema,{parseOptions:c,errorOnInvalidContent:null!=(o=n.errorOnInvalidContent)?o:i.options.enableContentCheck})}catch(a){return l(a),!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 s?[s]:s).forEach(e=>{e.check(),p=!!p&&(e.isText&&0===e.marks.length),h=!!h&&e.isBlock}),d===u&&h){const{parent:e}=r.doc.resolve(d);e.isTextblock&&!e.type.spec.code&&!e.childCount&&(d-=1,u+=1)}let f;if(p){if(Array.isArray(t))f=t.map(e=>e.text||"").join("");else if(t instanceof Qo){let e="";t.forEach(t=>{t.text&&(e+=t.text)}),f=e}else f="object"==typeof t&&t&&t.text?t.text:t;r.insertText(f,d,u)}else{f=s;const e=r.doc.resolve(d),t=e.node(),n=0===e.parentOffset,i=t.isText||t.isTextblock,o=t.content.size>0;n&&i&&o&&(d=Math.max(0,d-1)),r.replaceWith(d,u,f)}n.updateSelection&&function(e,t,n){const r=e.steps.length-1;if(r<t)return;const s=e.steps[r];if(!(s instanceof yl||s instanceof vl))return;const i=e.mapping.maps[r];let o=0;i.forEach((e,t,n,r)=>{0===o&&(o=r)}),e.setSelection(Jl.near(e.doc.resolve(o),n))}(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:d,text:f}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:d,text:f})}return!0},_m=()=>({state:e,dispatch:t})=>((e,t)=>{let n,r=e.selection,s=r instanceof tc;if(s){if(r.node.isTextblock||!Ol(e.doc,r.from))return!1;n=r.from}else if(n=Tl(e.doc,r.from,-1),null==n)return!1;if(t){let r=e.tr.join(n);s&&r.setSelection(tc.create(r.doc,n-e.doc.resolve(n).nodeBefore.nodeSize)),t(r.scrollIntoView())}return!0})(e,t),Nm=()=>({state:e,dispatch:t})=>((e,t)=>{let n,r=e.selection;if(r instanceof tc){if(r.node.isTextblock||!Ol(e.doc,r.to))return!1;n=r.to}else if(n=Tl(e.doc,r.to,1),null==n)return!1;return t&&t(e.tr.join(n).scrollIntoView()),!0})(e,t),Cm=()=>({state:e,dispatch:t})=>Eh(e,t),Om=()=>({state:e,dispatch:t})=>Ah(e,t),Am=()=>({state:e,dispatch:t,tr:n})=>{try{const r=Tl(e.doc,e.selection.$from.pos,-1);return null!=r&&(n.join(r,2),t&&t(n),!0)}catch{return!1}},Tm=()=>({state:e,dispatch:t,tr:n})=>{try{const r=Tl(e.doc,e.selection.$from.pos,1);return null!=r&&(n.join(r,2),t&&t(n),!0)}catch{return!1}},Im=()=>({state:e,dispatch:t})=>((e,t,n)=>{let r=Sh(e,n);if(!r)return!1;let s=Ch(r);return!!s&&Mh(e,s,t)})(e,t),Dm=()=>({state:e,dispatch:t})=>((e,t,n)=>{let r=Oh(e,n);if(!r)return!1;let s=Ih(r);return!!s&&Mh(e,s,t)})(e,t);function Rm(){return"undefined"!=typeof navigator&&/Mac/.test(navigator.platform)}var Lm=e=>({editor:t,view:n,tr:r,dispatch:s})=>{const i=function(e){const t=e.split(/-(?!$)/);let n,r,s,i,o=t[t.length-1];"Space"===o&&(o=" ");for(let a=0;a<t.length-1;a+=1){const e=t[a];if(/^(cmd|meta|m)$/i.test(e))i=!0;else if(/^a(lt)?$/i.test(e))n=!0;else if(/^(c|ctrl|control)$/i.test(e))r=!0;else if(/^s(hift)?$/i.test(e))s=!0;else{if(!/^mod$/i.test(e))throw new Error(`Unrecognized modifier name: ${e}`);xm()||Rm()?i=!0:r=!0}}return n&&(o=`Alt-${o}`),r&&(o=`Ctrl-${o}`),i&&(o=`Meta-${o}`),s&&(o=`Shift-${o}`),o}(e).split(/-(?!$)/),o=i.find(e=>!["Alt","Ctrl","Meta","Shift"].includes(e)),a=new KeyboardEvent("keydown",{key:"Space"===o?" ":o,altKey:i.includes("Alt"),ctrlKey:i.includes("Ctrl"),metaKey:i.includes("Meta"),shiftKey:i.includes("Shift"),bubbles:!0,cancelable:!0}),l=t.captureTransaction(()=>{n.someProp("handleKeyDown",e=>e(n,a))});return null==l||l.steps.forEach(e=>{const t=e.map(r.mapping);t&&s&&r.maybeStep(t)}),!0},Pm=(e,t={})=>({state:n,dispatch:r})=>!!jf(n,Sf(e,n.schema),t)&&((e,t)=>{let{$from:n,$to:r}=e.selection,s=n.blockRange(r),i=s&&Sl(s);return null!=i&&(t&&t(e.tr.lift(s,i).scrollIntoView()),!0)})(n,r),jm=()=>({state:e,dispatch:t})=>Ph(e,t),Bm=e=>({state:t,dispatch:n})=>Vh(Sf(e,t.schema))(t,n),zm=()=>({state:e,dispatch:t})=>Dh(e,t);function $m(e,t){const n="string"==typeof t?[t]:t;return Object.keys(e).reduce((t,r)=>(n.includes(r)||(t[r]=e[r]),t),{})}var Fm=(e,t)=>({tr:n,state:r,dispatch:s})=>{let i=null,o=null;const a=Ef("string"==typeof e?e:e.name,r.schema);return!!a&&("node"===a&&(i=Sf(e,r.schema)),"mark"===a&&(o=xf(e,r.schema)),s&&n.selection.ranges.forEach(e=>{r.doc.nodesBetween(e.$from.pos,e.$to.pos,(e,r)=>{i&&i===e.type&&n.setNodeMarkup(r,void 0,$m(e.attrs,t)),o&&e.marks.length&&e.marks.forEach(s=>{o===s.type&&n.addMark(r,r+e.nodeSize,o.create($m(s.attrs,t)))})})}),!0)},Hm=()=>({tr:e,dispatch:t})=>(t&&e.scrollIntoView(),!0),Um=()=>({tr:e,dispatch:t})=>{if(t){const t=new rc(e.doc);e.setSelection(t)}return!0},qm=()=>({state:e,dispatch:t})=>Nh(e,t),Vm=()=>({state:e,dispatch:t})=>Th(e,t),Km=()=>({state:e,dispatch:t})=>((e,t)=>{let n,{$from:r,to:s}=e.selection,i=r.sharedDepth(s);return 0!=i&&(n=r.before(i),t&&t(e.tr.setSelection(tc.create(e.doc,n))),!0)})(e,t),Wm=()=>({state:e,dispatch:t})=>Fh(e,t),Gm=()=>({state:e,dispatch:t})=>$h(e,t),Jm=(e,{errorOnInvalidContent:t,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:s,tr:i,dispatch:o,commands:a})=>{const{doc:l}=i;if("full"!==r.preserveWhitespace){const a=tf(e,s.schema,r,{errorOnInvalidContent:null!=t?t:s.options.enableContentCheck});return o&&i.replaceWith(0,l.content.size,a).setMeta("preventUpdate",!n),!0}return o&&i.setMeta("preventUpdate",!n),a.insertContentAt({from:0,to:l.content.size},e,{parseOptions:r,errorOnInvalidContent:null!=t?t:s.options.enableContentCheck})};var Zm=(e,t={})=>({tr:n,state:r,dispatch:s})=>{const{selection:i}=n,{empty:o,ranges:a}=i,l=xf(e,r.schema);if(s)if(o){const e=kf(r,l);n.addStoredMark(l.create({...e,...t}))}else a.forEach(e=>{const s=e.$from.pos,i=e.$to.pos;r.doc.nodesBetween(s,i,(e,r)=>{const o=Math.max(r,s),a=Math.min(r+e.nodeSize,i);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;const{selection:s}=t;let i=null;if(Hf(s)&&(i=s.$cursor),i){const t=null!=(r=e.storedMarks)?r:i.marks();return i.parent.type.allowsMarkType(n)&&(!!n.isInSet(t)||!t.some(e=>e.type.excludes(n)))}const{ranges:o}=s;return o.some(({$from:t,$to:r})=>{let s=0===t.depth&&e.doc.inlineContent&&e.doc.type.allowsMarkType(n);return e.doc.nodesBetween(t.pos,r.pos,(e,t,r)=>{if(s)return!1;if(e.isInline){const t=!r||r.type.allowsMarkType(n),i=!!n.isInSet(e.marks)||!e.marks.some(e=>e.type.excludes(n));s=t&&i}return!s}),s})}(r,n,l)},Qm=(e,t)=>({tr:n})=>(n.setMeta(e,t),!0),Xm=(e,t={})=>({state:n,dispatch:r,chain:s})=>{const i=Sf(e,n.schema);let o;return n.selection.$anchor.sameParent(n.selection.$head)&&(o=n.selection.$anchor.parent.attrs),i.isTextblock?s().command(({commands:e})=>!!Hh(i,{...o,...t})(n)||e.clearNodes()).command(({state:e})=>Hh(i,{...o,...t})(e,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},Ym=e=>({tr:t,dispatch:n})=>{if(n){const{doc:n}=t,r=Uf(e,0,n.content.size),s=tc.create(n,r);t.setSelection(s)}return!0},eg=e=>({tr:t,dispatch:n})=>{if(n){const{doc:n}=t,{from:r,to:s}="number"==typeof e?{from:e,to:e}:e,i=Yl.atStart(n).from,o=Yl.atEnd(n).to,a=Uf(r,i,o),l=Uf(s,i,o),c=Yl.create(n,a,l);t.setSelection(c)}return!0},tg=e=>({state:t,dispatch:n})=>{const r=Sf(e,t.schema);return(s=r,function(e,t){let{$from:n,$to:r}=e.selection,i=n.blockRange(r,e=>e.childCount>0&&e.firstChild.type==s);if(!i)return!1;let o=i.startIndex;if(0==o)return!1;let a=i.parent,l=a.child(o-1);if(l.type!=s)return!1;if(t){let n=l.lastChild&&l.lastChild.type==a.type,r=Qo.from(n?s.create():null),o=new ra(Qo.from(s.create(null,Qo.from(a.type.create(null,r)))),n?3:1,0),c=i.start,d=i.end;t(e.tr.step(new vl(c-(n?3:1),d,c,d,o,1,!0)).scrollIntoView())}return!0})(t,n);var s};function ng(e,t){const n=e.storedMarks||e.selection.$to.parentOffset&&e.selection.$from.marks();if(n){const r=n.filter(e=>null==t?void 0:t.includes(e.type.name));e.tr.ensureMarks(r)}}var rg=({keepMarks:e=!0}={})=>({tr:t,state:n,dispatch:r,editor:s})=>{const{selection:i,doc:o}=t,{$from:a,$to:l}=i,c=Lf(s.extensionManager.attributes,a.node().type.name,a.node().attrs);if(i instanceof tc&&i.node.isBlock)return!(!a.parentOffset||!Cl(o,a.pos))&&(r&&(e&&ng(n,s.extensionManager.splittableMarks),t.split(a.pos).scrollIntoView()),!0);if(!a.parent.isBlock)return!1;const d=l.parentOffset===l.parent.content.size,u=0===a.depth?void 0:function(e){for(let t=0;t<e.edgeCount;t+=1){const{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}(a.node(-1).contentMatchAt(a.indexAfter(-1)));let p=d&&u?[{type:u,attrs:c}]:void 0,h=Cl(t.doc,t.mapping.map(a.pos),1,p);if(p||h||!Cl(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&&(i instanceof Yl&&t.deleteSelection(),t.split(t.mapping.map(a.pos),1,p),u&&!d&&!a.parentOffset&&a.parent.type!==u)){const 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&&ng(n,s.extensionManager.splittableMarks),t.scrollIntoView()}return h},sg=(e,t={})=>({tr:n,state:r,dispatch:s,editor:i})=>{var o;const a=Sf(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;const u=l.node(-1);if(u.type!==a)return!1;const p=i.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(s){let e=Qo.empty;const r=l.index(-1)?1:l.index(-2)?2:3;for(let t=l.depth-r;t>=l.depth-3;t-=1)e=Qo.from(l.node(t).copy(e));const s=l.indexAfter(-1)<l.node(-2).childCount?1:l.indexAfter(-2)<l.node(-3).childCount?2:3,i={...Lf(p,l.node().type.name,l.node().attrs),...t},c=(null==(o=a.contentMatch.defaultType)?void 0:o.createAndFill(i))||void 0;e=e.append(Qo.from(a.createAndFill(null,c)||void 0));const d=l.before(l.depth-(r-1));n.replace(d,l.after(-s),new ra(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(Yl.near(n.doc.resolve(u))),n.scrollIntoView()}return!0}const h=c.pos===l.end()?u.contentMatchAt(0).defaultType:null,f={...Lf(p,u.type.name,u.attrs),...t},m={...Lf(p,l.node().type.name,l.node().attrs),...t};n.delete(l.pos,c.pos);const g=h?[{type:a,attrs:f},{type:h,attrs:m}]:[{type:a,attrs:f}];if(!Cl(n.doc,l.pos,2))return!1;if(s){const{selection:e,storedMarks:t}=r,{splittableMarks:o}=i.extensionManager,a=t||e.$to.parentOffset&&e.$from.marks();if(n.split(l.pos,2,g).scrollIntoView(),!a||!s)return!0;const c=a.filter(e=>o.includes(e.type.name));n.ensureMarks(c)}return!0},ig=(e,t)=>{const n=rf(e=>e.type===t)(e.selection);if(!n)return!0;const r=e.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(void 0===r)return!0;const s=e.doc.nodeAt(r);return n.node.type!==(null==s?void 0:s.type)||!Ol(e.doc,n.pos)||(e.join(n.pos),!0)},og=(e,t)=>{const n=rf(e=>e.type===t)(e.selection);if(!n)return!0;const r=e.doc.resolve(n.start).after(n.depth);if(void 0===r)return!0;const s=e.doc.nodeAt(r);return n.node.type!==(null==s?void 0:s.type)||!Ol(e.doc,r)||(e.join(r),!0)},ag=(e,t,n,r={})=>({editor:s,tr:i,state:o,dispatch:a,chain:l,commands:c,can:d})=>{const{extensions:u,splittableMarks:p}=s.extensionManager,h=Sf(e,o.schema),f=Sf(t,o.schema),{selection:m,storedMarks:g}=o,{$from:b,$to:y}=m,v=b.blockRange(y),w=g||m.$to.parentOffset&&m.$from.marks();if(!v)return!1;const x=rf(e=>zf(e.type.name,u))(m);if(v.depth>=1&&x&&v.depth-x.depth<=1){if(x.node.type===h)return c.liftListItem(f);if(zf(x.node.type.name,u)&&h.validContent(x.node.content)&&a)return l().command(()=>(i.setNodeMarkup(x.pos,h),!0)).command(()=>ig(i,h)).command(()=>og(i,h)).run()}return n&&w&&a?l().command(()=>{const e=d().wrapInList(h,r),t=w.filter(e=>p.includes(e.type.name));return i.ensureMarks(t),!!e||c.clearNodes()}).wrapInList(h,r).command(()=>ig(i,h)).command(()=>og(i,h)).run():l().command(()=>!!d().wrapInList(h,r)||c.clearNodes()).wrapInList(h,r).command(()=>ig(i,h)).command(()=>og(i,h)).run()},lg=(e,t={},n={})=>({state:r,commands:s})=>{const{extendEmptyMarkRange:i=!1}=n,o=xf(e,r.schema);return Pf(r,o,t)?s.unsetMark(o,{extendEmptyMarkRange:i}):s.setMark(o,t)},cg=(e,t,n={})=>({state:r,commands:s})=>{const i=Sf(e,r.schema),o=Sf(t,r.schema),a=jf(r,i,n);let l;return r.selection.$anchor.sameParent(r.selection.$head)&&(l=r.selection.$anchor.parent.attrs),a?s.setNode(o,l):s.setNode(i,{...l,...n})},dg=(e,t={})=>({state:n,commands:r})=>{const s=Sf(e,n.schema);return jf(n,s,t)?r.lift(s):r.wrapIn(s,t)},ug=()=>({state:e,dispatch:t})=>{const n=e.plugins;for(let r=0;r<n.length;r+=1){const s=n[r];let i;if(s.spec.isInputRules&&(i=s.getState(e))){if(t){const 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){const 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},pg=()=>({tr:e,dispatch:t})=>{const{selection:n}=e,{empty:r,ranges:s}=n;return r||t&&s.forEach(t=>{e.removeMark(t.$from.pos,t.$to.pos)}),!0},hg=(e,t={})=>({tr:n,state:r,dispatch:s})=>{var i;const{extendEmptyMarkRange:o=!1}=t,{selection:a}=n,l=xf(e,r.schema),{$from:c,empty:d,ranges:u}=a;if(!s)return!0;if(d&&o){let{from:e,to:t}=a;const r=null==(i=c.marks().find(e=>e.type===l))?void 0:i.attrs,s=If(c,l,r);s&&(e=s.from,t=s.to),n.removeMark(e,t,l)}else u.forEach(e=>{n.removeMark(e.$from.pos,e.$to.pos,l)});return n.removeStoredMark(l),!0},fg=(e,t={})=>({tr:n,state:r,dispatch:s})=>{let i=null,o=null;const a=Ef("string"==typeof e?e:e.name,r.schema);return!!a&&("node"===a&&(i=Sf(e,r.schema)),"mark"===a&&(o=xf(e,r.schema)),s&&n.selection.ranges.forEach(e=>{const s=e.$from.pos,a=e.$to.pos;let l,c,d,u;n.selection.empty?r.doc.nodesBetween(s,a,(e,t)=>{i&&i===e.type&&(d=Math.max(t,s),u=Math.min(t+e.nodeSize,a),l=t,c=e)}):r.doc.nodesBetween(s,a,(e,r)=>{r<s&&i&&i===e.type&&(d=Math.max(r,s),u=Math.min(r+e.nodeSize,a),l=r,c=e),r>=s&&r<=a&&(i&&i===e.type&&n.setNodeMarkup(r,void 0,{...e.attrs,...t}),o&&e.marks.length&&e.marks.forEach(i=>{if(o===i.type){const l=Math.max(r,s),c=Math.min(r+e.nodeSize,a);n.addMark(l,c,o.create({...i.attrs,...t}))}}))}),c&&(void 0!==l&&n.setNodeMarkup(l,void 0,{...c.attrs,...t}),o&&c.marks.length&&c.marks.forEach(e=>{o===e.type&&n.addMark(d,u,o.create({...e.attrs,...t}))}))}),!0)},mg=(e,t={})=>({state:n,dispatch:r})=>function(e,t=null){return function(n,r){let{$from:s,$to:i}=n.selection,o=s.blockRange(i),a=o&&El(o,e,t);return!!a&&(r&&r(n.tr.wrap(o,a).scrollIntoView()),!0)}}(Sf(e,n.schema),t)(n,r),gg=(e,t={})=>({state:n,dispatch:r})=>qh(Sf(e,n.schema),t)(n,r),bg=rm.create({name:"commands",addCommands:()=>({...im})}),yg=rm.create({name:"delete",onUpdate({transaction:e,appendedTransactions:t}){var n,r,s;const i=()=>{var n,r,s,i;if(null!=(i=null==(s=null==(r=null==(n=this.editor.options.coreExtensionOptions)?void 0:n.delete)?void 0:r.filterTransaction)?void 0:s.call(r,e))?i:e.getMeta("y-sync$"))return;const o=Qh(e.before,[e,...t]);Nf(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)=>{const s=r+n.nodeSize-2,i=t.oldRange.from<=r&&s<=t.oldRange.to;this.editor.emit("delete",{type:"node",node:n,from:r,to:s,newFrom:o.mapping.map(r),newTo:o.mapping.map(s),deletedRange:t.oldRange,newRange:t.newRange,partial:!i,editor:this.editor,transaction:e,combinedTransform:o})})});const a=o.mapping;o.steps.forEach((t,n)=>{var r,s;if(t instanceof ml){const i=a.slice(n).map(t.from,-1),l=a.slice(n).map(t.to),c=a.invert().map(i,-1),d=a.invert().map(l),u=null==(r=o.doc.nodeAt(i-1))?void 0:r.marks.some(e=>e.eq(t.mark)),p=null==(s=o.doc.nodeAt(l))?void 0:s.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:i,to:l},partial:Boolean(p||u),editor:this.editor,transaction:e,combinedTransform:o})}})};null==(s=null==(r=null==(n=this.editor.options.coreExtensionOptions)?void 0:n.delete)?void 0:r.async)||s?setTimeout(i,0):i()}}),vg=rm.create({name:"drop",addProseMirrorPlugins(){return[new fc({key:new bc("tiptapDrop"),props:{handleDrop:(e,t,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:t,slice:n,moved:r})}}})]}}),wg=rm.create({name:"editable",addProseMirrorPlugins(){return[new fc({key:new bc("editable"),props:{editable:()=>this.editor.options.editable}})]}}),xg=new bc("focusEvents"),kg=rm.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:e}=this;return[new fc({key:xg,props:{handleDOMEvents:{focus:(t,n)=>{e.isFocused=!0;const r=e.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return t.dispatch(r),!1},blur:(t,n)=>{e.isFocused=!1;const r=e.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return t.dispatch(r),!1}}}})]}}),Sg=rm.create({name:"keymap",addKeyboardShortcuts(){const e=()=>this.editor.commands.first(({commands:e})=>[()=>e.undoInputRule(),()=>e.command(({tr:t})=>{const{selection:n,doc:r}=t,{empty:s,$anchor:i}=n,{pos:o,parent:a}=i,l=i.parent.isTextblock&&o>0?t.doc.resolve(o-1):i,c=l.parent.type.spec.isolating,d=i.pos-i.parentOffset,u=c&&1===l.parent.childCount?d===i.pos:Jl.atStart(r).from===o;return!(!s||!a.type.isTextblock||a.textContent.length||!u||u&&"paragraph"===i.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},s={...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 xm()||Rm()?s:r},addProseMirrorPlugins(){return[new fc({key:new bc("clearDocument"),appendTransaction:(e,t,n)=>{if(e.some(e=>e.getMeta("composition")))return;const r=e.some(e=>e.docChanged)&&!t.doc.eq(n.doc),s=e.some(e=>e.getMeta("preventClearDocument"));if(!r||s)return;const{empty:i,from:o,to:a}=t.selection,l=Jl.atStart(t.doc).from,c=Jl.atEnd(t.doc).to;if(i||!(o===l&&a===c))return;if(!$f(n.doc))return;const d=n.tr,u=Gh({state:n,transaction:d}),{commands:p}=new Jh({editor:this.editor,state:u});return p.clearNodes(),d.steps.length?d:void 0}})]}}),Eg=rm.create({name:"paste",addProseMirrorPlugins(){return[new fc({key:new bc("tiptapPaste"),props:{handlePaste:(e,t,n)=>{this.editor.emit("paste",{editor:this.editor,event:t,slice:n})}}})]}}),Mg=rm.create({name:"tabindex",addProseMirrorPlugins(){return[new fc({key:new bc("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),_g=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?0:1)}get parent(){if(0===this.depth)return null;const t=this.resolvedPos.start(this.resolvedPos.depth-1),n=this.resolvedPos.doc.resolve(t);return new e(n,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(){const t=[];return this.node.content.forEach((n,r)=>{const s=n.isBlock&&!n.isTextblock,i=n.isAtom&&!n.isText,o=this.pos+r+(i?0:1);if(o<0||o>this.resolvedPos.doc.nodeSize-2)return;const a=this.resolvedPos.doc.resolve(o);if(!s&&a.depth<=this.depth)return;const l=new e(a,this.editor,s,s?n:null);s&&(l.actualDepth=this.depth+1),t.push(new e(a,this.editor,s,s?n:null))}),t}get firstChild(){return this.children[0]||null}get lastChild(){const 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){const e=r.node.attrs,n=Object.keys(t);for(let r=0;r<n.length;r+=1){const s=n[r];if(e[s]!==t[s])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;const s=Object.keys(t);return this.children.forEach(i=>{if(!(n&&r.length>0)){if(i.node.type.name===e){s.every(e=>t[e]===i.node.attrs[e])&&r.push(i)}n&&r.length>0||(r=r.concat(i.querySelectorAll(e,t,n)))}}),r}setAttribute(e){const{tr:t}=this.editor.state;t.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(t)}};var Ng=class extends Zh{constructor(e={}){super(),this.css=null,this.editorView=null,this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.options={element:"undefined"!=typeof document?document.createElement("div"):null,content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!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},this.isCapturingTransaction=!1,this.capturedTransaction=null,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=Vf(t,this.options.autofocus);this.editorState=pc.create({doc:t,schema:this.schema,selection:n||void 0}),this.options.element&&this.mount(this.options.element)}mount(e){if("undefined"==typeof document)throw new 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||(this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}unmount(){if(this.editorView){const 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)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&&"undefined"!=typeof document&&(this.css=function(e,t){const n=document.querySelector("style[data-tiptap-style]");if(null!==n)return n;const 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}('.ProseMirror {\n  position: relative;\n}\n\n.ProseMirror {\n  word-wrap: break-word;\n  white-space: pre-wrap;\n  white-space: break-spaces;\n  -webkit-font-variant-ligatures: none;\n  font-variant-ligatures: none;\n  font-feature-settings: "liga" 0; /* the above doesn\'t seem to work in Edge */\n}\n\n.ProseMirror [contenteditable="false"] {\n  white-space: normal;\n}\n\n.ProseMirror [contenteditable="false"] [contenteditable="true"] {\n  white-space: pre-wrap;\n}\n\n.ProseMirror pre {\n  white-space: pre-wrap;\n}\n\nimg.ProseMirror-separator {\n  display: inline !important;\n  border: none !important;\n  margin: 0 !important;\n  width: 0 !important;\n  height: 0 !important;\n}\n\n.ProseMirror-gapcursor {\n  display: none;\n  pointer-events: none;\n  position: absolute;\n  margin: 0;\n}\n\n.ProseMirror-gapcursor:after {\n  content: "";\n  display: block;\n  position: absolute;\n  top: -2px;\n  width: 20px;\n  border-top: 1px solid black;\n  animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;\n}\n\n@keyframes ProseMirror-cursor-blink {\n  to {\n    visibility: hidden;\n  }\n}\n\n.ProseMirror-hideselection *::selection {\n  background: transparent;\n}\n\n.ProseMirror-hideselection *::-moz-selection {\n  background: transparent;\n}\n\n.ProseMirror-hideselection * {\n  caret-color: transparent;\n}\n\n.ProseMirror-focused .ProseMirror-gapcursor {\n  display: block;\n}',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 new 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){const n=lf(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;const t=this.state.plugins;let n=t;if([].concat(e).forEach(e=>{const t="string"==typeof e?`${e}$`:e.key;n=n.filter(e=>!e.key.startsWith(t))}),t.length===n.length)return;const r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}createExtensionManager(){var e,t;const n=[...this.options.enableCoreExtensions?[wg,sm.configure({blockSeparator:null==(t=null==(e=this.options.coreExtensionOptions)?void 0:e.clipboardTextSerializer)?void 0:t.blockSeparator}),bg,kg,Sg,Mg,vg,Eg,yg].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 nm(n,this)}createCommandManager(){this.commandManager=new Jh({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let e;try{e=tf(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=tf(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return e}createView(e){var t;this.editorView=new sh(e,{...this.options.editorProps,attributes:{role:"textbox",...null==(t=this.options.editorProps)?void 0:t.attributes},dispatchTransaction:this.dispatchTransaction.bind(this),state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});const n=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(n),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=`tiptap ${this.view.dom.className}`}captureTransaction(e){this.isCapturingTransaction=!0,e(),this.isCapturingTransaction=!1;const t=this.capturedTransaction;return this.capturedTransaction=null,t}dispatchTransaction(e){if(this.view.isDestroyed)return;if(this.isCapturingTransaction)return this.capturedTransaction?void e.steps.forEach(e=>{var t;return null==(t=this.capturedTransaction)?void 0:t.step(e)}):void(this.capturedTransaction=e);const{state:t,transactions:n}=this.state.applyTransaction(e),r=!this.state.selection.eq(t.selection),s=n.includes(e),i=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:e,nextState:t}),!s)return;this.view.updateState(t),this.emit("transaction",{editor:this,transaction:e,appendedTransactions:n.slice(1)}),r&&this.emit("selectionUpdate",{editor:this,transaction:e});const 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)||i.doc.eq(t.doc)||this.emit("update",{editor:this,transaction:e,appendedTransactions:n.slice(1)})}getAttributes(e){return Mf(this.state,e)}isActive(e,t){const n="string"==typeof e?e:null,r="string"==typeof e?t:e;return function(e,t,n={}){if(!t)return jf(e,null,n)||Pf(e,null,n);const r=Ef(t,e.schema);return"node"===r?jf(e,t,n):"mark"===r&&Pf(e,t,n)}(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return af(this.state.doc.content,this.schema)}getText(e){const{blockSeparator:t="\n\n",textSerializers:n={}}=e||{};return vf(this.state.doc,{blockSeparator:t,textSerializers:{...wf(this.schema),...n}})}get isEmpty(){return $f(this.state.doc)}destroy(){this.emit("destroy"),this.unmount(),this.removeAllListeners()}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){const t=this.state.doc.resolve(e);return new _g(t,this)}get $doc(){return this.$pos(0)}};function Cg(e){return new Kf({find:e.find,handler:({state:t,range:n,match:r})=>{const s=cf(e.getAttributes,void 0,r);if(!1===s||null===s)return null;const{tr:i}=t,o=r[r.length-1],a=r[0];if(o){const r=a.search(/\S/),l=n.from+a.indexOf(o),c=l+o.length;if(Df(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&&i.delete(c,n.to),l>n.from&&i.delete(n.from+r,l);const d=n.from+r+o.length;i.addMark(n.from+r,d,e.type.create(s||{})),i.removeStoredMark(e.type)}},undoable:e.undoable})}function Og(e){return new Kf({find:e.find,handler:({state:t,range:n,match:r})=>{const s=t.doc.resolve(n.from),i=cf(e.getAttributes,void 0,r)||{};if(!s.node(-1).canReplaceWith(s.index(-1),s.indexAfter(-1),e.type))return null;t.tr.delete(n.from,n.to).setBlockType(n.from,n.from,e.type,i)},undoable:e.undoable})}function Ag(e){return new Kf({find:e.find,handler:({state:t,range:n,match:r,chain:s})=>{const i=cf(e.getAttributes,void 0,r)||{},o=t.tr.delete(n.from,n.to),a=o.doc.resolve(n.from).blockRange(),l=a&&El(a,e.type,i);if(!l)return null;if(o.wrap(a,l),e.keepMarks&&e.editor){const{selection:n,storedMarks:r}=t,{splittableMarks:s}=e.editor.extensionManager,i=r||n.$to.parentOffset&&n.$from.marks();if(i){const e=i.filter(e=>s.includes(e.type.name));o.ensureMarks(e)}}if(e.keepAttributes){const t="bulletList"===e.type.name||"orderedList"===e.type.name?"listItem":"taskList";s().updateAttributes(t,i).run()}const c=o.doc.resolve(n.from-1).nodeBefore;c&&c.type===e.type&&Ol(o.doc,n.from-1)&&(!e.joinPredicate||e.joinPredicate(r,c))&&o.join(n.from-1)},undoable:e.undoable})}var Tg=class e extends Zf{constructor(){super(...arguments),this.type="node"}static create(t={}){const n="function"==typeof t?t():t;return new e(n)}configure(e){return super.configure(e)}extend(e){const t="function"==typeof e?e():e;return super.extend(t)}},Ig=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,s,i,o,a;const{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){const t=this.dom.getBoundingClientRect(),n=d.getBoundingClientRect(),a=null!=(s=e.offsetX)?s:null==(r=e.nativeEvent)?void 0:r.offsetX,l=null!=(o=e.offsetY)?o:null==(i=e.nativeEvent)?void 0:i.offsetY;u=n.x-t.x+a,p=n.y-t.y+l}const h=this.dom.cloneNode(!0);try{const 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"),f.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)}const m=this.getPos();if("number"!=typeof m)return;const g=tc.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});const n=e.target;if(!(this.dom.contains(n)&&!(null==(t=this.contentDOM)?void 0:t.contains(n))))return!1;const r=e.type.startsWith("drag"),s="drop"===e.type;if((["INPUT","BUTTON","SELECT","TEXTAREA"].includes(n.tagName)||n.isContentEditable)&&!s&&!r)return!0;const{isEditable:i}=this.editor,{isDragging:o}=this,a=!!this.node.type.spec.draggable,l=tc.isSelectable(this.node),c="copy"===e.type,d="paste"===e.type,u="cut"===e.type,p="mousedown"===e.type;if(!a&&l&&r&&e.target===this.dom&&e.preventDefault(),a&&r&&!o&&e.target===this.dom)return e.preventDefault(),!1;if(a&&i&&!o&&p){const 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!(o||s||c||d||u||p&&l)}ignoreMutation(e){if(!this.dom||!this.contentDOM)return!0;if("function"==typeof this.options.ignoreMutation)return this.options.ignoreMutation({mutation:e});if(this.node.isLeaf||this.node.isAtom)return!0;if("selection"===e.type)return!1;if(this.dom.contains(e.target)&&"childList"===e.type&&(xm()||wm())&&this.editor.isFocused){if([...Array.from(e.addedNodes),...Array.from(e.removedNodes)].every(e=>e.isContentEditable))return!1}return this.contentDOM===e.target&&"attributes"===e.type||!this.contentDOM.contains(e.target)}updateAttributes(e){this.editor.commands.command(({tr:t})=>{const n=this.getPos();return"number"==typeof n&&(t.setNodeMarkup(n,void 0,{...this.node.attrs,...e}),!0)})}deleteNode(){const e=this.getPos();if("number"!=typeof e)return;const t=e+this.node.nodeSize;this.editor.commands.deleteRange({from:e,to:t})}};function Dg(e){return new Xf({find:e.find,handler:({state:t,range:n,match:r,pasteEvent:s})=>{const i=cf(e.getAttributes,void 0,r,s);if(!1===i||null===i)return null;const{tr:o}=t,a=r[r.length-1],l=r[0];let c=n.to;if(a){const r=l.search(/\S/),s=n.from+l.indexOf(a),d=s+a.length;if(Df(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>s).length)return null;d<n.to&&o.delete(d,n.to),s>n.from&&o.delete(n.from+r,s),c=n.from+r+a.length,o.addMark(n.from+r,c,e.type.create(i||{})),o.removeStoredMark(e.type)}}})}const Rg=Qf.create({name:"dictation",parseHTML:()=>[{tag:"span[data-dictation]"}],renderHTML:({HTMLAttributes:e})=>["span",pf(e,{"data-dictation":"",class:"italic text-text-500"}),0]});function Lg(e,t,n){const r=e+t+n,s=e.length,i=e.length+t.length,o=r.split("\n");let a=0;return{type:"doc",content:o.map(e=>{const t=a,n=a+e.length;if(a=n+1,0===e.length)return{type:"paragraph"};const r=[];if(t<s&&t<n){const i=Math.min(s,n),o=e.slice(0,i-t);o&&r.push({text:o,isDictation:!1})}if(n>s&&t<i){const o=Math.max(s,t),a=Math.min(i,n),l=e.slice(o-t,a-t);l&&r.push({text:l,isDictation:!0})}if(n>i){const n=Math.max(i,t),s=e.slice(n-t);s&&r.push({text:s,isDictation:!1})}const o=r.map(e=>{const t={type:"text",text:e.text};return e.isDictation&&(t.marks=[{type:"dictation"}]),t});return{type:"paragraph",content:o.length>0?o:void 0}})}}function Pg(e,t,n){let r=0;for(let s=0;s<t&&s<e.length;s++)"\n"===e[s]&&r++;return Math.min(t+1+r,n)}function jg(e,t){if(!t)return;const n=e.toLowerCase().indexOf(t);return-1!==n?[{start:n,end:n+t.length}]:void 0}function Bg(e,t){if(!t)return;const n=e.toLowerCase(),r=[];let s=0,i=n.indexOf(t,s);for(;-1!==i;){const e=i+t.length;r.push({start:i,end:e}),s=e,i=n.indexOf(t,s)}return r.length>0?r:void 0}function zg(e,t){if(!t||0===t.length)return[{text:e,highlighted:!1}];const n=[];let r=0;for(const s of t)s.start>r&&n.push({text:e.slice(r,s.start),highlighted:!1}),n.push({text:e.slice(s.start,s.end),highlighted:!0}),r=s.end;return r<e.length&&n.push({text:e.slice(r),highlighted:!1}),n}const $g=e.memo(function({text:e,query:n,highlightClassName:r="font-semibold text-text-100"}){if(!e)return t.jsx(t.Fragment,{});const s=n?jg(e,n):void 0;return s?t.jsx(t.Fragment,{children:zg(e,s).map((e,n)=>e.highlighted?t.jsx("span",{className:r,children:e.text},n):t.jsx("span",{children:e.text},n))}):t.jsx(t.Fragment,{children:e})}),Fg=e.createContext(!0);function Hg({reference:n,placement:s="top-start",horizontalOffset:i=-16,verticalOffset:o=10,usePortal:a=!1,onClickOutsideHandler:l,children:c,disableFlip:d=!1,maxHeightCap:u,zIndexClassName:p="z-dropdown",zIndex:h}){const[f,m]=e.useState(void 0),g=e.useRef(n),b=e.useMemo(()=>({getBoundingClientRect:()=>{const e=g.current;return"function"==typeof e?e():e||new DOMRect}}),[]),{refs:y,floatingStyles:v,isPositioned:w,update:x}=Nr({placement:s,middleware:[Or({mainAxis:o,crossAxis:i}),...d?[]:[Ar()],Tr({padding:8}),Ir({apply({availableHeight:e}){const t=e-16;m(void 0!==u?Math.min(t,u):t)},padding:8})],whileElementsMounted:Cr}),k=Xr(()=>{l&&l()},["mousedown"]);e.useLayoutEffect(()=>{y.setReference(b)},[y,b]),e.useLayoutEffect(()=>{g.current=n,x()},[n,x]);const S=t.jsx("div",{ref:e=>{y.setFloating(e),k&&(k.current=e)},role:"menu",style:{...v,...void 0!==h?{zIndex:h}:void 0,maxHeight:f?`${f}px`:void 0,...a?{pointerEvents:"auto"}:{}},className:`${p} bg-bg-000 rounded-xl border-0.5 border-border-200 shadow-[0px_2px_8px_0px_hsl(var(--always-black)/8%)] dark:shadow-[0px_2px_8px_0px_hsl(var(--always-black)/24%)] p-1.5 min-w-60 max-w-lg max-h-96 overflow-y-auto`,children:t.jsx(Fg.Provider,{value:w,children:c})});return a?r.createPortal(S,document.body):S}function Ug({anchorRef:n,description:s,sourcePluginName:i,sourceRepo:o,query:a=""}){const{refs:l,floatingStyles:c,isPositioned:d,middlewareData:u}=Nr({placement:"right-start",middleware:[Or(8),Ar({padding:8}),Tr({padding:8}),Dr()],whileElementsMounted:Cr}),p=e.useContext(Fg),h=br();e.useLayoutEffect(()=>{p&&n.current&&l.setReference(n.current)},[p,n,l]);const f=u.hide?.referenceHidden??!1;return r.createPortal(t.jsxs("div",{ref:l.setFloating,style:{...c,zIndex:h?yr:9999,visibility:d&&!f?"visible":"hidden"},className:"px-2 py-1 text-xs font-normal font-ui leading-tight rounded-md shadow-md text-always-white bg-always-black/80 backdrop-blur break-words max-w-[min(26rem,calc(100vw-4rem))] text-pretty pointer-events-none",children:[s&&t.jsx("div",{className:"line-clamp-[10]",children:t.jsx($g,{text:s,query:a,highlightClassName:"font-semibold"})}),o?t.jsx("div",{className:tt("text-always-white/60",{"mt-1":!!s}),children:t.jsx(pr,{defaultMessage:"via {repo}",id:"q8mQGA8/Dv",values:{repo:o}})}):i?t.jsx("div",{className:tt("text-always-white/60",{"mt-1":!!s}),children:t.jsx(pr,{defaultMessage:"{pluginName} plugin",id:"hjZiOewGta",values:{pluginName:bt(i)}})}):null]}),document.body)}const qg={local:["default","acceptEdits","plan"],remote:["default","plan"],bridge:["default","acceptEdits","plan"],cowork:["default"]};function Vg(e,t){const n=[...qg[e]];return t?.auto&&n.push("auto"),t?.bypass&&n.push("bypassPermissions"),n}function Kg(e,t){return t.includes(e)?e:"auto"===e&&t.includes("acceptEdits")?"acceptEdits":t[0]??"acceptEdits"}function Wg({mode:e,intl:n,iconSize:r=12,envType:s,sessionType:i,compact:o=!1}){const a=void 0!==s&&"local"!==s&&"ssh"!==s&&"bridge"!==s,l="cowork"===i;switch(e){case"plan":return{label:n.formatMessage({defaultMessage:"Plan",id:"6m12Z4ECay",description:"A mode where Claude makes a plan before doing any work"}),description:n.formatMessage({defaultMessage:"Create a plan before making changes",id:"OjKD8Jtn5k"}),icon:t.jsx(vr,{name:"Scroll",customSize:r})};case"acceptEdits":return{label:n.formatMessage({defaultMessage:"Accept edits",id:"q2/2k27Kto",description:"A permission mode where Claude automatically accepts all file edits."}),triggerLabel:o?n.formatMessage({defaultMessage:"Accept",id:"zV6CaeOA6D",description:"Short trigger label for the Accept edits permission mode."}):void 0,description:n.formatMessage({defaultMessage:"Automatically accept all file edits",id:"uAswEIOvGS"}),icon:t.jsx(vr,{name:"Code",customSize:r})};case"auto":return l?{label:n.formatMessage({defaultMessage:"Automatically approve",id:"3AfgKEM6TG"}),triggerLabel:n.formatMessage({defaultMessage:"Auto",id:"NXI/XLSYwc"}),description:n.formatMessage({defaultMessage:"Claude runs on its own and pauses to ask if anything looks unsafe.",id:"8WnXxpx/gr"}),icon:t.jsx(vr,{name:"Fastforward",customSize:r})}:{label:n.formatMessage({defaultMessage:"Auto",id:"xn3dIBnIVy",description:"Permission mode where Claude handles permission decisions automatically."}),description:n.formatMessage({defaultMessage:"Claude handles permission decisions",id:"2b+XMaMHUB"}),icon:t.jsx(vr,{name:"Lightning",customSize:r})};case"bypassPermissions":return l?{label:n.formatMessage({defaultMessage:"Skip all approvals",id:"LQiIjZex33"}),triggerLabel:n.formatMessage({defaultMessage:"Skip",id:"/4tOwTiCH6"}),description:n.formatMessage({defaultMessage:"Claude never pauses, even for unsafe actions.",id:"QGWE9Pc1Dn"}),icon:t.jsx(vr,{name:"Warning",customSize:r}),isWarning:!0}:{label:n.formatMessage({defaultMessage:"Bypass permissions",id:"q29dVy10XD",description:"A mode where Claude takes all actions without asking for permission."}),triggerLabel:o?n.formatMessage({defaultMessage:"Bypass",id:"OGLnXBWFlh",description:"Short trigger label for the Bypass permissions permission mode."}):void 0,description:n.formatMessage({defaultMessage:"Accepts all permissions",id:"UvugapWhRy"}),icon:t.jsx(vr,{name:"Warning",customSize:r}),isWarning:!0};case"default":if(l)return{label:n.formatMessage({defaultMessage:"Manually approve",id:"jBDj0CUO5X"}),triggerLabel:n.formatMessage({defaultMessage:"Manual",id:"M59JhXXku8"}),description:n.formatMessage({defaultMessage:"Claude pauses so you can approve each action.",id:"apqQvFGeSz"}),icon:t.jsx(vr,{name:"Hand",customSize:r})};if(a)return{label:n.formatMessage({defaultMessage:"Accept edits",id:"q2/2k27Kto",description:"A permission mode where Claude automatically accepts all file edits."}),description:n.formatMessage({defaultMessage:"Automatically accept all file edits",id:"uAswEIOvGS"}),icon:t.jsx(vr,{name:"Code",customSize:r})};default:return{label:n.formatMessage({defaultMessage:"Manual",id:"bEP1fZ8uSe",description:"A mode where Claude asks for approval before making changes."}),description:n.formatMessage({defaultMessage:"Always ask before making changes",id:"uScJvDfyGZ"}),icon:t.jsx(vr,{name:"Hand",customSize:r})}}}function Gg(e){const t=e.replace(/\/+$/,""),n=t.lastIndexOf("/");return(n>=0?t.slice(n+1):t)||void 0}function Jg(e){if(e.bridge_info?.machine_name){const{machine_name:t,directory:n,git_repo_url:r}=e.bridge_info;return{machineName:t,repoName:(r?r.match(/github\.com[/:]([^/]+)\/([^/.]+)/)?.[2]:void 0)??(n?Gg(n):void 0),directory:n??void 0}}const t=e.name.split(":");let n,r;if(t.length>=2&&t[0].trim()){n=t[0].trim();let e=t.slice(1);e.length>=2&&/^[0-9a-f]{4}$/.test(e[e.length-1])&&(e=e.slice(0,-1)),r=e.join(":").trim()||void 0}else n=e.name.replace(/:$/,"").trim();return{machineName:n||e.name,repoName:r}}function Zg(e){switch(e){case"local":case"ssh":case"wsl":return!0;case"bridge":case"anthropic_cloud":case"byoc":case"pool":case"project":return!1}}function Qg(e,t=!1){switch(e){case"local":case"ssh":return Boolean(S?.setMcpServers);case"wsl":return!1;case"bridge":case"anthropic_cloud":case"byoc":case"pool":case"project":return t}}function Xg(e,t=!1){switch(e){case"local":case"ssh":return!0;case"wsl":case"bridge":case"byoc":case"pool":case"project":return!1;case"anthropic_cloud":return t}}function Yg(e){switch(e){case"local":case"ssh":case"wsl":return!0;case"bridge":case"anthropic_cloud":case"byoc":case"pool":case"project":return!1}}function eb(e){switch(e){case"local":case"ssh":case"wsl":return!0;case"bridge":case"anthropic_cloud":case"byoc":case"pool":case"project":return!1}}function tb(e){switch(e){case"anthropic_cloud":case"byoc":case"pool":return!0;case"local":case"ssh":case"wsl":case"bridge":case"project":return!1}}function nb(e,t){if("pool"===t.type)return"pool";if("project"===t.type)return"project";const n=e?.environment_id??t.id;return n===C?"local":Bt(n)?"ssh":zt(n)?"wsl":e&&"bridge"===e.kind?"bridge":"byoc"===e?.kind?"byoc":"anthropic_cloud"}function rb(e,t){const n=t.isAutoModeAvailable??!1;switch(e){case"local":case"ssh":case"wsl":return Vg("local",{auto:n,bypass:t.isBypassAvailable});case"bridge":return Vg("bridge",{auto:n});case"anthropic_cloud":case"byoc":case"pool":case"project":return t.remotePlanModeEnabled?Vg("remote",{auto:n}):["acceptEdits"]}}function sb({config:e,tooltip:n,onClick:r}){return t.jsx(fr,{content:n,side:"right",multiline:!0,children:t.jsx("span",{children:t.jsx(xr.Item,{"aria-disabled":!0,keepOpen:!r,onClick:r,icon:e.icon,description:e.description,checked:!1,checkedRole:"radio",className:"opacity-50",children:e.label})})})}const ib=e.memo(function({value:n,onChange:r,disabled:s=!1,modes:i=Vg("remote"),disabledModes:o,onOpenChange:a,envType:l,sessionType:c,side:d="top",align:u="end",compactTrigger:p=!1,outlined:h=!1,iconOnlyTrigger:f=!1,responsiveTrigger:m=!1,triggerSize:g="sm"}){const b=ur(),[y,v]=e.useState(!1),w=!!l&&function(e){switch(e){case"local":case"ssh":case"wsl":case"bridge":return!0;case"anthropic_cloud":case"byoc":case"pool":case"project":return!1}}(l),x=e.useCallback(e=>{v(e),a?.(e)},[a]),k=e.useCallback(e=>{e!==n&&r(e)},[r,n]),S="sm"===g,E="compact"===wr(),M=Wg({mode:n,intl:b,iconSize:E?14:S&&!f?16:18,envType:l,sessionType:c,compact:p}),_=tt($t,"!text-text-300",f?"!h-8 !w-8 !min-h-0 !min-w-0 !p-0 justify-center !rounded compact:!h-6 compact:!w-6":S?"!px-1.5 !h-7 !min-h-0 compact:!h-6":m?"!px-2 !h-8 !min-h-0 !min-w-0 !rounded max-w-full !justify-start compact:!h-6":"!px-2 !h-9 !min-w-0 !rounded",h&&"border-0.5 border-border-300"),N=S?"text-xs text-text-300":"text-text-300",C=p&&M.triggerLabel||M.label;if(!w){const e=()=>{if(s)return;const e=(i.indexOf(n)+1)%i.length,t=i[e];t&&r(t)};return t.jsx(fr,{content:M.description,side:d,align:u,children:t.jsx(Dt,{variant:"ghost",size:g,type:"button",disabled:s,onClick:e,"aria-label":f?M.label:void 0,prepend:t.jsx("span",{className:tt("text-text-300",!f&&"mr-0.5"),children:M.icon}),className:_,children:!f&&t.jsx("span",{className:N+" truncate",children:C})})})}return t.jsxs(xr.Root,{onOpenChange:x,children:[t.jsx("span",{className:m?"inline-flex min-w-0 max-w-full":"",children:t.jsx(fr,{content:y?void 0:M.description,side:d,align:u,children:t.jsx(xr.Trigger,{disabled:s,render:t.jsx(Dt,{variant:"ghost",size:g,type:"button",disabled:s,"aria-label":f||m?M.label:void 0,prepend:t.jsx("span",{className:tt("text-text-300",!f&&"mr-0.5"),children:M.icon}),append:f?void 0:t.jsx(vr,{name:"CaretDown",customSize:12,className:"text-text-500"}),className:_,children:!f&&t.jsx("span",{className:N+" truncate",children:C})})})})}),t.jsx(xr.Popup,{side:d,align:u,sideOffset:4,className:"min-w-[200px] !max-w-none",children:t.jsxs(xr.Group,{children:[i.map(e=>{const r=Wg({mode:e,intl:b,iconSize:20,envType:l,sessionType:c}),s=o?.[e];return s?t.jsx(sb,{config:r,tooltip:s.tooltip,onClick:s.onClick},e):t.jsx(xr.Item,{icon:r.icon,description:r.description,checked:e===n,checkedRole:"radio",onClick:()=>k(e),children:r.label},e)}),o&&Object.entries(o).map(([e,n])=>{if(!n||i.includes(e))return null;const{tooltip:r,onClick:s}=n,o=Wg({mode:e,intl:b,iconSize:20,envType:l,sessionType:c});return t.jsx(sb,{config:o,tooltip:r,onClick:s},e)})]})})]})});ib.displayName="PermissionModeDropdown";const ob="cowork-unsupervised-sticky";function ab(e){if("undefined"==typeof window)return null;if(!e)return null;try{const t=localStorage.getItem(ob);if(!t)return null;const n=JSON.parse(t);if(("auto"===n.mode||"bypassPermissions"===n.mode)&&n.orgUuid===e&&4===n.keyFormat)return{mode:n.mode,chromeSkipAll:"boolean"==typeof n.chromeSkipAll?n.chromeSkipAll:void 0,orgUuid:n.orgUuid}}catch{}return null}function lb(e){try{const t={...e,keyFormat:4};localStorage.setItem(ob,JSON.stringify(t))}catch{}}function cb(){try{localStorage.removeItem(ob)}catch{}}function db(t,n){const{track:r}=I(),s=Ht(e=>e.showUnsupervisedModeWarning),{activeOrganization:i}=d(),o=i?.uuid;return e.useCallback(e=>{if("auto"===e)return t(e),o&&"scheduled-task"!==n&&lb({mode:e,chromeSkipAll:void 0,orgUuid:o}),void r({event_key:"claudeai.cowork.unsupervised_mode.enabled",mode:e,variant:n,chrome_skip_all:!1});if("bypassPermissions"===e){const i=ab(o);return"bypassPermissions"===i?.mode?(t(e,i.chromeSkipAll),void("scheduled-task"!==n&&lb({mode:e,chromeSkipAll:i.chromeSkipAll,orgUuid:i.orgUuid}))):void s((s,i)=>{s&&(t(e,i),o&&"scheduled-task"!==n&&lb({mode:e,chromeSkipAll:i,orgUuid:o}),r({event_key:"claudeai.cowork.unsupervised_mode.enabled",mode:e,variant:n,chrome_skip_all:i??!1}))})}t(e),"scheduled-task"!==n&&cb(),r({event_key:"claudeai.cowork.unsupervised_mode.disabled",variant:n})},[t,s,r,n,o])}function ub(t){const n=ur(),r=Ft(),s=Ht(e=>e.draftPermissionMode),i=Ht(e=>e.setDraftPermissionMode),o=Ht(e=>e.draftChromeSkipAllPermissionChecks),a=Xe(e=>e.sessionContext?.permissionMode??"default"),l="new-task"===t?s:a,c=function(t,n){return e.useMemo(()=>Vg("cowork",{auto:t?.has("auto")||"auto"===n,bypass:t?.has("bypassPermissions")||"bypassPermissions"===n}),[t,n])}(r,l),p=Xe(e=>e.sessionContext?.setPermissionMode),h=Xe(e=>e.sessionContext?.sessionId),f=u("ccr_auto_permission_mode"),m=u("ccr_mcp_permission_mode_override"),g=e.useCallback((e,t)=>p?.(e,t),[p]),b=e.useCallback((e,t)=>{i(e),Ht.setState({draftChromeSkipAllPermissionChecks:t})},[i]),y=db("new-task"===t?b:g,t),{activeOrganization:v}=d(),w=v?.uuid;e.useEffect(()=>{if(void 0===r||!w)return;const e=ab(w);if(e&&!r.has(e.mode))return cb(),void(s===e.mode&&i("default"));!Ut(s)||r.has(s)?(e?.mode!==s||"bypassPermissions"===e?.mode&&e.chromeSkipAll!==o)&&(e?b(e.mode,"bypassPermissions"===e.mode?e.chromeSkipAll:void 0):Ut(s)&&i("default")):i("default")},[r,s,o,b,i,w]);const x="session"===t&&xe(h),k=e.useMemo(()=>{if(!x||!r)return;const e={};for(const t of r)t!==a&&qt(t,f,m)&&(e[t]={tooltip:"auto"===t?n.formatMessage({defaultMessage:"Auto only runs locally",id:"3AHItFrUka"}):n.formatMessage({defaultMessage:"Skip all approvals only runs locally",id:"16bDb7NXOG"})});return Object.keys(e).length>0?e:void 0},[x,r,a,f,m,n]);return{modes:c,permissionMode:l,setPermissionMode:y,isAvailable:void 0!==r&&r.size>0&&("new-task"===t||Boolean(p)),disabledModes:k}}const pb=e.memo(function({variant:e,placement:n="inline",iconOnly:r=!1,responsive:s=!1,triggerSize:i="default"}){const{modes:o,permissionMode:a,setPermissionMode:l,isAvailable:c,disabledModes:d}=ub(e),u=Vt();if(!c)return null;const p="chin"===n,h=u||p,f=t.jsx(ib,{value:a,onChange:l,modes:o,disabledModes:d,envType:"local",sessionType:"cowork",side:p?"bottom":"top",align:h?"start":"end",triggerSize:i,compactTrigger:h||s,iconOnlyTrigger:r,responsiveTrigger:s,outlined:!h});return s?t.jsx("div",{className:"shrink-[999] min-w-8 -ml-1 overflow-x-clip compact:min-w-6",children:f}):f});pb.displayName="CoworkPermissionModeSelect";const hb=Jn(e=>({filePath:null,setFilePath:t=>e({filePath:t})})),fb=e.memo(({options:n,onSelect:s,onClose:i,position:o,selectedIndex:a})=>{const l=e.useRef(null),c=kr(50),[d,u]=e.useState(null),p=d??a,h=e.useMemo(()=>n.some(e=>e.description)?576:240,[n]),f=e.useMemo(()=>{if("undefined"==typeof window)return o.left;const e=o.left+h+16-window.innerWidth;return e<=0?o.left:Math.max(16,o.left-e)},[o.left,h]),m=e.useMemo(()=>{const e=o.top-24-16,t="undefined"==typeof window?0:window.innerHeight-o.top-24-16;return e>=t?{top:o.top-24+"px",maxHeight:`${Math.min(384,e)}px`,transform:"translateY(-100%)"}:{top:`${o.top+24}px`,maxHeight:`${Math.min(384,t)}px`}},[o.top]);return e.useEffect(()=>{if(l.current&&p>=0){const e=l.current.children[p];e?.scrollIntoView({block:"nearest"})}},[p]),e.useEffect(()=>{const e=e=>{l.current&&!l.current.contains(e.target)&&i()};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[i]),0===n.length?null:r.createPortal(t.jsx("div",{ref:l,"data-testid":"mention-dropdown",className:"fixed overflow-y-auto rounded-2xl border-0.5 border-border-200 bg-bg-000 shadow-lg p-2",style:{zIndex:c,...m,left:`${f}px`,width:`${h}px`},children:t.jsx(Sr,{children:n.map((e,n)=>t.jsxs("button",{type:"button",className:Wt("w-full flex items-center gap-2 overflow-clip","pl-2 pr-1.5 py-1.5 rounded-lg","font-base text-text-300 text-left","cursor-pointer select-none","hover:bg-bg-200 focus:bg-bg-200 focus:outline-none",p===n&&"bg-bg-200"),onClick:()=>s(e.id),onMouseEnter:()=>u(n),onMouseLeave:()=>u(null),children:[e.icon&&t.jsx("span",{className:"flex-shrink-0 w-5 h-5 flex items-center justify-center",children:"string"==typeof e.icon?t.jsx("img",{src:e.icon,alt:"",className:"w-4 h-4"}):e.icon}),t.jsx(Kt,{tooltipContent:e.renderedText??e.label,side:"right",sideOffset:8,children:t.jsxs("span",{className:"flex-1 min-w-0 flex items-baseline gap-2 text-left",children:[t.jsx("span",{className:Wt("truncate",e.description&&"flex-shrink-0 max-w-full font-medium text-text-100"),children:e.label}),e.description&&t.jsx("span",{className:"truncate text-text-500 text-xs",children:e.description})]})})]},e.id))})}),document.body)});var mb,gb;function bb(){return gb||(gb=1,mb=function e(t,n){if(t===n)return!0;if(t&&n&&"object"==typeof t&&"object"==typeof n){if(t.constructor!==n.constructor)return!1;var r,s,i;if(Array.isArray(t)){if((r=t.length)!=n.length)return!1;for(s=r;0!==s--;)if(!e(t[s],n[s]))return!1;return!0}if(t instanceof Map&&n instanceof Map){if(t.size!==n.size)return!1;for(s of t.entries())if(!n.has(s[0]))return!1;for(s of t.entries())if(!e(s[1],n.get(s[0])))return!1;return!0}if(t instanceof Set&&n instanceof Set){if(t.size!==n.size)return!1;for(s of t.entries())if(!n.has(s[0]))return!1;return!0}if(ArrayBuffer.isView(t)&&ArrayBuffer.isView(n)){if((r=t.length)!=n.length)return!1;for(s=r;0!==s--;)if(t[s]!==n[s])return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if((r=(i=Object.keys(t)).length)!==Object.keys(n).length)return!1;for(s=r;0!==s--;)if(!Object.prototype.hasOwnProperty.call(n,i[s]))return!1;for(s=r;0!==s--;){var o=i[s];if(("_owner"!==o||!t.$$typeof)&&!e(t[o],n[o]))return!1}return!0}return t!=t&&n!=n}),mb}fb.displayName="MentionDropdown";const yb=s(bb());var vb=(...e)=>t=>{e.forEach(e=>{"function"==typeof e?e(t):e&&(e.current=t)})},wb=({contentComponent:e})=>{const n=o.useSyncExternalStore(e.subscribe,e.getSnapshot,e.getServerSnapshot);return t.jsx(t.Fragment,{children:Object.values(n)})};var xb=class extends i.Component{constructor(e){var t;super(e),this.editorContentRef=i.createRef(),this.initialized=!1,this.state={hasContentComponentInitialized:Boolean(null==(t=e.editor)?void 0:t.contentComponent)}}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){const e=this.props.editor;if(e&&!e.isDestroyed&&e.options.element){if(e.contentComponent)return;const t=this.editorContentRef.current;t.append(e.view.dom),e.setOptions({element:t}),e.contentComponent=function(){const e=new Set;let t={};return{subscribe:t=>(e.add(t),()=>{e.delete(t)}),getSnapshot:()=>t,getServerSnapshot:()=>t,setRenderer(n,r){t={...t,[n]:l.createPortal(r.reactElement,r.element,n)},e.forEach(e=>e())},removeRenderer(n){const r={...t};delete r[n],t=r,e.forEach(e=>e())}}}(),this.state.hasContentComponentInitialized||(this.unsubscribeToContentComponent=e.contentComponent.subscribe(()=>{this.setState(e=>e.hasContentComponentInitialized?e:{hasContentComponentInitialized:!0}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent()})),e.createNodeViews(),this.initialized=!0}}componentWillUnmount(){var e;const t=this.props.editor;if(t){this.initialized=!1,t.isDestroyed||t.view.setProps({nodeViews:{}}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent(),t.contentComponent=null;try{if(!(null==(e=t.view.dom)?void 0:e.firstChild))return;const n=document.createElement("div");n.append(t.view.dom),t.setOptions({element:n})}catch{}}}render(){const{editor:e,innerRef:n,...r}=this.props;return t.jsxs(t.Fragment,{children:[t.jsx("div",{ref:vb(n,this.editorContentRef),...r}),(null==e?void 0:e.contentComponent)&&t.jsx(wb,{contentComponent:e.contentComponent})]})}},kb=e.forwardRef((e,t)=>{const n=i.useMemo(()=>Math.floor(4294967295*Math.random()).toString(),[e.editor]);return i.createElement(xb,{key:n,innerRef:t,...e})}),Sb=i.memo(kb),Eb="undefined"!=typeof window?e.useLayoutEffect:e.useEffect,Mb=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){const e=()=>{this.transactionNumber+=1,this.subscribers.forEach(e=>e())},t=this.editor;return t.on("transaction",e),()=>{t.off("transaction",e)}}}};function _b(t){var n;const[r]=e.useState(()=>new Mb(t.editor)),s=a.useSyncExternalStoreWithSelector(r.subscribe,r.getSnapshot,r.getServerSnapshot,t.selector,null!=(n=t.equalityFn)?n:yb);return Eb(()=>r.watch(t.editor),[t.editor,r]),e.useDebugValue(s),s}var Nb="undefined"==typeof window,Cb=Nb||Boolean("undefined"!=typeof window&&window.next),Ob=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(){return void 0===this.options.current.immediatelyRender?Nb||Cb?null:this.createEditor():(this.options.current.immediatelyRender,this.options.current.immediatelyRender?this.createEditor():null)}createEditor(){const e={...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)}};return new Ng(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)return void(this.previousDeps=e);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(){const e=this.instanceId,t=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{this.isComponentMounted&&this.instanceId===e?t&&t.setOptions(this.options.current):t&&!t.isDestroyed&&(t.destroy(),this.instanceId===e&&this.setEditor(null))},1)}};var Ab=e.createContext({editor:null});Ab.Consumer;var Tb=()=>e.useContext(Ab),Ib=e.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),Db=()=>e.useContext(Ib);function Rb({as:e="div",...n}){const{nodeViewContentRef:r,nodeViewContentChildren:s}=Db();return t.jsx(e,{...n,ref:r,"data-node-view-content":"",style:{whiteSpace:"pre-wrap",...n.style},children:s})}var Lb=i.forwardRef((e,n)=>{const{onDragStart:r}=Db(),s=e.as||"div";return t.jsx(s,{...e,ref:n,"data-node-view-wrapper":"",onDragStart:r,style:{whiteSpace:"normal",...e.style}})});function Pb(e){return!("function"!=typeof e||!e.prototype||!e.prototype.isReactComponent)}function jb(e){return!("object"!=typeof e||!e.$$typeof||"Symbol(react.forward_ref)"!==e.$$typeof.toString()&&"react.forward_ref"!==e.$$typeof.description)}var Bb=class{constructor(e,{editor:t,props:n={},as:s="div",className:i=""}){this.ref=null,this.id=Math.floor(4294967295*Math.random()).toString(),this.component=e,this.editor=t,this.props=n,this.element=document.createElement(s),this.element.classList.add("react-renderer"),i&&this.element.classList.add(...i.split(" ")),this.editor.isInitialized?r.flushSync(()=>{this.render()}):queueMicrotask(()=>{this.render()})}render(){var n;const r=this.component,s=this.props,i=this.editor,o=function(){try{if(e.version)return parseInt(e.version.split(".")[0],10)>=19}catch{}return!1}(),a=function(e){if(Pb(e))return!0;if(jb(e))return!0;if(function(e){return!("object"!=typeof e||!e.$$typeof||"Symbol(react.memo)"!==e.$$typeof.toString()&&"react.memo"!==e.$$typeof.description)}(e)){const t=e.type;if(t)return Pb(t)||jb(t)}return!1}(r),l={...s};!l.ref||o||a||delete l.ref,l.ref||!o&&!a||(l.ref=e=>{this.ref=e}),this.reactElement=t.jsx(r,{...l}),null==(n=null==i?void 0:i.contentComponent)||n.setRenderer(this.id,this)}updateProps(e={}){this.props={...this.props,...e},this.render()}destroy(){var e;const 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])})}};i.createContext({markViewContentRef:()=>{}});var zb=class extends Ig{constructor(e,t,n){if(super(e,t,n),!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)}}mount(){const n={editor:this.editor,node:this.node,decorations:this.decorations,innerDecorations:this.innerDecorations,view:this.view,selected:!1,extension:this.extension,HTMLAttributes:this.HTMLAttributes,getPos:()=>this.getPos(),updateAttributes:(e={})=>this.updateAttributes(e),deleteNode:()=>this.deleteNode(),ref:e.createRef()};if(!this.component.displayName){const e=e=>e.charAt(0).toUpperCase()+e.substring(1);this.component.displayName=e(this.extension.name)}const r={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))}},s=this.component,i=e.memo(n=>t.jsx(Ib.Provider,{value:r,children:e.createElement(s,n)}));i.displayName="ReactNodeView";let o=this.node.isInline?"span":"div";this.options.as&&(o=this.options.as);const{className:a=""}=this.options;this.handleSelectionUpdate=this.handleSelectionUpdate.bind(this),this.renderer=new Bb(i,{editor:this.editor,props:n,as:o,className:`node-${this.node.type.name} ${a}`.trim()}),this.editor.on("selectionUpdate",this.handleSelectionUpdate),this.updateElementAttributes()}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(){const{from:e,to:t}=this.editor.state.selection,n=this.getPos();if("number"==typeof n)if(e<=n&&t>=n+this.node.nodeSize){if(this.renderer.props.selected)return;this.selectNode()}else{if(!this.renderer.props.selected)return;this.deselectNode()}}update(e,t,n){const 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){const s=this.node,i=this.decorations,o=this.innerDecorations;return this.node=e,this.decorations=t,this.innerDecorations=n,this.options.update({oldNode:s,oldDecorations:i,newNode:e,newDecorations:t,oldInnerDecorations:o,innerDecorations:n,updateProps:()=>r({node:e,decorations:t,innerDecorations:n})})}return e===this.node&&this.decorations===t&&this.innerDecorations===n||(this.node=e,this.decorations=t,this.innerDecorations=n,r({node:e,decorations:t,innerDecorations:n})),!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.contentDOMElement=null}updateElementAttributes(){if(this.options.attrs){let e={};if("function"==typeof this.options.attrs){const t=this.editor.extensionManager.attributes,n=hf(this.node,t);e=this.options.attrs({node:this.node,HTMLAttributes:n})}else e=this.options.attrs;this.renderer.updateAttributes(e)}}};function $b(e,t){return n=>n.editor.contentComponent?new zb(e,n,t):{}}const Fb=new bc("mention"),Hb=Object.freeze({active:!1,query:"",position:null,options:[],selectedIndex:0,isLoading:!1});function Ub(e){e.dispatch(e.state.tr.setMeta(Fb,Hb))}function qb(e){return!!e?.active&&e.options.length>0}const Vb=rm.create({name:"mentionExtension",addOptions:()=>({getProviders:()=>[],onStateChange:()=>{},onSelect:()=>{}}),addStorage:()=>({disabled:!1}),addProseMirrorPlugins(){return[new fc({key:Fb,state:{init:()=>Hb,apply:(e,t,n,r)=>{const s=e.getMeta(Fb);if(s){const e={...t,...s};return this.options.onStateChange(e),e}return t}},view:()=>{let e=null,t=0;return{update:(n,r)=>{const{state:s}=n,{selection:i}=s,{$from:o}=i,a=o.parent.textBetween(Math.max(0,o.parentOffset-50),o.parentOffset,void 0,e=>"hardBreak"===e.type.name?"\n":"\ufffc"),l=this.storage.disabled?null:a.match(/(?:^|\s)@(\S*)$/);if(!l){e=null,t++;const r=Fb.getState(s);return void((r?.active||r?.isLoading)&&Ub(n))}const c=l[1]||"",d=Fb.getState(s),u=Fb.getState(r);if(u?.active&&!d?.active)return e=u.query,void t++;if(null!==e){if(""===e&&""===c)return;if(""!==e&&c.startsWith(e))return;e=null}if((d?.active||d?.isLoading)&&d.query===c)return;const p=n.coordsAtPos(o.pos-c.length-1),h=p.bottom+4,f=p.left,m=d?.position,g=m&&m.top===h&&m.left===f?m:{top:h,left:f},b=++t,y=this.options.getProviders().map(e=>e.fetchOptions(c)),v=e=>{n.dispatch(n.state.tr.setMeta(Fb,{active:!0,query:c,position:g,options:e,isLoading:!1,selectedIndex:d?.active&&d.query===c?d.selectedIndex:0}))};y.some(e=>!!e&&"function"==typeof e.then)?(n.dispatch(s.tr.setMeta(Fb,{query:c,position:g,isLoading:!0})),Promise.all(y).then(e=>{b===t&&v(e.flat())})):v(y.flat())},destroy:()=>{t++}}}})]},addKeyboardShortcuts(){return{ArrowDown:()=>{const e=Fb.getState(this.editor.state);if(!qb(e))return!1;const t=Math.min(e.selectedIndex+1,e.options.length-1);return this.editor.view.dispatch(this.editor.state.tr.setMeta(Fb,{selectedIndex:t})),!0},ArrowUp:()=>{const e=Fb.getState(this.editor.state);if(!qb(e))return!1;const t=Math.max(e.selectedIndex-1,0);return this.editor.view.dispatch(this.editor.state.tr.setMeta(Fb,{selectedIndex:t})),!0},Enter:()=>{const e=Fb.getState(this.editor.state);if(!qb(e))return!1;const t=e.options[e.selectedIndex];return t&&this.options.onSelect(t.id),!0},Escape:()=>!!qb(Fb.getState(this.editor.state))&&(Ub(this.editor.view),!0)}}});function Kb({trigger:e,items:n,children:r,onOpenChange:s,modal:i,className:o}){const a=e??r,l=e?r:n;return t.jsxs(Rr,{onOpenChange:s,modal:i,children:[t.jsx(Lr,{asChild:!0,children:a}),t.jsx(Pr,{children:t.jsx(Er,{children:t.jsx(Wb,{className:o,children:l})})})]})}const Wb=e.forwardRef(({className:e,style:n,...r},s)=>{const i=Gt();return t.jsx(jr,{ref:s,className:Jt("p-1.5",Zt,"max-h-[min(var(--radix-context-menu-content-available-height),var(--dropdown-max-height,24rem))] overflow-y-auto overflow-x-hidden",e),style:void 0!==i?{zIndex:i,...n}:n,...r})});Wb.displayName="ContextMenuContent";e.forwardRef(({className:e,...n},r)=>t.jsx(zr,{ref:r,className:Jt(en,e),...n})).displayName="ContextMenuLabel";const Gb=e.forwardRef(({className:e,disabled:n,danger:r,onSelect:s,onClick:i,...o},a)=>t.jsx(Br,{ref:a,"aria-disabled":n||void 0,"data-disabled":n?"":void 0,onSelect:n?e=>e.preventDefault():s,onClick:n?e=>{e.preventDefault(),e.stopPropagation()}:i,className:Jt(Qt,n&&Xt,r&&Yt,e),...o}));Gb.displayName="BaseContextMenuItem";const Jb=e.forwardRef(({children:e,icon:n,trailing:r,...s},i)=>n||r?t.jsx(Gb,{ref:i,...s,children:t.jsxs("div",{className:"flex items-center gap-2 w-full font-base group",children:[n,t.jsx("span",{className:"flex-1 truncate",children:e}),r&&t.jsx("div",{className:"flex items-center flex-shrink-0 -mr-2",children:r})]})}):t.jsx(Gb,{ref:i,...s,children:e}));function Zb(e,n){return t.jsxs(t.Fragment,{children:[e?t.jsxs("div",{className:"flex items-center gap-2 w-full font-base group",children:[e,t.jsx("span",{className:"flex-1 truncate",children:n})]}):n,t.jsx("span",{className:"flex h-4 w-4 items-center justify-center",children:t.jsx(qr,{children:t.jsx(sn,{size:16,"aria-hidden":"true"})})})]})}Jb.displayName="ContextMenuItem";e.forwardRef(({className:e,disabled:n,danger:r,icon:s,children:i,...o},a)=>t.jsx($r,{ref:a,disabled:n,className:Jt(Qt,n&&Xt,r&&Yt,e),...o,children:Zb(s,i)})).displayName="ContextMenuRadioItem";e.forwardRef(({className:e,...n},r)=>t.jsx(Fr,{ref:r,className:Jt(tn,e),...n})).displayName="ContextMenuSubTrigger";e.forwardRef(({className:e,style:n,...r},s)=>{const i=Gt();return t.jsx(Hr,{ref:s,className:Jt("p-1.5",Zt,nn,e),style:void 0!==i?{zIndex:i,...n}:n,...r})}).displayName="ContextMenuSubContent";const Qb=e.forwardRef(({className:e,...n},r)=>t.jsx(Ur,{ref:r,className:Jt(rn,e),...n}));Qb.displayName="ContextMenuSeparator";const Xb=e.forwardRef((e,n)=>t.jsx("span",{ref:n,...e}));Xb.displayName="MentionChipBody";const Yb=e=>{0!==e.button&&e.stopPropagation()},ey=e=>e.stopPropagation(),ty=["svg","g","path","circle","rect","line","polyline","polygon","ellipse","div","span","p","img"],ny=["alt","clip-rule","cx","cy","d","decoding","fill","fill-rule","focusable","height","loading","opacity","points","r","rx","ry","sizes","src","srcset","stroke","stroke-dasharray","stroke-linecap","stroke-linejoin","stroke-width","transform","viewBox","width","x","x1","x2","xmlns","y","y1","y2"],ry=e.memo(({node:n,selected:r,deleteNode:s,editor:i})=>{const[o,a]=e.useState(!1),l=n.attrs,c=l.label||"",d=l.renderedText||c,u=e.useMemo(()=>{return l.icon&&!l.icon.startsWith("data:image")?(e=l.icon,on.sanitize(e,{ALLOWED_TAGS:ty,ALLOWED_ATTR:ny,ALLOW_DATA_ATTR:!1,ALLOW_ARIA_ATTR:!1})):null;var e},[l.icon]);return t.jsx(Lb,{as:"span",className:Wt("inline-flex relative cursor-pointer group mx-0.5",r?"text-accent-000":"text-accent-100"),contentEditable:!1,"data-drag-handle":!0,onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),onMouseDown:Yb,onContextMenu:ey,children:t.jsx(Kb,{trigger:t.jsxs(Xb,{className:"inline-flex relative",children:[t.jsx("span",{className:Wt("absolute -inset-y-0.5 -left-0.5 -right-1 rounded-md pointer-events-none",r&&"bg-accent-900",o&&!r&&"bg-accent-900/50")}),t.jsxs("span",{className:Wt("relative",l.icon&&"pl-5"),children:[l.icon&&t.jsx("span",{className:"absolute top-1/2 -translate-y-1/2 left-0 w-5 h-5 flex items-center justify-center",children:l.icon.startsWith("data:image")?t.jsx("img",{src:l.icon,alt:"",className:"h-4 w-4",title:c}):t.jsx("span",{"aria-hidden":!0,className:"h-4 w-4 overflow-hidden flex items-center justify-center text-xs leading-none [&_div]:contents [&_svg]:w-4 [&_svg]:h-4 [&_img]:max-w-4 [&_img]:max-h-4 [&_img]:object-contain [&_p]:m-0",dangerouslySetInnerHTML:{__html:u??""},title:c})}),t.jsx("span",{className:"relative [&::selection]:bg-transparent",title:d,children:c})]})]}),children:t.jsx(Jb,{danger:!0,onSelect:()=>{s(),i.commands.focus()},children:t.jsx(pr,{defaultMessage:"Delete",id:"K3r6DQW7h+"})})})})});ry.displayName="MentionChip";const sy=Tg.create({name:"mention",group:"inline",inline:!0,atom:!0,addAttributes:()=>({id:{default:null,parseHTML:e=>e.getAttribute("data-id"),renderHTML:e=>({"data-id":e.id})},label:{default:null,parseHTML:e=>e.getAttribute("data-label"),renderHTML:e=>({"data-label":e.label})},icon:{default:null,parseHTML:e=>e.getAttribute("data-icon"),renderHTML:e=>({"data-icon":e.icon})},providerId:{default:null,parseHTML:e=>e.getAttribute("data-provider-id"),renderHTML:e=>({"data-provider-id":e.providerId})},renderedText:{default:null,parseHTML:e=>e.getAttribute("data-rendered-text"),renderHTML:e=>({"data-rendered-text":e.renderedText})}}),parseHTML:()=>[{tag:"span[data-type=\u201cat-mention\u201d]"}],renderHTML:({HTMLAttributes:e})=>["span",pf(e,{"data-type":"at-mention"}),`@${e["data-label"]||""}`],renderText:({node:e})=>`@${e.attrs.renderedText||e.attrs.label||""}`,addNodeView:()=>$b(ry)});function iy(e){return e.active&&e.options.length>0&&null!==e.position}function oy({mentionProviders:t,onMentionAttachments:n,onMentionDeleted:s}){const i=I(),o=e.useRef(null),[a,l]=e.useState(Hb),c=e.useRef(!1),d=cn(e=>{const t=iy(e);t&&!c.current&&i.track({event_key:"claudeai.mentions.dropdown.opened"}),c.current=t,l(e)}),u=e.useCallback(()=>{d(Hb);const e=o.current;e&&!e.isDestroyed&&Fb.getState(e.state)?.active&&Ub(e.view)},[d]),p=e.useCallback(()=>c.current,[]),{handleMentionSelect:h}=function({editor:t,mentionProviders:n,mentionOptions:s,onMentionAttachments:i,onMentionDeleted:o,onDropdownClose:a}){const l=I(),c=an(e=>e.incrementLoading),d=an(e=>e.decrementLoading),u=e.useRef(null),p=e.useRef(new Map);return e.useEffect(()=>{t&&(u.current=async e=>{a();const o=s.find(t=>t.id===e);if(!o||!t)return;const u=n.find(e=>e.id===o.providerId);if(!u)return;const{state:h,view:f}=t,{$from:m}=h.selection,g=m.parent.textBetween(Math.max(0,m.parentOffset-50),m.parentOffset,void 0,e=>"hardBreak"===e.type.name?"\n":"\ufffc").match(/(?:^|\s)@(\S*)$/);if(!g)return;const b=m.pos-g[0].length+(/^\s/.test(g[0])?1:0),y=h.tr;y.delete(b,m.pos);const v=h.schema.nodes.mention?.create({id:e,label:o.label,icon:u.getIconHtml(e),providerId:o.providerId,renderedText:o.renderedText});v&&(y.insert(b,v),y.insertText(" ",b+1)),f.dispatch(y),p.current.set(e,o.providerId),r.flushSync(()=>{c()});try{const n=await u.onSelect(e);if(t.isDestroyed)return;let r=!1;if(t.state.doc.descendants(t=>("mention"===t.type.name&&t.attrs.id===e&&(r=!0),!r)),!r)return void p.current.delete(e);if(!n)return t.view.dispatch(t.state.tr.delete(b,b+2)),p.current.delete(e),void t.commands.focus();if(n.additionalText){const e=t.state.tr;e.insertText(n.additionalText,t.state.doc.content.size),t.view.dispatch(e)}l.track({event_key:"claudeai.mentions.option.selected",attachment_count:n.attachments?.length??0}),i&&n.attachments&&await i(e,n.attachments),t.isDestroyed||t.commands.focus()}catch(w){ln(w,{tags:{source:"useMentionHandlers.handleMentionSelect"}}),t.isDestroyed||t.commands.focus()}finally{r.flushSync(()=>{d()})}})},[t,n,s,i,a,l,c,d]),e.useEffect(()=>{if(!t||!o)return;const e=({transaction:e})=>{const{before:t}=e;e.steps.forEach(e=>{const n=e;if(void 0!==n.from&&void 0!==n.to){const e=n.from,r=n.to;e<r&&t.nodesBetween(e,r,e=>{if("mention"===e.type.name&&e.attrs.id){const t=e.attrs.id,n=p.current.get(t);n&&(o(t,n),p.current.delete(t))}})}})};return t.on("update",e),()=>{t.off("update",e)}},[t,o]),{handleMentionSelect:e.useCallback(async e=>{u.current&&await u.current(e)},[])}}({editor:o.current,mentionProviders:t,mentionOptions:a.options,onMentionAttachments:n,onMentionDeleted:s,onDropdownClose:u}),f=e.useCallback(e=>{o.current=e},[]);return{mentionState:a,handleStateChange:d,handleDropdownClose:u,handleMentionSelect:h,isDropdownVisible:p,setEditor:f}}const ay=/(https?:\/\/[^\s<>"'`]+|\bwww\.[^\s<>"'`]+)/gi;function ly(e){try{return new URL(e),!0}catch{return!1}}function cy(e){let t=e.length;for(;t>0;t--){const n=e[t-1];if(".,;:!?".includes(n))continue;if(")"!==n)break;const r=e.slice(0,t),s=r.split("(").length-1;if(r.split(")").length-1<=s)break}return[e.slice(0,t),e.slice(t)]}const dy=e.memo(({children:n,linkClassName:r})=>"string"!=typeof n?t.jsx(t.Fragment,{children:n}):t.jsx(t.Fragment,{children:n.split(ay).map((n,s)=>{if(s%2==0)return n;const[i,o]=cy(n),a=/^www\./i.test(i)?`https://${i}`:i;return ly(a)?t.jsxs(e.Fragment,{children:[t.jsx(ct,{href:a,target:"_blank",rel:"noopener noreferrer",className:r,children:i}),o]},s):n})}));dy.displayName="LinkifiedText";var uy,py,hy=/(^|[^`])`([^`]+)`(?!`)$/,fy=/(^|[^`])`([^`]+)`(?!`)/g,my=Qf.create({name:"code",addOptions:()=>({HTMLAttributes:{}}),excludes:"_",code:!0,exitable:!0,parseHTML:()=>[{tag:"code"}],renderHTML({HTMLAttributes:e}){return["code",pf(this.options.HTMLAttributes,e),0]},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[Cg({find:hy,type:this.type})]},addPasteRules(){return[Dg({find:fy,type:this.type})]}}),gy=my,by=/^```([a-z]+)?[\s\n]$/,yy=/^~~~([a-z]+)?[\s\n]$/,vy=Tg.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;const{languageClassPrefix:n}=this.options;if(!n)return null;const 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",pf(this.options.HTMLAttributes,t),["code",{class:e.attrs.language?this.options.languageClassPrefix+e.attrs.language:null},0]]},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:()=>{const{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;const n=null!=(t=this.options.tabSize)?t:4,{state:r}=e,{selection:s}=r,{$from:i,empty:o}=s;if(i.parent.type!==this.type)return!1;const a=" ".repeat(n);return o?e.commands.insertContent(a):e.commands.command(({tr:e})=>{const{from:t,to:n}=s,i=r.doc.textBetween(t,n,"\n","\n").split("\n").map(e=>a+e).join("\n");return e.replaceWith(t,n,r.schema.text(i)),!0})},"Shift-Tab":({editor:e})=>{var t;if(!this.options.enableTabIndentation)return!1;const n=null!=(t=this.options.tabSize)?t:4,{state:r}=e,{selection:s}=r,{$from:i,empty:o}=s;return i.parent.type===this.type&&(o?e.commands.command(({tr:e})=>{var t;const{pos:s}=i,o=i.start(),a=i.end(),l=r.doc.textBetween(o,a,"\n","\n").split("\n");let c=0,d=0;const u=s-o;for(let n=0;n<l.length;n+=1){if(d+l[n].length>=u){c=n;break}d+=l[n].length+1}const p=(null==(t=l[c].match(/^ */))?void 0:t[0])||"",h=Math.min(p.length,n);if(0===h)return!0;let f=o;for(let n=0;n<c;n+=1)f+=l[n].length+1;e.delete(f,f+h);return s-f<=h&&e.setSelection(Yl.create(e.doc,f)),!0}):e.commands.command(({tr:e})=>{const{from:t,to:i}=s,o=r.doc.textBetween(t,i,"\n","\n").split("\n").map(e=>{var t;const r=(null==(t=e.match(/^ */))?void 0:t[0])||"",s=Math.min(r.length,n);return e.slice(s)}).join("\n");return e.replaceWith(t,i,r.schema.text(o)),!0}))},Enter:({editor:e})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:t}=e,{selection:n}=t,{$from:r,empty:s}=n;if(!s||r.parent.type!==this.type)return!1;const i=r.parentOffset===r.parent.nodeSize-2,o=r.parent.textContent.endsWith("\n\n");return!(!i||!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;const{state:t}=e,{selection:n,doc:r}=t,{$from:s,empty:i}=n;if(!i||s.parent.type!==this.type)return!1;if(!(s.parentOffset===s.parent.nodeSize-2))return!1;const o=s.after();if(void 0===o)return!1;return r.nodeAt(o)?e.commands.command(({tr:e})=>(e.setSelection(Jl.near(r.resolve(o))),!0)):e.commands.exitCode()}}},addInputRules(){return[Og({find:by,type:this.type,getAttributes:e=>({language:e[1]})}),Og({find:yy,type:this.type,getAttributes:e=>({language:e[1]})})]},addProseMirrorPlugins(){return[new fc({key:new bc("codeBlockVSCodeHandler"),props:{handlePaste:(e,t)=>{if(!t.clipboardData)return!1;if(this.editor.isActive(this.type.name))return!1;const n=t.clipboardData.getData("text/plain"),r=t.clipboardData.getData("vscode-editor-data"),s=r?JSON.parse(r):void 0,i=null==s?void 0:s.mode;if(!n||!i)return!1;const{tr:o,schema:a}=e.state,l=a.text(n.replace(/\r\n?/g,"\n"));return o.replaceSelectionWith(this.type.create({language:i},l)),o.selection.$from.parent.type!==this.type&&o.setSelection(Yl.near(o.doc.resolve(Math.max(0,o.selection.from-2)))),o.setMeta("paste",!0),e.dispatch(o),!0}}})]}}),wy=vy;function xy(){if(py)return uy;function e(t){return t instanceof Map?t.clear=t.delete=t.set=function(){throw new Error("map is read-only")}:t instanceof Set&&(t.add=t.clear=t.delete=function(){throw new Error("set is read-only")}),Object.freeze(t),Object.getOwnPropertyNames(t).forEach(n=>{const r=t[n],s=typeof r;"object"!==s&&"function"!==s||Object.isFrozen(r)||e(r)}),t}py=1;class t{constructor(e){void 0===e.data&&(e.data={}),this.data=e.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}}function n(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;")}function r(e,...t){const n=Object.create(null);for(const r in e)n[r]=e[r];return t.forEach(function(e){for(const t in e)n[t]=e[t]}),n}const s=e=>!!e.scope;class i{constructor(e,t){this.buffer="",this.classPrefix=t.classPrefix,e.walk(this)}addText(e){this.buffer+=n(e)}openNode(e){if(!s(e))return;const t=((e,{prefix:t})=>{if(e.startsWith("language:"))return e.replace("language:","language-");if(e.includes(".")){const 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){s(e)&&(this.buffer+="</span>")}value(){return this.buffer}span(e){this.buffer+=`<span class="${e}">`}}const o=(e={})=>{const t={children:[]};return Object.assign(t,e),t};class a{constructor(){this.rootNode=o(),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){const t=o({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=>{a._collapse(e)}))}}class l extends a{constructor(e){super(),this.options=e}addText(e){""!==e&&this.add(e)}startScope(e){this.openNode(e)}endScope(){this.closeNode()}__addSublanguage(e,t){const n=e.root;t&&(n.scope=`language:${t}`),this.add(n)}toHTML(){return new i(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}}function c(e){return e?"string"==typeof e?e:e.source:null}function d(e){return h("(?=",e,")")}function u(e){return h("(?:",e,")*")}function p(e){return h("(?:",e,")?")}function h(...e){return e.map(e=>c(e)).join("")}function f(...e){const t=function(e){const t=e[e.length-1];return"object"==typeof t&&t.constructor===Object?(e.splice(e.length-1,1),t):{}}(e);return"("+(t.capture?"":"?:")+e.map(e=>c(e)).join("|")+")"}function m(e){return new RegExp(e.toString()+"|").exec("").length-1}const g=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function b(e,{joinWith:t}){let n=0;return e.map(e=>{n+=1;const t=n;let r=c(e),s="";for(;r.length>0;){const e=g.exec(r);if(!e){s+=r;break}s+=r.substring(0,e.index),r=r.substring(e.index+e[0].length),"\\"===e[0][0]&&e[1]?s+="\\"+String(Number(e[1])+t):(s+=e[0],"("===e[0]&&n++)}return s}).map(e=>`(${e})`).join(t)}const y="[a-zA-Z]\\w*",v="[a-zA-Z_]\\w*",w="\\b\\d+(\\.\\d+)?",x="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",k="\\b(0b[01]+)",S={begin:"\\\\[\\s\\S]",relevance:0},E={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[S]},M={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[S]},_=function(e,t,n={}){const s=r({scope:"comment",begin:e,end:t,contains:[]},n);s.contains.push({scope:"doctag",begin:"[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)",end:/(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/,excludeBegin:!0,relevance:0});const i=f("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 s.contains.push({begin:h(/[ ]+/,"(",i,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),s},N=_("//","$"),C=_("/\\*","\\*/"),O=_("#","$"),A={scope:"number",begin:w,relevance:0},T={scope:"number",begin:x,relevance:0},I={scope:"number",begin:k,relevance:0},D={begin:/(?=\/[^/\n]*\/)/,contains:[{scope:"regexp",begin:/\//,end:/\/[gimuy]*/,illegal:/\n/,contains:[S,{begin:/\[/,end:/\]/,relevance:0,contains:[S]}]}]},R={scope:"title",begin:y,relevance:0},L={scope:"title",begin:v,relevance:0},P={begin:"\\.\\s*"+v,relevance:0};var j=Object.freeze({__proto__:null,MATCH_NOTHING_RE:/\b\B/,IDENT_RE:y,UNDERSCORE_IDENT_RE:v,NUMBER_RE:w,C_NUMBER_RE:x,BINARY_NUMBER_RE:k,RE_STARTERS_RE:"!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",SHEBANG:(e={})=>{const t=/^#![ ]*\//;return e.binary&&(e.begin=h(t,/.*\b/,e.binary,/\b.*/)),r({scope:"meta",begin:t,end:/$/,relevance:0,"on:begin":(e,t)=>{0!==e.index&&t.ignoreMatch()}},e)},BACKSLASH_ESCAPE:S,APOS_STRING_MODE:E,QUOTE_STRING_MODE:M,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/},COMMENT:_,C_LINE_COMMENT_MODE:N,C_BLOCK_COMMENT_MODE:C,HASH_COMMENT_MODE:O,NUMBER_MODE:A,C_NUMBER_MODE:T,BINARY_NUMBER_MODE:I,REGEXP_MODE:D,TITLE_MODE:R,UNDERSCORE_TITLE_MODE:L,METHOD_GUARD:P,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()}})}});function B(e,t){"."===e.input[e.index-1]&&t.ignoreMatch()}function z(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=B,e.keywords=e.keywords||e.beginKeywords,delete e.beginKeywords,void 0===e.relevance&&(e.relevance=0))}function F(e,t){Array.isArray(e.illegal)&&(e.illegal=f(...e.illegal))}function H(e,t){if(e.match){if(e.begin||e.end)throw new Error("begin & end are not supported with match");e.begin=e.match,delete e.match}}function U(e,t){void 0===e.relevance&&(e.relevance=1)}const q=(e,t)=>{if(!e.beforeMatch)return;if(e.starts)throw new Error("beforeMatch cannot be used with starts");const n=Object.assign({},e);Object.keys(e).forEach(t=>{delete e[t]}),e.keywords=n.keywords,e.begin=h(n.beforeMatch,d(n.begin)),e.starts={relevance:0,contains:[Object.assign(n,{endsParent:!0})]},e.relevance=0,delete n.beforeMatch},V=["of","and","for","in","not","or","if","then","parent","list","value"];function K(e,t,n="keyword"){const r=Object.create(null);return"string"==typeof e?s(n,e.split(" ")):Array.isArray(e)?s(n,e):Object.keys(e).forEach(function(n){Object.assign(r,K(e[n],t,n))}),r;function s(e,n){t&&(n=n.map(e=>e.toLowerCase())),n.forEach(function(t){const n=t.split("|");r[n[0]]=[e,W(n[0],n[1])]})}}function W(e,t){return t?Number(t):function(e){return V.includes(e.toLowerCase())}(e)?0:1}const G={},J=e=>{console.error(e)},Z=(e,...t)=>{console.log(`WARN: ${e}`,...t)},Q=(e,t)=>{G[`${e}/${t}`]||(console.log(`Deprecated as of ${e}. ${t}`),G[`${e}/${t}`]=!0)},X=new Error;function Y(e,t,{key:n}){let r=0;const s=e[n],i={},o={};for(let a=1;a<=t.length;a++)o[a+r]=s[a],i[a+r]=!0,r+=m(t[a-1]);e[n]=o,e[n]._emit=i,e[n]._multi=!0}function ee(e){!function(e){e.scope&&"object"==typeof e.scope&&null!==e.scope&&(e.beginScope=e.scope,delete e.scope)}(e),"string"==typeof e.beginScope&&(e.beginScope={_wrap:e.beginScope}),"string"==typeof e.endScope&&(e.endScope={_wrap:e.endScope}),function(e){if(Array.isArray(e.begin)){if(e.skip||e.excludeBegin||e.returnBegin)throw J("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),X;if("object"!=typeof e.beginScope||null===e.beginScope)throw J("beginScope must be object"),X;Y(e,e.begin,{key:"beginScope"}),e.begin=b(e.begin,{joinWith:""})}}(e),function(e){if(Array.isArray(e.end)){if(e.skip||e.excludeEnd||e.returnEnd)throw J("skip, excludeEnd, returnEnd not compatible with endScope: {}"),X;if("object"!=typeof e.endScope||null===e.endScope)throw J("endScope must be object"),X;Y(e,e.end,{key:"endScope"}),e.end=b(e.end,{joinWith:""})}}(e)}function te(e){function t(t,n){return new RegExp(c(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+=m(e)+1}compile(){0===this.regexes.length&&(this.exec=()=>null);const e=this.regexes.map(e=>e[1]);this.matcherRe=t(b(e,{joinWith:"|"}),!0),this.lastIndex=0}exec(e){this.matcherRe.lastIndex=this.lastIndex;const t=this.matcherRe.exec(e);if(!t)return null;const n=t.findIndex((e,t)=>t>0&&void 0!==e),r=this.matchIndexes[n];return t.splice(0,n),Object.assign(t,r)}}class s{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(e){if(this.multiRegexes[e])return this.multiRegexes[e];const 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){const t=this.getMatcher(this.regexIndex);t.lastIndex=this.lastIndex;let n=t.exec(e);if(this.resumingScanAtSamePosition())if(n&&n.index===this.lastIndex);else{const 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 new Error("ERR: contains `self` is not supported at the top-level of a language.  See documentation.");return e.classNameAliases=r(e.classNameAliases||{}),function n(i,o){const a=i;if(i.isCompiled)return a;[z,H,ee,q].forEach(e=>e(i,o)),e.compilerExtensions.forEach(e=>e(i,o)),i.__beforeBegin=null,[$,F,U].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=K(i.keywords,e.case_insensitive)),a.keywordPatternRe=t(l,!0),o&&(i.begin||(i.begin=/\B|\b/),a.beginRe=t(a.begin),i.end||i.endsWithParent||(i.end=/\B|\b/),i.end&&(a.endRe=t(a.end)),a.terminatorEnd=c(a.end)||"",i.endsWithParent&&o.terminatorEnd&&(a.terminatorEnd+=(i.end?"|":"")+o.terminatorEnd)),i.illegal&&(a.illegalRe=t(i.illegal)),i.contains||(i.contains=[]),i.contains=[].concat(...i.contains.map(function(e){return function(e){e.variants&&!e.cachedVariants&&(e.cachedVariants=e.variants.map(function(t){return r(e,{variants:null},t)}));if(e.cachedVariants)return e.cachedVariants;if(ne(e))return r(e,{starts:e.starts?r(e.starts):null});if(Object.isFrozen(e))return r(e);return e}("self"===e?i:e)})),i.contains.forEach(function(e){n(e,a)}),i.starts&&n(i.starts,o),a.matcher=function(e){const t=new s;return e.contains.forEach(e=>t.addRule(e.begin,{rule:e,type:"begin"})),e.terminatorEnd&&t.addRule(e.terminatorEnd,{type:"end"}),e.illegal&&t.addRule(e.illegal,{type:"illegal"}),t}(a),a}(e)}function ne(e){return!!e&&(e.endsWithParent||ne(e.starts))}class re extends Error{constructor(e,t){super(e),this.name="HTMLInjectionError",this.html=t}}const se=n,ie=r,oe=Symbol("nomatch"),ae=function(n){const r=Object.create(null),s=Object.create(null),i=[];let o=!0;const a="Could not find the language '{}', did you forget to load/include a language module?",c={disableAutodetect:!0,name:"Plain text",contains:[]};let m={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:l};function g(e){return m.noHighlightRe.test(e)}function b(e,t,n){let r="",s="";"object"==typeof t?(r=e,n=t.ignoreIllegals,s=t.language):(Q("10.7.0","highlight(lang, code, ...args) has been deprecated."),Q("10.7.0","Please use highlight(code, options) instead.\nhttps://github.com/highlightjs/highlight.js/issues/2277"),s=e,r=t),void 0===n&&(n=!0);const i={code:r,language:s};_("before:highlight",i);const o=i.result?i.result:y(i.language,i.code,n);return o.code=i.code,_("after:highlight",o),o}function y(e,n,s,i){const l=Object.create(null);function c(e,t){return e.keywords[t]}function d(){if(!N.keywords)return void O.addText(A);let e=0;N.keywordPatternRe.lastIndex=0;let t=N.keywordPatternRe.exec(A),n="";for(;t;){n+=A.substring(e,t.index);const r=E.case_insensitive?t[0].toLowerCase():t[0],s=c(N,r);if(s){const[e,i]=s;if(O.addText(n),n="",l[r]=(l[r]||0)+1,l[r]<=7&&(T+=i),e.startsWith("_"))n+=t[0];else{const n=E.classNameAliases[e]||e;p(t[0],n)}}else n+=t[0];e=N.keywordPatternRe.lastIndex,t=N.keywordPatternRe.exec(A)}n+=A.substring(e),O.addText(n)}function u(){null!=N.subLanguage?function(){if(""===A)return;let e=null;if("string"==typeof N.subLanguage){if(!r[N.subLanguage])return void O.addText(A);e=y(N.subLanguage,A,!0,C[N.subLanguage]),C[N.subLanguage]=e._top}else e=v(A,N.subLanguage.length?N.subLanguage:null);N.relevance>0&&(T+=e.relevance),O.__addSublanguage(e._emitter,e.language)}():d(),A=""}function p(e,t){""!==e&&(O.startScope(t),O.addText(e),O.endScope())}function h(e,t){let n=1;const r=t.length-1;for(;n<=r;){if(!e._emit[n]){n++;continue}const r=E.classNameAliases[e[n]]||e[n],s=t[n];r?p(s,r):(A=s,d(),A=""),n++}}function f(e,t){return e.scope&&"string"==typeof e.scope&&O.openNode(E.classNameAliases[e.scope]||e.scope),e.beginScope&&(e.beginScope._wrap?(p(A,E.classNameAliases[e.beginScope._wrap]||e.beginScope._wrap),A=""):e.beginScope._multi&&(h(e.beginScope,t),A="")),N=Object.create(e,{parent:{value:N}}),N}function g(e,n,r){let s=function(e,t){const n=e&&e.exec(t);return n&&0===n.index}(e.endRe,r);if(s){if(e["on:end"]){const r=new t(e);e["on:end"](n,r),r.isMatchIgnored&&(s=!1)}if(s){for(;e.endsParent&&e.parent;)e=e.parent;return e}}if(e.endsWithParent)return g(e.parent,n,r)}function b(e){return 0===N.matcher.regexIndex?(A+=e[0],1):(R=!0,0)}function w(e){const t=e[0],r=n.substring(e.index),s=g(N,e,r);if(!s)return oe;const i=N;N.endScope&&N.endScope._wrap?(u(),p(t,N.endScope._wrap)):N.endScope&&N.endScope._multi?(u(),h(N.endScope,e)):i.skip?A+=t:(i.returnEnd||i.excludeEnd||(A+=t),u(),i.excludeEnd&&(A=t));do{N.scope&&O.closeNode(),N.skip||N.subLanguage||(T+=N.relevance),N=N.parent}while(N!==s.parent);return s.starts&&f(s.starts,e),i.returnEnd?0:t.length}let x={};function k(r,i){const a=i&&i[0];if(A+=r,null==a)return u(),0;if("begin"===x.type&&"end"===i.type&&x.index===i.index&&""===a){if(A+=n.slice(i.index,i.index+1),!o){const t=new Error(`0 width match regex (${e})`);throw t.languageName=e,t.badRule=x.rule,t}return 1}if(x=i,"begin"===i.type)return function(e){const n=e[0],r=e.rule,s=new t(r),i=[r.__beforeBegin,r["on:begin"]];for(const t of i)if(t&&(t(e,s),s.isMatchIgnored))return b(n);return r.skip?A+=n:(r.excludeBegin&&(A+=n),u(),r.returnBegin||r.excludeBegin||(A=n)),f(r,e),r.returnBegin?0:n.length}(i);if("illegal"===i.type&&!s){const e=new Error('Illegal lexeme "'+a+'" for mode "'+(N.scope||"<unnamed>")+'"');throw e.mode=N,e}if("end"===i.type){const e=w(i);if(e!==oe)return e}if("illegal"===i.type&&""===a)return 1;if(D>1e5&&D>3*i.index){throw new Error("potential infinite loop, way more iterations than matches")}return A+=a,a.length}const E=S(e);if(!E)throw J(a.replace("{}",e)),new Error('Unknown language: "'+e+'"');const M=te(E);let _="",N=i||M;const C={},O=new m.__emitter(m);!function(){const e=[];for(let t=N;t!==E;t=t.parent)t.scope&&e.unshift(t.scope);e.forEach(e=>O.openNode(e))}();let A="",T=0,I=0,D=0,R=!1;try{if(E.__emitTokens)E.__emitTokens(n,O);else{for(N.matcher.considerAll();;){D++,R?R=!1:N.matcher.considerAll(),N.matcher.lastIndex=I;const e=N.matcher.exec(n);if(!e)break;const t=k(n.substring(I,e.index),e);I=e.index+t}k(n.substring(I))}return O.finalize(),_=O.toHTML(),{language:e,value:_,relevance:T,illegal:!1,_emitter:O,_top:N}}catch(L){if(L.message&&L.message.includes("Illegal"))return{language:e,value:se(n),illegal:!0,relevance:0,_illegalBy:{message:L.message,index:I,context:n.slice(I-100,I+100),mode:L.mode,resultSoFar:_},_emitter:O};if(o)return{language:e,value:se(n),illegal:!1,relevance:0,errorRaised:L,_emitter:O,_top:N};throw L}}function v(e,t){t=t||m.languages||Object.keys(r);const n=function(e){const t={value:se(e),illegal:!1,relevance:0,_top:c,_emitter:new m.__emitter(m)};return t._emitter.addText(e),t}(e),s=t.filter(S).filter(M).map(t=>y(t,e,!1));s.unshift(n);const i=s.sort((e,t)=>{if(e.relevance!==t.relevance)return t.relevance-e.relevance;if(e.language&&t.language){if(S(e.language).supersetOf===t.language)return 1;if(S(t.language).supersetOf===e.language)return-1}return 0}),[o,a]=i,l=o;return l.secondBest=a,l}function w(e){let t=null;const n=function(e){let t=e.className+" ";t+=e.parentNode?e.parentNode.className:"";const n=m.languageDetectRe.exec(t);if(n){const t=S(n[1]);return t||(Z(a.replace("{}",n[1])),Z("Falling back to no-highlight mode for this block.",e)),t?n[1]:"no-highlight"}return t.split(/\s+/).find(e=>g(e)||S(e))}(e);if(g(n))return;if(_("before:highlightElement",{el:e,language:n}),e.children.length>0&&(m.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)),m.throwUnescapedHTML)){throw new re("One of your code blocks includes unescaped HTML.",e.innerHTML)}t=e;const r=t.textContent,i=n?b(r,{language:n,ignoreIllegals:!0}):v(r);e.innerHTML=i.value,function(e,t,n){const r=t&&s[t]||n;e.classList.add("hljs"),e.classList.add(`language-${r}`)}(e,n,i.language),e.result={language:i.language,re:i.relevance,relevance:i.relevance},i.secondBest&&(e.secondBest={language:i.secondBest.language,relevance:i.secondBest.relevance}),_("after:highlightElement",{el:e,result:i,text:r})}let x=!1;function k(){if("loading"===document.readyState)return void(x=!0);document.querySelectorAll(m.cssSelector).forEach(w)}function S(e){return e=(e||"").toLowerCase(),r[e]||r[s[e]]}function E(e,{languageName:t}){"string"==typeof e&&(e=[e]),e.forEach(e=>{s[e.toLowerCase()]=t})}function M(e){const t=S(e);return t&&!t.disableAutodetect}function _(e,t){const n=e;i.forEach(function(e){e[n]&&e[n](t)})}"undefined"!=typeof window&&window.addEventListener&&window.addEventListener("DOMContentLoaded",function(){x&&k()},!1),Object.assign(n,{highlight:b,highlightAuto:v,highlightAll:k,highlightElement:w,highlightBlock:function(e){return Q("10.7.0","highlightBlock will be removed entirely in v12.0"),Q("10.7.0","Please use highlightElement now."),w(e)},configure:function(e){m=ie(m,e)},initHighlighting:()=>{k(),Q("10.6.0","initHighlighting() deprecated.  Use highlightAll() now.")},initHighlightingOnLoad:function(){k(),Q("10.6.0","initHighlightingOnLoad() deprecated.  Use highlightAll() now.")},registerLanguage:function(e,t){let s=null;try{s=t(n)}catch(i){if(J("Language definition for '{}' could not be registered.".replace("{}",e)),!o)throw i;J(i),s=c}s.name||(s.name=e),r[e]=s,s.rawDefinition=t.bind(null,n),s.aliases&&E(s.aliases,{languageName:e})},unregisterLanguage:function(e){delete r[e];for(const t of Object.keys(s))s[t]===e&&delete s[t]},listLanguages:function(){return Object.keys(r)},getLanguage:S,registerAliases:E,autoDetection:M,inherit:ie,addPlugin:function(e){!function(e){e["before:highlightBlock"]&&!e["before:highlightElement"]&&(e["before:highlightElement"]=t=>{e["before:highlightBlock"](Object.assign({block:t.el},t))}),e["after:highlightBlock"]&&!e["after:highlightElement"]&&(e["after:highlightElement"]=t=>{e["after:highlightBlock"](Object.assign({block:t.el},t))})}(e),i.push(e)},removePlugin:function(e){const t=i.indexOf(e);-1!==t&&i.splice(t,1)}}),n.debugMode=function(){o=!1},n.safeMode=function(){o=!0},n.versionString="11.8.0",n.regex={concat:h,lookahead:d,either:f,optional:p,anyNumberOfTimes:u};for(const t in j)"object"==typeof j[t]&&e(j[t]);return Object.assign(n,j),n},le=ae({});return le.newInstance=()=>ae({}),uy=le,le.HighlightJS=le,le.default=le,uy}const ky=s(xy());function Sy(e,t=[]){return e.flatMap(e=>{const n=[...t,...e.properties?e.properties.className:[]];return e.children?Sy(e.children,n):{text:e.value,classes:n}})}function Ey(e){return e.value||e.children||[]}function My({doc:e,name:t,lowlight:n,defaultLanguage:r}){const s=[];return nf(e,e=>e.type.name===t).forEach(e=>{var t;let i=e.pos+1;const o=e.node.attrs.language||r,a=n.listLanguages();var l;Sy(o&&(a.includes(o)||(l=o,Boolean(ky.getLanguage(l)))||(null==(t=n.registered)?void 0:t.call(n,o)))?Ey(n.highlight(o,e.node.textContent)):Ey(n.highlightAuto(e.node.textContent))).forEach(e=>{const t=i+e.text.length;if(e.classes.length){const n=Ap.inline(i,t,{class:e.classes.join(" ")});s.push(n)}i=t})}),Dp.create(e,s)}function _y({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");const r=new fc({key:new bc("lowlight"),state:{init:(r,{doc:s})=>My({doc:s,name:e,lowlight:t,defaultLanguage:n}),apply:(r,s,i,o)=>{const a=i.selection.$head.parent.type.name,l=o.selection.$head.parent.type.name,c=nf(i.doc,t=>t.type.name===e),d=nf(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)))?My({doc:r.doc,name:e,lowlight:t,defaultLanguage:n}):s.map(r.mapping,r.doc)}},props:{decorations:e=>r.getState(e)}});return r}var Ny=vy.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))||[],_y({name:this.name,lowlight:this.options.lowlight,defaultLanguage:this.options.defaultLanguage})]}}),Cy=Tg.create({name:"hardBreak",addOptions:()=>({keepMarks:!0,HTMLAttributes:{}}),inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML:()=>[{tag:"br"}],renderHTML({HTMLAttributes:e}){return["br",pf(this.options.HTMLAttributes,e)]},renderText:()=>"\n",addCommands(){return{setHardBreak:()=>({commands:e,chain:t,state:n,editor:r})=>e.first([()=>e.exitCode(),()=>e.command(()=>{const{selection:e,storedMarks:s}=n;if(e.$from.parent.type.spec.isolating)return!1;const{keepMarks:i}=this.options,{splittableMarks:o}=r.extensionManager,a=s||e.$to.parentOffset&&e.$from.marks();return t().insertContent({type:this.name}).command(({tr:e,dispatch:t})=>{if(t&&a&&i){const 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()}}}),Oy=Cy;const Ay="numeric",Ty="ascii",Iy="alpha",Dy="asciinumeric",Ry="alphanumeric",Ly="domain",Py="emoji",jy="scheme",By="slashscheme",zy="whitespace";function $y(e,t){return e in t||(t[e]=[]),t[e]}function Fy(e,t,n){t[Ay]&&(t[Dy]=!0,t[Ry]=!0),t[Ty]&&(t[Dy]=!0,t[Iy]=!0),t[Dy]&&(t[Ry]=!0),t[Iy]&&(t[Ry]=!0),t[Ry]&&(t[Ly]=!0),t[Py]&&(t[Ly]=!0);for(const r in t){const t=$y(r,n);t.indexOf(e)<0&&t.push(e)}}function Hy(e=null){this.j={},this.jr=[],this.jd=null,this.t=e}Hy.groups={},Hy.prototype={accepts(){return!!this.t},go(e){const t=this,n=t.j[e];if(n)return n;for(let r=0;r<t.jr.length;r++){const n=t.jr[r][0],s=t.jr[r][1];if(s&&n.test(e))return s}return t.jd},has(e,t=!1){return t?e in this.j:!!this.go(e)},ta(e,t,n,r){for(let s=0;s<e.length;s++)this.tt(e[s],t,n,r)},tr(e,t,n,r){let s;return r=r||Hy.groups,t&&t.j?s=t:(s=new Hy(t),n&&r&&Fy(t,n,r)),this.jr.push([e,s]),s},ts(e,t,n,r){let s=this;const i=e.length;if(!i)return s;for(let o=0;o<i-1;o++)s=s.tt(e[o]);return s.tt(e[i-1],t,n,r)},tt(e,t,n,r){r=r||Hy.groups;const s=this;if(t&&t.j)return s.j[e]=t,t;const i=t;let o,a=s.go(e);if(a?(o=new Hy,Object.assign(o.j,a.j),o.jr.push.apply(o.jr,a.jr),o.jd=a.jd,o.t=a.t):o=new Hy,i){if(r)if(o.t&&"string"==typeof o.t){const e=Object.assign(function(e,t){const n={};for(const r in t)t[r].indexOf(e)>=0&&(n[r]=!0);return n}(o.t,r),n);Fy(i,e,r)}else n&&Fy(i,n,r);o.t=i}return s.j[e]=o,o}};const Uy=(e,t,n,r,s)=>e.ta(t,n,r,s),qy=(e,t,n,r,s)=>e.tr(t,n,r,s),Vy=(e,t,n,r,s)=>e.ts(t,n,r,s),Ky=(e,t,n,r,s)=>e.tt(t,n,r,s),Wy="WORD",Gy="UWORD",Jy="ASCIINUMERICAL",Zy="ALPHANUMERICAL",Qy="LOCALHOST",Xy="TLD",Yy="UTLD",ev="SCHEME",tv="SLASH_SCHEME",nv="NUM",rv="WS",sv="NL",iv="OPENBRACE",ov="CLOSEBRACE",av="OPENBRACKET",lv="CLOSEBRACKET",cv="OPENPAREN",dv="CLOSEPAREN",uv="OPENANGLEBRACKET",pv="CLOSEANGLEBRACKET",hv="FULLWIDTHLEFTPAREN",fv="FULLWIDTHRIGHTPAREN",mv="LEFTCORNERBRACKET",gv="RIGHTCORNERBRACKET",bv="LEFTWHITECORNERBRACKET",yv="RIGHTWHITECORNERBRACKET",vv="FULLWIDTHLESSTHAN",wv="FULLWIDTHGREATERTHAN",xv="AMPERSAND",kv="APOSTROPHE",Sv="ASTERISK",Ev="AT",Mv="BACKSLASH",_v="BACKTICK",Nv="CARET",Cv="COLON",Ov="COMMA",Av="DOLLAR",Tv="DOT",Iv="EQUALS",Dv="EXCLAMATION",Rv="HYPHEN",Lv="PERCENT",Pv="PIPE",jv="PLUS",Bv="POUND",zv="QUERY",$v="QUOTE",Fv="FULLWIDTHMIDDLEDOT",Hv="SEMI",Uv="SLASH",qv="TILDE",Vv="UNDERSCORE",Kv="EMOJI",Wv="SYM";var Gv=Object.freeze({__proto__:null,ALPHANUMERICAL:Zy,AMPERSAND:xv,APOSTROPHE:kv,ASCIINUMERICAL:Jy,ASTERISK:Sv,AT:Ev,BACKSLASH:Mv,BACKTICK:_v,CARET:Nv,CLOSEANGLEBRACKET:pv,CLOSEBRACE:ov,CLOSEBRACKET:lv,CLOSEPAREN:dv,COLON:Cv,COMMA:Ov,DOLLAR:Av,DOT:Tv,EMOJI:Kv,EQUALS:Iv,EXCLAMATION:Dv,FULLWIDTHGREATERTHAN:wv,FULLWIDTHLEFTPAREN:hv,FULLWIDTHLESSTHAN:vv,FULLWIDTHMIDDLEDOT:Fv,FULLWIDTHRIGHTPAREN:fv,HYPHEN:Rv,LEFTCORNERBRACKET:mv,LEFTWHITECORNERBRACKET:bv,LOCALHOST:Qy,NL:sv,NUM:nv,OPENANGLEBRACKET:uv,OPENBRACE:iv,OPENBRACKET:av,OPENPAREN:cv,PERCENT:Lv,PIPE:Pv,PLUS:jv,POUND:Bv,QUERY:zv,QUOTE:$v,RIGHTCORNERBRACKET:gv,RIGHTWHITECORNERBRACKET:yv,SCHEME:ev,SEMI:Hv,SLASH:Uv,SLASH_SCHEME:tv,SYM:Wv,TILDE:qv,TLD:Xy,UNDERSCORE:Vv,UTLD:Yy,UWORD:Gy,WORD:Wy,WS:rv});const Jv=/[a-z]/,Zv=/\p{L}/u,Qv=/\p{Emoji}/u,Xv=/\d/,Yv=/\s/;let ew=null,tw=null;function nw(e,t){const n=function(e){const t=[],n=e.length;let r=0;for(;r<n;){let s,i=e.charCodeAt(r),o=i<55296||i>56319||r+1===n||(s=e.charCodeAt(r+1))<56320||s>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,s=[];let i=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,a.accepts()?(u=0,p=0,d=a):u>=0&&(u+=n[o].length,p++),c+=n[o].length,i+=n[o].length,o++;i-=u,o-=p,c-=u,s.push({t:d.t,v:t.slice(i-c,i),s:i-c,e:i})}return s}function rw(e,t,n,r,s){let i;const o=t.length;for(let a=0;a<o-1;a++){const n=t[a];e.j[n]?i=e.j[n]:(i=new Hy(r),i.jr=s.slice(),e.j[n]=i),e=i}return i=new Hy(n),i.jr=s.slice(),e.j[t[o-1]]=i,i}function sw(e){const t=[],n=[];let r=0;for(;r<e.length;){let s=0;for(;"0123456789".indexOf(e[r+s])>=0;)s++;if(s>0){t.push(n.join(""));for(let t=parseInt(e.substring(r,r+s),10);t>0;t--)n.pop();r+=s}else n.push(e[r]),r++}return t}const iw={defaultProtocol:"http",events:null,format:aw,formatHref:aw,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function ow(e,t=null){let n=Object.assign({},iw);e&&(n=Object.assign(n,e instanceof ow?e.o:e));const r=n.ignoreTags,s=[];for(let i=0;i<r.length;i++)s.push(r[i].toUpperCase());this.o=n,t&&(this.defaultRender=t),this.ignoreTags=s}function aw(e){return e}function lw(e,t){this.t="token",this.v=e,this.tk=t}function cw(e,t){class n extends lw{constructor(t,n){super(t,n),this.t=e}}for(const r in t)n.prototype[r]=t[r];return n.t=e,n}ow.prototype={o:iw,ignoreTags:[],defaultRender:e=>e,check(e){return this.get("validate",e.toString(),e)},get(e,t,n){const r=null!=t;let s=this.o[e];return s?("object"==typeof s?(s=n.t in s?s[n.t]:iw[e],"function"==typeof s&&r&&(s=s(t,n))):"function"==typeof s&&r&&(s=s(t,n.t,n)),s):s},getObj(e,t,n){let r=this.o[e];return"function"==typeof r&&null!=t&&(r=r(t,n.t,n)),r},render(e){const t=e.render(this);return(this.get("render",null,e)||this.defaultRender)(t,e.t,e)}},lw.prototype={isLink:!1,toString(){return this.v},toHref(e){return this.toString()},toFormattedString(e){const t=this.toString(),n=e.get("truncate",t,this),r=e.get("format",t,this);return n&&r.length>n?r.substring(0,n)+"\u2026":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=iw.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){const t=this,n=this.toHref(e.get("defaultProtocol")),r=e.get("formatHref",n,this),s=e.get("tagName",n,t),i=this.toFormattedString(e),o={},a=e.get("className",n,t),l=e.get("target",n,t),c=e.get("rel",n,t),d=e.getObj("attributes",n,t),u=e.getObj("events",n,t);return o.href=r,a&&(o.class=a),l&&(o.target=l),c&&(o.rel=c),d&&Object.assign(o,d),{tagName:s,attributes:o,content:i,eventListeners:u}}};const dw=cw("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),uw=cw("text"),pw=cw("nl"),hw=cw("url",{isLink:!0,toHref(e=iw.defaultProtocol){return this.hasProtocol()?this.v:`${e}://${this.v}`},hasProtocol(){const e=this.tk;return e.length>=2&&e[0].t!==Qy&&e[1].t===Cv}}),fw=e=>new Hy(e);function mw(e,t,n){const r=n[0].s,s=n[n.length-1].e;return new e(t.slice(r,s),n)}const gw="undefined"!=typeof console&&console&&console.warn||(()=>{}),bw={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function yw(e,t=!1){if(bw.initialized&&gw(`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 new Error('linkifyjs: incorrect scheme format.\n1. Must only contain digits, lowercase ASCII letters or "-"\n2. Cannot start or end with "-"\n3. "-" cannot repeat');bw.customSchemes.push([e,t])}function vw(){bw.scanner=function(e=[]){const t={};Hy.groups=t;const n=new Hy;null==ew&&(ew=sw("aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5m\xf6gensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2")),null==tw&&(tw=sw("\u03b5\u03bb1\u03c52\u0431\u04331\u0435\u043b3\u0434\u0435\u0442\u04384\u0435\u044e2\u043a\u0430\u0442\u043e\u043b\u0438\u043a6\u043e\u043c3\u043c\u043a\u04342\u043e\u043d1\u0441\u043a\u0432\u04306\u043e\u043d\u043b\u0430\u0439\u043d5\u0440\u04333\u0440\u0443\u04412\u04442\u0441\u0430\u0439\u04423\u0440\u04313\u0443\u043a\u04403\u049b\u0430\u04373\u0570\u0561\u05753\u05d9\u05e9\u05e8\u05d0\u05dc5\u05e7\u05d5\u05dd3\u0627\u0628\u0648\u0638\u0628\u064a5\u0631\u0627\u0645\u0643\u06485\u0644\u0627\u0631\u062f\u06464\u0628\u062d\u0631\u064a\u06465\u062c\u0632\u0627\u0626\u06315\u0633\u0639\u0648\u062f\u064a\u06296\u0639\u0644\u064a\u0627\u06465\u0645\u063a\u0631\u06285\u0645\u0627\u0631\u0627\u062a5\u06cc\u0631\u0627\u06465\u0628\u0627\u0631\u062a2\u0632\u0627\u06314\u064a\u062a\u06433\u06be\u0627\u0631\u062a5\u062a\u0648\u0646\u06334\u0633\u0648\u062f\u0627\u06463\u0631\u064a\u06295\u0634\u0628\u0643\u06294\u0639\u0631\u0627\u06422\u06282\u0645\u0627\u06464\u0641\u0644\u0633\u0637\u064a\u06466\u0642\u0637\u06313\u0643\u0627\u062b\u0648\u0644\u064a\u06436\u0648\u06453\u0645\u0635\u06312\u0644\u064a\u0633\u064a\u06275\u0648\u0631\u064a\u062a\u0627\u0646\u064a\u06277\u0642\u06394\u0647\u0645\u0631\u0627\u06475\u067e\u0627\u06a9\u0633\u062a\u0627\u06467\u0680\u0627\u0631\u062a4\u0915\u0949\u092e3\u0928\u0947\u091f3\u092d\u093e\u0930\u09240\u092e\u094d3\u094b\u09245\u0938\u0902\u0917\u0920\u09285\u09ac\u09be\u0982\u09b2\u09be5\u09ad\u09be\u09b0\u09a42\u09f0\u09a44\u0a2d\u0a3e\u0a30\u0a244\u0aad\u0abe\u0ab0\u0aa44\u0b2d\u0b3e\u0b30\u0b244\u0b87\u0ba8\u0bcd\u0ba4\u0bbf\u0baf\u0bbe6\u0bb2\u0b99\u0bcd\u0b95\u0bc86\u0b9a\u0bbf\u0b99\u0bcd\u0b95\u0baa\u0bcd\u0baa\u0bc2\u0bb0\u0bcd11\u0c2d\u0c3e\u0c30\u0c24\u0c4d5\u0cad\u0cbe\u0cb0\u0ca44\u0d2d\u0d3e\u0d30\u0d24\u0d025\u0dbd\u0d82\u0d9a\u0dcf4\u0e04\u0e2d\u0e213\u0e44\u0e17\u0e223\u0ea5\u0eb2\u0ea73\u10d2\u10d42\u307f\u3093\u306a3\u30a2\u30de\u30be\u30f34\u30af\u30e9\u30a6\u30c94\u30b0\u30fc\u30b0\u30eb4\u30b3\u30e02\u30b9\u30c8\u30a23\u30bb\u30fc\u30eb3\u30d5\u30a1\u30c3\u30b7\u30e7\u30f36\u30dd\u30a4\u30f3\u30c84\u4e16\u754c2\u4e2d\u4fe11\u56fd1\u570b1\u6587\u7f513\u4e9a\u9a6c\u900a3\u4f01\u4e1a2\u4f5b\u5c712\u4fe1\u606f2\u5065\u5eb72\u516b\u53662\u516c\u53f81\u76ca2\u53f0\u6e7e1\u70632\u5546\u57ce1\u5e971\u68072\u5609\u91cc0\u5927\u9152\u5e975\u5728\u7ebf2\u5927\u62ff2\u5929\u4e3b\u65593\u5a31\u4e502\u5bb6\u96fb2\u5e7f\u4e1c2\u5fae\u535a2\u6148\u55842\u6211\u7231\u4f603\u624b\u673a2\u62db\u80582\u653f\u52a11\u5e9c2\u65b0\u52a0\u57612\u95fb2\u65f6\u5c1a2\u66f8\u7c4d2\u673a\u67842\u6de1\u9a6c\u95213\u6e38\u620f2\u6fb3\u95802\u70b9\u770b2\u79fb\u52a82\u7ec4\u7ec7\u673a\u67844\u7f51\u57401\u5e971\u7ad91\u7edc2\u8054\u901a2\u8c37\u6b4c2\u8d2d\u72692\u901a\u8ca92\u96c6\u56e22\u96fb\u8a0a\u76c8\u79d14\u98de\u5229\u6d663\u98df\u54c12\u9910\u53852\u9999\u683c\u91cc\u62c93\u6e2f2\ub2f7\ub1371\ucef42\uc0bc\uc1312\ud55c\uad6d2")),Ky(n,"'",kv),Ky(n,"{",iv),Ky(n,"}",ov),Ky(n,"[",av),Ky(n,"]",lv),Ky(n,"(",cv),Ky(n,")",dv),Ky(n,"<",uv),Ky(n,">",pv),Ky(n,"\uff08",hv),Ky(n,"\uff09",fv),Ky(n,"\u300c",mv),Ky(n,"\u300d",gv),Ky(n,"\u300e",bv),Ky(n,"\u300f",yv),Ky(n,"\uff1c",vv),Ky(n,"\uff1e",wv),Ky(n,"&",xv),Ky(n,"*",Sv),Ky(n,"@",Ev),Ky(n,"`",_v),Ky(n,"^",Nv),Ky(n,":",Cv),Ky(n,",",Ov),Ky(n,"$",Av),Ky(n,".",Tv),Ky(n,"=",Iv),Ky(n,"!",Dv),Ky(n,"-",Rv),Ky(n,"%",Lv),Ky(n,"|",Pv),Ky(n,"+",jv),Ky(n,"#",Bv),Ky(n,"?",zv),Ky(n,'"',$v),Ky(n,"/",Uv),Ky(n,";",Hv),Ky(n,"~",qv),Ky(n,"_",Vv),Ky(n,"\\",Mv),Ky(n,"\u30fb",Fv);const r=qy(n,Xv,nv,{[Ay]:!0});qy(r,Xv,r);const s=qy(r,Jv,Jy,{[Dy]:!0}),i=qy(r,Zv,Zy,{[Ry]:!0}),o=qy(n,Jv,Wy,{[Ty]:!0});qy(o,Xv,s),qy(o,Jv,o),qy(s,Xv,s),qy(s,Jv,s);const a=qy(n,Zv,Gy,{[Iy]:!0});qy(a,Jv),qy(a,Xv,i),qy(a,Zv,a),qy(i,Xv,i),qy(i,Jv),qy(i,Zv,i);const l=Ky(n,"\n",sv,{[zy]:!0}),c=Ky(n,"\r",rv,{[zy]:!0}),d=qy(n,Yv,rv,{[zy]:!0});Ky(n,"\ufffc",d),Ky(c,"\n",l),Ky(c,"\ufffc",d),qy(c,Yv,d),Ky(d,"\r"),Ky(d,"\n"),qy(d,Yv,d),Ky(d,"\ufffc",d);const u=qy(n,Qv,Kv,{[Py]:!0});Ky(u,"#"),qy(u,Qv,u),Ky(u,"\ufe0f",u);const p=Ky(u,"\u200d");Ky(p,"#"),qy(p,Qv,u);const h=[[Jv,o],[Xv,s]],f=[[Jv,null],[Zv,a],[Xv,i]];for(let m=0;m<ew.length;m++)rw(n,ew[m],Xy,Wy,h);for(let m=0;m<tw.length;m++)rw(n,tw[m],Yy,Gy,f);Fy(Xy,{tld:!0,ascii:!0},t),Fy(Yy,{utld:!0,alpha:!0},t),rw(n,"file",ev,Wy,h),rw(n,"mailto",ev,Wy,h),rw(n,"http",tv,Wy,h),rw(n,"https",tv,Wy,h),rw(n,"ftp",tv,Wy,h),rw(n,"ftps",tv,Wy,h),Fy(ev,{scheme:!0,ascii:!0},t),Fy(tv,{slashscheme:!0,ascii:!0},t),e=e.sort((e,t)=>e[0]>t[0]?1:-1);for(let m=0;m<e.length;m++){const t=e[m][0],r=e[m][1]?{[jy]:!0}:{[By]:!0};t.indexOf("-")>=0?r[Ly]=!0:Jv.test(t)?Xv.test(t)?r[Dy]=!0:r[Ty]=!0:r[Ay]=!0,Vy(n,t,t,r)}return Vy(n,"localhost",Qy,{ascii:!0}),n.jd=new Hy(Wv),{start:n,tokens:Object.assign({groups:t},Gv)}}(bw.customSchemes);for(let e=0;e<bw.tokenQueue.length;e++)bw.tokenQueue[e][1]({scanner:bw.scanner});bw.parser=function({groups:e}){const t=e.domain.concat([xv,Sv,Ev,Mv,_v,Nv,Av,Iv,Rv,nv,Lv,Pv,jv,Bv,Uv,Wv,qv,Vv]),n=[kv,Cv,Ov,Tv,Dv,Lv,zv,$v,Hv,uv,pv,iv,ov,lv,av,cv,dv,hv,fv,mv,gv,bv,yv,vv,wv],r=[xv,kv,Sv,Mv,_v,Nv,Av,Iv,Rv,iv,ov,Lv,Pv,jv,Bv,zv,Uv,Wv,qv,Vv],s=fw(),i=Ky(s,qv);Uy(i,r,i),Uy(i,e.domain,i);const o=fw(),a=fw(),l=fw();Uy(s,e.domain,o),Uy(s,e.scheme,a),Uy(s,e.slashscheme,l),Uy(o,r,i),Uy(o,e.domain,o);const c=Ky(o,Ev);Ky(i,Ev,c),Ky(a,Ev,c),Ky(l,Ev,c);const d=Ky(i,Tv);Uy(d,r,i),Uy(d,e.domain,i);const u=fw();Uy(c,e.domain,u),Uy(u,e.domain,u);const p=Ky(u,Tv);Uy(p,e.domain,u);const h=fw(dw);Uy(p,e.tld,h),Uy(p,e.utld,h),Ky(c,Qy,h);const f=Ky(u,Rv);Ky(f,Rv,f),Uy(f,e.domain,u),Uy(h,e.domain,u),Ky(h,Tv,p),Ky(h,Rv,f);const m=Ky(h,Cv);Uy(m,e.numeric,dw);const g=Ky(o,Rv),b=Ky(o,Tv);Ky(g,Rv,g),Uy(g,e.domain,o),Uy(b,r,i),Uy(b,e.domain,o);const y=fw(hw);Uy(b,e.tld,y),Uy(b,e.utld,y),Uy(y,e.domain,o),Uy(y,r,i),Ky(y,Tv,b),Ky(y,Rv,g),Ky(y,Ev,c);const v=Ky(y,Cv),w=fw(hw);Uy(v,e.numeric,w);const x=fw(hw),k=fw();Uy(x,t,x),Uy(x,n,k),Uy(k,t,x),Uy(k,n,k),Ky(y,Uv,x),Ky(w,Uv,x);const S=Ky(a,Cv),E=Ky(l,Cv),M=Ky(E,Uv),_=Ky(M,Uv);Uy(a,e.domain,o),Ky(a,Tv,b),Ky(a,Rv,g),Uy(l,e.domain,o),Ky(l,Tv,b),Ky(l,Rv,g),Uy(S,e.domain,x),Ky(S,Uv,x),Ky(S,zv,x),Uy(_,e.domain,x),Uy(_,t,x),Ky(_,Uv,x);const N=[[iv,ov],[av,lv],[cv,dv],[uv,pv],[hv,fv],[mv,gv],[bv,yv],[vv,wv]];for(let C=0;C<N.length;C++){const[e,r]=N[C],s=Ky(x,e);Ky(k,e,s),Ky(s,r,x);const i=fw(hw);Uy(s,t,i);const o=fw();Uy(s,n),Uy(i,t,i),Uy(i,n,o),Uy(o,t,i),Uy(o,n,o),Ky(i,r,x),Ky(o,r,x)}return Ky(s,Qy,y),Ky(s,sv,pw),{start:s,tokens:Gv}}(bw.scanner.tokens);for(let e=0;e<bw.pluginQueue.length;e++)bw.pluginQueue[e][1]({scanner:bw.scanner,parser:bw.parser});return bw.initialized=!0,bw}function ww(e){return bw.initialized||vw(),function(e,t,n){let r=n.length,s=0,i=[],o=[];for(;s<r;){let a=e,l=null,c=null,d=0,u=null,p=-1;for(;s<r&&!(l=a.go(n[s].t));)o.push(n[s++]);for(;s<r&&(c=l||a.go(n[s].t));)l=null,a=c,a.accepts()?(p=0,u=a):p>=0&&p++,s++,d++;if(p<0)s-=d,s<r&&(o.push(n[s]),s++);else{o.length>0&&(i.push(mw(uw,t,o)),o=[]),s-=p,d-=p;const e=u.t,r=n.slice(s-d,s);i.push(mw(e,t,r))}}return o.length>0&&i.push(mw(uw,t,o)),i}(bw.parser.start,e,nw(bw.scanner.start,e))}function xw(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}const r=new ow(n),s=ww(e),i=[];for(let o=0;o<s.length;o++){const e=s[o];!e.isLink||t&&e.t!==t||!r.check(e)||i.push(e.toFormattedObject(r))}return i}ww.scan=nw;var kw="[\0- \xa0\u1680\u180e\u2000-\u2029\u205f\u3000]",Sw=new RegExp(kw),Ew=new RegExp(`${kw}$`),Mw=new RegExp(kw,"g");function _w(e,t){const n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return t&&t.forEach(e=>{const t="string"==typeof e?e:e.scheme;t&&n.push(t)}),!e||e.replace(Mw,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var Nw=Qf.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?yw(e.scheme,e.optionalSlashes):yw(e)})},onDestroy(){Hy.groups={},bw.scanner=null,bw.parser=null,bw.tokenQueue=[],bw.pluginQueue=[],bw.customSchemes=[],bw.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)=>!!_w(e,t.protocols),validate:e=>!!e,shouldAutoLink:e=>!!e}),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}}},parseHTML(){return[{tag:"a[href]",getAttrs:e=>{const t=e.getAttribute("href");return!(!t||!this.options.isAllowedUri(t,{defaultValidate:e=>!!_w(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol}))&&null}}]},renderHTML({HTMLAttributes:e}){return this.options.isAllowedUri(e.href,{defaultValidate:e=>!!_w(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",pf(this.options.HTMLAttributes,e),0]:["a",pf(this.options.HTMLAttributes,{...e,href:""}),0]},addCommands(){return{setLink:e=>({chain:t})=>{const{href:n}=e;return!!this.options.isAllowedUri(n,{defaultValidate:e=>!!_w(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})=>{const{href:n}=e||{};return!(n&&!this.options.isAllowedUri(n,{defaultValidate:e=>!!_w(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[Dg({find:e=>{const t=[];if(e){const{protocols:n,defaultProtocol:r}=this.options,s=xw(e).filter(e=>e.isLink&&this.options.isAllowedUri(e.value,{defaultValidate:e=>!!_w(e,n),protocols:n,defaultProtocol:r}));s.length&&s.forEach(e=>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(){const e=[],{protocols:t,defaultProtocol:n}=this.options;var r;return this.options.autolink&&e.push((r={type:this.type,defaultProtocol:this.options.defaultProtocol,validate:e=>this.options.isAllowedUri(e,{defaultValidate:e=>!!_w(e,t),protocols:t,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink},new fc({key:new bc("autolink"),appendTransaction:(e,t,n)=>{const s=e.some(e=>e.docChanged)&&!t.doc.eq(n.doc),i=e.some(e=>e.getMeta("preventAutolink"));if(!s||i)return;const{tr:o}=n;return Nf(Qh(t.doc,[...e])).forEach(({newRange:e})=>{const t=function(e,t,n){const r=[];return e.nodesBetween(t.from,t.to,(e,t)=>{n(e)&&r.push({node:e,pos:t})}),r}(n.doc,e,e=>e.isTextblock);let s,i;if(t.length>1)s=t[0],i=n.doc.textBetween(s.pos,s.pos+s.node.nodeSize,void 0," ");else if(t.length){const r=n.doc.textBetween(e.from,e.to," "," ");if(!Ew.test(r))return;s=t[0],i=n.doc.textBetween(s.pos,e.to,void 0," ")}if(s&&i){const e=i.split(Sw).filter(Boolean);if(e.length<=0)return!1;const t=e[e.length-1],l=s.pos+i.lastIndexOf(t);if(!t)return!1;const c=ww(t).map(e=>e.toObject(r.defaultProtocol));if(!(1===(a=c).length?a[0].isLink:3===a.length&&a[1].isLink&&["()","[]"].includes(a[0].value+a[2].value)))return!1;c.filter(e=>e.isLink).map(e=>({...e,from:l+e.start+1,to:l+e.end+1})).filter(e=>!n.schema.marks.code||!n.doc.rangeHasMark(e.from,e.to,n.schema.marks.code)).filter(e=>r.validate(e.value)).filter(e=>r.shouldAutoLink(e.value)).forEach(e=>{Df(e.from,e.to,n.doc).some(e=>e.mark.type===r.type)||o.addMark(e.from,e.to,r.type.create({href:e.href}))})}var a}),o.steps.length?o:void 0}}))),!0===this.options.openOnClick&&e.push(function(e){return new fc({key:new bc("handleClickLink"),props:{handleClick:(t,n,r)=>{var s,i;if(0!==r.button)return!1;if(!t.editable)return!1;let o=null;if(r.target instanceof HTMLAnchorElement)o=r.target;else{let e=r.target;const t=[];for(;"DIV"!==e.nodeName;)t.push(e),e=e.parentNode;o=t.find(e=>"A"===e.nodeName)}if(!o)return!1;const a=Mf(t.state,e.type.name),l=null!=(s=null==o?void 0:o.href)?s:a.href,c=null!=(i=null==o?void 0:o.target)?i:a.target;return e.enableClickSelection&&e.editor.commands.extendMarkRange(e.type.name),!(!o||!l||(window.open(l,c),0))}}})}({type:this.type,editor:this.editor,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&e.push(function(e){return new fc({key:new bc("handlePasteLink"),props:{handlePaste:(t,n,r)=>{const{state:s}=t,{selection:i}=s,{empty:o}=i;if(o)return!1;let a="";r.content.forEach(e=>{a+=e.textContent});const l=xw(a,{defaultProtocol:e.defaultProtocol}).find(e=>e.isLink&&e.value===a);return!(!a||!l)&&e.editor.commands.setMark(e.type,{href:l.href})}}})}({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type})),e}}),Cw=Nw;function Ow(e={}){return new fc({view:t=>new Aw(t,e)})}class Aw{constructor(e,t){var n;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=null!==(n=t.width)&&void 0!==n?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=this.editorView.state.doc.resolve(this.cursorPos),n=!t.parent.inlineContent,r=this.editorView.dom,s=r.getBoundingClientRect(),i=s.width/r.offsetWidth,o=s.height/r.offsetHeight;if(n){let n=t.nodeBefore,r=t.nodeAfter;if(n||r){let t=this.editorView.nodeDOM(this.cursorPos-(n?n.nodeSize:0));if(t){let s=t.getBoundingClientRect(),i=n?s.bottom:s.top;n&&r&&(i=(i+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let a=this.width/2*o;e={left:s.left,right:s.right,top:i-a,bottom:i+a}}}}if(!e){let t=this.editorView.coordsAtPos(this.cursorPos),n=this.width/2*i;e={left:t.left-n,right:t.left+n,top:t.top,bottom:t.bottom}}let a,l,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",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n),!c||c==document.body&&"static"==getComputedStyle(c).position)a=-pageXOffset,l=-pageYOffset;else{let e=c.getBoundingClientRect(),t=e.width/c.offsetWidth,n=e.height/c.offsetHeight;a=e.left-c.scrollLeft*t,l=e.top-c.scrollTop*n}this.element.style.left=(e.left-a)/i+"px",this.element.style.top=(e.top-l)/o+"px",this.element.style.width=(e.right-e.left)/i+"px",this.element.style.height=(e.bottom-e.top)/o+"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,s="function"==typeof r?r(this.editorView,t,e):r;if(t&&!s){let e=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let t=Il(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 Tw extends Jl{constructor(e){super(e,e)}map(e,t){let n=e.resolve(t.map(this.head));return Tw.valid(n)?new Tw(n):Jl.near(n)}content(){return ra.empty}eq(e){return e instanceof Tw&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if("number"!=typeof t.pos)throw new RangeError("Invalid input for GapCursor.fromJSON");return new Tw(e.resolve(t.pos))}getBookmark(){return new Iw(this.anchor)}static valid(e){let t=e.parent;if(t.isTextblock||!function(e){for(let t=e.depth;t>=0;t--){let n=e.index(t),r=e.node(t);if(0!=n)for(let e=r.child(n-1);;e=e.lastChild){if(0==e.childCount&&!e.inlineContent||e.isAtom||e.type.spec.isolating)return!0;if(e.inlineContent)return!1}else if(r.type.spec.isolating)return!0}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)for(let e=r.child(n);;e=e.firstChild){if(0==e.childCount&&!e.inlineContent||e.isAtom||e.type.spec.isolating)return!0;if(e.inlineContent)return!1}else if(r.type.spec.isolating)return!0}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){e:for(;;){if(!n&&Tw.valid(e))return e;let r=e.pos,s=null;for(let n=e.depth;;n--){let i=e.node(n);if(t>0?e.indexAfter(n)<i.childCount:e.index(n)>0){s=i.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(Tw.valid(o))return o}for(;;){let i=t>0?s.firstChild:s.lastChild;if(!i){if(s.isAtom&&!s.isText&&!tc.isSelectable(s)){e=e.doc.resolve(r+s.nodeSize*t),n=!1;continue e}break}s=i,r+=t;let o=e.doc.resolve(r);if(Tw.valid(o))return o}return null}}}Tw.prototype.visible=!1,Tw.findFrom=Tw.findGapCursorFrom,Jl.jsonID("gapcursor",Tw);class Iw{constructor(e){this.pos=e}map(e){return new Iw(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return Tw.valid(t)?new Tw(t):Jl.near(t)}}const Dw=xh({ArrowLeft:Rw("horiz",-1),ArrowRight:Rw("horiz",1),ArrowUp:Rw("vert",-1),ArrowDown:Rw("vert",1)});function Rw(e,t){const n="vert"==e?t>0?"down":"up":t>0?"right":"left";return function(e,r,s){let i=e.selection,o=t>0?i.$to:i.$from,a=i.empty;if(i instanceof Yl){if(!s.endOfTextblock(n)||0==o.depth)return!1;a=!1,o=e.doc.resolve(t>0?o.after():o.before())}let l=Tw.findGapCursorFrom(o,t,a);return!!l&&(r&&r(e.tr.setSelection(new Tw(l))),!0)}}function Lw(e,t,n){if(!e||!e.editable)return!1;let r=e.state.doc.resolve(t);if(!Tw.valid(r))return!1;let s=e.posAtCoords({left:n.clientX,top:n.clientY});return!(s&&s.inside>-1&&tc.isSelectable(e.state.doc.nodeAt(s.inside)))&&(e.dispatch(e.state.tr.setSelection(new Tw(r))),!0)}function Pw(e,t){if("insertCompositionText"!=t.inputType||!(e.state.selection instanceof Tw))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 s=Qo.empty;for(let o=r.length-1;o>=0;o--)s=Qo.from(r[o].createAndFill(null,s));let i=e.state.tr.replace(n.pos,n.pos,new ra(s,0,0));return i.setSelection(Yl.near(i.doc.resolve(n.pos+1))),e.dispatch(i),!1}function jw(e){if(!(e.selection instanceof Tw))return null;let t=document.createElement("div");return t.className="ProseMirror-gapcursor",Dp.create(e.doc,[Ap.widget(e.selection.head,t,{key:"gapcursor"})])}var Bw=200,zw=function(){};zw.prototype.append=function(e){return e.length?(e=zw.from(e),!this.length&&e||e.length<Bw&&this.leafAppend(e)||this.length<Bw&&e.leafPrepend(this)||this.appendInner(e)):this},zw.prototype.prepend=function(e){return e.length?zw.from(e).append(this):this},zw.prototype.appendInner=function(e){return new Fw(this,e)},zw.prototype.slice=function(e,t){return void 0===e&&(e=0),void 0===t&&(t=this.length),e>=t?zw.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},zw.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},zw.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)},zw.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},zw.from=function(e){return e instanceof zw?e:e&&e.length?new $w(e):zw.empty};var $w=function(e){function t(t){e.call(this),this.values=t}e&&(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 s=t;s<n;s++)if(!1===e(this.values[s],r+s))return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){for(var s=t-1;s>=n;s--)if(!1===e(this.values[s],r+s))return!1},t.prototype.leafAppend=function(e){if(this.length+e.length<=Bw)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=Bw)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}(zw);zw.empty=new $w([]);var Fw=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 e&&(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 s=this.left.length;return!(t<s&&!1===this.left.forEachInner(e,t,Math.min(n,s),r))&&(!(n>s&&!1===this.right.forEachInner(e,Math.max(t-s,0),Math.min(this.length,n)-s,r+s))&&void 0)},t.prototype.forEachInvertedInner=function(e,t,n,r){var s=this.left.length;return!(t>s&&!1===this.right.forEachInvertedInner(e,t-s,Math.max(n,s)-s,r+s))&&(!(n<s&&!1===this.left.forEachInvertedInner(e,Math.min(t,s),n,r))&&void 0)},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}(zw),Hw=zw;class Uw{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(0==this.eventCount)return null;let n,r,s=this.items.length;for(;;s--){if(this.items.get(s-1).selection){--s;break}}t&&(n=this.remapping(s,this.items.length),r=n.maps.length);let i,o,a=e.tr,l=[],c=[];return this.items.forEach((e,t)=>{if(!e.step)return n||(n=this.remapping(s,t+1),r=n.maps.length),r--,void c.push(e);if(n){c.push(new qw(e.map));let t,s=e.step.map(n.slice(r));s&&a.maybeStep(s).doc&&(t=a.mapping.maps[a.mapping.maps.length-1],l.push(new qw(t,void 0,void 0,l.length+c.length))),r--,t&&n.appendMap(t,r)}else a.maybeStep(e.step);return e.selection?(i=n?e.selection.map(n.slice(r)):e.selection,o=new Uw(this.items.slice(0,s).append(c.reverse().concat(l)),this.eventCount-1),!1):void 0},this.items.length,0),{remaining:o,transform:a,selection:i}}addTransform(e,t,n,r){let s=[],i=this.eventCount,o=this.items,a=!r&&o.length?o.get(o.length-1):null;for(let c=0;c<e.steps.length;c++){let n,l=e.steps[c].invert(e.docs[c]),d=new qw(e.mapping.maps[c],l,t);(n=a&&a.merge(d))&&(d=n,c?s.pop():o=o.slice(0,o.length-1)),s.push(d),t&&(i++,t=void 0),r||(a=d)}let l=i-n.depth;return l>Kw&&(o=function(e,t){let n;return e.forEach((e,r)=>{if(e.selection&&0==t--)return n=r,!1}),e.slice(n)}(o,l),i-=l),new Uw(o.append(s),i)}remapping(e,t){let n=new cl;return this.items.forEach((t,r)=>{let s=null!=t.mirrorOffset&&r-t.mirrorOffset>=e?n.maps.length-t.mirrorOffset:void 0;n.appendMap(t.map,s)},e,t),n}addMaps(e){return 0==this.eventCount?this:new Uw(this.items.append(e.map(e=>new qw(e))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let n=[],r=Math.max(0,this.items.length-t),s=e.mapping,i=e.steps.length,o=this.eventCount;this.items.forEach(e=>{e.selection&&o--},r);let a=t;this.items.forEach(t=>{let r=s.getMirror(--a);if(null==r)return;i=Math.min(i,r);let l=s.maps[r];if(t.step){let i=e.steps[r].invert(e.docs[r]),c=t.selection&&t.selection.map(s.slice(a+1,r));c&&o++,n.push(new qw(l,i,c))}else n.push(new qw(l))},r);let l=[];for(let u=t;u<i;u++)l.push(new qw(s.maps[u]));let c=this.items.slice(0,r).append(l).append(n),d=new Uw(c,o);return d.emptyItemCount()>500&&(d=d.compress(this.items.length-n.length)),d}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=[],s=0;return this.items.forEach((i,o)=>{if(o>=e)r.push(i),i.selection&&s++;else if(i.step){let e=i.step.map(t.slice(n)),o=e&&e.getMap();if(n--,o&&t.appendMap(o,n),e){let a=i.selection&&i.selection.map(t.slice(n));a&&s++;let l,c=new qw(o.invert(),e,a),d=r.length-1;(l=r.length&&r[d].merge(c))?r[d]=l:r.push(c)}}else i.map&&n--},this.items.length,0),new Uw(Hw.from(r.reverse()),s)}}Uw.empty=new Uw(Hw.empty,0);class qw{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 qw(t.getMap().invert(),t,this.selection)}}}class Vw{constructor(e,t,n,r,s){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=r,this.prevComposition=s}}const Kw=20;function Ww(e){let t=[];for(let n=e.length-1;n>=0&&0==t.length;n--)e[n].forEach((e,n,r,s)=>t.push(r,s));return t}function Gw(e,t){if(!e)return null;let n=[];for(let r=0;r<e.length;r+=2){let s=t.map(e[r],1),i=t.map(e[r+1],-1);s<=i&&n.push(s,i)}return n}let Jw=!1,Zw=null;function Qw(e){let t=e.plugins;if(Zw!=t){Jw=!1,Zw=t;for(let e=0;e<t.length;e++)if(t[e].spec.historyPreserveItems){Jw=!0;break}}return Jw}function Xw(e){return e.setMeta(ex,!0)}const Yw=new bc("history"),ex=new bc("closeHistory");function tx(e={}){return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new fc({key:Yw,state:{init:()=>new Vw(Uw.empty,Uw.empty,null,0,-1),apply:(t,n,r)=>function(e,t,n,r){let s,i=n.getMeta(Yw);if(i)return i.historyState;n.getMeta(ex)&&(e=new Vw(e.done,e.undone,null,0,-1));let o=n.getMeta("appendedTransaction");if(0==n.steps.length)return e;if(o&&o.getMeta(Yw))return o.getMeta(Yw).redo?new Vw(e.done.addTransform(n,void 0,r,Qw(t)),e.undone,Ww(n.mapping.maps),e.prevTime,e.prevComposition):new Vw(e.done,e.undone.addTransform(n,void 0,r,Qw(t)),null,e.prevTime,e.prevComposition);if(!1===n.getMeta("addToHistory")||o&&!1===o.getMeta("addToHistory"))return(s=n.getMeta("rebased"))?new Vw(e.done.rebased(n,s),e.undone.rebased(n,s),Gw(e.prevRanges,n.mapping),e.prevTime,e.prevComposition):new Vw(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),Gw(e.prevRanges,n.mapping),e.prevTime,e.prevComposition);{let s=n.getMeta("composition"),i=0==e.prevTime||!o&&e.prevComposition!=s&&(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 s=0;s<t.length;s+=2)e<=t[s+1]&&r>=t[s]&&(n=!0)}),n}(n,e.prevRanges)),a=o?Gw(e.prevRanges,n.mapping):Ww(n.mapping.maps);return new Vw(e.done.addTransform(n,i?t.selection.getBookmark():void 0,r,Qw(t)),Uw.empty,a,n.time,null==s?e.prevComposition:s)}}(n,r,t,e)},config:e,props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,r="historyUndo"==n?rx:"historyRedo"==n?sx:null;return!!r&&(t.preventDefault(),r(e.state,e.dispatch))}}}})}function nx(e,t){return(n,r)=>{let s=Yw.getState(n);if(!s||0==(e?s.undone:s.done).eventCount)return!1;if(r){let i=function(e,t,n){let r=Qw(t),s=Yw.get(t).spec.config,i=(n?e.undone:e.done).popEvent(t,r);if(!i)return null;let o=i.selection.resolve(i.transform.doc),a=(n?e.done:e.undone).addTransform(i.transform,t.selection.getBookmark(),s,r),l=new Vw(n?a:i.remaining,n?i.remaining:a,null,0,-1);return i.transform.setSelection(o).setMeta(Yw,{redo:n,historyState:l})}(s,n,e);i&&r(t?i.scrollIntoView():i)}return!0}}const rx=nx(!1,!0),sx=nx(!0,!0);rm.create({name:"characterCount",addOptions:()=>({limit:null,mode:"textSize",textCounter:e=>e.length,wordCounter:e=>e.split(" ").filter(e=>""!==e).length}),addStorage:()=>({characters:()=>0,words:()=>0}),onBeforeCreate(){this.storage.characters=e=>{const t=(null==e?void 0:e.node)||this.editor.state.doc;if("textSize"===((null==e?void 0:e.mode)||this.options.mode)){const e=t.textBetween(0,t.content.size,void 0," ");return this.options.textCounter(e)}return t.nodeSize},this.storage.words=e=>{const 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 fc({key:new bc("characterCount"),appendTransaction:(t,n,r)=>{if(e)return;const s=this.options.limit;if(null==s||0===s)return void(e=!0);const i=this.storage.characters({node:r.doc});if(i>s){const t=0,n=i-s;console.warn(`[CharacterCount] Initial content exceeded limit of ${s} characters. Content was automatically trimmed.`);const o=r.tr.deleteRange(t,n);return e=!0,o}e=!0},filterTransaction:(e,t)=>{const n=this.options.limit;if(!e.docChanged||0===n||null==n)return!0;const r=this.storage.characters({node:t.doc}),s=this.storage.characters({node:e.doc});if(s<=n)return!0;if(r>n&&s>n&&s<=r)return!0;if(r>n&&s>n&&s>r)return!1;if(!e.getMeta("paste"))return!1;const i=e.selection.$head.pos,o=i-(s-n),a=i;e.deleteRange(o,a);return!(this.storage.characters({node:e.doc})>n)}})]}});var ix=rm.create({name:"dropCursor",addOptions:()=>({color:"currentColor",width:1,class:void 0}),addProseMirrorPlugins(){return[Ow(this.options)]}});rm.create({name:"focus",addOptions:()=>({className:"has-focus",mode:"all"}),addProseMirrorPlugins(){return[new fc({key:new bc("focus"),props:{decorations:({doc:e,selection:t})=>{const{isEditable:n,isFocused:r}=this.editor,{anchor:s}=t,i=[];if(!n||!r)return Dp.create(e,[]);let o=0;"deepest"===this.options.mode&&e.descendants((e,t)=>{if(e.isText)return;if(!(s>=t&&s<=t+e.nodeSize-1))return!1;o+=1});let a=0;return e.descendants((e,t)=>{if(e.isText)return!1;if(!(s>=t&&s<=t+e.nodeSize-1))return!1;a+=1;if("deepest"===this.options.mode&&o-a>0||"shallowest"===this.options.mode&&a>1)return"deepest"===this.options.mode;i.push(Ap.node(t,t+e.nodeSize,{class:this.options.className}))}),Dp.create(e,i)}}})]}});var ox=rm.create({name:"gapCursor",addProseMirrorPlugins:()=>[new fc({props:{decorations:jw,createSelectionBetween:(e,t,n)=>t.pos==n.pos&&Tw.valid(n)?new Tw(n):null,handleClick:Lw,handleKeyDown:Dw,handleDOMEvents:{beforeinput:Pw}}})],extendNodeSchema(e){var t;return{allowGapCursor:null!=(t=cf(sf(e,"allowGapCursor",{name:e.name,options:e.options,storage:e.storage})))?t:null}}}),ax=rm.create({name:"placeholder",addOptions:()=>({emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something \u2026",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}),addProseMirrorPlugins(){return[new fc({key:new bc("placeholder"),props:{decorations:({doc:e,selection:t})=>{const n=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:r}=t,s=[];if(!n)return null;const i=this.editor.isEmpty;return e.descendants((e,t)=>{const n=r>=t&&r<=t+e.nodeSize,o=!e.isLeaf&&$f(e);if((n||!this.options.showOnlyCurrent)&&o){const r=[this.options.emptyNodeClass];i&&r.push(this.options.emptyEditorClass);const o=Ap.node(t,t+e.nodeSize,{class:r.join(" "),"data-placeholder":"function"==typeof this.options.placeholder?this.options.placeholder({editor:this.editor,node:e,pos:t,hasAnchor:n}):this.options.placeholder});s.push(o)}return this.options.includeChildren}),Dp.create(e,s)}}})]}});function lx({types:e,node:t}){return t&&Array.isArray(e)&&e.includes(t.type)||(null==t?void 0:t.type)===e}rm.create({name:"selection",addOptions:()=>({className:"selection"}),addProseMirrorPlugins(){const{editor:e,options:t}=this;return[new fc({key:new bc("selection"),props:{decorations:n=>n.selection.empty||e.isFocused||!e.isEditable||Ff(n.selection)||e.view.dragging?null:Dp.create(n.doc,[Ap.inline(n.selection.from,n.selection.to,{class:t.className})])}})]}});var cx=rm.create({name:"trailingNode",addOptions:()=>({node:"paragraph",notAfter:[]}),addProseMirrorPlugins(){const e=new bc(this.name),t=Object.entries(this.editor.schema.nodes).map(([,e])=>e).filter(e=>(this.options.notAfter||[]).concat(this.options.node).includes(e.name));return[new fc({key:e,appendTransaction:(t,n,r)=>{const{doc:s,tr:i,schema:o}=r,a=e.getState(r),l=s.content.size,c=o.nodes[this.options.node];if(a)return i.insert(l,c.create())},state:{init:(e,n)=>!lx({node:n.tr.doc.lastChild,types:t}),apply:(e,n)=>{if(!e.docChanged)return n;return!lx({node:e.doc.lastChild,types:t})}}})]}}),dx=rm.create({name:"undoRedo",addOptions:()=>({depth:100,newGroupDelay:500}),addCommands:()=>({undo:()=>({state:e,dispatch:t})=>rx(e,t),redo:()=>({state:e,dispatch:t})=>sx(e,t)}),addProseMirrorPlugins(){return[tx(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-\u044f":()=>this.editor.commands.undo(),"Shift-Mod-\u044f":()=>this.editor.commands.redo()}}}),ux=ax,px=(e,t)=>{if("slot"===e)return 0;if(e instanceof Function)return e(t);const{children:n,...r}=null!=t?t:{};if("svg"===e)throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");return[e,r,n]},hx=/^\s*>\s$/,fx=Tg.create({name:"blockquote",addOptions:()=>({HTMLAttributes:{}}),content:"block+",group:"block",defining:!0,parseHTML:()=>[{tag:"blockquote"}],renderHTML({HTMLAttributes:e}){return px("blockquote",{...pf(this.options.HTMLAttributes,e),children:px("slot",{})})},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[Ag({find:hx,type:this.type})]}}),mx=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,gx=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,bx=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,yx=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,vx=Qf.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 px("strong",{...pf(this.options.HTMLAttributes,e),children:px("slot",{})})},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[Cg({find:mx,type:this.type}),Cg({find:bx,type:this.type})]},addPasteRules(){return[Dg({find:gx,type:this.type}),Dg({find:yx,type:this.type})]}}),wx=Tg.create({name:"doc",topNode:!0,content:"block+"}),xx=Tg.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}){return[`h${this.options.levels.includes(e.attrs.level)?e.attrs.level:this.options.levels[0]}`,pf(this.options.HTMLAttributes,t),0]},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=>Og({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${e}})\\s$`),type:this.type,getAttributes:{level:e}}))}}),kx=Tg.create({name:"horizontalRule",addOptions:()=>({HTMLAttributes:{},nextNodeType:"paragraph"}),group:"block",parseHTML:()=>[{tag:"hr"}],renderHTML({HTMLAttributes:e}){return["hr",pf(this.options.HTMLAttributes,e)]},addCommands(){return{setHorizontalRule:()=>({chain:e,state:t})=>{if(!function(e,t){const{selection:n}=e,{$from:r}=n;if(n instanceof tc){const e=r.index();return r.parent.canReplaceWith(e,e+1,t)}let s=r.depth;for(;s>=0;){const e=r.index(s);if(r.node(s).contentMatchAt(e).matchType(t))return!0;s-=1}return!1}(t,t.schema.nodes[this.name]))return!1;const{selection:n}=t,{$to:r}=n,s=e();return Ff(n)?s.insertContentAt(r.pos,{type:this.name}):s.insertContent({type:this.name}),s.command(({state:e,tr:t,dispatch:n})=>{if(n){const{$to:n}=t.selection,r=n.end();if(n.nodeAfter)n.nodeAfter.isTextblock?t.setSelection(Yl.create(t.doc,n.pos+1)):n.nodeAfter.isBlock?t.setSelection(tc.create(t.doc,n.pos)):t.setSelection(Yl.create(t.doc,n.pos));else{const s=e.schema.nodes[this.options.nextNodeType]||n.parent.type.contentMatch.defaultType,i=null==s?void 0:s.create();i&&(t.insert(r,i),t.setSelection(Yl.create(t.doc,r+1)))}t.scrollIntoView()}return!0}).run()}}},addInputRules(){return[(e={find:/^(?:---|\u2014-|___\s|\*\*\*\s)$/,type:this.type},new Kf({find:e.find,handler:({state:t,range:n,match:r})=>{const s=cf(e.getAttributes,void 0,r)||{},{tr:i}=t,o=n.from;let a=n.to;const l=e.type.create(s);if(r[1]){let e=o+r[0].lastIndexOf(r[1]);e>a?e=a:a=e+r[1].length;const t=r[0][r[0].length-1];i.insertText(t,o+r[0].length-1),i.replaceWith(e,a,l)}else if(r[0]){const t=e.type.isInline?o:o-1;i.insert(t,e.type.create(s)).delete(i.mapping.map(o),i.mapping.map(a))}i.scrollIntoView()},undoable:e.undoable}))];var e}}),Sx=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,Ex=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,Mx=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,_x=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,Nx=Qf.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",pf(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)}},addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[Cg({find:Sx,type:this.type}),Cg({find:Mx,type:this.type})]},addPasteRules(){return[Dg({find:Ex,type:this.type}),Dg({find:_x,type:this.type})]}}),Cx=Object.defineProperty,Ox="textStyle",Ax=/^\s*([-+*])\s$/,Tx=Tg.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",pf(this.options.HTMLAttributes,e),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(Ox)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let e=Ag({find:Ax,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(e=Ag({find:Ax,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Ox),editor:this.editor})),[e]}}),Ix=Tg.create({name:"listItem",addOptions:()=>({HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}),content:"paragraph block*",defining:!0,parseHTML:()=>[{tag:"li"}],renderHTML({HTMLAttributes:e}){return["li",pf(this.options.HTMLAttributes,e),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}});((e,t)=>{for(var n in t)Cx(e,n,{get:t[n],enumerable:!0})})({},{findListItemPos:()=>Dx,getNextListDepth:()=>Rx,handleBackspace:()=>Bx,handleDelete:()=>Fx,hasListBefore:()=>Lx,hasListItemAfter:()=>Hx,hasListItemBefore:()=>Px,listItemHasSubList:()=>jx,nextListIsDeeper:()=>zx,nextListIsHigher:()=>$x});var Dx=(e,t)=>{const{$from:n}=t.selection,r=Sf(e,t.schema);let s=null,i=n.depth,o=n.pos,a=null;for(;i>0&&null===a;)s=n.node(i),s.type===r?a=i:(i-=1,o-=1);return null===a?null:{$pos:t.doc.resolve(o),depth:a}},Rx=(e,t)=>{const n=Dx(e,t);if(!n)return!1;const[,r]=((e,t,n,r=20)=>{const s=e.doc.resolve(n);let i=r,o=null;for(;i>0&&null===o;){const e=s.node(i);(null==e?void 0:e.type.name)===t?o=e:i-=1}return[o,i]})(t,e,n.$pos.pos+4);return r},Lx=(e,t,n)=>{const{$anchor:r}=e.selection,s=Math.max(0,r.pos-2),i=e.doc.resolve(s).node();return!(!i||!n.includes(i.type.name))},Px=(e,t)=>{var n;const{$anchor:r}=t.selection,s=t.doc.resolve(r.pos-2);return 0!==s.index()&&(null==(n=s.nodeBefore)?void 0:n.type.name)===e},jx=(e,t,n)=>{if(!n)return!1;const r=Sf(e,t.schema);let s=!1;return n.descendants(e=>{e.type===r&&(s=!0)}),s},Bx=(e,t,n)=>{if(e.commands.undoInputRule())return!0;if(e.state.selection.from!==e.state.selection.to)return!1;if(!jf(e.state,t)&&Lx(e.state,t,n)){const{$anchor:n}=e.state.selection,r=e.state.doc.resolve(n.before()-1),s=[];r.node().descendants((e,n)=>{e.type.name===t&&s.push({node:e,pos:n})});const i=s.at(-1);if(!i)return!1;const o=e.state.doc.resolve(r.start()+i.pos+1);return e.chain().cut({from:n.start()-1,to:n.end()+1},o.end()).joinForward().run()}if(!jf(e.state,t))return!1;if(!(e=>{const{$from:t,$to:n}=e.selection;return!(t.parentOffset>0||t.pos!==n.pos)})(e.state))return!1;const r=Dx(t,e.state);if(!r)return!1;const s=e.state.doc.resolve(r.$pos.pos-2).node(r.depth),i=jx(t,e.state,s);return Px(t,e.state)&&!i?e.commands.joinItemBackward():e.chain().liftListItem(t).run()},zx=(e,t)=>{const n=Rx(e,t),r=Dx(e,t);return!(!r||!n)&&n>r.depth},$x=(e,t)=>{const n=Rx(e,t),r=Dx(e,t);return!(!r||!n)&&n<r.depth},Fx=(e,t)=>{if(!jf(e.state,t))return!1;if(!((e,t)=>{const{$from:n,$to:r,$anchor:s}=e.selection;if(t){const n=rf(e=>e.type.name===t)(e.selection);if(!n)return!1;const r=e.doc.resolve(n.pos+1);return s.pos+1===r.end()}return!(r.parentOffset<r.parent.nodeSize-2||n.pos!==r.pos)})(e.state,t))return!1;const{selection:n}=e.state,{$from:r,$to:s}=n;return!(!n.empty&&r.sameParent(s))&&(zx(t,e.state)?e.chain().focus(e.state.selection.from+4).lift(t).joinBackward().run():$x(t,e.state)?e.chain().joinForward().joinBackward().run():e.commands.joinItemForward())},Hx=(e,t)=>{var n;const{$anchor:r}=t.selection,s=t.doc.resolve(r.pos-r.parentOffset-2);return s.index()!==s.parent.childCount-1&&(null==(n=s.nodeAfter)?void 0:n.type.name)===e},Ux=rm.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]&&Fx(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]&&Fx(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]&&Bx(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]&&Bx(e,n,r)&&(t=!0)}),t}}}}),qx="textStyle",Vx=/^(\d+)\.\s$/,Kx=Tg.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}){const{start:t,...n}=e;return 1===t?["ol",pf(this.options.HTMLAttributes,n),0]:["ol",pf(this.options.HTMLAttributes,e),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(qx)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let e=Ag({find:Vx,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=Ag({find:Vx,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(qx)}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1],editor:this.editor})),[e]}}),Wx=/^\s*(\[([( |x])?\])\s$/,Gx=Tg.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=>{const 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",pf(this.options.HTMLAttributes,t,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:e.attrs.checked?"checked":null}],["span"]],["div",0]]},addKeyboardShortcuts(){const 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})=>{const s=document.createElement("li"),i=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"}`};return c(e),i.contentEditable="false",a.type="checkbox",a.addEventListener("mousedown",e=>e.preventDefault()),a.addEventListener("change",t=>{if(!r.isEditable&&!this.options.onReadOnlyChecked)return void(a.checked=!a.checked);const{checked:s}=t.target;r.isEditable&&"function"==typeof n&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:e})=>{const t=n();if("number"!=typeof t)return!1;const r=e.doc.nodeAt(t);return e.setNodeMarkup(t,void 0,{...null==r?void 0:r.attrs,checked:s}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(e,s)||(a.checked=!a.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([e,t])=>{s.setAttribute(e,t)}),s.dataset.checked=e.attrs.checked,a.checked=e.attrs.checked,i.append(a,o),s.append(i,l),Object.entries(t).forEach(([e,t])=>{s.setAttribute(e,t)}),{dom:s,contentDOM:l,update:e=>e.type===this.type&&(s.dataset.checked=e.attrs.checked,a.checked=e.attrs.checked,c(e),!0)}}},addInputRules(){return[Ag({find:Wx,type:this.type,getAttributes:e=>({checked:"x"===e[e.length-1]})})]}}),Jx=Tg.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",pf(this.options.HTMLAttributes,e,{"data-type":this.name}),0]},addCommands(){return{toggleTaskList:()=>({commands:e})=>e.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});rm.create({name:"listKit",addExtensions(){const e=[];return!1!==this.options.bulletList&&e.push(Tx.configure(this.options.bulletList)),!1!==this.options.listItem&&e.push(Ix.configure(this.options.listItem)),!1!==this.options.listKeymap&&e.push(Ux.configure(this.options.listKeymap)),!1!==this.options.orderedList&&e.push(Kx.configure(this.options.orderedList)),!1!==this.options.taskItem&&e.push(Gx.configure(this.options.taskItem)),!1!==this.options.taskList&&e.push(Jx.configure(this.options.taskList)),e}});var Zx=Tg.create({name:"paragraph",priority:1e3,addOptions:()=>({HTMLAttributes:{}}),group:"block",content:"inline*",parseHTML:()=>[{tag:"p"}],renderHTML({HTMLAttributes:e}){return["p",pf(this.options.HTMLAttributes,e),0]},addCommands(){return{setParagraph:()=>({commands:e})=>e.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),Qx=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,Xx=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,Yx=Qf.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",pf(this.options.HTMLAttributes,e),0]},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[Cg({find:Qx,type:this.type})]},addPasteRules(){return[Dg({find:Xx,type:this.type})]}}),ek=Tg.create({name:"text",group:"inline"}),tk=Qf.create({name:"underline",addOptions:()=>({HTMLAttributes:{}}),parseHTML:()=>[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:e=>!!e.includes("underline")&&{}}],renderHTML({HTMLAttributes:e}){return["u",pf(this.options.HTMLAttributes,e),0]},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()}}}),nk=rm.create({name:"starterKit",addExtensions(){var e,t,n,r;const s=[];return!1!==this.options.bold&&s.push(vx.configure(this.options.bold)),!1!==this.options.blockquote&&s.push(fx.configure(this.options.blockquote)),!1!==this.options.bulletList&&s.push(Tx.configure(this.options.bulletList)),!1!==this.options.code&&s.push(my.configure(this.options.code)),!1!==this.options.codeBlock&&s.push(vy.configure(this.options.codeBlock)),!1!==this.options.document&&s.push(wx.configure(this.options.document)),!1!==this.options.dropcursor&&s.push(ix.configure(this.options.dropcursor)),!1!==this.options.gapcursor&&s.push(ox.configure(this.options.gapcursor)),!1!==this.options.hardBreak&&s.push(Cy.configure(this.options.hardBreak)),!1!==this.options.heading&&s.push(xx.configure(this.options.heading)),!1!==this.options.undoRedo&&s.push(dx.configure(this.options.undoRedo)),!1!==this.options.horizontalRule&&s.push(kx.configure(this.options.horizontalRule)),!1!==this.options.italic&&s.push(Nx.configure(this.options.italic)),!1!==this.options.listItem&&s.push(Ix.configure(this.options.listItem)),!1!==this.options.listKeymap&&s.push(Ux.configure(null==(e=this.options)?void 0:e.listKeymap)),!1!==this.options.link&&s.push(Nw.configure(null==(t=this.options)?void 0:t.link)),!1!==this.options.orderedList&&s.push(Kx.configure(this.options.orderedList)),!1!==this.options.paragraph&&s.push(Zx.configure(this.options.paragraph)),!1!==this.options.strike&&s.push(Yx.configure(this.options.strike)),!1!==this.options.text&&s.push(ek.configure(this.options.text)),!1!==this.options.underline&&s.push(tk.configure(null==(n=this.options)?void 0:n.underline)),!1!==this.options.trailingNode&&s.push(cx.configure(null==(r=this.options)?void 0:r.trailingNode)),s}});const rk=new bc("inputAutocomplete"),sk=()=>({decoration:null,completion:null}),ik=(e,t)=>Jl.atEnd(e).$anchor.pos===t.$anchor.pos,ok=({editor:e})=>{if(!ik(e.state.doc,e.state.selection))return!1;const t=rk.getState(e.state);return!!t.decoration&&(e.view.dispatch(e.state.tr.insertText(t.completion.content)),!0)},ak=(e,t,n,r)=>{const s=e.getMeta(rk);if(s&&s.prompt===r.doc.textContent&&(t.completion=s),!ik(r.doc,r.selection))return t.decoration=null,t;if(!t.completion)return t.decoration=null,t;if(t.completion.prompt!==r.doc.textContent)return t.decoration=null,t;const i=document.createElement("span");i.className="text-text-500",i.textContent=t.completion.content;const o=document.createElement("span");o.className="ml-1 px-1 border rounded-lg align-[1px] font-medium text-xs text-text-500",o.textContent="Tab",o.setAttribute("aria-hidden","true");const a=r.selection.$head.pos,l=Ap.widget(a,i),c=Ap.widget(a,o),d=Dp.create(r.doc,[l,c]);return t.decoration=d,t},lk=rm.create({name:"inputAutocompletion",addOptions:()=>({fetchInputAutocompletion:e=>Promise.resolve("")}),addProseMirrorPlugins(){const e=nr(async(e,t)=>{try{const n=this.options.fetchInputAutocompletion,r=await n(t);r&&e.dispatch(e.state.tr.setMeta(rk,{prompt:t,content:r}))}catch{}},300);return[new fc({key:rk,state:{init:sk,apply:ak},props:{decorations(e){return this.getState(e).decoration}},view:t=>{const{textContent:n}=t.state.doc;return n.length>=3&&e(t,n),{update:(t,n)=>{const{state:r}=t,{doc:s}=r;if(n.doc.eq(s))return;const i=rk.getState(r);i.completion?.prompt!==s.textContent&&s.textContent.length>=3&&e(t,s.textContent)}}}})]},addKeyboardShortcuts:()=>({Tab:ok})});const ck=["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","p","q","quote","samp","section","span","strong","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","ul","var","video"],dk=["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"],uk=["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"],pk=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"],hk=["align-content","align-items","align-self","all","animation","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-timing-function","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-repeat","background-size","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-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-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-decoration-break","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","caret-color","clear","clip","clip-path","clip-rule","color","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","contain","content","content-visibility","counter-increment","counter-reset","cue","cue-after","cue-before","cursor","direction","display","empty-cells","filter","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","flow","font","font-display","font-family","font-feature-settings","font-kerning","font-language-override","font-size","font-size-adjust","font-smoothing","font-stretch","font-style","font-synthesis","font-variant","font-variant-caps","font-variant-east-asian","font-variant-ligatures","font-variant-numeric","font-variant-position","font-variation-settings","font-weight","gap","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","hyphens","icon","image-orientation","image-rendering","image-resolution","ime-mode","inline-size","isolation","justify-content","left","letter-spacing","line-break","line-height","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","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","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","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-wrap","overflow-x","overflow-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-break-after","page-break-before","page-break-inside","pause","pause-after","pause-before","perspective","perspective-origin","pointer-events","position","quotes","resize","rest","rest-after","rest-before","right","row-gap","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","scrollbar-color","scrollbar-gutter","scrollbar-width","shape-image-threshold","shape-margin","shape-outside","speak","speak-as","src","tab-size","table-layout","text-align","text-align-all","text-align-last","text-combine-upright","text-decoration","text-decoration-color","text-decoration-line","text-decoration-style","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-indent","text-justify","text-orientation","text-overflow","text-rendering","text-shadow","text-transform","text-underline-position","top","transform","transform-box","transform-origin","transform-style","transition","transition-delay","transition-duration","transition-property","transition-timing-function","unicode-bidi","vertical-align","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","white-space","widows","width","will-change","word-break","word-spacing","word-wrap","writing-mode","z-index"].reverse();var fk="[0-9](_*[0-9])*",mk=`\\.(${fk})`,gk="[0-9a-fA-F](_*[0-9a-fA-F])*",bk={className:"number",variants:[{begin:`(\\b(${fk})((${mk})|\\.)?|(${mk}))[eE][+-]?(${fk})[fFdD]?\\b`},{begin:`\\b(${fk})((${mk})[fFdD]?\\b|\\.([fFdD]\\b)?)`},{begin:`(${mk})[fFdD]?\\b`},{begin:`\\b(${fk})[fFdD]\\b`},{begin:`\\b0[xX]((${gk})\\.?|(${gk})?\\.(${gk}))[pP][+-]?(${fk})[fFdD]?\\b`},{begin:"\\b(0|[1-9](_*[0-9])*)[lL]?\\b"},{begin:`\\b0[xX](${gk})[lL]?\\b`},{begin:"\\b0(_*[0-7])*[lL]?\\b"},{begin:"\\b0[bB][01](_*[01])*[lL]?\\b"}],relevance:0};function yk(e,t,n){return-1===n?"":e.replace(t,r=>yk(e,t,n-1))}const vk="[A-Za-z$_][0-9A-Za-z$_]*",wk=["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"],xk=["true","false","null","undefined","NaN","Infinity"],kk=["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"],Sk=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],Ek=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],Mk=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],_k=[].concat(Ek,kk,Sk);var Nk="[0-9](_*[0-9])*",Ck=`\\.(${Nk})`,Ok="[0-9a-fA-F](_*[0-9a-fA-F])*",Ak={className:"number",variants:[{begin:`(\\b(${Nk})((${Ck})|\\.)?|(${Ck}))[eE][+-]?(${Nk})[fFdD]?\\b`},{begin:`\\b(${Nk})((${Ck})[fFdD]?\\b|\\.([fFdD]\\b)?)`},{begin:`(${Ck})[fFdD]?\\b`},{begin:`\\b(${Nk})[fFdD]\\b`},{begin:`\\b0[xX]((${Ok})\\.?|(${Ok})?\\.(${Ok}))[pP][+-]?(${Nk})[fFdD]?\\b`},{begin:"\\b(0|[1-9](_*[0-9])*)[lL]?\\b"},{begin:`\\b0[xX](${Ok})[lL]?\\b`},{begin:"\\b0(_*[0-7])*[lL]?\\b"},{begin:"\\b0[bB][01](_*[01])*[lL]?\\b"}],relevance:0};const Tk=["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","p","q","quote","samp","section","span","strong","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","ul","var","video"],Ik=["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"],Dk=["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"],Rk=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"],Lk=["align-content","align-items","align-self","all","animation","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-timing-function","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-repeat","background-size","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-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-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-decoration-break","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","caret-color","clear","clip","clip-path","clip-rule","color","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","contain","content","content-visibility","counter-increment","counter-reset","cue","cue-after","cue-before","cursor","direction","display","empty-cells","filter","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","flow","font","font-display","font-family","font-feature-settings","font-kerning","font-language-override","font-size","font-size-adjust","font-smoothing","font-stretch","font-style","font-synthesis","font-variant","font-variant-caps","font-variant-east-asian","font-variant-ligatures","font-variant-numeric","font-variant-position","font-variation-settings","font-weight","gap","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","hyphens","icon","image-orientation","image-rendering","image-resolution","ime-mode","inline-size","isolation","justify-content","left","letter-spacing","line-break","line-height","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","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","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","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-wrap","overflow-x","overflow-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-break-after","page-break-before","page-break-inside","pause","pause-after","pause-before","perspective","perspective-origin","pointer-events","position","quotes","resize","rest","rest-after","rest-before","right","row-gap","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","scrollbar-color","scrollbar-gutter","scrollbar-width","shape-image-threshold","shape-margin","shape-outside","speak","speak-as","src","tab-size","table-layout","text-align","text-align-all","text-align-last","text-combine-upright","text-decoration","text-decoration-color","text-decoration-line","text-decoration-style","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-indent","text-justify","text-orientation","text-overflow","text-rendering","text-shadow","text-transform","text-underline-position","top","transform","transform-box","transform-origin","transform-style","transition","transition-delay","transition-duration","transition-property","transition-timing-function","unicode-bidi","vertical-align","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","white-space","widows","width","will-change","word-break","word-spacing","word-wrap","writing-mode","z-index"].reverse(),Pk=Dk.concat(Rk);const jk=["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","p","q","quote","samp","section","span","strong","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","ul","var","video"],Bk=["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"],zk=["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"],$k=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"],Fk=["align-content","align-items","align-self","all","animation","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-timing-function","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-repeat","background-size","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-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-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-decoration-break","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","caret-color","clear","clip","clip-path","clip-rule","color","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","contain","content","content-visibility","counter-increment","counter-reset","cue","cue-after","cue-before","cursor","direction","display","empty-cells","filter","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","flow","font","font-display","font-family","font-feature-settings","font-kerning","font-language-override","font-size","font-size-adjust","font-smoothing","font-stretch","font-style","font-synthesis","font-variant","font-variant-caps","font-variant-east-asian","font-variant-ligatures","font-variant-numeric","font-variant-position","font-variation-settings","font-weight","gap","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","hyphens","icon","image-orientation","image-rendering","image-resolution","ime-mode","inline-size","isolation","justify-content","left","letter-spacing","line-break","line-height","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","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","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","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-wrap","overflow-x","overflow-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-break-after","page-break-before","page-break-inside","pause","pause-after","pause-before","perspective","perspective-origin","pointer-events","position","quotes","resize","rest","rest-after","rest-before","right","row-gap","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","scrollbar-color","scrollbar-gutter","scrollbar-width","shape-image-threshold","shape-margin","shape-outside","speak","speak-as","src","tab-size","table-layout","text-align","text-align-all","text-align-last","text-combine-upright","text-decoration","text-decoration-color","text-decoration-line","text-decoration-style","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-indent","text-justify","text-orientation","text-overflow","text-rendering","text-shadow","text-transform","text-underline-position","top","transform","transform-box","transform-origin","transform-style","transition","transition-delay","transition-duration","transition-property","transition-timing-function","unicode-bidi","vertical-align","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","white-space","widows","width","will-change","word-break","word-spacing","word-wrap","writing-mode","z-index"].reverse();function Hk(e){return e?"string"==typeof e?e:e.source:null}function Uk(e){return qk("(?=",e,")")}function qk(...e){return e.map(e=>Hk(e)).join("")}function Vk(...e){const t=function(e){const t=e[e.length-1];return"object"==typeof t&&t.constructor===Object?(e.splice(e.length-1,1),t):{}}(e);return"("+(t.capture?"":"?:")+e.map(e=>Hk(e)).join("|")+")"}const Kk=e=>qk(/\b/,e,/\w$/.test(e)?/\b/:/\B/),Wk=["Protocol","Type"].map(Kk),Gk=["init","self"].map(Kk),Jk=["Any","Self"],Zk=["actor","any","associatedtype","async","await",/as\?/,/as!/,"as","break","case","catch","class","continue","convenience","default","defer","deinit","didSet","distributed","do","dynamic","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","mutating","nonmutating",/open\(set\)/,"open","operator","optional","override","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"],Qk=["false","nil","true"],Xk=["assignment","associativity","higherThan","left","lowerThan","none","right"],Yk=["#colorLiteral","#column","#dsohandle","#else","#elseif","#endif","#error","#file","#fileID","#fileLiteral","#filePath","#function","#if","#imageLiteral","#keyPath","#line","#selector","#sourceLocation","#warn_unqualified_access","#warning"],eS=["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"],tS=Vk(/[/=\-+!*%<>&|^~?]/,/[\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]/),nS=Vk(tS,/[\u0300-\u036F]/,/[\u1DC0-\u1DFF]/,/[\u20D0-\u20FF]/,/[\uFE00-\uFE0F]/,/[\uFE20-\uFE2F]/),rS=qk(tS,nS,"*"),sS=Vk(/[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]/),iS=Vk(sS,/\d/,/[\u0300-\u036F\u1DC0-\u1DFF\u20D0-\u20FF\uFE20-\uFE2F]/),oS=qk(sS,iS,"*"),aS=qk(/[A-Z]/,iS,"*"),lS=["autoclosure",qk(/convention\(/,Vk("swift","block","c"),/\)/),"discardableResult","dynamicCallable","dynamicMemberLookup","escaping","frozen","GKInspectable","IBAction","IBDesignable","IBInspectable","IBOutlet","IBSegueAction","inlinable","main","nonobjc","NSApplicationMain","NSCopying","NSManaged",qk(/objc\(/,oS,/\)/),"objc","objcMembers","propertyWrapper","requires_stored_property_inits","resultBuilder","testable","UIApplicationMain","unknown","usableFromInline"],cS=["iOS","iOSApplicationExtension","macOS","macOSApplicationExtension","macCatalyst","macCatalystApplicationExtension","watchOS","watchOSApplicationExtension","tvOS","tvOSApplicationExtension","swift"];const dS="[A-Za-z$_][0-9A-Za-z$_]*",uS=["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"],pS=["true","false","null","undefined","NaN","Infinity"],hS=["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"],fS=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],mS=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],gS=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],bS=[].concat(mS,hS,fS);var yS,vS=(po||(po=1,yS=ho,function(){var e;function t(e){for(var t,n,r,s,i=1,o=[].slice.call(arguments),a=0,l=e.length,c="",d=!1,u=!1,p=function(){return o[i++]},h=function(){for(var n="";/\d/.test(e[a]);)n+=e[a++],t=e[a];return n.length>0?parseInt(n):null};a<l;++a)if(t=e[a],d)switch(d=!1,"."==t?(u=!1,t=e[++a]):"0"==t&&"."==e[a+1]?(u=!0,t=e[a+=2]):u=!0,s=h(),t){case"b":c+=parseInt(p(),10).toString(2);break;case"c":c+="string"==typeof(n=p())||n instanceof String?n:String.fromCharCode(parseInt(n,10));break;case"d":c+=parseInt(p(),10);break;case"f":r=String(parseFloat(p()).toFixed(s||6)),c+=u?r:r.replace(/^0/,"");break;case"j":c+=JSON.stringify(p());break;case"o":c+="0"+parseInt(p(),10).toString(8);break;case"s":c+=p();break;case"x":c+="0x"+parseInt(p(),10).toString(16);break;case"X":c+="0x"+parseInt(p(),10).toString(16).toUpperCase();break;default:c+=t}else"%"===t?d=!0:c+=t;return c}(e=yS.exports=t).format=t,e.vsprintf=function(e,n){return t.apply(null,[e].concat(n))},"undefined"!=typeof console&&"function"==typeof console.log&&(e.printf=function(){console.log(t.apply(null,arguments))})}()),ho.exports);const wS=s(vS),xS=Object.assign(kS(Error),{eval:kS(EvalError),range:kS(RangeError),reference:kS(ReferenceError),syntax:kS(SyntaxError),type:kS(TypeError),uri:kS(URIError)});function kS(e){return t.displayName=e.displayName||e.name,t;function t(t,...n){const r=t?wS(t,...n):t;return new e(r)}}const SS={}.hasOwnProperty;function ES(e,t,n={}){let r=n.prefix;if("string"!=typeof e)throw xS("Expected `string` for name, got `%s`",e);if(!ky.getLanguage(e))throw xS("Unknown language: `%s` is not registered",e);if("string"!=typeof t)throw xS("Expected `string` for value, got `%s`",t);null==r&&(r="hljs-"),ky.configure({__emitter:MS,classPrefix:r});const s=ky.highlight(t,{language:e,ignoreIllegals:!0});if(ky.configure({}),s.errorRaised)throw s.errorRaised;return s._emitter.root.data.language=s.language,s._emitter.root.data.relevance=s.relevance,s._emitter.root}class MS{constructor(e){this.options=e,this.root={type:"root",data:{language:null,relevance:0},children:[]},this.stack=[this.root]}addText(e){if(""===e)return;const 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){const 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){const t=e.split(".").map((e,t)=>t?e+"_".repeat(t):this.options.classPrefix+e),n={type:"element",tagName:"span",properties:{className:t},children:[]};this.stack[this.stack.length-1].children.push(n),this.stack.push(n)}closeNode(){this.stack.pop()}finalize(){}toHTML(){return""}}const _S={highlight:ES,highlightAuto:function(e,t={}){const n=t.subset||ky.listLanguages();t.prefix;let r=-1,s={type:"root",data:{language:null,relevance:0},children:[]};if("string"!=typeof e)throw xS("Expected `string` for value, got `%s`",e);for(;++r<n.length;){const i=n[r];if(!ky.getLanguage(i))continue;const o=ES(i,e,t);o.data.relevance>s.data.relevance&&(s=o)}return s},registerLanguage:function(e,t){ky.registerLanguage(e,t)},registered:function(e){return Boolean(ky.getLanguage(e))},listLanguages:function(){return ky.listLanguages()},registerAlias:function(e,t){if("string"==typeof e)ky.registerAliases(t,{languageName:e});else{let t;for(t in e)SS.call(e,t)&&ky.registerAliases(e[t],{languageName:t})}}};_S.registerLanguage("arduino",function(e){const t={type:["boolean","byte","word","String"],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"],_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"],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"]},n=function(e){const t=e.regex,n=e.COMMENT("//","$",{contains:[{begin:/\\\n/}]}),r="decltype\\(auto\\)",s="[a-zA-Z_]\\w*::",i="(?!struct)("+r+"|"+t.optional(s)+"[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:"\\b(0b[01']+)"},{begin:"(-?)\\b([\\d']+(\\.[\\d']*)?|\\.[\\d']+)((ll|LL|l|L)(u|U)?|(u|U)(ll|LL|l|L)?|f|F|b|B)"},{begin:"(-?)(\\b0[xX][a-fA-F0-9']+|(\\b[\\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 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(s)+e.IDENT_RE,relevance:0},u=t.optional(s)+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","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:"("+i+"[\\*&\\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)\\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"}}])}}(e),r=n.keywords;return r.type=[...r.type,...t.type],r.literal=[...r.literal,...t.literal],r.built_in=[...r.built_in,...t.built_in],r._hints=t._hints,n.name="Arduino",n.aliases=["ino"],n.supersetOf="cpp",n}),_S.registerLanguage("bash",function(e){const t=e.regex,n={},r={begin:/\$\{/,end:/\}/,contains:["self",{begin:/:-/,contains:[n]}]};Object.assign(n,{className:"variable",variants:[{begin:t.concat(/\$[\w\d#@][\w\d_]*/,"(?![\\w\\d])(?![$])")},r]});const s={className:"subst",begin:/\$\(/,end:/\)/,contains:[e.BACKSLASH_ESCAPE]},i={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,s]};s.contains.push(o);const 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"].join("|")})`,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"],keywords:{$pattern:/\b[a-z][a-z0-9._-]+\b/,keyword:["if","then","else","elif","fi","for","while","until","in","do","done","case","esac","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","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,e.HASH_COMMENT_MODE,i,{match:/(\/[a-z._-]+)+/},o,{className:"",begin:/\\"/},{className:"string",begin:/'/,end:/'/},n]}}),_S.registerLanguage("c",function(e){const t=e.regex,n=e.COMMENT("//","$",{contains:[{begin:/\\\n/}]}),r="decltype\\(auto\\)",s="[a-zA-Z_]\\w*::",i="("+r+"|"+t.optional(s)+"[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:[{begin:"\\b(0b[01']+)"},{begin:"(-?)\\b([\\d']+(\\.[\\d']*)?|\\.[\\d']+)((ll|LL|l|L)(u|U)?|(u|U)(ll|LL|l|L)?|f|F|b|B)"},{begin:"(-?)(\\b0[xX][a-fA-F0-9']+|(\\b[\\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 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(s)+e.IDENT_RE,relevance:0},u=t.optional(s)+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","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","_Complex","_Imaginary","_Decimal32","_Decimal64","_Decimal128","const","static","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:"("+i+"[\\*&\\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}}}),_S.registerLanguage("cpp",function(e){const t=e.regex,n=e.COMMENT("//","$",{contains:[{begin:/\\\n/}]}),r="decltype\\(auto\\)",s="[a-zA-Z_]\\w*::",i="(?!struct)("+r+"|"+t.optional(s)+"[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:"\\b(0b[01']+)"},{begin:"(-?)\\b([\\d']+(\\.[\\d']*)?|\\.[\\d']+)((ll|LL|l|L)(u|U)?|(u|U)(ll|LL|l|L)?|f|F|b|B)"},{begin:"(-?)(\\b0[xX][a-fA-F0-9']+|(\\b[\\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 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(s)+e.IDENT_RE,relevance:0},u=t.optional(s)+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","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:"("+i+"[\\*&\\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)\\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"}}])}}),_S.registerLanguage("csharp",function(e){const 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","async","await","by","descending","equals","from","get","global","group","init","into","join","let","nameof","not","notnull","on","or","orderby","partial","remove","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},s={className:"string",begin:'@"',end:'"',contains:[{begin:'""'}]},i=e.inherit(s,{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,s,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,r,e.C_BLOCK_COMMENT_MODE],a.contains=[d,l,i,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,r,e.inherit(e.C_BLOCK_COMMENT_MODE,{illegal:/\n/})];const u={variants:[c,l,s,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:"\x3c!--|--\x3e"},{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"].join(" "),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]}}),_S.registerLanguage("css",function(e){const t=e.regex,n=(e=>({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_-]*/}}))(e),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:":("+uk.join("|")+")"},{begin:":(:)?("+pk.join("|")+")"}]},n.CSS_VARIABLE,{className:"attribute",begin:"\\b("+hk.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:dk.join(" ")},contains:[{begin:/[a-z-]+(?=:)/,className:"attribute"},...r,n.CSS_NUMBER_MODE]}]},{className:"selector-tag",begin:"\\b("+ck.join("|")+")\\b"}]}}),_S.registerLanguage("diff",function(e){const 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:/$/}]}}),_S.registerLanguage("go",function(e){const 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:[{begin:e.C_NUMBER_RE+"[i]",relevance:1},e.C_NUMBER_MODE]},{begin:/:=/},{className:"function",beginKeywords:"func",end:"\\s*(\\{|$)",excludeEnd:!0,contains:[e.TITLE_MODE,{className:"params",begin:/\(/,end:/\)/,endsParent:!0,keywords:t,illegal:/["']/}]}]}}),_S.registerLanguage("graphql",function(e){const 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/]}}),_S.registerLanguage("ini",function(e){const 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:/$/}];const s={className:"variable",variants:[{begin:/\$[\w\d"][\w\d_]*/},{begin:/\$\{(.*?)\}/}]},i={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={begin:/\[/,end:/\]/,contains:[r,i,s,o,n,"self"],relevance:0},l=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(l,"(\\s*\\.\\s*",l,")*",t.lookahead(/\s*=\s*[^#\s]/)),className:"attr",starts:{end:/$/,contains:[r,a,i,s,o,n]}}]}}),_S.registerLanguage("java",function(e){const t=e.regex,n="[\xc0-\u02b8a-zA-Z_$][\xc0-\u02b8a-zA-Z_$0-9]*",r=n+yk("(?:<"+n+"~~~(?:\\s*,\\s*"+n+"~~~)*>)?",/~~~/g,2),s={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"],literal:["false","true","null"],type:["char","boolean","long","float","int","byte","short","double"],built_in:["super","this"]},i={className:"meta",begin:"@"+n,contains:[{begin:/\(/,end:/\)/,contains:["self"]}]},o={className:"params",begin:/\(/,end:/\)/,keywords:s,relevance:0,contains:[e.C_BLOCK_COMMENT_MODE],endsParent:!0};return{name:"Java",aliases:["jsp"],keywords:s,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:s,contains:[{className:"params",begin:/\(/,end:/\)/,keywords:s,relevance:0,contains:[i,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,bk,e.C_BLOCK_COMMENT_MODE]},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},bk,i]}}),_S.registerLanguage("javascript",function(e){const t=e.regex,n=vk,r="<>",s="</>",i={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(e,t)=>{const n=e[0].length+e.index,r=e.input[n];if("<"===r||","===r)return void t.ignoreMatch();let s;">"===r&&(((e,{after:t})=>{const n="</"+e[0].slice(1);return-1!==e.input.indexOf(n,t)})(e,{after:n})||t.ignoreMatch());const i=e.input.substring(n);((s=i.match(/^\s*=/))||(s=i.match(/^\s+extends\s+/))&&0===s.index)&&t.ignoreMatch()}},o={$pattern:vk,keyword:wk,literal:xk,built_in:_k,"variable.language":Mk},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:n+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),e.C_BLOCK_COMMENT_MODE,e.C_LINE_COMMENT_MODE]},b=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,p,h,f,m,{match:/\$\d+/},d];u.contains=b.concat({begin:/\{/,end:/\}/,keywords:o,contains:["self"].concat(b)});const y=[].concat(g,u.contains),v=y.concat([{begin:/\(/,end:/\)/,keywords:o,contains:["self"].concat(y)}]),w={className:"params",begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:o,contains:v},x={variants:[{match:[/class/,/\s+/,n,/\s+/,/extends/,/\s+/,t.concat(n,"(",t.concat(/\./,n),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,n],scope:{1:"keyword",3:"title.class"}}]},k={relevance:0,match:t.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:{_:[...kk,...Sk]}},S={variants:[{match:[/function/,/\s+/,n,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[w],illegal:/%/},E={match:t.concat(/\b/,(M=[...Ek,"super","import"],t.concat("(?!",M.join("|"),")")),n,t.lookahead(/\(/)),className:"title.function",relevance:0};var M;const _={begin:t.concat(/\./,t.lookahead(t.concat(n,/(?![0-9A-Za-z$_(])/))),end:n,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},N={match:[/get|set/,/\s+/,n,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},w]},C="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",O={match:[/const|var|let/,/\s+/,n,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(C)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[w]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:o,exports:{PARAMS_CONTAINS:v,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,{className:"attr",begin:n+t.lookahead(":"),relevance:0},O,{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:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:o,contains:v}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:r,end:s},{match:/<[A-Za-z0-9\\._:-]+\s*\/>/},{begin:i.begin,"on:begin":i.isTrulyOpeningTag,end:i.end}],subLanguage:"xml",contains:[{begin:i.begin,end:i.end,skip:!0,contains:["self"]}]}]},S,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+e.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[w,e.inherit(e.TITLE_MODE,{begin:n,className:"title.function"})]},{match:/\.\.\./,relevance:0},_,{match:"\\$"+n,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[w]},E,{relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"},x,N,{match:/\$[(.]/}]}}),_S.registerLanguage("json",function(e){const t=["true","false","null"],n={scope:"literal",beginKeywords:t.join(" ")};return{name:"JSON",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"}}),_S.registerLanguage("kotlin",function(e){const 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]},s={className:"variable",begin:"\\$"+e.UNDERSCORE_IDENT_RE},i={className:"string",variants:[{begin:'"""',end:'"""(?=[^"])',contains:[s,r]},{begin:"'",end:"'",illegal:/\n/,contains:[e.BACKSLASH_ESCAPE]},{begin:'"',end:'"',illegal:/\n/,contains:[e.BACKSLASH_ESCAPE,s,r]}]};r.contains.push(i);const 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(i,{className:"string"}),"self"]}]},l=Ak,c=e.COMMENT("/\\*","\\*/",{contains:[e.C_BLOCK_COMMENT_MODE]}),d={variants:[{className:"type",begin:e.UNDERSCORE_IDENT_RE},{begin:/\(/,end:/\)/,contains:[]}]},u=d;return u.variants[1].contains=[d],d.variants[1].contains=[u],{name:"Kotlin",aliases:["kt","kts"],keywords:t,contains:[e.COMMENT("/\\*\\*","\\*/",{relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"}]}),e.C_LINE_COMMENT_MODE,c,{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:[d,e.C_LINE_COMMENT_MODE,c],relevance:0},e.C_LINE_COMMENT_MODE,c,o,a,i,e.C_NUMBER_MODE]},c]},{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]},i,{className:"meta",begin:"^#!/usr/bin/env",end:"$",illegal:"\n"},l]}}),_S.registerLanguage("less",function(e){const t=(e=>({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_-]*/}}))(e),n=Pk,r="[\\w-]+",s="("+r+"|@\\{"+r+"\\})",i=[],o=[],a=function(e){return{className:"string",begin:"~?"+e+".*?"+e}},l=function(e,t,n){return{className:e,begin:t,relevance:n}},c={$pattern:/[a-z-]+/,keyword:"and or not only",attribute:Ik.join(" ")},d={begin:"\\(",end:"\\)",contains:o,keywords:c,relevance:0};o.push(e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,a("'"),a('"'),t.CSS_NUMBER_MODE,{begin:"(url|data-uri)\\(",starts:{className:"string",end:"[\\)\\n]",excludeEnd:!0}},t.HEXCOLOR,d,l("variable","@@?"+r,10),l("variable","@\\{"+r+"\\}"),l("built_in","~?`[^`]*?`"),{className:"attribute",begin:r+"\\s*:",end:":",returnBegin:!0,excludeEnd:!0},t.IMPORTANT,{beginKeywords:"and not"},t.FUNCTION_DISPATCH);const u=o.concat({begin:/\{/,end:/\}/,contains:i}),p={beginKeywords:"when",endsWithParent:!0,contains:[{beginKeywords:"and not"}].concat(o)},h={begin:s+"\\s*:",returnBegin:!0,end:/[;}]/,relevance:0,contains:[{begin:/-(webkit|moz|ms|o)-/},t.CSS_VARIABLE,{className:"attribute",begin:"\\b("+Lk.join("|")+")\\b",end:/(?=:)/,starts:{endsWithParent:!0,illegal:"[<=$]",relevance:0,contains:o}}]},f={className:"keyword",begin:"@(import|media|charset|font-face|(-[a-z]+-)?keyframes|supports|document|namespace|page|viewport|host)\\b",starts:{end:"[;{}]",keywords:c,returnEnd:!0,contains:o,relevance:0}},m={className:"variable",variants:[{begin:"@"+r+"\\s*:",relevance:15},{begin:"@"+r}],starts:{end:"[;}]",returnEnd:!0,contains:u}},g={variants:[{begin:"[\\.#:&\\[>]",end:"[;{}]"},{begin:s,end:/\{/}],returnBegin:!0,returnEnd:!0,illegal:"[<='$\"]",relevance:0,contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,p,l("keyword","all\\b"),l("variable","@\\{"+r+"\\}"),{begin:"\\b("+Tk.join("|")+")\\b",className:"selector-tag"},t.CSS_NUMBER_MODE,l("selector-tag",s,0),l("selector-id","#"+s),l("selector-class","\\."+s,0),l("selector-tag","&",0),t.ATTRIBUTE_SELECTOR_MODE,{className:"selector-pseudo",begin:":("+Dk.join("|")+")"},{className:"selector-pseudo",begin:":(:)?("+Rk.join("|")+")"},{begin:/\(/,end:/\)/,relevance:0,contains:u},{begin:"!important"},t.FUNCTION_DISPATCH]},b={begin:r+`:(:)?(${n.join("|")})`,returnBegin:!0,contains:[g]};return i.push(e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,f,m,b,h,g,p,t.FUNCTION_DISPATCH),{name:"Less",case_insensitive:!0,illegal:"[=>'/<($\"]",contains:i}}),_S.registerLanguage("lua",function(e){const t="\\[=*\\[",n="\\]=*\\]",r={begin:t,end:n,contains:["self"]},s=[e.COMMENT("--(?!"+t+")","$"),e.COMMENT("--"+t,n,{contains:[r],relevance:10})];return{name:"Lua",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:s.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:s}].concat(s)},e.C_NUMBER_MODE,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,{className:"string",begin:t,end:n,contains:[r],relevance:5}])}}),_S.registerLanguage("makefile",function(e){const 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={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]},s={begin:"^"+e.UNDERSCORE_IDENT_RE+"\\s*(?=[:+?]?=)"},i={className:"section",begin:/^[^\s]+:/,end:/$/,contains:[t]};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,r,s,{className:"meta",begin:/^\.PHONY:/,end:/$/,keywords:{$pattern:/[\.\w]+/,keyword:".PHONY"}},i]}}),_S.registerLanguage("markdown",function(e){const t={begin:/<\/?[A-Za-z_]/,end:">",subLanguage:"xml",relevance:0},n={variants:[{begin:/\[.+?\]\[.*?\]/,relevance:0},{begin:/\[.+?\]\(((data|javascript|mailto):|(?:http|ftp)s?:\/\/).*?\)/,relevance:2},{begin:e.regex.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}]},r={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}]},i=e.inherit(r,{contains:[]}),o=e.inherit(s,{contains:[]});r.contains.push(o),s.contains.push(i);let a=[t,n];return[r,s,i,o].forEach(e=>{e.contains=e.contains.concat(a)}),a=a.concat(r,s),{name:"Markdown",aliases:["md","mkdown","mkd"],contains:[{className:"section",variants:[{begin:"^#{1,6}",end:"$",contains:a},{begin:"(?=^.+?\\n[=-]{2,}$)",contains:[{begin:"^[=-]*$"},{begin:"^",end:"\\n",contains:a}]}]},t,{className:"bullet",begin:"^[ \t]*([*+-]|(\\d+\\.))(?=\\s+)",end:"\\s+",excludeEnd:!0},r,s,{className:"quote",begin:"^>\\s+",contains:a,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:"$"},n,{begin:/^\[[^\n]+\]:/,returnBegin:!0,contains:[{className:"symbol",begin:/\[/,end:/\]/,excludeBegin:!0,excludeEnd:!0},{className:"link",begin:/:\s*/,end:/$/,excludeBegin:!0}]}]}}),_S.registerLanguage("objectivec",function(e){const 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}]}}),_S.registerLanguage("perl",function(e){const 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","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","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","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"].join(" ")},s={className:"subst",begin:"[$@]\\{",end:"\\}",keywords:r},i={begin:/->\{/,end:/\}/},o={variants:[{begin:/\$\d/},{begin:t.concat(/[$%@](\^\w\b|#\w+(::\w+)*|\{\w+\}|\w+(::\w*)*)/,"(?![A-Za-z])(?![@$%])")},{begin:/[$%@][^\s\w{]/,relevance:0}]},a=[e.BACKSLASH_ESCAPE,s,o],l=[/!/,/\//,/\|/,/\?/,/'/,/"/,/#/],c=(e,r,s="\\1")=>{const i="\\1"===s?s:t.concat(s,r);return t.concat(t.concat("(?:",e,")"),r,/(?:\\.|[^\\\/])*?/,i,/(?:\\.|[^\\\/])*?/,s,n)},d=(e,r,s)=>t.concat(t.concat("(?:",e,")"),r,/(?:\\.|[^\\\/])*?/,s,n),u=[o,e.HASH_COMMENT_MODE,e.COMMENT(/^=\w/,/=cut/,{endsWithParent:!0}),i,{className:"string",contains:a,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}]},{className:"number",begin:"(\\b0[0-7_]+)|(\\b0x[0-9a-fA-F_]+)|(\\b[1-9][0-9_]*(\\.[0-9_]+)?)|[0_]\\b",relevance:0},{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:c("s|tr|y",t.either(...l,{capture:!0}))},{begin:c("s|tr|y","\\(","\\)")},{begin:c("s|tr|y","\\[","\\]")},{begin:c("s|tr|y","\\{","\\}")}],relevance:2},{className:"regexp",variants:[{begin:/(m|qr)\/\//,relevance:0},{begin:d("(?:m|qr)?",/\//,/\//)},{begin:d("m|qr",t.either(...l,{capture:!0}),/\1/)},{begin:d("m|qr",/\(/,/\)/)},{begin:d("m|qr",/\[/,/\]/)},{begin:d("m|qr",/\{/,/\}/)}]}]},{className:"function",beginKeywords:"sub",end:"(\\s*\\(.*?\\))?[;{]",excludeEnd:!0,relevance:5,contains:[e.TITLE_MODE]},{begin:"-\\w\\b",relevance:0},{begin:"^__DATA__$",end:"^__END__$",subLanguage:"mojolicious",contains:[{begin:"^@@.*",end:"$",className:"comment"}]}];return s.contains=u,i.contains=u,{name:"Perl",aliases:["pl","pm"],keywords:r,contains:u}}),_S.registerLanguage("php",function(e){const t=e.regex,n=/(?![A-Za-z0-9])(?![$])/,r=t.concat(/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/,n),s=t.concat(/(\\?[A-Z][a-z0-9_\x7f-\xff]+|\\?[A-Z]+(?=[A-Z][a-z0-9_\x7f-\xff])){1,}/,n),i={scope:"variable",match:"\\$+"+r},o={scope:"subst",variants:[{begin:/\$\w+/},{begin:/\{\$/,end:/\}/}]},a=e.inherit(e.APOS_STRING_MODE,{illegal:null}),l="[ \t\n]",c={scope:"string",variants:[e.inherit(e.QUOTE_STRING_MODE,{illegal:null,contains:e.QUOTE_STRING_MODE.contains.concat(o)}),a,{begin:/<<<[ \t]*(?:(\w+)|"(\w+)")\n/,end:/[ \t]*(\w+)\b/,contains:e.QUOTE_STRING_MODE.contains.concat(o),"on:begin":(e,t)=>{t.data._beginMatch=e[1]||e[2]},"on:end":(e,t)=>{t.data._beginMatch!==e[1]&&t.ignoreMatch()}},e.END_SAME_AS_BEGIN({begin:/<<<[ \t]*'(\w+)'\n/,end:/[ \t]*(\w+)\b/})]},d={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},u=["false","null","true"],p=["__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"],h=["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"],f={keyword:p,literal:(e=>{const t=[];return e.forEach(e=>{t.push(e),e.toLowerCase()===e?t.push(e.toUpperCase()):t.push(e.toLowerCase())}),t})(u),built_in:h},m=e=>e.map(e=>e.replace(/\|\d+$/,"")),g={variants:[{match:[/new/,t.concat(l,"+"),t.concat("(?!",m(h).join("\\b|"),"\\b)"),s],scope:{1:"keyword",4:"title.class"}}]},b=t.concat(r,"\\b(?!\\()"),y={variants:[{match:[t.concat(/::/,t.lookahead(/(?!class\b)/)),b],scope:{2:"variable.constant"}},{match:[/::/,/class/],scope:{2:"variable.language"}},{match:[s,t.concat(/::/,t.lookahead(/(?!class\b)/)),b],scope:{1:"title.class",3:"variable.constant"}},{match:[s,t.concat("::",t.lookahead(/(?!class\b)/))],scope:{1:"title.class"}},{match:[s,/::/,/class/],scope:{1:"title.class",3:"variable.language"}}]},v={scope:"attr",match:t.concat(r,t.lookahead(":"),t.lookahead(/(?!::)/))},w={relevance:0,begin:/\(/,end:/\)/,keywords:f,contains:[v,i,y,e.C_BLOCK_COMMENT_MODE,c,d,g]},x={relevance:0,match:[/\b/,t.concat("(?!fn\\b|function\\b|",m(p).join("\\b|"),"|",m(h).join("\\b|"),"\\b)"),r,t.concat(l,"*"),t.lookahead(/(?=\()/)],scope:{3:"title.function.invoke"},contains:[w]};w.contains.push(x);const k=[v,y,e.C_BLOCK_COMMENT_MODE,c,d,g];return{case_insensitive:!1,keywords:f,contains:[{begin:t.concat(/#\[\s*/,s),beginScope:"meta",end:/]/,endScope:"meta",keywords:{literal:u,keyword:["new","array"]},contains:[{begin:/\[/,end:/]/,keywords:{literal:u,keyword:["new","array"]},contains:["self",...k]},...k,{scope:"meta",match:s}]},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/},i,x,y,{match:[/const/,/\s/,r],scope:{1:"keyword",3:"variable.constant"}},g,{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:f,contains:["self",i,y,e.C_BLOCK_COMMENT_MODE,c,d]}]},{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]},c,d]}}),_S.registerLanguage("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})]}]}}),_S.registerLanguage("plaintext",function(e){return{name:"Plain text",aliases:["text","txt"],disableAutodetect:!0}}),_S.registerLanguage("python",function(e){const 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"],s={$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"]},i={className:"meta",begin:/^(>>>|\.\.\.) /},o={className:"subst",begin:/\{/,end:/\}/,keywords:s,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,i],relevance:10},{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,i],relevance:10},{begin:/([fF][rR]|[rR][fF]|[fF])'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,i,a,o]},{begin:/([fF][rR]|[rR][fF]|[fF])"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,i,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:s,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:s,contains:["self",i,p,l,e.HASH_COMMENT_MODE]}]};return o.contains=[l,p,i],{name:"Python",aliases:["py","gyp","ipython"],unicodeRegex:!0,keywords:s,illegal:/(<\/|\?)|=>/,contains:[i,p,{begin:/\bself\b/},{beginKeywords:"if",relevance:0},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]}]}}),_S.registerLanguage("python-repl",function(e){return{aliases:["pycon"],contains:[{className:"meta.prompt",starts:{end:/ |$/,starts:{end:"$",subLanguage:"python"}},variants:[{begin:/^>>>(?=[ ]|$)/},{begin:/^\.\.\.(?=[ ]|$)/}]}]}}),_S.registerLanguage("r",function(e){const 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]?/),s=/[=!<>:]=|\|\||&&|:::?|<-|<<-|->>|->|\|>|[-+*\/?!$&|:<=>@^~]|\*\*/,i=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:[s,r]},{scope:{1:"operator",2:"number"},match:[/%[^%]*%/,r]},{scope:{1:"punctuation",2:"number"},match:[i,r]},{scope:{2:"number"},match:[/[^a-zA-Z0-9._]|^/,r]}]},{scope:{3:"operator"},match:[n,/\s+/,/<-/,/\s+/]},{scope:"operator",relevance:0,variants:[{match:s},{match:/%[^%]*%/}]},{scope:"punctuation",relevance:0,match:i},{begin:"`",end:"`",contains:[{begin:/\\./}]}]}}),_S.registerLanguage("ruby",function(e){const 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]+/),s=t.concat(r,/(::\w+)*/),i={"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:i},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:i}]},f=[d,{variants:[{match:[/class\s+/,s,/\s+<\s+/,s]},{match:[/\b(class|module)\s+/,s]}],scope:{2:"title.class",4:"title.class.inherited"},keywords:i},{match:[/(include|extend)\s+/,s],scope:{2:"title.class"},keywords:i},{relevance:0,match:[s,/\.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:i},{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;const 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:i,contains:f}}];return l.unshift(a),{name:"Ruby",aliases:["rb","gemspec","podspec","thor","irb"],keywords:i,illegal:/\/\*/,contains:[e.SHEBANG({binary:"ruby"})].concat(m).concat(l).concat(f)}}),_S.registerLanguage("rust",function(e){const t=e.regex,n={className:"title.function.invoke",relevance:0,begin:t.concat(/\b/,/(?!let\b)/,e.IDENT_RE,t.lookahead(/\s*\(/))},r="([ui](8|16|32|64|128|size)|f(32|64))?",s=["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!","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!"],i=["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:i,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","unsafe","unsized","use","virtual","where","while","yield"],literal:["true","false","Some","None","Ok","Err"],built_in:s},illegal:"</",contains:[e.C_LINE_COMMENT_MODE,e.COMMENT("/\\*","\\*/",{contains:["self"]}),e.inherit(e.QUOTE_STRING_MODE,{begin:/b?"/,illegal:null}),{className:"string",variants:[{begin:/b?r(#*)"(.|\n)*?"\1(?!#)/},{begin:/b?'\\?(x\w{2}|u\w{4}|U\w{8}|.)'/}]},{className:"symbol",begin:/'[a-zA-Z_][a-zA-Z0-9_]*/},{className:"number",variants:[{begin:"\\b0b([01_]+)"+r},{begin:"\\b0o([0-7_]+)"+r},{begin:"\\b0x([A-Fa-f0-9_]+)"+r},{begin:"\\b(\\d[\\d_]*(\\.[0-9_]+)?([eE][+-]?[0-9_]+)?)"+r}],relevance:0},{begin:[/fn/,/\s+/,e.UNDERSCORE_IDENT_RE],className:{1:"keyword",3:"title.function"}},{className:"meta",begin:"#!?\\[",end:"\\]",contains:[{className:"string",begin:/"/,end:/"/}]},{begin:[/let/,/\s+/,/(?:mut\s+)?/,e.UNDERSCORE_IDENT_RE],className:{1:"keyword",3:"keyword",4:"variable"}},{begin:[/for/,/\s+/,e.UNDERSCORE_IDENT_RE,/\s+/,/in/],className:{1:"keyword",3:"variable",5:"keyword"}},{begin:[/type/,/\s+/,e.UNDERSCORE_IDENT_RE],className:{1:"keyword",3:"title.class"}},{begin:[/(?:trait|enum|struct|union|impl|for)/,/\s+/,e.UNDERSCORE_IDENT_RE],className:{1:"keyword",3:"title.class"}},{begin:e.IDENT_RE+"::",keywords:{keyword:"Self",built_in:s,type:i}},{className:"punctuation",begin:"->"},n]}}),_S.registerLanguage("scss",function(e){const t=(e=>({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_-]*/}}))(e),n=$k,r=zk,s="@[a-z-]+",i={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("+jk.join("|")+")\\b",relevance:0},{className:"selector-pseudo",begin:":("+r.join("|")+")"},{className:"selector-pseudo",begin:":(:)?("+n.join("|")+")"},i,{begin:/\(/,end:/\)/,contains:[t.CSS_NUMBER_MODE]},t.CSS_VARIABLE,{className:"attribute",begin:"\\b("+Fk.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,i,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:s,keyword:"@page @font-face"}},{begin:"@",end:"[{;]",returnBegin:!0,keywords:{$pattern:/[a-z-]+/,keyword:"and or not only",attribute:Bk.join(" ")},contains:[{begin:s,className:"keyword"},{begin:/[a-z-]+(?=:)/,className:"attribute"},i,e.QUOTE_STRING_MODE,e.APOS_STRING_MODE,t.HEXCOLOR,t.CSS_NUMBER_MODE]},t.FUNCTION_DISPATCH]}}),_S.registerLanguage("shell",function(e){return{name:"Shell Session",aliases:["console","shellsession"],contains:[{className:"meta.prompt",begin:/^\s{0,3}[/~\w\d[\]()@-]*[>%$#][ ]?/,starts:{end:/[^\\](?=\s*$)/,subLanguage:"bash"}}]}}),_S.registerLanguage("sql",function(e){const t=e.regex,n=e.COMMENT("--","$"),r=["true","false","unknown"],s=["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"],i=["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"],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"],a=i,l=["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=>!i.includes(e)),c={begin:t.concat(/\b/,t.either(...a),/\s*\(/),relevance:0,keywords:{built_in:a}};return{name:"SQL",case_insensitive:!0,illegal:/[{}]|<\//,keywords:{$pattern:/\b[\w\.]+/,keyword:function(e,{exceptions:t,when:n}={}){const r=n;return t=t||[],e.map(e=>e.match(/\|\d+$/)||t.includes(e)?e:r(e)?`${e}|0`:e)}(l,{when:e=>e.length<3}),literal:r,type:s,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:[{begin:t.either(...o),relevance:0,keywords:{$pattern:/[\w\.]+/,keyword:l.concat(o),literal:r,type:s}},{className:"type",begin:t.either("double precision","large object","with timezone","without timezone")},c,{className:"variable",begin:/@[a-z0-9][a-z0-9_]*/},{className:"string",variants:[{begin:/'/,end:/'/,contains:[{begin:/''/}]}]},{begin:/"/,end:/"/,contains:[{begin:/""/}]},e.C_NUMBER_MODE,e.C_BLOCK_COMMENT_MODE,n,{className:"operator",begin:/[-+*/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?/,relevance:0}]}}),_S.registerLanguage("swift",function(e){const t={match:/\s+/,relevance:0},n=e.COMMENT("/\\*","\\*/",{contains:["self"]}),r=[e.C_LINE_COMMENT_MODE,n],s={match:[/\./,Vk(...Wk,...Gk)],className:{2:"keyword"}},i={match:qk(/\./,Vk(...Zk)),relevance:0},o=Zk.filter(e=>"string"==typeof e).concat(["_|0"]),a={variants:[{className:"keyword",match:Vk(...Zk.filter(e=>"string"!=typeof e).concat(Jk).map(Kk),...Gk)}]},l={$pattern:Vk(/\b\w+/,/#\w+/),keyword:o.concat(Yk),literal:Qk},c=[s,i,a],d=[{match:qk(/\./,Vk(...eS)),relevance:0},{className:"built_in",match:qk(/\b/,Vk(...eS),/(?=\()/)}],u={match:/->/,relevance:0},p=[u,{className:"operator",relevance:0,variants:[{match:rS},{match:`\\.(\\.|${nS})+`}]}],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:qk(/\\/,e,/[0\\tnr"']/)},{match:qk(/\\/,e,/u\{[0-9a-fA-F]{1,8}\}/)}]}),b=(e="")=>({className:"subst",match:qk(/\\/,e,/[\t ]*(?:[\r\n]|\r\n)/)}),y=(e="")=>({className:"subst",label:"interpol",begin:qk(/\\/,e,/\(/),end:/\)/}),v=(e="")=>({begin:qk(e,/"""/),end:qk(/"""/,e),contains:[g(e),b(e),y(e)]}),w=(e="")=>({begin:qk(e,/"/),end:qk(/"/,e),contains:[g(e),y(e)]}),x={className:"string",variants:[v(),v("#"),v("##"),v("###"),w(),w("#"),w("##"),w("###")]},k={match:qk(/`/,oS,/`/)},S=[k,{className:"variable",match:/\$\d+/},{className:"variable",match:`\\$${iS}+`}],E=[{match:/(@|#(un)?)available/,className:"keyword",starts:{contains:[{begin:/\(/,end:/\)/,keywords:cS,contains:[...p,m,x]}]}},{className:"keyword",match:qk(/@/,Vk(...lS))},{className:"meta",match:qk(/@/,oS)}],M={match:Uk(/\b[A-Z]/),relevance:0,contains:[{className:"type",match:qk(/(AV|CA|CF|CG|CI|CL|CM|CN|CT|MK|MP|MTK|MTL|NS|SCN|SK|UI|WK|XC)/,iS,"+")},{className:"type",match:aS,relevance:0},{match:/[?!]+/,relevance:0},{match:/\.\.\./,relevance:0},{match:qk(/\s+&\s+/,Uk(aS)),relevance:0}]},_={begin:/</,end:/>/,keywords:l,contains:[...r,...c,...E,u,M]};M.contains.push(_);const N={begin:/\(/,end:/\)/,relevance:0,keywords:l,contains:["self",{match:qk(oS,/\s*:/),keywords:"_|0",relevance:0},...r,...c,...d,...p,m,x,...S,...E,M]},C={begin:/</,end:/>/,contains:[...r,M]},O={begin:/\(/,end:/\)/,keywords:l,contains:[{begin:Vk(Uk(qk(oS,/\s*:/)),Uk(qk(oS,/\s+/,oS,/\s*:/))),end:/:/,relevance:0,contains:[{className:"keyword",match:/\b_\b/},{className:"params",match:oS}]},...r,...c,...p,m,x,...E,M,N],endsParent:!0,illegal:/["']/},A={match:[/func/,/\s+/,Vk(k.match,oS,rS)],className:{1:"keyword",3:"title.function"},contains:[C,O,t],illegal:[/\[/,/%/]},T={match:[/\b(?:subscript|init[?!]?)/,/\s*(?=[<(])/],className:{1:"keyword"},contains:[C,O,t],illegal:/\[|%/},I={match:[/operator/,/\s+/,rS],className:{1:"keyword",3:"title"}},D={begin:[/precedencegroup/,/\s+/,aS],className:{1:"keyword",3:"title"},contains:[M],keywords:[...Xk,...Qk],end:/}/};for(const R of x.variants){const e=R.contains.find(e=>"interpol"===e.label);e.keywords=l;const t=[...c,...d,...p,m,x,...S];e.contains=[...t,{begin:/\(/,end:/\)/,contains:["self",...t]}]}return{name:"Swift",keywords:l,contains:[...r,A,T,{beginKeywords:"struct protocol class extension enum actor",end:"\\{",excludeEnd:!0,keywords:l,contains:[e.inherit(e.TITLE_MODE,{className:"title.class",begin:/[A-Za-z$_][\u00C0-\u02B80-9A-Za-z$_]*/}),...c]},I,D,{beginKeywords:"import",end:/$/,contains:[...r],relevance:0},...c,...d,...p,m,x,...S,...E,M,N]}}),_S.registerLanguage("typescript",function(e){const t=function(e){const t=e.regex,n=dS,r="<>",s="</>",i={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(e,t)=>{const n=e[0].length+e.index,r=e.input[n];if("<"===r||","===r)return void t.ignoreMatch();let s;">"===r&&(((e,{after:t})=>{const n="</"+e[0].slice(1);return-1!==e.input.indexOf(n,t)})(e,{after:n})||t.ignoreMatch());const i=e.input.substring(n);((s=i.match(/^\s*=/))||(s=i.match(/^\s+extends\s+/))&&0===s.index)&&t.ignoreMatch()}},o={$pattern:dS,keyword:uS,literal:pS,built_in:bS,"variable.language":gS},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:n+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),e.C_BLOCK_COMMENT_MODE,e.C_LINE_COMMENT_MODE]},b=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,p,h,f,m,{match:/\$\d+/},d];u.contains=b.concat({begin:/\{/,end:/\}/,keywords:o,contains:["self"].concat(b)});const y=[].concat(g,u.contains),v=y.concat([{begin:/\(/,end:/\)/,keywords:o,contains:["self"].concat(y)}]),w={className:"params",begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:o,contains:v},x={variants:[{match:[/class/,/\s+/,n,/\s+/,/extends/,/\s+/,t.concat(n,"(",t.concat(/\./,n),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,n],scope:{1:"keyword",3:"title.class"}}]},k={relevance:0,match:t.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:{_:[...hS,...fS]}},S={variants:[{match:[/function/,/\s+/,n,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[w],illegal:/%/},E={match:t.concat(/\b/,(M=[...mS,"super","import"],t.concat("(?!",M.join("|"),")")),n,t.lookahead(/\(/)),className:"title.function",relevance:0};var M;const _={begin:t.concat(/\./,t.lookahead(t.concat(n,/(?![0-9A-Za-z$_(])/))),end:n,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},N={match:[/get|set/,/\s+/,n,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},w]},C="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",O={match:[/const|var|let/,/\s+/,n,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(C)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[w]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:o,exports:{PARAMS_CONTAINS:v,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,{className:"attr",begin:n+t.lookahead(":"),relevance:0},O,{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:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:o,contains:v}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:r,end:s},{match:/<[A-Za-z0-9\\._:-]+\s*\/>/},{begin:i.begin,"on:begin":i.isTrulyOpeningTag,end:i.end}],subLanguage:"xml",contains:[{begin:i.begin,end:i.end,skip:!0,contains:["self"]}]}]},S,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+e.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[w,e.inherit(e.TITLE_MODE,{begin:n,className:"title.function"})]},{match:/\.\.\./,relevance:0},_,{match:"\\$"+n,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[w]},E,{relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"},x,N,{match:/\$[(.]/}]}}(e),n=dS,r=["any","void","number","boolean","string","object","never","symbol","bigint","unknown"],s={beginKeywords:"namespace",end:/\{/,excludeEnd:!0,contains:[t.exports.CLASS_REFERENCE]},i={beginKeywords:"interface",end:/\{/,excludeEnd:!0,keywords:{keyword:"interface extends",built_in:r},contains:[t.exports.CLASS_REFERENCE]},o={$pattern:dS,keyword:uS.concat(["type","namespace","interface","public","private","protected","implements","declare","abstract","readonly","enum","override"]),literal:pS,built_in:bS.concat(r),"variable.language":gS},a={className:"meta",begin:"@"+n},l=(e,t,n)=>{const r=e.contains.findIndex(e=>e.label===t);if(-1===r)throw new Error("can not find mode to replace");e.contains.splice(r,1,n)};return Object.assign(t.keywords,o),t.exports.PARAMS_CONTAINS.push(a),t.contains=t.contains.concat([a,s,i]),l(t,"shebang",e.SHEBANG()),l(t,"use_strict",{className:"meta",relevance:10,begin:/^\s*['"]use strict['"]/}),t.contains.find(e=>"func.def"===e.label).relevance=0,Object.assign(t,{name:"TypeScript",aliases:["ts","tsx","mts","cts"]}),t}),_S.registerLanguage("vbnet",function(e){const t=e.regex,n=/\d{1,2}\/\d{1,2}\/\d{4}/,r=/\d{4}-\d{1,2}-\d{1,2}/,s=/(\d|1[012])(:\d+){0,2} *(AM|PM)/,i=/\d{1,2}(:\d{1,2}){1,2}/,o={className:"literal",variants:[{begin:t.concat(/# */,t.either(r,n),/ *#/)},{begin:t.concat(/# */,i,/ *#/)},{begin:t.concat(/# */,s,/ *#/)},{begin:t.concat(/# */,t.either(r,n),/ +/,t.either(s,i),/ *#/)}]},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]}]}}),_S.registerLanguage("wasm",function(e){e.regex;const 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/}]}}),_S.registerLanguage("xml",function(e){const 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]+;/},s={begin:/\s/,contains:[{className:"keyword",begin:/#?[a-z_][a-z1-9_-]+/,illegal:/\n/}]},i=e.inherit(s,{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:[s,a,o,i,{begin:/\[/,end:/\]/,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,contains:[s,i,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}]}]}}),_S.registerLanguage("yaml",function(e){const t="true false yes no null",n="[\\w#;/?:@&=+$,.~*'()[\\]]+",r={className:"string",relevance:0,variants:[{begin:/'/,end:/'/},{begin:/"/,end:/"/},{begin:/\S+/}],contains:[e.BACKSLASH_ESCAPE,{className:"template-variable",variants:[{begin:/\{\{/,end:/\}\}/},{begin:/%\{/,end:/\}/}]}]},s=e.inherit(r,{variants:[{begin:/'/,end:/'/},{begin:/"/,end:/"/},{begin:/[^\s,{}[\]]+/}]}),i={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"},o={end:",",endsWithParent:!0,excludeEnd:!0,keywords:t,relevance:0},a={begin:/\{/,end:/\}/,contains:[o],illegal:"\\n",relevance:0},l={begin:"\\[",end:"\\]",contains:[o],illegal:"\\n",relevance:0},c=[{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}},i,{className:"number",begin:e.C_NUMBER_RE+"\\b",relevance:0},a,l,r],d=[...c];return d.pop(),d.push(s),o.contains=d,{name:"YAML",case_insensitive:!0,aliases:["yml"],contains:c}});const NS={..._S,highlightAuto(e,t){const n=_S.highlightAuto(e,t),r=n.data?.relevance??0;return r>=5&&e.length>0&&r/e.length>=.04||(n.children=[],n.data={language:null,relevance:0}),n}},CS=e=>0===e.state.selection.$from.parentOffset,OS=e=>e.state.selection.$from.marks().some(e=>"code"===e.type.name),AS=e=>"heading"===e.state.selection.$from.parent.type.name,TS=e=>{const t=e.state.selection.$from;return t.parentOffset===t.parent.nodeSize-2},IS=e=>{const t=e.state.tr;t.setStoredMarks([]),t.insertText("\u200b"),e.view.dispatch(t)},DS=e=>!(e.state.selection.$from.after()<e.state.doc.content.size)&&(IS(e),!0),RS=e=>!(e.state.selection.$from.before()>0)&&e.chain().insertContentAt(0,"<p></p>").run(),LS=e=>!(e.state.selection.$from.after()<e.state.doc.content.size)&&e.chain().insertContent("<p></p>").run(),PS=rm.create({name:"CodeBlockKeyboardNavExtension",addKeyboardShortcuts:()=>({ArrowUp:({editor:e})=>!(!(e=>"codeBlock"===e.state.selection.$from.parent.type.name)(e)||!CS(e))&&RS(e)})}),jS=rm.create({name:"InlineCodeKeyboardNavExtension",addKeyboardShortcuts:()=>({ArrowUp:({editor:e})=>!(!OS(e)||!CS(e))&&RS(e),ArrowDown:({editor:e})=>!(!OS(e)||!TS(e))&&LS(e),ArrowRight:({editor:e})=>!(!OS(e)||!TS(e))&&DS(e),ArrowLeft:({editor:e})=>!(!OS(e)||!CS(e))&&(e=>!(e.state.selection.$from.before()>0||(IS(e),0)))(e)})}),BS=rm.create({name:"HeadingKeyboardNavExtension",addKeyboardShortcuts:()=>({ArrowUp:({editor:e})=>!(!AS(e)||!CS(e))&&RS(e),ArrowDown:({editor:e})=>!(!AS(e)||!TS(e))&&LS(e)})}),zS=rm.create({name:"StrikeKeyboardNavExtension",addKeyboardShortcuts:()=>({ArrowRight:({editor:e})=>!(!(e=>e.state.selection.$from.marks().some(e=>"strike"===e.type.name))(e)||!TS(e))&&DS(e)})}),$S=({editor:e})=>(e.commands.enter(),e.commands.scrollIntoView(),!0),FS=rm.create({name:"PTagShiftEnterCreateExtension",addKeyboardShortcuts:()=>({"Shift-Enter":$S,"Alt-Enter":$S})}),HS=Oy.extend({addKeyboardShortcuts:()=>({})}),US=new RegExp(ay.source,"i"),qS=new RegExp(ay.source,"gi"),VS=e=>US.test(e),KS=e=>{const t=[];for(const n of e.matchAll(qS)){const[e]=cy(n[0]),r=/^www\./i.test(e)?`https://${e}`:e;ly(r)&&t.push({text:e,index:n.index,data:{href:r}})}return t},WS=Cw.extend({inclusive:!1,addPasteRules(){return[Dg({find:KS,type:this.type,getAttributes:e=>({href:e.data?.href})})]}}),GS=rm.create({name:"linkBoundary",addProseMirrorPlugins:()=>[new fc({key:new bc("linkBoundary"),appendTransaction:(e,t,n)=>{if(t.selection.eq(n.selection))return null;const{$from:r,empty:s}=n.selection;if(!s)return null;const i=n.schema.marks.link;if(!i)return null;const o=r.marks();if(!i.isInSet(o))return null;const a=r.nodeBefore;return a&&i.isInSet(a.marks)?null:n.tr.setStoredMarks(i.removeFromSet(o))}})]}),JS=/(?<=^|[^`])`([^`]+)`(?!`)$/;const ZS=gy.extend({addPasteRules:()=>[],addInputRules(){const e=Cg({find:JS,type:this.type});return[new Kf({find:JS,handler:t=>{const{state:n,range:r}=t,s=n.doc.resolve(r.from);if(!function(e){let t=!0;for(let n=e.indexOf("`");-1!==n;n=e.indexOf("`",n+1))t=!t;return t}(s.parent.textBetween(0,s.parentOffset)))return null;const i=e.handler(t),{tr:o}=t.state;if(null===i||!o.steps.length)return null;o.setStoredMarks([]).insertText(dn)}})]}}),QS=e=>{if("hardBreak"===e.type.name)return"\n";const{toText:t,leafText:n}=e.type.spec;try{if("function"==typeof t)return t({node:e});if("function"==typeof n)return n(e)}catch{}return e.textContent},XS=e=>e.textBetween(0,e.size,"\n\n",QS),YS=e=>{let t=!1;const n=[];return e.forEach(e=>{let r=e;if(!e.type.spec.code||e.isText||e.type.validContent(e.content)){if(e.childCount>0){const t=YS(e.content);t!==e.content&&(r=e.copy(t))}}else{const t=XS(e.content);r=e.copy(t?Qo.from(e.type.schema.text(t)):Qo.empty)}r!==e&&(t=!0),n.push(r)}),t?Qo.fromArray(n):e},eE=(e,t)=>{let n=0;for(let r=e[t];r&&!r.isLeaf;r=r[t])n+=1;return n},tE=new WeakSet,nE=e=>(tE.add(e),queueMicrotask(()=>tE.delete(e)),!1),rE=(e,t)=>{const n=YS(e.content),r=n===e.content?e:new ra(n,Math.min(e.openStart,eE(n,"firstChild")),Math.min(e.openEnd,eE(n,"lastChild")));if(tE.has(t)&&t.state.selection.$from.parent.type.spec.code){const e=XS(r.content);if(e)return new ra(Qo.from(t.state.schema.text(e)),0,0)}return r},sE=rm.create({name:"pasteTableAsPlainText",addProseMirrorPlugins:()=>[new fc({key:new bc("pasteTableAsPlainText"),props:{handlePaste:(e,t)=>{if(!t.clipboardData)return!1;if(e.state.schema.nodes.table)return!1;const n=t.clipboardData.getData("text/html");if(!/<table[\s>]/i.test(n))return!1;const r=t.clipboardData.getData("text/plain");return!!r&&(e.pasteText(r),!0)}}})]}),iE=rm.create({name:"pasteCodeAsPlainText",addProseMirrorPlugins:()=>[new fc({key:new bc("pasteCodeAsPlainText"),props:{handlePaste:(e,t,n)=>{const{schema:r}=e.state;if(!t.clipboardData)return!1;if(!t.clipboardData.types.includes("vscode-editor-data"))return!1;const s=t.clipboardData.getData("text/plain"),i=r.text(s);return e.dispatch(e.state.tr.replaceSelectionWith(i)),!0}}})]}),oE=()=>t.jsx(Lb,{className:"code-block",children:t.jsx("pre",{className:"my-4 block rounded-md bg-[#282c34] p-2 text-[0.875rem] text-[#abb2bf]",children:t.jsx("code",{children:t.jsx(Rb,{as:"div"})})})}),aE=wy.extend({addNodeView:()=>$b(oE)}).configure({exitOnTripleEnter:!1}),lE=({tipTapEditorState:t,setTipTapEditorState:n,onRawUpdate:r,onReady:s,placeholder:i,extraEditorAttributes:a={},fetchInputAutocompletion:l,plainTextMode:c=!1,mentionsEnabled:d=!1,mentionProviders:u=[],onMentionStateChange:p,onMentionSelect:h,extraExtensions:f=[],codeBlockExtension:m,hasHydrated:g=!0,skipAutofocus:b=!1,disableDropCursor:y=!1,enableHardBreak:v=!1,shouldRerenderOnTransaction:w})=>{const x=e.useRef(i),k=e.useRef(({node:e})=>"paragraph"===e.type.name?x.current:""),S=cn(()=>u),E=cn(e=>p?.(e)),M=cn(e=>h?.(e)),_=e.useEffectEvent(()=>s?.()),N=e.useRef(!1),C=e.useRef({raf:null,bypass:!1}),O=[ux.configure({placeholder:k.current,emptyEditorClass:"is-editor-empty before:content-[attr(data-placeholder)] before:!text-text-500 before:whitespace-nowrap"}),...l?[lk.configure({fetchInputAutocompletion:l})]:[],FS,HS,WS.configure({openOnClick:!1,defaultProtocol:"https",shouldAutoLink:VS}),GS,sE],A=[sy,Vb.configure({getProviders:S,onStateChange:E,onSelect:M})],T=[ZS,iE,m??Ny.extend({addNodeView:()=>$b(oE)}).configure({lowlight:NS,exitOnTripleEnter:!1}),PS,BS,jS,zS],I=!y&&void 0,D=!1,R=[nk.configure(c?{dropcursor:I,link:D,bold:!1,italic:!1,underline:!1,strike:!1,code:!1,codeBlock:!1,blockquote:!1,hardBreak:!1,heading:!1,horizontalRule:!1,bulletList:{},orderedList:{},listItem:{}}:{dropcursor:I,link:D,bold:!1,italic:!1,underline:!1,code:!1,codeBlock:!1,blockquote:!1,hardBreak:!1,heading:!1,horizontalRule:!1}),...O,...c?[]:T,...A,...f],L=function(t={},n=[]){const r=e.useRef(t);r.current=t;const[s]=e.useState(()=>new Ob(r)),i=o.useSyncExternalStore(s.subscribe,s.getEditor,s.getServerSnapshot);return e.useDebugValue(i),e.useEffect(s.onRender(n)),_b({editor:i,selector:({transactionNumber:e})=>!1===t.shouldRerenderOnTransaction||void 0===t.shouldRerenderOnTransaction?null:t.immediatelyRender&&0===e?0:e+1}),i}({shouldRerenderOnTransaction:w,immediatelyRender:!1,editorProps:{attributes:{enterkeyhint:"enter",...a},...v?{transformPasted:rE,handleDOMEvents:{paste:nE}}:{transformPastedHTML:e=>e.replace(/<br\b[^>]*>/gi,"\n")},handleScrollToSelection:e=>{const t=C.current;if(t.bypass)return!1;const{$from:n}=e.state.selection;return(e=>/(?:^|\s)@\S*$/.test(e)||/(?:^|[\s\ufffc])\/[^\n]{0,50}$/.test(e))(n.parent.textBetween(Math.max(0,n.parentOffset-64),n.parentOffset,void 0,e=>"hardBreak"===e.type.name?"\n":"\ufffc"))?(null!==t.raf&&(cancelAnimationFrame(t.raf),t.raf=null),!1):(null!==t.raf&&cancelAnimationFrame(t.raf),t.raf=requestAnimationFrame(()=>{if(t.raf=null,!e.isDestroyed){t.bypass=!0;try{e.dispatch(e.state.tr.scrollIntoView())}finally{t.bypass=!1}}}),!0)}},autofocus:!pn()&&!b&&"end",extensions:R,content:t,onUpdate({editor:e}){N.current=!0;const t=e.isEmpty&&!e.isFocused;if(r)r(e);else{const t=e.getJSON(),r=un(t);n?.(r)}t&&e.commands.focus("end",{scrollIntoView:!1})}});return e.useEffect(()=>{L&&_()},[L]),e.useEffect(()=>()=>{const e=C.current;null!==e.raf&&(cancelAnimationFrame(e.raf),e.raf=null)},[]),e.useEffect(()=>{if(!L||L.isDestroyed||!L.isEmpty||!g||N.current)return;const e=t.content?.some(e=>e.content&&e.content.length>0);e&&L.commands.setContent(t)},[L,t,g]),e.useEffect(()=>{x.current=i,L&&L.view.dispatch(L.state.tr.setMeta("placeholderUpdate",!0))},[L,i]),{editor:L}};function cE({selected:e,id:n,displayName:r,description:s}){const i=hn().get(n),o=kc(n,i),a=i?.displayName??r,l=s||i?.description||"";return t.jsx(Lb,{as:"span",contentEditable:!1,children:t.jsx(Kc,{chipId:n,description:l,subtitle:o,href:i?.href,selected:e,children:t.jsx(Uc,{displayName:a,selectNone:!0})})})}let dE=!1;function uE(e){const t=new bc("skillChipArgumentHint");let n=null;const r=t=>{if(t.content.size>128)return{deco:Dp.empty,hint:null};const n=[];let r=null;return t.descendants((s,i,o)=>{if(s.type.name!==e)return;const a=s.attrs.skillArgumentHint??"";if(!a||!o)return;const l=i+s.nodeSize,c=t.textBetween(0,i," ","\ufffc"),d=t.textBetween(l,t.content.size," ","\ufffc");if(c.trim().length>0||d.trim().length>0)return;const u=t.resolve(l).end(),p=t.textBetween(l,u,void 0,"\ufffc");if(0===p.length)return;const h=l+p.length;r=a,n.push(Ap.widget(h,()=>function(e){const t=document.createElement("span");return t.style.display="inline",t.style.font="inherit",t.style.lineHeight="inherit",t.style.verticalAlign="baseline",t.style.opacity="0.5",t.style.pointerEvents="none",t.style.userSelect="none",t.setAttribute("data-skill-arg-hint","true"),t.setAttribute("aria-hidden","true"),t.textContent=e,t}(a),{side:1,key:`skillArgHint:${a}`}))}),{deco:n.length?Dp.create(t,n):Dp.empty,hint:r}};return new fc({key:t,state:{init:(e,t)=>({...r(t.doc),held:!1}),apply(e,s){if("refresh"===e.getMeta(t))return{...r(e.doc),held:!1};if(!e.docChanged)return s;const i=r(e.doc);if(n?.composing){const t=s.deco.map(e.mapping,e.doc);return{hint:i.hint,deco:t,held:s.held||t!==i.deco||s.hint!==i.hint}}return{...i,held:!1}}},props:{decorations:e=>t.getState(e)?.deco},view(e){n=e;const r=()=>{t.getState(e.state)?.held&&e.dispatch(e.state.tr.setMeta(t,"refresh"))};e.dom.addEventListener("compositionend",r);const s=`skill-arg-hint-sr-${Math.random().toString(36).slice(2,8)}`,i=document.createElement("span");i.id=s,i.setAttribute("role","status"),i.setAttribute("aria-live","polite"),i.setAttribute("style","position:absolute;top:0;left:0;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);clip-path:inset(50%);white-space:nowrap");const o=e=>{const t=e.dom.parentElement;t&&i.parentElement!==t&&t.appendChild(i)};o(e);const a=e=>(e.dom.getAttribute("aria-describedby")??"").split(/\s+/).filter(Boolean),l=e=>{const t=a(e).filter(e=>e!==s);t.length?e.dom.setAttribute("aria-describedby",t.join(" ")):e.dom.removeAttribute("aria-describedby")},c=e=>{const n=t.getState(e.state)?.hint;if(n){if(i.textContent!==n&&(i.textContent=n),!a(e).includes(s)){const t=e.dom.getAttribute("aria-describedby");e.dom.setAttribute("aria-describedby",t?`${t} ${s}`:s)}}else""!==i.textContent&&(i.textContent="",l(e))};return c(e),{update(e){const n=t.getState(e.state),r=n?.hint||n?.held?e.dom.querySelector("[data-skill-arg-hint]"):null;r&&(r.style.display=n?.hint?"inline":"none"),!e.composing&&n?.held&&e.dispatch(e.state.tr.setMeta(t,"refresh")),o(e),e.composing||c(e)},destroy(){n=null,e.dom.removeEventListener("compositionend",r),i.remove(),l(e)}}}})}function pE(t){return e.createElement(cE,{...t,id:t.node.attrs.skillId,displayName:t.node.attrs.skillDisplayName,description:t.node.attrs.skillDescription})}const hE=Tg.create({name:"skillChip",group:"inline",inline:!0,atom:!0,addOptions:()=>({onSkillChipInserted:void 0}),addAttributes:()=>({skillId:{default:null},skillDisplayName:{default:""},skillDescription:{default:""},skillArgumentHint:{default:""},slashRouting:{default:null,rendered:!1,parseHTML:()=>null}}),parseHTML:()=>[{tag:"span[data-skill-chip]"}],renderHTML({node:e,HTMLAttributes:t}){const n=e.attrs.skillId||e.attrs.skillDisplayName;return["span",pf(t,{"data-skill-chip":""}),`/${n}`]},renderText:({node:e})=>`/${e.attrs.skillId||e.attrs.skillDisplayName}`,addNodeView:()=>$b(pE),onCreate(){!function(){if(dE||"undefined"==typeof document)return;dE=!0;const e=document.createElement("style");e.setAttribute("data-skill-arg-hint-shim",""),e.textContent="\n.ProseMirror [data-skill-arg-hint] ~ .ProseMirror-separator,\n.ProseMirror [data-skill-arg-hint] ~ .ProseMirror-trailingBreak {\n  display: none;\n}",document.head.appendChild(e)}()},addProseMirrorPlugins(){const{onSkillChipInserted:e}=this.options,t=[uE(this.name)];var n,r;return e&&t.push((n=this.name,r=e,new fc({key:new bc("skillChipInsertion"),view:()=>({update:e=>{const t=new Map;e.state.doc.descendants(e=>{if(e.type.name===n&&e.attrs.skillId){const n=e.attrs.skillId;t.has(n)||t.set(n,{skillDescription:e.attrs.skillDescription??"",skillArgumentHint:e.attrs.skillArgumentHint??""})}});for(const[n,s]of t)fE.has(n)||r({skillId:n,...s});fE.clear();for(const n of t.keys())fE.add(n)}})}))),t},addKeyboardShortcuts(){return{Backspace:()=>{const{selection:e}=this.editor.state,{$from:t,empty:n}=e;if(!n)return!1;const r=t.nodeBefore;if(r&&r.type.name===this.name){const e=t.pos-r.nodeSize;return this.editor.chain().setNodeSelection(e).run(),!0}return!1}}}}),fE=new Set;function mE(e){var t;const{char:n,allowSpaces:r,allowToIncludeChar:s,allowedPrefixes:i,startOfLine:o,$position:a}=e,l=r&&!s,c=n.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&");const d=new RegExp(`\\s${c}$`),u=o?"^":"",p=s?"":c,h=l?new RegExp(`${u}${c}.*?(?=\\s${p}|$)`,"gm"):new RegExp(`${u}(?:^)?${c}[^\\s${p}]*`,"gm"),f=(null==(t=a.nodeBefore)?void 0:t.isText)&&a.nodeBefore.text;if(!f)return null;const m=a.pos-f.length,g=Array.from(f.matchAll(h)).pop();if(!g||void 0===g.input||void 0===g.index)return null;const b=g.input.slice(Math.max(0,g.index-1),g.index),y=new RegExp(`^[${null==i?void 0:i.join("")}\0]?$`).test(b);if(null!==i&&!y)return null;const v=m+g.index;let w=v+g[0].length;return l&&d.test(f.slice(w-1,w+1))&&(g[0]+=" ",w+=1),v<a.pos&&w>=a.pos?{range:{from:v,to:w},query:g[0].slice(n.length),text:g[0]}:null}var gE=new bc("suggestion");function bE(e,t=gE){const n=e.state.tr.setMeta(t,{exit:!0});e.dispatch(n)}var yE=function({pluginKey:e=gE,editor:t,char:n="@",allowSpaces:r=!1,allowToIncludeChar:s=!1,allowedPrefixes:i=[" "],startOfLine:o=!1,decorationTag:a="span",decorationClass:l="suggestion",decorationContent:c="",decorationEmptyClass:d="is-empty",command:u=()=>null,items:p=()=>[],render:h=()=>({}),allow:f=()=>!0,findSuggestionMatch:m=mE}){let g;const b=null==h?void 0:h(),y=()=>{const e=t.state.selection.$anchor.pos,n=t.view.coordsAtPos(e),{top:r,right:s,bottom:i,left:o}=n;try{return new DOMRect(o,r,s-o,i-r)}catch{return null}},v=(n,r)=>r?()=>{const r=e.getState(t.state),s=null==r?void 0:r.decorationId,i=n.dom.querySelector(`[data-decoration-id="${s}"]`);return(null==i?void 0:i.getBoundingClientRect())||null}:y,w=new fc({key:e,view(){return{update:async(e,n)=>{var r,s,i,o,a,l,c;const d=null==(r=this.key)?void 0:r.getState(n),h=null==(s=this.key)?void 0:s.getState(e.state),f=d.active&&h.active&&d.range.from!==h.range.from,m=!d.active&&h.active,y=d.active&&!h.active,w=!m&&!y&&d.query!==h.query,x=m||f&&w,k=w||f,S=y||f&&w;if(!x&&!k&&!S)return;const E=S&&!x?d:h,M=e.dom.querySelector(`[data-decoration-id="${E.decorationId}"]`);g={editor:t,range:E.range,query:E.query,text:E.text,items:[],command:e=>u({editor:t,range:E.range,props:e}),decorationNode:M,clientRect:v(e,M)},x&&(null==(i=null==b?void 0:b.onBeforeStart)||i.call(b,g)),k&&(null==(o=null==b?void 0:b.onBeforeUpdate)||o.call(b,g)),(k||x)&&(g.items=await p({editor:t,query:E.query})),S&&(null==(a=null==b?void 0:b.onExit)||a.call(b,g)),k&&(null==(l=null==b?void 0:b.onUpdate)||l.call(b,g)),x&&(null==(c=null==b?void 0:b.onStart)||c.call(b,g))},destroy:()=>{var e;g&&(null==(e=null==b?void 0:b.onExit)||e.call(b,g))}}},state:{init:()=>({active:!1,range:{from:0,to:0},query:null,text:null,composing:!1}),apply(a,l,c,d){const{isEditable:u}=t,{composing:p}=t.view,{selection:h}=a,{empty:g,from:b}=h,y={...l},v=a.getMeta(e);if(v&&v.exit)return y.active=!1,y.decorationId=null,y.range={from:0,to:0},y.query=null,y.text=null,y;if(y.composing=p,u&&(g||t.view.composing)){!(b<l.range.from||b>l.range.to)||p||l.composing||(y.active=!1);const e=m({char:n,allowSpaces:r,allowToIncludeChar:s,allowedPrefixes:i,startOfLine:o,$position:h.$from}),a=`id_${Math.floor(4294967295*Math.random())}`;e&&f({editor:t,state:d,range:e.range,isActive:l.active})?(y.active=!0,y.decorationId=l.decorationId?l.decorationId:a,y.range=e.range,y.query=e.query,y.text=e.text):y.active=!1}else y.active=!1;return y.active||(y.decorationId=null,y.range={from:0,to:0},y.query=null,y.text=null),y}},props:{handleKeyDown(n,r){var s,i,o,a;const{active:l,range:c}=w.getState(n.state);if(!l)return!1;if("Escape"===r.key||"Esc"===r.key){const a=w.getState(n.state),l=null!=(s=null==g?void 0:g.decorationNode)?s:null,c=null!=l?l:(null==a?void 0:a.decorationId)?n.dom.querySelector(`[data-decoration-id="${a.decorationId}"]`):null;if((null==(i=null==b?void 0:b.onKeyDown)?void 0:i.call(b,{view:n,event:r,range:a.range}))||!1)return!0;const d={editor:t,range:a.range,query:a.query,text:a.text,items:[],command:e=>u({editor:t,range:a.range,props:e}),decorationNode:c,clientRect:c?()=>c.getBoundingClientRect()||null:null};return null==(o=null==b?void 0:b.onExit)||o.call(b,d),function(n,r){var s;try{const r=e.getState(n.state),i=(null==r?void 0:r.decorationId)?n.dom.querySelector(`[data-decoration-id="${r.decorationId}"]`):null,o={editor:t,range:(null==r?void 0:r.range)||{from:0,to:0},query:(null==r?void 0:r.query)||null,text:(null==r?void 0:r.text)||null,items:[],command:e=>u({editor:t,range:(null==r?void 0:r.range)||{from:0,to:0},props:e}),decorationNode:i,clientRect:v(n,i)};null==(s=null==b?void 0:b.onExit)||s.call(b,o)}catch{}const i=n.state.tr.setMeta(r,{exit:!0});n.dispatch(i)}(n,e),!0}return(null==(a=null==b?void 0:b.onKeyDown)?void 0:a.call(b,{view:n,event:r,range:c}))||!1},decorations(e){const{active:t,range:n,decorationId:r,query:s}=w.getState(e);if(!t)return null;const i=!(null==s?void 0:s.length),o=[l];return i&&o.push(d),Dp.create(e.doc,[Ap.inline(n.from,n.to,{nodeName:a,class:o.join(" "),"data-decoration-id":r,"data-decoration-content":c})])}}});return w};const vE=t.jsx(fn,{});function wE({sessionId:t,shareSession:n,showIcon:r=!0,showSubtitle:s=!0,label:i}){const o=ur(),{exportLocalSession:a}=function(t){const{addError:n}=Nt(),r=hb(e=>e.setFilePath),s=e.useCallback(async e=>{if(t)try{const s=await t(e);s.success&&s.filePath?r(s.filePath):n(s.error||"Failed to export session.",{errorContext:{tags:{source:"share_session"}},messageForLogging:"Failed to export session."})}catch(s){n("Failed to export session. You can try again.",{error:s instanceof Error?s:void 0,errorContext:{tags:{source:"share_session"}},messageForLogging:"Failed to export session."})}},[t,r,n]);return{exportLocalSession:t?s:null}}(n);return e.useMemo(()=>{if(!t||!a)return null;const e=t;return{type:"button",label:i,...s&&{subtitle:o.formatMessage({defaultMessage:"Export transcript to Downloads",id:"qXQ6zVPez8"})},...r&&{icon:vE},onAction:()=>a(e)}},[t,a,r,s,i,o])}const xE=Jn(e=>({request:null,open:t=>e({request:t}),consume:()=>e({request:null})})),kE=t.jsx(vr,{name:"Palette"});const SE=t.jsx(ns,{}),EE=t.jsx(An,{});function ME({placement:t}){const{disableFileAttachments:n}=e.useContext(vn),r=ur(),{isLocalAgentRoute:s,localSessionId:i,conversation:o}=wn(),a=xn(),l=u("claudified_btw_side_chat"),c=kn(e=>e.openWith),d=function(){const t=ur(),n=mn("omelette").isAvailable,r=gn(),s=bn(),i=e.useMemo(()=>r.find(e=>e.uuid===yn&&e.isConnected),[r]);return e.useMemo(()=>{if(!n||!i)return null;const e=i.prompts.find(e=>"design"===e.name);return e?{type:"button",label:"design",icon:kE,subtitle:e.description??t.formatMessage({defaultMessage:"Work with Claude Design from this conversation",id:"y8YEcMT8zt"}),onAction:()=>{s({serverUuid:yn,prompt:e,args:{}})}}:null},[t,n,i,s])}(),p=a?null:d,h=Sn(),{items:f}=En(),m=Mn(),{plugins:g}=_n(),b=e.useMemo(()=>({type:"button",label:"add-files",icon:SE,subtitle:r.formatMessage({defaultMessage:"Open file picker",id:"Z2eVDMbG/B"}),onAction:()=>Nn(t)}),[r,t]),y=o?.id,v=e.useMemo(()=>l&&y?{type:"button",label:"btw",icon:EE,subtitle:r.formatMessage({defaultMessage:"Ask on the side without touching the main chat",id:"D7vaDuz9sI"}),onAction:()=>c(y)}:null,[l,y,r,c]),w=s&&xe(i),x=xE(e=>e.open),k=Ae(),S=wE({sessionId:s&&!w?i??null:null,shareSession:oe?.shareSession,label:"export"}),E=e.useMemo(()=>null,[w,i,x,k]),M=e.useMemo(()=>{const e=[...h?f:[],...a?m:[]].filter(e=>"skill"===e.type).filter(e=>!0).sort((e,t)=>e.label.localeCompare(t.label));return[...[..."compact"===t||n?[]:[b],...v?[v]:[],...p?[p]:[],...S?[S]:[],...E?[E]:[],...e],...g.flatMap(e=>{const t=e.skills.filter(Cn).map(t=>On(t,e.name));return 0===t.length?[]:[{type:"separator",label:`separator-${e.name}`},{type:"section-header",label:bt(e)},...t]})]},[b,t,n,v,null,p,S,E,h,f,m,g,a]);return{items:M}}function _E(e){return"separator"===e.type||"section-header"===e.type||"search-input"===e.type||"loading"===e.type}function NE(e,t){if(_E(e))return!1;const n=(e.label??"").toLowerCase();if(n.includes(t))return!0;if("button"===e.type&&e.acceptsArgs){const e=t.indexOf(" ");if(e>0&&t.slice(0,e)===n)return!0}if("skill"===e.type&&e.aliases?.some(e=>e.toLowerCase().includes(t)))return!0;if("skill"===e.type){const r=e.sourcePluginName||e.sourceRepo;if(r){const e=r.toLowerCase(),s=t.indexOf(":");if(-1===s)return e.includes(t);const i=t.slice(0,s),o=t.slice(s+1);return e.includes(i)&&n.includes(o)}}if("connector-tool"===e.type&&e.connectorName){const r=e.connectorName.toLowerCase(),s=t.indexOf(":");if(-1===s)return r.includes(t);const i=t.slice(0,s),o=t.slice(s+1);return r.includes(i)&&n.includes(o)}return!1}const CE=/[:_-]/g;function OE(e){return"skill"===e.type&&e.skillDescription?e.skillDescription.toLowerCase().split(/\W+/).filter(Boolean).slice(0,20):[]}function AE(e){const t=(e.label??"").toLowerCase(),n=function(e){return"skill"===e.type?e.sourcePluginName??e.sourceRepo??"":"connector-tool"===e.type?e.connectorName??"":""}(e).toLowerCase(),r=t.split(CE).filter(Boolean),s="skill"===e.type&&e.aliases?e.aliases.map(e=>e.toLowerCase()):[];return{item:e,label:t,qualified:n?`${n}:${t}`:t,parts:r.length>1?r:[],source:n,aliases:s,description:OE(e)}}let TE=null;function IE(e){if(TE?.source===e)return TE.fuse;const t=new Tn(function(e){const t=[],n=e=>{for(const r of e)"submenu"===r.type?n(r.items):_E(r)||t.push(r)};return n(e),t}(e).map(AE),{includeScore:!0,threshold:.3,location:0,distance:100,keys:[{name:"label",weight:3},{name:"qualified",weight:3},{name:"aliases",weight:3},{name:"parts",weight:2},{name:"source",weight:2},{name:"description",weight:.5}]});return TE={source:e,fuse:t},t}function DE(){return 0}function RE(e,t,n=DE){if(!t)return e.filter(e=>"submenu"!==e.type||e.items.length>0);const r=t.trim().toLowerCase();if(!r||r.length>50)return[];const s=r.indexOf(" ");if(s>0){const t=r.slice(0,s),n=e.find(e=>"button"===e.type&&!0===e.acceptsArgs&&(e.label??"").toLowerCase()===t);if(n)return[n]}return function(e,t,n){const r=new Map(e.map(e=>[e,n(e.item.qualified)]));return e.sort((e,n)=>{const s=e.item.label,i=n.item.label,o=s===t;if(o!==(i===t))return o?-1:1;const a=s.startsWith(t),l=i.startsWith(t);if(a!==l)return a?-1:1;if(a&&l&&s.length!==i.length)return s.length-i.length;const c=e.item.qualified.startsWith(t),d=n.item.qualified.startsWith(t);if(c!==d)return c?-1:1;if(c&&d&&e.item.qualified.length!==n.item.qualified.length)return e.item.qualified.length-n.item.qualified.length;const u=Math.floor(10*(e.score??0)),p=Math.floor(10*(n.score??0));return u!==p?u-p:(r.get(n)??0)-(r.get(e)??0)})}(IE(e).search(r),r,n).map(e=>e.item.item)}function LE(e){return`slash-command-skill-usage:${e}`}const PE=new Map;function jE(e,t){if(!e)return;const n=Date.now(),r=`${e}:${t}`,s=PE.get(r);if(void 0!==s&&n-s<6e4)return;PE.set(r,n);const i=LE(e),o=In(i)??{},a=o[t];Dn(i,{...o,[t]:{usageCount:(a?.usageCount??0)+1,lastUsedAt:n}})}function BE(e,t){return(t?`${t}:${e}`:e).toLowerCase()}const zE=e.createContext(void 0);function $E(e){return"skill"===e?.type?`${e.skillId}:${e.slashRouting??""}`:null}function FE(e,t){let n=t+1;for(;n<e.length&&("separator"===e[n].type||"section-header"===e[n].type);)n++;return n<e.length?n:t}function HE(e,t){let n=t-1;for(;n>=0&&("separator"===e[n].type||"section-header"===e[n].type);)n--;return n>=0?n:t}function UE(e){const t=e.findIndex(e=>"separator"!==e.type&&"section-header"!==e.type);return t>=0?t:0}function qE({children:n,items:r,onClose:s,onDismiss:i,resetKey:o}){const[a,l]=e.useState(0),[c,d]=e.useState(null),[u,p]=e.useState(-1),[h,f]=e.useState(null),[m,g]=e.useState(-1),[b,y]=e.useState("keyboard"),[v,w]=e.useState(!1),x=e.useRef(null),k=ts(o),S=ts(r);e.useEffect(()=>{o!==k?(l(UE(r)),x.current=null):r!==S&&(x.current=null,l(e=>e<r.length?e:UE(r)))},[o,k,r,S]),e.useEffect(()=>{const e=r[a];if(e&&"submenu"===e.type){const t=e.label??"";if(c!==t){const e=setTimeout(()=>{d(t),p(-1),f(null),g(-1)},150);return()=>clearTimeout(e)}}else d(null),f(null),g(-1)},[a,r,c]),e.useEffect(()=>{if(!c||u<0)return f(null),void g(-1);const e=r[a],t=("submenu"===e?.type?e.items:[])[u];if(t&&"submenu"===t.type){const e=t.label??"";if(h!==e){const t=setTimeout(()=>{f(e),g(-1)},150);return()=>clearTimeout(t)}}else f(null),g(-1)},[c,u,r,a,h]),e.useEffect(()=>{const e=()=>{v||w(!0),"keyboard"===b&&y("mouse")};return document.addEventListener("mousemove",e),()=>document.removeEventListener("mousemove",e)},[v,b]);const E=cn(e=>{if("Escape"===e.key)return e.preventDefault(),e.stopImmediatePropagation(),void(i??s)();if(!("ArrowUp"===e.key||"ArrowDown"===e.key||"ArrowLeft"===e.key||"ArrowRight"===e.key||"Enter"===e.key||"Tab"===e.key))return;const t=r[a],n="submenu"===t?.type?t.items:[],o=n[u],d="submenu"===o?.type?o.items:[],f=h&&m>=0?2:c&&u>=0?1:0;if("ArrowRight"===e.key){if(!(0===f&&"submenu"===t?.type&&c===(t.label??"")||1===f&&"submenu"===o?.type&&h===(o.label??"")))return}else if("ArrowLeft"===e.key&&f<1)return;if(y("keyboard"),w(!1),e.preventDefault(),e.stopImmediatePropagation(),"ArrowDown"===e.key||"ArrowUp"===e.key){const t="ArrowDown"===e.key?FE:HE;if(2===f){const e=t(d,m);e!==m&&(x.current=$E(d[e]),g(e))}else if(1===f){const e=t(n,u);e!==u&&(x.current=$E(n[e]),p(e))}else{const e=t(r,a);e!==a&&(x.current=$E(r[e]),l(e))}}else if("ArrowRight"===e.key)1===f?"submenu"===o?.type&&h===(o.label??"")&&g(UE(d)):0===f&&"submenu"===t?.type&&c===(t.label??"")&&p(UE(n));else if("ArrowLeft"===e.key)2===f?g(-1):1===f&&p(-1);else if("Tab"===e.key||"Enter"===e.key)if(2===f){const e=d[m];e&&"separator"!==e.type&&"section-header"!==e.type&&"submenu"!==e.type&&"search-input"!==e.type&&"loading"!==e.type&&("skill"===e.type?e.onAction?.({isExplicitSelection:null!==x.current&&x.current===$E(e)}):e.onAction?.())}else if(1===f){const e=n[u];e&&"separator"!==e.type&&"section-header"!==e.type&&"search-input"!==e.type&&"loading"!==e.type&&("submenu"===e.type?g(UE(e.items)):"skill"===e.type?e.onAction?.({isExplicitSelection:null!==x.current&&x.current===$E(e)}):e.onAction?.())}else{const e=r[a];e&&"separator"!==e.type&&"section-header"!==e.type&&"loading"!==e.type&&("submenu"===e.type?p(UE(e.items)):"search-input"!==e.type&&("skill"===e.type?e.onAction?.({isExplicitSelection:null!==x.current&&x.current===$E(e)}):e.onAction?.()))}});return e.useEffect(()=>(document.addEventListener("keydown",E,!0),()=>document.removeEventListener("keydown",E,!0)),[E]),t.jsx(zE.Provider,{value:{items:r,query:(o??"").trim().toLowerCase(),onClose:s,setActiveItemById:e=>{const t=r.findIndex(t=>"label"in t&&t.label===e);t>=0&&l(t)},setActiveIndex:l,activeIndex:a,submenuOpen:c,submenuActiveIndex:u,setSubmenuOpen:d,setSubmenuActiveIndex:p,subSubmenuOpen:h,subSubmenuActiveIndex:m,setSubSubmenuOpen:f,setSubSubmenuActiveIndex:g,interactionMode:b,hasMouseMoved:v,setHasMouseMoved:w},children:n})}function VE(){const t=e.useContext(zE);if(!t)throw new Error("useSlashCommandMenu must be used within SlashCommandMenuProvider");return t}function KE(){return t.jsx("div",{className:"h-[0.5px] bg-border-300 my-1.5 mx-2"})}function WE({items:e,activeIndex:n,depth:r=0,title:s,zIndexClassName:i,zIndex:o}){return e&&0!==e.length?t.jsxs("div",{className:"flex flex-col",children:[s&&t.jsx("div",{className:"px-2 pt-2 pb-1 text-xs font-semibold text-text-500",children:s}),e.map((e,s)=>{if("separator"===e.type)return t.jsx(KE,{},`separator:${e.label}:${s}`);if("section-header"===e.type)return t.jsx("div",{className:"px-2 pt-2 pb-1 text-xs font-semibold text-text-500",children:e.label},`section-header:${e.label}:${s}`);if("loading"===e.type)return null;const a="skill"===e.type?`skill:${e.skillId}:${s}`:`${e.type}:${"label"in e?e.label:"item"}:${s}`;return t.jsx(GE,{item:e,index:s,isActive:s===n,depth:r,zIndexClassName:i,zIndex:o},a)})]}):null}const GE=e.memo(function({item:n,index:r,isActive:s,depth:i=0,zIndexClassName:o,zIndex:a}){const{onClose:l,submenuOpen:c,subSubmenuOpen:d,setActiveIndex:u,setSubmenuActiveIndex:p,setSubSubmenuActiveIndex:h,submenuActiveIndex:f,subSubmenuActiveIndex:m,interactionMode:g,hasMouseMoved:b,setHasMouseMoved:y,query:v}=VE(),w=e.useRef(null),x=e.useRef(null),k=$E(n),S="search-input"!==n.type?n.label??"":"",E=("checkbox"===n.type||"toggle"===n.type)&&n.checked,M="checkbox"!==n.type&&"toggle"!==n.type||(n.closeOnClick??!0),_=E,N=b&&"mouse"===g,C=(0===i?c:1===i?d:null)===S,O=0===i?f:1===i?m:-1,A=C&&O>=0;if(e.useEffect(()=>{s&&"keyboard"===g&&w.current&&w.current.scrollIntoView({block:"nearest",inline:"nearest"})},[s,g]),"search-input"===n.type)return null;const T=()=>{"submenu"!==n.type&&("skill"===n.type?n.onAction?.({isExplicitSelection:null===x.current||x.current===k}):n.onAction?.(),("button"===n.type||"skill"===n.type||"connector-tool"===n.type||("checkbox"===n.type||"toggle"===n.type)&&M)&&l&&l())},I=()=>{("keyboard"!==g||b)&&(b||y(!0),0===i?u(r):1===i?p(r):h(r))},D=e=>{e.stopPropagation()},R=()=>{x.current=k};if("skill"===n.type||"connector-tool"===n.type){const e=!("skill"!==n.type||!n.skillDescription&&!n.sourcePluginName&&!n.sourceRepo);return t.jsxs(t.Fragment,{children:[t.jsxs("div",{ref:w,role:"menuitem",tabIndex:-1,"aria-disabled":n.disabled||void 0,onMouseEnter:I,onMouseDown:D,onPointerDown:R,className:tt("group flex items-center gap-2 overflow-clip pl-2 pr-1.5 py-1.5 rounded-lg font-base select-none",n.disabled?"opacity-50 cursor-not-allowed":"cursor-pointer active:bg-bg-300",s&&"bg-bg-200",N&&"hover:bg-bg-200","text-text-300"),onClick:n.disabled?void 0:T,children:[n.icon&&t.jsx("div",{className:"size-5 flex items-center justify-center opacity-50",children:n.icon}),t.jsx("span",{className:"truncate",children:t.jsx($g,{text:n.label,query:v})}),"skill"===n.type&&n.subtitle&&t.jsx("span",{className:"ml-auto pl-2 font-small text-muted shrink-0",children:n.subtitle})]}),s&&e&&"skill"===n.type&&t.jsx(Ug,{anchorRef:w,description:n.skillDescription,sourcePluginName:n.sourcePluginName,sourceRepo:n.sourceRepo,query:v})]})}return t.jsxs(t.Fragment,{children:[t.jsxs("div",{ref:w,role:"menuitem",tabIndex:-1,onMouseEnter:I,onMouseDown:D,className:tt("group flex items-start gap-2 overflow-clip pl-2 pr-1.5 py-1.5 rounded-lg font-base cursor-pointer select-none",s&&_&&"bg-accent-100/10",s&&!_&&!A&&"bg-bg-200",s&&!_&&A&&"bg-bg-100",s&&!_&&N&&"hover:bg-bg-200",_?"text-accent-100":"text-text-300",N&&_&&"hover:bg-accent-100/10",N&&!_&&"hover:bg-bg-200",s&&_&&"active:bg-accent-100/20",s&&!_&&"active:bg-bg-300"),onClick:T,children:["icon"in n&&n.icon&&t.jsx("div",{className:"size-5 flex items-center justify-center",children:n.icon}),t.jsxs("div",{className:"flex-1 flex flex-col",children:[t.jsx("span",{children:t.jsx($g,{text:n.label,query:v})}),"subtitle"in n&&n.subtitle&&t.jsx("span",{className:tt("font-small",_?"text-accent-200/75":"text-text-500"),children:n.subtitle})]}),"button"===n.type&&n.suffix&&t.jsx("div",{className:"flex items-center h-5 text-text-500 font-small",children:n.suffix}),("checkbox"===n.type||"toggle"===n.type)&&!M&&t.jsx("div",{className:"flex items-center h-5",children:t.jsx(Rn,{"aria-label":n.label,readOnly:!0,size:"small",checked:E})}),"checkbox"===n.type&&M&&E&&t.jsx(sn,{size:20,className:"text-accent-100"}),"submenu"===n.type&&t.jsx("div",{className:"h-5 flex items-center",children:t.jsx(Zr,{size:14,className:"text-text-500"})})]}),"submenu"===n.type&&C&&t.jsx(Hg,{reference:w.current?w.current.getBoundingClientRect():null,placement:"right-start",horizontalOffset:-8,verticalOffset:0,usePortal:!0,maxHeightCap:384,zIndexClassName:o,zIndex:a,children:t.jsx(WE,{items:n.items,activeIndex:O,depth:i+1,title:n.submenuTitle,zIndexClassName:o,zIndex:a})})]})});function JE({clientRect:e,maxHeightCap:n,zIndexClassName:r,zIndex:s}){const{onClose:i,items:o,activeIndex:a}=VE();return 0===o.length?null:t.jsx(Hg,{reference:e,onClickOutsideHandler:i,disableFlip:!0,maxHeightCap:n,zIndexClassName:r,zIndex:s,children:t.jsx(WE,{items:o,activeIndex:a,zIndexClassName:r,zIndex:s})})}function ZE({editor:n,query:s}){const[i,o]=e.useState(null),[a,l]=e.useState(!1),c=kr(50),[d,u]=e.useState(),p=e.useRef(null);if(e.useLayoutEffect(()=>{if(!n||!p.current)return void l(!1);const e=getComputedStyle(n.view.dom);u({fontSize:e.fontSize,fontFamily:e.fontFamily,lineHeight:e.lineHeight});const{from:t}=n.state.selection;if(t<n.state.doc.content.size-2)return o(null),void l(!1);const r=n.view.coordsAtPos(t);if(!r)return void l(!1);const s=r.left+2;o({top:r.top+(r.bottom-r.top)/2,left:s});const i=n.view.dom,a=i?.parentElement;if(a){const e=a.getBoundingClientRect(),t=p.current.offsetWidth,n=e.right-s;l(n>=t+8)}else l(!1)},[n,s]),""!==s)return null;const h=i&&a;return r.createPortal(t.jsx("span",{ref:p,className:"absolute -translate-y-1/2 text-text-500/75 font-large pointer-events-none select-none",style:{zIndex:c,top:i?.top??0,left:i?.left??0,...d,visibility:h?"visible":"hidden"},children:t.jsx(Sr,{children:t.jsx(pr,{defaultMessage:"Type to filter",id:"YHS8McfgFb"})})}),document.body)}function QE({placement:n,clientRect:r,editor:s,range:i,onClose:o,onDismiss:a,query:l}){const c=I(),{account:u}=d(),p=u?.uuid,h=e.useRef(!1),{items:f}=ME({placement:n});e.useEffect(()=>{h.current||(h.current=!0,c.track({event_key:"claudeai.slash_command_menu.opened"}))},[c]);const m=e.useCallback(e=>function(e,t){if(!e)return 0;const n=In(LE(e))?.[t];if(!n)return 0;const r=(Date.now()-n.lastUsedAt)/864e5,s=Math.pow(.5,r/7);return n.usageCount*Math.max(s,.1)}(p,e),[p]),g=e.useMemo(()=>RE(f,l,m),[f,l,m]);e.useEffect(()=>{if(!l.includes(" "))return;const e=l.indexOf(" "),t=l.slice(0,e).trim().toLowerCase();if(!t)return;const n=[],r=e=>{for(const s of e)"submenu"===s.type?r(s.items):"skill"===s.type&&NE(s,t)&&n.push(s)};if(r(f),1!==n.length)return;const a=n[0],d=l.slice(e),u=setTimeout(()=>{const e=s.storage["slash-command-suggestion"];e?.isActive&&(i.to>s.state.doc.content.size||"skill"===a.type&&(jE(p,BE(a.label??a.skillId,a.sourcePluginName)),s.chain().focus().deleteRange(i).insertContent(Ln(a.skillId,a.label??a.skillId,a.skillDescription??"",a.argumentHint??"",d||" ")).run(),c.track({event_key:"claudeai.slash_command_menu.auto_resolved",item_label:a.label??"",item_type:a.type}),o()))},0);return()=>{clearTimeout(u)}},[l,f,s,i,o,c,p]);const b=e.useCallback(e=>"separator"===e.type||"section-header"===e.type?e:"submenu"===e.type?{...e,items:e.items.map(e=>b(e))}:"search-input"===e.type||"loading"===e.type?e:{...e,onAction:()=>{if(c.track({event_key:"claudeai.slash_command_menu.item_selected",item_label:e.label??"",item_type:e.type}),"skill"===e.type)return jE(p,BE(e.label??e.skillId,e.sourcePluginName)),s.chain().focus().deleteRange(i).insertContent(Ln(e.skillId,e.label??e.skillId,e.skillDescription??"",e.argumentHint??"")).run(),void o();if("connector-tool"===e.type){if(e.disabled)return;return s.chain().focus().deleteRange(i).insertContent(Pn(e.toolName,e.label??e.toolName,e.connectorName??"")).run(),void o()}if("button"===e.type){let t;if(e.acceptsArgs){const n=(e.label??"").toLowerCase(),r=l.trim().toLowerCase();r.length>n.length&&r.startsWith(n+" ")&&(t=l.trim().slice(n.length+1).trim())}e.onAction?.(t)}else e.onAction?.();("button"===e.type||"checkbox"===e.type&&(e.closeOnClick??!0))&&(!function(e,t){e.chain().focus().deleteRange(t).run()}(s,i),o())}},[c,s,o,i,p,l]),y=e.useMemo(()=>g.map(e=>b(e)),[g,b]);e.useEffect(()=>{s&&s.view.dom.focus()},[s]);const v=y.length>0;return e.useEffect(()=>{const e=s.storage["slash-command-suggestion"];e&&(e.hasVisibleItems=v)},[s,v]),v?t.jsxs(t.Fragment,{children:[t.jsx(ZE,{editor:s,query:l||""}),t.jsx(qE,{items:y,onClose:o,onDismiss:a,resetKey:l,children:t.jsx(JE,{clientRect:r,maxHeightCap:384})})]}):null}GE.displayName="SlashCommandMenuItem";const XE=new bc("slash-command-suggestion");function YE(e,t,n,r){return{items:()=>[{}],command:()=>{},allow:({state:e,range:t})=>{const r=n.storage["slash-command-suggestion"];if(r?.disabled)return!1;if(r?.justClosed)return!1;if(null!=r?.dismissedTriggerFrom&&r.dismissedTriggerFrom===t.from)return!1;if(t.to-t.from>51)return!1;const s=e.doc.textBetween(t.from,t.to,"");if((s.startsWith("/")?s.slice(1):s).startsWith(" "))return!1;const i=e.doc.resolve(t.to),o=i.parentOffset;if(o<i.parent.content.size){if(""!==i.parent.textBetween(o,o+1).trim())return!1}return!0},render:()=>{let s=null,i=null,o=null,a=0;const l=n=>({placement:e,hostInterceptSurface:t,clientRect:n.clientRect,editor:n.editor,range:n.range,query:n.query,onClose:()=>bE(n.editor.view,XE),onDismiss:()=>{!function(e,t){const n=XE.getState(t.state),r=n?.range?.from;if(void 0===r)return;if("/"!==t.state.doc.textBetween(r,r+1,""))return;e.storage["slash-command-suggestion"].dismissedTriggerFrom=r}(n.editor,n.editor.view),bE(n.editor.view,XE)}});return{onStart:e=>{const t=e.editor.storage["slash-command-suggestion"];t.isActive||(t.isActive=!0,Bn("slash_menu",!0)),t.hasVisibleItems=!0,o=e;const n=++a;jn().then(()=>{e.editor.isDestroyed||n!==a||(i=new Bb(r,{props:l(o??e),editor:e.editor}),s=i.element,s.style.pointerEvents="auto",document.body.appendChild(s),function(e,t,n){const r=e.storage["slash-command-suggestion"];r.cleanup=()=>{t.destroy(),requestAnimationFrame(()=>{n.parentNode?.removeChild(n)})}}(e.editor,i,s))})},onUpdate:e=>{o=e,i?.updateProps(l(e))},onKeyDown:({event:e,view:t})=>{if("Escape"===e.key)return bE(t,XE),!0;const r=n.storage["slash-command-suggestion"];return!!r?.hasVisibleItems&&(("Enter"!==e.key||!e.shiftKey)&&("Enter"===e.key||"Tab"===e.key||"ArrowUp"===e.key||"ArrowDown"===e.key))},onExit:e=>{a++,o=null;const t=e.editor.storage["slash-command-suggestion"];if(t.isActive&&(t.isActive=!1,Bn("slash_menu",!1)),t.hasVisibleItems=!1,t.cleanup=null,t.justClosed=!0,setTimeout(()=>{t.justClosed=!1},100),i&&(i.destroy(),i=null),s){const e=s;s=null,requestAnimationFrame(()=>{e.parentNode?.removeChild(e)})}}}}}}const eM=rm.create({name:"slash-command-suggestion",addOptions:()=>({placement:"onpage",hostInterceptSurface:!1,menuComponent:void 0}),addStorage:()=>({isActive:!1,justClosed:!1,hasVisibleItems:!1,cleanup:null,disabled:!1,dismissedTriggerFrom:null}),onDestroy(){this.storage.cleanup?.(),this.storage.cleanup=null,this.storage.isActive&&(this.storage.isActive=!1,Bn("slash_menu",!1))},onTransaction({transaction:e}){const t=this.storage;if(null===t.dismissedTriggerFrom||!e.docChanged)return;const n=e.mapping.mapResult(t.dismissedTriggerFrom),r=!n.deleted&&n.pos<e.doc.content.size&&"/"===e.doc.textBetween(n.pos,n.pos+1,"");t.dismissedTriggerFrom=r?n.pos:null},addProseMirrorPlugins(){const e=this.options.menuComponent??QE;return[yE({editor:this.editor,pluginKey:XE,char:"/",allowSpaces:!0,...YE(this.options.placement,this.options.hostInterceptSurface??!1,this.editor,e)})]}});function tM(e,t,n){const r=e?"local":"remote",s=e?"remote":"local";zn("cowork.remote_backend_changed",{attributes:{from:r,to:s,source:t}}),n({event_key:"claudeai.cowork.remote_backend.changed",from:r,to:s,source:t}),e||zn("cowork.remote_opt_out",{attributes:{from:r,to:s,source:t}})}const nM=Date.parse("2026-08-06T06:59:59Z"),rM=lr([rr({enabled:ir().optional(),learn_more_url:ar().url().startsWith("https://").optional()}).passthrough(),ar(),cr(),dr()]);function sM(e={enabled:!0}){const t=Date.now()<nM,n=$n("cowork_2x_promo",null,rM,e.enabled&&t),r=n&&"object"==typeof n?n:void 0;return{enabled:t&&!0===r?.enabled,learnMoreUrl:r?.learn_more_url||"https://www.claude.com"}}const iM=e.memo(function({capAtIcon:n=!1,fallback:r}={}){const{enabled:s,learnMoreUrl:i}=sM(),o=at("cowork_promo_extension",s),{track:a}=I(),l=ur(),c=e.useCallback(()=>{a({event_key:"cowork.promo_2x.pill_clicked"})},[a]),[d,u]=es({box:"border-box"}),p=u.width,h=p>=200&&!n?"label":p>=40?"icon":"hidden",f=s&&"hidden"!==h,m=e.useRef(!1);e.useEffect(()=>{f&&!m.current?(m.current=!0,a({event_key:"cowork.promo_2x.displayed"})):f||(m.current=!1)},[a,f]);const g=o?l.formatMessage({defaultMessage:"2\xd7 more usage until August 5",id:"QCGujWali4"}):l.formatMessage({defaultMessage:"2\xd7 more usage until July 5",id:"d4u+iLejts"}),b={...Fn({href:i,webBehavior:"new-tab",desktopBehavior:"open-in-browser"}),rel:"noreferrer",onClick:c};return t.jsxs("div",{ref:d,className:"flex min-w-0 flex-1 items-center justify-end",children:[!s&&r,s&&"label"===h&&t.jsxs("a",{...b,className:"group inline-flex cursor-pointer items-center gap-1 text-muted transition-colors hover:text-primary",children:[t.jsx(vr,{name:"Lightning",size:"sm"}),t.jsx("span",{className:"underline-offset-2 group-hover:underline",children:g})]}),s&&"icon"===h&&t.jsx(gr,{variant:"ghost",size:"xs",icon:"Lightning",iconOnly:!0,"aria-label":g,className:"text-muted",...b})]})});function oM(){const e=Vt(),t=Wn();return e&&(t.considerEnabledForNonUI??!1)}function aM(){}const lM=e.memo(function({disabled:n,selectionLocked:r,overrideSelection:s}){const i=oM(),o=e.useMemo(()=>s&&{selectedFolders:s.selectedFolders,selectedProjectUuids:s.selectedProjectUuids,toggleSelectedFolder:aM,addSelectedFolder:aM,toggleSelectedProject:aM},[s]);return i?t.jsx("div",{className:"relative z-0 mx-2 -mt-5 rounded-b-[20px] bg-always-black/[0.01] shadow-[inset_0_0_0_0.5px_hsl(var(--border-300)/0.18),inset_0_0_0_1px_hsl(var(--bg-000)/0.8)] backdrop-blur-[2px] md:mx-0",children:t.jsxs("div",{className:"flex items-center gap-1 px-2 pb-1 pt-6",children:[t.jsx(Kn,{disabled:n||r,controlledSelection:o}),t.jsx(pb,{variant:"new-task",placement:"chin"}),t.jsx(iM,{})]})}):null}),cM={remote:"1w99mn",local:"1agq8ew"},dM={remote:"1bwzob5",local:"dqh848"},uM={folder:"1uymrfx",auto:"12hcfam",chrome_skip:"lj6w0d",options:"1whqemf",override:"chtsb",computer_use:"19mardu"},pM={dateAdded:"2026-06-25",priority:io.MEDIUM,showAfterOthersDismiss:!0};function hM({anchorRef:e,onDismiss:n}){const r=ur();return t.jsx(_r,{open:!0,onOpenChange:e=>!e&&n(),anchor:e,side:"top",align:"end",introDelay:.5,showClose:!0,"aria-label":qn({intl:r,id:"9xi3ir"}),badge:t.jsx(Mr,{size:"xxs",variant:"neutral",className:"!bg-on-accent/15 !text-on-accent",children:t.jsx(pr,{defaultMessage:"Beta",id:"riw/yc06Nq"})}),title:t.jsx(Vn,{id:"9xi3ir"}),children:t.jsx(Vn,{id:"gcmmvb"})})}const fM=e.memo(function({overrideSelection:n}={}){const r=ne(),s=Ht(e=>e.draftPermissionMode),i=T(),o=at("yukon_silver_dramatic_shrimp_internal",!1),a=Ae(),l=Hn(n),c=r.forcedLocalOverride?"override":"local_folder_forced"===l||"local_space_forced"===l?"folder":"local_auto_permission_forced"===l?"auto":"local_chrome_skip_forced"===l?"chrome_skip":"local_options_forced"===l?"options":"local_computer_use_forced"===l?"computer_use":null,d=Boolean(oe?.start)?null:"no_bridge",u=ur(),{track:p}=I(),[h,f]=e.useState(!1),[m,g]=e.useState(!1),b=e.useRef(null),y=uo(e=>null!==e.type),[v]=Un(()=>!!localStorage.getItem("LSS-ysds-cloud-coachmark-dismissed"),!1),{shouldShow:w,dismiss:x}=co("cowork-remote-cloud-beta",pM,{enabled:r.orgAvailable&&i&&r.canChooseBackend&&!r.isLoading&&null===c&&"remote"===l&&!y&&!v}),k=e.useRef(x);k.current=x;const S=e.useCallback(async e=>{k.current();const t="remote"===e;if(t!==("remote"===l)&&!m){g(!0);try{await r.setIsRemote(t),tM(t,"header",p)}catch{}finally{g(!1)}}},[r,m,p,o,a,l]);if(!r.orgAvailable||!i||!r.canChooseBackend)return null;if(r.isLoading&&!r.forcedLocalOverride)return null;const E="remote"===l?"remote":"local",M=null===c&&"remote"===E?"Cloud":"Computer";return t.jsxs(t.Fragment,{children:[null!==c?t.jsx("span",{className:"inline-flex cursor-not-allowed",children:t.jsx(fr,{multiline:!0,content:"auto"===c&&"auto"===s?t.jsx(pr,{defaultMessage:"This task will run on your computer. Auto only runs locally.",id:"OjvwkxrHwM"}):t.jsx(Vn,{id:uM[c]}),children:t.jsx("button",{type:"button","aria-disabled":!0,className:"flex h-9 cursor-not-allowed items-center rounded px-2 text-secondary opacity-50","aria-label":qn({intl:u,id:"16tja0q"}),children:t.jsx(vr,{name:M,size:"sm"})})})}):t.jsx("span",{ref:b,className:"inline-flex",children:t.jsxs(xr.Root,{onOpenChange:e=>e&&k.current(),children:[t.jsx(xr.Trigger,{render:t.jsx("span",{className:"group",children:t.jsx(fr,{content:t.jsx(Vn,{id:"remote"===E?"cu219u":"gcwg93"}),children:t.jsxs("button",{type:"button",className:"flex h-9 items-center gap-1.5 rounded px-2 text-secondary hover:bg-alpha-1 hover:text-primary group-data-[popup-open]:bg-alpha-1 group-data-[popup-open]:text-primary","aria-label":qn({intl:u,id:"16tja0q"}),children:[t.jsx(vr,{name:M,size:"sm"}),"remote"===E&&t.jsx("span",{className:"text-caption font-medium",children:t.jsx(pr,{defaultMessage:"Beta",id:"riw/yc06Nq"})})]})})})}),t.jsx(xr.Popup,{align:"end",className:"min-w-64 !max-w-sm",children:t.jsxs(xr.Group,{children:[t.jsx(xr.GroupLabel,{children:t.jsx(Vn,{id:"1agh9y9"})}),Object.keys(cM).map(e=>{const n=m||"local"===e&&null!==d;return t.jsx(xr.Item,{checkedRole:"radio",checked:E===e,disabled:n,onClick:n?void 0:()=>S(e),children:t.jsxs("span",{className:"flex flex-col gap-0.5 whitespace-normal",children:[t.jsxs("span",{className:"flex items-center gap-xs",children:[t.jsx(Vn,{id:cM[e]}),"remote"===e&&t.jsx(Mr,{size:"xxs",variant:"neutral",children:t.jsx(pr,{defaultMessage:"Beta",id:"riw/yc06Nq"})})]}),t.jsx("span",{className:"text-footnote text-muted",children:t.jsx(Vn,{id:dM[e]})})]})},e)})]})})]})}),w&&t.jsx(hM,{anchorRef:b,onDismiss:x}),""]})});export{fb as $,Sc as A,Ap as B,Oc as C,Dp as D,rm as E,Xw as F,Vi as G,tM as H,sM as I,pb as J,iM as K,QE as L,Vg as M,oo as N,is as O,fc as P,ds as Q,oy as R,Lo as S,hE as T,Rg as U,eM as V,lE as W,Lg as X,Pg as Y,Sb as Z,iy as _,jo as a,If as a$,ra as a0,Qo as a1,yo as a2,fo as a3,vo as a4,db as a5,ib as a6,cM as a7,Ni as a8,Us as a9,ps as aA,as as aB,Jg as aC,nb as aD,tb as aE,Ws as aF,eb as aG,Yg as aH,us as aI,xS as aJ,Uc as aK,Vs as aL,yE as aM,Kf as aN,bE as aO,Bb as aP,Jl as aQ,Zl as aR,Yl as aS,xh as aT,Hf as aU,qf as aV,tc as aW,vf as aX,wf as aY,Tb as aZ,_b as a_,_o as aa,fM as ab,lM as ac,so as ad,Io as ae,Ao as af,No as ag,hb as ah,Gs as ai,bb as aj,gh as ak,dh as al,uh as am,Zg as an,Is as ao,qs as ap,Do as aq,zs as ar,Ns as as,gs as at,Cs as au,Ms as av,_s as aw,Es as ax,vs as ay,Ss as az,Mo as b,Tg as b$,aE as b0,Vc as b1,KS as b2,Qg as b3,Xg as b4,Ac as b5,ws as b6,ji as b7,ti as b8,ri as b9,Bs as bA,js as bB,Ps as bC,Ds as bD,hs as bE,fs as bF,Ui as bG,Ls as bH,Bg as bI,Wc as bJ,Ji as bK,dy as bL,_i as bM,zo as bN,Bo as bO,$o as bP,Wo as bQ,Ei as bR,ki as bS,Si as bT,di as bU,ro as bV,Po as bW,Ks as bX,Ii as bY,Ug as bZ,ns as b_,es as ba,Ro as bb,xc as bc,wc as bd,no as be,vc as bf,eo as bg,ui as bh,ko as bi,So as bj,Ri as bk,Li as bl,mi as bm,vi as bn,gi as bo,wi as bp,ni as bq,Qs as br,si as bs,ts as bt,zg as bu,oM as bv,ao as bw,Gi as bx,Wi as by,Rs as bz,Eo as c,pf as c0,$b as c1,Lb as c2,Kc as c3,Xr as c4,_c as c5,Zi as d,Ki as e,Jb as f,Qb as g,Kb as h,cs as i,rb as j,Kg as k,Wg as l,Tc as m,wE as n,ks as o,RE as p,ZE as q,qE as r,JE as s,ME as t,uo as u,co as v,io as w,to as x,jg as y,bc as z};
