tandem-editor 0.13.0 → 0.13.6

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.
@@ -0,0 +1,240 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-Dm_QtxGQ.js","assets/core-DhEqZVGG.js","assets/event-CNdo2oXa.js","assets/CoworkSettings-L5Hw-XtT.js","assets/CoworkSettings-C-1BnhBH.css","assets/webview-KiZyy_pC.js","assets/window-DePn7tLG.js"])))=>i.map(i=>d[i]);
2
+ var m4=Object.defineProperty;var vy=t=>{throw TypeError(t)};var g4=(t,e,n)=>e in t?m4(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var In=(t,e,n)=>g4(t,typeof e!="symbol"?e+"":e,n),Fm=(t,e,n)=>e.has(t)||vy("Cannot "+n);var re=(t,e,n)=>(Fm(t,e,"read from private field"),n?n.call(t):e.get(t)),ft=(t,e,n)=>e.has(t)?vy("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n),pt=(t,e,n,r)=>(Fm(t,e,"write to private field"),r?r.call(t,n):e.set(t,n),n),Nt=(t,e,n)=>(Fm(t,e,"access private method"),n);(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 n(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=n(i);fetch(i.href,o)}})();const H2=!1;var ab=Array.isArray,v4=Array.prototype.indexOf,Nl=Array.prototype.includes,Pp=Array.from,b4=Object.defineProperty,ws=Object.getOwnPropertyDescriptor,V2=Object.getOwnPropertyDescriptors,y4=Object.prototype,w4=Array.prototype,lb=Object.getPrototypeOf,by=Object.isExtensible;function Qa(t){return typeof t=="function"}const Tn=()=>{};function x4(t){return typeof(t==null?void 0:t.then)=="function"}function k4(t){for(var e=0;e<t.length;e++)t[e]()}function U2(){var t,e,n=new Promise((r,i)=>{t=r,e=i});return{promise:n,resolve:t,reject:e}}function jd(t,e){if(Array.isArray(t))return t;if(e===void 0||!(Symbol.iterator in t))return Array.from(t);const n=[];for(const r of t)if(n.push(r),n.length===e)break;return n}const $n=2,Pl=4,Lp=8,j2=1<<24,li=16,Ai=32,Fo=64,f0=128,ci=512,Dn=1024,zn=2048,no=4096,pr=8192,ui=16384,Fs=32768,h0=1<<25,zo=65536,oh=1<<17,_4=1<<18,Ba=1<<19,C4=1<<20,Zi=1<<25,_a=65536,sh=1<<21,dl=1<<22,xs=1<<23,Qi=Symbol("$state"),q2=Symbol("legacy props"),S4=Symbol(""),Mf=Symbol("attributes"),p0=Symbol("class"),m0=Symbol("style"),Lc=Symbol("text"),Df=Symbol("form reset"),Fp=new class extends Error{constructor(){super(...arguments);In(this,"name","StaleReactionError");In(this,"message","The reaction that called `getAbortSignal()` was re-run or destroyed")}};var F2;const E4=!!((F2=globalThis.document)!=null&&F2.contentType)&&globalThis.document.contentType.includes("xml");function W2(t){throw new Error("https://svelte.dev/e/lifecycle_outside_component")}function A4(){throw new Error("https://svelte.dev/e/async_derived_orphan")}function T4(t,e,n){throw new Error("https://svelte.dev/e/each_key_duplicate")}function M4(t){throw new Error("https://svelte.dev/e/effect_in_teardown")}function D4(){throw new Error("https://svelte.dev/e/effect_in_unowned_derived")}function O4(t){throw new Error("https://svelte.dev/e/effect_orphan")}function I4(){throw new Error("https://svelte.dev/e/effect_update_depth_exceeded")}function R4(t){throw new Error("https://svelte.dev/e/props_invalid_value")}function N4(){throw new Error("https://svelte.dev/e/state_descriptors_fixed")}function P4(){throw new Error("https://svelte.dev/e/state_prototype_fixed")}function L4(){throw new Error("https://svelte.dev/e/state_unsafe_mutation")}function F4(){throw new Error("https://svelte.dev/e/svelte_boundary_reset_onerror")}const z4=1,B4=2,K2=4,H4=8,V4=16,U4=1,j4=2,q4=4,W4=8,K4=16,G4=1,Z4=2,Y4=4,G2=1,J4=2,En=Symbol(),Z2="http://www.w3.org/1999/xhtml",X4="http://www.w3.org/2000/svg",Q4="http://www.w3.org/1998/Math/MathML";function $4(){console.warn("https://svelte.dev/e/derived_inert")}function e6(){console.warn("https://svelte.dev/e/select_multiple_invalid_value")}function t6(){console.warn("https://svelte.dev/e/svelte_boundary_reset_noop")}function Y2(t){return t===this.v}function J2(t,e){return t!=t?e==e:t!==e||t!==null&&typeof t=="object"||typeof t=="function"}function X2(t){return!J2(t,this.v)}let ac=!1,n6=!1;function r6(){ac=!0}let mn=null;function Ll(t){mn=t}function We(t,e=!1,n){mn={p:mn,i:!1,c:null,e:null,s:t,x:null,r:Ct,l:ac&&!e?{s:null,u:null,$:[]}:null}}function Ke(t){var e=mn,n=e.e;if(n!==null){e.e=null;for(var r of n)w_(r)}return t!==void 0&&(e.x=t),e.i=!0,mn=e.p,t??{}}function Ha(){return!ac||mn!==null&&mn.l===null}let Qs=[];function Q2(){var t=Qs;Qs=[],k4(t)}function Ei(t){if(Qs.length===0&&!fl){var e=Qs;queueMicrotask(()=>{e===Qs&&Q2()})}Qs.push(t)}function i6(){for(;Qs.length>0;)Q2()}function $2(t){var e=Ct;if(e===null)return Rt.f|=xs,t;if((e.f&Fs)===0&&(e.f&Pl)===0)throw t;ps(t,e)}function ps(t,e){for(;e!==null;){if((e.f&f0)!==0){if((e.f&Fs)===0)throw t;try{e.b.error(t);return}catch(n){t=n}}e=e.parent}throw t}const o6=-7169;function fn(t,e){t.f=t.f&o6|e}function cb(t){(t.f&ci)!==0||t.deps===null?fn(t,Dn):fn(t,no)}function e_(t){if(t!==null)for(const e of t)(e.f&$n)===0||(e.f&_a)===0||(e.f^=_a,e_(e.deps))}function t_(t,e,n){(t.f&zn)!==0?e.add(t):(t.f&no)!==0&&n.add(t),e_(t.deps),fn(t,Dn)}let qd=!1;function s6(t){var e=qd;try{return qd=!1,[t(),qd]}finally{qd=e}}let zm=null,Ka=null,st=null,Gc=null,Zn=null,g0=null,fl=!1,Bm=!1,al=null,Of=null;var yy=0;let a6=1;var El,us,aa,Al,Tl,la,Ml,So,ad,zr,ld,ds,Wi,Ki,Dl,Ol,Vt,v0,Fc,b0,n_,r_,If,l6,y0,$a;const Mp=class Mp{constructor(){ft(this,Vt);In(this,"id",a6++);ft(this,El,!1);In(this,"linked",!0);ft(this,us,null);ft(this,aa,null);In(this,"async_deriveds",new Map);In(this,"current",new Map);In(this,"previous",new Map);In(this,"unblocked",new Set);ft(this,Al,new Set);ft(this,Tl,new Set);ft(this,la,new Set);ft(this,Ml,0);ft(this,So,new Map);ft(this,ad,null);ft(this,zr,[]);ft(this,ld,[]);ft(this,ds,new Set);ft(this,Wi,new Set);ft(this,Ki,new Map);ft(this,Dl,new Set);In(this,"is_fork",!1);ft(this,Ol,!1)}skip_effect(e){re(this,Ki).has(e)||re(this,Ki).set(e,{d:[],m:[]}),re(this,Dl).delete(e)}unskip_effect(e,n=r=>this.schedule(r)){var r=re(this,Ki).get(e);if(r){re(this,Ki).delete(e);for(var i of r.d)fn(i,zn),n(i);for(i of r.m)fn(i,no),n(i)}re(this,Dl).add(e)}capture(e,n,r=!1){e.v!==En&&!this.previous.has(e)&&this.previous.set(e,e.v),(e.f&xs)===0&&(this.current.set(e,[n,r]),Zn==null||Zn.set(e,n)),this.is_fork||(e.v=n)}activate(){st=this}deactivate(){st=null,Zn=null}flush(){try{Bm=!0,st=this,Nt(this,Vt,Fc).call(this)}finally{yy=0,g0=null,al=null,Of=null,Bm=!1,st=null,Zn=null,fa.clear()}}discard(){for(const e of re(this,Tl))e(this);re(this,Tl).clear(),re(this,la).clear(),Nt(this,Vt,$a).call(this)}register_created_effect(e){re(this,ld).push(e)}increment(e,n){if(pt(this,Ml,re(this,Ml)+1),e){let r=re(this,So).get(n)??0;re(this,So).set(n,r+1)}}decrement(e,n){if(pt(this,Ml,re(this,Ml)-1),e){let r=re(this,So).get(n)??0;r===1?re(this,So).delete(n):re(this,So).set(n,r-1)}re(this,Ol)||(pt(this,Ol,!0),Ei(()=>{pt(this,Ol,!1),this.linked&&this.flush()}))}transfer_effects(e,n){for(const r of e)re(this,ds).add(r);for(const r of n)re(this,Wi).add(r);e.clear(),n.clear()}oncommit(e){re(this,Al).add(e)}ondiscard(e){re(this,Tl).add(e)}on_fork_commit(e){re(this,la).add(e)}run_fork_commit_callbacks(){for(const e of re(this,la))e(this);re(this,la).clear()}settled(){return(re(this,ad)??pt(this,ad,U2())).promise}static ensure(){var e;if(st===null){const n=st=new Mp;Nt(e=n,Vt,y0).call(e),!Bm&&!fl&&Ei(()=>{re(n,El)||n.flush()})}return st}apply(){{Zn=null;return}}schedule(e){var i;if(g0=e,(i=e.b)!=null&&i.is_pending&&(e.f&(Pl|Lp|j2))!==0&&(e.f&Fs)===0){e.b.defer_effect(e);return}for(var n=e;n.parent!==null;){n=n.parent;var r=n.f;if(al!==null&&n===Ct&&(Rt===null||(Rt.f&$n)===0))return;if((r&(Fo|Ai))!==0){if((r&Dn)===0)return;n.f^=Dn}}re(this,zr).push(n)}};El=new WeakMap,us=new WeakMap,aa=new WeakMap,Al=new WeakMap,Tl=new WeakMap,la=new WeakMap,Ml=new WeakMap,So=new WeakMap,ad=new WeakMap,zr=new WeakMap,ld=new WeakMap,ds=new WeakMap,Wi=new WeakMap,Ki=new WeakMap,Dl=new WeakMap,Ol=new WeakMap,Vt=new WeakSet,v0=function(){if(this.is_fork)return!0;for(const r of re(this,So).keys()){for(var e=r,n=!1;e.parent!==null;){if(re(this,Ki).has(e)){n=!0;break}e=e.parent}if(!n)return!0}return!1},Fc=function(){var l,c,u,f;if(pt(this,El,!0),yy++>1e3&&(Nt(this,Vt,$a).call(this),c6()),!Nt(this,Vt,v0).call(this)){for(const h of re(this,ds))re(this,Wi).delete(h),fn(h,zn),this.schedule(h);for(const h of re(this,Wi))fn(h,no),this.schedule(h)}const e=re(this,zr);pt(this,zr,[]),this.apply();var n=al=[],r=[],i=Of=[];for(const h of e)try{Nt(this,Vt,b0).call(this,h,n,r)}catch(p){throw a_(h),p}if(st=null,i.length>0){var o=Mp.ensure();for(const h of i)o.schedule(h)}if(al=null,Of=null,Nt(this,Vt,v0).call(this)){Nt(this,Vt,If).call(this,r),Nt(this,Vt,If).call(this,n);for(const[h,p]of re(this,Ki))s_(h,p);i.length>0&&Nt(l=st,Vt,Fc).call(l);return}const s=Nt(this,Vt,n_).call(this);if(s){Nt(c=s,Vt,r_).call(c,this);return}re(this,ds).clear(),re(this,Wi).clear();for(const h of re(this,Al))h(this);re(this,Al).clear(),Gc=this,wy(r),wy(n),Gc=null,(u=re(this,ad))==null||u.resolve();var a=st;if(this.linked&&re(this,Ml)===0&&Nt(this,Vt,$a).call(this),re(this,zr).length>0){a===null&&(a=this,Nt(this,Vt,y0).call(this));const h=a;re(h,zr).push(...re(this,zr).filter(p=>!re(h,zr).includes(p)))}a!==null&&Nt(f=a,Vt,Fc).call(f)},b0=function(e,n,r){e.f^=Dn;for(var i=e.first;i!==null;){var o=i.f,s=(o&(Ai|Fo))!==0,a=s&&(o&Dn)!==0,l=a||(o&pr)!==0||re(this,Ki).has(i);if(!l&&i.fn!==null){s?i.f^=Dn:(o&Pl)!==0?n.push(i):bd(i)&&((o&li)!==0&&re(this,Wi).add(i),Fl(i));var c=i.first;if(c!==null){i=c;continue}}for(;i!==null;){var u=i.next;if(u!==null){i=u;break}i=i.parent}}},n_=function(){for(var e=re(this,us);e!==null;){if(!e.is_fork){for(const[n,[,r]]of this.current)if(e.current.has(n)&&!r)return e}e=re(e,us)}return null},r_=function(e){var r;for(const[i,o]of e.current)!this.previous.has(i)&&e.previous.has(i)&&this.previous.set(i,e.previous.get(i)),this.current.set(i,o);for(const[i,o]of e.async_deriveds){const s=this.async_deriveds.get(i);s&&o.promise.then(s.resolve)}const n=i=>{var o=i.reactions;if(o!==null)for(const l of o){var s=l.f;if((s&$n)!==0)n(l);else{var a=l;s&(dl|li)&&!this.async_deriveds.has(a)&&(re(this,Wi).delete(a),fn(a,zn),this.schedule(a))}}};for(const i of this.current.keys())n(i);this.oncommit(()=>e.discard()),Nt(r=e,Vt,$a).call(r),st=this,Nt(this,Vt,Fc).call(this)},If=function(e){for(var n=0;n<e.length;n+=1)t_(e[n],re(this,ds),re(this,Wi))},l6=function(){var u;Nt(this,Vt,$a).call(this);for(let f=zm;f!==null;f=re(f,aa)){var e=f.id<this.id,n=[];for(const[h,[p,m]]of this.current){if(f.current.has(h)){var r=f.current.get(h)[0];if(e&&p!==r)f.current.set(h,[p,m]);else continue}n.push(h)}if(e)for(const[h,p]of this.async_deriveds){const m=f.async_deriveds.get(h);m&&p.promise.then(m.resolve)}if(re(f,El)){var i=[...f.current.keys()].filter(h=>!this.current.has(h));if(i.length===0)e&&f.discard();else if(n.length>0){if(e)for(const h of re(this,Dl))f.unskip_effect(h,p=>{var m;(p.f&(li|dl))!==0?f.schedule(p):Nt(m=f,Vt,If).call(m,[p])});f.activate();var o=new Set,s=new Map;for(var a of n)o_(a,i,o,s);s=new Map;var l=[...f.current.keys()].filter(h=>this.current.has(h)?this.current.get(h)[0]!==h.v:!0);if(l.length>0)for(const h of re(this,ld))(h.f&(ui|pr|oh))===0&&ub(h,l,s)&&((h.f&(dl|li))!==0?(fn(h,zn),f.schedule(h)):re(f,ds).add(h));if(re(f,zr).length>0){f.apply();for(var c of re(f,zr))Nt(u=f,Vt,b0).call(u,c,[],[]);pt(f,zr,[])}f.deactivate()}}}},y0=function(){Ka===null?zm=Ka=this:(pt(Ka,aa,this),pt(this,us,Ka)),Ka=this},$a=function(){var e=re(this,us),n=re(this,aa);e===null?zm=n:pt(e,aa,n),n===null?Ka=e:pt(n,us,e),this.linked=!1};let Bo=Mp;function i_(t){var e=fl;fl=!0;try{for(var n;;){if(i6(),st===null)return n;st.flush()}}finally{fl=e}}function c6(){try{I4()}catch(t){ps(t,g0)}}let xi=null;function wy(t){var e=t.length;if(e!==0){for(var n=0;n<e;){var r=t[n++];if((r.f&(ui|pr))===0&&bd(r)&&(xi=new Set,Fl(r),r.deps===null&&r.first===null&&r.nodes===null&&r.teardown===null&&r.ac===null&&C_(r),(xi==null?void 0:xi.size)>0)){fa.clear();for(const i of xi){if((i.f&(ui|pr))!==0)continue;const o=[i];let s=i.parent;for(;s!==null;)xi.has(s)&&(xi.delete(s),o.push(s)),s=s.parent;for(let a=o.length-1;a>=0;a--){const l=o[a];(l.f&(ui|pr))===0&&Fl(l)}}xi.clear()}}xi=null}}function o_(t,e,n,r){if(!n.has(t)&&(n.add(t),t.reactions!==null))for(const i of t.reactions){const o=i.f;(o&$n)!==0?o_(i,e,n,r):(o&(dl|li))!==0&&(o&zn)===0&&ub(i,e,r)&&(fn(i,zn),db(i))}}function ub(t,e,n){const r=n.get(t);if(r!==void 0)return r;if(t.deps!==null)for(const i of t.deps){if(Nl.call(e,i))return!0;if((i.f&$n)!==0&&ub(i,e,n))return n.set(i,!0),!0}return n.set(t,!1),!1}function db(t){st.schedule(t)}function s_(t,e){if(!((t.f&Ai)!==0&&(t.f&Dn)!==0)){(t.f&zn)!==0?e.d.push(t):(t.f&no)!==0&&e.m.push(t),fn(t,Dn);for(var n=t.first;n!==null;)s_(n,e),n=n.next}}function a_(t){fn(t,Dn);for(var e=t.first;e!==null;)a_(e),e=e.next}function u6(t){let e=0,n=Ho(0),r;return()=>{mb()&&(d(n),vd(()=>(e===0&&(r=At(()=>t(()=>Zc(n)))),e+=1,()=>{Ei(()=>{e-=1,e===0&&(r==null||r(),r=void 0,Zc(n))})})))}}var d6=zo|Ba;function l_(t,e,n,r){new f6(t,e,n,r)}var $r,sb,ei,ca,xr,ti,fr,Br,Eo,ua,fs,Il,cd,ud,Ao,Dp,gn,h6,p6,m6,w0,Rf,Nf,x0,k0;class f6{constructor(e,n,r,i){ft(this,gn);In(this,"parent");In(this,"is_pending",!1);In(this,"transform_error");ft(this,$r);ft(this,sb,null);ft(this,ei);ft(this,ca);ft(this,xr);ft(this,ti,null);ft(this,fr,null);ft(this,Br,null);ft(this,Eo,null);ft(this,ua,0);ft(this,fs,0);ft(this,Il,!1);ft(this,cd,new Set);ft(this,ud,new Set);ft(this,Ao,null);ft(this,Dp,u6(()=>(pt(this,Ao,Ho(re(this,ua))),()=>{pt(this,Ao,null)})));var o;pt(this,$r,e),pt(this,ei,n),pt(this,ca,s=>{var a=Ct;a.b=this,a.f|=f0,r(s)}),this.parent=Ct.b,this.transform_error=i??((o=this.parent)==null?void 0:o.transform_error)??(s=>s),pt(this,xr,Va(()=>{Nt(this,gn,w0).call(this)},d6))}defer_effect(e){t_(e,re(this,cd),re(this,ud))}is_rendered(){return!this.is_pending&&(!this.parent||this.parent.is_rendered())}has_pending_snippet(){return!!re(this,ei).pending}update_pending_count(e,n){Nt(this,gn,x0).call(this,e,n),pt(this,ua,re(this,ua)+e),!(!re(this,Ao)||re(this,Il))&&(pt(this,Il,!0),Ei(()=>{pt(this,Il,!1),re(this,Ao)&&Do(re(this,Ao),re(this,ua))}))}get_effect_pending(){return re(this,Dp).call(this),d(re(this,Ao))}error(e){if(!re(this,ei).onerror&&!re(this,ei).failed)throw e;st!=null&&st.is_fork?(re(this,ti)&&st.skip_effect(re(this,ti)),re(this,fr)&&st.skip_effect(re(this,fr)),re(this,Br)&&st.skip_effect(re(this,Br)),st.on_fork_commit(()=>{Nt(this,gn,k0).call(this,e)})):Nt(this,gn,k0).call(this,e)}}$r=new WeakMap,sb=new WeakMap,ei=new WeakMap,ca=new WeakMap,xr=new WeakMap,ti=new WeakMap,fr=new WeakMap,Br=new WeakMap,Eo=new WeakMap,ua=new WeakMap,fs=new WeakMap,Il=new WeakMap,cd=new WeakMap,ud=new WeakMap,Ao=new WeakMap,Dp=new WeakMap,gn=new WeakSet,h6=function(){try{pt(this,ti,ni(()=>re(this,ca).call(this,re(this,$r))))}catch(e){this.error(e)}},p6=function(e){const n=re(this,ei).failed;n&&pt(this,Br,ni(()=>{n(re(this,$r),()=>e,()=>()=>{})}))},m6=function(){const e=re(this,ei).pending;e&&(this.is_pending=!0,pt(this,fr,ni(()=>e(re(this,$r)))),Ei(()=>{var n=pt(this,Eo,document.createDocumentFragment()),r=Oo();n.append(r),pt(this,ti,Nt(this,gn,Nf).call(this,()=>ni(()=>re(this,ca).call(this,r)))),re(this,fs)===0&&(re(this,$r).before(n),pt(this,Eo,null),ha(re(this,fr),()=>{pt(this,fr,null)}),Nt(this,gn,Rf).call(this,st))}))},w0=function(){try{if(this.is_pending=this.has_pending_snippet(),pt(this,fs,0),pt(this,ua,0),pt(this,ti,ni(()=>{re(this,ca).call(this,re(this,$r))})),re(this,fs)>0){var e=pt(this,Eo,document.createDocumentFragment());yb(re(this,ti),e);const n=re(this,ei).pending;pt(this,fr,ni(()=>n(re(this,$r))))}else Nt(this,gn,Rf).call(this,st)}catch(n){this.error(n)}},Rf=function(e){this.is_pending=!1,e.transfer_effects(re(this,cd),re(this,ud))},Nf=function(e){var n=Ct,r=Rt,i=mn;ro(re(this,xr)),gi(re(this,xr)),Ll(re(this,xr).ctx);try{return Bo.ensure(),e()}catch(o){return $2(o),null}finally{ro(n),gi(r),Ll(i)}},x0=function(e,n){var r;if(!this.has_pending_snippet()){this.parent&&Nt(r=this.parent,gn,x0).call(r,e,n);return}pt(this,fs,re(this,fs)+e),re(this,fs)===0&&(Nt(this,gn,Rf).call(this,n),re(this,fr)&&ha(re(this,fr),()=>{pt(this,fr,null)}),re(this,Eo)&&(re(this,$r).before(re(this,Eo)),pt(this,Eo,null)))},k0=function(e){re(this,ti)&&(mr(re(this,ti)),pt(this,ti,null)),re(this,fr)&&(mr(re(this,fr)),pt(this,fr,null)),re(this,Br)&&(mr(re(this,Br)),pt(this,Br,null));var n=re(this,ei).onerror;let r=re(this,ei).failed;var i=!1,o=!1;const s=()=>{if(i){t6();return}i=!0,o&&F4(),re(this,Br)!==null&&ha(re(this,Br),()=>{pt(this,Br,null)}),Nt(this,gn,Nf).call(this,()=>{Nt(this,gn,w0).call(this)})},a=l=>{try{o=!0,n==null||n(l,s),o=!1}catch(c){ps(c,re(this,xr)&&re(this,xr).parent)}r&&pt(this,Br,Nt(this,gn,Nf).call(this,()=>{try{return ni(()=>{var c=Ct;c.b=this,c.f|=f0,r(re(this,$r),()=>l,()=>s)})}catch(c){return ps(c,re(this,xr).parent),null}}))};Ei(()=>{var l;try{l=this.transform_error(e)}catch(c){ps(c,re(this,xr)&&re(this,xr).parent);return}l!==null&&typeof l=="object"&&typeof l.then=="function"?l.then(a,c=>ps(c,re(this,xr)&&re(this,xr).parent)):a(l)})};function g6(t,e,n,r){const i=Ha()?gu:fb;var o=t.filter(h=>!h.settled);if(n.length===0&&o.length===0){r(e.map(i));return}var s=Ct,a=c_(),l=o.length===1?o[0].promise:o.length>1?Promise.all(o.map(h=>h.promise)):null;function c(h){if((s.f&ui)===0){a();try{r(h)}catch(p){ps(p,s)}mu()}}var u=u_();if(n.length===0){l.then(()=>c(e.map(i))).finally(u);return}function f(){Promise.all(n.map(h=>v6(h))).then(h=>c([...e.map(i),...h])).catch(h=>ps(h,s)).finally(u)}l?l.then(()=>{a(),f(),mu()}):f()}function c_(){var t=Ct,e=Rt,n=mn,r=st;return function(o=!0){ro(t),gi(e),Ll(n),o&&(t.f&ui)===0&&(r==null||r.activate(),r==null||r.apply())}}function mu(t=!0){ro(null),gi(null),Ll(null),t&&(st==null||st.deactivate())}function u_(){var t=Ct,e=t.b,n=st,r=e.is_rendered();return e.update_pending_count(1,n),n.increment(r,t),()=>{e.update_pending_count(-1,n),n.decrement(r,t)}}function gu(t){var e=$n|zn;return Ct!==null&&(Ct.f|=Ba),{ctx:mn,deps:null,effects:null,equals:Y2,f:e,fn:t,reactions:null,rv:0,v:En,wv:0,parent:Ct,ac:null}}const Wd=Symbol("obsolete");function v6(t,e,n){let r=Ct;r===null&&A4();var i=void 0,o=Ho(En),s=!Rt,a=new Set;return M6(()=>{var p;var l=Ct,c=U2();i=c.promise;try{Promise.resolve(t()).then(c.resolve,m=>{m!==Fp&&c.reject(m)}).finally(mu)}catch(m){c.reject(m),mu()}var u=st;if(s){if((l.f&Fs)!==0)var f=u_();if(r.b.is_rendered())(p=u.async_deriveds.get(l))==null||p.reject(Wd);else for(const m of a.values())m.reject(Wd);a.add(c),u.async_deriveds.set(l,c)}const h=(m,v=void 0)=>{f==null||f(),a.delete(c),v!==Wd&&(u.activate(),v?(o.f|=xs,Do(o,v)):((o.f&xs)!==0&&(o.f^=xs),Do(o,m)),u.deactivate())};c.promise.then(h,m=>h(null,m||"unknown"))}),gb(()=>{for(const l of a)l.reject(Wd)}),new Promise(l=>{function c(u){function f(){u===i?l(o):c(i)}u.then(f,f)}c(i)})}function L(t){const e=gu(t);return A_(e),e}function fb(t){const e=gu(t);return e.equals=X2,e}function b6(t){var e=t.effects;if(e!==null){t.effects=null;for(var n=0;n<e.length;n+=1)mr(e[n])}}function hb(t){var e,n=Ct,r=t.parent;if(!Vo&&r!==null&&(r.f&(ui|pr))!==0)return $4(),t.v;ro(r);try{t.f&=~_a,b6(t),e=O_(t)}finally{ro(n)}return e}function d_(t){var e=hb(t);if(!t.equals(e)&&(t.wv=M_(),(!(st!=null&&st.is_fork)||t.deps===null)&&(st!==null?(st.capture(t,e,!0),Gc==null||Gc.capture(t,e,!0)):t.v=e,t.deps===null))){fn(t,Dn);return}Vo||(Zn!==null?(mb()||st!=null&&st.is_fork)&&Zn.set(t,e):cb(t))}function y6(t){var e,n;if(t.effects!==null)for(const r of t.effects)(r.teardown||r.ac)&&((e=r.teardown)==null||e.call(r),(n=r.ac)==null||n.abort(Fp),r.teardown=Tn,r.ac=null,bu(r,0),vb(r))}function f_(t){if(t.effects!==null)for(const e of t.effects)e.teardown&&Fl(e)}let ah=new Set;const fa=new Map;let h_=!1;function Ho(t,e){var n={f:0,v:t,reactions:null,equals:Y2,rv:0,wv:0};return n}function F(t,e){const n=Ho(t);return A_(n),n}function _0(t,e=!1,n=!0){var i;const r=Ho(t);return e||(r.equals=X2),ac&&n&&mn!==null&&mn.l!==null&&((i=mn.l).s??(i.s=[])).push(r),r}function y(t,e,n=!1){Rt!==null&&(!Ci||(Rt.f&oh)!==0)&&Ha()&&(Rt.f&($n|li|dl|oh))!==0&&(di===null||!Nl.call(di,t))&&L4();let r=n?Qe(e):e;return Do(t,r,Of)}function Do(t,e,n=null){if(!t.equals(e)){fa.set(t,Vo?e:t.v);var r=Bo.ensure();if(r.capture(t,e),(t.f&$n)!==0){const i=t;(t.f&zn)!==0&&hb(i),Zn===null&&cb(i)}t.wv=M_(),p_(t,zn,n),Ha()&&Ct!==null&&(Ct.f&Dn)!==0&&(Ct.f&(Ai|Fo))===0&&(Qr===null?O6([t]):Qr.push(t)),!r.is_fork&&ah.size>0&&!h_&&w6()}return e}function w6(){h_=!1;for(const t of ah){(t.f&Dn)!==0&&fn(t,no);let e;try{e=bd(t)}catch{e=!0}e&&Fl(t)}ah.clear()}function vu(t,e=1){var n=d(t),r=e===1?n++:n--;return y(t,n),r}function Zc(t){y(t,t.v+1)}function p_(t,e,n){var r=t.reactions;if(r!==null)for(var i=Ha(),o=r.length,s=0;s<o;s++){var a=r[s],l=a.f;if(!(!i&&a===Ct)){var c=(l&zn)===0;if(c&&fn(a,e),(l&oh)!==0)ah.add(a);else if((l&$n)!==0){var u=a;Zn==null||Zn.delete(u),(l&_a)===0&&(l&ci&&(Ct===null||(Ct.f&sh)===0)&&(a.f|=_a),p_(u,no,n))}else if(c){var f=a;(l&li)!==0&&xi!==null&&xi.add(f),n!==null?n.push(f):db(f)}}}}function Qe(t){if(typeof t!="object"||t===null||Qi in t)return t;const e=lb(t);if(e!==y4&&e!==w4)return t;var n=new Map,r=ab(t),i=F(0),o=pa,s=a=>{if(pa===o)return a();var l=Rt,c=pa;gi(null),Sy(o);var u=a();return gi(l),Sy(c),u};return r&&n.set("length",F(t.length)),new Proxy(t,{defineProperty(a,l,c){(!("value"in c)||c.configurable===!1||c.enumerable===!1||c.writable===!1)&&N4();var u=n.get(l);return u===void 0?s(()=>{var f=F(c.value);return n.set(l,f),f}):y(u,c.value,!0),!0},deleteProperty(a,l){var c=n.get(l);if(c===void 0){if(l in a){const u=s(()=>F(En));n.set(l,u),Zc(i)}}else y(c,En),Zc(i);return!0},get(a,l,c){var p;if(l===Qi)return t;var u=n.get(l),f=l in a;if(u===void 0&&(!f||(p=ws(a,l))!=null&&p.writable)&&(u=s(()=>{var m=Qe(f?a[l]:En),v=F(m);return v}),n.set(l,u)),u!==void 0){var h=d(u);return h===En?void 0:h}return Reflect.get(a,l,c)},getOwnPropertyDescriptor(a,l){var c=Reflect.getOwnPropertyDescriptor(a,l);if(c&&"value"in c){var u=n.get(l);u&&(c.value=d(u))}else if(c===void 0){var f=n.get(l),h=f==null?void 0:f.v;if(f!==void 0&&h!==En)return{enumerable:!0,configurable:!0,value:h,writable:!0}}return c},has(a,l){var h;if(l===Qi)return!0;var c=n.get(l),u=c!==void 0&&c.v!==En||Reflect.has(a,l);if(c!==void 0||Ct!==null&&(!u||(h=ws(a,l))!=null&&h.writable)){c===void 0&&(c=s(()=>{var p=u?Qe(a[l]):En,m=F(p);return m}),n.set(l,c));var f=d(c);if(f===En)return!1}return u},set(a,l,c,u){var k;var f=n.get(l),h=l in a;if(r&&l==="length")for(var p=c;p<f.v;p+=1){var m=n.get(p+"");m!==void 0?y(m,En):p in a&&(m=s(()=>F(En)),n.set(p+"",m))}if(f===void 0)(!h||(k=ws(a,l))!=null&&k.writable)&&(f=s(()=>F(void 0)),y(f,Qe(c)),n.set(l,f));else{h=f.v!==En;var v=s(()=>Qe(c));y(f,v)}var g=Reflect.getOwnPropertyDescriptor(a,l);if(g!=null&&g.set&&g.set.call(u,c),!h){if(r&&typeof l=="string"){var b=n.get("length"),_=Number(l);Number.isInteger(_)&&_>=b.v&&y(b,_+1)}Zc(i)}return!0},ownKeys(a){d(i);var l=Reflect.ownKeys(a).filter(f=>{var h=n.get(f);return h===void 0||h.v!==En});for(var[c,u]of n)u.v!==En&&!(c in a)&&l.push(c);return l},setPrototypeOf(){P4()}})}function xy(t){try{if(t!==null&&typeof t=="object"&&Qi in t)return t[Qi]}catch{}return t}function x6(t,e){return Object.is(xy(t),xy(e))}var ky,m_,g_,v_;function k6(){if(ky===void 0){ky=window,m_=/Firefox/.test(navigator.userAgent);var t=Element.prototype,e=Node.prototype,n=Text.prototype;g_=ws(e,"firstChild").get,v_=ws(e,"nextSibling").get,by(t)&&(t[p0]=void 0,t[Mf]=null,t[m0]=void 0,t.__e=void 0),by(n)&&(n[Lc]=void 0)}}function Oo(t=""){return document.createTextNode(t)}function Vr(t){return g_.call(t)}function md(t){return v_.call(t)}function w(t,e){return Vr(t)}function Ie(t,e=!1){{var n=Vr(t);return n instanceof Comment&&n.data===""?md(n):n}}function x(t,e=1,n=!1){let r=t;for(;e--;)r=md(r);return r}function _6(t){t.textContent=""}function b_(){return!1}function y_(t,e,n){return document.createElementNS(e??Z2,t,void 0)}function C6(t,e){{const n=document.body;t.autofocus=!0,Ei(()=>{document.activeElement===n&&t.focus()})}}let _y=!1;function S6(){_y||(_y=!0,document.addEventListener("reset",t=>{Promise.resolve().then(()=>{var e;if(!t.defaultPrevented)for(const n of t.target.elements)(e=n[Df])==null||e.call(n)})},{capture:!0}))}function lc(t){var e=Rt,n=Ct;gi(null),ro(null);try{return t()}finally{gi(e),ro(n)}}function pb(t,e,n,r=n){t.addEventListener(e,()=>lc(n));const i=t[Df];i?t[Df]=()=>{i(),r(!0)}:t[Df]=()=>r(!0),S6()}function E6(t){Ct===null&&(Rt===null&&O4(),D4()),Vo&&M4()}function A6(t,e){var n=e.last;n===null?e.last=e.first=t:(n.next=t,t.prev=n,e.last=t)}function lo(t,e){var n=Ct;n!==null&&(n.f&pr)!==0&&(t|=pr);var r={ctx:mn,deps:null,nodes:null,f:t|zn|ci,first:null,fn:e,last:null,next:null,parent:n,b:n&&n.b,prev:null,teardown:null,wv:0,ac:null};st==null||st.register_created_effect(r);var i=r;if((t&Pl)!==0)al!==null?al.push(r):Bo.ensure().schedule(r);else if(e!==null){try{Fl(r)}catch(s){throw mr(r),s}i.deps===null&&i.teardown===null&&i.nodes===null&&i.first===i.last&&(i.f&Ba)===0&&(i=i.first,(t&li)!==0&&(t&zo)!==0&&i!==null&&(i.f|=zo))}if(i!==null&&(i.parent=n,n!==null&&A6(i,n),Rt!==null&&(Rt.f&$n)!==0&&(t&Fo)===0)){var o=Rt;(o.effects??(o.effects=[])).push(i)}return r}function mb(){return Rt!==null&&!Ci}function gb(t){const e=lo(Lp,null);return fn(e,Dn),e.teardown=t,e}function he(t){E6();var e=Ct.f,n=!Rt&&(e&Ai)!==0&&(e&Fs)===0;if(n){var r=mn;(r.e??(r.e=[])).push(t)}else return w_(t)}function w_(t){return lo(Pl|C4,t)}function x_(t){Bo.ensure();const e=lo(Fo|Ba,t);return()=>{mr(e)}}function T6(t){Bo.ensure();const e=lo(Fo|Ba,t);return(n={})=>new Promise(r=>{n.outro?ha(e,()=>{mr(e),r(void 0)}):(mr(e),r(void 0))})}function gd(t){return lo(Pl,t)}function M6(t){return lo(dl|Ba,t)}function vd(t,e=0){return lo(Lp|e,t)}function j(t,e=[],n=[],r=[]){g6(r,e,n,i=>{lo(Lp,()=>t(...i.map(d)))})}function Va(t,e=0){var n=lo(li|e,t);return n}function ni(t){return lo(Ai|Ba,t)}function k_(t){var e=t.teardown;if(e!==null){const n=Vo,r=Rt;Cy(!0),gi(null);try{e.call(null)}finally{Cy(n),gi(r)}}}function vb(t,e=!1){var n=t.first;for(t.first=t.last=null;n!==null;){const i=n.ac;i!==null&&lc(()=>{i.abort(Fp)});var r=n.next;(n.f&Fo)!==0?n.parent=null:mr(n,e),n=r}}function D6(t){for(var e=t.first;e!==null;){var n=e.next;(e.f&Ai)===0&&mr(e),e=n}}function mr(t,e=!0){var n=!1;(e||(t.f&_4)!==0)&&t.nodes!==null&&t.nodes.end!==null&&(__(t.nodes.start,t.nodes.end),n=!0),fn(t,h0),vb(t,e&&!n),bu(t,0);var r=t.nodes&&t.nodes.t;if(r!==null)for(const o of r)o.stop();k_(t),t.f^=h0,t.f|=ui;var i=t.parent;i!==null&&i.first!==null&&C_(t),t.next=t.prev=t.teardown=t.ctx=t.deps=t.fn=t.nodes=t.ac=t.b=null}function __(t,e){for(;t!==null;){var n=t===e?null:md(t);t.remove(),t=n}}function C_(t){var e=t.parent,n=t.prev,r=t.next;n!==null&&(n.next=r),r!==null&&(r.prev=n),e!==null&&(e.first===t&&(e.first=r),e.last===t&&(e.last=n))}function ha(t,e,n=!0){var r=[];S_(t,r,!0);var i=()=>{n&&mr(t),e&&e()},o=r.length;if(o>0){var s=()=>--o||i();for(var a of r)a.out(s)}else i()}function S_(t,e,n){if((t.f&pr)===0){t.f^=pr;var r=t.nodes&&t.nodes.t;if(r!==null)for(const a of r)(a.is_global||n)&&e.push(a);for(var i=t.first;i!==null;){var o=i.next;if((i.f&Fo)===0){var s=(i.f&zo)!==0||(i.f&Ai)!==0&&(t.f&li)!==0;S_(i,e,s?n:!1)}i=o}}}function bb(t){E_(t,!0)}function E_(t,e){if((t.f&pr)!==0){t.f^=pr,(t.f&Dn)===0&&(fn(t,zn),Bo.ensure().schedule(t));for(var n=t.first;n!==null;){var r=n.next,i=(n.f&zo)!==0||(n.f&Ai)!==0;E_(n,i?e:!1),n=r}var o=t.nodes&&t.nodes.t;if(o!==null)for(const s of o)(s.is_global||e)&&s.in()}}function yb(t,e){if(t.nodes)for(var n=t.nodes.start,r=t.nodes.end;n!==null;){var i=n===r?null:md(n);e.append(n),n=i}}let Pf=!1,Vo=!1;function Cy(t){Vo=t}let Rt=null,Ci=!1;function gi(t){Rt=t}let Ct=null;function ro(t){Ct=t}let di=null;function A_(t){Rt!==null&&(di===null?di=[t]:di.push(t))}let kr=null,Pr=0,Qr=null;function O6(t){Qr=t}let T_=1,$s=0,pa=$s;function Sy(t){pa=t}function M_(){return++T_}function bd(t){var e=t.f;if((e&zn)!==0)return!0;if(e&$n&&(t.f&=~_a),(e&no)!==0){for(var n=t.deps,r=n.length,i=0;i<r;i++){var o=n[i];if(bd(o)&&d_(o),o.wv>t.wv)return!0}(e&ci)!==0&&Zn===null&&fn(t,Dn)}return!1}function D_(t,e,n=!0){var r=t.reactions;if(r!==null&&!(di!==null&&Nl.call(di,t)))for(var i=0;i<r.length;i++){var o=r[i];(o.f&$n)!==0?D_(o,e,!1):e===o&&(n?fn(o,zn):(o.f&Dn)!==0&&fn(o,no),db(o))}}function O_(t){var v;var e=kr,n=Pr,r=Qr,i=Rt,o=di,s=mn,a=Ci,l=pa,c=t.f;kr=null,Pr=0,Qr=null,Rt=(c&(Ai|Fo))===0?t:null,di=null,Ll(t.ctx),Ci=!1,pa=++$s,t.ac!==null&&(lc(()=>{t.ac.abort(Fp)}),t.ac=null);try{t.f|=sh;var u=t.fn,f=u();t.f|=Fs;var h=t.deps,p=st==null?void 0:st.is_fork;if(kr!==null){var m;if(p||bu(t,Pr),h!==null&&Pr>0)for(h.length=Pr+kr.length,m=0;m<kr.length;m++)h[Pr+m]=kr[m];else t.deps=h=kr;if(mb()&&(t.f&ci)!==0)for(m=Pr;m<h.length;m++)((v=h[m]).reactions??(v.reactions=[])).push(t)}else!p&&h!==null&&Pr<h.length&&(bu(t,Pr),h.length=Pr);if(Ha()&&Qr!==null&&!Ci&&h!==null&&(t.f&($n|no|zn))===0)for(m=0;m<Qr.length;m++)D_(Qr[m],t);if(i!==null&&i!==t){if($s++,i.deps!==null)for(let g=0;g<n;g+=1)i.deps[g].rv=$s;if(e!==null)for(const g of e)g.rv=$s;Qr!==null&&(r===null?r=Qr:r.push(...Qr))}return(t.f&xs)!==0&&(t.f^=xs),f}catch(g){return $2(g)}finally{t.f^=sh,kr=e,Pr=n,Qr=r,Rt=i,di=o,Ll(s),Ci=a,pa=l}}function I6(t,e){let n=e.reactions;if(n!==null){var r=v4.call(n,t);if(r!==-1){var i=n.length-1;i===0?n=e.reactions=null:(n[r]=n[i],n.pop())}}if(n===null&&(e.f&$n)!==0&&(kr===null||!Nl.call(kr,e))){var o=e;(o.f&ci)!==0&&(o.f^=ci,o.f&=~_a),o.v!==En&&cb(o),y6(o),bu(o,0)}}function bu(t,e){var n=t.deps;if(n!==null)for(var r=e;r<n.length;r++)I6(t,n[r])}function Fl(t){var e=t.f;if((e&ui)===0){fn(t,Dn);var n=Ct,r=Pf;Ct=t,Pf=!0;try{(e&(li|j2))!==0?D6(t):vb(t),k_(t);var i=O_(t);t.teardown=typeof i=="function"?i:null,t.wv=T_;var o;H2&&n6&&(t.f&zn)!==0&&t.deps}finally{Pf=r,Ct=n}}}async function R6(){await Promise.resolve(),i_()}function d(t){var e=t.f,n=(e&$n)!==0;if(Rt!==null&&!Ci){var r=Ct!==null&&(Ct.f&ui)!==0;if(!r&&(di===null||!Nl.call(di,t))){var i=Rt.deps;if((Rt.f&sh)!==0)t.rv<$s&&(t.rv=$s,kr===null&&i!==null&&i[Pr]===t?Pr++:kr===null?kr=[t]:kr.push(t));else{(Rt.deps??(Rt.deps=[])).push(t);var o=t.reactions;o===null?t.reactions=[Rt]:Nl.call(o,Rt)||o.push(Rt)}}}if(Vo&&fa.has(t))return fa.get(t);if(n){var s=t;if(Vo){var a=s.v;return((s.f&Dn)===0&&s.reactions!==null||R_(s))&&(a=hb(s)),fa.set(s,a),a}var l=(s.f&ci)===0&&!Ci&&Rt!==null&&(Pf||(Rt.f&ci)!==0),c=(s.f&Fs)===0;bd(s)&&(l&&(s.f|=ci),d_(s)),l&&!c&&(f_(s),I_(s))}if(Zn!=null&&Zn.has(t))return Zn.get(t);if((t.f&xs)!==0)throw t.v;return t.v}function I_(t){if(t.f|=ci,t.deps!==null)for(const e of t.deps)(e.reactions??(e.reactions=[])).push(t),(e.f&$n)!==0&&(e.f&ci)===0&&(f_(e),I_(e))}function R_(t){if(t.v===En)return!0;if(t.deps===null)return!1;for(const e of t.deps)if(fa.has(e)||(e.f&$n)!==0&&R_(e))return!0;return!1}function At(t){var e=Ci;try{return Ci=!0,t()}finally{Ci=e}}function N6(t){if(!(typeof t!="object"||!t||t instanceof EventTarget)){if(Qi in t)C0(t);else if(!Array.isArray(t))for(let e in t){const n=t[e];typeof n=="object"&&n&&Qi in n&&C0(n)}}}function C0(t,e=new Set){if(typeof t=="object"&&t!==null&&!(t instanceof EventTarget)&&!e.has(t)){e.add(t),t instanceof Date&&t.getTime();for(let r in t)try{C0(t[r],e)}catch{}const n=lb(t);if(n!==Object.prototype&&n!==Array.prototype&&n!==Map.prototype&&n!==Set.prototype&&n!==Date.prototype){const r=V2(n);for(let i in r){const o=r[i].get;if(o)try{o.call(t)}catch{}}}}}const P6=["touchstart","touchmove"];function L6(t){return P6.includes(t)}const ea=Symbol("events"),N_=new Set,S0=new Set;function F6(t,e,n,r={}){function i(o){if(r.capture||E0.call(e,o),!o.cancelBubble)return lc(()=>n==null?void 0:n.call(this,o))}return t.startsWith("pointer")||t.startsWith("touch")||t==="wheel"?Ei(()=>{e.addEventListener(t,i,r)}):e.addEventListener(t,i,r),i}function hn(t,e,n,r,i){var o={capture:r,passive:i},s=F6(t,e,n,o);(e===document.body||e===window||e===document||e instanceof HTMLMediaElement)&&gb(()=>{e.removeEventListener(t,s,o)})}function P(t,e,n){(e[ea]??(e[ea]={}))[t]=n}function et(t){for(var e=0;e<t.length;e++)N_.add(t[e]);for(var n of S0)n(t)}let Ey=null;function E0(t){var g,b;var e=this,n=e.ownerDocument,r=t.type,i=((g=t.composedPath)==null?void 0:g.call(t))||[],o=i[0]||t.target;Ey=t;var s=0,a=Ey===t&&t[ea];if(a){var l=i.indexOf(a);if(l!==-1&&(e===document||e===window)){t[ea]=e;return}var c=i.indexOf(e);if(c===-1)return;l<=c&&(s=l)}if(o=i[s]||t.target,o!==e){b4(t,"currentTarget",{configurable:!0,get(){return o||n}});var u=Rt,f=Ct;gi(null),ro(null);try{for(var h,p=[];o!==null;){var m=o.assignedSlot||o.parentNode||o.host||null;try{var v=(b=o[ea])==null?void 0:b[r];v!=null&&(!o.disabled||t.target===o)&&v.call(o,t)}catch(_){h?p.push(_):h=_}if(t.cancelBubble||m===e||m===null)break;o=m}if(h){for(let _ of p)queueMicrotask(()=>{throw _});throw h}}finally{t[ea]=e,delete t.currentTarget,gi(u),ro(f)}}}var z2;const Hm=((z2=globalThis==null?void 0:globalThis.window)==null?void 0:z2.trustedTypes)&&globalThis.window.trustedTypes.createPolicy("svelte-trusted-html",{createHTML:t=>t});function z6(t){return(Hm==null?void 0:Hm.createHTML(t))??t}function P_(t){var e=y_("template");return e.innerHTML=z6(t.replaceAll("<!>","<!---->")),e.content}function As(t,e){var n=Ct;n.nodes===null&&(n.nodes={start:t,end:e,a:null,t:null})}function T(t,e){var n=(e&G2)!==0,r=(e&J4)!==0,i,o=!t.startsWith("<!>");return()=>{i===void 0&&(i=P_(o?t:"<!>"+t),n||(i=Vr(i)));var s=r||m_?document.importNode(i,!0):i.cloneNode(!0);if(n){var a=Vr(s),l=s.lastChild;As(a,l)}else As(s,s);return s}}function B6(t,e,n="svg"){var r=!t.startsWith("<!>"),i=(e&G2)!==0,o=`<${n}>${r?t:"<!>"+t}</${n}>`,s;return()=>{if(!s){var a=P_(o),l=Vr(a);if(i)for(s=document.createDocumentFragment();Vr(l);)s.appendChild(Vr(l));else s=Vr(l)}var c=s.cloneNode(!0);if(i){var u=Vr(c),f=c.lastChild;As(u,f)}else As(c,c);return c}}function Dr(t,e){return B6(t,e,"svg")}function hr(t=""){{var e=Oo(t+"");return As(e,e),e}}function Mt(){var t=document.createDocumentFragment(),e=document.createComment(""),n=Oo();return t.append(e,n),As(e,n),t}function S(t,e){t!==null&&t.before(e)}let A0=!0;function J(t,e){var n=e==null?"":typeof e=="object"?`${e}`:e;n!==(t[Lc]??(t[Lc]=t.nodeValue))&&(t[Lc]=n,t.nodeValue=`${n}`)}function H6(t,e){return V6(t,e)}const Kd=new Map;function V6(t,{target:e,anchor:n,props:r={},events:i,context:o,intro:s=!0,transformError:a}){k6();var l=void 0,c=T6(()=>{var u=n??e.appendChild(Oo());l_(u,{pending:()=>{}},p=>{We({});var m=mn;o&&(m.c=o),i&&(r.$$events=i),A0=s,l=t(p,r)||{},A0=!0,Ke()},a);var f=new Set,h=p=>{for(var m=0;m<p.length;m++){var v=p[m];if(!f.has(v)){f.add(v);var g=L6(v);for(const k of[e,document]){var b=Kd.get(k);b===void 0&&(b=new Map,Kd.set(k,b));var _=b.get(v);_===void 0?(k.addEventListener(v,E0,{passive:g}),b.set(v,1)):b.set(v,_+1)}}}};return h(Pp(N_)),S0.add(h),()=>{var g;for(var p of f)for(const b of[e,document]){var m=Kd.get(b),v=m.get(p);--v==0?(b.removeEventListener(p,E0),m.delete(p),m.size===0&&Kd.delete(b)):m.set(p,v)}S0.delete(h),u!==n&&((g=u.parentNode)==null||g.removeChild(u))}});return U6.set(l,c),l}let U6=new WeakMap;var ki,Gi,Hr,da,dd,fd,Op;class yd{constructor(e,n=!0){In(this,"anchor");ft(this,ki,new Map);ft(this,Gi,new Map);ft(this,Hr,new Map);ft(this,da,new Set);ft(this,dd,!0);ft(this,fd,e=>{if(re(this,ki).has(e)){var n=re(this,ki).get(e),r=re(this,Gi).get(n);if(r)bb(r),re(this,da).delete(n);else{var i=re(this,Hr).get(n);i&&(re(this,Gi).set(n,i.effect),re(this,Hr).delete(n),i.fragment.lastChild.remove(),this.anchor.before(i.fragment),r=i.effect)}for(const[o,s]of re(this,ki)){if(re(this,ki).delete(o),o===e)break;const a=re(this,Hr).get(s);a&&(mr(a.effect),re(this,Hr).delete(s))}for(const[o,s]of re(this,Gi)){if(o===n||re(this,da).has(o))continue;const a=()=>{if(Array.from(re(this,ki).values()).includes(o)){var c=document.createDocumentFragment();yb(s,c),c.append(Oo()),re(this,Hr).set(o,{effect:s,fragment:c})}else mr(s);re(this,da).delete(o),re(this,Gi).delete(o)};re(this,dd)||!r?(re(this,da).add(o),ha(s,a,!1)):a()}}});ft(this,Op,e=>{re(this,ki).delete(e);const n=Array.from(re(this,ki).values());for(const[r,i]of re(this,Hr))n.includes(r)||(mr(i.effect),re(this,Hr).delete(r))});this.anchor=e,pt(this,dd,n)}ensure(e,n){var r=st,i=b_();if(n&&!re(this,Gi).has(e)&&!re(this,Hr).has(e))if(i){var o=document.createDocumentFragment(),s=Oo();o.append(s),re(this,Hr).set(e,{effect:ni(()=>n(s)),fragment:o})}else re(this,Gi).set(e,ni(()=>n(this.anchor)));if(re(this,ki).set(r,e),i){for(const[a,l]of re(this,Gi))a===e?r.unskip_effect(l):r.skip_effect(l);for(const[a,l]of re(this,Hr))a===e?r.unskip_effect(l.effect):r.skip_effect(l.effect);r.oncommit(re(this,fd)),r.ondiscard(re(this,Op))}else re(this,fd).call(this,r)}}ki=new WeakMap,Gi=new WeakMap,Hr=new WeakMap,da=new WeakMap,dd=new WeakMap,fd=new WeakMap,Op=new WeakMap;const j6=0,Ay=1,q6=2;function L_(t,e,n,r,i){var o=Ha(),s=En,a=o?Ho(s):_0(s,!1,!1),l=o?Ho(s):_0(s,!1,!1),c=new yd(t);Va(()=>{var u=st;u.deactivate();var f=e();u.activate();var h=!1;if(x4(f)){var p=c_(),m=!1;const v=g=>{if(!h){m=!0,p(!1),Bo.ensure();try{g()}finally{mu(!1),fl||i_()}}};f.then(g=>{v(()=>{Do(a,g),c.ensure(Ay,r&&(b=>r(b,a)))})},g=>{v(()=>{if(Do(l,g),c.ensure(q6,i&&(b=>i(b,l))),!i)throw l.v})}),Ei(()=>{m||v(()=>{c.ensure(j6,n)})})}else Do(a,f),c.ensure(Ay,r&&(v=>r(v,a)));return()=>{h=!0}})}function W(t,e,n=!1){var r=new yd(t),i=n?zo:0;function o(s,a){r.ensure(s,a)}Va(()=>{var s=!1;e((a,l=0)=>{s=!0,o(l,a)}),s||o(-1,null)},i)}const W6=Symbol("NaN");function yu(t,e,n){var r=new yd(t),i=!Ha();Va(()=>{var o=e();o!==o&&(o=W6),i&&o!==null&&typeof o=="object"&&(o={}),r.ensure(o,n)})}function zl(t,e){return e}function K6(t,e,n){for(var r=[],i=e.length,o,s=e.length,a=0;a<i;a++){let f=e[a];ha(f,()=>{if(o){if(o.pending.delete(f),o.done.add(f),o.pending.size===0){var h=t.outrogroups;T0(t,Pp(o.done)),h.delete(o),h.size===0&&(t.outrogroups=null)}}else s-=1},!1)}if(s===0){var l=r.length===0&&n!==null;if(l){var c=n,u=c.parentNode;_6(u),u.append(c),t.items.clear()}T0(t,e,!l)}else o={pending:new Set(e),done:new Set},(t.outrogroups??(t.outrogroups=new Set)).add(o)}function T0(t,e,n=!0){var r;if(t.pending.size>0){r=new Set;for(const s of t.pending.values())for(const a of s)r.add(t.items.get(a).e)}for(var i=0;i<e.length;i++){var o=e[i];if(r!=null&&r.has(o)){o.f|=Zi;const s=document.createDocumentFragment();yb(o,s)}else mr(e[i],n)}}var Ty;function nt(t,e,n,r,i,o=null){var s=t,a=new Map,l=(e&K2)!==0;if(l){var c=t;s=c.appendChild(Oo())}var u=null,f=fb(()=>{var k=n();return ab(k)?k:k==null?[]:Pp(k)}),h,p=new Map,m=!0;function v(k){(_.effect.f&ui)===0&&(_.pending.delete(k),_.fallback=u,G6(_,h,s,e,r),u!==null&&(h.length===0?(u.f&Zi)===0?bb(u):(u.f^=Zi,zc(u,null,s)):ha(u,()=>{u=null})))}function g(k){_.pending.delete(k)}var b=Va(()=>{h=d(f);for(var k=h.length,C=new Set,E=st,I=b_(),A=0;A<k;A+=1){var M=h[A],N=r(M,A),R=m?null:a.get(N);R?(R.v&&Do(R.v,M),R.i&&Do(R.i,A),I&&E.unskip_effect(R.e)):(R=Z6(a,m?s:Ty??(Ty=Oo()),M,N,A,i,e,n),m||(R.e.f|=Zi),a.set(N,R)),C.add(N)}if(k===0&&o&&!u&&(m?u=ni(()=>o(s)):(u=ni(()=>o(Ty??(Ty=Oo()))),u.f|=Zi)),k>C.size&&T4(),!m)if(p.set(E,C),I){for(const[B,Z]of a)C.has(B)||E.skip_effect(Z.e);E.oncommit(v),E.ondiscard(g)}else v(E);d(f)}),_={effect:b,items:a,pending:p,outrogroups:null,fallback:u};m=!1}function Cc(t){for(;t!==null&&(t.f&Ai)===0;)t=t.next;return t}function G6(t,e,n,r,i){var R,B,Z,q,Y,X,ae,ne,te;var o=(r&H4)!==0,s=e.length,a=t.items,l=Cc(t.effect.first),c,u=null,f,h=[],p=[],m,v,g,b;if(o)for(b=0;b<s;b+=1)m=e[b],v=i(m,b),g=a.get(v).e,(g.f&Zi)===0&&((B=(R=g.nodes)==null?void 0:R.a)==null||B.measure(),(f??(f=new Set)).add(g));for(b=0;b<s;b+=1){if(m=e[b],v=i(m,b),g=a.get(v).e,t.outrogroups!==null)for(const le of t.outrogroups)le.pending.delete(g),le.done.delete(g);if((g.f&pr)!==0&&(bb(g),o&&((q=(Z=g.nodes)==null?void 0:Z.a)==null||q.unfix(),(f??(f=new Set)).delete(g))),(g.f&Zi)!==0)if(g.f^=Zi,g===l)zc(g,null,n);else{var _=u?u.next:l;g===t.effect.last&&(t.effect.last=g.prev),g.prev&&(g.prev.next=g.next),g.next&&(g.next.prev=g.prev),Jo(t,u,g),Jo(t,g,_),zc(g,_,n),u=g,h=[],p=[],l=Cc(u.next);continue}if(g!==l){if(c!==void 0&&c.has(g)){if(h.length<p.length){var k=p[0],C;u=k.prev;var E=h[0],I=h[h.length-1];for(C=0;C<h.length;C+=1)zc(h[C],k,n);for(C=0;C<p.length;C+=1)c.delete(p[C]);Jo(t,E.prev,I.next),Jo(t,u,E),Jo(t,I,k),l=k,u=I,b-=1,h=[],p=[]}else c.delete(g),zc(g,l,n),Jo(t,g.prev,g.next),Jo(t,g,u===null?t.effect.first:u.next),Jo(t,u,g),u=g;continue}for(h=[],p=[];l!==null&&l!==g;)(c??(c=new Set)).add(l),p.push(l),l=Cc(l.next);if(l===null)continue}(g.f&Zi)===0&&h.push(g),u=g,l=Cc(g.next)}if(t.outrogroups!==null){for(const le of t.outrogroups)le.pending.size===0&&(T0(t,Pp(le.done)),(Y=t.outrogroups)==null||Y.delete(le));t.outrogroups.size===0&&(t.outrogroups=null)}if(l!==null||c!==void 0){var A=[];if(c!==void 0)for(g of c)(g.f&pr)===0&&A.push(g);for(;l!==null;)(l.f&pr)===0&&l!==t.fallback&&A.push(l),l=Cc(l.next);var M=A.length;if(M>0){var N=(r&K2)!==0&&s===0?n:null;if(o){for(b=0;b<M;b+=1)(ae=(X=A[b].nodes)==null?void 0:X.a)==null||ae.measure();for(b=0;b<M;b+=1)(te=(ne=A[b].nodes)==null?void 0:ne.a)==null||te.fix()}K6(t,A,N)}}o&&Ei(()=>{var le,se;if(f!==void 0)for(g of f)(se=(le=g.nodes)==null?void 0:le.a)==null||se.apply()})}function Z6(t,e,n,r,i,o,s,a){var l=(s&z4)!==0?(s&V4)===0?_0(n,!1,!1):Ho(n):null,c=(s&B4)!==0?Ho(i):null;return{v:l,i:c,e:ni(()=>(o(e,l??n,c??i,a),()=>{t.delete(r)}))}}function zc(t,e,n){if(t.nodes)for(var r=t.nodes.start,i=t.nodes.end,o=e&&(e.f&Zi)===0?e.nodes.start:n;r!==null;){var s=md(r);if(o.before(r),r===i)return;r=s}}function Jo(t,e,n){e===null?t.effect.first=n:e.next=n,n===null?t.effect.last=e:n.prev=e}function Y6(t,e,n=!1,r=!1,i=!1,o=!1){var s=t,a="";if(n)var l=t;j(()=>{var c=Ct;if(a!==(a=e()??"")){if(n){c.nodes=null,l.innerHTML=a,a!==""&&As(Vr(l),l.lastChild);return}if(c.nodes!==null&&(__(c.nodes.start,c.nodes.end),c.nodes=null),a!==""){var u=r?X4:i?Q4:void 0,f=y_(r?"svg":i?"math":"template",u);f.innerHTML=a;var h=r||i?f:f.content;if(As(Vr(h),h.lastChild),r||i)for(;Vr(h);)s.before(Vr(h));else s.before(h)}}})}function wd(t,e,...n){var r=new yd(t);Va(()=>{const i=e()??null;r.ensure(i,i&&(o=>i(o,...n)))},zo)}function wb(t,e,n){var r=new yd(t);Va(()=>{var i=e()??null;r.ensure(i,i&&(o=>n(o,i)))},zo)}const J6=()=>performance.now(),To={tick:t=>requestAnimationFrame(t),now:()=>J6(),tasks:new Set};function F_(){const t=To.now();To.tasks.forEach(e=>{e.c(t)||(To.tasks.delete(e),e.f())}),To.tasks.size!==0&&To.tick(F_)}function X6(t){let e;return To.tasks.size===0&&To.tick(F_),{promise:new Promise(n=>{To.tasks.add(e={c:t,f:n})}),abort(){To.tasks.delete(e)}}}function Gd(t,e){lc(()=>{t.dispatchEvent(new CustomEvent(e))})}function Q6(t){if(t==="float")return"cssFloat";if(t==="offset")return"cssOffset";if(t.startsWith("--"))return t;const e=t.split("-");return e.length===1?e[0]:e[0]+e.slice(1).map(n=>n[0].toUpperCase()+n.slice(1)).join("")}function My(t){const e={},n=t.split(";");for(const r of n){const[i,o]=r.split(":");if(!i||o===void 0)break;const s=Q6(i.trim());e[s]=o.trim()}return e}const $6=t=>t;function Uo(t,e,n,r){var k;var i=(t&G4)!==0,o=(t&Z4)!==0,s=i&&o,a=(t&Y4)!==0,l=s?"both":i?"in":"out",c,u=e.inert,f=e.style.overflow,h,p;function m(){return lc(()=>c??(c=n()(e,(r==null?void 0:r())??{},{direction:l})))}var v={is_global:a,in(){var C;if(e.inert=u,!i){p==null||p.abort(),(C=p==null?void 0:p.reset)==null||C.call(p);return}o||h==null||h.abort(),h=M0(e,m(),p,1,()=>{Gd(e,"introstart")},()=>{Gd(e,"introend"),h==null||h.abort(),h=c=void 0,e.style.overflow=f})},out(C){if(!o){C==null||C(),c=void 0;return}e.inert=!0,p=M0(e,m(),h,0,()=>{Gd(e,"outrostart")},()=>{Gd(e,"outroend"),C==null||C()})},stop:()=>{h==null||h.abort(),p==null||p.abort()}},g=Ct;if(((k=g.nodes).t??(k.t=[])).push(v),i&&A0){var b=a;if(!b){for(var _=g.parent;_&&(_.f&zo)!==0;)for(;(_=_.parent)&&(_.f&li)===0;);b=!_||(_.f&Fs)!==0}b&&gd(()=>{At(()=>v.in())})}}function M0(t,e,n,r,i,o){var s=r===1;if(Qa(e)){var a,l=!1;return Ei(()=>{if(!l){var b=e({direction:s?"in":"out"});a=M0(t,b,n,r,i,o)}}),{abort:()=>{l=!0,a==null||a.abort()},deactivate:()=>a.deactivate(),reset:()=>a.reset(),t:()=>a.t()}}if(n==null||n.deactivate(),!(e!=null&&e.duration)&&!(e!=null&&e.delay))return i(),o(),{abort:Tn,deactivate:Tn,reset:Tn,t:()=>r};const{delay:c=0,css:u,tick:f,easing:h=$6}=e;var p=[];if(s&&n===void 0&&(f&&f(0,1),u)){var m=My(u(0,1));p.push(m,m)}var v=()=>1-r,g=t.animate(p,{duration:c,fill:"forwards"});return g.onfinish=()=>{g.cancel(),i();var b=(n==null?void 0:n.t())??1-r;n==null||n.abort();var _=r-b,k=e.duration*Math.abs(_),C=[];if(k>0){var E=!1;if(u)for(var I=Math.ceil(k/16.666666666666668),A=0;A<=I;A+=1){var M=b+_*h(A/I),N=My(u(M,1-M));C.push(N),E||(E=N.overflow==="hidden")}E&&(t.style.overflow="hidden"),v=()=>{var R=g.currentTime;return b+_*h(R/k)},f&&X6(()=>{if(g.playState!=="running")return!1;var R=v();return f(R,1-R),!0})}g=t.animate(C,{duration:k,fill:"forwards"}),g.onfinish=()=>{v=()=>r,f==null||f(r,1-r),o()}},{abort:()=>{g&&(g.cancel(),g.effect=null,g.onfinish=Tn)},deactivate:()=>{o=Tn},reset:()=>{r===0&&(f==null||f(1,0))},t:()=>v()}}function Tr(t,e,n){gd(()=>{var r=At(()=>e(t,n==null?void 0:n())||{});if(n&&(r!=null&&r.update)){var i=!1,o={};vd(()=>{var s=n();N6(s),i&&J2(o,s)&&(o=s,r.update(s))}),i=!0}if(r!=null&&r.destroy)return()=>r.destroy()})}function z_(t){var e,n,r="";if(typeof t=="string"||typeof t=="number")r+=t;else if(typeof t=="object")if(Array.isArray(t)){var i=t.length;for(e=0;e<i;e++)t[e]&&(n=z_(t[e]))&&(r&&(r+=" "),r+=n)}else for(n in t)t[n]&&(r&&(r+=" "),r+=n);return r}function eM(){for(var t,e,n=0,r="",i=arguments.length;n<i;n++)(t=arguments[n])&&(e=z_(t))&&(r&&(r+=" "),r+=e);return r}function D0(t){return typeof t=="object"?eM(t):t??""}const Dy=[...`
3
+ \r\f \v\uFEFF`];function tM(t,e,n){var r=t==null?"":""+t;if(e&&(r=r?r+" "+e:e),n){for(var i of Object.keys(n))if(n[i])r=r?r+" "+i:i;else if(r.length)for(var o=i.length,s=0;(s=r.indexOf(i,s))>=0;){var a=s+o;(s===0||Dy.includes(r[s-1]))&&(a===r.length||Dy.includes(r[a]))?r=(s===0?"":r.substring(0,s))+r.substring(a+1):s=a}}return r===""?null:r}function nM(t,e){return t==null?null:String(t)}function yt(t,e,n,r,i,o){var s=t[p0];if(s!==n||s===void 0){var a=tM(n,r,o);a==null?t.removeAttribute("class"):t.className=a,t[p0]=n}else if(o&&i!==o)for(var l in o){var c=!!o[l];(i==null||c!==!!i[l])&&t.classList.toggle(l,c)}return o}function Me(t,e,n,r){var i=t[m0];if(i!==e){var o=nM(e);o==null?t.removeAttribute("style"):t.style.cssText=o,t[m0]=e}return r}function zp(t,e,n=!1){if(t.multiple){if(e==null)return;if(!ab(e))return e6();for(var r of t.options)r.selected=e.includes(Yc(r));return}for(r of t.options){var i=Yc(r);if(x6(i,e)){r.selected=!0;return}}(!n||e!==void 0)&&(t.selectedIndex=-1)}function xb(t){var e=new MutationObserver(()=>{zp(t,t.__value)});e.observe(t,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["value"]}),gb(()=>{e.disconnect()})}function rM(t,e,n=e){var r=new WeakSet,i=!0;pb(t,"change",o=>{var s=o?"[selected]":":checked",a;if(t.multiple)a=[].map.call(t.querySelectorAll(s),Yc);else{var l=t.querySelector(s)??t.querySelector("option:not([disabled])");a=l&&Yc(l)}n(a),t.__value=a,st!==null&&r.add(st)}),gd(()=>{var o=e();if(t===document.activeElement){var s=st;if(r.has(s))return}if(zp(t,o,i),i&&o===void 0){var a=t.querySelector(":checked");a!==null&&(o=Yc(a),n(o))}t.__value=o,i=!1}),xb(t)}function Yc(t){return"__value"in t?t.__value:t.value}const iM=Symbol("is custom element"),oM=Symbol("is html"),sM=E4?"progress":"PROGRESS";function Sr(t,e){var n=kb(t);n.value===(n.value=e??void 0)||t.value===e&&(e!==0||t.nodeName!==sM)||(t.value=e??"")}function Bn(t,e){var n=kb(t);n.checked!==(n.checked=e??void 0)&&(t.checked=e)}function V(t,e,n,r){var i=kb(t);i[e]!==(i[e]=n)&&(e==="loading"&&(t[S4]=n),n==null?t.removeAttribute(e):typeof n!="string"&&aM(t).includes(e)?t[e]=n:t.setAttribute(e,n))}function kb(t){return t[Mf]??(t[Mf]={[iM]:t.nodeName.includes("-"),[oM]:t.namespaceURI===Z2})}var Oy=new Map;function aM(t){var e=t.getAttribute("is")||t.nodeName,n=Oy.get(e);if(n)return n;Oy.set(e,n=[]);for(var r,i=t,o=Element.prototype;o!==i;){r=V2(i);for(var s in r)r[s].set&&s!=="innerHTML"&&s!=="textContent"&&s!=="innerText"&&n.push(s);i=lb(i)}return n}function Xn(t,e,n=e){var r=new WeakSet;pb(t,"input",async i=>{var o=i?t.defaultValue:t.value;if(o=Vm(t)?Um(o):o,n(o),st!==null&&r.add(st),await R6(),o!==(o=e())){var s=t.selectionStart,a=t.selectionEnd,l=t.value.length;if(t.value=o??"",a!==null){var c=t.value.length;s===a&&a===l&&c>l?(t.selectionStart=c,t.selectionEnd=c):(t.selectionStart=s,t.selectionEnd=Math.min(a,c))}}}),At(e)==null&&t.value&&(n(Vm(t)?Um(t.value):t.value),st!==null&&r.add(st)),vd(()=>{var i=e();if(t===document.activeElement){var o=st;if(r.has(o))return}Vm(t)&&i===Um(t.value)||t.type==="date"&&!i&&!t.value||i!==t.value&&(t.value=i??"")})}function Lf(t,e,n=e){pb(t,"change",r=>{var i=r?t.defaultChecked:t.checked;n(i)}),At(e)==null&&n(t.checked),vd(()=>{var r=e();t.checked=!!r})}function Vm(t){var e=t.type;return e==="number"||e==="range"}function Um(t){return t===""?null:+t}var hs,Rl,hd,Ip,B_;const Rp=class Rp{constructor(e){ft(this,Ip);ft(this,hs,new WeakMap);ft(this,Rl);ft(this,hd);pt(this,hd,e)}observe(e,n){var r=re(this,hs).get(e)||new Set;return r.add(n),re(this,hs).set(e,r),Nt(this,Ip,B_).call(this).observe(e,re(this,hd)),()=>{var i=re(this,hs).get(e);i.delete(n),i.size===0&&(re(this,hs).delete(e),re(this,Rl).unobserve(e))}}};hs=new WeakMap,Rl=new WeakMap,hd=new WeakMap,Ip=new WeakSet,B_=function(){return re(this,Rl)??pt(this,Rl,new ResizeObserver(e=>{for(var n of e){Rp.entries.set(n.target,n);for(var r of re(this,hs).get(n.target)||[])r(n)}}))},In(Rp,"entries",new WeakMap);let O0=Rp;var lM=new O0({box:"border-box"});function cM(t,e,n){var r=lM.observe(t,()=>n(t[e]));gd(()=>(At(()=>n(t[e])),r))}function jm(t,e){return t===e||(t==null?void 0:t[Qi])===e}function St(t={},e,n,r){var i=mn.r,o=Ct;return gd(()=>{var s,a;return vd(()=>{s=a,a=(r==null?void 0:r())||[],At(()=>{jm(n(...a),t)||(e(t,...a),s&&jm(n(...s),t)&&e(null,...s))})}),()=>{let l=o;for(;l!==i&&l.parent!==null&&l.parent.f&h0;)l=l.parent;const c=()=>{a&&jm(n(...a),t)&&e(null,...a)},u=l.teardown;l.teardown=()=>{c(),u==null||u()}}}),t}const uM={get(t,e){if(!t.exclude.includes(e))return t.props[e]},set(t,e){return!1},getOwnPropertyDescriptor(t,e){if(!t.exclude.includes(e)&&e in t.props)return{enumerable:!0,configurable:!0,value:t.props[e]}},has(t,e){return t.exclude.includes(e)?!1:e in t.props},ownKeys(t){return Reflect.ownKeys(t.props).filter(e=>!t.exclude.includes(e))}};function dM(t,e,n){return new Proxy({props:t,exclude:e},uM)}const fM={get(t,e){let n=t.props.length;for(;n--;){let r=t.props[n];if(Qa(r)&&(r=r()),typeof r=="object"&&r!==null&&e in r)return r[e]}},set(t,e,n){let r=t.props.length;for(;r--;){let i=t.props[r];Qa(i)&&(i=i());const o=ws(i,e);if(o&&o.set)return o.set(n),!0}return!1},getOwnPropertyDescriptor(t,e){let n=t.props.length;for(;n--;){let r=t.props[n];if(Qa(r)&&(r=r()),typeof r=="object"&&r!==null&&e in r){const i=ws(r,e);return i&&!i.configurable&&(i.configurable=!0),i}}},has(t,e){if(e===Qi||e===q2)return!1;for(let n of t.props)if(Qa(n)&&(n=n()),n!=null&&e in n)return!0;return!1},ownKeys(t){const e=[];for(let n of t.props)if(Qa(n)&&(n=n()),!!n){for(const r in n)e.includes(r)||e.push(r);for(const r of Object.getOwnPropertySymbols(n))e.includes(r)||e.push(r)}return e}};function Bc(...t){return new Proxy({props:t},fM)}function Ue(t,e,n,r){var C;var i=!ac||(n&j4)!==0,o=(n&W4)!==0,s=(n&K4)!==0,a=r,l=!0,c=void 0,u=()=>s&&i?(c??(c=gu(r)),d(c)):(l&&(l=!1,a=s?At(r):r),a);let f;if(o){var h=Qi in t||q2 in t;f=((C=ws(t,e))==null?void 0:C.set)??(h&&e in t?E=>t[e]=E:void 0)}var p,m=!1;o?[p,m]=s6(()=>t[e]):p=t[e],p===void 0&&r!==void 0&&(p=u(),f&&(i&&R4(),f(p)));var v;if(i?v=()=>{var E=t[e];return E===void 0?u():(l=!0,E)}:v=()=>{var E=t[e];return E!==void 0&&(a=void 0),E===void 0?a:E},i&&(n&q4)===0)return v;if(f){var g=t.$$legacy;return(function(E,I){return arguments.length>0?((!i||!I||g||m)&&f(I?v():E),E):v()})}var b=!1,_=((n&U4)!==0?gu:fb)(()=>(b=!1,v()));o&&d(_);var k=Ct;return(function(E,I){if(arguments.length>0){const A=I?d(_):i&&o?Qe(E):E;return y(_,A),b=!0,a!==void 0&&(a=A),E}return Vo&&b||(k.f&ui)!==0?_.v:d(_)})}function cc(t){mn===null&&W2(),ac&&mn.l!==null?hM(mn).m.push(t):he(()=>{const e=At(t);if(typeof e=="function")return e})}function gr(t){mn===null&&W2(),cc(()=>()=>At(t))}function hM(t){var e=t.l;return e.u??(e.u={a:[],b:[],m:[]})}const pM="5";var B2;typeof window<"u"&&((B2=window.__svelte??(window.__svelte={})).v??(B2.v=new Set)).add(pM);r6();const mM="modulepreload",gM=function(t){return"/"+t},Iy={},yn=function(e,n,r){let i=Promise.resolve();if(n&&n.length>0){let s=function(c){return Promise.all(c.map(u=>Promise.resolve(u).then(f=>({status:"fulfilled",value:f}),f=>({status:"rejected",reason:f}))))};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(n.map(c=>{if(c=gM(c),c in Iy)return;Iy[c]=!0;const u=c.endsWith(".css"),f=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${f}`))return;const h=document.createElement("link");if(h.rel=u?"stylesheet":mM,u||(h.as="script"),h.crossOrigin="",h.href=c,l&&h.setAttribute("nonce",l),document.head.appendChild(h),u)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)})},vM="upload://",H_="upload://scratchpad/";function el(t){return t.startsWith(vM)}function Bp(t){return t.startsWith(H_)}function V_(t){if(!Bp(t))return null;const n=t.slice(H_.length).split("/")[0];return n.length>0?n:null}const Ff=t=>t,Mn=t=>t;var Bt;(function(t){t.assertEqual=i=>{};function e(i){}t.assertIs=e;function n(i){throw new Error}t.assertNever=n,t.arrayToEnum=i=>{const o={};for(const s of i)o[s]=s;return o},t.getValidEnumValues=i=>{const o=t.objectKeys(i).filter(a=>typeof i[i[a]]!="number"),s={};for(const a of o)s[a]=i[a];return t.objectValues(s)},t.objectValues=i=>t.objectKeys(i).map(function(o){return i[o]}),t.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},t.find=(i,o)=>{for(const s of i)if(o(s))return s},t.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)}t.joinValues=r,t.jsonStringifyReplacer=(i,o)=>typeof o=="bigint"?o.toString():o})(Bt||(Bt={}));var Ry;(function(t){t.mergeShapes=(e,n)=>({...e,...n})})(Ry||(Ry={}));const Ze=Bt.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),$o=t=>{switch(typeof t){case"undefined":return Ze.undefined;case"string":return Ze.string;case"number":return Number.isNaN(t)?Ze.nan:Ze.number;case"boolean":return Ze.boolean;case"function":return Ze.function;case"bigint":return Ze.bigint;case"symbol":return Ze.symbol;case"object":return Array.isArray(t)?Ze.array:t===null?Ze.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?Ze.promise:typeof Map<"u"&&t instanceof Map?Ze.map:typeof Set<"u"&&t instanceof Set?Ze.set:typeof Date<"u"&&t instanceof Date?Ze.date:Ze.object;default:return Ze.unknown}},Pe=Bt.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 jo 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 n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=e}format(e){const n=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(n(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(n(s))):a[c]=a[c]||{_errors:[]},a=a[c],l++}}};return i(this),r}static assert(e){if(!(e instanceof jo))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Bt.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=n=>n.message){const n={},r=[];for(const i of this.issues)if(i.path.length>0){const o=i.path[0];n[o]=n[o]||[],n[o].push(e(i))}else r.push(e(i));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}}jo.create=t=>new jo(t);const I0=(t,e)=>{let n;switch(t.code){case Pe.invalid_type:t.received===Ze.undefined?n="Required":n=`Expected ${t.expected}, received ${t.received}`;break;case Pe.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(t.expected,Bt.jsonStringifyReplacer)}`;break;case Pe.unrecognized_keys:n=`Unrecognized key(s) in object: ${Bt.joinValues(t.keys,", ")}`;break;case Pe.invalid_union:n="Invalid input";break;case Pe.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${Bt.joinValues(t.options)}`;break;case Pe.invalid_enum_value:n=`Invalid enum value. Expected ${Bt.joinValues(t.options)}, received '${t.received}'`;break;case Pe.invalid_arguments:n="Invalid function arguments";break;case Pe.invalid_return_type:n="Invalid function return type";break;case Pe.invalid_date:n="Invalid date";break;case Pe.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(n=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?n=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?n=`Invalid input: must end with "${t.validation.endsWith}"`:Bt.assertNever(t.validation):t.validation!=="regex"?n=`Invalid ${t.validation}`:n="Invalid";break;case Pe.too_small:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:n="Invalid input";break;case Pe.too_big:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?n=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:n="Invalid input";break;case Pe.custom:n="Invalid input";break;case Pe.invalid_intersection_types:n="Intersection results could not be merged";break;case Pe.not_multiple_of:n=`Number must be a multiple of ${t.multipleOf}`;break;case Pe.not_finite:n="Number must be finite";break;default:n=e.defaultError,Bt.assertNever(t)}return{message:n}};let bM=I0;function yM(){return bM}const wM=t=>{const{data:e,path:n,errorMaps:r,issueData:i}=t,o=[...n,...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 Be(t,e){const n=yM(),r=wM({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,n,n===I0?void 0:I0].filter(i=>!!i)});t.common.issues.push(r)}class qr{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,n){const r=[];for(const i of n){if(i.status==="aborted")return mt;i.status==="dirty"&&e.dirty(),r.push(i.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,n){const r=[];for(const i of n){const o=await i.key,s=await i.value;r.push({key:o,value:s})}return qr.mergeObjectSync(e,r)}static mergeObjectSync(e,n){const r={};for(const i of n){const{key:o,value:s}=i;if(o.status==="aborted"||s.status==="aborted")return mt;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 mt=Object.freeze({status:"aborted"}),Hc=t=>({status:"dirty",value:t}),vi=t=>({status:"valid",value:t}),Ny=t=>t.status==="aborted",Py=t=>t.status==="dirty",Bl=t=>t.status==="valid",lh=t=>typeof Promise<"u"&&t instanceof Promise;var Je;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(Je||(Je={}));class Ts{constructor(e,n,r,i){this._cachedPath=[],this.parent=e,this.data=n,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 Ly=(t,e)=>{if(Bl(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const n=new jo(t.common.issues);return this._error=n,this._error}}};function Tt(t){if(!t)return{};const{errorMap:e,invalid_type_error:n,required_error:r,description:i}=t;if(e&&(n||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}=t;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??n??a.defaultError}},description:i}}class zt{get description(){return this._def.description}_getType(e){return $o(e.data)}_getOrReturnCtx(e,n){return n||{common:e.parent.common,data:e.data,parsedType:$o(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new qr,ctx:{common:e.parent.common,data:e.data,parsedType:$o(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const n=this._parse(e);if(lh(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(e){const n=this._parse(e);return Promise.resolve(n)}parse(e,n){const r=this.safeParse(e,n);if(r.success)return r.data;throw r.error}safeParse(e,n){const r={common:{issues:[],async:(n==null?void 0:n.async)??!1,contextualErrorMap:n==null?void 0:n.errorMap},path:(n==null?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:$o(e)},i=this._parseSync({data:e,path:r.path,parent:r});return Ly(r,i)}"~validate"(e){var r,i;const n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:$o(e)};if(!this["~standard"].async)try{const o=this._parseSync({data:e,path:[],parent:n});return Bl(o)?{value:o.value}:{issues:n.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),n.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:n}).then(o=>Bl(o)?{value:o.value}:{issues:n.common.issues})}async parseAsync(e,n){const r=await this.safeParseAsync(e,n);if(r.success)return r.data;throw r.error}async safeParseAsync(e,n){const r={common:{issues:[],contextualErrorMap:n==null?void 0:n.errorMap,async:!0},path:(n==null?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:$o(e)},i=this._parse({data:e,path:r.path,parent:r}),o=await(lh(i)?i:Promise.resolve(i));return Ly(r,o)}refine(e,n){const r=i=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(i):n;return this._refinement((i,o)=>{const s=e(i),a=()=>o.addIssue({code:Pe.custom,...r(i)});return typeof Promise<"u"&&s instanceof Promise?s.then(l=>l?!0:(a(),!1)):s?!0:(a(),!1)})}refinement(e,n){return this._refinement((r,i)=>e(r)?!0:(i.addIssue(typeof n=="function"?n(r,i):n),!1))}_refinement(e){return new Vl({schema:this,typeName:gt.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:n=>this["~validate"](n)}}optional(){return ks.create(this,this._def)}nullable(){return Ul.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return $i.create(this)}promise(){return fh.create(this,this._def)}or(e){return uh.create([this,e],this._def)}and(e){return dh.create(this,e,this._def)}transform(e){return new Vl({...Tt(this._def),schema:this,typeName:gt.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const n=typeof e=="function"?e:()=>e;return new N0({...Tt(this._def),innerType:this,defaultValue:n,typeName:gt.ZodDefault})}brand(){return new jM({typeName:gt.ZodBranded,type:this,...Tt(this._def)})}catch(e){const n=typeof e=="function"?e:()=>e;return new P0({...Tt(this._def),innerType:this,catchValue:n,typeName:gt.ZodCatch})}describe(e){const n=this.constructor;return new n({...this._def,description:e})}pipe(e){return _b.create(this,e)}readonly(){return L0.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const xM=/^c[^\s-]{8,}$/i,kM=/^[0-9a-z]+$/,_M=/^[0-9A-HJKMNP-TV-Z]{26}$/i,CM=/^[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,SM=/^[a-z0-9_-]{21}$/i,EM=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,AM=/^[-+]?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)?)??$/,TM=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,MM="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let qm;const DM=/^(?:(?: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])$/,OM=/^(?:(?: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])$/,IM=/^(([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]))$/,RM=/^(([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])$/,NM=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,PM=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,U_="((\\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])))",LM=new RegExp(`^${U_}$`);function j_(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);const n=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${n}`}function FM(t){return new RegExp(`^${j_(t)}$`)}function zM(t){let e=`${U_}T${j_(t)}`;const n=[];return n.push(t.local?"Z?":"Z"),t.offset&&n.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${n.join("|")})`,new RegExp(`^${e}$`)}function BM(t,e){return!!((e==="v4"||!e)&&DM.test(t)||(e==="v6"||!e)&&IM.test(t))}function HM(t,e){if(!EM.test(t))return!1;try{const[n]=t.split(".");if(!n)return!1;const r=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.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 VM(t,e){return!!((e==="v4"||!e)&&OM.test(t)||(e==="v6"||!e)&&RM.test(t))}class ta extends zt{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==Ze.string){const o=this._getOrReturnCtx(e);return Be(o,{code:Pe.invalid_type,expected:Ze.string,received:o.parsedType}),mt}const r=new qr;let i;for(const o of this._def.checks)if(o.kind==="min")e.data.length<o.value&&(i=this._getOrReturnCtx(e,i),Be(i,{code:Pe.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),Be(i,{code:Pe.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?Be(i,{code:Pe.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}):a&&Be(i,{code:Pe.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}),r.dirty())}else if(o.kind==="email")TM.test(e.data)||(i=this._getOrReturnCtx(e,i),Be(i,{validation:"email",code:Pe.invalid_string,message:o.message}),r.dirty());else if(o.kind==="emoji")qm||(qm=new RegExp(MM,"u")),qm.test(e.data)||(i=this._getOrReturnCtx(e,i),Be(i,{validation:"emoji",code:Pe.invalid_string,message:o.message}),r.dirty());else if(o.kind==="uuid")CM.test(e.data)||(i=this._getOrReturnCtx(e,i),Be(i,{validation:"uuid",code:Pe.invalid_string,message:o.message}),r.dirty());else if(o.kind==="nanoid")SM.test(e.data)||(i=this._getOrReturnCtx(e,i),Be(i,{validation:"nanoid",code:Pe.invalid_string,message:o.message}),r.dirty());else if(o.kind==="cuid")xM.test(e.data)||(i=this._getOrReturnCtx(e,i),Be(i,{validation:"cuid",code:Pe.invalid_string,message:o.message}),r.dirty());else if(o.kind==="cuid2")kM.test(e.data)||(i=this._getOrReturnCtx(e,i),Be(i,{validation:"cuid2",code:Pe.invalid_string,message:o.message}),r.dirty());else if(o.kind==="ulid")_M.test(e.data)||(i=this._getOrReturnCtx(e,i),Be(i,{validation:"ulid",code:Pe.invalid_string,message:o.message}),r.dirty());else if(o.kind==="url")try{new URL(e.data)}catch{i=this._getOrReturnCtx(e,i),Be(i,{validation:"url",code:Pe.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),Be(i,{validation:"regex",code:Pe.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),Be(i,{code:Pe.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),Be(i,{code:Pe.invalid_string,validation:{startsWith:o.value},message:o.message}),r.dirty()):o.kind==="endsWith"?e.data.endsWith(o.value)||(i=this._getOrReturnCtx(e,i),Be(i,{code:Pe.invalid_string,validation:{endsWith:o.value},message:o.message}),r.dirty()):o.kind==="datetime"?zM(o).test(e.data)||(i=this._getOrReturnCtx(e,i),Be(i,{code:Pe.invalid_string,validation:"datetime",message:o.message}),r.dirty()):o.kind==="date"?LM.test(e.data)||(i=this._getOrReturnCtx(e,i),Be(i,{code:Pe.invalid_string,validation:"date",message:o.message}),r.dirty()):o.kind==="time"?FM(o).test(e.data)||(i=this._getOrReturnCtx(e,i),Be(i,{code:Pe.invalid_string,validation:"time",message:o.message}),r.dirty()):o.kind==="duration"?AM.test(e.data)||(i=this._getOrReturnCtx(e,i),Be(i,{validation:"duration",code:Pe.invalid_string,message:o.message}),r.dirty()):o.kind==="ip"?BM(e.data,o.version)||(i=this._getOrReturnCtx(e,i),Be(i,{validation:"ip",code:Pe.invalid_string,message:o.message}),r.dirty()):o.kind==="jwt"?HM(e.data,o.alg)||(i=this._getOrReturnCtx(e,i),Be(i,{validation:"jwt",code:Pe.invalid_string,message:o.message}),r.dirty()):o.kind==="cidr"?VM(e.data,o.version)||(i=this._getOrReturnCtx(e,i),Be(i,{validation:"cidr",code:Pe.invalid_string,message:o.message}),r.dirty()):o.kind==="base64"?NM.test(e.data)||(i=this._getOrReturnCtx(e,i),Be(i,{validation:"base64",code:Pe.invalid_string,message:o.message}),r.dirty()):o.kind==="base64url"?PM.test(e.data)||(i=this._getOrReturnCtx(e,i),Be(i,{validation:"base64url",code:Pe.invalid_string,message:o.message}),r.dirty()):Bt.assertNever(o);return{status:r.value,value:e.data}}_regex(e,n,r){return this.refinement(i=>e.test(i),{validation:n,code:Pe.invalid_string,...Je.errToObj(r)})}_addCheck(e){return new ta({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...Je.errToObj(e)})}url(e){return this._addCheck({kind:"url",...Je.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...Je.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...Je.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...Je.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...Je.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...Je.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...Je.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...Je.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...Je.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...Je.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...Je.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...Je.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,...Je.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,...Je.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...Je.errToObj(e)})}regex(e,n){return this._addCheck({kind:"regex",regex:e,...Je.errToObj(n)})}includes(e,n){return this._addCheck({kind:"includes",value:e,position:n==null?void 0:n.position,...Je.errToObj(n==null?void 0:n.message)})}startsWith(e,n){return this._addCheck({kind:"startsWith",value:e,...Je.errToObj(n)})}endsWith(e,n){return this._addCheck({kind:"endsWith",value:e,...Je.errToObj(n)})}min(e,n){return this._addCheck({kind:"min",value:e,...Je.errToObj(n)})}max(e,n){return this._addCheck({kind:"max",value:e,...Je.errToObj(n)})}length(e,n){return this._addCheck({kind:"length",value:e,...Je.errToObj(n)})}nonempty(e){return this.min(1,Je.errToObj(e))}trim(){return new ta({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new ta({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new ta({...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 n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxLength(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}}ta.create=t=>new ta({checks:[],typeName:gt.ZodString,coerce:(t==null?void 0:t.coerce)??!1,...Tt(t)});function UM(t,e){const n=(t.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,i=n>r?n:r,o=Number.parseInt(t.toFixed(i).replace(".","")),s=Number.parseInt(e.toFixed(i).replace(".",""));return o%s/10**i}class wu extends zt{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)!==Ze.number){const o=this._getOrReturnCtx(e);return Be(o,{code:Pe.invalid_type,expected:Ze.number,received:o.parsedType}),mt}let r;const i=new qr;for(const o of this._def.checks)o.kind==="int"?Bt.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),Be(r,{code:Pe.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),Be(r,{code:Pe.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),Be(r,{code:Pe.too_big,maximum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),i.dirty()):o.kind==="multipleOf"?UM(e.data,o.value)!==0&&(r=this._getOrReturnCtx(e,r),Be(r,{code:Pe.not_multiple_of,multipleOf:o.value,message:o.message}),i.dirty()):o.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),Be(r,{code:Pe.not_finite,message:o.message}),i.dirty()):Bt.assertNever(o);return{status:i.value,value:e.data}}gte(e,n){return this.setLimit("min",e,!0,Je.toString(n))}gt(e,n){return this.setLimit("min",e,!1,Je.toString(n))}lte(e,n){return this.setLimit("max",e,!0,Je.toString(n))}lt(e,n){return this.setLimit("max",e,!1,Je.toString(n))}setLimit(e,n,r,i){return new wu({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:Je.toString(i)}]})}_addCheck(e){return new wu({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:Je.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Je.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Je.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Je.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Je.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:Je.toString(n)})}finite(e){return this._addCheck({kind:"finite",message:Je.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Je.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Je.toString(e)})}get minValue(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&Bt.isInteger(e.value))}get isFinite(){let e=null,n=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(n===null||r.value>n)&&(n=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value)}return Number.isFinite(n)&&Number.isFinite(e)}}wu.create=t=>new wu({checks:[],typeName:gt.ZodNumber,coerce:(t==null?void 0:t.coerce)||!1,...Tt(t)});class xu extends zt{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)!==Ze.bigint)return this._getInvalidInput(e);let r;const i=new qr;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),Be(r,{code:Pe.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),Be(r,{code:Pe.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),Be(r,{code:Pe.not_multiple_of,multipleOf:o.value,message:o.message}),i.dirty()):Bt.assertNever(o);return{status:i.value,value:e.data}}_getInvalidInput(e){const n=this._getOrReturnCtx(e);return Be(n,{code:Pe.invalid_type,expected:Ze.bigint,received:n.parsedType}),mt}gte(e,n){return this.setLimit("min",e,!0,Je.toString(n))}gt(e,n){return this.setLimit("min",e,!1,Je.toString(n))}lte(e,n){return this.setLimit("max",e,!0,Je.toString(n))}lt(e,n){return this.setLimit("max",e,!1,Je.toString(n))}setLimit(e,n,r,i){return new xu({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:Je.toString(i)}]})}_addCheck(e){return new xu({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Je.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Je.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Je.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Je.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:Je.toString(n)})}get minValue(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}}xu.create=t=>new xu({checks:[],typeName:gt.ZodBigInt,coerce:(t==null?void 0:t.coerce)??!1,...Tt(t)});class Fy extends zt{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==Ze.boolean){const r=this._getOrReturnCtx(e);return Be(r,{code:Pe.invalid_type,expected:Ze.boolean,received:r.parsedType}),mt}return vi(e.data)}}Fy.create=t=>new Fy({typeName:gt.ZodBoolean,coerce:(t==null?void 0:t.coerce)||!1,...Tt(t)});class ch extends zt{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==Ze.date){const o=this._getOrReturnCtx(e);return Be(o,{code:Pe.invalid_type,expected:Ze.date,received:o.parsedType}),mt}if(Number.isNaN(e.data.getTime())){const o=this._getOrReturnCtx(e);return Be(o,{code:Pe.invalid_date}),mt}const r=new qr;let i;for(const o of this._def.checks)o.kind==="min"?e.data.getTime()<o.value&&(i=this._getOrReturnCtx(e,i),Be(i,{code:Pe.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),Be(i,{code:Pe.too_big,message:o.message,inclusive:!0,exact:!1,maximum:o.value,type:"date"}),r.dirty()):Bt.assertNever(o);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new ch({...this._def,checks:[...this._def.checks,e]})}min(e,n){return this._addCheck({kind:"min",value:e.getTime(),message:Je.toString(n)})}max(e,n){return this._addCheck({kind:"max",value:e.getTime(),message:Je.toString(n)})}get minDate(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e!=null?new Date(e):null}}ch.create=t=>new ch({checks:[],coerce:(t==null?void 0:t.coerce)||!1,typeName:gt.ZodDate,...Tt(t)});class zy extends zt{_parse(e){if(this._getType(e)!==Ze.symbol){const r=this._getOrReturnCtx(e);return Be(r,{code:Pe.invalid_type,expected:Ze.symbol,received:r.parsedType}),mt}return vi(e.data)}}zy.create=t=>new zy({typeName:gt.ZodSymbol,...Tt(t)});class By extends zt{_parse(e){if(this._getType(e)!==Ze.undefined){const r=this._getOrReturnCtx(e);return Be(r,{code:Pe.invalid_type,expected:Ze.undefined,received:r.parsedType}),mt}return vi(e.data)}}By.create=t=>new By({typeName:gt.ZodUndefined,...Tt(t)});class Hy extends zt{_parse(e){if(this._getType(e)!==Ze.null){const r=this._getOrReturnCtx(e);return Be(r,{code:Pe.invalid_type,expected:Ze.null,received:r.parsedType}),mt}return vi(e.data)}}Hy.create=t=>new Hy({typeName:gt.ZodNull,...Tt(t)});class Vy extends zt{constructor(){super(...arguments),this._any=!0}_parse(e){return vi(e.data)}}Vy.create=t=>new Vy({typeName:gt.ZodAny,...Tt(t)});class Uy extends zt{constructor(){super(...arguments),this._unknown=!0}_parse(e){return vi(e.data)}}Uy.create=t=>new Uy({typeName:gt.ZodUnknown,...Tt(t)});class Ms extends zt{_parse(e){const n=this._getOrReturnCtx(e);return Be(n,{code:Pe.invalid_type,expected:Ze.never,received:n.parsedType}),mt}}Ms.create=t=>new Ms({typeName:gt.ZodNever,...Tt(t)});class jy extends zt{_parse(e){if(this._getType(e)!==Ze.undefined){const r=this._getOrReturnCtx(e);return Be(r,{code:Pe.invalid_type,expected:Ze.void,received:r.parsedType}),mt}return vi(e.data)}}jy.create=t=>new jy({typeName:gt.ZodVoid,...Tt(t)});class $i extends zt{_parse(e){const{ctx:n,status:r}=this._processInputParams(e),i=this._def;if(n.parsedType!==Ze.array)return Be(n,{code:Pe.invalid_type,expected:Ze.array,received:n.parsedType}),mt;if(i.exactLength!==null){const s=n.data.length>i.exactLength.value,a=n.data.length<i.exactLength.value;(s||a)&&(Be(n,{code:s?Pe.too_big:Pe.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&&n.data.length<i.minLength.value&&(Be(n,{code:Pe.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),r.dirty()),i.maxLength!==null&&n.data.length>i.maxLength.value&&(Be(n,{code:Pe.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((s,a)=>i.type._parseAsync(new Ts(n,s,n.path,a)))).then(s=>qr.mergeArray(r,s));const o=[...n.data].map((s,a)=>i.type._parseSync(new Ts(n,s,n.path,a)));return qr.mergeArray(r,o)}get element(){return this._def.type}min(e,n){return new $i({...this._def,minLength:{value:e,message:Je.toString(n)}})}max(e,n){return new $i({...this._def,maxLength:{value:e,message:Je.toString(n)}})}length(e,n){return new $i({...this._def,exactLength:{value:e,message:Je.toString(n)}})}nonempty(e){return this.min(1,e)}}$i.create=(t,e)=>new $i({type:t,minLength:null,maxLength:null,exactLength:null,typeName:gt.ZodArray,...Tt(e)});function tl(t){if(t instanceof An){const e={};for(const n in t.shape){const r=t.shape[n];e[n]=ks.create(tl(r))}return new An({...t._def,shape:()=>e})}else return t instanceof $i?new $i({...t._def,type:tl(t.element)}):t instanceof ks?ks.create(tl(t.unwrap())):t instanceof Ul?Ul.create(tl(t.unwrap())):t instanceof Ca?Ca.create(t.items.map(e=>tl(e))):t}class An extends zt{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(),n=Bt.objectKeys(e);return this._cached={shape:e,keys:n},this._cached}_parse(e){if(this._getType(e)!==Ze.object){const c=this._getOrReturnCtx(e);return Be(c,{code:Pe.invalid_type,expected:Ze.object,received:c.parsedType}),mt}const{status:r,ctx:i}=this._processInputParams(e),{shape:o,keys:s}=this._getCached(),a=[];if(!(this._def.catchall instanceof Ms&&this._def.unknownKeys==="strip"))for(const c in i.data)s.includes(c)||a.push(c);const l=[];for(const c of s){const u=o[c],f=i.data[c];l.push({key:{status:"valid",value:c},value:u._parse(new Ts(i,f,i.path,c)),alwaysSet:c in i.data})}if(this._def.catchall instanceof Ms){const c=this._def.unknownKeys;if(c==="passthrough")for(const u of a)l.push({key:{status:"valid",value:u},value:{status:"valid",value:i.data[u]}});else if(c==="strict")a.length>0&&(Be(i,{code:Pe.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 u of a){const f=i.data[u];l.push({key:{status:"valid",value:u},value:c._parse(new Ts(i,f,i.path,u)),alwaysSet:u in i.data})}}return i.common.async?Promise.resolve().then(async()=>{const c=[];for(const u of l){const f=await u.key,h=await u.value;c.push({key:f,value:h,alwaysSet:u.alwaysSet})}return c}).then(c=>qr.mergeObjectSync(r,c)):qr.mergeObjectSync(r,l)}get shape(){return this._def.shape()}strict(e){return Je.errToObj,new An({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(n,r)=>{var o,s;const i=((s=(o=this._def).errorMap)==null?void 0:s.call(o,n,r).message)??r.defaultError;return n.code==="unrecognized_keys"?{message:Je.errToObj(e).message??i}:{message:i}}}:{}})}strip(){return new An({...this._def,unknownKeys:"strip"})}passthrough(){return new An({...this._def,unknownKeys:"passthrough"})}extend(e){return new An({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new An({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:gt.ZodObject})}setKey(e,n){return this.augment({[e]:n})}catchall(e){return new An({...this._def,catchall:e})}pick(e){const n={};for(const r of Bt.objectKeys(e))e[r]&&this.shape[r]&&(n[r]=this.shape[r]);return new An({...this._def,shape:()=>n})}omit(e){const n={};for(const r of Bt.objectKeys(this.shape))e[r]||(n[r]=this.shape[r]);return new An({...this._def,shape:()=>n})}deepPartial(){return tl(this)}partial(e){const n={};for(const r of Bt.objectKeys(this.shape)){const i=this.shape[r];e&&!e[r]?n[r]=i:n[r]=i.optional()}return new An({...this._def,shape:()=>n})}required(e){const n={};for(const r of Bt.objectKeys(this.shape))if(e&&!e[r])n[r]=this.shape[r];else{let o=this.shape[r];for(;o instanceof ks;)o=o._def.innerType;n[r]=o}return new An({...this._def,shape:()=>n})}keyof(){return q_(Bt.objectKeys(this.shape))}}An.create=(t,e)=>new An({shape:()=>t,unknownKeys:"strip",catchall:Ms.create(),typeName:gt.ZodObject,...Tt(e)});An.strictCreate=(t,e)=>new An({shape:()=>t,unknownKeys:"strict",catchall:Ms.create(),typeName:gt.ZodObject,...Tt(e)});An.lazycreate=(t,e)=>new An({shape:t,unknownKeys:"strip",catchall:Ms.create(),typeName:gt.ZodObject,...Tt(e)});class uh extends zt{_parse(e){const{ctx:n}=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 n.common.issues.push(...a.ctx.common.issues),a.result;const s=o.map(a=>new jo(a.ctx.common.issues));return Be(n,{code:Pe.invalid_union,unionErrors:s}),mt}if(n.common.async)return Promise.all(r.map(async o=>{const s={...n,common:{...n.common,issues:[]},parent:null};return{result:await o._parseAsync({data:n.data,path:n.path,parent:s}),ctx:s}})).then(i);{let o;const s=[];for(const l of r){const c={...n,common:{...n.common,issues:[]},parent:null},u=l._parseSync({data:n.data,path:n.path,parent:c});if(u.status==="valid")return u;u.status==="dirty"&&!o&&(o={result:u,ctx:c}),c.common.issues.length&&s.push(c.common.issues)}if(o)return n.common.issues.push(...o.ctx.common.issues),o.result;const a=s.map(l=>new jo(l));return Be(n,{code:Pe.invalid_union,unionErrors:a}),mt}}get options(){return this._def.options}}uh.create=(t,e)=>new uh({options:t,typeName:gt.ZodUnion,...Tt(e)});function R0(t,e){const n=$o(t),r=$o(e);if(t===e)return{valid:!0,data:t};if(n===Ze.object&&r===Ze.object){const i=Bt.objectKeys(e),o=Bt.objectKeys(t).filter(a=>i.indexOf(a)!==-1),s={...t,...e};for(const a of o){const l=R0(t[a],e[a]);if(!l.valid)return{valid:!1};s[a]=l.data}return{valid:!0,data:s}}else if(n===Ze.array&&r===Ze.array){if(t.length!==e.length)return{valid:!1};const i=[];for(let o=0;o<t.length;o++){const s=t[o],a=e[o],l=R0(s,a);if(!l.valid)return{valid:!1};i.push(l.data)}return{valid:!0,data:i}}else return n===Ze.date&&r===Ze.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}class dh extends zt{_parse(e){const{status:n,ctx:r}=this._processInputParams(e),i=(o,s)=>{if(Ny(o)||Ny(s))return mt;const a=R0(o.value,s.value);return a.valid?((Py(o)||Py(s))&&n.dirty(),{status:n.value,value:a.data}):(Be(r,{code:Pe.invalid_intersection_types}),mt)};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}))}}dh.create=(t,e,n)=>new dh({left:t,right:e,typeName:gt.ZodIntersection,...Tt(n)});class Ca extends zt{_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==Ze.array)return Be(r,{code:Pe.invalid_type,expected:Ze.array,received:r.parsedType}),mt;if(r.data.length<this._def.items.length)return Be(r,{code:Pe.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),mt;!this._def.rest&&r.data.length>this._def.items.length&&(Be(r,{code:Pe.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());const o=[...r.data].map((s,a)=>{const l=this._def.items[a]||this._def.rest;return l?l._parse(new Ts(r,s,r.path,a)):null}).filter(s=>!!s);return r.common.async?Promise.all(o).then(s=>qr.mergeArray(n,s)):qr.mergeArray(n,o)}get items(){return this._def.items}rest(e){return new Ca({...this._def,rest:e})}}Ca.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Ca({items:t,typeName:gt.ZodTuple,rest:null,...Tt(e)})};class qy extends zt{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==Ze.map)return Be(r,{code:Pe.invalid_type,expected:Ze.map,received:r.parsedType}),mt;const i=this._def.keyType,o=this._def.valueType,s=[...r.data.entries()].map(([a,l],c)=>({key:i._parse(new Ts(r,a,r.path,[c,"key"])),value:o._parse(new Ts(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,u=await l.value;if(c.status==="aborted"||u.status==="aborted")return mt;(c.status==="dirty"||u.status==="dirty")&&n.dirty(),a.set(c.value,u.value)}return{status:n.value,value:a}})}else{const a=new Map;for(const l of s){const c=l.key,u=l.value;if(c.status==="aborted"||u.status==="aborted")return mt;(c.status==="dirty"||u.status==="dirty")&&n.dirty(),a.set(c.value,u.value)}return{status:n.value,value:a}}}}qy.create=(t,e,n)=>new qy({valueType:e,keyType:t,typeName:gt.ZodMap,...Tt(n)});class ku extends zt{_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==Ze.set)return Be(r,{code:Pe.invalid_type,expected:Ze.set,received:r.parsedType}),mt;const i=this._def;i.minSize!==null&&r.data.size<i.minSize.value&&(Be(r,{code:Pe.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),n.dirty()),i.maxSize!==null&&r.data.size>i.maxSize.value&&(Be(r,{code:Pe.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),n.dirty());const o=this._def.valueType;function s(l){const c=new Set;for(const u of l){if(u.status==="aborted")return mt;u.status==="dirty"&&n.dirty(),c.add(u.value)}return{status:n.value,value:c}}const a=[...r.data.values()].map((l,c)=>o._parse(new Ts(r,l,r.path,c)));return r.common.async?Promise.all(a).then(l=>s(l)):s(a)}min(e,n){return new ku({...this._def,minSize:{value:e,message:Je.toString(n)}})}max(e,n){return new ku({...this._def,maxSize:{value:e,message:Je.toString(n)}})}size(e,n){return this.min(e,n).max(e,n)}nonempty(e){return this.min(1,e)}}ku.create=(t,e)=>new ku({valueType:t,minSize:null,maxSize:null,typeName:gt.ZodSet,...Tt(e)});class Wy extends zt{get schema(){return this._def.getter()}_parse(e){const{ctx:n}=this._processInputParams(e);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}}Wy.create=(t,e)=>new Wy({getter:t,typeName:gt.ZodLazy,...Tt(e)});class Ky extends zt{_parse(e){if(e.data!==this._def.value){const n=this._getOrReturnCtx(e);return Be(n,{received:n.data,code:Pe.invalid_literal,expected:this._def.value}),mt}return{status:"valid",value:e.data}}get value(){return this._def.value}}Ky.create=(t,e)=>new Ky({value:t,typeName:gt.ZodLiteral,...Tt(e)});function q_(t,e){return new Hl({values:t,typeName:gt.ZodEnum,...Tt(e)})}class Hl extends zt{_parse(e){if(typeof e.data!="string"){const n=this._getOrReturnCtx(e),r=this._def.values;return Be(n,{expected:Bt.joinValues(r),received:n.parsedType,code:Pe.invalid_type}),mt}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const n=this._getOrReturnCtx(e),r=this._def.values;return Be(n,{received:n.data,code:Pe.invalid_enum_value,options:r}),mt}return vi(e.data)}get options(){return this._def.values}get enum(){const e={};for(const n of this._def.values)e[n]=n;return e}get Values(){const e={};for(const n of this._def.values)e[n]=n;return e}get Enum(){const e={};for(const n of this._def.values)e[n]=n;return e}extract(e,n=this._def){return Hl.create(e,{...this._def,...n})}exclude(e,n=this._def){return Hl.create(this.options.filter(r=>!e.includes(r)),{...this._def,...n})}}Hl.create=q_;class Gy extends zt{_parse(e){const n=Bt.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==Ze.string&&r.parsedType!==Ze.number){const i=Bt.objectValues(n);return Be(r,{expected:Bt.joinValues(i),received:r.parsedType,code:Pe.invalid_type}),mt}if(this._cache||(this._cache=new Set(Bt.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const i=Bt.objectValues(n);return Be(r,{received:r.data,code:Pe.invalid_enum_value,options:i}),mt}return vi(e.data)}get enum(){return this._def.values}}Gy.create=(t,e)=>new Gy({values:t,typeName:gt.ZodNativeEnum,...Tt(e)});class fh extends zt{unwrap(){return this._def.type}_parse(e){const{ctx:n}=this._processInputParams(e);if(n.parsedType!==Ze.promise&&n.common.async===!1)return Be(n,{code:Pe.invalid_type,expected:Ze.promise,received:n.parsedType}),mt;const r=n.parsedType===Ze.promise?n.data:Promise.resolve(n.data);return vi(r.then(i=>this._def.type.parseAsync(i,{path:n.path,errorMap:n.common.contextualErrorMap})))}}fh.create=(t,e)=>new fh({type:t,typeName:gt.ZodPromise,...Tt(e)});class Vl extends zt{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===gt.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:n,ctx:r}=this._processInputParams(e),i=this._def.effect||null,o={addIssue:s=>{Be(r,s),s.fatal?n.abort():n.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(n.value==="aborted")return mt;const l=await this._def.schema._parseAsync({data:a,path:r.path,parent:r});return l.status==="aborted"?mt:l.status==="dirty"||n.value==="dirty"?Hc(l.value):l});{if(n.value==="aborted")return mt;const a=this._def.schema._parseSync({data:s,path:r.path,parent:r});return a.status==="aborted"?mt:a.status==="dirty"||n.value==="dirty"?Hc(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"?mt:(a.status==="dirty"&&n.dirty(),s(a.value),{status:n.value,value:a.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(a=>a.status==="aborted"?mt:(a.status==="dirty"&&n.dirty(),s(a.value).then(()=>({status:n.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(!Bl(s))return mt;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:n.value,value:a}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(s=>Bl(s)?Promise.resolve(i.transform(s.value,o)).then(a=>({status:n.value,value:a})):mt);Bt.assertNever(i)}}Vl.create=(t,e,n)=>new Vl({schema:t,typeName:gt.ZodEffects,effect:e,...Tt(n)});Vl.createWithPreprocess=(t,e,n)=>new Vl({schema:e,effect:{type:"preprocess",transform:t},typeName:gt.ZodEffects,...Tt(n)});class ks extends zt{_parse(e){return this._getType(e)===Ze.undefined?vi(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}ks.create=(t,e)=>new ks({innerType:t,typeName:gt.ZodOptional,...Tt(e)});class Ul extends zt{_parse(e){return this._getType(e)===Ze.null?vi(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Ul.create=(t,e)=>new Ul({innerType:t,typeName:gt.ZodNullable,...Tt(e)});class N0 extends zt{_parse(e){const{ctx:n}=this._processInputParams(e);let r=n.data;return n.parsedType===Ze.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}}N0.create=(t,e)=>new N0({innerType:t,typeName:gt.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...Tt(e)});class P0 extends zt{_parse(e){const{ctx:n}=this._processInputParams(e),r={...n,common:{...n.common,issues:[]}},i=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return lh(i)?i.then(o=>({status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new jo(r.common.issues)},input:r.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new jo(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}P0.create=(t,e)=>new P0({innerType:t,typeName:gt.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...Tt(e)});class Zy extends zt{_parse(e){if(this._getType(e)!==Ze.nan){const r=this._getOrReturnCtx(e);return Be(r,{code:Pe.invalid_type,expected:Ze.nan,received:r.parsedType}),mt}return{status:"valid",value:e.data}}}Zy.create=t=>new Zy({typeName:gt.ZodNaN,...Tt(t)});class jM extends zt{_parse(e){const{ctx:n}=this._processInputParams(e),r=n.data;return this._def.type._parse({data:r,path:n.path,parent:n})}unwrap(){return this._def.type}}class _b extends zt{_parse(e){const{status:n,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"?mt:o.status==="dirty"?(n.dirty(),Hc(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"?mt:i.status==="dirty"?(n.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:r.path,parent:r})}}static create(e,n){return new _b({in:e,out:n,typeName:gt.ZodPipeline})}}class L0 extends zt{_parse(e){const n=this._def.innerType._parse(e),r=i=>(Bl(i)&&(i.value=Object.freeze(i.value)),i);return lh(n)?n.then(i=>r(i)):r(n)}unwrap(){return this._def.innerType}}L0.create=(t,e)=>new L0({innerType:t,typeName:gt.ZodReadonly,...Tt(e)});var gt;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(gt||(gt={}));Ms.create;$i.create;uh.create;dh.create;Ca.create;const bi=Hl.create;fh.create;ks.create;Ul.create;bi(["highlight","note","comment"]);bi(["pending","accepted","dismissed"]);bi(["yellow","green","blue","pink"]);bi(["info","warning","error","success"]);const qM=bi(["solo","tandem"]);bi(["user","claude","import"]);bi(["user","claude","import"]);bi(["accept","dismiss"]);bi(["markdown","json"]);bi(["md","txt","html","docx"]);bi(["RANGE_GONE","RANGE_MOVED","FILE_LOCKED","FILE_NOT_FOUND","NO_DOCUMENT","INVALID_RANGE","INVALID_ARGUMENT","NOT_FOUND","ANNOTATION_RESOLVED","FORMAT_ERROR","PERMISSION_DENIED"]);bi(["CHANNEL_CONNECT_FAILED","MONITOR_CONNECT_FAILED"]);function WM(t){return t.author!=="user"}function hh(t){return t.status==="pending"&&WM(t)}function Hp(t){return`${t}_${Date.now()}_${Math.random().toString(36).slice(2,8)}`}function F0(){return Hp("ann")}function KM(){return Hp("msg")}function Sc(){return Hp("ntf")}function GM(t){return Hp(t)}const ZM="/api/notify-stream",Yy="/api/info",YM="/api/open",JM="/api/close",Cb="/api/save",W_="/api/upload",XM="/api/scratchpad",QM="/api/convert",$M="/api/apply-changes",eD="/api/annotation-reply",tD="/api/remove-annotation",nD="/api/chat",rD="/api/sessions",iD="/api/sessions/delete",oD="/api/sessions/clear",sD="/api/launcher/status",aD="/api/launcher/nonce",lD="/api/launcher/relaunch",cD="/api/launcher/start-fresh",uD="/api/launcher/working-directory",Jy=3478,uc=3479,K_="https://github.com/bloknayrb/tandem",G_=`${K_}/issues/new`,xd=new Set([".md",".txt",".html",".htm",".docx"]),dD=3e3,fD=3e3,hD=3e4,Z_={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)"},_u={yellow:"var(--tandem-highlight-yellow)",green:"var(--tandem-highlight-green)",blue:"var(--tandem-highlight-blue)",pink:"var(--tandem-highlight-pink)"};function Y_(t){return t&&t in Z_?t:"yellow"}const Xy="tandem",Zd="tandem:mode",J_="tandem:settings",pD="tandem-panel-width",mD="tandem-left-panel-width",X_={left:mD,right:pD},Q_=1e3,jl=500,ql=3e3,gD="__tandem_ctrl__",Ti="annotations",$_="awareness",z0="userAwareness",vD="mode",bD="selectionDwellMs",Qy="chat",zf="documentMeta",eC="annotationReplies",$y="savedAtVersion",ew="authorship",tw="selection",nw="activity",B0="claude",Ec="openDocuments",Ac="activeDocumentId",Tc="activeDocumentEpoch",Wm="generationId",Km="readOnly",Gm="storeReadOnly",tC="tandem:showAuthorship",nC="tandem:decorationVisibility",Sb="tandem:recentFiles",yD=20,Eb="tandem:userName",rC="You",H0="tandem:user-name-changed",Vp=40,V0={error:8e3,warning:6e3,info:4e3},wD=5,xD="tandem:activityHistory",iC=50,oC="tandem:tutorialCompleted",sC="tutorial-",aC="tandem:coworkOnboardingSkipped",kD=3e4,jee=2e3,rw="tandem:zoomLevel",iw=.5,ow=2,Mc=1,On=`http://127.0.0.1:${uc}`;function _D(t){const e=new Uint8Array(t);let n="";for(let r=0;r<e.length;r++)n+=String.fromCharCode(e[r]);return btoa(n)}function CD(t){return t.toLowerCase().endsWith(".docx")}async function lC(t){if(CD(t.name)){const e=await t.arrayBuffer();return _D(e)}return t.text()}const cC=["editor","navigation","view","document","annotations","claude"];let Bf=F(Qe(new Map));function SD(t,e={}){if(d(Bf).has(t.id)&&!e.replace){const n=`[actions] id collision: "${t.id}" — existing action silently replaced. Pass { replace: true } to suppress this warning.`;console.warn(n)}return y(Bf,new Map(d(Bf)).set(t.id,t),!0),!0}function ph(){return d(Bf)}let U0=null;function ED(t){U0=t}function rn(t,e){if(!U0){console.warn(`[actions] "${t}" invoked before App mounted — deps not wired yet`);return}e(U0)}let j0=F(!1);const AD={get saving(){return d(j0)}};let Zm=!1,Ym=!1;const TD=400;function MD(t){return t.connected&&t.tabCount===0&&t.activeTabId===null}async function mh(){if(!Ym){Ym=!0;try{const t=await fetch(`${On}${XM}`,{method:"POST"});if(!t.ok){const e=await t.json().catch(()=>({}));console.warn("[Tandem] New Scratchpad failed:",e.message??t.statusText)}}catch(t){console.warn("[Tandem] New Scratchpad request failed:",t)}finally{Ym=!1}}}function uC(){try{return typeof window<"u"&&"__TAURI_INTERNALS__"in window}catch{return!1}}let Jm=!1;function DD(t,e){const n=`.${e}`,r=Math.max(t.lastIndexOf("/"),t.lastIndexOf("\\"));return t.slice(r+1).includes(".")?t.slice(t.lastIndexOf(".")).toLowerCase()===n?t:`${t.slice(0,t.lastIndexOf("."))}${n}`:`${t}${n}`}function OD(t,e,n){const r=new Blob([t],{type:n}),i=URL.createObjectURL(r),o=document.createElement("a");o.href=i,o.download=e,document.body.appendChild(o),o.click(),document.body.removeChild(o),setTimeout(()=>URL.revokeObjectURL(i),0)}async function sw(t){if(Jm)return;const{activeDocId:e,notify:n,defaultName:r,sourceFormat:i}=t;if(!e){n("warning","No active document to save.");return}Jm=!0;try{uC()?await ID(e,n,r??"Scratchpad.md"):await RD(e,n,i)}finally{Jm=!1}}async function ID(t,e,n){var a;let r;try{const{save:l}=await yn(async()=>{const{save:c}=await import("./index-Dm_QtxGQ.js");return{save:c}},__vite__mapDeps([0,1]));r=await l({defaultPath:n,filters:[{name:"Markdown",extensions:["md"]},{name:"Plain Text",extensions:["txt"]}]})}catch(l){e("error",`Save As dialog unavailable: ${l instanceof Error?l.message:l}`);return}if(typeof r!="string"||r.length===0)return;const o=r.toLowerCase().endsWith(".txt")?"txt":"md",s=DD(r,o);s!==r&&e("info",`Saving as ${o.toUpperCase()} — only .md and .txt are supported.`);try{const l=await fetch(`${On}${Cb}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({documentId:t,targetPath:s,format:o})});if(!l.ok){const f=await l.json().catch(()=>({}));e("error",`Save As failed: ${f.message??l.statusText}`);return}const c=await l.json().catch(()=>null),u=((a=c==null?void 0:c.data)==null?void 0:a.fileName)??s;e("info",`Saved to ${u}.`)}catch(l){e("error",`Save As request failed: ${l instanceof Error?l.message:l}`)}}async function RD(t,e,n){var i,o;const r=n==="txt"?"txt":"md";try{const s=await fetch(`${On}${Cb}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({documentId:t,serialize:!0,format:r})});if(!s.ok){const u=await s.json().catch(()=>({}));e("error",`Save As failed: ${u.message??s.statusText}`);return}const a=await s.json().catch(()=>null),l=(i=a==null?void 0:a.data)==null?void 0:i.content,c=((o=a==null?void 0:a.data)==null?void 0:o.fileName)??`Scratchpad.${r}`;if(typeof l!="string"){e("error","Save As returned no content.");return}OD(l,c,r==="md"?"text/markdown":"text/plain"),e("info","Downloaded; scratchpad remains in-session.")}catch(s){e("error",`Save As request failed: ${s instanceof Error?s.message:s}`)}}async function q0(t){if(!(!t||Zm)){Zm=!0,y(j0,!0);try{const e=await fetch(`${On}${Cb}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({documentId:t})});if(!e.ok){const n=await e.json().catch(()=>({}));console.warn("[Tandem] Save failed:",n.message??e.statusText)}}catch(e){console.warn("[Tandem] Save request failed:",e)}finally{Zm=!1,y(j0,!1)}}}let Cu=!1;async function ND(){let t;try{t=await fetch(`${On}${sD}`)}catch(e){return{ok:!1,kind:"network",detail:e instanceof Error?e.message:String(e)}}return t.status===404?{ok:!1,kind:"not-built"}:t.ok?{ok:!0,value:await t.json()}:{ok:!1,kind:"server-error",detail:`HTTP ${t.status}`}}async function PD(){let t;try{t=await fetch(`${On}${aD}`,{method:"GET"})}catch(n){return{ok:!1,kind:"network",detail:n instanceof Error?n.message:String(n)}}if(t.status===404)return{ok:!1,kind:"not-built"};if(!t.ok)return{ok:!1,kind:"server-error",detail:`HTTP ${t.status}`};const e=await t.json();return typeof e.nonce!="string"?{ok:!1,kind:"server-error",detail:"malformed nonce response"}:{ok:!0,value:e.nonce}}function LD(t){if(!t||/^[a-z]+:\/\//.test(t))return null;const e=Math.max(t.lastIndexOf("/"),t.lastIndexOf("\\"));return e>0?t.slice(0,e):null}async function dC(t,e,n,r){const i=await PD();if(!i.ok){t.notify("error",`Failed to acquire launcher nonce: ${i.kind}${i.detail?` (${i.detail})`:""}.`);return}const o=i.value;try{const s=await fetch(`${On}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...n,nonce:o})});if(!s.ok){const a=await s.json().catch(()=>({}));t.notify("error",`${r.failPrefix}: ${a.message??s.statusText}`);return}t.notify("info",r.successMessage)}catch(s){t.notify("error",`${r.requestFailPrefix}: ${s instanceof Error?s.message:s}`)}}async function fC(t){if(Cu)return!1;const e=await ND();if(!e.ok)return e.kind==="not-built"?t.notify("warning","Claude launcher not active in this Tandem build."):e.kind==="network"?t.notify("error",`Cannot reach Tandem server${e.detail?`: ${e.detail}`:""}.`):t.notify("error",`Launcher status check failed${e.detail?`: ${e.detail}`:""}.`),!1;const n=e.value;return n.available?("skillRefresh"in n&&n.skillRefresh&&t.notify("warning",`Bundled skill refresh failed: ${n.skillRefresh.message}. Run \`tandem setup\` to retry.`),!0):(t.notify("warning","Claude launcher not active in this Tandem build."),!1)}async function FD(t){if(!await fC(t))return;const e=LD(t.getActiveDocumentPath());if(!e){t.notify("warning","Active document isn't saved to a folder. Set a working directory in Settings → Claude Code.");return}if(confirm(`Restart Claude in:
4
+ ${e}
5
+
6
+ Your current task may be interrupted.`)){Cu=!0;try{await dC(t,lD,{cwd:e},{failPrefix:"Relaunch failed",requestFailPrefix:"Relaunch request failed",successMessage:`Claude restarting in ${e}.`})}finally{Cu=!1}}}async function zD(t){if(await fC(t)&&confirm("Drop Claude's saved conversation and restart fresh. This cannot be undone.")){Cu=!0;try{await dC(t,cD,{},{failPrefix:"Start fresh failed",requestFailPrefix:"Start-fresh request failed",successMessage:"Claude restarting with a fresh conversation."})}finally{Cu=!1}}}async function BD(t){const e=t.getActiveDocumentPath();if(!e){t.notify("warning","This document isn't saved to a file yet.");return}try{const{invoke:n}=await yn(async()=>{const{invoke:r}=await import("./core-DhEqZVGG.js");return{invoke:r}},[]);await n("show_in_file_manager",{path:e})}catch(n){t.notify("error",`Couldn't reveal in file manager: ${n instanceof Error?n.message:String(n)}`)}}const HD=[{id:"save",label:"Save document",group:"document",shortcut:"Ctrl+S",run(){rn("save",t=>void q0(t.getActiveTabId()))}},{id:"settings",label:"Open settings",group:"view",shortcut:"Ctrl+,",run(){rn("settings",t=>t.openSettings())}},{id:"settings-modal",label:"Open settings (new)",group:"view",shortcut:"Ctrl+Shift+,",run(){rn("settings-modal",t=>t.openSettingsModal())}},{id:"toggle-mode",label:"Toggle Solo / Tandem mode",group:"document",shortcut:"Ctrl+Shift+M",run(){rn("toggle-mode",t=>t.toggleSoloMode())}},{id:"new-scratchpad",label:"New Scratchpad",group:"document",shortcut:"Ctrl+N",run(){mh()}},{id:"save-as",label:"Save As…",group:"document",shortcut:"Ctrl+Shift+S",run(){rn("save-as",t=>void t.saveAs())}},{id:"close-tab",label:"Close active tab",group:"document",shortcut:"Ctrl+W",run(){rn("close-tab",t=>t.closeActiveTab())}},{id:"open-file",label:"Open file…",group:"document",shortcut:"Ctrl+O",run(){rn("open-file",t=>t.openFileDialog())}},{id:"find",label:"Find / Replace",group:"navigation",shortcut:"Ctrl+F",run(){rn("find",t=>t.openFindBar())}},{id:"find-in-tabs",label:"Find in open tabs",group:"navigation",shortcut:"Ctrl+Shift+F",run(){rn("find-in-tabs",t=>t.openFindBarTabs())}},{id:"find-next",label:"Find next match",group:"navigation",shortcut:"Ctrl+G",run(){rn("find-next",t=>t.findNext())}},{id:"find-previous",label:"Find previous match",group:"navigation",shortcut:"Ctrl+Shift+G",run(){rn("find-previous",t=>t.findPrev())}},{id:"toggle-left-panel",label:"Toggle left panel",group:"view",shortcut:"Alt+Shift+Left",run(){rn("toggle-left-panel",t=>t.toggleLeftPanel())}},{id:"toggle-right-panel",label:"Toggle right panel",group:"view",shortcut:"Alt+Shift+Right",run(){rn("toggle-right-panel",t=>t.toggleRightPanel())}},{id:"reopen-closed-tab",label:"Reopen closed tab (this session)",group:"document",shortcut:"Ctrl+Alt+T",run(){rn("reopen-closed-tab",t=>t.reopenClosedTab())}},{id:"annotation-next",label:"Next annotation",group:"annotations",shortcut:"Alt+]",run(){rn("annotation-next",t=>t.annotationNext())}},{id:"annotation-previous",label:"Previous annotation",group:"annotations",shortcut:"Alt+[",run(){rn("annotation-previous",t=>t.annotationPrev())}},{id:"annotation-accept",label:"Accept focused annotation",group:"annotations",shortcut:"Ctrl+Enter",run(){rn("annotation-accept",t=>t.annotationAccept())}},{id:"annotation-dismiss",label:"Dismiss focused annotation",group:"annotations",shortcut:"Ctrl+Shift+Enter",run(){rn("annotation-dismiss",t=>t.annotationDismiss())}},{id:"select-block",label:"Select containing block",group:"editor",shortcut:"Alt+L",run(){rn("select-block",t=>t.selectBlock())}},{id:"toggle-authorship",label:"Toggle authorship colors",group:"view",shortcut:"Ctrl+Alt+A",run(){rn("toggle-authorship",t=>t.toggleAuthorship())}},{id:"toggle-formatting-bar",label:"Toggle formatting bar",group:"view",run(){rn("toggle-formatting-bar",t=>t.toggleFormattingBar())}},{id:"launcher-relaunch-here",label:"Relaunch Claude in this folder",group:"claude",run(){rn("launcher-relaunch-here",t=>void FD(t))}},{id:"launcher-start-fresh",label:"Start fresh Claude conversation",group:"claude",run(){rn("launcher-start-fresh",t=>void zD(t))}},...uC()?[{id:"show-in-file-explorer",label:"Show in file explorer",group:"document",run(){rn("show-in-file-explorer",t=>void BD(t))}}]:[]];for(const t of HD)SD(t);const Sa=["save","save-as","settings","settings-modal","toggle-palette","new-scratchpad","close-tab","open-file","toggle-mode","reopen-closed-tab","comment-on-selection","toggle-authorship","toggle-left-panel","toggle-right-panel","annotation-next","annotation-prev","select-block","new-tab-menu"],VD=new Set(Sa);function hC(t){return VD.has(t)}const W0={save:"Save document","save-as":"Save As…",settings:"Open settings","settings-modal":"Open settings (new)","toggle-palette":"Toggle command palette","new-scratchpad":"New Scratchpad","close-tab":"Close active tab","open-file":"Open file…","toggle-mode":"Toggle Solo / Tandem mode","reopen-closed-tab":"Reopen closed tab","comment-on-selection":"Comment on selection","toggle-authorship":"Toggle authorship colors","toggle-left-panel":"Toggle left panel","toggle-right-panel":"Toggle right panel","annotation-next":"Next annotation","annotation-prev":"Previous annotation","select-block":"Select containing block","new-tab-menu":"New tab menu"},UD={save:{ctrlOrMeta:!0,alt:!1,shift:!1,code:"KeyS"},"save-as":{ctrlOrMeta:!0,alt:!1,shift:!0,code:"KeyS"},settings:{ctrlOrMeta:!0,alt:!1,shift:!1,code:"Comma"},"settings-modal":{ctrlOrMeta:!0,alt:!1,shift:!0,code:"Comma"},"toggle-palette":{ctrlOrMeta:!0,alt:!1,shift:!0,code:"KeyP"},"new-scratchpad":{ctrlOrMeta:!0,alt:!1,shift:!1,code:"KeyN"},"close-tab":{ctrlOrMeta:!0,alt:!1,shift:!1,code:"KeyW"},"open-file":{ctrlOrMeta:!0,alt:!1,shift:!1,code:"KeyO"},"toggle-mode":{ctrlOrMeta:!0,alt:!1,shift:!0,code:"KeyM"},"reopen-closed-tab":{ctrlOrMeta:!0,alt:!0,shift:!1,code:"KeyT"},"comment-on-selection":{ctrlOrMeta:!0,alt:!0,shift:!1,code:"KeyM"},"toggle-authorship":{ctrlOrMeta:!0,alt:!0,shift:!1,code:"KeyA"},"toggle-left-panel":{ctrlOrMeta:!1,alt:!0,shift:!0,code:"ArrowLeft"},"toggle-right-panel":{ctrlOrMeta:!1,alt:!0,shift:!0,code:"ArrowRight"},"annotation-next":{ctrlOrMeta:!1,alt:!0,shift:!1,code:"BracketRight"},"annotation-prev":{ctrlOrMeta:!1,alt:!0,shift:!1,code:"BracketLeft"},"select-block":{ctrlOrMeta:!1,alt:!0,shift:!1,code:"KeyL"},"new-tab-menu":{ctrlOrMeta:!0,alt:!1,shift:!1,code:"KeyT"}},pC=[{chord:{ctrlOrMeta:!0,alt:!1,shift:!1,code:"Tab"},label:"Next document tab"},{chord:{ctrlOrMeta:!0,alt:!1,shift:!0,code:"Tab"},label:"Previous document tab"},{chord:{ctrlOrMeta:!0,alt:!1,shift:!1,code:"Digit0"},label:"Reset zoom"},{chord:{ctrlOrMeta:!0,alt:!1,shift:!1,code:"Equal"},label:"Zoom in"},{chord:{ctrlOrMeta:!0,alt:!1,shift:!0,code:"Equal"},label:"Zoom in"},{chord:{ctrlOrMeta:!0,alt:!1,shift:!1,code:"Minus"},label:"Zoom out"},{chord:{ctrlOrMeta:!0,alt:!1,shift:!0,code:"Minus"},label:"Zoom out"},{chord:{ctrlOrMeta:!0,alt:!1,shift:!1,code:"KeyB"},label:"Bold"},{chord:{ctrlOrMeta:!0,alt:!1,shift:!1,code:"KeyI"},label:"Italic"},{chord:{ctrlOrMeta:!0,alt:!1,shift:!1,code:"KeyE"},label:"Inline code"},{chord:{ctrlOrMeta:!0,alt:!1,shift:!0,code:"KeyX"},label:"Strikethrough"},{chord:{ctrlOrMeta:!0,alt:!1,shift:!1,code:"KeyZ"},label:"Undo"},{chord:{ctrlOrMeta:!0,alt:!1,shift:!1,code:"KeyY"},label:"Redo"},{chord:{ctrlOrMeta:!0,alt:!1,shift:!0,code:"KeyZ"},label:"Redo"},{chord:{ctrlOrMeta:!0,alt:!1,shift:!1,code:"KeyK"},label:"Add link"},{chord:{ctrlOrMeta:!0,alt:!1,shift:!0,code:"KeyB"},label:"Blockquote"}],mC={save:"save","save-as":"save-as",settings:"settings","settings-modal":"settings-modal","new-scratchpad":"new-scratchpad","close-tab":"close-tab","open-file":"open-file","toggle-mode":"toggle-mode","reopen-closed-tab":"reopen-closed-tab","toggle-authorship":"toggle-authorship","toggle-left-panel":"toggle-left-panel","toggle-right-panel":"toggle-right-panel","annotation-next":"annotation-next","annotation-previous":"annotation-prev","select-block":"select-block"},jD=/^(Control|Shift|Alt|Meta|OS)/,qD=new Set(["Tab","Escape","Enter","NumpadEnter","NumLock","CapsLock","ContextMenu","Insert"]);function gC(t){return jD.test(t.code)||t.code.startsWith("Numpad")||qD.has(t.code)?!1:t.ctrlOrMeta||t.alt}function WD(t){if(!t.code||t.key==="Dead")return null;const e={ctrlOrMeta:t.ctrlKey||t.metaKey,alt:t.altKey,shift:t.shiftKey,code:t.code};return gC(e)?e:null}function KD(t,e){return t.ctrlOrMeta===(e.ctrlKey||e.metaKey)&&t.alt===e.altKey&&t.shift===e.shiftKey&&t.code===e.code}function gh(t,e){return t.ctrlOrMeta===e.ctrlOrMeta&&t.alt===e.alt&&t.shift===e.shift&&t.code===e.code}function GD(t){if(!t||typeof t!="object")return!1;const e=t;return typeof e.ctrlOrMeta=="boolean"&&typeof e.alt=="boolean"&&typeof e.shift=="boolean"&&typeof e.code=="string"&&e.code.length>0&&e.code.length<=32}function vC(){var t;try{if(typeof navigator>"u")return!1;const e=((t=navigator.userAgentData)==null?void 0:t.platform)??navigator.platform;return/Mac|iPhone|iPad|iPod/i.test(e??"")}catch{return!1}}function ZD(t){return t.startsWith("Key")?t.slice(3):t.startsWith("Digit")?t.slice(5):{Comma:",",Period:".",Slash:"/",Backslash:"\\",Semicolon:";",Quote:"'",BracketLeft:"[",BracketRight:"]",Backquote:"`",Minus:"-",Equal:"=",Space:"Space",Tab:"Tab",Enter:"Enter",ArrowLeft:"←",ArrowRight:"→",ArrowUp:"↑",ArrowDown:"↓"}[t]??t}function K0(t){const e=vC(),n=[];return t.ctrlOrMeta&&n.push(e?"⌘":"Ctrl"),t.alt&&n.push(e?"⌥":"Alt"),t.shift&&n.push(e?"⇧":"Shift"),n.push(ZD(t.code)),e?n.join(""):n.join("+")}function Ab(t,e){return e.get(t)??UD[t]}function YD(t){const e=new Map;for(const n of Sa)e.set(n,K0(Ab(n,t)));return e}function jt(t,e="y"){function n(){if(t.isConnected){if(e==="y"||e==="both"){const o=t.scrollTop>0,s=t.scrollTop+t.clientHeight<t.scrollHeight-1;r("data-overflow-top",o),r("data-overflow-bottom",s)}if(e==="x"||e==="both"){const o=t.scrollLeft>0,s=t.scrollLeft+t.clientWidth<t.scrollWidth-1;r("data-overflow-left",o),r("data-overflow-right",s)}}}function r(o,s){s?t.setAttribute(o,"true"):t.removeAttribute(o)}n(),t.addEventListener("scroll",n,{passive:!0});let i=null;try{i=new ResizeObserver(n),i.observe(t)}catch(o){console.warn("[tandem:scrollFade] ResizeObserver init failed",o)}return{destroy(){t.removeEventListener("scroll",n),i==null||i.disconnect()}}}function Rn(t,e){return e?e.has(t):!1}function bC(t,e){if(t.isComposing)return null;if(e&&e.size>0)for(const r of Sa){const i=e.get(r);if(i&&KD(i,t))return{id:r}}const n=t.ctrlKey||t.metaKey;if(t.key==="?")return{id:"toggle-help"};if(n){if(t.shiftKey&&t.code==="Comma"&&!Rn("settings-modal",e))return{id:"settings-modal"};if(!t.shiftKey&&t.code==="Comma"&&!Rn("settings",e))return{id:"settings"};if(t.key==="/")return{id:"toggle-help"};if(!t.altKey&&!t.shiftKey&&t.code==="KeyA")return{id:"select-all"};if(t.shiftKey&&!t.altKey&&t.code==="KeyS"&&!Rn("save-as",e))return{id:"save-as"};if(t.code==="KeyS"&&!Rn("save",e))return{id:"save"};if(t.shiftKey&&t.code==="KeyP"&&!Rn("toggle-palette",e))return{id:"toggle-palette"};if(t.code==="KeyN"&&!Rn("new-scratchpad",e))return{id:"new-scratchpad"};if(t.code==="KeyW"&&!Rn("close-tab",e))return{id:"close-tab"};if(t.code==="KeyO"&&!Rn("open-file",e))return{id:"open-file"};if(/^Digit[1-9]$/.test(t.code))return{id:"pick-tab",context:{tabIndex:Number(t.code.slice(5))}};if(t.shiftKey&&!t.altKey&&t.code==="KeyM"&&!Rn("toggle-mode",e))return{id:"toggle-mode"};if(t.altKey&&t.code==="KeyT"&&!Rn("reopen-closed-tab",e))return{id:"reopen-closed-tab"};if(!t.altKey&&!t.shiftKey&&t.code==="KeyT"&&!Rn("new-tab-menu",e))return{id:"new-tab-menu"};if(t.code==="KeyF")return{id:"find",context:{shift:t.shiftKey}};if(t.code==="KeyG")return{id:"find-nav",context:{shift:t.shiftKey}};if(t.key==="Enter")return{id:"annotation-accept-or-dismiss",context:{shift:t.shiftKey}};if(t.altKey&&t.code==="KeyM"&&!Rn("comment-on-selection",e))return{id:"comment-on-selection"};if(t.altKey&&t.code==="KeyA"&&!Rn("toggle-authorship",e))return{id:"toggle-authorship"}}if(t.altKey&&!t.ctrlKey&&!t.metaKey){if(t.shiftKey){if(t.code==="ArrowLeft"&&!Rn("toggle-left-panel",e))return{id:"toggle-left-panel"};if(t.code==="ArrowRight"&&!Rn("toggle-right-panel",e))return{id:"toggle-right-panel"}}if(!t.shiftKey){if(t.code==="BracketRight"&&!Rn("annotation-next",e))return{id:"annotation-next"};if(t.code==="BracketLeft"&&!Rn("annotation-prev",e))return{id:"annotation-prev"}}if(!t.shiftKey&&t.code==="KeyL"&&!Rn("select-block",e))return{id:"select-block"}}return null}function JD(t){return t.code==="Slash"?t.shift?"?":"/":t.code==="Enter"||t.code==="NumpadEnter"?"Enter":""}function XD(t){return{key:JD(t),code:t.code,ctrlKey:t.ctrlOrMeta,metaKey:!1,altKey:t.alt,shiftKey:t.shift,isComposing:!1}}function QD(t,e){switch(t){case"toggle-help":return"Show keyboard shortcuts";case"select-all":return"Select all";case"find":return e!=null&&e.shift?"Find in open tabs":"Find / Replace";case"find-nav":return e!=null&&e.shift?"Find previous":"Find next";case"annotation-accept-or-dismiss":return e!=null&&e.shift?"Dismiss annotation":"Accept annotation";case"pick-tab":return e!=null&&e.tabIndex?`Jump to tab ${e.tabIndex}`:"Jump to tab";default:return""}}function yC(t){const e=bC(XD(t));return!e||hC(e.id)?null:QD(e.id,e.context)||null}function $D(t,e,n){for(const i of Sa)if(i!==n&&gh(Ab(i,e),t))return W0[i];const r=yC(t);if(r)return r;for(const i of pC)if(gh(i.chord,t))return i.label;return null}function eO(t){return pC.some(e=>gh(e.chord,t))}function Tb(t){if(!t||typeof t!="object"||Array.isArray(t))return{};const e={};for(const[i,o]of Object.entries(t))hC(i)&&GD(o)&&gC(o)&&(eO(o)||yC(o)||(e[i]=o));const n={},r=[];for(const i of Sa){const o=e[i];o&&(r.some(s=>gh(s,o))||(r.push(o),n[i]=o))}return n}function wC(t){const e=new Map;for(const[n,r]of Object.entries(Tb(t)))e.set(n,r);return e}function xC(t){return t.type==="save-error"&&t.documentId?{label:"Retry",documentId:t.documentId}:null}const kC={info:["M12 3a9 9 0 100 18 9 9 0 000-18z","M12 11v6","M12 8h.01"],warning:["M10.3 3.86 1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z","M12 9v4","M12 17h.01"],error:["M12 3a9 9 0 100 18 9 9 0 000-18z","M15 9l-6 6","M9 9l6 6"]};function tO(t,e=Date.now()){const n=Math.max(0,Math.floor((e-t)/1e3));if(n<5)return"now";if(n<60)return`${n}s`;const r=Math.floor(n/60);if(r<60)return`${r}m`;const i=Math.floor(r/60);return i<24?`${i}h`:`${Math.floor(i/24)}d`}var nO=T('<button type="button" data-testid="activity-clear-all" class="svelte-bf7dij">Clear all</button>'),rO=T('<div class="tray-empty svelte-bf7dij" data-testid="activity-empty">Nothing to report. <div class="sub svelte-bf7dij">Saves, errors, and integration events appear here.</div></div>'),iO=Dr("<path></path>"),oO=T('<span class="badge svelte-bf7dij"> </span>'),sO=T('<button type="button" class="action svelte-bf7dij"><svg width="11" height="11" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M21 12a9 9 0 1 1-3-7"></path><path d="M21 4v5h-5"></path></svg> </button>'),aO=T('<div><span class="glyph svelte-bf7dij"><svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"></svg></span> <div class="body svelte-bf7dij"><div class="msg-row svelte-bf7dij"><span class="msg svelte-bf7dij"> </span> <!> <span class="ts svelte-bf7dij"> </span></div> <!></div> <button type="button" class="dismiss svelte-bf7dij" aria-label="Dismiss activity item"><svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M6 6l12 12"></path><path d="M6 18L18 6"></path></svg></button></div>'),lO=T('<div class="tray-list svelte-bf7dij"></div>'),cO=T('<div class="activity-tray svelte-bf7dij" id="activity-tray" role="region" aria-label="Activity" data-testid="activity-tray"><div class="tray-head svelte-bf7dij"><span class="label svelte-bf7dij">Activity</span> <span class="num svelte-bf7dij"> </span> <span class="spacer svelte-bf7dij"></span> <!></div> <!></div>'),uO=T('<span class="svelte-bf7dij">No activity</span>'),dO=T('<span class="svelte-bf7dij">Activity</span> <span class="count svelte-bf7dij"> </span>',1),fO=T('<div class="activity-anchor svelte-bf7dij"><!> <button type="button" data-testid="activity-pill"><span class="led svelte-bf7dij"></span> <!> <span class="chev svelte-bf7dij"><svg width="10" height="10" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M6 9l6 6 6-6"></path></svg></span></button></div>');function hO(t,e){We(e,!0);const n=L(()=>e.items.length),r=L(()=>e.items.some(m=>m.severity==="error")?"has-error":e.items.some(m=>m.severity==="warning")?"has-warning":e.items.some(m=>m.severity==="info")?"has-info":"idle");let i=F(Qe(Date.now()));const o=setInterval(()=>{y(i,Date.now(),!0)},3e4);gr(()=>clearInterval(o));var s=fO(),a=w(s);{var l=m=>{var v=cO(),g=w(v),b=x(w(g),2),_=w(b),k=x(b,4);{var C=M=>{var N=nO();P("click",N,function(...R){var B;(B=e.onClear)==null||B.apply(this,R)}),S(M,N)};W(k,M=>{d(n)>0&&M(C)})}var E=x(g,2);{var I=M=>{var N=rO();S(M,N)},A=M=>{var N=lO();nt(N,21,()=>e.items,R=>R.id,(R,B)=>{const Z=L(()=>xC(d(B)));var q=aO(),Y=w(q),X=w(Y);nt(X,20,()=>kC[d(B).severity],Q=>Q,(Q,ge)=>{var ye=iO();j(()=>V(ye,"d",ge)),S(Q,ye)});var ae=x(Y,2),ne=w(ae),te=w(ne),le=w(te),se=x(te,2);{var me=Q=>{var ge=oO(),ye=w(ge);j(()=>J(ye,`×${d(B).count??""}`)),S(Q,ge)};W(se,Q=>{d(B).count>1&&Q(me)})}var K=x(se,2),H=w(K),O=x(ne,2);{var G=Q=>{var ge=sO(),ye=x(w(ge));j(()=>{V(ge,"data-testid",`activity-action-${d(B).id}`),J(ye,` ${d(Z).label??""}`)}),P("click",ge,()=>e.onAction(d(B))),S(Q,ge)};W(O,Q=>{d(Z)&&Q(G)})}var z=x(ae,2);j(Q=>{yt(q,1,`toast-row ${d(B).severity??""}`,"svelte-bf7dij"),V(q,"data-testid",`activity-row-${d(B).id}`),J(le,d(B).message),J(H,Q),V(z,"data-testid",`activity-dismiss-${d(B).id}`)},[()=>tO(d(B).timestamp,d(i))]),P("click",z,()=>e.onDismiss(d(B).id)),S(R,q)}),S(M,N)};W(E,M=>{d(n)===0?M(I):M(A,-1)})}j(()=>J(_,d(n)===0?"No events":`${d(n)} event${d(n)===1?"":"s"}`)),S(m,v)};W(a,m=>{e.open&&m(l)})}var c=x(a,2);let u;var f=x(w(c),2);{var h=m=>{var v=uO();S(m,v)},p=m=>{var v=dO(),g=x(Ie(v),2),b=w(g);j(()=>J(b,d(n))),S(m,v)};W(f,m=>{d(n)===0?m(h):m(p,-1)})}j(()=>{u=yt(c,1,`activity-pill ${d(r)??""}`,"svelte-bf7dij",u,{open:e.open}),V(c,"aria-expanded",e.open),V(c,"aria-controls",e.open?"activity-tray":void 0)}),P("click",c,function(...m){var v;(v=e.onToggle)==null||v.apply(this,m)}),S(t,s),Ke()}et(["click"]);function Kn(t){this.content=t}Kn.prototype={constructor:Kn,find:function(t){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===t)return e;return-1},get:function(t){var e=this.find(t);return e==-1?void 0:this.content[e+1]},update:function(t,e,n){var r=n&&n!=t?this.remove(n):this,i=r.find(t),o=r.content.slice();return i==-1?o.push(n||t,e):(o[i+1]=e,n&&(o[i]=n)),new Kn(o)},remove:function(t){var e=this.find(t);if(e==-1)return this;var n=this.content.slice();return n.splice(e,2),new Kn(n)},addToStart:function(t,e){return new Kn([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new Kn(n)},addBefore:function(t,e,n){var r=this.remove(e),i=r.content.slice(),o=r.find(t);return i.splice(o==-1?i.length:o,0,e,n),new Kn(i)},forEach:function(t){for(var e=0;e<this.content.length;e+=2)t(this.content[e],this.content[e+1])},prepend:function(t){return t=Kn.from(t),t.size?new Kn(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=Kn.from(t),t.size?new Kn(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=Kn.from(t);for(var n=0;n<t.content.length;n+=2)e=e.remove(t.content[n]);return e},toObject:function(){var t={};return this.forEach(function(e,n){t[e]=n}),t},get size(){return this.content.length>>1}};Kn.from=function(t){if(t instanceof Kn)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new Kn(e)};function _C(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let i=t.child(r),o=e.child(r);if(i==o){n+=i.nodeSize;continue}if(!i.sameMarkup(o))return n;if(i.isText&&i.text!=o.text){for(let s=0;i.text[s]==o.text[s];s++)n++;return n}if(i.content.size||o.content.size){let s=_C(i.content,o.content,n+1);if(s!=null)return s}n+=i.nodeSize}}function CC(t,e,n,r){for(let i=t.childCount,o=e.childCount;;){if(i==0||o==0)return i==o?null:{a:n,b:r};let s=t.child(--i),a=e.child(--o),l=s.nodeSize;if(s==a){n-=l,r-=l;continue}if(!s.sameMarkup(a))return{a:n,b:r};if(s.isText&&s.text!=a.text){let c=0,u=Math.min(s.text.length,a.text.length);for(;c<u&&s.text[s.text.length-c-1]==a.text[a.text.length-c-1];)c++,n--,r--;return{a:n,b:r}}if(s.content.size||a.content.size){let c=CC(s.content,a.content,n-1,r-1);if(c)return c}n-=l,r-=l}}class be{constructor(e,n){if(this.content=e,this.size=n||0,n==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,n,r,i=0,o){for(let s=0,a=0;a<n;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 u=a+1;l.nodesBetween(Math.max(0,e-u),Math.min(l.content.size,n-u),r,i+u)}a=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,i){let o="",s=!0;return this.nodesBetween(e,n,(a,l)=>{let c=a.isText?a.text.slice(Math.max(e,l)-l,n-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 n=this.lastChild,r=e.firstChild,i=this.content.slice(),o=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),o=1);o<e.content.length;o++)i.push(e.content[o]);return new be(i,this.size+e.size)}cut(e,n=this.size){if(e==0&&n==this.size)return this;let r=[],i=0;if(n>e)for(let o=0,s=0;s<n;o++){let a=this.content[o],l=s+a.nodeSize;l>e&&((s<e||l>n)&&(a.isText?a=a.cut(Math.max(0,e-s),Math.min(a.text.length,n-s)):a=a.cut(Math.max(0,e-s-1),Math.min(a.content.size,n-s-1))),r.push(a),i+=a.nodeSize),s=l}return new be(r,i)}cutByIndex(e,n){return e==n?be.empty:e==0&&n==this.content.length?this:new be(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let i=this.content.slice(),o=this.size+n.nodeSize-r.nodeSize;return i[e]=n,new be(i,o)}addToStart(e){return new be([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new be(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(e.content[n]))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 n=this.content[e];if(!n)throw new RangeError("Index "+e+" out of range for "+this);return n}maybeChild(e){return this.content[e]||null}forEach(e){for(let n=0,r=0;n<this.content.length;n++){let i=this.content[n];e(i,r,n),r+=i.nodeSize}}findDiffStart(e,n=0){return _C(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return CC(this,e,n,r)}findIndex(e){if(e==0)return Yd(0,e);if(e==this.size)return Yd(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,r=0;;n++){let i=this.child(n),o=r+i.nodeSize;if(o>=e)return o==e?Yd(n+1,o):Yd(n,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,n){if(!n)return be.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new be(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return be.empty;let n,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)?(n||(n=e.slice(0,i)),n[n.length-1]=o.withText(n[n.length-1].text+o.text)):n&&n.push(o)}return new be(n||e,r)}static from(e){if(!e)return be.empty;if(e instanceof be)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new be([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}be.empty=new be([],0);const Xm={index:0,offset:0};function Yd(t,e){return Xm.index=t,Xm.offset=e,Xm}function vh(t,e){if(t===e)return!0;if(!(t&&typeof t=="object")||!(e&&typeof e=="object"))return!1;let n=Array.isArray(t);if(Array.isArray(e)!=n)return!1;if(n){if(t.length!=e.length)return!1;for(let r=0;r<t.length;r++)if(!vh(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!vh(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}let qt=class G0{constructor(e,n){this.type=e,this.attrs=n}addToSet(e){let n,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))n||(n=e.slice(0,i));else{if(o.type.excludes(this.type))return e;!r&&o.type.rank>this.type.rank&&(n||(n=e.slice(0,i)),n.push(this),r=!0),n&&n.push(o)}}return n||(n=e.slice()),r||n.push(this),n}removeFromSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return e.slice(0,n).concat(e.slice(n+1));return e}isInSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return!0;return!1}eq(e){return this==e||this.type==e.type&&vh(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[n.type];if(!r)throw new RangeError(`There is no mark type ${n.type} in this schema`);let i=r.create(n.attrs);return r.checkAttrs(i.attrs),i}static sameSet(e,n){if(e==n)return!0;if(e.length!=n.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(n[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return G0.none;if(e instanceof G0)return[e];let n=e.slice();return n.sort((r,i)=>r.type.rank-i.type.rank),n}};qt.none=[];class bh extends Error{}class Le{constructor(e,n,r){this.content=e,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let r=EC(this.content,e+this.openStart,n);return r&&new Le(r,this.openStart,this.openEnd)}removeBetween(e,n){return new Le(SC(this.content,e+this.openStart,n+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,n){if(!n)return Le.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new Le(be.fromJSON(e,n.content),r,i)}static maxOpen(e,n=!0){let r=0,i=0;for(let o=e.firstChild;o&&!o.isLeaf&&(n||!o.type.spec.isolating);o=o.firstChild)r++;for(let o=e.lastChild;o&&!o.isLeaf&&(n||!o.type.spec.isolating);o=o.lastChild)i++;return new Le(e,r,i)}}Le.empty=new Le(be.empty,0,0);function SC(t,e,n){let{index:r,offset:i}=t.findIndex(e),o=t.maybeChild(r),{index:s,offset:a}=t.findIndex(n);if(i==e||o.isText){if(a!=n&&!t.child(s).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=s)throw new RangeError("Removing non-flat range");return t.replaceChild(r,o.copy(SC(o.content,e-i-1,n-i-1)))}function EC(t,e,n,r){let{index:i,offset:o}=t.findIndex(e),s=t.maybeChild(i);if(o==e||s.isText)return r&&!r.canReplace(i,i,n)?null:t.cut(0,e).append(n).append(t.cut(e));let a=EC(s.content,e-o-1,n,s);return a&&t.replaceChild(i,s.copy(a))}function pO(t,e,n){if(n.openStart>t.depth)throw new bh("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new bh("Inconsistent open depths");return AC(t,e,n,0)}function AC(t,e,n,r){let i=t.index(r),o=t.node(r);if(i==e.index(r)&&r<t.depth-n.openStart){let s=AC(t,e,n,r+1);return o.copy(o.content.replaceChild(i,s))}else if(n.content.size)if(!n.openStart&&!n.openEnd&&t.depth==r&&e.depth==r){let s=t.parent,a=s.content;return ga(s,a.cut(0,t.parentOffset).append(n.content).append(a.cut(e.parentOffset)))}else{let{start:s,end:a}=mO(n,t);return ga(o,MC(t,s,a,e,r))}else return ga(o,yh(t,e,r))}function TC(t,e){if(!e.type.compatibleContent(t.type))throw new bh("Cannot join "+e.type.name+" onto "+t.type.name)}function Z0(t,e,n){let r=t.node(n);return TC(r,e.node(n)),r}function ma(t,e){let n=e.length-1;n>=0&&t.isText&&t.sameMarkup(e[n])?e[n]=t.withText(e[n].text+t.text):e.push(t)}function Jc(t,e,n,r){let i=(e||t).node(n),o=0,s=e?e.index(n):i.childCount;t&&(o=t.index(n),t.depth>n?o++:t.textOffset&&(ma(t.nodeAfter,r),o++));for(let a=o;a<s;a++)ma(i.child(a),r);e&&e.depth==n&&e.textOffset&&ma(e.nodeBefore,r)}function ga(t,e){return t.type.checkContent(e),t.copy(e)}function MC(t,e,n,r,i){let o=t.depth>i&&Z0(t,e,i+1),s=r.depth>i&&Z0(n,r,i+1),a=[];return Jc(null,t,i,a),o&&s&&e.index(i)==n.index(i)?(TC(o,s),ma(ga(o,MC(t,e,n,r,i+1)),a)):(o&&ma(ga(o,yh(t,e,i+1)),a),Jc(e,n,i,a),s&&ma(ga(s,yh(n,r,i+1)),a)),Jc(r,null,i,a),new be(a)}function yh(t,e,n){let r=[];if(Jc(null,t,n,r),t.depth>n){let i=Z0(t,e,n+1);ma(ga(i,yh(t,e,n+1)),r)}return Jc(e,null,n,r),new be(r)}function mO(t,e){let n=e.depth-t.openStart,i=e.node(n).copy(t.content);for(let o=n-1;o>=0;o--)i=e.node(o).copy(be.from(i));return{start:i.resolveNoCache(t.openStart+n),end:i.resolveNoCache(i.content.size-t.openEnd-n)}}class Su{constructor(e,n,r){this.pos=e,this.path=n,this.parentOffset=r,this.depth=n.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,n=this.index(this.depth);if(n==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],i=e.child(n);return r?e.child(n).cut(r):i}get nodeBefore(){let e=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(e).cut(0,n):e==0?null:this.parent.child(e-1)}posAtIndex(e,n){n=this.resolveDepth(n);let r=this.path[n*3],i=n==0?0:this.path[n*3-1]+1;for(let o=0;o<e;o++)i+=r.child(o).nodeSize;return i}marks(){let e=this.parent,n=this.index();if(e.content.size==0)return qt.none;if(this.textOffset)return e.child(n).marks;let r=e.maybeChild(n-1),i=e.maybeChild(n);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 n=this.parent.maybeChild(this.index());if(!n||!n.isInline)return null;let r=n.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 n=this.depth;n>0;n--)if(this.start(n)<=e&&this.end(n)>=e)return n;return 0}blockRange(e=this,n){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)&&(!n||n(this.node(r))))return new wh(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 n=1;n<=this.depth;n++)e+=(e?"/":"")+this.node(n).type.name+"_"+this.index(n-1);return e+":"+this.parentOffset}static resolve(e,n){if(!(n>=0&&n<=e.content.size))throw new RangeError("Position "+n+" out of range");let r=[],i=0,o=n;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 Su(n,r,o)}static resolveCached(e,n){let r=aw.get(e);if(r)for(let o=0;o<r.elts.length;o++){let s=r.elts[o];if(s.pos==n)return s}else aw.set(e,r=new gO);let i=r.elts[r.i]=Su.resolve(e,n);return r.i=(r.i+1)%vO,i}}class gO{constructor(){this.elts=[],this.i=0}}const vO=12,aw=new WeakMap;class wh{constructor(e,n,r){this.$from=e,this.$to=n,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 bO=Object.create(null);let _s=class Y0{constructor(e,n,r,i=qt.none){this.type=e,this.attrs=n,this.marks=i,this.content=r||be.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,n,r,i=0){this.content.nodesBetween(e,n,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,n,r,i){return this.content.textBetween(e,n,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,n,r){return this.type==e&&vh(this.attrs,n||e.defaultAttrs||bO)&&qt.sameSet(this.marks,r||qt.none)}copy(e=null){return e==this.content?this:new Y0(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new Y0(this.type,this.attrs,this.content,e)}cut(e,n=this.content.size){return e==0&&n==this.content.size?this:this.copy(this.content.cut(e,n))}slice(e,n=this.content.size,r=!1){if(e==n)return Le.empty;let i=this.resolve(e),o=this.resolve(n),s=r?0:i.sharedDepth(n),a=i.start(s),c=i.node(s).content.cut(i.pos-a,o.pos-a);return new Le(c,i.depth-s,o.depth-s)}replace(e,n,r){return pO(this.resolve(e),this.resolve(n),r)}nodeAt(e){for(let n=this;;){let{index:r,offset:i}=n.content.findIndex(e);if(n=n.maybeChild(r),!n)return null;if(i==e||n.isText)return n;e-=i+1}}childAfter(e){let{index:n,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(n),index:n,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:n,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(n),index:n,offset:r};let i=this.content.child(n-1);return{node:i,index:n-1,offset:r-i.nodeSize}}resolve(e){return Su.resolveCached(this,e)}resolveNoCache(e){return Su.resolve(this,e)}rangeHasMark(e,n,r){let i=!1;return n>e&&this.nodesBetween(e,n,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()+")"),DC(this.marks,e)}contentMatchAt(e){let n=this.type.contentMatch.matchFragment(this.content,0,e);if(!n)throw new Error("Called contentMatchAt on a node with invalid content");return n}canReplace(e,n,r=be.empty,i=0,o=r.childCount){let s=this.contentMatchAt(e).matchFragment(r,i,o),a=s&&s.matchFragment(this.content,n);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,n,r,i){if(i&&!this.type.allowsMarks(i))return!1;let o=this.contentMatchAt(e).matchType(r),s=o&&o.matchFragment(this.content,n);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=qt.none;for(let n=0;n<this.marks.length;n++){let r=this.marks[n];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!qt.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(n=>n.type.name)}`);this.content.forEach(n=>n.check())}toJSON(){let e={type:this.type.name};for(let n 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(n=>n.toJSON())),e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let r;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=n.marks.map(e.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(n.text,r)}let i=be.fromJSON(e,n.content),o=e.nodeType(n.type).create(n.attrs,i,r);return o.type.checkAttrs(o.attrs),o}};_s.prototype.text=void 0;class xh extends _s{constructor(e,n,r,i){if(super(e,n,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):DC(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,n){return this.text.slice(e,n)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new xh(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new xh(this.type,this.attrs,e,this.marks)}cut(e=0,n=this.text.length){return e==0&&n==this.text.length?this:this.withText(this.text.slice(e,n))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function DC(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class Ea{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new yO(e,n);if(r.next==null)return Ea.empty;let i=OC(r);r.next&&r.err("Unexpected trailing text");let o=EO(SO(i));return AO(o,r),o}matchType(e){for(let n=0;n<this.next.length;n++)if(this.next[n].type==e)return this.next[n].next;return null}matchFragment(e,n=0,r=e.childCount){let i=this;for(let o=n;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:n}=this.next[e];if(!(n.isText||n.hasRequiredAttrs()))return n}return null}compatible(e){for(let n=0;n<this.next.length;n++)for(let r=0;r<e.next.length;r++)if(this.next[n].type==e.next[r].type)return!0;return!1}fillBefore(e,n=!1,r=0){let i=[this];function o(s,a){let l=s.matchFragment(e,r);if(l&&(!n||l.validEnd))return be.from(a.map(c=>c.createAndFill()));for(let c=0;c<s.next.length;c++){let{type:u,next:f}=s.next[c];if(!(u.isText||u.hasRequiredAttrs())&&i.indexOf(f)==-1){i.push(f);let h=o(f,a.concat(u));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 n=this.computeWrapping(e);return this.wrapCache.push(e,n),n}computeWrapping(e){let n=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 n)&&(!i.type||l.validEnd)&&(r.push({match:a.contentMatch,type:a,via:i}),n[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 n(r){e.push(r);for(let i=0;i<r.next.length;i++)e.indexOf(r.next[i].next)==-1&&n(r.next[i].next)}return n(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(`
7
+ `)}}Ea.empty=new Ea(!0);class yO{constructor(e,n){this.string=e,this.nodeTypes=n,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 OC(t){let e=[];do e.push(wO(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function wO(t){let e=[];do e.push(xO(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function xO(t){let e=CO(t);for(;;)if(t.eat("+"))e={type:"plus",expr:e};else if(t.eat("*"))e={type:"star",expr:e};else if(t.eat("?"))e={type:"opt",expr:e};else if(t.eat("{"))e=kO(t,e);else break;return e}function lw(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function kO(t,e){let n=lw(t),r=n;return t.eat(",")&&(t.next!="}"?r=lw(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function _O(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let i=[];for(let o in n){let s=n[o];s.isInGroup(e)&&i.push(s)}return i.length==0&&t.err("No node type or group '"+e+"' found"),i}function CO(t){if(t.eat("(")){let e=OC(t);return t.eat(")")||t.err("Missing closing paren"),e}else if(/\W/.test(t.next))t.err("Unexpected token '"+t.next+"'");else{let e=_O(t,t.next).map(n=>(t.inline==null?t.inline=n.isInline:t.inline!=n.isInline&&t.err("Mixing inline and block content"),{type:"name",value:n}));return t.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function SO(t){let e=[[]];return i(o(t,0),n()),e;function n(){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=n())}else if(s.type=="star"){let l=n();return r(a,l),i(o(s.expr,l),l),[r(l)]}else if(s.type=="plus"){let l=n();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 u=n();i(o(s.expr,l),u),l=u}if(s.max==-1)i(o(s.expr,l),l);else for(let c=s.min;c<s.max;c++){let u=n();r(l,u),i(o(s.expr,l),u),l=u}return[r(l)]}else{if(s.type=="name")return[r(a,void 0,s.value)];throw new Error("Unknown expr type")}}}}function IC(t,e){return e-t}function cw(t,e){let n=[];return r(e),n.sort(IC);function r(i){let o=t[i];if(o.length==1&&!o[0].term)return r(o[0].to);n.push(i);for(let s=0;s<o.length;s++){let{term:a,to:l}=o[s];!a&&n.indexOf(l)==-1&&r(l)}}}function EO(t){let e=Object.create(null);return n(cw(t,0));function n(r){let i=[];r.forEach(s=>{t[s].forEach(({term:a,to:l})=>{if(!a)return;let c;for(let u=0;u<i.length;u++)i[u][0]==a&&(c=i[u][1]);cw(t,l).forEach(u=>{c||i.push([a,c=[]]),c.indexOf(u)==-1&&c.push(u)})})});let o=e[r.join(",")]=new Ea(r.indexOf(t.length-1)>-1);for(let s=0;s<i.length;s++){let a=i[s][1].sort(IC);o.next.push({type:i[s][0],next:e[a.join(",")]||n(a)})}return o}}function AO(t,e){for(let n=0,r=[t];n<r.length;n++){let i=r[n],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 RC(t){let e=Object.create(null);for(let n in t){let r=t[n];if(!r.hasDefault)return null;e[n]=r.default}return e}function NC(t,e){let n=Object.create(null);for(let r in t){let i=e&&e[r];if(i===void 0){let o=t[r];if(o.hasDefault)i=o.default;else throw new RangeError("No value supplied for attribute "+r)}n[r]=i}return n}function PC(t,e,n,r){for(let i in e)if(!(i in t))throw new RangeError(`Unsupported attribute ${i} for ${n} of type ${i}`);for(let i in t){let o=t[i];o.validate&&o.validate(e[i])}}function LC(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new MO(t,r,e[r]);return n}let uw=class FC{constructor(e,n,r){this.name=e,this.schema=n,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=LC(e,r.attrs),this.defaultAttrs=RC(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==Ea.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:NC(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new _s(this,this.computeAttrs(e),be.from(n),qt.setFrom(r))}createChecked(e=null,n,r){return n=be.from(n),this.checkContent(n),new _s(this,this.computeAttrs(e),n,qt.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=be.from(n),n.size){let s=this.contentMatch.fillBefore(n);if(!s)return null;n=s.append(n)}let i=this.contentMatch.matchFragment(n),o=i&&i.fillBefore(be.empty,!0);return o?new _s(this,e,n.append(o),qt.setFrom(r)):null}validContent(e){let n=this.contentMatch.matchFragment(e);if(!n||!n.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){PC(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 n=0;n<e.length;n++)if(!this.allowsMarkType(e[n].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let n;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?n&&n.push(e[r]):n||(n=e.slice(0,r));return n?n.length?n:qt.none:e}static compile(e,n){let r=Object.create(null);e.forEach((o,s)=>r[o]=new FC(o,n,s));let i=n.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 TO(t,e,n){let r=n.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 ${t}, got ${o}`)}}class MO{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?TO(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class Up{constructor(e,n,r,i){this.name=e,this.rank=n,this.schema=r,this.spec=i,this.attrs=LC(e,i.attrs),this.excluded=null;let o=RC(this.attrs);this.instance=o?new qt(this,o):null}create(e=null){return!e&&this.instance?this.instance:new qt(this,NC(this.attrs,e))}static compile(e,n){let r=Object.create(null),i=0;return e.forEach((o,s)=>r[o]=new Up(o,i++,n,s)),r}removeFromSet(e){for(var n=0;n<e.length;n++)e[n].type==this&&(e=e.slice(0,n).concat(e.slice(n+1)),n--);return e}isInSet(e){for(let n=0;n<e.length;n++)if(e[n].type==this)return e[n]}checkAttrs(e){PC(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}let Mb=class{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let n=this.spec={};for(let i in e)n[i]=e[i];n.nodes=Kn.from(e.nodes),n.marks=Kn.from(e.marks||{}),this.nodes=uw.compile(this.spec.nodes,this),this.marks=Up.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]=Ea.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?dw(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==""?[]:dw(this,s.split(" "))}this.nodeFromJSON=i=>_s.fromJSON(this,i),this.markFromJSON=i=>qt.fromJSON(this,i),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,n=null,r,i){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof uw){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(n,r,i)}text(e,n){let r=this.nodes.text;return new xh(r,r.defaultAttrs,e,qt.setFrom(n))}mark(e,n){return typeof e=="string"&&(e=this.marks[e]),e.create(n)}nodeType(e){let n=this.nodes[e];if(!n)throw new RangeError("Unknown node type: "+e);return n}};function dw(t,e){let n=[];for(let r=0;r<e.length;r++){let i=e[r],o=t.marks[i],s=o;if(o)n.push(o);else for(let a in t.marks){let l=t.marks[a];(i=="_"||l.spec.group&&l.spec.group.split(" ").indexOf(i)>-1)&&n.push(s=l)}if(!s)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}function DO(t){return t.tag!=null}function OO(t){return t.style!=null}let Xc=class J0{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(i=>{if(DO(i))this.tags.push(i);else if(OO(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,n={}){let r=new hw(this,n,!1);return r.addAll(e,qt.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new hw(this,n,!0);return r.addAll(e,qt.none,n.from,n.to),Le.maxOpen(r.finish())}matchTag(e,n,r){for(let i=r?this.tags.indexOf(r)+1:0;i<this.tags.length;i++){let o=this.tags[i];if(NO(e,o.tag)&&(o.namespace===void 0||e.namespaceURI==o.namespace)&&(!o.context||n.matchesContext(o.context))){if(o.getAttrs){let s=o.getAttrs(e);if(s===!1)continue;o.attrs=s||void 0}return o}}}matchStyle(e,n,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)!=n))){if(s.getAttrs){let l=s.getAttrs(n);if(l===!1)continue;s.attrs=l||void 0}return s}}}static schemaRules(e){let n=[];function r(i){let o=i.priority==null?50:i.priority,s=0;for(;s<n.length;s++){let a=n[s];if((a.priority==null?50:a.priority)<o)break}n.splice(s,0,i)}for(let i in e.marks){let o=e.marks[i].spec.parseDOM;o&&o.forEach(s=>{r(s=pw(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=pw(s)),s.node||s.ignore||s.mark||(s.node=i)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new J0(e,J0.schemaRules(e)))}};const zC={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},IO={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},BC={ol:!0,ul:!0},Eu=1,X0=2,Qc=4;function fw(t,e,n){return e!=null?(e?Eu:0)|(e==="full"?X0:0):t&&t.whitespace=="pre"?Eu|X0:n&~Qc}class Jd{constructor(e,n,r,i,o,s){this.type=e,this.attrs=n,this.marks=r,this.solid=i,this.options=s,this.content=[],this.activeMarks=qt.none,this.match=o||(s&Qc?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(be.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);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&Eu)){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 n=be.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(be.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!zC.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class hw{constructor(e,n,r){this.parser=e,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let i=n.topNode,o,s=fw(null,n.preserveWhitespace,0)|(r?Qc:0);i?o=new Jd(i.type,i.attrs,qt.none,!0,n.topMatch||i.type.contentMatch,s):r?o=new Jd(null,null,qt.none,!0,null,s):o=new Jd(e.schema.topNodeType,null,qt.none,!0,null,s),this.nodes=[o],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,n){e.nodeType==3?this.addTextNode(e,n):e.nodeType==1&&this.addElement(e,n)}addTextNode(e,n){let r=e.nodeValue,i=this.top,o=i.options&X0?"full":this.localPreserveWS||(i.options&Eu)>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,`
8
+ `);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(),n,!0),a[l]&&this.insertNode(s.text(a[l]),n,!/\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),n,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,n,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;BC.hasOwnProperty(s)&&this.parser.normalizeLists&&RO(e);let l=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(a=this.parser.matchTag(e,this,r));e:if(l?l.ignore:IO.hasOwnProperty(s))this.findInside(e),this.ignoreFallback(e,n);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,u=this.needsBlock;if(zC.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,n);break e}let f=l&&l.skip?n:this.readStyles(e,n);f&&this.addAll(e,f),c&&this.sync(o),this.needsBlock=u}else{let c=this.readStyles(e,n);c&&this.addElementByRule(e,l,c,l.consuming===!1?a:void 0)}this.localPreserveWS=i}leafFallback(e,n){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
9
+ `),n)}ignoreFallback(e,n){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),n,!0)}readStyles(e,n){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?n=n.filter(c=>!l.clearMark(c)):n=n.concat(this.parser.schema.marks[l.mark].create(l.attrs)),l.consuming===!1)a=l;else break}}return n}addElementByRule(e,n,r,i){let o,s;if(n.node)if(s=this.parser.schema.nodes[n.node],s.isLeaf)this.insertNode(s.create(n.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let l=this.enter(s,n.attrs||null,r,n.preserveWhitespace);l&&(o=!0,r=l)}else{let l=this.parser.schema.marks[n.mark];r=r.concat(l.create(n.attrs))}let a=this.top;if(s&&s.isLeaf)this.findInside(e);else if(i)this.addElement(e,r,i);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(l=>this.insertNode(l,r,!1));else{let l=e;typeof n.contentElement=="string"?l=e.querySelector(n.contentElement):typeof n.contentElement=="function"?l=n.contentElement(e):n.contentElement&&(l=n.contentElement),this.findAround(e,l,!0),this.addAll(l,r),this.findAround(e,l,!1)}o&&this.sync(a)&&this.open--}addAll(e,n,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,n);this.findAtPoint(e,o)}findPlace(e,n,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++)n=this.enterInner(i[s],null,n,!1);return n}insertNode(e,n,r){if(e.isInline&&this.needsBlock&&!this.top.type){let o=this.textblockFromContext();o&&(n=this.enterInner(o,null,n))}let i=this.findPlace(e,n,r);if(i){this.closeExtra();let o=this.top;o.match&&(o.match=o.match.matchType(e.type));let s=qt.none;for(let a of i.concat(e.marks))(o.type?o.type.allowsMarkType(a.type):mw(a.type,e.type))&&(s=a.addToSet(s));return o.content.push(e.mark(s)),!0}return!1}enter(e,n,r,i){let o=this.findPlace(e.create(n),r,!1);return o&&(o=this.enterInner(e,n,r,!0,i)),o}enterInner(e,n,r,i=!1,o){this.closeExtra();let s=this.top;s.match=s.match&&s.match.matchType(e);let a=fw(e,o,s.options);s.options&Qc&&s.content.length==0&&(a|=Qc);let l=qt.none;return r=r.filter(c=>(s.type?s.type.allowsMarkType(c.type):mw(c.type,e))?(l=c.addToSet(l),!1):!0),this.nodes.push(new Jd(e,n,l,i,null,a)),this.open++,r}closeExtra(e=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].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 n=this.open;n>=0;n--){if(this.nodes[n]==e)return this.open=n,!0;this.localPreserveWS&&(this.nodes[n].options|=Eu)}return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let i=r.length-1;i>=0;i--)e+=r[i].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==n&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].pos==null&&e.nodeType==1&&e.contains(this.find[n].node)&&(this.find[n].pos=this.currentPos)}findAround(e,n,r){if(e!=n&&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)&&n.compareDocumentPosition(this.find[i].node)&(r?2:4)&&(this.find[i].pos=this.currentPos)}findInText(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&(this.find[n].pos=this.currentPos-(e.nodeValue.length-this.find[n].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=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=n[a];if(c==""){if(a==n.length-1||a==0)continue;for(;l>=o;l--)if(s(a-1,l))return!0;return!1}else{let u=l>0||l==0&&i?this.nodes[l].type:r&&l>=o?r.node(l-o).type:null;if(!u||u.name!=c&&!u.isInGroup(c))return!1;l--}}return!0};return s(n.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let n=e.depth;n>=0;n--){let r=e.node(n).contentMatchAt(e.indexAfter(n)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let n in this.parser.schema.nodes){let r=this.parser.schema.nodes[n];if(r.isTextblock&&r.defaultAttrs)return r}}}function RO(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&BC.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function NO(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function pw(t){let e={};for(let n in t)e[n]=t[n];return e}function mw(t,e){let n=e.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(t))continue;let o=[],s=a=>{o.push(a);for(let l=0;l<a.edgeCount;l++){let{type:c,next:u}=a.edge(l);if(c==e||o.indexOf(u)<0&&s(u))return!0}};if(s(i.contentMatch))return!0}}class Ua{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=Qm(n).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++],u=this.serializeMark(c,s.isInline,n);u&&(o.push([c,i]),i.appendChild(u.dom),i=u.contentDOM||u.dom)}}i.appendChild(this.serializeNodeInner(s,n))}),r}serializeNodeInner(e,n){let{dom:r,contentDOM:i}=Hf(Qm(n),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,n,i)}return r}serializeNode(e,n={}){let r=this.serializeNodeInner(e,n);for(let i=e.marks.length-1;i>=0;i--){let o=this.serializeMark(e.marks[i],e.isInline,n);o&&((o.contentDOM||o.dom).appendChild(r),r=o.dom)}return r}serializeMark(e,n,r={}){let i=this.marks[e.type.name];return i&&Hf(Qm(r),i(e,n),null,e.attrs)}static renderSpec(e,n,r=null,i){return Hf(e,n,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Ua(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=gw(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return gw(e.marks)}}function gw(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function Qm(t){return t.document||window.document}const vw=new WeakMap;function PO(t){let e=vw.get(t);return e===void 0&&vw.set(t,e=LO(t)),e}function LO(t){let e=null;function n(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++)n(r[i]);else for(let i in r)n(r[i])}return n(t),e}function Hf(t,e,n,r){if(typeof e=="string")return{dom:t.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=PO(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&&(n=i.slice(0,s),i=i.slice(s+1));let a,l=n?t.createElementNS(n,i):t.createElement(i),c=e[1],u=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){u=2;for(let f in c)if(c[f]!=null){let h=f.indexOf(" ");h>0?l.setAttributeNS(f.slice(0,h),f.slice(h+1),c[f]):f=="style"&&l.style?l.style.cssText=c[f]:l.setAttribute(f,c[f])}}for(let f=u;f<e.length;f++){let h=e[f];if(h===0){if(f<e.length-1||f>u)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}=Hf(t,h,n,r);if(l.appendChild(p),m){if(a)throw new RangeError("Multiple content holes");a=m}}}return{dom:l,contentDOM:a}}const HC=65535,VC=Math.pow(2,16);function FO(t,e){return t+e*VC}function bw(t){return t&HC}function zO(t){return(t-(t&HC))/VC}const UC=1,jC=2,Vf=4,qC=8;class Q0{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&qC)>0}get deletedBefore(){return(this.delInfo&(UC|Vf))>0}get deletedAfter(){return(this.delInfo&(jC|Vf))>0}get deletedAcross(){return(this.delInfo&Vf)>0}}class Ur{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&Ur.empty)return Ur.empty}recover(e){let n=0,r=bw(e);if(!this.inverted)for(let i=0;i<r;i++)n+=this.ranges[i*3+2]-this.ranges[i*3+1];return this.ranges[r*3]+n+zO(e)}mapResult(e,n=1){return this._map(e,n,!1)}map(e,n=1){return this._map(e,n,!0)}_map(e,n,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],u=this.ranges[a+s],f=l+c;if(e<=f){let h=c?e==l?-1:e==f?1:n:n,p=l+i+(h<0?0:u);if(r)return p;let m=e==(n<0?l:f)?null:FO(a/3,e-l),v=e==l?jC:e==f?UC:Vf;return(n<0?e!=l:e!=f)&&(v|=qC),new Q0(p,v,m)}i+=u-c}return r?e+i:new Q0(e+i,0,null)}touches(e,n){let r=0,i=bw(n),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],u=l+c;if(e<=u&&a==i*3)return!0;r+=this.ranges[a+s]-c}return!1}forEach(e){let n=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+n],u=this.ranges[i+r];e(a,a+c,l,l+u),o+=u-c}}invert(){return new Ur(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?Ur.empty:new Ur(e<0?[0,-e,0]:[0,0,e])}}Ur.empty=new Ur([]);class Au{constructor(e,n,r=0,i=e?e.length:0){this.mirror=n,this.from=r,this.to=i,this._maps=e||[],this.ownData=!(e||n)}get maps(){return this._maps}slice(e=0,n=this.maps.length){return new Au(this._maps,this.mirror,e,n)}appendMap(e,n){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),n!=null&&this.setMirror(this._maps.length-1,n)}appendMapping(e){for(let n=0,r=this._maps.length;n<e._maps.length;n++){let i=e.getMirror(n);this.appendMap(e._maps[n],i!=null&&i<n?r+i:void 0)}}getMirror(e){if(this.mirror){for(let n=0;n<this.mirror.length;n++)if(this.mirror[n]==e)return this.mirror[n+(n%2?-1:1)]}}setMirror(e,n){this.mirror||(this.mirror=[]),this.mirror.push(e,n)}appendMappingInverted(e){for(let n=e.maps.length-1,r=this._maps.length+e._maps.length;n>=0;n--){let i=e.getMirror(n);this.appendMap(e._maps[n].invert(),i!=null&&i>n?r-i-1:void 0)}}invert(){let e=new Au;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,n);return e}mapResult(e,n=1){return this._map(e,n,!1)}_map(e,n,r){let i=0;for(let o=this.from;o<this.to;o++){let s=this._maps[o],a=s.mapResult(e,n);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 Q0(e,i,null)}}const $m=Object.create(null);class ar{getMap(){return Ur.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=$m[n.stepType];if(!r)throw new RangeError(`No step type ${n.stepType} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in $m)throw new RangeError("Duplicate use of step JSON ID "+e);return $m[e]=n,n.prototype.jsonID=e,n}}class xn{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new xn(e,null)}static fail(e){return new xn(null,e)}static fromReplace(e,n,r,i){try{return xn.ok(e.replace(n,r,i))}catch(o){if(o instanceof bh)return xn.fail(o.message);throw o}}}function Db(t,e,n){let r=[];for(let i=0;i<t.childCount;i++){let o=t.child(i);o.content.size&&(o=o.copy(Db(o.content,e,o))),o.isInline&&(o=e(o,n,i)),r.push(o)}return be.fromArray(r)}class ms extends ar{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=e.resolve(this.from),i=r.node(r.sharedDepth(this.to)),o=new Le(Db(n.content,(s,a)=>!s.isAtom||!a.type.allowsMarkType(this.mark.type)?s:s.mark(this.mark.addToSet(s.marks)),i),n.openStart,n.openEnd);return xn.fromReplace(e,this.from,this.to,o)}invert(){return new Yi(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new ms(n.pos,r.pos,this.mark)}merge(e){return e instanceof ms&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new ms(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,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new ms(n.from,n.to,e.markFromJSON(n.mark))}}ar.jsonID("addMark",ms);class Yi extends ar{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=new Le(Db(n.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),n.openStart,n.openEnd);return xn.fromReplace(e,this.from,this.to,r)}invert(){return new ms(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new Yi(n.pos,r.pos,this.mark)}merge(e){return e instanceof Yi&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Yi(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,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new Yi(n.from,n.to,e.markFromJSON(n.mark))}}ar.jsonID("removeMark",Yi);class gs extends ar{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return xn.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return xn.fromReplace(e,this.pos,this.pos+1,new Le(be.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(let i=0;i<n.marks.length;i++)if(!n.marks[i].isInSet(r))return new gs(this.pos,n.marks[i]);return new gs(this.pos,this.mark)}}return new Aa(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new gs(n.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new gs(n.pos,e.markFromJSON(n.mark))}}ar.jsonID("addNodeMark",gs);class Aa extends ar{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return xn.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return xn.fromReplace(e,this.pos,this.pos+1,new Le(be.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new gs(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Aa(n.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new Aa(n.pos,e.markFromJSON(n.mark))}}ar.jsonID("removeNodeMark",Aa);class Ln extends ar{constructor(e,n,r,i=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=i}apply(e){return this.structure&&$0(e,this.from,this.to)?xn.fail("Structure replace would overwrite content"):xn.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Ur([this.from,this.to-this.from,this.slice.size])}invert(e){return new Ln(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deletedAcross&&r.deletedAcross?null:new Ln(n.pos,Math.max(n.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof Ln)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let n=this.slice.size+e.slice.size==0?Le.empty:new Le(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new Ln(this.from,this.to+(e.to-e.from),n,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let n=this.slice.size+e.slice.size==0?Le.empty:new Le(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new Ln(e.from,this.to,n,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,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new Ln(n.from,n.to,Le.fromJSON(e,n.slice),!!n.structure)}}ar.jsonID("replace",Ln);class Hn extends ar{constructor(e,n,r,i,o,s,a=!1){super(),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=i,this.slice=o,this.insert=s,this.structure=a}apply(e){if(this.structure&&($0(e,this.from,this.gapFrom)||$0(e,this.gapTo,this.to)))return xn.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return xn.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?xn.fromReplace(e,this.from,this.to,r):xn.fail("Content does not fit in gap")}getMap(){return new Ur([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let n=this.gapTo-this.gapFrom;return new Hn(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),i=this.from==this.gapFrom?n.pos:e.map(this.gapFrom,-1),o=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||i<n.pos||o>r.pos?null:new Hn(n.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,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Hn(n.from,n.to,n.gapFrom,n.gapTo,Le.fromJSON(e,n.slice),n.insert,!!n.structure)}}ar.jsonID("replaceAround",Hn);function $0(t,e,n){let r=t.resolve(e),i=n-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 BO(t,e,n,r){let i=[],o=[],s,a;t.doc.nodesBetween(e,n,(l,c,u)=>{if(!l.isInline)return;let f=l.marks;if(!r.isInSet(f)&&u.type.allowsMarkType(r.type)){let h=Math.max(c,e),p=Math.min(c+l.nodeSize,n),m=r.addToSet(f);for(let v=0;v<f.length;v++)f[v].isInSet(m)||(s&&s.to==h&&s.mark.eq(f[v])?s.to=p:i.push(s=new Yi(h,p,f[v])));a&&a.to==h?a.to=p:o.push(a=new ms(h,p,r))}}),i.forEach(l=>t.step(l)),o.forEach(l=>t.step(l))}function HO(t,e,n,r){let i=[],o=0;t.doc.nodesBetween(e,n,(s,a)=>{if(!s.isInline)return;o++;let l=null;if(r instanceof Up){let c=s.marks,u;for(;u=r.isInSet(c);)(l||(l=[])).push(u),c=u.removeFromSet(c)}else r?r.isInSet(s.marks)&&(l=[r]):l=s.marks;if(l&&l.length){let c=Math.min(a+s.nodeSize,n);for(let u=0;u<l.length;u++){let f=l[u],h;for(let p=0;p<i.length;p++){let m=i[p];m.step==o-1&&f.eq(i[p].style)&&(h=m)}h?(h.to=c,h.step=o):i.push({style:f,from:Math.max(a,e),to:c,step:o})}}}),i.forEach(s=>t.step(new Yi(s.from,s.to,s.style)))}function Ob(t,e,n,r=n.contentMatch,i=!0){let o=t.doc.nodeAt(e),s=[],a=e+1;for(let l=0;l<o.childCount;l++){let c=o.child(l),u=a+c.nodeSize,f=r.matchType(c.type);if(!f)s.push(new Ln(a,u,Le.empty));else{r=f;for(let h=0;h<c.marks.length;h++)n.allowsMarkType(c.marks[h].type)||t.step(new Yi(a,u,c.marks[h]));if(i&&c.isText&&n.whitespace!="pre"){let h,p=/\r?\n|\r/g,m;for(;h=p.exec(c.text);)m||(m=new Le(be.from(n.schema.text(" ",n.allowedMarks(c.marks))),0,0)),s.push(new Ln(a+h.index,a+h.index+h[0].length,m))}}a=u}if(!r.validEnd){let l=r.fillBefore(be.empty,!0);t.replace(a,a,new Le(l,0,0))}for(let l=s.length-1;l>=0;l--)t.step(s[l])}function VO(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function dc(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth,i=0,o=0;;--r){let s=t.$from.node(r),a=t.$from.index(r)+i,l=t.$to.indexAfter(r)-o;if(r<t.depth&&s.canReplace(a,l,n))return r;if(r==0||s.type.spec.isolating||!VO(s,a,l))break;a&&(i=1),l<s.childCount&&(o=1)}return null}function UO(t,e,n){let{$from:r,$to:i,depth:o}=e,s=r.before(o+1),a=i.after(o+1),l=s,c=a,u=be.empty,f=0;for(let m=o,v=!1;m>n;m--)v||r.index(m)>0?(v=!0,u=be.from(r.node(m).copy(u)),f++):l--;let h=be.empty,p=0;for(let m=o,v=!1;m>n;m--)v||i.after(m+1)<i.end(m)?(v=!0,h=be.from(i.node(m).copy(h)),p++):c++;t.step(new Hn(l,c,s,a,new Le(u.append(h),f,p),u.size-f,!0))}function Ib(t,e,n=null,r=t){let i=jO(t,e),o=i&&qO(r,e);return o?i.map(yw).concat({type:e,attrs:n}).concat(o.map(yw)):null}function yw(t){return{type:t,attrs:null}}function jO(t,e){let{parent:n,startIndex:r,endIndex:i}=t,o=n.contentMatchAt(r).findWrapping(e);if(!o)return null;let s=o.length?o[0]:e;return n.canReplaceWith(r,i,s)?o:null}function qO(t,e){let{parent:n,startIndex:r,endIndex:i}=t,o=n.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(n.child(c).type);return!l||!l.validEnd?null:s}function WO(t,e,n){let r=be.empty;for(let s=n.length-1;s>=0;s--){if(r.size){let a=n[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=be.from(n[s].type.create(n[s].attrs,r))}let i=e.start,o=e.end;t.step(new Hn(i,o,i,o,new Le(r,0,0),n.length,!0))}function KO(t,e,n,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let o=t.steps.length;t.doc.nodesBetween(e,n,(s,a)=>{let l=typeof i=="function"?i(s):i;if(s.isTextblock&&!s.hasMarkup(r,l)&&GO(t.doc,t.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&&KC(t,s,a,o),Ob(t,t.mapping.slice(o).map(a,1),r,void 0,c===null);let u=t.mapping.slice(o),f=u.map(a,1),h=u.map(a+s.nodeSize,1);return t.step(new Hn(f,h,f+1,h-1,new Le(be.from(r.create(l,null,s.marks)),0,0),1,!0)),c===!0&&WC(t,s,a,o),!1}})}function WC(t,e,n,r){e.forEach((i,o)=>{if(i.isText){let s,a=/\r?\n|\r/g;for(;s=a.exec(i.text);){let l=t.mapping.slice(r).map(n+1+o+s.index);t.replaceWith(l,l+1,e.type.schema.linebreakReplacement.create())}}})}function KC(t,e,n,r){e.forEach((i,o)=>{if(i.type==i.type.schema.linebreakReplacement){let s=t.mapping.slice(r).map(n+1+o);t.replaceWith(s,s+1,e.type.schema.text(`
10
+ `))}})}function GO(t,e,n){let r=t.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function ZO(t,e,n,r,i){let o=t.doc.nodeAt(e);if(!o)throw new RangeError("No node at given position");n||(n=o.type);let s=n.create(r,null,i||o.marks);if(o.isLeaf)return t.replaceWith(e,e+o.nodeSize,s);if(!n.validContent(o.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new Hn(e,e+o.nodeSize,e+1,e+o.nodeSize-1,new Le(be.from(s),0,0),1,!0))}function Io(t,e,n=1,r){let i=t.resolve(e),o=i.depth-n,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,u=n-2;c>o;c--,u--){let f=i.node(c),h=i.index(c);if(f.type.spec.isolating)return!1;let p=f.content.cutByIndex(h,f.childCount),m=r&&r[u+1];m&&(p=p.replaceChild(0,m.type.create(m.attrs)));let v=r&&r[u]||f;if(!f.canReplace(h+1,f.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 YO(t,e,n=1,r){let i=t.doc.resolve(e),o=be.empty,s=be.empty;for(let a=i.depth,l=i.depth-n,c=n-1;a>l;a--,c--){o=be.from(i.node(a).copy(o));let u=r&&r[c];s=be.from(u?u.type.create(u.attrs,s):i.node(a).copy(s))}t.step(new Ln(e,e,new Le(o.append(s),n,n),!0))}function zs(t,e){let n=t.resolve(e),r=n.index();return GC(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function JO(t,e){e.content.size||t.type.compatibleContent(e.type);let n=t.contentMatchAt(t.childCount),{linebreakReplacement:r}=t.type.schema;for(let i=0;i<e.childCount;i++){let o=e.child(i),s=o.type==r?t.type.schema.nodes.text:o.type;if(n=n.matchType(s),!n||!t.type.allowsMarks(o.marks))return!1}return n.validEnd}function GC(t,e){return!!(t&&e&&!t.isLeaf&&JO(t,e))}function jp(t,e,n=-1){let r=t.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):n>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&&GC(o,s)&&r.node(i).canReplace(a,a+1))return e;if(i==0)break;e=n<0?r.before(i):r.after(i)}}function XO(t,e,n){let r=null,{linebreakReplacement:i}=t.doc.type.schema,o=t.doc.resolve(e-n),s=o.node().type;if(i&&s.inlineContent){let u=s.whitespace=="pre",f=!!s.contentMatch.matchType(i);u&&!f?r=!1:!u&&f&&(r=!0)}let a=t.steps.length;if(r===!1){let u=t.doc.resolve(e+n);KC(t,u.node(),u.before(),a)}s.inlineContent&&Ob(t,e+n-1,s,o.node().contentMatchAt(o.index()),r==null);let l=t.mapping.slice(a),c=l.map(e-n);if(t.step(new Ln(c,l.map(e+n,-1),Le.empty,!0)),r===!0){let u=t.doc.resolve(c);WC(t,u.node(),u.before(),t.steps.length)}return t}function QO(t,e,n){let r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),n))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,n))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,n))return r.after(i+1);if(o<r.node(i).childCount)return null}return null}function ZC(t,e,n){let r=t.resolve(e);if(!n.content.size)return e;let i=n.content;for(let o=0;o<n.openStart;o++)i=i.firstChild.content;for(let o=1;o<=(n.openStart==0&&n.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),u=!1;if(o==1)u=c.canReplace(l,l,i);else{let f=c.contentMatchAt(l).findWrapping(i.firstChild.type);u=f&&c.canReplaceWith(l,l,f[0])}if(u)return a==0?r.pos:a<0?r.before(s+1):r.after(s+1)}return null}function qp(t,e,n=e,r=Le.empty){if(e==n&&!r.size)return null;let i=t.resolve(e),o=t.resolve(n);return YC(i,o,r)?new Ln(e,n,r):new $O(i,o,r).fit()}function YC(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class $O{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=be.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=be.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(),n=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 Le(o,s,a);return e>-1?new Hn(r.pos,e,this.$to.pos,this.$to.end(),l,n):l.size||r.pos!=this.$to.pos?new Ln(r.pos,i.pos,l):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,i=this.unplaced.openEnd;r<e;r++){let o=n.firstChild;if(n.childCount>1&&(i=0),o.type.spec.isolating&&i<=r){e=r;break}n=o.content}for(let n=1;n<=2;n++)for(let r=n==1?e:this.unplaced.openStart;r>=0;r--){let i,o=null;r?(o=eg(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],u,f=null;if(n==1&&(s?c.matchType(s.type)||(f=c.fillBefore(be.from(s),!1)):o&&l.compatibleContent(o.type)))return{sliceDepth:r,frontierDepth:a,parent:o,inject:f};if(n==2&&s&&(u=c.findWrapping(s.type)))return{sliceDepth:r,frontierDepth:a,parent:o,wrap:u};if(o&&c.matchType(o.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced,i=eg(e,n);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new Le(e,n+1,Math.max(r,i.size+n>=e.size-r?n+1:0)),!0)}dropNode(){let{content:e,openStart:n,openEnd:r}=this.unplaced,i=eg(e,n);if(i.childCount<=1&&n>0){let o=e.size-n<=n+i.size;this.unplaced=new Le(Vc(e,n-1,1),n-1,o?n-1:r)}else this.unplaced=new Le(Vc(e,n,1),n,r)}placeNodes({sliceDepth:e,frontierDepth:n,parent:r,inject:i,wrap:o}){for(;this.depth>n;)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,u=[],{match:f,type:h}=this.frontier[n];if(i){for(let v=0;v<i.childCount;v++)u.push(i.child(v));f=f.matchFragment(i)}let p=a.size+e-(s.content.size-s.openEnd);for(;c<a.childCount;){let v=a.child(c),g=f.matchType(v.type);if(!g)break;c++,(c>1||l==0||v.content.size)&&(f=g,u.push(JC(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=Uc(this.placed,n,be.from(u)),this.frontier[n].match=f,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 b=g.lastChild;this.frontier.push({type:b.type,match:b.contentMatchAt(b.childCount)}),g=b.content}this.unplaced=m?e==0?Le.empty:new Le(Vc(s.content,e-1,1),e-1,p<0?s.openEnd:e-1):new Le(Vc(s.content,e,c),s.openStart,s.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],n;if(!e.type.isTextblock||!tg(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(n=this.findCloseLevel(this.$to))&&n.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 n=Math.min(this.depth,e.depth);n>=0;n--){let{match:r,type:i}=this.frontier[n],o=n<e.depth&&e.end(n+1)==e.pos+(e.depth-(n+1)),s=tg(e,n,i,r,o);if(s){for(let a=n-1;a>=0;a--){let{match:l,type:c}=this.frontier[a],u=tg(e,a,c,l,!0);if(!u||u.childCount)continue e}return{depth:n,fit:s,move:o?e.doc.resolve(e.after(n+1)):e}}}}close(e){let n=this.findCloseLevel(e);if(!n)return null;for(;this.depth>n.depth;)this.closeFrontierNode();n.fit.childCount&&(this.placed=Uc(this.placed,n.depth,n.fit)),e=n.move;for(let r=n.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,n=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=Uc(this.placed,this.depth,be.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(be.empty,!0);n.childCount&&(this.placed=Uc(this.placed,this.frontier.length,n))}}function Vc(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(Vc(t.firstChild.content,e-1,n)))}function Uc(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(Uc(t.lastChild.content,e-1,n)))}function eg(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function JC(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,JC(r.firstChild,e-1,r.childCount==1?n-1:0))),e>0&&(r=t.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(t.type.contentMatch.matchFragment(r).fillBefore(be.empty,!0)))),t.copy(r)}function tg(t,e,n,r,i){let o=t.node(e),s=i?t.indexAfter(e):t.index(e);if(s==o.childCount&&!n.compatibleContent(o.type))return null;let a=r.fillBefore(o.content,!0,s);return a&&!e5(n,o.content,s)?a:null}function e5(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}function t5(t){return t.spec.defining||t.spec.definingForContent}function n5(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let i=t.doc.resolve(e),o=t.doc.resolve(n);if(YC(i,o,r))return t.step(new Ln(e,n,r));let s=QC(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=[],u=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=u-1;h>=0;h--){let p=c[h],m=t5(p.type);if(m&&!p.sameMarkup(i.node(Math.abs(a)-1)))u=h;else if(m||!p.type.isTextblock)break}for(let h=r.openStart;h>=0;h--){let p=(h+u+1)%(r.openStart+1),m=c[p];if(m)for(let v=0;v<s.length;v++){let g=s[(v+l)%s.length],b=!0;g<0&&(b=!1,g=-g);let _=i.node(g-1),k=i.index(g-1);if(_.canReplaceWith(k,k,m.type,m.marks))return t.replace(i.before(g),b?o.after(g):n,new Le(XC(r.content,0,r.openStart,p),p,r.openEnd))}}let f=t.steps.length;for(let h=s.length-1;h>=0&&(t.replace(e,n,r),!(t.steps.length>f));h--){let p=s[h];p<0||(e=i.before(p),n=o.after(p))}}function XC(t,e,n,r,i){if(e<n){let o=t.firstChild;t=t.replaceChild(0,o.copy(XC(o.content,e+1,n,r,o)))}if(e>r){let o=i.contentMatchAt(0),s=o.fillBefore(t).append(t);t=s.append(o.matchFragment(s).fillBefore(be.empty,!0))}return t}function r5(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let i=QO(t.doc,e,r.type);i!=null&&(e=n=i)}t.replaceRange(e,n,new Le(be.from(r),0,0))}function i5(t,e,n){let r=t.doc.resolve(e),i=t.doc.resolve(n),o=QC(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 t.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 t.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&&n>r.end(s)&&i.end(s)-n!=i.depth-s&&r.start(s-1)==i.start(s-1)&&r.node(s-1).canReplace(r.index(s-1),i.index(s-1)))return t.delete(r.before(s),n);t.delete(e,n)}function QC(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let i=r;i>=0;i--){let o=t.start(i);if(o<t.pos-(t.depth-i)||e.end(i)>e.pos+(e.depth-i)||t.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(o==e.start(i)||i==t.depth&&i==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==o-1)&&n.push(i)}return n}class hl extends ar{constructor(e,n,r){super(),this.pos=e,this.attr=n,this.value=r}apply(e){let n=e.nodeAt(this.pos);if(!n)return xn.fail("No node at attribute step's position");let r=Object.create(null);for(let o in n.attrs)r[o]=n.attrs[o];r[this.attr]=this.value;let i=n.type.create(r,null,n.marks);return xn.fromReplace(e,this.pos,this.pos+1,new Le(be.from(i),0,n.isLeaf?0:1))}getMap(){return Ur.empty}invert(e){return new hl(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new hl(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.pos!="number"||typeof n.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new hl(n.pos,n.attr,n.value)}}ar.jsonID("attr",hl);class Tu extends ar{constructor(e,n){super(),this.attr=e,this.value=n}apply(e){let n=Object.create(null);for(let i in e.attrs)n[i]=e.attrs[i];n[this.attr]=this.value;let r=e.type.create(n,e.content,e.marks);return xn.ok(r)}getMap(){return Ur.empty}invert(e){return new Tu(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new Tu(n.attr,n.value)}}ar.jsonID("docAttr",Tu);let Wl=class extends Error{};Wl=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};Wl.prototype=Object.create(Error.prototype);Wl.prototype.constructor=Wl;Wl.prototype.name="TransformError";class Rb{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Au}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new Wl(n.failed);return this}maybeStep(e){let n=e.apply(this.doc);return n.failed||this.addStep(e,n.doc),n}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,n=-1e9;for(let r=0;r<this.mapping.maps.length;r++){let i=this.mapping.maps[r];r&&(e=i.map(e,1),n=i.map(n,-1)),i.forEach((o,s,a,l)=>{e=Math.min(e,a),n=Math.max(n,l)})}return e==1e9?null:{from:e,to:n}}addStep(e,n){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=n}replace(e,n=e,r=Le.empty){let i=qp(this.doc,e,n,r);return i&&this.step(i),this}replaceWith(e,n,r){return this.replace(e,n,new Le(be.from(r),0,0))}delete(e,n){return this.replace(e,n,Le.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return n5(this,e,n,r),this}replaceRangeWith(e,n,r){return r5(this,e,n,r),this}deleteRange(e,n){return i5(this,e,n),this}lift(e,n){return UO(this,e,n),this}join(e,n=1){return XO(this,e,n),this}wrap(e,n){return WO(this,e,n),this}setBlockType(e,n=e,r,i=null){return KO(this,e,n,r,i),this}setNodeMarkup(e,n,r=null,i){return ZO(this,e,n,r,i),this}setNodeAttribute(e,n,r){return this.step(new hl(e,n,r)),this}setDocAttribute(e,n){return this.step(new Tu(e,n)),this}addNodeMark(e,n){return this.step(new gs(e,n)),this}removeNodeMark(e,n){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(n instanceof qt)n.isInSet(r.marks)&&this.step(new Aa(e,n));else{let i=r.marks,o,s=[];for(;o=n.isInSet(i);)s.push(new Aa(e,o)),i=o.removeFromSet(i);for(let a=s.length-1;a>=0;a--)this.step(s[a])}return this}split(e,n=1,r){return YO(this,e,n,r),this}addMark(e,n,r){return BO(this,e,n,r),this}removeMark(e,n,r){return HO(this,e,n,r),this}clearIncompatible(e,n,r){return Ob(this,e,n,r),this}}const ng=Object.create(null);class lt{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new $C(e.min(n),e.max(n))]}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 n=0;n<e.length;n++)if(e[n].$from.pos!=e[n].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,n=Le.empty){let r=n.content.lastChild,i=null;for(let a=0;a<n.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],u=e.mapping.slice(o);e.replaceRange(u.map(l.pos),u.map(c.pos),a?Le.empty:n),a==0&&kw(e,o,(r?r.isInline:i&&i.isTextblock)?-1:1)}}replaceWith(e,n){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),u=l.map(a.pos);o?e.deleteRange(c,u):(e.replaceRangeWith(c,u,n),kw(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let i=e.parent.inlineContent?new $e(e):nl(e.node(0),e.parent,e.pos,e.index(),n,r);if(i)return i;for(let o=e.depth-1;o>=0;o--){let s=n<0?nl(e.node(0),e.node(o),e.before(o+1),e.index(o),n,r):nl(e.node(0),e.node(o),e.after(o+1),e.index(o)+1,n,r);if(s)return s}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new Er(e.node(0))}static atStart(e){return nl(e,e,0,0,1)||new Er(e)}static atEnd(e){return nl(e,e,e.content.size,e.childCount,-1)||new Er(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=ng[n.type];if(!r)throw new RangeError(`No selection type ${n.type} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in ng)throw new RangeError("Duplicate use of selection JSON ID "+e);return ng[e]=n,n.prototype.jsonID=e,n}getBookmark(){return $e.between(this.$anchor,this.$head).getBookmark()}}lt.prototype.visible=!0;class $C{constructor(e,n){this.$from=e,this.$to=n}}let ww=!1;function xw(t){!ww&&!t.parent.inlineContent&&(ww=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class $e extends lt{constructor(e,n=e){xw(e),xw(n),super(e,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,n){let r=e.resolve(n.map(this.head));if(!r.parent.inlineContent)return lt.near(r);let i=e.resolve(n.map(this.anchor));return new $e(i.parent.inlineContent?i:r,r)}replace(e,n=Le.empty){if(super.replace(e,n),n==Le.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof $e&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Wp(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new $e(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let i=e.resolve(n);return new this(i,r==n?i:e.resolve(r))}static between(e,n,r){let i=e.pos-n.pos;if((!r||i)&&(r=i>=0?1:-1),!n.parent.inlineContent){let o=lt.findFrom(n,r,!0)||lt.findFrom(n,-r,!0);if(o)n=o.$head;else return lt.near(n,r)}return e.parent.inlineContent||(i==0?e=n:(e=(lt.findFrom(e,-r,!0)||lt.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=i<0&&(e=n))),new $e(e,n)}}lt.jsonID("text",$e);class Wp{constructor(e,n){this.anchor=e,this.head=n}map(e){return new Wp(e.map(this.anchor),e.map(this.head))}resolve(e){return $e.between(e.resolve(this.anchor),e.resolve(this.head))}}class rt extends lt{constructor(e){let n=e.nodeAfter,r=e.node(0).resolve(e.pos+n.nodeSize);super(e,r),this.node=n}map(e,n){let{deleted:r,pos:i}=n.mapResult(this.anchor),o=e.resolve(i);return r?lt.near(o):new rt(o)}content(){return new Le(be.from(this.node),0,0)}eq(e){return e instanceof rt&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Nb(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new rt(e.resolve(n.anchor))}static create(e,n){return new rt(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}rt.prototype.visible=!1;lt.jsonID("node",rt);class Nb{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new Wp(r,r):new Nb(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&rt.isSelectable(r)?new rt(n):lt.near(n)}}class Er extends lt{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=Le.empty){if(n==Le.empty){e.delete(0,e.doc.content.size);let r=lt.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new Er(e)}map(e){return new Er(e)}eq(e){return e instanceof Er}getBookmark(){return o5}}lt.jsonID("all",Er);const o5={map(){return this},resolve(t){return new Er(t)}};function nl(t,e,n,r,i,o=!1){if(e.inlineContent)return $e.create(t,n);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&&rt.isSelectable(a))return rt.create(t,n-(i<0?a.nodeSize:0))}else{let l=nl(t,a,n+i,i<0?a.childCount:0,i,o);if(l)return l}n+=a.nodeSize*i}return null}function kw(t,e,n){let r=t.steps.length-1;if(r<e)return;let i=t.steps[r];if(!(i instanceof Ln||i instanceof Hn))return;let o=t.mapping.maps[r],s;o.forEach((a,l,c,u)=>{s==null&&(s=u)}),t.setSelection(lt.near(t.doc.resolve(s),n))}const _w=1,Xd=2,Cw=4;let s5=class extends Rb{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|_w)&~Xd,this.storedMarks=null,this}get selectionSet(){return(this.updated&_w)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Xd,this}ensureMarks(e){return qt.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&Xd)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~Xd,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,n=!0){let r=this.selection;return n&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||qt.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,n,r){let i=this.doc.type.schema;if(n==null)return e?this.replaceSelectionWith(i.text(e),!0):this.deleteSelection();{if(r==null&&(r=n),!e)return this.deleteRange(n,r);let o=this.storedMarks;if(!o){let s=this.doc.resolve(n);o=r==n?s.marks():s.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(n,r,i.text(e,o)),!this.selection.empty&&this.selection.to==n+e.length&&this.setSelection(lt.near(this.selection.$to)),this}}setMeta(e,n){return this.meta[typeof e=="string"?e:e.key]=n,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|=Cw,this}get scrolledIntoView(){return(this.updated&Cw)>0}};function Sw(t,e){return!e||!t?t:t.bind(e)}class jc{constructor(e,n,r){this.name=e,this.init=Sw(n.init,r),this.apply=Sw(n.apply,r)}}const a5=[new jc("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new jc("selection",{init(t,e){return t.selection||lt.atStart(e.doc)},apply(t){return t.selection}}),new jc("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new jc("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class rg{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=a5.slice(),n&&n.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 jc(r.key,r.spec.state,r))})}}class ll{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,n=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=n){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 n=[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,u=l<n.length&&a.spec.appendTransaction.call(a,l?n.slice(l):n,c,r);if(u&&r.filterTransaction(u,s)){if(u.setMeta("appendedTransaction",e),!i){i=[];for(let f=0;f<this.config.plugins.length;f++)i.push(f<s?{state:r,n:n.length}:{state:this,n:0})}n.push(u),r=r.applyInner(u),o=!0}i&&(i[s]={state:r,n:n.length})}}if(!o)return{state:r,transactions:n}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let n=new ll(this.config),r=this.config.fields;for(let i=0;i<r.length;i++){let o=r[i];n[o.name]=o.apply(e,this[o.name],this,n)}return n}get tr(){return new s5(this)}static create(e){let n=new rg(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new ll(n);for(let i=0;i<n.fields.length;i++)r[n.fields[i].name]=n.fields[i].init(e,r);return r}reconfigure(e){let n=new rg(this.schema,e.plugins),r=n.fields,i=new ll(n);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 n={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(n.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&&(n[r]=o.toJSON.call(i,this[i.key]))}return n}static fromJSON(e,n,r){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let i=new rg(e.schema,e.plugins),o=new ll(i);return i.fields.forEach(s=>{if(s.name=="doc")o.doc=_s.fromJSON(e.schema,n.doc);else if(s.name=="selection")o.selection=lt.fromJSON(o.doc,n.selection);else if(s.name=="storedMarks")n.storedMarks&&(o.storedMarks=n.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(n,a)){o[s.name]=c.fromJSON.call(l,e,n[a],o);return}}o[s.name]=s.init(e,o)}}),o}}function eS(t,e,n){for(let r in t){let i=t[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=eS(i,e,{})),n[r]=i}return n}class Lt{constructor(e){this.spec=e,this.props={},e.props&&eS(e.props,this,this.props),this.key=e.key?e.key.key:tS("plugin")}getState(e){return e[this.key]}}const ig=Object.create(null);function tS(t){return t in ig?t+"$"+ ++ig[t]:(ig[t]=0,t+"$")}class Ut{constructor(e="key"){this.key=tS(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const kh=[{keys:"Ctrl+B",description:"Bold"},{keys:"Ctrl+I",description:"Italic"},{keys:"Ctrl+Z",description:"Undo"},{keys:"Ctrl+Y",description:"Redo"},{keys:"? or Ctrl+/",description:"Show keyboard shortcuts"},{keys:"Ctrl+Tab",description:"Next document tab"},{keys:"Ctrl+Shift+Tab",description:"Previous document tab"},{keys:"Ctrl+1 – Ctrl+9",description:"Jump to tab by number"},{keys:"Ctrl+Alt+1",description:"Heading 1"},{keys:"Ctrl+Alt+2",description:"Heading 2"},{keys:"Ctrl+Alt+3",description:"Heading 3"},{keys:"Ctrl+Alt+4",description:"Heading 4"},{keys:"Ctrl+Alt+5",description:"Heading 5"},{keys:"Ctrl+Alt+6",description:"Heading 6"}];function ev(t){const e=[];return t.state.doc.descendants((n,r)=>{n.type.name==="heading"&&n.attrs.level<=3&&e.push({text:n.textContent,level:n.attrs.level,pos:r})}),e}var l5=T('<div style="font-size: var(--tandem-text-xs); color: var(--tandem-fg-subtle); margin-top: var(--tandem-space-1);"><!> <!> <!> <!></div>'),c5=T('<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>'),u5=T('<span style="font-size: var(--tandem-text-xs); color: var(--tandem-fg-faint); font-family: var(--tandem-font-mono);"> </span>'),d5=T('<span style="font-size: var(--tandem-text-sm);"> </span> <!>',1),f5=T(`<span style="display: flex; align-items: center; gap: var(--tandem-space-2);"><span style="
11
+ font-size: var(--tandem-text-xs);
12
+ color: var(--tandem-fg-subtle);
13
+ font-family: var(--tandem-font-mono);
14
+ min-width: 20px;
15
+ "> </span> <span> </span></span>`),h5=T('<span style="font-size: var(--tandem-text-xs); color: var(--tandem-fg-subtle); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;"> </span>'),p5=T('<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),m5=T('<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),g5=T('<li role="option"><!></li>'),v5=T(`<div role="presentation" class="palette-scrim svelte-gunx66" style="
16
+ position: fixed; inset: 0;
17
+ background: rgba(0,0,0,0.4);
18
+ backdrop-filter: blur(2px);
19
+ z-index: var(--tandem-z-above-titlebar);
20
+ display: flex; align-items: flex-start; justify-content: center;
21
+ padding-top: 15vh;
22
+ "><div data-testid="command-palette" role="dialog" tabindex="-1" aria-modal="true" aria-label="Command palette" class="palette-modal svelte-gunx66" style="
23
+ width: 640px; max-width: 92vw;
24
+ background: var(--tandem-surface);
25
+ border: 1px solid var(--tandem-border);
26
+ border-radius: var(--tandem-r-5);
27
+ box-shadow: var(--tandem-shadow-4);
28
+ overflow: hidden;
29
+ display: flex; flex-direction: column;
30
+ "><div style="padding: var(--tandem-space-3) var(--tandem-space-4); border-bottom: 1px solid var(--tandem-border);"><div style="display: flex; align-items: center; gap: var(--tandem-space-2);"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="var(--tandem-fg-faint)" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" style="flex-shrink: 0;"><circle cx="11" cy="11" r="7"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line></svg> <input data-testid="palette-input" type="text" aria-label="Search commands" aria-controls="palette-results" style="
31
+ flex: 1; min-width: 0; padding: 6px 0;
32
+ font-size: var(--tandem-text-md); color: var(--tandem-fg);
33
+ background: transparent; border: none; outline: none;
34
+ "/> <span class="palette-kbd svelte-gunx66" aria-hidden="true">Esc</span></div> <!></div> <ul id="palette-results" role="listbox" aria-label="Results" class="tandem-scroll-fade-y" style="max-height: 400px; overflow-y: auto; padding: var(--tandem-space-1); list-style: none; margin: 0;"><!></ul> <div style="
35
+ padding: var(--tandem-space-2) var(--tandem-space-4);
36
+ border-top: 1px solid var(--tandem-border);
37
+ background: var(--tandem-surface-muted);
38
+ display: flex; align-items: center; gap: var(--tandem-space-3);
39
+ font-size: var(--tandem-text-xs); color: var(--tandem-fg-subtle);
40
+ "><span><kbd class="palette-kbd svelte-gunx66">#</kbd> headings</span> <span><kbd class="palette-kbd svelte-gunx66">@</kbd> annotations</span> <span><kbd class="palette-kbd svelte-gunx66">?</kbd> shortcuts</span> <span><kbd class="palette-kbd svelte-gunx66">&gt;</kbd> commands</span></div></div></div>`);function b5(t,e){We(e,!0);let n=Ue(e,"editor",3,null),r=Ue(e,"annotations",19,()=>[]),i=F(""),o=F(0),s=F(null);const a=["#","@","?",">"],l=L(()=>a.find(M=>d(i).startsWith(M))??null),c=L(()=>(d(l)?d(i).slice(1):d(i)).trim().toLowerCase()),u=L(()=>{var B;if(d(l)!==null&&d(l)!==">")return[];const M=ph(),N=d(c),R=[];for(const Z of M.values())(!N||Z.label.toLowerCase().includes(N)||Z.group.toLowerCase().includes(N)||(((B=Z.shortcut)==null?void 0:B.toLowerCase().includes(N))??!1))&&R.push({kind:"action",id:Z.id,action:Z});return R}),f=L(()=>{if(d(l)!=="#")return[];const M=n();if(!M||M.isDestroyed)return[];const N=d(c);return ev(M).filter(R=>!N||R.text.toLowerCase().includes(N)).map((R,B)=>({kind:"heading",id:`heading-${B}`,...R}))}),h=L(()=>{if(d(l)!=="@")return[];const M=d(c);return r().filter(N=>{var R;return M?N.content.toLowerCase().includes(M)||((R=N.textSnapshot)==null?void 0:R.toLowerCase().includes(M)):!0}).slice(0,50).map(N=>({kind:"annotation",id:`annotation-${N.id}`,label:N.content?N.content.slice(0,60):"(no content)",snippet:N.textSnapshot??"",annotationType:N.type}))}),p=L(()=>{if(d(l)!=="?")return[];const M=d(c),N=ph(),R=[];for(const B of N.values())B.shortcut&&(!M||B.label.toLowerCase().includes(M)||B.shortcut.toLowerCase().includes(M))&&R.push({kind:"shortcut",id:`shortcut-registry-${B.id}`,keys:B.shortcut,description:B.label,group:B.group});for(let B=0;B<kh.length;B++){const Z=kh[B];(!M||Z.description.toLowerCase().includes(M)||Z.keys.toLowerCase().includes(M))&&R.push({kind:"shortcut",id:`shortcut-static-${B}`,keys:Z.keys,description:Z.description,group:"other"})}return R}),m=L(()=>[...d(u),...d(f),...d(h),...d(p)]);he(()=>{d(m),y(o,0)}),he(()=>{e.open&&(y(i,""),y(o,0),Promise.resolve().then(()=>{var M;return(M=d(s))==null?void 0:M.focus()}))}),cc(()=>{const M=N=>{N.key!=="Escape"||!e.open||(N.preventDefault(),N.stopPropagation(),b())};return window.addEventListener("keydown",M,{capture:!0}),()=>window.removeEventListener("keydown",M,{capture:!0})});const v={"#":"Search headings…","@":"Search annotations…","?":"Search shortcuts…",">":"Search commands…"},g=L(()=>d(l)?v[d(l)]:"Type a command, # headings, @ annotations, ? shortcuts…");function b(){e.onClose()}function _(M){var N;if(M.kind==="action")b(),M.action.run();else if(M.kind==="heading"){b();const R=n();if(!R||R.isDestroyed)return;const B=M.pos;try{const Z=R.state.doc.resolve(B+1),q=$e.near(Z);R.view.dispatch(R.state.tr.setSelection(q).scrollIntoView()),R.view.focus()}catch{}}else M.kind==="annotation"&&(b(),(N=e.onFocusAnnotation)==null||N.call(e,M.id.replace("annotation-","")))}function k(M){const N=d(m).length;if(M.key==="ArrowDown")M.preventDefault(),y(o,(d(o)+1)%Math.max(1,N));else if(M.key==="ArrowUp")M.preventDefault(),y(o,(d(o)-1+Math.max(1,N))%Math.max(1,N));else if(M.key==="Enter"){M.preventDefault();const R=d(m)[d(o)];R&&_(R)}else M.key==="Escape"&&(M.preventDefault(),b())}function C(M){M.target===M.currentTarget&&b()}var E=Mt(),I=Ie(E);{var A=M=>{var N=v5(),R=w(N),B=w(R),Z=w(B),q=x(w(Z),2);St(q,se=>y(s,se),()=>d(s));var Y=x(Z,2);{var X=se=>{var me=l5(),K=w(me);{var H=Se=>{var ee=hr("Searching document headings");S(Se,ee)};W(K,Se=>{d(l)==="#"&&Se(H)})}var O=x(K,2);{var G=Se=>{var ee=hr("Searching annotations");S(Se,ee)};W(O,Se=>{d(l)==="@"&&Se(G)})}var z=x(O,2);{var Q=Se=>{var ee=hr("Showing keyboard shortcuts");S(Se,ee)};W(z,Se=>{d(l)==="?"&&Se(Q)})}var ge=x(z,2);{var ye=Se=>{var ee=hr("Filtering commands");S(Se,ee)};W(ge,Se=>{d(l)===">"&&Se(ye)})}S(se,me)};W(Y,se=>{d(l)&&se(X)})}var ae=x(B,2),ne=w(ae);{var te=se=>{var me=c5(),K=w(me);j(()=>J(K,d(l)==="#"?"No headings found":d(l)==="@"?"No annotations found":d(l)==="?"?"No shortcuts found":"No commands match")),S(se,me)},le=se=>{var me=Mt(),K=Ie(me);nt(K,19,()=>d(m),H=>H.id,(H,O,G)=>{const z=L(()=>d(G)===d(o));var Q=g5(),ge=w(Q);{var ye=xe=>{var Ee=d5(),D=Ie(Ee),$=w(D),ke=x(D,2);{var we=Ae=>{var pe=u5(),oe=w(pe);j(()=>J(oe,d(O).action.shortcut)),S(Ae,pe)};W(ke,Ae=>{d(O).action.shortcut&&Ae(we)})}j(()=>J($,d(O).action.label)),S(xe,Ee)},Se=xe=>{var Ee=f5(),D=w(Ee),$=w(D),ke=x(D,2),we=w(ke);j(()=>{J($,`H${d(O).level??""}`),Me(ke,`font-size: var(--tandem-text-sm); padding-left: calc(${d(O).level-1} * var(--tandem-space-2));`),J(we,d(O).text)}),S(xe,Ee)},ee=xe=>{var Ee=p5(),D=Ie(Ee),$=w(D),ke=w($),we=x($,2);{var Ae=De=>{var ze=h5(),Ge=w(ze);j(()=>J(Ge,`"${d(O).snippet??""}"`)),S(De,ze)};W(we,De=>{d(O).snippet&&De(Ae)})}var pe=x(D,2),oe=w(pe);j(De=>{J(ke,d(O).label),J(oe,De)},[()=>d(O).annotationType.charAt(0).toUpperCase()+d(O).annotationType.slice(1)]),S(xe,Ee)},de=xe=>{var Ee=m5(),D=Ie(Ee),$=w(D),ke=x(D,2),we=w(ke);j(()=>{J($,d(O).description),J(we,d(O).keys)}),S(xe,Ee)};W(ge,xe=>{d(O).kind==="action"?xe(ye):d(O).kind==="heading"?xe(Se,1):d(O).kind==="annotation"?xe(ee,2):d(O).kind==="shortcut"&&xe(de,3)})}j(()=>{V(Q,"id",`palette-item-${d(O).id}`),V(Q,"data-testid",`palette-item-${d(O).id}`),V(Q,"aria-selected",d(z)),Me(Q,`
41
+ display: flex; align-items: center; justify-content: space-between;
42
+ padding: 8px var(--tandem-space-3);
43
+ border-radius: var(--tandem-r-3);
44
+ transition: background 80ms;
45
+ cursor: ${d(O).kind==="shortcut"?"default":"pointer"};
46
+ background: ${d(z)?"var(--tandem-accent-bg)":"transparent"};
47
+ color: ${d(z)?"var(--tandem-accent-fg-strong)":"var(--tandem-fg)"};
48
+ `)}),P("click",Q,()=>_(d(O))),hn("mouseenter",Q,()=>y(o,d(G),!0)),S(H,Q)}),S(se,me)};W(ne,se=>{d(m).length===0?se(te):se(le,-1)})}Tr(ae,(se,me)=>jt==null?void 0:jt(se,me),()=>"y"),j(()=>{V(q,"placeholder",d(g)),V(q,"aria-activedescendant",d(m)[d(o)]?`palette-item-${d(m)[d(o)].id}`:void 0)}),P("click",N,C),P("keydown",N,se=>{se.key==="Escape"&&b()}),P("keydown",R,k),Xn(q,()=>d(i),se=>y(i,se)),S(M,N)};W(I,M=>{e.open&&M(A)})}S(t,E),Ke()}et(["click","keydown"]);var y5=T('<div class="tandem-banner tandem-banner--error" role="status" aria-live="polite" data-testid="connection-banner"><span class="tandem-banner__icon" aria-hidden="true"><svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M2 2l20 20"></path><path d="M5.16 5.26A6 6 0 008 17h11a4 4 0 00.74-7.93"></path><path d="M12 7a5 5 0 014.9 4"></path></svg></span> <span class="tandem-banner__message">Connection to the Tandem server has been lost. Ensure the server is running.</span> <button type="button" class="tandem-banner__cta" data-testid="connection-banner-retry">Retry now</button> <button type="button" class="tandem-banner__dismiss" aria-label="Dismiss connection banner"><svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M6 6l12 12M6 18L18 6"></path></svg></button></div>');function w5(t,e){var n=y5(),r=x(w(n),4),i=x(r,2);P("click",r,function(...o){var s;(s=e.onRetry)==null||s.apply(this,o)}),P("click",i,function(...o){var s;(s=e.onDismiss)==null||s.apply(this,o)}),S(t,n)}et(["click"]);function Kee(t){return t?t.osSupported?t.coworkDetected?"normal":"undetected":"unsupported":"loading"}function x5(t){switch(t.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 ${t.exitCode}). Details: ${k5(t.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 (${t.kind}). Please restart Tandem.`}}function k5(t){const e=t.trim();return e.length===0?"(no output)":e.length<=200?e:`${e.slice(0,197)}...`}function nS(t){try{const e=JSON.parse(t);if(typeof e=="object"&&e!==null&&"kind"in e&&typeof e.kind=="string")try{return x5(e)}catch(n){return console.error("[cowork] firewallErrorHint failed for:",e,n),t}return t}catch{return t}}function Gee(t){switch(t){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 Zee(t){switch(t){case"ok":case"alreadyPresent":return"success";case"locked":return"warning";case"schemaDrift":case"insecureAcl":case"failed":return"error"}}function Yee(t){const e=["failed","schemaDrift","insecureAcl","locked","alreadyPresent","ok"],n=[t.installedPlugins,t.knownMarketplaces,t.coworkSettings];for(const r of e)if(n.includes(r))return r;return"ok"}function rS(t,e){return!(!t||e||!t.osSupported||!t.coworkDetected||t.enabled)}function iS(){try{return localStorage.getItem(aC)==="true"}catch{return!1}}function _5(){try{localStorage.setItem(aC,"true")}catch{}}function Pt(){try{return typeof window<"u"&&"__TAURI_INTERNALS__"in window}catch{return!1}}function Jee(t){let e=null;return{schedule(n){e!==null&&clearTimeout(e),e=setTimeout(()=>{e=null,n()},t)},cancel(){e!==null&&(clearTimeout(e),e=null)}}}const oS="Tauri runtime not available";async function Ta(){try{return(await yn(()=>import("./core-DhEqZVGG.js"),[])).invoke}catch(t){return Pt()&&console.error("[cowork] Failed to load @tauri-apps/api/core:",t),(()=>Promise.reject(new Error(oS)))}}function C5(t){return t("cowork_get_status")}function sS(t,e){return t("cowork_toggle_integration",{enabled:e})}function Xee(t){return t("cowork_rescan")}function Qee(t,e){return t("cowork_set_lan_ip_override",{enabled:e})}function S5(t){return t("cowork_retry_admin_elevation")}function aS(t){let e=F(null),n=F(!1),r=F(null),i=null,o=!1,s=!0,a=null;gr(()=>{s=!1,a!==null&&(clearInterval(a),a=null)});const l=async()=>{if(o){s&&y(n,!1);return}const c=i;if(c)try{const u=await C5(c);if(!s)return;y(e,u,!0),y(r,null)}catch(u){if(!s)return;const f=u instanceof Error?u.message:String(u);if(f===oS){o=!0,a!==null&&(clearInterval(a),a=null),y(n,!1);return}y(r,f,!0)}finally{s&&y(n,!1)}};return he(()=>{if(!t()){y(n,!1);return}let u=!1;return Ta().then(f=>{if(!u)return i=f,y(n,!0),l()}).catch(f=>{if(u)return;const h=f instanceof Error?f.message:String(f);y(r,h,!0),y(n,!1)}),a=setInterval(()=>{u||o||l()},kD),()=>{u=!0,a!==null&&(clearInterval(a),a=null)}}),{get status(){return d(e)},get loading(){return d(n)},get error(){return d(r)},refetch:l}}var E5=T(`<div class="cad-toast svelte-cbdwov" data-testid="cowork-admin-declined-status-error" role="alert">Cowork status check failed: unable to determine if admin elevation was declined. Please
49
+ restart Tandem to restore normal operation.</div>`),A5=T('<div class="cad-error svelte-cbdwov" data-testid="cowork-admin-declined-error" role="alert"> </div>'),T5=T('<div class="cad-warning-banner svelte-cbdwov" data-testid="cowork-admin-declined-confirm-disable"><div class="cad-confirm-heading svelte-cbdwov">Disable Cowork integration?</div> <div class="cad-confirm-body svelte-cbdwov">The deny rule will remain in place. You can re-enable Cowork later from Settings.</div> <div class="cad-actions svelte-cbdwov"><button class="cad-btn cad-btn--destructive svelte-cbdwov" data-testid="cowork-admin-declined-disable-confirm-btn" type="button">Disable</button> <button class="cad-btn cad-btn--ghost svelte-cbdwov" data-testid="cowork-admin-declined-disable-cancel-btn" type="button">Cancel</button></div></div>'),M5=T('<div class="cad-actions cad-actions--right svelte-cbdwov"><button class="cad-btn cad-btn--ghost cad-btn--lg svelte-cbdwov" data-testid="cowork-admin-declined-disable-btn" type="button">Disable Cowork</button> <button class="cad-btn cad-btn--primary cad-btn--lg svelte-cbdwov" data-testid="cowork-admin-declined-retry-btn" type="button">Retry with admin</button></div>'),D5=T(`<div class="cad-backdrop svelte-cbdwov" data-testid="cowork-admin-declined-backdrop"><div class="cad-dialog svelte-cbdwov" data-testid="cowork-admin-declined-modal" role="dialog" aria-modal="true" aria-labelledby="cowork-admin-declined-heading"><h2 class="cad-heading svelte-cbdwov" id="cowork-admin-declined-heading">Admin permission required</h2> <div class="cad-description svelte-cbdwov">Cowork integration requires Windows admin permission to configure firewall rules. Without
50
+ it, Tandem can't safely be reached from inside the Cowork VM. Port 3479 is currently
51
+ blocked by a deny rule to protect your machine.</div> <!> <!></div></div>`);function O5(t,e){We(e,!0);const n='button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])',r=aS(()=>!0),i=L(()=>{var g;return((g=r.status)==null?void 0:g.uacDeclined)===!0});let o=F(void 0),s=F(!1),a=F(!1),l=F(null);he(()=>{if(!d(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(!d(i))return;const g=b=>{if(b.key!=="Tab"||!d(o))return;const _=d(o).querySelectorAll(n);if(_.length===0)return;const k=_[0],C=_[_.length-1],E=document.activeElement;if(!d(o).contains(E)){b.preventDefault(),k.focus();return}b.shiftKey&&E===k?(b.preventDefault(),C.focus()):!b.shiftKey&&E===C&&(b.preventDefault(),k.focus())};return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)}),he(()=>{var g;d(i)&&((g=d(o))==null||g.focus())});async function c(g,b){y(a,!0),y(l,null);try{const _=await Ta();await g(_)}catch(_){const k=_ instanceof Error?_.message:String(_),C=nS(k);y(l,`${b}: ${C}`)}finally{y(a,!1)}}async function u(){await c(async g=>{await S5(g),await r.refetch()},"Retry failed")}async function f(){await c(async g=>{await sS(g,!1),await r.refetch()},"Failed to disable Cowork"),y(s,!1)}var h=Mt(),p=Ie(h);{var m=g=>{var b=E5();S(g,b)},v=g=>{var b=D5(),_=w(b);V(_,"tabindex",-1);var k=x(w(_),4);{var C=M=>{var N=A5(),R=w(N);j(()=>J(R,d(l))),S(M,N)};W(k,M=>{d(l)&&M(C)})}var E=x(k,2);{var I=M=>{var N=T5(),R=x(w(N),4),B=w(R),Z=x(B,2);j(()=>{B.disabled=d(a),Z.disabled=d(a)}),P("click",B,()=>void f()),P("click",Z,()=>{y(s,!1)}),S(M,N)},A=M=>{var N=M5(),R=w(N),B=x(R,2);j(()=>{R.disabled=d(a),B.disabled=d(a)}),P("click",R,()=>{y(s,!0)}),P("click",B,()=>void u()),S(M,N)};W(E,M=>{d(s)?M(I):M(A,-1)})}St(_,M=>y(o,M),()=>d(o)),S(g,b)};W(p,g=>{r.error&&!r.status?g(m):d(i)&&g(v,1)})}S(t,h),Ke()}et(["click"]);var I5=T(`<div class="empty-illus svelte-16uow3k" aria-hidden="true"><svg width="72" height="72" viewBox="0 0 72 72" fill="none" xmlns="http://www.w3.org/2000/svg"><circle cx="13" cy="36" r="9" stroke="var(--tandem-fg-faint)" stroke-width="1.5" fill="var(--tandem-surface)"></circle><circle cx="13" cy="36" r="3.5" fill="var(--tandem-fg-faint)"></circle><circle cx="59" cy="36" r="9" stroke="var(--tandem-border-strong)" stroke-width="1.5" fill="var(--tandem-surface-muted)"></circle><circle cx="59" cy="36" r="3.5" fill="var(--tandem-border-strong)"></circle><line x1="22" y1="36" x2="30" y2="36" stroke="var(--tandem-fg-faint)" stroke-width="1.5" stroke-linecap="round"></line><line x1="42" y1="36" x2="50" y2="36" stroke="var(--tandem-border-strong)" stroke-width="1.5" stroke-linecap="round"></line><line x1="32" y1="31" x2="40" y2="41" stroke="var(--tandem-error)" stroke-width="1.8" stroke-linecap="round"></line><line x1="40" y1="31" x2="32" y2="41" stroke="var(--tandem-error)" stroke-width="1.8" stroke-linecap="round"></line></svg></div> <p class="empty-heading svelte-16uow3k">Server unavailable</p> <p class="empty-sub svelte-16uow3k">Tandem can't reach its sync server. Make sure it's running locally.</p> <div class="empty-actions svelte-16uow3k"><button class="empty-cta svelte-16uow3k" data-testid="empty-state-retry">Retry</button> <button class="empty-link svelte-16uow3k" data-testid="empty-state-open-settings">Open settings</button></div>`,1),R5=T('<p class="empty-sub empty-sub-secondary svelte-16uow3k">Tandem works alongside Claude (the default integration) or any MCP-capable AI client.</p>'),N5=T('<div class="empty-illus svelte-16uow3k" aria-hidden="true"><svg width="72" height="72" viewBox="0 0 72 72" fill="none" xmlns="http://www.w3.org/2000/svg"><rect x="11" y="10" width="36" height="46" rx="3" stroke="var(--tandem-border-strong)" stroke-width="1.2" fill="var(--tandem-surface-muted)"></rect><rect x="20" y="17" width="36" height="46" rx="3" stroke="var(--tandem-fg-faint)" stroke-width="1.5" fill="var(--tandem-surface)"></rect><line x1="27" y1="27" x2="49" y2="27" stroke="var(--tandem-border-strong)" stroke-width="1.1" stroke-linecap="round"></line><line x1="27" y1="33" x2="46" y2="33" stroke="var(--tandem-border-strong)" stroke-width="1.1" stroke-linecap="round"></line><line x1="27" y1="39" x2="49" y2="39" stroke="var(--tandem-border-strong)" stroke-width="1.1" stroke-linecap="round"></line><line x1="27" y1="45" x2="44" y2="45" stroke="var(--tandem-border-strong)" stroke-width="1.1" stroke-linecap="round"></line><circle cx="56" cy="16" r="9" fill="var(--tandem-surface)" stroke="var(--tandem-fg-faint)" stroke-width="1.5"></circle><line x1="56" y1="11.5" x2="56" y2="20.5" stroke="var(--tandem-fg-faint)" stroke-width="1.5" stroke-linecap="round"></line><line x1="51.5" y1="16" x2="60.5" y2="16" stroke="var(--tandem-fg-faint)" stroke-width="1.5" stroke-linecap="round"></line></svg></div> <p class="empty-heading svelte-16uow3k">Nothing open yet</p> <p class="empty-sub svelte-16uow3k">Click + in the tab bar, or drop a Markdown file here.</p> <div class="empty-actions svelte-16uow3k"><button class="empty-cta svelte-16uow3k" data-testid="empty-state-open-file">Open file…</button></div> <!>',1),P5=T('<div class="empty-state svelte-16uow3k"><!></div>');function L5(t,e){We(e,!0);let n=F(!1);he(()=>{if(e.connected){y(n,!1);return}const a=setTimeout(()=>{y(n,!0)},fD);return()=>clearTimeout(a)});var r=P5(),i=w(r);{var o=a=>{var l=I5(),c=x(Ie(l),6),u=w(c),f=x(u,2);P("click",u,function(...h){var p;(p=e.onRetry)==null||p.apply(this,h)}),P("click",f,function(...h){var p;(p=e.onOpenSettings)==null||p.apply(this,h)}),S(a,l)},s=a=>{var l=N5(),c=x(Ie(l),6),u=w(c),f=x(c,2);{var h=p=>{var m=R5();S(p,m)};W(f,p=>{e.connected&&!e.claudeActive&&p(h)})}P("click",u,function(...p){var m;(m=e.onOpenFile)==null||m.apply(this,p)}),S(a,l)};W(i,a=>{d(n)?a(o):a(s,-1)})}S(t,r),Ke()}et(["click"]);function Kp(t,e,n=Date.now(),r=yD){const o=t.find(a=>a.path===e)??{path:e,openedAt:n},s=t.filter(a=>a.path!==e);return[o,...s].slice(0,r)}function Ew(t){return t.map(e=>e.path)}function F5(t,e=Date.now()){if(!t)return"";const n=e-t;if(n<6e4)return"just now";const r=Math.floor(n/6e4);if(r<60)return`${r}m`;const i=Math.floor(r/60);return i<24?`${i}h`:`${Math.floor(i/24)}d`}function Mu(){try{const t=localStorage.getItem(Sb);if(!t)return[];const e=JSON.parse(t);return Array.isArray(e)?e.map(n=>{if(typeof n=="string")return{path:n,openedAt:0};if(n!==null&&typeof n=="object"&&typeof n.path=="string"){const r=n;return{path:r.path,openedAt:typeof r.openedAt=="number"?r.openedAt:0}}return null}).filter(n=>n!==null):[]}catch(t){return console.warn("[tandem] failed to load recent files:",t),[]}}function Gp(t){try{localStorage.setItem(Sb,JSON.stringify(t)),lS()}catch(e){console.warn("[tandem] failed to save recent files:",e)}}function z5(){try{localStorage.removeItem(Sb),lS()}catch(t){console.warn("[tandem] failed to clear recent files:",t)}}const B5=3e4;let qc=null;function Aw(){const t=Date.now();if(qc&&t-qc.ts<B5)return qc.files;const e=Mu();return qc={files:e,ts:t},e}function lS(){qc=null}async function Wo(t,e={}){const{readOnly:n=!1,notFoundMessage:r="File not found.",failureMessage:i="Failed to open file."}=e;try{const o=await fetch(`${On}${YM}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filePath:t,readOnly:n})});if(!o.ok){let s=i;try{const a=await o.json();a.message&&(s=a.message)}catch{}return o.status===404&&(s=r),{ok:!1,error:s}}return{ok:!0}}catch(o){return console.warn("[tandem] openServerPath failed:",o),{ok:!1,error:"Server unavailable."}}}const H5=Array.from(xd).sort().map(t=>t.replace(/^\./,""));async function cS(){const{open:t}=await yn(async()=>{const{open:n}=await import("./index-Dm_QtxGQ.js");return{open:n}},__vite__mapDeps([0,1])),e=await t({multiple:!1,directory:!1,title:"Open file in Tandem",filters:[{name:"Documents",extensions:H5}]});return typeof e=="string"?e:null}async function V5(t={}){var r,i;let e;try{e=await cS()}catch(o){console.error("[tandem] native file picker unavailable:",o),(r=t.onError)==null||r.call(t,`File picker unavailable: ${o instanceof Error?o.message:o}`);return}if(!e)return;const n=await Wo(e);if(!n.ok){(i=t.onError)==null||i.call(t,n.error);return}Gp(Kp(Mu(),e))}async function U5(t){t.isTauri?await V5({onError:t.onError}):t.openModal()}async function uS(t,e){try{const n=await fetch(`${On}${t}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),r=await n.json().catch(()=>({}));return n.ok?{ok:!0,data:r.data??{}}:{ok:!1,error:r.message??"Request failed."}}catch(n){return console.warn("[tandem] sessions request failed:",n),{ok:!1,error:"Server unavailable."}}}async function j5(){var t;try{const e=await fetch(`${On}${rD}`),n=await e.json().catch(()=>({}));return e.ok?{ok:!0,data:((t=n.data)==null?void 0:t.sessions)??[]}:{ok:!1,error:n.message??"Failed to load sessions."}}catch(e){return console.warn("[tandem] fetchSessions failed:",e),{ok:!1,error:"Server unavailable."}}}async function q5(t){return uS(iD,{filePath:t})}async function W5(){return uS(oD,{})}var K5=T('<input type="file" style="display: none;"/>'),G5=T('<p style="margin: 8px 0 0; font-size: 11px; color: var(--tandem-fg-subtle); text-align: center;">…or drop a file anywhere in the window</p>'),Z5=T('<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>'),Y5=T('<div data-testid="recent-files-list" style="margin-top: 16px;"><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 class="tandem-scroll-fade-y" style="max-height: 180px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px;"></div></div>'),J5=T('<p data-testid="sessions-loading" style="margin: 8px 0 0; font-size: 12px; color: var(--tandem-fg-subtle);">Loading…</p>'),X5=T('<p data-testid="sessions-empty" style="margin: 8px 0 0; font-size: 12px; color: var(--tandem-fg-subtle);">No saved sessions.</p>'),Q5=T('<div data-testid="session-row" style="display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-radius: var(--tandem-r-2);"><button type="button" data-testid="session-reopen" style="flex: 1; min-width: 0; background: none; border: none; padding: 0; 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;"> </span> <span style="font-size: 11px; color: var(--tandem-fg-subtle);"> </span></button> <button type="button" data-testid="session-delete" style="background: none; border: none; color: var(--tandem-fg-subtle); font-size: 14px; cursor: pointer; padding: 4px; line-height: 1;">×</button></div>'),$5=T('<div style="display: flex; justify-content: flex-end; margin: 6px 0;"><button data-testid="sessions-clear-all" 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 class="tandem-scroll-fade-y" style="max-height: 200px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px;"></div>',1),e8=T('<div data-testid="sessions-error" style="margin-top: 8px; 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);"> </div>'),t8=T("<!> <!>",1),n8=T('<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>'),r8=T('<div role="dialog" aria-modal="true" aria-label="Open File" style="position: fixed; inset: 0; z-index: var(--tandem-z-above-titlebar); display: flex; align-items: flex-start; justify-content: center; padding-top: 80px; background: color-mix(in srgb, var(--tandem-bg) 70%, transparent);"><div style="background: var(--tandem-surface); border: 1px solid var(--tandem-border); border-radius: var(--tandem-r-5); 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 class="modal-close svelte-ik1xhg" aria-label="Close">×</button></div> <button type="button" data-testid="file-open-browse"> </button> <!> <!> <!> <div data-testid="sessions-section" style="margin-top: 16px;"><button type="button" data-testid="sessions-toggle" style="width: 100%; background: none; border: none; padding: 0; cursor: pointer; display: flex; justify-content: space-between; align-items: center; color: var(--tandem-fg-subtle);"><span style="font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em;">Saved sessions</span> <span style="font-size: 11px;"> </span></button> <!></div> <!></div></div>');function i8(t,e){We(e,!0);let n=F(null),r=F(!1),i=F(void 0),o=F(Qe(Ew(Mu()))),s=F(Qe([])),a=F(!1),l=F(!1),c=F(!1),u=F(null);async function f(){y(l,!0),y(u,null);const ee=await j5();ee.ok?(y(s,ee.data,!0),y(c,!0)):y(u,ee.error,!0),y(l,!1)}function h(){y(a,!d(a)),d(a)&&!d(c)&&!d(l)&&f()}async function p(ee){y(u,null);const de=await q5(ee);de.ok?y(s,d(s).filter(xe=>xe.filePath!==ee),!0):y(u,de.error,!0)}async function m(){y(u,null);const ee=await W5();ee.ok?y(s,[],!0):y(u,ee.error,!0)}function v(ee){if(!ee)return"unknown";const de=Date.now()-ee,xe=Math.floor(de/6e4);if(xe<1)return"just now";if(xe<60)return`${xe}m ago`;const Ee=Math.floor(xe/60);return Ee<24?`${Ee}h ago`:`${Math.floor(Ee/24)}d ago`}const b=Array.from(xd).sort().join(",");function _(ee){const de=Kp(Mu(),ee);Gp(de),y(o,Ew(de),!0)}function k(){z5(),y(o,[],!0)}async function C(ee){if(!d(r)){y(n,null),y(r,!0);try{const de=await Wo(ee);if(!de.ok){y(n,de.error,!0);return}_(ee),e.onClose()}finally{y(r,!1)}}}async function E(){if(!d(r))try{const ee=await cS();ee&&await C(ee)}catch(ee){y(n,`File picker unavailable: ${ee instanceof Error?ee.message:ee}`)}}async function I(ee){if(!d(r)){y(n,null),y(r,!0);try{const de=await lC(ee),xe=await fetch(`${On}${W_}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({fileName:ee.name,content:de})}),Ee=await xe.json();if(!xe.ok){y(n,Ee.message??"Failed to open file",!0);return}e.onClose()}catch(de){console.error("FileOpenDialog: upload failed",de),de instanceof SyntaxError?y(n,"Server returned an unexpected response"):de instanceof TypeError?y(n,"Unexpected response format"):y(n,"Cannot reach server. Is it running?")}finally{y(r,!1)}}}function A(ee){var Ee;const xe=(Ee=ee.target.files)==null?void 0:Ee[0];xe&&I(xe)}function M(){var ee;Pt()?E():(ee=d(i))==null||ee.click()}var N=r8();V(N,"tabindex",-1);var R=w(N),B=w(R),Z=x(w(B),2),q=x(B,2);C6(q);var Y=w(q),X=x(q,2);{var ae=ee=>{var de=K5();St(de,xe=>y(i,xe),()=>d(i)),j(()=>V(de,"accept",b)),P("change",de,A),S(ee,de)},ne=L(()=>!Pt());W(X,ee=>{d(ne)&&ee(ae)})}var te=x(X,2);{var le=ee=>{var de=G5();S(ee,de)},se=L(()=>Pt());W(te,ee=>{d(se)&&ee(le)})}var me=x(te,2);{var K=ee=>{var de=Y5(),xe=w(de),Ee=x(w(xe),2),D=x(xe,2);nt(D,22,()=>d(o),$=>$,($,ke,we)=>{const Ae=L(()=>ke.split(/[/\\]/)),pe=L(()=>d(Ae).at(-1)??ke),oe=L(()=>d(Ae).slice(0,-1).join("/")||"/");var De=Z5(),ze=w(De),Ge=w(ze),Ce=x(ze,2),ie=w(Ce);j(()=>{V(De,"data-testid",`recent-file-${d(we)}`),J(Ge,d(pe)),J(ie,d(oe))}),P("click",De,()=>C(ke)),hn("mouseenter",De,ve=>{ve.currentTarget.style.background="var(--tandem-surface-muted)"}),hn("mouseleave",De,ve=>{ve.currentTarget.style.background="transparent"}),S($,De)}),Tr(D,($,ke)=>jt==null?void 0:jt($,ke),()=>"y"),P("click",Ee,k),S(ee,de)};W(me,ee=>{d(o).length>0&&ee(K)})}var H=x(me,2),O=w(H),G=x(w(O),2),z=w(G),Q=x(O,2);{var ge=ee=>{var de=t8(),xe=Ie(de);{var Ee=Ae=>{var pe=J5();S(Ae,pe)},D=Ae=>{var pe=X5();S(Ae,pe)},$=Ae=>{var pe=$5(),oe=Ie(pe),De=w(oe),ze=x(oe,2);nt(ze,21,()=>d(s),Ge=>Ge.filePath,(Ge,Ce)=>{const ie=L(()=>d(Ce).filePath.split(/[/\\]/)),ve=L(()=>d(ie).at(-1)??d(Ce).filePath),Ye=L(()=>d(ie).slice(0,-1).join("/")||"/");var ut=Q5(),fe=w(ut),Te=w(fe),ce=w(Te),Oe=x(Te,2),He=w(Oe),it=x(Oe,2),Xe=w(it),Re=x(fe,2);j(ot=>{V(fe,"title",d(Ce).filePath),J(ce,d(ve)),J(He,d(Ye)),J(Xe,`${ot??""} · ${d(Ce).annotationCount??""} annotation${d(Ce).annotationCount===1?"":"s"}`),V(Re,"aria-label",`Delete session for ${d(ve)}`)},[()=>v(d(Ce).lastAccessed)]),P("click",fe,()=>C(d(Ce).filePath)),P("click",Re,()=>p(d(Ce).filePath)),S(Ge,ut)}),Tr(ze,(Ge,Ce)=>jt==null?void 0:jt(Ge,Ce),()=>"y"),P("click",De,m),S(Ae,pe)};W(xe,Ae=>{d(l)?Ae(Ee):d(s).length===0?Ae(D,1):Ae($,-1)})}var ke=x(xe,2);{var we=Ae=>{var pe=e8(),oe=w(pe);j(()=>J(oe,d(u))),S(Ae,pe)};W(ke,Ae=>{d(u)&&Ae(we)})}S(ee,de)};W(Q,ee=>{d(a)&&ee(ge)})}var ye=x(H,2);{var Se=ee=>{var de=n8(),xe=w(de);j(()=>J(xe,d(n))),S(ee,de)};W(ye,ee=>{d(n)&&ee(Se)})}j(()=>{q.disabled=d(r),Me(q,`width: 100%; padding: 12px; font-size: 14px; font-weight: 500; border: none; border-radius: var(--tandem-r-2); cursor: ${d(r)?"wait":"pointer"}; background: ${d(r)?"var(--tandem-fg-subtle)":"var(--tandem-accent)"}; color: var(--tandem-accent-fg);`),J(Y,d(r)?"Opening…":"Browse…"),V(O,"aria-expanded",d(a)),J(z,d(a)?"▾":"▸")}),P("click",N,ee=>{ee.target===ee.currentTarget&&e.onClose()}),P("keydown",N,ee=>{ee.key==="Escape"&&e.onClose()}),P("click",Z,function(...ee){var de;(de=e.onClose)==null||de.apply(this,ee)}),P("click",q,M),P("click",O,h),S(t,N),Ke()}et(["click","keydown","change"]);const o8="/api/integrations/existing",s8="/api/integrations",a8="/api/integrations/apply",l8="/api/integrations/first-run-needed";function c8(t){return`/api/integrations/secrets/${encodeURIComponent(t)}`}function u8(t){return`/api/models/secrets/${encodeURIComponent(t)}`}const d8=3,f8="KEYCHAIN_UNAVAILABLE",h8="Tauri runtime not available";async function p8(){try{return(await yn(()=>import("./core-DhEqZVGG.js"),[])).invoke}catch(t){return Pt()&&console.error("[keychain] Failed to load @tauri-apps/api/core:",t),(()=>Promise.reject(new Error(h8)))}}function m8(t,e,n){return t("keychain_set",{account:e,secret:n})}function g8(t,e){return t("keychain_delete",{account:e})}function v8(t={}){const e=t.fetchFn??((...i)=>globalThis.fetch(...i)),n=t.baseUrl??"",r=t.pathFor??c8;return{async set(i,o){try{const s=await e(`${n}${r(i)}`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({secret:o})});if(s.status===503){const a=await s.json().catch(()=>null);if((a==null?void 0:a.code)===f8)return{status:"unavailable"}}return s.ok?{status:"ok"}:{status:"error",message:`HTTP ${s.status}`}}catch(s){return{status:"error",message:s instanceof Error?s.message:String(s)}}},async delete(i){await e(`${n}${r(i)}`,{method:"DELETE"}).catch(()=>{})}}}const b8=["keychain-init","Platform secure storage failure","Couldn't access platform secure storage"];function y8(t){return b8.some(e=>t.includes(e))}function w8(t={}){const e=()=>t.invoke?Promise.resolve(t.invoke):p8();return{async set(n,r){try{const i=await e();return await m8(i,n,r),{status:"ok"}}catch(i){const o=i instanceof Error?i.message:String(i);return y8(o)?{status:"unavailable"}:{status:"error",message:o}}},async delete(n){try{const r=await e();await g8(r,n)}catch{}}}}function dS(t={}){return t.force==="tauri"||t.force!=="http"&&Pt()?w8({invoke:t.invoke}):v8({fetchFn:t.fetchFn,baseUrl:t.baseUrl,pathFor:t.pathFor})}const x8=["narrow","comfortable","wide","full"],Tw={narrow:"58ch",comfortable:"68ch",wide:"82ch",full:"100%"};function fS(t){return typeof t=="string"&&x8.includes(t)}const hS=["anthropic","openai","gemini","local-ollama","local-llamacpp"],k8=50,_8={s:14,m:16,l:18};function pS(){try{return typeof window>"u"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!1}}const vn={leftPanelVisible:!1,rightPanelVisible:!0,schemaVersion:13,primaryTab:"annotations",panelOrder:"chat-editor-annotations",editorMeasure:"comfortable",selectionDwellMs:Q_,showAuthorship:!0,reduceMotion:!1,textSize:"m",theme:"system",accentHue:275,editorFont:"sans",fontByExtension:{},density:"cozy",defaultMode:"tandem",highContrast:!1,annotationPatterns:!1,selectionToolbar:!0,formattingBarVisible:!0,soloRailHidden:!0,degradedBannerDelayMs:3e4,sidecarRetryStrategy:"exponential",holdAnnotationsWhileOffline:!0,marginView:!1,showComments:!0,showHighlights:!0,showNotes:!0,showRawMarkdown:!0,decorationsMuted:!1,models:[],defaultModelId:null,customShortcuts:{}},C8=64,S8=512;function mS(t){if(!Array.isArray(t))return[];const e=[];for(const n of t){if(e.length>=k8)break;if(!n||typeof n!="object")continue;const r=n;if(typeof r.id!="string"||r.id.length===0||r.id.length>64||typeof r.provider!="string"||!hS.includes(r.provider)||typeof r.displayName!="string"||r.displayName.length>256||typeof r.modelId!="string"||r.modelId.length===0||r.modelId.length>256||typeof r.enabled!="boolean")continue;const i={id:r.id,provider:r.provider,displayName:r.displayName,modelId:r.modelId,enabled:r.enabled};if(typeof r.apiKeyRef=="string"&&r.apiKeyRef.length>0&&r.apiKeyRef.length<=C8&&/^[A-Za-z0-9_-]+$/.test(r.apiKeyRef)?i.apiKeyRef=r.apiKeyRef:typeof r.apiKey=="string"&&r.apiKey.length<=S8&&(i._legacyApiKey=r.apiKey),typeof r.endpoint=="string"&&r.endpoint.length<=2048&&(i.endpoint=r.endpoint),r.params&&typeof r.params=="object"&&!Array.isArray(r.params)){const o={};for(const[s,a]of Object.entries(r.params))(typeof a=="number"||typeof a=="string"||typeof a=="boolean")&&(o[s]=a);i.params=o}e.push(i)}return e}const E8=["serif","sans","mono"];function gS(t){if(!t||typeof t!="object"||Array.isArray(t))return{};const e={};for(const[n,r]of Object.entries(t))n==="__proto__"||n==="constructor"||n==="prototype"||typeof n!="string"||n.length===0||n.length>32||typeof r=="string"&&E8.includes(r)&&(e[n]=r);return e}const Uf=13;function Mw(t){return{leftPanelVisible:t.leftPanelVisible===!0,rightPanelVisible:t.rightPanelVisible!==!1,schemaVersion:Uf,primaryTab:t.primaryTab==="annotations"?"annotations":"chat",panelOrder:t.panelOrder==="annotations-editor-chat"?"annotations-editor-chat":"chat-editor-annotations",editorMeasure:fS(t.editorMeasure)?t.editorMeasure:vn.editorMeasure,selectionDwellMs:Math.max(jl,Math.min(ql,Number(t.selectionDwellMs)||Q_)),showAuthorship:t.showAuthorship===!1?!1:vn.showAuthorship,reduceMotion:typeof t.reduceMotion=="boolean"?t.reduceMotion:pS(),textSize:t.textSize==="s"||t.textSize==="m"||t.textSize==="l"?t.textSize:vn.textSize,theme:t.theme==="light"||t.theme==="dark"||t.theme==="warm"||t.theme==="system"?t.theme:vn.theme,accentHue:typeof t.accentHue=="number"&&t.accentHue>=0&&t.accentHue<=360?t.accentHue:vn.accentHue,editorFont:t.editorFont==="serif"||t.editorFont==="sans"||t.editorFont==="mono"?t.editorFont:vn.editorFont,fontByExtension:gS(t.fontByExtension),density:t.density==="compact"||t.density==="cozy"||t.density==="spacious"?t.density:vn.density,defaultMode:t.defaultMode==="solo"||t.defaultMode==="tandem"?t.defaultMode:vn.defaultMode,highContrast:t.highContrast===!0,annotationPatterns:t.annotationPatterns===!0,selectionToolbar:t.selectionToolbar===!1?!1:vn.selectionToolbar,formattingBarVisible:t.formattingBarVisible===!1?!1:vn.formattingBarVisible,soloRailHidden:t.soloRailHidden===!1?!1:vn.soloRailHidden,degradedBannerDelayMs:typeof t.degradedBannerDelayMs=="number"&&t.degradedBannerDelayMs>=5e3&&t.degradedBannerDelayMs<=12e4?t.degradedBannerDelayMs:vn.degradedBannerDelayMs,sidecarRetryStrategy:t.sidecarRetryStrategy==="exponential"||t.sidecarRetryStrategy==="constant-2s"||t.sidecarRetryStrategy==="manual"?t.sidecarRetryStrategy:vn.sidecarRetryStrategy,holdAnnotationsWhileOffline:typeof t.holdAnnotationsWhileOffline=="boolean"?t.holdAnnotationsWhileOffline:vn.holdAnnotationsWhileOffline,marginView:t.marginView===!0,showComments:t.showComments===!1?!1:vn.showComments,showHighlights:t.showHighlights===!1?!1:vn.showHighlights,showNotes:t.showNotes===!1?!1:vn.showNotes,showRawMarkdown:t.showRawMarkdown===!1?!1:vn.showRawMarkdown,decorationsMuted:t.decorationsMuted===!0,models:mS(t.models),defaultModelId:typeof t.defaultModelId=="string"&&t.defaultModelId.length>0?t.defaultModelId:null,customShortcuts:Tb(t.customShortcuts)}}function Pb(){let t;try{t=localStorage.getItem(J_)}catch{t=null}if(t)try{let e=JSON.parse(t);if((!e||typeof e!="object"||Array.isArray(e))&&(e={leftPanelVisible:!1,rightPanelVisible:!0,schemaVersion:1}),(typeof e.schemaVersion=="number"?e.schemaVersion:1)===1){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}if(e.schemaVersion===2&&(e={...e,models:[],schemaVersion:3}),e.schemaVersion===3&&(e={...e,schemaVersion:4}),e.schemaVersion===4){const r={...e,schemaVersion:5};delete r.leftRailTabs,delete r.rightRailTabs,e=r}if(e.schemaVersion===5){const r={...e,schemaVersion:6};delete r.showIntegrationWizard,e=r}if(e.schemaVersion===6){const i=(Array.isArray(e.models)?e.models:[]).find(o=>typeof(o==null?void 0:o.id)=="string"&&o.enabled===!0);e={...e,schemaVersion:7,defaultModelId:i&&typeof i.id=="string"?i.id:null}}if(e.schemaVersion===7&&(e={...e,schemaVersion:8}),e.schemaVersion===8){const r=e.showAnnotationDecorations===!1,i={...e,showComments:!r,showHighlights:!r,showNotes:!r,decorationsMuted:!1,schemaVersion:9};delete i.showAnnotationDecorations,e=i}if(e.schemaVersion===9&&(e={...e,schemaVersion:10}),e.schemaVersion===10&&(e={...e,schemaVersion:11}),e.schemaVersion===11){const r={...e,schemaVersion:12};if(r.editorMeasure===void 0){const i=e.editorWidthPercent;r.editorMeasure=i===void 0||i===100?"full":"comfortable"}delete r.editorWidthPercent,e=r}if(e.showAnnotationDecorations===!1&&e.showComments===void 0&&(e={...e,showComments:!1,showHighlights:!1,showNotes:!1}),e.schemaVersion===12&&(e={...e,schemaVersion:13}),typeof e.schemaVersion=="number"&&e.schemaVersion>Uf){console.warn(`[tandem] settings schemaVersion=${e.schemaVersion} is newer than v${Uf}; loading defensively without writing.`);const r=e.editorMeasure,i=Mw(e);typeof r=="string"&&r!==i.editorMeasure&&console.warn(`[tandem] editorMeasure=${JSON.stringify(r)} from newer client is unknown to v${Uf}; displaying as ${JSON.stringify(i.editorMeasure)} (your setting is preserved on-disk).`);const o=new Set(Object.keys(i)),s=new Set(["leftRailTabs","rightRailTabs","showIntegrationWizard","showAnnotationDecorations","editorWidthPercent"]),a={};for(const[l,c]of Object.entries(e))!o.has(l)&&l!=="_readOnly"&&!s.has(l)&&(a[l]=c);return{...i,...a,_readOnly:!0}}return Mw(e)}catch(e){console.warn("[tandem] settings JSON is corrupt, resetting to defaults:",e)}return{...vn,reduceMotion:pS()}}function A8(t,e){const n={...t,...e},r=mS(n.models);return{...n,customShortcuts:Tb(n.customShortcuts),fontByExtension:gS(n.fontByExtension),selectionDwellMs:Math.max(jl,Math.min(ql,n.selectionDwellMs)),accentHue:Number.isFinite(n.accentHue)?Math.max(0,Math.min(360,n.accentHue)):vn.accentHue,editorMeasure:fS(n.editorMeasure)?n.editorMeasure:vn.editorMeasure,degradedBannerDelayMs:Math.max(5e3,Math.min(12e4,n.degradedBannerDelayMs)),models:r,defaultModelId:typeof n.defaultModelId=="string"&&r.some(i=>i.id===n.defaultModelId)?n.defaultModelId:null}}function T8(t,e){var n;if(e){const r=(n=t.fontByExtension)==null?void 0:n[e];if(r)return r}return t.editorFont}let Qd=null;function Dw(t){const e=t.decorationsMuted;try{localStorage.setItem(tC,String(!e&&t.showAuthorship)),localStorage.setItem(nC,JSON.stringify({comment:!e&&t.showComments,highlight:!e&&t.showHighlights,note:!e&&t.showNotes}))}catch{}}function Or(){if(Qd)return Qd;const t=Pb();let e=F(Qe(t));return Dw(t),Qd={get settings(){return d(e)},updateSettings:r=>{if(d(e)._readOnly)return;const i=A8(d(e),r);try{localStorage.setItem(J_,JSON.stringify(i))}catch{}Dw(i),y(e,i,!0)}},Qd}const tv=dS({baseUrl:`http://127.0.0.1:${uc}`,pathFor:u8});function og(){const t=new Uint8Array(16);crypto.getRandomValues(t);let e="";for(const n of t)e+=String.fromCharCode(n);return btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function M8(){return crypto.randomUUID()}function Ow(t){if(t.provider!==void 0&&!hS.includes(t.provider))throw new Error(`Invalid model provider: ${String(t.provider)}`)}async function sg(t,e){const n=await tv.set(t,e);if(n.status==="ok")return;const r=n.status==="unavailable"?"KEYCHAIN_UNAVAILABLE":"STORE_FAILED";throw new Error(`Failed to store model key (${r})`)}function vS(t){return{get models(){return t.settings.models},get defaultModelId(){return t.settings.defaultModelId},get hasLegacyKeys(){return t.settings.models.some(e=>typeof e._legacyApiKey=="string")},async addModel(e,n){Ow(e);const r=M8();let i;n&&n.length>0&&(i=og(),await sg(i,n));const o={...e,id:r,...i?{apiKeyRef:i}:{}};return t.updateSettings({models:[...t.settings.models,o]}),r},async updateModel(e,n,r){Ow(n);const i=t.settings.models.find(s=>s.id===e);if(!i)return;let o;r!==void 0&&r.length>0&&(o=og(),await Promise.all([sg(o,r),i.apiKeyRef?tv.delete(i.apiKeyRef):Promise.resolve()])),t.updateSettings({models:t.settings.models.map(s=>s.id===e?{...s,...n,...o?{apiKeyRef:o}:{}}:s)})},async deleteModel(e){const n=t.settings.models.find(r=>r.id===e);n!=null&&n.apiKeyRef&&await tv.delete(n.apiKeyRef),t.updateSettings({models:t.settings.models.filter(r=>r.id!==e),defaultModelId:t.settings.defaultModelId===e?null:t.settings.defaultModelId})},toggleEnabled(e){t.updateSettings({models:t.settings.models.map(n=>n.id===e?{...n,enabled:!n.enabled}:n)})},setDefault(e){t.updateSettings({defaultModelId:e})},async migrateLegacyKeys(){const e=t.settings.models,n=e.map((l,c)=>typeof l._legacyApiKey=="string"?c:-1).filter(l=>l>=0);if(n.length===0)return{migrated:0,failed:0};const r=n.map(()=>og()),i=await Promise.allSettled(n.map((l,c)=>sg(r[c],e[l]._legacyApiKey))),o=e.slice();let s=0,a=0;return i.forEach((l,c)=>{const u=n[c];if(l.status==="fulfilled"){const f={...e[u],apiKeyRef:r[c]};delete f._legacyApiKey,o[u]=f,s++}else a++}),s>0&&t.updateSettings({models:o}),{migrated:s,failed:a}}}}var D8=T('<label class="frm-provider-row svelte-1hpwfc5"><input type="radio" name="first-run-provider"/> <span> </span></label>'),O8=T('<label class="frm-field svelte-1hpwfc5"><span class="frm-label svelte-1hpwfc5">API key</span> <input type="password" data-testid="first-run-apikey" autocomplete="off" class="frm-mono svelte-1hpwfc5" placeholder="Paste your provider API key"/></label>'),I8=T('<label class="frm-field svelte-1hpwfc5"><span class="frm-label svelte-1hpwfc5">Endpoint URL</span> <input type="text" data-testid="first-run-endpoint" autocomplete="off" class="frm-mono svelte-1hpwfc5"/></label>'),R8=T('<div role="alert" class="frm-error svelte-1hpwfc5" data-testid="first-run-error"> </div>'),N8=T('<div role="presentation" class="frm-scrim svelte-1hpwfc5" data-testid="first-run-model-modal"><div role="dialog" aria-modal="true" aria-label="Connect an AI model" class="frm-dialog svelte-1hpwfc5"><header class="frm-header svelte-1hpwfc5"><div><h2 class="frm-title svelte-1hpwfc5">Connect an AI model</h2> <div class="frm-step svelte-1hpwfc5">Step 1 of 2 — Tandem stores your key in the OS keychain.</div></div> <button type="button" class="frm-close svelte-1hpwfc5" data-testid="first-run-skip" aria-label="Skip for now">×</button></header> <form class="frm-form svelte-1hpwfc5"><fieldset class="frm-providers svelte-1hpwfc5" data-testid="first-run-providers"><legend class="frm-label svelte-1hpwfc5">Provider</legend> <!></fieldset> <label class="frm-field svelte-1hpwfc5"><span class="frm-label svelte-1hpwfc5">Display name (optional)</span> <input type="text" data-testid="first-run-displayname" autocomplete="off" class="svelte-1hpwfc5"/></label> <label class="frm-field svelte-1hpwfc5"><span class="frm-label svelte-1hpwfc5">Model ID</span> <input type="text" data-testid="first-run-modelid" autocomplete="off" class="frm-mono svelte-1hpwfc5"/></label> <!> <!> <div class="frm-actions svelte-1hpwfc5"><button type="button" data-testid="first-run-skip-secondary" class="frm-btn frm-btn-secondary svelte-1hpwfc5">Skip for now</button> <button type="submit" data-testid="first-run-save" class="frm-btn frm-btn-primary svelte-1hpwfc5"> </button></div></form></div></div>');function P8(t,e){We(e,!0);const n=Or(),r=vS(n),i=[{value:"anthropic",label:"Anthropic (Claude)",defaultModelId:"claude-sonnet-4-6",isCloud:!0},{value:"openai",label:"OpenAI",defaultModelId:"gpt-4o",isCloud:!0},{value:"gemini",label:"Gemini (Google)",defaultModelId:"gemini-2.0-flash",isCloud:!0},{value:"local-ollama",label:"Ollama (local)",defaultModelId:"llama3.1:70b",isCloud:!1},{value:"local-llamacpp",label:"llama.cpp (local)",defaultModelId:"local-model",isCloud:!1}];let o=F("anthropic"),s=F(""),a=F(Qe(i[0].defaultModelId)),l=F(""),c=F("http://localhost:11434"),u=F(!1),f=F(null),h=F(null),p=null;const m=L(()=>i.find(O=>O.value===d(o))??i[0]),v=L(()=>d(m).isCloud),g=L(()=>d(a).trim().length>0&&(d(v)?d(l).trim().length>0:d(c).trim().length>0));he(()=>{const O=At(()=>d(h));if(O)return p=document.activeElement,O.focus(),()=>{p instanceof HTMLElement&&document.contains(p)&&p.focus()}});function b(O){const G=i.find(Q=>Q.value===d(o)),z=i.find(Q=>Q.value===O);z&&G&&d(a)===G.defaultModelId&&y(a,z.defaultModelId,!0),y(o,O,!0)}async function _(O){if(O.preventDefault(),!(!d(g)||d(u))){y(u,!0),y(f,null);try{const G=await r.addModel({provider:d(o),displayName:d(s).trim()||d(m).label,modelId:d(a).trim(),enabled:!0,...d(v)?{}:{endpoint:d(c).trim()}},d(v)?d(l).trim():void 0);r.setDefault(G),e.onComplete()}catch(G){y(f,G instanceof Error?G.message:"Failed to save",!0)}finally{y(u,!1)}}}function k(){e.onComplete()}var C=N8(),E=w(C);V(E,"tabindex",-1);var I=w(E),A=x(w(I),2),M=x(I,2),N=w(M),R=x(w(N),2);nt(R,17,()=>i,O=>O.value,(O,G)=>{var z=D8(),Q=w(z),ge=x(Q,2),ye=w(ge);j(()=>{Sr(Q,d(G).value),Bn(Q,d(o)===d(G).value),V(Q,"data-testid",`first-run-provider-${d(G).value}`),J(ye,d(G).label)}),P("change",Q,()=>b(d(G).value)),S(O,z)});var B=x(N,2),Z=x(w(B),2),q=x(B,2),Y=x(w(q),2),X=x(q,2);{var ae=O=>{var G=O8(),z=x(w(G),2);Xn(z,()=>d(l),Q=>y(l,Q)),S(O,G)},ne=O=>{var G=I8(),z=x(w(G),2);Xn(z,()=>d(c),Q=>y(c,Q)),S(O,G)};W(X,O=>{d(v)?O(ae):O(ne,-1)})}var te=x(X,2);{var le=O=>{var G=R8(),z=w(G);j(()=>J(z,d(f))),S(O,G)};W(te,O=>{d(f)&&O(le)})}var se=x(te,2),me=w(se),K=x(me,2),H=w(K);St(E,O=>y(h,O),()=>d(h)),j(()=>{V(Z,"placeholder",d(m).label),K.disabled=!d(g)||d(u),J(H,d(u)?"Saving…":"Save and continue")}),P("click",C,O=>{O.target===O.currentTarget&&k()}),P("keydown",E,O=>{O.key==="Escape"&&k(),O.key!=="Tab"&&O.stopPropagation()}),P("click",A,k),hn("submit",M,_),Xn(Z,()=>d(s),O=>y(s,O)),Xn(Y,()=>d(a),O=>y(a,O)),P("click",me,k),S(t,C),Ke()}et(["click","keydown","change"]);var L8=T('<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),F8=T('<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>'),z8=T('<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),B8=T(`<div role="presentation" style="position: fixed; inset: 0; background: color-mix(in srgb, var(--tandem-bg) 70%, transparent); display: flex; align-items: center; justify-content: center; z-index: var(--tandem-z-above-titlebar);" data-testid="help-modal"><div role="dialog" aria-modal="true" aria-label="Keyboard Shortcuts" tabindex="-1" class="tandem-scroll-fade-y" style="background-color: var(--tandem-surface); border: 1px solid var(--tandem-border); border-radius: var(--tandem-r-5); 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" class="modal-close svelte-6zgoeu" aria-label="Close help" data-testid="help-modal-close">✕</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>,
52
+ 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 H8(t,e){We(e,!0);const n=L(()=>{const l=ph(),c=e.effectiveShortcutLabels,u=new Map;for(const f of l.values()){if(!f.shortcut)continue;const h=mC[f.id],p=h&&(c==null?void 0:c.get(h))||f.shortcut,m=u.get(f.group)??[];m.push({keys:p,description:f.label}),u.set(f.group,m)}return cC.map(f=>({title:f.charAt(0).toUpperCase()+f.slice(1),rows:u.get(f)??[]})).filter(f=>f.rows.length>0)});let r=F(null),i=null;he(()=>{if(!e.open)return;const l=At(()=>d(r));if(!l)return;i=document.activeElement,l.focus();const c=u=>{l&&!l.contains(u.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"&&(c.preventDefault(),c.stopPropagation(),e.onClose())};return window.addEventListener("keydown",l,{capture:!0}),()=>window.removeEventListener("keydown",l,{capture:!0})});var o=Mt(),s=Ie(o);{var a=l=>{var c=B8(),u=w(c),f=w(u),h=x(w(f),2),p=x(f,2);nt(p,17,()=>d(n),g=>g.title,(g,b)=>{var _=F8(),k=w(_),C=w(k),E=x(k,2);nt(E,21,()=>d(b).rows,I=>I.description,(I,A)=>{var M=L8(),N=Ie(M),R=w(N),B=w(R),Z=x(N,2),q=w(Z);j(()=>{J(B,d(A).keys),J(q,d(A).description)}),S(I,M)}),j(()=>J(C,d(b).title)),S(g,_)});var m=x(p,2),v=x(w(m),2);nt(v,21,()=>kh,g=>g.description,(g,b)=>{var _=z8(),k=Ie(_),C=w(k),E=w(C),I=x(k,2),A=w(I);j(()=>{J(E,d(b).keys),J(A,d(b).description)}),S(g,_)}),St(u,g=>y(r,g),()=>d(r)),Tr(u,(g,b)=>jt==null?void 0:jt(g,b),()=>"y"),P("click",c,function(...g){var b;(b=e.onClose)==null||b.apply(this,g)}),P("click",u,g=>g.stopPropagation()),P("keydown",u,g=>{if(g.key==="Escape"){e.onClose();return}if(g.stopPropagation(),g.key==="Tab"&&d(r)){const b=Array.from(d(r).querySelectorAll('button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')).filter(C=>!C.closest("[hidden]"));if(b.length===0){g.preventDefault();return}const _=b[0],k=b[b.length-1];g.shiftKey&&document.activeElement===_?(g.preventDefault(),k.focus()):!g.shiftKey&&document.activeElement===k&&(g.preventDefault(),_.focus())}}),P("click",h,function(...g){var b;(b=e.onClose)==null||b.apply(this,g)}),S(l,c)};W(s,l=>{e.open&&l(a)})}S(t,o),Ke()}et(["click","keydown"]);function V8(t){const e=crypto.randomUUID().replace(/-/g,"").slice(0,12);return`${t}-${e}`}function U8(t={}){const e=t.fetchFn??globalThis.fetch.bind(globalThis),n=t.baseUrl??"",r=t.keychainBackend??dS({fetchFn:e,baseUrl:n});let i=F("detect"),o=F(Qe([])),s=F(Qe([])),a=F(null),l=F(Qe([])),c=F(!1),u=0;const f=E=>{y(a,E,!0),y(i,"error")},h=async()=>{const E=++u;y(i,"detect"),y(a,null);try{const I=await e(`${n}${o8}`);if(E!==u)return;if(!I.ok){f(`Could not load existing entries (HTTP ${I.status}).`);return}const A=await I.json();if(E!==u)return;y(o,A.installs,!0)}catch(I){if(E!==u)return;f(I instanceof Error?I.message:String(I))}},p=()=>{y(i,"pick")},m=E=>{y(s,E,!0)},v=()=>{y(i,"secrets")},g=async(E,I)=>{const A=V8(E.id),M=await r.set(A,I);if(M.status==="unavailable"){y(c,!0),y(s,d(s).map(N=>N.id===E.id?{...N,keychainUnavailable:!0,pendingSecret:void 0}:N),!0);return}if(M.status==="error"){f(`Could not store secret: ${M.message}`);return}y(s,d(s).map(N=>N.id===E.id?{...N,config:{...N.config,tokenSecretRef:A},hasStoredSecret:!0,pendingSecret:void 0,keychainUnavailable:!1}:N),!0)},b=()=>{y(i,"review")},_=async()=>{const E=d(s).map(I=>I.config.tokenSecretRef).filter(I=>typeof I=="string"&&I.length>0);await Promise.all(E.map(I=>r.delete(I)))};return{get step(){return d(i)},get existing(){return d(o)},get picked(){return d(s)},get errorMessage(){return d(a)},get applyResults(){return d(l)},get keychainUnavailable(){return d(c)},begin:h,advanceToPick:p,setPicked:m,advanceToSecrets:v,submitSecret:g,advanceToReview:b,save:async()=>{y(i,"saving");const E=d(s).map(A=>{if(A.config.kind==="other-mcp")return{...A.config,apply:"skip"};const M=A.config.configPath,N=d(o).find(B=>B.target.configPath===M),R=(N==null?void 0:N.tandemValidation)!==void 0&&N.tandemValidation.status!=="valid";return{...A.config,apply:R?"skip":"create"}}),I={schemaVersion:d8,integrations:E};try{const A=await e(`${n}${s8}`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(I)});if(!A.ok){const B=await A.json().catch(()=>null);await _(),f((B==null?void 0:B.message)??`Could not save (HTTP ${A.status}).`);return}const M=await A.json(),N=await e(`${n}${a8}`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({ids:M.ids,confirmationNonce:M.confirmationNonce})});if(!N.ok){const B=await N.json().catch(()=>null);f((B==null?void 0:B.message)??`Could not apply (HTTP ${N.status}).`);return}const R=await N.json();y(l,R.results,!0),y(i,"done")}catch(A){await _(),f(A instanceof Error?A.message:String(A))}},reset:()=>{y(i,"detect"),y(o,[],!0),y(s,[],!0),y(a,null),y(l,[],!0),y(c,!1)}}}var j8=T('<span class="iw-hint svelte-bt94ms">Tandem is already configured here.</span>'),q8=T('<li class="svelte-bt94ms"><strong> </strong> <span> </span> <!></li>'),W8=T('<ul class="iw-existing svelte-bt94ms"></ul>'),K8=T('<section data-testid="integration-wizard-step-detect"><p>Looking for existing AI integrations on your system…</p> <!> <div class="iw-actions svelte-bt94ms"><button type="button" data-testid="integration-wizard-continue-detect" class="svelte-bt94ms">Continue</button></div></section>'),G8=T('<li class="svelte-bt94ms"><label><input type="checkbox"/> <strong> </strong> <small> </small></label></li>'),Z8=T('<section data-testid="integration-wizard-step-pick"><p>Select which AI integrations to register with Tandem.</p> <ul class="iw-pick-list svelte-bt94ms"></ul> <div class="iw-actions svelte-bt94ms"><button type="button" data-testid="integration-wizard-continue-pick" class="svelte-bt94ms">Continue</button></div></section>'),Y8=T(`<p class="iw-warning svelte-bt94ms" data-testid="integration-wizard-keychain-fallback">Your operating system keychain isn't reachable from this Tandem build. Tokens
53
+ entered here can't be saved. Use the environment variable <code>TANDEM_INTEGRATION_&lt;id&gt;_TOKEN</code> instead, or skip this step and
54
+ add the token via your AI client's own configuration.</p>`),J8=T('<em class="iw-stored svelte-bt94ms">Token saved.</em>'),X8=T('<em class="iw-skipped svelte-bt94ms">Skipped (keychain unavailable).</em>'),Q8=T('<div class="iw-secret-input svelte-bt94ms"><input type="password" placeholder="Paste auth token (optional)" class="svelte-bt94ms"/> <button type="button">Save token</button></div>'),$8=T('<li class="svelte-bt94ms"><div class="iw-secret-row svelte-bt94ms"><strong> </strong> <small> </small></div> <!></li>'),eI=T(`<section data-testid="integration-wizard-step-secrets"><p>Optional — store an auth token for each integration. Tandem keeps these in your
55
+ operating system's keychain, never in plain text.</p> <!> <ul class="iw-secrets-list svelte-bt94ms"></ul> <div class="iw-actions svelte-bt94ms"><button type="button" data-testid="integration-wizard-continue-secrets" class="svelte-bt94ms">Continue</button></div></section>`),tI=T('<span class="iw-token-badge svelte-bt94ms">Token stored</span>'),nI=T('<li class="svelte-bt94ms"><strong> </strong> <small> </small> <!></li>'),rI=T('<section data-testid="integration-wizard-step-review"><p>Ready to save. Tandem will register these integrations:</p> <ul class="iw-review-list svelte-bt94ms"></ul> <div class="iw-actions svelte-bt94ms"><button type="button" data-testid="integration-wizard-save" class="svelte-bt94ms">Save and finish</button></div></section>'),iI=T('<section data-testid="integration-wizard-step-saving"><p>Saving integration configuration…</p></section>'),oI=T('<span class="iw-apply-result-message svelte-bt94ms"> </span>'),sI=T('<li><span class="iw-apply-result-id svelte-bt94ms"> </span> <span class="iw-apply-result-status svelte-bt94ms"> </span> <!></li>'),aI=T('<ul class="iw-apply-results svelte-bt94ms"></ul>'),lI=T('<section data-testid="integration-wizard-step-done"><p>Done — Tandem is connected to your AI client(s).</p> <!> <div class="iw-actions svelte-bt94ms"><button type="button" data-testid="integration-wizard-done-close" class="svelte-bt94ms">Close</button></div></section>'),cI=T('<section data-testid="integration-wizard-step-error"><p class="iw-error svelte-bt94ms"> </p> <div class="iw-actions svelte-bt94ms"><button type="button" class="svelte-bt94ms">Start over</button> <button type="button" class="svelte-bt94ms">Close</button></div></section>'),uI=T('<div role="presentation" class="iw-scrim svelte-bt94ms" data-testid="integration-wizard"><div role="dialog" aria-modal="true" aria-label="Integration Setup Wizard" tabindex="-1" class="iw-dialog svelte-bt94ms"><header class="iw-header svelte-bt94ms"><h2 class="iw-title svelte-bt94ms">Connect an AI assistant</h2> <button type="button" class="iw-close svelte-bt94ms" aria-label="Close wizard" data-testid="integration-wizard-close">×</button></header> <!></div></div>');function dI(t,e){We(e,!0);const n=U8({baseUrl:`http://127.0.0.1:${uc}`});let r=F(null),i=null,o=F(Qe({}));he(()=>{if(!e.open)return;const b=At(()=>d(r));if(b)return i=document.activeElement,b.focus(),()=>{i instanceof HTMLElement&&document.contains(i)&&i.focus()}}),he(()=>{e.open&&n.begin()}),he(()=>{if(!e.open)return;const b=_=>{_.key==="Escape"&&e.onClose()};return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)});function s(){n.reset(),y(o,{},!0),e.onClose()}function a(b){return`${b}-${crypto.randomUUID().slice(0,8)}`}function l(b){var _;if(b.target.kind==="claude-code"){const k=((_=b.tandemEntry)==null?void 0:_.url)??"http://127.0.0.1:3479",C=a("claude-code");return{id:C,config:{kind:"claude-code",id:C,label:b.target.label,configPath:b.target.configPath,transport:"http",url:k},hasStoredSecret:!1,keychainUnavailable:!1}}if(b.target.kind==="claude-desktop"){const k=a("claude-desktop");return{id:k,config:{kind:"claude-desktop",id:k,label:b.target.label,configPath:b.target.configPath,transport:"stdio"},hasStoredSecret:!1,keychainUnavailable:!1}}return null}function c(){const b=n.existing.filter(_=>_.status==="ok"||_.status==="missing").map(l).filter(_=>_!==null);n.setPicked(b),n.advanceToPick()}function u(b){const _=n.picked.findIndex(C=>C.config.kind===b.target.kind&&C.config.label===b.target.label);if(_>=0){n.setPicked(n.picked.filter((C,E)=>E!==_));return}const k=l(b);k&&n.setPicked([...n.picked,k])}function f(b){return n.picked.some(_=>_.config.kind===b.target.kind&&_.config.label===b.target.label)}async function h(b){const _=d(o)[b.id]??"";_.length!==0&&(await n.submitSecret(b,_),y(o,{...d(o),[b.id]:""},!0))}function p(b){return b.kind==="claude-code"?"Claude Code · HTTP":b.kind==="claude-desktop"?"Claude Desktop · stdio":`Other MCP · ${b.transport}`}var m=Mt(),v=Ie(m);{var g=b=>{var _=uI(),k=w(_),C=w(k),E=x(w(C),2),I=x(C,2);{var A=Y=>{var X=K8(),ae=x(w(X),2);{var ne=se=>{var me=W8();nt(me,21,()=>n.existing,K=>K.target.configPath,(K,H)=>{var O=q8(),G=w(O),z=w(G),Q=x(G,2),ge=w(Q),ye=x(Q,2);{var Se=ee=>{var de=j8();S(ee,de)};W(ye,ee=>{d(H).tandemEntry&&ee(Se)})}j(()=>{J(z,d(H).target.label),yt(Q,1,`iw-status iw-status-${d(H).status??""}`,"svelte-bt94ms"),J(ge,d(H).status)}),S(K,O)}),S(se,me)};W(ae,se=>{n.existing.length>0&&se(ne)})}var te=x(ae,2),le=w(te);P("click",le,c),S(Y,X)},M=Y=>{var X=Z8(),ae=x(w(X),2);nt(ae,21,()=>n.existing,le=>le.target.configPath,(le,se)=>{var me=G8(),K=w(me),H=w(K),O=x(H,2),G=w(O),z=x(O,2),Q=w(z);j(ge=>{Bn(H,ge),V(H,"data-testid",`integration-wizard-pick-${d(se).target.kind??""}`),J(G,d(se).target.label),J(Q,d(se).target.configPath)},[()=>f(d(se))]),P("change",H,()=>u(d(se))),S(le,me)});var ne=x(ae,2),te=w(ne);P("click",te,()=>n.advanceToSecrets()),S(Y,X)},N=Y=>{var X=eI(),ae=x(w(X),2);{var ne=me=>{var K=Y8();S(me,K)};W(ae,me=>{n.keychainUnavailable&&me(ne)})}var te=x(ae,2);nt(te,21,()=>n.picked,me=>me.id,(me,K)=>{var H=$8(),O=w(H),G=w(O),z=w(G),Q=x(G,2),ge=w(Q),ye=x(O,2);{var Se=xe=>{var Ee=J8();S(xe,Ee)},ee=xe=>{var Ee=X8();S(xe,Ee)},de=xe=>{var Ee=Q8(),D=w(Ee),$=x(D,2);j(()=>{V(D,"data-testid",`integration-wizard-secret-input-${d(K).id??""}`),$.disabled=!d(o)[d(K).id],V($,"data-testid",`integration-wizard-secret-submit-${d(K).id??""}`)}),Xn(D,()=>d(o)[d(K).id],ke=>d(o)[d(K).id]=ke),P("click",$,()=>h(d(K))),S(xe,Ee)};W(ye,xe=>{d(K).hasStoredSecret?xe(Se):d(K).keychainUnavailable?xe(ee,1):xe(de,-1)})}j(xe=>{J(z,d(K).config.label),J(ge,xe)},[()=>p(d(K).config)]),S(me,H)});var le=x(te,2),se=w(le);P("click",se,()=>n.advanceToReview()),S(Y,X)},R=Y=>{var X=rI(),ae=x(w(X),2);nt(ae,21,()=>n.picked,le=>le.id,(le,se)=>{var me=nI(),K=w(me),H=w(K),O=x(K,2),G=w(O),z=x(O,2);{var Q=ge=>{var ye=tI();S(ge,ye)};W(z,ge=>{d(se).config.tokenSecretRef&&ge(Q)})}j(ge=>{J(H,d(se).config.label),J(G,ge)},[()=>p(d(se).config)]),S(le,me)});var ne=x(ae,2),te=w(ne);P("click",te,()=>n.save()),S(Y,X)},B=Y=>{var X=iI();S(Y,X)},Z=Y=>{var X=lI(),ae=x(w(X),2);{var ne=se=>{var me=aI();nt(me,21,()=>n.applyResults,K=>K.id,(K,H)=>{var O=sI(),G=w(O),z=w(G),Q=x(G,2),ge=w(Q),ye=x(Q,2);{var Se=ee=>{var de=oI(),xe=w(de);j(()=>J(xe,d(H).message)),S(ee,de)};W(ye,ee=>{d(H).status==="error"&&d(H).message&&ee(Se)})}j(()=>{yt(O,1,`iw-apply-result iw-apply-result-${d(H).status??""}`,"svelte-bt94ms"),V(O,"data-testid",`integration-wizard-apply-result-${d(H).id??""}`),J(z,d(H).id),J(ge,d(H).status)}),S(K,O)}),S(se,me)};W(ae,se=>{n.applyResults.length>0&&se(ne)})}var te=x(ae,2),le=w(te);P("click",le,s),S(Y,X)},q=Y=>{var X=cI(),ae=w(X),ne=w(ae),te=x(ae,2),le=w(te),se=x(le,2);j(()=>J(ne,`Something went wrong: ${n.errorMessage??""}`)),P("click",le,()=>n.reset()),P("click",se,s),S(Y,X)};W(I,Y=>{n.step==="detect"?Y(A):n.step==="pick"?Y(M,1):n.step==="secrets"?Y(N,2):n.step==="review"?Y(R,3):n.step==="saving"?Y(B,4):n.step==="done"?Y(Z,5):n.step==="error"&&Y(q,6)})}St(k,Y=>y(r,Y),()=>d(r)),P("click",_,s),P("click",k,Y=>Y.stopPropagation()),P("keydown",k,Y=>{if(Y.key==="Escape"){s();return}Y.key!=="Tab"&&Y.stopPropagation()}),P("click",E,s),S(b,_)};W(v,b=>{e.open&&b(g)})}S(t,m),Ke()}et(["click","keydown","change"]);const fI=t=>t;function hI(t,{delay:e=0,duration:n=400,easing:r=fI}={}){const i=+getComputedStyle(t).opacity;return{delay:e,duration:n,easing:r,css:o=>`opacity: ${o*i}`}}function bS(t,e,n,r){const i=3*t,o=3*(n-t)-i,s=1-i-o,a=3*e,l=3*(r-e)-a,c=1-a-l,u=m=>((s*m+o)*m+i)*m,f=m=>((c*m+l)*m+a)*m,h=m=>(3*s*m+2*o)*m+i,p=m=>{let v=m;for(let _=0;_<8;_++){const k=u(v)-m;if(Math.abs(k)<1e-5)return v;const C=h(v);if(Math.abs(C)<1e-6)break;v-=k/C}let g=0,b=1;v=m;for(let _=0;_<20;_++){const k=u(v)-m;if(Math.abs(k)<1e-5)break;k>0?b=v:g=v,v=(g+b)/2}return v};return m=>m<=0?0:m>=1?1:f(p(m))}const kd=bS(.2,.8,.2,1),pI=bS(.4,0,.2,1),mI=260,gI=260,vI=280;function Bs(t){return t?!0:typeof matchMedia<"u"&&matchMedia("(prefers-reduced-motion: reduce)").matches}function Zp(t){return{h:t.offsetHeight,mb:Number.parseFloat(getComputedStyle(t).marginBottom)||0}}function bI(t,{enabled:e,reduceMotion:n}){if(!e||Bs(n))return{duration:0};const{h:r,mb:i}=Zp(t);return{duration:mI,easing:kd,css:(o,s)=>`opacity:${o}; transform:translateY(${-6*s}px); height:${o*r}px; margin-bottom:${o*i}px; overflow:clip; box-sizing:border-box;`}}function yI(t,{enabled:e,reduceMotion:n,id:r,modes:i}){const o=i==null?void 0:i.get(r);if(i==null||i.delete(r),!e||Bs(n))return{duration:0};const{h:s,mb:a}=Zp(t),l=c=>o==="accept"?`translateY(${-8*c}px)`:o==="dismiss"?`translateX(${40*c}px) scale(${1-.04*c})`:"none";return{duration:gI,easing:kd,css:(c,u)=>`opacity:${c}; height:${c*s}px; margin-bottom:${c*a}px; transform:${l(u)}; overflow:clip; box-sizing:border-box;`}}function yS(t,{reduceMotion:e}){if(Bs(e))return{duration:0};const{h:n,mb:r}=Zp(t);return{duration:vI,easing:kd,css:(i,o)=>`opacity:${i}; transform:translateY(${-8*o}px); height:${i*n}px; margin-bottom:${i*r}px; overflow:clip; box-sizing:border-box;`}}function wS(t,{reduceMotion:e,exitMs:n=200}){if(Bs(e))return{duration:0};const{h:r,mb:i}=Zp(t);return{duration:n,easing:pI,css:(o,s)=>`opacity:${o}; transform:translateY(${-8*s}px); height:${o*r}px; margin-bottom:${o*i}px; overflow:clip; box-sizing:border-box;`}}const wI=200;function xI(t,{reduceMotion:e}){if(Bs(e))return{duration:0};const n=t.offsetWidth;return{duration:wI,easing:kd,css:r=>`opacity:${r}; width:${r*n}px; min-width:0; overflow:clip; box-sizing:border-box; pointer-events:none;`}}const xS=440;function kI(t,{reduceMotion:e}){if(Bs(e))return{duration:0};const n=t.offsetWidth,r=t.offsetHeight;return{duration:xS,easing:kd,css:i=>`opacity:${i}; width:${i*n}px; height:${i*r}px; overflow:clip; box-sizing:border-box;`}}var _I=T("Detected VM subnet: <code> </code>.",1),CI=T('<div class="cos-error svelte-1h0desi" data-testid="cowork-onboarding-error" role="alert"> </div>'),SI=T('<div class="cos-confirm-banner svelte-1h0desi" data-testid="cowork-onboarding-confirm"><div class="cos-confirm-heading svelte-1h0desi">Confirm: Enable Cowork</div> <div class="cos-confirm-body svelte-1h0desi">Windows will prompt for admin permission to modify firewall rules. This is expected.</div> <div class="cos-actions svelte-1h0desi"><button data-testid="cowork-onboarding-enable-confirm-btn" class="cos-btn cos-btn--primary svelte-1h0desi" type="button">Enable</button> <button data-testid="cowork-onboarding-enable-cancel-btn" class="cos-btn cos-btn--ghost svelte-1h0desi" type="button">Cancel</button></div></div>'),EI=T('<button data-testid="cowork-onboarding-learn-more-btn" class="cos-btn cos-btn--ghost svelte-1h0desi" type="button">Learn more</button>'),AI=T('<a class="cos-learn-more-link svelte-1h0desi" data-testid="cowork-onboarding-learn-more-link" target="_blank" rel="noreferrer">Learn more</a>'),TI=T('<div class="cos-actions svelte-1h0desi"><button data-testid="cowork-onboarding-enable-btn" class="cos-btn cos-btn--primary svelte-1h0desi" type="button">Enable</button> <button data-testid="cowork-onboarding-skip-btn" class="cos-btn cos-btn--ghost svelte-1h0desi" type="button">Skip</button> <!></div>'),MI=T('<div class="cos-root svelte-1h0desi" data-testid="cowork-onboarding-step"><div class="cos-title svelte-1h0desi">Claude Desktop Cowork detected</div> <div class="cos-description svelte-1h0desi">Enable Tandem inside Cowork workspaces? <!></div> <!> <!></div>');function DI(t,e){We(e,!0);let n=F(!1),r=F(!1),i=F(null);async function o(b,_){y(r,!0),y(i,null);try{const k=await Ta();return await b(k),!0}catch(k){const C=k instanceof Error?k.message:String(k),E=nS(C);return y(i,`${_}: ${E}`),!1}finally{y(r,!1)}}async function s(){await o(async _=>{await sS(_,!0)},"Failed to enable Cowork")&&e.onAdvance()}function a(){_5(),e.onAdvance()}var l=MI(),c=x(w(l),2),u=x(w(c));{var f=b=>{var _=_I(),k=x(Ie(_)),C=w(k);j(()=>J(C,e.status.vethernetCidr)),S(b,_)};W(u,b=>{e.status.vethernetCidr!==null&&b(f)})}var h=x(c,2);{var p=b=>{var _=CI(),k=w(_);j(()=>J(k,d(i))),S(b,_)};W(h,b=>{d(i)&&b(p)})}var m=x(h,2);{var v=b=>{var _=SI(),k=x(w(_),4),C=w(k),E=x(C,2);j(()=>{C.disabled=d(r),E.disabled=d(r)}),P("click",C,()=>void s()),P("click",E,()=>{y(n,!1)}),S(b,_)},g=b=>{var _=TI(),k=w(_),C=x(k,2),E=x(C,2);{var I=M=>{var N=EI();j(()=>N.disabled=d(r)),P("click",N,function(...R){var B;(B=e.onLearnMore)==null||B.apply(this,R)}),S(M,N)},A=M=>{var N=AI();j(()=>V(N,"href",`${K_}#cowork`)),S(M,N)};W(E,M=>{e.onLearnMore?M(I):M(A,-1)})}j(()=>{k.disabled=d(r),C.disabled=d(r)}),P("click",k,()=>{y(n,!0)}),P("click",C,a),S(b,_)};W(m,b=>{d(n)?b(v):b(g,-1)})}S(t,l),Ke()}et(["click"]);var OI=T("<div></div>"),II=T('<div style="display: flex; gap: var(--tandem-space-1); margin-bottom: var(--tandem-space-3);" class="svelte-1us4jmd"></div>'),RI=T('<div style="font-size: var(--tandem-text-sm); font-weight: 600; color: var(--tandem-fg); margin-bottom: var(--tandem-space-1);" class="svelte-1us4jmd"> </div> <div class="svelte-1us4jmd"> </div>',1),NI=T('<div class="svelte-1us4jmd"><!></div>'),PI=T('<div style="display: flex; justify-content: space-between; align-items: center;" class="svelte-1us4jmd"><span style="font-size: var(--tandem-text-xs); color: var(--tandem-fg-subtle);" class="svelte-1us4jmd"> </span> <div style="display: flex; gap: 12px; align-items: center;" class="svelte-1us4jmd"><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;" class="svelte-1us4jmd">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-pill); background: var(--tandem-surface); color: var(--tandem-fg-muted); cursor: pointer; font-weight: 500;" class="svelte-1us4jmd"> </button></div></div>'),LI=T('<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;" class="svelte-1us4jmd"><!> <!> <!></div>');function FI(t,e){We(e,!0);const n=Or(),r=L(()=>Bs(n.settings.reduceMotion)?0:220),i=[{id:"review",title:"Review an annotation",text:"Open the side panel and accept or dismiss one of the highlighted annotations — or turn on the margin view to see them beside the text. 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 your AI assistant — 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. Open a tab or scratchpad with Ctrl+N, and jump anywhere with the command palette (Ctrl+Shift+P)."},{id:"cowork",title:"Claude Desktop Cowork detected",text:""},{id:"complete",title:"You're ready!",text:"You've learned the basics. Press ? anytime for keyboard shortcuts, or Ctrl+Shift+, to customize them."}],o=Pt(),s=iS(),a=L(()=>o&&rS(e.coworkStatus,s)),l=L(()=>i.filter(g=>g.id!=="cowork"||d(a))),c=L(()=>d(l).length-1),u=L(()=>d(l)[e.currentStep]),f=L(()=>e.currentStep>=d(c)),h=L(()=>{var g;return((g=d(u))==null?void 0:g.id)==="cowork"});var p=Mt(),m=Ie(p);{var v=g=>{var b=LI(),_=w(b);{var k=A=>{var M=II();nt(M,20,()=>Array.from({length:d(c)},(N,R)=>R),N=>N,(N,R)=>{var B=OI();let Z;j(()=>{Z=yt(B,1,"tut-dot svelte-1us4jmd",null,Z,{"is-current":R===e.currentStep}),Me(B,`width: var(--tandem-space-2); height: var(--tandem-space-2); border-radius: var(--tandem-r-circle); background: ${R<=e.currentStep?"var(--tandem-accent)":"var(--tandem-border)"}; transition: background 0.2s;`)}),S(N,B)}),S(A,M)};W(_,A=>{d(f)||A(k)})}var C=x(_,2);yu(C,()=>d(u).id,A=>{var M=NI(),N=w(M);{var R=Z=>{DI(Z,{get status(){return e.coworkStatus},get onAdvance(){return e.onNext}})},B=Z=>{var q=RI(),Y=Ie(q),X=w(Y),ae=x(Y,2),ne=w(ae);j(()=>{J(X,d(u).title),Me(ae,`font-size: var(--tandem-text-base); line-height: 1.5; color: var(--tandem-fg-muted); margin-bottom: ${d(f)?0:14}px;`),J(ne,d(u).text)}),S(Z,q)};W(N,Z=>{d(h)&&e.coworkStatus!==null?Z(R):Z(B,-1)})}Uo(1,M,()=>hI,()=>({duration:d(r)})),S(A,M)});var E=x(C,2);{var I=A=>{var M=PI(),N=w(M),R=w(N),B=x(N,2),Z=w(B),q=x(Z,2),Y=w(q);j(()=>{J(R,`Step ${e.currentStep+1} of ${d(c)??""}`),J(Y,e.currentStep===d(c)-1?"Done":"Next")}),P("click",Z,function(...X){var ae;(ae=e.onDismiss)==null||ae.apply(this,X)}),P("click",q,function(...X){var ae;(ae=e.onNext)==null||ae.apply(this,X)}),S(A,M)};W(E,A=>{!d(f)&&!d(h)&&A(I)})}S(g,b)};W(m,g=>{d(u)&&g(v)})}S(t,p),Ke()}et(["click"]);const fi=()=>new Map,nv=t=>{const e=fi();return t.forEach((n,r)=>{e.set(r,n)}),e},co=(t,e,n)=>{let r=t.get(e);return r===void 0&&t.set(e,r=n()),r},zI=(t,e)=>{const n=[];for(const[r,i]of t)n.push(e(i,r));return n},BI=(t,e)=>{for(const[n,r]of t)if(e(r,n))return!0;return!1},Ma=()=>new Set,ag=t=>t[t.length-1],HI=(t,e)=>{for(let n=0;n<e.length;n++)t.push(e[n])},Ds=Array.from,Lb=(t,e)=>{for(let n=0;n<t.length;n++)if(!e(t[n],n,t))return!1;return!0},Fb=(t,e)=>{for(let n=0;n<t.length;n++)if(e(t[n],n,t))return!0;return!1},VI=(t,e)=>{const n=new Array(t);for(let r=0;r<t;r++)n[r]=e(r,n);return n},Kl=Array.isArray;class kS{constructor(){this._observers=fi()}on(e,n){return co(this._observers,e,Ma).add(n),n}once(e,n){const r=(...i)=>{this.off(e,r),n(...i)};this.on(e,r)}off(e,n){const r=this._observers.get(e);r!==void 0&&(r.delete(n),r.size===0&&this._observers.delete(e))}emit(e,n){return Ds((this._observers.get(e)||fi()).values()).forEach(r=>r(...n))}destroy(){this._observers=fi()}}const Mi=Math.floor,jf=Math.abs,Ro=(t,e)=>t<e?t:e,Di=(t,e)=>t>e?t:e,_S=t=>t!==0?t<0:1/t<0,Iw=1,Rw=2,lg=4,cg=8,Du=32,No=64,vr=128,UI=1<<29,Yp=31,rv=63,va=127,jI=2147483647,_h=Number.MAX_SAFE_INTEGER,Nw=Number.MIN_SAFE_INTEGER,qI=Number.isInteger||(t=>typeof t=="number"&&isFinite(t)&&Mi(t)===t),CS=String.fromCharCode,WI=t=>t.toLowerCase(),KI=/^\s*/g,GI=t=>t.replace(KI,""),ZI=/([A-Z])/g,Pw=(t,e)=>GI(t.replace(ZI,n=>`${e}${WI(n)}`)),YI=t=>{const e=unescape(encodeURIComponent(t)),n=e.length,r=new Uint8Array(n);for(let i=0;i<n;i++)r[i]=e.codePointAt(i);return r},Ou=typeof TextEncoder<"u"?new TextEncoder:null,JI=t=>Ou.encode(t),XI=Ou?JI:YI;let $c=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});$c&&$c.decode(new Uint8Array).length===1&&($c=null);const QI=(t,e)=>VI(e,()=>t).join("");let _d=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}};const Cd=()=>new _d,$I=t=>{const e=Cd();return t(e),Si(e)},eR=t=>{let e=t.cpos;for(let n=0;n<t.bufs.length;n++)e+=t.bufs[n].length;return e},Si=t=>{const e=new Uint8Array(eR(t));let n=0;for(let r=0;r<t.bufs.length;r++){const i=t.bufs[r];e.set(i,n),n+=i.length}return e.set(new Uint8Array(t.cbuf.buffer,0,t.cpos),n),e},tR=(t,e)=>{const n=t.cbuf.length;n-t.cpos<e&&(t.bufs.push(new Uint8Array(t.cbuf.buffer,0,t.cpos)),t.cbuf=new Uint8Array(Di(n,e)*2),t.cpos=0)},Pn=(t,e)=>{const n=t.cbuf.length;t.cpos===n&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(n*2),t.cpos=0),t.cbuf[t.cpos++]=e},iv=Pn,Ot=(t,e)=>{for(;e>va;)Pn(t,vr|va&e),e=Mi(e/128);Pn(t,va&e)},zb=(t,e)=>{const n=_S(e);for(n&&(e=-e),Pn(t,(e>rv?vr:0)|(n?No:0)|rv&e),e=Mi(e/64);e>0;)Pn(t,(e>va?vr:0)|va&e),e=Mi(e/128)},ov=new Uint8Array(3e4),nR=ov.length/3,rR=(t,e)=>{if(e.length<nR){const n=Ou.encodeInto(e,ov).written||0;Ot(t,n);for(let r=0;r<n;r++)Pn(t,ov[r])}else Lr(t,XI(e))},iR=(t,e)=>{const n=unescape(encodeURIComponent(e)),r=n.length;Ot(t,r);for(let i=0;i<r;i++)Pn(t,n.codePointAt(i))},pl=Ou&&Ou.encodeInto?rR:iR,Jp=(t,e)=>{const n=t.cbuf.length,r=t.cpos,i=Ro(n-r,e.length),o=e.length-i;t.cbuf.set(e.subarray(0,i),r),t.cpos+=i,o>0&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(Di(n*2,o)),t.cbuf.set(e.subarray(i)),t.cpos=o)},Lr=(t,e)=>{Ot(t,e.byteLength),Jp(t,e)},Bb=(t,e)=>{tR(t,e);const n=new DataView(t.cbuf.buffer,t.cpos,e);return t.cpos+=e,n},oR=(t,e)=>Bb(t,4).setFloat32(0,e,!1),sR=(t,e)=>Bb(t,8).setFloat64(0,e,!1),aR=(t,e)=>Bb(t,8).setBigInt64(0,e,!1),Lw=new DataView(new ArrayBuffer(4)),lR=t=>(Lw.setFloat32(0,t),Lw.getFloat32(0)===t),Gl=(t,e)=>{switch(typeof e){case"string":Pn(t,119),pl(t,e);break;case"number":qI(e)&&jf(e)<=jI?(Pn(t,125),zb(t,e)):lR(e)?(Pn(t,124),oR(t,e)):(Pn(t,123),sR(t,e));break;case"bigint":Pn(t,122),aR(t,e);break;case"object":if(e===null)Pn(t,126);else if(Kl(e)){Pn(t,117),Ot(t,e.length);for(let n=0;n<e.length;n++)Gl(t,e[n])}else if(e instanceof Uint8Array)Pn(t,116),Lr(t,e);else{Pn(t,118);const n=Object.keys(e);Ot(t,n.length);for(let r=0;r<n.length;r++){const i=n[r];pl(t,i),Gl(t,e[i])}}break;case"boolean":Pn(t,e?120:121);break;default:Pn(t,127)}};class Fw extends _d{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 zw=t=>{t.count>0&&(zb(t.encoder,t.count===1?t.s:-t.s),t.count>1&&Ot(t.encoder,t.count-2))};class qf{constructor(){this.encoder=new _d,this.s=0,this.count=0}write(e){this.s===e?this.count++:(zw(this),this.count=1,this.s=e)}toUint8Array(){return zw(this),Si(this.encoder)}}const Bw=t=>{if(t.count>0){const e=t.diff*2+(t.count===1?0:1);zb(t.encoder,e),t.count>1&&Ot(t.encoder,t.count-2)}};class ug{constructor(){this.encoder=new _d,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(Bw(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return Bw(this),Si(this.encoder)}}class cR{constructor(){this.sarr=[],this.s="",this.lensE=new qf}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 _d;return this.sarr.push(this.s),this.s="",pl(e,this.sarr.join("")),Jp(e,this.lensE.toUint8Array()),Si(e)}}const io=t=>new Error(t),hi=()=>{throw io("Method unimplemented")},ir=()=>{throw io("Unexpected case")},SS=io("Unexpected end of array"),ES=io("Integer out of Range");let Xp=class{constructor(e){this.arr=e,this.pos=0}};const fc=t=>new Xp(t),uR=t=>t.pos!==t.arr.length,dR=(t,e)=>{const n=new Uint8Array(t.arr.buffer,t.pos+t.arr.byteOffset,e);return t.pos+=e,n},Fr=t=>dR(t,Et(t)),Zl=t=>t.arr[t.pos++],Et=t=>{let e=0,n=1;const r=t.arr.length;for(;t.pos<r;){const i=t.arr[t.pos++];if(e=e+(i&va)*n,n*=128,i<vr)return e;if(e>_h)throw ES}throw SS},Hb=t=>{let e=t.arr[t.pos++],n=e&rv,r=64;const i=(e&No)>0?-1:1;if((e&vr)===0)return i*n;const o=t.arr.length;for(;t.pos<o;){if(e=t.arr[t.pos++],n=n+(e&va)*r,r*=128,e<vr)return i*n;if(n>_h)throw ES}throw SS},fR=t=>{let e=Et(t);if(e===0)return"";{let n=String.fromCodePoint(Zl(t));if(--e<100)for(;e--;)n+=String.fromCodePoint(Zl(t));else for(;e>0;){const r=e<1e4?e:1e4,i=t.arr.subarray(t.pos,t.pos+r);t.pos+=r,n+=String.fromCodePoint.apply(null,i),e-=r}return decodeURIComponent(escape(n))}},hR=t=>$c.decode(Fr(t)),ml=$c?hR:fR,Vb=(t,e)=>{const n=new DataView(t.arr.buffer,t.arr.byteOffset+t.pos,e);return t.pos+=e,n},pR=t=>Vb(t,4).getFloat32(0,!1),mR=t=>Vb(t,8).getFloat64(0,!1),gR=t=>Vb(t,8).getBigInt64(0,!1),vR=[t=>{},t=>null,Hb,pR,mR,gR,t=>!1,t=>!0,ml,t=>{const e=Et(t),n={};for(let r=0;r<e;r++){const i=ml(t);n[i]=Iu(t)}return n},t=>{const e=Et(t),n=[];for(let r=0;r<e;r++)n.push(Iu(t));return n},Fr],Iu=t=>vR[127-Zl(t)](t);class Hw extends Xp{constructor(e,n){super(e),this.reader=n,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),uR(this)?this.count=Et(this)+1:this.count=-1),this.count--,this.s}}class Wf extends Xp{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=Hb(this);const e=_S(this.s);this.count=1,e&&(this.s=-this.s,this.count=Et(this)+2)}return this.count--,this.s}}class dg extends Xp{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){const e=Hb(this),n=e&1;this.diff=Mi(e/2),this.count=1,n&&(this.count=Et(this)+2)}return this.s+=this.diff,this.count--,this.s}}class bR{constructor(e){this.decoder=new Wf(e),this.str=ml(this.decoder),this.spos=0}read(){const e=this.spos+this.decoder.read(),n=this.str.slice(this.spos,e);return this.spos=e,n}}const yR=crypto.getRandomValues.bind(crypto),wR=Math.random,AS=()=>yR(new Uint32Array(1))[0],xR=t=>t[Mi(wR()*t.length)],kR="10000000-1000-4000-8000"+-1e11,_R=()=>kR.replace(/[018]/g,t=>(t^AS()&15>>t/4).toString(16)),CR=Date.now,Vw=t=>new Promise(t);Promise.all.bind(Promise);const Uw=t=>t===void 0?null:t;class SR{constructor(){this.map=new Map}setItem(e,n){this.map.set(e,n)}getItem(e){return this.map.get(e)}}let TS=new SR,ER=!0;try{typeof localStorage<"u"&&localStorage&&(TS=localStorage,ER=!1)}catch{}const AR=TS,Ru=Symbol("Equality"),MS=(t,e)=>{var n;return t===e||!!((n=t==null?void 0:t[Ru])!=null&&n.call(t,e))||!1},TR=t=>typeof t=="object",MR=Object.assign,DS=Object.keys,DR=(t,e)=>{for(const n in t)e(t[n],n)},Ch=t=>DS(t).length,OR=t=>{for(const e in t)return!1;return!0},hc=(t,e)=>{for(const n in t)if(!e(t[n],n))return!1;return!0},Ub=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),IR=(t,e)=>t===e||Ch(t)===Ch(e)&&hc(t,(n,r)=>(n!==void 0||Ub(e,r))&&MS(e[r],n)),RR=Object.freeze,OS=t=>{for(const e in t){const n=t[e];(typeof n=="object"||typeof n=="function")&&OS(t[e])}return RR(t)},jb=(t,e,n=0)=>{try{for(;n<t.length;n++)t[n](...e)}finally{n<t.length&&jb(t,e,n+1)}},NR=t=>t,Kf=(t,e)=>{if(t===e)return!0;if(t==null||e==null||t.constructor!==e.constructor&&(t.constructor||Object)!==(e.constructor||Object))return!1;if(t[Ru]!=null)return t[Ru](e);switch(t.constructor){case ArrayBuffer:t=new Uint8Array(t),e=new Uint8Array(e);case Uint8Array:{if(t.byteLength!==e.byteLength)return!1;for(let n=0;n<t.length;n++)if(t[n]!==e[n])return!1;break}case Set:{if(t.size!==e.size)return!1;for(const n of t)if(!e.has(n))return!1;break}case Map:{if(t.size!==e.size)return!1;for(const n of t.keys())if(!e.has(n)||!Kf(t.get(n),e.get(n)))return!1;break}case void 0:case Object:if(Ch(t)!==Ch(e))return!1;for(const n in t)if(!Ub(t,n)||!Kf(t[n],e[n]))return!1;break;case Array:if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++)if(!Kf(t[n],e[n]))return!1;break;default:return!1}return!0},PR=(t,e)=>e.includes(t);var IS={};const Yl=typeof process<"u"&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]",RS=typeof window<"u"&&typeof document<"u"&&!Yl;let Hi;const LR=()=>{if(Hi===void 0)if(Yl){Hi=fi();const t=process.argv;let e=null;for(let n=0;n<t.length;n++){const r=t[n];r[0]==="-"?(e!==null&&Hi.set(e,""),e=r):e!==null&&(Hi.set(e,r),e=null)}e!==null&&Hi.set(e,"")}else typeof location=="object"?(Hi=fi(),(location.search||"?").slice(1).split("&").forEach(t=>{if(t.length!==0){const[e,n]=t.split("=");Hi.set(`--${Pw(e,"-")}`,n),Hi.set(`-${Pw(e,"-")}`,n)}})):Hi=fi();return Hi},sv=t=>LR().has(t),Sh=t=>Uw(Yl?IS[t.toUpperCase().replaceAll("-","_")]:AR.getItem(t)),NS=t=>sv("--"+t)||Sh(t)!==null,FR=NS("production"),zR=Yl&&PR(IS.FORCE_COLOR,["true","1","2"]),BR=zR||!sv("--no-colors")&&!NS("no-color")&&(!Yl||process.stdout.isTTY)&&(!Yl||sv("--color")||Sh("COLORTERM")!==null||(Sh("TERM")||"").includes("color")),HR=t=>new Uint8Array(t),VR=t=>{let e="";for(let n=0;n<t.byteLength;n++)e+=CS(t[n]);return btoa(e)},UR=t=>Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("base64"),jR=RS?VR:UR,qR=t=>{const e=HR(t.byteLength);return e.set(t),e},WR=t=>$I(e=>Gl(e,t));class KR{constructor(e,n){this.left=e,this.right=n}}const mo=(t,e)=>new KR(t,e),jw=t=>t.next()>=.5,fg=(t,e,n)=>Mi(t.next()*(n+1-e)+e),PS=(t,e,n)=>Mi(t.next()*(n+1-e)+e),qb=(t,e,n)=>PS(t,e,n),GR=t=>CS(qb(t,97,122)),ZR=(t,e=0,n=20)=>{const r=qb(t,e,n);let i="";for(let o=0;o<r;o++)i+=GR(t);return i},hg=(t,e)=>e[qb(t,0,e.length-1)],YR=Symbol("0schema");class JR{constructor(){this._rerrs=[]}extend(e,n,r,i=null){this._rerrs.push({path:e,expected:n,has:r,message:i})}toString(){const e=[];for(let n=this._rerrs.length-1;n>0;n--){const r=this._rerrs[n];e.push(QI(" ",(this._rerrs.length-n)*2)+`${r.path!=null?`[${r.path}] `:""}${r.has} doesn't match ${r.expected}. ${r.message}`)}return e.join(`
56
+ `)}}const av=(t,e)=>t===e?!0:t==null||e==null||t.constructor!==e.constructor?!1:t[Ru]?MS(t,e):Kl(t)?Lb(t,n=>Fb(e,r=>av(n,r))):TR(t)?hc(t,(n,r)=>av(n,e[r])):!1;class lr{extends(e){let[n,r]=[this.shape,e.shape];return this.constructor._dilutes&&([r,n]=[n,r]),av(n,r)}equals(e){return this.constructor===e.constructor&&Kf(this.shape,e.shape)}[YR](){return!0}[Ru](e){return this.equals(e)}validate(e){return this.check(e)}check(e,n){hi()}get nullable(){return pc(this,nm)}get optional(){return new zS(this)}cast(e){return qw(e,this),e}expect(e){return qw(e,this),e}}In(lr,"_dilutes",!1);class Wb extends lr{constructor(e,n){super(),this.shape=e,this._c=n}check(e,n=void 0){const r=(e==null?void 0:e.constructor)===this.shape&&(this._c==null||this._c(e));return!r&&(n==null||n.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 Cn=(t,e=null)=>new Wb(t,e);Cn(Wb);class Kb extends lr{constructor(e){super(),this.shape=e}check(e,n){const r=this.shape(e);return!r&&(n==null||n.extend(null,"custom prop",e==null?void 0:e.constructor.name,"failed to check custom prop")),r}}const qn=t=>new Kb(t);Cn(Kb);class Qp extends lr{constructor(e){super(),this.shape=e}check(e,n){const r=this.shape.some(i=>i===e);return!r&&(n==null||n.extend(null,this.shape.join(" | "),e.toString())),r}}const $p=(...t)=>new Qp(t),LS=Cn(Qp),XR=RegExp.escape||(t=>t.replace(/[().|&,$^[\]]/g,e=>"\\"+e)),FS=t=>{if(Jl.check(t))return[XR(t)];if(LS.check(t))return t.shape.map(e=>e+"");if(GS.check(t))return["[+-]?\\d+.?\\d*"];if(ZS.check(t))return[".*"];if(Ah.check(t))return t.shape.map(FS).flat(1);ir()};class QR extends lr{constructor(e){super(),this.shape=e,this._r=new RegExp("^"+e.map(FS).map(n=>`(${n.join("|")})`).join("")+"$")}check(e,n){const r=this._r.exec(e)!=null;return!r&&(n==null||n.extend(null,this._r.toString(),e.toString(),"String doesn't match string template.")),r}}Cn(QR);const $R=Symbol("optional");class zS extends lr{constructor(e){super(),this.shape=e}check(e,n){const r=e===void 0||this.shape.check(e);return!r&&(n==null||n.extend(null,"undefined (optional)","()")),r}get[$R](){return!0}}const eN=Cn(zS);class tN extends lr{check(e,n){return n==null||n.extend(null,"never",typeof e),!1}}Cn(tN);const Np=class Np extends lr{constructor(e,n=!1){super(),this.shape=e,this._isPartial=n}get partial(){return new Np(this.shape,!0)}check(e,n){return e==null?(n==null||n.extend(null,"object","null"),!1):hc(this.shape,(r,i)=>{const o=this._isPartial&&!Ub(e,i)||r.check(e[i],n);return!o&&(n==null||n.extend(i.toString(),r.toString(),typeof e[i],"Object property does not match")),o})}};In(Np,"_dilutes",!0);let Eh=Np;const nN=t=>new Eh(t),rN=Cn(Eh),iN=qn(t=>t!=null&&(t.constructor===Object||t.constructor==null));class BS extends lr{constructor(e,n){super(),this.shape={keys:e,values:n}}check(e,n){return e!=null&&hc(e,(r,i)=>{const o=this.shape.keys.check(i,n);return!o&&(n==null||n.extend(i+"","Record",typeof e,o?"Key doesn't match schema":"Value doesn't match value")),o&&this.shape.values.check(r,n)})}}const HS=(t,e)=>new BS(t,e),oN=Cn(BS);class VS extends lr{constructor(e){super(),this.shape=e}check(e,n){return e!=null&&hc(this.shape,(r,i)=>{const o=r.check(e[i],n);return!o&&(n==null||n.extend(i.toString(),"Tuple",typeof r)),o})}}const sN=(...t)=>new VS(t);Cn(VS);class US extends lr{constructor(e){super(),this.shape=e.length===1?e[0]:new em(e)}check(e,n){const r=Kl(e)&&Lb(e,i=>this.shape.check(i));return!r&&(n==null||n.extend(null,"Array","")),r}}const jS=(...t)=>new US(t),aN=Cn(US),lN=qn(t=>Kl(t));class qS extends lr{constructor(e,n){super(),this.shape=e,this._c=n}check(e,n){const r=e instanceof this.shape&&(this._c==null||this._c(e));return!r&&(n==null||n.extend(null,this.shape.name,e==null?void 0:e.constructor.name)),r}}const cN=(t,e=null)=>new qS(t,e);Cn(qS);const uN=cN(lr);class dN extends lr{constructor(e){super(),this.len=e.length-1,this.args=sN(...e.slice(-1)),this.res=e[this.len]}check(e,n){const r=e.constructor===Function&&e.length<=this.len;return!r&&(n==null||n.extend(null,"function",typeof e)),r}}const fN=Cn(dN),hN=qn(t=>typeof t=="function");class pN extends lr{constructor(e){super(),this.shape=e}check(e,n){const r=Lb(this.shape,i=>i.check(e,n));return!r&&(n==null||n.extend(null,"Intersectinon",typeof e)),r}}Cn(pN,t=>t.shape.length>0);class em extends lr{constructor(e){super(),this.shape=e}check(e,n){const r=Fb(this.shape,i=>i.check(e,n));return n==null||n.extend(null,"Union",typeof e),r}}In(em,"_dilutes",!0);const pc=(...t)=>t.findIndex(e=>Ah.check(e))>=0?pc(...t.map(e=>Nu(e)).map(e=>Ah.check(e)?e.shape:[e]).flat(1)):t.length===1?t[0]:new em(t),Ah=Cn(em),WS=()=>!0,Th=qn(WS),mN=Cn(Kb,t=>t.shape===WS),Gb=qn(t=>typeof t=="bigint"),gN=qn(t=>t===Gb),KS=qn(t=>typeof t=="symbol");qn(t=>t===KS);const gl=qn(t=>typeof t=="number"),GS=qn(t=>t===gl),Jl=qn(t=>typeof t=="string"),ZS=qn(t=>t===Jl),tm=qn(t=>typeof t=="boolean"),vN=qn(t=>t===tm),YS=$p(void 0);Cn(Qp,t=>t.shape.length===1&&t.shape[0]===void 0);$p(void 0);const nm=$p(null),bN=Cn(Qp,t=>t.shape.length===1&&t.shape[0]===null);Cn(Uint8Array);Cn(Wb,t=>t.shape===Uint8Array);const yN=pc(gl,Jl,nm,YS,Gb,tm,KS);(()=>{const t=jS(Th),e=HS(Jl,Th),n=pc(gl,Jl,nm,tm,t,e);return t.shape=n,e.shape.values=n,n})();const Nu=t=>{if(uN.check(t))return t;if(iN.check(t)){const e={};for(const n in t)e[n]=Nu(t[n]);return nN(e)}else{if(lN.check(t))return pc(...t.map(Nu));if(yN.check(t))return $p(t);if(hN.check(t))return Cn(t)}ir()},qw=FR?()=>{}:(t,e)=>{const n=new JR;if(!e.check(t,n))throw io(`Expected value to be of type ${e.constructor.name}.
57
+ ${n.toString()}`)};class wN{constructor(e){this.patterns=[],this.$state=e}if(e,n){return this.patterns.push({if:Nu(e),h:n}),this}else(e){return this.if(Th,e)}done(){return(e,n)=>{for(let r=0;r<this.patterns.length;r++){const i=this.patterns[r];if(i.if.check(e))return i.h(e,n)}throw io("Unhandled pattern")}}}const xN=t=>new wN(t),JS=xN(Th).if(GS,(t,e)=>fg(e,Nw,_h)).if(ZS,(t,e)=>ZR(e)).if(vN,(t,e)=>jw(e)).if(gN,(t,e)=>BigInt(fg(e,Nw,_h))).if(Ah,(t,e)=>Ga(e,hg(e,t.shape))).if(rN,(t,e)=>{const n={};for(const r in t.shape){let i=t.shape[r];if(eN.check(i)){if(jw(e))continue;i=i.shape}n[r]=JS(i,e)}return n}).if(aN,(t,e)=>{const n=[],r=PS(e,0,42);for(let i=0;i<r;i++)n.push(Ga(e,t.shape));return n}).if(LS,(t,e)=>hg(e,t.shape)).if(bN,(t,e)=>null).if(fN,(t,e)=>{const n=Ga(e,t.res);return()=>n}).if(mN,(t,e)=>Ga(e,hg(e,[gl,Jl,nm,YS,Gb,tm,jS(gl),HS(pc("a","b","c"),gl)]))).if(oN,(t,e)=>{const n={},r=fg(e,0,3);for(let i=0;i<r;i++){const o=Ga(e,t.shape.keys),s=Ga(e,t.shape.values);n[o]=s}return n}).done(),Ga=(t,e)=>JS(Nu(e),t),Sd=typeof document<"u"?document:{};qn(t=>t.nodeType===EN);typeof DOMParser<"u"&&new DOMParser;qn(t=>t.nodeType===_N);qn(t=>t.nodeType===CN);const kN=t=>zI(t,(e,n)=>`${n}:${e};`).join(""),_N=Sd.ELEMENT_NODE,CN=Sd.TEXT_NODE,SN=Sd.DOCUMENT_NODE,EN=Sd.DOCUMENT_FRAGMENT_NODE;qn(t=>t.nodeType===SN);const AN=t=>class{constructor(n){this._=n}destroy(){t(this._)}},TN=AN(clearTimeout),Zb=(t,e)=>new TN(setTimeout(e,t)),Ko=Symbol,XS=Ko(),QS=Ko(),MN=Ko(),DN=Ko(),ON=Ko(),$S=Ko(),IN=Ko(),Yb=Ko(),RN=Ko(),NN=t=>{var i;t.length===1&&((i=t[0])==null?void 0:i.constructor)===Function&&(t=t[0]());const e=[],n=[];let r=0;for(;r<t.length;r++){const o=t[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&&n.push(e.join(""));r<t.length;r++){const o=t[r];o instanceof Symbol||n.push(o)}return n},PN={[XS]:mo("font-weight","bold"),[QS]:mo("font-weight","normal"),[MN]:mo("color","blue"),[ON]:mo("color","green"),[DN]:mo("color","grey"),[$S]:mo("color","red"),[IN]:mo("color","purple"),[Yb]:mo("color","orange"),[RN]:mo("color","black")},LN=t=>{var s;t.length===1&&((s=t[0])==null?void 0:s.constructor)===Function&&(t=t[0]());const e=[],n=[],r=fi();let i=[],o=0;for(;o<t.length;o++){const a=t[o],l=PN[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=kN(r);o>0||c.length>0?(e.push("%c"+a),n.push(c)):e.push(a)}else break}}for(o>0&&(i=n,i.unshift(e.join("")));o<t.length;o++){const a=t[o];a instanceof Symbol||i.push(a)}return i},e3=BR?LN:NN,FN=(...t)=>{console.log(...e3(t)),n3.forEach(e=>e.print(t))},t3=(...t)=>{console.warn(...e3(t)),t.unshift(Yb),n3.forEach(e=>e.print(t))},n3=Ma(),r3=t=>({[Symbol.iterator](){return this},next:t}),zN=(t,e)=>r3(()=>{let n;do n=t.next();while(!n.done&&!e(n.value));return n}),pg=(t,e)=>r3(()=>{const{done:n,value:r}=t.next();return{done:n,value:n?void 0:e(r)}});class rm{constructor(e,n){this.clock=e,this.len=n}}class mc{constructor(){this.clients=new Map}}const Os=(t,e,n)=>e.clients.forEach((r,i)=>{const o=t.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])v3(t,o,c.clock,c.len,n)}}),BN=(t,e)=>{let n=0,r=t.length-1;for(;n<=r;){const i=Mi((n+r)/2),o=t[i],s=o.clock;if(s<=e){if(e<s+o.len)return i;n=i+1}else r=i-1}return null},gc=(t,e)=>{const n=t.clients.get(e.client);return n!==void 0&&BN(n,e.clock)!==null},Jb=t=>{t.clients.forEach(e=>{e.sort((i,o)=>i.clock-o.clock);let n,r;for(n=1,r=1;n<e.length;n++){const i=e[r-1],o=e[n];i.clock+i.len>=o.clock?e[r-1]=new rm(i.clock,Di(i.len,o.clock+o.len-i.clock)):(r<n&&(e[r]=o),r++)}e.length=r})},lv=t=>{const e=new mc;for(let n=0;n<t.length;n++)t[n].clients.forEach((r,i)=>{if(!e.clients.has(i)){const o=r.slice();for(let s=n+1;s<t.length;s++)HI(o,t[s].clients.get(i)||[]);e.clients.set(i,o)}});return Jb(e),e},Pu=(t,e,n,r)=>{co(t.clients,e,()=>[]).push(new rm(n,r))},i3=()=>new mc,o3=t=>{const e=i3();return t.clients.forEach((n,r)=>{const i=[];for(let o=0;o<n.length;o++){const s=n[o];if(s.deleted){const a=s.id.clock;let l=s.length;if(o+1<n.length)for(let c=n[o+1];o+1<n.length&&c.deleted;c=n[++o+1])l+=c.length;i.push(new rm(a,l))}}i.length>0&&e.clients.set(r,i)}),e},vc=(t,e)=>{Ot(t.restEncoder,e.clients.size),Ds(e.clients.entries()).sort((n,r)=>r[0]-n[0]).forEach(([n,r])=>{t.resetDsCurVal(),Ot(t.restEncoder,n);const i=r.length;Ot(t.restEncoder,i);for(let o=0;o<i;o++){const s=r[o];t.writeDsClock(s.clock),t.writeDsLen(s.len)}})},Xb=t=>{const e=new mc,n=Et(t.restDecoder);for(let r=0;r<n;r++){t.resetDsCurVal();const i=Et(t.restDecoder),o=Et(t.restDecoder);if(o>0){const s=co(e.clients,i,()=>[]);for(let a=0;a<o;a++)s.push(new rm(t.readDsClock(),t.readDsLen()))}}return e},Ww=(t,e,n)=>{const r=new mc,i=Et(t.restDecoder);for(let o=0;o<i;o++){t.resetDsCurVal();const s=Et(t.restDecoder),a=Et(t.restDecoder),l=n.clients.get(s)||[],c=bn(n,s);for(let u=0;u<a;u++){const f=t.readDsClock(),h=f+t.readDsLen();if(f<c){c<h&&Pu(r,s,c,h-c);let p=Oi(l,f),m=l[p];for(!m.deleted&&m.id.clock<f&&(l.splice(p+1,0,Ph(e,m,f-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,Ph(e,m,h-m.id.clock)),m.delete(e))}else Pu(r,s,f,h-f)}}if(r.clients.size>0){const o=new Da;return Ot(o.restEncoder,0),vc(o,r),o.toUint8Array()}return null},s3=AS;class oo extends kS{constructor({guid:e=_R(),collectionid:n=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=s3(),this.guid=e,this.collectionid=n,this.share=new Map,this.store=new m3,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=Vw(c=>{this.on("load",()=>{this.isLoaded=!0,c(this)})});const l=()=>Vw(c=>{const u=f=>{(f===void 0||f===!0)&&(this.off("sync",u),c())};this.on("sync",u)});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&&Yt(e.parent.doc,n=>{n.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(Ds(this.subdocs).map(e=>e.guid))}transact(e,n=null){return Yt(this,e,n)}get(e,n=Vn){const r=co(this.share,e,()=>{const o=new n;return o._integrate(this,null),o}),i=r.constructor;if(n!==Vn&&i!==n)if(i===Vn){const o=new n;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,yl)}getText(e=""){return this.get(e,Is)}getMap(e=""){return this.get(e,Ql)}getXmlElement(e=""){return this.get(e,ln)}getXmlFragment(e=""){return this.get(e,Oa)}toJSON(){const e={};return this.share.forEach((n,r)=>{e[r]=n.toJSON()}),e}destroy(){this.isDestroyed=!0,Ds(this.subdocs).forEach(n=>n.destroy());const e=this._item;if(e!==null){this._item=null;const n=e.content;n.doc=new oo({guid:this.guid,...n.opts,shouldLoad:!1}),n.doc._item=e,Yt(e.parent.doc,r=>{const i=n.doc;e.deleted||r.subdocsAdded.add(i),r.subdocsRemoved.add(this)},null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}}class a3{constructor(e){this.restDecoder=e}resetDsCurVal(){}readDsClock(){return Et(this.restDecoder)}readDsLen(){return Et(this.restDecoder)}}class l3 extends a3{readLeftID(){return bt(Et(this.restDecoder),Et(this.restDecoder))}readRightID(){return bt(Et(this.restDecoder),Et(this.restDecoder))}readClient(){return Et(this.restDecoder)}readInfo(){return Zl(this.restDecoder)}readString(){return ml(this.restDecoder)}readParentInfo(){return Et(this.restDecoder)===1}readTypeRef(){return Et(this.restDecoder)}readLen(){return Et(this.restDecoder)}readAny(){return Iu(this.restDecoder)}readBuf(){return qR(Fr(this.restDecoder))}readJSON(){return JSON.parse(ml(this.restDecoder))}readKey(){return ml(this.restDecoder)}}class HN{constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=Et(this.restDecoder),this.dsCurrVal}readDsLen(){const e=Et(this.restDecoder)+1;return this.dsCurrVal+=e,e}}class Xl extends HN{constructor(e){super(e),this.keys=[],Et(e),this.keyClockDecoder=new dg(Fr(e)),this.clientDecoder=new Wf(Fr(e)),this.leftClockDecoder=new dg(Fr(e)),this.rightClockDecoder=new dg(Fr(e)),this.infoDecoder=new Hw(Fr(e),Zl),this.stringDecoder=new bR(Fr(e)),this.parentInfoDecoder=new Hw(Fr(e),Zl),this.typeRefDecoder=new Wf(Fr(e)),this.lenDecoder=new Wf(Fr(e))}readLeftID(){return new vl(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new vl(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 Iu(this.restDecoder)}readBuf(){return Fr(this.restDecoder)}readJSON(){return Iu(this.restDecoder)}readKey(){const e=this.keyClockDecoder.read();if(e<this.keys.length)return this.keys[e];{const n=this.stringDecoder.read();return this.keys.push(n),n}}}class c3{constructor(){this.restEncoder=Cd()}toUint8Array(){return Si(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){Ot(this.restEncoder,e)}writeDsLen(e){Ot(this.restEncoder,e)}}class Ed extends c3{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){iv(this.restEncoder,e)}writeString(e){pl(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){Gl(this.restEncoder,e)}writeBuf(e){Lr(this.restEncoder,e)}writeJSON(e){pl(this.restEncoder,JSON.stringify(e))}writeKey(e){pl(this.restEncoder,e)}}class u3{constructor(){this.restEncoder=Cd(),this.dsCurrVal=0}toUint8Array(){return Si(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){const n=e-this.dsCurrVal;this.dsCurrVal=e,Ot(this.restEncoder,n)}writeDsLen(e){e===0&&ir(),Ot(this.restEncoder,e-1),this.dsCurrVal+=e}}class Da extends u3{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new ug,this.clientEncoder=new qf,this.leftClockEncoder=new ug,this.rightClockEncoder=new ug,this.infoEncoder=new Fw(iv),this.stringEncoder=new cR,this.parentInfoEncoder=new Fw(iv),this.typeRefEncoder=new qf,this.lenEncoder=new qf}toUint8Array(){const e=Cd();return Ot(e,0),Lr(e,this.keyClockEncoder.toUint8Array()),Lr(e,this.clientEncoder.toUint8Array()),Lr(e,this.leftClockEncoder.toUint8Array()),Lr(e,this.rightClockEncoder.toUint8Array()),Lr(e,Si(this.infoEncoder)),Lr(e,this.stringEncoder.toUint8Array()),Lr(e,Si(this.parentInfoEncoder)),Lr(e,this.typeRefEncoder.toUint8Array()),Lr(e,this.lenEncoder.toUint8Array()),Jp(e,Si(this.restEncoder)),Si(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){Gl(this.restEncoder,e)}writeBuf(e){Lr(this.restEncoder,e)}writeJSON(e){Gl(this.restEncoder,e)}writeKey(e){const n=this.keyMap.get(e);n===void 0?(this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(e)):this.keyClockEncoder.write(n)}}const VN=(t,e,n,r)=>{r=Di(r,e[0].id.clock);const i=Oi(e,r);Ot(t.restEncoder,e.length-i),t.writeClient(n),Ot(t.restEncoder,r);const o=e[i];o.write(t,r-o.id.clock);for(let s=i+1;s<e.length;s++)e[s].write(t,0)},Qb=(t,e,n)=>{const r=new Map;n.forEach((i,o)=>{bn(e,o)>i&&r.set(o,i)}),Ad(e).forEach((i,o)=>{n.has(o)||r.set(o,0)}),Ot(t.restEncoder,r.size),Ds(r.entries()).sort((i,o)=>o[0]-i[0]).forEach(([i,o])=>{VN(t,e.clients.get(i),i,o)})},UN=(t,e)=>{const n=fi(),r=Et(t.restDecoder);for(let i=0;i<r;i++){const o=Et(t.restDecoder),s=new Array(o),a=t.readClient();let l=Et(t.restDecoder);n.set(a,{i:0,refs:s});for(let c=0;c<o;c++){const u=t.readInfo();switch(Yp&u){case 0:{const f=t.readLen();s[c]=new oi(bt(a,l),f),l+=f;break}case 10:{const f=Et(t.restDecoder);s[c]=new si(bt(a,l),f),l+=f;break}default:{const f=(u&(No|vr))===0,h=new Qt(bt(a,l),null,(u&vr)===vr?t.readLeftID():null,null,(u&No)===No?t.readRightID():null,f?t.readParentInfo()?e.get(t.readString()):t.readLeftID():null,f&&(u&Du)===Du?t.readString():null,B3(t,u));s[c]=h,l+=h.length}}}}return n},jN=(t,e,n)=>{const r=[];let i=Ds(n.keys()).sort((p,m)=>p-m);if(i.length===0)return null;const o=()=>{if(i.length===0)return null;let p=n.get(i[i.length-1]);for(;p.refs.length===p.i;)if(i.pop(),i.length>0)p=n.get(i[i.length-1]);else return null;return p};let s=o();if(s===null)return null;const a=new m3,l=new Map,c=(p,m)=>{const v=l.get(p);(v==null||v>m)&&l.set(p,m)};let u=s.refs[s.i++];const f=new Map,h=()=>{for(const p of r){const m=p.id.client,v=n.get(m);v?(v.i--,a.clients.set(m,v.refs.slice(v.i)),n.delete(m),v.i=0,v.refs=[]):a.clients.set(m,[p]),i=i.filter(g=>g!==m)}r.length=0};for(;;){if(u.constructor!==si){const m=co(f,u.id.client,()=>bn(e,u.id.client))-u.id.clock;if(m<0)r.push(u),c(u.id.client,u.id.clock-1),h();else{const v=u.getMissing(t,e);if(v!==null){r.push(u);const g=n.get(v)||{refs:[],i:0};if(g.refs.length===g.i)c(v,bn(e,v)),h();else{u=g.refs[g.i++];continue}}else(m===0||m<u.length)&&(u.integrate(t,m),f.set(u.id.client,u.id.clock+u.length))}}if(r.length>0)u=r.pop();else if(s!==null&&s.i<s.refs.length)u=s.refs[s.i++];else{if(s=o(),s===null)break;u=s.refs[s.i++]}}if(a.clients.size>0){const p=new Da;return Qb(p,a,new Map),Ot(p.restEncoder,0),{missing:l,update:p.toUint8Array()}}return null},qN=(t,e)=>Qb(t,e.doc.store,e.beforeState),WN=(t,e,n,r=new Xl(t))=>Yt(e,i=>{i.local=!1;let o=!1;const s=i.doc,a=s.store,l=UN(r,s),c=jN(i,a,l),u=a.pendingStructs;if(u){for(const[h,p]of u.missing)if(p<bn(a,h)){o=!0;break}if(c){for(const[h,p]of c.missing){const m=u.missing.get(h);(m==null||m>p)&&u.missing.set(h,p)}u.update=Dh([u.update,c.update])}}else a.pendingStructs=c;const f=Ww(r,i,a);if(a.pendingDs){const h=new Xl(fc(a.pendingDs));Et(h.restDecoder);const p=Ww(h,i,a);f&&p?a.pendingDs=Dh([f,p]):a.pendingDs=f||p}else a.pendingDs=f;if(o){const h=a.pendingStructs.update;a.pendingStructs=null,Mh(i.doc,h)}},n,!1),Mh=(t,e,n,r=Xl)=>{const i=fc(e);WN(i,t,n,new r(i))},KN=(t,e,n)=>Mh(t,e,n,l3),GN=(t,e,n=new Map)=>{Qb(t,e.store,n),vc(t,o3(e.store))},ZN=(t,e=new Uint8Array([0]),n=new Da)=>{const r=d3(e);GN(n,t,r);const i=[n.toUint8Array()];if(t.store.pendingDs&&i.push(t.store.pendingDs),t.store.pendingStructs&&i.push(h9(t.store.pendingStructs.update,e)),i.length>1){if(n.constructor===Ed)return d9(i.map((o,s)=>s===0?o:m9(o)));if(n.constructor===Da)return Dh(i)}return i[0]},YN=(t,e)=>ZN(t,e,new Ed),JN=t=>{const e=new Map,n=Et(t.restDecoder);for(let r=0;r<n;r++){const i=Et(t.restDecoder),o=Et(t.restDecoder);e.set(i,o)}return e},d3=t=>JN(new a3(fc(t))),f3=(t,e)=>(Ot(t.restEncoder,e.size),Ds(e.entries()).sort((n,r)=>r[0]-n[0]).forEach(([n,r])=>{Ot(t.restEncoder,n),Ot(t.restEncoder,r)}),t),XN=(t,e)=>f3(t,Ad(e.store)),QN=(t,e=new u3)=>(t instanceof Map?f3(e,t):XN(e,t),e.toUint8Array()),$N=t=>QN(t,new c3);class e9{constructor(){this.l=[]}}const Kw=()=>new e9,Gw=(t,e)=>t.l.push(e),Zw=(t,e)=>{const n=t.l,r=n.length;t.l=n.filter(i=>e!==i),r===t.l.length&&console.error("[yjs] Tried to remove event handler that doesn't exist.")},h3=(t,e,n)=>jb(t.l,[e,n]);class vl{constructor(e,n){this.client=e,this.clock=n}}const cl=(t,e)=>t===e||t!==null&&e!==null&&t.client===e.client&&t.clock===e.clock,bt=(t,e)=>new vl(t,e),Lu=t=>{for(const[e,n]of t.doc.share.entries())if(n===t)return e;throw ir()},Fu=(t,e)=>{for(;e!==null;){if(e.parent===t)return!0;e=e.parent._item}return!1};class zu{constructor(e,n,r,i=0){this.type=e,this.tname=n,this.item=r,this.assoc=i}}const ba=t=>new zu(t.type==null?null:bt(t.type.client,t.type.clock),t.tname??null,t.item==null?null:bt(t.item.client,t.item.clock),t.assoc==null?0:t.assoc);class t9{constructor(e,n,r=0){this.type=e,this.index=n,this.assoc=r}}const n9=(t,e,n=0)=>new t9(t,e,n),$d=(t,e,n)=>{let r=null,i=null;return t._item===null?i=Lu(t):r=bt(t._item.id.client,t._item.id.clock),new zu(r,i,e,n)},mg=(t,e,n=0)=>{let r=t._start;if(n<0){if(e===0)return $d(t,null,n);e--}for(;r!==null;){if(!r.deleted&&r.countable){if(r.length>e)return $d(t,bt(r.id.client,r.id.clock+e),n);e-=r.length}if(r.right===null&&n<0)return $d(t,r.lastId,n);r=r.right}return $d(t,null,n)},r9=(t,e)=>{const n=bl(t,e),r=e.clock-n.id.clock;return{item:n,diff:r}},cv=(t,e,n=!0)=>{const r=e.store,i=t.item,o=t.type,s=t.tname,a=t.assoc;let l=null,c=0;if(i!==null){if(bn(r,i.client)<=i.clock)return null;const u=n?hv(r,i):r9(r,i),f=u.item;if(!(f instanceof Qt))return null;if(l=f.parent,l._item===null||!l._item.deleted){c=f.deleted||!f.countable?0:u.diff+(a>=0?0:1);let h=f.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(bn(r,o.client)<=o.clock)return null;const{item:u}=n?hv(r,o):{item:bl(r,o)};if(u instanceof Qt&&u.content instanceof Ni)l=u.content.type;else return null}else throw ir();a>=0?c=l._length:c=0}return n9(l,c,t.assoc)},Yw=(t,e)=>t===e||t!==null&&e!==null&&t.tname===e.tname&&cl(t.item,e.item)&&cl(t.type,e.type)&&t.assoc===e.assoc;class $b{constructor(e,n){this.ds=e,this.sv=n}}const p3=(t,e)=>new $b(t,e),gg=t=>p3(o3(t.store),Ad(t.store)),Ys=(t,e)=>e===void 0?!t.deleted:e.sv.has(t.id.client)&&(e.sv.get(t.id.client)||0)>t.id.clock&&!gc(e.ds,t.id),uv=(t,e)=>{const n=co(t.meta,uv,Ma),r=t.doc.store;n.has(e)||(e.sv.forEach((i,o)=>{i<bn(r,o)&&Cr(t,bt(o,i))}),Os(t,e.ds,i=>{}),n.add(e))};class m3{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}}const Ad=t=>{const e=new Map;return t.clients.forEach((n,r)=>{const i=n[n.length-1];e.set(r,i.id.clock+i.length)}),e},bn=(t,e)=>{const n=t.clients.get(e);if(n===void 0)return 0;const r=n[n.length-1];return r.id.clock+r.length},g3=(t,e)=>{let n=t.clients.get(e.id.client);if(n===void 0)n=[],t.clients.set(e.id.client,n);else{const r=n[n.length-1];if(r.id.clock+r.length!==e.id.clock)throw ir()}n.push(e)},Oi=(t,e)=>{let n=0,r=t.length-1,i=t[r],o=i.id.clock;if(o===e)return r;let s=Mi(e/(o+i.length-1)*r);for(;n<=r;){if(i=t[s],o=i.id.clock,o<=e){if(e<o+i.length)return s;n=s+1}else r=s-1;s=Mi((n+r)/2)}throw ir()},i9=(t,e)=>{const n=t.clients.get(e.client);return n[Oi(n,e.clock)]},bl=i9,dv=(t,e,n)=>{const r=Oi(e,n),i=e[r];return i.id.clock<n&&i instanceof Qt?(e.splice(r+1,0,Ph(t,i,n-i.id.clock)),r+1):r},Cr=(t,e)=>{const n=t.doc.store.clients.get(e.client);return n[dv(t,n,e.clock)]},Jw=(t,e,n)=>{const r=e.clients.get(n.client),i=Oi(r,n.clock),o=r[i];return n.clock!==o.id.clock+o.length-1&&o.constructor!==oi&&r.splice(i+1,0,Ph(t,o,n.clock-o.id.clock+1)),o},o9=(t,e,n)=>{const r=t.clients.get(e.id.client);r[Oi(r,e.id.clock)]=n},v3=(t,e,n,r,i)=>{if(r===0)return;const o=n+r;let s=dv(t,e,n),a;do a=e[s++],o<a.id.clock+a.length&&dv(t,e,o),i(a);while(s<e.length&&e[s].id.clock<o)};class s9{constructor(e,n,r){this.doc=e,this.deleteSet=new mc,this.beforeState=Ad(e.store),this.afterState=new Map,this.changed=new Map,this.changedParentTypes=new Map,this._mergeStructs=[],this.origin=n,this.meta=new Map,this.local=r,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}}const Xw=(t,e)=>e.deleteSet.clients.size===0&&!BI(e.afterState,(n,r)=>e.beforeState.get(r)!==n)?!1:(Jb(e.deleteSet),qN(t,e),vc(t,e.deleteSet),!0),Qw=(t,e,n)=>{const r=e._item;(r===null||r.id.clock<(t.beforeState.get(r.id.client)||0)&&!r.deleted)&&co(t.changed,e,Ma).add(n)},Gf=(t,e)=>{let n=t[e],r=t[e-1],i=e;for(;i>0;n=r,r=t[--i-1]){if(r.deleted===n.deleted&&r.constructor===n.constructor&&r.mergeWith(n)){n instanceof Qt&&n.parentSub!==null&&n.parent._map.get(n.parentSub)===n&&n.parent._map.set(n.parentSub,r);continue}break}const o=e-i;return o&&t.splice(e+1-o,o),o},a9=(t,e,n)=>{for(const[r,i]of t.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=Oi(o,a.clock),u=o[c];c<o.length&&u.id.clock<l;u=o[++c]){const f=o[c];if(a.clock+a.len<=f.id.clock)break;f instanceof Qt&&f.deleted&&!f.keep&&n(f)&&f.gc(e,!1)}}}},l9=(t,e)=>{t.clients.forEach((n,r)=>{const i=e.clients.get(r);for(let o=n.length-1;o>=0;o--){const s=n[o],a=Ro(i.length-1,1+Oi(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+Gf(i,l)}})},b3=(t,e)=>{if(e<t.length){const n=t[e],r=n.doc,i=r.store,o=n.deleteSet,s=n._mergeStructs;try{Jb(o),n.afterState=Ad(n.doc.store),r.emit("beforeObserverCalls",[n,r]);const a=[];n.changed.forEach((l,c)=>a.push(()=>{(c._item===null||!c._item.deleted)&&c._callObserver(n,l)})),a.push(()=>{n.changedParentTypes.forEach((l,c)=>{c._dEH.l.length>0&&(c._item===null||!c._item.deleted)&&(l=l.filter(u=>u.target._item===null||!u.target._item.deleted),l.forEach(u=>{u.currentTarget=c,u._path=null}),l.sort((u,f)=>u.path.length-f.path.length),a.push(()=>{h3(c._dEH,l,n)}))}),a.push(()=>r.emit("afterTransaction",[n,r])),a.push(()=>{n._needFormattingCleanup&&M9(n)})}),jb(a,[])}finally{r.gc&&a9(o,i,r.gcFilter),l9(o,i),n.afterState.forEach((u,f)=>{const h=n.beforeState.get(f)||0;if(h!==u){const p=i.clients.get(f),m=Di(Oi(p,h),1);for(let v=p.length-1;v>=m;)v-=1+Gf(p,v)}});for(let u=s.length-1;u>=0;u--){const{client:f,clock:h}=s[u].id,p=i.clients.get(f),m=Oi(p,h);m+1<p.length&&Gf(p,m+1)>1||m>0&&Gf(p,m)}if(!n.local&&n.afterState.get(r.clientID)!==n.beforeState.get(r.clientID)&&(FN(Yb,XS,"[yjs] ",QS,$S,"Changed the client-id because another client seems to be using it."),r.clientID=s3()),r.emit("afterTransactionCleanup",[n,r]),r._observers.has("update")){const u=new Ed;Xw(u,n)&&r.emit("update",[u.toUint8Array(),n.origin,r,n])}if(r._observers.has("updateV2")){const u=new Da;Xw(u,n)&&r.emit("updateV2",[u.toUint8Array(),n.origin,r,n])}const{subdocsAdded:a,subdocsLoaded:l,subdocsRemoved:c}=n;(a.size>0||c.size>0||l.size>0)&&(a.forEach(u=>{u.clientID=r.clientID,u.collectionid==null&&(u.collectionid=r.collectionid),r.subdocs.add(u)}),c.forEach(u=>r.subdocs.delete(u)),r.emit("subdocs",[{loaded:l,added:a,removed:c},r,n]),c.forEach(u=>u.destroy())),t.length<=e+1?(r._transactionCleanups=[],r.emit("afterAllTransactions",[r,t])):b3(t,e+1)}}},Yt=(t,e,n=null,r=!0)=>{const i=t._transactionCleanups;let o=!1,s=null;t._transaction===null&&(o=!0,t._transaction=new s9(t,n,r),i.push(t._transaction),i.length===1&&t.emit("beforeAllTransactions",[t]),t.emit("beforeTransaction",[t._transaction,t]));try{s=e(t._transaction)}finally{if(o){const a=t._transaction===i[0];t._transaction=null,a&&b3(i,0)}}return s};class c9{constructor(e,n){this.insertions=n,this.deletions=e,this.meta=new Map}}const $w=(t,e,n)=>{Os(t,n.deletions,r=>{r instanceof Qt&&e.scope.some(i=>i===t.doc||Fu(i,r))&&a1(r,!1)})},ex=(t,e,n)=>{let r=null;const i=t.doc,o=t.scope;Yt(i,a=>{for(;e.length>0&&t.currStackItem===null;){const l=i.store,c=e.pop(),u=new Set,f=[];let h=!1;Os(a,c.insertions,p=>{if(p instanceof Qt){if(p.redone!==null){let{item:m,diff:v}=hv(l,p.id);v>0&&(m=Cr(a,bt(m.id.client,m.id.clock+v))),p=m}!p.deleted&&o.some(m=>m===a.doc||Fu(m,p))&&f.push(p)}}),Os(a,c.deletions,p=>{p instanceof Qt&&o.some(m=>m===a.doc||Fu(m,p))&&!gc(c.insertions,p.id)&&u.add(p)}),u.forEach(p=>{h=z3(a,p,u,c.insertions,t.ignoreRemoteMapChanges,t)!==null||h});for(let p=f.length-1;p>=0;p--){const m=f[p];t.deleteFilter(m)&&(m.delete(a),h=!0)}t.currStackItem=h?c:null}a.changed.forEach((l,c)=>{l.has(null)&&c._searchMarker&&(c._searchMarker.length=0)}),r=a},t);const s=t.currStackItem;if(s!=null){const a=r.changedParentTypes;t.emit("stack-item-popped",[{stackItem:s,type:n,changedParentTypes:a,origin:t},t]),t.currStackItem=null}return s};class y3 extends kS{constructor(e,{captureTimeout:n=500,captureTransaction:r=l=>!0,deleteFilter:i=()=>!0,trackedOrigins:o=new Set([null]),ignoreRemoteMapChanges:s=!1,doc:a=Kl(e)?e[0].doc:e instanceof oo?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=n,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,u=this.redoing,f=c?this.redoStack:this.undoStack;c?this.stopCapturing():u||this.clear(!1,!0);const h=new mc;l.afterState.forEach((g,b)=>{const _=l.beforeState.get(b)||0,k=g-_;k>0&&Pu(h,b,_,k)});const p=CR();let m=!1;if(this.lastChange>0&&p-this.lastChange<this.captureTimeout&&f.length>0&&!c&&!u){const g=f[f.length-1];g.deletions=lv([g.deletions,l.deleteSet]),g.insertions=lv([g.insertions,h])}else f.push(new c9(l.deleteSet,h)),m=!0;!c&&!u&&(this.lastChange=p),Os(l,l.deleteSet,g=>{g instanceof Qt&&this.scope.some(b=>b===l.doc||Fu(b,g))&&a1(g,!0)});const v=[{stackItem:f[f.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 n=new Set(this.scope);e=Kl(e)?e:[e],e.forEach(r=>{n.has(r)||(n.add(r),(r instanceof Vn?r.doc!==this.doc:r!==this.doc)&&t3("[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,n=!0){(e&&this.canUndo()||n&&this.canRedo())&&this.doc.transact(r=>{e&&(this.undoStack.forEach(i=>$w(r,this,i)),this.undoStack=[]),n&&(this.redoStack.forEach(i=>$w(r,this,i)),this.redoStack=[]),this.emit("stack-cleared",[{undoStackCleared:e,redoStackCleared:n}])})}stopCapturing(){this.lastChange=0}undo(){this.undoing=!0;let e;try{e=ex(this,this.undoStack,"undo")}finally{this.undoing=!1}return e}redo(){this.redoing=!0;let e;try{e=ex(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*u9(t){const e=Et(t.restDecoder);for(let n=0;n<e;n++){const r=Et(t.restDecoder),i=t.readClient();let o=Et(t.restDecoder);for(let s=0;s<r;s++){const a=t.readInfo();if(a===10){const l=Et(t.restDecoder);yield new si(bt(i,o),l),o+=l}else if((Yp&a)!==0){const l=(a&(No|vr))===0,c=new Qt(bt(i,o),null,(a&vr)===vr?t.readLeftID():null,null,(a&No)===No?t.readRightID():null,l?t.readParentInfo()?t.readString():t.readLeftID():null,l&&(a&Du)===Du?t.readString():null,B3(t,a));yield c,o+=c.length}else{const l=t.readLen();yield new oi(bt(i,o),l),o+=l}}}}class e1{constructor(e,n){this.gen=u9(e),this.curr=null,this.done=!1,this.filterSkips=n,this.next()}next(){do this.curr=this.gen.next().value||null;while(this.filterSkips&&this.curr!==null&&this.curr.constructor===si);return this.curr}}class t1{constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}}const d9=t=>Dh(t,l3,Ed),f9=(t,e)=>{if(t.constructor===oi){const{client:n,clock:r}=t.id;return new oi(bt(n,r+e),t.length-e)}else if(t.constructor===si){const{client:n,clock:r}=t.id;return new si(bt(n,r+e),t.length-e)}else{const n=t,{client:r,clock:i}=n.id;return new Qt(bt(r,i+e),null,bt(r,i+e-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(e))}},Dh=(t,e=Xl,n=Da)=>{if(t.length===1)return t[0];const r=t.map(u=>new e(fc(u)));let i=r.map(u=>new e1(u,!0)),o=null;const s=new n,a=new t1(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===si?1:-1:m}else return p.curr.id.client-h.curr.id.client}),i.length!==0;){const u=i[0],f=u.curr.id.client;if(o!==null){let h=u.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=u.next(),p=!0;if(h===null||h.id.client!==f||p&&h.id.clock>o.struct.id.clock+o.struct.length)continue;if(f!==o.struct.id.client)is(a,o.struct,o.offset),o={struct:h,offset:0},u.next();else if(o.struct.id.clock+o.struct.length<h.id.clock)if(o.struct.constructor===si)o.struct.length=h.id.clock+h.length-o.struct.id.clock;else{is(a,o.struct,o.offset);const m=h.id.clock-o.struct.id.clock-o.struct.length;o={struct:new si(bt(f,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===si?o.struct.length-=m:h=f9(h,m)),o.struct.mergeWith(h)||(is(a,o.struct,o.offset),o={struct:h,offset:0},u.next())}}else o={struct:u.curr,offset:0},u.next();for(let h=u.curr;h!==null&&h.id.client===f&&h.id.clock===o.struct.id.clock+o.struct.length&&h.constructor!==si;h=u.next())is(a,o.struct,o.offset),o={struct:h,offset:0}}o!==null&&(is(a,o.struct,o.offset),o=null),n1(a);const l=r.map(u=>Xb(u)),c=lv(l);return vc(s,c),s.toUint8Array()},h9=(t,e,n=Xl,r=Da)=>{const i=d3(e),o=new r,s=new t1(o),a=new n(fc(t)),l=new e1(a,!1);for(;l.curr;){const u=l.curr,f=u.id.client,h=i.get(f)||0;if(l.curr.constructor===si){l.next();continue}if(u.id.clock+u.length>h)for(is(s,u,Di(h-u.id.clock,0)),l.next();l.curr&&l.curr.id.client===f;)is(s,l.curr,0),l.next();else for(;l.curr&&l.curr.id.client===f&&l.curr.id.clock+l.curr.length<=h;)l.next()}n1(s);const c=Xb(a);return vc(o,c),o.toUint8Array()},w3=t=>{t.written>0&&(t.clientStructs.push({written:t.written,restEncoder:Si(t.encoder.restEncoder)}),t.encoder.restEncoder=Cd(),t.written=0)},is=(t,e,n)=>{t.written>0&&t.currClient!==e.id.client&&w3(t),t.written===0&&(t.currClient=e.id.client,t.encoder.writeClient(e.id.client),Ot(t.encoder.restEncoder,e.id.clock+n)),e.write(t.encoder,n),t.written++},n1=t=>{w3(t);const e=t.encoder.restEncoder;Ot(e,t.clientStructs.length);for(let n=0;n<t.clientStructs.length;n++){const r=t.clientStructs[n];Ot(e,r.written),Jp(e,r.restEncoder)}},p9=(t,e,n,r)=>{const i=new n(fc(t)),o=new e1(i,!1),s=new r,a=new t1(s);for(let c=o.curr;c!==null;c=o.next())is(a,e(c),0);n1(a);const l=Xb(i);return vc(s,l),s.toUint8Array()},m9=t=>p9(t,NR,Xl,Ed),tx="You must not compute changes after the event-handler fired.";class im{constructor(e,n){this.target=e,this.currentTarget=e,this.transaction=n,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||(this._path=g9(this.currentTarget,this.target))}deletes(e){return gc(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw io(tx);const e=new Map,n=this.target;this.transaction.changed.get(n).forEach(i=>{if(i!==null){const o=n._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=ag(l.content.getContent());else return;else l!==null&&this.deletes(l)?(s="update",a=ag(l.content.getContent())):(s="add",a=void 0)}else if(this.deletes(o))s="delete",a=ag(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 io(tx);const n=this.target,r=Ma(),i=Ma(),o=[];if(e={added:r,deleted:i,delta:o,keys:this.keys},this.transaction.changed.get(n).has(null)){let a=null;const l=()=>{a&&o.push(a)};for(let c=n._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 g9=(t,e)=>{const n=[];for(;e._item!==null&&e!==t;){if(e._item.parentSub!==null)n.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;n.unshift(r)}e=e._item.parent}return n},nr=()=>{t3("Invalid access: Add Yjs type to a document before reading data.")},x3=80;let r1=0;class v9{constructor(e,n){e.marker=!0,this.p=e,this.index=n,this.timestamp=r1++}}const b9=t=>{t.timestamp=r1++},k3=(t,e,n)=>{t.p.marker=!1,t.p=e,e.marker=!0,t.index=n,t.timestamp=r1++},y9=(t,e,n)=>{if(t.length>=x3){const r=t.reduce((i,o)=>i.timestamp<o.timestamp?i:o);return k3(r,e,n),r}else{const r=new v9(e,n);return t.push(r),r}},om=(t,e)=>{if(t._start===null||e===0||t._searchMarker===null)return null;const n=t._searchMarker.length===0?null:t._searchMarker.reduce((o,s)=>jf(e-o.index)<jf(e-s.index)?o:s);let r=t._start,i=0;for(n!==null&&(r=n.p,i=n.index,b9(n));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 n!==null&&jf(n.index-i)<r.parent.length/x3?(k3(n,r,i),n):y9(t._searchMarker,r,i)},Bu=(t,e,n)=>{for(let r=t.length-1;r>=0;r--){const i=t[r];if(n>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){t.splice(r,1);continue}i.p=o,o.marker=!0}(e<i.index||n>0&&e===i.index)&&(i.index=Di(e,i.index+n))}},sm=(t,e,n)=>{const r=t,i=e.changedParentTypes;for(;co(i,t,()=>[]).push(n),t._item!==null;)t=t._item.parent;h3(r._eH,n,e)};class Vn{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=Kw(),this._dEH=Kw(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,n){this.doc=e,this._item=n}_copy(){throw hi()}clone(){throw hi()}_write(e){}get _first(){let e=this._start;for(;e!==null&&e.deleted;)e=e.right;return e}_callObserver(e,n){!e.local&&this._searchMarker&&(this._searchMarker.length=0)}observe(e){Gw(this._eH,e)}observeDeep(e){Gw(this._dEH,e)}unobserve(e){Zw(this._eH,e)}unobserveDeep(e){Zw(this._dEH,e)}toJSON(){}}const _3=(t,e,n)=>{t.doc??nr(),e<0&&(e=t._length+e),n<0&&(n=t._length+n);let r=n-e;const i=[];let o=t._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},C3=t=>{t.doc??nr();const e=[];let n=t._start;for(;n!==null;){if(n.countable&&!n.deleted){const r=n.content.getContent();for(let i=0;i<r.length;i++)e.push(r[i])}n=n.right}return e},S3=(t,e)=>{const n=[];let r=t._start;for(;r!==null;){if(r.countable&&Ys(r,e)){const i=r.content.getContent();for(let o=0;o<i.length;o++)n.push(i[o])}r=r.right}return n},Hu=(t,e)=>{let n=0,r=t._start;for(t.doc??nr();r!==null;){if(r.countable&&!r.deleted){const i=r.content.getContent();for(let o=0;o<i.length;o++)e(i[o],n++,t)}r=r.right}},E3=(t,e)=>{const n=[];return Hu(t,(r,i)=>{n.push(e(r,i,t))}),n},w9=t=>{let e=t._start,n=null,r=0;return{[Symbol.iterator](){return this},next:()=>{if(n===null){for(;e!==null&&e.deleted;)e=e.right;if(e===null)return{done:!0,value:void 0};n=e.content.getContent(),r=0,e=e.right}const i=n[r++];return n.length<=r&&(n=null),{done:!1,value:i}}}},A3=(t,e)=>{t.doc??nr();const n=om(t,e);let r=t._start;for(n!==null&&(r=n.p,e-=n.index);r!==null;r=r.right)if(!r.deleted&&r.countable){if(e<r.length)return r.content.getContent()[e];e-=r.length}},Oh=(t,e,n,r)=>{let i=n;const o=t.doc,s=o.clientID,a=o.store,l=n===null?e._start:n.right;let c=[];const u=()=>{c.length>0&&(i=new Qt(bt(s,bn(a,s)),i,i&&i.lastId,l,l&&l.id,e,null,new Ia(c)),i.integrate(t,0),c=[])};r.forEach(f=>{if(f===null)c.push(f);else switch(f.constructor){case Number:case Object:case Boolean:case Array:case String:c.push(f);break;default:switch(u(),f.constructor){case Uint8Array:case ArrayBuffer:i=new Qt(bt(s,bn(a,s)),i,i&&i.lastId,l,l&&l.id,e,null,new Td(new Uint8Array(f))),i.integrate(t,0);break;case oo:i=new Qt(bt(s,bn(a,s)),i,i&&i.lastId,l,l&&l.id,e,null,new Md(f)),i.integrate(t,0);break;default:if(f instanceof Vn)i=new Qt(bt(s,bn(a,s)),i,i&&i.lastId,l,l&&l.id,e,null,new Ni(f)),i.integrate(t,0);else throw new Error("Unexpected content type in insert operation")}}}),u()},T3=()=>io("Length exceeded!"),M3=(t,e,n,r)=>{if(n>e._length)throw T3();if(n===0)return e._searchMarker&&Bu(e._searchMarker,n,r.length),Oh(t,e,null,r);const i=n,o=om(e,n);let s=e._start;for(o!==null&&(s=o.p,n-=o.index,n===0&&(s=s.prev,n+=s&&s.countable&&!s.deleted?s.length:0));s!==null;s=s.right)if(!s.deleted&&s.countable){if(n<=s.length){n<s.length&&Cr(t,bt(s.id.client,s.id.clock+n));break}n-=s.length}return e._searchMarker&&Bu(e._searchMarker,i,r.length),Oh(t,e,s,r)},x9=(t,e,n)=>{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 Oh(t,e,i,n)},D3=(t,e,n,r)=>{if(r===0)return;const i=n,o=r,s=om(e,n);let a=e._start;for(s!==null&&(a=s.p,n-=s.index);a!==null&&n>0;a=a.right)!a.deleted&&a.countable&&(n<a.length&&Cr(t,bt(a.id.client,a.id.clock+n)),n-=a.length);for(;r>0&&a!==null;)a.deleted||(r<a.length&&Cr(t,bt(a.id.client,a.id.clock+r)),a.delete(t),r-=a.length),a=a.right;if(r>0)throw T3();e._searchMarker&&Bu(e._searchMarker,i,-o+r)},Ih=(t,e,n)=>{const r=e._map.get(n);r!==void 0&&r.delete(t)},i1=(t,e,n,r)=>{const i=e._map.get(n)||null,o=t.doc,s=o.clientID;let a;if(r==null)a=new Ia([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:a=new Ia([r]);break;case Uint8Array:a=new Td(r);break;case oo:a=new Md(r);break;default:if(r instanceof Vn)a=new Ni(r);else throw new Error("Unexpected content type")}new Qt(bt(s,bn(o.store,s)),i,i&&i.lastId,null,null,e,n,a).integrate(t,0)},o1=(t,e)=>{t.doc??nr();const n=t._map.get(e);return n!==void 0&&!n.deleted?n.content.getContent()[n.length-1]:void 0},O3=t=>{const e={};return t.doc??nr(),t._map.forEach((n,r)=>{n.deleted||(e[r]=n.content.getContent()[n.length-1])}),e},I3=(t,e)=>{t.doc??nr();const n=t._map.get(e);return n!==void 0&&!n.deleted},k9=(t,e)=>{const n={};return t._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&&Ys(o,e)&&(n[i]=o.content.getContent()[o.length-1])}),n},ef=t=>(t.doc??nr(),zN(t._map.entries(),e=>!e[1].deleted));class _9 extends im{}class yl extends Vn{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(e){const n=new yl;return n.push(e),n}_integrate(e,n){super._integrate(e,n),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new yl}clone(){const e=new yl;return e.insert(0,this.toArray().map(n=>n instanceof Vn?n.clone():n)),e}get length(){return this.doc??nr(),this._length}_callObserver(e,n){super._callObserver(e,n),sm(this,e,new _9(this,e))}insert(e,n){this.doc!==null?Yt(this.doc,r=>{M3(r,this,e,n)}):this._prelimContent.splice(e,0,...n)}push(e){this.doc!==null?Yt(this.doc,n=>{x9(n,this,e)}):this._prelimContent.push(...e)}unshift(e){this.insert(0,e)}delete(e,n=1){this.doc!==null?Yt(this.doc,r=>{D3(r,this,e,n)}):this._prelimContent.splice(e,n)}get(e){return A3(this,e)}toArray(){return C3(this)}slice(e=0,n=this.length){return _3(this,e,n)}toJSON(){return this.map(e=>e instanceof Vn?e.toJSON():e)}map(e){return E3(this,e)}forEach(e){Hu(this,e)}[Symbol.iterator](){return w9(this)}_write(e){e.writeTypeRef(Z9)}}const C9=t=>new yl;class S9 extends im{constructor(e,n,r){super(e,n),this.keysChanged=r}}class Ql extends Vn{constructor(e){super(),this._prelimContent=null,e===void 0?this._prelimContent=new Map:this._prelimContent=new Map(e)}_integrate(e,n){super._integrate(e,n),this._prelimContent.forEach((r,i)=>{this.set(i,r)}),this._prelimContent=null}_copy(){return new Ql}clone(){const e=new Ql;return this.forEach((n,r)=>{e.set(r,n instanceof Vn?n.clone():n)}),e}_callObserver(e,n){sm(this,e,new S9(this,e,n))}toJSON(){this.doc??nr();const e={};return this._map.forEach((n,r)=>{if(!n.deleted){const i=n.content.getContent()[n.length-1];e[r]=i instanceof Vn?i.toJSON():i}}),e}get size(){return[...ef(this)].length}keys(){return pg(ef(this),e=>e[0])}values(){return pg(ef(this),e=>e[1].content.getContent()[e[1].length-1])}entries(){return pg(ef(this),e=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){this.doc??nr(),this._map.forEach((n,r)=>{n.deleted||e(n.content.getContent()[n.length-1],r,this)})}[Symbol.iterator](){return this.entries()}delete(e){this.doc!==null?Yt(this.doc,n=>{Ih(n,this,e)}):this._prelimContent.delete(e)}set(e,n){return this.doc!==null?Yt(this.doc,r=>{i1(r,this,e,n)}):this._prelimContent.set(e,n),n}get(e){return o1(this,e)}has(e){return I3(this,e)}clear(){this.doc!==null?Yt(this.doc,e=>{this.forEach(function(n,r,i){Ih(e,i,r)})}):this._prelimContent.clear()}_write(e){e.writeTypeRef(Y9)}}const E9=t=>new Ql,vs=(t,e)=>t===e||typeof t=="object"&&typeof e=="object"&&t&&e&&IR(t,e);class fv{constructor(e,n,r,i){this.left=e,this.right=n,this.index=r,this.currentAttributes=i}forward(){switch(this.right===null&&ir(),this.right.content.constructor){case _n:this.right.deleted||bc(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 nx=(t,e,n)=>{for(;e.right!==null&&n>0;){switch(e.right.content.constructor){case _n:e.right.deleted||bc(e.currentAttributes,e.right.content);break;default:e.right.deleted||(n<e.right.length&&Cr(t,bt(e.right.id.client,e.right.id.clock+n)),e.index+=e.right.length,n-=e.right.length);break}e.left=e.right,e.right=e.right.right}return e},tf=(t,e,n,r)=>{const i=new Map,o=r?om(e,n):null;if(o){const s=new fv(o.p.left,o.p,o.index,i);return nx(t,s,n-o.index)}else{const s=new fv(null,e._start,0,i);return nx(t,s,n)}},R3=(t,e,n,r)=>{for(;n.right!==null&&(n.right.deleted===!0||n.right.content.constructor===_n&&vs(r.get(n.right.content.key),n.right.content.value));)n.right.deleted||r.delete(n.right.content.key),n.forward();const i=t.doc,o=i.clientID;r.forEach((s,a)=>{const l=n.left,c=n.right,u=new Qt(bt(o,bn(i.store,o)),l,l&&l.lastId,c,c&&c.id,e,null,new _n(a,s));u.integrate(t,0),n.right=u,n.forward()})},bc=(t,e)=>{const{key:n,value:r}=e;r===null?t.delete(n):t.set(n,r)},N3=(t,e)=>{for(;t.right!==null;){if(!(t.right.deleted||t.right.content.constructor===_n&&vs(e[t.right.content.key]??null,t.right.content.value)))break;t.forward()}},P3=(t,e,n,r)=>{const i=t.doc,o=i.clientID,s=new Map;for(const a in r){const l=r[a],c=n.currentAttributes.get(a)??null;if(!vs(c,l)){s.set(a,c);const{left:u,right:f}=n;n.right=new Qt(bt(o,bn(i.store,o)),u,u&&u.lastId,f,f&&f.id,e,null,new _n(a,l)),n.right.integrate(t,0),n.forward()}}return s},vg=(t,e,n,r,i)=>{n.currentAttributes.forEach((h,p)=>{i[p]===void 0&&(i[p]=null)});const o=t.doc,s=o.clientID;N3(n,i);const a=P3(t,e,n,i),l=r.constructor===String?new Ii(r):r instanceof Vn?new Ni(r):new ja(r);let{left:c,right:u,index:f}=n;e._searchMarker&&Bu(e._searchMarker,n.index,l.getLength()),u=new Qt(bt(s,bn(o.store,s)),c,c&&c.lastId,u,u&&u.id,e,null,l),u.integrate(t,0),n.right=u,n.index=f,n.forward(),R3(t,e,n,a)},rx=(t,e,n,r,i)=>{const o=t.doc,s=o.clientID;N3(n,i);const a=P3(t,e,n,i);e:for(;n.right!==null&&(r>0||a.size>0&&(n.right.deleted||n.right.content.constructor===_n));){if(!n.right.deleted)switch(n.right.content.constructor){case _n:{const{key:l,value:c}=n.right.content,u=i[l];if(u!==void 0){if(vs(u,c))a.delete(l);else{if(r===0)break e;a.set(l,c)}n.right.delete(t)}else n.currentAttributes.set(l,c);break}default:r<n.right.length&&Cr(t,bt(n.right.id.client,n.right.id.clock+r)),r-=n.right.length;break}n.forward()}if(r>0){let l="";for(;r>0;r--)l+=`
58
+ `;n.right=new Qt(bt(s,bn(o.store,s)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,e,null,new Ii(l)),n.right.integrate(t,0),n.forward()}R3(t,e,n,a)},L3=(t,e,n,r,i)=>{let o=e;const s=fi();for(;o&&(!o.countable||o.deleted);){if(!o.deleted&&o.content.constructor===_n){const c=o.content;s.set(c.key,c)}o=o.right}let a=0,l=!1;for(;e!==o;){if(n===e&&(l=!0),!e.deleted){const c=e.content;switch(c.constructor){case _n:{const{key:u,value:f}=c,h=r.get(u)??null;(s.get(u)!==c||h===f)&&(e.delete(t),a++,!l&&(i.get(u)??null)===f&&h!==f&&(h===null?i.delete(u):i.set(u,h))),!l&&!e.deleted&&bc(i,c);break}}}e=e.right}return a},A9=(t,e)=>{for(;e&&e.right&&(e.right.deleted||!e.right.countable);)e=e.right;const n=new Set;for(;e&&(e.deleted||!e.countable);){if(!e.deleted&&e.content.constructor===_n){const r=e.content.key;n.has(r)?e.delete(t):n.add(r)}e=e.left}},T9=t=>{let e=0;return Yt(t.doc,n=>{let r=t._start,i=t._start,o=fi();const s=nv(o);for(;i;){if(i.deleted===!1)switch(i.content.constructor){case _n:bc(s,i.content);break;default:e+=L3(n,r,i,o,s),o=nv(s),r=i;break}i=i.right}}),e},M9=t=>{const e=new Set,n=t.doc;for(const[r,i]of t.afterState.entries()){const o=t.beforeState.get(r)||0;i!==o&&v3(t,n.store.clients.get(r),o,i,s=>{!s.deleted&&s.content.constructor===_n&&s.constructor!==oi&&e.add(s.parent)})}Yt(n,r=>{Os(t,t.deleteSet,i=>{if(i instanceof oi||!i.parent._hasFormatting||e.has(i.parent))return;const o=i.parent;i.content.constructor===_n?e.add(o):A9(r,i)});for(const i of e)T9(i)})},ix=(t,e,n)=>{const r=n,i=nv(e.currentAttributes),o=e.right;for(;n>0&&e.right!==null;){if(e.right.deleted===!1)switch(e.right.content.constructor){case Ni:case ja:case Ii:n<e.right.length&&Cr(t,bt(e.right.id.client,e.right.id.clock+n)),n-=e.right.length,e.right.delete(t);break}e.forward()}o&&L3(t,o,e.right,i,e.currentAttributes);const s=(e.left||e.right).parent;return s._searchMarker&&Bu(s._searchMarker,e.index,-r+n),e};class D9 extends im{constructor(e,n,r){super(e,n),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,n=[];Yt(e,r=>{const i=new Map,o=new Map;let s=this.target._start,a=null;const l={};let c="",u=0,f=0;const h=()=>{if(a!==null){let p=null;switch(a){case"delete":f>0&&(p={delete:f}),f=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":u>0&&(p={retain:u},OR(l)||(p.attributes=MR({},l))),u=0;break}p&&n.push(p),a=null}};for(;s!==null;){switch(s.content.constructor){case Ni:case ja:this.adds(s)?this.deletes(s)||(h(),a="insert",c=s.content.getContent()[0],h()):this.deletes(s)?(a!=="delete"&&(h(),a="delete"),f+=1):s.deleted||(a!=="retain"&&(h(),a="retain"),u+=1);break;case Ii:this.adds(s)?this.deletes(s)||(a!=="insert"&&(h(),a="insert"),c+=s.content.str):this.deletes(s)?(a!=="delete"&&(h(),a="delete"),f+=s.length):s.deleted||(a!=="retain"&&(h(),a="retain"),u+=s.length);break;case _n:{const{key:p,value:m}=s.content;if(this.adds(s)){if(!this.deletes(s)){const v=i.get(p)??null;vs(v,m)?m!==null&&s.delete(r):(a==="retain"&&h(),vs(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;vs(v,m)||(a==="retain"&&h(),l[p]=v)}else if(!s.deleted){o.set(p,m);const v=l[p];v!==void 0&&(vs(v,m)?v!==null&&s.delete(r):(a==="retain"&&h(),m===null?delete l[p]:l[p]=m))}s.deleted||(a==="insert"&&h(),bc(i,s.content));break}}s=s.right}for(h();n.length>0;){const p=n[n.length-1];if(p.retain!==void 0&&p.attributes===void 0)n.pop();else break}}),this._delta=n}return this._delta}}class Is extends Vn{constructor(e){super(),this._pending=e!==void 0?[()=>this.insert(0,e)]:[],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??nr(),this._length}_integrate(e,n){super._integrate(e,n);try{this._pending.forEach(r=>r())}catch(r){console.error(r)}this._pending=null}_copy(){return new Is}clone(){const e=new Is;return e.applyDelta(this.toDelta()),e}_callObserver(e,n){super._callObserver(e,n);const r=new D9(this,e,n);sm(this,e,r),!e.local&&this._hasFormatting&&(e._needFormattingCleanup=!0)}toString(){this.doc??nr();let e="",n=this._start;for(;n!==null;)!n.deleted&&n.countable&&n.content.constructor===Ii&&(e+=n.content.str),n=n.right;return e}toJSON(){return this.toString()}applyDelta(e,{sanitize:n=!0}={}){this.doc!==null?Yt(this.doc,r=>{const i=new fv(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=!n&&typeof s.insert=="string"&&o===e.length-1&&i.right===null&&s.insert.slice(-1)===`
59
+ `?s.insert.slice(0,-1):s.insert;(typeof a!="string"||a.length>0)&&vg(r,this,i,a,s.attributes||{})}else s.retain!==void 0?rx(r,this,i,s.retain,s.attributes||{}):s.delete!==void 0&&ix(r,i,s.delete)}}):this._pending.push(()=>this.applyDelta(e))}toDelta(e,n,r){this.doc??nr();const i=[],o=new Map,s=this.doc;let a="",l=this._start;function c(){if(a.length>0){const f={};let h=!1;o.forEach((m,v)=>{h=!0,f[v]=m});const p={insert:a};h&&(p.attributes=f),i.push(p),a=""}}const u=()=>{for(;l!==null;){if(Ys(l,e)||n!==void 0&&Ys(l,n))switch(l.content.constructor){case Ii:{const f=o.get("ychange");e!==void 0&&!Ys(l,e)?(f===void 0||f.user!==l.id.client||f.type!=="removed")&&(c(),o.set("ychange",r?r("removed",l.id):{type:"removed"})):n!==void 0&&!Ys(l,n)?(f===void 0||f.user!==l.id.client||f.type!=="added")&&(c(),o.set("ychange",r?r("added",l.id):{type:"added"})):f!==void 0&&(c(),o.delete("ychange")),a+=l.content.str;break}case Ni:case ja:{c();const f={insert:l.content.getContent()[0]};if(o.size>0){const h={};f.attributes=h,o.forEach((p,m)=>{h[m]=p})}i.push(f);break}case _n:Ys(l,e)&&(c(),bc(o,l.content));break}l=l.right}c()};return e||n?Yt(s,f=>{e&&uv(f,e),n&&uv(f,n),u()},"cleanup"):u(),i}insert(e,n,r){if(n.length<=0)return;const i=this.doc;i!==null?Yt(i,o=>{const s=tf(o,this,e,!r);r||(r={},s.currentAttributes.forEach((a,l)=>{r[l]=a})),vg(o,this,s,n,r)}):this._pending.push(()=>this.insert(e,n,r))}insertEmbed(e,n,r){const i=this.doc;i!==null?Yt(i,o=>{const s=tf(o,this,e,!r);vg(o,this,s,n,r||{})}):this._pending.push(()=>this.insertEmbed(e,n,r||{}))}delete(e,n){if(n===0)return;const r=this.doc;r!==null?Yt(r,i=>{ix(i,tf(i,this,e,!0),n)}):this._pending.push(()=>this.delete(e,n))}format(e,n,r){if(n===0)return;const i=this.doc;i!==null?Yt(i,o=>{const s=tf(o,this,e,!1);s.right!==null&&rx(o,this,s,n,r)}):this._pending.push(()=>this.format(e,n,r))}removeAttribute(e){this.doc!==null?Yt(this.doc,n=>{Ih(n,this,e)}):this._pending.push(()=>this.removeAttribute(e))}setAttribute(e,n){this.doc!==null?Yt(this.doc,r=>{i1(r,this,e,n)}):this._pending.push(()=>this.setAttribute(e,n))}getAttribute(e){return o1(this,e)}getAttributes(){return O3(this)}_write(e){e.writeTypeRef(J9)}}const O9=t=>new Is;class bg{constructor(e,n=()=>!0){this._filter=n,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??nr()}[Symbol.iterator](){return this}next(){let e=this._currentNode,n=e&&e.content&&e.content.type;if(e!==null&&(!this._firstCall||e.deleted||!this._filter(n)))do if(n=e.content.type,!e.deleted&&(n.constructor===ln||n.constructor===Oa)&&n._start!==null)e=n._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 Oa extends Vn{constructor(){super(),this._prelimContent=[]}get firstChild(){const e=this._first;return e?e.content.getContent()[0]:null}_integrate(e,n){super._integrate(e,n),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new Oa}clone(){const e=new Oa;return e.insert(0,this.toArray().map(n=>n instanceof Vn?n.clone():n)),e}get length(){return this.doc??nr(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new bg(this,e)}querySelector(e){e=e.toUpperCase();const r=new bg(this,i=>i.nodeName&&i.nodeName.toUpperCase()===e).next();return r.done?null:r.value}querySelectorAll(e){return e=e.toUpperCase(),Ds(new bg(this,n=>n.nodeName&&n.nodeName.toUpperCase()===e))}_callObserver(e,n){sm(this,e,new N9(this,n,e))}toString(){return E3(this,e=>e.toString()).join("")}toJSON(){return this.toString()}toDOM(e=document,n={},r){const i=e.createDocumentFragment();return r!==void 0&&r._createAssociation(i,this),Hu(this,o=>{i.insertBefore(o.toDOM(e,n,r),null)}),i}insert(e,n){this.doc!==null?Yt(this.doc,r=>{M3(r,this,e,n)}):this._prelimContent.splice(e,0,...n)}insertAfter(e,n){if(this.doc!==null)Yt(this.doc,r=>{const i=e&&e instanceof Vn?e._item:e;Oh(r,this,i,n)});else{const r=this._prelimContent,i=e===null?0:r.findIndex(o=>o===e)+1;if(i===0&&e!==null)throw io("Reference item not found");r.splice(i,0,...n)}}delete(e,n=1){this.doc!==null?Yt(this.doc,r=>{D3(r,this,e,n)}):this._prelimContent.splice(e,n)}toArray(){return C3(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return A3(this,e)}slice(e=0,n=this.length){return _3(this,e,n)}forEach(e){Hu(this,e)}_write(e){e.writeTypeRef(Q9)}}const I9=t=>new Oa;class ln extends Oa{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,n){super._integrate(e,n),this._prelimAttrs.forEach((r,i)=>{this.setAttribute(i,r)}),this._prelimAttrs=null}_copy(){return new ln(this.nodeName)}clone(){const e=new ln(this.nodeName),n=this.getAttributes();return DR(n,(r,i)=>{e.setAttribute(i,r)}),e.insert(0,this.toArray().map(r=>r instanceof Vn?r.clone():r)),e}toString(){const e=this.getAttributes(),n=[],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];n.push(l+'="'+e[l]+'"')}const o=this.nodeName.toLocaleLowerCase(),s=n.length>0?" "+n.join(" "):"";return`<${o}${s}>${super.toString()}</${o}>`}removeAttribute(e){this.doc!==null?Yt(this.doc,n=>{Ih(n,this,e)}):this._prelimAttrs.delete(e)}setAttribute(e,n){this.doc!==null?Yt(this.doc,r=>{i1(r,this,e,n)}):this._prelimAttrs.set(e,n)}getAttribute(e){return o1(this,e)}hasAttribute(e){return I3(this,e)}getAttributes(e){return e?k9(this,e):O3(this)}toDOM(e=document,n={},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 Hu(this,s=>{i.appendChild(s.toDOM(e,n,r))}),r!==void 0&&r._createAssociation(i,this),i}_write(e){e.writeTypeRef(X9),e.writeKey(this.nodeName)}}const R9=t=>new ln(t.readKey());class N9 extends im{constructor(e,n,r){super(e,r),this.childListChanged=!1,this.attributesChanged=new Set,n.forEach(i=>{i===null?this.childListChanged=!0:this.attributesChanged.add(i)})}}class Rh extends Ql{constructor(e){super(),this.hookName=e}_copy(){return new Rh(this.hookName)}clone(){const e=new Rh(this.hookName);return this.forEach((n,r)=>{e.set(r,n)}),e}toDOM(e=document,n={},r){const i=n[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($9),e.writeKey(this.hookName)}}const P9=t=>new Rh(t.readKey());class kn extends Is{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 kn}clone(){const e=new kn;return e.applyDelta(this.toDelta()),e}toDOM(e=document,n,r){const i=e.createTextNode(this.toString());return r!==void 0&&r._createAssociation(i,this),i}toString(){return this.toDelta().map(e=>{const n=[];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),n.push({nodeName:i,attrs:o})}n.sort((i,o)=>i.nodeName<o.nodeName?-1:1);let r="";for(let i=0;i<n.length;i++){const o=n[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=n.length-1;i>=0;i--)r+=`</${n[i].nodeName}>`;return r}).join("")}toJSON(){return this.toString()}_write(e){e.writeTypeRef(eP)}}const L9=t=>new kn;class s1{constructor(e,n){this.id=e,this.length=n}get deleted(){throw hi()}mergeWith(e){return!1}write(e,n,r){throw hi()}integrate(e,n){throw hi()}}const F9=0;class oi extends s1{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,n){n>0&&(this.id.clock+=n,this.length-=n),g3(e.doc.store,this)}write(e,n){e.writeInfo(F9),e.writeLen(this.length-n)}getMissing(e,n){return null}}class Td{constructor(e){this.content=e}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new Td(this.content)}splice(e){throw hi()}mergeWith(e){return!1}integrate(e,n){}delete(e){}gc(e){}write(e,n){e.writeBuf(this.content)}getRef(){return 3}}const z9=t=>new Td(t.readBuf());class Vu{constructor(e){this.len=e}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new Vu(this.len)}splice(e){const n=new Vu(this.len-e);return this.len=e,n}mergeWith(e){return this.len+=e.len,!0}integrate(e,n){Pu(e.deleteSet,n.id.client,n.id.clock,this.len),n.markDeleted()}delete(e){}gc(e){}write(e,n){e.writeLen(this.len-n)}getRef(){return 1}}const B9=t=>new Vu(t.readLen()),F3=(t,e)=>new oo({guid:t,...e,shouldLoad:e.shouldLoad||e.autoLoad||!1});class Md{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 n={};this.opts=n,e.gc||(n.gc=!1),e.autoLoad&&(n.autoLoad=!0),e.meta!==null&&(n.meta=e.meta)}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new Md(F3(this.doc.guid,this.opts))}splice(e){throw hi()}mergeWith(e){return!1}integrate(e,n){this.doc._item=n,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,n){e.writeString(this.doc.guid),e.writeAny(this.opts)}getRef(){return 9}}const H9=t=>new Md(F3(t.readString(),t.readAny()));class ja{constructor(e){this.embed=e}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new ja(this.embed)}splice(e){throw hi()}mergeWith(e){return!1}integrate(e,n){}delete(e){}gc(e){}write(e,n){e.writeJSON(this.embed)}getRef(){return 5}}const V9=t=>new ja(t.readJSON());class _n{constructor(e,n){this.key=e,this.value=n}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new _n(this.key,this.value)}splice(e){throw hi()}mergeWith(e){return!1}integrate(e,n){const r=n.parent;r._searchMarker=null,r._hasFormatting=!0}delete(e){}gc(e){}write(e,n){e.writeKey(this.key),e.writeJSON(this.value)}getRef(){return 6}}const U9=t=>new _n(t.readKey(),t.readJSON());class Nh{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new Nh(this.arr)}splice(e){const n=new Nh(this.arr.slice(e));return this.arr=this.arr.slice(0,e),n}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,n){}delete(e){}gc(e){}write(e,n){const r=this.arr.length;e.writeLen(r-n);for(let i=n;i<r;i++){const o=this.arr[i];e.writeString(o===void 0?"undefined":JSON.stringify(o))}}getRef(){return 2}}const j9=t=>{const e=t.readLen(),n=[];for(let r=0;r<e;r++){const i=t.readString();i==="undefined"?n.push(void 0):n.push(JSON.parse(i))}return new Nh(n)},q9=Sh("node_env")==="development";class Ia{constructor(e){this.arr=e,q9&&OS(e)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new Ia(this.arr)}splice(e){const n=new Ia(this.arr.slice(e));return this.arr=this.arr.slice(0,e),n}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,n){}delete(e){}gc(e){}write(e,n){const r=this.arr.length;e.writeLen(r-n);for(let i=n;i<r;i++){const o=this.arr[i];e.writeAny(o)}}getRef(){return 8}}const W9=t=>{const e=t.readLen(),n=[];for(let r=0;r<e;r++)n.push(t.readAny());return new Ia(n)};class Ii{constructor(e){this.str=e}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new Ii(this.str)}splice(e){const n=new Ii(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)+"�",n.str="�"+n.str.slice(1)),n}mergeWith(e){return this.str+=e.str,!0}integrate(e,n){}delete(e){}gc(e){}write(e,n){e.writeString(n===0?this.str:this.str.slice(n))}getRef(){return 4}}const K9=t=>new Ii(t.readString()),G9=[C9,E9,O9,R9,I9,P9,L9],Z9=0,Y9=1,J9=2,X9=3,Q9=4,$9=5,eP=6;class Ni{constructor(e){this.type=e}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new Ni(this.type._copy())}splice(e){throw hi()}mergeWith(e){return!1}integrate(e,n){this.type._integrate(e.doc,n)}delete(e){let n=this.type._start;for(;n!==null;)n.deleted?n.id.clock<(e.beforeState.get(n.id.client)||0)&&e._mergeStructs.push(n):n.delete(e),n=n.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 n=this.type._start;for(;n!==null;)n.gc(e,!0),n=n.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,n){this.type._write(e)}getRef(){return 7}}const tP=t=>new Ni(G9[t.readTypeRef()](t)),hv=(t,e)=>{let n=e,r=0,i;do r>0&&(n=bt(n.client,n.clock+r)),i=bl(t,n),r=n.clock-i.id.clock,n=i.redone;while(n!==null&&i instanceof Qt);return{item:i,diff:r}},a1=(t,e)=>{for(;t!==null&&t.keep!==e;)t.keep=e,t=t.parent._item},Ph=(t,e,n)=>{const{client:r,clock:i}=e.id,o=new Qt(bt(r,i+n),e,bt(r,i+n-1),e.right,e.rightOrigin,e.parent,e.parentSub,e.content.splice(n));return e.deleted&&o.markDeleted(),e.keep&&(o.keep=!0),e.redone!==null&&(o.redone=bt(e.redone.client,e.redone.clock+n)),e.right=o,o.right!==null&&(o.right.left=o),t._mergeStructs.push(o),o.parentSub!==null&&o.right===null&&o.parent._map.set(o.parentSub,o),e.length=n,o},ox=(t,e)=>Fb(t,n=>gc(n.deletions,e)),z3=(t,e,n,r,i,o)=>{const s=t.doc,a=s.store,l=s.clientID,c=e.redone;if(c!==null)return Cr(t,c);let u=e.parent._item,f=null,h;if(u!==null&&u.deleted===!0){if(u.redone===null&&(!n.has(u)||z3(t,u,n,r,i,o)===null))return null;for(;u.redone!==null;)u=Cr(t,u.redone)}const p=u===null?e.parent:u.content.type;if(e.parentSub===null){for(f=e.left,h=e;f!==null;){let b=f;for(;b!==null&&b.parent._item!==u;)b=b.redone===null?null:Cr(t,b.redone);if(b!==null&&b.parent._item===u){f=b;break}f=f.left}for(;h!==null;){let b=h;for(;b!==null&&b.parent._item!==u;)b=b.redone===null?null:Cr(t,b.redone);if(b!==null&&b.parent._item===u){h=b;break}h=h.right}}else if(h=null,e.right&&!i){for(f=e;f!==null&&f.right!==null&&(f.right.redone||gc(r,f.right.id)||ox(o.undoStack,f.right.id)||ox(o.redoStack,f.right.id));)for(f=f.right;f.redone;)f=Cr(t,f.redone);if(f&&f.right!==null)return null}else f=p._map.get(e.parentSub)||null;const m=bn(a,l),v=bt(l,m),g=new Qt(v,f,f&&f.lastId,h,h&&h.id,p,e.parentSub,e.content.copy());return e.redone=v,a1(g,!0),g.integrate(t,0),g};let Qt=class pv extends s1{constructor(e,n,r,i,o,s,a,l){super(e,l.getLength()),this.origin=r,this.left=n,this.right=i,this.rightOrigin=o,this.parent=s,this.parentSub=a,this.redone=null,this.content=l,this.info=this.content.isCountable()?Rw:0}set marker(e){(this.info&cg)>0!==e&&(this.info^=cg)}get marker(){return(this.info&cg)>0}get keep(){return(this.info&Iw)>0}set keep(e){this.keep!==e&&(this.info^=Iw)}get countable(){return(this.info&Rw)>0}get deleted(){return(this.info&lg)>0}set deleted(e){this.deleted!==e&&(this.info^=lg)}markDeleted(){this.info|=lg}getMissing(e,n){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=bn(n,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=bn(n,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===vl&&this.id.client!==this.parent.client&&this.parent.clock>=bn(n,this.parent.client))return this.parent.client;if(this.origin&&(this.left=Jw(e,n,this.origin),this.origin=this.left.lastId),this.rightOrigin&&(this.right=Cr(e,this.rightOrigin),this.rightOrigin=this.right.id),this.left&&this.left.constructor===oi||this.right&&this.right.constructor===oi)this.parent=null;else if(!this.parent)this.left&&this.left.constructor===pv?(this.parent=this.left.parent,this.parentSub=this.left.parentSub):this.right&&this.right.constructor===pv&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===vl){const r=bl(n,this.parent);r.constructor===oi?this.parent=null:this.parent=r.content.type}return null}integrate(e,n){if(n>0&&(this.id.clock+=n,this.left=Jw(e,e.doc.store,bt(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(n),this.length-=n),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),cl(this.origin,i.origin)){if(i.id.client<this.id.client)r=i,o.clear();else if(cl(this.rightOrigin,i.rightOrigin))break}else if(i.origin!==null&&s.has(bl(e.doc.store,i.origin)))o.has(bl(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),g3(e.doc.store,this),this.content.integrate(e,this),Qw(e,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(e)}else new oi(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:bt(this.id.client,this.id.clock+this.length-1)}mergeWith(e){if(this.constructor===e.constructor&&cl(e.origin,this.lastId)&&this.right===e&&cl(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 n=this.parent._searchMarker;return n&&n.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 n=this.parent;this.countable&&this.parentSub===null&&(n._length-=this.length),this.markDeleted(),Pu(e.deleteSet,this.id.client,this.id.clock,this.length),Qw(e,n,this.parentSub),this.content.delete(e)}}gc(e,n){if(!this.deleted)throw ir();this.content.gc(e),n?o9(e,this,new oi(this.id,this.length)):this.content=new Vu(this.length)}write(e,n){const r=n>0?bt(this.id.client,this.id.clock+n-1):this.origin,i=this.rightOrigin,o=this.parentSub,s=this.content.getRef()&Yp|(r===null?0:vr)|(i===null?0:No)|(o===null?0:Du);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=Lu(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===vl?(e.writeParentInfo(!1),e.writeLeftID(a)):ir();o!==null&&e.writeString(o)}this.content.write(e,n)}};const B3=(t,e)=>nP[e&Yp](t),nP=[()=>{ir()},B9,j9,z9,K9,V9,U9,tP,W9,H9,()=>{ir()}],rP=10;class si extends s1{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,n){ir()}write(e,n){e.writeInfo(rP),Ot(e.restEncoder,this.length-n)}getMissing(e,n){return null}}const H3=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},V3="__ $YJS$ __";H3[V3]===!0&&console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438");H3[V3]=!0;const iP={anthropic:"Claude",openai:"GPT",gemini:"Gemini","local-ollama":"Local model","local-llamacpp":"Local model"},sx="Assistant";function oP(t){const e=t.defaultModelId?t.models.find(n=>n.id===t.defaultModelId):void 0;return e||(t.models.length===1?t.models[0]:void 0)}function mv(t,e){const n=oP(t);if(!n)return sx;const r=iP[n.provider]||sx;return e==="family"?r:n.displayName||n.modelId||r}function uo(t){const e=L(()=>mv(t.settings,"family")),n=L(()=>mv(t.settings,"model"));return{get family(){return d(e)},get specific(){return d(n)}}}function U3(t){return t?t+1:0}function am(t){let e=0;return t.forEach(n=>{n.isText?e+=n.text.length:n.type.name==="hardBreak"&&(e+=1)}),e}function Dd(t){if(t.isTextblock)return am(t);let e=0;for(let n=0;n<t.childCount;n++)n>0&&(e+=1),e+=Dd(t.child(n));return e}function j3(t,e,n){if(t.isTextblock)return Mn(n+Math.min(e,am(t)));let r=0,i=n;for(let o=0;o<t.childCount;o++){const s=t.child(o),a=i+1;o>0&&(r+=1);const l=Dd(s);if(r+l>e)return j3(s,e-r,a);r+=l,i+=s.nodeSize}return Mn(n+t.content.size)}function Rs(t,e){let n=0,r=0;const i=t.childCount;for(let o=0;o<i;o++){const s=t.child(o),a=r+1,l=s.type.name==="heading"?U3(s.attrs.level||1):0,c=Dd(s),u=l+c;if(n+u>e){const f=e-n,h=Math.max(0,f-l);return j3(s,h,a)}if(n+=u,r+=s.nodeSize,o<i-1&&(n+=1,n>e))return Mn(a+s.content.size)}return Mn(t.content.size)}function q3(t,e,n){if(t.isTextblock)return Math.min(e-n,am(t));let r=0,i=n;for(let o=0;o<t.childCount;o++){const s=t.child(o),a=i+1;o>0&&(r+=1);const l=i+s.nodeSize;if(e<l)return e<=a?r:r+q3(s,e,a);r+=Dd(s),i+=s.nodeSize}return r}function ii(t,e){let n=0,r=0;const i=t.childCount;for(let o=0;o<i;o++){const s=t.child(o),a=r+1,l=s.type.name==="heading"?U3(s.attrs.level||1):0,c=Dd(s),u=r+s.nodeSize;if(e<u)return e<=a?Ff(n+l):Ff(n+l+q3(s,e,a));n+=l+c,r+=s.nodeSize,o<i-1&&(n+=1)}return Ff(n)}function W3(t,e,n,r){if(e.isTextblock){let s=0;for(let a=0;a<t.length;a++){const l=t.get(a);if(l instanceof kn){if(l===r.type)return Mn(n+Math.min(s+r.index,am(e)));s+=l.length}}return null}let i=n;t.length!==e.childCount&&console.warn(`[positions] Y.js/PM child count mismatch: yEl(${t.nodeName}).length=${t.length} vs pmNode(${e.type.name}).childCount=${e.childCount}`);const o=Math.min(t.length,e.childCount);for(let s=0;s<o;s++){const a=t.get(s),l=e.child(s),c=i+1;if(a instanceof ln){const u=W3(a,l,c,r);if(u!==null)return u}i+=l.nodeSize}return null}function ax(t,e,n){let r=0;const i=Math.min(t.childCount,e.length);for(let o=0;o<i;o++){const s=e.get(o),a=t.child(o),l=r+1;if(s instanceof ln){const c=W3(s,a,l,n);if(c!==null)return c}r+=a.nodeSize}return null}function K3(t,e,n){let r,i;try{const l=ba(n.fromRel),c=ba(n.toRel);r=cv(l,t),i=cv(c,t)}catch(l){return console.warn("[positions] relRangeToPmPositions: failed to resolve relRange:",l),null}if(!r||!i)return null;const o=t.getXmlFragment("default"),s=ax(e,o,r),a=ax(e,o,i);return s===null||a===null?null:{from:s,to:a}}function $l(t,e,n){if(t.relRange&&n){const r=K3(n,e,t.relRange);if(r&&r.from<=r.to)return{...r,method:"rel"};console.warn(r?`[positions] annotationToPmRange: inverted rel range for ${t.id}, falling back to flat`:`[positions] annotationToPmRange: relRange resolved to null for ${t.id}, falling back to flat`)}return t.range?{from:Rs(e,t.range.from),to:Rs(e,t.range.to),method:"flat"}:null}function G3(t,e){return{from:ii(t,e.from),to:ii(t,e.to)}}function sP(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function aP(t){const e=sP(t),n=[];let r=e.replace(/```(\w*)\n?([\s\S]*?)```/g,(i,o,s)=>{const a=n.length,l=o?` class="language-${o}"`:"";return n.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<n.length;i++)r=r.replace(`\0BLOCK${i}\0`,n[i]);return r}var lP=T('<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>'),cP=T('<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>'),uP=T('<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 your AI.</div>'),dP=T('<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>'),fP=T('<button type="button" class="chat-anchor-quote" title="Click to scroll to this text"> </button>'),hP=T('<div class="chat-markdown svelte-15oag3v"></div>'),pP=T('<div style="white-space: pre-wrap; word-break: break-word;"> </div>'),mP=T('<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>'),gP=T("<span></span>"),vP=T('<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>'),bP=T('<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>'),yP=T('<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 class="tandem-scroll-fade-y" style="flex: 1; overflow: auto; padding: var(--tandem-space-3); min-height: 0;"><!> <!> <!> <div></div></div> <!> <div class="chat-composer-outer svelte-15oag3v"><div class="chat-composer svelte-15oag3v"><textarea placeholder="Message your AI..." class="chat-composer-input svelte-15oag3v"></textarea> <button>Send</button></div></div></div>');function lx(t,e){We(e,!0);const n=[0,.2,.4],r=uo(Or());let i=Ue(e,"inputEl",15,null);const o=L(()=>e.reduceMotion?"auto":"smooth");let s=F(Qe([])),a=F(""),l=F(void 0),c=F(void 0);he(()=>{i(d(c)??null)}),he(()=>{if(!e.ctrlYdoc)return;const H=e.ctrlYdoc.getMap(Qy),O=()=>{const G=[];H.forEach(z=>{G.push(z)}),G.sort((z,Q)=>z.timestamp-Q.timestamp||z.id.localeCompare(Q.id)),y(s,G,!0)};return H.observe(O),O(),()=>H.unobserve(O)});let u=!1;he(()=>{var G;d(s);const H=!!e.claudeActive,O=At(()=>d(o));if(!H&&u){u=!1;return}u=H,(G=d(l))==null||G.scrollIntoView({behavior:O})}),he(()=>{var G;const H=e.visible,O=At(()=>d(o));H&&((G=d(l))==null||G.scrollIntoView({behavior:O}))});const f=L(()=>d(s).filter(H=>H.author==="claude"&&!H.read).length);function h(){if(!e.ctrlYdoc||!d(a).trim())return;const H=e.ctrlYdoc.getMap(Qy),O={id:KM(),author:"user",text:d(a).trim(),timestamp:Date.now(),...e.activeDocId?{documentId:e.activeDocId}:{},...e.capturedAnchor?{anchor:e.capturedAnchor}:{},read:!1};H.set(O.id,O),y(a,""),e.onCapturedAnchorChange(null)}function p(H){H.key==="Enter"&&!H.shiftKey&&(H.preventDefault(),h())}function m(H,O){if(!(!e.editor||O&&O!==e.activeDocId))try{const G=Rs(e.editor.state.doc,H.from),z=Rs(e.editor.state.doc,H.to);e.editor.chain().focus().setTextSelection({from:G,to:z}).scrollIntoView().run()}catch(G){console.warn("[ChatPanel] Could not scroll to anchor:",G instanceof Error?G.message:G)}}function v(H){if(!H)return null;const O=e.openDocs.find(G=>G.id===H);return(O==null?void 0:O.fileName)??null}async function g(){try{await fetch(`http://127.0.0.1:${uc}${nD}`,{method:"DELETE"})}catch(H){console.warn("[ChatPanel] Failed to clear chat:",H)}}let b=F(Qe(new Set));function _(H){const O=new Set(d(b));O.has(H)?O.delete(H):O.add(H),y(b,O,!0)}var k=yP(),C=w(k),E=x(w(C)),I=w(E);{var A=H=>{var O=lP(),G=w(O);j(()=>J(G,d(f))),S(H,O)};W(I,H=>{d(f)>0&&H(A)})}var M=x(I,2);{var N=H=>{var O=cP();P("click",O,g),S(H,O)};W(M,H=>{d(s).length>0&&H(N)})}var R=x(C,2),B=w(R);{var Z=H=>{var O=uP();S(H,O)};W(B,H=>{d(s).length===0&&H(Z)})}var q=x(B,2);nt(q,17,()=>d(s),H=>H.id,(H,O)=>{var G=mP(),z=w(G),Q=w(z),ge=w(Q),ye=x(Q,2);{var Se=we=>{var Ae=dP(),pe=w(Ae);j(oe=>J(pe,oe),[()=>v(d(O).documentId)??d(O).documentId]),S(we,Ae)};W(ye,we=>{d(O).documentId&&we(Se)})}var ee=x(ye,2),de=w(ee),xe=x(z,2);{var Ee=we=>{var Ae=fP(),pe=w(Ae);j(oe=>{Me(Ae,`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: ${oe??""}; overflow: hidden; transition: max-height 0.3s ease;`),J(pe,d(O).anchor.textSnapshot)},[()=>d(b).has(d(O).id)?"500px":"60px"]),P("click",Ae,()=>m(d(O).anchor,d(O).documentId)),hn("mouseenter",Ae,()=>_(d(O).id)),hn("mouseleave",Ae,()=>_(d(O).id)),S(we,Ae)};W(xe,we=>{d(O).anchor&&we(Ee)})}var D=x(xe,2);{var $=we=>{var Ae=hP();Y6(Ae,()=>aP(d(O).text),!0),S(we,Ae)},ke=we=>{var Ae=pP(),pe=w(Ae);j(()=>J(pe,d(O).text)),S(we,Ae)};W(D,we=>{d(O).author==="claude"?we($):we(ke,-1)})}j(we=>{Me(G,`margin-bottom: var(--tandem-space-3); padding: var(--tandem-space-2) var(--tandem-space-3); border-radius: var(--tandem-r-4); background: ${d(O).author==="user"?"var(--tandem-accent-bg)":"var(--tandem-surface)"}; border: 1px solid ${d(O).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);`),Me(Q,`font-weight: 600; font-size: 11px; color: ${d(O).author==="claude"?"var(--tandem-accent)":"var(--tandem-fg-muted)"}; text-transform: uppercase;`),J(ge,d(O).author==="claude"?r.family:"You"),J(de,we)},[()=>new Date(d(O).timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})]),S(H,G)});var Y=x(q,2);{var X=H=>{var O=vP(),G=w(O);nt(G,20,()=>n,ge=>ge,(ge,ye)=>{var Se=gP();j(()=>Me(Se,`width: 5px; height: 5px; border-radius: 50%; background: var(--tandem-author-claude); animation: tandem-typing-bounce 1.2s ease-in-out ${ye??""}s infinite;`)),S(ge,Se)});var z=x(G,2),Q=w(z);j(()=>J(Q,e.claudeStatus??"Your AI is thinking...")),S(H,O)};W(Y,H=>{e.claudeActive&&H(X)})}var ae=x(Y,2);St(ae,H=>y(l,H),()=>d(l)),Tr(R,(H,O)=>jt==null?void 0:jt(H,O),()=>"y");var ne=x(R,2);{var te=H=>{var O=bP(),G=w(O),z=w(G),Q=x(G,2);j(ge=>J(z,`with selection: “${ge??""}${e.capturedAnchor.textSnapshot.length>40?"...":""}”`),[()=>e.capturedAnchor.textSnapshot.slice(0,40)]),P("click",Q,()=>e.onCapturedAnchorChange(null)),S(H,O)};W(ne,H=>{e.capturedAnchor&&H(te)})}var le=x(ne,2),se=w(le),me=w(se);V(me,"rows",2),St(me,H=>y(c,H),()=>d(c));var K=x(me,2);j((H,O)=>{Sr(me,d(a)),K.disabled=H,yt(K,1,O,"svelte-15oag3v")},[()=>!d(a).trim(),()=>"chat-composer-send"+(d(a).trim()?" on":"")]),P("input",me,H=>y(a,H.target.value,!0)),P("keydown",me,p),P("click",K,h),S(t,k),Ke()}et(["click","input","keydown"]);var wP=T('<button type="button" data-testid="apply-changes-btn"> </button>');function xP(t,e){We(e,!0);let n=F(!1);const r=L(()=>e.annotations.filter(u=>u.status==="accepted")),i=L(()=>e.annotations.filter(u=>u.status==="pending")),o=L(()=>d(r).length===0||d(n));async function s(){if(d(o)||!e.documentId)return;let u=`Apply ${d(r).length} change(s) as tracked revisions?
60
+
61
+ The changes will appear as tracked revisions in Word — you can Accept or Reject each one individually.
62
+
63
+ Your original file will be backed up.`;if(d(i).length>0&&(u+=`
64
+
65
+ ⚠ ${d(i).length} annotation(s) are still pending review and will not be applied.`),!!confirm(u)){y(n,!0);try{const f=await fetch(`${On}${$M}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({documentId:e.documentId})}),h=await f.json().catch(m=>(console.error("[ApplyChanges] Failed to parse response JSON:",m),null));if(!f.ok){alert((h==null?void 0:h.message)??`Apply failed (HTTP ${f.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(`
66
+ Backup saved to:
67
+ ${p.backupPath}`),alert(m.join(" "))}else alert("Changes applied successfully.")}catch(f){console.error("[ApplyChanges] Request failed:",f),alert(f instanceof TypeError?"Could not reach the server.":`Apply failed: ${f instanceof Error?f.message:String(f)}`)}finally{y(n,!1)}}}var a=Mt(),l=Ie(a);{var c=u=>{var f=wP();let h;var p=w(f);j(()=>{h=yt(f,1,"acb-btn svelte-hdlegv",null,h,{"is-disabled":d(o),"is-applying":d(n)}),f.disabled=d(o),V(f,"title",d(r).length===0?"No accepted suggestions to apply":void 0),J(p,d(n)?"Applying…":`Apply as Tracked Changes (${d(r).length})`)}),P("click",f,s),S(u,f)};W(l,u=>{e.activeDocFormat==="docx"&&u(c)})}S(t,a),Ke()}et(["click"]);const nf={background:"var(--tandem-warning-bg)",border:"var(--tandem-warning-border)",color:"var(--tandem-warning-fg-strong)"};function lm(t,e){return t.type==="highlight"?[]:e??[]}var kP=T('<button class="aca-btn aca-btn--accept svelte-1u9ox5p">Accept</button>'),_P=T('<button class="aca-btn aca-btn--reject svelte-1u9ox5p">Reject</button>'),CP=T('<div class="aca-row svelte-1u9ox5p"><!> <!></div>'),SP=T('<button class="aca-btn aca-btn--ghost svelte-1u9ox5p">Archive</button>'),EP=T('<button class="aca-btn aca-btn--send svelte-1u9ox5p"> </button>'),AP=T('<div class="aca-row svelte-1u9ox5p"><!> <!></div>'),TP=T('<button class="aca-btn aca-btn--ghost aca-standalone svelte-1u9ox5p">Remove</button>'),MP=T(`<div class="aca-undo-error svelte-1u9ox5p">Can't undo — text has changed.</div>`),DP=T('<div class="aca-undo-row svelte-1u9ox5p"><button data-testid="undo-btn" class="aca-undo svelte-1u9ox5p">Undo</button> <!></div>');function OP(t,e){We(e,!0);const n=uo(Or());let r=F(!1),i=null;function o(){i&&(clearTimeout(i),i=null)}function s(p){if(p.stopPropagation(),!e.onUndo)return;const m=e.onUndo(e.annotationId);if(m){o(),y(r,!1);return}m||(y(r,!0),o(),i=setTimeout(()=>{y(r,!1),i=null},3e3))}gr(o);var a=Mt(),l=Ie(a);{var c=p=>{var m=CP(),v=w(m);{var g=k=>{var C=kP();j(()=>V(C,"data-testid",`accept-btn-${e.annotationId??""}`)),P("click",C,E=>{E.stopPropagation(),e.onAccept(e.annotationId)}),S(k,C)};W(v,k=>{e.onAccept&&k(g)})}var b=x(v,2);{var _=k=>{var C=_P();j(()=>V(C,"data-testid",`dismiss-btn-${e.annotationId??""}`)),P("click",C,E=>{E.stopPropagation(),e.onDismiss(e.annotationId)}),S(k,C)};W(b,k=>{e.onDismiss&&k(_)})}S(p,m)},u=p=>{var m=AP(),v=w(m);{var g=k=>{var C=SP();j(()=>V(C,"data-testid",`archive-btn-${e.annotationId??""}`)),P("click",C,E=>{E.stopPropagation(),e.onRemove(e.annotationId)}),S(k,C)};W(v,k=>{e.onRemove&&k(g)})}var b=x(v,2);{var _=k=>{var C=EP(),E=w(C);j(()=>{V(C,"data-testid",`send-to-claude-btn-${e.annotationId??""}`),J(E,`Send to ${n.family??""}`)}),P("click",C,I=>{I.stopPropagation(),e.onSendToClaude(e.annotationId)}),S(k,C)};W(b,k=>{e.onSendToClaude&&k(_)})}S(p,m)},f=p=>{var m=TP();j(()=>V(m,"data-testid",`remove-btn-${e.annotationId??""}`)),P("click",m,v=>{v.stopPropagation(),e.onRemove(e.annotationId)}),S(p,m)},h=p=>{var m=DP(),v=w(m),g=x(v,2);{var b=_=>{var k=MP();S(_,k)};W(g,_=>{d(r)&&_(b)})}P("click",v,s),S(p,m)};W(l,p=>{e.isPending&&!e.isEditing&&(e.onAccept||e.onDismiss)?p(c):e.isPending&&!e.isEditing&&e.annotationType==="note"?p(u,1):e.isPending&&!e.isEditing&&e.onRemove?p(f,2):!e.isPending&&e.undoable&&e.onUndo&&p(h,3)})}S(t,a),Ke()}et(["click"]);const eu="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);",cx="padding: 4px 10px; 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;";var IP=T('<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),RP=T("<textarea></textarea>"),NP=T('<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 PP(t,e){We(e,!0);let n=F(null);he(()=>{var u;(u=d(n))==null||u.focus()});var r=NP(),i=w(r);{var o=u=>{var f=IP(),h=Ie(f),p=x(h,2);St(p,g=>y(n,g),()=>d(n));var m=x(p,2),v=x(m,2);j(()=>{V(h,"for",`edit-newtext-${e.annotationId??""}`),V(p,"id",`edit-newtext-${e.annotationId??""}`),V(p,"data-testid",`edit-newtext-${e.annotationId??""}`),Sr(p,e.editNewText),Me(p,eu),V(m,"for",`edit-reason-${e.annotationId??""}`),V(v,"id",`edit-reason-${e.annotationId??""}`),V(v,"data-testid",`edit-reason-${e.annotationId??""}`),Sr(v,e.editReason),Me(v,eu)}),P("input",p,g=>e.onChangeEditNewText(g.target.value)),P("keydown",p,function(...g){var b;(b=e.onKeyDown)==null||b.apply(this,g)}),P("input",v,g=>e.onChangeEditReason(g.target.value)),P("keydown",v,function(...g){var b;(b=e.onKeyDown)==null||b.apply(this,g)}),S(u,f)},s=u=>{var f=RP();St(f,h=>y(n,h),()=>d(n)),j(()=>{V(f,"data-testid",`edit-text-${e.annotationId??""}`),Sr(f,e.editText),Me(f,eu)}),P("input",f,h=>e.onChangeEditText(h.target.value)),P("keydown",f,function(...h){var p;(p=e.onKeyDown)==null||p.apply(this,h)}),S(u,f)};W(i,u=>{e.hasSuggestedText?u(o):u(s,-1)})}var a=x(i,2),l=w(a),c=x(l,2);j(()=>{V(l,"data-testid",`edit-save-btn-${e.annotationId??""}`),V(c,"data-testid",`edit-cancel-btn-${e.annotationId??""}`)}),P("click",r,u=>u.stopPropagation()),P("keydown",r,u=>u.stopPropagation()),P("click",l,u=>{u.stopPropagation(),e.onSave()}),P("click",c,u=>{u.stopPropagation(),e.onCancel()}),S(t,r),Ke()}et(["click","keydown","input"]);function LP(t,e){return t==="claude"?e??"Assistant":t==="import"?"Imported":"You"}function Z3(t){return t.suggestedText!==void 0?"replacement":t.type}function FP(t,e){return t?t.length>e?t.slice(0,e-3)+"...":t:""}function zP(t){const e=Z3(t),n=FP(t.content,60);return`${t.type==="note"?"private ":""}${e} annotation${n?": "+n:""}, ${t.status}`}function BP(t){return t.type==="highlight"&&t.color?_u[Y_(t.color)]:"var(--tandem-author-user)"}var HP=T("<span> </span>"),VP=T(`<button class="ach-edit-btn svelte-d1dbnh" title="Edit this annotation's content">✎ Edit</button>`),UP=T('<span class="ach-edited svelte-d1dbnh">(edited)</span>'),jP=T('<span class="ach-dot svelte-d1dbnh" aria-hidden="true"></span>'),qP=T('<div class="ach-row svelte-d1dbnh"><span class="ach-type svelte-d1dbnh"><span class="ach-badge annotation-type-badge svelte-d1dbnh"> </span> <!> <!> <!></span> <span class="ach-author svelte-d1dbnh"><!> <!> </span></div>');function Od(t,e){We(e,!0);const n=uo(Or()),r=L(()=>Z3(e.annotation)),i=L(()=>LP(e.annotation.author,n.family)),o=L(()=>e.annotation.author==="claude"?"var(--tandem-author-claude)":"var(--tandem-author-user)");var s=qP(),a=w(s),l=w(a),c=w(l),u=x(l,2);{var f=I=>{var A=Mt(),M=Ie(A);wd(M,()=>e.extraPill),S(I,A)};W(u,I=>{e.extraPill&&I(f)})}var h=x(u,2);{var p=I=>{var A=HP();let M;var N=w(A);j(()=>{M=yt(A,1,"ach-status svelte-d1dbnh",null,M,{"is-accepted":e.annotation.status==="accepted","is-rejected":e.annotation.status!=="accepted"}),J(N,e.annotation.status)}),S(I,A)};W(h,I=>{e.isPending||I(p)})}var m=x(h,2);{var v=I=>{var A=VP();j(()=>V(A,"data-testid",`edit-btn-${e.annotation.id??""}`)),P("click",A,M=>{M.stopPropagation(),e.onEnterEdit()}),S(I,A)};W(m,I=>{e.isPending&&e.canEdit&&!e.isReviewTarget&&!e.isEditing&&I(v)})}var g=x(a,2),b=w(g);{var _=I=>{var A=UP();S(I,A)};W(b,I=>{e.annotation.editedAt&&I(_)})}var k=x(b,2);{var C=I=>{var A=jP();j(()=>Me(A,`background: ${d(o)??""};`)),S(I,A)};W(k,I=>{e.annotation.author!=="import"&&I(C)})}var E=x(k);j(()=>{Me(l,`background: ${e.badgeBg??""}; color: ${e.badgeFg??""};`),J(c,d(r)),J(E,` ${d(i)??""}`)}),S(t,s),Ke()}et(["click"]);var WP=T('<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>');function Id(t,e){We(e,!0);const n=L(()=>e.text?e.text.length>80?e.text.slice(0,77)+"...":e.text:"");var r=Mt(),i=Ie(r);{var o=s=>{var a=WP(),l=w(a);j(()=>{V(a,"data-testid",`annotation-snippet-${e.annotationId??""}`),J(l,d(n))}),S(s,a)};W(i,s=>{e.text&&s(o)})}S(t,r),Ke()}var KP=T('<div class="aca-body" style="margin: 0; color: var(--tandem-fg); line-height: 1.45;"><p style="margin: 0;"> </p></div>'),GP=T("<!> <!> <!>",1);function ZP(t,e){We(e,!0);var n=GP(),r=Ie(n);Od(r,{get annotation(){return e.annotation},get isPending(){return e.isPending},get isReviewTarget(){return e.isReviewTarget},get isEditing(){return e.isEditing},get canEdit(){return e.canEdit},badgeBg:"var(--tandem-surface-sunk)",badgeFg:"var(--tandem-fg-muted)",get onEnterEdit(){return e.onEnterEdit}});var i=x(r,2);Id(i,{get annotationId(){return e.annotation.id},get text(){return e.annotation.textSnapshot}});var o=x(i,2);{var s=a=>{var l=KP(),c=w(l),u=w(c);j(()=>J(u,e.annotation.content||"(no note)")),S(a,l)};W(o,a=>{e.isEditing||a(s)})}S(t,n),Ke()}var YP=T('<div class="aca-body" style="margin: 0; color: var(--tandem-fg); line-height: 1.45;"><p style="margin: 0;"> </p></div>'),JP=T("<!> <!> <!>",1);function XP(t,e){We(e,!0);var n=JP(),r=Ie(n);Od(r,{get annotation(){return e.annotation},get isPending(){return e.isPending},get isReviewTarget(){return e.isReviewTarget},get isEditing(){return e.isEditing},get canEdit(){return e.canEdit},badgeBg:"var(--tandem-surface-sunk)",badgeFg:"var(--tandem-fg-muted)",get onEnterEdit(){return e.onEnterEdit}});var i=x(r,2);Id(i,{get annotationId(){return e.annotation.id},get text(){return e.annotation.textSnapshot}});var o=x(i,2);{var s=a=>{var l=YP(),c=w(l),u=w(c);j(()=>J(u,e.annotation.content||"(no note)")),S(a,l)};W(o,a=>{e.isEditing||a(s)})}S(t,n),Ke()}var QP=T('<input type="checkbox" style="margin-top: 4px; flex-shrink: 0; cursor: pointer;"/>'),$P=T('<div style="font-size: var(--tandem-text-2xs); color: var(--tandem-fg-subtle); margin-bottom: 4px;">From: <span style="font-weight: 500;"> </span></div>'),eL=T('<div class="aca-body" style="margin: 0; color: var(--tandem-fg); line-height: 1.45;"><p style="margin: 0;"> </p></div>'),tL=T('<div style="display: flex; align-items: flex-start; gap: var(--tandem-space-2);"><!> <div style="flex: 1; min-width: 0;"><!> <!> <!> <!></div></div>');function nL(t,e){We(e,!0);let n=Ue(e,"selected",3,!1);var r=tL(),i=w(r);{var o=p=>{var m=QP();j(()=>{var v;V(m,"data-testid",`annotation-select-checkbox-${e.annotation.id??""}`),Bn(m,n()),V(m,"aria-label",`Select ${((v=e.annotation.importSource)==null?void 0:v.author)??"import"} comment for batch promote`)}),P("click",m,v=>v.stopPropagation()),P("change",m,()=>{var v;return(v=e.onToggleSelect)==null?void 0:v.call(e,e.annotation.id)}),S(p,m)};W(i,p=>{e.onToggleSelect&&p(o)})}var s=x(i,2),a=w(s);Od(a,{get annotation(){return e.annotation},get isPending(){return e.isPending},get isReviewTarget(){return e.isReviewTarget},get isEditing(){return e.isEditing},get canEdit(){return e.canEdit},badgeBg:"var(--tandem-surface-sunk)",badgeFg:"var(--tandem-fg-muted)",get onEnterEdit(){return e.onEnterEdit}});var l=x(a,2);{var c=p=>{var m=$P(),v=x(w(m)),g=w(v);j(()=>{V(m,"data-testid",`annotation-import-byline-${e.annotation.id??""}`),J(g,e.annotation.importSource.author)}),S(p,m)};W(l,p=>{var m;(m=e.annotation.importSource)!=null&&m.author&&p(c)})}var u=x(l,2);Id(u,{get annotationId(){return e.annotation.id},get text(){return e.annotation.textSnapshot}});var f=x(u,2);{var h=p=>{var m=eL(),v=w(m),g=w(v);j(()=>J(g,e.annotation.content||"(no note)")),S(p,m)};W(f,p=>{e.isEditing||p(h)})}S(t,r),Ke()}et(["click","change"]);var rL=T('<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>'),iL=T('<div class="aca-body" style="margin: 0; color: var(--tandem-fg); line-height: 1.45;"><p style="margin: 0;"> </p></div>'),oL=T("<!> <!> <!>",1);function sL(t,e){We(e,!0);var n=oL(),r=Ie(n);Od(r,{get annotation(){return e.annotation},get isPending(){return e.isPending},get isReviewTarget(){return e.isReviewTarget},get isEditing(){return e.isEditing},get canEdit(){return e.canEdit},badgeBg:"var(--tandem-warning-bg)",badgeFg:"var(--tandem-warning-fg-strong)",get onEnterEdit(){return e.onEnterEdit},extraPill:l=>{var c=rL();S(l,c)},$$slots:{extraPill:!0}});var i=x(r,2);Id(i,{get annotationId(){return e.annotation.id},get text(){return e.annotation.textSnapshot}});var o=x(i,2);{var s=a=>{var l=iL(),c=w(l),u=w(c);j(()=>J(u,e.annotation.content||"(no note)")),S(a,l)};W(o,a=>{e.isEditing||a(s)})}S(t,n),Ke()}var aL=T('<span class="ct-author-dot ct-author-dot--claude svelte-4l0b78" aria-hidden="true"></span> ',1),lL=T("<span> </span>"),cL=T('<span class="ct-author-dot ct-author-dot--user svelte-4l0b78" aria-hidden="true"></span> You',1),uL=T('<span class="ct-edited svelte-4l0b78">(edited)</span>'),dL=T('<div class="ct-reply svelte-4l0b78"><div class="ct-reply-head svelte-4l0b78"><span><!></span> <span class="ct-time svelte-4l0b78"><!> </span></div> <p class="ct-body svelte-4l0b78"> </p></div>'),fL=T('<div class="ct-root svelte-4l0b78" data-testid="comment-thread"></div>');function Y3(t,e){We(e,!0);const n=uo(Or());function r(a){const l=new Date(a),u=new Date().getTime()-l.getTime(),f=Math.floor(u/6e4);if(f<1)return"just now";if(f<60)return`${f}m ago`;const h=Math.floor(f/60);return h<24?`${h}h ago`:l.toLocaleDateString()}var i=Mt(),o=Ie(i);{var s=a=>{var l=fL();nt(l,21,()=>e.replies,c=>c.id,(c,u)=>{const f=L(()=>d(u).author==="claude"?"claude":d(u).author==="import"?"import":"user");var h=dL(),p=w(h),m=w(p);let v;var g=w(m);{var b=R=>{var B=aL(),Z=x(Ie(B));j(()=>J(Z,` ${n.family??""}`)),S(R,B)},_=R=>{var B=lL(),Z=w(B);j(()=>{V(B,"data-testid",`reply-import-byline-${d(u).id??""}`),J(Z,d(u).importAuthor??"Imported")}),S(R,B)},k=R=>{var B=cL();S(R,B)};W(g,R=>{d(f)==="claude"?R(b):d(f)==="import"?R(_,1):R(k,-1)})}var C=x(m,2),E=w(C);{var I=R=>{var B=uL();S(R,B)};W(E,R=>{d(u).editedAt&&R(I)})}var A=x(E),M=x(p,2),N=w(M);j(R=>{V(h,"data-testid",`reply-${d(u).id??""}`),v=yt(m,1,"ct-author svelte-4l0b78",null,v,{"is-claude":d(f)==="claude","is-import":d(f)==="import","is-user":d(f)==="user"}),J(A,` ${R??""}`),J(N,d(u).text)},[()=>r(d(u).timestamp)]),S(c,h)}),S(a,l)};W(o,a=>{e.replies.length>0&&a(s)})}S(t,i),Ke()}var hL=T('<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>'),pL=T('<button style="padding: 1px 4px; font-size: var(--tandem-text-xs); border: none; background: none; color: var(--tandem-fg-subtle); cursor: pointer;"> </button>'),mL=T('<div style="margin-top: 6px;"><!></div>'),gL=T('<div style="margin-top: 4px; font-size: var(--tandem-text-xs); color: var(--tandem-fg-subtle);"> </div>'),vL=T('<div class="art-root svelte-155xn9n"><!> <!> <!></div>');function bL(t,e){We(e,!0);let n=Ue(e,"openNonce",3,0);const r=L(()=>lm(e.annotation,e.replies)),i=L(()=>e.annotation.id);let o=F(!1),s=F(""),a=F(!1),l=F(null);const c=L(()=>!!d(s).trim());he(()=>{var k;d(o)&&((k=d(l))==null||k.focus())});let u=At(()=>n());he(()=>{n()!==u&&(u=n(),y(o,!0))});function f(k){k.key==="Escape"&&(k.stopPropagation(),y(o,!1),y(s,""))}async function h(){var C;const k=d(s).trim();if(!(!k||d(a))){y(a,!0);try{await((C=e.onReply)==null?void 0:C.call(e,d(i),k))!==!1&&(y(s,""),y(o,!1))}finally{y(a,!1)}}}var p=vL(),m=w(p);Y3(m,{get replies(){return d(r)}});var v=x(m,2);{var g=k=>{var C=mL(),E=w(C);{var I=M=>{var N=hL(),R=w(N);St(R,Y=>y(l,Y),()=>d(l));var B=x(R,2),Z=w(B),q=x(Z,2);j(()=>{V(R,"data-testid",`reply-input-${d(i)??""}`),Sr(R,d(s)),Me(R,eu),V(Z,"data-testid",`reply-send-btn-${d(i)??""}`),Z.disabled=!d(c)||d(a),Me(Z,`padding: 2px 8px; font-size: var(--tandem-text-xs); border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-1); background: ${d(c)?"var(--tandem-accent-bg)":"var(--tandem-surface-muted)"}; color: ${d(c)?"var(--tandem-accent-fg-strong)":"var(--tandem-fg-subtle)"}; cursor: ${d(c)?"pointer":"default"};`),V(q,"data-testid",`reply-cancel-btn-${d(i)??""}`)}),P("input",R,Y=>y(s,Y.target.value,!0)),P("keydown",R,f),P("click",Z,h),P("click",q,()=>{y(o,!1),y(s,"")}),S(M,N)},A=M=>{var N=pL(),R=w(N);j(()=>{V(N,"data-testid",`reply-btn-${d(i)??""}`),J(R,`Reply${d(r).length>0?` (${d(r).length})`:""}`)}),P("click",N,()=>y(o,!0)),S(M,N)};W(E,M=>{d(o)?M(I):M(A,-1)})}P("click",C,M=>M.stopPropagation()),P("keydown",C,M=>M.stopPropagation()),S(k,C)};W(v,k=>{e.isPending&&e.onReply&&!e.isEditing&&k(g)})}var b=x(v,2);{var _=k=>{var C=gL(),E=w(C);j(()=>J(E,`${d(r).length??""}
68
+ ${d(r).length===1?"reply":"replies"}`)),S(k,C)};W(b,k=>{!e.isPending&&d(r).length>0&&!e.onReply&&k(_)})}S(t,p),Ke()}et(["click","keydown","input"]);function yg(t){return document.body.appendChild(t),{destroy(){t.remove()}}}var yL=T('<p style="margin: 0; font-size: var(--tandem-text-sm); color: var(--tandem-fg-subtle);">No replies yet.</p>'),wL=T('<textarea data-testid="reply-thread-overlay-input" placeholder="Write a reply..."></textarea> <div style="display: flex; gap: var(--tandem-space-2); margin-top: var(--tandem-space-2);"><button type="button" data-testid="reply-thread-overlay-send">Send</button> <button type="button" data-testid="reply-thread-overlay-cancel">Cancel</button></div>',1),xL=T('<button type="button" data-testid="reply-thread-overlay-reply">Reply</button>'),kL=T('<div style="border-top: 1px solid var(--tandem-border); padding-top: var(--tandem-space-3);"><!></div>'),_L=T('<div role="presentation" data-testid="reply-thread-overlay" style="position: fixed; inset: 0; background-color: rgba(0, 0, 0, 0.45); display: flex; align-items: center; justify-content: center; z-index: var(--tandem-z-above-titlebar);"><div role="dialog" aria-modal="true" aria-label="Reply thread" 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: var(--tandem-space-4) var(--tandem-space-5); width: 520px; max-width: 90vw; max-height: 80vh; overflow-y: auto; display: flex; flex-direction: column; gap: var(--tandem-space-3);"><div style="display: flex; align-items: center; justify-content: space-between;"><h2 style="margin: 0; font-size: var(--tandem-text-lg); font-weight: 600; color: var(--tandem-fg);">Reply thread <span style="font-weight: 400; color: var(--tandem-fg-subtle); font-size: var(--tandem-text-sm); margin-left: var(--tandem-space-2);"> </span></h2> <button type="button" data-testid="reply-thread-overlay-close" aria-label="Close reply thread" 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="padding: var(--tandem-space-2) var(--tandem-space-3); background: var(--tandem-surface-muted); border-radius: var(--tandem-r-2); border-left: 3px solid var(--tandem-author-claude); font-family: var(--tandem-font-serif, var(--tandem-font-sans)); font-style: italic; font-size: var(--tandem-text-sm); color: var(--tandem-fg-muted); white-space: pre-wrap;"> </div> <!> <!></div></div>');function CL(t,e){We(e,!0);const n=L(()=>lm(e.annotation,e.replies));let r=F(null),i=F(null),o=null,s=F(!1),a=F(""),l=F(!1);const c=L(()=>!!d(a).trim());he(()=>{if(!e.open)return;const g=At(()=>d(r));if(!g)return;o=document.activeElement,g.focus();const b=_=>{g&&!g.contains(_.target)&&g.focus()};return document.addEventListener("focusin",b),()=>{document.removeEventListener("focusin",b),o instanceof HTMLElement&&document.contains(o)&&o.focus()}}),he(()=>{e.open||(y(s,!1),y(a,""),y(l,!1))}),he(()=>{var g;d(s)&&((g=d(i))==null||g.focus())});function u(g){g.key==="Escape"&&(g.stopPropagation(),y(s,!1),y(a,""))}async function f(){const g=d(a).trim();if(!(!g||d(l)||!e.onReply)){y(l,!0);try{await e.onReply(e.annotation.id,g)!==!1&&(y(a,""),y(s,!1))}finally{y(l,!1)}}}function h(g){if(g.key==="Escape"){g.preventDefault(),g.stopPropagation(),e.onClose();return}if(g.stopPropagation(),g.key!=="Tab"||!d(r))return;const b=Array.from(d(r).querySelectorAll('button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')).filter(C=>!C.closest("[hidden]"));if(b.length===0){g.preventDefault();return}const _=b[0],k=b[b.length-1];g.shiftKey&&document.activeElement===_?(g.preventDefault(),k.focus()):!g.shiftKey&&document.activeElement===k&&(g.preventDefault(),_.focus())}var p=Mt(),m=Ie(p);{var v=g=>{var b=_L(),_=w(b),k=w(_),C=w(k),E=x(w(C)),I=w(E),A=x(C,2),M=x(k,2),N=w(M),R=x(M,2);{var B=X=>{var ae=yL();S(X,ae)},Z=X=>{Y3(X,{get replies(){return d(n)}})};W(R,X=>{d(n).length===0?X(B):X(Z,-1)})}var q=x(R,2);{var Y=X=>{var ae=kL(),ne=w(ae);{var te=se=>{var me=wL(),K=Ie(me);St(K,z=>y(i,z),()=>d(i));var H=x(K,2),O=w(H),G=x(O,2);j(()=>{Me(K,eu),O.disabled=!d(c)||d(l),Me(O,`padding: 4px 10px; font-size: var(--tandem-text-xs); border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-1); background: ${d(c)?"var(--tandem-accent-bg)":"var(--tandem-surface-muted)"}; color: ${d(c)?"var(--tandem-accent-fg-strong)":"var(--tandem-fg-subtle)"}; cursor: ${d(c)&&!d(l)?"pointer":"default"};`),Me(G,cx)}),P("keydown",K,u),Xn(K,()=>d(a),z=>y(a,z)),P("click",O,f),P("click",G,()=>{y(s,!1),y(a,"")}),S(se,me)},le=se=>{var me=xL();j(()=>Me(me,cx)),P("click",me,()=>y(s,!0)),S(se,me)};W(ne,se=>{d(s)?se(te):se(le,-1)})}S(X,ae)};W(q,X=>{e.onReply&&X(Y)})}St(_,X=>y(r,X),()=>d(r)),Tr(b,X=>yg==null?void 0:yg(X)),j(()=>{J(I,`(${d(n).length??""}
69
+ ${d(n).length===1?"reply":"replies"})`),J(N,e.annotation.content)}),P("click",b,function(...X){var ae;(ae=e.onClose)==null||ae.apply(this,X)}),P("keydown",b,()=>{}),P("click",_,X=>X.stopPropagation()),P("keydown",_,h),P("click",A,function(...X){var ae;(ae=e.onClose)==null||ae.apply(this,X)}),S(g,b)};W(m,g=>{e.open&&g(v)})}S(t,p),Ke()}et(["click","keydown"]);var SL=T('<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> ',1),EL=T('<p style="margin: 0; font-size: 12px; color: var(--tandem-fg-muted);"> </p>'),AL=T('<div class="aca-body" style="margin: 0; color: var(--tandem-fg); line-height: 1.45;"><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> <!></div>'),TL=T("<!> <!> <!>",1);function ML(t,e){We(e,!0);var n=TL(),r=Ie(n);Od(r,{get annotation(){return e.annotation},get isPending(){return e.isPending},get isReviewTarget(){return e.isReviewTarget},get isEditing(){return e.isEditing},get canEdit(){return e.canEdit},badgeBg:"var(--tandem-suggestion-bg)",badgeFg:"var(--tandem-suggestion-fg-strong)",get onEnterEdit(){return e.onEnterEdit}});var i=x(r,2);Id(i,{get annotationId(){return e.annotation.id},get text(){return e.annotation.textSnapshot}});var o=x(i,2);{var s=a=>{var l=AL(),c=w(l),u=w(c);{var f=g=>{var b=SL(),_=Ie(b),k=w(_),C=x(_);C.nodeValue=" → ",j(()=>J(k,e.annotation.textSnapshot)),S(g,b)};W(u,g=>{e.annotation.textSnapshot&&g(f)})}var h=x(u,2),p=w(h),m=x(c,2);{var v=g=>{var b=EL(),_=w(b);j(()=>J(_,e.annotation.content)),S(g,b)};W(m,g=>{e.annotation.content&&g(v)})}j(()=>{V(c,"data-testid",`suggestion-diff-${e.annotation.id??""}`),Me(c,`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;`),J(p,e.annotation.suggestedText)}),S(a,l)};W(o,a=>{e.isEditing||a(s)})}S(t,n),Ke()}var DL=T('<div class="tandem-claude-typing svelte-3ascys" role="status" aria-live="polite"><span class="tandem-claude-typing-dot svelte-3ascys"></span> <span class="tandem-claude-typing-dot svelte-3ascys"></span> <span class="tandem-claude-typing-dot svelte-3ascys"></span></div>'),OL=T('<button type="button" class="tandem-expand-thread svelte-3ascys">Expand thread</button>'),IL=T('<div role="listitem"><!> <!> <!> <!> <!> <!></div> <!>',1);function gv(t,e){We(e,!0);let n=Ue(e,"replies",19,()=>[]),r=Ue(e,"claudeTyping",3,!1),i=Ue(e,"selected",3,!1),o=Ue(e,"density",3,"full"),s=Ue(e,"lifecycleMotion",3,!1),a=Ue(e,"reduceMotion",3,!1),l=Ue(e,"openRequest",3,null);const c=uo(Or());let u=F(!1),f=F(""),h=F(""),p=F("");const m=L(()=>e.annotation.status==="pending"),v=L(()=>e.annotation.suggestedText!==void 0),g=L(()=>e.onEdit!==void 0),b=L(()=>zP(e.annotation)),_=L(()=>lm(e.annotation,n())),k=L(()=>d(_).length>=1);let C=F(!1);const E=L(()=>o()==="stub"?"stub":d(u)?"full":o());let I=At(()=>d(E));he(()=>{d(E)!==I&&(I=d(E),d(E)==="stub"&&y(C,!1))});let A=-1,M=-1,N=F(0);he(()=>{const D=l();if(D)if(D.kind==="edit"){if(D.nonce===A)return;A=D.nonce,e.onEdit&&Z()}else{if(D.nonce===M)return;M=D.nonce,y(N,D.nonce,!0)}});const R=L(()=>e.annotation.author==="import"?"var(--tandem-surface-muted)":e.annotation.type==="highlight"?`color-mix(in srgb, ${BP(e.annotation)} 18%, var(--tandem-surface))`:e.annotation.type==="note"?"var(--tandem-warning-bg)":e.annotation.suggestedText!==void 0?"var(--tandem-suggestion-bg)":e.annotation.author==="claude"?"var(--tandem-author-claude-bg)":"var(--tandem-author-user-bg)"),B=L(()=>e.isReviewTarget?"var(--tandem-accent-bg)":d(R));function Z(){d(v)?(y(h,e.annotation.suggestedText??"",!0),y(p,e.annotation.content,!0)):y(f,e.annotation.content,!0),y(u,!0)}function q(){var $;const D=d(v)?JSON.stringify({suggestedText:d(h),content:d(p)}):d(f);($=e.onEdit)==null||$.call(e,e.annotation.id,D),y(u,!1)}function Y(){y(u,!1)}function X(D){D.key==="Escape"&&(D.stopPropagation(),Y())}var ae=IL(),ne=Ie(ae);let te;var le=w(ne);{var se=D=>{var $=DL();j(()=>{V($,"data-testid",`claude-typing-indicator-${e.annotation.id??""}`),V($,"aria-label",`${c.family??""} is working on this annotation`),V($,"title",`${c.family??""} is working on this annotation`)}),S(D,$)};W(le,D=>{r()&&D(se)})}var me=x(le,2);{var K=D=>{nL(D,{get annotation(){return e.annotation},get isPending(){return d(m)},get isReviewTarget(){return e.isReviewTarget},get isEditing(){return d(u)},get canEdit(){return d(g)},onEnterEdit:Z,get selected(){return i()},get onToggleSelect(){return e.onToggleSelect}})},H=D=>{XP(D,{get annotation(){return e.annotation},get isPending(){return d(m)},get isReviewTarget(){return e.isReviewTarget},get isEditing(){return d(u)},get canEdit(){return d(g)},onEnterEdit:Z})},O=D=>{sL(D,{get annotation(){return e.annotation},get isPending(){return d(m)},get isReviewTarget(){return e.isReviewTarget},get isEditing(){return d(u)},get canEdit(){return d(g)},onEnterEdit:Z})},G=D=>{ML(D,{get annotation(){return e.annotation},get isPending(){return d(m)},get isReviewTarget(){return e.isReviewTarget},get isEditing(){return d(u)},get canEdit(){return d(g)},onEnterEdit:Z})},z=D=>{ZP(D,{get annotation(){return e.annotation},get isPending(){return d(m)},get isReviewTarget(){return e.isReviewTarget},get isEditing(){return d(u)},get canEdit(){return d(g)},onEnterEdit:Z})};W(me,D=>{e.annotation.author==="import"?D(K):e.annotation.type==="highlight"?D(H,1):e.annotation.type==="note"?D(O,2):e.annotation.suggestedText!==void 0?D(G,3):D(z,-1)})}var Q=x(me,2);{var ge=D=>{PP(D,{get annotationId(){return e.annotation.id},get hasSuggestedText(){return d(v)},get editText(){return d(f)},get editNewText(){return d(h)},get editReason(){return d(p)},onChangeEditText:$=>y(f,$,!0),onChangeEditNewText:$=>y(h,$,!0),onChangeEditReason:$=>y(p,$,!0),onKeyDown:X,onSave:q,onCancel:Y})};W(Q,D=>{d(u)&&D(ge)})}var ye=x(Q,2);OP(ye,{get annotationId(){return e.annotation.id},get annotationType(){return e.annotation.type},get isPending(){return d(m)},get isEditing(){return d(u)},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 Se=x(ye,2);bL(Se,{get annotation(){return e.annotation},get replies(){return d(_)},get isPending(){return d(m)},get isEditing(){return d(u)},get onReply(){return e.onReply},get openNonce(){return d(N)}});var ee=x(Se,2);{var de=D=>{var $=OL();j(()=>V($,"data-testid",`reply-thread-expand-${e.annotation.id??""}`)),P("click",$,ke=>{ke.stopPropagation(),y(C,!0)}),S(D,$)};W(ee,D=>{d(k)&&D(de)})}var xe=x(ne,2);{var Ee=D=>{CL(D,{get open(){return d(C)},get annotation(){return e.annotation},get replies(){return d(_)},get onReply(){return e.onReply},onClose:()=>y(C,!1)})};W(xe,D=>{(d(k)||d(C))&&D(Ee)})}j(()=>{te=yt(ne,1,"tandem-annotation-card svelte-3ascys",null,te,{"is-review-target":e.isReviewTarget,"is-density-clamped":d(E)==="clamped","is-density-stub":d(E)==="stub"}),V(ne,"data-testid",`annotation-card-${e.annotation.id??""}`),V(ne,"data-annotation-id",e.annotation.id),V(ne,"data-annotation-type",e.annotation.type),V(ne,"data-density",d(E)),V(ne,"data-claude-typing",r()?"true":void 0),V(ne,"aria-label",d(b)),V(ne,"aria-current",e.isReviewTarget?"true":void 0),Me(ne,`background: ${d(B)??""}; opacity: ${d(m)?1:.6}; cursor: ${e.onClick?"pointer":"default"};`)}),P("click",ne,function(...D){var $;($=e.onClick)==null||$.apply(this,D)}),Uo(1,ne,()=>bI,()=>({enabled:s(),reduceMotion:a()})),Uo(2,ne,()=>yI,()=>({enabled:s(),reduceMotion:a(),id:e.annotation.id,modes:e.exitModes})),S(t,ae),Ke()}et(["click"]);const RL="browser";function NL(t,e,n){let r,i=!1;if(t.transact(()=>{r=e(),i=!0},n),!i)throw new Error(`origins: transact callback did not run (origin=${n})`);return r}function Po(t,e){return NL(t,e,RL)}function Ra(t,e){const n=t,r=s=>{try{e(s)}catch(a){console.warn(`[sanitizeAnnotation] onLossy threw for ${s.kind}:`,a)}},i=n.audience==="private"||n.audience==="outbound"?n.audience:n.author==="import"||n.type==="highlight"||n.type==="note"||n.type==="flag"?"private":"outbound",o={id:n.id,author:n.author,range:n.range,content:n.content,status:n.status,timestamp:n.timestamp,...n.relRange!==void 0?{relRange:n.relRange}:{},...n.textSnapshot!==void 0?{textSnapshot:n.textSnapshot}:{},...n.editedAt!==void 0?{editedAt:n.editedAt}:{},...typeof n.rev=="number"?{rev:n.rev}:{},audience:i,...n.promotedFrom!==void 0?{promotedFrom:n.promotedFrom}:{},...n.importSource!==void 0?{importSource:n.importSource}:{}};if(o.audience==="outbound"&&n.author==="user"&&(n.type==="note"||n.type==="highlight"||n.type==="flag")&&(o.audience="private",r({kind:"audience-conflict-resolved",id:n.id})),n.type==="suggestion"){let s,a;try{const l=JSON.parse(n.content);s=l.newText,a=l.reason??""}catch{r({kind:"malformed-suggestion-json",id:n.id}),a=n.content}return{...o,type:"comment",content:a,suggestedText:s}}return n.type==="question"?(r({kind:"question-to-comment",id:n.id}),{...o,type:"comment"}):n.type==="highlight"?{...o,type:"highlight",color:n.color}:n.type==="flag"||n.type==="note"?(n.type==="flag"&&r({kind:"flag-to-note",id:n.id}),{...o,type:"note"}):n.type==="comment"?{...o,type:"comment",...n.suggestedText!==void 0?{suggestedText:n.suggestedText}:{}}:(r({kind:"unknown-type",id:n.id,rawType:n.type}),{...o,type:"comment"})}const l1=t=>{console.warn("[sanitize]",t)};function J3(t,e,n){if(!t)return;const r=t.getMap(Ti),i=r.get(e);if(!i)return;const o=Ra(i,l1);Po(t,()=>{if(o.suggestedText!==void 0){try{const s=JSON.parse(n);r.set(e,{...o,suggestedText:s.suggestedText,content:s.content,editedAt:Date.now(),rev:(o.rev??0)+1})}catch{console.warn(`[annotation-actions] Failed to parse edit payload for annotation ${e}`)}return}r.set(e,{...o,content:n,editedAt:Date.now(),rev:(o.rev??0)+1})})}function X3(t){const{color:e,suggestedText:n,...r}=t;return{...r,type:"comment",author:t.author==="import"?"user":t.author,audience:"outbound",promotedFrom:"note",rev:(t.rev??0)+1}}function Q3(t,e){if(!t)return;const n=t.getMap(Ti),r=n.get(e);if(!r)return;const i=Ra(r,l1);i.type==="note"&&Po(t,()=>{n.set(e,X3(i))})}function PL(t,e){if(!t||e.length===0)return 0;const n=t.getMap(Ti);let r=0;return Po(t,()=>{for(const i of e){const o=n.get(i);if(!o)continue;const s=Ra(o,l1);s.type==="note"&&(n.set(i,X3(s)),r++)}}),r}async function $3(t,e){try{const n=await fetch(`${On}${tD}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({annotationId:t,documentId:e})});if(!n.ok){const r=await n.json().catch(()=>({message:"Unknown error"}));console.error("[Tandem] Remove annotation failed:",r)}}catch(n){console.error("[Tandem] Remove annotation failed:",n)}}async function eE(t,e,n){try{const r=await fetch(`${On}${eD}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({annotationId:t,text:e,documentId:n})});if(!r.ok){const i=await r.json().catch(()=>({}));return console.warn(`[annotation-actions] Reply failed (${r.status}): ${i.message??"unknown error"}`),!1}return!0}catch(r){return console.error("[annotation-actions] Reply request failed:",r),!1}}const LL=["ctx:annotation:accept","ctx:annotation:dismiss","ctx:annotation:reply","ctx:annotation:edit","ctx:annotation:sendToClaude","ctx:annotation:copy","ctx:annotation:remove"],FL=new Set(LL);function zL(t){return typeof t=="string"&&FL.has(t)}const yc=t=>t.status==="pending",cm=t=>t.author!=="user"&&yc(t),um=t=>t.author!=="user"&&yc(t),dm=t=>(t.type==="note"||t.type==="comment")&&yc(t),fm=t=>t.author==="user"&&yc(t),hm=t=>t.author==="user"&&t.type==="note"&&yc(t),pm=t=>t.author==="user"&&yc(t),BL=t=>!0;function HL(t){return{canAccept:cm(t),canDismiss:um(t),canReply:dm(t),canEdit:fm(t),canSendToClaude:hm(t),canCopy:BL(),canRemove:pm(t),isNote:t.type==="note"}}function VL(t){var n;return((n=t.content)==null?void 0:n.trim())?t.content:t.textSnapshot??""}let Zf=null;function UL(t){Zf=t}function tE(t,e,n){var r,i,o,s,a,l;switch(t){case"ctx:annotation:accept":cm(e)&&((r=n.accept)==null||r.call(n,e.id));return;case"ctx:annotation:dismiss":um(e)&&((i=n.dismiss)==null||i.call(n,e.id));return;case"ctx:annotation:sendToClaude":hm(e)&&((o=n.sendToClaude)==null||o.call(n,e.id));return;case"ctx:annotation:remove":pm(e)&&((s=n.remove)==null||s.call(n,e.id));return;case"ctx:annotation:edit":fm(e)&&((a=n.openEdit)==null||a.call(n,e.id));return;case"ctx:annotation:reply":dm(e)&&((l=n.openReply)==null||l.call(n,e.id));return;case"ctx:annotation:copy":{const c=VL(e);c&&navigator.clipboard.writeText(c).catch(()=>{})}return}}async function nE(t,e){UL({run:e});try{await(await Ta())("show_annotation_context_menu",{req:HL(t)})}catch{}}let rf=0,of=null;function rE(){if(!Pt())return()=>{};rf++,rf===1&&(of=yn(async()=>{const{listen:e}=await import("./event-CNdo2oXa.js");return{listen:e}},__vite__mapDeps([2,1])).then(({listen:e})=>e("context-menu-action",n=>{var i;const r=(i=n.payload)==null?void 0:i.id;zL(r)&&(Zf==null||Zf.run(r))})),of.catch(()=>{}));let t=!1;return()=>{if(!t&&(t=!0,rf--,rf===0)){const e=of;of=null,e==null||e.then(n=>n()).catch(()=>{})}}}var jL=T('<div data-testid="batch-promote-bar" role="region" aria-label="Batch promote imported notes" style="position: sticky; top: 0; z-index: var(--tandem-z-base); display: flex; align-items: center; gap: var(--tandem-space-2); padding: var(--tandem-space-2) var(--tandem-space-4); background: var(--tandem-surface); border-bottom: 1px solid var(--tandem-border); box-shadow: var(--tandem-shadow-1);"><span data-testid="batch-promote-count" style="flex: 1; font-size: var(--tandem-text-2xs); font-weight: 500; color: var(--tandem-fg-subtle);"> </span> <button data-testid="batch-promote-clear" style="padding: 3px 10px; border: 1px solid transparent; background: none; color: var(--tandem-fg-subtle); border-radius: var(--tandem-r-pill); cursor: pointer; font-size: var(--tandem-text-xs);">Clear</button> <button data-testid="batch-promote-confirm" style="padding: 3px 12px; border: 1px solid var(--tandem-accent); background: var(--tandem-accent); color: var(--tandem-accent-fg); border-radius: var(--tandem-r-pill); cursor: pointer; font-size: var(--tandem-text-xs); font-weight: 500;"> </button></div>');function qL(t,e){We(e,!0);let n=Ue(e,"reduceMotion",3,!1);const r=uo(Or());var i=Mt(),o=Ie(i);{var s=a=>{var l=jL(),c=w(l),u=w(c),f=x(c,2),h=x(f,2),p=w(h);j(()=>{J(u,`${e.selectedCount??""} selected`),J(p,`Send ${e.selectedCount??""} to ${r.family??""}`)}),P("click",f,function(...m){var v;(v=e.onClear)==null||v.apply(this,m)}),P("click",h,function(...m){var v;(v=e.onPromote)==null||v.apply(this,m)}),Uo(1,l,()=>yS,()=>({reduceMotion:n()})),Uo(2,l,()=>wS,()=>({reduceMotion:n(),exitMs:200})),S(a,l)};W(o,a=>{e.selectedCount>0&&a(s)})}S(t,i),Ke()}et(["click"]);var WL=T('<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),KL=T('<button data-testid="bulk-accept-btn"> </button> <button data-testid="bulk-dismiss-btn">Reject All</button>',1),GL=T('<div style="padding: 6px var(--tandem-space-4); border-bottom: 1px solid var(--tandem-border); display: flex; gap: 4px; align-items: center;"><!></div>');function ZL(t,e){We(e,!0);let n=Ue(e,"confirmRef",15,null),r=Ue(e,"reduceMotion",3,!1);const i=L(()=>e.bulkConfirm==="accept"),o=L(()=>e.pendingCount===e.allPendingCount?`${e.pendingCount} annotations?`:`${e.pendingCount} of ${e.allPendingCount} pending?`);var s=Mt(),a=Ie(s);{var l=c=>{var u=GL(),f=w(u);{var h=m=>{var v=WL(),g=Ie(v),b=w(g),_=x(g,2);St(_,C=>n(C),()=>n());var k=x(_,2);Me(k,"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);"),j(()=>{J(b,`${d(i)?"Accept":"Reject"}
70
+ ${d(o)??""}`),Me(_,`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: ${d(i)?"var(--tandem-success-bg)":"var(--tandem-error-bg)"}; color: ${d(i)?"var(--tandem-success-fg-strong)":"var(--tandem-error-fg-strong)"}; font-weight: 600;`)}),P("click",_,function(...C){var E;(E=d(i)?e.onConfirmAccept:e.onConfirmDismiss)==null||E.apply(this,C)}),P("click",k,function(...C){var E;(E=e.onCancel)==null||E.apply(this,C)}),S(m,v)},p=m=>{var v=KL(),g=Ie(v);Me(g,"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 b=w(g),_=x(g,2);Me(_,"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);"),j(()=>J(b,`Accept All (${e.pendingCount??""})`)),P("click",g,function(...k){var C;(C=e.onRequestAccept)==null||C.apply(this,k)}),P("click",_,function(...k){var C;(C=e.onRequestDismiss)==null||C.apply(this,k)}),S(m,v)};W(f,m=>{e.bulkConfirm?m(h):m(p,-1)})}Uo(1,u,()=>yS,()=>({reduceMotion:r()})),Uo(2,u,()=>wS,()=>({reduceMotion:r(),exitMs:180})),S(c,u)};W(a,c=>{e.pendingCount>1&&c(l)})}S(t,s),Ke()}et(["click"]);var YL=T("<option> </option>"),JL=T('<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 wg(t,e){We(e,!0);var n=JL();nt(n,21,()=>e.options,i=>i.value,(i,o)=>{var s=YL(),a=w(s),l={};j(()=>{J(a,d(o).label),l!==(l=d(o).value)&&(s.value=(s.__value=d(o).value)??"")}),S(i,s)});var r;xb(n),j(()=>{V(n,"data-testid",e.testId),V(n,"aria-label",e.ariaLabel),r!==(r=e.value)&&(n.value=(n.__value=e.value)??"",zp(n,e.value))}),P("change",n,i=>e.onChange(i.target.value)),S(t,n),Ke()}et(["change"]);var XL=T('<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>'),QL=T('<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 $L(t,e){We(e,!0);const n=uo(Or());var r=Mt(),i=Ie(r);{var o=s=>{var a=QL(),l=w(a);wg(l,{testId:"filter-type",ariaLabel:"Filter by type",get value(){return e.filterType},onChange:m=>e.onSetFilterType(m),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 c=x(l,2);{let m=L(()=>[{value:"all",label:"Anyone"},{value:"claude",label:n.family},{value:"user",label:"You"},{value:"import",label:"Imported"}]);wg(c,{testId:"filter-author",ariaLabel:"Filter by author",get value(){return e.filterAuthor},onChange:v=>e.onSetFilterAuthor(v),get options(){return d(m)}})}var u=x(c,2);wg(u,{testId:"filter-status",ariaLabel:"Filter by status",get value(){return e.filterStatus},onChange:m=>e.onSetFilterStatus(m),options:[{value:"all",label:"Any status"},{value:"pending",label:"Pending"},{value:"accepted",label:"Accepted"},{value:"dismissed",label:"Dismissed"}]});var f=x(u,2);{var h=m=>{var v=XL();P("click",v,function(...g){var b;(b=e.onClearFilters)==null||b.apply(this,g)}),S(m,v)};W(f,m=>{e.hasFilters&&m(h)})}var p=x(f,2);P("click",p,function(...m){var v;(v=e.onToggleOpen)==null||v.apply(this,m)}),S(s,a)};W(i,s=>{e.open&&s(o)})}S(t,r),Ke()}et(["click"]);var e7=T(`<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
71
+ won't be saved. Close the other instance and restart.</span> <button data-testid="store-readonly-dismiss" class="svelte-l26r3u">Dismiss</button></div>`),t7=T('<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>'),n7=T('<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>'),r7=T('<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>'),i7=T('<div style="padding: var(--tandem-space-3); flex: 1;" role="list" aria-label="Annotations" class="svelte-l26r3u"><!> <!></div>'),o7=T('<div data-testid="annotation-list-scroll-container" class="tandem-scroll-fade-y svelte-l26r3u" style="width: 100%; background: var(--tandem-surface-muted); display: flex; flex-direction: column; overflow-y: auto;"><!> <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> <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;" class="svelte-l26r3u"><span class="svelte-l26r3u"> </span> <span style="font-size: 9px; opacity: 0.7;" class="svelte-l26r3u">▾</span> <span class="svelte-l26r3u">Filter</span></button></div></div> <!> <div style="padding: var(--tandem-space-1) var(--tandem-space-4) 0;" class="svelte-l26r3u"><!></div> <!> <!> <!></div>');function ux(t,e){We(e,!0);let n=Ue(e,"storeReadOnly",3,!1),r=Ue(e,"claudeWorkingAnnotationId",3,null);const i=L(()=>e.reduceMotion?"auto":"smooth"),o="tandem:storeReadOnlyBannerDismissed";function s(){try{return localStorage.getItem(o)==="true"}catch{return!1}}let a=F(Qe(s()));he(()=>{if(!n()){y(a,!1);try{localStorage.removeItem(o)}catch{}}});function l(){try{localStorage.setItem(o,"true")}catch{}y(a,!0)}let c=F("all"),u=F("all"),f=F("all"),h=F(!1),p=F(null),m=F(void 0),v=F(null);he(()=>{var ie;d(p)&&((ie=d(v))==null||ie.focus())}),he(()=>{d(c),d(u),d(f),y(p,null)}),he(()=>{var ie;(ie=e.onFilterChange)==null||ie.call(e,d(c),d(u),d(f))});let g=F(Qe(new Map));he(()=>{if(!e.ydoc){y(g,new Map,!0);return}const ie=e.ydoc.getMap(eC);function ve(){const Ye=new Map;ie.forEach(ut=>{const fe=ut;if(fe&&typeof fe=="object"&&fe.annotationId){const Te=Ye.get(fe.annotationId)??[];Te.push(fe),Ye.set(fe.annotationId,Te)}});for(const ut of Ye.values())ut.sort((fe,Te)=>fe.timestamp-Te.timestamp);y(g,Ye,!0)}return ve(),ie.observe(ve),()=>ie.unobserve(ve)});const b=L(()=>{const ie=[],ve=[];for(const ce of e.annotations){ce.status==="pending"&&ve.push(ce);let Oe;d(c)==="all"?Oe=!0:d(c)==="with-replacement"?Oe=ce.suggestedText!==void 0:Oe=ce.type===d(c);const He=d(u)==="all"||ce.author===d(u),it=d(f)==="all"||ce.status===d(f);Oe&&He&&it&&ie.push(ce)}const Ye=ie.filter(ce=>ce.status==="pending"),ut=ie.filter(hh),fe=ie.filter(ce=>ce.status!=="pending"),Te=e.annotations.filter(hh);return{filtered:ie,pending:Ye,reviewPending:ut,resolved:fe,allPending:ve,reviewAllPending:Te}}),_=uo(Or()),k=L(()=>d(c)!=="all"||d(u)!=="all"||d(f)!=="all"),C=L(()=>{if(!d(k))return"All";const ie=[];if(d(c)!=="all"){const ve={all:"All",highlight:"Highlights",comment:"Comments",note:"Notes","with-replacement":"With replacement"};ie.push(ve[d(c)])}if(d(u)!=="all"){const ve={all:"Anyone",claude:_.family,user:"You",import:"Imported"};ie.push(ve[d(u)])}if(d(f)!=="all"){const ve={all:"Any status",pending:"Pending",accepted:"Accepted",dismissed:"Dismissed"};ie.push(ve[d(f)])}return ie.join(" · ")||"All"});let E=!1;he(()=>{if(d(c),d(u),d(f),!E){E=!0;return}At(()=>{var ie;if(e.activeAnnotationId){const ve=document.querySelector(`[data-testid="annotation-card-${e.activeAnnotationId}"]`);if(ve){ve.scrollIntoView({block:"center"});return}console.warn(`[tandem] SidePanel: active annotation ${e.activeAnnotationId} not found on filter change; scrolling to top`)}(ie=d(m))==null||ie.scrollTo({top:0})})}),he(()=>{const ie=e.activeAnnotationId;if(!ie)return;const ve=d(i),Ye=e.reduceMotion||typeof matchMedia<"u"&&matchMedia("(prefers-reduced-motion: reduce)").matches,ut=setTimeout(()=>{const fe=document.querySelector(`[data-testid="annotation-card-${ie}"]`);if(!fe){console.warn(`[tandem] SidePanel: active annotation ${ie} not found after 50ms delay; scroll-to-card skipped`);return}if(fe.scrollIntoView({behavior:ve,block:"nearest"}),Ye)return;fe.classList.add("tandem-annotation-flash");const Te=ce=>{ce.animationName.includes("tandem-annotation-flash")&&(fe.classList.remove("tandem-annotation-flash"),fe.removeEventListener("animationend",Te))};fe.addEventListener("animationend",Te)},50);return()=>clearTimeout(ut)});const I=(ie,ve)=>J3(e.ydoc,ie,ve),A=ie=>Q3(e.ydoc,ie),M=ie=>$3(ie,e.documentId),N=(ie,ve)=>eE(ie,ve,e.documentId),R=new Map;function B(ie){R.set(ie,"accept"),e.review.handleAccept(ie)}function Z(ie){R.set(ie,"dismiss"),e.review.handleDismiss(ie)}let q=F(void 0),Y=F(null),X=0;function ae(ie){return e.annotations.find(ve=>ve.id===ie)}function ne(ie){return ve=>{const Ye=ae(ie);Ye&&tE(ve,Ye,{accept:B,dismiss:Z,sendToClaude:A,remove:M,openEdit:ut=>y(Y,{id:ut,kind:"edit",nonce:++X},!0),openReply:ut=>y(Y,{id:ut,kind:"reply",nonce:++X},!0)})}}async function te(ie){var fe;if(!Pt())return;const ve=(fe=ie.target)==null?void 0:fe.closest("[data-annotation-id]"),Ye=ve==null?void 0:ve.getAttribute("data-annotation-id");if(!Ye)return;const ut=ae(Ye);ut&&(ie.preventDefault(),ie.stopPropagation(),await nE(ut,ne(Ye)))}he(()=>{const ie=d(q);if(ie)return ie.addEventListener("contextmenu",te),()=>ie.removeEventListener("contextmenu",te)}),he(()=>rE());function le(ie){for(const ve of d(b).reviewPending)e.review.resolveAnnotation(ve.id,ie);y(p,null)}let se=F(Qe(new Set));he(()=>{const ie=new Set(d(b).pending.filter(ve=>ve.author==="import"&&ve.type==="note").map(ve=>ve.id));At(()=>{const ve=new Set([...d(se)].filter(Ye=>ie.has(Ye)));ve.size!==d(se).size&&y(se,ve,!0)})});function me(ie){const ve=new Set(d(se));ve.has(ie)?ve.delete(ie):ve.add(ie),y(se,ve,!0)}function K(){const ie=Array.from(d(se));PL(e.ydoc,ie),y(se,new Set,!0)}function H(){y(se,new Set,!0)}function O(ie){ie.target===ie.currentTarget&&e.onActiveAnnotationChange(null)}var G=o7(),z=w(G);{var Q=ie=>{var ve=e7(),Ye=x(w(ve),2);j(()=>{Me(ve,`padding: 10px 14px; margin: 10px 14px 0; background: ${nf.background}; border: 1px solid ${nf.border}; border-radius: var(--tandem-r-4); font-size: var(--tandem-text-xs); color: ${nf.color}; display: flex; justify-content: space-between; align-items: flex-start; gap: 10px;`),Me(Ye,`flex-shrink: 0; font-size: var(--tandem-text-xs); padding: 2px 8px; border: none; border-radius: var(--tandem-r-2); background: none; color: ${nf.color}; cursor: pointer; font-weight: 500;`)}),P("click",Ye,l),S(ie,ve)};W(z,ie=>{n()&&!d(a)&&ie(Q)})}var ge=x(z,2),ye=w(ge),Se=w(ye),ee=x(w(Se));{var de=ie=>{var ve=t7(),Ye=w(ve);j(()=>J(Ye,d(b).allPending.length)),S(ie,ve)};W(ee,ie=>{d(b).allPending.length>0&&ie(de)})}var xe=x(Se,2),Ee=w(xe),D=x(xe,2),$=w(D),ke=w($),we=x(ge,2);$L(we,{get filterType(){return d(c)},get filterAuthor(){return d(u)},get filterStatus(){return d(f)},get hasFilters(){return d(k)},get open(){return d(h)},onToggleOpen:()=>y(h,!d(h)),onSetFilterType:ie=>{y(c,ie,!0)},onSetFilterAuthor:ie=>{y(u,ie,!0)},onSetFilterStatus:ie=>{y(f,ie,!0)},onClearFilters:()=>{y(c,"all"),y(u,"all"),y(f,"all")}});var Ae=x(we,2),pe=w(Ae);xP(pe,{get annotations(){return e.annotations},get activeDocFormat(){return e.activeDocFormat},get documentId(){return e.documentId}});var oe=x(Ae,2);qL(oe,{get selectedCount(){return d(se).size},onPromote:K,onClear:H,get reduceMotion(){return e.reduceMotion}});var De=x(oe,2);ZL(De,{get bulkConfirm(){return d(p)},get pendingCount(){return d(b).reviewPending.length},get allPendingCount(){return d(b).reviewAllPending.length},onConfirmAccept:()=>le("accepted"),onConfirmDismiss:()=>le("dismissed"),onCancel:()=>y(p,null),onRequestAccept:()=>y(p,"accept"),onRequestDismiss:()=>y(p,"dismiss"),get reduceMotion(){return e.reduceMotion},get confirmRef(){return d(v)},set confirmRef(ie){y(v,ie,!0)}});var ze=x(De,2);{var Ge=ie=>{var ve=n7(),Ye=w(ve),ut=w(Ye);j(()=>J(ut,d(k)?"No annotations match filters.":"No annotations yet. Open a document to get started.")),P("click",ve,O),S(ie,ve)},Ce=ie=>{var ve=i7(),Ye=w(ve);nt(Ye,17,()=>d(b).pending,Te=>Te.id,(Te,ce)=>{const Oe=L(()=>e.activeAnnotationId===d(ce).id);{let He=L(()=>d(g).get(d(ce).id)??[]),it=L(()=>r()===d(ce).id),Xe=L(()=>cm(d(ce))?B:void 0),Re=L(()=>um(d(ce))?Z:void 0),ot=L(()=>pm(d(ce))?M:void 0),tt=L(()=>hm(d(ce))?A:void 0),at=L(()=>fm(d(ce))?I:void 0),_t=L(()=>dm(d(ce))?N:void 0),Fe=L(()=>{var Ft;return((Ft=d(Y))==null?void 0:Ft.id)===d(ce).id?d(Y):null}),dt=L(()=>d(se).has(d(ce).id)),ht=L(()=>d(ce).author==="import"&&d(ce).type==="note"?me:void 0);gv(Te,{get annotation(){return d(ce)},get replies(){return d(He)},get isReviewTarget(){return d(Oe)},get claudeTyping(){return d(it)},lifecycleMotion:!0,get reduceMotion(){return e.reduceMotion},get exitModes(){return R},get onAccept(){return d(Xe)},get onDismiss(){return d(Re)},get onRemove(){return d(ot)},get onSendToClaude(){return d(tt)},get onEdit(){return d(at)},get onReply(){return d(_t)},get openRequest(){return d(Fe)},onClick:()=>e.review.scrollToAnnotation(d(ce)),get selected(){return d(dt)},get onToggleSelect(){return d(ht)}})}});var ut=x(Ye,2);{var fe=Te=>{var ce=r7(),Oe=w(ce),He=w(Oe),it=x(Oe,2);nt(it,21,()=>d(b).resolved,Xe=>Xe.id,(Xe,Re)=>{{let ot=L(()=>d(g).get(d(Re).id)??[]),tt=L(()=>e.review.getRecentlyResolved().has(d(Re).id));gv(Xe,{get annotation(){return d(Re)},get replies(){return d(ot)},get onUndo(){return e.review.undoResolveAnnotation},get undoable(){return d(tt)},onClick:()=>e.review.scrollToAnnotation(d(Re))})}}),j(()=>J(He,`${d(b).resolved.length??""} resolved`)),S(Te,ce)};W(ut,Te=>{d(b).resolved.length>0&&Te(fe)})}St(ve,Te=>y(q,Te),()=>d(q)),P("click",ve,O),S(ie,ve)};W(ze,ie=>{d(b).filtered.length===0?ie(Ge):ie(Ce,-1)})}St(G,ie=>y(m,ie),()=>d(m)),Tr(G,(ie,ve)=>jt==null?void 0:jt(ie,ve),()=>"y"),j(()=>{J(Ee,`${d(b).allPending.length??""} pending annotation${d(b).allPending.length!==1?"s":""}`),J(ke,`${d(C)??""} ${d(b).filtered.length??""}`)}),P("click",D,()=>y(h,!d(h))),S(t,G),Ke()}et(["click"]);var s7=T('<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>'),a7=T(`<span style="
72
+ flex-shrink: 0;
73
+ font-family: var(--tandem-font-mono);
74
+ font-size: var(--tandem-text-2xs, 10px);
75
+ font-weight: 500;
76
+ color: var(--tandem-fg-subtle);
77
+ background: var(--tandem-surface-muted);
78
+ border-radius: var(--tandem-r-pill);
79
+ padding: 0 var(--tandem-space-1);
80
+ min-width: 16px;
81
+ text-align: center;
82
+ line-height: 16px;
83
+ "> </span>`),l7=T('<li><button><span class="outline-tick svelte-or41wm" aria-hidden="true"></span> <span style="flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;"> </span> <!></button></li>'),c7=T('<ul style="list-style: none; margin: 0; padding: 0;"></ul>'),u7=T('<nav data-testid="outline-panel" aria-label="Document outline" style="display: flex; flex-direction: column; flex: 1; overflow-y: auto;"><div class="outline-header-label tandem-ui svelte-or41wm">Outline</div> <div style="padding: var(--tandem-space-3) var(--tandem-space-3) var(--tandem-space-2);"><div class="outline-search-pill svelte-or41wm"><svg class="outline-search-icon svelte-or41wm" width="14" height="14" viewBox="0 0 16 16" fill="none" aria-hidden="true"><circle cx="7" cy="7" r="4.3" stroke="currentColor" stroke-width="1.4" fill="none"></circle><line x1="10.2" y1="10.2" x2="13.5" y2="13.5" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"></line></svg> <input type="search" placeholder="Search in document…" data-testid="outline-search-input" aria-label="Search document" class="outline-search-input svelte-or41wm"/></div></div> <div class="tandem-scroll-fade-y" style="flex: 1; overflow-y: auto; padding: var(--tandem-space-3) var(--tandem-space-3);"><!></div></nav>');function dx(t,e){We(e,!0);let n=Ue(e,"annotations",19,()=>[]),r=Ue(e,"focusTrigger",3,0),i=Ue(e,"activeFilterType",3,"all"),o=Ue(e,"activeFilterAuthor",3,"all"),s=Ue(e,"activeFilterStatus",3,"all"),a=F(Qe([])),l=F(-1),c=F(Qe([])),u=F(""),f=F(null),h=F(-1);he(()=>{const R=e.editor;if(!R||R.isDestroyed){y(a,[],!0);return}y(a,ev(R),!0),At(()=>{y(c,d(c).slice(0,d(a).length),!0),d(l)>=d(a).length&&y(l,Math.max(0,d(a).length-1),!0)});const B=()=>{y(a,ev(R),!0),y(c,d(c).slice(0,d(a).length),!0),d(l)>=d(a).length&&y(l,Math.max(0,d(a).length-1),!0)};return R.on("update",B),()=>{R.isDestroyed||R.off("update",B),y(a,[],!0)}}),he(()=>{var R,B;r()>0&&((R=d(f))==null||R.focus(),(B=d(f))==null||B.select())}),he(()=>{const R=e.editor;if(!R||R.isDestroyed)return;const B=R.view.dom.closest(".editor-scroll")??R.view.dom.parentElement;function Z(){if(!R||R.isDestroyed||d(a).length===0){y(h,-1);return}const Y=((B==null?void 0:B.getBoundingClientRect().top)??0)+48;let X=-1;for(let ae=0;ae<d(a).length;ae++)try{R.view.coordsAtPos(d(a)[ae].pos+1).top<=Y&&(X=ae)}catch{}y(h,X,!0)}return Z(),B==null||B.addEventListener("scroll",Z),()=>B==null?void 0:B.removeEventListener("scroll",Z)});function p(){const R=e.editor;!R||R.isDestroyed||(d(u)?R.commands.find({query:d(u),caseSensitive:!1,wholeWord:!1,regexMode:!1}):R.commands.findClose())}function m(R){var B,Z,q,Y;R.key==="Enter"?(R.preventDefault(),R.shiftKey?(B=e.editor)==null||B.commands.findPrev():(Z=e.editor)==null||Z.commands.findNext()):R.key==="Escape"&&(R.preventDefault(),y(u,""),(q=e.editor)==null||q.commands.findClose(),(Y=d(f))==null||Y.blur())}const v=L(()=>{const R=e.editor;if(!R||R.isDestroyed||d(a).length===0)return[];const B=R.state.doc.content.size,Z=[];for(const q of n()){if(i()!=="all"){if(i()==="with-replacement"){if(!q.suggestedText)continue}else if(q.type!==i())continue}if(!(o()!=="all"&&q.author!==o())&&!(s()!=="all"&&q.status!==s()))try{Z.push(Rs(R.state.doc,q.range.from))}catch{}}return d(a).map((q,Y)=>{const X=Y+1<d(a).length?d(a)[Y+1].pos:B;return Z.filter(ae=>ae>=q.pos&&ae<X).length})});function g(R,B){const Z=e.editor;if(!Z||Z.isDestroyed)return;const{state:q}=Z;try{const Y=q.doc.resolve(R.pos+1),X=$e.near(Y);Z.view.dispatch(q.tr.setSelection(X)),Z.view.focus();const{node:ae}=Z.view.domAtPos(R.pos+1),ne=ae instanceof Element?ae:ae.parentElement,te=Z.view.dom.closest(".editor-scroll")??Z.view.dom.parentElement;if(ne&&te){const le=ne.getBoundingClientRect().top,se=te.getBoundingClientRect().top;te.scrollTop+=le-se-te.clientHeight*.05}}catch{}y(l,B,!0)}function b(R){var B,Z,q,Y;if(d(a).length!==0)if(R.key==="ArrowDown"){R.preventDefault();const X=(d(l)+1)%d(a).length;y(l,X),(B=d(c)[X])==null||B.focus()}else if(R.key==="ArrowUp"){R.preventDefault();const X=(d(l)-1+d(a).length)%d(a).length;y(l,X),(Z=d(c)[X])==null||Z.focus()}else R.key==="Home"?(R.preventDefault(),y(l,0),(q=d(c)[0])==null||q.focus()):R.key==="End"&&(R.preventDefault(),y(l,d(a).length-1),(Y=d(c)[d(a).length-1])==null||Y.focus())}var _=u7(),k=x(w(_),2),C=w(k),E=x(w(C),2);St(E,R=>y(f,R),()=>d(f));var I=x(k,2),A=w(I);{var M=R=>{var B=s7();S(R,B)},N=R=>{var B=c7();nt(B,21,()=>d(a),zl,(Z,q,Y)=>{const X=L(()=>d(h)===Y),ae=L(()=>d(v)[Y]??0);var ne=l7(),te=w(ne),le=w(te),se=x(le,2),me=w(se),K=x(se,2);{var H=O=>{var G=a7(),z=w(G);j(()=>{V(G,"title",`${d(ae)??""} annotation${d(ae)!==1?"s":""}`),J(z,d(ae))}),S(O,G)};W(K,O=>{d(ae)>0&&O(H)})}St(te,(O,G)=>d(c)[G]=O,O=>{var G;return(G=d(c))==null?void 0:G[O]},()=>[Y]),j(()=>{V(te,"data-testid",`outline-heading-${d(q).level}-${Y}`),V(te,"tabindex",d(l)===Y||d(l)===-1&&Y===0?0:-1),Me(te,`
84
+ display: flex; align-items: center; width: 100%; text-align: left;
85
+ padding: var(--tandem-space-1) var(--tandem-space-3);
86
+ padding-left: calc(var(--tandem-space-1) + ${(d(q).level-1)*12}px);
87
+ font-size: ${d(q).level===1?"var(--tandem-text-sm)":"var(--tandem-text-xs)"};
88
+ font-weight: ${d(q).level===1?600:d(q).level===2?500:400};
89
+ color: ${d(X)?"var(--tandem-accent)":d(q).level===1?"var(--tandem-fg)":d(q).level===2?"var(--tandem-fg-subtle)":"var(--tandem-fg-muted)"};
90
+ background: ${d(X)?"var(--tandem-accent-bg)":"none"};
91
+ border: none; cursor: pointer; line-height: 1.5;
92
+ transition: color 0.1s, background 0.1s;
93
+ gap: var(--tandem-space-2);
94
+ `),V(te,"title",d(q).text),Me(le,d(X)?"background-color: var(--tandem-accent); opacity: 1;":""),J(me,d(q).text||"(untitled)")}),P("click",te,()=>g(d(q),Y)),hn("focus",te,()=>y(l,Y,!0)),hn("mouseenter",te,O=>{d(X)||(O.currentTarget.style.background="var(--tandem-surface-hover, var(--tandem-surface-muted))")}),hn("mouseleave",te,O=>{d(X)||(O.currentTarget.style.background="none")}),S(Z,ne)}),S(R,B)};W(A,R=>{d(a).length===0?R(M):R(N,-1)})}Tr(I,(R,B)=>jt==null?void 0:jt(R,B),()=>"y"),P("keydown",_,b),P("input",E,p),P("keydown",E,m),Xn(E,()=>d(u),R=>y(u,R)),S(t,_),Ke()}et(["keydown","input","click"]);var d7=T("<div><!></div>");function xg(t,e){We(e,!0);let n=dM(e,["$$slots","$$events","$$legacy","kind","visible"]);const r=L(()=>e.visible!==void 0?`display: ${e.visible?"flex":"none"}; flex-direction: column; flex: 1; min-height: 0;${e.kind==="outline"?" padding-bottom: var(--tandem-status-clearance-total, 88px);":""}`:void 0);var i=Mt(),o=Ie(i);{var s=u=>{var f=d7(),h=w(f);{var p=g=>{lx(g,Bc(()=>n,{get visible(){return e.visible}}))},m=g=>{dx(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=>{ux(g,Bc(()=>n))};W(h,g=>{e.kind==="chat"?g(p):e.kind==="outline"?g(m,1):g(v,-1)})}j(()=>Me(f,d(r))),S(u,f)},a=u=>{lx(u,Bc(()=>n))},l=u=>{dx(u,{get editor(){return e.editor},get annotations(){return e.annotations},get focusTrigger(){return e.focusTrigger},get activeFilterType(){return e.activeFilterType}})},c=u=>{ux(u,Bc(()=>n))};W(o,u=>{d(r)?u(s):e.kind==="chat"?u(a,1):e.kind==="outline"?u(l,2):u(c,-1)})}S(t,i),Ke()}var f7=T('<span style="color: var(--tandem-error-fg-strong); font-size: var(--tandem-text-xs); max-width: 200px;"> </span>'),h7=T('<button type="button" class="tandem-banner__cta" data-testid="convert-to-markdown-btn"> </button>'),p7=T(`<div class="tandem-banner tandem-banner--info" role="status" aria-live="polite" data-testid="review-only-banner"><span class="tandem-banner__message">This document is open in review-only mode. You can add annotations and review, but cannot
95
+ edit directly.</span> <!> <!> <button type="button" class="tandem-banner__dismiss" data-testid="review-only-dismiss" aria-label="Dismiss review-only banner"><svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M6 6l12 12M6 18L18 6"></path></svg></button></div>`);function m7(t,e){We(e,!0);const n="tandem:reviewOnlyBannerDismissed";function r(){try{return localStorage.getItem(n)==="true"}catch{return!1}}let i=F(Qe(r())),o=F(!1),s=F(null);async function a(){if(!(!e.documentId||d(o))){y(o,!0),y(s,null);try{const h=await fetch(`${On}${QM}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({documentId:e.documentId})});if(!h.ok){const p=await h.json().catch(()=>null);y(s,(p==null?void 0:p.message)??`Conversion failed (HTTP ${h.status}).`,!0)}}catch{y(s,"Could not reach the server.")}finally{y(o,!1)}}}function l(){try{localStorage.setItem(n,"true")}catch{}y(i,!0)}var c=Mt(),u=Ie(c);{var f=h=>{var p=p7(),m=x(w(p),2);{var v=k=>{var C=f7(),E=w(C);j(()=>J(E,d(s))),S(k,C)};W(m,k=>{d(s)&&k(v)})}var g=x(m,2);{var b=k=>{var C=h7(),E=w(C);j(()=>{C.disabled=d(o),J(E,d(o)?"Converting…":"Convert to Markdown")}),P("click",C,a),S(k,C)};W(g,k=>{e.documentId&&k(b)})}var _=x(g,2);P("click",_,l),S(h,p)};W(u,h=>{e.visible&&!d(i)&&h(f)})}S(t,c),Ke()}et(["click"]);let kg=null;async function g7(t){if(kg!==null)return kg;const e=await fetch(`${On}${Yy}`,{signal:t});if(!e.ok)throw new Error(`${Yy} responded ${e.status} ${e.statusText}`);const n=await e.json();return kg=n,n}function mm(t){let e=F(null),n=F(!1);return he(()=>{if(!t())return;let r=!1;const i=new AbortController,o=setTimeout(()=>i.abort(),3e3);return y(n,!0),g7(i.signal).then(s=>{r||y(e,s,!0)}).catch(s=>{s instanceof Error&&s.name!=="AbortError"&&console.warn("[useAppInfo] failed to load /api/info:",s)}).finally(()=>{clearTimeout(o),r||y(n,!1)}),()=>{r=!0,clearTimeout(o),i.abort()}}),{get info(){return d(e)},get loading(){return d(n)}}}var v7=T('<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 iE(t,e){We(e,!0);const n="font-size: 11px; font-weight: 600; color: var(--tandem-fg); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px;";var r=v7(),i=Ie(r),o=w(i);Me(o,n);var s=x(o,2),a=w(s),l=x(i,2),c=w(l);Me(c,n);var u=x(c,2),f=w(u);j(()=>{Bn(a,e.settings.highContrast),Bn(f,e.settings.annotationPatterns)}),P("change",a,h=>e.onUpdate({highContrast:h.target.checked})),P("change",f,h=>e.onUpdate({annotationPatterns:h.target.checked})),S(t,r),Ke()}et(["change"]);function Gs(t,e,n,r){return{handleKeyDown:s=>{var b;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=t(),u=l.indexOf(c),f=l.length-1;let h;a==="Home"?h=0:a==="End"?h=f:a==="ArrowLeft"||a==="ArrowUp"?h=u<=0?f:u-1:h=u>=f?0:u+1;const p=l[h];n(p);const m=s.currentTarget,v=m==null?void 0:m.querySelectorAll('[role="radio"]'),g=e.indexOf(p);(b=v==null?void 0:v[g])==null||b.focus()},tabIndexFor:s=>{const l=t();return s===l?0:-1}}}var b7=T('<button role="radio"> </button>'),y7=T('<button role="radio"> </button>'),w7=T('<button role="radio"> </button>'),x7=T('<button role="radio"> </button>'),k7=T('<div style="display: flex; align-items: center; gap: var(--tandem-space-2);"><span style="flex: 0 0 7rem; font-size: 11px; color: var(--tandem-fg-muted);"> </span> <div role="radiogroup" tabindex="0" style="display: flex; gap: var(--tandem-space-2); flex: 1;"></div></div>'),_7=T('<button role="radio"> </button>'),C7=T('<label style="display: flex; align-items: center; gap: var(--tandem-space-2); cursor: pointer; font-size: var(--tandem-text-sm); color: var(--tandem-fg); min-height: var(--tandem-space-5);"><input type="checkbox" style="accent-color: var(--tandem-accent);"/> <span> </span></label>'),S7=T(`<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 data-testid="font-by-extension-section"><div style="display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px;"><div id="settings-font-by-ext-label">Default font by file type</div> <button data-testid="font-by-extension-reset" type="button">Reset to defaults</button></div> <div style="display: flex; flex-direction: column; 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);">Each file type uses this font; files with no specific choice fall back to the Editor Font above.</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><div>Decorations</div> <!> <div style="font-size: var(--tandem-text-2xs); color: var(--tandem-fg-subtle); margin-top: var(--tandem-space-1);">Turn a type off to hide its inline marks in the editor. Annotation cards in the
96
+ side panel stay visible. Display-only — hiding Notes never affects what Claude reads.</div></div> <div><label data-testid="reduce-motion-toggle" style="display: flex; align-items: center; gap: var(--tandem-space-2); cursor: pointer; font-size: var(--tandem-text-sm); color: var(--tandem-fg); min-height: var(--tandem-space-5);"><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> <div><label data-testid="appearance-formatting-bar" style="display: flex; align-items: center; gap: var(--tandem-space-2); cursor: pointer; font-size: var(--tandem-text-sm); color: var(--tandem-fg); min-height: var(--tandem-space-5);"><input type="checkbox" style="accent-color: var(--tandem-accent);"/> <span>Show formatting bar</span></label> <div style="font-size: var(--tandem-text-2xs); color: var(--tandem-fg-subtle); margin-top: var(--tandem-space-1);">The persistent toolbar above the document. When hidden, formatting stays available
97
+ in the selection popup, and Ctrl+Z / Ctrl+Y still undo and redo.</div></div> <div><label data-testid="appearance-show-raw-markdown" style="display: flex; align-items: center; gap: var(--tandem-space-2); cursor: pointer; font-size: var(--tandem-text-sm); color: var(--tandem-fg); min-height: var(--tandem-space-5);"><input type="checkbox" style="accent-color: var(--tandem-accent);"/> <span>Show raw markdown</span></label> <div style="font-size: var(--tandem-text-2xs); color: var(--tandem-fg-subtle); margin-top: var(--tandem-space-1);">Footnotes, reference-style links, and inline HTML that Tandem keeps as raw source.
98
+ When hidden they stay in the file and always save — only the on-screen markers are
99
+ hidden.</div></div>`,1);function oE(t,e){We(e,!0);const n=[{format:"md",label:"Markdown (.md)"},{format:"docx",label:"Word (.docx)"},{format:"html",label:"HTML (.html)"},{format:"txt",label:"Plain text (.txt)"}],r=[["sans","Sans"],["serif","Serif"],["mono","Mono"]];function i(pe){var oe;return((oe=e.settings.fontByExtension)==null?void 0:oe[pe])??e.settings.editorFont}function o(pe,oe){e.onUpdate({fontByExtension:{...e.settings.fontByExtension,[pe]:oe}})}function s(){e.onUpdate({fontByExtension:{}})}const a=L(()=>Object.keys(e.settings.fontByExtension??{}).length>0),l="font-size: 11px; font-weight: 600; color: var(--tandem-fg); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px;",c=[["showAuthorship","appearance-show-authorship","Authorship colors"],["showComments","appearance-show-comments","Comments"],["showHighlights","appearance-show-highlights","Highlights"],["showNotes","appearance-show-notes","Notes (private)"]];function u(pe,oe){return["flex: 1;","padding: var(--tandem-space-2);","min-height: 24px;",`border: 2px solid ${pe?"var(--tandem-accent)":"var(--tandem-border)"};`,"border-radius: var(--tandem-r-3);",`background: ${pe?"var(--tandem-accent-bg)":"var(--tandem-surface)"};`,"cursor: pointer;","text-align: center;","font-size: 11px;",`color: ${pe?"var(--tandem-accent-fg-strong)":"var(--tandem-fg-muted)"};`,`font-weight: ${pe?600:400};`,"opacity: 1;","transition: border-color 0.15s, background 0.15s;"].join(" ")}const f=Gs(()=>e.settings.theme,["light","warm","dark","system"],pe=>e.onUpdate({theme:pe})),h=Gs(()=>e.settings.primaryTab,["chat","annotations"],pe=>e.onUpdate({primaryTab:pe})),p=Gs(()=>e.settings.textSize,["s","m","l"],pe=>e.onUpdate({textSize:pe})),m=Gs(()=>e.settings.editorFont,["sans","serif","mono"],pe=>e.onUpdate({editorFont:pe})),v=Gs(()=>e.settings.density,["compact","cozy","spacious"],pe=>e.onUpdate({density:pe})),g={};for(const pe of n)g[pe.format]=Gs(()=>i(pe.format),["sans","serif","mono"],oe=>o(pe.format,oe));var b=S7(),_=Ie(b),k=w(_);Me(k,l);var C=x(k,2);nt(C,20,()=>["light","warm","dark","system"],pe=>pe,(pe,oe)=>{var De=b7(),ze=w(De);j((Ge,Ce)=>{V(De,"data-testid",`theme-${oe}-btn`),V(De,"aria-checked",e.settings.theme===oe),V(De,"tabindex",Ge),Me(De,Ce),J(ze,oe==="light"?"Light":oe==="warm"?"Warm":oe==="dark"?"Dark":"System")},[()=>f.tabIndexFor(oe),()=>u(e.settings.theme===oe)]),P("click",De,()=>e.onUpdate({theme:oe})),S(pe,De)});var E=x(_,2),I=w(E);Me(I,l);var A=x(I,2),M=w(A),N=x(M,2),R=x(E,2),B=w(R);Me(B,l);var Z=x(B,2);nt(Z,20,()=>["s","m","l"],pe=>pe,(pe,oe)=>{var De=y7(),ze=w(De);j((Ge,Ce)=>{V(De,"data-testid",`text-size-${oe}-btn`),V(De,"aria-checked",e.settings.textSize===oe),V(De,"tabindex",Ge),Me(De,Ce),J(ze,oe==="s"?"Small":oe==="m"?"Medium":"Large")},[()=>p.tabIndexFor(oe),()=>u(e.settings.textSize===oe)]),P("click",De,()=>e.onUpdate({textSize:oe})),S(pe,De)});var q=x(R,2),Y=w(q);Me(Y,l);var X=x(Y,2),ae=x(w(X),2),ne=x(q,2),te=w(ne);Me(te,l);var le=x(te,2);nt(le,20,()=>[["sans","Sans-serif"],["serif","Serif (Source Serif 4)"],["mono","Monospace"]],([pe,oe])=>pe,(pe,oe)=>{var De=L(()=>jd(oe,2));let ze=()=>d(De)[0],Ge=()=>d(De)[1];var Ce=w7(),ie=w(Ce);j((ve,Ye)=>{V(Ce,"data-testid",`editor-font-${ze()}-btn`),V(Ce,"aria-checked",e.settings.editorFont===ze()),V(Ce,"tabindex",ve),Me(Ce,Ye),J(ie,Ge())},[()=>m.tabIndexFor(ze()),()=>u(e.settings.editorFont===ze())]),P("click",Ce,()=>e.onUpdate({editorFont:ze()})),S(pe,Ce)});var se=x(ne,2),me=w(se),K=w(me);Me(K,`${l} margin-bottom: 0;`);var H=x(K,2),O=x(me,2);nt(O,21,()=>n,pe=>pe.format,(pe,oe)=>{var De=k7(),ze=w(De),Ge=w(ze),Ce=x(ze,2);nt(Ce,21,()=>r,([ie,ve])=>ie,(ie,ve)=>{var Ye=L(()=>jd(d(ve),2));let ut=()=>d(Ye)[0],fe=()=>d(Ye)[1];var Te=x7(),ce=w(Te);j((Oe,He,it)=>{V(Te,"data-testid",`font-by-extension-${d(oe).format}-${ut()}`),V(Te,"aria-checked",Oe),V(Te,"tabindex",He),Me(Te,it),J(ce,fe())},[()=>i(d(oe).format)===ut(),()=>g[d(oe).format].tabIndexFor(ut()),()=>u(i(d(oe).format)===ut())]),P("click",Te,()=>o(d(oe).format,ut())),S(ie,Te)}),j(()=>{V(De,"data-testid",`font-by-extension-row-${d(oe).format}`),J(Ge,d(oe).label),V(Ce,"aria-label",`Default font for ${d(oe).label}`)}),P("keydown",Ce,function(...ie){var ve;(ve=g[d(oe).format].handleKeyDown)==null||ve.apply(this,ie)}),S(pe,De)});var G=x(se,2),z=w(G);Me(z,l);var Q=x(z,2);nt(Q,20,()=>[["compact","Compact"],["cozy","Cozy"],["spacious","Spacious"]],([pe,oe])=>pe,(pe,oe)=>{var De=L(()=>jd(oe,2));let ze=()=>d(De)[0],Ge=()=>d(De)[1];var Ce=_7(),ie=w(Ce);j((ve,Ye)=>{V(Ce,"data-testid",`density-${ze()}-btn`),V(Ce,"aria-checked",e.settings.density===ze()),V(Ce,"tabindex",ve),Me(Ce,Ye),J(ie,Ge())},[()=>v.tabIndexFor(ze()),()=>u(e.settings.density===ze())]),P("click",Ce,()=>e.onUpdate({density:ze()})),S(pe,Ce)});var ge=x(G,2),ye=w(ge);Me(ye,l);var Se=x(ye,2);nt(Se,17,()=>c,([pe,oe,De])=>pe,(pe,oe)=>{var De=L(()=>jd(d(oe),3));let ze=()=>d(De)[0],Ge=()=>d(De)[1],Ce=()=>d(De)[2];var ie=C7(),ve=w(ie),Ye=x(ve,2),ut=w(Ye);j(()=>{V(ie,"data-testid",Ge()),Bn(ve,e.settings[ze()]),J(ut,Ce())}),P("change",ve,fe=>e.onUpdate({[ze()]:fe.target.checked,...e.settings.decorationsMuted?{decorationsMuted:!1}:{}})),S(pe,ie)});var ee=x(ge,2),de=w(ee),xe=w(de),Ee=x(ee,2),D=w(Ee),$=w(D),ke=x(Ee,2),we=w(ke),Ae=w(we);j((pe,oe,De,ze)=>{V(M,"aria-checked",e.settings.primaryTab==="chat"),V(M,"tabindex",pe),Me(M,oe),V(N,"aria-checked",e.settings.primaryTab==="annotations"),V(N,"tabindex",De),Me(N,ze),Sr(ae,e.settings.accentHue),H.disabled=!d(a),Me(H,`background: none; border: none; padding: 0; font-size: var(--tandem-text-2xs); color: ${d(a)?"var(--tandem-accent-fg-strong)":"var(--tandem-fg-subtle)"}; cursor: ${d(a)?"pointer":"default"}; text-decoration: ${d(a)?"underline":"none"};`),Bn(xe,e.settings.reduceMotion),Bn($,e.settings.formattingBarVisible),Bn(Ae,e.settings.showRawMarkdown)},[()=>h.tabIndexFor("chat"),()=>u(e.settings.primaryTab==="chat"),()=>h.tabIndexFor("annotations"),()=>u(e.settings.primaryTab==="annotations")]),P("keydown",C,function(...pe){var oe;(oe=f.handleKeyDown)==null||oe.apply(this,pe)}),P("keydown",A,function(...pe){var oe;(oe=h.handleKeyDown)==null||oe.apply(this,pe)}),P("click",M,()=>e.onUpdate({primaryTab:"chat"})),P("click",N,()=>e.onUpdate({primaryTab:"annotations"})),P("keydown",Z,function(...pe){var oe;(oe=p.handleKeyDown)==null||oe.apply(this,pe)}),P("input",ae,pe=>e.onUpdate({accentHue:Number(pe.target.value)})),P("keydown",le,function(...pe){var oe;(oe=m.handleKeyDown)==null||oe.apply(this,pe)}),P("click",H,s),P("keydown",Q,function(...pe){var oe;(oe=v.handleKeyDown)==null||oe.apply(this,pe)}),P("change",xe,pe=>e.onUpdate({reduceMotion:pe.target.checked})),P("change",$,pe=>e.onUpdate({formattingBarVisible:pe.target.checked})),P("change",Ae,pe=>e.onUpdate({showRawMarkdown:pe.target.checked})),S(t,b),Ke()}et(["keydown","click","input","change"]);var E7=T('<button type="button" role="radio"> </button>'),A7=T(`<div><div id="settings-measure-label">Reading Measure</div> <div style="font-size: 10px; color: var(--tandem-fg-subtle); margin-bottom: 8px;">The line length of the editor text. A stable measure keeps lines readable
100
+ regardless of panel state.</div> <div role="radiogroup" aria-labelledby="settings-measure-label" tabindex="0" style="display: flex; gap: var(--tandem-space-1); border: 1px solid var(--tandem-border); border-radius: var(--tandem-r-2); padding: 2px;"></div> <div style="font-size: 10px; color: var(--tandem-fg-subtle); margin-top: 6px;"> </div></div>`);function sE(t,e){We(e,!0);const n="font-size: 11px; font-weight: 600; color: var(--tandem-fg); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px;",r=[{value:"narrow",label:"Narrow",hint:"58 characters"},{value:"comfortable",label:"Comfortable",hint:"68 characters"},{value:"wide",label:"Wide",hint:"82 characters"},{value:"full",label:"Full",hint:"Fills the editor"}],i=Gs(()=>e.settings.editorMeasure,r.map(f=>f.value),f=>e.onUpdate({editorMeasure:f})),o=L(()=>{var f;return((f=r.find(h=>h.value===e.settings.editorMeasure))==null?void 0:f.hint)??""});var s=A7(),a=w(s);Me(a,n);var l=x(a,4);nt(l,21,()=>r,f=>f.value,(f,h)=>{const p=L(()=>e.settings.editorMeasure===d(h).value);var m=E7(),v=w(m);j(g=>{V(m,"aria-checked",d(p)),V(m,"tabindex",g),V(m,"data-testid",`editor-measure-${d(h).value}`),Me(m,`flex: 1; padding: 6px 4px; border: none; border-radius: var(--tandem-r-1); cursor: pointer; font-size: 11px; font-weight: ${d(p)?600:400}; background: ${d(p)?"var(--tandem-accent)":"transparent"}; color: ${d(p)?"var(--tandem-accent-fg)":"var(--tandem-fg)"};`),J(v,d(h).label)},[()=>i.tabIndexFor(d(h).value)]),P("click",m,()=>e.onUpdate({editorMeasure:d(h).value})),S(f,m)});var c=x(l,2),u=w(c);j(()=>J(u,d(o))),P("keydown",l,function(...f){var h;(h=i.handleKeyDown)==null||h.apply(this,f)}),S(t,s),Ke()}et(["keydown","click"]);var T7=T('<details class="cs-details svelte-x76129"><summary class="cs-summary svelte-x76129"><span class="cs-chevron svelte-x76129" aria-hidden="true">›</span> </summary> <div class="cs-body svelte-x76129"><!></div></details>');function aE(t,e){const n=Ue(e,"defaultOpen",3,!1);var r=T7(),i=w(r),o=x(w(i)),s=x(i,2),a=w(s);wd(a,()=>e.children),j(()=>{V(r,"data-testid",e.testid),r.open=n(),V(i,"data-testid",e.testid?`${e.testid}-toggle`:void 0),J(o,` ${e.label??""}`)}),S(t,r)}var M7=T('<span style="color: var(--tandem-fg-subtle);"> </span>'),D7=T('<button type="button" data-testid="network-restart-sidecar"> </button>'),O7=T('<span style="font-size: 10px; color: var(--tandem-fg-subtle);">Run <code>tandem stop &amp;&amp; tandem start</code> to restart</span>'),I7=T('<div style="font-size: 10px; color: var(--tandem-error-fg); margin-top: var(--tandem-space-1);"> </div>'),R7=T("<span><strong>Host:</strong> </span>"),N7=T('<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 &lt;N&gt;</code>.</div></div>'),P7=T("<option> </option>"),L7=T('<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>'),F7=T('<!> <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),z7=T('<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> <!>',1);function lE(t,e){We(e,!0);const n=mm(()=>e.open),r=Pt();let i=F(null),o=F(!1);async function s(){if(r){y(o,!0),y(i,null);try{const{invoke:K}=await yn(async()=>{const{invoke:H}=await import("./core-DhEqZVGG.js");return{invoke:H}},[]);await K("restart_sidecar")}catch(K){y(i,K instanceof Error?K.message:String(K),!0)}finally{y(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;",u="font-size: 10px; color: var(--tandem-fg-subtle); margin-top: var(--tandem-space-1);",f=L(()=>{var K;return(K=n.info)==null?void 0:K.transport}),h=L(()=>{var K;return(K=n.info)==null?void 0:K.bindHost}),p=L(()=>{var K;return(K=n.info)==null?void 0:K.bindPort}),m=L(()=>d(f)==="http"),v=L(()=>{var K;return(K=n.info)==null?void 0:K.tokenRotatedAt});var g=z7(),b=Ie(g),_=w(b);Me(_,l);var k=x(_,2),C=w(k),E=x(C,2),I=w(E),A=x(I);{var M=K=>{var H=M7(),O=w(H);j(()=>J(O,`· ${e.reconnectAttempts??""} retry attempt${e.reconnectAttempts===1?"":"s"}`)),S(K,H)};W(A,K=>{e.reconnectAttempts>0&&K(M)})}var N=x(E,2);{var R=K=>{var H=D7(),O=w(H);j(()=>{H.disabled=d(o),Me(H,`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: ${d(o)?.5:1};`),J(O,d(o)?"Restarting…":"Restart sidecar")}),P("click",H,s),S(K,H)},B=K=>{var H=O7();S(K,H)};W(N,K=>{r?K(R):K(B,-1)})}var Z=x(k,2);{var q=K=>{var H=I7(),O=w(H);j(()=>J(O,d(i))),S(K,H)};W(Z,K=>{d(i)&&K(q)})}var Y=x(b,2),X=w(Y);Me(X,l);var ae=x(X,2),ne=w(ae),te=x(w(ne)),le=x(ne,2);{var se=K=>{var H=R7(),O=x(w(H));j(()=>J(O,` ${d(h)??""}`)),S(K,H)};W(le,K=>{d(h)&&K(se)})}var me=x(Y,2);aE(me,{label:"Advanced",testid:"network-advanced",children:(K,H)=>{var O=F7(),G=Ie(O);{var z=oe=>{var De=N7(),ze=w(De);Me(ze,l);var Ge=x(ze,2),Ce=w(Ge),ie=x(Ge,2);Me(ie,u),j(()=>J(Ce,d(p)??"—")),S(oe,De)};W(G,oe=>{d(m)&&oe(z)})}var Q=x(G,2),ge=w(Q);Me(ge,l);var ye=x(w(ge)),Se=w(ye),ee=x(ge,2),de=x(Q,2),xe=w(de);Me(xe,l);var Ee=x(xe,2);nt(Ee,21,()=>a,oe=>oe.value,(oe,De)=>{var ze=P7(),Ge=w(ze),Ce={};j(()=>{J(Ge,d(De).label),Ce!==(Ce=d(De).value)&&(ze.value=(ze.__value=d(De).value)??"")}),S(oe,ze)});var D;xb(Ee);var $=x(de,2);Me($,c);var ke=w($),we=x($,2);Me(we,u);var Ae=x(we,2);{var pe=oe=>{var De=L7(),ze=w(De);Me(ze,l);var Ge=x(ze,2),Ce=w(Ge),ie=x(Ge,2);Me(ie,u),j(ve=>J(Ce,ve),[()=>d(v)===null?"Auth token not yet created":`Last rotated: ${new Date(d(v)).toLocaleString()}`]),S(oe,De)};W(Ae,oe=>{d(v)!==void 0&&oe(pe)})}j(()=>{J(Se,`${e.settings.degradedBannerDelayMs/1e3}s`),Sr(ee,e.settings.degradedBannerDelayMs),D!==(D=e.settings.sidecarRetryStrategy)&&(Ee.value=(Ee.__value=e.settings.sidecarRetryStrategy)??"",zp(Ee,e.settings.sidecarRetryStrategy)),Bn(ke,e.settings.holdAnnotationsWhileOffline)}),P("input",ee,oe=>e.onUpdate({degradedBannerDelayMs:Number(oe.target.value)})),P("change",Ee,oe=>e.onUpdate({sidecarRetryStrategy:oe.target.value})),P("change",ke,oe=>e.onUpdate({holdAnnotationsWhileOffline:oe.target.checked})),S(K,O)},$$slots:{default:!0}}),j(K=>{Me(C,`width: 8px; height: 8px; border-radius: var(--tandem-r-circle); background: ${e.connected?"var(--tandem-success)":"var(--tandem-error)"}; flex-shrink: 0;`),J(I,`${e.connected?"Connected to Tandem server":"Disconnected"} `),J(te,` ${K??""}`)},[()=>d(f)?d(f).toUpperCase():"—"]),S(t,g),Ke()}et(["click","input","change"]);const B7="INVALID_BODY",H7="PATH_REJECTED",V7="LAUNCHER_IN_PROGRESS",U7="LAUNCHER_NOT_AVAILABLE",j7="NO_CLAUDE_INTEGRATION";var q7=T('<div role="alert" data-testid="settings-modal-working-directory-load-error" style="font-size: 11px; color: var(--tandem-error-fg); background: var(--tandem-error-bg); border: 1px solid var(--tandem-error-border); border-radius: var(--tandem-r-2); padding: var(--tandem-space-2);"> </div>'),W7=T('<button type="button" data-testid="settings-modal-working-directory-pick" style="font-size: 12px; padding: var(--tandem-space-2) var(--tandem-space-3); border-radius: var(--tandem-r-2); border: 1px solid var(--tandem-border); background: var(--tandem-surface-elevated); color: var(--tandem-fg); cursor: pointer;">Choose folder…</button>'),K7=T('<div role="alert" style="font-size: 11px; color: var(--tandem-error-fg);"> </div>'),G7=T('<div data-testid="settings-modal-working-directory" style="display: flex; flex-direction: column; gap: var(--tandem-space-2);"><div class="settings-section-label">Claude working directory</div> <div class="settings-hint">Folder where Claude launches. Defaults to your home directory if empty.</div> <form style="display: flex; gap: var(--tandem-space-2);"><input type="text" name="wd" data-testid="settings-modal-working-directory-input" style="flex: 1; font-size: 12px; padding: var(--tandem-space-2); border-radius: var(--tandem-r-2); border: 1px solid var(--tandem-border); background: var(--tandem-surface); color: var(--tandem-fg); font-family: var(--tandem-font-mono);"/> <button type="submit" data-testid="settings-modal-working-directory-save" style="font-size: 12px; padding: var(--tandem-space-2) var(--tandem-space-3); border-radius: var(--tandem-r-2); border: 1px solid var(--tandem-border); background: var(--tandem-surface-elevated); color: var(--tandem-fg); cursor: pointer;">Save</button></form> <div style="display: flex; gap: var(--tandem-space-2);"><!> <button type="button" data-testid="settings-modal-working-directory-reset" style="font-size: 12px; padding: var(--tandem-space-2) var(--tandem-space-3); border-radius: var(--tandem-r-2); border: 1px solid var(--tandem-border); background: transparent; color: var(--tandem-fg-muted); cursor: pointer;">Reset to default</button></div> <!></div>'),Z7=T('<div data-testid="settings-modal-cowork-suspense-fallback" style="font-size: 12px; color: var(--tandem-fg-subtle);">Loading Cowork integration...</div>'),Y7=T(`<p style="font-size: 12px; line-height: 1.5; color: var(--tandem-fg-muted); margin: 0 0 var(--tandem-space-3);">Tandem connects to any MCP-capable AI client over its MCP endpoint. Claude (Claude Code and
101
+ Claude Desktop) is the default integration — auto-configured, tested, and the only client whose
102
+ channel-push, cowork, and auto-launch extras are validated today. Other clients can connect
103
+ manually using the MCP endpoint on the Network tab.</p> <div><div class="settings-section-label">Selection Sensitivity: <span style="font-weight: 400; text-transform: none;"> </span></div> <div class="settings-hint" style="margin-bottom: 6px;">How long you must hold a selection before your AI notices it</div> <input data-testid="settings-modal-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="settings-modal-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> <label data-testid="settings-modal-margin-view-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>Margin annotation view (Word-style)</span></label> <div data-testid="settings-modal-margin-view-hint" style="font-size: 10px; color: var(--tandem-fg-subtle);">Margin columns appear where rails are collapsed — open rails hide that side.</div> <!> <!> <button type="button" data-testid="settings-modal-open-integration-wizard" style="font-size: 12px; padding: var(--tandem-space-2) var(--tandem-space-3); border-radius: var(--tandem-r-2); border: 1px solid var(--tandem-border); background: var(--tandem-surface-elevated); color: var(--tandem-fg); cursor: pointer; align-self: flex-start;">Reopen integration wizard…</button> <!>`,1);function J7(t,e){We(e,!0);function n(H){switch(H){case H7:return"Working directory must be a folder inside your home directory.";case B7:return"Working directory path is invalid.";case V7:return"Another working-directory update is in progress. Try again.";case j7:return"No Claude Code integration is configured.";case U7:return"Auto-launcher is not available in this Tandem build.";default:return"Couldn't save working directory."}}function r(){window.dispatchEvent(new CustomEvent("tandem:open-integration-wizard"))}let i=F(null),o=F(!1),s=F(null),a=F(!1),l=F(!1),c=F(null),u=!0;gr(()=>{u=!1});async function f(){var H;try{const O=await fetch(`${On}/api/integrations`);if(!u)return;if(!O.ok){y(c,`Failed to load integrations (HTTP ${O.status}).`);return}const G=await O.json();if(!u)return;const z=(H=G.integrations)==null?void 0:H.find(Q=>Q.kind==="claude-code");z&&(y(l,!0),y(i,z.workingDirectory??null,!0))}catch(O){if(!u)return;console.warn("[Settings] Failed to load workingDirectory:",O),y(c,"Couldn't load Claude working directory.")}finally{u&&y(a,!0)}}f();async function h(H){y(o,!0),y(s,null);try{const O=await fetch(`${On}${uD}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workingDirectory:H})});if(!u)return;if(!O.ok){const z=await O.json().catch(()=>({}));if(!u)return;y(s,n(z.code),!0);return}const G=await O.json();if(!u)return;y(i,G.workingDirectory??null,!0),e.notify("info","Working directory saved.")}catch(O){if(!u)return;console.warn("[Settings] Failed to save workingDirectory:",O),y(s,"Couldn't save working directory.")}finally{u&&y(o,!1)}}async function p(){let H;try{({open:H}=await yn(()=>import("./index-Dm_QtxGQ.js"),__vite__mapDeps([0,1])))}catch(O){console.warn("[Settings] Folder picker import failed:",O),e.notify("error","Folder picker plugin unavailable");return}try{const O=await H({directory:!0,multiple:!1,title:"Choose Claude working directory"});typeof O=="string"&&h(O)}catch(O){console.warn("[Settings] Folder picker open() failed:",O),e.notify("error","Folder picker permission denied or IPC error")}}function m(H){H.preventDefault();const O=H.target.elements.namedItem("wd"),G=O==null?void 0:O.value.trim();h(G||null)}function v(){h(null)}var g=Y7(),b=x(Ie(g),2),_=w(b),k=x(w(_)),C=w(k),E=x(_,4);V(E,"step",100);var I=x(E,2),A=w(I),M=w(A),N=x(A,2),R=w(N),B=x(b,2),Z=w(B),q=x(B,2),Y=w(q),X=x(q,4);{var ae=H=>{var O=q7(),G=w(O);j(()=>J(G,d(c))),S(H,O)};W(X,H=>{d(a)&&!d(l)&&d(c)&&H(ae)})}var ne=x(X,2);{var te=H=>{var O=G7(),G=x(w(O),4),z=w(G);V(z,"placeholder","(default: home)");var Q=x(z,2),ge=x(G,2),ye=w(ge);{var Se=D=>{var $=W7();j(()=>$.disabled=d(o)),P("click",$,p),S(D,$)},ee=L(()=>Pt());W(ye,D=>{d(ee)&&D(Se)})}var de=x(ye,2),xe=x(ge,2);{var Ee=D=>{var $=K7(),ke=w($);j(()=>J(ke,d(s))),S(D,$)};W(xe,D=>{d(s)&&D(Ee)})}j(()=>{Sr(z,d(i)??""),z.disabled=d(o),Q.disabled=d(o),de.disabled=d(o)||d(i)===null}),hn("submit",G,m),P("click",de,v),S(H,O)};W(ne,H=>{d(a)&&d(l)&&H(te)})}var le=x(ne,2),se=x(le,2);{var me=H=>{var O=Mt(),G=Ie(O);L_(G,()=>yn(()=>import("./CoworkSettings-L5Hw-XtT.js"),__vite__mapDeps([3,4])),z=>{var Q=Z7();S(z,Q)},(z,Q)=>{const ge=L(()=>d(Q).default);var ye=Mt(),Se=Ie(ye);wb(Se,()=>d(ge),(ee,de)=>{de(ee,{})}),S(z,ye)}),S(H,O)},K=L(()=>Pt());W(se,H=>{d(K)&&H(me)})}j((H,O,G)=>{J(C,`${H??""}s`),V(E,"min",jl),V(E,"max",ql),Sr(E,e.settings.selectionDwellMs),J(M,`${O??""}s`),J(R,`${G??""}s`),Bn(Z,e.settings.selectionToolbar),Bn(Y,e.settings.marginView)},[()=>(e.settings.selectionDwellMs/1e3).toFixed(1),()=>(jl/1e3).toFixed(1),()=>(ql/1e3).toFixed(1)]),P("input",E,H=>e.onUpdate({selectionDwellMs:Number(H.target.value)})),P("change",Z,H=>e.onUpdate({selectionToolbar:H.target.checked})),P("change",Y,H=>e.onUpdate({marginView:H.target.checked})),P("click",le,r),S(t,g),Ke()}et(["input","change","click"]);function c1(t){const e=t==null?void 0:t.trim();return e?e.slice(0,Vp):rC}function u1(){try{return c1(localStorage.getItem(Eb))}catch{return rC}}function X7(t){const e=c1(t);try{localStorage.setItem(Eb,e)}catch{}return typeof window<"u"&&window.dispatchEvent(new Event(H0)),e}function cE(t){const e=()=>t(u1()),n=r=>{r.key===Eb&&t(c1(r.newValue))};return window.addEventListener(H0,e),window.addEventListener("storage",n),()=>{window.removeEventListener(H0,e),window.removeEventListener("storage",n)}}function d1(){let t=F(Qe(u1()));const e=cE(r=>{y(t,r,!0)});return gr(e),{get userName(){return d(t)},setUserName:r=>{const i=X7(r);y(t,i,!0)}}}var Q7=T(`<div><label for="settings-modal-display-name" class="settings-section-label">Display Name</label> <input id="settings-modal-display-name" data-testid="settings-modal-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-modal-default-mode-label" class="settings-section-label">Default Mode</div> <div role="radiogroup" aria-labelledby="settings-modal-default-mode-label" class="settings-mode-btns"><button type="button" data-testid="settings-modal-default-mode-tandem-btn" role="radio" class="settings-mode-btn">Tandem</button> <button type="button" data-testid="settings-modal-default-mode-solo-btn" role="radio" class="settings-mode-btn">Solo</button></div> <div class="settings-hint" style="margin-top: var(--tandem-space-1);">Sets the preferred starting mode for new sessions.</div></div> <label data-testid="settings-modal-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 class="settings-hint" style="margin-top: var(--tandem-space-1);">When enabled, the annotation panel hides automatically when you enter Solo mode and
104
+ restores when you return to Tandem.</div>`,1);function $7(t,e){We(e,!0);const n=d1();let r=F(Qe(n.userName)),i=F(void 0);he(()=>{const m=n.userName;d(r)!==m&&document.activeElement!==d(i)&&y(r,m,!0)});var o=Q7(),s=Ie(o),a=x(w(s),2);St(a,m=>y(i,m),()=>d(i));var l=x(s,2),c=x(w(l),2),u=w(c),f=x(u,2),h=x(l,2),p=w(h);j(()=>{Sr(a,d(r)),V(a,"maxlength",Vp),V(u,"aria-checked",e.settings.defaultMode==="tandem"),V(f,"aria-checked",e.settings.defaultMode==="solo"),Bn(p,e.settings.soloRailHidden)}),P("input",a,m=>{y(r,m.target.value,!0)}),hn("blur",a,()=>n.setUserName(d(r))),P("keydown",a,m=>{m.key==="Enter"&&m.currentTarget.blur(),m.key==="Escape"&&(y(r,n.userName,!0),m.currentTarget.blur())}),P("click",u,()=>e.onUpdate({defaultMode:"tandem"})),P("click",f,()=>e.onUpdate({defaultMode:"solo"})),P("change",p,m=>e.onUpdate({soloRailHidden:m.target.checked})),S(t,o),Ke()}et(["input","keydown","click","change"]);var eF=T("<option> </option>"),tF=T('<div class="mem-key-row svelte-1pwv6ag"><span class="mem-key-preview svelte-1pwv6ag" aria-label="Existing API key (masked)"> </span> <button type="button" class="mem-key-replace-btn svelte-1pwv6ag" data-testid="model-edit-apikey-replace-btn">Replace key</button></div>'),nF=T('<input data-testid="model-edit-apikey" class="mem-input mem-input--mono svelte-1pwv6ag" type="password" autocomplete="off"/>'),rF=T('<label class="mem-field svelte-1pwv6ag"><span class="mem-label svelte-1pwv6ag">API key</span> <!></label>'),iF=T('<label class="mem-field svelte-1pwv6ag"><span class="mem-label svelte-1pwv6ag">Endpoint</span> <input data-testid="model-edit-endpoint" class="mem-input mem-input--mono svelte-1pwv6ag" type="text" autocomplete="off" placeholder="http://localhost:11434"/></label>'),oF=T('<p class="mem-advanced-help svelte-1pwv6ag">Per-model parameter overrides (temperature, max tokens, etc.) are not editable in\n this preview. The data model accepts a `params` map for forward-compat with\n Wave 6 surfaces.</p>'),sF=T('<div role="dialog" aria-modal="true" data-testid="model-edit-modal" class="mem-scrim svelte-1pwv6ag"><form class="mem-dialog svelte-1pwv6ag"><div class="mem-header svelte-1pwv6ag"><h3 class="mem-title svelte-1pwv6ag"> </h3> <button type="button" class="mem-close svelte-1pwv6ag" data-testid="model-edit-cancel" aria-label="Close">×</button></div> <label class="mem-field svelte-1pwv6ag"><span class="mem-label svelte-1pwv6ag">Provider</span> <select data-testid="model-edit-provider" class="mem-input svelte-1pwv6ag"></select></label> <label class="mem-field svelte-1pwv6ag"><span class="mem-label svelte-1pwv6ag">Display name</span> <input data-testid="model-edit-displayname" class="mem-input svelte-1pwv6ag" type="text" autocomplete="off" placeholder="My Anthropic key"/></label> <label class="mem-field svelte-1pwv6ag"><span class="mem-label svelte-1pwv6ag">Model ID</span> <input data-testid="model-edit-modelid" class="mem-input mem-input--mono svelte-1pwv6ag" type="text" autocomplete="off" placeholder="e.g. claude-opus-4-7"/></label> <!> <!> <label class="mem-enabled-row svelte-1pwv6ag"><input type="checkbox" class="mem-enabled-cbx svelte-1pwv6ag"/> <span>Enabled</span></label> <!> <div class="mem-actions svelte-1pwv6ag"><button type="button" class="mem-btn mem-btn--ghost svelte-1pwv6ag">Cancel</button> <button type="submit" class="mem-btn mem-btn--primary svelte-1pwv6ag" data-testid="model-edit-save"> </button></div></form></div>');function aF(t,e){We(e,!0);const n=[{value:"anthropic",label:"Anthropic"},{value:"openai",label:"OpenAI"},{value:"gemini",label:"Gemini"},{value:"local-ollama",label:"Ollama (local)"},{value:"local-llamacpp",label:"llama.cpp (local)"}],r=At(()=>e.entry);let i=F(Qe((r==null?void 0:r.provider)??"anthropic")),o=F(Qe((r==null?void 0:r.displayName)??"")),s=F(Qe((r==null?void 0:r.modelId)??"")),a=F(Qe((r==null?void 0:r.endpoint)??"")),l=F(Qe((r==null?void 0:r.enabled)??!0)),c=F("");const u=r!==void 0&&!!r.apiKeyRef;let f=F(Qe(r===void 0||!u));const h=r!==void 0,p=L(()=>d(i)==="anthropic"||d(i)==="openai"||d(i)==="gemini"),m=L(()=>d(i).startsWith("local-")),v=r!=null&&r.apiKeyRef?r.apiKeyRef.slice(-4):"",g=L(()=>d(o).trim().length>0&&d(s).trim().length>0&&(!d(p)||!d(f)||d(c).trim().length>0));function b(z){if(z.preventDefault(),!d(g))return;const Q={provider:d(i),displayName:d(o).trim(),modelId:d(s).trim(),enabled:d(l)};d(p)&&d(f)&&d(c).trim()&&(Q.plaintextApiKey=d(c).trim()),d(m)&&d(a).trim()&&(Q.endpoint=d(a).trim()),e.onSave(Q)}function _(){y(f,!0),y(c,"")}var k=sF();V(k,"tabindex",-1);var C=w(k),E=w(C),I=w(E),A=w(I),M=x(I,2),N=x(E,2),R=x(w(N),2);nt(R,21,()=>n,z=>z.value,(z,Q)=>{var ge=eF(),ye=w(ge),Se={};j(()=>{J(ye,d(Q).label),Se!==(Se=d(Q).value)&&(ge.value=(ge.__value=d(Q).value)??"")}),S(z,ge)});var B=x(N,2),Z=x(w(B),2),q=x(B,2),Y=x(w(q),2),X=x(q,2);{var ae=z=>{var Q=rF(),ge=x(w(Q),2);{var ye=ee=>{var de=tF(),xe=w(de),Ee=w(xe),D=x(xe,2);j(()=>J(Ee,`••••••••${v??""}`)),P("click",D,_),S(ee,de)},Se=ee=>{var de=nF();j(()=>V(de,"placeholder",h?"Enter new key":"Paste your API key")),Xn(de,()=>d(c),xe=>y(c,xe)),S(ee,de)};W(ge,ee=>{h&&(r!=null&&r.apiKeyRef)&&!d(f)?ee(ye):ee(Se,-1)})}S(z,Q)};W(X,z=>{d(p)&&z(ae)})}var ne=x(X,2);{var te=z=>{var Q=iF(),ge=x(w(Q),2);Xn(ge,()=>d(a),ye=>y(a,ye)),S(z,Q)};W(ne,z=>{d(m)&&z(te)})}var le=x(ne,2),se=w(le),me=x(le,2);aE(me,{label:"Advanced parameters",testid:"model-edit-advanced",children:(z,Q)=>{var ge=oF();S(z,ge)},$$slots:{default:!0}});var K=x(me,2),H=w(K),O=x(H,2),G=w(O);j(()=>{V(k,"aria-label",h?"Edit model":"Add model"),J(A,h?"Edit model":"Add model"),O.disabled=!d(g),J(G,h?"Save changes":"Add model")}),P("click",k,z=>{z.target===z.currentTarget&&e.onCancel()}),P("keydown",k,z=>{z.key==="Escape"&&e.onCancel()}),hn("submit",C,b),P("click",M,function(...z){var Q;(Q=e.onCancel)==null||Q.apply(this,z)}),rM(R,()=>d(i),z=>y(i,z)),Xn(Z,()=>d(o),z=>y(o,z)),Xn(Y,()=>d(s),z=>y(s,z)),Lf(se,()=>d(l),z=>y(l,z)),P("click",H,function(...z){var Q;(Q=e.onCancel)==null||Q.apply(this,z)}),S(t,k),Ke()}et(["click","keydown"]);var lF=T('<span data-testid="models-legacy-migration-status"> </span>'),cF=T(`<div data-testid="models-legacy-migration-banner" role="note" style="padding: var(--tandem-space-2) var(--tandem-space-3); border: 1px solid var(--tandem-warning-border); border-radius: var(--tandem-r-3); background: var(--tandem-warning-bg); color: var(--tandem-warning-fg-strong); font-size: 12px; line-height: 1.5; display: flex; flex-direction: column; gap: var(--tandem-space-2);"><div><strong style="font-weight: 600;">Move API keys to OS keychain.</strong> Existing keys were stored unencrypted in browser storage. Move them now to
105
+ encrypt them with your operating system's credential store.</div> <div style="display: flex; align-items: center; gap: var(--tandem-space-2);"><button type="button" data-testid="models-legacy-migrate-btn"> </button> <!></div></div>`),uF=T('<div data-testid="models-empty-state" style="padding: var(--tandem-space-5) var(--tandem-space-3); text-align: center; border: 1px dashed var(--tandem-border-strong); border-radius: var(--tandem-r-3); color: var(--tandem-fg-muted); font-size: 13px;"><p style="margin: 0 0 var(--tandem-space-3) 0;">No models configured.</p> <button type="button" data-testid="model-add-btn" style="padding: 6px var(--tandem-space-3); font-size: 13px; font-weight: 500; border: none; border-radius: var(--tandem-r-2); cursor: pointer; background: var(--tandem-accent); color: var(--tandem-accent-fg);">Add your first model</button></div>'),dF=T('<button type="button" style="padding: 2px var(--tandem-space-2); font-size: 11px; border: 1px solid var(--tandem-error-border); border-radius: var(--tandem-r-2); background: var(--tandem-error-bg); color: var(--tandem-error-fg-strong); cursor: pointer;">Confirm</button> <button type="button" style="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;">Cancel</button>',1),fF=T('<button type="button" style="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-error-fg); cursor: pointer;">Delete</button>'),hF=T('<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);"><div style="flex: 1; min-width: 0;"><div style="font-size: 13px; color: var(--tandem-fg); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;"> </div> <div style="font-size: 11px; color: var(--tandem-fg-subtle); font-family: var(--tandem-font-mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;"> </div></div> <label style="display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--tandem-fg-muted);" title="Use as the default model"><input type="radio" name="default-model" style="accent-color: var(--tandem-accent);"/> <span>Default</span></label> <label style="display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--tandem-fg-muted);"><input type="checkbox" style="accent-color: var(--tandem-accent);"/> <span> </span></label> <button type="button" style="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); cursor: pointer;">Edit</button> <!></div>'),pF=T('<div><div class="settings-section-label"> </div> <div style="display: flex; flex-direction: column; gap: 4px;"></div></div>'),mF=T('<div style="display: flex; flex-direction: column; gap: var(--tandem-space-3);"></div> <button type="button" data-testid="model-add-btn" style="align-self: flex-start; padding: 6px var(--tandem-space-3); font-size: 13px; font-weight: 500; border: 1px solid var(--tandem-accent-border); border-radius: var(--tandem-r-2); cursor: pointer; background: var(--tandem-surface); color: var(--tandem-accent);">+ Add model</button>',1),gF=T('<div role="alert" data-testid="models-save-error" style="padding: var(--tandem-space-2) var(--tandem-space-3); border: 1px solid var(--tandem-error-border); border-radius: var(--tandem-r-3); background: var(--tandem-error-bg); color: var(--tandem-error-fg-strong); font-size: 12px;"> </div>'),vF=T('<div style="display: flex; flex-direction: column; gap: var(--tandem-space-3);"><!> <!></div> <!> <!>',1);function bF(t,e){We(e,!0);const n=Or(),r=vS(n),i={anthropic:"Anthropic",openai:"OpenAI",gemini:"Gemini","local-ollama":"Ollama (local)","local-llamacpp":"llama.cpp (local)"},o=["anthropic","openai","gemini","local-ollama","local-llamacpp"],s=L(()=>{const q=new Map;for(const Y of o)q.set(Y,[]);for(const Y of r.models){const X=q.get(Y.provider);X&&X.push(Y)}return q});let a=F(void 0),l=F(!1),c=F(null),u=F(null),f=F(!1),h=F(null);function p(){y(a,void 0),y(u,null),y(l,!0)}function m(q){y(a,q,!0),y(u,null),y(l,!0)}async function v(q){const{plaintextApiKey:Y,...X}=q;try{d(a)?await r.updateModel(d(a).id,X,Y):await r.addModel(X,Y),y(l,!1),y(a,void 0),y(u,null)}catch(ae){y(u,ae instanceof Error?ae.message:"Failed to save",!0)}}async function g(q){await r.deleteModel(q),y(c,null)}async function b(){y(f,!0),y(h,null);try{const q=await r.migrateLegacyKeys();q.failed>0?y(h,`Migrated ${q.migrated}; ${q.failed} failed. Retry?`):q.migrated>0&&y(h,`Migrated ${q.migrated} ${q.migrated===1?"key":"keys"} to OS keychain.`)}finally{y(f,!1)}}var _=vF(),k=Ie(_),C=w(k);{var E=q=>{var Y=cF(),X=x(w(Y),2),ae=w(X),ne=w(ae),te=x(ae,2);{var le=se=>{var me=lF(),K=w(me);j(()=>J(K,d(h))),S(se,me)};W(te,se=>{d(h)&&se(le)})}j(()=>{ae.disabled=d(f),Me(ae,`padding: 4px var(--tandem-space-3); font-size: 12px; font-weight: 500; border: 1px solid var(--tandem-warning-border); border-radius: var(--tandem-r-2); background: var(--tandem-surface); color: var(--tandem-warning-fg-strong); cursor: ${d(f)?"wait":"pointer"};`),J(ne,d(f)?"Migrating…":"Migrate keys")}),P("click",ae,b),S(q,Y)};W(C,q=>{r.hasLegacyKeys&&q(E)})}var I=x(C,2);{var A=q=>{var Y=uF(),X=x(w(Y),2);P("click",X,p),S(q,Y)},M=q=>{var Y=mF(),X=Ie(Y);nt(X,20,()=>o,ne=>ne,(ne,te)=>{const le=L(()=>d(s).get(te)??[]);var se=Mt(),me=Ie(se);{var K=H=>{var O=pF(),G=w(O),z=w(G),Q=x(G,2);nt(Q,21,()=>d(le),ge=>ge.id,(ge,ye)=>{var Se=hF(),ee=w(Se),de=w(ee),xe=w(de),Ee=x(de,2),D=w(Ee),$=x(ee,2),ke=w($),we=x($,2),Ae=w(we),pe=x(Ae,2),oe=w(pe),De=x(we,2),ze=x(De,2);{var Ge=ie=>{var ve=dF(),Ye=Ie(ve),ut=x(Ye,2);j(()=>V(Ye,"data-testid",`model-delete-confirm-${d(ye).id}`)),P("click",Ye,()=>g(d(ye).id)),P("click",ut,()=>y(c,null)),S(ie,ve)},Ce=ie=>{var ve=fF();j(()=>V(ve,"data-testid",`model-delete-btn-${d(ye).id}`)),P("click",ve,()=>y(c,d(ye).id,!0)),S(ie,ve)};W(ze,ie=>{d(c)===d(ye).id?ie(Ge):ie(Ce,-1)})}j(()=>{V(Se,"data-testid",`model-row-${d(ye).id}`),J(xe,d(ye).displayName),J(D,d(ye).modelId),V(ke,"data-testid",`model-default-${d(ye).id}`),Bn(ke,r.defaultModelId===d(ye).id),V(Ae,"data-testid",`model-toggle-${d(ye).id}`),Bn(Ae,d(ye).enabled),J(oe,d(ye).enabled?"On":"Off"),V(De,"data-testid",`model-edit-btn-${d(ye).id}`)}),P("change",ke,()=>r.setDefault(d(ye).id)),P("change",Ae,()=>r.toggleEnabled(d(ye).id)),P("click",De,()=>m(d(ye))),S(ge,Se)}),j(()=>J(z,i[te])),S(H,O)};W(me,H=>{d(le).length>0&&H(K)})}S(ne,se)});var ae=x(X,2);P("click",ae,p),S(q,Y)};W(I,q=>{r.models.length===0?q(A):q(M,-1)})}var N=x(k,2);{var R=q=>{var Y=gF(),X=w(Y);j(()=>J(X,d(u))),S(q,Y)};W(N,q=>{d(u)&&q(R)})}var B=x(N,2);{var Z=q=>{aF(q,{get entry(){return d(a)},onCancel:()=>{y(l,!1),y(a,void 0),y(u,null)},onSave:v})};W(B,q=>{d(l)&&q(Z)})}S(t,_),Ke()}et(["click","change"]);var yF=T('<div data-testid="store-readonly-banner" style="font-size: 11px; color: var(--tandem-warning-fg); margin-bottom: 8px;">Settings are read-only (a newer client wrote them). Shortcut changes are disabled.</div>'),wF=T('<span style="justify-self: start; font-size: 11px; color: var(--tandem-accent-fg-strong); font-style: italic;">Press keys… (Esc to cancel)</span>'),xF=T("<kbd> </kbd>"),kF=T('<button type="button">Reset</button>'),_F=T('<div style="grid-column: 1 / -1; font-size: 11px; color: var(--tandem-error-fg);"> </div>'),CF=T('<div style="display: grid; grid-template-columns: 1fr max-content auto; gap: 10px; align-items: center; padding: 3px 0;"><span style="font-size: 13px; color: var(--tandem-fg-muted);"> </span> <!> <div style="display: flex; gap: 6px; justify-self: end;"><button type="button"> </button> <!></div> <!></div>'),SF=T('<kbd> </kbd> <span style="font-size: 13px; color: var(--tandem-fg-muted);"> </span>',1),EF=T('<section><div class="settings-section-label"> </div> <div style="display: grid; grid-template-columns: minmax(120px, max-content) 1fr; gap: 6px 14px; align-items: center;"></div></section>'),AF=T('<kbd> </kbd> <span style="font-size: 13px; color: var(--tandem-fg-muted);"> </span>',1),TF=T('<div style="display: flex; flex-direction: column; gap: var(--tandem-space-4);"><section><div style="display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px;"><div class="settings-section-label">Customizable</div> <button type="button" data-testid="shortcuts-reset-all">Reset all</button></div> <!> <div style="display: flex; flex-direction: column; gap: 4px;"></div></section> <!> <section><div class="settings-section-label">Other (fixed)</div> <div style="display: grid; grid-template-columns: minmax(120px, max-content) 1fr; gap: 6px 14px; align-items: center;"></div></section></div>');function uE(t,e){We(e,!0);let n=Ue(e,"notify",3,()=>{}),r=F(null),i=F(null);const o=L(()=>e.settings._readOnly===!0),s=L(()=>wC(e.settings.customShortcuts));he(()=>{if(d(r)===null)return;const A=d(r),M=N=>{if(N.preventDefault(),N.stopPropagation(),N.key==="Escape"){y(r,null),y(i,null);return}const R=WD(N);if(!R)return;const B=$D(R,d(s),A);if(B){y(i,{id:A,message:`Already used by ${B}`},!0);return}y(r,null),y(i,null),e.onUpdate({customShortcuts:{...e.settings.customShortcuts,[A]:R}}),n()("info",`${W0[A]} set to ${K0(R)}`)};return window.addEventListener("keydown",M,{capture:!0}),()=>window.removeEventListener("keydown",M,{capture:!0})});function a(A){d(o)||(y(i,null),y(r,A,!0))}function l(A){var R;if(d(o))return;const{[A]:M,...N}=e.settings.customShortcuts;e.onUpdate({customShortcuts:N}),d(r)===A&&y(r,null),((R=d(i))==null?void 0:R.id)===A&&y(i,null)}function c(){d(o)||(e.onUpdate({customShortcuts:{}}),y(r,null),y(i,null))}const u=L(()=>Sa.some(A=>d(s).has(A))),f=L(()=>{const A=ph(),M=new Map;for(const N of A.values()){if(!N.shortcut||mC[N.id])continue;const R=M.get(N.group)??[];R.push({keys:N.shortcut,description:N.label}),M.set(N.group,R)}return cC.map(N=>({title:N.charAt(0).toUpperCase()+N.slice(1),rows:M.get(N)??[]})).filter(N=>N.rows.length>0)}),h="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);";var p=TF(),m=w(p),v=w(m),g=x(w(v),2),b=x(v,2);{var _=A=>{var M=yF();S(A,M)};W(b,A=>{d(o)&&A(_)})}var k=x(b,2);nt(k,20,()=>Sa,A=>A,(A,M)=>{const N=L(()=>d(r)===M),R=L(()=>d(s).has(M)),B=L(()=>K0(Ab(M,d(s))));var Z=CF(),q=w(Z),Y=w(q),X=x(q,2);{var ae=G=>{var z=wF();j(()=>V(z,"data-testid",`shortcut-recording-${M}`)),S(G,z)},ne=G=>{var z=xF();Me(z,h);var Q=w(z);j(()=>J(Q,d(B))),S(G,z)};W(X,G=>{d(N)?G(ae):G(ne,-1)})}var te=x(X,2),le=w(te),se=w(le),me=x(le,2);{var K=G=>{var z=kF();j(()=>{V(z,"data-testid",`shortcut-reset-${M}`),z.disabled=d(o),Me(z,`font-size: 11px; padding: 2px 8px; border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-2); background: var(--tandem-surface); color: var(--tandem-fg-muted); cursor: ${d(o)?"not-allowed":"pointer"}; opacity: ${d(o)?.5:1};`)}),P("click",z,()=>l(M)),S(G,z)};W(me,G=>{d(R)&&G(K)})}var H=x(te,2);{var O=G=>{var z=_F(),Q=w(z);j(()=>{V(z,"data-testid",`shortcut-conflict-${M}`),J(Q,d(i).message)}),S(G,z)};W(H,G=>{d(i)&&d(i).id===M&&G(O)})}j(()=>{V(Z,"data-testid",`shortcut-row-${M}`),J(Y,W0[M]),V(le,"data-testid",`shortcut-edit-${M}`),le.disabled=d(o),Me(le,`font-size: 11px; padding: 2px 8px; border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-2); background: ${d(N)?"var(--tandem-accent-bg)":"var(--tandem-surface)"}; color: var(--tandem-fg); cursor: ${d(o)?"not-allowed":"pointer"}; opacity: ${d(o)?.5:1};`),J(se,d(N)?"Recording…":"Change")}),P("click",le,()=>a(M)),S(A,Z)});var C=x(m,2);nt(C,17,()=>d(f),A=>A.title,(A,M)=>{var N=EF(),R=w(N),B=w(R),Z=x(R,2);nt(Z,21,()=>d(M).rows,q=>q.keys+q.description,(q,Y)=>{var X=SF(),ae=Ie(X);Me(ae,h);var ne=w(ae),te=x(ae,2),le=w(te);j(()=>{J(ne,d(Y).keys),J(le,d(Y).description)}),S(q,X)}),j(()=>J(B,`${d(M).title??""} (fixed)`)),S(A,N)});var E=x(C,2),I=x(w(E),2);nt(I,21,()=>kh,A=>A.keys+A.description,(A,M)=>{var N=AF(),R=Ie(N);Me(R,h);var B=w(R),Z=x(R,2),q=w(Z);j(()=>{J(B,d(M).keys),J(q,d(M).description)}),S(A,N)}),j(()=>{g.disabled=d(o)||!d(u),Me(g,`font-size: 11px; padding: 2px 8px; border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-2); background: var(--tandem-surface); color: var(--tandem-fg-muted); cursor: ${d(o)||!d(u)?"not-allowed":"pointer"}; opacity: ${d(o)||!d(u)?.5:1};`)}),P("click",g,c),S(t,p),Ke()}et(["click"]);var MF=T('<div data-testid="settings-modal-shortcuts-list"><!></div>');function DF(t,e){var n=MF(),r=w(n);uE(r,{get settings(){return e.settings},get onUpdate(){return e.onUpdate},get notify(){return e.notify}}),S(t,n)}var OF=T('<div style="margin-top: 6px; font-size: 11px; color: var(--tandem-error-fg);"> </div>'),IF=T('<div style="font-size: 11px; color: var(--tandem-fg-subtle);">Loading...</div>'),RF=T('<dt style="color: var(--tandem-fg-subtle);"> </dt> <dd style="margin: 0; color: var(--tandem-fg-muted); overflow-wrap: anywhere; font-family: var(--tandem-font-mono);"> </dd>',1),NF=T('<dl style="display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 5px 14px; margin: 0; font-size: 11px;"></dl>'),PF=T('<div style="font-size: 11px; color: var(--tandem-fg-subtle);">App info unavailable.</div>'),LF=T('<div><button type="button" data-testid="settings-modal-view-documentation-btn"> </button> <!></div> <div data-testid="settings-modal-app-info-footer" style="border-top: 1px solid var(--tandem-border); padding-top: 10px;"><div class="settings-section-label">About</div> <!></div>',1);function FF(t,e){We(e,!0);const n=mm(()=>e.open);let r=F(!1),i=F(null);async function o(){var C;const _=(C=n.info)==null?void 0:C.workflowsPath;if(!_){y(i,"Documentation file not found.");return}y(r,!0),y(i,null);const k=await Wo(_,{readOnly:!0,notFoundMessage:"Documentation file not found.",failureMessage:"Failed to open documentation."});y(r,!1),k.ok||y(i,k.error,!0)}const s=L(()=>{var C;const _=n.info;if(!_)return[];const k=[{label:"Version",value:`Tandem v${_.version}`},{label:"Tools",value:_.toolCount===null?"Tool count unavailable":`${_.toolCount} tools available`},{label:"MCP SDK",value:`MCP SDK ${_.mcpSdkVersion}`},{label:"Transport",value:((C=_.transport)==null?void 0:C.toUpperCase())??"—"}];return _.storagePath&&k.push({label:"Storage",value:_.storagePath}),_.tokenRotatedAt!==void 0&&k.push({label:"Token",value:_.tokenRotatedAt===null?"Token not created":`Token rotated ${new Date(_.tokenRotatedAt).toLocaleString()}`}),_.changelogPath&&k.push({label:"Changelog",value:_.changelogPath}),k});var a=LF(),l=Ie(a),c=w(l),u=w(c),f=x(c,2);{var h=_=>{var k=OF(),C=w(k);j(()=>J(C,d(i))),S(_,k)};W(f,_=>{d(i)&&_(h)})}var p=x(l,2),m=x(w(p),2);{var v=_=>{var k=IF();S(_,k)},g=_=>{var k=NF();nt(k,21,()=>d(s),C=>C.label,(C,E)=>{var I=RF(),A=Ie(I),M=w(A),N=x(A,2),R=w(N);j(()=>{J(M,d(E).label),J(R,d(E).value)}),S(C,I)}),S(_,k)},b=_=>{var k=PF();S(_,k)};W(m,_=>{n.loading?_(v):n.info?_(g,1):_(b,-1)})}j(()=>{c.disabled=d(r)||n.loading,Me(c,`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: ${d(r)||n.loading?"not-allowed":"pointer"}; background: var(--tandem-surface-muted); color: var(--tandem-fg); opacity: ${d(r)||n.loading?.6:1};`),J(u,d(r)?"Opening…":"View Documentation")}),P("click",c,()=>void o()),S(t,a),Ke()}et(["click"]);const zF={models:"models"};var BF=T('<span class="settings-modal-version-chip svelte-bbu5nk" data-testid="settings-modal-sidebar-version"> </span>'),HF=T('<button type="button" class="settings-modal-nav-btn svelte-bbu5nk"><svg aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" style="flex-shrink: 0;"><path></path></svg> <span> </span></button>'),VF=T('<div role="alert" data-testid="settings-modal-changelog-error" style="font-size: 11px; color: var(--tandem-error-fg); padding: 0 var(--tandem-space-2);"> </div>'),UF=T('<div role="button" tabindex="-1" aria-label="Close settings" data-testid="settings-modal-scrim" style="position: fixed; inset: 0; background: color-mix(in srgb, var(--tandem-bg) 70%, transparent); z-index: var(--tandem-z-above-titlebar);"></div> <div data-testid="settings-modal" role="dialog" aria-modal="true" class="settings-modal svelte-bbu5nk"><aside class="settings-modal-sidebar tandem-scroll-fade-y svelte-bbu5nk"><div class="settings-modal-sidebar-head svelte-bbu5nk"><div class="settings-modal-sidebar-title svelte-bbu5nk">Settings</div> <!></div> <nav aria-label="Settings sections" class="settings-modal-sidebar-nav svelte-bbu5nk"></nav> <div class="settings-modal-sidebar-foot svelte-bbu5nk" data-testid="settings-modal-sidebar-footer"><button type="button" data-testid="settings-modal-view-changelog-btn" class="settings-modal-sidebar-link svelte-bbu5nk"> </button> <!> <a target="_blank" rel="noreferrer" data-testid="settings-modal-report-bug-link" class="settings-modal-sidebar-link svelte-bbu5nk">Report a bug</a> <div class="settings-modal-sidebar-status svelte-bbu5nk" data-testid="settings-modal-mcp-status" aria-live="polite"><span class="settings-modal-status-dot svelte-bbu5nk"></span> <span class="settings-modal-status-label svelte-bbu5nk"><!></span></div></div></aside> <section class="settings-modal-content svelte-bbu5nk" data-testid="settings-modal-content"><header class="settings-modal-content-head svelte-bbu5nk"><button type="button" class="settings-modal-narrow-hamburger svelte-bbu5nk" data-testid="settings-modal-narrow-hamburger"><svg aria-hidden="true" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"><line x1="4" y1="7" x2="20" y2="7"></line><line x1="4" y1="12" x2="20" y2="12"></line><line x1="4" y1="17" x2="20" y2="17"></line></svg></button> <h2 class="settings-modal-content-title svelte-bbu5nk"> </h2> <button type="button" data-testid="settings-modal-close-btn" class="settings-modal-close svelte-bbu5nk" aria-label="Close settings">×</button></header> <div class="settings-modal-content-body tandem-scroll-fade-y svelte-bbu5nk"><div class="settings-modal-content-inner svelte-bbu5nk"><!></div></div></section></div>',1);function jF(t,e){We(e,!0);const n="tandem-settings-modal-heading",r='button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])',i=[{id:"appearance",label:"Appearance",icon:"M12 3v2M12 19v2M5 12H3M21 12h-2M6.3 6.3 4.9 4.9M19.1 19.1l-1.4-1.4M6.3 17.7l-1.4 1.4M19.1 4.9l-1.4 1.4M16 12a4 4 0 1 1-8 0 4 4 0 0 1 8 0Z",component:oE},{id:"editor",label:"Editor",icon:"M4 4h11M4 9h16M4 14h11M4 19h16",component:sE},{id:"network",label:"Network",icon:"M3 12h18M3 12a9 9 0 0 1 18 0M3 12a9 9 0 0 0 18 0M12 3a14 14 0 0 1 0 18M12 3a14 14 0 0 0 0 18",component:lE},{id:"accessibility",label:"Accessibility",icon:"M12 3a2 2 0 1 1 0 4 2 2 0 0 1 0-4ZM4 9h16M9 9v5l-2 7M15 9v5l2 7M9 14h6",component:iE},{id:"collaboration",label:"Collaboration",icon:"M17 21v-2a4 4 0 0 0-4-4H7a4 4 0 0 0-4 4v2M10 11a4 4 0 1 0 0-8 4 4 0 0 0 0 8ZM21 21v-2a4 4 0 0 0-3-3.87M16 3.13A4 4 0 0 1 16 11",component:$7},{id:"claude-code",label:"AI Assistant",icon:"M12 3l1.9 5.1L19 10l-5.1 1.9L12 17l-1.9-5.1L5 10l5.1-1.9L12 3Z",component:J7},{id:"models",label:"Models",icon:"M4 4h16v16H4V4Zm5-3v3M15 1v3M9 20v3M15 20v3M1 9h3M1 15h3M20 9h3M20 15h3M8 8h8v8H8V8Z",component:bF},{id:"shortcuts",label:"Shortcuts",icon:"M3 7h2v2H3V7Zm0 4h2v2H3v-2Zm0 4h2v2H3v-2Zm4-8h2v2H7V7Zm0 4h2v2H7v-2Zm0 4h10v2H7v-2Zm4-8h10v2H11V7Zm0 4h6v2h-6v-2Zm8 0h2v2h-2v-2Z",component:DF},{id:"about",label:"About",icon:"M12 3a9 9 0 1 0 0 18 9 9 0 0 0 0-18Zm0 4v6m0 4h.01",component:FF}];let o=Ue(e,"returnFocusEl",3,null),s=Ue(e,"triggerEl",3,null),a=Ue(e,"connected",3,!1),l=Ue(e,"reconnectAttempts",3,0),c=Ue(e,"tabs",3,i),u=Ue(e,"initialTabId",3,null),f=Ue(e,"notify",3,()=>{}),h=F(void 0);const p=mm(()=>e.open);let m=F(!1),v=F(null),g=F(!1);he(()=>{e.open&&y(g,!1)});let b=!1;he(()=>{if(e.open&&!b&&u()){const q=d(k).find(Y=>Y.id===u());q&&y(C,q.id,!0)}b=e.open});let _=F(!1);he(()=>{if(typeof window>"u"||!window.matchMedia)return;const q=window.matchMedia("(max-width: 860px)");y(_,q.matches,!0);const Y=X=>{y(_,X.matches,!0)};return q.addEventListener("change",Y),()=>q.removeEventListener("change",Y)});const k=L(()=>c().length>0?c():i);let C=F(Qe(i[0].id));const E=L(()=>d(k).find(q=>q.id===d(C))??d(k)[0]),I=L(()=>d(E).label),A=L(()=>({open:e.open,settings:e.settings,onUpdate:e.onUpdate,connected:a(),reconnectAttempts:l(),notify:f()}));he(()=>{d(E)&&d(E).id!==d(C)&&y(C,d(E).id,!0)}),he(()=>{if(e.open)return At(()=>{var q;return(q=d(h))==null?void 0:q.focus()}),()=>{var q;(q=o())==null||q.focus()}}),he(()=>{if(!e.open)return;const q=X=>{var ne;const ae=X.target;ae&&((ne=s())!=null&&ne.contains(ae)||d(h)&&!d(h).contains(ae)&&e.onClose())},Y=setTimeout(()=>document.addEventListener("pointerdown",q),0);return()=>{clearTimeout(Y),document.removeEventListener("pointerdown",q)}}),cc(()=>{const q=Y=>{if(Y.key!=="Escape"||!e.open)return;const X=Y.target;if(!(!d(h)||!X||!d(h).contains(X))){if(Y.stopPropagation(),d(_)&&d(g)){y(g,!1);return}e.onClose()}};return document.addEventListener("keydown",q),()=>document.removeEventListener("keydown",q)}),he(()=>{if(!e.open)return;const q=Y=>{if(Y.key!=="Tab"||!d(h))return;const X=d(h).querySelectorAll(r);if(X.length===0)return;const ae=X[0],ne=X[X.length-1],te=document.activeElement;if(!d(h).contains(te)){Y.preventDefault(),ae.focus();return}Y.shiftKey&&te===ae?(Y.preventDefault(),ne.focus()):!Y.shiftKey&&te===ne&&(Y.preventDefault(),ae.focus())};return window.addEventListener("keydown",q),()=>window.removeEventListener("keydown",q)}),he(()=>{d(C),y(v,null)});async function M(){var X;const q=(X=p.info)==null?void 0:X.changelogPath;if(!q){y(v,"Changelog file not found.");return}y(m,!0),y(v,null);const Y=await Wo(q,{readOnly:!0,notFoundMessage:"Changelog file not found.",failureMessage:"Failed to open changelog."});y(m,!1),Y.ok?e.onClose():y(v,Y.error,!0)}var N={DEFAULT_SETTINGS_TABS:i},R=Mt(),B=Ie(R);{var Z=q=>{var Y=UF(),X=Ie(Y),ae=x(X,2);V(ae,"aria-labelledby",n),V(ae,"tabindex",-1);var ne=w(ae),te=w(ne),le=w(te);V(le,"id",n);var se=x(le,2);{var me=Ce=>{var ie=BF(),ve=w(ie);j(()=>J(ve,`v${p.info.version??""}`)),S(Ce,ie)};W(se,Ce=>{p.info&&Ce(me)})}var K=x(te,2);nt(K,21,()=>d(k),Ce=>Ce.id,(Ce,ie)=>{var ve=HF(),Ye=w(ve),ut=w(Ye),fe=x(Ye,2),Te=w(fe);j(()=>{V(ve,"aria-current",d(C)===d(ie).id?"page":void 0),V(ve,"data-active",d(C)===d(ie).id?"true":"false"),V(ve,"data-testid",`settings-modal-tab-${d(ie).id}`),V(ut,"d",d(ie).icon),J(Te,d(ie).label)}),P("click",ve,()=>{y(C,d(ie).id,!0),y(g,!1)}),S(Ce,ve)});var H=x(K,2),O=w(H),G=w(O),z=x(O,2);{var Q=Ce=>{var ie=VF(),ve=w(ie);j(()=>J(ve,d(v))),S(Ce,ie)};W(z,Ce=>{d(v)&&Ce(Q)})}var ge=x(z,2),ye=x(ge,2),Se=w(ye),ee=x(Se,2),de=w(ee);{var xe=Ce=>{var ie=hr("MCP connected");S(Ce,ie)},Ee=Ce=>{var ie=hr("Reconnecting…");S(Ce,ie)},D=Ce=>{var ie=hr("MCP offline");S(Ce,ie)};W(de,Ce=>{a()?Ce(xe):l()>0?Ce(Ee,1):Ce(D,-1)})}Tr(ne,(Ce,ie)=>jt==null?void 0:jt(Ce,ie),()=>"y");var $=x(ne,2),ke=w($),we=w(ke),Ae=x(we,2),pe=w(Ae),oe=x(Ae,2),De=x(ke,2),ze=w(De),Ge=w(ze);yu(Ge,()=>d(E).id,Ce=>{var ie=Mt(),ve=Ie(ie);wb(ve,()=>d(E).component,(Ye,ut)=>{ut(Ye,Bc(()=>d(A)))}),S(Ce,ie)}),Tr(De,(Ce,ie)=>jt==null?void 0:jt(Ce,ie),()=>"y"),St(ae,Ce=>y(h,Ce),()=>d(h)),j(()=>{V(ae,"data-narrow-sidebar-open",d(g)?"true":"false"),ne.inert=d(_)&&!d(g),O.disabled=d(m)||p.loading,J(G,d(m)?"Opening…":"Changelog"),V(ge,"href",G_),V(Se,"data-state",a()?"connected":l()>0?"reconnecting":"disconnected"),V(we,"aria-label",d(g)?"Hide sections":"Show sections"),V(we,"aria-expanded",d(g)),J(pe,d(I))}),P("click",X,function(...Ce){var ie;(ie=e.onClose)==null||ie.apply(this,Ce)}),P("keydown",X,Ce=>{(Ce.key==="Enter"||Ce.key===" ")&&(Ce.preventDefault(),e.onClose())}),P("click",O,()=>void M()),P("click",we,()=>{y(g,!d(g))}),P("click",oe,function(...Ce){var ie;(ie=e.onClose)==null||ie.apply(this,Ce)}),S(q,Y)};W(B,q=>{e.open&&q(Z)})}return S(t,R),Ke(N)}et(["click","keydown"]);var qF=T('<span class="settings-version-chip svelte-fsutp8" data-testid="settings-sidebar-version"> </span>'),WF=T('<button type="button" class="settings-nav-btn svelte-fsutp8"><svg aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" style="flex-shrink: 0;"><path></path></svg> <span> </span></button>'),KF=T('<div role="alert" data-testid="changelog-error" style="font-size: 11px; color: var(--tandem-error-fg); padding: 0 var(--tandem-space-2);"> </div>'),GF=T(`<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
106
+ restores when you return to Tandem.</div>`,1),ZF=T('<div data-testid="cowork-settings-suspense-fallback" style="font-size: 12px; color: var(--tandem-fg-subtle);">Loading Cowork integration...</div>'),YF=T('<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 your AI 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> <label data-testid="margin-view-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>Margin annotation view (Word-style)</span></label> <div data-testid="margin-view-hint" style="font-size: 10px; color: var(--tandem-fg-subtle);">Margin columns appear where rails are collapsed — open rails hide that side.</div> <!>',1),JF=T('<div data-testid="settings-shortcuts-list"><!></div>'),XF=T('<div style="margin-top: 6px; font-size: 11px; color: var(--tandem-error-fg);"> </div>'),QF=T('<div style="font-size: 11px; color: var(--tandem-fg-subtle);">Loading...</div>'),$F=T('<dt style="color: var(--tandem-fg-subtle);"> </dt> <dd style="margin: 0; color: var(--tandem-fg-muted); overflow-wrap: anywhere;"> </dd>',1),ez=T('<dl style="display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 5px 12px; margin: 0; font-size: 11px;"></dl>'),tz=T('<div style="font-size: 11px; color: var(--tandem-fg-subtle);">App info unavailable.</div>'),nz=T('<div><button data-testid="view-documentation-btn"> </button> <!></div> <div data-testid="app-info-footer" style="border-top: 1px solid var(--tandem-border); padding-top: 10px;"><div>About</div> <!></div>',1),rz=T('<div aria-hidden="true" style="position: fixed; inset: 0; background: color-mix(in srgb, var(--tandem-bg) 70%, transparent); z-index: var(--tandem-z-above-titlebar);"></div> <div data-testid="settings-popover" role="dialog" aria-modal="true" class="settings-dialog svelte-fsutp8"><aside class="settings-sidebar svelte-fsutp8"><div class="settings-sidebar-head svelte-fsutp8"><div class="settings-sidebar-title svelte-fsutp8">Settings</div> <!></div> <nav aria-label="Settings sections" class="settings-sidebar-nav svelte-fsutp8"></nav> <div class="settings-sidebar-foot svelte-fsutp8" data-testid="settings-sidebar-footer"><button type="button" data-testid="view-changelog-btn" class="settings-sidebar-link svelte-fsutp8"> </button> <!> <a target="_blank" rel="noreferrer" data-testid="report-bug-link" class="settings-sidebar-link svelte-fsutp8">Report a bug</a> <div class="settings-sidebar-status svelte-fsutp8" data-testid="settings-mcp-status" aria-live="polite"><span class="settings-status-dot svelte-fsutp8"></span> <span class="settings-status-label svelte-fsutp8"><!></span></div></div></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 class="settings-close-btn svelte-fsutp8" 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 iz(t,e){We(e,!0);const n="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",icon:"M12 3v2M12 19v2M5 12H3M21 12h-2M6.3 6.3 4.9 4.9M19.1 19.1l-1.4-1.4M6.3 17.7l-1.4 1.4M19.1 4.9l-1.4 1.4M16 12a4 4 0 1 1-8 0 4 4 0 0 1 8 0Z"},{id:"editor",label:"Editor",icon:"M4 4h11M4 9h16M4 14h11M4 19h16"},{id:"network",label:"Network",icon:"M3 12h18M3 12a9 9 0 0 1 18 0M3 12a9 9 0 0 0 18 0M12 3a14 14 0 0 1 0 18M12 3a14 14 0 0 0 0 18"},{id:"accessibility",label:"Accessibility",icon:"M12 3a2 2 0 1 1 0 4 2 2 0 0 1 0-4ZM4 9h16M9 9v5l-2 7M15 9v5l2 7M9 14h6"},{id:"collaboration",label:"Collaboration",icon:"M17 21v-2a4 4 0 0 0-4-4H7a4 4 0 0 0-4 4v2M10 11a4 4 0 1 0 0-8 4 4 0 0 0 0 8ZM21 21v-2a4 4 0 0 0-3-3.87M16 3.13A4 4 0 0 1 16 11"},{id:"claude-code",label:"AI Assistant",icon:"M12 3l1.9 5.1L19 10l-5.1 1.9L12 17l-1.9-5.1L5 10l5.1-1.9L12 3Z"},{id:"shortcuts",label:"Shortcuts",icon:"M3 7h2v2H3V7Zm0 4h2v2H3v-2Zm0 4h2v2H3v-2Zm4-8h2v2H7V7Zm0 4h2v2H7v-2Zm0 4h10v2H7v-2Zm4-8h10v2H11V7Zm0 4h6v2h-6v-2Zm8 0h2v2h-2v-2Z"},{id:"about",label:"About",icon:"M12 3a9 9 0 1 0 0 18 9 9 0 0 0 0-18Zm0 4v6m0 4h.01"}];let o=Ue(e,"connected",3,!1),s=Ue(e,"reconnectAttempts",3,0),a=F(void 0),l=F(void 0);const c=d1();let u=F(Qe(c.userName));const f=mm(()=>e.open);let h=F(!1),p=F(null),m=F(!1),v=F(null),g=F("appearance");he(()=>{d(g),y(p,null),y(v,null)}),he(()=>{const B=c.userName;d(u)!==B&&document.activeElement!==d(l)&&y(u,B,!0)}),he(()=>{var B;if(e.open)return(B=d(a))==null||B.focus(),()=>{var Z;(Z=e.returnFocusEl)==null||Z.focus()}}),he(()=>{if(!e.open)return;const B=q=>{var X;const Y=q.target;(X=e.anchorEl)!=null&&X.contains(Y)||d(a)&&!d(a).contains(Y)&&e.onClose()},Z=setTimeout(()=>document.addEventListener("pointerdown",B),0);return()=>{clearTimeout(Z),document.removeEventListener("pointerdown",B)}}),he(()=>{if(!e.open)return;const B=Z=>{if(Z.key==="Escape"){Z.preventDefault(),Z.stopPropagation(),e.onClose();return}if(Z.key!=="Tab"||!d(a))return;const q=d(a).querySelectorAll(r);if(q.length===0)return;const Y=q[0],X=q[q.length-1],ae=document.activeElement;if(!d(a).contains(ae)){Z.preventDefault(),Y.focus();return}Z.shiftKey&&ae===Y?(Z.preventDefault(),X.focus()):!Z.shiftKey&&ae===X&&(Z.preventDefault(),Y.focus())};return window.addEventListener("keydown",B,{capture:!0}),()=>window.removeEventListener("keydown",B,{capture:!0})});async function b(B,Z,q,Y){if(!B){q(Y.notFound);return}Z(!0),q(null);try{const X=await Wo(B,{readOnly:!0,notFoundMessage:Y.notFound,failureMessage:Y.failed});if(!X.ok){q(X.error);return}e.onClose()}finally{Z(!1)}}function _(){var B;return b((B=f.info)==null?void 0:B.workflowsPath,Z=>y(m,Z,!0),Z=>y(v,Z,!0),{notFound:"Documentation file not found.",failed:"Failed to open documentation."})}function k(){var B;return b((B=f.info)==null?void 0:B.changelogPath,Z=>y(h,Z,!0),Z=>y(p,Z,!0),{notFound:"Changelog file not found.",failed:"Failed to open changelog."})}const C="font-size: 11px; font-weight: 600; color: var(--tandem-fg); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px;",E=()=>{};function I(B){var Z;return((Z=i.find(q=>q.id===B))==null?void 0:Z.label)??"Settings"}function A(){var q;const B=f.info;if(!B)return[];const Z=[{label:"Version",value:`Tandem v${B.version}`},{label:"Tools",value:B.toolCount===null?"Tool count unavailable":`${B.toolCount} tools available`},{label:"MCP SDK",value:`MCP SDK ${B.mcpSdkVersion}`},{label:"Transport",value:((q=B.transport)==null?void 0:q.toUpperCase())??"—"}];return B.storagePath&&Z.push({label:"Storage",value:B.storagePath}),B.tokenRotatedAt!==void 0&&Z.push({label:"Token",value:B.tokenRotatedAt===null?"Token not created":`Token rotated ${new Date(B.tokenRotatedAt).toLocaleString()}`}),B.changelogPath&&Z.push({label:"Changelog",value:B.changelogPath}),Z}var M=Mt(),N=Ie(M);{var R=B=>{var Z=rz(),q=Ie(Z),Y=x(q,2);V(Y,"aria-labelledby",n),V(Y,"tabindex",-1);var X=w(Y),ae=w(X),ne=w(ae);V(ne,"id",n);var te=x(ne,2);{var le=fe=>{var Te=qF(),ce=w(Te);j(()=>J(ce,`v${f.info.version??""}`)),S(fe,Te)};W(te,fe=>{f.info&&fe(le)})}var se=x(ae,2);nt(se,21,()=>i,fe=>fe.id,(fe,Te)=>{var ce=WF(),Oe=w(ce),He=w(Oe),it=x(Oe,2),Xe=w(it);j(()=>{V(ce,"aria-current",d(g)===d(Te).id?"page":void 0),V(ce,"data-active",d(g)===d(Te).id?"true":"false"),V(He,"d",d(Te).icon),J(Xe,d(Te).label)}),P("click",ce,()=>y(g,d(Te).id,!0)),S(fe,ce)});var me=x(se,2),K=w(me),H=w(K),O=x(K,2);{var G=fe=>{var Te=KF(),ce=w(Te);j(()=>J(ce,d(p))),S(fe,Te)};W(O,fe=>{d(p)&&fe(G)})}var z=x(O,2),Q=x(z,2),ge=w(Q),ye=x(ge,2),Se=w(ye);{var ee=fe=>{var Te=hr("MCP connected");S(fe,Te)},de=fe=>{var Te=hr("Reconnecting…");S(fe,Te)},xe=fe=>{var Te=hr("MCP offline");S(fe,Te)};W(Se,fe=>{o()?fe(ee):s()>0?fe(de,1):fe(xe,-1)})}var Ee=x(X,2),D=w(Ee),$=w(D),ke=w($),we=x($,2),Ae=x(D,2),pe=w(Ae),oe=w(pe);{var De=fe=>{var Te=GF(),ce=Ie(Te),Oe=w(ce);Me(Oe,C);var He=x(Oe,2);St(He,Fe=>y(l,Fe),()=>d(l));var it=x(ce,2),Xe=w(it);Me(Xe,C);var Re=x(Xe,2),ot=w(Re),tt=x(ot,2),at=x(it,2),_t=w(at);j(()=>{Sr(He,d(u)),V(He,"maxlength",Vp),V(ot,"aria-checked",e.settings.defaultMode==="tandem"),Me(ot,`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;`),V(tt,"aria-checked",e.settings.defaultMode==="solo"),Me(tt,`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;`),Bn(_t,e.settings.soloRailHidden)}),P("input",He,Fe=>{y(u,Fe.target.value,!0)}),hn("blur",He,()=>c.setUserName(d(u))),P("keydown",He,Fe=>{Fe.key==="Enter"&&Fe.currentTarget.blur(),Fe.key==="Escape"&&(y(u,c.userName,!0),Fe.currentTarget.blur())}),P("click",ot,()=>e.onUpdate({defaultMode:"tandem"})),P("click",tt,()=>e.onUpdate({defaultMode:"solo"})),P("change",_t,Fe=>e.onUpdate({soloRailHidden:Fe.target.checked})),S(fe,Te)},ze=fe=>{oE(fe,{get open(){return e.open},get settings(){return e.settings},get onUpdate(){return e.onUpdate},get connected(){return o()},get reconnectAttempts(){return s()},notify:E})},Ge=fe=>{sE(fe,{get open(){return e.open},get settings(){return e.settings},get onUpdate(){return e.onUpdate},get connected(){return o()},get reconnectAttempts(){return s()},notify:E})},Ce=fe=>{lE(fe,{get open(){return e.open},get settings(){return e.settings},get onUpdate(){return e.onUpdate},get connected(){return o()},get reconnectAttempts(){return s()},notify:E})},ie=fe=>{iE(fe,{get open(){return e.open},get settings(){return e.settings},get onUpdate(){return e.onUpdate},get connected(){return o()},get reconnectAttempts(){return s()},notify:E})},ve=fe=>{var Te=YF(),ce=Ie(Te),Oe=w(ce);Me(Oe,C);var He=x(w(Oe)),it=w(He),Xe=x(Oe,4);V(Xe,"step",100);var Re=x(Xe,2),ot=w(Re),tt=w(ot),at=x(ot,2),_t=w(at),Fe=x(ce,2),dt=w(Fe),ht=x(Fe,2),Ft=w(ht),Sn=x(ht,4);{var Gr=on=>{var Wn=Mt(),yi=Ie(Wn);L_(yi,()=>yn(()=>import("./CoworkSettings-L5Hw-XtT.js"),__vite__mapDeps([3,4])),zi=>{var Go=ZF();S(zi,Go)},(zi,Go)=>{const kc=L(()=>d(Go).default);var Wa=Mt(),U=Ie(Wa);wb(U,()=>d(kc),(ue,_e)=>{_e(ue,{})}),S(zi,Wa)}),S(on,Wn)},Fi=L(()=>Pt());W(Sn,on=>{d(Fi)&&on(Gr)})}j((on,Wn,yi)=>{J(it,`${on??""}s`),V(Xe,"min",jl),V(Xe,"max",ql),Sr(Xe,e.settings.selectionDwellMs),J(tt,`${Wn??""}s`),J(_t,`${yi??""}s`),Bn(dt,e.settings.selectionToolbar),Bn(Ft,e.settings.marginView)},[()=>(e.settings.selectionDwellMs/1e3).toFixed(1),()=>(jl/1e3).toFixed(1),()=>(ql/1e3).toFixed(1)]),P("input",Xe,on=>e.onUpdate({selectionDwellMs:Number(on.target.value)})),P("change",dt,on=>e.onUpdate({selectionToolbar:on.target.checked})),P("change",Ft,on=>e.onUpdate({marginView:on.target.checked})),S(fe,Te)},Ye=fe=>{var Te=JF(),ce=w(Te);uE(ce,{get settings(){return e.settings},get onUpdate(){return e.onUpdate},notify:E}),S(fe,Te)},ut=fe=>{var Te=nz(),ce=Ie(Te),Oe=w(ce),He=w(Oe),it=x(Oe,2);{var Xe=dt=>{var ht=XF(),Ft=w(ht);j(()=>J(Ft,d(v))),S(dt,ht)};W(it,dt=>{d(v)&&dt(Xe)})}var Re=x(ce,2),ot=w(Re);Me(ot,C);var tt=x(ot,2);{var at=dt=>{var ht=QF();S(dt,ht)},_t=dt=>{var ht=ez();nt(ht,21,A,Ft=>Ft.label,(Ft,Sn)=>{var Gr=$F(),Fi=Ie(Gr),on=w(Fi),Wn=x(Fi,2),yi=w(Wn);j(()=>{J(on,d(Sn).label),J(yi,d(Sn).value)}),S(Ft,Gr)}),S(dt,ht)},Fe=dt=>{var ht=tz();S(dt,ht)};W(tt,dt=>{f.loading?dt(at):f.info?dt(_t,1):dt(Fe,-1)})}j(()=>{Oe.disabled=d(m)||f.loading,Me(Oe,`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: ${d(m)||f.loading?"not-allowed":"pointer"}; background: var(--tandem-surface-muted); color: var(--tandem-fg); opacity: ${d(m)||f.loading?.6:1};`),J(He,d(m)?"Opening…":"View Documentation")}),P("click",Oe,()=>void _()),S(fe,Te)};W(oe,fe=>{d(g)==="collaboration"?fe(De):d(g)==="appearance"?fe(ze,1):d(g)==="editor"?fe(Ge,2):d(g)==="network"?fe(Ce,3):d(g)==="accessibility"?fe(ie,4):d(g)==="claude-code"?fe(ve,5):d(g)==="shortcuts"?fe(Ye,6):fe(ut,-1)})}St(Y,fe=>y(a,fe),()=>d(a)),j(fe=>{K.disabled=d(h)||f.loading,J(H,d(h)?"Opening…":"Changelog"),V(z,"href",G_),V(ge,"data-state",o()?"connected":s()>0?"reconnecting":"disconnected"),J(ke,fe)},[()=>I(d(g))]),P("click",q,function(...fe){var Te;(Te=e.onClose)==null||Te.apply(this,fe)}),P("click",K,()=>void k()),P("click",we,function(...fe){var Te;(Te=e.onClose)==null||Te.apply(this,fe)}),S(B,Z)};W(N,B=>{e.open&&B(R)})}S(t,M),Ke()}et(["click","input","keydown","change"]);var oz=Dr("<path></path>"),sz=T('<span class="badge svelte-nsu1aw"> </span>'),az=T('<div><span class="glyph svelte-nsu1aw"><svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"></svg></span> <div class="body svelte-nsu1aw"><span class="msg svelte-nsu1aw"> </span> <!></div> <button type="button" class="dismiss svelte-nsu1aw" aria-label="Dismiss notification"><svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M6 6l12 12"></path><path d="M6 18L18 6"></path></svg></button></div>'),lz=T('<div data-testid="toast-container" class="toast-stack svelte-nsu1aw"></div>');function cz(t,e){We(e,!0);var n=Mt(),r=Ie(n);{var i=o=>{var s=lz();nt(s,21,()=>e.toasts,a=>a.id,(a,l)=>{var c=az(),u=w(c),f=w(u);nt(f,20,()=>kC[d(l).severity],_=>_,(_,k)=>{var C=oz();j(()=>V(C,"d",k)),S(_,C)});var h=x(u,2),p=w(h),m=w(p),v=x(p,2);{var g=_=>{var k=sz(),C=w(k);j(()=>{V(k,"data-testid",`toast-count-${d(l).id}`),J(C,`×${d(l).count??""}`)}),S(_,k)};W(v,_=>{d(l).count>1&&_(g)})}var b=x(h,2);j(()=>{V(c,"role",d(l).severity==="info"?"status":"alert"),V(c,"data-testid",`toast-${d(l).id}`),yt(c,1,`toast-card ${d(l).severity??""}`,"svelte-nsu1aw"),J(m,d(l).message),V(b,"data-testid",`toast-dismiss-${d(l).id}`)}),P("click",b,()=>e.onDismiss(d(l).id)),S(a,c)}),S(o,s)};W(r,o=>{e.toasts.length>0&&o(i)})}S(t,n),Ke()}et(["click"]);var uz=T('<div class="tandem-banner tandem-banner--info" role="status" aria-live="polite" data-testid="updater-banner"><span class="tandem-banner__icon" aria-hidden="true"><svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M20 16.58A5 5 0 0018 7h-1.26A8 8 0 104 15.25"></path><path d="M12 12v8"></path><path d="M8 16l4 4 4-4"></path></svg></span> <span class="tandem-banner__message"> </span> <button type="button" class="tandem-banner__cta" data-testid="updater-banner-install"> </button> <button type="button" class="tandem-banner__dismiss" data-testid="updater-banner-dismiss" aria-label="Dismiss update notification"><svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M6 6l12 12M6 18L18 6"></path></svg></button></div>');function dz(t,e){const n=L(()=>e.installing?"Installing…":"Restart to install");var r=uz(),i=x(w(r),2),o=w(i),s=x(i,2),a=w(s),l=x(s,2);j(()=>{J(o,`Tandem v${e.version??""} is available.`),s.disabled=e.installing,J(a,d(n))}),P("click",s,function(...c){var u;(u=e.onInstall)==null||u.apply(this,c)}),P("click",l,function(...c){var u;(u=e.onDismiss)==null||u.apply(this,c)}),S(t,r)}et(["click"]);const fz=Math.floor,hz=(t,e)=>t<e?t:e,pz=(t,e)=>t>e?t:e,dE=128,Yf=127,mz=Number.MAX_SAFE_INTEGER,gz=t=>{const e=unescape(encodeURIComponent(t)),n=e.length,r=new Uint8Array(n);for(let i=0;i<n;i++)r[i]=e.codePointAt(i);return r},Uu=typeof TextEncoder<"u"?new TextEncoder:null,vz=t=>Uu.encode(t),bz=Uu?vz:gz;let tu=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});tu&&tu.decode(new Uint8Array).length===1&&(tu=null);const Lh=(t,e)=>{const n=t.cbuf.length;t.cpos===n&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(n*2),t.cpos=0),t.cbuf[t.cpos++]=e},gm=(t,e)=>{for(;e>Yf;)Lh(t,dE|Yf&e),e=fz(e/128);Lh(t,Yf&e)},vv=new Uint8Array(3e4),yz=vv.length/3,wz=(t,e)=>{if(e.length<yz){const n=Uu.encodeInto(e,vv).written||0;gm(t,n);for(let r=0;r<n;r++)Lh(t,vv[r])}else Cz(t,bz(e))},xz=(t,e)=>{const n=unescape(encodeURIComponent(e)),r=n.length;gm(t,r);for(let i=0;i<r;i++)Lh(t,n.codePointAt(i))},kz=Uu&&Uu.encodeInto?wz:xz,_z=(t,e)=>{const n=t.cbuf.length,r=t.cpos,i=hz(n-r,e.length),o=e.length-i;t.cbuf.set(e.subarray(0,i),r),t.cpos+=i,o>0&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(pz(n*2,o)),t.cbuf.set(e.subarray(i)),t.cpos=o)},Cz=(t,e)=>{gm(t,e.byteLength),_z(t,e)},fE=t=>new Error(t),Sz=fE("Unexpected end of array"),Ez=fE("Integer out of Range"),Az=(t,e)=>{const n=new Uint8Array(t.arr.buffer,t.pos+t.arr.byteOffset,e);return t.pos+=e,n},Tz=t=>Az(t,f1(t)),fx=t=>t.arr[t.pos++],f1=t=>{let e=0,n=1;const r=t.arr.length;for(;t.pos<r;){const i=t.arr[t.pos++];if(e=e+(i&Yf)*n,n*=128,i<dE)return e;if(e>mz)throw Ez}throw Sz},Mz=t=>{let e=f1(t);if(e===0)return"";{let n=String.fromCodePoint(fx(t));if(--e<100)for(;e--;)n+=String.fromCodePoint(fx(t));else for(;e>0;){const r=e<1e4?e:1e4,i=t.arr.subarray(t.pos,t.pos+r);t.pos+=r,n+=String.fromCodePoint.apply(null,i),e-=r}return decodeURIComponent(escape(n))}},Dz=t=>tu.decode(Tz(t)),hx=tu?Dz:Mz;var wl;(function(t){t[t.Token=0]="Token",t[t.PermissionDenied=1]="PermissionDenied",t[t.Authenticated=2]="Authenticated"})(wl||(wl={}));const Oz=(t,e)=>{gm(t,wl.Token),kz(t,e)},Iz=(t,e,n,r)=>{switch(f1(t)){case wl.Token:{e();break}case wl.PermissionDenied:{n(hx(t));break}case wl.Authenticated:{r(hx(t));break}}},px=t=>Array.from(t.entries()).map(([e,n])=>({clientId:e,...n}));var bv;(function(t){t[t.Connecting=0]="Connecting",t[t.Open=1]="Open",t[t.Closing=2]="Closing",t[t.Closed=3]="Closed"})(bv||(bv={}));function Rz(t){return t||(t={}),{delay:t.delay===void 0?200:t.delay,initialDelay:t.initialDelay===void 0?0:t.initialDelay,minDelay:t.minDelay===void 0?0:t.minDelay,maxDelay:t.maxDelay===void 0?0:t.maxDelay,factor:t.factor===void 0?0:t.factor,maxAttempts:t.maxAttempts===void 0?3:t.maxAttempts,timeout:t.timeout===void 0?0:t.timeout,jitter:t.jitter===!0,initialJitter:t.initialJitter===!0,handleError:t.handleError===void 0?null:t.handleError,handleTimeout:t.handleTimeout===void 0?null:t.handleTimeout,beforeAttempt:t.beforeAttempt===void 0?null:t.beforeAttempt,calculateDelay:t.calculateDelay===void 0?null:t.calculateDelay}}async function _g(t){return new Promise(e=>setTimeout(e,t))}function Nz(t,e){let n=e.delay;if(n===0)return 0;if(e.factor&&(n*=Math.pow(e.factor,t.attemptNum-1),e.maxDelay!==0&&(n=Math.min(n,e.maxDelay))),e.jitter){const r=Math.ceil(e.minDelay),i=Math.floor(n);n=Math.floor(Math.random()*(i-r+1))+r}return Math.round(n)}async function Pz(t,e){const n=Rz(e);for(const a of["delay","initialDelay","minDelay","maxDelay","maxAttempts","timeout"]){const l=n[a];if(!Number.isInteger(l)||l<0)throw new Error(`Value for ${a} must be an integer greater than or equal to 0`)}if(n.factor.constructor!==Number||n.factor<0)throw new Error("Value for factor must be a number greater than or equal to 0");if(n.delay<n.minDelay)throw new Error(`delay cannot be less than minDelay (delay: ${n.delay}, minDelay: ${n.minDelay}`);const r={attemptNum:0,attemptsRemaining:n.maxAttempts?n.maxAttempts:-1,aborted:!1,abort(){r.aborted=!0}},i=n.calculateDelay||Nz;async function o(){if(n.beforeAttempt&&n.beforeAttempt(r,n),r.aborted){const l=new Error("Attempt aborted");throw l.code="ATTEMPT_ABORTED",l}const a=async l=>{if(n.handleError&&await n.handleError(l,r,n),r.aborted||r.attemptsRemaining===0)throw l;r.attemptNum++;const c=i(r,n);return c&&await _g(c),o()};return r.attemptsRemaining>0&&r.attemptsRemaining--,n.timeout?new Promise((l,c)=>{const u=setTimeout(()=>{if(n.handleTimeout)try{l(n.handleTimeout(r,n))}catch(f){c(f)}else{const f=new Error(`Retry timeout (attemptNum: ${r.attemptNum}, timeout: ${n.timeout})`);f.code="ATTEMPT_TIMEOUT",c(f)}},n.timeout);t(r,n).then(f=>{clearTimeout(u),l(f)}).catch(f=>{clearTimeout(u),a(f).then(l).catch(c)})}):t(r,n).catch(a)}const s=n.calculateDelay?n.calculateDelay(r,n):n.initialDelay;if(s&&await _g(s),r.attemptNum<1&&n.initialJitter){const a=i(r,n);a&&await _g(a)}return o()}const hE=Math.floor,Lz=(t,e)=>t<e?t:e,Fz=(t,e)=>t>e?t:e,zz=64,Fh=128,Bz=63,nu=127,pE=Number.MAX_SAFE_INTEGER,Hz=()=>new Set,Vz=Array.from,Uz=t=>{const e=unescape(encodeURIComponent(t)),n=e.length,r=new Uint8Array(n);for(let i=0;i<n;i++)r[i]=e.codePointAt(i);return r},ju=typeof TextEncoder<"u"?new TextEncoder:null,jz=t=>ju.encode(t),qz=ju?jz:Uz;let ru=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});ru&&ru.decode(new Uint8Array).length===1&&(ru=null);class Wz{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}const h1=()=>new Wz,mE=t=>{let e=t.cpos;for(let n=0;n<t.bufs.length;n++)e+=t.bufs[n].length;return e},p1=t=>{const e=new Uint8Array(mE(t));let n=0;for(let r=0;r<t.bufs.length;r++){const i=t.bufs[r];e.set(i,n),n+=i.length}return e.set(new Uint8Array(t.cbuf.buffer,0,t.cpos),n),e},zh=(t,e)=>{const n=t.cbuf.length;t.cpos===n&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(n*2),t.cpos=0),t.cbuf[t.cpos++]=e},rr=(t,e)=>{for(;e>nu;)zh(t,Fh|nu&e),e=hE(e/128);zh(t,nu&e)},yv=new Uint8Array(3e4),Kz=yv.length/3,Gz=(t,e)=>{if(e.length<Kz){const n=ju.encodeInto(e,yv).written||0;rr(t,n);for(let r=0;r<n;r++)zh(t,yv[r])}else wc(t,qz(e))},Zz=(t,e)=>{const n=unescape(encodeURIComponent(e)),r=n.length;rr(t,r);for(let i=0;i<r;i++)zh(t,n.codePointAt(i))},qo=ju&&ju.encodeInto?Gz:Zz,Yz=(t,e)=>{const n=t.cbuf.length,r=t.cpos,i=Lz(n-r,e.length),o=e.length-i;t.cbuf.set(e.subarray(0,i),r),t.cpos+=i,o>0&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(Fz(n*2,o)),t.cbuf.set(e.subarray(i)),t.cpos=o)},wc=(t,e)=>{rr(t,e.byteLength),Yz(t,e)},gE=t=>new Error(t),vE=gE("Unexpected end of array"),bE=gE("Integer out of Range");class Jz{constructor(e){this.arr=e,this.pos=0}}const yE=t=>new Jz(t),Xz=(t,e)=>{const n=new Uint8Array(t.arr.buffer,t.pos+t.arr.byteOffset,e);return t.pos+=e,n},vm=t=>Xz(t,ya(t)),mx=t=>t.arr[t.pos++],ya=t=>{let e=0,n=1;const r=t.arr.length;for(;t.pos<r;){const i=t.arr[t.pos++];if(e=e+(i&nu)*n,n*=128,i<Fh)return e;if(e>pE)throw bE}throw vE},Qz=t=>{let e=t.arr[t.pos++],n=e&Bz,r=64;const i=(e&zz)>0?-1:1;if((e&Fh)===0)return i*n;const o=t.arr.length;for(;t.pos<o;){if(e=t.arr[t.pos++],n=n+(e&nu)*r,r*=128,e<Fh)return i*n;if(n>pE)throw bE}throw vE},$z=t=>{let e=ya(t);if(e===0)return"";{let n=String.fromCodePoint(mx(t));if(--e<100)for(;e--;)n+=String.fromCodePoint(mx(t));else for(;e>0;){const r=e<1e4?e:1e4,i=t.arr.subarray(t.pos,t.pos+r);t.pos+=r,n+=String.fromCodePoint.apply(null,i),e-=r}return decodeURIComponent(escape(n))}},eB=t=>ru.decode(vm(t)),qu=ru?eB:$z,tB=t=>{const e=t.pos,n=qu(t);return t.pos=e,n},ec=Date.now,Cg=()=>new Map,nB=(t,e,n)=>{let r=t.get(e);return r===void 0&&t.set(e,r=n()),r};class rB{constructor(){this._observers=Cg()}on(e,n){nB(this._observers,e,Hz).add(n)}once(e,n){const r=(...i)=>{this.off(e,r),n(...i)};this.on(e,r)}off(e,n){const r=this._observers.get(e);r!==void 0&&(r.delete(n),r.size===0&&this._observers.delete(e))}emit(e,n){return Vz((this._observers.get(e)||Cg()).values()).forEach(r=>r(...n))}destroy(){this._observers=Cg()}}const iB=Object.keys,gx=t=>iB(t).length,oB=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),sB=(t,e)=>t===e,iu=(t,e)=>{if(t==null||e==null)return sB(t,e);if(t.constructor!==e.constructor)return!1;if(t===e)return!0;switch(t.constructor){case ArrayBuffer:t=new Uint8Array(t),e=new Uint8Array(e);case Uint8Array:{if(t.byteLength!==e.byteLength)return!1;for(let n=0;n<t.length;n++)if(t[n]!==e[n])return!1;break}case Set:{if(t.size!==e.size)return!1;for(const n of t)if(!e.has(n))return!1;break}case Map:{if(t.size!==e.size)return!1;for(const n of t.keys())if(!e.has(n)||!iu(t.get(n),e.get(n)))return!1;break}case Object:if(gx(t)!==gx(e))return!1;for(const n in t)if(!oB(t,n)||!iu(t[n],e[n]))return!1;break;case Array:if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++)if(!iu(t[n],e[n]))return!1;break;default:return!1}return!0},Sg=3e4;class aB extends rB{constructor(e){super(),this.doc=e,this.clientID=e.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval(()=>{const n=ec();this.getLocalState()!==null&&Sg/2<=n-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());const r=[];this.meta.forEach((i,o)=>{o!==this.clientID&&Sg<=n-i.lastUpdated&&this.states.has(o)&&r.push(o)}),r.length>0&&Jf(this,r,"timeout")},hE(Sg/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 n=this.clientID,r=this.meta.get(n),i=r===void 0?0:r.clock+1,o=this.states.get(n);e===null?this.states.delete(n):this.states.set(n,e),this.meta.set(n,{clock:i,lastUpdated:ec()});const s=[],a=[],l=[],c=[];e===null?c.push(n):o==null?e!=null&&s.push(n):(a.push(n),iu(o,e)||l.push(n)),(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,n){const r=this.getLocalState();r!==null&&this.setLocalState({...r,[e]:n})}getStates(){return this.states}}const Jf=(t,e,n)=>{const r=[];for(let i=0;i<e.length;i++){const o=e[i];if(t.states.has(o)){if(t.states.delete(o),o===t.clientID){const s=t.meta.get(o);t.meta.set(o,{clock:s.clock+1,lastUpdated:ec()})}r.push(o)}}r.length>0&&(t.emit("change",[{added:[],updated:[],removed:r},n]),t.emit("update",[{added:[],updated:[],removed:r},n]))},wv=(t,e,n=t.states)=>{const r=e.length,i=h1();rr(i,r);for(let o=0;o<r;o++){const s=e[o],a=n.get(s)||null,l=t.meta.get(s).clock;rr(i,s),rr(i,l),qo(i,JSON.stringify(a))}return p1(i)},lB=(t,e,n)=>{const r=yE(e),i=ec(),o=[],s=[],a=[],l=[],c=ya(r);for(let u=0;u<c;u++){const f=ya(r);let h=ya(r);const p=JSON.parse(qu(r)),m=t.meta.get(f),v=t.states.get(f),g=m===void 0?0:m.clock;(g<h||g===h&&p===null&&t.states.has(f))&&(p===null?f===t.clientID&&t.getLocalState()!=null?h++:t.states.delete(f):t.states.set(f,p),t.meta.set(f,{clock:h,lastUpdated:i}),m===void 0&&p!==null?o.push(f):m!==void 0&&p===null?l.push(f):p!==null&&(iu(p,v)||a.push(f),s.push(f)))}(o.length>0||a.length>0||l.length>0)&&t.emit("change",[{added:o,updated:a,removed:l},n]),(o.length>0||s.length>0||l.length>0)&&t.emit("update",[{added:o,updated:s,removed:l},n])};let wE=class{constructor(){this.callbacks={}}on(e,n){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(n),this}emit(e,...n){const r=this.callbacks[e];return r&&r.forEach(i=>i.apply(this,n)),this}off(e,n){const r=this.callbacks[e];return r&&(n?this.callbacks[e]=r.filter(i=>i!==n):delete this.callbacks[e]),this}removeAllListeners(){this.callbacks={}}};class xv{constructor(e){this.data=e,this.encoder=h1(),this.decoder=yE(new Uint8Array(this.data))}peekVarString(){return tB(this.decoder)}readVarUint(){return ya(this.decoder)}readVarString(){return qu(this.decoder)}readVarUint8Array(){return vm(this.decoder)}writeVarUint(e){return rr(this.encoder,e)}writeVarString(e){return qo(this.encoder,e)}writeVarUint8Array(e){return wc(this.encoder,e)}length(){return mE(this.encoder)}}var Gn;(function(t){t[t.Sync=0]="Sync",t[t.Awareness=1]="Awareness",t[t.Auth=2]="Auth",t[t.QueryAwareness=3]="QueryAwareness",t[t.Stateless=5]="Stateless",t[t.CLOSE=7]="CLOSE",t[t.SyncStatus=8]="SyncStatus"})(Gn||(Gn={}));var dr;(function(t){t.Connecting="connecting",t.Connected="connected",t.Disconnected="disconnected"})(dr||(dr={}));class qa{constructor(){this.encoder=h1()}get(e){return e.encoder}toUint8Array(){return p1(this.encoder)}}class cB extends qa{constructor(){super(...arguments),this.type=Gn.CLOSE,this.description="Ask the server to close the connection"}get(e){return qo(this.encoder,e.documentName),rr(this.encoder,this.type),this.encoder}}class uB extends wE{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=dr.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=dr.Connected,this.emit("status",{status:dr.Connected}),this.cancelWebsocketRetry=void 0,this.receivedOnOpenPayload=e}attach(e){this.configuration.providerMap.set(e.configuration.name,e),this.status===dr.Disconnected&&this.shouldConnect&&this.connect(),this.receivedOnOpenPayload&&this.status===dr.Connected&&e.onOpen(this.receivedOnOpenPayload)}detach(e){this.configuration.providerMap.has(e.configuration.name)&&(e.send(cB,{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===dr.Connected)return;this.cancelWebsocketRetry&&(this.cancelWebsocketRetry(),this.cancelWebsocketRetry=void 0),this.receivedOnOpenPayload=void 0,this.shouldConnect=!0;const e=()=>{let i=!1;return{retryPromise:Pz(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:n,cancelFunc:r}=e();return this.cancelWebsocketRetry=r,n}attachWebSocketListeners(e,n){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=>{n(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,n=this.webSocketHandlers[e];Object.keys(n).forEach(r=>{var i;(i=this.webSocket)===null||i===void 0||i.removeEventListener(r,n[r]),delete this.webSocketHandlers[e]}),this.webSocket.close(),this.webSocket=null}createWebSocketConnection(){return new Promise((e,n)=>{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,n),this.webSocket=r,this.status=dr.Connecting,this.emit("status",{status:dr.Connecting}),this.connectionAttempt={resolve:e,reject:n}})}onMessage(e){var n;this.resolveConnectionAttempt(),this.lastMessageReceived=ec();const i=new xv(e.data).peekVarString();(n=this.configuration.providerMap.get(i))===null||n===void 0||n.onMessage(e)}resolveConnectionAttempt(){this.connectionAttempt&&(this.connectionAttempt.resolve(),this.connectionAttempt=null,this.status=dr.Connected,this.emit("status",{status:dr.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===dr.Connected&&this.lastMessageReceived&&(this.configuration.messageReconnectTimeout>=ec()-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 n;((n=this.webSocket)===null||n===void 0?void 0:n.readyState)===bv.Open?this.webSocket.send(e):this.messageQueue.push(e)}onClose({event:e}){this.closeTries=0,this.cleanupWebSocket(),this.connectionAttempt&&this.rejectConnectionAttempt(),this.status=dr.Disconnected,this.emit("status",{status:dr.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 xE=0,m1=1,kE=2,dB=(t,e)=>{rr(t,xE);const n=$N(e);wc(t,n)},fB=(t,e,n)=>{rr(t,m1),wc(t,YN(e,n))},hB=(t,e,n)=>fB(e,n,vm(t)),_E=(t,e,n)=>{try{KN(e,vm(t),n)}catch(r){console.error("Caught error while handling a Yjs update",r)}},pB=(t,e)=>{rr(t,kE),wc(t,e)},mB=_E,gB=(t,e,n,r)=>{const i=ya(t);switch(i){case xE:hB(t,e,n);break;case m1:_E(t,n,r);break;case kE:mB(t,n,r);break;default:throw new Error("Unknown message type")}return i};class vB{constructor(e){this.message=e}apply(e,n){const{message:r}=this,i=r.readVarUint(),o=r.length();switch(i){case Gn.Sync:this.applySyncMessage(e,n);break;case Gn.Awareness:this.applyAwarenessMessage(e);break;case Gn.Auth:this.applyAuthMessage(e);break;case Gn.QueryAwareness:this.applyQueryAwarenessMessage(e);break;case Gn.Stateless:e.receiveStateless(qu(r.decoder));break;case Gn.SyncStatus:this.applySyncStatusMessage(e,Qz(r.decoder)===1);break;case Gn.CLOSE:const s={code:1e3,reason:qu(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(qa,{encoder:r.encoder})}applySyncMessage(e,n){const{message:r}=this;r.writeVarUint(Gn.Sync);const i=gB(r.decoder,r.encoder,e.document,e);n&&i===m1&&(e.synced=!0)}applySyncStatusMessage(e,n){n&&e.decrementUnsyncedChanges()}applyAwarenessMessage(e){if(!e.awareness)return;const{message:n}=this;lB(e.awareness,n.readVarUint8Array(),e)}applyAuthMessage(e){const{message:n}=this;Iz(n.decoder,e.sendToken.bind(e),e.permissionDeniedHandler.bind(e),e.authenticatedHandler.bind(e))}applyQueryAwarenessMessage(e){if(!e.awareness)return;const{message:n}=this;n.writeVarUint(Gn.Awareness),n.writeVarUint8Array(wv(e.awareness,Array.from(e.awareness.getStates().keys())))}}class bB{constructor(e,n={}){this.message=new e,this.encoder=this.message.get(n)}create(){return p1(this.encoder)}send(e){e==null||e.send(this.create())}}class yB extends qa{constructor(){super(...arguments),this.type=Gn.Auth,this.description="Authentication"}get(e){if(typeof e.token>"u")throw new Error("The authentication message requires `token` as an argument.");return qo(this.encoder,e.documentName),rr(this.encoder,this.type),Oz(this.encoder,e.token),this.encoder}}class vx extends qa{constructor(){super(...arguments),this.type=Gn.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");qo(this.encoder,e.documentName),rr(this.encoder,this.type);let n;return e.states===void 0?n=wv(e.awareness,e.clients):n=wv(e.awareness,e.clients,e.states),wc(this.encoder,n),this.encoder}}class wB extends qa{constructor(){super(...arguments),this.type=Gn.Stateless,this.description="A stateless message"}get(e){var n;return qo(this.encoder,e.documentName),rr(this.encoder,this.type),qo(this.encoder,(n=e.payload)!==null&&n!==void 0?n:""),this.encoder}}class bx extends qa{constructor(){super(...arguments),this.type=Gn.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 qo(this.encoder,e.documentName),rr(this.encoder,this.type),dB(this.encoder,e.document),this.encoder}}class xB extends qa{constructor(){super(...arguments),this.type=Gn.Sync,this.description="A document update"}get(e){return qo(this.encoder,e.documentName),rr(this.encoder,this.type),pB(this.encoder,e.update),this.encoder}}class kB extends Error{constructor(){super(...arguments),this.code=1001}}class yx extends wE{constructor(e){var n,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 oo,this.configuration.awareness=e.awareness!==void 0?e.awareness:new aB(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),(n=this.awareness)===null||n===void 0||n.on("update",()=>{this.emit("awarenessUpdate",{states:px(this.awareness.getStates())})}),(r=this.awareness)===null||r===void 0||r.on("change",()=>{this.emit("awarenessChange",{states:px(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 uB(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(bx,{document:this.document,documentName:this.configuration.name})}pageHide(){this.awareness&&Jf(this.awareness,[this.document.clientID],"page hide")}registerEventListeners(){typeof window>"u"||!("addEventListener"in window)||window.addEventListener("pagehide",this.boundPageHide)}sendStateless(e){this.send(wB,{documentName:this.configuration.name,payload:e})}async sendToken(){let e;try{e=await this.getToken()}catch(n){this.permissionDeniedHandler(`Failed to get token during sendToken(): ${n}`);return}this.send(yB,{token:e??"",documentName:this.configuration.name})}documentUpdateHandler(e,n){n!==this&&(this.incrementUnsyncedChanges(),this.send(xB,{update:e,documentName:this.configuration.name}))}awarenessUpdateHandler({added:e,updated:n,removed:r},i){const o=e.concat(n).concat(r);this.send(vx,{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(bx,{document:this.document,documentName:this.configuration.name}),this.awareness&&this.awareness.getLocalState()!==null&&this.send(vx,{awareness:this.awareness,clients:[this.document.clientID],documentName:this.configuration.name})}send(e,n){if(!this._isAttached)return;const r=new bB(e,n);this.emit("outgoingMessage",{message:r.message}),r.send(this.configuration.websocketProvider)}onMessage(e){const n=new xv(e.data),r=n.readVarString();n.writeVarString(r),this.emit("message",{event:e,message:new xv(e.data)}),new vB(n).apply(this,!0)}onClose(){this.isAuthenticated=!1,this.synced=!1,this.awareness&&Jf(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&&(Jf(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,n){if(!this.awareness)throw new kB(`Cannot set awareness field "${e}" to ${JSON.stringify(n)}. You have disabled Awareness for this provider by explicitly passing awareness: null in the provider configuration.`);this.awareness.setLocalStateField(e,n)}}const Yn=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},tc=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let kv=null;const _o=function(t,e,n){let r=kv||(kv=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},_B=function(){kv=null},Na=function(t,e,n,r){return n&&(wx(t,e,n,r,-1)||wx(t,e,n,r,1))},CB=/^(img|br|input|textarea|hr)$/i;function wx(t,e,n,r,i){for(var o;;){if(t==n&&e==r)return!0;if(e==(i<0?0:ai(t))){let s=t.parentNode;if(!s||s.nodeType!=1||Rd(t)||CB.test(t.nodeName)||t.contentEditable=="false")return!1;e=Yn(t)+(i<0?0:1),t=s}else if(t.nodeType==1){let s=t.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 t=s,e=i<0?ai(t):0}else return!1}}function ai(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function SB(t,e){for(;;){if(t.nodeType==3&&e)return t;if(t.nodeType==1&&e>0){if(t.contentEditable=="false")return null;t=t.childNodes[e-1],e=ai(t)}else if(t.parentNode&&!Rd(t))e=Yn(t),t=t.parentNode;else return null}}function EB(t,e){for(;;){if(t.nodeType==3&&e<t.nodeValue.length)return t;if(t.nodeType==1&&e<t.childNodes.length){if(t.contentEditable=="false")return null;t=t.childNodes[e],e=0}else if(t.parentNode&&!Rd(t))e=Yn(t)+1,t=t.parentNode;else return null}}function AB(t,e,n){for(let r=e==0,i=e==ai(t);r||i;){if(t==n)return!0;let o=Yn(t);if(t=t.parentNode,!t)return!1;r=r&&o==0,i=i&&o==ai(t)}}function Rd(t){let e;for(let n=t;n&&!(e=n.pmViewDesc);n=n.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}const bm=function(t){return t.focusNode&&Na(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function Js(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function TB(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function MB(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:Math.min(ai(r.offsetNode),r.offset)}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:Math.min(ai(r.startContainer),r.startOffset)}}}const so=typeof navigator<"u"?navigator:null,xx=typeof document<"u"?document:null,Hs=so&&so.userAgent||"",_v=/Edge\/(\d+)/.exec(Hs),CE=/MSIE \d/.exec(Hs),Cv=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Hs),Ar=!!(CE||Cv||_v),Cs=CE?document.documentMode:Cv?+Cv[1]:_v?+_v[1]:0,pi=!Ar&&/gecko\/(\d+)/i.test(Hs);pi&&+(/Firefox\/(\d+)/.exec(Hs)||[0,0])[1];const Sv=!Ar&&/Chrome\/(\d+)/.exec(Hs),Qn=!!Sv,SE=Sv?+Sv[1]:0,or=!Ar&&!!so&&/Apple Computer/.test(so.vendor),nc=or&&(/Mobile\/\w+/.test(Hs)||!!so&&so.maxTouchPoints>2),ri=nc||(so?/Mac/.test(so.platform):!1),EE=so?/Win/.test(so.platform):!1,Mo=/Android \d/.test(Hs),Nd=!!xx&&"webkitFontSmoothing"in xx.documentElement.style,DB=Nd?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function OB(t){let e=t.defaultView&&t.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function go(t,e){return typeof t=="number"?t:t[e]}function IB(t){let e=t.getBoundingClientRect(),n=e.width/t.offsetWidth||1,r=e.height/t.offsetHeight||1;return{left:e.left,right:e.left+t.clientWidth*n,top:e.top,bottom:e.top+t.clientHeight*r}}function kx(t,e,n){let r=t.someProp("scrollThreshold")||0,i=t.someProp("scrollMargin")||5,o=t.dom.ownerDocument;for(let s=n||t.dom;s;){if(s.nodeType!=1){s=tc(s);continue}let a=s,l=a==o.body,c=l?OB(o):IB(a),u=0,f=0;if(e.top<c.top+go(r,"top")?f=-(c.top-e.top+go(i,"top")):e.bottom>c.bottom-go(r,"bottom")&&(f=e.bottom-e.top>c.bottom-c.top?e.top+go(i,"top")-c.top:e.bottom-c.bottom+go(i,"bottom")),e.left<c.left+go(r,"left")?u=-(c.left-e.left+go(i,"left")):e.right>c.right-go(r,"right")&&(u=e.right-c.right+go(i,"right")),u||f)if(l)o.defaultView.scrollBy(u,f);else{let p=a.scrollLeft,m=a.scrollTop;f&&(a.scrollTop+=f),u&&(a.scrollLeft+=u);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:tc(s)}}function RB(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),r,i;for(let o=(e.left+e.right)/2,s=n+1;s<Math.min(innerHeight,e.bottom);s+=5){let a=t.root.elementFromPoint(o,s);if(!a||a==t.dom||!t.dom.contains(a))continue;let l=a.getBoundingClientRect();if(l.top>=n-20){r=a,i=l.top;break}}return{refDOM:r,refTop:i,stack:AE(t.dom)}}function AE(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=tc(r));return e}function NB({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;TE(n,r==0?0:r-e)}function TE(t,e){for(let n=0;n<t.length;n++){let{dom:r,top:i,left:o}=t[n];r.scrollTop!=i+e&&(r.scrollTop=i+e),r.scrollLeft!=o&&(r.scrollLeft=o)}}let Za=null;function PB(t){if(t.setActive)return t.setActive();if(Za)return t.focus(Za);let e=AE(t);t.focus(Za==null?{get preventScroll(){return Za={preventScroll:!0},!0}}:void 0),Za||(Za=!1,TE(e,0))}function ME(t,e){let n,r=2e8,i,o=0,s=e.top,a=e.top,l,c;for(let u=t.firstChild,f=0;u;u=u.nextSibling,f++){let h;if(u.nodeType==1)h=u.getClientRects();else if(u.nodeType==3)h=_o(u).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){n=u,r=v,i=v&&n.nodeType==3?{left:m.right<e.left?m.right:m.left,top:e.top}:e,u.nodeType==1&&v&&(o=f+(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=u,c={left:Math.max(m.left,Math.min(m.right,e.left)),top:m.top});!n&&(e.left>=m.right&&e.top>=m.top||e.left>=m.left&&e.top>=m.bottom)&&(o=f+1)}}return!n&&l&&(n=l,i=c,r=0),n&&n.nodeType==3?LB(n,i):!n||r&&n.nodeType==1?{node:t,offset:o}:ME(n,i)}function LB(t,e){let n=t.nodeValue.length,r=document.createRange(),i;for(let o=0;o<n;o++){r.setEnd(t,o+1),r.setStart(t,o);let s=Qo(r,1);if(s.top!=s.bottom&&g1(e,s)){i={node:t,offset:o+(e.left>=(s.left+s.right)/2?1:0)};break}}return r.detach(),i||{node:t,offset:0}}function g1(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function FB(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function zB(t,e,n){let{node:r,offset:i}=ME(e,n),o=-1;if(r.nodeType==1&&!r.firstChild){let s=r.getBoundingClientRect();o=s.left!=s.right&&n.left>(s.left+s.right)/2?1:-1}return t.docView.posFromDOM(r,i,o)}function BB(t,e,n,r){let i=-1;for(let o=e,s=!1;o!=t.dom;){let a=t.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:t.docView.posFromDOM(e,n,-1)}function DE(t,e,n){let r=t.childNodes.length;if(r&&n.top<n.bottom)for(let i=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-n.top)/(n.bottom-n.top))-2)),o=i;;){let s=t.childNodes[o];if(s.nodeType==1){let a=s.getClientRects();for(let l=0;l<a.length;l++){let c=a[l];if(g1(e,c))return DE(s,e,c)}}if((o=(o+1)%r)==i)break}return t}function HB(t,e){let n=t.dom.ownerDocument,r,i=0,o=MB(n,e.left,e.top);o&&({node:r,offset:i}=o);let s=(t.root.elementFromPoint?t.root:n).elementFromPoint(e.left,e.top),a;if(!s||!t.dom.contains(s.nodeType!=1?s.parentNode:s)){let c=t.dom.getBoundingClientRect();if(!g1(e,c)||(s=DE(t.dom,e,c),!s))return null}if(or)for(let c=s;r&&c;c=tc(c))c.draggable&&(r=void 0);if(s=FB(s,e),r){if(pi&&r.nodeType==1&&(i=Math.min(i,r.childNodes.length),i<r.childNodes.length)){let u=r.childNodes[i],f;u.nodeName=="IMG"&&(f=u.getBoundingClientRect()).right<=e.left&&f.bottom>e.top&&i++}let c;Nd&&i&&r.nodeType==1&&(c=r.childNodes[i-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&i--,r==t.dom&&i==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?a=t.state.doc.content.size:(i==0||r.nodeType!=1||r.childNodes[i-1].nodeName!="BR")&&(a=BB(t,r,i,e))}a==null&&(a=zB(t,s,e));let l=t.docView.nearestDesc(s,!0);return{pos:a,inside:l?l.posAtStart-l.border:-1}}function _x(t){return t.top<t.bottom||t.left<t.right}function Qo(t,e){let n=t.getClientRects();if(n.length){let r=n[e<0?0:n.length-1];if(_x(r))return r}return Array.prototype.find.call(n,_x)||t.getBoundingClientRect()}const VB=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function OE(t,e,n){let{node:r,offset:i,atom:o}=t.docView.domFromPos(e,n<0?-1:1),s=Nd||pi;if(r.nodeType==3)if(s&&(VB.test(r.nodeValue)||(n<0?!i:i==r.nodeValue.length))){let l=Qo(_o(r,i,i),n);if(pi&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let c=Qo(_o(r,i-1,i-1),-1);if(c.top==l.top){let u=Qo(_o(r,i,i+1),-1);if(u.top!=l.top)return Dc(u,u.left<c.left)}}return l}else{let l=i,c=i,u=n<0?1:-1;return n<0&&!i?(c++,u=-1):n>=0&&i==r.nodeValue.length?(l--,u=1):n<0?l--:c++,Dc(Qo(_o(r,l,c),u),u<0)}if(!t.state.doc.resolve(e-(o||0)).parent.inlineContent){if(o==null&&i&&(n<0||i==ai(r))){let l=r.childNodes[i-1];if(l.nodeType==1)return Eg(l.getBoundingClientRect(),!1)}if(o==null&&i<ai(r)){let l=r.childNodes[i];if(l.nodeType==1)return Eg(l.getBoundingClientRect(),!0)}return Eg(r.getBoundingClientRect(),n>=0)}if(o==null&&i&&(n<0||i==ai(r))){let l=r.childNodes[i-1],c=l.nodeType==3?_o(l,ai(l)-(s?0:1)):l.nodeType==1&&(l.nodeName!="BR"||!l.nextSibling)?l:null;if(c)return Dc(Qo(c,1),!1)}if(o==null&&i<ai(r)){let l=r.childNodes[i];for(;l.pmViewDesc&&l.pmViewDesc.ignoreForCoords;)l=l.nextSibling;let c=l?l.nodeType==3?_o(l,0,s?0:1):l.nodeType==1?l:null:null;if(c)return Dc(Qo(c,-1),!0)}return Dc(Qo(r.nodeType==3?_o(r):r,-n),n>=0)}function Dc(t,e){if(t.width==0)return t;let n=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:n,right:n}}function Eg(t,e){if(t.height==0)return t;let n=e?t.top:t.bottom;return{top:n,bottom:n,left:t.left,right:t.right}}function IE(t,e,n){let r=t.state,i=t.root.activeElement;r!=e&&t.updateState(e),i!=t.dom&&t.focus();try{return n()}finally{r!=e&&t.updateState(r),i!=t.dom&&i&&i.focus()}}function UB(t,e,n){let r=e.selection,i=n=="up"?r.$from:r.$to;return IE(t,e,()=>{let{node:o}=t.docView.domFromPos(i.pos,n=="up"?-1:1);for(;;){let a=t.docView.nearestDesc(o,!0);if(!a)break;if(a.node.isBlock){o=a.contentDOM||a.dom;break}o=a.dom.parentNode}let s=OE(t,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=_o(a,0,a.nodeValue.length).getClientRects();else continue;for(let c=0;c<l.length;c++){let u=l[c];if(u.bottom>u.top+1&&(n=="up"?s.top-u.top>(u.bottom-s.top)*2:u.bottom-s.bottom>(s.bottom-u.top)*2))return!1}}return!0})}const jB=/[\u0590-\u08ac]/;function qB(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,o=!i,s=i==r.parent.content.size,a=t.domSelection();return a?!jB.test(r.parent.textContent)||!a.modify?n=="left"||n=="backward"?o:s:IE(t,e,()=>{let{focusNode:l,focusOffset:c,anchorNode:u,anchorOffset:f}=t.domSelectionRange(),h=a.caretBidiLevel;a.modify("move",n,"character");let p=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:m,focusOffset:v}=t.domSelectionRange(),g=m&&!p.contains(m.nodeType==1?m:m.parentNode)||l==m&&c==v;try{a.collapse(u,f),l&&(l!=u||c!=f)&&a.extend&&a.extend(l,c)}catch{}return h!=null&&(a.caretBidiLevel=h),g}):r.pos==r.start()||r.pos==r.end()}let Cx=null,Sx=null,Ex=!1;function WB(t,e,n){return Cx==e&&Sx==n?Ex:(Cx=e,Sx=n,Ex=n=="up"||n=="down"?UB(t,e,n):qB(t,e,n))}const mi=0,Ax=1,na=2,ao=3;class Pd{constructor(e,n,r,i){this.parent=e,this.children=n,this.dom=r,this.contentDOM=i,this.dirty=mi,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,n,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let n=0;n<this.children.length;n++)e+=this.children[n].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 n=0,r=this.posAtStart;;n++){let i=this.children[n];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,n,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[n-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[n];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=n>Yn(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(n==0)for(let o=e;;o=o.parentNode){if(o==this.dom){i=!1;break}if(o.previousSibling)break}if(i==null&&n==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,n=!1){for(let r=!0,i=e;i;i=i.parentNode){let o=this.getDesc(i),s;if(o&&(!n||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 n=e.pmViewDesc;for(let r=n;r;r=r.parent)if(r==this)return n}posFromDOM(e,n,r){for(let i=e;i;i=i.parentNode){let o=this.getDesc(i);if(o)return o.localPosFromDOM(e,n,r)}return-1}descAt(e){for(let n=0,r=0;n<this.children.length;n++){let i=this.children[n],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,n){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 NE){i=e-o;break}o=a}if(i)return this.children[r].domFromPos(i-this.children[r].border,n);for(let o;r&&!(o=this.children[r-1]).size&&o instanceof RE&&o.side>=0;r--);if(n<=0){let o,s=!0;for(;o=r?this.children[r-1]:null,!(!o||o.dom.parentNode==this.contentDOM);r--,s=!1);return o&&n&&s&&!o.border&&!o.domAtom?o.domFromPos(o.size,n):{node:this.contentDOM,offset:o?Yn(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,n):{node:this.contentDOM,offset:o?Yn(o.dom):this.contentDOM.childNodes.length}}}parseRange(e,n,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:n,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 u=s+l.border;if(e>=u&&n<=c-l.border&&l.node&&l.contentDOM&&this.contentDOM.contains(l.contentDOM))return l.parseRange(e,n,u);e=s;for(let f=a;f>0;f--){let h=this.children[f-1];if(h.size&&h.dom.parentNode==this.contentDOM&&!h.emptyChildAt(1)){i=Yn(h.dom)+1;break}e-=h.size}i==-1&&(i=0)}if(i>-1&&(c>n||a==this.children.length-1)){n=c;for(let u=a+1;u<this.children.length;u++){let f=this.children[u];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(-1)){o=Yn(f.dom);break}n+=f.size}o==-1&&(o=this.contentDOM.childNodes.length);break}s=c}return{node:this.contentDOM,from:e,to:n,fromOffset:i,toOffset:o}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let n=this.children[e<0?0:this.children.length-1];return n.size==0||n.emptyChildAt(e)}domAfterPos(e){let{node:n,offset:r}=this.domFromPos(e,0);if(n.nodeType!=1||r==n.childNodes.length)throw new RangeError("No node after pos "+e);return n.childNodes[r]}setSelection(e,n,r,i=!1){let o=Math.min(e,n),s=Math.max(e,n);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,n-m-v.border,r,i);m=g}let a=this.domFromPos(e,e?-1:1),l=n==e?a:this.domFromPos(n,n?-1:1),c=r.root.getSelection(),u=r.domSelectionRange(),f=!1;if((pi||or)&&e==n){let{node:p,offset:m}=a;if(p.nodeType==3){if(f=!!(m&&p.nodeValue[m-1]==`
107
+ `),f&&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:Yn(g)+1});break}let b=v.pmViewDesc;if(b&&b.node&&b.node.isBlock)break}}else{let v=p.childNodes[m-1];f=v&&(v.nodeName=="BR"||v.contentEditable=="false")}}if(pi&&u.focusNode&&u.focusNode!=l.node&&u.focusNode.nodeType==1){let p=u.focusNode.childNodes[u.focusOffset];p&&p.contentEditable=="false"&&(i=!0)}if(!(i||f&&or)&&Na(a.node,a.offset,u.anchorNode,u.anchorOffset)&&Na(l.node,l.offset,u.focusNode,u.focusOffset))return;let h=!1;if((c.extend||e==n)&&!(f&&pi)){c.collapse(a.node,a.offset);try{e!=n&&c.extend(l.node,l.offset),h=!0}catch{}}if(!h){if(e>n){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,n){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&&n>=r:e<s&&n>r){let a=r+o.border,l=s-o.border;if(e>=a&&n<=l){this.dirty=e==r||n==s?na:Ax,e==a&&n==l&&(o.contentLost||o.dom.parentNode!=this.contentDOM)?o.dirty=ao:o.markDirty(e-a,n-a);return}else o.dirty=o.dom==o.contentDOM&&o.dom.parentNode==this.contentDOM&&!o.children.length?na:ao}r=s}this.dirty=na}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?na:Ax;n.dirty<r&&(n.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class RE extends Pd{constructor(e,n,r,i){let o,s=n.type.toDOM;if(typeof s=="function"&&(s=s(r,()=>{if(!o)return i;if(o.parent)return o.parent.posBeforeChild(o)})),!n.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=n,this.widget=n,o=this}matchesWidget(e){return this.dirty==mi&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let n=this.widget.spec.stopEvent;return n?n(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 KB extends Pd{constructor(e,n,r,i){super(e,[],n,null),this.textDOM=r,this.text=i}get size(){return this.text.length}localPosFromDOM(e,n){return e!=this.textDOM?this.posAtStart+(n?this.size:0):this.posAtStart+n}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class Pa extends Pd{constructor(e,n,r,i,o){super(e,[],r,i),this.mark=n,this.spec=o}static create(e,n,r,i){let o=i.nodeViews[n.type.name],s=o&&o(n,i,r);return(!s||!s.dom)&&(s=Ua.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new Pa(e,n,s.dom,s.contentDOM||s.dom,s)}parseRule(){return this.dirty&ao||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=ao&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=mi){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=mi}}slice(e,n,r){let i=Pa.create(this.parent,this.mark,!0,r),o=this.children,s=this.size;n<s&&(o=Av(o,n,s,r)),e>0&&(o=Av(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 Ss extends Pd{constructor(e,n,r,i,o,s,a,l,c){super(e,[],o,s),this.node=n,this.outerDeco=r,this.innerDeco=i,this.nodeDOM=a}static create(e,n,r,i,o,s){let a=o.nodeViews[n.type.name],l,c=a&&a(n,o,()=>{if(!l)return s;if(l.parent)return l.parent.posBeforeChild(l)},r,i),u=c&&c.dom,f=c&&c.contentDOM;if(n.isText){if(!u)u=document.createTextNode(n.text);else if(u.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else u||({dom:u,contentDOM:f}=Ua.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!f&&!n.isText&&u.nodeName!="BR"&&(u.hasAttribute("contenteditable")||(u.contentEditable="false"),n.type.spec.draggable&&(u.draggable=!0));let h=u;return u=FE(u,r,n),c?l=new GB(e,n,r,i,u,f||null,h,c,o,s+1):n.isText?new ym(e,n,r,i,u,h,o):new Ss(e,n,r,i,u,f||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 n=this.children.length-1;n>=0;n--){let r=this.children[n];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>be.empty)}return e}matchesNode(e,n,r){return this.dirty==mi&&e.eq(this.node)&&Bh(n,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,n){let r=this.node.inlineContent,i=n,o=e.composing?this.localCompositionInfo(e,n):null,s=o&&o.pos>-1?o:null,a=o&&o.pos<0,l=new YB(this,s&&s.node,e);QB(this.node,this.innerDeco,(c,u,f)=>{c.spec.marks?l.syncToMarks(c.spec.marks,r,e,u):c.type.side>=0&&!f&&l.syncToMarks(u==this.node.childCount?qt.none:this.node.child(u).marks,r,e,u),l.placeWidget(c,e,i)},(c,u,f,h)=>{l.syncToMarks(c.marks,r,e,h);let p;l.findNodeMatch(c,u,f,h)||a&&e.state.selection.from>i&&e.state.selection.to<i+c.nodeSize&&(p=l.findIndexWithChild(o.node))>-1&&l.updateNodeAt(c,u,f,p,e)||l.updateNextNode(c,u,f,e,h,i)||l.addNode(c,u,f,e,i),i+=c.nodeSize}),l.syncToMarks([],r,e,0),this.node.isTextblock&&l.addTextblockHacks(),l.destroyRest(),(l.changed||this.dirty==na)&&(s&&this.protectLocalComposition(e,s),PE(this.contentDOM,this.children,e),nc&&$B(this.dom))}localCompositionInfo(e,n){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof $e)||r<n||i>n+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=eH(this.node.content,s,r-n,i-n);return a<0?null:{node:o,pos:a,text:s}}else return{node:o,pos:-1,text:""}}protectLocalComposition(e,{node:n,pos:r,text:i}){if(this.getDesc(n))return;let o=n;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 KB(this,o,n,i);e.input.compositionNodes.push(s),this.children=Av(this.children,r,r+i.length,e,s)}update(e,n,r,i){return this.dirty==ao||!e.sameMarkup(this.node)?!1:(this.updateInner(e,n,r,i),!0)}updateInner(e,n,r,i){this.updateOuterDeco(n),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=mi}updateOuterDeco(e){if(Bh(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=LE(this.dom,this.nodeDOM,Ev(this.outerDeco,this.node,n),Ev(e,this.node,n)),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 Tx(t,e,n,r,i){FE(r,e,t);let o=new Ss(void 0,t,e,n,r,r,r,i,0);return o.contentDOM&&o.updateChildren(i,0),o}class ym extends Ss{constructor(e,n,r,i,o,s,a){super(e,n,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,n,r,i){return this.dirty==ao||this.dirty!=mi&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=mi||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=mi,!0)}inParent(){let e=this.parent.contentDOM;for(let n=this.nodeDOM;n;n=n.parentNode)if(n==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,n,r){return e==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(e,n,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,n,r){let i=this.node.cut(e,n),o=document.createTextNode(i.text);return new ym(this.parent,i,this.outerDeco,this.innerDeco,o,o,r)}markDirty(e,n){super.markDirty(e,n),this.dom!=this.nodeDOM&&(e==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=ao)}get domAtom(){return!1}isText(e){return this.node.text==e}}class NE extends Pd{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==mi&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class GB extends Ss{constructor(e,n,r,i,o,s,a,l,c,u){super(e,n,r,i,o,s,a,c,u),this.spec=l}update(e,n,r,i){if(this.dirty==ao)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let o=this.spec.update(e,n,r);return o&&this.updateInner(e,n,r,i),o}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,n,r,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,n,r,i){this.spec.setSelection?this.spec.setSelection(e,n,r.root):super.setSelection(e,n,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 PE(t,e,n){let r=t.firstChild,i=!1;for(let o=0;o<e.length;o++){let s=e[o],a=s.dom;if(a.parentNode==t){for(;a!=r;)r=Mx(r),i=!0;r=r.nextSibling}else i=!0,t.insertBefore(a,r);if(s instanceof Pa){let l=r?r.previousSibling:t.lastChild;PE(s.contentDOM,s.children,n),r=l?l.nextSibling:t.firstChild}}for(;r;)r=Mx(r),i=!0;i&&n.trackWrites==t&&(n.trackWrites=null)}const ou=function(t){t&&(this.nodeName=t)};ou.prototype=Object.create(null);const ra=[new ou];function Ev(t,e,n){if(t.length==0)return ra;let r=n?ra[0]:new ou,i=[r];for(let o=0;o<t.length;o++){let s=t[o].type.attrs;if(s){s.nodeName&&i.push(r=new ou(s.nodeName));for(let a in s){let l=s[a];l!=null&&(n&&i.length==1&&i.push(r=new ou(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 LE(t,e,n,r){if(n==ra&&r==ra)return e;let i=e;for(let o=0;o<r.length;o++){let s=r[o],a=n[o];if(o){let l;a&&a.nodeName==s.nodeName&&i!=t&&(l=i.parentNode)&&l.nodeName.toLowerCase()==s.nodeName||(l=document.createElement(s.nodeName),l.pmIsDeco=!0,l.appendChild(i),a=ra[0]),i=l}ZB(i,a||ra[0],s)}return i}function ZB(t,e,n){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in n)&&t.removeAttribute(r);for(let r in n)r!="class"&&r!="style"&&r!="nodeName"&&n[r]!=e[r]&&t.setAttribute(r,n[r]);if(e.class!=n.class){let r=e.class?e.class.split(" ").filter(Boolean):[],i=n.class?n.class.split(" ").filter(Boolean):[];for(let o=0;o<r.length;o++)i.indexOf(r[o])==-1&&t.classList.remove(r[o]);for(let o=0;o<i.length;o++)r.indexOf(i[o])==-1&&t.classList.add(i[o]);t.classList.length==0&&t.removeAttribute("class")}if(e.style!=n.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,i;for(;i=r.exec(e.style);)t.style.removeProperty(i[1])}n.style&&(t.style.cssText+=n.style)}}function FE(t,e,n){return LE(t,t,ra,Ev(e,n,t.nodeType!=1))}function Bh(t,e){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!t[n].type.eq(e[n].type))return!1;return!0}function Mx(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class YB{constructor(e,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=JB(e.node.content,e)}destroyBetween(e,n){if(e!=n){for(let r=e;r<n;r++)this.top.children[r].destroy();this.top.children.splice(e,n-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,n,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=mi,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 u=this.index;u<c;u++){let f=this.top.children[u];if(f.matchesMark(e[s])&&!this.isLocked(f.dom)){l=u;break}}if(l>-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let u=Pa.create(this.top,e[s],n,r);this.top.children.splice(this.index,0,u),this.top=u,this.changed=!0}this.index=0,s++}}findNodeMatch(e,n,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,n,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,n,r)&&!this.preMatch.matched.has(c)){o=a;break}}return o<0?!1:(this.destroyBetween(this.index,o),this.index++,!0)}updateNodeAt(e,n,r,i,o){let s=this.top.children[i];return s.dirty==ao&&s.dom==s.contentDOM&&(s.dirty=na),s.update(e,n,r,o)?(this.destroyBetween(this.index,i),this.index++,!0):!1}findIndexWithChild(e){for(;;){let n=e.parentNode;if(!n)return-1;if(n==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=n}}updateNextNode(e,n,r,i,o,s){for(let a=this.index;a<this.top.children.length;a++){let l=this.top.children[a];if(l instanceof Ss){let c=this.preMatch.matched.get(l);if(c!=null&&c!=o)return!1;let u=l.dom,f,h=this.isLocked(u)&&!(e.isText&&l.node&&l.node.isText&&l.nodeDOM.nodeValue==e.text&&l.dirty!=ao&&Bh(n,l.outerDeco));if(!h&&l.update(e,n,r,i))return this.destroyBetween(this.index,a),l.dom!=u&&(this.changed=!0),this.index++,!0;if(!h&&(f=this.recreateWrapper(l,e,n,r,i,s)))return this.destroyBetween(this.index,a),this.top.children[this.index]=f,f.contentDOM&&(f.dirty=na,f.updateChildren(i,s+1),f.dirty=mi),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,n,r,i,o,s){if(e.dirty||n.isAtom||!e.children.length||!e.node.content.eq(n.content)||!Bh(r,e.outerDeco)||!i.eq(e.innerDeco))return null;let a=Ss.create(this.top,n,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,n,r,i,o){let s=Ss.create(this.top,e,n,r,i,o);s.contentDOM&&s.updateChildren(i,o+1),this.top.children.splice(this.index++,0,s),this.changed=!0}placeWidget(e,n,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 RE(this.top,e,n,r);this.top.children.splice(this.index++,0,o),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],n=this.top;for(;e instanceof Pa;)n=e,e=n.children[n.children.length-1];(!e||!(e instanceof ym)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((or||Qn)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",n),this.addHackNode("BR",this.top))}addHackNode(e,n){if(n==this.top&&this.index<n.children.length&&n.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 NE(this.top,[],r,null);n!=this.top?n.children.push(i):n.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 JB(t,e){let n=e,r=n.children.length,i=t.childCount,o=new Map,s=[];e:for(;i>0;){let a;for(;;)if(r){let c=n.children[r-1];if(c instanceof Pa)n=c,r=c.children.length;else{a=c,r--;break}}else{if(n==e)break e;r=n.parent.children.indexOf(n),n=n.parent}let l=a.node;if(l){if(l!=t.child(i-1))break;--i,o.set(a,i),s.push(a)}}return{index:i,matched:o,matches:s.reverse()}}function XB(t,e){return t.type.side-e.type.side}function QB(t,e,n,r){let i=e.locals(t),o=0;if(i.length==0){for(let c=0;c<t.childCount;c++){let u=t.child(c);r(u,i,e.forChild(o,u),c),o+=u.nodeSize}return}let s=0,a=[],l=null;for(let c=0;;){let u,f;for(;s<i.length&&i[s].to==o;){let g=i[s++];g.widget&&(u?(f||(f=[u])).push(g):u=g)}if(u)if(f){f.sort(XB);for(let g=0;g<f.length;g++)n(f[g],c,!!l)}else n(u,c,!!l);let h,p;if(l)p=-1,h=l,l=null;else if(c<t.childCount)p=c,h=t.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 b=0;b<a.length;b++)a[b].to<g&&(g=a[b].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 $B(t){if(t.nodeName=="UL"||t.nodeName=="OL"){let e=t.style.cssText;t.style.cssText=e+"; list-style: square !important",window.getComputedStyle(t).listStyle,t.style.cssText=e}}function eH(t,e,n,r){for(let i=0,o=0;i<t.childCount&&o<=r;){let s=t.child(i++),a=o;if(o+=s.nodeSize,!s.isText)continue;let l=s.text;for(;i<t.childCount;){let c=t.child(i++);if(o+=c.nodeSize,!c.isText)break;l+=c.text}if(o>=n){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>=n)return a+c;if(n==r&&l.length>=r+e.length-a&&l.slice(r-a,r-a+e.length)==e)return r}}return-1}function Av(t,e,n,r,i){let o=[];for(let s=0,a=0;s<t.length;s++){let l=t[s],c=a,u=a+=l.size;c>=n||u<=e?o.push(l):(c<e&&o.push(l.slice(0,e-c,r)),i&&(o.push(i),i=void 0),u>n&&o.push(l.slice(n-c,l.size,r)))}return o}function v1(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let i=t.docView.nearestDesc(n.focusNode),o=i&&i.size==0,s=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(s<0)return null;let a=r.resolve(s),l,c;if(bm(n)){for(l=s;i&&!i.node;)i=i.parent;let f=i.node;if(i&&f.isAtom&&rt.isSelectable(f)&&i.parent&&!(f.isInline&&AB(n.focusNode,n.focusOffset,i.dom))){let h=i.posBefore;c=new rt(s==h?a:r.resolve(h))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let f=s,h=s;for(let p=0;p<n.rangeCount;p++){let m=n.getRangeAt(p);f=Math.min(f,t.docView.posFromDOM(m.startContainer,m.startOffset,1)),h=Math.max(h,t.docView.posFromDOM(m.endContainer,m.endOffset,-1))}if(f<0)return null;[l,s]=h==t.state.selection.anchor?[h,f]:[f,h],a=r.resolve(s)}else l=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(l<0)return null}let u=r.resolve(l);if(!c){let f=e=="pointer"||t.state.selection.head<a.pos&&!o?1:-1;c=b1(t,u,a,f)}return c}function zE(t){return t.editable?t.hasFocus():HE(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function Lo(t,e=!1){let n=t.state.selection;if(BE(t,n),!!zE(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&Qn){let r=t.domSelectionRange(),i=t.domObserver.currentSelection;if(r.anchorNode&&i.anchorNode&&Na(r.anchorNode,r.anchorOffset,i.anchorNode,i.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)nH(t);else{let{anchor:r,head:i}=n,o,s;Dx&&!(n instanceof $e)&&(n.$from.parent.inlineContent||(o=Ox(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(s=Ox(t,n.to))),t.docView.setSelection(r,i,t,e),Dx&&(o&&Ix(o),s&&Ix(s)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&tH(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const Dx=or||Qn&&SE<63;function Ox(t,e){let{node:n,offset:r}=t.docView.domFromPos(e,0),i=r<n.childNodes.length?n.childNodes[r]:null,o=r?n.childNodes[r-1]:null;if(or&&i&&i.contentEditable=="false")return Ag(i);if((!i||i.contentEditable=="false")&&(!o||o.contentEditable=="false")){if(i)return Ag(i);if(o)return Ag(o)}}function Ag(t){return t.contentEditable="true",or&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function Ix(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function tH(t){let e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.input.hideSelectionGuard);let n=t.domSelectionRange(),r=n.anchorNode,i=n.anchorOffset;e.addEventListener("selectionchange",t.input.hideSelectionGuard=()=>{(n.anchorNode!=r||n.anchorOffset!=i)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!zE(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function nH(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,Yn(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&Ar&&Cs<=11&&(n.disabled=!0,n.disabled=!1)}function BE(t,e){if(e instanceof rt){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(Rx(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else Rx(t)}function Rx(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function b1(t,e,n,r){return t.someProp("createSelectionBetween",i=>i(t,e,n))||$e.between(e,n,r)}function Nx(t){return t.editable&&!t.hasFocus()?!1:HE(t)}function HE(t){let e=t.domSelectionRange();if(!e.anchorNode)return!1;try{return t.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(t.editable||t.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function rH(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return Na(e.node,e.offset,n.anchorNode,n.anchorOffset)}function Tv(t,e){let{$anchor:n,$head:r}=t.selection,i=e>0?n.max(r):n.min(r),o=i.parent.inlineContent?i.depth?t.doc.resolve(e>0?i.after():i.before()):null:i;return o&&lt.findFrom(o,e)}function es(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function Px(t,e,n){let r=t.state.selection;if(r instanceof $e)if(n.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=t.state.doc.resolve(i.pos+o.nodeSize*(e<0?-1:1));return es(t,new $e(r.$anchor,s))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let i=Tv(t.state,e);return i&&i instanceof rt?es(t,i):!1}else if(!(ri&&n.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=t.docView.descAt(a))&&!s.contentDOM?rt.isSelectable(o)?es(t,new rt(e<0?t.state.doc.resolve(i.pos-o.nodeSize):i)):Nd?es(t,new $e(t.state.doc.resolve(e<0?a:a+o.nodeSize))):!1:!1}}else return!1;else{if(r instanceof rt&&r.node.isInline)return es(t,new $e(e>0?r.$to:r.$from));{let i=Tv(t.state,e);return i?es(t,i):!1}}}function Hh(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function su(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function Ya(t,e){return e<0?iH(t):oH(t)}function iH(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i,o,s=!1;for(pi&&n.nodeType==1&&r<Hh(n)&&su(n.childNodes[r],-1)&&(s=!0);;)if(r>0){if(n.nodeType!=1)break;{let a=n.childNodes[r-1];if(su(a,-1))i=n,o=--r;else if(a.nodeType==3)n=a,r=n.nodeValue.length;else break}}else{if(VE(n))break;{let a=n.previousSibling;for(;a&&su(a,-1);)i=n.parentNode,o=Yn(a),a=a.previousSibling;if(a)n=a,r=Hh(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}s?Mv(t,n,r):i&&Mv(t,i,o)}function oH(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i=Hh(n),o,s;for(;;)if(r<i){if(n.nodeType!=1)break;let a=n.childNodes[r];if(su(a,1))o=n,s=++r;else break}else{if(VE(n))break;{let a=n.nextSibling;for(;a&&su(a,1);)o=a.parentNode,s=Yn(a)+1,a=a.nextSibling;if(a)n=a,r=0,i=Hh(n);else{if(n=n.parentNode,n==t.dom)break;r=i=0}}}o&&Mv(t,o,s)}function VE(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function sH(t,e){for(;t&&e==t.childNodes.length&&!Rd(t);)e=Yn(t)+1,t=t.parentNode;for(;t&&e<t.childNodes.length;){let n=t.childNodes[e];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;t=n,e=0}}function aH(t,e){for(;t&&!e&&!Rd(t);)e=Yn(t),t=t.parentNode;for(;t&&e;){let n=t.childNodes[e-1];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;t=n,e=t.childNodes.length}}function Mv(t,e,n){if(e.nodeType!=3){let o,s;(s=sH(e,n))?(e=s,n=0):(o=aH(e,n))&&(e=o,n=o.nodeValue.length)}let r=t.domSelection();if(!r)return;if(bm(r)){let o=document.createRange();o.setEnd(e,n),o.setStart(e,n),r.removeAllRanges(),r.addRange(o)}else r.extend&&r.extend(e,n);t.domObserver.setCurSelection();let{state:i}=t;setTimeout(()=>{t.state==i&&Lo(t)},50)}function Lx(t,e){let n=t.state.doc.resolve(e);if(!(Qn||EE)&&n.parent.inlineContent){let i=t.coordsAtPos(e);if(e>n.start()){let o=t.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<n.end()){let o=t.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(t.dom).direction=="rtl"?"rtl":"ltr"}function Fx(t,e,n){let r=t.state.selection;if(r instanceof $e&&!r.empty||n.indexOf("s")>-1||ri&&n.indexOf("m")>-1)return!1;let{$from:i,$to:o}=r;if(!i.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let s=Tv(t.state,e);if(s&&s instanceof rt)return es(t,s)}if(!i.parent.inlineContent){let s=e<0?i:o,a=r instanceof Er?lt.near(s,e):lt.findFrom(s,e);return a?es(t,a):!1}return!1}function zx(t,e){if(!(t.state.selection instanceof $e))return!0;let{$head:n,$anchor:r,empty:i}=t.state.selection;if(!n.sameParent(r))return!0;if(!i)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let o=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(o&&!o.isText){let s=t.state.tr;return e<0?s.delete(n.pos-o.nodeSize,n.pos):s.delete(n.pos,n.pos+o.nodeSize),t.dispatch(s),!0}return!1}function Bx(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function lH(t){if(!or||t.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(e&&e.nodeType==1&&n==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;Bx(t,r,"true"),setTimeout(()=>Bx(t,r,"false"),20)}return!1}function cH(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function uH(t,e){let n=e.keyCode,r=cH(e);if(n==8||ri&&n==72&&r=="c")return zx(t,-1)||Ya(t,-1);if(n==46&&!e.shiftKey||ri&&n==68&&r=="c")return zx(t,1)||Ya(t,1);if(n==13||n==27)return!0;if(n==37||ri&&n==66&&r=="c"){let i=n==37?Lx(t,t.state.selection.from)=="ltr"?-1:1:-1;return Px(t,i,r)||Ya(t,i)}else if(n==39||ri&&n==70&&r=="c"){let i=n==39?Lx(t,t.state.selection.from)=="ltr"?1:-1:1;return Px(t,i,r)||Ya(t,i)}else{if(n==38||ri&&n==80&&r=="c")return Fx(t,-1,r)||Ya(t,-1);if(n==40||ri&&n==78&&r=="c")return lH(t)||Fx(t,1,r)||Ya(t,1);if(r==(ri?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function y1(t,e){t.someProp("transformCopied",p=>{e=p(e,t)});let n=[],{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;n.push(p.type.name,p.attrs!=p.type.defaultAttrs?p.attrs:null),r=p.content}let s=t.someProp("clipboardSerializer")||Ua.fromSchema(t.state.schema),a=GE(),l=a.createElement("div");l.appendChild(s.serializeFragment(r,{document:a}));let c=l.firstChild,u,f=0;for(;c&&c.nodeType==1&&(u=KE[c.nodeName.toLowerCase()]);){for(let p=u.length-1;p>=0;p--){let m=a.createElement(u[p]);for(;l.firstChild;)m.appendChild(l.firstChild);l.appendChild(m),f++}c=l.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${i} ${o}${f?` -${f}`:""} ${JSON.stringify(n)}`);let h=t.someProp("clipboardTextSerializer",p=>p(e,t))||e.content.textBetween(0,e.content.size,`
108
+
109
+ `);return{dom:l,text:h,slice:e}}function UE(t,e,n,r,i){let o=i.parent.type.spec.code,s,a;if(!n&&!e)return null;let l=!!e&&(r||o||!n);if(l){if(t.someProp("transformPastedText",h=>{e=h(e,o||r,t)}),o)return a=new Le(be.from(t.state.schema.text(e.replace(/\r\n?/g,`
110
+ `))),0,0),t.someProp("transformPasted",h=>{a=h(a,t,!0)}),a;let f=t.someProp("clipboardTextParser",h=>h(e,i,r,t));if(f)a=f;else{let h=i.marks(),{schema:p}=t.state,m=Ua.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 t.someProp("transformPastedHTML",f=>{n=f(n,t)}),s=pH(n),Nd&&mH(s);let c=s&&s.querySelector("[data-pm-slice]"),u=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let f=+u[3];f>0;f--){let h=s.firstChild;for(;h&&h.nodeType!=1;)h=h.nextSibling;if(!h)break;s=h}if(a||(a=(t.someProp("clipboardParser")||t.someProp("domParser")||Xc.fromSchema(t.state.schema)).parseSlice(s,{preserveWhitespace:!!(l||u),context:i,ruleFromNode(h){return h.nodeName=="BR"&&!h.nextSibling&&h.parentNode&&!dH.test(h.parentNode.nodeName)?{ignore:!0}:null}})),u)a=gH(Hx(a,+u[1],+u[2]),u[4]);else if(a=Le.maxOpen(fH(a.content,i),!0),a.openStart||a.openEnd){let f=0,h=0;for(let p=a.content.firstChild;f<a.openStart&&!p.type.spec.isolating;f++,p=p.firstChild);for(let p=a.content.lastChild;h<a.openEnd&&!p.type.spec.isolating;h++,p=p.lastChild);a=Hx(a,f,h)}return t.someProp("transformPasted",f=>{a=f(a,t,l)}),a}const dH=/^(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 fH(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let i=e.node(n).contentMatchAt(e.index(n)),o,s=[];if(t.forEach(a=>{if(!s)return;let l=i.findWrapping(a.type),c;if(!l)return s=null;if(c=s.length&&o.length&&qE(l,o,a,s[s.length-1],0))s[s.length-1]=c;else{s.length&&(s[s.length-1]=WE(s[s.length-1],o.length));let u=jE(a,l);s.push(u),i=i.matchType(u.type),o=l}}),s)return be.from(s)}return t}function jE(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,be.from(t));return t}function qE(t,e,n,r,i){if(i<t.length&&i<e.length&&t[i]==e[i]){let o=qE(t,e,n,r.lastChild,i+1);if(o)return r.copy(r.content.replaceChild(r.childCount-1,o));if(r.contentMatchAt(r.childCount).matchType(i==t.length-1?n.type:t[i+1]))return r.copy(r.content.append(be.from(jE(n,t,i+1))))}}function WE(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,WE(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(be.empty,!0);return t.copy(n.append(r))}function Dv(t,e,n,r,i,o){let s=e<0?t.firstChild:t.lastChild,a=s.content;return t.childCount>1&&(o=0),i<r-1&&(a=Dv(a,e,n,r,i+1,o)),i>=n&&(a=e<0?s.contentMatchAt(0).fillBefore(a,o<=i).append(a):a.append(s.contentMatchAt(s.childCount).fillBefore(be.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,s.copy(a))}function Hx(t,e,n){return e<t.openStart&&(t=new Le(Dv(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new Le(Dv(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const KE={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 Vx=null;function GE(){return Vx||(Vx=document.implementation.createHTMLDocument("title"))}let Tg=null;function hH(t){let e=window.trustedTypes;return e?(Tg||(Tg=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),Tg.createHTML(t)):t}function pH(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=GE().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),i;if((i=r&&KE[r[1].toLowerCase()])&&(t=i.map(o=>"<"+o+">").join("")+t+i.map(o=>"</"+o+">").reverse().join("")),n.innerHTML=hH(t),i)for(let o=0;o<i.length;o++)n=n.querySelector(i[o])||n;return n}function mH(t){let e=t.querySelectorAll(Qn?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<e.length;n++){let r=e[n];r.childNodes.length==1&&r.textContent==" "&&r.parentNode&&r.parentNode.replaceChild(t.ownerDocument.createTextNode(" "),r)}}function gH(t,e){if(!t.size)return t;let n=t.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return t}let{content:i,openStart:o,openEnd:s}=t;for(let a=r.length-2;a>=0;a-=2){let l=n.nodes[r[a]];if(!l||l.hasRequiredAttrs())break;i=be.from(l.create(r[a+1],i)),o++,s++}return new Le(i,o,s)}const br={},yr={},vH={touchstart:!0,touchmove:!0};class bH{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 yH(t){for(let e in br){let n=br[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{xH(t,r)&&!w1(t,r)&&(t.editable||!(r.type in yr))&&n(t,r)},vH[e]?{passive:!0}:void 0)}or&&t.dom.addEventListener("input",()=>null),Ov(t)}function bs(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function wH(t){t.domObserver.stop();for(let e in t.input.eventHandlers)t.dom.removeEventListener(e,t.input.eventHandlers[e]);clearTimeout(t.input.composingTimeout),clearTimeout(t.input.lastIOSEnterFallbackTimeout)}function Ov(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>w1(t,r))})}function w1(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function xH(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target;n!=t.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(e))return!1;return!0}function kH(t,e){!w1(t,e)&&br[e.type]&&(t.editable||!(e.type in yr))&&br[e.type](t,e)}yr.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!YE(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(Mo&&Qn&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),nc&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let r=Date.now();t.input.lastIOSEnter=r,t.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{t.input.lastIOSEnter==r&&(t.someProp("handleKeyDown",i=>i(t,Js(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||uH(t,n)?n.preventDefault():bs(t,"key")};yr.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};yr.keypress=(t,e)=>{let n=e;if(YE(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||ri&&n.metaKey)return;if(t.someProp("handleKeyPress",i=>i(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof $e)||!r.$from.sameParent(r.$to)){let i=String.fromCharCode(n.charCode),o=()=>t.state.tr.insertText(i).scrollIntoView();!/[\r\n]/.test(i)&&!t.someProp("handleTextInput",s=>s(t,r.$from.pos,r.$to.pos,i,o))&&t.dispatch(o()),n.preventDefault()}};function wm(t){return{left:t.clientX,top:t.clientY}}function _H(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function x1(t,e,n,r,i){if(r==-1)return!1;let o=t.state.doc.resolve(r);for(let s=o.depth+1;s>0;s--)if(t.someProp(e,a=>s>o.depth?a(t,n,o.nodeAfter,o.before(s),i,!0):a(t,n,o.node(s),o.before(s),i,!1)))return!0;return!1}function xl(t,e,n){if(t.focused||t.focus(),t.state.selection.eq(e))return;let r=t.state.tr.setSelection(e);r.setMeta("pointer",!0),t.dispatch(r)}function CH(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&rt.isSelectable(r)?(xl(t,new rt(n)),!0):!1}function SH(t,e){if(e==-1)return!1;let n=t.state.selection,r,i;n instanceof rt&&(r=n.node);let o=t.state.doc.resolve(e);for(let s=o.depth+1;s>0;s--){let a=s>o.depth?o.nodeAfter:o.node(s);if(rt.isSelectable(a)){r&&n.$from.depth>0&&s>=n.$from.depth&&o.before(n.$from.depth+1)==n.$from.pos?i=o.before(n.$from.depth):i=o.before(s);break}}return i!=null?(xl(t,rt.create(t.state.doc,i)),!0):!1}function EH(t,e,n,r,i){return x1(t,"handleClickOn",e,n,r)||t.someProp("handleClick",o=>o(t,e,r))||(i?SH(t,n):CH(t,n))}function AH(t,e,n,r){return x1(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",i=>i(t,e,r))}function TH(t,e,n,r){return x1(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",i=>i(t,e,r))||MH(t,n,r)}function MH(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(xl(t,$e.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)xl(t,$e.create(r,a+1,a+1+s.content.size));else if(rt.isSelectable(s))xl(t,rt.create(r,a));else continue;return!0}}function k1(t){return Vh(t)}const ZE=ri?"metaKey":"ctrlKey";br.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=k1(t),i=Date.now(),o="singleClick";i-t.input.lastClick.time<500&&_H(n,t.input.lastClick)&&!n[ZE]&&t.input.lastClick.button==n.button&&(t.input.lastClick.type=="singleClick"?o="doubleClick":t.input.lastClick.type=="doubleClick"&&(o="tripleClick")),t.input.lastClick={time:i,x:n.clientX,y:n.clientY,type:o,button:n.button};let s=t.posAtCoords(wm(n));s&&(o=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new DH(t,s,n,!!r)):(o=="doubleClick"?AH:TH)(t,s.pos,s.inside,n)?n.preventDefault():bs(t,"pointer"))};class DH{constructor(e,n,r,i){this.view=e,this.pos=n,this.event=r,this.flushed=i,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[ZE],this.allowDefault=r.shiftKey;let o,s;if(n.inside>-1)o=e.state.doc.nodeAt(n.inside),s=n.inside;else{let u=e.state.doc.resolve(n.pos);o=u.parent,s=u.depth?u.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 rt&&c.from<=s&&c.to>s)&&(this.mightDrag={node:o,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&pi&&!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)),bs(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(()=>Lo(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let n=this.pos;this.view.state.doc!=this.startDoc&&(n=this.view.posAtCoords(wm(e))),this.updateAllowDefault(e),this.allowDefault||!n?bs(this.view,"pointer"):EH(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||or&&this.mightDrag&&!this.mightDrag.node.isAtom||Qn&&!this.view.state.selection.visible&&Math.min(Math.abs(n.pos-this.view.state.selection.from),Math.abs(n.pos-this.view.state.selection.to))<=2)?(xl(this.view,lt.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):bs(this.view,"pointer")}move(e){this.updateAllowDefault(e),bs(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)}}br.touchstart=t=>{t.input.lastTouch=Date.now(),k1(t),bs(t,"pointer")};br.touchmove=t=>{t.input.lastTouch=Date.now(),bs(t,"pointer")};br.contextmenu=t=>k1(t);function YE(t,e){return t.composing?!0:or&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const OH=Mo?5e3:-1;yr.compositionstart=yr.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof $e&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||Qn&&EE&&IH(t)))t.markCursor=t.state.storedMarks||n.marks(),Vh(t,!0),t.markCursor=null;else if(Vh(t,!e.selection.empty),pi&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=t.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=t.domSelection();a&&a.collapse(s,s.nodeValue.length);break}else i=s,o=-1}}t.input.composing=!0}JE(t,OH)};function IH(t){let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(!e||e.nodeType!=1||n>=e.childNodes.length)return!1;let r=e.childNodes[n];return r.nodeType==1&&r.contentEditable=="false"}yr.compositionend=(t,e)=>{t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=e.timeStamp,t.input.compositionPendingChanges=t.domObserver.pendingRecords().length?t.input.compositionID:0,t.input.compositionNode=null,t.input.badSafariComposition?t.domObserver.forceFlush():t.input.compositionPendingChanges&&Promise.resolve().then(()=>t.domObserver.flush()),t.input.compositionID++,JE(t,20))};function JE(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>Vh(t),e))}function XE(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=NH());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function RH(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=SB(e.focusNode,e.focusOffset),r=EB(e.focusNode,e.focusOffset);if(n&&r&&n!=r){let i=r.pmViewDesc,o=t.domObserver.lastChangedTextNode;if(n==o||r==o)return o;if(!i||!i.isText(r.nodeValue))return r;if(t.input.compositionNode==r){let s=n.pmViewDesc;if(!(!s||!s.isText(n.nodeValue)))return r}}return n||r}function NH(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function Vh(t,e=!1){if(!(Mo&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),XE(t),e||t.docView&&t.docView.dirty){let n=v1(t),r=t.state.selection;return n&&!n.eq(r)?t.dispatch(t.state.tr.setSelection(n)):(t.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?t.dispatch(t.state.tr.deleteSelection()):t.updateState(t.state),!0}return!1}}function PH(t,e){if(!t.dom.parentNode)return;let n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),i=document.createRange();i.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()},50)}const Wu=Ar&&Cs<15||nc&&DB<604;br.copy=yr.cut=(t,e)=>{let n=e,r=t.state.selection,i=n.type=="cut";if(r.empty)return;let o=Wu?null:n.clipboardData,s=r.content(),{dom:a,text:l}=y1(t,s);o?(n.preventDefault(),o.clearData(),o.setData("text/html",a.innerHTML),o.setData("text/plain",l)):PH(t,a),i&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function LH(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function FH(t,e){if(!t.dom.parentNode)return;let n=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,r=t.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let i=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout(()=>{t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?Ku(t,r.value,null,i,e):Ku(t,r.textContent,r.innerHTML,i,e)},50)}function Ku(t,e,n,r,i){let o=UE(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",l=>l(t,i,o||Le.empty)))return!0;if(!o)return!1;let s=LH(o),a=s?t.state.tr.replaceSelectionWith(s,r):t.state.tr.replaceSelection(o);return t.dispatch(a.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function QE(t){let e=t.getData("text/plain")||t.getData("Text");if(e)return e;let n=t.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}yr.paste=(t,e)=>{let n=e;if(t.composing&&!Mo)return;let r=Wu?null:n.clipboardData,i=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&Ku(t,QE(r),r.getData("text/html"),i,n)?n.preventDefault():FH(t,n)};class $E{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const zH=ri?"altKey":"ctrlKey";function eA(t,e){let n=t.someProp("dragCopies",r=>!r(e));return n??!e[zH]}br.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let i=t.state.selection,o=i.empty?null:t.posAtCoords(wm(n)),s;if(!(o&&o.pos>=i.from&&o.pos<=(i instanceof rt?i.to-1:i.to))){if(r&&r.mightDrag)s=rt.create(t.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let f=t.docView.nearestDesc(n.target,!0);f&&f.node.type.spec.draggable&&f!=t.docView&&(s=rt.create(t.state.doc,f.posBefore))}}let a=(s||t.state.selection).content(),{dom:l,text:c,slice:u}=y1(t,a);(!n.dataTransfer.files.length||!Qn||SE>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(Wu?"Text":"text/html",l.innerHTML),n.dataTransfer.effectAllowed="copyMove",Wu||n.dataTransfer.setData("text/plain",c),t.dragging=new $E(u,eA(t,n),s)};br.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};yr.dragover=yr.dragenter=(t,e)=>e.preventDefault();yr.drop=(t,e)=>{try{BH(t,e,t.dragging)}finally{t.dragging=null}};function BH(t,e,n){if(!e.dataTransfer)return;let r=t.posAtCoords(wm(e));if(!r)return;let i=t.state.doc.resolve(r.pos),o=n&&n.slice;o?t.someProp("transformPasted",p=>{o=p(o,t,!1)}):o=UE(t,QE(e.dataTransfer),Wu?null:e.dataTransfer.getData("text/html"),!1,i);let s=!!(n&&eA(t,e));if(t.someProp("handleDrop",p=>p(t,e,o||Le.empty,s))){e.preventDefault();return}if(!o)return;e.preventDefault();let a=o?ZC(t.state.doc,i.pos,o):i.pos;a==null&&(a=i.pos);let l=t.state.tr;if(s){let{node:p}=n;p?p.replace(l):l.deleteSelection()}let c=l.mapping.map(a),u=o.openStart==0&&o.openEnd==0&&o.content.childCount==1,f=l.doc;if(u?l.replaceRangeWith(c,c,o.content.firstChild):l.replaceRange(c,c,o),l.doc.eq(f))return;let h=l.doc.resolve(c);if(u&&rt.isSelectable(o.content.firstChild)&&h.nodeAfter&&h.nodeAfter.sameMarkup(o.content.firstChild))l.setSelection(new rt(h));else{let p=l.mapping.map(a);l.mapping.maps[l.mapping.maps.length-1].forEach((m,v,g,b)=>p=b),l.setSelection(b1(t,h,l.doc.resolve(p)))}t.focus(),t.dispatch(l.setMeta("uiEvent","drop"))}br.focus=t=>{t.input.lastFocus=Date.now(),t.focused||(t.domObserver.stop(),t.dom.classList.add("ProseMirror-focused"),t.domObserver.start(),t.focused=!0,setTimeout(()=>{t.docView&&t.hasFocus()&&!t.domObserver.currentSelection.eq(t.domSelectionRange())&&Lo(t)},20))};br.blur=(t,e)=>{let n=e;t.focused&&(t.domObserver.stop(),t.dom.classList.remove("ProseMirror-focused"),t.domObserver.start(),n.relatedTarget&&t.dom.contains(n.relatedTarget)&&t.domObserver.currentSelection.clear(),t.focused=!1)};br.beforeinput=(t,e)=>{if(Qn&&Mo&&e.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:r}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=r||(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",o=>o(t,Js(8,"Backspace")))))return;let{$cursor:i}=t.state.selection;i&&i.pos>0&&t.dispatch(t.state.tr.delete(i.pos-1,i.pos).scrollIntoView())},50)}};for(let t in yr)br[t]=yr[t];function Gu(t,e){if(t==e)return!0;for(let n in t)if(t[n]!==e[n])return!1;for(let n in e)if(!(n in t))return!1;return!0}class Uh{constructor(e,n){this.toDOM=e,this.spec=n||wa,this.side=this.spec.side||0}map(e,n,r,i){let{pos:o,deleted:s}=e.mapResult(n.from+i,this.side<0?-1:1);return s?null:new Kt(o-r,o-r,this)}valid(){return!0}eq(e){return this==e||e instanceof Uh&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Gu(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Es{constructor(e,n){this.attrs=e,this.spec=n||wa}map(e,n,r,i){let o=e.map(n.from+i,this.spec.inclusiveStart?-1:1)-r,s=e.map(n.to+i,this.spec.inclusiveEnd?1:-1)-r;return o>=s?null:new Kt(o,s,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof Es&&Gu(this.attrs,e.attrs)&&Gu(this.spec,e.spec)}static is(e){return e.type instanceof Es}destroy(){}}class _1{constructor(e,n){this.attrs=e,this.spec=n||wa}map(e,n,r,i){let o=e.mapResult(n.from+i,1);if(o.deleted)return null;let s=e.mapResult(n.to+i,-1);return s.deleted||s.pos<=o.pos?null:new Kt(o.pos-r,s.pos-r,this)}valid(e,n){let{index:r,offset:i}=e.content.findIndex(n.from),o;return i==n.from&&!(o=e.child(r)).isText&&i+o.nodeSize==n.to}eq(e){return this==e||e instanceof _1&&Gu(this.attrs,e.attrs)&&Gu(this.spec,e.spec)}destroy(){}}class Kt{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new Kt(e,n,this.type)}eq(e,n=0){return this.type.eq(e.type)&&this.from+n==e.from&&this.to+n==e.to}map(e,n,r){return this.type.map(e,this,n,r)}static widget(e,n,r){return new Kt(e,e,new Uh(n,r))}static inline(e,n,r,i){return new Kt(e,n,new Es(r,i))}static node(e,n,r,i){return new Kt(e,n,new _1(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof Es}get widget(){return this.type instanceof Uh}}const rl=[],wa={};class ct{constructor(e,n){this.local=e.length?e:rl,this.children=n.length?n:rl}static create(e,n){return n.length?jh(n,e,0,wa):tr}find(e,n,r){let i=[];return this.findInner(e??0,n??1e9,i,0,r),i}findInner(e,n,r,i,o){for(let s=0;s<this.local.length;s++){let a=this.local[s];a.from<=n&&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]<n&&this.children[s+1]>e){let a=this.children[s]+1;this.children[s+2].findInner(e-a,n-a,r,i+a,o)}}map(e,n,r){return this==tr||e.maps.length==0?this:this.mapInner(e,n,0,0,r||wa)}mapInner(e,n,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(n,l)?(s||(s=[])).push(l):o.onRemove&&o.onRemove(this.local[a].spec)}return this.children.length?HH(this.children,s||[],e,n,r,i,o):s?new ct(s.sort(xa),rl):tr}add(e,n){return n.length?this==tr?ct.create(e,n):this.addInner(e,n,0):this}addInner(e,n,r){let i,o=0;e.forEach((a,l)=>{let c=l+r,u;if(u=nA(n,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,u,c+1):i.splice(o,0,l,l+a.nodeSize,jh(u,a,c+1,wa)),o+=3}});let s=tA(o?rA(n):n,-r);for(let a=0;a<s.length;a++)s[a].type.valid(e,s[a])||s.splice(a--,1);return new ct(s.length?this.local.concat(s).sort(xa):this.local,i||this.children)}remove(e){return e.length==0||this==tr?this:this.removeInner(e,0)}removeInner(e,n){let r=this.children,i=this.local;for(let o=0;o<r.length;o+=3){let s,a=r[o]+n,l=r[o+1]+n;for(let u=0,f;u<e.length;u++)(f=e[u])&&f.from>a&&f.to<l&&(e[u]=null,(s||(s=[])).push(f));if(!s)continue;r==this.children&&(r=this.children.slice());let c=r[o+2].removeInner(s,a+1);c!=tr?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,n)&&(i==this.local&&(i=this.local.slice()),i.splice(a--,1))}return r==this.children&&i==this.local?this:i.length||r.length?new ct(i,r):tr}forChild(e,n){if(this==tr)return this;if(n.isLeaf)return ct.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+n.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 Es){let c=Math.max(o,l.from)-o,u=Math.min(s,l.to)-o;c<u&&(i||(i=[])).push(l.copy(c,u))}}if(i){let a=new ct(i.sort(xa),rl);return r?new ss([a,r]):a}return r||tr}eq(e){if(this==e)return!0;if(!(e instanceof ct)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let n=0;n<this.local.length;n++)if(!this.local[n].eq(e.local[n]))return!1;for(let n=0;n<this.children.length;n+=3)if(this.children[n]!=e.children[n]||this.children[n+1]!=e.children[n+1]||!this.children[n+2].eq(e.children[n+2]))return!1;return!0}locals(e){return C1(this.localsInner(e))}localsInner(e){if(this==tr)return rl;if(e.inlineContent||!this.local.some(Es.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof Es||n.push(this.local[r]);return n}forEachSet(e){e(this)}}ct.empty=new ct([],[]);ct.removeOverlap=C1;const tr=ct.empty;class ss{constructor(e){this.members=e}map(e,n){const r=this.members.map(i=>i.map(e,n,wa));return ss.from(r)}forChild(e,n){if(n.isLeaf)return ct.empty;let r=[];for(let i=0;i<this.members.length;i++){let o=this.members[i].forChild(e,n);o!=tr&&(o instanceof ss?r=r.concat(o.members):r.push(o))}return ss.from(r)}eq(e){if(!(e instanceof ss)||e.members.length!=this.members.length)return!1;for(let n=0;n<this.members.length;n++)if(!this.members[n].eq(e.members[n]))return!1;return!0}locals(e){let n,r=!0;for(let i=0;i<this.members.length;i++){let o=this.members[i].localsInner(e);if(o.length)if(!n)n=o;else{r&&(n=n.slice(),r=!1);for(let s=0;s<o.length;s++)n.push(o[s])}}return n?C1(r?n:n.sort(xa)):rl}static from(e){switch(e.length){case 0:return tr;case 1:return e[0];default:return new ss(e.every(n=>n instanceof ct)?e:e.reduce((n,r)=>n.concat(r instanceof ct?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}}function HH(t,e,n,r,i,o,s){let a=t.slice();for(let c=0,u=o;c<n.maps.length;c++){let f=0;n.maps[c].forEach((h,p,m,v)=>{let g=v-m-(p-h);for(let b=0;b<a.length;b+=3){let _=a[b+1];if(_<0||h>_+u-f)continue;let k=a[b]+u-f;p>=k?a[b+1]=h<=k?-2:-1:h>=u&&g&&(a[b]+=g,a[b+1]+=g)}f+=g}),u=n.maps[c].map(u,-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 u=n.map(t[c]+o),f=u-i;if(f<0||f>=r.content.size){l=!0;continue}let h=n.map(t[c+1]+o,-1),p=h-i,{index:m,offset:v}=r.content.findIndex(f),g=r.maybeChild(m);if(g&&v==f&&v+g.nodeSize==p){let b=a[c+2].mapInner(n,g,u+1,t[c]+o+1,s);b!=tr?(a[c]=f,a[c+1]=p,a[c+2]=b):(a[c+1]=-2,l=!0)}else l=!0}if(l){let c=VH(a,t,e,n,i,o,s),u=jh(c,r,0,s);e=u.local;for(let f=0;f<a.length;f+=3)a[f+1]<0&&(a.splice(f,3),f-=3);for(let f=0,h=0;f<u.children.length;f+=3){let p=u.children[f];for(;h<a.length&&a[h]<p;)h+=3;a.splice(h,0,u.children[f],u.children[f+1],u.children[f+2])}}return new ct(e.sort(xa),a)}function tA(t,e){if(!e||!t.length)return t;let n=[];for(let r=0;r<t.length;r++){let i=t[r];n.push(new Kt(i.from+e,i.to+e,i.type))}return n}function VH(t,e,n,r,i,o,s){function a(l,c){for(let u=0;u<l.local.length;u++){let f=l.local[u].map(r,i,c);f?n.push(f):s.onRemove&&s.onRemove(l.local[u].spec)}for(let u=0;u<l.children.length;u+=3)a(l.children[u+2],l.children[u]+c+1)}for(let l=0;l<t.length;l+=3)t[l+1]==-1&&a(t[l+2],e[l]+o+1);return n}function nA(t,e,n){if(e.isLeaf)return null;let r=n+e.nodeSize,i=null;for(let o=0,s;o<t.length;o++)(s=t[o])&&s.from>n&&s.to<r&&((i||(i=[])).push(s),t[o]=null);return i}function rA(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function jh(t,e,n,r){let i=[],o=!1;e.forEach((a,l)=>{let c=nA(t,a,l+n);if(c){o=!0;let u=jh(c,a,n+l+1,r);u!=tr&&i.push(l,l+a.nodeSize,u)}});let s=tA(o?rA(t):t,-n).sort(xa);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 ct(s,i):tr}function xa(t,e){return t.from-e.from||t.to-e.to}function C1(t){let e=t;for(let n=0;n<e.length-1;n++){let r=e[n];if(r.from!=r.to)for(let i=n+1;i<e.length;i++){let o=e[i];if(o.from==r.from){o.to!=r.to&&(e==t&&(e=t.slice()),e[i]=o.copy(o.from,r.to),Ux(e,i+1,o.copy(r.to,o.to)));continue}else{o.from<r.to&&(e==t&&(e=t.slice()),e[n]=r.copy(r.from,o.from),Ux(e,i,r.copy(o.from,r.to)));break}}}return e}function Ux(t,e,n){for(;e<t.length&&xa(n,t[e])>0;)e++;t.splice(e,0,n)}function Mg(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=tr&&e.push(r)}),t.cursorWrapper&&e.push(ct.create(t.state.doc,[t.cursorWrapper.deco])),ss.from(e)}const UH={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},jH=Ar&&Cs<=11;class qH{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 WH{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new qH,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]);Ar&&Cs<=11&&r.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():or&&e.composing&&r.some(i=>i.type=="childList"&&i.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),jH&&(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,UH)),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 n=0;n<e.length;n++)this.queue.push(e[n]);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(Nx(this.view)){if(this.suppressingSelectionUpdates)return Lo(this.view);if(Ar&&Cs<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Na(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 n=new Set,r;for(let o=e.focusNode;o;o=tc(o))n.add(o);for(let o=e.anchorNode;o;o=tc(o))if(n.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 n=this.pendingRecords();n.length&&(this.queue=[]);let r=e.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&Nx(e)&&!this.ignoreSelectionChange(r),o=-1,s=-1,a=!1,l=[];if(e.editable)for(let u=0;u<n.length;u++){let f=this.registerMutation(n[u],l);f&&(o=o<0?f.from:Math.min(f.from,o),s=s<0?f.to:Math.max(f.to,s),f.typeOver&&(a=!0))}if(l.some(u=>u.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46)){for(let u of l)if(u.nodeName=="BR"&&u.parentNode){let f=u.nextSibling;for(;f&&f.nodeType==1;){if(f.contentEditable=="false"){u.parentNode.removeChild(u);break}f=f.firstChild}}}else if(pi&&l.length){let u=l.filter(f=>f.nodeName=="BR");if(u.length==2){let[f,h]=u;f.parentNode&&f.parentNode.parentNode==h.parentNode?h.remove():f.remove()}else{let{focusNode:f}=this.currentSelection;for(let h of u){let p=h.parentNode;p&&p.nodeName=="LI"&&(!f||ZH(e,f)!=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&&bm(r)&&(c=v1(e))&&c.eq(lt.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Lo(e),this.currentSelection.set(r),e.scrollToSelection()):(o>-1||i)&&(o>-1&&(e.docView.markDirty(o,s),KH(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,YH(e,l)),this.handleDOMChange(o,s,a,l),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||Lo(e),this.currentSelection.set(r))}registerMutation(e,n){if(n.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 u=0;u<e.addedNodes.length;u++){let f=e.addedNodes[u];n.push(f),f.nodeType==3&&(this.lastChangedTextNode=f)}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(Ar&&Cs<=11&&e.addedNodes.length)for(let u=0;u<e.addedNodes.length;u++){let{previousSibling:f,nextSibling:h}=e.addedNodes[u];(!f||Array.prototype.indexOf.call(e.addedNodes,f)<0)&&(i=f),(!h||Array.prototype.indexOf.call(e.addedNodes,h)<0)&&(o=h)}let s=i&&i.parentNode==e.target?Yn(i)+1:0,a=r.localPosFromDOM(e.target,s,-1),l=o&&o.parentNode==e.target?Yn(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 jx=new WeakMap,qx=!1;function KH(t){if(!jx.has(t)&&(jx.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=pi,qx)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."),qx=!0}}function Wx(t,e){let n=e.startContainer,r=e.startOffset,i=e.endContainer,o=e.endOffset,s=t.domAtPos(t.state.selection.anchor);return Na(s.node,s.offset,i,o)&&([n,r,i,o]=[i,o,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:o}}function GH(t,e){if(e.getComposedRanges){let i=e.getComposedRanges(t.root)[0];if(i)return Wx(t,i)}let n;function r(i){i.preventDefault(),i.stopImmediatePropagation(),n=i.getTargetRanges()[0]}return t.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),t.dom.removeEventListener("beforeinput",r,!0),n?Wx(t,n):null}function ZH(t,e){for(let n=e.parentNode;n&&n!=t.dom;n=n.parentNode){let r=t.docView.nearestDesc(n,!0);if(r&&r.node.isBlock)return n}return null}function YH(t,e){var n;let{focusNode:r,focusOffset:i}=t.domSelectionRange();for(let o of e)if(((n=o.parentNode)===null||n===void 0?void 0:n.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&&t.domSelection().collapse(o,i)}else o.parentNode.removeChild(o)}}function JH(t,e,n){let{node:r,fromOffset:i,toOffset:o,from:s,to:a}=t.docView.parseRange(e,n),l=t.domSelectionRange(),c,u=l.anchorNode;if(u&&t.dom.contains(u.nodeType==1?u:u.parentNode)&&(c=[{node:u,offset:l.anchorOffset}],bm(l)||c.push({node:l.focusNode,offset:l.focusOffset})),Qn&&t.input.lastKeyCode===8)for(let g=o;g>i;g--){let b=r.childNodes[g-1],_=b.pmViewDesc;if(b.nodeName=="BR"&&!_){o=g;break}if(!_||_.size)break}let f=t.state.doc,h=t.someProp("domParser")||Xc.fromSchema(t.state.schema),p=f.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:XH,context:p});if(c&&c[0].pos!=null){let g=c[0].pos,b=c[1]&&c[1].pos;b==null&&(b=g),m={anchor:g+s,head:b+s}}return{doc:v,sel:m,from:s,to:a}}function XH(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(or&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let n=document.createElement("div");return n.appendChild(document.createElement("li")),{skip:n}}else if(t.parentNode.lastChild==t||or&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if(t.nodeName=="IMG"&&t.getAttribute("mark-placeholder"))return{ignore:!0};return null}const QH=/^(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 $H(t,e,n,r,i){let o=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let A=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,M=v1(t,A);if(M&&!t.state.selection.eq(M)){if(Qn&&Mo&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",R=>R(t,Js(13,"Enter"))))return;let N=t.state.tr.setSelection(M);A=="pointer"?N.setMeta("pointer",!0):A=="key"&&N.scrollIntoView(),o&&N.setMeta("composition",o),t.dispatch(N)}return}let s=t.state.doc.resolve(e),a=s.sharedDepth(n);e=s.before(a+1),n=t.state.doc.resolve(n).after(a+1);let l=t.state.selection,c=JH(t,e,n),u=t.state.doc,f=u.slice(c.from,c.to),h,p;t.input.lastKeyCode===8&&Date.now()-100<t.input.lastKeyCodeTime?(h=t.state.selection.to,p="end"):(h=t.state.selection.from,p="start"),t.input.lastKeyCode=null;let m=nV(f.content,c.doc.content,c.from,h,p);if(m&&t.input.domChangeCount++,(nc&&t.input.lastIOSEnter>Date.now()-225||Mo)&&i.some(A=>A.nodeType==1&&!QH.test(A.nodeName))&&(!m||m.endA>=m.endB)&&t.someProp("handleKeyDown",A=>A(t,Js(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!m)if(r&&l instanceof $e&&!l.empty&&l.$head.sameParent(l.$anchor)&&!t.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))m={start:l.from,endA:l.to,endB:l.to};else{if(c.sel){let A=Kx(t,t.state.doc,c.sel);if(A&&!A.eq(t.state.selection)){let M=t.state.tr.setSelection(A);o&&M.setMeta("composition",o),t.dispatch(M)}}return}t.state.selection.from<t.state.selection.to&&m.start==m.endB&&t.state.selection instanceof $e&&(m.start>t.state.selection.from&&m.start<=t.state.selection.from+2&&t.state.selection.from>=c.from?m.start=t.state.selection.from:m.endA<t.state.selection.to&&m.endA>=t.state.selection.to-2&&t.state.selection.to<=c.to&&(m.endB+=t.state.selection.to-m.endA,m.endA=t.state.selection.to)),Ar&&Cs<=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),b=u.resolve(m.start),_=v.sameParent(g)&&v.parent.inlineContent&&b.end()>=m.endA;if((nc&&t.input.lastIOSEnter>Date.now()-225&&(!_||i.some(A=>A.nodeName=="DIV"||A.nodeName=="P"))||!_&&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,"","")))&&t.someProp("handleKeyDown",A=>A(t,Js(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>m.start&&tV(u,m.start,m.endA,v,g)&&t.someProp("handleKeyDown",A=>A(t,Js(8,"Backspace")))){Mo&&Qn&&t.domObserver.suppressSelectionUpdates();return}Qn&&m.endB==m.start&&(t.input.lastChromeDelete=Date.now()),Mo&&!_&&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(()=>{t.someProp("handleKeyDown",function(A){return A(t,Js(13,"Enter"))})},20));let k=m.start,C=m.endA,E=A=>{let M=A||t.state.tr.replace(k,C,c.doc.slice(m.start-c.from,m.endB-c.from));if(c.sel){let N=Kx(t,M.doc,c.sel);N&&!(Qn&&t.composing&&N.empty&&(m.start!=m.endB||t.input.lastChromeDelete<Date.now()-100)&&(N.head==k||N.head==M.mapping.map(C)-1)||Ar&&N.empty&&N.head==k)&&M.setSelection(N)}return o&&M.setMeta("composition",o),M.scrollIntoView()},I;if(_)if(v.pos==g.pos){Ar&&Cs<=11&&v.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>Lo(t),20));let A=E(t.state.tr.delete(k,C)),M=u.resolve(m.start).marksAcross(u.resolve(m.endA));M&&A.ensureMarks(M),t.dispatch(A)}else if(m.endA==m.endB&&(I=eV(v.parent.content.cut(v.parentOffset,g.parentOffset),b.parent.content.cut(b.parentOffset,m.endA-b.start())))){let A=E(t.state.tr);I.type=="add"?A.addMark(k,C,I.mark):A.removeMark(k,C,I.mark),t.dispatch(A)}else if(v.parent.child(v.index()).isText&&v.index()==g.index()-(g.textOffset?0:1)){let A=v.parent.textBetween(v.parentOffset,g.parentOffset),M=()=>E(t.state.tr.insertText(A,k,C));t.someProp("handleTextInput",N=>N(t,k,C,A,M))||t.dispatch(M())}else t.dispatch(E());else t.dispatch(E())}function Kx(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:b1(t,e.resolve(n.anchor),e.resolve(n.head))}function eV(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,i=n,o=r,s,a,l;for(let u=0;u<r.length;u++)i=r[u].removeFromSet(i);for(let u=0;u<n.length;u++)o=n[u].removeFromSet(o);if(i.length==1&&o.length==0)a=i[0],s="add",l=u=>u.mark(a.addToSet(u.marks));else if(i.length==0&&o.length==1)a=o[0],s="remove",l=u=>u.mark(a.removeFromSet(u.marks));else return null;let c=[];for(let u=0;u<e.childCount;u++)c.push(l(e.child(u)));if(be.from(c).eq(t))return{mark:a,type:s}}function tV(t,e,n,r,i){if(n-e<=i.pos-r.pos||Dg(r,!0,!1)<i.pos)return!1;let o=t.resolve(e);if(!r.parent.isTextblock){let a=o.nodeAfter;return a!=null&&n==e+a.nodeSize}if(o.parentOffset<o.parent.content.size||!o.parent.isTextblock)return!1;let s=t.resolve(Dg(o,!0,!0));return!s.parent.isTextblock||s.pos>n||Dg(s,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(s.parent.content)}function Dg(t,e,n){let r=t.depth,i=e?t.end():t.pos;for(;r>0&&(e||t.indexAfter(r)==t.node(r).childCount);)r--,i++,e=!1;if(n){let o=t.node(r).maybeChild(t.indexAfter(r));for(;o&&!o.isLeaf;)o=o.firstChild,i++}return i}function nV(t,e,n,r,i){let o=t.findDiffStart(e,n);if(o==null)return null;let{a:s,b:a}=t.findDiffEnd(e,n+t.size,n+e.size);if(i=="end"){let l=Math.max(0,o-Math.min(s,a));r-=s+l-o}if(s<o&&t.size<e.size){let l=r<=o&&r>=s?o-r:0;o-=l,o&&o<e.size&&Gx(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<t.size&&Gx(t.textBetween(o-1,o+1))&&(o+=l?1:-1),s=o+(s-a),a=o}return{start:o,endA:s,endB:a}}function Gx(t){if(t.length!=2)return!1;let e=t.charCodeAt(0),n=t.charCodeAt(1);return e>=56320&&e<=57343&&n>=55296&&n<=56319}class iA{constructor(e,n){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 bH,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(Qx),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=Jx(this),Yx(this),this.nodeViews=Xx(this),this.docView=Tx(this.state.doc,Zx(this),Mg(this),this.dom,this),this.domObserver=new WH(this,(r,i,o,s)=>$H(this,r,i,o,s)),this.domObserver.start(),yH(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 n in e)this._props[n]=e[n];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&Ov(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Qx),this.directPlugins=e.plugins),this.updateStateInner(e.state,n)}setProps(e){let n={};for(let r in this._props)n[r]=this._props[r];n.state=this.state;for(let r in e)n[r]=e[r];this.update(n)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,n){var r;let i=this.state,o=!1,s=!1;e.storedMarks&&this.composing&&(XE(this),s=!0),this.state=e;let a=i.plugins!=e.plugins||this._props.plugins!=n.plugins;if(a||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let p=Xx(this);iV(p,this.nodeViews)&&(this.nodeViews=p,o=!0)}(a||n.handleDOMEvents!=this._props.handleDOMEvents)&&Ov(this),this.editable=Jx(this),Yx(this);let l=Mg(this),c=Zx(this),u=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",f=o||!this.docView.matchesNode(e.doc,c,l);(f||!e.selection.eq(i.selection))&&(s=!0);let h=u=="preserve"&&s&&this.dom.style.overflowAnchor==null&&RB(this);if(s){this.domObserver.stop();let p=f&&(Ar||Qn)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&rV(i.selection,e.selection);if(f){let m=Qn?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=RH(this)),(o||!this.docView.update(e.doc,c,l,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=Tx(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())&&rH(this))?Lo(this,p):(BE(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),u=="reset"?this.dom.scrollTop=0:u=="to selection"?this.scrollToSelection():h&&NB(h)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",n=>n(this)))if(this.state.selection instanceof rt){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&kx(this,n.getBoundingClientRect(),e)}else kx(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 n=0;n<this.directPlugins.length;n++){let r=this.directPlugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let n=0;n<this.state.plugins.length;n++){let r=this.state.plugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let n=0;n<this.pluginViews.length;n++){let r=this.pluginViews[n];r.update&&r.update(this,e)}}updateDraggedNode(e,n){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-n.doc.content.size);(o>0&&o<this.state.doc.content.size&&this.state.doc.nodeAt(o))==r.node&&(i=o)}this.dragging=new $E(e.slice,e.move,i<0?void 0:rt.create(this.state.doc,i))}someProp(e,n){let r=this._props&&this._props[e],i;if(r!=null&&(i=n?n(r):r))return i;for(let s=0;s<this.directPlugins.length;s++){let a=this.directPlugins[s].props[e];if(a!=null&&(i=n?n(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=n?n(a):a))return i}}hasFocus(){if(Ar){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&&PB(this.dom),Lo(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let n=this.dom.parentNode;n;n=n.parentNode)if(n.nodeType==9||n.nodeType==11&&n.host)return n.getSelection||(Object.getPrototypeOf(n).getSelection=()=>n.ownerDocument.getSelection()),this._root=n}return e||document}updateRoot(){this._root=null}posAtCoords(e){return HB(this,e)}coordsAtPos(e,n=1){return OE(this,e,n)}domAtPos(e,n=0){return this.docView.domFromPos(e,n)}nodeDOM(e){let n=this.docView.descAt(e);return n?n.nodeDOM:null}posAtDOM(e,n,r=-1){let i=this.docView.posFromDOM(e,n,r);if(i==null)throw new RangeError("DOM position not inside the editor");return i}endOfTextblock(e,n){return WB(this,n||this.state,e)}pasteHTML(e,n){return Ku(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return Ku(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return y1(this,e)}destroy(){this.docView&&(wH(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Mg(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,_B())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return kH(this,e)}domSelectionRange(){let e=this.domSelection();return e?or&&this.root.nodeType===11&&TB(this.dom.ownerDocument)==this.dom&&GH(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}iA.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function Zx(t){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(t.editable),t.someProp("attributes",n=>{if(typeof n=="function"&&(n=n(t.state)),n)for(let r in n)r=="class"?e.class+=" "+n[r]:r=="style"?e.style=(e.style?e.style+";":"")+n[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(n[r]))}),e.translate||(e.translate="no"),[Kt.node(0,t.state.doc.content.size,e)]}function Yx(t){if(t.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),t.cursorWrapper={dom:e,deco:Kt.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function Jx(t){return!t.someProp("editable",e=>e(t.state)===!1)}function rV(t,e){let n=Math.min(t.$anchor.sharedDepth(t.head),e.$anchor.sharedDepth(e.head));return t.$anchor.start(n)!=e.$anchor.start(n)}function Xx(t){let e=Object.create(null);function n(r){for(let i in r)Object.prototype.hasOwnProperty.call(e,i)||(e[i]=r[i])}return t.someProp("nodeViews",n),t.someProp("markViews",n),e}function iV(t,e){let n=0,r=0;for(let i in t){if(t[i]!=e[i])return!0;n++}for(let i in e)r++;return n!=r}function Qx(t){if(t.spec.state||t.spec.filterTransaction||t.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var Ns={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:"'"},qh={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},oV=typeof navigator<"u"&&/Mac/.test(navigator.platform),sV=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Jn=0;Jn<10;Jn++)Ns[48+Jn]=Ns[96+Jn]=String(Jn);for(var Jn=1;Jn<=24;Jn++)Ns[Jn+111]="F"+Jn;for(var Jn=65;Jn<=90;Jn++)Ns[Jn]=String.fromCharCode(Jn+32),qh[Jn]=String.fromCharCode(Jn);for(var Og in Ns)qh.hasOwnProperty(Og)||(qh[Og]=Ns[Og]);function aV(t){var e=oV&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||sV&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?qh:Ns)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}const lV=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),cV=typeof navigator<"u"&&/Win/.test(navigator.platform);function uV(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");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))lV?s=!0:i=!0;else throw new Error("Unrecognized modifier name: "+l)}return r&&(n="Alt-"+n),i&&(n="Ctrl-"+n),s&&(n="Meta-"+n),o&&(n="Shift-"+n),n}function dV(t){let e=Object.create(null);for(let n in t)e[uV(n)]=t[n];return e}function Ig(t,e,n=!0){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),n&&e.shiftKey&&(t="Shift-"+t),t}function fV(t){return new Lt({props:{handleKeyDown:S1(t)}})}function S1(t){let e=dV(t);return function(n,r){let i=aV(r),o,s=e[Ig(i,r)];if(s&&s(n.state,n.dispatch,n))return!0;if(i.length==1&&i!=" "){if(r.shiftKey){let a=e[Ig(i,r,!1)];if(a&&a(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(cV&&r.ctrlKey&&r.altKey)&&(o=Ns[r.keyCode])&&o!=i){let a=e[Ig(o,r)];if(a&&a(n.state,n.dispatch,n))return!0}}return!1}}const E1=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function oA(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const sA=(t,e,n)=>{let r=oA(t,n);if(!r)return!1;let i=A1(r);if(!i){let s=r.blockRange(),a=s&&dc(s);return a==null?!1:(e&&e(t.tr.lift(s,a).scrollIntoView()),!0)}let o=i.nodeBefore;if(mA(t,i,e,-1))return!0;if(r.parent.content.size==0&&(rc(o,"end")||rt.isSelectable(o)))for(let s=r.depth;;s--){let a=qp(t.doc,r.before(s),r.after(s),Le.empty);if(a&&a.slice.size<a.to-a.from){if(e){let l=t.tr.step(a);l.setSelection(rc(o,"end")?lt.findFrom(l.doc.resolve(l.mapping.map(i.pos,-1)),-1):rt.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(t.tr.delete(i.pos-o.nodeSize,i.pos).scrollIntoView()),!0):!1},hV=(t,e,n)=>{let r=oA(t,n);if(!r)return!1;let i=A1(r);return i?aA(t,i,e):!1},pV=(t,e,n)=>{let r=cA(t,n);if(!r)return!1;let i=T1(r);return i?aA(t,i,e):!1};function aA(t,e,n){let r=e.nodeBefore,i=r,o=e.pos-1;for(;!i.isTextblock;o--){if(i.type.spec.isolating)return!1;let u=i.lastChild;if(!u)return!1;i=u}let s=e.nodeAfter,a=s,l=e.pos+1;for(;!a.isTextblock;l++){if(a.type.spec.isolating)return!1;let u=a.firstChild;if(!u)return!1;a=u}let c=qp(t.doc,o,l,Le.empty);if(!c||c.from!=o||c instanceof Ln&&c.slice.size>=l-o)return!1;if(n){let u=t.tr.step(c);u.setSelection($e.create(u.doc,o)),n(u.scrollIntoView())}return!0}function rc(t,e,n=!1){for(let r=t;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&r.childCount!=1)return!1}return!1}const lA=(t,e,n)=>{let{$head:r,empty:i}=t.selection,o=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):r.parentOffset>0)return!1;o=A1(r)}let s=o&&o.nodeBefore;return!s||!rt.isSelectable(s)?!1:(e&&e(t.tr.setSelection(rt.create(t.doc,o.pos-s.nodeSize)).scrollIntoView()),!0)};function A1(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){if(t.index(e)>0)return t.doc.resolve(t.before(e+1));if(t.node(e).type.spec.isolating)break}return null}function cA(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const uA=(t,e,n)=>{let r=cA(t,n);if(!r)return!1;let i=T1(r);if(!i)return!1;let o=i.nodeAfter;if(mA(t,i,e,1))return!0;if(r.parent.content.size==0&&(rc(o,"start")||rt.isSelectable(o))){let s=qp(t.doc,r.before(),r.after(),Le.empty);if(s&&s.slice.size<s.to-s.from){if(e){let a=t.tr.step(s);a.setSelection(rc(o,"start")?lt.findFrom(a.doc.resolve(a.mapping.map(i.pos)),1):rt.create(a.doc,a.mapping.map(i.pos))),e(a.scrollIntoView())}return!0}}return o.isAtom&&i.depth==r.depth-1?(e&&e(t.tr.delete(i.pos,i.pos+o.nodeSize).scrollIntoView()),!0):!1},dA=(t,e,n)=>{let{$head:r,empty:i}=t.selection,o=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):r.parentOffset<r.parent.content.size)return!1;o=T1(r)}let s=o&&o.nodeAfter;return!s||!rt.isSelectable(s)?!1:(e&&e(t.tr.setSelection(rt.create(t.doc,o.pos)).scrollIntoView()),!0)};function T1(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){let n=t.node(e);if(t.index(e)+1<n.childCount)return t.doc.resolve(t.after(e+1));if(n.type.spec.isolating)break}return null}const mV=(t,e)=>{let n=t.selection,r=n instanceof rt,i;if(r){if(n.node.isTextblock||!zs(t.doc,n.from))return!1;i=n.from}else if(i=jp(t.doc,n.from,-1),i==null)return!1;if(e){let o=t.tr.join(i);r&&o.setSelection(rt.create(o.doc,i-t.doc.resolve(i).nodeBefore.nodeSize)),e(o.scrollIntoView())}return!0},gV=(t,e)=>{let n=t.selection,r;if(n instanceof rt){if(n.node.isTextblock||!zs(t.doc,n.to))return!1;r=n.to}else if(r=jp(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},vV=(t,e)=>{let{$from:n,$to:r}=t.selection,i=n.blockRange(r),o=i&&dc(i);return o==null?!1:(e&&e(t.tr.lift(i,o).scrollIntoView()),!0)},fA=(t,e)=>{let{$head:n,$anchor:r}=t.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(e&&e(t.tr.insertText(`
111
+ `).scrollIntoView()),!0)};function M1(t){for(let e=0;e<t.edgeCount;e++){let{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}const bV=(t,e)=>{let{$head:n,$anchor:r}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let i=n.node(-1),o=n.indexAfter(-1),s=M1(i.contentMatchAt(o));if(!s||!i.canReplaceWith(o,o,s))return!1;if(e){let a=n.after(),l=t.tr.replaceWith(a,a,s.createAndFill());l.setSelection(lt.near(l.doc.resolve(a),1)),e(l.scrollIntoView())}return!0},hA=(t,e)=>{let n=t.selection,{$from:r,$to:i}=n;if(n instanceof Er||r.parent.inlineContent||i.parent.inlineContent)return!1;let o=M1(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=t.tr.insert(s,o.createAndFill());a.setSelection($e.create(a.doc,s+1)),e(a.scrollIntoView())}return!0},pA=(t,e)=>{let{$cursor:n}=t.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let o=n.before();if(Io(t.doc,o))return e&&e(t.tr.split(o).scrollIntoView()),!0}let r=n.blockRange(),i=r&&dc(r);return i==null?!1:(e&&e(t.tr.lift(r,i).scrollIntoView()),!0)};function yV(t){return(e,n)=>{let{$from:r,$to:i}=e.selection;if(e.selection instanceof rt&&e.selection.node.isBlock)return!r.parentOffset||!Io(e.doc,r.pos)?!1:(n&&n(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=M1(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 u=e.tr;(e.selection instanceof $e||e.selection instanceof Er)&&u.deleteSelection();let f=u.mapping.map(r.pos),h=Io(u.doc,f,o.length,o);if(h||(o[0]=a?{type:a}:null,h=Io(u.doc,f,o.length,o)),!h)return!1;if(u.split(f,o.length,o),!l&&c&&r.node(s).type!=a){let p=u.mapping.map(r.before(s)),m=u.doc.resolve(p);a&&r.node(s-1).canReplaceWith(m.index(),m.index()+1,a)&&u.setNodeMarkup(u.mapping.map(r.before(s)),a)}return n&&n(u.scrollIntoView()),!0}}const wV=yV(),xV=(t,e)=>{let{$from:n,to:r}=t.selection,i,o=n.sharedDepth(r);return o==0?!1:(i=n.before(o),e&&e(t.tr.setSelection(rt.create(t.doc,i))),!0)};function kV(t,e,n){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)?(n&&n(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(o,o+1)||!(i.isTextblock||zs(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function mA(t,e,n,r){let i=e.nodeBefore,o=e.nodeAfter,s,a,l=i.type.spec.isolating||o.type.spec.isolating;if(!l&&kV(t,e,n))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(n){let p=e.pos+o.nodeSize,m=be.empty;for(let b=s.length-1;b>=0;b--)m=be.from(s[b].create(null,m));m=be.from(i.copy(m));let v=t.tr.step(new Hn(e.pos-1,p,e.pos,p,new Le(m,1,0),s.length,!0)),g=v.doc.resolve(p+2*s.length);g.nodeAfter&&g.nodeAfter.type==i.type&&zs(v.doc,g.pos)&&v.join(g.pos),n(v.scrollIntoView())}return!0}let u=o.type.spec.isolating||r>0&&l?null:lt.findFrom(e,1),f=u&&u.$from.blockRange(u.$to),h=f&&dc(f);if(h!=null&&h>=e.depth)return n&&n(t.tr.lift(f,h).scrollIntoView()),!0;if(c&&rc(o,"start",!0)&&rc(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(n){let b=be.empty;for(let k=m.length-1;k>=0;k--)b=be.from(m[k].copy(b));let _=t.tr.step(new Hn(e.pos-m.length,e.pos+o.nodeSize,e.pos+g,e.pos+o.nodeSize-g,new Le(b,m.length,0),0,!0));n(_.scrollIntoView())}return!0}}return!1}function gA(t){return function(e,n){let r=e.selection,i=t<0?r.$from:r.$to,o=i.depth;for(;i.node(o).isInline;){if(!o)return!1;o--}return i.node(o).isTextblock?(n&&n(e.tr.setSelection($e.create(e.doc,t<0?i.start(o):i.end(o)))),!0):!1}}const _V=gA(-1),CV=gA(1);function SV(t,e=null){return function(n,r){let{$from:i,$to:o}=n.selection,s=i.blockRange(o),a=s&&Ib(s,t,e);return a?(r&&r(n.tr.wrap(s,a).scrollIntoView()),!0):!1}}function $x(t,e=null){return function(n,r){let i=!1;for(let o=0;o<n.selection.ranges.length&&!i;o++){let{$from:{pos:s},$to:{pos:a}}=n.selection.ranges[o];n.doc.nodesBetween(s,a,(l,c)=>{if(i)return!1;if(!(!l.isTextblock||l.hasMarkup(t,e)))if(l.type==t)i=!0;else{let u=n.doc.resolve(c),f=u.index();i=u.parent.canReplaceWith(f,f+1,t)}})}if(!i)return!1;if(r){let o=n.tr;for(let s=0;s<n.selection.ranges.length;s++){let{$from:{pos:a},$to:{pos:l}}=n.selection.ranges[s];o.setBlockType(a,l,t,e)}r(o.scrollIntoView())}return!0}}function D1(...t){return function(e,n,r){for(let i=0;i<t.length;i++)if(t[i](e,n,r))return!0;return!1}}D1(E1,sA,lA);D1(E1,uA,dA);D1(fA,hA,pA,wV);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function EV(t,e=null){return function(n,r){let{$from:i,$to:o}=n.selection,s=i.blockRange(o);if(!s)return!1;let a=r?n.tr:null;return AV(a,s,t,e)?(r&&r(a.scrollIntoView()),!0):!1}}function AV(t,e,n,r=null){let i=!1,o=e,s=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(n)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let l=s.resolve(e.start-2);o=new wh(l,l,e.depth),e.endIndex<e.parent.childCount&&(e=new wh(e.$from,s.resolve(e.$to.end(e.depth)),e.depth)),i=!0}let a=Ib(o,n,r,e);return a?(t&&TV(t,e,a,i,n),!0):!1}function TV(t,e,n,r,i){let o=be.empty;for(let u=n.length-1;u>=0;u--)o=be.from(n[u].type.create(n[u].attrs,o));t.step(new Hn(e.start-(r?2:0),e.end,e.start,e.end,new Le(o,0,0),n.length,!0));let s=0;for(let u=0;u<n.length;u++)n[u].type==i&&(s=u+1);let a=n.length-s,l=e.start+n.length-(r?2:0),c=e.parent;for(let u=e.startIndex,f=e.endIndex,h=!0;u<f;u++,h=!1)!h&&Io(t.doc,l,a)&&(t.split(l,a),l+=2*a),l+=c.child(u).nodeSize;return t}function MV(t){return function(e,n){let{$from:r,$to:i}=e.selection,o=r.blockRange(i,s=>s.childCount>0&&s.firstChild.type==t);return o?n?r.node(o.depth-1).type==t?DV(e,n,t,o):OV(e,n,o):!0:!1}}function DV(t,e,n,r){let i=t.tr,o=r.end,s=r.$to.end(r.depth);o<s&&(i.step(new Hn(o-1,s,o,s,new Le(be.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new wh(i.doc.resolve(r.$from.pos),i.doc.resolve(s),r.depth));const a=dc(r);if(a==null)return!1;i.lift(r,a);let l=i.doc.resolve(i.mapping.map(o,-1)-1);return zs(i.doc,l.pos)&&l.nodeBefore.type==l.nodeAfter.type&&i.join(l.pos),e(i.scrollIntoView()),!0}function OV(t,e,n){let r=t.tr,i=n.parent;for(let p=n.end,m=n.endIndex-1,v=n.startIndex;m>v;m--)p-=i.child(m).nodeSize,r.delete(p-1,p+1);let o=r.doc.resolve(n.start),s=o.nodeAfter;if(r.mapping.map(n.end)!=n.start+o.nodeAfter.nodeSize)return!1;let a=n.startIndex==0,l=n.endIndex==i.childCount,c=o.node(-1),u=o.index(-1);if(!c.canReplace(u+(a?0:1),u+1,s.content.append(l?be.empty:be.from(i))))return!1;let f=o.pos,h=f+s.nodeSize;return r.step(new Hn(f-(a?1:0),h+(l?1:0),f+1,h-1,new Le((a?be.empty:be.from(i.copy(be.empty))).append(l?be.empty:be.from(i.copy(be.empty))),a?0:1,l?0:1),a?0:1)),e(r.scrollIntoView()),!0}function IV(t){return function(e,n){let{$from:r,$to:i}=e.selection,o=r.blockRange(i,c=>c.childCount>0&&c.firstChild.type==t);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!=t)return!1;if(n){let c=l.lastChild&&l.lastChild.type==a.type,u=be.from(c?t.create():null),f=new Le(be.from(t.create(null,be.from(a.type.create(null,u)))),c?3:1,0),h=o.start,p=o.end;n(e.tr.step(new Hn(h-(c?3:1),p,h,p,f,1,!0)).scrollIntoView())}return!0}}function xm(t){const{state:e,transaction:n}=t;let{selection:r}=n,{doc:i}=n,{storedMarks:o}=n;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=n.selection,i=n.doc,o=n.storedMarks,n}}}class km{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:n,state:r}=this,{view:i}=n,{tr:o}=r,s=this.buildProps(o);return Object.fromEntries(Object.entries(e).map(([a,l])=>[a,(...u)=>{const f=l(...u)(s);return!o.getMeta("preventDispatch")&&!this.hasCustomState&&i.dispatch(o),f}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(e,n=!0){const{rawCommands:r,editor:i,state:o}=this,{view:s}=i,a=[],l=!!e,c=e||o.tr,u=()=>(!l&&n&&!c.getMeta("preventDispatch")&&!this.hasCustomState&&s.dispatch(c),a.every(h=>h===!0)),f={...Object.fromEntries(Object.entries(r).map(([h,p])=>[h,(...v)=>{const g=this.buildProps(c,n),b=p(...v)(g);return a.push(b),f}])),run:u};return f}createCan(e){const{rawCommands:n,state:r}=this,i=!1,o=e||r.tr,s=this.buildProps(o,i);return{...Object.fromEntries(Object.entries(n).map(([l,c])=>[l,(...u)=>c(...u)({...s,dispatch:void 0})])),chain:()=>this.createChain(o,i)}}buildProps(e,n=!0){const{rawCommands:r,editor:i,state:o}=this,{view:s}=i,a={tr:e,editor:i,view:s,state:xm({state:o,transaction:e}),dispatch:n?()=>{}:void 0,chain:()=>this.createChain(e,n),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(r).map(([l,c])=>[l,(...u)=>c(...u)(a)]))}};return a}}class RV{constructor(){this.callbacks={}}on(e,n){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(n),this}emit(e,...n){const r=this.callbacks[e];return r&&r.forEach(i=>i.apply(this,n)),this}off(e,n){const r=this.callbacks[e];return r&&(n?this.callbacks[e]=r.filter(i=>i!==n):delete this.callbacks[e]),this}once(e,n){const r=(...i)=>{this.off(e,r),n.apply(this,i)};return this.on(e,r)}removeAllListeners(){this.callbacks={}}}function qe(t,e,n){return t.config[e]===void 0&&t.parent?qe(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?qe(t.parent,e,n):null}):t.config[e]}function _m(t){const e=t.filter(i=>i.type==="extension"),n=t.filter(i=>i.type==="node"),r=t.filter(i=>i.type==="mark");return{baseExtensions:e,nodeExtensions:n,markExtensions:r}}function vA(t){const e=[],{nodeExtensions:n,markExtensions:r}=_m(t),i=[...n,...r],o={default:null,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return t.forEach(s=>{const a={name:s.name,options:s.options,storage:s.storage,extensions:i},l=qe(s,"addGlobalAttributes",a);if(!l)return;l().forEach(u=>{u.types.forEach(f=>{Object.entries(u.attributes).forEach(([h,p])=>{e.push({type:f,name:h,attribute:{...o,...p}})})})})}),i.forEach(s=>{const a={name:s.name,options:s.options,storage:s.storage},l=qe(s,"addAttributes",a);if(!l)return;const c=l();Object.entries(c).forEach(([u,f])=>{const h={...o,...f};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:u,attribute:h})})}),e}function jn(t,e){if(typeof t=="string"){if(!e.nodes[t])throw Error(`There is no node type named '${t}'. Maybe you forgot to add the extension?`);return e.nodes[t]}return t}function cn(...t){return t.filter(e=>!!e).reduce((e,n)=>{const r={...e};return Object.entries(n).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(u=>!l.includes(u));r[i]=[...l,...c].join(" ")}else if(i==="style"){const a=o?o.split(";").map(u=>u.trim()).filter(Boolean):[],l=r[i]?r[i].split(";").map(u=>u.trim()).filter(Boolean):[],c=new Map;l.forEach(u=>{const[f,h]=u.split(":").map(p=>p.trim());c.set(f,h)}),a.forEach(u=>{const[f,h]=u.split(":").map(p=>p.trim());c.set(f,h)}),r[i]=Array.from(c.entries()).map(([u,f])=>`${u}: ${f}`).join("; ")}else r[i]=o}),r},{})}function Iv(t,e){return e.filter(n=>n.type===t.type.name).filter(n=>n.attribute.rendered).map(n=>n.attribute.renderHTML?n.attribute.renderHTML(t.attrs)||{}:{[n.name]:t.attrs[n.name]}).reduce((n,r)=>cn(n,r),{})}function bA(t){return typeof t=="function"}function kt(t,e=void 0,...n){return bA(t)?e?t.bind(e)(...n):t(...n):t}function NV(t={}){return Object.keys(t).length===0&&t.constructor===Object}function PV(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function ek(t,e){return"style"in t?t:{...t,getAttrs:n=>{const r=t.getAttrs?t.getAttrs(n):t.attrs;if(r===!1)return!1;const i=e.reduce((o,s)=>{const a=s.attribute.parseHTML?s.attribute.parseHTML(n):PV(n.getAttribute(s.name));return a==null?o:{...o,[s.name]:a}},{});return{...r,...i}}}}function tk(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&NV(n)?!1:n!=null))}function LV(t,e){var n;const r=vA(t),{nodeExtensions:i,markExtensions:o}=_m(t),s=(n=i.find(c=>qe(c,"topNode")))===null||n===void 0?void 0:n.name,a=Object.fromEntries(i.map(c=>{const u=r.filter(b=>b.type===c.name),f={name:c.name,options:c.options,storage:c.storage,editor:e},h=t.reduce((b,_)=>{const k=qe(_,"extendNodeSchema",f);return{...b,...k?k(c):{}}},{}),p=tk({...h,content:kt(qe(c,"content",f)),marks:kt(qe(c,"marks",f)),group:kt(qe(c,"group",f)),inline:kt(qe(c,"inline",f)),atom:kt(qe(c,"atom",f)),selectable:kt(qe(c,"selectable",f)),draggable:kt(qe(c,"draggable",f)),code:kt(qe(c,"code",f)),whitespace:kt(qe(c,"whitespace",f)),linebreakReplacement:kt(qe(c,"linebreakReplacement",f)),defining:kt(qe(c,"defining",f)),isolating:kt(qe(c,"isolating",f)),attrs:Object.fromEntries(u.map(b=>{var _;return[b.name,{default:(_=b==null?void 0:b.attribute)===null||_===void 0?void 0:_.default}]}))}),m=kt(qe(c,"parseHTML",f));m&&(p.parseDOM=m.map(b=>ek(b,u)));const v=qe(c,"renderHTML",f);v&&(p.toDOM=b=>v({node:b,HTMLAttributes:Iv(b,u)}));const g=qe(c,"renderText",f);return g&&(p.toText=g),[c.name,p]})),l=Object.fromEntries(o.map(c=>{const u=r.filter(g=>g.type===c.name),f={name:c.name,options:c.options,storage:c.storage,editor:e},h=t.reduce((g,b)=>{const _=qe(b,"extendMarkSchema",f);return{...g,..._?_(c):{}}},{}),p=tk({...h,inclusive:kt(qe(c,"inclusive",f)),excludes:kt(qe(c,"excludes",f)),group:kt(qe(c,"group",f)),spanning:kt(qe(c,"spanning",f)),code:kt(qe(c,"code",f)),attrs:Object.fromEntries(u.map(g=>{var b;return[g.name,{default:(b=g==null?void 0:g.attribute)===null||b===void 0?void 0:b.default}]}))}),m=kt(qe(c,"parseHTML",f));m&&(p.parseDOM=m.map(g=>ek(g,u)));const v=qe(c,"renderHTML",f);return v&&(p.toDOM=g=>v({mark:g,HTMLAttributes:Iv(g,u)})),[c.name,p]}));return new Mb({topNode:s,nodes:a,marks:l})}function Rg(t,e){return e.nodes[t]||e.marks[t]||null}function nk(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function O1(t,e){const n=Ua.fromSchema(e).serializeFragment(t),i=document.implementation.createHTMLDocument().createElement("div");return i.appendChild(n),i.innerHTML}const FV=(t,e=500)=>{let n="";const r=t.parentOffset;return t.parent.nodesBetween(Math.max(0,r-e),r,(i,o,s,a)=>{var l,c;const u=((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%";n+=i.isAtom&&!i.isText?u:u.slice(0,Math.max(0,r-o))}),n};function I1(t){return Object.prototype.toString.call(t)==="[object RegExp]"}class Ld{constructor(e){this.find=e.find,this.handler=e.handler}}const zV=(t,e)=>{if(I1(e))return e.exec(t);const n=e(t);if(!n)return null;const r=[n.text];return r.index=n.index,r.input=t,r.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(n.replaceWith)),r};function sf(t){var e;const{editor:n,from:r,to:i,text:o,rules:s,plugin:a}=t,{view:l}=n;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 u=!1;const f=FV(c)+o;return s.forEach(h=>{if(u)return;const p=zV(f,h.find);if(!p)return;const m=l.state.tr,v=xm({state:l.state,transaction:m}),g={from:r-(p[0].length-o.length),to:i},{commands:b,chain:_,can:k}=new km({editor:n,state:v});h.handler({state:v,range:g,match:p,commands:b,chain:_,can:k})===null||!m.steps.length||(m.setMeta(a,{transform:m,from:r,to:i,text:o}),l.dispatch(m),u=!0)}),u}function BV(t){const{editor:e,rules:n}=t,r=new Lt({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:u}=l;typeof u=="string"?u=u:u=O1(be.from(u),s.schema);const{from:f}=l,h=f+u.length;sf({editor:e,from:f,to:h,text:u,rules:n,plugin:r})}),i.selectionSet||i.docChanged?null:o}},props:{handleTextInput(i,o,s,a){return sf({editor:e,from:o,to:s,text:a,rules:n,plugin:r})},handleDOMEvents:{compositionend:i=>(setTimeout(()=>{const{$cursor:o}=i.state.selection;o&&sf({editor:e,from:o.pos,to:o.pos,text:"",rules:n,plugin:r})}),!1)},handleKeyDown(i,o){if(o.key!=="Enter")return!1;const{$cursor:s}=i.state.selection;return s?sf({editor:e,from:s.pos,to:s.pos,text:`
112
+ `,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function HV(t){return Object.prototype.toString.call(t).slice(8,-1)}function af(t){return HV(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function Cm(t,e){const n={...t};return af(t)&&af(e)&&Object.keys(e).forEach(r=>{af(e[r])&&af(t[r])?n[r]=Cm(t[r],e[r]):n[r]=e[r]}),n}class Ri{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=kt(qe(this,"addOptions",{name:this.name}))),this.storage=kt(qe(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new Ri(e)}configure(e={}){const n=this.extend({...this.config,addOptions:()=>Cm(this.options,e)});return n.name=this.name,n.parent=this.parent,n}extend(e={}){const n=new Ri(e);return n.parent=this,this.child=n,n.name=e.name?e.name:n.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: "${n.name}".`),n.options=kt(qe(n,"addOptions",{name:n.name})),n.storage=kt(qe(n,"addStorage",{name:n.name,options:n.options})),n}static handleExit({editor:e,mark:n}){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)===n.name))return!1;const l=s.find(c=>(c==null?void 0:c.type.name)===n.name);return l&&r.removeStoredMark(l),r.insertText(" ",i.pos),e.view.dispatch(r),!0}return!1}}function VV(t){return typeof t=="number"}class UV{constructor(e){this.find=e.find,this.handler=e.handler}}const jV=(t,e,n)=>{if(I1(e))return[...t.matchAll(e)];const r=e(t,n);return r?r.map(i=>{const o=[i.text];return o.index=i.index,o.input=t,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 qV(t){const{editor:e,state:n,from:r,to:i,rule:o,pasteEvent:s,dropEvent:a}=t,{commands:l,chain:c,can:u}=new km({editor:e,state:n}),f=[];return n.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),b=p.textBetween(v-m,g-m,void 0,"");jV(b,o.find,s).forEach(k=>{if(k.index===void 0)return;const C=v+k.index+1,E=C+k[0].length,I={from:n.tr.mapping.map(C),to:n.tr.mapping.map(E)},A=o.handler({state:n,range:I,match:k,commands:l,chain:c,can:u,pasteEvent:s,dropEvent:a});f.push(A)})}),f.every(p=>p!==null)}let lf=null;const WV=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)===null||e===void 0||e.setData("text/html",t),n};function KV(t){const{editor:e,rules:n}=t;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:u,from:f,to:h,rule:p,pasteEvt:m})=>{const v=u.tr,g=xm({state:u,transaction:v});if(!(!qV({editor:e,state:g,from:Math.max(f-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 n.map(u=>new Lt({view(f){const h=m=>{var v;r=!((v=f.dom.parentElement)===null||v===void 0)&&v.contains(m.target)?f.dom.parentElement:null,r&&(lf=e)},p=()=>{lf&&(lf=null)};return window.addEventListener("dragstart",h),window.addEventListener("dragend",p),{destroy(){window.removeEventListener("dragstart",h),window.removeEventListener("dragend",p)}}},props:{handleDOMEvents:{drop:(f,h)=>{if(o=r===f.dom.parentElement,a=h,!o){const p=lf;p!=null&&p.isEditable&&setTimeout(()=>{const m=p.state.selection;m&&p.commands.deleteRange({from:m.from,to:m.to})},10)}return!1},paste:(f,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:(f,h,p)=>{const m=f[0],v=m.getMeta("uiEvent")==="paste"&&!i,g=m.getMeta("uiEvent")==="drop"&&!o,b=m.getMeta("applyPasteRules"),_=!!b;if(!v&&!g&&!_)return;if(_){let{text:E}=b;typeof E=="string"?E=E:E=O1(be.from(E),p.schema);const{from:I}=b,A=I+E.length,M=WV(E);return l({rule:u,state:p,from:I,to:{b:A},pasteEvt:M})}const k=h.doc.content.findDiffStart(p.doc.content),C=h.doc.content.findDiffEnd(p.doc.content);if(!(!VV(k)||!C||k===C.b))return l({rule:u,state:p,from:k,to:C,pasteEvt:s})}}))}function GV(t){const e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}class ul{constructor(e,n){this.splittableMarks=[],this.editor=n,this.extensions=ul.resolve(e),this.schema=LV(this.extensions,n),this.setupExtensions()}static resolve(e){const n=ul.sort(ul.flatten(e)),r=GV(n.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.`),n}static flatten(e){return e.map(n=>{const r={name:n.name,options:n.options,storage:n.storage},i=qe(n,"addExtensions",r);return i?[n,...this.flatten(i())]:n}).flat(10)}static sort(e){return e.sort((r,i)=>{const o=qe(r,"priority")||100,s=qe(i,"priority")||100;return o>s?-1:o<s?1:0})}get commands(){return this.extensions.reduce((e,n)=>{const r={name:n.name,options:n.options,storage:n.storage,editor:this.editor,type:Rg(n.name,this.schema)},i=qe(n,"addCommands",r);return i?{...e,...i()}:e},{})}get plugins(){const{editor:e}=this,n=ul.sort([...this.extensions].reverse()),r=[],i=[],o=n.map(s=>{const a={name:s.name,options:s.options,storage:s.storage,editor:e,type:Rg(s.name,this.schema)},l=[],c=qe(s,"addKeyboardShortcuts",a);let u={};if(s.type==="mark"&&qe(s,"exitable",a)&&(u.ArrowRight=()=>Ri.handleExit({editor:e,mark:s})),c){const v=Object.fromEntries(Object.entries(c()).map(([g,b])=>[g,()=>b({editor:e})]));u={...u,...v}}const f=fV(u);l.push(f);const h=qe(s,"addInputRules",a);nk(s,e.options.enableInputRules)&&h&&r.push(...h());const p=qe(s,"addPasteRules",a);nk(s,e.options.enablePasteRules)&&p&&i.push(...p());const m=qe(s,"addProseMirrorPlugins",a);if(m){const v=m();l.push(...v)}return l}).flat();return[BV({editor:e,rules:r}),...KV({editor:e,rules:i}),...o]}get attributes(){return vA(this.extensions)}get nodeViews(){const{editor:e}=this,{nodeExtensions:n}=_m(this.extensions);return Object.fromEntries(n.filter(r=>!!qe(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:jn(r.name,this.schema)},s=qe(r,"addNodeView",o);if(!s)return[];const a=(l,c,u,f,h)=>{const p=Iv(l,i);return s()({node:l,view:c,getPos:u,decorations:f,innerDecorations:h,editor:e,extension:r,HTMLAttributes:p})};return[r.name,a]}))}setupExtensions(){this.extensions.forEach(e=>{var n;this.editor.extensionStorage[e.name]=e.storage;const r={name:e.name,options:e.options,storage:e.storage,editor:this.editor,type:Rg(e.name,this.schema)};e.type==="mark"&&(!((n=kt(qe(e,"keepOnSplit",r)))!==null&&n!==void 0)||n)&&this.splittableMarks.push(e.name);const i=qe(e,"onBeforeCreate",r),o=qe(e,"onCreate",r),s=qe(e,"onUpdate",r),a=qe(e,"onSelectionUpdate",r),l=qe(e,"onTransaction",r),c=qe(e,"onFocus",r),u=qe(e,"onBlur",r),f=qe(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),u&&this.editor.on("blur",u),f&&this.editor.on("destroy",f)})}}class Jt{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=kt(qe(this,"addOptions",{name:this.name}))),this.storage=kt(qe(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new Jt(e)}configure(e={}){const n=this.extend({...this.config,addOptions:()=>Cm(this.options,e)});return n.name=this.name,n.parent=this.parent,n}extend(e={}){const n=new Jt({...this.config,...e});return n.parent=this,this.child=n,n.name=e.name?e.name:n.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: "${n.name}".`),n.options=kt(qe(n,"addOptions",{name:n.name})),n.storage=kt(qe(n,"addStorage",{name:n.name,options:n.options})),n}}function yA(t,e,n){const{from:r,to:i}=e,{blockSeparator:o=`
113
+
114
+ `,textSerializers:s={}}=n||{};let a="";return t.nodesBetween(r,i,(l,c,u,f)=>{var h;l.isBlock&&c>r&&(a+=o);const p=s==null?void 0:s[l.type.name];if(p)return u&&(a+=p({node:l,pos:c,parent:u,index:f,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 wA(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}const ZV=Jt.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new Lt({key:new Ut("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:e,schema:n}=t,{doc:r,selection:i}=e,{ranges:o}=i,s=Math.min(...o.map(u=>u.$from.pos)),a=Math.max(...o.map(u=>u.$to.pos)),l=wA(n);return yA(r,{from:s,to:a},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:l})}}})]}}),YV=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window==null?void 0:window.getSelection())===null||n===void 0||n.removeAllRanges())}),!0),JV=(t=!1)=>({commands:e})=>e.setContent("",t),XV=()=>({state:t,tr:e,dispatch:n})=>{const{selection:r}=e,{ranges:i}=r;return n&&i.forEach(({$from:o,$to:s})=>{t.doc.nodesBetween(o.pos,s.pos,(a,l)=>{if(a.type.isText)return;const{doc:c,mapping:u}=e,f=c.resolve(u.map(l)),h=c.resolve(u.map(l+a.nodeSize)),p=f.blockRange(h);if(!p)return;const m=dc(p);if(a.type.isTextblock){const{defaultType:v}=f.parent.contentMatchAt(f.index());e.setNodeMarkup(p.start,v)}(m||m===0)&&e.lift(p,m)})}),!0},QV=t=>e=>t(e),$V=()=>({state:t,dispatch:e})=>hA(t,e),eU=(t,e)=>({editor:n,tr:r})=>{const{state:i}=n,o=i.doc.slice(t.from,t.to);r.deleteRange(t.from,t.to);const s=r.mapping.map(e);return r.insert(s,o.content),r.setSelection(new $e(r.doc.resolve(Math.max(s-1,0)))),!0},tU=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,r=n.$anchor.node();if(r.content.size>0)return!1;const i=t.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);t.delete(a,l).scrollIntoView()}return!0}return!1},nU=t=>({tr:e,state:n,dispatch:r})=>{const i=jn(t,n.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},rU=t=>({tr:e,dispatch:n})=>{const{from:r,to:i}=t;return n&&e.delete(r,i),!0},iU=()=>({state:t,dispatch:e})=>E1(t,e),oU=()=>({commands:t})=>t.keyboardShortcut("Enter"),sU=()=>({state:t,dispatch:e})=>bV(t,e);function Wh(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(i=>n.strict?e[i]===t[i]:I1(e[i])?e[i].test(t[i]):e[i]===t[i]):!0}function xA(t,e,n={}){return t.find(r=>r.type===e&&Wh(Object.fromEntries(Object.keys(n).map(i=>[i,r.attrs[i]])),n))}function rk(t,e,n={}){return!!xA(t,e,n)}function R1(t,e,n){var r;if(!t||!e)return;let i=t.parent.childAfter(t.parentOffset);if((!i.node||!i.node.marks.some(u=>u.type===e))&&(i=t.parent.childBefore(t.parentOffset)),!i.node||!i.node.marks.some(u=>u.type===e)||(n=n||((r=i.node.marks[0])===null||r===void 0?void 0:r.attrs),!xA([...i.node.marks],e,n)))return;let s=i.index,a=t.start()+i.offset,l=s+1,c=a+i.node.nodeSize;for(;s>0&&rk([...t.parent.child(s-1).marks],e,n);)s-=1,a-=t.parent.child(s).nodeSize;for(;l<t.parent.childCount&&rk([...t.parent.child(l).marks],e,n);)c+=t.parent.child(l).nodeSize,l+=1;return{from:a,to:c}}function Vs(t,e){if(typeof t=="string"){if(!e.marks[t])throw Error(`There is no mark type named '${t}'. Maybe you forgot to add the extension?`);return e.marks[t]}return t}const aU=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const o=Vs(t,r.schema),{doc:s,selection:a}=n,{$from:l,from:c,to:u}=a;if(i){const f=R1(l,o,e);if(f&&f.from<=c&&f.to>=u){const h=$e.create(s,f.from,f.to);n.setSelection(h)}}return!0},lU=t=>e=>{const n=typeof t=="function"?t(e):t;for(let r=0;r<n.length;r+=1)if(n[r](e))return!0;return!1};function kA(t){return t instanceof $e}function ia(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function _A(t,e=null){if(!e)return null;const n=lt.atStart(t),r=lt.atEnd(t);if(e==="start"||e===!0)return n;if(e==="end")return r;const i=n.from,o=r.to;return e==="all"?$e.create(t,ia(0,i,o),ia(t.content.size,i,o)):$e.create(t,ia(e,i,o),ia(e,i,o))}function ik(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function Kh(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function cU(){return typeof navigator<"u"?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}const uU=(t=null,e={})=>({editor:n,view:r,tr:i,dispatch:o})=>{e={scrollIntoView:!0,...e};const s=()=>{(Kh()||ik())&&r.dom.focus(),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),cU()&&!Kh()&&!ik()&&r.dom.focus({preventScroll:!0}))})};if(r.hasFocus()&&t===null||t===!1)return!0;if(o&&t===null&&!kA(n.state.selection))return s(),!0;const a=_A(i.doc,t)||n.state.selection,l=n.state.selection.eq(a);return o&&(l||i.setSelection(a),l&&i.storedMarks&&i.setStoredMarks(i.storedMarks),s()),!0},dU=(t,e)=>n=>t.every((r,i)=>e(r,{...n,index:i})),fU=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),CA=t=>{const e=t.childNodes;for(let n=e.length-1;n>=0;n-=1){const r=e[n];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?t.removeChild(r):r.nodeType===1&&CA(r)}return t};function cf(t){const e=`<body>${t}</body>`,n=new window.DOMParser().parseFromString(e,"text/html").body;return CA(n)}function Zu(t,e,n){if(t instanceof _s||t instanceof be)return t;n={slice:!0,parseOptions:{},...n};const r=typeof t=="object"&&t!==null,i=typeof t=="string";if(r)try{if(Array.isArray(t)&&t.length>0)return be.fromArray(t.map(a=>e.nodeFromJSON(a)));const s=e.nodeFromJSON(t);return n.errorOnInvalidContent&&s.check(),s}catch(o){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:o});return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",o),Zu("",e,n)}if(i){if(n.errorOnInvalidContent){let s=!1,a="";const l=new Mb({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(n.slice?Xc.fromSchema(l).parseSlice(cf(t),n.parseOptions):Xc.fromSchema(l).parse(cf(t),n.parseOptions),n.errorOnInvalidContent&&s)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${a}`)})}const o=Xc.fromSchema(e);return n.slice?o.parseSlice(cf(t),n.parseOptions).content:o.parse(cf(t),n.parseOptions)}return Zu("",e,n)}function hU(t,e,n){const r=t.steps.length-1;if(r<e)return;const i=t.steps[r];if(!(i instanceof Ln||i instanceof Hn))return;const o=t.mapping.maps[r];let s=0;o.forEach((a,l,c,u)=>{s===0&&(s=u)}),t.setSelection(lt.near(t.doc.resolve(s),n))}const pU=t=>!("type"in t),mU=(t,e,n)=>({tr:r,dispatch:i,editor:o})=>{var s;if(i){n={parseOptions:o.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let a;const l=g=>{o.emit("contentError",{editor:o,error:g,disableCollaboration:()=>{o.storage.collaboration&&(o.storage.collaboration.isDisabled=!0)}})},c={preserveWhitespace:"full",...n.parseOptions};if(!n.errorOnInvalidContent&&!o.options.enableContentCheck&&o.options.emitContentError)try{Zu(e,o.schema,{parseOptions:c,errorOnInvalidContent:!0})}catch(g){l(g)}try{a=Zu(e,o.schema,{parseOptions:c,errorOnInvalidContent:(s=n.errorOnInvalidContent)!==null&&s!==void 0?s:o.options.enableContentCheck})}catch(g){return l(g),!1}let{from:u,to:f}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},h=!0,p=!0;if((pU(a)?a:[a]).forEach(g=>{g.check(),h=h?g.isText&&g.marks.length===0:!1,p=p?g.isBlock:!1}),u===f&&p){const{parent:g}=r.doc.resolve(u);g.isTextblock&&!g.type.spec.code&&!g.childCount&&(u-=1,f+=1)}let v;if(h){if(Array.isArray(e))v=e.map(g=>g.text||"").join("");else if(e instanceof be){let g="";e.forEach(b=>{b.text&&(g+=b.text)}),v=g}else typeof e=="object"&&e&&e.text?v=e.text:v=e;r.insertText(v,u,f)}else v=a,r.replaceWith(u,f,v);n.updateSelection&&hU(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:u,text:v}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:u,text:v})}return!0},gU=()=>({state:t,dispatch:e})=>mV(t,e),vU=()=>({state:t,dispatch:e})=>gV(t,e),bU=()=>({state:t,dispatch:e})=>sA(t,e),yU=()=>({state:t,dispatch:e})=>uA(t,e),wU=()=>({state:t,dispatch:e,tr:n})=>{try{const r=jp(t.doc,t.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},xU=()=>({state:t,dispatch:e,tr:n})=>{try{const r=jp(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},kU=()=>({state:t,dispatch:e})=>hV(t,e),_U=()=>({state:t,dispatch:e})=>pV(t,e);function SA(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function CU(t){const e=t.split(/-(?!$)/);let n=e[e.length-1];n==="Space"&&(n=" ");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))Kh()||SA()?s=!0:i=!0;else throw new Error(`Unrecognized modifier name: ${l}`)}return r&&(n=`Alt-${n}`),i&&(n=`Ctrl-${n}`),s&&(n=`Meta-${n}`),o&&(n=`Shift-${n}`),n}const SU=t=>({editor:e,view:n,tr:r,dispatch:i})=>{const o=CU(t).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(()=>{n.someProp("handleKeyDown",c=>c(n,a))});return l==null||l.steps.forEach(c=>{const u=c.map(r.mapping);u&&i&&r.maybeStep(u)}),!0};function Yu(t,e,n={}){const{from:r,to:i,empty:o}=t.selection,s=e?jn(e,t.schema):null,a=[];t.doc.nodesBetween(r,i,(f,h)=>{if(f.isText)return;const p=Math.max(r,h),m=Math.min(i,h+f.nodeSize);a.push({node:f,from:p,to:m})});const l=i-r,c=a.filter(f=>s?s.name===f.node.type.name:!0).filter(f=>Wh(f.node.attrs,n,{strict:!1}));return o?!!c.length:c.reduce((f,h)=>f+h.to-h.from,0)>=l}const EU=(t,e={})=>({state:n,dispatch:r})=>{const i=jn(t,n.schema);return Yu(n,i,e)?vV(n,r):!1},AU=()=>({state:t,dispatch:e})=>pA(t,e),TU=t=>({state:e,dispatch:n})=>{const r=jn(t,e.schema);return MV(r)(e,n)},MU=()=>({state:t,dispatch:e})=>fA(t,e);function Sm(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function ok(t,e){const n=typeof e=="string"?[e]:e;return Object.keys(t).reduce((r,i)=>(n.includes(i)||(r[i]=t[i]),r),{})}const DU=(t,e)=>({tr:n,state:r,dispatch:i})=>{let o=null,s=null;const a=Sm(typeof t=="string"?t:t.name,r.schema);return a?(a==="node"&&(o=jn(t,r.schema)),a==="mark"&&(s=Vs(t,r.schema)),i&&n.selection.ranges.forEach(l=>{r.doc.nodesBetween(l.$from.pos,l.$to.pos,(c,u)=>{o&&o===c.type&&n.setNodeMarkup(u,void 0,ok(c.attrs,e)),s&&c.marks.length&&c.marks.forEach(f=>{s===f.type&&n.addMark(u,u+c.nodeSize,s.create(ok(f.attrs,e)))})})}),!0):!1},OU=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),IU=()=>({tr:t,dispatch:e})=>{if(e){const n=new Er(t.doc);t.setSelection(n)}return!0},RU=()=>({state:t,dispatch:e})=>lA(t,e),NU=()=>({state:t,dispatch:e})=>dA(t,e),PU=()=>({state:t,dispatch:e})=>xV(t,e),LU=()=>({state:t,dispatch:e})=>CV(t,e),FU=()=>({state:t,dispatch:e})=>_V(t,e);function Rv(t,e,n={},r={}){return Zu(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}const zU=(t,e=!1,n={},r={})=>({editor:i,tr:o,dispatch:s,commands:a})=>{var l,c;const{doc:u}=o;if(n.preserveWhitespace!=="full"){const f=Rv(t,i.schema,n,{errorOnInvalidContent:(l=r.errorOnInvalidContent)!==null&&l!==void 0?l:i.options.enableContentCheck});return s&&o.replaceWith(0,u.content.size,f).setMeta("preventUpdate",!e),!0}return s&&o.setMeta("preventUpdate",!e),a.insertContentAt({from:0,to:u.content.size},t,{parseOptions:n,errorOnInvalidContent:(c=r.errorOnInvalidContent)!==null&&c!==void 0?c:i.options.enableContentCheck})};function EA(t,e){const n=Vs(e,t.schema),{from:r,to:i,empty:o}=t.selection,s=[];o?(t.storedMarks&&s.push(...t.storedMarks),s.push(...t.selection.$head.marks())):t.doc.nodesBetween(r,i,l=>{s.push(...l.marks)});const a=s.find(l=>l.type.name===n.name);return a?{...a.attrs}:{}}function BU(t,e){const n=new Rb(t);return e.forEach(r=>{r.steps.forEach(i=>{n.step(i)})}),n}function HU(t){for(let e=0;e<t.edgeCount;e+=1){const{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}function VU(t,e,n){const r=[];return t.nodesBetween(e.from,e.to,(i,o)=>{n(i)&&r.push({node:i,pos:o})}),r}function AA(t,e){for(let n=t.depth;n>0;n-=1){const r=t.node(n);if(e(r))return{pos:n>0?t.before(n):0,start:t.start(n),depth:n,node:r}}}function N1(t){return e=>AA(e.$from,t)}function UU(t,e){const n={from:0,to:t.content.size};return yA(t,n,e)}function jU(t,e){const n=jn(e,t.schema),{from:r,to:i}=t.selection,o=[];t.doc.nodesBetween(r,i,a=>{o.push(a)});const s=o.reverse().find(a=>a.type.name===n.name);return s?{...s.attrs}:{}}function TA(t,e){const n=Sm(typeof e=="string"?e:e.name,t.schema);return n==="node"?jU(t,e):n==="mark"?EA(t,e):{}}function qU(t,e=JSON.stringify){const n={};return t.filter(r=>{const i=e(r);return Object.prototype.hasOwnProperty.call(n,i)?!1:n[i]=!0})}function WU(t){const e=qU(t);return e.length===1?e:e.filter((n,r)=>!e.filter((o,s)=>s!==r).some(o=>n.oldRange.from>=o.oldRange.from&&n.oldRange.to<=o.oldRange.to&&n.newRange.from>=o.newRange.from&&n.newRange.to<=o.newRange.to))}function KU(t){const{mapping:e,steps:n}=t,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}=n[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),u=e.slice(o).map(l),f=e.invert().map(c,-1),h=e.invert().map(u);r.push({oldRange:{from:f,to:h},newRange:{from:c,to:u}})})}),WU(r)}function P1(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(i=>{const o=n.resolve(t),s=R1(o,i.type);s&&r.push({mark:i,...s})}):n.nodesBetween(t,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 Xf(t,e,n){return Object.fromEntries(Object.entries(n).filter(([r])=>{const i=t.find(o=>o.type===e&&o.name===r);return i?i.attribute.keepOnSplit:!1}))}function Nv(t,e,n={}){const{empty:r,ranges:i}=t.selection,o=e?Vs(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(f=>o?o.name===f.type.name:!0).find(f=>Wh(f.attrs,n,{strict:!1}));let s=0;const a=[];if(i.forEach(({$from:f,$to:h})=>{const p=f.pos,m=h.pos;t.doc.nodesBetween(p,m,(v,g)=>{if(!v.isText&&!v.marks.length)return;const b=Math.max(p,g),_=Math.min(m,g+v.nodeSize),k=_-b;s+=k,a.push(...v.marks.map(C=>({mark:C,from:b,to:_})))})}),s===0)return!1;const l=a.filter(f=>o?o.name===f.mark.type.name:!0).filter(f=>Wh(f.mark.attrs,n,{strict:!1})).reduce((f,h)=>f+h.to-h.from,0),c=a.filter(f=>o?f.mark.type!==o&&f.mark.type.excludes(o):!0).reduce((f,h)=>f+h.to-h.from,0);return(l>0?l+c:l)>=s}function GU(t,e,n={}){if(!e)return Yu(t,null,n)||Nv(t,null,n);const r=Sm(e,t.schema);return r==="node"?Yu(t,e,n):r==="mark"?Nv(t,e,n):!1}function sk(t,e){const{nodeExtensions:n}=_m(e),r=n.find(s=>s.name===t);if(!r)return!1;const i={name:r.name,options:r.options,storage:r.storage},o=kt(qe(r,"group",i));return typeof o!="string"?!1:o.split(" ").includes("list")}function Em(t,{checkChildren:e=!0,ignoreWhitespace:n=!1}={}){var r;if(n){if(t.type.name==="hardBreak")return!0;if(t.isText)return/^\s*$/m.test((r=t.text)!==null&&r!==void 0?r:"")}if(t.isText)return!t.text;if(t.isAtom||t.isLeaf)return!1;if(t.content.childCount===0)return!0;if(e){let i=!0;return t.content.forEach(o=>{i!==!1&&(Em(o,{ignoreWhitespace:n,checkChildren:e})||(i=!1))}),i}return!1}function ZU(t){return t instanceof rt}function YU(t,e,n){var r;const{selection:i}=e;let o=null;if(kA(i)&&(o=i.$cursor),o){const a=(r=t.storedMarks)!==null&&r!==void 0?r:o.marks();return!!n.isInSet(a)||!a.some(l=>l.type.excludes(n))}const{ranges:s}=i;return s.some(({$from:a,$to:l})=>{let c=a.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(n):!1;return t.doc.nodesBetween(a.pos,l.pos,(u,f,h)=>{if(c)return!1;if(u.isInline){const p=!h||h.type.allowsMarkType(n),m=!!n.isInSet(u.marks)||!u.marks.some(v=>v.type.excludes(n));c=p&&m}return!c}),c})}const JU=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const{selection:o}=n,{empty:s,ranges:a}=o,l=Vs(t,r.schema);if(i)if(s){const c=EA(r,l);n.addStoredMark(l.create({...c,...e}))}else a.forEach(c=>{const u=c.$from.pos,f=c.$to.pos;r.doc.nodesBetween(u,f,(h,p)=>{const m=Math.max(p,u),v=Math.min(p+h.nodeSize,f);h.marks.find(b=>b.type===l)?h.marks.forEach(b=>{l===b.type&&n.addMark(m,v,l.create({...b.attrs,...e}))}):n.addMark(m,v,l.create(e))})});return YU(r,n,l)},XU=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),QU=(t,e={})=>({state:n,dispatch:r,chain:i})=>{const o=jn(t,n.schema);let s;return n.selection.$anchor.sameParent(n.selection.$head)&&(s=n.selection.$anchor.parent.attrs),o.isTextblock?i().command(({commands:a})=>$x(o,{...s,...e})(n)?!0:a.clearNodes()).command(({state:a})=>$x(o,{...s,...e})(a,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},$U=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,i=ia(t,0,r.content.size),o=rt.create(r,i);e.setSelection(o)}return!0},ej=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:i,to:o}=typeof t=="number"?{from:t,to:t}:t,s=$e.atStart(r).from,a=$e.atEnd(r).to,l=ia(i,s,a),c=ia(o,s,a),u=$e.create(r,l,c);e.setSelection(u)}return!0},tj=t=>({state:e,dispatch:n})=>{const r=jn(t,e.schema);return IV(r)(e,n)};function ak(t,e){const n=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();if(n){const r=n.filter(i=>e==null?void 0:e.includes(i.type.name));t.tr.ensureMarks(r)}}const nj=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:i})=>{const{selection:o,doc:s}=e,{$from:a,$to:l}=o,c=i.extensionManager.attributes,u=Xf(c,a.node().type.name,a.node().attrs);if(o instanceof rt&&o.node.isBlock)return!a.parentOffset||!Io(s,a.pos)?!1:(r&&(t&&ak(n,i.extensionManager.splittableMarks),e.split(a.pos).scrollIntoView()),!0);if(!a.parent.isBlock)return!1;const f=l.parentOffset===l.parent.content.size,h=a.depth===0?void 0:HU(a.node(-1).contentMatchAt(a.indexAfter(-1)));let p=f&&h?[{type:h,attrs:u}]:void 0,m=Io(e.doc,e.mapping.map(a.pos),1,p);if(!p&&!m&&Io(e.doc,e.mapping.map(a.pos),1,h?[{type:h}]:void 0)&&(m=!0,p=h?[{type:h,attrs:u}]:void 0),r){if(m&&(o instanceof $e&&e.deleteSelection(),e.split(e.mapping.map(a.pos),1,p),h&&!f&&!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)}t&&ak(n,i.extensionManager.splittableMarks),e.scrollIntoView()}return m},rj=(t,e={})=>({tr:n,state:r,dispatch:i,editor:o})=>{var s;const a=jn(t,r.schema),{$from:l,$to:c}=r.selection,u=r.selection.node;if(u&&u.isBlock||l.depth<2||!l.sameParent(c))return!1;const f=l.node(-1);if(f.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 b=be.empty;const _=l.index(-1)?1:l.index(-2)?2:3;for(let M=l.depth-_;M>=l.depth-3;M-=1)b=be.from(l.node(M).copy(b));const k=l.indexAfter(-1)<l.node(-2).childCount?1:l.indexAfter(-2)<l.node(-3).childCount?2:3,C={...Xf(h,l.node().type.name,l.node().attrs),...e},E=((s=a.contentMatch.defaultType)===null||s===void 0?void 0:s.createAndFill(C))||void 0;b=b.append(be.from(a.createAndFill(null,E)||void 0));const I=l.before(l.depth-(_-1));n.replace(I,l.after(-k),new Le(b,4-_,0));let A=-1;n.doc.nodesBetween(I,n.doc.content.size,(M,N)=>{if(A>-1)return!1;M.isTextblock&&M.content.size===0&&(A=N+1)}),A>-1&&n.setSelection($e.near(n.doc.resolve(A))),n.scrollIntoView()}return!0}const p=c.pos===l.end()?f.contentMatchAt(0).defaultType:null,m={...Xf(h,f.type.name,f.attrs),...e},v={...Xf(h,l.node().type.name,l.node().attrs),...e};n.delete(l.pos,c.pos);const g=p?[{type:a,attrs:m},{type:p,attrs:v}]:[{type:a,attrs:m}];if(!Io(n.doc,l.pos,2))return!1;if(i){const{selection:b,storedMarks:_}=r,{splittableMarks:k}=o.extensionManager,C=_||b.$to.parentOffset&&b.$from.marks();if(n.split(l.pos,2,g).scrollIntoView(),!C||!i)return!0;const E=C.filter(I=>k.includes(I.type.name));n.ensureMarks(E)}return!0},Ng=(t,e)=>{const n=N1(s=>s.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(r===void 0)return!0;const i=t.doc.nodeAt(r);return n.node.type===(i==null?void 0:i.type)&&zs(t.doc,n.pos)&&t.join(n.pos),!0},Pg=(t,e)=>{const n=N1(s=>s.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(n.start).after(n.depth);if(r===void 0)return!0;const i=t.doc.nodeAt(r);return n.node.type===(i==null?void 0:i.type)&&zs(t.doc,r)&&t.join(r),!0},ij=(t,e,n,r={})=>({editor:i,tr:o,state:s,dispatch:a,chain:l,commands:c,can:u})=>{const{extensions:f,splittableMarks:h}=i.extensionManager,p=jn(t,s.schema),m=jn(e,s.schema),{selection:v,storedMarks:g}=s,{$from:b,$to:_}=v,k=b.blockRange(_),C=g||v.$to.parentOffset&&v.$from.marks();if(!k)return!1;const E=N1(I=>sk(I.type.name,f))(v);if(k.depth>=1&&E&&k.depth-E.depth<=1){if(E.node.type===p)return c.liftListItem(m);if(sk(E.node.type.name,f)&&p.validContent(E.node.content)&&a)return l().command(()=>(o.setNodeMarkup(E.pos,p),!0)).command(()=>Ng(o,p)).command(()=>Pg(o,p)).run()}return!n||!C||!a?l().command(()=>u().wrapInList(p,r)?!0:c.clearNodes()).wrapInList(p,r).command(()=>Ng(o,p)).command(()=>Pg(o,p)).run():l().command(()=>{const I=u().wrapInList(p,r),A=C.filter(M=>h.includes(M.type.name));return o.ensureMarks(A),I?!0:c.clearNodes()}).wrapInList(p,r).command(()=>Ng(o,p)).command(()=>Pg(o,p)).run()},oj=(t,e={},n={})=>({state:r,commands:i})=>{const{extendEmptyMarkRange:o=!1}=n,s=Vs(t,r.schema);return Nv(r,s,e)?i.unsetMark(s,{extendEmptyMarkRange:o}):i.setMark(s,e)},sj=(t,e,n={})=>({state:r,commands:i})=>{const o=jn(t,r.schema),s=jn(e,r.schema),a=Yu(r,o,n);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,...n})},aj=(t,e={})=>({state:n,commands:r})=>{const i=jn(t,n.schema);return Yu(n,i,e)?r.lift(i):r.wrapIn(i,e)},lj=()=>({state:t,dispatch:e})=>{const n=t.plugins;for(let r=0;r<n.length;r+=1){const i=n[r];let o;if(i.spec.isInputRules&&(o=i.getState(t))){if(e){const s=t.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,t.schema.text(o.text,l))}else s.delete(o.from,o.to)}return!0}}return!1},cj=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,{empty:r,ranges:i}=n;return r||e&&i.forEach(o=>{t.removeMark(o.$from.pos,o.$to.pos)}),!0},uj=(t,e={})=>({tr:n,state:r,dispatch:i})=>{var o;const{extendEmptyMarkRange:s=!1}=e,{selection:a}=n,l=Vs(t,r.schema),{$from:c,empty:u,ranges:f}=a;if(!i)return!0;if(u&&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=R1(c,l,m);v&&(h=v.from,p=v.to),n.removeMark(h,p,l)}else f.forEach(h=>{n.removeMark(h.$from.pos,h.$to.pos,l)});return n.removeStoredMark(l),!0},dj=(t,e={})=>({tr:n,state:r,dispatch:i})=>{let o=null,s=null;const a=Sm(typeof t=="string"?t:t.name,r.schema);return a?(a==="node"&&(o=jn(t,r.schema)),a==="mark"&&(s=Vs(t,r.schema)),i&&n.selection.ranges.forEach(l=>{const c=l.$from.pos,u=l.$to.pos;let f,h,p,m;n.selection.empty?r.doc.nodesBetween(c,u,(v,g)=>{o&&o===v.type&&(p=Math.max(g,c),m=Math.min(g+v.nodeSize,u),f=g,h=v)}):r.doc.nodesBetween(c,u,(v,g)=>{g<c&&o&&o===v.type&&(p=Math.max(g,c),m=Math.min(g+v.nodeSize,u),f=g,h=v),g>=c&&g<=u&&(o&&o===v.type&&n.setNodeMarkup(g,void 0,{...v.attrs,...e}),s&&v.marks.length&&v.marks.forEach(b=>{if(s===b.type){const _=Math.max(g,c),k=Math.min(g+v.nodeSize,u);n.addMark(_,k,s.create({...b.attrs,...e}))}}))}),h&&(f!==void 0&&n.setNodeMarkup(f,void 0,{...h.attrs,...e}),s&&h.marks.length&&h.marks.forEach(v=>{s===v.type&&n.addMark(p,m,s.create({...v.attrs,...e}))}))}),!0):!1},fj=(t,e={})=>({state:n,dispatch:r})=>{const i=jn(t,n.schema);return SV(i,e)(n,r)},hj=(t,e={})=>({state:n,dispatch:r})=>{const i=jn(t,n.schema);return EV(i,e)(n,r)};var pj=Object.freeze({__proto__:null,blur:YV,clearContent:JV,clearNodes:XV,command:QV,createParagraphNear:$V,cut:eU,deleteCurrentNode:tU,deleteNode:nU,deleteRange:rU,deleteSelection:iU,enter:oU,exitCode:sU,extendMarkRange:aU,first:lU,focus:uU,forEach:dU,insertContent:fU,insertContentAt:mU,joinBackward:bU,joinDown:vU,joinForward:yU,joinItemBackward:wU,joinItemForward:xU,joinTextblockBackward:kU,joinTextblockForward:_U,joinUp:gU,keyboardShortcut:SU,lift:EU,liftEmptyBlock:AU,liftListItem:TU,newlineInCode:MU,resetAttributes:DU,scrollIntoView:OU,selectAll:IU,selectNodeBackward:RU,selectNodeForward:NU,selectParentNode:PU,selectTextblockEnd:LU,selectTextblockStart:FU,setContent:zU,setMark:JU,setMeta:XU,setNode:QU,setNodeSelection:$U,setTextSelection:ej,sinkListItem:tj,splitBlock:nj,splitListItem:rj,toggleList:ij,toggleMark:oj,toggleNode:sj,toggleWrap:aj,undoInputRule:lj,unsetAllMarks:cj,unsetMark:uj,updateAttributes:dj,wrapIn:fj,wrapInList:hj});const mj=Jt.create({name:"commands",addCommands(){return{...pj}}}),gj=Jt.create({name:"drop",addProseMirrorPlugins(){return[new Lt({key:new Ut("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),vj=Jt.create({name:"editable",addProseMirrorPlugins(){return[new Lt({key:new Ut("editable"),props:{editable:()=>this.editor.options.editable}})]}}),bj=new Ut("focusEvents"),yj=Jt.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new Lt({key:bj,props:{handleDOMEvents:{focus:(e,n)=>{t.isFocused=!0;const r=t.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,n)=>{t.isFocused=!1;const r=t.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}}),wj=Jt.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first(({commands:s})=>[()=>s.undoInputRule(),()=>s.command(({tr:a})=>{const{selection:l,doc:c}=a,{empty:u,$anchor:f}=l,{pos:h,parent:p}=f,m=f.parent.isTextblock&&h>0?a.doc.resolve(h-1):f,v=m.parent.type.spec.isolating,g=f.pos-f.parentOffset,b=v&&m.parent.childCount===1?g===f.pos:lt.atStart(c).from===h;return!u||!p.type.isTextblock||p.textContent.length||!b||b&&f.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:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},i={...r},o={...r,"Ctrl-h":t,"Alt-Backspace":t,"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 Kh()||SA()?o:i},addProseMirrorPlugins(){return[new Lt({key:new Ut("clearDocument"),appendTransaction:(t,e,n)=>{if(t.some(v=>v.getMeta("composition")))return;const r=t.some(v=>v.docChanged)&&!e.doc.eq(n.doc),i=t.some(v=>v.getMeta("preventClearDocument"));if(!r||i)return;const{empty:o,from:s,to:a}=e.selection,l=lt.atStart(e.doc).from,c=lt.atEnd(e.doc).to;if(o||!(s===l&&a===c)||!Em(n.doc))return;const h=n.tr,p=xm({state:n,transaction:h}),{commands:m}=new km({editor:this.editor,state:p});if(m.clearNodes(),!!h.steps.length)return h}})]}}),xj=Jt.create({name:"paste",addProseMirrorPlugins(){return[new Lt({key:new Ut("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),kj=Jt.create({name:"tabindex",addProseMirrorPlugins(){return[new Lt({key:new Ut("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}});class Xs{get name(){return this.node.type.name}constructor(e,n,r=!1,i=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=n,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 n=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}n=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:n,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),n=this.resolvedPos.doc.resolve(e);return new Xs(n,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 Xs(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 Xs(e,this.editor)}get children(){const e=[];return this.node.content.forEach((n,r)=>{const i=n.isBlock&&!n.isTextblock,o=n.isAtom&&!n.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 Xs(a,this.editor,i,i?n:null);i&&(l.actualDepth=this.depth+1),e.push(new Xs(a,this.editor,i,i?n:null))}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,n={}){let r=null,i=this.parent;for(;i&&!r;){if(i.node.type.name===e)if(Object.keys(n).length>0){const o=i.node.attrs,s=Object.keys(n);for(let a=0;a<s.length;a+=1){const l=s[a];if(o[l]!==n[l])break}}else r=i;i=i.parent}return r}querySelector(e,n={}){return this.querySelectorAll(e,n,!0)[0]||null}querySelectorAll(e,n={},r=!1){let i=[];if(!this.children||this.children.length===0)return i;const o=Object.keys(n);return this.children.forEach(s=>{r&&i.length>0||(s.node.type.name===e&&o.every(l=>n[l]===s.node.attrs[l])&&i.push(s),!(r&&i.length>0)&&(i=i.concat(s.querySelectorAll(e,n,r))))}),i}setAttribute(e){const{tr:n}=this.editor.state;n.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(n)}}const _j=`.ProseMirror {
115
+ position: relative;
116
+ }
117
+
118
+ .ProseMirror {
119
+ word-wrap: break-word;
120
+ white-space: pre-wrap;
121
+ white-space: break-spaces;
122
+ -webkit-font-variant-ligatures: none;
123
+ font-variant-ligatures: none;
124
+ font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */
125
+ }
126
+
127
+ .ProseMirror [contenteditable="false"] {
128
+ white-space: normal;
129
+ }
130
+
131
+ .ProseMirror [contenteditable="false"] [contenteditable="true"] {
132
+ white-space: pre-wrap;
133
+ }
134
+
135
+ .ProseMirror pre {
136
+ white-space: pre-wrap;
137
+ }
138
+
139
+ img.ProseMirror-separator {
140
+ display: inline !important;
141
+ border: none !important;
142
+ margin: 0 !important;
143
+ width: 0 !important;
144
+ height: 0 !important;
145
+ }
146
+
147
+ .ProseMirror-gapcursor {
148
+ display: none;
149
+ pointer-events: none;
150
+ position: absolute;
151
+ margin: 0;
152
+ }
153
+
154
+ .ProseMirror-gapcursor:after {
155
+ content: "";
156
+ display: block;
157
+ position: absolute;
158
+ top: -2px;
159
+ width: 20px;
160
+ border-top: 1px solid black;
161
+ animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
162
+ }
163
+
164
+ @keyframes ProseMirror-cursor-blink {
165
+ to {
166
+ visibility: hidden;
167
+ }
168
+ }
169
+
170
+ .ProseMirror-hideselection *::selection {
171
+ background: transparent;
172
+ }
173
+
174
+ .ProseMirror-hideselection *::-moz-selection {
175
+ background: transparent;
176
+ }
177
+
178
+ .ProseMirror-hideselection * {
179
+ caret-color: transparent;
180
+ }
181
+
182
+ .ProseMirror-focused .ProseMirror-gapcursor {
183
+ display: block;
184
+ }
185
+
186
+ .tippy-box[data-animation=fade][data-state=hidden] {
187
+ opacity: 0
188
+ }`;function Cj(t,e,n){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=t,document.getElementsByTagName("head")[0].appendChild(i),i}let Sj=class extends RV{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:n})=>{throw n},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:n,slice:r,moved:i})=>this.options.onDrop(n,r,i)),this.on("paste",({event:n,slice:r})=>this.options.onPaste(n,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=Cj(_j,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,n=!0){this.setOptions({editable:e}),n&&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,n){const r=bA(n)?n(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 n=this.state.plugins;let r=n;if([].concat(e).forEach(o=>{const s=typeof o=="string"?`${o}$`:o.key;r=r.filter(a=>!a.key.startsWith(s))}),n.length===r.length)return;const i=this.state.reconfigure({plugins:r});return this.view.updateState(i),i}createExtensionManager(){var e,n;const i=[...this.options.enableCoreExtensions?[vj,ZV.configure({blockSeparator:(n=(e=this.options.coreExtensionOptions)===null||e===void 0?void 0:e.clipboardTextSerializer)===null||n===void 0?void 0:n.blockSeparator}),mj,yj,wj,kj,gj,xj].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 ul(i,this)}createCommandManager(){this.commandManager=new km({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createView(){var e;let n;try{n=Rv(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()}}),n=Rv(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}const r=_A(n,this.options.autofocus);this.view=new iA(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:ll.create({doc:n,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 n=this.capturedTransaction;return this.capturedTransaction=null,n}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 n=this.state.apply(e),r=!this.state.selection.eq(n.selection);this.emit("beforeTransaction",{editor:this,transaction:e,nextState:n}),this.view.updateState(n),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 TA(this.state,e)}isActive(e,n){const r=typeof e=="string"?e:null,i=typeof e=="string"?n:e;return GU(this.state,r,i)}getJSON(){return this.state.doc.toJSON()}getHTML(){return O1(this.state.doc.content,this.schema)}getText(e){const{blockSeparator:n=`
189
+
190
+ `,textSerializers:r={}}=e||{};return UU(this.state.doc,{blockSeparator:n,textSerializers:{...wA(this.schema),...r}})}get isEmpty(){return Em(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,n){var r;return((r=this.$doc)===null||r===void 0?void 0:r.querySelector(e,n))||null}$nodes(e,n){var r;return((r=this.$doc)===null||r===void 0?void 0:r.querySelectorAll(e,n))||null}$pos(e){const n=this.state.doc.resolve(e);return new Xs(n,this)}get $doc(){return this.$pos(0)}};function La(t){return new Ld({find:t.find,handler:({state:e,range:n,match:r})=>{const i=kt(t.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=n.from+a.indexOf(s),u=c+s.length;if(P1(n.from,n.to,e.doc).filter(p=>p.mark.type.excluded.find(v=>v===t.type&&v!==p.mark.type)).filter(p=>p.to>c).length)return null;u<n.to&&o.delete(u,n.to),c>n.from&&o.delete(n.from+l,c);const h=n.from+l+s.length;o.addMark(n.from+l,h,t.type.create(i||{})),o.removeStoredMark(t.type)}}})}function MA(t){return new Ld({find:t.find,handler:({state:e,range:n,match:r})=>{const i=kt(t.getAttributes,void 0,r)||{},{tr:o}=e,s=n.from;let a=n.to;const l=t.type.create(i);if(r[1]){const c=r[0].lastIndexOf(r[1]);let u=s+c;u>a?u=a:a=u+r[1].length;const f=r[0][r[0].length-1];o.insertText(f,s+r[0].length-1),o.replaceWith(u,a,l)}else if(r[0]){const c=t.type.isInline?s:s-1;o.insert(c,t.type.create(i)).delete(o.mapping.map(s),o.mapping.map(a))}o.scrollIntoView()}})}function Pv(t){return new Ld({find:t.find,handler:({state:e,range:n,match:r})=>{const i=e.doc.resolve(n.from),o=kt(t.getAttributes,void 0,r)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),t.type))return null;e.tr.delete(n.from,n.to).setBlockType(n.from,n.from,t.type,o)}})}function Ju(t){return new Ld({find:t.find,handler:({state:e,range:n,match:r,chain:i})=>{const o=kt(t.getAttributes,void 0,r)||{},s=e.tr.delete(n.from,n.to),l=s.doc.resolve(n.from).blockRange(),c=l&&Ib(l,t.type,o);if(!c)return null;if(s.wrap(l,c),t.keepMarks&&t.editor){const{selection:f,storedMarks:h}=e,{splittableMarks:p}=t.editor.extensionManager,m=h||f.$to.parentOffset&&f.$from.marks();if(m){const v=m.filter(g=>p.includes(g.type.name));s.ensureMarks(v)}}if(t.keepAttributes){const f=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";i().updateAttributes(f,o).run()}const u=s.doc.resolve(n.from-1).nodeBefore;u&&u.type===t.type&&zs(s.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,u))&&s.join(n.from-1)}})}let cr=class Lv{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=kt(qe(this,"addOptions",{name:this.name}))),this.storage=kt(qe(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new Lv(e)}configure(e={}){const n=this.extend({...this.config,addOptions:()=>Cm(this.options,e)});return n.name=this.name,n.parent=this.parent,n}extend(e={}){const n=new Lv(e);return n.parent=this,this.child=n,n.name=e.name?e.name:n.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: "${n.name}".`),n.options=kt(qe(n,"addOptions",{name:n.name})),n.storage=kt(qe(n,"addStorage",{name:n.name,options:n.options})),n}};function Ps(t){return new UV({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:i})=>{const o=kt(t.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=n.to;if(a){const u=l.search(/\S/),f=n.from+l.indexOf(a),h=f+a.length;if(P1(n.from,n.to,e.doc).filter(m=>m.mark.type.excluded.find(g=>g===t.type&&g!==m.mark.type)).filter(m=>m.to>f).length)return null;h<n.to&&s.delete(h,n.to),f>n.from&&s.delete(n.from+u,f),c=n.from+u+a.length,s.addMark(n.from+u,c,t.type.create(o||{})),s.removeStoredMark(t.type)}}})}function Ej(t,e){const{selection:n}=t,{$from:r}=n;if(n instanceof rt){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 Aj=()=>{let t=!0;return(e,n)=>{if(t){t=!1;try{e()}finally{t=!0}}else n!==void 0&&n()}},Tj=/[\uD800-\uDBFF]/,Mj=/[\uDC00-\uDFFF]/,Dj=(t,e)=>{let n=0,r=0;for(;n<t.length&&n<e.length&&t[n]===e[n];)n++;for(n>0&&Tj.test(t[n-1])&&n--;r+n<t.length&&r+n<e.length&&t[t.length-r-1]===e[e.length-r-1];)r++;return r>0&&Mj.test(t[t.length-r])&&r--,{index:n,remove:t.length-n-r,insert:e.slice(n,e.length-r)}},Oj=Dj,an=new Ut("y-sync"),eo=new Ut("y-undo"),uf=new Ut("yjs-cursor"),to=(t,e)=>t>>>e|t<<32-e,Ij=t=>to(t,2)^to(t,13)^to(t,22),Rj=t=>to(t,6)^to(t,11)^to(t,25),Nj=t=>to(t,7)^to(t,18)^t>>>3,Pj=t=>to(t,17)^to(t,19)^t>>>10,Lj=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]),Fj=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);class zj{constructor(){const e=new ArrayBuffer(320);this._H=new Uint32Array(e,0,8),this._H.set(Fj),this._W=new Uint32Array(e,64,64)}_updateHash(){const e=this._H,n=this._W;for(let f=16;f<64;f++)n[f]=Pj(n[f-2])+n[f-7]+Nj(n[f-15])+n[f-16];let r=e[0],i=e[1],o=e[2],s=e[3],a=e[4],l=e[5],c=e[6],u=e[7];for(let f=0,h,p;f<64;f++)h=u+Rj(a)+(a&l^~a&c)+Lj[f]+n[f]>>>0,p=Ij(r)+(r&i^r&o^i&o)>>>0,u=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]+=u}digest(e){let n=0;for(;n+56<=e.length;){let s=0;for(;s<16&&n+3<e.length;s++)this._W[s]=e[n++]<<24|e[n++]<<16|e[n++]<<8|e[n++];if(n%64!==0){for(this._W.fill(0,s,16);n<e.length;)this._W[s]|=e[n]<<(3-n%4)*8,n++;this._W[s]|=vr<<(3-n%4)*8}this._updateHash()}const r=n%64!==0;this._W.fill(0,0,16);let i=0;for(;n<e.length;i++)for(let s=3;s>=0&&n<e.length;s--)this._W[i]|=e[n++]<<s*8;r||(this._W[i-(n%4===0?0:1)]|=vr<<(3-n%4)*8),this._W[14]=e.byteLength/UI,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 Bj=t=>new zj().digest(t),Hj=t=>{for(let n=6;n<t.length;n++)t[n%6]=t[n%6]^t[n];return t.slice(0,6)},Vj=t=>jR(Hj(Bj(WR(t)))),Gh=(t,e)=>e===void 0?!t.deleted:e.sv.has(t.id.client)&&e.sv.get(t.id.client)>t.id.clock&&!gc(e.ds,t.id),Uj=[{light:"#ecd44433",dark:"#ecd444"}],jj=(t,e,n)=>{if(!t.has(n)){if(t.size<e.length){const r=Ma();t.forEach(i=>r.add(i)),e=e.filter(i=>!r.has(i))}t.set(n,xR(e))}return t.get(n)},qj=(t,{colors:e=Uj,colorMapping:n=new Map,permanentUserData:r=null,onFirstRender:i=()=>{},mapping:o}={})=>{let s=!1;const a=new Kj(t,o),l=new Lt({props:{editable:c=>{const u=an.getState(c);return u.snapshot==null&&u.prevSnapshot==null}},key:an,state:{init:(c,u)=>({type:t,doc:t.doc,binding:a,snapshot:null,prevSnapshot:null,isChangeOrigin:!1,isUndoRedoOperation:!1,addToHistory:!0,colors:e,colorMapping:n,permanentUserData:r}),apply:(c,u)=>{const f=c.getMeta(an);if(f!==void 0){u=Object.assign({},u);for(const h in f)u[h]=f[h]}return u.addToHistory=c.getMeta("addToHistory")!==!1,u.isChangeOrigin=f!==void 0&&!!f.isChangeOrigin,u.isUndoRedoOperation=f!==void 0&&!!f.isChangeOrigin&&!!f.isUndoRedoOperation,a.prosemirrorView!==null&&f!==void 0&&(f.snapshot!=null||f.prevSnapshot!=null)&&Zb(0,()=>{a.prosemirrorView!=null&&(f.restore==null?a._renderSnapshot(f.snapshot,f.prevSnapshot,u):(a._renderSnapshot(f.snapshot,f.snapshot,u),delete u.restore,delete u.snapshot,delete u.prevSnapshot,a.mux(()=>{a._prosemirrorChanged(a.prosemirrorView.state.doc)})))}),u}},view:c=>(a.initView(c),o==null&&a._forceRerender(),i(),{update:()=>{const u=l.getState(c.state);if(u.snapshot==null&&u.prevSnapshot==null&&(s||c.state.doc.content.findDiffStart(c.state.doc.type.createAndFill().content)!==null)){if(s=!0,u.addToHistory===!1&&!u.isChangeOrigin){const f=eo.getState(c.state),h=f&&f.undoManager;h&&h.stopCapturing()}a.mux(()=>{u.doc.transact(f=>{f.meta.set("addToHistory",u.addToHistory),a._prosemirrorChanged(c.state.doc)},an)})}},destroy:()=>{a.destroy()}})});return l},Wj=(t,e,n)=>{if(e!==null&&e.anchor!==null&&e.head!==null)if(e.type==="all")t.setSelection(new Er(t.doc));else if(e.type==="node"){const r=kl(n.doc,n.type,e.anchor,n.mapping);t.setSelection(rt.create(t.doc,r))}else{const r=kl(n.doc,n.type,e.anchor,n.mapping),i=kl(n.doc,n.type,e.head,n.mapping);if(r!==null&&i!==null){const o=$e.between(t.doc.resolve(r),t.doc.resolve(i));t.setSelection(o)}}},Fv=(t,e)=>({type:e.selection.jsonID,anchor:Yh(e.selection.anchor,t.type,t.mapping),head:Yh(e.selection.head,t.type,t.mapping)});class Kj{constructor(e,n=new Map){this.type=e,this.prosemirrorView=null,this.mux=Aj(),this.mapping=n,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=Fv(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()?(RS&&this._domSelectionInView===null&&(Zb(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 n=this.prosemirrorView._root.createRange();n.setStart(e.anchorNode,e.anchorOffset),n.setEnd(e.focusNode,e.focusOffset),n.getClientRects().length===0&&n.startContainer&&n.collapsed&&n.selectNodeContents(n.startContainer);const i=n.getBoundingClientRect(),o=Sd.documentElement;return i.bottom>=0&&i.right>=0&&i.left<=(window.innerWidth||o.clientWidth||0)&&i.top<=(window.innerHeight||o.clientHeight||0)}renderSnapshot(e,n){n||(n=p3(i3(),new Map)),this.prosemirrorView.dispatch(this._tr.setMeta(an,{snapshot:e,prevSnapshot:n}))}unrenderSnapshot(){this.mapping.clear(),this.mux(()=>{const e=this.type.toArray().map(r=>Qf(r,this.prosemirrorView.state.schema,this)).filter(r=>r!==null),n=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new Le(be.from(e),0,0));n.setMeta(an,{snapshot:null,prevSnapshot:null}),this.prosemirrorView.dispatch(n)})}_forceRerender(){this.mapping.clear(),this.mux(()=>{const e=this.beforeTransactionSelection!==null?null:this.prosemirrorView.state.selection,n=this.type.toArray().map(i=>Qf(i,this.prosemirrorView.state.schema,this)).filter(i=>i!==null),r=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new Le(be.from(n),0,0));if(e){const i=Ro(Di(e.anchor,0),r.doc.content.size),o=Ro(Di(e.head,0),r.doc.content.size);r.setSelection($e.create(r.doc,i,o))}this.prosemirrorView.dispatch(r.setMeta(an,{isChangeOrigin:!0,binding:this}))})}_renderSnapshot(e,n,r){let i=this.doc,o=this.type;if(e||(e=gg(this.doc)),e instanceof Uint8Array||n instanceof Uint8Array)if((!(e instanceof Uint8Array)||!(n instanceof Uint8Array))&&ir(),i=new oo({gc:!1}),Mh(i,n),n=gg(i),Mh(i,e),e=gg(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=Oi(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(f=>{Os(s,f,h=>{})});const l=(f,h)=>{const p=f==="added"?a.getUserByClientId(h.client):a.getUserByDeletedId(h);return{user:p,type:f,color:jj(r.colorMapping,r.colors,p)}},c=S3(o,new $b(n.ds,e.sv)).map(f=>!f._item.deleted||Gh(f._item,e)||Gh(f._item,n)?Qf(f,this.prosemirrorView.state.schema,{mapping:new Map,isOMark:new Map},e,n,l):null).filter(f=>f!==null),u=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new Le(be.from(c),0,0));this.prosemirrorView.dispatch(u.setMeta(an,{isChangeOrigin:!0}))},an)})}_typeChanged(e,n){if(this.prosemirrorView==null)return;const r=an.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);Os(n,n.deleteSet,a=>{if(a.constructor===Qt){const l=a.content.type;l&&this.mapping.delete(l)}}),n.changed.forEach(i),n.changedParentTypes.forEach(i);const o=this.type.toArray().map(a=>DA(a,this.prosemirrorView.state.schema,this)).filter(a=>a!==null);let s=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new Le(be.from(o),0,0));Wj(s,this.beforeTransactionSelection,this),s=s.setMeta(an,{isChangeOrigin:!0,isUndoRedoOperation:n.origin instanceof y3}),this.beforeTransactionSelection!==null&&this._isLocalCursorInView()&&s.scrollIntoView(),this.prosemirrorView.dispatch(s)})}_prosemirrorChanged(e){this.doc.transact(()=>{Bv(this.doc,this.type,e,this),this.beforeTransactionSelection=Fv(this,this.prosemirrorView.state)},an)}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 DA=(t,e,n,r,i,o)=>{const s=n.mapping.get(t);if(s===void 0){if(t instanceof ln)return Qf(t,e,n,r,i,o);throw hi()}return s},Qf=(t,e,n,r,i,o)=>{const s=[],a=l=>{var c,u;if(l instanceof ln){const f=DA(l,e,n,r,i,o);f!==null&&s.push(f)}else{const f=(u=(c=l._item.right)==null?void 0:c.content)==null?void 0:u.type;f instanceof Is&&!f._item.deleted&&f._item.id.client===f.doc.clientID&&(l.applyDelta([{retain:l.length},...f.toDelta()]),f.doc.transact(p=>{f._item.delete(p)}));const h=Gj(l,e,n,r,i,o);h!==null&&h.forEach(p=>{p!==null&&s.push(p)})}};r===void 0||i===void 0?t.toArray().forEach(a):S3(t,new $b(i.ds,r.sv)).forEach(a);try{const l=t.getAttributes(r);r!==void 0&&(Gh(t._item,r)?Gh(t._item,i)||(l.ychange=o?o("added",t._item.id):{type:"added"}):l.ychange=o?o("removed",t._item.id):{type:"removed"});const c=e.node(t.nodeName,l,s);return n.mapping.set(t,c),c}catch{return t.doc.transact(c=>{t._item.delete(c)},an),n.mapping.delete(t),null}},Gj=(t,e,n,r,i,o)=>{const s=[],a=t.toDelta(r,i,o);try{for(let l=0;l<a.length;l++){const c=a[l];s.push(e.text(c.insert,$j(c.attributes,e)))}}catch{return t.doc.transact(c=>{t._item.delete(c)},an),null}return s},Zj=(t,e)=>{const n=new kn,r=t.map(i=>({insert:i.text,attributes:IA(i.marks,e)}));return n.applyDelta(r),e.mapping.set(n,t),n},Yj=(t,e)=>{const n=new ln(t.type.name);for(const r in t.attrs){const i=t.attrs[r];i!==null&&r!=="ychange"&&n.setAttribute(r,i)}return n.insert(0,Am(t).map(r=>zv(r,e))),e.mapping.set(n,t),n},zv=(t,e)=>t instanceof Array?Zj(t,e):Yj(t,e),lk=t=>typeof t=="object"&&t!==null,L1=(t,e)=>{const n=Object.keys(t).filter(i=>t[i]!==null);let r=n.length===(e==null?0:Object.keys(e).filter(i=>e[i]!==null).length);for(let i=0;i<n.length&&r;i++){const o=n[i],s=t[o],a=e[o];r=o==="ychange"||s===a||lk(s)&&lk(a)&&L1(s,a)}return r},Am=t=>{const e=t.content.content,n=[];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--,n.push(o)}else n.push(i)}return n},OA=(t,e)=>{const n=t.toDelta();return n.length===e.length&&n.every((r,i)=>r.insert===e[i].text&&DS(r.attributes||{}).length===e[i].marks.length&&hc(r.attributes,(o,s)=>{var c;const a=F1(s),l=e[i].marks;return L1(o,(c=l.find(u=>u.type.name===a))==null?void 0:c.attrs)}))},Xu=(t,e)=>{if(t instanceof ln&&!(e instanceof Array)&&Hv(t,e)){const n=Am(e);return t._length===n.length&&L1(t.getAttributes(),e.attrs)&&t.toArray().every((r,i)=>Xu(r,n[i]))}return t instanceof kn&&e instanceof Array&&OA(t,e)},Zh=(t,e)=>t===e||t instanceof Array&&e instanceof Array&&t.length===e.length&&t.every((n,r)=>e[r]===n),ck=(t,e,n)=>{const r=t.toArray(),i=Am(e),o=i.length,s=r.length,a=Ro(s,o);let l=0,c=0,u=!1;for(;l<a;l++){const f=r[l],h=i[l];if(Zh(n.mapping.get(f),h))u=!0;else if(!Xu(f,h))break}for(;l+c<a;c++){const f=r[s-c-1],h=i[o-c-1];if(Zh(n.mapping.get(f),h))u=!0;else if(!Xu(f,h))break}return{equalityFactor:l+c,foundMappedChild:u}},Jj=t=>{let e="",n=t._start;const r={};for(;n!==null;)n.deleted||(n.countable&&n.content instanceof Ii?e+=n.content.str:n.content instanceof _n&&(r[n.content.key]=null)),n=n.right;return{str:e,nAttrs:r}},Xj=(t,e,n)=>{n.mapping.set(t,e);const{nAttrs:r,str:i}=Jj(t),o=e.map(c=>({insert:c.text,attributes:Object.assign({},r,IA(c.marks,n))})),{insert:s,remove:a,index:l}=Oj(i,o.map(c=>c.insert).join(""));t.delete(l,a),t.insert(l,s),t.applyDelta(o.map(c=>({retain:c.insert.length,attributes:c.attributes})))},Qj=/(.*)(--[a-zA-Z0-9+/=]{8})$/,F1=t=>{var e;return((e=Qj.exec(t))==null?void 0:e[1])??t},$j=(t,e)=>{const n=[];for(const r in t)n.push(e.mark(F1(r),t[r]));return n},IA=(t,e)=>{const n={};return t.forEach(r=>{if(r.type.name!=="ychange"){const i=co(e.isOMark,r.type,()=>!r.type.excludes(r.type));n[i?`${r.type.name}--${Vj(r.toJSON())}`:r.type.name]=r.attrs}}),n},Bv=(t,e,n,r)=>{if(e instanceof ln&&e.nodeName!==n.type.name)throw new Error("node name mismatch!");if(r.mapping.set(e,n),e instanceof ln){const f=e.getAttributes(),h=n.attrs;for(const p in h)h[p]!==null?f[p]!==h[p]&&p!=="ychange"&&e.setAttribute(p,h[p]):e.removeAttribute(p);for(const p in f)h[p]===void 0&&e.removeAttribute(p)}const i=Am(n),o=i.length,s=e.toArray(),a=s.length,l=Ro(o,a);let c=0,u=0;for(;c<l;c++){const f=s[c],h=i[c];if(!Zh(r.mapping.get(f),h))if(Xu(f,h))r.mapping.set(f,h);else break}for(;u+c<l;u++){const f=s[a-u-1],h=i[o-u-1];if(!Zh(r.mapping.get(f),h))if(Xu(f,h))r.mapping.set(f,h);else break}t.transact(()=>{for(;a-c-u>0&&o-c-u>0;){const h=s[c],p=i[c],m=s[a-u-1],v=i[o-u-1];if(h instanceof kn&&p instanceof Array)OA(h,p)||Xj(h,p,r),c+=1;else{let g=h instanceof ln&&Hv(h,p),b=m instanceof ln&&Hv(m,v);if(g&&b){const _=ck(h,p,r),k=ck(m,v,r);_.foundMappedChild&&!k.foundMappedChild?b=!1:!_.foundMappedChild&&k.foundMappedChild||_.equalityFactor<k.equalityFactor?g=!1:b=!1}g?(Bv(t,h,p,r),c+=1):b?(Bv(t,m,v,r),u+=1):(r.mapping.delete(e.get(c)),e.delete(c,1),e.insert(c,[zv(p,r)]),c+=1)}}const f=a-c-u;if(a===1&&o===0&&s[0]instanceof kn?(r.mapping.delete(s[0]),s[0].delete(0,s[0].length)):f>0&&(e.slice(c,c+f).forEach(h=>r.mapping.delete(h)),e.delete(c,f)),c+u<o){const h=[];for(let p=c;p<o-u;p++)h.push(zv(i[p],r));e.insert(c,h)}},an)},Hv=(t,e)=>!(e instanceof Array)&&t.nodeName===e.type.name;let au=null;const eq=()=>{const t=au;au=null,t.forEach((e,n)=>{const r=n.state.tr,i=an.getState(n.state);i&&i.binding&&!i.binding.isDestroyed&&(e.forEach((o,s)=>{r.setMeta(s,o)}),n.dispatch(r))})},tq=(t,e,n)=>{au||(au=new Map,Zb(0,eq)),co(au,t,fi).set(e,n)},Yh=(t,e,n)=>{if(t===0)return mg(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 kn){if(r._length>=t)return mg(r,t,e.length===0?-1:0);if(t-=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,t--;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=(n.get(r)||{nodeSize:0}).nodeSize;if(r._first!==null&&t<i)r=r._first.content.type,t--;else{if(t===1&&r._length===0&&i>1)return new zu(r._item===null?null:r._item.id,r._item===null?Lu(r):null,null);if(t-=i,r._item!==null&&r._item.next!==null)r=r._item.next.content.type;else{if(t===0)return r=r._item===null?r:r._item.parent,new zu(r._item===null?null:r._item.id,r._item===null?Lu(r):null,null);do r=r._item.parent,t--;while(r!==e&&r._item.next===null);r!==e&&(r=r._item.next.content.type)}}}if(r===null)throw ir();if(t===0&&r.constructor!==kn&&r!==e)return nq(r._item.parent,r._item)}return mg(e,e._length,e.length===0?-1:0)},nq=(t,e)=>{let n=null,r=null;return t._item===null?r=Lu(t):n=bt(t._item.id.client,t._item.id.clock),new zu(n,r,e.id)},kl=(t,e,n,r)=>{const i=cv(n,t);if(i===null||i.type!==e&&!Fu(e,i.type._item))return null;let o=i.type,s=0;if(o.constructor===kn)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 kn?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 kn?s+=c._length:s+=r.get(c).nodeSize),l=l.right}}o=a}return s-1};function rq(t){const e=t.toArray(),n=r=>{let i;if(r instanceof kn)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],f={type:F1(l)};return Object.keys(c)&&(f.attrs=c),f})),a});else if(r instanceof ln){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(n).flat())}else ir();return i};return{type:"doc",content:e.map(n)}}const iq=(t,e,n)=>t!==e,oq=t=>{const e=document.createElement("span");e.classList.add("ProseMirror-yjs-cursor"),e.setAttribute("style",`border-color: ${t.color}`);const n=document.createElement("div");n.setAttribute("style",`background-color: ${t.color}`),n.insertBefore(document.createTextNode(t.name),null);const r=document.createTextNode("⁠"),i=document.createTextNode("⁠");return e.insertBefore(r,null),e.insertBefore(n,null),e.insertBefore(i,null),e},RA=t=>({style:`background-color: ${t.color}70`,class:"ProseMirror-yjs-selection"}),sq=/^#[0-9a-fA-F]{6}$/,uk=(t,e,n,r,i)=>{const o=an.getState(t),s=o.doc,a=[];return o.snapshot!=null||o.prevSnapshot!=null||o.binding.mapping.size===0?ct.create(t.doc,[]):(e.getStates().forEach((l,c)=>{if(n(s.clientID,c,l)&&l.cursor!=null){const u=l.user||{};u.color==null?u.color="#ffa500":sq.test(u.color)||console.warn("A user uses an unsupported color format",u),u.name==null&&(u.name=`User: ${c}`);let f=kl(s,o.type,ba(l.cursor.anchor),o.binding.mapping),h=kl(s,o.type,ba(l.cursor.head),o.binding.mapping);if(f!==null&&h!==null){const p=Di(t.doc.content.size-1,0);f=Ro(f,p),h=Ro(h,p),a.push(Kt.widget(h,()=>r(u,c),{key:c+"",side:10}));const m=Ro(f,h),v=Di(f,h);a.push(Kt.inline(m,v,i(u,c),{inclusiveEnd:!0,inclusiveStart:!1}))}}}),ct.create(t.doc,a))},aq=(t,{awarenessStateFilter:e=iq,cursorBuilder:n=oq,selectionBuilder:r=RA,getSelection:i=s=>s.selection}={},o="cursor")=>new Lt({key:uf,state:{init(s,a){return uk(a,t,e,n,r)},apply(s,a,l,c){const u=an.getState(c),f=s.getMeta(uf);return u&&u.isChangeOrigin||f&&f.awarenessUpdated?uk(c,t,e,n,r):a.map(s.mapping,s.doc)}},props:{decorations:s=>uf.getState(s)},view:s=>{const a=()=>{s.docView&&tq(s,uf,{awarenessUpdated:!0})},l=()=>{const c=an.getState(s.state),u=t.getLocalState()||{};if(s.hasFocus()){const f=i(s.state),h=Yh(f.anchor,c.type,c.binding.mapping),p=Yh(f.head,c.type,c.binding.mapping);(u.cursor==null||!Yw(ba(u.cursor.anchor),h)||!Yw(ba(u.cursor.head),p))&&t.setLocalStateField(o,{anchor:h,head:p})}else u.cursor!=null&&kl(c.doc,c.type,ba(u.cursor.anchor),c.binding.mapping)!==null&&t.setLocalStateField(o,null)};return t.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),t.off("change",a),t.setLocalStateField(o,null)}}}}),lq=t=>{var e,n;return((n=(e=eo.getState(t))==null?void 0:e.undoManager)==null?void 0:n.undo())!=null},cq=t=>{var e,n;return((n=(e=eo.getState(t))==null?void 0:e.undoManager)==null?void 0:n.redo())!=null},uq=new Set(["paragraph"]),dq=(t,e)=>!(t instanceof Qt)||!(t.content instanceof Ni)||!(t.content.type instanceof Is||t.content.type instanceof ln&&e.has(t.content.type.nodeName))||t.content.type._length===0,fq=({protectedNodes:t=uq,trackedOrigins:e=[],undoManager:n=null}={})=>new Lt({key:eo,state:{init:(r,i)=>{const o=an.getState(i),s=n||new y3(o.type,{trackedOrigins:new Set([an].concat(e)),deleteFilter:a=>dq(a,t),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=an.getState(s).binding,l=i.undoManager,c=l.undoStack.length>0,u=l.redoStack.length>0;return a?{undoManager:l,prevSel:Fv(a,o),hasUndoOps:c,hasRedoOps:u}:c!==i.hasUndoOps||u!==i.hasRedoOps?Object.assign({},i,{hasUndoOps:l.undoStack.length>0,hasRedoOps:l.redoStack.length>0}):i}},view:r=>{const i=an.getState(r.state),o=eo.getState(r.state).undoManager;return o.on("stack-item-added",({stackItem:s})=>{const a=i.binding;a&&s.meta.set(a,eo.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()}}}}),hq=Jt.create({name:"collaboration",priority:1e3,addOptions(){return{document:null,field:"default",fragment:null}},addStorage(){return{isDisabled:!1}},onCreate(){this.editor.extensionManager.extensions.find(t=>t.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:t,state:e,dispatch:n})=>(t.setMeta("preventDispatch",!0),eo.getState(e).undoManager.undoStack.length===0?!1:n?lq(e):!0),redo:()=>({tr:t,state:e,dispatch:n})=>(t.setMeta("preventDispatch",!0),eo.getState(e).undoManager.redoStack.length===0?!1:n?cq(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 t;const e=this.options.fragment?this.options.fragment:this.options.document.getXmlFragment(this.options.field),n=fq(this.options.yUndoOptions),r=n.spec.view;n.spec.view=s=>{const{undoManager:a}=eo.getState(s.state);a.restore&&(a.restore(),a.restore=()=>{});const l=r?r(s):void 0;return{destroy:()=>{const c=a.trackedOrigins.has(a),u=a._observers;a.restore=()=>{c&&a.trackedOrigins.add(a),a.doc.on("afterTransaction",a.afterTransactionHandler),a._observers=u},l!=null&&l.destroy&&l.destroy()}}};const i={...this.options.ySyncOptions,onFirstRender:this.options.onFirstRender},o=qj(e,i);return this.editor.options.enableContentCheck&&((t=e.doc)===null||t===void 0||t.on("beforeTransaction",()=>{try{const s=rq(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,n,this.editor.options.enableContentCheck&&new Lt({key:new Ut("filterInvalidContent"),filterTransaction:()=>{var s;return this.storage.isDisabled&&((s=e.doc)===null||s===void 0||s.destroy()),!0}})].filter(Boolean)}}),dk=t=>Array.from(t.entries()).map(([e,n])=>({clientId:e,...n.user})),fk=()=>null,pq=Jt.create({name:"collaborationCursor",priority:999,addOptions(){return{provider:null,user:{name:null,color:null},render:t=>{const e=document.createElement("span");e.classList.add("collaboration-cursor__caret"),e.setAttribute("style",`border-color: ${t.color}`);const n=document.createElement("div");return n.classList.add("collaboration-cursor__label"),n.setAttribute("style",`background-color: ${t.color}`),n.insertBefore(document.createTextNode(t.name),null),e.insertBefore(n,null),e},selectionRender:RA,onUpdate:fk}},onCreate(){if(this.options.onUpdate!==fk&&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:t=>()=>(this.options.user=t,this.options.provider.awareness.setLocalStateField("user",this.options.user),!0),user:t=>({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(t))}},addProseMirrorPlugins(){return[aq((this.options.provider.awareness.setLocalStateField("user",this.options.user),this.storage.users=dk(this.options.provider.awareness.states),this.options.provider.awareness.on("update",()=>{this.storage.users=dk(this.options.provider.awareness.states)}),this.options.provider.awareness),{cursorBuilder:this.options.render,selectionBuilder:this.options.selectionRender})]}}),mq=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,gq=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,vq=Ri.create({name:"highlight",addOptions(){return{multicolor:!1,HTMLAttributes:{}}},addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:t=>t.getAttribute("data-color")||t.style.backgroundColor,renderHTML:t=>t.color?{"data-color":t.color,style:`background-color: ${t.color}; color: inherit`}:{}}}:{}},parseHTML(){return[{tag:"mark"}]},renderHTML({HTMLAttributes:t}){return["mark",cn(this.options.HTMLAttributes,t),0]},addCommands(){return{setHighlight:t=>({commands:e})=>e.setMark(this.name,t),toggleHighlight:t=>({commands:e})=>e.toggleMark(this.name,t),unsetHighlight:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}},addInputRules(){return[La({find:mq,type:this.type})]},addPasteRules(){return[Ps({find:gq,type:this.type})]}}),bq=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,yq=cr.create({name:"image",addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{}}},inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},draggable:!0,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null}}},parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML({HTMLAttributes:t}){return["img",cn(this.options.HTMLAttributes,t)]},addCommands(){return{setImage:t=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}},addInputRules(){return[MA({find:bq,type:this.type,getAttributes:t=>{const[,,e,n,r]=t;return{src:n,alt:e,title:r}}})]}}),wq="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",xq="ελ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",Vv="numeric",Uv="ascii",jv="alpha",lu="asciinumeric",Wc="alphanumeric",qv="domain",NA="emoji",kq="scheme",_q="slashscheme",Lg="whitespace";function Cq(t,e){return t in e||(e[t]=[]),e[t]}function oa(t,e,n){e[Vv]&&(e[lu]=!0,e[Wc]=!0),e[Uv]&&(e[lu]=!0,e[jv]=!0),e[lu]&&(e[Wc]=!0),e[jv]&&(e[Wc]=!0),e[Wc]&&(e[qv]=!0),e[NA]&&(e[qv]=!0);for(const r in e){const i=Cq(r,n);i.indexOf(t)<0&&i.push(t)}}function Sq(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function _r(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}_r.groups={};_r.prototype={accepts(){return!!this.t},go(t){const e=this,n=e.j[t];if(n)return n;for(let r=0;r<e.jr.length;r++){const i=e.jr[r][0],o=e.jr[r][1];if(o&&i.test(t))return o}return e.jd},has(t,e=!1){return e?t in this.j:!!this.go(t)},ta(t,e,n,r){for(let i=0;i<t.length;i++)this.tt(t[i],e,n,r)},tr(t,e,n,r){r=r||_r.groups;let i;return e&&e.j?i=e:(i=new _r(e),n&&r&&oa(e,n,r)),this.jr.push([t,i]),i},ts(t,e,n,r){let i=this;const o=t.length;if(!o)return i;for(let s=0;s<o-1;s++)i=i.tt(t[s]);return i.tt(t[o-1],e,n,r)},tt(t,e,n,r){r=r||_r.groups;const i=this;if(e&&e.j)return i.j[t]=e,e;const o=e;let s,a=i.go(t);if(a?(s=new _r,Object.assign(s.j,a.j),s.jr.push.apply(s.jr,a.jr),s.jd=a.jd,s.t=a.t):s=new _r,o){if(r)if(s.t&&typeof s.t=="string"){const l=Object.assign(Sq(s.t,r),n);oa(o,l,r)}else n&&oa(o,n,r);s.t=o}return i.j[t]=s,s}};const xt=(t,e,n,r,i)=>t.ta(e,n,r,i),un=(t,e,n,r,i)=>t.tr(e,n,r,i),hk=(t,e,n,r,i)=>t.ts(e,n,r,i),Ne=(t,e,n,r,i)=>t.tt(e,n,r,i),wo="WORD",Wv="UWORD",PA="ASCIINUMERICAL",LA="ALPHANUMERICAL",Qu="LOCALHOST",Kv="TLD",Gv="UTLD",$f="SCHEME",il="SLASH_SCHEME",z1="NUM",Zv="WS",B1="NL",cu="OPENBRACE",uu="CLOSEBRACE",Jh="OPENBRACKET",Xh="CLOSEBRACKET",Qh="OPENPAREN",$h="CLOSEPAREN",ep="OPENANGLEBRACKET",tp="CLOSEANGLEBRACKET",np="FULLWIDTHLEFTPAREN",rp="FULLWIDTHRIGHTPAREN",ip="LEFTCORNERBRACKET",op="RIGHTCORNERBRACKET",sp="LEFTWHITECORNERBRACKET",ap="RIGHTWHITECORNERBRACKET",lp="FULLWIDTHLESSTHAN",cp="FULLWIDTHGREATERTHAN",up="AMPERSAND",dp="APOSTROPHE",fp="ASTERISK",ts="AT",hp="BACKSLASH",pp="BACKTICK",mp="CARET",as="COLON",H1="COMMA",gp="DOLLAR",Vi="DOT",vp="EQUALS",V1="EXCLAMATION",Xr="HYPHEN",du="PERCENT",bp="PIPE",yp="PLUS",wp="POUND",fu="QUERY",U1="QUOTE",FA="FULLWIDTHMIDDLEDOT",j1="SEMI",Ui="SLASH",hu="TILDE",xp="UNDERSCORE",zA="EMOJI",kp="SYM";var BA=Object.freeze({__proto__:null,ALPHANUMERICAL:LA,AMPERSAND:up,APOSTROPHE:dp,ASCIINUMERICAL:PA,ASTERISK:fp,AT:ts,BACKSLASH:hp,BACKTICK:pp,CARET:mp,CLOSEANGLEBRACKET:tp,CLOSEBRACE:uu,CLOSEBRACKET:Xh,CLOSEPAREN:$h,COLON:as,COMMA:H1,DOLLAR:gp,DOT:Vi,EMOJI:zA,EQUALS:vp,EXCLAMATION:V1,FULLWIDTHGREATERTHAN:cp,FULLWIDTHLEFTPAREN:np,FULLWIDTHLESSTHAN:lp,FULLWIDTHMIDDLEDOT:FA,FULLWIDTHRIGHTPAREN:rp,HYPHEN:Xr,LEFTCORNERBRACKET:ip,LEFTWHITECORNERBRACKET:sp,LOCALHOST:Qu,NL:B1,NUM:z1,OPENANGLEBRACKET:ep,OPENBRACE:cu,OPENBRACKET:Jh,OPENPAREN:Qh,PERCENT:du,PIPE:bp,PLUS:yp,POUND:wp,QUERY:fu,QUOTE:U1,RIGHTCORNERBRACKET:op,RIGHTWHITECORNERBRACKET:ap,SCHEME:$f,SEMI:j1,SLASH:Ui,SLASH_SCHEME:il,SYM:kp,TILDE:hu,TLD:Kv,UNDERSCORE:xp,UTLD:Gv,UWORD:Wv,WORD:wo,WS:Zv});const vo=/[a-z]/,Oc=new RegExp("\\p{L}","u"),Fg=new RegExp("\\p{Emoji}","u"),bo=/\d/,zg=/\s/,pk="\r",Bg=`
191
+ `,Eq="️",Aq="‍",Hg="";let df=null,ff=null;function Tq(t=[]){const e={};_r.groups=e;const n=new _r;df==null&&(df=mk(wq)),ff==null&&(ff=mk(xq)),Ne(n,"'",dp),Ne(n,"{",cu),Ne(n,"}",uu),Ne(n,"[",Jh),Ne(n,"]",Xh),Ne(n,"(",Qh),Ne(n,")",$h),Ne(n,"<",ep),Ne(n,">",tp),Ne(n,"(",np),Ne(n,")",rp),Ne(n,"「",ip),Ne(n,"」",op),Ne(n,"『",sp),Ne(n,"』",ap),Ne(n,"<",lp),Ne(n,">",cp),Ne(n,"&",up),Ne(n,"*",fp),Ne(n,"@",ts),Ne(n,"`",pp),Ne(n,"^",mp),Ne(n,":",as),Ne(n,",",H1),Ne(n,"$",gp),Ne(n,".",Vi),Ne(n,"=",vp),Ne(n,"!",V1),Ne(n,"-",Xr),Ne(n,"%",du),Ne(n,"|",bp),Ne(n,"+",yp),Ne(n,"#",wp),Ne(n,"?",fu),Ne(n,'"',U1),Ne(n,"/",Ui),Ne(n,";",j1),Ne(n,"~",hu),Ne(n,"_",xp),Ne(n,"\\",hp),Ne(n,"・",FA);const r=un(n,bo,z1,{[Vv]:!0});un(r,bo,r);const i=un(r,vo,PA,{[lu]:!0}),o=un(r,Oc,LA,{[Wc]:!0}),s=un(n,vo,wo,{[Uv]:!0});un(s,bo,i),un(s,vo,s),un(i,bo,i),un(i,vo,i);const a=un(n,Oc,Wv,{[jv]:!0});un(a,vo),un(a,bo,o),un(a,Oc,a),un(o,bo,o),un(o,vo),un(o,Oc,o);const l=Ne(n,Bg,B1,{[Lg]:!0}),c=Ne(n,pk,Zv,{[Lg]:!0}),u=un(n,zg,Zv,{[Lg]:!0});Ne(n,Hg,u),Ne(c,Bg,l),Ne(c,Hg,u),un(c,zg,u),Ne(u,pk),Ne(u,Bg),un(u,zg,u),Ne(u,Hg,u);const f=un(n,Fg,zA,{[NA]:!0});Ne(f,"#"),un(f,Fg,f),Ne(f,Eq,f);const h=Ne(f,Aq);Ne(h,"#"),un(h,Fg,f);const p=[[vo,s],[bo,i]],m=[[vo,null],[Oc,a],[bo,o]];for(let v=0;v<df.length;v++)Xo(n,df[v],Kv,wo,p);for(let v=0;v<ff.length;v++)Xo(n,ff[v],Gv,Wv,m);oa(Kv,{tld:!0,ascii:!0},e),oa(Gv,{utld:!0,alpha:!0},e),Xo(n,"file",$f,wo,p),Xo(n,"mailto",$f,wo,p),Xo(n,"http",il,wo,p),Xo(n,"https",il,wo,p),Xo(n,"ftp",il,wo,p),Xo(n,"ftps",il,wo,p),oa($f,{scheme:!0,ascii:!0},e),oa(il,{slashscheme:!0,ascii:!0},e),t=t.sort((v,g)=>v[0]>g[0]?1:-1);for(let v=0;v<t.length;v++){const g=t[v][0],_=t[v][1]?{[kq]:!0}:{[_q]:!0};g.indexOf("-")>=0?_[qv]=!0:vo.test(g)?bo.test(g)?_[lu]=!0:_[Uv]=!0:_[Vv]=!0,hk(n,g,g,_)}return hk(n,"localhost",Qu,{ascii:!0}),n.jd=new _r(kp),{start:n,tokens:Object.assign({groups:e},BA)}}function HA(t,e){const n=Mq(e.replace(/[A-Z]/g,a=>a.toLowerCase())),r=n.length,i=[];let o=0,s=0;for(;s<r;){let a=t,l=null,c=0,u=null,f=-1,h=-1;for(;s<r&&(l=a.go(n[s]));)a=l,a.accepts()?(f=0,h=0,u=a):f>=0&&(f+=n[s].length,h++),c+=n[s].length,o+=n[s].length,s++;o-=f,s-=h,c-=f,i.push({t:u.t,v:e.slice(o-c,o),s:o-c,e:o})}return i}function Mq(t){const e=[],n=t.length;let r=0;for(;r<n;){let i=t.charCodeAt(r),o,s=i<55296||i>56319||r+1===n||(o=t.charCodeAt(r+1))<56320||o>57343?t[r]:t.slice(r,r+2);e.push(s),r+=s.length}return e}function Xo(t,e,n,r,i){let o;const s=e.length;for(let a=0;a<s-1;a++){const l=e[a];t.j[l]?o=t.j[l]:(o=new _r(r),o.jr=i.slice(),t.j[l]=o),t=o}return o=new _r(n),o.jr=i.slice(),t.j[e[s-1]]=o,o}function mk(t){const e=[],n=[];let r=0,i="0123456789";for(;r<t.length;){let o=0;for(;i.indexOf(t[r+o])>=0;)o++;if(o>0){e.push(n.join(""));for(let s=parseInt(t.substring(r,r+o),10);s>0;s--)n.pop();r+=o}else n.push(t[r]),r++}return e}const $u={defaultProtocol:"http",events:null,format:gk,formatHref:gk,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function q1(t,e=null){let n=Object.assign({},$u);t&&(n=Object.assign(n,t instanceof q1?t.o:t));const r=n.ignoreTags,i=[];for(let o=0;o<r.length;o++)i.push(r[o].toUpperCase());this.o=n,e&&(this.defaultRender=e),this.ignoreTags=i}q1.prototype={o:$u,ignoreTags:[],defaultRender(t){return t},check(t){return this.get("validate",t.toString(),t)},get(t,e,n){const r=e!=null;let i=this.o[t];return i&&(typeof i=="object"?(i=n.t in i?i[n.t]:$u[t],typeof i=="function"&&r&&(i=i(e,n))):typeof i=="function"&&r&&(i=i(e,n.t,n)),i)},getObj(t,e,n){let r=this.o[t];return typeof r=="function"&&e!=null&&(r=r(e,n.t,n)),r},render(t){const e=t.render(this);return(this.get("render",null,t)||this.defaultRender)(e,t.t,t)}};function gk(t){return t}function VA(t,e){this.t="token",this.v=t,this.tk=e}VA.prototype={isLink:!1,toString(){return this.v},toHref(t){return this.toString()},toFormattedString(t){const e=this.toString(),n=t.get("truncate",e,this),r=t.get("format",e,this);return n&&r.length>n?r.substring(0,n)+"…":r},toFormattedHref(t){return t.get("formatHref",this.toHref(t.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(t=$u.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(t),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(t){return{type:this.t,value:this.toFormattedString(t),isLink:this.isLink,href:this.toFormattedHref(t),start:this.startIndex(),end:this.endIndex()}},validate(t){return t.get("validate",this.toString(),this)},render(t){const e=this,n=this.toHref(t.get("defaultProtocol")),r=t.get("formatHref",n,this),i=t.get("tagName",n,e),o=this.toFormattedString(t),s={},a=t.get("className",n,e),l=t.get("target",n,e),c=t.get("rel",n,e),u=t.getObj("attributes",n,e),f=t.getObj("events",n,e);return s.href=r,a&&(s.class=a),l&&(s.target=l),c&&(s.rel=c),u&&Object.assign(s,u),{tagName:i,attributes:s,content:o,eventListeners:f}}};function Tm(t,e){class n extends VA{constructor(i,o){super(i,o),this.t=t}}for(const r in e)n.prototype[r]=e[r];return n.t=t,n}const vk=Tm("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),bk=Tm("text"),Dq=Tm("nl"),hf=Tm("url",{isLink:!0,toHref(t=$u.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==Qu&&t[1].t===as}}),Yr=t=>new _r(t);function Oq({groups:t}){const e=t.domain.concat([up,fp,ts,hp,pp,mp,gp,vp,Xr,z1,du,bp,yp,wp,Ui,kp,hu,xp]),n=[dp,as,H1,Vi,V1,du,fu,U1,j1,ep,tp,cu,uu,Xh,Jh,Qh,$h,np,rp,ip,op,sp,ap,lp,cp],r=[up,dp,fp,hp,pp,mp,gp,vp,Xr,cu,uu,du,bp,yp,wp,fu,Ui,kp,hu,xp],i=Yr(),o=Ne(i,hu);xt(o,r,o),xt(o,t.domain,o);const s=Yr(),a=Yr(),l=Yr();xt(i,t.domain,s),xt(i,t.scheme,a),xt(i,t.slashscheme,l),xt(s,r,o),xt(s,t.domain,s);const c=Ne(s,ts);Ne(o,ts,c),Ne(a,ts,c),Ne(l,ts,c);const u=Ne(o,Vi);xt(u,r,o),xt(u,t.domain,o);const f=Yr();xt(c,t.domain,f),xt(f,t.domain,f);const h=Ne(f,Vi);xt(h,t.domain,f);const p=Yr(vk);xt(h,t.tld,p),xt(h,t.utld,p),Ne(c,Qu,p);const m=Ne(f,Xr);Ne(m,Xr,m),xt(m,t.domain,f),xt(p,t.domain,f),Ne(p,Vi,h),Ne(p,Xr,m);const v=Ne(p,as);xt(v,t.numeric,vk);const g=Ne(s,Xr),b=Ne(s,Vi);Ne(g,Xr,g),xt(g,t.domain,s),xt(b,r,o),xt(b,t.domain,s);const _=Yr(hf);xt(b,t.tld,_),xt(b,t.utld,_),xt(_,t.domain,s),xt(_,r,o),Ne(_,Vi,b),Ne(_,Xr,g),Ne(_,ts,c);const k=Ne(_,as),C=Yr(hf);xt(k,t.numeric,C);const E=Yr(hf),I=Yr();xt(E,e,E),xt(E,n,I),xt(I,e,E),xt(I,n,I),Ne(_,Ui,E),Ne(C,Ui,E);const A=Ne(a,as),M=Ne(l,as),N=Ne(M,Ui),R=Ne(N,Ui);xt(a,t.domain,s),Ne(a,Vi,b),Ne(a,Xr,g),xt(l,t.domain,s),Ne(l,Vi,b),Ne(l,Xr,g),xt(A,t.domain,E),Ne(A,Ui,E),Ne(A,fu,E),xt(R,t.domain,E),xt(R,e,E),Ne(R,Ui,E);const B=[[cu,uu],[Jh,Xh],[Qh,$h],[ep,tp],[np,rp],[ip,op],[sp,ap],[lp,cp]];for(let Z=0;Z<B.length;Z++){const[q,Y]=B[Z],X=Ne(E,q);Ne(I,q,X),Ne(X,Y,E);const ae=Yr(hf);xt(X,e,ae);const ne=Yr();xt(X,n),xt(ae,e,ae),xt(ae,n,ne),xt(ne,e,ae),xt(ne,n,ne),Ne(ae,Y,E),Ne(ne,Y,E)}return Ne(i,Qu,_),Ne(i,B1,Dq),{start:i,tokens:BA}}function Iq(t,e,n){let r=n.length,i=0,o=[],s=[];for(;i<r;){let a=t,l=null,c=null,u=0,f=null,h=-1;for(;i<r&&!(l=a.go(n[i].t));)s.push(n[i++]);for(;i<r&&(c=l||a.go(n[i].t));)l=null,a=c,a.accepts()?(h=0,f=a):h>=0&&h++,i++,u++;if(h<0)i-=u,i<r&&(s.push(n[i]),i++);else{s.length>0&&(o.push(Vg(bk,e,s)),s=[]),i-=h,u-=h;const p=f.t,m=n.slice(i-u,i);o.push(Vg(p,e,m))}}return s.length>0&&o.push(Vg(bk,e,s)),o}function Vg(t,e,n){const r=n[0].s,i=n[n.length-1].e,o=e.slice(r,i);return new t(o,n)}const Rq=typeof console<"u"&&console&&console.warn||(()=>{}),Nq="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",tn={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function Pq(){return _r.groups={},tn.scanner=null,tn.parser=null,tn.tokenQueue=[],tn.pluginQueue=[],tn.customSchemes=[],tn.initialized=!1,tn}function yk(t,e=!1){if(tn.initialized&&Rq(`linkifyjs: already initialized - will not register custom scheme "${t}" ${Nq}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(t))throw new Error(`linkifyjs: incorrect scheme format.
192
+ 1. Must only contain digits, lowercase ASCII letters or "-"
193
+ 2. Cannot start or end with "-"
194
+ 3. "-" cannot repeat`);tn.customSchemes.push([t,e])}function Lq(){tn.scanner=Tq(tn.customSchemes);for(let t=0;t<tn.tokenQueue.length;t++)tn.tokenQueue[t][1]({scanner:tn.scanner});tn.parser=Oq(tn.scanner.tokens);for(let t=0;t<tn.pluginQueue.length;t++)tn.pluginQueue[t][1]({scanner:tn.scanner,parser:tn.parser});return tn.initialized=!0,tn}function W1(t){return tn.initialized||Lq(),Iq(tn.parser.start,t,HA(tn.scanner.start,t))}W1.scan=HA;function UA(t,e=null,n=null){if(e&&typeof e=="object"){if(n)throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);n=e,e=null}const r=new q1(n),i=W1(t),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 K1="[\0-   ᠎ -\u2029  ]",Fq=new RegExp(K1),zq=new RegExp(`${K1}$`),Bq=new RegExp(K1,"g");function Hq(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function Vq(t){return new Lt({key:new Ut("autolink"),appendTransaction:(e,n,r)=>{const i=e.some(c=>c.docChanged)&&!n.doc.eq(r.doc),o=e.some(c=>c.getMeta("preventAutolink"));if(!i||o)return;const{tr:s}=r,a=BU(n.doc,[...e]);if(KU(a).forEach(({newRange:c})=>{const u=VU(r.doc,c,p=>p.isTextblock);let f,h;if(u.length>1)f=u[0],h=r.doc.textBetween(f.pos,f.pos+f.node.nodeSize,void 0," ");else if(u.length){const p=r.doc.textBetween(c.from,c.to," "," ");if(!zq.test(p))return;f=u[0],h=r.doc.textBetween(f.pos,c.to,void 0," ")}if(f&&h){const p=h.split(Fq).filter(Boolean);if(p.length<=0)return!1;const m=p[p.length-1],v=f.pos+h.lastIndexOf(m);if(!m)return!1;const g=W1(m).map(b=>b.toObject(t.defaultProtocol));if(!Hq(g))return!1;g.filter(b=>b.isLink).map(b=>({...b,from:v+b.start+1,to:v+b.end+1})).filter(b=>r.schema.marks.code?!r.doc.rangeHasMark(b.from,b.to,r.schema.marks.code):!0).filter(b=>t.validate(b.value)).filter(b=>t.shouldAutoLink(b.value)).forEach(b=>{P1(b.from,b.to,r.doc).some(_=>_.mark.type===t.type)||s.addMark(b.from,b.to,t.type.create({href:b.href}))})}}),!!s.steps.length)return s}})}function Uq(t){return new Lt({key:new Ut("handleClickLink"),props:{handleClick:(e,n,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=TA(e.state,t.type.name),c=r.target,u=(i=c==null?void 0:c.href)!==null&&i!==void 0?i:l.href,f=(o=c==null?void 0:c.target)!==null&&o!==void 0?o:l.target;return c&&u?(window.open(u,f),!0):!1}}})}function jq(t){return new Lt({key:new Ut("handlePasteLink"),props:{handlePaste:(e,n,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=UA(a,{defaultProtocol:t.defaultProtocol}).find(c=>c.isLink&&c.value===a);return!a||!l?!1:t.editor.commands.setMark(t.type,{href:l.href})}}})}function Ws(t,e){const n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(r=>{const i=typeof r=="string"?r:r.scheme;i&&n.push(i)}),!t||t.replace(Bq,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}const qq=Ri.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(t=>{if(typeof t=="string"){yk(t);return}yk(t.scheme,t.optionalSlashes)})},onDestroy(){Pq()},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:(t,e)=>!!Ws(t,e.protocols),validate:t=>!!t,shouldAutoLink:t=>!!t}},addAttributes(){return{href:{default:null,parseHTML(t){return t.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:t=>{const e=t.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:n=>!!Ws(n,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:t}){return this.options.isAllowedUri(t.href,{defaultValidate:e=>!!Ws(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",cn(this.options.HTMLAttributes,t),0]:["a",cn(this.options.HTMLAttributes,{...t,href:""}),0]},addCommands(){return{setLink:t=>({chain:e})=>{const{href:n}=t;return this.options.isAllowedUri(n,{defaultValidate:r=>!!Ws(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,t).setMeta("preventAutolink",!0).run():!1},toggleLink:t=>({chain:e})=>{const{href:n}=t;return this.options.isAllowedUri(n,{defaultValidate:r=>!!Ws(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().toggleMark(this.name,t,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run():!1},unsetLink:()=>({chain:t})=>t().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[Ps({find:t=>{const e=[];if(t){const{protocols:n,defaultProtocol:r}=this.options,i=UA(t).filter(o=>o.isLink&&this.options.isAllowedUri(o.value,{defaultValidate:s=>!!Ws(s,n),protocols:n,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:t=>{var e;return{href:(e=t.data)===null||e===void 0?void 0:e.href}}})]},addProseMirrorPlugins(){const t=[],{protocols:e,defaultProtocol:n}=this.options;return this.options.autolink&&t.push(Vq({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:i=>!!Ws(i,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),this.options.openOnClick===!0&&t.push(Uq({type:this.type})),this.options.linkOnPaste&&t.push(jq({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type})),t}}),Wq=Jt.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new Lt({key:new Ut("placeholder"),props:{decorations:({doc:t,selection:e})=>{const n=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:r}=e,i=[];if(!n)return null;const o=this.editor.isEmpty;return t.descendants((s,a)=>{const l=r>=a&&r<=a+s.nodeSize,c=!s.isLeaf&&Em(s);if((l||!this.options.showOnlyCurrent)&&c){const u=[this.options.emptyNodeClass];o&&u.push(this.options.emptyEditorClass);const f=Kt.node(a,a+s.nodeSize,{class:u.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(f)}return this.options.includeChildren}),ct.create(t,i)}}})]}});let Yv,Jv;if(typeof WeakMap<"u"){let t=new WeakMap;Yv=e=>t.get(e),Jv=(e,n)=>(t.set(e,n),n)}else{const t=[];let n=0;Yv=r=>{for(let i=0;i<t.length;i+=2)if(t[i]==r)return t[i+1]},Jv=(r,i)=>(n==10&&(n=0),t[n++]=r,t[n++]=i)}var pn=class{constructor(t,e,n,r){this.width=t,this.height=e,this.map=n,this.problems=r}findCell(t){for(let e=0;e<this.map.length;e++){const n=this.map[e];if(n!=t)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]==n;a++)o++;for(let a=1;s<this.height&&this.map[e+this.width*a]==n;a++)s++;return{left:r,top:i,right:o,bottom:s}}throw new RangeError(`No cell with offset ${t} found`)}colCount(t){for(let e=0;e<this.map.length;e++)if(this.map[e]==t)return e%this.width;throw new RangeError(`No cell with offset ${t} found`)}nextCell(t,e,n){const{left:r,right:i,top:o,bottom:s}=this.findCell(t);return e=="horiz"?(n<0?r==0:i==this.width)?null:this.map[o*this.width+(n<0?r-1:i)]:(n<0?o==0:s==this.height)?null:this.map[r+this.width*(n<0?o-1:s)]}rectBetween(t,e){const{left:n,right:r,top:i,bottom:o}=this.findCell(t),{left:s,right:a,top:l,bottom:c}=this.findCell(e);return{left:Math.min(n,s),top:Math.min(i,l),right:Math.max(r,a),bottom:Math.max(o,c)}}cellsInRect(t){const e=[],n={};for(let r=t.top;r<t.bottom;r++)for(let i=t.left;i<t.right;i++){const o=r*this.width+i,s=this.map[o];n[s]||(n[s]=!0,!(i==t.left&&i&&this.map[o-1]==s||r==t.top&&r&&this.map[o-this.width]==s)&&e.push(s))}return e}positionAt(t,e,n){for(let r=0,i=0;;r++){const o=i+n.child(r).nodeSize;if(r==t){let s=e+t*this.width;const a=(t+1)*this.width;for(;s<a&&this.map[s]<i;)s++;return s==a?o-1:this.map[s]}i=o}}static get(t){return Yv(t)||Jv(t,Kq(t))}};function Kq(t){if(t.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+t.type.name);const e=Gq(t),n=t.childCount,r=[];let i=0,o=null;const s=[];for(let c=0,u=e*n;c<u;c++)r[c]=0;for(let c=0,u=0;c<n;c++){const f=t.child(c);u++;for(let m=0;;m++){for(;i<r.length&&r[i]!=0;)i++;if(m==f.childCount)break;const v=f.child(m),{colspan:g,rowspan:b,colwidth:_}=v.attrs;for(let k=0;k<b;k++){if(k+c>=n){(o||(o=[])).push({type:"overlong_rowspan",pos:u,n:b-k});break}const C=i+k*e;for(let E=0;E<g;E++){r[C+E]==0?r[C+E]=u:(o||(o=[])).push({type:"collision",row:c,pos:u,n:g-E});const I=_&&_[E];if(I){const A=(C+E)%e*2,M=s[A];M==null||M!=I&&s[A+1]==1?(s[A]=I,s[A+1]=1):M==I&&s[A+1]++}}}i+=g,u+=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}),u++}(e===0||n===0)&&(o||(o=[])).push({type:"zero_sized"});const a=new pn(e,n,r,o);let l=!1;for(let c=0;!l&&c<s.length;c+=2)s[c]!=null&&s[c+1]<n&&(l=!0);return l&&Zq(a,s,t),a}function Gq(t){let e=-1,n=!1;for(let r=0;r<t.childCount;r++){const i=t.child(r);let o=0;if(n)for(let s=0;s<r;s++){const a=t.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&&(n=!0)}e==-1?e=o:e!=o&&(e=Math.max(e,o))}return e}function Zq(t,e,n){t.problems||(t.problems=[]);const r={};for(let i=0;i<t.map.length;i++){const o=t.map[i];if(r[o])continue;r[o]=!0;const s=n.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 u=e[(i+c)%t.width*2];u!=null&&(!l.colwidth||l.colwidth[c]!=u)&&((a||(a=Yq(l)))[c]=u)}a&&t.problems.unshift({type:"colwidth mismatch",pos:o,colwidth:a})}}function Yq(t){if(t.colwidth)return t.colwidth.slice();const e=[];for(let n=0;n<t.colspan;n++)e.push(0);return e}function sr(t){let e=t.cached.tableNodeTypes;if(!e){e=t.cached.tableNodeTypes={};for(const n in t.nodes){const r=t.nodes[n],i=r.spec.tableRole;i&&(e[i]=r)}}return e}const ls=new Ut("selectingCells");function Fa(t){for(let e=t.depth-1;e>0;e--)if(t.node(e).type.spec.tableRole=="row")return t.node(0).resolve(t.before(e+1));return null}function Jq(t){for(let e=t.depth;e>0;e--){const n=t.node(e).type.spec.tableRole;if(n==="cell"||n==="header_cell")return t.node(e)}return null}function Pi(t){const e=t.selection.$head;for(let n=e.depth;n>0;n--)if(e.node(n).type.spec.tableRole=="row")return!0;return!1}function Mm(t){const e=t.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 n=Fa(e.$head)||Xq(e.$head);if(n)return n;throw new RangeError(`No cell found around position ${e.head}`)}function Xq(t){for(let e=t.nodeAfter,n=t.pos;e;e=e.firstChild,n++){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n)}for(let e=t.nodeBefore,n=t.pos;e;e=e.lastChild,n--){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n-e.nodeSize)}}function Xv(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function Qq(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function G1(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function jA(t,e,n){const r=t.node(-1),i=pn.get(r),o=t.start(-1),s=i.nextCell(t.pos-o,e,n);return s==null?null:t.node(0).resolve(o+s)}function za(t,e,n=1){const r={...t,colspan:t.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,n),r.colwidth.some(i=>i>0)||(r.colwidth=null)),r}function qA(t,e,n=1){const r={...t,colspan:t.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let i=0;i<n;i++)r.colwidth.splice(e,0,0)}return r}function $q(t,e,n){const r=sr(e.type.schema).header_cell;for(let i=0;i<t.height;i++)if(e.nodeAt(t.map[n+i*t.width]).type!=r)return!1;return!0}var en=class xo extends lt{constructor(e,n=e){const r=e.node(-1),i=pn.get(r),o=e.start(-1),s=i.rectBetween(e.pos-o,n.pos-o),a=e.node(0),l=i.cellsInRect(s).filter(u=>u!=n.pos-o);l.unshift(n.pos-o);const c=l.map(u=>{const f=r.nodeAt(u);if(!f)throw new RangeError(`No cell with offset ${u} found`);const h=o+u+1;return new $C(a.resolve(h),a.resolve(h+f.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=n}map(e,n){const r=e.resolve(n.map(this.$anchorCell.pos)),i=e.resolve(n.map(this.$headCell.pos));if(Xv(r)&&Xv(i)&&G1(r,i)){const o=this.$anchorCell.node(-1)!=r.node(-1);return o&&this.isRowSelection()?xo.rowSelection(r,i):o&&this.isColSelection()?xo.colSelection(r,i):new xo(r,i)}return $e.between(r,i)}content(){const e=this.$anchorCell.node(-1),n=pn.get(e),r=this.$anchorCell.start(-1),i=n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),o={},s=[];for(let l=i.top;l<i.bottom;l++){const c=[];for(let u=l*n.width+i.left,f=i.left;f<i.right;f++,u++){const h=n.map[u];if(o[h])continue;o[h]=!0;const p=n.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 b=m.attrs;if(v>0&&(b=za(b,0,v)),g>0&&(b=za(b,b.colspan-g,g)),p.left<i.left){if(m=m.type.createAndFill(b),!m)throw new RangeError(`Could not create cell with attrs ${JSON.stringify(b)}`)}else m=m.type.create(b,m.content)}if(p.top<i.top||p.bottom>i.bottom){const b={...m.attrs,rowspan:Math.min(p.bottom,i.bottom)-Math.max(p.top,i.top)};p.top<i.top?m=m.type.createAndFill(b):m=m.type.create(b,m.content)}c.push(m)}s.push(e.child(l).copy(be.from(c)))}const a=this.isColSelection()&&this.isRowSelection()?e:s;return new Le(be.from(a),1,1)}replace(e,n=Le.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?Le.empty:n)}const o=lt.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);o&&e.setSelection(o)}replaceWith(e,n){this.replace(e,new Le(be.from(n),0,0))}forEachCell(e){const n=this.$anchorCell.node(-1),r=pn.get(n),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(n.nodeAt(o[s]),i+o[s])}isColSelection(){const e=this.$anchorCell.index(-1),n=this.$headCell.index(-1);if(Math.min(e,n)>0)return!1;const r=e+this.$anchorCell.nodeAfter.attrs.rowspan,i=n+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,i)==this.$headCell.node(-1).childCount}static colSelection(e,n=e){const r=e.node(-1),i=pn.get(r),o=e.start(-1),s=i.findCell(e.pos-o),a=i.findCell(n.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&&(n=l.resolve(o+i.map[i.width*(i.height-1)+a.right-1]))):(a.top>0&&(n=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 xo(e,n)}isRowSelection(){const e=this.$anchorCell.node(-1),n=pn.get(e),r=this.$anchorCell.start(-1),i=n.colCount(this.$anchorCell.pos-r),o=n.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)==n.width}eq(e){return e instanceof xo&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,n=e){const r=e.node(-1),i=pn.get(r),o=e.start(-1),s=i.findCell(e.pos-o),a=i.findCell(n.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&&(n=l.resolve(o+i.map[i.width*(a.top+1)-1]))):(a.left>0&&(n=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 xo(e,n)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,n){return new xo(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){return new xo(e.resolve(n),e.resolve(r))}getBookmark(){return new eW(this.$anchorCell.pos,this.$headCell.pos)}};en.prototype.visible=!1;lt.jsonID("cell",en);var eW=class WA{constructor(e,n){this.anchor=e,this.head=n}map(e){return new WA(e.map(this.anchor),e.map(this.head))}resolve(e){const n=e.resolve(this.anchor),r=e.resolve(this.head);return n.parent.type.spec.tableRole=="row"&&r.parent.type.spec.tableRole=="row"&&n.index()<n.parent.childCount&&r.index()<r.parent.childCount&&G1(n,r)?new en(n,r):lt.near(r,1)}};function tW(t){if(!(t.selection instanceof en))return null;const e=[];return t.selection.forEachCell((n,r)=>{e.push(Kt.node(r,r+n.nodeSize,{class:"selectedCell"}))}),ct.create(t.doc,e)}function nW({$from:t,$to:e}){if(t.pos==e.pos||t.pos<e.pos-6)return!1;let n=t.pos,r=e.pos,i=t.depth;for(;i>=0&&!(t.after(i+1)<t.end(i));i--,n++);for(let o=e.depth;o>=0&&!(e.before(o+1)>e.start(o));o--,r--);return n==r&&/row|table/.test(t.node(i).type.spec.tableRole)}function rW({$from:t,$to:e}){let n,r;for(let i=t.depth;i>0;i--){const o=t.node(i);if(o.type.spec.tableRole==="cell"||o.type.spec.tableRole==="header_cell"){n=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 n!==r&&e.parentOffset===0}function iW(t,e,n){const r=(e||t).selection,i=(e||t).doc;let o,s;if(r instanceof rt&&(s=r.node.type.spec.tableRole)){if(s=="cell"||s=="header_cell")o=en.create(i,r.from);else if(s=="row"){const a=i.resolve(r.from+1);o=en.rowSelection(a,a)}else if(!n){const a=pn.get(r.node),l=r.from+1,c=l+a.map[a.width*a.height-1];o=en.create(i,l+1,c)}}else r instanceof $e&&nW(r)?o=$e.create(i,r.from):r instanceof $e&&rW(r)&&(o=$e.create(i,r.$from.start(),r.$from.end()));return o&&(e||(e=t.tr)).setSelection(o),e}const oW=new Ut("fix-tables");function KA(t,e,n,r){const i=t.childCount,o=e.childCount;e:for(let s=0,a=0;s<o;s++){const l=e.child(s);for(let c=a,u=Math.min(i,s+3);c<u;c++)if(t.child(c)==l){a=c+1,n+=l.nodeSize;continue e}r(l,n),a<i&&t.child(a).sameMarkup(l)?KA(t.child(a),l,n+1,r):l.nodesBetween(0,l.content.size,r,n+1),n+=l.nodeSize}}function GA(t,e){let n;const r=(i,o)=>{i.type.spec.tableRole=="table"&&(n=sW(t,i,o,n))};return e?e.doc!=t.doc&&KA(e.doc,t.doc,0,r):t.doc.descendants(r),n}function sW(t,e,n,r){const i=pn.get(e);if(!i.problems)return r;r||(r=t.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 u=e.nodeAt(c.pos);if(!u)continue;const f=u.attrs;for(let h=0;h<f.rowspan;h++)o[c.row+h]+=c.n;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,za(f,f.colspan-c.n,c.n))}else if(c.type=="missing")o[c.row]+=c.n;else if(c.type=="overlong_rowspan"){const u=e.nodeAt(c.pos);if(!u)continue;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,{...u.attrs,rowspan:u.attrs.rowspan-c.n})}else if(c.type=="colwidth mismatch"){const u=e.nodeAt(c.pos);if(!u)continue;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,{...u.attrs,colwidth:c.colwidth})}else if(c.type=="zero_sized"){const u=r.mapping.map(n);r.delete(u,u+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=n+1;l<i.height;l++){const u=e.child(l),f=c+u.nodeSize,h=o[l];if(h>0){let p="cell";u.firstChild&&(p=u.firstChild.type.spec.tableRole);const m=[];for(let g=0;g<h;g++){const b=sr(t.schema)[p].createAndFill();b&&m.push(b)}const v=(l==0||s==l-1)&&a==l?c+1:f-1;r.insert(r.mapping.map(v),m)}c=f}return r.setMeta(oW,{fixTables:!0})}function fo(t){const e=t.selection,n=Mm(t),r=n.node(-1),i=n.start(-1),o=pn.get(r);return{...e instanceof en?o.rectBetween(e.$anchorCell.pos-i,e.$headCell.pos-i):o.findCell(n.pos-i),tableStart:i,map:o,table:r}}function ZA(t,{map:e,tableStart:n,table:r},i){let o=i>0?-1:0;$q(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);t.setNodeMarkup(t.mapping.map(n+l),null,qA(c.attrs,i-e.colCount(l))),s+=c.attrs.rowspan-1}else{const l=o==null?sr(r.type.schema).cell:r.nodeAt(e.map[a+o]).type,c=e.positionAt(s,i,r);t.insert(t.mapping.map(n+c),l.createAndFill())}}return t}function aW(t,e){if(!Pi(t))return!1;if(e){const n=fo(t);e(ZA(t.tr,n,n.left))}return!0}function lW(t,e){if(!Pi(t))return!1;if(e){const n=fo(t);e(ZA(t.tr,n,n.right))}return!0}function cW(t,{map:e,table:n,tableStart:r},i){const o=t.mapping.maps.length;for(let s=0;s<e.height;){const a=s*e.width+i,l=e.map[a],c=n.nodeAt(l),u=c.attrs;if(i>0&&e.map[a-1]==l||i<e.width-1&&e.map[a+1]==l)t.setNodeMarkup(t.mapping.slice(o).map(r+l),null,za(u,i-e.colCount(l)));else{const f=t.mapping.slice(o).map(r+l);t.delete(f,f+c.nodeSize)}s+=u.rowspan}}function uW(t,e){if(!Pi(t))return!1;if(e){const n=fo(t),r=t.tr;if(n.left==0&&n.right==n.map.width)return!1;for(let i=n.right-1;cW(r,n,i),i!=n.left;i--){const o=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!o)throw new RangeError("No table found");n.table=o,n.map=pn.get(o)}e(r)}return!0}function dW(t,e,n){var r;const i=sr(e.type.schema).header_cell;for(let o=0;o<t.width;o++)if(((r=e.nodeAt(t.map[o+n*t.width]))===null||r===void 0?void 0:r.type)!=i)return!1;return!0}function YA(t,{map:e,tableStart:n,table:r},i){let o=n;for(let c=0;c<i;c++)o+=r.child(c).nodeSize;const s=[];let a=i>0?-1:0;dW(e,r,i+a)&&(a=i==0||i==e.height?null:0);for(let c=0,u=e.width*i;c<e.width;c++,u++)if(i>0&&i<e.height&&e.map[u]==e.map[u-e.width]){const f=e.map[u],h=r.nodeAt(f).attrs;t.setNodeMarkup(n+f,null,{...h,rowspan:h.rowspan+1}),c+=h.colspan-1}else{var l;const f=a==null?sr(r.type.schema).cell:(l=r.nodeAt(e.map[u+a*e.width]))===null||l===void 0?void 0:l.type,h=f==null?void 0:f.createAndFill();h&&s.push(h)}return t.insert(o,sr(r.type.schema).row.create(null,s)),t}function fW(t,e){if(!Pi(t))return!1;if(e){const n=fo(t);e(YA(t.tr,n,n.top))}return!0}function hW(t,e){if(!Pi(t))return!1;if(e){const n=fo(t);e(YA(t.tr,n,n.bottom))}return!0}function pW(t,{map:e,table:n,tableStart:r},i){let o=0;for(let c=0;c<i;c++)o+=n.child(c).nodeSize;const s=o+n.child(i).nodeSize,a=t.mapping.maps.length;t.delete(o+r,s+r);const l=new Set;for(let c=0,u=i*e.width;c<e.width;c++,u++){const f=e.map[u];if(!l.has(f)){if(l.add(f),i>0&&f==e.map[u-e.width]){const h=n.nodeAt(f).attrs;t.setNodeMarkup(t.mapping.slice(a).map(f+r),null,{...h,rowspan:h.rowspan-1}),c+=h.colspan-1}else if(i<e.height&&f==e.map[u+e.width]){const h=n.nodeAt(f),p=h.attrs,m=h.type.create({...p,rowspan:h.attrs.rowspan-1},h.content),v=e.positionAt(i+1,c,n);t.insert(t.mapping.slice(a).map(r+v),m),c+=p.colspan-1}}}}function mW(t,e){if(!Pi(t))return!1;if(e){const n=fo(t),r=t.tr;if(n.top==0&&n.bottom==n.map.height)return!1;for(let i=n.bottom-1;pW(r,n,i),i!=n.top;i--){const o=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!o)throw new RangeError("No table found");n.table=o,n.map=pn.get(n.table)}e(r)}return!0}function wk(t){const e=t.content;return e.childCount==1&&e.child(0).isTextblock&&e.child(0).childCount==0}function gW({width:t,height:e,map:n},r){let i=r.top*t+r.left,o=i,s=(r.bottom-1)*t+r.left,a=i+(r.right-r.left-1);for(let l=r.top;l<r.bottom;l++){if(r.left>0&&n[o]==n[o-1]||r.right<t&&n[a]==n[a+1])return!0;o+=t,a+=t}for(let l=r.left;l<r.right;l++){if(r.top>0&&n[i]==n[i-t]||r.bottom<e&&n[s]==n[s+t])return!0;i++,s++}return!1}function xk(t,e){const n=t.selection;if(!(n instanceof en)||n.$anchorCell.pos==n.$headCell.pos)return!1;const r=fo(t),{map:i}=r;if(gW(i,r))return!1;if(e){const o=t.tr,s={};let a=be.empty,l,c;for(let u=r.top;u<r.bottom;u++)for(let f=r.left;f<r.right;f++){const h=i.map[u*i.width+f],p=r.table.nodeAt(h);if(!(s[h]||!p))if(s[h]=!0,l==null)l=h,c=p;else{wk(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,{...qA(c.attrs,c.attrs.colspan,r.right-r.left-c.attrs.colspan),rowspan:r.bottom-r.top}),a.size>0){const u=l+1+c.content.size,f=wk(c)?l+1:u;o.replaceWith(f+r.tableStart,u+r.tableStart,a)}o.setSelection(new en(o.doc.resolve(l+r.tableStart))),e(o)}return!0}function kk(t,e){const n=sr(t.schema);return vW(({node:r})=>n[r.type.spec.tableRole])(t,e)}function vW(t){return(e,n)=>{const r=e.selection;let i,o;if(r instanceof en){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;i=r.$anchorCell.nodeAfter,o=r.$anchorCell.pos}else{var s;if(i=Jq(r.$from),!i)return!1;o=(s=Fa(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(n){let a=i.attrs;const l=[],c=a.colwidth;a.rowspan>1&&(a={...a,rowspan:1}),a.colspan>1&&(a={...a,colspan:1});const u=fo(e),f=e.tr;for(let p=0;p<u.right-u.left;p++)l.push(c?{...a,colwidth:c&&c[p]?[c[p]]:null}:a);let h;for(let p=u.top;p<u.bottom;p++){let m=u.map.positionAt(p,u.left,u.table);p==u.top&&(m+=i.nodeSize);for(let v=u.left,g=0;v<u.right;v++,g++)v==u.left&&p==u.top||f.insert(h=f.mapping.map(m+u.tableStart,1),t({node:i,row:p,col:v}).createAndFill(l[g]))}f.setNodeMarkup(o,t({node:i,row:u.top,col:u.left}),l[0]),r instanceof en&&f.setSelection(new en(f.doc.resolve(r.$anchorCell.pos),h?f.doc.resolve(h):void 0)),n(f)}return!0}}function bW(t,e){return function(n,r){if(!Pi(n))return!1;const i=Mm(n);if(i.nodeAfter.attrs[t]===e)return!1;if(r){const o=n.tr;n.selection instanceof en?n.selection.forEachCell((s,a)=>{s.attrs[t]!==e&&o.setNodeMarkup(a,null,{...s.attrs,[t]:e})}):o.setNodeMarkup(i.pos,null,{...i.nodeAfter.attrs,[t]:e}),r(o)}return!0}}function yW(t){return function(e,n){if(!Pi(e))return!1;if(n){const r=sr(e.schema),i=fo(e),o=e.tr,s=i.map.cellsInRect(t=="column"?{left:i.left,top:0,right:i.right,bottom:i.map.height}:t=="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);n(o)}return!0}}function _k(t,e,n){const r=e.map.cellsInRect({left:0,top:0,right:t=="row"?e.map.width:1,bottom:t=="column"?e.map.height:1});for(let i=0;i<r.length;i++){const o=e.table.nodeAt(r[i]);if(o&&o.type!==n.header_cell)return!1}return!0}function ed(t,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?yW(t):function(n,r){if(!Pi(n))return!1;if(r){const i=sr(n.schema),o=fo(n),s=n.tr,a=_k("row",o,i),l=_k("column",o,i),c=(t==="column"?a:t==="row"&&l)?1:0,u=t=="column"?{left:0,top:c,right:1,bottom:o.map.height}:t=="row"?{left:c,top:0,right:o.map.width,bottom:1}:o,f=t=="column"?l?i.cell:i.header_cell:t=="row"?a?i.cell:i.header_cell:i.cell;o.map.cellsInRect(u).forEach(h=>{const p=h+o.tableStart,m=s.doc.nodeAt(p);m&&s.setNodeMarkup(p,f,m.attrs)}),r(s)}return!0}}ed("row",{useDeprecatedLogic:!0});ed("column",{useDeprecatedLogic:!0});const wW=ed("cell",{useDeprecatedLogic:!0});function xW(t,e){if(e<0){const n=t.nodeBefore;if(n)return t.pos-n.nodeSize;for(let r=t.index(-1)-1,i=t.before();r>=0;r--){const o=t.node(-1).child(r),s=o.lastChild;if(s)return i-1-s.nodeSize;i-=o.nodeSize}}else{if(t.index()<t.parent.childCount-1)return t.pos+t.nodeAfter.nodeSize;const n=t.node(-1);for(let r=t.indexAfter(-1),i=t.after();r<n.childCount;r++){const o=n.child(r);if(o.childCount)return i+1;i+=o.nodeSize}}return null}function Ck(t){return function(e,n){if(!Pi(e))return!1;const r=xW(Mm(e),t);if(r==null)return!1;if(n){const i=e.doc.resolve(r);n(e.tr.setSelection($e.between(i,Qq(i))).scrollIntoView())}return!0}}function kW(t,e){const n=t.selection.$anchor;for(let r=n.depth;r>0;r--)if(n.node(r).type.spec.tableRole=="table")return e&&e(t.tr.delete(n.before(r),n.after(r)).scrollIntoView()),!0;return!1}function pf(t,e){const n=t.selection;if(!(n instanceof en))return!1;if(e){const r=t.tr,i=sr(t.schema).cell.createAndFill().content;n.forEachCell((o,s)=>{o.content.eq(i)||r.replace(r.mapping.map(s+1),r.mapping.map(s+o.nodeSize-1),new Le(i,0,0))}),r.docChanged&&e(r)}return!0}function _W(t){if(t.size===0)return null;let{content:e,openStart:n,openEnd:r}=t;for(;e.childCount==1&&(n>0&&r>0||e.child(0).type.spec.tableRole=="table");)n--,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 u=l?0:Math.max(0,n-1),f=l<e.childCount-1?0:Math.max(0,r-1);(u||f)&&(c=Qv(sr(s).row,new Le(c,u,f)).content),a.push(c)}else if(o=="cell"||o=="header_cell")a.push(n||r?Qv(sr(s).row,new Le(e,n,r)).content:e);else return null;return CW(s,a)}function CW(t,e){const n=[];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++)n[c]=(n[c]||0)+l}}let r=0;for(let i=0;i<n.length;i++)r=Math.max(r,n[i]);for(let i=0;i<n.length;i++)if(i>=e.length&&e.push(be.empty),n[i]<r){const o=sr(t).cell.createAndFill(),s=[];for(let a=n[i];a<r;a++)s.push(o);e[i]=e[i].append(be.from(s))}return{height:e.length,width:r,rows:e}}function Qv(t,e){const n=t.createAndFill();return new Rb(n).replace(0,n.content.size,e).doc}function SW({width:t,height:e,rows:n},r,i){if(t!=r){const o=[],s=[];for(let a=0;a<n.length;a++){const l=n[a],c=[];for(let u=o[a]||0,f=0;u<r;f++){let h=l.child(f%l.childCount);u+h.attrs.colspan>r&&(h=h.type.createChecked(za(h.attrs,h.attrs.colspan,u+h.attrs.colspan-r),h.content)),c.push(h),u+=h.attrs.colspan;for(let p=1;p<h.attrs.rowspan;p++)o[a+p]=(o[a+p]||0)+h.attrs.colspan}s.push(be.from(c))}n=s,t=r}if(e!=i){const o=[];for(let s=0,a=0;s<i;s++,a++){const l=[],c=n[a%e];for(let u=0;u<c.childCount;u++){let f=c.child(u);s+f.attrs.rowspan>i&&(f=f.type.create({...f.attrs,rowspan:Math.max(1,i-f.attrs.rowspan)},f.content)),l.push(f)}o.push(be.from(l))}n=o,e=i}return{width:t,height:e,rows:n}}function EW(t,e,n,r,i,o,s){const a=t.doc.type.schema,l=sr(a);let c,u;if(i>e.width)for(let f=0,h=0;f<e.height;f++){const p=n.child(f);h+=p.nodeSize;const m=[];let v;p.lastChild==null||p.lastChild.type==l.cell?v=c||(c=l.cell.createAndFill()):v=u||(u=l.header_cell.createAndFill());for(let g=e.width;g<i;g++)m.push(v);t.insert(t.mapping.slice(s).map(h-1+r),m)}if(o>e.height){const f=[];for(let m=0,v=(e.height-1)*e.width;m<Math.max(e.width,i);m++){const g=m>=e.width?!1:n.nodeAt(e.map[v+m]).type==l.header_cell;f.push(g?u||(u=l.header_cell.createAndFill()):c||(c=l.cell.createAndFill()))}const h=l.row.create(null,be.from(f)),p=[];for(let m=e.height;m<o;m++)p.push(h);t.insert(t.mapping.slice(s).map(r+n.nodeSize-2),p)}return!!(c||u)}function Sk(t,e,n,r,i,o,s,a){if(s==0||s==e.height)return!1;let l=!1;for(let c=i;c<o;c++){const u=s*e.width+c,f=e.map[u];if(e.map[u-e.width]==f){l=!0;const h=n.nodeAt(f),{top:p,left:m}=e.findCell(f);t.setNodeMarkup(t.mapping.slice(a).map(f+r),null,{...h.attrs,rowspan:s-p}),t.insert(t.mapping.slice(a).map(e.positionAt(s,m,n)),h.type.createAndFill({...h.attrs,rowspan:p+h.attrs.rowspan-s})),c+=h.attrs.colspan-1}}return l}function Ek(t,e,n,r,i,o,s,a){if(s==0||s==e.width)return!1;let l=!1;for(let c=i;c<o;c++){const u=c*e.width+s,f=e.map[u];if(e.map[u-1]==f){l=!0;const h=n.nodeAt(f),p=e.colCount(f),m=t.mapping.slice(a).map(f+r);t.setNodeMarkup(m,null,za(h.attrs,s-p,h.attrs.colspan-(s-p))),t.insert(m+h.nodeSize,h.type.createAndFill(za(h.attrs,0,s-p))),c+=h.attrs.rowspan-1}}return l}function Ak(t,e,n,r,i){let o=n?t.doc.nodeAt(n-1):t.doc;if(!o)throw new Error("No table found");let s=pn.get(o);const{top:a,left:l}=r,c=l+i.width,u=a+i.height,f=t.tr;let h=0;function p(){if(o=n?f.doc.nodeAt(n-1):f.doc,!o)throw new Error("No table found");s=pn.get(o),h=f.mapping.maps.length}EW(f,s,o,n,c,u,h)&&p(),Sk(f,s,o,n,l,c,a,h)&&p(),Sk(f,s,o,n,l,c,u,h)&&p(),Ek(f,s,o,n,a,u,l,h)&&p(),Ek(f,s,o,n,a,u,c,h)&&p();for(let m=a;m<u;m++){const v=s.positionAt(m,l,o),g=s.positionAt(m,c,o);f.replace(f.mapping.slice(h).map(v+n),f.mapping.slice(h).map(g+n),new Le(i.rows[m-a],0,0))}p(),f.setSelection(new en(f.doc.resolve(n+s.positionAt(a,l,o)),f.doc.resolve(n+s.positionAt(u-1,c-1,o)))),e(f)}const AW=S1({ArrowLeft:mf("horiz",-1),ArrowRight:mf("horiz",1),ArrowUp:mf("vert",-1),ArrowDown:mf("vert",1),"Shift-ArrowLeft":gf("horiz",-1),"Shift-ArrowRight":gf("horiz",1),"Shift-ArrowUp":gf("vert",-1),"Shift-ArrowDown":gf("vert",1),Backspace:pf,"Mod-Backspace":pf,Delete:pf,"Mod-Delete":pf});function eh(t,e,n){return n.eq(t.selection)?!1:(e&&e(t.tr.setSelection(n).scrollIntoView()),!0)}function mf(t,e){return(n,r,i)=>{if(!i)return!1;const o=n.selection;if(o instanceof en)return eh(n,r,lt.near(o.$headCell,e));if(t!="horiz"&&!o.empty)return!1;const s=JA(i,t,e);if(s==null)return!1;if(t=="horiz")return eh(n,r,lt.near(n.doc.resolve(o.head+e),e));{const a=n.doc.resolve(s),l=jA(a,t,e);let c;return l?c=lt.near(l,1):e<0?c=lt.near(n.doc.resolve(a.before(-1)),-1):c=lt.near(n.doc.resolve(a.after(-1)),1),eh(n,r,c)}}}function gf(t,e){return(n,r,i)=>{if(!i)return!1;const o=n.selection;let s;if(o instanceof en)s=o;else{const l=JA(i,t,e);if(l==null)return!1;s=new en(n.doc.resolve(l))}const a=jA(s.$headCell,t,e);return a?eh(n,r,new en(s.$anchorCell,a)):!1}}function TW(t,e){const n=t.state.doc,r=Fa(n.resolve(e));return r?(t.dispatch(t.state.tr.setSelection(new en(r))),!0):!1}function MW(t,e,n){if(!Pi(t.state))return!1;let r=_W(n);const i=t.state.selection;if(i instanceof en){r||(r={width:1,height:1,rows:[be.from(Qv(sr(t.state.schema).cell,n))]});const o=i.$anchorCell.node(-1),s=i.$anchorCell.start(-1),a=pn.get(o).rectBetween(i.$anchorCell.pos-s,i.$headCell.pos-s);return r=SW(r,a.right-a.left,a.bottom-a.top),Ak(t.state,t.dispatch,s,a,r),!0}else if(r){const o=Mm(t.state),s=o.start(-1);return Ak(t.state,t.dispatch,s,pn.get(o.node(-1)).findCell(o.pos-s),r),!0}else return!1}function DW(t,e){var n;if(e.button!=0||e.ctrlKey||e.metaKey)return;const r=Tk(t,e.target);let i;if(e.shiftKey&&t.state.selection instanceof en)o(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(i=Fa(t.state.selection.$anchor))!=null&&((n=Ug(t,e))===null||n===void 0?void 0:n.pos)!=i.pos)o(i,e),e.preventDefault();else if(!r)return;function o(l,c){let u=Ug(t,c);const f=ls.getState(t.state)==null;if(!u||!G1(l,u))if(f)u=l;else return;const h=new en(l,u);if(f||!t.state.selection.eq(h)){const p=t.state.tr.setSelection(h);f&&p.setMeta(ls,l.pos),t.dispatch(p)}}function s(){t.root.removeEventListener("mouseup",s),t.root.removeEventListener("dragstart",s),t.root.removeEventListener("mousemove",a),ls.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta(ls,-1))}function a(l){const c=l,u=ls.getState(t.state);let f;if(u!=null)f=t.state.doc.resolve(u);else if(Tk(t,c.target)!=r&&(f=Ug(t,e),!f))return s();f&&o(f,c)}t.root.addEventListener("mouseup",s),t.root.addEventListener("dragstart",s),t.root.addEventListener("mousemove",a)}function JA(t,e,n){if(!(t.state.selection instanceof $e))return null;const{$head:r}=t.state.selection;for(let i=r.depth-1;i>=0;i--){const o=r.node(i);if((n<0?r.index(i):r.indexAfter(i))!=(n<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"?n>0?"down":"up":n>0?"right":"left";return t.endOfTextblock(a)?s:null}}return null}function Tk(t,e){for(;e&&e!=t.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function Ug(t,e){const n=t.posAtCoords({left:e.clientX,top:e.clientY});if(!n)return null;let{inside:r,pos:i}=n;return r>=0&&Fa(t.state.doc.resolve(r))||Fa(t.state.doc.resolve(i))}var OW=class{constructor(e,n){this.node=e,this.defaultCellMinWidth=n,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",`${n}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),$v(e,this.colgroup,this.table,n),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!=this.node.type?!1:(this.node=e,$v(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function $v(t,e,n,r,i,o){let s=0,a=!0,l=e.firstChild;const c=t.firstChild;if(c){for(let f=0,h=0;f<c.childCount;f++){const{colspan:p,colwidth:m}=c.child(f).attrs;for(let v=0;v<p;v++,h++){const g=i==h?o:m&&m[v],b=g?g+"px":"";if(s+=g||r,g||(a=!1),l)l.style.width!=b&&(l.style.width=b),l=l.nextSibling;else{const _=document.createElement("col");_.style.width=b,e.appendChild(_)}}}for(;l;){var u;const f=l.nextSibling;(u=l.parentNode)===null||u===void 0||u.removeChild(l),l=f}a?(n.style.width=s+"px",n.style.minWidth=""):(n.style.width="",n.style.minWidth=s+"px")}}const jr=new Ut("tableColumnResizing");function IW({handleWidth:t=5,cellMinWidth:e=25,defaultCellMinWidth:n=100,View:r=OW,lastColumnResizable:i=!0}={}){const o=new Lt({key:jr,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,u=sr(a.schema).table.name;return r&&c&&(c[u]=(f,h)=>new r(f,n,h)),new RW(-1,!1)},apply(s,a){return a.apply(s)}},props:{attributes:s=>{const a=jr.getState(s);return a&&a.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(s,a)=>{NW(s,a,t,i)},mouseleave:s=>{PW(s)},mousedown:(s,a)=>{LW(s,a,e,n)}},decorations:s=>{const a=jr.getState(s);if(a&&a.activeHandle>-1)return VW(s,a.activeHandle)},nodeViews:{}}});return o}var RW=class th{constructor(e,n){this.activeHandle=e,this.dragging=n}apply(e){const n=this,r=e.getMeta(jr);if(r&&r.setHandle!=null)return new th(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new th(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&e.docChanged){let i=e.mapping.map(n.activeHandle,-1);return Xv(e.doc.resolve(i))||(i=-1),new th(i,n.dragging)}return n}};function NW(t,e,n,r){if(!t.editable)return;const i=jr.getState(t.state);if(i&&!i.dragging){const o=zW(e.target);let s=-1;if(o){const{left:a,right:l}=o.getBoundingClientRect();e.clientX-a<=n?s=Mk(t,e,"left",n):l-e.clientX<=n&&(s=Mk(t,e,"right",n))}if(s!=i.activeHandle){if(!r&&s!==-1){const a=t.state.doc.resolve(s),l=a.node(-1),c=pn.get(l),u=a.start(-1);if(c.colCount(a.pos-u)+a.nodeAfter.attrs.colspan-1==c.width-1)return}XA(t,s)}}}function PW(t){if(!t.editable)return;const e=jr.getState(t.state);e&&e.activeHandle>-1&&!e.dragging&&XA(t,-1)}function LW(t,e,n,r){var i;if(!t.editable)return!1;const o=(i=t.dom.ownerDocument.defaultView)!==null&&i!==void 0?i:window,s=jr.getState(t.state);if(!s||s.activeHandle==-1||s.dragging)return!1;const a=t.state.doc.nodeAt(s.activeHandle),l=FW(t,s.activeHandle,a.attrs);t.dispatch(t.state.tr.setMeta(jr,{setDragging:{startX:e.clientX,startWidth:l}}));function c(f){o.removeEventListener("mouseup",c),o.removeEventListener("mousemove",u);const h=jr.getState(t.state);h!=null&&h.dragging&&(BW(t,h.activeHandle,Dk(h.dragging,f,n)),t.dispatch(t.state.tr.setMeta(jr,{setDragging:null})))}function u(f){if(!f.which)return c(f);const h=jr.getState(t.state);if(h&&h.dragging){const p=Dk(h.dragging,f,n);Ok(t,h.activeHandle,p,r)}}return Ok(t,s.activeHandle,l,r),o.addEventListener("mouseup",c),o.addEventListener("mousemove",u),e.preventDefault(),!0}function FW(t,e,{colspan:n,colwidth:r}){const i=r&&r[r.length-1];if(i)return i;const o=t.domAtPos(e);let s=o.node.childNodes[o.offset].offsetWidth,a=n;if(r)for(let l=0;l<n;l++)r[l]&&(s-=r[l],a--);return s/a}function zW(t){for(;t&&t.nodeName!="TD"&&t.nodeName!="TH";)t=t.classList&&t.classList.contains("ProseMirror")?null:t.parentNode;return t}function Mk(t,e,n,r){const i=n=="right"?-r:r,o=t.posAtCoords({left:e.clientX+i,top:e.clientY});if(!o)return-1;const{pos:s}=o,a=Fa(t.state.doc.resolve(s));if(!a)return-1;if(n=="right")return a.pos;const l=pn.get(a.node(-1)),c=a.start(-1),u=l.map.indexOf(a.pos-c);return u%l.width==0?-1:c+l.map[u-1]}function Dk(t,e,n){const r=e.clientX-t.startX;return Math.max(n,t.startWidth+r)}function XA(t,e){t.dispatch(t.state.tr.setMeta(jr,{setHandle:e}))}function BW(t,e,n){const r=t.state.doc.resolve(e),i=r.node(-1),o=pn.get(i),s=r.start(-1),a=o.colCount(r.pos-s)+r.nodeAfter.attrs.colspan-1,l=t.state.tr;for(let c=0;c<o.height;c++){const u=c*o.width+a;if(c&&o.map[u]==o.map[u-o.width])continue;const f=o.map[u],h=i.nodeAt(f).attrs,p=h.colspan==1?0:a-o.colCount(f);if(h.colwidth&&h.colwidth[p]==n)continue;const m=h.colwidth?h.colwidth.slice():HW(h.colspan);m[p]=n,l.setNodeMarkup(s+f,null,{...h,colwidth:m})}l.docChanged&&t.dispatch(l)}function Ok(t,e,n,r){const i=t.state.doc.resolve(e),o=i.node(-1),s=i.start(-1),a=pn.get(o).colCount(i.pos-s)+i.nodeAfter.attrs.colspan-1;let l=t.domAtPos(i.start(-1)).node;for(;l&&l.nodeName!="TABLE";)l=l.parentNode;l&&$v(o,l.firstChild,l,r,a,n)}function HW(t){return Array(t).fill(0)}function VW(t,e){const n=[],r=t.doc.resolve(e),i=r.node(-1);if(!i)return ct.empty;const o=pn.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 u=a+c*o.width;if((a==o.width-1||o.map[u]!=o.map[u+1])&&(c==0||o.map[u]!=o.map[u-o.width])){var l;const f=o.map[u],h=s+f+i.nodeAt(f).nodeSize-1,p=document.createElement("div");p.className="column-resize-handle",!((l=jr.getState(t))===null||l===void 0)&&l.dragging&&n.push(Kt.node(s+f,s+f+i.nodeAt(f).nodeSize,{class:"column-resize-dragging"})),n.push(Kt.widget(h,p))}}return ct.create(t.doc,n)}function UW({allowTableNodeSelection:t=!1}={}){return new Lt({key:ls,state:{init(){return null},apply(e,n){const r=e.getMeta(ls);if(r!=null)return r==-1?null:r;if(n==null||!e.docChanged)return n;const{deleted:i,pos:o}=e.mapping.mapResult(n);return i?null:o}},props:{decorations:tW,handleDOMEvents:{mousedown:DW},createSelectionBetween(e){return ls.getState(e.state)!=null?e.state.selection:null},handleTripleClick:TW,handleKeyDown:AW,handlePaste:MW},appendTransaction(e,n,r){return iW(r,GA(r,n),t)}})}function eb(t,e){return e?["width",`${Math.max(e,t)}px`]:["min-width",`${t}px`]}function Ik(t,e,n,r,i,o){var s;let a=0,l=!0,c=e.firstChild;const u=t.firstChild;if(u!==null)for(let f=0,h=0;f<u.childCount;f+=1){const{colspan:p,colwidth:m}=u.child(f).attrs;for(let v=0;v<p;v+=1,h+=1){const g=i===h?o:m&&m[v],b=g?`${g}px`:"";if(a+=g||r,g||(l=!1),c){if(c.style.width!==b){const[_,k]=eb(r,g);c.style.setProperty(_,k)}c=c.nextSibling}else{const _=document.createElement("col"),[k,C]=eb(r,g);_.style.setProperty(k,C),e.appendChild(_)}}}for(;c;){const f=c.nextSibling;(s=c.parentNode)===null||s===void 0||s.removeChild(c),c=f}l?(n.style.width=`${a}px`,n.style.minWidth=""):(n.style.width="",n.style.minWidth=`${a}px`)}class jW{constructor(e,n){this.node=e,this.cellMinWidth=n,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")),Ik(e,this.colgroup,this.table,n),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!==this.node.type?!1:(this.node=e,Ik(e,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(e){return e.type==="attributes"&&(e.target===this.table||this.colgroup.contains(e.target))}}function qW(t,e,n,r){let i=0,o=!0;const s=[],a=t.firstChild;if(!a)return{};for(let f=0,h=0;f<a.childCount;f+=1){const{colspan:p,colwidth:m}=a.child(f).attrs;for(let v=0;v<p;v+=1,h+=1){const g=n===h?r:m&&m[v];i+=g||e,g||(o=!1);const[b,_]=eb(e,g);s.push(["col",{style:`${b}: ${_}`}])}}const l=o?`${i}px`:"",c=o?"":`${i}px`;return{colgroup:["colgroup",{},...s],tableWidth:l,tableMinWidth:c}}function Rk(t,e){return t.createAndFill()}function WW(t){if(t.cached.tableNodeTypes)return t.cached.tableNodeTypes;const e={};return Object.keys(t.nodes).forEach(n=>{const r=t.nodes[n];r.spec.tableRole&&(e[r.spec.tableRole]=r)}),t.cached.tableNodeTypes=e,e}function KW(t,e,n,r,i){const o=WW(t),s=[],a=[];for(let c=0;c<n;c+=1){const u=Rk(o.cell);if(u&&a.push(u),r){const f=Rk(o.header_cell);f&&s.push(f)}}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 GW(t){return t instanceof en}const vf=({editor:t})=>{const{selection:e}=t.state;if(!GW(e))return!1;let n=0;const r=AA(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)&&(n+=1)}),n===e.ranges.length?(t.commands.deleteTable(),!0):!1},ZW=cr.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:jW,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:t,HTMLAttributes:e}){const{colgroup:n,tableWidth:r,tableMinWidth:i}=qW(t,this.options.cellMinWidth),o=["table",cn(this.options.HTMLAttributes,e,{style:r?`width: ${r}`:`min-width: ${i}`}),n,["tbody",0]];return this.options.renderWrapper?["div",{class:"tableWrapper"},o]:o},addCommands(){return{insertTable:({rows:t=3,cols:e=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:i,editor:o})=>{const s=KW(o.schema,t,e,n);if(i){const a=r.selection.from+1;r.replaceSelectionWith(s).scrollIntoView().setSelection($e.near(r.doc.resolve(a)))}return!0},addColumnBefore:()=>({state:t,dispatch:e})=>aW(t,e),addColumnAfter:()=>({state:t,dispatch:e})=>lW(t,e),deleteColumn:()=>({state:t,dispatch:e})=>uW(t,e),addRowBefore:()=>({state:t,dispatch:e})=>fW(t,e),addRowAfter:()=>({state:t,dispatch:e})=>hW(t,e),deleteRow:()=>({state:t,dispatch:e})=>mW(t,e),deleteTable:()=>({state:t,dispatch:e})=>kW(t,e),mergeCells:()=>({state:t,dispatch:e})=>xk(t,e),splitCell:()=>({state:t,dispatch:e})=>kk(t,e),toggleHeaderColumn:()=>({state:t,dispatch:e})=>ed("column")(t,e),toggleHeaderRow:()=>({state:t,dispatch:e})=>ed("row")(t,e),toggleHeaderCell:()=>({state:t,dispatch:e})=>wW(t,e),mergeOrSplit:()=>({state:t,dispatch:e})=>xk(t,e)?!0:kk(t,e),setCellAttribute:(t,e)=>({state:n,dispatch:r})=>bW(t,e)(n,r),goToNextCell:()=>({state:t,dispatch:e})=>Ck(1)(t,e),goToPreviousCell:()=>({state:t,dispatch:e})=>Ck(-1)(t,e),fixTables:()=>({state:t,dispatch:e})=>(e&&GA(t),!0),setCellSelection:t=>({tr:e,dispatch:n})=>{if(n){const r=en.create(e.doc,t.anchorCell,t.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:vf,"Mod-Backspace":vf,Delete:vf,"Mod-Delete":vf}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[IW({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],UW({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(t){const e={name:t.name,options:t.options,storage:t.storage};return{tableRole:kt(qe(t,"tableRole",e))}}}),YW=cr.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{const e=t.getAttribute("colwidth");return e?e.split(",").map(r=>parseInt(r,10)):null}}}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:t}){return["td",cn(this.options.HTMLAttributes,t),0]}}),JW=cr.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{const e=t.getAttribute("colwidth");return e?e.split(",").map(r=>parseInt(r,10)):null}}}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:t}){return["th",cn(this.options.HTMLAttributes,t),0]}}),XW=cr.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:t}){return["tr",cn(this.options.HTMLAttributes,t),0]}}),QW=/^\s*>\s$/,$W=cr.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return["blockquote",cn(this.options.HTMLAttributes,t),0]},addCommands(){return{setBlockquote:()=>({commands:t})=>t.wrapIn(this.name),toggleBlockquote:()=>({commands:t})=>t.toggleWrap(this.name),unsetBlockquote:()=>({commands:t})=>t.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[Ju({find:QW,type:this.type})]}}),eK=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,tK=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,nK=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,rK=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,iK=Ri.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:t=>t.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:t=>t.type.name===this.name},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}]},renderHTML({HTMLAttributes:t}){return["strong",cn(this.options.HTMLAttributes,t),0]},addCommands(){return{setBold:()=>({commands:t})=>t.setMark(this.name),toggleBold:()=>({commands:t})=>t.toggleMark(this.name),unsetBold:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[La({find:eK,type:this.type}),La({find:nK,type:this.type})]},addPasteRules(){return[Ps({find:tK,type:this.type}),Ps({find:rK,type:this.type})]}}),oK="listItem",Nk="textStyle",Pk=/^\s*([-+*])\s$/,sK=cr.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:t}){return["ul",cn(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(oK,this.editor.getAttributes(Nk)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=Ju({find:Pk,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Ju({find:Pk,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Nk),editor:this.editor})),[t]}}),aK=/(^|[^`])`([^`]+)`(?!`)/,lK=/(^|[^`])`([^`]+)`(?!`)/g,cK=Ri.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",cn(this.options.HTMLAttributes,t),0]},addCommands(){return{setCode:()=>({commands:t})=>t.setMark(this.name),toggleCode:()=>({commands:t})=>t.toggleMark(this.name),unsetCode:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[La({find:aK,type:this.type})]},addPasteRules(){return[Ps({find:lK,type:this.type})]}}),uK=/^```([a-z]+)?[\s\n]$/,dK=/^~~~([a-z]+)?[\s\n]$/,fK=cr.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:t=>{var e;const{languageClassPrefix:n}=this.options,o=[...((e=t.firstElementChild)===null||e===void 0?void 0:e.classList)||[]].filter(s=>s.startsWith(n)).map(s=>s.replace(n,""))[0];return o||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:t,HTMLAttributes:e}){return["pre",cn(this.options.HTMLAttributes,e),["code",{class:t.attrs.language?this.options.languageClassPrefix+t.attrs.language:null},0]]},addCommands(){return{setCodeBlock:t=>({commands:e})=>e.setNode(this.name,t),toggleCodeBlock:t=>({commands:e})=>e.toggleNode(this.name,"paragraph",t)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:t,$anchor:e}=this.editor.state.selection,n=e.pos===1;return!t||e.parent.type.name!==this.name?!1:n||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Enter:({editor:t})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=t,{selection:n}=e,{$from:r,empty:i}=n;if(!i||r.parent.type!==this.type)return!1;const o=r.parentOffset===r.parent.nodeSize-2,s=r.parent.textContent.endsWith(`
195
+
196
+ `);return!o||!s?!1:t.chain().command(({tr:a})=>(a.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:t})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=t,{selection:n,doc:r}=e,{$from:i,empty:o}=n;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)?t.commands.command(({tr:c})=>(c.setSelection(lt.near(r.resolve(a))),!0)):t.commands.exitCode()}}},addInputRules(){return[Pv({find:uK,type:this.type,getAttributes:t=>({language:t[1]})}),Pv({find:dK,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new Lt({key:new Ut("codeBlockVSCodeHandler"),props:{handlePaste:(t,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const n=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(!n||!o)return!1;const{tr:s,schema:a}=t.state,l=a.text(n.replace(/\r\n?/g,`
197
+ `));return s.replaceSelectionWith(this.type.create({language:o},l)),s.selection.$from.parent.type!==this.type&&s.setSelection($e.near(s.doc.resolve(Math.max(0,s.selection.from-2)))),s.setMeta("paste",!0),t.dispatch(s),!0}}})]}}),hK=cr.create({name:"doc",topNode:!0,content:"block+"});function pK(t={}){return new Lt({view(e){return new mK(e,t)}})}class mK{constructor(e,n){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=n.width)!==null&&r!==void 0?r:1,this.color=n.color===!1?void 0:n.color||"black",this.class=n.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:n})=>this.editorView.dom.removeEventListener(e,n))}update(e,n){this.cursorPos!=null&&n.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),n=!e.parent.inlineContent,r,i=this.editorView.dom,o=i.getBoundingClientRect(),s=o.width/i.offsetWidth,a=o.height/i.offsetHeight;if(n){let f=e.nodeBefore,h=e.nodeAfter;if(f||h){let p=this.editorView.nodeDOM(this.cursorPos-(f?f.nodeSize:0));if(p){let m=p.getBoundingClientRect(),v=f?m.bottom:m.top;f&&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 f=this.editorView.coordsAtPos(this.cursorPos),h=this.width/2*s;r={left:f.left-h,right:f.left+h,top:f.top,bottom:f.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",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n);let c,u;if(!l||l==document.body&&getComputedStyle(l).position=="static")c=-pageXOffset,u=-pageYOffset;else{let f=l.getBoundingClientRect(),h=f.width/l.offsetWidth,p=f.height/l.offsetHeight;c=f.left-l.scrollLeft*h,u=f.top-l.scrollTop*p}this.element.style.left=(r.left-c)/s+"px",this.element.style.top=(r.top-u)/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 n=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),i=r&&r.type.spec.disableDropCursor,o=typeof i=="function"?i(this.editorView,n,e):i;if(n&&!o){let s=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let a=ZC(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 gK=Jt.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[pK(this.options)]}});class dn extends lt{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return dn.valid(r)?new dn(r):lt.near(r)}content(){return Le.empty}eq(e){return e instanceof dn&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new dn(e.resolve(n.pos))}getBookmark(){return new Z1(this.anchor)}static valid(e){let n=e.parent;if(n.inlineContent||!vK(e)||!bK(e))return!1;let r=n.type.spec.allowGapCursor;if(r!=null)return r;let i=n.contentMatchAt(e.index()).defaultType;return i&&i.isTextblock}static findGapCursorFrom(e,n,r=!1){e:for(;;){if(!r&&dn.valid(e))return e;let i=e.pos,o=null;for(let s=e.depth;;s--){let a=e.node(s);if(n>0?e.indexAfter(s)<a.childCount:e.index(s)>0){o=a.child(n>0?e.indexAfter(s):e.index(s)-1);break}else if(s==0)return null;i+=n;let l=e.doc.resolve(i);if(dn.valid(l))return l}for(;;){let s=n>0?o.firstChild:o.lastChild;if(!s){if(o.isAtom&&!o.isText&&!rt.isSelectable(o)){e=e.doc.resolve(i+o.nodeSize*n),r=!1;continue e}break}o=s,i+=n;let a=e.doc.resolve(i);if(dn.valid(a))return a}return null}}}dn.prototype.visible=!1;dn.findFrom=dn.findGapCursorFrom;lt.jsonID("gapcursor",dn);class Z1{constructor(e){this.pos=e}map(e){return new Z1(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return dn.valid(n)?new dn(n):lt.near(n)}}function QA(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function vK(t){for(let e=t.depth;e>=0;e--){let n=t.index(e),r=t.node(e);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(n-1);;i=i.lastChild){if(i.childCount==0&&!i.inlineContent||QA(i.type))return!0;if(i.inlineContent)return!1}}return!0}function bK(t){for(let e=t.depth;e>=0;e--){let n=t.indexAfter(e),r=t.node(e);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(n);;i=i.firstChild){if(i.childCount==0&&!i.inlineContent||QA(i.type))return!0;if(i.inlineContent)return!1}}return!0}function yK(){return new Lt({props:{decorations:_K,createSelectionBetween(t,e,n){return e.pos==n.pos&&dn.valid(n)?new dn(n):null},handleClick:xK,handleKeyDown:wK,handleDOMEvents:{beforeinput:kK}}})}const wK=S1({ArrowLeft:bf("horiz",-1),ArrowRight:bf("horiz",1),ArrowUp:bf("vert",-1),ArrowDown:bf("vert",1)});function bf(t,e){const n=t=="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 $e){if(!o.endOfTextblock(n)||a.depth==0)return!1;l=!1,a=r.doc.resolve(e>0?a.after():a.before())}let c=dn.findGapCursorFrom(a,e,l);return c?(i&&i(r.tr.setSelection(new dn(c))),!0):!1}}function xK(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!dn.valid(r))return!1;let i=t.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&rt.isSelectable(t.state.doc.nodeAt(i.inside))?!1:(t.dispatch(t.state.tr.setSelection(new dn(r))),!0)}function kK(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof dn))return!1;let{$from:n}=t.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);if(!r)return!1;let i=be.empty;for(let s=r.length-1;s>=0;s--)i=be.from(r[s].createAndFill(null,i));let o=t.state.tr.replace(n.pos,n.pos,new Le(i,0,0));return o.setSelection($e.near(o.doc.resolve(n.pos+1))),t.dispatch(o),!1}function _K(t){if(!(t.selection instanceof dn))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",ct.create(t.doc,[Kt.widget(t.selection.head,e,{key:"gapcursor"})])}const CK=Jt.create({name:"gapCursor",addProseMirrorPlugins(){return[yK()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=kt(qe(t,"allowGapCursor",n)))!==null&&e!==void 0?e:null}}}),SK=cr.create({name:"hardBreak",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:t}){return["br",cn(this.options.HTMLAttributes,t)]},renderText(){return`
198
+ `},addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:n,editor:r})=>t.first([()=>t.exitCode(),()=>t.command(()=>{const{selection:i,storedMarks:o}=n;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:u})=>{if(u&&l&&s){const f=l.filter(h=>a.includes(h.type.name));c.ensureMarks(f)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),EK=cr.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(t=>({tag:`h${t}`,attrs:{level:t}}))},renderHTML({node:t,HTMLAttributes:e}){return[`h${this.options.levels.includes(t.attrs.level)?t.attrs.level:this.options.levels[0]}`,cn(this.options.HTMLAttributes,e),0]},addCommands(){return{setHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.setNode(this.name,t):!1,toggleHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.toggleNode(this.name,"paragraph",t):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((t,e)=>({...t,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(t=>Pv({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}});var _p=200,Un=function(){};Un.prototype.append=function(e){return e.length?(e=Un.from(e),!this.length&&e||e.length<_p&&this.leafAppend(e)||this.length<_p&&e.leafPrepend(this)||this.appendInner(e)):this};Un.prototype.prepend=function(e){return e.length?Un.from(e).append(this):this};Un.prototype.appendInner=function(e){return new AK(this,e)};Un.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?Un.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};Un.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};Un.prototype.forEach=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length),n<=r?this.forEachInner(e,n,r,0):this.forEachInvertedInner(e,n,r,0)};Un.prototype.map=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var i=[];return this.forEach(function(o,s){return i.push(e(o,s))},n,r),i};Un.from=function(e){return e instanceof Un?e:e&&e.length?new $A(e):Un.empty};var $A=(function(t){function e(r){t.call(this),this.values=r}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={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<=_p)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=_p)return new e(i.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e})(Un);Un.empty=new $A([]);var AK=(function(t){function e(n,r){t.call(this),this.left=n,this.right=r,this.length=n.length+r.length,this.depth=Math.max(n.depth,r.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.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})(Un);const TK=500;class _i{constructor(e,n){this.items=e,this.eventCount=n}popEvent(e,n){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;n&&(i=this.remapping(r,this.items.length),o=i.maps.length);let s=e.tr,a,l,c=[],u=[];return this.items.forEach((f,h)=>{if(!f.step){i||(i=this.remapping(r,h+1),o=i.maps.length),o--,u.push(f);return}if(i){u.push(new ji(f.map));let p=f.step.map(i.slice(o)),m;p&&s.maybeStep(p).doc&&(m=s.mapping.maps[s.mapping.maps.length-1],c.push(new ji(m,void 0,void 0,c.length+u.length))),o--,m&&i.appendMap(m,o)}else s.maybeStep(f.step);if(f.selection)return a=i?f.selection.map(i.slice(o)):f.selection,l=new _i(this.items.slice(0,r).append(u.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:l,transform:s,selection:a}}addTransform(e,n,r,i){let o=[],s=this.eventCount,a=this.items,l=!i&&a.length?a.get(a.length-1):null;for(let u=0;u<e.steps.length;u++){let f=e.steps[u].invert(e.docs[u]),h=new ji(e.mapping.maps[u],f,n),p;(p=l&&l.merge(h))&&(h=p,u?o.pop():a=a.slice(0,a.length-1)),o.push(h),n&&(s++,n=void 0),i||(l=h)}let c=s-r.depth;return c>DK&&(a=MK(a,c),s-=c),new _i(a.append(o),s)}remapping(e,n){let r=new Au;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,n),r}addMaps(e){return this.eventCount==0?this:new _i(this.items.append(e.map(n=>new ji(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-n),o=e.mapping,s=e.steps.length,a=this.eventCount;this.items.forEach(h=>{h.selection&&a--},i);let l=n;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 ji(m,v,g))}else r.push(new ji(m))},i);let c=[];for(let h=n;h<s;h++)c.push(new ji(o.maps[h]));let u=this.items.slice(0,i).append(c).append(r),f=new _i(u,a);return f.emptyItemCount()>TK&&(f=f.compress(this.items.length-r.length)),f}emptyItemCount(){let e=0;return this.items.forEach(n=>{n.step||e++}),e}compress(e=this.items.length){let n=this.remapping(0,e),r=n.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(n.slice(r)),c=l&&l.getMap();if(r--,c&&n.appendMap(c,r),l){let u=s.selection&&s.selection.map(n.slice(r));u&&o++;let f=new ji(c.invert(),l,u),h,p=i.length-1;(h=i.length&&i[p].merge(f))?i[p]=h:i.push(f)}}else s.map&&r--},this.items.length,0),new _i(Un.from(i.reverse()),o)}}_i.empty=new _i(Un.empty,0);function MK(t,e){let n;return t.forEach((r,i)=>{if(r.selection&&e--==0)return n=i,!1}),t.slice(n)}class ji{constructor(e,n,r,i){this.map=e,this.step=n,this.selection=r,this.mirrorOffset=i}merge(e){if(this.step&&e.step&&!e.selection){let n=e.step.merge(this.step);if(n)return new ji(n.getMap().invert(),n,this.selection)}}}class ns{constructor(e,n,r,i,o){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=i,this.prevComposition=o}}const DK=20;function OK(t,e,n,r){let i=n.getMeta(ka),o;if(i)return i.historyState;n.getMeta(NK)&&(t=new ns(t.done,t.undone,null,0,-1));let s=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(s&&s.getMeta(ka))return s.getMeta(ka).redo?new ns(t.done.addTransform(n,void 0,r,nh(e)),t.undone,Lk(n.mapping.maps),t.prevTime,t.prevComposition):new ns(t.done,t.undone.addTransform(n,void 0,r,nh(e)),null,t.prevTime,t.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(s&&s.getMeta("addToHistory")===!1)){let a=n.getMeta("composition"),l=t.prevTime==0||!s&&t.prevComposition!=a&&(t.prevTime<(n.time||0)-r.newGroupDelay||!IK(n,t.prevRanges)),c=s?jg(t.prevRanges,n.mapping):Lk(n.mapping.maps);return new ns(t.done.addTransform(n,l?e.selection.getBookmark():void 0,r,nh(e)),_i.empty,c,n.time,a??t.prevComposition)}else return(o=n.getMeta("rebased"))?new ns(t.done.rebased(n,o),t.undone.rebased(n,o),jg(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new ns(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),jg(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function IK(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach((r,i)=>{for(let o=0;o<e.length;o+=2)r<=e[o+1]&&i>=e[o]&&(n=!0)}),n}function Lk(t){let e=[];for(let n=t.length-1;n>=0&&e.length==0;n--)t[n].forEach((r,i,o,s)=>e.push(o,s));return e}function jg(t,e){if(!t)return null;let n=[];for(let r=0;r<t.length;r+=2){let i=e.map(t[r],1),o=e.map(t[r+1],-1);i<=o&&n.push(i,o)}return n}function RK(t,e,n){let r=nh(e),i=ka.get(e).spec.config,o=(n?t.undone:t.done).popEvent(e,r);if(!o)return null;let s=o.selection.resolve(o.transform.doc),a=(n?t.done:t.undone).addTransform(o.transform,e.selection.getBookmark(),i,r),l=new ns(n?a:o.remaining,n?o.remaining:a,null,0,-1);return o.transform.setSelection(s).setMeta(ka,{redo:n,historyState:l})}let qg=!1,Fk=null;function nh(t){let e=t.plugins;if(Fk!=e){qg=!1,Fk=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){qg=!0;break}}return qg}const ka=new Ut("history"),NK=new Ut("closeHistory");function PK(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new Lt({key:ka,state:{init(){return new ns(_i.empty,_i.empty,null,0,-1)},apply(e,n,r){return OK(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,i=r=="historyUndo"?tT:r=="historyRedo"?nT:null;return!i||!e.editable?!1:(n.preventDefault(),i(e.state,e.dispatch))}}}})}function eT(t,e){return(n,r)=>{let i=ka.getState(n);if(!i||(t?i.undone:i.done).eventCount==0)return!1;if(r){let o=RK(i,n,t);o&&r(e?o.scrollIntoView():o)}return!0}}const tT=eT(!1,!0),nT=eT(!0,!0),LK=Jt.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>tT(t,e),redo:()=>({state:t,dispatch:e})=>nT(t,e)}},addProseMirrorPlugins(){return[PK(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()}}}),FK=cr.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",cn(this.options.HTMLAttributes,t)]},addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!Ej(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$from:r,$to:i}=n,o=t();return r.parentOffset===0?o.insertContentAt({from:Math.max(r.pos-1,0),to:i.pos},{type:this.name}):ZU(n)?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,u=c.end();if(c.nodeAfter)c.nodeAfter.isTextblock?s.setSelection($e.create(s.doc,c.pos+1)):c.nodeAfter.isBlock?s.setSelection(rt.create(s.doc,c.pos)):s.setSelection($e.create(s.doc,c.pos));else{const f=(l=c.parent.type.contentMatch.defaultType)===null||l===void 0?void 0:l.create();f&&(s.insert(u,f),s.setSelection($e.create(s.doc,u+1)))}s.scrollIntoView()}return!0}).run()}}},addInputRules(){return[MA({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),zK=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,BK=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,HK=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,VK=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,UK=Ri.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:t=>t.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:t=>t.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:t}){return["em",cn(this.options.HTMLAttributes,t),0]},addCommands(){return{setItalic:()=>({commands:t})=>t.setMark(this.name),toggleItalic:()=>({commands:t})=>t.toggleMark(this.name),unsetItalic:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[La({find:zK,type:this.type}),La({find:HK,type:this.type})]},addPasteRules(){return[Ps({find:BK,type:this.type}),Ps({find:VK,type:this.type})]}}),rT=cr.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",cn(this.options.HTMLAttributes,t),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)}}}),jK="listItem",zk="textStyle",Bk=/^(\d+)\.\s$/,qK=cr.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:t=>t.hasAttribute("start")?parseInt(t.getAttribute("start")||"",10):1},type:{default:null,parseHTML:t=>t.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:t}){const{start:e,...n}=t;return e===1?["ol",cn(this.options.HTMLAttributes,n),0]:["ol",cn(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(jK,this.editor.getAttributes(zk)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=Ju({find:Bk,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Ju({find:Bk,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(zk)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),WK=cr.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",cn(this.options.HTMLAttributes,t),0]},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),KK=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,GK=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,ZK=Ri.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["s",cn(this.options.HTMLAttributes,t),0]},addCommands(){return{setStrike:()=>({commands:t})=>t.setMark(this.name),toggleStrike:()=>({commands:t})=>t.toggleMark(this.name),unsetStrike:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[La({find:KK,type:this.type})]},addPasteRules(){return[Ps({find:GK,type:this.type})]}}),YK=cr.create({name:"text",group:"inline"}),JK=Jt.create({name:"starterKit",addExtensions(){const t=[];return this.options.bold!==!1&&t.push(iK.configure(this.options.bold)),this.options.blockquote!==!1&&t.push($W.configure(this.options.blockquote)),this.options.bulletList!==!1&&t.push(sK.configure(this.options.bulletList)),this.options.code!==!1&&t.push(cK.configure(this.options.code)),this.options.codeBlock!==!1&&t.push(fK.configure(this.options.codeBlock)),this.options.document!==!1&&t.push(hK.configure(this.options.document)),this.options.dropcursor!==!1&&t.push(gK.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&t.push(CK.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&t.push(SK.configure(this.options.hardBreak)),this.options.heading!==!1&&t.push(EK.configure(this.options.heading)),this.options.history!==!1&&t.push(LK.configure(this.options.history)),this.options.horizontalRule!==!1&&t.push(FK.configure(this.options.horizontalRule)),this.options.italic!==!1&&t.push(UK.configure(this.options.italic)),this.options.listItem!==!1&&t.push(rT.configure(this.options.listItem)),this.options.orderedList!==!1&&t.push(qK.configure(this.options.orderedList)),this.options.paragraph!==!1&&t.push(WK.configure(this.options.paragraph)),this.options.strike!==!1&&t.push(ZK.configure(this.options.strike)),this.options.text!==!1&&t.push(YK.configure(this.options.text)),t}});function XK(t){const{targetEl:e,platform:n,hasSelection:r,isEditable:i}=t,o=e.closest("a[href]")!=null,s=e.closest("td, th")!=null,a={hasSelection:r,isEditable:i,overLink:o,canMergeCells:!1,canSplitCell:!1};return o?{kind:"link",...a}:s?{kind:"tableCell",...a}:n==="macos"?null:{kind:"editorText",...a}}function QK(t){const e=t.toLowerCase();return e.includes("mac")||e==="darwin"?"macos":e.includes("win")?"windows":"linux"}function iT(t,e,n){const r=t.split(/(?:\r\n?|\n)+/).map(i=>e.nodes.paragraph.create(null,i?e.text(i,n):void 0));return Le.maxOpen(be.fromArray(r))}const $K=["http://","https://","mailto:","ftp://","//"];function oT(t){const e=t.toLowerCase();return $K.some(n=>e.startsWith(n))}function sT(t){if(!t)return null;const e=t.trim();if(!e)return null;if(oT(e)||e.startsWith("#"))return e;const n=e.indexOf(":");if(n===-1)return e;const r=Math.min(...["/","#","?"].map(i=>e.indexOf(i)).filter(i=>i!==-1));return Number.isFinite(r)&&r<n?e:null}function Jr(t){return t.chain().focus()}async function eG(t,e){const{editor:n}=e;switch(t){case"ctx:undo":Jr(n).undo().run();return;case"ctx:redo":Jr(n).redo().run();return;case"ctx:pastePlain":{const r=await e.readClipboardText();if(!r)return;const{state:i,view:o}=n,s=iT(r,i.schema,i.selection.$from.marks());o.dispatch(i.tr.replaceSelection(s).scrollIntoView()),o.focus();return}case"ctx:table:insertRowAbove":Jr(n).addRowBefore().run();return;case"ctx:table:insertRowBelow":Jr(n).addRowAfter().run();return;case"ctx:table:insertColLeft":Jr(n).addColumnBefore().run();return;case"ctx:table:insertColRight":Jr(n).addColumnAfter().run();return;case"ctx:table:deleteRow":Jr(n).deleteRow().run();return;case"ctx:table:deleteCol":Jr(n).deleteColumn().run();return;case"ctx:table:mergeCells":Jr(n).mergeCells().run();return;case"ctx:table:splitCell":Jr(n).splitCell().run();return;case"ctx:table:deleteTable":Jr(n).deleteTable().run();return;case"ctx:link:open":{const r=e.getLinkHref();r&&e.openHref(r);return}case"ctx:link:copy":{const r=e.getLinkHref();if(!r)return;const i=sT(r);i&&await e.writeClipboardText(i);return}case"ctx:link:remove":Jr(n).extendMarkRange("link").unsetLink().run();return;default:return}}const tG=["ctx:undo","ctx:redo","ctx:pastePlain","ctx:table:insertRowAbove","ctx:table:insertRowBelow","ctx:table:insertColLeft","ctx:table:insertColRight","ctx:table:deleteRow","ctx:table:deleteCol","ctx:table:mergeCells","ctx:table:splitCell","ctx:table:deleteTable","ctx:link:open","ctx:link:copy","ctx:link:remove"],nG=new Set(tG);function rG(t){return typeof t=="string"&&nG.has(t)}async function iG(){try{return await navigator.clipboard.readText()}catch{return null}}async function oG(t){try{await navigator.clipboard.writeText(t)}catch{}}function sG(t,e){if(!Pt())return()=>{};const n=t.view.dom,r=e.platform??QK(typeof navigator<"u"?navigator.platform||navigator.userAgent:"");let i=null;const o=async a=>{var f;const l=a.target;if(!l)return;const c=XK({targetEl:l,platform:r,hasSelection:!1,isEditable:t.isEditable});if(!c)return;a.preventDefault();const u=t.view.posAtCoords({left:a.clientX,top:a.clientY});if(u){const{from:h,to:p}=t.state.selection;(u.pos<h||u.pos>p)&&t.commands.setTextSelection(u.pos)}if(c.hasSelection=!t.state.selection.empty,i=((f=l.closest("a[href]"))==null?void 0:f.getAttribute("href"))??null,c.kind==="tableCell"){const h=t.can();c.canMergeCells=h.mergeCells(),c.canSplitCell=h.splitCell()}t.view.focus();try{await(await Ta())("show_context_menu",{req:c})}catch{}};n.addEventListener("contextmenu",o);const s=yn(async()=>{const{listen:a}=await import("./event-CNdo2oXa.js");return{listen:a}},__vite__mapDeps([2,1])).then(({listen:a})=>a("context-menu-action",l=>{var u;const c=(u=l.payload)==null?void 0:u.id;rG(c)&&eG(c,{editor:t,openHref:e.openHref,getLinkHref:()=>i,readClipboardText:iG,writeClipboardText:oG})}));return s.catch(()=>{}),()=>{n.removeEventListener("contextmenu",o),s.then(a=>a()).catch(()=>{})}}const Kc=new Ut("tandemAnnotations"),Hk={comment:!0,highlight:!0,note:!0};function aT(){try{const t=localStorage.getItem(nC);if(!t)return{...Hk};const e=JSON.parse(t);return{comment:e.comment!==!1,highlight:e.highlight!==!1,note:e.note!==!1}}catch(t){return console.warn("[annotation] localStorage unavailable",t),{...Hk}}}function Vk(){return mv(Pb(),"family")}function lT(t){return t==="highlight"?"highlight":t==="note"||t==="flag"?"note":"comment"}function Wg(t,e,n,r,i){const o=[],s=t.content.size;return e.forEach(a=>{const l=Ra(a,p=>{console.warn("[sanitize]",p)});if(l.status!=="pending"||!r[l.type]||!l.range&&!l.relRange)return;const c=$l(l,t,n);if(!c)return;l.relRange&&c.method==="flat"&&console.warn("[annotation] relRange-equipped annotation %s fell back to flat offsets",l.id);const{from:u,to:f}=c;if(u>=f||u<0||f>s)return;let h={};switch(l.type){case"highlight":{const p=Y_(l.color),m=_u[p];h={class:`tandem-highlight tandem-highlight--${p}`,style:`background: ${m}; border-radius: var(--tandem-r-1); padding: 1px 0;`,"data-annotation-id":l.id,"data-annotation-type":l.type,"data-annotation-author":l.author,"aria-label":`Highlight annotation (${p})`};break}case"comment":l.suggestedText!==void 0?h={class:"tandem-suggestion",style:"background: var(--tandem-suggestion-bg); text-decoration: underline wavy var(--tandem-suggestion); text-underline-offset: 3px;","data-annotation-id":l.id,"data-annotation-type":l.type,"data-annotation-author":l.author,"aria-label":"Replacement annotation"}:l.author==="claude"?h={class:"tandem-comment tandem-comment--claude",style:"border-bottom: 2px solid var(--tandem-author-claude); padding-bottom: 1px;","data-annotation-id":l.id,"data-annotation-type":l.type,"data-annotation-author":l.author,"aria-label":`${i} comment annotation`}:h={class:"tandem-comment",style:"border-bottom: 2px dashed var(--tandem-author-user); padding-bottom: 1px;","data-annotation-id":l.id,"data-annotation-type":l.type,"data-annotation-author":l.author,"aria-label":"Comment annotation"};break;case"note":h={class:"tandem-note",style:"border-bottom: 2px dotted var(--tandem-fg-muted); padding-bottom: 1px;","data-annotation-id":l.id,"data-annotation-type":l.type,"data-annotation-author":l.author,"aria-label":"Note annotation"};break;default:{console.warn("[annotation] Unhandled annotation type in buildDecorations, skipping");return}}try{o.push(Kt.inline(u,f,h))}catch(p){if(!(p instanceof RangeError))throw p;console.debug("[annotation] RangeError for %s (from=%d, to=%d), skipping",l.id,u,f)}}),ct.create(t,o)}const aG=Jt.create({name:"tandemAnnotations",addOptions(){return{ydoc:null}},addProseMirrorPlugins(){const t=this.options.ydoc;if(!t)return[];const e=t.getMap(Ti);let n=aT(),r=Vk();function i(){for(const a of e.values()){const l=a;if(l&&l.status==="pending"&&n[lT(l.type)])return!0}return!1}let o=i(),s=!1;return[new Lt({key:Kc,state:{init(a,l){return o?Wg(l.doc,e,t,n,r):ct.empty},apply(a,l,c,u){const f=a.getMeta(Kc);if(f&&typeof f=="object"&&f.type==="toggle-decorations"&&(n=f.visible,o=i(),s=!1),f)return r=Vk(),o?Wg(u.doc,e,t,n,r):ct.empty;if(!o)return ct.empty;if(a.docChanged){if(!s&&l===ct.empty&&o){const h=Wg(u.doc,e,t,n,r);return h!==ct.empty&&(s=!0),h}return l.map(a.mapping,a.doc)}return l}},props:{decorations(a){return Kc.getState(a)}},view(a){let l=null,c=!1;function u(){l===null&&(l=requestAnimationFrame(()=>{l=null,c=!0;const p=a.state.tr.setMeta(Kc,!0);a.dispatch(p)}))}const f=()=>{o=i(),s=!1,u()};e.observe(f);const h=setTimeout(()=>{!c&&l===null&&e.size>0&&f()},500);return{destroy(){clearTimeout(h),l!==null&&cancelAnimationFrame(l),e.unobserve(f)}}}})]}}),Ic=new Ut("tandemAnnotationPing"),lG=700,cG=500,uG="tandem-annotation-ping";function dG(t,e){return!(!e.isLive||e.alreadySeen||!t||t.status!=="pending"||!e.visible[lT(t.type)])}function fG(){try{if(Pb().reduceMotion)return!0}catch{}return typeof matchMedia<"u"&&matchMedia("(prefers-reduced-motion: reduce)").matches}const hG=Jt.create({name:"tandemAnnotationPing",addOptions(){return{ydoc:null}},addProseMirrorPlugins(){const t=this.options.ydoc;if(!t)return[];const e=t.getMap(Ti),n=new Set;let r=!1;return[new Lt({key:Ic,state:{init:()=>ct.empty,apply(i,o){let s=o.map(i.mapping,i.doc);const a=i.getMeta(Ic);if((a==null?void 0:a.type)==="add")s=s.add(i.doc,[a.deco]);else if((a==null?void 0:a.type)==="remove"){const l=s.find(void 0,void 0,c=>c.pingId===a.id);l.length&&(s=s.remove(l))}return s}},props:{decorations(i){return Ic.getState(i)}},view(i){const o=new Map;let s=!1;function a(h,p){if(fG())return;const m=$l(p,i.state.doc,t);if(m)try{const v=i.state.doc.resolve(m.from),g=v.depth;if(g<1)return;const b=v.before(g),_=v.after(g),k=Kt.node(b,_,{class:uG},{pingId:h});i.dispatch(i.state.tr.setMeta(Ic,{type:"add",deco:k}));const C=setTimeout(()=>{o.delete(h),!s&&i.dispatch(i.state.tr.setMeta(Ic,{type:"remove",id:h}))},lG);o.set(h,C)}catch(v){if(!(v instanceof RangeError))throw v}}let l;const c=()=>{for(const h of e.keys())n.add(h);r=!0},u=()=>{clearTimeout(l),l=setTimeout(c,cG)},f=h=>{r||u();const p=aT();for(const m of h.keysChanged){const v=e.get(m),g=dG(v,{isLive:r,alreadySeen:n.has(m),visible:p});n.add(m),g&&v&&a(m,v)}};return e.observe(f),u(),{destroy(){s=!0,clearTimeout(l);for(const h of o.values())clearTimeout(h);o.clear(),e.unobserve(f)}}}})]}}),ol=new Ut("tandemAuthorship"),pG=new Set(["paragraph","heading"]);function mG(t,e,n){if(t.relRange){const r=K3(n,e,t.relRange);if(r&&r.from<r.to)return r}if(t.range){console.warn("[authorship] Falling back to flat offsets for range",t.id);const r=Rs(e,t.range.from),i=Rs(e,t.range.to);if(r<i)return{from:r,to:i}}return null}function Kg(t,e,n,r){if(!r)return ct.empty;const i=[],o=t.content.size,s=[];return e.forEach(a=>{const l=a;if(!l.author||!l.range||l.author!=="user"&&l.author!=="claude")return;const c=mG(l,t,n);if(!c)return;const{from:u,to:f}=c;if(!(u>=f||u<0||f>o)){try{i.push(Kt.inline(u,f,{"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:u,to:f})}}),t.descendants((a,l)=>{if(!pG.has(a.type.name))return;const c=l,u=l+a.nodeSize;let f=0,h=0;for(const m of s){const v=Math.max(m.from,c),g=Math.min(m.to,u);if(g<=v)continue;const b=g-v;m.author==="user"?f+=b:h+=b}if(f===0&&h===0||a.content.size===0)return;const p=f>=h?"user":"claude";try{i.push(Kt.node(c,u,{"data-tandem-author-block":p}))}catch(m){if(!(m instanceof RangeError))throw m;console.warn("[authorship] node Decoration RangeError at offset",l,m)}}),ct.create(t,i)}const gG=Jt.create({name:"tandemAuthorship",addOptions(){return{ydoc:null}},addProseMirrorPlugins(){const t=this.options.ydoc;if(!t)return[];const e=t.getMap(ew);let n=!1;try{n=localStorage.getItem(tC)==="true"}catch(r){console.warn("[authorship] localStorage unavailable",r)}return[new Lt({key:ol,state:{init(r,i){return{visible:n,decorations:Kg(i.doc,e,t,n)}},apply(r,i,o,s){const a=r.getMeta(ol);if((a==null?void 0:a.type)==="toggle"){const l=a.visible;return{visible:l,decorations:Kg(s.doc,e,t,l)}}return(a==null?void 0:a.type)==="rebuild"?{visible:i.visible,decorations:Kg(s.doc,e,t,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=ol.getState(r))==null?void 0:i.decorations)??ct.empty}},view(r){const i=()=>{const s=r.state.tr.setMeta(ol,{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:t}){const e=this.options.ydoc;if(!e||t.getMeta("y-sync$")||t.getMeta(ol)||!t.docChanged)return;const n=e.getMap(ew),r=t.doc;t.steps.forEach(i=>{i.getMap().forEach((s,a,l,c)=>{if(c-l-(a-s)>0)try{const f=ii(r,Mn(l)),h=ii(r,Mn(c));if(h<=f)return;const p=GM("user"),m={id:p,author:"user",range:{from:f,to:h},timestamp:Date.now()};n.set(p,m)}catch(f){console.warn("[authorship] Position conversion failed during user attribution",f)}})})}}),yf=new Ut("tandemAwareness");function Uk(t,e){if(!e)return ct.empty;const n=[],{focusParagraph:r,focusOffset:i,active:o}=e;if(r!==null&&r>=0){let s=0;t.forEach((a,l)=>{s===r&&n.push(Kt.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=Rs(t,Ff(i)),a=o===!1?" tandem-claude-cursor-idle":"";n.push(Kt.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="AI",l.appendChild(c),l}))}catch(s){console.warn("[awareness] cursor decoration failed, falling back to gutter-only:",s)}return n.length===0?ct.empty:ct.create(t,n)}const vG=Jt.create({name:"tandemAwareness",addOptions(){return{ydoc:null}},addProseMirrorPlugins(){const t=this.options.ydoc;if(!t)return[];const e=t.getMap($_),n=t.getMap(z0);return[new Lt({key:yf,state:{init(r,i){const o=e.get(B0);return Uk(i.doc,o??null)},apply(r,i,o,s){if(r.getMeta(yf)){const a=e.get(B0);return Uk(s.doc,a??null)}return r.docChanged?i.map(r.mapping,r.doc):i}},props:{decorations(r){return yf.getState(r)}},view(r){const i=()=>{const o=r.state.tr.setMeta(yf,!0);r.dispatch(o)};return e.observe(i),{destroy(){e.unobserve(i)}}}}),new Lt({key:new Ut("tandemUserAwareness"),view(){let r=null,i=null,o=null,s=!1,a=-1;return{update(l,c){const{state:u}=l;if(!u.selection.eq(c.selection)){const f=G3(u.doc,{from:Mn(u.selection.from),to:Mn(u.selection.to)});if(u.selection.from===u.selection.to)o&&(clearTimeout(o),o=null),n.set(tw,{...f,timestamp:Date.now()});else{const h=u.doc.textBetween(u.selection.from,u.selection.to,`
199
+ `),p=h.length>200?h.slice(0,197)+"...":h;o&&clearTimeout(o),o=setTimeout(()=>{o=null,n.set(tw,{...f,selectedText:p,timestamp:Date.now()})},150)}}u.doc!==c.doc&&(a=u.selection.from,s=!0,i||(i=setTimeout(()=>{i=null,s&&n.set(nw,{isTyping:!0,cursor:a,lastEdit:Date.now()})},200)),r&&clearTimeout(r),r=setTimeout(()=>{s=!1,n.set(nw,{isTyping:!1,cursor:l.state.selection.from,lastEdit:Date.now()})},dD))},destroy(){r&&clearTimeout(r),i&&clearTimeout(i),o&&clearTimeout(o)}}}})]}}),qi=new Ut("tandemFindReplace"),cT={query:"",caseSensitive:!1,wholeWord:!1,regexMode:!1,matches:[],activeIndex:-1,decoSet:ct.empty};function bG(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function yG(t){if(!t.query)return null;try{const e=t.regexMode?t.query:bG(t.query),n=t.caseSensitive?"g":"gi",r=t.wholeWord?`\\b${e}\\b`:e;return new RegExp(r,n)}catch{return null}}function uT(t,e){const n=yG(e);if(!n)return[];const r=[];return t.descendants((i,o)=>{if(!i.isTextblock)return;const s=i.textContent;for(const a of s.matchAll(n)){const l=a.index??0;r.push({from:o+1+l,to:o+1+l+a[0].length})}}),r}function pu(t,e,n){if(e.length===0)return ct.empty;const r=[];for(let i=0;i<e.length;i++){const{from:o,to:s}=e[i];try{r.push(Kt.inline(o,s,{class:i===n?"tandem-find-active":"tandem-find-match"}))}catch{}}return ct.create(t,r)}function tb(t,e){if(t.length===0)return-1;for(let n=0;n<t.length;n++)if(t[n].from<=e&&e<=t[n].to)return n;for(let n=0;n<t.length;n++)if(t[n].from>e)return n;return 0}function wG(t,e,n){if(t.type==="close")return cT;if(t.type==="find"){const i=t.opts,o=uT(n.doc,i),s=n.selection.from,a=tb(o,s);return{...i,matches:o,activeIndex:a,decoSet:pu(n.doc,o,a)}}if(t.type==="next"){const i=e.matches.length===0?-1:(e.activeIndex+1)%e.matches.length;return{...e,activeIndex:i,decoSet:pu(n.doc,e.matches,i)}}if(t.type==="prev"){const i=e.matches.length===0?-1:(e.activeIndex-1+e.matches.length)%e.matches.length;return{...e,activeIndex:i,decoSet:pu(n.doc,e.matches,i)}}return t}const xG=Jt.create({name:"tandemFindReplace",addProseMirrorPlugins(){return[new Lt({key:qi,state:{init:()=>cT,apply(t,e,n,r){const i=t.getMeta(qi);if(i)return wG(i,e,r);if(!e.query)return e;if(t.docChanged){const a=uT(r.doc,e),l=r.selection.from,c=tb(a,l);return{...e,matches:a,activeIndex:c,decoSet:pu(r.doc,a,c)}}const o=r.selection.from,s=tb(e.matches,o);return s===e.activeIndex?e:{...e,activeIndex:s,decoSet:pu(r.doc,e.matches,s)}}},props:{decorations(t){var e;return((e=qi.getState(t))==null?void 0:e.decoSet)??ct.empty}}})]},addCommands(){return{find:t=>({dispatch:e,tr:n})=>(e&&e(n.setMeta(qi,{type:"find",opts:t})),!0),findNext:()=>({dispatch:t,tr:e})=>(t&&t(e.setMeta(qi,{type:"next"})),!0),findPrev:()=>({dispatch:t,tr:e})=>(t&&t(e.setMeta(qi,{type:"prev"})),!0),findClose:()=>({dispatch:t,tr:e})=>(t&&t(e.setMeta(qi,{type:"close"})),!0)}},addKeyboardShortcuts(){return{Escape:({editor:t})=>{const e=qi.getState(t.state);return e!=null&&e.query?(t.commands.findClose(),!0):!1}}}});function _l(t){return qi.getState(t)}function kG(t,e){const n=_l(t.state);if(!n||n.activeIndex<0||n.matches.length===0)return!1;const{from:r,to:i}=n.matches[n.activeIndex],o=t.state.tr.insertText(e,r,i).setMeta(qi,{type:"next"});return t.dispatch(o),!0}async function _G(t,e,n){let i=0,o=!1;for(let s=0;s<50;s++){const a=_l(t.state);if(!(a!=null&&a.query)||a.matches.length===0)break;const l=a.matches.slice(0,100);try{let c=t.state.tr;for(let u=l.length-1;u>=0;u--){const{from:f,to:h}=l[u];c=c.insertText(e,f,h)}t.dispatch(c),i+=l.length,n==null||n(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 Zs=new Ut("tandemHeadingCollapse"),CG="tandem:headingCollapse:";function dT(t){return!t||t.startsWith("upload://")?null:CG+t}function jk(t){const e=dT(t);if(!e)return new Set;try{const n=window.localStorage.getItem(e);if(!n)return new Set;const r=JSON.parse(n);return Array.isArray(r)?new Set(r.filter(i=>typeof i=="string")):new Set}catch{return new Set}}function Cp(t,e){const n=dT(t);if(n)try{e.size===0?window.localStorage.removeItem(n):window.localStorage.setItem(n,JSON.stringify(Array.from(e)))}catch{}}function SG(t){return t.trim().toLowerCase().replace(/\s+/g," ")}function Gg(t){const e=[],n=new Map;return t.descendants((r,i,o)=>{if(r.type.name!=="heading")return!0;if(o!==t)return!1;const s=r.attrs.level??1,a=SG(r.textContent),l=`${s}::${a}`,c=n.get(l)??0;n.set(l,c+1);const u=`${l}::${c}`;return e.push({pos:i,level:s,hash:u}),!1}),e}function EG(t,e,n,r){if(n.size===0)return n;const i=new Set(e.map(a=>a.hash));if(t.length===e.length){const a=[];for(let h=0;h<t.length;h++)t[h].hash!==e[h].hash&&a.push(h);if(a.length!==1)return n;const l=a[0],c=t[l].hash,u=e[l].hash;if(!n.has(c))return n;const f=new Set(n);return f.delete(c),f.add(u),Cp(r,f),f}if(e.length>t.length||e.length===0)return n;let o=!1;const s=new Set;for(const a of n)i.has(a)?s.add(a):o=!0;return o?(Cp(r,s),s):n}function AG(t,e,n){return Kt.widget(t+1,r=>{const i=document.createElement("button");return i.type="button",i.className="tandem-heading-chevron",i.dataset.testid="heading-chevron",i.dataset.headingHash=e,i.dataset.collapsed=String(n),i.setAttribute("aria-label",n?"Expand section":"Collapse section"),i.setAttribute("aria-expanded",String(!n)),i.contentEditable="false",i.textContent=n?"▶":"▼",i.addEventListener("mousedown",o=>{o.preventDefault()}),i.addEventListener("click",o=>{o.stopPropagation(),o.preventDefault();const s=r.state.tr.setMeta(Zs,{type:"toggle",hash:e});r.dispatch(s)}),i},{side:-1,ignoreSelection:!0,stopEvent:()=>!0,key:`chevron:${e}:${n?"c":"e"}`})}function TG(t,e,n){const r=e[n];let i=t.content.size;for(let s=n+1;s<e.length;s++)if(e[s].level<=r.level){i=e[s].pos;break}const o=[];return t.forEach((s,a)=>{if(a>r.pos&&a<i){const l=a,c=a+s.nodeSize;o.push(Kt.node(l,c,{class:"tandem-heading-collapsed-hidden",style:"display: none;"}))}}),o}function wf(t,e,n){const r=[];for(let i=0;i<e.length;i++){const o=e[i],s=n.has(o.hash);try{r.push(AG(o.pos,o.hash,s)),s&&r.push(...TG(t,e,i))}catch{}}return r.length===0?ct.empty:ct.create(t,r)}const MG=Jt.create({name:"tandemHeadingCollapse",addOptions(){return{filePath:null}},addProseMirrorPlugins(){const t=this.options.filePath;return[new Lt({key:Zs,state:{init(e,n){const r=jk(t),i=Gg(n.doc);return{collapsed:r,headings:i,decoSet:wf(n.doc,i,r),hasSeenContent:i.length>0}},apply(e,n,r,i){const o=e.getMeta(Zs);if((o==null?void 0:o.type)==="toggle"){const c=new Set(n.collapsed);return c.has(o.hash)?c.delete(o.hash):c.add(o.hash),Cp(t,c),{collapsed:c,headings:n.headings,decoSet:wf(i.doc,n.headings,c),hasSeenContent:n.hasSeenContent}}if((o==null?void 0:o.type)==="rehydrate"){const c=Gg(i.doc),u=jk(t),f=new Set(c.map(p=>p.hash)),h=new Set;for(const p of u)f.has(p)&&h.add(p);return h.size!==u.size&&Cp(t,h),{collapsed:h,headings:c,decoSet:wf(i.doc,c,h),hasSeenContent:!0}}if(!e.docChanged)return n;const s=Gg(i.doc),a=n.hasSeenContent||s.length>0;let l=n.collapsed;return n.hasSeenContent&&(l=EG(n.headings,s,n.collapsed,t)),{collapsed:l,headings:s,decoSet:wf(i.doc,s,l),hasSeenContent:a}}},view(e){let n=!1,r=null;function i(){n||r!==null||(r=requestAnimationFrame(()=>{if(r=null,n)return;const o=Zs.getState(e.state);if(!o||o.headings.length===0)return;n=!0;const s=e.state.tr.setMeta(Zs,{type:"rehydrate"}).setMeta("addToHistory",!1);e.dispatch(s)}))}return i(),{update(o){if(n)return;const s=Zs.getState(o.state);!s||s.headings.length===0||i()},destroy(){r!==null&&cancelAnimationFrame(r)}}},props:{decorations(e){var n;return((n=Zs.getState(e))==null?void 0:n.decoSet)??ct.empty}}})]}}),DG=new Ut("listItemCheckbox"),OG=/^\[([ xX])\]\s$/,IG=rT.extend({addAttributes(){var t;return{...(t=this.parent)==null?void 0:t.call(this),checked:{default:null,keepOnSplit:!1,parseHTML:e=>{const n=e.getAttribute("data-checked");return n==="true"?!0:n==="false"?!1:null},renderHTML:e=>e.checked===null||e.checked===void 0?{}:{"data-checked":String(e.checked)}}}},addInputRules(){const t=this.type;return[new Ld({find:OG,handler:({state:e,range:n,match:r})=>{const i=r[1]!==" ",o=e.doc.resolve(n.from);let s=-1,a={};for(let c=o.depth;c>0;c--){const u=o.node(c);if(u.type===t){s=o.before(c),a=u.attrs;break}}if(s<0)return null;const l=e.tr;l.delete(n.from,n.to),l.setNodeMarkup(s,void 0,{...a,checked:i})}})]},addProseMirrorPlugins(){var n;const t=this.type;return[...((n=this.parent)==null?void 0:n.call(this))??[],new Lt({key:DG,props:{decorations:r=>{const i=[];return r.doc.descendants((o,s)=>{if(o.type!==t||o.attrs.checked===null||o.attrs.checked===void 0)return;const a=o.attrs.checked===!0;i.push(Kt.widget(s+1,(l,c)=>RG(l,c,a,t),{side:-1,key:`tandem-checkbox-${s}:${a}`,stopEvent:()=>!0,ignoreSelection:!0}))}),ct.create(r.doc,i)}}})]}});function RG(t,e,n,r){const i=document.createElement("label");i.className="tandem-list-checkbox",i.contentEditable="false";const o=document.createElement("input");return o.type="checkbox",o.checked=n,o.setAttribute("aria-label",n?"Checked task":"Unchecked task"),o.addEventListener("mousedown",s=>s.preventDefault()),o.addEventListener("change",()=>{if(!t.editable){o.checked=n;return}const s=e();if(s==null)return;const a=s-1,l=t.state.doc.resolve(a).nodeAfter;!l||l.type!==r||t.dispatch(t.state.tr.setNodeMarkup(a,void 0,{...l.attrs,checked:!l.attrs.checked}))}),i.appendChild(o),i}const NG=Jt.create({name:"markdownHtml",addGlobalAttributes(){return[{types:["paragraph"],attributes:{markdownHtml:{default:null,parseHTML:()=>null,renderHTML:()=>({})},markdownRaw:{default:null,parseHTML:()=>null,renderHTML:t=>t.markdownRaw?{"data-markdown-raw":""}:{}}}}]}}),PG=Ri.create({name:"rawMarkdown",parseHTML(){return[]},renderHTML(){return["span",{class:"tandem-raw-md"},0]}}),LG=new Ut("tandemSelectionDecoration"),FG=Jt.create({name:"tandemSelectionDecoration",addProseMirrorPlugins(){return[new Lt({key:LG,props:{decorations(t){const{selection:e}=t;if(!(e instanceof $e))return ct.empty;const{from:n,to:r}=e;return n===r?ct.empty:ct.create(t.doc,[Kt.inline(n,r,{class:"tandem-selection-blurred"})])}}})]}});function yo(t){return t.chain().focus()}const qk={tag:"path",attrs:{d:"M6 4.5h7M6 8h7M6 11.5h7"}},Wk=[{id:"heading-1",label:"Heading 1",keywords:["h1","heading","title"],hint:"h1",icon:{kind:"glyph",glyph:"H¹"},run:t=>yo(t).toggleHeading({level:1}).run()},{id:"heading-2",label:"Heading 2",keywords:["h2","heading","subtitle"],hint:"h2",icon:{kind:"glyph",glyph:"H²"},run:t=>yo(t).toggleHeading({level:2}).run()},{id:"heading-3",label:"Heading 3",keywords:["h3","heading","subheading"],hint:"h3",icon:{kind:"glyph",glyph:"H³"},run:t=>yo(t).toggleHeading({level:3}).run()},{id:"bullet-list",label:"Bullet list",keywords:["bullet","ul","list"],hint:"ul",icon:{kind:"svg",els:[{tag:"circle",attrs:{cx:"3",cy:"4.5",r:"0.7",fill:"currentColor",stroke:"none"}},{tag:"circle",attrs:{cx:"3",cy:"8",r:"0.7",fill:"currentColor",stroke:"none"}},{tag:"circle",attrs:{cx:"3",cy:"11.5",r:"0.7",fill:"currentColor",stroke:"none"}},qk]},run:t=>yo(t).toggleBulletList().run()},{id:"numbered-list",label:"Numbered list",keywords:["numbered","ordered","ol","list"],hint:"ol",icon:{kind:"svg",els:[{tag:"path",attrs:{d:"M2 3.5h1V6M2 6h2M2 9.5c0-.5.5-1 1-1s1 .5 1 1c0 1-2 1.3-2 2.5h2"}},qk]},run:t=>yo(t).toggleOrderedList().run()},{id:"task-list",label:"Task list",keywords:["task","todo","checkbox","check","checklist"],hint:"todo",icon:{kind:"svg",els:[{tag:"path",attrs:{d:"M3 3h10v10H3z"}},{tag:"path",attrs:{d:"M5.5 8l2 2 3.5-4"}}]},run:t=>yo(t).toggleBulletList().updateAttributes("listItem",{checked:!1}).run()},{id:"quote",label:"Quote",keywords:["blockquote","quote"],hint:"q",icon:{kind:"svg",els:[{tag:"path",attrs:{d:"M3 6c0-1.5 1-2.5 2-2.5"}},{tag:"path",attrs:{d:"M3 6v3h3V6z"}},{tag:"path",attrs:{d:"M9 6c0-1.5 1-2.5 2-2.5"}},{tag:"path",attrs:{d:"M9 6v3h3V6z"}}]},run:t=>yo(t).toggleBlockquote().run()},{id:"code-block",label:"Code block",keywords:["code","pre","snippet"],hint:"code",icon:{kind:"svg",els:[{tag:"path",attrs:{d:"M5 4l-3 4 3 4"}},{tag:"path",attrs:{d:"M11 4l3 4-3 4"}}]},run:t=>yo(t).toggleCodeBlock().run()},{id:"horizontal-rule",label:"Horizontal rule",keywords:["hr","divider","rule","separator"],hint:"hr",icon:{kind:"glyph",glyph:"—"},run:t=>yo(t).setHorizontalRule().run()}];function zG(t){const e=/(?:^|\s)\/([A-Za-z0-9 -]*)$/.exec(t);if(!e)return null;const n=e[1]??"";return{fromOffset:t.length-n.length-1,query:n}}function Dm(t){const e=t.trim().toLowerCase();return e?Wk.filter(n=>[n.label,...n.keywords].join(" ").toLowerCase().includes(e)):Wk}const BG=["popup-annotation-input","popup-note-submit","popup-comment-submit","popup-highlight-yellow","popup-highlight-green","popup-highlight-blue","popup-highlight-pink"];function HG(t){const e=document.querySelector(`[data-testid="${t}"]`);return e?document.activeElement===e:!1}function VG(t){for(const e of t)if(document.querySelector(`[data-testid="${e}"]`))return!0;return!1}function UG(){return typeof document>"u"?!1:!!(HG("find-input")||document.querySelector('[data-testid="command-palette"]')||VG(BG))}const Kk="http://www.w3.org/2000/svg",ko=new Ut("tandemSlashCommand");function fT(t){return`${t.from}:${t.to}:${t.query}`}function jG(t){if(!t.docChanged||t.getMeta("y-sync$"))return!1;const e=t.getMeta("uiEvent");if(e==="paste"||e==="drop"||t.getMeta("paste"))return!1;const n=t.selection.from;let r=!1;return t.mapping.maps.forEach((i,o)=>{i.forEach((s,a,l,c)=>{if(c<=l)return;t.mapping.slice(o+1).map(c,-1)===n&&(r=!0)})}),r}function qG(t,e=0){if(UG())return null;const{selection:n}=t;if(!n.empty)return null;const r=n.$from,i=r.parent.textBetween(0,r.parentOffset,`
200
+ `,`
201
+ `),o=zG(i);if(!o)return null;const s=r.start()+o.fromOffset,a=r.pos,l=Dm(o.query);return l.length===0?null:{from:s,to:a,query:o.query,selectedIndex:Math.min(e,l.length-1)}}function WG(t,e){const n=t.getMeta(ko);return n?n.type==="close"?{active:null,dismissedKey:e.active?fT(e.active):e.dismissedKey}:n.type==="select"&&e.active?{...e,active:{...e.active,selectedIndex:n.selectedIndex??e.active.selectedIndex}}:e:null}function hT(t){for(;t.firstChild;)t.removeChild(t.firstChild)}function KG(){const t=document.createElement("div");t.className="tandem-slash-menu__hint";const e=[["↑↓","navigate"],["↵","insert"],["esc","close"]];for(const[n,r]of e){const i=document.createElement("span"),o=document.createElement("kbd");o.textContent=n,i.appendChild(o),i.appendChild(document.createTextNode(` ${r}`)),t.appendChild(i)}return t}function GG(t){const e=document.createElement("span");if(e.className="tandem-slash-menu__icon",e.setAttribute("aria-hidden","true"),t.kind==="glyph")return e.textContent=t.glyph,e;const n=document.createElementNS(Kk,"svg");n.setAttribute("viewBox","0 0 16 16"),n.setAttribute("fill","none"),n.setAttribute("stroke","currentColor"),n.setAttribute("stroke-width","1.6"),n.setAttribute("stroke-linecap","round"),n.setAttribute("stroke-linejoin","round");for(const r of t.els){const i=document.createElementNS(Kk,r.tag);for(const[o,s]of Object.entries(r.attrs))i.setAttribute(o,s);n.appendChild(i)}return e.appendChild(n),e}function ZG(t,e,n,r,i){const o=Dm(e.query);hT(t),t.className="tandem-floating-pill tandem-slash-menu";const s=document.createElement("div");s.setAttribute("role","listbox"),s.setAttribute("aria-label","Slash commands"),o.forEach((l,c)=>{const u=document.createElement("button");u.type="button",u.role="option",u.id=`slash-command-${l.id}`,u.className="tandem-slash-menu__item",u.setAttribute("aria-selected",String(c===e.selectedIndex)),u.setAttribute("aria-label",l.label),u.dataset.commandId=l.id,u.appendChild(GG(l.icon));const f=document.createElement("span");f.className="tandem-slash-menu__label",f.textContent=l.label,u.appendChild(f);const h=document.createElement("span");h.className="tandem-slash-menu__shortcut",h.setAttribute("aria-hidden","true"),h.textContent=l.hint,u.appendChild(h),u.addEventListener("mouseenter",()=>r(c)),u.addEventListener("mousedown",p=>{p.preventDefault(),i(l)}),s.appendChild(u)}),t.appendChild(s),t.appendChild(KG());const a=n.view.coordsAtPos(e.from);t.style.display="block",t.style.position="fixed",t.style.left=`${Math.max(8,a.left)}px`,t.style.top=`${a.bottom+8}px`}function YG(t,e){const n=Dm(e.query)[e.selectedIndex];return n?(t.chain().focus().deleteRange({from:e.from,to:e.to}).run(),n.run(t),!0):!1}const JG=Jt.create({name:"slashCommand",addOptions(){return{onOpenChange:void 0}},addProseMirrorPlugins(){const t=this.editor,e=this.options.onOpenChange;return[new Lt({key:ko,state:{init:()=>({active:null,dismissedKey:null}),apply(n,r,i,o){var l;const s=WG(n,r);if(s)return s;const a=qG(o,((l=r.active)==null?void 0:l.selectedIndex)??0);return a&&!r.active&&!jG(n)?{active:null,dismissedKey:r.dismissedKey}:a&&fT(a)===r.dismissedKey?{active:null,dismissedKey:r.dismissedKey}:{active:a,dismissedKey:a?null:r.dismissedKey}}},props:{handleKeyDown(n,r){const i=ko.getState(n.state),o=i==null?void 0:i.active;if(!o)return!1;const s=Dm(o.query);if(r.key==="ArrowDown"){r.preventDefault();const a=(o.selectedIndex+1)%s.length;return n.dispatch(n.state.tr.setMeta(ko,{type:"select",selectedIndex:a})),!0}if(r.key==="ArrowUp"){r.preventDefault();const a=(o.selectedIndex-1+s.length)%s.length;return n.dispatch(n.state.tr.setMeta(ko,{type:"select",selectedIndex:a})),!0}return r.key==="Enter"?(r.preventDefault(),YG(t,o)):r.key==="Escape"?(r.preventDefault(),n.dispatch(n.state.tr.setMeta(ko,{type:"close"})),!0):!1}},view(n){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",hT(r),o(!1)},a=()=>{var c;const l=(c=ko.getState(n.state))==null?void 0:c.active;if(!l){s();return}ZG(r,l,t,u=>{n.dispatch(n.state.tr.setMeta(ko,{type:"select",selectedIndex:u}))},u=>{t.chain().focus().deleteRange({from:l.from,to:l.to}).run(),u.run(t),s(),n.dispatch(n.state.tr.setMeta(ko,{type:"close"}))}),o(!0)};return a(),{update:a,destroy(){o(!1),r.remove()}}}})]}}),Gk={};function XG(t){let e=Gk[t];if(e)return e;e=Gk[t]=[];for(let n=0;n<128;n++){const r=String.fromCharCode(n);e.push(r)}for(let n=0;n<t.length;n++){const r=t.charCodeAt(n);e[r]="%"+("0"+r.toString(16).toUpperCase()).slice(-2)}return e}function ic(t,e){typeof e!="string"&&(e=ic.defaultChars);const n=XG(e);return t.replace(/(%[a-f0-9]{2})+/gi,function(r){let i="";for(let o=0,s=r.length;o<s;o+=3){const a=parseInt(r.slice(o+1,o+3),16);if(a<128){i+=n[a];continue}if((a&224)===192&&o+3<s){const l=parseInt(r.slice(o+4,o+6),16);if((l&192)===128){const c=a<<6&1984|l&63;c<128?i+="��":i+=String.fromCharCode(c),o+=3;continue}}if((a&240)===224&&o+6<s){const l=parseInt(r.slice(o+4,o+6),16),c=parseInt(r.slice(o+7,o+9),16);if((l&192)===128&&(c&192)===128){const u=a<<12&61440|l<<6&4032|c&63;u<2048||u>=55296&&u<=57343?i+="���":i+=String.fromCharCode(u),o+=6;continue}}if((a&248)===240&&o+9<s){const l=parseInt(r.slice(o+4,o+6),16),c=parseInt(r.slice(o+7,o+9),16),u=parseInt(r.slice(o+10,o+12),16);if((l&192)===128&&(c&192)===128&&(u&192)===128){let f=a<<18&1835008|l<<12&258048|c<<6&4032|u&63;f<65536||f>1114111?i+="����":(f-=65536,i+=String.fromCharCode(55296+(f>>10),56320+(f&1023))),o+=9;continue}}i+="�"}return i})}ic.defaultChars=";/?:@&=+$,#";ic.componentChars="";const Zk={};function QG(t){let e=Zk[t];if(e)return e;e=Zk[t]=[];for(let n=0;n<128;n++){const r=String.fromCharCode(n);/^[0-9a-z]$/i.test(r)?e.push(r):e.push("%"+("0"+n.toString(16).toUpperCase()).slice(-2))}for(let n=0;n<t.length;n++)e[t.charCodeAt(n)]=t[n];return e}function Fd(t,e,n){typeof e!="string"&&(n=e,e=Fd.defaultChars),typeof n>"u"&&(n=!0);const r=QG(e);let i="";for(let o=0,s=t.length;o<s;o++){const a=t.charCodeAt(o);if(n&&a===37&&o+2<s&&/^[0-9a-f]{2}$/i.test(t.slice(o+1,o+3))){i+=t.slice(o,o+3),o+=2;continue}if(a<128){i+=r[a];continue}if(a>=55296&&a<=57343){if(a>=55296&&a<=56319&&o+1<s){const l=t.charCodeAt(o+1);if(l>=56320&&l<=57343){i+=encodeURIComponent(t[o]+t[o+1]),o++;continue}}i+="%EF%BF%BD";continue}i+=encodeURIComponent(t[o])}return i}Fd.defaultChars=";/?:@&=+$,-_.!~*'()#";Fd.componentChars="-_.!~*'()";function Y1(t){let e="";return e+=t.protocol||"",e+=t.slashes?"//":"",e+=t.auth?t.auth+"@":"",t.hostname&&t.hostname.indexOf(":")!==-1?e+="["+t.hostname+"]":e+=t.hostname||"",e+=t.port?":"+t.port:"",e+=t.pathname||"",e+=t.search||"",e+=t.hash||"",e}function Sp(){this.protocol=null,this.slashes=null,this.auth=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.pathname=null}const $G=/^([a-z0-9.+-]+:)/i,eZ=/:[0-9]*$/,tZ=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,nZ=["<",">",'"',"`"," ","\r",`
202
+ `," "],rZ=["{","}","|","\\","^","`"].concat(nZ),iZ=["'"].concat(rZ),Yk=["%","/","?",";","#"].concat(iZ),Jk=["/","?","#"],oZ=255,Xk=/^[+a-z0-9A-Z_-]{0,63}$/,sZ=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,Qk={javascript:!0,"javascript:":!0},$k={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0};function J1(t,e){if(t&&t instanceof Sp)return t;const n=new Sp;return n.parse(t,e),n}Sp.prototype.parse=function(t,e){let n,r,i,o=t;if(o=o.trim(),!e&&t.split("#").length===1){const c=tZ.exec(o);if(c)return this.pathname=c[1],c[2]&&(this.search=c[2]),this}let s=$G.exec(o);if(s&&(s=s[0],n=s.toLowerCase(),this.protocol=s,o=o.substr(s.length)),(e||s||o.match(/^\/\/[^@\/]+@[^@\/]+/))&&(i=o.substr(0,2)==="//",i&&!(s&&Qk[s])&&(o=o.substr(2),this.slashes=!0)),!Qk[s]&&(i||s&&!$k[s])){let c=-1;for(let m=0;m<Jk.length;m++)r=o.indexOf(Jk[m]),r!==-1&&(c===-1||r<c)&&(c=r);let u,f;c===-1?f=o.lastIndexOf("@"):f=o.lastIndexOf("@",c),f!==-1&&(u=o.slice(0,f),o=o.slice(f+1),this.auth=u),c=-1;for(let m=0;m<Yk.length;m++)r=o.indexOf(Yk[m]),r!==-1&&(c===-1||r<c)&&(c=r);c===-1&&(c=o.length),o[c-1]===":"&&c--;const h=o.slice(0,c);o=o.slice(c),this.parseHost(h),this.hostname=this.hostname||"";const p=this.hostname[0]==="["&&this.hostname[this.hostname.length-1]==="]";if(!p){const m=this.hostname.split(/\./);for(let v=0,g=m.length;v<g;v++){const b=m[v];if(b&&!b.match(Xk)){let _="";for(let k=0,C=b.length;k<C;k++)b.charCodeAt(k)>127?_+="x":_+=b[k];if(!_.match(Xk)){const k=m.slice(0,v),C=m.slice(v+1),E=b.match(sZ);E&&(k.push(E[1]),C.unshift(E[2])),C.length&&(o=C.join(".")+o),this.hostname=k.join(".");break}}}}this.hostname.length>oZ&&(this.hostname=""),p&&(this.hostname=this.hostname.substr(1,this.hostname.length-2))}const a=o.indexOf("#");a!==-1&&(this.hash=o.substr(a),o=o.slice(0,a));const l=o.indexOf("?");return l!==-1&&(this.search=o.substr(l),o=o.slice(0,l)),o&&(this.pathname=o),$k[n]&&this.hostname&&!this.pathname&&(this.pathname=""),this};Sp.prototype.parseHost=function(t){let e=eZ.exec(t);e&&(e=e[0],e!==":"&&(this.port=e.substr(1)),t=t.substr(0,t.length-e.length)),t&&(this.hostname=t)};const aZ=Object.freeze(Object.defineProperty({__proto__:null,decode:ic,encode:Fd,format:Y1,parse:J1},Symbol.toStringTag,{value:"Module"})),pT=/[\0-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,mT=/[\0-\x1F\x7F-\x9F]/,lZ=/[\xAD\u0600-\u0605\u061C\u06DD\u070F\u0890\u0891\u08E2\u180E\u200B-\u200F\u202A-\u202E\u2060-\u2064\u2066-\u206F\uFEFF\uFFF9-\uFFFB]|\uD804[\uDCBD\uDCCD]|\uD80D[\uDC30-\uDC3F]|\uD82F[\uDCA0-\uDCA3]|\uD834[\uDD73-\uDD7A]|\uDB40[\uDC01\uDC20-\uDC7F]/,X1=/[!-#%-\*,-\/:;\?@\[-\]_\{\}\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061D-\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u09FD\u0A76\u0AF0\u0C77\u0C84\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1B7D\u1B7E\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E4F\u2E52-\u2E5D\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD803[\uDEAD\uDF55-\uDF59\uDF86-\uDF89]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC8\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDC4B-\uDC4F\uDC5A\uDC5B\uDC5D\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDE60-\uDE6C\uDEB9\uDF3C-\uDF3E]|\uD806[\uDC3B\uDD44-\uDD46\uDDE2\uDE3F-\uDE46\uDE9A-\uDE9C\uDE9E-\uDEA2\uDF00-\uDF09]|\uD807[\uDC41-\uDC45\uDC70\uDC71\uDEF7\uDEF8\uDF43-\uDF4F\uDFFF]|\uD809[\uDC70-\uDC74]|\uD80B[\uDFF1\uDFF2]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD81B[\uDE97-\uDE9A\uDFE2]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]|\uD83A[\uDD5E\uDD5F]/,gT=/[\$\+<->\^`\|~\xA2-\xA6\xA8\xA9\xAC\xAE-\xB1\xB4\xB8\xD7\xF7\u02C2-\u02C5\u02D2-\u02DF\u02E5-\u02EB\u02ED\u02EF-\u02FF\u0375\u0384\u0385\u03F6\u0482\u058D-\u058F\u0606-\u0608\u060B\u060E\u060F\u06DE\u06E9\u06FD\u06FE\u07F6\u07FE\u07FF\u0888\u09F2\u09F3\u09FA\u09FB\u0AF1\u0B70\u0BF3-\u0BFA\u0C7F\u0D4F\u0D79\u0E3F\u0F01-\u0F03\u0F13\u0F15-\u0F17\u0F1A-\u0F1F\u0F34\u0F36\u0F38\u0FBE-\u0FC5\u0FC7-\u0FCC\u0FCE\u0FCF\u0FD5-\u0FD8\u109E\u109F\u1390-\u1399\u166D\u17DB\u1940\u19DE-\u19FF\u1B61-\u1B6A\u1B74-\u1B7C\u1FBD\u1FBF-\u1FC1\u1FCD-\u1FCF\u1FDD-\u1FDF\u1FED-\u1FEF\u1FFD\u1FFE\u2044\u2052\u207A-\u207C\u208A-\u208C\u20A0-\u20C0\u2100\u2101\u2103-\u2106\u2108\u2109\u2114\u2116-\u2118\u211E-\u2123\u2125\u2127\u2129\u212E\u213A\u213B\u2140-\u2144\u214A-\u214D\u214F\u218A\u218B\u2190-\u2307\u230C-\u2328\u232B-\u2426\u2440-\u244A\u249C-\u24E9\u2500-\u2767\u2794-\u27C4\u27C7-\u27E5\u27F0-\u2982\u2999-\u29D7\u29DC-\u29FB\u29FE-\u2B73\u2B76-\u2B95\u2B97-\u2BFF\u2CE5-\u2CEA\u2E50\u2E51\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFF\u3004\u3012\u3013\u3020\u3036\u3037\u303E\u303F\u309B\u309C\u3190\u3191\u3196-\u319F\u31C0-\u31E3\u31EF\u3200-\u321E\u322A-\u3247\u3250\u3260-\u327F\u328A-\u32B0\u32C0-\u33FF\u4DC0-\u4DFF\uA490-\uA4C6\uA700-\uA716\uA720\uA721\uA789\uA78A\uA828-\uA82B\uA836-\uA839\uAA77-\uAA79\uAB5B\uAB6A\uAB6B\uFB29\uFBB2-\uFBC2\uFD40-\uFD4F\uFDCF\uFDFC-\uFDFF\uFE62\uFE64-\uFE66\uFE69\uFF04\uFF0B\uFF1C-\uFF1E\uFF3E\uFF40\uFF5C\uFF5E\uFFE0-\uFFE6\uFFE8-\uFFEE\uFFFC\uFFFD]|\uD800[\uDD37-\uDD3F\uDD79-\uDD89\uDD8C-\uDD8E\uDD90-\uDD9C\uDDA0\uDDD0-\uDDFC]|\uD802[\uDC77\uDC78\uDEC8]|\uD805\uDF3F|\uD807[\uDFD5-\uDFF1]|\uD81A[\uDF3C-\uDF3F\uDF45]|\uD82F\uDC9C|\uD833[\uDF50-\uDFC3]|\uD834[\uDC00-\uDCF5\uDD00-\uDD26\uDD29-\uDD64\uDD6A-\uDD6C\uDD83\uDD84\uDD8C-\uDDA9\uDDAE-\uDDEA\uDE00-\uDE41\uDE45\uDF00-\uDF56]|\uD835[\uDEC1\uDEDB\uDEFB\uDF15\uDF35\uDF4F\uDF6F\uDF89\uDFA9\uDFC3]|\uD836[\uDC00-\uDDFF\uDE37-\uDE3A\uDE6D-\uDE74\uDE76-\uDE83\uDE85\uDE86]|\uD838[\uDD4F\uDEFF]|\uD83B[\uDCAC\uDCB0\uDD2E\uDEF0\uDEF1]|\uD83C[\uDC00-\uDC2B\uDC30-\uDC93\uDCA0-\uDCAE\uDCB1-\uDCBF\uDCC1-\uDCCF\uDCD1-\uDCF5\uDD0D-\uDDAD\uDDE6-\uDE02\uDE10-\uDE3B\uDE40-\uDE48\uDE50\uDE51\uDE60-\uDE65\uDF00-\uDFFF]|\uD83D[\uDC00-\uDED7\uDEDC-\uDEEC\uDEF0-\uDEFC\uDF00-\uDF76\uDF7B-\uDFD9\uDFE0-\uDFEB\uDFF0]|\uD83E[\uDC00-\uDC0B\uDC10-\uDC47\uDC50-\uDC59\uDC60-\uDC87\uDC90-\uDCAD\uDCB0\uDCB1\uDD00-\uDE53\uDE60-\uDE6D\uDE70-\uDE7C\uDE80-\uDE88\uDE90-\uDEBD\uDEBF-\uDEC5\uDECE-\uDEDB\uDEE0-\uDEE8\uDEF0-\uDEF8\uDF00-\uDF92\uDF94-\uDFCA]/,vT=/[ \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]/,cZ=Object.freeze(Object.defineProperty({__proto__:null,Any:pT,Cc:mT,Cf:lZ,P:X1,S:gT,Z:vT},Symbol.toStringTag,{value:"Module"})),uZ=new Uint16Array('ᵁ<Õıʊҝջאٵ۞ޢߖࠏ੊ઑඡ๭༉༦჊ረዡᐕᒝᓃᓟᔥ\0\0\0\0\0\0ᕫᛍᦍᰒᷝ὾⁠↰⊍⏀⏻⑂⠤⤒ⴈ⹈⿎〖㊺㘹㞬㣾㨨㩱㫠㬮ࠀEMabcfglmnoprstu\\bfms„‹•˜¦³¹ÈÏlig耻Æ䃆P耻&䀦cute耻Á䃁reve;䄂Āiyx}rc耻Â䃂;䐐r;쀀𝔄rave耻À䃀pha;䎑acr;䄀d;橓Āgp¡on;䄄f;쀀𝔸plyFunction;恡ing耻Å䃅Ācs¾Ãr;쀀𝒜ign;扔ilde耻Ã䃃ml耻Ä䃄ЀaceforsuåûþėĜĢħĪĀcrêòkslash;或Ŷöø;櫧ed;挆y;䐑ƀcrtąċĔause;戵noullis;愬a;䎒r;쀀𝔅pf;쀀𝔹eve;䋘còēmpeq;扎܀HOacdefhilorsuōőŖƀƞƢƵƷƺǜȕɳɸɾcy;䐧PY耻©䂩ƀcpyŝŢźute;䄆Ā;iŧŨ拒talDifferentialD;慅leys;愭ȀaeioƉƎƔƘron;䄌dil耻Ç䃇rc;䄈nint;戰ot;䄊ĀdnƧƭilla;䂸terDot;䂷òſi;䎧rcleȀDMPTLJNjǑǖot;抙inus;抖lus;投imes;抗oĀcsǢǸkwiseContourIntegral;戲eCurlyĀDQȃȏoubleQuote;思uote;怙ȀlnpuȞȨɇɕonĀ;eȥȦ户;橴ƀgitȯȶȺruent;扡nt;戯ourIntegral;戮ĀfrɌɎ;愂oduct;成nterClockwiseContourIntegral;戳oss;樯cr;쀀𝒞pĀ;Cʄʅ拓ap;才րDJSZacefiosʠʬʰʴʸˋ˗ˡ˦̳ҍĀ;oŹʥtrahd;椑cy;䐂cy;䐅cy;䐏ƀgrsʿ˄ˇger;怡r;憡hv;櫤Āayː˕ron;䄎;䐔lĀ;t˝˞戇a;䎔r;쀀𝔇Āaf˫̧Ācm˰̢riticalȀADGT̖̜̀̆cute;䂴oŴ̋̍;䋙bleAcute;䋝rave;䁠ilde;䋜ond;拄ferentialD;慆Ѱ̽\0\0\0͔͂\0Ѕf;쀀𝔻ƀ;DE͈͉͍䂨ot;惜qual;扐blèCDLRUVͣͲ΂ϏϢϸontourIntegraìȹoɴ͹\0\0ͻ»͉nArrow;懓Āeo·ΤftƀARTΐΖΡrrow;懐ightArrow;懔eåˊngĀLRΫτeftĀARγιrrow;柸ightArrow;柺ightArrow;柹ightĀATϘϞrrow;懒ee;抨pɁϩ\0\0ϯrrow;懑ownArrow;懕erticalBar;戥ǹABLRTaВЪаўѿͼrrowƀ;BUНОТ憓ar;椓pArrow;懵reve;䌑eft˒к\0ц\0ѐightVector;楐eeVector;楞ectorĀ;Bљњ憽ar;楖ightǔѧ\0ѱeeVector;楟ectorĀ;BѺѻ懁ar;楗eeĀ;A҆҇护rrow;憧ĀctҒҗr;쀀𝒟rok;䄐ࠀNTacdfglmopqstuxҽӀӄӋӞӢӧӮӵԡԯԶՒ՝ՠեG;䅊H耻Ð䃐cute耻É䃉ƀaiyӒӗӜron;䄚rc耻Ê䃊;䐭ot;䄖r;쀀𝔈rave耻È䃈ement;戈ĀapӺӾcr;䄒tyɓԆ\0\0ԒmallSquare;旻erySmallSquare;斫ĀgpԦԪon;䄘f;쀀𝔼silon;䎕uĀaiԼՉlĀ;TՂՃ橵ilde;扂librium;懌Āci՗՚r;愰m;橳a;䎗ml耻Ë䃋Āipժկsts;戃onentialE;慇ʀcfiosօֈ֍ֲ׌y;䐤r;쀀𝔉lledɓ֗\0\0֣mallSquare;旼erySmallSquare;斪Ͱֺ\0ֿ\0\0ׄf;쀀𝔽All;戀riertrf;愱cò׋؀JTabcdfgorstר׬ׯ׺؀ؒؖ؛؝أ٬ٲcy;䐃耻>䀾mmaĀ;d׷׸䎓;䏜reve;䄞ƀeiy؇،ؐdil;䄢rc;䄜;䐓ot;䄠r;쀀𝔊;拙pf;쀀𝔾eater̀EFGLSTصلَٖٛ٦qualĀ;Lؾؿ扥ess;招ullEqual;执reater;檢ess;扷lantEqual;橾ilde;扳cr;쀀𝒢;扫ЀAacfiosuڅڋږڛڞڪھۊRDcy;䐪Āctڐڔek;䋇;䁞irc;䄤r;愌lbertSpace;愋ǰگ\0ڲf;愍izontalLine;攀Āctۃۅòکrok;䄦mpńېۘownHumðįqual;扏܀EJOacdfgmnostuۺ۾܃܇܎ܚܞܡܨ݄ݸދޏޕcy;䐕lig;䄲cy;䐁cute耻Í䃍Āiyܓܘrc耻Î䃎;䐘ot;䄰r;愑rave耻Ì䃌ƀ;apܠܯܿĀcgܴܷr;䄪inaryI;慈lieóϝǴ݉\0ݢĀ;eݍݎ戬Āgrݓݘral;戫section;拂isibleĀCTݬݲomma;恣imes;恢ƀgptݿރވon;䄮f;쀀𝕀a;䎙cr;愐ilde;䄨ǫޚ\0ޞcy;䐆l耻Ï䃏ʀcfosuެ޷޼߂ߐĀiyޱ޵rc;䄴;䐙r;쀀𝔍pf;쀀𝕁ǣ߇\0ߌr;쀀𝒥rcy;䐈kcy;䐄΀HJacfosߤߨ߽߬߱ࠂࠈcy;䐥cy;䐌ppa;䎚Āey߶߻dil;䄶;䐚r;쀀𝔎pf;쀀𝕂cr;쀀𝒦րJTaceflmostࠥࠩࠬࡐࡣ঳সে্਷ੇcy;䐉耻<䀼ʀcmnpr࠷࠼ࡁࡄࡍute;䄹bda;䎛g;柪lacetrf;愒r;憞ƀaeyࡗ࡜ࡡron;䄽dil;䄻;䐛Āfsࡨ॰tԀACDFRTUVarࡾࢩࢱࣦ࣠ࣼयज़ΐ४Ānrࢃ࢏gleBracket;柨rowƀ;BR࢙࢚࢞憐ar;懤ightArrow;懆eiling;挈oǵࢷ\0ࣃbleBracket;柦nǔࣈ\0࣒eeVector;楡ectorĀ;Bࣛࣜ懃ar;楙loor;挊ightĀAV࣯ࣵrrow;憔ector;楎Āerँगeƀ;AVउऊऐ抣rrow;憤ector;楚iangleƀ;BEतथऩ抲ar;槏qual;抴pƀDTVषूौownVector;楑eeVector;楠ectorĀ;Bॖॗ憿ar;楘ectorĀ;B॥०憼ar;楒ightáΜs̀EFGLSTॾঋকঝঢভqualGreater;拚ullEqual;扦reater;扶ess;檡lantEqual;橽ilde;扲r;쀀𝔏Ā;eঽা拘ftarrow;懚idot;䄿ƀnpw৔ਖਛgȀLRlr৞৷ਂਐeftĀAR০৬rrow;柵ightArrow;柷ightArrow;柶eftĀarγਊightáοightáϊf;쀀𝕃erĀLRਢਬeftArrow;憙ightArrow;憘ƀchtਾੀੂòࡌ;憰rok;䅁;扪Ѐacefiosuਗ਼੝੠੷੼અઋ઎p;椅y;䐜Ādl੥੯iumSpace;恟lintrf;愳r;쀀𝔐nusPlus;戓pf;쀀𝕄cò੶;䎜ҀJacefostuણધભીଔଙඑ඗ඞcy;䐊cute;䅃ƀaey઴હાron;䅇dil;䅅;䐝ƀgswે૰଎ativeƀMTV૓૟૨ediumSpace;怋hiĀcn૦૘ë૙eryThiî૙tedĀGL૸ଆreaterGreateòٳessLesóੈLine;䀊r;쀀𝔑ȀBnptଢନଷ଺reak;恠BreakingSpace;䂠f;愕ڀ;CDEGHLNPRSTV୕ୖ୪୼஡௫ఄ౞಄ದ೘ൡඅ櫬Āou୛୤ngruent;扢pCap;扭oubleVerticalBar;戦ƀlqxஃஊ஛ement;戉ualĀ;Tஒஓ扠ilde;쀀≂̸ists;戄reater΀;EFGLSTஶஷ஽௉௓௘௥扯qual;扱ullEqual;쀀≧̸reater;쀀≫̸ess;批lantEqual;쀀⩾̸ilde;扵umpń௲௽ownHump;쀀≎̸qual;쀀≏̸eĀfsఊధtTriangleƀ;BEచఛడ拪ar;쀀⧏̸qual;括s̀;EGLSTవశ఼ౄోౘ扮qual;扰reater;扸ess;쀀≪̸lantEqual;쀀⩽̸ilde;扴estedĀGL౨౹reaterGreater;쀀⪢̸essLess;쀀⪡̸recedesƀ;ESಒಓಛ技qual;쀀⪯̸lantEqual;拠ĀeiಫಹverseElement;戌ghtTriangleƀ;BEೋೌ೒拫ar;쀀⧐̸qual;拭ĀquೝഌuareSuĀbp೨೹setĀ;E೰ೳ쀀⊏̸qual;拢ersetĀ;Eഃആ쀀⊐̸qual;拣ƀbcpഓതൎsetĀ;Eഛഞ쀀⊂⃒qual;抈ceedsȀ;ESTലള഻െ抁qual;쀀⪰̸lantEqual;拡ilde;쀀≿̸ersetĀ;E൘൛쀀⊃⃒qual;抉ildeȀ;EFT൮൯൵ൿ扁qual;扄ullEqual;扇ilde;扉erticalBar;戤cr;쀀𝒩ilde耻Ñ䃑;䎝܀Eacdfgmoprstuvලෂ෉෕ෛ෠෧෼ขภยา฿ไlig;䅒cute耻Ó䃓Āiy෎ීrc耻Ô䃔;䐞blac;䅐r;쀀𝔒rave耻Ò䃒ƀaei෮ෲ෶cr;䅌ga;䎩cron;䎟pf;쀀𝕆enCurlyĀDQฎบoubleQuote;怜uote;怘;橔Āclวฬr;쀀𝒪ash耻Ø䃘iŬื฼de耻Õ䃕es;樷ml耻Ö䃖erĀBP๋๠Āar๐๓r;怾acĀek๚๜;揞et;掴arenthesis;揜Ҁacfhilors๿ງຊຏຒດຝະ໼rtialD;戂y;䐟r;쀀𝔓i;䎦;䎠usMinus;䂱Āipຢອncareplanåڝf;愙Ȁ;eio຺ູ໠໤檻cedesȀ;EST່້໏໚扺qual;檯lantEqual;扼ilde;找me;怳Ādp໩໮uct;戏ortionĀ;aȥ໹l;戝Āci༁༆r;쀀𝒫;䎨ȀUfos༑༖༛༟OT耻"䀢r;쀀𝔔pf;愚cr;쀀𝒬؀BEacefhiorsu༾གྷཇའཱིྦྷྪྭ႖ႩႴႾarr;椐G耻®䂮ƀcnrཎནབute;䅔g;柫rĀ;tཛྷཝ憠l;椖ƀaeyཧཬཱron;䅘dil;䅖;䐠Ā;vླྀཹ愜erseĀEUྂྙĀlq྇ྎement;戋uilibrium;懋pEquilibrium;楯r»ཹo;䎡ghtЀACDFTUVa࿁࿫࿳ဢဨၛႇϘĀnr࿆࿒gleBracket;柩rowƀ;BL࿜࿝࿡憒ar;懥eftArrow;懄eiling;按oǵ࿹\0စbleBracket;柧nǔည\0နeeVector;楝ectorĀ;Bဝသ懂ar;楕loor;挋Āerိ၃eƀ;AVဵံြ抢rrow;憦ector;楛iangleƀ;BEၐၑၕ抳ar;槐qual;抵pƀDTVၣၮၸownVector;楏eeVector;楜ectorĀ;Bႂႃ憾ar;楔ectorĀ;B႑႒懀ar;楓Āpuႛ႞f;愝ndImplies;楰ightarrow;懛ĀchႹႼr;愛;憱leDelayed;槴ڀHOacfhimoqstuფჱჷჽᄙᄞᅑᅖᅡᅧᆵᆻᆿĀCcჩხHcy;䐩y;䐨FTcy;䐬cute;䅚ʀ;aeiyᄈᄉᄎᄓᄗ檼ron;䅠dil;䅞rc;䅜;䐡r;쀀𝔖ortȀDLRUᄪᄴᄾᅉownArrow»ОeftArrow»࢚ightArrow»࿝pArrow;憑gma;䎣allCircle;战pf;쀀𝕊ɲᅭ\0\0ᅰt;戚areȀ;ISUᅻᅼᆉᆯ斡ntersection;抓uĀbpᆏᆞsetĀ;Eᆗᆘ抏qual;抑ersetĀ;Eᆨᆩ抐qual;抒nion;抔cr;쀀𝒮ar;拆ȀbcmpᇈᇛሉላĀ;sᇍᇎ拐etĀ;Eᇍᇕqual;抆ĀchᇠህeedsȀ;ESTᇭᇮᇴᇿ扻qual;檰lantEqual;扽ilde;承Tháྌ;我ƀ;esሒሓሣ拑rsetĀ;Eሜም抃qual;抇et»ሓրHRSacfhiorsሾቄ቉ቕ቞ቱቶኟዂወዑORN耻Þ䃞ADE;愢ĀHc቎ቒcy;䐋y;䐦Ābuቚቜ;䀉;䎤ƀaeyብቪቯron;䅤dil;䅢;䐢r;쀀𝔗Āeiቻ኉Dzኀ\0ኇefore;戴a;䎘Ācn኎ኘkSpace;쀀  Space;怉ldeȀ;EFTካኬኲኼ戼qual;扃ullEqual;扅ilde;扈pf;쀀𝕋ipleDot;惛Āctዖዛr;쀀𝒯rok;䅦ૡዷጎጚጦ\0ጬጱ\0\0\0\0\0ጸጽ፷ᎅ\0᏿ᐄᐊᐐĀcrዻጁute耻Ú䃚rĀ;oጇገ憟cir;楉rǣጓ\0጖y;䐎ve;䅬Āiyጞጣrc耻Û䃛;䐣blac;䅰r;쀀𝔘rave耻Ù䃙acr;䅪Ādiፁ፩erĀBPፈ፝Āarፍፐr;䁟acĀekፗፙ;揟et;掵arenthesis;揝onĀ;P፰፱拃lus;抎Āgp፻፿on;䅲f;쀀𝕌ЀADETadps᎕ᎮᎸᏄϨᏒᏗᏳrrowƀ;BDᅐᎠᎤar;椒ownArrow;懅ownArrow;憕quilibrium;楮eeĀ;AᏋᏌ报rrow;憥ownáϳerĀLRᏞᏨeftArrow;憖ightArrow;憗iĀ;lᏹᏺ䏒on;䎥ing;䅮cr;쀀𝒰ilde;䅨ml耻Ü䃜ҀDbcdefosvᐧᐬᐰᐳᐾᒅᒊᒐᒖash;披ar;櫫y;䐒ashĀ;lᐻᐼ抩;櫦Āerᑃᑅ;拁ƀbtyᑌᑐᑺar;怖Ā;iᑏᑕcalȀBLSTᑡᑥᑪᑴar;戣ine;䁼eparator;杘ilde;所ThinSpace;怊r;쀀𝔙pf;쀀𝕍cr;쀀𝒱dash;抪ʀcefosᒧᒬᒱᒶᒼirc;䅴dge;拀r;쀀𝔚pf;쀀𝕎cr;쀀𝒲Ȁfiosᓋᓐᓒᓘr;쀀𝔛;䎞pf;쀀𝕏cr;쀀𝒳ҀAIUacfosuᓱᓵᓹᓽᔄᔏᔔᔚᔠcy;䐯cy;䐇cy;䐮cute耻Ý䃝Āiyᔉᔍrc;䅶;䐫r;쀀𝔜pf;쀀𝕐cr;쀀𝒴ml;䅸ЀHacdefosᔵᔹᔿᕋᕏᕝᕠᕤcy;䐖cute;䅹Āayᕄᕉron;䅽;䐗ot;䅻Dzᕔ\0ᕛoWidtè૙a;䎖r;愨pf;愤cr;쀀𝒵௡ᖃᖊᖐ\0ᖰᖶᖿ\0\0\0\0ᗆᗛᗫᙟ᙭\0ᚕ᚛ᚲᚹ\0ᚾcute耻á䃡reve;䄃̀;Ediuyᖜᖝᖡᖣᖨᖭ戾;쀀∾̳;房rc耻â䃢te肻´̆;䐰lig耻æ䃦Ā;r²ᖺ;쀀𝔞rave耻à䃠ĀepᗊᗖĀfpᗏᗔsym;愵èᗓha;䎱ĀapᗟcĀclᗤᗧr;䄁g;樿ɤᗰ\0\0ᘊʀ;adsvᗺᗻᗿᘁᘇ戧nd;橕;橜lope;橘;橚΀;elmrszᘘᘙᘛᘞᘿᙏᙙ戠;榤e»ᘙsdĀ;aᘥᘦ戡ѡᘰᘲᘴᘶᘸᘺᘼᘾ;榨;榩;榪;榫;榬;榭;榮;榯tĀ;vᙅᙆ戟bĀ;dᙌᙍ抾;榝Āptᙔᙗh;戢»¹arr;捼Āgpᙣᙧon;䄅f;쀀𝕒΀;Eaeiop዁ᙻᙽᚂᚄᚇᚊ;橰cir;橯;扊d;手s;䀧roxĀ;e዁ᚒñᚃing耻å䃥ƀctyᚡᚦᚨr;쀀𝒶;䀪mpĀ;e዁ᚯñʈilde耻ã䃣ml耻ä䃤Āciᛂᛈoninôɲnt;樑ࠀNabcdefiklnoprsu᛭ᛱᜰ᜼ᝃᝈ᝸᝽០៦ᠹᡐᜍ᤽᥈ᥰot;櫭Ācrᛶ᜞kȀcepsᜀᜅᜍᜓong;扌psilon;䏶rime;怵imĀ;e᜚᜛戽q;拍Ŷᜢᜦee;抽edĀ;gᜬᜭ挅e»ᜭrkĀ;t፜᜷brk;掶Āoyᜁᝁ;䐱quo;怞ʀcmprtᝓ᝛ᝡᝤᝨausĀ;eĊĉptyv;榰séᜌnoõēƀahwᝯ᝱ᝳ;䎲;愶een;扬r;쀀𝔟g΀costuvwឍឝឳេ៕៛៞ƀaiuបពរðݠrc;旯p»፱ƀdptឤឨឭot;樀lus;樁imes;樂ɱឹ\0\0ើcup;樆ar;昅riangleĀdu៍្own;施p;斳plus;樄eåᑄåᒭarow;植ƀako៭ᠦᠵĀcn៲ᠣkƀlst៺֫᠂ozenge;槫riangleȀ;dlr᠒᠓᠘᠝斴own;斾eft;旂ight;斸k;搣Ʊᠫ\0ᠳƲᠯ\0ᠱ;斒;斑4;斓ck;斈ĀeoᠾᡍĀ;qᡃᡆ쀀=⃥uiv;쀀≡⃥t;挐Ȁptwxᡙᡞᡧᡬf;쀀𝕓Ā;tᏋᡣom»Ꮜtie;拈؀DHUVbdhmptuvᢅᢖᢪᢻᣗᣛᣬ᣿ᤅᤊᤐᤡȀLRlrᢎᢐᢒᢔ;敗;敔;敖;敓ʀ;DUduᢡᢢᢤᢦᢨ敐;敦;敩;敤;敧ȀLRlrᢳᢵᢷᢹ;敝;敚;敜;教΀;HLRhlrᣊᣋᣍᣏᣑᣓᣕ救;敬;散;敠;敫;敢;敟ox;槉ȀLRlrᣤᣦᣨᣪ;敕;敒;攐;攌ʀ;DUduڽ᣷᣹᣻᣽;敥;敨;攬;攴inus;抟lus;択imes;抠ȀLRlrᤙᤛᤝ᤟;敛;敘;攘;攔΀;HLRhlrᤰᤱᤳᤵᤷ᤻᤹攂;敪;敡;敞;攼;攤;攜Āevģ᥂bar耻¦䂦Ȁceioᥑᥖᥚᥠr;쀀𝒷mi;恏mĀ;e᜚᜜lƀ;bhᥨᥩᥫ䁜;槅sub;柈Ŭᥴ᥾lĀ;e᥹᥺怢t»᥺pƀ;Eeįᦅᦇ;檮Ā;qۜۛೡᦧ\0᧨ᨑᨕᨲ\0ᨷᩐ\0\0᪴\0\0᫁\0\0ᬡᬮ᭍᭒\0᯽\0ᰌƀcpr᦭ᦲ᧝ute;䄇̀;abcdsᦿᧀᧄ᧊᧕᧙戩nd;橄rcup;橉Āau᧏᧒p;橋p;橇ot;橀;쀀∩︀Āeo᧢᧥t;恁îړȀaeiu᧰᧻ᨁᨅǰ᧵\0᧸s;橍on;䄍dil耻ç䃧rc;䄉psĀ;sᨌᨍ橌m;橐ot;䄋ƀdmnᨛᨠᨦil肻¸ƭptyv;榲t脀¢;eᨭᨮ䂢räƲr;쀀𝔠ƀceiᨽᩀᩍy;䑇ckĀ;mᩇᩈ朓ark»ᩈ;䏇r΀;Ecefms᩟᩠ᩢᩫ᪤᪪᪮旋;槃ƀ;elᩩᩪᩭ䋆q;扗eɡᩴ\0\0᪈rrowĀlr᩼᪁eft;憺ight;憻ʀRSacd᪒᪔᪖᪚᪟»ཇ;擈st;抛irc;抚ash;抝nint;樐id;櫯cir;槂ubsĀ;u᪻᪼晣it»᪼ˬ᫇᫔᫺\0ᬊonĀ;eᫍᫎ䀺Ā;qÇÆɭ᫙\0\0᫢aĀ;t᫞᫟䀬;䁀ƀ;fl᫨᫩᫫戁îᅠeĀmx᫱᫶ent»᫩eóɍǧ᫾\0ᬇĀ;dኻᬂot;橭nôɆƀfryᬐᬔᬗ;쀀𝕔oäɔ脀©;sŕᬝr;愗Āaoᬥᬩrr;憵ss;朗Ācuᬲᬷr;쀀𝒸Ābpᬼ᭄Ā;eᭁᭂ櫏;櫑Ā;eᭉᭊ櫐;櫒dot;拯΀delprvw᭠᭬᭷ᮂᮬᯔ᯹arrĀlr᭨᭪;椸;椵ɰ᭲\0\0᭵r;拞c;拟arrĀ;p᭿ᮀ憶;椽̀;bcdosᮏᮐᮖᮡᮥᮨ截rcap;橈Āauᮛᮞp;橆p;橊ot;抍r;橅;쀀∪︀Ȁalrv᮵ᮿᯞᯣrrĀ;mᮼᮽ憷;椼yƀevwᯇᯔᯘqɰᯎ\0\0ᯒreã᭳uã᭵ee;拎edge;拏en耻¤䂤earrowĀlrᯮ᯳eft»ᮀight»ᮽeäᯝĀciᰁᰇoninôǷnt;戱lcty;挭ঀAHabcdefhijlorstuwz᰸᰻᰿ᱝᱩᱵᲊᲞᲬᲷ᳻᳿ᴍᵻᶑᶫᶻ᷆᷍rò΁ar;楥Ȁglrs᱈ᱍ᱒᱔ger;怠eth;愸òᄳhĀ;vᱚᱛ怐»ऊūᱡᱧarow;椏aã̕Āayᱮᱳron;䄏;䐴ƀ;ao̲ᱼᲄĀgrʿᲁr;懊tseq;橷ƀglmᲑᲔᲘ耻°䂰ta;䎴ptyv;榱ĀirᲣᲨsht;楿;쀀𝔡arĀlrᲳᲵ»ࣜ»သʀaegsv᳂͸᳖᳜᳠mƀ;oș᳊᳔ndĀ;ș᳑uit;晦amma;䏝in;拲ƀ;io᳧᳨᳸䃷de脀÷;o᳧ᳰntimes;拇nø᳷cy;䑒cɯᴆ\0\0ᴊrn;挞op;挍ʀlptuwᴘᴝᴢᵉᵕlar;䀤f;쀀𝕕ʀ;emps̋ᴭᴷᴽᵂqĀ;d͒ᴳot;扑inus;戸lus;戔quare;抡blebarwedgåúnƀadhᄮᵝᵧownarrowóᲃarpoonĀlrᵲᵶefôᲴighôᲶŢᵿᶅkaro÷གɯᶊ\0\0ᶎrn;挟op;挌ƀcotᶘᶣᶦĀryᶝᶡ;쀀𝒹;䑕l;槶rok;䄑Ādrᶰᶴot;拱iĀ;fᶺ᠖斿Āah᷀᷃ròЩaòྦangle;榦Āci᷒ᷕy;䑟grarr;柿ऀDacdefglmnopqrstuxḁḉḙḸոḼṉṡṾấắẽỡἪἷὄ὎὚ĀDoḆᴴoôᲉĀcsḎḔute耻é䃩ter;橮ȀaioyḢḧḱḶron;䄛rĀ;cḭḮ扖耻ê䃪lon;払;䑍ot;䄗ĀDrṁṅot;扒;쀀𝔢ƀ;rsṐṑṗ檚ave耻è䃨Ā;dṜṝ檖ot;檘Ȁ;ilsṪṫṲṴ檙nters;揧;愓Ā;dṹṺ檕ot;檗ƀapsẅẉẗcr;䄓tyƀ;svẒẓẕ戅et»ẓpĀ1;ẝẤijạả;怄;怅怃ĀgsẪẬ;䅋p;怂ĀgpẴẸon;䄙f;쀀𝕖ƀalsỄỎỒrĀ;sỊị拕l;槣us;橱iƀ;lvỚớở䎵on»ớ;䏵ȀcsuvỪỳἋἣĀioữḱrc»Ḯɩỹ\0\0ỻíՈantĀglἂἆtr»ṝess»Ṻƀaeiἒ἖Ἒls;䀽st;扟vĀ;DȵἠD;橸parsl;槥ĀDaἯἳot;打rr;楱ƀcdiἾὁỸr;愯oô͒ĀahὉὋ;䎷耻ð䃰Āmrὓὗl耻ë䃫o;悬ƀcipὡὤὧl;䀡sôծĀeoὬὴctatioîՙnentialåչৡᾒ\0ᾞ\0ᾡᾧ\0\0ῆῌ\0ΐ\0ῦῪ \0 ⁚llingdotseñṄy;䑄male;晀ƀilrᾭᾳ῁lig;耀ffiɩᾹ\0\0᾽g;耀ffig;耀ffl;쀀𝔣lig;耀filig;쀀fjƀaltῙ῜ῡt;晭ig;耀flns;斱of;䆒ǰ΅\0ῳf;쀀𝕗ĀakֿῷĀ;vῼ´拔;櫙artint;樍Āao‌⁕Ācs‑⁒ႉ‸⁅⁈\0⁐β•‥‧‪‬\0‮耻½䂽;慓耻¼䂼;慕;慙;慛Ƴ‴\0‶;慔;慖ʴ‾⁁\0\0⁃耻¾䂾;慗;慜5;慘ƶ⁌\0⁎;慚;慝8;慞l;恄wn;挢cr;쀀𝒻ࢀEabcdefgijlnorstv₂₉₟₥₰₴⃰⃵⃺⃿℃ℒℸ̗ℾ⅒↞Ā;lٍ₇;檌ƀcmpₐₕ₝ute;䇵maĀ;dₜ᳚䎳;檆reve;䄟Āiy₪₮rc;䄝;䐳ot;䄡Ȁ;lqsؾق₽⃉ƀ;qsؾٌ⃄lanô٥Ȁ;cdl٥⃒⃥⃕c;檩otĀ;o⃜⃝檀Ā;l⃢⃣檂;檄Ā;e⃪⃭쀀⋛︀s;檔r;쀀𝔤Ā;gٳ؛mel;愷cy;䑓Ȁ;Eajٚℌℎℐ;檒;檥;檤ȀEaesℛℝ℩ℴ;扩pĀ;p℣ℤ檊rox»ℤĀ;q℮ℯ檈Ā;q℮ℛim;拧pf;쀀𝕘Āci⅃ⅆr;愊mƀ;el٫ⅎ⅐;檎;檐茀>;cdlqr׮ⅠⅪⅮⅳⅹĀciⅥⅧ;檧r;橺ot;拗Par;榕uest;橼ʀadelsↄⅪ←ٖ↛ǰ↉\0↎proø₞r;楸qĀlqؿ↖lesó₈ií٫Āen↣↭rtneqq;쀀≩︀Å↪ԀAabcefkosy⇄⇇⇱⇵⇺∘∝∯≨≽ròΠȀilmr⇐⇔⇗⇛rsðᒄf»․ilôکĀdr⇠⇤cy;䑊ƀ;cwࣴ⇫⇯ir;楈;憭ar;意irc;䄥ƀalr∁∎∓rtsĀ;u∉∊晥it»∊lip;怦con;抹r;쀀𝔥sĀew∣∩arow;椥arow;椦ʀamopr∺∾≃≞≣rr;懿tht;戻kĀlr≉≓eftarrow;憩ightarrow;憪f;쀀𝕙bar;怕ƀclt≯≴≸r;쀀𝒽asè⇴rok;䄧Ābp⊂⊇ull;恃hen»ᱛૡ⊣\0⊪\0⊸⋅⋎\0⋕⋳\0\0⋸⌢⍧⍢⍿\0⎆⎪⎴cute耻í䃭ƀ;iyݱ⊰⊵rc耻î䃮;䐸Ācx⊼⊿y;䐵cl耻¡䂡ĀfrΟ⋉;쀀𝔦rave耻ì䃬Ȁ;inoܾ⋝⋩⋮Āin⋢⋦nt;樌t;戭fin;槜ta;愩lig;䄳ƀaop⋾⌚⌝ƀcgt⌅⌈⌗r;䄫ƀelpܟ⌏⌓inåގarôܠh;䄱f;抷ed;䆵ʀ;cfotӴ⌬⌱⌽⍁are;愅inĀ;t⌸⌹戞ie;槝doô⌙ʀ;celpݗ⍌⍐⍛⍡al;抺Āgr⍕⍙eróᕣã⍍arhk;樗rod;樼Ȁcgpt⍯⍲⍶⍻y;䑑on;䄯f;쀀𝕚a;䎹uest耻¿䂿Āci⎊⎏r;쀀𝒾nʀ;EdsvӴ⎛⎝⎡ӳ;拹ot;拵Ā;v⎦⎧拴;拳Ā;iݷ⎮lde;䄩ǫ⎸\0⎼cy;䑖l耻ï䃯̀cfmosu⏌⏗⏜⏡⏧⏵Āiy⏑⏕rc;䄵;䐹r;쀀𝔧ath;䈷pf;쀀𝕛ǣ⏬\0⏱r;쀀𝒿rcy;䑘kcy;䑔Ѐacfghjos␋␖␢␧␭␱␵␻ppaĀ;v␓␔䎺;䏰Āey␛␠dil;䄷;䐺r;쀀𝔨reen;䄸cy;䑅cy;䑜pf;쀀𝕜cr;쀀𝓀஀ABEHabcdefghjlmnoprstuv⑰⒁⒆⒍⒑┎┽╚▀♎♞♥♹♽⚚⚲⛘❝❨➋⟀⠁⠒ƀart⑷⑺⑼rò৆òΕail;椛arr;椎Ā;gঔ⒋;檋ar;楢ॣ⒥\0⒪\0⒱\0\0\0\0\0⒵Ⓔ\0ⓆⓈⓍ\0⓹ute;䄺mptyv;榴raîࡌbda;䎻gƀ;dlࢎⓁⓃ;榑åࢎ;檅uo耻«䂫rЀ;bfhlpst࢙ⓞⓦⓩ⓫⓮⓱⓵Ā;f࢝ⓣs;椟s;椝ë≒p;憫l;椹im;楳l;憢ƀ;ae⓿─┄檫il;椙Ā;s┉┊檭;쀀⪭︀ƀabr┕┙┝rr;椌rk;杲Āak┢┬cĀek┨┪;䁻;䁛Āes┱┳;榋lĀdu┹┻;榏;榍Ȁaeuy╆╋╖╘ron;䄾Ādi═╔il;䄼ìࢰâ┩;䐻Ȁcqrs╣╦╭╽a;椶uoĀ;rนᝆĀdu╲╷har;楧shar;楋h;憲ʀ;fgqs▋▌উ◳◿扤tʀahlrt▘▤▷◂◨rrowĀ;t࢙□aé⓶arpoonĀdu▯▴own»њp»०eftarrows;懇ightƀahs◍◖◞rrowĀ;sࣴࢧarpoonó྘quigarro÷⇰hreetimes;拋ƀ;qs▋ও◺lanôবʀ;cdgsব☊☍☝☨c;檨otĀ;o☔☕橿Ā;r☚☛檁;檃Ā;e☢☥쀀⋚︀s;檓ʀadegs☳☹☽♉♋pproøⓆot;拖qĀgq♃♅ôউgtò⒌ôছiíলƀilr♕࣡♚sht;楼;쀀𝔩Ā;Eজ♣;檑š♩♶rĀdu▲♮Ā;l॥♳;楪lk;斄cy;䑙ʀ;achtੈ⚈⚋⚑⚖rò◁orneòᴈard;楫ri;旺Āio⚟⚤dot;䅀ustĀ;a⚬⚭掰che»⚭ȀEaes⚻⚽⛉⛔;扨pĀ;p⛃⛄檉rox»⛄Ā;q⛎⛏檇Ā;q⛎⚻im;拦Ѐabnoptwz⛩⛴⛷✚✯❁❇❐Ānr⛮⛱g;柬r;懽rëࣁgƀlmr⛿✍✔eftĀar০✇ightá৲apsto;柼ightá৽parrowĀlr✥✩efô⓭ight;憬ƀafl✶✹✽r;榅;쀀𝕝us;樭imes;樴š❋❏st;戗áፎƀ;ef❗❘᠀旊nge»❘arĀ;l❤❥䀨t;榓ʀachmt❳❶❼➅➇ròࢨorneòᶌarĀ;d྘➃;業;怎ri;抿̀achiqt➘➝ੀ➢➮➻quo;怹r;쀀𝓁mƀ;egল➪➬;檍;檏Ābu┪➳oĀ;rฟ➹;怚rok;䅂萀<;cdhilqrࠫ⟒☹⟜⟠⟥⟪⟰Āci⟗⟙;檦r;橹reå◲mes;拉arr;楶uest;橻ĀPi⟵⟹ar;榖ƀ;ef⠀भ᠛旃rĀdu⠇⠍shar;楊har;楦Āen⠗⠡rtneqq;쀀≨︀Å⠞܀Dacdefhilnopsu⡀⡅⢂⢎⢓⢠⢥⢨⣚⣢⣤ઃ⣳⤂Dot;戺Ȁclpr⡎⡒⡣⡽r耻¯䂯Āet⡗⡙;時Ā;e⡞⡟朠se»⡟Ā;sျ⡨toȀ;dluျ⡳⡷⡻owîҌefôएðᏑker;斮Āoy⢇⢌mma;権;䐼ash;怔asuredangle»ᘦr;쀀𝔪o;愧ƀcdn⢯⢴⣉ro耻µ䂵Ȁ;acdᑤ⢽⣀⣄sôᚧir;櫰ot肻·Ƶusƀ;bd⣒ᤃ⣓戒Ā;uᴼ⣘;横ţ⣞⣡p;櫛ò−ðઁĀdp⣩⣮els;抧f;쀀𝕞Āct⣸⣽r;쀀𝓂pos»ᖝƀ;lm⤉⤊⤍䎼timap;抸ఀGLRVabcdefghijlmoprstuvw⥂⥓⥾⦉⦘⧚⧩⨕⨚⩘⩝⪃⪕⪤⪨⬄⬇⭄⭿⮮ⰴⱧⱼ⳩Āgt⥇⥋;쀀⋙̸Ā;v⥐௏쀀≫⃒ƀelt⥚⥲⥶ftĀar⥡⥧rrow;懍ightarrow;懎;쀀⋘̸Ā;v⥻ే쀀≪⃒ightarrow;懏ĀDd⦎⦓ash;抯ash;抮ʀbcnpt⦣⦧⦬⦱⧌la»˞ute;䅄g;쀀∠⃒ʀ;Eiop඄⦼⧀⧅⧈;쀀⩰̸d;쀀≋̸s;䅉roø඄urĀ;a⧓⧔普lĀ;s⧓ସdz⧟\0⧣p肻 ଷmpĀ;e௹ఀʀaeouy⧴⧾⨃⨐⨓ǰ⧹\0⧻;橃on;䅈dil;䅆ngĀ;dൾ⨊ot;쀀⩭̸p;橂;䐽ash;怓΀;Aadqsxஒ⨩⨭⨻⩁⩅⩐rr;懗rĀhr⨳⨶k;椤Ā;oᏲᏰot;쀀≐̸uiöୣĀei⩊⩎ar;椨í஘istĀ;s஠டr;쀀𝔫ȀEest௅⩦⩹⩼ƀ;qs஼⩭௡ƀ;qs஼௅⩴lanô௢ií௪Ā;rஶ⪁»ஷƀAap⪊⪍⪑rò⥱rr;憮ar;櫲ƀ;svྍ⪜ྌĀ;d⪡⪢拼;拺cy;䑚΀AEadest⪷⪺⪾⫂⫅⫶⫹rò⥦;쀀≦̸rr;憚r;急Ȁ;fqs఻⫎⫣⫯tĀar⫔⫙rro÷⫁ightarro÷⪐ƀ;qs఻⪺⫪lanôౕĀ;sౕ⫴»శiíౝĀ;rవ⫾iĀ;eచథiäඐĀpt⬌⬑f;쀀𝕟膀¬;in⬙⬚⬶䂬nȀ;Edvஉ⬤⬨⬮;쀀⋹̸ot;쀀⋵̸ǡஉ⬳⬵;拷;拶iĀ;vಸ⬼ǡಸ⭁⭃;拾;拽ƀaor⭋⭣⭩rȀ;ast୻⭕⭚⭟lleì୻l;쀀⫽⃥;쀀∂̸lint;樔ƀ;ceಒ⭰⭳uåಥĀ;cಘ⭸Ā;eಒ⭽ñಘȀAait⮈⮋⮝⮧rò⦈rrƀ;cw⮔⮕⮙憛;쀀⤳̸;쀀↝̸ghtarrow»⮕riĀ;eೋೖ΀chimpqu⮽⯍⯙⬄୸⯤⯯Ȁ;cerല⯆ഷ⯉uå൅;쀀𝓃ortɭ⬅\0\0⯖ará⭖mĀ;e൮⯟Ā;q൴൳suĀbp⯫⯭å೸åഋƀbcp⯶ⰑⰙȀ;Ees⯿ⰀഢⰄ抄;쀀⫅̸etĀ;eഛⰋqĀ;qണⰀcĀ;eലⰗñസȀ;EesⰢⰣൟⰧ抅;쀀⫆̸etĀ;e൘ⰮqĀ;qൠⰣȀgilrⰽⰿⱅⱇìௗlde耻ñ䃱çృiangleĀlrⱒⱜeftĀ;eచⱚñదightĀ;eೋⱥñ೗Ā;mⱬⱭ䎽ƀ;esⱴⱵⱹ䀣ro;愖p;怇ҀDHadgilrsⲏⲔⲙⲞⲣⲰⲶⳓⳣash;抭arr;椄p;쀀≍⃒ash;抬ĀetⲨⲬ;쀀≥⃒;쀀>⃒nfin;槞ƀAetⲽⳁⳅrr;椂;쀀≤⃒Ā;rⳊⳍ쀀<⃒ie;쀀⊴⃒ĀAtⳘⳜrr;椃rie;쀀⊵⃒im;쀀∼⃒ƀAan⳰⳴ⴂrr;懖rĀhr⳺⳽k;椣Ā;oᏧᏥear;椧ቓ᪕\0\0\0\0\0\0\0\0\0\0\0\0\0ⴭ\0ⴸⵈⵠⵥ⵲ⶄᬇ\0\0ⶍⶫ\0ⷈⷎ\0ⷜ⸙⸫⸾⹃Ācsⴱ᪗ute耻ó䃳ĀiyⴼⵅrĀ;c᪞ⵂ耻ô䃴;䐾ʀabios᪠ⵒⵗLjⵚlac;䅑v;樸old;榼lig;䅓Ācr⵩⵭ir;榿;쀀𝔬ͯ⵹\0\0⵼\0ⶂn;䋛ave耻ò䃲;槁Ābmⶈ෴ar;榵Ȁacitⶕ⶘ⶥⶨrò᪀Āir⶝ⶠr;榾oss;榻nå๒;槀ƀaeiⶱⶵⶹcr;䅍ga;䏉ƀcdnⷀⷅǍron;䎿;榶pf;쀀𝕠ƀaelⷔ⷗ǒr;榷rp;榹΀;adiosvⷪⷫⷮ⸈⸍⸐⸖戨rò᪆Ȁ;efmⷷⷸ⸂⸅橝rĀ;oⷾⷿ愴f»ⷿ耻ª䂪耻º䂺gof;抶r;橖lope;橗;橛ƀclo⸟⸡⸧ò⸁ash耻ø䃸l;折iŬⸯ⸴de耻õ䃵esĀ;aǛ⸺s;樶ml耻ö䃶bar;挽ૡ⹞\0⹽\0⺀⺝\0⺢⺹\0\0⻋ຜ\0⼓\0\0⼫⾼\0⿈rȀ;astЃ⹧⹲຅脀¶;l⹭⹮䂶leìЃɩ⹸\0\0⹻m;櫳;櫽y;䐿rʀcimpt⺋⺏⺓ᡥ⺗nt;䀥od;䀮il;怰enk;怱r;쀀𝔭ƀimo⺨⺰⺴Ā;v⺭⺮䏆;䏕maô੶ne;明ƀ;tv⺿⻀⻈䏀chfork»´;䏖Āau⻏⻟nĀck⻕⻝kĀ;h⇴⻛;愎ö⇴sҀ;abcdemst⻳⻴ᤈ⻹⻽⼄⼆⼊⼎䀫cir;樣ir;樢Āouᵀ⼂;樥;橲n肻±ຝim;樦wo;樧ƀipu⼙⼠⼥ntint;樕f;쀀𝕡nd耻£䂣Ԁ;Eaceinosu່⼿⽁⽄⽇⾁⾉⾒⽾⾶;檳p;檷uå໙Ā;c໎⽌̀;acens່⽙⽟⽦⽨⽾pproø⽃urlyeñ໙ñ໎ƀaes⽯⽶⽺pprox;檹qq;檵im;拨iíໟmeĀ;s⾈ຮ怲ƀEas⽸⾐⽺ð⽵ƀdfp໬⾙⾯ƀals⾠⾥⾪lar;挮ine;挒urf;挓Ā;t໻⾴ï໻rel;抰Āci⿀⿅r;쀀𝓅;䏈ncsp;怈̀fiopsu⿚⋢⿟⿥⿫⿱r;쀀𝔮pf;쀀𝕢rime;恗cr;쀀𝓆ƀaeo⿸〉〓tĀei⿾々rnionóڰnt;樖stĀ;e【】䀿ñἙô༔઀ABHabcdefhilmnoprstux぀けさすムㄎㄫㅇㅢㅲㆎ㈆㈕㈤㈩㉘㉮㉲㊐㊰㊷ƀartぇおがròႳòϝail;検aròᱥar;楤΀cdenqrtとふへみわゔヌĀeuねぱ;쀀∽̱te;䅕iãᅮmptyv;榳gȀ;del࿑らるろ;榒;榥å࿑uo耻»䂻rր;abcfhlpstw࿜ガクシスゼゾダッデナp;極Ā;f࿠ゴs;椠;椳s;椞ë≝ð✮l;楅im;楴l;憣;憝Āaiパフil;椚oĀ;nホボ戶aló༞ƀabrョリヮrò៥rk;杳ĀakンヽcĀekヹ・;䁽;䁝Āes㄂㄄;榌lĀduㄊㄌ;榎;榐Ȁaeuyㄗㄜㄧㄩron;䅙Ādiㄡㄥil;䅗ì࿲âヺ;䑀Ȁclqsㄴㄷㄽㅄa;椷dhar;楩uoĀ;rȎȍh;憳ƀacgㅎㅟངlȀ;ipsླྀㅘㅛႜnåႻarôྩt;断ƀilrㅩဣㅮsht;楽;쀀𝔯ĀaoㅷㆆrĀduㅽㅿ»ѻĀ;l႑ㆄ;楬Ā;vㆋㆌ䏁;䏱ƀgns㆕ㇹㇼht̀ahlrstㆤㆰ㇂㇘㇤㇮rrowĀ;t࿜ㆭaéトarpoonĀduㆻㆿowîㅾp»႒eftĀah㇊㇐rrowó࿪arpoonóՑightarrows;應quigarro÷ニhreetimes;拌g;䋚ingdotseñἲƀahm㈍㈐㈓rò࿪aòՑ;怏oustĀ;a㈞㈟掱che»㈟mid;櫮Ȁabpt㈲㈽㉀㉒Ānr㈷㈺g;柭r;懾rëဃƀafl㉇㉊㉎r;榆;쀀𝕣us;樮imes;樵Āap㉝㉧rĀ;g㉣㉤䀩t;榔olint;樒arò㇣Ȁachq㉻㊀Ⴜ㊅quo;怺r;쀀𝓇Ābu・㊊oĀ;rȔȓƀhir㊗㊛㊠reåㇸmes;拊iȀ;efl㊪ၙᠡ㊫方tri;槎luhar;楨;愞ൡ㋕㋛㋟㌬㌸㍱\0㍺㎤\0\0㏬㏰\0㐨㑈㑚㒭㒱㓊㓱\0㘖\0\0㘳cute;䅛quï➺Ԁ;Eaceinpsyᇭ㋳㋵㋿㌂㌋㌏㌟㌦㌩;檴ǰ㋺\0㋼;檸on;䅡uåᇾĀ;dᇳ㌇il;䅟rc;䅝ƀEas㌖㌘㌛;檶p;檺im;择olint;樓iíሄ;䑁otƀ;be㌴ᵇ㌵担;橦΀Aacmstx㍆㍊㍗㍛㍞㍣㍭rr;懘rĀhr㍐㍒ë∨Ā;oਸ਼਴t耻§䂧i;䀻war;椩mĀin㍩ðnuóñt;朶rĀ;o㍶⁕쀀𝔰Ȁacoy㎂㎆㎑㎠rp;景Āhy㎋㎏cy;䑉;䑈rtɭ㎙\0\0㎜iäᑤaraì⹯耻­䂭Āgm㎨㎴maƀ;fv㎱㎲㎲䏃;䏂Ѐ;deglnprካ㏅㏉㏎㏖㏞㏡㏦ot;橪Ā;q኱ኰĀ;E㏓㏔檞;檠Ā;E㏛㏜檝;檟e;扆lus;樤arr;楲aròᄽȀaeit㏸㐈㐏㐗Āls㏽㐄lsetmé㍪hp;樳parsl;槤Ādlᑣ㐔e;挣Ā;e㐜㐝檪Ā;s㐢㐣檬;쀀⪬︀ƀflp㐮㐳㑂tcy;䑌Ā;b㐸㐹䀯Ā;a㐾㐿槄r;挿f;쀀𝕤aĀdr㑍ЂesĀ;u㑔㑕晠it»㑕ƀcsu㑠㑹㒟Āau㑥㑯pĀ;sᆈ㑫;쀀⊓︀pĀ;sᆴ㑵;쀀⊔︀uĀbp㑿㒏ƀ;esᆗᆜ㒆etĀ;eᆗ㒍ñᆝƀ;esᆨᆭ㒖etĀ;eᆨ㒝ñᆮƀ;afᅻ㒦ְrť㒫ֱ»ᅼaròᅈȀcemt㒹㒾㓂㓅r;쀀𝓈tmîñiì㐕aræᆾĀar㓎㓕rĀ;f㓔ឿ昆Āan㓚㓭ightĀep㓣㓪psiloîỠhé⺯s»⡒ʀbcmnp㓻㕞ሉ㖋㖎Ҁ;Edemnprs㔎㔏㔑㔕㔞㔣㔬㔱㔶抂;櫅ot;檽Ā;dᇚ㔚ot;櫃ult;櫁ĀEe㔨㔪;櫋;把lus;檿arr;楹ƀeiu㔽㕒㕕tƀ;en㔎㕅㕋qĀ;qᇚ㔏eqĀ;q㔫㔨m;櫇Ābp㕚㕜;櫕;櫓c̀;acensᇭ㕬㕲㕹㕻㌦pproø㋺urlyeñᇾñᇳƀaes㖂㖈㌛pproø㌚qñ㌗g;晪ڀ123;Edehlmnps㖩㖬㖯ሜ㖲㖴㗀㗉㗕㗚㗟㗨㗭耻¹䂹耻²䂲耻³䂳;櫆Āos㖹㖼t;檾ub;櫘Ā;dሢ㗅ot;櫄sĀou㗏㗒l;柉b;櫗arr;楻ult;櫂ĀEe㗤㗦;櫌;抋lus;櫀ƀeiu㗴㘉㘌tƀ;enሜ㗼㘂qĀ;qሢ㖲eqĀ;q㗧㗤m;櫈Ābp㘑㘓;櫔;櫖ƀAan㘜㘠㘭rr;懙rĀhr㘦㘨ë∮Ā;oਫ਩war;椪lig耻ß䃟௡㙑㙝㙠ዎ㙳㙹\0㙾㛂\0\0\0\0\0㛛㜃\0㜉㝬\0\0\0㞇ɲ㙖\0\0㙛get;挖;䏄rë๟ƀaey㙦㙫㙰ron;䅥dil;䅣;䑂lrec;挕r;쀀𝔱Ȁeiko㚆㚝㚵㚼Dz㚋\0㚑eĀ4fኄኁaƀ;sv㚘㚙㚛䎸ym;䏑Ācn㚢㚲kĀas㚨㚮pproø዁im»ኬsðኞĀas㚺㚮ð዁rn耻þ䃾Ǭ̟㛆⋧es膀×;bd㛏㛐㛘䃗Ā;aᤏ㛕r;樱;樰ƀeps㛡㛣㜀á⩍Ȁ;bcf҆㛬㛰㛴ot;挶ir;櫱Ā;o㛹㛼쀀𝕥rk;櫚á㍢rime;怴ƀaip㜏㜒㝤dåቈ΀adempst㜡㝍㝀㝑㝗㝜㝟ngleʀ;dlqr㜰㜱㜶㝀㝂斵own»ᶻeftĀ;e⠀㜾ñम;扜ightĀ;e㊪㝋ñၚot;旬inus;樺lus;樹b;槍ime;樻ezium;揢ƀcht㝲㝽㞁Āry㝷㝻;쀀𝓉;䑆cy;䑛rok;䅧Āio㞋㞎xô᝷headĀlr㞗㞠eftarro÷ࡏightarrow»ཝऀAHabcdfghlmoprstuw㟐㟓㟗㟤㟰㟼㠎㠜㠣㠴㡑㡝㡫㢩㣌㣒㣪㣶ròϭar;楣Ācr㟜㟢ute耻ú䃺òᅐrǣ㟪\0㟭y;䑞ve;䅭Āiy㟵㟺rc耻û䃻;䑃ƀabh㠃㠆㠋ròᎭlac;䅱aòᏃĀir㠓㠘sht;楾;쀀𝔲rave耻ù䃹š㠧㠱rĀlr㠬㠮»ॗ»ႃlk;斀Āct㠹㡍ɯ㠿\0\0㡊rnĀ;e㡅㡆挜r»㡆op;挏ri;旸Āal㡖㡚cr;䅫肻¨͉Āgp㡢㡦on;䅳f;쀀𝕦̀adhlsuᅋ㡸㡽፲㢑㢠ownáᎳarpoonĀlr㢈㢌efô㠭ighô㠯iƀ;hl㢙㢚㢜䏅»ᏺon»㢚parrows;懈ƀcit㢰㣄㣈ɯ㢶\0\0㣁rnĀ;e㢼㢽挝r»㢽op;挎ng;䅯ri;旹cr;쀀𝓊ƀdir㣙㣝㣢ot;拰lde;䅩iĀ;f㜰㣨»᠓Āam㣯㣲rò㢨l耻ü䃼angle;榧ހABDacdeflnoprsz㤜㤟㤩㤭㦵㦸㦽㧟㧤㧨㧳㧹㧽㨁㨠ròϷarĀ;v㤦㤧櫨;櫩asèϡĀnr㤲㤷grt;榜΀eknprst㓣㥆㥋㥒㥝㥤㦖appá␕othinçẖƀhir㓫⻈㥙opô⾵Ā;hᎷ㥢ïㆍĀiu㥩㥭gmá㎳Ābp㥲㦄setneqĀ;q㥽㦀쀀⊊︀;쀀⫋︀setneqĀ;q㦏㦒쀀⊋︀;쀀⫌︀Āhr㦛㦟etá㚜iangleĀlr㦪㦯eft»थight»ၑy;䐲ash»ံƀelr㧄㧒㧗ƀ;beⷪ㧋㧏ar;抻q;扚lip;拮Ābt㧜ᑨaòᑩr;쀀𝔳tré㦮suĀbp㧯㧱»ജ»൙pf;쀀𝕧roð໻tré㦴Ācu㨆㨋r;쀀𝓋Ābp㨐㨘nĀEe㦀㨖»㥾nĀEe㦒㨞»㦐igzag;榚΀cefoprs㨶㨻㩖㩛㩔㩡㩪irc;䅵Ādi㩀㩑Ābg㩅㩉ar;機eĀ;qᗺ㩏;扙erp;愘r;쀀𝔴pf;쀀𝕨Ā;eᑹ㩦atèᑹcr;쀀𝓌ૣណ㪇\0㪋\0㪐㪛\0\0㪝㪨㪫㪯\0\0㫃㫎\0㫘ៜ៟tré៑r;쀀𝔵ĀAa㪔㪗ròσrò৶;䎾ĀAa㪡㪤ròθrò৫að✓is;拻ƀdptឤ㪵㪾Āfl㪺ឩ;쀀𝕩imåឲĀAa㫇㫊ròώròਁĀcq㫒ីr;쀀𝓍Āpt៖㫜ré។Ѐacefiosu㫰㫽㬈㬌㬑㬕㬛㬡cĀuy㫶㫻te耻ý䃽;䑏Āiy㬂㬆rc;䅷;䑋n耻¥䂥r;쀀𝔶cy;䑗pf;쀀𝕪cr;쀀𝓎Ācm㬦㬩y;䑎l耻ÿ䃿Ԁacdefhiosw㭂㭈㭔㭘㭤㭩㭭㭴㭺㮀cute;䅺Āay㭍㭒ron;䅾;䐷ot;䅼Āet㭝㭡træᕟa;䎶r;쀀𝔷cy;䐶grarr;懝pf;쀀𝕫cr;쀀𝓏Ājn㮅㮇;怍j;怌'.split("").map(t=>t.charCodeAt(0))),dZ=new Uint16Array("Ȁaglq \x1Bɭ\0\0p;䀦os;䀧t;䀾t;䀼uot;䀢".split("").map(t=>t.charCodeAt(0)));var Zg;const fZ=new Map([[0,65533],[128,8364],[130,8218],[131,402],[132,8222],[133,8230],[134,8224],[135,8225],[136,710],[137,8240],[138,352],[139,8249],[140,338],[142,381],[145,8216],[146,8217],[147,8220],[148,8221],[149,8226],[150,8211],[151,8212],[152,732],[153,8482],[154,353],[155,8250],[156,339],[158,382],[159,376]]),hZ=(Zg=String.fromCodePoint)!==null&&Zg!==void 0?Zg:function(t){let e="";return t>65535&&(t-=65536,e+=String.fromCharCode(t>>>10&1023|55296),t=56320|t&1023),e+=String.fromCharCode(t),e};function pZ(t){var e;return t>=55296&&t<=57343||t>1114111?65533:(e=fZ.get(t))!==null&&e!==void 0?e:t}var Fn;(function(t){t[t.NUM=35]="NUM",t[t.SEMI=59]="SEMI",t[t.EQUALS=61]="EQUALS",t[t.ZERO=48]="ZERO",t[t.NINE=57]="NINE",t[t.LOWER_A=97]="LOWER_A",t[t.LOWER_F=102]="LOWER_F",t[t.LOWER_X=120]="LOWER_X",t[t.LOWER_Z=122]="LOWER_Z",t[t.UPPER_A=65]="UPPER_A",t[t.UPPER_F=70]="UPPER_F",t[t.UPPER_Z=90]="UPPER_Z"})(Fn||(Fn={}));const mZ=32;var ys;(function(t){t[t.VALUE_LENGTH=49152]="VALUE_LENGTH",t[t.BRANCH_LENGTH=16256]="BRANCH_LENGTH",t[t.JUMP_TABLE=127]="JUMP_TABLE"})(ys||(ys={}));function nb(t){return t>=Fn.ZERO&&t<=Fn.NINE}function gZ(t){return t>=Fn.UPPER_A&&t<=Fn.UPPER_F||t>=Fn.LOWER_A&&t<=Fn.LOWER_F}function vZ(t){return t>=Fn.UPPER_A&&t<=Fn.UPPER_Z||t>=Fn.LOWER_A&&t<=Fn.LOWER_Z||nb(t)}function bZ(t){return t===Fn.EQUALS||vZ(t)}var Nn;(function(t){t[t.EntityStart=0]="EntityStart",t[t.NumericStart=1]="NumericStart",t[t.NumericDecimal=2]="NumericDecimal",t[t.NumericHex=3]="NumericHex",t[t.NamedEntity=4]="NamedEntity"})(Nn||(Nn={}));var cs;(function(t){t[t.Legacy=0]="Legacy",t[t.Strict=1]="Strict",t[t.Attribute=2]="Attribute"})(cs||(cs={}));class yZ{constructor(e,n,r){this.decodeTree=e,this.emitCodePoint=n,this.errors=r,this.state=Nn.EntityStart,this.consumed=1,this.result=0,this.treeIndex=0,this.excess=1,this.decodeMode=cs.Strict}startEntity(e){this.decodeMode=e,this.state=Nn.EntityStart,this.result=0,this.treeIndex=0,this.excess=1,this.consumed=1}write(e,n){switch(this.state){case Nn.EntityStart:return e.charCodeAt(n)===Fn.NUM?(this.state=Nn.NumericStart,this.consumed+=1,this.stateNumericStart(e,n+1)):(this.state=Nn.NamedEntity,this.stateNamedEntity(e,n));case Nn.NumericStart:return this.stateNumericStart(e,n);case Nn.NumericDecimal:return this.stateNumericDecimal(e,n);case Nn.NumericHex:return this.stateNumericHex(e,n);case Nn.NamedEntity:return this.stateNamedEntity(e,n)}}stateNumericStart(e,n){return n>=e.length?-1:(e.charCodeAt(n)|mZ)===Fn.LOWER_X?(this.state=Nn.NumericHex,this.consumed+=1,this.stateNumericHex(e,n+1)):(this.state=Nn.NumericDecimal,this.stateNumericDecimal(e,n))}addToNumericResult(e,n,r,i){if(n!==r){const o=r-n;this.result=this.result*Math.pow(i,o)+parseInt(e.substr(n,o),i),this.consumed+=o}}stateNumericHex(e,n){const r=n;for(;n<e.length;){const i=e.charCodeAt(n);if(nb(i)||gZ(i))n+=1;else return this.addToNumericResult(e,r,n,16),this.emitNumericEntity(i,3)}return this.addToNumericResult(e,r,n,16),-1}stateNumericDecimal(e,n){const r=n;for(;n<e.length;){const i=e.charCodeAt(n);if(nb(i))n+=1;else return this.addToNumericResult(e,r,n,10),this.emitNumericEntity(i,2)}return this.addToNumericResult(e,r,n,10),-1}emitNumericEntity(e,n){var r;if(this.consumed<=n)return(r=this.errors)===null||r===void 0||r.absenceOfDigitsInNumericCharacterReference(this.consumed),0;if(e===Fn.SEMI)this.consumed+=1;else if(this.decodeMode===cs.Strict)return 0;return this.emitCodePoint(pZ(this.result),this.consumed),this.errors&&(e!==Fn.SEMI&&this.errors.missingSemicolonAfterCharacterReference(),this.errors.validateNumericCharacterReference(this.result)),this.consumed}stateNamedEntity(e,n){const{decodeTree:r}=this;let i=r[this.treeIndex],o=(i&ys.VALUE_LENGTH)>>14;for(;n<e.length;n++,this.excess++){const s=e.charCodeAt(n);if(this.treeIndex=wZ(r,i,this.treeIndex+Math.max(1,o),s),this.treeIndex<0)return this.result===0||this.decodeMode===cs.Attribute&&(o===0||bZ(s))?0:this.emitNotTerminatedNamedEntity();if(i=r[this.treeIndex],o=(i&ys.VALUE_LENGTH)>>14,o!==0){if(s===Fn.SEMI)return this.emitNamedEntityData(this.treeIndex,o,this.consumed+this.excess);this.decodeMode!==cs.Strict&&(this.result=this.treeIndex,this.consumed+=this.excess,this.excess=0)}}return-1}emitNotTerminatedNamedEntity(){var e;const{result:n,decodeTree:r}=this,i=(r[n]&ys.VALUE_LENGTH)>>14;return this.emitNamedEntityData(n,i,this.consumed),(e=this.errors)===null||e===void 0||e.missingSemicolonAfterCharacterReference(),this.consumed}emitNamedEntityData(e,n,r){const{decodeTree:i}=this;return this.emitCodePoint(n===1?i[e]&~ys.VALUE_LENGTH:i[e+1],r),n===3&&this.emitCodePoint(i[e+2],r),r}end(){var e;switch(this.state){case Nn.NamedEntity:return this.result!==0&&(this.decodeMode!==cs.Attribute||this.result===this.treeIndex)?this.emitNotTerminatedNamedEntity():0;case Nn.NumericDecimal:return this.emitNumericEntity(0,2);case Nn.NumericHex:return this.emitNumericEntity(0,3);case Nn.NumericStart:return(e=this.errors)===null||e===void 0||e.absenceOfDigitsInNumericCharacterReference(this.consumed),0;case Nn.EntityStart:return 0}}}function bT(t){let e="";const n=new yZ(t,r=>e+=hZ(r));return function(i,o){let s=0,a=0;for(;(a=i.indexOf("&",a))>=0;){e+=i.slice(s,a),n.startEntity(o);const c=n.write(i,a+1);if(c<0){s=a+n.end();break}s=a+c,a=c===0?s+1:s}const l=e+i.slice(s);return e="",l}}function wZ(t,e,n,r){const i=(e&ys.BRANCH_LENGTH)>>7,o=e&ys.JUMP_TABLE;if(i===0)return o!==0&&r===o?n:-1;if(o){const l=r-o;return l<0||l>=i?-1:t[n+l]-1}let s=n,a=s+i-1;for(;s<=a;){const l=s+a>>>1,c=t[l];if(c<r)s=l+1;else if(c>r)a=l-1;else return t[l+i]}return-1}const xZ=bT(uZ);bT(dZ);function yT(t,e=cs.Legacy){return xZ(t,e)}function kZ(t){return Object.prototype.toString.call(t)}function Q1(t){return kZ(t)==="[object String]"}const _Z=Object.prototype.hasOwnProperty;function CZ(t,e){return _Z.call(t,e)}function Om(t){return Array.prototype.slice.call(arguments,1).forEach(function(n){if(n){if(typeof n!="object")throw new TypeError(n+"must be object");Object.keys(n).forEach(function(r){t[r]=n[r]})}}),t}function wT(t,e,n){return[].concat(t.slice(0,e),n,t.slice(e+1))}function $1(t){return!(t>=55296&&t<=57343||t>=64976&&t<=65007||(t&65535)===65535||(t&65535)===65534||t>=0&&t<=8||t===11||t>=14&&t<=31||t>=127&&t<=159||t>1114111)}function Ep(t){if(t>65535){t-=65536;const e=55296+(t>>10),n=56320+(t&1023);return String.fromCharCode(e,n)}return String.fromCharCode(t)}const xT=/\\([!"#$%&'()*+,\-./:;<=>?@[\\\]^_`{|}~])/g,SZ=/&([a-z#][a-z0-9]{1,31});/gi,EZ=new RegExp(xT.source+"|"+SZ.source,"gi"),AZ=/^#((?:x[a-f0-9]{1,8}|[0-9]{1,8}))$/i;function TZ(t,e){if(e.charCodeAt(0)===35&&AZ.test(e)){const r=e[1].toLowerCase()==="x"?parseInt(e.slice(2),16):parseInt(e.slice(1),10);return $1(r)?Ep(r):t}const n=yT(t);return n!==t?n:t}function MZ(t){return t.indexOf("\\")<0?t:t.replace(xT,"$1")}function oc(t){return t.indexOf("\\")<0&&t.indexOf("&")<0?t:t.replace(EZ,function(e,n,r){return n||TZ(e,r)})}const DZ=/[&<>"]/,OZ=/[&<>"]/g,IZ={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;"};function RZ(t){return IZ[t]}function Ls(t){return DZ.test(t)?t.replace(OZ,RZ):t}const NZ=/[.?*+^$[\]\\(){}|-]/g;function PZ(t){return t.replace(NZ,"\\$&")}function $t(t){switch(t){case 9:case 32:return!0}return!1}function td(t){if(t>=8192&&t<=8202)return!0;switch(t){case 9:case 10:case 11:case 12:case 13:case 32:case 160:case 5760:case 8239:case 8287:case 12288:return!0}return!1}function nd(t){return X1.test(t)||gT.test(t)}function rd(t){switch(t){case 33:case 34:case 35:case 36:case 37:case 38:case 39:case 40:case 41:case 42:case 43:case 44:case 45:case 46:case 47:case 58:case 59:case 60:case 61:case 62:case 63:case 64:case 91:case 92:case 93:case 94:case 95:case 96:case 123:case 124:case 125:case 126:return!0;default:return!1}}function Im(t){return t=t.trim().replace(/\s+/g," "),"ẞ".toLowerCase()==="Ṿ"&&(t=t.replace(/ẞ/g,"ß")),t.toLowerCase().toUpperCase()}const LZ={mdurl:aZ,ucmicro:cZ},FZ=Object.freeze(Object.defineProperty({__proto__:null,arrayReplaceAt:wT,assign:Om,escapeHtml:Ls,escapeRE:PZ,fromCodePoint:Ep,has:CZ,isMdAsciiPunct:rd,isPunctChar:nd,isSpace:$t,isString:Q1,isValidEntityCode:$1,isWhiteSpace:td,lib:LZ,normalizeReference:Im,unescapeAll:oc,unescapeMd:MZ},Symbol.toStringTag,{value:"Module"}));function zZ(t,e,n){let r,i,o,s;const a=t.posMax,l=t.pos;for(t.pos=e+1,r=1;t.pos<a;){if(o=t.src.charCodeAt(t.pos),o===93&&(r--,r===0)){i=!0;break}if(s=t.pos,t.md.inline.skipToken(t),o===91){if(s===t.pos-1)r++;else if(n)return t.pos=l,-1}}let c=-1;return i&&(c=t.pos),t.pos=l,c}function BZ(t,e,n){let r,i=e;const o={ok:!1,pos:0,str:""};if(t.charCodeAt(i)===60){for(i++;i<n;){if(r=t.charCodeAt(i),r===10||r===60)return o;if(r===62)return o.pos=i+1,o.str=oc(t.slice(e+1,i)),o.ok=!0,o;if(r===92&&i+1<n){i+=2;continue}i++}return o}let s=0;for(;i<n&&(r=t.charCodeAt(i),!(r===32||r<32||r===127));){if(r===92&&i+1<n){if(t.charCodeAt(i+1)===32)break;i+=2;continue}if(r===40&&(s++,s>32))return o;if(r===41){if(s===0)break;s--}i++}return e===i||s!==0||(o.str=oc(t.slice(e,i)),o.pos=i,o.ok=!0),o}function HZ(t,e,n,r){let i,o=e;const s={ok:!1,can_continue:!1,pos:0,str:"",marker:0};if(r)s.str=r.str,s.marker=r.marker;else{if(o>=n)return s;let a=t.charCodeAt(o);if(a!==34&&a!==39&&a!==40)return s;e++,o++,a===40&&(a=41),s.marker=a}for(;o<n;){if(i=t.charCodeAt(o),i===s.marker)return s.pos=o+1,s.str+=oc(t.slice(e,o)),s.ok=!0,s;if(i===40&&s.marker===41)return s;i===92&&o+1<n&&o++,o++}return s.can_continue=!0,s.str+=oc(t.slice(e,o)),s}const VZ=Object.freeze(Object.defineProperty({__proto__:null,parseLinkDestination:BZ,parseLinkLabel:zZ,parseLinkTitle:HZ},Symbol.toStringTag,{value:"Module"})),ho={};ho.code_inline=function(t,e,n,r,i){const o=t[e];return"<code"+i.renderAttrs(o)+">"+Ls(o.content)+"</code>"};ho.code_block=function(t,e,n,r,i){const o=t[e];return"<pre"+i.renderAttrs(o)+"><code>"+Ls(t[e].content)+`</code></pre>
203
+ `};ho.fence=function(t,e,n,r,i){const o=t[e],s=o.info?oc(o.info).trim():"";let a="",l="";if(s){const u=s.split(/(\s+)/g);a=u[0],l=u.slice(2).join("")}let c;if(n.highlight?c=n.highlight(o.content,a,l)||Ls(o.content):c=Ls(o.content),c.indexOf("<pre")===0)return c+`
204
+ `;if(s){const u=o.attrIndex("class"),f=o.attrs?o.attrs.slice():[];u<0?f.push(["class",n.langPrefix+a]):(f[u]=f[u].slice(),f[u][1]+=" "+n.langPrefix+a);const h={attrs:f};return`<pre><code${i.renderAttrs(h)}>${c}</code></pre>
205
+ `}return`<pre><code${i.renderAttrs(o)}>${c}</code></pre>
206
+ `};ho.image=function(t,e,n,r,i){const o=t[e];return o.attrs[o.attrIndex("alt")][1]=i.renderInlineAsText(o.children,n,r),i.renderToken(t,e,n)};ho.hardbreak=function(t,e,n){return n.xhtmlOut?`<br />
207
+ `:`<br>
208
+ `};ho.softbreak=function(t,e,n){return n.breaks?n.xhtmlOut?`<br />
209
+ `:`<br>
210
+ `:`
211
+ `};ho.text=function(t,e){return Ls(t[e].content)};ho.html_block=function(t,e){return t[e].content};ho.html_inline=function(t,e){return t[e].content};function xc(){this.rules=Om({},ho)}xc.prototype.renderAttrs=function(e){let n,r,i;if(!e.attrs)return"";for(i="",n=0,r=e.attrs.length;n<r;n++)i+=" "+Ls(e.attrs[n][0])+'="'+Ls(e.attrs[n][1])+'"';return i};xc.prototype.renderToken=function(e,n,r){const i=e[n];let o="";if(i.hidden)return"";i.block&&i.nesting!==-1&&n&&e[n-1].hidden&&(o+=`
212
+ `),o+=(i.nesting===-1?"</":"<")+i.tag,o+=this.renderAttrs(i),i.nesting===0&&r.xhtmlOut&&(o+=" /");let s=!1;if(i.block&&(s=!0,i.nesting===1&&n+1<e.length)){const a=e[n+1];(a.type==="inline"||a.hidden||a.nesting===-1&&a.tag===i.tag)&&(s=!1)}return o+=s?`>
213
+ `:">",o};xc.prototype.renderInline=function(t,e,n){let r="";const i=this.rules;for(let o=0,s=t.length;o<s;o++){const a=t[o].type;typeof i[a]<"u"?r+=i[a](t,o,e,n,this):r+=this.renderToken(t,o,e)}return r};xc.prototype.renderInlineAsText=function(t,e,n){let r="";for(let i=0,o=t.length;i<o;i++)switch(t[i].type){case"text":r+=t[i].content;break;case"image":r+=this.renderInlineAsText(t[i].children,e,n);break;case"html_inline":case"html_block":r+=t[i].content;break;case"softbreak":case"hardbreak":r+=`
214
+ `;break}return r};xc.prototype.render=function(t,e,n){let r="";const i=this.rules;for(let o=0,s=t.length;o<s;o++){const a=t[o].type;a==="inline"?r+=this.renderInline(t[o].children,e,n):typeof i[a]<"u"?r+=i[a](t,o,e,n,this):r+=this.renderToken(t,o,e,n)}return r};function Mr(){this.__rules__=[],this.__cache__=null}Mr.prototype.__find__=function(t){for(let e=0;e<this.__rules__.length;e++)if(this.__rules__[e].name===t)return e;return-1};Mr.prototype.__compile__=function(){const t=this,e=[""];t.__rules__.forEach(function(n){n.enabled&&n.alt.forEach(function(r){e.indexOf(r)<0&&e.push(r)})}),t.__cache__={},e.forEach(function(n){t.__cache__[n]=[],t.__rules__.forEach(function(r){r.enabled&&(n&&r.alt.indexOf(n)<0||t.__cache__[n].push(r.fn))})})};Mr.prototype.at=function(t,e,n){const r=this.__find__(t),i=n||{};if(r===-1)throw new Error("Parser rule not found: "+t);this.__rules__[r].fn=e,this.__rules__[r].alt=i.alt||[],this.__cache__=null};Mr.prototype.before=function(t,e,n,r){const i=this.__find__(t),o=r||{};if(i===-1)throw new Error("Parser rule not found: "+t);this.__rules__.splice(i,0,{name:e,enabled:!0,fn:n,alt:o.alt||[]}),this.__cache__=null};Mr.prototype.after=function(t,e,n,r){const i=this.__find__(t),o=r||{};if(i===-1)throw new Error("Parser rule not found: "+t);this.__rules__.splice(i+1,0,{name:e,enabled:!0,fn:n,alt:o.alt||[]}),this.__cache__=null};Mr.prototype.push=function(t,e,n){const r=n||{};this.__rules__.push({name:t,enabled:!0,fn:e,alt:r.alt||[]}),this.__cache__=null};Mr.prototype.enable=function(t,e){Array.isArray(t)||(t=[t]);const n=[];return t.forEach(function(r){const i=this.__find__(r);if(i<0){if(e)return;throw new Error("Rules manager: invalid rule name "+r)}this.__rules__[i].enabled=!0,n.push(r)},this),this.__cache__=null,n};Mr.prototype.enableOnly=function(t,e){Array.isArray(t)||(t=[t]),this.__rules__.forEach(function(n){n.enabled=!1}),this.enable(t,e)};Mr.prototype.disable=function(t,e){Array.isArray(t)||(t=[t]);const n=[];return t.forEach(function(r){const i=this.__find__(r);if(i<0){if(e)return;throw new Error("Rules manager: invalid rule name "+r)}this.__rules__[i].enabled=!1,n.push(r)},this),this.__cache__=null,n};Mr.prototype.getRules=function(t){return this.__cache__===null&&this.__compile__(),this.__cache__[t]||[]};function Li(t,e,n){this.type=t,this.tag=e,this.attrs=null,this.map=null,this.nesting=n,this.level=0,this.children=null,this.content="",this.markup="",this.info="",this.meta=null,this.block=!1,this.hidden=!1}Li.prototype.attrIndex=function(e){if(!this.attrs)return-1;const n=this.attrs;for(let r=0,i=n.length;r<i;r++)if(n[r][0]===e)return r;return-1};Li.prototype.attrPush=function(e){this.attrs?this.attrs.push(e):this.attrs=[e]};Li.prototype.attrSet=function(e,n){const r=this.attrIndex(e),i=[e,n];r<0?this.attrPush(i):this.attrs[r]=i};Li.prototype.attrGet=function(e){const n=this.attrIndex(e);let r=null;return n>=0&&(r=this.attrs[n][1]),r};Li.prototype.attrJoin=function(e,n){const r=this.attrIndex(e);r<0?this.attrPush([e,n]):this.attrs[r][1]=this.attrs[r][1]+" "+n};function kT(t,e,n){this.src=t,this.env=n,this.tokens=[],this.inlineMode=!1,this.md=e}kT.prototype.Token=Li;const UZ=/\r\n?|\n/g,jZ=/\0/g;function qZ(t){let e;e=t.src.replace(UZ,`
215
+ `),e=e.replace(jZ,"�"),t.src=e}function WZ(t){let e;t.inlineMode?(e=new t.Token("inline","",0),e.content=t.src,e.map=[0,1],e.children=[],t.tokens.push(e)):t.md.block.parse(t.src,t.md,t.env,t.tokens)}function KZ(t){const e=t.tokens;for(let n=0,r=e.length;n<r;n++){const i=e[n];i.type==="inline"&&t.md.inline.parse(i.content,t.md,t.env,i.children)}}function GZ(t){return/^<a[>\s]/i.test(t)}function ZZ(t){return/^<\/a\s*>/i.test(t)}function YZ(t){const e=t.tokens;if(t.md.options.linkify)for(let n=0,r=e.length;n<r;n++){if(e[n].type!=="inline"||!t.md.linkify.pretest(e[n].content))continue;let i=e[n].children,o=0;for(let s=i.length-1;s>=0;s--){const a=i[s];if(a.type==="link_close"){for(s--;i[s].level!==a.level&&i[s].type!=="link_open";)s--;continue}if(a.type==="html_inline"&&(GZ(a.content)&&o>0&&o--,ZZ(a.content)&&o++),!(o>0)&&a.type==="text"&&t.md.linkify.test(a.content)){const l=a.content;let c=t.md.linkify.match(l);const u=[];let f=a.level,h=0;c.length>0&&c[0].index===0&&s>0&&i[s-1].type==="text_special"&&(c=c.slice(1));for(let p=0;p<c.length;p++){const m=c[p].url,v=t.md.normalizeLink(m);if(!t.md.validateLink(v))continue;let g=c[p].text;c[p].schema?c[p].schema==="mailto:"&&!/^mailto:/i.test(g)?g=t.md.normalizeLinkText("mailto:"+g).replace(/^mailto:/,""):g=t.md.normalizeLinkText(g):g=t.md.normalizeLinkText("http://"+g).replace(/^http:\/\//,"");const b=c[p].index;if(b>h){const E=new t.Token("text","",0);E.content=l.slice(h,b),E.level=f,u.push(E)}const _=new t.Token("link_open","a",1);_.attrs=[["href",v]],_.level=f++,_.markup="linkify",_.info="auto",u.push(_);const k=new t.Token("text","",0);k.content=g,k.level=f,u.push(k);const C=new t.Token("link_close","a",-1);C.level=--f,C.markup="linkify",C.info="auto",u.push(C),h=c[p].lastIndex}if(h<l.length){const p=new t.Token("text","",0);p.content=l.slice(h),p.level=f,u.push(p)}e[n].children=i=wT(i,s,u)}}}}const _T=/\+-|\.\.|\?\?\?\?|!!!!|,,|--/,JZ=/\((c|tm|r)\)/i,XZ=/\((c|tm|r)\)/ig,QZ={c:"©",r:"®",tm:"™"};function $Z(t,e){return QZ[e.toLowerCase()]}function eY(t){let e=0;for(let n=t.length-1;n>=0;n--){const r=t[n];r.type==="text"&&!e&&(r.content=r.content.replace(XZ,$Z)),r.type==="link_open"&&r.info==="auto"&&e--,r.type==="link_close"&&r.info==="auto"&&e++}}function tY(t){let e=0;for(let n=t.length-1;n>=0;n--){const r=t[n];r.type==="text"&&!e&&_T.test(r.content)&&(r.content=r.content.replace(/\+-/g,"±").replace(/\.{2,}/g,"…").replace(/([?!])…/g,"$1..").replace(/([?!]){4,}/g,"$1$1$1").replace(/,{2,}/g,",").replace(/(^|[^-])---(?=[^-]|$)/mg,"$1—").replace(/(^|\s)--(?=\s|$)/mg,"$1–").replace(/(^|[^-\s])--(?=[^-\s]|$)/mg,"$1–")),r.type==="link_open"&&r.info==="auto"&&e--,r.type==="link_close"&&r.info==="auto"&&e++}}function nY(t){let e;if(t.md.options.typographer)for(e=t.tokens.length-1;e>=0;e--)t.tokens[e].type==="inline"&&(JZ.test(t.tokens[e].content)&&eY(t.tokens[e].children),_T.test(t.tokens[e].content)&&tY(t.tokens[e].children))}const rY=/['"]/,e2=/['"]/g,t2="’";function xf(t,e,n){return t.slice(0,e)+n+t.slice(e+1)}function iY(t,e){let n;const r=[];for(let i=0;i<t.length;i++){const o=t[i],s=t[i].level;for(n=r.length-1;n>=0&&!(r[n].level<=s);n--);if(r.length=n+1,o.type!=="text")continue;let a=o.content,l=0,c=a.length;e:for(;l<c;){e2.lastIndex=l;const u=e2.exec(a);if(!u)break;let f=!0,h=!0;l=u.index+1;const p=u[0]==="'";let m=32;if(u.index-1>=0)m=a.charCodeAt(u.index-1);else for(n=i-1;n>=0&&!(t[n].type==="softbreak"||t[n].type==="hardbreak");n--)if(t[n].content){m=t[n].content.charCodeAt(t[n].content.length-1);break}let v=32;if(l<c)v=a.charCodeAt(l);else for(n=i+1;n<t.length&&!(t[n].type==="softbreak"||t[n].type==="hardbreak");n++)if(t[n].content){v=t[n].content.charCodeAt(0);break}const g=rd(m)||nd(String.fromCharCode(m)),b=rd(v)||nd(String.fromCharCode(v)),_=td(m),k=td(v);if(k?f=!1:b&&(_||g||(f=!1)),_?h=!1:g&&(k||b||(h=!1)),v===34&&u[0]==='"'&&m>=48&&m<=57&&(h=f=!1),f&&h&&(f=g,h=b),!f&&!h){p&&(o.content=xf(o.content,u.index,t2));continue}if(h)for(n=r.length-1;n>=0;n--){let C=r[n];if(r[n].level<s)break;if(C.single===p&&r[n].level===s){C=r[n];let E,I;p?(E=e.md.options.quotes[2],I=e.md.options.quotes[3]):(E=e.md.options.quotes[0],I=e.md.options.quotes[1]),o.content=xf(o.content,u.index,I),t[C.token].content=xf(t[C.token].content,C.pos,E),l+=I.length-1,C.token===i&&(l+=E.length-1),a=o.content,c=a.length,r.length=n;continue e}}f?r.push({token:i,pos:u.index,single:p,level:s}):h&&p&&(o.content=xf(o.content,u.index,t2))}}}function oY(t){if(t.md.options.typographer)for(let e=t.tokens.length-1;e>=0;e--)t.tokens[e].type!=="inline"||!rY.test(t.tokens[e].content)||iY(t.tokens[e].children,t)}function sY(t){let e,n;const r=t.tokens,i=r.length;for(let o=0;o<i;o++){if(r[o].type!=="inline")continue;const s=r[o].children,a=s.length;for(e=0;e<a;e++)s[e].type==="text_special"&&(s[e].type="text");for(e=n=0;e<a;e++)s[e].type==="text"&&e+1<a&&s[e+1].type==="text"?s[e+1].content=s[e].content+s[e+1].content:(e!==n&&(s[n]=s[e]),n++);e!==n&&(s.length=n)}}const Yg=[["normalize",qZ],["block",WZ],["inline",KZ],["linkify",YZ],["replacements",nY],["smartquotes",oY],["text_join",sY]];function ey(){this.ruler=new Mr;for(let t=0;t<Yg.length;t++)this.ruler.push(Yg[t][0],Yg[t][1])}ey.prototype.process=function(t){const e=this.ruler.getRules("");for(let n=0,r=e.length;n<r;n++)e[n](t)};ey.prototype.State=kT;function po(t,e,n,r){this.src=t,this.md=e,this.env=n,this.tokens=r,this.bMarks=[],this.eMarks=[],this.tShift=[],this.sCount=[],this.bsCount=[],this.blkIndent=0,this.line=0,this.lineMax=0,this.tight=!1,this.ddIndent=-1,this.listIndent=-1,this.parentType="root",this.level=0;const i=this.src;for(let o=0,s=0,a=0,l=0,c=i.length,u=!1;s<c;s++){const f=i.charCodeAt(s);if(!u)if($t(f)){a++,f===9?l+=4-l%4:l++;continue}else u=!0;(f===10||s===c-1)&&(f!==10&&s++,this.bMarks.push(o),this.eMarks.push(s),this.tShift.push(a),this.sCount.push(l),this.bsCount.push(0),u=!1,a=0,l=0,o=s+1)}this.bMarks.push(i.length),this.eMarks.push(i.length),this.tShift.push(0),this.sCount.push(0),this.bsCount.push(0),this.lineMax=this.bMarks.length-1}po.prototype.push=function(t,e,n){const r=new Li(t,e,n);return r.block=!0,n<0&&this.level--,r.level=this.level,n>0&&this.level++,this.tokens.push(r),r};po.prototype.isEmpty=function(e){return this.bMarks[e]+this.tShift[e]>=this.eMarks[e]};po.prototype.skipEmptyLines=function(e){for(let n=this.lineMax;e<n&&!(this.bMarks[e]+this.tShift[e]<this.eMarks[e]);e++);return e};po.prototype.skipSpaces=function(e){for(let n=this.src.length;e<n;e++){const r=this.src.charCodeAt(e);if(!$t(r))break}return e};po.prototype.skipSpacesBack=function(e,n){if(e<=n)return e;for(;e>n;)if(!$t(this.src.charCodeAt(--e)))return e+1;return e};po.prototype.skipChars=function(e,n){for(let r=this.src.length;e<r&&this.src.charCodeAt(e)===n;e++);return e};po.prototype.skipCharsBack=function(e,n,r){if(e<=r)return e;for(;e>r;)if(n!==this.src.charCodeAt(--e))return e+1;return e};po.prototype.getLines=function(e,n,r,i){if(e>=n)return"";const o=new Array(n-e);for(let s=0,a=e;a<n;a++,s++){let l=0;const c=this.bMarks[a];let u=c,f;for(a+1<n||i?f=this.eMarks[a]+1:f=this.eMarks[a];u<f&&l<r;){const h=this.src.charCodeAt(u);if($t(h))h===9?l+=4-(l+this.bsCount[a])%4:l++;else if(u-c<this.tShift[a])l++;else break;u++}l>r?o[s]=new Array(l-r+1).join(" ")+this.src.slice(u,f):o[s]=this.src.slice(u,f)}return o.join("")};po.prototype.Token=Li;const aY=65536;function Jg(t,e){const n=t.bMarks[e]+t.tShift[e],r=t.eMarks[e];return t.src.slice(n,r)}function n2(t){const e=[],n=t.length;let r=0,i=t.charCodeAt(r),o=!1,s=0,a="";for(;r<n;)i===124&&(o?(a+=t.substring(s,r-1),s=r):(e.push(a+t.substring(s,r)),a="",s=r+1)),o=i===92,r++,i=t.charCodeAt(r);return e.push(a+t.substring(s)),e}function lY(t,e,n,r){if(e+2>n)return!1;let i=e+1;if(t.sCount[i]<t.blkIndent||t.sCount[i]-t.blkIndent>=4)return!1;let o=t.bMarks[i]+t.tShift[i];if(o>=t.eMarks[i])return!1;const s=t.src.charCodeAt(o++);if(s!==124&&s!==45&&s!==58||o>=t.eMarks[i])return!1;const a=t.src.charCodeAt(o++);if(a!==124&&a!==45&&a!==58&&!$t(a)||s===45&&$t(a))return!1;for(;o<t.eMarks[i];){const C=t.src.charCodeAt(o);if(C!==124&&C!==45&&C!==58&&!$t(C))return!1;o++}let l=Jg(t,e+1),c=l.split("|");const u=[];for(let C=0;C<c.length;C++){const E=c[C].trim();if(!E){if(C===0||C===c.length-1)continue;return!1}if(!/^:?-+:?$/.test(E))return!1;E.charCodeAt(E.length-1)===58?u.push(E.charCodeAt(0)===58?"center":"right"):E.charCodeAt(0)===58?u.push("left"):u.push("")}if(l=Jg(t,e).trim(),l.indexOf("|")===-1||t.sCount[e]-t.blkIndent>=4)return!1;c=n2(l),c.length&&c[0]===""&&c.shift(),c.length&&c[c.length-1]===""&&c.pop();const f=c.length;if(f===0||f!==u.length)return!1;if(r)return!0;const h=t.parentType;t.parentType="table";const p=t.md.block.ruler.getRules("blockquote"),m=t.push("table_open","table",1),v=[e,0];m.map=v;const g=t.push("thead_open","thead",1);g.map=[e,e+1];const b=t.push("tr_open","tr",1);b.map=[e,e+1];for(let C=0;C<c.length;C++){const E=t.push("th_open","th",1);u[C]&&(E.attrs=[["style","text-align:"+u[C]]]);const I=t.push("inline","",0);I.content=c[C].trim(),I.children=[],t.push("th_close","th",-1)}t.push("tr_close","tr",-1),t.push("thead_close","thead",-1);let _,k=0;for(i=e+2;i<n&&!(t.sCount[i]<t.blkIndent);i++){let C=!1;for(let I=0,A=p.length;I<A;I++)if(p[I](t,i,n,!0)){C=!0;break}if(C||(l=Jg(t,i).trim(),!l)||t.sCount[i]-t.blkIndent>=4||(c=n2(l),c.length&&c[0]===""&&c.shift(),c.length&&c[c.length-1]===""&&c.pop(),k+=f-c.length,k>aY))break;if(i===e+2){const I=t.push("tbody_open","tbody",1);I.map=_=[e+2,0]}const E=t.push("tr_open","tr",1);E.map=[i,i+1];for(let I=0;I<f;I++){const A=t.push("td_open","td",1);u[I]&&(A.attrs=[["style","text-align:"+u[I]]]);const M=t.push("inline","",0);M.content=c[I]?c[I].trim():"",M.children=[],t.push("td_close","td",-1)}t.push("tr_close","tr",-1)}return _&&(t.push("tbody_close","tbody",-1),_[1]=i),t.push("table_close","table",-1),v[1]=i,t.parentType=h,t.line=i,!0}function cY(t,e,n){if(t.sCount[e]-t.blkIndent<4)return!1;let r=e+1,i=r;for(;r<n;){if(t.isEmpty(r)){r++;continue}if(t.sCount[r]-t.blkIndent>=4){r++,i=r;continue}break}t.line=i;const o=t.push("code_block","code",0);return o.content=t.getLines(e,i,4+t.blkIndent,!1)+`
216
+ `,o.map=[e,t.line],!0}function uY(t,e,n,r){let i=t.bMarks[e]+t.tShift[e],o=t.eMarks[e];if(t.sCount[e]-t.blkIndent>=4||i+3>o)return!1;const s=t.src.charCodeAt(i);if(s!==126&&s!==96)return!1;let a=i;i=t.skipChars(i,s);let l=i-a;if(l<3)return!1;const c=t.src.slice(a,i),u=t.src.slice(i,o);if(s===96&&u.indexOf(String.fromCharCode(s))>=0)return!1;if(r)return!0;let f=e,h=!1;for(;f++,!(f>=n||(i=a=t.bMarks[f]+t.tShift[f],o=t.eMarks[f],i<o&&t.sCount[f]<t.blkIndent));)if(t.src.charCodeAt(i)===s&&!(t.sCount[f]-t.blkIndent>=4)&&(i=t.skipChars(i,s),!(i-a<l)&&(i=t.skipSpaces(i),!(i<o)))){h=!0;break}l=t.sCount[e],t.line=f+(h?1:0);const p=t.push("fence","code",0);return p.info=u,p.content=t.getLines(e+1,f,l,!0),p.markup=c,p.map=[e,t.line],!0}function dY(t,e,n,r){let i=t.bMarks[e]+t.tShift[e],o=t.eMarks[e];const s=t.lineMax;if(t.sCount[e]-t.blkIndent>=4||t.src.charCodeAt(i)!==62)return!1;if(r)return!0;const a=[],l=[],c=[],u=[],f=t.md.block.ruler.getRules("blockquote"),h=t.parentType;t.parentType="blockquote";let p=!1,m;for(m=e;m<n;m++){const k=t.sCount[m]<t.blkIndent;if(i=t.bMarks[m]+t.tShift[m],o=t.eMarks[m],i>=o)break;if(t.src.charCodeAt(i++)===62&&!k){let E=t.sCount[m]+1,I,A;t.src.charCodeAt(i)===32?(i++,E++,A=!1,I=!0):t.src.charCodeAt(i)===9?(I=!0,(t.bsCount[m]+E)%4===3?(i++,E++,A=!1):A=!0):I=!1;let M=E;for(a.push(t.bMarks[m]),t.bMarks[m]=i;i<o;){const N=t.src.charCodeAt(i);if($t(N))N===9?M+=4-(M+t.bsCount[m]+(A?1:0))%4:M++;else break;i++}p=i>=o,l.push(t.bsCount[m]),t.bsCount[m]=t.sCount[m]+1+(I?1:0),c.push(t.sCount[m]),t.sCount[m]=M-E,u.push(t.tShift[m]),t.tShift[m]=i-t.bMarks[m];continue}if(p)break;let C=!1;for(let E=0,I=f.length;E<I;E++)if(f[E](t,m,n,!0)){C=!0;break}if(C){t.lineMax=m,t.blkIndent!==0&&(a.push(t.bMarks[m]),l.push(t.bsCount[m]),u.push(t.tShift[m]),c.push(t.sCount[m]),t.sCount[m]-=t.blkIndent);break}a.push(t.bMarks[m]),l.push(t.bsCount[m]),u.push(t.tShift[m]),c.push(t.sCount[m]),t.sCount[m]=-1}const v=t.blkIndent;t.blkIndent=0;const g=t.push("blockquote_open","blockquote",1);g.markup=">";const b=[e,0];g.map=b,t.md.block.tokenize(t,e,m);const _=t.push("blockquote_close","blockquote",-1);_.markup=">",t.lineMax=s,t.parentType=h,b[1]=t.line;for(let k=0;k<u.length;k++)t.bMarks[k+e]=a[k],t.tShift[k+e]=u[k],t.sCount[k+e]=c[k],t.bsCount[k+e]=l[k];return t.blkIndent=v,!0}function fY(t,e,n,r){const i=t.eMarks[e];if(t.sCount[e]-t.blkIndent>=4)return!1;let o=t.bMarks[e]+t.tShift[e];const s=t.src.charCodeAt(o++);if(s!==42&&s!==45&&s!==95)return!1;let a=1;for(;o<i;){const c=t.src.charCodeAt(o++);if(c!==s&&!$t(c))return!1;c===s&&a++}if(a<3)return!1;if(r)return!0;t.line=e+1;const l=t.push("hr","hr",0);return l.map=[e,t.line],l.markup=Array(a+1).join(String.fromCharCode(s)),!0}function r2(t,e){const n=t.eMarks[e];let r=t.bMarks[e]+t.tShift[e];const i=t.src.charCodeAt(r++);if(i!==42&&i!==45&&i!==43)return-1;if(r<n){const o=t.src.charCodeAt(r);if(!$t(o))return-1}return r}function i2(t,e){const n=t.bMarks[e]+t.tShift[e],r=t.eMarks[e];let i=n;if(i+1>=r)return-1;let o=t.src.charCodeAt(i++);if(o<48||o>57)return-1;for(;;){if(i>=r)return-1;if(o=t.src.charCodeAt(i++),o>=48&&o<=57){if(i-n>=10)return-1;continue}if(o===41||o===46)break;return-1}return i<r&&(o=t.src.charCodeAt(i),!$t(o))?-1:i}function hY(t,e){const n=t.level+2;for(let r=e+2,i=t.tokens.length-2;r<i;r++)t.tokens[r].level===n&&t.tokens[r].type==="paragraph_open"&&(t.tokens[r+2].hidden=!0,t.tokens[r].hidden=!0,r+=2)}function pY(t,e,n,r){let i,o,s,a,l=e,c=!0;if(t.sCount[l]-t.blkIndent>=4||t.listIndent>=0&&t.sCount[l]-t.listIndent>=4&&t.sCount[l]<t.blkIndent)return!1;let u=!1;r&&t.parentType==="paragraph"&&t.sCount[l]>=t.blkIndent&&(u=!0);let f,h,p;if((p=i2(t,l))>=0){if(f=!0,s=t.bMarks[l]+t.tShift[l],h=Number(t.src.slice(s,p-1)),u&&h!==1)return!1}else if((p=r2(t,l))>=0)f=!1;else return!1;if(u&&t.skipSpaces(p)>=t.eMarks[l])return!1;if(r)return!0;const m=t.src.charCodeAt(p-1),v=t.tokens.length;f?(a=t.push("ordered_list_open","ol",1),h!==1&&(a.attrs=[["start",h]])):a=t.push("bullet_list_open","ul",1);const g=[l,0];a.map=g,a.markup=String.fromCharCode(m);let b=!1;const _=t.md.block.ruler.getRules("list"),k=t.parentType;for(t.parentType="list";l<n;){o=p,i=t.eMarks[l];const C=t.sCount[l]+p-(t.bMarks[l]+t.tShift[l]);let E=C;for(;o<i;){const X=t.src.charCodeAt(o);if(X===9)E+=4-(E+t.bsCount[l])%4;else if(X===32)E++;else break;o++}const I=o;let A;I>=i?A=1:A=E-C,A>4&&(A=1);const M=C+A;a=t.push("list_item_open","li",1),a.markup=String.fromCharCode(m);const N=[l,0];a.map=N,f&&(a.info=t.src.slice(s,p-1));const R=t.tight,B=t.tShift[l],Z=t.sCount[l],q=t.listIndent;if(t.listIndent=t.blkIndent,t.blkIndent=M,t.tight=!0,t.tShift[l]=I-t.bMarks[l],t.sCount[l]=E,I>=i&&t.isEmpty(l+1)?t.line=Math.min(t.line+2,n):t.md.block.tokenize(t,l,n,!0),(!t.tight||b)&&(c=!1),b=t.line-l>1&&t.isEmpty(t.line-1),t.blkIndent=t.listIndent,t.listIndent=q,t.tShift[l]=B,t.sCount[l]=Z,t.tight=R,a=t.push("list_item_close","li",-1),a.markup=String.fromCharCode(m),l=t.line,N[1]=l,l>=n||t.sCount[l]<t.blkIndent||t.sCount[l]-t.blkIndent>=4)break;let Y=!1;for(let X=0,ae=_.length;X<ae;X++)if(_[X](t,l,n,!0)){Y=!0;break}if(Y)break;if(f){if(p=i2(t,l),p<0)break;s=t.bMarks[l]+t.tShift[l]}else if(p=r2(t,l),p<0)break;if(m!==t.src.charCodeAt(p-1))break}return f?a=t.push("ordered_list_close","ol",-1):a=t.push("bullet_list_close","ul",-1),a.markup=String.fromCharCode(m),g[1]=l,t.line=l,t.parentType=k,c&&hY(t,v),!0}function mY(t,e,n,r){let i=t.bMarks[e]+t.tShift[e],o=t.eMarks[e],s=e+1;if(t.sCount[e]-t.blkIndent>=4||t.src.charCodeAt(i)!==91)return!1;function a(_){const k=t.lineMax;if(_>=k||t.isEmpty(_))return null;let C=!1;if(t.sCount[_]-t.blkIndent>3&&(C=!0),t.sCount[_]<0&&(C=!0),!C){const A=t.md.block.ruler.getRules("reference"),M=t.parentType;t.parentType="reference";let N=!1;for(let R=0,B=A.length;R<B;R++)if(A[R](t,_,k,!0)){N=!0;break}if(t.parentType=M,N)return null}const E=t.bMarks[_]+t.tShift[_],I=t.eMarks[_];return t.src.slice(E,I+1)}let l=t.src.slice(i,o+1);o=l.length;let c=-1;for(i=1;i<o;i++){const _=l.charCodeAt(i);if(_===91)return!1;if(_===93){c=i;break}else if(_===10){const k=a(s);k!==null&&(l+=k,o=l.length,s++)}else if(_===92&&(i++,i<o&&l.charCodeAt(i)===10)){const k=a(s);k!==null&&(l+=k,o=l.length,s++)}}if(c<0||l.charCodeAt(c+1)!==58)return!1;for(i=c+2;i<o;i++){const _=l.charCodeAt(i);if(_===10){const k=a(s);k!==null&&(l+=k,o=l.length,s++)}else if(!$t(_))break}const u=t.md.helpers.parseLinkDestination(l,i,o);if(!u.ok)return!1;const f=t.md.normalizeLink(u.str);if(!t.md.validateLink(f))return!1;i=u.pos;const h=i,p=s,m=i;for(;i<o;i++){const _=l.charCodeAt(i);if(_===10){const k=a(s);k!==null&&(l+=k,o=l.length,s++)}else if(!$t(_))break}let v=t.md.helpers.parseLinkTitle(l,i,o);for(;v.can_continue;){const _=a(s);if(_===null)break;l+=_,i=o,o=l.length,s++,v=t.md.helpers.parseLinkTitle(l,i,o,v)}let g;for(i<o&&m!==i&&v.ok?(g=v.str,i=v.pos):(g="",i=h,s=p);i<o;){const _=l.charCodeAt(i);if(!$t(_))break;i++}if(i<o&&l.charCodeAt(i)!==10&&g)for(g="",i=h,s=p;i<o;){const _=l.charCodeAt(i);if(!$t(_))break;i++}if(i<o&&l.charCodeAt(i)!==10)return!1;const b=Im(l.slice(1,c));return b?(r||(typeof t.env.references>"u"&&(t.env.references={}),typeof t.env.references[b]>"u"&&(t.env.references[b]={title:g,href:f}),t.line=s),!0):!1}const gY=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],vY="[a-zA-Z_:][a-zA-Z0-9:._-]*",bY="[^\"'=<>`\\x00-\\x20]+",yY="'[^']*'",wY='"[^"]*"',xY="(?:"+bY+"|"+yY+"|"+wY+")",kY="(?:\\s+"+vY+"(?:\\s*=\\s*"+xY+")?)",CT="<[A-Za-z][A-Za-z0-9\\-]*"+kY+"*\\s*\\/?>",ST="<\\/[A-Za-z][A-Za-z0-9\\-]*\\s*>",_Y="<!---?>|<!--(?:[^-]|-[^-]|--[^>])*-->",CY="<[?][\\s\\S]*?[?]>",SY="<![A-Za-z][^>]*>",EY="<!\\[CDATA\\[[\\s\\S]*?\\]\\]>",AY=new RegExp("^(?:"+CT+"|"+ST+"|"+_Y+"|"+CY+"|"+SY+"|"+EY+")"),TY=new RegExp("^(?:"+CT+"|"+ST+")"),Ja=[[/^<(script|pre|style|textarea)(?=(\s|>|$))/i,/<\/(script|pre|style|textarea)>/i,!0],[/^<!--/,/-->/,!0],[/^<\?/,/\?>/,!0],[/^<![A-Z]/,/>/,!0],[/^<!\[CDATA\[/,/\]\]>/,!0],[new RegExp("^</?("+gY.join("|")+")(?=(\\s|/?>|$))","i"),/^$/,!0],[new RegExp(TY.source+"\\s*$"),/^$/,!1]];function MY(t,e,n,r){let i=t.bMarks[e]+t.tShift[e],o=t.eMarks[e];if(t.sCount[e]-t.blkIndent>=4||!t.md.options.html||t.src.charCodeAt(i)!==60)return!1;let s=t.src.slice(i,o),a=0;for(;a<Ja.length&&!Ja[a][0].test(s);a++);if(a===Ja.length)return!1;if(r)return Ja[a][2];let l=e+1;if(!Ja[a][1].test(s)){for(;l<n&&!(t.sCount[l]<t.blkIndent);l++)if(i=t.bMarks[l]+t.tShift[l],o=t.eMarks[l],s=t.src.slice(i,o),Ja[a][1].test(s)){s.length!==0&&l++;break}}t.line=l;const c=t.push("html_block","",0);return c.map=[e,l],c.content=t.getLines(e,l,t.blkIndent,!0),!0}function DY(t,e,n,r){let i=t.bMarks[e]+t.tShift[e],o=t.eMarks[e];if(t.sCount[e]-t.blkIndent>=4)return!1;let s=t.src.charCodeAt(i);if(s!==35||i>=o)return!1;let a=1;for(s=t.src.charCodeAt(++i);s===35&&i<o&&a<=6;)a++,s=t.src.charCodeAt(++i);if(a>6||i<o&&!$t(s))return!1;if(r)return!0;o=t.skipSpacesBack(o,i);const l=t.skipCharsBack(o,35,i);l>i&&$t(t.src.charCodeAt(l-1))&&(o=l),t.line=e+1;const c=t.push("heading_open","h"+String(a),1);c.markup="########".slice(0,a),c.map=[e,t.line];const u=t.push("inline","",0);u.content=t.src.slice(i,o).trim(),u.map=[e,t.line],u.children=[];const f=t.push("heading_close","h"+String(a),-1);return f.markup="########".slice(0,a),!0}function OY(t,e,n){const r=t.md.block.ruler.getRules("paragraph");if(t.sCount[e]-t.blkIndent>=4)return!1;const i=t.parentType;t.parentType="paragraph";let o=0,s,a=e+1;for(;a<n&&!t.isEmpty(a);a++){if(t.sCount[a]-t.blkIndent>3)continue;if(t.sCount[a]>=t.blkIndent){let p=t.bMarks[a]+t.tShift[a];const m=t.eMarks[a];if(p<m&&(s=t.src.charCodeAt(p),(s===45||s===61)&&(p=t.skipChars(p,s),p=t.skipSpaces(p),p>=m))){o=s===61?1:2;break}}if(t.sCount[a]<0)continue;let h=!1;for(let p=0,m=r.length;p<m;p++)if(r[p](t,a,n,!0)){h=!0;break}if(h)break}if(!o)return!1;const l=t.getLines(e,a,t.blkIndent,!1).trim();t.line=a+1;const c=t.push("heading_open","h"+String(o),1);c.markup=String.fromCharCode(s),c.map=[e,t.line];const u=t.push("inline","",0);u.content=l,u.map=[e,t.line-1],u.children=[];const f=t.push("heading_close","h"+String(o),-1);return f.markup=String.fromCharCode(s),t.parentType=i,!0}function IY(t,e,n){const r=t.md.block.ruler.getRules("paragraph"),i=t.parentType;let o=e+1;for(t.parentType="paragraph";o<n&&!t.isEmpty(o);o++){if(t.sCount[o]-t.blkIndent>3||t.sCount[o]<0)continue;let c=!1;for(let u=0,f=r.length;u<f;u++)if(r[u](t,o,n,!0)){c=!0;break}if(c)break}const s=t.getLines(e,o,t.blkIndent,!1).trim();t.line=o;const a=t.push("paragraph_open","p",1);a.map=[e,t.line];const l=t.push("inline","",0);return l.content=s,l.map=[e,t.line],l.children=[],t.push("paragraph_close","p",-1),t.parentType=i,!0}const kf=[["table",lY,["paragraph","reference"]],["code",cY],["fence",uY,["paragraph","reference","blockquote","list"]],["blockquote",dY,["paragraph","reference","blockquote","list"]],["hr",fY,["paragraph","reference","blockquote","list"]],["list",pY,["paragraph","reference","blockquote"]],["reference",mY],["html_block",MY,["paragraph","reference","blockquote"]],["heading",DY,["paragraph","reference","blockquote"]],["lheading",OY],["paragraph",IY]];function Rm(){this.ruler=new Mr;for(let t=0;t<kf.length;t++)this.ruler.push(kf[t][0],kf[t][1],{alt:(kf[t][2]||[]).slice()})}Rm.prototype.tokenize=function(t,e,n){const r=this.ruler.getRules(""),i=r.length,o=t.md.options.maxNesting;let s=e,a=!1;for(;s<n&&(t.line=s=t.skipEmptyLines(s),!(s>=n||t.sCount[s]<t.blkIndent));){if(t.level>=o){t.line=n;break}const l=t.line;let c=!1;for(let u=0;u<i;u++)if(c=r[u](t,s,n,!1),c){if(l>=t.line)throw new Error("block rule didn't increment state.line");break}if(!c)throw new Error("none of the block rules matched");t.tight=!a,t.isEmpty(t.line-1)&&(a=!0),s=t.line,s<n&&t.isEmpty(s)&&(a=!0,s++,t.line=s)}};Rm.prototype.parse=function(t,e,n,r){if(!t)return;const i=new this.State(t,e,n,r);this.tokenize(i,i.line,i.lineMax)};Rm.prototype.State=po;function zd(t,e,n,r){this.src=t,this.env=n,this.md=e,this.tokens=r,this.tokens_meta=Array(r.length),this.pos=0,this.posMax=this.src.length,this.level=0,this.pending="",this.pendingLevel=0,this.cache={},this.delimiters=[],this._prev_delimiters=[],this.backticks={},this.backticksScanned=!1,this.linkLevel=0}zd.prototype.pushPending=function(){const t=new Li("text","",0);return t.content=this.pending,t.level=this.pendingLevel,this.tokens.push(t),this.pending="",t};zd.prototype.push=function(t,e,n){this.pending&&this.pushPending();const r=new Li(t,e,n);let i=null;return n<0&&(this.level--,this.delimiters=this._prev_delimiters.pop()),r.level=this.level,n>0&&(this.level++,this._prev_delimiters.push(this.delimiters),this.delimiters=[],i={delimiters:this.delimiters}),this.pendingLevel=this.level,this.tokens.push(r),this.tokens_meta.push(i),r};zd.prototype.scanDelims=function(t,e){const n=this.posMax,r=this.src.charCodeAt(t),i=t>0?this.src.charCodeAt(t-1):32;let o=t;for(;o<n&&this.src.charCodeAt(o)===r;)o++;const s=o-t,a=o<n?this.src.charCodeAt(o):32,l=rd(i)||nd(String.fromCharCode(i)),c=rd(a)||nd(String.fromCharCode(a)),u=td(i),f=td(a),h=!f&&(!c||u||l),p=!u&&(!l||f||c);return{can_open:h&&(e||!p||l),can_close:p&&(e||!h||c),length:s}};zd.prototype.Token=Li;function RY(t){switch(t){case 10:case 33:case 35:case 36:case 37:case 38:case 42:case 43:case 45:case 58:case 60:case 61:case 62:case 64:case 91:case 92:case 93:case 94:case 95:case 96:case 123:case 125:case 126:return!0;default:return!1}}function NY(t,e){let n=t.pos;for(;n<t.posMax&&!RY(t.src.charCodeAt(n));)n++;return n===t.pos?!1:(e||(t.pending+=t.src.slice(t.pos,n)),t.pos=n,!0)}const PY=/(?:^|[^a-z0-9.+-])([a-z][a-z0-9.+-]*)$/i;function LY(t,e){if(!t.md.options.linkify||t.linkLevel>0)return!1;const n=t.pos,r=t.posMax;if(n+3>r||t.src.charCodeAt(n)!==58||t.src.charCodeAt(n+1)!==47||t.src.charCodeAt(n+2)!==47)return!1;const i=t.pending.match(PY);if(!i)return!1;const o=i[1],s=t.md.linkify.matchAtStart(t.src.slice(n-o.length));if(!s)return!1;let a=s.url;if(a.length<=o.length)return!1;let l=a.length;for(;l>0&&a.charCodeAt(l-1)===42;)l--;l!==a.length&&(a=a.slice(0,l));const c=t.md.normalizeLink(a);if(!t.md.validateLink(c))return!1;if(!e){t.pending=t.pending.slice(0,-o.length);const u=t.push("link_open","a",1);u.attrs=[["href",c]],u.markup="linkify",u.info="auto";const f=t.push("text","",0);f.content=t.md.normalizeLinkText(a);const h=t.push("link_close","a",-1);h.markup="linkify",h.info="auto"}return t.pos+=a.length-o.length,!0}function FY(t,e){let n=t.pos;if(t.src.charCodeAt(n)!==10)return!1;const r=t.pending.length-1,i=t.posMax;if(!e)if(r>=0&&t.pending.charCodeAt(r)===32)if(r>=1&&t.pending.charCodeAt(r-1)===32){let o=r-1;for(;o>=1&&t.pending.charCodeAt(o-1)===32;)o--;t.pending=t.pending.slice(0,o),t.push("hardbreak","br",0)}else t.pending=t.pending.slice(0,-1),t.push("softbreak","br",0);else t.push("softbreak","br",0);for(n++;n<i&&$t(t.src.charCodeAt(n));)n++;return t.pos=n,!0}const ty=[];for(let t=0;t<256;t++)ty.push(0);"\\!\"#$%&'()*+,./:;<=>?@[]^_`{|}~-".split("").forEach(function(t){ty[t.charCodeAt(0)]=1});function zY(t,e){let n=t.pos;const r=t.posMax;if(t.src.charCodeAt(n)!==92||(n++,n>=r))return!1;let i=t.src.charCodeAt(n);if(i===10){for(e||t.push("hardbreak","br",0),n++;n<r&&(i=t.src.charCodeAt(n),!!$t(i));)n++;return t.pos=n,!0}let o=t.src[n];if(i>=55296&&i<=56319&&n+1<r){const a=t.src.charCodeAt(n+1);a>=56320&&a<=57343&&(o+=t.src[n+1],n++)}const s="\\"+o;if(!e){const a=t.push("text_special","",0);i<256&&ty[i]!==0?a.content=o:a.content=s,a.markup=s,a.info="escape"}return t.pos=n+1,!0}function BY(t,e){let n=t.pos;if(t.src.charCodeAt(n)!==96)return!1;const i=n;n++;const o=t.posMax;for(;n<o&&t.src.charCodeAt(n)===96;)n++;const s=t.src.slice(i,n),a=s.length;if(t.backticksScanned&&(t.backticks[a]||0)<=i)return e||(t.pending+=s),t.pos+=a,!0;let l=n,c;for(;(c=t.src.indexOf("`",l))!==-1;){for(l=c+1;l<o&&t.src.charCodeAt(l)===96;)l++;const u=l-c;if(u===a){if(!e){const f=t.push("code_inline","code",0);f.markup=s,f.content=t.src.slice(n,c).replace(/\n/g," ").replace(/^ (.+) $/,"$1")}return t.pos=l,!0}t.backticks[u]=c}return t.backticksScanned=!0,e||(t.pending+=s),t.pos+=a,!0}function HY(t,e){const n=t.pos,r=t.src.charCodeAt(n);if(e||r!==126)return!1;const i=t.scanDelims(t.pos,!0);let o=i.length;const s=String.fromCharCode(r);if(o<2)return!1;let a;o%2&&(a=t.push("text","",0),a.content=s,o--);for(let l=0;l<o;l+=2)a=t.push("text","",0),a.content=s+s,t.delimiters.push({marker:r,length:0,token:t.tokens.length-1,end:-1,open:i.can_open,close:i.can_close});return t.pos+=i.length,!0}function o2(t,e){let n;const r=[],i=e.length;for(let o=0;o<i;o++){const s=e[o];if(s.marker!==126||s.end===-1)continue;const a=e[s.end];n=t.tokens[s.token],n.type="s_open",n.tag="s",n.nesting=1,n.markup="~~",n.content="",n=t.tokens[a.token],n.type="s_close",n.tag="s",n.nesting=-1,n.markup="~~",n.content="",t.tokens[a.token-1].type==="text"&&t.tokens[a.token-1].content==="~"&&r.push(a.token-1)}for(;r.length;){const o=r.pop();let s=o+1;for(;s<t.tokens.length&&t.tokens[s].type==="s_close";)s++;s--,o!==s&&(n=t.tokens[s],t.tokens[s]=t.tokens[o],t.tokens[o]=n)}}function VY(t){const e=t.tokens_meta,n=t.tokens_meta.length;o2(t,t.delimiters);for(let r=0;r<n;r++)e[r]&&e[r].delimiters&&o2(t,e[r].delimiters)}const ET={tokenize:HY,postProcess:VY};function UY(t,e){const n=t.pos,r=t.src.charCodeAt(n);if(e||r!==95&&r!==42)return!1;const i=t.scanDelims(t.pos,r===42);for(let o=0;o<i.length;o++){const s=t.push("text","",0);s.content=String.fromCharCode(r),t.delimiters.push({marker:r,length:i.length,token:t.tokens.length-1,end:-1,open:i.can_open,close:i.can_close})}return t.pos+=i.length,!0}function s2(t,e){const n=e.length;for(let r=n-1;r>=0;r--){const i=e[r];if(i.marker!==95&&i.marker!==42||i.end===-1)continue;const o=e[i.end],s=r>0&&e[r-1].end===i.end+1&&e[r-1].marker===i.marker&&e[r-1].token===i.token-1&&e[i.end+1].token===o.token+1,a=String.fromCharCode(i.marker),l=t.tokens[i.token];l.type=s?"strong_open":"em_open",l.tag=s?"strong":"em",l.nesting=1,l.markup=s?a+a:a,l.content="";const c=t.tokens[o.token];c.type=s?"strong_close":"em_close",c.tag=s?"strong":"em",c.nesting=-1,c.markup=s?a+a:a,c.content="",s&&(t.tokens[e[r-1].token].content="",t.tokens[e[i.end+1].token].content="",r--)}}function jY(t){const e=t.tokens_meta,n=t.tokens_meta.length;s2(t,t.delimiters);for(let r=0;r<n;r++)e[r]&&e[r].delimiters&&s2(t,e[r].delimiters)}const AT={tokenize:UY,postProcess:jY};function qY(t,e){let n,r,i,o,s="",a="",l=t.pos,c=!0;if(t.src.charCodeAt(t.pos)!==91)return!1;const u=t.pos,f=t.posMax,h=t.pos+1,p=t.md.helpers.parseLinkLabel(t,t.pos,!0);if(p<0)return!1;let m=p+1;if(m<f&&t.src.charCodeAt(m)===40){for(c=!1,m++;m<f&&(n=t.src.charCodeAt(m),!(!$t(n)&&n!==10));m++);if(m>=f)return!1;if(l=m,i=t.md.helpers.parseLinkDestination(t.src,m,t.posMax),i.ok){for(s=t.md.normalizeLink(i.str),t.md.validateLink(s)?m=i.pos:s="",l=m;m<f&&(n=t.src.charCodeAt(m),!(!$t(n)&&n!==10));m++);if(i=t.md.helpers.parseLinkTitle(t.src,m,t.posMax),m<f&&l!==m&&i.ok)for(a=i.str,m=i.pos;m<f&&(n=t.src.charCodeAt(m),!(!$t(n)&&n!==10));m++);}(m>=f||t.src.charCodeAt(m)!==41)&&(c=!0),m++}if(c){if(typeof t.env.references>"u")return!1;if(m<f&&t.src.charCodeAt(m)===91?(l=m+1,m=t.md.helpers.parseLinkLabel(t,m),m>=0?r=t.src.slice(l,m++):m=p+1):m=p+1,r||(r=t.src.slice(h,p)),o=t.env.references[Im(r)],!o)return t.pos=u,!1;s=o.href,a=o.title}if(!e){t.pos=h,t.posMax=p;const v=t.push("link_open","a",1),g=[["href",s]];v.attrs=g,a&&g.push(["title",a]),t.linkLevel++,t.md.inline.tokenize(t),t.linkLevel--,t.push("link_close","a",-1)}return t.pos=m,t.posMax=f,!0}function WY(t,e){let n,r,i,o,s,a,l,c,u="";const f=t.pos,h=t.posMax;if(t.src.charCodeAt(t.pos)!==33||t.src.charCodeAt(t.pos+1)!==91)return!1;const p=t.pos+2,m=t.md.helpers.parseLinkLabel(t,t.pos+1,!1);if(m<0)return!1;if(o=m+1,o<h&&t.src.charCodeAt(o)===40){for(o++;o<h&&(n=t.src.charCodeAt(o),!(!$t(n)&&n!==10));o++);if(o>=h)return!1;for(c=o,a=t.md.helpers.parseLinkDestination(t.src,o,t.posMax),a.ok&&(u=t.md.normalizeLink(a.str),t.md.validateLink(u)?o=a.pos:u=""),c=o;o<h&&(n=t.src.charCodeAt(o),!(!$t(n)&&n!==10));o++);if(a=t.md.helpers.parseLinkTitle(t.src,o,t.posMax),o<h&&c!==o&&a.ok)for(l=a.str,o=a.pos;o<h&&(n=t.src.charCodeAt(o),!(!$t(n)&&n!==10));o++);else l="";if(o>=h||t.src.charCodeAt(o)!==41)return t.pos=f,!1;o++}else{if(typeof t.env.references>"u")return!1;if(o<h&&t.src.charCodeAt(o)===91?(c=o+1,o=t.md.helpers.parseLinkLabel(t,o),o>=0?i=t.src.slice(c,o++):o=m+1):o=m+1,i||(i=t.src.slice(p,m)),s=t.env.references[Im(i)],!s)return t.pos=f,!1;u=s.href,l=s.title}if(!e){r=t.src.slice(p,m);const v=[];t.md.inline.parse(r,t.md,t.env,v);const g=t.push("image","img",0),b=[["src",u],["alt",""]];g.attrs=b,g.children=v,g.content=r,l&&b.push(["title",l])}return t.pos=o,t.posMax=h,!0}const KY=/^([a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*)$/,GY=/^([a-zA-Z][a-zA-Z0-9+.-]{1,31}):([^<>\x00-\x20]*)$/;function ZY(t,e){let n=t.pos;if(t.src.charCodeAt(n)!==60)return!1;const r=t.pos,i=t.posMax;for(;;){if(++n>=i)return!1;const s=t.src.charCodeAt(n);if(s===60)return!1;if(s===62)break}const o=t.src.slice(r+1,n);if(GY.test(o)){const s=t.md.normalizeLink(o);if(!t.md.validateLink(s))return!1;if(!e){const a=t.push("link_open","a",1);a.attrs=[["href",s]],a.markup="autolink",a.info="auto";const l=t.push("text","",0);l.content=t.md.normalizeLinkText(o);const c=t.push("link_close","a",-1);c.markup="autolink",c.info="auto"}return t.pos+=o.length+2,!0}if(KY.test(o)){const s=t.md.normalizeLink("mailto:"+o);if(!t.md.validateLink(s))return!1;if(!e){const a=t.push("link_open","a",1);a.attrs=[["href",s]],a.markup="autolink",a.info="auto";const l=t.push("text","",0);l.content=t.md.normalizeLinkText(o);const c=t.push("link_close","a",-1);c.markup="autolink",c.info="auto"}return t.pos+=o.length+2,!0}return!1}function YY(t){return/^<a[>\s]/i.test(t)}function JY(t){return/^<\/a\s*>/i.test(t)}function XY(t){const e=t|32;return e>=97&&e<=122}function QY(t,e){if(!t.md.options.html)return!1;const n=t.posMax,r=t.pos;if(t.src.charCodeAt(r)!==60||r+2>=n)return!1;const i=t.src.charCodeAt(r+1);if(i!==33&&i!==63&&i!==47&&!XY(i))return!1;const o=t.src.slice(r).match(AY);if(!o)return!1;if(!e){const s=t.push("html_inline","",0);s.content=o[0],YY(s.content)&&t.linkLevel++,JY(s.content)&&t.linkLevel--}return t.pos+=o[0].length,!0}const $Y=/^&#((?:x[a-f0-9]{1,6}|[0-9]{1,7}));/i,eJ=/^&([a-z][a-z0-9]{1,31});/i;function tJ(t,e){const n=t.pos,r=t.posMax;if(t.src.charCodeAt(n)!==38||n+1>=r)return!1;if(t.src.charCodeAt(n+1)===35){const o=t.src.slice(n).match($Y);if(o){if(!e){const s=o[1][0].toLowerCase()==="x"?parseInt(o[1].slice(1),16):parseInt(o[1],10),a=t.push("text_special","",0);a.content=$1(s)?Ep(s):Ep(65533),a.markup=o[0],a.info="entity"}return t.pos+=o[0].length,!0}}else{const o=t.src.slice(n).match(eJ);if(o){const s=yT(o[0]);if(s!==o[0]){if(!e){const a=t.push("text_special","",0);a.content=s,a.markup=o[0],a.info="entity"}return t.pos+=o[0].length,!0}}}return!1}function a2(t){const e={},n=t.length;if(!n)return;let r=0,i=-2;const o=[];for(let s=0;s<n;s++){const a=t[s];if(o.push(0),(t[r].marker!==a.marker||i!==a.token-1)&&(r=s),i=a.token,a.length=a.length||0,!a.close)continue;e.hasOwnProperty(a.marker)||(e[a.marker]=[-1,-1,-1,-1,-1,-1]);const l=e[a.marker][(a.open?3:0)+a.length%3];let c=r-o[r]-1,u=c;for(;c>l;c-=o[c]+1){const f=t[c];if(f.marker===a.marker&&f.open&&f.end<0){let h=!1;if((f.close||a.open)&&(f.length+a.length)%3===0&&(f.length%3!==0||a.length%3!==0)&&(h=!0),!h){const p=c>0&&!t[c-1].open?o[c-1]+1:0;o[s]=s-c+p,o[c]=p,a.open=!1,f.end=s,f.close=!1,u=-1,i=-2;break}}}u!==-1&&(e[a.marker][(a.open?3:0)+(a.length||0)%3]=u)}}function nJ(t){const e=t.tokens_meta,n=t.tokens_meta.length;a2(t.delimiters);for(let r=0;r<n;r++)e[r]&&e[r].delimiters&&a2(e[r].delimiters)}function rJ(t){let e,n,r=0;const i=t.tokens,o=t.tokens.length;for(e=n=0;e<o;e++)i[e].nesting<0&&r--,i[e].level=r,i[e].nesting>0&&r++,i[e].type==="text"&&e+1<o&&i[e+1].type==="text"?i[e+1].content=i[e].content+i[e+1].content:(e!==n&&(i[n]=i[e]),n++);e!==n&&(i.length=n)}const Xg=[["text",NY],["linkify",LY],["newline",FY],["escape",zY],["backticks",BY],["strikethrough",ET.tokenize],["emphasis",AT.tokenize],["link",qY],["image",WY],["autolink",ZY],["html_inline",QY],["entity",tJ]],Qg=[["balance_pairs",nJ],["strikethrough",ET.postProcess],["emphasis",AT.postProcess],["fragments_join",rJ]];function Bd(){this.ruler=new Mr;for(let t=0;t<Xg.length;t++)this.ruler.push(Xg[t][0],Xg[t][1]);this.ruler2=new Mr;for(let t=0;t<Qg.length;t++)this.ruler2.push(Qg[t][0],Qg[t][1])}Bd.prototype.skipToken=function(t){const e=t.pos,n=this.ruler.getRules(""),r=n.length,i=t.md.options.maxNesting,o=t.cache;if(typeof o[e]<"u"){t.pos=o[e];return}let s=!1;if(t.level<i){for(let a=0;a<r;a++)if(t.level++,s=n[a](t,!0),t.level--,s){if(e>=t.pos)throw new Error("inline rule didn't increment state.pos");break}}else t.pos=t.posMax;s||t.pos++,o[e]=t.pos};Bd.prototype.tokenize=function(t){const e=this.ruler.getRules(""),n=e.length,r=t.posMax,i=t.md.options.maxNesting;for(;t.pos<r;){const o=t.pos;let s=!1;if(t.level<i){for(let a=0;a<n;a++)if(s=e[a](t,!1),s){if(o>=t.pos)throw new Error("inline rule didn't increment state.pos");break}}if(s){if(t.pos>=r)break;continue}t.pending+=t.src[t.pos++]}t.pending&&t.pushPending()};Bd.prototype.parse=function(t,e,n,r){const i=new this.State(t,e,n,r);this.tokenize(i);const o=this.ruler2.getRules(""),s=o.length;for(let a=0;a<s;a++)o[a](i)};Bd.prototype.State=zd;function iJ(t){const e={};t=t||{},e.src_Any=pT.source,e.src_Cc=mT.source,e.src_Z=vT.source,e.src_P=X1.source,e.src_ZPCc=[e.src_Z,e.src_P,e.src_Cc].join("|"),e.src_ZCc=[e.src_Z,e.src_Cc].join("|");const n="[><|]";return e.src_pseudo_letter="(?:(?!"+n+"|"+e.src_ZPCc+")"+e.src_Any+")",e.src_ip4="(?:(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)",e.src_auth="(?:(?:(?!"+e.src_ZCc+"|[@/\\[\\]()]).)+@)?",e.src_port="(?::(?:6(?:[0-4]\\d{3}|5(?:[0-4]\\d{2}|5(?:[0-2]\\d|3[0-5])))|[1-5]?\\d{1,4}))?",e.src_host_terminator="(?=$|"+n+"|"+e.src_ZPCc+")(?!"+(t["---"]?"-(?!--)|":"-|")+"_|:\\d|\\.-|\\.(?!$|"+e.src_ZPCc+"))",e.src_path="(?:[/?#](?:(?!"+e.src_ZCc+"|"+n+`|[()[\\]{}.,"'?!\\-;]).|\\[(?:(?!`+e.src_ZCc+"|\\]).)*\\]|\\((?:(?!"+e.src_ZCc+"|[)]).)*\\)|\\{(?:(?!"+e.src_ZCc+'|[}]).)*\\}|\\"(?:(?!'+e.src_ZCc+`|["]).)+\\"|\\'(?:(?!`+e.src_ZCc+"|[']).)+\\'|\\'(?="+e.src_pseudo_letter+"|[-])|\\.{2,}[a-zA-Z0-9%/&]|\\.(?!"+e.src_ZCc+"|[.]|$)|"+(t["---"]?"\\-(?!--(?:[^-]|$))(?:-*)|":"\\-+|")+",(?!"+e.src_ZCc+"|$)|;(?!"+e.src_ZCc+"|$)|\\!+(?!"+e.src_ZCc+"|[!]|$)|\\?(?!"+e.src_ZCc+"|[?]|$))+|\\/)?",e.src_email_name='[\\-;:&=\\+\\$,\\.a-zA-Z0-9_][\\-;:&=\\+\\$,\\"\\.a-zA-Z0-9_]*',e.src_xn="xn--[a-z0-9\\-]{1,59}",e.src_domain_root="(?:"+e.src_xn+"|"+e.src_pseudo_letter+"{1,63})",e.src_domain="(?:"+e.src_xn+"|(?:"+e.src_pseudo_letter+")|(?:"+e.src_pseudo_letter+"(?:-|"+e.src_pseudo_letter+"){0,61}"+e.src_pseudo_letter+"))",e.src_host="(?:(?:(?:(?:"+e.src_domain+")\\.)*"+e.src_domain+"))",e.tpl_host_fuzzy="(?:"+e.src_ip4+"|(?:(?:(?:"+e.src_domain+")\\.)+(?:%TLDS%)))",e.tpl_host_no_ip_fuzzy="(?:(?:(?:"+e.src_domain+")\\.)+(?:%TLDS%))",e.src_host_strict=e.src_host+e.src_host_terminator,e.tpl_host_fuzzy_strict=e.tpl_host_fuzzy+e.src_host_terminator,e.src_host_port_strict=e.src_host+e.src_port+e.src_host_terminator,e.tpl_host_port_fuzzy_strict=e.tpl_host_fuzzy+e.src_port+e.src_host_terminator,e.tpl_host_port_no_ip_fuzzy_strict=e.tpl_host_no_ip_fuzzy+e.src_port+e.src_host_terminator,e.tpl_host_fuzzy_test="localhost|www\\.|\\.\\d{1,3}\\.|(?:\\.(?:%TLDS%)(?:"+e.src_ZPCc+"|>|$))",e.tpl_email_fuzzy="(^|"+n+'|"|\\(|'+e.src_ZCc+")("+e.src_email_name+"@"+e.tpl_host_fuzzy_strict+")",e.tpl_link_fuzzy="(^|(?![.:/\\-_@])(?:[$+<=>^`||]|"+e.src_ZPCc+"))((?![$+<=>^`||])"+e.tpl_host_port_fuzzy_strict+e.src_path+")",e.tpl_link_no_ip_fuzzy="(^|(?![.:/\\-_@])(?:[$+<=>^`||]|"+e.src_ZPCc+"))((?![$+<=>^`||])"+e.tpl_host_port_no_ip_fuzzy_strict+e.src_path+")",e}function rb(t){return Array.prototype.slice.call(arguments,1).forEach(function(n){n&&Object.keys(n).forEach(function(r){t[r]=n[r]})}),t}function Nm(t){return Object.prototype.toString.call(t)}function oJ(t){return Nm(t)==="[object String]"}function sJ(t){return Nm(t)==="[object Object]"}function aJ(t){return Nm(t)==="[object RegExp]"}function l2(t){return Nm(t)==="[object Function]"}function lJ(t){return t.replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}const TT={fuzzyLink:!0,fuzzyEmail:!0,fuzzyIP:!1};function cJ(t){return Object.keys(t||{}).reduce(function(e,n){return e||TT.hasOwnProperty(n)},!1)}const uJ={"http:":{validate:function(t,e,n){const r=t.slice(e);return n.re.http||(n.re.http=new RegExp("^\\/\\/"+n.re.src_auth+n.re.src_host_port_strict+n.re.src_path,"i")),n.re.http.test(r)?r.match(n.re.http)[0].length:0}},"https:":"http:","ftp:":"http:","//":{validate:function(t,e,n){const r=t.slice(e);return n.re.no_http||(n.re.no_http=new RegExp("^"+n.re.src_auth+"(?:localhost|(?:(?:"+n.re.src_domain+")\\.)+"+n.re.src_domain_root+")"+n.re.src_port+n.re.src_host_terminator+n.re.src_path,"i")),n.re.no_http.test(r)?e>=3&&t[e-3]===":"||e>=3&&t[e-3]==="/"?0:r.match(n.re.no_http)[0].length:0}},"mailto:":{validate:function(t,e,n){const r=t.slice(e);return n.re.mailto||(n.re.mailto=new RegExp("^"+n.re.src_email_name+"@"+n.re.src_host_strict,"i")),n.re.mailto.test(r)?r.match(n.re.mailto)[0].length:0}}},dJ="a[cdefgilmnoqrstuwxz]|b[abdefghijmnorstvwyz]|c[acdfghiklmnoruvwxyz]|d[ejkmoz]|e[cegrstu]|f[ijkmor]|g[abdefghilmnpqrstuwy]|h[kmnrtu]|i[delmnoqrst]|j[emop]|k[eghimnprwyz]|l[abcikrstuvy]|m[acdeghklmnopqrstuvwxyz]|n[acefgilopruz]|om|p[aefghklmnrstwy]|qa|r[eosuw]|s[abcdeghijklmnortuvxyz]|t[cdfghjklmnortvwz]|u[agksyz]|v[aceginu]|w[fs]|y[et]|z[amw]",fJ="biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|рф".split("|");function hJ(t){t.__index__=-1,t.__text_cache__=""}function pJ(t){return function(e,n){const r=e.slice(n);return t.test(r)?r.match(t)[0].length:0}}function c2(){return function(t,e){e.normalize(t)}}function Ap(t){const e=t.re=iJ(t.__opts__),n=t.__tlds__.slice();t.onCompile(),t.__tlds_replaced__||n.push(dJ),n.push(e.src_xn),e.src_tlds=n.join("|");function r(a){return a.replace("%TLDS%",e.src_tlds)}e.email_fuzzy=RegExp(r(e.tpl_email_fuzzy),"i"),e.link_fuzzy=RegExp(r(e.tpl_link_fuzzy),"i"),e.link_no_ip_fuzzy=RegExp(r(e.tpl_link_no_ip_fuzzy),"i"),e.host_fuzzy_test=RegExp(r(e.tpl_host_fuzzy_test),"i");const i=[];t.__compiled__={};function o(a,l){throw new Error('(LinkifyIt) Invalid schema "'+a+'": '+l)}Object.keys(t.__schemas__).forEach(function(a){const l=t.__schemas__[a];if(l===null)return;const c={validate:null,link:null};if(t.__compiled__[a]=c,sJ(l)){aJ(l.validate)?c.validate=pJ(l.validate):l2(l.validate)?c.validate=l.validate:o(a,l),l2(l.normalize)?c.normalize=l.normalize:l.normalize?o(a,l):c.normalize=c2();return}if(oJ(l)){i.push(a);return}o(a,l)}),i.forEach(function(a){t.__compiled__[t.__schemas__[a]]&&(t.__compiled__[a].validate=t.__compiled__[t.__schemas__[a]].validate,t.__compiled__[a].normalize=t.__compiled__[t.__schemas__[a]].normalize)}),t.__compiled__[""]={validate:null,normalize:c2()};const s=Object.keys(t.__compiled__).filter(function(a){return a.length>0&&t.__compiled__[a]}).map(lJ).join("|");t.re.schema_test=RegExp("(^|(?!_)(?:[><|]|"+e.src_ZPCc+"))("+s+")","i"),t.re.schema_search=RegExp("(^|(?!_)(?:[><|]|"+e.src_ZPCc+"))("+s+")","ig"),t.re.schema_at_start=RegExp("^"+t.re.schema_search.source,"i"),t.re.pretest=RegExp("("+t.re.schema_test.source+")|("+t.re.host_fuzzy_test.source+")|@","i"),hJ(t)}function mJ(t,e){const n=t.__index__,r=t.__last_index__,i=t.__text_cache__.slice(n,r);this.schema=t.__schema__.toLowerCase(),this.index=n+e,this.lastIndex=r+e,this.raw=i,this.text=i,this.url=i}function ib(t,e){const n=new mJ(t,e);return t.__compiled__[n.schema].normalize(n,t),n}function Wr(t,e){if(!(this instanceof Wr))return new Wr(t,e);e||cJ(t)&&(e=t,t={}),this.__opts__=rb({},TT,e),this.__index__=-1,this.__last_index__=-1,this.__schema__="",this.__text_cache__="",this.__schemas__=rb({},uJ,t),this.__compiled__={},this.__tlds__=fJ,this.__tlds_replaced__=!1,this.re={},Ap(this)}Wr.prototype.add=function(e,n){return this.__schemas__[e]=n,Ap(this),this};Wr.prototype.set=function(e){return this.__opts__=rb(this.__opts__,e),this};Wr.prototype.test=function(e){if(this.__text_cache__=e,this.__index__=-1,!e.length)return!1;let n,r,i,o,s,a,l,c,u;if(this.re.schema_test.test(e)){for(l=this.re.schema_search,l.lastIndex=0;(n=l.exec(e))!==null;)if(o=this.testSchemaAt(e,n[2],l.lastIndex),o){this.__schema__=n[2],this.__index__=n.index+n[1].length,this.__last_index__=n.index+n[0].length+o;break}}return this.__opts__.fuzzyLink&&this.__compiled__["http:"]&&(c=e.search(this.re.host_fuzzy_test),c>=0&&(this.__index__<0||c<this.__index__)&&(r=e.match(this.__opts__.fuzzyIP?this.re.link_fuzzy:this.re.link_no_ip_fuzzy))!==null&&(s=r.index+r[1].length,(this.__index__<0||s<this.__index__)&&(this.__schema__="",this.__index__=s,this.__last_index__=r.index+r[0].length))),this.__opts__.fuzzyEmail&&this.__compiled__["mailto:"]&&(u=e.indexOf("@"),u>=0&&(i=e.match(this.re.email_fuzzy))!==null&&(s=i.index+i[1].length,a=i.index+i[0].length,(this.__index__<0||s<this.__index__||s===this.__index__&&a>this.__last_index__)&&(this.__schema__="mailto:",this.__index__=s,this.__last_index__=a))),this.__index__>=0};Wr.prototype.pretest=function(e){return this.re.pretest.test(e)};Wr.prototype.testSchemaAt=function(e,n,r){return this.__compiled__[n.toLowerCase()]?this.__compiled__[n.toLowerCase()].validate(e,r,this):0};Wr.prototype.match=function(e){const n=[];let r=0;this.__index__>=0&&this.__text_cache__===e&&(n.push(ib(this,r)),r=this.__last_index__);let i=r?e.slice(r):e;for(;this.test(i);)n.push(ib(this,r)),i=i.slice(this.__last_index__),r+=this.__last_index__;return n.length?n:null};Wr.prototype.matchAtStart=function(e){if(this.__text_cache__=e,this.__index__=-1,!e.length)return null;const n=this.re.schema_at_start.exec(e);if(!n)return null;const r=this.testSchemaAt(e,n[2],n[0].length);return r?(this.__schema__=n[2],this.__index__=n.index+n[1].length,this.__last_index__=n.index+n[0].length+r,ib(this,0)):null};Wr.prototype.tlds=function(e,n){return e=Array.isArray(e)?e:[e],n?(this.__tlds__=this.__tlds__.concat(e).sort().filter(function(r,i,o){return r!==o[i-1]}).reverse(),Ap(this),this):(this.__tlds__=e.slice(),this.__tlds_replaced__=!0,Ap(this),this)};Wr.prototype.normalize=function(e){e.schema||(e.url="http://"+e.url),e.schema==="mailto:"&&!/^mailto:/i.test(e.url)&&(e.url="mailto:"+e.url)};Wr.prototype.onCompile=function(){};const Cl=2147483647,Ji=36,ny=1,id=26,gJ=38,vJ=700,MT=72,DT=128,OT="-",bJ=/^xn--/,yJ=/[^\0-\x7F]/,wJ=/[\x2E\u3002\uFF0E\uFF61]/g,xJ={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},$g=Ji-ny,Xi=Math.floor,e0=String.fromCharCode;function rs(t){throw new RangeError(xJ[t])}function kJ(t,e){const n=[];let r=t.length;for(;r--;)n[r]=e(t[r]);return n}function IT(t,e){const n=t.split("@");let r="";n.length>1&&(r=n[0]+"@",t=n[1]),t=t.replace(wJ,".");const i=t.split("."),o=kJ(i,e).join(".");return r+o}function RT(t){const e=[];let n=0;const r=t.length;for(;n<r;){const i=t.charCodeAt(n++);if(i>=55296&&i<=56319&&n<r){const o=t.charCodeAt(n++);(o&64512)==56320?e.push(((i&1023)<<10)+(o&1023)+65536):(e.push(i),n--)}else e.push(i)}return e}const _J=t=>String.fromCodePoint(...t),CJ=function(t){return t>=48&&t<58?26+(t-48):t>=65&&t<91?t-65:t>=97&&t<123?t-97:Ji},u2=function(t,e){return t+22+75*(t<26)-((e!=0)<<5)},NT=function(t,e,n){let r=0;for(t=n?Xi(t/vJ):t>>1,t+=Xi(t/e);t>$g*id>>1;r+=Ji)t=Xi(t/$g);return Xi(r+($g+1)*t/(t+gJ))},PT=function(t){const e=[],n=t.length;let r=0,i=DT,o=MT,s=t.lastIndexOf(OT);s<0&&(s=0);for(let a=0;a<s;++a)t.charCodeAt(a)>=128&&rs("not-basic"),e.push(t.charCodeAt(a));for(let a=s>0?s+1:0;a<n;){const l=r;for(let u=1,f=Ji;;f+=Ji){a>=n&&rs("invalid-input");const h=CJ(t.charCodeAt(a++));h>=Ji&&rs("invalid-input"),h>Xi((Cl-r)/u)&&rs("overflow"),r+=h*u;const p=f<=o?ny:f>=o+id?id:f-o;if(h<p)break;const m=Ji-p;u>Xi(Cl/m)&&rs("overflow"),u*=m}const c=e.length+1;o=NT(r-l,c,l==0),Xi(r/c)>Cl-i&&rs("overflow"),i+=Xi(r/c),r%=c,e.splice(r++,0,i)}return String.fromCodePoint(...e)},LT=function(t){const e=[];t=RT(t);const n=t.length;let r=DT,i=0,o=MT;for(const l of t)l<128&&e.push(e0(l));const s=e.length;let a=s;for(s&&e.push(OT);a<n;){let l=Cl;for(const u of t)u>=r&&u<l&&(l=u);const c=a+1;l-r>Xi((Cl-i)/c)&&rs("overflow"),i+=(l-r)*c,r=l;for(const u of t)if(u<r&&++i>Cl&&rs("overflow"),u===r){let f=i;for(let h=Ji;;h+=Ji){const p=h<=o?ny:h>=o+id?id:h-o;if(f<p)break;const m=f-p,v=Ji-p;e.push(e0(u2(p+m%v,0))),f=Xi(m/v)}e.push(e0(u2(f,0))),o=NT(i,c,a===s),i=0,++a}++i,++r}return e.join("")},SJ=function(t){return IT(t,function(e){return bJ.test(e)?PT(e.slice(4).toLowerCase()):e})},EJ=function(t){return IT(t,function(e){return yJ.test(e)?"xn--"+LT(e):e})},FT={version:"2.3.1",ucs2:{decode:RT,encode:_J},decode:PT,encode:LT,toASCII:EJ,toUnicode:SJ},AJ={options:{html:!1,xhtmlOut:!1,breaks:!1,langPrefix:"language-",linkify:!1,typographer:!1,quotes:"“”‘’",highlight:null,maxNesting:100},components:{core:{},block:{},inline:{}}},TJ={options:{html:!1,xhtmlOut:!1,breaks:!1,langPrefix:"language-",linkify:!1,typographer:!1,quotes:"“”‘’",highlight:null,maxNesting:20},components:{core:{rules:["normalize","block","inline","text_join"]},block:{rules:["paragraph"]},inline:{rules:["text"],rules2:["balance_pairs","fragments_join"]}}},MJ={options:{html:!0,xhtmlOut:!0,breaks:!1,langPrefix:"language-",linkify:!1,typographer:!1,quotes:"“”‘’",highlight:null,maxNesting:20},components:{core:{rules:["normalize","block","inline","text_join"]},block:{rules:["blockquote","code","fence","heading","hr","html_block","lheading","list","reference","paragraph"]},inline:{rules:["autolink","backticks","emphasis","entity","escape","html_inline","image","link","newline","text"],rules2:["balance_pairs","emphasis","fragments_join"]}}},DJ={default:AJ,zero:TJ,commonmark:MJ},OJ=/^(vbscript|javascript|file|data):/,IJ=/^data:image\/(gif|png|jpeg|webp);/;function RJ(t){const e=t.trim().toLowerCase();return OJ.test(e)?IJ.test(e):!0}const zT=["http:","https:","mailto:"];function NJ(t){const e=J1(t,!0);if(e.hostname&&(!e.protocol||zT.indexOf(e.protocol)>=0))try{e.hostname=FT.toASCII(e.hostname)}catch{}return Fd(Y1(e))}function PJ(t){const e=J1(t,!0);if(e.hostname&&(!e.protocol||zT.indexOf(e.protocol)>=0))try{e.hostname=FT.toUnicode(e.hostname)}catch{}return ic(Y1(e),ic.defaultChars+"%")}function Kr(t,e){if(!(this instanceof Kr))return new Kr(t,e);e||Q1(t)||(e=t||{},t="default"),this.inline=new Bd,this.block=new Rm,this.core=new ey,this.renderer=new xc,this.linkify=new Wr,this.validateLink=RJ,this.normalizeLink=NJ,this.normalizeLinkText=PJ,this.utils=FZ,this.helpers=Om({},VZ),this.options={},this.configure(t),e&&this.set(e)}Kr.prototype.set=function(t){return Om(this.options,t),this};Kr.prototype.configure=function(t){const e=this;if(Q1(t)){const n=t;if(t=DJ[n],!t)throw new Error('Wrong `markdown-it` preset "'+n+'", check name')}if(!t)throw new Error("Wrong `markdown-it` preset, can't be empty");return t.options&&e.set(t.options),t.components&&Object.keys(t.components).forEach(function(n){t.components[n].rules&&e[n].ruler.enableOnly(t.components[n].rules),t.components[n].rules2&&e[n].ruler2.enableOnly(t.components[n].rules2)}),this};Kr.prototype.enable=function(t,e){let n=[];Array.isArray(t)||(t=[t]),["core","block","inline"].forEach(function(i){n=n.concat(this[i].ruler.enable(t,!0))},this),n=n.concat(this.inline.ruler2.enable(t,!0));const r=t.filter(function(i){return n.indexOf(i)<0});if(r.length&&!e)throw new Error("MarkdownIt. Failed to enable unknown rule(s): "+r);return this};Kr.prototype.disable=function(t,e){let n=[];Array.isArray(t)||(t=[t]),["core","block","inline"].forEach(function(i){n=n.concat(this[i].ruler.disable(t,!0))},this),n=n.concat(this.inline.ruler2.disable(t,!0));const r=t.filter(function(i){return n.indexOf(i)<0});if(r.length&&!e)throw new Error("MarkdownIt. Failed to disable unknown rule(s): "+r);return this};Kr.prototype.use=function(t){const e=[this].concat(Array.prototype.slice.call(arguments,1));return t.apply(t,e),this};Kr.prototype.parse=function(t,e){if(typeof t!="string")throw new Error("Input data should be a String");const n=new this.core.State(t,this,e);return this.core.process(n),n.tokens};Kr.prototype.render=function(t,e){return e=e||{},this.renderer.render(this.parse(t,e),this.options,e)};Kr.prototype.parseInline=function(t,e){const n=new this.core.State(t,this,e);return n.inlineMode=!0,this.core.process(n),n.tokens};Kr.prototype.renderInline=function(t,e){return e=e||{},this.renderer.render(this.parseInline(t,e),this.options,e)};const LJ=new Mb({nodes:{doc:{content:"block+"},paragraph:{content:"inline*",group:"block",parseDOM:[{tag:"p"}],toDOM(){return["p",0]}},blockquote:{content:"block+",group:"block",parseDOM:[{tag:"blockquote"}],toDOM(){return["blockquote",0]}},horizontal_rule:{group:"block",parseDOM:[{tag:"hr"}],toDOM(){return["div",["hr"]]}},heading:{attrs:{level:{default:1}},content:"(text | image)*",group:"block",defining:!0,parseDOM:[{tag:"h1",attrs:{level:1}},{tag:"h2",attrs:{level:2}},{tag:"h3",attrs:{level:3}},{tag:"h4",attrs:{level:4}},{tag:"h5",attrs:{level:5}},{tag:"h6",attrs:{level:6}}],toDOM(t){return["h"+t.attrs.level,0]}},code_block:{content:"text*",group:"block",code:!0,defining:!0,marks:"",attrs:{params:{default:""}},parseDOM:[{tag:"pre",preserveWhitespace:"full",getAttrs:t=>({params:t.getAttribute("data-params")||""})}],toDOM(t){return["pre",t.attrs.params?{"data-params":t.attrs.params}:{},["code",0]]}},ordered_list:{content:"list_item+",group:"block",attrs:{order:{default:1},tight:{default:!1}},parseDOM:[{tag:"ol",getAttrs(t){return{order:t.hasAttribute("start")?+t.getAttribute("start"):1,tight:t.hasAttribute("data-tight")}}}],toDOM(t){return["ol",{start:t.attrs.order==1?null:t.attrs.order,"data-tight":t.attrs.tight?"true":null},0]}},bullet_list:{content:"list_item+",group:"block",attrs:{tight:{default:!1}},parseDOM:[{tag:"ul",getAttrs:t=>({tight:t.hasAttribute("data-tight")})}],toDOM(t){return["ul",{"data-tight":t.attrs.tight?"true":null},0]}},list_item:{content:"block+",defining:!0,parseDOM:[{tag:"li"}],toDOM(){return["li",0]}},text:{group:"inline"},image:{inline:!0,attrs:{src:{},alt:{default:null},title:{default:null}},group:"inline",draggable:!0,parseDOM:[{tag:"img[src]",getAttrs(t){return{src:t.getAttribute("src"),title:t.getAttribute("title"),alt:t.getAttribute("alt")}}}],toDOM(t){return["img",t.attrs]}},hard_break:{inline:!0,group:"inline",selectable:!1,parseDOM:[{tag:"br"}],toDOM(){return["br"]}}},marks:{em:{parseDOM:[{tag:"i"},{tag:"em"},{style:"font-style=italic"},{style:"font-style=normal",clearMark:t=>t.type.name=="em"}],toDOM(){return["em"]}},strong:{parseDOM:[{tag:"strong"},{tag:"b",getAttrs:t=>t.style.fontWeight!="normal"&&null},{style:"font-weight=400",clearMark:t=>t.type.name=="strong"},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}],toDOM(){return["strong"]}},link:{attrs:{href:{},title:{default:null}},inclusive:!1,parseDOM:[{tag:"a[href]",getAttrs(t){return{href:t.getAttribute("href"),title:t.getAttribute("title")}}}],toDOM(t){return["a",t.attrs]}},code:{code:!0,parseDOM:[{tag:"code"}],toDOM(){return["code"]}}}});function FJ(t,e){if(t.isText&&e.isText&&qt.sameSet(t.marks,e.marks))return t.withText(t.text+e.text)}class zJ{constructor(e,n){this.schema=e,this.tokenHandlers=n,this.stack=[{type:e.topNodeType,attrs:null,content:[],marks:qt.none}]}top(){return this.stack[this.stack.length-1]}push(e){this.stack.length&&this.top().content.push(e)}addText(e){if(!e)return;let n=this.top(),r=n.content,i=r[r.length-1],o=this.schema.text(e,n.marks),s;i&&(s=FJ(i,o))?r[r.length-1]=s:r.push(o)}openMark(e){let n=this.top();n.marks=e.addToSet(n.marks)}closeMark(e){let n=this.top();n.marks=e.removeFromSet(n.marks)}parseTokens(e){for(let n=0;n<e.length;n++){let r=e[n],i=this.tokenHandlers[r.type];if(!i)throw new Error("Token type `"+r.type+"` not supported by Markdown parser");i(this,r,e,n)}}addNode(e,n,r){let i=this.top(),o=e.createAndFill(n,r,i?i.marks:[]);return o?(this.push(o),o):null}openNode(e,n){this.stack.push({type:e,attrs:n,content:[],marks:qt.none})}closeNode(){let e=this.stack.pop();return this.addNode(e.type,e.attrs,e.content)}}function Rc(t,e,n,r){return t.getAttrs?t.getAttrs(e,n,r):t.attrs instanceof Function?t.attrs(e):t.attrs}function t0(t,e){return t.noCloseToken||e=="code_inline"||e=="code_block"||e=="fence"}function d2(t){return t[t.length-1]==`
217
+ `?t.slice(0,t.length-1):t}function n0(){}function BJ(t,e){let n=Object.create(null);for(let r in e){let i=e[r];if(i.block){let o=t.nodeType(i.block);t0(i,r)?n[r]=(s,a,l,c)=>{s.openNode(o,Rc(i,a,l,c)),s.addText(d2(a.content)),s.closeNode()}:(n[r+"_open"]=(s,a,l,c)=>s.openNode(o,Rc(i,a,l,c)),n[r+"_close"]=s=>s.closeNode())}else if(i.node){let o=t.nodeType(i.node);n[r]=(s,a,l,c)=>s.addNode(o,Rc(i,a,l,c))}else if(i.mark){let o=t.marks[i.mark];t0(i,r)?n[r]=(s,a,l,c)=>{s.openMark(o.create(Rc(i,a,l,c))),s.addText(d2(a.content)),s.closeMark(o)}:(n[r+"_open"]=(s,a,l,c)=>s.openMark(o.create(Rc(i,a,l,c))),n[r+"_close"]=s=>s.closeMark(o))}else if(i.ignore)t0(i,r)?n[r]=n0:(n[r+"_open"]=n0,n[r+"_close"]=n0);else throw new RangeError("Unrecognized parsing spec "+JSON.stringify(i))}return n.text=(r,i)=>r.addText(i.content),n.inline=(r,i)=>r.parseTokens(i.children),n.softbreak=n.softbreak||(r=>r.addText(" ")),n}class BT{constructor(e,n,r){this.schema=e,this.tokenizer=n,this.tokens=r,this.tokenHandlers=BJ(e,r)}parse(e,n={}){let r=new zJ(this.schema,this.tokenHandlers),i;r.parseTokens(this.tokenizer.parse(e,n));do i=r.closeNode();while(r.stack.length);return i||this.schema.topNodeType.createAndFill()}}function f2(t,e){for(;++e<t.length;)if(t[e].type!="list_item_open")return t[e].hidden;return!1}new BT(LJ,Kr("commonmark",{html:!1}),{blockquote:{block:"blockquote"},paragraph:{block:"paragraph"},list_item:{block:"list_item"},bullet_list:{block:"bullet_list",getAttrs:(t,e,n)=>({tight:f2(e,n)})},ordered_list:{block:"ordered_list",getAttrs:(t,e,n)=>({order:+t.attrGet("start")||1,tight:f2(e,n)})},heading:{block:"heading",getAttrs:t=>({level:+t.tag.slice(1)})},code_block:{block:"code_block",noCloseToken:!0},fence:{block:"code_block",getAttrs:t=>({params:t.info||""}),noCloseToken:!0},hr:{node:"horizontal_rule"},image:{node:"image",getAttrs:t=>({src:t.attrGet("src"),title:t.attrGet("title")||null,alt:t.children[0]&&t.children[0].content||null})},hardbreak:{node:"hard_break"},em:{mark:"em"},strong:{mark:"strong"},link:{mark:"link",getAttrs:t=>({href:t.attrGet("href"),title:t.attrGet("title")||null})},code_inline:{mark:"code",noCloseToken:!0}});function HJ(t){const e={blockquote:{block:"blockquote"},paragraph:{block:"paragraph"},list_item:{block:"listItem"},bullet_list:{block:"bulletList"},ordered_list:{block:"orderedList",getAttrs:r=>({start:+(r.attrGet("start")??1)||1})},heading:{block:"heading",getAttrs:r=>({level:+r.tag.slice(1)})},code_block:{block:"codeBlock",noCloseToken:!0,getAttrs:r=>{var i;return{language:((i=r.info)==null?void 0:i.trim())||null}}},fence:{block:"codeBlock",noCloseToken:!0,getAttrs:r=>{var i;return{language:((i=r.info)==null?void 0:i.trim())||null}}},hr:{node:"horizontalRule"},hardbreak:{node:"hardBreak"},softbreak:{ignore:!0,noCloseToken:!0},html_block:{ignore:!0,noCloseToken:!0},html_inline:{ignore:!0,noCloseToken:!0},image:{ignore:!0,noCloseToken:!0},em:{mark:"italic"},strong:{mark:"bold"},s:{mark:"strike"},code_inline:{mark:"code",noCloseToken:!0},link:{mark:"link",getAttrs:r=>({href:sT(r.attrGet("href")),title:r.attrGet("title")||null})}},n={};for(const[r,i]of Object.entries(e))i.node&&!t.nodes[i.node]||i.block&&!t.nodes[i.block]||i.mark&&!t.marks[i.mark]||(n[r]=i);return n}function VJ(t){const e=Kr("commonmark",{html:!1}).enable(["strikethrough","linkify"]);return new BT(t,e,HJ(t))}function UJ(t){return t?!!(/^\s{0,3}(#{1,6}\s|[-*+]\s|\d+[.)]\s|>\s|```|~~~|-{3,}\s*$|\*{3,}\s*$|_{3,}\s*$)/m.test(t)||/(\*\*\S(?:[^*\n]*\S)?\*\*|__\S(?:[^_\n]*\S)?__|\*\S(?:[^*\n]*\S)?\*|`[^`\n]+`|~~\S(?:[^~\n]*\S)?~~|\[[^\]\n]+\]\([^)\n]+\))/.test(t)):!1}function jJ(t,e){if(!UJ(t))return null;let n;try{const i=VJ(e).parse(t);if(!i)return null;n=i}catch{return null}return n.childCount===0?null:Le.maxOpen(n.content)}var qJ=T('<div role="presentation" data-testid="editor-root"></div>');function WJ(t,e){We(e,!0);const n=new Set([...xd].filter(h=>h!==".docx"));function r(h,p){const m=p.includes("\\")?"\\":"/",v=h.indexOf("#"),g=v>=0?h.slice(0,v):h;if(!g)return null;const b=g.match(/\.[^./\\]+$/),_=b?b[0].toLowerCase():"";if(!n.has(_))return null;const k=p.split(m);k.pop();const E=g.replace(/\//g,m).split(m),I=[...k];for(const A of E)A===".."?I.length>0&&I.pop():A!=="."&&I.push(A);return I.join(m)}let i=F(null),o=null;const s=L(()=>e.format==="docx");he(()=>{if(e.ydoc,e.provider,!o)return;const h=new Sj({element:o,extensions:[JK.configure({history:!1,listItem:!1}),IG,vq.configure({multicolor:!0}),qq.configure({openOnClick:!1,HTMLAttributes:{rel:"noopener noreferrer",target:"_blank"}}),yq.configure({allowBase64:!0}),Wq.configure({placeholder:"Start typing…"}),ZW.configure({resizable:!0}),XW,YW,JW,NG,PG,hq.configure({document:e.ydoc}),pq.configure({provider:e.provider,user:{name:u1(),color:"var(--tandem-warning)"}}),aG.configure({ydoc:e.ydoc}),hG.configure({ydoc:e.ydoc}),MG.configure({filePath:At(()=>e.currentFilePath??null)}),gG.configure({ydoc:e.ydoc}),vG.configure({ydoc:e.ydoc}),JG.configure({onOpenChange:e.onSlashCommandMenuChange}),xG,FG],editorProps:{attributes:{class:"tandem-editor",style:"outline: none; font-size: var(--tandem-editor-font-size, 16px); line-height: 1.6;"},clipboardTextParser:(m,v,g,b)=>{if(!g){const _=jJ(m,b.state.schema);if(_)return _}return iT(m,b.state.schema,v.marks())}},editable:At(()=>!e.readOnly),autofocus:At(()=>!e.readOnly)});y(i,h,!0),At(()=>{var m;return(m=e.onEditorReady)==null?void 0:m.call(e,h)});const p=sG(h,{openHref:m=>{l(m)}});return()=>{At(()=>{var m;return(m=e.onEditorReady)==null?void 0:m.call(e,null)}),p(),h.destroy(),d(i)===h&&y(i,null)}});let a;he(()=>{const h=d(i);if(!h)return;const p=e.readOnly;a!==p&&(a=p,h.setEditable(!p))}),he(()=>{const h=d(i);if(h)return cE(p=>h.commands.updateUser({name:p}))}),he(()=>{const h=d(i);if(!h)return;const p=h.view.dom;p.querySelectorAll(".tandem-annotation-active").forEach(m=>{m.classList.remove("tandem-annotation-active")}),e.activeAnnotationId&&p.querySelectorAll(`[data-annotation-id="${CSS.escape(e.activeAnnotationId)}"]`).forEach(m=>{m.classList.add("tandem-annotation-active")})});async function l(h){if(!(!h||h.startsWith("#"))){if(oT(h)){window.open(h,"_blank","noopener,noreferrer");return}if(e.currentFilePath){const p=r(h,e.currentFilePath);if(p){const m=await Wo(p);m.ok||console.warn(`[tandem] Could not open linked file "${p}": ${m.error}`)}}}}async function c(h){var _;const p=h.target.closest("a[href]");if(p){const k=p.getAttribute("href")??"";if(!k||k.startsWith("#"))return;h.preventDefault(),await l(k);return}const m={highlight:2,comment:1,note:0};let v=h.target.closest("[data-annotation-id]"),g=null,b=Number.NEGATIVE_INFINITY;for(;v;){const k=v.getAttribute("data-annotation-id");if(k){const E=v.getAttribute("data-annotation-type")??"",I=m[E]??-1;I>b&&(b=I,g=k)}const C=v.parentElement;v=C?C.closest("[data-annotation-id]"):null}g&&e.onAnnotationClick?e.onAnnotationClick(g):g||(_=e.onClearAnnotation)==null||_.call(e)}var u=qJ();let f;St(u,h=>o=h,()=>o),j(()=>f=yt(u,1,"",null,f,{"tandem-paged":d(s)})),P("click",u,c),S(t,u),Ke()}et(["click"]);var KJ=T('<div data-testid="find-scope-pills" class="fr-scope-row svelte-1q9bff2"><button data-testid="find-scope-doc">This document</button> <button data-testid="find-scope-tabs">Open tabs</button></div>'),GJ=T('<div class="fr-error svelte-1q9bff2" role="alert"> </div>'),ZJ=T('<div class="fr-warning svelte-1q9bff2" role="status"> </div>'),YJ=T('<div class="fr-xdoc-status svelte-1q9bff2">Searching…</div>'),JJ=T('<div class="fr-xdoc-status svelte-1q9bff2">No matches in open tabs</div>'),XJ=T('<div class="fr-xdoc-snip svelte-1q9bff2"> </div>'),QJ=T('<div class="fr-xdoc-row svelte-1q9bff2"><div class="fr-xdoc-name svelte-1q9bff2"> <span class="fr-xdoc-count svelte-1q9bff2"> </span></div> <!></div>'),$J=T('<div data-testid="find-cross-doc-results" class="fr-xdoc svelte-1q9bff2"><!></div>'),eX=T('<div data-testid="find-replace-bar" role="dialog" tabindex="-1" aria-modal="false" aria-label="Find and replace" class="fr-bar svelte-1q9bff2"><!> <div class="fr-row svelte-1q9bff2"><input data-testid="find-input" type="text" placeholder="Find…" aria-label="Find"/> <span data-testid="find-match-count" class="fr-count svelte-1q9bff2"><!></span> <button data-testid="find-prev-btn" class="fr-nav svelte-1q9bff2" title="Previous match (Shift+Enter)" aria-label="Previous match">↑</button> <button data-testid="find-next-btn" class="fr-nav svelte-1q9bff2" title="Next match (Enter)" aria-label="Next match">↓</button> <button data-testid="find-close-btn" class="fr-close svelte-1q9bff2" title="Close (Esc)" aria-label="Close find bar">×</button></div> <!> <div class="fr-options svelte-1q9bff2"><label class="fr-toggle svelte-1q9bff2"><input data-testid="find-case-toggle" type="checkbox"/> Aa</label> <label class="fr-toggle svelte-1q9bff2"><input data-testid="find-word-toggle" type="checkbox"/> \\b</label> <label class="fr-toggle svelte-1q9bff2"><input data-testid="find-regex-toggle" type="checkbox"/> .*</label></div> <div class="fr-row svelte-1q9bff2"><input data-testid="replace-input" type="text" placeholder="Replace with…" aria-label="Replace with" class="fr-input svelte-1q9bff2"/> <button data-testid="replace-btn" class="fr-replace-btn svelte-1q9bff2">Replace</button> <button data-testid="replace-all-btn" class="fr-replace-btn svelte-1q9bff2"><!></button></div> <!> <!></div>');function tX(t,e){We(e,!0);let n=Ue(e,"tabs",19,()=>[]),r=F("doc"),i=F(Qe([])),o=F(!1);he(()=>{n().length<=1&&d(r)==="tabs"&&(y(r,"doc"),y(i,[],!0),y(o,!1))});function s(ne){const te=ne.getXmlFragment("default"),le=[];function se(me){if(me instanceof kn)le.push(me.toString());else{for(let K=0;K<me.length;K++){const H=me.get(K);(H instanceof kn||H instanceof ln)&&se(H)}me instanceof ln&&me.nodeName!=="text"&&le.push(" ")}}return se(te),le.join("")}function a(ne,te,le){const se=s(ne),me=le?te:te.toLowerCase(),K=le?se:se.toLowerCase(),H=[];let O=0,G=0;for(;(G=K.indexOf(me,G))!==-1;){if(O++,H.length<3){const z=Math.max(0,G-30),Q=Math.min(se.length,G+me.length+30),ge=se.slice(z,Q).replace(/\s+/g," ").trim();H.push((z>0?"…":"")+ge+(Q<se.length?"…":""))}G+=me.length}return{count:O,snippets:H}}let l;gr(()=>clearTimeout(l));function c(ne,te){if(clearTimeout(l),!ne){y(i,[],!0),y(o,!1);return}y(o,!0),l=setTimeout(()=>{const le=[];for(const se of n()){if(!se.ydoc)continue;const{count:me,snippets:K}=a(se.ydoc,ne,te);me>0&&le.push({tabId:se.id,fileName:se.fileName,count:me,snippets:K})}y(i,le,!0),y(o,!1)},300)}let u=F(""),f=F(""),h=F(!1),p=F(!1),m=F(!1),v=F(null),g=F(!1),b=F(null),_=F(null),k=F(0);const C=L(()=>(d(k),e.editor?_l(e.editor.state):void 0)),E=L(()=>{var ne;return((ne=d(C))==null?void 0:ne.matches.length)??0}),I=L(()=>{var ne;return((ne=d(C))==null?void 0:ne.activeIndex)??-1});let A=F(null);he(()=>{var ne;e.open&&((ne=d(A))==null||ne.focus())});let M=!1;he(()=>{const ne=e.open&&!M;M=e.open,!(!ne||!e.forceScope)&&(e.forceScope==="tabs"&&n().length>1?(y(r,"tabs"),c(d(u),d(h))):y(r,"doc"))}),he(()=>{const ne=e.editor;if(!ne||ne.isDestroyed)return;const te=()=>vu(k);return ne.on("update",te),ne.on("selectionUpdate",te),()=>{ne.isDestroyed||(ne.off("update",te),ne.off("selectionUpdate",te))}});function N(){if(d(r)==="tabs"){c(d(u),d(h));return}const ne=e.editor;if(!ne||!d(u)){y(v,null),ne==null||ne.commands.findClose();return}if(d(m))try{new RegExp(d(u)),y(v,null)}catch(le){y(v,le instanceof Error?le.message:"Invalid regex",!0);return}else y(v,null);const te={query:d(u),caseSensitive:d(h),wholeWord:d(p),regexMode:d(m)};ne.commands.find(te)}function R(ne){var te;y(r,ne,!0),ne==="tabs"?((te=e.editor)==null||te.commands.findClose(),c(d(u),d(h))):(y(i,[],!0),clearTimeout(l),N())}function B(ne){var te,le;if(ne.key==="Enter"){ne.preventDefault(),ne.shiftKey?(te=e.editor)==null||te.commands.findPrev():(le=e.editor)==null||le.commands.findNext();return}ne.key==="Escape"&&Z()}function Z(){var ne;(ne=e.editor)==null||ne.commands.findClose(),e.onClose()}async function q(){const ne=e.editor;if(!ne||!d(u)||d(g))return;const te=d(E);if(te>500&&!window.confirm(`Replace all ${te} occurrences? This cannot be undone as a single action.`))return;y(g,!0),y(_,null),y(b,{replaced:0,total:te},!0);const{replaced:le,partial:se}=await _G(ne.view,d(f),(me,K)=>{y(b,{replaced:me,total:K},!0)});y(b,null),y(g,!1),se&&y(_,`Replaced ${le} of ${te}; re-run to continue`)}var Y=Mt(),X=Ie(Y);{var ae=ne=>{var te=eX(),le=w(te);{var se=fe=>{var Te=KJ(),ce=w(Te);let Oe;var He=x(ce,2);let it;j(()=>{Oe=yt(ce,1,"fr-scope-pill svelte-1q9bff2",null,Oe,{on:d(r)==="doc"}),V(ce,"aria-pressed",d(r)==="doc"),it=yt(He,1,"fr-scope-pill svelte-1q9bff2",null,it,{on:d(r)==="tabs"}),V(He,"aria-pressed",d(r)==="tabs")}),P("click",ce,()=>R("doc")),P("click",He,()=>R("tabs")),S(fe,Te)};W(le,fe=>{n().length>1&&fe(se)})}var me=x(le,2),K=w(me);let H;St(K,fe=>y(A,fe),()=>d(A));var O=x(K,2),G=w(O);{var z=fe=>{var Te=hr();j(()=>J(Te,d(E)===0?"No matches":`${d(I)+1} / ${d(E)}`)),S(fe,Te)};W(G,fe=>{d(u)&&fe(z)})}var Q=x(O,2),ge=x(Q,2),ye=x(ge,2),Se=x(me,2);{var ee=fe=>{var Te=GJ(),ce=w(Te);j(()=>J(ce,d(v))),S(fe,Te)};W(Se,fe=>{d(v)&&fe(ee)})}var de=x(Se,2),xe=w(de),Ee=w(xe),D=x(xe,2),$=w(D),ke=x(D,2),we=w(ke),Ae=x(de,2),pe=w(Ae),oe=x(pe,2),De=x(oe,2),ze=w(De);{var Ge=fe=>{var Te=hr();j(()=>J(Te,`${d(b).replaced??""}/${d(b).total??""}`)),S(fe,Te)},Ce=fe=>{var Te=hr("All");S(fe,Te)};W(ze,fe=>{d(g)&&d(b)?fe(Ge):fe(Ce,-1)})}var ie=x(Ae,2);{var ve=fe=>{var Te=ZJ(),ce=w(Te);j(()=>J(ce,d(_))),S(fe,Te)};W(ie,fe=>{d(_)&&fe(ve)})}var Ye=x(ie,2);{var ut=fe=>{var Te=$J(),ce=w(Te);{var Oe=Xe=>{var Re=YJ();S(Xe,Re)},He=Xe=>{var Re=JJ();S(Xe,Re)},it=Xe=>{var Re=Mt(),ot=Ie(Re);nt(ot,17,()=>d(i),zl,(tt,at)=>{var _t=QJ(),Fe=w(_t),dt=w(Fe),ht=x(dt),Ft=w(ht),Sn=x(Fe,2);nt(Sn,17,()=>d(at).snippets,zl,(Gr,Fi)=>{var on=XJ(),Wn=w(on);j(()=>J(Wn,d(Fi))),S(Gr,on)}),j(()=>{J(dt,`${d(at).fileName??""} `),J(Ft,`(${d(at).count??""} ${d(at).count===1?"match":"matches"})`)}),S(tt,_t)}),S(Xe,Re)};W(ce,Xe=>{d(o)?Xe(Oe):d(u)&&d(i).length===0?Xe(He,1):Xe(it,-1)})}S(fe,Te)};W(Ye,fe=>{d(r)==="tabs"&&fe(ut)})}j(()=>{H=yt(K,1,"fr-input svelte-1q9bff2",null,H,{"has-error":!!d(v)}),Q.disabled=d(E)===0,ge.disabled=d(E)===0,oe.disabled=d(E)===0||d(g)||d(r)==="tabs",V(oe,"title",d(r)==="tabs"?"Replace is not available in Open tabs mode":void 0),De.disabled=d(E)===0||d(g)||d(r)==="tabs",V(De,"title",d(r)==="tabs"?"Replace All is not available in Open tabs mode":void 0)}),P("keydown",te,B),P("input",K,N),Xn(K,()=>d(u),fe=>y(u,fe)),P("click",Q,()=>{var fe;return(fe=e.editor)==null?void 0:fe.commands.findPrev()}),P("click",ge,()=>{var fe;return(fe=e.editor)==null?void 0:fe.commands.findNext()}),P("click",ye,Z),P("change",Ee,N),Lf(Ee,()=>d(h),fe=>y(h,fe)),P("change",$,N),Lf($,()=>d(p),fe=>y(p,fe)),P("change",we,N),Lf(we,()=>d(m),fe=>y(m,fe)),Xn(pe,()=>d(f),fe=>y(f,fe)),P("click",oe,()=>{e.editor&&(kG(e.editor.view,d(f)),vu(k))}),P("click",De,q),S(ne,te)};W(X,ne=>{e.open&&ne(ae)})}S(t,Y),Ke()}et(["keydown","click","input","change"]);function Co(t,e){function n(r){t.contains(r.target)||e(r)}return document.addEventListener("mousedown",n),{destroy(){document.removeEventListener("mousedown",n)}}}var nX=T('<div class="menu-div svelte-94a7fq" role="separator"></div> <button type="button" class="mi link svelte-94a7fq" data-testid="decorations-settings-link" role="menuitem"><span>Appearance settings…</span> <kbd class="svelte-94a7fq">Ctrl+,</kbd></button>',1),rX=T('<div class="menu svelte-94a7fq" role="menu" aria-label="Decorations"><div class="menu-head svelte-94a7fq">Decorations</div> <button type="button" data-testid="decorations-row-authorship" role="menuitemcheckbox"><span class="mi-ic svelte-94a7fq"><svg viewBox="0 0 24 24" aria-hidden="true" class="svelte-94a7fq"><circle cx="9.5" cy="12" r="5" fill="var(--tandem-author-user)"></circle><circle cx="14.5" cy="12" r="5" fill="var(--tandem-author-claude)"></circle></svg></span> <span class="mi-label svelte-94a7fq">Authorship colors</span> <span class="chk svelte-94a7fq" aria-hidden="true"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" class="svelte-94a7fq"><path d="M20 6 9 17l-5-5"></path></svg></span></button> <button type="button" data-testid="decorations-row-comments" role="menuitemcheckbox"><span class="mi-ic svelte-94a7fq"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" class="svelte-94a7fq"><path d="M21 11.5a8.5 8.5 0 0 1-12.5 7.5L3 21l1.6-5A8.5 8.5 0 1 1 21 11.5z"></path></svg></span> <span class="mi-label svelte-94a7fq">Comments</span> <span class="chk svelte-94a7fq" aria-hidden="true"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" class="svelte-94a7fq"><path d="M20 6 9 17l-5-5"></path></svg></span></button> <button type="button" data-testid="decorations-row-highlights" role="menuitemcheckbox"><span class="mi-ic svelte-94a7fq"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" class="svelte-94a7fq"><rect x="3" y="9" width="18" height="6" rx="2" fill="currentColor" opacity="0.25" stroke="none"></rect><path d="M4 6h16M4 18h11"></path></svg></span> <span class="mi-label svelte-94a7fq">Highlights</span> <span class="chk svelte-94a7fq" aria-hidden="true"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" class="svelte-94a7fq"><path d="M20 6 9 17l-5-5"></path></svg></span></button> <button type="button" data-testid="decorations-row-notes" role="menuitemcheckbox"><span class="mi-ic svelte-94a7fq"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" class="svelte-94a7fq"><path d="M14 3H6a1 1 0 0 0-1 1v16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V8z"></path><path d="M14 3v5h5"></path><path d="M8 13h7M8 17h4"></path></svg></span> <span class="mi-label svelte-94a7fq">Notes <span class="mi-tag svelte-94a7fq">· private</span></span> <span class="chk svelte-94a7fq" aria-hidden="true"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" class="svelte-94a7fq"><path d="M20 6 9 17l-5-5"></path></svg></span></button> <!></div>'),iX=T('<div data-testid="decorations-menu" data-tauri-drag-region="false"><button type="button" data-testid="decorations-mute-toggle"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" class="svelte-94a7fq"><path d="M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7S2 12 2 12z"></path><circle cx="12" cy="12" r="3"></circle></svg></button> <span class="split-div svelte-94a7fq" aria-hidden="true"></span> <button type="button" class="ib half-caret svelte-94a7fq" data-testid="decorations-menu-caret" aria-haspopup="menu" title="Decoration options" aria-label="Decoration options"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" class="svelte-94a7fq"><path d="m6 9 6 6 6-6"></path></svg></button> <!></div>');function HT(t,e){We(e,!0);let n=F(!1),r=F(null);function i(){e.onUpdate({decorationsMuted:!e.decorationsMuted})}function o(g,b){e.onUpdate({[g]:!b,...e.decorationsMuted?{decorationsMuted:!1}:{}})}function s(){var g;y(n,!1),(g=d(r))==null||g.focus()}function a(g){g.key==="Escape"&&d(n)&&(g.stopPropagation(),s())}function l(){var g;(g=e.onOpenSettings)==null||g.call(e),y(n,!1)}var c=iX();let u;var f=w(c);let h;var p=x(f,4);St(p,g=>y(r,g),()=>d(r));var m=x(p,2);{var v=g=>{var b=rX(),_=x(w(b),2);let k;var C=x(_,2);let E;var I=x(C,2);let A;var M=x(I,2);let N;var R=x(M,2);{var B=Z=>{var q=nX(),Y=x(Ie(q),2);P("click",Y,l),S(Z,q)};W(R,Z=>{e.onOpenSettings&&Z(B)})}j(()=>{k=yt(_,1,"mi svelte-94a7fq",null,k,{on:e.showAuthorship}),V(_,"aria-checked",e.showAuthorship),E=yt(C,1,"mi svelte-94a7fq",null,E,{on:e.showComments}),V(C,"aria-checked",e.showComments),A=yt(I,1,"mi svelte-94a7fq",null,A,{on:e.showHighlights}),V(I,"aria-checked",e.showHighlights),N=yt(M,1,"mi svelte-94a7fq",null,N,{on:e.showNotes}),V(M,"aria-checked",e.showNotes)}),P("click",_,()=>o("showAuthorship",e.showAuthorship)),P("click",C,()=>o("showComments",e.showComments)),P("click",I,()=>o("showHighlights",e.showHighlights)),P("click",M,()=>o("showNotes",e.showNotes)),S(g,b)};W(m,g=>{d(n)&&g(v)})}Tr(c,(g,b)=>Co==null?void 0:Co(g,b),()=>()=>y(n,!1)),j(()=>{u=yt(c,1,"split menu-wrap svelte-94a7fq",null,u,{open:d(n)}),h=yt(f,1,"ib half-main svelte-94a7fq",null,h,{on:!e.decorationsMuted}),V(f,"aria-pressed",!e.decorationsMuted),V(f,"title",e.decorationsMuted?"Restore decorations":"Mute decorations"),V(f,"aria-label",e.decorationsMuted?"Restore decorations":"Mute decorations"),V(p,"aria-expanded",d(n))}),P("keydown",c,a),P("click",f,i),P("click",p,()=>y(n,!d(n))),S(t,c),Ke()}et(["keydown","click"]);function ry(t,e,n,r={}){const{capture:i=!0}=r;function o(s){const a=t();a&&(s.target instanceof Node&&a.contains(s.target)||n(s))}for(const s of e)document.addEventListener(s,o,i);return()=>{for(const s of e)document.removeEventListener(s,o,i)}}function oX(t){var n;const e=(n=t.closest)==null?void 0:n.call(t,"[data-tauri-drag-region]");return!!e&&e.getAttribute("data-tauri-drag-region")!=="false"}function wi(t){return e=>{e.preventDefault(),t()}}function sX(t){const e=t.getAttributes("link").href;return e===void 0?"":typeof e=="string"?e:(console.warn("[tandem] getInitialLinkHref: non-string href attribute",{href:e}),"")}function aX(t,e){const n=e.trim();n?t.chain().focus().setLink({href:n}).run():t.isActive("link")&&t.chain().focus().unsetLink().run()}var lX=T('<button type="button"><!></button>');function wr(t,e){const n=Ue(e,"disabled",3,!1),r=Ue(e,"active",3,!1),i=Ue(e,"style",3,""),o=L(()=>e.ariaLabel??(typeof e.label=="string"?e.label:void 0)),s=L(()=>d(o)??""),a=L(()=>n()&&e.disabledTitle?e.disabledTitle:e.shortcut?`${d(s)} (${e.shortcut})`:d(s));var l=lX();let c;var u=w(l);{var f=p=>{var m=Mt(),v=Ie(m);wd(v,()=>e.children),S(p,m)},h=p=>{var m=hr();j(()=>J(m,e.label)),S(p,m)};W(u,p=>{e.children?p(f):p(h,-1)})}j(()=>{c=yt(l,1,"toolbar-btn svelte-xw5pw0",null,c,{"is-active":r()}),V(l,"data-testid",e.testId),l.disabled=n(),V(l,"title",d(a)),V(l,"aria-label",d(o)),V(l,"aria-pressed",e.ariaPressed),V(l,"aria-haspopup",e.ariaHasPopup),V(l,"aria-expanded",e.ariaExpanded),Me(l,i())}),P("mousedown",l,function(...p){var m;(m=e.onMouseDown)==null||m.apply(this,p)}),P("click",l,function(...p){var m;(m=e.onClick)==null||m.apply(this,p)}),S(t,l)}et(["mousedown","click"]);var cX=Dr('<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>'),uX=Dr('<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>'),dX=T('<!> <!> <div style="width: 1px; height: 16px; background: var(--tandem-border); margin: 0 2px;"></div>',1),fX=Dr('<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>'),hX=T(`<div role="dialog" aria-label="Insert link" style="position: absolute; top: 100%; left: 0; margin-top: 4px;
218
+ background: var(--tandem-surface); border: 1px solid var(--tandem-border);
219
+ border-radius: var(--tandem-r-3); padding: 6px;
220
+ display: flex; align-items: center; gap: 4px;
221
+ 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;
222
+ border: 1px solid var(--tandem-border); border-radius: var(--tandem-r-2);
223
+ background: var(--tandem-surface); color: var(--tandem-fg);
224
+ 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;
225
+ border: 1px solid var(--tandem-accent-border); background: transparent;
226
+ color: var(--tandem-accent); border-radius: var(--tandem-r-2); cursor: pointer;
227
+ 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;
228
+ border: 1px solid var(--tandem-border); background: transparent;
229
+ color: var(--tandem-fg-muted); border-radius: var(--tandem-r-2); cursor: pointer;">Cancel</button></div>`),pX=T('<span style="font-family: var(--tandem-font-serif); font-weight: 600; font-size: 13.5px; line-height: 1;"> </span> <span aria-hidden="true" style="color: var(--tandem-fg-faint); font-size: 10px; line-height: 1;">▾</span>',1),mX=T('<button type="button" role="menuitemradio"> </button>'),gX=T(`<div role="menu" aria-label="Heading level" style="position: absolute; top: 100%; left: 0; margin-top: 4px;
230
+ background: var(--tandem-surface); border: 1px solid var(--tandem-border);
231
+ border-radius: var(--tandem-r-3); padding: 4px; display: flex; flex-direction: column;
232
+ gap: 2px; z-index: var(--tandem-z-dropdown); box-shadow: var(--tandem-shadow-1);"></div>`),vX=Dr('<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>'),bX=Dr('<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>'),yX=Dr('<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>'),wX=Dr('<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>'),xX=T('<div style="display: flex; align-items: center; gap: 1px;"><!> <!> <!> <!> <!> <div style="position: relative;" role="presentation"><!> <!></div> <div style="width: 1px; height: 16px; background: var(--tandem-border); margin: 0 2px;"></div> <div style="position: relative;" role="presentation"><!> <!></div> <!> <!> <!> <!> <!></div>');function VT(t,e){We(e,!0);const n=Ue(e,"disabled",3,!1),r=Ue(e,"variant",3,"bar"),i=L(()=>r()==="bar"),o=L(()=>r()==="bar"),s=[1,2,3],a={1:700,2:600,3:500};let l=F(0),c=F(!1),u=F(!1),f=F(""),h=F(null);he(()=>{const D=e.editor;if(!D||D.isDestroyed)return;const $=()=>{D.isDestroyed||vu(l)};return D.on("transaction",$),()=>{D.isDestroyed||D.off("transaction",$)}}),he(()=>{var D,$;d(u)&&((D=d(h))==null||D.focus(),($=d(h))==null||$.select())});function p(D){for(const $ of s)if(D.isActive("heading",{level:$}))return $;return null}const m=L(()=>e.editor?e.editor.isEditable:!1),v=L(()=>!d(m)||!!n()),g=L(()=>(d(l),e.editor?eo.getState(e.editor.state):null)),b=L(()=>{var D,$;return!d(v)&&((($=(D=d(g))==null?void 0:D.undoManager)==null?void 0:$.undoStack.length)??0)>0}),_=L(()=>{var D,$;return!d(v)&&((($=(D=d(g))==null?void 0:D.undoManager)==null?void 0:$.redoStack.length)??0)>0}),k=L(()=>(d(l),e.editor?p(e.editor):null)),C=L(()=>{var D;return d(l),!!((D=e.editor)!=null&&D.isActive("bold"))}),E=L(()=>{var D;return d(l),!!((D=e.editor)!=null&&D.isActive("italic"))}),I=L(()=>{var D;return d(l),!!((D=e.editor)!=null&&D.isActive("strike"))}),A=L(()=>{var D;return d(l),!!((D=e.editor)!=null&&D.isActive("code"))}),M=L(()=>{var D;return d(l),!!((D=e.editor)!=null&&D.isActive("bulletList"))}),N=L(()=>{var D;return d(l),!!((D=e.editor)!=null&&D.isActive("orderedList"))}),R=L(()=>{var D;return d(l),!!((D=e.editor)!=null&&D.isActive("blockquote"))}),B=L(()=>{var D;return d(l),!!((D=e.editor)!=null&&D.isActive("codeBlock"))}),Z=L(()=>{var D;return d(l),!!((D=e.editor)!=null&&D.isActive("link"))}),q=L(()=>(d(l),e.editor?d(v)||!e.editor.isActive("link")&&e.editor.state.selection.from===e.editor.state.selection.to:!0)),Y=L(()=>d(k)?`H${d(k)}`:"H"),X=L(()=>wi(()=>{var D;return(D=e.editor)==null?void 0:D.commands.undo()})),ae=L(()=>wi(()=>{var D;return(D=e.editor)==null?void 0:D.commands.redo()})),ne=L(()=>wi(()=>{var D;return(D=e.editor)==null?void 0:D.chain().focus().toggleBold().run()})),te=L(()=>wi(()=>{var D;return(D=e.editor)==null?void 0:D.chain().focus().toggleItalic().run()})),le=L(()=>wi(()=>{var D;return(D=e.editor)==null?void 0:D.chain().focus().toggleStrike().run()})),se=L(()=>wi(()=>{var D;return(D=e.editor)==null?void 0:D.chain().focus().toggleCode().run()})),me=L(()=>wi(()=>{var D;return(D=e.editor)==null?void 0:D.chain().focus().toggleBulletList().run()})),K=L(()=>wi(()=>{var D;return(D=e.editor)==null?void 0:D.chain().focus().toggleOrderedList().run()})),H=L(()=>wi(()=>{var D;return(D=e.editor)==null?void 0:D.chain().focus().toggleBlockquote().run()})),O=L(()=>wi(()=>{var D;return(D=e.editor)==null?void 0:D.chain().focus().setHorizontalRule().run()})),G=L(()=>wi(()=>{var D;return(D=e.editor)==null?void 0:D.chain().focus().toggleCodeBlock().run()}));function z(D){return $=>{$.detail===0&&D($)}}function Q(D){return $=>{$.preventDefault(),!(!e.editor||e.editor.isDestroyed)&&(e.editor.chain().focus().toggleHeading({level:D}).run(),y(c,!1))}}function ge(D){D.preventDefault(),e.editor&&(y(f,sX(e.editor),!0),y(u,!0))}function ye(){e.editor&&(aX(e.editor,d(f)),Se())}function Se(){y(u,!1),y(f,"")}function ee(D){D.key==="Enter"?(D.preventDefault(),D.stopPropagation(),ye()):D.key==="Escape"&&(D.preventDefault(),D.stopPropagation(),Se())}var de=Mt(),xe=Ie(de);{var Ee=D=>{var $=xX(),ke=w($);{var we=Re=>{var ot=dX(),tt=Ie(ot);{const _t=ht=>{var Ft=cX();S(ht,Ft)};let Fe=L(()=>!d(b)),dt=L(()=>z(d(X)));wr(tt,{ariaLabel:"Undo",shortcut:"Ctrl+Z",get disabled(){return d(Fe)},get onMouseDown(){return d(X)},get onClick(){return d(dt)},children:_t,$$slots:{default:!0}})}var at=x(tt,2);{const _t=ht=>{var Ft=uX();S(ht,Ft)};let Fe=L(()=>!d(_)),dt=L(()=>z(d(ae)));wr(at,{ariaLabel:"Redo",shortcut:"Ctrl+Shift+Z",get disabled(){return d(Fe)},get onMouseDown(){return d(ae)},get onClick(){return d(dt)},children:_t,$$slots:{default:!0}})}S(Re,ot)};W(ke,Re=>{d(i)&&Re(we)})}var Ae=x(ke,2);{let Re=L(()=>z(d(ne)));wr(Ae,{label:"B",shortcut:"Ctrl+B",get disabled(){return d(v)},get active(){return d(C)},get onMouseDown(){return d(ne)},get onClick(){return d(Re)},style:"font-weight: 700;"})}var pe=x(Ae,2);{let Re=L(()=>z(d(te)));wr(pe,{label:"I",shortcut:"Ctrl+I",get disabled(){return d(v)},get active(){return d(E)},get onMouseDown(){return d(te)},get onClick(){return d(Re)},style:"font-style: italic;"})}var oe=x(pe,2);{let Re=L(()=>z(d(le)));wr(oe,{label:"S",shortcut:"Ctrl+Shift+X",get disabled(){return d(v)},get active(){return d(I)},get onMouseDown(){return d(le)},get onClick(){return d(Re)},style:"text-decoration: line-through;"})}var De=x(oe,2);{let Re=L(()=>z(d(se)));wr(De,{label:"<>",shortcut:"Ctrl+E",get disabled(){return d(v)},get active(){return d(A)},get onMouseDown(){return d(se)},get onClick(){return d(Re)},style:"font-family: monospace;"})}var ze=x(De,2),Ge=w(ze);{const Re=at=>{var _t=fX();S(at,_t)};let ot=L(()=>d(Z)||d(u)),tt=L(()=>z(ge));wr(Ge,{ariaLabel:"Link",shortcut:"Ctrl+K",get disabled(){return d(q)},get active(){return d(ot)},ariaHasPopup:"dialog",get ariaExpanded(){return d(u)},onMouseDown:ge,get onClick(){return d(tt)},children:Re,$$slots:{default:!0}})}var Ce=x(Ge,2);{var ie=Re=>{var ot=hX(),tt=w(ot);St(tt,ht=>y(h,ht),()=>d(h));var at=x(tt,2),_t=L(()=>z(ht=>{ht.preventDefault(),ye()})),Fe=x(at,2),dt=L(()=>z(ht=>{ht.preventDefault(),Se()}));P("keydown",tt,ee),Xn(tt,()=>d(f),ht=>y(f,ht)),P("mousedown",at,ht=>{ht.preventDefault(),ye()}),P("click",at,function(...ht){var Ft;(Ft=d(_t))==null||Ft.apply(this,ht)}),P("mousedown",Fe,ht=>{ht.preventDefault(),Se()}),P("click",Fe,function(...ht){var Ft;(Ft=d(dt))==null||Ft.apply(this,ht)}),S(Re,ot)};W(Ce,Re=>{d(u)&&Re(ie)})}Tr(ze,(Re,ot)=>Co==null?void 0:Co(Re,ot),()=>Se);var ve=x(ze,4),Ye=w(ve);{const Re=_t=>{var Fe=pX(),dt=Ie(Fe),ht=w(dt);j(()=>J(ht,d(Y))),S(_t,Fe)};let ot=L(()=>d(k)?`Heading ${d(k)}`:"Heading"),tt=L(()=>d(k)!==null),at=L(()=>z(_t=>{_t.preventDefault(),y(c,!d(c))}));wr(Ye,{get ariaLabel(){return d(ot)},get disabled(){return d(v)},get active(){return d(tt)},ariaHasPopup:"menu",get ariaExpanded(){return d(c)},style:"gap: 2px; padding-right: 4px;",onMouseDown:_t=>{_t.preventDefault(),y(c,!d(c))},get onClick(){return d(at)},children:Re,$$slots:{default:!0}})}var ut=x(Ye,2);{var fe=Re=>{var ot=gX();nt(ot,20,()=>s,tt=>tt,(tt,at)=>{const _t=L(()=>Q(at));var Fe=mX(),dt=L(()=>z(d(_t))),ht=w(Fe);j(()=>{V(Fe,"aria-checked",d(k)===at),Me(Fe,`padding: 4px 12px; font-size: 13px; border: none;
233
+ border-radius: var(--tandem-r-2);
234
+ background: ${d(k)===at?"var(--tandem-accent-bg)":"transparent"};
235
+ color: ${d(k)===at?"var(--tandem-accent)":"var(--tandem-fg)"};
236
+ cursor: pointer; text-align: left;
237
+ font-weight: ${a[at]??""}; white-space: nowrap;`),J(ht,`Heading ${at??""}`)}),P("mousedown",Fe,function(...Ft){var Sn;(Sn=d(_t))==null||Sn.apply(this,Ft)}),P("click",Fe,function(...Ft){var Sn;(Sn=d(dt))==null||Sn.apply(this,Ft)}),S(tt,Fe)}),S(Re,ot)};W(ut,Re=>{d(c)&&Re(fe)})}Tr(ve,(Re,ot)=>Co==null?void 0:Co(Re,ot),()=>()=>y(c,!1));var Te=x(ve,2);{const Re=tt=>{var at=vX();S(tt,at)};let ot=L(()=>z(d(me)));wr(Te,{ariaLabel:"Bullet list",shortcut:"Ctrl+Shift+8",get disabled(){return d(v)},get active(){return d(M)},get onMouseDown(){return d(me)},get onClick(){return d(ot)},children:Re,$$slots:{default:!0}})}var ce=x(Te,2);{const Re=tt=>{var at=bX();S(tt,at)};let ot=L(()=>z(d(K)));wr(ce,{ariaLabel:"Ordered list",shortcut:"Ctrl+Shift+7",get disabled(){return d(v)},get active(){return d(N)},get onMouseDown(){return d(K)},get onClick(){return d(ot)},children:Re,$$slots:{default:!0}})}var Oe=x(ce,2);{const Re=tt=>{var at=yX();S(tt,at)};let ot=L(()=>z(d(H)));wr(Oe,{ariaLabel:"Blockquote",shortcut:"Ctrl+Shift+B",get disabled(){return d(v)},get active(){return d(R)},get onMouseDown(){return d(H)},get onClick(){return d(ot)},children:Re,$$slots:{default:!0}})}var He=x(Oe,2);{var it=Re=>{{let ot=L(()=>z(d(O)));wr(Re,{label:"—",ariaLabel:"Horizontal rule",get disabled(){return d(v)},get onMouseDown(){return d(O)},get onClick(){return d(ot)}})}};W(He,Re=>{d(o)&&Re(it)})}var Xe=x(He,2);{const Re=tt=>{var at=wX();S(tt,at)};let ot=L(()=>z(d(G)));wr(Xe,{ariaLabel:"Code block",get disabled(){return d(v)},get active(){return d(B)},get onMouseDown(){return d(G)},get onClick(){return d(ot)},children:Re,$$slots:{default:!0}})}P("keydown",ze,Re=>{Re.key==="Escape"&&Se()}),P("keydown",ve,Re=>{Re.key==="Escape"&&y(c,!1)}),S(D,$)};W(xe,D=>{e.editor&&D(Ee)})}S(t,de),Ke()}et(["keydown","mousedown","click"]);function UT(t,e,n){const r=t.getMap(Ti);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=F0(),c={id:l,author:"user",type:"highlight",audience:"private",range:{from:e.from,to:e.to},content:"",status:"pending",timestamp:Date.now(),color:n};return Po(t,()=>r.set(l,c)),"added"}if(o===n)return Po(t,()=>r.delete(i)),"removed";const s=F0(),a={id:s,author:"user",type:"highlight",audience:"private",range:{from:e.from,to:e.to},content:"",status:"pending",timestamp:Date.now(),color:n};return Po(t,()=>{r.delete(i),r.set(s,a)}),"recolored"}function kX(t,e){const n=t.getMap(Ti),r=[];for(const[i,o]of n.entries())o.type==="highlight"&&o.range.from===e.from&&o.range.to===e.to&&o.author==="user"&&o.status==="pending"&&o.content===""&&r.push(i);return r.length===0?"noop":(Po(t,()=>{for(const i of r)n.delete(i)}),"removed")}const r0=48,_f=8,i0=6,h2=4,_X=200;function CX({anchorX:t,anchorY:e,toolbarHeight:n,toolbarWidth:r,viewportHeight:i,viewportWidth:o,previousPlacement:s}){const a=_f,l=Math.max(a,o-_f-r),c=e+i0,u=c+n,f=e-i0-n,h=i-_f,p=s==="below"?h+h2:h-h2,m=u<=p,v=f>=r0,g=Math.max(r0,i-n-_f);let b,_;m?(b=c,_="below"):v?(b=f,_="above"):(b=g,_="below");const k=i-(e-i0);return{left:Math.min(Math.max(t,a),l),top:Math.min(Math.max(b,r0),g),bottom:k,placement:_}}function SX(t,e){return t.on("selectionUpdate",e),()=>t.off("selectionUpdate",e)}var EX=T('<div style="width: 1px; height: 18px; background: var(--tandem-border); margin: 0 3px; flex-shrink: 0;"></div> <div style="display: inline-flex; align-items: center;" role="presentation"><!></div>',1),AX=T('<div style="width: 1px; height: 18px; background: var(--tandem-border); margin: 0 3px; flex-shrink: 0;"></div> <button type="button" data-testid="popup-show-formatbar-btn" style="height: 26px; min-width: 26px; padding: 0 6px; border: 1px solid transparent; background: transparent; color: var(--tandem-fg-muted); border-radius: var(--tandem-r-pill); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0;"><svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path></path></svg></button>',1),TX=T('<button type="button"></button>'),MX=T('<div role="toolbar" aria-label="Selection tools"><div><div class="morph-block-inner svelte-1tvmluw"><div class="popup-format-col svelte-1tvmluw" role="presentation"><div class="pill-row tandem-floating-pill svelte-1tvmluw" data-testid="popup-format-row"><!> <!> <!></div> <div class="pill-row tandem-floating-pill svelte-1tvmluw" data-testid="popup-annotate-row"><div style="display: inline-flex; gap: 3px; padding: 0 4px;" aria-label="Highlight colors"><button type="button" data-testid="popup-highlight-none" aria-label="No highlight" title="No highlight" style="width: 16px; height: 16px; border-radius: var(--tandem-r-2); border: 1px solid var(--tandem-border); background: var(--tandem-surface); cursor: pointer; padding: 0; display: inline-flex; align-items: center; justify-content: center;"><svg viewBox="0 0 16 16" width="12" height="12" aria-hidden="true"><line x1="3.5" y1="12.5" x2="12.5" y2="3.5" stroke="var(--tandem-fg-muted)" stroke-width="1.5" stroke-linecap="round"></line></svg></button> <!></div> <div style="width: 1px; height: 18px; background: var(--tandem-border); margin: 0 3px;"></div> <button type="button" data-testid="popup-annotate-btn" aria-label="Annotate" style="height: 24px; padding: 0 12px; border: 1px solid var(--tandem-author-user); background: transparent; color: var(--tandem-author-user); border-radius: var(--tandem-r-pill); font-size: 12px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 5px;"><svg viewBox="0 0 24 24" width="12" height="12" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 20h9"></path><path d="M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4z"></path></svg> Annotate</button></div></div></div></div> <div><div class="morph-block-inner svelte-1tvmluw"><div style="display: flex; flex-direction: column; gap: 6px; padding: 6px 8px; min-width: 260px; max-width: 360px;"><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 style="display: flex; justify-content: space-between; gap: 6px;"><button type="button" data-testid="popup-note-submit" aria-label="Note to self (Alt+Enter)" 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; display: inline-flex; align-items: center; justify-content: center; gap: 6px;">Note to self <kbd style="font-family: var(--tandem-font-mono); font-size: 10px; color: var(--tandem-fg-subtle);"> </kbd></button> <button type="button" data-testid="popup-comment-submit" 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; display: inline-flex; align-items: center; justify-content: center; gap: 6px;"> <kbd style="font-family: var(--tandem-font-mono); font-size: 10px; color: var(--tandem-author-user);"> </kbd></button></div></div></div></div></div>');function DX(t,e){We(e,!0);let n=Ue(e,"selectionToolbar",3,!0),r=Ue(e,"suppressSelectionToolbar",3,!1),i=Ue(e,"requestCommentFocus",3,0),o=Ue(e,"showAuthorship",3,!0),s=Ue(e,"showComments",3,!0),a=Ue(e,"showHighlights",3,!0),l=Ue(e,"showNotes",3,!0),c=Ue(e,"decorationsMuted",3,!1),u=Ue(e,"formattingBarVisible",3,!0),f=Ue(e,"reduceMotion",3,!1);const h=uo(Or());let p=F(!1),m=F(null),v=F(null),g=F(""),b=F(null),_=F(null),k=F(!1);const C=100;let E=F(!1),I=F(!1),A,M,N=-1,R=-1,B=!1,Z=0,q=0,Y=0,X=0,ae=null,ne=null,te=!1;function le(){ae=B?Z:Y,ne=B?q:X,!Bs(f())&&(y(I,!0),clearTimeout(M),M=setTimeout(()=>{y(I,!1)},xS))}function se(){clearTimeout(A),clearTimeout(M),y(E,!1),y(I,!1),N=-1,R=-1,ae=null,ne=null,B=!1}function me(ce,Oe,He){N=ce,R=Oe,B=He,clearTimeout(A),A=setTimeout(()=>{le(),y(E,!0)},C)}const K=vC(),H=K?"⌥⏎":"Alt+⏎",O=K?"⌘⏎":"Ctrl+⏎",G=L(()=>{const ce=d(m);if(!ce)return"";const Oe=ce.placement==="above"?`bottom: ${ce.bottom}px; top: auto;`:`top: ${ce.top}px; bottom: auto;`;return`left: ${ce.left}px; ${Oe}`});let z=F(0),Q=F(Qe(window.innerHeight)),ge=F(Qe(window.innerWidth));const ye=Object.keys(Z_),Se=L(()=>!!e.editor&&!!e.ydoc&&d(p)),ee=L(()=>n()&&!r()&&d(Se)&&d(m)!==null&&d(E)),de=L(()=>d(g).trim());let xe,Ee=0,D=0;const $=3;function ke(ce){const{from:Oe,to:He}=ce.state.selection,it=Oe!==He;if(y(p,it),!it){y(m,null),xe=void 0,D=0,se(),document.activeElement!==d(_)&&y(k,!1);return}!d(E)&&!te&&(Oe!==N||He!==R)&&me(Oe,He,!1);try{const Xe=ce.view.coordsAtPos(ce.state.selection.head);Y=Xe.left,X=Xe.bottom;const Re=CX({anchorX:ae??Y,anchorY:ne??X,toolbarHeight:_X,toolbarWidth:d(z),viewportHeight:d(Q),viewportWidth:d(ge),previousPlacement:xe});if(xe=Re.placement,D=0,d(m)&&d(m).left===Re.left&&d(m).top===Re.top&&d(m).bottom===Re.bottom&&d(m).placement===Re.placement)return;y(m,{left:Re.left,top:Re.top,bottom:Re.bottom,placement:Re.placement},!0)}catch{if(D>=$){D=0,y(m,null),xe=void 0;return}D+=1,cancelAnimationFrame(Ee),Ee=requestAnimationFrame(()=>{ce.isDestroyed||ke(ce)})}}he(()=>{if(!e.editor)return;const ce=e.editor;function Oe(){ke(ce)}const He=ce.view.dom,it=He.ownerDocument;function Xe(at){at.button!==0||!at.isPrimary||(te=!0)}function Re(at){if(!te)return;te=!1,Z=at.clientX,q=at.clientY;const{from:_t,to:Fe}=ce.state.selection;_t!==Fe&&!d(E)&&me(_t,Fe,!0)}function ot(){te=!1}He.addEventListener("pointerdown",Xe),it.addEventListener("pointerup",Re),it.addEventListener("pointercancel",ot);const tt=SX(ce,Oe);return Oe(),()=>{He.removeEventListener("pointerdown",Xe),it.removeEventListener("pointerup",Re),it.removeEventListener("pointercancel",ot),cancelAnimationFrame(Ee),Ee=0,clearTimeout(A),clearTimeout(M),tt()}}),he(()=>{if(!e.editor||!d(m))return;const ce=e.editor;let Oe=0;function He(){cancelAnimationFrame(Oe),Oe=requestAnimationFrame(()=>{y(Q,window.innerHeight,!0),y(ge,window.innerWidth,!0),ke(ce)})}window.addEventListener("resize",He);let it=!1;requestAnimationFrame(()=>{it=!0});const Xe=ry(()=>d(v),["scroll"],()=>{it&&document.activeElement!==d(_)&&Ge()});return()=>{cancelAnimationFrame(Oe),window.removeEventListener("resize",He),Xe()}}),he(()=>{const ce=e.editor,Oe=d(v);if(!ce||!Oe||!d(m))return;const He=d(I),it=()=>{if(document.activeElement===d(_))return;if(d(I)){d(z)===0&&(y(z,Oe.scrollWidth,!0),ke(ce));return}const Re=Oe.getBoundingClientRect();y(z,Re.width,!0),ke(ce)};He||it();const Xe=new ResizeObserver(it);return Xe.observe(Oe),()=>Xe.disconnect()}),he(()=>{d(ee)&&!d(b)&&pe(),d(ee)||(y(b,null),document.activeElement!==d(_)&&y(g,""))});let we=0;he(()=>{if(i()===we||(we=i(),i()===0||!e.editor))return;const{from:ce,to:Oe}=e.editor.state.selection;ce!==Oe&&(At(()=>pe()),y(k,!0),y(E,!0),le(),requestAnimationFrame(()=>{var He;return(He=d(_))==null?void 0:He.focus()}))}),he(()=>{if(!e.editor||!d(ee))return;const ce=e.editor,Oe=()=>{document.activeElement!==d(_)&&pe()};return ce.on("selectionUpdate",Oe),()=>{ce.isDestroyed||ce.off("selectionUpdate",Oe)}}),he(()=>{if(!d(ee))return;function ce(Oe){Oe.key==="Escape"&&(Oe.preventDefault(),Oe.stopPropagation(),Ge())}return window.addEventListener("keydown",ce,{capture:!0}),()=>window.removeEventListener("keydown",ce,{capture:!0})});function Ae(ce,Oe,He){if(!e.editor||!e.ydoc||ce!=="highlight"&&!Oe.trim())return;const it=d(b)??e.editor.state.selection,{from:Xe,to:Re}=it;if(Xe===Re)return;const ot=ii(e.editor.state.doc,Mn(Xe)),tt=ii(e.editor.state.doc,Mn(Re)),at=F0(),Fe={id:at,author:"user",type:ce,audience:ce==="highlight"||ce==="note"?"private":"outbound",range:{from:ot,to:tt},content:Oe,status:"pending",timestamp:Date.now()};Po(e.ydoc,()=>e.ydoc.getMap(Ti).set(at,Fe)),y(b,null)}function pe(){if(!e.editor)return;const{from:ce,to:Oe}=e.editor.state.selection;y(b,{from:ce,to:Oe},!0)}function oe(ce){if(!e.editor||!e.ydoc)return;const Oe=d(b)??e.editor.state.selection,{from:He,to:it}=Oe;if(He===it)return;const Xe=ii(e.editor.state.doc,Mn(He)),Re=ii(e.editor.state.doc,Mn(it));UT(e.ydoc,{from:Xe,to:Re},ce),y(b,null),e.editor.chain().setTextSelection(it).run()}function De(){if(!e.editor||!e.ydoc)return;const ce=d(b)??e.editor.state.selection,{from:Oe,to:He}=ce;if(Oe===He)return;const it=ii(e.editor.state.doc,Mn(Oe)),Xe=ii(e.editor.state.doc,Mn(He));kX(e.ydoc,{from:it,to:Xe}),y(b,null),e.editor.chain().setTextSelection(He).run()}function ze(ce){return Oe=>{Oe.detail===0&&ce(Oe)}}function Ge(){var ce;y(p,!1),y(m,null),y(b,null),y(g,""),y(k,!1),se(),(ce=e.editor)==null||ce.chain().focus().run()}function Ce(){y(k,!0),requestAnimationFrame(()=>{var ce;return(ce=d(_))==null?void 0:ce.focus()})}function ie(){d(de)&&(Ae("comment",d(de)),Ge())}function ve(){d(de)&&(Ae("note",d(de)),Ge())}function Ye(ce){ce.key==="Enter"&&ce.altKey?(ce.preventDefault(),ve()):ce.key==="Enter"&&(ce.metaKey||ce.ctrlKey)?(ce.preventDefault(),ie()):ce.key==="Escape"&&(ce.preventDefault(),Ge())}var ut=Mt(),fe=Ie(ut);{var Te=ce=>{var Oe=MX();let He;var it=w(Oe);let Xe;var Re=w(it),ot=w(Re),tt=w(ot),at=w(tt);VT(at,{get editor(){return e.editor},variant:"popup"});var _t=x(at,2);{var Fe=vt=>{var Xt=EX(),Gt=x(Ie(Xt),2),sn=w(Gt);HT(sn,{get showAuthorship(){return o()},get showComments(){return s()},get showHighlights(){return a()},get showNotes(){return l()},get decorationsMuted(){return c()},get onUpdate(){return e.onUpdateDecorations},get onOpenSettings(){return e.onOpenSettings}}),P("mousedown",Gt,Dt=>Dt.preventDefault()),S(vt,Xt)};W(_t,vt=>{e.onUpdateDecorations&&vt(Fe)})}var dt=x(_t,2);{var ht=vt=>{var Xt=AX(),Gt=x(Ie(Xt),2),sn=L(()=>ze(()=>{var nn;return(nn=e.onToggleFormattingBar)==null?void 0:nn.call(e)})),Dt=w(Gt),It=w(Dt);j(()=>{V(Gt,"aria-label",u()?"Hide formatting bar":"Show formatting bar"),V(Gt,"title",u()?"Hide formatting bar":"Show formatting bar"),V(It,"d",u()?"m18 15-6-6-6 6":"m6 9 6 6 6-6")}),P("mousedown",Gt,nn=>{var wn;nn.preventDefault(),(wn=e.onToggleFormattingBar)==null||wn.call(e)}),P("click",Gt,function(...nn){var wn;(wn=d(sn))==null||wn.apply(this,nn)}),S(vt,Xt)};W(dt,vt=>{e.onToggleFormattingBar&&vt(ht)})}var Ft=x(tt,2),Sn=w(Ft),Gr=w(Sn),Fi=L(()=>ze(()=>{var vt;De(),(vt=e.editor)==null||vt.chain().focus().run()})),on=x(Gr,2);nt(on,17,()=>ye,zl,(vt,Xt)=>{var Gt=TX(),sn=L(()=>ze(()=>{var Dt;oe(d(Xt)),(Dt=e.editor)==null||Dt.chain().focus().run()}));j(()=>{V(Gt,"data-testid",`popup-highlight-${d(Xt)}`),V(Gt,"aria-label",`Highlight ${d(Xt)}`),V(Gt,"title",`Highlight ${d(Xt)}`),Me(Gt,`width: 16px; height: 16px; border-radius: var(--tandem-r-2); border: 1px solid var(--tandem-border); background: ${_u[d(Xt)]}; cursor: pointer; padding: 0;`)}),P("mousedown",Gt,Dt=>{var It;Dt.preventDefault(),oe(d(Xt)),(It=e.editor)==null||It.chain().focus().run()}),P("click",Gt,function(...Dt){var It;(It=d(sn))==null||It.apply(this,Dt)}),S(vt,Gt)});var Wn=x(Sn,4),yi=L(()=>ze(()=>Ce())),zi=x(it,2);let Go;var kc=w(zi),Wa=w(kc),U=w(Wa);V(U,"rows",1),St(U,vt=>y(_,vt),()=>d(_));var ue=x(U,2),_e=w(ue),Ve=x(w(_e)),wt=w(Ve),Ht=x(_e,2),Wt=w(Ht),Bi=x(Wt),Us=w(Bi);St(Oe,vt=>y(v,vt),()=>d(v)),j(()=>{He=yt(Oe,1,"tandem-floating-pill selection-popup svelte-1tvmluw",null,He,{"is-annotate":d(k),"is-below":d(m).placement==="below"}),Me(Oe,d(G)),Xe=yt(it,1,"morph-block morph-format svelte-1tvmluw",null,Xe,{"is-active":!d(k)}),it.inert=d(k),Go=yt(zi,1,"morph-block morph-annotate svelte-1tvmluw",null,Go,{"is-active":d(k)}),zi.inert=!d(k),V(_e,"title",`Note to self — private, not sent to ${h.family??""} (Alt+Enter)`),_e.disabled=!d(de),J(wt,H),V(Ht,"aria-label",`Send to ${h.family??""} (Ctrl+Enter)`),V(Ht,"title",`Send to ${h.family??""} — outbound comment (Ctrl/Cmd+Enter)`),Ht.disabled=!d(de),J(Wt,`Send to ${h.family??""} `),J(Us,O)}),P("mousedown",ot,vt=>vt.preventDefault()),P("mousedown",Gr,vt=>{var Xt;vt.preventDefault(),De(),(Xt=e.editor)==null||Xt.chain().focus().run()}),P("click",Gr,function(...vt){var Xt;(Xt=d(Fi))==null||Xt.apply(this,vt)}),P("mousedown",Wn,vt=>{vt.preventDefault(),Ce()}),P("click",Wn,function(...vt){var Xt;(Xt=d(yi))==null||Xt.apply(this,vt)}),P("keydown",U,Ye),Xn(U,()=>d(g),vt=>y(g,vt)),P("click",_e,ve),P("click",Ht,ie),Uo(1,Oe,()=>kI,()=>({reduceMotion:f()})),S(ce,Oe)};W(fe,ce=>{d(ee)&&d(m)&&ce(Te)})}S(t,ut),Ke()}et(["mousedown","click","keydown"]);function OX(t,e=document.documentElement){const n=Math.max(0,Math.min(360,Math.round(t)));return e.style.setProperty("--tandem-accent-h",`${n}deg`),()=>e.style.removeProperty("--tandem-accent-h")}function IX(t){he(()=>OX(t()))}function Cf(t){return[...t].sort((e,n)=>{const r=e.range.from-n.range.from;return r!==0?r:e.id<n.id?-1:e.id>n.id?1:0})}function jT(t,e){if(!e)return-1;for(let n=0;n<t.length;n++)if(t[n].id===e)return n;return-1}function p2(t,e){if(t.length===0)return null;const n=jT(t,e);return n===-1?t[0].id:t[(n+1)%t.length].id}function m2(t,e){if(t.length===0)return null;const n=jT(t,e);return n===-1?t[t.length-1].id:t[(n-1+t.length)%t.length].id}function RX(t,e=document.documentElement){return t?e.setAttribute("data-annotation-patterns","true"):e.removeAttribute("data-annotation-patterns"),()=>e.removeAttribute("data-annotation-patterns")}function NX(t){he(()=>RX(t()))}function PX(t){let e=F(Qe(new Map));return he(()=>{const n=t.getYdoc();if(!n){d(e).size>0&&y(e,new Map,!0);return}const r=n.getMap(eC),i=()=>{y(e,LX(r),!0)};return i(),r.observe(i),()=>r.unobserve(i)}),{get byId(){return d(e)}}}function LX(t){const e=new Map;t.forEach(n=>{const r=n;if(!r||typeof r!="object"||!r.annotationId)return;const i=e.get(r.annotationId)??[];i.push(r),e.set(r.annotationId,i)});for(const n of e.values())n.sort((r,i)=>r.timestamp-i.timestamp);return e}const FX=25;function zX(t=FX){const e=Qe([]);return{push(n){if(!(e.length&&e[e.length-1].filePath===n.filePath))for(e.push(n);e.length>t;)e.shift()},pop(){return e.pop()??null},peek(){return e.length?e[e.length-1]:null},get top(){return e.length?e[e.length-1]:null},size(){return e.length},clear(){e.length=0}}}function BX(t,e=()=>hD){let n=F(!1),r=F(!1);return he(()=>{const i=t();if(i==null){y(n,!1),y(r,!1);return}const o=Date.now()-i,s=e()-o;if(s<=0){y(n,!0);return}const a=setTimeout(()=>{y(n,!0)},s);return()=>clearTimeout(a)}),{get showBanner(){return d(n)&&!d(r)},dismiss(){y(r,!0)}}}function HX(t,e=document.documentElement){return e.setAttribute("data-density",t),()=>e.removeAttribute("data-density")}function VX(t){he(()=>HX(t()))}const Sl=200,od=600,UX=300;function g2(t){const e=X_[t];try{const n=localStorage.getItem(e);if(n){const r=parseInt(n,10);if(Number.isFinite(r))return Math.max(Sl,Math.min(od,r));console.warn(`[tandem] ignoring non-numeric panel width for ${e}: ${n}`)}}catch(n){console.warn(`[tandem] localStorage unavailable reading ${e}:`,n)}return UX}function v2(t){const{side:e}=t,n=X_[e];let r=F(Qe(t.initialWidth)),i=null;return he(()=>{!t.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 d(r)},handleResizeStart:a=>{a.preventDefault();const l=a.clientX,c=d(r);let u=c;document.body.style.userSelect="none",document.body.style.cursor="col-resize";const f=p=>{const m=p.clientX-l,v=e==="left"?c+m:c-m;u=Math.max(Sl,Math.min(od,v)),y(r,u,!0)},h=()=>{if(document.removeEventListener("mousemove",f),document.removeEventListener("mouseup",h),i=null,document.body.style.userSelect="",document.body.style.cursor="",t.getVisible())try{localStorage.setItem(n,String(u))}catch(p){console.warn(`[tandem] failed to persist ${n}:`,p)}};i={move:f,up:h},document.addEventListener("mousemove",f),document.addEventListener("mouseup",h)},handleResizeStep:a=>{const l=Math.max(Sl,Math.min(od,d(r)+a));if(y(r,l,!0),t.getVisible())try{localStorage.setItem(n,String(l))}catch(c){console.warn(`[tandem] failed to persist ${n}:`,c)}}}}const jX={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 qX(t){const e=document.documentElement;return e.style.setProperty("--tandem-editor-font-family",jX[t]),()=>e.style.removeProperty("--tandem-editor-font-family")}function WX(t){he(()=>qX(t()))}function KX(){let t=F(!1);return{get fileDragOver(){return d(t)},handleEditorDragOver:i=>{var o;Pt()||(o=i.dataTransfer)!=null&&o.types.includes("Files")&&(i.preventDefault(),y(t,!0))},handleEditorDragLeave:i=>{Pt()||(i.currentTarget===i.target||!i.currentTarget.contains(i.relatedTarget))&&y(t,!1)},handleEditorDrop:async i=>{var a;if(Pt()||(y(t,!1),!((a=i.dataTransfer)!=null&&a.files.length)))return;i.preventDefault();const o=i.dataTransfer.files[0],s=await lC(o);try{const l=await fetch(`${On}${W_}`,{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 o0(t){return!!(t!=null&&t.query)}function GX(){let t=F(null),e=F(null),n=F(null),r=F(!1),i=0;async function o(){const s=++i;try{const a=await fetch(l8,{credentials:"same-origin"});if(!a.ok){if(s!==i)return;y(t,!1),y(e,null),y(n,null),y(r,!0);return}const l=await a.json();if(s!==i)return;y(t,l.needed===!0),y(e,typeof l.serverVersion=="string"?l.serverVersion:null,!0),y(n,typeof l.confirmationNonce=="string"?l.confirmationNonce:null,!0),y(r,!0)}catch{if(s!==i)return;y(t,!1),y(e,null),y(n,null),y(r,!0)}}return o(),{get needed(){return d(t)},get serverVersion(){return d(e)},get confirmationNonce(){return d(n)},get settled(){return d(r)},refetch:o}}function ZX(t,e=document.documentElement){return t?e.setAttribute("data-high-contrast","true"):e.removeAttribute("data-high-contrast"),()=>e.removeAttribute("data-high-contrast")}function YX(t){he(()=>ZX(t()))}function JX(t,e,n,r){const i=new Map;let o=0,s=0;for(const a of t){const l=e(a);if(l){o++;try{const c=n(l.from);if(!Number.isFinite(c.top))continue;i.set(a.id,c.top-r())}catch{s++}}}return{positions:i,attempted:o,thrown:s}}function XX(t){let e=null;return{schedule(){e===null&&(e=requestAnimationFrame(()=>{e=null,t()}))},cancel(){e!==null&&(cancelAnimationFrame(e),e=null)}}}function QX(t){let e=F(Qe(new Map));function n(){if(!t.getEnabled()){d(e).size>0&&y(e,new Map,!0);return}const i=t.getEditor(),o=t.getLayerEl(),s=t.getYdoc();if(!i||!o||!s){d(e).size>0&&y(e,new Map,!0);return}const a=t.getAnnotations(),{positions:l,attempted:c,thrown:u}=JX(a,f=>$l(f,i.state.doc,s),f=>i.view.coordsAtPos(f),()=>o.getBoundingClientRect().top);c>0&&u===c&&console.warn(`[margin] coordsAtPos threw for all ${c} annotations — view may be detached`),!$X(d(e),l)&&y(e,l,!0)}const r=XX(n);return he(()=>{if(!t.getEnabled())return;const i=t.getEditor(),o=t.getLayerEl();if(!i||!o)return;const s=()=>r.schedule();i.on("transaction",s);const a=new ResizeObserver(()=>r.schedule());return a.observe(o),r.schedule(),()=>{i.off("transaction",s),a.disconnect(),r.cancel()}}),he(()=>{t.getAnnotations(),r.schedule()}),{get byId(){return d(e)}}}function $X(t,e){if(t.size!==e.size)return!1;for(const[n,r]of t){const i=e.get(n);if(i===void 0||Math.abs(i-r)>.5)return!1}return!0}const qT=V0.info,eQ=250;function tQ(t,e){return t.severity==="info"&&e-t.timestamp>=qT}function nQ(t){try{const e=localStorage.getItem(t);if(!e)return[];const n=JSON.parse(e);if(!Array.isArray(n))return[];const r=Date.now();return n.filter(o=>o!==null&&typeof o=="object"&&typeof o.id=="string"&&typeof o.message=="string"&&typeof o.timestamp=="number"&&["info","warning","error"].includes(o.severity)).filter(o=>!tQ(o,r)).slice(-iC)}catch(e){return console.warn("[useNotifications] failed to load activity history:",e),[]}}function rQ(t={}){const e=t.persist??!0,n=t.storageKey??xD;let r=F(Qe([])),i=F(Qe(e?nQ(n):[]));const o=new Map,s=new Map;let a=null;const l=()=>{if(e){a=null;try{localStorage.setItem(n,JSON.stringify(d(i)))}catch{}}},c=()=>{e&&(a&&clearTimeout(a),a=setTimeout(l,eQ))},u=A=>{const M=o.get(A);M&&(clearTimeout(M),o.delete(A))},f=(A,M)=>{u(A);const N=V0[M]??V0.info;o.set(A,setTimeout(()=>{y(r,d(r).filter(R=>R.id!==A),!0),o.delete(A)},N))},h=A=>{if(A.dedupKey){const R=d(r).findIndex(B=>B.dedupKey===A.dedupKey);if(R!==-1){const B=d(r)[R];u(B.id);const Z={...A,count:B.count+1},q=[...d(r)];q[R]=Z,y(r,q,!0),f(Z.id,Z.severity);return}}const M={...A,count:1},N=[...d(r),M];for(;N.length>wD;){const R=N.shift();u(R.id)}y(r,N,!0),f(M.id,M.severity)},p=A=>{const M=s.get(A);M&&(clearTimeout(M),s.delete(A))},m=(A,M)=>{p(A);const N=Math.max(0,qT-(Date.now()-M));s.set(A,setTimeout(()=>{s.delete(A),d(i).some(R=>R.id===A)&&(y(i,d(i).filter(R=>R.id!==A),!0),y(r,d(r).filter(R=>R.id!==A),!0),c())},N))},v=A=>{if(A.dedupKey){const R=d(i).findIndex(B=>B.dedupKey===A.dedupKey);if(R!==-1){const B=d(i)[R],Z={...A,id:B.id,count:B.count+1},q=[...d(i)];q[R]=Z,y(i,q,!0),Z.severity==="info"?m(Z.id,Z.timestamp):p(Z.id),c();return}}const M={...A,count:1},N=[...d(i),M];for(;N.length>iC;)N.shift();y(i,N,!0),M.severity==="info"&&m(M.id,M.timestamp),c()},g=(A,M)=>{v(A),(A.severity!=="info"||M)&&h(A)},b=A=>{y(r,d(r).filter(M=>M.id!==A),!0),u(A)},_=A=>{y(i,d(i).filter(M=>M.id!==A),!0),p(A),c()},k=()=>{y(i,[],!0);for(const A of s.values())clearTimeout(A);s.clear(),c()};for(const A of d(i))A.severity==="info"&&m(A.id,A.timestamp);const C=A=>g(A,!0),E=`http://127.0.0.1:${uc}${ZM}`,I=new EventSource(E);return I.onmessage=A=>{let M;try{M=JSON.parse(A.data)}catch{console.warn("[useNotifications] Malformed SSE data:",A.data);return}g(M,!1)},I.onerror=()=>{I.readyState===EventSource.CLOSED&&console.warn("[useNotifications] EventSource permanently closed. Notifications will not be delivered. Is the server running?")},gr(()=>{I.close();for(const A of o.values())clearTimeout(A);o.clear();for(const A of s.values())clearTimeout(A);s.clear(),a&&(clearTimeout(a),l())}),{get toasts(){return d(r)},get activity(){return d(i)},get total(){return d(i).length},dismiss:b,dismissActivity:_,clearActivity:k,push:C}}function b2(t,e){let n=null,r=null;const i=(...o)=>{r=o,n!==null&&clearTimeout(n),n=setTimeout(()=>{n=null;const s=r;r=null,s&&t(...s)},e)};return i.cancel=()=>{n!==null&&(clearTimeout(n),n=null),r=null},i.flush=()=>{n!==null&&(clearTimeout(n),n=null);const o=r;r=null,o&&t(...o)},i}function Xa(t){return`tandem:scratchpad:${t}`}const Ks="tandem:scratchpad:latest",y2=500;function w2(t){const e=[],n=r=>{if(r instanceof kn)return r.toString();if(r instanceof ln){let i="";for(let o=0;o<r.length;o++)i+=n(r.get(o));return i}return""};for(let r=0;r<t.length;r++){const i=t.get(r);(i instanceof ln||i instanceof kn)&&e.push(n(i))}return e.join(`
238
+ `).replace(/\n+$/,"")}function Nc(t){try{return localStorage.getItem(t)}catch{return null}}function Sf(t,e){try{localStorage.setItem(t,e)}catch{}}function Pc(t){try{localStorage.removeItem(t)}catch{}}function iQ(t){const e=new Map,n=Qe({}),r=()=>Object.values(n).some(Boolean),i=u=>{const f=u.ydoc.getXmlFragment("default"),h=w2(f),p=Xa(u.uuid);if(h.length===0){Pc(p),Nc(Ks)===u.uuid&&Pc(Ks),n[u.uuid]=!1;return}Sf(p,h),Sf(Ks,u.uuid),n[u.uuid]=!0},o=(u,f,h)=>{if(e.has(u))return;const p={uuid:u,ydoc:f,provider:h,updateHandler:()=>{},syncedHandler:null,persist:b2(()=>{},y2)};if(p.persist=b2(()=>i(p),y2),p.updateHandler=()=>p.persist(),f.on("update",p.updateHandler),e.set(u,p),h.synced)s(p);else{const m=()=>{p.syncedHandler=null,h.off("synced",m),e.get(u)===p&&s(p)};p.syncedHandler=m,h.on("synced",m)}},s=u=>{const f=u.ydoc.getXmlFragment("default");if(w2(f).length>0)return;let h=u.uuid,p=Nc(Xa(h));if(p===null&&e.size===1){const g=Nc(Ks);g&&g!==u.uuid&&(p=Nc(Xa(g)),h=g)}if(p===null||p.length===0)return;const v=p.split(`
239
+ `).map(g=>{const b=new ln("paragraph");return g.length>0&&b.insert(0,[new kn(g)]),b});Po(u.ydoc,()=>{f.length>0&&f.delete(0,f.length),f.insert(0,v)}),Sf(Xa(u.uuid),p),Sf(Ks,u.uuid),h!==u.uuid&&Pc(Xa(h)),n[u.uuid]=!0},a=u=>{const f=e.get(u);f&&(f.persist.flush(),f.ydoc.off("update",f.updateHandler),f.syncedHandler&&f.provider.off("synced",f.syncedHandler),e.delete(u))},l=u=>{var f;Pc(Xa(u)),Nc(Ks)===u&&Pc(Ks),(f=e.get(u))==null||f.persist.cancel(),n[u]=!1},c=x_(()=>{he(()=>{const u=t(),f=new Set;for(const h of u){if(!Bp(h.filePath))continue;const p=V_(h.filePath);p&&(f.add(p),o(p,h.ydoc,h.provider))}for(const h of[...e.keys()])f.has(h)||a(h)}),he(()=>{const u=f=>{if(r()){for(const h of e.values())h.persist.flush();return f.preventDefault(),f.returnValue="You have unsaved scratchpad content.","You have unsaved scratchpad content."}};return window.addEventListener("beforeunload",u),()=>window.removeEventListener("beforeunload",u)})});return{hasUnsavedContent:u=>n[u]===!0,clearUnsaved:l,destroy:()=>{c();for(const u of[...e.keys()])a(u)}}}function oQ(t,e,n){if(t.length<2)return null;const o=(t.findIndex(s=>s.id===e)+(n?-1:1)+t.length)%t.length;return t[o].id}function sQ(t,e,n){let r=null;cc(()=>{r=i=>{if(!i.ctrlKey&&!i.metaKey||i.key!=="Tab")return;const o=oQ(t(),e(),i.shiftKey);o&&(i.preventDefault(),n(o))},window.addEventListener("keydown",r)}),gr(()=>{r&&window.removeEventListener("keydown",r)})}function aQ(t,e){if(t.length===0||e<1||e>9)return null;const n=Math.min(e-1,t.length-1);return t[n].id}function Nr(t){if(t.isComposing)return!0;const e=t.target;return e?e.tagName==="INPUT"||e.tagName==="TEXTAREA":!1}function x2(t,e){const n=new Set(e),r=t.filter(s=>n.has(s)),i=new Set(r),o=e.filter(s=>!i.has(s));return[...r,...o]}function lQ(t,e,n,r,i="left"){const o=t.filter(f=>r.has(f)),s=o.indexOf(e),a=o.indexOf(n);if(s===-1||a===-1)return o;const l=[...o];l.splice(s,1);const c=l.indexOf(n),u=i==="right"?c+1:c;return l.splice(u,0,e),l}function cQ(t){let e=F(Qe([]));he(()=>{const o=t().map(a=>a.id),s=x2(d(e),o);(d(e).length!==s.length||d(e).some((a,l)=>a!==s[l]))&&y(e,s,!0)});const n=L(()=>{const i=t(),o=new Map(i.map(l=>[l.id,l])),s=i.map(l=>l.id);return x2(d(e),s).map(l=>o.get(l)).filter(Boolean)});return{get orderedTabs(){return d(n)},reorder:(i,o,s="left")=>{if(i===o)return;const a=t(),l=new Set(a.map(c=>c.id));y(e,lQ(d(e),i,o,l,s),!0)}}}function uQ(t,e){let n=F(Qe((()=>{try{const r=localStorage.getItem(Zd),i=qM.safeParse(r);return i.success?i.data:Xy}catch(r){return console.warn(`[tandem] localStorage unavailable reading ${Zd}:`,r),Xy}})()));return he(()=>{const r=d(n);try{localStorage.setItem(Zd,r)}catch(i){console.warn(`[tandem] failed to persist ${Zd}:`,i)}}),he(()=>{const r=t(),i=d(n);if(r)try{r.getMap(z0).set(vD,i)}catch(o){console.warn("[tandem] failed to broadcast tandem mode to Y.Map:",o)}}),he(()=>{const r=t(),i=e();if(r)try{r.getMap(z0).set(bD,i)}catch(o){console.warn("[tandem] failed to broadcast dwell ms to Y.Map:",o)}}),{get tandemMode(){return d(n)},setTandemMode(r){y(n,r,!0)}}}let rh=F(!1),s0=!1,WT=()=>{};const a0={get fileDragOver(){return d(rh)}};function dQ(t){const e=t.split(/[/\\]/).at(-1)??"",n=e.lastIndexOf(".");return n<=0?!1:xd.has(e.slice(n).toLowerCase())}const fQ=(()=>{const t=Array.from(xd).sort();return t.length<=1?t[0]??"":t.length===2?`${t[0]} or ${t[1]}`:`${t.slice(0,-1).join(", ")}, or ${t.at(-1)}`})();function Ef(t,e,n){WT({id:`tauri-drop-${n}-${Date.now()}`,type:"general-error",severity:e,message:t,dedupKey:n,timestamp:Date.now()})}function hQ(t){WT=t,!s0&&Pt()&&(s0=!0,yn(()=>import("./webview-KiZyy_pC.js"),__vite__mapDeps([5,6,1,2])).then(async({getCurrentWebview:e})=>{await e().onDragDropEvent(n=>{try{const r=n.payload;switch(r.type){case"enter":y(rh,!0);return;case"drop":y(rh,!1);for(const i of r.paths)if(dQ(i)){(async()=>{const o=await Wo(i);o.ok||Ef(`Couldn't open ${i}: ${o.error}`,"error","tauri-drop-open-failed")})();return}Ef(`Tandem can only open ${fQ} files`,"warning","tauri-drop-unsupported");return;case"leave":y(rh,!1);return;default:console.warn("[useTauriFileDrop] unknown payload type:",r)}}catch(r){console.error("[useTauriFileDrop] callback threw:",r),Ef("Drag-and-drop encountered an error — try the Open File dialog","error","tauri-drop-callback-error")}})}).catch(e=>{s0=!1,console.error("[useTauriFileDrop] Failed to attach onDragDropEvent:",e),Ef("Drag-and-drop unavailable — use the Open File dialog instead","warning","tauri-drop-unavailable")}))}var pd;class pQ{constructor(){ft(this,pd,F(Qe(Pt()?window.__TANDEM_INITIAL_THEME__??null:null)))}get current(){return d(re(this,pd))}set current(e){y(re(this,pd),e,!0)}}pd=new WeakMap;const Pm=new pQ;let k2=!1;function l0(t){Pm.current=t,typeof window<"u"&&(window.__TANDEM_INITIAL_THEME__=t)}function mQ(){if(k2||!Pt())return;k2=!0;let t=null;yn(async()=>{const{invoke:i}=await import("./core-DhEqZVGG.js");return{invoke:i}},[]).then(({invoke:i})=>{t=i,i("get_app_theme").then(o=>{l0(o==="dark"?"dark":"light")}).catch(o=>{console.warn("[useTauriTheme] get_app_theme failed:",o)})}).catch(i=>{console.warn("[useTauriTheme] Tauri API import failed:",i)}),yn(async()=>{const{getCurrentWindow:i}=await import("./window-DePn7tLG.js").then(o=>o.w);return{getCurrentWindow:i}},__vite__mapDeps([6,1,2])).then(({getCurrentWindow:i})=>{i().onThemeChanged(({payload:o})=>{l0(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 n=setInterval(()=>{!document.hasFocus()||!t||t("get_app_theme").then(i=>{const o=i==="dark"?"dark":"light";Pm.current!==o&&(l0(o),e=!1)}).catch(i=>{e||(console.warn("[useTauriTheme] theme poll failed (further errors suppressed):",i),e=!0)})},3e3),r=()=>clearInterval(n);window.addEventListener("pagehide",r,{once:!0})}function KT(){try{if(typeof window>"u")return"light";if(Pt()){const t=Pm.current;if(t==="dark"||t==="light")return t;const e=window.__TANDEM_INITIAL_THEME__;if(e==="dark"||e==="light")return e}return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}catch(t){return console.warn("[Tandem] Theme detection failed, defaulting to light:",t),"light"}}function gQ(t){return t==="system"?KT():t}function _2(t){try{const e=document.querySelector('meta[name="theme-color"]');e&&(e.content=t==="dark"?"#1c1c24":t==="warm"?"#f1ead9":"#fafaf9")}catch{}}function vQ(t){const e=document.documentElement,n=gQ(t);if(e.setAttribute("data-theme",n),_2(n),t!=="system")return()=>e.removeAttribute("data-theme");if(Pt())return()=>e.removeAttribute("data-theme");const r=window.matchMedia("(prefers-color-scheme: dark)"),i=()=>{const o=KT();e.setAttribute("data-theme",o),_2(o)};return r.addEventListener("change",i),()=>{r.removeEventListener("change",i),e.removeAttribute("data-theme")}}function bQ(t){mQ(),he(()=>{const e=t();return Pm.current,vQ(e)})}function yQ(){try{return localStorage.getItem(oC)==="true"}catch{return!1}}function wQ(t){return t.author==="user"&&!t.id.startsWith(sC)}function C2(){try{localStorage.setItem(oC,"true")}catch{}}function xQ(t,e,n){let r=F(Qe(yQ())),i=F(0),o=0;const s=iS(),a=L(()=>n()==="welcome.md"),l=L(()=>!d(r)&&d(a)),c=Pt(),u=aS(()=>c&&d(l)),f=L(()=>!c||u.status!==null||u.error!==null),h=L(()=>c&&rS(u.status,s)),p=L(()=>d(f)?d(h)?4:3:1/0);return he(()=>{if(!d(l)||d(i)!==0)return;const b=t().filter(k=>k.id.startsWith(sC));if(b.length===0)return;b.some(k=>k.status!=="pending")&&(o=Date.now(),y(i,1))}),he(()=>{if(!d(l)||d(i)!==1)return;t().some(wQ)&&(o=Date.now(),y(i,2))}),he(()=>{if(!d(l)||d(i)!==2||!isFinite(d(p)))return;const g=e();if(!g)return;const b=()=>{Date.now()-o<2e3||g.isFocused&&(o=Date.now(),y(i,3))};return g.on("update",b),()=>{g.off("update",b)}}),he(()=>{if(!d(l)||!isFinite(d(p))||d(i)!==d(p))return;const g=setTimeout(()=>{C2(),y(r,!0)},3e3);return()=>clearTimeout(g)}),he(()=>{isFinite(d(p))&&d(i)>d(p)&&y(i,d(p),!0)}),{get tutorialActive(){return d(l)},get currentStep(){return d(i)},get coworkStatus(){return u.status},dismissTutorial:()=>{C2(),y(r,!0)},nextStep:()=>{o=Date.now(),y(i,Math.min(d(i)+1,d(p)),!0)}}}const kQ="tandem://update-available",_Q="tandem:updater-dismissed-v";function GT(t){return`${_Q}${t}`}function ZT(t){try{return window.localStorage.getItem(GT(t))==="1"}catch{return!1}}function CQ(t){try{window.localStorage.setItem(GT(t),"1")}catch{}}let YT=F(null),Tp=F(null),sl=0,c0=null,Af=!1,u0=0;function S2(){return sl}function sa(){return d(YT)}function JT(){return d(Tp)}function XT(t){t&&(CQ(t),y(Tp,t,!0))}function QT(){if(sl+=1,sl===1&&Pt()){Af=!1;const e=++u0;(async()=>{try{const{listen:n}=await yn(async()=>{const{listen:i}=await import("./event-CNdo2oXa.js");return{listen:i}},__vite__mapDeps([2,1]));if(Af||e!==u0||S2()===0)return;const r=await n(kQ,i=>{var s;const o=((s=i.payload)==null?void 0:s.version)??null;o&&(y(YT,o,!0),d(Tp)!==o&&y(Tp,null))});if(Af||e!==u0||S2()===0){r();return}c0=r}catch(n){console.warn("[useUpdaterChannel] listen() failed:",n)}})()}let t=!1;return()=>{if(!t&&(t=!0,sl=Math.max(0,sl-1),sl===0)){Af=!0;const e=c0;if(c0=null,e)try{e()}catch(n){console.warn("[useUpdaterChannel] unlisten threw:",n)}}}}function SQ(){return he(()=>QT()),{get availableVersion(){return sa()},get showDot(){const t=sa();return!(!t||JT()===t||ZT(t))},acknowledge(){XT(sa())}}}const E2=3e4;function EQ(){let t=F(!1),e=null;function n(){e!==null&&(clearTimeout(e),e=null)}he(()=>{const i=QT();return()=>{n(),i()}});async function r(){if(!(!sa()||d(t))){y(t,!0),n(),e=setTimeout(()=>{e=null,y(t,!1),console.warn(`[useUpdaterBanner] install_update did not tear down WebView within ${E2}ms; re-arming CTA`)},E2);try{const{invoke:o}=await yn(async()=>{const{invoke:s}=await import("./core-DhEqZVGG.js");return{invoke:s}},[]);await o("install_update"),n(),y(t,!1)}catch(o){console.warn("[useUpdaterBanner] install_update failed:",o),n(),y(t,!1)}}}return{get availableVersion(){return sa()},get installing(){return d(t)},get showBanner(){const i=sa();return!(!i||JT()===i||ZT(i))},dismiss(){XT(sa())},install:r}}function AQ(){let t=F(Qe(window.innerWidth));return he(()=>{let e=null;const n=()=>{e===null&&(e=requestAnimationFrame(()=>{y(t,window.innerWidth,!0),e=null}))};return window.addEventListener("resize",n),()=>{window.removeEventListener("resize",n),e!==null&&cancelAnimationFrame(e)}}),{get width(){return d(t)}}}function TQ(){let t=null;cc(()=>{let e=!1,n;yn(async()=>{const{getCurrentWebview:r}=await import("./webview-KiZyy_pC.js");return{getCurrentWebview:r}},__vite__mapDeps([5,6,1,2])).then(({getCurrentWebview:r})=>{if(e)return;const i=r();let o=Mc;try{const u=localStorage.getItem(rw);if(u!==null){const f=Number(u);Number.isFinite(f)?o=Math.max(iw,Math.min(ow,f)):console.warn(`[tandem] ignoring invalid stored zoom: ${u}`)}}catch{}o!==Mc&&i.setZoom(o).catch(u=>{console.warn("[tandem] failed to restore zoom level:",u)});function s(u){try{localStorage.setItem(rw,String(u))}catch{}}const a=u=>{!(u.metaKey||u.ctrlKey)||u.key!=="0"||(u.preventDefault(),u.stopPropagation(),o=Mc,i.setZoom(Mc).catch(h=>{console.warn("[tandem] failed to reset zoom:",h)}),s(Mc))},l=.1,c=u=>{if(!(u.metaKey||u.ctrlKey))return;const h=u.key==="+"||u.key==="=",p=u.key==="-"||u.key==="_";if(!h&&!p)return;const m=h?o+l:o-l;o=Math.max(iw,Math.min(ow,Math.round(m*100)/100)),s(o)};window.addEventListener("keydown",a,{capture:!0}),window.addEventListener("keydown",c,{capture:!0}),n=()=>{window.removeEventListener("keydown",a,{capture:!0}),window.removeEventListener("keydown",c,{capture:!0})}}).catch(()=>{}),t=()=>{e=!0,n==null||n()}}),gr(()=>{t==null||t()})}function MQ(t){const{prev:e,serverActiveId:n,serverIds:r,removedCount:i,serverEpoch:o,lastAppliedEpoch:s}=t;return e===null||!r.has(e)?n:i>0&&n===e?e:o!==s?n:e}function DQ(t,e,n){return t.filter(r=>!e.has(r.id)&&!n.has(r.id))}function OQ(){let t=F(Qe([])),e=F(null),n=F(!1),r=F("connecting"),i=F(0),o=F(null),s=F(Qe([])),a=F(null),l=F(!1),c=F(null),u=F(!1),f=F(!1),h=F(!1),p=F(!1),m=F(null),v=null,g=!1,b=null,_=null;const k=new Set,C=new Map,E=new Map,I=new Map;let A=!1;const M=te=>{const{ydoc:le}=te,se=le.getMap(Ti),me=()=>{const de=[];se.forEach(xe=>{de.push(Ra(xe,Ee=>{console.warn("[sanitize]",Ee)}))}),y(s,de,!0)};se.observe(me),me();const K=le.getMap($_);let H=null,O=!1,G=null;const z=de=>de?`${de.tool} ${de.annotationId??""} ${de.token??de.startedAt}`:null,Q=()=>{const de=K.get(B0),xe=(de==null?void 0:de.status)??null,Ee=(de==null?void 0:de.active)??!1,D=(de==null?void 0:de.working)??null;xe!==H&&(H=xe,y(a,xe,!0)),Ee!==O&&(O=Ee,y(l,Ee,!0));const $=z(D);$!==G&&(G=$,y(c,D,!0))};K.observe(Q),Q();const ge=le.getMap(zf);let ye=!1;const Se=de=>{if(!de.keysChanged.has(Km))return;const xe=ge.get(Km)===!0;xe!==ye&&(ye=xe,y(u,xe))};ge.observe(Se);const ee=ge.get(Km)===!0;return ee!==ye&&(ye=ee,y(u,ee)),()=>{se.unobserve(me),K.unobserve(Q),ge.unobserve(Se)}},N=(te,le,se)=>{var ye,Se;const me=d(t),K=new Set(me.map(ee=>ee.id)),H=new Set(te.map(ee=>ee.id));for(const ee of me)k.delete(ee.id),C.delete(ee.id);for(const[ee,de]of C)H.has(ee)||((ye=I.get(ee))==null||ye(),I.delete(ee),de.provider.destroy(),de.ydoc.destroy(),C.delete(ee),k.delete(ee));const O=DQ(te,K,k),G=[];for(const ee of O){k.add(ee.id);const de=new oo,xe=new yx({url:`ws://127.0.0.1:${Jy}`,name:ee.id,document:de});C.set(ee.id,{ydoc:de,provider:xe});const Ee=de.getMap(zf),D=$=>{if(!$.keysChanged.has(Ec)&&!$.keysChanged.has(Ac)&&!$.keysChanged.has(Tc))return;const ke=Ee.get(Ec),we=Ee.get(Ac),Ae=Ee.get(Tc);ke&&N(ke,we??null,Ae??null)};Ee.observe(D),I.set(ee.id,()=>Ee.unobserve(D)),G.push({...ee,ydoc:de,provider:xe})}const z=me.filter(ee=>!H.has(ee.id));for(const ee of z){const de=E.get(ee.id);de&&(de.cleanup(),E.delete(ee.id)),(Se=I.get(ee.id))==null||Se(),I.delete(ee.id),k.delete(ee.id),C.delete(ee.id),ee.provider.destroy(),ee.ydoc.destroy()}const Q=new Map(te.map(ee=>[ee.id,ee])),ge=me.filter(ee=>H.has(ee.id)).map(ee=>{const de=Q.get(ee.id);return!de||de.fileName===ee.fileName&&de.filePath===ee.filePath&&de.format===ee.format&&de.readOnly===ee.readOnly?ee:{...ee,fileName:de.fileName,filePath:de.filePath,format:de.format,readOnly:de.readOnly}});y(t,[...ge,...G],!0),le!==null&&(y(e,MQ({prev:d(e),serverActiveId:le,serverIds:H,removedCount:z.length,serverEpoch:se,lastAppliedEpoch:_}),!0),_=se)};let R=null,B=null;{const te=new oo,le=new yx({url:`ws://127.0.0.1:${Jy}`,name:gD,document:te});y(m,te,!0),B=le,le.on("status",({status:z})=>{y(n,z==="connected"),y(r,["connected","connecting","disconnected"].includes(z)?z:"connecting",!0),z==="connected"?(g=!0,y(i,0),y(o,null)):z==="disconnected"?d(o)===null&&y(o,Date.now(),!0):z==="connecting"&&(g&&y(i,d(i)+1),d(o)===null&&y(o,Date.now(),!0))});const se=te.getMap(zf),me=z=>{if(z.keysChanged.has(Wm)){const Q=se.get(Wm);Q&&b&&Q!==b&&(console.warn("[Tandem] Server restarted — refreshing documents"),y(p,!0),_=null,v&&clearTimeout(v),v=setTimeout(()=>{y(p,!1)},5e3)),Q&&(b=Q)}if(z.keysChanged.has(Ec)||z.keysChanged.has(Ac)||z.keysChanged.has(Tc)){const Q=se.get(Ec),ge=se.get(Ac),ye=se.get(Tc);Q&&N(Q,ge??null,ye??null)}z.keysChanged.has(Gm)&&y(f,se.get(Gm)===!0)};se.observe(me);const K=se.get(Wm);K&&(b=K);const H=se.get(Ec),O=se.get(Ac),G=se.get(Tc);H&&N(H,O??null,G??null),y(f,se.get(Gm)===!0),R=()=>{se.unobserve(me),v&&(clearTimeout(v),v=null),le.destroy(),te.destroy(),y(m,null),B=null},y(h,!0)}const Z=L(()=>d(t).find(te=>te.id===d(e))??null),q=L(()=>{var te;return((te=d(Z))==null?void 0:te.ydoc)??null}),Y=x_(()=>{he(()=>{d(q);const te=d(Z);for(const le of E.values())le.cleanup();if(E.clear(),te){const le=M(te);E.set(te.id,{cleanup:le})}else y(s,[],!0),y(a,null),y(l,!1),y(c,null),y(u,!1)})});return{get tabs(){return d(t)},get activeTabId(){return d(e)},setActiveTabId:te=>{y(e,te,!0)},handleTabClose:te=>{if(d(e)===te){const le=d(t),se=le.findIndex(K=>K.id===te),me=le.filter(K=>K.id!==te);me.length===0?y(e,null):y(e,me[Math.min(se,me.length-1)].id,!0)}fetch(`http://127.0.0.1:${uc}${JM}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({documentId:te})}).then(le=>{le.ok||console.warn("[Tandem] Server rejected close:",le.status)}).catch(le=>{console.warn("[Tandem] Failed to close document on server:",le)})},get connected(){return d(n)},get connectionStatus(){return d(r)},get reconnectAttempts(){return d(i)},get disconnectedSince(){return d(o)},get annotations(){return d(s)},get claudeStatus(){return d(a)},get claudeActive(){return d(l)},get claudeWorking(){return d(c)},get readOnly(){return d(u)},get storeReadOnly(){return d(f)},get bootstrapYdoc(){return d(m)},get ready(){return d(h)},get serverRestarted(){return d(p)},destroy:()=>{if(!A){A=!0,Y();for(const te of E.values())te.cleanup();E.clear();for(const te of I.values())te();I.clear();for(const te of C.values())te.provider.destroy(),te.ydoc.destroy();C.clear(),k.clear();for(const te of d(t))te.provider.destroy(),te.ydoc.destroy();R==null||R(),y(t,[],!0),y(s,[],!0),y(e,null),y(h,!1)}},reconnect(){B==null||B.connect();for(const te of d(t))te.provider.connect()}}}const sc={full:{column:240,inset:8,gap:24},narrow:{column:160,inset:8,gap:24},stub:{column:28,inset:8,gap:24},off:{column:0,inset:0,gap:0}};function sd(t){return t.column+t.inset+t.gap}sc.full.column;const IQ=sd(sc.full),$T=480,RQ=32;function NQ(t){return 2*IQ+t+$T}function PQ(t){const e=t+$T;return{t1:NQ(t),t2:2*sd(sc.narrow)+e,t3:2*sd(sc.stub)+e}}const Tf={off:0,stub:1,narrow:2,full:3};function LQ(t,e,n,r){const{t1:i,t2:o,t3:s}=n,a=e,l=r,c=a<s?"off":a<o?"stub":a<i?"narrow":"full",u=a>i+l?"full":a>o+l?"narrow":a>s+l?"stub":"off";return Tf[t]>Tf[c]?c:Tf[t]<Tf[u]?u:t}function FQ(t,e,n){return t?e&&n==="full"?"full":"off":e?n:"off"}function A2(t,e,n){return!e&&!n?"off":t}function zQ(t){return t.isDocx?t.effectivelyOn?"position: relative;":"display: contents;":`--editor-measure: ${t.measure}; --margin-left-track: ${t.leftReservePx}px; --margin-right-track: ${t.rightReservePx}px; display: grid; align-items: stretch; grid-template-columns: minmax(0, 1fr) var(--margin-left-track) minmax(0, var(--editor-measure)) var(--margin-right-track) minmax(0, 1fr);`}function BQ(t){const e=L(()=>(t.getLeftRailVisible()?t.leftRailWidthPx:0)+(t.getRightRailVisible()?t.rightRailWidthPx:0)),n=L(()=>PQ(d(e)));let r=F("full");he(()=>{const v=t.getViewportWidth(),g=d(n),b=At(()=>d(r)),_=LQ(b,v,g,RQ);_!==b&&y(r,_,!0)});const i=L(()=>t.getFormat()==="docx"),o=L(()=>FQ(d(i),t.getMarginView(),d(r))),s=L(()=>A2(d(o),d(i),t.getLeftHasPending())),a=L(()=>A2(d(o),d(i),t.getRightHasPending())),l=L(()=>d(s)!=="off"),c=L(()=>d(a)!=="off"),u=L(()=>d(l)||d(c)),f=L(()=>sc[d(s)]),h=L(()=>sc[d(a)]),p=new Set,m=L(()=>zQ({isDocx:d(i),effectivelyOn:d(u),leftReservePx:sd(d(f)),rightReservePx:sd(d(h)),measure:(()=>{const v=t.getEditorMeasure(),g=Tw[v];return g===void 0&&!p.has(v)&&(p.add(v),console.warn(`[tandem] editorMeasure=${JSON.stringify(v)} not in EDITOR_MEASURE_CH; falling back to comfortable. Both useTandemSettings validators should have coerced this upstream — a TS-violating cast slipped past them.`)),g??Tw.comfortable})()}));return{get effectivelyOn(){return d(u)},get leftVisible(){return d(l)},get rightVisible(){return d(c)},get leftMode(){return d(s)},get rightMode(){return d(a)},get leftGeometry(){return d(f)},get rightGeometry(){return d(h)},get layerStyle(){return d(m)}}}function HQ(t,e){const n=L(()=>t.settings.leftPanelVisible),r=L(()=>t.settings.rightPanelVisible&&!(e.tandemMode==="solo"&&t.settings.soloRailHidden));function i(){t.updateSettings({leftPanelVisible:!t.settings.leftPanelVisible})}function o(){if(d(r)){t.updateSettings({rightPanelVisible:!1});return}t.updateSettings({rightPanelVisible:!0,...e.tandemMode==="solo"?{soloRailHidden:!1}:{}})}return{get leftVisible(){return d(n)},get rightVisible(){return d(r)},toggleLeft:i,toggleRight:o}}function VQ(t){return t.mode==="stub"?"stub":t.isActive?"full":t.mode==="narrow"?"clamped":"full"}const UQ=6;function jQ(t,e={}){const n=e.gap??UQ,r=new Map;if(t.length===0)return r;const i=t.map((s,a)=>({...s,idx:a})).sort((s,a)=>s.top-a.top||s.idx-a.idx);let o=Number.NEGATIVE_INFINITY;for(const s of i){if(!Number.isFinite(s.top))continue;const a=Math.max(s.top,o);r.set(s.id,a),typeof s.height=="number"&&Number.isFinite(s.height)&&s.height>0&&(o=a+s.height+n)}return r}function qQ(t,e){const n=[];for(const r of t.keys())e.has(r)||n.push(r);for(const r of n)t.delete(r);return n.length}const T2=.62;function WQ(t){const e=t.endX-t.startX,n=t.startX+e*T2,r=t.endX-e*T2;return`M ${t.startX.toFixed(1)},${t.startY.toFixed(1)} C ${n.toFixed(1)},${t.startY.toFixed(1)} ${r.toFixed(1)},${t.endY.toFixed(1)} ${t.endX.toFixed(1)},${t.endY.toFixed(1)}`}function KQ(t){throw new Error(`unhandled annotation author: ${String(t)}`)}function GQ(t){switch(t){case"claude":return"var(--tandem-author-claude)";case"user":return"var(--tandem-author-user)";case"import":return"var(--tandem-fg-subtle)";default:return KQ(t)}}var ZQ=Dr('<path stroke-linecap="round" fill="none"></path><circle data-testid="margin-anchor-dot"></circle>',1),YQ=T('<div class="margin-bubble svelte-lzz9jv"><!></div>'),JQ=T('<svg aria-hidden="true"></svg> <div></div>',1);function XQ(t,e){We(e,!0);const n=12,r=L(()=>e.side==="right"?0:e.gap),i=L(()=>e.side==="right"?e.gap:0),o=L(()=>`position: absolute; top: 0; bottom: 0; ${e.side}: ${e.edgeInset+e.width}px; width: ${e.gap}px; pointer-events: none;`),s=L(()=>e.annotations.filter(C=>e.positions.has(C.id)&&C.status==="pending"));let a=F(Qe(new Map));const l=L(()=>new Map(d(s).map(C=>[C.id,VQ({mode:e.mode,isActive:C.id===e.activeAnnotationId})]))),c=L(()=>{const C=d(s).map(E=>({id:E.id,top:e.positions.get(E.id)??0,height:d(l).get(E.id)==="stub"?void 0:d(a).get(E.id)}));return jQ(C)});he(()=>{const C=new Set(d(s).map(E=>E.id));At(()=>{qQ(d(a),C)>0&&y(a,new Map(d(a)),!0)})});function u(C,E){if(!Number.isFinite(E)||E<=0)return;const I=d(a).get(C);if(I!==void 0&&Math.abs(I-E)<.5)return;const A=new Map(d(a));A.set(C,E),y(a,A,!0)}let f=F(void 0),h=F(null),p=0;function m(C){return e.annotations.find(E=>E.id===C)}function v(C){return E=>{const I=m(C);I&&tE(E,I,{accept:e.onAccept,dismiss:e.onDismiss,sendToClaude:e.onSendToClaude,remove:e.onRemove,openEdit:A=>y(h,{id:A,kind:"edit",nonce:++p},!0),openReply:A=>y(h,{id:A,kind:"reply",nonce:++p},!0)})}}async function g(C){var M;if(!Pt())return;const E=(M=C.target)==null?void 0:M.closest("[data-annotation-id]"),I=E==null?void 0:E.getAttribute("data-annotation-id");if(!I)return;const A=m(I);A&&(C.preventDefault(),C.stopPropagation(),await nE(A,v(I)))}he(()=>{const C=d(f);if(C)return C.addEventListener("contextmenu",g),()=>C.removeEventListener("contextmenu",g)}),he(()=>rE());var b=JQ(),_=Ie(b);nt(_,21,()=>d(s),C=>C.id,(C,E)=>{const I=L(()=>e.positions.get(d(E).id)),A=L(()=>d(c).get(d(E).id));var M=Mt(),N=Ie(M);{var R=B=>{const Z=L(()=>d(E).id===e.activeAnnotationId),q=L(()=>d(A)??d(I)),Y=L(()=>d(q)+n),X=L(()=>GQ(d(E).author)),ae=L(()=>WQ({startX:d(r),startY:d(I),endX:d(i),endY:d(Y)}));var ne=ZQ(),te=Ie(ne),le=x(te);j(()=>{V(te,"data-annotation-id",d(E).id),V(te,"data-tandem-author",d(E).author),V(te,"d",d(ae)),V(te,"stroke",d(X)),V(te,"stroke-width",d(Z)?1.8:1.1),V(te,"stroke-opacity",d(Z)?.82:.38),V(le,"data-annotation-id",d(E).id),V(le,"data-tandem-author",d(E).author),V(le,"cx",d(r)),V(le,"cy",d(I)),V(le,"r",d(Z)?3:2),V(le,"fill",d(X)),V(le,"fill-opacity",d(Z)?.72:.42)}),S(B,ne)};W(N,B=>{d(I)!==void 0&&B(R)})}S(C,M)});var k=x(_,2);nt(k,21,()=>d(s),C=>C.id,(C,E)=>{const I=L(()=>d(c).get(d(E).id)??e.positions.get(d(E).id)??0),A=L(()=>lm(d(E),e.repliesById.get(d(E).id))),M=L(()=>d(l).get(d(E).id)??"full");var N=YQ(),R=w(N);{let B=L(()=>d(E).id===e.activeAnnotationId),Z=L(()=>cm(d(E))?e.onAccept:void 0),q=L(()=>um(d(E))?e.onDismiss:void 0),Y=L(()=>pm(d(E))?e.onRemove:void 0),X=L(()=>hm(d(E))?e.onSendToClaude:void 0),ae=L(()=>fm(d(E))?e.onEdit:void 0),ne=L(()=>dm(d(E))?e.onReply:void 0),te=L(()=>{var le;return((le=d(h))==null?void 0:le.id)===d(E).id?d(h):null});gv(R,{get annotation(){return d(E)},get replies(){return d(A)},get isReviewTarget(){return d(B)},get density(){return d(M)},onClick:()=>e.onClick(d(E)),get onAccept(){return d(Z)},get onDismiss(){return d(q)},get onRemove(){return d(Y)},get onSendToClaude(){return d(X)},get onEdit(){return d(ae)},get onReply(){return d(ne)},get openRequest(){return d(te)}})}j(()=>{V(N,"data-testid",`margin-bubble-${d(E).id??""}`),V(N,"data-margin-bubble-reply-count",d(A).length),Me(N,`position: absolute; top: ${d(I)??""}px; ${e.side??""}: 0; width: ${e.width??""}px; pointer-events: auto;`)}),cM(N,"clientHeight",B=>u(d(E).id,B)),S(C,N)}),St(k,C=>y(f,C),()=>d(f)),j(()=>{V(_,"data-testid",`margin-leaders-${e.side??""}`),Me(_,d(o)),V(k,"data-testid",`margin-column-${e.side??""}`),V(k,"aria-label",e.side==="left"?"Note bubbles":"Comment bubbles"),Me(k,`position: absolute; top: 0; ${e.side??""}: ${e.edgeInset??""}px; width: ${e.width??""}px; pointer-events: none;`)}),S(t,b),Ke()}function M2(t){return t.type==="note"}function D2(t){return t.author==="import"||t.type==="comment"}var QQ=T('<span class="peek-tick h1 svelte-1mwvi22"></span> <span class="peek-tick h2 svelte-1mwvi22"></span> <span class="peek-tick h2 svelte-1mwvi22"></span> <span class="peek-tick h3 svelte-1mwvi22"></span> <span class="peek-tick h2 svelte-1mwvi22"></span>',1),$Q=T("<span></span>"),e$=T('<button type="button" tabindex="-1"><span class="peek-chevron svelte-1mwvi22" aria-hidden="true"> </span> <div class="peek-content svelte-1mwvi22" aria-hidden="true"><!></div> <span class="peek-label svelte-1mwvi22" aria-hidden="true"> </span></button>');function O2(t,e){We(e,!0);const n=Ue(e,"annotations",19,()=>[]),r=L(()=>e.side==="left"?"Outline":"Annotations");function i(v){return v.type==="highlight"?"hl":v.type==="comment"&&v.suggestedText!=null?"suggest":v.author==="claude"?"claude":v.author==="import"?"import":"user"}function o(v){(v.key==="Enter"||v.key===" ")&&(v.preventDefault(),e.onActivate())}var s=e$(),a=w(s),l=w(a),c=x(a,2),u=w(c);{var f=v=>{var g=QQ();S(v,g)},h=v=>{var g=Mt(),b=Ie(g);nt(b,17,n,_=>_.id,(_,k)=>{var C=$Q();j(E=>yt(C,1,`peek-dot ${E??""}`,"svelte-1mwvi22"),[()=>i(d(k))]),S(_,C)}),S(v,g)};W(u,v=>{e.kind==="outline"?v(f):v(h,-1)})}var p=x(c,2),m=w(p);j(()=>{yt(s,1,`peek-strip peek-strip-${e.side??""}`,"svelte-1mwvi22"),V(s,"data-testid",`peek-strip-${e.side}`),V(s,"aria-label",e.side==="left"?"Show left panel":"Show right panel"),V(s,"aria-expanded",!e.collapsed),Me(s,e.collapsed?"":"display: none;"),J(l,e.side==="left"?"›":"‹"),J(m,d(r))}),P("click",s,function(...v){var g;(g=e.onActivate)==null||g.apply(this,v)}),P("keydown",s,o),S(t,s),Ke()}et(["click","keydown"]);const I2=t=>{console.warn("[sanitize]",t)};function t$(t,e,n){if(t.suggestedText===void 0)return!1;const r=t.suggestedText,i=$l(t,e.state.doc,n);if(!i)return console.warn("[SidePanel] Could not resolve range for suggestion",t.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",t.id,o),!1}return!0}function n$({getYdoc:t,getEditor:e,getAnnotations:n,onActiveAnnotationChange:r,getScrollBehavior:i,getActiveAnnotationId:o}){let s=F(0),a=F(Qe(new Set));const l=new Map;gr(()=>{for(const b of l.values())clearTimeout(b);l.clear()});function c(){return n().filter(hh)}function u(b,_){const k=t();if(!k)return;const C=k.getMap(Ti),E=C.get(b);if(!E||E.status!=="pending")return;const I=Ra(E,I2);if(C.set(b,{...I,status:_}),_==="accepted"&&I.suggestedText!==void 0){const A=e();if(A&&!t$(I,A,k)){C.set(b,{...I,status:"pending"});return}}y(a,new Set(d(a)).add(b),!0)}function f(b){const _=l.get(b);_&&clearTimeout(_),l.set(b,setTimeout(()=>{l.delete(b);const k=new Set(d(a));k.delete(b),y(a,k,!0)},3e3))}function h(b){const _=l.get(b);_&&(clearTimeout(_),l.delete(b));const k=new Set(d(a));k.delete(b),y(a,k,!0)}function p(b){const _=t();if(!_)return!1;const k=_.getMap(Ti),C=k.get(b);if(!C||C.status==="pending")return h(b),!1;const E=Ra(C,I2),I=e();if(E.status==="accepted"&&E.suggestedText!==void 0&&I)try{const A=E.suggestedText,M=E.textSnapshot;if(typeof A=="string"&&typeof M=="string"){const N=$l(E,I.state.doc,_);if(!N)return console.warn(`[undo] Cannot resolve range for annotation ${b}, skipping`),f(b),!1;if(I.state.doc.textBetween(N.from,N.to)!==A)return console.warn(`[undo] Text changed since accept for annotation ${b}, skipping`),f(b),!1;I.chain().focus().deleteRange({from:N.from,to:N.to}).insertContentAt(N.from,M).run()}}catch(A){return console.warn(`[undo] Failed to revert text for annotation ${b}:`,A),f(b),!1}return k.set(b,{...E,status:"pending"}),h(b),!0}function m(b){u(b,"accepted")}function v(b){u(b,"dismissed")}function g(b){const _=e();if(!_)return;const k=$l(b,_.state.doc,t());if(!k)return;_.chain().focus().setTextSelection({from:k.from,to:k.to}).run();const C=_.view.domAtPos(k.from),E=C.node instanceof HTMLElement?C.node:C.node.parentElement;E==null||E.scrollIntoView({behavior:i(),block:"center"})}return he(()=>{var k;const b=(o==null?void 0:o())??null;if(b===null)return;if(!n().some(C=>C.id===b&&C.status==="pending")){const C=c();r(((k=C[d(s)])==null?void 0:k.id)??null)}}),he(()=>{const b=c();d(s)>=b.length&&y(s,Math.max(0,b.length-1),!0)}),{resolveAnnotation:u,undoResolveAnnotation:p,handleAccept:m,handleDismiss:v,scrollToAnnotation:g,getRecentlyResolved:()=>d(a),getReviewIndex:()=>d(s),getReviewTargets:c}}var r$=T('<button type="button"><span class="highlight-picker-swatch-inner svelte-1d240y8"></span> <svg class="highlight-picker-swatch-check svelte-1d240y8" width="10" height="10" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 11l3 3 7-9"></path></svg></button>'),i$=T('<div class="highlight-picker-popover svelte-1d240y8"><!> <button type="button" data-testid="color-picker-close" title="Close" aria-label="Close color picker" class="highlight-picker-close svelte-1d240y8">✕</button></div>'),o$=T('<div class="highlight-picker-wrap svelte-1d240y8"><!> <button type="button" class="highlight-swatch-toggle svelte-1d240y8" data-testid="toolbar-highlight-color-toggle" title="Choose highlight color"><span class="highlight-swatch-preview svelte-1d240y8"></span></button> <!></div>');function s$(t,e){We(e,!0);const n=[{value:"yellow",label:"Yellow"},{value:"green",label:"Green"},{value:"blue",label:"Blue"},{value:"pink",label:"Pink"}],r=Ue(e,"disabled",3,!1);let i=F("yellow"),o=F(!1),s=F(null);he(()=>{if(d(o))return ry(()=>d(s),["mousedown"],()=>{y(o,!1)},{capture:!1})});function a(g){g.preventDefault(),e.onHighlight(d(i))}function l(g){g.preventDefault(),y(o,!d(o))}function c(g){y(i,g,!0),y(o,!1)}var u=o$(),f=w(u);wr(f,{label:"Highlight",testId:"toolbar-highlight-btn",get disabled(){return r()},disabledTitle:"Select text first",onMouseDown:a});var h=x(f,2),p=w(h),m=x(h,2);{var v=g=>{var b=i$(),_=w(b);nt(_,17,()=>n,({value:C,label:E})=>C,(C,E)=>{let I=()=>d(E).value,A=()=>d(E).label;var M=r$();let N;var R=w(M);j(()=>{V(M,"data-testid",`toolbar-highlight-color-${I()}`),V(M,"title",A()),V(M,"aria-label",A()),N=yt(M,1,"highlight-picker-swatch svelte-1d240y8",null,N,{"is-selected":I()===d(i)}),Me(R,`background: ${_u[I()]??""};`)}),P("click",M,()=>c(I())),S(C,M)});var k=x(_,2);St(b,C=>y(s,C),()=>d(s)),P("click",k,()=>y(o,!1)),S(g,b)};W(m,g=>{d(o)&&g(v)})}j(()=>{h.disabled=r(),Me(p,`background: ${_u[d(i)]??""};`)}),P("mousedown",h,l),S(t,u),Ke()}et(["mousedown","click"]);var a$=T('<div class="fmtbar-divider svelte-1lcxsnm"></div> <!>',1),l$=T('<div class="fmtbar-divider svelte-1lcxsnm"></div> <button type="button" class="fmtbar-hide svelte-1lcxsnm" data-testid="formatbar-hide-btn" title="Hide formatting bar" aria-label="Hide formatting bar"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" class="svelte-1lcxsnm"><path d="m18 15-6-6-6 6"></path></svg></button>',1),c$=T('<div class="tandem-fmtbar-wrap" style="position: fixed; top: var(--tandem-fmtbar-top, 52px); left: 0; right: 0; display: flex; justify-content: center; pointer-events: none; z-index: var(--tandem-z-sticky);"><div data-testid="formatting-bar" class="tandem-floating-pill" style="display: inline-flex; align-items: center; padding: var(--tandem-space-1); user-select: none; pointer-events: auto; -webkit-app-region: no-drag; max-width: calc(100% - var(--tandem-space-6));"><div style="display: flex; align-items: center; gap: 1px; overflow: hidden; min-width: 0;"><!> <div class="fmtbar-divider svelte-1lcxsnm"></div> <!></div> <!> <!></div></div>');function u$(t,e){We(e,!0);const n=Ue(e,"showAuthorship",3,!0),r=Ue(e,"showComments",3,!0),i=Ue(e,"showHighlights",3,!0),o=Ue(e,"showNotes",3,!0),s=Ue(e,"decorationsMuted",3,!1);let a=F(0);he(()=>{const k=e.editor;if(!k||k.isDestroyed)return;const C=()=>{k.isDestroyed||vu(a)};return k.on("selectionUpdate",C),k.on("transaction",C),()=>{k.off("selectionUpdate",C),k.off("transaction",C)}});const l=L(()=>(d(a),!e.editor||e.editor.isDestroyed||!e.ydoc?!1:!e.editor.state.selection.empty));function c(k){if(!e.editor||!e.ydoc||e.editor.isDestroyed)return;const{state:C}=e.editor,{from:E,to:I}=C.selection;if(E===I)return;const A=ii(C.doc,Mn(E)),M=ii(C.doc,Mn(I));if(A===null||M===null){console.warn("[FormattingBar] pmPosToFlatOffset returned null — CRDT position may be degraded",{from:E,to:I});return}UT(e.ydoc,{from:A,to:M},k)}var u=c$(),f=w(u),h=w(f),p=w(h);VT(p,{get editor(){return e.editor}});var m=x(p,4);{let k=L(()=>!d(l));s$(m,{get disabled(){return d(k)},onHighlight:c})}var v=x(h,2);{var g=k=>{var C=a$(),E=x(Ie(C),2);HT(E,{get showAuthorship(){return n()},get showComments(){return r()},get showHighlights(){return i()},get showNotes(){return o()},get decorationsMuted(){return s()},get onUpdate(){return e.onUpdateDecorations},get onOpenSettings(){return e.onOpenSettings}}),S(k,C)};W(v,k=>{e.onUpdateDecorations&&k(g)})}var b=x(v,2);{var _=k=>{var C=l$(),E=x(Ie(C),2);P("click",E,function(...I){var A;(A=e.onHide)==null||A.apply(this,I)}),S(k,C)};W(b,k=>{e.onHide&&k(_)})}S(t,u),Ke()}et(["click"]);var d$=T('<div data-testid="mode-toggle" data-tauri-drag-region="false" class="mode-toggle svelte-14q5edy" role="group" aria-label="AI collaboration mode"><span aria-hidden="true"></span> <button data-testid="mode-solo-btn" title="Write undisturbed — your AI only responds when you message">Solo</button> <button data-testid="mode-tandem-btn" title="Full collaboration — your AI reacts to selections and document changes">Tandem</button></div>');function f$(t,e){We(e,!0);var n=d$(),r=w(n);let i;var o=x(r,2),s=x(o,2);j(()=>{i=yt(r,1,"thumb svelte-14q5edy",null,i,{tandem:e.tandemMode==="tandem"}),yt(o,1,D0(e.tandemMode==="solo"?"on":""),"svelte-14q5edy"),V(o,"aria-pressed",e.tandemMode==="solo"),yt(s,1,D0(e.tandemMode==="tandem"?"on":""),"svelte-14q5edy"),V(s,"aria-pressed",e.tandemMode==="tandem")}),P("click",o,()=>e.onModeChange("solo")),P("click",s,()=>e.onModeChange("tandem")),S(t,n),Ke()}et(["click"]);const h$=[{value:"system",label:"Match system"},{value:"light",label:"Light"},{value:"dark",label:"Dark"},{value:"warm",label:"Warm"}];var p$=T('<span class="titlebar-settings-dot svelte-12l7ydf" data-testid="titlebar-update-available-dot" aria-hidden="true"></span>'),m$=T('<button type="button" role="menuitemradio"><span class="brand-theme-dot svelte-12l7ydf" aria-hidden="true"></span> <span class="brand-theme-label svelte-12l7ydf"> </span></button>'),g$=T('<div class="brand-menu-divider svelte-12l7ydf" role="separator"></div>'),v$=T('<div class="brand-menu-heading svelte-12l7ydf">Color scheme</div> <div class="brand-theme-grid svelte-12l7ydf" role="group" aria-label="Color scheme"></div> <!>',1),b$=T('<button type="button" class="brand-menu-item svelte-12l7ydf" data-testid="brand-menu-settings" role="menuitem"><span>Settings…</span> <kbd class="brand-menu-kbd svelte-12l7ydf">Ctrl+,</kbd></button>'),y$=T('<button type="button" class="brand-menu-item svelte-12l7ydf" data-testid="brand-menu-shortcuts" role="menuitem"><span>Keyboard Shortcuts</span> <kbd class="brand-menu-kbd svelte-12l7ydf">?</kbd></button>'),w$=T('<div class="brand-menu tandem-floating-pill svelte-12l7ydf" data-testid="titlebar-brand-menu-popover" data-tauri-drag-region="false" role="menu" tabindex="-1" aria-label="Tandem menu"><!> <!> <!></div>'),x$=T('<div class="title-bar-center svelte-12l7ydf" data-tauri-drag-region="false"><!></div>'),k$=T('<span class="status-dot svelte-12l7ydf" data-tauri-drag-region="false" title="AI assistant is connected" aria-label="AI assistant is connected"></span>'),_$=T('<button type="button" class="model-chip svelte-12l7ydf" data-testid="titlebar-default-model"><span class="model-chip-dot svelte-12l7ydf" aria-hidden="true"></span> <span class="model-chip-label svelte-12l7ydf"> </span></button>'),C$=Dr('<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>'),S$=Dr('<svg width="10" height="10" viewBox="0 0 10 10" aria-hidden="true" focusable="false"><path d="M0 0H10V10H0V0ZM1 2V9H9V2H1Z" fill="currentColor"></path></svg>'),E$=T('<div class="title-bar-spacer-sm svelte-12l7ydf" data-tauri-drag-region=""></div> <div class="title-bar-controls svelte-12l7ydf" data-tauri-drag-region="false"><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>',1),A$=T('<div class="title-bar svelte-12l7ydf" data-testid="title-bar" data-tauri-drag-region=""><div class="title-bar-left svelte-12l7ydf"><button type="button" class="brand-btn svelte-12l7ydf" data-testid="titlebar-brand-menu" data-tauri-drag-region="false" aria-label="Tandem menu" aria-haspopup="menu"><img class="brand-mark svelte-12l7ydf" src="/logo.png" alt="" width="32" height="32"/> <!></button> <!></div> <div class="title-bar-spacer title-bar-spacer-fixed svelte-12l7ydf" data-tauri-drag-region=""></div> <!> <div class="title-bar-spacer svelte-12l7ydf" data-tauri-drag-region=""></div> <div class="title-bar-actions svelte-12l7ydf"><!> <!> <!></div> <!></div>');function T$(t,e){We(e,!0);let n=Ue(e,"claudeActive",3,!1),r=Ue(e,"theme",3,"system"),i=Ue(e,"settingsBtn",15,null),o=Ue(e,"updateAvailable",3,!1),s=Ue(e,"defaultModelLabel",3,null),a=F(null),l=F(!1),c=[],u=!0;cc(async()=>{if(Pt())try{const[{invoke:z},{getCurrentWindow:Q}]=await Promise.all([yn(()=>import("./core-DhEqZVGG.js"),[]),yn(()=>import("./window-DePn7tLG.js").then(ee=>ee.w),__vite__mapDeps([6,1,2]))]);if(!u||(await z("setup_overlay_titlebar").catch(ee=>{console.error("[TitleBar] setup_overlay_titlebar failed:",ee)}),!u))return;const ge=Q();if(y(a,ge,!0),y(l,await ge.isMaximized(),!0),!u)return;const ye=await ge.onResized(async()=>{try{y(l,await ge.isMaximized(),!0)}catch(ee){console.warn("[TitleBar] isMaximized check failed on resize:",ee)}});if(!u){ye();return}c.push(ye);const Se=await ge.onMoved(async()=>{try{y(l,await ge.isMaximized(),!0)}catch(ee){console.warn("[TitleBar] isMaximized check failed on move:",ee)}});if(!u){Se();return}c.push(Se)}catch(z){console.error("[TitleBar] Window API initialization failed:",z)}}),gr(()=>{u=!1,c.forEach(z=>z())});async function f(){var z;try{await((z=d(a))==null?void 0:z.minimize())}catch(Q){console.error("[TitleBar] minimize failed:",Q)}}async function h(){var z;try{await((z=d(a))==null?void 0:z.toggleMaximize())}catch(Q){console.error("[TitleBar] toggleMaximize failed:",Q)}}async function p(){var z;try{await((z=d(a))==null?void 0:z.close())}catch(Q){console.error("[TitleBar] close failed:",Q)}}let m=F(!1),v=F(null);he(()=>{if(d(m))return ry(()=>d(v)??i(),["mousedown"],()=>{y(m,!1)})});function g(){y(m,!d(m))}function b(){var z;y(m,!1),(z=i())==null||z.focus()}function _(z){z.key==="Escape"&&(z.stopPropagation(),b())}function k(z){var Q;(Q=e.onSetTheme)==null||Q.call(e,z),b()}function C(){var z;(z=e.onOpenSettings)==null||z.call(e),y(m,!1)}function E(){var z;(z=e.onOpenHelp)==null||z.call(e),y(m,!1)}var I=A$(),A=w(I),M=w(A),N=x(w(M),2);{var R=z=>{var Q=p$();S(z,Q)},B=L(()=>Pt()&&o());W(N,z=>{d(B)&&z(R)})}St(M,z=>i(z),()=>i());var Z=x(M,2);{var q=z=>{var Q=w$(),ge=w(Q);{var ye=Ee=>{var D=v$(),$=x(Ie(D),2);nt($,21,()=>h$,Ae=>Ae.value,(Ae,pe)=>{var oe=m$();let De;var ze=x(w(oe),2),Ge=w(ze);j(()=>{De=yt(oe,1,"brand-theme-sw svelte-12l7ydf",null,De,{on:r()===d(pe).value}),V(oe,"data-testid",`brand-menu-theme-${d(pe).value??""}`),V(oe,"data-theme-swatch",d(pe).value),V(oe,"aria-checked",r()===d(pe).value),J(Ge,d(pe).label)}),P("click",oe,()=>k(d(pe).value)),S(Ae,oe)});var ke=x($,2);{var we=Ae=>{var pe=g$();S(Ae,pe)};W(ke,Ae=>{(e.onOpenSettings||e.onOpenHelp)&&Ae(we)})}S(Ee,D)};W(ge,Ee=>{e.onSetTheme&&Ee(ye)})}var Se=x(ge,2);{var ee=Ee=>{var D=b$();P("click",D,C),S(Ee,D)};W(Se,Ee=>{e.onOpenSettings&&Ee(ee)})}var de=x(Se,2);{var xe=Ee=>{var D=y$();P("click",D,E),S(Ee,D)};W(de,Ee=>{e.onOpenHelp&&Ee(xe)})}St(Q,Ee=>y(v,Ee),()=>d(v)),P("keydown",Q,_),S(z,Q)};W(Z,z=>{d(m)&&z(q)})}var Y=x(A,4);{var X=z=>{var Q=x$(),ge=w(Q);wd(ge,()=>e.center),S(z,Q)};W(Y,z=>{e.center&&z(X)})}var ae=x(Y,4),ne=w(ae);{var te=z=>{f$(z,{get tandemMode(){return e.tandemMode},get onModeChange(){return e.onModeChange}})};W(ne,z=>{e.tandemMode&&e.onModeChange&&z(te)})}var le=x(ne,2);{var se=z=>{var Q=k$();S(z,Q)};W(le,z=>{n()&&z(se)})}var me=x(le,2);{var K=z=>{var Q=_$(),ge=x(w(Q),2),ye=w(ge);j(()=>{V(Q,"aria-label",`Default model: ${s()}. Open Settings → Models.`),V(Q,"title",`Default model: ${s()}`),J(ye,s())}),P("click",Q,function(...Se){var ee;(ee=e.onOpenModelsSettings)==null||ee.apply(this,Se)}),S(z,Q)};W(me,z=>{s()&&e.onOpenModelsSettings&&z(K)})}var H=x(ae,2);{var O=z=>{var Q=E$(),ge=x(Ie(Q),2),ye=w(ge),Se=x(ye,2),ee=w(Se);{var de=D=>{var $=C$();S(D,$)},xe=D=>{var $=S$();S(D,$)};W(ee,D=>{d(l)?D(de):D(xe,-1)})}var Ee=x(Se,2);j(()=>{ye.disabled=d(a)===null,V(Se,"aria-label",d(l)?"Restore":"Maximize"),Se.disabled=d(a)===null,Ee.disabled=d(a)===null}),P("click",ye,f),P("click",Se,h),P("click",Ee,p),S(z,Q)},G=L(()=>Pt());W(H,z=>{d(G)&&z(O)})}j(()=>V(M,"aria-expanded",d(m))),P("click",M,g),S(t,I),Ke()}et(["click","keydown"]);const e4="tandem-status-count-mode",ih=["words","characters","sentences","paragraphs","pages"],M$={words:"words",characters:"chars",sentences:"sentences",paragraphs:"paragraphs",pages:"pages"},D$=250;function R2(t){const e=t.trim();return e?e.split(/\s+/).length:0}function N2(t){const e=ih.indexOf(t);return ih[(e+1)%ih.length]??"words"}function d0(t){return M$[t]}function O$(){try{const t=localStorage.getItem(e4);if(t&&ih.includes(t))return t}catch{}return"words"}function I$(t){try{localStorage.setItem(e4,t)}catch{}}function R$(t,e){if(!t||t.isDestroyed)return 0;const n=t.state.doc.textContent;switch(e){case"characters":return n.length;case"words":return R2(n);case"sentences":{const r=n.match(/[^.!?]+[.!?]+(?:\s|$)/g);return(r==null?void 0:r.length)??(n.trim()?1:0)}case"paragraphs":{let r=0;return t.state.doc.forEach(i=>{i.type.name==="paragraph"&&i.textContent.trim()&&r++}),r}case"pages":return Math.ceil(R2(n)/D$)}}var N$=T('<button type="button" data-testid="status-word-count" style="background: none; border: none; padding: 0; margin: 0; cursor: pointer; color: var(--tandem-fg-subtle); font: inherit; font-family: var(--tandem-font-mono);" class="svelte-1esxubl"> </button>'),P$=T('<span data-testid="save-indicator" style="color: var(--tandem-accent);" class="svelte-1esxubl">Saving...</span>'),L$=T('<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);" class="svelte-1esxubl">Review Only</span>'),F$=T('<span data-testid="claude-working-indicator" class="claude-working-pill svelte-1esxubl" role="status" aria-live="polite"><span class="claude-working-dot svelte-1esxubl"></span> <span class="claude-working-dot svelte-1esxubl"></span> <span class="claude-working-dot svelte-1esxubl"></span> <span style="margin-left: 4px;" class="svelte-1esxubl"> </span></span>'),z$=T('<div class="tandem-floating-pill tandem-status-pill svelte-1esxubl" style="position: fixed; bottom: var(--tandem-space-3, 12px); left: var(--tandem-space-5, 22px); max-width: calc(100% - var(--tandem-space-7, 44px)); display: inline-flex; align-items: center; padding: 6px var(--tandem-space-3); 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); z-index: var(--tandem-z-sticky); overflow: hidden;"><div style="display: flex; align-items: center; gap: var(--tandem-space-2);" class="svelte-1esxubl"><span class="status-dot svelte-1esxubl"></span> <span class="svelte-1esxubl"> </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);" class="svelte-1esxubl"><span class="svelte-1esxubl">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;" class="svelte-1esxubl"/></div> <!> <div style="display: flex; align-items: center; gap: var(--tandem-space-2);" class="svelte-1esxubl"><span class="claude-dot svelte-1esxubl"></span> <span class="svelte-1esxubl"> </span> <!></div></div>');function B$(t,e){We(e,!0);let n=Ue(e,"claudeWorkingTool",3,null),r=Ue(e,"saving",3,!1);function i(O){return{tandem_edit:"editing",tandem_comment:"commenting",tandem_reply:"replying",tandem_annotationReply:"replying"}[O]??O.replace(/^tandem_/,"")}const o=2e3,s=d1(),a=uo(Or());let l=F(Qe(s.userName)),c=F(void 0);he(()=>{const O=s.userName;d(l)!==O&&document.activeElement!==d(c)&&y(l,O,!0)});let u=F(!1),f=F(0),h=At(()=>e.connected);he(()=>{const O=h;if(h=e.connected,e.connected&&!O){y(u,!0);const G=setTimeout(()=>{y(u,!1)},o);return()=>clearTimeout(G)}}),he(()=>{if(e.disconnectedSince==null){y(f,0);return}y(f,Math.floor((Date.now()-e.disconnectedSince)/1e3),!0);const O=setInterval(()=>{y(f,Math.floor((Date.now()-(e.disconnectedSince??0))/1e3),!0)},1e3);return()=>clearInterval(O)});const p=L(()=>e.connectionStatus==="connecting"),m=L(()=>e.connected?"var(--tandem-success)":d(p)?"var(--tandem-warning)":"var(--tandem-error)"),v=L(()=>d(u)?"Reconnected":e.connectionStatus==="connected"?"Connected":e.connectionStatus==="connecting"?(()=>{const O=["Reconnecting…"];if(e.reconnectAttempts>0||d(f)>0){const G=[];e.reconnectAttempts>0&&G.push(`attempt ${e.reconnectAttempts}`),d(f)>0&&G.push(`${d(f)}s`),O.push(`(${G.join(", ")})`)}return O.join(" ")})():"Disconnected — check that the server is running");function g(){s.setUserName(d(l))}let b=F(Qe(O$())),_=F(0);he(()=>{const O=e.editor;if(!O||O.isDestroyed)return;const G=()=>{O.isDestroyed||vu(_)};return O.on("update",G),O.on("transaction",G),()=>{O.off("update",G),O.off("transaction",G)}});const k=L(()=>(d(_),R$(e.editor??null,d(b))));function C(){const O=N2(d(b));y(b,O,!0),I$(O)}var E=z$(),I=w(E),A=w(I),M=x(A,2),N=w(M),R=x(M,2);{var B=O=>{var G=N$(),z=w(G);j((Q,ge,ye,Se)=>{V(G,"title",Q),V(G,"aria-label",ge),J(z,`${ye??""} ${Se??""}`)},[()=>`Click to cycle: ${d0(N2(d(b)))}`,()=>`${d(k)} ${d0(d(b))} (click to change unit)`,()=>d(k).toLocaleString(),()=>d0(d(b))]),P("click",G,C),S(O,G)};W(R,O=>{e.editor&&O(B)})}var Z=x(R,2);{var q=O=>{var G=P$();S(O,G)};W(Z,O=>{r()&&O(q)})}var Y=x(I,2),X=x(w(Y),2);St(X,O=>y(c,O),()=>d(c));var ae=x(Y,2);{var ne=O=>{var G=L$();S(O,G)};W(ae,O=>{e.readOnly&&O(ne)})}var te=x(ae,2),le=w(te),se=x(le,2),me=w(se),K=x(se,2);{var H=O=>{var G=F$(),z=x(w(G),6),Q=w(z);j(ge=>J(Q,`${a.specific??""} is ${ge??""}…`),[()=>i(n())]),S(O,G)};W(K,O=>{n()&&O(H)})}j(()=>{Me(A,`width: 7px; height: 7px; border-radius: 50%; background: ${d(m)??""}; display: inline-block; animation: ${e.connected&&d(u)?"tandem-conn-bloom 500ms var(--tandem-ease-out)":d(p)?"tandem-conn-pulse 900ms ease-in-out infinite":"none"};`),J(N,d(v)),Sr(X,d(l)),V(X,"maxlength",Vp),Me(le,`width: 7px; height: 7px; 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"};`),Me(se,`transition: color 0.3s ease; color: ${e.claudeActive?"var(--tandem-fg)":"var(--tandem-fg-subtle)"};`),J(me,e.claudeStatus?`${a.specific} · ${e.claudeStatus}`:`${a.specific} · idle`)}),P("input",X,O=>{y(l,O.target.value,!0)}),hn("blur",X,g),P("keydown",X,O=>{O.key==="Enter"&&O.currentTarget.blur(),O.key==="Escape"&&(y(l,s.userName,!0),O.currentTarget.blur())}),S(t,E),Ke()}et(["click","input","keydown"]);const H$={md:"md",markdown:"md",docx:"docx",doc:"docx",txt:"txt",text:"txt",html:"html",htm:"html"};function V$(t){const e=t.lastIndexOf(".");return e<=0||e===t.length-1?"other":H$[t.slice(e+1).toLowerCase()]??"other"}function U$(t){const e=t.split(/[/\\]/);return{name:e.at(-1)??t,dir:e.slice(0,-1).join("/")}}function j$(t,e=Date.now()){const{dir:n,name:r}=U$(t.path);return{path:t.path,name:r,dir:n,when:F5(t.openedAt,e),pip:V$(r)}}function q$(t,e){const n=e.trim().toLowerCase();return n?t.name.toLowerCase().includes(n)||t.dir.toLowerCase().includes(n):!0}function W$(t,e){const n=e.trim();if(!n)return[{text:t,match:!1}];const r=t.toLowerCase(),i=n.toLowerCase(),o=[];let s=0;for(;s<t.length;){const a=r.indexOf(i,s);if(a===-1){o.push({text:t.slice(s),match:!1});break}a>s&&o.push({text:t.slice(s,a),match:!1}),o.push({text:t.slice(a,a+i.length),match:!0}),s=a+i.length}return o}var K$=Dr("<path></path>"),G$=Dr('<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"></svg>'),Z$=T('<button class="ntl-search-clr svelte-7c4il0" type="button" aria-label="Clear search"><svg width="11" height="11" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" aria-hidden="true"><path d="M6 6l12 12M6 18L18 6"></path></svg></button>'),Y$=T('<span class="ntl-count svelte-7c4il0" aria-hidden="true"> </span>'),J$=T(`<div class="ntl-empty svelte-7c4il0" data-testid="new-tab-empty"><div class="ntl-empty-ic svelte-7c4il0"><!></div> No recent files yet. <div class="ntl-sub svelte-7c4il0">Open something and it'll appear here.</div></div>`),X$=T('<div class="ntl-no-match svelte-7c4il0" data-testid="new-tab-no-match"> <div class="ntl-sub svelte-7c4il0">Try a different name, or create a scratchpad.</div></div>'),Q$=T('<mark class="svelte-7c4il0"> </mark>'),$$=T('<span class="ntl-path svelte-7c4il0"> </span>'),eee=T('<span class="ntl-when svelte-7c4il0"> </span>'),tee=T('<button type="button" data-nav-item="" class="ntl-recent svelte-7c4il0"><span></span> <span class="ntl-body svelte-7c4il0"><span class="ntl-name svelte-7c4il0"></span> <!></span> <!></button>'),nee=T('<div class="ntl-recents svelte-7c4il0"></div>'),ree=T('<button type="button" data-nav-item="" class="ntl-action svelte-7c4il0" data-testid="new-tab-reopen-closed"><span class="ntl-glyph svelte-7c4il0"><!></span> <span class="ntl-lbl svelte-7c4il0">Reopen last closed</span> <span class="ntl-kbd svelte-7c4il0" aria-hidden="true">Ctrl+Alt+T</span></button>'),iee=T('<div role="dialog" aria-label="New tab" tabindex="-1" class="new-tab-menu svelte-7c4il0"><div class="ntl-search svelte-7c4il0"><span class="ntl-search-ic svelte-7c4il0"><!></span> <input type="text" placeholder="Search recent files…" aria-label="Search recent files" data-testid="new-tab-search" class="svelte-7c4il0"/> <!> <!> <span class="ntl-esc svelte-7c4il0" aria-hidden="true">Esc</span></div> <div class="ntl-cols svelte-7c4il0"><div class="ntl-col ntl-left svelte-7c4il0"><!></div> <div class="ntl-col ntl-right svelte-7c4il0"><div class="ntl-colhead svelte-7c4il0"><span class="ntl-colhead-label svelte-7c4il0">Create</span></div> <button type="button" data-nav-item="" class="ntl-action ntl-action-primary svelte-7c4il0" data-testid="palette-item-new-scratchpad"><span class="ntl-glyph svelte-7c4il0"><!></span> <span class="ntl-lbl svelte-7c4il0">New scratchpad</span> <span class="ntl-kbd svelte-7c4il0" aria-hidden="true">Ctrl+N</span></button> <div class="ntl-colhead svelte-7c4il0"><span class="ntl-colhead-label svelte-7c4il0">Open</span></div> <button type="button" data-nav-item="" class="ntl-action svelte-7c4il0" data-testid="new-tab-browse"><span class="ntl-glyph svelte-7c4il0"><!></span> <span class="ntl-lbl svelte-7c4il0">Browse files…</span> <span class="ntl-kbd svelte-7c4il0" aria-hidden="true">Ctrl+O</span></button> <!></div></div> <div class="ntl-footer svelte-7c4il0"><span class="ntl-kgrp svelte-7c4il0"><span class="ntl-key svelte-7c4il0" aria-hidden="true">↑</span><span class="ntl-key svelte-7c4il0" aria-hidden="true">↓</span>navigate</span> <span class="ntl-kgrp svelte-7c4il0"><span class="ntl-key svelte-7c4il0" aria-hidden="true">↵</span>open</span> <span class="ntl-spacer svelte-7c4il0"></span> <span class="ntl-kgrp svelte-7c4il0">type to filter</span></div></div>');function oee(t,e){We(e,!0);const n=(K,H=Tn,O=Tn,G=Tn)=>{var z=G$();nt(z,21,()=>u[H()]??[],zl,(Q,ge)=>{var ye=K$();j(()=>V(ye,"d",d(ge))),S(Q,ye)}),j(()=>{V(z,"width",O()),V(z,"height",O()),V(z,"stroke-width",G())}),S(K,z)};let r=F(""),i=F(null),o=F(null);const s=L(()=>e.recentFiles.map(K=>j$(K))),a=L(()=>d(s).filter(K=>q$(K,d(r)))),l=L(()=>d(s).length>0),c=L(()=>d(r).trim().length>0),u={plus:["M12 5v14","M5 12h14"],folder:["M14 3H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z","M14 3v6h6"],undo:["M3 7v6h6","M3 13a9 9 0 1 0 3-7"],search:["M11 4a7 7 0 1 0 0 14 7 7 0 0 0 0-14z","m20 20-3.5-3.5"],inbox:["M3 7l9 6 9-6","M3 7v10a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V7l-9-4-9 4z"]};function f(){var K;return Array.from(((K=d(i))==null?void 0:K.querySelectorAll("[data-nav-item]"))??[])}function h(K){var G,z;const H=f();if(H.length===0)return;const O=H.indexOf(document.activeElement);if(O===-1){(G=K>0?H[0]:H[H.length-1])==null||G.focus();return}(z=H[(O+K+H.length)%H.length])==null||z.focus()}function p(K){K.key==="Escape"?(K.preventDefault(),e.onClose()):K.key==="ArrowDown"?(K.preventDefault(),h(1)):K.key==="ArrowUp"&&(K.preventDefault(),h(-1))}he(()=>{var K;d(i)&&((K=d(o))==null||K.focus({preventScroll:!0}))});var m=iee(),v=w(m),g=w(v),b=w(g);n(b,()=>"search",()=>13,()=>1.7);var _=x(g,2);St(_,K=>y(o,K),()=>d(o));var k=x(_,2);{var C=K=>{var H=Z$();P("click",H,()=>y(r,"")),S(K,H)};W(k,K=>{d(c)&&K(C)})}var E=x(k,2);{var I=K=>{var H=Y$(),O=w(H);j(()=>J(O,`${d(a).length??""} of ${d(s).length??""}`)),S(K,H)};W(E,K=>{d(l)&&K(I)})}var A=x(v,2),M=w(A),N=w(M);{var R=K=>{var H=J$(),O=w(H),G=w(O);n(G,()=>"inbox",()=>16,()=>1.6),S(K,H)},B=K=>{var H=X$(),O=w(H);j(G=>J(O,`No matches for “${G??""}”. `),[()=>d(r).trim()]),S(K,H)},Z=K=>{var H=nee();nt(H,23,()=>d(a),O=>O.path,(O,G,z)=>{var Q=tee(),ge=w(Q),ye=x(ge,2),Se=w(ye);nt(Se,21,()=>W$(d(G).name,d(r)),zl,(D,$)=>{var ke=Mt(),we=Ie(ke);{var Ae=oe=>{var De=Q$(),ze=w(De);j(()=>J(ze,d($).text)),S(oe,De)},pe=oe=>{var De=hr();j(()=>J(De,d($).text)),S(oe,De)};W(we,oe=>{d($).match?oe(Ae):oe(pe,-1)})}S(D,ke)});var ee=x(Se,2);{var de=D=>{var $=$$(),ke=w($);j(()=>J(ke,d(G).dir)),S(D,$)};W(ee,D=>{d(G).dir&&D(de)})}var xe=x(ye,2);{var Ee=D=>{var $=eee(),ke=w($);j(()=>J(ke,d(G).when)),S(D,$)};W(xe,D=>{d(G).when&&D(Ee)})}j(()=>{V(Q,"data-testid",`new-tab-recent-${d(z)}`),V(Q,"title",d(G).path),yt(ge,1,`ntl-pip ntl-pip-${d(G).pip??""}`,"svelte-7c4il0")}),P("click",Q,()=>e.onOpen(d(G).path)),S(O,Q)}),S(K,H)};W(N,K=>{d(l)?d(a).length===0?K(B,1):K(Z,-1):K(R)})}var q=x(M,2),Y=x(w(q),2),X=w(Y),ae=w(X);n(ae,()=>"plus",()=>14,()=>1.9);var ne=x(Y,4),te=w(ne),le=w(te);n(le,()=>"folder",()=>13,()=>1.7);var se=x(ne,2);{var me=K=>{var H=ree(),O=w(H),G=w(O);n(G,()=>"undo",()=>13,()=>1.7),j(()=>V(H,"title",e.closedTabTop.filePath)),P("click",H,function(...z){var Q;(Q=e.onReopenClosed)==null||Q.apply(this,z)}),S(K,H)};W(se,K=>{e.closedTabTop&&K(me)})}St(m,K=>y(i,K),()=>d(i)),P("keydown",m,p),Xn(_,()=>d(r),K=>y(r,K)),P("click",Y,function(...K){var H;(H=e.onNewScratchpad)==null||H.apply(this,K)}),P("click",ne,function(...K){var H;(H=e.onBrowse)==null||H.apply(this,K)}),S(t,m),Ke()}et(["keydown","click"]);var see=T('<span class="dot svelte-1btt0ja" aria-hidden="true">●</span>'),aee=T('<span class="saved-check svelte-1btt0ja" aria-hidden="true">✓</span>'),lee=T('<span class="tab-ro-badge svelte-1btt0ja" aria-label="Read-only">RO</span>'),cee=T('<div role="tab" class="svelte-1btt0ja"><span class="save-indicator svelte-1btt0ja"><!></span> <span class="svelte-1btt0ja"> </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" class="svelte-1btt0ja">×</button></div>');function uee(t,e){We(e,!0);const n=Ue(e,"reduceMotion",3,!1);let r=F(!1),i=null;he(()=>{const{ydoc:I,readOnly:A}=e.tab;if(A){y(r,!1);return}const M=I.getXmlFragment("default"),N=I.getMap(zf);let R=!1;const B=setTimeout(()=>{R=!0,i=N.get($y)??0,y(r,!1)},500),Z=()=>{R&&y(r,!0)};M.observeDeep(Z);const q=()=>{if(!R)return;const Y=N.get($y);Y!==void 0&&Y!==i&&(i=Y,y(r,!1))};return N.observe(q),()=>{clearTimeout(B),M.unobserveDeep(Z),N.unobserve(q)}});const o=600;let s=F(!1),a=!1;he(()=>{const I=a;if(a=d(r),!d(r)&&I){y(s,!0);const A=setTimeout(()=>{y(s,!1)},o);return()=>clearTimeout(A)}y(s,!1)});const l=L(()=>["display: flex","align-items: center","gap: 6px","padding: 0 10px 0 12px","height: 26px","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: 1px solid ${e.isActive?"var(--tandem-border)":"transparent"}`,`border-left: ${e.dropIndicator==="left"?"2px solid var(--tandem-accent)":e.isActive?"1px solid var(--tandem-border)":"2px solid transparent"}`,`border-right: ${e.dropIndicator==="right"?"2px solid var(--tandem-accent)":e.isActive?"1px solid var(--tandem-border)":"2px solid transparent"}`,"border-radius: var(--tandem-r-pill)",`box-shadow: ${e.isActive?"var(--tandem-shadow-1)":"0 1px 3px rgba(0, 0, 0, 0.08)"}`,"user-select: none","touch-action: none","white-space: nowrap","transition: background 0.15s, color 0.15s, border-color 0.15s, box-shadow 0.15s","flex-shrink: 0"].join("; "));let c=F(void 0);function u(){d(c)&&(d(c).style.color="var(--tandem-error)")}function f(){d(c)&&(d(c).style.color="var(--tandem-fg-muted)")}var h=cee();V(h,"tabindex",0);var p=w(h),m=w(p);{var v=I=>{var A=see();S(I,A)},g=I=>{var A=aee();S(I,A)};W(m,I=>{d(r)?I(v):d(s)&&I(g,1)})}var b=x(p,2),_=w(b),k=x(b,2);{var C=I=>{var A=lee();S(I,A)};W(k,I=>{e.tab.readOnly&&I(C)})}var E=x(k,2);St(E,I=>y(c,I),()=>d(c)),j(()=>{V(h,"data-testid",`tab-${e.tab.id}`),V(h,"data-active",e.isActive),V(h,"aria-selected",e.isActive),V(h,"aria-label",e.tab.fileName),Me(h,d(l)),V(p,"data-testid",`unsaved-indicator-${e.tab.id}`),V(p,"aria-hidden",!d(r)),V(b,"data-testid",`tab-name-${e.tab.id}`),V(b,"title",e.tab.filePath),Me(b,`font-weight: ${e.isActive?500:400}; min-width: 80px; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;`),J(_,e.tab.fileName),V(E,"aria-label",`Close ${e.tab.fileName}`)}),P("click",h,()=>e.onswitch(e.tab.id)),P("pointerdown",h,I=>e.onpointerdown(I,e.tab.id)),P("keydown",h,I=>e.onkeydown(I,e.tab.id)),P("click",E,I=>{I.stopPropagation(),e.onclose(e.tab.id)}),P("pointerdown",E,I=>I.stopPropagation()),hn("mouseenter",E,u),hn("mouseleave",E,f),Uo(2,h,()=>xI,()=>({reduceMotion:n()})),S(t,h),Ke()}et(["click","pointerdown","keydown"]);const dee=["ctx:tab:close","ctx:tab:closeOthers","ctx:tab:closeRight","ctx:tab:copyPath","ctx:tab:reveal"],fee=new Set(dee);function hee(t){return typeof t=="string"&&fee.has(t)}function ob(t){return!Bp(t)&&!el(t)}function pee(t,e){const n=t.findIndex(i=>i.id===e),r=n>=0?t[n]:void 0;return{canCloseOthers:t.length>1,canCloseRight:n>=0&&n<t.length-1,hasPath:!!r&&ob(r.filePath)}}function mee(t,e){return t.some(n=>n.id===e)?t.filter(n=>n.id!==e).map(n=>n.id):[]}function gee(t,e){const n=t.findIndex(r=>r.id===e);return n<0?[]:t.slice(n+1).map(r=>r.id)}var vee=T('<div style="position: relative; display: flex; align-items: center; background: transparent; min-height: 32px; z-index: var(--tandem-z-base); width: 100%; min-width: 0;"><div data-testid="tab-scroll-container" role="tablist" aria-label="Open documents" style="display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0; overflow-x: auto; overflow-y: hidden; padding: 6px 8px;"></div> <div class="nt-wrap svelte-urrc8n"><div><button data-testid="open-file-btn" class="tandem-floating-pill tab-add-pill svelte-urrc8n" title="Open file" aria-label="Open file" aria-haspopup="dialog">+</button> <div class="nt-grid svelte-urrc8n"><div class="nt-cell svelte-urrc8n"><!></div></div></div></div></div>');function bee(t,e){We(e,!0);const n=Ue(e,"reduceMotion",3,!1),r=Ue(e,"openMenuTrigger",3,0),i=Ue(e,"closedTabTop",3,null),o=L(()=>n()?"auto":"smooth");let s=F(!1),a=F(Qe([])),l=F(null),c=new Set;he(()=>{const D=new Set(e.tabs.map($=>$.id));for(const $ of c)D.has($)||c.delete($)});function u(D){c.has(D)||(c.add(D),e.onTabClose(D))}let f=null,h=null;async function p(D){var Ae;if(!Pt())return;const $=(Ae=D.target)==null?void 0:Ae.closest('[data-testid^="tab-"][role="tab"]'),ke=te($);if(!ke)return;const we=e.tabs.find(pe=>pe.id===ke);if(we){f=ke,h=we.filePath,D.preventDefault();try{await(await Ta())("show_tab_context_menu",{req:pee(e.tabs,ke)})}catch{}}}async function m(D){var we,Ae;const $=f,ke=h;if($)switch(D){case"ctx:tab:close":u($);return;case"ctx:tab:closeOthers":(we=e.onCloseOthers)==null||we.call(e,$);return;case"ctx:tab:closeRight":(Ae=e.onCloseToRight)==null||Ae.call(e,$);return;case"ctx:tab:copyPath":if(ke&&ob(ke))try{await navigator.clipboard.writeText(ke)}catch{}return;case"ctx:tab:reveal":if(ke&&ob(ke))try{await(await Ta())("show_in_file_manager",{path:ke})}catch{}return}}let v=F(void 0),g=F(!1),b=F(!1),_=F(null),k=F(null),C=null,E=0,I=0,A=!1,M=null;const N=5;function R(D){le(D)}function B(D){se(D)}function Z(D){C!==null&&D.pointerId===C&&Y()}function q(D){D.key==="Escape"&&Y()}function Y(){if(M&&C!==null)try{M.releasePointerCapture(C)}catch{}window.removeEventListener("pointermove",R),window.removeEventListener("pointerup",B),window.removeEventListener("pointercancel",Z),window.removeEventListener("keydown",q),y(_,null),y(k,null),C=null,A=!1,M=null}gr(Y),he(()=>{if(!d(_)&&!d(k))return;const D=new Set(e.tabs.map($=>$.id));d(_)&&!D.has(d(_))&&y(_,null),d(k)&&!D.has(d(k).id)&&y(k,null)});function X(){const D=d(v);D&&(y(g,D.scrollLeft>0),y(b,D.scrollLeft+D.clientWidth<D.scrollWidth-1))}he(()=>{const D=d(v);if(!D)return;X(),D.addEventListener("scroll",X,{passive:!0});const $=new ResizeObserver(X);return $.observe(D),()=>{D.removeEventListener("scroll",X),$.disconnect()}}),he(()=>{const D=d(v);if(D)return D.addEventListener("contextmenu",p),()=>D.removeEventListener("contextmenu",p)}),he(()=>{if(!Pt())return;const D=yn(async()=>{const{listen:$}=await import("./event-CNdo2oXa.js");return{listen:$}},__vite__mapDeps([2,1])).then(({listen:$})=>$("context-menu-action",ke=>{var Ae;const we=(Ae=ke.payload)==null?void 0:Ae.id;hee(we)&&m(we)}));return D.catch(()=>{}),()=>{D.then($=>$()).catch(()=>{})}}),he(()=>{e.tabs.length,X()}),he(()=>{if(!e.activeTabId||!d(v))return;const D=d(v).querySelector(`[data-testid="tab-${e.activeTabId}"]`);D&&D.scrollIntoView({inline:"nearest",block:"nearest",behavior:d(o)})});function ae(D,$){if(!(D.button!==0||d(K))){C=D.pointerId,E=D.clientX,I=D.clientY,A=!1,y(_,$,!0),M=D.currentTarget;try{M.setPointerCapture(D.pointerId)}catch{}window.addEventListener("pointermove",R),window.addEventListener("pointerup",B),window.addEventListener("pointercancel",Z),window.addEventListener("keydown",q)}}function ne(D,$){var we;return((we=document.elementFromPoint(D,$))==null?void 0:we.closest('[data-testid^="tab-"][role="tab"]'))??null}function te(D){var $;return(($=D==null?void 0:D.getAttribute("data-testid"))==null?void 0:$.slice(4))??null}function le(D){if(C===null||D.pointerId!==C||!d(_))return;if(!A){const oe=D.clientX-E,De=D.clientY-I;if(Math.hypot(oe,De)<N)return;A=!0}D.preventDefault();const $=ne(D.clientX,D.clientY),ke=te($);if(!$||!ke||ke===d(_)){y(k,null);return}const we=$.getBoundingClientRect(),Ae=we.left+we.width/2,pe=D.clientX<Ae?"left":"right";y(k,{id:ke,side:pe},!0)}function se(D){if(C===null||D.pointerId!==C)return;const $=A,ke=d(k);if($&&d(_)&&ke&&ke.id!==d(_)&&e.reorder&&e.tabs.some(we=>we.id===d(_))&&e.tabs.some(we=>we.id===ke.id)&&e.reorder(d(_),ke.id,ke.side),$){let we;const Ae=pe=>{pe.stopPropagation(),pe.preventDefault(),window.removeEventListener("click",Ae,!0),clearTimeout(we)};window.addEventListener("click",Ae,!0),we=setTimeout(()=>window.removeEventListener("click",Ae,!0),0)}Y()}function me(D,$){if(!D.altKey||!e.reorder||D.key!=="ArrowLeft"&&D.key!=="ArrowRight")return;D.preventDefault();const ke=e.tabs.findIndex(we=>we.id===$);ke!==-1&&(D.key==="ArrowLeft"&&ke>0?e.reorder($,e.tabs[ke-1].id):D.key==="ArrowRight"&&ke<e.tabs.length-1&&e.reorder(e.tabs[ke+1].id,$))}const K=L(()=>e.tabs.length<=1);function H(){const D=!d(s);D&&y(a,Aw(),!0),y(s,D)}he(()=>{if(!d(s))return;function D($){var we,Ae;const ke=$.target;ke&&((we=d(l))!=null&&we.contains(ke)||(Ae=ke.closest)!=null&&Ae.call(ke,".new-tab-menu")||oX(ke)||y(s,!1))}return window.addEventListener("pointerdown",D,!0),()=>window.removeEventListener("pointerdown",D,!0)});let O=!1;he(()=>{var $;if(d(s)){O=!0;return}if(!O)return;O=!1;const D=document.activeElement;(!D||D===document.body)&&(($=d(l))==null||$.focus({preventScroll:!0}))}),he(()=>{r()>0&&At(H)});var G=vee(),z=w(G);nt(z,21,()=>e.tabs,D=>D.id,(D,$)=>{{let ke=L(()=>d($).id===e.activeTabId),we=L(()=>{var Ae;return((Ae=d(k))==null?void 0:Ae.id)===d($).id?d(k).side:null});uee(D,{get tab(){return d($)},get isActive(){return d(ke)},get onswitch(){return e.onTabSwitch},onclose:u,onpointerdown:ae,get dropIndicator(){return d(we)},onkeydown:me,get reduceMotion(){return n()}})}}),St(z,D=>y(v,D),()=>d(v));var Q=x(z,2),ge=w(Q);let ye;var Se=w(ge);St(Se,D=>y(l,D),()=>d(l));var ee=x(Se,2),de=w(ee),xe=w(de);{var Ee=D=>{oee(D,{get recentFiles(){return d(a)},get closedTabTop(){return i()},onOpen:async $=>{y(s,!1);const ke=await Wo($);ke.ok?Gp(Kp(Aw(),$)):console.warn("[tandem] failed to open recent file:",ke.error)},onNewScratchpad:()=>{y(s,!1),mh()},onBrowse:()=>{var $;y(s,!1),($=e.onRequestOpenDialog)==null||$.call(e)},onReopenClosed:()=>{var $;y(s,!1),($=e.onReopenClosed)==null||$.call(e)},onClose:()=>y(s,!1)})};W(xe,D=>{d(s)&&D(Ee)})}j(()=>{yt(z,1,D0(["tab-scroll-hide","tab-scroll-mask",d(g)&&d(b)&&"has-overflow",d(g)&&!d(b)&&"overflow-left",!d(g)&&d(b)&&"overflow-right"])),ye=yt(ge,1,"nt-morph svelte-urrc8n",null,ye,{open:d(s)}),V(Se,"aria-expanded",d(s))}),P("click",Se,H),S(t,G),Ke()}et(["click"]);const P2=(t,e=Tn,n=Tn)=>{var r=wee();j(()=>{yt(r,1,`panel-edge-collapse panel-edge-collapse-${e()}`,"svelte-y74n0s"),V(r,"data-testid",`panel-edge-collapse-${e()}`),V(r,"aria-label",e()==="left"?"Hide left panel":"Hide right panel")}),P("click",r,function(...i){var o;(o=n())==null||o.apply(this,i)}),S(t,r)};var yee=T('<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>'),wee=T('<div role="button" tabindex="-1"></div>'),xee=T("<!> <!> <!>",1),kee=T('<div class="margin-track svelte-y74n0s" style="grid-column: 2; grid-row: 1;"><!></div>'),_ee=T('<div class="margin-track svelte-y74n0s" style="grid-column: 4; grid-row: 1;"><!></div>'),Cee=T('<div class="editor-content-track svelte-y74n0s" style="grid-column: 3; grid-row: 1;"><!></div> <!> <!>',1),See=T('<div class="editor-end-marker svelte-y74n0s" aria-hidden="true"><span class="editor-end-pill svelte-y74n0s">End of document</span></div>'),Eee=T('<div role="region" aria-label="Document editor"><!> <div data-testid="editor-stage"><!></div> <!> <!></div>'),Aee=T('<div style="display: flex; flex: 1; align-items: center; justify-content: center; color: var(--tandem-fg-subtle);">Connecting...</div>'),Tee=T('<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>'),Mee=T('<span class="rail-tab-badge svelte-y74n0s"> </span>'),Dee=T('<!> <!> <!> <!> <!> <div style="position: relative; display: flex; flex: 1; overflow: hidden; background: var(--tandem-bg);"><div><div data-testid="left-outline-rail" class="rail-full rail-full-left svelte-y74n0s"><!> <!></div> <!></div> <!> <!> <!> <div><div class="rail-full rail-full-right svelte-y74n0s"><!> <div class="rail-tabs-row svelte-y74n0s"><div class="rail-tabs-track svelte-y74n0s"><button data-testid="annotations-tab">Annotations <!></button> <button data-testid="chat-tab">Chat</button></div></div> <!> <!></div> <!></div></div> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!>',1),Oee=T('<div style="display: flex; flex-direction: column; height: 100vh; background: var(--tandem-bg); color: var(--tandem-fg);"><!> <!></div>');function Iee(t,e){We(e,!0);const n=U=>{bee(U,{get tabs(){return p.orderedTabs},get activeTabId(){return o.activeTabId},get onTabSwitch(){return o.setActiveTabId},onTabClose:c,onCloseOthers:u,onCloseToRight:f,get reorder(){return p.reorder},get reduceMotion(){return m.settings.reduceMotion},onRequestOpenDialog:()=>void G(),get openMenuTrigger(){return d(Ye)},get closedTabTop(){return a.top},onReopenClosed:h})},r=(U,ue=Tn,_e=Tn,Ve=Tn,wt=Tn)=>{var Ht=yee();V(Ht,"aria-valuemin",0),V(Ht,"aria-valuemax",100),j(Wt=>{V(Ht,"data-testid",Ve()??`${ue()}-panel-resize-handle`),V(Ht,"aria-label",ue()==="left"?"Resize left panel":"Resize right panel"),V(Ht,"aria-valuenow",Wt)},[()=>wt()!==void 0?Math.round((wt()-Sl)/(od-Sl)*100):50]),P("mousedown",Ht,function(...Wt){var Bi;(Bi=_e())==null||Bi.apply(this,Wt)}),P("keydown",Ht,Wt=>{let vt=null;Wt.key==="ArrowRight"||Wt.key==="ArrowUp"?vt=16:Wt.key==="ArrowLeft"||Wt.key==="ArrowDown"?vt=-16:Wt.key==="PageUp"?vt=80:Wt.key==="PageDown"?vt=-80:Wt.key==="Home"?vt=Sl-(ue()==="left"?Te.width:ce.width):Wt.key==="End"&&(vt=od-(ue()==="left"?Te.width:ce.width)),vt!==null&&(Wt.preventDefault(),Wt.stopPropagation(),ue()==="left"?Te.handleResizeStep(vt):ce.handleResizeStep(vt))}),P("keyup",Ht,()=>{}),hn("mouseenter",Ht,Wt=>{Wt.currentTarget.style.background="var(--tandem-border-strong)"}),hn("mouseleave",Ht,Wt=>{Wt.currentTarget.style.background="transparent"}),S(U,Ht)},i=U=>{var ue=Eee();let _e;{const Gt=Dt=>{WJ(Dt,{get ydoc(){return d(Fe).ydoc},get provider(){return d(Fe).provider},get readOnly(){return o.readOnly},get currentFilePath(){return d(Fe).filePath},get format(){return d(Fe).format},get activeAnnotationId(){return d(we)},onEditorReady:It=>y(oe,It,!0),onAnnotationClick:It=>{y($,"annotations"),y(we,It,!0)},onClearAnnotation:()=>{y(we,null)},onSlashCommandMenuChange:It=>y(ze,It,!0)})},sn=(Dt,It=Tn,nn=Tn)=>{const wn=L(()=>It()==="left"?tt.leftGeometry:tt.rightGeometry),js=L(()=>It()==="left"?tt.leftMode:tt.rightMode);XQ(Dt,{get side(){return It()},get annotations(){return nn()},get positions(){return Gr.byId},get width(){return d(wn).column},get edgeInset(){return d(wn).inset},get gap(){return d(wn).gap},get mode(){return d(js)},get activeAnnotationId(){return d(we)},get repliesById(){return Fi.byId},onClick:Zo=>{y(we,Zo.id,!0),dt.scrollToAnnotation(Zo)},get onAccept(){return dt.handleAccept},get onDismiss(){return dt.handleDismiss},get onRemove(){return d(on).onRemove},get onEdit(){return d(on).onEdit},get onReply(){return d(on).onReply},get onSendToClaude(){return d(on).onSendToClaude}})};var Ve=w(ue);{let Dt=L(()=>{var nn,wn;return((nn=d(Fe))==null?void 0:nn.readOnly)===!0&&((wn=d(Fe))==null?void 0:wn.format)==="docx"}),It=L(()=>{var nn;return(nn=d(Fe))==null?void 0:nn.id});m7(Ve,{get visible(){return d(Dt)},get documentId(){return d(It)}})}var wt=x(Ve,2),Ht=w(wt);{var Wt=Dt=>{var It=xee(),nn=Ie(It);yu(nn,()=>d(Fe).id,Ir=>{Gt(Ir)});var wn=x(nn,2);{var js=Ir=>{sn(Ir,()=>"left",()=>d(Ft))};W(wn,Ir=>{tt.leftVisible&&d(Fe)&&Ir(js)})}var Zo=x(wn,2);{var qs=Ir=>{sn(Ir,()=>"right",()=>d(Sn))};W(Zo,Ir=>{tt.rightVisible&&d(Fe)&&Ir(qs)})}S(Dt,It)},Bi=Dt=>{var It=Cee(),nn=Ie(It),wn=w(nn);{var js=er=>{var Zr=Mt(),Yo=Ie(Zr);yu(Yo,()=>d(Fe).id,_c=>{Gt(_c)}),S(er,Zr)},Zo=er=>{L5(er,{get connected(){return o.connected},get claudeActive(){return o.claudeActive},onOpenFile:()=>y(O,!0),onRetry:()=>o.reconnect(),onOpenSettings:ge})};W(wn,er=>{d(Fe)?er(js):er(Zo,-1)})}var qs=x(nn,2);{var Ir=er=>{var Zr=kee(),Yo=w(Zr);sn(Yo,()=>"left",()=>d(Ft)),S(er,Zr)};W(qs,er=>{tt.leftVisible&&d(Fe)&&er(Ir)})}var Hd=x(qs,2);{var Vd=er=>{var Zr=_ee(),Yo=w(Zr);sn(Yo,()=>"right",()=>d(Sn)),S(er,Zr)};W(Hd,er=>{tt.rightVisible&&d(Fe)&&er(Vd)})}S(Dt,It)};W(Ht,Dt=>{var It;((It=d(Fe))==null?void 0:It.format)==="docx"?Dt(Wt):Dt(Bi,-1)})}St(wt,Dt=>y(De,Dt),()=>d(De));var Us=x(wt,2);{var vt=Dt=>{var It=See();S(Dt,It)};W(Us,Dt=>{d(Fe)&&Dt(vt)})}var Xt=x(Us,2);tX(Xt,{get editor(){return d(oe)},get open(){return d(Ge)},onClose:()=>y(Ge,!1),get tabs(){return o.tabs},get forceScope(){return d(Ce)}}),Tr(ue,(Dt,It)=>jt==null?void 0:jt(Dt,It),()=>"y"),j(()=>Me(wt,tt.layerStyle))}j(()=>{_e=yt(ue,1,"editor-scroll tandem-scroll-fade-y",null,_e,{"hide-raw-md":!m.settings.showRawMarkdown}),Me(ue,`position: relative; flex: 1; overflow: auto; padding: max(var(--tandem-space-7), 52px) var(--tandem-space-5) var(--tandem-space-7) var(--tandem-space-5); border: ${N.fileDragOver||a0.fileDragOver?"2px dashed var(--tandem-accent)":"2px solid transparent"}; background: ${N.fileDragOver||a0.fileDragOver?"var(--tandem-accent-bg)":"var(--tandem-bg)"}; transition: border-color 0.15s, background 0.15s; border-radius: ${N.fileDragOver||a0.fileDragOver?"var(--tandem-r-5)":"0"};`)}),hn("dragover",ue,function(...Gt){var sn;(sn=N.handleEditorDragOver)==null||sn.apply(this,Gt)}),hn("dragleave",ue,function(...Gt){var sn;(sn=N.handleEditorDragLeave)==null||sn.apply(this,Gt)}),hn("drop",ue,function(...Gt){var sn;(sn=N.handleEditorDrop)==null||sn.apply(this,Gt)}),S(U,ue)},o=OQ();gr(()=>o.destroy());const s=iQ(()=>o.tabs);gr(()=>s.destroy());const a=zX(),l=new Set;function c(U){const ue=o.tabs.find(_e=>_e.id===U);if(ue&&Bp(ue.filePath)){const _e=V_(ue.filePath);if(_e&&s.hasUnsavedContent(_e)){if(!window.confirm("This scratchpad has unsaved content that will be lost. Close it anyway?"))return;s.clearUnsaved(_e)}}ue&&!el(ue.filePath)&&a.push({filePath:ue.filePath,closedAt:Date.now()}),o.handleTabClose(U)}function u(U){for(const ue of mee(p.orderedTabs,U))c(ue)}function f(U){for(const ue of gee(p.orderedTabs,U))c(ue)}async function h(){const U=a.pop();if(!U)return;const ue=o.tabs.find(Ve=>Ve.filePath===U.filePath);if(ue){o.setActiveTabId(ue.id);return}if(l.has(U.filePath))return;l.add(U.filePath);const _e=Ve=>{a.push(U);const wt=U.filePath.split(/[\\/]/).pop()||U.filePath;A.push({id:`reopen-failed-${Date.now()}`,type:"general-error",severity:"error",message:`Couldn't reopen ${wt}: ${Ve}`,dedupKey:`reopen-failed:${U.filePath}`,timestamp:Date.now()})};try{const Ve=await Wo(U.filePath);Ve.ok||_e(Ve.error)}finally{l.delete(U.filePath)}}const p=cQ(()=>o.tabs);sQ(()=>p.orderedTabs,()=>o.activeTabId,U=>o.setActiveTabId(U)),he(()=>{const U=o.tabs;if(U.length!==0)try{const ue=Mu();let _e=ue;for(const Ve of U)el(Ve.filePath)||(_e=Kp(_e,Ve.filePath));(_e.length!==ue.length||_e.some((Ve,wt)=>Ve!==ue[wt]))&&Gp(_e)}catch(ue){console.warn("[tandem] failed to sync recent files:",ue)}});const m=Or(),v=uQ(()=>o.bootstrapYdoc,()=>m.settings.selectionDwellMs),g=HQ(m,v),b=L(()=>wC(m.settings.customShortcuts)),_=L(()=>YD(d(b))),k=L(()=>o.annotations),C=BX(()=>o.disconnectedSince,()=>m.settings.degradedBannerDelayMs),E=EQ();TQ();const I=L(()=>o.tabs.map(U=>({id:U.id,fileName:U.fileName}))),A=rQ();let M=F(!1);const N=KX();if(hQ(A.push),Pt()){let U=null,ue=!1;yn(async()=>{const{listen:_e}=await import("./event-CNdo2oXa.js");return{listen:_e}},__vite__mapDeps([2,1])).then(({listen:_e})=>_e("sidecar-restart-failed",()=>{A.push({id:`sidecar-restart-failed-${Date.now()}`,type:"general-error",severity:"error",message:"Sidecar failed to restart — see logs",dedupKey:"sidecar-restart-failed",timestamp:Date.now(),errorCode:"SIDECAR_RESTART_FAILED"})})).then(_e=>{ue?_e():U=_e}).catch(_e=>{console.warn("[App] Failed to wire sidecar-restart-failed listener:",_e)}),gr(()=>{ue=!0,U==null||U()})}let R=F(!1),B=F(!1);const Z=GX(),q="tandem:wizard-dismissed";let Y=F(Qe(ae())),X=F(!1);function ae(){try{return localStorage.getItem(q)}catch{return null}}const ne=L(()=>Z.needed===!0&&Z.serverVersion!==null&&d(Y)!==Z.serverVersion),te=L(()=>d(X)||d(ne));let le=F(!1);const se=L(()=>d(ne)&&m.settings.models.length===0&&!d(le));function me(){if(d(ne)&&Z.serverVersion!==null)try{localStorage.setItem(q,Z.serverVersion),y(Y,Z.serverVersion,!0)}catch{}y(X,!1),y(le,!1)}he(()=>{const U=ue=>{ue.key===q&&y(Y,ue.newValue,!0)};return window.addEventListener("storage",U),()=>window.removeEventListener("storage",U)}),he(()=>{const U=()=>{y(X,!0),y(B,!1),Z.refetch()};return window.addEventListener("tandem:open-integration-wizard",U),()=>window.removeEventListener("tandem:open-integration-wizard",U)});let K=F(null),H=F(!1),O=F(!1);function G(){return U5({isTauri:Pt(),openModal:()=>{y(O,!0)},onError:U=>A.push({id:Sc(),type:"general-error",severity:"error",message:U,timestamp:Date.now()})})}const z=SQ();function Q(){d(R)||z.acknowledge(),y(R,!d(R))}function ge(){z.acknowledge(),y(B,!0)}const ye=L(()=>{const U=m.settings.defaultModelId;if(U===null)return null;const ue=m.settings.models.find(_e=>_e.id===U);return ue?ue.displayName:null});let Se=F(null);function ee(){d(B)||y(Se,zF.models,!0),ge()}function de(){z.acknowledge(),y(R,!0)}ED({getActiveTabId:()=>o.activeTabId,getActiveDocumentPath:()=>{const U=o.tabs.find(ue=>ue.id===o.activeTabId);return U&&!el(U.filePath)?U.filePath:null},notify:(U,ue)=>{A.push({id:`launcher-${Date.now()}`,type:"launcher",severity:U,message:ue,timestamp:Date.now()})},openSettings:de,openSettingsModal:ge,toggleSoloMode:()=>v.setTandemMode(v.tandemMode==="solo"?"tandem":"solo"),openFindBar:()=>{y(Ce,"doc"),y(Ge,!0)},openFindBarTabs:()=>{y(Ce,"tabs"),y(Ge,!0)},findNext:()=>{const U=d(oe),ue=U?_l(U.state):void 0;U&&o0(ue)?U.commands.findNext():(y(Ce,"doc"),y(Ge,!0))},findPrev:()=>{const U=d(oe),ue=U?_l(U.state):void 0;U&&o0(ue)?U.commands.findPrev():(y(Ce,"doc"),y(Ge,!0))},closeActiveTab:()=>{const U=o.activeTabId;U&&c(U)},openFileDialog:()=>void G(),toggleLeftPanel:()=>Xe(),toggleRightPanel:()=>Re(),reopenClosedTab:()=>void h(),annotationNext:()=>{const U=Cf(d(k)),ue=p2(U,d(we));if(ue){y(we,ue,!0);const _e=U.find(Ve=>Ve.id===ue);_e&&dt.scrollToAnnotation(_e)}},annotationPrev:()=>{const U=Cf(d(k)),ue=m2(U,d(we));if(ue){y(we,ue,!0);const _e=U.find(Ve=>Ve.id===ue);_e&&dt.scrollToAnnotation(_e)}},annotationAccept:()=>{const U=ht();U&&U.author!=="user"&&dt.handleAccept(U.id)},annotationDismiss:()=>{const U=ht();U&&U.author!=="user"&&dt.handleDismiss(U.id)},selectBlock:()=>{var U;return(U=d(oe))==null?void 0:U.chain().focus().selectParentNode().run()},toggleAuthorship:()=>xe(!m.settings.showAuthorship),toggleFormattingBar:()=>m.updateSettings({formattingBarVisible:!m.settings.formattingBarVisible}),saveAs:async()=>{const U=o.tabs.find(Ve=>Ve.id===o.activeTabId);if(!U||!el(U.filePath)){A.push({id:Sc(),type:"launcher",severity:"info",message:"Save As is only available for scratchpads; this document is already on disk.",timestamp:Date.now()});return}const ue=Math.max(U.filePath.lastIndexOf("/"),U.filePath.lastIndexOf("\\")),_e=U.filePath.slice(ue+1);await sw({activeDocId:o.activeTabId,defaultName:_e,sourceFormat:U.format,notify:(Ve,wt)=>A.push({id:Sc(),type:"launcher",severity:Ve,message:wt,timestamp:Date.now()})})}});function xe(U){m.updateSettings({showAuthorship:U,...m.settings.decorationsMuted?{decorationsMuted:!1}:{}})}let Ee=null;he(()=>{const U=d(oe);if(!U)return;const ue=m.settings,_e=!ue.decorationsMuted&&ue.showAuthorship;if(Ee===_e)return;const Ve=Ee===null;Ee=_e,!Ve&&At(()=>{const wt=U.state.tr.setMeta(ol,{type:"toggle",visible:_e});U.view.dispatch(wt)})});let D=null;he(()=>{const U=d(oe);if(!U)return;const ue=m.settings,_e=ue.decorationsMuted,Ve={comment:!_e&&ue.showComments,highlight:!_e&&ue.showHighlights,note:!_e&&ue.showNotes},wt=`${Ve.comment?1:0}${Ve.highlight?1:0}${Ve.note?1:0}`;if(D===wt)return;const Ht=D===null;D=wt,!Ht&&At(()=>{const Wt=U.state.tr.setMeta(Kc,{type:"toggle-decorations",visible:Ve});U.view.dispatch(Wt)})}),he(()=>(document.body.classList.toggle("tandem-reduce-motion",m.settings.reduceMotion),()=>document.body.classList.remove("tandem-reduce-motion"))),bQ(()=>m.settings.theme),IX(()=>m.settings.accentHue),WX(()=>{var U;return T8(m.settings,(U=d(Fe))==null?void 0:U.format)}),VX(()=>m.settings.density),YX(()=>m.settings.highContrast),NX(()=>m.settings.annotationPatterns),he(()=>{const U=_8[m.settings.textSize];return document.documentElement.style.setProperty("--tandem-editor-font-size",`${U}px`),()=>document.documentElement.style.removeProperty("--tandem-editor-font-size")});let $=F(Qe(m.settings.primaryTab==="chat"?"chat":"annotations"));const ke=L(()=>d($)==="annotations"?0:d(k).filter(hh).length);let we=F(null),Ae=F(!1),pe=F(null),oe=F(null),De=F(null),ze=F(!1),Ge=F(!1),Ce=F("doc"),ie=F(0),ve=F(0),Ye=F(0);const ut=g2("left"),fe=g2("right"),Te=v2({side:"left",initialWidth:ut,getVisible:()=>d(Oe)}),ce=v2({side:"right",initialWidth:fe,getVisible:()=>d(He)}),Oe=L(()=>g.leftVisible),He=L(()=>g.rightVisible);function it(U,ue){queueMicrotask(()=>{const _e=ue?`panel-edge-collapse-${U}`:`peek-strip-${U}`,Ve=document.querySelector(`[data-testid="${_e}"]`);Ve?Ve.focus():console.warn(`[tandem] focusToggleTarget: ${_e} not mounted; focus dropped to body`)})}const Xe=()=>{const U=!g.leftVisible;g.toggleLeft(),it("left",U)},Re=()=>{const U=!g.rightVisible;g.toggleRight(),it("right",U)},ot=AQ(),tt=BQ({getFormat:()=>{var U;return(U=d(Fe))==null?void 0:U.format},getMarginView:()=>m.settings.marginView,getEditorMeasure:()=>m.settings.editorMeasure,getLeftRailVisible:()=>d(Oe),getRightRailVisible:()=>d(He),getViewportWidth:()=>ot.width,getLeftHasPending:()=>d(k).some(U=>U.status==="pending"&&M2(U)),getRightHasPending:()=>d(k).some(U=>U.status==="pending"&&D2(U)),leftRailWidthPx:ut,rightRailWidthPx:fe});function at(){if(d($)==="chat"||!d(oe))return;const{from:U,to:ue}=d(oe).state.selection;if(U===ue)return;const _e=G3(d(oe).state.doc,{from:Mn(U),to:Mn(ue)}),Ve=d(oe).state.doc.textBetween(U,ue,`
240
+ `);y(pe,{..._e,textSnapshot:Ve.length>200?Ve.slice(0,197)+"...":Ve},!0)}const _t={"toggle-help":U=>{const ue=U.target;ue&&(ue.tagName==="INPUT"||ue.tagName==="TEXTAREA"||ue.isContentEditable)||(U.preventDefault(),y(Ae,At(()=>!d(Ae)),!0))},"select-all":U=>{var _e,Ve;const ue=document.activeElement;ue instanceof HTMLInputElement||ue instanceof HTMLTextAreaElement||(_e=ue==null?void 0:ue.closest)!=null&&_e.call(ue,".ProseMirror")||(U.preventDefault(),(Ve=d(oe))==null||Ve.commands.selectAll())},save:U=>{U.preventDefault(),q0(o.activeTabId)},"save-as":U=>{const ue=U.target;if(ue&&(ue.tagName==="INPUT"||ue.tagName==="TEXTAREA"||ue.isContentEditable))return;U.preventDefault();const _e=o.tabs.find(Ht=>Ht.id===o.activeTabId);if(!_e||!el(_e.filePath)){A.push({id:Sc(),type:"launcher",severity:"info",message:"Save As is only available for scratchpads; this document is already on disk.",timestamp:Date.now()});return}const Ve=Math.max(_e.filePath.lastIndexOf("/"),_e.filePath.lastIndexOf("\\")),wt=_e.filePath.slice(Ve+1);sw({activeDocId:o.activeTabId,defaultName:wt,sourceFormat:_e.format,notify:(Ht,Wt)=>A.push({id:Sc(),type:"launcher",severity:Ht,message:Wt,timestamp:Date.now()})})},"settings-modal":U=>{U.preventDefault(),ge()},settings:U=>{U.preventDefault(),de()},"toggle-palette":U=>{U.preventDefault(),y(H,!At(()=>d(H)))},"new-scratchpad":U=>{const ue=U.target;ue&&(ue.tagName==="INPUT"||ue.tagName==="TEXTAREA")||(U.preventDefault(),mh())},"close-tab":U=>{if(Nr(U))return;U.preventDefault();const ue=o.activeTabId;ue&&c(ue)},"open-file":U=>{Nr(U)||(U.preventDefault(),G())},"pick-tab":(U,ue)=>{if(Nr(U))return;const _e=ue==null?void 0:ue.tabIndex;if(_e===void 0)return;const Ve=aQ(o.tabs,_e);Ve&&(U.preventDefault(),o.setActiveTabId(Ve))},"toggle-mode":U=>{Nr(U)||(U.preventDefault(),v.setTandemMode(v.tandemMode==="solo"?"tandem":"solo"))},"reopen-closed-tab":U=>{Nr(U)||(U.preventDefault(),h())},"new-tab-menu":U=>{Nr(U)||(U.preventDefault(),y(Ye,d(Ye)+1))},find:(U,ue)=>{if(U.preventDefault(),ue!=null&&ue.shift){y(Ce,"tabs"),y(Ge,!0);return}d(Oe)?y(ie,d(ie)+1):(y(Ce,"doc"),y(Ge,!0))},"find-nav":(U,ue)=>{if(Nr(U))return;U.preventDefault();const _e=d(oe),Ve=_e?_l(_e.state):void 0;_e&&o0(Ve)?ue!=null&&ue.shift?_e.commands.findPrev():_e.commands.findNext():(y(Ce,"doc"),y(Ge,!0))},"annotation-accept-or-dismiss":(U,ue)=>{if(Nr(U))return;U.preventDefault();const _e=ht();_e&&_e.author!=="user"&&(ue!=null&&ue.shift?dt.handleDismiss(_e.id):dt.handleAccept(_e.id))},"comment-on-selection":U=>{var wt;U.preventDefault();const ue=!!d(oe)&&d(oe).state.selection.from!==d(oe).state.selection.to,_e=((wt=d(Fe))==null?void 0:wt.readOnly)===!0;if(!(d(ze)||d(Ge)||d(H))){if(!ue){A.push({id:`comment-shortcut-no-selection-${Date.now()}`,type:"general-error",severity:"info",message:"Select text to comment",dedupKey:"comment-shortcut-no-selection",timestamp:Date.now()});return}if(_e){A.push({id:`comment-shortcut-readonly-${Date.now()}`,type:"general-error",severity:"info",message:"Document is read-only",dedupKey:"comment-shortcut-readonly",timestamp:Date.now()});return}if(!m.settings.selectionToolbar){A.push({id:`comment-shortcut-toolbar-off-${Date.now()}`,type:"general-error",severity:"info",message:"Enable selection toolbar in Settings to comment via keyboard",dedupKey:"comment-shortcut-toolbar-off",timestamp:Date.now()});return}y(ve,d(ve)+1)}},"toggle-authorship":U=>{U.preventDefault(),xe(!m.settings.showAuthorship)},"toggle-left-panel":U=>{Nr(U)||(U.preventDefault(),Xe())},"toggle-right-panel":U=>{Nr(U)||(U.preventDefault(),Re())},"annotation-next":U=>{if(Nr(U))return;U.preventDefault();const ue=Cf(d(k)),_e=p2(ue,d(we));if(_e){y(we,_e,!0);const Ve=ue.find(wt=>wt.id===_e);Ve&&dt.scrollToAnnotation(Ve)}},"annotation-prev":U=>{if(Nr(U))return;U.preventDefault();const ue=Cf(d(k)),_e=m2(ue,d(we));if(_e){y(we,_e,!0);const Ve=ue.find(wt=>wt.id===_e);Ve&&dt.scrollToAnnotation(Ve)}},"select-block":U=>{Nr(U)||(U.preventDefault(),d(oe)&&d(oe).chain().focus().selectParentNode().run())}};he(()=>{function U(ue){var Ve;const _e=bC(ue,At(()=>d(b)));_e&&((Ve=_t[_e.id])==null||Ve.call(_t,ue,_e.context))}return window.addEventListener("keydown",U),()=>window.removeEventListener("keydown",U)}),he(()=>{function U(ue){if(ue.key!=="Escape"||ue.defaultPrevented||d(we)===null||d(Ge))return;const _e=document.activeElement;_e instanceof HTMLInputElement||_e instanceof HTMLTextAreaElement||!(!_e||_e===document.body||_e.closest('.ProseMirror, [data-testid="editor-root"], [data-testid="annotation-list-scroll-container"]'))||(ue.preventDefault(),y(we,null))}return window.addEventListener("keydown",U),()=>window.removeEventListener("keydown",U)});const Fe=L(()=>o.tabs.find(U=>U.id===o.activeTabId));he(()=>{if(!MD({connected:o.connected,tabCount:o.tabs.length,activeTabId:o.activeTabId}))return;const U=setTimeout(()=>{mh()},TD);return()=>clearTimeout(U)});const dt=n$({getYdoc:()=>{var U;return((U=d(Fe))==null?void 0:U.ydoc)??null},getEditor:()=>d(oe),getAnnotations:()=>d(k),onActiveAnnotationChange:U=>{y(we,U,!0)},getScrollBehavior:()=>m.settings.reduceMotion?"auto":"smooth",getActiveAnnotationId:()=>d(we)});function ht(){return d(we)?d(k).find(U=>U.id===d(we)):dt.getReviewTargets()[0]}const Ft=L(()=>tt.effectivelyOn?d(k).filter(M2):[]),Sn=L(()=>tt.effectivelyOn?d(k).filter(D2):[]),Gr=QX({getEditor:()=>d(oe),getYdoc:()=>{var U;return((U=d(Fe))==null?void 0:U.ydoc)??null},getAnnotations:()=>[...d(Ft),...d(Sn)],getLayerEl:()=>d(De),getEnabled:()=>tt.effectivelyOn}),Fi=PX({getYdoc:()=>{var U;return((U=d(Fe))==null?void 0:U.ydoc)??null}}),on=L(()=>{var _e,Ve;const U=((_e=d(Fe))==null?void 0:_e.ydoc)??null,ue=(Ve=d(Fe))==null?void 0:Ve.id;return{ydoc:U,docId:ue,onEdit:(wt,Ht)=>J3(U,wt,Ht),onReply:(wt,Ht)=>eE(wt,Ht,ue),onRemove:wt=>$3(wt,ue),onSendToClaude:wt=>Q3(U,wt)}}),Wn=xQ(()=>d(k),()=>d(oe),()=>{var U;return(U=d(Fe))==null?void 0:U.fileName});var yi=Oee(),zi=w(yi);T$(zi,{get tandemMode(){return v.tandemMode},get onModeChange(){return v.setTandemMode},get claudeActive(){return o.claudeActive},get theme(){return m.settings.theme},onSetTheme:U=>m.updateSettings({theme:U}),onOpenHelp:()=>y(Ae,!0),onOpenSettings:Q,onOpenSettingsModal:ge,get updateAvailable(){return z.showDot},get defaultModelLabel(){return d(ye)},onOpenModelsSettings:ee,get center(){return n},get settingsBtn(){return d(K)},set settingsBtn(U){y(K,U,!0)}});var Go=x(zi,2);{var kc=U=>{var ue=Aee();S(U,ue)},Wa=U=>{var ue=Dee(),_e=Ie(ue);{var Ve=je=>{var Zt=Tee();S(je,Zt)};W(_e,je=>{o.serverRestarted&&je(Ve)})}var wt=x(_e,2);{var Ht=je=>{dz(je,{get version(){return E.availableVersion},get installing(){return E.installing},onInstall:()=>{E.install()},get onDismiss(){return E.dismiss}})},Wt=L(()=>Pt()&&E.showBanner&&E.availableVersion);W(wt,je=>{d(Wt)&&je(Ht)})}var Bi=x(wt,2);{var Us=je=>{w5(je,{get onDismiss(){return C.dismiss},onRetry:()=>{o.reconnect()}})};W(Bi,je=>{C.showBanner&&je(Us)})}var vt=x(Bi,2);{let je=L(()=>{var ur;return((ur=d(Fe))==null?void 0:ur.ydoc)??null}),Zt=L(()=>d(ze)||d(Ge)||d(H));DX(vt,{get editor(){return d(oe)},get ydoc(){return d(je)},get selectionToolbar(){return m.settings.selectionToolbar},get suppressSelectionToolbar(){return d(Zt)},get requestCommentFocus(){return d(ve)},get showAuthorship(){return m.settings.showAuthorship},get showComments(){return m.settings.showComments},get showHighlights(){return m.settings.showHighlights},get showNotes(){return m.settings.showNotes},get decorationsMuted(){return m.settings.decorationsMuted},onUpdateDecorations:ur=>m.updateSettings(ur),onOpenSettings:Q,get formattingBarVisible(){return m.settings.formattingBarVisible},onToggleFormattingBar:()=>m.updateSettings({formattingBarVisible:!m.settings.formattingBarVisible}),get reduceMotion(){return m.settings.reduceMotion}})}var Xt=x(vt,2);{var Gt=je=>{{let Zt=L(()=>{var ur;return((ur=d(Fe))==null?void 0:ur.ydoc)??null});u$(je,{get editor(){return d(oe)},get ydoc(){return d(Zt)},get showAuthorship(){return m.settings.showAuthorship},get showComments(){return m.settings.showComments},get showHighlights(){return m.settings.showHighlights},get showNotes(){return m.settings.showNotes},get decorationsMuted(){return m.settings.decorationsMuted},onUpdateDecorations:ur=>m.updateSettings(ur),onOpenSettings:Q,onHide:()=>m.updateSettings({formattingBarVisible:!1})})}};W(Xt,je=>{m.settings.formattingBarVisible&&je(Gt)})}var sn=x(Xt,2),Dt=w(sn);let It;var nn=w(Dt),wn=w(nn);xg(wn,{kind:"outline",get focusTrigger(){return d(ie)},get editor(){return d(oe)},visible:!0});var js=x(wn,2);P2(js,()=>"left",()=>Xe);var Zo=x(nn,2);{let je=L(()=>!d(Oe));O2(Zo,{side:"left",get collapsed(){return d(je)},kind:"outline",onActivate:Xe})}var qs=x(Dt,2);{var Ir=je=>{r(je,()=>"left",()=>Zt=>Te.handleResizeStart(Zt),()=>{},()=>Te.width)};W(qs,je=>{d(Oe)&&je(Ir)})}var Hd=x(qs,2);i(Hd);var Vd=x(Hd,2);{var er=je=>{r(je,()=>"right",()=>Zt=>ce.handleResizeStart(Zt),()=>"panel-resize-handle",()=>ce.width)};W(Vd,je=>{d(He)&&je(er)})}var Zr=x(Vd,2);let Yo;var _c=w(Zr),iy=w(_c);P2(iy,()=>"right",()=>Re);var oy=x(iy,2),t4=w(oy),Ud=w(t4),n4=x(w(Ud));{var r4=je=>{var Zt=Mee(),ur=w(Zt);j(()=>J(ur,d(ke)>9?"9+":d(ke))),S(je,Zt)};W(n4,je=>{d($)!=="annotations"&&d(ke)>0&&je(r4)})}var Lm=x(Ud,2),sy=x(oy,2);{let je=L(()=>d($)==="chat");xg(sy,{kind:"chat",get ctrlYdoc(){return o.bootstrapYdoc},get editor(){return d(oe)},get activeDocId(){return o.activeTabId},get openDocs(){return d(I)},get claudeActive(){return o.claudeActive},get claudeStatus(){return o.claudeStatus},get capturedAnchor(){return d(pe)},onCapturedAnchorChange:Zt=>y(pe,Zt,!0),get reduceMotion(){return m.settings.reduceMotion},get visible(){return d(je)}})}var i4=x(sy,2);{let je=L(()=>{var Rr;return((Rr=d(Fe))==null?void 0:Rr.ydoc)??null}),Zt=L(()=>{var Rr;return(Rr=d(Fe))==null?void 0:Rr.format}),ur=L(()=>{var Rr;return(Rr=d(Fe))==null?void 0:Rr.id}),h4=L(()=>{var Rr;return((Rr=o.claudeWorking)==null?void 0:Rr.annotationId)??null}),p4=L(()=>d($)==="annotations");xg(i4,{kind:"side",get annotations(){return d(k)},get editor(){return d(oe)},get ydoc(){return d(je)},get activeDocFormat(){return d(Zt)},get documentId(){return d(ur)},get activeAnnotationId(){return d(we)},onActiveAnnotationChange:Rr=>y(we,Rr,!0),get reduceMotion(){return m.settings.reduceMotion},get storeReadOnly(){return o.storeReadOnly},get claudeWorkingAnnotationId(){return d(h4)},get review(){return dt},get visible(){return d(p4)}})}var o4=x(_c,2);{let je=L(()=>!d(He));O2(o4,{side:"right",get collapsed(){return d(je)},kind:"annotations",get annotations(){return d(k)},onActivate:Re})}var ay=x(sn,2);{let je=L(()=>{var Zt;return((Zt=o.claudeWorking)==null?void 0:Zt.tool)??null});B$(ay,{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 claudeWorkingTool(){return d(je)},get readOnly(){return o.readOnly},get saving(){return AD.saving},get editor(){return d(oe)}})}var ly=x(ay,2);iz(ly,{get open(){return d(R)},onClose:()=>y(R,!1),get settings(){return m.settings},get onUpdate(){return m.updateSettings},get returnFocusEl(){return d(K)},get anchorEl(){return d(K)},get connected(){return o.connected},get reconnectAttempts(){return o.reconnectAttempts}});var cy=x(ly,2);jF(cy,{get open(){return d(B)},onClose:()=>{y(B,!1),y(Se,null)},get settings(){return m.settings},get onUpdate(){return m.updateSettings},get returnFocusEl(){return d(K)},get triggerEl(){return d(K)},get connected(){return o.connected},get reconnectAttempts(){return o.reconnectAttempts},get initialTabId(){return d(Se)},notify:(je,Zt)=>A.push({id:`settings-${Date.now()}`,type:"launcher",severity:je,message:Zt,timestamp:Date.now()})});var uy=x(cy,2);H8(uy,{get open(){return d(Ae)},onClose:()=>y(Ae,!1),get effectiveShortcutLabels(){return d(_)}});var dy=x(uy,2);{var s4=je=>{P8(je,{onComplete:()=>y(le,!0)})},a4=je=>{dI(je,{open:!0,onClose:me})};W(dy,je=>{d(se)?je(s4):d(te)&&je(a4,1)})}var fy=x(dy,2);{var l4=je=>{i8(je,{onClose:()=>y(O,!1)})};W(fy,je=>{d(O)&&je(l4)})}var hy=x(fy,2);b5(hy,{get open(){return d(H)},onClose:()=>y(H,!1),get editor(){return d(oe)},get annotations(){return d(k)},onFocusAnnotation:je=>{y(we,je,!0)}});var py=x(hy,2);cz(py,{get toasts(){return A.toasts},get onDismiss(){return A.dismiss}});var my=x(py,2);hO(my,{get items(){return A.activity},get open(){return d(M)},onToggle:()=>y(M,!d(M)),get onDismiss(){return A.dismissActivity},get onClear(){return A.clearActivity},onAction:je=>{const Zt=xC(je);Zt&&(o.tabs.some(ur=>ur.id===Zt.documentId)?q0(Zt.documentId):A.push({id:`retry-unavailable-${Zt.documentId}`,type:"general-error",severity:"warning",message:"Reopen the document to retry the save.",dedupKey:`retry-unavailable:${Zt.documentId}`,timestamp:Date.now()}))}});var gy=x(my,2);{var c4=je=>{O5(je,{})},u4=L(()=>Pt());W(gy,je=>{d(u4)&&je(c4)})}var d4=x(gy,2);{var f4=je=>{FI(je,{get currentStep(){return Wn.currentStep},get onNext(){return Wn.nextStep},get onDismiss(){return Wn.dismissTutorial},get coworkStatus(){return Wn.coworkStatus}})};W(d4,je=>{Wn.tutorialActive&&je(f4)})}j(()=>{It=yt(Dt,1,"rail-shell rail-shell-left svelte-y74n0s",null,It,{collapsed:!d(Oe)}),Me(Dt,d(Oe)?`width: ${Te.width}px;`:""),Me(nn,`width: ${Te.width}px;`),Yo=yt(Zr,1,"rail-shell rail-shell-right svelte-y74n0s",null,Yo,{collapsed:!d(He)}),Me(Zr,d(He)?`width: ${ce.width}px;`:""),Me(_c,`width: ${ce.width}px;`),yt(Ud,1,"rail-tab"+(d($)==="annotations"?" on":""),"svelte-y74n0s"),yt(Lm,1,"rail-tab"+(d($)==="chat"?" on":""),"svelte-y74n0s")}),hn("scroll",sn,je=>{je.currentTarget.scrollLeft=0}),P("click",Ud,()=>{y($,"annotations")}),P("mousedown",Lm,at),P("click",Lm,()=>{y($,"chat")}),S(U,ue)};W(Go,U=>{o.ready?U(Wa,-1):U(kc)})}j(()=>V(yi,"data-tandem-mode",v.tandemMode)),S(t,yi),Ke()}et(["mousedown","keydown","keyup","click"]);const L2=3,Ree="error-boundary-recover-btn",Nee="error-boundary-reload-btn";function Pee(t,e){We(e,!0),he(()=>{e.onSuccess()}),Ke()}var Lee=T('<button class="btn btn-primary svelte-1bcl6yi">Try to recover</button>'),Fee=T('<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>'),zee=T("<!> <!>",1);function Bee(t,e){let n=F(0),r=F(0);var i=Mt(),o=Ie(i);l_(o,{onerror:()=>{y(r,d(r)+1)},failed:(a,l=Tn,c=Tn)=>{var u=Mt(),f=Ie(u);yu(f,()=>d(r),h=>{var p=Fee(),m=x(w(p),2),v=w(m),g=x(m,2),b=w(g),_=x(g,2);{var k=E=>{var I=Lee();j(()=>V(I,"data-testid",Ree)),P("click",I,()=>{y(n,d(n)+1),c()()}),S(E,I)};W(_,E=>{d(n)<L2&&E(k)})}var C=x(_,2);j(E=>{J(v,d(n)>=L2?"Recovery attempts exhausted. Reload the page to continue.":"The editor encountered an unexpected error."),J(b,E),V(C,"data-testid",Nee)},[()=>l()instanceof Error?l().message:String(l())]),P("click",C,()=>window.location.reload()),S(h,p)}),S(a,u)}},a=>{var l=zee(),c=Ie(l);wd(c,()=>e.children);var u=x(c,2);Pee(u,{onSuccess:()=>{y(n,0)}}),S(a,l)}),S(t,i)}et(["click"]);function Hee(t){Bee(t,{children:(e,n)=>{Iee(e,{})}})}H6(Hee,{target:document.getElementById("root")});export{nt as A,Me as B,jee as C,Yee as D,Gee as E,et as F,Qee as G,Zee as H,K_ as T,w as a,S as b,aS as c,Ke as d,F as e,Kee as f,d as g,V as h,W as i,Ie as j,yt as k,Bn as l,Jee as m,J as n,gr as o,We as p,P as q,y as r,x as s,j as t,L as u,T as v,Ta as w,nS as x,sS as y,Xee as z};