tandem-editor 0.11.0 → 0.11.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +67 -37
- package/README.md +4 -0
- package/dist/channel/index.js +2 -0
- package/dist/channel/index.js.map +1 -1
- package/dist/cli/index.js +4 -2
- package/dist/cli/index.js.map +1 -1
- package/dist/client/assets/CoworkSettings-DK3jjdwK.js +3 -0
- package/dist/client/assets/index-CfT503n4.js +297 -0
- package/dist/client/assets/index-DeJe09pn.css +1 -0
- package/dist/client/index.html +2 -2
- package/dist/monitor/index.js +2 -0
- package/dist/monitor/index.js.map +1 -1
- package/dist/server/index.js +24 -8
- package/dist/server/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/client/assets/CoworkSettings-ChE5WuAe.js +0 -3
- package/dist/client/assets/index-BJKuWd_k.css +0 -1
- package/dist/client/assets/index-vu_QxvyU.js +0 -310
|
@@ -1,310 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/window-BxBvHL5k.js","assets/core-DhEqZVGG.js","assets/webview-Ben21ZLJ.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
var DS=Object.defineProperty;var mv=n=>{throw TypeError(n)};var RS=(n,e,t)=>e in n?DS(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var Vn=(n,e,t)=>RS(n,typeof e!="symbol"?e+"":e,t),Lf=(n,e,t)=>e.has(n)||mv("Cannot "+t);var H=(n,e,t)=>(Lf(n,e,"read from private field"),t?t.call(n):e.get(n)),Je=(n,e,t)=>e.has(n)?mv("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(n):e.set(n,t),it=(n,e,t,r)=>(Lf(n,e,"write to private field"),r?r.call(n,t):e.set(n,t),t),St=(n,e,t)=>(Lf(n,e,"access private method"),t);(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const o of i)if(o.type==="childList")for(const s of o.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&r(s)}).observe(document,{childList:!0,subtree:!0});function t(i){const o={};return i.integrity&&(o.integrity=i.integrity),i.referrerPolicy&&(o.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?o.credentials="include":i.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function r(i){if(i.ep)return;i.ep=!0;const o=t(i);fetch(i.href,o)}})();const NS=!1;var Sm=Array.isArray,IS=Array.prototype.indexOf,ua=Array.prototype.includes,Zu=Array.from,PS=Object.defineProperty,uo=Object.getOwnPropertyDescriptor,G0=Object.getOwnPropertyDescriptors,LS=Object.prototype,zS=Array.prototype,Cm=Object.getPrototypeOf,gv=Object.isExtensible;function ja(n){return typeof n=="function"}const Ci=()=>{};function BS(n){return typeof(n==null?void 0:n.then)=="function"}function FS(n){for(var e=0;e<n.length;e++)n[e]()}function Z0(){var n,e,t=new Promise((r,i)=>{n=r,e=i});return{promise:t,resolve:n,reject:e}}function vv(n,e){if(Array.isArray(n))return n;if(!(Symbol.iterator in n))return Array.from(n);const t=[];for(const r of n)if(t.push(r),t.length===e)break;return t}const Tn=2,fa=4,Xu=8,X0=1<<24,ei=16,Nr=32,Bi=64,Wh=128,vr=512,$t=1024,vn=2048,si=4096,In=8192,tr=16384,Ts=32768,Kh=1<<25,yo=65536,qh=1<<17,VS=1<<18,As=1<<19,HS=1<<20,Zr=1<<25,ds=65536,Ed=1<<21,Cl=1<<22,fo=1<<23,ti=Symbol("$state"),Q0=Symbol("legacy props"),US=Symbol(""),Ti=new class extends Error{constructor(){super(...arguments);Vn(this,"name","StaleReactionError");Vn(this,"message","The reaction that called `getAbortSignal()` was re-run or destroyed")}};var q0;const jS=!!((q0=globalThis.document)!=null&&q0.contentType)&&globalThis.document.contentType.includes("xml");function $0(n){throw new Error("https://svelte.dev/e/lifecycle_outside_component")}function WS(){throw new Error("https://svelte.dev/e/async_derived_orphan")}function KS(n,e,t){throw new Error("https://svelte.dev/e/each_key_duplicate")}function qS(n){throw new Error("https://svelte.dev/e/effect_in_teardown")}function JS(){throw new Error("https://svelte.dev/e/effect_in_unowned_derived")}function YS(n){throw new Error("https://svelte.dev/e/effect_orphan")}function GS(){throw new Error("https://svelte.dev/e/effect_update_depth_exceeded")}function ZS(n){throw new Error("https://svelte.dev/e/props_invalid_value")}function XS(){throw new Error("https://svelte.dev/e/state_descriptors_fixed")}function QS(){throw new Error("https://svelte.dev/e/state_prototype_fixed")}function $S(){throw new Error("https://svelte.dev/e/state_unsafe_mutation")}function eC(){throw new Error("https://svelte.dev/e/svelte_boundary_reset_onerror")}const tC=1,nC=2,ew=4,rC=8,iC=16,oC=1,sC=2,aC=4,lC=8,cC=16,dC=1,uC=2,Zt=Symbol(),tw="http://www.w3.org/1999/xhtml",fC="http://www.w3.org/2000/svg",hC="http://www.w3.org/1998/Math/MathML";function pC(){console.warn("https://svelte.dev/e/derived_inert")}function mC(){console.warn("https://svelte.dev/e/select_multiple_invalid_value")}function gC(){console.warn("https://svelte.dev/e/svelte_boundary_reset_noop")}function nw(n){return n===this.v}function rw(n,e){return n!=n?e==e:n!==e||n!==null&&typeof n=="object"||typeof n=="function"}function iw(n){return!rw(n,this.v)}let Na=!1,vC=!1;function yC(){Na=!0}let Pt=null;function ha(n){Pt=n}function We(n,e=!1,t){Pt={p:Pt,i:!1,c:null,e:null,s:n,x:null,r:$e,l:Na&&!e?{s:null,u:null,$:[]}:null}}function Ke(n){var e=Pt,t=e.e;if(t!==null){e.e=null;for(var r of t)Aw(r)}return e.i=!0,Pt=e.p,{}}function Es(){return!Na||Pt!==null&&Pt.l===null}let Fo=[];function ow(){var n=Fo;Fo=[],FS(n)}function ni(n){if(Fo.length===0&&!Ys){var e=Fo;queueMicrotask(()=>{e===Fo&&ow()})}Fo.push(n)}function bC(){for(;Fo.length>0;)ow()}function sw(n){var e=$e;if(e===null)return st.f|=fo,n;if((e.f&Ts)===0&&(e.f&fa)===0)throw n;oo(n,e)}function oo(n,e){for(;e!==null;){if((e.f&Wh)!==0){if((e.f&Ts)===0)throw n;try{e.b.error(n);return}catch(t){n=t}}e=e.parent}throw n}const wC=-7169;function Vt(n,e){n.f=n.f&wC|e}function Tm(n){(n.f&vr)!==0||n.deps===null?Vt(n,$t):Vt(n,si)}function aw(n){if(n!==null)for(const e of n)(e.f&Tn)===0||(e.f&ds)===0||(e.f^=ds,aw(e.deps))}function lw(n,e,t){(n.f&vn)!==0?e.add(n):(n.f&si)!==0&&t.add(n),aw(n.deps),Vt(n,$t)}let Rc=!1;function xC(n){var e=Rc;try{return Rc=!1,[n(),Rc]}finally{Rc=e}}const No=new Set;let Be=null,fn=null,Jh=null,Ys=!1,zf=!1,Ws=null,rd=null;var yv=0;let kC=1;var sa,aa,Jo,Ai,Jr,cc,Zn,dc,ro,Ei,Yr,la,ca,Yo,Kt,id,cw,od,Yh,sd,_C;const qu=class qu{constructor(){Je(this,Kt);Vn(this,"id",kC++);Vn(this,"current",new Map);Vn(this,"previous",new Map);Je(this,sa,new Set);Je(this,aa,new Set);Je(this,Jo,new Set);Je(this,Ai,new Map);Je(this,Jr,new Map);Je(this,cc,null);Je(this,Zn,[]);Je(this,dc,[]);Je(this,ro,new Set);Je(this,Ei,new Set);Je(this,Yr,new Map);Je(this,la,new Set);Vn(this,"is_fork",!1);Je(this,ca,!1);Je(this,Yo,new Set)}skip_effect(e){H(this,Yr).has(e)||H(this,Yr).set(e,{d:[],m:[]}),H(this,la).delete(e)}unskip_effect(e,t=r=>this.schedule(r)){var r=H(this,Yr).get(e);if(r){H(this,Yr).delete(e);for(var i of r.d)Vt(i,vn),t(i);for(i of r.m)Vt(i,si),t(i)}H(this,la).add(e)}capture(e,t,r=!1){e.v!==Zt&&!this.previous.has(e)&&this.previous.set(e,e.v),(e.f&fo)===0&&(this.current.set(e,[t,r]),fn==null||fn.set(e,t)),this.is_fork||(e.v=t)}activate(){Be=this}deactivate(){Be=null,fn=null}flush(){try{zf=!0,Be=this,St(this,Kt,od).call(this)}finally{yv=0,Jh=null,Ws=null,rd=null,zf=!1,Be=null,fn=null,Qo.clear()}}discard(){for(const e of H(this,aa))e(this);H(this,aa).clear(),H(this,Jo).clear(),No.delete(this)}register_created_effect(e){H(this,dc).push(e)}increment(e,t){let r=H(this,Ai).get(t)??0;if(H(this,Ai).set(t,r+1),e){let i=H(this,Jr).get(t)??0;H(this,Jr).set(t,i+1)}}decrement(e,t,r){let i=H(this,Ai).get(t)??0;if(i===1?H(this,Ai).delete(t):H(this,Ai).set(t,i-1),e){let o=H(this,Jr).get(t)??0;o===1?H(this,Jr).delete(t):H(this,Jr).set(t,o-1)}H(this,ca)||r||(it(this,ca,!0),ni(()=>{it(this,ca,!1),this.flush()}))}transfer_effects(e,t){for(const r of e)H(this,ro).add(r);for(const r of t)H(this,Ei).add(r);e.clear(),t.clear()}oncommit(e){H(this,sa).add(e)}ondiscard(e){H(this,aa).add(e)}on_fork_commit(e){H(this,Jo).add(e)}run_fork_commit_callbacks(){for(const e of H(this,Jo))e(this);H(this,Jo).clear()}settled(){return(H(this,cc)??it(this,cc,Z0())).promise}static ensure(){if(Be===null){const e=Be=new qu;zf||(No.add(Be),Ys||ni(()=>{Be===e&&e.flush()}))}return Be}apply(){{fn=null;return}}schedule(e){var i;if(Jh=e,(i=e.b)!=null&&i.is_pending&&(e.f&(fa|Xu|X0))!==0&&(e.f&Ts)===0){e.b.defer_effect(e);return}for(var t=e;t.parent!==null;){t=t.parent;var r=t.f;if(Ws!==null&&t===$e&&(st===null||(st.f&Tn)===0))return;if((r&(Bi|Nr))!==0){if((r&$t)===0)return;t.f^=$t}}H(this,Zn).push(t)}};sa=new WeakMap,aa=new WeakMap,Jo=new WeakMap,Ai=new WeakMap,Jr=new WeakMap,cc=new WeakMap,Zn=new WeakMap,dc=new WeakMap,ro=new WeakMap,Ei=new WeakMap,Yr=new WeakMap,la=new WeakMap,ca=new WeakMap,Yo=new WeakMap,Kt=new WeakSet,id=function(){return this.is_fork||H(this,Jr).size>0},cw=function(){for(const r of H(this,Yo))for(const i of H(r,Jr).keys()){for(var e=!1,t=i;t.parent!==null;){if(H(this,Yr).has(t)){e=!0;break}t=t.parent}if(!e)return!0}return!1},od=function(){var a,l;if(yv++>1e3&&(No.delete(this),SC()),!St(this,Kt,id).call(this)){for(const c of H(this,ro))H(this,Ei).delete(c),Vt(c,vn),this.schedule(c);for(const c of H(this,Ei))Vt(c,si),this.schedule(c)}const e=H(this,Zn);it(this,Zn,[]),this.apply();var t=Ws=[],r=[],i=rd=[];for(const c of e)try{St(this,Kt,Yh).call(this,c,t,r)}catch(d){throw hw(c),d}if(Be=null,i.length>0){var o=qu.ensure();for(const c of i)o.schedule(c)}if(Ws=null,rd=null,St(this,Kt,id).call(this)||St(this,Kt,cw).call(this)){St(this,Kt,sd).call(this,r),St(this,Kt,sd).call(this,t);for(const[c,d]of H(this,Yr))fw(c,d)}else{H(this,Ai).size===0&&No.delete(this),H(this,ro).clear(),H(this,Ei).clear();for(const c of H(this,sa))c(this);H(this,sa).clear(),bv(r),bv(t),(a=H(this,cc))==null||a.resolve()}var s=Be;if(H(this,Zn).length>0){const c=s??(s=this);H(c,Zn).push(...H(this,Zn).filter(d=>!H(c,Zn).includes(d)))}s!==null&&(No.add(s),St(l=s,Kt,od).call(l))},Yh=function(e,t,r){e.f^=$t;for(var i=e.first;i!==null;){var o=i.f,s=(o&(Nr|Bi))!==0,a=s&&(o&$t)!==0,l=a||(o&In)!==0||H(this,Yr).has(i);if(!l&&i.fn!==null){s?i.f^=$t:(o&fa)!==0?t.push(i):yc(i)&&((o&ei)!==0&&H(this,Ei).add(i),pa(i));var c=i.first;if(c!==null){i=c;continue}}for(;i!==null;){var d=i.next;if(d!==null){i=d;break}i=i.parent}}},sd=function(e){for(var t=0;t<e.length;t+=1)lw(e[t],H(this,ro),H(this,Ei))},_C=function(){var d,u,h;for(const p of No){var e=p.id<this.id,t=[];for(const[m,[v,g]]of this.current){if(p.current.has(m)){var r=p.current.get(m)[0];if(e&&v!==r)p.current.set(m,[v,g]);else continue}t.push(m)}var i=[...p.current.keys()].filter(m=>!this.current.has(m));if(i.length===0)e&&p.discard();else if(t.length>0){if(e)for(const m of H(this,la))p.unskip_effect(m,v=>{var g;(v.f&(ei|Cl))!==0?p.schedule(v):St(g=p,Kt,sd).call(g,[v])});p.activate();var o=new Set,s=new Map;for(var a of t)uw(a,i,o,s);s=new Map;var l=[...p.current.keys()].filter(m=>this.current.has(m)?this.current.get(m)[0]!==m:!0);for(const m of H(this,dc))(m.f&(tr|In|qh))===0&&Am(m,l,s)&&((m.f&(Cl|ei))!==0?(Vt(m,vn),p.schedule(m)):H(p,ro).add(m));if(H(p,Zn).length>0){p.apply();for(var c of H(p,Zn))St(d=p,Kt,Yh).call(d,c,[],[]);it(p,Zn,[])}p.deactivate()}}for(const p of No)H(p,Yo).has(this)&&(H(p,Yo).delete(this),H(p,Yo).size===0&&!St(u=p,Kt,id).call(u)&&(p.activate(),St(h=p,Kt,od).call(h)))};let Fi=qu;function dw(n){var e=Ys;Ys=!0;try{for(var t;;){if(bC(),Be===null)return t;Be.flush()}}finally{Ys=e}}function SC(){try{GS()}catch(n){oo(n,Jh)}}let Ar=null;function bv(n){var e=n.length;if(e!==0){for(var t=0;t<e;){var r=n[t++];if((r.f&(tr|In))===0&&yc(r)&&(Ar=new Set,pa(r),r.deps===null&&r.first===null&&r.nodes===null&&r.teardown===null&&r.ac===null&&Dw(r),(Ar==null?void 0:Ar.size)>0)){Qo.clear();for(const i of Ar){if((i.f&(tr|In))!==0)continue;const o=[i];let s=i.parent;for(;s!==null;)Ar.has(s)&&(Ar.delete(s),o.push(s)),s=s.parent;for(let a=o.length-1;a>=0;a--){const l=o[a];(l.f&(tr|In))===0&&pa(l)}}Ar.clear()}}Ar=null}}function uw(n,e,t,r){if(!t.has(n)&&(t.add(n),n.reactions!==null))for(const i of n.reactions){const o=i.f;(o&Tn)!==0?uw(i,e,t,r):(o&(Cl|ei))!==0&&(o&vn)===0&&Am(i,e,r)&&(Vt(i,vn),Em(i))}}function Am(n,e,t){const r=t.get(n);if(r!==void 0)return r;if(n.deps!==null)for(const i of n.deps){if(ua.call(e,i))return!0;if((i.f&Tn)!==0&&Am(i,e,t))return t.set(i,!0),!0}return t.set(n,!1),!1}function Em(n){Be.schedule(n)}function fw(n,e){if(!((n.f&Nr)!==0&&(n.f&$t)!==0)){(n.f&vn)!==0?e.d.push(n):(n.f&si)!==0&&e.m.push(n),Vt(n,$t);for(var t=n.first;t!==null;)fw(t,e),t=t.next}}function hw(n){Vt(n,$t);for(var e=n.first;e!==null;)hw(e),e=e.next}function CC(n){let e=0,t=Vi(0),r;return()=>{Dm()&&(f(t),vc(()=>(e===0&&(r=Ut(()=>n(()=>il(t)))),e+=1,()=>{ni(()=>{e-=1,e===0&&(r==null||r(),r=void 0,il(t))})})))}}var TC=yo|As;function pw(n,e,t,r){new AC(n,e,t,r)}var lr,_m,cr,Go,Hn,dr,Rn,Xn,Mi,Zo,io,da,uc,fc,Oi,Ju,Lt,EC,MC,OC,Gh,ad,ld,Zh,Xh;class AC{constructor(e,t,r,i){Je(this,Lt);Vn(this,"parent");Vn(this,"is_pending",!1);Vn(this,"transform_error");Je(this,lr);Je(this,_m,null);Je(this,cr);Je(this,Go);Je(this,Hn);Je(this,dr,null);Je(this,Rn,null);Je(this,Xn,null);Je(this,Mi,null);Je(this,Zo,0);Je(this,io,0);Je(this,da,!1);Je(this,uc,new Set);Je(this,fc,new Set);Je(this,Oi,null);Je(this,Ju,CC(()=>(it(this,Oi,Vi(H(this,Zo))),()=>{it(this,Oi,null)})));var o;it(this,lr,e),it(this,cr,t),it(this,Go,s=>{var a=$e;a.b=this,a.f|=Wh,r(s)}),this.parent=$e.b,this.transform_error=i??((o=this.parent)==null?void 0:o.transform_error)??(s=>s),it(this,Hn,Ms(()=>{St(this,Lt,Gh).call(this)},TC))}defer_effect(e){lw(e,H(this,uc),H(this,fc))}is_rendered(){return!this.is_pending&&(!this.parent||this.parent.is_rendered())}has_pending_snippet(){return!!H(this,cr).pending}update_pending_count(e,t){St(this,Lt,Zh).call(this,e,t),it(this,Zo,H(this,Zo)+e),!(!H(this,Oi)||H(this,da))&&(it(this,da,!0),ni(()=>{it(this,da,!1),H(this,Oi)&&Ri(H(this,Oi),H(this,Zo))}))}get_effect_pending(){return H(this,Ju).call(this),f(H(this,Oi))}error(e){if(!H(this,cr).onerror&&!H(this,cr).failed)throw e;Be!=null&&Be.is_fork?(H(this,dr)&&Be.skip_effect(H(this,dr)),H(this,Rn)&&Be.skip_effect(H(this,Rn)),H(this,Xn)&&Be.skip_effect(H(this,Xn)),Be.on_fork_commit(()=>{St(this,Lt,Xh).call(this,e)})):St(this,Lt,Xh).call(this,e)}}lr=new WeakMap,_m=new WeakMap,cr=new WeakMap,Go=new WeakMap,Hn=new WeakMap,dr=new WeakMap,Rn=new WeakMap,Xn=new WeakMap,Mi=new WeakMap,Zo=new WeakMap,io=new WeakMap,da=new WeakMap,uc=new WeakMap,fc=new WeakMap,Oi=new WeakMap,Ju=new WeakMap,Lt=new WeakSet,EC=function(){try{it(this,dr,ur(()=>H(this,Go).call(this,H(this,lr))))}catch(e){this.error(e)}},MC=function(e){const t=H(this,cr).failed;t&&it(this,Xn,ur(()=>{t(H(this,lr),()=>e,()=>()=>{})}))},OC=function(){const e=H(this,cr).pending;e&&(this.is_pending=!0,it(this,Rn,ur(()=>e(H(this,lr)))),ni(()=>{var t=it(this,Mi,document.createDocumentFragment()),r=Ni();t.append(r),it(this,dr,St(this,Lt,ld).call(this,()=>ur(()=>H(this,Go).call(this,r)))),H(this,io)===0&&(H(this,lr).before(t),it(this,Mi,null),$o(H(this,Rn),()=>{it(this,Rn,null)}),St(this,Lt,ad).call(this,Be))}))},Gh=function(){try{if(this.is_pending=this.has_pending_snippet(),it(this,io,0),it(this,Zo,0),it(this,dr,ur(()=>{H(this,Go).call(this,H(this,lr))})),H(this,io)>0){var e=it(this,Mi,document.createDocumentFragment());Pm(H(this,dr),e);const t=H(this,cr).pending;it(this,Rn,ur(()=>t(H(this,lr))))}else St(this,Lt,ad).call(this,Be)}catch(t){this.error(t)}},ad=function(e){this.is_pending=!1,e.transfer_effects(H(this,uc),H(this,fc))},ld=function(e){var t=$e,r=st,i=Pt;ai(H(this,Hn)),_r(H(this,Hn)),ha(H(this,Hn).ctx);try{return Fi.ensure(),e()}catch(o){return sw(o),null}finally{ai(t),_r(r),ha(i)}},Zh=function(e,t){var r;if(!this.has_pending_snippet()){this.parent&&St(r=this.parent,Lt,Zh).call(r,e,t);return}it(this,io,H(this,io)+e),H(this,io)===0&&(St(this,Lt,ad).call(this,t),H(this,Rn)&&$o(H(this,Rn),()=>{it(this,Rn,null)}),H(this,Mi)&&(H(this,lr).before(H(this,Mi)),it(this,Mi,null)))},Xh=function(e){H(this,dr)&&(Pn(H(this,dr)),it(this,dr,null)),H(this,Rn)&&(Pn(H(this,Rn)),it(this,Rn,null)),H(this,Xn)&&(Pn(H(this,Xn)),it(this,Xn,null));var t=H(this,cr).onerror;let r=H(this,cr).failed;var i=!1,o=!1;const s=()=>{if(i){gC();return}i=!0,o&&eC(),H(this,Xn)!==null&&$o(H(this,Xn),()=>{it(this,Xn,null)}),St(this,Lt,ld).call(this,()=>{St(this,Lt,Gh).call(this)})},a=l=>{try{o=!0,t==null||t(l,s),o=!1}catch(c){oo(c,H(this,Hn)&&H(this,Hn).parent)}r&&it(this,Xn,St(this,Lt,ld).call(this,()=>{try{return ur(()=>{var c=$e;c.b=this,c.f|=Wh,r(H(this,lr),()=>l,()=>s)})}catch(c){return oo(c,H(this,Hn).parent),null}}))};ni(()=>{var l;try{l=this.transform_error(e)}catch(c){oo(c,H(this,Hn)&&H(this,Hn).parent);return}l!==null&&typeof l=="object"&&typeof l.then=="function"?l.then(a,c=>oo(c,H(this,Hn)&&H(this,Hn).parent)):a(l)})};function DC(n,e,t,r){const i=Es()?Qu:Mm;var o=n.filter(h=>!h.settled);if(t.length===0&&o.length===0){r(e.map(i));return}var s=$e,a=mw(),l=o.length===1?o[0].promise:o.length>1?Promise.all(o.map(h=>h.promise)):null;function c(h){a();try{r(h)}catch(p){(s.f&tr)===0&&oo(p,s)}Tl()}if(t.length===0){l.then(()=>c(e.map(i)));return}var d=gw();function u(){Promise.all(t.map(h=>RC(h))).then(h=>c([...e.map(i),...h])).catch(h=>oo(h,s)).finally(()=>d())}l?l.then(()=>{a(),u(),Tl()}):u()}function mw(){var n=$e,e=st,t=Pt,r=Be;return function(o=!0){ai(n),_r(e),ha(t),o&&(n.f&tr)===0&&(r==null||r.activate(),r==null||r.apply())}}function Tl(n=!0){ai(null),_r(null),ha(null),n&&(Be==null||Be.deactivate())}function gw(){var n=$e,e=n.b,t=Be,r=e.is_rendered();return e.update_pending_count(1,t),t.increment(r,n),(i=!1)=>{e.update_pending_count(-1,t),t.decrement(r,n,i)}}function Qu(n){var e=Tn|vn;return $e!==null&&($e.f|=As),{ctx:Pt,deps:null,effects:null,equals:nw,f:e,fn:n,reactions:null,rv:0,v:Zt,wv:0,parent:$e,ac:null}}function RC(n,e,t){let r=$e;r===null&&WS();var i=void 0,o=Vi(Zt),s=!st,a=new Map;return KC(()=>{var p;var l=$e,c=Z0();i=c.promise;try{Promise.resolve(n()).then(c.resolve,c.reject).finally(Tl)}catch(m){c.reject(m),Tl()}var d=Be;if(s){if((l.f&Ts)!==0)var u=gw();if(r.b.is_rendered())(p=a.get(d))==null||p.reject(Ti),a.delete(d);else{for(const m of a.values())m.reject(Ti);a.clear()}a.set(d,c)}const h=(m,v=void 0)=>{if(u){var g=v===Ti;u(g)}if(!(v===Ti||(l.f&tr)!==0)){if(d.activate(),v)o.f|=fo,Ri(o,v);else{(o.f&fo)!==0&&(o.f^=fo),Ri(o,m);for(const[y,w]of a){if(a.delete(y),y===d)break;w.reject(Ti)}}d.deactivate()}};c.promise.then(h,m=>h(null,m||"unknown"))}),Rm(()=>{for(const l of a.values())l.reject(Ti)}),new Promise(l=>{function c(d){function u(){d===i?l(o):c(i)}d.then(u,u)}c(i)})}function P(n){const e=Qu(n);return Iw(e),e}function Mm(n){const e=Qu(n);return e.equals=iw,e}function NC(n){var e=n.effects;if(e!==null){n.effects=null;for(var t=0;t<e.length;t+=1)Pn(e[t])}}function Om(n){var e,t=$e,r=n.parent;if(!Hi&&r!==null&&(r.f&(tr|In))!==0)return pC(),n.v;ai(r);try{n.f&=~ds,NC(n),e=Bw(n)}finally{ai(t)}return e}function vw(n){var e=Om(n);if(!n.equals(e)&&(n.wv=Lw(),(!(Be!=null&&Be.is_fork)||n.deps===null)&&(Be!==null?Be.capture(n,e,!0):n.v=e,n.deps===null))){Vt(n,$t);return}Hi||(fn!==null?(Dm()||Be!=null&&Be.is_fork)&&fn.set(n,e):Tm(n))}function IC(n){var e,t;if(n.effects!==null)for(const r of n.effects)(r.teardown||r.ac)&&((e=r.teardown)==null||e.call(r),(t=r.ac)==null||t.abort(Ti),r.teardown=Ci,r.ac=null,Al(r,0),Nm(r))}function yw(n){if(n.effects!==null)for(const e of n.effects)e.teardown&&pa(e)}let Qh=new Set;const Qo=new Map;let bw=!1;function Vi(n,e){var t={f:0,v:n,reactions:null,equals:nw,rv:0,wv:0};return t}function z(n,e){const t=Vi(n);return Iw(t),t}function $h(n,e=!1,t=!0){var i;const r=Vi(n);return e||(r.equals=iw),Na&&t&&Pt!==null&&Pt.l!==null&&((i=Pt.l).s??(i.s=[])).push(r),r}function b(n,e,t=!1){st!==null&&(!Or||(st.f&qh)!==0)&&Es()&&(st.f&(Tn|ei|Cl|qh))!==0&&(yr===null||!ua.call(yr,n))&&$S();let r=t?at(e):e;return Ri(n,r,rd)}function Ri(n,e,t=null){if(!n.equals(e)){Qo.set(n,Hi?e:n.v);var r=Fi.ensure();if(r.capture(n,e),(n.f&Tn)!==0){const i=n;(n.f&vn)!==0&&Om(i),fn===null&&Tm(i)}n.wv=Lw(),ww(n,vn,t),Es()&&$e!==null&&($e.f&$t)!==0&&($e.f&(Nr|Bi))===0&&(ar===null?JC([n]):ar.push(n)),!r.is_fork&&Qh.size>0&&!bw&&PC()}return e}function PC(){bw=!1;for(const n of Qh)(n.f&$t)!==0&&Vt(n,si),yc(n)&&pa(n);Qh.clear()}function Md(n,e=1){var t=f(n),r=e===1?t++:t--;return b(n,t),r}function il(n){b(n,n.v+1)}function ww(n,e,t){var r=n.reactions;if(r!==null)for(var i=Es(),o=r.length,s=0;s<o;s++){var a=r[s],l=a.f;if(!(!i&&a===$e)){var c=(l&vn)===0;if(c&&Vt(a,e),(l&Tn)!==0){var d=a;fn==null||fn.delete(d),(l&ds)===0&&(l&vr&&($e===null||($e.f&Ed)===0)&&(a.f|=ds),ww(d,si,t))}else if(c){var u=a;(l&ei)!==0&&Ar!==null&&Ar.add(u),t!==null?t.push(u):Em(u)}}}}function at(n){if(typeof n!="object"||n===null||ti in n)return n;const e=Cm(n);if(e!==LS&&e!==zS)return n;var t=new Map,r=Sm(n),i=z(0),o=es,s=a=>{if(es===o)return a();var l=st,c=es;_r(null),Sv(o);var d=a();return _r(l),Sv(c),d};return r&&t.set("length",z(n.length)),new Proxy(n,{defineProperty(a,l,c){(!("value"in c)||c.configurable===!1||c.enumerable===!1||c.writable===!1)&&XS();var d=t.get(l);return d===void 0?s(()=>{var u=z(c.value);return t.set(l,u),u}):b(d,c.value,!0),!0},deleteProperty(a,l){var c=t.get(l);if(c===void 0){if(l in a){const d=s(()=>z(Zt));t.set(l,d),il(i)}}else b(c,Zt),il(i);return!0},get(a,l,c){var p;if(l===ti)return n;var d=t.get(l),u=l in a;if(d===void 0&&(!u||(p=uo(a,l))!=null&&p.writable)&&(d=s(()=>{var m=at(u?a[l]:Zt),v=z(m);return v}),t.set(l,d)),d!==void 0){var h=f(d);return h===Zt?void 0:h}return Reflect.get(a,l,c)},getOwnPropertyDescriptor(a,l){var c=Reflect.getOwnPropertyDescriptor(a,l);if(c&&"value"in c){var d=t.get(l);d&&(c.value=f(d))}else if(c===void 0){var u=t.get(l),h=u==null?void 0:u.v;if(u!==void 0&&h!==Zt)return{enumerable:!0,configurable:!0,value:h,writable:!0}}return c},has(a,l){var h;if(l===ti)return!0;var c=t.get(l),d=c!==void 0&&c.v!==Zt||Reflect.has(a,l);if(c!==void 0||$e!==null&&(!d||(h=uo(a,l))!=null&&h.writable)){c===void 0&&(c=s(()=>{var p=d?at(a[l]):Zt,m=z(p);return m}),t.set(l,c));var u=f(c);if(u===Zt)return!1}return d},set(a,l,c,d){var _;var u=t.get(l),h=l in a;if(r&&l==="length")for(var p=c;p<u.v;p+=1){var m=t.get(p+"");m!==void 0?b(m,Zt):p in a&&(m=s(()=>z(Zt)),t.set(p+"",m))}if(u===void 0)(!h||(_=uo(a,l))!=null&&_.writable)&&(u=s(()=>z(void 0)),b(u,at(c)),t.set(l,u));else{h=u.v!==Zt;var v=s(()=>at(c));b(u,v)}var g=Reflect.getOwnPropertyDescriptor(a,l);if(g!=null&&g.set&&g.set.call(d,c),!h){if(r&&typeof l=="string"){var y=t.get("length"),w=Number(l);Number.isInteger(w)&&w>=y.v&&b(y,w+1)}il(i)}return!0},ownKeys(a){f(i);var l=Reflect.ownKeys(a).filter(u=>{var h=t.get(u);return h===void 0||h.v!==Zt});for(var[c,d]of t)d.v!==Zt&&!(c in a)&&l.push(c);return l},setPrototypeOf(){QS()}})}function wv(n){try{if(n!==null&&typeof n=="object"&&ti in n)return n[ti]}catch{}return n}function LC(n,e){return Object.is(wv(n),wv(e))}var xv,xw,kw,_w;function zC(){if(xv===void 0){xv=window,xw=/Firefox/.test(navigator.userAgent);var n=Element.prototype,e=Node.prototype,t=Text.prototype;kw=uo(e,"firstChild").get,_w=uo(e,"nextSibling").get,gv(n)&&(n.__click=void 0,n.__className=void 0,n.__attributes=null,n.__style=void 0,n.__e=void 0),gv(t)&&(t.__t=void 0)}}function Ni(n=""){return document.createTextNode(n)}function Xr(n){return kw.call(n)}function gc(n){return _w.call(n)}function x(n,e){return Xr(n)}function Le(n,e=!1){{var t=Xr(n);return t instanceof Comment&&t.data===""?gc(t):t}}function k(n,e=1,t=!1){let r=n;for(;e--;)r=gc(r);return r}function BC(n){n.textContent=""}function Sw(){return!1}function Cw(n,e,t){return document.createElementNS(e??tw,n,void 0)}function FC(n,e){{const t=document.body;n.autofocus=!0,ni(()=>{document.activeElement===t&&n.focus()})}}let kv=!1;function VC(){kv||(kv=!0,document.addEventListener("reset",n=>{Promise.resolve().then(()=>{var e;if(!n.defaultPrevented)for(const t of n.target.elements)(e=t.__on_r)==null||e.call(t)})},{capture:!0}))}function $u(n){var e=st,t=$e;_r(null),ai(null);try{return n()}finally{_r(e),ai(t)}}function Tw(n,e,t,r=t){n.addEventListener(e,()=>$u(t));const i=n.__on_r;i?n.__on_r=()=>{i(),r(!0)}:n.__on_r=()=>r(!0),VC()}function HC(n){$e===null&&(st===null&&YS(),JS()),Hi&&qS()}function UC(n,e){var t=e.last;t===null?e.last=e.first=n:(t.next=n,n.prev=t,e.last=n)}function hi(n,e){var t=$e;t!==null&&(t.f&In)!==0&&(n|=In);var r={ctx:Pt,deps:null,nodes:null,f:n|vn|vr,first:null,fn:e,last:null,next:null,parent:t,b:t&&t.b,prev:null,teardown:null,wv:0,ac:null};Be==null||Be.register_created_effect(r);var i=r;if((n&fa)!==0)Ws!==null?Ws.push(r):Fi.ensure().schedule(r);else if(e!==null){try{pa(r)}catch(s){throw Pn(r),s}i.deps===null&&i.teardown===null&&i.nodes===null&&i.first===i.last&&(i.f&As)===0&&(i=i.first,(n&ei)!==0&&(n&yo)!==0&&i!==null&&(i.f|=yo))}if(i!==null&&(i.parent=t,t!==null&&UC(i,t),st!==null&&(st.f&Tn)!==0&&(n&Bi)===0)){var o=st;(o.effects??(o.effects=[])).push(i)}return r}function Dm(){return st!==null&&!Or}function Rm(n){const e=hi(Xu,null);return Vt(e,$t),e.teardown=n,e}function he(n){HC();var e=$e.f,t=!st&&(e&Nr)!==0&&(e&Ts)===0;if(t){var r=Pt;(r.e??(r.e=[])).push(n)}else return Aw(n)}function Aw(n){return hi(fa|HS,n)}function jC(n){Fi.ensure();const e=hi(Bi|As,n);return()=>{Pn(e)}}function WC(n){Fi.ensure();const e=hi(Bi|As,n);return(t={})=>new Promise(r=>{t.outro?$o(e,()=>{Pn(e),r(void 0)}):(Pn(e),r(void 0))})}function Ew(n){return hi(fa,n)}function KC(n){return hi(Cl|As,n)}function vc(n,e=0){return hi(Xu|e,n)}function G(n,e=[],t=[],r=[]){DC(r,e,t,i=>{hi(Xu,()=>n(...i.map(f)))})}function Ms(n,e=0){var t=hi(ei|e,n);return t}function ur(n){return hi(Nr|As,n)}function Mw(n){var e=n.teardown;if(e!==null){const t=Hi,r=st;_v(!0),_r(null);try{e.call(null)}finally{_v(t),_r(r)}}}function Nm(n,e=!1){var t=n.first;for(n.first=n.last=null;t!==null;){const i=t.ac;i!==null&&$u(()=>{i.abort(Ti)});var r=t.next;(t.f&Bi)!==0?t.parent=null:Pn(t,e),t=r}}function qC(n){for(var e=n.first;e!==null;){var t=e.next;(e.f&Nr)===0&&Pn(e),e=t}}function Pn(n,e=!0){var t=!1;(e||(n.f&VS)!==0)&&n.nodes!==null&&n.nodes.end!==null&&(Ow(n.nodes.start,n.nodes.end),t=!0),Vt(n,Kh),Nm(n,e&&!t),Al(n,0);var r=n.nodes&&n.nodes.t;if(r!==null)for(const o of r)o.stop();Mw(n),n.f^=Kh,n.f|=tr;var i=n.parent;i!==null&&i.first!==null&&Dw(n),n.next=n.prev=n.teardown=n.ctx=n.deps=n.fn=n.nodes=n.ac=n.b=null}function Ow(n,e){for(;n!==null;){var t=n===e?null:gc(n);n.remove(),n=t}}function Dw(n){var e=n.parent,t=n.prev,r=n.next;t!==null&&(t.next=r),r!==null&&(r.prev=t),e!==null&&(e.first===n&&(e.first=r),e.last===n&&(e.last=t))}function $o(n,e,t=!0){var r=[];Rw(n,r,!0);var i=()=>{t&&Pn(n),e&&e()},o=r.length;if(o>0){var s=()=>--o||i();for(var a of r)a.out(s)}else i()}function Rw(n,e,t){if((n.f&In)===0){n.f^=In;var r=n.nodes&&n.nodes.t;if(r!==null)for(const a of r)(a.is_global||t)&&e.push(a);for(var i=n.first;i!==null;){var o=i.next;if((i.f&Bi)===0){var s=(i.f&yo)!==0||(i.f&Nr)!==0&&(n.f&ei)!==0;Rw(i,e,s?t:!1)}i=o}}}function Im(n){Nw(n,!0)}function Nw(n,e){if((n.f&In)!==0){n.f^=In,(n.f&$t)===0&&(Vt(n,vn),Fi.ensure().schedule(n));for(var t=n.first;t!==null;){var r=t.next,i=(t.f&yo)!==0||(t.f&Nr)!==0;Nw(t,i?e:!1),t=r}var o=n.nodes&&n.nodes.t;if(o!==null)for(const s of o)(s.is_global||e)&&s.in()}}function Pm(n,e){if(n.nodes)for(var t=n.nodes.start,r=n.nodes.end;t!==null;){var i=t===r?null:gc(t);e.append(t),t=i}}let cd=!1,Hi=!1;function _v(n){Hi=n}let st=null,Or=!1;function _r(n){st=n}let $e=null;function ai(n){$e=n}let yr=null;function Iw(n){st!==null&&(yr===null?yr=[n]:yr.push(n))}let Un=null,Jn=0,ar=null;function JC(n){ar=n}let Pw=1,Vo=0,es=Vo;function Sv(n){es=n}function Lw(){return++Pw}function yc(n){var e=n.f;if((e&vn)!==0)return!0;if(e&Tn&&(n.f&=~ds),(e&si)!==0){for(var t=n.deps,r=t.length,i=0;i<r;i++){var o=t[i];if(yc(o)&&vw(o),o.wv>n.wv)return!0}(e&vr)!==0&&fn===null&&Vt(n,$t)}return!1}function zw(n,e,t=!0){var r=n.reactions;if(r!==null&&!(yr!==null&&ua.call(yr,n)))for(var i=0;i<r.length;i++){var o=r[i];(o.f&Tn)!==0?zw(o,e,!1):e===o&&(t?Vt(o,vn):(o.f&$t)!==0&&Vt(o,si),Em(o))}}function Bw(n){var v;var e=Un,t=Jn,r=ar,i=st,o=yr,s=Pt,a=Or,l=es,c=n.f;Un=null,Jn=0,ar=null,st=(c&(Nr|Bi))===0?n:null,yr=null,ha(n.ctx),Or=!1,es=++Vo,n.ac!==null&&($u(()=>{n.ac.abort(Ti)}),n.ac=null);try{n.f|=Ed;var d=n.fn,u=d();n.f|=Ts;var h=n.deps,p=Be==null?void 0:Be.is_fork;if(Un!==null){var m;if(p||Al(n,Jn),h!==null&&Jn>0)for(h.length=Jn+Un.length,m=0;m<Un.length;m++)h[Jn+m]=Un[m];else n.deps=h=Un;if(Dm()&&(n.f&vr)!==0)for(m=Jn;m<h.length;m++)((v=h[m]).reactions??(v.reactions=[])).push(n)}else!p&&h!==null&&Jn<h.length&&(Al(n,Jn),h.length=Jn);if(Es()&&ar!==null&&!Or&&h!==null&&(n.f&(Tn|si|vn))===0)for(m=0;m<ar.length;m++)zw(ar[m],n);if(i!==null&&i!==n){if(Vo++,i.deps!==null)for(let g=0;g<t;g+=1)i.deps[g].rv=Vo;if(e!==null)for(const g of e)g.rv=Vo;ar!==null&&(r===null?r=ar:r.push(...ar))}return(n.f&fo)!==0&&(n.f^=fo),u}catch(g){return sw(g)}finally{n.f^=Ed,Un=e,Jn=t,ar=r,st=i,yr=o,ha(s),Or=a,es=l}}function YC(n,e){let t=e.reactions;if(t!==null){var r=IS.call(t,n);if(r!==-1){var i=t.length-1;i===0?t=e.reactions=null:(t[r]=t[i],t.pop())}}if(t===null&&(e.f&Tn)!==0&&(Un===null||!ua.call(Un,e))){var o=e;(o.f&vr)!==0&&(o.f^=vr,o.f&=~ds),o.v!==Zt&&Tm(o),IC(o),Al(o,0)}}function Al(n,e){var t=n.deps;if(t!==null)for(var r=e;r<t.length;r++)YC(n,t[r])}function pa(n){var e=n.f;if((e&tr)===0){Vt(n,$t);var t=$e,r=cd;$e=n,cd=!0;try{(e&(ei|X0))!==0?qC(n):Nm(n),Mw(n);var i=Bw(n);n.teardown=typeof i=="function"?i:null,n.wv=Pw;var o;NS&&vC&&(n.f&vn)!==0&&n.deps}finally{cd=r,$e=t}}}async function GC(){await Promise.resolve(),dw()}function f(n){var e=n.f,t=(e&Tn)!==0;if(st!==null&&!Or){var r=$e!==null&&($e.f&tr)!==0;if(!r&&(yr===null||!ua.call(yr,n))){var i=st.deps;if((st.f&Ed)!==0)n.rv<Vo&&(n.rv=Vo,Un===null&&i!==null&&i[Jn]===n?Jn++:Un===null?Un=[n]:Un.push(n));else{(st.deps??(st.deps=[])).push(n);var o=n.reactions;o===null?n.reactions=[st]:ua.call(o,st)||o.push(st)}}}if(Hi&&Qo.has(n))return Qo.get(n);if(t){var s=n;if(Hi){var a=s.v;return((s.f&$t)===0&&s.reactions!==null||Vw(s))&&(a=Om(s)),Qo.set(s,a),a}var l=(s.f&vr)===0&&!Or&&st!==null&&(cd||(st.f&vr)!==0),c=(s.f&Ts)===0;yc(s)&&(l&&(s.f|=vr),vw(s)),l&&!c&&(yw(s),Fw(s))}if(fn!=null&&fn.has(n))return fn.get(n);if((n.f&fo)!==0)throw n.v;return n.v}function Fw(n){if(n.f|=vr,n.deps!==null)for(const e of n.deps)(e.reactions??(e.reactions=[])).push(n),(e.f&Tn)!==0&&(e.f&vr)===0&&(yw(e),Fw(e))}function Vw(n){if(n.v===Zt)return!0;if(n.deps===null)return!1;for(const e of n.deps)if(Qo.has(e)||(e.f&Tn)!==0&&Vw(e))return!0;return!1}function Ut(n){var e=Or;try{return Or=!0,n()}finally{Or=e}}function ZC(n){if(!(typeof n!="object"||!n||n instanceof EventTarget)){if(ti in n)ep(n);else if(!Array.isArray(n))for(let e in n){const t=n[e];typeof t=="object"&&t&&ti in t&&ep(t)}}}function ep(n,e=new Set){if(typeof n=="object"&&n!==null&&!(n instanceof EventTarget)&&!e.has(n)){e.add(n),n instanceof Date&&n.getTime();for(let r in n)try{ep(n[r],e)}catch{}const t=Cm(n);if(t!==Object.prototype&&t!==Array.prototype&&t!==Map.prototype&&t!==Set.prototype&&t!==Date.prototype){const r=G0(t);for(let i in r){const o=r[i].get;if(o)try{o.call(n)}catch{}}}}}const XC=["touchstart","touchmove"];function QC(n){return XC.includes(n)}const Ho=Symbol("events"),Hw=new Set,tp=new Set;function $C(n,e,t,r={}){function i(o){if(r.capture||np.call(e,o),!o.cancelBubble)return $u(()=>t==null?void 0:t.call(this,o))}return n.startsWith("pointer")||n.startsWith("touch")||n==="wheel"?ni(()=>{e.addEventListener(n,i,r)}):e.addEventListener(n,i,r),i}function vt(n,e,t,r,i){var o={capture:r,passive:i},s=$C(n,e,t,o);(e===document.body||e===window||e===document||e instanceof HTMLMediaElement)&&Rm(()=>{e.removeEventListener(n,s,o)})}function L(n,e,t){(e[Ho]??(e[Ho]={}))[n]=t}function Ye(n){for(var e=0;e<n.length;e++)Hw.add(n[e]);for(var t of tp)t(n)}let Cv=null;function np(n){var g,y;var e=this,t=e.ownerDocument,r=n.type,i=((g=n.composedPath)==null?void 0:g.call(n))||[],o=i[0]||n.target;Cv=n;var s=0,a=Cv===n&&n[Ho];if(a){var l=i.indexOf(a);if(l!==-1&&(e===document||e===window)){n[Ho]=e;return}var c=i.indexOf(e);if(c===-1)return;l<=c&&(s=l)}if(o=i[s]||n.target,o!==e){PS(n,"currentTarget",{configurable:!0,get(){return o||t}});var d=st,u=$e;_r(null),ai(null);try{for(var h,p=[];o!==null;){var m=o.assignedSlot||o.parentNode||o.host||null;try{var v=(y=o[Ho])==null?void 0:y[r];v!=null&&(!o.disabled||n.target===o)&&v.call(o,n)}catch(w){h?p.push(w):h=w}if(n.cancelBubble||m===e||m===null)break;o=m}if(h){for(let w of p)queueMicrotask(()=>{throw w});throw h}}finally{n[Ho]=e,delete n.currentTarget,_r(d),ai(u)}}}var J0;const Bf=((J0=globalThis==null?void 0:globalThis.window)==null?void 0:J0.trustedTypes)&&globalThis.window.trustedTypes.createPolicy("svelte-trusted-html",{createHTML:n=>n});function eT(n){return(Bf==null?void 0:Bf.createHTML(n))??n}function Uw(n){var e=Cw("template");return e.innerHTML=eT(n.replaceAll("<!>","<!---->")),e.content}function us(n,e){var t=$e;t.nodes===null&&(t.nodes={start:n,end:e,a:null,t:null})}function O(n,e){var t=(e&dC)!==0,r=(e&uC)!==0,i,o=!n.startsWith("<!>");return()=>{i===void 0&&(i=Uw(o?n:"<!>"+n),t||(i=Xr(i)));var s=r||xw?document.importNode(i,!0):i.cloneNode(!0);if(t){var a=Xr(s),l=s.lastChild;us(a,l)}else us(s,s);return s}}function tT(n,e,t="svg"){var r=!n.startsWith("<!>"),i=`<${t}>${r?n:"<!>"+n}</${t}>`,o;return()=>{if(!o){var s=Uw(i),a=Xr(s);o=Xr(a)}var l=o.cloneNode(!0);return us(l,l),l}}function Wi(n,e){return tT(n,e,"svg")}function Nn(n=""){{var e=Ni(n+"");return us(e,e),e}}function Tt(){var n=document.createDocumentFragment(),e=document.createComment(""),t=Ni();return n.append(e,t),us(e,t),n}function T(n,e){n!==null&&n.before(e)}function ne(n,e){var t=e==null?"":typeof e=="object"?`${e}`:e;t!==(n.__t??(n.__t=n.nodeValue))&&(n.__t=t,n.nodeValue=`${t}`)}function nT(n,e){return rT(n,e)}const Nc=new Map;function rT(n,{target:e,anchor:t,props:r={},events:i,context:o,intro:s=!0,transformError:a}){zC();var l=void 0,c=WC(()=>{var d=t??e.appendChild(Ni());pw(d,{pending:()=>{}},p=>{We({});var m=Pt;o&&(m.c=o),i&&(r.$$events=i),l=n(p,r)||{},Ke()},a);var u=new Set,h=p=>{for(var m=0;m<p.length;m++){var v=p[m];if(!u.has(v)){u.add(v);var g=QC(v);for(const _ of[e,document]){var y=Nc.get(_);y===void 0&&(y=new Map,Nc.set(_,y));var w=y.get(v);w===void 0?(_.addEventListener(v,np,{passive:g}),y.set(v,1)):y.set(v,w+1)}}}};return h(Zu(Hw)),tp.add(h),()=>{var g;for(var p of u)for(const y of[e,document]){var m=Nc.get(y),v=m.get(p);--v==0?(y.removeEventListener(p,np),m.delete(p),m.size===0&&Nc.delete(y)):m.set(p,v)}tp.delete(h),d!==t&&((g=d.parentNode)==null||g.removeChild(d))}});return iT.set(l,c),l}let iT=new WeakMap;var Er,Gr,Qn,Xo,hc,pc,Yu;class bc{constructor(e,t=!0){Vn(this,"anchor");Je(this,Er,new Map);Je(this,Gr,new Map);Je(this,Qn,new Map);Je(this,Xo,new Set);Je(this,hc,!0);Je(this,pc,e=>{if(H(this,Er).has(e)){var t=H(this,Er).get(e),r=H(this,Gr).get(t);if(r)Im(r),H(this,Xo).delete(t);else{var i=H(this,Qn).get(t);i&&(H(this,Gr).set(t,i.effect),H(this,Qn).delete(t),i.fragment.lastChild.remove(),this.anchor.before(i.fragment),r=i.effect)}for(const[o,s]of H(this,Er)){if(H(this,Er).delete(o),o===e)break;const a=H(this,Qn).get(s);a&&(Pn(a.effect),H(this,Qn).delete(s))}for(const[o,s]of H(this,Gr)){if(o===t||H(this,Xo).has(o))continue;const a=()=>{if(Array.from(H(this,Er).values()).includes(o)){var c=document.createDocumentFragment();Pm(s,c),c.append(Ni()),H(this,Qn).set(o,{effect:s,fragment:c})}else Pn(s);H(this,Xo).delete(o),H(this,Gr).delete(o)};H(this,hc)||!r?(H(this,Xo).add(o),$o(s,a,!1)):a()}}});Je(this,Yu,e=>{H(this,Er).delete(e);const t=Array.from(H(this,Er).values());for(const[r,i]of H(this,Qn))t.includes(r)||(Pn(i.effect),H(this,Qn).delete(r))});this.anchor=e,it(this,hc,t)}ensure(e,t){var r=Be,i=Sw();if(t&&!H(this,Gr).has(e)&&!H(this,Qn).has(e))if(i){var o=document.createDocumentFragment(),s=Ni();o.append(s),H(this,Qn).set(e,{effect:ur(()=>t(s)),fragment:o})}else H(this,Gr).set(e,ur(()=>t(this.anchor)));if(H(this,Er).set(r,e),i){for(const[a,l]of H(this,Gr))a===e?r.unskip_effect(l):r.skip_effect(l);for(const[a,l]of H(this,Qn))a===e?r.unskip_effect(l.effect):r.skip_effect(l.effect);r.oncommit(H(this,pc)),r.ondiscard(H(this,Yu))}else H(this,pc).call(this,r)}}Er=new WeakMap,Gr=new WeakMap,Qn=new WeakMap,Xo=new WeakMap,hc=new WeakMap,pc=new WeakMap,Yu=new WeakMap;const oT=0,Tv=1,sT=2;function aT(n,e,t,r,i){var o=Es(),s=Zt,a=o?Vi(s):$h(s,!1,!1),l=o?Vi(s):$h(s,!1,!1),c=new bc(n);Ms(()=>{var d=Be;d.deactivate();var u=e();d.activate();var h=!1;if(BS(u)){var p=mw(),m=!1;const v=g=>{if(!h){m=!0,p(!1),Fi.ensure();try{g()}finally{Tl(!1),Ys||dw()}}};u.then(g=>{v(()=>{Ri(a,g),c.ensure(Tv,r&&(y=>r(y,a)))})},g=>{v(()=>{if(Ri(l,g),c.ensure(sT,i&&(y=>i(y,l))),!i)throw l.v})}),ni(()=>{m||v(()=>{c.ensure(oT,t)})})}else Ri(a,u),c.ensure(Tv,r&&(v=>r(v,a)));return()=>{h=!0}})}function Z(n,e,t=!1){var r=new bc(n),i=t?yo:0;function o(s,a){r.ensure(s,a)}Ms(()=>{var s=!1;e((a,l=0)=>{s=!0,o(l,a)}),s||o(-1,null)},i)}const lT=Symbol("NaN");function rp(n,e,t){var r=new bc(n),i=!Es();Ms(()=>{var o=e();o!==o&&(o=lT),i&&o!==null&&typeof o=="object"&&(o={}),r.ensure(o,t)})}function ma(n,e){return e}function cT(n,e,t){for(var r=[],i=e.length,o,s=e.length,a=0;a<i;a++){let u=e[a];$o(u,()=>{if(o){if(o.pending.delete(u),o.done.add(u),o.pending.size===0){var h=n.outrogroups;ip(n,Zu(o.done)),h.delete(o),h.size===0&&(n.outrogroups=null)}}else s-=1},!1)}if(s===0){var l=r.length===0&&t!==null;if(l){var c=t,d=c.parentNode;BC(d),d.append(c),n.items.clear()}ip(n,e,!l)}else o={pending:new Set(e),done:new Set},(n.outrogroups??(n.outrogroups=new Set)).add(o)}function ip(n,e,t=!0){var r;if(n.pending.size>0){r=new Set;for(const s of n.pending.values())for(const a of s)r.add(n.items.get(a).e)}for(var i=0;i<e.length;i++){var o=e[i];if(r!=null&&r.has(o)){o.f|=Zr;const s=document.createDocumentFragment();Pm(o,s)}else Pn(e[i],t)}}var Av;function ft(n,e,t,r,i,o=null){var s=n,a=new Map,l=(e&ew)!==0;if(l){var c=n;s=c.appendChild(Ni())}var d=null,u=Mm(()=>{var _=t();return Sm(_)?_:_==null?[]:Zu(_)}),h,p=new Map,m=!0;function v(_){(w.effect.f&tr)===0&&(w.pending.delete(_),w.fallback=d,dT(w,h,s,e,r),d!==null&&(h.length===0?(d.f&Zr)===0?Im(d):(d.f^=Zr,Xa(d,null,s)):$o(d,()=>{d=null})))}function g(_){w.pending.delete(_)}var y=Ms(()=>{h=f(u);for(var _=h.length,S=new Set,A=Be,U=Sw(),N=0;N<_;N+=1){var R=h[N],E=r(R,N),q=m?null:a.get(E);q?(q.v&&Ri(q.v,R),q.i&&Ri(q.i,N),U&&A.unskip_effect(q.e)):(q=uT(a,m?s:Av??(Av=Ni()),R,E,N,i,e,t),m||(q.e.f|=Zr),a.set(E,q)),S.add(E)}if(_===0&&o&&!d&&(m?d=ur(()=>o(s)):(d=ur(()=>o(Av??(Av=Ni()))),d.f|=Zr)),_>S.size&&KS(),!m)if(p.set(A,S),U){for(const[te,K]of a)S.has(te)||A.skip_effect(K.e);A.oncommit(v),A.ondiscard(g)}else v(A);f(u)}),w={effect:y,items:a,pending:p,outrogroups:null,fallback:d};m=!1}function Wa(n){for(;n!==null&&(n.f&Nr)===0;)n=n.next;return n}function dT(n,e,t,r,i){var q,te,K,V,ee,se,F,X,B;var o=(r&rC)!==0,s=e.length,a=n.items,l=Wa(n.effect.first),c,d=null,u,h=[],p=[],m,v,g,y;if(o)for(y=0;y<s;y+=1)m=e[y],v=i(m,y),g=a.get(v).e,(g.f&Zr)===0&&((te=(q=g.nodes)==null?void 0:q.a)==null||te.measure(),(u??(u=new Set)).add(g));for(y=0;y<s;y+=1){if(m=e[y],v=i(m,y),g=a.get(v).e,n.outrogroups!==null)for(const j of n.outrogroups)j.pending.delete(g),j.done.delete(g);if((g.f&In)!==0&&(Im(g),o&&((V=(K=g.nodes)==null?void 0:K.a)==null||V.unfix(),(u??(u=new Set)).delete(g))),(g.f&Zr)!==0)if(g.f^=Zr,g===l)Xa(g,null,t);else{var w=d?d.next:l;g===n.effect.last&&(n.effect.last=g.prev),g.prev&&(g.prev.next=g.next),g.next&&(g.next.prev=g.prev),qi(n,d,g),qi(n,g,w),Xa(g,w,t),d=g,h=[],p=[],l=Wa(d.next);continue}if(g!==l){if(c!==void 0&&c.has(g)){if(h.length<p.length){var _=p[0],S;d=_.prev;var A=h[0],U=h[h.length-1];for(S=0;S<h.length;S+=1)Xa(h[S],_,t);for(S=0;S<p.length;S+=1)c.delete(p[S]);qi(n,A.prev,U.next),qi(n,d,A),qi(n,U,_),l=_,d=U,y-=1,h=[],p=[]}else c.delete(g),Xa(g,l,t),qi(n,g.prev,g.next),qi(n,g,d===null?n.effect.first:d.next),qi(n,d,g),d=g;continue}for(h=[],p=[];l!==null&&l!==g;)(c??(c=new Set)).add(l),p.push(l),l=Wa(l.next);if(l===null)continue}(g.f&Zr)===0&&h.push(g),d=g,l=Wa(g.next)}if(n.outrogroups!==null){for(const j of n.outrogroups)j.pending.size===0&&(ip(n,Zu(j.done)),(ee=n.outrogroups)==null||ee.delete(j));n.outrogroups.size===0&&(n.outrogroups=null)}if(l!==null||c!==void 0){var N=[];if(c!==void 0)for(g of c)(g.f&In)===0&&N.push(g);for(;l!==null;)(l.f&In)===0&&l!==n.fallback&&N.push(l),l=Wa(l.next);var R=N.length;if(R>0){var E=(r&ew)!==0&&s===0?t:null;if(o){for(y=0;y<R;y+=1)(F=(se=N[y].nodes)==null?void 0:se.a)==null||F.measure();for(y=0;y<R;y+=1)(B=(X=N[y].nodes)==null?void 0:X.a)==null||B.fix()}cT(n,N,E)}}o&&ni(()=>{var j,ae;if(u!==void 0)for(g of u)(ae=(j=g.nodes)==null?void 0:j.a)==null||ae.apply()})}function uT(n,e,t,r,i,o,s,a){var l=(s&tC)!==0?(s&iC)===0?$h(t,!1,!1):Vi(t):null,c=(s&nC)!==0?Vi(i):null;return{v:l,i:c,e:ur(()=>(o(e,l??t,c??i,a),()=>{n.delete(r)}))}}function Xa(n,e,t){if(n.nodes)for(var r=n.nodes.start,i=n.nodes.end,o=e&&(e.f&Zr)===0?e.nodes.start:t;r!==null;){var s=gc(r);if(o.before(r),r===i)return;r=s}}function qi(n,e,t){e===null?n.effect.first=t:e.next=t,t===null?n.effect.last=e:t.prev=e}function fT(n,e,t=!1,r=!1,i=!1,o=!1){var s=n,a="";if(t)var l=n;G(()=>{var c=$e;if(a!==(a=e()??"")){if(t){c.nodes=null,l.innerHTML=a,a!==""&&us(Xr(l),l.lastChild);return}if(c.nodes!==null&&(Ow(c.nodes.start,c.nodes.end),c.nodes=null),a!==""){var d=r?fC:i?hC:void 0,u=Cw(r?"svg":i?"math":"template",d);u.innerHTML=a;var h=r||i?u:u.content;if(us(Xr(h),h.lastChild),r||i)for(;Xr(h);)s.before(Xr(h));else s.before(h)}}})}function Lm(n,e,...t){var r=new bc(n);Ms(()=>{const i=e()??null;r.ensure(i,i&&(o=>i(o,...t)))},yo)}function hT(n,e,t){var r=new bc(n);Ms(()=>{var i=e()??null;r.ensure(i,i&&(o=>t(o,i)))},yo)}function El(n,e,t){Ew(()=>{var r=Ut(()=>e(n,t==null?void 0:t())||{});if(t&&(r!=null&&r.update)){var i=!1,o={};vc(()=>{var s=t();ZC(s),i&&rw(o,s)&&(o=s,r.update(s))}),i=!0}if(r!=null&&r.destroy)return()=>r.destroy()})}function pT(n,e){return n==null?null:String(n)}function re(n,e,t,r){var i=n.__style;if(i!==e){var o=pT(e);o==null?n.removeAttribute("style"):n.style.cssText=o,n.__style=e}return r}function zm(n,e,t=!1){if(n.multiple){if(e==null)return;if(!Sm(e))return mC();for(var r of n.options)r.selected=e.includes(Ev(r));return}for(r of n.options){var i=Ev(r);if(LC(i,e)){r.selected=!0;return}}(!t||e!==void 0)&&(n.selectedIndex=-1)}function jw(n){var e=new MutationObserver(()=>{zm(n,n.__value)});e.observe(n,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["value"]}),Rm(()=>{e.disconnect()})}function Ev(n){return"__value"in n?n.__value:n.value}const mT=Symbol("is custom element"),gT=Symbol("is html"),vT=jS?"progress":"PROGRESS";function Rr(n,e){var t=Bm(n);t.value===(t.value=e??void 0)||n.value===e&&(e!==0||n.nodeName!==vT)||(n.value=e??"")}function fs(n,e){var t=Bm(n);t.checked!==(t.checked=e??void 0)&&(n.checked=e)}function Q(n,e,t,r){var i=Bm(n);i[e]!==(i[e]=t)&&(e==="loading"&&(n[US]=t),t==null?n.removeAttribute(e):typeof t!="string"&&yT(n).includes(e)?n[e]=t:n.setAttribute(e,t))}function Bm(n){return n.__attributes??(n.__attributes={[mT]:n.nodeName.includes("-"),[gT]:n.namespaceURI===tw})}var Mv=new Map;function yT(n){var e=n.getAttribute("is")||n.nodeName,t=Mv.get(e);if(t)return t;Mv.set(e,t=[]);for(var r,i=n,o=Element.prototype;o!==i;){r=G0(i);for(var s in r)r[s].set&&t.push(s);i=Cm(i)}return t}function hs(n,e,t=e){var r=new WeakSet;Tw(n,"input",async i=>{var o=i?n.defaultValue:n.value;if(o=Vf(n)?Hf(o):o,t(o),Be!==null&&r.add(Be),await GC(),o!==(o=e())){var s=n.selectionStart,a=n.selectionEnd,l=n.value.length;if(n.value=o??"",a!==null){var c=n.value.length;s===a&&a===l&&c>l?(n.selectionStart=c,n.selectionEnd=c):(n.selectionStart=s,n.selectionEnd=Math.min(a,c))}}}),Ut(e)==null&&n.value&&(t(Vf(n)?Hf(n.value):n.value),Be!==null&&r.add(Be)),vc(()=>{var i=e();if(n===document.activeElement){var o=Be;if(r.has(o))return}Vf(n)&&i===Hf(n.value)||n.type==="date"&&!i&&!n.value||i!==n.value&&(n.value=i??"")})}function Ff(n,e,t=e){Tw(n,"change",r=>{var i=r?n.defaultChecked:n.checked;t(i)}),Ut(e)==null&&t(n.checked),vc(()=>{var r=e();n.checked=!!r})}function Vf(n){var e=n.type;return e==="number"||e==="range"}function Hf(n){return n===""?null:+n}function Ov(n,e){return n===e||(n==null?void 0:n[ti])===e}function yt(n={},e,t,r){var i=Pt.r,o=$e;return Ew(()=>{var s,a;return vc(()=>{s=a,a=(r==null?void 0:r())||[],Ut(()=>{n!==t(...a)&&(e(n,...a),s&&Ov(t(...s),n)&&e(null,...s))})}),()=>{let l=o;for(;l!==i&&l.parent!==null&&l.parent.f&Kh;)l=l.parent;const c=()=>{a&&Ov(t(...a),n)&&e(null,...a)},d=l.teardown;l.teardown=()=>{c(),d==null||d()}}}),n}const bT={get(n,e){if(!n.exclude.includes(e))return n.props[e]},set(n,e){return!1},getOwnPropertyDescriptor(n,e){if(!n.exclude.includes(e)&&e in n.props)return{enumerable:!0,configurable:!0,value:n.props[e]}},has(n,e){return n.exclude.includes(e)?!1:e in n.props},ownKeys(n){return Reflect.ownKeys(n.props).filter(e=>!n.exclude.includes(e))}};function wT(n,e,t){return new Proxy({props:n,exclude:e},bT)}const xT={get(n,e){let t=n.props.length;for(;t--;){let r=n.props[t];if(ja(r)&&(r=r()),typeof r=="object"&&r!==null&&e in r)return r[e]}},set(n,e,t){let r=n.props.length;for(;r--;){let i=n.props[r];ja(i)&&(i=i());const o=uo(i,e);if(o&&o.set)return o.set(t),!0}return!1},getOwnPropertyDescriptor(n,e){let t=n.props.length;for(;t--;){let r=n.props[t];if(ja(r)&&(r=r()),typeof r=="object"&&r!==null&&e in r){const i=uo(r,e);return i&&!i.configurable&&(i.configurable=!0),i}}},has(n,e){if(e===ti||e===Q0)return!1;for(let t of n.props)if(ja(t)&&(t=t()),t!=null&&e in t)return!0;return!1},ownKeys(n){const e=[];for(let t of n.props)if(ja(t)&&(t=t()),!!t){for(const r in t)e.includes(r)||e.push(r);for(const r of Object.getOwnPropertySymbols(t))e.includes(r)||e.push(r)}return e}};function Ic(...n){return new Proxy({props:n},xT)}function lt(n,e,t,r){var _;var i=!Na||(t&sC)!==0,o=(t&lC)!==0,s=(t&cC)!==0,a=r,l=!0,c=()=>(l&&(l=!1,a=s?Ut(r):r),a);let d;if(o){var u=ti in n||Q0 in n;d=((_=uo(n,e))==null?void 0:_.set)??(u&&e in n?S=>n[e]=S:void 0)}var h,p=!1;o?[h,p]=xC(()=>n[e]):h=n[e],h===void 0&&r!==void 0&&(h=c(),d&&(i&&ZS(),d(h)));var m;if(i?m=()=>{var S=n[e];return S===void 0?c():(l=!0,S)}:m=()=>{var S=n[e];return S!==void 0&&(a=void 0),S===void 0?a:S},i&&(t&aC)===0)return m;if(d){var v=n.$$legacy;return(function(S,A){return arguments.length>0?((!i||!A||v||p)&&d(A?m():S),S):m()})}var g=!1,y=((t&oC)!==0?Qu:Mm)(()=>(g=!1,m()));o&&f(y);var w=$e;return(function(S,A){if(arguments.length>0){const U=A?f(y):i&&o?at(S):S;return b(y,U),g=!0,a!==void 0&&(a=U),S}return Hi&&g||(w.f&tr)!==0?y.v:f(y)})}function ef(n){Pt===null&&$0(),Na&&Pt.l!==null?kT(Pt).m.push(n):he(()=>{const e=Ut(n);if(typeof e=="function")return e})}function pi(n){Pt===null&&$0(),ef(()=>()=>Ut(n))}function kT(n){var e=n.l;return e.u??(e.u={a:[],b:[],m:[]})}const _T="5";var Y0;typeof window<"u"&&((Y0=window.__svelte??(window.__svelte={})).v??(Y0.v=new Set)).add(_T);yC();const ST="upload://";function CT(n){return n.startsWith(ST)}const dd=n=>n,mn=n=>n;var ut;(function(n){n.assertEqual=i=>{};function e(i){}n.assertIs=e;function t(i){throw new Error}n.assertNever=t,n.arrayToEnum=i=>{const o={};for(const s of i)o[s]=s;return o},n.getValidEnumValues=i=>{const o=n.objectKeys(i).filter(a=>typeof i[i[a]]!="number"),s={};for(const a of o)s[a]=i[a];return n.objectValues(s)},n.objectValues=i=>n.objectKeys(i).map(function(o){return i[o]}),n.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const o=[];for(const s in i)Object.prototype.hasOwnProperty.call(i,s)&&o.push(s);return o},n.find=(i,o)=>{for(const s of i)if(o(s))return s},n.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&Number.isFinite(i)&&Math.floor(i)===i;function r(i,o=" | "){return i.map(s=>typeof s=="string"?`'${s}'`:s).join(o)}n.joinValues=r,n.jsonStringifyReplacer=(i,o)=>typeof o=="bigint"?o.toString():o})(ut||(ut={}));var Dv;(function(n){n.mergeShapes=(e,t)=>({...e,...t})})(Dv||(Dv={}));const Me=ut.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Gi=n=>{switch(typeof n){case"undefined":return Me.undefined;case"string":return Me.string;case"number":return Number.isNaN(n)?Me.nan:Me.number;case"boolean":return Me.boolean;case"function":return Me.function;case"bigint":return Me.bigint;case"symbol":return Me.symbol;case"object":return Array.isArray(n)?Me.array:n===null?Me.null:n.then&&typeof n.then=="function"&&n.catch&&typeof n.catch=="function"?Me.promise:typeof Map<"u"&&n instanceof Map?Me.map:typeof Set<"u"&&n instanceof Set?Me.set:typeof Date<"u"&&n instanceof Date?Me.date:Me.object;default:return Me.unknown}},me=ut.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class Ui extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){const t=e||function(o){return o.message},r={_errors:[]},i=o=>{for(const s of o.issues)if(s.code==="invalid_union")s.unionErrors.map(i);else if(s.code==="invalid_return_type")i(s.returnTypeError);else if(s.code==="invalid_arguments")i(s.argumentsError);else if(s.path.length===0)r._errors.push(t(s));else{let a=r,l=0;for(;l<s.path.length;){const c=s.path[l];l===s.path.length-1?(a[c]=a[c]||{_errors:[]},a[c]._errors.push(t(s))):a[c]=a[c]||{_errors:[]},a=a[c],l++}}};return i(this),r}static assert(e){if(!(e instanceof Ui))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,ut.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},r=[];for(const i of this.issues)if(i.path.length>0){const o=i.path[0];t[o]=t[o]||[],t[o].push(e(i))}else r.push(e(i));return{formErrors:r,fieldErrors:t}}get formErrors(){return this.flatten()}}Ui.create=n=>new Ui(n);const op=(n,e)=>{let t;switch(n.code){case me.invalid_type:n.received===Me.undefined?t="Required":t=`Expected ${n.expected}, received ${n.received}`;break;case me.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(n.expected,ut.jsonStringifyReplacer)}`;break;case me.unrecognized_keys:t=`Unrecognized key(s) in object: ${ut.joinValues(n.keys,", ")}`;break;case me.invalid_union:t="Invalid input";break;case me.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${ut.joinValues(n.options)}`;break;case me.invalid_enum_value:t=`Invalid enum value. Expected ${ut.joinValues(n.options)}, received '${n.received}'`;break;case me.invalid_arguments:t="Invalid function arguments";break;case me.invalid_return_type:t="Invalid function return type";break;case me.invalid_date:t="Invalid date";break;case me.invalid_string:typeof n.validation=="object"?"includes"in n.validation?(t=`Invalid input: must include "${n.validation.includes}"`,typeof n.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${n.validation.position}`)):"startsWith"in n.validation?t=`Invalid input: must start with "${n.validation.startsWith}"`:"endsWith"in n.validation?t=`Invalid input: must end with "${n.validation.endsWith}"`:ut.assertNever(n.validation):n.validation!=="regex"?t=`Invalid ${n.validation}`:t="Invalid";break;case me.too_small:n.type==="array"?t=`Array must contain ${n.exact?"exactly":n.inclusive?"at least":"more than"} ${n.minimum} element(s)`:n.type==="string"?t=`String must contain ${n.exact?"exactly":n.inclusive?"at least":"over"} ${n.minimum} character(s)`:n.type==="number"?t=`Number must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${n.minimum}`:n.type==="bigint"?t=`Number must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${n.minimum}`:n.type==="date"?t=`Date must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(n.minimum))}`:t="Invalid input";break;case me.too_big:n.type==="array"?t=`Array must contain ${n.exact?"exactly":n.inclusive?"at most":"less than"} ${n.maximum} element(s)`:n.type==="string"?t=`String must contain ${n.exact?"exactly":n.inclusive?"at most":"under"} ${n.maximum} character(s)`:n.type==="number"?t=`Number must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="bigint"?t=`BigInt must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="date"?t=`Date must be ${n.exact?"exactly":n.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(n.maximum))}`:t="Invalid input";break;case me.custom:t="Invalid input";break;case me.invalid_intersection_types:t="Intersection results could not be merged";break;case me.not_multiple_of:t=`Number must be a multiple of ${n.multipleOf}`;break;case me.not_finite:t="Number must be finite";break;default:t=e.defaultError,ut.assertNever(n)}return{message:t}};let TT=op;function AT(){return TT}const ET=n=>{const{data:e,path:t,errorMaps:r,issueData:i}=n,o=[...t,...i.path||[]],s={...i,path:o};if(i.message!==void 0)return{...i,path:o,message:i.message};let a="";const l=r.filter(c=>!!c).slice().reverse();for(const c of l)a=c(s,{data:e,defaultError:a}).message;return{...i,path:o,message:a}};function _e(n,e){const t=AT(),r=ET({issueData:e,data:n.data,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,t,t===op?void 0:op].filter(i=>!!i)});n.common.issues.push(r)}class nr{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const r=[];for(const i of t){if(i.status==="aborted")return He;i.status==="dirty"&&e.dirty(),r.push(i.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,t){const r=[];for(const i of t){const o=await i.key,s=await i.value;r.push({key:o,value:s})}return nr.mergeObjectSync(e,r)}static mergeObjectSync(e,t){const r={};for(const i of t){const{key:o,value:s}=i;if(o.status==="aborted"||s.status==="aborted")return He;o.status==="dirty"&&e.dirty(),s.status==="dirty"&&e.dirty(),o.value!=="__proto__"&&(typeof s.value<"u"||i.alwaysSet)&&(r[o.value]=s.value)}return{status:e.value,value:r}}}const He=Object.freeze({status:"aborted"}),Qa=n=>({status:"dirty",value:n}),Tr=n=>({status:"valid",value:n}),Rv=n=>n.status==="aborted",Nv=n=>n.status==="dirty",ga=n=>n.status==="valid",Od=n=>typeof Promise<"u"&&n instanceof Promise;var Re;(function(n){n.errToObj=e=>typeof e=="string"?{message:e}:e||{},n.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(Re||(Re={}));class bo{constructor(e,t,r,i){this._cachedPath=[],this.parent=e,this.data=t,this._path=r,this._key=i}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const Iv=(n,e)=>{if(ga(e))return{success:!0,data:e.value};if(!n.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new Ui(n.common.issues);return this._error=t,this._error}}};function et(n){if(!n)return{};const{errorMap:e,invalid_type_error:t,required_error:r,description:i}=n;if(e&&(t||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:i}:{errorMap:(s,a)=>{const{message:l}=n;return s.code==="invalid_enum_value"?{message:l??a.defaultError}:typeof a.data>"u"?{message:l??r??a.defaultError}:s.code!=="invalid_type"?{message:a.defaultError}:{message:l??t??a.defaultError}},description:i}}class ct{get description(){return this._def.description}_getType(e){return Gi(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Gi(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new nr,ctx:{common:e.parent.common,data:e.data,parsedType:Gi(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(Od(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const r=this.safeParse(e,t);if(r.success)return r.data;throw r.error}safeParse(e,t){const r={common:{issues:[],async:(t==null?void 0:t.async)??!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Gi(e)},i=this._parseSync({data:e,path:r.path,parent:r});return Iv(r,i)}"~validate"(e){var r,i;const t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Gi(e)};if(!this["~standard"].async)try{const o=this._parseSync({data:e,path:[],parent:t});return ga(o)?{value:o.value}:{issues:t.common.issues}}catch(o){(i=(r=o==null?void 0:o.message)==null?void 0:r.toLowerCase())!=null&&i.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(o=>ga(o)?{value:o.value}:{issues:t.common.issues})}async parseAsync(e,t){const r=await this.safeParseAsync(e,t);if(r.success)return r.data;throw r.error}async safeParseAsync(e,t){const r={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Gi(e)},i=this._parse({data:e,path:r.path,parent:r}),o=await(Od(i)?i:Promise.resolve(i));return Iv(r,o)}refine(e,t){const r=i=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(i):t;return this._refinement((i,o)=>{const s=e(i),a=()=>o.addIssue({code:me.custom,...r(i)});return typeof Promise<"u"&&s instanceof Promise?s.then(l=>l?!0:(a(),!1)):s?!0:(a(),!1)})}refinement(e,t){return this._refinement((r,i)=>e(r)?!0:(i.addIssue(typeof t=="function"?t(r,i):t),!1))}_refinement(e){return new ya({schema:this,typeName:Ue.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:t=>this["~validate"](t)}}optional(){return ho.create(this,this._def)}nullable(){return ba.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ri.create(this)}promise(){return Id.create(this,this._def)}or(e){return Rd.create([this,e],this._def)}and(e){return Nd.create(this,e,this._def)}transform(e){return new ya({...et(this._def),schema:this,typeName:Ue.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new ap({...et(this._def),innerType:this,defaultValue:t,typeName:Ue.ZodDefault})}brand(){return new XT({typeName:Ue.ZodBranded,type:this,...et(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new lp({...et(this._def),innerType:this,catchValue:t,typeName:Ue.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Fm.create(this,e)}readonly(){return cp.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const MT=/^c[^\s-]{8,}$/i,OT=/^[0-9a-z]+$/,DT=/^[0-9A-HJKMNP-TV-Z]{26}$/i,RT=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,NT=/^[a-z0-9_-]{21}$/i,IT=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,PT=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,LT=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,zT="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Uf;const BT=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,FT=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,VT=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,HT=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,UT=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,jT=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Ww="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",WT=new RegExp(`^${Ww}$`);function Kw(n){let e="[0-5]\\d";n.precision?e=`${e}\\.\\d{${n.precision}}`:n.precision==null&&(e=`${e}(\\.\\d+)?`);const t=n.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${t}`}function KT(n){return new RegExp(`^${Kw(n)}$`)}function qT(n){let e=`${Ww}T${Kw(n)}`;const t=[];return t.push(n.local?"Z?":"Z"),n.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function JT(n,e){return!!((e==="v4"||!e)&&BT.test(n)||(e==="v6"||!e)&&VT.test(n))}function YT(n,e){if(!IT.test(n))return!1;try{const[t]=n.split(".");if(!t)return!1;const r=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),i=JSON.parse(atob(r));return!(typeof i!="object"||i===null||"typ"in i&&(i==null?void 0:i.typ)!=="JWT"||!i.alg||e&&i.alg!==e)}catch{return!1}}function GT(n,e){return!!((e==="v4"||!e)&&FT.test(n)||(e==="v6"||!e)&&HT.test(n))}class Uo extends ct{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==Me.string){const o=this._getOrReturnCtx(e);return _e(o,{code:me.invalid_type,expected:Me.string,received:o.parsedType}),He}const r=new nr;let i;for(const o of this._def.checks)if(o.kind==="min")e.data.length<o.value&&(i=this._getOrReturnCtx(e,i),_e(i,{code:me.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),r.dirty());else if(o.kind==="max")e.data.length>o.value&&(i=this._getOrReturnCtx(e,i),_e(i,{code:me.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),r.dirty());else if(o.kind==="length"){const s=e.data.length>o.value,a=e.data.length<o.value;(s||a)&&(i=this._getOrReturnCtx(e,i),s?_e(i,{code:me.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}):a&&_e(i,{code:me.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}),r.dirty())}else if(o.kind==="email")LT.test(e.data)||(i=this._getOrReturnCtx(e,i),_e(i,{validation:"email",code:me.invalid_string,message:o.message}),r.dirty());else if(o.kind==="emoji")Uf||(Uf=new RegExp(zT,"u")),Uf.test(e.data)||(i=this._getOrReturnCtx(e,i),_e(i,{validation:"emoji",code:me.invalid_string,message:o.message}),r.dirty());else if(o.kind==="uuid")RT.test(e.data)||(i=this._getOrReturnCtx(e,i),_e(i,{validation:"uuid",code:me.invalid_string,message:o.message}),r.dirty());else if(o.kind==="nanoid")NT.test(e.data)||(i=this._getOrReturnCtx(e,i),_e(i,{validation:"nanoid",code:me.invalid_string,message:o.message}),r.dirty());else if(o.kind==="cuid")MT.test(e.data)||(i=this._getOrReturnCtx(e,i),_e(i,{validation:"cuid",code:me.invalid_string,message:o.message}),r.dirty());else if(o.kind==="cuid2")OT.test(e.data)||(i=this._getOrReturnCtx(e,i),_e(i,{validation:"cuid2",code:me.invalid_string,message:o.message}),r.dirty());else if(o.kind==="ulid")DT.test(e.data)||(i=this._getOrReturnCtx(e,i),_e(i,{validation:"ulid",code:me.invalid_string,message:o.message}),r.dirty());else if(o.kind==="url")try{new URL(e.data)}catch{i=this._getOrReturnCtx(e,i),_e(i,{validation:"url",code:me.invalid_string,message:o.message}),r.dirty()}else o.kind==="regex"?(o.regex.lastIndex=0,o.regex.test(e.data)||(i=this._getOrReturnCtx(e,i),_e(i,{validation:"regex",code:me.invalid_string,message:o.message}),r.dirty())):o.kind==="trim"?e.data=e.data.trim():o.kind==="includes"?e.data.includes(o.value,o.position)||(i=this._getOrReturnCtx(e,i),_e(i,{code:me.invalid_string,validation:{includes:o.value,position:o.position},message:o.message}),r.dirty()):o.kind==="toLowerCase"?e.data=e.data.toLowerCase():o.kind==="toUpperCase"?e.data=e.data.toUpperCase():o.kind==="startsWith"?e.data.startsWith(o.value)||(i=this._getOrReturnCtx(e,i),_e(i,{code:me.invalid_string,validation:{startsWith:o.value},message:o.message}),r.dirty()):o.kind==="endsWith"?e.data.endsWith(o.value)||(i=this._getOrReturnCtx(e,i),_e(i,{code:me.invalid_string,validation:{endsWith:o.value},message:o.message}),r.dirty()):o.kind==="datetime"?qT(o).test(e.data)||(i=this._getOrReturnCtx(e,i),_e(i,{code:me.invalid_string,validation:"datetime",message:o.message}),r.dirty()):o.kind==="date"?WT.test(e.data)||(i=this._getOrReturnCtx(e,i),_e(i,{code:me.invalid_string,validation:"date",message:o.message}),r.dirty()):o.kind==="time"?KT(o).test(e.data)||(i=this._getOrReturnCtx(e,i),_e(i,{code:me.invalid_string,validation:"time",message:o.message}),r.dirty()):o.kind==="duration"?PT.test(e.data)||(i=this._getOrReturnCtx(e,i),_e(i,{validation:"duration",code:me.invalid_string,message:o.message}),r.dirty()):o.kind==="ip"?JT(e.data,o.version)||(i=this._getOrReturnCtx(e,i),_e(i,{validation:"ip",code:me.invalid_string,message:o.message}),r.dirty()):o.kind==="jwt"?YT(e.data,o.alg)||(i=this._getOrReturnCtx(e,i),_e(i,{validation:"jwt",code:me.invalid_string,message:o.message}),r.dirty()):o.kind==="cidr"?GT(e.data,o.version)||(i=this._getOrReturnCtx(e,i),_e(i,{validation:"cidr",code:me.invalid_string,message:o.message}),r.dirty()):o.kind==="base64"?UT.test(e.data)||(i=this._getOrReturnCtx(e,i),_e(i,{validation:"base64",code:me.invalid_string,message:o.message}),r.dirty()):o.kind==="base64url"?jT.test(e.data)||(i=this._getOrReturnCtx(e,i),_e(i,{validation:"base64url",code:me.invalid_string,message:o.message}),r.dirty()):ut.assertNever(o);return{status:r.value,value:e.data}}_regex(e,t,r){return this.refinement(i=>e.test(i),{validation:t,code:me.invalid_string,...Re.errToObj(r)})}_addCheck(e){return new Uo({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...Re.errToObj(e)})}url(e){return this._addCheck({kind:"url",...Re.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...Re.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...Re.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...Re.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...Re.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...Re.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...Re.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...Re.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...Re.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...Re.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...Re.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...Re.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(e==null?void 0:e.offset)??!1,local:(e==null?void 0:e.local)??!1,...Re.errToObj(e==null?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,...Re.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...Re.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...Re.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...Re.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...Re.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...Re.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...Re.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...Re.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...Re.errToObj(t)})}nonempty(e){return this.min(1,Re.errToObj(e))}trim(){return new Uo({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Uo({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Uo({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}Uo.create=n=>new Uo({checks:[],typeName:Ue.ZodString,coerce:(n==null?void 0:n.coerce)??!1,...et(n)});function ZT(n,e){const t=(n.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,i=t>r?t:r,o=Number.parseInt(n.toFixed(i).replace(".","")),s=Number.parseInt(e.toFixed(i).replace(".",""));return o%s/10**i}class Ml extends ct{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==Me.number){const o=this._getOrReturnCtx(e);return _e(o,{code:me.invalid_type,expected:Me.number,received:o.parsedType}),He}let r;const i=new nr;for(const o of this._def.checks)o.kind==="int"?ut.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),_e(r,{code:me.invalid_type,expected:"integer",received:"float",message:o.message}),i.dirty()):o.kind==="min"?(o.inclusive?e.data<o.value:e.data<=o.value)&&(r=this._getOrReturnCtx(e,r),_e(r,{code:me.too_small,minimum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),i.dirty()):o.kind==="max"?(o.inclusive?e.data>o.value:e.data>=o.value)&&(r=this._getOrReturnCtx(e,r),_e(r,{code:me.too_big,maximum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),i.dirty()):o.kind==="multipleOf"?ZT(e.data,o.value)!==0&&(r=this._getOrReturnCtx(e,r),_e(r,{code:me.not_multiple_of,multipleOf:o.value,message:o.message}),i.dirty()):o.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),_e(r,{code:me.not_finite,message:o.message}),i.dirty()):ut.assertNever(o);return{status:i.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,Re.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Re.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Re.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Re.toString(t))}setLimit(e,t,r,i){return new Ml({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:Re.toString(i)}]})}_addCheck(e){return new Ml({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:Re.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Re.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Re.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Re.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Re.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Re.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:Re.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Re.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Re.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&ut.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(t===null||r.value>t)&&(t=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value)}return Number.isFinite(t)&&Number.isFinite(e)}}Ml.create=n=>new Ml({checks:[],typeName:Ue.ZodNumber,coerce:(n==null?void 0:n.coerce)||!1,...et(n)});class Ol extends ct{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==Me.bigint)return this._getInvalidInput(e);let r;const i=new nr;for(const o of this._def.checks)o.kind==="min"?(o.inclusive?e.data<o.value:e.data<=o.value)&&(r=this._getOrReturnCtx(e,r),_e(r,{code:me.too_small,type:"bigint",minimum:o.value,inclusive:o.inclusive,message:o.message}),i.dirty()):o.kind==="max"?(o.inclusive?e.data>o.value:e.data>=o.value)&&(r=this._getOrReturnCtx(e,r),_e(r,{code:me.too_big,type:"bigint",maximum:o.value,inclusive:o.inclusive,message:o.message}),i.dirty()):o.kind==="multipleOf"?e.data%o.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),_e(r,{code:me.not_multiple_of,multipleOf:o.value,message:o.message}),i.dirty()):ut.assertNever(o);return{status:i.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return _e(t,{code:me.invalid_type,expected:Me.bigint,received:t.parsedType}),He}gte(e,t){return this.setLimit("min",e,!0,Re.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Re.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Re.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Re.toString(t))}setLimit(e,t,r,i){return new Ol({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:Re.toString(i)}]})}_addCheck(e){return new Ol({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Re.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Re.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Re.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Re.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Re.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}Ol.create=n=>new Ol({checks:[],typeName:Ue.ZodBigInt,coerce:(n==null?void 0:n.coerce)??!1,...et(n)});class Pv extends ct{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==Me.boolean){const r=this._getOrReturnCtx(e);return _e(r,{code:me.invalid_type,expected:Me.boolean,received:r.parsedType}),He}return Tr(e.data)}}Pv.create=n=>new Pv({typeName:Ue.ZodBoolean,coerce:(n==null?void 0:n.coerce)||!1,...et(n)});class Dd extends ct{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==Me.date){const o=this._getOrReturnCtx(e);return _e(o,{code:me.invalid_type,expected:Me.date,received:o.parsedType}),He}if(Number.isNaN(e.data.getTime())){const o=this._getOrReturnCtx(e);return _e(o,{code:me.invalid_date}),He}const r=new nr;let i;for(const o of this._def.checks)o.kind==="min"?e.data.getTime()<o.value&&(i=this._getOrReturnCtx(e,i),_e(i,{code:me.too_small,message:o.message,inclusive:!0,exact:!1,minimum:o.value,type:"date"}),r.dirty()):o.kind==="max"?e.data.getTime()>o.value&&(i=this._getOrReturnCtx(e,i),_e(i,{code:me.too_big,message:o.message,inclusive:!0,exact:!1,maximum:o.value,type:"date"}),r.dirty()):ut.assertNever(o);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Dd({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:Re.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:Re.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}Dd.create=n=>new Dd({checks:[],coerce:(n==null?void 0:n.coerce)||!1,typeName:Ue.ZodDate,...et(n)});class Lv extends ct{_parse(e){if(this._getType(e)!==Me.symbol){const r=this._getOrReturnCtx(e);return _e(r,{code:me.invalid_type,expected:Me.symbol,received:r.parsedType}),He}return Tr(e.data)}}Lv.create=n=>new Lv({typeName:Ue.ZodSymbol,...et(n)});class zv extends ct{_parse(e){if(this._getType(e)!==Me.undefined){const r=this._getOrReturnCtx(e);return _e(r,{code:me.invalid_type,expected:Me.undefined,received:r.parsedType}),He}return Tr(e.data)}}zv.create=n=>new zv({typeName:Ue.ZodUndefined,...et(n)});class Bv extends ct{_parse(e){if(this._getType(e)!==Me.null){const r=this._getOrReturnCtx(e);return _e(r,{code:me.invalid_type,expected:Me.null,received:r.parsedType}),He}return Tr(e.data)}}Bv.create=n=>new Bv({typeName:Ue.ZodNull,...et(n)});class Fv extends ct{constructor(){super(...arguments),this._any=!0}_parse(e){return Tr(e.data)}}Fv.create=n=>new Fv({typeName:Ue.ZodAny,...et(n)});class Vv extends ct{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Tr(e.data)}}Vv.create=n=>new Vv({typeName:Ue.ZodUnknown,...et(n)});class wo extends ct{_parse(e){const t=this._getOrReturnCtx(e);return _e(t,{code:me.invalid_type,expected:Me.never,received:t.parsedType}),He}}wo.create=n=>new wo({typeName:Ue.ZodNever,...et(n)});class Hv extends ct{_parse(e){if(this._getType(e)!==Me.undefined){const r=this._getOrReturnCtx(e);return _e(r,{code:me.invalid_type,expected:Me.void,received:r.parsedType}),He}return Tr(e.data)}}Hv.create=n=>new Hv({typeName:Ue.ZodVoid,...et(n)});class ri extends ct{_parse(e){const{ctx:t,status:r}=this._processInputParams(e),i=this._def;if(t.parsedType!==Me.array)return _e(t,{code:me.invalid_type,expected:Me.array,received:t.parsedType}),He;if(i.exactLength!==null){const s=t.data.length>i.exactLength.value,a=t.data.length<i.exactLength.value;(s||a)&&(_e(t,{code:s?me.too_big:me.too_small,minimum:a?i.exactLength.value:void 0,maximum:s?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),r.dirty())}if(i.minLength!==null&&t.data.length<i.minLength.value&&(_e(t,{code:me.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),r.dirty()),i.maxLength!==null&&t.data.length>i.maxLength.value&&(_e(t,{code:me.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),r.dirty()),t.common.async)return Promise.all([...t.data].map((s,a)=>i.type._parseAsync(new bo(t,s,t.path,a)))).then(s=>nr.mergeArray(r,s));const o=[...t.data].map((s,a)=>i.type._parseSync(new bo(t,s,t.path,a)));return nr.mergeArray(r,o)}get element(){return this._def.type}min(e,t){return new ri({...this._def,minLength:{value:e,message:Re.toString(t)}})}max(e,t){return new ri({...this._def,maxLength:{value:e,message:Re.toString(t)}})}length(e,t){return new ri({...this._def,exactLength:{value:e,message:Re.toString(t)}})}nonempty(e){return this.min(1,e)}}ri.create=(n,e)=>new ri({type:n,minLength:null,maxLength:null,exactLength:null,typeName:Ue.ZodArray,...et(e)});function Fs(n){if(n instanceof Qt){const e={};for(const t in n.shape){const r=n.shape[t];e[t]=ho.create(Fs(r))}return new Qt({...n._def,shape:()=>e})}else return n instanceof ri?new ri({...n._def,type:Fs(n.element)}):n instanceof ho?ho.create(Fs(n.unwrap())):n instanceof ba?ba.create(Fs(n.unwrap())):n instanceof ps?ps.create(n.items.map(e=>Fs(e))):n}class Qt extends ct{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=ut.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==Me.object){const c=this._getOrReturnCtx(e);return _e(c,{code:me.invalid_type,expected:Me.object,received:c.parsedType}),He}const{status:r,ctx:i}=this._processInputParams(e),{shape:o,keys:s}=this._getCached(),a=[];if(!(this._def.catchall instanceof wo&&this._def.unknownKeys==="strip"))for(const c in i.data)s.includes(c)||a.push(c);const l=[];for(const c of s){const d=o[c],u=i.data[c];l.push({key:{status:"valid",value:c},value:d._parse(new bo(i,u,i.path,c)),alwaysSet:c in i.data})}if(this._def.catchall instanceof wo){const c=this._def.unknownKeys;if(c==="passthrough")for(const d of a)l.push({key:{status:"valid",value:d},value:{status:"valid",value:i.data[d]}});else if(c==="strict")a.length>0&&(_e(i,{code:me.unrecognized_keys,keys:a}),r.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const c=this._def.catchall;for(const d of a){const u=i.data[d];l.push({key:{status:"valid",value:d},value:c._parse(new bo(i,u,i.path,d)),alwaysSet:d in i.data})}}return i.common.async?Promise.resolve().then(async()=>{const c=[];for(const d of l){const u=await d.key,h=await d.value;c.push({key:u,value:h,alwaysSet:d.alwaysSet})}return c}).then(c=>nr.mergeObjectSync(r,c)):nr.mergeObjectSync(r,l)}get shape(){return this._def.shape()}strict(e){return Re.errToObj,new Qt({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,r)=>{var o,s;const i=((s=(o=this._def).errorMap)==null?void 0:s.call(o,t,r).message)??r.defaultError;return t.code==="unrecognized_keys"?{message:Re.errToObj(e).message??i}:{message:i}}}:{}})}strip(){return new Qt({...this._def,unknownKeys:"strip"})}passthrough(){return new Qt({...this._def,unknownKeys:"passthrough"})}extend(e){return new Qt({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Qt({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:Ue.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new Qt({...this._def,catchall:e})}pick(e){const t={};for(const r of ut.objectKeys(e))e[r]&&this.shape[r]&&(t[r]=this.shape[r]);return new Qt({...this._def,shape:()=>t})}omit(e){const t={};for(const r of ut.objectKeys(this.shape))e[r]||(t[r]=this.shape[r]);return new Qt({...this._def,shape:()=>t})}deepPartial(){return Fs(this)}partial(e){const t={};for(const r of ut.objectKeys(this.shape)){const i=this.shape[r];e&&!e[r]?t[r]=i:t[r]=i.optional()}return new Qt({...this._def,shape:()=>t})}required(e){const t={};for(const r of ut.objectKeys(this.shape))if(e&&!e[r])t[r]=this.shape[r];else{let o=this.shape[r];for(;o instanceof ho;)o=o._def.innerType;t[r]=o}return new Qt({...this._def,shape:()=>t})}keyof(){return qw(ut.objectKeys(this.shape))}}Qt.create=(n,e)=>new Qt({shape:()=>n,unknownKeys:"strip",catchall:wo.create(),typeName:Ue.ZodObject,...et(e)});Qt.strictCreate=(n,e)=>new Qt({shape:()=>n,unknownKeys:"strict",catchall:wo.create(),typeName:Ue.ZodObject,...et(e)});Qt.lazycreate=(n,e)=>new Qt({shape:n,unknownKeys:"strip",catchall:wo.create(),typeName:Ue.ZodObject,...et(e)});class Rd extends ct{_parse(e){const{ctx:t}=this._processInputParams(e),r=this._def.options;function i(o){for(const a of o)if(a.result.status==="valid")return a.result;for(const a of o)if(a.result.status==="dirty")return t.common.issues.push(...a.ctx.common.issues),a.result;const s=o.map(a=>new Ui(a.ctx.common.issues));return _e(t,{code:me.invalid_union,unionErrors:s}),He}if(t.common.async)return Promise.all(r.map(async o=>{const s={...t,common:{...t.common,issues:[]},parent:null};return{result:await o._parseAsync({data:t.data,path:t.path,parent:s}),ctx:s}})).then(i);{let o;const s=[];for(const l of r){const c={...t,common:{...t.common,issues:[]},parent:null},d=l._parseSync({data:t.data,path:t.path,parent:c});if(d.status==="valid")return d;d.status==="dirty"&&!o&&(o={result:d,ctx:c}),c.common.issues.length&&s.push(c.common.issues)}if(o)return t.common.issues.push(...o.ctx.common.issues),o.result;const a=s.map(l=>new Ui(l));return _e(t,{code:me.invalid_union,unionErrors:a}),He}}get options(){return this._def.options}}Rd.create=(n,e)=>new Rd({options:n,typeName:Ue.ZodUnion,...et(e)});function sp(n,e){const t=Gi(n),r=Gi(e);if(n===e)return{valid:!0,data:n};if(t===Me.object&&r===Me.object){const i=ut.objectKeys(e),o=ut.objectKeys(n).filter(a=>i.indexOf(a)!==-1),s={...n,...e};for(const a of o){const l=sp(n[a],e[a]);if(!l.valid)return{valid:!1};s[a]=l.data}return{valid:!0,data:s}}else if(t===Me.array&&r===Me.array){if(n.length!==e.length)return{valid:!1};const i=[];for(let o=0;o<n.length;o++){const s=n[o],a=e[o],l=sp(s,a);if(!l.valid)return{valid:!1};i.push(l.data)}return{valid:!0,data:i}}else return t===Me.date&&r===Me.date&&+n==+e?{valid:!0,data:n}:{valid:!1}}class Nd extends ct{_parse(e){const{status:t,ctx:r}=this._processInputParams(e),i=(o,s)=>{if(Rv(o)||Rv(s))return He;const a=sp(o.value,s.value);return a.valid?((Nv(o)||Nv(s))&&t.dirty(),{status:t.value,value:a.data}):(_e(r,{code:me.invalid_intersection_types}),He)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([o,s])=>i(o,s)):i(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}Nd.create=(n,e,t)=>new Nd({left:n,right:e,typeName:Ue.ZodIntersection,...et(t)});class ps extends ct{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==Me.array)return _e(r,{code:me.invalid_type,expected:Me.array,received:r.parsedType}),He;if(r.data.length<this._def.items.length)return _e(r,{code:me.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),He;!this._def.rest&&r.data.length>this._def.items.length&&(_e(r,{code:me.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const o=[...r.data].map((s,a)=>{const l=this._def.items[a]||this._def.rest;return l?l._parse(new bo(r,s,r.path,a)):null}).filter(s=>!!s);return r.common.async?Promise.all(o).then(s=>nr.mergeArray(t,s)):nr.mergeArray(t,o)}get items(){return this._def.items}rest(e){return new ps({...this._def,rest:e})}}ps.create=(n,e)=>{if(!Array.isArray(n))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new ps({items:n,typeName:Ue.ZodTuple,rest:null,...et(e)})};class Uv extends ct{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==Me.map)return _e(r,{code:me.invalid_type,expected:Me.map,received:r.parsedType}),He;const i=this._def.keyType,o=this._def.valueType,s=[...r.data.entries()].map(([a,l],c)=>({key:i._parse(new bo(r,a,r.path,[c,"key"])),value:o._parse(new bo(r,l,r.path,[c,"value"]))}));if(r.common.async){const a=new Map;return Promise.resolve().then(async()=>{for(const l of s){const c=await l.key,d=await l.value;if(c.status==="aborted"||d.status==="aborted")return He;(c.status==="dirty"||d.status==="dirty")&&t.dirty(),a.set(c.value,d.value)}return{status:t.value,value:a}})}else{const a=new Map;for(const l of s){const c=l.key,d=l.value;if(c.status==="aborted"||d.status==="aborted")return He;(c.status==="dirty"||d.status==="dirty")&&t.dirty(),a.set(c.value,d.value)}return{status:t.value,value:a}}}}Uv.create=(n,e,t)=>new Uv({valueType:e,keyType:n,typeName:Ue.ZodMap,...et(t)});class Dl extends ct{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==Me.set)return _e(r,{code:me.invalid_type,expected:Me.set,received:r.parsedType}),He;const i=this._def;i.minSize!==null&&r.data.size<i.minSize.value&&(_e(r,{code:me.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),t.dirty()),i.maxSize!==null&&r.data.size>i.maxSize.value&&(_e(r,{code:me.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),t.dirty());const o=this._def.valueType;function s(l){const c=new Set;for(const d of l){if(d.status==="aborted")return He;d.status==="dirty"&&t.dirty(),c.add(d.value)}return{status:t.value,value:c}}const a=[...r.data.values()].map((l,c)=>o._parse(new bo(r,l,r.path,c)));return r.common.async?Promise.all(a).then(l=>s(l)):s(a)}min(e,t){return new Dl({...this._def,minSize:{value:e,message:Re.toString(t)}})}max(e,t){return new Dl({...this._def,maxSize:{value:e,message:Re.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}Dl.create=(n,e)=>new Dl({valueType:n,minSize:null,maxSize:null,typeName:Ue.ZodSet,...et(e)});class jv extends ct{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}jv.create=(n,e)=>new jv({getter:n,typeName:Ue.ZodLazy,...et(e)});class Wv extends ct{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return _e(t,{received:t.data,code:me.invalid_literal,expected:this._def.value}),He}return{status:"valid",value:e.data}}get value(){return this._def.value}}Wv.create=(n,e)=>new Wv({value:n,typeName:Ue.ZodLiteral,...et(e)});function qw(n,e){return new va({values:n,typeName:Ue.ZodEnum,...et(e)})}class va extends ct{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),r=this._def.values;return _e(t,{expected:ut.joinValues(r),received:t.parsedType,code:me.invalid_type}),He}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const t=this._getOrReturnCtx(e),r=this._def.values;return _e(t,{received:t.data,code:me.invalid_enum_value,options:r}),He}return Tr(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return va.create(e,{...this._def,...t})}exclude(e,t=this._def){return va.create(this.options.filter(r=>!e.includes(r)),{...this._def,...t})}}va.create=qw;class Kv extends ct{_parse(e){const t=ut.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==Me.string&&r.parsedType!==Me.number){const i=ut.objectValues(t);return _e(r,{expected:ut.joinValues(i),received:r.parsedType,code:me.invalid_type}),He}if(this._cache||(this._cache=new Set(ut.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const i=ut.objectValues(t);return _e(r,{received:r.data,code:me.invalid_enum_value,options:i}),He}return Tr(e.data)}get enum(){return this._def.values}}Kv.create=(n,e)=>new Kv({values:n,typeName:Ue.ZodNativeEnum,...et(e)});class Id extends ct{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==Me.promise&&t.common.async===!1)return _e(t,{code:me.invalid_type,expected:Me.promise,received:t.parsedType}),He;const r=t.parsedType===Me.promise?t.data:Promise.resolve(t.data);return Tr(r.then(i=>this._def.type.parseAsync(i,{path:t.path,errorMap:t.common.contextualErrorMap})))}}Id.create=(n,e)=>new Id({type:n,typeName:Ue.ZodPromise,...et(e)});class ya extends ct{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Ue.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:r}=this._processInputParams(e),i=this._def.effect||null,o={addIssue:s=>{_e(r,s),s.fatal?t.abort():t.dirty()},get path(){return r.path}};if(o.addIssue=o.addIssue.bind(o),i.type==="preprocess"){const s=i.transform(r.data,o);if(r.common.async)return Promise.resolve(s).then(async a=>{if(t.value==="aborted")return He;const l=await this._def.schema._parseAsync({data:a,path:r.path,parent:r});return l.status==="aborted"?He:l.status==="dirty"||t.value==="dirty"?Qa(l.value):l});{if(t.value==="aborted")return He;const a=this._def.schema._parseSync({data:s,path:r.path,parent:r});return a.status==="aborted"?He:a.status==="dirty"||t.value==="dirty"?Qa(a.value):a}}if(i.type==="refinement"){const s=a=>{const l=i.refinement(a,o);if(r.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(r.common.async===!1){const a=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?He:(a.status==="dirty"&&t.dirty(),s(a.value),{status:t.value,value:a.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(a=>a.status==="aborted"?He:(a.status==="dirty"&&t.dirty(),s(a.value).then(()=>({status:t.value,value:a.value}))))}if(i.type==="transform")if(r.common.async===!1){const s=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!ga(s))return He;const a=i.transform(s.value,o);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:a}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(s=>ga(s)?Promise.resolve(i.transform(s.value,o)).then(a=>({status:t.value,value:a})):He);ut.assertNever(i)}}ya.create=(n,e,t)=>new ya({schema:n,typeName:Ue.ZodEffects,effect:e,...et(t)});ya.createWithPreprocess=(n,e,t)=>new ya({schema:e,effect:{type:"preprocess",transform:n},typeName:Ue.ZodEffects,...et(t)});class ho extends ct{_parse(e){return this._getType(e)===Me.undefined?Tr(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}ho.create=(n,e)=>new ho({innerType:n,typeName:Ue.ZodOptional,...et(e)});class ba extends ct{_parse(e){return this._getType(e)===Me.null?Tr(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}ba.create=(n,e)=>new ba({innerType:n,typeName:Ue.ZodNullable,...et(e)});class ap extends ct{_parse(e){const{ctx:t}=this._processInputParams(e);let r=t.data;return t.parsedType===Me.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}ap.create=(n,e)=>new ap({innerType:n,typeName:Ue.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...et(e)});class lp extends ct{_parse(e){const{ctx:t}=this._processInputParams(e),r={...t,common:{...t.common,issues:[]}},i=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return Od(i)?i.then(o=>({status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new Ui(r.common.issues)},input:r.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Ui(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}lp.create=(n,e)=>new lp({innerType:n,typeName:Ue.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...et(e)});class qv extends ct{_parse(e){if(this._getType(e)!==Me.nan){const r=this._getOrReturnCtx(e);return _e(r,{code:me.invalid_type,expected:Me.nan,received:r.parsedType}),He}return{status:"valid",value:e.data}}}qv.create=n=>new qv({typeName:Ue.ZodNaN,...et(n)});class XT extends ct{_parse(e){const{ctx:t}=this._processInputParams(e),r=t.data;return this._def.type._parse({data:r,path:t.path,parent:t})}unwrap(){return this._def.type}}class Fm extends ct{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{const o=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return o.status==="aborted"?He:o.status==="dirty"?(t.dirty(),Qa(o.value)):this._def.out._parseAsync({data:o.value,path:r.path,parent:r})})();{const i=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?He:i.status==="dirty"?(t.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:r.path,parent:r})}}static create(e,t){return new Fm({in:e,out:t,typeName:Ue.ZodPipeline})}}class cp extends ct{_parse(e){const t=this._def.innerType._parse(e),r=i=>(ga(i)&&(i.value=Object.freeze(i.value)),i);return Od(t)?t.then(i=>r(i)):r(t)}unwrap(){return this._def.innerType}}cp.create=(n,e)=>new cp({innerType:n,typeName:Ue.ZodReadonly,...et(e)});var Ue;(function(n){n.ZodString="ZodString",n.ZodNumber="ZodNumber",n.ZodNaN="ZodNaN",n.ZodBigInt="ZodBigInt",n.ZodBoolean="ZodBoolean",n.ZodDate="ZodDate",n.ZodSymbol="ZodSymbol",n.ZodUndefined="ZodUndefined",n.ZodNull="ZodNull",n.ZodAny="ZodAny",n.ZodUnknown="ZodUnknown",n.ZodNever="ZodNever",n.ZodVoid="ZodVoid",n.ZodArray="ZodArray",n.ZodObject="ZodObject",n.ZodUnion="ZodUnion",n.ZodDiscriminatedUnion="ZodDiscriminatedUnion",n.ZodIntersection="ZodIntersection",n.ZodTuple="ZodTuple",n.ZodRecord="ZodRecord",n.ZodMap="ZodMap",n.ZodSet="ZodSet",n.ZodFunction="ZodFunction",n.ZodLazy="ZodLazy",n.ZodLiteral="ZodLiteral",n.ZodEnum="ZodEnum",n.ZodEffects="ZodEffects",n.ZodNativeEnum="ZodNativeEnum",n.ZodOptional="ZodOptional",n.ZodNullable="ZodNullable",n.ZodDefault="ZodDefault",n.ZodCatch="ZodCatch",n.ZodPromise="ZodPromise",n.ZodBranded="ZodBranded",n.ZodPipeline="ZodPipeline",n.ZodReadonly="ZodReadonly"})(Ue||(Ue={}));wo.create;ri.create;Rd.create;Nd.create;ps.create;const Br=va.create;Id.create;ho.create;ba.create;Br(["highlight","note","comment"]);Br(["pending","accepted","dismissed"]);Br(["yellow","green","blue","pink"]);Br(["info","warning","error","success"]);const QT=Br(["solo","tandem"]);Br(["user","claude","import"]);Br(["user","claude"]);Br(["accept","dismiss"]);Br(["markdown","json"]);Br(["md","txt","html","docx"]);Br(["RANGE_GONE","RANGE_MOVED","FILE_LOCKED","FILE_NOT_FOUND","NO_DOCUMENT","INVALID_RANGE","FORMAT_ERROR","PERMISSION_DENIED"]);function $T(n){return n.author!=="user"}function Pd(n){return n.status==="pending"&&$T(n)}const Jv=3478,wc=3479,eA=new Set([".md",".txt",".html",".htm",".docx"]),tA=3e3,nA=3e3,rA=3e4,Jw={yellow:"rgba(255, 235, 59, 0.3)",green:"rgba(76, 175, 80, 0.3)",blue:"rgba(33, 150, 243, 0.3)",pink:"rgba(236, 72, 153, 0.3)"},Rl={yellow:"var(--tandem-highlight-yellow)",green:"var(--tandem-highlight-green)",blue:"var(--tandem-highlight-blue)",pink:"var(--tandem-highlight-pink)"};function Yw(n){return n&&n in Jw?n:"yellow"}const Yv="tandem",Pc="tandem:mode",Gw="tandem:settings",iA="tandem-panel-width",oA="tandem-left-panel-width",Zw={left:oA,right:iA},Xw=1e3,Ld=500,zd=3e3,sA="__tandem_ctrl__",xo="annotations",Qw="awareness",dp="userAwareness",aA="mode",lA="selectionDwellMs",Gv="chat",ol="documentMeta",cA="annotationReplies",sl="savedAtVersion",Zv="authorship",Xv="selection",Qv="activity",up="claude",Ka="openDocuments",qa="activeDocumentId",jf="generationId",Wf="readOnly",Kf="storeReadOnly",$w="tandem:showAuthorship",Vm="tandem:recentFiles",dA=20,Hm="tandem:userName",ex="You",fp="tandem:user-name-changed",tx=40,$v={error:8e3,warning:6e3,info:4e3},uA=5,nx="tandem:tutorialCompleted",fA="tutorial-",rx="tandem:coworkOnboardingSkipped",hA=3e4,R5=2e3,ey="tandem:zoomLevel",ty=.5,ny=2,Ja=1,Sr=`http://localhost:${wc}/api`;function pA(n){const e=new Uint8Array(n);let t="";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return btoa(t)}function mA(n){return n.toLowerCase().endsWith(".docx")}async function ix(n){if(mA(n.name)){const e=await n.arrayBuffer();return pA(e)}return n.text()}const ox=["editor","navigation","view","document"];let ud=z(at(new Map));function gA(n,e={}){if(f(ud).has(n.id)&&!e.replace){const t=`[actions] id collision: "${n.id}" — existing action silently replaced. Pass { replace: true } to suppress this warning.`;console.warn(t)}return b(ud,new Map(f(ud)).set(n.id,n),!0),!0}function Bd(){return f(ud)}let hp=null;function vA(n){hp=n}function qf(n,e){if(!hp){console.warn(`[actions] "${n}" invoked before App mounted — deps not wired yet`);return}e(hp)}let pp=z(!1);const yA={get saving(){return f(pp)}};let Jf=!1,Yf=!1;async function Um(){if(!Yf){Yf=!0;try{const n=await fetch(`${Sr}/scratchpad`,{method:"POST"});if(!n.ok){const e=await n.json().catch(()=>({}));console.warn("[Tandem] New Scratchpad failed:",e.message??n.statusText)}}catch(n){console.warn("[Tandem] New Scratchpad request failed:",n)}finally{Yf=!1}}}async function sx(n){if(!(!n||Jf)){Jf=!0,b(pp,!0);try{const e=await fetch(`http://localhost:${wc}/api/save`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({documentId:n})});if(!e.ok){const t=await e.json().catch(()=>({}));console.warn("[Tandem] Save failed:",t.message??e.statusText)}}catch(e){console.warn("[Tandem] Save request failed:",e)}finally{Jf=!1,b(pp,!1)}}}const bA=[{id:"save",label:"Save document",group:"document",shortcut:"Ctrl+S",run(){qf("save",n=>void sx(n.getActiveTabId()))}},{id:"settings",label:"Open settings",group:"view",shortcut:"Ctrl+,",run(){qf("settings",n=>n.openSettings())}},{id:"toggle-mode",label:"Toggle Solo / Tandem mode",group:"document",run(){qf("toggle-mode",n=>n.toggleSoloMode())}},{id:"new-scratchpad",label:"New Scratchpad",group:"document",shortcut:"Ctrl+N",run(){Um()}}];for(const n of bA)gA(n);function dn(n){this.content=n}dn.prototype={constructor:dn,find:function(n){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===n)return e;return-1},get:function(n){var e=this.find(n);return e==-1?void 0:this.content[e+1]},update:function(n,e,t){var r=t&&t!=n?this.remove(t):this,i=r.find(n),o=r.content.slice();return i==-1?o.push(t||n,e):(o[i+1]=e,t&&(o[i]=t)),new dn(o)},remove:function(n){var e=this.find(n);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new dn(t)},addToStart:function(n,e){return new dn([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new dn(t)},addBefore:function(n,e,t){var r=this.remove(e),i=r.content.slice(),o=r.find(n);return i.splice(o==-1?i.length:o,0,e,t),new dn(i)},forEach:function(n){for(var e=0;e<this.content.length;e+=2)n(this.content[e],this.content[e+1])},prepend:function(n){return n=dn.from(n),n.size?new dn(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=dn.from(n),n.size?new dn(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=dn.from(n);for(var t=0;t<n.content.length;t+=2)e=e.remove(n.content[t]);return e},toObject:function(){var n={};return this.forEach(function(e,t){n[e]=t}),n},get size(){return this.content.length>>1}};dn.from=function(n){if(n instanceof dn)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new dn(e)};function ax(n,e,t){for(let r=0;;r++){if(r==n.childCount||r==e.childCount)return n.childCount==e.childCount?null:t;let i=n.child(r),o=e.child(r);if(i==o){t+=i.nodeSize;continue}if(!i.sameMarkup(o))return t;if(i.isText&&i.text!=o.text){for(let s=0;i.text[s]==o.text[s];s++)t++;return t}if(i.content.size||o.content.size){let s=ax(i.content,o.content,t+1);if(s!=null)return s}t+=i.nodeSize}}function lx(n,e,t,r){for(let i=n.childCount,o=e.childCount;;){if(i==0||o==0)return i==o?null:{a:t,b:r};let s=n.child(--i),a=e.child(--o),l=s.nodeSize;if(s==a){t-=l,r-=l;continue}if(!s.sameMarkup(a))return{a:t,b:r};if(s.isText&&s.text!=a.text){let c=0,d=Math.min(s.text.length,a.text.length);for(;c<d&&s.text[s.text.length-c-1]==a.text[a.text.length-c-1];)c++,t--,r--;return{a:t,b:r}}if(s.content.size||a.content.size){let c=lx(s.content,a.content,t-1,r-1);if(c)return c}t-=l,r-=l}}class ie{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,t,r,i=0,o){for(let s=0,a=0;a<t;s++){let l=this.content[s],c=a+l.nodeSize;if(c>e&&r(l,i+a,o||null,s)!==!1&&l.content.size){let d=a+1;l.nodesBetween(Math.max(0,e-d),Math.min(l.content.size,t-d),r,i+d)}a=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,i){let o="",s=!0;return this.nodesBetween(e,t,(a,l)=>{let c=a.isText?a.text.slice(Math.max(e,l)-l,t-l):a.isLeaf?i?typeof i=="function"?i(a):i:a.type.spec.leafText?a.type.spec.leafText(a):"":"";a.isBlock&&(a.isLeaf&&c||a.isTextblock)&&r&&(s?s=!1:o+=r),o+=c},0),o}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,i=this.content.slice(),o=0;for(t.isText&&t.sameMarkup(r)&&(i[i.length-1]=t.withText(t.text+r.text),o=1);o<e.content.length;o++)i.push(e.content[o]);return new ie(i,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let r=[],i=0;if(t>e)for(let o=0,s=0;s<t;o++){let a=this.content[o],l=s+a.nodeSize;l>e&&((s<e||l>t)&&(a.isText?a=a.cut(Math.max(0,e-s),Math.min(a.text.length,t-s)):a=a.cut(Math.max(0,e-s-1),Math.min(a.content.size,t-s-1))),r.push(a),i+=a.nodeSize),s=l}return new ie(r,i)}cutByIndex(e,t){return e==t?ie.empty:e==0&&t==this.content.length?this:new ie(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let i=this.content.slice(),o=this.size+t.nodeSize-r.nodeSize;return i[e]=t,new ie(i,o)}addToStart(e){return new ie([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new ie(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,r=0;t<this.content.length;t++){let i=this.content[t];e(i,r,t),r+=i.nodeSize}}findDiffStart(e,t=0){return ax(this,e,t)}findDiffEnd(e,t=this.size,r=e.size){return lx(this,e,t,r)}findIndex(e){if(e==0)return Lc(0,e);if(e==this.size)return Lc(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,r=0;;t++){let i=this.child(t),o=r+i.nodeSize;if(o>=e)return o==e?Lc(t+1,o):Lc(t,r);r=o}}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 ie.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new ie(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return ie.empty;let t,r=0;for(let i=0;i<e.length;i++){let o=e[i];r+=o.nodeSize,i&&o.isText&&e[i-1].sameMarkup(o)?(t||(t=e.slice(0,i)),t[t.length-1]=o.withText(t[t.length-1].text+o.text)):t&&t.push(o)}return new ie(t||e,r)}static from(e){if(!e)return ie.empty;if(e instanceof ie)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new ie([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}ie.empty=new ie([],0);const Gf={index:0,offset:0};function Lc(n,e){return Gf.index=n,Gf.offset=e,Gf}function Fd(n,e){if(n===e)return!0;if(!(n&&typeof n=="object")||!(e&&typeof e=="object"))return!1;let t=Array.isArray(n);if(Array.isArray(e)!=t)return!1;if(t){if(n.length!=e.length)return!1;for(let r=0;r<n.length;r++)if(!Fd(n[r],e[r]))return!1}else{for(let r in n)if(!(r in e)||!Fd(n[r],e[r]))return!1;for(let r in e)if(!(r in n))return!1}return!0}let wt=class mp{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,r=!1;for(let i=0;i<e.length;i++){let o=e[i];if(this.eq(o))return e;if(this.type.excludes(o.type))t||(t=e.slice(0,i));else{if(o.type.excludes(this.type))return e;!r&&o.type.rank>this.type.rank&&(t||(t=e.slice(0,i)),t.push(this),r=!0),t&&t.push(o)}}return t||(t=e.slice()),r||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&&Fd(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 r=e.marks[t.type];if(!r)throw new RangeError(`There is no mark type ${t.type} in this schema`);let i=r.create(t.attrs);return r.checkAttrs(i.attrs),i}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(t[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return mp.none;if(e instanceof mp)return[e];let t=e.slice();return t.sort((r,i)=>r.type.rank-i.type.rank),t}};wt.none=[];class Vd extends Error{}class ye{constructor(e,t,r){this.content=e,this.openStart=t,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let r=dx(this.content,e+this.openStart,t);return r&&new ye(r,this.openStart,this.openEnd)}removeBetween(e,t){return new ye(cx(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 ye.empty;let r=t.openStart||0,i=t.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new ye(ie.fromJSON(e,t.content),r,i)}static maxOpen(e,t=!0){let r=0,i=0;for(let o=e.firstChild;o&&!o.isLeaf&&(t||!o.type.spec.isolating);o=o.firstChild)r++;for(let o=e.lastChild;o&&!o.isLeaf&&(t||!o.type.spec.isolating);o=o.lastChild)i++;return new ye(e,r,i)}}ye.empty=new ye(ie.empty,0,0);function cx(n,e,t){let{index:r,offset:i}=n.findIndex(e),o=n.maybeChild(r),{index:s,offset:a}=n.findIndex(t);if(i==e||o.isText){if(a!=t&&!n.child(s).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=s)throw new RangeError("Removing non-flat range");return n.replaceChild(r,o.copy(cx(o.content,e-i-1,t-i-1)))}function dx(n,e,t,r){let{index:i,offset:o}=n.findIndex(e),s=n.maybeChild(i);if(o==e||s.isText)return r&&!r.canReplace(i,i,t)?null:n.cut(0,e).append(t).append(n.cut(e));let a=dx(s.content,e-o-1,t,s);return a&&n.replaceChild(i,s.copy(a))}function wA(n,e,t){if(t.openStart>n.depth)throw new Vd("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new Vd("Inconsistent open depths");return ux(n,e,t,0)}function ux(n,e,t,r){let i=n.index(r),o=n.node(r);if(i==e.index(r)&&r<n.depth-t.openStart){let s=ux(n,e,t,r+1);return o.copy(o.content.replaceChild(i,s))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==r&&e.depth==r){let s=n.parent,a=s.content;return ns(s,a.cut(0,n.parentOffset).append(t.content).append(a.cut(e.parentOffset)))}else{let{start:s,end:a}=xA(t,n);return ns(o,hx(n,s,a,e,r))}else return ns(o,Hd(n,e,r))}function fx(n,e){if(!e.type.compatibleContent(n.type))throw new Vd("Cannot join "+e.type.name+" onto "+n.type.name)}function gp(n,e,t){let r=n.node(t);return fx(r,e.node(t)),r}function ts(n,e){let t=e.length-1;t>=0&&n.isText&&n.sameMarkup(e[t])?e[t]=n.withText(e[t].text+n.text):e.push(n)}function al(n,e,t,r){let i=(e||n).node(t),o=0,s=e?e.index(t):i.childCount;n&&(o=n.index(t),n.depth>t?o++:n.textOffset&&(ts(n.nodeAfter,r),o++));for(let a=o;a<s;a++)ts(i.child(a),r);e&&e.depth==t&&e.textOffset&&ts(e.nodeBefore,r)}function ns(n,e){return n.type.checkContent(e),n.copy(e)}function hx(n,e,t,r,i){let o=n.depth>i&&gp(n,e,i+1),s=r.depth>i&&gp(t,r,i+1),a=[];return al(null,n,i,a),o&&s&&e.index(i)==t.index(i)?(fx(o,s),ts(ns(o,hx(n,e,t,r,i+1)),a)):(o&&ts(ns(o,Hd(n,e,i+1)),a),al(e,t,i,a),s&&ts(ns(s,Hd(t,r,i+1)),a)),al(r,null,i,a),new ie(a)}function Hd(n,e,t){let r=[];if(al(null,n,t,r),n.depth>t){let i=gp(n,e,t+1);ts(ns(i,Hd(n,e,t+1)),r)}return al(e,null,t,r),new ie(r)}function xA(n,e){let t=e.depth-n.openStart,i=e.node(t).copy(n.content);for(let o=t-1;o>=0;o--)i=e.node(o).copy(ie.from(i));return{start:i.resolveNoCache(n.openStart+t),end:i.resolveNoCache(i.content.size-n.openEnd-t)}}class Nl{constructor(e,t,r){this.pos=e,this.path=t,this.parentOffset=r,this.depth=t.length/3-1}resolveDepth(e){return e==null?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[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].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 r=this.pos-this.path[this.path.length-1],i=e.child(t);return r?e.child(t).cut(r):i}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):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let r=this.path[t*3],i=t==0?0:this.path[t*3-1]+1;for(let o=0;o<e;o++)i+=r.child(o).nodeSize;return i}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return wt.none;if(this.textOffset)return e.child(t).marks;let r=e.maybeChild(t-1),i=e.maybeChild(t);if(!r){let a=r;r=i,i=a}let o=r.marks;for(var s=0;s<o.length;s++)o[s].type.spec.inclusive===!1&&(!i||!o[s].isInSet(i.marks))&&(o=o[s--].removeFromSet(o));return o}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let r=t.marks,i=e.parent.maybeChild(e.index());for(var o=0;o<r.length;o++)r[o].type.spec.inclusive===!1&&(!i||!r[o].isInSet(i.marks))&&(r=r[o--].removeFromSet(r));return r}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 r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!t||t(this.node(r))))return new Ud(this,e,r);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 r=[],i=0,o=t;for(let s=e;;){let{index:a,offset:l}=s.content.findIndex(o),c=o-l;if(r.push(s,a,i+l),!c||(s=s.child(a),s.isText))break;o=c-1,i+=l+1}return new Nl(t,r,o)}static resolveCached(e,t){let r=ry.get(e);if(r)for(let o=0;o<r.elts.length;o++){let s=r.elts[o];if(s.pos==t)return s}else ry.set(e,r=new kA);let i=r.elts[r.i]=Nl.resolve(e,t);return r.i=(r.i+1)%_A,i}}class kA{constructor(){this.elts=[],this.i=0}}const _A=12,ry=new WeakMap;class Ud{constructor(e,t,r){this.$from=e,this.$to=t,this.depth=r}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 SA=Object.create(null);let po=class vp{constructor(e,t,r,i=wt.none){this.type=e,this.attrs=t,this.marks=i,this.content=r||ie.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,r,i=0){this.content.nodesBetween(e,t,r,i,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,r,i){return this.content.textBetween(e,t,r,i)}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,r){return this.type==e&&Fd(this.attrs,t||e.defaultAttrs||SA)&&wt.sameSet(this.marks,r||wt.none)}copy(e=null){return e==this.content?this:new vp(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new vp(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,r=!1){if(e==t)return ye.empty;let i=this.resolve(e),o=this.resolve(t),s=r?0:i.sharedDepth(t),a=i.start(s),c=i.node(s).content.cut(i.pos-a,o.pos-a);return new ye(c,i.depth-s,o.depth-s)}replace(e,t,r){return wA(this.resolve(e),this.resolve(t),r)}nodeAt(e){for(let t=this;;){let{index:r,offset:i}=t.content.findIndex(e);if(t=t.maybeChild(r),!t)return null;if(i==e||t.isText)return t;e-=i+1}}childAfter(e){let{index:t,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(t),index:t,offset:r};let i=this.content.child(t-1);return{node:i,index:t-1,offset:r-i.nodeSize}}resolve(e){return Nl.resolveCached(this,e)}resolveNoCache(e){return Nl.resolve(this,e)}rangeHasMark(e,t,r){let i=!1;return t>e&&this.nodesBetween(e,t,o=>(r.isInSet(o.marks)&&(i=!0),!i)),i}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()+")"),px(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,r=ie.empty,i=0,o=r.childCount){let s=this.contentMatchAt(e).matchFragment(r,i,o),a=s&&s.matchFragment(this.content,t);if(!a||!a.validEnd)return!1;for(let l=i;l<o;l++)if(!this.type.allowsMarks(r.child(l).marks))return!1;return!0}canReplaceWith(e,t,r,i){if(i&&!this.type.allowsMarks(i))return!1;let o=this.contentMatchAt(e).matchType(r),s=o&&o.matchFragment(this.content,t);return s?s.validEnd:!1}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=wt.none;for(let t=0;t<this.marks.length;t++){let r=this.marks[t];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!wt.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(t=>t.type.name)}`);this.content.forEach(t=>t.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(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let r;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,r)}let i=ie.fromJSON(e,t.content),o=e.nodeType(t.type).create(t.attrs,i,r);return o.type.checkAttrs(o.attrs),o}};po.prototype.text=void 0;class jd extends po{constructor(e,t,r,i){if(super(e,t,null,i),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):px(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 jd(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new jd(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return e==0&&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 px(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class ms{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new CA(e,t);if(r.next==null)return ms.empty;let i=mx(r);r.next&&r.err("Unexpected trailing text");let o=RA(DA(i));return NA(o,r),o}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,r=e.childCount){let i=this;for(let o=t;i&&o<r;o++)i=i.matchType(e.child(o).type);return i}get inlineContent(){return this.next.length!=0&&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 r=0;r<e.next.length;r++)if(this.next[t].type==e.next[r].type)return!0;return!1}fillBefore(e,t=!1,r=0){let i=[this];function o(s,a){let l=s.matchFragment(e,r);if(l&&(!t||l.validEnd))return ie.from(a.map(c=>c.createAndFill()));for(let c=0;c<s.next.length;c++){let{type:d,next:u}=s.next[c];if(!(d.isText||d.hasRequiredAttrs())&&i.indexOf(u)==-1){i.push(u);let h=o(u,a.concat(d));if(h)return h}}return null}return o(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let i=r.shift(),o=i.match;if(o.matchType(e)){let s=[];for(let a=i;a.type;a=a.via)s.push(a.type);return s.reverse()}for(let s=0;s<o.next.length;s++){let{type:a,next:l}=o.next[s];!a.isLeaf&&!a.hasRequiredAttrs()&&!(a.name in t)&&(!i.type||l.validEnd)&&(r.push({match:a.contentMatch,type:a,via:i}),t[a.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=[];function t(r){e.push(r);for(let i=0;i<r.next.length;i++)e.indexOf(r.next[i].next)==-1&&t(r.next[i].next)}return t(this),e.map((r,i)=>{let o=i+(r.validEnd?"*":" ")+" ";for(let s=0;s<r.next.length;s++)o+=(s?", ":"")+r.next[s].type.name+"->"+e.indexOf(r.next[s].next);return o}).join(`
|
|
3
|
-
`)}}ms.empty=new ms(!0);class CA{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 mx(n){let e=[];do e.push(TA(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function TA(n){let e=[];do e.push(AA(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function AA(n){let e=OA(n);for(;;)if(n.eat("+"))e={type:"plus",expr:e};else if(n.eat("*"))e={type:"star",expr:e};else if(n.eat("?"))e={type:"opt",expr:e};else if(n.eat("{"))e=EA(n,e);else break;return e}function iy(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function EA(n,e){let t=iy(n),r=t;return n.eat(",")&&(n.next!="}"?r=iy(n):r=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:r,expr:e}}function MA(n,e){let t=n.nodeTypes,r=t[e];if(r)return[r];let i=[];for(let o in t){let s=t[o];s.isInGroup(e)&&i.push(s)}return i.length==0&&n.err("No node type or group '"+e+"' found"),i}function OA(n){if(n.eat("(")){let e=mx(n);return n.eat(")")||n.err("Missing closing paren"),e}else if(/\W/.test(n.next))n.err("Unexpected token '"+n.next+"'");else{let e=MA(n,n.next).map(t=>(n.inline==null?n.inline=t.isInline:n.inline!=t.isInline&&n.err("Mixing inline and block content"),{type:"name",value:t}));return n.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function DA(n){let e=[[]];return i(o(n,0),t()),e;function t(){return e.push([])-1}function r(s,a,l){let c={term:l,to:a};return e[s].push(c),c}function i(s,a){s.forEach(l=>l.to=a)}function o(s,a){if(s.type=="choice")return s.exprs.reduce((l,c)=>l.concat(o(c,a)),[]);if(s.type=="seq")for(let l=0;;l++){let c=o(s.exprs[l],a);if(l==s.exprs.length-1)return c;i(c,a=t())}else if(s.type=="star"){let l=t();return r(a,l),i(o(s.expr,l),l),[r(l)]}else if(s.type=="plus"){let l=t();return i(o(s.expr,a),l),i(o(s.expr,l),l),[r(l)]}else{if(s.type=="opt")return[r(a)].concat(o(s.expr,a));if(s.type=="range"){let l=a;for(let c=0;c<s.min;c++){let d=t();i(o(s.expr,l),d),l=d}if(s.max==-1)i(o(s.expr,l),l);else for(let c=s.min;c<s.max;c++){let d=t();r(l,d),i(o(s.expr,l),d),l=d}return[r(l)]}else{if(s.type=="name")return[r(a,void 0,s.value)];throw new Error("Unknown expr type")}}}}function gx(n,e){return e-n}function oy(n,e){let t=[];return r(e),t.sort(gx);function r(i){let o=n[i];if(o.length==1&&!o[0].term)return r(o[0].to);t.push(i);for(let s=0;s<o.length;s++){let{term:a,to:l}=o[s];!a&&t.indexOf(l)==-1&&r(l)}}}function RA(n){let e=Object.create(null);return t(oy(n,0));function t(r){let i=[];r.forEach(s=>{n[s].forEach(({term:a,to:l})=>{if(!a)return;let c;for(let d=0;d<i.length;d++)i[d][0]==a&&(c=i[d][1]);oy(n,l).forEach(d=>{c||i.push([a,c=[]]),c.indexOf(d)==-1&&c.push(d)})})});let o=e[r.join(",")]=new ms(r.indexOf(n.length-1)>-1);for(let s=0;s<i.length;s++){let a=i[s][1].sort(gx);o.next.push({type:i[s][0],next:e[a.join(",")]||t(a)})}return o}}function NA(n,e){for(let t=0,r=[n];t<r.length;t++){let i=r[t],o=!i.validEnd,s=[];for(let a=0;a<i.next.length;a++){let{type:l,next:c}=i.next[a];s.push(l.name),o&&!(l.isText||l.hasRequiredAttrs())&&(o=!1),r.indexOf(c)==-1&&r.push(c)}o&&e.err("Only non-generatable nodes ("+s.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function vx(n){let e=Object.create(null);for(let t in n){let r=n[t];if(!r.hasDefault)return null;e[t]=r.default}return e}function yx(n,e){let t=Object.create(null);for(let r in n){let i=e&&e[r];if(i===void 0){let o=n[r];if(o.hasDefault)i=o.default;else throw new RangeError("No value supplied for attribute "+r)}t[r]=i}return t}function bx(n,e,t,r){for(let i in e)if(!(i in n))throw new RangeError(`Unsupported attribute ${i} for ${t} of type ${i}`);for(let i in n){let o=n[i];o.validate&&o.validate(e[i])}}function wx(n,e){let t=Object.create(null);if(e)for(let r in e)t[r]=new PA(n,r,e[r]);return t}let sy=class xx{constructor(e,t,r){this.name=e,this.schema=t,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=wx(e,r.attrs),this.defaultAttrs=vx(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(r.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==ms.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:yx(this.attrs,e)}create(e=null,t,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new po(this,this.computeAttrs(e),ie.from(t),wt.setFrom(r))}createChecked(e=null,t,r){return t=ie.from(t),this.checkContent(t),new po(this,this.computeAttrs(e),t,wt.setFrom(r))}createAndFill(e=null,t,r){if(e=this.computeAttrs(e),t=ie.from(t),t.size){let s=this.contentMatch.fillBefore(t);if(!s)return null;t=s.append(t)}let i=this.contentMatch.matchFragment(t),o=i&&i.fillBefore(ie.empty,!0);return o?new po(this,e,t.append(o),wt.setFrom(r)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).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){bx(this.attrs,e,"node",this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?t&&t.push(e[r]):t||(t=e.slice(0,r));return t?t.length?t:wt.none:e}static compile(e,t){let r=Object.create(null);e.forEach((o,s)=>r[o]=new xx(o,t,s));let i=t.spec.topNode||"doc";if(!r[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let o in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function IA(n,e,t){let r=t.split("|");return i=>{let o=i===null?"null":typeof i;if(r.indexOf(o)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${n}, got ${o}`)}}class PA{constructor(e,t,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?IA(e,t,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class tf{constructor(e,t,r,i){this.name=e,this.rank=t,this.schema=r,this.spec=i,this.attrs=wx(e,i.attrs),this.excluded=null;let o=vx(this.attrs);this.instance=o?new wt(this,o):null}create(e=null){return!e&&this.instance?this.instance:new wt(this,yx(this.attrs,e))}static compile(e,t){let r=Object.create(null),i=0;return e.forEach((o,s)=>r[o]=new tf(o,i++,t,s)),r}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){bx(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}let kx=class{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let i in e)t[i]=e[i];t.nodes=dn.from(e.nodes),t.marks=dn.from(e.marks||{}),this.nodes=sy.compile(this.spec.nodes,this),this.marks=tf.compile(this.spec.marks,this);let r=Object.create(null);for(let i in this.nodes){if(i in this.marks)throw new RangeError(i+" can not be both a node and a mark");let o=this.nodes[i],s=o.spec.content||"",a=o.spec.marks;if(o.contentMatch=r[s]||(r[s]=ms.parse(s,this.nodes)),o.inlineContent=o.contentMatch.inlineContent,o.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!o.isInline||!o.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=o}o.markSet=a=="_"?null:a?ay(this,a.split(" ")):a==""||!o.inlineContent?[]:null}for(let i in this.marks){let o=this.marks[i],s=o.spec.excludes;o.excluded=s==null?[o]:s==""?[]:ay(this,s.split(" "))}this.nodeFromJSON=i=>po.fromJSON(this,i),this.markFromJSON=i=>wt.fromJSON(this,i),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,r,i){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof sy){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(t,r,i)}text(e,t){let r=this.nodes.text;return new jd(r,r.defaultAttrs,e,wt.setFrom(t))}mark(e,t){return typeof e=="string"&&(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 ay(n,e){let t=[];for(let r=0;r<e.length;r++){let i=e[r],o=n.marks[i],s=o;if(o)t.push(o);else for(let a in n.marks){let l=n.marks[a];(i=="_"||l.spec.group&&l.spec.group.split(" ").indexOf(i)>-1)&&t.push(s=l)}if(!s)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return t}function LA(n){return n.tag!=null}function zA(n){return n.style!=null}let ll=class yp{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let r=this.matchedStyles=[];t.forEach(i=>{if(LA(i))this.tags.push(i);else if(zA(i)){let o=/[^=]*/.exec(i.style)[0];r.indexOf(o)<0&&r.push(o),this.styles.push(i)}}),this.normalizeLists=!this.tags.some(i=>{if(!/^(ul|ol)\b/.test(i.tag)||!i.node)return!1;let o=e.nodes[i.node];return o.contentMatch.matchType(o)})}parse(e,t={}){let r=new cy(this,t,!1);return r.addAll(e,wt.none,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new cy(this,t,!0);return r.addAll(e,wt.none,t.from,t.to),ye.maxOpen(r.finish())}matchTag(e,t,r){for(let i=r?this.tags.indexOf(r)+1:0;i<this.tags.length;i++){let o=this.tags[i];if(VA(e,o.tag)&&(o.namespace===void 0||e.namespaceURI==o.namespace)&&(!o.context||t.matchesContext(o.context))){if(o.getAttrs){let s=o.getAttrs(e);if(s===!1)continue;o.attrs=s||void 0}return o}}}matchStyle(e,t,r,i){for(let o=i?this.styles.indexOf(i)+1:0;o<this.styles.length;o++){let s=this.styles[o],a=s.style;if(!(a.indexOf(e)!=0||s.context&&!r.matchesContext(s.context)||a.length>e.length&&(a.charCodeAt(e.length)!=61||a.slice(e.length+1)!=t))){if(s.getAttrs){let l=s.getAttrs(t);if(l===!1)continue;s.attrs=l||void 0}return s}}}static schemaRules(e){let t=[];function r(i){let o=i.priority==null?50:i.priority,s=0;for(;s<t.length;s++){let a=t[s];if((a.priority==null?50:a.priority)<o)break}t.splice(s,0,i)}for(let i in e.marks){let o=e.marks[i].spec.parseDOM;o&&o.forEach(s=>{r(s=dy(s)),s.mark||s.ignore||s.clearMark||(s.mark=i)})}for(let i in e.nodes){let o=e.nodes[i].spec.parseDOM;o&&o.forEach(s=>{r(s=dy(s)),s.node||s.ignore||s.mark||(s.node=i)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new yp(e,yp.schemaRules(e)))}};const _x={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},BA={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Sx={ol:!0,ul:!0},Il=1,bp=2,cl=4;function ly(n,e,t){return e!=null?(e?Il:0)|(e==="full"?bp:0):n&&n.whitespace=="pre"?Il|bp:t&~cl}class zc{constructor(e,t,r,i,o,s){this.type=e,this.attrs=t,this.marks=r,this.solid=i,this.options=s,this.content=[],this.activeMarks=wt.none,this.match=o||(s&cl?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(ie.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let r=this.type.contentMatch,i;return(i=r.findWrapping(e.type))?(this.match=r,i):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Il)){let r=this.content[this.content.length-1],i;if(r&&r.isText&&(i=/[ \t\r\n\u000c]+$/.exec(r.text))){let o=r;r.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=o.withText(o.text.slice(0,o.text.length-i[0].length))}}let t=ie.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(ie.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&&!_x.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class cy{constructor(e,t,r){this.parser=e,this.options=t,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let i=t.topNode,o,s=ly(null,t.preserveWhitespace,0)|(r?cl:0);i?o=new zc(i.type,i.attrs,wt.none,!0,t.topMatch||i.type.contentMatch,s):r?o=new zc(null,null,wt.none,!0,null,s):o=new zc(e.schema.topNodeType,null,wt.none,!0,null,s),this.nodes=[o],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let r=e.nodeValue,i=this.top,o=i.options&bp?"full":this.localPreserveWS||(i.options&Il)>0,{schema:s}=this.parser;if(o==="full"||i.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(o)if(o==="full")r=r.replace(/\r\n?/g,`
|
|
4
|
-
`);else if(s.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(s.linebreakReplacement.create())){let a=r.split(/\r?\n|\r/);for(let l=0;l<a.length;l++)l&&this.insertNode(s.linebreakReplacement.create(),t,!0),a[l]&&this.insertNode(s.text(a[l]),t,!/\S/.test(a[l]));r=""}else r=r.replace(/\r?\n|\r/g," ");else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let a=i.content[i.content.length-1],l=e.previousSibling;(!a||l&&l.nodeName=="BR"||a.isText&&/[ \t\r\n\u000c]$/.test(a.text))&&(r=r.slice(1))}r&&this.insertNode(s.text(r),t,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,t,r){let i=this.localPreserveWS,o=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let s=e.nodeName.toLowerCase(),a;Sx.hasOwnProperty(s)&&this.parser.normalizeLists&&FA(e);let l=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(a=this.parser.matchTag(e,this,r));e:if(l?l.ignore:BA.hasOwnProperty(s))this.findInside(e),this.ignoreFallback(e,t);else if(!l||l.skip||l.closeParent){l&&l.closeParent?this.open=Math.max(0,this.open-1):l&&l.skip.nodeType&&(e=l.skip);let c,d=this.needsBlock;if(_x.hasOwnProperty(s))o.content.length&&o.content[0].isInline&&this.open&&(this.open--,o=this.top),c=!0,o.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}let u=l&&l.skip?t:this.readStyles(e,t);u&&this.addAll(e,u),c&&this.sync(o),this.needsBlock=d}else{let c=this.readStyles(e,t);c&&this.addElementByRule(e,l,c,l.consuming===!1?a:void 0)}this.localPreserveWS=i}leafFallback(e,t){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
|
|
5
|
-
`),t)}ignoreFallback(e,t){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),t,!0)}readStyles(e,t){let r=e.style;if(r&&r.length)for(let i=0;i<this.parser.matchedStyles.length;i++){let o=this.parser.matchedStyles[i],s=r.getPropertyValue(o);if(s)for(let a=void 0;;){let l=this.parser.matchStyle(o,s,this,a);if(!l)break;if(l.ignore)return null;if(l.clearMark?t=t.filter(c=>!l.clearMark(c)):t=t.concat(this.parser.schema.marks[l.mark].create(l.attrs)),l.consuming===!1)a=l;else break}}return t}addElementByRule(e,t,r,i){let o,s;if(t.node)if(s=this.parser.schema.nodes[t.node],s.isLeaf)this.insertNode(s.create(t.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let l=this.enter(s,t.attrs||null,r,t.preserveWhitespace);l&&(o=!0,r=l)}else{let l=this.parser.schema.marks[t.mark];r=r.concat(l.create(t.attrs))}let a=this.top;if(s&&s.isLeaf)this.findInside(e);else if(i)this.addElement(e,r,i);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(l=>this.insertNode(l,r,!1));else{let l=e;typeof t.contentElement=="string"?l=e.querySelector(t.contentElement):typeof t.contentElement=="function"?l=t.contentElement(e):t.contentElement&&(l=t.contentElement),this.findAround(e,l,!0),this.addAll(l,r),this.findAround(e,l,!1)}o&&this.sync(a)&&this.open--}addAll(e,t,r,i){let o=r||0;for(let s=r?e.childNodes[r]:e.firstChild,a=i==null?null:e.childNodes[i];s!=a;s=s.nextSibling,++o)this.findAtPoint(e,o),this.addDOM(s,t);this.findAtPoint(e,o)}findPlace(e,t,r){let i,o;for(let s=this.open,a=0;s>=0;s--){let l=this.nodes[s],c=l.findWrapping(e);if(c&&(!i||i.length>c.length+a)&&(i=c,o=l,!c.length))break;if(l.solid){if(r)break;a+=2}}if(!i)return null;this.sync(o);for(let s=0;s<i.length;s++)t=this.enterInner(i[s],null,t,!1);return t}insertNode(e,t,r){if(e.isInline&&this.needsBlock&&!this.top.type){let o=this.textblockFromContext();o&&(t=this.enterInner(o,null,t))}let i=this.findPlace(e,t,r);if(i){this.closeExtra();let o=this.top;o.match&&(o.match=o.match.matchType(e.type));let s=wt.none;for(let a of i.concat(e.marks))(o.type?o.type.allowsMarkType(a.type):uy(a.type,e.type))&&(s=a.addToSet(s));return o.content.push(e.mark(s)),!0}return!1}enter(e,t,r,i){let o=this.findPlace(e.create(t),r,!1);return o&&(o=this.enterInner(e,t,r,!0,i)),o}enterInner(e,t,r,i=!1,o){this.closeExtra();let s=this.top;s.match=s.match&&s.match.matchType(e);let a=ly(e,o,s.options);s.options&cl&&s.content.length==0&&(a|=cl);let l=wt.none;return r=r.filter(c=>(s.type?s.type.allowsMarkType(c.type):uy(c.type,e))?(l=c.addToSet(l),!1):!0),this.nodes.push(new zc(e,t,l,i,null,a)),this.open++,r}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|=Il)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let r=this.nodes[t].content;for(let i=r.length-1;i>=0;i--)e+=r[i].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==t&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,r){if(e!=t&&this.find)for(let i=0;i<this.find.length;i++)this.find[i].pos==null&&e.nodeType==1&&e.contains(this.find[i].node)&&t.compareDocumentPosition(this.find[i].node)&(r?2:4)&&(this.find[i].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("/"),r=this.options.context,i=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),o=-(r?r.depth+1:0)+(i?0:1),s=(a,l)=>{for(;a>=0;a--){let c=t[a];if(c==""){if(a==t.length-1||a==0)continue;for(;l>=o;l--)if(s(a-1,l))return!0;return!1}else{let d=l>0||l==0&&i?this.nodes[l].type:r&&l>=o?r.node(l-o).type:null;if(!d||d.name!=c&&!d.isInGroup(c))return!1;l--}}return!0};return s(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let r=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let t in this.parser.schema.nodes){let r=this.parser.schema.nodes[t];if(r.isTextblock&&r.defaultAttrs)return r}}}function FA(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Sx.hasOwnProperty(r)&&t?(t.appendChild(e),e=t):r=="li"?t=e:r&&(t=null)}}function VA(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function dy(n){let e={};for(let t in n)e[t]=n[t];return e}function uy(n,e){let t=e.schema.nodes;for(let r in t){let i=t[r];if(!i.allowsMarkType(n))continue;let o=[],s=a=>{o.push(a);for(let l=0;l<a.edgeCount;l++){let{type:c,next:d}=a.edge(l);if(c==e||o.indexOf(d)<0&&s(d))return!0}};if(s(i.contentMatch))return!0}}class Os{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},r){r||(r=Zf(t).createDocumentFragment());let i=r,o=[];return e.forEach(s=>{if(o.length||s.marks.length){let a=0,l=0;for(;a<o.length&&l<s.marks.length;){let c=s.marks[l];if(!this.marks[c.type.name]){l++;continue}if(!c.eq(o[a][0])||c.type.spec.spanning===!1)break;a++,l++}for(;a<o.length;)i=o.pop()[1];for(;l<s.marks.length;){let c=s.marks[l++],d=this.serializeMark(c,s.isInline,t);d&&(o.push([c,i]),i.appendChild(d.dom),i=d.contentDOM||d.dom)}}i.appendChild(this.serializeNodeInner(s,t))}),r}serializeNodeInner(e,t){let{dom:r,contentDOM:i}=fd(Zf(t),this.nodes[e.type.name](e),null,e.attrs);if(i){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,i)}return r}serializeNode(e,t={}){let r=this.serializeNodeInner(e,t);for(let i=e.marks.length-1;i>=0;i--){let o=this.serializeMark(e.marks[i],e.isInline,t);o&&((o.contentDOM||o.dom).appendChild(r),r=o.dom)}return r}serializeMark(e,t,r={}){let i=this.marks[e.type.name];return i&&fd(Zf(r),i(e,t),null,e.attrs)}static renderSpec(e,t,r=null,i){return fd(e,t,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Os(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=fy(e.nodes);return t.text||(t.text=r=>r.text),t}static marksFromSchema(e){return fy(e.marks)}}function fy(n){let e={};for(let t in n){let r=n[t].spec.toDOM;r&&(e[t]=r)}return e}function Zf(n){return n.document||window.document}const hy=new WeakMap;function HA(n){let e=hy.get(n);return e===void 0&&hy.set(n,e=UA(n)),e}function UA(n){let e=null;function t(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let i=0;i<r.length;i++)t(r[i]);else for(let i in r)t(r[i])}return t(n),e}function fd(n,e,t,r){if(typeof e=="string")return{dom:n.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let i=e[0],o;if(typeof i!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(o=HA(r))&&o.indexOf(e)>-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 s=i.indexOf(" ");s>0&&(t=i.slice(0,s),i=i.slice(s+1));let a,l=t?n.createElementNS(t,i):n.createElement(i),c=e[1],d=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){d=2;for(let u in c)if(c[u]!=null){let h=u.indexOf(" ");h>0?l.setAttributeNS(u.slice(0,h),u.slice(h+1),c[u]):u=="style"&&l.style?l.style.cssText=c[u]:l.setAttribute(u,c[u])}}for(let u=d;u<e.length;u++){let h=e[u];if(h===0){if(u<e.length-1||u>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:l,contentDOM:l}}else{let{dom:p,contentDOM:m}=fd(n,h,t,r);if(l.appendChild(p),m){if(a)throw new RangeError("Multiple content holes");a=m}}}return{dom:l,contentDOM:a}}const Cx=65535,Tx=Math.pow(2,16);function jA(n,e){return n+e*Tx}function py(n){return n&Cx}function WA(n){return(n-(n&Cx))/Tx}const Ax=1,Ex=2,hd=4,Mx=8;class wp{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&Mx)>0}get deletedBefore(){return(this.delInfo&(Ax|hd))>0}get deletedAfter(){return(this.delInfo&(Ex|hd))>0}get deletedAcross(){return(this.delInfo&hd)>0}}class $n{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&$n.empty)return $n.empty}recover(e){let t=0,r=py(e);if(!this.inverted)for(let i=0;i<r;i++)t+=this.ranges[i*3+2]-this.ranges[i*3+1];return this.ranges[r*3]+t+WA(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,r){let i=0,o=this.inverted?2:1,s=this.inverted?1:2;for(let a=0;a<this.ranges.length;a+=3){let l=this.ranges[a]-(this.inverted?i:0);if(l>e)break;let c=this.ranges[a+o],d=this.ranges[a+s],u=l+c;if(e<=u){let h=c?e==l?-1:e==u?1:t:t,p=l+i+(h<0?0:d);if(r)return p;let m=e==(t<0?l:u)?null:jA(a/3,e-l),v=e==l?Ex:e==u?Ax:hd;return(t<0?e!=l:e!=u)&&(v|=Mx),new wp(p,v,m)}i+=d-c}return r?e+i:new wp(e+i,0,null)}touches(e,t){let r=0,i=py(t),o=this.inverted?2:1,s=this.inverted?1:2;for(let a=0;a<this.ranges.length;a+=3){let l=this.ranges[a]-(this.inverted?r:0);if(l>e)break;let c=this.ranges[a+o],d=l+c;if(e<=d&&a==i*3)return!0;r+=this.ranges[a+s]-c}return!1}forEach(e){let t=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,o=0;i<this.ranges.length;i+=3){let s=this.ranges[i],a=s-(this.inverted?o:0),l=s+(this.inverted?0:o),c=this.ranges[i+t],d=this.ranges[i+r];e(a,a+c,l,l+d),o+=d-c}}invert(){return new $n(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?$n.empty:new $n(e<0?[0,-e,0]:[0,0,e])}}$n.empty=new $n([]);class Pl{constructor(e,t,r=0,i=e?e.length:0){this.mirror=t,this.from=r,this.to=i,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new Pl(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),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,r=this._maps.length;t<e._maps.length;t++){let i=e.getMirror(t);this.appendMap(e._maps[t],i!=null&&i<t?r+i: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,r=this._maps.length+e._maps.length;t>=0;t--){let i=e.getMirror(t);this.appendMap(e._maps[t].invert(),i!=null&&i>t?r-i-1:void 0)}}invert(){let e=new Pl;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,r){let i=0;for(let o=this.from;o<this.to;o++){let s=this._maps[o],a=s.mapResult(e,t);if(a.recover!=null){let l=this.getMirror(o);if(l!=null&&l>o&&l<this.to){o=l,e=this._maps[l].recover(a.recover);continue}}i|=a.delInfo,e=a.pos}return r?e:new wp(e,i,null)}}const Xf=Object.create(null);class An{getMap(){return $n.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=Xf[t.stepType];if(!r)throw new RangeError(`No step type ${t.stepType} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in Xf)throw new RangeError("Duplicate use of step JSON ID "+e);return Xf[e]=t,t.prototype.jsonID=e,t}}class jt{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new jt(e,null)}static fail(e){return new jt(null,e)}static fromReplace(e,t,r,i){try{return jt.ok(e.replace(t,r,i))}catch(o){if(o instanceof Vd)return jt.fail(o.message);throw o}}}function jm(n,e,t){let r=[];for(let i=0;i<n.childCount;i++){let o=n.child(i);o.content.size&&(o=o.copy(jm(o.content,e,o))),o.isInline&&(o=e(o,t,i)),r.push(o)}return ie.fromArray(r)}class so extends An{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=e.resolve(this.from),i=r.node(r.sharedDepth(this.to)),o=new ye(jm(t.content,(s,a)=>!s.isAtom||!a.type.allowsMarkType(this.mark.type)?s:s.mark(this.mark.addToSet(s.marks)),i),t.openStart,t.openEnd);return jt.fromReplace(e,this.from,this.to,o)}invert(){return new Qr(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new so(t.pos,r.pos,this.mark)}merge(e){return e instanceof so&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new so(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(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new so(t.from,t.to,e.markFromJSON(t.mark))}}An.jsonID("addMark",so);class Qr extends An{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=new ye(jm(t.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),t.openStart,t.openEnd);return jt.fromReplace(e,this.from,this.to,r)}invert(){return new so(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new Qr(t.pos,r.pos,this.mark)}merge(e){return e instanceof Qr&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Qr(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(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new Qr(t.from,t.to,e.markFromJSON(t.mark))}}An.jsonID("removeMark",Qr);class ao extends An{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return jt.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return jt.fromReplace(e,this.pos,this.pos+1,new ye(ie.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let r=this.mark.addToSet(t.marks);if(r.length==t.marks.length){for(let i=0;i<t.marks.length;i++)if(!t.marks[i].isInSet(r))return new ao(this.pos,t.marks[i]);return new ao(this.pos,this.mark)}}return new gs(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new ao(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new ao(t.pos,e.markFromJSON(t.mark))}}An.jsonID("addNodeMark",ao);class gs extends An{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return jt.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return jt.fromReplace(e,this.pos,this.pos+1,new ye(ie.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new ao(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new gs(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new gs(t.pos,e.markFromJSON(t.mark))}}An.jsonID("removeNodeMark",gs);class nn extends An{constructor(e,t,r,i=!1){super(),this.from=e,this.to=t,this.slice=r,this.structure=i}apply(e){return this.structure&&xp(e,this.from,this.to)?jt.fail("Structure replace would overwrite content"):jt.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new $n([this.from,this.to-this.from,this.slice.size])}invert(e){return new nn(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deletedAcross&&r.deletedAcross?null:new nn(t.pos,Math.max(t.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof nn)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let t=this.slice.size+e.slice.size==0?ye.empty:new ye(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new nn(this.from,this.to+(e.to-e.from),t,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let t=this.slice.size+e.slice.size==0?ye.empty:new ye(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new nn(e.from,this.to,t,this.structure)}else return null}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(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new nn(t.from,t.to,ye.fromJSON(e,t.slice),!!t.structure)}}An.jsonID("replace",nn);class rn extends An{constructor(e,t,r,i,o,s,a=!1){super(),this.from=e,this.to=t,this.gapFrom=r,this.gapTo=i,this.slice=o,this.insert=s,this.structure=a}apply(e){if(this.structure&&(xp(e,this.from,this.gapFrom)||xp(e,this.gapTo,this.to)))return jt.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return jt.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,t.content);return r?jt.fromReplace(e,this.from,this.to,r):jt.fail("Content does not fit in gap")}getMap(){return new $n([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 rn(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),r=e.mapResult(this.to,-1),i=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),o=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return t.deletedAcross&&r.deletedAcross||i<t.pos||o>r.pos?null:new rn(t.pos,r.pos,i,o,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(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new rn(t.from,t.to,t.gapFrom,t.gapTo,ye.fromJSON(e,t.slice),t.insert,!!t.structure)}}An.jsonID("replaceAround",rn);function xp(n,e,t){let r=n.resolve(e),i=t-e,o=r.depth;for(;i>0&&o>0&&r.indexAfter(o)==r.node(o).childCount;)o--,i--;if(i>0){let s=r.node(o).maybeChild(r.indexAfter(o));for(;i>0;){if(!s||s.isLeaf)return!0;s=s.firstChild,i--}}return!1}function KA(n,e,t,r){let i=[],o=[],s,a;n.doc.nodesBetween(e,t,(l,c,d)=>{if(!l.isInline)return;let u=l.marks;if(!r.isInSet(u)&&d.type.allowsMarkType(r.type)){let h=Math.max(c,e),p=Math.min(c+l.nodeSize,t),m=r.addToSet(u);for(let v=0;v<u.length;v++)u[v].isInSet(m)||(s&&s.to==h&&s.mark.eq(u[v])?s.to=p:i.push(s=new Qr(h,p,u[v])));a&&a.to==h?a.to=p:o.push(a=new so(h,p,r))}}),i.forEach(l=>n.step(l)),o.forEach(l=>n.step(l))}function qA(n,e,t,r){let i=[],o=0;n.doc.nodesBetween(e,t,(s,a)=>{if(!s.isInline)return;o++;let l=null;if(r instanceof tf){let c=s.marks,d;for(;d=r.isInSet(c);)(l||(l=[])).push(d),c=d.removeFromSet(c)}else r?r.isInSet(s.marks)&&(l=[r]):l=s.marks;if(l&&l.length){let c=Math.min(a+s.nodeSize,t);for(let d=0;d<l.length;d++){let u=l[d],h;for(let p=0;p<i.length;p++){let m=i[p];m.step==o-1&&u.eq(i[p].style)&&(h=m)}h?(h.to=c,h.step=o):i.push({style:u,from:Math.max(a,e),to:c,step:o})}}}),i.forEach(s=>n.step(new Qr(s.from,s.to,s.style)))}function Wm(n,e,t,r=t.contentMatch,i=!0){let o=n.doc.nodeAt(e),s=[],a=e+1;for(let l=0;l<o.childCount;l++){let c=o.child(l),d=a+c.nodeSize,u=r.matchType(c.type);if(!u)s.push(new nn(a,d,ye.empty));else{r=u;for(let h=0;h<c.marks.length;h++)t.allowsMarkType(c.marks[h].type)||n.step(new Qr(a,d,c.marks[h]));if(i&&c.isText&&t.whitespace!="pre"){let h,p=/\r?\n|\r/g,m;for(;h=p.exec(c.text);)m||(m=new ye(ie.from(t.schema.text(" ",t.allowedMarks(c.marks))),0,0)),s.push(new nn(a+h.index,a+h.index+h[0].length,m))}}a=d}if(!r.validEnd){let l=r.fillBefore(ie.empty,!0);n.replace(a,a,new ye(l,0,0))}for(let l=s.length-1;l>=0;l--)n.step(s[l])}function JA(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function Ia(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let r=n.depth,i=0,o=0;;--r){let s=n.$from.node(r),a=n.$from.index(r)+i,l=n.$to.indexAfter(r)-o;if(r<n.depth&&s.canReplace(a,l,t))return r;if(r==0||s.type.spec.isolating||!JA(s,a,l))break;a&&(i=1),l<s.childCount&&(o=1)}return null}function YA(n,e,t){let{$from:r,$to:i,depth:o}=e,s=r.before(o+1),a=i.after(o+1),l=s,c=a,d=ie.empty,u=0;for(let m=o,v=!1;m>t;m--)v||r.index(m)>0?(v=!0,d=ie.from(r.node(m).copy(d)),u++):l--;let h=ie.empty,p=0;for(let m=o,v=!1;m>t;m--)v||i.after(m+1)<i.end(m)?(v=!0,h=ie.from(i.node(m).copy(h)),p++):c++;n.step(new rn(l,c,s,a,new ye(d.append(h),u,p),d.size-u,!0))}function Km(n,e,t=null,r=n){let i=GA(n,e),o=i&&ZA(r,e);return o?i.map(my).concat({type:e,attrs:t}).concat(o.map(my)):null}function my(n){return{type:n,attrs:null}}function GA(n,e){let{parent:t,startIndex:r,endIndex:i}=n,o=t.contentMatchAt(r).findWrapping(e);if(!o)return null;let s=o.length?o[0]:e;return t.canReplaceWith(r,i,s)?o:null}function ZA(n,e){let{parent:t,startIndex:r,endIndex:i}=n,o=t.child(r),s=e.contentMatch.findWrapping(o.type);if(!s)return null;let l=(s.length?s[s.length-1]:e).contentMatch;for(let c=r;l&&c<i;c++)l=l.matchType(t.child(c).type);return!l||!l.validEnd?null:s}function XA(n,e,t){let r=ie.empty;for(let s=t.length-1;s>=0;s--){if(r.size){let a=t[s].type.contentMatch.matchFragment(r);if(!a||!a.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=ie.from(t[s].type.create(t[s].attrs,r))}let i=e.start,o=e.end;n.step(new rn(i,o,i,o,new ye(r,0,0),t.length,!0))}function QA(n,e,t,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let o=n.steps.length;n.doc.nodesBetween(e,t,(s,a)=>{let l=typeof i=="function"?i(s):i;if(s.isTextblock&&!s.hasMarkup(r,l)&&$A(n.doc,n.mapping.slice(o).map(a),r)){let c=null;if(r.schema.linebreakReplacement){let p=r.whitespace=="pre",m=!!r.contentMatch.matchType(r.schema.linebreakReplacement);p&&!m?c=!1:!p&&m&&(c=!0)}c===!1&&Dx(n,s,a,o),Wm(n,n.mapping.slice(o).map(a,1),r,void 0,c===null);let d=n.mapping.slice(o),u=d.map(a,1),h=d.map(a+s.nodeSize,1);return n.step(new rn(u,h,u+1,h-1,new ye(ie.from(r.create(l,null,s.marks)),0,0),1,!0)),c===!0&&Ox(n,s,a,o),!1}})}function Ox(n,e,t,r){e.forEach((i,o)=>{if(i.isText){let s,a=/\r?\n|\r/g;for(;s=a.exec(i.text);){let l=n.mapping.slice(r).map(t+1+o+s.index);n.replaceWith(l,l+1,e.type.schema.linebreakReplacement.create())}}})}function Dx(n,e,t,r){e.forEach((i,o)=>{if(i.type==i.type.schema.linebreakReplacement){let s=n.mapping.slice(r).map(t+1+o);n.replaceWith(s,s+1,e.type.schema.text(`
|
|
6
|
-
`))}})}function $A(n,e,t){let r=n.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,t)}function eE(n,e,t,r,i){let o=n.doc.nodeAt(e);if(!o)throw new RangeError("No node at given position");t||(t=o.type);let s=t.create(r,null,i||o.marks);if(o.isLeaf)return n.replaceWith(e,e+o.nodeSize,s);if(!t.validContent(o.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new rn(e,e+o.nodeSize,e+1,e+o.nodeSize-1,new ye(ie.from(s),0,0),1,!0))}function Ii(n,e,t=1,r){let i=n.resolve(e),o=i.depth-t,s=r&&r[r.length-1]||i.parent;if(o<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!s.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let c=i.depth-1,d=t-2;c>o;c--,d--){let u=i.node(c),h=i.index(c);if(u.type.spec.isolating)return!1;let p=u.content.cutByIndex(h,u.childCount),m=r&&r[d+1];m&&(p=p.replaceChild(0,m.type.create(m.attrs)));let v=r&&r[d]||u;if(!u.canReplace(h+1,u.childCount)||!v.type.validContent(p))return!1}let a=i.indexAfter(o),l=r&&r[0];return i.node(o).canReplaceWith(a,a,l?l.type:i.node(o+1).type)}function tE(n,e,t=1,r){let i=n.doc.resolve(e),o=ie.empty,s=ie.empty;for(let a=i.depth,l=i.depth-t,c=t-1;a>l;a--,c--){o=ie.from(i.node(a).copy(o));let d=r&&r[c];s=ie.from(d?d.type.create(d.attrs,s):i.node(a).copy(s))}n.step(new nn(e,e,new ye(o.append(s),t,t),!0))}function Mo(n,e){let t=n.resolve(e),r=t.index();return Rx(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(r,r+1)}function nE(n,e){e.content.size||n.type.compatibleContent(e.type);let t=n.contentMatchAt(n.childCount),{linebreakReplacement:r}=n.type.schema;for(let i=0;i<e.childCount;i++){let o=e.child(i),s=o.type==r?n.type.schema.nodes.text:o.type;if(t=t.matchType(s),!t||!n.type.allowsMarks(o.marks))return!1}return t.validEnd}function Rx(n,e){return!!(n&&e&&!n.isLeaf&&nE(n,e))}function nf(n,e,t=-1){let r=n.resolve(e);for(let i=r.depth;;i--){let o,s,a=r.index(i);if(i==r.depth?(o=r.nodeBefore,s=r.nodeAfter):t>0?(o=r.node(i+1),a++,s=r.node(i).maybeChild(a)):(o=r.node(i).maybeChild(a-1),s=r.node(i+1)),o&&!o.isTextblock&&Rx(o,s)&&r.node(i).canReplace(a,a+1))return e;if(i==0)break;e=t<0?r.before(i):r.after(i)}}function rE(n,e,t){let r=null,{linebreakReplacement:i}=n.doc.type.schema,o=n.doc.resolve(e-t),s=o.node().type;if(i&&s.inlineContent){let d=s.whitespace=="pre",u=!!s.contentMatch.matchType(i);d&&!u?r=!1:!d&&u&&(r=!0)}let a=n.steps.length;if(r===!1){let d=n.doc.resolve(e+t);Dx(n,d.node(),d.before(),a)}s.inlineContent&&Wm(n,e+t-1,s,o.node().contentMatchAt(o.index()),r==null);let l=n.mapping.slice(a),c=l.map(e-t);if(n.step(new nn(c,l.map(e+t,-1),ye.empty,!0)),r===!0){let d=n.doc.resolve(c);Ox(n,d.node(),d.before(),n.steps.length)}return n}function iE(n,e,t){let r=n.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),t))return e;if(r.parentOffset==0)for(let i=r.depth-1;i>=0;i--){let o=r.index(i);if(r.node(i).canReplaceWith(o,o,t))return r.before(i+1);if(o>0)return null}if(r.parentOffset==r.parent.content.size)for(let i=r.depth-1;i>=0;i--){let o=r.indexAfter(i);if(r.node(i).canReplaceWith(o,o,t))return r.after(i+1);if(o<r.node(i).childCount)return null}return null}function Nx(n,e,t){let r=n.resolve(e);if(!t.content.size)return e;let i=t.content;for(let o=0;o<t.openStart;o++)i=i.firstChild.content;for(let o=1;o<=(t.openStart==0&&t.size?2:1);o++)for(let s=r.depth;s>=0;s--){let a=s==r.depth?0:r.pos<=(r.start(s+1)+r.end(s+1))/2?-1:1,l=r.index(s)+(a>0?1:0),c=r.node(s),d=!1;if(o==1)d=c.canReplace(l,l,i);else{let u=c.contentMatchAt(l).findWrapping(i.firstChild.type);d=u&&c.canReplaceWith(l,l,u[0])}if(d)return a==0?r.pos:a<0?r.before(s+1):r.after(s+1)}return null}function rf(n,e,t=e,r=ye.empty){if(e==t&&!r.size)return null;let i=n.resolve(e),o=n.resolve(t);return Ix(i,o,r)?new nn(e,t,r):new oE(i,o,r).fit()}function Ix(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}class oE{constructor(e,t,r){this.$from=e,this.$to=t,this.unplaced=r,this.frontier=[],this.placed=ie.empty;for(let i=0;i<=e.depth;i++){let o=e.node(i);this.frontier.push({type:o.type,match:o.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=ie.from(e.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,r=this.$from,i=this.close(e<0?this.$to:r.doc.resolve(e));if(!i)return null;let o=this.placed,s=r.depth,a=i.depth;for(;s&&a&&o.childCount==1;)o=o.firstChild.content,s--,a--;let l=new ye(o,s,a);return e>-1?new rn(r.pos,e,this.$to.pos,this.$to.end(),l,t):l.size||r.pos!=this.$to.pos?new nn(r.pos,i.pos,l):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,r=0,i=this.unplaced.openEnd;r<e;r++){let o=t.firstChild;if(t.childCount>1&&(i=0),o.type.spec.isolating&&i<=r){e=r;break}t=o.content}for(let t=1;t<=2;t++)for(let r=t==1?e:this.unplaced.openStart;r>=0;r--){let i,o=null;r?(o=Qf(this.unplaced.content,r-1).firstChild,i=o.content):i=this.unplaced.content;let s=i.firstChild;for(let a=this.depth;a>=0;a--){let{type:l,match:c}=this.frontier[a],d,u=null;if(t==1&&(s?c.matchType(s.type)||(u=c.fillBefore(ie.from(s),!1)):o&&l.compatibleContent(o.type)))return{sliceDepth:r,frontierDepth:a,parent:o,inject:u};if(t==2&&s&&(d=c.findWrapping(s.type)))return{sliceDepth:r,frontierDepth:a,parent:o,wrap:d};if(o&&c.matchType(o.type))break}}}openMore(){let{content:e,openStart:t,openEnd:r}=this.unplaced,i=Qf(e,t);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new ye(e,t+1,Math.max(r,i.size+t>=e.size-r?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:r}=this.unplaced,i=Qf(e,t);if(i.childCount<=1&&t>0){let o=e.size-t<=t+i.size;this.unplaced=new ye($a(e,t-1,1),t-1,o?t-1:r)}else this.unplaced=new ye($a(e,t,1),t,r)}placeNodes({sliceDepth:e,frontierDepth:t,parent:r,inject:i,wrap:o}){for(;this.depth>t;)this.closeFrontierNode();if(o)for(let v=0;v<o.length;v++)this.openFrontierNode(o[v]);let s=this.unplaced,a=r?r.content:s.content,l=s.openStart-e,c=0,d=[],{match:u,type:h}=this.frontier[t];if(i){for(let v=0;v<i.childCount;v++)d.push(i.child(v));u=u.matchFragment(i)}let p=a.size+e-(s.content.size-s.openEnd);for(;c<a.childCount;){let v=a.child(c),g=u.matchType(v.type);if(!g)break;c++,(c>1||l==0||v.content.size)&&(u=g,d.push(Px(v.mark(h.allowedMarks(v.marks)),c==1?l:0,c==a.childCount?p:-1)))}let m=c==a.childCount;m||(p=-1),this.placed=el(this.placed,t,ie.from(d)),this.frontier[t].match=u,m&&p<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let v=0,g=a;v<p;v++){let y=g.lastChild;this.frontier.push({type:y.type,match:y.contentMatchAt(y.childCount)}),g=y.content}this.unplaced=m?e==0?ye.empty:new ye($a(s.content,e-1,1),e-1,p<0?s.openEnd:e-1):new ye($a(s.content,e,c),s.openStart,s.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!$f(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;let{depth:r}=this.$to,i=this.$to.after(r);for(;r>1&&i==this.$to.end(--r);)++i;return i}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:r,type:i}=this.frontier[t],o=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),s=$f(e,t,i,r,o);if(s){for(let a=t-1;a>=0;a--){let{match:l,type:c}=this.frontier[a],d=$f(e,a,c,l,!0);if(!d||d.childCount)continue e}return{depth:t,fit:s,move:o?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=el(this.placed,t.depth,t.fit)),e=t.move;for(let r=t.depth+1;r<=e.depth;r++){let i=e.node(r),o=i.type.contentMatch.fillBefore(i.content,!0,e.index(r));this.openFrontierNode(i.type,i.attrs,o)}return e}openFrontierNode(e,t=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=el(this.placed,this.depth,ie.from(e.create(t,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(ie.empty,!0);t.childCount&&(this.placed=el(this.placed,this.frontier.length,t))}}function $a(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy($a(n.firstChild.content,e-1,t)))}function el(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(el(n.lastChild.content,e-1,t)))}function Qf(n,e){for(let t=0;t<e;t++)n=n.firstChild.content;return n}function Px(n,e,t){if(e<=0)return n;let r=n.content;return e>1&&(r=r.replaceChild(0,Px(r.firstChild,e-1,r.childCount==1?t-1:0))),e>0&&(r=n.type.contentMatch.fillBefore(r).append(r),t<=0&&(r=r.append(n.type.contentMatch.matchFragment(r).fillBefore(ie.empty,!0)))),n.copy(r)}function $f(n,e,t,r,i){let o=n.node(e),s=i?n.indexAfter(e):n.index(e);if(s==o.childCount&&!t.compatibleContent(o.type))return null;let a=r.fillBefore(o.content,!0,s);return a&&!sE(t,o.content,s)?a:null}function sE(n,e,t){for(let r=t;r<e.childCount;r++)if(!n.allowsMarks(e.child(r).marks))return!0;return!1}function aE(n){return n.spec.defining||n.spec.definingForContent}function lE(n,e,t,r){if(!r.size)return n.deleteRange(e,t);let i=n.doc.resolve(e),o=n.doc.resolve(t);if(Ix(i,o,r))return n.step(new nn(e,t,r));let s=zx(i,o);s[s.length-1]==0&&s.pop();let a=-(i.depth+1);s.unshift(a);for(let h=i.depth,p=i.pos-1;h>0;h--,p--){let m=i.node(h).type.spec;if(m.defining||m.definingAsContext||m.isolating)break;s.indexOf(h)>-1?a=h:i.before(h)==p&&s.splice(1,0,-h)}let l=s.indexOf(a),c=[],d=r.openStart;for(let h=r.content,p=0;;p++){let m=h.firstChild;if(c.push(m),p==r.openStart)break;h=m.content}for(let h=d-1;h>=0;h--){let p=c[h],m=aE(p.type);if(m&&!p.sameMarkup(i.node(Math.abs(a)-1)))d=h;else if(m||!p.type.isTextblock)break}for(let h=r.openStart;h>=0;h--){let p=(h+d+1)%(r.openStart+1),m=c[p];if(m)for(let v=0;v<s.length;v++){let g=s[(v+l)%s.length],y=!0;g<0&&(y=!1,g=-g);let w=i.node(g-1),_=i.index(g-1);if(w.canReplaceWith(_,_,m.type,m.marks))return n.replace(i.before(g),y?o.after(g):t,new ye(Lx(r.content,0,r.openStart,p),p,r.openEnd))}}let u=n.steps.length;for(let h=s.length-1;h>=0&&(n.replace(e,t,r),!(n.steps.length>u));h--){let p=s[h];p<0||(e=i.before(p),t=o.after(p))}}function Lx(n,e,t,r,i){if(e<t){let o=n.firstChild;n=n.replaceChild(0,o.copy(Lx(o.content,e+1,t,r,o)))}if(e>r){let o=i.contentMatchAt(0),s=o.fillBefore(n).append(n);n=s.append(o.matchFragment(s).fillBefore(ie.empty,!0))}return n}function cE(n,e,t,r){if(!r.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let i=iE(n.doc,e,r.type);i!=null&&(e=t=i)}n.replaceRange(e,t,new ye(ie.from(r),0,0))}function dE(n,e,t){let r=n.doc.resolve(e),i=n.doc.resolve(t),o=zx(r,i);for(let s=0;s<o.length;s++){let a=o[s],l=s==o.length-1;if(l&&a==0||r.node(a).type.contentMatch.validEnd)return n.delete(r.start(a),i.end(a));if(a>0&&(l||r.node(a-1).canReplace(r.index(a-1),i.indexAfter(a-1))))return n.delete(r.before(a),i.after(a))}for(let s=1;s<=r.depth&&s<=i.depth;s++)if(e-r.start(s)==r.depth-s&&t>r.end(s)&&i.end(s)-t!=i.depth-s&&r.start(s-1)==i.start(s-1)&&r.node(s-1).canReplace(r.index(s-1),i.index(s-1)))return n.delete(r.before(s),t);n.delete(e,t)}function zx(n,e){let t=[],r=Math.min(n.depth,e.depth);for(let i=r;i>=0;i--){let o=n.start(i);if(o<n.pos-(n.depth-i)||e.end(i)>e.pos+(e.depth-i)||n.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(o==e.start(i)||i==n.depth&&i==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==o-1)&&t.push(i)}return t}class Gs extends An{constructor(e,t,r){super(),this.pos=e,this.attr=t,this.value=r}apply(e){let t=e.nodeAt(this.pos);if(!t)return jt.fail("No node at attribute step's position");let r=Object.create(null);for(let o in t.attrs)r[o]=t.attrs[o];r[this.attr]=this.value;let i=t.type.create(r,null,t.marks);return jt.fromReplace(e,this.pos,this.pos+1,new ye(ie.from(i),0,t.isLeaf?0:1))}getMap(){return $n.empty}invert(e){return new Gs(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 Gs(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.pos!="number"||typeof t.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new Gs(t.pos,t.attr,t.value)}}An.jsonID("attr",Gs);class Ll extends An{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let i in e.attrs)t[i]=e.attrs[i];t[this.attr]=this.value;let r=e.type.create(t,e.content,e.marks);return jt.ok(r)}getMap(){return $n.empty}invert(e){return new Ll(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(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new Ll(t.attr,t.value)}}An.jsonID("docAttr",Ll);let wa=class extends Error{};wa=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t};wa.prototype=Object.create(Error.prototype);wa.prototype.constructor=wa;wa.prototype.name="TransformError";class qm{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Pl}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new wa(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,t=-1e9;for(let r=0;r<this.mapping.maps.length;r++){let i=this.mapping.maps[r];r&&(e=i.map(e,1),t=i.map(t,-1)),i.forEach((o,s,a,l)=>{e=Math.min(e,a),t=Math.max(t,l)})}return e==1e9?null:{from:e,to:t}}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,r=ye.empty){let i=rf(this.doc,e,t,r);return i&&this.step(i),this}replaceWith(e,t,r){return this.replace(e,t,new ye(ie.from(r),0,0))}delete(e,t){return this.replace(e,t,ye.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,r){return lE(this,e,t,r),this}replaceRangeWith(e,t,r){return cE(this,e,t,r),this}deleteRange(e,t){return dE(this,e,t),this}lift(e,t){return YA(this,e,t),this}join(e,t=1){return rE(this,e,t),this}wrap(e,t){return XA(this,e,t),this}setBlockType(e,t=e,r,i=null){return QA(this,e,t,r,i),this}setNodeMarkup(e,t,r=null,i){return eE(this,e,t,r,i),this}setNodeAttribute(e,t,r){return this.step(new Gs(e,t,r)),this}setDocAttribute(e,t){return this.step(new Ll(e,t)),this}addNodeMark(e,t){return this.step(new ao(e,t)),this}removeNodeMark(e,t){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(t instanceof wt)t.isInSet(r.marks)&&this.step(new gs(e,t));else{let i=r.marks,o,s=[];for(;o=t.isInSet(i);)s.push(new gs(e,o)),i=o.removeFromSet(i);for(let a=s.length-1;a>=0;a--)this.step(s[a])}return this}split(e,t=1,r){return tE(this,e,t,r),this}addMark(e,t,r){return KA(this,e,t,r),this}removeMark(e,t,r){return qA(this,e,t,r),this}clearIncompatible(e,t,r){return Wm(this,e,t,r),this}}const eh=Object.create(null);class Fe{constructor(e,t,r){this.$anchor=e,this.$head=t,this.ranges=r||[new Bx(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=ye.empty){let r=t.content.lastChild,i=null;for(let a=0;a<t.openEnd;a++)i=r,r=r.lastChild;let o=e.steps.length,s=this.ranges;for(let a=0;a<s.length;a++){let{$from:l,$to:c}=s[a],d=e.mapping.slice(o);e.replaceRange(d.map(l.pos),d.map(c.pos),a?ye.empty:t),a==0&&yy(e,o,(r?r.isInline:i&&i.isTextblock)?-1:1)}}replaceWith(e,t){let r=e.steps.length,i=this.ranges;for(let o=0;o<i.length;o++){let{$from:s,$to:a}=i[o],l=e.mapping.slice(r),c=l.map(s.pos),d=l.map(a.pos);o?e.deleteRange(c,d):(e.replaceRangeWith(c,d,t),yy(e,r,t.isInline?-1:1))}}static findFrom(e,t,r=!1){let i=e.parent.inlineContent?new Ie(e):Vs(e.node(0),e.parent,e.pos,e.index(),t,r);if(i)return i;for(let o=e.depth-1;o>=0;o--){let s=t<0?Vs(e.node(0),e.node(o),e.before(o+1),e.index(o),t,r):Vs(e.node(0),e.node(o),e.after(o+1),e.index(o)+1,t,r);if(s)return s}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new Kn(e.node(0))}static atStart(e){return Vs(e,e,0,0,1)||new Kn(e)}static atEnd(e){return Vs(e,e,e.content.size,e.childCount,-1)||new Kn(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=eh[t.type];if(!r)throw new RangeError(`No selection type ${t.type} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in eh)throw new RangeError("Duplicate use of selection JSON ID "+e);return eh[e]=t,t.prototype.jsonID=e,t}getBookmark(){return Ie.between(this.$anchor,this.$head).getBookmark()}}Fe.prototype.visible=!0;class Bx{constructor(e,t){this.$from=e,this.$to=t}}let gy=!1;function vy(n){!gy&&!n.parent.inlineContent&&(gy=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}class Ie extends Fe{constructor(e,t=e){vy(e),vy(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let r=e.resolve(t.map(this.head));if(!r.parent.inlineContent)return Fe.near(r);let i=e.resolve(t.map(this.anchor));return new Ie(i.parent.inlineContent?i:r,r)}replace(e,t=ye.empty){if(super.replace(e,t),t==ye.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof Ie&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new of(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new Ie(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){let i=e.resolve(t);return new this(i,r==t?i:e.resolve(r))}static between(e,t,r){let i=e.pos-t.pos;if((!r||i)&&(r=i>=0?1:-1),!t.parent.inlineContent){let o=Fe.findFrom(t,r,!0)||Fe.findFrom(t,-r,!0);if(o)t=o.$head;else return Fe.near(t,r)}return e.parent.inlineContent||(i==0?e=t:(e=(Fe.findFrom(e,-r,!0)||Fe.findFrom(e,r,!0)).$anchor,e.pos<t.pos!=i<0&&(e=t))),new Ie(e,t)}}Fe.jsonID("text",Ie);class of{constructor(e,t){this.anchor=e,this.head=t}map(e){return new of(e.map(this.anchor),e.map(this.head))}resolve(e){return Ie.between(e.resolve(this.anchor),e.resolve(this.head))}}class Pe extends Fe{constructor(e){let t=e.nodeAfter,r=e.node(0).resolve(e.pos+t.nodeSize);super(e,r),this.node=t}map(e,t){let{deleted:r,pos:i}=t.mapResult(this.anchor),o=e.resolve(i);return r?Fe.near(o):new Pe(o)}content(){return new ye(ie.from(this.node),0,0)}eq(e){return e instanceof Pe&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Jm(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new Pe(e.resolve(t.anchor))}static create(e,t){return new Pe(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}Pe.prototype.visible=!1;Fe.jsonID("node",Pe);class Jm{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:r}=e.mapResult(this.anchor);return t?new of(r,r):new Jm(r)}resolve(e){let t=e.resolve(this.anchor),r=t.nodeAfter;return r&&Pe.isSelectable(r)?new Pe(t):Fe.near(t)}}class Kn extends Fe{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=ye.empty){if(t==ye.empty){e.delete(0,e.doc.content.size);let r=Fe.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new Kn(e)}map(e){return new Kn(e)}eq(e){return e instanceof Kn}getBookmark(){return uE}}Fe.jsonID("all",Kn);const uE={map(){return this},resolve(n){return new Kn(n)}};function Vs(n,e,t,r,i,o=!1){if(e.inlineContent)return Ie.create(n,t);for(let s=r-(i>0?0:1);i>0?s<e.childCount:s>=0;s+=i){let a=e.child(s);if(a.isAtom){if(!o&&Pe.isSelectable(a))return Pe.create(n,t-(i<0?a.nodeSize:0))}else{let l=Vs(n,a,t+i,i<0?a.childCount:0,i,o);if(l)return l}t+=a.nodeSize*i}return null}function yy(n,e,t){let r=n.steps.length-1;if(r<e)return;let i=n.steps[r];if(!(i instanceof nn||i instanceof rn))return;let o=n.mapping.maps[r],s;o.forEach((a,l,c,d)=>{s==null&&(s=d)}),n.setSelection(Fe.near(n.doc.resolve(s),t))}const by=1,Bc=2,wy=4;let fE=class extends qm{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=(this.updated|by)&~Bc,this.storedMarks=null,this}get selectionSet(){return(this.updated&by)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Bc,this}ensureMarks(e){return wt.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(this.updated&Bc)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~Bc,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let r=this.selection;return t&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||wt.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,r){let i=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(i.text(e),!0):this.deleteSelection();{if(r==null&&(r=t),!e)return this.deleteRange(t,r);let o=this.storedMarks;if(!o){let s=this.doc.resolve(t);o=r==t?s.marks():s.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(t,r,i.text(e,o)),!this.selection.empty&&this.selection.to==t+e.length&&this.setSelection(Fe.near(this.selection.$to)),this}}setMeta(e,t){return this.meta[typeof e=="string"?e:e.key]=t,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=wy,this}get scrolledIntoView(){return(this.updated&wy)>0}};function xy(n,e){return!e||!n?n:n.bind(e)}class tl{constructor(e,t,r){this.name=e,this.init=xy(t.init,r),this.apply=xy(t.apply,r)}}const hE=[new tl("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new tl("selection",{init(n,e){return n.selection||Fe.atStart(e.doc)},apply(n){return n.selection}}),new tl("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,r){return r.selection.$cursor?n.storedMarks:null}}),new tl("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})];class th{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=hE.slice(),t&&t.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new tl(r.key,r.spec.state,r))})}}class Ks{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 r=0;r<this.config.plugins.length;r++)if(r!=t){let i=this.config.plugins[r];if(i.spec.filterTransaction&&!i.spec.filterTransaction.call(i,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],r=this.applyInner(e),i=null;for(;;){let o=!1;for(let s=0;s<this.config.plugins.length;s++){let a=this.config.plugins[s];if(a.spec.appendTransaction){let l=i?i[s].n:0,c=i?i[s].state:this,d=l<t.length&&a.spec.appendTransaction.call(a,l?t.slice(l):t,c,r);if(d&&r.filterTransaction(d,s)){if(d.setMeta("appendedTransaction",e),!i){i=[];for(let u=0;u<this.config.plugins.length;u++)i.push(u<s?{state:r,n:t.length}:{state:this,n:0})}t.push(d),r=r.applyInner(d),o=!0}i&&(i[s]={state:r,n:t.length})}}if(!o)return{state:r,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new Ks(this.config),r=this.config.fields;for(let i=0;i<r.length;i++){let o=r[i];t[o.name]=o.apply(e,this[o.name],this,t)}return t}get tr(){return new fE(this)}static create(e){let t=new th(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new Ks(t);for(let i=0;i<t.fields.length;i++)r[t.fields[i].name]=t.fields[i].init(e,r);return r}reconfigure(e){let t=new th(this.schema,e.plugins),r=t.fields,i=new Ks(t);for(let o=0;o<r.length;o++){let s=r[o].name;i[s]=this.hasOwnProperty(s)?this[s]:r[o].init(e,i)}return i}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(r=>r.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=e[r],o=i.spec.state;o&&o.toJSON&&(t[r]=o.toJSON.call(i,this[i.key]))}return t}static fromJSON(e,t,r){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let i=new th(e.schema,e.plugins),o=new Ks(i);return i.fields.forEach(s=>{if(s.name=="doc")o.doc=po.fromJSON(e.schema,t.doc);else if(s.name=="selection")o.selection=Fe.fromJSON(o.doc,t.selection);else if(s.name=="storedMarks")t.storedMarks&&(o.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let a in r){let l=r[a],c=l.spec.state;if(l.key==s.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(t,a)){o[s.name]=c.fromJSON.call(l,e,t[a],o);return}}o[s.name]=s.init(e,o)}}),o}}function Fx(n,e,t){for(let r in n){let i=n[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=Fx(i,e,{})),t[r]=i}return t}class pt{constructor(e){this.spec=e,this.props={},e.props&&Fx(e.props,this,this.props),this.key=e.key?e.key.key:Vx("plugin")}getState(e){return e[this.key]}}const nh=Object.create(null);function Vx(n){return n in nh?n+"$"+ ++nh[n]:(nh[n]=0,n+"$")}class xt{constructor(e="key"){this.key=Vx(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const kp=[{keys:"Ctrl+B",description:"Bold"},{keys:"Ctrl+I",description:"Italic"},{keys:"Ctrl+Z",description:"Undo"},{keys:"Ctrl+Y",description:"Redo"},{keys:"Ctrl+F",description:"Find / Replace"},{keys:"Ctrl+N",description:"New scratchpad"},{keys:"? or Ctrl+/",description:"Show keyboard shortcuts"},{keys:"Ctrl+Tab",description:"Next document tab"},{keys:"Ctrl+Shift+Tab",description:"Previous document tab"}];function _p(n){const e=[];return n.state.doc.descendants((t,r)=>{t.type.name==="heading"&&t.attrs.level<=3&&e.push({text:t.textContent,level:t.attrs.level,pos:r})}),e}var pE=O('<div style="font-size: var(--tandem-text-xs); color: var(--tandem-fg-subtle); margin-top: var(--tandem-space-1);"><!> <!> <!> <!></div>'),mE=O('<li data-testid="palette-empty" style="padding: var(--tandem-space-3) var(--tandem-space-4); font-size: var(--tandem-text-sm); color: var(--tandem-fg-faint); font-style: italic;"> </li>'),gE=O('<span style="font-size: var(--tandem-text-xs); color: var(--tandem-fg-faint); font-family: var(--tandem-font-mono);"> </span>'),vE=O('<span style="font-size: var(--tandem-text-sm);"> </span> <!>',1),yE=O(`<span style="display: flex; align-items: center; gap: var(--tandem-space-2);"><span style="
|
|
7
|
-
font-size: var(--tandem-text-xs);
|
|
8
|
-
color: var(--tandem-fg-subtle);
|
|
9
|
-
font-family: var(--tandem-font-mono);
|
|
10
|
-
min-width: 20px;
|
|
11
|
-
"> </span> <span> </span></span>`),bE=O('<span style="font-size: var(--tandem-text-xs); color: var(--tandem-fg-subtle); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;"> </span>'),wE=O('<span style="display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0;"><span style="font-size: var(--tandem-text-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;"> </span> <!></span> <span style="font-size: var(--tandem-text-xs); color: var(--tandem-fg-faint); flex-shrink: 0; margin-left: var(--tandem-space-2);"> </span>',1),xE=O('<span style="font-size: var(--tandem-text-sm);"> </span> <span style="font-size: var(--tandem-text-xs); color: var(--tandem-fg-faint); font-family: var(--tandem-font-mono);"> </span>',1),kE=O('<li role="option"><!></li>'),_E=O(`<div role="presentation" style="
|
|
12
|
-
position: fixed; inset: 0;
|
|
13
|
-
background: rgba(0,0,0,0.4);
|
|
14
|
-
z-index: var(--tandem-z-overlay, 200);
|
|
15
|
-
display: flex; align-items: flex-start; justify-content: center;
|
|
16
|
-
padding-top: 15vh;
|
|
17
|
-
"><div data-testid="command-palette" role="dialog" tabindex="-1" aria-modal="true" aria-label="Command palette" style="
|
|
18
|
-
width: 560px; max-width: 90vw;
|
|
19
|
-
background: var(--tandem-surface);
|
|
20
|
-
border: 1px solid var(--tandem-border);
|
|
21
|
-
border-radius: var(--tandem-r-4);
|
|
22
|
-
box-shadow: var(--tandem-shadow-4);
|
|
23
|
-
overflow: hidden;
|
|
24
|
-
display: flex; flex-direction: column;
|
|
25
|
-
"><div style="padding: var(--tandem-space-3) var(--tandem-space-4); border-bottom: 1px solid var(--tandem-border);"><input data-testid="palette-input" type="text" aria-label="Search commands" aria-controls="palette-results" style="
|
|
26
|
-
width: 100%; padding: 6px 0;
|
|
27
|
-
font-size: var(--tandem-text-md); color: var(--tandem-fg);
|
|
28
|
-
background: transparent; border: none; outline: none;
|
|
29
|
-
"/> <!></div> <ul id="palette-results" role="listbox" aria-label="Results" style="max-height: 400px; overflow-y: auto; padding: var(--tandem-space-1) 0; list-style: none; margin: 0;"><!></ul> <div style="
|
|
30
|
-
padding: var(--tandem-space-2) var(--tandem-space-4);
|
|
31
|
-
border-top: 1px solid var(--tandem-border);
|
|
32
|
-
display: flex; gap: var(--tandem-space-3);
|
|
33
|
-
font-size: var(--tandem-text-xs); color: var(--tandem-fg-subtle);
|
|
34
|
-
"><span><kbd style="font-family: var(--tandem-font-mono);">#</kbd> headings</span> <span><kbd style="font-family: var(--tandem-font-mono);">@</kbd> annotations</span> <span><kbd style="font-family: var(--tandem-font-mono);">?</kbd> shortcuts</span> <span><kbd style="font-family: var(--tandem-font-mono);">></kbd> commands</span></div></div></div>`);function SE(n,e){We(e,!0);let t=lt(e,"editor",3,null),r=lt(e,"annotations",19,()=>[]),i=z(""),o=z(0),s=z(null);const a=["#","@","?",">"],l=P(()=>a.find(R=>f(i).startsWith(R))??null),c=P(()=>(f(l)?f(i).slice(1):f(i)).trim().toLowerCase()),d=P(()=>{var te;if(f(l)!==null&&f(l)!==">")return[];const R=Bd(),E=f(c),q=[];for(const K of R.values())(!E||K.label.toLowerCase().includes(E)||K.group.toLowerCase().includes(E)||(((te=K.shortcut)==null?void 0:te.toLowerCase().includes(E))??!1))&&q.push({kind:"action",id:K.id,action:K});return q}),u=P(()=>{if(f(l)!=="#")return[];const R=t();if(!R||R.isDestroyed)return[];const E=f(c);return _p(R).filter(q=>!E||q.text.toLowerCase().includes(E)).map((q,te)=>({kind:"heading",id:`heading-${te}`,...q}))}),h=P(()=>{if(f(l)!=="@")return[];const R=f(c);return r().filter(E=>{var q;return R?E.content.toLowerCase().includes(R)||((q=E.textSnapshot)==null?void 0:q.toLowerCase().includes(R)):!0}).slice(0,50).map(E=>({kind:"annotation",id:`annotation-${E.id}`,label:E.content?E.content.slice(0,60):"(no content)",snippet:E.textSnapshot??"",annotationType:E.type}))}),p=P(()=>{if(f(l)!=="?")return[];const R=f(c),E=Bd(),q=[];for(const te of E.values())te.shortcut&&(!R||te.label.toLowerCase().includes(R)||te.shortcut.toLowerCase().includes(R))&&q.push({kind:"shortcut",id:`shortcut-registry-${te.id}`,keys:te.shortcut,description:te.label,group:te.group});for(let te=0;te<kp.length;te++){const K=kp[te];(!R||K.description.toLowerCase().includes(R)||K.keys.toLowerCase().includes(R))&&q.push({kind:"shortcut",id:`shortcut-static-${te}`,keys:K.keys,description:K.description,group:"other"})}return q}),m=P(()=>[...f(d),...f(u),...f(h),...f(p)]);he(()=>{f(m),b(o,0)}),he(()=>{e.open&&(b(i,""),b(o,0),Promise.resolve().then(()=>{var R;return(R=f(s))==null?void 0:R.focus()}))});const v={"#":"Search headings…","@":"Search annotations…","?":"Search shortcuts…",">":"Search commands…"},g=P(()=>f(l)?v[f(l)]:"Type a command, # headings, @ annotations, ? shortcuts…");function y(){e.onClose()}function w(R){var E;if(R.kind==="action")y(),R.action.run();else if(R.kind==="heading"){y();const q=t();if(!q||q.isDestroyed)return;const te=R.pos;try{const K=q.state.doc.resolve(te+1),V=Ie.near(K);q.view.dispatch(q.state.tr.setSelection(V).scrollIntoView()),q.view.focus()}catch{}}else R.kind==="annotation"&&(y(),(E=e.onFocusAnnotation)==null||E.call(e,R.id.replace("annotation-","")))}function _(R){const E=f(m).length;if(R.key==="ArrowDown")R.preventDefault(),b(o,(f(o)+1)%Math.max(1,E));else if(R.key==="ArrowUp")R.preventDefault(),b(o,(f(o)-1+Math.max(1,E))%Math.max(1,E));else if(R.key==="Enter"){R.preventDefault();const q=f(m)[f(o)];q&&w(q)}else R.key==="Escape"&&(R.preventDefault(),y())}function S(R){R.target===R.currentTarget&&y()}var A=Tt(),U=Le(A);{var N=R=>{var E=_E(),q=x(E),te=x(q),K=x(te);yt(K,j=>b(s,j),()=>f(s));var V=k(K,2);{var ee=j=>{var ae=pE(),C=x(ae);{var I=D=>{var Y=Nn("Searching document headings");T(D,Y)};Z(C,D=>{f(l)==="#"&&D(I)})}var W=k(C,2);{var ge=D=>{var Y=Nn("Searching annotations");T(D,Y)};Z(W,D=>{f(l)==="@"&&D(ge)})}var xe=k(W,2);{var Oe=D=>{var Y=Nn("Showing keyboard shortcuts");T(D,Y)};Z(xe,D=>{f(l)==="?"&&D(Oe)})}var J=k(xe,2);{var fe=D=>{var Y=Nn("Filtering commands");T(D,Y)};Z(J,D=>{f(l)===">"&&D(fe)})}T(j,ae)};Z(V,j=>{f(l)&&j(ee)})}var se=k(te,2),F=x(se);{var X=j=>{var ae=mE(),C=x(ae);G(()=>ne(C,f(l)==="#"?"No headings found":f(l)==="@"?"No annotations found":f(l)==="?"?"No shortcuts found":"No commands match")),T(j,ae)},B=j=>{var ae=Tt(),C=Le(ae);ft(C,19,()=>f(m),I=>I.id,(I,W,ge)=>{const xe=P(()=>f(ge)===f(o));var Oe=kE(),J=x(Oe);{var fe=we=>{var Te=vE(),Se=Le(Te),De=x(Se),oe=k(Se,2);{var M=$=>{var le=gE(),de=x(le);G(()=>ne(de,f(W).action.shortcut)),T($,le)};Z(oe,$=>{f(W).action.shortcut&&$(M)})}G(()=>ne(De,f(W).action.label)),T(we,Te)},D=we=>{var Te=yE(),Se=x(Te),De=x(Se),oe=k(Se,2),M=x(oe);G(()=>{ne(De,`H${f(W).level??""}`),re(oe,`font-size: var(--tandem-text-sm); padding-left: calc(${f(W).level-1} * var(--tandem-space-2));`),ne(M,f(W).text)}),T(we,Te)},Y=we=>{var Te=wE(),Se=Le(Te),De=x(Se),oe=x(De),M=k(De,2);{var $=Ee=>{var ce=bE(),ve=x(ce);G(()=>ne(ve,`"${f(W).snippet??""}"`)),T(Ee,ce)};Z(M,Ee=>{f(W).snippet&&Ee($)})}var le=k(Se,2),de=x(le);G(Ee=>{ne(oe,f(W).label),ne(de,Ee)},[()=>f(W).annotationType.charAt(0).toUpperCase()+f(W).annotationType.slice(1)]),T(we,Te)},be=we=>{var Te=xE(),Se=Le(Te),De=x(Se),oe=k(Se,2),M=x(oe);G(()=>{ne(De,f(W).description),ne(M,f(W).keys)}),T(we,Te)};Z(J,we=>{f(W).kind==="action"?we(fe):f(W).kind==="heading"?we(D,1):f(W).kind==="annotation"?we(Y,2):f(W).kind==="shortcut"&&we(be,3)})}G(()=>{Q(Oe,"id",`palette-item-${f(W).id}`),Q(Oe,"data-testid",`palette-item-${f(W).id}`),Q(Oe,"aria-selected",f(xe)),re(Oe,`
|
|
35
|
-
display: flex; align-items: center; justify-content: space-between;
|
|
36
|
-
padding: 8px var(--tandem-space-4);
|
|
37
|
-
cursor: ${f(W).kind==="shortcut"?"default":"pointer"};
|
|
38
|
-
background: ${f(xe)?"var(--tandem-accent-bg)":"transparent"};
|
|
39
|
-
color: ${f(xe)?"var(--tandem-accent-fg-strong)":"var(--tandem-fg)"};
|
|
40
|
-
`)}),L("click",Oe,()=>w(f(W))),vt("mouseenter",Oe,()=>b(o,f(ge),!0)),T(I,Oe)}),T(j,ae)};Z(F,j=>{f(m).length===0?j(X):j(B,-1)})}G(()=>{Q(K,"placeholder",f(g)),Q(K,"aria-activedescendant",f(m)[f(o)]?`palette-item-${f(m)[f(o)].id}`:void 0)}),L("click",E,S),L("keydown",E,j=>{j.key==="Escape"&&y()}),L("keydown",q,_),hs(K,()=>f(i),j=>b(i,j)),T(R,E)};Z(U,R=>{e.open&&R(N)})}T(n,A),Ke()}Ye(["click","keydown"]);var CE=O('<div data-testid="connection-banner" style="padding: var(--tandem-space-2) var(--tandem-space-4); background: var(--tandem-error-bg); border-bottom: 1px solid var(--tandem-error-border); font-size: var(--tandem-text-base); color: var(--tandem-error-fg-strong); text-align: center; display: flex; justify-content: center; align-items: center; gap: var(--tandem-space-3);"><span>Connection to the Tandem server has been lost. Ensure the server is running.</span> <button data-testid="connection-banner-retry" style="background: none; border: 1px solid var(--tandem-error-border); border-radius: var(--tandem-r-2); cursor: pointer; color: var(--tandem-error-fg-strong); font-size: var(--tandem-text-sm); padding: 2px var(--tandem-space-2);">Retry now</button> <button style="background: none; border: none; cursor: pointer; color: var(--tandem-error-fg-strong); font-size: 16px; line-height: 1; padding: 0 4px;" aria-label="Dismiss connection banner">×</button></div>');function TE(n,e){var t=CE(),r=k(x(t),2),i=k(r,2);L("click",r,function(...o){var s;(s=e.onRetry)==null||s.apply(this,o)}),L("click",i,function(...o){var s;(s=e.onDismiss)==null||s.apply(this,o)}),T(n,t)}Ye(["click"]);function P5(n){return n?n.osSupported?n.coworkDetected?"normal":"undetected":"unsupported":"loading"}function AE(n){switch(n.kind){case"adminDeclined":return"Admin permission was denied. Retry with admin, or disable Cowork integration.";case"netshNotFound":return"Windows Firewall command (netsh) was not found on PATH. Confirm your Windows install is intact.";case"netshFailure":return`Windows Firewall command failed (exit ${n.exitCode}). Details: ${EE(n.stderrTail)}`;case"subnetDetectionFailed":return"Could not detect the Hyper-V / Cowork VM subnet. Is Claude Desktop Cowork actually set up on this machine?";case"adapterEnumerationFailed":return"Could not enumerate Hyper-V network adapters. Run Tandem as administrator or reboot to refresh the adapter list.";default:return`Unexpected firewall error (${n.kind}). Please restart Tandem.`}}function EE(n){const e=n.trim();return e.length===0?"(no output)":e.length<=200?e:`${e.slice(0,197)}...`}function Hx(n){try{const e=JSON.parse(n);if(typeof e=="object"&&e!==null&&"kind"in e&&typeof e.kind=="string")try{return AE(e)}catch(t){return console.error("[cowork] firewallErrorHint failed for:",e,t),n}return n}catch{return n}}function L5(n){switch(n){case"ok":return"Installed";case"alreadyPresent":return"Already installed";case"locked":return"Locked (retrying)";case"schemaDrift":return"Schema drift";case"insecureAcl":return"Insecure ACL";case"failed":return"Failed"}}function z5(n){switch(n){case"ok":case"alreadyPresent":return"success";case"locked":return"warning";case"schemaDrift":case"insecureAcl":case"failed":return"error"}}function B5(n){const e=["failed","schemaDrift","insecureAcl","locked","alreadyPresent","ok"],t=[n.installedPlugins,n.knownMarketplaces,n.coworkSettings];for(const r of e)if(t.includes(r))return r;return"ok"}function Ux(n,e){return!(!n||e||!n.osSupported||!n.coworkDetected||n.enabled)}function jx(){try{return localStorage.getItem(rx)==="true"}catch{return!1}}function ME(){try{localStorage.setItem(rx,"true")}catch{}}function Cr(){try{return typeof window<"u"&&"__TAURI_INTERNALS__"in window}catch{return!1}}function F5(n){let e=null;return{schedule(t){e!==null&&clearTimeout(e),e=setTimeout(()=>{e=null,t()},n)},cancel(){e!==null&&(clearTimeout(e),e=null)}}}const OE="modulepreload",DE=function(n){return"/"+n},ky={},ko=function(e,t,r){let i=Promise.resolve();if(t&&t.length>0){let s=function(c){return Promise.all(c.map(d=>Promise.resolve(d).then(u=>({status:"fulfilled",value:u}),u=>({status:"rejected",reason:u}))))};document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),l=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));i=s(t.map(c=>{if(c=DE(c),c in ky)return;ky[c]=!0;const d=c.endsWith(".css"),u=d?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${u}`))return;const h=document.createElement("link");if(h.rel=d?"stylesheet":OE,d||(h.as="script"),h.crossOrigin="",h.href=c,l&&h.setAttribute("nonce",l),document.head.appendChild(h),d)return new Promise((p,m)=>{h.addEventListener("load",p),h.addEventListener("error",()=>m(new Error(`Unable to preload CSS for ${c}`)))})}))}function o(s){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=s,window.dispatchEvent(a),!a.defaultPrevented)throw s}return i.then(s=>{for(const a of s||[])a.status==="rejected"&&o(a.reason);return e().catch(o)})},Wx="Tauri runtime not available";async function Ym(){try{return(await ko(()=>import("./core-DhEqZVGG.js"),[])).invoke}catch(n){return Cr()&&console.error("[cowork] Failed to load @tauri-apps/api/core:",n),(()=>Promise.reject(new Error(Wx)))}}function RE(n){return n("cowork_get_status")}function Kx(n,e){return n("cowork_toggle_integration",{enabled:e})}function V5(n){return n("cowork_rescan")}function H5(n,e){return n("cowork_set_lan_ip_override",{enabled:e})}function NE(n){return n("cowork_retry_admin_elevation")}function qx(n){let e=z(null),t=z(!1),r=z(null),i=null,o=!1,s=!0,a=null;pi(()=>{s=!1,a!==null&&(clearInterval(a),a=null)});const l=async()=>{if(o){s&&b(t,!1);return}const c=i;if(c)try{const d=await RE(c);if(!s)return;b(e,d,!0),b(r,null)}catch(d){if(!s)return;const u=d instanceof Error?d.message:String(d);if(u===Wx){o=!0,a!==null&&(clearInterval(a),a=null),b(t,!1);return}b(r,u,!0)}finally{s&&b(t,!1)}};return he(()=>{if(!n()){b(t,!1);return}let d=!1;return Ym().then(u=>{if(!d)return i=u,b(t,!0),l()}).catch(u=>{if(d)return;const h=u instanceof Error?u.message:String(u);b(r,h,!0),b(t,!1)}),a=setInterval(()=>{d||o||l()},hA),()=>{d=!0,a!==null&&(clearInterval(a),a=null)}}),{get status(){return f(e)},get loading(){return f(t)},get error(){return f(r)},refetch:l}}var IE=O(`<div data-testid="cowork-admin-declined-status-error" role="alert" style="position: fixed; bottom: 16px; right: 16px; z-index: 10000; max-width: 400px; border: 1px solid var(--tandem-error-border); background: var(--tandem-error-bg); color: var(--tandem-error-fg-strong); border-radius: var(--tandem-r-3); padding: 10px 14px; font-size: 12px; line-height: 1.5;">Cowork status check failed: unable to determine if admin elevation was declined. Please
|
|
41
|
-
restart Tandem to restore normal operation.</div>`),PE=O('<div data-testid="cowork-admin-declined-error" role="alert" style="font-size: 12px; color: var(--tandem-error-fg-strong); background: var(--tandem-error-bg); border: 1px solid var(--tandem-error-border); border-radius: var(--tandem-r-2); padding: 6px 8px;"> </div>'),LE=O('<div data-testid="cowork-admin-declined-confirm-disable" style="font-size: 12px; color: var(--tandem-warning-fg-strong); background: var(--tandem-warning-bg); border: 1px solid var(--tandem-warning-border); border-radius: var(--tandem-r-2); padding: 8px 10px;"><div style="font-weight: 600; margin-bottom: 6px;">Disable Cowork integration?</div> <div style="margin-bottom: 8px;">The deny rule will remain in place. You can re-enable Cowork later from Settings.</div> <div style="display: flex; gap: 8px;"><button data-testid="cowork-admin-declined-disable-confirm-btn" type="button" style="padding: 4px 10px; font-size: 12px; border: 1px solid var(--tandem-error-border); border-radius: var(--tandem-r-2); background: var(--tandem-error); color: var(--tandem-error-fg); cursor: pointer; font-weight: 600;">Disable</button> <button data-testid="cowork-admin-declined-disable-cancel-btn" type="button" style="padding: 4px 10px; font-size: 12px; border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-2); background: var(--tandem-surface); color: var(--tandem-fg-muted); cursor: pointer;">Cancel</button></div></div>'),zE=O('<div style="display: flex; gap: 8px; justify-content: flex-end;"><button data-testid="cowork-admin-declined-disable-btn" type="button" style="padding: 6px 12px; font-size: 13px; border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-2); background: var(--tandem-surface); color: var(--tandem-fg-muted); cursor: pointer;">Disable Cowork</button> <button data-testid="cowork-admin-declined-retry-btn" type="button" style="padding: 6px 12px; font-size: 13px; border: 1px solid var(--tandem-accent); border-radius: var(--tandem-r-2); background: var(--tandem-accent); color: var(--tandem-accent-fg); cursor: pointer; font-weight: 600;">Retry with admin</button></div>'),BE=O(`<div data-testid="cowork-admin-declined-backdrop" style="position: fixed; inset: 0; background: rgba(0, 0, 0, 0.45); z-index: 10000; display: flex; align-items: center; justify-content: center;"><div data-testid="cowork-admin-declined-modal" role="dialog" aria-modal="true" aria-labelledby="cowork-admin-declined-heading" style="width: 440px; max-width: calc(100vw - 32px); background: var(--tandem-surface); color: var(--tandem-fg); border: 1px solid var(--tandem-error-border); border-radius: var(--tandem-r-4); padding: 20px; box-shadow: var(--tandem-shadow-3); outline: none; display: flex; flex-direction: column; gap: 12px;"><h2 id="cowork-admin-declined-heading" style="margin: 0; font-size: 16px; font-weight: 600; color: var(--tandem-error-fg-strong);">Admin permission required</h2> <div style="font-size: 13px; line-height: 1.5; color: var(--tandem-fg-muted);">Cowork integration requires Windows admin permission to configure firewall rules. Without
|
|
42
|
-
it, Tandem can't safely be reached from inside the Cowork VM. Port 3479 is currently
|
|
43
|
-
blocked by a deny rule to protect your machine.</div> <!> <!></div></div>`);function FE(n,e){We(e,!0);const t='button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])',r=qx(()=>!0),i=P(()=>{var g;return((g=r.status)==null?void 0:g.uacDeclined)===!0});let o=z(void 0),s=z(!1),a=z(!1),l=z(null);he(()=>{if(!f(i))return;const g=typeof document<"u"?document.title:null;return typeof document<"u"&&!document.title.startsWith("⚠")&&(document.title=`⚠ ${document.title}`),()=>{typeof document<"u"&&g!==null&&(document.title=g)}}),he(()=>{if(!f(i))return;const g=y=>{if(y.key!=="Tab"||!f(o))return;const w=f(o).querySelectorAll(t);if(w.length===0)return;const _=w[0],S=w[w.length-1],A=document.activeElement;if(!f(o).contains(A)){y.preventDefault(),_.focus();return}y.shiftKey&&A===_?(y.preventDefault(),S.focus()):!y.shiftKey&&A===S&&(y.preventDefault(),_.focus())};return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)}),he(()=>{var g;f(i)&&((g=f(o))==null||g.focus())});async function c(g,y){b(a,!0),b(l,null);try{const w=await Ym();await g(w)}catch(w){const _=w instanceof Error?w.message:String(w),S=Hx(_);b(l,`${y}: ${S}`)}finally{b(a,!1)}}async function d(){await c(async g=>{await NE(g),await r.refetch()},"Retry failed")}async function u(){await c(async g=>{await Kx(g,!1),await r.refetch()},"Failed to disable Cowork"),b(s,!1)}var h=Tt(),p=Le(h);{var m=g=>{var y=IE();T(g,y)},v=g=>{var y=BE(),w=x(y);Q(w,"tabindex",-1);var _=k(x(w),4);{var S=R=>{var E=PE(),q=x(E);G(()=>ne(q,f(l))),T(R,E)};Z(_,R=>{f(l)&&R(S)})}var A=k(_,2);{var U=R=>{var E=LE(),q=k(x(E),4),te=x(q),K=k(te,2);G(()=>{te.disabled=f(a),K.disabled=f(a)}),L("click",te,()=>void u()),L("click",K,()=>{b(s,!1)}),T(R,E)},N=R=>{var E=zE(),q=x(E),te=k(q,2);G(()=>{q.disabled=f(a),te.disabled=f(a)}),L("click",q,()=>{b(s,!0)}),L("click",te,()=>void d()),T(R,E)};Z(A,R=>{f(s)?R(U):R(N,-1)})}yt(w,R=>b(o,R),()=>f(o)),T(g,y)};Z(p,g=>{r.error&&!r.status?g(m):f(i)&&g(v,1)})}T(n,h),Ke()}Ye(["click"]);var VE=O("<span>Cannot reach the Tandem server. Is it running?</span>"),HE=O('<span style="font-family: var(--tandem-font-sans); font-size: 13px; color: var(--tandem-fg-subtle);">Tip: open Claude Code in this directory to start collaborating</span>'),UE=O("<span>No document open. Click + in the tab bar or drop a file here.</span> <!>",1),jE=O('<div style="display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 360px; color: var(--tandem-fg-subtle); gap: 10px; font-family: var(--tandem-font-serif); font-size: 17px; line-height: 1.55; text-align: center;"><!></div>');function WE(n,e){We(e,!0);let t=z(!1);he(()=>{if(e.connected){b(t,!1);return}const a=setTimeout(()=>{b(t,!0)},nA);return()=>clearTimeout(a)});var r=jE(),i=x(r);{var o=a=>{var l=VE();T(a,l)},s=a=>{var l=UE(),c=k(Le(l),2);{var d=u=>{var h=HE();T(u,h)};Z(c,u=>{e.connected&&!e.claudeActive&&u(d)})}T(a,l)};Z(i,a=>{f(t)?a(o):a(s,-1)})}T(n,r),Ke()}var KE=O('<span style="font-size: 12px; font-family: ui-monospace, SFMono-Regular, monospace; white-space: nowrap;"><kbd style="display: inline-block; padding: 1px 6px; font-size: 12px; font-family: inherit; background: var(--tandem-surface-muted); border: 1px solid var(--tandem-border-strong); border-bottom: 2px solid var(--tandem-border-strong); border-radius: var(--tandem-r-2); color: var(--tandem-fg); line-height: 1.5;"> </kbd></span> <span style="font-size: 13px; color: var(--tandem-fg-muted);"> </span>',1),qE=O('<div style="margin-bottom: 18px;"><div style="font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--tandem-fg-subtle); margin-bottom: 6px;"> </div> <div style="display: grid; grid-template-columns: minmax(120px, max-content) 1fr; gap: 6px 14px; align-items: center;"></div></div>'),JE=O('<span style="font-size: 12px; font-family: ui-monospace, SFMono-Regular, monospace; white-space: nowrap;"><kbd style="display: inline-block; padding: 1px 6px; font-size: 12px; font-family: inherit; background: var(--tandem-surface-muted); border: 1px solid var(--tandem-border-strong); border-bottom: 2px solid var(--tandem-border-strong); border-radius: var(--tandem-r-2); color: var(--tandem-fg); line-height: 1.5;"> </kbd></span> <span style="font-size: 13px; color: var(--tandem-fg-muted);"> </span>',1),YE=O(`<div role="presentation" style="position: fixed; inset: 0; background-color: rgba(0, 0, 0, 0.45); display: flex; align-items: center; justify-content: center; z-index: 1000;" data-testid="help-modal"><div role="dialog" aria-modal="true" aria-label="Keyboard Shortcuts" tabindex="-1" style="background-color: var(--tandem-surface); border: 1px solid var(--tandem-border); border-radius: var(--tandem-r-4); box-shadow: var(--tandem-shadow-3); padding: 24px 28px 20px; width: 480px; max-width: 90vw; max-height: 80vh; overflow-y: auto; position: relative;"><div style="display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px;"><h2 style="margin: 0; font-size: 16px; font-weight: 600; color: var(--tandem-fg);">Keyboard Shortcuts</h2> <button type="button" aria-label="Close help" data-testid="help-modal-close" style="background: none; border: none; cursor: pointer; font-size: 18px; color: var(--tandem-fg-muted); line-height: 1; padding: 2px 6px; border-radius: var(--tandem-r-2);">✕</button></div> <!> <div style="margin-bottom: 18px;"><div style="font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--tandem-fg-subtle); margin-bottom: 6px;">Other</div> <div style="display: grid; grid-template-columns: minmax(120px, max-content) 1fr; gap: 6px 14px; align-items: center;"></div></div> <div style="margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--tandem-border); font-size: 11px; color: var(--tandem-fg-subtle); text-align: center;">Press <kbd style="font-size: 11px; padding: 1px 4px; background: var(--tandem-surface-muted); border: 1px solid var(--tandem-border); border-radius: var(--tandem-r-1); color: var(--tandem-fg-subtle);">?</kbd>, <kbd style="font-size: 11px; padding: 1px 4px; background: var(--tandem-surface-muted); border: 1px solid var(--tandem-border); border-radius: var(--tandem-r-1); color: var(--tandem-fg-subtle);">Ctrl+/</kbd>,
|
|
44
|
-
or <kbd style="font-size: 11px; padding: 1px 4px; background: var(--tandem-surface-muted); border: 1px solid var(--tandem-border); border-radius: var(--tandem-r-1); color: var(--tandem-fg-subtle);">Esc</kbd> to close</div></div></div>`);function GE(n,e){We(e,!0);const t=P(()=>{const l=Bd(),c=new Map;for(const d of l.values()){if(!d.shortcut)continue;const u=c.get(d.group)??[];u.push({keys:d.shortcut,description:d.label}),c.set(d.group,u)}return ox.map(d=>({title:d.charAt(0).toUpperCase()+d.slice(1),rows:c.get(d)??[]})).filter(d=>d.rows.length>0)});let r=z(null),i=null;he(()=>{if(!e.open)return;const l=Ut(()=>f(r));if(!l)return;i=document.activeElement,l.focus();const c=d=>{l&&!l.contains(d.target)&&l.focus()};return document.addEventListener("focusin",c),()=>{document.removeEventListener("focusin",c),i instanceof HTMLElement&&document.contains(i)&&i.focus()}}),he(()=>{if(!e.open)return;const l=c=>{c.key==="Escape"&&e.onClose()};return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)});var o=Tt(),s=Le(o);{var a=l=>{var c=YE(),d=x(c),u=x(d),h=k(x(u),2),p=k(u,2);ft(p,17,()=>f(t),g=>g.title,(g,y)=>{var w=qE(),_=x(w),S=x(_),A=k(_,2);ft(A,21,()=>f(y).rows,U=>U.description,(U,N)=>{var R=KE(),E=Le(R),q=x(E),te=x(q),K=k(E,2),V=x(K);G(()=>{ne(te,f(N).keys),ne(V,f(N).description)}),T(U,R)}),G(()=>ne(S,f(y).title)),T(g,w)});var m=k(p,2),v=k(x(m),2);ft(v,21,()=>kp,g=>g.description,(g,y)=>{var w=JE(),_=Le(w),S=x(_),A=x(S),U=k(_,2),N=x(U);G(()=>{ne(A,f(y).keys),ne(N,f(y).description)}),T(g,w)}),yt(d,g=>b(r,g),()=>f(r)),L("click",c,function(...g){var y;(y=e.onClose)==null||y.apply(this,g)}),L("click",d,g=>g.stopPropagation()),L("keydown",d,g=>{if(g.key==="Escape"){e.onClose();return}if(g.stopPropagation(),g.key==="Tab"&&f(r)){const y=Array.from(f(r).querySelectorAll('button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')).filter(S=>!S.closest("[hidden]"));if(y.length===0){g.preventDefault();return}const w=y[0],_=y[y.length-1];g.shiftKey&&document.activeElement===w?(g.preventDefault(),_.focus()):!g.shiftKey&&document.activeElement===_&&(g.preventDefault(),w.focus())}}),L("click",h,function(...g){var y;(y=e.onClose)==null||y.apply(this,g)}),T(l,c)};Z(s,l=>{e.open&&l(a)})}T(n,o),Ke()}Ye(["click","keydown"]);var ZE=O("Detected VM subnet: <code> </code>.",1),XE=O('<div data-testid="cowork-onboarding-error" role="alert" style="font-size: 12px; color: var(--tandem-error-fg-strong); background: var(--tandem-error-bg); border: 1px solid var(--tandem-error-border); border-radius: var(--tandem-r-2); padding: 6px 8px;"> </div>'),QE=O('<div data-testid="cowork-onboarding-confirm" style="font-size: 12px; color: var(--tandem-warning-fg-strong); background: var(--tandem-warning-bg); border: 1px solid var(--tandem-warning-border); border-radius: var(--tandem-r-2); padding: 8px 10px;"><div style="font-weight: 600; margin-bottom: 6px;">Confirm: Enable Cowork</div> <div style="margin-bottom: 8px;">Windows will prompt for admin permission to modify firewall rules. This is expected.</div> <div style="display: flex; gap: 8px;"><button data-testid="cowork-onboarding-enable-confirm-btn" type="button">Enable</button> <button data-testid="cowork-onboarding-enable-cancel-btn" type="button">Cancel</button></div></div>'),$E=O('<button data-testid="cowork-onboarding-learn-more-btn" type="button">Learn more</button>'),eM=O('<a data-testid="cowork-onboarding-learn-more-link" href="https://github.com/bloknayrb/tandem#cowork" target="_blank" rel="noreferrer" style="font-size: 12px; color: var(--tandem-accent); align-self: center; text-decoration: underline;">Learn more</a>'),tM=O('<div style="display: flex; gap: 8px; flex-wrap: wrap;"><button data-testid="cowork-onboarding-enable-btn" type="button">Enable</button> <button data-testid="cowork-onboarding-skip-btn" type="button">Skip</button> <!></div>'),nM=O('<div data-testid="cowork-onboarding-step" style="display: flex; flex-direction: column; gap: 8px;"><div style="font-size: 14px; font-weight: 600; color: var(--tandem-fg);">Claude Desktop Cowork detected</div> <div style="font-size: 13px; line-height: 1.5; color: var(--tandem-fg-muted);">Enable Tandem inside Cowork workspaces? <!></div> <!> <!></div>');function rM(n,e){We(e,!0);const t="padding: 4px 10px; font-size: 12px; border: 1px solid var(--tandem-accent); border-radius: var(--tandem-r-2); background: var(--tandem-accent); color: var(--tandem-accent-fg); cursor: pointer; font-weight: 600;",r="padding: 4px 10px; font-size: 12px; border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-2); background: var(--tandem-surface); color: var(--tandem-fg-muted); cursor: pointer;";let i=z(!1),o=z(!1),s=z(null);async function a(_,S){b(o,!0),b(s,null);try{const A=await Ym();return await _(A),!0}catch(A){const U=A instanceof Error?A.message:String(A),N=Hx(U);return b(s,`${S}: ${N}`),!1}finally{b(o,!1)}}async function l(){await a(async S=>{await Kx(S,!0)},"Failed to enable Cowork")&&e.onAdvance()}function c(){ME(),e.onAdvance()}var d=nM(),u=k(x(d),2),h=k(x(u));{var p=_=>{var S=ZE(),A=k(Le(S)),U=x(A);G(()=>ne(U,e.status.vethernetCidr)),T(_,S)};Z(h,_=>{e.status.vethernetCidr!==null&&_(p)})}var m=k(u,2);{var v=_=>{var S=XE(),A=x(S);G(()=>ne(A,f(s))),T(_,S)};Z(m,_=>{f(s)&&_(v)})}var g=k(m,2);{var y=_=>{var S=QE(),A=k(x(S),4),U=x(A);re(U,t);var N=k(U,2);re(N,r),G(()=>{U.disabled=f(o),N.disabled=f(o)}),L("click",U,()=>void l()),L("click",N,()=>{b(i,!1)}),T(_,S)},w=_=>{var S=tM(),A=x(S);re(A,t);var U=k(A,2);re(U,r);var N=k(U,2);{var R=q=>{var te=$E();re(te,r),G(()=>te.disabled=f(o)),L("click",te,function(...K){var V;(V=e.onLearnMore)==null||V.apply(this,K)}),T(q,te)},E=q=>{var te=eM();T(q,te)};Z(N,q=>{e.onLearnMore?q(R):q(E,-1)})}G(()=>{A.disabled=f(o),U.disabled=f(o)}),L("click",A,()=>{b(i,!0)}),L("click",U,c),T(_,S)};Z(g,_=>{f(i)?_(y):_(w,-1)})}T(n,d),Ke()}Ye(["click"]);var iM=O("<div></div>"),oM=O('<div style="display: flex; gap: var(--tandem-space-1); margin-bottom: var(--tandem-space-3);"></div>'),sM=O('<div style="font-size: var(--tandem-text-sm); font-weight: 600; color: var(--tandem-fg); margin-bottom: var(--tandem-space-1);"> </div> <div> </div>',1),aM=O('<div style="display: flex; justify-content: space-between; align-items: center;"><span style="font-size: var(--tandem-text-xs); color: var(--tandem-fg-subtle);"> </span> <div style="display: flex; gap: 12px; align-items: center;"><button data-testid="tutorial-dismiss-btn" style="background: none; border: none; cursor: pointer; font-size: var(--tandem-text-xs); color: var(--tandem-fg-subtle); padding: 0; text-decoration: underline;">Dismiss tutorial</button> <button data-testid="tutorial-next-btn" style="padding: var(--tandem-space-1) var(--tandem-space-3); font-size: var(--tandem-text-xs); border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-2); background: var(--tandem-surface); color: var(--tandem-fg-muted); cursor: pointer; font-weight: 500;"> </button></div></div>'),lM=O('<div data-testid="onboarding-tutorial" style="position: fixed; bottom: 48px; left: 24px; z-index: var(--tandem-z-overlay); max-width: 340px; background: var(--tandem-surface); border-left: 4px solid var(--tandem-accent); border-radius: var(--tandem-r-4); box-shadow: var(--tandem-shadow-2); padding: var(--tandem-space-4) var(--tandem-space-5); font-family: inherit;"><!> <!> <!></div>');function cM(n,e){We(e,!0);const t=[{id:"review",title:"Review an annotation",text:"Open the side panel and accept or dismiss one of the highlighted annotations. Try Review Mode (Ctrl+Shift+R) for keyboard shortcuts."},{id:"question",title:"Ask a question",text:"Select text and click Comment to send a question to Claude — or click Note to keep a private thought to yourself. You can also use the Chat panel."},{id:"edit",title:"Make an edit",text:"Click in the document and type something. All changes sync in real-time."},{id:"cowork",title:"Claude Desktop Cowork detected",text:""},{id:"complete",title:"You're ready!",text:"You've learned the basics. Press ? anytime to see keyboard shortcuts."}],r=Cr(),i=jx(),o=P(()=>r&&Ux(e.coworkStatus,i)),s=P(()=>t.filter(m=>m.id!=="cowork"||f(o))),a=P(()=>f(s).length-1),l=P(()=>f(s)[e.currentStep]),c=P(()=>e.currentStep>=f(a)),d=P(()=>{var m;return((m=f(l))==null?void 0:m.id)==="cowork"});var u=Tt(),h=Le(u);{var p=m=>{var v=lM(),g=x(v);{var y=N=>{var R=oM();ft(R,20,()=>Array.from({length:f(a)},(E,q)=>q),E=>E,(E,q)=>{var te=iM();G(()=>re(te,`width: var(--tandem-space-2); height: var(--tandem-space-2); border-radius: var(--tandem-r-circle); background: ${q<=e.currentStep?"var(--tandem-accent)":"var(--tandem-border)"}; transition: background 0.2s;`)),T(E,te)}),T(N,R)};Z(g,N=>{f(c)||N(y)})}var w=k(g,2);{var _=N=>{rM(N,{get status(){return e.coworkStatus},get onAdvance(){return e.onNext}})},S=N=>{var R=sM(),E=Le(R),q=x(E),te=k(E,2),K=x(te);G(()=>{ne(q,f(l).title),re(te,`font-size: var(--tandem-text-base); line-height: 1.5; color: var(--tandem-fg-muted); margin-bottom: ${f(c)?0:14}px;`),ne(K,f(l).text)}),T(N,R)};Z(w,N=>{f(d)&&e.coworkStatus!==null?N(_):N(S,-1)})}var A=k(w,2);{var U=N=>{var R=aM(),E=x(R),q=x(E),te=k(E,2),K=x(te),V=k(K,2),ee=x(V);G(()=>{ne(q,`Step ${e.currentStep+1} of ${f(a)??""}`),ne(ee,e.currentStep===f(a)-1?"Done":"Next")}),L("click",K,function(...se){var F;(F=e.onDismiss)==null||F.apply(this,se)}),L("click",V,function(...se){var F;(F=e.onNext)==null||F.apply(this,se)}),T(N,R)};Z(A,N=>{!f(c)&&!f(d)&&N(U)})}T(m,v)};Z(h,m=>{f(l)&&m(p)})}T(n,u),Ke()}Ye(["click"]);const br=()=>new Map,Sp=n=>{const e=br();return n.forEach((t,r)=>{e.set(r,t)}),e},mi=(n,e,t)=>{let r=n.get(e);return r===void 0&&n.set(e,r=t()),r},dM=(n,e)=>{const t=[];for(const[r,i]of n)t.push(e(i,r));return t},uM=(n,e)=>{for(const[t,r]of n)if(e(r,t))return!0;return!1},vs=()=>new Set,rh=n=>n[n.length-1],fM=(n,e)=>{for(let t=0;t<e.length;t++)n.push(e[t])},_o=Array.from,Gm=(n,e)=>{for(let t=0;t<n.length;t++)if(!e(n[t],t,n))return!1;return!0},Zm=(n,e)=>{for(let t=0;t<n.length;t++)if(e(n[t],t,n))return!0;return!1},hM=(n,e)=>{const t=new Array(n);for(let r=0;r<n;r++)t[r]=e(r,t);return t},xa=Array.isArray;class Jx{constructor(){this._observers=br()}on(e,t){return mi(this._observers,e,vs).add(t),t}once(e,t){const r=(...i)=>{this.off(e,r),t(...i)};this.on(e,r)}off(e,t){const r=this._observers.get(e);r!==void 0&&(r.delete(t),r.size===0&&this._observers.delete(e))}emit(e,t){return _o((this._observers.get(e)||br()).values()).forEach(r=>r(...t))}destroy(){this._observers=br()}}const Ir=Math.floor,pd=Math.abs,Pi=(n,e)=>n<e?n:e,Pr=(n,e)=>n>e?n:e,Yx=n=>n!==0?n<0:1/n<0,_y=1,Sy=2,ih=4,oh=8,zl=32,Li=64,Ln=128,pM=1<<29,sf=31,Cp=63,rs=127,mM=2147483647,Wd=Number.MAX_SAFE_INTEGER,Cy=Number.MIN_SAFE_INTEGER,gM=Number.isInteger||(n=>typeof n=="number"&&isFinite(n)&&Ir(n)===n),Gx=String.fromCharCode,vM=n=>n.toLowerCase(),yM=/^\s*/g,bM=n=>n.replace(yM,""),wM=/([A-Z])/g,Ty=(n,e)=>bM(n.replace(wM,t=>`${e}${vM(t)}`)),xM=n=>{const e=unescape(encodeURIComponent(n)),t=e.length,r=new Uint8Array(t);for(let i=0;i<t;i++)r[i]=e.codePointAt(i);return r},Bl=typeof TextEncoder<"u"?new TextEncoder:null,kM=n=>Bl.encode(n),_M=Bl?kM:xM;let dl=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});dl&&dl.decode(new Uint8Array).length===1&&(dl=null);const SM=(n,e)=>hM(e,()=>n).join("");let xc=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}};const kc=()=>new xc,CM=n=>{const e=kc();return n(e),Dr(e)},TM=n=>{let e=n.cpos;for(let t=0;t<n.bufs.length;t++)e+=n.bufs[t].length;return e},Dr=n=>{const e=new Uint8Array(TM(n));let t=0;for(let r=0;r<n.bufs.length;r++){const i=n.bufs[r];e.set(i,t),t+=i.length}return e.set(new Uint8Array(n.cbuf.buffer,0,n.cpos),t),e},AM=(n,e)=>{const t=n.cbuf.length;t-n.cpos<e&&(n.bufs.push(new Uint8Array(n.cbuf.buffer,0,n.cpos)),n.cbuf=new Uint8Array(Pr(t,e)*2),n.cpos=0)},tn=(n,e)=>{const t=n.cbuf.length;n.cpos===t&&(n.bufs.push(n.cbuf),n.cbuf=new Uint8Array(t*2),n.cpos=0),n.cbuf[n.cpos++]=e},Tp=tn,ot=(n,e)=>{for(;e>rs;)tn(n,Ln|rs&e),e=Ir(e/128);tn(n,rs&e)},Xm=(n,e)=>{const t=Yx(e);for(t&&(e=-e),tn(n,(e>Cp?Ln:0)|(t?Li:0)|Cp&e),e=Ir(e/64);e>0;)tn(n,(e>rs?Ln:0)|rs&e),e=Ir(e/128)},Ap=new Uint8Array(3e4),EM=Ap.length/3,MM=(n,e)=>{if(e.length<EM){const t=Bl.encodeInto(e,Ap).written||0;ot(n,t);for(let r=0;r<t;r++)tn(n,Ap[r])}else Yn(n,_M(e))},OM=(n,e)=>{const t=unescape(encodeURIComponent(e)),r=t.length;ot(n,r);for(let i=0;i<r;i++)tn(n,t.codePointAt(i))},Zs=Bl&&Bl.encodeInto?MM:OM,af=(n,e)=>{const t=n.cbuf.length,r=n.cpos,i=Pi(t-r,e.length),o=e.length-i;n.cbuf.set(e.subarray(0,i),r),n.cpos+=i,o>0&&(n.bufs.push(n.cbuf),n.cbuf=new Uint8Array(Pr(t*2,o)),n.cbuf.set(e.subarray(i)),n.cpos=o)},Yn=(n,e)=>{ot(n,e.byteLength),af(n,e)},Qm=(n,e)=>{AM(n,e);const t=new DataView(n.cbuf.buffer,n.cpos,e);return n.cpos+=e,t},DM=(n,e)=>Qm(n,4).setFloat32(0,e,!1),RM=(n,e)=>Qm(n,8).setFloat64(0,e,!1),NM=(n,e)=>Qm(n,8).setBigInt64(0,e,!1),Ay=new DataView(new ArrayBuffer(4)),IM=n=>(Ay.setFloat32(0,n),Ay.getFloat32(0)===n),ka=(n,e)=>{switch(typeof e){case"string":tn(n,119),Zs(n,e);break;case"number":gM(e)&&pd(e)<=mM?(tn(n,125),Xm(n,e)):IM(e)?(tn(n,124),DM(n,e)):(tn(n,123),RM(n,e));break;case"bigint":tn(n,122),NM(n,e);break;case"object":if(e===null)tn(n,126);else if(xa(e)){tn(n,117),ot(n,e.length);for(let t=0;t<e.length;t++)ka(n,e[t])}else if(e instanceof Uint8Array)tn(n,116),Yn(n,e);else{tn(n,118);const t=Object.keys(e);ot(n,t.length);for(let r=0;r<t.length;r++){const i=t[r];Zs(n,i),ka(n,e[i])}}break;case"boolean":tn(n,e?120:121);break;default:tn(n,127)}};class Ey extends xc{constructor(e){super(),this.w=e,this.s=null,this.count=0}write(e){this.s===e?this.count++:(this.count>0&&ot(this,this.count-1),this.count=1,this.w(this,e),this.s=e)}}const My=n=>{n.count>0&&(Xm(n.encoder,n.count===1?n.s:-n.s),n.count>1&&ot(n.encoder,n.count-2))};class md{constructor(){this.encoder=new xc,this.s=0,this.count=0}write(e){this.s===e?this.count++:(My(this),this.count=1,this.s=e)}toUint8Array(){return My(this),Dr(this.encoder)}}const Oy=n=>{if(n.count>0){const e=n.diff*2+(n.count===1?0:1);Xm(n.encoder,e),n.count>1&&ot(n.encoder,n.count-2)}};class sh{constructor(){this.encoder=new xc,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(Oy(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return Oy(this),Dr(this.encoder)}}class PM{constructor(){this.sarr=[],this.s="",this.lensE=new md}write(e){this.s+=e,this.s.length>19&&(this.sarr.push(this.s),this.s=""),this.lensE.write(e.length)}toUint8Array(){const e=new xc;return this.sarr.push(this.s),this.s="",Zs(e,this.sarr.join("")),af(e,this.lensE.toUint8Array()),Dr(e)}}const li=n=>new Error(n),wr=()=>{throw li("Method unimplemented")},_n=()=>{throw li("Unexpected case")},Zx=li("Unexpected end of array"),Xx=li("Integer out of Range");let lf=class{constructor(e){this.arr=e,this.pos=0}};const Pa=n=>new lf(n),LM=n=>n.pos!==n.arr.length,zM=(n,e)=>{const t=new Uint8Array(n.arr.buffer,n.pos+n.arr.byteOffset,e);return n.pos+=e,t},Gn=n=>zM(n,Xe(n)),_a=n=>n.arr[n.pos++],Xe=n=>{let e=0,t=1;const r=n.arr.length;for(;n.pos<r;){const i=n.arr[n.pos++];if(e=e+(i&rs)*t,t*=128,i<Ln)return e;if(e>Wd)throw Xx}throw Zx},$m=n=>{let e=n.arr[n.pos++],t=e&Cp,r=64;const i=(e&Li)>0?-1:1;if((e&Ln)===0)return i*t;const o=n.arr.length;for(;n.pos<o;){if(e=n.arr[n.pos++],t=t+(e&rs)*r,r*=128,e<Ln)return i*t;if(t>Wd)throw Xx}throw Zx},BM=n=>{let e=Xe(n);if(e===0)return"";{let t=String.fromCodePoint(_a(n));if(--e<100)for(;e--;)t+=String.fromCodePoint(_a(n));else for(;e>0;){const r=e<1e4?e:1e4,i=n.arr.subarray(n.pos,n.pos+r);n.pos+=r,t+=String.fromCodePoint.apply(null,i),e-=r}return decodeURIComponent(escape(t))}},FM=n=>dl.decode(Gn(n)),Xs=dl?FM:BM,eg=(n,e)=>{const t=new DataView(n.arr.buffer,n.arr.byteOffset+n.pos,e);return n.pos+=e,t},VM=n=>eg(n,4).getFloat32(0,!1),HM=n=>eg(n,8).getFloat64(0,!1),UM=n=>eg(n,8).getBigInt64(0,!1),jM=[n=>{},n=>null,$m,VM,HM,UM,n=>!1,n=>!0,Xs,n=>{const e=Xe(n),t={};for(let r=0;r<e;r++){const i=Xs(n);t[i]=Fl(n)}return t},n=>{const e=Xe(n),t=[];for(let r=0;r<e;r++)t.push(Fl(n));return t},Gn],Fl=n=>jM[127-_a(n)](n);class Dy extends lf{constructor(e,t){super(e),this.reader=t,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),LM(this)?this.count=Xe(this)+1:this.count=-1),this.count--,this.s}}class gd extends lf{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=$m(this);const e=Yx(this.s);this.count=1,e&&(this.s=-this.s,this.count=Xe(this)+2)}return this.count--,this.s}}class ah extends lf{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){const e=$m(this),t=e&1;this.diff=Ir(e/2),this.count=1,t&&(this.count=Xe(this)+2)}return this.s+=this.diff,this.count--,this.s}}class WM{constructor(e){this.decoder=new gd(e),this.str=Xs(this.decoder),this.spos=0}read(){const e=this.spos+this.decoder.read(),t=this.str.slice(this.spos,e);return this.spos=e,t}}const KM=crypto.getRandomValues.bind(crypto),qM=Math.random,Qx=()=>KM(new Uint32Array(1))[0],JM=n=>n[Ir(qM()*n.length)],YM="10000000-1000-4000-8000"+-1e11,GM=()=>YM.replace(/[018]/g,n=>(n^Qx()&15>>n/4).toString(16)),ZM=Date.now,Ry=n=>new Promise(n);Promise.all.bind(Promise);const Ny=n=>n===void 0?null:n;class XM{constructor(){this.map=new Map}setItem(e,t){this.map.set(e,t)}getItem(e){return this.map.get(e)}}let $x=new XM,QM=!0;try{typeof localStorage<"u"&&localStorage&&($x=localStorage,QM=!1)}catch{}const $M=$x,Vl=Symbol("Equality"),e1=(n,e)=>{var t;return n===e||!!((t=n==null?void 0:n[Vl])!=null&&t.call(n,e))||!1},e2=n=>typeof n=="object",t2=Object.assign,t1=Object.keys,n2=(n,e)=>{for(const t in n)e(n[t],t)},Kd=n=>t1(n).length,r2=n=>{for(const e in n)return!1;return!0},La=(n,e)=>{for(const t in n)if(!e(n[t],t))return!1;return!0},tg=(n,e)=>Object.prototype.hasOwnProperty.call(n,e),i2=(n,e)=>n===e||Kd(n)===Kd(e)&&La(n,(t,r)=>(t!==void 0||tg(e,r))&&e1(e[r],t)),o2=Object.freeze,n1=n=>{for(const e in n){const t=n[e];(typeof t=="object"||typeof t=="function")&&n1(n[e])}return o2(n)},ng=(n,e,t=0)=>{try{for(;t<n.length;t++)n[t](...e)}finally{t<n.length&&ng(n,e,t+1)}},s2=n=>n,vd=(n,e)=>{if(n===e)return!0;if(n==null||e==null||n.constructor!==e.constructor&&(n.constructor||Object)!==(e.constructor||Object))return!1;if(n[Vl]!=null)return n[Vl](e);switch(n.constructor){case ArrayBuffer:n=new Uint8Array(n),e=new Uint8Array(e);case Uint8Array:{if(n.byteLength!==e.byteLength)return!1;for(let t=0;t<n.length;t++)if(n[t]!==e[t])return!1;break}case Set:{if(n.size!==e.size)return!1;for(const t of n)if(!e.has(t))return!1;break}case Map:{if(n.size!==e.size)return!1;for(const t of n.keys())if(!e.has(t)||!vd(n.get(t),e.get(t)))return!1;break}case void 0:case Object:if(Kd(n)!==Kd(e))return!1;for(const t in n)if(!tg(n,t)||!vd(n[t],e[t]))return!1;break;case Array:if(n.length!==e.length)return!1;for(let t=0;t<n.length;t++)if(!vd(n[t],e[t]))return!1;break;default:return!1}return!0},a2=(n,e)=>e.includes(n);var r1={};const Sa=typeof process<"u"&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]",i1=typeof window<"u"&&typeof document<"u"&&!Sa;let Ur;const l2=()=>{if(Ur===void 0)if(Sa){Ur=br();const n=process.argv;let e=null;for(let t=0;t<n.length;t++){const r=n[t];r[0]==="-"?(e!==null&&Ur.set(e,""),e=r):e!==null&&(Ur.set(e,r),e=null)}e!==null&&Ur.set(e,"")}else typeof location=="object"?(Ur=br(),(location.search||"?").slice(1).split("&").forEach(n=>{if(n.length!==0){const[e,t]=n.split("=");Ur.set(`--${Ty(e,"-")}`,t),Ur.set(`-${Ty(e,"-")}`,t)}})):Ur=br();return Ur},Ep=n=>l2().has(n),qd=n=>Ny(Sa?r1[n.toUpperCase().replaceAll("-","_")]:$M.getItem(n)),o1=n=>Ep("--"+n)||qd(n)!==null,c2=o1("production"),d2=Sa&&a2(r1.FORCE_COLOR,["true","1","2"]),u2=d2||!Ep("--no-colors")&&!o1("no-color")&&(!Sa||process.stdout.isTTY)&&(!Sa||Ep("--color")||qd("COLORTERM")!==null||(qd("TERM")||"").includes("color")),f2=n=>new Uint8Array(n),h2=n=>{let e="";for(let t=0;t<n.byteLength;t++)e+=Gx(n[t]);return btoa(e)},p2=n=>Buffer.from(n.buffer,n.byteOffset,n.byteLength).toString("base64"),m2=i1?h2:p2,g2=n=>{const e=f2(n.byteLength);return e.set(n),e},v2=n=>CM(e=>ka(e,n));class y2{constructor(e,t){this.left=e,this.right=t}}const vi=(n,e)=>new y2(n,e),Iy=n=>n.next()>=.5,lh=(n,e,t)=>Ir(n.next()*(t+1-e)+e),s1=(n,e,t)=>Ir(n.next()*(t+1-e)+e),rg=(n,e,t)=>s1(n,e,t),b2=n=>Gx(rg(n,97,122)),w2=(n,e=0,t=20)=>{const r=rg(n,e,t);let i="";for(let o=0;o<r;o++)i+=b2(n);return i},ch=(n,e)=>e[rg(n,0,e.length-1)],x2=Symbol("0schema");class k2{constructor(){this._rerrs=[]}extend(e,t,r,i=null){this._rerrs.push({path:e,expected:t,has:r,message:i})}toString(){const e=[];for(let t=this._rerrs.length-1;t>0;t--){const r=this._rerrs[t];e.push(SM(" ",(this._rerrs.length-t)*2)+`${r.path!=null?`[${r.path}] `:""}${r.has} doesn't match ${r.expected}. ${r.message}`)}return e.join(`
|
|
45
|
-
`)}}const Mp=(n,e)=>n===e?!0:n==null||e==null||n.constructor!==e.constructor?!1:n[Vl]?e1(n,e):xa(n)?Gm(n,t=>Zm(e,r=>Mp(t,r))):e2(n)?La(n,(t,r)=>Mp(t,e[r])):!1;class En{extends(e){let[t,r]=[this.shape,e.shape];return this.constructor._dilutes&&([r,t]=[t,r]),Mp(t,r)}equals(e){return this.constructor===e.constructor&&vd(this.shape,e.shape)}[x2](){return!0}[Vl](e){return this.equals(e)}validate(e){return this.check(e)}check(e,t){wr()}get nullable(){return za(this,hf)}get optional(){return new c1(this)}cast(e){return Py(e,this),e}expect(e){return Py(e,this),e}}Vn(En,"_dilutes",!1);class ig extends En{constructor(e,t){super(),this.shape=e,this._c=t}check(e,t=void 0){const r=(e==null?void 0:e.constructor)===this.shape&&(this._c==null||this._c(e));return!r&&(t==null||t.extend(null,this.shape.name,e==null?void 0:e.constructor.name,(e==null?void 0:e.constructor)!==this.shape?"Constructor match failed":"Check failed")),r}}const Jt=(n,e=null)=>new ig(n,e);Jt(ig);class og extends En{constructor(e){super(),this.shape=e}check(e,t){const r=this.shape(e);return!r&&(t==null||t.extend(null,"custom prop",e==null?void 0:e.constructor.name,"failed to check custom prop")),r}}const ln=n=>new og(n);Jt(og);class cf extends En{constructor(e){super(),this.shape=e}check(e,t){const r=this.shape.some(i=>i===e);return!r&&(t==null||t.extend(null,this.shape.join(" | "),e.toString())),r}}const df=(...n)=>new cf(n),a1=Jt(cf),_2=RegExp.escape||(n=>n.replace(/[().|&,$^[\]]/g,e=>"\\"+e)),l1=n=>{if(Ca.check(n))return[_2(n)];if(a1.check(n))return n.shape.map(e=>e+"");if(y1.check(n))return["[+-]?\\d+.?\\d*"];if(b1.check(n))return[".*"];if(Yd.check(n))return n.shape.map(l1).flat(1);_n()};class S2 extends En{constructor(e){super(),this.shape=e,this._r=new RegExp("^"+e.map(l1).map(t=>`(${t.join("|")})`).join("")+"$")}check(e,t){const r=this._r.exec(e)!=null;return!r&&(t==null||t.extend(null,this._r.toString(),e.toString(),"String doesn't match string template.")),r}}Jt(S2);const C2=Symbol("optional");class c1 extends En{constructor(e){super(),this.shape=e}check(e,t){const r=e===void 0||this.shape.check(e);return!r&&(t==null||t.extend(null,"undefined (optional)","()")),r}get[C2](){return!0}}const T2=Jt(c1);class A2 extends En{check(e,t){return t==null||t.extend(null,"never",typeof e),!1}}Jt(A2);const Gu=class Gu extends En{constructor(e,t=!1){super(),this.shape=e,this._isPartial=t}get partial(){return new Gu(this.shape,!0)}check(e,t){return e==null?(t==null||t.extend(null,"object","null"),!1):La(this.shape,(r,i)=>{const o=this._isPartial&&!tg(e,i)||r.check(e[i],t);return!o&&(t==null||t.extend(i.toString(),r.toString(),typeof e[i],"Object property does not match")),o})}};Vn(Gu,"_dilutes",!0);let Jd=Gu;const E2=n=>new Jd(n),M2=Jt(Jd),O2=ln(n=>n!=null&&(n.constructor===Object||n.constructor==null));class d1 extends En{constructor(e,t){super(),this.shape={keys:e,values:t}}check(e,t){return e!=null&&La(e,(r,i)=>{const o=this.shape.keys.check(i,t);return!o&&(t==null||t.extend(i+"","Record",typeof e,o?"Key doesn't match schema":"Value doesn't match value")),o&&this.shape.values.check(r,t)})}}const u1=(n,e)=>new d1(n,e),D2=Jt(d1);class f1 extends En{constructor(e){super(),this.shape=e}check(e,t){return e!=null&&La(this.shape,(r,i)=>{const o=r.check(e[i],t);return!o&&(t==null||t.extend(i.toString(),"Tuple",typeof r)),o})}}const R2=(...n)=>new f1(n);Jt(f1);class h1 extends En{constructor(e){super(),this.shape=e.length===1?e[0]:new uf(e)}check(e,t){const r=xa(e)&&Gm(e,i=>this.shape.check(i));return!r&&(t==null||t.extend(null,"Array","")),r}}const p1=(...n)=>new h1(n),N2=Jt(h1),I2=ln(n=>xa(n));class m1 extends En{constructor(e,t){super(),this.shape=e,this._c=t}check(e,t){const r=e instanceof this.shape&&(this._c==null||this._c(e));return!r&&(t==null||t.extend(null,this.shape.name,e==null?void 0:e.constructor.name)),r}}const P2=(n,e=null)=>new m1(n,e);Jt(m1);const L2=P2(En);class z2 extends En{constructor(e){super(),this.len=e.length-1,this.args=R2(...e.slice(-1)),this.res=e[this.len]}check(e,t){const r=e.constructor===Function&&e.length<=this.len;return!r&&(t==null||t.extend(null,"function",typeof e)),r}}const B2=Jt(z2),F2=ln(n=>typeof n=="function");class V2 extends En{constructor(e){super(),this.shape=e}check(e,t){const r=Gm(this.shape,i=>i.check(e,t));return!r&&(t==null||t.extend(null,"Intersectinon",typeof e)),r}}Jt(V2,n=>n.shape.length>0);class uf extends En{constructor(e){super(),this.shape=e}check(e,t){const r=Zm(this.shape,i=>i.check(e,t));return t==null||t.extend(null,"Union",typeof e),r}}Vn(uf,"_dilutes",!0);const za=(...n)=>n.findIndex(e=>Yd.check(e))>=0?za(...n.map(e=>Hl(e)).map(e=>Yd.check(e)?e.shape:[e]).flat(1)):n.length===1?n[0]:new uf(n),Yd=Jt(uf),g1=()=>!0,Gd=ln(g1),H2=Jt(og,n=>n.shape===g1),sg=ln(n=>typeof n=="bigint"),U2=ln(n=>n===sg),v1=ln(n=>typeof n=="symbol");ln(n=>n===v1);const Qs=ln(n=>typeof n=="number"),y1=ln(n=>n===Qs),Ca=ln(n=>typeof n=="string"),b1=ln(n=>n===Ca),ff=ln(n=>typeof n=="boolean"),j2=ln(n=>n===ff),w1=df(void 0);Jt(cf,n=>n.shape.length===1&&n.shape[0]===void 0);df(void 0);const hf=df(null),W2=Jt(cf,n=>n.shape.length===1&&n.shape[0]===null);Jt(Uint8Array);Jt(ig,n=>n.shape===Uint8Array);const K2=za(Qs,Ca,hf,w1,sg,ff,v1);(()=>{const n=p1(Gd),e=u1(Ca,Gd),t=za(Qs,Ca,hf,ff,n,e);return n.shape=t,e.shape.values=t,t})();const Hl=n=>{if(L2.check(n))return n;if(O2.check(n)){const e={};for(const t in n)e[t]=Hl(n[t]);return E2(e)}else{if(I2.check(n))return za(...n.map(Hl));if(K2.check(n))return df(n);if(F2.check(n))return Jt(n)}_n()},Py=c2?()=>{}:(n,e)=>{const t=new k2;if(!e.check(n,t))throw li(`Expected value to be of type ${e.constructor.name}.
|
|
46
|
-
${t.toString()}`)};class q2{constructor(e){this.patterns=[],this.$state=e}if(e,t){return this.patterns.push({if:Hl(e),h:t}),this}else(e){return this.if(Gd,e)}done(){return(e,t)=>{for(let r=0;r<this.patterns.length;r++){const i=this.patterns[r];if(i.if.check(e))return i.h(e,t)}throw li("Unhandled pattern")}}}const J2=n=>new q2(n),x1=J2(Gd).if(y1,(n,e)=>lh(e,Cy,Wd)).if(b1,(n,e)=>w2(e)).if(j2,(n,e)=>Iy(e)).if(U2,(n,e)=>BigInt(lh(e,Cy,Wd))).if(Yd,(n,e)=>Is(e,ch(e,n.shape))).if(M2,(n,e)=>{const t={};for(const r in n.shape){let i=n.shape[r];if(T2.check(i)){if(Iy(e))continue;i=i.shape}t[r]=x1(i,e)}return t}).if(N2,(n,e)=>{const t=[],r=s1(e,0,42);for(let i=0;i<r;i++)t.push(Is(e,n.shape));return t}).if(a1,(n,e)=>ch(e,n.shape)).if(W2,(n,e)=>null).if(B2,(n,e)=>{const t=Is(e,n.res);return()=>t}).if(H2,(n,e)=>Is(e,ch(e,[Qs,Ca,hf,w1,sg,ff,p1(Qs),u1(za("a","b","c"),Qs)]))).if(D2,(n,e)=>{const t={},r=lh(e,0,3);for(let i=0;i<r;i++){const o=Is(e,n.shape.keys),s=Is(e,n.shape.values);t[o]=s}return t}).done(),Is=(n,e)=>x1(Hl(e),n),_c=typeof document<"u"?document:{};ln(n=>n.nodeType===Q2);typeof DOMParser<"u"&&new DOMParser;ln(n=>n.nodeType===G2);ln(n=>n.nodeType===Z2);const Y2=n=>dM(n,(e,t)=>`${t}:${e};`).join(""),G2=_c.ELEMENT_NODE,Z2=_c.TEXT_NODE,X2=_c.DOCUMENT_NODE,Q2=_c.DOCUMENT_FRAGMENT_NODE;ln(n=>n.nodeType===X2);const $2=n=>class{constructor(t){this._=t}destroy(){n(this._)}},eO=$2(clearTimeout),ag=(n,e)=>new eO(setTimeout(e,n)),Ki=Symbol,k1=Ki(),_1=Ki(),tO=Ki(),nO=Ki(),rO=Ki(),S1=Ki(),iO=Ki(),lg=Ki(),oO=Ki(),sO=n=>{var i;n.length===1&&((i=n[0])==null?void 0:i.constructor)===Function&&(n=n[0]());const e=[],t=[];let r=0;for(;r<n.length;r++){const o=n[r];if(o===void 0)break;if(o.constructor===String||o.constructor===Number)e.push(o);else if(o.constructor===Object)break}for(r>0&&t.push(e.join(""));r<n.length;r++){const o=n[r];o instanceof Symbol||t.push(o)}return t},aO={[k1]:vi("font-weight","bold"),[_1]:vi("font-weight","normal"),[tO]:vi("color","blue"),[rO]:vi("color","green"),[nO]:vi("color","grey"),[S1]:vi("color","red"),[iO]:vi("color","purple"),[lg]:vi("color","orange"),[oO]:vi("color","black")},lO=n=>{var s;n.length===1&&((s=n[0])==null?void 0:s.constructor)===Function&&(n=n[0]());const e=[],t=[],r=br();let i=[],o=0;for(;o<n.length;o++){const a=n[o],l=aO[a];if(l!==void 0)r.set(l.left,l.right);else{if(a===void 0)break;if(a.constructor===String||a.constructor===Number){const c=Y2(r);o>0||c.length>0?(e.push("%c"+a),t.push(c)):e.push(a)}else break}}for(o>0&&(i=t,i.unshift(e.join("")));o<n.length;o++){const a=n[o];a instanceof Symbol||i.push(a)}return i},C1=u2?lO:sO,cO=(...n)=>{console.log(...C1(n)),A1.forEach(e=>e.print(n))},T1=(...n)=>{console.warn(...C1(n)),n.unshift(lg),A1.forEach(e=>e.print(n))},A1=vs(),E1=n=>({[Symbol.iterator](){return this},next:n}),dO=(n,e)=>E1(()=>{let t;do t=n.next();while(!t.done&&!e(t.value));return t}),dh=(n,e)=>E1(()=>{const{done:t,value:r}=n.next();return{done:t,value:t?void 0:e(r)}});class pf{constructor(e,t){this.clock=e,this.len=t}}class Ba{constructor(){this.clients=new Map}}const So=(n,e,t)=>e.clients.forEach((r,i)=>{const o=n.doc.store.clients.get(i);if(o!=null){const s=o[o.length-1],a=s.id.clock+s.length;for(let l=0,c=r[l];l<r.length&&c.clock<a;c=r[++l])U1(n,o,c.clock,c.len,t)}}),uO=(n,e)=>{let t=0,r=n.length-1;for(;t<=r;){const i=Ir((t+r)/2),o=n[i],s=o.clock;if(s<=e){if(e<s+o.len)return i;t=i+1}else r=i-1}return null},Fa=(n,e)=>{const t=n.clients.get(e.client);return t!==void 0&&uO(t,e.clock)!==null},cg=n=>{n.clients.forEach(e=>{e.sort((i,o)=>i.clock-o.clock);let t,r;for(t=1,r=1;t<e.length;t++){const i=e[r-1],o=e[t];i.clock+i.len>=o.clock?e[r-1]=new pf(i.clock,Pr(i.len,o.clock+o.len-i.clock)):(r<t&&(e[r]=o),r++)}e.length=r})},Op=n=>{const e=new Ba;for(let t=0;t<n.length;t++)n[t].clients.forEach((r,i)=>{if(!e.clients.has(i)){const o=r.slice();for(let s=t+1;s<n.length;s++)fM(o,n[s].clients.get(i)||[]);e.clients.set(i,o)}});return cg(e),e},Ul=(n,e,t,r)=>{mi(n.clients,e,()=>[]).push(new pf(t,r))},M1=()=>new Ba,O1=n=>{const e=M1();return n.clients.forEach((t,r)=>{const i=[];for(let o=0;o<t.length;o++){const s=t[o];if(s.deleted){const a=s.id.clock;let l=s.length;if(o+1<t.length)for(let c=t[o+1];o+1<t.length&&c.deleted;c=t[++o+1])l+=c.length;i.push(new pf(a,l))}}i.length>0&&e.clients.set(r,i)}),e},Va=(n,e)=>{ot(n.restEncoder,e.clients.size),_o(e.clients.entries()).sort((t,r)=>r[0]-t[0]).forEach(([t,r])=>{n.resetDsCurVal(),ot(n.restEncoder,t);const i=r.length;ot(n.restEncoder,i);for(let o=0;o<i;o++){const s=r[o];n.writeDsClock(s.clock),n.writeDsLen(s.len)}})},dg=n=>{const e=new Ba,t=Xe(n.restDecoder);for(let r=0;r<t;r++){n.resetDsCurVal();const i=Xe(n.restDecoder),o=Xe(n.restDecoder);if(o>0){const s=mi(e.clients,i,()=>[]);for(let a=0;a<o;a++)s.push(new pf(n.readDsClock(),n.readDsLen()))}}return e},Ly=(n,e,t)=>{const r=new Ba,i=Xe(n.restDecoder);for(let o=0;o<i;o++){n.resetDsCurVal();const s=Xe(n.restDecoder),a=Xe(n.restDecoder),l=t.clients.get(s)||[],c=Ht(t,s);for(let d=0;d<a;d++){const u=n.readDsClock(),h=u+n.readDsLen();if(u<c){c<h&&Ul(r,s,c,h-c);let p=Lr(l,u),m=l[p];for(!m.deleted&&m.id.clock<u&&(l.splice(p+1,0,nu(e,m,u-m.id.clock)),p++);p<l.length&&(m=l[p++],m.id.clock<h);)m.deleted||(h<m.id.clock+m.length&&l.splice(p,0,nu(e,m,h-m.id.clock)),m.delete(e))}else Ul(r,s,u,h-u)}}if(r.clients.size>0){const o=new ys;return ot(o.restEncoder,0),Va(o,r),o.toUint8Array()}return null},D1=Qx;class ci extends Jx{constructor({guid:e=GM(),collectionid:t=null,gc:r=!0,gcFilter:i=()=>!0,meta:o=null,autoLoad:s=!1,shouldLoad:a=!0}={}){super(),this.gc=r,this.gcFilter=i,this.clientID=D1(),this.guid=e,this.collectionid=t,this.share=new Map,this.store=new V1,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=a,this.autoLoad=s,this.meta=o,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=Ry(c=>{this.on("load",()=>{this.isLoaded=!0,c(this)})});const l=()=>Ry(c=>{const d=u=>{(u===void 0||u===!0)&&(this.off("sync",d),c())};this.on("sync",d)});this.on("sync",c=>{c===!1&&this.isSynced&&(this.whenSynced=l()),this.isSynced=c===void 0||c===!0,this.isSynced&&!this.isLoaded&&this.emit("load",[this])}),this.whenSynced=l()}load(){const e=this._item;e!==null&&!this.shouldLoad&&bt(e.parent.doc,t=>{t.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(_o(this.subdocs).map(e=>e.guid))}transact(e,t=null){return bt(this,e,t)}get(e,t=on){const r=mi(this.share,e,()=>{const o=new t;return o._integrate(this,null),o}),i=r.constructor;if(t!==on&&i!==t)if(i===on){const o=new t;o._map=r._map,r._map.forEach(s=>{for(;s!==null;s=s.left)s.parent=o}),o._start=r._start;for(let s=o._start;s!==null;s=s.right)s.parent=o;return o._length=r._length,this.share.set(e,o),o._integrate(this,null),o}else throw new Error(`Type with the name ${e} has already been defined with a different constructor`);return r}getArray(e=""){return this.get(e,ta)}getText(e=""){return this.get(e,Co)}getMap(e=""){return this.get(e,Aa)}getXmlElement(e=""){return this.get(e,Wt)}getXmlFragment(e=""){return this.get(e,bs)}toJSON(){const e={};return this.share.forEach((t,r)=>{e[r]=t.toJSON()}),e}destroy(){this.isDestroyed=!0,_o(this.subdocs).forEach(t=>t.destroy());const e=this._item;if(e!==null){this._item=null;const t=e.content;t.doc=new ci({guid:this.guid,...t.opts,shouldLoad:!1}),t.doc._item=e,bt(e.parent.doc,r=>{const i=t.doc;e.deleted||r.subdocsAdded.add(i),r.subdocsRemoved.add(this)},null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}}class R1{constructor(e){this.restDecoder=e}resetDsCurVal(){}readDsClock(){return Xe(this.restDecoder)}readDsLen(){return Xe(this.restDecoder)}}class N1 extends R1{readLeftID(){return je(Xe(this.restDecoder),Xe(this.restDecoder))}readRightID(){return je(Xe(this.restDecoder),Xe(this.restDecoder))}readClient(){return Xe(this.restDecoder)}readInfo(){return _a(this.restDecoder)}readString(){return Xs(this.restDecoder)}readParentInfo(){return Xe(this.restDecoder)===1}readTypeRef(){return Xe(this.restDecoder)}readLen(){return Xe(this.restDecoder)}readAny(){return Fl(this.restDecoder)}readBuf(){return g2(Gn(this.restDecoder))}readJSON(){return JSON.parse(Xs(this.restDecoder))}readKey(){return Xs(this.restDecoder)}}class fO{constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=Xe(this.restDecoder),this.dsCurrVal}readDsLen(){const e=Xe(this.restDecoder)+1;return this.dsCurrVal+=e,e}}class Ta extends fO{constructor(e){super(e),this.keys=[],Xe(e),this.keyClockDecoder=new ah(Gn(e)),this.clientDecoder=new gd(Gn(e)),this.leftClockDecoder=new ah(Gn(e)),this.rightClockDecoder=new ah(Gn(e)),this.infoDecoder=new Dy(Gn(e),_a),this.stringDecoder=new WM(Gn(e)),this.parentInfoDecoder=new Dy(Gn(e),_a),this.typeRefDecoder=new gd(Gn(e)),this.lenDecoder=new gd(Gn(e))}readLeftID(){return new $s(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new $s(this.clientDecoder.read(),this.rightClockDecoder.read())}readClient(){return this.clientDecoder.read()}readInfo(){return this.infoDecoder.read()}readString(){return this.stringDecoder.read()}readParentInfo(){return this.parentInfoDecoder.read()===1}readTypeRef(){return this.typeRefDecoder.read()}readLen(){return this.lenDecoder.read()}readAny(){return Fl(this.restDecoder)}readBuf(){return Gn(this.restDecoder)}readJSON(){return Fl(this.restDecoder)}readKey(){const e=this.keyClockDecoder.read();if(e<this.keys.length)return this.keys[e];{const t=this.stringDecoder.read();return this.keys.push(t),t}}}class I1{constructor(){this.restEncoder=kc()}toUint8Array(){return Dr(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){ot(this.restEncoder,e)}writeDsLen(e){ot(this.restEncoder,e)}}class Sc extends I1{writeLeftID(e){ot(this.restEncoder,e.client),ot(this.restEncoder,e.clock)}writeRightID(e){ot(this.restEncoder,e.client),ot(this.restEncoder,e.clock)}writeClient(e){ot(this.restEncoder,e)}writeInfo(e){Tp(this.restEncoder,e)}writeString(e){Zs(this.restEncoder,e)}writeParentInfo(e){ot(this.restEncoder,e?1:0)}writeTypeRef(e){ot(this.restEncoder,e)}writeLen(e){ot(this.restEncoder,e)}writeAny(e){ka(this.restEncoder,e)}writeBuf(e){Yn(this.restEncoder,e)}writeJSON(e){Zs(this.restEncoder,JSON.stringify(e))}writeKey(e){Zs(this.restEncoder,e)}}class P1{constructor(){this.restEncoder=kc(),this.dsCurrVal=0}toUint8Array(){return Dr(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){const t=e-this.dsCurrVal;this.dsCurrVal=e,ot(this.restEncoder,t)}writeDsLen(e){e===0&&_n(),ot(this.restEncoder,e-1),this.dsCurrVal+=e}}class ys extends P1{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new sh,this.clientEncoder=new md,this.leftClockEncoder=new sh,this.rightClockEncoder=new sh,this.infoEncoder=new Ey(Tp),this.stringEncoder=new PM,this.parentInfoEncoder=new Ey(Tp),this.typeRefEncoder=new md,this.lenEncoder=new md}toUint8Array(){const e=kc();return ot(e,0),Yn(e,this.keyClockEncoder.toUint8Array()),Yn(e,this.clientEncoder.toUint8Array()),Yn(e,this.leftClockEncoder.toUint8Array()),Yn(e,this.rightClockEncoder.toUint8Array()),Yn(e,Dr(this.infoEncoder)),Yn(e,this.stringEncoder.toUint8Array()),Yn(e,Dr(this.parentInfoEncoder)),Yn(e,this.typeRefEncoder.toUint8Array()),Yn(e,this.lenEncoder.toUint8Array()),af(e,Dr(this.restEncoder)),Dr(e)}writeLeftID(e){this.clientEncoder.write(e.client),this.leftClockEncoder.write(e.clock)}writeRightID(e){this.clientEncoder.write(e.client),this.rightClockEncoder.write(e.clock)}writeClient(e){this.clientEncoder.write(e)}writeInfo(e){this.infoEncoder.write(e)}writeString(e){this.stringEncoder.write(e)}writeParentInfo(e){this.parentInfoEncoder.write(e?1:0)}writeTypeRef(e){this.typeRefEncoder.write(e)}writeLen(e){this.lenEncoder.write(e)}writeAny(e){ka(this.restEncoder,e)}writeBuf(e){Yn(this.restEncoder,e)}writeJSON(e){ka(this.restEncoder,e)}writeKey(e){const t=this.keyMap.get(e);t===void 0?(this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(e)):this.keyClockEncoder.write(t)}}const hO=(n,e,t,r)=>{r=Pr(r,e[0].id.clock);const i=Lr(e,r);ot(n.restEncoder,e.length-i),n.writeClient(t),ot(n.restEncoder,r);const o=e[i];o.write(n,r-o.id.clock);for(let s=i+1;s<e.length;s++)e[s].write(n,0)},ug=(n,e,t)=>{const r=new Map;t.forEach((i,o)=>{Ht(e,o)>i&&r.set(o,i)}),Cc(e).forEach((i,o)=>{t.has(o)||r.set(o,0)}),ot(n.restEncoder,r.size),_o(r.entries()).sort((i,o)=>o[0]-i[0]).forEach(([i,o])=>{hO(n,e.clients.get(i),i,o)})},pO=(n,e)=>{const t=br(),r=Xe(n.restDecoder);for(let i=0;i<r;i++){const o=Xe(n.restDecoder),s=new Array(o),a=n.readClient();let l=Xe(n.restDecoder);t.set(a,{i:0,refs:s});for(let c=0;c<o;c++){const d=n.readInfo();switch(sf&d){case 0:{const u=n.readLen();s[c]=new pr(je(a,l),u),l+=u;break}case 10:{const u=Xe(n.restDecoder);s[c]=new mr(je(a,l),u),l+=u;break}default:{const u=(d&(Li|Ln))===0,h=new kt(je(a,l),null,(d&Ln)===Ln?n.readLeftID():null,null,(d&Li)===Li?n.readRightID():null,u?n.readParentInfo()?e.get(n.readString()):n.readLeftID():null,u&&(d&zl)===zl?n.readString():null,dk(n,d));s[c]=h,l+=h.length}}}}return t},mO=(n,e,t)=>{const r=[];let i=_o(t.keys()).sort((p,m)=>p-m);if(i.length===0)return null;const o=()=>{if(i.length===0)return null;let p=t.get(i[i.length-1]);for(;p.refs.length===p.i;)if(i.pop(),i.length>0)p=t.get(i[i.length-1]);else return null;return p};let s=o();if(s===null)return null;const a=new V1,l=new Map,c=(p,m)=>{const v=l.get(p);(v==null||v>m)&&l.set(p,m)};let d=s.refs[s.i++];const u=new Map,h=()=>{for(const p of r){const m=p.id.client,v=t.get(m);v?(v.i--,a.clients.set(m,v.refs.slice(v.i)),t.delete(m),v.i=0,v.refs=[]):a.clients.set(m,[p]),i=i.filter(g=>g!==m)}r.length=0};for(;;){if(d.constructor!==mr){const m=mi(u,d.id.client,()=>Ht(e,d.id.client))-d.id.clock;if(m<0)r.push(d),c(d.id.client,d.id.clock-1),h();else{const v=d.getMissing(n,e);if(v!==null){r.push(d);const g=t.get(v)||{refs:[],i:0};if(g.refs.length===g.i)c(v,Ht(e,v)),h();else{d=g.refs[g.i++];continue}}else(m===0||m<d.length)&&(d.integrate(n,m),u.set(d.id.client,d.id.clock+d.length))}}if(r.length>0)d=r.pop();else if(s!==null&&s.i<s.refs.length)d=s.refs[s.i++];else{if(s=o(),s===null)break;d=s.refs[s.i++]}}if(a.clients.size>0){const p=new ys;return ug(p,a,new Map),ot(p.restEncoder,0),{missing:l,update:p.toUint8Array()}}return null},gO=(n,e)=>ug(n,e.doc.store,e.beforeState),vO=(n,e,t,r=new Ta(n))=>bt(e,i=>{i.local=!1;let o=!1;const s=i.doc,a=s.store,l=pO(r,s),c=mO(i,a,l),d=a.pendingStructs;if(d){for(const[h,p]of d.missing)if(p<Ht(a,h)){o=!0;break}if(c){for(const[h,p]of c.missing){const m=d.missing.get(h);(m==null||m>p)&&d.missing.set(h,p)}d.update=Xd([d.update,c.update])}}else a.pendingStructs=c;const u=Ly(r,i,a);if(a.pendingDs){const h=new Ta(Pa(a.pendingDs));Xe(h.restDecoder);const p=Ly(h,i,a);u&&p?a.pendingDs=Xd([u,p]):a.pendingDs=u||p}else a.pendingDs=u;if(o){const h=a.pendingStructs.update;a.pendingStructs=null,Zd(i.doc,h)}},t,!1),Zd=(n,e,t,r=Ta)=>{const i=Pa(e);vO(i,n,t,new r(i))},yO=(n,e,t)=>Zd(n,e,t,N1),bO=(n,e,t=new Map)=>{ug(n,e.store,t),Va(n,O1(e.store))},wO=(n,e=new Uint8Array([0]),t=new ys)=>{const r=L1(e);bO(t,n,r);const i=[t.toUint8Array()];if(n.store.pendingDs&&i.push(n.store.pendingDs),n.store.pendingStructs&&i.push(FO(n.store.pendingStructs.update,e)),i.length>1){if(t.constructor===Sc)return zO(i.map((o,s)=>s===0?o:HO(o)));if(t.constructor===ys)return Xd(i)}return i[0]},xO=(n,e)=>wO(n,e,new Sc),kO=n=>{const e=new Map,t=Xe(n.restDecoder);for(let r=0;r<t;r++){const i=Xe(n.restDecoder),o=Xe(n.restDecoder);e.set(i,o)}return e},L1=n=>kO(new R1(Pa(n))),z1=(n,e)=>(ot(n.restEncoder,e.size),_o(e.entries()).sort((t,r)=>r[0]-t[0]).forEach(([t,r])=>{ot(n.restEncoder,t),ot(n.restEncoder,r)}),n),_O=(n,e)=>z1(n,Cc(e.store)),SO=(n,e=new P1)=>(n instanceof Map?z1(e,n):_O(e,n),e.toUint8Array()),CO=n=>SO(n,new I1);class TO{constructor(){this.l=[]}}const zy=()=>new TO,By=(n,e)=>n.l.push(e),Fy=(n,e)=>{const t=n.l,r=t.length;n.l=t.filter(i=>e!==i),r===n.l.length&&console.error("[yjs] Tried to remove event handler that doesn't exist.")},B1=(n,e,t)=>ng(n.l,[e,t]);class $s{constructor(e,t){this.client=e,this.clock=t}}const qs=(n,e)=>n===e||n!==null&&e!==null&&n.client===e.client&&n.clock===e.clock,je=(n,e)=>new $s(n,e),jl=n=>{for(const[e,t]of n.doc.share.entries())if(t===n)return e;throw _n()},Wl=(n,e)=>{for(;e!==null;){if(e.parent===n)return!0;e=e.parent._item}return!1};class Kl{constructor(e,t,r,i=0){this.type=e,this.tname=t,this.item=r,this.assoc=i}}const is=n=>new Kl(n.type==null?null:je(n.type.client,n.type.clock),n.tname??null,n.item==null?null:je(n.item.client,n.item.clock),n.assoc==null?0:n.assoc);class AO{constructor(e,t,r=0){this.type=e,this.index=t,this.assoc=r}}const EO=(n,e,t=0)=>new AO(n,e,t),Fc=(n,e,t)=>{let r=null,i=null;return n._item===null?i=jl(n):r=je(n._item.id.client,n._item.id.clock),new Kl(r,i,e,t)},uh=(n,e,t=0)=>{let r=n._start;if(t<0){if(e===0)return Fc(n,null,t);e--}for(;r!==null;){if(!r.deleted&&r.countable){if(r.length>e)return Fc(n,je(r.id.client,r.id.clock+e),t);e-=r.length}if(r.right===null&&t<0)return Fc(n,r.lastId,t);r=r.right}return Fc(n,null,t)},MO=(n,e)=>{const t=ea(n,e),r=e.clock-t.id.clock;return{item:t,diff:r}},Dp=(n,e,t=!0)=>{const r=e.store,i=n.item,o=n.type,s=n.tname,a=n.assoc;let l=null,c=0;if(i!==null){if(Ht(r,i.client)<=i.clock)return null;const d=t?Pp(r,i):MO(r,i),u=d.item;if(!(u instanceof kt))return null;if(l=u.parent,l._item===null||!l._item.deleted){c=u.deleted||!u.countable?0:d.diff+(a>=0?0:1);let h=u.left;for(;h!==null;)!h.deleted&&h.countable&&(c+=h.length),h=h.left}}else{if(s!==null)l=e.get(s);else if(o!==null){if(Ht(r,o.client)<=o.clock)return null;const{item:d}=t?Pp(r,o):{item:ea(r,o)};if(d instanceof kt&&d.content instanceof Fr)l=d.content.type;else return null}else throw _n();a>=0?c=l._length:c=0}return EO(l,c,n.assoc)},Vy=(n,e)=>n===e||n!==null&&e!==null&&n.tname===e.tname&&qs(n.item,e.item)&&qs(n.type,e.type)&&n.assoc===e.assoc;class fg{constructor(e,t){this.ds=e,this.sv=t}}const F1=(n,e)=>new fg(n,e),fh=n=>F1(O1(n.store),Cc(n.store)),Lo=(n,e)=>e===void 0?!n.deleted:e.sv.has(n.id.client)&&(e.sv.get(n.id.client)||0)>n.id.clock&&!Fa(e.ds,n.id),Rp=(n,e)=>{const t=mi(n.meta,Rp,vs),r=n.doc.store;t.has(e)||(e.sv.forEach((i,o)=>{i<Ht(r,o)&&Wn(n,je(o,i))}),So(n,e.ds,i=>{}),t.add(e))};class V1{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}}const Cc=n=>{const e=new Map;return n.clients.forEach((t,r)=>{const i=t[t.length-1];e.set(r,i.id.clock+i.length)}),e},Ht=(n,e)=>{const t=n.clients.get(e);if(t===void 0)return 0;const r=t[t.length-1];return r.id.clock+r.length},H1=(n,e)=>{let t=n.clients.get(e.id.client);if(t===void 0)t=[],n.clients.set(e.id.client,t);else{const r=t[t.length-1];if(r.id.clock+r.length!==e.id.clock)throw _n()}t.push(e)},Lr=(n,e)=>{let t=0,r=n.length-1,i=n[r],o=i.id.clock;if(o===e)return r;let s=Ir(e/(o+i.length-1)*r);for(;t<=r;){if(i=n[s],o=i.id.clock,o<=e){if(e<o+i.length)return s;t=s+1}else r=s-1;s=Ir((t+r)/2)}throw _n()},OO=(n,e)=>{const t=n.clients.get(e.client);return t[Lr(t,e.clock)]},ea=OO,Np=(n,e,t)=>{const r=Lr(e,t),i=e[r];return i.id.clock<t&&i instanceof kt?(e.splice(r+1,0,nu(n,i,t-i.id.clock)),r+1):r},Wn=(n,e)=>{const t=n.doc.store.clients.get(e.client);return t[Np(n,t,e.clock)]},Hy=(n,e,t)=>{const r=e.clients.get(t.client),i=Lr(r,t.clock),o=r[i];return t.clock!==o.id.clock+o.length-1&&o.constructor!==pr&&r.splice(i+1,0,nu(n,o,t.clock-o.id.clock+1)),o},DO=(n,e,t)=>{const r=n.clients.get(e.id.client);r[Lr(r,e.id.clock)]=t},U1=(n,e,t,r,i)=>{if(r===0)return;const o=t+r;let s=Np(n,e,t),a;do a=e[s++],o<a.id.clock+a.length&&Np(n,e,o),i(a);while(s<e.length&&e[s].id.clock<o)};class RO{constructor(e,t,r){this.doc=e,this.deleteSet=new Ba,this.beforeState=Cc(e.store),this.afterState=new Map,this.changed=new Map,this.changedParentTypes=new Map,this._mergeStructs=[],this.origin=t,this.meta=new Map,this.local=r,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}}const Uy=(n,e)=>e.deleteSet.clients.size===0&&!uM(e.afterState,(t,r)=>e.beforeState.get(r)!==t)?!1:(cg(e.deleteSet),gO(n,e),Va(n,e.deleteSet),!0),jy=(n,e,t)=>{const r=e._item;(r===null||r.id.clock<(n.beforeState.get(r.id.client)||0)&&!r.deleted)&&mi(n.changed,e,vs).add(t)},yd=(n,e)=>{let t=n[e],r=n[e-1],i=e;for(;i>0;t=r,r=n[--i-1]){if(r.deleted===t.deleted&&r.constructor===t.constructor&&r.mergeWith(t)){t instanceof kt&&t.parentSub!==null&&t.parent._map.get(t.parentSub)===t&&t.parent._map.set(t.parentSub,r);continue}break}const o=e-i;return o&&n.splice(e+1-o,o),o},NO=(n,e,t)=>{for(const[r,i]of n.clients.entries()){const o=e.clients.get(r);for(let s=i.length-1;s>=0;s--){const a=i[s],l=a.clock+a.len;for(let c=Lr(o,a.clock),d=o[c];c<o.length&&d.id.clock<l;d=o[++c]){const u=o[c];if(a.clock+a.len<=u.id.clock)break;u instanceof kt&&u.deleted&&!u.keep&&t(u)&&u.gc(e,!1)}}}},IO=(n,e)=>{n.clients.forEach((t,r)=>{const i=e.clients.get(r);for(let o=t.length-1;o>=0;o--){const s=t[o],a=Pi(i.length-1,1+Lr(i,s.clock+s.len-1));for(let l=a,c=i[l];l>0&&c.id.clock>=s.clock;c=i[l])l-=1+yd(i,l)}})},j1=(n,e)=>{if(e<n.length){const t=n[e],r=t.doc,i=r.store,o=t.deleteSet,s=t._mergeStructs;try{cg(o),t.afterState=Cc(t.doc.store),r.emit("beforeObserverCalls",[t,r]);const a=[];t.changed.forEach((l,c)=>a.push(()=>{(c._item===null||!c._item.deleted)&&c._callObserver(t,l)})),a.push(()=>{t.changedParentTypes.forEach((l,c)=>{c._dEH.l.length>0&&(c._item===null||!c._item.deleted)&&(l=l.filter(d=>d.target._item===null||!d.target._item.deleted),l.forEach(d=>{d.currentTarget=c,d._path=null}),l.sort((d,u)=>d.path.length-u.path.length),a.push(()=>{B1(c._dEH,l,t)}))}),a.push(()=>r.emit("afterTransaction",[t,r])),a.push(()=>{t._needFormattingCleanup&&tD(t)})}),ng(a,[])}finally{r.gc&&NO(o,i,r.gcFilter),IO(o,i),t.afterState.forEach((d,u)=>{const h=t.beforeState.get(u)||0;if(h!==d){const p=i.clients.get(u),m=Pr(Lr(p,h),1);for(let v=p.length-1;v>=m;)v-=1+yd(p,v)}});for(let d=s.length-1;d>=0;d--){const{client:u,clock:h}=s[d].id,p=i.clients.get(u),m=Lr(p,h);m+1<p.length&&yd(p,m+1)>1||m>0&&yd(p,m)}if(!t.local&&t.afterState.get(r.clientID)!==t.beforeState.get(r.clientID)&&(cO(lg,k1,"[yjs] ",_1,S1,"Changed the client-id because another client seems to be using it."),r.clientID=D1()),r.emit("afterTransactionCleanup",[t,r]),r._observers.has("update")){const d=new Sc;Uy(d,t)&&r.emit("update",[d.toUint8Array(),t.origin,r,t])}if(r._observers.has("updateV2")){const d=new ys;Uy(d,t)&&r.emit("updateV2",[d.toUint8Array(),t.origin,r,t])}const{subdocsAdded:a,subdocsLoaded:l,subdocsRemoved:c}=t;(a.size>0||c.size>0||l.size>0)&&(a.forEach(d=>{d.clientID=r.clientID,d.collectionid==null&&(d.collectionid=r.collectionid),r.subdocs.add(d)}),c.forEach(d=>r.subdocs.delete(d)),r.emit("subdocs",[{loaded:l,added:a,removed:c},r,t]),c.forEach(d=>d.destroy())),n.length<=e+1?(r._transactionCleanups=[],r.emit("afterAllTransactions",[r,n])):j1(n,e+1)}}},bt=(n,e,t=null,r=!0)=>{const i=n._transactionCleanups;let o=!1,s=null;n._transaction===null&&(o=!0,n._transaction=new RO(n,t,r),i.push(n._transaction),i.length===1&&n.emit("beforeAllTransactions",[n]),n.emit("beforeTransaction",[n._transaction,n]));try{s=e(n._transaction)}finally{if(o){const a=n._transaction===i[0];n._transaction=null,a&&j1(i,0)}}return s};class PO{constructor(e,t){this.insertions=t,this.deletions=e,this.meta=new Map}}const Wy=(n,e,t)=>{So(n,t.deletions,r=>{r instanceof kt&&e.scope.some(i=>i===n.doc||Wl(i,r))&&wg(r,!1)})},Ky=(n,e,t)=>{let r=null;const i=n.doc,o=n.scope;bt(i,a=>{for(;e.length>0&&n.currStackItem===null;){const l=i.store,c=e.pop(),d=new Set,u=[];let h=!1;So(a,c.insertions,p=>{if(p instanceof kt){if(p.redone!==null){let{item:m,diff:v}=Pp(l,p.id);v>0&&(m=Wn(a,je(m.id.client,m.id.clock+v))),p=m}!p.deleted&&o.some(m=>m===a.doc||Wl(m,p))&&u.push(p)}}),So(a,c.deletions,p=>{p instanceof kt&&o.some(m=>m===a.doc||Wl(m,p))&&!Fa(c.insertions,p.id)&&d.add(p)}),d.forEach(p=>{h=ck(a,p,d,c.insertions,n.ignoreRemoteMapChanges,n)!==null||h});for(let p=u.length-1;p>=0;p--){const m=u[p];n.deleteFilter(m)&&(m.delete(a),h=!0)}n.currStackItem=h?c:null}a.changed.forEach((l,c)=>{l.has(null)&&c._searchMarker&&(c._searchMarker.length=0)}),r=a},n);const s=n.currStackItem;if(s!=null){const a=r.changedParentTypes;n.emit("stack-item-popped",[{stackItem:s,type:t,changedParentTypes:a,origin:n},n]),n.currStackItem=null}return s};class W1 extends Jx{constructor(e,{captureTimeout:t=500,captureTransaction:r=l=>!0,deleteFilter:i=()=>!0,trackedOrigins:o=new Set([null]),ignoreRemoteMapChanges:s=!1,doc:a=xa(e)?e[0].doc:e instanceof ci?e:e.doc}={}){super(),this.scope=[],this.doc=a,this.addToScope(e),this.deleteFilter=i,o.add(this),this.trackedOrigins=o,this.captureTransaction=r,this.undoStack=[],this.redoStack=[],this.undoing=!1,this.redoing=!1,this.currStackItem=null,this.lastChange=0,this.ignoreRemoteMapChanges=s,this.captureTimeout=t,this.afterTransactionHandler=l=>{if(!this.captureTransaction(l)||!this.scope.some(g=>l.changedParentTypes.has(g)||g===this.doc)||!this.trackedOrigins.has(l.origin)&&(!l.origin||!this.trackedOrigins.has(l.origin.constructor)))return;const c=this.undoing,d=this.redoing,u=c?this.redoStack:this.undoStack;c?this.stopCapturing():d||this.clear(!1,!0);const h=new Ba;l.afterState.forEach((g,y)=>{const w=l.beforeState.get(y)||0,_=g-w;_>0&&Ul(h,y,w,_)});const p=ZM();let m=!1;if(this.lastChange>0&&p-this.lastChange<this.captureTimeout&&u.length>0&&!c&&!d){const g=u[u.length-1];g.deletions=Op([g.deletions,l.deleteSet]),g.insertions=Op([g.insertions,h])}else u.push(new PO(l.deleteSet,h)),m=!0;!c&&!d&&(this.lastChange=p),So(l,l.deleteSet,g=>{g instanceof kt&&this.scope.some(y=>y===l.doc||Wl(y,g))&&wg(g,!0)});const v=[{stackItem:u[u.length-1],origin:l.origin,type:c?"redo":"undo",changedParentTypes:l.changedParentTypes},this];m?this.emit("stack-item-added",v):this.emit("stack-item-updated",v)},this.doc.on("afterTransaction",this.afterTransactionHandler),this.doc.on("destroy",()=>{this.destroy()})}addToScope(e){const t=new Set(this.scope);e=xa(e)?e:[e],e.forEach(r=>{t.has(r)||(t.add(r),(r instanceof on?r.doc!==this.doc:r!==this.doc)&&T1("[yjs#509] Not same Y.Doc"),this.scope.push(r))})}addTrackedOrigin(e){this.trackedOrigins.add(e)}removeTrackedOrigin(e){this.trackedOrigins.delete(e)}clear(e=!0,t=!0){(e&&this.canUndo()||t&&this.canRedo())&&this.doc.transact(r=>{e&&(this.undoStack.forEach(i=>Wy(r,this,i)),this.undoStack=[]),t&&(this.redoStack.forEach(i=>Wy(r,this,i)),this.redoStack=[]),this.emit("stack-cleared",[{undoStackCleared:e,redoStackCleared:t}])})}stopCapturing(){this.lastChange=0}undo(){this.undoing=!0;let e;try{e=Ky(this,this.undoStack,"undo")}finally{this.undoing=!1}return e}redo(){this.redoing=!0;let e;try{e=Ky(this,this.redoStack,"redo")}finally{this.redoing=!1}return e}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}destroy(){this.trackedOrigins.delete(this),this.doc.off("afterTransaction",this.afterTransactionHandler),super.destroy()}}function*LO(n){const e=Xe(n.restDecoder);for(let t=0;t<e;t++){const r=Xe(n.restDecoder),i=n.readClient();let o=Xe(n.restDecoder);for(let s=0;s<r;s++){const a=n.readInfo();if(a===10){const l=Xe(n.restDecoder);yield new mr(je(i,o),l),o+=l}else if((sf&a)!==0){const l=(a&(Li|Ln))===0,c=new kt(je(i,o),null,(a&Ln)===Ln?n.readLeftID():null,null,(a&Li)===Li?n.readRightID():null,l?n.readParentInfo()?n.readString():n.readLeftID():null,l&&(a&zl)===zl?n.readString():null,dk(n,a));yield c,o+=c.length}else{const l=n.readLen();yield new pr(je(i,o),l),o+=l}}}}class hg{constructor(e,t){this.gen=LO(e),this.curr=null,this.done=!1,this.filterSkips=t,this.next()}next(){do this.curr=this.gen.next().value||null;while(this.filterSkips&&this.curr!==null&&this.curr.constructor===mr);return this.curr}}class pg{constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}}const zO=n=>Xd(n,N1,Sc),BO=(n,e)=>{if(n.constructor===pr){const{client:t,clock:r}=n.id;return new pr(je(t,r+e),n.length-e)}else if(n.constructor===mr){const{client:t,clock:r}=n.id;return new mr(je(t,r+e),n.length-e)}else{const t=n,{client:r,clock:i}=t.id;return new kt(je(r,i+e),null,je(r,i+e-1),null,t.rightOrigin,t.parent,t.parentSub,t.content.splice(e))}},Xd=(n,e=Ta,t=ys)=>{if(n.length===1)return n[0];const r=n.map(d=>new e(Pa(d)));let i=r.map(d=>new hg(d,!0)),o=null;const s=new t,a=new pg(s);for(;i=i.filter(h=>h.curr!==null),i.sort((h,p)=>{if(h.curr.id.client===p.curr.id.client){const m=h.curr.id.clock-p.curr.id.clock;return m===0?h.curr.constructor===p.curr.constructor?0:h.curr.constructor===mr?1:-1:m}else return p.curr.id.client-h.curr.id.client}),i.length!==0;){const d=i[0],u=d.curr.id.client;if(o!==null){let h=d.curr,p=!1;for(;h!==null&&h.id.clock+h.length<=o.struct.id.clock+o.struct.length&&h.id.client>=o.struct.id.client;)h=d.next(),p=!0;if(h===null||h.id.client!==u||p&&h.id.clock>o.struct.id.clock+o.struct.length)continue;if(u!==o.struct.id.client)$i(a,o.struct,o.offset),o={struct:h,offset:0},d.next();else if(o.struct.id.clock+o.struct.length<h.id.clock)if(o.struct.constructor===mr)o.struct.length=h.id.clock+h.length-o.struct.id.clock;else{$i(a,o.struct,o.offset);const m=h.id.clock-o.struct.id.clock-o.struct.length;o={struct:new mr(je(u,o.struct.id.clock+o.struct.length),m),offset:0}}else{const m=o.struct.id.clock+o.struct.length-h.id.clock;m>0&&(o.struct.constructor===mr?o.struct.length-=m:h=BO(h,m)),o.struct.mergeWith(h)||($i(a,o.struct,o.offset),o={struct:h,offset:0},d.next())}}else o={struct:d.curr,offset:0},d.next();for(let h=d.curr;h!==null&&h.id.client===u&&h.id.clock===o.struct.id.clock+o.struct.length&&h.constructor!==mr;h=d.next())$i(a,o.struct,o.offset),o={struct:h,offset:0}}o!==null&&($i(a,o.struct,o.offset),o=null),mg(a);const l=r.map(d=>dg(d)),c=Op(l);return Va(s,c),s.toUint8Array()},FO=(n,e,t=Ta,r=ys)=>{const i=L1(e),o=new r,s=new pg(o),a=new t(Pa(n)),l=new hg(a,!1);for(;l.curr;){const d=l.curr,u=d.id.client,h=i.get(u)||0;if(l.curr.constructor===mr){l.next();continue}if(d.id.clock+d.length>h)for($i(s,d,Pr(h-d.id.clock,0)),l.next();l.curr&&l.curr.id.client===u;)$i(s,l.curr,0),l.next();else for(;l.curr&&l.curr.id.client===u&&l.curr.id.clock+l.curr.length<=h;)l.next()}mg(s);const c=dg(a);return Va(o,c),o.toUint8Array()},K1=n=>{n.written>0&&(n.clientStructs.push({written:n.written,restEncoder:Dr(n.encoder.restEncoder)}),n.encoder.restEncoder=kc(),n.written=0)},$i=(n,e,t)=>{n.written>0&&n.currClient!==e.id.client&&K1(n),n.written===0&&(n.currClient=e.id.client,n.encoder.writeClient(e.id.client),ot(n.encoder.restEncoder,e.id.clock+t)),e.write(n.encoder,t),n.written++},mg=n=>{K1(n);const e=n.encoder.restEncoder;ot(e,n.clientStructs.length);for(let t=0;t<n.clientStructs.length;t++){const r=n.clientStructs[t];ot(e,r.written),af(e,r.restEncoder)}},VO=(n,e,t,r)=>{const i=new t(Pa(n)),o=new hg(i,!1),s=new r,a=new pg(s);for(let c=o.curr;c!==null;c=o.next())$i(a,e(c),0);mg(a);const l=dg(i);return Va(s,l),s.toUint8Array()},HO=n=>VO(n,s2,Ta,Sc),qy="You must not compute changes after the event-handler fired.";class mf{constructor(e,t){this.target=e,this.currentTarget=e,this.transaction=t,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||(this._path=UO(this.currentTarget,this.target))}deletes(e){return Fa(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw li(qy);const e=new Map,t=this.target;this.transaction.changed.get(t).forEach(i=>{if(i!==null){const o=t._map.get(i);let s,a;if(this.adds(o)){let l=o.left;for(;l!==null&&this.adds(l);)l=l.left;if(this.deletes(o))if(l!==null&&this.deletes(l))s="delete",a=rh(l.content.getContent());else return;else l!==null&&this.deletes(l)?(s="update",a=rh(l.content.getContent())):(s="add",a=void 0)}else if(this.deletes(o))s="delete",a=rh(o.content.getContent());else return;e.set(i,{action:s,oldValue:a})}}),this._keys=e}return this._keys}get delta(){return this.changes.delta}adds(e){return e.id.clock>=(this.transaction.beforeState.get(e.id.client)||0)}get changes(){let e=this._changes;if(e===null){if(this.transaction.doc._transactionCleanups.length===0)throw li(qy);const t=this.target,r=vs(),i=vs(),o=[];if(e={added:r,deleted:i,delta:o,keys:this.keys},this.transaction.changed.get(t).has(null)){let a=null;const l=()=>{a&&o.push(a)};for(let c=t._start;c!==null;c=c.right)c.deleted?this.deletes(c)&&!this.adds(c)&&((a===null||a.delete===void 0)&&(l(),a={delete:0}),a.delete+=c.length,i.add(c)):this.adds(c)?((a===null||a.insert===void 0)&&(l(),a={insert:[]}),a.insert=a.insert.concat(c.content.getContent()),r.add(c)):((a===null||a.retain===void 0)&&(l(),a={retain:0}),a.retain+=c.length);a!==null&&a.retain===void 0&&l()}this._changes=e}return e}}const UO=(n,e)=>{const t=[];for(;e._item!==null&&e!==n;){if(e._item.parentSub!==null)t.unshift(e._item.parentSub);else{let r=0,i=e._item.parent._start;for(;i!==e._item&&i!==null;)!i.deleted&&i.countable&&(r+=i.length),i=i.right;t.unshift(r)}e=e._item.parent}return t},xn=()=>{T1("Invalid access: Add Yjs type to a document before reading data.")},q1=80;let gg=0;class jO{constructor(e,t){e.marker=!0,this.p=e,this.index=t,this.timestamp=gg++}}const WO=n=>{n.timestamp=gg++},J1=(n,e,t)=>{n.p.marker=!1,n.p=e,e.marker=!0,n.index=t,n.timestamp=gg++},KO=(n,e,t)=>{if(n.length>=q1){const r=n.reduce((i,o)=>i.timestamp<o.timestamp?i:o);return J1(r,e,t),r}else{const r=new jO(e,t);return n.push(r),r}},gf=(n,e)=>{if(n._start===null||e===0||n._searchMarker===null)return null;const t=n._searchMarker.length===0?null:n._searchMarker.reduce((o,s)=>pd(e-o.index)<pd(e-s.index)?o:s);let r=n._start,i=0;for(t!==null&&(r=t.p,i=t.index,WO(t));r.right!==null&&i<e;){if(!r.deleted&&r.countable){if(e<i+r.length)break;i+=r.length}r=r.right}for(;r.left!==null&&i>e;)r=r.left,!r.deleted&&r.countable&&(i-=r.length);for(;r.left!==null&&r.left.id.client===r.id.client&&r.left.id.clock+r.left.length===r.id.clock;)r=r.left,!r.deleted&&r.countable&&(i-=r.length);return t!==null&&pd(t.index-i)<r.parent.length/q1?(J1(t,r,i),t):KO(n._searchMarker,r,i)},ql=(n,e,t)=>{for(let r=n.length-1;r>=0;r--){const i=n[r];if(t>0){let o=i.p;for(o.marker=!1;o&&(o.deleted||!o.countable);)o=o.left,o&&!o.deleted&&o.countable&&(i.index-=o.length);if(o===null||o.marker===!0){n.splice(r,1);continue}i.p=o,o.marker=!0}(e<i.index||t>0&&e===i.index)&&(i.index=Pr(e,i.index+t))}},vf=(n,e,t)=>{const r=n,i=e.changedParentTypes;for(;mi(i,n,()=>[]).push(t),n._item!==null;)n=n._item.parent;B1(r._eH,t,e)};class on{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=zy(),this._dEH=zy(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,t){this.doc=e,this._item=t}_copy(){throw wr()}clone(){throw wr()}_write(e){}get _first(){let e=this._start;for(;e!==null&&e.deleted;)e=e.right;return e}_callObserver(e,t){!e.local&&this._searchMarker&&(this._searchMarker.length=0)}observe(e){By(this._eH,e)}observeDeep(e){By(this._dEH,e)}unobserve(e){Fy(this._eH,e)}unobserveDeep(e){Fy(this._dEH,e)}toJSON(){}}const Y1=(n,e,t)=>{n.doc??xn(),e<0&&(e=n._length+e),t<0&&(t=n._length+t);let r=t-e;const i=[];let o=n._start;for(;o!==null&&r>0;){if(o.countable&&!o.deleted){const s=o.content.getContent();if(s.length<=e)e-=s.length;else{for(let a=e;a<s.length&&r>0;a++)i.push(s[a]),r--;e=0}}o=o.right}return i},G1=n=>{n.doc??xn();const e=[];let t=n._start;for(;t!==null;){if(t.countable&&!t.deleted){const r=t.content.getContent();for(let i=0;i<r.length;i++)e.push(r[i])}t=t.right}return e},Z1=(n,e)=>{const t=[];let r=n._start;for(;r!==null;){if(r.countable&&Lo(r,e)){const i=r.content.getContent();for(let o=0;o<i.length;o++)t.push(i[o])}r=r.right}return t},Jl=(n,e)=>{let t=0,r=n._start;for(n.doc??xn();r!==null;){if(r.countable&&!r.deleted){const i=r.content.getContent();for(let o=0;o<i.length;o++)e(i[o],t++,n)}r=r.right}},X1=(n,e)=>{const t=[];return Jl(n,(r,i)=>{t.push(e(r,i,n))}),t},qO=n=>{let e=n._start,t=null,r=0;return{[Symbol.iterator](){return this},next:()=>{if(t===null){for(;e!==null&&e.deleted;)e=e.right;if(e===null)return{done:!0,value:void 0};t=e.content.getContent(),r=0,e=e.right}const i=t[r++];return t.length<=r&&(t=null),{done:!1,value:i}}}},Q1=(n,e)=>{n.doc??xn();const t=gf(n,e);let r=n._start;for(t!==null&&(r=t.p,e-=t.index);r!==null;r=r.right)if(!r.deleted&&r.countable){if(e<r.length)return r.content.getContent()[e];e-=r.length}},Qd=(n,e,t,r)=>{let i=t;const o=n.doc,s=o.clientID,a=o.store,l=t===null?e._start:t.right;let c=[];const d=()=>{c.length>0&&(i=new kt(je(s,Ht(a,s)),i,i&&i.lastId,l,l&&l.id,e,null,new ws(c)),i.integrate(n,0),c=[])};r.forEach(u=>{if(u===null)c.push(u);else switch(u.constructor){case Number:case Object:case Boolean:case Array:case String:c.push(u);break;default:switch(d(),u.constructor){case Uint8Array:case ArrayBuffer:i=new kt(je(s,Ht(a,s)),i,i&&i.lastId,l,l&&l.id,e,null,new Tc(new Uint8Array(u))),i.integrate(n,0);break;case ci:i=new kt(je(s,Ht(a,s)),i,i&&i.lastId,l,l&&l.id,e,null,new Ac(u)),i.integrate(n,0);break;default:if(u instanceof on)i=new kt(je(s,Ht(a,s)),i,i&&i.lastId,l,l&&l.id,e,null,new Fr(u)),i.integrate(n,0);else throw new Error("Unexpected content type in insert operation")}}}),d()},$1=()=>li("Length exceeded!"),ek=(n,e,t,r)=>{if(t>e._length)throw $1();if(t===0)return e._searchMarker&&ql(e._searchMarker,t,r.length),Qd(n,e,null,r);const i=t,o=gf(e,t);let s=e._start;for(o!==null&&(s=o.p,t-=o.index,t===0&&(s=s.prev,t+=s&&s.countable&&!s.deleted?s.length:0));s!==null;s=s.right)if(!s.deleted&&s.countable){if(t<=s.length){t<s.length&&Wn(n,je(s.id.client,s.id.clock+t));break}t-=s.length}return e._searchMarker&&ql(e._searchMarker,i,r.length),Qd(n,e,s,r)},JO=(n,e,t)=>{let i=(e._searchMarker||[]).reduce((o,s)=>s.index>o.index?s:o,{index:0,p:e._start}).p;if(i)for(;i.right;)i=i.right;return Qd(n,e,i,t)},tk=(n,e,t,r)=>{if(r===0)return;const i=t,o=r,s=gf(e,t);let a=e._start;for(s!==null&&(a=s.p,t-=s.index);a!==null&&t>0;a=a.right)!a.deleted&&a.countable&&(t<a.length&&Wn(n,je(a.id.client,a.id.clock+t)),t-=a.length);for(;r>0&&a!==null;)a.deleted||(r<a.length&&Wn(n,je(a.id.client,a.id.clock+r)),a.delete(n),r-=a.length),a=a.right;if(r>0)throw $1();e._searchMarker&&ql(e._searchMarker,i,-o+r)},$d=(n,e,t)=>{const r=e._map.get(t);r!==void 0&&r.delete(n)},vg=(n,e,t,r)=>{const i=e._map.get(t)||null,o=n.doc,s=o.clientID;let a;if(r==null)a=new ws([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:a=new ws([r]);break;case Uint8Array:a=new Tc(r);break;case ci:a=new Ac(r);break;default:if(r instanceof on)a=new Fr(r);else throw new Error("Unexpected content type")}new kt(je(s,Ht(o.store,s)),i,i&&i.lastId,null,null,e,t,a).integrate(n,0)},yg=(n,e)=>{n.doc??xn();const t=n._map.get(e);return t!==void 0&&!t.deleted?t.content.getContent()[t.length-1]:void 0},nk=n=>{const e={};return n.doc??xn(),n._map.forEach((t,r)=>{t.deleted||(e[r]=t.content.getContent()[t.length-1])}),e},rk=(n,e)=>{n.doc??xn();const t=n._map.get(e);return t!==void 0&&!t.deleted},YO=(n,e)=>{const t={};return n._map.forEach((r,i)=>{let o=r;for(;o!==null&&(!e.sv.has(o.id.client)||o.id.clock>=(e.sv.get(o.id.client)||0));)o=o.left;o!==null&&Lo(o,e)&&(t[i]=o.content.getContent()[o.length-1])}),t},Vc=n=>(n.doc??xn(),dO(n._map.entries(),e=>!e[1].deleted));class GO extends mf{}class ta extends on{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(e){const t=new ta;return t.push(e),t}_integrate(e,t){super._integrate(e,t),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new ta}clone(){const e=new ta;return e.insert(0,this.toArray().map(t=>t instanceof on?t.clone():t)),e}get length(){return this.doc??xn(),this._length}_callObserver(e,t){super._callObserver(e,t),vf(this,e,new GO(this,e))}insert(e,t){this.doc!==null?bt(this.doc,r=>{ek(r,this,e,t)}):this._prelimContent.splice(e,0,...t)}push(e){this.doc!==null?bt(this.doc,t=>{JO(t,this,e)}):this._prelimContent.push(...e)}unshift(e){this.insert(0,e)}delete(e,t=1){this.doc!==null?bt(this.doc,r=>{tk(r,this,e,t)}):this._prelimContent.splice(e,t)}get(e){return Q1(this,e)}toArray(){return G1(this)}slice(e=0,t=this.length){return Y1(this,e,t)}toJSON(){return this.map(e=>e instanceof on?e.toJSON():e)}map(e){return X1(this,e)}forEach(e){Jl(this,e)}[Symbol.iterator](){return qO(this)}_write(e){e.writeTypeRef(wD)}}const ZO=n=>new ta;class XO extends mf{constructor(e,t,r){super(e,t),this.keysChanged=r}}class Aa extends on{constructor(e){super(),this._prelimContent=null,e===void 0?this._prelimContent=new Map:this._prelimContent=new Map(e)}_integrate(e,t){super._integrate(e,t),this._prelimContent.forEach((r,i)=>{this.set(i,r)}),this._prelimContent=null}_copy(){return new Aa}clone(){const e=new Aa;return this.forEach((t,r)=>{e.set(r,t instanceof on?t.clone():t)}),e}_callObserver(e,t){vf(this,e,new XO(this,e,t))}toJSON(){this.doc??xn();const e={};return this._map.forEach((t,r)=>{if(!t.deleted){const i=t.content.getContent()[t.length-1];e[r]=i instanceof on?i.toJSON():i}}),e}get size(){return[...Vc(this)].length}keys(){return dh(Vc(this),e=>e[0])}values(){return dh(Vc(this),e=>e[1].content.getContent()[e[1].length-1])}entries(){return dh(Vc(this),e=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){this.doc??xn(),this._map.forEach((t,r)=>{t.deleted||e(t.content.getContent()[t.length-1],r,this)})}[Symbol.iterator](){return this.entries()}delete(e){this.doc!==null?bt(this.doc,t=>{$d(t,this,e)}):this._prelimContent.delete(e)}set(e,t){return this.doc!==null?bt(this.doc,r=>{vg(r,this,e,t)}):this._prelimContent.set(e,t),t}get(e){return yg(this,e)}has(e){return rk(this,e)}clear(){this.doc!==null?bt(this.doc,e=>{this.forEach(function(t,r,i){$d(e,i,r)})}):this._prelimContent.clear()}_write(e){e.writeTypeRef(xD)}}const QO=n=>new Aa,lo=(n,e)=>n===e||typeof n=="object"&&typeof e=="object"&&n&&e&&i2(n,e);class Ip{constructor(e,t,r,i){this.left=e,this.right=t,this.index=r,this.currentAttributes=i}forward(){switch(this.right===null&&_n(),this.right.content.constructor){case qt:this.right.deleted||Ha(this.currentAttributes,this.right.content);break;default:this.right.deleted||(this.index+=this.right.length);break}this.left=this.right,this.right=this.right.right}}const Jy=(n,e,t)=>{for(;e.right!==null&&t>0;){switch(e.right.content.constructor){case qt:e.right.deleted||Ha(e.currentAttributes,e.right.content);break;default:e.right.deleted||(t<e.right.length&&Wn(n,je(e.right.id.client,e.right.id.clock+t)),e.index+=e.right.length,t-=e.right.length);break}e.left=e.right,e.right=e.right.right}return e},Hc=(n,e,t,r)=>{const i=new Map,o=r?gf(e,t):null;if(o){const s=new Ip(o.p.left,o.p,o.index,i);return Jy(n,s,t-o.index)}else{const s=new Ip(null,e._start,0,i);return Jy(n,s,t)}},ik=(n,e,t,r)=>{for(;t.right!==null&&(t.right.deleted===!0||t.right.content.constructor===qt&&lo(r.get(t.right.content.key),t.right.content.value));)t.right.deleted||r.delete(t.right.content.key),t.forward();const i=n.doc,o=i.clientID;r.forEach((s,a)=>{const l=t.left,c=t.right,d=new kt(je(o,Ht(i.store,o)),l,l&&l.lastId,c,c&&c.id,e,null,new qt(a,s));d.integrate(n,0),t.right=d,t.forward()})},Ha=(n,e)=>{const{key:t,value:r}=e;r===null?n.delete(t):n.set(t,r)},ok=(n,e)=>{for(;n.right!==null;){if(!(n.right.deleted||n.right.content.constructor===qt&&lo(e[n.right.content.key]??null,n.right.content.value)))break;n.forward()}},sk=(n,e,t,r)=>{const i=n.doc,o=i.clientID,s=new Map;for(const a in r){const l=r[a],c=t.currentAttributes.get(a)??null;if(!lo(c,l)){s.set(a,c);const{left:d,right:u}=t;t.right=new kt(je(o,Ht(i.store,o)),d,d&&d.lastId,u,u&&u.id,e,null,new qt(a,l)),t.right.integrate(n,0),t.forward()}}return s},hh=(n,e,t,r,i)=>{t.currentAttributes.forEach((h,p)=>{i[p]===void 0&&(i[p]=null)});const o=n.doc,s=o.clientID;ok(t,i);const a=sk(n,e,t,i),l=r.constructor===String?new zr(r):r instanceof on?new Fr(r):new Ds(r);let{left:c,right:d,index:u}=t;e._searchMarker&&ql(e._searchMarker,t.index,l.getLength()),d=new kt(je(s,Ht(o.store,s)),c,c&&c.lastId,d,d&&d.id,e,null,l),d.integrate(n,0),t.right=d,t.index=u,t.forward(),ik(n,e,t,a)},Yy=(n,e,t,r,i)=>{const o=n.doc,s=o.clientID;ok(t,i);const a=sk(n,e,t,i);e:for(;t.right!==null&&(r>0||a.size>0&&(t.right.deleted||t.right.content.constructor===qt));){if(!t.right.deleted)switch(t.right.content.constructor){case qt:{const{key:l,value:c}=t.right.content,d=i[l];if(d!==void 0){if(lo(d,c))a.delete(l);else{if(r===0)break e;a.set(l,c)}t.right.delete(n)}else t.currentAttributes.set(l,c);break}default:r<t.right.length&&Wn(n,je(t.right.id.client,t.right.id.clock+r)),r-=t.right.length;break}t.forward()}if(r>0){let l="";for(;r>0;r--)l+=`
|
|
47
|
-
`;t.right=new kt(je(s,Ht(o.store,s)),t.left,t.left&&t.left.lastId,t.right,t.right&&t.right.id,e,null,new zr(l)),t.right.integrate(n,0),t.forward()}ik(n,e,t,a)},ak=(n,e,t,r,i)=>{let o=e;const s=br();for(;o&&(!o.countable||o.deleted);){if(!o.deleted&&o.content.constructor===qt){const c=o.content;s.set(c.key,c)}o=o.right}let a=0,l=!1;for(;e!==o;){if(t===e&&(l=!0),!e.deleted){const c=e.content;switch(c.constructor){case qt:{const{key:d,value:u}=c,h=r.get(d)??null;(s.get(d)!==c||h===u)&&(e.delete(n),a++,!l&&(i.get(d)??null)===u&&h!==u&&(h===null?i.delete(d):i.set(d,h))),!l&&!e.deleted&&Ha(i,c);break}}}e=e.right}return a},$O=(n,e)=>{for(;e&&e.right&&(e.right.deleted||!e.right.countable);)e=e.right;const t=new Set;for(;e&&(e.deleted||!e.countable);){if(!e.deleted&&e.content.constructor===qt){const r=e.content.key;t.has(r)?e.delete(n):t.add(r)}e=e.left}},eD=n=>{let e=0;return bt(n.doc,t=>{let r=n._start,i=n._start,o=br();const s=Sp(o);for(;i;){if(i.deleted===!1)switch(i.content.constructor){case qt:Ha(s,i.content);break;default:e+=ak(t,r,i,o,s),o=Sp(s),r=i;break}i=i.right}}),e},tD=n=>{const e=new Set,t=n.doc;for(const[r,i]of n.afterState.entries()){const o=n.beforeState.get(r)||0;i!==o&&U1(n,t.store.clients.get(r),o,i,s=>{!s.deleted&&s.content.constructor===qt&&s.constructor!==pr&&e.add(s.parent)})}bt(t,r=>{So(n,n.deleteSet,i=>{if(i instanceof pr||!i.parent._hasFormatting||e.has(i.parent))return;const o=i.parent;i.content.constructor===qt?e.add(o):$O(r,i)});for(const i of e)eD(i)})},Gy=(n,e,t)=>{const r=t,i=Sp(e.currentAttributes),o=e.right;for(;t>0&&e.right!==null;){if(e.right.deleted===!1)switch(e.right.content.constructor){case Fr:case Ds:case zr:t<e.right.length&&Wn(n,je(e.right.id.client,e.right.id.clock+t)),t-=e.right.length,e.right.delete(n);break}e.forward()}o&&ak(n,o,e.right,i,e.currentAttributes);const s=(e.left||e.right).parent;return s._searchMarker&&ql(s._searchMarker,e.index,-r+t),e};class nD extends mf{constructor(e,t,r){super(e,t),this.childListChanged=!1,this.keysChanged=new Set,r.forEach(i=>{i===null?this.childListChanged=!0:this.keysChanged.add(i)})}get changes(){if(this._changes===null){const e={keys:this.keys,delta:this.delta,added:new Set,deleted:new Set};this._changes=e}return this._changes}get delta(){if(this._delta===null){const e=this.target.doc,t=[];bt(e,r=>{const i=new Map,o=new Map;let s=this.target._start,a=null;const l={};let c="",d=0,u=0;const h=()=>{if(a!==null){let p=null;switch(a){case"delete":u>0&&(p={delete:u}),u=0;break;case"insert":(typeof c=="object"||c.length>0)&&(p={insert:c},i.size>0&&(p.attributes={},i.forEach((m,v)=>{m!==null&&(p.attributes[v]=m)}))),c="";break;case"retain":d>0&&(p={retain:d},r2(l)||(p.attributes=t2({},l))),d=0;break}p&&t.push(p),a=null}};for(;s!==null;){switch(s.content.constructor){case Fr:case Ds:this.adds(s)?this.deletes(s)||(h(),a="insert",c=s.content.getContent()[0],h()):this.deletes(s)?(a!=="delete"&&(h(),a="delete"),u+=1):s.deleted||(a!=="retain"&&(h(),a="retain"),d+=1);break;case zr:this.adds(s)?this.deletes(s)||(a!=="insert"&&(h(),a="insert"),c+=s.content.str):this.deletes(s)?(a!=="delete"&&(h(),a="delete"),u+=s.length):s.deleted||(a!=="retain"&&(h(),a="retain"),d+=s.length);break;case qt:{const{key:p,value:m}=s.content;if(this.adds(s)){if(!this.deletes(s)){const v=i.get(p)??null;lo(v,m)?m!==null&&s.delete(r):(a==="retain"&&h(),lo(m,o.get(p)??null)?delete l[p]:l[p]=m)}}else if(this.deletes(s)){o.set(p,m);const v=i.get(p)??null;lo(v,m)||(a==="retain"&&h(),l[p]=v)}else if(!s.deleted){o.set(p,m);const v=l[p];v!==void 0&&(lo(v,m)?v!==null&&s.delete(r):(a==="retain"&&h(),m===null?delete l[p]:l[p]=m))}s.deleted||(a==="insert"&&h(),Ha(i,s.content));break}}s=s.right}for(h();t.length>0;){const p=t[t.length-1];if(p.retain!==void 0&&p.attributes===void 0)t.pop();else break}}),this._delta=t}return this._delta}}class Co extends on{constructor(e){super(),this._pending=e!==void 0?[()=>this.insert(0,e)]:[],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??xn(),this._length}_integrate(e,t){super._integrate(e,t);try{this._pending.forEach(r=>r())}catch(r){console.error(r)}this._pending=null}_copy(){return new Co}clone(){const e=new Co;return e.applyDelta(this.toDelta()),e}_callObserver(e,t){super._callObserver(e,t);const r=new nD(this,e,t);vf(this,e,r),!e.local&&this._hasFormatting&&(e._needFormattingCleanup=!0)}toString(){this.doc??xn();let e="",t=this._start;for(;t!==null;)!t.deleted&&t.countable&&t.content.constructor===zr&&(e+=t.content.str),t=t.right;return e}toJSON(){return this.toString()}applyDelta(e,{sanitize:t=!0}={}){this.doc!==null?bt(this.doc,r=>{const i=new Ip(null,this._start,0,new Map);for(let o=0;o<e.length;o++){const s=e[o];if(s.insert!==void 0){const a=!t&&typeof s.insert=="string"&&o===e.length-1&&i.right===null&&s.insert.slice(-1)===`
|
|
48
|
-
`?s.insert.slice(0,-1):s.insert;(typeof a!="string"||a.length>0)&&hh(r,this,i,a,s.attributes||{})}else s.retain!==void 0?Yy(r,this,i,s.retain,s.attributes||{}):s.delete!==void 0&&Gy(r,i,s.delete)}}):this._pending.push(()=>this.applyDelta(e))}toDelta(e,t,r){this.doc??xn();const i=[],o=new Map,s=this.doc;let a="",l=this._start;function c(){if(a.length>0){const u={};let h=!1;o.forEach((m,v)=>{h=!0,u[v]=m});const p={insert:a};h&&(p.attributes=u),i.push(p),a=""}}const d=()=>{for(;l!==null;){if(Lo(l,e)||t!==void 0&&Lo(l,t))switch(l.content.constructor){case zr:{const u=o.get("ychange");e!==void 0&&!Lo(l,e)?(u===void 0||u.user!==l.id.client||u.type!=="removed")&&(c(),o.set("ychange",r?r("removed",l.id):{type:"removed"})):t!==void 0&&!Lo(l,t)?(u===void 0||u.user!==l.id.client||u.type!=="added")&&(c(),o.set("ychange",r?r("added",l.id):{type:"added"})):u!==void 0&&(c(),o.delete("ychange")),a+=l.content.str;break}case Fr:case Ds:{c();const u={insert:l.content.getContent()[0]};if(o.size>0){const h={};u.attributes=h,o.forEach((p,m)=>{h[m]=p})}i.push(u);break}case qt:Lo(l,e)&&(c(),Ha(o,l.content));break}l=l.right}c()};return e||t?bt(s,u=>{e&&Rp(u,e),t&&Rp(u,t),d()},"cleanup"):d(),i}insert(e,t,r){if(t.length<=0)return;const i=this.doc;i!==null?bt(i,o=>{const s=Hc(o,this,e,!r);r||(r={},s.currentAttributes.forEach((a,l)=>{r[l]=a})),hh(o,this,s,t,r)}):this._pending.push(()=>this.insert(e,t,r))}insertEmbed(e,t,r){const i=this.doc;i!==null?bt(i,o=>{const s=Hc(o,this,e,!r);hh(o,this,s,t,r||{})}):this._pending.push(()=>this.insertEmbed(e,t,r||{}))}delete(e,t){if(t===0)return;const r=this.doc;r!==null?bt(r,i=>{Gy(i,Hc(i,this,e,!0),t)}):this._pending.push(()=>this.delete(e,t))}format(e,t,r){if(t===0)return;const i=this.doc;i!==null?bt(i,o=>{const s=Hc(o,this,e,!1);s.right!==null&&Yy(o,this,s,t,r)}):this._pending.push(()=>this.format(e,t,r))}removeAttribute(e){this.doc!==null?bt(this.doc,t=>{$d(t,this,e)}):this._pending.push(()=>this.removeAttribute(e))}setAttribute(e,t){this.doc!==null?bt(this.doc,r=>{vg(r,this,e,t)}):this._pending.push(()=>this.setAttribute(e,t))}getAttribute(e){return yg(this,e)}getAttributes(){return nk(this)}_write(e){e.writeTypeRef(kD)}}const rD=n=>new Co;class ph{constructor(e,t=()=>!0){this._filter=t,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??xn()}[Symbol.iterator](){return this}next(){let e=this._currentNode,t=e&&e.content&&e.content.type;if(e!==null&&(!this._firstCall||e.deleted||!this._filter(t)))do if(t=e.content.type,!e.deleted&&(t.constructor===Wt||t.constructor===bs)&&t._start!==null)e=t._start;else for(;e!==null;){const r=e.next;if(r!==null){e=r;break}else e.parent===this._root?e=null:e=e.parent._item}while(e!==null&&(e.deleted||!this._filter(e.content.type)));return this._firstCall=!1,e===null?{value:void 0,done:!0}:(this._currentNode=e,{value:e.content.type,done:!1})}}class bs extends on{constructor(){super(),this._prelimContent=[]}get firstChild(){const e=this._first;return e?e.content.getContent()[0]:null}_integrate(e,t){super._integrate(e,t),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new bs}clone(){const e=new bs;return e.insert(0,this.toArray().map(t=>t instanceof on?t.clone():t)),e}get length(){return this.doc??xn(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new ph(this,e)}querySelector(e){e=e.toUpperCase();const r=new ph(this,i=>i.nodeName&&i.nodeName.toUpperCase()===e).next();return r.done?null:r.value}querySelectorAll(e){return e=e.toUpperCase(),_o(new ph(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e))}_callObserver(e,t){vf(this,e,new sD(this,t,e))}toString(){return X1(this,e=>e.toString()).join("")}toJSON(){return this.toString()}toDOM(e=document,t={},r){const i=e.createDocumentFragment();return r!==void 0&&r._createAssociation(i,this),Jl(this,o=>{i.insertBefore(o.toDOM(e,t,r),null)}),i}insert(e,t){this.doc!==null?bt(this.doc,r=>{ek(r,this,e,t)}):this._prelimContent.splice(e,0,...t)}insertAfter(e,t){if(this.doc!==null)bt(this.doc,r=>{const i=e&&e instanceof on?e._item:e;Qd(r,this,i,t)});else{const r=this._prelimContent,i=e===null?0:r.findIndex(o=>o===e)+1;if(i===0&&e!==null)throw li("Reference item not found");r.splice(i,0,...t)}}delete(e,t=1){this.doc!==null?bt(this.doc,r=>{tk(r,this,e,t)}):this._prelimContent.splice(e,t)}toArray(){return G1(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return Q1(this,e)}slice(e=0,t=this.length){return Y1(this,e,t)}forEach(e){Jl(this,e)}_write(e){e.writeTypeRef(SD)}}const iD=n=>new bs;class Wt extends bs{constructor(e="UNDEFINED"){super(),this.nodeName=e,this._prelimAttrs=new Map}get nextSibling(){const e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){const e=this._item?this._item.prev:null;return e?e.content.type:null}_integrate(e,t){super._integrate(e,t),this._prelimAttrs.forEach((r,i)=>{this.setAttribute(i,r)}),this._prelimAttrs=null}_copy(){return new Wt(this.nodeName)}clone(){const e=new Wt(this.nodeName),t=this.getAttributes();return n2(t,(r,i)=>{e.setAttribute(i,r)}),e.insert(0,this.toArray().map(r=>r instanceof on?r.clone():r)),e}toString(){const e=this.getAttributes(),t=[],r=[];for(const a in e)r.push(a);r.sort();const i=r.length;for(let a=0;a<i;a++){const l=r[a];t.push(l+'="'+e[l]+'"')}const o=this.nodeName.toLocaleLowerCase(),s=t.length>0?" "+t.join(" "):"";return`<${o}${s}>${super.toString()}</${o}>`}removeAttribute(e){this.doc!==null?bt(this.doc,t=>{$d(t,this,e)}):this._prelimAttrs.delete(e)}setAttribute(e,t){this.doc!==null?bt(this.doc,r=>{vg(r,this,e,t)}):this._prelimAttrs.set(e,t)}getAttribute(e){return yg(this,e)}hasAttribute(e){return rk(this,e)}getAttributes(e){return e?YO(this,e):nk(this)}toDOM(e=document,t={},r){const i=e.createElement(this.nodeName),o=this.getAttributes();for(const s in o){const a=o[s];typeof a=="string"&&i.setAttribute(s,a)}return Jl(this,s=>{i.appendChild(s.toDOM(e,t,r))}),r!==void 0&&r._createAssociation(i,this),i}_write(e){e.writeTypeRef(_D),e.writeKey(this.nodeName)}}const oD=n=>new Wt(n.readKey());class sD extends mf{constructor(e,t,r){super(e,r),this.childListChanged=!1,this.attributesChanged=new Set,t.forEach(i=>{i===null?this.childListChanged=!0:this.attributesChanged.add(i)})}}class eu extends Aa{constructor(e){super(),this.hookName=e}_copy(){return new eu(this.hookName)}clone(){const e=new eu(this.hookName);return this.forEach((t,r)=>{e.set(r,t)}),e}toDOM(e=document,t={},r){const i=t[this.hookName];let o;return i!==void 0?o=i.createDom(this):o=document.createElement(this.hookName),o.setAttribute("data-yjs-hook",this.hookName),r!==void 0&&r._createAssociation(o,this),o}_write(e){e.writeTypeRef(CD),e.writeKey(this.hookName)}}const aD=n=>new eu(n.readKey());class yn extends Co{get nextSibling(){const e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){const e=this._item?this._item.prev:null;return e?e.content.type:null}_copy(){return new yn}clone(){const e=new yn;return e.applyDelta(this.toDelta()),e}toDOM(e=document,t,r){const i=e.createTextNode(this.toString());return r!==void 0&&r._createAssociation(i,this),i}toString(){return this.toDelta().map(e=>{const t=[];for(const i in e.attributes){const o=[];for(const s in e.attributes[i])o.push({key:s,value:e.attributes[i][s]});o.sort((s,a)=>s.key<a.key?-1:1),t.push({nodeName:i,attrs:o})}t.sort((i,o)=>i.nodeName<o.nodeName?-1:1);let r="";for(let i=0;i<t.length;i++){const o=t[i];r+=`<${o.nodeName}`;for(let s=0;s<o.attrs.length;s++){const a=o.attrs[s];r+=` ${a.key}="${a.value}"`}r+=">"}r+=e.insert;for(let i=t.length-1;i>=0;i--)r+=`</${t[i].nodeName}>`;return r}).join("")}toJSON(){return this.toString()}_write(e){e.writeTypeRef(TD)}}const lD=n=>new yn;class bg{constructor(e,t){this.id=e,this.length=t}get deleted(){throw wr()}mergeWith(e){return!1}write(e,t,r){throw wr()}integrate(e,t){throw wr()}}const cD=0;class pr extends bg{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,t){t>0&&(this.id.clock+=t,this.length-=t),H1(e.doc.store,this)}write(e,t){e.writeInfo(cD),e.writeLen(this.length-t)}getMissing(e,t){return null}}class Tc{constructor(e){this.content=e}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new Tc(this.content)}splice(e){throw wr()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeBuf(this.content)}getRef(){return 3}}const dD=n=>new Tc(n.readBuf());class Yl{constructor(e){this.len=e}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new Yl(this.len)}splice(e){const t=new Yl(this.len-e);return this.len=e,t}mergeWith(e){return this.len+=e.len,!0}integrate(e,t){Ul(e.deleteSet,t.id.client,t.id.clock,this.len),t.markDeleted()}delete(e){}gc(e){}write(e,t){e.writeLen(this.len-t)}getRef(){return 1}}const uD=n=>new Yl(n.readLen()),lk=(n,e)=>new ci({guid:n,...e,shouldLoad:e.shouldLoad||e.autoLoad||!1});class Ac{constructor(e){e._item&&console.error("This document was already integrated as a sub-document. You should create a second instance instead with the same guid."),this.doc=e;const t={};this.opts=t,e.gc||(t.gc=!1),e.autoLoad&&(t.autoLoad=!0),e.meta!==null&&(t.meta=e.meta)}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new Ac(lk(this.doc.guid,this.opts))}splice(e){throw wr()}mergeWith(e){return!1}integrate(e,t){this.doc._item=t,e.subdocsAdded.add(this.doc),this.doc.shouldLoad&&e.subdocsLoaded.add(this.doc)}delete(e){e.subdocsAdded.has(this.doc)?e.subdocsAdded.delete(this.doc):e.subdocsRemoved.add(this.doc)}gc(e){}write(e,t){e.writeString(this.doc.guid),e.writeAny(this.opts)}getRef(){return 9}}const fD=n=>new Ac(lk(n.readString(),n.readAny()));class Ds{constructor(e){this.embed=e}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new Ds(this.embed)}splice(e){throw wr()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeJSON(this.embed)}getRef(){return 5}}const hD=n=>new Ds(n.readJSON());class qt{constructor(e,t){this.key=e,this.value=t}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new qt(this.key,this.value)}splice(e){throw wr()}mergeWith(e){return!1}integrate(e,t){const r=t.parent;r._searchMarker=null,r._hasFormatting=!0}delete(e){}gc(e){}write(e,t){e.writeKey(this.key),e.writeJSON(this.value)}getRef(){return 6}}const pD=n=>new qt(n.readKey(),n.readJSON());class tu{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new tu(this.arr)}splice(e){const t=new tu(this.arr.slice(e));return this.arr=this.arr.slice(0,e),t}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){const r=this.arr.length;e.writeLen(r-t);for(let i=t;i<r;i++){const o=this.arr[i];e.writeString(o===void 0?"undefined":JSON.stringify(o))}}getRef(){return 2}}const mD=n=>{const e=n.readLen(),t=[];for(let r=0;r<e;r++){const i=n.readString();i==="undefined"?t.push(void 0):t.push(JSON.parse(i))}return new tu(t)},gD=qd("node_env")==="development";class ws{constructor(e){this.arr=e,gD&&n1(e)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new ws(this.arr)}splice(e){const t=new ws(this.arr.slice(e));return this.arr=this.arr.slice(0,e),t}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){const r=this.arr.length;e.writeLen(r-t);for(let i=t;i<r;i++){const o=this.arr[i];e.writeAny(o)}}getRef(){return 8}}const vD=n=>{const e=n.readLen(),t=[];for(let r=0;r<e;r++)t.push(n.readAny());return new ws(t)};class zr{constructor(e){this.str=e}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new zr(this.str)}splice(e){const t=new zr(this.str.slice(e));this.str=this.str.slice(0,e);const r=this.str.charCodeAt(e-1);return r>=55296&&r<=56319&&(this.str=this.str.slice(0,e-1)+"�",t.str="�"+t.str.slice(1)),t}mergeWith(e){return this.str+=e.str,!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeString(t===0?this.str:this.str.slice(t))}getRef(){return 4}}const yD=n=>new zr(n.readString()),bD=[ZO,QO,rD,oD,iD,aD,lD],wD=0,xD=1,kD=2,_D=3,SD=4,CD=5,TD=6;class Fr{constructor(e){this.type=e}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new Fr(this.type._copy())}splice(e){throw wr()}mergeWith(e){return!1}integrate(e,t){this.type._integrate(e.doc,t)}delete(e){let t=this.type._start;for(;t!==null;)t.deleted?t.id.clock<(e.beforeState.get(t.id.client)||0)&&e._mergeStructs.push(t):t.delete(e),t=t.right;this.type._map.forEach(r=>{r.deleted?r.id.clock<(e.beforeState.get(r.id.client)||0)&&e._mergeStructs.push(r):r.delete(e)}),e.changed.delete(this.type)}gc(e){let t=this.type._start;for(;t!==null;)t.gc(e,!0),t=t.right;this.type._start=null,this.type._map.forEach(r=>{for(;r!==null;)r.gc(e,!0),r=r.left}),this.type._map=new Map}write(e,t){this.type._write(e)}getRef(){return 7}}const AD=n=>new Fr(bD[n.readTypeRef()](n)),Pp=(n,e)=>{let t=e,r=0,i;do r>0&&(t=je(t.client,t.clock+r)),i=ea(n,t),r=t.clock-i.id.clock,t=i.redone;while(t!==null&&i instanceof kt);return{item:i,diff:r}},wg=(n,e)=>{for(;n!==null&&n.keep!==e;)n.keep=e,n=n.parent._item},nu=(n,e,t)=>{const{client:r,clock:i}=e.id,o=new kt(je(r,i+t),e,je(r,i+t-1),e.right,e.rightOrigin,e.parent,e.parentSub,e.content.splice(t));return e.deleted&&o.markDeleted(),e.keep&&(o.keep=!0),e.redone!==null&&(o.redone=je(e.redone.client,e.redone.clock+t)),e.right=o,o.right!==null&&(o.right.left=o),n._mergeStructs.push(o),o.parentSub!==null&&o.right===null&&o.parent._map.set(o.parentSub,o),e.length=t,o},Zy=(n,e)=>Zm(n,t=>Fa(t.deletions,e)),ck=(n,e,t,r,i,o)=>{const s=n.doc,a=s.store,l=s.clientID,c=e.redone;if(c!==null)return Wn(n,c);let d=e.parent._item,u=null,h;if(d!==null&&d.deleted===!0){if(d.redone===null&&(!t.has(d)||ck(n,d,t,r,i,o)===null))return null;for(;d.redone!==null;)d=Wn(n,d.redone)}const p=d===null?e.parent:d.content.type;if(e.parentSub===null){for(u=e.left,h=e;u!==null;){let y=u;for(;y!==null&&y.parent._item!==d;)y=y.redone===null?null:Wn(n,y.redone);if(y!==null&&y.parent._item===d){u=y;break}u=u.left}for(;h!==null;){let y=h;for(;y!==null&&y.parent._item!==d;)y=y.redone===null?null:Wn(n,y.redone);if(y!==null&&y.parent._item===d){h=y;break}h=h.right}}else if(h=null,e.right&&!i){for(u=e;u!==null&&u.right!==null&&(u.right.redone||Fa(r,u.right.id)||Zy(o.undoStack,u.right.id)||Zy(o.redoStack,u.right.id));)for(u=u.right;u.redone;)u=Wn(n,u.redone);if(u&&u.right!==null)return null}else u=p._map.get(e.parentSub)||null;const m=Ht(a,l),v=je(l,m),g=new kt(v,u,u&&u.lastId,h,h&&h.id,p,e.parentSub,e.content.copy());return e.redone=v,wg(g,!0),g.integrate(n,0),g};let kt=class Lp extends bg{constructor(e,t,r,i,o,s,a,l){super(e,l.getLength()),this.origin=r,this.left=t,this.right=i,this.rightOrigin=o,this.parent=s,this.parentSub=a,this.redone=null,this.content=l,this.info=this.content.isCountable()?Sy:0}set marker(e){(this.info&oh)>0!==e&&(this.info^=oh)}get marker(){return(this.info&oh)>0}get keep(){return(this.info&_y)>0}set keep(e){this.keep!==e&&(this.info^=_y)}get countable(){return(this.info&Sy)>0}get deleted(){return(this.info&ih)>0}set deleted(e){this.deleted!==e&&(this.info^=ih)}markDeleted(){this.info|=ih}getMissing(e,t){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=Ht(t,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=Ht(t,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===$s&&this.id.client!==this.parent.client&&this.parent.clock>=Ht(t,this.parent.client))return this.parent.client;if(this.origin&&(this.left=Hy(e,t,this.origin),this.origin=this.left.lastId),this.rightOrigin&&(this.right=Wn(e,this.rightOrigin),this.rightOrigin=this.right.id),this.left&&this.left.constructor===pr||this.right&&this.right.constructor===pr)this.parent=null;else if(!this.parent)this.left&&this.left.constructor===Lp?(this.parent=this.left.parent,this.parentSub=this.left.parentSub):this.right&&this.right.constructor===Lp&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===$s){const r=ea(t,this.parent);r.constructor===pr?this.parent=null:this.parent=r.content.type}return null}integrate(e,t){if(t>0&&(this.id.clock+=t,this.left=Hy(e,e.doc.store,je(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(t),this.length-=t),this.parent){if(!this.left&&(!this.right||this.right.left!==null)||this.left&&this.left.right!==this.right){let r=this.left,i;if(r!==null)i=r.right;else if(this.parentSub!==null)for(i=this.parent._map.get(this.parentSub)||null;i!==null&&i.left!==null;)i=i.left;else i=this.parent._start;const o=new Set,s=new Set;for(;i!==null&&i!==this.right;){if(s.add(i),o.add(i),qs(this.origin,i.origin)){if(i.id.client<this.id.client)r=i,o.clear();else if(qs(this.rightOrigin,i.rightOrigin))break}else if(i.origin!==null&&s.has(ea(e.doc.store,i.origin)))o.has(ea(e.doc.store,i.origin))||(r=i,o.clear());else break;i=i.right}this.left=r}if(this.left!==null){const r=this.left.right;this.right=r,this.left.right=this}else{let r;if(this.parentSub!==null)for(r=this.parent._map.get(this.parentSub)||null;r!==null&&r.left!==null;)r=r.left;else r=this.parent._start,this.parent._start=this;this.right=r}this.right!==null?this.right.left=this:this.parentSub!==null&&(this.parent._map.set(this.parentSub,this),this.left!==null&&this.left.delete(e)),this.parentSub===null&&this.countable&&!this.deleted&&(this.parent._length+=this.length),H1(e.doc.store,this),this.content.integrate(e,this),jy(e,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(e)}else new pr(this.id,this.length).integrate(e,0)}get next(){let e=this.right;for(;e!==null&&e.deleted;)e=e.right;return e}get prev(){let e=this.left;for(;e!==null&&e.deleted;)e=e.left;return e}get lastId(){return this.length===1?this.id:je(this.id.client,this.id.clock+this.length-1)}mergeWith(e){if(this.constructor===e.constructor&&qs(e.origin,this.lastId)&&this.right===e&&qs(this.rightOrigin,e.rightOrigin)&&this.id.client===e.id.client&&this.id.clock+this.length===e.id.clock&&this.deleted===e.deleted&&this.redone===null&&e.redone===null&&this.content.constructor===e.content.constructor&&this.content.mergeWith(e.content)){const t=this.parent._searchMarker;return t&&t.forEach(r=>{r.p===e&&(r.p=this,!this.deleted&&this.countable&&(r.index-=this.length))}),e.keep&&(this.keep=!0),this.right=e.right,this.right!==null&&(this.right.left=this),this.length+=e.length,!0}return!1}delete(e){if(!this.deleted){const t=this.parent;this.countable&&this.parentSub===null&&(t._length-=this.length),this.markDeleted(),Ul(e.deleteSet,this.id.client,this.id.clock,this.length),jy(e,t,this.parentSub),this.content.delete(e)}}gc(e,t){if(!this.deleted)throw _n();this.content.gc(e),t?DO(e,this,new pr(this.id,this.length)):this.content=new Yl(this.length)}write(e,t){const r=t>0?je(this.id.client,this.id.clock+t-1):this.origin,i=this.rightOrigin,o=this.parentSub,s=this.content.getRef()&sf|(r===null?0:Ln)|(i===null?0:Li)|(o===null?0:zl);if(e.writeInfo(s),r!==null&&e.writeLeftID(r),i!==null&&e.writeRightID(i),r===null&&i===null){const a=this.parent;if(a._item!==void 0){const l=a._item;if(l===null){const c=jl(a);e.writeParentInfo(!0),e.writeString(c)}else e.writeParentInfo(!1),e.writeLeftID(l.id)}else a.constructor===String?(e.writeParentInfo(!0),e.writeString(a)):a.constructor===$s?(e.writeParentInfo(!1),e.writeLeftID(a)):_n();o!==null&&e.writeString(o)}this.content.write(e,t)}};const dk=(n,e)=>ED[e&sf](n),ED=[()=>{_n()},uD,mD,dD,yD,hD,pD,AD,vD,fD,()=>{_n()}],MD=10;class mr extends bg{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,t){_n()}write(e,t){e.writeInfo(MD),ot(e.restEncoder,this.length-t)}getMissing(e,t){return null}}const uk=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},fk="__ $YJS$ __";uk[fk]===!0&&console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438");uk[fk]=!0;function xg(n){return`${n}_${Date.now()}_${Math.random().toString(36).slice(2,8)}`}function zp(){return xg("ann")}function OD(){return xg("msg")}function DD(n){return xg(n)}function hk(n){return n?n+1:0}function yf(n){let e=0;return n.forEach(t=>{t.isText?e+=t.text.length:t.type.name==="hardBreak"&&(e+=1)}),e}function Ec(n){if(n.isTextblock)return yf(n);let e=0;for(let t=0;t<n.childCount;t++)t>0&&(e+=1),e+=Ec(n.child(t));return e}function pk(n,e,t){if(n.isTextblock)return mn(t+Math.min(e,yf(n)));let r=0,i=t;for(let o=0;o<n.childCount;o++){const s=n.child(o),a=i+1;o>0&&(r+=1);const l=Ec(s);if(r+l>e)return pk(s,e-r,a);r+=l,i+=s.nodeSize}return mn(t+n.content.size)}function To(n,e){let t=0,r=0;const i=n.childCount;for(let o=0;o<i;o++){const s=n.child(o),a=r+1,l=s.type.name==="heading"?hk(s.attrs.level||1):0,c=Ec(s),d=l+c;if(t+d>e){const u=e-t,h=Math.max(0,u-l);return pk(s,h,a)}if(t+=d,r+=s.nodeSize,o<i-1&&(t+=1,t>e))return mn(a+s.content.size)}return mn(n.content.size)}function mk(n,e,t){if(n.isTextblock)return Math.min(e-t,yf(n));let r=0,i=t;for(let o=0;o<n.childCount;o++){const s=n.child(o),a=i+1;o>0&&(r+=1);const l=i+s.nodeSize;if(e<l)return e<=a?r:r+mk(s,e,a);r+=Ec(s),i+=s.nodeSize}return r}function $r(n,e){let t=0,r=0;const i=n.childCount;for(let o=0;o<i;o++){const s=n.child(o),a=r+1,l=s.type.name==="heading"?hk(s.attrs.level||1):0,c=Ec(s),d=r+s.nodeSize;if(e<d)return e<=a?dd(t+l):dd(t+l+mk(s,e,a));t+=l+c,r+=s.nodeSize,o<i-1&&(t+=1)}return dd(t)}function gk(n,e,t,r){if(e.isTextblock){let s=0;for(let a=0;a<n.length;a++){const l=n.get(a);if(l instanceof yn){if(l===r.type)return mn(t+Math.min(s+r.index,yf(e)));s+=l.length}}return null}let i=t;n.length!==e.childCount&&console.warn(`[positions] Y.js/PM child count mismatch: yEl(${n.nodeName}).length=${n.length} vs pmNode(${e.type.name}).childCount=${e.childCount}`);const o=Math.min(n.length,e.childCount);for(let s=0;s<o;s++){const a=n.get(s),l=e.child(s),c=i+1;if(a instanceof Wt){const d=gk(a,l,c,r);if(d!==null)return d}i+=l.nodeSize}return null}function Xy(n,e,t){let r=0;const i=Math.min(n.childCount,e.length);for(let o=0;o<i;o++){const s=e.get(o),a=n.child(o),l=r+1;if(s instanceof Wt){const c=gk(s,a,l,t);if(c!==null)return c}r+=a.nodeSize}return null}function vk(n,e,t){let r,i;try{const l=is(t.fromRel),c=is(t.toRel);r=Dp(l,n),i=Dp(c,n)}catch(l){return console.warn("[positions] relRangeToPmPositions: failed to resolve relRange:",l),null}if(!r||!i)return null;const o=n.getXmlFragment("default"),s=Xy(e,o,r),a=Xy(e,o,i);return s===null||a===null?null:{from:s,to:a}}function ru(n,e,t){if(n.relRange&&t){const r=vk(t,e,n.relRange);if(r&&r.from<=r.to)return{...r,method:"rel"};r&&console.warn(`[positions] annotationToPmRange: inverted rel range for ${n.id}, falling back to flat`)}return n.range?{from:To(e,n.range.from),to:To(e,n.range.to),method:"flat"}:null}function yk(n,e){return{from:$r(n,e.from),to:$r(n,e.to)}}function RD(n){return n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function ND(n){const e=RD(n),t=[];let r=e.replace(/```(\w*)\n?([\s\S]*?)```/g,(i,o,s)=>{const a=t.length,l=o?` class="language-${o}"`:"";return t.push(`<pre><code${l}>${s.trimEnd()}</code></pre>`),`\0BLOCK${a}\0`});r=r.replace(/^### (.+)$/gm,"<h3>$1</h3>").replace(/^## (.+)$/gm,"<h2>$1</h2>").replace(/^# (.+)$/gm,"<h1>$1</h1>").replace(/\*\*\*(.+?)\*\*\*/g,"<strong><em>$1</em></strong>").replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>").replace(/\*(.+?)\*/g,"<em>$1</em>").replace(/`([^`\n]+)`/g,"<code>$1</code>").replace(/\[([^\]]+)\]\(([^)]+)\)/g,(i,o,s)=>{const a=s.trim();return/^(https?:\/\/|mailto:|#)/i.test(a)?`<a href="${a}" target="_blank" rel="noopener noreferrer">${o}</a>`:o}).replace(/^[*-] (.+)$/gm,"<li>$1</li>").replace(/\n\n/g,"</p><p>").replace(/\n/g,"<br>");for(let i=0;i<t.length;i++)r=r.replace(`\0BLOCK${i}\0`,t[i]);return r}var ID=O('<span style="background: var(--tandem-accent); color: var(--tandem-accent-fg); border-radius: var(--tandem-r-pill); padding: 2px 8px; font-size: var(--tandem-text-xs);"> </span>'),PD=O('<button title="Clear chat history" data-testid="clear-chat-btn" style="background: none; border: none; cursor: pointer; color: var(--tandem-fg-subtle); font-size: 13px; padding: 2px 4px; line-height: 1;">Clear</button>'),LD=O('<div style="color: var(--tandem-fg-subtle); font-size: 13px; text-align: center; margin-top: 24px;">No messages yet. Select text and send a message to Claude.</div>'),zD=O('<span style="font-size: var(--tandem-text-2xs); color: var(--tandem-fg-muted); background: var(--tandem-surface-muted); padding: 1px 6px; border-radius: var(--tandem-r-2);"> </span>'),BD=O('<button type="button" class="chat-anchor-quote" title="Click to scroll to this text"> </button>'),FD=O('<div class="chat-markdown svelte-15oag3v"></div>'),VD=O('<div style="white-space: pre-wrap; word-break: break-word;"> </div>'),HD=O('<div><div style="display: flex; gap: 6px; align-items: center; margin-bottom: 4px;"><span> </span> <!> <span style="font-size: 10px; color: var(--tandem-fg-subtle); margin-left: auto;"> </span></div> <!> <!></div>'),UD=O("<span></span>"),jD=O('<div style="padding: var(--tandem-space-2) var(--tandem-space-3); margin-bottom: var(--tandem-space-2); font-size: 12px; color: var(--tandem-author-claude); display: flex; align-items: center; gap: var(--tandem-space-2);"><span style="display: inline-flex; gap: 3px;"></span> <span> </span></div>'),WD=O('<div style="padding: var(--tandem-space-1) var(--tandem-space-3); background: var(--tandem-accent-bg); border-top: 1px solid var(--tandem-accent-border); font-size: 11px; color: var(--tandem-accent-fg-strong); display: flex; justify-content: space-between; align-items: center;"><span> </span> <button style="background: none; border: none; cursor: pointer; color: var(--tandem-fg-muted); font-size: 14px;">x</button></div>'),KD=O('<div style="width: 100%; display: flex; flex-direction: column; background: var(--tandem-surface-muted); flex: 1; min-height: 0;"><div style="padding: var(--tandem-space-3) var(--tandem-space-4); border-bottom: 1px solid var(--tandem-border); font-weight: 600; font-size: var(--tandem-text-md); display: flex; justify-content: space-between; align-items: center;">Chat <div style="display: flex; align-items: center; gap: var(--tandem-space-2);"><!> <!></div></div> <div style="flex: 1; overflow: auto; padding: var(--tandem-space-3); min-height: 0;"><!> <!> <!> <div></div></div> <!> <div style="padding: var(--tandem-space-2) var(--tandem-space-3); border-top: 1px solid var(--tandem-border); display: flex; gap: var(--tandem-space-2);"><textarea placeholder="Message Claude..." style="flex: 1; padding: var(--tandem-space-2); border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-3); font-size: var(--tandem-text-base); resize: none; outline: none; font-family: inherit; background: var(--tandem-surface); color: var(--tandem-fg);"></textarea> <button>Send</button></div></div>');function Qy(n,e){We(e,!0);const t=[0,.2,.4];let r=lt(e,"inputEl",15,null);const i=P(()=>e.reduceMotion?"auto":"smooth");let o=z(at([])),s=z(""),a=z(void 0),l=z(void 0);he(()=>{r(f(l)??null)}),he(()=>{if(!e.ctrlYdoc)return;const C=e.ctrlYdoc.getMap(Gv),I=()=>{const W=[];C.forEach(ge=>{W.push(ge)}),W.sort((ge,xe)=>ge.timestamp-xe.timestamp||ge.id.localeCompare(xe.id)),b(o,W,!0)};return C.observe(I),I(),()=>C.unobserve(I)});let c=!1;he(()=>{var W;f(o);const C=!!e.claudeActive,I=f(i);if(!C&&c){c=!1;return}c=C,(W=f(a))==null||W.scrollIntoView({behavior:I})}),he(()=>{var W;const C=e.visible,I=f(i);C&&((W=f(a))==null||W.scrollIntoView({behavior:I}))});const d=P(()=>f(o).filter(C=>C.author==="claude"&&!C.read).length);function u(){if(!e.ctrlYdoc||!f(s).trim())return;const C=e.ctrlYdoc.getMap(Gv),I={id:OD(),author:"user",text:f(s).trim(),timestamp:Date.now(),...e.activeDocId?{documentId:e.activeDocId}:{},...e.capturedAnchor?{anchor:e.capturedAnchor}:{},read:!1};C.set(I.id,I),b(s,""),e.onCapturedAnchorChange(null)}function h(C){C.key==="Enter"&&!C.shiftKey&&(C.preventDefault(),u())}function p(C,I){if(!(!e.editor||I&&I!==e.activeDocId))try{const W=To(e.editor.state.doc,C.from),ge=To(e.editor.state.doc,C.to);e.editor.chain().focus().setTextSelection({from:W,to:ge}).scrollIntoView().run()}catch(W){console.warn("[ChatPanel] Could not scroll to anchor:",W instanceof Error?W.message:W)}}function m(C){if(!C)return null;const I=e.openDocs.find(W=>W.id===C);return(I==null?void 0:I.fileName)??null}async function v(){try{await fetch(`http://localhost:${wc}/api/chat`,{method:"DELETE"})}catch(C){console.warn("[ChatPanel] Failed to clear chat:",C)}}let g=z(at(new Set));function y(C){const I=new Set(f(g));I.has(C)?I.delete(C):I.add(C),b(g,I,!0)}var w=KD(),_=x(w),S=k(x(_)),A=x(S);{var U=C=>{var I=ID(),W=x(I);G(()=>ne(W,f(d))),T(C,I)};Z(A,C=>{f(d)>0&&C(U)})}var N=k(A,2);{var R=C=>{var I=PD();L("click",I,v),T(C,I)};Z(N,C=>{f(o).length>0&&C(R)})}var E=k(_,2),q=x(E);{var te=C=>{var I=LD();T(C,I)};Z(q,C=>{f(o).length===0&&C(te)})}var K=k(q,2);ft(K,17,()=>f(o),C=>C.id,(C,I)=>{var W=HD(),ge=x(W),xe=x(ge),Oe=x(xe),J=k(xe,2);{var fe=oe=>{var M=zD(),$=x(M);G(le=>ne($,le),[()=>m(f(I).documentId)??f(I).documentId]),T(oe,M)};Z(J,oe=>{f(I).documentId&&oe(fe)})}var D=k(J,2),Y=x(D),be=k(ge,2);{var we=oe=>{var M=BD(),$=x(M);G(le=>{re(M,`background: var(--tandem-accent-bg); border: none; border-left: 3px solid var(--tandem-accent-border); padding: 4px 8px; margin-bottom: 6px; font: inherit; color: var(--tandem-accent-fg-strong); cursor: pointer; text-align: left; width: 100%; font-size: var(--tandem-text-sm); border-radius: 0 var(--tandem-r-2) var(--tandem-r-2) 0; max-height: ${le??""}; overflow: hidden; transition: max-height 0.3s ease;`),ne($,f(I).anchor.textSnapshot)},[()=>f(g).has(f(I).id)?"500px":"60px"]),L("click",M,()=>p(f(I).anchor,f(I).documentId)),vt("mouseenter",M,()=>y(f(I).id)),vt("mouseleave",M,()=>y(f(I).id)),T(oe,M)};Z(be,oe=>{f(I).anchor&&oe(we)})}var Te=k(be,2);{var Se=oe=>{var M=FD();fT(M,()=>ND(f(I).text),!0),T(oe,M)},De=oe=>{var M=VD(),$=x(M);G(()=>ne($,f(I).text)),T(oe,M)};Z(Te,oe=>{f(I).author==="claude"?oe(Se):oe(De,-1)})}G(oe=>{re(W,`margin-bottom: var(--tandem-space-3); padding: var(--tandem-space-2) var(--tandem-space-3); border-radius: var(--tandem-r-4); background: ${f(I).author==="user"?"var(--tandem-accent-bg)":"var(--tandem-surface)"}; border: 1px solid ${f(I).author==="user"?"var(--tandem-accent-border)":"var(--tandem-border)"}; font-size: var(--tandem-text-base); color: var(--tandem-fg); box-shadow: var(--tandem-shadow-1);`),re(xe,`font-weight: 600; font-size: 11px; color: ${f(I).author==="claude"?"var(--tandem-accent)":"var(--tandem-fg-muted)"}; text-transform: uppercase;`),ne(Oe,f(I).author),ne(Y,oe)},[()=>new Date(f(I).timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})]),T(C,W)});var V=k(K,2);{var ee=C=>{var I=jD(),W=x(I);ft(W,20,()=>t,Oe=>Oe,(Oe,J)=>{var fe=UD();G(()=>re(fe,`width: 5px; height: 5px; border-radius: 50%; background: var(--tandem-author-claude); animation: tandem-typing-bounce 1.2s ease-in-out ${J??""}s infinite;`)),T(Oe,fe)});var ge=k(W,2),xe=x(ge);G(()=>ne(xe,e.claudeStatus??"Claude is thinking...")),T(C,I)};Z(V,C=>{e.claudeActive&&C(ee)})}var se=k(V,2);yt(se,C=>b(a,C),()=>f(a));var F=k(E,2);{var X=C=>{var I=WD(),W=x(I),ge=x(W),xe=k(W,2);G(Oe=>ne(ge,`with selection: “${Oe??""}${e.capturedAnchor.textSnapshot.length>40?"...":""}”`),[()=>e.capturedAnchor.textSnapshot.slice(0,40)]),L("click",xe,()=>e.onCapturedAnchorChange(null)),T(C,I)};Z(F,C=>{e.capturedAnchor&&C(X)})}var B=k(F,2),j=x(B);Q(j,"rows",2),yt(j,C=>b(l,C),()=>f(l));var ae=k(j,2);G((C,I,W,ge)=>{Rr(j,f(s)),ae.disabled=C,re(ae,`padding: var(--tandem-space-2) var(--tandem-space-3); background: ${I??""}; color: ${W??""}; border: none; border-radius: var(--tandem-r-3); cursor: ${ge??""}; font-size: var(--tandem-text-base); font-weight: 500; align-self: flex-end;`)},[()=>!f(s).trim(),()=>f(s).trim()?"var(--tandem-accent)":"var(--tandem-border-strong)",()=>f(s).trim()?"var(--tandem-accent-fg)":"var(--tandem-fg-subtle)",()=>f(s).trim()?"pointer":"default"]),L("input",j,C=>b(s,C.target.value,!0)),L("keydown",j,h),L("click",ae,u),T(n,w),Ke()}Ye(["click","input","keydown"]);function Ea(n,e){const t=n,r=s=>{try{e(s)}catch(a){console.warn(`[sanitizeAnnotation] onLossy threw for ${s.kind}:`,a)}},i=t.audience==="private"||t.audience==="outbound"?t.audience:t.author==="import"||t.type==="highlight"||t.type==="note"||t.type==="flag"?"private":"outbound",o={id:t.id,author:t.author,range:t.range,content:t.content,status:t.status,timestamp:t.timestamp,...t.relRange!==void 0?{relRange:t.relRange}:{},...t.textSnapshot!==void 0?{textSnapshot:t.textSnapshot}:{},...t.editedAt!==void 0?{editedAt:t.editedAt}:{},...typeof t.rev=="number"?{rev:t.rev}:{},audience:i,...t.promotedFrom!==void 0?{promotedFrom:t.promotedFrom}:{},...t.importSource!==void 0?{importSource:t.importSource}:{}};if(o.audience==="outbound"&&t.author==="user"&&(t.type==="note"||t.type==="highlight"||t.type==="flag")&&(o.audience="private",r({kind:"audience-conflict-resolved",id:t.id})),t.type==="suggestion"){let s,a;try{const l=JSON.parse(t.content);s=l.newText,a=l.reason??""}catch{r({kind:"malformed-suggestion-json",id:t.id}),a=t.content}return{...o,type:"comment",content:a,suggestedText:s}}return t.type==="question"?(r({kind:"question-to-comment",id:t.id}),{...o,type:"comment"}):t.type==="highlight"?{...o,type:"highlight",color:t.color}:t.author==="import"&&t.type==="note"?(r({kind:"import-note-to-comment",id:t.id}),{...o,type:"comment"}):t.type==="flag"||t.type==="note"?(t.type==="flag"&&r({kind:"flag-to-note",id:t.id}),{...o,type:"note"}):t.type==="comment"?{...o,type:"comment",...t.suggestedText!==void 0?{suggestedText:t.suggestedText}:{}}:(r({kind:"unknown-type",id:t.id,rawType:t.type}),{...o,type:"comment"})}var qD=O('<button type="button" data-testid="apply-changes-btn"> </button>');function JD(n,e){We(e,!0);let t=z(!1);const r=P(()=>e.annotations.filter(d=>d.status==="accepted")),i=P(()=>e.annotations.filter(d=>d.status==="pending")),o=P(()=>f(r).length===0||f(t));async function s(){if(f(o)||!e.documentId)return;let d=`Apply ${f(r).length} change(s) as tracked revisions?
|
|
49
|
-
|
|
50
|
-
The changes will appear as tracked revisions in Word — you can Accept or Reject each one individually.
|
|
51
|
-
|
|
52
|
-
Your original file will be backed up.`;if(f(i).length>0&&(d+=`
|
|
53
|
-
|
|
54
|
-
⚠ ${f(i).length} annotation(s) are still pending review and will not be applied.`),!!confirm(d)){b(t,!0);try{const u=await fetch(`${Sr}/apply-changes`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({documentId:e.documentId})}),h=await u.json().catch(m=>(console.error("[ApplyChanges] Failed to parse response JSON:",m),null));if(!u.ok){alert((h==null?void 0:h.message)??`Apply failed (HTTP ${u.status}).`);return}const p=h==null?void 0:h.data;if(p){const m=[`Applied ${p.applied??0} tracked change(s).`];p.rejected>0&&m.push(`${p.rejected} could not be applied.`),p.backupPath&&m.push(`
|
|
55
|
-
Backup saved to:
|
|
56
|
-
${p.backupPath}`),alert(m.join(" "))}else alert("Changes applied successfully.")}catch(u){console.error("[ApplyChanges] Request failed:",u),alert(u instanceof TypeError?"Could not reach the server.":`Apply failed: ${u instanceof Error?u.message:String(u)}`)}finally{b(t,!1)}}}var a=Tt(),l=Le(a);{var c=d=>{var u=qD(),h=x(u);G(()=>{u.disabled=f(o),Q(u,"title",f(r).length===0?"No accepted suggestions to apply":void 0),re(u,`width: 100%; padding: var(--tandem-space-1) var(--tandem-space-3); font-size: var(--tandem-text-xs); font-weight: 500; border: 1px solid ${f(o)?"var(--tandem-border)":"var(--tandem-info-border)"}; border-radius: var(--tandem-r-2); background: ${f(o)?"var(--tandem-surface-muted)":"var(--tandem-info)"}; color: ${f(o)?"var(--tandem-fg-subtle)":"var(--tandem-info-fg)"}; cursor: ${f(o)?"default":"pointer"}; opacity: ${f(t)?.6:1}; white-space: nowrap;`),ne(h,f(t)?"Applying…":`Apply as Tracked Changes (${f(r).length})`)}),L("click",u,s),T(d,u)};Z(l,d=>{e.activeDocFormat==="docx"&&d(c)})}T(n,a),Ke()}Ye(["click"]);const Io={background:"var(--tandem-warning-bg)",border:"var(--tandem-warning-border)",color:"var(--tandem-warning-fg-strong)"};var YD=O('<button style="padding: 2px 8px; font-size: var(--tandem-text-xs); border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-1); background: var(--tandem-success-bg); color: var(--tandem-success-fg-strong); cursor: pointer;">Accept</button>'),GD=O('<button style="padding: 2px 8px; font-size: var(--tandem-text-xs); border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-1); background: var(--tandem-error-bg); color: var(--tandem-error-fg-strong); cursor: pointer;">Reject</button>'),ZD=O('<div style="display: flex; gap: 4px; margin-top: 4px;"><!> <!></div>'),XD=O('<button style="padding: 2px 8px; font-size: var(--tandem-text-xs); border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-1); background: var(--tandem-surface-muted); color: var(--tandem-fg-muted); cursor: pointer;">Archive</button>'),QD=O('<button style="padding: 2px 8px; font-size: var(--tandem-text-xs); border: 1px solid var(--tandem-accent-border); border-radius: var(--tandem-r-1); background: var(--tandem-accent-bg); color: var(--tandem-accent); cursor: pointer;">Send to Claude</button>'),$D=O('<div style="display: flex; gap: 4px; margin-top: 4px;"><!> <!></div>'),eR=O('<button style="margin-top: 4px; padding: 2px 8px; font-size: var(--tandem-text-xs); border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-1); background: var(--tandem-surface-muted); color: var(--tandem-fg-muted); cursor: pointer;">Remove</button>'),tR=O(`<div style="font-size: var(--tandem-text-xs); color: var(--tandem-error-fg); margin-top: 2px;">Can't undo — text has changed.</div>`),nR=O('<div style="margin-top: 4px;"><button data-testid="undo-btn" style="padding: 1px 6px; font-size: var(--tandem-text-xs); border: none; background: none; color: var(--tandem-accent); cursor: pointer; text-decoration: underline;">Undo</button> <!></div>');function rR(n,e){We(e,!0);let t=z(!1),r=null;function i(){r&&(clearTimeout(r),r=null)}function o(h){if(h.stopPropagation(),!e.onUndo)return;const p=e.onUndo(e.annotationId);if(p){i(),b(t,!1);return}p||(b(t,!0),i(),r=setTimeout(()=>{b(t,!1),r=null},3e3))}pi(i);var s=Tt(),a=Le(s);{var l=h=>{var p=ZD(),m=x(p);{var v=w=>{var _=YD();G(()=>Q(_,"data-testid",`accept-btn-${e.annotationId??""}`)),L("click",_,S=>{S.stopPropagation(),e.onAccept(e.annotationId)}),T(w,_)};Z(m,w=>{e.onAccept&&w(v)})}var g=k(m,2);{var y=w=>{var _=GD();G(()=>Q(_,"data-testid",`dismiss-btn-${e.annotationId??""}`)),L("click",_,S=>{S.stopPropagation(),e.onDismiss(e.annotationId)}),T(w,_)};Z(g,w=>{e.onDismiss&&w(y)})}T(h,p)},c=h=>{var p=$D(),m=x(p);{var v=w=>{var _=XD();G(()=>Q(_,"data-testid",`archive-btn-${e.annotationId??""}`)),L("click",_,S=>{S.stopPropagation(),e.onRemove(e.annotationId)}),T(w,_)};Z(m,w=>{e.onRemove&&w(v)})}var g=k(m,2);{var y=w=>{var _=QD();G(()=>Q(_,"data-testid",`send-to-claude-btn-${e.annotationId??""}`)),L("click",_,S=>{S.stopPropagation(),e.onSendToClaude(e.annotationId)}),T(w,_)};Z(g,w=>{e.onSendToClaude&&w(y)})}T(h,p)},d=h=>{var p=eR();G(()=>Q(p,"data-testid",`remove-btn-${e.annotationId??""}`)),L("click",p,m=>{m.stopPropagation(),e.onRemove(e.annotationId)}),T(h,p)},u=h=>{var p=nR(),m=x(p),v=k(m,2);{var g=y=>{var w=tR();T(y,w)};Z(v,y=>{f(t)&&y(g)})}L("click",m,o),T(h,p)};Z(a,h=>{e.isPending&&!e.isEditing&&(e.onAccept||e.onDismiss)?h(l):e.isPending&&!e.isEditing&&e.annotationType==="note"?h(c,1):e.isPending&&!e.isEditing&&e.onRemove?h(d,2):!e.isPending&&e.undoable&&e.onUndo&&h(u,3)})}T(n,s),Ke()}Ye(["click"]);const bd="width: 100%; padding: 4px 6px; font-size: var(--tandem-text-xs); border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-1); resize: vertical; font-family: inherit; min-height: 40px; box-sizing: border-box; background: var(--tandem-surface); color: var(--tandem-fg);";var iR=O('<label style="font-size: var(--tandem-text-xs); color: var(--tandem-fg-muted); display: block; margin-bottom: 2px;">Replacement text</label> <textarea></textarea> <label style="font-size: var(--tandem-text-xs); color: var(--tandem-fg-muted); display: block; margin-top: 4px; margin-bottom: 2px;">Reason</label> <textarea></textarea>',1),oR=O("<textarea></textarea>"),sR=O('<div style="margin-top: 4px;"><!> <div style="display: flex; gap: 2px; margin-top: 4px;"><button style="padding: 2px 8px; font-size: var(--tandem-text-xs); border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-1); background: var(--tandem-success-bg); color: var(--tandem-success-fg-strong); cursor: pointer;">Save</button> <button style="padding: 2px 8px; font-size: var(--tandem-text-xs); border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-1); background: var(--tandem-surface); color: var(--tandem-fg-muted); cursor: pointer;">Cancel</button></div></div>');function aR(n,e){We(e,!0);let t=z(null);he(()=>{var d;(d=f(t))==null||d.focus()});var r=sR(),i=x(r);{var o=d=>{var u=iR(),h=Le(u),p=k(h,2);yt(p,g=>b(t,g),()=>f(t));var m=k(p,2),v=k(m,2);G(()=>{Q(h,"for",`edit-newtext-${e.annotationId??""}`),Q(p,"id",`edit-newtext-${e.annotationId??""}`),Q(p,"data-testid",`edit-newtext-${e.annotationId??""}`),Rr(p,e.editNewText),re(p,bd),Q(m,"for",`edit-reason-${e.annotationId??""}`),Q(v,"id",`edit-reason-${e.annotationId??""}`),Q(v,"data-testid",`edit-reason-${e.annotationId??""}`),Rr(v,e.editReason),re(v,bd)}),L("input",p,g=>e.onChangeEditNewText(g.target.value)),L("keydown",p,function(...g){var y;(y=e.onKeyDown)==null||y.apply(this,g)}),L("input",v,g=>e.onChangeEditReason(g.target.value)),L("keydown",v,function(...g){var y;(y=e.onKeyDown)==null||y.apply(this,g)}),T(d,u)},s=d=>{var u=oR();yt(u,h=>b(t,h),()=>f(t)),G(()=>{Q(u,"data-testid",`edit-text-${e.annotationId??""}`),Rr(u,e.editText),re(u,bd)}),L("input",u,h=>e.onChangeEditText(h.target.value)),L("keydown",u,function(...h){var p;(p=e.onKeyDown)==null||p.apply(this,h)}),T(d,u)};Z(i,d=>{e.hasSuggestedText?d(o):d(s,-1)})}var a=k(i,2),l=x(a),c=k(l,2);G(()=>{Q(l,"data-testid",`edit-save-btn-${e.annotationId??""}`),Q(c,"data-testid",`edit-cancel-btn-${e.annotationId??""}`)}),L("click",r,d=>d.stopPropagation()),L("keydown",r,d=>d.stopPropagation()),L("click",l,d=>{d.stopPropagation(),e.onSave()}),L("click",c,d=>{d.stopPropagation(),e.onCancel()}),T(n,r),Ke()}Ye(["click","keydown","input"]);var lR=O('<span style="font-style: italic; margin-right: 4px;">(edited)</span>'),cR=O('<div style="padding: 4px 0; font-size: 12px; line-height: 1.4;"><div style="display: flex; justify-content: space-between; margin-bottom: 2px;"><span> </span> <span style="font-size: 10px; color: var(--tandem-fg-subtle);"><!> </span></div> <p style="margin: 0; color: var(--tandem-fg);"> </p></div>'),dR=O('<div data-testid="comment-thread" style="margin-top: 6px; padding-left: 8px; border-left: 2px solid var(--tandem-border);"></div>');function uR(n,e){We(e,!0);function t(s){const a=new Date(s),c=new Date().getTime()-a.getTime(),d=Math.floor(c/6e4);if(d<1)return"just now";if(d<60)return`${d}m ago`;const u=Math.floor(d/60);return u<24?`${u}h ago`:a.toLocaleDateString()}var r=Tt(),i=Le(r);{var o=s=>{var a=dR();ft(a,21,()=>e.replies,l=>l.id,(l,c)=>{var d=cR(),u=x(d),h=x(u),p=x(h),m=k(h,2),v=x(m);{var g=S=>{var A=lR();T(S,A)};Z(v,S=>{f(c).editedAt&&S(g)})}var y=k(v),w=k(u,2),_=x(w);G(S=>{Q(d,"data-testid",`reply-${f(c).id??""}`),re(h,`font-weight: 600; font-size: 11px; color: ${f(c).author==="claude"?"var(--tandem-accent)":"var(--tandem-fg-muted)"};`),ne(p,f(c).author==="claude"?"Claude":"You"),ne(y,` ${S??""}`),ne(_,f(c).text)},[()=>t(f(c).timestamp)]),T(l,d)}),T(s,a)};Z(i,s=>{e.replies.length>0&&s(o)})}T(n,r),Ke()}var fR=O('<div><textarea placeholder="Write a reply..."></textarea> <div style="display: flex; gap: 2px; margin-top: 2px;"><button>Send</button> <button style="padding: 2px 8px; font-size: var(--tandem-text-xs); border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-1); background: var(--tandem-surface); color: var(--tandem-fg-muted); cursor: pointer;">Cancel</button></div></div>'),hR=O('<button style="padding: 1px 4px; font-size: var(--tandem-text-xs); border: none; background: none; color: var(--tandem-fg-subtle); cursor: pointer;"> </button>'),pR=O('<div style="margin-top: 6px;"><!></div>'),mR=O('<div style="margin-top: 4px; font-size: var(--tandem-text-xs); color: var(--tandem-fg-subtle);"> </div>'),gR=O("<!> <!> <!>",1);function vR(n,e){We(e,!0);let t=z(!1),r=z(""),i=z(!1),o=z(null);const s=P(()=>!!f(r).trim());he(()=>{var v;f(t)&&((v=f(o))==null||v.focus())});function a(v){v.key==="Escape"&&(v.stopPropagation(),b(t,!1),b(r,""))}async function l(){var g;const v=f(r).trim();if(!(!v||f(i))){b(i,!0);try{await((g=e.onReply)==null?void 0:g.call(e,e.annotationId,v))!==!1&&(b(r,""),b(t,!1))}finally{b(i,!1)}}}var c=gR(),d=Le(c);uR(d,{get replies(){return e.replies}});var u=k(d,2);{var h=v=>{var g=pR(),y=x(g);{var w=S=>{var A=fR(),U=x(A);yt(U,q=>b(o,q),()=>f(o));var N=k(U,2),R=x(N),E=k(R,2);G(()=>{Q(U,"data-testid",`reply-input-${e.annotationId??""}`),Rr(U,f(r)),re(U,bd),Q(R,"data-testid",`reply-send-btn-${e.annotationId??""}`),R.disabled=!f(s)||f(i),re(R,`padding: 2px 8px; font-size: var(--tandem-text-xs); border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-1); background: ${f(s)?"var(--tandem-accent-bg)":"var(--tandem-surface-muted)"}; color: ${f(s)?"var(--tandem-accent-fg-strong)":"var(--tandem-fg-subtle)"}; cursor: ${f(s)?"pointer":"default"};`),Q(E,"data-testid",`reply-cancel-btn-${e.annotationId??""}`)}),L("input",U,q=>b(r,q.target.value,!0)),L("keydown",U,a),L("click",R,l),L("click",E,()=>{b(t,!1),b(r,"")}),T(S,A)},_=S=>{var A=hR(),U=x(A);G(()=>{Q(A,"data-testid",`reply-btn-${e.annotationId??""}`),ne(U,`Reply${e.replies.length>0?` (${e.replies.length})`:""}`)}),L("click",A,()=>b(t,!0)),T(S,A)};Z(y,S=>{f(t)?S(w):S(_,-1)})}L("click",g,S=>S.stopPropagation()),L("keydown",g,S=>S.stopPropagation()),T(v,g)};Z(u,v=>{e.isPending&&e.onReply&&!e.isEditing&&v(h)})}var p=k(u,2);{var m=v=>{var g=mR(),y=x(g);G(()=>ne(y,`${e.replies.length??""}
|
|
57
|
-
${e.replies.length===1?"reply":"replies"}`)),T(v,g)};Z(p,v=>{!e.isPending&&e.replies.length>0&&!e.onReply&&v(m)})}T(n,c),Ke()}Ye(["click","keydown","input"]);var yR=O('<span data-testid="annotation-private-pill" aria-hidden="true" title="Private note" style="padding: 1px 6px; font-size: var(--tandem-text-2xs); font-weight: 600; letter-spacing: 0.02em; text-transform: uppercase; color: var(--tandem-warning-fg); background: var(--tandem-warning); border-radius: var(--tandem-r-2); line-height: 1;">Private</span>'),bR=O("<span> </span>"),wR=O(`<button style="padding: 1px 4px; font-size: 11px; border: none; background: none; color: var(--tandem-fg-subtle); cursor: pointer; line-height: 1;" title="Edit this annotation's content">✎ Edit</button>`),xR=O('<span style="font-style: italic; font-size: 10px; color: var(--tandem-fg-subtle);">(edited)</span>'),kR=O('<div style="padding: 4px 8px; margin-bottom: 6px; border-left: 3px solid var(--tandem-border-strong); color: var(--tandem-fg-muted); font-size: 12px; font-style: italic; background-color: var(--tandem-surface-muted); border-radius: var(--tandem-r-1);"> </div>'),_R=O('<span style="text-decoration: line-through; color: var(--tandem-error); background-color: var(--tandem-error-bg); padding: 0 2px; border-radius: var(--tandem-r-1);"> </span>'),SR=O('<p style="margin: 0; font-size: 12px; color: var(--tandem-fg-muted);"> </p>'),CR=O('<div><!> <!> <span style="color: var(--tandem-success-fg-strong); background-color: var(--tandem-success-bg); padding: 0 2px; border-radius: var(--tandem-r-1);"> </span></div> <!>',1),TR=O('<p style="margin: 0;"> </p>'),AR=O('<div style="margin: 0; color: var(--tandem-fg); line-height: 1.45;"><!></div>'),ER=O('<div role="listitem"><div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; gap: 8px;"><span style="font-weight: 600; text-transform: capitalize; display: flex; align-items: center; gap: 6px; color: var(--tandem-fg-muted); font-size: 11px;"><span class="annotation-type-badge svelte-3ascys"> </span> <!> <!> <!></span> <span style="font-size: 11px; color: var(--tandem-fg-subtle); display: flex; align-items: center; gap: 4px;"><!> </span></div> <!> <!> <!> <!></div>');function $y(n,e){We(e,!0);let t=lt(e,"replies",19,()=>[]),r=z(!1),i=z(""),o=z(""),s=z("");const a=P(()=>e.annotation.status==="pending"),l=P(()=>e.annotation.suggestedText!==void 0);function c(D){return D.suggestedText!==void 0?"replacement":D.type}function d(D){return D==="claude"?"Claude":D==="import"?"Imported":"You"}function u(D){return D.color?Rl[Yw(D.color)]:D.suggestedText!==void 0?"var(--tandem-suggestion)":D.type==="note"?"var(--tandem-warning)":"var(--tandem-author-user)"}function h(D,Y){return Y?"var(--tandem-accent-bg)":(D.type==="note","var(--tandem-surface)")}const p=P(()=>c(e.annotation)),m=P(()=>u(e.annotation)),v=P(()=>h(e.annotation,e.isReviewTarget)),g=P(()=>e.annotation.type==="note"),y=P(()=>e.annotation.content?e.annotation.content.length>60?e.annotation.content.slice(0,57)+"...":e.annotation.content:""),w=P(()=>`${f(g)?"private ":""}${f(p)} annotation${f(y)?": "+f(y):""}, ${e.annotation.status}`);function _(){f(l)?(b(o,e.annotation.suggestedText??"",!0),b(s,e.annotation.content,!0)):b(i,e.annotation.content,!0),b(r,!0)}function S(){var Y;const D=f(l)?JSON.stringify({suggestedText:f(o),content:f(s)}):f(i);(Y=e.onEdit)==null||Y.call(e,e.annotation.id,D),b(r,!1)}function A(){b(r,!1)}function U(D){D.key==="Escape"&&(D.stopPropagation(),A())}var N=ER(),R=x(N),E=x(R),q=x(E),te=x(q),K=k(q,2);{var V=D=>{var Y=yR();T(D,Y)};Z(K,D=>{f(g)&&D(V)})}var ee=k(K,2);{var se=D=>{var Y=bR(),be=x(Y);G(()=>{re(Y,`margin-left: 6px; font-size: 10px; color: ${e.annotation.status==="accepted"?"var(--tandem-success)":"var(--tandem-error)"}; font-weight: 600;`),ne(be,e.annotation.status)}),T(D,Y)};Z(ee,D=>{f(a)||D(se)})}var F=k(ee,2);{var X=D=>{var Y=wR();G(()=>Q(Y,"data-testid",`edit-btn-${e.annotation.id??""}`)),L("click",Y,be=>{be.stopPropagation(),_()}),T(D,Y)};Z(F,D=>{f(a)&&e.onEdit&&!e.isReviewTarget&&!f(r)&&D(X)})}var B=k(E,2),j=x(B);{var ae=D=>{var Y=xR();T(D,Y)};Z(j,D=>{e.annotation.editedAt&&D(ae)})}var C=k(j),I=k(R,2);{var W=D=>{var Y=kR(),be=x(Y);G(we=>{Q(Y,"data-testid",`annotation-snippet-${e.annotation.id??""}`),ne(be,we)},[()=>e.annotation.textSnapshot.length>80?e.annotation.textSnapshot.slice(0,77)+"...":e.annotation.textSnapshot]),T(D,Y)};Z(I,D=>{e.annotation.textSnapshot&&D(W)})}var ge=k(I,2);{var xe=D=>{aR(D,{get annotationId(){return e.annotation.id},get hasSuggestedText(){return f(l)},get editText(){return f(i)},get editNewText(){return f(o)},get editReason(){return f(s)},onChangeEditText:Y=>b(i,Y,!0),onChangeEditNewText:Y=>b(o,Y,!0),onChangeEditReason:Y=>b(s,Y,!0),onKeyDown:U,onSave:S,onCancel:A})},Oe=D=>{var Y=AR(),be=x(Y);{var we=Se=>{var De=CR(),oe=Le(De),M=x(oe);{var $=pe=>{var ze=_R(),tt=x(ze);G(()=>ne(tt,e.annotation.textSnapshot)),T(pe,ze)};Z(M,pe=>{e.annotation.textSnapshot&&pe($)})}var le=k(M,2);{var de=pe=>{var ze=Nn();ze.nodeValue=" → ",T(pe,ze)};Z(le,pe=>{e.annotation.textSnapshot&&pe(de)})}var Ee=k(le,2),ce=x(Ee),ve=k(oe,2);{var ke=pe=>{var ze=SR(),tt=x(ze);G(()=>ne(tt,e.annotation.content)),T(pe,ze)};Z(ve,pe=>{e.annotation.content&&pe(ke)})}G(()=>{Q(oe,"data-testid",`suggestion-diff-${e.annotation.id??""}`),re(oe,`padding: 4px 8px; margin-bottom: ${e.annotation.content?"4px":"0"}; background-color: var(--tandem-surface-muted); border-radius: var(--tandem-r-2); font-size: 12px; line-height: 1.5;`),ne(ce,e.annotation.suggestedText)}),T(Se,De)},Te=Se=>{var De=TR(),oe=x(De);G(()=>ne(oe,e.annotation.content||"(no note)")),T(Se,De)};Z(be,Se=>{f(l)?Se(we):Se(Te,-1)})}T(D,Y)};Z(ge,D=>{f(r)?D(xe):D(Oe,-1)})}var J=k(ge,2);rR(J,{get annotationId(){return e.annotation.id},get annotationType(){return e.annotation.type},get isPending(){return f(a)},get isEditing(){return f(r)},get undoable(){return e.undoable},get onAccept(){return e.onAccept},get onDismiss(){return e.onDismiss},get onUndo(){return e.onUndo},get onRemove(){return e.onRemove},get onSendToClaude(){return e.onSendToClaude}});var fe=k(J,2);vR(fe,{get annotationId(){return e.annotation.id},get replies(){return t()},get isPending(){return f(a)},get isEditing(){return f(r)},get onReply(){return e.onReply}}),G(D=>{Q(N,"data-testid",`annotation-card-${e.annotation.id??""}`),Q(N,"aria-label",f(w)),Q(N,"aria-current",e.isReviewTarget?"true":void 0),re(N,`padding: var(--tandem-space-3); margin-bottom: var(--tandem-space-2); border: 1px solid var(--tandem-border); border-left: 3px solid ${f(m)??""}; background: ${f(v)??""}; border-radius: var(--tandem-r-3); font-size: var(--tandem-text-base); opacity: ${f(a)?1:.6}; cursor: ${e.onClick?"pointer":"default"}; box-shadow: ${e.isReviewTarget?"0 0 0 3px var(--tandem-accent-bg)":"none"}; transition: background 0.15s, box-shadow 0.15s, border-color 0.15s;`),re(q,`font-family: var(--tandem-font-mono); font-size: var(--tandem-text-2xs); letter-spacing: 0.04em; text-transform: uppercase; padding: 1px 7px; border-radius: var(--tandem-r-pill); background: ${f(l)?"var(--tandem-suggestion-bg)":e.annotation.type==="note"?"var(--tandem-warning-bg)":"var(--tandem-surface-sunk)"}; color: ${f(l)?"var(--tandem-suggestion-fg-strong)":e.annotation.type==="note"?"var(--tandem-warning-fg-strong)":"var(--tandem-fg-muted)"};`),ne(te,f(p)),ne(C,` ${D??""}`)},[()=>d(e.annotation.author)]),L("click",N,function(...D){var Y;(Y=e.onClick)==null||Y.apply(this,D)}),T(n,N),Ke()}Ye(["click"]);var MR=O('<span style="font-size: var(--tandem-text-xs); color: var(--tandem-fg);"> </span> <button data-testid="bulk-confirm-btn">Confirm</button> <button data-testid="bulk-cancel-btn">Cancel</button>',1),OR=O('<button data-testid="bulk-accept-btn"> </button> <button data-testid="bulk-dismiss-btn">Reject All</button>',1),DR=O('<div style="padding: 6px var(--tandem-space-4); border-bottom: 1px solid var(--tandem-border); display: flex; gap: 4px; align-items: center;"><!></div>');function RR(n,e){We(e,!0);let t=lt(e,"confirmRef",15,null);const r=P(()=>e.bulkConfirm==="accept"),i=P(()=>e.pendingCount===e.allPendingCount?`${e.pendingCount} annotations?`:`${e.pendingCount} of ${e.allPendingCount} pending?`);var o=Tt(),s=Le(o);{var a=l=>{var c=DR(),d=x(c);{var u=p=>{var m=MR(),v=Le(m),g=x(v),y=k(v,2);yt(y,_=>t(_),()=>t());var w=k(y,2);re(w,"padding: 2px 8px; font-size: var(--tandem-text-xs); border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-1); cursor: pointer; background: var(--tandem-surface); color: var(--tandem-fg-muted);"),G(()=>{ne(g,`${f(r)?"Accept":"Reject"}
|
|
58
|
-
${f(i)??""}`),re(y,`padding: 2px 8px; font-size: var(--tandem-text-xs); border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-1); cursor: pointer; background: ${f(r)?"var(--tandem-success-bg)":"var(--tandem-error-bg)"}; color: ${f(r)?"var(--tandem-success-fg-strong)":"var(--tandem-error-fg-strong)"}; font-weight: 600;`)}),L("click",y,function(..._){var S;(S=f(r)?e.onConfirmAccept:e.onConfirmDismiss)==null||S.apply(this,_)}),L("click",w,function(..._){var S;(S=e.onCancel)==null||S.apply(this,_)}),T(p,m)},h=p=>{var m=OR(),v=Le(m);re(v,"padding: 2px 8px; font-size: var(--tandem-text-xs); border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-1); cursor: pointer; background: var(--tandem-success-bg); color: var(--tandem-success-fg-strong);");var g=x(v),y=k(v,2);re(y,"padding: 2px 8px; font-size: var(--tandem-text-xs); border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-1); cursor: pointer; background: var(--tandem-error-bg); color: var(--tandem-error-fg-strong);"),G(()=>ne(g,`Accept All (${e.pendingCount??""})`)),L("click",v,function(...w){var _;(_=e.onRequestAccept)==null||_.apply(this,w)}),L("click",y,function(...w){var _;(_=e.onRequestDismiss)==null||_.apply(this,w)}),T(p,m)};Z(d,p=>{e.bulkConfirm?p(u):p(h,-1)})}T(l,c)};Z(s,l=>{e.pendingCount>1&&l(a)})}T(n,o),Ke()}Ye(["click"]);var NR=O("<option> </option>"),IR=O('<select style="padding: 2px 4px; font-size: 11px; border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-1); background: var(--tandem-surface); color: var(--tandem-fg); cursor: pointer; outline: none;"></select>');function mh(n,e){We(e,!0);var t=IR();ft(t,21,()=>e.options,i=>i.value,(i,o)=>{var s=NR(),a=x(s),l={};G(()=>{ne(a,f(o).label),l!==(l=f(o).value)&&(s.value=(s.__value=f(o).value)??"")}),T(i,s)});var r;jw(t),G(()=>{Q(t,"data-testid",e.testId),Q(t,"aria-label",e.ariaLabel),r!==(r=e.value)&&(t.value=(t.__value=e.value)??"",zm(t,e.value))}),L("change",t,i=>e.onChange(i.target.value)),T(n,t),Ke()}Ye(["change"]);var PR=O('<div style="padding: 6px 16px; border-bottom: 1px solid var(--tandem-border);"><button data-testid="filter-bar-toggle" style="display: flex; align-items: center; gap: 4px; background: none; border: 1px solid var(--tandem-border); border-radius: var(--tandem-r-pill); padding: 3px 10px; font-size: var(--tandem-text-xs); color: var(--tandem-fg-subtle); cursor: pointer; white-space: nowrap;"><span> </span> <span style="font-size: 9px; opacity: 0.7;">▾</span> <span>Filter</span></button></div>'),LR=O('<button data-testid="clear-filters-btn" style="background: none; border: none; color: var(--tandem-accent); font-size: 11px; cursor: pointer; padding: 2px 4px;">Clear</button>'),zR=O('<div style="padding: 8px 16px; border-bottom: 1px solid var(--tandem-border); display: flex; gap: 4px; flex-wrap: wrap; align-items: center;"><!> <!> <!> <!> <button style="background: none; border: none; color: var(--tandem-fg-subtle); font-size: 10px; cursor: pointer; padding: 2px 4px; margin-left: auto;" aria-label="Collapse filters">▲</button></div>');function BR(n,e){We(e,!0);const t=P(()=>{if(!e.hasFilters)return"All";const a=[];if(e.filterType!=="all"){const l={all:"All",highlight:"Highlights",comment:"Comments",note:"Notes","with-replacement":"With replacement"};a.push(l[e.filterType])}if(e.filterAuthor!=="all"){const l={all:"Anyone",claude:"Claude",user:"You",import:"Imported"};a.push(l[e.filterAuthor])}if(e.filterStatus!=="all"){const l={all:"Any status",pending:"Pending",accepted:"Accepted",dismissed:"Dismissed"};a.push(l[e.filterStatus])}return a.join(" · ")||"All"});var r=Tt(),i=Le(r);{var o=a=>{var l=PR(),c=x(l),d=x(c),u=x(d);G(()=>ne(u,`${f(t)??""} ${e.totalCount??""}`)),L("click",c,function(...h){var p;(p=e.onToggleOpen)==null||p.apply(this,h)}),T(a,l)},s=a=>{var l=zR(),c=x(l);mh(c,{testId:"filter-type",ariaLabel:"Filter by type",get value(){return e.filterType},onChange:v=>e.onSetFilterType(v),options:[{value:"all",label:"All types"},{value:"highlight",label:"Highlights"},{value:"comment",label:"Comments"},{value:"note",label:"Notes"},{value:"with-replacement",label:"With replacement"}]});var d=k(c,2);mh(d,{testId:"filter-author",ariaLabel:"Filter by author",get value(){return e.filterAuthor},onChange:v=>e.onSetFilterAuthor(v),options:[{value:"all",label:"Anyone"},{value:"claude",label:"Claude"},{value:"user",label:"You"},{value:"import",label:"Imported"}]});var u=k(d,2);mh(u,{testId:"filter-status",ariaLabel:"Filter by status",get value(){return e.filterStatus},onChange:v=>e.onSetFilterStatus(v),options:[{value:"all",label:"Any status"},{value:"pending",label:"Pending"},{value:"accepted",label:"Accepted"},{value:"dismissed",label:"Dismissed"}]});var h=k(u,2);{var p=v=>{var g=LR();L("click",g,function(...y){var w;(w=e.onClearFilters)==null||w.apply(this,y)}),T(v,g)};Z(h,v=>{e.hasFilters&&v(p)})}var m=k(h,2);L("click",m,function(...v){var g;(g=e.onToggleOpen)==null||g.apply(this,v)}),T(a,l)};Z(i,a=>{e.open?a(s,-1):a(o)})}T(n,r),Ke()}Ye(["click"]);const eb=n=>{console.warn("[sanitize]",n)};function FR(n,e,t){if(n.suggestedText===void 0)return!1;const r=n.suggestedText,i=ru(n,e.state.doc,t);if(!i)return console.warn("[SidePanel] Could not resolve range for suggestion",n.id),!1;try{e.chain().focus().deleteRange({from:i.from,to:i.to}).insertContentAt(i.from,r).run()}catch(o){return console.error("[SidePanel] Editor mutation failed for suggestion",n.id,o),!1}return!0}function VR({getYdoc:n,getEditor:e,getAnnotations:t,onActiveAnnotationChange:r,getScrollBehavior:i}){let o=z(0),s=z(at(new Set));const a=new Map,l=null;pi(()=>{for(const w of a.values())clearTimeout(w);a.clear()});function c(){return t().filter(Pd)}function d(){const w=c();return w.length>0?w[f(o)]??null:null}function u(w,_){const S=n();if(!S)return;const A=S.getMap(xo),U=A.get(w);if(!U)return;const N=Ea(U,eb);if(A.set(w,{...N,status:_}),_==="accepted"&&N.suggestedText!==void 0){const R=e();if(R&&!FR(N,R,S)){A.set(w,{...N,status:"pending"});return}}b(s,new Set(f(s)).add(w),!0)}function h(w){const _=a.get(w);_&&clearTimeout(_),a.set(w,setTimeout(()=>{a.delete(w);const S=new Set(f(s));S.delete(w),b(s,S,!0)},3e3))}function p(w){const _=a.get(w);_&&(clearTimeout(_),a.delete(w));const S=new Set(f(s));S.delete(w),b(s,S,!0)}function m(w){const _=n();if(!_)return!1;const S=_.getMap(xo),A=S.get(w);if(!A||A.status==="pending")return p(w),!1;const U=Ea(A,eb),N=e();if(U.status==="accepted"&&U.suggestedText!==void 0&&N)try{const R=U.suggestedText,E=U.textSnapshot;if(typeof R=="string"&&typeof E=="string"){const q=ru(U,N.state.doc,_);if(!q)return console.warn(`[undo] Cannot resolve range for annotation ${w}, skipping`),h(w),!1;if(N.state.doc.textBetween(q.from,q.to)!==R)return console.warn(`[undo] Text changed since accept for annotation ${w}, skipping`),h(w),!1;N.chain().focus().deleteRange({from:q.from,to:q.to}).insertContentAt(q.from,E).run()}}catch(R){return console.warn(`[undo] Failed to revert text for annotation ${w}:`,R),h(w),!1}return S.set(w,{...U,status:"pending"}),p(w),!0}function v(w){u(w,"accepted")}function g(w){u(w,"dismissed")}function y(w){const _=e();if(!_)return;const S=ru(w,_.state.doc,n());if(!S)return;_.chain().focus().setTextSelection({from:S.from,to:S.to}).run();const A=_.view.domAtPos(S.from),U=A.node instanceof HTMLElement?A.node:A.node.parentElement;U==null||U.scrollIntoView({behavior:i(),block:"center"})}return he(()=>{var _;const w=c();r(((_=w[f(o)])==null?void 0:_.id)??null)}),he(()=>{const w=c();f(o)>=w.length&&b(o,Math.max(0,w.length-1),!0)}),{resolveAnnotation:u,undoResolveAnnotation:m,handleAccept:v,handleDismiss:g,scrollToAnnotation:y,getRecentlyResolved:()=>f(s),getReviewIndex:()=>f(o),getReviewTargets:c,getActiveReviewAnn:d,confirmEl:l}}var HR=O(`<div data-testid="store-readonly-banner" class="svelte-l26r3u"><span class="svelte-l26r3u">Annotation store is read-only — another Tandem instance holds the lock. Annotations
|
|
59
|
-
won't be saved. Close the other instance and restart.</span> <button data-testid="store-readonly-dismiss" class="svelte-l26r3u">Dismiss</button></div>`),UR=O('<div class="svelte-l26r3u"><span data-testid="held-banner" class="svelte-l26r3u"> </span> <button style="font-size: var(--tandem-text-xs); padding: 4px 10px; border: 1px solid var(--tandem-author-claude); border-radius: var(--tandem-r-2); background: var(--tandem-author-claude); color: var(--tandem-author-claude-fg); cursor: pointer; font-weight: 500;" class="svelte-l26r3u">Show all</button></div>'),jR=O('<span style="margin-left: 8px; padding: 1px 6px; font-size: var(--tandem-text-xs); background: var(--tandem-accent); color: var(--tandem-accent-fg); border-radius: var(--tandem-r-pill);" class="svelte-l26r3u"> </span>'),WR=O('<div style="padding: var(--tandem-space-3); flex: 1;" aria-live="polite" class="svelte-l26r3u"><p style="font-size: var(--tandem-text-base); color: var(--tandem-fg-subtle); margin-top: 8px;" class="svelte-l26r3u"> </p></div>'),KR=O('<details style="margin-top: 12px;" class="svelte-l26r3u"><summary style="font-size: 12px; color: var(--tandem-fg-subtle); cursor: pointer;" class="svelte-l26r3u"> </summary> <div role="list" aria-label="Resolved annotations" class="svelte-l26r3u"></div></details>'),qR=O('<div style="padding: var(--tandem-space-3); flex: 1;" role="list" aria-label="Annotations" class="svelte-l26r3u"><!> <!></div>'),JR=O('<div data-testid="annotation-list-scroll-container" style="width: 100%; background: var(--tandem-surface-muted); display: flex; flex-direction: column; overflow-y: auto;" class="svelte-l26r3u"><!> <!> <div style="padding: var(--tandem-space-3) var(--tandem-space-4); border-bottom: 1px solid var(--tandem-border);" class="svelte-l26r3u"><div style="display: flex; justify-content: space-between; align-items: center;" class="svelte-l26r3u"><h3 style="font-size: 13px; font-weight: 600; margin: 0;" class="svelte-l26r3u">Annotations <!></h3> <span aria-live="polite" style="position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0);" class="svelte-l26r3u"> </span></div></div> <!> <div style="padding: var(--tandem-space-1) var(--tandem-space-4) 0;" class="svelte-l26r3u"><!></div> <!> <!></div>');function tb(n,e){We(e,!0);let t=lt(e,"heldCount",3,0),r=lt(e,"storeReadOnly",3,!1);const i=P(()=>e.reduceMotion?"auto":"smooth"),o="tandem:storeReadOnlyBannerDismissed";function s(){try{return localStorage.getItem(o)==="true"}catch{return!1}}let a=z(at(s()));he(()=>{if(!r()){b(a,!1);try{localStorage.removeItem(o)}catch{}}});function l(){try{localStorage.setItem(o,"true")}catch{}b(a,!0)}let c=z("all"),d=z("all"),u=z("all"),h=z(!1),p=z(null),m=z(void 0),v=z(null);he(()=>{var D;f(p)&&((D=f(v))==null||D.focus())}),he(()=>{f(c),f(d),f(u),b(p,null)}),he(()=>{var D;(D=e.onFilterChange)==null||D.call(e,f(c),f(d),f(u))});let g=z(at(new Map));he(()=>{if(!e.ydoc){b(g,new Map,!0);return}const D=e.ydoc.getMap(cA);function Y(){const be=new Map;D.forEach(we=>{const Te=we;if(Te&&typeof Te=="object"&&Te.annotationId){const Se=be.get(Te.annotationId)??[];Se.push(Te),be.set(Te.annotationId,Se)}});for(const we of be.values())we.sort((Te,Se)=>Te.timestamp-Se.timestamp);b(g,be,!0)}return Y(),D.observe(Y),()=>D.unobserve(Y)});const y=P(()=>{const D=[],Y=[];for(const De of e.annotations){De.status==="pending"&&Y.push(De);let oe;f(c)==="all"?oe=!0:f(c)==="with-replacement"?oe=De.suggestedText!==void 0:oe=De.type===f(c);const M=f(d)==="all"||De.author===f(d),$=f(u)==="all"||De.status===f(u);oe&&M&&$&&D.push(De)}const be=D.filter(De=>De.status==="pending"),we=D.filter(Pd),Te=D.filter(De=>De.status!=="pending"),Se=e.annotations.filter(Pd);return{filtered:D,pending:be,reviewPending:we,resolved:Te,allPending:Y,reviewAllPending:Se}}),w=P(()=>f(c)!=="all"||f(d)!=="all"||f(u)!=="all"),_=VR({getYdoc:()=>e.ydoc,getEditor:()=>e.editor,getAnnotations:()=>e.annotations,onActiveAnnotationChange:D=>e.onActiveAnnotationChange(D),getScrollBehavior:()=>f(i)});let S=!1;he(()=>{if(f(c),f(d),f(u),!S){S=!0;return}Ut(()=>{var D;if(e.activeAnnotationId){const Y=document.querySelector(`[data-testid="annotation-card-${e.activeAnnotationId}"]`);if(Y){Y.scrollIntoView({block:"center"});return}console.warn(`[tandem] SidePanel: active annotation ${e.activeAnnotationId} not found on filter change; scrolling to top`)}(D=f(m))==null||D.scrollTo({top:0})})}),he(()=>{const D=e.activeAnnotationId;if(!D)return;const Y=f(i),be=setTimeout(()=>{const we=document.querySelector(`[data-testid="annotation-card-${D}"]`);if(we){we.scrollIntoView({behavior:Y,block:"nearest"}),we.classList.add("tandem-annotation-flash");const Te=()=>we.classList.remove("tandem-annotation-flash");we.addEventListener("animationend",Te,{once:!0})}else console.warn(`[tandem] SidePanel: active annotation ${D} not found after 50ms delay; scroll-to-card skipped`)},50);return()=>clearTimeout(be)});function A(D,Y){if(!e.ydoc)return;const be=e.ydoc.getMap(xo),we=be.get(D);if(!we)return;const Te=Ea(we,Se=>{console.warn("[sanitize]",Se)});if(Te.suggestedText!==void 0){try{const Se=JSON.parse(Y);be.set(D,{...Te,suggestedText:Se.suggestedText,content:Se.content,editedAt:Date.now()})}catch{console.warn(`[SidePanel] Failed to parse edit payload for annotation ${D}`)}return}be.set(D,{...Te,content:Y,editedAt:Date.now()})}function U(D){if(!e.ydoc)return;const Y=e.ydoc.getMap(xo),be=Y.get(D);if(!be)return;const we=Ea(be,Te=>{console.warn("[sanitize]",Te)});Y.set(D,{...we,type:"comment"})}async function N(D){try{const Y=await fetch(`${Sr}/remove-annotation`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({annotationId:D,documentId:e.documentId})});if(!Y.ok){const be=await Y.json().catch(()=>({message:"Unknown error"}));console.error("[Tandem] Remove annotation failed:",be)}}catch(Y){console.error("[Tandem] Remove annotation failed:",Y)}}async function R(D,Y){try{const be=await fetch(`${Sr}/annotation-reply`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({annotationId:D,text:Y,documentId:e.documentId})});if(!be.ok){const we=await be.json().catch(()=>({}));return console.warn(`[SidePanel] Reply failed (${be.status}): ${we.message??"unknown error"}`),!1}return!0}catch(be){return console.error("[SidePanel] Reply request failed:",be),!1}}function E(D){for(const Y of f(y).reviewPending)_.resolveAnnotation(Y.id,D);b(p,null)}var q=JR(),te=x(q);{var K=D=>{var Y=HR(),be=k(x(Y),2);G(()=>{re(Y,`padding: 10px 14px; margin: 10px 14px 0; background: ${Io.background}; border: 1px solid ${Io.border}; border-radius: var(--tandem-r-4); font-size: var(--tandem-text-xs); color: ${Io.color}; display: flex; justify-content: space-between; align-items: flex-start; gap: 10px;`),re(be,`flex-shrink: 0; font-size: var(--tandem-text-xs); padding: 2px 8px; border: none; border-radius: var(--tandem-r-2); background: none; color: ${Io.color}; cursor: pointer; font-weight: 500;`)}),L("click",be,l),T(D,Y)};Z(te,D=>{r()&&!f(a)&&D(K)})}var V=k(te,2);{var ee=D=>{var Y=UR(),be=x(Y),we=x(be),Te=k(be,2);G(()=>{re(Y,`padding: 10px 14px; margin: 10px 14px 0; background: ${Io.background}; border: 1px solid ${Io.border}; border-radius: var(--tandem-r-4); font-size: var(--tandem-text-xs); color: ${Io.color}; display: flex; justify-content: space-between; align-items: center; gap: 10px;`),ne(we,`${t()??""} annotation${t()!==1?"s":""} held`)}),L("click",Te,()=>{var Se;return(Se=e.onModeChange)==null?void 0:Se.call(e,"tandem")}),T(D,Y)};Z(V,D=>{t()>0&&D(ee)})}var se=k(V,2),F=x(se),X=x(F),B=k(x(X));{var j=D=>{var Y=jR(),be=x(Y);G(()=>ne(be,f(y).allPending.length)),T(D,Y)};Z(B,D=>{f(y).allPending.length>0&&D(j)})}var ae=k(X,2),C=x(ae),I=k(se,2);BR(I,{get filterType(){return f(c)},get filterAuthor(){return f(d)},get filterStatus(){return f(u)},get hasFilters(){return f(w)},get open(){return f(h)},get totalCount(){return f(y).filtered.length},onToggleOpen:()=>b(h,!f(h)),onSetFilterType:D=>{b(c,D,!0)},onSetFilterAuthor:D=>{b(d,D,!0)},onSetFilterStatus:D=>{b(u,D,!0)},onClearFilters:()=>{b(c,"all"),b(d,"all"),b(u,"all")}});var W=k(I,2),ge=x(W);JD(ge,{get annotations(){return e.annotations},get activeDocFormat(){return e.activeDocFormat},get documentId(){return e.documentId}});var xe=k(W,2);RR(xe,{get bulkConfirm(){return f(p)},get pendingCount(){return f(y).reviewPending.length},get allPendingCount(){return f(y).reviewAllPending.length},onConfirmAccept:()=>E("accepted"),onConfirmDismiss:()=>E("dismissed"),onCancel:()=>b(p,null),onRequestAccept:()=>b(p,"accept"),onRequestDismiss:()=>b(p,"dismiss"),get confirmRef(){return f(v)},set confirmRef(D){b(v,D,!0)}});var Oe=k(xe,2);{var J=D=>{var Y=WR(),be=x(Y),we=x(be);G(()=>ne(we,f(w)?"No annotations match filters.":"No annotations yet. Open a document to get started.")),T(D,Y)},fe=D=>{var Y=qR(),be=x(Y);ft(be,17,()=>f(y).pending,Se=>Se.id,(Se,De)=>{const oe=P(()=>{var M;return((M=_.getActiveReviewAnn())==null?void 0:M.id)===f(De).id});{let M=P(()=>f(g).get(f(De).id)??[]),$=P(()=>f(De).author!=="user"?_.handleAccept:void 0),le=P(()=>f(De).author!=="user"?_.handleDismiss:void 0),de=P(()=>f(De).author==="user"?N:void 0),Ee=P(()=>f(De).type==="note"?U:void 0);$y(Se,{get annotation(){return f(De)},get replies(){return f(M)},get isReviewTarget(){return f(oe)},get onAccept(){return f($)},get onDismiss(){return f(le)},get onRemove(){return f(de)},get onSendToClaude(){return f(Ee)},onEdit:A,onReply:R,onClick:()=>_.scrollToAnnotation(f(De))})}});var we=k(be,2);{var Te=Se=>{var De=KR(),oe=x(De),M=x(oe),$=k(oe,2);ft($,21,()=>f(y).resolved,le=>le.id,(le,de)=>{{let Ee=P(()=>f(g).get(f(de).id)??[]),ce=P(()=>_.getRecentlyResolved().has(f(de).id));$y(le,{get annotation(){return f(de)},get replies(){return f(Ee)},get onUndo(){return _.undoResolveAnnotation},get undoable(){return f(ce)},onClick:()=>_.scrollToAnnotation(f(de))})}}),G(()=>ne(M,`${f(y).resolved.length??""} resolved`)),T(Se,De)};Z(we,Se=>{f(y).resolved.length>0&&Se(Te)})}T(D,Y)};Z(Oe,D=>{f(y).filtered.length===0?D(J):D(fe,-1)})}yt(q,D=>b(m,D),()=>f(m)),G(()=>ne(C,`${f(y).allPending.length??""} pending annotation${f(y).allPending.length!==1?"s":""}`)),T(n,q),Ke()}Ye(["click"]);var YR=O('<div style="padding: var(--tandem-space-3) var(--tandem-space-4); font-size: var(--tandem-text-xs); color: var(--tandem-fg-faint); font-style: italic;">No headings</div>'),GR=O(`<span style="
|
|
60
|
-
flex-shrink: 0;
|
|
61
|
-
font-size: var(--tandem-text-2xs, 10px);
|
|
62
|
-
font-weight: 500;
|
|
63
|
-
color: var(--tandem-fg-subtle);
|
|
64
|
-
background: var(--tandem-surface-muted);
|
|
65
|
-
border-radius: var(--tandem-r-pill);
|
|
66
|
-
padding: 0 var(--tandem-space-1);
|
|
67
|
-
min-width: 16px;
|
|
68
|
-
text-align: center;
|
|
69
|
-
line-height: 16px;
|
|
70
|
-
"> </span>`),ZR=O('<li><button><span style="flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;"> </span> <!></button></li>'),XR=O('<ul style="list-style: none; margin: 0; padding: 0;"></ul>'),QR=O(`<nav data-testid="outline-panel" aria-label="Document outline" style="display: flex; flex-direction: column; flex: 1; overflow-y: auto;"><div style="padding: var(--tandem-space-2) var(--tandem-space-3); border-bottom: 1px solid var(--tandem-border);"><input type="search" placeholder="Search in document…" data-testid="outline-search-input" aria-label="Search document" style="
|
|
71
|
-
width: 100%; box-sizing: border-box;
|
|
72
|
-
padding: var(--tandem-space-1) var(--tandem-space-2);
|
|
73
|
-
font-size: var(--tandem-text-xs);
|
|
74
|
-
border: 1px solid var(--tandem-border);
|
|
75
|
-
border-radius: var(--tandem-r-2);
|
|
76
|
-
background: var(--tandem-surface);
|
|
77
|
-
color: var(--tandem-fg);
|
|
78
|
-
outline: none;
|
|
79
|
-
"/></div> <div style="flex: 1; overflow-y: auto; padding: var(--tandem-space-2) 0;"><!></div></nav>`);function nb(n,e){We(e,!0);let t=lt(e,"annotations",19,()=>[]),r=lt(e,"focusTrigger",3,0),i=lt(e,"activeFilterType",3,"all"),o=lt(e,"activeFilterAuthor",3,"all"),s=lt(e,"activeFilterStatus",3,"all"),a=z(at([])),l=z(-1),c=z(at([])),d=z(""),u=z(null),h=z(-1);he(()=>{const E=e.editor;if(!E||E.isDestroyed){b(a,[],!0);return}b(a,_p(E),!0),Ut(()=>{b(c,f(c).slice(0,f(a).length),!0),f(l)>=f(a).length&&b(l,Math.max(0,f(a).length-1),!0)});const q=()=>{b(a,_p(E),!0),b(c,f(c).slice(0,f(a).length),!0),f(l)>=f(a).length&&b(l,Math.max(0,f(a).length-1),!0)};return E.on("update",q),()=>{E.isDestroyed||E.off("update",q),b(a,[],!0)}}),he(()=>{var E,q;r()>0&&((E=f(u))==null||E.focus(),(q=f(u))==null||q.select())}),he(()=>{const E=e.editor;if(!E||E.isDestroyed)return;function q(){if(!E||E.isDestroyed||f(a).length===0){b(h,-1);return}const V=E.view.dom.getBoundingClientRect().top+48;let ee=-1;for(let se=0;se<f(a).length;se++)try{E.view.coordsAtPos(f(a)[se].pos+1).top<=V&&(ee=se)}catch{}b(h,ee,!0)}q();const te=E.view.dom.closest(".editor-scroll")??E.view.dom.parentElement;return te==null||te.addEventListener("scroll",q),()=>te==null?void 0:te.removeEventListener("scroll",q)});function p(){const E=e.editor;!E||E.isDestroyed||(f(d)?E.commands.find({query:f(d),caseSensitive:!1,wholeWord:!1,regexMode:!1}):E.commands.findClose())}function m(E){var q,te,K,V;E.key==="Enter"?(E.preventDefault(),E.shiftKey?(q=e.editor)==null||q.commands.findPrev():(te=e.editor)==null||te.commands.findNext()):E.key==="Escape"&&(E.preventDefault(),b(d,""),(K=e.editor)==null||K.commands.findClose(),(V=f(u))==null||V.blur())}const v=P(()=>{const E=e.editor;if(!E||E.isDestroyed||f(a).length===0)return[];const q=E.state.doc.content.size,te=[];for(const K of t()){if(i()!=="all"){if(i()==="with-replacement"){if(!K.suggestedText)continue}else if(K.type!==i())continue}if(!(o()!=="all"&&K.author!==o())&&!(s()!=="all"&&K.status!==s()))try{te.push(To(E.state.doc,K.range.from))}catch{}}return f(a).map((K,V)=>{const ee=V+1<f(a).length?f(a)[V+1].pos:q;return te.filter(se=>se>=K.pos&&se<ee).length})});function g(E,q){const te=e.editor;if(!te||te.isDestroyed)return;const{state:K}=te;try{const V=K.doc.resolve(E.pos+1),ee=Ie.near(V);te.view.dispatch(K.tr.setSelection(ee)),te.view.focus();const{node:se}=te.view.domAtPos(E.pos+1),F=se instanceof Element?se:se.parentElement,X=te.view.dom.closest(".editor-scroll")??te.view.dom.parentElement;if(F&&X){const B=F.getBoundingClientRect().top,j=X.getBoundingClientRect().top;X.scrollTop+=B-j-X.clientHeight*.05}}catch{}b(l,q,!0)}function y(E){var q,te,K,V;if(f(a).length!==0)if(E.key==="ArrowDown"){E.preventDefault();const ee=(f(l)+1)%f(a).length;b(l,ee),(q=f(c)[ee])==null||q.focus()}else if(E.key==="ArrowUp"){E.preventDefault();const ee=(f(l)-1+f(a).length)%f(a).length;b(l,ee),(te=f(c)[ee])==null||te.focus()}else E.key==="Home"?(E.preventDefault(),b(l,0),(K=f(c)[0])==null||K.focus()):E.key==="End"&&(E.preventDefault(),b(l,f(a).length-1),(V=f(c)[f(a).length-1])==null||V.focus())}var w=QR(),_=x(w),S=x(_);yt(S,E=>b(u,E),()=>f(u));var A=k(_,2),U=x(A);{var N=E=>{var q=YR();T(E,q)},R=E=>{var q=XR();ft(q,21,()=>f(a),ma,(te,K,V)=>{const ee=P(()=>f(h)===V),se=P(()=>f(v)[V]??0);var F=ZR(),X=x(F),B=x(X),j=x(B),ae=k(B,2);{var C=I=>{var W=GR(),ge=x(W);G(()=>{Q(W,"title",`${f(se)??""} annotation${f(se)!==1?"s":""}`),ne(ge,f(se))}),T(I,W)};Z(ae,I=>{f(se)>0&&I(C)})}yt(X,(I,W)=>f(c)[W]=I,I=>{var W;return(W=f(c))==null?void 0:W[I]},()=>[V]),G(()=>{Q(X,"data-testid",`outline-heading-${f(K).level}-${V}`),Q(X,"tabindex",f(l)===V||f(l)===-1&&V===0?0:-1),re(X,`
|
|
80
|
-
display: flex; align-items: center; width: 100%; text-align: left;
|
|
81
|
-
padding: var(--tandem-space-1) var(--tandem-space-3);
|
|
82
|
-
padding-left: calc(var(--tandem-space-1) + ${(f(K).level-1)*12}px);
|
|
83
|
-
font-size: ${f(K).level===1?"var(--tandem-text-sm)":"var(--tandem-text-xs)"};
|
|
84
|
-
font-weight: ${f(K).level===1?600:f(K).level===2?500:400};
|
|
85
|
-
color: ${f(ee)?"var(--tandem-accent)":f(K).level===1?"var(--tandem-fg)":f(K).level===2?"var(--tandem-fg-subtle)":"var(--tandem-fg-muted)"};
|
|
86
|
-
background: ${f(ee)?"var(--tandem-accent-bg)":"none"};
|
|
87
|
-
border: none; cursor: pointer; line-height: 1.5;
|
|
88
|
-
transition: color 0.1s, background 0.1s;
|
|
89
|
-
gap: var(--tandem-space-2);
|
|
90
|
-
`),Q(X,"title",f(K).text),ne(j,f(K).text||"(untitled)")}),L("click",X,()=>g(f(K),V)),vt("focus",X,()=>b(l,V,!0)),vt("mouseenter",X,I=>{f(ee)||(I.currentTarget.style.background="var(--tandem-surface-hover, var(--tandem-surface-muted))")}),vt("mouseleave",X,I=>{f(ee)||(I.currentTarget.style.background="none")}),T(te,F)}),T(E,q)};Z(U,E=>{f(a).length===0?E(N):E(R,-1)})}L("keydown",w,y),L("input",S,p),L("keydown",S,m),hs(S,()=>f(d),E=>b(d,E)),T(n,w),Ke()}Ye(["keydown","input","click"]);var $R=O("<div><!></div>");function Ps(n,e){We(e,!0);let t=wT(e,["$$slots","$$events","$$legacy","kind","visible"]);const r=P(()=>e.visible!==void 0?`display: ${e.visible?"flex":"none"}; flex-direction: column; flex: 1; min-height: 0;`:void 0);var i=Tt(),o=Le(i);{var s=d=>{var u=$R(),h=x(u);{var p=g=>{Qy(g,Ic(()=>t,{get visible(){return e.visible}}))},m=g=>{nb(g,{get editor(){return e.editor},get annotations(){return e.annotations},get focusTrigger(){return e.focusTrigger},get activeFilterType(){return e.activeFilterType},get activeFilterAuthor(){return e.activeFilterAuthor},get activeFilterStatus(){return e.activeFilterStatus}})},v=g=>{tb(g,Ic(()=>t))};Z(h,g=>{e.kind==="chat"?g(p):e.kind==="outline"?g(m,1):g(v,-1)})}G(()=>re(u,f(r))),T(d,u)},a=d=>{Qy(d,Ic(()=>t))},l=d=>{nb(d,{get editor(){return e.editor},get annotations(){return e.annotations},get focusTrigger(){return e.focusTrigger},get activeFilterType(){return e.activeFilterType}})},c=d=>{tb(d,Ic(()=>t))};Z(o,d=>{f(r)?d(s):e.kind==="chat"?d(a,1):e.kind==="outline"?d(l,2):d(c,-1)})}T(n,i),Ke()}var eN=O('<span style="color: var(--tandem-error-fg-strong); font-size: 12px; max-width: 200px;"> </span>'),tN=O('<button type="button" data-testid="convert-to-markdown-btn"> </button>'),nN=O(`<div data-testid="review-only-banner" style="padding: var(--tandem-space-2) var(--tandem-space-4); background-color: var(--tandem-info-bg); border-bottom: 1px solid var(--tandem-info-border); display: flex; align-items: center; justify-content: space-between; font-size: var(--tandem-text-base); color: var(--tandem-info-fg-strong); gap: var(--tandem-space-3);"><span>This document is open in review-only mode. You can add annotations and review, but cannot
|
|
91
|
-
edit directly.</span> <div style="display: flex; align-items: center; gap: var(--tandem-space-2); flex-shrink: 0;"><!> <!> <button type="button" data-testid="review-only-dismiss" style="background: none; border: none; color: var(--tandem-info-fg-strong); cursor: pointer; font-weight: 500; font-size: 13px; padding: 2px 8px; white-space: nowrap;">Dismiss</button></div></div>`);function rN(n,e){We(e,!0);const t="tandem:reviewOnlyBannerDismissed";function r(){try{return localStorage.getItem(t)==="true"}catch{return!1}}let i=z(at(r())),o=z(!1),s=z(null);async function a(){if(!(!e.documentId||f(o))){b(o,!0),b(s,null);try{const h=await fetch(`${Sr}/convert`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({documentId:e.documentId})});if(!h.ok){const p=await h.json().catch(()=>null);b(s,(p==null?void 0:p.message)??`Conversion failed (HTTP ${h.status}).`,!0)}}catch{b(s,"Could not reach the server.")}finally{b(o,!1)}}}function l(){try{localStorage.setItem(t,"true")}catch{}b(i,!0)}var c=Tt(),d=Le(c);{var u=h=>{var p=nN(),m=k(x(p),2),v=x(m);{var g=S=>{var A=eN(),U=x(A);G(()=>ne(U,f(s))),T(S,A)};Z(v,S=>{f(s)&&S(g)})}var y=k(v,2);{var w=S=>{var A=tN(),U=x(A);G(()=>{A.disabled=f(o),re(A,`background: var(--tandem-info); border: none; color: var(--tandem-info-fg); cursor: ${f(o)?"default":"pointer"}; font-weight: 500; font-size: var(--tandem-text-sm); padding: 4px 10px; border-radius: var(--tandem-r-2); white-space: nowrap; opacity: ${f(o)?.6:1};`),ne(U,f(o)?"Converting…":"Convert to Markdown")}),L("click",A,a),T(S,A)};Z(y,S=>{e.documentId&&S(w)})}var _=k(y,2);L("click",_,l),T(h,p)};Z(d,h=>{e.visible&&!f(i)&&h(u)})}T(n,c),Ke()}Ye(["click"]);let gh=null;async function iN(n){if(gh!==null)return gh;const e=await fetch(`${Sr}/info`,{signal:n});if(!e.ok)throw new Error(`/api/info responded ${e.status} ${e.statusText}`);const t=await e.json();return gh=t,t}function bk(n){let e=z(null),t=z(!1);return he(()=>{if(!n())return;let r=!1;const i=new AbortController,o=setTimeout(()=>i.abort(),3e3);return b(t,!0),iN(i.signal).then(s=>{r||b(e,s,!0)}).catch(s=>{s instanceof Error&&s.name!=="AbortError"&&console.warn("[useAppInfo] failed to load /api/info:",s)}).finally(()=>{clearTimeout(o),r||b(t,!1)}),()=>{r=!0,clearTimeout(o),i.abort()}}),{get info(){return f(e)},get loading(){return f(t)}}}function kg(n){return(n==null?void 0:n.trim())||ex}function _g(){try{return kg(localStorage.getItem(Hm))}catch{return ex}}function oN(n){const e=kg(n);try{localStorage.setItem(Hm,e)}catch{}return typeof window<"u"&&window.dispatchEvent(new Event(fp)),e}function wk(n){const e=()=>n(_g()),t=r=>{r.key===Hm&&n(kg(r.newValue))};return window.addEventListener(fp,e),window.addEventListener("storage",t),()=>{window.removeEventListener(fp,e),window.removeEventListener("storage",t)}}function xk(){let n=z(at(_g()));const e=wk(r=>{b(n,r,!0)});return pi(e),{get userName(){return f(n)},setUserName:r=>{const i=oN(r);b(n,i,!0)}}}var sN=O('<div><div>Contrast</div> <label data-testid="high-contrast-toggle" style="display: flex; align-items: center; gap: var(--tandem-space-2); cursor: pointer; font-size: 12px; color: var(--tandem-fg); min-height: 24px;"><input type="checkbox" style="accent-color: var(--tandem-accent);"/> <span>High contrast</span></label> <div style="font-size: 10px; color: var(--tandem-fg-subtle); margin-top: var(--tandem-space-1);">Increases border and text contrast for improved readability.</div></div> <div><div>Annotation Patterns</div> <label data-testid="annotation-patterns-toggle" style="display: flex; align-items: center; gap: var(--tandem-space-2); cursor: pointer; font-size: 12px; color: var(--tandem-fg); min-height: 24px;"><input type="checkbox" style="accent-color: var(--tandem-accent);"/> <span>Use pattern fills for annotations</span></label> <div style="font-size: 10px; color: var(--tandem-fg-subtle); margin-top: var(--tandem-space-1);">Adds visual patterns to annotation decorations (color-blind friendly).</div></div>',1);function aN(n,e){We(e,!0);const t="font-size: 11px; font-weight: 600; color: var(--tandem-fg); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px;";var r=sN(),i=Le(r),o=x(i);re(o,t);var s=k(o,2),a=x(s),l=k(i,2),c=x(l);re(c,t);var d=k(c,2),u=x(d);G(()=>{fs(a,e.settings.highContrast),fs(u,e.settings.annotationPatterns)}),L("change",a,h=>e.onUpdate({highContrast:h.target.checked})),L("change",u,h=>e.onUpdate({annotationPatterns:h.target.checked})),T(n,r),Ke()}Ye(["change"]);function Ya(n,e,t,r){return{handleKeyDown:s=>{var y;const{key:a}=s;if(a!=="ArrowLeft"&&a!=="ArrowRight"&&a!=="ArrowUp"&&a!=="ArrowDown"&&a!=="Home"&&a!=="End")return;const l=e;if(l.length===0)return;s.preventDefault();const c=n(),d=l.indexOf(c),u=l.length-1;let h;a==="Home"?h=0:a==="End"?h=u:a==="ArrowLeft"||a==="ArrowUp"?h=d<=0?u:d-1:h=d>=u?0:d+1;const p=l[h];t(p);const m=s.currentTarget,v=m==null?void 0:m.querySelectorAll('[role="radio"]'),g=e.indexOf(p);(y=v==null?void 0:v[g])==null||y.focus()},tabIndexFor:s=>{const l=n();return s===l?0:-1}}}var lN=O('<button role="radio"> </button>'),cN=O('<button role="radio"> </button>'),dN=O('<button role="radio"> </button>'),uN=O('<button role="radio"> </button>'),fN=O('<div><div id="settings-theme-label">Theme</div> <div role="radiogroup" aria-labelledby="settings-theme-label" tabindex="0" style="display: flex; gap: var(--tandem-space-2);"></div></div> <div><div id="settings-default-tab-label">Default Tab</div> <div role="radiogroup" aria-labelledby="settings-default-tab-label" tabindex="0" style="display: flex; gap: var(--tandem-space-2);"><button data-testid="default-tab-chat-btn" role="radio">Chat</button> <button data-testid="default-tab-annotations-btn" role="radio">Annotations</button></div></div> <div><div id="settings-text-size-label">Text Size</div> <div role="radiogroup" aria-labelledby="settings-text-size-label" tabindex="0" style="display: flex; gap: var(--tandem-space-2);"></div> <div style="font-size: var(--tandem-text-2xs); color: var(--tandem-fg-subtle); margin-top: var(--tandem-space-1);">Reading density only — use browser zoom (Ctrl + =/−) to scale the whole UI.</div></div> <div><div id="settings-accent-color-label">Accent Color</div> <div style="display: flex; align-items: center; gap: 8px;"><span aria-hidden="true" style="display: inline-block; width: 16px; height: 16px; background: var(--tandem-accent); border-radius: var(--tandem-r-1); flex-shrink: 0; border: 1px solid var(--tandem-border-strong);"></span> <input data-testid="accent-hue-slider" type="range" min="0" max="360" step="1" aria-labelledby="settings-accent-color-label" style="flex: 1; accent-color: var(--tandem-accent);"/></div></div> <div><div id="settings-editor-font-label">Editor Font</div> <div role="radiogroup" aria-labelledby="settings-editor-font-label" tabindex="0" style="display: flex; gap: var(--tandem-space-2);"></div></div> <div><div id="settings-density-label">Spacing Density</div> <div role="radiogroup" aria-labelledby="settings-density-label" tabindex="0" style="display: flex; gap: var(--tandem-space-2);"></div></div> <div><label data-testid="reduce-motion-toggle" style="display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 12px; color: var(--tandem-fg); min-height: 24px;"><input type="checkbox" style="accent-color: var(--tandem-accent);"/> <span>Reduce motion</span></label> <div style="font-size: var(--tandem-text-2xs); color: var(--tandem-fg-subtle); margin-top: var(--tandem-space-1);">Disables smooth autoscroll and the annotation flash animation.</div></div>',1);function hN(n,e){We(e,!0);const t="font-size: 11px; font-weight: 600; color: var(--tandem-fg); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px;";function r(B,j){return["flex: 1;","padding: var(--tandem-space-2);","min-height: 24px;",`border: 2px solid ${B?"var(--tandem-accent)":"var(--tandem-border)"};`,"border-radius: var(--tandem-r-3);",`background: ${B?"var(--tandem-accent-bg)":"var(--tandem-surface)"};`,"cursor: pointer;","text-align: center;","font-size: 11px;",`color: ${B?"var(--tandem-accent-fg-strong)":"var(--tandem-fg-muted)"};`,`font-weight: ${B?600:400};`,"opacity: 1;","transition: border-color 0.15s, background 0.15s;"].join(" ")}const i=Ya(()=>e.settings.theme,["light","dark","system"],B=>e.onUpdate({theme:B})),o=Ya(()=>e.settings.primaryTab,["chat","annotations"],B=>e.onUpdate({primaryTab:B})),s=Ya(()=>e.settings.textSize,["s","m","l"],B=>e.onUpdate({textSize:B})),a=Ya(()=>e.settings.editorFont,["sans","serif","mono"],B=>e.onUpdate({editorFont:B})),l=Ya(()=>e.settings.density,["compact","cozy","spacious"],B=>e.onUpdate({density:B}));var c=fN(),d=Le(c),u=x(d);re(u,t);var h=k(u,2);ft(h,20,()=>["light","dark","system"],B=>B,(B,j)=>{var ae=lN(),C=x(ae);G((I,W)=>{Q(ae,"data-testid",`theme-${j}-btn`),Q(ae,"aria-checked",e.settings.theme===j),Q(ae,"tabindex",I),re(ae,W),ne(C,j==="light"?"Light":j==="dark"?"Dark":"System")},[()=>i.tabIndexFor(j),()=>r(e.settings.theme===j)]),L("click",ae,()=>e.onUpdate({theme:j})),T(B,ae)});var p=k(d,2),m=x(p);re(m,t);var v=k(m,2),g=x(v),y=k(g,2),w=k(p,2),_=x(w);re(_,t);var S=k(_,2);ft(S,20,()=>["s","m","l"],B=>B,(B,j)=>{var ae=cN(),C=x(ae);G((I,W)=>{Q(ae,"data-testid",`text-size-${j}-btn`),Q(ae,"aria-checked",e.settings.textSize===j),Q(ae,"tabindex",I),re(ae,W),ne(C,j==="s"?"Small":j==="m"?"Medium":"Large")},[()=>s.tabIndexFor(j),()=>r(e.settings.textSize===j)]),L("click",ae,()=>e.onUpdate({textSize:j})),T(B,ae)});var A=k(w,2),U=x(A);re(U,t);var N=k(U,2),R=k(x(N),2),E=k(A,2),q=x(E);re(q,t);var te=k(q,2);ft(te,20,()=>[["sans","Sans-serif"],["serif","Serif"],["mono","Monospace"]],([B,j])=>B,(B,j)=>{var ae=P(()=>vv(j,2));let C=()=>f(ae)[0],I=()=>f(ae)[1];var W=dN(),ge=x(W);G((xe,Oe)=>{Q(W,"data-testid",`editor-font-${C()}-btn`),Q(W,"aria-checked",e.settings.editorFont===C()),Q(W,"tabindex",xe),re(W,Oe),ne(ge,I())},[()=>a.tabIndexFor(C()),()=>r(e.settings.editorFont===C())]),L("click",W,()=>e.onUpdate({editorFont:C()})),T(B,W)});var K=k(E,2),V=x(K);re(V,t);var ee=k(V,2);ft(ee,20,()=>[["compact","Compact"],["cozy","Cozy"],["spacious","Spacious"]],([B,j])=>B,(B,j)=>{var ae=P(()=>vv(j,2));let C=()=>f(ae)[0],I=()=>f(ae)[1];var W=uN(),ge=x(W);G((xe,Oe)=>{Q(W,"data-testid",`density-${C()}-btn`),Q(W,"aria-checked",e.settings.density===C()),Q(W,"tabindex",xe),re(W,Oe),ne(ge,I())},[()=>l.tabIndexFor(C()),()=>r(e.settings.density===C())]),L("click",W,()=>e.onUpdate({density:C()})),T(B,W)});var se=k(K,2),F=x(se),X=x(F);G((B,j,ae,C)=>{Q(g,"aria-checked",e.settings.primaryTab==="chat"),Q(g,"tabindex",B),re(g,j),Q(y,"aria-checked",e.settings.primaryTab==="annotations"),Q(y,"tabindex",ae),re(y,C),Rr(R,e.settings.accentHue),fs(X,e.settings.reduceMotion)},[()=>o.tabIndexFor("chat"),()=>r(e.settings.primaryTab==="chat"),()=>o.tabIndexFor("annotations"),()=>r(e.settings.primaryTab==="annotations")]),L("keydown",h,function(...B){var j;(j=i.handleKeyDown)==null||j.apply(this,B)}),L("keydown",v,function(...B){var j;(j=o.handleKeyDown)==null||j.apply(this,B)}),L("click",g,()=>e.onUpdate({primaryTab:"chat"})),L("click",y,()=>e.onUpdate({primaryTab:"annotations"})),L("keydown",S,function(...B){var j;(j=s.handleKeyDown)==null||j.apply(this,B)}),L("input",R,B=>e.onUpdate({accentHue:Number(B.target.value)})),L("keydown",te,function(...B){var j;(j=a.handleKeyDown)==null||j.apply(this,B)}),L("keydown",ee,function(...B){var j;(j=l.handleKeyDown)==null||j.apply(this,B)}),L("change",X,B=>e.onUpdate({reduceMotion:B.target.checked})),T(n,c),Ke()}Ye(["keydown","click","input","change"]);var pN=O('<div><div>Editor Width: <span style="font-weight: 400; text-transform: none;"> </span></div> <div style="font-size: 10px; color: var(--tandem-fg-subtle); margin-bottom: 6px;">How much of the available space the editor text fills</div> <input data-testid="editor-width-slider" type="range" style="width: 100%; accent-color: var(--tandem-accent);" aria-label="Editor width"/> <div style="display: flex; justify-content: space-between; font-size: 10px; color: var(--tandem-fg-subtle);"><span>40%</span> <span>100%</span></div></div>');function mN(n,e){We(e,!0);const t="font-size: 11px; font-weight: 600; color: var(--tandem-fg); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px;";var r=pN(),i=x(r);re(i,t);var o=k(x(i)),s=x(o),a=k(i,4);Q(a,"min",40),Q(a,"max",100),Q(a,"step",5),G(()=>{ne(s,`${e.settings.editorWidthPercent??""}%`),Rr(a,e.settings.editorWidthPercent)}),L("input",a,l=>e.onUpdate({editorWidthPercent:Number(l.target.value)})),T(n,r),Ke()}Ye(["input"]);var gN=O('<span style="color: var(--tandem-fg-subtle);"> </span>'),vN=O('<button type="button" data-testid="network-restart-sidecar"> </button>'),yN=O('<span style="font-size: 10px; color: var(--tandem-fg-subtle);">Run <code>tandem stop && tandem start</code> to restart</span>'),bN=O('<div style="font-size: 10px; color: var(--tandem-error-fg); margin-top: var(--tandem-space-1);"> </div>'),wN=O("<span><strong>Host:</strong> </span>"),xN=O('<div><div>Loopback Port</div> <div style="padding: var(--tandem-space-2) var(--tandem-space-3); border: 1px solid var(--tandem-border); border-radius: var(--tandem-r-3); background: var(--tandem-surface-muted); font-size: 13px; color: var(--tandem-fg-subtle); display: inline-block;"> </div> <div>Port used when transport is HTTP. To change, run <code>tandem start --port <N></code>.</div></div>'),kN=O("<option> </option>"),_N=O('<div><div>Token Rotation</div> <div style="font-size: 12px; color: var(--tandem-fg);"> </div> <div>To rotate: run <code>tandem rotate-token</code> in the CLI.</div></div>'),SN=O('<div><div>Connection Status</div> <div style="display: flex; align-items: center; gap: var(--tandem-space-2); padding: var(--tandem-space-2) var(--tandem-space-3); border: 1px solid var(--tandem-border); border-radius: var(--tandem-r-3); background: var(--tandem-surface);"><span aria-hidden="true"></span> <span style="font-size: 12px; color: var(--tandem-fg); flex: 1;"> <!></span> <!></div> <!></div> <div><div>Transport</div> <div style="display: flex; gap: var(--tandem-space-4); padding: var(--tandem-space-2) var(--tandem-space-3); border: 1px solid var(--tandem-border); border-radius: var(--tandem-r-3); background: var(--tandem-surface); font-size: 12px; color: var(--tandem-fg);"><span><strong>Mode:</strong> </span> <!></div></div> <!> <div><div>Show degraded banner after: <span style="font-weight: 400; text-transform: none;"> </span></div> <input data-testid="network-degraded-delay-slider" type="range" min="5000" max="120000" step="5000" style="width: 100%; accent-color: var(--tandem-accent);" aria-label="Degraded banner delay"/> <div style="display: flex; justify-content: space-between; font-size: 10px; color: var(--tandem-fg-subtle);"><span>5s</span> <span>120s</span></div></div> <div><div>Reconnect Strategy <span style="font-size: 10px; color: var(--tandem-fg-subtle);">(not yet active)</span></div> <select data-testid="network-retry-strategy" style="width: 100%; padding: 6px 8px; font-size: 13px; color: var(--tandem-fg); background: var(--tandem-surface); border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-2); cursor: pointer;" aria-label="Reconnect retry strategy"></select></div> <label><input type="checkbox" data-testid="network-hold-annotations-toggle" style="accent-color: var(--tandem-accent);"/> <span>Hold annotations while offline <span style="font-size: 10px; color: var(--tandem-fg-subtle);">(not yet active)</span></span></label> <div>When enabled, annotation events will queue locally and sync when the connection is restored.</div> <!>',1);function CN(n,e){We(e,!0);const t=bk(()=>e.open),r=Cr();let i=z(null),o=z(!1);async function s(){if(r){b(o,!0),b(i,null);try{const{invoke:M}=await ko(async()=>{const{invoke:$}=await import("./core-DhEqZVGG.js");return{invoke:$}},[]);await M("restart_sidecar")}catch(M){b(i,M instanceof Error?M.message:String(M),!0)}finally{b(o,!1)}}}const a=[{value:"exponential",label:"Exponential backoff"},{value:"constant-2s",label:"Constant (2s)"},{value:"manual",label:"Manual only"}],l="font-size: 11px; font-weight: 600; color: var(--tandem-fg); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px;",c="display: flex; align-items: center; gap: var(--tandem-space-2); cursor: pointer; font-size: 12px; color: var(--tandem-fg); min-height: 24px;",d="font-size: 10px; color: var(--tandem-fg-subtle); margin-top: var(--tandem-space-1);",u=P(()=>{var M;return(M=t.info)==null?void 0:M.transport}),h=P(()=>{var M;return(M=t.info)==null?void 0:M.bindHost}),p=P(()=>{var M;return(M=t.info)==null?void 0:M.bindPort}),m=P(()=>f(u)==="http"),v=P(()=>{var M;return(M=t.info)==null?void 0:M.tokenRotatedAt});var g=SN(),y=Le(g),w=x(y);re(w,l);var _=k(w,2),S=x(_),A=k(S,2),U=x(A),N=k(U);{var R=M=>{var $=gN(),le=x($);G(()=>ne(le,`· ${e.reconnectAttempts??""} retry attempt${e.reconnectAttempts===1?"":"s"}`)),T(M,$)};Z(N,M=>{e.reconnectAttempts>0&&M(R)})}var E=k(A,2);{var q=M=>{var $=vN(),le=x($);G(()=>{$.disabled=f(o),re($,`padding: 2px var(--tandem-space-2); font-size: 11px; border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-2); background: var(--tandem-surface); color: var(--tandem-fg-muted); cursor: pointer; opacity: ${f(o)?.5:1};`),ne(le,f(o)?"Restarting…":"Restart sidecar")}),L("click",$,s),T(M,$)},te=M=>{var $=yN();T(M,$)};Z(E,M=>{r?M(q):M(te,-1)})}var K=k(_,2);{var V=M=>{var $=bN(),le=x($);G(()=>ne(le,f(i))),T(M,$)};Z(K,M=>{f(i)&&M(V)})}var ee=k(y,2),se=x(ee);re(se,l);var F=k(se,2),X=x(F),B=k(x(X)),j=k(X,2);{var ae=M=>{var $=wN(),le=k(x($));G(()=>ne(le,` ${f(h)??""}`)),T(M,$)};Z(j,M=>{f(h)&&M(ae)})}var C=k(ee,2);{var I=M=>{var $=xN(),le=x($);re(le,l);var de=k(le,2),Ee=x(de),ce=k(de,2);re(ce,d),G(()=>ne(Ee,f(p)??"—")),T(M,$)};Z(C,M=>{f(m)&&M(I)})}var W=k(C,2),ge=x(W);re(ge,l);var xe=k(x(ge)),Oe=x(xe),J=k(ge,2),fe=k(W,2),D=x(fe);re(D,l);var Y=k(D,2);ft(Y,21,()=>a,M=>M.value,(M,$)=>{var le=kN(),de=x(le),Ee={};G(()=>{ne(de,f($).label),Ee!==(Ee=f($).value)&&(le.value=(le.__value=f($).value)??"")}),T(M,le)});var be;jw(Y);var we=k(fe,2);re(we,c);var Te=x(we),Se=k(we,2);re(Se,d);var De=k(Se,2);{var oe=M=>{var $=_N(),le=x($);re(le,l);var de=k(le,2),Ee=x(de),ce=k(de,2);re(ce,d),G(ve=>ne(Ee,ve),[()=>f(v)===null?"Auth token not yet created":`Last rotated: ${new Date(f(v)).toLocaleString()}`]),T(M,$)};Z(De,M=>{f(v)!==void 0&&M(oe)})}G(M=>{re(S,`width: 8px; height: 8px; border-radius: var(--tandem-r-circle); background: ${e.connected?"var(--tandem-success)":"var(--tandem-error)"}; flex-shrink: 0;`),ne(U,`${e.connected?"Connected to claude-sidecar":"Disconnected"} `),ne(B,` ${M??""}`),ne(Oe,`${e.settings.degradedBannerDelayMs/1e3}s`),Rr(J,e.settings.degradedBannerDelayMs),be!==(be=e.settings.sidecarRetryStrategy)&&(Y.value=(Y.__value=e.settings.sidecarRetryStrategy)??"",zm(Y,e.settings.sidecarRetryStrategy)),fs(Te,e.settings.holdAnnotationsWhileOffline)},[()=>f(u)?f(u).toUpperCase():"—"]),L("input",J,M=>e.onUpdate({degradedBannerDelayMs:Number(M.target.value)})),L("change",Y,M=>e.onUpdate({sidecarRetryStrategy:M.target.value})),L("change",Te,M=>e.onUpdate({holdAnnotationsWhileOffline:M.target.checked})),T(n,g),Ke()}Ye(["click","input","change"]);var TN=O('<button type="button"> </button>'),AN=O(`<div><label for="settings-display-name">Display Name</label> <input id="settings-display-name" data-testid="settings-display-name" type="text" style="width: 100%; padding: 8px 10px; font-size: 13px; color: var(--tandem-fg); background: var(--tandem-surface); border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-2); outline: none;"/></div> <div><div id="settings-default-mode-label">Default Mode</div> <div role="radiogroup" aria-labelledby="settings-default-mode-label" style="display: flex; gap: var(--tandem-space-2);"><button type="button" data-testid="default-mode-tandem-btn" role="radio">Tandem</button> <button type="button" data-testid="default-mode-solo-btn" role="radio">Solo</button></div> <div style="font-size: 10px; color: var(--tandem-fg-subtle); margin-top: var(--tandem-space-1);">Sets the preferred starting mode for new sessions.</div></div> <label data-testid="solo-rail-hidden-toggle" style="display: flex; align-items: center; gap: var(--tandem-space-2); cursor: pointer; font-size: 12px; color: var(--tandem-fg); min-height: 24px;"><input type="checkbox" style="accent-color: var(--tandem-accent);"/> <span>Hide side panel in Solo mode</span></label> <div style="font-size: 10px; color: var(--tandem-fg-subtle); margin-top: var(--tandem-space-1);">When enabled, the annotation panel hides automatically when you enter Solo mode and
|
|
92
|
-
restores when you return to Tandem.</div>`,1),EN=O('<div data-testid="cowork-settings-suspense-fallback" style="font-size: 12px; color: var(--tandem-fg-subtle);">Loading Cowork integration...</div>'),MN=O('<div><div>Selection Sensitivity: <span style="font-weight: 400; text-transform: none;"> </span></div> <div style="font-size: 10px; color: var(--tandem-fg-subtle); margin-bottom: 6px;">How long you must hold a selection before Claude notices it</div> <input data-testid="dwell-time-slider" type="range" style="width: 100%; accent-color: var(--tandem-accent);" aria-label="Selection dwell time"/> <div style="display: flex; justify-content: space-between; font-size: 10px; color: var(--tandem-fg-subtle);"><span> </span> <span> </span></div></div> <label data-testid="selection-toolbar-toggle" style="display: flex; align-items: center; gap: var(--tandem-space-2); cursor: pointer; font-size: 12px; color: var(--tandem-fg); min-height: 24px;"><input type="checkbox" style="accent-color: var(--tandem-accent);"/> <span>Show floating selection toolbar</span></label> <!>',1),ON=O('<kbd style="justify-self: start; padding: 1px 6px; font-family: var(--tandem-font-mono); font-size: 11px; color: var(--tandem-fg); background: var(--tandem-surface-muted); border: 1px solid var(--tandem-border-strong); border-bottom-width: 2px; border-radius: var(--tandem-r-2);"> </kbd> <span style="font-size: 13px; color: var(--tandem-fg-muted);"> </span>',1),DN=O('<section><div> </div> <div style="display: grid; grid-template-columns: minmax(120px, max-content) 1fr; gap: 6px 14px; align-items: center;"></div></section>'),RN=O('<kbd style="justify-self: start; padding: 1px 6px; font-family: var(--tandem-font-mono); font-size: 11px; color: var(--tandem-fg); background: var(--tandem-surface-muted); border: 1px solid var(--tandem-border-strong); border-bottom-width: 2px; border-radius: var(--tandem-r-2);"> </kbd> <span style="font-size: 13px; color: var(--tandem-fg-muted);"> </span>',1),NN=O('<div data-testid="settings-shortcuts-list" style="display: flex; flex-direction: column; gap: var(--tandem-space-4);"><!> <section><div>Other</div> <div style="display: grid; grid-template-columns: minmax(120px, max-content) 1fr; gap: 6px 14px; align-items: center;"></div></section></div>'),IN=O('<div style="margin-top: 6px; font-size: 11px; color: var(--tandem-error-fg);"> </div>'),PN=O('<div style="margin-top: 6px; font-size: 11px; color: var(--tandem-error-fg);"> </div>'),LN=O('<div style="font-size: 11px; color: var(--tandem-fg-subtle);">Loading...</div>'),zN=O('<dt style="color: var(--tandem-fg-subtle);"> </dt> <dd style="margin: 0; color: var(--tandem-fg-muted); overflow-wrap: anywhere;"> </dd>',1),BN=O('<dl style="display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 5px 12px; margin: 0; font-size: 11px;"></dl>'),FN=O('<div style="font-size: 11px; color: var(--tandem-fg-subtle);">App info unavailable.</div>'),VN=O('<div><button data-testid="view-documentation-btn"> </button> <!></div> <div><button data-testid="view-changelog-btn"> </button> <!></div> <div><a href="https://github.com/bloknayrb/tandem/issues/new" target="_blank" rel="noreferrer" style="display: block; width: 100%; padding: var(--tandem-space-2); font-size: 13px; font-weight: 500; border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-2); background: var(--tandem-surface-muted); color: var(--tandem-fg); text-align: center; text-decoration: none; box-sizing: border-box;">Report a bug</a></div> <div data-testid="app-info-footer" style="border-top: 1px solid var(--tandem-border); padding-top: 10px;"><div>About</div> <!></div>',1),HN=O('<div aria-hidden="true" style="position: fixed; inset: 0; background: color-mix(in srgb, var(--tandem-bg) 70%, transparent); z-index: 9998;"></div> <div data-testid="settings-popover" role="dialog" aria-modal="true" class="settings-dialog svelte-fsutp8"><aside class="settings-sidebar svelte-fsutp8"><div style="padding: 0 var(--tandem-space-2);"><div style="font-size: 18px; font-weight: 700; color: var(--tandem-fg);">Settings</div> <div style="margin-top: 2px; font-size: 11px; color: var(--tandem-fg-subtle);">Tandem preferences</div></div> <nav aria-label="Settings sections" style="display: flex; flex-direction: column; gap: 2px;"></nav></aside> <section class="settings-content svelte-fsutp8" data-testid="settings-content"><header style="display: flex; align-items: center; justify-content: space-between; min-height: 56px; padding: 0 var(--tandem-space-5); border-bottom: 1px solid var(--tandem-border); background: var(--tandem-surface);"><h2 style="font-size: 16px; font-weight: 700; color: var(--tandem-fg); margin: 0;"> </h2> <button style="background: none; border: 1px solid transparent; cursor: pointer; color: var(--tandem-fg-subtle); font-size: 18px; line-height: 1; padding: 4px 8px; min-width: 30px; min-height: 30px; border-radius: var(--tandem-r-2);" aria-label="Close settings">×</button></header> <div style="flex: 1; overflow-y: auto; padding: var(--tandem-space-5);"><div style="display: flex; flex-direction: column; gap: var(--tandem-space-5); max-width: 620px;"><!></div></div></section></div>',1);function UN(n,e){We(e,!0);const t="tandem-settings-heading",r='button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])',i=[{id:"appearance",label:"Appearance"},{id:"editor",label:"Editor"},{id:"network",label:"Network"},{id:"accessibility",label:"Accessibility"},{id:"collaboration",label:"Collaboration"},{id:"claude-code",label:"Claude Code/Cowork"},{id:"shortcuts",label:"Shortcuts"},{id:"about",label:"About"}],o=[{keys:"Ctrl+B",description:"Bold"},{keys:"Ctrl+I",description:"Italic"},{keys:"Ctrl+Z",description:"Undo"},{keys:"Ctrl+Y",description:"Redo"},{keys:"Ctrl+F",description:"Find / Replace"},{keys:"?",description:"Show keyboard shortcuts"},{keys:"Ctrl+Tab",description:"Next document tab"},{keys:"Ctrl+Shift+Tab",description:"Previous document tab"}],s=P(()=>{const V=Bd(),ee=new Map;for(const se of V.values()){if(!se.shortcut)continue;const F=se.group,X=ee.get(F)??[];X.push({keys:se.shortcut,description:se.label}),ee.set(F,X)}return ox.map(se=>({title:se.charAt(0).toUpperCase()+se.slice(1),rows:ee.get(se)??[]})).filter(se=>se.rows.length>0)});let a=lt(e,"connected",3,!1),l=lt(e,"reconnectAttempts",3,0),c=z(void 0),d=z(void 0);const u=xk();let h=z(at(u.userName));const p=bk(()=>e.open);let m=z(!1),v=z(null),g=z(!1),y=z(null),w=z("appearance");he(()=>{const V=u.userName;f(h)!==V&&document.activeElement!==f(d)&&b(h,V,!0)}),he(()=>{var V;if(e.open)return(V=f(c))==null||V.focus(),()=>{var ee;(ee=e.returnFocusEl)==null||ee.focus()}}),he(()=>{if(!e.open)return;const V=se=>{var X;const F=se.target;(X=e.anchorEl)!=null&&X.contains(F)||f(c)&&!f(c).contains(F)&&e.onClose()},ee=setTimeout(()=>document.addEventListener("pointerdown",V),0);return()=>{clearTimeout(ee),document.removeEventListener("pointerdown",V)}}),he(()=>{if(!e.open)return;const V=ee=>{if(ee.key==="Escape"){e.onClose();return}if(ee.key!=="Tab"||!f(c))return;const se=f(c).querySelectorAll(r);if(se.length===0)return;const F=se[0],X=se[se.length-1],B=document.activeElement;if(!f(c).contains(B)){ee.preventDefault(),F.focus();return}ee.shiftKey&&B===F?(ee.preventDefault(),X.focus()):!ee.shiftKey&&B===X&&(ee.preventDefault(),F.focus())};return window.addEventListener("keydown",V),()=>window.removeEventListener("keydown",V)});async function _(V,ee,se,F){if(!V){se(F.notFound);return}ee(!0),se(null);try{const X=await fetch(`${Sr}/open`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filePath:V,readOnly:!0})});if(!X.ok){let B=F.failed;try{const j=await X.json();j.message&&(B=j.message)}catch{}X.status===404&&(B=F.notFound),se(B);return}e.onClose()}catch(X){console.warn("[Tandem] Failed to open read-only file:",X),se("Server unavailable.")}finally{ee(!1)}}function S(){var V;return _((V=p.info)==null?void 0:V.workflowsPath,ee=>b(g,ee,!0),ee=>b(y,ee,!0),{notFound:"Documentation file not found.",failed:"Failed to open documentation."})}function A(){var V;return _((V=p.info)==null?void 0:V.changelogPath,ee=>b(m,ee,!0),ee=>b(v,ee,!0),{notFound:"Changelog file not found.",failed:"Failed to open changelog."})}const U="font-size: 11px; font-weight: 600; color: var(--tandem-fg); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px;";function N(V){const ee=f(w)===V;return["width: 100%;","display: flex;","align-items: center;","min-height: 34px;","padding: 0 var(--tandem-space-3);","border: 1px solid transparent;","border-radius: var(--tandem-r-3);","background: "+(ee?"var(--tandem-accent-bg)":"transparent")+";","color: "+(ee?"var(--tandem-accent-fg-strong)":"var(--tandem-fg-muted)")+";","font-size: 13px;","font-weight: "+(ee?"600":"500")+";","text-align: left;","cursor: pointer;"].join(" ")}function R(V){var ee;return((ee=i.find(se=>se.id===V))==null?void 0:ee.label)??"Settings"}function E(){var se;const V=p.info;if(!V)return[];const ee=[{label:"Version",value:`Tandem v${V.version}`},{label:"Tools",value:V.toolCount===null?"Tool count unavailable":`${V.toolCount} tools available`},{label:"MCP SDK",value:`MCP SDK ${V.mcpSdkVersion}`},{label:"Transport",value:((se=V.transport)==null?void 0:se.toUpperCase())??"—"}];return V.storagePath&&ee.push({label:"Storage",value:V.storagePath}),V.tokenRotatedAt!==void 0&&ee.push({label:"Token",value:V.tokenRotatedAt===null?"Token not created":`Token rotated ${new Date(V.tokenRotatedAt).toLocaleString()}`}),V.changelogPath&&ee.push({label:"Changelog",value:V.changelogPath}),ee}var q=Tt(),te=Le(q);{var K=V=>{var ee=HN(),se=Le(ee),F=k(se,2);Q(F,"aria-labelledby",t),Q(F,"tabindex",-1);var X=x(F),B=x(X),j=x(B);Q(j,"id",t);var ae=k(B,2);ft(ae,21,()=>i,M=>M.id,(M,$)=>{var le=TN(),de=x(le);G(Ee=>{Q(le,"aria-current",f(w)===f($).id?"page":void 0),re(le,Ee),ne(de,f($).label)},[()=>N(f($).id)]),L("click",le,()=>b(w,f($).id,!0)),T(M,le)});var C=k(X,2),I=x(C),W=x(I),ge=x(W),xe=k(W,2),Oe=k(I,2),J=x(Oe),fe=x(J);{var D=M=>{var $=AN(),le=Le($),de=x(le);re(de,U);var Ee=k(de,2);yt(Ee,Ne=>b(d,Ne),()=>f(d));var ce=k(le,2),ve=x(ce);re(ve,U);var ke=k(ve,2),pe=x(ke),ze=k(pe,2),tt=k(ce,2),Ce=x(tt);G(()=>{Rr(Ee,f(h)),Q(Ee,"maxlength",tx),Q(pe,"aria-checked",e.settings.defaultMode==="tandem"),re(pe,`flex: 1; padding: var(--tandem-space-2); min-height: 30px; border: 2px solid ${e.settings.defaultMode==="tandem"?"var(--tandem-accent)":"var(--tandem-border)"}; border-radius: var(--tandem-r-3); background: ${e.settings.defaultMode==="tandem"?"var(--tandem-accent-bg)":"var(--tandem-surface)"}; color: ${e.settings.defaultMode==="tandem"?"var(--tandem-accent-fg-strong)":"var(--tandem-fg-muted)"}; font-size: 12px; font-weight: ${e.settings.defaultMode==="tandem"?600:400}; cursor: pointer;`),Q(ze,"aria-checked",e.settings.defaultMode==="solo"),re(ze,`flex: 1; padding: var(--tandem-space-2); min-height: 30px; border: 2px solid ${e.settings.defaultMode==="solo"?"var(--tandem-accent)":"var(--tandem-border)"}; border-radius: var(--tandem-r-3); background: ${e.settings.defaultMode==="solo"?"var(--tandem-accent-bg)":"var(--tandem-surface)"}; color: ${e.settings.defaultMode==="solo"?"var(--tandem-accent-fg-strong)":"var(--tandem-fg-muted)"}; font-size: 12px; font-weight: ${e.settings.defaultMode==="solo"?600:400}; cursor: pointer;`),fs(Ce,e.settings.soloRailHidden)}),L("input",Ee,Ne=>{b(h,Ne.target.value,!0)}),vt("blur",Ee,()=>u.setUserName(f(h))),L("keydown",Ee,Ne=>{Ne.key==="Enter"&&Ne.currentTarget.blur(),Ne.key==="Escape"&&(b(h,u.userName,!0),Ne.currentTarget.blur())}),L("click",pe,()=>e.onUpdate({defaultMode:"tandem"})),L("click",ze,()=>e.onUpdate({defaultMode:"solo"})),L("change",Ce,Ne=>e.onUpdate({soloRailHidden:Ne.target.checked})),T(M,$)},Y=M=>{hN(M,{get open(){return e.open},get settings(){return e.settings},get onUpdate(){return e.onUpdate}})},be=M=>{mN(M,{get settings(){return e.settings},get onUpdate(){return e.onUpdate}})},we=M=>{CN(M,{get open(){return e.open},get settings(){return e.settings},get onUpdate(){return e.onUpdate},get connected(){return a()},get reconnectAttempts(){return l()}})},Te=M=>{aN(M,{get settings(){return e.settings},get onUpdate(){return e.onUpdate}})},Se=M=>{var $=MN(),le=Le($),de=x(le);re(de,U);var Ee=k(x(de)),ce=x(Ee),ve=k(de,4);Q(ve,"step",100);var ke=k(ve,2),pe=x(ke),ze=x(pe),tt=k(pe,2),Ce=x(tt),Ne=k(le,2),mt=x(Ne),Yt=k(Ne,2);{var Mn=gt=>{var nt=Tt(),Mt=Le(nt);aT(Mt,()=>ko(()=>import("./CoworkSettings-ChE5WuAe.js"),[]),cn=>{var On=EN();T(cn,On)},(cn,On)=>{const ht=P(()=>f(On).default);var rt=Tt(),Ve=Le(rt);hT(Ve,()=>f(ht),(dt,qe)=>{qe(dt,{})}),T(cn,rt)}),T(gt,nt)},rr=P(()=>Cr());Z(Yt,gt=>{f(rr)&>(Mn)})}G((gt,nt,Mt)=>{ne(ce,`${gt??""}s`),Q(ve,"min",Ld),Q(ve,"max",zd),Rr(ve,e.settings.selectionDwellMs),ne(ze,`${nt??""}s`),ne(Ce,`${Mt??""}s`),fs(mt,e.settings.selectionToolbar)},[()=>(e.settings.selectionDwellMs/1e3).toFixed(1),()=>(Ld/1e3).toFixed(1),()=>(zd/1e3).toFixed(1)]),L("input",ve,gt=>e.onUpdate({selectionDwellMs:Number(gt.target.value)})),L("change",mt,gt=>e.onUpdate({selectionToolbar:gt.target.checked})),T(M,$)},De=M=>{var $=NN(),le=x($);ft(le,17,()=>f(s),ve=>ve.title,(ve,ke)=>{var pe=DN(),ze=x(pe);re(ze,U);var tt=x(ze),Ce=k(ze,2);ft(Ce,21,()=>f(ke).rows,Ne=>Ne.keys+Ne.description,(Ne,mt)=>{var Yt=ON(),Mn=Le(Yt),rr=x(Mn),gt=k(Mn,2),nt=x(gt);G(()=>{ne(rr,f(mt).keys),ne(nt,f(mt).description)}),T(Ne,Yt)}),G(()=>ne(tt,f(ke).title)),T(ve,pe)});var de=k(le,2),Ee=x(de);re(Ee,U);var ce=k(Ee,2);ft(ce,21,()=>o,ve=>ve.keys+ve.description,(ve,ke)=>{var pe=RN(),ze=Le(pe),tt=x(ze),Ce=k(ze,2),Ne=x(Ce);G(()=>{ne(tt,f(ke).keys),ne(Ne,f(ke).description)}),T(ve,pe)}),T(M,$)},oe=M=>{var $=VN(),le=Le($),de=x(le),Ee=x(de),ce=k(de,2);{var ve=nt=>{var Mt=IN(),cn=x(Mt);G(()=>ne(cn,f(y))),T(nt,Mt)};Z(ce,nt=>{f(y)&&nt(ve)})}var ke=k(le,2),pe=x(ke),ze=x(pe),tt=k(pe,2);{var Ce=nt=>{var Mt=PN(),cn=x(Mt);G(()=>ne(cn,f(v))),T(nt,Mt)};Z(tt,nt=>{f(v)&&nt(Ce)})}var Ne=k(ke,4),mt=x(Ne);re(mt,U);var Yt=k(mt,2);{var Mn=nt=>{var Mt=LN();T(nt,Mt)},rr=nt=>{var Mt=BN();ft(Mt,21,E,cn=>cn.label,(cn,On)=>{var ht=zN(),rt=Le(ht),Ve=x(rt),dt=k(rt,2),qe=x(dt);G(()=>{ne(Ve,f(On).label),ne(qe,f(On).value)}),T(cn,ht)}),T(nt,Mt)},gt=nt=>{var Mt=FN();T(nt,Mt)};Z(Yt,nt=>{p.loading?nt(Mn):p.info?nt(rr,1):nt(gt,-1)})}G(()=>{de.disabled=f(g)||p.loading,re(de,`width: 100%; padding: var(--tandem-space-2); font-size: 13px; font-weight: 500; border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-2); cursor: ${f(g)||p.loading?"not-allowed":"pointer"}; background: var(--tandem-surface-muted); color: var(--tandem-fg); opacity: ${f(g)||p.loading?.6:1};`),ne(Ee,f(g)?"Opening…":"View Documentation"),pe.disabled=f(m)||p.loading,re(pe,`width: 100%; padding: var(--tandem-space-2); font-size: 13px; font-weight: 500; border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-2); cursor: ${f(m)||p.loading?"not-allowed":"pointer"}; background: var(--tandem-surface-muted); color: var(--tandem-fg); opacity: ${f(m)||p.loading?.6:1};`),ne(ze,f(m)?"Opening…":"View Changelog")}),L("click",de,()=>void S()),L("click",pe,()=>void A()),T(M,$)};Z(fe,M=>{f(w)==="collaboration"?M(D):f(w)==="appearance"?M(Y,1):f(w)==="editor"?M(be,2):f(w)==="network"?M(we,3):f(w)==="accessibility"?M(Te,4):f(w)==="claude-code"?M(Se,5):f(w)==="shortcuts"?M(De,6):M(oe,-1)})}yt(F,M=>b(c,M),()=>f(c)),G(M=>ne(ge,M),[()=>R(f(w))]),L("click",se,function(...M){var $;($=e.onClose)==null||$.apply(this,M)}),L("click",xe,function(...M){var $;($=e.onClose)==null||$.apply(this,M)}),T(V,ee)};Z(te,V=>{e.open&&V(K)})}T(n,q),Ke()}Ye(["click","input","keydown","change"]);var jN=O('<span class="toast-badge svelte-nsu1aw"> </span>'),WN=O('<div><span> </span> <!> <button style="position: absolute; top: 6px; right: 6px; border: none; background: transparent; cursor: pointer; font-size: 14px; color: var(--tandem-fg-subtle); line-height: 1; padding: 2px 4px;" aria-label="Dismiss notification">×</button></div>'),KN=O('<div data-testid="toast-container" style="position: fixed; bottom: 40px; right: var(--tandem-space-4); z-index: var(--tandem-z-toast); display: flex; flex-direction: column; gap: var(--tandem-space-2); max-width: 360px; pointer-events: none;"></div>');function qN(n,e){We(e,!0);const t={error:"var(--tandem-error)",warning:"var(--tandem-warning)",info:"var(--tandem-accent)"},r={error:"var(--tandem-error-bg)",warning:"var(--tandem-warning-bg)",info:"var(--tandem-accent-bg)"},i={error:"var(--tandem-error-fg-strong)",warning:"var(--tandem-warning-fg-strong)",info:"var(--tandem-accent-fg-strong)"};var o=Tt(),s=Le(o);{var a=l=>{var c=KN();ft(c,21,()=>e.toasts,d=>d.id,(d,u)=>{const h=P(()=>t[f(u).severity]),p=P(()=>r[f(u).severity]),m=P(()=>i[f(u).severity]),v=P(()=>f(u).severity==="info"?"status":"alert");var g=WN(),y=x(g),w=x(y),_=k(y,2);{var S=U=>{var N=jN(),R=x(N);G(()=>{Q(N,"data-testid",`toast-count-${f(u).id}`),re(N,`margin-left: 6px; font-size: 11px; font-weight: 600; color: ${f(m)??""}; background: ${f(p)??""}; padding: 1px 5px; border-radius: var(--tandem-r-4);`),ne(R,`×${f(u).count??""}`)}),T(U,N)};Z(_,U=>{f(u).count>1&&U(S)})}var A=k(_,2);G(()=>{Q(g,"role",f(v)),Q(g,"data-testid",`toast-${f(u).id}`),re(g,`pointer-events: auto; background: var(--tandem-surface); border-radius: var(--tandem-r-3); border-left: 4px solid ${f(h)??""}; box-shadow: var(--tandem-shadow-4); padding: 10px 32px 10px 12px; position: relative; animation: tandem-toast-slide-in 0.2s ease-out; font-size: var(--tandem-text-base); line-height: 1.4; color: var(--tandem-fg);`),ne(w,f(u).message),Q(A,"data-testid",`toast-dismiss-${f(u).id}`)}),L("click",A,()=>e.onDismiss(f(u).id)),T(d,g)}),T(l,c)};Z(s,l=>{e.toasts.length>0&&l(a)})}T(n,o),Ke()}Ye(["click"]);var JN=O('<div class="docx-canvas svelte-wm6yrp"><div class="docx-sheet svelte-wm6yrp"><!></div></div>');function YN(n,e){var t=JN(),r=x(t),i=x(r);Lm(i,()=>e.children),T(n,t)}const GN=Math.floor,ZN=(n,e)=>n<e?n:e,XN=(n,e)=>n>e?n:e,kk=128,wd=127,QN=Number.MAX_SAFE_INTEGER,$N=n=>{const e=unescape(encodeURIComponent(n)),t=e.length,r=new Uint8Array(t);for(let i=0;i<t;i++)r[i]=e.codePointAt(i);return r},Gl=typeof TextEncoder<"u"?new TextEncoder:null,eI=n=>Gl.encode(n),tI=Gl?eI:$N;let ul=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});ul&&ul.decode(new Uint8Array).length===1&&(ul=null);const iu=(n,e)=>{const t=n.cbuf.length;n.cpos===t&&(n.bufs.push(n.cbuf),n.cbuf=new Uint8Array(t*2),n.cpos=0),n.cbuf[n.cpos++]=e},bf=(n,e)=>{for(;e>wd;)iu(n,kk|wd&e),e=GN(e/128);iu(n,wd&e)},Bp=new Uint8Array(3e4),nI=Bp.length/3,rI=(n,e)=>{if(e.length<nI){const t=Gl.encodeInto(e,Bp).written||0;bf(n,t);for(let r=0;r<t;r++)iu(n,Bp[r])}else aI(n,tI(e))},iI=(n,e)=>{const t=unescape(encodeURIComponent(e)),r=t.length;bf(n,r);for(let i=0;i<r;i++)iu(n,t.codePointAt(i))},oI=Gl&&Gl.encodeInto?rI:iI,sI=(n,e)=>{const t=n.cbuf.length,r=n.cpos,i=ZN(t-r,e.length),o=e.length-i;n.cbuf.set(e.subarray(0,i),r),n.cpos+=i,o>0&&(n.bufs.push(n.cbuf),n.cbuf=new Uint8Array(XN(t*2,o)),n.cbuf.set(e.subarray(i)),n.cpos=o)},aI=(n,e)=>{bf(n,e.byteLength),sI(n,e)},_k=n=>new Error(n),lI=_k("Unexpected end of array"),cI=_k("Integer out of Range"),dI=(n,e)=>{const t=new Uint8Array(n.arr.buffer,n.pos+n.arr.byteOffset,e);return n.pos+=e,t},uI=n=>dI(n,Sg(n)),rb=n=>n.arr[n.pos++],Sg=n=>{let e=0,t=1;const r=n.arr.length;for(;n.pos<r;){const i=n.arr[n.pos++];if(e=e+(i&wd)*t,t*=128,i<kk)return e;if(e>QN)throw cI}throw lI},fI=n=>{let e=Sg(n);if(e===0)return"";{let t=String.fromCodePoint(rb(n));if(--e<100)for(;e--;)t+=String.fromCodePoint(rb(n));else for(;e>0;){const r=e<1e4?e:1e4,i=n.arr.subarray(n.pos,n.pos+r);n.pos+=r,t+=String.fromCodePoint.apply(null,i),e-=r}return decodeURIComponent(escape(t))}},hI=n=>ul.decode(uI(n)),ib=ul?hI:fI;var na;(function(n){n[n.Token=0]="Token",n[n.PermissionDenied=1]="PermissionDenied",n[n.Authenticated=2]="Authenticated"})(na||(na={}));const pI=(n,e)=>{bf(n,na.Token),oI(n,e)},mI=(n,e,t,r)=>{switch(Sg(n)){case na.Token:{e();break}case na.PermissionDenied:{t(ib(n));break}case na.Authenticated:{r(ib(n));break}}},ob=n=>Array.from(n.entries()).map(([e,t])=>({clientId:e,...t}));var Fp;(function(n){n[n.Connecting=0]="Connecting",n[n.Open=1]="Open",n[n.Closing=2]="Closing",n[n.Closed=3]="Closed"})(Fp||(Fp={}));function gI(n){return n||(n={}),{delay:n.delay===void 0?200:n.delay,initialDelay:n.initialDelay===void 0?0:n.initialDelay,minDelay:n.minDelay===void 0?0:n.minDelay,maxDelay:n.maxDelay===void 0?0:n.maxDelay,factor:n.factor===void 0?0:n.factor,maxAttempts:n.maxAttempts===void 0?3:n.maxAttempts,timeout:n.timeout===void 0?0:n.timeout,jitter:n.jitter===!0,initialJitter:n.initialJitter===!0,handleError:n.handleError===void 0?null:n.handleError,handleTimeout:n.handleTimeout===void 0?null:n.handleTimeout,beforeAttempt:n.beforeAttempt===void 0?null:n.beforeAttempt,calculateDelay:n.calculateDelay===void 0?null:n.calculateDelay}}async function vh(n){return new Promise(e=>setTimeout(e,n))}function vI(n,e){let t=e.delay;if(t===0)return 0;if(e.factor&&(t*=Math.pow(e.factor,n.attemptNum-1),e.maxDelay!==0&&(t=Math.min(t,e.maxDelay))),e.jitter){const r=Math.ceil(e.minDelay),i=Math.floor(t);t=Math.floor(Math.random()*(i-r+1))+r}return Math.round(t)}async function yI(n,e){const t=gI(e);for(const a of["delay","initialDelay","minDelay","maxDelay","maxAttempts","timeout"]){const l=t[a];if(!Number.isInteger(l)||l<0)throw new Error(`Value for ${a} must be an integer greater than or equal to 0`)}if(t.factor.constructor!==Number||t.factor<0)throw new Error("Value for factor must be a number greater than or equal to 0");if(t.delay<t.minDelay)throw new Error(`delay cannot be less than minDelay (delay: ${t.delay}, minDelay: ${t.minDelay}`);const r={attemptNum:0,attemptsRemaining:t.maxAttempts?t.maxAttempts:-1,aborted:!1,abort(){r.aborted=!0}},i=t.calculateDelay||vI;async function o(){if(t.beforeAttempt&&t.beforeAttempt(r,t),r.aborted){const l=new Error("Attempt aborted");throw l.code="ATTEMPT_ABORTED",l}const a=async l=>{if(t.handleError&&await t.handleError(l,r,t),r.aborted||r.attemptsRemaining===0)throw l;r.attemptNum++;const c=i(r,t);return c&&await vh(c),o()};return r.attemptsRemaining>0&&r.attemptsRemaining--,t.timeout?new Promise((l,c)=>{const d=setTimeout(()=>{if(t.handleTimeout)try{l(t.handleTimeout(r,t))}catch(u){c(u)}else{const u=new Error(`Retry timeout (attemptNum: ${r.attemptNum}, timeout: ${t.timeout})`);u.code="ATTEMPT_TIMEOUT",c(u)}},t.timeout);n(r,t).then(u=>{clearTimeout(d),l(u)}).catch(u=>{clearTimeout(d),a(u).then(l).catch(c)})}):n(r,t).catch(a)}const s=t.calculateDelay?t.calculateDelay(r,t):t.initialDelay;if(s&&await vh(s),r.attemptNum<1&&t.initialJitter){const a=i(r,t);a&&await vh(a)}return o()}const Sk=Math.floor,bI=(n,e)=>n<e?n:e,wI=(n,e)=>n>e?n:e,xI=64,ou=128,kI=63,fl=127,Ck=Number.MAX_SAFE_INTEGER,_I=()=>new Set,SI=Array.from,CI=n=>{const e=unescape(encodeURIComponent(n)),t=e.length,r=new Uint8Array(t);for(let i=0;i<t;i++)r[i]=e.codePointAt(i);return r},Zl=typeof TextEncoder<"u"?new TextEncoder:null,TI=n=>Zl.encode(n),AI=Zl?TI:CI;let hl=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});hl&&hl.decode(new Uint8Array).length===1&&(hl=null);class EI{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}const Cg=()=>new EI,Tk=n=>{let e=n.cpos;for(let t=0;t<n.bufs.length;t++)e+=n.bufs[t].length;return e},Tg=n=>{const e=new Uint8Array(Tk(n));let t=0;for(let r=0;r<n.bufs.length;r++){const i=n.bufs[r];e.set(i,t),t+=i.length}return e.set(new Uint8Array(n.cbuf.buffer,0,n.cpos),t),e},su=(n,e)=>{const t=n.cbuf.length;n.cpos===t&&(n.bufs.push(n.cbuf),n.cbuf=new Uint8Array(t*2),n.cpos=0),n.cbuf[n.cpos++]=e},kn=(n,e)=>{for(;e>fl;)su(n,ou|fl&e),e=Sk(e/128);su(n,fl&e)},Vp=new Uint8Array(3e4),MI=Vp.length/3,OI=(n,e)=>{if(e.length<MI){const t=Zl.encodeInto(e,Vp).written||0;kn(n,t);for(let r=0;r<t;r++)su(n,Vp[r])}else Ua(n,AI(e))},DI=(n,e)=>{const t=unescape(encodeURIComponent(e)),r=t.length;kn(n,r);for(let i=0;i<r;i++)su(n,t.codePointAt(i))},ji=Zl&&Zl.encodeInto?OI:DI,RI=(n,e)=>{const t=n.cbuf.length,r=n.cpos,i=bI(t-r,e.length),o=e.length-i;n.cbuf.set(e.subarray(0,i),r),n.cpos+=i,o>0&&(n.bufs.push(n.cbuf),n.cbuf=new Uint8Array(wI(t*2,o)),n.cbuf.set(e.subarray(i)),n.cpos=o)},Ua=(n,e)=>{kn(n,e.byteLength),RI(n,e)},Ak=n=>new Error(n),Ek=Ak("Unexpected end of array"),Mk=Ak("Integer out of Range");class NI{constructor(e){this.arr=e,this.pos=0}}const Ok=n=>new NI(n),II=(n,e)=>{const t=new Uint8Array(n.arr.buffer,n.pos+n.arr.byteOffset,e);return n.pos+=e,t},wf=n=>II(n,ss(n)),sb=n=>n.arr[n.pos++],ss=n=>{let e=0,t=1;const r=n.arr.length;for(;n.pos<r;){const i=n.arr[n.pos++];if(e=e+(i&fl)*t,t*=128,i<ou)return e;if(e>Ck)throw Mk}throw Ek},PI=n=>{let e=n.arr[n.pos++],t=e&kI,r=64;const i=(e&xI)>0?-1:1;if((e&ou)===0)return i*t;const o=n.arr.length;for(;n.pos<o;){if(e=n.arr[n.pos++],t=t+(e&fl)*r,r*=128,e<ou)return i*t;if(t>Ck)throw Mk}throw Ek},LI=n=>{let e=ss(n);if(e===0)return"";{let t=String.fromCodePoint(sb(n));if(--e<100)for(;e--;)t+=String.fromCodePoint(sb(n));else for(;e>0;){const r=e<1e4?e:1e4,i=n.arr.subarray(n.pos,n.pos+r);n.pos+=r,t+=String.fromCodePoint.apply(null,i),e-=r}return decodeURIComponent(escape(t))}},zI=n=>hl.decode(wf(n)),Xl=hl?zI:LI,BI=n=>{const e=n.pos,t=Xl(n);return n.pos=e,t},Ma=Date.now,yh=()=>new Map,FI=(n,e,t)=>{let r=n.get(e);return r===void 0&&n.set(e,r=t()),r};class VI{constructor(){this._observers=yh()}on(e,t){FI(this._observers,e,_I).add(t)}once(e,t){const r=(...i)=>{this.off(e,r),t(...i)};this.on(e,r)}off(e,t){const r=this._observers.get(e);r!==void 0&&(r.delete(t),r.size===0&&this._observers.delete(e))}emit(e,t){return SI((this._observers.get(e)||yh()).values()).forEach(r=>r(...t))}destroy(){this._observers=yh()}}const HI=Object.keys,ab=n=>HI(n).length,UI=(n,e)=>Object.prototype.hasOwnProperty.call(n,e),jI=(n,e)=>n===e,pl=(n,e)=>{if(n==null||e==null)return jI(n,e);if(n.constructor!==e.constructor)return!1;if(n===e)return!0;switch(n.constructor){case ArrayBuffer:n=new Uint8Array(n),e=new Uint8Array(e);case Uint8Array:{if(n.byteLength!==e.byteLength)return!1;for(let t=0;t<n.length;t++)if(n[t]!==e[t])return!1;break}case Set:{if(n.size!==e.size)return!1;for(const t of n)if(!e.has(t))return!1;break}case Map:{if(n.size!==e.size)return!1;for(const t of n.keys())if(!e.has(t)||!pl(n.get(t),e.get(t)))return!1;break}case Object:if(ab(n)!==ab(e))return!1;for(const t in n)if(!UI(n,t)||!pl(n[t],e[t]))return!1;break;case Array:if(n.length!==e.length)return!1;for(let t=0;t<n.length;t++)if(!pl(n[t],e[t]))return!1;break;default:return!1}return!0},bh=3e4;class WI extends VI{constructor(e){super(),this.doc=e,this.clientID=e.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval(()=>{const t=Ma();this.getLocalState()!==null&&bh/2<=t-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());const r=[];this.meta.forEach((i,o)=>{o!==this.clientID&&bh<=t-i.lastUpdated&&this.states.has(o)&&r.push(o)}),r.length>0&&xd(this,r,"timeout")},Sk(bh/10)),e.on("destroy",()=>{this.destroy()}),this.setLocalState({})}destroy(){this.emit("destroy",[this]),this.setLocalState(null),super.destroy(),clearInterval(this._checkInterval)}getLocalState(){return this.states.get(this.clientID)||null}setLocalState(e){const t=this.clientID,r=this.meta.get(t),i=r===void 0?0:r.clock+1,o=this.states.get(t);e===null?this.states.delete(t):this.states.set(t,e),this.meta.set(t,{clock:i,lastUpdated:Ma()});const s=[],a=[],l=[],c=[];e===null?c.push(t):o==null?e!=null&&s.push(t):(a.push(t),pl(o,e)||l.push(t)),(s.length>0||l.length>0||c.length>0)&&this.emit("change",[{added:s,updated:l,removed:c},"local"]),this.emit("update",[{added:s,updated:a,removed:c},"local"])}setLocalStateField(e,t){const r=this.getLocalState();r!==null&&this.setLocalState({...r,[e]:t})}getStates(){return this.states}}const xd=(n,e,t)=>{const r=[];for(let i=0;i<e.length;i++){const o=e[i];if(n.states.has(o)){if(n.states.delete(o),o===n.clientID){const s=n.meta.get(o);n.meta.set(o,{clock:s.clock+1,lastUpdated:Ma()})}r.push(o)}}r.length>0&&(n.emit("change",[{added:[],updated:[],removed:r},t]),n.emit("update",[{added:[],updated:[],removed:r},t]))},Hp=(n,e,t=n.states)=>{const r=e.length,i=Cg();kn(i,r);for(let o=0;o<r;o++){const s=e[o],a=t.get(s)||null,l=n.meta.get(s).clock;kn(i,s),kn(i,l),ji(i,JSON.stringify(a))}return Tg(i)},KI=(n,e,t)=>{const r=Ok(e),i=Ma(),o=[],s=[],a=[],l=[],c=ss(r);for(let d=0;d<c;d++){const u=ss(r);let h=ss(r);const p=JSON.parse(Xl(r)),m=n.meta.get(u),v=n.states.get(u),g=m===void 0?0:m.clock;(g<h||g===h&&p===null&&n.states.has(u))&&(p===null?u===n.clientID&&n.getLocalState()!=null?h++:n.states.delete(u):n.states.set(u,p),n.meta.set(u,{clock:h,lastUpdated:i}),m===void 0&&p!==null?o.push(u):m!==void 0&&p===null?l.push(u):p!==null&&(pl(p,v)||a.push(u),s.push(u)))}(o.length>0||a.length>0||l.length>0)&&n.emit("change",[{added:o,updated:a,removed:l},t]),(o.length>0||s.length>0||l.length>0)&&n.emit("update",[{added:o,updated:s,removed:l},t])};let Dk=class{constructor(){this.callbacks={}}on(e,t){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),this}emit(e,...t){const r=this.callbacks[e];return r&&r.forEach(i=>i.apply(this,t)),this}off(e,t){const r=this.callbacks[e];return r&&(t?this.callbacks[e]=r.filter(i=>i!==t):delete this.callbacks[e]),this}removeAllListeners(){this.callbacks={}}};class Up{constructor(e){this.data=e,this.encoder=Cg(),this.decoder=Ok(new Uint8Array(this.data))}peekVarString(){return BI(this.decoder)}readVarUint(){return ss(this.decoder)}readVarString(){return Xl(this.decoder)}readVarUint8Array(){return wf(this.decoder)}writeVarUint(e){return kn(this.encoder,e)}writeVarString(e){return ji(this.encoder,e)}writeVarUint8Array(e){return Ua(this.encoder,e)}length(){return Tk(this.encoder)}}var un;(function(n){n[n.Sync=0]="Sync",n[n.Awareness=1]="Awareness",n[n.Auth=2]="Auth",n[n.QueryAwareness=3]="QueryAwareness",n[n.Stateless=5]="Stateless",n[n.CLOSE=7]="CLOSE",n[n.SyncStatus=8]="SyncStatus"})(un||(un={}));var Dn;(function(n){n.Connecting="connecting",n.Connected="connected",n.Disconnected="disconnected"})(Dn||(Dn={}));class Rs{constructor(){this.encoder=Cg()}get(e){return e.encoder}toUint8Array(){return Tg(this.encoder)}}class qI extends Rs{constructor(){super(...arguments),this.type=un.CLOSE,this.description="Ask the server to close the connection"}get(e){return ji(this.encoder,e.documentName),kn(this.encoder,this.type),this.encoder}}class JI extends Dk{constructor(e){super(),this.messageQueue=[],this.configuration={url:"",autoConnect:!0,preserveTrailingSlash:!1,document:void 0,WebSocketPolyfill:void 0,messageReconnectTimeout:3e4,delay:1e3,initialDelay:0,factor:2,maxAttempts:0,minDelay:1e3,maxDelay:3e4,jitter:!0,timeout:0,onOpen:()=>null,onConnect:()=>null,onMessage:()=>null,onOutgoingMessage:()=>null,onStatus:()=>null,onDisconnect:()=>null,onClose:()=>null,onDestroy:()=>null,onAwarenessUpdate:()=>null,onAwarenessChange:()=>null,handleTimeout:null,providerMap:new Map},this.webSocket=null,this.webSocketHandlers={},this.shouldConnect=!0,this.status=Dn.Disconnected,this.lastMessageReceived=0,this.identifier=0,this.intervals={connectionChecker:null},this.connectionAttempt=null,this.receivedOnOpenPayload=void 0,this.closeTries=0,this.setConfiguration(e),this.configuration.WebSocketPolyfill=e.WebSocketPolyfill?e.WebSocketPolyfill:WebSocket,this.on("open",this.configuration.onOpen),this.on("open",this.onOpen.bind(this)),this.on("connect",this.configuration.onConnect),this.on("message",this.configuration.onMessage),this.on("outgoingMessage",this.configuration.onOutgoingMessage),this.on("status",this.configuration.onStatus),this.on("disconnect",this.configuration.onDisconnect),this.on("close",this.configuration.onClose),this.on("destroy",this.configuration.onDestroy),this.on("awarenessUpdate",this.configuration.onAwarenessUpdate),this.on("awarenessChange",this.configuration.onAwarenessChange),this.on("close",this.onClose.bind(this)),this.on("message",this.onMessage.bind(this)),this.intervals.connectionChecker=setInterval(this.checkConnection.bind(this),this.configuration.messageReconnectTimeout/10),this.shouldConnect&&this.connect()}async onOpen(e){this.status=Dn.Connected,this.emit("status",{status:Dn.Connected}),this.cancelWebsocketRetry=void 0,this.receivedOnOpenPayload=e}attach(e){this.configuration.providerMap.set(e.configuration.name,e),this.status===Dn.Disconnected&&this.shouldConnect&&this.connect(),this.receivedOnOpenPayload&&this.status===Dn.Connected&&e.onOpen(this.receivedOnOpenPayload)}detach(e){this.configuration.providerMap.has(e.configuration.name)&&(e.send(qI,{documentName:e.configuration.name}),this.configuration.providerMap.delete(e.configuration.name))}setConfiguration(e={}){this.configuration={...this.configuration,...e},this.configuration.autoConnect||(this.shouldConnect=!1)}async connect(){if(this.status===Dn.Connected)return;this.cancelWebsocketRetry&&(this.cancelWebsocketRetry(),this.cancelWebsocketRetry=void 0),this.receivedOnOpenPayload=void 0,this.shouldConnect=!0;const e=()=>{let i=!1;return{retryPromise:yI(this.createWebSocketConnection.bind(this),{delay:this.configuration.delay,initialDelay:this.configuration.initialDelay,factor:this.configuration.factor,maxAttempts:this.configuration.maxAttempts,minDelay:this.configuration.minDelay,maxDelay:this.configuration.maxDelay,jitter:this.configuration.jitter,timeout:this.configuration.timeout,handleTimeout:this.configuration.handleTimeout,beforeAttempt:s=>{(!this.shouldConnect||i)&&s.abort()}}).catch(s=>{if(s&&s.code!=="ATTEMPT_ABORTED")throw s}),cancelFunc:()=>{i=!0}}},{retryPromise:t,cancelFunc:r}=e();return this.cancelWebsocketRetry=r,t}attachWebSocketListeners(e,t){const{identifier:r}=e,i=c=>this.emit("message",c),o=c=>this.emit("close",{event:c}),s=c=>this.emit("open",c),a=c=>{t(c)};this.webSocketHandlers[r]={message:i,close:o,open:s,error:a};const l=this.webSocketHandlers[e.identifier];Object.keys(l).forEach(c=>{e.addEventListener(c,l[c])})}cleanupWebSocket(){if(!this.webSocket)return;const{identifier:e}=this.webSocket,t=this.webSocketHandlers[e];Object.keys(t).forEach(r=>{var i;(i=this.webSocket)===null||i===void 0||i.removeEventListener(r,t[r]),delete this.webSocketHandlers[e]}),this.webSocket.close(),this.webSocket=null}createWebSocketConnection(){return new Promise((e,t)=>{this.webSocket&&(this.messageQueue=[],this.cleanupWebSocket()),this.lastMessageReceived=0,this.identifier+=1;const r=new this.configuration.WebSocketPolyfill(this.url);r.binaryType="arraybuffer",r.identifier=this.identifier,this.attachWebSocketListeners(r,t),this.webSocket=r,this.status=Dn.Connecting,this.emit("status",{status:Dn.Connecting}),this.connectionAttempt={resolve:e,reject:t}})}onMessage(e){var t;this.resolveConnectionAttempt(),this.lastMessageReceived=Ma();const i=new Up(e.data).peekVarString();(t=this.configuration.providerMap.get(i))===null||t===void 0||t.onMessage(e)}resolveConnectionAttempt(){this.connectionAttempt&&(this.connectionAttempt.resolve(),this.connectionAttempt=null,this.status=Dn.Connected,this.emit("status",{status:Dn.Connected}),this.emit("connect"),this.messageQueue.forEach(e=>this.send(e)),this.messageQueue=[])}stopConnectionAttempt(){this.connectionAttempt=null}rejectConnectionAttempt(){var e;(e=this.connectionAttempt)===null||e===void 0||e.reject(),this.connectionAttempt=null}checkConnection(){var e;this.status===Dn.Connected&&this.lastMessageReceived&&(this.configuration.messageReconnectTimeout>=Ma()-this.lastMessageReceived||(this.closeTries+=1,this.closeTries>2?(this.onClose({event:{code:4408,reason:"forced"}}),this.closeTries=0):((e=this.webSocket)===null||e===void 0||e.close(),this.messageQueue=[])))}get serverUrl(){if(this.configuration.preserveTrailingSlash)return this.configuration.url;let e=this.configuration.url;for(;e[e.length-1]==="/";)e=e.slice(0,e.length-1);return e}get url(){return this.serverUrl}disconnect(){if(this.shouldConnect=!1,this.webSocket!==null)try{this.webSocket.close(),this.messageQueue=[]}catch(e){console.error(e)}}send(e){var t;((t=this.webSocket)===null||t===void 0?void 0:t.readyState)===Fp.Open?this.webSocket.send(e):this.messageQueue.push(e)}onClose({event:e}){this.closeTries=0,this.cleanupWebSocket(),this.connectionAttempt&&this.rejectConnectionAttempt(),this.status=Dn.Disconnected,this.emit("status",{status:Dn.Disconnected}),this.emit("disconnect",{event:e}),!this.cancelWebsocketRetry&&this.shouldConnect&&setTimeout(()=>{this.connect()},this.configuration.delay)}destroy(){this.emit("destroy"),clearInterval(this.intervals.connectionChecker),this.stopConnectionAttempt(),this.disconnect(),this.removeAllListeners(),this.cleanupWebSocket()}}const Rk=0,Ag=1,Nk=2,YI=(n,e)=>{kn(n,Rk);const t=CO(e);Ua(n,t)},GI=(n,e,t)=>{kn(n,Ag),Ua(n,xO(e,t))},ZI=(n,e,t)=>GI(e,t,wf(n)),Ik=(n,e,t)=>{try{yO(e,wf(n),t)}catch(r){console.error("Caught error while handling a Yjs update",r)}},XI=(n,e)=>{kn(n,Nk),Ua(n,e)},QI=Ik,$I=(n,e,t,r)=>{const i=ss(n);switch(i){case Rk:ZI(n,e,t);break;case Ag:Ik(n,t,r);break;case Nk:QI(n,t,r);break;default:throw new Error("Unknown message type")}return i};class eP{constructor(e){this.message=e}apply(e,t){const{message:r}=this,i=r.readVarUint(),o=r.length();switch(i){case un.Sync:this.applySyncMessage(e,t);break;case un.Awareness:this.applyAwarenessMessage(e);break;case un.Auth:this.applyAuthMessage(e);break;case un.QueryAwareness:this.applyQueryAwarenessMessage(e);break;case un.Stateless:e.receiveStateless(Xl(r.decoder));break;case un.SyncStatus:this.applySyncStatusMessage(e,PI(r.decoder)===1);break;case un.CLOSE:const s={code:1e3,reason:Xl(r.decoder),target:e.configuration.websocketProvider.webSocket,type:"close"};e.onClose(),e.configuration.onClose({event:s}),e.forwardClose({event:s});break;default:throw new Error(`Can’t apply message of unknown type: ${i}`)}r.length()>o+1&&e.send(Rs,{encoder:r.encoder})}applySyncMessage(e,t){const{message:r}=this;r.writeVarUint(un.Sync);const i=$I(r.decoder,r.encoder,e.document,e);t&&i===Ag&&(e.synced=!0)}applySyncStatusMessage(e,t){t&&e.decrementUnsyncedChanges()}applyAwarenessMessage(e){if(!e.awareness)return;const{message:t}=this;KI(e.awareness,t.readVarUint8Array(),e)}applyAuthMessage(e){const{message:t}=this;mI(t.decoder,e.sendToken.bind(e),e.permissionDeniedHandler.bind(e),e.authenticatedHandler.bind(e))}applyQueryAwarenessMessage(e){if(!e.awareness)return;const{message:t}=this;t.writeVarUint(un.Awareness),t.writeVarUint8Array(Hp(e.awareness,Array.from(e.awareness.getStates().keys())))}}class tP{constructor(e,t={}){this.message=new e,this.encoder=this.message.get(t)}create(){return Tg(this.encoder)}send(e){e==null||e.send(this.create())}}class nP extends Rs{constructor(){super(...arguments),this.type=un.Auth,this.description="Authentication"}get(e){if(typeof e.token>"u")throw new Error("The authentication message requires `token` as an argument.");return ji(this.encoder,e.documentName),kn(this.encoder,this.type),pI(this.encoder,e.token),this.encoder}}class lb extends Rs{constructor(){super(...arguments),this.type=un.Awareness,this.description="Awareness states update"}get(e){if(typeof e.awareness>"u")throw new Error("The awareness message requires awareness as an argument");if(typeof e.clients>"u")throw new Error("The awareness message requires clients as an argument");ji(this.encoder,e.documentName),kn(this.encoder,this.type);let t;return e.states===void 0?t=Hp(e.awareness,e.clients):t=Hp(e.awareness,e.clients,e.states),Ua(this.encoder,t),this.encoder}}class rP extends Rs{constructor(){super(...arguments),this.type=un.Stateless,this.description="A stateless message"}get(e){var t;return ji(this.encoder,e.documentName),kn(this.encoder,this.type),ji(this.encoder,(t=e.payload)!==null&&t!==void 0?t:""),this.encoder}}class cb extends Rs{constructor(){super(...arguments),this.type=un.Sync,this.description="First sync step"}get(e){if(typeof e.document>"u")throw new Error("The sync step one message requires document as an argument");return ji(this.encoder,e.documentName),kn(this.encoder,this.type),YI(this.encoder,e.document),this.encoder}}class iP extends Rs{constructor(){super(...arguments),this.type=un.Sync,this.description="A document update"}get(e){return ji(this.encoder,e.documentName),kn(this.encoder,this.type),XI(this.encoder,e.update),this.encoder}}class oP extends Error{constructor(){super(...arguments),this.code=1001}}class db extends Dk{constructor(e){var t,r,i;super(),this.configuration={name:"",document:void 0,awareness:void 0,token:null,forceSyncInterval:!1,onAuthenticated:()=>null,onAuthenticationFailed:()=>null,onOpen:()=>null,onConnect:()=>null,onMessage:()=>null,onOutgoingMessage:()=>null,onSynced:()=>null,onStatus:()=>null,onDisconnect:()=>null,onClose:()=>null,onDestroy:()=>null,onAwarenessUpdate:()=>null,onAwarenessChange:()=>null,onStateless:()=>null,onUnsyncedChanges:()=>null},this.isSynced=!1,this.unsyncedChanges=0,this.isAuthenticated=!1,this.authorizedScope=void 0,this.manageSocket=!1,this._isAttached=!1,this.intervals={forceSync:null},this.boundDocumentUpdateHandler=this.documentUpdateHandler.bind(this),this.boundAwarenessUpdateHandler=this.awarenessUpdateHandler.bind(this),this.boundPageHide=this.pageHide.bind(this),this.boundOnOpen=this.onOpen.bind(this),this.boundOnClose=this.onClose.bind(this),this.forwardConnect=()=>this.emit("connect"),this.forwardStatus=o=>this.emit("status",o),this.forwardClose=o=>this.emit("close",o),this.forwardDisconnect=o=>this.emit("disconnect",o),this.forwardDestroy=()=>this.emit("destroy"),this.setConfiguration(e),this.configuration.document=e.document?e.document:new ci,this.configuration.awareness=e.awareness!==void 0?e.awareness:new WI(this.document),this.on("open",this.configuration.onOpen),this.on("message",this.configuration.onMessage),this.on("outgoingMessage",this.configuration.onOutgoingMessage),this.on("synced",this.configuration.onSynced),this.on("destroy",this.configuration.onDestroy),this.on("awarenessUpdate",this.configuration.onAwarenessUpdate),this.on("awarenessChange",this.configuration.onAwarenessChange),this.on("stateless",this.configuration.onStateless),this.on("unsyncedChanges",this.configuration.onUnsyncedChanges),this.on("authenticated",this.configuration.onAuthenticated),this.on("authenticationFailed",this.configuration.onAuthenticationFailed),(t=this.awareness)===null||t===void 0||t.on("update",()=>{this.emit("awarenessUpdate",{states:ob(this.awareness.getStates())})}),(r=this.awareness)===null||r===void 0||r.on("change",()=>{this.emit("awarenessChange",{states:ob(this.awareness.getStates())})}),this.document.on("update",this.boundDocumentUpdateHandler),(i=this.awareness)===null||i===void 0||i.on("update",this.boundAwarenessUpdateHandler),this.registerEventListeners(),this.configuration.forceSyncInterval&&typeof this.configuration.forceSyncInterval=="number"&&(this.intervals.forceSync=setInterval(this.forceSync.bind(this),this.configuration.forceSyncInterval)),this.manageSocket&&this.attach()}setConfiguration(e={}){e.websocketProvider||(this.manageSocket=!0,this.configuration.websocketProvider=new JI(e)),this.configuration={...this.configuration,...e}}get document(){return this.configuration.document}get isAttached(){return this._isAttached}get awareness(){return this.configuration.awareness}get hasUnsyncedChanges(){return this.unsyncedChanges>0}resetUnsyncedChanges(){this.unsyncedChanges=1,this.emit("unsyncedChanges",{number:this.unsyncedChanges})}incrementUnsyncedChanges(){this.unsyncedChanges+=1,this.emit("unsyncedChanges",{number:this.unsyncedChanges})}decrementUnsyncedChanges(){this.unsyncedChanges>0&&(this.unsyncedChanges-=1),this.unsyncedChanges===0&&(this.synced=!0),this.emit("unsyncedChanges",{number:this.unsyncedChanges})}forceSync(){this.resetUnsyncedChanges(),this.send(cb,{document:this.document,documentName:this.configuration.name})}pageHide(){this.awareness&&xd(this.awareness,[this.document.clientID],"page hide")}registerEventListeners(){typeof window>"u"||!("addEventListener"in window)||window.addEventListener("pagehide",this.boundPageHide)}sendStateless(e){this.send(rP,{documentName:this.configuration.name,payload:e})}async sendToken(){let e;try{e=await this.getToken()}catch(t){this.permissionDeniedHandler(`Failed to get token during sendToken(): ${t}`);return}this.send(nP,{token:e??"",documentName:this.configuration.name})}documentUpdateHandler(e,t){t!==this&&(this.incrementUnsyncedChanges(),this.send(iP,{update:e,documentName:this.configuration.name}))}awarenessUpdateHandler({added:e,updated:t,removed:r},i){const o=e.concat(t).concat(r);this.send(lb,{awareness:this.awareness,clients:o,documentName:this.configuration.name})}get synced(){return this.isSynced}set synced(e){this.isSynced!==e&&(this.isSynced=e,e&&this.emit("synced",{state:e}))}receiveStateless(e){this.emit("stateless",{payload:e})}async connect(){if(this.manageSocket)return this.configuration.websocketProvider.connect();console.warn("HocuspocusProvider::connect() is deprecated and does not do anything. Please connect/disconnect on the websocketProvider, or attach/deattach providers.")}disconnect(){if(this.manageSocket)return this.configuration.websocketProvider.disconnect();console.warn("HocuspocusProvider::disconnect() is deprecated and does not do anything. Please connect/disconnect on the websocketProvider, or attach/deattach providers.")}async onOpen(e){this.isAuthenticated=!1,this.emit("open",{event:e}),await this.sendToken(),this.startSync()}async getToken(){return typeof this.configuration.token=="function"?await this.configuration.token():this.configuration.token}startSync(){this.resetUnsyncedChanges(),this.send(cb,{document:this.document,documentName:this.configuration.name}),this.awareness&&this.awareness.getLocalState()!==null&&this.send(lb,{awareness:this.awareness,clients:[this.document.clientID],documentName:this.configuration.name})}send(e,t){if(!this._isAttached)return;const r=new tP(e,t);this.emit("outgoingMessage",{message:r.message}),r.send(this.configuration.websocketProvider)}onMessage(e){const t=new Up(e.data),r=t.readVarString();t.writeVarString(r),this.emit("message",{event:e,message:new Up(e.data)}),new eP(t).apply(this,!0)}onClose(){this.isAuthenticated=!1,this.synced=!1,this.awareness&&xd(this.awareness,Array.from(this.awareness.getStates().keys()).filter(e=>e!==this.document.clientID),this)}destroy(){this.emit("destroy"),this.intervals.forceSync&&clearInterval(this.intervals.forceSync),this.awareness&&(xd(this.awareness,[this.document.clientID],"provider destroy"),this.awareness.off("update",this.boundAwarenessUpdateHandler),this.awareness.destroy()),this.document.off("update",this.boundDocumentUpdateHandler),this.removeAllListeners(),this.detach(),this.manageSocket&&this.configuration.websocketProvider.destroy(),!(typeof window>"u"||!("removeEventListener"in window))&&window.removeEventListener("pagehide",this.boundPageHide)}detach(){this.configuration.websocketProvider.off("connect",this.configuration.onConnect),this.configuration.websocketProvider.off("connect",this.forwardConnect),this.configuration.websocketProvider.off("status",this.forwardStatus),this.configuration.websocketProvider.off("status",this.configuration.onStatus),this.configuration.websocketProvider.off("open",this.boundOnOpen),this.configuration.websocketProvider.off("close",this.boundOnClose),this.configuration.websocketProvider.off("close",this.configuration.onClose),this.configuration.websocketProvider.off("close",this.forwardClose),this.configuration.websocketProvider.off("disconnect",this.configuration.onDisconnect),this.configuration.websocketProvider.off("disconnect",this.forwardDisconnect),this.configuration.websocketProvider.off("destroy",this.configuration.onDestroy),this.configuration.websocketProvider.off("destroy",this.forwardDestroy),this.configuration.websocketProvider.detach(this),this._isAttached=!1}attach(){this._isAttached||(this.configuration.websocketProvider.on("connect",this.configuration.onConnect),this.configuration.websocketProvider.on("connect",this.forwardConnect),this.configuration.websocketProvider.on("status",this.configuration.onStatus),this.configuration.websocketProvider.on("status",this.forwardStatus),this.configuration.websocketProvider.on("open",this.boundOnOpen),this.configuration.websocketProvider.on("close",this.boundOnClose),this.configuration.websocketProvider.on("close",this.configuration.onClose),this.configuration.websocketProvider.on("close",this.forwardClose),this.configuration.websocketProvider.on("disconnect",this.configuration.onDisconnect),this.configuration.websocketProvider.on("disconnect",this.forwardDisconnect),this.configuration.websocketProvider.on("destroy",this.configuration.onDestroy),this.configuration.websocketProvider.on("destroy",this.forwardDestroy),this.configuration.websocketProvider.attach(this),this._isAttached=!0)}permissionDeniedHandler(e){this.emit("authenticationFailed",{reason:e}),this.isAuthenticated=!1}authenticatedHandler(e){this.isAuthenticated=!0,this.authorizedScope=e,this.emit("authenticated",{scope:e})}setAwarenessField(e,t){if(!this.awareness)throw new oP(`Cannot set awareness field "${e}" to ${JSON.stringify(t)}. You have disabled Awareness for this provider by explicitly passing awareness: null in the provider configuration.`);this.awareness.setLocalStateField(e,t)}}const hn=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},Oa=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e};let jp=null;const Si=function(n,e,t){let r=jp||(jp=document.createRange());return r.setEnd(n,t??n.nodeValue.length),r.setStart(n,e||0),r},sP=function(){jp=null},xs=function(n,e,t,r){return t&&(ub(n,e,t,r,-1)||ub(n,e,t,r,1))},aP=/^(img|br|input|textarea|hr)$/i;function ub(n,e,t,r,i){for(var o;;){if(n==t&&e==r)return!0;if(e==(i<0?0:gr(n))){let s=n.parentNode;if(!s||s.nodeType!=1||Mc(n)||aP.test(n.nodeName)||n.contentEditable=="false")return!1;e=hn(n)+(i<0?0:1),n=s}else if(n.nodeType==1){let s=n.childNodes[e+(i<0?-1:0)];if(s.nodeType==1&&s.contentEditable=="false")if(!((o=s.pmViewDesc)===null||o===void 0)&&o.ignoreForSelection)e+=i;else return!1;else n=s,e=i<0?gr(n):0}else return!1}}function gr(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function lP(n,e){for(;;){if(n.nodeType==3&&e)return n;if(n.nodeType==1&&e>0){if(n.contentEditable=="false")return null;n=n.childNodes[e-1],e=gr(n)}else if(n.parentNode&&!Mc(n))e=hn(n),n=n.parentNode;else return null}}function cP(n,e){for(;;){if(n.nodeType==3&&e<n.nodeValue.length)return n;if(n.nodeType==1&&e<n.childNodes.length){if(n.contentEditable=="false")return null;n=n.childNodes[e],e=0}else if(n.parentNode&&!Mc(n))e=hn(n)+1,n=n.parentNode;else return null}}function dP(n,e,t){for(let r=e==0,i=e==gr(n);r||i;){if(n==t)return!0;let o=hn(n);if(n=n.parentNode,!n)return!1;r=r&&o==0,i=i&&o==gr(n)}}function Mc(n){let e;for(let t=n;t&&!(e=t.pmViewDesc);t=t.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==n||e.contentDOM==n)}const xf=function(n){return n.focusNode&&xs(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)};function zo(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}function uP(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function fP(n,e,t){if(n.caretPositionFromPoint)try{let r=n.caretPositionFromPoint(e,t);if(r)return{node:r.offsetNode,offset:Math.min(gr(r.offsetNode),r.offset)}}catch{}if(n.caretRangeFromPoint){let r=n.caretRangeFromPoint(e,t);if(r)return{node:r.startContainer,offset:Math.min(gr(r.startContainer),r.startOffset)}}}const di=typeof navigator<"u"?navigator:null,fb=typeof document<"u"?document:null,Oo=di&&di.userAgent||"",Wp=/Edge\/(\d+)/.exec(Oo),Pk=/MSIE \d/.exec(Oo),Kp=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Oo),qn=!!(Pk||Kp||Wp),mo=Pk?document.documentMode:Kp?+Kp[1]:Wp?+Wp[1]:0,xr=!qn&&/gecko\/(\d+)/i.test(Oo);xr&&+(/Firefox\/(\d+)/.exec(Oo)||[0,0])[1];const qp=!qn&&/Chrome\/(\d+)/.exec(Oo),gn=!!qp,Lk=qp?+qp[1]:0,Sn=!qn&&!!di&&/Apple Computer/.test(di.vendor),Da=Sn&&(/Mobile\/\w+/.test(Oo)||!!di&&di.maxTouchPoints>2),fr=Da||(di?/Mac/.test(di.platform):!1),zk=di?/Win/.test(di.platform):!1,Di=/Android \d/.test(Oo),Oc=!!fb&&"webkitFontSmoothing"in fb.documentElement.style,hP=Oc?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function pP(n){let e=n.defaultView&&n.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:n.documentElement.clientWidth,top:0,bottom:n.documentElement.clientHeight}}function yi(n,e){return typeof n=="number"?n:n[e]}function mP(n){let e=n.getBoundingClientRect(),t=e.width/n.offsetWidth||1,r=e.height/n.offsetHeight||1;return{left:e.left,right:e.left+n.clientWidth*t,top:e.top,bottom:e.top+n.clientHeight*r}}function hb(n,e,t){let r=n.someProp("scrollThreshold")||0,i=n.someProp("scrollMargin")||5,o=n.dom.ownerDocument;for(let s=t||n.dom;s;){if(s.nodeType!=1){s=Oa(s);continue}let a=s,l=a==o.body,c=l?pP(o):mP(a),d=0,u=0;if(e.top<c.top+yi(r,"top")?u=-(c.top-e.top+yi(i,"top")):e.bottom>c.bottom-yi(r,"bottom")&&(u=e.bottom-e.top>c.bottom-c.top?e.top+yi(i,"top")-c.top:e.bottom-c.bottom+yi(i,"bottom")),e.left<c.left+yi(r,"left")?d=-(c.left-e.left+yi(i,"left")):e.right>c.right-yi(r,"right")&&(d=e.right-c.right+yi(i,"right")),d||u)if(l)o.defaultView.scrollBy(d,u);else{let p=a.scrollLeft,m=a.scrollTop;u&&(a.scrollTop+=u),d&&(a.scrollLeft+=d);let v=a.scrollLeft-p,g=a.scrollTop-m;e={left:e.left-v,top:e.top-g,right:e.right-v,bottom:e.bottom-g}}let h=l?"fixed":getComputedStyle(s).position;if(/^(fixed|sticky)$/.test(h))break;s=h=="absolute"?s.offsetParent:Oa(s)}}function gP(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),r,i;for(let o=(e.left+e.right)/2,s=t+1;s<Math.min(innerHeight,e.bottom);s+=5){let a=n.root.elementFromPoint(o,s);if(!a||a==n.dom||!n.dom.contains(a))continue;let l=a.getBoundingClientRect();if(l.top>=t-20){r=a,i=l.top;break}}return{refDOM:r,refTop:i,stack:Bk(n.dom)}}function Bk(n){let e=[],t=n.ownerDocument;for(let r=n;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),n!=t);r=Oa(r));return e}function vP({refDOM:n,refTop:e,stack:t}){let r=n?n.getBoundingClientRect().top:0;Fk(t,r==0?0:r-e)}function Fk(n,e){for(let t=0;t<n.length;t++){let{dom:r,top:i,left:o}=n[t];r.scrollTop!=i+e&&(r.scrollTop=i+e),r.scrollLeft!=o&&(r.scrollLeft=o)}}let Ls=null;function yP(n){if(n.setActive)return n.setActive();if(Ls)return n.focus(Ls);let e=Bk(n);n.focus(Ls==null?{get preventScroll(){return Ls={preventScroll:!0},!0}}:void 0),Ls||(Ls=!1,Fk(e,0))}function Vk(n,e){let t,r=2e8,i,o=0,s=e.top,a=e.top,l,c;for(let d=n.firstChild,u=0;d;d=d.nextSibling,u++){let h;if(d.nodeType==1)h=d.getClientRects();else if(d.nodeType==3)h=Si(d).getClientRects();else continue;for(let p=0;p<h.length;p++){let m=h[p];if(m.top<=s&&m.bottom>=a){s=Math.max(m.bottom,s),a=Math.min(m.top,a);let v=m.left>e.left?m.left-e.left:m.right<e.left?e.left-m.right:0;if(v<r){t=d,r=v,i=v&&t.nodeType==3?{left:m.right<e.left?m.right:m.left,top:e.top}:e,d.nodeType==1&&v&&(o=u+(e.left>=(m.left+m.right)/2?1:0));continue}}else m.top>e.top&&!l&&m.left<=e.left&&m.right>=e.left&&(l=d,c={left:Math.max(m.left,Math.min(m.right,e.left)),top:m.top});!t&&(e.left>=m.right&&e.top>=m.top||e.left>=m.left&&e.top>=m.bottom)&&(o=u+1)}}return!t&&l&&(t=l,i=c,r=0),t&&t.nodeType==3?bP(t,i):!t||r&&t.nodeType==1?{node:n,offset:o}:Vk(t,i)}function bP(n,e){let t=n.nodeValue.length,r=document.createRange(),i;for(let o=0;o<t;o++){r.setEnd(n,o+1),r.setStart(n,o);let s=Yi(r,1);if(s.top!=s.bottom&&Eg(e,s)){i={node:n,offset:o+(e.left>=(s.left+s.right)/2?1:0)};break}}return r.detach(),i||{node:n,offset:0}}function Eg(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function wP(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<n.getBoundingClientRect().left?t:n}function xP(n,e,t){let{node:r,offset:i}=Vk(e,t),o=-1;if(r.nodeType==1&&!r.firstChild){let s=r.getBoundingClientRect();o=s.left!=s.right&&t.left>(s.left+s.right)/2?1:-1}return n.docView.posFromDOM(r,i,o)}function kP(n,e,t,r){let i=-1;for(let o=e,s=!1;o!=n.dom;){let a=n.docView.nearestDesc(o,!0),l;if(!a)return null;if(a.dom.nodeType==1&&(a.node.isBlock&&a.parent||!a.contentDOM)&&((l=a.dom.getBoundingClientRect()).width||l.height)&&(a.node.isBlock&&a.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(a.dom.nodeName)&&(!s&&l.left>r.left||l.top>r.top?i=a.posBefore:(!s&&l.right<r.left||l.bottom<r.top)&&(i=a.posAfter),s=!0),!a.contentDOM&&i<0&&!a.node.isText))return(a.node.isBlock?r.top<(l.top+l.bottom)/2:r.left<(l.left+l.right)/2)?a.posBefore:a.posAfter;o=a.dom.parentNode}return i>-1?i:n.docView.posFromDOM(e,t,-1)}function Hk(n,e,t){let r=n.childNodes.length;if(r&&t.top<t.bottom)for(let i=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-t.top)/(t.bottom-t.top))-2)),o=i;;){let s=n.childNodes[o];if(s.nodeType==1){let a=s.getClientRects();for(let l=0;l<a.length;l++){let c=a[l];if(Eg(e,c))return Hk(s,e,c)}}if((o=(o+1)%r)==i)break}return n}function _P(n,e){let t=n.dom.ownerDocument,r,i=0,o=fP(t,e.left,e.top);o&&({node:r,offset:i}=o);let s=(n.root.elementFromPoint?n.root:t).elementFromPoint(e.left,e.top),a;if(!s||!n.dom.contains(s.nodeType!=1?s.parentNode:s)){let c=n.dom.getBoundingClientRect();if(!Eg(e,c)||(s=Hk(n.dom,e,c),!s))return null}if(Sn)for(let c=s;r&&c;c=Oa(c))c.draggable&&(r=void 0);if(s=wP(s,e),r){if(xr&&r.nodeType==1&&(i=Math.min(i,r.childNodes.length),i<r.childNodes.length)){let d=r.childNodes[i],u;d.nodeName=="IMG"&&(u=d.getBoundingClientRect()).right<=e.left&&u.bottom>e.top&&i++}let c;Oc&&i&&r.nodeType==1&&(c=r.childNodes[i-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&i--,r==n.dom&&i==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?a=n.state.doc.content.size:(i==0||r.nodeType!=1||r.childNodes[i-1].nodeName!="BR")&&(a=kP(n,r,i,e))}a==null&&(a=xP(n,s,e));let l=n.docView.nearestDesc(s,!0);return{pos:a,inside:l?l.posAtStart-l.border:-1}}function pb(n){return n.top<n.bottom||n.left<n.right}function Yi(n,e){let t=n.getClientRects();if(t.length){let r=t[e<0?0:t.length-1];if(pb(r))return r}return Array.prototype.find.call(t,pb)||n.getBoundingClientRect()}const SP=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Uk(n,e,t){let{node:r,offset:i,atom:o}=n.docView.domFromPos(e,t<0?-1:1),s=Oc||xr;if(r.nodeType==3)if(s&&(SP.test(r.nodeValue)||(t<0?!i:i==r.nodeValue.length))){let l=Yi(Si(r,i,i),t);if(xr&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let c=Yi(Si(r,i-1,i-1),-1);if(c.top==l.top){let d=Yi(Si(r,i,i+1),-1);if(d.top!=l.top)return Ga(d,d.left<c.left)}}return l}else{let l=i,c=i,d=t<0?1:-1;return t<0&&!i?(c++,d=-1):t>=0&&i==r.nodeValue.length?(l--,d=1):t<0?l--:c++,Ga(Yi(Si(r,l,c),d),d<0)}if(!n.state.doc.resolve(e-(o||0)).parent.inlineContent){if(o==null&&i&&(t<0||i==gr(r))){let l=r.childNodes[i-1];if(l.nodeType==1)return wh(l.getBoundingClientRect(),!1)}if(o==null&&i<gr(r)){let l=r.childNodes[i];if(l.nodeType==1)return wh(l.getBoundingClientRect(),!0)}return wh(r.getBoundingClientRect(),t>=0)}if(o==null&&i&&(t<0||i==gr(r))){let l=r.childNodes[i-1],c=l.nodeType==3?Si(l,gr(l)-(s?0:1)):l.nodeType==1&&(l.nodeName!="BR"||!l.nextSibling)?l:null;if(c)return Ga(Yi(c,1),!1)}if(o==null&&i<gr(r)){let l=r.childNodes[i];for(;l.pmViewDesc&&l.pmViewDesc.ignoreForCoords;)l=l.nextSibling;let c=l?l.nodeType==3?Si(l,0,s?0:1):l.nodeType==1?l:null:null;if(c)return Ga(Yi(c,-1),!0)}return Ga(Yi(r.nodeType==3?Si(r):r,-t),t>=0)}function Ga(n,e){if(n.width==0)return n;let t=e?n.left:n.right;return{top:n.top,bottom:n.bottom,left:t,right:t}}function wh(n,e){if(n.height==0)return n;let t=e?n.top:n.bottom;return{top:t,bottom:t,left:n.left,right:n.right}}function jk(n,e,t){let r=n.state,i=n.root.activeElement;r!=e&&n.updateState(e),i!=n.dom&&n.focus();try{return t()}finally{r!=e&&n.updateState(r),i!=n.dom&&i&&i.focus()}}function CP(n,e,t){let r=e.selection,i=t=="up"?r.$from:r.$to;return jk(n,e,()=>{let{node:o}=n.docView.domFromPos(i.pos,t=="up"?-1:1);for(;;){let a=n.docView.nearestDesc(o,!0);if(!a)break;if(a.node.isBlock){o=a.contentDOM||a.dom;break}o=a.dom.parentNode}let s=Uk(n,i.pos,1);for(let a=o.firstChild;a;a=a.nextSibling){let l;if(a.nodeType==1)l=a.getClientRects();else if(a.nodeType==3)l=Si(a,0,a.nodeValue.length).getClientRects();else continue;for(let c=0;c<l.length;c++){let d=l[c];if(d.bottom>d.top+1&&(t=="up"?s.top-d.top>(d.bottom-s.top)*2:d.bottom-s.bottom>(s.bottom-d.top)*2))return!1}}return!0})}const TP=/[\u0590-\u08ac]/;function AP(n,e,t){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,o=!i,s=i==r.parent.content.size,a=n.domSelection();return a?!TP.test(r.parent.textContent)||!a.modify?t=="left"||t=="backward"?o:s:jk(n,e,()=>{let{focusNode:l,focusOffset:c,anchorNode:d,anchorOffset:u}=n.domSelectionRange(),h=a.caretBidiLevel;a.modify("move",t,"character");let p=r.depth?n.docView.domAfterPos(r.before()):n.dom,{focusNode:m,focusOffset:v}=n.domSelectionRange(),g=m&&!p.contains(m.nodeType==1?m:m.parentNode)||l==m&&c==v;try{a.collapse(d,u),l&&(l!=d||c!=u)&&a.extend&&a.extend(l,c)}catch{}return h!=null&&(a.caretBidiLevel=h),g}):r.pos==r.start()||r.pos==r.end()}let mb=null,gb=null,vb=!1;function EP(n,e,t){return mb==e&&gb==t?vb:(mb=e,gb=t,vb=t=="up"||t=="down"?CP(n,e,t):AP(n,e,t))}const kr=0,yb=1,jo=2,ui=3;class Dc{constructor(e,t,r,i){this.parent=e,this.children=t,this.dom=r,this.contentDOM=i,this.dirty=kr,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,r){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,r=this.posAtStart;;t++){let i=this.children[t];if(i==e)return r;r+=i.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,r){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(r<0){let o,s;if(e==this.contentDOM)o=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;o=e.previousSibling}for(;o&&!((s=o.pmViewDesc)&&s.parent==this);)o=o.previousSibling;return o?this.posBeforeChild(s)+s.size:this.posAtStart}else{let o,s;if(e==this.contentDOM)o=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;o=e.nextSibling}for(;o&&!((s=o.pmViewDesc)&&s.parent==this);)o=o.nextSibling;return o?this.posBeforeChild(s):this.posAtEnd}let i;if(e==this.dom&&this.contentDOM)i=t>hn(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))i=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let o=e;;o=o.parentNode){if(o==this.dom){i=!1;break}if(o.previousSibling)break}if(i==null&&t==e.childNodes.length)for(let o=e;;o=o.parentNode){if(o==this.dom){i=!0;break}if(o.nextSibling)break}}return i??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let r=!0,i=e;i;i=i.parentNode){let o=this.getDesc(i),s;if(o&&(!t||o.node))if(r&&(s=o.nodeDOM)&&!(s.nodeType==1?s.contains(e.nodeType==1?e:e.parentNode):s==e))r=!1;else return o}}getDesc(e){let t=e.pmViewDesc;for(let r=t;r;r=r.parent)if(r==this)return t}posFromDOM(e,t,r){for(let i=e;i;i=i.parentNode){let o=this.getDesc(i);if(o)return o.localPosFromDOM(e,t,r)}return-1}descAt(e){for(let t=0,r=0;t<this.children.length;t++){let i=this.children[t],o=r+i.size;if(r==e&&o!=r){for(;!i.border&&i.children.length;)for(let s=0;s<i.children.length;s++){let a=i.children[s];if(a.size){i=a;break}}return i}if(e<o)return i.descAt(e-r-i.border);r=o}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,i=0;for(let o=0;r<this.children.length;r++){let s=this.children[r],a=o+s.size;if(a>e||s instanceof Kk){i=e-o;break}o=a}if(i)return this.children[r].domFromPos(i-this.children[r].border,t);for(let o;r&&!(o=this.children[r-1]).size&&o instanceof Wk&&o.side>=0;r--);if(t<=0){let o,s=!0;for(;o=r?this.children[r-1]:null,!(!o||o.dom.parentNode==this.contentDOM);r--,s=!1);return o&&t&&s&&!o.border&&!o.domAtom?o.domFromPos(o.size,t):{node:this.contentDOM,offset:o?hn(o.dom)+1:0}}else{let o,s=!0;for(;o=r<this.children.length?this.children[r]:null,!(!o||o.dom.parentNode==this.contentDOM);r++,s=!1);return o&&s&&!o.border&&!o.domAtom?o.domFromPos(0,t):{node:this.contentDOM,offset:o?hn(o.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let i=-1,o=-1;for(let s=r,a=0;;a++){let l=this.children[a],c=s+l.size;if(i==-1&&e<=c){let d=s+l.border;if(e>=d&&t<=c-l.border&&l.node&&l.contentDOM&&this.contentDOM.contains(l.contentDOM))return l.parseRange(e,t,d);e=s;for(let u=a;u>0;u--){let h=this.children[u-1];if(h.size&&h.dom.parentNode==this.contentDOM&&!h.emptyChildAt(1)){i=hn(h.dom)+1;break}e-=h.size}i==-1&&(i=0)}if(i>-1&&(c>t||a==this.children.length-1)){t=c;for(let d=a+1;d<this.children.length;d++){let u=this.children[d];if(u.size&&u.dom.parentNode==this.contentDOM&&!u.emptyChildAt(-1)){o=hn(u.dom);break}t+=u.size}o==-1&&(o=this.contentDOM.childNodes.length);break}s=c}return{node:this.contentDOM,from:e,to:t,fromOffset:i,toOffset:o}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return t.size==0||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:r}=this.domFromPos(e,0);if(t.nodeType!=1||r==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[r]}setSelection(e,t,r,i=!1){let o=Math.min(e,t),s=Math.max(e,t);for(let p=0,m=0;p<this.children.length;p++){let v=this.children[p],g=m+v.size;if(o>m&&s<g)return v.setSelection(e-m-v.border,t-m-v.border,r,i);m=g}let a=this.domFromPos(e,e?-1:1),l=t==e?a:this.domFromPos(t,t?-1:1),c=r.root.getSelection(),d=r.domSelectionRange(),u=!1;if((xr||Sn)&&e==t){let{node:p,offset:m}=a;if(p.nodeType==3){if(u=!!(m&&p.nodeValue[m-1]==`
|
|
93
|
-
`),u&&m==p.nodeValue.length)for(let v=p,g;v;v=v.parentNode){if(g=v.nextSibling){g.nodeName=="BR"&&(a=l={node:g.parentNode,offset:hn(g)+1});break}let y=v.pmViewDesc;if(y&&y.node&&y.node.isBlock)break}}else{let v=p.childNodes[m-1];u=v&&(v.nodeName=="BR"||v.contentEditable=="false")}}if(xr&&d.focusNode&&d.focusNode!=l.node&&d.focusNode.nodeType==1){let p=d.focusNode.childNodes[d.focusOffset];p&&p.contentEditable=="false"&&(i=!0)}if(!(i||u&&Sn)&&xs(a.node,a.offset,d.anchorNode,d.anchorOffset)&&xs(l.node,l.offset,d.focusNode,d.focusOffset))return;let h=!1;if((c.extend||e==t)&&!(u&&xr)){c.collapse(a.node,a.offset);try{e!=t&&c.extend(l.node,l.offset),h=!0}catch{}}if(!h){if(e>t){let m=a;a=l,l=m}let p=document.createRange();p.setEnd(l.node,l.offset),p.setStart(a.node,a.offset),c.removeAllRanges(),c.addRange(p)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let r=0,i=0;i<this.children.length;i++){let o=this.children[i],s=r+o.size;if(r==s?e<=s&&t>=r:e<s&&t>r){let a=r+o.border,l=s-o.border;if(e>=a&&t<=l){this.dirty=e==r||t==s?jo:yb,e==a&&t==l&&(o.contentLost||o.dom.parentNode!=this.contentDOM)?o.dirty=ui:o.markDirty(e-a,t-a);return}else o.dirty=o.dom==o.contentDOM&&o.dom.parentNode==this.contentDOM&&!o.children.length?jo:ui}r=s}this.dirty=jo}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let r=e==1?jo:yb;t.dirty<r&&(t.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class Wk extends Dc{constructor(e,t,r,i){let o,s=t.type.toDOM;if(typeof s=="function"&&(s=s(r,()=>{if(!o)return i;if(o.parent)return o.parent.posBeforeChild(o)})),!t.type.spec.raw){if(s.nodeType!=1){let a=document.createElement("span");a.appendChild(s),s=a}s.contentEditable="false",s.classList.add("ProseMirror-widget")}super(e,[],s,null),this.widget=t,this.widget=t,o=this}matchesWidget(e){return this.dirty==kr&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!="selection"||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 MP extends Dc{constructor(e,t,r,i){super(e,[],t,null),this.textDOM=r,this.text=i}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 e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class ks extends Dc{constructor(e,t,r,i,o){super(e,[],r,i),this.mark=t,this.spec=o}static create(e,t,r,i){let o=i.nodeViews[t.type.name],s=o&&o(t,i,r);return(!s||!s.dom)&&(s=Os.renderSpec(document,t.type.spec.toDOM(t,r),null,t.attrs)),new ks(e,t,s.dom,s.contentDOM||s.dom,s)}parseRule(){return this.dirty&ui||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=ui&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=kr){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=kr}}slice(e,t,r){let i=ks.create(this.parent,this.mark,!0,r),o=this.children,s=this.size;t<s&&(o=Yp(o,t,s,r)),e>0&&(o=Yp(o,0,e,r));for(let a=0;a<o.length;a++)o[a].parent=i;return i.children=o,i}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class go extends Dc{constructor(e,t,r,i,o,s,a,l,c){super(e,[],o,s),this.node=t,this.outerDeco=r,this.innerDeco=i,this.nodeDOM=a}static create(e,t,r,i,o,s){let a=o.nodeViews[t.type.name],l,c=a&&a(t,o,()=>{if(!l)return s;if(l.parent)return l.parent.posBeforeChild(l)},r,i),d=c&&c.dom,u=c&&c.contentDOM;if(t.isText){if(!d)d=document.createTextNode(t.text);else if(d.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else d||({dom:d,contentDOM:u}=Os.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!u&&!t.isText&&d.nodeName!="BR"&&(d.hasAttribute("contenteditable")||(d.contentEditable="false"),t.type.spec.draggable&&(d.draggable=!0));let h=d;return d=Yk(d,r,t),c?l=new OP(e,t,r,i,d,u||null,h,c,o,s+1):t.isText?new kf(e,t,r,i,d,h,o):new go(e,t,r,i,d,u||null,h,o,s+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let t=this.children.length-1;t>=0;t--){let r=this.children[t];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>ie.empty)}return e}matchesNode(e,t,r){return this.dirty==kr&&e.eq(this.node)&&au(t,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let r=this.node.inlineContent,i=t,o=e.composing?this.localCompositionInfo(e,t):null,s=o&&o.pos>-1?o:null,a=o&&o.pos<0,l=new RP(this,s&&s.node,e);PP(this.node,this.innerDeco,(c,d,u)=>{c.spec.marks?l.syncToMarks(c.spec.marks,r,e,d):c.type.side>=0&&!u&&l.syncToMarks(d==this.node.childCount?wt.none:this.node.child(d).marks,r,e,d),l.placeWidget(c,e,i)},(c,d,u,h)=>{l.syncToMarks(c.marks,r,e,h);let p;l.findNodeMatch(c,d,u,h)||a&&e.state.selection.from>i&&e.state.selection.to<i+c.nodeSize&&(p=l.findIndexWithChild(o.node))>-1&&l.updateNodeAt(c,d,u,p,e)||l.updateNextNode(c,d,u,e,h,i)||l.addNode(c,d,u,e,i),i+=c.nodeSize}),l.syncToMarks([],r,e,0),this.node.isTextblock&&l.addTextblockHacks(),l.destroyRest(),(l.changed||this.dirty==jo)&&(s&&this.protectLocalComposition(e,s),qk(this.contentDOM,this.children,e),Da&&LP(this.dom))}localCompositionInfo(e,t){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof Ie)||r<t||i>t+this.node.content.size)return null;let o=e.input.compositionNode;if(!o||!this.dom.contains(o.parentNode))return null;if(this.node.inlineContent){let s=o.nodeValue,a=zP(this.node.content,s,r-t,i-t);return a<0?null:{node:o,pos:a,text:s}}else return{node:o,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:r,text:i}){if(this.getDesc(t))return;let o=t;for(;o.parentNode!=this.contentDOM;o=o.parentNode){for(;o.previousSibling;)o.parentNode.removeChild(o.previousSibling);for(;o.nextSibling;)o.parentNode.removeChild(o.nextSibling);o.pmViewDesc&&(o.pmViewDesc=void 0)}let s=new MP(this,o,t,i);e.input.compositionNodes.push(s),this.children=Yp(this.children,r,r+i.length,e,s)}update(e,t,r,i){return this.dirty==ui||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,r,i),!0)}updateInner(e,t,r,i){this.updateOuterDeco(t),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=kr}updateOuterDeco(e){if(au(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=Jk(this.dom,this.nodeDOM,Jp(this.outerDeco,this.node,t),Jp(e,this.node,t)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function bb(n,e,t,r,i){Yk(r,e,n);let o=new go(void 0,n,e,t,r,r,r,i,0);return o.contentDOM&&o.updateChildren(i,0),o}class kf extends go{constructor(e,t,r,i,o,s,a){super(e,t,r,i,o,null,s,a,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,r,i){return this.dirty==ui||this.dirty!=kr&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=kr||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,i.trackWrites==this.nodeDOM&&(i.trackWrites=null)),this.node=e,this.dirty=kr,!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,r){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,r){let i=this.node.cut(e,t),o=document.createTextNode(i.text);return new kf(this.parent,i,this.outerDeco,this.innerDeco,o,o,r)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=ui)}get domAtom(){return!1}isText(e){return this.node.text==e}}class Kk extends Dc{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==kr&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class OP extends go{constructor(e,t,r,i,o,s,a,l,c,d){super(e,t,r,i,o,s,a,c,d),this.spec=l}update(e,t,r,i){if(this.dirty==ui)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let o=this.spec.update(e,t,r);return o&&this.updateInner(e,t,r,i),o}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,r,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,r,i){this.spec.setSelection?this.spec.setSelection(e,t,r.root):super.setSelection(e,t,r,i)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function qk(n,e,t){let r=n.firstChild,i=!1;for(let o=0;o<e.length;o++){let s=e[o],a=s.dom;if(a.parentNode==n){for(;a!=r;)r=wb(r),i=!0;r=r.nextSibling}else i=!0,n.insertBefore(a,r);if(s instanceof ks){let l=r?r.previousSibling:n.lastChild;qk(s.contentDOM,s.children,t),r=l?l.nextSibling:n.firstChild}}for(;r;)r=wb(r),i=!0;i&&t.trackWrites==n&&(t.trackWrites=null)}const ml=function(n){n&&(this.nodeName=n)};ml.prototype=Object.create(null);const Wo=[new ml];function Jp(n,e,t){if(n.length==0)return Wo;let r=t?Wo[0]:new ml,i=[r];for(let o=0;o<n.length;o++){let s=n[o].type.attrs;if(s){s.nodeName&&i.push(r=new ml(s.nodeName));for(let a in s){let l=s[a];l!=null&&(t&&i.length==1&&i.push(r=new ml(e.isInline?"span":"div")),a=="class"?r.class=(r.class?r.class+" ":"")+l:a=="style"?r.style=(r.style?r.style+";":"")+l:a!="nodeName"&&(r[a]=l))}}}return i}function Jk(n,e,t,r){if(t==Wo&&r==Wo)return e;let i=e;for(let o=0;o<r.length;o++){let s=r[o],a=t[o];if(o){let l;a&&a.nodeName==s.nodeName&&i!=n&&(l=i.parentNode)&&l.nodeName.toLowerCase()==s.nodeName||(l=document.createElement(s.nodeName),l.pmIsDeco=!0,l.appendChild(i),a=Wo[0]),i=l}DP(i,a||Wo[0],s)}return i}function DP(n,e,t){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in t)&&n.removeAttribute(r);for(let r in t)r!="class"&&r!="style"&&r!="nodeName"&&t[r]!=e[r]&&n.setAttribute(r,t[r]);if(e.class!=t.class){let r=e.class?e.class.split(" ").filter(Boolean):[],i=t.class?t.class.split(" ").filter(Boolean):[];for(let o=0;o<r.length;o++)i.indexOf(r[o])==-1&&n.classList.remove(r[o]);for(let o=0;o<i.length;o++)r.indexOf(i[o])==-1&&n.classList.add(i[o]);n.classList.length==0&&n.removeAttribute("class")}if(e.style!=t.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,i;for(;i=r.exec(e.style);)n.style.removeProperty(i[1])}t.style&&(n.style.cssText+=t.style)}}function Yk(n,e,t){return Jk(n,n,Wo,Jp(e,t,n.nodeType!=1))}function au(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++)if(!n[t].type.eq(e[t].type))return!1;return!0}function wb(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}class RP{constructor(e,t,r){this.lock=t,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=NP(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let r=e;r<t;r++)this.top.children[r].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,r,i){let o=0,s=this.stack.length>>1,a=Math.min(s,e.length);for(;o<a&&(o==s-1?this.top:this.stack[o+1<<1]).matchesMark(e[o])&&e[o].type.spec.spanning!==!1;)o++;for(;o<s;)this.destroyRest(),this.top.dirty=kr,this.index=this.stack.pop(),this.top=this.stack.pop(),s--;for(;s<e.length;){this.stack.push(this.top,this.index+1);let l=-1,c=this.top.children.length;i<this.preMatch.index&&(c=Math.min(this.index+3,c));for(let d=this.index;d<c;d++){let u=this.top.children[d];if(u.matchesMark(e[s])&&!this.isLocked(u.dom)){l=d;break}}if(l>-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let d=ks.create(this.top,e[s],t,r);this.top.children.splice(this.index,0,d),this.top=d,this.changed=!0}this.index=0,s++}}findNodeMatch(e,t,r,i){let o=-1,s;if(i>=this.preMatch.index&&(s=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&s.matchesNode(e,t,r))o=this.top.children.indexOf(s,this.index);else for(let a=this.index,l=Math.min(this.top.children.length,a+5);a<l;a++){let c=this.top.children[a];if(c.matchesNode(e,t,r)&&!this.preMatch.matched.has(c)){o=a;break}}return o<0?!1:(this.destroyBetween(this.index,o),this.index++,!0)}updateNodeAt(e,t,r,i,o){let s=this.top.children[i];return s.dirty==ui&&s.dom==s.contentDOM&&(s.dirty=jo),s.update(e,t,r,o)?(this.destroyBetween(this.index,i),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let i=this.index;i<this.top.children.length;i++)if(this.top.children[i]==r)return i}return-1}e=t}}updateNextNode(e,t,r,i,o,s){for(let a=this.index;a<this.top.children.length;a++){let l=this.top.children[a];if(l instanceof go){let c=this.preMatch.matched.get(l);if(c!=null&&c!=o)return!1;let d=l.dom,u,h=this.isLocked(d)&&!(e.isText&&l.node&&l.node.isText&&l.nodeDOM.nodeValue==e.text&&l.dirty!=ui&&au(t,l.outerDeco));if(!h&&l.update(e,t,r,i))return this.destroyBetween(this.index,a),l.dom!=d&&(this.changed=!0),this.index++,!0;if(!h&&(u=this.recreateWrapper(l,e,t,r,i,s)))return this.destroyBetween(this.index,a),this.top.children[this.index]=u,u.contentDOM&&(u.dirty=jo,u.updateChildren(i,s+1),u.dirty=kr),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,r,i,o,s){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!au(r,e.outerDeco)||!i.eq(e.innerDeco))return null;let a=go.create(this.top,t,r,i,o,s);if(a.contentDOM){a.children=e.children,e.children=[];for(let l of a.children)l.parent=a}return e.destroy(),a}addNode(e,t,r,i,o){let s=go.create(this.top,e,t,r,i,o);s.contentDOM&&s.updateChildren(i,o+1),this.top.children.splice(this.index++,0,s),this.changed=!0}placeWidget(e,t,r){let i=this.index<this.top.children.length?this.top.children[this.index]:null;if(i&&i.matchesWidget(e)&&(e==i.widget||!i.widget.type.toDOM.parentNode))this.index++;else{let o=new Wk(this.top,e,t,r);this.top.children.splice(this.index++,0,o),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof ks;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof kf)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((Sn||gn)&&e&&e.dom.contentEditable=="false"&&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 r=document.createElement(e);e=="IMG"&&(r.className="ProseMirror-separator",r.alt=""),e=="BR"&&(r.className="ProseMirror-trailingBreak");let i=new Kk(this.top,[],r,null);t!=this.top?t.children.push(i):t.children.splice(this.index++,0,i),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function NP(n,e){let t=e,r=t.children.length,i=n.childCount,o=new Map,s=[];e:for(;i>0;){let a;for(;;)if(r){let c=t.children[r-1];if(c instanceof ks)t=c,r=c.children.length;else{a=c,r--;break}}else{if(t==e)break e;r=t.parent.children.indexOf(t),t=t.parent}let l=a.node;if(l){if(l!=n.child(i-1))break;--i,o.set(a,i),s.push(a)}}return{index:i,matched:o,matches:s.reverse()}}function IP(n,e){return n.type.side-e.type.side}function PP(n,e,t,r){let i=e.locals(n),o=0;if(i.length==0){for(let c=0;c<n.childCount;c++){let d=n.child(c);r(d,i,e.forChild(o,d),c),o+=d.nodeSize}return}let s=0,a=[],l=null;for(let c=0;;){let d,u;for(;s<i.length&&i[s].to==o;){let g=i[s++];g.widget&&(d?(u||(u=[d])).push(g):d=g)}if(d)if(u){u.sort(IP);for(let g=0;g<u.length;g++)t(u[g],c,!!l)}else t(d,c,!!l);let h,p;if(l)p=-1,h=l,l=null;else if(c<n.childCount)p=c,h=n.child(c++);else break;for(let g=0;g<a.length;g++)a[g].to<=o&&a.splice(g--,1);for(;s<i.length&&i[s].from<=o&&i[s].to>o;)a.push(i[s++]);let m=o+h.nodeSize;if(h.isText){let g=m;s<i.length&&i[s].from<g&&(g=i[s].from);for(let y=0;y<a.length;y++)a[y].to<g&&(g=a[y].to);g<m&&(l=h.cut(g-o),h=h.cut(0,g-o),m=g,p=-1)}else for(;s<i.length&&i[s].to<m;)s++;let v=h.isInline&&!h.isLeaf?a.filter(g=>!g.inline):a.slice();r(h,v,e.forChild(o,h),p),o=m}}function LP(n){if(n.nodeName=="UL"||n.nodeName=="OL"){let e=n.style.cssText;n.style.cssText=e+"; list-style: square !important",window.getComputedStyle(n).listStyle,n.style.cssText=e}}function zP(n,e,t,r){for(let i=0,o=0;i<n.childCount&&o<=r;){let s=n.child(i++),a=o;if(o+=s.nodeSize,!s.isText)continue;let l=s.text;for(;i<n.childCount;){let c=n.child(i++);if(o+=c.nodeSize,!c.isText)break;l+=c.text}if(o>=t){if(o>=r&&l.slice(r-e.length-a,r-a)==e)return r-e.length;let c=a<r?l.lastIndexOf(e,r-a-1):-1;if(c>=0&&c+e.length+a>=t)return a+c;if(t==r&&l.length>=r+e.length-a&&l.slice(r-a,r-a+e.length)==e)return r}}return-1}function Yp(n,e,t,r,i){let o=[];for(let s=0,a=0;s<n.length;s++){let l=n[s],c=a,d=a+=l.size;c>=t||d<=e?o.push(l):(c<e&&o.push(l.slice(0,e-c,r)),i&&(o.push(i),i=void 0),d>t&&o.push(l.slice(t-c,l.size,r)))}return o}function Mg(n,e=null){let t=n.domSelectionRange(),r=n.state.doc;if(!t.focusNode)return null;let i=n.docView.nearestDesc(t.focusNode),o=i&&i.size==0,s=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(s<0)return null;let a=r.resolve(s),l,c;if(xf(t)){for(l=s;i&&!i.node;)i=i.parent;let u=i.node;if(i&&u.isAtom&&Pe.isSelectable(u)&&i.parent&&!(u.isInline&&dP(t.focusNode,t.focusOffset,i.dom))){let h=i.posBefore;c=new Pe(s==h?a:r.resolve(h))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let u=s,h=s;for(let p=0;p<t.rangeCount;p++){let m=t.getRangeAt(p);u=Math.min(u,n.docView.posFromDOM(m.startContainer,m.startOffset,1)),h=Math.max(h,n.docView.posFromDOM(m.endContainer,m.endOffset,-1))}if(u<0)return null;[l,s]=h==n.state.selection.anchor?[h,u]:[u,h],a=r.resolve(s)}else l=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(l<0)return null}let d=r.resolve(l);if(!c){let u=e=="pointer"||n.state.selection.head<a.pos&&!o?1:-1;c=Og(n,d,a,u)}return c}function Gk(n){return n.editable?n.hasFocus():Xk(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function zi(n,e=!1){let t=n.state.selection;if(Zk(n,t),!!Gk(n)){if(!e&&n.input.mouseDown&&n.input.mouseDown.allowDefault&&gn){let r=n.domSelectionRange(),i=n.domObserver.currentSelection;if(r.anchorNode&&i.anchorNode&&xs(r.anchorNode,r.anchorOffset,i.anchorNode,i.anchorOffset)){n.input.mouseDown.delayedSelectionSync=!0,n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)FP(n);else{let{anchor:r,head:i}=t,o,s;xb&&!(t instanceof Ie)&&(t.$from.parent.inlineContent||(o=kb(n,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(s=kb(n,t.to))),n.docView.setSelection(r,i,n,e),xb&&(o&&_b(o),s&&_b(s)),t.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&BP(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}}const xb=Sn||gn&&Lk<63;function kb(n,e){let{node:t,offset:r}=n.docView.domFromPos(e,0),i=r<t.childNodes.length?t.childNodes[r]:null,o=r?t.childNodes[r-1]:null;if(Sn&&i&&i.contentEditable=="false")return xh(i);if((!i||i.contentEditable=="false")&&(!o||o.contentEditable=="false")){if(i)return xh(i);if(o)return xh(o)}}function xh(n){return n.contentEditable="true",Sn&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function _b(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function BP(n){let e=n.dom.ownerDocument;e.removeEventListener("selectionchange",n.input.hideSelectionGuard);let t=n.domSelectionRange(),r=t.anchorNode,i=t.anchorOffset;e.addEventListener("selectionchange",n.input.hideSelectionGuard=()=>{(t.anchorNode!=r||t.anchorOffset!=i)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!Gk(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function FP(n){let e=n.domSelection();if(!e)return;let t=n.cursorWrapper.dom,r=t.nodeName=="IMG";r?e.collapse(t.parentNode,hn(t)+1):e.collapse(t,0),!r&&!n.state.selection.visible&&qn&&mo<=11&&(t.disabled=!0,t.disabled=!1)}function Zk(n,e){if(e instanceof Pe){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(Sb(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else Sb(n)}function Sb(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function Og(n,e,t,r){return n.someProp("createSelectionBetween",i=>i(n,e,t))||Ie.between(e,t,r)}function Cb(n){return n.editable&&!n.hasFocus()?!1:Xk(n)}function Xk(n){let e=n.domSelectionRange();if(!e.anchorNode)return!1;try{return n.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(n.editable||n.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function VP(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return xs(e.node,e.offset,t.anchorNode,t.anchorOffset)}function Gp(n,e){let{$anchor:t,$head:r}=n.selection,i=e>0?t.max(r):t.min(r),o=i.parent.inlineContent?i.depth?n.doc.resolve(e>0?i.after():i.before()):null:i;return o&&Fe.findFrom(o,e)}function Zi(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function Tb(n,e,t){let r=n.state.selection;if(r instanceof Ie)if(t.indexOf("s")>-1){let{$head:i}=r,o=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!o||o.isText||!o.isLeaf)return!1;let s=n.state.doc.resolve(i.pos+o.nodeSize*(e<0?-1:1));return Zi(n,new Ie(r.$anchor,s))}else if(r.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let i=Gp(n.state,e);return i&&i instanceof Pe?Zi(n,i):!1}else if(!(fr&&t.indexOf("m")>-1)){let i=r.$head,o=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,s;if(!o||o.isText)return!1;let a=e<0?i.pos-o.nodeSize:i.pos;return o.isAtom||(s=n.docView.descAt(a))&&!s.contentDOM?Pe.isSelectable(o)?Zi(n,new Pe(e<0?n.state.doc.resolve(i.pos-o.nodeSize):i)):Oc?Zi(n,new Ie(n.state.doc.resolve(e<0?a:a+o.nodeSize))):!1:!1}}else return!1;else{if(r instanceof Pe&&r.node.isInline)return Zi(n,new Ie(e>0?r.$to:r.$from));{let i=Gp(n.state,e);return i?Zi(n,i):!1}}}function lu(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function gl(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function zs(n,e){return e<0?HP(n):UP(n)}function HP(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let i,o,s=!1;for(xr&&t.nodeType==1&&r<lu(t)&&gl(t.childNodes[r],-1)&&(s=!0);;)if(r>0){if(t.nodeType!=1)break;{let a=t.childNodes[r-1];if(gl(a,-1))i=t,o=--r;else if(a.nodeType==3)t=a,r=t.nodeValue.length;else break}}else{if(Qk(t))break;{let a=t.previousSibling;for(;a&&gl(a,-1);)i=t.parentNode,o=hn(a),a=a.previousSibling;if(a)t=a,r=lu(t);else{if(t=t.parentNode,t==n.dom)break;r=0}}}s?Zp(n,t,r):i&&Zp(n,i,o)}function UP(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let i=lu(t),o,s;for(;;)if(r<i){if(t.nodeType!=1)break;let a=t.childNodes[r];if(gl(a,1))o=t,s=++r;else break}else{if(Qk(t))break;{let a=t.nextSibling;for(;a&&gl(a,1);)o=a.parentNode,s=hn(a)+1,a=a.nextSibling;if(a)t=a,r=0,i=lu(t);else{if(t=t.parentNode,t==n.dom)break;r=i=0}}}o&&Zp(n,o,s)}function Qk(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function jP(n,e){for(;n&&e==n.childNodes.length&&!Mc(n);)e=hn(n)+1,n=n.parentNode;for(;n&&e<n.childNodes.length;){let t=n.childNodes[e];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=0}}function WP(n,e){for(;n&&!e&&!Mc(n);)e=hn(n),n=n.parentNode;for(;n&&e;){let t=n.childNodes[e-1];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=n.childNodes.length}}function Zp(n,e,t){if(e.nodeType!=3){let o,s;(s=jP(e,t))?(e=s,t=0):(o=WP(e,t))&&(e=o,t=o.nodeValue.length)}let r=n.domSelection();if(!r)return;if(xf(r)){let o=document.createRange();o.setEnd(e,t),o.setStart(e,t),r.removeAllRanges(),r.addRange(o)}else r.extend&&r.extend(e,t);n.domObserver.setCurSelection();let{state:i}=n;setTimeout(()=>{n.state==i&&zi(n)},50)}function Ab(n,e){let t=n.state.doc.resolve(e);if(!(gn||zk)&&t.parent.inlineContent){let i=n.coordsAtPos(e);if(e>t.start()){let o=n.coordsAtPos(e-1),s=(o.top+o.bottom)/2;if(s>i.top&&s<i.bottom&&Math.abs(o.left-i.left)>1)return o.left<i.left?"ltr":"rtl"}if(e<t.end()){let o=n.coordsAtPos(e+1),s=(o.top+o.bottom)/2;if(s>i.top&&s<i.bottom&&Math.abs(o.left-i.left)>1)return o.left>i.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function Eb(n,e,t){let r=n.state.selection;if(r instanceof Ie&&!r.empty||t.indexOf("s")>-1||fr&&t.indexOf("m")>-1)return!1;let{$from:i,$to:o}=r;if(!i.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let s=Gp(n.state,e);if(s&&s instanceof Pe)return Zi(n,s)}if(!i.parent.inlineContent){let s=e<0?i:o,a=r instanceof Kn?Fe.near(s,e):Fe.findFrom(s,e);return a?Zi(n,a):!1}return!1}function Mb(n,e){if(!(n.state.selection instanceof Ie))return!0;let{$head:t,$anchor:r,empty:i}=n.state.selection;if(!t.sameParent(r))return!0;if(!i)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let o=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(o&&!o.isText){let s=n.state.tr;return e<0?s.delete(t.pos-o.nodeSize,t.pos):s.delete(t.pos,t.pos+o.nodeSize),n.dispatch(s),!0}return!1}function Ob(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function KP(n){if(!Sn||n.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(e&&e.nodeType==1&&t==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;Ob(n,r,"true"),setTimeout(()=>Ob(n,r,"false"),20)}return!1}function qP(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function JP(n,e){let t=e.keyCode,r=qP(e);if(t==8||fr&&t==72&&r=="c")return Mb(n,-1)||zs(n,-1);if(t==46&&!e.shiftKey||fr&&t==68&&r=="c")return Mb(n,1)||zs(n,1);if(t==13||t==27)return!0;if(t==37||fr&&t==66&&r=="c"){let i=t==37?Ab(n,n.state.selection.from)=="ltr"?-1:1:-1;return Tb(n,i,r)||zs(n,i)}else if(t==39||fr&&t==70&&r=="c"){let i=t==39?Ab(n,n.state.selection.from)=="ltr"?1:-1:1;return Tb(n,i,r)||zs(n,i)}else{if(t==38||fr&&t==80&&r=="c")return Eb(n,-1,r)||zs(n,-1);if(t==40||fr&&t==78&&r=="c")return KP(n)||Eb(n,1,r)||zs(n,1);if(r==(fr?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function Dg(n,e){n.someProp("transformCopied",p=>{e=p(e,n)});let t=[],{content:r,openStart:i,openEnd:o}=e;for(;i>1&&o>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,o--;let p=r.firstChild;t.push(p.type.name,p.attrs!=p.type.defaultAttrs?p.attrs:null),r=p.content}let s=n.someProp("clipboardSerializer")||Os.fromSchema(n.state.schema),a=i_(),l=a.createElement("div");l.appendChild(s.serializeFragment(r,{document:a}));let c=l.firstChild,d,u=0;for(;c&&c.nodeType==1&&(d=r_[c.nodeName.toLowerCase()]);){for(let p=d.length-1;p>=0;p--){let m=a.createElement(d[p]);for(;l.firstChild;)m.appendChild(l.firstChild);l.appendChild(m),u++}c=l.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${i} ${o}${u?` -${u}`:""} ${JSON.stringify(t)}`);let h=n.someProp("clipboardTextSerializer",p=>p(e,n))||e.content.textBetween(0,e.content.size,`
|
|
94
|
-
|
|
95
|
-
`);return{dom:l,text:h,slice:e}}function $k(n,e,t,r,i){let o=i.parent.type.spec.code,s,a;if(!t&&!e)return null;let l=!!e&&(r||o||!t);if(l){if(n.someProp("transformPastedText",h=>{e=h(e,o||r,n)}),o)return a=new ye(ie.from(n.state.schema.text(e.replace(/\r\n?/g,`
|
|
96
|
-
`))),0,0),n.someProp("transformPasted",h=>{a=h(a,n,!0)}),a;let u=n.someProp("clipboardTextParser",h=>h(e,i,r,n));if(u)a=u;else{let h=i.marks(),{schema:p}=n.state,m=Os.fromSchema(p);s=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(v=>{let g=s.appendChild(document.createElement("p"));v&&g.appendChild(m.serializeNode(p.text(v,h)))})}}else n.someProp("transformPastedHTML",u=>{t=u(t,n)}),s=XP(t),Oc&&QP(s);let c=s&&s.querySelector("[data-pm-slice]"),d=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(d&&d[3])for(let u=+d[3];u>0;u--){let h=s.firstChild;for(;h&&h.nodeType!=1;)h=h.nextSibling;if(!h)break;s=h}if(a||(a=(n.someProp("clipboardParser")||n.someProp("domParser")||ll.fromSchema(n.state.schema)).parseSlice(s,{preserveWhitespace:!!(l||d),context:i,ruleFromNode(h){return h.nodeName=="BR"&&!h.nextSibling&&h.parentNode&&!YP.test(h.parentNode.nodeName)?{ignore:!0}:null}})),d)a=$P(Db(a,+d[1],+d[2]),d[4]);else if(a=ye.maxOpen(GP(a.content,i),!0),a.openStart||a.openEnd){let u=0,h=0;for(let p=a.content.firstChild;u<a.openStart&&!p.type.spec.isolating;u++,p=p.firstChild);for(let p=a.content.lastChild;h<a.openEnd&&!p.type.spec.isolating;h++,p=p.lastChild);a=Db(a,u,h)}return n.someProp("transformPasted",u=>{a=u(a,n,l)}),a}const YP=/^(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 GP(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let i=e.node(t).contentMatchAt(e.index(t)),o,s=[];if(n.forEach(a=>{if(!s)return;let l=i.findWrapping(a.type),c;if(!l)return s=null;if(c=s.length&&o.length&&t_(l,o,a,s[s.length-1],0))s[s.length-1]=c;else{s.length&&(s[s.length-1]=n_(s[s.length-1],o.length));let d=e_(a,l);s.push(d),i=i.matchType(d.type),o=l}}),s)return ie.from(s)}return n}function e_(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,ie.from(n));return n}function t_(n,e,t,r,i){if(i<n.length&&i<e.length&&n[i]==e[i]){let o=t_(n,e,t,r.lastChild,i+1);if(o)return r.copy(r.content.replaceChild(r.childCount-1,o));if(r.contentMatchAt(r.childCount).matchType(i==n.length-1?t.type:n[i+1]))return r.copy(r.content.append(ie.from(e_(t,n,i+1))))}}function n_(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,n_(n.lastChild,e-1)),r=n.contentMatchAt(n.childCount).fillBefore(ie.empty,!0);return n.copy(t.append(r))}function Xp(n,e,t,r,i,o){let s=e<0?n.firstChild:n.lastChild,a=s.content;return n.childCount>1&&(o=0),i<r-1&&(a=Xp(a,e,t,r,i+1,o)),i>=t&&(a=e<0?s.contentMatchAt(0).fillBefore(a,o<=i).append(a):a.append(s.contentMatchAt(s.childCount).fillBefore(ie.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,s.copy(a))}function Db(n,e,t){return e<n.openStart&&(n=new ye(Xp(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new ye(Xp(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}const r_={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 Rb=null;function i_(){return Rb||(Rb=document.implementation.createHTMLDocument("title"))}let kh=null;function ZP(n){let e=window.trustedTypes;return e?(kh||(kh=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),kh.createHTML(n)):n}function XP(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=i_().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(n),i;if((i=r&&r_[r[1].toLowerCase()])&&(n=i.map(o=>"<"+o+">").join("")+n+i.map(o=>"</"+o+">").reverse().join("")),t.innerHTML=ZP(n),i)for(let o=0;o<i.length;o++)t=t.querySelector(i[o])||t;return t}function QP(n){let e=n.querySelectorAll(gn?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let r=e[t];r.childNodes.length==1&&r.textContent==" "&&r.parentNode&&r.parentNode.replaceChild(n.ownerDocument.createTextNode(" "),r)}}function $P(n,e){if(!n.size)return n;let t=n.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return n}let{content:i,openStart:o,openEnd:s}=n;for(let a=r.length-2;a>=0;a-=2){let l=t.nodes[r[a]];if(!l||l.hasRequiredAttrs())break;i=ie.from(l.create(r[a+1],i)),o++,s++}return new ye(i,o,s)}const zn={},Bn={},eL={touchstart:!0,touchmove:!0};class tL{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function nL(n){for(let e in zn){let t=zn[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=r=>{iL(n,r)&&!Rg(n,r)&&(n.editable||!(r.type in Bn))&&t(n,r)},eL[e]?{passive:!0}:void 0)}Sn&&n.dom.addEventListener("input",()=>null),Qp(n)}function co(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function rL(n){n.domObserver.stop();for(let e in n.input.eventHandlers)n.dom.removeEventListener(e,n.input.eventHandlers[e]);clearTimeout(n.input.composingTimeout),clearTimeout(n.input.lastIOSEnterFallbackTimeout)}function Qp(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=r=>Rg(n,r))})}function Rg(n,e){return n.someProp("handleDOMEvents",t=>{let r=t[e.type];return r?r(n,e)||e.defaultPrevented:!1})}function iL(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target;t!=n.dom;t=t.parentNode)if(!t||t.nodeType==11||t.pmViewDesc&&t.pmViewDesc.stopEvent(e))return!1;return!0}function oL(n,e){!Rg(n,e)&&zn[e.type]&&(n.editable||!(e.type in Bn))&&zn[e.type](n,e)}Bn.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!s_(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(Di&&gn&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),Da&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let r=Date.now();n.input.lastIOSEnter=r,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==r&&(n.someProp("handleKeyDown",i=>i(n,zo(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",r=>r(n,t))||JP(n,t)?t.preventDefault():co(n,"key")};Bn.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)};Bn.keypress=(n,e)=>{let t=e;if(s_(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||fr&&t.metaKey)return;if(n.someProp("handleKeyPress",i=>i(n,t))){t.preventDefault();return}let r=n.state.selection;if(!(r instanceof Ie)||!r.$from.sameParent(r.$to)){let i=String.fromCharCode(t.charCode),o=()=>n.state.tr.insertText(i).scrollIntoView();!/[\r\n]/.test(i)&&!n.someProp("handleTextInput",s=>s(n,r.$from.pos,r.$to.pos,i,o))&&n.dispatch(o()),t.preventDefault()}};function _f(n){return{left:n.clientX,top:n.clientY}}function sL(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function Ng(n,e,t,r,i){if(r==-1)return!1;let o=n.state.doc.resolve(r);for(let s=o.depth+1;s>0;s--)if(n.someProp(e,a=>s>o.depth?a(n,t,o.nodeAfter,o.before(s),i,!0):a(n,t,o.node(s),o.before(s),i,!1)))return!0;return!1}function ra(n,e,t){if(n.focused||n.focus(),n.state.selection.eq(e))return;let r=n.state.tr.setSelection(e);r.setMeta("pointer",!0),n.dispatch(r)}function aL(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&Pe.isSelectable(r)?(ra(n,new Pe(t)),!0):!1}function lL(n,e){if(e==-1)return!1;let t=n.state.selection,r,i;t instanceof Pe&&(r=t.node);let o=n.state.doc.resolve(e);for(let s=o.depth+1;s>0;s--){let a=s>o.depth?o.nodeAfter:o.node(s);if(Pe.isSelectable(a)){r&&t.$from.depth>0&&s>=t.$from.depth&&o.before(t.$from.depth+1)==t.$from.pos?i=o.before(t.$from.depth):i=o.before(s);break}}return i!=null?(ra(n,Pe.create(n.state.doc,i)),!0):!1}function cL(n,e,t,r,i){return Ng(n,"handleClickOn",e,t,r)||n.someProp("handleClick",o=>o(n,e,r))||(i?lL(n,t):aL(n,t))}function dL(n,e,t,r){return Ng(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",i=>i(n,e,r))}function uL(n,e,t,r){return Ng(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",i=>i(n,e,r))||fL(n,t,r)}function fL(n,e,t){if(t.button!=0)return!1;let r=n.state.doc;if(e==-1)return r.inlineContent?(ra(n,Ie.create(r,0,r.content.size)),!0):!1;let i=r.resolve(e);for(let o=i.depth+1;o>0;o--){let s=o>i.depth?i.nodeAfter:i.node(o),a=i.before(o);if(s.inlineContent)ra(n,Ie.create(r,a+1,a+1+s.content.size));else if(Pe.isSelectable(s))ra(n,Pe.create(r,a));else continue;return!0}}function Ig(n){return cu(n)}const o_=fr?"metaKey":"ctrlKey";zn.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let r=Ig(n),i=Date.now(),o="singleClick";i-n.input.lastClick.time<500&&sL(t,n.input.lastClick)&&!t[o_]&&n.input.lastClick.button==t.button&&(n.input.lastClick.type=="singleClick"?o="doubleClick":n.input.lastClick.type=="doubleClick"&&(o="tripleClick")),n.input.lastClick={time:i,x:t.clientX,y:t.clientY,type:o,button:t.button};let s=n.posAtCoords(_f(t));s&&(o=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new hL(n,s,t,!!r)):(o=="doubleClick"?dL:uL)(n,s.pos,s.inside,t)?t.preventDefault():co(n,"pointer"))};class hL{constructor(e,t,r,i){this.view=e,this.pos=t,this.event=r,this.flushed=i,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[o_],this.allowDefault=r.shiftKey;let o,s;if(t.inside>-1)o=e.state.doc.nodeAt(t.inside),s=t.inside;else{let d=e.state.doc.resolve(t.pos);o=d.parent,s=d.depth?d.before():0}const a=i?null:r.target,l=a?e.docView.nearestDesc(a,!0):null;this.target=l&&l.nodeDOM.nodeType==1?l.nodeDOM:null;let{selection:c}=e.state;(r.button==0&&o.type.spec.draggable&&o.type.spec.selectable!==!1||c instanceof Pe&&c.from<=s&&c.to>s)&&(this.mightDrag={node:o,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&xr&&!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)),co(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(()=>zi(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(_f(e))),this.updateAllowDefault(e),this.allowDefault||!t?co(this.view,"pointer"):cL(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Sn&&this.mightDrag&&!this.mightDrag.node.isAtom||gn&&!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)?(ra(this.view,Fe.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):co(this.view,"pointer")}move(e){this.updateAllowDefault(e),co(this.view,"pointer"),e.buttons==0&&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)}}zn.touchstart=n=>{n.input.lastTouch=Date.now(),Ig(n),co(n,"pointer")};zn.touchmove=n=>{n.input.lastTouch=Date.now(),co(n,"pointer")};zn.contextmenu=n=>Ig(n);function s_(n,e){return n.composing?!0:Sn&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const pL=Di?5e3:-1;Bn.compositionstart=Bn.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof Ie&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||gn&&zk&&mL(n)))n.markCursor=n.state.storedMarks||t.marks(),cu(n,!0),n.markCursor=null;else if(cu(n,!e.selection.empty),xr&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let r=n.domSelectionRange();for(let i=r.focusNode,o=r.focusOffset;i&&i.nodeType==1&&o!=0;){let s=o<0?i.lastChild:i.childNodes[o-1];if(!s)break;if(s.nodeType==3){let a=n.domSelection();a&&a.collapse(s,s.nodeValue.length);break}else i=s,o=-1}}n.input.composing=!0}a_(n,pL)};function mL(n){let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(!e||e.nodeType!=1||t>=e.childNodes.length)return!1;let r=e.childNodes[t];return r.nodeType==1&&r.contentEditable=="false"}Bn.compositionend=(n,e)=>{n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=e.timeStamp,n.input.compositionPendingChanges=n.domObserver.pendingRecords().length?n.input.compositionID:0,n.input.compositionNode=null,n.input.badSafariComposition?n.domObserver.forceFlush():n.input.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,a_(n,20))};function a_(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>cu(n),e))}function l_(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=vL());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function gL(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=lP(e.focusNode,e.focusOffset),r=cP(e.focusNode,e.focusOffset);if(t&&r&&t!=r){let i=r.pmViewDesc,o=n.domObserver.lastChangedTextNode;if(t==o||r==o)return o;if(!i||!i.isText(r.nodeValue))return r;if(n.input.compositionNode==r){let s=t.pmViewDesc;if(!(!s||!s.isText(t.nodeValue)))return r}}return t||r}function vL(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function cu(n,e=!1){if(!(Di&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),l_(n),e||n.docView&&n.docView.dirty){let t=Mg(n),r=n.state.selection;return t&&!t.eq(r)?n.dispatch(n.state.tr.setSelection(t)):(n.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?n.dispatch(n.state.tr.deleteSelection()):n.updateState(n.state),!0}return!1}}function yL(n,e){if(!n.dom.parentNode)return;let t=n.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),i=document.createRange();i.selectNodeContents(e),n.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}const Ql=qn&&mo<15||Da&&hP<604;zn.copy=Bn.cut=(n,e)=>{let t=e,r=n.state.selection,i=t.type=="cut";if(r.empty)return;let o=Ql?null:t.clipboardData,s=r.content(),{dom:a,text:l}=Dg(n,s);o?(t.preventDefault(),o.clearData(),o.setData("text/html",a.innerHTML),o.setData("text/plain",l)):yL(n,a),i&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function bL(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function wL(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,r=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let i=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),r.parentNode&&r.parentNode.removeChild(r),t?$l(n,r.value,null,i,e):$l(n,r.textContent,r.innerHTML,i,e)},50)}function $l(n,e,t,r,i){let o=$k(n,e,t,r,n.state.selection.$from);if(n.someProp("handlePaste",l=>l(n,i,o||ye.empty)))return!0;if(!o)return!1;let s=bL(o),a=s?n.state.tr.replaceSelectionWith(s,r):n.state.tr.replaceSelection(o);return n.dispatch(a.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function c_(n){let e=n.getData("text/plain")||n.getData("Text");if(e)return e;let t=n.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}Bn.paste=(n,e)=>{let t=e;if(n.composing&&!Di)return;let r=Ql?null:t.clipboardData,i=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&$l(n,c_(r),r.getData("text/html"),i,t)?t.preventDefault():wL(n,t)};class d_{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}}const xL=fr?"altKey":"ctrlKey";function u_(n,e){let t=n.someProp("dragCopies",r=>!r(e));return t??!e[xL]}zn.dragstart=(n,e)=>{let t=e,r=n.input.mouseDown;if(r&&r.done(),!t.dataTransfer)return;let i=n.state.selection,o=i.empty?null:n.posAtCoords(_f(t)),s;if(!(o&&o.pos>=i.from&&o.pos<=(i instanceof Pe?i.to-1:i.to))){if(r&&r.mightDrag)s=Pe.create(n.state.doc,r.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let u=n.docView.nearestDesc(t.target,!0);u&&u.node.type.spec.draggable&&u!=n.docView&&(s=Pe.create(n.state.doc,u.posBefore))}}let a=(s||n.state.selection).content(),{dom:l,text:c,slice:d}=Dg(n,a);(!t.dataTransfer.files.length||!gn||Lk>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(Ql?"Text":"text/html",l.innerHTML),t.dataTransfer.effectAllowed="copyMove",Ql||t.dataTransfer.setData("text/plain",c),n.dragging=new d_(d,u_(n,t),s)};zn.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)};Bn.dragover=Bn.dragenter=(n,e)=>e.preventDefault();Bn.drop=(n,e)=>{try{kL(n,e,n.dragging)}finally{n.dragging=null}};function kL(n,e,t){if(!e.dataTransfer)return;let r=n.posAtCoords(_f(e));if(!r)return;let i=n.state.doc.resolve(r.pos),o=t&&t.slice;o?n.someProp("transformPasted",p=>{o=p(o,n,!1)}):o=$k(n,c_(e.dataTransfer),Ql?null:e.dataTransfer.getData("text/html"),!1,i);let s=!!(t&&u_(n,e));if(n.someProp("handleDrop",p=>p(n,e,o||ye.empty,s))){e.preventDefault();return}if(!o)return;e.preventDefault();let a=o?Nx(n.state.doc,i.pos,o):i.pos;a==null&&(a=i.pos);let l=n.state.tr;if(s){let{node:p}=t;p?p.replace(l):l.deleteSelection()}let c=l.mapping.map(a),d=o.openStart==0&&o.openEnd==0&&o.content.childCount==1,u=l.doc;if(d?l.replaceRangeWith(c,c,o.content.firstChild):l.replaceRange(c,c,o),l.doc.eq(u))return;let h=l.doc.resolve(c);if(d&&Pe.isSelectable(o.content.firstChild)&&h.nodeAfter&&h.nodeAfter.sameMarkup(o.content.firstChild))l.setSelection(new Pe(h));else{let p=l.mapping.map(a);l.mapping.maps[l.mapping.maps.length-1].forEach((m,v,g,y)=>p=y),l.setSelection(Og(n,h,l.doc.resolve(p)))}n.focus(),n.dispatch(l.setMeta("uiEvent","drop"))}zn.focus=n=>{n.input.lastFocus=Date.now(),n.focused||(n.domObserver.stop(),n.dom.classList.add("ProseMirror-focused"),n.domObserver.start(),n.focused=!0,setTimeout(()=>{n.docView&&n.hasFocus()&&!n.domObserver.currentSelection.eq(n.domSelectionRange())&&zi(n)},20))};zn.blur=(n,e)=>{let t=e;n.focused&&(n.domObserver.stop(),n.dom.classList.remove("ProseMirror-focused"),n.domObserver.start(),t.relatedTarget&&n.dom.contains(t.relatedTarget)&&n.domObserver.currentSelection.clear(),n.focused=!1)};zn.beforeinput=(n,e)=>{if(gn&&Di&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:r}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=r||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",o=>o(n,zo(8,"Backspace")))))return;let{$cursor:i}=n.state.selection;i&&i.pos>0&&n.dispatch(n.state.tr.delete(i.pos-1,i.pos).scrollIntoView())},50)}};for(let n in Bn)zn[n]=Bn[n];function ec(n,e){if(n==e)return!0;for(let t in n)if(n[t]!==e[t])return!1;for(let t in e)if(!(t in n))return!1;return!0}class du{constructor(e,t){this.toDOM=e,this.spec=t||as,this.side=this.spec.side||0}map(e,t,r,i){let{pos:o,deleted:s}=e.mapResult(t.from+i,this.side<0?-1:1);return s?null:new At(o-r,o-r,this)}valid(){return!0}eq(e){return this==e||e instanceof du&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&ec(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class vo{constructor(e,t){this.attrs=e,this.spec=t||as}map(e,t,r,i){let o=e.map(t.from+i,this.spec.inclusiveStart?-1:1)-r,s=e.map(t.to+i,this.spec.inclusiveEnd?1:-1)-r;return o>=s?null:new At(o,s,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof vo&&ec(this.attrs,e.attrs)&&ec(this.spec,e.spec)}static is(e){return e.type instanceof vo}destroy(){}}class Pg{constructor(e,t){this.attrs=e,this.spec=t||as}map(e,t,r,i){let o=e.mapResult(t.from+i,1);if(o.deleted)return null;let s=e.mapResult(t.to+i,-1);return s.deleted||s.pos<=o.pos?null:new At(o.pos-r,s.pos-r,this)}valid(e,t){let{index:r,offset:i}=e.content.findIndex(t.from),o;return i==t.from&&!(o=e.child(r)).isText&&i+o.nodeSize==t.to}eq(e){return this==e||e instanceof Pg&&ec(this.attrs,e.attrs)&&ec(this.spec,e.spec)}destroy(){}}class At{constructor(e,t,r){this.from=e,this.to=t,this.type=r}copy(e,t){return new At(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,r){return this.type.map(e,this,t,r)}static widget(e,t,r){return new At(e,e,new du(t,r))}static inline(e,t,r,i){return new At(e,t,new vo(r,i))}static node(e,t,r,i){return new At(e,t,new Pg(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof vo}get widget(){return this.type instanceof du}}const Hs=[],as={};class Qe{constructor(e,t){this.local=e.length?e:Hs,this.children=t.length?t:Hs}static create(e,t){return t.length?uu(t,e,0,as):wn}find(e,t,r){let i=[];return this.findInner(e??0,t??1e9,i,0,r),i}findInner(e,t,r,i,o){for(let s=0;s<this.local.length;s++){let a=this.local[s];a.from<=t&&a.to>=e&&(!o||o(a.spec))&&r.push(a.copy(a.from+i,a.to+i))}for(let s=0;s<this.children.length;s+=3)if(this.children[s]<t&&this.children[s+1]>e){let a=this.children[s]+1;this.children[s+2].findInner(e-a,t-a,r,i+a,o)}}map(e,t,r){return this==wn||e.maps.length==0?this:this.mapInner(e,t,0,0,r||as)}mapInner(e,t,r,i,o){let s;for(let a=0;a<this.local.length;a++){let l=this.local[a].map(e,r,i);l&&l.type.valid(t,l)?(s||(s=[])).push(l):o.onRemove&&o.onRemove(this.local[a].spec)}return this.children.length?_L(this.children,s||[],e,t,r,i,o):s?new Qe(s.sort(ls),Hs):wn}add(e,t){return t.length?this==wn?Qe.create(e,t):this.addInner(e,t,0):this}addInner(e,t,r){let i,o=0;e.forEach((a,l)=>{let c=l+r,d;if(d=h_(t,a,c)){for(i||(i=this.children.slice());o<i.length&&i[o]<l;)o+=3;i[o]==l?i[o+2]=i[o+2].addInner(a,d,c+1):i.splice(o,0,l,l+a.nodeSize,uu(d,a,c+1,as)),o+=3}});let s=f_(o?p_(t):t,-r);for(let a=0;a<s.length;a++)s[a].type.valid(e,s[a])||s.splice(a--,1);return new Qe(s.length?this.local.concat(s).sort(ls):this.local,i||this.children)}remove(e){return e.length==0||this==wn?this:this.removeInner(e,0)}removeInner(e,t){let r=this.children,i=this.local;for(let o=0;o<r.length;o+=3){let s,a=r[o]+t,l=r[o+1]+t;for(let d=0,u;d<e.length;d++)(u=e[d])&&u.from>a&&u.to<l&&(e[d]=null,(s||(s=[])).push(u));if(!s)continue;r==this.children&&(r=this.children.slice());let c=r[o+2].removeInner(s,a+1);c!=wn?r[o+2]=c:(r.splice(o,3),o-=3)}if(i.length){for(let o=0,s;o<e.length;o++)if(s=e[o])for(let a=0;a<i.length;a++)i[a].eq(s,t)&&(i==this.local&&(i=this.local.slice()),i.splice(a--,1))}return r==this.children&&i==this.local?this:i.length||r.length?new Qe(i,r):wn}forChild(e,t){if(this==wn)return this;if(t.isLeaf)return Qe.empty;let r,i;for(let a=0;a<this.children.length;a+=3)if(this.children[a]>=e){this.children[a]==e&&(r=this.children[a+2]);break}let o=e+1,s=o+t.content.size;for(let a=0;a<this.local.length;a++){let l=this.local[a];if(l.from<s&&l.to>o&&l.type instanceof vo){let c=Math.max(o,l.from)-o,d=Math.min(s,l.to)-o;c<d&&(i||(i=[])).push(l.copy(c,d))}}if(i){let a=new Qe(i.sort(ls),Hs);return r?new eo([a,r]):a}return r||wn}eq(e){if(this==e)return!0;if(!(e instanceof Qe)||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 Lg(this.localsInner(e))}localsInner(e){if(this==wn)return Hs;if(e.inlineContent||!this.local.some(vo.is))return this.local;let t=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof vo||t.push(this.local[r]);return t}forEachSet(e){e(this)}}Qe.empty=new Qe([],[]);Qe.removeOverlap=Lg;const wn=Qe.empty;class eo{constructor(e){this.members=e}map(e,t){const r=this.members.map(i=>i.map(e,t,as));return eo.from(r)}forChild(e,t){if(t.isLeaf)return Qe.empty;let r=[];for(let i=0;i<this.members.length;i++){let o=this.members[i].forChild(e,t);o!=wn&&(o instanceof eo?r=r.concat(o.members):r.push(o))}return eo.from(r)}eq(e){if(!(e instanceof eo)||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,r=!0;for(let i=0;i<this.members.length;i++){let o=this.members[i].localsInner(e);if(o.length)if(!t)t=o;else{r&&(t=t.slice(),r=!1);for(let s=0;s<o.length;s++)t.push(o[s])}}return t?Lg(r?t:t.sort(ls)):Hs}static from(e){switch(e.length){case 0:return wn;case 1:return e[0];default:return new eo(e.every(t=>t instanceof Qe)?e:e.reduce((t,r)=>t.concat(r instanceof Qe?r:r.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function _L(n,e,t,r,i,o,s){let a=n.slice();for(let c=0,d=o;c<t.maps.length;c++){let u=0;t.maps[c].forEach((h,p,m,v)=>{let g=v-m-(p-h);for(let y=0;y<a.length;y+=3){let w=a[y+1];if(w<0||h>w+d-u)continue;let _=a[y]+d-u;p>=_?a[y+1]=h<=_?-2:-1:h>=d&&g&&(a[y]+=g,a[y+1]+=g)}u+=g}),d=t.maps[c].map(d,-1)}let l=!1;for(let c=0;c<a.length;c+=3)if(a[c+1]<0){if(a[c+1]==-2){l=!0,a[c+1]=-1;continue}let d=t.map(n[c]+o),u=d-i;if(u<0||u>=r.content.size){l=!0;continue}let h=t.map(n[c+1]+o,-1),p=h-i,{index:m,offset:v}=r.content.findIndex(u),g=r.maybeChild(m);if(g&&v==u&&v+g.nodeSize==p){let y=a[c+2].mapInner(t,g,d+1,n[c]+o+1,s);y!=wn?(a[c]=u,a[c+1]=p,a[c+2]=y):(a[c+1]=-2,l=!0)}else l=!0}if(l){let c=SL(a,n,e,t,i,o,s),d=uu(c,r,0,s);e=d.local;for(let u=0;u<a.length;u+=3)a[u+1]<0&&(a.splice(u,3),u-=3);for(let u=0,h=0;u<d.children.length;u+=3){let p=d.children[u];for(;h<a.length&&a[h]<p;)h+=3;a.splice(h,0,d.children[u],d.children[u+1],d.children[u+2])}}return new Qe(e.sort(ls),a)}function f_(n,e){if(!e||!n.length)return n;let t=[];for(let r=0;r<n.length;r++){let i=n[r];t.push(new At(i.from+e,i.to+e,i.type))}return t}function SL(n,e,t,r,i,o,s){function a(l,c){for(let d=0;d<l.local.length;d++){let u=l.local[d].map(r,i,c);u?t.push(u):s.onRemove&&s.onRemove(l.local[d].spec)}for(let d=0;d<l.children.length;d+=3)a(l.children[d+2],l.children[d]+c+1)}for(let l=0;l<n.length;l+=3)n[l+1]==-1&&a(n[l+2],e[l]+o+1);return t}function h_(n,e,t){if(e.isLeaf)return null;let r=t+e.nodeSize,i=null;for(let o=0,s;o<n.length;o++)(s=n[o])&&s.from>t&&s.to<r&&((i||(i=[])).push(s),n[o]=null);return i}function p_(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function uu(n,e,t,r){let i=[],o=!1;e.forEach((a,l)=>{let c=h_(n,a,l+t);if(c){o=!0;let d=uu(c,a,t+l+1,r);d!=wn&&i.push(l,l+a.nodeSize,d)}});let s=f_(o?p_(n):n,-t).sort(ls);for(let a=0;a<s.length;a++)s[a].type.valid(e,s[a])||(r.onRemove&&r.onRemove(s[a].spec),s.splice(a--,1));return s.length||i.length?new Qe(s,i):wn}function ls(n,e){return n.from-e.from||n.to-e.to}function Lg(n){let e=n;for(let t=0;t<e.length-1;t++){let r=e[t];if(r.from!=r.to)for(let i=t+1;i<e.length;i++){let o=e[i];if(o.from==r.from){o.to!=r.to&&(e==n&&(e=n.slice()),e[i]=o.copy(o.from,r.to),Nb(e,i+1,o.copy(r.to,o.to)));continue}else{o.from<r.to&&(e==n&&(e=n.slice()),e[t]=r.copy(r.from,o.from),Nb(e,i,r.copy(o.from,r.to)));break}}}return e}function Nb(n,e,t){for(;e<n.length&&ls(t,n[e])>0;)e++;n.splice(e,0,t)}function _h(n){let e=[];return n.someProp("decorations",t=>{let r=t(n.state);r&&r!=wn&&e.push(r)}),n.cursorWrapper&&e.push(Qe.create(n.state.doc,[n.cursorWrapper.deco])),eo.from(e)}const CL={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},TL=qn&&mo<=11;class AL{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 EL{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new AL,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let i=0;i<r.length;i++)this.queue.push(r[i]);qn&&mo<=11&&r.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():Sn&&e.composing&&r.some(i=>i.type=="childList"&&i.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),TL&&(this.onCharData=r=>{this.queue.push({target:r.target,type:"characterData",oldValue:r.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,CL)),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(Cb(this.view)){if(this.suppressingSelectionUpdates)return zi(this.view);if(qn&&mo<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&xs(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,r;for(let o=e.focusNode;o;o=Oa(o))t.add(o);for(let o=e.anchorNode;o;o=Oa(o))if(t.has(o)){r=o;break}let i=r&&this.view.docView.nearestDesc(r);if(i&&i.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!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 r=e.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&Cb(e)&&!this.ignoreSelectionChange(r),o=-1,s=-1,a=!1,l=[];if(e.editable)for(let d=0;d<t.length;d++){let u=this.registerMutation(t[d],l);u&&(o=o<0?u.from:Math.min(u.from,o),s=s<0?u.to:Math.max(u.to,s),u.typeOver&&(a=!0))}if(l.some(d=>d.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46)){for(let d of l)if(d.nodeName=="BR"&&d.parentNode){let u=d.nextSibling;for(;u&&u.nodeType==1;){if(u.contentEditable=="false"){d.parentNode.removeChild(d);break}u=u.firstChild}}}else if(xr&&l.length){let d=l.filter(u=>u.nodeName=="BR");if(d.length==2){let[u,h]=d;u.parentNode&&u.parentNode.parentNode==h.parentNode?h.remove():u.remove()}else{let{focusNode:u}=this.currentSelection;for(let h of d){let p=h.parentNode;p&&p.nodeName=="LI"&&(!u||DL(e,u)!=p)&&h.remove()}}}let c=null;o<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&xf(r)&&(c=Mg(e))&&c.eq(Fe.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,zi(e),this.currentSelection.set(r),e.scrollToSelection()):(o>-1||i)&&(o>-1&&(e.docView.markDirty(o,s),ML(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,RL(e,l)),this.handleDOMChange(o,s,a,l),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||zi(e),this.currentSelection.set(r))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let d=0;d<e.addedNodes.length;d++){let u=e.addedNodes[d];t.push(u),u.nodeType==3&&(this.lastChangedTextNode=u)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let i=e.previousSibling,o=e.nextSibling;if(qn&&mo<=11&&e.addedNodes.length)for(let d=0;d<e.addedNodes.length;d++){let{previousSibling:u,nextSibling:h}=e.addedNodes[d];(!u||Array.prototype.indexOf.call(e.addedNodes,u)<0)&&(i=u),(!h||Array.prototype.indexOf.call(e.addedNodes,h)<0)&&(o=h)}let s=i&&i.parentNode==e.target?hn(i)+1:0,a=r.localPosFromDOM(e.target,s,-1),l=o&&o.parentNode==e.target?hn(o):e.target.childNodes.length,c=r.localPosFromDOM(e.target,l,1);return{from:a,to:c}}else return e.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=e.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let Ib=new WeakMap,Pb=!1;function ML(n){if(!Ib.has(n)&&(Ib.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=xr,Pb)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."),Pb=!0}}function Lb(n,e){let t=e.startContainer,r=e.startOffset,i=e.endContainer,o=e.endOffset,s=n.domAtPos(n.state.selection.anchor);return xs(s.node,s.offset,i,o)&&([t,r,i,o]=[i,o,t,r]),{anchorNode:t,anchorOffset:r,focusNode:i,focusOffset:o}}function OL(n,e){if(e.getComposedRanges){let i=e.getComposedRanges(n.root)[0];if(i)return Lb(n,i)}let t;function r(i){i.preventDefault(),i.stopImmediatePropagation(),t=i.getTargetRanges()[0]}return n.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),n.dom.removeEventListener("beforeinput",r,!0),t?Lb(n,t):null}function DL(n,e){for(let t=e.parentNode;t&&t!=n.dom;t=t.parentNode){let r=n.docView.nearestDesc(t,!0);if(r&&r.node.isBlock)return t}return null}function RL(n,e){var t;let{focusNode:r,focusOffset:i}=n.domSelectionRange();for(let o of e)if(((t=o.parentNode)===null||t===void 0?void 0:t.nodeName)=="TR"){let s=o.nextSibling;for(;s&&s.nodeName!="TD"&&s.nodeName!="TH";)s=s.nextSibling;if(s){let a=s;for(;;){let l=a.firstChild;if(!l||l.nodeType!=1||l.contentEditable=="false"||/^(BR|IMG)$/.test(l.nodeName))break;a=l}a.insertBefore(o,a.firstChild),r==o&&n.domSelection().collapse(o,i)}else o.parentNode.removeChild(o)}}function NL(n,e,t){let{node:r,fromOffset:i,toOffset:o,from:s,to:a}=n.docView.parseRange(e,t),l=n.domSelectionRange(),c,d=l.anchorNode;if(d&&n.dom.contains(d.nodeType==1?d:d.parentNode)&&(c=[{node:d,offset:l.anchorOffset}],xf(l)||c.push({node:l.focusNode,offset:l.focusOffset})),gn&&n.input.lastKeyCode===8)for(let g=o;g>i;g--){let y=r.childNodes[g-1],w=y.pmViewDesc;if(y.nodeName=="BR"&&!w){o=g;break}if(!w||w.size)break}let u=n.state.doc,h=n.someProp("domParser")||ll.fromSchema(n.state.schema),p=u.resolve(s),m=null,v=h.parse(r,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:i,to:o,preserveWhitespace:p.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:IL,context:p});if(c&&c[0].pos!=null){let g=c[0].pos,y=c[1]&&c[1].pos;y==null&&(y=g),m={anchor:g+s,head:y+s}}return{doc:v,sel:m,from:s,to:a}}function IL(n){let e=n.pmViewDesc;if(e)return e.parseRule();if(n.nodeName=="BR"&&n.parentNode){if(Sn&&/^(ul|ol)$/i.test(n.parentNode.nodeName)){let t=document.createElement("div");return t.appendChild(document.createElement("li")),{skip:t}}else if(n.parentNode.lastChild==n||Sn&&/^(tr|table)$/i.test(n.parentNode.nodeName))return{ignore:!0}}else if(n.nodeName=="IMG"&&n.getAttribute("mark-placeholder"))return{ignore:!0};return null}const PL=/^(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 LL(n,e,t,r,i){let o=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let N=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,R=Mg(n,N);if(R&&!n.state.selection.eq(R)){if(gn&&Di&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&n.someProp("handleKeyDown",q=>q(n,zo(13,"Enter"))))return;let E=n.state.tr.setSelection(R);N=="pointer"?E.setMeta("pointer",!0):N=="key"&&E.scrollIntoView(),o&&E.setMeta("composition",o),n.dispatch(E)}return}let s=n.state.doc.resolve(e),a=s.sharedDepth(t);e=s.before(a+1),t=n.state.doc.resolve(t).after(a+1);let l=n.state.selection,c=NL(n,e,t),d=n.state.doc,u=d.slice(c.from,c.to),h,p;n.input.lastKeyCode===8&&Date.now()-100<n.input.lastKeyCodeTime?(h=n.state.selection.to,p="end"):(h=n.state.selection.from,p="start"),n.input.lastKeyCode=null;let m=FL(u.content,c.doc.content,c.from,h,p);if(m&&n.input.domChangeCount++,(Da&&n.input.lastIOSEnter>Date.now()-225||Di)&&i.some(N=>N.nodeType==1&&!PL.test(N.nodeName))&&(!m||m.endA>=m.endB)&&n.someProp("handleKeyDown",N=>N(n,zo(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!m)if(r&&l instanceof Ie&&!l.empty&&l.$head.sameParent(l.$anchor)&&!n.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))m={start:l.from,endA:l.to,endB:l.to};else{if(c.sel){let N=zb(n,n.state.doc,c.sel);if(N&&!N.eq(n.state.selection)){let R=n.state.tr.setSelection(N);o&&R.setMeta("composition",o),n.dispatch(R)}}return}n.state.selection.from<n.state.selection.to&&m.start==m.endB&&n.state.selection instanceof Ie&&(m.start>n.state.selection.from&&m.start<=n.state.selection.from+2&&n.state.selection.from>=c.from?m.start=n.state.selection.from:m.endA<n.state.selection.to&&m.endA>=n.state.selection.to-2&&n.state.selection.to<=c.to&&(m.endB+=n.state.selection.to-m.endA,m.endA=n.state.selection.to)),qn&&mo<=11&&m.endB==m.start+1&&m.endA==m.start&&m.start>c.from&&c.doc.textBetween(m.start-c.from-1,m.start-c.from+1)==" "&&(m.start--,m.endA--,m.endB--);let v=c.doc.resolveNoCache(m.start-c.from),g=c.doc.resolveNoCache(m.endB-c.from),y=d.resolve(m.start),w=v.sameParent(g)&&v.parent.inlineContent&&y.end()>=m.endA;if((Da&&n.input.lastIOSEnter>Date.now()-225&&(!w||i.some(N=>N.nodeName=="DIV"||N.nodeName=="P"))||!w&&v.pos<c.doc.content.size&&(!v.sameParent(g)||!v.parent.inlineContent)&&v.pos<g.pos&&!/\S/.test(c.doc.textBetween(v.pos,g.pos,"","")))&&n.someProp("handleKeyDown",N=>N(n,zo(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>m.start&&BL(d,m.start,m.endA,v,g)&&n.someProp("handleKeyDown",N=>N(n,zo(8,"Backspace")))){Di&&gn&&n.domObserver.suppressSelectionUpdates();return}gn&&m.endB==m.start&&(n.input.lastChromeDelete=Date.now()),Di&&!w&&v.start()!=g.start()&&g.parentOffset==0&&v.depth==g.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==m.endA&&(m.endB-=2,g=c.doc.resolveNoCache(m.endB-c.from),setTimeout(()=>{n.someProp("handleKeyDown",function(N){return N(n,zo(13,"Enter"))})},20));let _=m.start,S=m.endA,A=N=>{let R=N||n.state.tr.replace(_,S,c.doc.slice(m.start-c.from,m.endB-c.from));if(c.sel){let E=zb(n,R.doc,c.sel);E&&!(gn&&n.composing&&E.empty&&(m.start!=m.endB||n.input.lastChromeDelete<Date.now()-100)&&(E.head==_||E.head==R.mapping.map(S)-1)||qn&&E.empty&&E.head==_)&&R.setSelection(E)}return o&&R.setMeta("composition",o),R.scrollIntoView()},U;if(w)if(v.pos==g.pos){qn&&mo<=11&&v.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>zi(n),20));let N=A(n.state.tr.delete(_,S)),R=d.resolve(m.start).marksAcross(d.resolve(m.endA));R&&N.ensureMarks(R),n.dispatch(N)}else if(m.endA==m.endB&&(U=zL(v.parent.content.cut(v.parentOffset,g.parentOffset),y.parent.content.cut(y.parentOffset,m.endA-y.start())))){let N=A(n.state.tr);U.type=="add"?N.addMark(_,S,U.mark):N.removeMark(_,S,U.mark),n.dispatch(N)}else if(v.parent.child(v.index()).isText&&v.index()==g.index()-(g.textOffset?0:1)){let N=v.parent.textBetween(v.parentOffset,g.parentOffset),R=()=>A(n.state.tr.insertText(N,_,S));n.someProp("handleTextInput",E=>E(n,_,S,N,R))||n.dispatch(R())}else n.dispatch(A());else n.dispatch(A())}function zb(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:Og(n,e.resolve(t.anchor),e.resolve(t.head))}function zL(n,e){let t=n.firstChild.marks,r=e.firstChild.marks,i=t,o=r,s,a,l;for(let d=0;d<r.length;d++)i=r[d].removeFromSet(i);for(let d=0;d<t.length;d++)o=t[d].removeFromSet(o);if(i.length==1&&o.length==0)a=i[0],s="add",l=d=>d.mark(a.addToSet(d.marks));else if(i.length==0&&o.length==1)a=o[0],s="remove",l=d=>d.mark(a.removeFromSet(d.marks));else return null;let c=[];for(let d=0;d<e.childCount;d++)c.push(l(e.child(d)));if(ie.from(c).eq(n))return{mark:a,type:s}}function BL(n,e,t,r,i){if(t-e<=i.pos-r.pos||Sh(r,!0,!1)<i.pos)return!1;let o=n.resolve(e);if(!r.parent.isTextblock){let a=o.nodeAfter;return a!=null&&t==e+a.nodeSize}if(o.parentOffset<o.parent.content.size||!o.parent.isTextblock)return!1;let s=n.resolve(Sh(o,!0,!0));return!s.parent.isTextblock||s.pos>t||Sh(s,!0,!1)<t?!1:r.parent.content.cut(r.parentOffset).eq(s.parent.content)}function Sh(n,e,t){let r=n.depth,i=e?n.end():n.pos;for(;r>0&&(e||n.indexAfter(r)==n.node(r).childCount);)r--,i++,e=!1;if(t){let o=n.node(r).maybeChild(n.indexAfter(r));for(;o&&!o.isLeaf;)o=o.firstChild,i++}return i}function FL(n,e,t,r,i){let o=n.findDiffStart(e,t);if(o==null)return null;let{a:s,b:a}=n.findDiffEnd(e,t+n.size,t+e.size);if(i=="end"){let l=Math.max(0,o-Math.min(s,a));r-=s+l-o}if(s<o&&n.size<e.size){let l=r<=o&&r>=s?o-r:0;o-=l,o&&o<e.size&&Bb(e.textBetween(o-1,o+1))&&(o+=l?1:-1),a=o+(a-s),s=o}else if(a<o){let l=r<=o&&r>=a?o-r:0;o-=l,o&&o<n.size&&Bb(n.textBetween(o-1,o+1))&&(o+=l?1:-1),s=o+(s-a),a=o}return{start:o,endA:s,endB:a}}function Bb(n){if(n.length!=2)return!1;let e=n.charCodeAt(0),t=n.charCodeAt(1);return e>=56320&&e<=57343&&t>=55296&&t<=56319}class m_{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 tL,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(jb),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):typeof e=="function"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=Hb(this),Vb(this),this.nodeViews=Ub(this),this.docView=bb(this.state.doc,Fb(this),_h(this),this.dom,this),this.domObserver=new EL(this,(r,i,o,s)=>LL(this,r,i,o,s)),this.domObserver.start(),nL(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&&Qp(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(jb),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let r in this._props)t[r]=this._props[r];t.state=this.state;for(let r in e)t[r]=e[r];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var r;let i=this.state,o=!1,s=!1;e.storedMarks&&this.composing&&(l_(this),s=!0),this.state=e;let a=i.plugins!=e.plugins||this._props.plugins!=t.plugins;if(a||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let p=Ub(this);HL(p,this.nodeViews)&&(this.nodeViews=p,o=!0)}(a||t.handleDOMEvents!=this._props.handleDOMEvents)&&Qp(this),this.editable=Hb(this),Vb(this);let l=_h(this),c=Fb(this),d=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",u=o||!this.docView.matchesNode(e.doc,c,l);(u||!e.selection.eq(i.selection))&&(s=!0);let h=d=="preserve"&&s&&this.dom.style.overflowAnchor==null&&gP(this);if(s){this.domObserver.stop();let p=u&&(qn||gn)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&VL(i.selection,e.selection);if(u){let m=gn?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=gL(this)),(o||!this.docView.update(e.doc,c,l,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=bb(e.doc,c,l,this.dom,this)),m&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(p=!0)}p||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&VP(this))?zi(this,p):(Zk(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(i),!((r=this.dragging)===null||r===void 0)&&r.node&&!i.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,i),d=="reset"?this.dom.scrollTop=0:d=="to selection"?this.scrollToSelection():h&&vP(h)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof Pe){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&hb(this,t.getBoundingClientRect(),e)}else hb(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let t=0;t<this.directPlugins.length;t++){let r=this.directPlugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let r=this.state.plugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let r=this.pluginViews[t];r.update&&r.update(this,e)}}updateDraggedNode(e,t){let r=e.node,i=-1;if(r.from<this.state.doc.content.size&&this.state.doc.nodeAt(r.from)==r.node)i=r.from;else{let o=r.from+(this.state.doc.content.size-t.doc.content.size);(o>0&&o<this.state.doc.content.size&&this.state.doc.nodeAt(o))==r.node&&(i=o)}this.dragging=new d_(e.slice,e.move,i<0?void 0:Pe.create(this.state.doc,i))}someProp(e,t){let r=this._props&&this._props[e],i;if(r!=null&&(i=t?t(r):r))return i;for(let s=0;s<this.directPlugins.length;s++){let a=this.directPlugins[s].props[e];if(a!=null&&(i=t?t(a):a))return i}let o=this.state.plugins;if(o)for(let s=0;s<o.length;s++){let a=o[s].props[e];if(a!=null&&(i=t?t(a):a))return i}}hasFocus(){if(qn){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(e.contentEditable=="false")return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&yP(this.dom),zi(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let t=this.dom.parentNode;t;t=t.parentNode)if(t.nodeType==9||t.nodeType==11&&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 _P(this,e)}coordsAtPos(e,t=1){return Uk(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,r=-1){let i=this.docView.posFromDOM(e,t,r);if(i==null)throw new RangeError("DOM position not inside the editor");return i}endOfTextblock(e,t){return EP(this,t||this.state,e)}pasteHTML(e,t){return $l(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return $l(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return Dg(this,e)}destroy(){this.docView&&(rL(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],_h(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,sP())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return oL(this,e)}domSelectionRange(){let e=this.domSelection();return e?Sn&&this.root.nodeType===11&&uP(this.dom.ownerDocument)==this.dom&&OL(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}m_.prototype.dispatch=function(n){let e=this._props.dispatchTransaction;e?e.call(this,n):this.updateState(this.state.apply(n))};function Fb(n){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(n.editable),n.someProp("attributes",t=>{if(typeof t=="function"&&(t=t(n.state)),t)for(let r in t)r=="class"?e.class+=" "+t[r]:r=="style"?e.style=(e.style?e.style+";":"")+t[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(t[r]))}),e.translate||(e.translate="no"),[At.node(0,n.state.doc.content.size,e)]}function Vb(n){if(n.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),n.cursorWrapper={dom:e,deco:At.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function Hb(n){return!n.someProp("editable",e=>e(n.state)===!1)}function VL(n,e){let t=Math.min(n.$anchor.sharedDepth(n.head),e.$anchor.sharedDepth(e.head));return n.$anchor.start(t)!=e.$anchor.start(t)}function Ub(n){let e=Object.create(null);function t(r){for(let i in r)Object.prototype.hasOwnProperty.call(e,i)||(e[i]=r[i])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function HL(n,e){let t=0,r=0;for(let i in n){if(n[i]!=e[i])return!0;t++}for(let i in e)r++;return t!=r}function jb(n){if(n.spec.state||n.spec.filterTransaction||n.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var Ao={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:"'"},fu={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},UL=typeof navigator<"u"&&/Mac/.test(navigator.platform),jL=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var pn=0;pn<10;pn++)Ao[48+pn]=Ao[96+pn]=String(pn);for(var pn=1;pn<=24;pn++)Ao[pn+111]="F"+pn;for(var pn=65;pn<=90;pn++)Ao[pn]=String.fromCharCode(pn+32),fu[pn]=String.fromCharCode(pn);for(var Ch in Ao)fu.hasOwnProperty(Ch)||(fu[Ch]=Ao[Ch]);function WL(n){var e=UL&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||jL&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?fu:Ao)[n.keyCode]||n.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}const KL=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),qL=typeof navigator<"u"&&/Win/.test(navigator.platform);function JL(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let r,i,o,s;for(let a=0;a<e.length-1;a++){let l=e[a];if(/^(cmd|meta|m)$/i.test(l))s=!0;else if(/^a(lt)?$/i.test(l))r=!0;else if(/^(c|ctrl|control)$/i.test(l))i=!0;else if(/^s(hift)?$/i.test(l))o=!0;else if(/^mod$/i.test(l))KL?s=!0:i=!0;else throw new Error("Unrecognized modifier name: "+l)}return r&&(t="Alt-"+t),i&&(t="Ctrl-"+t),s&&(t="Meta-"+t),o&&(t="Shift-"+t),t}function YL(n){let e=Object.create(null);for(let t in n)e[JL(t)]=n[t];return e}function Th(n,e,t=!0){return e.altKey&&(n="Alt-"+n),e.ctrlKey&&(n="Ctrl-"+n),e.metaKey&&(n="Meta-"+n),t&&e.shiftKey&&(n="Shift-"+n),n}function GL(n){return new pt({props:{handleKeyDown:zg(n)}})}function zg(n){let e=YL(n);return function(t,r){let i=WL(r),o,s=e[Th(i,r)];if(s&&s(t.state,t.dispatch,t))return!0;if(i.length==1&&i!=" "){if(r.shiftKey){let a=e[Th(i,r,!1)];if(a&&a(t.state,t.dispatch,t))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(qL&&r.ctrlKey&&r.altKey)&&(o=Ao[r.keyCode])&&o!=i){let a=e[Th(o,r)];if(a&&a(t.state,t.dispatch,t))return!0}}return!1}}const Bg=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function g_(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}const v_=(n,e,t)=>{let r=g_(n,t);if(!r)return!1;let i=Fg(r);if(!i){let s=r.blockRange(),a=s&&Ia(s);return a==null?!1:(e&&e(n.tr.lift(s,a).scrollIntoView()),!0)}let o=i.nodeBefore;if(T_(n,i,e,-1))return!0;if(r.parent.content.size==0&&(Ra(o,"end")||Pe.isSelectable(o)))for(let s=r.depth;;s--){let a=rf(n.doc,r.before(s),r.after(s),ye.empty);if(a&&a.slice.size<a.to-a.from){if(e){let l=n.tr.step(a);l.setSelection(Ra(o,"end")?Fe.findFrom(l.doc.resolve(l.mapping.map(i.pos,-1)),-1):Pe.create(l.doc,i.pos-o.nodeSize)),e(l.scrollIntoView())}return!0}if(s==1||r.node(s-1).childCount>1)break}return o.isAtom&&i.depth==r.depth-1?(e&&e(n.tr.delete(i.pos-o.nodeSize,i.pos).scrollIntoView()),!0):!1},ZL=(n,e,t)=>{let r=g_(n,t);if(!r)return!1;let i=Fg(r);return i?y_(n,i,e):!1},XL=(n,e,t)=>{let r=w_(n,t);if(!r)return!1;let i=Vg(r);return i?y_(n,i,e):!1};function y_(n,e,t){let r=e.nodeBefore,i=r,o=e.pos-1;for(;!i.isTextblock;o--){if(i.type.spec.isolating)return!1;let d=i.lastChild;if(!d)return!1;i=d}let s=e.nodeAfter,a=s,l=e.pos+1;for(;!a.isTextblock;l++){if(a.type.spec.isolating)return!1;let d=a.firstChild;if(!d)return!1;a=d}let c=rf(n.doc,o,l,ye.empty);if(!c||c.from!=o||c instanceof nn&&c.slice.size>=l-o)return!1;if(t){let d=n.tr.step(c);d.setSelection(Ie.create(d.doc,o)),t(d.scrollIntoView())}return!0}function Ra(n,e,t=!1){for(let r=n;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(t&&r.childCount!=1)return!1}return!1}const b_=(n,e,t)=>{let{$head:r,empty:i}=n.selection,o=r;if(!i)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):r.parentOffset>0)return!1;o=Fg(r)}let s=o&&o.nodeBefore;return!s||!Pe.isSelectable(s)?!1:(e&&e(n.tr.setSelection(Pe.create(n.doc,o.pos-s.nodeSize)).scrollIntoView()),!0)};function Fg(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){if(n.index(e)>0)return n.doc.resolve(n.before(e+1));if(n.node(e).type.spec.isolating)break}return null}function w_(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset<t.parent.content.size)?null:t}const x_=(n,e,t)=>{let r=w_(n,t);if(!r)return!1;let i=Vg(r);if(!i)return!1;let o=i.nodeAfter;if(T_(n,i,e,1))return!0;if(r.parent.content.size==0&&(Ra(o,"start")||Pe.isSelectable(o))){let s=rf(n.doc,r.before(),r.after(),ye.empty);if(s&&s.slice.size<s.to-s.from){if(e){let a=n.tr.step(s);a.setSelection(Ra(o,"start")?Fe.findFrom(a.doc.resolve(a.mapping.map(i.pos)),1):Pe.create(a.doc,a.mapping.map(i.pos))),e(a.scrollIntoView())}return!0}}return o.isAtom&&i.depth==r.depth-1?(e&&e(n.tr.delete(i.pos,i.pos+o.nodeSize).scrollIntoView()),!0):!1},k_=(n,e,t)=>{let{$head:r,empty:i}=n.selection,o=r;if(!i)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("forward",n):r.parentOffset<r.parent.content.size)return!1;o=Vg(r)}let s=o&&o.nodeAfter;return!s||!Pe.isSelectable(s)?!1:(e&&e(n.tr.setSelection(Pe.create(n.doc,o.pos)).scrollIntoView()),!0)};function Vg(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){let t=n.node(e);if(n.index(e)+1<t.childCount)return n.doc.resolve(n.after(e+1));if(t.type.spec.isolating)break}return null}const QL=(n,e)=>{let t=n.selection,r=t instanceof Pe,i;if(r){if(t.node.isTextblock||!Mo(n.doc,t.from))return!1;i=t.from}else if(i=nf(n.doc,t.from,-1),i==null)return!1;if(e){let o=n.tr.join(i);r&&o.setSelection(Pe.create(o.doc,i-n.doc.resolve(i).nodeBefore.nodeSize)),e(o.scrollIntoView())}return!0},$L=(n,e)=>{let t=n.selection,r;if(t instanceof Pe){if(t.node.isTextblock||!Mo(n.doc,t.to))return!1;r=t.to}else if(r=nf(n.doc,t.to,1),r==null)return!1;return e&&e(n.tr.join(r).scrollIntoView()),!0},ez=(n,e)=>{let{$from:t,$to:r}=n.selection,i=t.blockRange(r),o=i&&Ia(i);return o==null?!1:(e&&e(n.tr.lift(i,o).scrollIntoView()),!0)},__=(n,e)=>{let{$head:t,$anchor:r}=n.selection;return!t.parent.type.spec.code||!t.sameParent(r)?!1:(e&&e(n.tr.insertText(`
|
|
97
|
-
`).scrollIntoView()),!0)};function Hg(n){for(let e=0;e<n.edgeCount;e++){let{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}const tz=(n,e)=>{let{$head:t,$anchor:r}=n.selection;if(!t.parent.type.spec.code||!t.sameParent(r))return!1;let i=t.node(-1),o=t.indexAfter(-1),s=Hg(i.contentMatchAt(o));if(!s||!i.canReplaceWith(o,o,s))return!1;if(e){let a=t.after(),l=n.tr.replaceWith(a,a,s.createAndFill());l.setSelection(Fe.near(l.doc.resolve(a),1)),e(l.scrollIntoView())}return!0},S_=(n,e)=>{let t=n.selection,{$from:r,$to:i}=t;if(t instanceof Kn||r.parent.inlineContent||i.parent.inlineContent)return!1;let o=Hg(i.parent.contentMatchAt(i.indexAfter()));if(!o||!o.isTextblock)return!1;if(e){let s=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,a=n.tr.insert(s,o.createAndFill());a.setSelection(Ie.create(a.doc,s+1)),e(a.scrollIntoView())}return!0},C_=(n,e)=>{let{$cursor:t}=n.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let o=t.before();if(Ii(n.doc,o))return e&&e(n.tr.split(o).scrollIntoView()),!0}let r=t.blockRange(),i=r&&Ia(r);return i==null?!1:(e&&e(n.tr.lift(r,i).scrollIntoView()),!0)};function nz(n){return(e,t)=>{let{$from:r,$to:i}=e.selection;if(e.selection instanceof Pe&&e.selection.node.isBlock)return!r.parentOffset||!Ii(e.doc,r.pos)?!1:(t&&t(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let o=[],s,a,l=!1,c=!1;for(let p=r.depth;;p--)if(r.node(p).isBlock){l=r.end(p)==r.pos+(r.depth-p),c=r.start(p)==r.pos-(r.depth-p),a=Hg(r.node(p-1).contentMatchAt(r.indexAfter(p-1))),o.unshift(l&&a?{type:a}:null),s=p;break}else{if(p==1)return!1;o.unshift(null)}let d=e.tr;(e.selection instanceof Ie||e.selection instanceof Kn)&&d.deleteSelection();let u=d.mapping.map(r.pos),h=Ii(d.doc,u,o.length,o);if(h||(o[0]=a?{type:a}:null,h=Ii(d.doc,u,o.length,o)),!h)return!1;if(d.split(u,o.length,o),!l&&c&&r.node(s).type!=a){let p=d.mapping.map(r.before(s)),m=d.doc.resolve(p);a&&r.node(s-1).canReplaceWith(m.index(),m.index()+1,a)&&d.setNodeMarkup(d.mapping.map(r.before(s)),a)}return t&&t(d.scrollIntoView()),!0}}const rz=nz(),iz=(n,e)=>{let{$from:t,to:r}=n.selection,i,o=t.sharedDepth(r);return o==0?!1:(i=t.before(o),e&&e(n.tr.setSelection(Pe.create(n.doc,i))),!0)};function oz(n,e,t){let r=e.nodeBefore,i=e.nodeAfter,o=e.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&e.parent.canReplace(o-1,o)?(t&&t(n.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(o,o+1)||!(i.isTextblock||Mo(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function T_(n,e,t,r){let i=e.nodeBefore,o=e.nodeAfter,s,a,l=i.type.spec.isolating||o.type.spec.isolating;if(!l&&oz(n,e,t))return!0;let c=!l&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(s=(a=i.contentMatchAt(i.childCount)).findWrapping(o.type))&&a.matchType(s[0]||o.type).validEnd){if(t){let p=e.pos+o.nodeSize,m=ie.empty;for(let y=s.length-1;y>=0;y--)m=ie.from(s[y].create(null,m));m=ie.from(i.copy(m));let v=n.tr.step(new rn(e.pos-1,p,e.pos,p,new ye(m,1,0),s.length,!0)),g=v.doc.resolve(p+2*s.length);g.nodeAfter&&g.nodeAfter.type==i.type&&Mo(v.doc,g.pos)&&v.join(g.pos),t(v.scrollIntoView())}return!0}let d=o.type.spec.isolating||r>0&&l?null:Fe.findFrom(e,1),u=d&&d.$from.blockRange(d.$to),h=u&&Ia(u);if(h!=null&&h>=e.depth)return t&&t(n.tr.lift(u,h).scrollIntoView()),!0;if(c&&Ra(o,"start",!0)&&Ra(i,"end")){let p=i,m=[];for(;m.push(p),!p.isTextblock;)p=p.lastChild;let v=o,g=1;for(;!v.isTextblock;v=v.firstChild)g++;if(p.canReplace(p.childCount,p.childCount,v.content)){if(t){let y=ie.empty;for(let _=m.length-1;_>=0;_--)y=ie.from(m[_].copy(y));let w=n.tr.step(new rn(e.pos-m.length,e.pos+o.nodeSize,e.pos+g,e.pos+o.nodeSize-g,new ye(y,m.length,0),0,!0));t(w.scrollIntoView())}return!0}}return!1}function A_(n){return function(e,t){let r=e.selection,i=n<0?r.$from:r.$to,o=i.depth;for(;i.node(o).isInline;){if(!o)return!1;o--}return i.node(o).isTextblock?(t&&t(e.tr.setSelection(Ie.create(e.doc,n<0?i.start(o):i.end(o)))),!0):!1}}const sz=A_(-1),az=A_(1);function lz(n,e=null){return function(t,r){let{$from:i,$to:o}=t.selection,s=i.blockRange(o),a=s&&Km(s,n,e);return a?(r&&r(t.tr.wrap(s,a).scrollIntoView()),!0):!1}}function Wb(n,e=null){return function(t,r){let i=!1;for(let o=0;o<t.selection.ranges.length&&!i;o++){let{$from:{pos:s},$to:{pos:a}}=t.selection.ranges[o];t.doc.nodesBetween(s,a,(l,c)=>{if(i)return!1;if(!(!l.isTextblock||l.hasMarkup(n,e)))if(l.type==n)i=!0;else{let d=t.doc.resolve(c),u=d.index();i=d.parent.canReplaceWith(u,u+1,n)}})}if(!i)return!1;if(r){let o=t.tr;for(let s=0;s<t.selection.ranges.length;s++){let{$from:{pos:a},$to:{pos:l}}=t.selection.ranges[s];o.setBlockType(a,l,n,e)}r(o.scrollIntoView())}return!0}}function Ug(...n){return function(e,t,r){for(let i=0;i<n.length;i++)if(n[i](e,t,r))return!0;return!1}}Ug(Bg,v_,b_);Ug(Bg,x_,k_);Ug(__,S_,C_,rz);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function cz(n,e=null){return function(t,r){let{$from:i,$to:o}=t.selection,s=i.blockRange(o);if(!s)return!1;let a=r?t.tr:null;return dz(a,s,n,e)?(r&&r(a.scrollIntoView()),!0):!1}}function dz(n,e,t,r=null){let i=!1,o=e,s=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(t)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let l=s.resolve(e.start-2);o=new Ud(l,l,e.depth),e.endIndex<e.parent.childCount&&(e=new Ud(e.$from,s.resolve(e.$to.end(e.depth)),e.depth)),i=!0}let a=Km(o,t,r,e);return a?(n&&uz(n,e,a,i,t),!0):!1}function uz(n,e,t,r,i){let o=ie.empty;for(let d=t.length-1;d>=0;d--)o=ie.from(t[d].type.create(t[d].attrs,o));n.step(new rn(e.start-(r?2:0),e.end,e.start,e.end,new ye(o,0,0),t.length,!0));let s=0;for(let d=0;d<t.length;d++)t[d].type==i&&(s=d+1);let a=t.length-s,l=e.start+t.length-(r?2:0),c=e.parent;for(let d=e.startIndex,u=e.endIndex,h=!0;d<u;d++,h=!1)!h&&Ii(n.doc,l,a)&&(n.split(l,a),l+=2*a),l+=c.child(d).nodeSize;return n}function fz(n){return function(e,t){let{$from:r,$to:i}=e.selection,o=r.blockRange(i,s=>s.childCount>0&&s.firstChild.type==n);return o?t?r.node(o.depth-1).type==n?hz(e,t,n,o):pz(e,t,o):!0:!1}}function hz(n,e,t,r){let i=n.tr,o=r.end,s=r.$to.end(r.depth);o<s&&(i.step(new rn(o-1,s,o,s,new ye(ie.from(t.create(null,r.parent.copy())),1,0),1,!0)),r=new Ud(i.doc.resolve(r.$from.pos),i.doc.resolve(s),r.depth));const a=Ia(r);if(a==null)return!1;i.lift(r,a);let l=i.doc.resolve(i.mapping.map(o,-1)-1);return Mo(i.doc,l.pos)&&l.nodeBefore.type==l.nodeAfter.type&&i.join(l.pos),e(i.scrollIntoView()),!0}function pz(n,e,t){let r=n.tr,i=t.parent;for(let p=t.end,m=t.endIndex-1,v=t.startIndex;m>v;m--)p-=i.child(m).nodeSize,r.delete(p-1,p+1);let o=r.doc.resolve(t.start),s=o.nodeAfter;if(r.mapping.map(t.end)!=t.start+o.nodeAfter.nodeSize)return!1;let a=t.startIndex==0,l=t.endIndex==i.childCount,c=o.node(-1),d=o.index(-1);if(!c.canReplace(d+(a?0:1),d+1,s.content.append(l?ie.empty:ie.from(i))))return!1;let u=o.pos,h=u+s.nodeSize;return r.step(new rn(u-(a?1:0),h+(l?1:0),u+1,h-1,new ye((a?ie.empty:ie.from(i.copy(ie.empty))).append(l?ie.empty:ie.from(i.copy(ie.empty))),a?0:1,l?0:1),a?0:1)),e(r.scrollIntoView()),!0}function mz(n){return function(e,t){let{$from:r,$to:i}=e.selection,o=r.blockRange(i,c=>c.childCount>0&&c.firstChild.type==n);if(!o)return!1;let s=o.startIndex;if(s==0)return!1;let a=o.parent,l=a.child(s-1);if(l.type!=n)return!1;if(t){let c=l.lastChild&&l.lastChild.type==a.type,d=ie.from(c?n.create():null),u=new ye(ie.from(n.create(null,ie.from(a.type.create(null,d)))),c?3:1,0),h=o.start,p=o.end;t(e.tr.step(new rn(h-(c?3:1),p,h,p,u,1,!0)).scrollIntoView())}return!0}}function Sf(n){const{state:e,transaction:t}=n;let{selection:r}=t,{doc:i}=t,{storedMarks:o}=t;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return o},get selection(){return r},get doc(){return i},get tr(){return r=t.selection,i=t.doc,o=t.storedMarks,t}}}class Cf{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:r}=this,{view:i}=t,{tr:o}=r,s=this.buildProps(o);return Object.fromEntries(Object.entries(e).map(([a,l])=>[a,(...d)=>{const u=l(...d)(s);return!o.getMeta("preventDispatch")&&!this.hasCustomState&&i.dispatch(o),u}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(e,t=!0){const{rawCommands:r,editor:i,state:o}=this,{view:s}=i,a=[],l=!!e,c=e||o.tr,d=()=>(!l&&t&&!c.getMeta("preventDispatch")&&!this.hasCustomState&&s.dispatch(c),a.every(h=>h===!0)),u={...Object.fromEntries(Object.entries(r).map(([h,p])=>[h,(...v)=>{const g=this.buildProps(c,t),y=p(...v)(g);return a.push(y),u}])),run:d};return u}createCan(e){const{rawCommands:t,state:r}=this,i=!1,o=e||r.tr,s=this.buildProps(o,i);return{...Object.fromEntries(Object.entries(t).map(([l,c])=>[l,(...d)=>c(...d)({...s,dispatch:void 0})])),chain:()=>this.createChain(o,i)}}buildProps(e,t=!0){const{rawCommands:r,editor:i,state:o}=this,{view:s}=i,a={tr:e,editor:i,view:s,state:Sf({state:o,transaction:e}),dispatch:t?()=>{}:void 0,chain:()=>this.createChain(e,t),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(r).map(([l,c])=>[l,(...d)=>c(...d)(a)]))}};return a}}class gz{constructor(){this.callbacks={}}on(e,t){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),this}emit(e,...t){const r=this.callbacks[e];return r&&r.forEach(i=>i.apply(this,t)),this}off(e,t){const r=this.callbacks[e];return r&&(t?this.callbacks[e]=r.filter(i=>i!==t):delete this.callbacks[e]),this}once(e,t){const r=(...i)=>{this.off(e,r),t.apply(this,i)};return this.on(e,r)}removeAllListeners(){this.callbacks={}}}function Ae(n,e,t){return n.config[e]===void 0&&n.parent?Ae(n.parent,e,t):typeof n.config[e]=="function"?n.config[e].bind({...t,parent:n.parent?Ae(n.parent,e,t):null}):n.config[e]}function Tf(n){const e=n.filter(i=>i.type==="extension"),t=n.filter(i=>i.type==="node"),r=n.filter(i=>i.type==="mark");return{baseExtensions:e,nodeExtensions:t,markExtensions:r}}function E_(n){const e=[],{nodeExtensions:t,markExtensions:r}=Tf(n),i=[...t,...r],o={default:null,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return n.forEach(s=>{const a={name:s.name,options:s.options,storage:s.storage,extensions:i},l=Ae(s,"addGlobalAttributes",a);if(!l)return;l().forEach(d=>{d.types.forEach(u=>{Object.entries(d.attributes).forEach(([h,p])=>{e.push({type:u,name:h,attribute:{...o,...p}})})})})}),i.forEach(s=>{const a={name:s.name,options:s.options,storage:s.storage},l=Ae(s,"addAttributes",a);if(!l)return;const c=l();Object.entries(c).forEach(([d,u])=>{const h={...o,...u};typeof(h==null?void 0:h.default)=="function"&&(h.default=h.default()),h!=null&&h.isRequired&&(h==null?void 0:h.default)===void 0&&delete h.default,e.push({type:s.name,name:d,attribute:h})})}),e}function an(n,e){if(typeof n=="string"){if(!e.nodes[n])throw Error(`There is no node type named '${n}'. Maybe you forgot to add the extension?`);return e.nodes[n]}return n}function zt(...n){return n.filter(e=>!!e).reduce((e,t)=>{const r={...e};return Object.entries(t).forEach(([i,o])=>{if(!r[i]){r[i]=o;return}if(i==="class"){const a=o?String(o).split(" "):[],l=r[i]?r[i].split(" "):[],c=a.filter(d=>!l.includes(d));r[i]=[...l,...c].join(" ")}else if(i==="style"){const a=o?o.split(";").map(d=>d.trim()).filter(Boolean):[],l=r[i]?r[i].split(";").map(d=>d.trim()).filter(Boolean):[],c=new Map;l.forEach(d=>{const[u,h]=d.split(":").map(p=>p.trim());c.set(u,h)}),a.forEach(d=>{const[u,h]=d.split(":").map(p=>p.trim());c.set(u,h)}),r[i]=Array.from(c.entries()).map(([d,u])=>`${d}: ${u}`).join("; ")}else r[i]=o}),r},{})}function $p(n,e){return e.filter(t=>t.type===n.type.name).filter(t=>t.attribute.rendered).map(t=>t.attribute.renderHTML?t.attribute.renderHTML(n.attrs)||{}:{[t.name]:n.attrs[t.name]}).reduce((t,r)=>zt(t,r),{})}function M_(n){return typeof n=="function"}function Ze(n,e=void 0,...t){return M_(n)?e?n.bind(e)(...t):n(...t):n}function vz(n={}){return Object.keys(n).length===0&&n.constructor===Object}function yz(n){return typeof n!="string"?n:n.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(n):n==="true"?!0:n==="false"?!1:n}function Kb(n,e){return"style"in n?n:{...n,getAttrs:t=>{const r=n.getAttrs?n.getAttrs(t):n.attrs;if(r===!1)return!1;const i=e.reduce((o,s)=>{const a=s.attribute.parseHTML?s.attribute.parseHTML(t):yz(t.getAttribute(s.name));return a==null?o:{...o,[s.name]:a}},{});return{...r,...i}}}}function qb(n){return Object.fromEntries(Object.entries(n).filter(([e,t])=>e==="attrs"&&vz(t)?!1:t!=null))}function bz(n,e){var t;const r=E_(n),{nodeExtensions:i,markExtensions:o}=Tf(n),s=(t=i.find(c=>Ae(c,"topNode")))===null||t===void 0?void 0:t.name,a=Object.fromEntries(i.map(c=>{const d=r.filter(y=>y.type===c.name),u={name:c.name,options:c.options,storage:c.storage,editor:e},h=n.reduce((y,w)=>{const _=Ae(w,"extendNodeSchema",u);return{...y,..._?_(c):{}}},{}),p=qb({...h,content:Ze(Ae(c,"content",u)),marks:Ze(Ae(c,"marks",u)),group:Ze(Ae(c,"group",u)),inline:Ze(Ae(c,"inline",u)),atom:Ze(Ae(c,"atom",u)),selectable:Ze(Ae(c,"selectable",u)),draggable:Ze(Ae(c,"draggable",u)),code:Ze(Ae(c,"code",u)),whitespace:Ze(Ae(c,"whitespace",u)),linebreakReplacement:Ze(Ae(c,"linebreakReplacement",u)),defining:Ze(Ae(c,"defining",u)),isolating:Ze(Ae(c,"isolating",u)),attrs:Object.fromEntries(d.map(y=>{var w;return[y.name,{default:(w=y==null?void 0:y.attribute)===null||w===void 0?void 0:w.default}]}))}),m=Ze(Ae(c,"parseHTML",u));m&&(p.parseDOM=m.map(y=>Kb(y,d)));const v=Ae(c,"renderHTML",u);v&&(p.toDOM=y=>v({node:y,HTMLAttributes:$p(y,d)}));const g=Ae(c,"renderText",u);return g&&(p.toText=g),[c.name,p]})),l=Object.fromEntries(o.map(c=>{const d=r.filter(g=>g.type===c.name),u={name:c.name,options:c.options,storage:c.storage,editor:e},h=n.reduce((g,y)=>{const w=Ae(y,"extendMarkSchema",u);return{...g,...w?w(c):{}}},{}),p=qb({...h,inclusive:Ze(Ae(c,"inclusive",u)),excludes:Ze(Ae(c,"excludes",u)),group:Ze(Ae(c,"group",u)),spanning:Ze(Ae(c,"spanning",u)),code:Ze(Ae(c,"code",u)),attrs:Object.fromEntries(d.map(g=>{var y;return[g.name,{default:(y=g==null?void 0:g.attribute)===null||y===void 0?void 0:y.default}]}))}),m=Ze(Ae(c,"parseHTML",u));m&&(p.parseDOM=m.map(g=>Kb(g,d)));const v=Ae(c,"renderHTML",u);return v&&(p.toDOM=g=>v({mark:g,HTMLAttributes:$p(g,d)})),[c.name,p]}));return new kx({topNode:s,nodes:a,marks:l})}function Ah(n,e){return e.nodes[n]||e.marks[n]||null}function Jb(n,e){return Array.isArray(e)?e.some(t=>(typeof t=="string"?t:t.name)===n.name):e}function jg(n,e){const t=Os.fromSchema(e).serializeFragment(n),i=document.implementation.createHTMLDocument().createElement("div");return i.appendChild(t),i.innerHTML}const wz=(n,e=500)=>{let t="";const r=n.parentOffset;return n.parent.nodesBetween(Math.max(0,r-e),r,(i,o,s,a)=>{var l,c;const d=((c=(l=i.type.spec).toText)===null||c===void 0?void 0:c.call(l,{node:i,pos:o,parent:s,index:a}))||i.textContent||"%leaf%";t+=i.isAtom&&!i.isText?d:d.slice(0,Math.max(0,r-o))}),t};function Wg(n){return Object.prototype.toString.call(n)==="[object RegExp]"}class Af{constructor(e){this.find=e.find,this.handler=e.handler}}const xz=(n,e)=>{if(Wg(e))return e.exec(n);const t=e(n);if(!t)return null;const r=[t.text];return r.index=t.index,r.input=n,r.data=t.data,t.replaceWith&&(t.text.includes(t.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(t.replaceWith)),r};function Uc(n){var e;const{editor:t,from:r,to:i,text:o,rules:s,plugin:a}=n,{view:l}=t;if(l.composing)return!1;const c=l.state.doc.resolve(r);if(c.parent.type.spec.code||!((e=c.nodeBefore||c.nodeAfter)===null||e===void 0)&&e.marks.find(h=>h.type.spec.code))return!1;let d=!1;const u=wz(c)+o;return s.forEach(h=>{if(d)return;const p=xz(u,h.find);if(!p)return;const m=l.state.tr,v=Sf({state:l.state,transaction:m}),g={from:r-(p[0].length-o.length),to:i},{commands:y,chain:w,can:_}=new Cf({editor:t,state:v});h.handler({state:v,range:g,match:p,commands:y,chain:w,can:_})===null||!m.steps.length||(m.setMeta(a,{transform:m,from:r,to:i,text:o}),l.dispatch(m),d=!0)}),d}function kz(n){const{editor:e,rules:t}=n,r=new pt({state:{init(){return null},apply(i,o,s){const a=i.getMeta(r);if(a)return a;const l=i.getMeta("applyInputRules");return!!l&&setTimeout(()=>{let{text:d}=l;typeof d=="string"?d=d:d=jg(ie.from(d),s.schema);const{from:u}=l,h=u+d.length;Uc({editor:e,from:u,to:h,text:d,rules:t,plugin:r})}),i.selectionSet||i.docChanged?null:o}},props:{handleTextInput(i,o,s,a){return Uc({editor:e,from:o,to:s,text:a,rules:t,plugin:r})},handleDOMEvents:{compositionend:i=>(setTimeout(()=>{const{$cursor:o}=i.state.selection;o&&Uc({editor:e,from:o.pos,to:o.pos,text:"",rules:t,plugin:r})}),!1)},handleKeyDown(i,o){if(o.key!=="Enter")return!1;const{$cursor:s}=i.state.selection;return s?Uc({editor:e,from:s.pos,to:s.pos,text:`
|
|
98
|
-
`,rules:t,plugin:r}):!1}},isInputRules:!0});return r}function _z(n){return Object.prototype.toString.call(n).slice(8,-1)}function jc(n){return _z(n)!=="Object"?!1:n.constructor===Object&&Object.getPrototypeOf(n)===Object.prototype}function Ef(n,e){const t={...n};return jc(n)&&jc(e)&&Object.keys(e).forEach(r=>{jc(e[r])&&jc(n[r])?t[r]=Ef(n[r],e[r]):t[r]=e[r]}),t}class fi{constructor(e={}){this.type="mark",this.name="mark",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=Ze(Ae(this,"addOptions",{name:this.name}))),this.storage=Ze(Ae(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new fi(e)}configure(e={}){const t=this.extend({...this.config,addOptions:()=>Ef(this.options,e)});return t.name=this.name,t.parent=this.parent,t}extend(e={}){const t=new fi(e);return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=Ze(Ae(t,"addOptions",{name:t.name})),t.storage=Ze(Ae(t,"addStorage",{name:t.name,options:t.options})),t}static handleExit({editor:e,mark:t}){const{tr:r}=e.state,i=e.state.selection.$from;if(i.pos===i.end()){const s=i.marks();if(!!!s.find(c=>(c==null?void 0:c.type.name)===t.name))return!1;const l=s.find(c=>(c==null?void 0:c.type.name)===t.name);return l&&r.removeStoredMark(l),r.insertText(" ",i.pos),e.view.dispatch(r),!0}return!1}}function Sz(n){return typeof n=="number"}class Cz{constructor(e){this.find=e.find,this.handler=e.handler}}const Tz=(n,e,t)=>{if(Wg(e))return[...n.matchAll(e)];const r=e(n,t);return r?r.map(i=>{const o=[i.text];return o.index=i.index,o.input=n,o.data=i.data,i.replaceWith&&(i.text.includes(i.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),o.push(i.replaceWith)),o}):[]};function Az(n){const{editor:e,state:t,from:r,to:i,rule:o,pasteEvent:s,dropEvent:a}=n,{commands:l,chain:c,can:d}=new Cf({editor:e,state:t}),u=[];return t.doc.nodesBetween(r,i,(p,m)=>{if(!p.isTextblock||p.type.spec.code)return;const v=Math.max(r,m),g=Math.min(i,m+p.content.size),y=p.textBetween(v-m,g-m,void 0,"");Tz(y,o.find,s).forEach(_=>{if(_.index===void 0)return;const S=v+_.index+1,A=S+_[0].length,U={from:t.tr.mapping.map(S),to:t.tr.mapping.map(A)},N=o.handler({state:t,range:U,match:_,commands:l,chain:c,can:d,pasteEvent:s,dropEvent:a});u.push(N)})}),u.every(p=>p!==null)}let Wc=null;const Ez=n=>{var e;const t=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=t.clipboardData)===null||e===void 0||e.setData("text/html",n),t};function Mz(n){const{editor:e,rules:t}=n;let r=null,i=!1,o=!1,s=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,a;try{a=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{a=null}const l=({state:d,from:u,to:h,rule:p,pasteEvt:m})=>{const v=d.tr,g=Sf({state:d,transaction:v});if(!(!Az({editor:e,state:g,from:Math.max(u-1,0),to:h.b-1,rule:p,pasteEvent:m,dropEvent:a})||!v.steps.length)){try{a=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{a=null}return s=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,v}};return t.map(d=>new pt({view(u){const h=m=>{var v;r=!((v=u.dom.parentElement)===null||v===void 0)&&v.contains(m.target)?u.dom.parentElement:null,r&&(Wc=e)},p=()=>{Wc&&(Wc=null)};return window.addEventListener("dragstart",h),window.addEventListener("dragend",p),{destroy(){window.removeEventListener("dragstart",h),window.removeEventListener("dragend",p)}}},props:{handleDOMEvents:{drop:(u,h)=>{if(o=r===u.dom.parentElement,a=h,!o){const p=Wc;p!=null&&p.isEditable&&setTimeout(()=>{const m=p.state.selection;m&&p.commands.deleteRange({from:m.from,to:m.to})},10)}return!1},paste:(u,h)=>{var p;const m=(p=h.clipboardData)===null||p===void 0?void 0:p.getData("text/html");return s=h,i=!!(m!=null&&m.includes("data-pm-slice")),!1}}},appendTransaction:(u,h,p)=>{const m=u[0],v=m.getMeta("uiEvent")==="paste"&&!i,g=m.getMeta("uiEvent")==="drop"&&!o,y=m.getMeta("applyPasteRules"),w=!!y;if(!v&&!g&&!w)return;if(w){let{text:A}=y;typeof A=="string"?A=A:A=jg(ie.from(A),p.schema);const{from:U}=y,N=U+A.length,R=Ez(A);return l({rule:d,state:p,from:U,to:{b:N},pasteEvt:R})}const _=h.doc.content.findDiffStart(p.doc.content),S=h.doc.content.findDiffEnd(p.doc.content);if(!(!Sz(_)||!S||_===S.b))return l({rule:d,state:p,from:_,to:S,pasteEvt:s})}}))}function Oz(n){const e=n.filter((t,r)=>n.indexOf(t)!==r);return Array.from(new Set(e))}class Js{constructor(e,t){this.splittableMarks=[],this.editor=t,this.extensions=Js.resolve(e),this.schema=bz(this.extensions,t),this.setupExtensions()}static resolve(e){const t=Js.sort(Js.flatten(e)),r=Oz(t.map(i=>i.name));return r.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${r.map(i=>`'${i}'`).join(", ")}]. This can lead to issues.`),t}static flatten(e){return e.map(t=>{const r={name:t.name,options:t.options,storage:t.storage},i=Ae(t,"addExtensions",r);return i?[t,...this.flatten(i())]:t}).flat(10)}static sort(e){return e.sort((r,i)=>{const o=Ae(r,"priority")||100,s=Ae(i,"priority")||100;return o>s?-1:o<s?1:0})}get commands(){return this.extensions.reduce((e,t)=>{const r={name:t.name,options:t.options,storage:t.storage,editor:this.editor,type:Ah(t.name,this.schema)},i=Ae(t,"addCommands",r);return i?{...e,...i()}:e},{})}get plugins(){const{editor:e}=this,t=Js.sort([...this.extensions].reverse()),r=[],i=[],o=t.map(s=>{const a={name:s.name,options:s.options,storage:s.storage,editor:e,type:Ah(s.name,this.schema)},l=[],c=Ae(s,"addKeyboardShortcuts",a);let d={};if(s.type==="mark"&&Ae(s,"exitable",a)&&(d.ArrowRight=()=>fi.handleExit({editor:e,mark:s})),c){const v=Object.fromEntries(Object.entries(c()).map(([g,y])=>[g,()=>y({editor:e})]));d={...d,...v}}const u=GL(d);l.push(u);const h=Ae(s,"addInputRules",a);Jb(s,e.options.enableInputRules)&&h&&r.push(...h());const p=Ae(s,"addPasteRules",a);Jb(s,e.options.enablePasteRules)&&p&&i.push(...p());const m=Ae(s,"addProseMirrorPlugins",a);if(m){const v=m();l.push(...v)}return l}).flat();return[kz({editor:e,rules:r}),...Mz({editor:e,rules:i}),...o]}get attributes(){return E_(this.extensions)}get nodeViews(){const{editor:e}=this,{nodeExtensions:t}=Tf(this.extensions);return Object.fromEntries(t.filter(r=>!!Ae(r,"addNodeView")).map(r=>{const i=this.attributes.filter(l=>l.type===r.name),o={name:r.name,options:r.options,storage:r.storage,editor:e,type:an(r.name,this.schema)},s=Ae(r,"addNodeView",o);if(!s)return[];const a=(l,c,d,u,h)=>{const p=$p(l,i);return s()({node:l,view:c,getPos:d,decorations:u,innerDecorations:h,editor:e,extension:r,HTMLAttributes:p})};return[r.name,a]}))}setupExtensions(){this.extensions.forEach(e=>{var t;this.editor.extensionStorage[e.name]=e.storage;const r={name:e.name,options:e.options,storage:e.storage,editor:this.editor,type:Ah(e.name,this.schema)};e.type==="mark"&&(!((t=Ze(Ae(e,"keepOnSplit",r)))!==null&&t!==void 0)||t)&&this.splittableMarks.push(e.name);const i=Ae(e,"onBeforeCreate",r),o=Ae(e,"onCreate",r),s=Ae(e,"onUpdate",r),a=Ae(e,"onSelectionUpdate",r),l=Ae(e,"onTransaction",r),c=Ae(e,"onFocus",r),d=Ae(e,"onBlur",r),u=Ae(e,"onDestroy",r);i&&this.editor.on("beforeCreate",i),o&&this.editor.on("create",o),s&&this.editor.on("update",s),a&&this.editor.on("selectionUpdate",a),l&&this.editor.on("transaction",l),c&&this.editor.on("focus",c),d&&this.editor.on("blur",d),u&&this.editor.on("destroy",u)})}}class Et{constructor(e={}){this.type="extension",this.name="extension",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=Ze(Ae(this,"addOptions",{name:this.name}))),this.storage=Ze(Ae(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new Et(e)}configure(e={}){const t=this.extend({...this.config,addOptions:()=>Ef(this.options,e)});return t.name=this.name,t.parent=this.parent,t}extend(e={}){const t=new Et({...this.config,...e});return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=Ze(Ae(t,"addOptions",{name:t.name})),t.storage=Ze(Ae(t,"addStorage",{name:t.name,options:t.options})),t}}function O_(n,e,t){const{from:r,to:i}=e,{blockSeparator:o=`
|
|
99
|
-
|
|
100
|
-
`,textSerializers:s={}}=t||{};let a="";return n.nodesBetween(r,i,(l,c,d,u)=>{var h;l.isBlock&&c>r&&(a+=o);const p=s==null?void 0:s[l.type.name];if(p)return d&&(a+=p({node:l,pos:c,parent:d,index:u,range:e})),!1;l.isText&&(a+=(h=l==null?void 0:l.text)===null||h===void 0?void 0:h.slice(Math.max(r,c)-c,i-c))}),a}function D_(n){return Object.fromEntries(Object.entries(n.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}const Dz=Et.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new pt({key:new xt("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:n}=this,{state:e,schema:t}=n,{doc:r,selection:i}=e,{ranges:o}=i,s=Math.min(...o.map(d=>d.$from.pos)),a=Math.max(...o.map(d=>d.$to.pos)),l=D_(t);return O_(r,{from:s,to:a},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:l})}}})]}}),Rz=()=>({editor:n,view:e})=>(requestAnimationFrame(()=>{var t;n.isDestroyed||(e.dom.blur(),(t=window==null?void 0:window.getSelection())===null||t===void 0||t.removeAllRanges())}),!0),Nz=(n=!1)=>({commands:e})=>e.setContent("",n),Iz=()=>({state:n,tr:e,dispatch:t})=>{const{selection:r}=e,{ranges:i}=r;return t&&i.forEach(({$from:o,$to:s})=>{n.doc.nodesBetween(o.pos,s.pos,(a,l)=>{if(a.type.isText)return;const{doc:c,mapping:d}=e,u=c.resolve(d.map(l)),h=c.resolve(d.map(l+a.nodeSize)),p=u.blockRange(h);if(!p)return;const m=Ia(p);if(a.type.isTextblock){const{defaultType:v}=u.parent.contentMatchAt(u.index());e.setNodeMarkup(p.start,v)}(m||m===0)&&e.lift(p,m)})}),!0},Pz=n=>e=>n(e),Lz=()=>({state:n,dispatch:e})=>S_(n,e),zz=(n,e)=>({editor:t,tr:r})=>{const{state:i}=t,o=i.doc.slice(n.from,n.to);r.deleteRange(n.from,n.to);const s=r.mapping.map(e);return r.insert(s,o.content),r.setSelection(new Ie(r.doc.resolve(Math.max(s-1,0)))),!0},Bz=()=>({tr:n,dispatch:e})=>{const{selection:t}=n,r=t.$anchor.node();if(r.content.size>0)return!1;const i=n.selection.$anchor;for(let o=i.depth;o>0;o-=1)if(i.node(o).type===r.type){if(e){const a=i.before(o),l=i.after(o);n.delete(a,l).scrollIntoView()}return!0}return!1},Fz=n=>({tr:e,state:t,dispatch:r})=>{const i=an(n,t.schema),o=e.selection.$anchor;for(let s=o.depth;s>0;s-=1)if(o.node(s).type===i){if(r){const l=o.before(s),c=o.after(s);e.delete(l,c).scrollIntoView()}return!0}return!1},Vz=n=>({tr:e,dispatch:t})=>{const{from:r,to:i}=n;return t&&e.delete(r,i),!0},Hz=()=>({state:n,dispatch:e})=>Bg(n,e),Uz=()=>({commands:n})=>n.keyboardShortcut("Enter"),jz=()=>({state:n,dispatch:e})=>tz(n,e);function hu(n,e,t={strict:!0}){const r=Object.keys(e);return r.length?r.every(i=>t.strict?e[i]===n[i]:Wg(e[i])?e[i].test(n[i]):e[i]===n[i]):!0}function R_(n,e,t={}){return n.find(r=>r.type===e&&hu(Object.fromEntries(Object.keys(t).map(i=>[i,r.attrs[i]])),t))}function Yb(n,e,t={}){return!!R_(n,e,t)}function Kg(n,e,t){var r;if(!n||!e)return;let i=n.parent.childAfter(n.parentOffset);if((!i.node||!i.node.marks.some(d=>d.type===e))&&(i=n.parent.childBefore(n.parentOffset)),!i.node||!i.node.marks.some(d=>d.type===e)||(t=t||((r=i.node.marks[0])===null||r===void 0?void 0:r.attrs),!R_([...i.node.marks],e,t)))return;let s=i.index,a=n.start()+i.offset,l=s+1,c=a+i.node.nodeSize;for(;s>0&&Yb([...n.parent.child(s-1).marks],e,t);)s-=1,a-=n.parent.child(s).nodeSize;for(;l<n.parent.childCount&&Yb([...n.parent.child(l).marks],e,t);)c+=n.parent.child(l).nodeSize,l+=1;return{from:a,to:c}}function Do(n,e){if(typeof n=="string"){if(!e.marks[n])throw Error(`There is no mark type named '${n}'. Maybe you forgot to add the extension?`);return e.marks[n]}return n}const Wz=(n,e={})=>({tr:t,state:r,dispatch:i})=>{const o=Do(n,r.schema),{doc:s,selection:a}=t,{$from:l,from:c,to:d}=a;if(i){const u=Kg(l,o,e);if(u&&u.from<=c&&u.to>=d){const h=Ie.create(s,u.from,u.to);t.setSelection(h)}}return!0},Kz=n=>e=>{const t=typeof n=="function"?n(e):n;for(let r=0;r<t.length;r+=1)if(t[r](e))return!0;return!1};function N_(n){return n instanceof Ie}function Ko(n=0,e=0,t=0){return Math.min(Math.max(n,e),t)}function I_(n,e=null){if(!e)return null;const t=Fe.atStart(n),r=Fe.atEnd(n);if(e==="start"||e===!0)return t;if(e==="end")return r;const i=t.from,o=r.to;return e==="all"?Ie.create(n,Ko(0,i,o),Ko(n.content.size,i,o)):Ie.create(n,Ko(e,i,o),Ko(e,i,o))}function Gb(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function pu(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function qz(){return typeof navigator<"u"?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}const Jz=(n=null,e={})=>({editor:t,view:r,tr:i,dispatch:o})=>{e={scrollIntoView:!0,...e};const s=()=>{(pu()||Gb())&&r.dom.focus(),requestAnimationFrame(()=>{t.isDestroyed||(r.focus(),qz()&&!pu()&&!Gb()&&r.dom.focus({preventScroll:!0}))})};if(r.hasFocus()&&n===null||n===!1)return!0;if(o&&n===null&&!N_(t.state.selection))return s(),!0;const a=I_(i.doc,n)||t.state.selection,l=t.state.selection.eq(a);return o&&(l||i.setSelection(a),l&&i.storedMarks&&i.setStoredMarks(i.storedMarks),s()),!0},Yz=(n,e)=>t=>n.every((r,i)=>e(r,{...t,index:i})),Gz=(n,e)=>({tr:t,commands:r})=>r.insertContentAt({from:t.selection.from,to:t.selection.to},n,e),P_=n=>{const e=n.childNodes;for(let t=e.length-1;t>=0;t-=1){const r=e[t];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?n.removeChild(r):r.nodeType===1&&P_(r)}return n};function Kc(n){const e=`<body>${n}</body>`,t=new window.DOMParser().parseFromString(e,"text/html").body;return P_(t)}function tc(n,e,t){if(n instanceof po||n instanceof ie)return n;t={slice:!0,parseOptions:{},...t};const r=typeof n=="object"&&n!==null,i=typeof n=="string";if(r)try{if(Array.isArray(n)&&n.length>0)return ie.fromArray(n.map(a=>e.nodeFromJSON(a)));const s=e.nodeFromJSON(n);return t.errorOnInvalidContent&&s.check(),s}catch(o){if(t.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:o});return console.warn("[tiptap warn]: Invalid content.","Passed value:",n,"Error:",o),tc("",e,t)}if(i){if(t.errorOnInvalidContent){let s=!1,a="";const l=new kx({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:c=>(s=!0,a=typeof c=="string"?c:c.outerHTML,null)}]}})});if(t.slice?ll.fromSchema(l).parseSlice(Kc(n),t.parseOptions):ll.fromSchema(l).parse(Kc(n),t.parseOptions),t.errorOnInvalidContent&&s)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${a}`)})}const o=ll.fromSchema(e);return t.slice?o.parseSlice(Kc(n),t.parseOptions).content:o.parse(Kc(n),t.parseOptions)}return tc("",e,t)}function Zz(n,e,t){const r=n.steps.length-1;if(r<e)return;const i=n.steps[r];if(!(i instanceof nn||i instanceof rn))return;const o=n.mapping.maps[r];let s=0;o.forEach((a,l,c,d)=>{s===0&&(s=d)}),n.setSelection(Fe.near(n.doc.resolve(s),t))}const Xz=n=>!("type"in n),Qz=(n,e,t)=>({tr:r,dispatch:i,editor:o})=>{var s;if(i){t={parseOptions:o.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...t};let a;const l=g=>{o.emit("contentError",{editor:o,error:g,disableCollaboration:()=>{o.storage.collaboration&&(o.storage.collaboration.isDisabled=!0)}})},c={preserveWhitespace:"full",...t.parseOptions};if(!t.errorOnInvalidContent&&!o.options.enableContentCheck&&o.options.emitContentError)try{tc(e,o.schema,{parseOptions:c,errorOnInvalidContent:!0})}catch(g){l(g)}try{a=tc(e,o.schema,{parseOptions:c,errorOnInvalidContent:(s=t.errorOnInvalidContent)!==null&&s!==void 0?s:o.options.enableContentCheck})}catch(g){return l(g),!1}let{from:d,to:u}=typeof n=="number"?{from:n,to:n}:{from:n.from,to:n.to},h=!0,p=!0;if((Xz(a)?a:[a]).forEach(g=>{g.check(),h=h?g.isText&&g.marks.length===0:!1,p=p?g.isBlock:!1}),d===u&&p){const{parent:g}=r.doc.resolve(d);g.isTextblock&&!g.type.spec.code&&!g.childCount&&(d-=1,u+=1)}let v;if(h){if(Array.isArray(e))v=e.map(g=>g.text||"").join("");else if(e instanceof ie){let g="";e.forEach(y=>{y.text&&(g+=y.text)}),v=g}else typeof e=="object"&&e&&e.text?v=e.text:v=e;r.insertText(v,d,u)}else v=a,r.replaceWith(d,u,v);t.updateSelection&&Zz(r,r.steps.length-1,-1),t.applyInputRules&&r.setMeta("applyInputRules",{from:d,text:v}),t.applyPasteRules&&r.setMeta("applyPasteRules",{from:d,text:v})}return!0},$z=()=>({state:n,dispatch:e})=>QL(n,e),e3=()=>({state:n,dispatch:e})=>$L(n,e),t3=()=>({state:n,dispatch:e})=>v_(n,e),n3=()=>({state:n,dispatch:e})=>x_(n,e),r3=()=>({state:n,dispatch:e,tr:t})=>{try{const r=nf(n.doc,n.selection.$from.pos,-1);return r==null?!1:(t.join(r,2),e&&e(t),!0)}catch{return!1}},i3=()=>({state:n,dispatch:e,tr:t})=>{try{const r=nf(n.doc,n.selection.$from.pos,1);return r==null?!1:(t.join(r,2),e&&e(t),!0)}catch{return!1}},o3=()=>({state:n,dispatch:e})=>ZL(n,e),s3=()=>({state:n,dispatch:e})=>XL(n,e);function L_(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function a3(n){const e=n.split(/-(?!$)/);let t=e[e.length-1];t==="Space"&&(t=" ");let r,i,o,s;for(let a=0;a<e.length-1;a+=1){const l=e[a];if(/^(cmd|meta|m)$/i.test(l))s=!0;else if(/^a(lt)?$/i.test(l))r=!0;else if(/^(c|ctrl|control)$/i.test(l))i=!0;else if(/^s(hift)?$/i.test(l))o=!0;else if(/^mod$/i.test(l))pu()||L_()?s=!0:i=!0;else throw new Error(`Unrecognized modifier name: ${l}`)}return r&&(t=`Alt-${t}`),i&&(t=`Ctrl-${t}`),s&&(t=`Meta-${t}`),o&&(t=`Shift-${t}`),t}const l3=n=>({editor:e,view:t,tr:r,dispatch:i})=>{const o=a3(n).split(/-(?!$)/),s=o.find(c=>!["Alt","Ctrl","Meta","Shift"].includes(c)),a=new KeyboardEvent("keydown",{key:s==="Space"?" ":s,altKey:o.includes("Alt"),ctrlKey:o.includes("Ctrl"),metaKey:o.includes("Meta"),shiftKey:o.includes("Shift"),bubbles:!0,cancelable:!0}),l=e.captureTransaction(()=>{t.someProp("handleKeyDown",c=>c(t,a))});return l==null||l.steps.forEach(c=>{const d=c.map(r.mapping);d&&i&&r.maybeStep(d)}),!0};function nc(n,e,t={}){const{from:r,to:i,empty:o}=n.selection,s=e?an(e,n.schema):null,a=[];n.doc.nodesBetween(r,i,(u,h)=>{if(u.isText)return;const p=Math.max(r,h),m=Math.min(i,h+u.nodeSize);a.push({node:u,from:p,to:m})});const l=i-r,c=a.filter(u=>s?s.name===u.node.type.name:!0).filter(u=>hu(u.node.attrs,t,{strict:!1}));return o?!!c.length:c.reduce((u,h)=>u+h.to-h.from,0)>=l}const c3=(n,e={})=>({state:t,dispatch:r})=>{const i=an(n,t.schema);return nc(t,i,e)?ez(t,r):!1},d3=()=>({state:n,dispatch:e})=>C_(n,e),u3=n=>({state:e,dispatch:t})=>{const r=an(n,e.schema);return fz(r)(e,t)},f3=()=>({state:n,dispatch:e})=>__(n,e);function Mf(n,e){return e.nodes[n]?"node":e.marks[n]?"mark":null}function Zb(n,e){const t=typeof e=="string"?[e]:e;return Object.keys(n).reduce((r,i)=>(t.includes(i)||(r[i]=n[i]),r),{})}const h3=(n,e)=>({tr:t,state:r,dispatch:i})=>{let o=null,s=null;const a=Mf(typeof n=="string"?n:n.name,r.schema);return a?(a==="node"&&(o=an(n,r.schema)),a==="mark"&&(s=Do(n,r.schema)),i&&t.selection.ranges.forEach(l=>{r.doc.nodesBetween(l.$from.pos,l.$to.pos,(c,d)=>{o&&o===c.type&&t.setNodeMarkup(d,void 0,Zb(c.attrs,e)),s&&c.marks.length&&c.marks.forEach(u=>{s===u.type&&t.addMark(d,d+c.nodeSize,s.create(Zb(u.attrs,e)))})})}),!0):!1},p3=()=>({tr:n,dispatch:e})=>(e&&n.scrollIntoView(),!0),m3=()=>({tr:n,dispatch:e})=>{if(e){const t=new Kn(n.doc);n.setSelection(t)}return!0},g3=()=>({state:n,dispatch:e})=>b_(n,e),v3=()=>({state:n,dispatch:e})=>k_(n,e),y3=()=>({state:n,dispatch:e})=>iz(n,e),b3=()=>({state:n,dispatch:e})=>az(n,e),w3=()=>({state:n,dispatch:e})=>sz(n,e);function em(n,e,t={},r={}){return tc(n,e,{slice:!1,parseOptions:t,errorOnInvalidContent:r.errorOnInvalidContent})}const x3=(n,e=!1,t={},r={})=>({editor:i,tr:o,dispatch:s,commands:a})=>{var l,c;const{doc:d}=o;if(t.preserveWhitespace!=="full"){const u=em(n,i.schema,t,{errorOnInvalidContent:(l=r.errorOnInvalidContent)!==null&&l!==void 0?l:i.options.enableContentCheck});return s&&o.replaceWith(0,d.content.size,u).setMeta("preventUpdate",!e),!0}return s&&o.setMeta("preventUpdate",!e),a.insertContentAt({from:0,to:d.content.size},n,{parseOptions:t,errorOnInvalidContent:(c=r.errorOnInvalidContent)!==null&&c!==void 0?c:i.options.enableContentCheck})};function z_(n,e){const t=Do(e,n.schema),{from:r,to:i,empty:o}=n.selection,s=[];o?(n.storedMarks&&s.push(...n.storedMarks),s.push(...n.selection.$head.marks())):n.doc.nodesBetween(r,i,l=>{s.push(...l.marks)});const a=s.find(l=>l.type.name===t.name);return a?{...a.attrs}:{}}function k3(n,e){const t=new qm(n);return e.forEach(r=>{r.steps.forEach(i=>{t.step(i)})}),t}function _3(n){for(let e=0;e<n.edgeCount;e+=1){const{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}function S3(n,e,t){const r=[];return n.nodesBetween(e.from,e.to,(i,o)=>{t(i)&&r.push({node:i,pos:o})}),r}function B_(n,e){for(let t=n.depth;t>0;t-=1){const r=n.node(t);if(e(r))return{pos:t>0?n.before(t):0,start:n.start(t),depth:t,node:r}}}function qg(n){return e=>B_(e.$from,n)}function C3(n,e){const t={from:0,to:n.content.size};return O_(n,t,e)}function T3(n,e){const t=an(e,n.schema),{from:r,to:i}=n.selection,o=[];n.doc.nodesBetween(r,i,a=>{o.push(a)});const s=o.reverse().find(a=>a.type.name===t.name);return s?{...s.attrs}:{}}function F_(n,e){const t=Mf(typeof e=="string"?e:e.name,n.schema);return t==="node"?T3(n,e):t==="mark"?z_(n,e):{}}function A3(n,e=JSON.stringify){const t={};return n.filter(r=>{const i=e(r);return Object.prototype.hasOwnProperty.call(t,i)?!1:t[i]=!0})}function E3(n){const e=A3(n);return e.length===1?e:e.filter((t,r)=>!e.filter((o,s)=>s!==r).some(o=>t.oldRange.from>=o.oldRange.from&&t.oldRange.to<=o.oldRange.to&&t.newRange.from>=o.newRange.from&&t.newRange.to<=o.newRange.to))}function M3(n){const{mapping:e,steps:t}=n,r=[];return e.maps.forEach((i,o)=>{const s=[];if(i.ranges.length)i.forEach((a,l)=>{s.push({from:a,to:l})});else{const{from:a,to:l}=t[o];if(a===void 0||l===void 0)return;s.push({from:a,to:l})}s.forEach(({from:a,to:l})=>{const c=e.slice(o).map(a,-1),d=e.slice(o).map(l),u=e.invert().map(c,-1),h=e.invert().map(d);r.push({oldRange:{from:u,to:h},newRange:{from:c,to:d}})})}),E3(r)}function Jg(n,e,t){const r=[];return n===e?t.resolve(n).marks().forEach(i=>{const o=t.resolve(n),s=Kg(o,i.type);s&&r.push({mark:i,...s})}):t.nodesBetween(n,e,(i,o)=>{!i||(i==null?void 0:i.nodeSize)===void 0||r.push(...i.marks.map(s=>({from:o,to:o+i.nodeSize,mark:s})))}),r}function kd(n,e,t){return Object.fromEntries(Object.entries(t).filter(([r])=>{const i=n.find(o=>o.type===e&&o.name===r);return i?i.attribute.keepOnSplit:!1}))}function tm(n,e,t={}){const{empty:r,ranges:i}=n.selection,o=e?Do(e,n.schema):null;if(r)return!!(n.storedMarks||n.selection.$from.marks()).filter(u=>o?o.name===u.type.name:!0).find(u=>hu(u.attrs,t,{strict:!1}));let s=0;const a=[];if(i.forEach(({$from:u,$to:h})=>{const p=u.pos,m=h.pos;n.doc.nodesBetween(p,m,(v,g)=>{if(!v.isText&&!v.marks.length)return;const y=Math.max(p,g),w=Math.min(m,g+v.nodeSize),_=w-y;s+=_,a.push(...v.marks.map(S=>({mark:S,from:y,to:w})))})}),s===0)return!1;const l=a.filter(u=>o?o.name===u.mark.type.name:!0).filter(u=>hu(u.mark.attrs,t,{strict:!1})).reduce((u,h)=>u+h.to-h.from,0),c=a.filter(u=>o?u.mark.type!==o&&u.mark.type.excludes(o):!0).reduce((u,h)=>u+h.to-h.from,0);return(l>0?l+c:l)>=s}function O3(n,e,t={}){if(!e)return nc(n,null,t)||tm(n,null,t);const r=Mf(e,n.schema);return r==="node"?nc(n,e,t):r==="mark"?tm(n,e,t):!1}function Xb(n,e){const{nodeExtensions:t}=Tf(e),r=t.find(s=>s.name===n);if(!r)return!1;const i={name:r.name,options:r.options,storage:r.storage},o=Ze(Ae(r,"group",i));return typeof o!="string"?!1:o.split(" ").includes("list")}function Of(n,{checkChildren:e=!0,ignoreWhitespace:t=!1}={}){var r;if(t){if(n.type.name==="hardBreak")return!0;if(n.isText)return/^\s*$/m.test((r=n.text)!==null&&r!==void 0?r:"")}if(n.isText)return!n.text;if(n.isAtom||n.isLeaf)return!1;if(n.content.childCount===0)return!0;if(e){let i=!0;return n.content.forEach(o=>{i!==!1&&(Of(o,{ignoreWhitespace:t,checkChildren:e})||(i=!1))}),i}return!1}function D3(n){return n instanceof Pe}function R3(n,e,t){var r;const{selection:i}=e;let o=null;if(N_(i)&&(o=i.$cursor),o){const a=(r=n.storedMarks)!==null&&r!==void 0?r:o.marks();return!!t.isInSet(a)||!a.some(l=>l.type.excludes(t))}const{ranges:s}=i;return s.some(({$from:a,$to:l})=>{let c=a.depth===0?n.doc.inlineContent&&n.doc.type.allowsMarkType(t):!1;return n.doc.nodesBetween(a.pos,l.pos,(d,u,h)=>{if(c)return!1;if(d.isInline){const p=!h||h.type.allowsMarkType(t),m=!!t.isInSet(d.marks)||!d.marks.some(v=>v.type.excludes(t));c=p&&m}return!c}),c})}const N3=(n,e={})=>({tr:t,state:r,dispatch:i})=>{const{selection:o}=t,{empty:s,ranges:a}=o,l=Do(n,r.schema);if(i)if(s){const c=z_(r,l);t.addStoredMark(l.create({...c,...e}))}else a.forEach(c=>{const d=c.$from.pos,u=c.$to.pos;r.doc.nodesBetween(d,u,(h,p)=>{const m=Math.max(p,d),v=Math.min(p+h.nodeSize,u);h.marks.find(y=>y.type===l)?h.marks.forEach(y=>{l===y.type&&t.addMark(m,v,l.create({...y.attrs,...e}))}):t.addMark(m,v,l.create(e))})});return R3(r,t,l)},I3=(n,e)=>({tr:t})=>(t.setMeta(n,e),!0),P3=(n,e={})=>({state:t,dispatch:r,chain:i})=>{const o=an(n,t.schema);let s;return t.selection.$anchor.sameParent(t.selection.$head)&&(s=t.selection.$anchor.parent.attrs),o.isTextblock?i().command(({commands:a})=>Wb(o,{...s,...e})(t)?!0:a.clearNodes()).command(({state:a})=>Wb(o,{...s,...e})(a,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},L3=n=>({tr:e,dispatch:t})=>{if(t){const{doc:r}=e,i=Ko(n,0,r.content.size),o=Pe.create(r,i);e.setSelection(o)}return!0},z3=n=>({tr:e,dispatch:t})=>{if(t){const{doc:r}=e,{from:i,to:o}=typeof n=="number"?{from:n,to:n}:n,s=Ie.atStart(r).from,a=Ie.atEnd(r).to,l=Ko(i,s,a),c=Ko(o,s,a),d=Ie.create(r,l,c);e.setSelection(d)}return!0},B3=n=>({state:e,dispatch:t})=>{const r=an(n,e.schema);return mz(r)(e,t)};function Qb(n,e){const t=n.storedMarks||n.selection.$to.parentOffset&&n.selection.$from.marks();if(t){const r=t.filter(i=>e==null?void 0:e.includes(i.type.name));n.tr.ensureMarks(r)}}const F3=({keepMarks:n=!0}={})=>({tr:e,state:t,dispatch:r,editor:i})=>{const{selection:o,doc:s}=e,{$from:a,$to:l}=o,c=i.extensionManager.attributes,d=kd(c,a.node().type.name,a.node().attrs);if(o instanceof Pe&&o.node.isBlock)return!a.parentOffset||!Ii(s,a.pos)?!1:(r&&(n&&Qb(t,i.extensionManager.splittableMarks),e.split(a.pos).scrollIntoView()),!0);if(!a.parent.isBlock)return!1;const u=l.parentOffset===l.parent.content.size,h=a.depth===0?void 0:_3(a.node(-1).contentMatchAt(a.indexAfter(-1)));let p=u&&h?[{type:h,attrs:d}]:void 0,m=Ii(e.doc,e.mapping.map(a.pos),1,p);if(!p&&!m&&Ii(e.doc,e.mapping.map(a.pos),1,h?[{type:h}]:void 0)&&(m=!0,p=h?[{type:h,attrs:d}]:void 0),r){if(m&&(o instanceof Ie&&e.deleteSelection(),e.split(e.mapping.map(a.pos),1,p),h&&!u&&!a.parentOffset&&a.parent.type!==h)){const v=e.mapping.map(a.before()),g=e.doc.resolve(v);a.node(-1).canReplaceWith(g.index(),g.index()+1,h)&&e.setNodeMarkup(e.mapping.map(a.before()),h)}n&&Qb(t,i.extensionManager.splittableMarks),e.scrollIntoView()}return m},V3=(n,e={})=>({tr:t,state:r,dispatch:i,editor:o})=>{var s;const a=an(n,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 h=o.extensionManager.attributes;if(l.parent.content.size===0&&l.node(-1).childCount===l.indexAfter(-1)){if(l.depth===2||l.node(-3).type!==a||l.index(-2)!==l.node(-2).childCount-1)return!1;if(i){let y=ie.empty;const w=l.index(-1)?1:l.index(-2)?2:3;for(let R=l.depth-w;R>=l.depth-3;R-=1)y=ie.from(l.node(R).copy(y));const _=l.indexAfter(-1)<l.node(-2).childCount?1:l.indexAfter(-2)<l.node(-3).childCount?2:3,S={...kd(h,l.node().type.name,l.node().attrs),...e},A=((s=a.contentMatch.defaultType)===null||s===void 0?void 0:s.createAndFill(S))||void 0;y=y.append(ie.from(a.createAndFill(null,A)||void 0));const U=l.before(l.depth-(w-1));t.replace(U,l.after(-_),new ye(y,4-w,0));let N=-1;t.doc.nodesBetween(U,t.doc.content.size,(R,E)=>{if(N>-1)return!1;R.isTextblock&&R.content.size===0&&(N=E+1)}),N>-1&&t.setSelection(Ie.near(t.doc.resolve(N))),t.scrollIntoView()}return!0}const p=c.pos===l.end()?u.contentMatchAt(0).defaultType:null,m={...kd(h,u.type.name,u.attrs),...e},v={...kd(h,l.node().type.name,l.node().attrs),...e};t.delete(l.pos,c.pos);const g=p?[{type:a,attrs:m},{type:p,attrs:v}]:[{type:a,attrs:m}];if(!Ii(t.doc,l.pos,2))return!1;if(i){const{selection:y,storedMarks:w}=r,{splittableMarks:_}=o.extensionManager,S=w||y.$to.parentOffset&&y.$from.marks();if(t.split(l.pos,2,g).scrollIntoView(),!S||!i)return!0;const A=S.filter(U=>_.includes(U.type.name));t.ensureMarks(A)}return!0},Eh=(n,e)=>{const t=qg(s=>s.type===e)(n.selection);if(!t)return!0;const r=n.doc.resolve(Math.max(0,t.pos-1)).before(t.depth);if(r===void 0)return!0;const i=n.doc.nodeAt(r);return t.node.type===(i==null?void 0:i.type)&&Mo(n.doc,t.pos)&&n.join(t.pos),!0},Mh=(n,e)=>{const t=qg(s=>s.type===e)(n.selection);if(!t)return!0;const r=n.doc.resolve(t.start).after(t.depth);if(r===void 0)return!0;const i=n.doc.nodeAt(r);return t.node.type===(i==null?void 0:i.type)&&Mo(n.doc,r)&&n.join(r),!0},H3=(n,e,t,r={})=>({editor:i,tr:o,state:s,dispatch:a,chain:l,commands:c,can:d})=>{const{extensions:u,splittableMarks:h}=i.extensionManager,p=an(n,s.schema),m=an(e,s.schema),{selection:v,storedMarks:g}=s,{$from:y,$to:w}=v,_=y.blockRange(w),S=g||v.$to.parentOffset&&v.$from.marks();if(!_)return!1;const A=qg(U=>Xb(U.type.name,u))(v);if(_.depth>=1&&A&&_.depth-A.depth<=1){if(A.node.type===p)return c.liftListItem(m);if(Xb(A.node.type.name,u)&&p.validContent(A.node.content)&&a)return l().command(()=>(o.setNodeMarkup(A.pos,p),!0)).command(()=>Eh(o,p)).command(()=>Mh(o,p)).run()}return!t||!S||!a?l().command(()=>d().wrapInList(p,r)?!0:c.clearNodes()).wrapInList(p,r).command(()=>Eh(o,p)).command(()=>Mh(o,p)).run():l().command(()=>{const U=d().wrapInList(p,r),N=S.filter(R=>h.includes(R.type.name));return o.ensureMarks(N),U?!0:c.clearNodes()}).wrapInList(p,r).command(()=>Eh(o,p)).command(()=>Mh(o,p)).run()},U3=(n,e={},t={})=>({state:r,commands:i})=>{const{extendEmptyMarkRange:o=!1}=t,s=Do(n,r.schema);return tm(r,s,e)?i.unsetMark(s,{extendEmptyMarkRange:o}):i.setMark(s,e)},j3=(n,e,t={})=>({state:r,commands:i})=>{const o=an(n,r.schema),s=an(e,r.schema),a=nc(r,o,t);let l;return r.selection.$anchor.sameParent(r.selection.$head)&&(l=r.selection.$anchor.parent.attrs),a?i.setNode(s,l):i.setNode(o,{...l,...t})},W3=(n,e={})=>({state:t,commands:r})=>{const i=an(n,t.schema);return nc(t,i,e)?r.lift(i):r.wrapIn(i,e)},K3=()=>({state:n,dispatch:e})=>{const t=n.plugins;for(let r=0;r<t.length;r+=1){const i=t[r];let o;if(i.spec.isInputRules&&(o=i.getState(n))){if(e){const s=n.tr,a=o.transform;for(let l=a.steps.length-1;l>=0;l-=1)s.step(a.steps[l].invert(a.docs[l]));if(o.text){const l=s.doc.resolve(o.from).marks();s.replaceWith(o.from,o.to,n.schema.text(o.text,l))}else s.delete(o.from,o.to)}return!0}}return!1},q3=()=>({tr:n,dispatch:e})=>{const{selection:t}=n,{empty:r,ranges:i}=t;return r||e&&i.forEach(o=>{n.removeMark(o.$from.pos,o.$to.pos)}),!0},J3=(n,e={})=>({tr:t,state:r,dispatch:i})=>{var o;const{extendEmptyMarkRange:s=!1}=e,{selection:a}=t,l=Do(n,r.schema),{$from:c,empty:d,ranges:u}=a;if(!i)return!0;if(d&&s){let{from:h,to:p}=a;const m=(o=c.marks().find(g=>g.type===l))===null||o===void 0?void 0:o.attrs,v=Kg(c,l,m);v&&(h=v.from,p=v.to),t.removeMark(h,p,l)}else u.forEach(h=>{t.removeMark(h.$from.pos,h.$to.pos,l)});return t.removeStoredMark(l),!0},Y3=(n,e={})=>({tr:t,state:r,dispatch:i})=>{let o=null,s=null;const a=Mf(typeof n=="string"?n:n.name,r.schema);return a?(a==="node"&&(o=an(n,r.schema)),a==="mark"&&(s=Do(n,r.schema)),i&&t.selection.ranges.forEach(l=>{const c=l.$from.pos,d=l.$to.pos;let u,h,p,m;t.selection.empty?r.doc.nodesBetween(c,d,(v,g)=>{o&&o===v.type&&(p=Math.max(g,c),m=Math.min(g+v.nodeSize,d),u=g,h=v)}):r.doc.nodesBetween(c,d,(v,g)=>{g<c&&o&&o===v.type&&(p=Math.max(g,c),m=Math.min(g+v.nodeSize,d),u=g,h=v),g>=c&&g<=d&&(o&&o===v.type&&t.setNodeMarkup(g,void 0,{...v.attrs,...e}),s&&v.marks.length&&v.marks.forEach(y=>{if(s===y.type){const w=Math.max(g,c),_=Math.min(g+v.nodeSize,d);t.addMark(w,_,s.create({...y.attrs,...e}))}}))}),h&&(u!==void 0&&t.setNodeMarkup(u,void 0,{...h.attrs,...e}),s&&h.marks.length&&h.marks.forEach(v=>{s===v.type&&t.addMark(p,m,s.create({...v.attrs,...e}))}))}),!0):!1},G3=(n,e={})=>({state:t,dispatch:r})=>{const i=an(n,t.schema);return lz(i,e)(t,r)},Z3=(n,e={})=>({state:t,dispatch:r})=>{const i=an(n,t.schema);return cz(i,e)(t,r)};var X3=Object.freeze({__proto__:null,blur:Rz,clearContent:Nz,clearNodes:Iz,command:Pz,createParagraphNear:Lz,cut:zz,deleteCurrentNode:Bz,deleteNode:Fz,deleteRange:Vz,deleteSelection:Hz,enter:Uz,exitCode:jz,extendMarkRange:Wz,first:Kz,focus:Jz,forEach:Yz,insertContent:Gz,insertContentAt:Qz,joinBackward:t3,joinDown:e3,joinForward:n3,joinItemBackward:r3,joinItemForward:i3,joinTextblockBackward:o3,joinTextblockForward:s3,joinUp:$z,keyboardShortcut:l3,lift:c3,liftEmptyBlock:d3,liftListItem:u3,newlineInCode:f3,resetAttributes:h3,scrollIntoView:p3,selectAll:m3,selectNodeBackward:g3,selectNodeForward:v3,selectParentNode:y3,selectTextblockEnd:b3,selectTextblockStart:w3,setContent:x3,setMark:N3,setMeta:I3,setNode:P3,setNodeSelection:L3,setTextSelection:z3,sinkListItem:B3,splitBlock:F3,splitListItem:V3,toggleList:H3,toggleMark:U3,toggleNode:j3,toggleWrap:W3,undoInputRule:K3,unsetAllMarks:q3,unsetMark:J3,updateAttributes:Y3,wrapIn:G3,wrapInList:Z3});const Q3=Et.create({name:"commands",addCommands(){return{...X3}}}),$3=Et.create({name:"drop",addProseMirrorPlugins(){return[new pt({key:new xt("tiptapDrop"),props:{handleDrop:(n,e,t,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:t,moved:r})}}})]}}),e4=Et.create({name:"editable",addProseMirrorPlugins(){return[new pt({key:new xt("editable"),props:{editable:()=>this.editor.options.editable}})]}}),t4=new xt("focusEvents"),n4=Et.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:n}=this;return[new pt({key:t4,props:{handleDOMEvents:{focus:(e,t)=>{n.isFocused=!0;const r=n.state.tr.setMeta("focus",{event:t}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,t)=>{n.isFocused=!1;const r=n.state.tr.setMeta("blur",{event:t}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}}),r4=Et.create({name:"keymap",addKeyboardShortcuts(){const n=()=>this.editor.commands.first(({commands:s})=>[()=>s.undoInputRule(),()=>s.command(({tr:a})=>{const{selection:l,doc:c}=a,{empty:d,$anchor:u}=l,{pos:h,parent:p}=u,m=u.parent.isTextblock&&h>0?a.doc.resolve(h-1):u,v=m.parent.type.spec.isolating,g=u.pos-u.parentOffset,y=v&&m.parent.childCount===1?g===u.pos:Fe.atStart(c).from===h;return!d||!p.type.isTextblock||p.textContent.length||!y||y&&u.parent.type.name==="paragraph"?!1:s.clearNodes()}),()=>s.deleteSelection(),()=>s.joinBackward(),()=>s.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:s})=>[()=>s.deleteSelection(),()=>s.deleteCurrentNode(),()=>s.joinForward(),()=>s.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:s})=>[()=>s.newlineInCode(),()=>s.createParagraphNear(),()=>s.liftEmptyBlock(),()=>s.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:n,"Mod-Backspace":n,"Shift-Backspace":n,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},i={...r},o={...r,"Ctrl-h":n,"Alt-Backspace":n,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return pu()||L_()?o:i},addProseMirrorPlugins(){return[new pt({key:new xt("clearDocument"),appendTransaction:(n,e,t)=>{if(n.some(v=>v.getMeta("composition")))return;const r=n.some(v=>v.docChanged)&&!e.doc.eq(t.doc),i=n.some(v=>v.getMeta("preventClearDocument"));if(!r||i)return;const{empty:o,from:s,to:a}=e.selection,l=Fe.atStart(e.doc).from,c=Fe.atEnd(e.doc).to;if(o||!(s===l&&a===c)||!Of(t.doc))return;const h=t.tr,p=Sf({state:t,transaction:h}),{commands:m}=new Cf({editor:this.editor,state:p});if(m.clearNodes(),!!h.steps.length)return h}})]}}),i4=Et.create({name:"paste",addProseMirrorPlugins(){return[new pt({key:new xt("tiptapPaste"),props:{handlePaste:(n,e,t)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:t})}}})]}}),o4=Et.create({name:"tabindex",addProseMirrorPlugins(){return[new pt({key:new xt("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}});class Bo{get name(){return this.node.type.name}constructor(e,t,r=!1,i=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=t,this.currentNode=i}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return(e=this.actualDepth)!==null&&e!==void 0?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let t=this.from,r=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}t=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:t,to:r},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(this.depth===0)return null;const e=this.resolvedPos.start(this.resolvedPos.depth-1),t=this.resolvedPos.doc.resolve(e);return new Bo(t,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new Bo(e,this.editor)}get after(){let e=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.to+3)),new Bo(e,this.editor)}get children(){const e=[];return this.node.content.forEach((t,r)=>{const i=t.isBlock&&!t.isTextblock,o=t.isAtom&&!t.isText,s=this.pos+r+(o?0:1);if(s<0||s>this.resolvedPos.doc.nodeSize-2)return;const a=this.resolvedPos.doc.resolve(s);if(!i&&a.depth<=this.depth)return;const l=new Bo(a,this.editor,i,i?t:null);i&&(l.actualDepth=this.depth+1),e.push(new Bo(a,this.editor,i,i?t:null))}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,t={}){let r=null,i=this.parent;for(;i&&!r;){if(i.node.type.name===e)if(Object.keys(t).length>0){const o=i.node.attrs,s=Object.keys(t);for(let a=0;a<s.length;a+=1){const l=s[a];if(o[l]!==t[l])break}}else r=i;i=i.parent}return r}querySelector(e,t={}){return this.querySelectorAll(e,t,!0)[0]||null}querySelectorAll(e,t={},r=!1){let i=[];if(!this.children||this.children.length===0)return i;const o=Object.keys(t);return this.children.forEach(s=>{r&&i.length>0||(s.node.type.name===e&&o.every(l=>t[l]===s.node.attrs[l])&&i.push(s),!(r&&i.length>0)&&(i=i.concat(s.querySelectorAll(e,t,r))))}),i}setAttribute(e){const{tr:t}=this.editor.state;t.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(t)}}const s4=`.ProseMirror {
|
|
101
|
-
position: relative;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
.ProseMirror {
|
|
105
|
-
word-wrap: break-word;
|
|
106
|
-
white-space: pre-wrap;
|
|
107
|
-
white-space: break-spaces;
|
|
108
|
-
-webkit-font-variant-ligatures: none;
|
|
109
|
-
font-variant-ligatures: none;
|
|
110
|
-
font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
.ProseMirror [contenteditable="false"] {
|
|
114
|
-
white-space: normal;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
.ProseMirror [contenteditable="false"] [contenteditable="true"] {
|
|
118
|
-
white-space: pre-wrap;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
.ProseMirror pre {
|
|
122
|
-
white-space: pre-wrap;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
img.ProseMirror-separator {
|
|
126
|
-
display: inline !important;
|
|
127
|
-
border: none !important;
|
|
128
|
-
margin: 0 !important;
|
|
129
|
-
width: 0 !important;
|
|
130
|
-
height: 0 !important;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
.ProseMirror-gapcursor {
|
|
134
|
-
display: none;
|
|
135
|
-
pointer-events: none;
|
|
136
|
-
position: absolute;
|
|
137
|
-
margin: 0;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
.ProseMirror-gapcursor:after {
|
|
141
|
-
content: "";
|
|
142
|
-
display: block;
|
|
143
|
-
position: absolute;
|
|
144
|
-
top: -2px;
|
|
145
|
-
width: 20px;
|
|
146
|
-
border-top: 1px solid black;
|
|
147
|
-
animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
@keyframes ProseMirror-cursor-blink {
|
|
151
|
-
to {
|
|
152
|
-
visibility: hidden;
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
.ProseMirror-hideselection *::selection {
|
|
157
|
-
background: transparent;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
.ProseMirror-hideselection *::-moz-selection {
|
|
161
|
-
background: transparent;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
.ProseMirror-hideselection * {
|
|
165
|
-
caret-color: transparent;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
.ProseMirror-focused .ProseMirror-gapcursor {
|
|
169
|
-
display: block;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
.tippy-box[data-animation=fade][data-state=hidden] {
|
|
173
|
-
opacity: 0
|
|
174
|
-
}`;function a4(n,e,t){const r=document.querySelector("style[data-tiptap-style]");if(r!==null)return r;const i=document.createElement("style");return e&&i.setAttribute("nonce",e),i.setAttribute("data-tiptap-style",""),i.innerHTML=n,document.getElementsByTagName("head")[0].appendChild(i),i}let l4=class extends gz{constructor(e={}){super(),this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.options={element:document.createElement("div"),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,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:t})=>{throw t},onPaste:()=>null,onDrop:()=>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("contentError",this.options.onContentError),this.createView(),this.injectCSS(),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:t,slice:r,moved:i})=>this.options.onDrop(t,r,i)),this.on("paste",({event:t,slice:r})=>this.options.onPaste(t,r)),window.setTimeout(()=>{this.isDestroyed||(this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}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&&document&&(this.css=a4(s4,this.options.injectNonce))}setOptions(e={}){this.options={...this.options,...e},!(!this.view||!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})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get state(){return this.view.state}registerPlugin(e,t){const r=M_(t)?t(e,[...this.state.plugins]):[...this.state.plugins,e],i=this.state.reconfigure({plugins:r});return this.view.updateState(i),i}unregisterPlugin(e){if(this.isDestroyed)return;const t=this.state.plugins;let r=t;if([].concat(e).forEach(o=>{const s=typeof o=="string"?`${o}$`:o.key;r=r.filter(a=>!a.key.startsWith(s))}),t.length===r.length)return;const i=this.state.reconfigure({plugins:r});return this.view.updateState(i),i}createExtensionManager(){var e,t;const i=[...this.options.enableCoreExtensions?[e4,Dz.configure({blockSeparator:(t=(e=this.options.coreExtensionOptions)===null||e===void 0?void 0:e.clipboardTextSerializer)===null||t===void 0?void 0:t.blockSeparator}),Q3,n4,r4,o4,$3,i4].filter(o=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[o.name]!==!1:!0):[],...this.options.extensions].filter(o=>["extension","node","mark"].includes(o==null?void 0:o.type));this.extensionManager=new Js(i,this)}createCommandManager(){this.commandManager=new Cf({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createView(){var e;let t;try{t=em(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(s){if(!(s instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(s.message))throw s;this.emit("contentError",{editor:this,error:s,disableCollaboration:()=>{this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(a=>a.name!=="collaboration"),this.createExtensionManager()}}),t=em(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}const r=I_(t,this.options.autofocus);this.view=new m_(this.options.element,{...this.options.editorProps,attributes:{role:"textbox",...(e=this.options.editorProps)===null||e===void 0?void 0:e.attributes},dispatchTransaction:this.dispatchTransaction.bind(this),state:Ks.create({doc:t,selection:r||void 0})});const i=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(i),this.createNodeViews(),this.prependClass();const o=this.view.dom;o.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({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){if(!this.capturedTransaction){this.capturedTransaction=e;return}e.steps.forEach(s=>{var a;return(a=this.capturedTransaction)===null||a===void 0?void 0:a.step(s)});return}const t=this.state.apply(e),r=!this.state.selection.eq(t.selection);this.emit("beforeTransaction",{editor:this,transaction:e,nextState:t}),this.view.updateState(t),this.emit("transaction",{editor:this,transaction:e}),r&&this.emit("selectionUpdate",{editor:this,transaction:e});const i=e.getMeta("focus"),o=e.getMeta("blur");i&&this.emit("focus",{editor:this,event:i.event,transaction:e}),o&&this.emit("blur",{editor:this,event:o.event,transaction:e}),!(!e.docChanged||e.getMeta("preventUpdate"))&&this.emit("update",{editor:this,transaction:e})}getAttributes(e){return F_(this.state,e)}isActive(e,t){const r=typeof e=="string"?e:null,i=typeof e=="string"?t:e;return O3(this.state,r,i)}getJSON(){return this.state.doc.toJSON()}getHTML(){return jg(this.state.doc.content,this.schema)}getText(e){const{blockSeparator:t=`
|
|
175
|
-
|
|
176
|
-
`,textSerializers:r={}}=e||{};return C3(this.state.doc,{blockSeparator:t,textSerializers:{...D_(this.schema),...r}})}get isEmpty(){return Of(this.state.doc)}getCharacterCount(){return console.warn('[tiptap warn]: "editor.getCharacterCount()" is deprecated. Please use "editor.storage.characterCount.characters()" instead.'),this.state.doc.content.size-2}destroy(){if(this.emit("destroy"),this.view){const e=this.view.dom;e&&e.editor&&delete e.editor,this.view.destroy()}this.removeAllListeners()}get isDestroyed(){var e;return!(!((e=this.view)===null||e===void 0)&&e.docView)}$node(e,t){var r;return((r=this.$doc)===null||r===void 0?void 0:r.querySelector(e,t))||null}$nodes(e,t){var r;return((r=this.$doc)===null||r===void 0?void 0:r.querySelectorAll(e,t))||null}$pos(e){const t=this.state.doc.resolve(e);return new Bo(t,this)}get $doc(){return this.$pos(0)}};function _s(n){return new Af({find:n.find,handler:({state:e,range:t,match:r})=>{const i=Ze(n.getAttributes,void 0,r);if(i===!1||i===null)return null;const{tr:o}=e,s=r[r.length-1],a=r[0];if(s){const l=a.search(/\S/),c=t.from+a.indexOf(s),d=c+s.length;if(Jg(t.from,t.to,e.doc).filter(p=>p.mark.type.excluded.find(v=>v===n.type&&v!==p.mark.type)).filter(p=>p.to>c).length)return null;d<t.to&&o.delete(d,t.to),c>t.from&&o.delete(t.from+l,c);const h=t.from+l+s.length;o.addMark(t.from+l,h,n.type.create(i||{})),o.removeStoredMark(n.type)}}})}function c4(n){return new Af({find:n.find,handler:({state:e,range:t,match:r})=>{const i=Ze(n.getAttributes,void 0,r)||{},{tr:o}=e,s=t.from;let a=t.to;const l=n.type.create(i);if(r[1]){const c=r[0].lastIndexOf(r[1]);let d=s+c;d>a?d=a:a=d+r[1].length;const u=r[0][r[0].length-1];o.insertText(u,s+r[0].length-1),o.replaceWith(d,a,l)}else if(r[0]){const c=n.type.isInline?s:s-1;o.insert(c,n.type.create(i)).delete(o.mapping.map(s),o.mapping.map(a))}o.scrollIntoView()}})}function nm(n){return new Af({find:n.find,handler:({state:e,range:t,match:r})=>{const i=e.doc.resolve(t.from),o=Ze(n.getAttributes,void 0,r)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),n.type))return null;e.tr.delete(t.from,t.to).setBlockType(t.from,t.from,n.type,o)}})}function rc(n){return new Af({find:n.find,handler:({state:e,range:t,match:r,chain:i})=>{const o=Ze(n.getAttributes,void 0,r)||{},s=e.tr.delete(t.from,t.to),l=s.doc.resolve(t.from).blockRange(),c=l&&Km(l,n.type,o);if(!c)return null;if(s.wrap(l,c),n.keepMarks&&n.editor){const{selection:u,storedMarks:h}=e,{splittableMarks:p}=n.editor.extensionManager,m=h||u.$to.parentOffset&&u.$from.marks();if(m){const v=m.filter(g=>p.includes(g.type.name));s.ensureMarks(v)}}if(n.keepAttributes){const u=n.type.name==="bulletList"||n.type.name==="orderedList"?"listItem":"taskList";i().updateAttributes(u,o).run()}const d=s.doc.resolve(t.from-1).nodeBefore;d&&d.type===n.type&&Mo(s.doc,t.from-1)&&(!n.joinPredicate||n.joinPredicate(r,d))&&s.join(t.from-1)}})}let Fn=class rm{constructor(e={}){this.type="node",this.name="node",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=Ze(Ae(this,"addOptions",{name:this.name}))),this.storage=Ze(Ae(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new rm(e)}configure(e={}){const t=this.extend({...this.config,addOptions:()=>Ef(this.options,e)});return t.name=this.name,t.parent=this.parent,t}extend(e={}){const t=new rm(e);return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=Ze(Ae(t,"addOptions",{name:t.name})),t.storage=Ze(Ae(t,"addStorage",{name:t.name,options:t.options})),t}};function Eo(n){return new Cz({find:n.find,handler:({state:e,range:t,match:r,pasteEvent:i})=>{const o=Ze(n.getAttributes,void 0,r,i);if(o===!1||o===null)return null;const{tr:s}=e,a=r[r.length-1],l=r[0];let c=t.to;if(a){const d=l.search(/\S/),u=t.from+l.indexOf(a),h=u+a.length;if(Jg(t.from,t.to,e.doc).filter(m=>m.mark.type.excluded.find(g=>g===n.type&&g!==m.mark.type)).filter(m=>m.to>u).length)return null;h<t.to&&s.delete(h,t.to),u>t.from&&s.delete(t.from+d,u),c=t.from+d+a.length,s.addMark(t.from+d,c,n.type.create(o||{})),s.removeStoredMark(n.type)}}})}function d4(n,e){const{selection:t}=n,{$from:r}=t;if(t instanceof Pe){const o=r.index();return r.parent.canReplaceWith(o,o+1,e)}let i=r.depth;for(;i>=0;){const o=r.index(i);if(r.node(i).contentMatchAt(o).matchType(e))return!0;i-=1}return!1}const u4=()=>{let n=!0;return(e,t)=>{if(n){n=!1;try{e()}finally{n=!0}}else t!==void 0&&t()}},f4=/[\uD800-\uDBFF]/,h4=/[\uDC00-\uDFFF]/,p4=(n,e)=>{let t=0,r=0;for(;t<n.length&&t<e.length&&n[t]===e[t];)t++;for(t>0&&f4.test(n[t-1])&&t--;r+t<n.length&&r+t<e.length&&n[n.length-r-1]===e[e.length-r-1];)r++;return r>0&&h4.test(n[n.length-r])&&r--,{index:t,remove:n.length-t-r,insert:e.slice(t,e.length-r)}},m4=p4,Dt=new xt("y-sync"),ii=new xt("y-undo"),qc=new xt("yjs-cursor"),oi=(n,e)=>n>>>e|n<<32-e,g4=n=>oi(n,2)^oi(n,13)^oi(n,22),v4=n=>oi(n,6)^oi(n,11)^oi(n,25),y4=n=>oi(n,7)^oi(n,18)^n>>>3,b4=n=>oi(n,17)^oi(n,19)^n>>>10,w4=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),x4=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);class k4{constructor(){const e=new ArrayBuffer(320);this._H=new Uint32Array(e,0,8),this._H.set(x4),this._W=new Uint32Array(e,64,64)}_updateHash(){const e=this._H,t=this._W;for(let u=16;u<64;u++)t[u]=b4(t[u-2])+t[u-7]+y4(t[u-15])+t[u-16];let r=e[0],i=e[1],o=e[2],s=e[3],a=e[4],l=e[5],c=e[6],d=e[7];for(let u=0,h,p;u<64;u++)h=d+v4(a)+(a&l^~a&c)+w4[u]+t[u]>>>0,p=g4(r)+(r&i^r&o^i&o)>>>0,d=c,c=l,l=a,a=s+h>>>0,s=o,o=i,i=r,r=h+p>>>0;e[0]+=r,e[1]+=i,e[2]+=o,e[3]+=s,e[4]+=a,e[5]+=l,e[6]+=c,e[7]+=d}digest(e){let t=0;for(;t+56<=e.length;){let s=0;for(;s<16&&t+3<e.length;s++)this._W[s]=e[t++]<<24|e[t++]<<16|e[t++]<<8|e[t++];if(t%64!==0){for(this._W.fill(0,s,16);t<e.length;)this._W[s]|=e[t]<<(3-t%4)*8,t++;this._W[s]|=Ln<<(3-t%4)*8}this._updateHash()}const r=t%64!==0;this._W.fill(0,0,16);let i=0;for(;t<e.length;i++)for(let s=3;s>=0&&t<e.length;s--)this._W[i]|=e[t++]<<s*8;r||(this._W[i-(t%4===0?0:1)]|=Ln<<(3-t%4)*8),this._W[14]=e.byteLength/pM,this._W[15]=e.byteLength*8,this._updateHash();const o=new Uint8Array(32);for(let s=0;s<this._H.length;s++)for(let a=0;a<4;a++)o[s*4+a]=this._H[s]>>>(3-a)*8;return o}}const _4=n=>new k4().digest(n),S4=n=>{for(let t=6;t<n.length;t++)n[t%6]=n[t%6]^n[t];return n.slice(0,6)},C4=n=>m2(S4(_4(v2(n)))),mu=(n,e)=>e===void 0?!n.deleted:e.sv.has(n.id.client)&&e.sv.get(n.id.client)>n.id.clock&&!Fa(e.ds,n.id),T4=[{light:"#ecd44433",dark:"#ecd444"}],A4=(n,e,t)=>{if(!n.has(t)){if(n.size<e.length){const r=vs();n.forEach(i=>r.add(i)),e=e.filter(i=>!r.has(i))}n.set(t,JM(e))}return n.get(t)},E4=(n,{colors:e=T4,colorMapping:t=new Map,permanentUserData:r=null,onFirstRender:i=()=>{},mapping:o}={})=>{let s=!1;const a=new O4(n,o),l=new pt({props:{editable:c=>{const d=Dt.getState(c);return d.snapshot==null&&d.prevSnapshot==null}},key:Dt,state:{init:(c,d)=>({type:n,doc:n.doc,binding:a,snapshot:null,prevSnapshot:null,isChangeOrigin:!1,isUndoRedoOperation:!1,addToHistory:!0,colors:e,colorMapping:t,permanentUserData:r}),apply:(c,d)=>{const u=c.getMeta(Dt);if(u!==void 0){d=Object.assign({},d);for(const h in u)d[h]=u[h]}return d.addToHistory=c.getMeta("addToHistory")!==!1,d.isChangeOrigin=u!==void 0&&!!u.isChangeOrigin,d.isUndoRedoOperation=u!==void 0&&!!u.isChangeOrigin&&!!u.isUndoRedoOperation,a.prosemirrorView!==null&&u!==void 0&&(u.snapshot!=null||u.prevSnapshot!=null)&&ag(0,()=>{a.prosemirrorView!=null&&(u.restore==null?a._renderSnapshot(u.snapshot,u.prevSnapshot,d):(a._renderSnapshot(u.snapshot,u.snapshot,d),delete d.restore,delete d.snapshot,delete d.prevSnapshot,a.mux(()=>{a._prosemirrorChanged(a.prosemirrorView.state.doc)})))}),d}},view:c=>(a.initView(c),o==null&&a._forceRerender(),i(),{update:()=>{const d=l.getState(c.state);if(d.snapshot==null&&d.prevSnapshot==null&&(s||c.state.doc.content.findDiffStart(c.state.doc.type.createAndFill().content)!==null)){if(s=!0,d.addToHistory===!1&&!d.isChangeOrigin){const u=ii.getState(c.state),h=u&&u.undoManager;h&&h.stopCapturing()}a.mux(()=>{d.doc.transact(u=>{u.meta.set("addToHistory",d.addToHistory),a._prosemirrorChanged(c.state.doc)},Dt)})}},destroy:()=>{a.destroy()}})});return l},M4=(n,e,t)=>{if(e!==null&&e.anchor!==null&&e.head!==null)if(e.type==="all")n.setSelection(new Kn(n.doc));else if(e.type==="node"){const r=ia(t.doc,t.type,e.anchor,t.mapping);n.setSelection(Pe.create(n.doc,r))}else{const r=ia(t.doc,t.type,e.anchor,t.mapping),i=ia(t.doc,t.type,e.head,t.mapping);if(r!==null&&i!==null){const o=Ie.between(n.doc.resolve(r),n.doc.resolve(i));n.setSelection(o)}}},im=(n,e)=>({type:e.selection.jsonID,anchor:vu(e.selection.anchor,n.type,n.mapping),head:vu(e.selection.head,n.type,n.mapping)});class O4{constructor(e,t=new Map){this.type=e,this.prosemirrorView=null,this.mux=u4(),this.mapping=t,this.isOMark=new Map,this._observeFunction=this._typeChanged.bind(this),this.doc=e.doc,this.beforeTransactionSelection=null,this.beforeAllTransactions=()=>{this.beforeTransactionSelection===null&&this.prosemirrorView!=null&&(this.beforeTransactionSelection=im(this,this.prosemirrorView.state))},this.afterAllTransactions=()=>{this.beforeTransactionSelection=null},this._domSelectionInView=null}get _tr(){return this.prosemirrorView.state.tr.setMeta("addToHistory",!1)}_isLocalCursorInView(){return this.prosemirrorView.hasFocus()?(i1&&this._domSelectionInView===null&&(ag(0,()=>{this._domSelectionInView=null}),this._domSelectionInView=this._isDomSelectionInView()),this._domSelectionInView):!1}_isDomSelectionInView(){const e=this.prosemirrorView._root.getSelection();if(e==null||e.anchorNode==null)return!1;const t=this.prosemirrorView._root.createRange();t.setStart(e.anchorNode,e.anchorOffset),t.setEnd(e.focusNode,e.focusOffset),t.getClientRects().length===0&&t.startContainer&&t.collapsed&&t.selectNodeContents(t.startContainer);const i=t.getBoundingClientRect(),o=_c.documentElement;return i.bottom>=0&&i.right>=0&&i.left<=(window.innerWidth||o.clientWidth||0)&&i.top<=(window.innerHeight||o.clientHeight||0)}renderSnapshot(e,t){t||(t=F1(M1(),new Map)),this.prosemirrorView.dispatch(this._tr.setMeta(Dt,{snapshot:e,prevSnapshot:t}))}unrenderSnapshot(){this.mapping.clear(),this.mux(()=>{const e=this.type.toArray().map(r=>_d(r,this.prosemirrorView.state.schema,this)).filter(r=>r!==null),t=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new ye(ie.from(e),0,0));t.setMeta(Dt,{snapshot:null,prevSnapshot:null}),this.prosemirrorView.dispatch(t)})}_forceRerender(){this.mapping.clear(),this.mux(()=>{const e=this.beforeTransactionSelection!==null?null:this.prosemirrorView.state.selection,t=this.type.toArray().map(i=>_d(i,this.prosemirrorView.state.schema,this)).filter(i=>i!==null),r=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new ye(ie.from(t),0,0));if(e){const i=Pi(Pr(e.anchor,0),r.doc.content.size),o=Pi(Pr(e.head,0),r.doc.content.size);r.setSelection(Ie.create(r.doc,i,o))}this.prosemirrorView.dispatch(r.setMeta(Dt,{isChangeOrigin:!0,binding:this}))})}_renderSnapshot(e,t,r){let i=this.doc,o=this.type;if(e||(e=fh(this.doc)),e instanceof Uint8Array||t instanceof Uint8Array)if((!(e instanceof Uint8Array)||!(t instanceof Uint8Array))&&_n(),i=new ci({gc:!1}),Zd(i,t),t=fh(i),Zd(i,e),e=fh(i),o._item===null){const s=Array.from(this.doc.share.keys()).find(a=>this.doc.share.get(a)===this.type);o=i.getXmlFragment(s)}else{const s=i.store.clients.get(o._item.id.client)??[],a=Lr(s,o._item.id.clock);o=s[a].content.type}this.mapping.clear(),this.mux(()=>{i.transact(s=>{const a=r.permanentUserData;a&&a.dss.forEach(u=>{So(s,u,h=>{})});const l=(u,h)=>{const p=u==="added"?a.getUserByClientId(h.client):a.getUserByDeletedId(h);return{user:p,type:u,color:A4(r.colorMapping,r.colors,p)}},c=Z1(o,new fg(t.ds,e.sv)).map(u=>!u._item.deleted||mu(u._item,e)||mu(u._item,t)?_d(u,this.prosemirrorView.state.schema,{mapping:new Map,isOMark:new Map},e,t,l):null).filter(u=>u!==null),d=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new ye(ie.from(c),0,0));this.prosemirrorView.dispatch(d.setMeta(Dt,{isChangeOrigin:!0}))},Dt)})}_typeChanged(e,t){if(this.prosemirrorView==null)return;const r=Dt.getState(this.prosemirrorView.state);if(e.length===0||r.snapshot!=null||r.prevSnapshot!=null){this.renderSnapshot(r.snapshot,r.prevSnapshot);return}this.mux(()=>{const i=(a,l)=>this.mapping.delete(l);So(t,t.deleteSet,a=>{if(a.constructor===kt){const l=a.content.type;l&&this.mapping.delete(l)}}),t.changed.forEach(i),t.changedParentTypes.forEach(i);const o=this.type.toArray().map(a=>V_(a,this.prosemirrorView.state.schema,this)).filter(a=>a!==null);let s=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new ye(ie.from(o),0,0));M4(s,this.beforeTransactionSelection,this),s=s.setMeta(Dt,{isChangeOrigin:!0,isUndoRedoOperation:t.origin instanceof W1}),this.beforeTransactionSelection!==null&&this._isLocalCursorInView()&&s.scrollIntoView(),this.prosemirrorView.dispatch(s)})}_prosemirrorChanged(e){this.doc.transact(()=>{sm(this.doc,this.type,e,this),this.beforeTransactionSelection=im(this,this.prosemirrorView.state)},Dt)}initView(e){this.prosemirrorView!=null&&this.destroy(),this.prosemirrorView=e,this.doc.on("beforeAllTransactions",this.beforeAllTransactions),this.doc.on("afterAllTransactions",this.afterAllTransactions),this.type.observeDeep(this._observeFunction)}destroy(){this.prosemirrorView!=null&&(this.prosemirrorView=null,this.type.unobserveDeep(this._observeFunction),this.doc.off("beforeAllTransactions",this.beforeAllTransactions),this.doc.off("afterAllTransactions",this.afterAllTransactions))}}const V_=(n,e,t,r,i,o)=>{const s=t.mapping.get(n);if(s===void 0){if(n instanceof Wt)return _d(n,e,t,r,i,o);throw wr()}return s},_d=(n,e,t,r,i,o)=>{const s=[],a=l=>{var c,d;if(l instanceof Wt){const u=V_(l,e,t,r,i,o);u!==null&&s.push(u)}else{const u=(d=(c=l._item.right)==null?void 0:c.content)==null?void 0:d.type;u instanceof Co&&!u._item.deleted&&u._item.id.client===u.doc.clientID&&(l.applyDelta([{retain:l.length},...u.toDelta()]),u.doc.transact(p=>{u._item.delete(p)}));const h=D4(l,e,t,r,i,o);h!==null&&h.forEach(p=>{p!==null&&s.push(p)})}};r===void 0||i===void 0?n.toArray().forEach(a):Z1(n,new fg(i.ds,r.sv)).forEach(a);try{const l=n.getAttributes(r);r!==void 0&&(mu(n._item,r)?mu(n._item,i)||(l.ychange=o?o("added",n._item.id):{type:"added"}):l.ychange=o?o("removed",n._item.id):{type:"removed"});const c=e.node(n.nodeName,l,s);return t.mapping.set(n,c),c}catch{return n.doc.transact(c=>{n._item.delete(c)},Dt),t.mapping.delete(n),null}},D4=(n,e,t,r,i,o)=>{const s=[],a=n.toDelta(r,i,o);try{for(let l=0;l<a.length;l++){const c=a[l];s.push(e.text(c.insert,z4(c.attributes,e)))}}catch{return n.doc.transact(c=>{n._item.delete(c)},Dt),null}return s},R4=(n,e)=>{const t=new yn,r=n.map(i=>({insert:i.text,attributes:U_(i.marks,e)}));return t.applyDelta(r),e.mapping.set(t,n),t},N4=(n,e)=>{const t=new Wt(n.type.name);for(const r in n.attrs){const i=n.attrs[r];i!==null&&r!=="ychange"&&t.setAttribute(r,i)}return t.insert(0,Df(n).map(r=>om(r,e))),e.mapping.set(t,n),t},om=(n,e)=>n instanceof Array?R4(n,e):N4(n,e),$b=n=>typeof n=="object"&&n!==null,Yg=(n,e)=>{const t=Object.keys(n).filter(i=>n[i]!==null);let r=t.length===(e==null?0:Object.keys(e).filter(i=>e[i]!==null).length);for(let i=0;i<t.length&&r;i++){const o=t[i],s=n[o],a=e[o];r=o==="ychange"||s===a||$b(s)&&$b(a)&&Yg(s,a)}return r},Df=n=>{const e=n.content.content,t=[];for(let r=0;r<e.length;r++){const i=e[r];if(i.isText){const o=[];for(let s=e[r];r<e.length&&s.isText;s=e[++r])o.push(s);r--,t.push(o)}else t.push(i)}return t},H_=(n,e)=>{const t=n.toDelta();return t.length===e.length&&t.every((r,i)=>r.insert===e[i].text&&t1(r.attributes||{}).length===e[i].marks.length&&La(r.attributes,(o,s)=>{var c;const a=Gg(s),l=e[i].marks;return Yg(o,(c=l.find(d=>d.type.name===a))==null?void 0:c.attrs)}))},ic=(n,e)=>{if(n instanceof Wt&&!(e instanceof Array)&&am(n,e)){const t=Df(e);return n._length===t.length&&Yg(n.getAttributes(),e.attrs)&&n.toArray().every((r,i)=>ic(r,t[i]))}return n instanceof yn&&e instanceof Array&&H_(n,e)},gu=(n,e)=>n===e||n instanceof Array&&e instanceof Array&&n.length===e.length&&n.every((t,r)=>e[r]===t),e0=(n,e,t)=>{const r=n.toArray(),i=Df(e),o=i.length,s=r.length,a=Pi(s,o);let l=0,c=0,d=!1;for(;l<a;l++){const u=r[l],h=i[l];if(gu(t.mapping.get(u),h))d=!0;else if(!ic(u,h))break}for(;l+c<a;c++){const u=r[s-c-1],h=i[o-c-1];if(gu(t.mapping.get(u),h))d=!0;else if(!ic(u,h))break}return{equalityFactor:l+c,foundMappedChild:d}},I4=n=>{let e="",t=n._start;const r={};for(;t!==null;)t.deleted||(t.countable&&t.content instanceof zr?e+=t.content.str:t.content instanceof qt&&(r[t.content.key]=null)),t=t.right;return{str:e,nAttrs:r}},P4=(n,e,t)=>{t.mapping.set(n,e);const{nAttrs:r,str:i}=I4(n),o=e.map(c=>({insert:c.text,attributes:Object.assign({},r,U_(c.marks,t))})),{insert:s,remove:a,index:l}=m4(i,o.map(c=>c.insert).join(""));n.delete(l,a),n.insert(l,s),n.applyDelta(o.map(c=>({retain:c.insert.length,attributes:c.attributes})))},L4=/(.*)(--[a-zA-Z0-9+/=]{8})$/,Gg=n=>{var e;return((e=L4.exec(n))==null?void 0:e[1])??n},z4=(n,e)=>{const t=[];for(const r in n)t.push(e.mark(Gg(r),n[r]));return t},U_=(n,e)=>{const t={};return n.forEach(r=>{if(r.type.name!=="ychange"){const i=mi(e.isOMark,r.type,()=>!r.type.excludes(r.type));t[i?`${r.type.name}--${C4(r.toJSON())}`:r.type.name]=r.attrs}}),t},sm=(n,e,t,r)=>{if(e instanceof Wt&&e.nodeName!==t.type.name)throw new Error("node name mismatch!");if(r.mapping.set(e,t),e instanceof Wt){const u=e.getAttributes(),h=t.attrs;for(const p in h)h[p]!==null?u[p]!==h[p]&&p!=="ychange"&&e.setAttribute(p,h[p]):e.removeAttribute(p);for(const p in u)h[p]===void 0&&e.removeAttribute(p)}const i=Df(t),o=i.length,s=e.toArray(),a=s.length,l=Pi(o,a);let c=0,d=0;for(;c<l;c++){const u=s[c],h=i[c];if(!gu(r.mapping.get(u),h))if(ic(u,h))r.mapping.set(u,h);else break}for(;d+c<l;d++){const u=s[a-d-1],h=i[o-d-1];if(!gu(r.mapping.get(u),h))if(ic(u,h))r.mapping.set(u,h);else break}n.transact(()=>{for(;a-c-d>0&&o-c-d>0;){const h=s[c],p=i[c],m=s[a-d-1],v=i[o-d-1];if(h instanceof yn&&p instanceof Array)H_(h,p)||P4(h,p,r),c+=1;else{let g=h instanceof Wt&&am(h,p),y=m instanceof Wt&&am(m,v);if(g&&y){const w=e0(h,p,r),_=e0(m,v,r);w.foundMappedChild&&!_.foundMappedChild?y=!1:!w.foundMappedChild&&_.foundMappedChild||w.equalityFactor<_.equalityFactor?g=!1:y=!1}g?(sm(n,h,p,r),c+=1):y?(sm(n,m,v,r),d+=1):(r.mapping.delete(e.get(c)),e.delete(c,1),e.insert(c,[om(p,r)]),c+=1)}}const u=a-c-d;if(a===1&&o===0&&s[0]instanceof yn?(r.mapping.delete(s[0]),s[0].delete(0,s[0].length)):u>0&&(e.slice(c,c+u).forEach(h=>r.mapping.delete(h)),e.delete(c,u)),c+d<o){const h=[];for(let p=c;p<o-d;p++)h.push(om(i[p],r));e.insert(c,h)}},Dt)},am=(n,e)=>!(e instanceof Array)&&n.nodeName===e.type.name;let vl=null;const B4=()=>{const n=vl;vl=null,n.forEach((e,t)=>{const r=t.state.tr,i=Dt.getState(t.state);i&&i.binding&&!i.binding.isDestroyed&&(e.forEach((o,s)=>{r.setMeta(s,o)}),t.dispatch(r))})},F4=(n,e,t)=>{vl||(vl=new Map,ag(0,B4)),mi(vl,n,br).set(e,t)},vu=(n,e,t)=>{if(n===0)return uh(e,0,e.length===0?-1:0);let r=e._first===null?null:e._first.content.type;for(;r!==null&&e!==r;){if(r instanceof yn){if(r._length>=n)return uh(r,n,e.length===0?-1:0);if(n-=r._length,r._item!==null&&r._item.next!==null)r=r._item.next.content.type;else{do r=r._item===null?null:r._item.parent,n--;while(r!==e&&r!==null&&r._item!==null&&r._item.next===null);r!==null&&r!==e&&(r=r._item===null?null:r._item.next.content.type)}}else{const i=(t.get(r)||{nodeSize:0}).nodeSize;if(r._first!==null&&n<i)r=r._first.content.type,n--;else{if(n===1&&r._length===0&&i>1)return new Kl(r._item===null?null:r._item.id,r._item===null?jl(r):null,null);if(n-=i,r._item!==null&&r._item.next!==null)r=r._item.next.content.type;else{if(n===0)return r=r._item===null?r:r._item.parent,new Kl(r._item===null?null:r._item.id,r._item===null?jl(r):null,null);do r=r._item.parent,n--;while(r!==e&&r._item.next===null);r!==e&&(r=r._item.next.content.type)}}}if(r===null)throw _n();if(n===0&&r.constructor!==yn&&r!==e)return V4(r._item.parent,r._item)}return uh(e,e._length,e.length===0?-1:0)},V4=(n,e)=>{let t=null,r=null;return n._item===null?r=jl(n):t=je(n._item.id.client,n._item.id.clock),new Kl(t,r,e.id)},ia=(n,e,t,r)=>{const i=Dp(t,n);if(i===null||i.type!==e&&!Wl(e,i.type._item))return null;let o=i.type,s=0;if(o.constructor===yn)s=i.index;else if(o._item===null||!o._item.deleted){let a=o._first,l=0;for(;l<o._length&&l<i.index&&a!==null;){if(!a.deleted){const c=a.content.type;l++,c instanceof yn?s+=c._length:s+=r.get(c).nodeSize}a=a.right}s+=1}for(;o!==e&&o._item!==null;){const a=o._item.parent;if(a._item===null||!a._item.deleted){s+=1;let l=a._first;for(;l!==null;){const c=l.content.type;if(c===o)break;l.deleted||(c instanceof yn?s+=c._length:s+=r.get(c).nodeSize),l=l.right}}o=a}return s-1};function H4(n){const e=n.toArray(),t=r=>{let i;if(r instanceof yn)i=r.toDelta().map(s=>{const a={type:"text",text:s.insert};return s.attributes&&(a.marks=Object.keys(s.attributes).map(l=>{const c=s.attributes[l],u={type:Gg(l)};return Object.keys(c)&&(u.attrs=c),u})),a});else if(r instanceof Wt){i={type:r.nodeName};const o=r.getAttributes();Object.keys(o).length&&(i.attrs=o);const s=r.toArray();s.length&&(i.content=s.map(t).flat())}else _n();return i};return{type:"doc",content:e.map(t)}}const U4=(n,e,t)=>n!==e,j4=n=>{const e=document.createElement("span");e.classList.add("ProseMirror-yjs-cursor"),e.setAttribute("style",`border-color: ${n.color}`);const t=document.createElement("div");t.setAttribute("style",`background-color: ${n.color}`),t.insertBefore(document.createTextNode(n.name),null);const r=document.createTextNode(""),i=document.createTextNode("");return e.insertBefore(r,null),e.insertBefore(t,null),e.insertBefore(i,null),e},j_=n=>({style:`background-color: ${n.color}70`,class:"ProseMirror-yjs-selection"}),W4=/^#[0-9a-fA-F]{6}$/,t0=(n,e,t,r,i)=>{const o=Dt.getState(n),s=o.doc,a=[];return o.snapshot!=null||o.prevSnapshot!=null||o.binding.mapping.size===0?Qe.create(n.doc,[]):(e.getStates().forEach((l,c)=>{if(t(s.clientID,c,l)&&l.cursor!=null){const d=l.user||{};d.color==null?d.color="#ffa500":W4.test(d.color)||console.warn("A user uses an unsupported color format",d),d.name==null&&(d.name=`User: ${c}`);let u=ia(s,o.type,is(l.cursor.anchor),o.binding.mapping),h=ia(s,o.type,is(l.cursor.head),o.binding.mapping);if(u!==null&&h!==null){const p=Pr(n.doc.content.size-1,0);u=Pi(u,p),h=Pi(h,p),a.push(At.widget(h,()=>r(d,c),{key:c+"",side:10}));const m=Pi(u,h),v=Pr(u,h);a.push(At.inline(m,v,i(d,c),{inclusiveEnd:!0,inclusiveStart:!1}))}}}),Qe.create(n.doc,a))},K4=(n,{awarenessStateFilter:e=U4,cursorBuilder:t=j4,selectionBuilder:r=j_,getSelection:i=s=>s.selection}={},o="cursor")=>new pt({key:qc,state:{init(s,a){return t0(a,n,e,t,r)},apply(s,a,l,c){const d=Dt.getState(c),u=s.getMeta(qc);return d&&d.isChangeOrigin||u&&u.awarenessUpdated?t0(c,n,e,t,r):a.map(s.mapping,s.doc)}},props:{decorations:s=>qc.getState(s)},view:s=>{const a=()=>{s.docView&&F4(s,qc,{awarenessUpdated:!0})},l=()=>{const c=Dt.getState(s.state),d=n.getLocalState()||{};if(s.hasFocus()){const u=i(s.state),h=vu(u.anchor,c.type,c.binding.mapping),p=vu(u.head,c.type,c.binding.mapping);(d.cursor==null||!Vy(is(d.cursor.anchor),h)||!Vy(is(d.cursor.head),p))&&n.setLocalStateField(o,{anchor:h,head:p})}else d.cursor!=null&&ia(c.doc,c.type,is(d.cursor.anchor),c.binding.mapping)!==null&&n.setLocalStateField(o,null)};return n.on("change",a),s.dom.addEventListener("focusin",l),s.dom.addEventListener("focusout",l),{update:l,destroy:()=>{s.dom.removeEventListener("focusin",l),s.dom.removeEventListener("focusout",l),n.off("change",a),n.setLocalStateField(o,null)}}}}),q4=n=>{var e,t;return((t=(e=ii.getState(n))==null?void 0:e.undoManager)==null?void 0:t.undo())!=null},J4=n=>{var e,t;return((t=(e=ii.getState(n))==null?void 0:e.undoManager)==null?void 0:t.redo())!=null},Y4=new Set(["paragraph"]),G4=(n,e)=>!(n instanceof kt)||!(n.content instanceof Fr)||!(n.content.type instanceof Co||n.content.type instanceof Wt&&e.has(n.content.type.nodeName))||n.content.type._length===0,Z4=({protectedNodes:n=Y4,trackedOrigins:e=[],undoManager:t=null}={})=>new pt({key:ii,state:{init:(r,i)=>{const o=Dt.getState(i),s=t||new W1(o.type,{trackedOrigins:new Set([Dt].concat(e)),deleteFilter:a=>G4(a,n),captureTransaction:a=>a.meta.get("addToHistory")!==!1});return{undoManager:s,prevSel:null,hasUndoOps:s.undoStack.length>0,hasRedoOps:s.redoStack.length>0}},apply:(r,i,o,s)=>{const a=Dt.getState(s).binding,l=i.undoManager,c=l.undoStack.length>0,d=l.redoStack.length>0;return a?{undoManager:l,prevSel:im(a,o),hasUndoOps:c,hasRedoOps:d}:c!==i.hasUndoOps||d!==i.hasRedoOps?Object.assign({},i,{hasUndoOps:l.undoStack.length>0,hasRedoOps:l.redoStack.length>0}):i}},view:r=>{const i=Dt.getState(r.state),o=ii.getState(r.state).undoManager;return o.on("stack-item-added",({stackItem:s})=>{const a=i.binding;a&&s.meta.set(a,ii.getState(r.state).prevSel)}),o.on("stack-item-popped",({stackItem:s})=>{const a=i.binding;a&&(a.beforeTransactionSelection=s.meta.get(a)||a.beforeTransactionSelection)}),{destroy:()=>{o.destroy()}}}}),X4=Et.create({name:"collaboration",priority:1e3,addOptions(){return{document:null,field:"default",fragment:null}},addStorage(){return{isDisabled:!1}},onCreate(){this.editor.extensionManager.extensions.find(n=>n.name==="history")&&console.warn('[tiptap warn]: "@tiptap/extension-collaboration" comes with its own history support and is not compatible with "@tiptap/extension-history".')},addCommands(){return{undo:()=>({tr:n,state:e,dispatch:t})=>(n.setMeta("preventDispatch",!0),ii.getState(e).undoManager.undoStack.length===0?!1:t?q4(e):!0),redo:()=>({tr:n,state:e,dispatch:t})=>(n.setMeta("preventDispatch",!0),ii.getState(e).undoManager.redoStack.length===0?!1:t?J4(e):!0)}},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Mod-y":()=>this.editor.commands.redo(),"Shift-Mod-z":()=>this.editor.commands.redo()}},addProseMirrorPlugins(){var n;const e=this.options.fragment?this.options.fragment:this.options.document.getXmlFragment(this.options.field),t=Z4(this.options.yUndoOptions),r=t.spec.view;t.spec.view=s=>{const{undoManager:a}=ii.getState(s.state);a.restore&&(a.restore(),a.restore=()=>{});const l=r?r(s):void 0;return{destroy:()=>{const c=a.trackedOrigins.has(a),d=a._observers;a.restore=()=>{c&&a.trackedOrigins.add(a),a.doc.on("afterTransaction",a.afterTransactionHandler),a._observers=d},l!=null&&l.destroy&&l.destroy()}}};const i={...this.options.ySyncOptions,onFirstRender:this.options.onFirstRender},o=E4(e,i);return this.editor.options.enableContentCheck&&((n=e.doc)===null||n===void 0||n.on("beforeTransaction",()=>{try{const s=H4(e);if(s.content.length===0)return;this.editor.schema.nodeFromJSON(s).check()}catch(s){return this.editor.emit("contentError",{error:s,editor:this.editor,disableCollaboration:()=>{var a;(a=e.doc)===null||a===void 0||a.destroy(),this.storage.isDisabled=!0}}),!1}})),[o,t,this.editor.options.enableContentCheck&&new pt({key:new xt("filterInvalidContent"),filterTransaction:()=>{var s;return this.storage.isDisabled&&((s=e.doc)===null||s===void 0||s.destroy()),!0}})].filter(Boolean)}}),n0=n=>Array.from(n.entries()).map(([e,t])=>({clientId:e,...t.user})),r0=()=>null,Q4=Et.create({name:"collaborationCursor",priority:999,addOptions(){return{provider:null,user:{name:null,color:null},render:n=>{const e=document.createElement("span");e.classList.add("collaboration-cursor__caret"),e.setAttribute("style",`border-color: ${n.color}`);const t=document.createElement("div");return t.classList.add("collaboration-cursor__label"),t.setAttribute("style",`background-color: ${n.color}`),t.insertBefore(document.createTextNode(n.name),null),e.insertBefore(t,null),e},selectionRender:j_,onUpdate:r0}},onCreate(){if(this.options.onUpdate!==r0&&console.warn('[tiptap warn]: DEPRECATED: The "onUpdate" option is deprecated. Please use `editor.storage.collaborationCursor.users` instead. Read more: https://tiptap.dev/api/extensions/collaboration-cursor'),!this.options.provider)throw new Error('The "provider" option is required for the CollaborationCursor extension')},addStorage(){return{users:[]}},addCommands(){return{updateUser:n=>()=>(this.options.user=n,this.options.provider.awareness.setLocalStateField("user",this.options.user),!0),user:n=>({editor:e})=>(console.warn('[tiptap warn]: DEPRECATED: The "user" command is deprecated. Please use "updateUser" instead. Read more: https://tiptap.dev/api/extensions/collaboration-cursor'),e.commands.updateUser(n))}},addProseMirrorPlugins(){return[K4((this.options.provider.awareness.setLocalStateField("user",this.options.user),this.storage.users=n0(this.options.provider.awareness.states),this.options.provider.awareness.on("update",()=>{this.storage.users=n0(this.options.provider.awareness.states)}),this.options.provider.awareness),{cursorBuilder:this.options.render,selectionBuilder:this.options.selectionRender})]}}),$4=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,eB=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,tB=fi.create({name:"highlight",addOptions(){return{multicolor:!1,HTMLAttributes:{}}},addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:n=>n.getAttribute("data-color")||n.style.backgroundColor,renderHTML:n=>n.color?{"data-color":n.color,style:`background-color: ${n.color}; color: inherit`}:{}}}:{}},parseHTML(){return[{tag:"mark"}]},renderHTML({HTMLAttributes:n}){return["mark",zt(this.options.HTMLAttributes,n),0]},addCommands(){return{setHighlight:n=>({commands:e})=>e.setMark(this.name,n),toggleHighlight:n=>({commands:e})=>e.toggleMark(this.name,n),unsetHighlight:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}},addInputRules(){return[_s({find:$4,type:this.type})]},addPasteRules(){return[Eo({find:eB,type:this.type})]}}),nB="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",rB="ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2",lm="numeric",cm="ascii",dm="alpha",yl="asciinumeric",nl="alphanumeric",um="domain",W_="emoji",iB="scheme",oB="slashscheme",Oh="whitespace";function sB(n,e){return n in e||(e[n]=[]),e[n]}function qo(n,e,t){e[lm]&&(e[yl]=!0,e[nl]=!0),e[cm]&&(e[yl]=!0,e[dm]=!0),e[yl]&&(e[nl]=!0),e[dm]&&(e[nl]=!0),e[nl]&&(e[um]=!0),e[W_]&&(e[um]=!0);for(const r in e){const i=sB(r,t);i.indexOf(n)<0&&i.push(n)}}function aB(n,e){const t={};for(const r in e)e[r].indexOf(n)>=0&&(t[r]=!0);return t}function jn(n=null){this.j={},this.jr=[],this.jd=null,this.t=n}jn.groups={};jn.prototype={accepts(){return!!this.t},go(n){const e=this,t=e.j[n];if(t)return t;for(let r=0;r<e.jr.length;r++){const i=e.jr[r][0],o=e.jr[r][1];if(o&&i.test(n))return o}return e.jd},has(n,e=!1){return e?n in this.j:!!this.go(n)},ta(n,e,t,r){for(let i=0;i<n.length;i++)this.tt(n[i],e,t,r)},tr(n,e,t,r){r=r||jn.groups;let i;return e&&e.j?i=e:(i=new jn(e),t&&r&&qo(e,t,r)),this.jr.push([n,i]),i},ts(n,e,t,r){let i=this;const o=n.length;if(!o)return i;for(let s=0;s<o-1;s++)i=i.tt(n[s]);return i.tt(n[o-1],e,t,r)},tt(n,e,t,r){r=r||jn.groups;const i=this;if(e&&e.j)return i.j[n]=e,e;const o=e;let s,a=i.go(n);if(a?(s=new jn,Object.assign(s.j,a.j),s.jr.push.apply(s.jr,a.jr),s.jd=a.jd,s.t=a.t):s=new jn,o){if(r)if(s.t&&typeof s.t=="string"){const l=Object.assign(aB(s.t,r),t);qo(o,l,r)}else t&&qo(o,t,r);s.t=o}return i.j[n]=s,s}};const Ge=(n,e,t,r,i)=>n.ta(e,t,r,i),Rt=(n,e,t,r,i)=>n.tr(e,t,r,i),i0=(n,e,t,r,i)=>n.ts(e,t,r,i),ue=(n,e,t,r,i)=>n.tt(e,t,r,i),xi="WORD",fm="UWORD",K_="ASCIINUMERICAL",q_="ALPHANUMERICAL",oc="LOCALHOST",hm="TLD",pm="UTLD",Sd="SCHEME",Us="SLASH_SCHEME",Zg="NUM",mm="WS",Xg="NL",bl="OPENBRACE",wl="CLOSEBRACE",yu="OPENBRACKET",bu="CLOSEBRACKET",wu="OPENPAREN",xu="CLOSEPAREN",ku="OPENANGLEBRACKET",_u="CLOSEANGLEBRACKET",Su="FULLWIDTHLEFTPAREN",Cu="FULLWIDTHRIGHTPAREN",Tu="LEFTCORNERBRACKET",Au="RIGHTCORNERBRACKET",Eu="LEFTWHITECORNERBRACKET",Mu="RIGHTWHITECORNERBRACKET",Ou="FULLWIDTHLESSTHAN",Du="FULLWIDTHGREATERTHAN",Ru="AMPERSAND",Nu="APOSTROPHE",Iu="ASTERISK",Xi="AT",Pu="BACKSLASH",Lu="BACKTICK",zu="CARET",to="COLON",Qg="COMMA",Bu="DOLLAR",jr="DOT",Fu="EQUALS",$g="EXCLAMATION",sr="HYPHEN",xl="PERCENT",Vu="PIPE",Hu="PLUS",Uu="POUND",kl="QUERY",ev="QUOTE",J_="FULLWIDTHMIDDLEDOT",tv="SEMI",Wr="SLASH",_l="TILDE",ju="UNDERSCORE",Y_="EMOJI",Wu="SYM";var G_=Object.freeze({__proto__:null,ALPHANUMERICAL:q_,AMPERSAND:Ru,APOSTROPHE:Nu,ASCIINUMERICAL:K_,ASTERISK:Iu,AT:Xi,BACKSLASH:Pu,BACKTICK:Lu,CARET:zu,CLOSEANGLEBRACKET:_u,CLOSEBRACE:wl,CLOSEBRACKET:bu,CLOSEPAREN:xu,COLON:to,COMMA:Qg,DOLLAR:Bu,DOT:jr,EMOJI:Y_,EQUALS:Fu,EXCLAMATION:$g,FULLWIDTHGREATERTHAN:Du,FULLWIDTHLEFTPAREN:Su,FULLWIDTHLESSTHAN:Ou,FULLWIDTHMIDDLEDOT:J_,FULLWIDTHRIGHTPAREN:Cu,HYPHEN:sr,LEFTCORNERBRACKET:Tu,LEFTWHITECORNERBRACKET:Eu,LOCALHOST:oc,NL:Xg,NUM:Zg,OPENANGLEBRACKET:ku,OPENBRACE:bl,OPENBRACKET:yu,OPENPAREN:wu,PERCENT:xl,PIPE:Vu,PLUS:Hu,POUND:Uu,QUERY:kl,QUOTE:ev,RIGHTCORNERBRACKET:Au,RIGHTWHITECORNERBRACKET:Mu,SCHEME:Sd,SEMI:tv,SLASH:Wr,SLASH_SCHEME:Us,SYM:Wu,TILDE:_l,TLD:hm,UNDERSCORE:ju,UTLD:pm,UWORD:fm,WORD:xi,WS:mm});const bi=/[a-z]/,Za=new RegExp("\\p{L}","u"),Dh=new RegExp("\\p{Emoji}","u"),wi=/\d/,Rh=/\s/,o0="\r",Nh=`
|
|
177
|
-
`,lB="️",cB="",Ih="";let Jc=null,Yc=null;function dB(n=[]){const e={};jn.groups=e;const t=new jn;Jc==null&&(Jc=s0(nB)),Yc==null&&(Yc=s0(rB)),ue(t,"'",Nu),ue(t,"{",bl),ue(t,"}",wl),ue(t,"[",yu),ue(t,"]",bu),ue(t,"(",wu),ue(t,")",xu),ue(t,"<",ku),ue(t,">",_u),ue(t,"(",Su),ue(t,")",Cu),ue(t,"「",Tu),ue(t,"」",Au),ue(t,"『",Eu),ue(t,"』",Mu),ue(t,"<",Ou),ue(t,">",Du),ue(t,"&",Ru),ue(t,"*",Iu),ue(t,"@",Xi),ue(t,"`",Lu),ue(t,"^",zu),ue(t,":",to),ue(t,",",Qg),ue(t,"$",Bu),ue(t,".",jr),ue(t,"=",Fu),ue(t,"!",$g),ue(t,"-",sr),ue(t,"%",xl),ue(t,"|",Vu),ue(t,"+",Hu),ue(t,"#",Uu),ue(t,"?",kl),ue(t,'"',ev),ue(t,"/",Wr),ue(t,";",tv),ue(t,"~",_l),ue(t,"_",ju),ue(t,"\\",Pu),ue(t,"・",J_);const r=Rt(t,wi,Zg,{[lm]:!0});Rt(r,wi,r);const i=Rt(r,bi,K_,{[yl]:!0}),o=Rt(r,Za,q_,{[nl]:!0}),s=Rt(t,bi,xi,{[cm]:!0});Rt(s,wi,i),Rt(s,bi,s),Rt(i,wi,i),Rt(i,bi,i);const a=Rt(t,Za,fm,{[dm]:!0});Rt(a,bi),Rt(a,wi,o),Rt(a,Za,a),Rt(o,wi,o),Rt(o,bi),Rt(o,Za,o);const l=ue(t,Nh,Xg,{[Oh]:!0}),c=ue(t,o0,mm,{[Oh]:!0}),d=Rt(t,Rh,mm,{[Oh]:!0});ue(t,Ih,d),ue(c,Nh,l),ue(c,Ih,d),Rt(c,Rh,d),ue(d,o0),ue(d,Nh),Rt(d,Rh,d),ue(d,Ih,d);const u=Rt(t,Dh,Y_,{[W_]:!0});ue(u,"#"),Rt(u,Dh,u),ue(u,lB,u);const h=ue(u,cB);ue(h,"#"),Rt(h,Dh,u);const p=[[bi,s],[wi,i]],m=[[bi,null],[Za,a],[wi,o]];for(let v=0;v<Jc.length;v++)Ji(t,Jc[v],hm,xi,p);for(let v=0;v<Yc.length;v++)Ji(t,Yc[v],pm,fm,m);qo(hm,{tld:!0,ascii:!0},e),qo(pm,{utld:!0,alpha:!0},e),Ji(t,"file",Sd,xi,p),Ji(t,"mailto",Sd,xi,p),Ji(t,"http",Us,xi,p),Ji(t,"https",Us,xi,p),Ji(t,"ftp",Us,xi,p),Ji(t,"ftps",Us,xi,p),qo(Sd,{scheme:!0,ascii:!0},e),qo(Us,{slashscheme:!0,ascii:!0},e),n=n.sort((v,g)=>v[0]>g[0]?1:-1);for(let v=0;v<n.length;v++){const g=n[v][0],w=n[v][1]?{[iB]:!0}:{[oB]:!0};g.indexOf("-")>=0?w[um]=!0:bi.test(g)?wi.test(g)?w[yl]=!0:w[cm]=!0:w[lm]=!0,i0(t,g,g,w)}return i0(t,"localhost",oc,{ascii:!0}),t.jd=new jn(Wu),{start:t,tokens:Object.assign({groups:e},G_)}}function Z_(n,e){const t=uB(e.replace(/[A-Z]/g,a=>a.toLowerCase())),r=t.length,i=[];let o=0,s=0;for(;s<r;){let a=n,l=null,c=0,d=null,u=-1,h=-1;for(;s<r&&(l=a.go(t[s]));)a=l,a.accepts()?(u=0,h=0,d=a):u>=0&&(u+=t[s].length,h++),c+=t[s].length,o+=t[s].length,s++;o-=u,s-=h,c-=u,i.push({t:d.t,v:e.slice(o-c,o),s:o-c,e:o})}return i}function uB(n){const e=[],t=n.length;let r=0;for(;r<t;){let i=n.charCodeAt(r),o,s=i<55296||i>56319||r+1===t||(o=n.charCodeAt(r+1))<56320||o>57343?n[r]:n.slice(r,r+2);e.push(s),r+=s.length}return e}function Ji(n,e,t,r,i){let o;const s=e.length;for(let a=0;a<s-1;a++){const l=e[a];n.j[l]?o=n.j[l]:(o=new jn(r),o.jr=i.slice(),n.j[l]=o),n=o}return o=new jn(t),o.jr=i.slice(),n.j[e[s-1]]=o,o}function s0(n){const e=[],t=[];let r=0,i="0123456789";for(;r<n.length;){let o=0;for(;i.indexOf(n[r+o])>=0;)o++;if(o>0){e.push(t.join(""));for(let s=parseInt(n.substring(r,r+o),10);s>0;s--)t.pop();r+=o}else t.push(n[r]),r++}return e}const sc={defaultProtocol:"http",events:null,format:a0,formatHref:a0,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function nv(n,e=null){let t=Object.assign({},sc);n&&(t=Object.assign(t,n instanceof nv?n.o:n));const r=t.ignoreTags,i=[];for(let o=0;o<r.length;o++)i.push(r[o].toUpperCase());this.o=t,e&&(this.defaultRender=e),this.ignoreTags=i}nv.prototype={o:sc,ignoreTags:[],defaultRender(n){return n},check(n){return this.get("validate",n.toString(),n)},get(n,e,t){const r=e!=null;let i=this.o[n];return i&&(typeof i=="object"?(i=t.t in i?i[t.t]:sc[n],typeof i=="function"&&r&&(i=i(e,t))):typeof i=="function"&&r&&(i=i(e,t.t,t)),i)},getObj(n,e,t){let r=this.o[n];return typeof r=="function"&&e!=null&&(r=r(e,t.t,t)),r},render(n){const e=n.render(this);return(this.get("render",null,n)||this.defaultRender)(e,n.t,n)}};function a0(n){return n}function X_(n,e){this.t="token",this.v=n,this.tk=e}X_.prototype={isLink:!1,toString(){return this.v},toHref(n){return this.toString()},toFormattedString(n){const e=this.toString(),t=n.get("truncate",e,this),r=n.get("format",e,this);return t&&r.length>t?r.substring(0,t)+"…":r},toFormattedHref(n){return n.get("formatHref",this.toHref(n.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(n=sc.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(n),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(n){return{type:this.t,value:this.toFormattedString(n),isLink:this.isLink,href:this.toFormattedHref(n),start:this.startIndex(),end:this.endIndex()}},validate(n){return n.get("validate",this.toString(),this)},render(n){const e=this,t=this.toHref(n.get("defaultProtocol")),r=n.get("formatHref",t,this),i=n.get("tagName",t,e),o=this.toFormattedString(n),s={},a=n.get("className",t,e),l=n.get("target",t,e),c=n.get("rel",t,e),d=n.getObj("attributes",t,e),u=n.getObj("events",t,e);return s.href=r,a&&(s.class=a),l&&(s.target=l),c&&(s.rel=c),d&&Object.assign(s,d),{tagName:i,attributes:s,content:o,eventListeners:u}}};function Rf(n,e){class t extends X_{constructor(i,o){super(i,o),this.t=n}}for(const r in e)t.prototype[r]=e[r];return t.t=n,t}const l0=Rf("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),c0=Rf("text"),fB=Rf("nl"),Gc=Rf("url",{isLink:!0,toHref(n=sc.defaultProtocol){return this.hasProtocol()?this.v:`${n}://${this.v}`},hasProtocol(){const n=this.tk;return n.length>=2&&n[0].t!==oc&&n[1].t===to}}),or=n=>new jn(n);function hB({groups:n}){const e=n.domain.concat([Ru,Iu,Xi,Pu,Lu,zu,Bu,Fu,sr,Zg,xl,Vu,Hu,Uu,Wr,Wu,_l,ju]),t=[Nu,to,Qg,jr,$g,xl,kl,ev,tv,ku,_u,bl,wl,bu,yu,wu,xu,Su,Cu,Tu,Au,Eu,Mu,Ou,Du],r=[Ru,Nu,Iu,Pu,Lu,zu,Bu,Fu,sr,bl,wl,xl,Vu,Hu,Uu,kl,Wr,Wu,_l,ju],i=or(),o=ue(i,_l);Ge(o,r,o),Ge(o,n.domain,o);const s=or(),a=or(),l=or();Ge(i,n.domain,s),Ge(i,n.scheme,a),Ge(i,n.slashscheme,l),Ge(s,r,o),Ge(s,n.domain,s);const c=ue(s,Xi);ue(o,Xi,c),ue(a,Xi,c),ue(l,Xi,c);const d=ue(o,jr);Ge(d,r,o),Ge(d,n.domain,o);const u=or();Ge(c,n.domain,u),Ge(u,n.domain,u);const h=ue(u,jr);Ge(h,n.domain,u);const p=or(l0);Ge(h,n.tld,p),Ge(h,n.utld,p),ue(c,oc,p);const m=ue(u,sr);ue(m,sr,m),Ge(m,n.domain,u),Ge(p,n.domain,u),ue(p,jr,h),ue(p,sr,m);const v=ue(p,to);Ge(v,n.numeric,l0);const g=ue(s,sr),y=ue(s,jr);ue(g,sr,g),Ge(g,n.domain,s),Ge(y,r,o),Ge(y,n.domain,s);const w=or(Gc);Ge(y,n.tld,w),Ge(y,n.utld,w),Ge(w,n.domain,s),Ge(w,r,o),ue(w,jr,y),ue(w,sr,g),ue(w,Xi,c);const _=ue(w,to),S=or(Gc);Ge(_,n.numeric,S);const A=or(Gc),U=or();Ge(A,e,A),Ge(A,t,U),Ge(U,e,A),Ge(U,t,U),ue(w,Wr,A),ue(S,Wr,A);const N=ue(a,to),R=ue(l,to),E=ue(R,Wr),q=ue(E,Wr);Ge(a,n.domain,s),ue(a,jr,y),ue(a,sr,g),Ge(l,n.domain,s),ue(l,jr,y),ue(l,sr,g),Ge(N,n.domain,A),ue(N,Wr,A),ue(N,kl,A),Ge(q,n.domain,A),Ge(q,e,A),ue(q,Wr,A);const te=[[bl,wl],[yu,bu],[wu,xu],[ku,_u],[Su,Cu],[Tu,Au],[Eu,Mu],[Ou,Du]];for(let K=0;K<te.length;K++){const[V,ee]=te[K],se=ue(A,V);ue(U,V,se),ue(se,ee,A);const F=or(Gc);Ge(se,e,F);const X=or();Ge(se,t),Ge(F,e,F),Ge(F,t,X),Ge(X,e,F),Ge(X,t,X),ue(F,ee,A),ue(X,ee,A)}return ue(i,oc,w),ue(i,Xg,fB),{start:i,tokens:G_}}function pB(n,e,t){let r=t.length,i=0,o=[],s=[];for(;i<r;){let a=n,l=null,c=null,d=0,u=null,h=-1;for(;i<r&&!(l=a.go(t[i].t));)s.push(t[i++]);for(;i<r&&(c=l||a.go(t[i].t));)l=null,a=c,a.accepts()?(h=0,u=a):h>=0&&h++,i++,d++;if(h<0)i-=d,i<r&&(s.push(t[i]),i++);else{s.length>0&&(o.push(Ph(c0,e,s)),s=[]),i-=h,d-=h;const p=u.t,m=t.slice(i-d,i);o.push(Ph(p,e,m))}}return s.length>0&&o.push(Ph(c0,e,s)),o}function Ph(n,e,t){const r=t[0].s,i=t[t.length-1].e,o=e.slice(r,i);return new n(o,t)}const mB=typeof console<"u"&&console&&console.warn||(()=>{}),gB="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",Ct={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function vB(){return jn.groups={},Ct.scanner=null,Ct.parser=null,Ct.tokenQueue=[],Ct.pluginQueue=[],Ct.customSchemes=[],Ct.initialized=!1,Ct}function d0(n,e=!1){if(Ct.initialized&&mB(`linkifyjs: already initialized - will not register custom scheme "${n}" ${gB}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(n))throw new Error(`linkifyjs: incorrect scheme format.
|
|
178
|
-
1. Must only contain digits, lowercase ASCII letters or "-"
|
|
179
|
-
2. Cannot start or end with "-"
|
|
180
|
-
3. "-" cannot repeat`);Ct.customSchemes.push([n,e])}function yB(){Ct.scanner=dB(Ct.customSchemes);for(let n=0;n<Ct.tokenQueue.length;n++)Ct.tokenQueue[n][1]({scanner:Ct.scanner});Ct.parser=hB(Ct.scanner.tokens);for(let n=0;n<Ct.pluginQueue.length;n++)Ct.pluginQueue[n][1]({scanner:Ct.scanner,parser:Ct.parser});return Ct.initialized=!0,Ct}function rv(n){return Ct.initialized||yB(),pB(Ct.parser.start,n,Z_(Ct.scanner.start,n))}rv.scan=Z_;function Q_(n,e=null,t=null){if(e&&typeof e=="object"){if(t)throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);t=e,e=null}const r=new nv(t),i=rv(n),o=[];for(let s=0;s<i.length;s++){const a=i[s];a.isLink&&(!e||a.t===e)&&r.check(a)&&o.push(a.toFormattedObject(r))}return o}const iv="[\0- -\u2029 ]",bB=new RegExp(iv),wB=new RegExp(`${iv}$`),xB=new RegExp(iv,"g");function kB(n){return n.length===1?n[0].isLink:n.length===3&&n[1].isLink?["()","[]"].includes(n[0].value+n[2].value):!1}function _B(n){return new pt({key:new xt("autolink"),appendTransaction:(e,t,r)=>{const i=e.some(c=>c.docChanged)&&!t.doc.eq(r.doc),o=e.some(c=>c.getMeta("preventAutolink"));if(!i||o)return;const{tr:s}=r,a=k3(t.doc,[...e]);if(M3(a).forEach(({newRange:c})=>{const d=S3(r.doc,c,p=>p.isTextblock);let u,h;if(d.length>1)u=d[0],h=r.doc.textBetween(u.pos,u.pos+u.node.nodeSize,void 0," ");else if(d.length){const p=r.doc.textBetween(c.from,c.to," "," ");if(!wB.test(p))return;u=d[0],h=r.doc.textBetween(u.pos,c.to,void 0," ")}if(u&&h){const p=h.split(bB).filter(Boolean);if(p.length<=0)return!1;const m=p[p.length-1],v=u.pos+h.lastIndexOf(m);if(!m)return!1;const g=rv(m).map(y=>y.toObject(n.defaultProtocol));if(!kB(g))return!1;g.filter(y=>y.isLink).map(y=>({...y,from:v+y.start+1,to:v+y.end+1})).filter(y=>r.schema.marks.code?!r.doc.rangeHasMark(y.from,y.to,r.schema.marks.code):!0).filter(y=>n.validate(y.value)).filter(y=>n.shouldAutoLink(y.value)).forEach(y=>{Jg(y.from,y.to,r.doc).some(w=>w.mark.type===n.type)||s.addMark(y.from,y.to,n.type.create({href:y.href}))})}}),!!s.steps.length)return s}})}function SB(n){return new pt({key:new xt("handleClickLink"),props:{handleClick:(e,t,r)=>{var i,o;if(r.button!==0||!e.editable)return!1;let s=r.target;const a=[];for(;s.nodeName!=="DIV";)a.push(s),s=s.parentNode;if(!a.find(h=>h.nodeName==="A"))return!1;const l=F_(e.state,n.type.name),c=r.target,d=(i=c==null?void 0:c.href)!==null&&i!==void 0?i:l.href,u=(o=c==null?void 0:c.target)!==null&&o!==void 0?o:l.target;return c&&d?(window.open(d,u),!0):!1}}})}function CB(n){return new pt({key:new xt("handlePasteLink"),props:{handlePaste:(e,t,r)=>{const{state:i}=e,{selection:o}=i,{empty:s}=o;if(s)return!1;let a="";r.content.forEach(c=>{a+=c.textContent});const l=Q_(a,{defaultProtocol:n.defaultProtocol}).find(c=>c.isLink&&c.value===a);return!a||!l?!1:n.editor.commands.setMark(n.type,{href:l.href})}}})}function Po(n,e){const t=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(r=>{const i=typeof r=="string"?r:r.scheme;i&&t.push(i)}),!n||n.replace(xB,"").match(new RegExp(`^(?:(?:${t.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}const TB=fi.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(n=>{if(typeof n=="string"){d0(n);return}d0(n.scheme,n.optionalSlashes)})},onDestroy(){vB()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(n,e)=>!!Po(n,e.protocols),validate:n=>!!n,shouldAutoLink:n=>!!n}},addAttributes(){return{href:{default:null,parseHTML(n){return n.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:n=>{const e=n.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:t=>!!Po(t,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:n}){return this.options.isAllowedUri(n.href,{defaultValidate:e=>!!Po(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",zt(this.options.HTMLAttributes,n),0]:["a",zt(this.options.HTMLAttributes,{...n,href:""}),0]},addCommands(){return{setLink:n=>({chain:e})=>{const{href:t}=n;return this.options.isAllowedUri(t,{defaultValidate:r=>!!Po(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,n).setMeta("preventAutolink",!0).run():!1},toggleLink:n=>({chain:e})=>{const{href:t}=n;return this.options.isAllowedUri(t,{defaultValidate:r=>!!Po(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().toggleMark(this.name,n,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run():!1},unsetLink:()=>({chain:n})=>n().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[Eo({find:n=>{const e=[];if(n){const{protocols:t,defaultProtocol:r}=this.options,i=Q_(n).filter(o=>o.isLink&&this.options.isAllowedUri(o.value,{defaultValidate:s=>!!Po(s,t),protocols:t,defaultProtocol:r}));i.length&&i.forEach(o=>e.push({text:o.value,data:{href:o.href},index:o.start}))}return e},type:this.type,getAttributes:n=>{var e;return{href:(e=n.data)===null||e===void 0?void 0:e.href}}})]},addProseMirrorPlugins(){const n=[],{protocols:e,defaultProtocol:t}=this.options;return this.options.autolink&&n.push(_B({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:i=>!!Po(i,e),protocols:e,defaultProtocol:t}),shouldAutoLink:this.options.shouldAutoLink})),this.options.openOnClick===!0&&n.push(SB({type:this.type})),this.options.linkOnPaste&&n.push(CB({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type})),n}}),AB=Et.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new pt({key:new xt("placeholder"),props:{decorations:({doc:n,selection:e})=>{const t=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:r}=e,i=[];if(!t)return null;const o=this.editor.isEmpty;return n.descendants((s,a)=>{const l=r>=a&&r<=a+s.nodeSize,c=!s.isLeaf&&Of(s);if((l||!this.options.showOnlyCurrent)&&c){const d=[this.options.emptyNodeClass];o&&d.push(this.options.emptyEditorClass);const u=At.node(a,a+s.nodeSize,{class:d.join(" "),"data-placeholder":typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:s,pos:a,hasAnchor:l}):this.options.placeholder});i.push(u)}return this.options.includeChildren}),Qe.create(n,i)}}})]}});let gm,vm;if(typeof WeakMap<"u"){let n=new WeakMap;gm=e=>n.get(e),vm=(e,t)=>(n.set(e,t),t)}else{const n=[];let t=0;gm=r=>{for(let i=0;i<n.length;i+=2)if(n[i]==r)return n[i+1]},vm=(r,i)=>(t==10&&(t=0),n[t++]=r,n[t++]=i)}var It=class{constructor(n,e,t,r){this.width=n,this.height=e,this.map=t,this.problems=r}findCell(n){for(let e=0;e<this.map.length;e++){const t=this.map[e];if(t!=n)continue;const r=e%this.width,i=e/this.width|0;let o=r+1,s=i+1;for(let a=1;o<this.width&&this.map[e+a]==t;a++)o++;for(let a=1;s<this.height&&this.map[e+this.width*a]==t;a++)s++;return{left:r,top:i,right:o,bottom:s}}throw new RangeError(`No cell with offset ${n} found`)}colCount(n){for(let e=0;e<this.map.length;e++)if(this.map[e]==n)return e%this.width;throw new RangeError(`No cell with offset ${n} found`)}nextCell(n,e,t){const{left:r,right:i,top:o,bottom:s}=this.findCell(n);return e=="horiz"?(t<0?r==0:i==this.width)?null:this.map[o*this.width+(t<0?r-1:i)]:(t<0?o==0:s==this.height)?null:this.map[r+this.width*(t<0?o-1:s)]}rectBetween(n,e){const{left:t,right:r,top:i,bottom:o}=this.findCell(n),{left:s,right:a,top:l,bottom:c}=this.findCell(e);return{left:Math.min(t,s),top:Math.min(i,l),right:Math.max(r,a),bottom:Math.max(o,c)}}cellsInRect(n){const e=[],t={};for(let r=n.top;r<n.bottom;r++)for(let i=n.left;i<n.right;i++){const o=r*this.width+i,s=this.map[o];t[s]||(t[s]=!0,!(i==n.left&&i&&this.map[o-1]==s||r==n.top&&r&&this.map[o-this.width]==s)&&e.push(s))}return e}positionAt(n,e,t){for(let r=0,i=0;;r++){const o=i+t.child(r).nodeSize;if(r==n){let s=e+n*this.width;const a=(n+1)*this.width;for(;s<a&&this.map[s]<i;)s++;return s==a?o-1:this.map[s]}i=o}}static get(n){return gm(n)||vm(n,EB(n))}};function EB(n){if(n.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+n.type.name);const e=MB(n),t=n.childCount,r=[];let i=0,o=null;const s=[];for(let c=0,d=e*t;c<d;c++)r[c]=0;for(let c=0,d=0;c<t;c++){const u=n.child(c);d++;for(let m=0;;m++){for(;i<r.length&&r[i]!=0;)i++;if(m==u.childCount)break;const v=u.child(m),{colspan:g,rowspan:y,colwidth:w}=v.attrs;for(let _=0;_<y;_++){if(_+c>=t){(o||(o=[])).push({type:"overlong_rowspan",pos:d,n:y-_});break}const S=i+_*e;for(let A=0;A<g;A++){r[S+A]==0?r[S+A]=d:(o||(o=[])).push({type:"collision",row:c,pos:d,n:g-A});const U=w&&w[A];if(U){const N=(S+A)%e*2,R=s[N];R==null||R!=U&&s[N+1]==1?(s[N]=U,s[N+1]=1):R==U&&s[N+1]++}}}i+=g,d+=v.nodeSize}const h=(c+1)*e;let p=0;for(;i<h;)r[i++]==0&&p++;p&&(o||(o=[])).push({type:"missing",row:c,n:p}),d++}(e===0||t===0)&&(o||(o=[])).push({type:"zero_sized"});const a=new It(e,t,r,o);let l=!1;for(let c=0;!l&&c<s.length;c+=2)s[c]!=null&&s[c+1]<t&&(l=!0);return l&&OB(a,s,n),a}function MB(n){let e=-1,t=!1;for(let r=0;r<n.childCount;r++){const i=n.child(r);let o=0;if(t)for(let s=0;s<r;s++){const a=n.child(s);for(let l=0;l<a.childCount;l++){const c=a.child(l);s+c.attrs.rowspan>r&&(o+=c.attrs.colspan)}}for(let s=0;s<i.childCount;s++){const a=i.child(s);o+=a.attrs.colspan,a.attrs.rowspan>1&&(t=!0)}e==-1?e=o:e!=o&&(e=Math.max(e,o))}return e}function OB(n,e,t){n.problems||(n.problems=[]);const r={};for(let i=0;i<n.map.length;i++){const o=n.map[i];if(r[o])continue;r[o]=!0;const s=t.nodeAt(o);if(!s)throw new RangeError(`No cell with offset ${o} found`);let a=null;const l=s.attrs;for(let c=0;c<l.colspan;c++){const d=e[(i+c)%n.width*2];d!=null&&(!l.colwidth||l.colwidth[c]!=d)&&((a||(a=DB(l)))[c]=d)}a&&n.problems.unshift({type:"colwidth mismatch",pos:o,colwidth:a})}}function DB(n){if(n.colwidth)return n.colwidth.slice();const e=[];for(let t=0;t<n.colspan;t++)e.push(0);return e}function Cn(n){let e=n.cached.tableNodeTypes;if(!e){e=n.cached.tableNodeTypes={};for(const t in n.nodes){const r=n.nodes[t],i=r.spec.tableRole;i&&(e[i]=r)}}return e}const no=new xt("selectingCells");function Ss(n){for(let e=n.depth-1;e>0;e--)if(n.node(e).type.spec.tableRole=="row")return n.node(0).resolve(n.before(e+1));return null}function RB(n){for(let e=n.depth;e>0;e--){const t=n.node(e).type.spec.tableRole;if(t==="cell"||t==="header_cell")return n.node(e)}return null}function Vr(n){const e=n.selection.$head;for(let t=e.depth;t>0;t--)if(e.node(t).type.spec.tableRole=="row")return!0;return!1}function Nf(n){const e=n.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&e.node.type.spec.tableRole=="cell")return e.$anchor;const t=Ss(e.$head)||NB(e.$head);if(t)return t;throw new RangeError(`No cell found around position ${e.head}`)}function NB(n){for(let e=n.nodeAfter,t=n.pos;e;e=e.firstChild,t++){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return n.doc.resolve(t)}for(let e=n.nodeBefore,t=n.pos;e;e=e.lastChild,t--){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return n.doc.resolve(t-e.nodeSize)}}function ym(n){return n.parent.type.spec.tableRole=="row"&&!!n.nodeAfter}function IB(n){return n.node(0).resolve(n.pos+n.nodeAfter.nodeSize)}function ov(n,e){return n.depth==e.depth&&n.pos>=e.start(-1)&&n.pos<=e.end(-1)}function $_(n,e,t){const r=n.node(-1),i=It.get(r),o=n.start(-1),s=i.nextCell(n.pos-o,e,t);return s==null?null:n.node(0).resolve(o+s)}function Cs(n,e,t=1){const r={...n,colspan:n.colspan-t};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,t),r.colwidth.some(i=>i>0)||(r.colwidth=null)),r}function eS(n,e,t=1){const r={...n,colspan:n.colspan+t};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let i=0;i<t;i++)r.colwidth.splice(e,0,0)}return r}function PB(n,e,t){const r=Cn(e.type.schema).header_cell;for(let i=0;i<n.height;i++)if(e.nodeAt(n.map[t+i*n.width]).type!=r)return!1;return!0}var _t=class ki extends Fe{constructor(e,t=e){const r=e.node(-1),i=It.get(r),o=e.start(-1),s=i.rectBetween(e.pos-o,t.pos-o),a=e.node(0),l=i.cellsInRect(s).filter(d=>d!=t.pos-o);l.unshift(t.pos-o);const c=l.map(d=>{const u=r.nodeAt(d);if(!u)throw new RangeError(`No cell with offset ${d} found`);const h=o+d+1;return new Bx(a.resolve(h),a.resolve(h+u.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=t}map(e,t){const r=e.resolve(t.map(this.$anchorCell.pos)),i=e.resolve(t.map(this.$headCell.pos));if(ym(r)&&ym(i)&&ov(r,i)){const o=this.$anchorCell.node(-1)!=r.node(-1);return o&&this.isRowSelection()?ki.rowSelection(r,i):o&&this.isColSelection()?ki.colSelection(r,i):new ki(r,i)}return Ie.between(r,i)}content(){const e=this.$anchorCell.node(-1),t=It.get(e),r=this.$anchorCell.start(-1),i=t.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),o={},s=[];for(let l=i.top;l<i.bottom;l++){const c=[];for(let d=l*t.width+i.left,u=i.left;u<i.right;u++,d++){const h=t.map[d];if(o[h])continue;o[h]=!0;const p=t.findCell(h);let m=e.nodeAt(h);if(!m)throw new RangeError(`No cell with offset ${h} found`);const v=i.left-p.left,g=p.right-i.right;if(v>0||g>0){let y=m.attrs;if(v>0&&(y=Cs(y,0,v)),g>0&&(y=Cs(y,y.colspan-g,g)),p.left<i.left){if(m=m.type.createAndFill(y),!m)throw new RangeError(`Could not create cell with attrs ${JSON.stringify(y)}`)}else m=m.type.create(y,m.content)}if(p.top<i.top||p.bottom>i.bottom){const y={...m.attrs,rowspan:Math.min(p.bottom,i.bottom)-Math.max(p.top,i.top)};p.top<i.top?m=m.type.createAndFill(y):m=m.type.create(y,m.content)}c.push(m)}s.push(e.child(l).copy(ie.from(c)))}const a=this.isColSelection()&&this.isRowSelection()?e:s;return new ye(ie.from(a),1,1)}replace(e,t=ye.empty){const r=e.steps.length,i=this.ranges;for(let s=0;s<i.length;s++){const{$from:a,$to:l}=i[s],c=e.mapping.slice(r);e.replace(c.map(a.pos),c.map(l.pos),s?ye.empty:t)}const o=Fe.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);o&&e.setSelection(o)}replaceWith(e,t){this.replace(e,new ye(ie.from(t),0,0))}forEachCell(e){const t=this.$anchorCell.node(-1),r=It.get(t),i=this.$anchorCell.start(-1),o=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-i,this.$headCell.pos-i));for(let s=0;s<o.length;s++)e(t.nodeAt(o[s]),i+o[s])}isColSelection(){const e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;const r=e+this.$anchorCell.nodeAfter.attrs.rowspan,i=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,i)==this.$headCell.node(-1).childCount}static colSelection(e,t=e){const r=e.node(-1),i=It.get(r),o=e.start(-1),s=i.findCell(e.pos-o),a=i.findCell(t.pos-o),l=e.node(0);return s.top<=a.top?(s.top>0&&(e=l.resolve(o+i.map[s.left])),a.bottom<i.height&&(t=l.resolve(o+i.map[i.width*(i.height-1)+a.right-1]))):(a.top>0&&(t=l.resolve(o+i.map[a.left])),s.bottom<i.height&&(e=l.resolve(o+i.map[i.width*(i.height-1)+s.right-1]))),new ki(e,t)}isRowSelection(){const e=this.$anchorCell.node(-1),t=It.get(e),r=this.$anchorCell.start(-1),i=t.colCount(this.$anchorCell.pos-r),o=t.colCount(this.$headCell.pos-r);if(Math.min(i,o)>0)return!1;const s=i+this.$anchorCell.nodeAfter.attrs.colspan,a=o+this.$headCell.nodeAfter.attrs.colspan;return Math.max(s,a)==t.width}eq(e){return e instanceof ki&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,t=e){const r=e.node(-1),i=It.get(r),o=e.start(-1),s=i.findCell(e.pos-o),a=i.findCell(t.pos-o),l=e.node(0);return s.left<=a.left?(s.left>0&&(e=l.resolve(o+i.map[s.top*i.width])),a.right<i.width&&(t=l.resolve(o+i.map[i.width*(a.top+1)-1]))):(a.left>0&&(t=l.resolve(o+i.map[a.top*i.width])),s.right<i.width&&(e=l.resolve(o+i.map[i.width*(s.top+1)-1]))),new ki(e,t)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,t){return new ki(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){return new ki(e.resolve(t),e.resolve(r))}getBookmark(){return new LB(this.$anchorCell.pos,this.$headCell.pos)}};_t.prototype.visible=!1;Fe.jsonID("cell",_t);var LB=class tS{constructor(e,t){this.anchor=e,this.head=t}map(e){return new tS(e.map(this.anchor),e.map(this.head))}resolve(e){const t=e.resolve(this.anchor),r=e.resolve(this.head);return t.parent.type.spec.tableRole=="row"&&r.parent.type.spec.tableRole=="row"&&t.index()<t.parent.childCount&&r.index()<r.parent.childCount&&ov(t,r)?new _t(t,r):Fe.near(r,1)}};function zB(n){if(!(n.selection instanceof _t))return null;const e=[];return n.selection.forEachCell((t,r)=>{e.push(At.node(r,r+t.nodeSize,{class:"selectedCell"}))}),Qe.create(n.doc,e)}function BB({$from:n,$to:e}){if(n.pos==e.pos||n.pos<e.pos-6)return!1;let t=n.pos,r=e.pos,i=n.depth;for(;i>=0&&!(n.after(i+1)<n.end(i));i--,t++);for(let o=e.depth;o>=0&&!(e.before(o+1)>e.start(o));o--,r--);return t==r&&/row|table/.test(n.node(i).type.spec.tableRole)}function FB({$from:n,$to:e}){let t,r;for(let i=n.depth;i>0;i--){const o=n.node(i);if(o.type.spec.tableRole==="cell"||o.type.spec.tableRole==="header_cell"){t=o;break}}for(let i=e.depth;i>0;i--){const o=e.node(i);if(o.type.spec.tableRole==="cell"||o.type.spec.tableRole==="header_cell"){r=o;break}}return t!==r&&e.parentOffset===0}function VB(n,e,t){const r=(e||n).selection,i=(e||n).doc;let o,s;if(r instanceof Pe&&(s=r.node.type.spec.tableRole)){if(s=="cell"||s=="header_cell")o=_t.create(i,r.from);else if(s=="row"){const a=i.resolve(r.from+1);o=_t.rowSelection(a,a)}else if(!t){const a=It.get(r.node),l=r.from+1,c=l+a.map[a.width*a.height-1];o=_t.create(i,l+1,c)}}else r instanceof Ie&&BB(r)?o=Ie.create(i,r.from):r instanceof Ie&&FB(r)&&(o=Ie.create(i,r.$from.start(),r.$from.end()));return o&&(e||(e=n.tr)).setSelection(o),e}const HB=new xt("fix-tables");function nS(n,e,t,r){const i=n.childCount,o=e.childCount;e:for(let s=0,a=0;s<o;s++){const l=e.child(s);for(let c=a,d=Math.min(i,s+3);c<d;c++)if(n.child(c)==l){a=c+1,t+=l.nodeSize;continue e}r(l,t),a<i&&n.child(a).sameMarkup(l)?nS(n.child(a),l,t+1,r):l.nodesBetween(0,l.content.size,r,t+1),t+=l.nodeSize}}function rS(n,e){let t;const r=(i,o)=>{i.type.spec.tableRole=="table"&&(t=UB(n,i,o,t))};return e?e.doc!=n.doc&&nS(e.doc,n.doc,0,r):n.doc.descendants(r),t}function UB(n,e,t,r){const i=It.get(e);if(!i.problems)return r;r||(r=n.tr);const o=[];for(let l=0;l<i.height;l++)o.push(0);for(let l=0;l<i.problems.length;l++){const c=i.problems[l];if(c.type=="collision"){const d=e.nodeAt(c.pos);if(!d)continue;const u=d.attrs;for(let h=0;h<u.rowspan;h++)o[c.row+h]+=c.n;r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,Cs(u,u.colspan-c.n,c.n))}else if(c.type=="missing")o[c.row]+=c.n;else if(c.type=="overlong_rowspan"){const d=e.nodeAt(c.pos);if(!d)continue;r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,{...d.attrs,rowspan:d.attrs.rowspan-c.n})}else if(c.type=="colwidth mismatch"){const d=e.nodeAt(c.pos);if(!d)continue;r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,{...d.attrs,colwidth:c.colwidth})}else if(c.type=="zero_sized"){const d=r.mapping.map(t);r.delete(d,d+e.nodeSize)}}let s,a;for(let l=0;l<o.length;l++)o[l]&&(s==null&&(s=l),a=l);for(let l=0,c=t+1;l<i.height;l++){const d=e.child(l),u=c+d.nodeSize,h=o[l];if(h>0){let p="cell";d.firstChild&&(p=d.firstChild.type.spec.tableRole);const m=[];for(let g=0;g<h;g++){const y=Cn(n.schema)[p].createAndFill();y&&m.push(y)}const v=(l==0||s==l-1)&&a==l?c+1:u-1;r.insert(r.mapping.map(v),m)}c=u}return r.setMeta(HB,{fixTables:!0})}function gi(n){const e=n.selection,t=Nf(n),r=t.node(-1),i=t.start(-1),o=It.get(r);return{...e instanceof _t?o.rectBetween(e.$anchorCell.pos-i,e.$headCell.pos-i):o.findCell(t.pos-i),tableStart:i,map:o,table:r}}function iS(n,{map:e,tableStart:t,table:r},i){let o=i>0?-1:0;PB(e,r,i+o)&&(o=i==0||i==e.width?null:0);for(let s=0;s<e.height;s++){const a=s*e.width+i;if(i>0&&i<e.width&&e.map[a-1]==e.map[a]){const l=e.map[a],c=r.nodeAt(l);n.setNodeMarkup(n.mapping.map(t+l),null,eS(c.attrs,i-e.colCount(l))),s+=c.attrs.rowspan-1}else{const l=o==null?Cn(r.type.schema).cell:r.nodeAt(e.map[a+o]).type,c=e.positionAt(s,i,r);n.insert(n.mapping.map(t+c),l.createAndFill())}}return n}function jB(n,e){if(!Vr(n))return!1;if(e){const t=gi(n);e(iS(n.tr,t,t.left))}return!0}function WB(n,e){if(!Vr(n))return!1;if(e){const t=gi(n);e(iS(n.tr,t,t.right))}return!0}function KB(n,{map:e,table:t,tableStart:r},i){const o=n.mapping.maps.length;for(let s=0;s<e.height;){const a=s*e.width+i,l=e.map[a],c=t.nodeAt(l),d=c.attrs;if(i>0&&e.map[a-1]==l||i<e.width-1&&e.map[a+1]==l)n.setNodeMarkup(n.mapping.slice(o).map(r+l),null,Cs(d,i-e.colCount(l)));else{const u=n.mapping.slice(o).map(r+l);n.delete(u,u+c.nodeSize)}s+=d.rowspan}}function qB(n,e){if(!Vr(n))return!1;if(e){const t=gi(n),r=n.tr;if(t.left==0&&t.right==t.map.width)return!1;for(let i=t.right-1;KB(r,t,i),i!=t.left;i--){const o=t.tableStart?r.doc.nodeAt(t.tableStart-1):r.doc;if(!o)throw new RangeError("No table found");t.table=o,t.map=It.get(o)}e(r)}return!0}function JB(n,e,t){var r;const i=Cn(e.type.schema).header_cell;for(let o=0;o<n.width;o++)if(((r=e.nodeAt(n.map[o+t*n.width]))===null||r===void 0?void 0:r.type)!=i)return!1;return!0}function oS(n,{map:e,tableStart:t,table:r},i){let o=t;for(let c=0;c<i;c++)o+=r.child(c).nodeSize;const s=[];let a=i>0?-1:0;JB(e,r,i+a)&&(a=i==0||i==e.height?null:0);for(let c=0,d=e.width*i;c<e.width;c++,d++)if(i>0&&i<e.height&&e.map[d]==e.map[d-e.width]){const u=e.map[d],h=r.nodeAt(u).attrs;n.setNodeMarkup(t+u,null,{...h,rowspan:h.rowspan+1}),c+=h.colspan-1}else{var l;const u=a==null?Cn(r.type.schema).cell:(l=r.nodeAt(e.map[d+a*e.width]))===null||l===void 0?void 0:l.type,h=u==null?void 0:u.createAndFill();h&&s.push(h)}return n.insert(o,Cn(r.type.schema).row.create(null,s)),n}function YB(n,e){if(!Vr(n))return!1;if(e){const t=gi(n);e(oS(n.tr,t,t.top))}return!0}function GB(n,e){if(!Vr(n))return!1;if(e){const t=gi(n);e(oS(n.tr,t,t.bottom))}return!0}function ZB(n,{map:e,table:t,tableStart:r},i){let o=0;for(let c=0;c<i;c++)o+=t.child(c).nodeSize;const s=o+t.child(i).nodeSize,a=n.mapping.maps.length;n.delete(o+r,s+r);const l=new Set;for(let c=0,d=i*e.width;c<e.width;c++,d++){const u=e.map[d];if(!l.has(u)){if(l.add(u),i>0&&u==e.map[d-e.width]){const h=t.nodeAt(u).attrs;n.setNodeMarkup(n.mapping.slice(a).map(u+r),null,{...h,rowspan:h.rowspan-1}),c+=h.colspan-1}else if(i<e.height&&u==e.map[d+e.width]){const h=t.nodeAt(u),p=h.attrs,m=h.type.create({...p,rowspan:h.attrs.rowspan-1},h.content),v=e.positionAt(i+1,c,t);n.insert(n.mapping.slice(a).map(r+v),m),c+=p.colspan-1}}}}function XB(n,e){if(!Vr(n))return!1;if(e){const t=gi(n),r=n.tr;if(t.top==0&&t.bottom==t.map.height)return!1;for(let i=t.bottom-1;ZB(r,t,i),i!=t.top;i--){const o=t.tableStart?r.doc.nodeAt(t.tableStart-1):r.doc;if(!o)throw new RangeError("No table found");t.table=o,t.map=It.get(t.table)}e(r)}return!0}function u0(n){const e=n.content;return e.childCount==1&&e.child(0).isTextblock&&e.child(0).childCount==0}function QB({width:n,height:e,map:t},r){let i=r.top*n+r.left,o=i,s=(r.bottom-1)*n+r.left,a=i+(r.right-r.left-1);for(let l=r.top;l<r.bottom;l++){if(r.left>0&&t[o]==t[o-1]||r.right<n&&t[a]==t[a+1])return!0;o+=n,a+=n}for(let l=r.left;l<r.right;l++){if(r.top>0&&t[i]==t[i-n]||r.bottom<e&&t[s]==t[s+n])return!0;i++,s++}return!1}function f0(n,e){const t=n.selection;if(!(t instanceof _t)||t.$anchorCell.pos==t.$headCell.pos)return!1;const r=gi(n),{map:i}=r;if(QB(i,r))return!1;if(e){const o=n.tr,s={};let a=ie.empty,l,c;for(let d=r.top;d<r.bottom;d++)for(let u=r.left;u<r.right;u++){const h=i.map[d*i.width+u],p=r.table.nodeAt(h);if(!(s[h]||!p))if(s[h]=!0,l==null)l=h,c=p;else{u0(p)||(a=a.append(p.content));const m=o.mapping.map(h+r.tableStart);o.delete(m,m+p.nodeSize)}}if(l==null||c==null)return!0;if(o.setNodeMarkup(l+r.tableStart,null,{...eS(c.attrs,c.attrs.colspan,r.right-r.left-c.attrs.colspan),rowspan:r.bottom-r.top}),a.size>0){const d=l+1+c.content.size,u=u0(c)?l+1:d;o.replaceWith(u+r.tableStart,d+r.tableStart,a)}o.setSelection(new _t(o.doc.resolve(l+r.tableStart))),e(o)}return!0}function h0(n,e){const t=Cn(n.schema);return $B(({node:r})=>t[r.type.spec.tableRole])(n,e)}function $B(n){return(e,t)=>{const r=e.selection;let i,o;if(r instanceof _t){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;i=r.$anchorCell.nodeAfter,o=r.$anchorCell.pos}else{var s;if(i=RB(r.$from),!i)return!1;o=(s=Ss(r.$from))===null||s===void 0?void 0:s.pos}if(i==null||o==null||i.attrs.colspan==1&&i.attrs.rowspan==1)return!1;if(t){let a=i.attrs;const l=[],c=a.colwidth;a.rowspan>1&&(a={...a,rowspan:1}),a.colspan>1&&(a={...a,colspan:1});const d=gi(e),u=e.tr;for(let p=0;p<d.right-d.left;p++)l.push(c?{...a,colwidth:c&&c[p]?[c[p]]:null}:a);let h;for(let p=d.top;p<d.bottom;p++){let m=d.map.positionAt(p,d.left,d.table);p==d.top&&(m+=i.nodeSize);for(let v=d.left,g=0;v<d.right;v++,g++)v==d.left&&p==d.top||u.insert(h=u.mapping.map(m+d.tableStart,1),n({node:i,row:p,col:v}).createAndFill(l[g]))}u.setNodeMarkup(o,n({node:i,row:d.top,col:d.left}),l[0]),r instanceof _t&&u.setSelection(new _t(u.doc.resolve(r.$anchorCell.pos),h?u.doc.resolve(h):void 0)),t(u)}return!0}}function eF(n,e){return function(t,r){if(!Vr(t))return!1;const i=Nf(t);if(i.nodeAfter.attrs[n]===e)return!1;if(r){const o=t.tr;t.selection instanceof _t?t.selection.forEachCell((s,a)=>{s.attrs[n]!==e&&o.setNodeMarkup(a,null,{...s.attrs,[n]:e})}):o.setNodeMarkup(i.pos,null,{...i.nodeAfter.attrs,[n]:e}),r(o)}return!0}}function tF(n){return function(e,t){if(!Vr(e))return!1;if(t){const r=Cn(e.schema),i=gi(e),o=e.tr,s=i.map.cellsInRect(n=="column"?{left:i.left,top:0,right:i.right,bottom:i.map.height}:n=="row"?{left:0,top:i.top,right:i.map.width,bottom:i.bottom}:i),a=s.map(l=>i.table.nodeAt(l));for(let l=0;l<s.length;l++)a[l].type==r.header_cell&&o.setNodeMarkup(i.tableStart+s[l],r.cell,a[l].attrs);if(o.steps.length===0)for(let l=0;l<s.length;l++)o.setNodeMarkup(i.tableStart+s[l],r.header_cell,a[l].attrs);t(o)}return!0}}function p0(n,e,t){const r=e.map.cellsInRect({left:0,top:0,right:n=="row"?e.map.width:1,bottom:n=="column"?e.map.height:1});for(let i=0;i<r.length;i++){const o=e.table.nodeAt(r[i]);if(o&&o.type!==t.header_cell)return!1}return!0}function ac(n,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?tF(n):function(t,r){if(!Vr(t))return!1;if(r){const i=Cn(t.schema),o=gi(t),s=t.tr,a=p0("row",o,i),l=p0("column",o,i),c=(n==="column"?a:n==="row"&&l)?1:0,d=n=="column"?{left:0,top:c,right:1,bottom:o.map.height}:n=="row"?{left:c,top:0,right:o.map.width,bottom:1}:o,u=n=="column"?l?i.cell:i.header_cell:n=="row"?a?i.cell:i.header_cell:i.cell;o.map.cellsInRect(d).forEach(h=>{const p=h+o.tableStart,m=s.doc.nodeAt(p);m&&s.setNodeMarkup(p,u,m.attrs)}),r(s)}return!0}}ac("row",{useDeprecatedLogic:!0});ac("column",{useDeprecatedLogic:!0});const nF=ac("cell",{useDeprecatedLogic:!0});function rF(n,e){if(e<0){const t=n.nodeBefore;if(t)return n.pos-t.nodeSize;for(let r=n.index(-1)-1,i=n.before();r>=0;r--){const o=n.node(-1).child(r),s=o.lastChild;if(s)return i-1-s.nodeSize;i-=o.nodeSize}}else{if(n.index()<n.parent.childCount-1)return n.pos+n.nodeAfter.nodeSize;const t=n.node(-1);for(let r=n.indexAfter(-1),i=n.after();r<t.childCount;r++){const o=t.child(r);if(o.childCount)return i+1;i+=o.nodeSize}}return null}function m0(n){return function(e,t){if(!Vr(e))return!1;const r=rF(Nf(e),n);if(r==null)return!1;if(t){const i=e.doc.resolve(r);t(e.tr.setSelection(Ie.between(i,IB(i))).scrollIntoView())}return!0}}function iF(n,e){const t=n.selection.$anchor;for(let r=t.depth;r>0;r--)if(t.node(r).type.spec.tableRole=="table")return e&&e(n.tr.delete(t.before(r),t.after(r)).scrollIntoView()),!0;return!1}function Zc(n,e){const t=n.selection;if(!(t instanceof _t))return!1;if(e){const r=n.tr,i=Cn(n.schema).cell.createAndFill().content;t.forEachCell((o,s)=>{o.content.eq(i)||r.replace(r.mapping.map(s+1),r.mapping.map(s+o.nodeSize-1),new ye(i,0,0))}),r.docChanged&&e(r)}return!0}function oF(n){if(n.size===0)return null;let{content:e,openStart:t,openEnd:r}=n;for(;e.childCount==1&&(t>0&&r>0||e.child(0).type.spec.tableRole=="table");)t--,r--,e=e.child(0).content;const i=e.child(0),o=i.type.spec.tableRole,s=i.type.schema,a=[];if(o=="row")for(let l=0;l<e.childCount;l++){let c=e.child(l).content;const d=l?0:Math.max(0,t-1),u=l<e.childCount-1?0:Math.max(0,r-1);(d||u)&&(c=bm(Cn(s).row,new ye(c,d,u)).content),a.push(c)}else if(o=="cell"||o=="header_cell")a.push(t||r?bm(Cn(s).row,new ye(e,t,r)).content:e);else return null;return sF(s,a)}function sF(n,e){const t=[];for(let i=0;i<e.length;i++){const o=e[i];for(let s=o.childCount-1;s>=0;s--){const{rowspan:a,colspan:l}=o.child(s).attrs;for(let c=i;c<i+a;c++)t[c]=(t[c]||0)+l}}let r=0;for(let i=0;i<t.length;i++)r=Math.max(r,t[i]);for(let i=0;i<t.length;i++)if(i>=e.length&&e.push(ie.empty),t[i]<r){const o=Cn(n).cell.createAndFill(),s=[];for(let a=t[i];a<r;a++)s.push(o);e[i]=e[i].append(ie.from(s))}return{height:e.length,width:r,rows:e}}function bm(n,e){const t=n.createAndFill();return new qm(t).replace(0,t.content.size,e).doc}function aF({width:n,height:e,rows:t},r,i){if(n!=r){const o=[],s=[];for(let a=0;a<t.length;a++){const l=t[a],c=[];for(let d=o[a]||0,u=0;d<r;u++){let h=l.child(u%l.childCount);d+h.attrs.colspan>r&&(h=h.type.createChecked(Cs(h.attrs,h.attrs.colspan,d+h.attrs.colspan-r),h.content)),c.push(h),d+=h.attrs.colspan;for(let p=1;p<h.attrs.rowspan;p++)o[a+p]=(o[a+p]||0)+h.attrs.colspan}s.push(ie.from(c))}t=s,n=r}if(e!=i){const o=[];for(let s=0,a=0;s<i;s++,a++){const l=[],c=t[a%e];for(let d=0;d<c.childCount;d++){let u=c.child(d);s+u.attrs.rowspan>i&&(u=u.type.create({...u.attrs,rowspan:Math.max(1,i-u.attrs.rowspan)},u.content)),l.push(u)}o.push(ie.from(l))}t=o,e=i}return{width:n,height:e,rows:t}}function lF(n,e,t,r,i,o,s){const a=n.doc.type.schema,l=Cn(a);let c,d;if(i>e.width)for(let u=0,h=0;u<e.height;u++){const p=t.child(u);h+=p.nodeSize;const m=[];let v;p.lastChild==null||p.lastChild.type==l.cell?v=c||(c=l.cell.createAndFill()):v=d||(d=l.header_cell.createAndFill());for(let g=e.width;g<i;g++)m.push(v);n.insert(n.mapping.slice(s).map(h-1+r),m)}if(o>e.height){const u=[];for(let m=0,v=(e.height-1)*e.width;m<Math.max(e.width,i);m++){const g=m>=e.width?!1:t.nodeAt(e.map[v+m]).type==l.header_cell;u.push(g?d||(d=l.header_cell.createAndFill()):c||(c=l.cell.createAndFill()))}const h=l.row.create(null,ie.from(u)),p=[];for(let m=e.height;m<o;m++)p.push(h);n.insert(n.mapping.slice(s).map(r+t.nodeSize-2),p)}return!!(c||d)}function g0(n,e,t,r,i,o,s,a){if(s==0||s==e.height)return!1;let l=!1;for(let c=i;c<o;c++){const d=s*e.width+c,u=e.map[d];if(e.map[d-e.width]==u){l=!0;const h=t.nodeAt(u),{top:p,left:m}=e.findCell(u);n.setNodeMarkup(n.mapping.slice(a).map(u+r),null,{...h.attrs,rowspan:s-p}),n.insert(n.mapping.slice(a).map(e.positionAt(s,m,t)),h.type.createAndFill({...h.attrs,rowspan:p+h.attrs.rowspan-s})),c+=h.attrs.colspan-1}}return l}function v0(n,e,t,r,i,o,s,a){if(s==0||s==e.width)return!1;let l=!1;for(let c=i;c<o;c++){const d=c*e.width+s,u=e.map[d];if(e.map[d-1]==u){l=!0;const h=t.nodeAt(u),p=e.colCount(u),m=n.mapping.slice(a).map(u+r);n.setNodeMarkup(m,null,Cs(h.attrs,s-p,h.attrs.colspan-(s-p))),n.insert(m+h.nodeSize,h.type.createAndFill(Cs(h.attrs,0,s-p))),c+=h.attrs.rowspan-1}}return l}function y0(n,e,t,r,i){let o=t?n.doc.nodeAt(t-1):n.doc;if(!o)throw new Error("No table found");let s=It.get(o);const{top:a,left:l}=r,c=l+i.width,d=a+i.height,u=n.tr;let h=0;function p(){if(o=t?u.doc.nodeAt(t-1):u.doc,!o)throw new Error("No table found");s=It.get(o),h=u.mapping.maps.length}lF(u,s,o,t,c,d,h)&&p(),g0(u,s,o,t,l,c,a,h)&&p(),g0(u,s,o,t,l,c,d,h)&&p(),v0(u,s,o,t,a,d,l,h)&&p(),v0(u,s,o,t,a,d,c,h)&&p();for(let m=a;m<d;m++){const v=s.positionAt(m,l,o),g=s.positionAt(m,c,o);u.replace(u.mapping.slice(h).map(v+t),u.mapping.slice(h).map(g+t),new ye(i.rows[m-a],0,0))}p(),u.setSelection(new _t(u.doc.resolve(t+s.positionAt(a,l,o)),u.doc.resolve(t+s.positionAt(d-1,c-1,o)))),e(u)}const cF=zg({ArrowLeft:Xc("horiz",-1),ArrowRight:Xc("horiz",1),ArrowUp:Xc("vert",-1),ArrowDown:Xc("vert",1),"Shift-ArrowLeft":Qc("horiz",-1),"Shift-ArrowRight":Qc("horiz",1),"Shift-ArrowUp":Qc("vert",-1),"Shift-ArrowDown":Qc("vert",1),Backspace:Zc,"Mod-Backspace":Zc,Delete:Zc,"Mod-Delete":Zc});function Cd(n,e,t){return t.eq(n.selection)?!1:(e&&e(n.tr.setSelection(t).scrollIntoView()),!0)}function Xc(n,e){return(t,r,i)=>{if(!i)return!1;const o=t.selection;if(o instanceof _t)return Cd(t,r,Fe.near(o.$headCell,e));if(n!="horiz"&&!o.empty)return!1;const s=sS(i,n,e);if(s==null)return!1;if(n=="horiz")return Cd(t,r,Fe.near(t.doc.resolve(o.head+e),e));{const a=t.doc.resolve(s),l=$_(a,n,e);let c;return l?c=Fe.near(l,1):e<0?c=Fe.near(t.doc.resolve(a.before(-1)),-1):c=Fe.near(t.doc.resolve(a.after(-1)),1),Cd(t,r,c)}}}function Qc(n,e){return(t,r,i)=>{if(!i)return!1;const o=t.selection;let s;if(o instanceof _t)s=o;else{const l=sS(i,n,e);if(l==null)return!1;s=new _t(t.doc.resolve(l))}const a=$_(s.$headCell,n,e);return a?Cd(t,r,new _t(s.$anchorCell,a)):!1}}function dF(n,e){const t=n.state.doc,r=Ss(t.resolve(e));return r?(n.dispatch(n.state.tr.setSelection(new _t(r))),!0):!1}function uF(n,e,t){if(!Vr(n.state))return!1;let r=oF(t);const i=n.state.selection;if(i instanceof _t){r||(r={width:1,height:1,rows:[ie.from(bm(Cn(n.state.schema).cell,t))]});const o=i.$anchorCell.node(-1),s=i.$anchorCell.start(-1),a=It.get(o).rectBetween(i.$anchorCell.pos-s,i.$headCell.pos-s);return r=aF(r,a.right-a.left,a.bottom-a.top),y0(n.state,n.dispatch,s,a,r),!0}else if(r){const o=Nf(n.state),s=o.start(-1);return y0(n.state,n.dispatch,s,It.get(o.node(-1)).findCell(o.pos-s),r),!0}else return!1}function fF(n,e){var t;if(e.button!=0||e.ctrlKey||e.metaKey)return;const r=b0(n,e.target);let i;if(e.shiftKey&&n.state.selection instanceof _t)o(n.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(i=Ss(n.state.selection.$anchor))!=null&&((t=Lh(n,e))===null||t===void 0?void 0:t.pos)!=i.pos)o(i,e),e.preventDefault();else if(!r)return;function o(l,c){let d=Lh(n,c);const u=no.getState(n.state)==null;if(!d||!ov(l,d))if(u)d=l;else return;const h=new _t(l,d);if(u||!n.state.selection.eq(h)){const p=n.state.tr.setSelection(h);u&&p.setMeta(no,l.pos),n.dispatch(p)}}function s(){n.root.removeEventListener("mouseup",s),n.root.removeEventListener("dragstart",s),n.root.removeEventListener("mousemove",a),no.getState(n.state)!=null&&n.dispatch(n.state.tr.setMeta(no,-1))}function a(l){const c=l,d=no.getState(n.state);let u;if(d!=null)u=n.state.doc.resolve(d);else if(b0(n,c.target)!=r&&(u=Lh(n,e),!u))return s();u&&o(u,c)}n.root.addEventListener("mouseup",s),n.root.addEventListener("dragstart",s),n.root.addEventListener("mousemove",a)}function sS(n,e,t){if(!(n.state.selection instanceof Ie))return null;const{$head:r}=n.state.selection;for(let i=r.depth-1;i>=0;i--){const o=r.node(i);if((t<0?r.index(i):r.indexAfter(i))!=(t<0?0:o.childCount))return null;if(o.type.spec.tableRole=="cell"||o.type.spec.tableRole=="header_cell"){const s=r.before(i),a=e=="vert"?t>0?"down":"up":t>0?"right":"left";return n.endOfTextblock(a)?s:null}}return null}function b0(n,e){for(;e&&e!=n.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function Lh(n,e){const t=n.posAtCoords({left:e.clientX,top:e.clientY});if(!t)return null;let{inside:r,pos:i}=t;return r>=0&&Ss(n.state.doc.resolve(r))||Ss(n.state.doc.resolve(i))}var hF=class{constructor(e,t){this.node=e,this.defaultCellMinWidth=t,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${t}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),wm(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!=this.node.type?!1:(this.node=e,wm(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function wm(n,e,t,r,i,o){let s=0,a=!0,l=e.firstChild;const c=n.firstChild;if(c){for(let u=0,h=0;u<c.childCount;u++){const{colspan:p,colwidth:m}=c.child(u).attrs;for(let v=0;v<p;v++,h++){const g=i==h?o:m&&m[v],y=g?g+"px":"";if(s+=g||r,g||(a=!1),l)l.style.width!=y&&(l.style.width=y),l=l.nextSibling;else{const w=document.createElement("col");w.style.width=y,e.appendChild(w)}}}for(;l;){var d;const u=l.nextSibling;(d=l.parentNode)===null||d===void 0||d.removeChild(l),l=u}a?(t.style.width=s+"px",t.style.minWidth=""):(t.style.width="",t.style.minWidth=s+"px")}}const er=new xt("tableColumnResizing");function pF({handleWidth:n=5,cellMinWidth:e=25,defaultCellMinWidth:t=100,View:r=hF,lastColumnResizable:i=!0}={}){const o=new pt({key:er,state:{init(s,a){var l;const c=(l=o.spec)===null||l===void 0||(l=l.props)===null||l===void 0?void 0:l.nodeViews,d=Cn(a.schema).table.name;return r&&c&&(c[d]=(u,h)=>new r(u,t,h)),new mF(-1,!1)},apply(s,a){return a.apply(s)}},props:{attributes:s=>{const a=er.getState(s);return a&&a.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(s,a)=>{gF(s,a,n,i)},mouseleave:s=>{vF(s)},mousedown:(s,a)=>{yF(s,a,e,t)}},decorations:s=>{const a=er.getState(s);if(a&&a.activeHandle>-1)return _F(s,a.activeHandle)},nodeViews:{}}});return o}var mF=class Td{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(e){const t=this,r=e.getMeta(er);if(r&&r.setHandle!=null)return new Td(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new Td(t.activeHandle,r.setDragging);if(t.activeHandle>-1&&e.docChanged){let i=e.mapping.map(t.activeHandle,-1);return ym(e.doc.resolve(i))||(i=-1),new Td(i,t.dragging)}return t}};function gF(n,e,t,r){if(!n.editable)return;const i=er.getState(n.state);if(i&&!i.dragging){const o=wF(e.target);let s=-1;if(o){const{left:a,right:l}=o.getBoundingClientRect();e.clientX-a<=t?s=w0(n,e,"left",t):l-e.clientX<=t&&(s=w0(n,e,"right",t))}if(s!=i.activeHandle){if(!r&&s!==-1){const a=n.state.doc.resolve(s),l=a.node(-1),c=It.get(l),d=a.start(-1);if(c.colCount(a.pos-d)+a.nodeAfter.attrs.colspan-1==c.width-1)return}aS(n,s)}}}function vF(n){if(!n.editable)return;const e=er.getState(n.state);e&&e.activeHandle>-1&&!e.dragging&&aS(n,-1)}function yF(n,e,t,r){var i;if(!n.editable)return!1;const o=(i=n.dom.ownerDocument.defaultView)!==null&&i!==void 0?i:window,s=er.getState(n.state);if(!s||s.activeHandle==-1||s.dragging)return!1;const a=n.state.doc.nodeAt(s.activeHandle),l=bF(n,s.activeHandle,a.attrs);n.dispatch(n.state.tr.setMeta(er,{setDragging:{startX:e.clientX,startWidth:l}}));function c(u){o.removeEventListener("mouseup",c),o.removeEventListener("mousemove",d);const h=er.getState(n.state);h!=null&&h.dragging&&(xF(n,h.activeHandle,x0(h.dragging,u,t)),n.dispatch(n.state.tr.setMeta(er,{setDragging:null})))}function d(u){if(!u.which)return c(u);const h=er.getState(n.state);if(h&&h.dragging){const p=x0(h.dragging,u,t);k0(n,h.activeHandle,p,r)}}return k0(n,s.activeHandle,l,r),o.addEventListener("mouseup",c),o.addEventListener("mousemove",d),e.preventDefault(),!0}function bF(n,e,{colspan:t,colwidth:r}){const i=r&&r[r.length-1];if(i)return i;const o=n.domAtPos(e);let s=o.node.childNodes[o.offset].offsetWidth,a=t;if(r)for(let l=0;l<t;l++)r[l]&&(s-=r[l],a--);return s/a}function wF(n){for(;n&&n.nodeName!="TD"&&n.nodeName!="TH";)n=n.classList&&n.classList.contains("ProseMirror")?null:n.parentNode;return n}function w0(n,e,t,r){const i=t=="right"?-r:r,o=n.posAtCoords({left:e.clientX+i,top:e.clientY});if(!o)return-1;const{pos:s}=o,a=Ss(n.state.doc.resolve(s));if(!a)return-1;if(t=="right")return a.pos;const l=It.get(a.node(-1)),c=a.start(-1),d=l.map.indexOf(a.pos-c);return d%l.width==0?-1:c+l.map[d-1]}function x0(n,e,t){const r=e.clientX-n.startX;return Math.max(t,n.startWidth+r)}function aS(n,e){n.dispatch(n.state.tr.setMeta(er,{setHandle:e}))}function xF(n,e,t){const r=n.state.doc.resolve(e),i=r.node(-1),o=It.get(i),s=r.start(-1),a=o.colCount(r.pos-s)+r.nodeAfter.attrs.colspan-1,l=n.state.tr;for(let c=0;c<o.height;c++){const d=c*o.width+a;if(c&&o.map[d]==o.map[d-o.width])continue;const u=o.map[d],h=i.nodeAt(u).attrs,p=h.colspan==1?0:a-o.colCount(u);if(h.colwidth&&h.colwidth[p]==t)continue;const m=h.colwidth?h.colwidth.slice():kF(h.colspan);m[p]=t,l.setNodeMarkup(s+u,null,{...h,colwidth:m})}l.docChanged&&n.dispatch(l)}function k0(n,e,t,r){const i=n.state.doc.resolve(e),o=i.node(-1),s=i.start(-1),a=It.get(o).colCount(i.pos-s)+i.nodeAfter.attrs.colspan-1;let l=n.domAtPos(i.start(-1)).node;for(;l&&l.nodeName!="TABLE";)l=l.parentNode;l&&wm(o,l.firstChild,l,r,a,t)}function kF(n){return Array(n).fill(0)}function _F(n,e){const t=[],r=n.doc.resolve(e),i=r.node(-1);if(!i)return Qe.empty;const o=It.get(i),s=r.start(-1),a=o.colCount(r.pos-s)+r.nodeAfter.attrs.colspan-1;for(let c=0;c<o.height;c++){const d=a+c*o.width;if((a==o.width-1||o.map[d]!=o.map[d+1])&&(c==0||o.map[d]!=o.map[d-o.width])){var l;const u=o.map[d],h=s+u+i.nodeAt(u).nodeSize-1,p=document.createElement("div");p.className="column-resize-handle",!((l=er.getState(n))===null||l===void 0)&&l.dragging&&t.push(At.node(s+u,s+u+i.nodeAt(u).nodeSize,{class:"column-resize-dragging"})),t.push(At.widget(h,p))}}return Qe.create(n.doc,t)}function SF({allowTableNodeSelection:n=!1}={}){return new pt({key:no,state:{init(){return null},apply(e,t){const r=e.getMeta(no);if(r!=null)return r==-1?null:r;if(t==null||!e.docChanged)return t;const{deleted:i,pos:o}=e.mapping.mapResult(t);return i?null:o}},props:{decorations:zB,handleDOMEvents:{mousedown:fF},createSelectionBetween(e){return no.getState(e.state)!=null?e.state.selection:null},handleTripleClick:dF,handleKeyDown:cF,handlePaste:uF},appendTransaction(e,t,r){return VB(r,rS(r,t),n)}})}function xm(n,e){return e?["width",`${Math.max(e,n)}px`]:["min-width",`${n}px`]}function _0(n,e,t,r,i,o){var s;let a=0,l=!0,c=e.firstChild;const d=n.firstChild;if(d!==null)for(let u=0,h=0;u<d.childCount;u+=1){const{colspan:p,colwidth:m}=d.child(u).attrs;for(let v=0;v<p;v+=1,h+=1){const g=i===h?o:m&&m[v],y=g?`${g}px`:"";if(a+=g||r,g||(l=!1),c){if(c.style.width!==y){const[w,_]=xm(r,g);c.style.setProperty(w,_)}c=c.nextSibling}else{const w=document.createElement("col"),[_,S]=xm(r,g);w.style.setProperty(_,S),e.appendChild(w)}}}for(;c;){const u=c.nextSibling;(s=c.parentNode)===null||s===void 0||s.removeChild(c),c=u}l?(t.style.width=`${a}px`,t.style.minWidth=""):(t.style.width="",t.style.minWidth=`${a}px`)}class CF{constructor(e,t){this.node=e,this.cellMinWidth=t,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.colgroup=this.table.appendChild(document.createElement("colgroup")),_0(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!==this.node.type?!1:(this.node=e,_0(e,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(e){return e.type==="attributes"&&(e.target===this.table||this.colgroup.contains(e.target))}}function TF(n,e,t,r){let i=0,o=!0;const s=[],a=n.firstChild;if(!a)return{};for(let u=0,h=0;u<a.childCount;u+=1){const{colspan:p,colwidth:m}=a.child(u).attrs;for(let v=0;v<p;v+=1,h+=1){const g=t===h?r:m&&m[v];i+=g||e,g||(o=!1);const[y,w]=xm(e,g);s.push(["col",{style:`${y}: ${w}`}])}}const l=o?`${i}px`:"",c=o?"":`${i}px`;return{colgroup:["colgroup",{},...s],tableWidth:l,tableMinWidth:c}}function S0(n,e){return n.createAndFill()}function AF(n){if(n.cached.tableNodeTypes)return n.cached.tableNodeTypes;const e={};return Object.keys(n.nodes).forEach(t=>{const r=n.nodes[t];r.spec.tableRole&&(e[r.spec.tableRole]=r)}),n.cached.tableNodeTypes=e,e}function EF(n,e,t,r,i){const o=AF(n),s=[],a=[];for(let c=0;c<t;c+=1){const d=S0(o.cell);if(d&&a.push(d),r){const u=S0(o.header_cell);u&&s.push(u)}}const l=[];for(let c=0;c<e;c+=1)l.push(o.row.createChecked(null,r&&c===0?s:a));return o.table.createChecked(null,l)}function MF(n){return n instanceof _t}const $c=({editor:n})=>{const{selection:e}=n.state;if(!MF(e))return!1;let t=0;const r=B_(e.ranges[0].$from,o=>o.type.name==="table");return r==null||r.node.descendants(o=>{if(o.type.name==="table")return!1;["tableCell","tableHeader"].includes(o.type.name)&&(t+=1)}),t===e.ranges.length?(n.commands.deleteTable(),!0):!1},OF=Fn.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:CF,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:n,HTMLAttributes:e}){const{colgroup:t,tableWidth:r,tableMinWidth:i}=TF(n,this.options.cellMinWidth),o=["table",zt(this.options.HTMLAttributes,e,{style:r?`width: ${r}`:`min-width: ${i}`}),t,["tbody",0]];return this.options.renderWrapper?["div",{class:"tableWrapper"},o]:o},addCommands(){return{insertTable:({rows:n=3,cols:e=3,withHeaderRow:t=!0}={})=>({tr:r,dispatch:i,editor:o})=>{const s=EF(o.schema,n,e,t);if(i){const a=r.selection.from+1;r.replaceSelectionWith(s).scrollIntoView().setSelection(Ie.near(r.doc.resolve(a)))}return!0},addColumnBefore:()=>({state:n,dispatch:e})=>jB(n,e),addColumnAfter:()=>({state:n,dispatch:e})=>WB(n,e),deleteColumn:()=>({state:n,dispatch:e})=>qB(n,e),addRowBefore:()=>({state:n,dispatch:e})=>YB(n,e),addRowAfter:()=>({state:n,dispatch:e})=>GB(n,e),deleteRow:()=>({state:n,dispatch:e})=>XB(n,e),deleteTable:()=>({state:n,dispatch:e})=>iF(n,e),mergeCells:()=>({state:n,dispatch:e})=>f0(n,e),splitCell:()=>({state:n,dispatch:e})=>h0(n,e),toggleHeaderColumn:()=>({state:n,dispatch:e})=>ac("column")(n,e),toggleHeaderRow:()=>({state:n,dispatch:e})=>ac("row")(n,e),toggleHeaderCell:()=>({state:n,dispatch:e})=>nF(n,e),mergeOrSplit:()=>({state:n,dispatch:e})=>f0(n,e)?!0:h0(n,e),setCellAttribute:(n,e)=>({state:t,dispatch:r})=>eF(n,e)(t,r),goToNextCell:()=>({state:n,dispatch:e})=>m0(1)(n,e),goToPreviousCell:()=>({state:n,dispatch:e})=>m0(-1)(n,e),fixTables:()=>({state:n,dispatch:e})=>(e&&rS(n),!0),setCellSelection:n=>({tr:e,dispatch:t})=>{if(t){const r=_t.create(e.doc,n.anchorCell,n.headCell);e.setSelection(r)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:$c,"Mod-Backspace":$c,Delete:$c,"Mod-Delete":$c}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[pF({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],SF({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(n){const e={name:n.name,options:n.options,storage:n.storage};return{tableRole:Ze(Ae(n,"tableRole",e))}}}),DF=Fn.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:n=>{const e=n.getAttribute("colwidth");return e?e.split(",").map(r=>parseInt(r,10)):null}}}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:n}){return["td",zt(this.options.HTMLAttributes,n),0]}}),RF=Fn.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:n=>{const e=n.getAttribute("colwidth");return e?e.split(",").map(r=>parseInt(r,10)):null}}}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:n}){return["th",zt(this.options.HTMLAttributes,n),0]}}),NF=Fn.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:n}){return["tr",zt(this.options.HTMLAttributes,n),0]}}),IF=/^\s*>\s$/,PF=Fn.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:n}){return["blockquote",zt(this.options.HTMLAttributes,n),0]},addCommands(){return{setBlockquote:()=>({commands:n})=>n.wrapIn(this.name),toggleBlockquote:()=>({commands:n})=>n.toggleWrap(this.name),unsetBlockquote:()=>({commands:n})=>n.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[rc({find:IF,type:this.type})]}}),LF=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,zF=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,BF=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,FF=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,VF=fi.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:n=>n.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:n=>n.type.name===this.name},{style:"font-weight",getAttrs:n=>/^(bold(er)?|[5-9]\d{2,})$/.test(n)&&null}]},renderHTML({HTMLAttributes:n}){return["strong",zt(this.options.HTMLAttributes,n),0]},addCommands(){return{setBold:()=>({commands:n})=>n.setMark(this.name),toggleBold:()=>({commands:n})=>n.toggleMark(this.name),unsetBold:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[_s({find:LF,type:this.type}),_s({find:BF,type:this.type})]},addPasteRules(){return[Eo({find:zF,type:this.type}),Eo({find:FF,type:this.type})]}}),HF="listItem",C0="textStyle",T0=/^\s*([-+*])\s$/,UF=Fn.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:n}){return["ul",zt(this.options.HTMLAttributes,n),0]},addCommands(){return{toggleBulletList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(HF,this.editor.getAttributes(C0)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let n=rc({find:T0,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(n=rc({find:T0,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(C0),editor:this.editor})),[n]}}),jF=/(^|[^`])`([^`]+)`(?!`)/,WF=/(^|[^`])`([^`]+)`(?!`)/g,KF=fi.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:n}){return["code",zt(this.options.HTMLAttributes,n),0]},addCommands(){return{setCode:()=>({commands:n})=>n.setMark(this.name),toggleCode:()=>({commands:n})=>n.toggleMark(this.name),unsetCode:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[_s({find:jF,type:this.type})]},addPasteRules(){return[Eo({find:WF,type:this.type})]}}),qF=/^```([a-z]+)?[\s\n]$/,JF=/^~~~([a-z]+)?[\s\n]$/,YF=Fn.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:n=>{var e;const{languageClassPrefix:t}=this.options,o=[...((e=n.firstElementChild)===null||e===void 0?void 0:e.classList)||[]].filter(s=>s.startsWith(t)).map(s=>s.replace(t,""))[0];return o||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:n,HTMLAttributes:e}){return["pre",zt(this.options.HTMLAttributes,e),["code",{class:n.attrs.language?this.options.languageClassPrefix+n.attrs.language:null},0]]},addCommands(){return{setCodeBlock:n=>({commands:e})=>e.setNode(this.name,n),toggleCodeBlock:n=>({commands:e})=>e.toggleNode(this.name,"paragraph",n)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:n,$anchor:e}=this.editor.state.selection,t=e.pos===1;return!n||e.parent.type.name!==this.name?!1:t||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Enter:({editor:n})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=n,{selection:t}=e,{$from:r,empty:i}=t;if(!i||r.parent.type!==this.type)return!1;const o=r.parentOffset===r.parent.nodeSize-2,s=r.parent.textContent.endsWith(`
|
|
181
|
-
|
|
182
|
-
`);return!o||!s?!1:n.chain().command(({tr:a})=>(a.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:n})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=n,{selection:t,doc:r}=e,{$from:i,empty:o}=t;if(!o||i.parent.type!==this.type||!(i.parentOffset===i.parent.nodeSize-2))return!1;const a=i.after();return a===void 0?!1:r.nodeAt(a)?n.commands.command(({tr:c})=>(c.setSelection(Fe.near(r.resolve(a))),!0)):n.commands.exitCode()}}},addInputRules(){return[nm({find:qF,type:this.type,getAttributes:n=>({language:n[1]})}),nm({find:JF,type:this.type,getAttributes:n=>({language:n[1]})})]},addProseMirrorPlugins(){return[new pt({key:new xt("codeBlockVSCodeHandler"),props:{handlePaste:(n,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const t=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),i=r?JSON.parse(r):void 0,o=i==null?void 0:i.mode;if(!t||!o)return!1;const{tr:s,schema:a}=n.state,l=a.text(t.replace(/\r\n?/g,`
|
|
183
|
-
`));return s.replaceSelectionWith(this.type.create({language:o},l)),s.selection.$from.parent.type!==this.type&&s.setSelection(Ie.near(s.doc.resolve(Math.max(0,s.selection.from-2)))),s.setMeta("paste",!0),n.dispatch(s),!0}}})]}}),GF=Fn.create({name:"doc",topNode:!0,content:"block+"});function ZF(n={}){return new pt({view(e){return new XF(e,n)}})}class XF{constructor(e,t){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=t.width)!==null&&r!==void 0?r:1,this.color=t.color===!1?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map(i=>{let o=s=>{this[i](s)};return e.dom.addEventListener(i,o),{name:i,handler:o}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){this.cursorPos!=null&&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,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,r,i=this.editorView.dom,o=i.getBoundingClientRect(),s=o.width/i.offsetWidth,a=o.height/i.offsetHeight;if(t){let u=e.nodeBefore,h=e.nodeAfter;if(u||h){let p=this.editorView.nodeDOM(this.cursorPos-(u?u.nodeSize:0));if(p){let m=p.getBoundingClientRect(),v=u?m.bottom:m.top;u&&h&&(v=(v+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let g=this.width/2*a;r={left:m.left,right:m.right,top:v-g,bottom:v+g}}}}if(!r){let u=this.editorView.coordsAtPos(this.cursorPos),h=this.width/2*s;r={left:u.left-h,right:u.left+h,top:u.top,bottom:u.bottom}}let l=this.editorView.dom.offsetParent;this.element||(this.element=l.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",t),this.element.classList.toggle("prosemirror-dropcursor-inline",!t);let c,d;if(!l||l==document.body&&getComputedStyle(l).position=="static")c=-pageXOffset,d=-pageYOffset;else{let u=l.getBoundingClientRect(),h=u.width/l.offsetWidth,p=u.height/l.offsetHeight;c=u.left-l.scrollLeft*h,d=u.top-l.scrollTop*p}this.element.style.left=(r.left-c)/s+"px",this.element.style.top=(r.top-d)/a+"px",this.element.style.width=(r.right-r.left)/s+"px",this.element.style.height=(r.bottom-r.top)/a+"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}),r=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),i=r&&r.type.spec.disableDropCursor,o=typeof i=="function"?i(this.editorView,t,e):i;if(t&&!o){let s=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let a=Nx(this.editorView.state.doc,s,this.editorView.dragging.slice);a!=null&&(s=a)}this.setCursor(s),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}const QF=Et.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[ZF(this.options)]}});class Nt extends Fe{constructor(e){super(e,e)}map(e,t){let r=e.resolve(t.map(this.head));return Nt.valid(r)?new Nt(r):Fe.near(r)}content(){return ye.empty}eq(e){return e instanceof Nt&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new Nt(e.resolve(t.pos))}getBookmark(){return new sv(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!$F(e)||!eV(e))return!1;let r=t.type.spec.allowGapCursor;if(r!=null)return r;let i=t.contentMatchAt(e.index()).defaultType;return i&&i.isTextblock}static findGapCursorFrom(e,t,r=!1){e:for(;;){if(!r&&Nt.valid(e))return e;let i=e.pos,o=null;for(let s=e.depth;;s--){let a=e.node(s);if(t>0?e.indexAfter(s)<a.childCount:e.index(s)>0){o=a.child(t>0?e.indexAfter(s):e.index(s)-1);break}else if(s==0)return null;i+=t;let l=e.doc.resolve(i);if(Nt.valid(l))return l}for(;;){let s=t>0?o.firstChild:o.lastChild;if(!s){if(o.isAtom&&!o.isText&&!Pe.isSelectable(o)){e=e.doc.resolve(i+o.nodeSize*t),r=!1;continue e}break}o=s,i+=t;let a=e.doc.resolve(i);if(Nt.valid(a))return a}return null}}}Nt.prototype.visible=!1;Nt.findFrom=Nt.findGapCursorFrom;Fe.jsonID("gapcursor",Nt);class sv{constructor(e){this.pos=e}map(e){return new sv(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return Nt.valid(t)?new Nt(t):Fe.near(t)}}function lS(n){return n.isAtom||n.spec.isolating||n.spec.createGapCursor}function $F(n){for(let e=n.depth;e>=0;e--){let t=n.index(e),r=n.node(e);if(t==0){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(t-1);;i=i.lastChild){if(i.childCount==0&&!i.inlineContent||lS(i.type))return!0;if(i.inlineContent)return!1}}return!0}function eV(n){for(let e=n.depth;e>=0;e--){let t=n.indexAfter(e),r=n.node(e);if(t==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(t);;i=i.firstChild){if(i.childCount==0&&!i.inlineContent||lS(i.type))return!0;if(i.inlineContent)return!1}}return!0}function tV(){return new pt({props:{decorations:oV,createSelectionBetween(n,e,t){return e.pos==t.pos&&Nt.valid(t)?new Nt(t):null},handleClick:rV,handleKeyDown:nV,handleDOMEvents:{beforeinput:iV}}})}const nV=zg({ArrowLeft:ed("horiz",-1),ArrowRight:ed("horiz",1),ArrowUp:ed("vert",-1),ArrowDown:ed("vert",1)});function ed(n,e){const t=n=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,i,o){let s=r.selection,a=e>0?s.$to:s.$from,l=s.empty;if(s instanceof Ie){if(!o.endOfTextblock(t)||a.depth==0)return!1;l=!1,a=r.doc.resolve(e>0?a.after():a.before())}let c=Nt.findGapCursorFrom(a,e,l);return c?(i&&i(r.tr.setSelection(new Nt(c))),!0):!1}}function rV(n,e,t){if(!n||!n.editable)return!1;let r=n.state.doc.resolve(e);if(!Nt.valid(r))return!1;let i=n.posAtCoords({left:t.clientX,top:t.clientY});return i&&i.inside>-1&&Pe.isSelectable(n.state.doc.nodeAt(i.inside))?!1:(n.dispatch(n.state.tr.setSelection(new Nt(r))),!0)}function iV(n,e){if(e.inputType!="insertCompositionText"||!(n.state.selection instanceof Nt))return!1;let{$from:t}=n.state.selection,r=t.parent.contentMatchAt(t.index()).findWrapping(n.state.schema.nodes.text);if(!r)return!1;let i=ie.empty;for(let s=r.length-1;s>=0;s--)i=ie.from(r[s].createAndFill(null,i));let o=n.state.tr.replace(t.pos,t.pos,new ye(i,0,0));return o.setSelection(Ie.near(o.doc.resolve(t.pos+1))),n.dispatch(o),!1}function oV(n){if(!(n.selection instanceof Nt))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",Qe.create(n.doc,[At.widget(n.selection.head,e,{key:"gapcursor"})])}const sV=Et.create({name:"gapCursor",addProseMirrorPlugins(){return[tV()]},extendNodeSchema(n){var e;const t={name:n.name,options:n.options,storage:n.storage};return{allowGapCursor:(e=Ze(Ae(n,"allowGapCursor",t)))!==null&&e!==void 0?e:null}}}),aV=Fn.create({name:"hardBreak",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:n}){return["br",zt(this.options.HTMLAttributes,n)]},renderText(){return`
|
|
184
|
-
`},addCommands(){return{setHardBreak:()=>({commands:n,chain:e,state:t,editor:r})=>n.first([()=>n.exitCode(),()=>n.command(()=>{const{selection:i,storedMarks:o}=t;if(i.$from.parent.type.spec.isolating)return!1;const{keepMarks:s}=this.options,{splittableMarks:a}=r.extensionManager,l=o||i.$to.parentOffset&&i.$from.marks();return e().insertContent({type:this.name}).command(({tr:c,dispatch:d})=>{if(d&&l&&s){const u=l.filter(h=>a.includes(h.type.name));c.ensureMarks(u)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),lV=Fn.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(n=>({tag:`h${n}`,attrs:{level:n}}))},renderHTML({node:n,HTMLAttributes:e}){return[`h${this.options.levels.includes(n.attrs.level)?n.attrs.level:this.options.levels[0]}`,zt(this.options.HTMLAttributes,e),0]},addCommands(){return{setHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.setNode(this.name,n):!1,toggleHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.toggleNode(this.name,"paragraph",n):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((n,e)=>({...n,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(n=>nm({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${n}})\\s$`),type:this.type,getAttributes:{level:n}}))}});var Ku=200,sn=function(){};sn.prototype.append=function(e){return e.length?(e=sn.from(e),!this.length&&e||e.length<Ku&&this.leafAppend(e)||this.length<Ku&&e.leafPrepend(this)||this.appendInner(e)):this};sn.prototype.prepend=function(e){return e.length?sn.from(e).append(this):this};sn.prototype.appendInner=function(e){return new cV(this,e)};sn.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?sn.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))};sn.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};sn.prototype.forEach=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length),t<=r?this.forEachInner(e,t,r,0):this.forEachInvertedInner(e,t,r,0)};sn.prototype.map=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length);var i=[];return this.forEach(function(o,s){return i.push(e(o,s))},t,r),i};sn.from=function(e){return e instanceof sn?e:e&&e.length?new cS(e):sn.empty};var cS=(function(n){function e(r){n.call(this),this.values=r}n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(i,o){return i==0&&o==this.length?this:new e(this.values.slice(i,o))},e.prototype.getInner=function(i){return this.values[i]},e.prototype.forEachInner=function(i,o,s,a){for(var l=o;l<s;l++)if(i(this.values[l],a+l)===!1)return!1},e.prototype.forEachInvertedInner=function(i,o,s,a){for(var l=o-1;l>=s;l--)if(i(this.values[l],a+l)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=Ku)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=Ku)return new e(i.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e})(sn);sn.empty=new cS([]);var cV=(function(n){function e(t,r){n.call(this),this.left=t,this.right=r,this.length=t.length+r.length,this.depth=Math.max(t.depth,r.depth)+1}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,i,o,s){var a=this.left.length;if(i<a&&this.left.forEachInner(r,i,Math.min(o,a),s)===!1||o>a&&this.right.forEachInner(r,Math.max(i-a,0),Math.min(this.length,o)-a,s+a)===!1)return!1},e.prototype.forEachInvertedInner=function(r,i,o,s){var a=this.left.length;if(i>a&&this.right.forEachInvertedInner(r,i-a,Math.max(o,a)-a,s+a)===!1||o<a&&this.left.forEachInvertedInner(r,Math.min(i,a),o,s)===!1)return!1},e.prototype.sliceInner=function(r,i){if(r==0&&i==this.length)return this;var o=this.left.length;return i<=o?this.left.slice(r,i):r>=o?this.right.slice(r-o,i-o):this.left.slice(r,o).append(this.right.slice(0,i-o))},e.prototype.leafAppend=function(r){var i=this.right.leafAppend(r);if(i)return new e(this.left,i)},e.prototype.leafPrepend=function(r){var i=this.left.leafPrepend(r);if(i)return new e(i,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e})(sn);const dV=500;class Mr{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,o;t&&(i=this.remapping(r,this.items.length),o=i.maps.length);let s=e.tr,a,l,c=[],d=[];return this.items.forEach((u,h)=>{if(!u.step){i||(i=this.remapping(r,h+1),o=i.maps.length),o--,d.push(u);return}if(i){d.push(new Kr(u.map));let p=u.step.map(i.slice(o)),m;p&&s.maybeStep(p).doc&&(m=s.mapping.maps[s.mapping.maps.length-1],c.push(new Kr(m,void 0,void 0,c.length+d.length))),o--,m&&i.appendMap(m,o)}else s.maybeStep(u.step);if(u.selection)return a=i?u.selection.map(i.slice(o)):u.selection,l=new Mr(this.items.slice(0,r).append(d.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:l,transform:s,selection:a}}addTransform(e,t,r,i){let o=[],s=this.eventCount,a=this.items,l=!i&&a.length?a.get(a.length-1):null;for(let d=0;d<e.steps.length;d++){let u=e.steps[d].invert(e.docs[d]),h=new Kr(e.mapping.maps[d],u,t),p;(p=l&&l.merge(h))&&(h=p,d?o.pop():a=a.slice(0,a.length-1)),o.push(h),t&&(s++,t=void 0),i||(l=h)}let c=s-r.depth;return c>fV&&(a=uV(a,c),s-=c),new Mr(a.append(o),s)}remapping(e,t){let r=new Pl;return this.items.forEach((i,o)=>{let s=i.mirrorOffset!=null&&o-i.mirrorOffset>=e?r.maps.length-i.mirrorOffset:void 0;r.appendMap(i.map,s)},e,t),r}addMaps(e){return this.eventCount==0?this:new Mr(this.items.append(e.map(t=>new Kr(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-t),o=e.mapping,s=e.steps.length,a=this.eventCount;this.items.forEach(h=>{h.selection&&a--},i);let l=t;this.items.forEach(h=>{let p=o.getMirror(--l);if(p==null)return;s=Math.min(s,p);let m=o.maps[p];if(h.step){let v=e.steps[p].invert(e.docs[p]),g=h.selection&&h.selection.map(o.slice(l+1,p));g&&a++,r.push(new Kr(m,v,g))}else r.push(new Kr(m))},i);let c=[];for(let h=t;h<s;h++)c.push(new Kr(o.maps[h]));let d=this.items.slice(0,i).append(c).append(r),u=new Mr(d,a);return u.emptyItemCount()>dV&&(u=u.compress(this.items.length-r.length)),u}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),r=t.maps.length,i=[],o=0;return this.items.forEach((s,a)=>{if(a>=e)i.push(s),s.selection&&o++;else if(s.step){let l=s.step.map(t.slice(r)),c=l&&l.getMap();if(r--,c&&t.appendMap(c,r),l){let d=s.selection&&s.selection.map(t.slice(r));d&&o++;let u=new Kr(c.invert(),l,d),h,p=i.length-1;(h=i.length&&i[p].merge(u))?i[p]=h:i.push(u)}}else s.map&&r--},this.items.length,0),new Mr(sn.from(i.reverse()),o)}}Mr.empty=new Mr(sn.empty,0);function uV(n,e){let t;return n.forEach((r,i)=>{if(r.selection&&e--==0)return t=i,!1}),n.slice(t)}class Kr{constructor(e,t,r,i){this.map=e,this.step=t,this.selection=r,this.mirrorOffset=i}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new Kr(t.getMap().invert(),t,this.selection)}}}class Qi{constructor(e,t,r,i,o){this.done=e,this.undone=t,this.prevRanges=r,this.prevTime=i,this.prevComposition=o}}const fV=20;function hV(n,e,t,r){let i=t.getMeta(cs),o;if(i)return i.historyState;t.getMeta(gV)&&(n=new Qi(n.done,n.undone,null,0,-1));let s=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(s&&s.getMeta(cs))return s.getMeta(cs).redo?new Qi(n.done.addTransform(t,void 0,r,Ad(e)),n.undone,A0(t.mapping.maps),n.prevTime,n.prevComposition):new Qi(n.done,n.undone.addTransform(t,void 0,r,Ad(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(s&&s.getMeta("addToHistory")===!1)){let a=t.getMeta("composition"),l=n.prevTime==0||!s&&n.prevComposition!=a&&(n.prevTime<(t.time||0)-r.newGroupDelay||!pV(t,n.prevRanges)),c=s?zh(n.prevRanges,t.mapping):A0(t.mapping.maps);return new Qi(n.done.addTransform(t,l?e.selection.getBookmark():void 0,r,Ad(e)),Mr.empty,c,t.time,a??n.prevComposition)}else return(o=t.getMeta("rebased"))?new Qi(n.done.rebased(t,o),n.undone.rebased(t,o),zh(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new Qi(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),zh(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function pV(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((r,i)=>{for(let o=0;o<e.length;o+=2)r<=e[o+1]&&i>=e[o]&&(t=!0)}),t}function A0(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((r,i,o,s)=>e.push(o,s));return e}function zh(n,e){if(!n)return null;let t=[];for(let r=0;r<n.length;r+=2){let i=e.map(n[r],1),o=e.map(n[r+1],-1);i<=o&&t.push(i,o)}return t}function mV(n,e,t){let r=Ad(e),i=cs.get(e).spec.config,o=(t?n.undone:n.done).popEvent(e,r);if(!o)return null;let s=o.selection.resolve(o.transform.doc),a=(t?n.done:n.undone).addTransform(o.transform,e.selection.getBookmark(),i,r),l=new Qi(t?a:o.remaining,t?o.remaining:a,null,0,-1);return o.transform.setSelection(s).setMeta(cs,{redo:t,historyState:l})}let Bh=!1,E0=null;function Ad(n){let e=n.plugins;if(E0!=e){Bh=!1,E0=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){Bh=!0;break}}return Bh}const cs=new xt("history"),gV=new xt("closeHistory");function vV(n={}){return n={depth:n.depth||100,newGroupDelay:n.newGroupDelay||500},new pt({key:cs,state:{init(){return new Qi(Mr.empty,Mr.empty,null,0,-1)},apply(e,t,r){return hV(t,r,e,n)}},config:n,props:{handleDOMEvents:{beforeinput(e,t){let r=t.inputType,i=r=="historyUndo"?uS:r=="historyRedo"?fS:null;return!i||!e.editable?!1:(t.preventDefault(),i(e.state,e.dispatch))}}}})}function dS(n,e){return(t,r)=>{let i=cs.getState(t);if(!i||(n?i.undone:i.done).eventCount==0)return!1;if(r){let o=mV(i,t,n);o&&r(e?o.scrollIntoView():o)}return!0}}const uS=dS(!1,!0),fS=dS(!0,!0),yV=Et.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:n,dispatch:e})=>uS(n,e),redo:()=>({state:n,dispatch:e})=>fS(n,e)}},addProseMirrorPlugins(){return[vV(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),bV=Fn.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:n}){return["hr",zt(this.options.HTMLAttributes,n)]},addCommands(){return{setHorizontalRule:()=>({chain:n,state:e})=>{if(!d4(e,e.schema.nodes[this.name]))return!1;const{selection:t}=e,{$from:r,$to:i}=t,o=n();return r.parentOffset===0?o.insertContentAt({from:Math.max(r.pos-1,0),to:i.pos},{type:this.name}):D3(t)?o.insertContentAt(i.pos,{type:this.name}):o.insertContent({type:this.name}),o.command(({tr:s,dispatch:a})=>{var l;if(a){const{$to:c}=s.selection,d=c.end();if(c.nodeAfter)c.nodeAfter.isTextblock?s.setSelection(Ie.create(s.doc,c.pos+1)):c.nodeAfter.isBlock?s.setSelection(Pe.create(s.doc,c.pos)):s.setSelection(Ie.create(s.doc,c.pos));else{const u=(l=c.parent.type.contentMatch.defaultType)===null||l===void 0?void 0:l.create();u&&(s.insert(d,u),s.setSelection(Ie.create(s.doc,d+1)))}s.scrollIntoView()}return!0}).run()}}},addInputRules(){return[c4({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),wV=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,xV=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,kV=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,_V=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,SV=fi.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:n=>n.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:n=>n.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:n}){return["em",zt(this.options.HTMLAttributes,n),0]},addCommands(){return{setItalic:()=>({commands:n})=>n.setMark(this.name),toggleItalic:()=>({commands:n})=>n.toggleMark(this.name),unsetItalic:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[_s({find:wV,type:this.type}),_s({find:kV,type:this.type})]},addPasteRules(){return[Eo({find:xV,type:this.type}),Eo({find:_V,type:this.type})]}}),CV=Fn.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:n}){return["li",zt(this.options.HTMLAttributes,n),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)}}}),TV="listItem",M0="textStyle",O0=/^(\d+)\.\s$/,AV=Fn.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:n=>n.hasAttribute("start")?parseInt(n.getAttribute("start")||"",10):1},type:{default:null,parseHTML:n=>n.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:n}){const{start:e,...t}=n;return e===1?["ol",zt(this.options.HTMLAttributes,t),0]:["ol",zt(this.options.HTMLAttributes,n),0]},addCommands(){return{toggleOrderedList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(TV,this.editor.getAttributes(M0)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let n=rc({find:O0,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)&&(n=rc({find:O0,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(M0)}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1],editor:this.editor})),[n]}}),EV=Fn.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:n}){return["p",zt(this.options.HTMLAttributes,n),0]},addCommands(){return{setParagraph:()=>({commands:n})=>n.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),MV=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,OV=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,DV=fi.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["s",zt(this.options.HTMLAttributes,n),0]},addCommands(){return{setStrike:()=>({commands:n})=>n.setMark(this.name),toggleStrike:()=>({commands:n})=>n.toggleMark(this.name),unsetStrike:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[_s({find:MV,type:this.type})]},addPasteRules(){return[Eo({find:OV,type:this.type})]}}),RV=Fn.create({name:"text",group:"inline"}),NV=Et.create({name:"starterKit",addExtensions(){const n=[];return this.options.bold!==!1&&n.push(VF.configure(this.options.bold)),this.options.blockquote!==!1&&n.push(PF.configure(this.options.blockquote)),this.options.bulletList!==!1&&n.push(UF.configure(this.options.bulletList)),this.options.code!==!1&&n.push(KF.configure(this.options.code)),this.options.codeBlock!==!1&&n.push(YF.configure(this.options.codeBlock)),this.options.document!==!1&&n.push(GF.configure(this.options.document)),this.options.dropcursor!==!1&&n.push(QF.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&n.push(sV.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&n.push(aV.configure(this.options.hardBreak)),this.options.heading!==!1&&n.push(lV.configure(this.options.heading)),this.options.history!==!1&&n.push(yV.configure(this.options.history)),this.options.horizontalRule!==!1&&n.push(bV.configure(this.options.horizontalRule)),this.options.italic!==!1&&n.push(SV.configure(this.options.italic)),this.options.listItem!==!1&&n.push(CV.configure(this.options.listItem)),this.options.orderedList!==!1&&n.push(AV.configure(this.options.orderedList)),this.options.paragraph!==!1&&n.push(EV.configure(this.options.paragraph)),this.options.strike!==!1&&n.push(DV.configure(this.options.strike)),this.options.text!==!1&&n.push(RV.configure(this.options.text)),n}}),td=new xt("tandemAnnotations");function Fh(n,e,t){const r=[],i=n.content.size;return e.forEach(o=>{const s=Ea(o,u=>{console.warn("[sanitize]",u)});if(s.status!=="pending"||!s.range&&!s.relRange)return;const a=ru(s,n,t);if(!a)return;s.relRange&&a.method==="flat"&&console.warn("[annotation] relRange-equipped annotation %s fell back to flat offsets",s.id);const{from:l,to:c}=a;if(l>=c||l<0||c>i)return;let d={};switch(s.type){case"highlight":{const u=Yw(s.color),h=Rl[u];d={class:`tandem-highlight tandem-highlight--${u}`,style:`background: ${h}; border-radius: var(--tandem-r-1); padding: 1px 0;`,"data-annotation-id":s.id,"data-annotation-author":s.author,"aria-label":`Highlight annotation (${u})`};break}case"comment":s.suggestedText!==void 0?d={class:"tandem-suggestion",style:"background: var(--tandem-suggestion-bg); text-decoration: underline wavy var(--tandem-suggestion); text-underline-offset: 3px;","data-annotation-id":s.id,"data-annotation-author":s.author,"aria-label":"Replacement annotation"}:s.author==="claude"?d={class:"tandem-comment tandem-comment--claude",style:"border-bottom: 2px solid var(--tandem-author-claude); padding-bottom: 1px;","data-annotation-id":s.id,"data-annotation-author":s.author,"aria-label":"Claude comment annotation"}:d={class:"tandem-comment",style:"border-bottom: 2px dashed var(--tandem-author-user); padding-bottom: 1px;","data-annotation-id":s.id,"data-annotation-author":s.author,"aria-label":"Comment annotation"};break;case"note":d={class:"tandem-note",style:"border-bottom: 2px dotted var(--tandem-fg-muted); padding-bottom: 1px;","data-annotation-id":s.id,"data-annotation-author":s.author,"aria-label":"Note annotation"};break;default:{console.warn("[annotation] Unhandled annotation type in buildDecorations, skipping");return}}try{r.push(At.inline(l,c,d))}catch(u){if(!(u instanceof RangeError))throw u;console.debug("[annotation] RangeError for %s (from=%d, to=%d), skipping",s.id,l,c)}}),Qe.create(n,r)}const IV=Et.create({name:"tandemAnnotations",addOptions(){return{ydoc:null}},addProseMirrorPlugins(){const n=this.options.ydoc;if(!n)return[];const e=n.getMap(xo);let t=e.size>0,r=!1;return[new pt({key:td,state:{init(i,o){return Fh(o.doc,e,n)},apply(i,o,s,a){if(i.getMeta(td))return Fh(a.doc,e,n);if(i.docChanged){if(!r&&o===Qe.empty&&t){const l=Fh(a.doc,e,n);return l!==Qe.empty&&(r=!0),l}return o.map(i.mapping,i.doc)}return o}},props:{decorations(i){return td.getState(i)}},view(i){const o=()=>{t=e.size>0,r=!1;const s=i.state.tr.setMeta(td,!0);i.dispatch(s)};return e.observe(o),{destroy(){e.unobserve(o)}}}})]}}),js=new xt("tandemAuthorship"),PV=new Set(["paragraph","heading"]);function LV(n,e,t){if(n.relRange){const r=vk(t,e,n.relRange);if(r&&r.from<r.to)return r}if(n.range){console.warn("[authorship] Falling back to flat offsets for range",n.id);const r=To(e,n.range.from),i=To(e,n.range.to);if(r<i)return{from:r,to:i}}return null}function Vh(n,e,t,r){if(!r)return Qe.empty;const i=[],o=n.content.size,s=[];return e.forEach(a=>{const l=a;if(!l.author||!l.range||l.author!=="user"&&l.author!=="claude")return;const c=LV(l,n,t);if(!c)return;const{from:d,to:u}=c;if(!(d>=u||d<0||u>o)){try{i.push(At.inline(d,u,{"data-tandem-author":l.author}))}catch(h){if(!(h instanceof RangeError))throw h;console.warn("[authorship] Decoration RangeError for entry",l.id,h)}s.push({author:l.author,from:d,to:u})}}),n.descendants((a,l)=>{if(!PV.has(a.type.name))return;const c=l,d=l+a.nodeSize;let u=0,h=0;for(const m of s){const v=Math.max(m.from,c),g=Math.min(m.to,d);if(g<=v)continue;const y=g-v;m.author==="user"?u+=y:h+=y}if(u===0&&h===0)return;const p=u>=h?"user":"claude";try{i.push(At.node(c,d,{"data-tandem-author-block":p}))}catch(m){if(!(m instanceof RangeError))throw m;console.warn("[authorship] node Decoration RangeError at offset",l,m)}}),Qe.create(n,i)}const zV=Et.create({name:"tandemAuthorship",addOptions(){return{ydoc:null}},addProseMirrorPlugins(){const n=this.options.ydoc;if(!n)return[];const e=n.getMap(Zv);let t=!1;try{t=localStorage.getItem($w)==="true"}catch(r){console.warn("[authorship] localStorage unavailable",r)}return[new pt({key:js,state:{init(r,i){return{visible:t,decorations:Vh(i.doc,e,n,t)}},apply(r,i,o,s){const a=r.getMeta(js);if((a==null?void 0:a.type)==="toggle"){const l=a.visible;return{visible:l,decorations:Vh(s.doc,e,n,l)}}return(a==null?void 0:a.type)==="rebuild"?{visible:i.visible,decorations:Vh(s.doc,e,n,i.visible)}:r.docChanged&&i.visible?{visible:i.visible,decorations:i.decorations.map(r.mapping,r.doc)}:i}},props:{decorations(r){var i;return((i=js.getState(r))==null?void 0:i.decorations)??Qe.empty}},view(r){const i=()=>{const s=r.state.tr.setMeta(js,{type:"rebuild"});r.dispatch(s)};e.observe(i);const o=setTimeout(()=>{e.size>0&&i()},500);return{destroy(){clearTimeout(o),e.unobserve(i)}}}})]},onTransaction({transaction:n}){const e=this.options.ydoc;if(!e||n.getMeta("y-sync$")||n.getMeta(js)||!n.docChanged)return;const t=e.getMap(Zv),r=n.doc;n.steps.forEach(i=>{i.getMap().forEach((s,a,l,c)=>{if(c-l-(a-s)>0)try{const u=$r(r,mn(l)),h=$r(r,mn(c));if(h<=u)return;const p=DD("user"),m={id:p,author:"user",range:{from:u,to:h},timestamp:Date.now()};t.set(p,m)}catch(u){console.warn("[authorship] Position conversion failed during user attribution",u)}})})}}),nd=new xt("tandemAwareness");function D0(n,e){if(!e)return Qe.empty;const t=[],{focusParagraph:r,focusOffset:i,active:o}=e;if(r!==null&&r>=0){let s=0;n.forEach((a,l)=>{s===r&&t.push(At.node(l,l+a.nodeSize,{class:"tandem-claude-focus",style:"background: var(--tandem-claude-focus-bg); border-left: 3px solid var(--tandem-claude-focus-border); padding-left: 8px; transition: background 0.3s ease, border-color 0.3s ease;"})),s++})}if(i!==null&&i>=0)try{const s=To(n,dd(i)),a=o===!1?" tandem-claude-cursor-idle":"";t.push(At.widget(s,()=>{const l=document.createElement("span");l.className=`tandem-claude-cursor${a}`,l.setAttribute("aria-hidden","true");const c=document.createElement("span");return c.className="tandem-claude-cursor-label",c.textContent="Claude",l.appendChild(c),l}))}catch(s){console.warn("[awareness] cursor decoration failed, falling back to gutter-only:",s)}return t.length===0?Qe.empty:Qe.create(n,t)}const BV=Et.create({name:"tandemAwareness",addOptions(){return{ydoc:null}},addProseMirrorPlugins(){const n=this.options.ydoc;if(!n)return[];const e=n.getMap(Qw),t=n.getMap(dp);return[new pt({key:nd,state:{init(r,i){const o=e.get(up);return D0(i.doc,o??null)},apply(r,i,o,s){if(r.getMeta(nd)){const a=e.get(up);return D0(s.doc,a??null)}return r.docChanged?i.map(r.mapping,r.doc):i}},props:{decorations(r){return nd.getState(r)}},view(r){const i=()=>{const o=r.state.tr.setMeta(nd,!0);r.dispatch(o)};return e.observe(i),{destroy(){e.unobserve(i)}}}}),new pt({key:new xt("tandemUserAwareness"),view(){let r=null,i=null,o=null,s=!1,a=-1;return{update(l,c){const{state:d}=l;if(!d.selection.eq(c.selection)){const u=yk(d.doc,{from:mn(d.selection.from),to:mn(d.selection.to)});if(d.selection.from===d.selection.to)o&&(clearTimeout(o),o=null),t.set(Xv,{...u,timestamp:Date.now()});else{const h=d.doc.textBetween(d.selection.from,d.selection.to,`
|
|
185
|
-
`),p=h.length>200?h.slice(0,197)+"...":h;o&&clearTimeout(o),o=setTimeout(()=>{o=null,t.set(Xv,{...u,selectedText:p,timestamp:Date.now()})},150)}}d.doc!==c.doc&&(a=d.selection.from,s=!0,i||(i=setTimeout(()=>{i=null,s&&t.set(Qv,{isTyping:!0,cursor:a,lastEdit:Date.now()})},200)),r&&clearTimeout(r),r=setTimeout(()=>{s=!1,t.set(Qv,{isTyping:!1,cursor:l.state.selection.from,lastEdit:Date.now()})},tA))},destroy(){r&&clearTimeout(r),i&&clearTimeout(i),o&&clearTimeout(o)}}}})]}}),qr=new xt("tandemFindReplace"),hS={query:"",caseSensitive:!1,wholeWord:!1,regexMode:!1,matches:[],activeIndex:-1,decoSet:Qe.empty};function FV(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function VV(n){if(!n.query)return null;try{const e=n.regexMode?n.query:FV(n.query),t=n.caseSensitive?"g":"gi",r=n.wholeWord?`\\b${e}\\b`:e;return new RegExp(r,t)}catch{return null}}function pS(n,e){const t=VV(e);if(!t)return[];const r=[];return n.descendants((i,o)=>{if(!i.isTextblock)return;const s=i.textContent;for(const a of s.matchAll(t)){const l=a.index??0;r.push({from:o+1+l,to:o+1+l+a[0].length})}}),r}function Sl(n,e,t){if(e.length===0)return Qe.empty;const r=[];for(let i=0;i<e.length;i++){const{from:o,to:s}=e[i];try{r.push(At.inline(o,s,{class:i===t?"tandem-find-active":"tandem-find-match"}))}catch{}}return Qe.create(n,r)}function km(n,e){if(n.length===0)return-1;for(let t=0;t<n.length;t++)if(n[t].from<=e&&e<=n[t].to)return t;for(let t=0;t<n.length;t++)if(n[t].from>e)return t;return 0}function HV(n,e,t){if(n.type==="close")return hS;if(n.type==="find"){const i=n.opts,o=pS(t.doc,i),s=t.selection.from,a=km(o,s);return{...i,matches:o,activeIndex:a,decoSet:Sl(t.doc,o,a)}}if(n.type==="next"){const i=e.matches.length===0?-1:(e.activeIndex+1)%e.matches.length;return{...e,activeIndex:i,decoSet:Sl(t.doc,e.matches,i)}}if(n.type==="prev"){const i=e.matches.length===0?-1:(e.activeIndex-1+e.matches.length)%e.matches.length;return{...e,activeIndex:i,decoSet:Sl(t.doc,e.matches,i)}}return n}const UV=Et.create({name:"tandemFindReplace",addProseMirrorPlugins(){return[new pt({key:qr,state:{init:()=>hS,apply(n,e,t,r){const i=n.getMeta(qr);if(i)return HV(i,e,r);if(!e.query)return e;if(n.docChanged){const a=pS(r.doc,e),l=r.selection.from,c=km(a,l);return{...e,matches:a,activeIndex:c,decoSet:Sl(r.doc,a,c)}}const o=r.selection.from,s=km(e.matches,o);return s===e.activeIndex?e:{...e,activeIndex:s,decoSet:Sl(r.doc,e.matches,s)}}},props:{decorations(n){var e;return((e=qr.getState(n))==null?void 0:e.decoSet)??Qe.empty}}})]},addCommands(){return{find:n=>({dispatch:e,tr:t})=>(e&&e(t.setMeta(qr,{type:"find",opts:n})),!0),findNext:()=>({dispatch:n,tr:e})=>(n&&n(e.setMeta(qr,{type:"next"})),!0),findPrev:()=>({dispatch:n,tr:e})=>(n&&n(e.setMeta(qr,{type:"prev"})),!0),findClose:()=>({dispatch:n,tr:e})=>(n&&n(e.setMeta(qr,{type:"close"})),!0)}},addKeyboardShortcuts(){return{Escape:({editor:n})=>{const e=qr.getState(n.state);return e!=null&&e.query?(n.commands.findClose(),!0):!1}}}});function av(n){return qr.getState(n)}function jV(n,e){const t=av(n.state);if(!t||t.activeIndex<0||t.matches.length===0)return!1;const{from:r,to:i}=t.matches[t.activeIndex],o=n.state.tr.insertText(e,r,i).setMeta(qr,{type:"next"});return n.dispatch(o),!0}async function WV(n,e,t){let i=0,o=!1;for(let s=0;s<50;s++){const a=av(n.state);if(!(a!=null&&a.query)||a.matches.length===0)break;const l=a.matches.slice(0,100);try{let c=n.state.tr;for(let d=l.length-1;d>=0;d--){const{from:u,to:h}=l[d];c=c.insertText(e,u,h)}n.dispatch(c),i+=l.length,t==null||t(i,i+(a.matches.length-l.length))}catch(c){o=!0,console.warn("[find-replace] replaceAll chunk failed at pass",s,c);break}if(l.length<100)break;await new Promise(c=>setTimeout(c,0))}return{replaced:i,partial:o}}const KV=Et.create({name:"markdownHtml",addGlobalAttributes(){return[{types:["paragraph"],attributes:{markdownHtml:{default:null,parseHTML:()=>null,renderHTML:()=>({})}}}]}}),_i=new xt("tandemSlashCommand");function Bs(n){return n.chain().focus()}const R0=[{id:"heading-1",label:"Heading 1",keywords:["h1","heading","title"],run:n=>Bs(n).toggleHeading({level:1}).run()},{id:"heading-2",label:"Heading 2",keywords:["h2","heading","subtitle"],run:n=>Bs(n).toggleHeading({level:2}).run()},{id:"bullet-list",label:"Bullet list",keywords:["bullet","ul","list"],run:n=>Bs(n).toggleBulletList().run()},{id:"numbered-list",label:"Numbered list",keywords:["numbered","ordered","ol","list"],run:n=>Bs(n).toggleOrderedList().run()},{id:"quote",label:"Quote",keywords:["blockquote","quote"],run:n=>Bs(n).toggleBlockquote().run()},{id:"code-block",label:"Code block",keywords:["code","pre"],run:n=>Bs(n).toggleCodeBlock().run()}];function qV(n){const e=/(?:^|\s)\/([A-Za-z0-9 -]*)$/.exec(n);if(!e)return null;const t=e[1]??"";return{fromOffset:n.length-t.length-1,query:t}}function If(n){const e=n.trim().toLowerCase();return e?R0.filter(t=>[t.label,...t.keywords].join(" ").toLowerCase().includes(e)):R0}function mS(n){return`${n.from}:${n.to}:${n.query}`}function N0(n,e=0){const{selection:t}=n;if(!t.empty)return null;const r=t.$from,i=r.parent.textBetween(0,r.parentOffset,`
|
|
186
|
-
`,`
|
|
187
|
-
`),o=qV(i);if(!o)return null;const s=r.start()+o.fromOffset,a=r.pos,l=If(o.query);return l.length===0?null:{from:s,to:a,query:o.query,selectedIndex:Math.min(e,l.length-1)}}function JV(n,e){const t=n.getMeta(_i);return t?t.type==="close"?{active:null,dismissedKey:e.active?mS(e.active):e.dismissedKey}:t.type==="select"&&e.active?{...e,active:{...e.active,selectedIndex:t.selectedIndex??e.active.selectedIndex}}:e:null}function YV(n,e,t,r,i){const o=If(e.query);n.innerHTML="",n.setAttribute("role","listbox"),n.setAttribute("aria-label","Slash commands"),o.forEach((a,l)=>{const c=document.createElement("button");c.type="button",c.role="option",c.id=`slash-command-${a.id}`,c.setAttribute("aria-selected",String(l===e.selectedIndex)),c.textContent=a.label,c.dataset.commandId=a.id,c.style.cssText="display: block; width: 100%; padding: 7px 10px; border: 0; border-radius: var(--tandem-r-2); background: transparent; color: var(--tandem-fg); font: inherit; font-size: 13px; text-align: left; cursor: pointer;",l===e.selectedIndex&&(c.style.background="var(--tandem-accent-bg)",c.style.color="var(--tandem-accent)"),c.addEventListener("mouseenter",()=>r(l)),c.addEventListener("mousedown",d=>{d.preventDefault(),i(a)}),n.appendChild(c)});const s=t.view.coordsAtPos(e.from);n.style.display="block",n.style.position="fixed",n.style.left=`${Math.max(8,s.left)}px`,n.style.top=`${s.bottom+8}px`,n.style.zIndex="1100",n.style.minWidth="180px",n.style.padding="4px",n.style.border="1px solid var(--tandem-border)",n.style.borderRadius="6px",n.style.background="var(--tandem-surface)",n.style.boxShadow="0 1px 2px color-mix(in srgb, var(--tandem-fg) 4%, transparent), 0 8px 28px color-mix(in srgb, var(--tandem-fg) 10%, transparent)"}function GV(n,e){const t=If(e.query)[e.selectedIndex];return t?(n.chain().focus().deleteRange({from:e.from,to:e.to}).run(),t.run(n),!0):!1}const ZV=Et.create({name:"slashCommand",addOptions(){return{onOpenChange:void 0}},addProseMirrorPlugins(){const n=this.editor,e=this.options.onOpenChange;return[new pt({key:_i,state:{init:(t,r)=>({active:N0(r),dismissedKey:null}),apply(t,r,i,o){var l;const s=JV(t,r);if(s)return s;const a=N0(o,((l=r.active)==null?void 0:l.selectedIndex)??0);return a&&mS(a)===r.dismissedKey?{active:null,dismissedKey:r.dismissedKey}:{active:a,dismissedKey:a?null:r.dismissedKey}}},props:{handleKeyDown(t,r){const i=_i.getState(t.state),o=i==null?void 0:i.active;if(!o)return!1;const s=If(o.query);if(r.key==="ArrowDown"){r.preventDefault();const a=(o.selectedIndex+1)%s.length;return t.dispatch(t.state.tr.setMeta(_i,{type:"select",selectedIndex:a})),!0}if(r.key==="ArrowUp"){r.preventDefault();const a=(o.selectedIndex-1+s.length)%s.length;return t.dispatch(t.state.tr.setMeta(_i,{type:"select",selectedIndex:a})),!0}return r.key==="Enter"?(r.preventDefault(),GV(n,o)):r.key==="Escape"?(r.preventDefault(),t.dispatch(t.state.tr.setMeta(_i,{type:"close"})),!0):!1}},view(t){const r=document.createElement("div");r.dataset.testid="slash-command-menu",r.style.display="none",document.body.appendChild(r);let i=!1;const o=l=>{l!==i&&(i=l,e==null||e(l))},s=()=>{r.style.display="none",r.innerHTML="",o(!1)},a=()=>{var c;const l=(c=_i.getState(t.state))==null?void 0:c.active;if(!l){s();return}YV(r,l,n,d=>{t.dispatch(t.state.tr.setMeta(_i,{type:"select",selectedIndex:d}))},d=>{n.chain().focus().deleteRange({from:l.from,to:l.to}).run(),d.run(n),s(),t.dispatch(t.state.tr.setMeta(_i,{type:"close"}))}),o(!0)};return a(),{update:a,destroy(){o(!1),r.remove()}}}})]}});var XV=O('<div role="presentation"></div>');function QV(n,e){We(e,!0);const t=new Set([...eA].filter(d=>d!==".docx")),r=["http://","https://","mailto:","ftp://","//"];function i(d){return r.some(u=>d.startsWith(u))}function o(d,u){const h=u.includes("\\")?"\\":"/",p=d.indexOf("#"),m=p>=0?d.slice(0,p):d;if(!m)return null;const v=m.match(/\.[^./\\]+$/),g=v?v[0].toLowerCase():"";if(!t.has(g))return null;const y=u.split(h);y.pop();const _=m.replace(/\//g,h).split(h),S=[...y];for(const A of _)A===".."?S.length>0&&S.pop():A!=="."&&S.push(A);return S.join(h)}let s=z(null),a=null;he(()=>{if(e.ydoc,e.provider,!a)return;const d=new l4({element:a,extensions:[NV.configure({history:!1}),tB.configure({multicolor:!0}),TB.configure({openOnClick:!1,HTMLAttributes:{rel:"noopener noreferrer",target:"_blank"}}),AB.configure({placeholder:"Start typing…"}),OF.configure({resizable:!0}),NF,DF,RF,KV,X4.configure({document:e.ydoc}),Q4.configure({provider:e.provider,user:{name:_g(),color:"var(--tandem-warning)"}}),IV.configure({ydoc:e.ydoc}),zV.configure({ydoc:e.ydoc}),BV.configure({ydoc:e.ydoc}),ZV.configure({onOpenChange:e.onSlashCommandMenuChange}),UV],editorProps:{attributes:{class:"tandem-editor",style:"outline: none; min-height: 500px; font-size: var(--tandem-editor-font-size, 16px); line-height: 1.6;"}},editable:Ut(()=>!e.readOnly),autofocus:Ut(()=>!e.readOnly)});return b(s,d,!0),Ut(()=>{var u;return(u=e.onEditorReady)==null?void 0:u.call(e,d)}),()=>{Ut(()=>{var u;return(u=e.onEditorReady)==null?void 0:u.call(e,null)}),d.destroy(),f(s)===d&&b(s,null)}}),he(()=>{const d=f(s);d&&d.setEditable(!e.readOnly)}),he(()=>{const d=f(s);if(d)return wk(u=>d.commands.updateUser({name:u}))}),he(()=>{const d=f(s);if(!d)return;const u=d.view.dom;u.querySelectorAll(".tandem-annotation-active").forEach(h=>{h.classList.remove("tandem-annotation-active")}),e.activeAnnotationId&&u.querySelectorAll(`[data-annotation-id="${CSS.escape(e.activeAnnotationId)}"]`).forEach(h=>{h.classList.add("tandem-annotation-active")})});async function l(d){const u=d.target.closest("a[href]");if(u){const m=u.getAttribute("href")??"";if(!m||m.startsWith("#"))return;if(d.preventDefault(),i(m)){window.open(m,"_blank","noopener,noreferrer");return}if(e.currentFilePath){const v=o(m,e.currentFilePath);if(v)try{const g=await fetch(`${Sr}/open`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filePath:v})});if(!g.ok){const y=await g.json().catch(()=>({}));console.warn(`[tandem] Could not open linked file "${v}": ${y.message??g.statusText}`)}}catch(g){console.warn("[tandem] Failed to open relative link:",g)}}return}const h=d.target.closest("[data-annotation-id]");if(!h)return;const p=h.getAttribute("data-annotation-id");p&&e.onAnnotationClick&&e.onAnnotationClick(p)}var c=XV();yt(c,d=>a=d,()=>a),L("click",c,l),T(n,c),Ke()}Ye(["click"]);var $V=O('<div data-testid="find-scope-pills" style="display: flex; gap: var(--tandem-space-1); align-items: center;"><button data-testid="find-scope-doc">This document</button> <button data-testid="find-scope-tabs">Open tabs</button></div>'),eH=O('<div style="font-size: var(--tandem-text-xs); color: var(--tandem-error-fg);" role="alert"> </div>'),tH=O('<div style="font-size: var(--tandem-text-xs); color: var(--tandem-warning-fg); padding: 2px 0;" role="status"> </div>'),nH=O('<div style="font-size: var(--tandem-text-xs); color: var(--tandem-fg-subtle);">Searching…</div>'),rH=O('<div style="font-size: var(--tandem-text-xs); color: var(--tandem-fg-subtle);">No matches in open tabs</div>'),iH=O('<div style="font-size: var(--tandem-text-2xs); color: var(--tandem-fg-subtle); padding-left: var(--tandem-space-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;"> </div>'),oH=O('<div style="display: flex; flex-direction: column; gap: 2px;"><div style="font-size: var(--tandem-text-xs); color: var(--tandem-fg); font-weight: 500;"> <span style="color: var(--tandem-fg-subtle); font-weight: normal;"> </span></div> <!></div>'),sH=O('<div data-testid="find-cross-doc-results" style="border-top: 1px solid var(--tandem-border); padding-top: var(--tandem-space-2); display: flex; flex-direction: column; gap: var(--tandem-space-1);"><!></div>'),aH=O(`<div data-testid="find-replace-bar" role="dialog" tabindex="-1" aria-modal="false" aria-label="Find and replace" style="
|
|
188
|
-
position: absolute; bottom: 0; right: 0;
|
|
189
|
-
background: var(--tandem-surface); border: 1px solid var(--tandem-border);
|
|
190
|
-
border-radius: var(--tandem-r-3) var(--tandem-r-3) 0 0;
|
|
191
|
-
padding: var(--tandem-space-3) var(--tandem-space-4);
|
|
192
|
-
box-shadow: var(--tandem-shadow-3);
|
|
193
|
-
z-index: var(--tandem-z-overlay, 200);
|
|
194
|
-
min-width: 320px; max-width: 480px;
|
|
195
|
-
display: flex; flex-direction: column; gap: var(--tandem-space-2);
|
|
196
|
-
"><!> <div style="display: flex; gap: var(--tandem-space-2); align-items: center;"><input data-testid="find-input" type="text" placeholder="Find…" aria-label="Find"/> <span data-testid="find-match-count" style="font-size: var(--tandem-text-xs); color: var(--tandem-fg-muted); white-space: nowrap; min-width: 48px; text-align: right;"><!></span> <button data-testid="find-prev-btn" title="Previous match (Shift+Enter)" aria-label="Previous match">↑</button> <button data-testid="find-next-btn" title="Next match (Enter)" aria-label="Next match">↓</button> <button data-testid="find-close-btn" title="Close (Esc)" aria-label="Close find bar" style="background: none; border: none; cursor: pointer; font-size: 16px; color: var(--tandem-fg-muted); padding: 0 2px; line-height: 1;">×</button></div> <!> <div style="display: flex; gap: var(--tandem-space-3); align-items: center;"><label style="display: flex; align-items: center; gap: 4px; font-size: var(--tandem-text-xs); color: var(--tandem-fg-muted); cursor: pointer; user-select: none;"><input data-testid="find-case-toggle" type="checkbox"/> Aa</label> <label style="display: flex; align-items: center; gap: 4px; font-size: var(--tandem-text-xs); color: var(--tandem-fg-muted); cursor: pointer; user-select: none;"><input data-testid="find-word-toggle" type="checkbox"/> \\b</label> <label style="display: flex; align-items: center; gap: 4px; font-size: var(--tandem-text-xs); color: var(--tandem-fg-muted); cursor: pointer; user-select: none;"><input data-testid="find-regex-toggle" type="checkbox"/> .*</label></div> <div style="display: flex; gap: var(--tandem-space-2); align-items: center;"><input data-testid="replace-input" type="text" placeholder="Replace with…" aria-label="Replace with" style="
|
|
197
|
-
flex: 1; padding: 4px 8px; font-size: var(--tandem-text-sm);
|
|
198
|
-
border: 1px solid var(--tandem-border); border-radius: var(--tandem-r-2);
|
|
199
|
-
background: var(--tandem-surface); color: var(--tandem-fg); outline: none;
|
|
200
|
-
"/> <button data-testid="replace-btn">Replace</button> <button data-testid="replace-all-btn"><!></button></div> <!> <!></div>`);function lH(n,e){We(e,!0);let t=lt(e,"tabs",19,()=>[]),r=z("doc"),i=z(at([])),o=z(!1);he(()=>{t().length<=1&&f(r)==="tabs"&&(b(r,"doc"),b(i,[],!0),b(o,!1))});function s(F){const X=F.getXmlFragment("default"),B=[];function j(ae){if(ae instanceof yn)B.push(ae.toString());else{for(let C=0;C<ae.length;C++){const I=ae.get(C);(I instanceof yn||I instanceof Wt)&&j(I)}ae instanceof Wt&&ae.nodeName!=="text"&&B.push(" ")}}return j(X),B.join("")}function a(F,X,B){const j=s(F),ae=B?X:X.toLowerCase(),C=B?j:j.toLowerCase(),I=[];let W=0,ge=0;for(;(ge=C.indexOf(ae,ge))!==-1;){if(W++,I.length<3){const xe=Math.max(0,ge-30),Oe=Math.min(j.length,ge+ae.length+30),J=j.slice(xe,Oe).replace(/\s+/g," ").trim();I.push((xe>0?"…":"")+J+(Oe<j.length?"…":""))}ge+=ae.length}return{count:W,snippets:I}}let l;pi(()=>clearTimeout(l));function c(F,X){if(clearTimeout(l),!F){b(i,[],!0),b(o,!1);return}b(o,!0),l=setTimeout(()=>{const B=[];for(const j of t()){if(!j.ydoc)continue;const{count:ae,snippets:C}=a(j.ydoc,F,X);ae>0&&B.push({tabId:j.id,fileName:j.fileName,count:ae,snippets:C})}b(i,B,!0),b(o,!1)},300)}let d=z(""),u=z(""),h=z(!1),p=z(!1),m=z(!1),v=z(null),g=z(!1),y=z(null),w=z(null),_=z(0);const S=P(()=>(f(_),e.editor?av(e.editor.state):void 0)),A=P(()=>{var F;return((F=f(S))==null?void 0:F.matches.length)??0}),U=P(()=>{var F;return((F=f(S))==null?void 0:F.activeIndex)??-1});let N=z(null);he(()=>{var F;e.open&&((F=f(N))==null||F.focus())}),he(()=>{const F=e.editor;if(!F||F.isDestroyed)return;const X=()=>Md(_);return F.on("update",X),F.on("selectionUpdate",X),()=>{F.isDestroyed||(F.off("update",X),F.off("selectionUpdate",X))}});function R(){if(f(r)==="tabs"){c(f(d),f(h));return}const F=e.editor;if(!F||!f(d)){b(v,null),F==null||F.commands.findClose();return}if(f(m))try{new RegExp(f(d)),b(v,null)}catch(B){b(v,B instanceof Error?B.message:"Invalid regex",!0);return}else b(v,null);const X={query:f(d),caseSensitive:f(h),wholeWord:f(p),regexMode:f(m)};F.commands.find(X)}function E(F){var X;b(r,F,!0),F==="tabs"?((X=e.editor)==null||X.commands.findClose(),c(f(d),f(h))):(b(i,[],!0),clearTimeout(l),R())}function q(F){var X,B;if(F.key==="Enter"){F.preventDefault(),F.shiftKey?(X=e.editor)==null||X.commands.findPrev():(B=e.editor)==null||B.commands.findNext();return}F.key==="Escape"&&te()}function te(){var F;(F=e.editor)==null||F.commands.findClose(),e.onClose()}async function K(){const F=e.editor;if(!F||!f(d)||f(g))return;const X=f(A);if(X>500&&!window.confirm(`Replace all ${X} occurrences? This cannot be undone as a single action.`))return;b(g,!0),b(w,null),b(y,{replaced:0,total:X},!0);const{replaced:B,partial:j}=await WV(F.view,f(u),(ae,C)=>{b(y,{replaced:ae,total:C},!0)});b(y,null),b(g,!1),j&&b(w,`Replaced ${B} of ${X}; re-run to continue`)}var V=Tt(),ee=Le(V);{var se=F=>{var X=aH(),B=x(X);{var j=Ce=>{var Ne=$V(),mt=x(Ne),Yt=k(mt,2);G(()=>{Q(mt,"aria-pressed",f(r)==="doc"),re(mt,`
|
|
201
|
-
padding: 2px var(--tandem-space-2); font-size: var(--tandem-text-xs);
|
|
202
|
-
border: 1px solid ${f(r)==="doc"?"var(--tandem-accent-border)":"var(--tandem-border)"};
|
|
203
|
-
border-radius: var(--tandem-r-pill);
|
|
204
|
-
background: ${f(r)==="doc"?"var(--tandem-accent-bg)":"var(--tandem-surface)"};
|
|
205
|
-
color: ${f(r)==="doc"?"var(--tandem-accent)":"var(--tandem-fg-muted)"};
|
|
206
|
-
cursor: pointer;
|
|
207
|
-
`),Q(Yt,"aria-pressed",f(r)==="tabs"),re(Yt,`
|
|
208
|
-
padding: 2px var(--tandem-space-2); font-size: var(--tandem-text-xs);
|
|
209
|
-
border: 1px solid ${f(r)==="tabs"?"var(--tandem-accent-border)":"var(--tandem-border)"};
|
|
210
|
-
border-radius: var(--tandem-r-pill);
|
|
211
|
-
background: ${f(r)==="tabs"?"var(--tandem-accent-bg)":"var(--tandem-surface)"};
|
|
212
|
-
color: ${f(r)==="tabs"?"var(--tandem-accent)":"var(--tandem-fg-muted)"};
|
|
213
|
-
cursor: pointer;
|
|
214
|
-
`)}),L("click",mt,()=>E("doc")),L("click",Yt,()=>E("tabs")),T(Ce,Ne)};Z(B,Ce=>{t().length>1&&Ce(j)})}var ae=k(B,2),C=x(ae);yt(C,Ce=>b(N,Ce),()=>f(N));var I=k(C,2),W=x(I);{var ge=Ce=>{var Ne=Nn();G(()=>ne(Ne,f(A)===0?"No matches":`${f(U)+1} / ${f(A)}`)),T(Ce,Ne)};Z(W,Ce=>{f(d)&&Ce(ge)})}var xe=k(I,2),Oe=k(xe,2),J=k(Oe,2),fe=k(ae,2);{var D=Ce=>{var Ne=eH(),mt=x(Ne);G(()=>ne(mt,f(v))),T(Ce,Ne)};Z(fe,Ce=>{f(v)&&Ce(D)})}var Y=k(fe,2),be=x(Y),we=x(be),Te=k(be,2),Se=x(Te),De=k(Te,2),oe=x(De),M=k(Y,2),$=x(M),le=k($,2),de=k(le,2),Ee=x(de);{var ce=Ce=>{var Ne=Nn();G(()=>ne(Ne,`${f(y).replaced??""}/${f(y).total??""}`)),T(Ce,Ne)},ve=Ce=>{var Ne=Nn("All");T(Ce,Ne)};Z(Ee,Ce=>{f(g)&&f(y)?Ce(ce):Ce(ve,-1)})}var ke=k(M,2);{var pe=Ce=>{var Ne=tH(),mt=x(Ne);G(()=>ne(mt,f(w))),T(Ce,Ne)};Z(ke,Ce=>{f(w)&&Ce(pe)})}var ze=k(ke,2);{var tt=Ce=>{var Ne=sH(),mt=x(Ne);{var Yt=gt=>{var nt=nH();T(gt,nt)},Mn=gt=>{var nt=rH();T(gt,nt)},rr=gt=>{var nt=Tt(),Mt=Le(nt);ft(Mt,17,()=>f(i),ma,(cn,On)=>{var ht=oH(),rt=x(ht),Ve=x(rt),dt=k(Ve),qe=x(dt),Ot=k(rt,2);ft(Ot,17,()=>f(On).snippets,ma,(en,bn)=>{var ir=iH(),Ns=x(ir);G(()=>ne(Ns,f(bn))),T(en,ir)}),G(()=>{ne(Ve,`${f(On).fileName??""} `),ne(qe,`(${f(On).count??""} ${f(On).count===1?"match":"matches"})`)}),T(cn,ht)}),T(gt,nt)};Z(mt,gt=>{f(o)?gt(Yt):f(d)&&f(i).length===0?gt(Mn,1):gt(rr,-1)})}T(Ce,Ne)};Z(ze,Ce=>{f(r)==="tabs"&&Ce(tt)})}G(()=>{re(C,`
|
|
215
|
-
flex: 1; padding: 4px 8px; font-size: var(--tandem-text-sm);
|
|
216
|
-
border: 1px solid ${f(v)?"var(--tandem-error)":"var(--tandem-border)"};
|
|
217
|
-
border-radius: var(--tandem-r-2); background: var(--tandem-surface);
|
|
218
|
-
color: var(--tandem-fg); outline: none;
|
|
219
|
-
`),xe.disabled=f(A)===0,re(xe,`background: none; border: 1px solid var(--tandem-border); border-radius: var(--tandem-r-2); padding: 2px 6px; cursor: pointer; font-size: 12px; color: var(--tandem-fg-muted); opacity: ${f(A)===0?.4:1};`),Oe.disabled=f(A)===0,re(Oe,`background: none; border: 1px solid var(--tandem-border); border-radius: var(--tandem-r-2); padding: 2px 6px; cursor: pointer; font-size: 12px; color: var(--tandem-fg-muted); opacity: ${f(A)===0?.4:1};`),le.disabled=f(A)===0||f(g)||f(r)==="tabs",Q(le,"title",f(r)==="tabs"?"Replace is not available in Open tabs mode":void 0),re(le,`
|
|
220
|
-
padding: 4px 10px; font-size: var(--tandem-text-xs); cursor: pointer;
|
|
221
|
-
border: 1px solid var(--tandem-border); border-radius: var(--tandem-r-2);
|
|
222
|
-
background: var(--tandem-surface); color: var(--tandem-fg-muted);
|
|
223
|
-
opacity: ${f(A)===0||f(g)||f(r)==="tabs"?.4:1};
|
|
224
|
-
`),de.disabled=f(A)===0||f(g)||f(r)==="tabs",Q(de,"title",f(r)==="tabs"?"Replace All is not available in Open tabs mode":void 0),re(de,`
|
|
225
|
-
padding: 4px 10px; font-size: var(--tandem-text-xs); cursor: pointer;
|
|
226
|
-
border: 1px solid var(--tandem-border); border-radius: var(--tandem-r-2);
|
|
227
|
-
background: var(--tandem-surface); color: var(--tandem-fg-muted);
|
|
228
|
-
opacity: ${f(A)===0||f(g)||f(r)==="tabs"?.4:1};
|
|
229
|
-
`)}),L("keydown",X,q),L("input",C,R),hs(C,()=>f(d),Ce=>b(d,Ce)),L("click",xe,()=>{var Ce;return(Ce=e.editor)==null?void 0:Ce.commands.findPrev()}),L("click",Oe,()=>{var Ce;return(Ce=e.editor)==null?void 0:Ce.commands.findNext()}),L("click",J,te),L("change",we,R),Ff(we,()=>f(h),Ce=>b(h,Ce)),L("change",Se,R),Ff(Se,()=>f(p),Ce=>b(p,Ce)),L("change",oe,R),Ff(oe,()=>f(m),Ce=>b(m,Ce)),hs($,()=>f(u),Ce=>b(u,Ce)),L("click",le,()=>{e.editor&&(jV(e.editor.view,f(u)),Md(_))}),L("click",de,K),T(F,X)};Z(ee,F=>{e.open&&F(se)})}T(n,V),Ke()}Ye(["keydown","click","input","change"]);function gS(n,e,t){const r=n.getMap(xo);let i=null,o;for(const[l,c]of r.entries())if(c.type==="highlight"&&c.range.from===e.from&&c.range.to===e.to&&c.author==="user"&&c.status==="pending"&&c.content===""){i=l,o=c.color;break}if(i===null){const l=zp(),c={id:l,author:"user",type:"highlight",audience:"private",range:{from:e.from,to:e.to},content:"",status:"pending",timestamp:Date.now(),color:t};return r.set(l,c),"added"}if(o===t)return r.delete(i),"removed";const s=zp(),a={id:s,author:"user",type:"highlight",audience:"private",range:{from:e.from,to:e.to},content:"",status:"pending",timestamp:Date.now(),color:t};return n.transact(()=>{r.delete(i),r.set(s,a)}),"recolored"}var cH=O('<span style="width: 6px; height: 6px; border-radius: var(--tandem-r-circle); background: var(--tandem-fg-subtle); display: inline-block;"></span>'),dH=O('<span style="width: 6px; height: 6px; border-radius: var(--tandem-r-circle); background: var(--tandem-success); display: inline-block;"></span>'),uH=O('<div data-testid="mode-toggle" role="group" aria-label="Claude collaboration mode" style="display: inline-flex; background: var(--tandem-surface-sunk); border: 1px solid var(--tandem-border); border-radius: var(--tandem-r-2); padding: 2px; gap: 2px;"><button data-testid="mode-solo-btn" title="Write undisturbed — Claude only responds when you message" class="svelte-14q5edy"><!> Solo</button> <button data-testid="mode-tandem-btn" title="Full collaboration — Claude reacts to selections and document changes" class="svelte-14q5edy"><!> Tandem</button></div>');function fH(n,e){We(e,!0);var t=uH(),r=x(t),i=x(r);{var o=c=>{var d=cH();T(c,d)};Z(i,c=>{e.tandemMode==="solo"&&c(o)})}var s=k(r,2),a=x(s);{var l=c=>{var d=dH();T(c,d)};Z(a,c=>{e.tandemMode==="tandem"&&c(l)})}G(()=>{Q(r,"aria-pressed",e.tandemMode==="solo"),re(r,`height: 24px; padding: 0 10px; font-size: 12px; border: none; border-radius: var(--tandem-r-1); cursor: pointer;
|
|
230
|
-
background: ${e.tandemMode==="solo"?"var(--tandem-surface)":"transparent"};
|
|
231
|
-
color: ${e.tandemMode==="solo"?"var(--tandem-fg)":"var(--tandem-fg-muted)"};
|
|
232
|
-
font-weight: 500;
|
|
233
|
-
display: flex; align-items: center; gap: 5px;`),Q(s,"aria-pressed",e.tandemMode==="tandem"),re(s,`height: 24px; padding: 0 10px; font-size: 12px; border: none; border-radius: var(--tandem-r-1); cursor: pointer;
|
|
234
|
-
background: ${e.tandemMode==="tandem"?"var(--tandem-surface)":"transparent"};
|
|
235
|
-
color: ${e.tandemMode==="tandem"?"var(--tandem-fg)":"var(--tandem-fg-muted)"};
|
|
236
|
-
font-weight: 500;
|
|
237
|
-
display: flex; align-items: center; gap: 5px;`)}),L("click",r,()=>e.onModeChange("solo")),L("click",s,()=>e.onModeChange("tandem")),T(n,t),Ke()}Ye(["click"]);const I0=48,Hh=8,hH=10;function pH({start:n,end:e,toolbarHeight:t,toolbarWidth:r,viewportHeight:i,viewportWidth:o}){const s=(n.left+e.right)/2,a=r/2,l=Hh+a,c=Math.max(l,o-Hh-a),d=Math.min(n.top,e.top)-hH-t,u=Math.max(I0,i-t-Hh);return{left:Math.min(Math.max(s,l),c),top:Math.min(Math.max(d,I0),u)}}function mH(n,e){return n.on("selectionUpdate",e),()=>n.off("selectionUpdate",e)}var gH=O('<button type="button"><!></button>');function Xt(n,e){const t=lt(e,"disabled",3,!1),r=lt(e,"active",3,!1),i=lt(e,"style",3,""),o=P(()=>{let v="1px solid transparent",g="transparent",y="var(--tandem-fg-muted)";return t()?(g="transparent",y="var(--tandem-fg-subtle)"):r()&&(g="var(--tandem-accent-bg)",v="1px solid var(--tandem-accent-border)",y="var(--tandem-accent-fg-strong)"),{border:v,background:g,color:y}}),s=P(()=>e.ariaLabel??(typeof e.label=="string"?e.label:void 0)),a=P(()=>f(s)??""),l=P(()=>t()&&e.disabledTitle?e.disabledTitle:e.shortcut?`${f(a)} (${e.shortcut})`:f(a)),c="height: 28px; padding: 0 8px; font-size: 12px; border-radius: var(--tandem-r-2); display: inline-flex; align-items: center; justify-content: center; gap: 5px;",d=P(()=>`${c} cursor: ${t()?"not-allowed":"pointer"}; ${i()}; border: ${f(o).border}; background: ${f(o).background}; color: ${f(o).color};`);var u=gH(),h=x(u);{var p=v=>{var g=Tt(),y=Le(g);Lm(y,()=>e.children),T(v,g)},m=v=>{var g=Nn();G(()=>ne(g,e.label)),T(v,g)};Z(h,v=>{e.children?v(p):v(m,-1)})}G(()=>{Q(u,"data-testid",e.testId),u.disabled=t(),Q(u,"title",f(l)),Q(u,"aria-label",f(s)),re(u,f(d))}),L("mousedown",u,function(...v){var g;(g=e.onMouseDown)==null||g.apply(this,v)}),L("click",u,function(...v){var g;(g=e.onClick)==null||g.apply(this,v)}),T(n,u)}Ye(["mousedown","click"]);var vH=O('<button type="button"></button>'),yH=O('<div role="toolbar" aria-label="Selection tools"><div style="display: flex; align-items: center; gap: 1px; padding: 4px; border-bottom: 1px solid var(--tandem-border);"><!> <!> <div style="width: 1px; height: 18px; background: var(--tandem-border); margin: 0 3px;"></div> <div style="display: inline-flex; gap: 3px; padding: 0 4px;" aria-label="Highlight colors"></div></div> <div style="padding: 6px 8px;"><textarea data-testid="popup-annotation-input" aria-label="Annotation text" placeholder="Write a note or instruction..." style="width: 100%; box-sizing: border-box; field-sizing: content; min-height: 28px; max-height: 120px; overflow-y: auto; resize: none; border: 1px solid var(--tandem-border); border-radius: var(--tandem-r-2); background: var(--tandem-surface); color: var(--tandem-fg); font-size: 12px; padding: 4px 6px; outline: none; font-family: inherit;"></textarea></div> <div style="display: flex; justify-content: space-between; gap: 6px; padding: 4px 8px 6px;"><button type="button" data-testid="popup-note-submit" aria-label="Note to self" style="flex: 1; height: 28px; padding: 0 10px; border: 1px solid var(--tandem-border); background: transparent; color: var(--tandem-fg-muted); border-radius: var(--tandem-r-2); font-size: 12px; font-weight: 500; cursor: pointer;">Note to self</button> <button type="button" data-testid="popup-comment-submit" aria-label="Comment on selection" style="flex: 1; height: 28px; padding: 0 10px; border: 1px solid var(--tandem-author-user); background: transparent; color: var(--tandem-author-user); border-radius: var(--tandem-r-2); font-size: 12px; font-weight: 600; cursor: pointer;">Comment</button></div></div>'),bH=O(`<button data-testid="settings-btn" title="Settings (Ctrl+,)" aria-label="Settings" aria-keyshortcuts="Control+Comma" style="background: transparent; border: 1px solid transparent;
|
|
238
|
-
border-radius: var(--tandem-r-2); cursor: pointer; color: var(--tandem-fg-muted);
|
|
239
|
-
font-size: 12px; padding: 0 var(--tandem-space-3); min-height: 28px;">Settings</button>`),wH=O(`<!> <div style="display: flex; flex-wrap: wrap; align-items: center; gap: var(--tandem-space-3);
|
|
240
|
-
min-height: 44px; padding: 0 var(--tandem-space-4);
|
|
241
|
-
border-bottom: 1px solid var(--tandem-border);
|
|
242
|
-
background: var(--tandem-surface-muted); user-select: none; position: relative; z-index: 5;"><span style="font-weight: 700; font-size: 14px;
|
|
243
|
-
color: var(--tandem-fg); letter-spacing: 0; display: inline-flex; align-items: center; gap: 8px; padding-right: var(--tandem-space-3); border-right: 1px solid var(--tandem-border); height: 22px;"><span aria-hidden="true" style="width: 18px; height: 18px; border-radius: var(--tandem-r-circle); background: conic-gradient(from 210deg, var(--tandem-author-user), var(--tandem-author-user) 44%, transparent 44% 56%, var(--tandem-author-claude) 56%, var(--tandem-author-claude)); display: inline-block;"></span> Tandem</span> <!> <!> <div style="flex: 1;"></div> <div style="display: flex; align-items: center; gap: var(--tandem-space-3);"><!> <!> <!></div></div>`,1);function xH(n,e){We(e,!0);let t=lt(e,"settingsBtn",15,null),r=lt(e,"showAuthorship",3,!1),i=lt(e,"selectionToolbar",3,!0),o=lt(e,"suppressSelectionToolbar",3,!1),s=z(!1),a=z(null),l=z(null),c=z(""),d=z(null),u=z(null),h=z(0),p=z(0),m=z(at(window.innerHeight)),v=z(at(window.innerWidth));const g=Object.keys(Jw),y=P(()=>!!e.editor&&!!e.ydoc&&f(s)),w=P(()=>i()&&!o()&&f(y)&&f(a)!==null),_=P(()=>f(c).trim());function S(J){const{from:fe,to:D}=J.state.selection,Y=fe!==D;if(b(s,Y),!Y){b(a,null);return}try{const be=J.view.coordsAtPos(fe),we=J.view.coordsAtPos(D),Te=pH({start:be,end:we,toolbarHeight:f(h),toolbarWidth:f(p),viewportHeight:f(m),viewportWidth:f(v)});if(f(a)&&f(a).left===Te.left&&f(a).top===Te.top)return;b(a,Te,!0)}catch{b(a,null)}}he(()=>{if(!e.editor)return;const J=e.editor;function fe(){S(J)}const D=mH(J,fe);return fe(),D}),he(()=>{if(!e.editor||!f(a))return;const J=e.editor;let fe=0;function D(){cancelAnimationFrame(fe),fe=requestAnimationFrame(()=>{b(m,window.innerHeight,!0),b(v,window.innerWidth,!0),S(J)})}return window.addEventListener("resize",D),document.addEventListener("scroll",E,!0),()=>{cancelAnimationFrame(fe),window.removeEventListener("resize",D),document.removeEventListener("scroll",E,!0)}}),he(()=>{const J=e.editor,fe=f(l);if(!J||!fe||!f(a))return;const D=()=>{if(document.activeElement===f(u))return;const be=fe.getBoundingClientRect();b(h,be.height,!0),b(p,be.width,!0),S(J)};D();const Y=new ResizeObserver(D);return Y.observe(fe),()=>Y.disconnect()}),he(()=>{f(w)&&!f(d)&&U(),f(w)||(b(d,null),document.activeElement!==f(u)&&b(c,""))}),he(()=>{f(w)&&Ut(()=>{var J;return(J=f(u))==null?void 0:J.focus()})}),he(()=>{if(!f(w))return;function J(fe){fe.key==="Escape"&&(fe.preventDefault(),q())}return window.addEventListener("keydown",J),()=>window.removeEventListener("keydown",J)});function A(J,fe,D){if(!e.editor||!e.ydoc)return;const Y=f(d)??e.editor.state.selection,{from:be,to:we}=Y;if(be===we)return;const Te=$r(e.editor.state.doc,mn(be)),Se=$r(e.editor.state.doc,mn(we)),De=zp(),M={id:De,author:"user",type:J,audience:J==="highlight"||J==="note"?"private":"outbound",range:{from:Te,to:Se},content:fe,status:"pending",timestamp:Date.now()};e.ydoc.getMap(xo).set(De,M),b(d,null)}function U(){if(!e.editor)return;const{from:J,to:fe}=e.editor.state.selection;b(d,{from:J,to:fe},!0)}function N(J){if(!e.editor||!e.ydoc)return;const fe=f(d)??e.editor.state.selection,{from:D,to:Y}=fe;if(D===Y)return;const be=$r(e.editor.state.doc,mn(D)),we=$r(e.editor.state.doc,mn(Y));gS(e.ydoc,{from:be,to:we},J),b(d,null)}function R(J){return fe=>{fe.detail===0&&J(fe)}}function E(J){f(l)&&J.target instanceof Node&&f(l).contains(J.target)||document.activeElement!==f(u)&&q()}function q(){var J;b(s,!1),b(a,null),b(d,null),b(c,""),(J=e.editor)==null||J.chain().focus().run()}function te(){f(_)&&(A("comment",f(_)),q())}function K(){A("note",f(_)),q()}function V(J){J.key==="Enter"&&!J.shiftKey?(J.preventDefault(),te()):J.key==="Escape"&&(J.preventDefault(),q())}var ee=wH(),se=Le(ee);{var F=J=>{var fe=yH(),D=x(fe),Y=x(D);Xt(Y,{label:"B",ariaLabel:"Bold",style:"font-weight: 700; min-width: 28px;",onMouseDown:$=>$.preventDefault(),onClick:()=>{var $;return($=e.editor)==null?void 0:$.chain().focus().toggleBold().run()}});var be=k(Y,2);Xt(be,{label:"I",ariaLabel:"Italic",style:"font-style: italic; min-width: 28px;",onMouseDown:$=>$.preventDefault(),onClick:()=>{var $;return($=e.editor)==null?void 0:$.chain().focus().toggleItalic().run()}});var we=k(be,4);ft(we,21,()=>g,ma,($,le)=>{var de=vH(),Ee=P(()=>R(()=>{var ce;N(f(le)),(ce=e.editor)==null||ce.chain().focus().run()}));G(()=>{Q(de,"data-testid",`popup-highlight-${f(le)}`),Q(de,"aria-label",`Highlight ${f(le)}`),Q(de,"title",`Highlight ${f(le)}`),re(de,`width: 16px; height: 16px; border-radius: var(--tandem-r-2); border: 1px solid var(--tandem-border); background: ${Rl[f(le)]}; cursor: pointer; padding: 0;`)}),L("mousedown",de,ce=>{var ve;ce.preventDefault(),N(f(le)),(ve=e.editor)==null||ve.chain().focus().run()}),L("click",de,function(...ce){var ve;(ve=f(Ee))==null||ve.apply(this,ce)}),T($,de)});var Te=k(D,2),Se=x(Te);Q(Se,"rows",1),yt(Se,$=>b(u,$),()=>f(u));var De=k(Te,2),oe=x(De),M=k(oe,2);yt(fe,$=>b(l,$),()=>f(l)),G(()=>{re(fe,`position: fixed; left: ${f(a).left}px; top: ${f(a).top}px; transform: translateX(-50%); display: flex; flex-direction: column; background: var(--tandem-surface); border: 1px solid var(--tandem-border); border-radius: var(--tandem-r-4); box-shadow: 0 1px 2px color-mix(in srgb, var(--tandem-fg) 4%, transparent), 0 8px 28px color-mix(in srgb, var(--tandem-fg) 10%, transparent); z-index: var(--tandem-z-modal); min-width: 260px; max-width: 320px;`),M.disabled=!f(_)}),L("keydown",Se,V),hs(Se,()=>f(c),$=>b(c,$)),L("click",oe,K),L("click",M,te),T(J,fe)};Z(se,J=>{f(w)&&f(a)&&J(F)})}var X=k(se,2),B=k(x(X),2);{let J=P(()=>!f(y));Xt(B,{label:"Comment",testId:"toolbar-comment-btn",get disabled(){return f(J)},disabledTitle:"Select text first",onMouseDown:fe=>{var D;fe.preventDefault(),(D=f(u))==null||D.focus()}})}var j=k(B,2);{let J=P(()=>!f(y));Xt(j,{label:"Note",testId:"toolbar-note-btn",get disabled(){return f(J)},disabledTitle:"Select text first",onMouseDown:fe=>{var D;fe.preventDefault(),(D=f(u))==null||D.focus()}})}var ae=k(j,4),C=x(ae);{var I=J=>{{let fe=P(()=>r()?"Hide authorship colors":"Show authorship colors");Xt(J,{label:"Authorship",testId:"toolbar-authorship-toggle",get ariaLabel(){return f(fe)},get active(){return r()},onClick:()=>{const D=e.onAuthorshipChange;D&&D(!r())}})}};Z(C,J=>{e.onAuthorshipChange&&J(I)})}var W=k(C,2);{var ge=J=>{fH(J,{get tandemMode(){return e.tandemMode},get onModeChange(){return e.onModeChange}})};Z(W,J=>{e.tandemMode&&e.onModeChange&&J(ge)})}var xe=k(W,2);{var Oe=J=>{var fe=bH();yt(fe,D=>t(D),()=>t()),L("click",fe,function(...D){var Y;(Y=e.onSettingsOpen)==null||Y.apply(this,D)}),T(J,fe)};Z(xe,J=>{e.onSettingsOpen&&J(Oe)})}T(n,ee),Ke()}Ye(["mousedown","click","keydown"]);function kH(n,e=document.documentElement){const t=Math.max(0,Math.min(360,Math.round(n)));return e.style.setProperty("--tandem-accent-h",`${t}deg`),()=>e.style.removeProperty("--tandem-accent-h")}function _H(n){he(()=>kH(n()))}function SH(n,e=document.documentElement){return n?e.setAttribute("data-annotation-patterns","true"):e.removeAttribute("data-annotation-patterns"),()=>e.removeAttribute("data-annotation-patterns")}function CH(n){he(()=>SH(n()))}function TH(n,e=()=>rA){let t=z(!1),r=z(!1);return he(()=>{const i=n();if(i==null){b(t,!1),b(r,!1);return}const o=Date.now()-i,s=e()-o;if(s<=0){b(t,!0);return}const a=setTimeout(()=>{b(t,!0)},s);return()=>clearTimeout(a)}),{get showBanner(){return f(t)&&!f(r)},dismiss(){b(r,!0)}}}function AH(n,e=document.documentElement){return e.setAttribute("data-density",n),()=>e.removeAttribute("data-density")}function EH(n){he(()=>AH(n()))}const oa=200,lc=600,MH=300;function P0(n){const e=Zw[n];try{const t=localStorage.getItem(e);if(t){const r=parseInt(t,10);if(Number.isFinite(r))return Math.max(oa,Math.min(lc,r));console.warn(`[tandem] ignoring non-numeric panel width for ${e}: ${t}`)}}catch(t){console.warn(`[tandem] localStorage unavailable reading ${e}:`,t)}return MH}function L0(n){const{side:e}=n,t=Zw[e];let r=z(at(n.initialWidth)),i=null;return he(()=>{!n.getVisible()&&i&&(document.removeEventListener("mousemove",i.move),document.removeEventListener("mouseup",i.up),i=null,document.body.style.userSelect="",document.body.style.cursor="")}),he(()=>()=>{i&&(document.removeEventListener("mousemove",i.move),document.removeEventListener("mouseup",i.up),document.body.style.userSelect="",document.body.style.cursor="",i=null)}),{get width(){return f(r)},handleResizeStart:a=>{a.preventDefault();const l=a.clientX,c=f(r);let d=c;document.body.style.userSelect="none",document.body.style.cursor="col-resize";const u=p=>{const m=p.clientX-l,v=e==="left"?c+m:c-m;d=Math.max(oa,Math.min(lc,v)),b(r,d,!0)},h=()=>{if(document.removeEventListener("mousemove",u),document.removeEventListener("mouseup",h),i=null,document.body.style.userSelect="",document.body.style.cursor="",n.getVisible())try{localStorage.setItem(t,String(d))}catch(p){console.warn(`[tandem] failed to persist ${t}:`,p)}};i={move:u,up:h},document.addEventListener("mousemove",u),document.addEventListener("mouseup",h)},handleResizeStep:a=>{const l=Math.max(oa,Math.min(lc,f(r)+a));if(b(r,l,!0),n.getVisible())try{localStorage.setItem(t,String(l))}catch(c){console.warn(`[tandem] failed to persist ${t}:`,c)}}}}const OH={sans:'var(--tandem-font-sans), -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',serif:'var(--tandem-font-serif), Georgia, "Times New Roman", Times, serif',mono:'var(--tandem-font-mono), "JetBrains Mono", "Fira Code", Menlo, Consolas, monospace'};function DH(n){const e=document.documentElement;return e.style.setProperty("--tandem-editor-font-family",OH[n]),()=>e.style.removeProperty("--tandem-editor-font-family")}function RH(n){he(()=>DH(n()))}function NH(){let n=z(!1);return{get fileDragOver(){return f(n)},handleEditorDragOver:i=>{var o;(o=i.dataTransfer)!=null&&o.types.includes("Files")&&(i.preventDefault(),b(n,!0))},handleEditorDragLeave:i=>{(i.currentTarget===i.target||!i.currentTarget.contains(i.relatedTarget))&&b(n,!1)},handleEditorDrop:async i=>{var a;if(b(n,!1),!((a=i.dataTransfer)!=null&&a.files.length))return;i.preventDefault();const o=i.dataTransfer.files[0],s=await ix(o);try{const l=await fetch(`${Sr}/upload`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({fileName:o.name,content:s})});if(!l.ok){const c=await l.json().catch(()=>({message:"Upload failed"}));console.error("[useFileDrop] Upload failed:",l.status,c.message??c.error)}}catch{console.error("[useFileDrop] Server unreachable — file drop ignored")}}}}function IH(n,e=document.documentElement){return n?e.setAttribute("data-high-contrast","true"):e.removeAttribute("data-high-contrast"),()=>e.removeAttribute("data-high-contrast")}function PH(n){he(()=>IH(n()))}function LH(n,e){return n.status!=="pending"||e==="tandem"?!0:n.author!=="claude"}function zH(){let n=z(at([]));const e=new Map,t=a=>{const l=e.get(a);l&&(clearTimeout(l),e.delete(a))},r=(a,l)=>{const c=e.get(a);c&&clearTimeout(c);const d=$v[l]??$v.info,u=setTimeout(()=>{b(n,f(n).filter(h=>h.id!==a),!0),e.delete(a)},d);e.set(a,u)},i=a=>{b(n,f(n).filter(l=>l.id!==a),!0),t(a)},o=`http://localhost:${wc}/api/notify-stream`,s=new EventSource(o);return s.onmessage=a=>{let l;try{l=JSON.parse(a.data)}catch{console.warn("[useNotifications] Malformed SSE data:",a.data);return}if(l.dedupKey){const u=f(n).findIndex(h=>h.dedupKey===l.dedupKey);if(u!==-1){const h=f(n)[u];t(h.id);const p={...l,count:h.count+1},m=[...f(n)];m[u]=p,b(n,m,!0),r(p.id,p.severity);return}}const c={...l,count:1},d=[...f(n),c];for(;d.length>uA;){const u=d.shift();t(u.id)}b(n,d,!0),r(c.id,c.severity)},s.onerror=()=>{s.readyState===EventSource.CLOSED&&console.warn("[useNotifications] EventSource permanently closed. Notifications will not be delivered. Is the server running?")},pi(()=>{s.close();for(const a of e.values())clearTimeout(a);e.clear()}),{get toasts(){return f(n)},dismiss:i}}function BH(n){return n.isComposing||n.code!=="Comma"?!1:n.ctrlKey||n.metaKey}function FH(n,e,t){if(n.length<2)return null;const o=(n.findIndex(s=>s.id===e)+(t?-1:1)+n.length)%n.length;return n[o].id}function VH(n,e,t){let r=null;ef(()=>{r=i=>{if(!i.ctrlKey&&!i.metaKey||i.key!=="Tab")return;const o=FH(n(),e(),i.shiftKey);o&&(i.preventDefault(),t(o))},window.addEventListener("keydown",r)}),pi(()=>{r&&window.removeEventListener("keydown",r)})}function HH(n){let e=z(!1);return he(()=>{const t=n();if(!t||t.readOnly){b(e,!1);return}const{ydoc:r}=t,i=r.getXmlFragment("default"),o=r.getMap(ol);let s=!1,a=null;const l=setTimeout(()=>{s=!0,a=o.get(sl)??0,b(e,!1)},500),c=()=>{s&&b(e,!0)};i.observeDeep(c);const d=u=>{if(!u.keysChanged.has(sl)||!s)return;const h=o.get(sl);h!==void 0&&h!==a&&(a=h,b(e,!1))};return o.observe(d),()=>{clearTimeout(l),i.unobserveDeep(c),o.unobserve(d)}}),{get dirty(){return f(e)}}}function z0(n,e){const t=new Set(e),r=n.filter(s=>t.has(s)),i=new Set(r),o=e.filter(s=>!i.has(s));return[...r,...o]}function UH(n,e,t,r,i="left"){const o=n.filter(u=>r.has(u)),s=o.indexOf(e),a=o.indexOf(t);if(s===-1||a===-1)return o;const l=[...o];l.splice(s,1);const c=l.indexOf(t),d=i==="right"?c+1:c;return l.splice(d,0,e),l}function jH(n){let e=z(at([]));he(()=>{const o=n().map(a=>a.id),s=z0(f(e),o);(f(e).length!==s.length||f(e).some((a,l)=>a!==s[l]))&&b(e,s,!0)});const t=P(()=>{const i=n(),o=new Map(i.map(l=>[l.id,l])),s=i.map(l=>l.id);return z0(f(e),s).map(l=>o.get(l)).filter(Boolean)});return{get orderedTabs(){return f(t)},reorder:(i,o,s="left")=>{if(i===o)return;const a=n(),l=new Set(a.map(c=>c.id));b(e,UH(f(e),i,o,l,s),!0)}}}function WH(n,e){let t=z(at((()=>{try{const r=localStorage.getItem(Pc),i=QT.safeParse(r);return i.success?i.data:Yv}catch(r){return console.warn(`[tandem] localStorage unavailable reading ${Pc}:`,r),Yv}})()));return he(()=>{const r=f(t);try{localStorage.setItem(Pc,r)}catch(i){console.warn(`[tandem] failed to persist ${Pc}:`,i)}}),he(()=>{const r=n(),i=f(t);if(r)try{r.getMap(dp).set(aA,i)}catch(o){console.warn("[tandem] failed to broadcast tandem mode to Y.Map:",o)}}),he(()=>{const r=n(),i=e();if(r)try{r.getMap(dp).set(lA,i)}catch(o){console.warn("[tandem] failed to broadcast dwell ms to Y.Map:",o)}}),{get tandemMode(){return f(t)},setTandemMode(r){b(t,r,!0)}}}const KH={s:14,m:16,l:18};function B0(){try{return typeof window>"u"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!1}}const Gt={leftPanelVisible:!1,rightPanelVisible:!0,schemaVersion:2,primaryTab:"annotations",panelOrder:"chat-editor-annotations",editorWidthPercent:100,selectionDwellMs:Xw,showAuthorship:!0,reduceMotion:!1,textSize:"m",theme:"system",accentHue:275,editorFont:"serif",density:"cozy",defaultMode:"tandem",highContrast:!1,annotationPatterns:!1,selectionToolbar:!0,soloRailHidden:!0,leftRailTabs:["annotations","outline"],rightRailTabs:["annotations","chat"],degradedBannerDelayMs:3e4,sidecarRetryStrategy:"exponential",holdAnnotationsWhileOffline:!0},qH=["annotations","chat","outline"];function F0(n,e){if(Array.isArray(n)){const t=n.filter(r=>qH.includes(r));return t.length>0?t:e}return e}function JH(){let n;try{n=localStorage.getItem(Gw)}catch{n=null}if(n)try{let e=JSON.parse(n);if((!e||typeof e!="object"||Array.isArray(e))&&(e={leftPanelVisible:!1,rightPanelVisible:!0,schemaVersion:2}),e.schemaVersion!==2){const r=e.panelHidden===!0;let i=!1,o=!0;r?(i=!1,o=!1):e.layout==="three-panel"?(i=!0,o=!0):e.layout==="tabbed-left"&&(i=!0,o=!1),e={...e,leftPanelVisible:i,rightPanelVisible:o,schemaVersion:2},delete e.layout,delete e.panelHidden}let t=Gt.leftRailTabs;if(!Array.isArray(e.leftRailTabs)){const r=e.leftSlot;(r==null?void 0:r.kind)==="outline"?(console.warn("[tandem] migrating legacy leftSlot.kind=outline → leftRailTabs"),t=["outline","annotations"]):(r==null?void 0:r.kind)==="side"&&console.warn("[tandem] migrating legacy leftSlot.kind=side → leftRailTabs")}return{leftPanelVisible:e.leftPanelVisible===!0,rightPanelVisible:e.rightPanelVisible!==!1,schemaVersion:2,primaryTab:e.primaryTab==="annotations"?"annotations":"chat",panelOrder:e.panelOrder==="annotations-editor-chat"?"annotations-editor-chat":"chat-editor-annotations",editorWidthPercent:Math.max(40,Math.min(100,Number(e.editorWidthPercent)||Gt.editorWidthPercent)),selectionDwellMs:Math.max(Ld,Math.min(zd,Number(e.selectionDwellMs)||Xw)),showAuthorship:e.showAuthorship===!1?!1:Gt.showAuthorship,reduceMotion:typeof e.reduceMotion=="boolean"?e.reduceMotion:B0(),textSize:e.textSize==="s"||e.textSize==="m"||e.textSize==="l"?e.textSize:Gt.textSize,theme:e.theme==="light"||e.theme==="dark"||e.theme==="system"?e.theme:Gt.theme,accentHue:typeof e.accentHue=="number"&&e.accentHue>=0&&e.accentHue<=360?e.accentHue:Gt.accentHue,editorFont:e.editorFont==="serif"||e.editorFont==="sans"||e.editorFont==="mono"?e.editorFont:Gt.editorFont,density:e.density==="compact"||e.density==="cozy"||e.density==="spacious"?e.density:Gt.density,defaultMode:e.defaultMode==="solo"||e.defaultMode==="tandem"?e.defaultMode:Gt.defaultMode,highContrast:e.highContrast===!0,annotationPatterns:e.annotationPatterns===!0,selectionToolbar:e.selectionToolbar===!1?!1:Gt.selectionToolbar,soloRailHidden:e.soloRailHidden===!1?!1:Gt.soloRailHidden,degradedBannerDelayMs:typeof e.degradedBannerDelayMs=="number"&&e.degradedBannerDelayMs>=5e3&&e.degradedBannerDelayMs<=12e4?e.degradedBannerDelayMs:Gt.degradedBannerDelayMs,sidecarRetryStrategy:e.sidecarRetryStrategy==="exponential"||e.sidecarRetryStrategy==="constant-2s"||e.sidecarRetryStrategy==="manual"?e.sidecarRetryStrategy:Gt.sidecarRetryStrategy,holdAnnotationsWhileOffline:typeof e.holdAnnotationsWhileOffline=="boolean"?e.holdAnnotationsWhileOffline:Gt.holdAnnotationsWhileOffline,leftRailTabs:F0(e.leftRailTabs,t),rightRailTabs:F0(e.rightRailTabs,Gt.rightRailTabs)}}catch(e){console.warn("[tandem] settings JSON is corrupt, resetting to defaults:",e)}return{...Gt,reduceMotion:B0()}}function YH(n,e){const t={...n,...e};return{...t,editorWidthPercent:Math.max(40,Math.min(100,t.editorWidthPercent)),selectionDwellMs:Math.max(Ld,Math.min(zd,t.selectionDwellMs)),accentHue:Number.isFinite(t.accentHue)?Math.max(0,Math.min(360,t.accentHue)):Gt.accentHue,degradedBannerDelayMs:Math.max(5e3,Math.min(12e4,t.degradedBannerDelayMs)),leftRailTabs:t.leftRailTabs.length>0?t.leftRailTabs:Gt.leftRailTabs,rightRailTabs:t.rightRailTabs.length>0?t.rightRailTabs:Gt.rightRailTabs}}function GH(){let n=z(at(JH()));return{get settings(){return f(n)},updateSettings:t=>{const r=YH(f(n),t);try{localStorage.setItem(Gw,JSON.stringify(r)),localStorage.setItem($w,String(r.showAuthorship))}catch{}b(n,r,!0)}}}var mc;class ZH{constructor(){Je(this,mc,z(at(Cr()?window.__TANDEM_INITIAL_THEME__??null:null)))}get current(){return f(H(this,mc))}set current(e){b(H(this,mc),e,!0)}}mc=new WeakMap;const Pf=new ZH;let V0=!1;function Uh(n){Pf.current=n,typeof window<"u"&&(window.__TANDEM_INITIAL_THEME__=n)}function XH(){if(V0||!Cr())return;V0=!0;let n=null;ko(async()=>{const{invoke:i}=await import("./core-DhEqZVGG.js");return{invoke:i}},[]).then(({invoke:i})=>{n=i,i("get_app_theme").then(o=>{Uh(o==="dark"?"dark":"light")}).catch(o=>{console.warn("[useTauriTheme] get_app_theme failed:",o)})}).catch(i=>{console.warn("[useTauriTheme] Tauri API import failed:",i)}),ko(async()=>{const{getCurrentWindow:i}=await import("./window-BxBvHL5k.js").then(o=>o.w);return{getCurrentWindow:i}},__vite__mapDeps([0,1])).then(({getCurrentWindow:i})=>{i().onThemeChanged(({payload:o})=>{Uh(o==="dark"?"dark":"light")}).catch(o=>{console.warn("[useTauriTheme] onThemeChanged subscribe failed:",o)})}).catch(i=>{console.warn("[useTauriTheme] Tauri window API import failed:",i)});let e=!1;const t=setInterval(()=>{!document.hasFocus()||!n||n("get_app_theme").then(i=>{const o=i==="dark"?"dark":"light";Pf.current!==o&&(Uh(o),e=!1)}).catch(i=>{e||(console.warn("[useTauriTheme] theme poll failed (further errors suppressed):",i),e=!0)})},3e3),r=()=>clearInterval(t);window.addEventListener("pagehide",r,{once:!0})}function vS(){try{if(typeof window>"u")return"light";if(Cr()){const n=Pf.current;if(n==="dark"||n==="light")return n;const e=window.__TANDEM_INITIAL_THEME__;if(e==="dark"||e==="light")return e}return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}catch(n){return console.warn("[Tandem] Theme detection failed, defaulting to light:",n),"light"}}function QH(n){return n==="system"?vS():n}function H0(n){try{const e=document.querySelector('meta[name="theme-color"]');e&&(e.content=n==="dark"?"#1c1c24":"#fafaf9")}catch{}}function $H(n){const e=document.documentElement,t=QH(n);if(e.setAttribute("data-theme",t),H0(t),n!=="system")return()=>e.removeAttribute("data-theme");if(Cr())return()=>e.removeAttribute("data-theme");const r=window.matchMedia("(prefers-color-scheme: dark)"),i=()=>{const o=vS();e.setAttribute("data-theme",o),H0(o)};return r.addEventListener("change",i),()=>{r.removeEventListener("change",i),e.removeAttribute("data-theme")}}function eU(n){XH(),he(()=>{const e=n();return Pf.current,$H(e)})}function tU(){try{return localStorage.getItem(nx)==="true"}catch{return!1}}function U0(){try{localStorage.setItem(nx,"true")}catch{}}function nU(n,e,t){let r=z(at(tU())),i=z(0),o=0;const s=jx(),a=P(()=>t()==="welcome.md"),l=P(()=>!f(r)&&f(a)),c=Cr(),d=qx(()=>c&&f(l)),u=P(()=>!c||d.status!==null||d.error!==null),h=P(()=>c&&Ux(d.status,s)),p=P(()=>f(u)?f(h)?4:3:1/0);return he(()=>{if(!f(l)||f(i)!==0)return;const y=n().filter(_=>_.id.startsWith(fA));if(y.length===0)return;y.some(_=>_.status!=="pending")&&(o=Date.now(),b(i,1))}),he(()=>{if(!f(l)||f(i)!==1)return;n().some(w=>w.author==="user")&&(o=Date.now(),b(i,2))}),he(()=>{if(!f(l)||f(i)!==2||!isFinite(f(p)))return;const g=e();if(!g)return;const y=()=>{Date.now()-o<2e3||g.isFocused&&(o=Date.now(),b(i,3))};return g.on("update",y),()=>{g.off("update",y)}}),he(()=>{if(!f(l)||!isFinite(f(p))||f(i)!==f(p))return;const g=setTimeout(()=>{U0(),b(r,!0)},3e3);return()=>clearTimeout(g)}),he(()=>{isFinite(f(p))&&f(i)>f(p)&&b(i,f(p),!0)}),{get tutorialActive(){return f(l)},get currentStep(){return f(i)},get coworkStatus(){return d.status},dismissTutorial:()=>{U0(),b(r,!0)},nextStep:()=>{o=Date.now(),b(i,Math.min(f(i)+1,f(p)),!0)}}}function rU(){let n=null;ef(()=>{let e=!1,t;ko(async()=>{const{getCurrentWebview:r}=await import("./webview-Ben21ZLJ.js");return{getCurrentWebview:r}},__vite__mapDeps([2,0,1])).then(({getCurrentWebview:r})=>{if(e)return;const i=r();let o=Ja;try{const d=localStorage.getItem(ey);if(d!==null){const u=Number(d);Number.isFinite(u)?o=Math.max(ty,Math.min(ny,u)):console.warn(`[tandem] ignoring invalid stored zoom: ${d}`)}}catch{}o!==Ja&&i.setZoom(o).catch(d=>{console.warn("[tandem] failed to restore zoom level:",d)});function s(d){try{localStorage.setItem(ey,String(d))}catch{}}const a=d=>{!(d.metaKey||d.ctrlKey)||d.key!=="0"||(d.preventDefault(),d.stopPropagation(),o=Ja,i.setZoom(Ja).catch(h=>{console.warn("[tandem] failed to reset zoom:",h)}),s(Ja))},l=.1,c=d=>{if(!(d.metaKey||d.ctrlKey))return;const h=d.key==="+"||d.key==="=",p=d.key==="-"||d.key==="_";if(!h&&!p)return;const m=h?o+l:o-l;o=Math.max(ty,Math.min(ny,Math.round(m*100)/100)),s(o)};window.addEventListener("keydown",a,{capture:!0}),window.addEventListener("keydown",c,{capture:!0}),t=()=>{window.removeEventListener("keydown",a,{capture:!0}),window.removeEventListener("keydown",c,{capture:!0})}}).catch(()=>{}),n=()=>{e=!0,t==null||t()}}),pi(()=>{n==null||n()})}function iU(n,e,t){return n.filter(r=>!e.has(r.id)&&!t.has(r.id))}function oU(){let n=z(at([])),e=z(null),t=z(!1),r=z("connecting"),i=z(0),o=z(null),s=z(at([])),a=z(null),l=z(!1),c=z(!1),d=z(!1),u=z(!1),h=z(!1),p=z(null),m=null,v=!1,g=null;const y=new Set,w=new Map,_=new Map,S=new Map;let A=!1;const U=F=>{const{ydoc:X}=F,B=X.getMap(xo),j=()=>{const fe=[];B.forEach(D=>{fe.push(Ea(D,Y=>{console.warn("[sanitize]",Y)}))}),b(s,fe,!0)};B.observe(j),j();const ae=X.getMap(Qw);let C=null,I=!1;const W=()=>{const fe=ae.get(up),D=(fe==null?void 0:fe.status)??null,Y=(fe==null?void 0:fe.active)??!1;D!==C&&(C=D,b(a,D,!0)),Y!==I&&(I=Y,b(l,Y,!0))};ae.observe(W),W();const ge=X.getMap(ol);let xe=!1;const Oe=fe=>{if(!fe.keysChanged.has(Wf))return;const D=ge.get(Wf)===!0;D!==xe&&(xe=D,b(c,D))};ge.observe(Oe);const J=ge.get(Wf)===!0;return J!==xe&&(xe=J,b(c,J)),()=>{B.unobserve(j),ae.unobserve(W),ge.unobserve(Oe)}},N=(F,X)=>{var xe,Oe;const B=f(n),j=new Set(B.map(J=>J.id)),ae=new Set(F.map(J=>J.id));for(const J of B)y.delete(J.id),w.delete(J.id);for(const[J,fe]of w)ae.has(J)||((xe=S.get(J))==null||xe(),S.delete(J),fe.provider.destroy(),fe.ydoc.destroy(),w.delete(J),y.delete(J));const C=iU(F,j,y),I=[];for(const J of C){y.add(J.id);const fe=new ci,D=new db({url:`ws://localhost:${Jv}`,name:J.id,document:fe});w.set(J.id,{ydoc:fe,provider:D});const Y=fe.getMap(ol),be=we=>{if(!we.keysChanged.has(Ka)&&!we.keysChanged.has(qa))return;const Te=Y.get(Ka),Se=Y.get(qa);Te&&N(Te,Se??null)};Y.observe(be),S.set(J.id,()=>Y.unobserve(be)),I.push({...J,ydoc:fe,provider:D})}const W=B.filter(J=>!ae.has(J.id));for(const J of W){const fe=_.get(J.id);fe&&(fe.cleanup(),_.delete(J.id)),(Oe=S.get(J.id))==null||Oe(),S.delete(J.id),y.delete(J.id),w.delete(J.id),J.provider.destroy(),J.ydoc.destroy()}const ge=B.filter(J=>ae.has(J.id));if(b(n,[...ge,...I],!0),X!==null){const J=f(e);J===null?b(e,X,!0):ae.has(J)&&W.length>0&&X===J||b(e,X,!0)}};let R=null,E=null;{const F=new ci,X=new db({url:`ws://localhost:${Jv}`,name:sA,document:F});b(p,F,!0),E=X,X.on("status",({status:W})=>{b(t,W==="connected"),b(r,["connected","connecting","disconnected"].includes(W)?W:"connecting",!0),W==="connected"?(v=!0,b(i,0),b(o,null)):W==="disconnected"?f(o)===null&&b(o,Date.now(),!0):W==="connecting"&&(v&&b(i,f(i)+1),f(o)===null&&b(o,Date.now(),!0))});const B=F.getMap(ol),j=W=>{if(W.keysChanged.has(jf)){const ge=B.get(jf);ge&&g&&ge!==g&&(console.warn("[Tandem] Server restarted — refreshing documents"),b(h,!0),m&&clearTimeout(m),m=setTimeout(()=>{b(h,!1)},5e3)),ge&&(g=ge)}if(W.keysChanged.has(Ka)||W.keysChanged.has(qa)){const ge=B.get(Ka),xe=B.get(qa);ge&&N(ge,xe??null)}W.keysChanged.has(Kf)&&b(d,B.get(Kf)===!0)};B.observe(j);const ae=B.get(jf);ae&&(g=ae);const C=B.get(Ka),I=B.get(qa);C&&N(C,I??null),b(d,B.get(Kf)===!0),R=()=>{B.unobserve(j),m&&(clearTimeout(m),m=null),X.destroy(),F.destroy(),b(p,null),E=null},b(u,!0)}const q=P(()=>f(n).find(F=>F.id===f(e))??null),te=P(()=>{var F;return((F=f(q))==null?void 0:F.ydoc)??null}),K=jC(()=>{he(()=>{f(te);const F=f(q);for(const X of _.values())X.cleanup();if(_.clear(),F){const X=U(F);_.set(F.id,{cleanup:X})}else b(s,[],!0),b(a,null),b(l,!1),b(c,!1)})});return{get tabs(){return f(n)},get activeTabId(){return f(e)},setActiveTabId:F=>{b(e,F,!0)},handleTabClose:F=>{if(f(e)===F){const X=f(n),B=X.findIndex(ae=>ae.id===F),j=X.filter(ae=>ae.id!==F);j.length===0?b(e,null):b(e,j[Math.min(B,j.length-1)].id,!0)}fetch(`http://localhost:${wc}/api/close`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({documentId:F})}).then(X=>{X.ok||console.warn("[Tandem] Server rejected close:",X.status)}).catch(X=>{console.warn("[Tandem] Failed to close document on server:",X)})},get connected(){return f(t)},get connectionStatus(){return f(r)},get reconnectAttempts(){return f(i)},get disconnectedSince(){return f(o)},get annotations(){return f(s)},get claudeStatus(){return f(a)},get claudeActive(){return f(l)},get readOnly(){return f(c)},get storeReadOnly(){return f(d)},get bootstrapYdoc(){return f(p)},get ready(){return f(u)},get serverRestarted(){return f(h)},destroy:()=>{if(!A){A=!0,K();for(const F of _.values())F.cleanup();_.clear();for(const F of S.values())F();S.clear();for(const F of w.values())F.provider.destroy(),F.ydoc.destroy();w.clear(),y.clear();for(const F of f(n))F.provider.destroy(),F.ydoc.destroy();R==null||R(),b(n,[],!0),b(s,[],!0),b(e,null),b(u,!1)}},reconnect(){E==null||E.connect();for(const F of f(n))F.provider.connect()}}}function hr(n,e){function t(r){n.contains(r.target)||e(r)}return document.addEventListener("mousedown",t),{destroy(){document.removeEventListener("mousedown",t)}}}var sU=O('<label><input type="checkbox" style="accent-color: var(--tandem-accent);"/> </label>'),aU=O("<div></div>"),lU=O(`<div class="rail-tab-picker" style="display: flex; align-items: center;"><button aria-label="Configure tabs" style="
|
|
244
|
-
width: 22px; height: 22px; border: none; background: transparent;
|
|
245
|
-
cursor: pointer; border-radius: var(--tandem-r-2);
|
|
246
|
-
color: var(--tandem-fg-subtle); font-size: 14px; line-height: 1;
|
|
247
|
-
display: flex; align-items: center; justify-content: center;
|
|
248
|
-
padding: 0;
|
|
249
|
-
">+</button> <!></div>`);function j0(n,e){We(e,!0);let t=lt(e,"disabledTabs",19,()=>[]),r=lt(e,"testIdPrefix",3,""),i=z(!1),o=z(null),s=z(null);const a=[{id:"annotations",label:"Annotations"},{id:"chat",label:"Chat"},{id:"outline",label:"Outline"}];function l(m){if(t().includes(m))return;const v=e.enabledTabs.includes(m)?e.enabledTabs.filter(g=>g!==m):[...e.enabledTabs,m];v.length>0&&e.onTabsChange(v)}function c(m){if(m.stopPropagation(),f(i)){b(i,!1);return}if(f(o)){const v=f(o).getBoundingClientRect();b(s,{top:v.bottom+4,right:window.innerWidth-v.right},!0)}b(i,!0)}he(()=>{f(i)||b(s,null)});var d=lU(),u=x(d);yt(u,m=>b(o,m),()=>f(o));var h=k(u,2);{var p=m=>{var v=aU();ft(v,21,()=>a,ma,(g,y)=>{const w=P(()=>e.enabledTabs.length===1&&e.enabledTabs.includes(f(y).id)),_=P(()=>t().includes(f(y).id)||f(w));var S=sU(),A=x(S),U=k(A);G(N=>{Q(S,"title",f(_)?"Each rail must keep at least one tab":void 0),re(S,`
|
|
250
|
-
display: flex; align-items: center; gap: var(--tandem-space-2);
|
|
251
|
-
padding: var(--tandem-space-1) var(--tandem-space-2);
|
|
252
|
-
cursor: ${f(_)?"not-allowed":"pointer"}; border-radius: var(--tandem-r-2);
|
|
253
|
-
font-size: var(--tandem-text-sm); color: ${f(_)?"var(--tandem-fg-subtle)":"var(--tandem-fg)"};
|
|
254
|
-
opacity: ${f(_)?.5:1};
|
|
255
|
-
`),Q(A,"data-testid",`${r()}rail-tab-picker-${f(y).id}`),fs(A,N),A.disabled=f(_),ne(U,` ${f(y).label??""}`)},[()=>e.enabledTabs.includes(f(y).id)]),L("change",A,()=>l(f(y).id)),T(g,S)}),G(()=>{Q(v,"data-testid",`${r()}rail-tab-picker-dropdown`),re(v,`
|
|
256
|
-
position: fixed; top: ${f(s).top??""}px; right: ${f(s).right??""}px;
|
|
257
|
-
z-index: var(--tandem-z-dropdown, 200);
|
|
258
|
-
background: var(--tandem-surface); border: 1px solid var(--tandem-border);
|
|
259
|
-
border-radius: var(--tandem-r-3); box-shadow: var(--tandem-shadow-2);
|
|
260
|
-
padding: var(--tandem-space-2); min-width: 140px;
|
|
261
|
-
`)}),T(m,v)};Z(h,m=>{f(i)&&f(s)&&m(p)})}El(d,(m,v)=>hr==null?void 0:hr(m,v),()=>()=>b(i,!1)),G(()=>{Q(u,"data-testid",`${r()}rail-tab-picker-btn`),Q(u,"aria-expanded",f(i))}),L("click",u,c),T(n,d),Ke()}Ye(["click","change"]);var cU=Wi('<svg width="14" height="14" viewBox="0 0 16 16" fill="none" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"><path d="M4 7L1 4l3-3" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path><path d="M1 4h9a5 5 0 0 1 0 10H7" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path></svg>'),dU=Wi('<svg width="14" height="14" viewBox="0 0 16 16" fill="none" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"><path d="M12 7l3-3-3-3" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path><path d="M15 4H6a5 5 0 0 0 0 10h3" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path></svg>'),uU=O('<button type="button" role="menuitem"> </button>'),fU=O(`<div role="menu" aria-label="Heading level" style="position: absolute; top: 100%; left: 0; margin-top: 4px;
|
|
262
|
-
background: var(--tandem-surface); border: 1px solid var(--tandem-border);
|
|
263
|
-
border-radius: var(--tandem-r-3); padding: 4px; display: flex; flex-direction: column;
|
|
264
|
-
gap: 2px; z-index: var(--tandem-z-dropdown); box-shadow: var(--tandem-shadow-1);"></div>`),hU=Wi('<svg width="14" height="14" viewBox="0 0 16 16" fill="none" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"><circle cx="2" cy="4" r="1.5" fill="currentColor"></circle><circle cx="2" cy="8" r="1.5" fill="currentColor"></circle><circle cx="2" cy="12" r="1.5" fill="currentColor"></circle><rect x="5" y="3" width="9" height="2" rx="1" fill="currentColor"></rect><rect x="5" y="7" width="9" height="2" rx="1" fill="currentColor"></rect><rect x="5" y="11" width="9" height="2" rx="1" fill="currentColor"></rect></svg>'),pU=Wi('<svg width="14" height="14" viewBox="0 0 16 16" fill="none" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"><rect x="5" y="3" width="9" height="2" rx="1" fill="currentColor"></rect><rect x="5" y="7" width="9" height="2" rx="1" fill="currentColor"></rect><rect x="5" y="11" width="9" height="2" rx="1" fill="currentColor"></rect><text x="0" y="5.5" font-size="4.5" fill="currentColor" font-family="monospace" font-weight="bold">1.</text><text x="0" y="9.5" font-size="4.5" fill="currentColor" font-family="monospace" font-weight="bold">2.</text><text x="0" y="13.5" font-size="4.5" fill="currentColor" font-family="monospace" font-weight="bold">3.</text></svg>'),mU=Wi('<svg width="14" height="14" viewBox="0 0 16 16" fill="none" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"><rect x="0" y="2" width="3" height="12" rx="1.5" fill="currentColor"></rect><rect x="5" y="4" width="9" height="2" rx="1" fill="currentColor" opacity="0.7"></rect><rect x="5" y="8" width="7" height="2" rx="1" fill="currentColor" opacity="0.7"></rect><rect x="5" y="12" width="8" height="2" rx="1" fill="currentColor" opacity="0.7"></rect></svg>'),gU=Wi('<svg width="14" height="14" viewBox="0 0 16 16" fill="none" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"><path d="M6.5 8.5a3.5 3.5 0 0 0 5 0l2-2a3.5 3.5 0 0 0-5-5l-1 1" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path><path d="M9.5 7.5a3.5 3.5 0 0 0-5 0l-2 2a3.5 3.5 0 0 0 5 5l1-1" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path></svg>'),vU=O(`<div role="dialog" aria-label="Insert link" style="position: absolute; top: 100%; left: 0; margin-top: 4px;
|
|
265
|
-
background: var(--tandem-surface); border: 1px solid var(--tandem-border);
|
|
266
|
-
border-radius: var(--tandem-r-3); padding: 6px;
|
|
267
|
-
display: flex; align-items: center; gap: 4px;
|
|
268
|
-
z-index: var(--tandem-z-dropdown); box-shadow: var(--tandem-shadow-1); min-width: 240px;"><input data-testid="toolbar-link-input" type="url" placeholder="https://" style="flex: 1; height: 26px; padding: 2px 6px; font-size: 12px;
|
|
269
|
-
border: 1px solid var(--tandem-border); border-radius: var(--tandem-r-2);
|
|
270
|
-
background: var(--tandem-surface); color: var(--tandem-fg);
|
|
271
|
-
outline: none; font-family: inherit;"/> <button type="button" data-testid="toolbar-link-submit" style="height: 26px; padding: 0 8px; font-size: 12px; font-weight: 500;
|
|
272
|
-
border: 1px solid var(--tandem-accent-border); background: transparent;
|
|
273
|
-
color: var(--tandem-accent); border-radius: var(--tandem-r-2); cursor: pointer;
|
|
274
|
-
white-space: nowrap;">Apply</button> <button type="button" data-testid="toolbar-link-cancel" style="height: 26px; padding: 0 8px; font-size: 12px; font-weight: 500;
|
|
275
|
-
border: 1px solid var(--tandem-border); background: transparent;
|
|
276
|
-
color: var(--tandem-fg-muted); border-radius: var(--tandem-r-2); cursor: pointer;">Cancel</button></div>`),yU=Wi('<svg width="14" height="14" viewBox="0 0 16 16" fill="none" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"><path d="M5 4L1 8l4 4" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path><path d="M11 4l4 4-4 4" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path><path d="M9 2l-2 12" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"></path></svg>'),bU=O('<div style="display: flex; align-items: center; gap: 2px;"><!> <!> <div style="width: 1px; height: 16px; background: var(--tandem-border); margin: 0 2px;"></div> <!> <!> <!> <!> <div style="position: relative;" role="presentation"><!> <!></div> <div style="width: 1px; height: 16px; background: var(--tandem-border); margin: 0 2px;"></div> <!> <!> <!> <div style="width: 1px; height: 16px; background: var(--tandem-border); margin: 0 2px;"></div> <div style="position: relative;" role="presentation"><!> <!></div> <!> <!></div>');function wU(n,e){We(e,!0);const t=lt(e,"disabled",3,!1),r=[1,2,3],i={1:700,2:600,3:500};let o=z(0),s=z(!1),a=z(!1),l=z(""),c=z(null);he(()=>{if(!e.editor)return;const C=()=>{e.editor.isDestroyed||Md(o)};return e.editor.on("transaction",C),()=>{e.editor.off("transaction",C)}}),he(()=>{var C,I;f(a)&&((C=f(c))==null||C.focus(),(I=f(c))==null||I.select())});function d(C){for(const I of r)if(C.isActive("heading",{level:I}))return I;return null}const u=P(()=>e.editor?e.editor.isEditable:!1),h=P(()=>!f(u)||!!t()),p=P(()=>(f(o),e.editor?ii.getState(e.editor.state):null)),m=P(()=>{var C,I;return!f(h)&&(((I=(C=f(p))==null?void 0:C.undoManager)==null?void 0:I.undoStack.length)??0)>0}),v=P(()=>{var C,I;return!f(h)&&(((I=(C=f(p))==null?void 0:C.undoManager)==null?void 0:I.redoStack.length)??0)>0}),g=P(()=>(f(o),e.editor?d(e.editor):null)),y=P(()=>{var C;return f(o),!!((C=e.editor)!=null&&C.isActive("bold"))}),w=P(()=>{var C;return f(o),!!((C=e.editor)!=null&&C.isActive("italic"))}),_=P(()=>{var C;return f(o),!!((C=e.editor)!=null&&C.isActive("strike"))}),S=P(()=>{var C;return f(o),!!((C=e.editor)!=null&&C.isActive("code"))}),A=P(()=>{var C;return f(o),!!((C=e.editor)!=null&&C.isActive("bulletList"))}),U=P(()=>{var C;return f(o),!!((C=e.editor)!=null&&C.isActive("orderedList"))}),N=P(()=>{var C;return f(o),!!((C=e.editor)!=null&&C.isActive("blockquote"))}),R=P(()=>{var C;return f(o),!!((C=e.editor)!=null&&C.isActive("codeBlock"))}),E=P(()=>{var C;return f(o),!!((C=e.editor)!=null&&C.isActive("link"))}),q=P(()=>(f(o),e.editor?f(h)||!e.editor.isActive("link")&&e.editor.state.selection.from===e.editor.state.selection.to:!0)),te=P(()=>f(g)?`H${f(g)}`:"H");function K(C){return I=>{I.preventDefault(),C()}}function V(C){return I=>{I.preventDefault(),!(!e.editor||e.editor.isDestroyed)&&(e.editor.chain().focus().toggleHeading({level:C}).run(),b(s,!1))}}function ee(C){C.preventDefault(),e.editor&&(b(l,e.editor.getAttributes("link").href??"",!0),b(a,!0))}function se(){if(!e.editor)return;const C=f(l).trim();C?e.editor.chain().focus().setLink({href:C}).run():e.editor.isActive("link")&&e.editor.chain().focus().unsetLink().run(),F()}function F(){b(a,!1),b(l,"")}function X(C){C.key==="Enter"?(C.preventDefault(),se()):C.key==="Escape"&&(C.preventDefault(),F())}var B=Tt(),j=Le(B);{var ae=C=>{var I=bU(),W=x(I);{const ce=pe=>{var ze=cU();T(pe,ze)};let ve=P(()=>!f(m)),ke=P(()=>K(()=>e.editor.commands.undo()));Xt(W,{ariaLabel:"Undo",shortcut:"Ctrl+Z",get disabled(){return f(ve)},get onMouseDown(){return f(ke)},style:"min-width: 30px; padding: 4px 6px;",children:ce,$$slots:{default:!0}})}var ge=k(W,2);{const ce=pe=>{var ze=dU();T(pe,ze)};let ve=P(()=>!f(v)),ke=P(()=>K(()=>e.editor.commands.redo()));Xt(ge,{ariaLabel:"Redo",shortcut:"Ctrl+Shift+Z",get disabled(){return f(ve)},get onMouseDown(){return f(ke)},style:"min-width: 30px; padding: 4px 6px;",children:ce,$$slots:{default:!0}})}var xe=k(ge,4);{let ce=P(()=>K(()=>e.editor.chain().focus().toggleBold().run()));Xt(xe,{label:"B",shortcut:"Ctrl+B",get disabled(){return f(h)},get active(){return f(y)},get onMouseDown(){return f(ce)},style:"font-weight: 700; min-width: 30px;"})}var Oe=k(xe,2);{let ce=P(()=>K(()=>e.editor.chain().focus().toggleItalic().run()));Xt(Oe,{label:"I",shortcut:"Ctrl+I",get disabled(){return f(h)},get active(){return f(w)},get onMouseDown(){return f(ce)},style:"font-style: italic; min-width: 30px;"})}var J=k(Oe,2);{let ce=P(()=>K(()=>e.editor.chain().focus().toggleStrike().run()));Xt(J,{label:"S",shortcut:"Ctrl+Shift+X",get disabled(){return f(h)},get active(){return f(_)},get onMouseDown(){return f(ce)},style:"text-decoration: line-through; min-width: 30px;"})}var fe=k(J,2);{let ce=P(()=>K(()=>e.editor.chain().focus().toggleCode().run()));Xt(fe,{label:"<>",shortcut:"Ctrl+E",get disabled(){return f(h)},get active(){return f(S)},get onMouseDown(){return f(ce)},style:"font-family: monospace; min-width: 30px;"})}var D=k(fe,2),Y=x(D);{let ce=P(()=>f(g)!==null);Xt(Y,{get label(){return f(te)},get disabled(){return f(h)},get active(){return f(ce)},onMouseDown:ve=>{ve.preventDefault(),b(s,!f(s))},style:"min-width: 30px;"})}var be=k(Y,2);{var we=ce=>{var ve=fU();ft(ve,20,()=>r,ke=>ke,(ke,pe)=>{var ze=uU(),tt=P(()=>V(pe)),Ce=x(ze);G(()=>{re(ze,`padding: 4px 12px; font-size: 13px; border: none;
|
|
277
|
-
border-radius: var(--tandem-r-2);
|
|
278
|
-
background: ${f(g)===pe?"var(--tandem-accent-bg)":"transparent"};
|
|
279
|
-
color: ${f(g)===pe?"var(--tandem-accent)":"var(--tandem-fg)"};
|
|
280
|
-
cursor: pointer; text-align: left;
|
|
281
|
-
font-weight: ${i[pe]??""}; white-space: nowrap;`),ne(Ce,`Heading ${pe??""}`)}),L("mousedown",ze,function(...Ne){var mt;(mt=f(tt))==null||mt.apply(this,Ne)}),T(ke,ze)}),T(ce,ve)};Z(be,ce=>{f(s)&&ce(we)})}El(D,(ce,ve)=>hr==null?void 0:hr(ce,ve),()=>()=>b(s,!1));var Te=k(D,4);{const ce=ke=>{var pe=hU();T(ke,pe)};let ve=P(()=>K(()=>e.editor.chain().focus().toggleBulletList().run()));Xt(Te,{ariaLabel:"Bullet list",shortcut:"Ctrl+Shift+8",get disabled(){return f(h)},get active(){return f(A)},get onMouseDown(){return f(ve)},style:"min-width: 30px; padding: 4px 6px;",children:ce,$$slots:{default:!0}})}var Se=k(Te,2);{const ce=ke=>{var pe=pU();T(ke,pe)};let ve=P(()=>K(()=>e.editor.chain().focus().toggleOrderedList().run()));Xt(Se,{ariaLabel:"Ordered list",shortcut:"Ctrl+Shift+7",get disabled(){return f(h)},get active(){return f(U)},get onMouseDown(){return f(ve)},style:"min-width: 30px; padding: 4px 6px;",children:ce,$$slots:{default:!0}})}var De=k(Se,2);{const ce=ke=>{var pe=mU();T(ke,pe)};let ve=P(()=>K(()=>e.editor.chain().focus().toggleBlockquote().run()));Xt(De,{ariaLabel:"Blockquote",shortcut:"Ctrl+Shift+B",get disabled(){return f(h)},get active(){return f(N)},get onMouseDown(){return f(ve)},style:"min-width: 30px; padding: 4px 6px;",children:ce,$$slots:{default:!0}})}var oe=k(De,4),M=x(oe);{const ce=ke=>{var pe=gU();T(ke,pe)};let ve=P(()=>f(E)||f(a));Xt(M,{ariaLabel:"Link",shortcut:"Ctrl+K",get disabled(){return f(q)},get active(){return f(ve)},onMouseDown:ee,style:"min-width: 30px; padding: 4px 6px;",children:ce,$$slots:{default:!0}})}var $=k(M,2);{var le=ce=>{var ve=vU(),ke=x(ve);yt(ke,tt=>b(c,tt),()=>f(c));var pe=k(ke,2),ze=k(pe,2);L("keydown",ke,X),hs(ke,()=>f(l),tt=>b(l,tt)),L("mousedown",pe,tt=>{tt.preventDefault(),se()}),L("mousedown",ze,tt=>{tt.preventDefault(),F()}),T(ce,ve)};Z($,ce=>{f(a)&&ce(le)})}El(oe,(ce,ve)=>hr==null?void 0:hr(ce,ve),()=>F);var de=k(oe,2);{let ce=P(()=>K(()=>e.editor.chain().focus().setHorizontalRule().run()));Xt(de,{label:"—",ariaLabel:"Horizontal rule",get disabled(){return f(h)},get onMouseDown(){return f(ce)},style:"min-width: 30px;"})}var Ee=k(de,2);{const ce=ke=>{var pe=yU();T(ke,pe)};let ve=P(()=>K(()=>e.editor.chain().focus().toggleCodeBlock().run()));Xt(Ee,{ariaLabel:"Code block",get disabled(){return f(h)},get active(){return f(R)},get onMouseDown(){return f(ve)},style:"min-width: 30px; padding: 4px 6px;",children:ce,$$slots:{default:!0}})}L("keydown",D,ce=>{ce.key==="Escape"&&b(s,!1)}),L("keydown",oe,ce=>{ce.key==="Escape"&&F()}),T(C,I)};Z(j,C=>{e.editor&&C(ae)})}T(n,B),Ke()}Ye(["keydown","mousedown"]);var xU=O("<button></button>"),kU=O(`<div style="position: absolute; top: 100%; left: 0; margin-top: 4px;
|
|
282
|
-
background: var(--tandem-surface); border: 1px solid var(--tandem-border);
|
|
283
|
-
border-radius: var(--tandem-r-3); padding: 6px; display: flex; gap: 4px;
|
|
284
|
-
z-index: var(--tandem-z-dropdown); box-shadow: var(--tandem-shadow-2);"><!> <button data-testid="color-picker-close" title="Close" aria-label="Close color picker" style="width: 24px; height: 24px; border-radius: var(--tandem-r-2);
|
|
285
|
-
border: 1px solid var(--tandem-border);
|
|
286
|
-
background: var(--tandem-surface-muted); cursor: pointer; padding: 0;
|
|
287
|
-
font-size: 13px; color: var(--tandem-fg-muted);
|
|
288
|
-
display: flex; align-items: center; justify-content: center;">✕</button></div>`),_U=O('<div style="display: flex; align-items: center; gap: 2px; position: relative;"><!> <button data-testid="toolbar-highlight-color-toggle" title="Choose highlight color"><span></span></button> <!></div>');function SU(n,e){We(e,!0);const t=[{value:"yellow",label:"Yellow"},{value:"green",label:"Green"},{value:"blue",label:"Blue"},{value:"pink",label:"Pink"}],r=lt(e,"disabled",3,!1);let i=z("yellow"),o=z(!1),s=z(null);he(()=>{if(!f(o))return;function g(y){f(s)&&!f(s).contains(y.target)&&b(o,!1)}return document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)});function a(g){g.preventDefault(),e.onHighlight(f(i))}function l(g){g.preventDefault(),b(o,!f(o))}function c(g){b(i,g,!0),b(o,!1)}var d=_U(),u=x(d);Xt(u,{label:"Highlight",testId:"toolbar-highlight-btn",get disabled(){return r()},disabledTitle:"Select text first",onMouseDown:a,style:"border-radius: var(--tandem-r-2) 0 0 var(--tandem-r-2); border-right: none;"});var h=k(u,2),p=x(h),m=k(h,2);{var v=g=>{var y=kU(),w=x(y);ft(w,17,()=>t,({value:S,label:A})=>S,(S,A)=>{let U=()=>f(A).value,N=()=>f(A).label;var R=xU();G(()=>{Q(R,"data-testid",`toolbar-highlight-color-${U()}`),Q(R,"title",N()),Q(R,"aria-label",N()),re(R,`width: 24px; height: 24px; border-radius: var(--tandem-r-2);
|
|
289
|
-
border: ${U()===f(i)?"2px solid var(--tandem-fg)":"1px solid var(--tandem-border)"};
|
|
290
|
-
background: ${Rl[U()]??""};
|
|
291
|
-
cursor: pointer; padding: 0;`)}),L("click",R,()=>c(U())),T(S,R)});var _=k(w,2);yt(y,S=>b(s,S),()=>f(s)),L("click",_,()=>b(o,!1)),T(g,y)};Z(m,g=>{f(o)&&g(v)})}G(()=>{h.disabled=r(),re(h,`padding: 4px 6px; font-size: 13px; border: 1px solid var(--tandem-border);
|
|
292
|
-
border-radius: 0 var(--tandem-r-2) var(--tandem-r-2) 0;
|
|
293
|
-
background: ${r()?"var(--tandem-surface-muted)":"var(--tandem-surface)"};
|
|
294
|
-
cursor: ${r()?"not-allowed":"pointer"};
|
|
295
|
-
display: flex; align-items: center;`),re(p,`display: inline-block; width: 12px; height: 12px; border-radius: var(--tandem-r-1);
|
|
296
|
-
background: ${Rl[f(i)]??""};
|
|
297
|
-
border: 1px solid var(--tandem-border);`)}),L("mousedown",h,l),T(n,d),Ke()}Ye(["mousedown","click"]);var CU=O(`<div data-testid="formatting-bar" style="display: flex; align-items: center; height: var(--tandem-h-fmtbar, 36px);
|
|
298
|
-
padding: 0 var(--tandem-space-2);
|
|
299
|
-
border-bottom: 1px solid var(--tandem-border);
|
|
300
|
-
background: var(--tandem-surface-muted);
|
|
301
|
-
user-select: none; position: relative; z-index: 4;"><button type="button" data-testid="formatting-bar-toggle-left"><svg width="14" height="14" viewBox="0 0 16 16" fill="none" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"><rect x="1" y="2" width="14" height="12" rx="1.5" stroke="currentColor" stroke-width="1.5" fill="none"></rect><rect x="1" y="2" width="5" height="12" fill="currentColor" opacity="0.6"></rect></svg></button> <div style="width: 1px; height: 16px; background: var(--tandem-border); margin: 0 var(--tandem-space-2); flex-shrink: 0;"></div> <div style="flex: 1; display: flex; align-items: center; gap: 2px; overflow: hidden; min-width: 0;"><!> <div style="width: 1px; height: 16px; background: var(--tandem-border); margin: 0 2px; flex-shrink: 0;"></div> <!></div> <div style="width: 1px; height: 16px; background: var(--tandem-border); margin: 0 var(--tandem-space-2); flex-shrink: 0;"></div> <button type="button" data-testid="formatting-bar-toggle-right"><svg width="14" height="14" viewBox="0 0 16 16" fill="none" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"><rect x="1" y="2" width="14" height="12" rx="1.5" stroke="currentColor" stroke-width="1.5" fill="none"></rect><rect x="10" y="2" width="5" height="12" fill="currentColor" opacity="0.6"></rect></svg></button></div>`);function TU(n,e){We(e,!0);const t=lt(e,"leftPanelVisible",3,!1),r=lt(e,"rightPanelVisible",3,!0);let i=z(0);he(()=>{const p=e.editor;if(!p||p.isDestroyed)return;const m=()=>{p.isDestroyed||Md(i)};return p.on("selectionUpdate",m),p.on("transaction",m),()=>{p.off("selectionUpdate",m),p.off("transaction",m)}});const o=P(()=>(f(i),!e.editor||e.editor.isDestroyed||!e.ydoc?!1:!e.editor.state.selection.empty));function s(p){if(!e.editor||!e.ydoc||e.editor.isDestroyed)return;const{state:m}=e.editor,{from:v,to:g}=m.selection;if(v===g)return;const y=$r(m.doc,mn(v)),w=$r(m.doc,mn(g));if(y===null||w===null){console.warn("[FormattingBar] pmPosToFlatOffset returned null — CRDT position may be degraded",{from:v,to:g});return}gS(e.ydoc,{from:y,to:w},p)}var a=CU(),l=x(a),c=k(l,4),d=x(c);wU(d,{get editor(){return e.editor}});var u=k(d,4);{let p=P(()=>!f(o));SU(u,{get disabled(){return f(p)},onHighlight:s})}var h=k(c,4);G(()=>{Q(l,"aria-label",t()?"Hide panel":"Show panel"),Q(l,"aria-pressed",t()),Q(l,"title",t()?"Hide panel":"Show panel"),re(l,`width: 28px; height: 24px; padding: 0 4px; border: none; border-radius: var(--tandem-r-2);
|
|
302
|
-
background: ${t()?"var(--tandem-accent-bg)":"transparent"};
|
|
303
|
-
color: ${t()?"var(--tandem-accent)":"var(--tandem-fg-subtle)"};
|
|
304
|
-
cursor: pointer; display: flex; align-items: center; justify-content: center;
|
|
305
|
-
margin-right: var(--tandem-space-2); flex-shrink: 0;`),Q(h,"aria-label",r()?"Hide panels":"Show panels"),Q(h,"aria-pressed",r()),Q(h,"title",r()?"Hide panels":"Show panels"),re(h,`width: 28px; height: 24px; padding: 0 4px; border: none; border-radius: var(--tandem-r-2);
|
|
306
|
-
background: ${r()?"var(--tandem-accent-bg)":"transparent"};
|
|
307
|
-
color: ${r()?"var(--tandem-accent)":"var(--tandem-fg-subtle)"};
|
|
308
|
-
cursor: pointer; display: flex; align-items: center; justify-content: center;
|
|
309
|
-
margin-left: var(--tandem-space-2); flex-shrink: 0;`)}),L("click",l,function(...p){var m;(m=e.onToggleLeftPanel)==null||m.apply(this,p)}),L("click",h,function(...p){var m;(m=e.onToggleRightPanel)==null||m.apply(this,p)}),T(n,a),Ke()}Ye(["click"]);var AU=O('<span class="title-bar-dirty svelte-12l7ydf" aria-label="unsaved changes"></span>'),EU=Wi('<svg width="10" height="10" viewBox="0 0 10 10" aria-hidden="true" focusable="false"><path d="M3 0H10V7H7V10H0V3H3V0ZM3 3H1V9H6V7H3V3ZM4 1V6H9V1H4Z" fill="currentColor"></path></svg>'),MU=Wi('<svg width="10" height="10" viewBox="0 0 10 10" aria-hidden="true" focusable="false"><path d="M0 0H10V10H0V0ZM1 2V9H9V2H1Z" fill="currentColor"></path></svg>'),OU=O('<div class="title-bar svelte-12l7ydf"><div class="title-bar-left svelte-12l7ydf" data-tauri-drag-region=""><span class="title-bar-title svelte-12l7ydf"> <!></span></div> <div class="title-bar-chrome svelte-12l7ydf"></div> <div class="title-bar-controls svelte-12l7ydf"><button type="button" class="title-bar-btn svelte-12l7ydf" aria-label="Minimize"><svg width="10" height="1" viewBox="0 0 10 1" aria-hidden="true" focusable="false"><rect width="10" height="1" fill="currentColor"></rect></svg></button> <button type="button" class="title-bar-btn svelte-12l7ydf"><!></button> <button type="button" class="title-bar-btn title-bar-close svelte-12l7ydf" aria-label="Close"><svg width="10" height="10" viewBox="0 0 10 10" aria-hidden="true" focusable="false"><path d="M1 0L0 1L4 5L0 9L1 10L5 6L9 10L10 9L6 5L10 1L9 0L5 4L1 0Z" fill="currentColor"></path></svg></button></div></div>');function DU(n,e){We(e,!0);const t=lt(e,"title",3,"Tandem"),r=lt(e,"dirty",3,!1);let i=null,o=z(!1),s=[];ef(async()=>{if(Cr())try{const[{invoke:m},{getCurrentWindow:v}]=await Promise.all([ko(()=>import("./core-DhEqZVGG.js"),[]),ko(()=>import("./window-BxBvHL5k.js").then(w=>w.w),__vite__mapDeps([0,1]))]);await m("setup_overlay_titlebar").catch(w=>{console.warn("[TitleBar] setup_overlay_titlebar failed:",w)}),i=v(),b(o,await i.isMaximized(),!0);const g=await i.onResized(async()=>{try{b(o,await i.isMaximized(),!0)}catch(w){console.warn("[TitleBar] isMaximized check failed on resize:",w)}}),y=await i.onMoved(async()=>{try{b(o,await i.isMaximized(),!0)}catch(w){console.warn("[TitleBar] isMaximized check failed on move:",w)}});s=[g,y]}catch(m){console.error("[TitleBar] Window API initialization failed:",m)}}),pi(()=>{s.forEach(m=>m())});async function a(){try{await(i==null?void 0:i.minimize())}catch(m){console.error("[TitleBar] minimize failed:",m)}}async function l(){try{await(i==null?void 0:i.toggleMaximize())}catch(m){console.error("[TitleBar] toggleMaximize failed:",m)}}async function c(){try{await(i==null?void 0:i.close())}catch(m){console.error("[TitleBar] close failed:",m)}}var d=Tt(),u=Le(d);{var h=m=>{var v=OU(),g=x(v),y=x(g),w=x(y),_=k(w);{var S=K=>{var V=AU();T(K,V)};Z(_,K=>{r()&&K(S)})}var A=k(g,4),U=x(A),N=k(U,2),R=x(N);{var E=K=>{var V=EU();T(K,V)},q=K=>{var V=MU();T(K,V)};Z(R,K=>{f(o)?K(E):K(q,-1)})}var te=k(N,2);G(()=>{ne(w,t()??"Tandem"),Q(N,"aria-label",f(o)?"Restore":"Maximize")}),L("click",U,a),L("click",N,l),L("click",te,c),T(m,v)},p=P(()=>Cr());Z(u,m=>{f(p)&&m(h)})}T(n,d),Ke()}Ye(["click"]);var RU=O('<span style="color: var(--tandem-fg-subtle);"> </span>'),NU=O('<span data-testid="save-indicator" style="color: var(--tandem-accent);">Saving...</span>'),IU=O('<button data-testid="sb-held" title="Show held annotations — switches to Tandem" style="display: inline-flex; align-items: center; gap: var(--tandem-space-1); padding: 1px 8px; font-size: var(--tandem-text-xs); font-weight: 600; border: 1px solid var(--tandem-warning-border); border-radius: var(--tandem-r-pill); background: var(--tandem-warning-bg); color: var(--tandem-warning-fg-strong); cursor: pointer;"><span style="width: 6px; height: 6px; border-radius: 50%; background: var(--tandem-warning-fg-strong); display: inline-block;"></span> </button>'),PU=O('<span style="padding: 1px 8px; font-size: var(--tandem-text-2xs); font-weight: 600; color: var(--tandem-warning-fg-strong); background: var(--tandem-warning-bg); border-radius: var(--tandem-r-pill); border: 1px solid var(--tandem-warning-border);">Review Only</span>'),LU=O('<div style="display: flex; align-items: center; justify-content: space-between; padding: 0 var(--tandem-space-4); height: 28px; border-top: 1px solid var(--tandem-border); background: var(--tandem-surface-muted); font-family: var(--tandem-font-mono); font-size: var(--tandem-text-xs); color: var(--tandem-fg-muted); user-select: none; gap: var(--tandem-space-3);"><div style="display: flex; align-items: center; gap: var(--tandem-space-2);"><span class="status-dot svelte-1esxubl"></span> <span> </span> <!> <!></div> <div style="display: flex; align-items: center; gap: var(--tandem-space-1); font-size: var(--tandem-text-xs); color: var(--tandem-fg-subtle);"><span>You:</span> <input data-testid="user-name-input" type="text" aria-label="Display name" title="Your display name" style="background: transparent; border: none; border-bottom: 1px dashed transparent; color: var(--tandem-fg-muted); font: inherit; font-family: var(--tandem-font-sans); font-size: var(--tandem-text-xs); width: 80px; outline: none; padding: 0 2px;"/></div> <!> <!> <div style="display: flex; align-items: center; gap: var(--tandem-space-2);"><span class="claude-dot svelte-1esxubl"></span> <span> </span></div></div>');function zU(n,e){We(e,!0);let t=lt(e,"documentCount",3,0),r=lt(e,"saving",3,!1);const i=2e3,o=xk();let s=z(at(o.userName)),a=z(void 0);he(()=>{const B=o.userName;f(s)!==B&&document.activeElement!==f(a)&&b(s,B,!0)});let l=z(!1),c=z(0),d=Ut(()=>e.connected);he(()=>{const B=d;if(d=e.connected,e.connected&&!B){b(l,!0);const j=setTimeout(()=>{b(l,!1)},i);return()=>clearTimeout(j)}}),he(()=>{if(e.disconnectedSince==null){b(c,0);return}b(c,Math.floor((Date.now()-e.disconnectedSince)/1e3),!0);const B=setInterval(()=>{b(c,Math.floor((Date.now()-(e.disconnectedSince??0))/1e3),!0)},1e3);return()=>clearInterval(B)});const u=P(()=>e.connectionStatus==="connecting"),h=P(()=>e.connected?"var(--tandem-success)":f(u)?"var(--tandem-warning)":"var(--tandem-error)"),p=P(()=>f(l)?"Reconnected":e.connectionStatus==="connected"?"Connected":e.connectionStatus==="connecting"?(()=>{const B=["Reconnecting…"];if(e.reconnectAttempts>0||f(c)>0){const j=[];e.reconnectAttempts>0&&j.push(`attempt ${e.reconnectAttempts}`),f(c)>0&&j.push(`${f(c)}s`),B.push(`(${j.join(", ")})`)}return B.join(" ")})():"Disconnected — check that the server is running");function m(){o.setUserName(f(s))}var v=LU(),g=x(v),y=x(g),w=k(y,2),_=x(w),S=k(w,2);{var A=B=>{var j=RU(),ae=x(j);G(()=>ne(ae,`${t()??""} doc${t()!==1?"s":""} open`)),T(B,j)};Z(S,B=>{t()>0&&B(A)})}var U=k(S,2);{var N=B=>{var j=NU();T(B,j)};Z(U,B=>{r()&&B(N)})}var R=k(g,2),E=k(x(R),2);yt(E,B=>b(a,B),()=>f(a));var q=k(R,2);{var te=B=>{var j=IU(),ae=k(x(j));G(()=>ne(ae,` ${e.heldCount??""} held`)),L("click",j,function(...C){var I;(I=e.onShowHeld)==null||I.apply(this,C)}),T(B,j)};Z(q,B=>{(e.heldCount??0)>0&&e.mode==="solo"&&B(te)})}var K=k(q,2);{var V=B=>{var j=PU();T(B,j)};Z(K,B=>{e.readOnly&&B(V)})}var ee=k(K,2),se=x(ee),F=k(se,2),X=x(F);G(()=>{re(y,`width: 8px; height: 8px; border-radius: 50%; background: ${f(h)??""}; display: inline-block; animation: ${f(u)?"tandem-reconnect-pulse 1.2s ease-in-out infinite":"none"};`),ne(_,f(p)),Rr(E,f(s)),Q(E,"maxlength",tx),re(se,`width: 8px; height: 8px; border-radius: 50%; background: var(--tandem-author-claude); opacity: ${e.claudeActive?1:.4}; display: inline-block; transition: opacity 0.3s ease; animation: ${e.claudeActive?"tandem-status-pulse 1.5s ease-in-out infinite":"none"};`),re(F,`transition: color 0.3s ease; color: ${e.claudeActive?"var(--tandem-fg)":"var(--tandem-fg-subtle)"};`),ne(X,e.claudeStatus?`Claude · ${e.claudeStatus}`:"Claude · idle")}),L("input",E,B=>{b(s,B.target.value,!0)}),vt("blur",E,m),L("keydown",E,B=>{B.key==="Enter"&&B.currentTarget.blur(),B.key==="Escape"&&(b(s,o.userName,!0),B.currentTarget.blur())}),T(n,v),Ke()}Ye(["input","keydown","click"]);function lv(n,e,t=dA){const r=n.filter(i=>i!==e);return[e,...r].slice(0,t)}function cv(){try{const n=localStorage.getItem(Vm);if(!n)return[];const e=JSON.parse(n);return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}catch(n){return console.warn("[tandem] failed to load recent files:",n),[]}}function dv(n){try{localStorage.setItem(Vm,JSON.stringify(n)),yS()}catch(e){console.warn("[tandem] failed to save recent files:",e)}}function BU(){try{localStorage.removeItem(Vm),yS()}catch(n){console.warn("[tandem] failed to clear recent files:",n)}}const FU=3e4;let rl=null;function W0(){const n=Date.now();if(rl&&n-rl.ts<FU)return rl.files;const e=cv();return rl={files:e,ts:n},e}function yS(){rl=null}var VU=O('<button type="button" style="background: none; border: none; padding: 6px 8px; border-radius: var(--tandem-r-2); cursor: pointer; text-align: left; display: flex; flex-direction: column; gap: 1px;"><span style="font-size: 13px; color: var(--tandem-fg);"> </span> <span style="font-size: 11px; color: var(--tandem-fg-subtle); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 380px;"> </span></button>'),HU=O('<div data-testid="recent-files-list" style="margin-top: 14px;"><div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px;"><span style="font-size: 11px; color: var(--tandem-fg-subtle); text-transform: uppercase; letter-spacing: 0.05em;">Recent</span> <button data-testid="clear-recent-files" type="button" style="background: none; border: none; color: var(--tandem-fg-subtle); font-size: 11px; cursor: pointer; padding: 0; text-decoration: underline;">Clear all</button></div> <div style="max-height: 150px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px;"></div></div>'),UU=O('<div><input type="text" placeholder="Paste absolute file path..." style="width: 100%; padding: 8px 10px; font-size: 13px; border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-2); box-sizing: border-box; background: var(--tandem-surface); color: var(--tandem-fg);" data-testid="file-path-input"/> <button data-testid="file-open-submit"> </button> <!></div>'),jU=O('<div role="button" data-testid="file-upload-zone"><input type="file" accept=".md,.txt,.html,.htm,.docx" style="display: none;"/> <div style="font-size: 13px; color: var(--tandem-fg-muted);"> </div> <div style="font-size: 11px; color: var(--tandem-fg-subtle); margin-top: 6px;">.md, .txt, .html, .docx</div></div>'),WU=O('<div style="margin-top: 10px; padding: 8px 10px; font-size: 12px; color: var(--tandem-error-fg-strong); background: var(--tandem-error-bg); border-radius: var(--tandem-r-2); border: 1px solid var(--tandem-error-border);" data-testid="file-open-error"> </div>'),KU=O('<div role="dialog" aria-modal="true" aria-label="Open File" style="position: fixed; inset: 0; z-index: 1000; display: flex; align-items: flex-start; justify-content: center; padding-top: 80px; background: rgba(0,0,0,0.3);"><div style="background: var(--tandem-surface); border-radius: var(--tandem-r-4); box-shadow: var(--tandem-shadow-3); width: 440px; padding: 20px;" data-testid="file-open-dialog"><div style="display: flex; justify-content: space-between; margin-bottom: 16px;"><h3 style="margin: 0; font-size: 15px; font-weight: 600; color: var(--tandem-fg);">Open File</h3> <button style="background: none; border: none; cursor: pointer; font-size: 16px; color: var(--tandem-fg-subtle);">×</button></div> <div style="display: flex; gap: 8px; margin-bottom: 16px;"><button>File Path</button> <button>Open</button></div> <!> <!></div></div>');function qU(n,e){We(e,!0);let t=z("upload"),r=z(""),i=z(null),o=z(!1),s=z(!1),a=z(void 0),l=z(at(cv()));function c(K){b(l,(()=>{const V=lv(f(l),K);return dv(V),V})(),!0)}function d(){BU(),b(l,[],!0)}async function u(K){if(!f(o)){b(i,null),b(o,!0);try{const V=await fetch(`${Sr}/open`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filePath:K})}),ee=await V.json();if(!V.ok){b(i,ee.message??"Failed to open file",!0);return}c(K),e.onClose()}catch(V){console.error("FileOpenDialog: path open failed",V),V instanceof SyntaxError?b(i,"Server returned an unexpected response"):V instanceof TypeError?b(i,"Unexpected response format"):b(i,"Cannot reach server. Is it running?")}finally{b(o,!1)}}}function h(){f(r).trim()&&u(f(r).trim())}async function p(K){if(!f(o)){b(i,null),b(o,!0);try{const V=await ix(K),ee=await fetch(`${Sr}/upload`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({fileName:K.name,content:V})}),se=await ee.json();if(!ee.ok){b(i,se.message??"Failed to open file",!0);return}e.onClose()}catch(V){console.error("FileOpenDialog: upload failed",V),V instanceof SyntaxError?b(i,"Server returned an unexpected response"):V instanceof TypeError?b(i,"Unexpected response format"):b(i,"Cannot reach server. Is it running?")}finally{b(o,!1)}}}function m(K){var ee;K.preventDefault(),b(s,!1);const V=(ee=K.dataTransfer)==null?void 0:ee.files[0];V&&p(V)}function v(K){var se;const ee=(se=K.target.files)==null?void 0:se[0];ee&&p(ee)}var g=KU();Q(g,"tabindex",-1);var y=x(g),w=x(y),_=k(x(w),2),S=k(w,2),A=x(S),U=k(A,2),N=k(S,2);{var R=K=>{var V=UU(),ee=x(V);FC(ee);var se=k(ee,2),F=x(se),X=k(se,2);{var B=j=>{var ae=HU(),C=x(ae),I=k(x(C),2),W=k(C,2);ft(W,22,()=>f(l),ge=>ge,(ge,xe,Oe)=>{const J=P(()=>xe.split(/[/\\]/)),fe=P(()=>f(J).at(-1)??xe),D=P(()=>f(J).slice(0,-1).join("/")||"/");var Y=VU(),be=x(Y),we=x(be),Te=k(be,2),Se=x(Te);G(()=>{Q(Y,"data-testid",`recent-file-${f(Oe)}`),ne(we,f(fe)),ne(Se,f(D))}),L("click",Y,()=>{b(r,xe,!0),u(xe)}),vt("mouseenter",Y,De=>{De.currentTarget.style.background="var(--tandem-surface-muted)"}),vt("mouseleave",Y,De=>{De.currentTarget.style.background="transparent"}),T(ge,Y)}),L("click",I,d),T(j,ae)};Z(X,j=>{f(l).length>0&&j(B)})}G((j,ae)=>{se.disabled=j,re(se,ae),ne(F,f(o)?"Opening...":"Open")},[()=>f(o)||!f(r).trim(),()=>`margin-top: 10px; width: 100%; padding: 8px; font-size: 13px; font-weight: 500; border: none; border-radius: var(--tandem-r-2); cursor: ${f(o)?"wait":"pointer"}; background: ${f(o)?"var(--tandem-fg-subtle)":"var(--tandem-accent)"}; color: var(--tandem-accent-fg); opacity: ${f(r).trim()?1:.5};`]),L("keydown",ee,j=>{j.key==="Enter"&&h()}),hs(ee,()=>f(r),j=>b(r,j)),L("click",se,h),T(K,V)},E=K=>{var V=jU();Q(V,"tabindex",0);var ee=x(V);yt(ee,X=>b(a,X),()=>f(a));var se=k(ee,2),F=x(se);G(()=>{re(V,`border: 2px dashed ${f(s)?"var(--tandem-accent)":"var(--tandem-border-strong)"}; border-radius: var(--tandem-r-3); padding: 32px 16px; text-align: center; cursor: ${f(o)?"wait":"pointer"}; background: ${f(s)?"var(--tandem-accent-bg)":"var(--tandem-surface-muted)"}; transition: border-color 0.15s, background 0.15s;`),ne(F,f(o)?"Opening...":"Drop a file here or click to browse")}),vt("dragover",V,X=>{X.preventDefault(),b(s,!0)}),vt("dragleave",V,()=>b(s,!1)),vt("drop",V,m),L("click",V,()=>{var X;return(X=f(a))==null?void 0:X.click()}),L("keydown",V,X=>{var B;(X.key==="Enter"||X.key===" ")&&((B=f(a))==null||B.click())}),L("change",ee,v),T(K,V)};Z(N,K=>{f(t)==="path"?K(R):K(E,-1)})}var q=k(N,2);{var te=K=>{var V=WU(),ee=x(V);G(()=>ne(ee,f(i))),T(K,V)};Z(q,K=>{f(i)&&K(te)})}G(()=>{re(A,`flex: 1; padding: 6px; font-size: 13px; border: 1px solid var(--tandem-border); border-radius: var(--tandem-r-2); cursor: pointer; background: ${f(t)==="path"?"var(--tandem-accent)":"var(--tandem-surface)"}; color: ${f(t)==="path"?"var(--tandem-accent-fg)":"var(--tandem-fg)"};`),re(U,`flex: 1; padding: 6px; font-size: 13px; border: 1px solid var(--tandem-border); border-radius: var(--tandem-r-2); cursor: pointer; background: ${f(t)==="upload"?"var(--tandem-accent)":"var(--tandem-surface)"}; color: ${f(t)==="upload"?"var(--tandem-accent-fg)":"var(--tandem-fg)"};`)}),L("click",g,K=>{K.target===K.currentTarget&&e.onClose()}),L("keydown",g,K=>{K.key==="Escape"&&e.onClose()}),L("click",_,function(...K){var V;(V=e.onClose)==null||V.apply(this,K)}),L("click",A,()=>b(t,"path")),L("click",U,()=>b(t,"upload")),T(n,g),Ke()}Ye(["click","keydown","change"]);function jh(n){return document.body.appendChild(n),{destroy(){n.remove()}}}var JU=O('<button role="menuitem" type="button" class="new-tab-menu-item svelte-7c4il0"><span class="new-tab-menu-badge svelte-7c4il0"> </span> <span class="new-tab-menu-label svelte-7c4il0"> </span></button>'),YU=O('<div class="new-tab-menu-divider svelte-7c4il0"></div>'),GU=O('<div role="dialog" aria-label="New tab" tabindex="-1" class="new-tab-menu svelte-7c4il0"><div class="new-tab-menu-header svelte-7c4il0">Recent files</div> <!> <!> <button role="menuitem" type="button" data-testid="palette-item-new-scratchpad" class="new-tab-menu-item new-tab-menu-action svelte-7c4il0">New Scratchpad</button> <button role="menuitem" type="button" class="new-tab-menu-item new-tab-menu-action svelte-7c4il0" style="padding-bottom: 8px;">Browse files…</button></div>');function ZU(n,e){We(e,!0);function t(v){return v.replace(/[/\\]+$/,"").replace(/.*[/\\]/,"")}function r(v){var y;const g=((y=v.split(".").pop())==null?void 0:y.toLowerCase())??"";return g==="md"?"M":g==="docx"||g==="doc"?"W":g==="txt"?"T":g==="html"||g==="htm"?"H":g.slice(0,1).toUpperCase()||"?"}function i(v){var g,y;if(v.key==="Escape")v.preventDefault(),e.onClose();else if(v.key==="ArrowDown"){v.preventDefault();const w=o(),_=w.indexOf(document.activeElement);(g=w[(_+1)%w.length])==null||g.focus()}else if(v.key==="ArrowUp"){v.preventDefault();const w=o(),_=w.indexOf(document.activeElement);(y=w[(_-1+w.length)%w.length])==null||y.focus()}}function o(){var v;return Array.from(((v=f(s))==null?void 0:v.querySelectorAll("[role='menuitem']"))??[])}let s=z(null);function a(v){var y,w;const g=v.target;g&&((y=e.anchorEl)!=null&&y.contains(g)||(w=g.closest)!=null&&w.call(g,"[data-tauri-drag-region]")||e.onClose())}function l(){if(!f(s))return;if(!e.anchorEl){f(s).style.top="8px",f(s).style.left="8px",f(s).style.right="auto";return}const v=e.anchorEl.getBoundingClientRect(),g=f(s).offsetWidth,y=window.innerWidth,w=v.bottom+4,_=v.left;_+g>y-8?(f(s).style.right="8px",f(s).style.left="auto"):(f(s).style.left=`${_}px`,f(s).style.right="auto"),f(s).style.top=`${w}px`}he(()=>{var v;f(s)&&(l(),(v=o()[0])==null||v.focus())});var c=GU(),d=k(x(c),2);ft(d,17,()=>e.recentFiles,ma,(v,g)=>{var y=JU(),w=x(y),_=x(w),S=k(w,2),A=x(S);G((U,N)=>{Q(y,"title",f(g)),ne(_,U),ne(A,N)},[()=>r(f(g)),()=>t(f(g))]),L("click",y,()=>e.onOpen(f(g))),T(v,y)});var u=k(d,2);{var h=v=>{var g=YU();T(v,g)};Z(u,v=>{e.recentFiles.length>0&&v(h)})}var p=k(u,2),m=k(p,2);El(c,v=>jh==null?void 0:jh(v)),El(c,(v,g)=>hr==null?void 0:hr(v,g),()=>a),yt(c,v=>b(s,v),()=>f(s)),L("keydown",c,i),L("click",p,function(...v){var g;(g=e.onNewScratchpad)==null||g.apply(this,v)}),L("click",m,function(...v){var g;(g=e.onBrowse)==null||g.apply(this,v)}),T(n,c),Ke()}Ye(["keydown","click"]);var XU=O('<span style="font-family: var(--tandem-font-mono); font-size: var(--tandem-text-2xs); color: var(--tandem-warning-fg-strong); background: var(--tandem-warning-bg); border: 1px solid var(--tandem-warning-border); padding: 0 4px; border-radius: var(--tandem-r-pill);">RO</span>'),QU=O('<div role="tab"><span>●</span> <span> </span> <span> </span> <!> <button style="background: none; border: none; cursor: pointer; font-size: var(--tandem-text-md); line-height: 1; color: var(--tandem-fg-muted); padding: 0 2px; border-radius: var(--tandem-r-1);" title="Close document">×</button></div>');function $U(n,e){We(e,!0);const t={md:"MD",txt:"TXT",html:"HTML",docx:"DOCX"},r={md:"var(--tandem-accent-fg-strong)",txt:"var(--tandem-fg-faint)",html:"var(--tandem-info-fg)",docx:"var(--tandem-suggestion-fg-strong)"},i=P(()=>r[e.tab.format]??"var(--tandem-fg-faint)");let o=z(!1),s=null;he(()=>{const{ydoc:S,readOnly:A}=e.tab;if(A){b(o,!1);return}const U=S.getXmlFragment("default"),N=S.getMap(ol);let R=!1;const E=setTimeout(()=>{R=!0,s=N.get(sl)??0,b(o,!1)},500),q=()=>{R&&b(o,!0)};U.observeDeep(q);const te=()=>{if(!R)return;const K=N.get(sl);K!==void 0&&K!==s&&(s=K,b(o,!1))};return N.observe(te),()=>{clearTimeout(E),U.unobserveDeep(q),N.unobserve(te)}});const a=P(()=>["display: flex","align-items: center","gap: 8px","padding: 0 12px","height: 100%","font-size: var(--tandem-text-sm)","cursor: pointer",`background: ${e.isActive?"var(--tandem-surface)":"transparent"}`,`color: ${e.isActive?"var(--tandem-fg)":"var(--tandem-fg-subtle)"}`,"border-top: 0",`border-bottom: ${e.isActive?"2px solid var(--tandem-accent)":"2px solid transparent"}`,`border-left: ${e.dropIndicator==="left"?"2px solid var(--tandem-accent)":"2px solid transparent"}`,`border-right: ${e.dropIndicator==="right"?"2px solid var(--tandem-accent)":"2px solid transparent"}`,"margin-bottom: -1px","user-select: none","white-space: nowrap","transition: background 0.15s, color 0.15s, border-color 0.15s","flex-shrink: 0"].join("; "));let l=z(void 0);function c(){f(l)&&(f(l).style.color="var(--tandem-error)")}function d(){f(l)&&(f(l).style.color="var(--tandem-fg-muted)")}var u=QU();Q(u,"tabindex",0);var h=x(u),p=k(h,2),m=x(p),v=k(p,2),g=x(v),y=k(v,2);{var w=S=>{var A=XU();T(S,A)};Z(y,S=>{e.tab.readOnly&&S(w)})}var _=k(y,2);yt(_,S=>b(l,S),()=>f(l)),G(S=>{Q(u,"data-testid",`tab-${e.tab.id}`),Q(u,"data-active",e.isActive),Q(u,"aria-selected",e.isActive),Q(u,"aria-label",e.tab.fileName),Q(u,"draggable",e.draggable),re(u,f(a)),Q(h,"data-testid",`unsaved-indicator-${e.tab.id}`),re(h,`color: var(--tandem-warning); font-size: 10px; visibility: ${f(o)?"visible":"hidden"};`),Q(h,"aria-hidden",!f(o)),Q(p,"data-testid",`tab-format-badge-${e.tab.id}`),Q(p,"aria-label",`Format: ${e.tab.format}`),re(p,`font-family: var(--tandem-font-mono); font-size: 9px; font-weight: 600; letter-spacing: 0.03em; color: ${f(i)}; background: transparent; padding: 1px 4px; border: 1px solid ${f(i)}; border-radius: var(--tandem-r-pill); white-space: nowrap;`),ne(m,S),Q(v,"data-testid",`tab-name-${e.tab.id}`),Q(v,"title",e.tab.filePath),re(v,`font-weight: ${e.isActive?500:400}; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;`),ne(g,e.tab.fileName),Q(_,"aria-label",`Close ${e.tab.fileName}`)},[()=>t[e.tab.format]??e.tab.format.toUpperCase()]),L("click",u,()=>e.onswitch(e.tab.id)),vt("dragstart",u,S=>e.ondragstart(S,e.tab.id)),vt("dragover",u,S=>e.ondragover(S,e.tab.id)),vt("drop",u,S=>e.ondrop(S,e.tab.id)),vt("dragend",u,function(...S){var A;(A=e.ondragend)==null||A.apply(this,S)}),vt("dragleave",u,function(...S){var A;(A=e.ondragleave)==null||A.apply(this,S)}),L("keydown",u,S=>e.onkeydown(S,e.tab.id)),L("click",_,S=>{S.stopPropagation(),e.onclose(e.tab.id)}),vt("dragover",_,S=>{S.stopPropagation(),S.preventDefault()}),vt("drop",_,S=>{S.stopPropagation(),S.preventDefault()}),vt("mouseenter",_,c),vt("mouseleave",_,d),T(n,u),Ke()}Ye(["click","keydown"]);var e5=O('<button data-testid="tab-scroll-left" style="display: flex; align-items: center; justify-content: center; width: 28px; min-width: 28px; background: linear-gradient(to right, var(--tandem-surface-muted) 70%, transparent); border: none; cursor: pointer; font-size: 12px; color: var(--tandem-fg-muted); padding: 0; z-index: 1;" title="Scroll tabs left">◀</button>'),t5=O('<button data-testid="tab-scroll-right" style="display: flex; align-items: center; justify-content: center; width: 28px; min-width: 28px; background: linear-gradient(to left, var(--tandem-surface-muted) 70%, transparent); border: none; cursor: pointer; font-size: 12px; color: var(--tandem-fg-muted); padding: 0; z-index: 1;" title="Scroll tabs right">▶</button>'),n5=O('<div style="position: relative; display: flex; align-items: stretch; background: var(--tandem-surface-muted); border-bottom: 1px solid var(--tandem-border); min-height: 32px; padding: 0 var(--tandem-space-3); z-index: var(--tandem-z-base);"><!> <div data-testid="tab-scroll-container" class="tab-scroll-hide" role="tablist" aria-label="Open documents" style="display: flex; align-items: stretch; gap: 2px; flex: 1; overflow-x: auto; overflow-y: hidden;"></div> <button data-testid="open-file-btn" title="Open file" style="background: none; border: none; border-radius: var(--tandem-r-2); cursor: pointer; font-size: 16px; line-height: 1; color: var(--tandem-fg-subtle); padding: 0 8px; margin-left: 4px; flex-shrink: 0;">+</button> <!> <!> <!></div>');function r5(n,e){We(e,!0);const t=lt(e,"reduceMotion",3,!1),r=P(()=>t()?"auto":"smooth");let i=z(!1),o=z(!1),s=z(at([])),a=z(null),l=new Set;he(()=>{const C=new Set(e.tabs.map(I=>I.id));for(const I of l)C.has(I)||l.delete(I)});function c(C){l.has(C)||(l.add(C),e.onTabClose(C))}let d=z(void 0),u=z(!1),h=z(!1),p=z(null),m=z(null);function v(){b(p,null),b(m,null)}function g(){const C=f(d);C&&(b(u,C.scrollLeft>0),b(h,C.scrollLeft+C.clientWidth<C.scrollWidth-1))}he(()=>{const C=f(d);if(!C)return;g(),C.addEventListener("scroll",g,{passive:!0});const I=new ResizeObserver(g);return I.observe(C),()=>{C.removeEventListener("scroll",g),I.disconnect()}}),he(()=>{e.tabs.length,g()}),he(()=>{if(!e.activeTabId||!f(d))return;const C=f(d).querySelector(`[data-testid="tab-${e.activeTabId}"]`);C&&C.scrollIntoView({inline:"nearest",block:"nearest",behavior:f(r)})}),he(()=>{e.tabs.length,v()});function y(C,I){b(p,I,!0),C.dataTransfer&&(C.dataTransfer.setData("text/plain",I),C.dataTransfer.effectAllowed="move")}function w(C,I){if(C.preventDefault(),!f(p)||f(p)===I){b(m,null);return}const W=C.currentTarget.getBoundingClientRect(),ge=W.left+W.width/2,xe=C.clientX<ge?"left":"right";b(m,{id:I,side:xe},!0)}function _(C,I){var ge;C.preventDefault();const W=(ge=C.dataTransfer)==null?void 0:ge.getData("text/plain");if(W&&W!==I&&e.reorder){const xe=C.currentTarget.getBoundingClientRect(),Oe=xe.left+xe.width/2,J=C.clientX<Oe?"left":"right";e.reorder(W,I,J)}v()}function S(){v()}function A(){b(m,null)}function U(C,I){if(!C.altKey||!e.reorder||C.key!=="ArrowLeft"&&C.key!=="ArrowRight")return;C.preventDefault();const W=e.tabs.findIndex(ge=>ge.id===I);W!==-1&&(C.key==="ArrowLeft"&&W>0?e.reorder(I,e.tabs[W-1].id):C.key==="ArrowRight"&&W<e.tabs.length-1&&e.reorder(e.tabs[W+1].id,I))}function N(){var C;(C=f(d))==null||C.scrollBy({left:-150,behavior:f(r)})}function R(){var C;(C=f(d))==null||C.scrollBy({left:150,behavior:f(r)})}const E=P(()=>e.tabs.length<=1);he(()=>{if(!f(o))return;function C(I){var ge,xe,Oe;const W=I.target;W&&((ge=f(a))!=null&&ge.contains(W)||(xe=W.closest)!=null&&xe.call(W,".new-tab-menu")||(Oe=W.closest)!=null&&Oe.call(W,"[data-tauri-drag-region]")||b(o,!1))}return window.addEventListener("pointerdown",C,!0),()=>window.removeEventListener("pointerdown",C,!0)});var q=n5(),te=x(q);{var K=C=>{var I=e5();L("click",I,N),T(C,I)};Z(te,C=>{f(u)&&C(K)})}var V=k(te,2);ft(V,21,()=>e.tabs,C=>C.id,(C,I)=>{{let W=P(()=>f(I).id===e.activeTabId),ge=P(()=>!f(E)),xe=P(()=>{var Oe;return((Oe=f(m))==null?void 0:Oe.id)===f(I).id?f(m).side:null});$U(C,{get tab(){return f(I)},get isActive(){return f(W)},get onswitch(){return e.onTabSwitch},onclose:c,get draggable(){return f(ge)},ondragstart:y,ondragover:w,ondrop:_,ondragend:S,ondragleave:A,get dropIndicator(){return f(xe)},onkeydown:U})}}),yt(V,C=>b(d,C),()=>f(d));var ee=k(V,2);yt(ee,C=>b(a,C),()=>f(a));var se=k(ee,2);{var F=C=>{var I=t5();L("click",I,R),T(C,I)};Z(se,C=>{f(h)&&C(F)})}var X=k(se,2);{var B=C=>{ZU(C,{get recentFiles(){return f(s)},get anchorEl(){return f(a)},onOpen:async I=>{b(o,!1);try{const W=await fetch(`${Sr}/open`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filePath:I})});if(W.ok)dv(lv(W0(),I));else{const ge=await W.text();console.warn("[tandem] failed to open recent file:",ge)}}catch(W){console.warn("[tandem] failed to open recent file:",W)}},onNewScratchpad:()=>{b(o,!1),Um()},onBrowse:()=>{b(o,!1),b(i,!0)},onClose:()=>b(o,!1)})};Z(X,C=>{f(o)&&C(B)})}var j=k(X,2);{var ae=C=>{qU(C,{onClose:()=>b(i,!1)})};Z(j,C=>{f(i)&&C(ae)})}L("click",ee,()=>{b(s,W0(),!0),b(o,!f(o))}),vt("mouseenter",ee,C=>{C.currentTarget.style.color="var(--tandem-accent)",C.currentTarget.style.borderColor="var(--tandem-accent)"}),vt("mouseleave",ee,C=>{C.currentTarget.style.color="var(--tandem-fg-muted)",C.currentTarget.style.borderColor="var(--tandem-border-strong)"}),T(n,q),Ke()}Ye(["click"]);var i5=O('<div role="slider" aria-orientation="horizontal" tabindex="0" style="width: 4px; cursor: col-resize; background: transparent; flex-shrink: 0; transition: background 0.15s; position: relative; z-index: var(--tandem-z-base);"></div>'),o5=O("<div><!></div>"),s5=O('<div class="editor-scroll" role="region" aria-label="Document editor"><!> <!> <!></div>'),a5=O('<span style="position: absolute; top: 2px; right: 2px; background: var(--tandem-error); color: var(--tandem-error-fg); font-size: 9px; width: 16px; height: 16px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700;"> </span>'),l5=O('<button data-testid="annotations-tab"><!> <!></button>'),c5=O('<button data-testid="chat-tab"><!></button>'),d5=O('<button data-testid="outline-tab"><!></button>'),u5=O('<div><div style="display: flex; border-bottom: 1px solid var(--tandem-border); background: var(--tandem-surface-muted); min-height: 38px; align-items: stretch; padding: 0 var(--tandem-space-2); gap: 2px;"><!> <!> <!> <div style="display: flex; align-items: center; margin-left: auto; padding-right: var(--tandem-space-1);"><!></div></div> <!> <!> <!></div>'),f5=O('<div style="display: flex; flex: 1; align-items: center; justify-content: center; color: var(--tandem-fg-subtle);">Connecting...</div>'),h5=O('<div style="padding: var(--tandem-space-2) var(--tandem-space-4); background: var(--tandem-warning-bg); border-bottom: 1px solid var(--tandem-warning-border); font-size: 13px; color: var(--tandem-warning-fg-strong); text-align: center;">Server restarted — refreshing documents</div>'),p5=O('<button data-testid="left-annotations-tab"> </button>'),m5=O('<button data-testid="left-chat-tab"> </button>'),g5=O('<button data-testid="left-outline-tab"> </button>'),v5=O('<div><div style="display: flex; border-bottom: 1px solid var(--tandem-border); background: var(--tandem-surface-muted); min-height: 38px; align-items: stretch; padding: 0 var(--tandem-space-2); gap: 2px;"><!> <!> <!> <div style="display: flex; align-items: center; margin-left: auto; padding-right: var(--tandem-space-1);"><!></div></div> <div style="display: flex; flex-direction: column; flex: 1; min-height: 0;"><!> <!> <!></div></div> <!>',1),y5=O("<!> <!>",1),b5=O('<!> <!> <!> <!> <!> <div style="display: flex; flex: 1; overflow: hidden; background: var(--tandem-bg);"><!> <!> <!></div> <!> <!> <!> <!> <!> <!> <!>',1),w5=O('<div style="display: flex; flex-direction: column; height: 100vh; background: var(--tandem-bg); color: var(--tandem-fg);"><!> <!></div>');function x5(n,e){We(e,!0);const t=(oe,M=Ci,$=Ci,le=Ci,de=Ci)=>{var Ee=i5();Q(Ee,"aria-valuemin",0),Q(Ee,"aria-valuemax",100),G(ce=>{Q(Ee,"data-testid",le()??`${M()}-panel-resize-handle`),Q(Ee,"aria-label",M()==="left"?"Resize left panel":"Resize right panel"),Q(Ee,"aria-valuenow",ce)},[()=>de()!==void 0?Math.round((de()-oa)/(lc-oa)*100):50]),L("mousedown",Ee,function(...ce){var ve;(ve=$())==null||ve.apply(this,ce)}),L("keydown",Ee,ce=>{let pe=null;ce.key==="ArrowRight"||ce.key==="ArrowUp"?pe=16:ce.key==="ArrowLeft"||ce.key==="ArrowDown"?pe=-16:ce.key==="PageUp"?pe=80:ce.key==="PageDown"?pe=-80:ce.key==="Home"?pe=oa-(M()==="left"?F.width:X.width):ce.key==="End"&&(pe=lc-(M()==="left"?F.width:X.width)),pe!==null&&(ce.preventDefault(),ce.stopPropagation(),M()==="left"?F.handleResizeStep(pe):X.handleResizeStep(pe))}),L("keyup",Ee,()=>{}),vt("mouseenter",Ee,ce=>{ce.currentTarget.style.background="var(--tandem-border-strong)"}),vt("mouseleave",Ee,ce=>{ce.currentTarget.style.background="transparent"}),T(oe,Ee)},r=oe=>{var M=s5();{const ve=ke=>{QV(ke,{get ydoc(){return f(J).ydoc},get provider(){return f(J).provider},get readOnly(){return o.readOnly},get currentFilePath(){return f(J).filePath},get activeAnnotationId(){return f(U)},onEditorReady:pe=>b(E,pe,!0),onAnnotationClick:pe=>{b(_,"annotations"),b(U,pe,!0)},onSlashCommandMenuChange:pe=>b(q,pe,!0)})};var $=x(M);{let ke=P(()=>{var ze,tt;return((ze=f(J))==null?void 0:ze.readOnly)===!0&&((tt=f(J))==null?void 0:tt.format)==="docx"}),pe=P(()=>{var ze;return(ze=f(J))==null?void 0:ze.id});rN($,{get visible(){return f(ke)},get documentId(){return f(pe)}})}var le=k($,2);{var de=ke=>{YN(ke,{children:(pe,ze)=>{var tt=Tt(),Ce=Le(tt);rp(Ce,()=>f(J).id,Ne=>{ve(Ne)}),T(pe,tt)}})},Ee=ke=>{var pe=o5(),ze=x(pe);{var tt=Ne=>{var mt=Tt(),Yt=Le(mt);rp(Yt,()=>f(J).id,Mn=>{ve(Mn)}),T(Ne,mt)},Ce=Ne=>{WE(Ne,{get connected(){return o.connected},get claudeActive(){return o.claudeActive}})};Z(ze,Ne=>{f(J)?Ne(tt):Ne(Ce,-1)})}G(()=>re(pe,`max-width: ${f(ge)??"68ch"}; margin: ${f(xe)??"0 auto"};`)),T(ke,pe)};Z(le,ke=>{var pe;((pe=f(J))==null?void 0:pe.format)==="docx"?ke(de):ke(Ee,-1)})}var ce=k(le,2);lH(ce,{get editor(){return f(E)},get open(){return f(te)},onClose:()=>b(te,!1),get tabs(){return o.tabs}})}G(()=>re(M,`position: relative; flex: 1; overflow: auto; padding: var(--tandem-space-7) var(--tandem-space-5); border: ${p.fileDragOver?"2px dashed var(--tandem-accent)":"2px solid transparent"}; background: ${p.fileDragOver?"var(--tandem-accent-bg)":"var(--tandem-bg)"}; transition: border-color 0.15s, background 0.15s; border-radius: ${p.fileDragOver?"var(--tandem-r-5)":"0"};`)),vt("dragover",M,function(...ve){var ke;(ke=p.handleEditorDragOver)==null||ke.apply(this,ve)}),vt("dragleave",M,function(...ve){var ke;(ke=p.handleEditorDragLeave)==null||ke.apply(this,ve)}),vt("drop",M,function(...ve){var ke;(ke=p.handleEditorDrop)==null||ke.apply(this,ve)}),T(oe,M)},i=(oe,M=Ci,$=Ci)=>{const le=P(()=>a.settings.rightRailTabs),de=P(()=>f(le).length>3);var Ee=u5(),ce=x(Ee),ve=x(ce);{var ke=ht=>{var rt=l5(),Ve=x(rt);{var dt=bn=>{var ir=Nn("◨");T(bn,ir)},qe=bn=>{var ir=Nn("Annotations");T(bn,ir)};Z(Ve,bn=>{f(de)?bn(dt):bn(qe,-1)})}var Ot=k(Ve,2);{var en=bn=>{var ir=a5(),Ns=x(ir);G(()=>ne(Ns,f(A)>9?"9+":f(A))),T(bn,ir)};Z(Ot,bn=>{f(_)!=="annotations"&&f(A)>0&&bn(en)})}G(()=>{re(rt,`flex: 1; padding: 0 var(--tandem-space-2); font-size: 12px; font-weight: 500; border: none; border-bottom: ${f(_)==="annotations"?"2px solid var(--tandem-accent)":"2px solid transparent"}; background: transparent; cursor: pointer; color: ${f(_)==="annotations"?"var(--tandem-fg)":"var(--tandem-fg-subtle)"}; position: relative; white-space: nowrap;`),Q(rt,"title",f(de)?"Annotations":void 0)}),L("click",rt,()=>{b(_,"annotations")}),T(ht,rt)},pe=P(()=>f(le).includes("annotations"));Z(ve,ht=>{f(pe)&&ht(ke)})}var ze=k(ve,2);{var tt=ht=>{var rt=c5(),Ve=x(rt);{var dt=Ot=>{var en=Nn("💬");T(Ot,en)},qe=Ot=>{var en=Nn("Chat");T(Ot,en)};Z(Ve,Ot=>{f(de)?Ot(dt):Ot(qe,-1)})}G(()=>{re(rt,`flex: 1; padding: 0 var(--tandem-space-2); font-size: 12px; font-weight: 500; border: none; border-bottom: ${f(_)==="chat"?"2px solid var(--tandem-accent)":"2px solid transparent"}; background: transparent; cursor: pointer; color: ${f(_)==="chat"?"var(--tandem-fg)":"var(--tandem-fg-subtle)"}; white-space: nowrap;`),Q(rt,"title",f(de)?"Chat":void 0)}),L("mousedown",rt,Oe),L("click",rt,()=>{b(_,"chat")}),T(ht,rt)},Ce=P(()=>f(le).includes("chat"));Z(ze,ht=>{f(Ce)&&ht(tt)})}var Ne=k(ze,2);{var mt=ht=>{var rt=d5(),Ve=x(rt);{var dt=Ot=>{var en=Nn("≡");T(Ot,en)},qe=Ot=>{var en=Nn("Outline");T(Ot,en)};Z(Ve,Ot=>{f(de)?Ot(dt):Ot(qe,-1)})}G(()=>{re(rt,`flex: 1; padding: 0 var(--tandem-space-2); font-size: 12px; font-weight: 500; border: none; border-bottom: ${f(_)==="outline"?"2px solid var(--tandem-accent)":"2px solid transparent"}; background: transparent; cursor: pointer; color: ${f(_)==="outline"?"var(--tandem-fg)":"var(--tandem-fg-subtle)"}; white-space: nowrap;`),Q(rt,"title",f(de)?"Outline":void 0)}),L("click",rt,()=>{b(_,"outline")}),T(ht,rt)},Yt=P(()=>f(le).includes("outline"));Z(Ne,ht=>{f(Yt)&&ht(mt)})}var Mn=k(Ne,2),rr=x(Mn);{let ht=P(()=>a.settings.leftRailTabs.length===1?a.settings.leftRailTabs:[]);j0(rr,{get enabledTabs(){return a.settings.rightRailTabs},get disabledTabs(){return f(ht)},onTabsChange:rt=>{I("right",rt)}})}var gt=k(ce,2);{let ht=P(()=>f(_)==="chat"&&f(le).includes("chat"));Ps(gt,{kind:"chat",get ctrlYdoc(){return o.bootstrapYdoc},get editor(){return f(E)},get activeDocId(){return o.activeTabId},get openDocs(){return f(u)},get claudeActive(){return o.claudeActive},get claudeStatus(){return o.claudeStatus},get capturedAnchor(){return f(R)},onCapturedAnchorChange:rt=>b(R,rt,!0),get reduceMotion(){return a.settings.reduceMotion},get visible(){return f(ht)}})}var nt=k(gt,2);{let ht=P(()=>{var qe;return((qe=f(J))==null?void 0:qe.ydoc)??null}),rt=P(()=>{var qe;return(qe=f(J))==null?void 0:qe.format}),Ve=P(()=>{var qe;return(qe=f(J))==null?void 0:qe.id}),dt=P(()=>f(_)==="annotations"&&f(le).includes("annotations"));Ps(nt,{kind:"side",get annotations(){return f(c).visibleAnnotations},get editor(){return f(E)},get ydoc(){return f(ht)},get heldCount(){return f(c).heldCount},get tandemMode(){return l.tandemMode},get onModeChange(){return l.setTandemMode},get activeDocFormat(){return f(rt)},get documentId(){return f(Ve)},get activeAnnotationId(){return f(U)},onActiveAnnotationChange:qe=>b(U,qe,!0),get reduceMotion(){return a.settings.reduceMotion},get storeReadOnly(){return o.storeReadOnly},onFilterChange:(qe,Ot,en)=>{b(V,{type:qe,author:Ot,status:en},!0)},get visible(){return f(dt)}})}var Mt=k(nt,2);{var cn=ht=>{{let rt=P(()=>f(_)==="outline");Ps(ht,{kind:"outline",get editor(){return f(E)},get annotations(){return f(c).visibleAnnotations},get focusTrigger(){return f(K)},get activeFilterType(){return f(V).type},get visible(){return f(rt)}})}},On=P(()=>f(le).includes("outline"));Z(Mt,ht=>{f(On)&&ht(cn)})}G(()=>re(Ee,`display: flex; flex-direction: column; width: ${M()}px; ${$()==="left"?"border-right":"border-left"}: 1px solid var(--tandem-border); background: var(--tandem-surface-muted);`)),T(oe,Ee)},o=oU();pi(()=>o.destroy());const s=jH(()=>o.tabs);VH(()=>s.orderedTabs,()=>o.activeTabId,oe=>o.setActiveTabId(oe)),he(()=>{const oe=o.tabs;if(oe.length!==0)try{const M=cv();let $=M;for(const le of oe)CT(le.filePath)||($=lv($,le.filePath));($.length!==M.length||$.some((le,de)=>le!==M[de]))&&dv($)}catch(M){console.warn("[tandem] failed to sync recent files:",M)}});const a=GH(),l=WH(()=>o.bootstrapYdoc,()=>a.settings.selectionDwellMs),c=P(()=>{const oe=o.annotations,M=l.tandemMode,$=[];let le=0;for(const de of oe)LH(de,M)?$.push(de):de.status==="pending"&&le++;return{visibleAnnotations:$,heldCount:le}}),d=TH(()=>o.disconnectedSince,()=>a.settings.degradedBannerDelayMs);rU();const u=P(()=>o.tabs.map(oe=>({id:oe.id,fileName:oe.fileName}))),h=zH(),p=NH();let m=z(!1),v=z(null),g=z(!1);function y(){b(m,!f(m))}vA({getActiveTabId:()=>o.activeTabId,openSettings:()=>b(m,!0),toggleSoloMode:()=>l.setTandemMode(l.tandemMode==="solo"?"tandem":"solo"),openFindBar:()=>{}});let w;he(()=>{const oe=f(E);if(!oe)return;const M=a.settings.showAuthorship;if(w===M)return;w=M;const $=oe.state.tr.setMeta(js,{type:"toggle",visible:M});oe.view.dispatch($)}),he(()=>(document.body.classList.toggle("tandem-reduce-motion",a.settings.reduceMotion),()=>document.body.classList.remove("tandem-reduce-motion"))),eU(()=>a.settings.theme),_H(()=>a.settings.accentHue),RH(()=>a.settings.editorFont),EH(()=>a.settings.density),PH(()=>a.settings.highContrast),CH(()=>a.settings.annotationPatterns),he(()=>{const oe=KH[a.settings.textSize];return document.documentElement.style.setProperty("--tandem-editor-font-size",`${oe}px`),()=>document.documentElement.style.removeProperty("--tandem-editor-font-size")});let _=z(at(a.settings.primaryTab==="chat"?"chat":"annotations")),S=z(at(a.settings.leftRailTabs[0]??"annotations"));he(()=>{a.settings.leftRailTabs.includes(f(S))||b(S,a.settings.leftRailTabs[0]??"annotations",!0)}),he(()=>{a.settings.rightRailTabs.includes(f(_))||b(_,a.settings.rightRailTabs[0]??"chat",!0)});const A=P(()=>f(_)==="annotations"?0:f(c).visibleAnnotations.filter(Pd).length);let U=z(null),N=z(!1),R=z(null),E=z(null),q=z(!1),te=z(!1),K=z(0),V=z(at({type:"all",author:"all",status:"all"}));const ee=P0("left"),se=P0("right"),F=L0({side:"left",initialWidth:ee,getVisible:()=>f(B)}),X=L0({side:"right",initialWidth:se,getVisible:()=>f(j)}),B=P(()=>a.settings.leftPanelVisible),j=P(()=>a.settings.rightPanelVisible&&!(l.tandemMode==="solo"&&a.settings.soloRailHidden));function ae(){a.updateSettings({leftPanelVisible:!a.settings.leftPanelVisible})}function C(){f(j)?a.updateSettings({rightPanelVisible:!1}):a.updateSettings({rightPanelVisible:!0,...l.tandemMode==="solo"?{soloRailHidden:!1}:{}})}function I(oe,M){const $=a.settings.leftRailTabs,le=a.settings.rightRailTabs,de=oe==="left"?$:le,Ee=oe==="left"?le:$,ce=M.filter(ke=>!de.includes(ke));if(ce.length===0)return a.updateSettings(oe==="left"?{leftRailTabs:M}:{rightRailTabs:M}),!0;const ve=Ee.filter(ke=>!ce.includes(ke));return ve.length===0?(console.warn("[tandem] cross-rail tab move blocked — would leave the %s rail empty",oe==="left"?"right":"left"),!1):(a.updateSettings(oe==="left"?{leftRailTabs:M,rightRailTabs:ve}:{rightRailTabs:M,leftRailTabs:ve}),!0)}function W(oe,M,$){b(V,{type:oe,author:M,status:$},!0)}const ge=P(()=>a.settings.editorWidthPercent<100?`${a.settings.editorWidthPercent}%`:void 0),xe=P(()=>a.settings.editorWidthPercent<100?"0 auto":void 0);function Oe(){if(f(_)==="chat"||!f(E))return;const{from:oe,to:M}=f(E).state.selection;if(oe===M)return;const $=yk(f(E).state.doc,{from:mn(oe),to:mn(M)}),le=f(E).state.doc.textBetween(oe,M,`
|
|
310
|
-
`);b(R,{...$,textSnapshot:le.length>200?le.slice(0,197)+"...":le},!0)}he(()=>{function oe(M){var $,le;if(M.key==="?"){const de=M.target;if(de.tagName==="INPUT"||de.tagName==="TEXTAREA"||de.isContentEditable)return;b(N,Ut(()=>!f(N)),!0);return}if(M.ctrlKey||M.metaKey){if(M.key==="a"){const de=document.activeElement;if(de instanceof HTMLInputElement||de instanceof HTMLTextAreaElement||($=de==null?void 0:de.closest)!=null&&$.call(de,".ProseMirror"))return;M.preventDefault(),(le=f(E))==null||le.commands.selectAll()}else if(M.key==="s")M.preventDefault(),sx(o.activeTabId);else if(BH(M))M.preventDefault(),b(m,!0);else if(M.shiftKey&&M.key==="P")M.preventDefault(),b(g,!Ut(()=>f(g)));else if(M.key==="n"){const de=M.target;if(de.tagName==="INPUT"||de.tagName==="TEXTAREA")return;M.preventDefault(),Um()}else if(M.key==="/"){const de=M.target;if(de.tagName==="INPUT"||de.tagName==="TEXTAREA"||de.isContentEditable)return;M.preventDefault(),b(N,Ut(()=>!f(N)),!0)}}(M.ctrlKey||M.metaKey)&&M.key==="f"&&(M.preventDefault(),f(B)&&f(S)==="outline"||f(j)&&f(_)==="outline"?b(K,f(K)+1):b(te,!0))}return window.addEventListener("keydown",oe),()=>window.removeEventListener("keydown",oe)});const J=P(()=>o.tabs.find(oe=>oe.id===o.activeTabId)),fe=HH(()=>f(J)),D=P(()=>fe.dirty),Y=nU(()=>f(c).visibleAnnotations,()=>f(E),()=>{var oe;return(oe=f(J))==null?void 0:oe.fileName});var be=w5(),we=x(be);{let oe=P(()=>{var M;return(M=f(J))==null?void 0:M.fileName});DU(we,{get title(){return f(oe)},get dirty(){return f(D)}})}var Te=k(we,2);{var Se=oe=>{var M=f5();T(oe,M)},De=oe=>{var M=b5(),$=Le(M);{var le=Ve=>{var dt=h5();T(Ve,dt)};Z($,Ve=>{o.serverRestarted&&Ve(le)})}var de=k($,2);{var Ee=Ve=>{TE(Ve,{get onDismiss(){return d.dismiss},onRetry:()=>{o.reconnect()}})};Z(de,Ve=>{d.showBanner&&Ve(Ee)})}var ce=k(de,2);{let Ve=P(()=>{var qe;return((qe=f(J))==null?void 0:qe.ydoc)??null}),dt=P(()=>f(q)||f(te)||f(g));xH(ce,{get editor(){return f(E)},get ydoc(){return f(Ve)},onSettingsOpen:y,get tandemMode(){return l.tandemMode},get onModeChange(){return l.setTandemMode},get showAuthorship(){return a.settings.showAuthorship},onAuthorshipChange:qe=>a.updateSettings({showAuthorship:qe}),get selectionToolbar(){return a.settings.selectionToolbar},get suppressSelectionToolbar(){return f(dt)},get settingsBtn(){return f(v)},set settingsBtn(qe){b(v,qe,!0)}})}var ve=k(ce,2);r5(ve,{get tabs(){return s.orderedTabs},get activeTabId(){return o.activeTabId},get onTabSwitch(){return o.setActiveTabId},get onTabClose(){return o.handleTabClose},get reorder(){return s.reorder},get reduceMotion(){return a.settings.reduceMotion}});var ke=k(ve,2);{let Ve=P(()=>{var dt;return((dt=f(J))==null?void 0:dt.ydoc)??null});TU(ke,{get editor(){return f(E)},get ydoc(){return f(Ve)},get leftPanelVisible(){return f(B)},onToggleLeftPanel:ae,get rightPanelVisible(){return f(j)},onToggleRightPanel:C})}var pe=k(ke,2),ze=x(pe);{var tt=Ve=>{const dt=P(()=>a.settings.leftRailTabs),qe=P(()=>f(dt).length>3),Ot=P(()=>a.settings.rightRailTabs.length===1?a.settings.rightRailTabs:[]);var en=v5(),bn=Le(en),ir=x(bn),Ns=x(ir);{var bS=Bt=>{var Ft=p5(),Ro=x(Ft);G(()=>{re(Ft,`flex: 1; padding: 0 var(--tandem-space-2); font-size: 12px; font-weight: 500; border: none; border-bottom: ${f(S)==="annotations"?"2px solid var(--tandem-accent)":"2px solid transparent"}; background: transparent; cursor: pointer; color: ${f(S)==="annotations"?"var(--tandem-fg)":"var(--tandem-fg-subtle)"}; white-space: nowrap;`),Q(Ft,"title",f(qe)?"Annotations":void 0),ne(Ro,f(qe)?"◨":"Annotations")}),L("click",Ft,()=>{b(S,"annotations")}),T(Bt,Ft)},wS=P(()=>f(dt).includes("annotations"));Z(Ns,Bt=>{f(wS)&&Bt(bS)})}var uv=k(Ns,2);{var xS=Bt=>{var Ft=m5(),Ro=x(Ft);G(()=>{re(Ft,`flex: 1; padding: 0 var(--tandem-space-2); font-size: 12px; font-weight: 500; border: none; border-bottom: ${f(S)==="chat"?"2px solid var(--tandem-accent)":"2px solid transparent"}; background: transparent; cursor: pointer; color: ${f(S)==="chat"?"var(--tandem-fg)":"var(--tandem-fg-subtle)"}; white-space: nowrap;`),Q(Ft,"title",f(qe)?"Chat":void 0),ne(Ro,f(qe)?"💬":"Chat")}),L("click",Ft,()=>{b(S,"chat")}),T(Bt,Ft)},kS=P(()=>f(dt).includes("chat"));Z(uv,Bt=>{f(kS)&&Bt(xS)})}var fv=k(uv,2);{var _S=Bt=>{var Ft=g5(),Ro=x(Ft);G(()=>{re(Ft,`flex: 1; padding: 0 var(--tandem-space-2); font-size: 12px; font-weight: 500; border: none; border-bottom: ${f(S)==="outline"?"2px solid var(--tandem-accent)":"2px solid transparent"}; background: transparent; cursor: pointer; color: ${f(S)==="outline"?"var(--tandem-fg)":"var(--tandem-fg-subtle)"}; white-space: nowrap;`),Q(Ft,"title",f(qe)?"Outline":void 0),ne(Ro,f(qe)?"≡":"Outline")}),L("click",Ft,()=>{b(S,"outline")}),T(Bt,Ft)},SS=P(()=>f(dt).includes("outline"));Z(fv,Bt=>{f(SS)&&Bt(_S)})}var CS=k(fv,2),TS=x(CS);j0(TS,{get enabledTabs(){return f(dt)},get disabledTabs(){return f(Ot)},testIdPrefix:"left-",onTabsChange:Bt=>{I("left",Bt)}});var AS=k(ir,2),hv=x(AS);{let Bt=P(()=>f(S)==="chat"&&f(dt).includes("chat"));Ps(hv,{kind:"chat",get ctrlYdoc(){return o.bootstrapYdoc},get editor(){return f(E)},get activeDocId(){return o.activeTabId},get openDocs(){return f(u)},get claudeActive(){return o.claudeActive},get claudeStatus(){return o.claudeStatus},get capturedAnchor(){return f(R)},onCapturedAnchorChange:Ft=>b(R,Ft,!0),get reduceMotion(){return a.settings.reduceMotion},get visible(){return f(Bt)}})}var pv=k(hv,2);{let Bt=P(()=>{var Hr;return((Hr=f(J))==null?void 0:Hr.ydoc)??null}),Ft=P(()=>{var Hr;return(Hr=f(J))==null?void 0:Hr.format}),Ro=P(()=>{var Hr;return(Hr=f(J))==null?void 0:Hr.id}),OS=P(()=>f(S)==="annotations"&&f(dt).includes("annotations"));Ps(pv,{kind:"side",get annotations(){return f(c).visibleAnnotations},get activeFilterType(){return f(V).type},get activeFilterAuthor(){return f(V).author},get activeFilterStatus(){return f(V).status},onFilterChange:W,get editor(){return f(E)},get ydoc(){return f(Bt)},get heldCount(){return f(c).heldCount},get tandemMode(){return l.tandemMode},get onModeChange(){return l.setTandemMode},get activeDocFormat(){return f(Ft)},get documentId(){return f(Ro)},get activeAnnotationId(){return f(U)},onActiveAnnotationChange:Hr=>b(U,Hr,!0),get reduceMotion(){return a.settings.reduceMotion},get storeReadOnly(){return o.storeReadOnly},get visible(){return f(OS)}})}var ES=k(pv,2);{let Bt=P(()=>f(S)==="outline"&&f(dt).includes("outline"));Ps(ES,{kind:"outline",get focusTrigger(){return f(K)},get editor(){return f(E)},get visible(){return f(Bt)}})}var MS=k(bn,2);t(MS,()=>"left",()=>Bt=>F.handleResizeStart(Bt),()=>{},()=>F.width),G(()=>re(bn,`display: flex; flex-direction: column; width: ${F.width}px; border-right: 1px solid var(--tandem-border); background: var(--tandem-surface-muted);`)),T(Ve,en)};Z(ze,Ve=>{f(B)&&Ve(tt)})}var Ce=k(ze,2);r(Ce);var Ne=k(Ce,2);{var mt=Ve=>{var dt=y5(),qe=Le(dt);t(qe,()=>"right",()=>en=>X.handleResizeStart(en),()=>"panel-resize-handle",()=>X.width);var Ot=k(qe,2);i(Ot,()=>X.width,()=>"right"),T(Ve,dt)};Z(Ne,Ve=>{f(j)&&Ve(mt)})}var Yt=k(pe,2);zU(Yt,{get connected(){return o.connected},get connectionStatus(){return o.connectionStatus},get reconnectAttempts(){return o.reconnectAttempts},get disconnectedSince(){return o.disconnectedSince},get claudeStatus(){return o.claudeStatus},get claudeActive(){return o.claudeActive},get readOnly(){return o.readOnly},get documentCount(){return o.tabs.length},get saving(){return yA.saving},get heldCount(){return f(c).heldCount},get mode(){return l.tandemMode},onShowHeld:()=>l.setTandemMode("tandem")});var Mn=k(Yt,2);UN(Mn,{get open(){return f(m)},onClose:()=>b(m,!1),get settings(){return a.settings},get onUpdate(){return a.updateSettings},get returnFocusEl(){return f(v)},get anchorEl(){return f(v)},get connected(){return o.connected},get reconnectAttempts(){return o.reconnectAttempts}});var rr=k(Mn,2);GE(rr,{get open(){return f(N)},onClose:()=>b(N,!1)});var gt=k(rr,2);SE(gt,{get open(){return f(g)},onClose:()=>b(g,!1),get editor(){return f(E)},get annotations(){return f(c).visibleAnnotations},onFocusAnnotation:Ve=>{b(U,Ve,!0)}});var nt=k(gt,2);qN(nt,{get toasts(){return h.toasts},get onDismiss(){return h.dismiss}});var Mt=k(nt,2);{var cn=Ve=>{FE(Ve,{})},On=P(()=>Cr());Z(Mt,Ve=>{f(On)&&Ve(cn)})}var ht=k(Mt,2);{var rt=Ve=>{cM(Ve,{get currentStep(){return Y.currentStep},get onNext(){return Y.nextStep},get onDismiss(){return Y.dismissTutorial},get coworkStatus(){return Y.coworkStatus}})};Z(ht,Ve=>{Y.tutorialActive&&Ve(rt)})}T(oe,M)};Z(Te,oe=>{o.ready?oe(De,-1):oe(Se)})}T(n,be),Ke()}Ye(["mousedown","keydown","keyup","click"]);const K0=3,k5="error-boundary-recover-btn",_5="error-boundary-reload-btn";function S5(n,e){We(e,!0),he(()=>{e.onSuccess()}),Ke()}var C5=O('<button class="btn btn-primary svelte-1bcl6yi">Try to recover</button>'),T5=O('<div role="alert" class="error-boundary svelte-1bcl6yi"><h2 class="svelte-1bcl6yi">Something went wrong</h2> <p class="message svelte-1bcl6yi"> </p> <pre class="detail svelte-1bcl6yi"> </pre> <!> <button class="btn btn-secondary svelte-1bcl6yi">Reload</button></div>'),A5=O("<!> <!>",1);function E5(n,e){let t=z(0),r=z(0);var i=Tt(),o=Le(i);pw(o,{onerror:()=>{b(r,f(r)+1)},failed:(a,l=Ci,c=Ci)=>{var d=Tt(),u=Le(d);rp(u,()=>f(r),h=>{var p=T5(),m=k(x(p),2),v=x(m),g=k(m,2),y=x(g),w=k(g,2);{var _=A=>{var U=C5();G(()=>Q(U,"data-testid",k5)),L("click",U,()=>{b(t,f(t)+1),c()()}),T(A,U)};Z(w,A=>{f(t)<K0&&A(_)})}var S=k(w,2);G(A=>{ne(v,f(t)>=K0?"Recovery attempts exhausted. Reload the page to continue.":"The editor encountered an unexpected error."),ne(y,A),Q(S,"data-testid",_5)},[()=>l()instanceof Error?l().message:String(l())]),L("click",S,()=>window.location.reload()),T(h,p)}),T(a,d)}},a=>{var l=A5(),c=Le(l);Lm(c,()=>e.children);var d=k(c,2);S5(d,{onSuccess:()=>{b(t,0)}}),T(a,l)}),T(n,i)}Ye(["click"]);function M5(n){E5(n,{children:(e,t)=>{x5(e,{})}})}nT(M5,{target:document.getElementById("root")});export{Q as A,B5 as B,R5 as C,L5 as D,Ye as E,H5 as F,z5 as G,k as a,T as b,qx as c,Ke as d,z as e,P5 as f,f as g,x as h,Z as i,Le as j,fs as k,ne as l,F5 as m,L as n,pi as o,We as p,b as q,O as r,re as s,G as t,P as u,Ym as v,Hx as w,Kx as x,V5 as y,ft as z};
|