tandem-editor 0.12.0 → 0.13.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +2 -2
- package/.claude-plugin/plugin.json +1 -1
- package/CHANGELOG.md +121 -9
- package/README.md +142 -237
- package/dist/channel/index.js +158 -69
- package/dist/channel/index.js.map +1 -1
- package/dist/cli/index.js +656 -148
- package/dist/cli/index.js.map +1 -1
- package/dist/client/assets/CoworkSettings-BEvEpByR.js +3 -0
- package/dist/client/assets/CoworkSettings-C-1BnhBH.css +1 -0
- package/dist/client/assets/index-CXkPU0mo.css +1 -0
- package/dist/client/assets/index-D6kdw28e.js +238 -0
- package/dist/client/assets/index-Dm_QtxGQ.js +1 -0
- package/dist/client/assets/webview-KiZyy_pC.js +1 -0
- package/dist/client/fonts/OFL-Hanuman.txt +93 -0
- package/dist/client/fonts/OFL-InterTight.txt +93 -0
- package/dist/client/fonts/OFL-JetBrainsMono.txt +93 -0
- package/dist/client/fonts/OFL-SNPro.txt +93 -0
- package/dist/client/fonts/OFL-Sono.txt +93 -0
- package/dist/client/fonts/OFL-SourceSerif4.txt +93 -0
- package/dist/client/fonts/hanuman-latin.woff2 +0 -0
- package/dist/client/fonts/jetbrains-mono-latin.woff2 +0 -0
- package/dist/client/fonts/sn-pro-latin.woff2 +0 -0
- package/dist/client/fonts/sono-latin.woff2 +0 -0
- package/dist/client/fonts/source-serif-4-latin.woff2 +0 -0
- package/dist/client/index.html +341 -17
- package/dist/client/logo.png +0 -0
- package/dist/monitor/index.js +235 -161
- package/dist/monitor/index.js.map +1 -1
- package/dist/server/index.js +25323 -21754
- package/dist/server/index.js.map +1 -1
- package/package.json +11 -3
- package/sample/welcome.md +6 -6
- package/skills/tandem/SKILL.md +15 -0
- package/dist/client/assets/CoworkSettings-C0cS9R7L.js +0 -3
- package/dist/client/assets/index-Dn5JwXA3.css +0 -1
- package/dist/client/assets/index-n-vFW5By.js +0 -299
- package/dist/client/assets/webview-Bhf-n_os.js +0 -1
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-Dm_QtxGQ.js","assets/core-DhEqZVGG.js","assets/CoworkSettings-BEvEpByR.js","assets/CoworkSettings-C-1BnhBH.css","assets/webview-KiZyy_pC.js","assets/window-DePn7tLG.js","assets/event-CNdo2oXa.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
var CT=Object.defineProperty;var j1=t=>{throw TypeError(t)};var ST=(t,e,n)=>e in t?CT(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var wn=(t,e,n)=>ST(t,typeof e!="symbol"?e+"":e,n),pm=(t,e,n)=>e.has(t)||j1("Cannot "+n);var ie=(t,e,n)=>(pm(t,e,"read from private field"),n?n.call(t):e.get(t)),tt=(t,e,n)=>e.has(t)?j1("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n),rt=(t,e,n,r)=>(pm(t,e,"write to private field"),r?r.call(t,n):e.set(t,n),n),Et=(t,e,n)=>(pm(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 cx=!1;var Ov=Array.isArray,ET=Array.prototype.indexOf,kl=Array.prototype.includes,mp=Array.from,AT=Object.defineProperty,cs=Object.getOwnPropertyDescriptor,dx=Object.getOwnPropertyDescriptors,TT=Object.prototype,MT=Array.prototype,Iv=Object.getPrototypeOf,q1=Object.isExtensible;function au(t){return typeof t=="function"}const yr=()=>{};function DT(t){return typeof(t==null?void 0:t.then)=="function"}function OT(t){for(var e=0;e<t.length;e++)t[e]()}function fx(){var t,e,n=new Promise((r,i)=>{t=r,e=i});return{promise:n,resolve:t,reject:e}}function Sd(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 jn=2,xl=4,gp=8,hx=1<<24,vi=16,wi=32,To=64,Hg=128,ti=512,yn=1024,Sn=2048,Ji=4096,sr=8192,ni=16384,Ea=32768,Vg=1<<25,bs=65536,zf=1<<17,IT=1<<18,Aa=1<<19,RT=1<<20,Bi=1<<25,da=65536,Bf=1<<21,Xa=1<<22,ds=1<<23,qi=Symbol("$state"),px=Symbol("legacy props"),NT=Symbol(""),uf=Symbol("attributes"),Ug=Symbol("class"),jg=Symbol("style"),wu=Symbol("text"),cf=Symbol("form reset"),vp=new class extends Error{constructor(){super(...arguments);wn(this,"name","StaleReactionError");wn(this,"message","The reaction that called `getAbortSignal()` was re-run or destroyed")}};var ax;const PT=!!((ax=globalThis.document)!=null&&ax.contentType)&&globalThis.document.contentType.includes("xml");function mx(t){throw new Error("https://svelte.dev/e/lifecycle_outside_component")}function LT(){throw new Error("https://svelte.dev/e/async_derived_orphan")}function FT(t,e,n){throw new Error("https://svelte.dev/e/each_key_duplicate")}function zT(t){throw new Error("https://svelte.dev/e/effect_in_teardown")}function BT(){throw new Error("https://svelte.dev/e/effect_in_unowned_derived")}function HT(t){throw new Error("https://svelte.dev/e/effect_orphan")}function VT(){throw new Error("https://svelte.dev/e/effect_update_depth_exceeded")}function UT(t){throw new Error("https://svelte.dev/e/props_invalid_value")}function jT(){throw new Error("https://svelte.dev/e/state_descriptors_fixed")}function qT(){throw new Error("https://svelte.dev/e/state_prototype_fixed")}function WT(){throw new Error("https://svelte.dev/e/state_unsafe_mutation")}function KT(){throw new Error("https://svelte.dev/e/svelte_boundary_reset_onerror")}const GT=1,ZT=2,gx=4,JT=8,YT=16,XT=1,QT=2,$T=4,e4=8,t4=16,vx=1,n4=2,vn=Symbol(),bx="http://www.w3.org/1999/xhtml",r4="http://www.w3.org/2000/svg",i4="http://www.w3.org/1998/Math/MathML";function o4(){console.warn("https://svelte.dev/e/derived_inert")}function s4(){console.warn("https://svelte.dev/e/select_multiple_invalid_value")}function a4(){console.warn("https://svelte.dev/e/svelte_boundary_reset_noop")}function yx(t){return t===this.v}function wx(t,e){return t!=t?e==e:t!==e||t!==null&&typeof t=="object"||typeof t=="function"}function kx(t){return!wx(t,this.v)}let Gl=!1,l4=!1;function u4(){Gl=!0}let sn=null;function _l(t){sn=t}function ze(t,e=!1,n){sn={p:sn,i:!1,c:null,e:null,s:t,x:null,r:vt,l:Gl&&!e?{s:null,u:null,$:[]}:null}}function Be(t){var e=sn,n=e.e;if(n!==null){e.e=null;for(var r of n)qx(r)}return t!==void 0&&(e.x=t),e.i=!0,sn=e.p,t??{}}function Ta(){return!Gl||sn!==null&&sn.l===null}let Hs=[];function xx(){var t=Hs;Hs=[],OT(t)}function Wi(t){if(Hs.length===0&&!Qa){var e=Hs;queueMicrotask(()=>{e===Hs&&xx()})}Hs.push(t)}function c4(){for(;Hs.length>0;)xx()}function _x(t){var e=vt;if(e===null)return Ct.f|=ds,t;if((e.f&Ea)===0&&(e.f&xl)===0)throw t;rs(t,e)}function rs(t,e){for(;e!==null;){if((e.f&Hg)!==0){if((e.f&Ea)===0)throw t;try{e.b.error(t);return}catch(n){t=n}}e=e.parent}throw t}const d4=-7169;function nn(t,e){t.f=t.f&d4|e}function Rv(t){(t.f&ti)!==0||t.deps===null?nn(t,yn):nn(t,Ji)}function Cx(t){if(t!==null)for(const e of t)(e.f&jn)===0||(e.f&da)===0||(e.f^=da,Cx(e.deps))}function Sx(t,e,n){(t.f&Sn)!==0?e.add(t):(t.f&Ji)!==0&&n.add(t),Cx(t.deps),nn(t,yn)}let Ed=!1;function f4(t){var e=Ed;try{return Ed=!1,[t(),Ed]}finally{Ed=e}}let mm=null,Na=null,Xe=null,Ou=null,Ln=null,qg=null,Qa=!1,gm=!1,Ga=null,df=null;var W1=0;let h4=1;var hl,$o,Js,pl,ml,Ys,gl,bo,Wc,Or,Kc,es,Li,Fi,vl,bl,Ot,Wg,ku,Kg,Ex,Ax,ff,p4,Gg,Ha;const up=class up{constructor(){tt(this,Ot);wn(this,"id",h4++);tt(this,hl,!1);wn(this,"linked",!0);tt(this,$o,null);tt(this,Js,null);wn(this,"async_deriveds",new Map);wn(this,"current",new Map);wn(this,"previous",new Map);wn(this,"unblocked",new Set);tt(this,pl,new Set);tt(this,ml,new Set);tt(this,Ys,new Set);tt(this,gl,0);tt(this,bo,new Map);tt(this,Wc,null);tt(this,Or,[]);tt(this,Kc,[]);tt(this,es,new Set);tt(this,Li,new Set);tt(this,Fi,new Map);tt(this,vl,new Set);wn(this,"is_fork",!1);tt(this,bl,!1)}skip_effect(e){ie(this,Fi).has(e)||ie(this,Fi).set(e,{d:[],m:[]}),ie(this,vl).delete(e)}unskip_effect(e,n=r=>this.schedule(r)){var r=ie(this,Fi).get(e);if(r){ie(this,Fi).delete(e);for(var i of r.d)nn(i,Sn),n(i);for(i of r.m)nn(i,Ji),n(i)}ie(this,vl).add(e)}capture(e,n,r=!1){e.v!==vn&&!this.previous.has(e)&&this.previous.set(e,e.v),(e.f&ds)===0&&(this.current.set(e,[n,r]),Ln==null||Ln.set(e,n)),this.is_fork||(e.v=n)}activate(){Xe=this}deactivate(){Xe=null,Ln=null}flush(){try{gm=!0,Xe=this,Et(this,Ot,ku).call(this)}finally{W1=0,qg=null,Ga=null,df=null,gm=!1,Xe=null,Ln=null,ea.clear()}}discard(){for(const e of ie(this,ml))e(this);ie(this,ml).clear(),ie(this,Ys).clear(),Et(this,Ot,Ha).call(this)}register_created_effect(e){ie(this,Kc).push(e)}increment(e,n){if(rt(this,gl,ie(this,gl)+1),e){let r=ie(this,bo).get(n)??0;ie(this,bo).set(n,r+1)}}decrement(e,n){if(rt(this,gl,ie(this,gl)-1),e){let r=ie(this,bo).get(n)??0;r===1?ie(this,bo).delete(n):ie(this,bo).set(n,r-1)}ie(this,bl)||(rt(this,bl,!0),Wi(()=>{rt(this,bl,!1),this.linked&&this.flush()}))}transfer_effects(e,n){for(const r of e)ie(this,es).add(r);for(const r of n)ie(this,Li).add(r);e.clear(),n.clear()}oncommit(e){ie(this,pl).add(e)}ondiscard(e){ie(this,ml).add(e)}on_fork_commit(e){ie(this,Ys).add(e)}run_fork_commit_callbacks(){for(const e of ie(this,Ys))e(this);ie(this,Ys).clear()}settled(){return(ie(this,Wc)??rt(this,Wc,fx())).promise}static ensure(){var e;if(Xe===null){const n=Xe=new up;Et(e=n,Ot,Gg).call(e),!gm&&!Qa&&Wi(()=>{ie(n,hl)||n.flush()})}return Xe}apply(){{Ln=null;return}}schedule(e){var i;if(qg=e,(i=e.b)!=null&&i.is_pending&&(e.f&(xl|gp|hx))!==0&&(e.f&Ea)===0){e.b.defer_effect(e);return}for(var n=e;n.parent!==null;){n=n.parent;var r=n.f;if(Ga!==null&&n===vt&&(Ct===null||(Ct.f&jn)===0))return;if((r&(To|wi))!==0){if((r&yn)===0)return;n.f^=yn}}ie(this,Or).push(n)}};hl=new WeakMap,$o=new WeakMap,Js=new WeakMap,pl=new WeakMap,ml=new WeakMap,Ys=new WeakMap,gl=new WeakMap,bo=new WeakMap,Wc=new WeakMap,Or=new WeakMap,Kc=new WeakMap,es=new WeakMap,Li=new WeakMap,Fi=new WeakMap,vl=new WeakMap,bl=new WeakMap,Ot=new WeakSet,Wg=function(){if(this.is_fork)return!0;for(const r of ie(this,bo).keys()){for(var e=r,n=!1;e.parent!==null;){if(ie(this,Fi).has(e)){n=!0;break}e=e.parent}if(!n)return!0}return!1},ku=function(){var l,u,c,f;if(rt(this,hl,!0),W1++>1e3&&(Et(this,Ot,Ha).call(this),m4()),!Et(this,Ot,Wg).call(this)){for(const h of ie(this,es))ie(this,Li).delete(h),nn(h,Sn),this.schedule(h);for(const h of ie(this,Li))nn(h,Ji),this.schedule(h)}const e=ie(this,Or);rt(this,Or,[]),this.apply();var n=Ga=[],r=[],i=df=[];for(const h of e)try{Et(this,Ot,Kg).call(this,h,n,r)}catch(p){throw Ox(h),p}if(Xe=null,i.length>0){var o=up.ensure();for(const h of i)o.schedule(h)}if(Ga=null,df=null,Et(this,Ot,Wg).call(this)){Et(this,Ot,ff).call(this,r),Et(this,Ot,ff).call(this,n);for(const[h,p]of ie(this,Fi))Dx(h,p);i.length>0&&Et(l=Xe,Ot,ku).call(l);return}const s=Et(this,Ot,Ex).call(this);if(s){Et(u=s,Ot,Ax).call(u,this);return}ie(this,es).clear(),ie(this,Li).clear();for(const h of ie(this,pl))h(this);ie(this,pl).clear(),Ou=this,K1(r),K1(n),Ou=null,(c=ie(this,Wc))==null||c.resolve();var a=Xe;if(this.linked&&ie(this,gl)===0&&Et(this,Ot,Ha).call(this),ie(this,Or).length>0){a===null&&(a=this,Et(this,Ot,Gg).call(this));const h=a;ie(h,Or).push(...ie(this,Or).filter(p=>!ie(h,Or).includes(p)))}a!==null&&Et(f=a,Ot,ku).call(f)},Kg=function(e,n,r){e.f^=yn;for(var i=e.first;i!==null;){var o=i.f,s=(o&(wi|To))!==0,a=s&&(o&yn)!==0,l=a||(o&sr)!==0||ie(this,Fi).has(i);if(!l&&i.fn!==null){s?i.f^=yn:(o&xl)!==0?n.push(i):td(i)&&((o&vi)!==0&&ie(this,Li).add(i),Cl(i));var u=i.first;if(u!==null){i=u;continue}}for(;i!==null;){var c=i.next;if(c!==null){i=c;break}i=i.parent}}},Ex=function(){for(var e=ie(this,$o);e!==null;){if(!e.is_fork){for(const[n,[,r]]of this.current)if(e.current.has(n)&&!r)return e}e=ie(e,$o)}return null},Ax=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&jn)!==0)n(l);else{var a=l;s&(Xa|vi)&&!this.async_deriveds.has(a)&&(ie(this,Li).delete(a),nn(a,Sn),this.schedule(a))}}};for(const i of this.current.keys())n(i);this.oncommit(()=>e.discard()),Et(r=e,Ot,Ha).call(r),Xe=this,Et(this,Ot,ku).call(this)},ff=function(e){for(var n=0;n<e.length;n+=1)Sx(e[n],ie(this,es),ie(this,Li))},p4=function(){var c;Et(this,Ot,Ha).call(this);for(let f=mm;f!==null;f=ie(f,Js)){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(ie(f,hl)){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 ie(this,vl))f.unskip_effect(h,p=>{var m;(p.f&(vi|Xa))!==0?f.schedule(p):Et(m=f,Ot,ff).call(m,[p])});f.activate();var o=new Set,s=new Map;for(var a of n)Mx(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 ie(this,Kc))(h.f&(ni|sr|zf))===0&&Nv(h,l,s)&&((h.f&(Xa|vi))!==0?(nn(h,Sn),f.schedule(h)):ie(f,es).add(h));if(ie(f,Or).length>0){f.apply();for(var u of ie(f,Or))Et(c=f,Ot,Kg).call(c,u,[],[]);rt(f,Or,[])}f.deactivate()}}}},Gg=function(){Na===null?mm=Na=this:(rt(Na,Js,this),rt(this,$o,Na)),Na=this},Ha=function(){var e=ie(this,$o),n=ie(this,Js);e===null?mm=n:rt(e,Js,n),n===null?Na=e:rt(n,$o,e),this.linked=!1};let Mo=up;function Tx(t){var e=Qa;Qa=!0;try{for(var n;;){if(c4(),Xe===null)return n;Xe.flush()}}finally{Qa=e}}function m4(){try{VT()}catch(t){rs(t,qg)}}let pi=null;function K1(t){var e=t.length;if(e!==0){for(var n=0;n<e;){var r=t[n++];if((r.f&(ni|sr))===0&&td(r)&&(pi=new Set,Cl(r),r.deps===null&&r.first===null&&r.nodes===null&&r.teardown===null&&r.ac===null&&Zx(r),(pi==null?void 0:pi.size)>0)){ea.clear();for(const i of pi){if((i.f&(ni|sr))!==0)continue;const o=[i];let s=i.parent;for(;s!==null;)pi.has(s)&&(pi.delete(s),o.push(s)),s=s.parent;for(let a=o.length-1;a>=0;a--){const l=o[a];(l.f&(ni|sr))===0&&Cl(l)}}pi.clear()}}pi=null}}function Mx(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&jn)!==0?Mx(i,e,n,r):(o&(Xa|vi))!==0&&(o&Sn)===0&&Nv(i,e,r)&&(nn(i,Sn),Pv(i))}}function Nv(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(kl.call(e,i))return!0;if((i.f&jn)!==0&&Nv(i,e,n))return n.set(i,!0),!0}return n.set(t,!1),!1}function Pv(t){Xe.schedule(t)}function Dx(t,e){if(!((t.f&wi)!==0&&(t.f&yn)!==0)){(t.f&Sn)!==0?e.d.push(t):(t.f&Ji)!==0&&e.m.push(t),nn(t,yn);for(var n=t.first;n!==null;)Dx(n,e),n=n.next}}function Ox(t){nn(t,yn);for(var e=t.first;e!==null;)Ox(e),e=e.next}function g4(t){let e=0,n=Do(0),r;return()=>{Bv()&&(d(n),ed(()=>(e===0&&(r=St(()=>t(()=>Iu(n)))),e+=1,()=>{Wi(()=>{e-=1,e===0&&(r==null||r(),r=void 0,Iu(n))})})))}}var v4=bs|Aa;function Ix(t,e,n,r){new b4(t,e,n,r)}var Kr,Dv,Gr,Xs,vr,Zr,ir,Ir,yo,Qs,ts,yl,Gc,Zc,wo,cp,an,y4,w4,k4,Zg,hf,pf,Jg,Yg;class b4{constructor(e,n,r,i){tt(this,an);wn(this,"parent");wn(this,"is_pending",!1);wn(this,"transform_error");tt(this,Kr);tt(this,Dv,null);tt(this,Gr);tt(this,Xs);tt(this,vr);tt(this,Zr,null);tt(this,ir,null);tt(this,Ir,null);tt(this,yo,null);tt(this,Qs,0);tt(this,ts,0);tt(this,yl,!1);tt(this,Gc,new Set);tt(this,Zc,new Set);tt(this,wo,null);tt(this,cp,g4(()=>(rt(this,wo,Do(ie(this,Qs))),()=>{rt(this,wo,null)})));var o;rt(this,Kr,e),rt(this,Gr,n),rt(this,Xs,s=>{var a=vt;a.b=this,a.f|=Hg,r(s)}),this.parent=vt.b,this.transform_error=i??((o=this.parent)==null?void 0:o.transform_error)??(s=>s),rt(this,vr,Ma(()=>{Et(this,an,Zg).call(this)},v4))}defer_effect(e){Sx(e,ie(this,Gc),ie(this,Zc))}is_rendered(){return!this.is_pending&&(!this.parent||this.parent.is_rendered())}has_pending_snippet(){return!!ie(this,Gr).pending}update_pending_count(e,n){Et(this,an,Jg).call(this,e,n),rt(this,Qs,ie(this,Qs)+e),!(!ie(this,wo)||ie(this,yl))&&(rt(this,yl,!0),Wi(()=>{rt(this,yl,!1),ie(this,wo)&&xo(ie(this,wo),ie(this,Qs))}))}get_effect_pending(){return ie(this,cp).call(this),d(ie(this,wo))}error(e){if(!ie(this,Gr).onerror&&!ie(this,Gr).failed)throw e;Xe!=null&&Xe.is_fork?(ie(this,Zr)&&Xe.skip_effect(ie(this,Zr)),ie(this,ir)&&Xe.skip_effect(ie(this,ir)),ie(this,Ir)&&Xe.skip_effect(ie(this,Ir)),Xe.on_fork_commit(()=>{Et(this,an,Yg).call(this,e)})):Et(this,an,Yg).call(this,e)}}Kr=new WeakMap,Dv=new WeakMap,Gr=new WeakMap,Xs=new WeakMap,vr=new WeakMap,Zr=new WeakMap,ir=new WeakMap,Ir=new WeakMap,yo=new WeakMap,Qs=new WeakMap,ts=new WeakMap,yl=new WeakMap,Gc=new WeakMap,Zc=new WeakMap,wo=new WeakMap,cp=new WeakMap,an=new WeakSet,y4=function(){try{rt(this,Zr,Jr(()=>ie(this,Xs).call(this,ie(this,Kr))))}catch(e){this.error(e)}},w4=function(e){const n=ie(this,Gr).failed;n&&rt(this,Ir,Jr(()=>{n(ie(this,Kr),()=>e,()=>()=>{})}))},k4=function(){const e=ie(this,Gr).pending;e&&(this.is_pending=!0,rt(this,ir,Jr(()=>e(ie(this,Kr)))),Wi(()=>{var n=rt(this,yo,document.createDocumentFragment()),r=_o();n.append(r),rt(this,Zr,Et(this,an,pf).call(this,()=>Jr(()=>ie(this,Xs).call(this,r)))),ie(this,ts)===0&&(ie(this,Kr).before(n),rt(this,yo,null),ta(ie(this,ir),()=>{rt(this,ir,null)}),Et(this,an,hf).call(this,Xe))}))},Zg=function(){try{if(this.is_pending=this.has_pending_snippet(),rt(this,ts,0),rt(this,Qs,0),rt(this,Zr,Jr(()=>{ie(this,Xs).call(this,ie(this,Kr))})),ie(this,ts)>0){var e=rt(this,yo,document.createDocumentFragment());jv(ie(this,Zr),e);const n=ie(this,Gr).pending;rt(this,ir,Jr(()=>n(ie(this,Kr))))}else Et(this,an,hf).call(this,Xe)}catch(n){this.error(n)}},hf=function(e){this.is_pending=!1,e.transfer_effects(ie(this,Gc),ie(this,Zc))},pf=function(e){var n=vt,r=Ct,i=sn;Yi(ie(this,vr)),li(ie(this,vr)),_l(ie(this,vr).ctx);try{return Mo.ensure(),e()}catch(o){return _x(o),null}finally{Yi(n),li(r),_l(i)}},Jg=function(e,n){var r;if(!this.has_pending_snippet()){this.parent&&Et(r=this.parent,an,Jg).call(r,e,n);return}rt(this,ts,ie(this,ts)+e),ie(this,ts)===0&&(Et(this,an,hf).call(this,n),ie(this,ir)&&ta(ie(this,ir),()=>{rt(this,ir,null)}),ie(this,yo)&&(ie(this,Kr).before(ie(this,yo)),rt(this,yo,null)))},Yg=function(e){ie(this,Zr)&&(ar(ie(this,Zr)),rt(this,Zr,null)),ie(this,ir)&&(ar(ie(this,ir)),rt(this,ir,null)),ie(this,Ir)&&(ar(ie(this,Ir)),rt(this,Ir,null));var n=ie(this,Gr).onerror;let r=ie(this,Gr).failed;var i=!1,o=!1;const s=()=>{if(i){a4();return}i=!0,o&&KT(),ie(this,Ir)!==null&&ta(ie(this,Ir),()=>{rt(this,Ir,null)}),Et(this,an,pf).call(this,()=>{Et(this,an,Zg).call(this)})},a=l=>{try{o=!0,n==null||n(l,s),o=!1}catch(u){rs(u,ie(this,vr)&&ie(this,vr).parent)}r&&rt(this,Ir,Et(this,an,pf).call(this,()=>{try{return Jr(()=>{var u=vt;u.b=this,u.f|=Hg,r(ie(this,Kr),()=>l,()=>s)})}catch(u){return rs(u,ie(this,vr).parent),null}}))};Wi(()=>{var l;try{l=this.transform_error(e)}catch(u){rs(u,ie(this,vr)&&ie(this,vr).parent);return}l!==null&&typeof l=="object"&&typeof l.then=="function"?l.then(a,u=>rs(u,ie(this,vr)&&ie(this,vr).parent)):a(l)})};function x4(t,e,n,r){const i=Ta()?ec:Lv;var o=t.filter(h=>!h.settled);if(n.length===0&&o.length===0){r(e.map(i));return}var s=vt,a=Rx(),l=o.length===1?o[0].promise:o.length>1?Promise.all(o.map(h=>h.promise)):null;function u(h){if((s.f&ni)===0){a();try{r(h)}catch(p){rs(p,s)}$u()}}var c=Nx();if(n.length===0){l.then(()=>u(e.map(i))).finally(c);return}function f(){Promise.all(n.map(h=>_4(h))).then(h=>u([...e.map(i),...h])).catch(h=>rs(h,s)).finally(c)}l?l.then(()=>{a(),f(),$u()}):f()}function Rx(){var t=vt,e=Ct,n=sn,r=Xe;return function(o=!0){Yi(t),li(e),_l(n),o&&(t.f&ni)===0&&(r==null||r.activate(),r==null||r.apply())}}function $u(t=!0){Yi(null),li(null),_l(null),t&&(Xe==null||Xe.deactivate())}function Nx(){var t=vt,e=t.b,n=Xe,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 ec(t){var e=jn|Sn;return vt!==null&&(vt.f|=Aa),{ctx:sn,deps:null,effects:null,equals:yx,f:e,fn:t,reactions:null,rv:0,v:vn,wv:0,parent:vt,ac:null}}const Ad=Symbol("obsolete");function _4(t,e,n){let r=vt;r===null&<();var i=void 0,o=Do(vn),s=!Ct,a=new Set;return P4(()=>{var p;var l=vt,u=fx();i=u.promise;try{Promise.resolve(t()).then(u.resolve,m=>{m!==vp&&u.reject(m)}).finally($u)}catch(m){u.reject(m),$u()}var c=Xe;if(s){if((l.f&Ea)!==0)var f=Nx();if(r.b.is_rendered())(p=c.async_deriveds.get(l))==null||p.reject(Ad);else for(const m of a.values())m.reject(Ad);a.add(u),c.async_deriveds.set(l,u)}const h=(m,v=void 0)=>{f==null||f(),a.delete(u),v!==Ad&&(c.activate(),v?(o.f|=ds,xo(o,v)):((o.f&ds)!==0&&(o.f^=ds),xo(o,m)),c.deactivate())};u.promise.then(h,m=>h(null,m||"unknown"))}),Hv(()=>{for(const l of a)l.reject(Ad)}),new Promise(l=>{function u(c){function f(){c===i?l(o):u(i)}c.then(f,f)}u(i)})}function F(t){const e=ec(t);return Xx(e),e}function Lv(t){const e=ec(t);return e.equals=kx,e}function C4(t){var e=t.effects;if(e!==null){t.effects=null;for(var n=0;n<e.length;n+=1)ar(e[n])}}function Fv(t){var e,n=vt,r=t.parent;if(!Oo&&r!==null&&(r.f&(ni|sr))!==0)return o4(),t.v;Yi(r);try{t.f&=~da,C4(t),e=t_(t)}finally{Yi(n)}return e}function Px(t){var e=Fv(t);if(!t.equals(e)&&(t.wv=$x(),(!(Xe!=null&&Xe.is_fork)||t.deps===null)&&(Xe!==null?(Xe.capture(t,e,!0),Ou==null||Ou.capture(t,e,!0)):t.v=e,t.deps===null))){nn(t,yn);return}Oo||(Ln!==null?(Bv()||Xe!=null&&Xe.is_fork)&&Ln.set(t,e):Rv(t))}function S4(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(vp),r.teardown=yr,r.ac=null,nc(r,0),Vv(r))}function Lx(t){if(t.effects!==null)for(const e of t.effects)e.teardown&&Cl(e)}let Hf=new Set;const ea=new Map;let Fx=!1;function Do(t,e){var n={f:0,v:t,reactions:null,equals:yx,rv:0,wv:0};return n}function B(t,e){const n=Do(t);return Xx(n),n}function Xg(t,e=!1,n=!0){var i;const r=Do(t);return e||(r.equals=kx),Gl&&n&&sn!==null&&sn.l!==null&&((i=sn.l).s??(i.s=[])).push(r),r}function y(t,e,n=!1){Ct!==null&&(!bi||(Ct.f&zf)!==0)&&Ta()&&(Ct.f&(jn|vi|Xa|zf))!==0&&(ri===null||!kl.call(ri,t))&&WT();let r=n?Ge(e):e;return xo(t,r,df)}function xo(t,e,n=null){if(!t.equals(e)){ea.set(t,Oo?e:t.v);var r=Mo.ensure();if(r.capture(t,e),(t.f&jn)!==0){const i=t;(t.f&Sn)!==0&&Fv(i),Ln===null&&Rv(i)}t.wv=$x(),zx(t,Sn,n),Ta()&&vt!==null&&(vt.f&yn)!==0&&(vt.f&(wi|To))===0&&(Wr===null?F4([t]):Wr.push(t)),!r.is_fork&&Hf.size>0&&!Fx&&E4()}return e}function E4(){Fx=!1;for(const t of Hf){(t.f&yn)!==0&&nn(t,Ji);let e;try{e=td(t)}catch{e=!0}e&&Cl(t)}Hf.clear()}function tc(t,e=1){var n=d(t),r=e===1?n++:n--;return y(t,n),r}function Iu(t){y(t,t.v+1)}function zx(t,e,n){var r=t.reactions;if(r!==null)for(var i=Ta(),o=r.length,s=0;s<o;s++){var a=r[s],l=a.f;if(!(!i&&a===vt)){var u=(l&Sn)===0;if(u&&nn(a,e),(l&zf)!==0)Hf.add(a);else if((l&jn)!==0){var c=a;Ln==null||Ln.delete(c),(l&da)===0&&(l&ti&&(vt===null||(vt.f&Bf)===0)&&(a.f|=da),zx(c,Ji,n))}else if(u){var f=a;(l&vi)!==0&&pi!==null&&pi.add(f),n!==null?n.push(f):Pv(f)}}}}function Ge(t){if(typeof t!="object"||t===null||qi in t)return t;const e=Iv(t);if(e!==TT&&e!==MT)return t;var n=new Map,r=Ov(t),i=B(0),o=na,s=a=>{if(na===o)return a();var l=Ct,u=na;li(null),X1(o);var c=a();return li(l),X1(u),c};return r&&n.set("length",B(t.length)),new Proxy(t,{defineProperty(a,l,u){(!("value"in u)||u.configurable===!1||u.enumerable===!1||u.writable===!1)&&jT();var c=n.get(l);return c===void 0?s(()=>{var f=B(u.value);return n.set(l,f),f}):y(c,u.value,!0),!0},deleteProperty(a,l){var u=n.get(l);if(u===void 0){if(l in a){const c=s(()=>B(vn));n.set(l,c),Iu(i)}}else y(u,vn),Iu(i);return!0},get(a,l,u){var p;if(l===qi)return t;var c=n.get(l),f=l in a;if(c===void 0&&(!f||(p=cs(a,l))!=null&&p.writable)&&(c=s(()=>{var m=Ge(f?a[l]:vn),v=B(m);return v}),n.set(l,c)),c!==void 0){var h=d(c);return h===vn?void 0:h}return Reflect.get(a,l,u)},getOwnPropertyDescriptor(a,l){var u=Reflect.getOwnPropertyDescriptor(a,l);if(u&&"value"in u){var c=n.get(l);c&&(u.value=d(c))}else if(u===void 0){var f=n.get(l),h=f==null?void 0:f.v;if(f!==void 0&&h!==vn)return{enumerable:!0,configurable:!0,value:h,writable:!0}}return u},has(a,l){var h;if(l===qi)return!0;var u=n.get(l),c=u!==void 0&&u.v!==vn||Reflect.has(a,l);if(u!==void 0||vt!==null&&(!c||(h=cs(a,l))!=null&&h.writable)){u===void 0&&(u=s(()=>{var p=c?Ge(a[l]):vn,m=B(p);return m}),n.set(l,u));var f=d(u);if(f===vn)return!1}return c},set(a,l,u,c){var _;var f=n.get(l),h=l in a;if(r&&l==="length")for(var p=u;p<f.v;p+=1){var m=n.get(p+"");m!==void 0?y(m,vn):p in a&&(m=s(()=>B(vn)),n.set(p+"",m))}if(f===void 0)(!h||(_=cs(a,l))!=null&&_.writable)&&(f=s(()=>B(void 0)),y(f,Ge(u)),n.set(l,f));else{h=f.v!==vn;var v=s(()=>Ge(u));y(f,v)}var g=Reflect.getOwnPropertyDescriptor(a,l);if(g!=null&&g.set&&g.set.call(c,u),!h){if(r&&typeof l=="string"){var b=n.get("length"),x=Number(l);Number.isInteger(x)&&x>=b.v&&y(b,x+1)}Iu(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!==vn});for(var[u,c]of n)c.v!==vn&&!(u in a)&&l.push(u);return l},setPrototypeOf(){qT()}})}function G1(t){try{if(t!==null&&typeof t=="object"&&qi in t)return t[qi]}catch{}return t}function A4(t,e){return Object.is(G1(t),G1(e))}var Z1,Bx,Hx,Vx;function T4(){if(Z1===void 0){Z1=window,Bx=/Firefox/.test(navigator.userAgent);var t=Element.prototype,e=Node.prototype,n=Text.prototype;Hx=cs(e,"firstChild").get,Vx=cs(e,"nextSibling").get,q1(t)&&(t[Ug]=void 0,t[uf]=null,t[jg]=void 0,t.__e=void 0),q1(n)&&(n[wu]=void 0)}}function _o(t=""){return document.createTextNode(t)}function Nr(t){return Hx.call(t)}function $c(t){return Vx.call(t)}function w(t,e){return Nr(t)}function Se(t,e=!1){{var n=Nr(t);return n instanceof Comment&&n.data===""?$c(n):n}}function k(t,e=1,n=!1){let r=t;for(;e--;)r=$c(r);return r}function M4(t){t.textContent=""}function Ux(){return!1}function jx(t,e,n){return document.createElementNS(e??bx,t,void 0)}function D4(t,e){{const n=document.body;t.autofocus=!0,Wi(()=>{document.activeElement===n&&t.focus()})}}let J1=!1;function O4(){J1||(J1=!0,document.addEventListener("reset",t=>{Promise.resolve().then(()=>{var e;if(!t.defaultPrevented)for(const n of t.target.elements)(e=n[cf])==null||e.call(n)})},{capture:!0}))}function bp(t){var e=Ct,n=vt;li(null),Yi(null);try{return t()}finally{li(e),Yi(n)}}function zv(t,e,n,r=n){t.addEventListener(e,()=>bp(n));const i=t[cf];i?t[cf]=()=>{i(),r(!0)}:t[cf]=()=>r(!0),O4()}function I4(t){vt===null&&(Ct===null&&HT(),BT()),Oo&&zT()}function R4(t,e){var n=e.last;n===null?e.last=e.first=t:(n.next=t,t.prev=n,e.last=t)}function no(t,e){var n=vt;n!==null&&(n.f&sr)!==0&&(t|=sr);var r={ctx:sn,deps:null,nodes:null,f:t|Sn|ti,first:null,fn:e,last:null,next:null,parent:n,b:n&&n.b,prev:null,teardown:null,wv:0,ac:null};Xe==null||Xe.register_created_effect(r);var i=r;if((t&xl)!==0)Ga!==null?Ga.push(r):Mo.ensure().schedule(r);else if(e!==null){try{Cl(r)}catch(s){throw ar(r),s}i.deps===null&&i.teardown===null&&i.nodes===null&&i.first===i.last&&(i.f&Aa)===0&&(i=i.first,(t&vi)!==0&&(t&bs)!==0&&i!==null&&(i.f|=bs))}if(i!==null&&(i.parent=n,n!==null&&R4(i,n),Ct!==null&&(Ct.f&jn)!==0&&(t&To)===0)){var o=Ct;(o.effects??(o.effects=[])).push(i)}return r}function Bv(){return Ct!==null&&!bi}function Hv(t){const e=no(gp,null);return nn(e,yn),e.teardown=t,e}function me(t){I4();var e=vt.f,n=!Ct&&(e&wi)!==0&&(e&Ea)===0;if(n){var r=sn;(r.e??(r.e=[])).push(t)}else return qx(t)}function qx(t){return no(xl|RT,t)}function Wx(t){Mo.ensure();const e=no(To|Aa,t);return()=>{ar(e)}}function N4(t){Mo.ensure();const e=no(To|Aa,t);return(n={})=>new Promise(r=>{n.outro?ta(e,()=>{ar(e),r(void 0)}):(ar(e),r(void 0))})}function yp(t){return no(xl,t)}function P4(t){return no(Xa|Aa,t)}function ed(t,e=0){return no(gp|e,t)}function q(t,e=[],n=[],r=[]){x4(r,e,n,i=>{no(gp,()=>t(...i.map(d)))})}function Ma(t,e=0){var n=no(vi|e,t);return n}function Jr(t){return no(wi|Aa,t)}function Kx(t){var e=t.teardown;if(e!==null){const n=Oo,r=Ct;Y1(!0),li(null);try{e.call(null)}finally{Y1(n),li(r)}}}function Vv(t,e=!1){var n=t.first;for(t.first=t.last=null;n!==null;){const i=n.ac;i!==null&&bp(()=>{i.abort(vp)});var r=n.next;(n.f&To)!==0?n.parent=null:ar(n,e),n=r}}function L4(t){for(var e=t.first;e!==null;){var n=e.next;(e.f&wi)===0&&ar(e),e=n}}function ar(t,e=!0){var n=!1;(e||(t.f&IT)!==0)&&t.nodes!==null&&t.nodes.end!==null&&(Gx(t.nodes.start,t.nodes.end),n=!0),nn(t,Vg),Vv(t,e&&!n),nc(t,0);var r=t.nodes&&t.nodes.t;if(r!==null)for(const o of r)o.stop();Kx(t),t.f^=Vg,t.f|=ni;var i=t.parent;i!==null&&i.first!==null&&Zx(t),t.next=t.prev=t.teardown=t.ctx=t.deps=t.fn=t.nodes=t.ac=t.b=null}function Gx(t,e){for(;t!==null;){var n=t===e?null:$c(t);t.remove(),t=n}}function Zx(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 ta(t,e,n=!0){var r=[];Jx(t,r,!0);var i=()=>{n&&ar(t),e&&e()},o=r.length;if(o>0){var s=()=>--o||i();for(var a of r)a.out(s)}else i()}function Jx(t,e,n){if((t.f&sr)===0){t.f^=sr;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&To)===0){var s=(i.f&bs)!==0||(i.f&wi)!==0&&(t.f&vi)!==0;Jx(i,e,s?n:!1)}i=o}}}function Uv(t){Yx(t,!0)}function Yx(t,e){if((t.f&sr)!==0){t.f^=sr,(t.f&yn)===0&&(nn(t,Sn),Mo.ensure().schedule(t));for(var n=t.first;n!==null;){var r=n.next,i=(n.f&bs)!==0||(n.f&wi)!==0;Yx(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 jv(t,e){if(t.nodes)for(var n=t.nodes.start,r=t.nodes.end;n!==null;){var i=n===r?null:$c(n);e.append(n),n=i}}let mf=!1,Oo=!1;function Y1(t){Oo=t}let Ct=null,bi=!1;function li(t){Ct=t}let vt=null;function Yi(t){vt=t}let ri=null;function Xx(t){Ct!==null&&(ri===null?ri=[t]:ri.push(t))}let br=null,Tr=0,Wr=null;function F4(t){Wr=t}let Qx=1,Vs=0,na=Vs;function X1(t){na=t}function $x(){return++Qx}function td(t){var e=t.f;if((e&Sn)!==0)return!0;if(e&jn&&(t.f&=~da),(e&Ji)!==0){for(var n=t.deps,r=n.length,i=0;i<r;i++){var o=n[i];if(td(o)&&Px(o),o.wv>t.wv)return!0}(e&ti)!==0&&Ln===null&&nn(t,yn)}return!1}function e_(t,e,n=!0){var r=t.reactions;if(r!==null&&!(ri!==null&&kl.call(ri,t)))for(var i=0;i<r.length;i++){var o=r[i];(o.f&jn)!==0?e_(o,e,!1):e===o&&(n?nn(o,Sn):(o.f&yn)!==0&&nn(o,Ji),Pv(o))}}function t_(t){var v;var e=br,n=Tr,r=Wr,i=Ct,o=ri,s=sn,a=bi,l=na,u=t.f;br=null,Tr=0,Wr=null,Ct=(u&(wi|To))===0?t:null,ri=null,_l(t.ctx),bi=!1,na=++Vs,t.ac!==null&&(bp(()=>{t.ac.abort(vp)}),t.ac=null);try{t.f|=Bf;var c=t.fn,f=c();t.f|=Ea;var h=t.deps,p=Xe==null?void 0:Xe.is_fork;if(br!==null){var m;if(p||nc(t,Tr),h!==null&&Tr>0)for(h.length=Tr+br.length,m=0;m<br.length;m++)h[Tr+m]=br[m];else t.deps=h=br;if(Bv()&&(t.f&ti)!==0)for(m=Tr;m<h.length;m++)((v=h[m]).reactions??(v.reactions=[])).push(t)}else!p&&h!==null&&Tr<h.length&&(nc(t,Tr),h.length=Tr);if(Ta()&&Wr!==null&&!bi&&h!==null&&(t.f&(jn|Ji|Sn))===0)for(m=0;m<Wr.length;m++)e_(Wr[m],t);if(i!==null&&i!==t){if(Vs++,i.deps!==null)for(let g=0;g<n;g+=1)i.deps[g].rv=Vs;if(e!==null)for(const g of e)g.rv=Vs;Wr!==null&&(r===null?r=Wr:r.push(...Wr))}return(t.f&ds)!==0&&(t.f^=ds),f}catch(g){return _x(g)}finally{t.f^=Bf,br=e,Tr=n,Wr=r,Ct=i,ri=o,_l(s),bi=a,na=l}}function z4(t,e){let n=e.reactions;if(n!==null){var r=ET.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&jn)!==0&&(br===null||!kl.call(br,e))){var o=e;(o.f&ti)!==0&&(o.f^=ti,o.f&=~da),o.v!==vn&&Rv(o),S4(o),nc(o,0)}}function nc(t,e){var n=t.deps;if(n!==null)for(var r=e;r<n.length;r++)z4(t,n[r])}function Cl(t){var e=t.f;if((e&ni)===0){nn(t,yn);var n=vt,r=mf;vt=t,mf=!0;try{(e&(vi|hx))!==0?L4(t):Vv(t),Kx(t);var i=t_(t);t.teardown=typeof i=="function"?i:null,t.wv=Qx;var o;cx&&l4&&(t.f&Sn)!==0&&t.deps}finally{mf=r,vt=n}}}async function B4(){await Promise.resolve(),Tx()}function d(t){var e=t.f,n=(e&jn)!==0;if(Ct!==null&&!bi){var r=vt!==null&&(vt.f&ni)!==0;if(!r&&(ri===null||!kl.call(ri,t))){var i=Ct.deps;if((Ct.f&Bf)!==0)t.rv<Vs&&(t.rv=Vs,br===null&&i!==null&&i[Tr]===t?Tr++:br===null?br=[t]:br.push(t));else{(Ct.deps??(Ct.deps=[])).push(t);var o=t.reactions;o===null?t.reactions=[Ct]:kl.call(o,Ct)||o.push(Ct)}}}if(Oo&&ea.has(t))return ea.get(t);if(n){var s=t;if(Oo){var a=s.v;return((s.f&yn)===0&&s.reactions!==null||r_(s))&&(a=Fv(s)),ea.set(s,a),a}var l=(s.f&ti)===0&&!bi&&Ct!==null&&(mf||(Ct.f&ti)!==0),u=(s.f&Ea)===0;td(s)&&(l&&(s.f|=ti),Px(s)),l&&!u&&(Lx(s),n_(s))}if(Ln!=null&&Ln.has(t))return Ln.get(t);if((t.f&ds)!==0)throw t.v;return t.v}function n_(t){if(t.f|=ti,t.deps!==null)for(const e of t.deps)(e.reactions??(e.reactions=[])).push(t),(e.f&jn)!==0&&(e.f&ti)===0&&(Lx(e),n_(e))}function r_(t){if(t.v===vn)return!0;if(t.deps===null)return!1;for(const e of t.deps)if(ea.has(e)||(e.f&jn)!==0&&r_(e))return!0;return!1}function St(t){var e=bi;try{return bi=!0,t()}finally{bi=e}}function H4(t){if(!(typeof t!="object"||!t||t instanceof EventTarget)){if(qi in t)Qg(t);else if(!Array.isArray(t))for(let e in t){const n=t[e];typeof n=="object"&&n&&qi in n&&Qg(n)}}}function Qg(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{Qg(t[r],e)}catch{}const n=Iv(t);if(n!==Object.prototype&&n!==Array.prototype&&n!==Map.prototype&&n!==Set.prototype&&n!==Date.prototype){const r=dx(n);for(let i in r){const o=r[i].get;if(o)try{o.call(t)}catch{}}}}}const V4=["touchstart","touchmove"];function U4(t){return V4.includes(t)}const Us=Symbol("events"),i_=new Set,$g=new Set;function j4(t,e,n,r={}){function i(o){if(r.capture||e0.call(e,o),!o.cancelBubble)return bp(()=>n==null?void 0:n.call(this,o))}return t.startsWith("pointer")||t.startsWith("touch")||t==="wheel"?Wi(()=>{e.addEventListener(t,i,r)}):e.addEventListener(t,i,r),i}function rn(t,e,n,r,i){var o={capture:r,passive:i},s=j4(t,e,n,o);(e===document.body||e===window||e===document||e instanceof HTMLMediaElement)&&Hv(()=>{e.removeEventListener(t,s,o)})}function N(t,e,n){(e[Us]??(e[Us]={}))[t]=n}function We(t){for(var e=0;e<t.length;e++)i_.add(t[e]);for(var n of $g)n(t)}let Q1=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;Q1=t;var s=0,a=Q1===t&&t[Us];if(a){var l=i.indexOf(a);if(l!==-1&&(e===document||e===window)){t[Us]=e;return}var u=i.indexOf(e);if(u===-1)return;l<=u&&(s=l)}if(o=i[s]||t.target,o!==e){AT(t,"currentTarget",{configurable:!0,get(){return o||n}});var c=Ct,f=vt;li(null),Yi(null);try{for(var h,p=[];o!==null;){var m=o.assignedSlot||o.parentNode||o.host||null;try{var v=(b=o[Us])==null?void 0:b[r];v!=null&&(!o.disabled||t.target===o)&&v.call(o,t)}catch(x){h?p.push(x):h=x}if(t.cancelBubble||m===e||m===null)break;o=m}if(h){for(let x of p)queueMicrotask(()=>{throw x});throw h}}finally{t[Us]=e,delete t.currentTarget,li(c),Yi(f)}}}var lx;const vm=((lx=globalThis==null?void 0:globalThis.window)==null?void 0:lx.trustedTypes)&&globalThis.window.trustedTypes.createPolicy("svelte-trusted-html",{createHTML:t=>t});function q4(t){return(vm==null?void 0:vm.createHTML(t))??t}function o_(t){var e=jx("template");return e.innerHTML=q4(t.replaceAll("<!>","<!---->")),e.content}function ys(t,e){var n=vt;n.nodes===null&&(n.nodes={start:t,end:e,a:null,t:null})}function M(t,e){var n=(e&vx)!==0,r=(e&n4)!==0,i,o=!t.startsWith("<!>");return()=>{i===void 0&&(i=o_(o?t:"<!>"+t),n||(i=Nr(i)));var s=r||Bx?document.importNode(i,!0):i.cloneNode(!0);if(n){var a=Nr(s),l=s.lastChild;ys(a,l)}else ys(s,s);return s}}function W4(t,e,n="svg"){var r=!t.startsWith("<!>"),i=(e&vx)!==0,o=`<${n}>${r?t:"<!>"+t}</${n}>`,s;return()=>{if(!s){var a=o_(o),l=Nr(a);if(i)for(s=document.createDocumentFragment();Nr(l);)s.appendChild(Nr(l));else s=Nr(l)}var u=s.cloneNode(!0);if(i){var c=Nr(u),f=u.lastChild;ys(c,f)}else ys(u,u);return u}}function Er(t,e){return W4(t,e,"svg")}function or(t=""){{var e=_o(t+"");return ys(e,e),e}}function kt(){var t=document.createDocumentFragment(),e=document.createComment(""),n=_o();return t.append(e,n),ys(e,n),t}function C(t,e){t!==null&&t.before(e)}function ee(t,e){var n=e==null?"":typeof e=="object"?`${e}`:e;n!==(t[wu]??(t[wu]=t.nodeValue))&&(t[wu]=n,t.nodeValue=`${n}`)}function K4(t,e){return G4(t,e)}const Td=new Map;function G4(t,{target:e,anchor:n,props:r={},events:i,context:o,intro:s=!0,transformError:a}){T4();var l=void 0,u=N4(()=>{var c=n??e.appendChild(_o());Ix(c,{pending:()=>{}},p=>{ze({});var m=sn;o&&(m.c=o),i&&(r.$$events=i),l=t(p,r)||{},Be()},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=U4(v);for(const _ of[e,document]){var b=Td.get(_);b===void 0&&(b=new Map,Td.set(_,b));var x=b.get(v);x===void 0?(_.addEventListener(v,e0,{passive:g}),b.set(v,1)):b.set(v,x+1)}}}};return h(mp(i_)),$g.add(h),()=>{var g;for(var p of f)for(const b of[e,document]){var m=Td.get(b),v=m.get(p);--v==0?(b.removeEventListener(p,e0),m.delete(p),m.size===0&&Td.delete(b)):m.set(p,v)}$g.delete(h),c!==n&&((g=c.parentNode)==null||g.removeChild(c))}});return Z4.set(l,u),l}let Z4=new WeakMap;var mi,zi,Rr,$s,Jc,Yc,dp;class nd{constructor(e,n=!0){wn(this,"anchor");tt(this,mi,new Map);tt(this,zi,new Map);tt(this,Rr,new Map);tt(this,$s,new Set);tt(this,Jc,!0);tt(this,Yc,e=>{if(ie(this,mi).has(e)){var n=ie(this,mi).get(e),r=ie(this,zi).get(n);if(r)Uv(r),ie(this,$s).delete(n);else{var i=ie(this,Rr).get(n);i&&(ie(this,zi).set(n,i.effect),ie(this,Rr).delete(n),i.fragment.lastChild.remove(),this.anchor.before(i.fragment),r=i.effect)}for(const[o,s]of ie(this,mi)){if(ie(this,mi).delete(o),o===e)break;const a=ie(this,Rr).get(s);a&&(ar(a.effect),ie(this,Rr).delete(s))}for(const[o,s]of ie(this,zi)){if(o===n||ie(this,$s).has(o))continue;const a=()=>{if(Array.from(ie(this,mi).values()).includes(o)){var u=document.createDocumentFragment();jv(s,u),u.append(_o()),ie(this,Rr).set(o,{effect:s,fragment:u})}else ar(s);ie(this,$s).delete(o),ie(this,zi).delete(o)};ie(this,Jc)||!r?(ie(this,$s).add(o),ta(s,a,!1)):a()}}});tt(this,dp,e=>{ie(this,mi).delete(e);const n=Array.from(ie(this,mi).values());for(const[r,i]of ie(this,Rr))n.includes(r)||(ar(i.effect),ie(this,Rr).delete(r))});this.anchor=e,rt(this,Jc,n)}ensure(e,n){var r=Xe,i=Ux();if(n&&!ie(this,zi).has(e)&&!ie(this,Rr).has(e))if(i){var o=document.createDocumentFragment(),s=_o();o.append(s),ie(this,Rr).set(e,{effect:Jr(()=>n(s)),fragment:o})}else ie(this,zi).set(e,Jr(()=>n(this.anchor)));if(ie(this,mi).set(r,e),i){for(const[a,l]of ie(this,zi))a===e?r.unskip_effect(l):r.skip_effect(l);for(const[a,l]of ie(this,Rr))a===e?r.unskip_effect(l.effect):r.skip_effect(l.effect);r.oncommit(ie(this,Yc)),r.ondiscard(ie(this,dp))}else ie(this,Yc).call(this,r)}}mi=new WeakMap,zi=new WeakMap,Rr=new WeakMap,$s=new WeakMap,Jc=new WeakMap,Yc=new WeakMap,dp=new WeakMap;const J4=0,$1=1,Y4=2;function s_(t,e,n,r,i){var o=Ta(),s=vn,a=o?Do(s):Xg(s,!1,!1),l=o?Do(s):Xg(s,!1,!1),u=new nd(t);Ma(()=>{var c=Xe;c.deactivate();var f=e();c.activate();var h=!1;if(DT(f)){var p=Rx(),m=!1;const v=g=>{if(!h){m=!0,p(!1),Mo.ensure();try{g()}finally{$u(!1),Qa||Tx()}}};f.then(g=>{v(()=>{xo(a,g),u.ensure($1,r&&(b=>r(b,a)))})},g=>{v(()=>{if(xo(l,g),u.ensure(Y4,i&&(b=>i(b,l))),!i)throw l.v})}),Wi(()=>{m||v(()=>{u.ensure(J4,n)})})}else xo(a,f),u.ensure($1,r&&(v=>r(v,a)));return()=>{h=!0}})}function G(t,e,n=!1){var r=new nd(t),i=n?bs:0;function o(s,a){r.ensure(s,a)}Ma(()=>{var s=!1;e((a,l=0)=>{s=!0,o(l,a)}),s||o(-1,null)},i)}const X4=Symbol("NaN");function Vf(t,e,n){var r=new nd(t),i=!Ta();Ma(()=>{var o=e();o!==o&&(o=X4),i&&o!==null&&typeof o=="object"&&(o={}),r.ensure(o,n)})}function Sl(t,e){return e}function Q4(t,e,n){for(var r=[],i=e.length,o,s=e.length,a=0;a<i;a++){let f=e[a];ta(f,()=>{if(o){if(o.pending.delete(f),o.done.add(f),o.pending.size===0){var h=t.outrogroups;t0(t,mp(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 u=n,c=u.parentNode;M4(c),c.append(u),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|=Bi;const s=document.createDocumentFragment();jv(o,s)}else ar(e[i],n)}}var ey;function Je(t,e,n,r,i,o=null){var s=t,a=new Map,l=(e&gx)!==0;if(l){var u=t;s=u.appendChild(_o())}var c=null,f=Lv(()=>{var _=n();return Ov(_)?_:_==null?[]:mp(_)}),h,p=new Map,m=!0;function v(_){(x.effect.f&ni)===0&&(x.pending.delete(_),x.fallback=c,$4(x,h,s,e,r),c!==null&&(h.length===0?(c.f&Bi)===0?Uv(c):(c.f^=Bi,xu(c,null,s)):ta(c,()=>{c=null})))}function g(_){x.pending.delete(_)}var b=Ma(()=>{h=d(f);for(var _=h.length,T=new Set,S=Xe,z=Ux(),E=0;E<_;E+=1){var D=h[E],P=r(D,E),R=m?null:a.get(P);R?(R.v&&xo(R.v,D),R.i&&xo(R.i,E),z&&S.unskip_effect(R.e)):(R=e6(a,m?s:ey??(ey=_o()),D,P,E,i,e,n),m||(R.e.f|=Bi),a.set(P,R)),T.add(P)}if(_===0&&o&&!c&&(m?c=Jr(()=>o(s)):(c=Jr(()=>o(ey??(ey=_o()))),c.f|=Bi)),_>T.size&&FT(),!m)if(p.set(S,T),z){for(const[H,Q]of a)T.has(H)||S.skip_effect(Q.e);S.oncommit(v),S.ondiscard(g)}else v(S);d(f)}),x={effect:b,items:a,pending:p,outrogroups:null,fallback:c};m=!1}function lu(t){for(;t!==null&&(t.f&wi)===0;)t=t.next;return t}function $4(t,e,n,r,i){var R,H,Q,Z,$,W,te,ae,re;var o=(r&JT)!==0,s=e.length,a=t.items,l=lu(t.effect.first),u,c=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&Bi)===0&&((H=(R=g.nodes)==null?void 0:R.a)==null||H.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 ue of t.outrogroups)ue.pending.delete(g),ue.done.delete(g);if((g.f&sr)!==0&&(Uv(g),o&&((Z=(Q=g.nodes)==null?void 0:Q.a)==null||Z.unfix(),(f??(f=new Set)).delete(g))),(g.f&Bi)!==0)if(g.f^=Bi,g===l)xu(g,null,n);else{var x=c?c.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),Bo(t,c,g),Bo(t,g,x),xu(g,x,n),c=g,h=[],p=[],l=lu(c.next);continue}if(g!==l){if(u!==void 0&&u.has(g)){if(h.length<p.length){var _=p[0],T;c=_.prev;var S=h[0],z=h[h.length-1];for(T=0;T<h.length;T+=1)xu(h[T],_,n);for(T=0;T<p.length;T+=1)u.delete(p[T]);Bo(t,S.prev,z.next),Bo(t,c,S),Bo(t,z,_),l=_,c=z,b-=1,h=[],p=[]}else u.delete(g),xu(g,l,n),Bo(t,g.prev,g.next),Bo(t,g,c===null?t.effect.first:c.next),Bo(t,c,g),c=g;continue}for(h=[],p=[];l!==null&&l!==g;)(u??(u=new Set)).add(l),p.push(l),l=lu(l.next);if(l===null)continue}(g.f&Bi)===0&&h.push(g),c=g,l=lu(g.next)}if(t.outrogroups!==null){for(const ue of t.outrogroups)ue.pending.size===0&&(t0(t,mp(ue.done)),($=t.outrogroups)==null||$.delete(ue));t.outrogroups.size===0&&(t.outrogroups=null)}if(l!==null||u!==void 0){var E=[];if(u!==void 0)for(g of u)(g.f&sr)===0&&E.push(g);for(;l!==null;)(l.f&sr)===0&&l!==t.fallback&&E.push(l),l=lu(l.next);var D=E.length;if(D>0){var P=(r&gx)!==0&&s===0?n:null;if(o){for(b=0;b<D;b+=1)(te=(W=E[b].nodes)==null?void 0:W.a)==null||te.measure();for(b=0;b<D;b+=1)(re=(ae=E[b].nodes)==null?void 0:ae.a)==null||re.fix()}Q4(t,E,P)}}o&&Wi(()=>{var ue,oe;if(f!==void 0)for(g of f)(oe=(ue=g.nodes)==null?void 0:ue.a)==null||oe.apply()})}function e6(t,e,n,r,i,o,s,a){var l=(s>)!==0?(s&YT)===0?Xg(n,!1,!1):Do(n):null,u=(s&ZT)!==0?Do(i):null;return{v:l,i:u,e:Jr(()=>(o(e,l??n,u??i,a),()=>{t.delete(r)}))}}function xu(t,e,n){if(t.nodes)for(var r=t.nodes.start,i=t.nodes.end,o=e&&(e.f&Bi)===0?e.nodes.start:n;r!==null;){var s=$c(r);if(o.before(r),r===i)return;r=s}}function Bo(t,e,n){e===null?t.effect.first=n:e.next=n,n===null?t.effect.last=e:n.prev=e}function t6(t,e,n=!1,r=!1,i=!1,o=!1){var s=t,a="";if(n)var l=t;q(()=>{var u=vt;if(a!==(a=e()??"")){if(n){u.nodes=null,l.innerHTML=a,a!==""&&ys(Nr(l),l.lastChild);return}if(u.nodes!==null&&(Gx(u.nodes.start,u.nodes.end),u.nodes=null),a!==""){var c=r?r4:i?i4:void 0,f=jx(r?"svg":i?"math":"template",c);f.innerHTML=a;var h=r||i?f:f.content;if(ys(Nr(h),h.lastChild),r||i)for(;Nr(h);)s.before(Nr(h));else s.before(h)}}})}function rd(t,e,...n){var r=new nd(t);Ma(()=>{const i=e()??null;r.ensure(i,i&&(o=>i(o,...n)))},bs)}function qv(t,e,n){var r=new nd(t);Ma(()=>{var i=e()??null;r.ensure(i,i&&(o=>n(o,i)))},bs)}function cr(t,e,n){yp(()=>{var r=St(()=>e(t,n==null?void 0:n())||{});if(n&&(r!=null&&r.update)){var i=!1,o={};ed(()=>{var s=n();H4(s),i&&wx(o,s)&&(o=s,r.update(s))}),i=!0}if(r!=null&&r.destroy)return()=>r.destroy()})}function a_(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=a_(t[e]))&&(r&&(r+=" "),r+=n)}else for(n in t)t[n]&&(r&&(r+=" "),r+=n);return r}function n6(){for(var t,e,n=0,r="",i=arguments.length;n<i;n++)(t=arguments[n])&&(e=a_(t))&&(r&&(r+=" "),r+=e);return r}function n0(t){return typeof t=="object"?n6(t):t??""}const ty=[...`
|
|
3
|
+
\r\f \v\uFEFF`];function r6(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||ty.includes(r[s-1]))&&(a===r.length||ty.includes(r[a]))?r=(s===0?"":r.substring(0,s))+r.substring(a+1):s=a}}return r===""?null:r}function i6(t,e){return t==null?null:String(t)}function At(t,e,n,r,i,o){var s=t[Ug];if(s!==n||s===void 0){var a=r6(n,r,o);a==null?t.removeAttribute("class"):t.className=a,t[Ug]=n}else if(o&&i!==o)for(var l in o){var u=!!o[l];(i==null||u!==!!i[l])&&t.classList.toggle(l,u)}return o}function xe(t,e,n,r){var i=t[jg];if(i!==e){var o=i6(e);o==null?t.removeAttribute("style"):t.style.cssText=o,t[jg]=e}return r}function wp(t,e,n=!1){if(t.multiple){if(e==null)return;if(!Ov(e))return s4();for(var r of t.options)r.selected=e.includes(Ru(r));return}for(r of t.options){var i=Ru(r);if(A4(i,e)){r.selected=!0;return}}(!n||e!==void 0)&&(t.selectedIndex=-1)}function Wv(t){var e=new MutationObserver(()=>{wp(t,t.__value)});e.observe(t,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["value"]}),Hv(()=>{e.disconnect()})}function o6(t,e,n=e){var r=new WeakSet,i=!0;zv(t,"change",o=>{var s=o?"[selected]":":checked",a;if(t.multiple)a=[].map.call(t.querySelectorAll(s),Ru);else{var l=t.querySelector(s)??t.querySelector("option:not([disabled])");a=l&&Ru(l)}n(a),t.__value=a,Xe!==null&&r.add(Xe)}),yp(()=>{var o=e();if(t===document.activeElement){var s=Xe;if(r.has(s))return}if(wp(t,o,i),i&&o===void 0){var a=t.querySelector(":checked");a!==null&&(o=Ru(a),n(o))}t.__value=o,i=!1}),Wv(t)}function Ru(t){return"__value"in t?t.__value:t.value}const s6=Symbol("is custom element"),a6=Symbol("is html"),l6=PT?"progress":"PROGRESS";function xr(t,e){var n=Kv(t);n.value===(n.value=e??void 0)||t.value===e&&(e!==0||t.nodeName!==l6)||(t.value=e??"")}function Un(t,e){var n=Kv(t);n.checked!==(n.checked=e??void 0)&&(t.checked=e)}function U(t,e,n,r){var i=Kv(t);i[e]!==(i[e]=n)&&(e==="loading"&&(t[NT]=n),n==null?t.removeAttribute(e):typeof n!="string"&&u6(t).includes(e)?t[e]=n:t.setAttribute(e,n))}function Kv(t){return t[uf]??(t[uf]={[s6]:t.nodeName.includes("-"),[a6]:t.namespaceURI===bx})}var ny=new Map;function u6(t){var e=t.getAttribute("is")||t.nodeName,n=ny.get(e);if(n)return n;ny.set(e,n=[]);for(var r,i=t,o=Element.prototype;o!==i;){r=dx(i);for(var s in r)r[s].set&&s!=="innerHTML"&&s!=="textContent"&&s!=="innerText"&&n.push(s);i=Iv(i)}return n}function Bn(t,e,n=e){var r=new WeakSet;zv(t,"input",async i=>{var o=i?t.defaultValue:t.value;if(o=bm(t)?ym(o):o,n(o),Xe!==null&&r.add(Xe),await B4(),o!==(o=e())){var s=t.selectionStart,a=t.selectionEnd,l=t.value.length;if(t.value=o??"",a!==null){var u=t.value.length;s===a&&a===l&&u>l?(t.selectionStart=u,t.selectionEnd=u):(t.selectionStart=s,t.selectionEnd=Math.min(a,u))}}}),St(e)==null&&t.value&&(n(bm(t)?ym(t.value):t.value),Xe!==null&&r.add(Xe)),ed(()=>{var i=e();if(t===document.activeElement){var o=Xe;if(r.has(o))return}bm(t)&&i===ym(t.value)||t.type==="date"&&!i&&!t.value||i!==t.value&&(t.value=i??"")})}function gf(t,e,n=e){zv(t,"change",r=>{var i=r?t.defaultChecked:t.checked;n(i)}),St(e)==null&&n(t.checked),ed(()=>{var r=e();t.checked=!!r})}function bm(t){var e=t.type;return e==="number"||e==="range"}function ym(t){return t===""?null:+t}var ns,wl,Xc,fp,l_;const hp=class hp{constructor(e){tt(this,fp);tt(this,ns,new WeakMap);tt(this,wl);tt(this,Xc);rt(this,Xc,e)}observe(e,n){var r=ie(this,ns).get(e)||new Set;return r.add(n),ie(this,ns).set(e,r),Et(this,fp,l_).call(this).observe(e,ie(this,Xc)),()=>{var i=ie(this,ns).get(e);i.delete(n),i.size===0&&(ie(this,ns).delete(e),ie(this,wl).unobserve(e))}}};ns=new WeakMap,wl=new WeakMap,Xc=new WeakMap,fp=new WeakSet,l_=function(){return ie(this,wl)??rt(this,wl,new ResizeObserver(e=>{for(var n of e){hp.entries.set(n.target,n);for(var r of ie(this,ns).get(n.target)||[])r(n)}}))},wn(hp,"entries",new WeakMap);let r0=hp;var c6=new r0({box:"border-box"});function d6(t,e,n){var r=c6.observe(t,()=>n(t[e]));yp(()=>(St(()=>n(t[e])),r))}function wm(t,e){return t===e||(t==null?void 0:t[qi])===e}function xt(t={},e,n,r){var i=sn.r,o=vt;return yp(()=>{var s,a;return ed(()=>{s=a,a=(r==null?void 0:r())||[],St(()=>{wm(n(...a),t)||(e(t,...a),s&&wm(n(...s),t)&&e(null,...s))})}),()=>{let l=o;for(;l!==i&&l.parent!==null&&l.parent.f&Vg;)l=l.parent;const u=()=>{a&&wm(n(...a),t)&&e(null,...a)},c=l.teardown;l.teardown=()=>{u(),c==null||c()}}}),t}const f6={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 h6(t,e,n){return new Proxy({props:t,exclude:e},f6)}const p6={get(t,e){let n=t.props.length;for(;n--;){let r=t.props[n];if(au(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];au(i)&&(i=i());const o=cs(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(au(r)&&(r=r()),typeof r=="object"&&r!==null&&e in r){const i=cs(r,e);return i&&!i.configurable&&(i.configurable=!0),i}}},has(t,e){if(e===qi||e===px)return!1;for(let n of t.props)if(au(n)&&(n=n()),n!=null&&e in n)return!0;return!1},ownKeys(t){const e=[];for(let n of t.props)if(au(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 _u(...t){return new Proxy({props:t},p6)}function je(t,e,n,r){var T;var i=!Gl||(n&QT)!==0,o=(n&e4)!==0,s=(n&t4)!==0,a=r,l=!0,u=void 0,c=()=>s&&i?(u??(u=ec(r)),d(u)):(l&&(l=!1,a=s?St(r):r),a);let f;if(o){var h=qi in t||px in t;f=((T=cs(t,e))==null?void 0:T.set)??(h&&e in t?S=>t[e]=S:void 0)}var p,m=!1;o?[p,m]=f4(()=>t[e]):p=t[e],p===void 0&&r!==void 0&&(p=c(),f&&(i&&UT(),f(p)));var v;if(i?v=()=>{var S=t[e];return S===void 0?c():(l=!0,S)}:v=()=>{var S=t[e];return S!==void 0&&(a=void 0),S===void 0?a:S},i&&(n&$T)===0)return v;if(f){var g=t.$$legacy;return(function(S,z){return arguments.length>0?((!i||!z||g||m)&&f(z?v():S),S):v()})}var b=!1,x=((n&XT)!==0?ec:Lv)(()=>(b=!1,v()));o&&d(x);var _=vt;return(function(S,z){if(arguments.length>0){const E=z?d(x):i&&o?Ge(S):S;return y(x,E),b=!0,a!==void 0&&(a=E),S}return Oo&&b||(_.f&ni)!==0?x.v:d(x)})}function Zl(t){sn===null&&mx(),Gl&&sn.l!==null?m6(sn).m.push(t):me(()=>{const e=St(t);if(typeof e=="function")return e})}function lr(t){sn===null&&mx(),Zl(()=>()=>St(t))}function m6(t){var e=t.l;return e.u??(e.u={a:[],b:[],m:[]})}const g6="5";var ux;typeof window<"u"&&((ux=window.__svelte??(window.__svelte={})).v??(ux.v=new Set)).add(g6);u4();const v6="modulepreload",b6=function(t){return"/"+t},ry={},Mn=function(e,n,r){let i=Promise.resolve();if(n&&n.length>0){let s=function(u){return Promise.all(u.map(c=>Promise.resolve(c).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(u=>{if(u=b6(u),u in ry)return;ry[u]=!0;const c=u.endsWith(".css"),f=c?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${u}"]${f}`))return;const h=document.createElement("link");if(h.rel=c?"stylesheet":v6,c||(h.as="script"),h.crossOrigin="",h.href=u,l&&h.setAttribute("nonce",l),document.head.appendChild(h),c)return new Promise((p,m)=>{h.addEventListener("load",p),h.addEventListener("error",()=>m(new Error(`Unable to preload CSS for ${u}`)))})}))}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)})},y6="upload://",u_="upload://scratchpad/";function uu(t){return t.startsWith(y6)}function Gv(t){return t.startsWith(u_)}function c_(t){if(!Gv(t))return null;const n=t.slice(u_.length).split("/")[0];return n.length>0?n:null}const vf=t=>t,Hn=t=>t;var Mt;(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})(Mt||(Mt={}));var iy;(function(t){t.mergeShapes=(e,n)=>({...e,...n})})(iy||(iy={}));const He=Mt.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),jo=t=>{switch(typeof t){case"undefined":return He.undefined;case"string":return He.string;case"number":return Number.isNaN(t)?He.nan:He.number;case"boolean":return He.boolean;case"function":return He.function;case"bigint":return He.bigint;case"symbol":return He.symbol;case"object":return Array.isArray(t)?He.array:t===null?He.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?He.promise:typeof Map<"u"&&t instanceof Map?He.map:typeof Set<"u"&&t instanceof Set?He.set:typeof Date<"u"&&t instanceof Date?He.date:He.object;default:return He.unknown}},Ee=Mt.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 Io 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 u=s.path[l];l===s.path.length-1?(a[u]=a[u]||{_errors:[]},a[u]._errors.push(n(s))):a[u]=a[u]||{_errors:[]},a=a[u],l++}}};return i(this),r}static assert(e){if(!(e instanceof Io))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Mt.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()}}Io.create=t=>new Io(t);const i0=(t,e)=>{let n;switch(t.code){case Ee.invalid_type:t.received===He.undefined?n="Required":n=`Expected ${t.expected}, received ${t.received}`;break;case Ee.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(t.expected,Mt.jsonStringifyReplacer)}`;break;case Ee.unrecognized_keys:n=`Unrecognized key(s) in object: ${Mt.joinValues(t.keys,", ")}`;break;case Ee.invalid_union:n="Invalid input";break;case Ee.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${Mt.joinValues(t.options)}`;break;case Ee.invalid_enum_value:n=`Invalid enum value. Expected ${Mt.joinValues(t.options)}, received '${t.received}'`;break;case Ee.invalid_arguments:n="Invalid function arguments";break;case Ee.invalid_return_type:n="Invalid function return type";break;case Ee.invalid_date:n="Invalid date";break;case Ee.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}"`:Mt.assertNever(t.validation):t.validation!=="regex"?n=`Invalid ${t.validation}`:n="Invalid";break;case Ee.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 Ee.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 Ee.custom:n="Invalid input";break;case Ee.invalid_intersection_types:n="Intersection results could not be merged";break;case Ee.not_multiple_of:n=`Number must be a multiple of ${t.multipleOf}`;break;case Ee.not_finite:n="Number must be finite";break;default:n=e.defaultError,Mt.assertNever(t)}return{message:n}};let w6=i0;function k6(){return w6}const x6=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(u=>!!u).slice().reverse();for(const u of l)a=u(s,{data:e,defaultError:a}).message;return{...i,path:o,message:a}};function Re(t,e){const n=k6(),r=x6({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 Fr{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 st;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 Fr.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 st;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 st=Object.freeze({status:"aborted"}),Cu=t=>({status:"dirty",value:t}),ui=t=>({status:"valid",value:t}),oy=t=>t.status==="aborted",sy=t=>t.status==="dirty",El=t=>t.status==="valid",Uf=t=>typeof Promise<"u"&&t instanceof Promise;var Ue;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(Ue||(Ue={}));class ws{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 ay=(t,e)=>{if(El(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 Io(t.common.issues);return this._error=n,this._error}}};function bt(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 Tt{get description(){return this._def.description}_getType(e){return jo(e.data)}_getOrReturnCtx(e,n){return n||{common:e.parent.common,data:e.data,parsedType:jo(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Fr,ctx:{common:e.parent.common,data:e.data,parsedType:jo(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const n=this._parse(e);if(Uf(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:jo(e)},i=this._parseSync({data:e,path:r.path,parent:r});return ay(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:jo(e)};if(!this["~standard"].async)try{const o=this._parseSync({data:e,path:[],parent:n});return El(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=>El(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:jo(e)},i=this._parse({data:e,path:r.path,parent:r}),o=await(Uf(i)?i:Promise.resolve(i));return ay(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:Ee.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 Tl({schema:this,typeName:at.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 fs.create(this,this._def)}nullable(){return Ml.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Ki.create(this)}promise(){return Kf.create(this,this._def)}or(e){return qf.create([this,e],this._def)}and(e){return Wf.create(this,e,this._def)}transform(e){return new Tl({...bt(this._def),schema:this,typeName:at.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const n=typeof e=="function"?e:()=>e;return new s0({...bt(this._def),innerType:this,defaultValue:n,typeName:at.ZodDefault})}brand(){return new W6({typeName:at.ZodBranded,type:this,...bt(this._def)})}catch(e){const n=typeof e=="function"?e:()=>e;return new a0({...bt(this._def),innerType:this,catchValue:n,typeName:at.ZodCatch})}describe(e){const n=this.constructor;return new n({...this._def,description:e})}pipe(e){return Zv.create(this,e)}readonly(){return l0.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const _6=/^c[^\s-]{8,}$/i,C6=/^[0-9a-z]+$/,S6=/^[0-9A-HJKMNP-TV-Z]{26}$/i,E6=/^[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,A6=/^[a-z0-9_-]{21}$/i,T6=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,M6=/^[-+]?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)?)??$/,D6=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,O6="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let km;const I6=/^(?:(?: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])$/,R6=/^(?:(?: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])$/,N6=/^(([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]))$/,P6=/^(([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])$/,L6=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,F6=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,d_="((\\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])))",z6=new RegExp(`^${d_}$`);function f_(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 B6(t){return new RegExp(`^${f_(t)}$`)}function H6(t){let e=`${d_}T${f_(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 V6(t,e){return!!((e==="v4"||!e)&&I6.test(t)||(e==="v6"||!e)&&N6.test(t))}function U6(t,e){if(!T6.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 j6(t,e){return!!((e==="v4"||!e)&&R6.test(t)||(e==="v6"||!e)&&P6.test(t))}class js extends Tt{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==He.string){const o=this._getOrReturnCtx(e);return Re(o,{code:Ee.invalid_type,expected:He.string,received:o.parsedType}),st}const r=new Fr;let i;for(const o of this._def.checks)if(o.kind==="min")e.data.length<o.value&&(i=this._getOrReturnCtx(e,i),Re(i,{code:Ee.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),Re(i,{code:Ee.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?Re(i,{code:Ee.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}):a&&Re(i,{code:Ee.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}),r.dirty())}else if(o.kind==="email")D6.test(e.data)||(i=this._getOrReturnCtx(e,i),Re(i,{validation:"email",code:Ee.invalid_string,message:o.message}),r.dirty());else if(o.kind==="emoji")km||(km=new RegExp(O6,"u")),km.test(e.data)||(i=this._getOrReturnCtx(e,i),Re(i,{validation:"emoji",code:Ee.invalid_string,message:o.message}),r.dirty());else if(o.kind==="uuid")E6.test(e.data)||(i=this._getOrReturnCtx(e,i),Re(i,{validation:"uuid",code:Ee.invalid_string,message:o.message}),r.dirty());else if(o.kind==="nanoid")A6.test(e.data)||(i=this._getOrReturnCtx(e,i),Re(i,{validation:"nanoid",code:Ee.invalid_string,message:o.message}),r.dirty());else if(o.kind==="cuid")_6.test(e.data)||(i=this._getOrReturnCtx(e,i),Re(i,{validation:"cuid",code:Ee.invalid_string,message:o.message}),r.dirty());else if(o.kind==="cuid2")C6.test(e.data)||(i=this._getOrReturnCtx(e,i),Re(i,{validation:"cuid2",code:Ee.invalid_string,message:o.message}),r.dirty());else if(o.kind==="ulid")S6.test(e.data)||(i=this._getOrReturnCtx(e,i),Re(i,{validation:"ulid",code:Ee.invalid_string,message:o.message}),r.dirty());else if(o.kind==="url")try{new URL(e.data)}catch{i=this._getOrReturnCtx(e,i),Re(i,{validation:"url",code:Ee.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),Re(i,{validation:"regex",code:Ee.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),Re(i,{code:Ee.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),Re(i,{code:Ee.invalid_string,validation:{startsWith:o.value},message:o.message}),r.dirty()):o.kind==="endsWith"?e.data.endsWith(o.value)||(i=this._getOrReturnCtx(e,i),Re(i,{code:Ee.invalid_string,validation:{endsWith:o.value},message:o.message}),r.dirty()):o.kind==="datetime"?H6(o).test(e.data)||(i=this._getOrReturnCtx(e,i),Re(i,{code:Ee.invalid_string,validation:"datetime",message:o.message}),r.dirty()):o.kind==="date"?z6.test(e.data)||(i=this._getOrReturnCtx(e,i),Re(i,{code:Ee.invalid_string,validation:"date",message:o.message}),r.dirty()):o.kind==="time"?B6(o).test(e.data)||(i=this._getOrReturnCtx(e,i),Re(i,{code:Ee.invalid_string,validation:"time",message:o.message}),r.dirty()):o.kind==="duration"?M6.test(e.data)||(i=this._getOrReturnCtx(e,i),Re(i,{validation:"duration",code:Ee.invalid_string,message:o.message}),r.dirty()):o.kind==="ip"?V6(e.data,o.version)||(i=this._getOrReturnCtx(e,i),Re(i,{validation:"ip",code:Ee.invalid_string,message:o.message}),r.dirty()):o.kind==="jwt"?U6(e.data,o.alg)||(i=this._getOrReturnCtx(e,i),Re(i,{validation:"jwt",code:Ee.invalid_string,message:o.message}),r.dirty()):o.kind==="cidr"?j6(e.data,o.version)||(i=this._getOrReturnCtx(e,i),Re(i,{validation:"cidr",code:Ee.invalid_string,message:o.message}),r.dirty()):o.kind==="base64"?L6.test(e.data)||(i=this._getOrReturnCtx(e,i),Re(i,{validation:"base64",code:Ee.invalid_string,message:o.message}),r.dirty()):o.kind==="base64url"?F6.test(e.data)||(i=this._getOrReturnCtx(e,i),Re(i,{validation:"base64url",code:Ee.invalid_string,message:o.message}),r.dirty()):Mt.assertNever(o);return{status:r.value,value:e.data}}_regex(e,n,r){return this.refinement(i=>e.test(i),{validation:n,code:Ee.invalid_string,...Ue.errToObj(r)})}_addCheck(e){return new js({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...Ue.errToObj(e)})}url(e){return this._addCheck({kind:"url",...Ue.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...Ue.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...Ue.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...Ue.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...Ue.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...Ue.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...Ue.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...Ue.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...Ue.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...Ue.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...Ue.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...Ue.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,...Ue.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,...Ue.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...Ue.errToObj(e)})}regex(e,n){return this._addCheck({kind:"regex",regex:e,...Ue.errToObj(n)})}includes(e,n){return this._addCheck({kind:"includes",value:e,position:n==null?void 0:n.position,...Ue.errToObj(n==null?void 0:n.message)})}startsWith(e,n){return this._addCheck({kind:"startsWith",value:e,...Ue.errToObj(n)})}endsWith(e,n){return this._addCheck({kind:"endsWith",value:e,...Ue.errToObj(n)})}min(e,n){return this._addCheck({kind:"min",value:e,...Ue.errToObj(n)})}max(e,n){return this._addCheck({kind:"max",value:e,...Ue.errToObj(n)})}length(e,n){return this._addCheck({kind:"length",value:e,...Ue.errToObj(n)})}nonempty(e){return this.min(1,Ue.errToObj(e))}trim(){return new js({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new js({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new js({...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}}js.create=t=>new js({checks:[],typeName:at.ZodString,coerce:(t==null?void 0:t.coerce)??!1,...bt(t)});function q6(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 rc extends Tt{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)!==He.number){const o=this._getOrReturnCtx(e);return Re(o,{code:Ee.invalid_type,expected:He.number,received:o.parsedType}),st}let r;const i=new Fr;for(const o of this._def.checks)o.kind==="int"?Mt.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),Re(r,{code:Ee.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),Re(r,{code:Ee.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),Re(r,{code:Ee.too_big,maximum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),i.dirty()):o.kind==="multipleOf"?q6(e.data,o.value)!==0&&(r=this._getOrReturnCtx(e,r),Re(r,{code:Ee.not_multiple_of,multipleOf:o.value,message:o.message}),i.dirty()):o.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),Re(r,{code:Ee.not_finite,message:o.message}),i.dirty()):Mt.assertNever(o);return{status:i.value,value:e.data}}gte(e,n){return this.setLimit("min",e,!0,Ue.toString(n))}gt(e,n){return this.setLimit("min",e,!1,Ue.toString(n))}lte(e,n){return this.setLimit("max",e,!0,Ue.toString(n))}lt(e,n){return this.setLimit("max",e,!1,Ue.toString(n))}setLimit(e,n,r,i){return new rc({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:Ue.toString(i)}]})}_addCheck(e){return new rc({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:Ue.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Ue.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Ue.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Ue.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Ue.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:Ue.toString(n)})}finite(e){return this._addCheck({kind:"finite",message:Ue.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Ue.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Ue.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"&&Mt.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)}}rc.create=t=>new rc({checks:[],typeName:at.ZodNumber,coerce:(t==null?void 0:t.coerce)||!1,...bt(t)});class ic extends Tt{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)!==He.bigint)return this._getInvalidInput(e);let r;const i=new Fr;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),Re(r,{code:Ee.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),Re(r,{code:Ee.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),Re(r,{code:Ee.not_multiple_of,multipleOf:o.value,message:o.message}),i.dirty()):Mt.assertNever(o);return{status:i.value,value:e.data}}_getInvalidInput(e){const n=this._getOrReturnCtx(e);return Re(n,{code:Ee.invalid_type,expected:He.bigint,received:n.parsedType}),st}gte(e,n){return this.setLimit("min",e,!0,Ue.toString(n))}gt(e,n){return this.setLimit("min",e,!1,Ue.toString(n))}lte(e,n){return this.setLimit("max",e,!0,Ue.toString(n))}lt(e,n){return this.setLimit("max",e,!1,Ue.toString(n))}setLimit(e,n,r,i){return new ic({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:Ue.toString(i)}]})}_addCheck(e){return new ic({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Ue.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Ue.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Ue.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Ue.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:Ue.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}}ic.create=t=>new ic({checks:[],typeName:at.ZodBigInt,coerce:(t==null?void 0:t.coerce)??!1,...bt(t)});class ly extends Tt{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==He.boolean){const r=this._getOrReturnCtx(e);return Re(r,{code:Ee.invalid_type,expected:He.boolean,received:r.parsedType}),st}return ui(e.data)}}ly.create=t=>new ly({typeName:at.ZodBoolean,coerce:(t==null?void 0:t.coerce)||!1,...bt(t)});class jf extends Tt{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==He.date){const o=this._getOrReturnCtx(e);return Re(o,{code:Ee.invalid_type,expected:He.date,received:o.parsedType}),st}if(Number.isNaN(e.data.getTime())){const o=this._getOrReturnCtx(e);return Re(o,{code:Ee.invalid_date}),st}const r=new Fr;let i;for(const o of this._def.checks)o.kind==="min"?e.data.getTime()<o.value&&(i=this._getOrReturnCtx(e,i),Re(i,{code:Ee.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),Re(i,{code:Ee.too_big,message:o.message,inclusive:!0,exact:!1,maximum:o.value,type:"date"}),r.dirty()):Mt.assertNever(o);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new jf({...this._def,checks:[...this._def.checks,e]})}min(e,n){return this._addCheck({kind:"min",value:e.getTime(),message:Ue.toString(n)})}max(e,n){return this._addCheck({kind:"max",value:e.getTime(),message:Ue.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}}jf.create=t=>new jf({checks:[],coerce:(t==null?void 0:t.coerce)||!1,typeName:at.ZodDate,...bt(t)});class uy extends Tt{_parse(e){if(this._getType(e)!==He.symbol){const r=this._getOrReturnCtx(e);return Re(r,{code:Ee.invalid_type,expected:He.symbol,received:r.parsedType}),st}return ui(e.data)}}uy.create=t=>new uy({typeName:at.ZodSymbol,...bt(t)});class cy extends Tt{_parse(e){if(this._getType(e)!==He.undefined){const r=this._getOrReturnCtx(e);return Re(r,{code:Ee.invalid_type,expected:He.undefined,received:r.parsedType}),st}return ui(e.data)}}cy.create=t=>new cy({typeName:at.ZodUndefined,...bt(t)});class dy extends Tt{_parse(e){if(this._getType(e)!==He.null){const r=this._getOrReturnCtx(e);return Re(r,{code:Ee.invalid_type,expected:He.null,received:r.parsedType}),st}return ui(e.data)}}dy.create=t=>new dy({typeName:at.ZodNull,...bt(t)});class fy extends Tt{constructor(){super(...arguments),this._any=!0}_parse(e){return ui(e.data)}}fy.create=t=>new fy({typeName:at.ZodAny,...bt(t)});class hy extends Tt{constructor(){super(...arguments),this._unknown=!0}_parse(e){return ui(e.data)}}hy.create=t=>new hy({typeName:at.ZodUnknown,...bt(t)});class ks extends Tt{_parse(e){const n=this._getOrReturnCtx(e);return Re(n,{code:Ee.invalid_type,expected:He.never,received:n.parsedType}),st}}ks.create=t=>new ks({typeName:at.ZodNever,...bt(t)});class py extends Tt{_parse(e){if(this._getType(e)!==He.undefined){const r=this._getOrReturnCtx(e);return Re(r,{code:Ee.invalid_type,expected:He.void,received:r.parsedType}),st}return ui(e.data)}}py.create=t=>new py({typeName:at.ZodVoid,...bt(t)});class Ki extends Tt{_parse(e){const{ctx:n,status:r}=this._processInputParams(e),i=this._def;if(n.parsedType!==He.array)return Re(n,{code:Ee.invalid_type,expected:He.array,received:n.parsedType}),st;if(i.exactLength!==null){const s=n.data.length>i.exactLength.value,a=n.data.length<i.exactLength.value;(s||a)&&(Re(n,{code:s?Ee.too_big:Ee.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&&(Re(n,{code:Ee.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&&(Re(n,{code:Ee.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 ws(n,s,n.path,a)))).then(s=>Fr.mergeArray(r,s));const o=[...n.data].map((s,a)=>i.type._parseSync(new ws(n,s,n.path,a)));return Fr.mergeArray(r,o)}get element(){return this._def.type}min(e,n){return new Ki({...this._def,minLength:{value:e,message:Ue.toString(n)}})}max(e,n){return new Ki({...this._def,maxLength:{value:e,message:Ue.toString(n)}})}length(e,n){return new Ki({...this._def,exactLength:{value:e,message:Ue.toString(n)}})}nonempty(e){return this.min(1,e)}}Ki.create=(t,e)=>new Ki({type:t,minLength:null,maxLength:null,exactLength:null,typeName:at.ZodArray,...bt(e)});function Va(t){if(t instanceof bn){const e={};for(const n in t.shape){const r=t.shape[n];e[n]=fs.create(Va(r))}return new bn({...t._def,shape:()=>e})}else return t instanceof Ki?new Ki({...t._def,type:Va(t.element)}):t instanceof fs?fs.create(Va(t.unwrap())):t instanceof Ml?Ml.create(Va(t.unwrap())):t instanceof fa?fa.create(t.items.map(e=>Va(e))):t}class bn extends Tt{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=Mt.objectKeys(e);return this._cached={shape:e,keys:n},this._cached}_parse(e){if(this._getType(e)!==He.object){const u=this._getOrReturnCtx(e);return Re(u,{code:Ee.invalid_type,expected:He.object,received:u.parsedType}),st}const{status:r,ctx:i}=this._processInputParams(e),{shape:o,keys:s}=this._getCached(),a=[];if(!(this._def.catchall instanceof ks&&this._def.unknownKeys==="strip"))for(const u in i.data)s.includes(u)||a.push(u);const l=[];for(const u of s){const c=o[u],f=i.data[u];l.push({key:{status:"valid",value:u},value:c._parse(new ws(i,f,i.path,u)),alwaysSet:u in i.data})}if(this._def.catchall instanceof ks){const u=this._def.unknownKeys;if(u==="passthrough")for(const c of a)l.push({key:{status:"valid",value:c},value:{status:"valid",value:i.data[c]}});else if(u==="strict")a.length>0&&(Re(i,{code:Ee.unrecognized_keys,keys:a}),r.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const u=this._def.catchall;for(const c of a){const f=i.data[c];l.push({key:{status:"valid",value:c},value:u._parse(new ws(i,f,i.path,c)),alwaysSet:c in i.data})}}return i.common.async?Promise.resolve().then(async()=>{const u=[];for(const c of l){const f=await c.key,h=await c.value;u.push({key:f,value:h,alwaysSet:c.alwaysSet})}return u}).then(u=>Fr.mergeObjectSync(r,u)):Fr.mergeObjectSync(r,l)}get shape(){return this._def.shape()}strict(e){return Ue.errToObj,new bn({...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:Ue.errToObj(e).message??i}:{message:i}}}:{}})}strip(){return new bn({...this._def,unknownKeys:"strip"})}passthrough(){return new bn({...this._def,unknownKeys:"passthrough"})}extend(e){return new bn({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new bn({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:at.ZodObject})}setKey(e,n){return this.augment({[e]:n})}catchall(e){return new bn({...this._def,catchall:e})}pick(e){const n={};for(const r of Mt.objectKeys(e))e[r]&&this.shape[r]&&(n[r]=this.shape[r]);return new bn({...this._def,shape:()=>n})}omit(e){const n={};for(const r of Mt.objectKeys(this.shape))e[r]||(n[r]=this.shape[r]);return new bn({...this._def,shape:()=>n})}deepPartial(){return Va(this)}partial(e){const n={};for(const r of Mt.objectKeys(this.shape)){const i=this.shape[r];e&&!e[r]?n[r]=i:n[r]=i.optional()}return new bn({...this._def,shape:()=>n})}required(e){const n={};for(const r of Mt.objectKeys(this.shape))if(e&&!e[r])n[r]=this.shape[r];else{let o=this.shape[r];for(;o instanceof fs;)o=o._def.innerType;n[r]=o}return new bn({...this._def,shape:()=>n})}keyof(){return h_(Mt.objectKeys(this.shape))}}bn.create=(t,e)=>new bn({shape:()=>t,unknownKeys:"strip",catchall:ks.create(),typeName:at.ZodObject,...bt(e)});bn.strictCreate=(t,e)=>new bn({shape:()=>t,unknownKeys:"strict",catchall:ks.create(),typeName:at.ZodObject,...bt(e)});bn.lazycreate=(t,e)=>new bn({shape:t,unknownKeys:"strip",catchall:ks.create(),typeName:at.ZodObject,...bt(e)});class qf extends Tt{_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 Io(a.ctx.common.issues));return Re(n,{code:Ee.invalid_union,unionErrors:s}),st}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 u={...n,common:{...n.common,issues:[]},parent:null},c=l._parseSync({data:n.data,path:n.path,parent:u});if(c.status==="valid")return c;c.status==="dirty"&&!o&&(o={result:c,ctx:u}),u.common.issues.length&&s.push(u.common.issues)}if(o)return n.common.issues.push(...o.ctx.common.issues),o.result;const a=s.map(l=>new Io(l));return Re(n,{code:Ee.invalid_union,unionErrors:a}),st}}get options(){return this._def.options}}qf.create=(t,e)=>new qf({options:t,typeName:at.ZodUnion,...bt(e)});function o0(t,e){const n=jo(t),r=jo(e);if(t===e)return{valid:!0,data:t};if(n===He.object&&r===He.object){const i=Mt.objectKeys(e),o=Mt.objectKeys(t).filter(a=>i.indexOf(a)!==-1),s={...t,...e};for(const a of o){const l=o0(t[a],e[a]);if(!l.valid)return{valid:!1};s[a]=l.data}return{valid:!0,data:s}}else if(n===He.array&&r===He.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=o0(s,a);if(!l.valid)return{valid:!1};i.push(l.data)}return{valid:!0,data:i}}else return n===He.date&&r===He.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}class Wf extends Tt{_parse(e){const{status:n,ctx:r}=this._processInputParams(e),i=(o,s)=>{if(oy(o)||oy(s))return st;const a=o0(o.value,s.value);return a.valid?((sy(o)||sy(s))&&n.dirty(),{status:n.value,value:a.data}):(Re(r,{code:Ee.invalid_intersection_types}),st)};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}))}}Wf.create=(t,e,n)=>new Wf({left:t,right:e,typeName:at.ZodIntersection,...bt(n)});class fa extends Tt{_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==He.array)return Re(r,{code:Ee.invalid_type,expected:He.array,received:r.parsedType}),st;if(r.data.length<this._def.items.length)return Re(r,{code:Ee.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),st;!this._def.rest&&r.data.length>this._def.items.length&&(Re(r,{code:Ee.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 ws(r,s,r.path,a)):null}).filter(s=>!!s);return r.common.async?Promise.all(o).then(s=>Fr.mergeArray(n,s)):Fr.mergeArray(n,o)}get items(){return this._def.items}rest(e){return new fa({...this._def,rest:e})}}fa.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new fa({items:t,typeName:at.ZodTuple,rest:null,...bt(e)})};class my extends Tt{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!==He.map)return Re(r,{code:Ee.invalid_type,expected:He.map,received:r.parsedType}),st;const i=this._def.keyType,o=this._def.valueType,s=[...r.data.entries()].map(([a,l],u)=>({key:i._parse(new ws(r,a,r.path,[u,"key"])),value:o._parse(new ws(r,l,r.path,[u,"value"]))}));if(r.common.async){const a=new Map;return Promise.resolve().then(async()=>{for(const l of s){const u=await l.key,c=await l.value;if(u.status==="aborted"||c.status==="aborted")return st;(u.status==="dirty"||c.status==="dirty")&&n.dirty(),a.set(u.value,c.value)}return{status:n.value,value:a}})}else{const a=new Map;for(const l of s){const u=l.key,c=l.value;if(u.status==="aborted"||c.status==="aborted")return st;(u.status==="dirty"||c.status==="dirty")&&n.dirty(),a.set(u.value,c.value)}return{status:n.value,value:a}}}}my.create=(t,e,n)=>new my({valueType:e,keyType:t,typeName:at.ZodMap,...bt(n)});class oc extends Tt{_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==He.set)return Re(r,{code:Ee.invalid_type,expected:He.set,received:r.parsedType}),st;const i=this._def;i.minSize!==null&&r.data.size<i.minSize.value&&(Re(r,{code:Ee.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&&(Re(r,{code:Ee.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 u=new Set;for(const c of l){if(c.status==="aborted")return st;c.status==="dirty"&&n.dirty(),u.add(c.value)}return{status:n.value,value:u}}const a=[...r.data.values()].map((l,u)=>o._parse(new ws(r,l,r.path,u)));return r.common.async?Promise.all(a).then(l=>s(l)):s(a)}min(e,n){return new oc({...this._def,minSize:{value:e,message:Ue.toString(n)}})}max(e,n){return new oc({...this._def,maxSize:{value:e,message:Ue.toString(n)}})}size(e,n){return this.min(e,n).max(e,n)}nonempty(e){return this.min(1,e)}}oc.create=(t,e)=>new oc({valueType:t,minSize:null,maxSize:null,typeName:at.ZodSet,...bt(e)});class gy extends Tt{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})}}gy.create=(t,e)=>new gy({getter:t,typeName:at.ZodLazy,...bt(e)});class vy extends Tt{_parse(e){if(e.data!==this._def.value){const n=this._getOrReturnCtx(e);return Re(n,{received:n.data,code:Ee.invalid_literal,expected:this._def.value}),st}return{status:"valid",value:e.data}}get value(){return this._def.value}}vy.create=(t,e)=>new vy({value:t,typeName:at.ZodLiteral,...bt(e)});function h_(t,e){return new Al({values:t,typeName:at.ZodEnum,...bt(e)})}class Al extends Tt{_parse(e){if(typeof e.data!="string"){const n=this._getOrReturnCtx(e),r=this._def.values;return Re(n,{expected:Mt.joinValues(r),received:n.parsedType,code:Ee.invalid_type}),st}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 Re(n,{received:n.data,code:Ee.invalid_enum_value,options:r}),st}return ui(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 Al.create(e,{...this._def,...n})}exclude(e,n=this._def){return Al.create(this.options.filter(r=>!e.includes(r)),{...this._def,...n})}}Al.create=h_;class by extends Tt{_parse(e){const n=Mt.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==He.string&&r.parsedType!==He.number){const i=Mt.objectValues(n);return Re(r,{expected:Mt.joinValues(i),received:r.parsedType,code:Ee.invalid_type}),st}if(this._cache||(this._cache=new Set(Mt.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const i=Mt.objectValues(n);return Re(r,{received:r.data,code:Ee.invalid_enum_value,options:i}),st}return ui(e.data)}get enum(){return this._def.values}}by.create=(t,e)=>new by({values:t,typeName:at.ZodNativeEnum,...bt(e)});class Kf extends Tt{unwrap(){return this._def.type}_parse(e){const{ctx:n}=this._processInputParams(e);if(n.parsedType!==He.promise&&n.common.async===!1)return Re(n,{code:Ee.invalid_type,expected:He.promise,received:n.parsedType}),st;const r=n.parsedType===He.promise?n.data:Promise.resolve(n.data);return ui(r.then(i=>this._def.type.parseAsync(i,{path:n.path,errorMap:n.common.contextualErrorMap})))}}Kf.create=(t,e)=>new Kf({type:t,typeName:at.ZodPromise,...bt(e)});class Tl extends Tt{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===at.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=>{Re(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 st;const l=await this._def.schema._parseAsync({data:a,path:r.path,parent:r});return l.status==="aborted"?st:l.status==="dirty"||n.value==="dirty"?Cu(l.value):l});{if(n.value==="aborted")return st;const a=this._def.schema._parseSync({data:s,path:r.path,parent:r});return a.status==="aborted"?st:a.status==="dirty"||n.value==="dirty"?Cu(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"?st:(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"?st:(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(!El(s))return st;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=>El(s)?Promise.resolve(i.transform(s.value,o)).then(a=>({status:n.value,value:a})):st);Mt.assertNever(i)}}Tl.create=(t,e,n)=>new Tl({schema:t,typeName:at.ZodEffects,effect:e,...bt(n)});Tl.createWithPreprocess=(t,e,n)=>new Tl({schema:e,effect:{type:"preprocess",transform:t},typeName:at.ZodEffects,...bt(n)});class fs extends Tt{_parse(e){return this._getType(e)===He.undefined?ui(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}fs.create=(t,e)=>new fs({innerType:t,typeName:at.ZodOptional,...bt(e)});class Ml extends Tt{_parse(e){return this._getType(e)===He.null?ui(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Ml.create=(t,e)=>new Ml({innerType:t,typeName:at.ZodNullable,...bt(e)});class s0 extends Tt{_parse(e){const{ctx:n}=this._processInputParams(e);let r=n.data;return n.parsedType===He.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}}s0.create=(t,e)=>new s0({innerType:t,typeName:at.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...bt(e)});class a0 extends Tt{_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 Uf(i)?i.then(o=>({status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new Io(r.common.issues)},input:r.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Io(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}a0.create=(t,e)=>new a0({innerType:t,typeName:at.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...bt(e)});class yy extends Tt{_parse(e){if(this._getType(e)!==He.nan){const r=this._getOrReturnCtx(e);return Re(r,{code:Ee.invalid_type,expected:He.nan,received:r.parsedType}),st}return{status:"valid",value:e.data}}}yy.create=t=>new yy({typeName:at.ZodNaN,...bt(t)});class W6 extends Tt{_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 Zv extends Tt{_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"?st:o.status==="dirty"?(n.dirty(),Cu(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"?st: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 Zv({in:e,out:n,typeName:at.ZodPipeline})}}class l0 extends Tt{_parse(e){const n=this._def.innerType._parse(e),r=i=>(El(i)&&(i.value=Object.freeze(i.value)),i);return Uf(n)?n.then(i=>r(i)):r(n)}unwrap(){return this._def.innerType}}l0.create=(t,e)=>new l0({innerType:t,typeName:at.ZodReadonly,...bt(e)});var at;(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"})(at||(at={}));ks.create;Ki.create;qf.create;Wf.create;fa.create;const ci=Al.create;Kf.create;fs.create;Ml.create;ci(["highlight","note","comment"]);ci(["pending","accepted","dismissed"]);ci(["yellow","green","blue","pink"]);ci(["info","warning","error","success"]);const K6=ci(["solo","tandem"]);ci(["user","claude","import"]);ci(["user","claude"]);ci(["accept","dismiss"]);ci(["markdown","json"]);ci(["md","txt","html","docx"]);ci(["RANGE_GONE","RANGE_MOVED","FILE_LOCKED","FILE_NOT_FOUND","NO_DOCUMENT","INVALID_RANGE","INVALID_ARGUMENT","NOT_FOUND","ANNOTATION_RESOLVED","FORMAT_ERROR","PERMISSION_DENIED"]);ci(["CHANNEL_CONNECT_FAILED","MONITOR_CONNECT_FAILED"]);function G6(t){return t.author!=="user"}function Gf(t){return t.status==="pending"&&G6(t)}function kp(t){return`${t}_${Date.now()}_${Math.random().toString(36).slice(2,8)}`}function u0(){return kp("ann")}function Z6(){return kp("msg")}function cu(){return kp("ntf")}function J6(t){return kp(t)}const Y6="/api/notify-stream",wy="/api/info",X6="/api/open",Q6="/api/close",Jv="/api/save",p_="/api/upload",$6="/api/scratchpad",eM="/api/convert",tM="/api/apply-changes",nM="/api/annotation-reply",rM="/api/remove-annotation",iM="/api/chat",oM="/api/launcher/status",sM="/api/launcher/nonce",aM="/api/launcher/relaunch",lM="/api/launcher/start-fresh",uM="/api/launcher/working-directory",ky=3478,Jl=3479,m_="https://github.com/bloknayrb/tandem",g_=`${m_}/issues/new`,id=new Set([".md",".txt",".html",".htm",".docx"]),cM=3e3,dM=3e3,fM=3e4,v_={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)"},sc={yellow:"var(--tandem-highlight-yellow)",green:"var(--tandem-highlight-green)",blue:"var(--tandem-highlight-blue)",pink:"var(--tandem-highlight-pink)"};function b_(t){return t&&t in v_?t:"yellow"}const xy="tandem",Md="tandem:mode",y_="tandem:settings",hM="tandem-panel-width",pM="tandem-left-panel-width",w_={left:pM,right:hM},k_=1e3,Dl=500,Ol=3e3,mM="__tandem_ctrl__",Ro="annotations",x_="awareness",c0="userAwareness",gM="mode",vM="selectionDwellMs",_y="chat",bf="documentMeta",__="annotationReplies",Cy="savedAtVersion",Sy="authorship",Ey="selection",Ay="activity",d0="claude",du="openDocuments",fu="activeDocumentId",hu="activeDocumentEpoch",xm="generationId",_m="readOnly",Cm="storeReadOnly",C_="tandem:showAuthorship",S_="tandem:decorationVisibility",Yv="tandem:recentFiles",bM=20,Xv="tandem:userName",E_="You",f0="tandem:user-name-changed",xp=40,h0={error:8e3,warning:6e3,info:4e3},yM=5,wM="tandem:activityHistory",A_=50,T_="tandem:tutorialCompleted",M_="tutorial-",D_="tandem:coworkOnboardingSkipped",kM=3e4,zQ=2e3,Ty="tandem:zoomLevel",My=.5,Dy=2,pu=1,qn=`http://127.0.0.1:${Jl}`;function xM(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 _M(t){return t.toLowerCase().endsWith(".docx")}async function O_(t){if(_M(t.name)){const e=await t.arrayBuffer();return xM(e)}return t.text()}const I_=["editor","navigation","view","document","annotations","claude"];let yf=B(Ge(new Map));function CM(t,e={}){if(d(yf).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(yf,new Map(d(yf)).set(t.id,t),!0),!0}function Zf(){return d(yf)}let p0=null;function SM(t){p0=t}function Yt(t,e){if(!p0){console.warn(`[actions] "${t}" invoked before App mounted — deps not wired yet`);return}e(p0)}let m0=B(!1);const EM={get saving(){return d(m0)}};let Sm=!1,Em=!1;const AM=400;function TM(t){return t.connected&&t.tabCount===0&&t.activeTabId===null}async function Jf(){if(!Em){Em=!0;try{const t=await fetch(`${qn}${$6}`,{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{Em=!1}}}function R_(){try{return typeof window<"u"&&"__TAURI_INTERNALS__"in window}catch{return!1}}let Am=!1;function MM(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 DM(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 Oy(t){if(Am)return;const{activeDocId:e,notify:n,defaultName:r,sourceFormat:i}=t;if(!e){n("warning","No active document to save.");return}Am=!0;try{R_()?await OM(e,n,r??"Scratchpad.md"):await IM(e,n,i)}finally{Am=!1}}async function OM(t,e,n){var a;let r;try{const{save:l}=await Mn(async()=>{const{save:u}=await import("./index-Dm_QtxGQ.js");return{save:u}},__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=MM(r,o);s!==r&&e("info",`Saving as ${o.toUpperCase()} — only .md and .txt are supported.`);try{const l=await fetch(`${qn}${Jv}`,{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 u=await l.json().catch(()=>null),c=((a=u==null?void 0:u.data)==null?void 0:a.fileName)??s;e("info",`Saved to ${c}.`)}catch(l){e("error",`Save As request failed: ${l instanceof Error?l.message:l}`)}}async function IM(t,e,n){var i,o;const r=n==="txt"?"txt":"md";try{const s=await fetch(`${qn}${Jv}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({documentId:t,serialize:!0,format:r})});if(!s.ok){const c=await s.json().catch(()=>({}));e("error",`Save As failed: ${c.message??s.statusText}`);return}const a=await s.json().catch(()=>null),l=(i=a==null?void 0:a.data)==null?void 0:i.content,u=((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}DM(l,u,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 g0(t){if(!(!t||Sm)){Sm=!0,y(m0,!0);try{const e=await fetch(`${qn}${Jv}`,{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{Sm=!1,y(m0,!1)}}}let ac=!1;async function RM(){let t;try{t=await fetch(`${qn}${oM}`)}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 NM(){let t;try{t=await fetch(`${qn}${sM}`,{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 PM(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 N_(t,e,n,r){const i=await NM();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(`${qn}${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 P_(t){if(ac)return!1;const e=await RM();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 LM(t){if(!await P_(t))return;const e=PM(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.`)){ac=!0;try{await N_(t,aM,{cwd:e},{failPrefix:"Relaunch failed",requestFailPrefix:"Relaunch request failed",successMessage:`Claude restarting in ${e}.`})}finally{ac=!1}}}async function FM(t){if(await P_(t)&&confirm("Drop Claude's saved conversation and restart fresh. This cannot be undone.")){ac=!0;try{await N_(t,lM,{},{failPrefix:"Start fresh failed",requestFailPrefix:"Start-fresh request failed",successMessage:"Claude restarting with a fresh conversation."})}finally{ac=!1}}}async function zM(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 Mn(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 BM=[{id:"save",label:"Save document",group:"document",shortcut:"Ctrl+S",run(){Yt("save",t=>void g0(t.getActiveTabId()))}},{id:"settings",label:"Open settings",group:"view",shortcut:"Ctrl+,",run(){Yt("settings",t=>t.openSettings())}},{id:"settings-modal",label:"Open settings (new)",group:"view",shortcut:"Ctrl+Shift+,",run(){Yt("settings-modal",t=>t.openSettingsModal())}},{id:"toggle-mode",label:"Toggle Solo / Tandem mode",group:"document",shortcut:"Ctrl+Shift+M",run(){Yt("toggle-mode",t=>t.toggleSoloMode())}},{id:"new-scratchpad",label:"New Scratchpad",group:"document",shortcut:"Ctrl+N",run(){Jf()}},{id:"save-as",label:"Save As…",group:"document",shortcut:"Ctrl+Shift+S",run(){Yt("save-as",t=>void t.saveAs())}},{id:"close-tab",label:"Close active tab",group:"document",shortcut:"Ctrl+W",run(){Yt("close-tab",t=>t.closeActiveTab())}},{id:"open-file",label:"Open file…",group:"document",shortcut:"Ctrl+O",run(){Yt("open-file",t=>t.openFileDialog())}},{id:"find",label:"Find / Replace",group:"navigation",shortcut:"Ctrl+F",run(){Yt("find",t=>t.openFindBar())}},{id:"find-in-tabs",label:"Find in open tabs",group:"navigation",shortcut:"Ctrl+Shift+F",run(){Yt("find-in-tabs",t=>t.openFindBarTabs())}},{id:"find-next",label:"Find next match",group:"navigation",shortcut:"Ctrl+G",run(){Yt("find-next",t=>t.findNext())}},{id:"find-previous",label:"Find previous match",group:"navigation",shortcut:"Ctrl+Shift+G",run(){Yt("find-previous",t=>t.findPrev())}},{id:"toggle-left-panel",label:"Toggle left panel",group:"view",shortcut:"Alt+Shift+Left",run(){Yt("toggle-left-panel",t=>t.toggleLeftPanel())}},{id:"toggle-right-panel",label:"Toggle right panel",group:"view",shortcut:"Alt+Shift+Right",run(){Yt("toggle-right-panel",t=>t.toggleRightPanel())}},{id:"reopen-closed-tab",label:"Reopen closed tab (this session)",group:"document",shortcut:"Ctrl+Alt+T",run(){Yt("reopen-closed-tab",t=>t.reopenClosedTab())}},{id:"annotation-next",label:"Next annotation",group:"annotations",shortcut:"Alt+]",run(){Yt("annotation-next",t=>t.annotationNext())}},{id:"annotation-previous",label:"Previous annotation",group:"annotations",shortcut:"Alt+[",run(){Yt("annotation-previous",t=>t.annotationPrev())}},{id:"annotation-accept",label:"Accept focused annotation",group:"annotations",shortcut:"Ctrl+Enter",run(){Yt("annotation-accept",t=>t.annotationAccept())}},{id:"annotation-dismiss",label:"Dismiss focused annotation",group:"annotations",shortcut:"Ctrl+Shift+Enter",run(){Yt("annotation-dismiss",t=>t.annotationDismiss())}},{id:"select-block",label:"Select containing block",group:"editor",shortcut:"Alt+L",run(){Yt("select-block",t=>t.selectBlock())}},{id:"toggle-authorship",label:"Toggle authorship colors",group:"view",shortcut:"Ctrl+Alt+A",run(){Yt("toggle-authorship",t=>t.toggleAuthorship())}},{id:"toggle-formatting-bar",label:"Toggle formatting bar",group:"view",run(){Yt("toggle-formatting-bar",t=>t.toggleFormattingBar())}},{id:"launcher-relaunch-here",label:"Relaunch Claude in this folder",group:"claude",run(){Yt("launcher-relaunch-here",t=>void LM(t))}},{id:"launcher-start-fresh",label:"Start fresh Claude conversation",group:"claude",run(){Yt("launcher-start-fresh",t=>void FM(t))}},...R_()?[{id:"show-in-file-explorer",label:"Show in file explorer",group:"document",run(){Yt("show-in-file-explorer",t=>void zM(t))}}]:[]];for(const t of BM)CM(t);const ha=["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"],HM=new Set(ha);function L_(t){return HM.has(t)}const v0={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"},VM={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"}},F_=[{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"}],z_={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"},UM=/^(Control|Shift|Alt|Meta|OS)/,jM=new Set(["Tab","Escape","Enter","NumpadEnter","NumLock","CapsLock","ContextMenu","Insert"]);function B_(t){return UM.test(t.code)||t.code.startsWith("Numpad")||jM.has(t.code)?!1:t.ctrlOrMeta||t.alt}function qM(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 B_(e)?e:null}function WM(t,e){return t.ctrlOrMeta===(e.ctrlKey||e.metaKey)&&t.alt===e.altKey&&t.shift===e.shiftKey&&t.code===e.code}function Yf(t,e){return t.ctrlOrMeta===e.ctrlOrMeta&&t.alt===e.alt&&t.shift===e.shift&&t.code===e.code}function KM(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 GM(){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 ZM(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 b0(t){const e=GM(),n=[];return t.ctrlOrMeta&&n.push(e?"⌘":"Ctrl"),t.alt&&n.push(e?"⌥":"Alt"),t.shift&&n.push(e?"⇧":"Shift"),n.push(ZM(t.code)),e?n.join(""):n.join("+")}function Qv(t,e){return e.get(t)??VM[t]}function JM(t){const e=new Map;for(const n of ha)e.set(n,b0(Qv(n,t)));return e}function Ht(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 H_(t,e){if(t.isComposing)return null;if(e&&e.size>0)for(const r of ha){const i=e.get(r);if(i&&WM(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.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 YM(t){return t.code==="Slash"?t.shift?"?":"/":t.code==="Enter"||t.code==="NumpadEnter"?"Enter":""}function XM(t){return{key:YM(t),code:t.code,ctrlKey:t.ctrlOrMeta,metaKey:!1,altKey:t.alt,shiftKey:t.shift,isComposing:!1}}function QM(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 V_(t){const e=H_(XM(t));return!e||L_(e.id)?null:QM(e.id,e.context)||null}function $M(t,e,n){for(const i of ha)if(i!==n&&Yf(Qv(i,e),t))return v0[i];const r=V_(t);if(r)return r;for(const i of F_)if(Yf(i.chord,t))return i.label;return null}function eD(t){return F_.some(e=>Yf(e.chord,t))}function $v(t){if(!t||typeof t!="object"||Array.isArray(t))return{};const e={};for(const[i,o]of Object.entries(t))L_(i)&&KM(o)&&B_(o)&&(eD(o)||V_(o)||(e[i]=o));const n={},r=[];for(const i of ha){const o=e[i];o&&(r.some(s=>Yf(s,o))||(r.push(o),n[i]=o))}return n}function U_(t){const e=new Map;for(const[n,r]of Object.entries($v(t)))e.set(n,r);return e}function j_(t){return t.type==="save-error"&&t.documentId?{label:"Retry",documentId:t.documentId}:null}const q_={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 tD(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 nD=M('<button type="button" data-testid="activity-clear-all" class="svelte-bf7dij">Clear all</button>'),rD=M('<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>'),iD=Er("<path></path>"),oD=M('<span class="badge svelte-bf7dij"> </span>'),sD=M('<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>'),aD=M('<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>'),lD=M('<div class="tray-list svelte-bf7dij"></div>'),uD=M('<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>'),cD=M('<span class="svelte-bf7dij">No activity</span>'),dD=M('<span class="svelte-bf7dij">Activity</span> <span class="count svelte-bf7dij"> </span>',1),fD=M('<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 hD(t,e){ze(e,!0);const n=F(()=>e.items.length),r=F(()=>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=B(Ge(Date.now()));const o=setInterval(()=>{y(i,Date.now(),!0)},3e4);lr(()=>clearInterval(o));var s=fD(),a=w(s);{var l=m=>{var v=uD(),g=w(v),b=k(w(g),2),x=w(b),_=k(b,4);{var T=D=>{var P=nD();N("click",P,function(...R){var H;(H=e.onClear)==null||H.apply(this,R)}),C(D,P)};G(_,D=>{d(n)>0&&D(T)})}var S=k(g,2);{var z=D=>{var P=rD();C(D,P)},E=D=>{var P=lD();Je(P,21,()=>e.items,R=>R.id,(R,H)=>{const Q=F(()=>j_(d(H)));var Z=aD(),$=w(Z),W=w($);Je(W,20,()=>q_[d(H).severity],J=>J,(J,K)=>{var ne=iD();q(()=>U(ne,"d",K)),C(J,ne)});var te=k($,2),ae=w(te),re=w(ae),ue=w(re),oe=k(re,2);{var fe=J=>{var K=oD(),ne=w(K);q(()=>ee(ne,`×${d(H).count??""}`)),C(J,K)};G(oe,J=>{d(H).count>1&&J(fe)})}var I=k(oe,2),O=w(I),A=k(ae,2);{var V=J=>{var K=sD(),ne=k(w(K));q(()=>{U(K,"data-testid",`activity-action-${d(H).id}`),ee(ne,` ${d(Q).label??""}`)}),N("click",K,()=>e.onAction(d(H))),C(J,K)};G(A,J=>{d(Q)&&J(V)})}var L=k(te,2);q(J=>{At(Z,1,`toast-row ${d(H).severity??""}`,"svelte-bf7dij"),U(Z,"data-testid",`activity-row-${d(H).id}`),ee(ue,d(H).message),ee(O,J),U(L,"data-testid",`activity-dismiss-${d(H).id}`)},[()=>tD(d(H).timestamp,d(i))]),N("click",L,()=>e.onDismiss(d(H).id)),C(R,Z)}),C(D,P)};G(S,D=>{d(n)===0?D(z):D(E,-1)})}q(()=>ee(x,d(n)===0?"No events":`${d(n)} event${d(n)===1?"":"s"}`)),C(m,v)};G(a,m=>{e.open&&m(l)})}var u=k(a,2);let c;var f=k(w(u),2);{var h=m=>{var v=cD();C(m,v)},p=m=>{var v=dD(),g=k(Se(v),2),b=w(g);q(()=>ee(b,d(n))),C(m,v)};G(f,m=>{d(n)===0?m(h):m(p,-1)})}q(()=>{c=At(u,1,`activity-pill ${d(r)??""}`,"svelte-bf7dij",c,{open:e.open}),U(u,"aria-expanded",e.open),U(u,"aria-controls",e.open?"activity-tray":void 0)}),N("click",u,function(...m){var v;(v=e.onToggle)==null||v.apply(this,m)}),C(t,s),Be()}We(["click"]);function Nn(t){this.content=t}Nn.prototype={constructor:Nn,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 Nn(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 Nn(n)},addToStart:function(t,e){return new Nn([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new Nn(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 Nn(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=Nn.from(t),t.size?new Nn(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=Nn.from(t),t.size?new Nn(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=Nn.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}};Nn.from=function(t){if(t instanceof Nn)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new Nn(e)};function W_(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=W_(i.content,o.content,n+1);if(s!=null)return s}n+=i.nodeSize}}function K_(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 u=0,c=Math.min(s.text.length,a.text.length);for(;u<c&&s.text[s.text.length-u-1]==a.text[a.text.length-u-1];)u++,n--,r--;return{a:n,b:r}}if(s.content.size||a.content.size){let u=K_(s.content,a.content,n-1,r-1);if(u)return u}n-=l,r-=l}}class ge{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],u=a+l.nodeSize;if(u>e&&r(l,i+a,o||null,s)!==!1&&l.content.size){let c=a+1;l.nodesBetween(Math.max(0,e-c),Math.min(l.content.size,n-c),r,i+c)}a=u}}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 u=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&&u||a.isTextblock)&&r&&(s?s=!1:o+=r),o+=u},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 ge(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 ge(r,i)}cutByIndex(e,n){return e==n?ge.empty:e==0&&n==this.content.length?this:new ge(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 ge(i,o)}addToStart(e){return new ge([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new ge(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 W_(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return K_(this,e,n,r)}findIndex(e){if(e==0)return Dd(0,e);if(e==this.size)return Dd(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?Dd(n+1,o):Dd(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 ge.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new ge(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return ge.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 ge(n||e,r)}static from(e){if(!e)return ge.empty;if(e instanceof ge)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new ge([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}ge.empty=new ge([],0);const Tm={index:0,offset:0};function Dd(t,e){return Tm.index=t,Tm.offset=e,Tm}function Xf(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(!Xf(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!Xf(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}let It=class y0{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&&Xf(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 y0.none;if(e instanceof y0)return[e];let n=e.slice();return n.sort((r,i)=>r.type.rank-i.type.rank),n}};It.none=[];class Qf extends Error{}class Te{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=Z_(this.content,e+this.openStart,n);return r&&new Te(r,this.openStart,this.openEnd)}removeBetween(e,n){return new Te(G_(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 Te.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 Te(ge.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 Te(e,r,i)}}Te.empty=new Te(ge.empty,0,0);function G_(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(G_(o.content,e-i-1,n-i-1)))}function Z_(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=Z_(s.content,e-o-1,n,s);return a&&t.replaceChild(i,s.copy(a))}function pD(t,e,n){if(n.openStart>t.depth)throw new Qf("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new Qf("Inconsistent open depths");return J_(t,e,n,0)}function J_(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=J_(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 ia(s,a.cut(0,t.parentOffset).append(n.content).append(a.cut(e.parentOffset)))}else{let{start:s,end:a}=mD(n,t);return ia(o,X_(t,s,a,e,r))}else return ia(o,$f(t,e,r))}function Y_(t,e){if(!e.type.compatibleContent(t.type))throw new Qf("Cannot join "+e.type.name+" onto "+t.type.name)}function w0(t,e,n){let r=t.node(n);return Y_(r,e.node(n)),r}function ra(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 Nu(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&&(ra(t.nodeAfter,r),o++));for(let a=o;a<s;a++)ra(i.child(a),r);e&&e.depth==n&&e.textOffset&&ra(e.nodeBefore,r)}function ia(t,e){return t.type.checkContent(e),t.copy(e)}function X_(t,e,n,r,i){let o=t.depth>i&&w0(t,e,i+1),s=r.depth>i&&w0(n,r,i+1),a=[];return Nu(null,t,i,a),o&&s&&e.index(i)==n.index(i)?(Y_(o,s),ra(ia(o,X_(t,e,n,r,i+1)),a)):(o&&ra(ia(o,$f(t,e,i+1)),a),Nu(e,n,i,a),s&&ra(ia(s,$f(n,r,i+1)),a)),Nu(r,null,i,a),new ge(a)}function $f(t,e,n){let r=[];if(Nu(null,t,n,r),t.depth>n){let i=w0(t,e,n+1);ra(ia(i,$f(t,e,n+1)),r)}return Nu(e,null,n,r),new ge(r)}function mD(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(ge.from(i));return{start:i.resolveNoCache(t.openStart+n),end:i.resolveNoCache(i.content.size-t.openEnd-n)}}class lc{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 It.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 eh(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),u=o-l;if(r.push(s,a,i+l),!u||(s=s.child(a),s.isText))break;o=u-1,i+=l+1}return new lc(n,r,o)}static resolveCached(e,n){let r=Iy.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 Iy.set(e,r=new gD);let i=r.elts[r.i]=lc.resolve(e,n);return r.i=(r.i+1)%vD,i}}class gD{constructor(){this.elts=[],this.i=0}}const vD=12,Iy=new WeakMap;class eh{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 bD=Object.create(null);let hs=class k0{constructor(e,n,r,i=It.none){this.type=e,this.attrs=n,this.marks=i,this.content=r||ge.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&&Xf(this.attrs,n||e.defaultAttrs||bD)&&It.sameSet(this.marks,r||It.none)}copy(e=null){return e==this.content?this:new k0(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new k0(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 Te.empty;let i=this.resolve(e),o=this.resolve(n),s=r?0:i.sharedDepth(n),a=i.start(s),u=i.node(s).content.cut(i.pos-a,o.pos-a);return new Te(u,i.depth-s,o.depth-s)}replace(e,n,r){return pD(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 lc.resolveCached(this,e)}resolveNoCache(e){return lc.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()+")"),Q_(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=ge.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=It.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(!It.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=ge.fromJSON(e,n.content),o=e.nodeType(n.type).create(n.attrs,i,r);return o.type.checkAttrs(o.attrs),o}};hs.prototype.text=void 0;class th extends hs{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):Q_(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 th(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new th(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 Q_(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class pa{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new yD(e,n);if(r.next==null)return pa.empty;let i=$_(r);r.next&&r.err("Unexpected trailing text");let o=ED(SD(i));return AD(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 ge.from(a.map(u=>u.createAndFill()));for(let u=0;u<s.next.length;u++){let{type:c,next:f}=s.next[u];if(!(c.isText||c.hasRequiredAttrs())&&i.indexOf(f)==-1){i.push(f);let h=o(f,a.concat(c));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
|
+
`)}}pa.empty=new pa(!0);class yD{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 $_(t){let e=[];do e.push(wD(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function wD(t){let e=[];do e.push(kD(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function kD(t){let e=CD(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=xD(t,e);else break;return e}function Ry(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function xD(t,e){let n=Ry(t),r=n;return t.eat(",")&&(t.next!="}"?r=Ry(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function _D(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 CD(t){if(t.eat("(")){let e=$_(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=_D(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 SD(t){let e=[[]];return i(o(t,0),n()),e;function n(){return e.push([])-1}function r(s,a,l){let u={term:l,to:a};return e[s].push(u),u}function i(s,a){s.forEach(l=>l.to=a)}function o(s,a){if(s.type=="choice")return s.exprs.reduce((l,u)=>l.concat(o(u,a)),[]);if(s.type=="seq")for(let l=0;;l++){let u=o(s.exprs[l],a);if(l==s.exprs.length-1)return u;i(u,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 u=0;u<s.min;u++){let c=n();i(o(s.expr,l),c),l=c}if(s.max==-1)i(o(s.expr,l),l);else for(let u=s.min;u<s.max;u++){let c=n();r(l,c),i(o(s.expr,l),c),l=c}return[r(l)]}else{if(s.type=="name")return[r(a,void 0,s.value)];throw new Error("Unknown expr type")}}}}function eC(t,e){return e-t}function Ny(t,e){let n=[];return r(e),n.sort(eC);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 ED(t){let e=Object.create(null);return n(Ny(t,0));function n(r){let i=[];r.forEach(s=>{t[s].forEach(({term:a,to:l})=>{if(!a)return;let u;for(let c=0;c<i.length;c++)i[c][0]==a&&(u=i[c][1]);Ny(t,l).forEach(c=>{u||i.push([a,u=[]]),u.indexOf(c)==-1&&u.push(c)})})});let o=e[r.join(",")]=new pa(r.indexOf(t.length-1)>-1);for(let s=0;s<i.length;s++){let a=i[s][1].sort(eC);o.next.push({type:i[s][0],next:e[a.join(",")]||n(a)})}return o}}function AD(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:u}=i.next[a];s.push(l.name),o&&!(l.isText||l.hasRequiredAttrs())&&(o=!1),r.indexOf(u)==-1&&r.push(u)}o&&e.err("Only non-generatable nodes ("+s.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function tC(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 rC(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 iC(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new MD(t,r,e[r]);return n}let Py=class oC{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=iC(e,r.attrs),this.defaultAttrs=tC(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==pa.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 hs(this,this.computeAttrs(e),ge.from(n),It.setFrom(r))}createChecked(e=null,n,r){return n=ge.from(n),this.checkContent(n),new hs(this,this.computeAttrs(e),n,It.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=ge.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(ge.empty,!0);return o?new hs(this,e,n.append(o),It.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){rC(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:It.none:e}static compile(e,n){let r=Object.create(null);e.forEach((o,s)=>r[o]=new oC(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 TD(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 MD{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?TD(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class _p{constructor(e,n,r,i){this.name=e,this.rank=n,this.schema=r,this.spec=i,this.attrs=iC(e,i.attrs),this.excluded=null;let o=tC(this.attrs);this.instance=o?new It(this,o):null}create(e=null){return!e&&this.instance?this.instance:new It(this,nC(this.attrs,e))}static compile(e,n){let r=Object.create(null),i=0;return e.forEach((o,s)=>r[o]=new _p(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){rC(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}let eb=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=Nn.from(e.nodes),n.marks=Nn.from(e.marks||{}),this.nodes=Py.compile(this.spec.nodes,this),this.marks=_p.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]=pa.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?Ly(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==""?[]:Ly(this,s.split(" "))}this.nodeFromJSON=i=>hs.fromJSON(this,i),this.markFromJSON=i=>It.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 Py){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 th(r,r.defaultAttrs,e,It.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 Ly(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 DD(t){return t.tag!=null}function OD(t){return t.style!=null}let Pu=class x0{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(i=>{if(DD(i))this.tags.push(i);else if(OD(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 zy(this,n,!1);return r.addAll(e,It.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new zy(this,n,!0);return r.addAll(e,It.none,n.from,n.to),Te.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(ND(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=By(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=By(s)),s.node||s.ignore||s.mark||(s.node=i)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new x0(e,x0.schemaRules(e)))}};const sC={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},ID={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},aC={ol:!0,ul:!0},uc=1,_0=2,Lu=4;function Fy(t,e,n){return e!=null?(e?uc:0)|(e==="full"?_0:0):t&&t.whitespace=="pre"?uc|_0:n&~Lu}class Od{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=It.none,this.match=o||(s&Lu?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(ge.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&uc)){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=ge.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(ge.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&&!sC.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class zy{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=Fy(null,n.preserveWhitespace,0)|(r?Lu:0);i?o=new Od(i.type,i.attrs,It.none,!0,n.topMatch||i.type.contentMatch,s):r?o=new Od(null,null,It.none,!0,null,s):o=new Od(e.schema.topNodeType,null,It.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&_0?"full":this.localPreserveWS||(i.options&uc)>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;aC.hasOwnProperty(s)&&this.parser.normalizeLists&&RD(e);let l=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(a=this.parser.matchTag(e,this,r));e:if(l?l.ignore:ID.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 u,c=this.needsBlock;if(sC.hasOwnProperty(s))o.content.length&&o.content[0].isInline&&this.open&&(this.open--,o=this.top),u=!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),u&&this.sync(o),this.needsBlock=c}else{let u=this.readStyles(e,n);u&&this.addElementByRule(e,l,u,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(u=>!l.clearMark(u)):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],u=l.findWrapping(e);if(u&&(!i||i.length>u.length+a)&&(i=u,o=l,!u.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=It.none;for(let a of i.concat(e.marks))(o.type?o.type.allowsMarkType(a.type):Hy(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=Fy(e,o,s.options);s.options&Lu&&s.content.length==0&&(a|=Lu);let l=It.none;return r=r.filter(u=>(s.type?s.type.allowsMarkType(u.type):Hy(u.type,e))?(l=u.addToSet(l),!1):!0),this.nodes.push(new Od(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|=uc)}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 u=n[a];if(u==""){if(a==n.length-1||a==0)continue;for(;l>=o;l--)if(s(a-1,l))return!0;return!1}else{let c=l>0||l==0&&i?this.nodes[l].type:r&&l>=o?r.node(l-o).type:null;if(!c||c.name!=u&&!c.isInGroup(u))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 RD(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&aC.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function ND(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function By(t){let e={};for(let n in t)e[n]=t[n];return e}function Hy(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:u,next:c}=a.edge(l);if(u==e||o.indexOf(c)<0&&s(c))return!0}};if(s(i.contentMatch))return!0}}class Da{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=Mm(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 u=s.marks[l];if(!this.marks[u.type.name]){l++;continue}if(!u.eq(o[a][0])||u.type.spec.spanning===!1)break;a++,l++}for(;a<o.length;)i=o.pop()[1];for(;l<s.marks.length;){let u=s.marks[l++],c=this.serializeMark(u,s.isInline,n);c&&(o.push([u,i]),i.appendChild(c.dom),i=c.contentDOM||c.dom)}}i.appendChild(this.serializeNodeInner(s,n))}),r}serializeNodeInner(e,n){let{dom:r,contentDOM:i}=wf(Mm(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&&wf(Mm(r),i(e,n),null,e.attrs)}static renderSpec(e,n,r=null,i){return wf(e,n,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Da(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=Vy(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return Vy(e.marks)}}function Vy(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function Mm(t){return t.document||window.document}const Uy=new WeakMap;function PD(t){let e=Uy.get(t);return e===void 0&&Uy.set(t,e=LD(t)),e}function LD(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 wf(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=PD(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),u=e[1],c=1;if(u&&typeof u=="object"&&u.nodeType==null&&!Array.isArray(u)){c=2;for(let f in u)if(u[f]!=null){let h=f.indexOf(" ");h>0?l.setAttributeNS(f.slice(0,h),f.slice(h+1),u[f]):f=="style"&&l.style?l.style.cssText=u[f]:l.setAttribute(f,u[f])}}for(let f=c;f<e.length;f++){let h=e[f];if(h===0){if(f<e.length-1||f>c)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}=wf(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 lC=65535,uC=Math.pow(2,16);function FD(t,e){return t+e*uC}function jy(t){return t&lC}function zD(t){return(t-(t&lC))/uC}const cC=1,dC=2,kf=4,fC=8;class C0{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&fC)>0}get deletedBefore(){return(this.delInfo&(cC|kf))>0}get deletedAfter(){return(this.delInfo&(dC|kf))>0}get deletedAcross(){return(this.delInfo&kf)>0}}class Pr{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&Pr.empty)return Pr.empty}recover(e){let n=0,r=jy(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+zD(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 u=this.ranges[a+o],c=this.ranges[a+s],f=l+u;if(e<=f){let h=u?e==l?-1:e==f?1:n:n,p=l+i+(h<0?0:c);if(r)return p;let m=e==(n<0?l:f)?null:FD(a/3,e-l),v=e==l?dC:e==f?cC:kf;return(n<0?e!=l:e!=f)&&(v|=fC),new C0(p,v,m)}i+=c-u}return r?e+i:new C0(e+i,0,null)}touches(e,n){let r=0,i=jy(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 u=this.ranges[a+o],c=l+u;if(e<=c&&a==i*3)return!0;r+=this.ranges[a+s]-u}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),u=this.ranges[i+n],c=this.ranges[i+r];e(a,a+u,l,l+c),o+=c-u}}invert(){return new Pr(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?Pr.empty:new Pr(e<0?[0,-e,0]:[0,0,e])}}Pr.empty=new Pr([]);class cc{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 cc(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 cc;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 C0(e,i,null)}}const Dm=Object.create(null);class Qn{getMap(){return Pr.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=Dm[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 Dm)throw new RangeError("Duplicate use of step JSON ID "+e);return Dm[e]=n,n.prototype.jsonID=e,n}}class fn{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new fn(e,null)}static fail(e){return new fn(null,e)}static fromReplace(e,n,r,i){try{return fn.ok(e.replace(n,r,i))}catch(o){if(o instanceof Qf)return fn.fail(o.message);throw o}}}function tb(t,e,n){let r=[];for(let i=0;i<t.childCount;i++){let o=t.child(i);o.content.size&&(o=o.copy(tb(o.content,e,o))),o.isInline&&(o=e(o,n,i)),r.push(o)}return ge.fromArray(r)}class is extends Qn{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 Te(tb(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 fn.fromReplace(e,this.from,this.to,o)}invert(){return new Hi(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 is(n.pos,r.pos,this.mark)}merge(e){return e instanceof is&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new is(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 is(n.from,n.to,e.markFromJSON(n.mark))}}Qn.jsonID("addMark",is);class Hi extends Qn{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 Te(tb(n.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),n.openStart,n.openEnd);return fn.fromReplace(e,this.from,this.to,r)}invert(){return new is(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 Hi(n.pos,r.pos,this.mark)}merge(e){return e instanceof Hi&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Hi(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 Hi(n.from,n.to,e.markFromJSON(n.mark))}}Qn.jsonID("removeMark",Hi);class ss extends Qn{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return fn.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return fn.fromReplace(e,this.pos,this.pos+1,new Te(ge.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 ss(this.pos,n.marks[i]);return new ss(this.pos,this.mark)}}return new ma(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new ss(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 ss(n.pos,e.markFromJSON(n.mark))}}Qn.jsonID("addNodeMark",ss);class ma extends Qn{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return fn.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return fn.fromReplace(e,this.pos,this.pos+1,new Te(ge.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new ss(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new ma(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 ma(n.pos,e.markFromJSON(n.mark))}}Qn.jsonID("removeNodeMark",ma);class _n extends Qn{constructor(e,n,r,i=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=i}apply(e){return this.structure&&S0(e,this.from,this.to)?fn.fail("Structure replace would overwrite content"):fn.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Pr([this.from,this.to-this.from,this.slice.size])}invert(e){return new _n(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 _n(n.pos,Math.max(n.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof _n)||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?Te.empty:new Te(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new _n(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?Te.empty:new Te(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new _n(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 _n(n.from,n.to,Te.fromJSON(e,n.slice),!!n.structure)}}Qn.jsonID("replace",_n);class En extends Qn{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&&(S0(e,this.from,this.gapFrom)||S0(e,this.gapTo,this.to)))return fn.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return fn.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?fn.fromReplace(e,this.from,this.to,r):fn.fail("Content does not fit in gap")}getMap(){return new Pr([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 En(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 En(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 En(n.from,n.to,n.gapFrom,n.gapTo,Te.fromJSON(e,n.slice),n.insert,!!n.structure)}}Qn.jsonID("replaceAround",En);function S0(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 BD(t,e,n,r){let i=[],o=[],s,a;t.doc.nodesBetween(e,n,(l,u,c)=>{if(!l.isInline)return;let f=l.marks;if(!r.isInSet(f)&&c.type.allowsMarkType(r.type)){let h=Math.max(u,e),p=Math.min(u+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 Hi(h,p,f[v])));a&&a.to==h?a.to=p:o.push(a=new is(h,p,r))}}),i.forEach(l=>t.step(l)),o.forEach(l=>t.step(l))}function HD(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 _p){let u=s.marks,c;for(;c=r.isInSet(u);)(l||(l=[])).push(c),u=c.removeFromSet(u)}else r?r.isInSet(s.marks)&&(l=[r]):l=s.marks;if(l&&l.length){let u=Math.min(a+s.nodeSize,n);for(let c=0;c<l.length;c++){let f=l[c],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=u,h.step=o):i.push({style:f,from:Math.max(a,e),to:u,step:o})}}}),i.forEach(s=>t.step(new Hi(s.from,s.to,s.style)))}function nb(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 u=o.child(l),c=a+u.nodeSize,f=r.matchType(u.type);if(!f)s.push(new _n(a,c,Te.empty));else{r=f;for(let h=0;h<u.marks.length;h++)n.allowsMarkType(u.marks[h].type)||t.step(new Hi(a,c,u.marks[h]));if(i&&u.isText&&n.whitespace!="pre"){let h,p=/\r?\n|\r/g,m;for(;h=p.exec(u.text);)m||(m=new Te(ge.from(n.schema.text(" ",n.allowedMarks(u.marks))),0,0)),s.push(new _n(a+h.index,a+h.index+h[0].length,m))}}a=c}if(!r.validEnd){let l=r.fillBefore(ge.empty,!0);t.replace(a,a,new Te(l,0,0))}for(let l=s.length-1;l>=0;l--)t.step(s[l])}function VD(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function Yl(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||!VD(s,a,l))break;a&&(i=1),l<s.childCount&&(o=1)}return null}function UD(t,e,n){let{$from:r,$to:i,depth:o}=e,s=r.before(o+1),a=i.after(o+1),l=s,u=a,c=ge.empty,f=0;for(let m=o,v=!1;m>n;m--)v||r.index(m)>0?(v=!0,c=ge.from(r.node(m).copy(c)),f++):l--;let h=ge.empty,p=0;for(let m=o,v=!1;m>n;m--)v||i.after(m+1)<i.end(m)?(v=!0,h=ge.from(i.node(m).copy(h)),p++):u++;t.step(new En(l,u,s,a,new Te(c.append(h),f,p),c.size-f,!0))}function rb(t,e,n=null,r=t){let i=jD(t,e),o=i&&qD(r,e);return o?i.map(qy).concat({type:e,attrs:n}).concat(o.map(qy)):null}function qy(t){return{type:t,attrs:null}}function jD(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 qD(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 u=r;l&&u<i;u++)l=l.matchType(n.child(u).type);return!l||!l.validEnd?null:s}function WD(t,e,n){let r=ge.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=ge.from(n[s].type.create(n[s].attrs,r))}let i=e.start,o=e.end;t.step(new En(i,o,i,o,new Te(r,0,0),n.length,!0))}function KD(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)&&GD(t.doc,t.mapping.slice(o).map(a),r)){let u=null;if(r.schema.linebreakReplacement){let p=r.whitespace=="pre",m=!!r.contentMatch.matchType(r.schema.linebreakReplacement);p&&!m?u=!1:!p&&m&&(u=!0)}u===!1&&pC(t,s,a,o),nb(t,t.mapping.slice(o).map(a,1),r,void 0,u===null);let c=t.mapping.slice(o),f=c.map(a,1),h=c.map(a+s.nodeSize,1);return t.step(new En(f,h,f+1,h-1,new Te(ge.from(r.create(l,null,s.marks)),0,0),1,!0)),u===!0&&hC(t,s,a,o),!1}})}function hC(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 pC(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 GD(t,e,n){let r=t.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function ZD(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 En(e,e+o.nodeSize,e+1,e+o.nodeSize-1,new Te(ge.from(s),0,0),1,!0))}function Co(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 u=i.depth-1,c=n-2;u>o;u--,c--){let f=i.node(u),h=i.index(u);if(f.type.spec.isolating)return!1;let p=f.content.cutByIndex(h,f.childCount),m=r&&r[c+1];m&&(p=p.replaceChild(0,m.type.create(m.attrs)));let v=r&&r[c]||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 JD(t,e,n=1,r){let i=t.doc.resolve(e),o=ge.empty,s=ge.empty;for(let a=i.depth,l=i.depth-n,u=n-1;a>l;a--,u--){o=ge.from(i.node(a).copy(o));let c=r&&r[u];s=ge.from(c?c.type.create(c.attrs,s):i.node(a).copy(s))}t.step(new _n(e,e,new Te(o.append(s),n,n),!0))}function Ms(t,e){let n=t.resolve(e),r=n.index();return mC(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function YD(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 mC(t,e){return!!(t&&e&&!t.isLeaf&&YD(t,e))}function Cp(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&&mC(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 XD(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 c=s.whitespace=="pre",f=!!s.contentMatch.matchType(i);c&&!f?r=!1:!c&&f&&(r=!0)}let a=t.steps.length;if(r===!1){let c=t.doc.resolve(e+n);pC(t,c.node(),c.before(),a)}s.inlineContent&&nb(t,e+n-1,s,o.node().contentMatchAt(o.index()),r==null);let l=t.mapping.slice(a),u=l.map(e-n);if(t.step(new _n(u,l.map(e+n,-1),Te.empty,!0)),r===!0){let c=t.doc.resolve(u);hC(t,c.node(),c.before(),t.steps.length)}return t}function QD(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 gC(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),u=r.node(s),c=!1;if(o==1)c=u.canReplace(l,l,i);else{let f=u.contentMatchAt(l).findWrapping(i.firstChild.type);c=f&&u.canReplaceWith(l,l,f[0])}if(c)return a==0?r.pos:a<0?r.before(s+1):r.after(s+1)}return null}function Sp(t,e,n=e,r=Te.empty){if(e==n&&!r.size)return null;let i=t.resolve(e),o=t.resolve(n);return vC(i,o,r)?new _n(e,n,r):new $D(i,o,r).fit()}function vC(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class $D{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=ge.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=ge.from(e.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let u=this.findFittable();u?this.placeNodes(u):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 Te(o,s,a);return e>-1?new En(r.pos,e,this.$to.pos,this.$to.end(),l,n):l.size||r.pos!=this.$to.pos?new _n(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=Om(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:u}=this.frontier[a],c,f=null;if(n==1&&(s?u.matchType(s.type)||(f=u.fillBefore(ge.from(s),!1)):o&&l.compatibleContent(o.type)))return{sliceDepth:r,frontierDepth:a,parent:o,inject:f};if(n==2&&s&&(c=u.findWrapping(s.type)))return{sliceDepth:r,frontierDepth:a,parent:o,wrap:c};if(o&&u.matchType(o.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced,i=Om(e,n);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new Te(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=Om(e,n);if(i.childCount<=1&&n>0){let o=e.size-n<=n+i.size;this.unplaced=new Te(Su(e,n-1,1),n-1,o?n-1:r)}else this.unplaced=new Te(Su(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,u=0,c=[],{match:f,type:h}=this.frontier[n];if(i){for(let v=0;v<i.childCount;v++)c.push(i.child(v));f=f.matchFragment(i)}let p=a.size+e-(s.content.size-s.openEnd);for(;u<a.childCount;){let v=a.child(u),g=f.matchType(v.type);if(!g)break;u++,(u>1||l==0||v.content.size)&&(f=g,c.push(bC(v.mark(h.allowedMarks(v.marks)),u==1?l:0,u==a.childCount?p:-1)))}let m=u==a.childCount;m||(p=-1),this.placed=Eu(this.placed,n,ge.from(c)),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?Te.empty:new Te(Su(s.content,e-1,1),e-1,p<0?s.openEnd:e-1):new Te(Su(s.content,e,u),s.openStart,s.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],n;if(!e.type.isTextblock||!Im(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=Im(e,n,i,r,o);if(s){for(let a=n-1;a>=0;a--){let{match:l,type:u}=this.frontier[a],c=Im(e,a,u,l,!0);if(!c||c.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=Eu(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=Eu(this.placed,this.depth,ge.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(ge.empty,!0);n.childCount&&(this.placed=Eu(this.placed,this.frontier.length,n))}}function Su(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(Su(t.firstChild.content,e-1,n)))}function Eu(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(Eu(t.lastChild.content,e-1,n)))}function Om(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function bC(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,bC(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(ge.empty,!0)))),t.copy(r)}function Im(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&&!eO(n,o.content,s)?a:null}function eO(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}function tO(t){return t.spec.defining||t.spec.definingForContent}function nO(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let i=t.doc.resolve(e),o=t.doc.resolve(n);if(vC(i,o,r))return t.step(new _n(e,n,r));let s=wC(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),u=[],c=r.openStart;for(let h=r.content,p=0;;p++){let m=h.firstChild;if(u.push(m),p==r.openStart)break;h=m.content}for(let h=c-1;h>=0;h--){let p=u[h],m=tO(p.type);if(m&&!p.sameMarkup(i.node(Math.abs(a)-1)))c=h;else if(m||!p.type.isTextblock)break}for(let h=r.openStart;h>=0;h--){let p=(h+c+1)%(r.openStart+1),m=u[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 x=i.node(g-1),_=i.index(g-1);if(x.canReplaceWith(_,_,m.type,m.marks))return t.replace(i.before(g),b?o.after(g):n,new Te(yC(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 yC(t,e,n,r,i){if(e<n){let o=t.firstChild;t=t.replaceChild(0,o.copy(yC(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(ge.empty,!0))}return t}function rO(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let i=QD(t.doc,e,r.type);i!=null&&(e=n=i)}t.replaceRange(e,n,new Te(ge.from(r),0,0))}function iO(t,e,n){let r=t.doc.resolve(e),i=t.doc.resolve(n),o=wC(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 wC(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 $a extends Qn{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 fn.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 fn.fromReplace(e,this.pos,this.pos+1,new Te(ge.from(i),0,n.isLeaf?0:1))}getMap(){return Pr.empty}invert(e){return new $a(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 $a(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 $a(n.pos,n.attr,n.value)}}Qn.jsonID("attr",$a);class dc extends Qn{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 fn.ok(r)}getMap(){return Pr.empty}invert(e){return new dc(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 dc(n.attr,n.value)}}Qn.jsonID("docAttr",dc);let Il=class extends Error{};Il=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};Il.prototype=Object.create(Error.prototype);Il.prototype.constructor=Il;Il.prototype.name="TransformError";class ib{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new cc}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new Il(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=Te.empty){let i=Sp(this.doc,e,n,r);return i&&this.step(i),this}replaceWith(e,n,r){return this.replace(e,n,new Te(ge.from(r),0,0))}delete(e,n){return this.replace(e,n,Te.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return nO(this,e,n,r),this}replaceRangeWith(e,n,r){return rO(this,e,n,r),this}deleteRange(e,n){return iO(this,e,n),this}lift(e,n){return UD(this,e,n),this}join(e,n=1){return XD(this,e,n),this}wrap(e,n){return WD(this,e,n),this}setBlockType(e,n=e,r,i=null){return KD(this,e,n,r,i),this}setNodeMarkup(e,n,r=null,i){return ZD(this,e,n,r,i),this}setNodeAttribute(e,n,r){return this.step(new $a(e,n,r)),this}setDocAttribute(e,n){return this.step(new dc(e,n)),this}addNodeMark(e,n){return this.step(new ss(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 It)n.isInSet(r.marks)&&this.step(new ma(e,n));else{let i=r.marks,o,s=[];for(;o=n.isInSet(i);)s.push(new ma(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 JD(this,e,n,r),this}addMark(e,n,r){return BD(this,e,n,r),this}removeMark(e,n,r){return HD(this,e,n,r),this}clearIncompatible(e,n,r){return nb(this,e,n,r),this}}const Rm=Object.create(null);class et{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new kC(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=Te.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:u}=s[a],c=e.mapping.slice(o);e.replaceRange(c.map(l.pos),c.map(u.pos),a?Te.empty:n),a==0&&Gy(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),u=l.map(s.pos),c=l.map(a.pos);o?e.deleteRange(u,c):(e.replaceRangeWith(u,c,n),Gy(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let i=e.parent.inlineContent?new qe(e):Ua(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?Ua(e.node(0),e.node(o),e.before(o+1),e.index(o),n,r):Ua(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 _r(e.node(0))}static atStart(e){return Ua(e,e,0,0,1)||new _r(e)}static atEnd(e){return Ua(e,e,e.content.size,e.childCount,-1)||new _r(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Rm[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 Rm)throw new RangeError("Duplicate use of selection JSON ID "+e);return Rm[e]=n,n.prototype.jsonID=e,n}getBookmark(){return qe.between(this.$anchor,this.$head).getBookmark()}}et.prototype.visible=!0;class kC{constructor(e,n){this.$from=e,this.$to=n}}let Wy=!1;function Ky(t){!Wy&&!t.parent.inlineContent&&(Wy=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class qe extends et{constructor(e,n=e){Ky(e),Ky(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 et.near(r);let i=e.resolve(n.map(this.anchor));return new qe(i.parent.inlineContent?i:r,r)}replace(e,n=Te.empty){if(super.replace(e,n),n==Te.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof qe&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Ep(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 qe(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=et.findFrom(n,r,!0)||et.findFrom(n,-r,!0);if(o)n=o.$head;else return et.near(n,r)}return e.parent.inlineContent||(i==0?e=n:(e=(et.findFrom(e,-r,!0)||et.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=i<0&&(e=n))),new qe(e,n)}}et.jsonID("text",qe);class Ep{constructor(e,n){this.anchor=e,this.head=n}map(e){return new Ep(e.map(this.anchor),e.map(this.head))}resolve(e){return qe.between(e.resolve(this.anchor),e.resolve(this.head))}}class Ye extends et{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?et.near(o):new Ye(o)}content(){return new Te(ge.from(this.node),0,0)}eq(e){return e instanceof Ye&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new ob(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new Ye(e.resolve(n.anchor))}static create(e,n){return new Ye(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}Ye.prototype.visible=!1;et.jsonID("node",Ye);class ob{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new Ep(r,r):new ob(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&Ye.isSelectable(r)?new Ye(n):et.near(n)}}class _r extends et{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=Te.empty){if(n==Te.empty){e.delete(0,e.doc.content.size);let r=et.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new _r(e)}map(e){return new _r(e)}eq(e){return e instanceof _r}getBookmark(){return oO}}et.jsonID("all",_r);const oO={map(){return this},resolve(t){return new _r(t)}};function Ua(t,e,n,r,i,o=!1){if(e.inlineContent)return qe.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&&Ye.isSelectable(a))return Ye.create(t,n-(i<0?a.nodeSize:0))}else{let l=Ua(t,a,n+i,i<0?a.childCount:0,i,o);if(l)return l}n+=a.nodeSize*i}return null}function Gy(t,e,n){let r=t.steps.length-1;if(r<e)return;let i=t.steps[r];if(!(i instanceof _n||i instanceof En))return;let o=t.mapping.maps[r],s;o.forEach((a,l,u,c)=>{s==null&&(s=c)}),t.setSelection(et.near(t.doc.resolve(s),n))}const Zy=1,Id=2,Jy=4;let sO=class extends ib{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|Zy)&~Id,this.storedMarks=null,this}get selectionSet(){return(this.updated&Zy)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Id,this}ensureMarks(e){return It.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&Id)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~Id,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)||It.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(et.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|=Jy,this}get scrolledIntoView(){return(this.updated&Jy)>0}};function Yy(t,e){return!e||!t?t:t.bind(e)}class Au{constructor(e,n,r){this.name=e,this.init=Yy(n.init,r),this.apply=Yy(n.apply,r)}}const aO=[new Au("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new Au("selection",{init(t,e){return t.selection||et.atStart(e.doc)},apply(t){return t.selection}}),new Au("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new Au("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class Nm{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=aO.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 Au(r.key,r.spec.state,r))})}}class Za{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,u=i?i[s].state:this,c=l<n.length&&a.spec.appendTransaction.call(a,l?n.slice(l):n,u,r);if(c&&r.filterTransaction(c,s)){if(c.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(c),r=r.applyInner(c),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 Za(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 sO(this)}static create(e){let n=new Nm(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new Za(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 Nm(this.schema,e.plugins),r=n.fields,i=new Za(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 Nm(e.schema,e.plugins),o=new Za(i);return i.fields.forEach(s=>{if(s.name=="doc")o.doc=hs.fromJSON(e.schema,n.doc);else if(s.name=="selection")o.selection=et.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],u=l.spec.state;if(l.key==s.name&&u&&u.fromJSON&&Object.prototype.hasOwnProperty.call(n,a)){o[s.name]=u.fromJSON.call(l,e,n[a],o);return}}o[s.name]=s.init(e,o)}}),o}}function xC(t,e,n){for(let r in t){let i=t[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=xC(i,e,{})),n[r]=i}return n}class Dt{constructor(e){this.spec=e,this.props={},e.props&&xC(e.props,this,this.props),this.key=e.key?e.key.key:_C("plugin")}getState(e){return e[this.key]}}const Pm=Object.create(null);function _C(t){return t in Pm?t+"$"+ ++Pm[t]:(Pm[t]=0,t+"$")}class Nt{constructor(e="key"){this.key=_C(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const nh=[{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 E0(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 lO=M('<div style="font-size: var(--tandem-text-xs); color: var(--tandem-fg-subtle); margin-top: var(--tandem-space-1);"><!> <!> <!> <!></div>'),uO=M('<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>'),cO=M('<span style="font-size: var(--tandem-text-xs); color: var(--tandem-fg-faint); font-family: var(--tandem-font-mono);"> </span>'),dO=M('<span style="font-size: var(--tandem-text-sm);"> </span> <!>',1),fO=M(`<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>`),hO=M('<span style="font-size: var(--tandem-text-xs); color: var(--tandem-fg-subtle); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;"> </span>'),pO=M('<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),mO=M('<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),gO=M('<li role="option"><!></li>'),vO=M(`<div role="presentation" 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" 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">></kbd> commands</span></div></div></div>`);function bO(t,e){ze(e,!0);let n=je(e,"editor",3,null),r=je(e,"annotations",19,()=>[]),i=B(""),o=B(0),s=B(null);const a=["#","@","?",">"],l=F(()=>a.find(D=>d(i).startsWith(D))??null),u=F(()=>(d(l)?d(i).slice(1):d(i)).trim().toLowerCase()),c=F(()=>{var H;if(d(l)!==null&&d(l)!==">")return[];const D=Zf(),P=d(u),R=[];for(const Q of D.values())(!P||Q.label.toLowerCase().includes(P)||Q.group.toLowerCase().includes(P)||(((H=Q.shortcut)==null?void 0:H.toLowerCase().includes(P))??!1))&&R.push({kind:"action",id:Q.id,action:Q});return R}),f=F(()=>{if(d(l)!=="#")return[];const D=n();if(!D||D.isDestroyed)return[];const P=d(u);return E0(D).filter(R=>!P||R.text.toLowerCase().includes(P)).map((R,H)=>({kind:"heading",id:`heading-${H}`,...R}))}),h=F(()=>{if(d(l)!=="@")return[];const D=d(u);return r().filter(P=>{var R;return D?P.content.toLowerCase().includes(D)||((R=P.textSnapshot)==null?void 0:R.toLowerCase().includes(D)):!0}).slice(0,50).map(P=>({kind:"annotation",id:`annotation-${P.id}`,label:P.content?P.content.slice(0,60):"(no content)",snippet:P.textSnapshot??"",annotationType:P.type}))}),p=F(()=>{if(d(l)!=="?")return[];const D=d(u),P=Zf(),R=[];for(const H of P.values())H.shortcut&&(!D||H.label.toLowerCase().includes(D)||H.shortcut.toLowerCase().includes(D))&&R.push({kind:"shortcut",id:`shortcut-registry-${H.id}`,keys:H.shortcut,description:H.label,group:H.group});for(let H=0;H<nh.length;H++){const Q=nh[H];(!D||Q.description.toLowerCase().includes(D)||Q.keys.toLowerCase().includes(D))&&R.push({kind:"shortcut",id:`shortcut-static-${H}`,keys:Q.keys,description:Q.description,group:"other"})}return R}),m=F(()=>[...d(c),...d(f),...d(h),...d(p)]);me(()=>{d(m),y(o,0)}),me(()=>{e.open&&(y(i,""),y(o,0),Promise.resolve().then(()=>{var D;return(D=d(s))==null?void 0:D.focus()}))}),Zl(()=>{const D=P=>{P.key!=="Escape"||!e.open||(P.preventDefault(),P.stopPropagation(),b())};return window.addEventListener("keydown",D,{capture:!0}),()=>window.removeEventListener("keydown",D,{capture:!0})});const v={"#":"Search headings…","@":"Search annotations…","?":"Search shortcuts…",">":"Search commands…"},g=F(()=>d(l)?v[d(l)]:"Type a command, # headings, @ annotations, ? shortcuts…");function b(){e.onClose()}function x(D){var P;if(D.kind==="action")b(),D.action.run();else if(D.kind==="heading"){b();const R=n();if(!R||R.isDestroyed)return;const H=D.pos;try{const Q=R.state.doc.resolve(H+1),Z=qe.near(Q);R.view.dispatch(R.state.tr.setSelection(Z).scrollIntoView()),R.view.focus()}catch{}}else D.kind==="annotation"&&(b(),(P=e.onFocusAnnotation)==null||P.call(e,D.id.replace("annotation-","")))}function _(D){const P=d(m).length;if(D.key==="ArrowDown")D.preventDefault(),y(o,(d(o)+1)%Math.max(1,P));else if(D.key==="ArrowUp")D.preventDefault(),y(o,(d(o)-1+Math.max(1,P))%Math.max(1,P));else if(D.key==="Enter"){D.preventDefault();const R=d(m)[d(o)];R&&x(R)}else D.key==="Escape"&&(D.preventDefault(),b())}function T(D){D.target===D.currentTarget&&b()}var S=kt(),z=Se(S);{var E=D=>{var P=vO(),R=w(P),H=w(R),Q=w(H),Z=k(w(Q),2);xt(Z,oe=>y(s,oe),()=>d(s));var $=k(Q,2);{var W=oe=>{var fe=lO(),I=w(fe);{var O=ye=>{var ce=or("Searching document headings");C(ye,ce)};G(I,ye=>{d(l)==="#"&&ye(O)})}var A=k(I,2);{var V=ye=>{var ce=or("Searching annotations");C(ye,ce)};G(A,ye=>{d(l)==="@"&&ye(V)})}var L=k(A,2);{var J=ye=>{var ce=or("Showing keyboard shortcuts");C(ye,ce)};G(L,ye=>{d(l)==="?"&&ye(J)})}var K=k(L,2);{var ne=ye=>{var ce=or("Filtering commands");C(ye,ce)};G(K,ye=>{d(l)===">"&&ye(ne)})}C(oe,fe)};G($,oe=>{d(l)&&oe(W)})}var te=k(H,2),ae=w(te);{var re=oe=>{var fe=uO(),I=w(fe);q(()=>ee(I,d(l)==="#"?"No headings found":d(l)==="@"?"No annotations found":d(l)==="?"?"No shortcuts found":"No commands match")),C(oe,fe)},ue=oe=>{var fe=kt(),I=Se(fe);Je(I,19,()=>d(m),O=>O.id,(O,A,V)=>{const L=F(()=>d(V)===d(o));var J=gO(),K=w(J);{var ne=_e=>{var Y=dO(),we=Se(Y),se=w(we),X=k(we,2);{var le=he=>{var De=cO(),Oe=w(De);q(()=>ee(Oe,d(A).action.shortcut)),C(he,De)};G(X,he=>{d(A).action.shortcut&&he(le)})}q(()=>ee(se,d(A).action.label)),C(_e,Y)},ye=_e=>{var Y=fO(),we=w(Y),se=w(we),X=k(we,2),le=w(X);q(()=>{ee(se,`H${d(A).level??""}`),xe(X,`font-size: var(--tandem-text-sm); padding-left: calc(${d(A).level-1} * var(--tandem-space-2));`),ee(le,d(A).text)}),C(_e,Y)},ce=_e=>{var Y=pO(),we=Se(Y),se=w(we),X=w(se),le=k(se,2);{var he=be=>{var Ne=hO(),Qe=w(Ne);q(()=>ee(Qe,`"${d(A).snippet??""}"`)),C(be,Ne)};G(le,be=>{d(A).snippet&&be(he)})}var De=k(we,2),Oe=w(De);q(be=>{ee(X,d(A).label),ee(Oe,be)},[()=>d(A).annotationType.charAt(0).toUpperCase()+d(A).annotationType.slice(1)]),C(_e,Y)},ve=_e=>{var Y=mO(),we=Se(Y),se=w(we),X=k(we,2),le=w(X);q(()=>{ee(se,d(A).description),ee(le,d(A).keys)}),C(_e,Y)};G(K,_e=>{d(A).kind==="action"?_e(ne):d(A).kind==="heading"?_e(ye,1):d(A).kind==="annotation"?_e(ce,2):d(A).kind==="shortcut"&&_e(ve,3)})}q(()=>{U(J,"id",`palette-item-${d(A).id}`),U(J,"data-testid",`palette-item-${d(A).id}`),U(J,"aria-selected",d(L)),xe(J,`
|
|
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(A).kind==="shortcut"?"default":"pointer"};
|
|
46
|
+
background: ${d(L)?"var(--tandem-accent-bg)":"transparent"};
|
|
47
|
+
color: ${d(L)?"var(--tandem-accent-fg-strong)":"var(--tandem-fg)"};
|
|
48
|
+
`)}),N("click",J,()=>x(d(A))),rn("mouseenter",J,()=>y(o,d(V),!0)),C(O,J)}),C(oe,fe)};G(ae,oe=>{d(m).length===0?oe(re):oe(ue,-1)})}cr(te,(oe,fe)=>Ht==null?void 0:Ht(oe,fe),()=>"y"),q(()=>{U(Z,"placeholder",d(g)),U(Z,"aria-activedescendant",d(m)[d(o)]?`palette-item-${d(m)[d(o)].id}`:void 0)}),N("click",P,T),N("keydown",P,oe=>{oe.key==="Escape"&&b()}),N("keydown",R,_),Bn(Z,()=>d(i),oe=>y(i,oe)),C(D,P)};G(z,D=>{e.open&&D(E)})}C(t,S),Be()}We(["click","keydown"]);var yO=M('<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 wO(t,e){var n=yO(),r=k(w(n),4),i=k(r,2);N("click",r,function(...o){var s;(s=e.onRetry)==null||s.apply(this,o)}),N("click",i,function(...o){var s;(s=e.onDismiss)==null||s.apply(this,o)}),C(t,n)}We(["click"]);function VQ(t){return t?t.osSupported?t.coworkDetected?"normal":"undetected":"unsupported":"loading"}function kO(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: ${xO(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 xO(t){const e=t.trim();return e.length===0?"(no output)":e.length<=200?e:`${e.slice(0,197)}...`}function CC(t){try{const e=JSON.parse(t);if(typeof e=="object"&&e!==null&&"kind"in e&&typeof e.kind=="string")try{return kO(e)}catch(n){return console.error("[cowork] firewallErrorHint failed for:",e,n),t}return t}catch{return t}}function UQ(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 jQ(t){switch(t){case"ok":case"alreadyPresent":return"success";case"locked":return"warning";case"schemaDrift":case"insecureAcl":case"failed":return"error"}}function qQ(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 SC(t,e){return!(!t||e||!t.osSupported||!t.coworkDetected||t.enabled)}function EC(){try{return localStorage.getItem(D_)==="true"}catch{return!1}}function _O(){try{localStorage.setItem(D_,"true")}catch{}}function Lt(){try{return typeof window<"u"&&"__TAURI_INTERNALS__"in window}catch{return!1}}function WQ(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 AC="Tauri runtime not available";async function sb(){try{return(await Mn(()=>import("./core-DhEqZVGG.js"),[])).invoke}catch(t){return Lt()&&console.error("[cowork] Failed to load @tauri-apps/api/core:",t),(()=>Promise.reject(new Error(AC)))}}function CO(t){return t("cowork_get_status")}function TC(t,e){return t("cowork_toggle_integration",{enabled:e})}function KQ(t){return t("cowork_rescan")}function GQ(t,e){return t("cowork_set_lan_ip_override",{enabled:e})}function SO(t){return t("cowork_retry_admin_elevation")}function MC(t){let e=B(null),n=B(!1),r=B(null),i=null,o=!1,s=!0,a=null;lr(()=>{s=!1,a!==null&&(clearInterval(a),a=null)});const l=async()=>{if(o){s&&y(n,!1);return}const u=i;if(u)try{const c=await CO(u);if(!s)return;y(e,c,!0),y(r,null)}catch(c){if(!s)return;const f=c instanceof Error?c.message:String(c);if(f===AC){o=!0,a!==null&&(clearInterval(a),a=null),y(n,!1);return}y(r,f,!0)}finally{s&&y(n,!1)}};return me(()=>{if(!t()){y(n,!1);return}let c=!1;return sb().then(f=>{if(!c)return i=f,y(n,!0),l()}).catch(f=>{if(c)return;const h=f instanceof Error?f.message:String(f);y(r,h,!0),y(n,!1)}),a=setInterval(()=>{c||o||l()},kM),()=>{c=!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 EO=M(`<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>`),AO=M('<div class="cad-error svelte-cbdwov" data-testid="cowork-admin-declined-error" role="alert"> </div>'),TO=M('<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>'),MO=M('<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>'),DO=M(`<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 OO(t,e){ze(e,!0);const n='button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])',r=MC(()=>!0),i=F(()=>{var g;return((g=r.status)==null?void 0:g.uacDeclined)===!0});let o=B(void 0),s=B(!1),a=B(!1),l=B(null);me(()=>{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)}}),me(()=>{if(!d(i))return;const g=b=>{if(b.key!=="Tab"||!d(o))return;const x=d(o).querySelectorAll(n);if(x.length===0)return;const _=x[0],T=x[x.length-1],S=document.activeElement;if(!d(o).contains(S)){b.preventDefault(),_.focus();return}b.shiftKey&&S===_?(b.preventDefault(),T.focus()):!b.shiftKey&&S===T&&(b.preventDefault(),_.focus())};return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)}),me(()=>{var g;d(i)&&((g=d(o))==null||g.focus())});async function u(g,b){y(a,!0),y(l,null);try{const x=await sb();await g(x)}catch(x){const _=x instanceof Error?x.message:String(x),T=CC(_);y(l,`${b}: ${T}`)}finally{y(a,!1)}}async function c(){await u(async g=>{await SO(g),await r.refetch()},"Retry failed")}async function f(){await u(async g=>{await TC(g,!1),await r.refetch()},"Failed to disable Cowork"),y(s,!1)}var h=kt(),p=Se(h);{var m=g=>{var b=EO();C(g,b)},v=g=>{var b=DO(),x=w(b);U(x,"tabindex",-1);var _=k(w(x),4);{var T=D=>{var P=AO(),R=w(P);q(()=>ee(R,d(l))),C(D,P)};G(_,D=>{d(l)&&D(T)})}var S=k(_,2);{var z=D=>{var P=TO(),R=k(w(P),4),H=w(R),Q=k(H,2);q(()=>{H.disabled=d(a),Q.disabled=d(a)}),N("click",H,()=>void f()),N("click",Q,()=>{y(s,!1)}),C(D,P)},E=D=>{var P=MO(),R=w(P),H=k(R,2);q(()=>{R.disabled=d(a),H.disabled=d(a)}),N("click",R,()=>{y(s,!0)}),N("click",H,()=>void c()),C(D,P)};G(S,D=>{d(s)?D(z):D(E,-1)})}xt(x,D=>y(o,D),()=>d(o)),C(g,b)};G(p,g=>{r.error&&!r.status?g(m):d(i)&&g(v,1)})}C(t,h),Be()}We(["click"]);var IO=M(`<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),RO=M('<p class="empty-sub empty-sub-secondary svelte-16uow3k">Tandem works alongside Claude (the default integration) or any MCP-capable AI client.</p>'),NO=M('<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),PO=M('<div class="empty-state svelte-16uow3k"><!></div>');function LO(t,e){ze(e,!0);let n=B(!1);me(()=>{if(e.connected){y(n,!1);return}const a=setTimeout(()=>{y(n,!0)},dM);return()=>clearTimeout(a)});var r=PO(),i=w(r);{var o=a=>{var l=IO(),u=k(Se(l),6),c=w(u),f=k(c,2);N("click",c,function(...h){var p;(p=e.onRetry)==null||p.apply(this,h)}),N("click",f,function(...h){var p;(p=e.onOpenSettings)==null||p.apply(this,h)}),C(a,l)},s=a=>{var l=NO(),u=k(Se(l),6),c=w(u),f=k(u,2);{var h=p=>{var m=RO();C(p,m)};G(f,p=>{e.connected&&!e.claudeActive&&p(h)})}N("click",c,function(...p){var m;(m=e.onOpenFile)==null||m.apply(this,p)}),C(a,l)};G(i,a=>{d(n)?a(o):a(s,-1)})}C(t,r),Be()}We(["click"]);function Ap(t,e,n=Date.now(),r=bM){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 Xy(t){return t.map(e=>e.path)}function FO(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 fc(){try{const t=localStorage.getItem(Yv);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 Tp(t){try{localStorage.setItem(Yv,JSON.stringify(t)),DC()}catch(e){console.warn("[tandem] failed to save recent files:",e)}}function zO(){try{localStorage.removeItem(Yv),DC()}catch(t){console.warn("[tandem] failed to clear recent files:",t)}}const BO=3e4;let Tu=null;function Qy(){const t=Date.now();if(Tu&&t-Tu.ts<BO)return Tu.files;const e=fc();return Tu={files:e,ts:t},e}function DC(){Tu=null}async function Po(t,e={}){const{readOnly:n=!1,notFoundMessage:r="File not found.",failureMessage:i="Failed to open file."}=e;try{const o=await fetch(`${qn}${X6}`,{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 HO=Array.from(id).sort().map(t=>t.replace(/^\./,""));async function OC(){const{open:t}=await Mn(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:HO}]});return typeof e=="string"?e:null}async function VO(t={}){var r,i;let e;try{e=await OC()}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 Po(e);if(!n.ok){(i=t.onError)==null||i.call(t,n.error);return}Tp(Ap(fc(),e))}async function UO(t){t.isTauri?await VO({onError:t.onError}):t.openModal()}var jO=M('<input type="file" style="display: none;"/>'),qO=M('<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>'),WO=M('<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>'),KO=M('<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>'),GO=M('<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>'),ZO=M('<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></div>');function JO(t,e){ze(e,!0);let n=B(null),r=B(!1),i=B(void 0),o=B(Ge(Xy(fc())));const a=Array.from(id).sort().join(",");function l(W){const te=Ap(fc(),W);Tp(te),y(o,Xy(te),!0)}function u(){zO(),y(o,[],!0)}async function c(W){if(!d(r)){y(n,null),y(r,!0);try{const te=await Po(W);if(!te.ok){y(n,te.error,!0);return}l(W),e.onClose()}finally{y(r,!1)}}}async function f(){if(!d(r))try{const W=await OC();W&&await c(W)}catch(W){y(n,`File picker unavailable: ${W instanceof Error?W.message:W}`)}}async function h(W){if(!d(r)){y(n,null),y(r,!0);try{const te=await O_(W),ae=await fetch(`${qn}${p_}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({fileName:W.name,content:te})}),re=await ae.json();if(!ae.ok){y(n,re.message??"Failed to open file",!0);return}e.onClose()}catch(te){console.error("FileOpenDialog: upload failed",te),te instanceof SyntaxError?y(n,"Server returned an unexpected response"):te instanceof TypeError?y(n,"Unexpected response format"):y(n,"Cannot reach server. Is it running?")}finally{y(r,!1)}}}function p(W){var re;const ae=(re=W.target.files)==null?void 0:re[0];ae&&h(ae)}function m(){var W;Lt()?f():(W=d(i))==null||W.click()}var v=ZO();U(v,"tabindex",-1);var g=w(v),b=w(g),x=k(w(b),2),_=k(b,2);D4(_);var T=w(_),S=k(_,2);{var z=W=>{var te=jO();xt(te,ae=>y(i,ae),()=>d(i)),q(()=>U(te,"accept",a)),N("change",te,p),C(W,te)},E=F(()=>!Lt());G(S,W=>{d(E)&&W(z)})}var D=k(S,2);{var P=W=>{var te=qO();C(W,te)},R=F(()=>Lt());G(D,W=>{d(R)&&W(P)})}var H=k(D,2);{var Q=W=>{var te=KO(),ae=w(te),re=k(w(ae),2),ue=k(ae,2);Je(ue,22,()=>d(o),oe=>oe,(oe,fe,I)=>{const O=F(()=>fe.split(/[/\\]/)),A=F(()=>d(O).at(-1)??fe),V=F(()=>d(O).slice(0,-1).join("/")||"/");var L=WO(),J=w(L),K=w(J),ne=k(J,2),ye=w(ne);q(()=>{U(L,"data-testid",`recent-file-${d(I)}`),ee(K,d(A)),ee(ye,d(V))}),N("click",L,()=>c(fe)),rn("mouseenter",L,ce=>{ce.currentTarget.style.background="var(--tandem-surface-muted)"}),rn("mouseleave",L,ce=>{ce.currentTarget.style.background="transparent"}),C(oe,L)}),cr(ue,(oe,fe)=>Ht==null?void 0:Ht(oe,fe),()=>"y"),N("click",re,u),C(W,te)};G(H,W=>{d(o).length>0&&W(Q)})}var Z=k(H,2);{var $=W=>{var te=GO(),ae=w(te);q(()=>ee(ae,d(n))),C(W,te)};G(Z,W=>{d(n)&&W($)})}q(()=>{_.disabled=d(r),xe(_,`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);`),ee(T,d(r)?"Opening…":"Browse…")}),N("click",v,W=>{W.target===W.currentTarget&&e.onClose()}),N("keydown",v,W=>{W.key==="Escape"&&e.onClose()}),N("click",x,function(...W){var te;(te=e.onClose)==null||te.apply(this,W)}),N("click",_,m),C(t,v),Be()}We(["click","keydown","change"]);const YO="/api/integrations/existing",XO="/api/integrations",QO="/api/integrations/apply",$O="/api/integrations/first-run-needed";function e5(t){return`/api/integrations/secrets/${encodeURIComponent(t)}`}function t5(t){return`/api/models/secrets/${encodeURIComponent(t)}`}const n5=3,r5="KEYCHAIN_UNAVAILABLE",i5="Tauri runtime not available";async function o5(){try{return(await Mn(()=>import("./core-DhEqZVGG.js"),[])).invoke}catch(t){return Lt()&&console.error("[keychain] Failed to load @tauri-apps/api/core:",t),(()=>Promise.reject(new Error(i5)))}}function s5(t,e,n){return t("keychain_set",{account:e,secret:n})}function a5(t,e){return t("keychain_delete",{account:e})}function l5(t={}){const e=t.fetchFn??((...i)=>globalThis.fetch(...i)),n=t.baseUrl??"",r=t.pathFor??e5;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)===r5)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 u5=["keychain-init","Platform secure storage failure","Couldn't access platform secure storage"];function c5(t){return u5.some(e=>t.includes(e))}function d5(t={}){const e=()=>t.invoke?Promise.resolve(t.invoke):o5();return{async set(n,r){try{const i=await e();return await s5(i,n,r),{status:"ok"}}catch(i){const o=i instanceof Error?i.message:String(i);return c5(o)?{status:"unavailable"}:{status:"error",message:o}}},async delete(n){try{const r=await e();await a5(r,n)}catch{}}}}function IC(t={}){return t.force==="tauri"||t.force!=="http"&&Lt()?d5({invoke:t.invoke}):l5({fetchFn:t.fetchFn,baseUrl:t.baseUrl,pathFor:t.pathFor})}const f5=["narrow","comfortable","wide","full"],$y={narrow:"58ch",comfortable:"68ch",wide:"82ch",full:"100%"};function RC(t){return typeof t=="string"&&f5.includes(t)}const NC=["anthropic","openai","gemini","local-ollama","local-llamacpp"],h5=50,p5={s:14,m:16,l:18};function PC(){try{return typeof window>"u"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!1}}const dn={leftPanelVisible:!1,rightPanelVisible:!0,schemaVersion:13,primaryTab:"annotations",panelOrder:"chat-editor-annotations",editorMeasure:"comfortable",selectionDwellMs:k_,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,decorationsMuted:!1,models:[],defaultModelId:null,customShortcuts:{}},m5=64,g5=512;function LC(t){if(!Array.isArray(t))return[];const e=[];for(const n of t){if(e.length>=h5)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"||!NC.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<=m5&&/^[A-Za-z0-9_-]+$/.test(r.apiKeyRef)?i.apiKeyRef=r.apiKeyRef:typeof r.apiKey=="string"&&r.apiKey.length<=g5&&(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 v5=["serif","sans","mono"];function FC(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"&&v5.includes(r)&&(e[n]=r);return e}const xf=13;function ew(t){return{leftPanelVisible:t.leftPanelVisible===!0,rightPanelVisible:t.rightPanelVisible!==!1,schemaVersion:xf,primaryTab:t.primaryTab==="annotations"?"annotations":"chat",panelOrder:t.panelOrder==="annotations-editor-chat"?"annotations-editor-chat":"chat-editor-annotations",editorMeasure:RC(t.editorMeasure)?t.editorMeasure:dn.editorMeasure,selectionDwellMs:Math.max(Dl,Math.min(Ol,Number(t.selectionDwellMs)||k_)),showAuthorship:t.showAuthorship===!1?!1:dn.showAuthorship,reduceMotion:typeof t.reduceMotion=="boolean"?t.reduceMotion:PC(),textSize:t.textSize==="s"||t.textSize==="m"||t.textSize==="l"?t.textSize:dn.textSize,theme:t.theme==="light"||t.theme==="dark"||t.theme==="warm"||t.theme==="system"?t.theme:dn.theme,accentHue:typeof t.accentHue=="number"&&t.accentHue>=0&&t.accentHue<=360?t.accentHue:dn.accentHue,editorFont:t.editorFont==="serif"||t.editorFont==="sans"||t.editorFont==="mono"?t.editorFont:dn.editorFont,fontByExtension:FC(t.fontByExtension),density:t.density==="compact"||t.density==="cozy"||t.density==="spacious"?t.density:dn.density,defaultMode:t.defaultMode==="solo"||t.defaultMode==="tandem"?t.defaultMode:dn.defaultMode,highContrast:t.highContrast===!0,annotationPatterns:t.annotationPatterns===!0,selectionToolbar:t.selectionToolbar===!1?!1:dn.selectionToolbar,formattingBarVisible:t.formattingBarVisible===!1?!1:dn.formattingBarVisible,soloRailHidden:t.soloRailHidden===!1?!1:dn.soloRailHidden,degradedBannerDelayMs:typeof t.degradedBannerDelayMs=="number"&&t.degradedBannerDelayMs>=5e3&&t.degradedBannerDelayMs<=12e4?t.degradedBannerDelayMs:dn.degradedBannerDelayMs,sidecarRetryStrategy:t.sidecarRetryStrategy==="exponential"||t.sidecarRetryStrategy==="constant-2s"||t.sidecarRetryStrategy==="manual"?t.sidecarRetryStrategy:dn.sidecarRetryStrategy,holdAnnotationsWhileOffline:typeof t.holdAnnotationsWhileOffline=="boolean"?t.holdAnnotationsWhileOffline:dn.holdAnnotationsWhileOffline,marginView:t.marginView===!0,showComments:t.showComments===!1?!1:dn.showComments,showHighlights:t.showHighlights===!1?!1:dn.showHighlights,showNotes:t.showNotes===!1?!1:dn.showNotes,decorationsMuted:t.decorationsMuted===!0,models:LC(t.models),defaultModelId:typeof t.defaultModelId=="string"&&t.defaultModelId.length>0?t.defaultModelId:null,customShortcuts:$v(t.customShortcuts)}}function b5(){let t;try{t=localStorage.getItem(y_)}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>xf){console.warn(`[tandem] settings schemaVersion=${e.schemaVersion} is newer than v${xf}; loading defensively without writing.`);const r=e.editorMeasure,i=ew(e);typeof r=="string"&&r!==i.editorMeasure&&console.warn(`[tandem] editorMeasure=${JSON.stringify(r)} from newer client is unknown to v${xf}; 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,u]of Object.entries(e))!o.has(l)&&l!=="_readOnly"&&!s.has(l)&&(a[l]=u);return{...i,...a,_readOnly:!0}}return ew(e)}catch(e){console.warn("[tandem] settings JSON is corrupt, resetting to defaults:",e)}return{...dn,reduceMotion:PC()}}function y5(t,e){const n={...t,...e},r=LC(n.models);return{...n,customShortcuts:$v(n.customShortcuts),fontByExtension:FC(n.fontByExtension),selectionDwellMs:Math.max(Dl,Math.min(Ol,n.selectionDwellMs)),accentHue:Number.isFinite(n.accentHue)?Math.max(0,Math.min(360,n.accentHue)):dn.accentHue,editorMeasure:RC(n.editorMeasure)?n.editorMeasure:dn.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 w5(t,e){var n;if(e){const r=(n=t.fontByExtension)==null?void 0:n[e];if(r)return r}return t.editorFont}let Rd=null;function tw(t){const e=t.decorationsMuted;try{localStorage.setItem(C_,String(!e&&t.showAuthorship)),localStorage.setItem(S_,JSON.stringify({comment:!e&&t.showComments,highlight:!e&&t.showHighlights,note:!e&&t.showNotes}))}catch{}}function ab(){if(Rd)return Rd;const t=b5();let e=B(Ge(t));return tw(t),Rd={get settings(){return d(e)},updateSettings:r=>{if(d(e)._readOnly)return;const i=y5(d(e),r);try{localStorage.setItem(y_,JSON.stringify(i))}catch{}tw(i),y(e,i,!0)}},Rd}const A0=IC({baseUrl:`http://127.0.0.1:${Jl}`,pathFor:t5});function Lm(){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 k5(){return crypto.randomUUID()}function nw(t){if(t.provider!==void 0&&!NC.includes(t.provider))throw new Error(`Invalid model provider: ${String(t.provider)}`)}async function Fm(t,e){const n=await A0.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 zC(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){nw(e);const r=k5();let i;n&&n.length>0&&(i=Lm(),await Fm(i,n));const o={...e,id:r,...i?{apiKeyRef:i}:{}};return t.updateSettings({models:[...t.settings.models,o]}),r},async updateModel(e,n,r){nw(n);const i=t.settings.models.find(s=>s.id===e);if(!i)return;let o;r!==void 0&&r.length>0&&(o=Lm(),await Promise.all([Fm(o,r),i.apiKeyRef?A0.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 A0.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,u)=>typeof l._legacyApiKey=="string"?u:-1).filter(l=>l>=0);if(n.length===0)return{migrated:0,failed:0};const r=n.map(()=>Lm()),i=await Promise.allSettled(n.map((l,u)=>Fm(r[u],e[l]._legacyApiKey))),o=e.slice();let s=0,a=0;return i.forEach((l,u)=>{const c=n[u];if(l.status==="fulfilled"){const f={...e[c],apiKeyRef:r[u]};delete f._legacyApiKey,o[c]=f,s++}else a++}),s>0&&t.updateSettings({models:o}),{migrated:s,failed:a}}}}var x5=M('<label class="frm-provider-row svelte-1hpwfc5"><input type="radio" name="first-run-provider"/> <span> </span></label>'),_5=M('<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>'),C5=M('<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>'),S5=M('<div role="alert" class="frm-error svelte-1hpwfc5" data-testid="first-run-error"> </div>'),E5=M('<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 A5(t,e){ze(e,!0);const n=ab(),r=zC(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=B("anthropic"),s=B(""),a=B(Ge(i[0].defaultModelId)),l=B(""),u=B("http://localhost:11434"),c=B(!1),f=B(null),h=B(null),p=null;const m=F(()=>i.find(A=>A.value===d(o))??i[0]),v=F(()=>d(m).isCloud),g=F(()=>d(a).trim().length>0&&(d(v)?d(l).trim().length>0:d(u).trim().length>0));me(()=>{const A=St(()=>d(h));if(A)return p=document.activeElement,A.focus(),()=>{p instanceof HTMLElement&&document.contains(p)&&p.focus()}});function b(A){const V=i.find(J=>J.value===d(o)),L=i.find(J=>J.value===A);L&&V&&d(a)===V.defaultModelId&&y(a,L.defaultModelId,!0),y(o,A,!0)}async function x(A){if(A.preventDefault(),!(!d(g)||d(c))){y(c,!0),y(f,null);try{const V=await r.addModel({provider:d(o),displayName:d(s).trim()||d(m).label,modelId:d(a).trim(),enabled:!0,...d(v)?{}:{endpoint:d(u).trim()}},d(v)?d(l).trim():void 0);r.setDefault(V),e.onComplete()}catch(V){y(f,V instanceof Error?V.message:"Failed to save",!0)}finally{y(c,!1)}}}function _(){e.onComplete()}var T=E5(),S=w(T);U(S,"tabindex",-1);var z=w(S),E=k(w(z),2),D=k(z,2),P=w(D),R=k(w(P),2);Je(R,17,()=>i,A=>A.value,(A,V)=>{var L=x5(),J=w(L),K=k(J,2),ne=w(K);q(()=>{xr(J,d(V).value),Un(J,d(o)===d(V).value),U(J,"data-testid",`first-run-provider-${d(V).value}`),ee(ne,d(V).label)}),N("change",J,()=>b(d(V).value)),C(A,L)});var H=k(P,2),Q=k(w(H),2),Z=k(H,2),$=k(w(Z),2),W=k(Z,2);{var te=A=>{var V=_5(),L=k(w(V),2);Bn(L,()=>d(l),J=>y(l,J)),C(A,V)},ae=A=>{var V=C5(),L=k(w(V),2);Bn(L,()=>d(u),J=>y(u,J)),C(A,V)};G(W,A=>{d(v)?A(te):A(ae,-1)})}var re=k(W,2);{var ue=A=>{var V=S5(),L=w(V);q(()=>ee(L,d(f))),C(A,V)};G(re,A=>{d(f)&&A(ue)})}var oe=k(re,2),fe=w(oe),I=k(fe,2),O=w(I);xt(S,A=>y(h,A),()=>d(h)),q(()=>{U(Q,"placeholder",d(m).label),I.disabled=!d(g)||d(c),ee(O,d(c)?"Saving…":"Save and continue")}),N("click",T,A=>{A.target===A.currentTarget&&_()}),N("keydown",S,A=>{A.key==="Escape"&&_(),A.key!=="Tab"&&A.stopPropagation()}),N("click",E,_),rn("submit",D,x),Bn(Q,()=>d(s),A=>y(s,A)),Bn($,()=>d(a),A=>y(a,A)),N("click",fe,_),C(t,T),Be()}We(["click","keydown","change"]);var T5=M('<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),M5=M('<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>'),D5=M('<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),O5=M(`<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 I5(t,e){ze(e,!0);const n=F(()=>{const l=Zf(),u=e.effectiveShortcutLabels,c=new Map;for(const f of l.values()){if(!f.shortcut)continue;const h=z_[f.id],p=h&&(u==null?void 0:u.get(h))||f.shortcut,m=c.get(f.group)??[];m.push({keys:p,description:f.label}),c.set(f.group,m)}return I_.map(f=>({title:f.charAt(0).toUpperCase()+f.slice(1),rows:c.get(f)??[]})).filter(f=>f.rows.length>0)});let r=B(null),i=null;me(()=>{if(!e.open)return;const l=St(()=>d(r));if(!l)return;i=document.activeElement,l.focus();const u=c=>{l&&!l.contains(c.target)&&l.focus()};return document.addEventListener("focusin",u),()=>{document.removeEventListener("focusin",u),i instanceof HTMLElement&&document.contains(i)&&i.focus()}}),me(()=>{if(!e.open)return;const l=u=>{u.key==="Escape"&&(u.preventDefault(),u.stopPropagation(),e.onClose())};return window.addEventListener("keydown",l,{capture:!0}),()=>window.removeEventListener("keydown",l,{capture:!0})});var o=kt(),s=Se(o);{var a=l=>{var u=O5(),c=w(u),f=w(c),h=k(w(f),2),p=k(f,2);Je(p,17,()=>d(n),g=>g.title,(g,b)=>{var x=M5(),_=w(x),T=w(_),S=k(_,2);Je(S,21,()=>d(b).rows,z=>z.description,(z,E)=>{var D=T5(),P=Se(D),R=w(P),H=w(R),Q=k(P,2),Z=w(Q);q(()=>{ee(H,d(E).keys),ee(Z,d(E).description)}),C(z,D)}),q(()=>ee(T,d(b).title)),C(g,x)});var m=k(p,2),v=k(w(m),2);Je(v,21,()=>nh,g=>g.description,(g,b)=>{var x=D5(),_=Se(x),T=w(_),S=w(T),z=k(_,2),E=w(z);q(()=>{ee(S,d(b).keys),ee(E,d(b).description)}),C(g,x)}),xt(c,g=>y(r,g),()=>d(r)),cr(c,(g,b)=>Ht==null?void 0:Ht(g,b),()=>"y"),N("click",u,function(...g){var b;(b=e.onClose)==null||b.apply(this,g)}),N("click",c,g=>g.stopPropagation()),N("keydown",c,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(T=>!T.closest("[hidden]"));if(b.length===0){g.preventDefault();return}const x=b[0],_=b[b.length-1];g.shiftKey&&document.activeElement===x?(g.preventDefault(),_.focus()):!g.shiftKey&&document.activeElement===_&&(g.preventDefault(),x.focus())}}),N("click",h,function(...g){var b;(b=e.onClose)==null||b.apply(this,g)}),C(l,u)};G(s,l=>{e.open&&l(a)})}C(t,o),Be()}We(["click","keydown"]);function R5(t){const e=crypto.randomUUID().replace(/-/g,"").slice(0,12);return`${t}-${e}`}function N5(t={}){const e=t.fetchFn??globalThis.fetch.bind(globalThis),n=t.baseUrl??"",r=t.keychainBackend??IC({fetchFn:e,baseUrl:n});let i=B("detect"),o=B(Ge([])),s=B(Ge([])),a=B(null),l=B(Ge([])),u=B(!1),c=0;const f=S=>{y(a,S,!0),y(i,"error")},h=async()=>{const S=++c;y(i,"detect"),y(a,null);try{const z=await e(`${n}${YO}`);if(S!==c)return;if(!z.ok){f(`Could not load existing entries (HTTP ${z.status}).`);return}const E=await z.json();if(S!==c)return;y(o,E.installs,!0)}catch(z){if(S!==c)return;f(z instanceof Error?z.message:String(z))}},p=()=>{y(i,"pick")},m=S=>{y(s,S,!0)},v=()=>{y(i,"secrets")},g=async(S,z)=>{const E=R5(S.id),D=await r.set(E,z);if(D.status==="unavailable"){y(u,!0),y(s,d(s).map(P=>P.id===S.id?{...P,keychainUnavailable:!0,pendingSecret:void 0}:P),!0);return}if(D.status==="error"){f(`Could not store secret: ${D.message}`);return}y(s,d(s).map(P=>P.id===S.id?{...P,config:{...P.config,tokenSecretRef:E},hasStoredSecret:!0,pendingSecret:void 0,keychainUnavailable:!1}:P),!0)},b=()=>{y(i,"review")},x=async()=>{const S=d(s).map(z=>z.config.tokenSecretRef).filter(z=>typeof z=="string"&&z.length>0);await Promise.all(S.map(z=>r.delete(z)))};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(u)},begin:h,advanceToPick:p,setPicked:m,advanceToSecrets:v,submitSecret:g,advanceToReview:b,save:async()=>{y(i,"saving");const S=d(s).map(E=>{if(E.config.kind==="other-mcp")return{...E.config,apply:"skip"};const D=E.config.configPath,P=d(o).find(H=>H.target.configPath===D),R=(P==null?void 0:P.tandemValidation)!==void 0&&P.tandemValidation.status!=="valid";return{...E.config,apply:R?"skip":"create"}}),z={schemaVersion:n5,integrations:S};try{const E=await e(`${n}${XO}`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(z)});if(!E.ok){const H=await E.json().catch(()=>null);await x(),f((H==null?void 0:H.message)??`Could not save (HTTP ${E.status}).`);return}const D=await E.json(),P=await e(`${n}${QO}`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({ids:D.ids,confirmationNonce:D.confirmationNonce})});if(!P.ok){const H=await P.json().catch(()=>null);f((H==null?void 0:H.message)??`Could not apply (HTTP ${P.status}).`);return}const R=await P.json();y(l,R.results,!0),y(i,"done")}catch(E){await x(),f(E instanceof Error?E.message:String(E))}},reset:()=>{y(i,"detect"),y(o,[],!0),y(s,[],!0),y(a,null),y(l,[],!0),y(u,!1)}}}var P5=M('<span class="iw-hint svelte-bt94ms">Tandem is already configured here.</span>'),L5=M('<li class="svelte-bt94ms"><strong> </strong> <span> </span> <!></li>'),F5=M('<ul class="iw-existing svelte-bt94ms"></ul>'),z5=M('<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>'),B5=M('<li class="svelte-bt94ms"><label><input type="checkbox"/> <strong> </strong> <small> </small></label></li>'),H5=M('<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>'),V5=M(`<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_<id>_TOKEN</code> instead, or skip this step and
|
|
54
|
+
add the token via your AI client's own configuration.</p>`),U5=M('<em class="iw-stored svelte-bt94ms">Token saved.</em>'),j5=M('<em class="iw-skipped svelte-bt94ms">Skipped (keychain unavailable).</em>'),q5=M('<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>'),W5=M('<li class="svelte-bt94ms"><div class="iw-secret-row svelte-bt94ms"><strong> </strong> <small> </small></div> <!></li>'),K5=M(`<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>`),G5=M('<span class="iw-token-badge svelte-bt94ms">Token stored</span>'),Z5=M('<li class="svelte-bt94ms"><strong> </strong> <small> </small> <!></li>'),J5=M('<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>'),Y5=M('<section data-testid="integration-wizard-step-saving"><p>Saving integration configuration…</p></section>'),X5=M('<span class="iw-apply-result-message svelte-bt94ms"> </span>'),Q5=M('<li><span class="iw-apply-result-id svelte-bt94ms"> </span> <span class="iw-apply-result-status svelte-bt94ms"> </span> <!></li>'),$5=M('<ul class="iw-apply-results svelte-bt94ms"></ul>'),e8=M('<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>'),t8=M('<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>'),n8=M('<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 r8(t,e){ze(e,!0);const n=N5({baseUrl:`http://127.0.0.1:${Jl}`});let r=B(null),i=null,o=B(Ge({}));me(()=>{if(!e.open)return;const b=St(()=>d(r));if(b)return i=document.activeElement,b.focus(),()=>{i instanceof HTMLElement&&document.contains(i)&&i.focus()}}),me(()=>{e.open&&n.begin()}),me(()=>{if(!e.open)return;const b=x=>{x.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 x;if(b.target.kind==="claude-code"){const _=((x=b.tandemEntry)==null?void 0:x.url)??"http://127.0.0.1:3479",T=a("claude-code");return{id:T,config:{kind:"claude-code",id:T,label:b.target.label,configPath:b.target.configPath,transport:"http",url:_},hasStoredSecret:!1,keychainUnavailable:!1}}if(b.target.kind==="claude-desktop"){const _=a("claude-desktop");return{id:_,config:{kind:"claude-desktop",id:_,label:b.target.label,configPath:b.target.configPath,transport:"stdio"},hasStoredSecret:!1,keychainUnavailable:!1}}return null}function u(){const b=n.existing.filter(x=>x.status==="ok"||x.status==="missing").map(l).filter(x=>x!==null);n.setPicked(b),n.advanceToPick()}function c(b){const x=n.picked.findIndex(T=>T.config.kind===b.target.kind&&T.config.label===b.target.label);if(x>=0){n.setPicked(n.picked.filter((T,S)=>S!==x));return}const _=l(b);_&&n.setPicked([...n.picked,_])}function f(b){return n.picked.some(x=>x.config.kind===b.target.kind&&x.config.label===b.target.label)}async function h(b){const x=d(o)[b.id]??"";x.length!==0&&(await n.submitSecret(b,x),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=kt(),v=Se(m);{var g=b=>{var x=n8(),_=w(x),T=w(_),S=k(w(T),2),z=k(T,2);{var E=$=>{var W=z5(),te=k(w(W),2);{var ae=oe=>{var fe=F5();Je(fe,21,()=>n.existing,I=>I.target.configPath,(I,O)=>{var A=L5(),V=w(A),L=w(V),J=k(V,2),K=w(J),ne=k(J,2);{var ye=ce=>{var ve=P5();C(ce,ve)};G(ne,ce=>{d(O).tandemEntry&&ce(ye)})}q(()=>{ee(L,d(O).target.label),At(J,1,`iw-status iw-status-${d(O).status??""}`,"svelte-bt94ms"),ee(K,d(O).status)}),C(I,A)}),C(oe,fe)};G(te,oe=>{n.existing.length>0&&oe(ae)})}var re=k(te,2),ue=w(re);N("click",ue,u),C($,W)},D=$=>{var W=H5(),te=k(w(W),2);Je(te,21,()=>n.existing,ue=>ue.target.configPath,(ue,oe)=>{var fe=B5(),I=w(fe),O=w(I),A=k(O,2),V=w(A),L=k(A,2),J=w(L);q(K=>{Un(O,K),U(O,"data-testid",`integration-wizard-pick-${d(oe).target.kind??""}`),ee(V,d(oe).target.label),ee(J,d(oe).target.configPath)},[()=>f(d(oe))]),N("change",O,()=>c(d(oe))),C(ue,fe)});var ae=k(te,2),re=w(ae);N("click",re,()=>n.advanceToSecrets()),C($,W)},P=$=>{var W=K5(),te=k(w(W),2);{var ae=fe=>{var I=V5();C(fe,I)};G(te,fe=>{n.keychainUnavailable&&fe(ae)})}var re=k(te,2);Je(re,21,()=>n.picked,fe=>fe.id,(fe,I)=>{var O=W5(),A=w(O),V=w(A),L=w(V),J=k(V,2),K=w(J),ne=k(A,2);{var ye=_e=>{var Y=U5();C(_e,Y)},ce=_e=>{var Y=j5();C(_e,Y)},ve=_e=>{var Y=q5(),we=w(Y),se=k(we,2);q(()=>{U(we,"data-testid",`integration-wizard-secret-input-${d(I).id??""}`),se.disabled=!d(o)[d(I).id],U(se,"data-testid",`integration-wizard-secret-submit-${d(I).id??""}`)}),Bn(we,()=>d(o)[d(I).id],X=>d(o)[d(I).id]=X),N("click",se,()=>h(d(I))),C(_e,Y)};G(ne,_e=>{d(I).hasStoredSecret?_e(ye):d(I).keychainUnavailable?_e(ce,1):_e(ve,-1)})}q(_e=>{ee(L,d(I).config.label),ee(K,_e)},[()=>p(d(I).config)]),C(fe,O)});var ue=k(re,2),oe=w(ue);N("click",oe,()=>n.advanceToReview()),C($,W)},R=$=>{var W=J5(),te=k(w(W),2);Je(te,21,()=>n.picked,ue=>ue.id,(ue,oe)=>{var fe=Z5(),I=w(fe),O=w(I),A=k(I,2),V=w(A),L=k(A,2);{var J=K=>{var ne=G5();C(K,ne)};G(L,K=>{d(oe).config.tokenSecretRef&&K(J)})}q(K=>{ee(O,d(oe).config.label),ee(V,K)},[()=>p(d(oe).config)]),C(ue,fe)});var ae=k(te,2),re=w(ae);N("click",re,()=>n.save()),C($,W)},H=$=>{var W=Y5();C($,W)},Q=$=>{var W=e8(),te=k(w(W),2);{var ae=oe=>{var fe=$5();Je(fe,21,()=>n.applyResults,I=>I.id,(I,O)=>{var A=Q5(),V=w(A),L=w(V),J=k(V,2),K=w(J),ne=k(J,2);{var ye=ce=>{var ve=X5(),_e=w(ve);q(()=>ee(_e,d(O).message)),C(ce,ve)};G(ne,ce=>{d(O).status==="error"&&d(O).message&&ce(ye)})}q(()=>{At(A,1,`iw-apply-result iw-apply-result-${d(O).status??""}`,"svelte-bt94ms"),U(A,"data-testid",`integration-wizard-apply-result-${d(O).id??""}`),ee(L,d(O).id),ee(K,d(O).status)}),C(I,A)}),C(oe,fe)};G(te,oe=>{n.applyResults.length>0&&oe(ae)})}var re=k(te,2),ue=w(re);N("click",ue,s),C($,W)},Z=$=>{var W=t8(),te=w(W),ae=w(te),re=k(te,2),ue=w(re),oe=k(ue,2);q(()=>ee(ae,`Something went wrong: ${n.errorMessage??""}`)),N("click",ue,()=>n.reset()),N("click",oe,s),C($,W)};G(z,$=>{n.step==="detect"?$(E):n.step==="pick"?$(D,1):n.step==="secrets"?$(P,2):n.step==="review"?$(R,3):n.step==="saving"?$(H,4):n.step==="done"?$(Q,5):n.step==="error"&&$(Z,6)})}xt(_,$=>y(r,$),()=>d(r)),N("click",x,s),N("click",_,$=>$.stopPropagation()),N("keydown",_,$=>{if($.key==="Escape"){s();return}$.key!=="Tab"&&$.stopPropagation()}),N("click",S,s),C(b,x)};G(v,b=>{e.open&&b(g)})}C(t,m),Be()}We(["click","keydown","change"]);var i8=M("Detected VM subnet: <code> </code>.",1),o8=M('<div class="cos-error svelte-1h0desi" data-testid="cowork-onboarding-error" role="alert"> </div>'),s8=M('<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>'),a8=M('<button data-testid="cowork-onboarding-learn-more-btn" class="cos-btn cos-btn--ghost svelte-1h0desi" type="button">Learn more</button>'),l8=M('<a class="cos-learn-more-link svelte-1h0desi" data-testid="cowork-onboarding-learn-more-link" target="_blank" rel="noreferrer">Learn more</a>'),u8=M('<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>'),c8=M('<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 d8(t,e){ze(e,!0);let n=B(!1),r=B(!1),i=B(null);async function o(b,x){y(r,!0),y(i,null);try{const _=await sb();return await b(_),!0}catch(_){const T=_ instanceof Error?_.message:String(_),S=CC(T);return y(i,`${x}: ${S}`),!1}finally{y(r,!1)}}async function s(){await o(async x=>{await TC(x,!0)},"Failed to enable Cowork")&&e.onAdvance()}function a(){_O(),e.onAdvance()}var l=c8(),u=k(w(l),2),c=k(w(u));{var f=b=>{var x=i8(),_=k(Se(x)),T=w(_);q(()=>ee(T,e.status.vethernetCidr)),C(b,x)};G(c,b=>{e.status.vethernetCidr!==null&&b(f)})}var h=k(u,2);{var p=b=>{var x=o8(),_=w(x);q(()=>ee(_,d(i))),C(b,x)};G(h,b=>{d(i)&&b(p)})}var m=k(h,2);{var v=b=>{var x=s8(),_=k(w(x),4),T=w(_),S=k(T,2);q(()=>{T.disabled=d(r),S.disabled=d(r)}),N("click",T,()=>void s()),N("click",S,()=>{y(n,!1)}),C(b,x)},g=b=>{var x=u8(),_=w(x),T=k(_,2),S=k(T,2);{var z=D=>{var P=a8();q(()=>P.disabled=d(r)),N("click",P,function(...R){var H;(H=e.onLearnMore)==null||H.apply(this,R)}),C(D,P)},E=D=>{var P=l8();q(()=>U(P,"href",`${m_}#cowork`)),C(D,P)};G(S,D=>{e.onLearnMore?D(z):D(E,-1)})}q(()=>{_.disabled=d(r),T.disabled=d(r)}),N("click",_,()=>{y(n,!0)}),N("click",T,a),C(b,x)};G(m,b=>{d(n)?b(v):b(g,-1)})}C(t,l),Be()}We(["click"]);var f8=M("<div></div>"),h8=M('<div style="display: flex; gap: var(--tandem-space-1); margin-bottom: var(--tandem-space-3);"></div>'),p8=M('<div style="font-size: var(--tandem-text-sm); font-weight: 600; color: var(--tandem-fg); margin-bottom: var(--tandem-space-1);"> </div> <div> </div>',1),m8=M('<div style="display: flex; justify-content: space-between; align-items: center;"><span style="font-size: var(--tandem-text-xs); color: var(--tandem-fg-subtle);"> </span> <div style="display: flex; gap: 12px; align-items: center;"><button data-testid="tutorial-dismiss-btn" style="background: none; border: none; cursor: pointer; font-size: var(--tandem-text-xs); color: var(--tandem-fg-subtle); padding: 0; text-decoration: underline;">Dismiss tutorial</button> <button data-testid="tutorial-next-btn" style="padding: var(--tandem-space-1) var(--tandem-space-3); font-size: var(--tandem-text-xs); border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-pill); background: var(--tandem-surface); color: var(--tandem-fg-muted); cursor: pointer; font-weight: 500;"> </button></div></div>'),g8=M('<div data-testid="onboarding-tutorial" style="position: fixed; bottom: 48px; left: 24px; z-index: var(--tandem-z-overlay); max-width: 340px; background: var(--tandem-surface); border-left: 4px solid var(--tandem-accent); border-radius: var(--tandem-r-4); box-shadow: var(--tandem-shadow-2); padding: var(--tandem-space-4) var(--tandem-space-5); font-family: inherit;"><!> <!> <!></div>');function v8(t,e){ze(e,!0);const n=[{id:"review",title:"Review an annotation",text:"Open the side panel and accept or dismiss one of the highlighted annotations. Try Review Mode (Ctrl+Shift+R) for keyboard shortcuts."},{id:"question",title:"Ask a question",text:"Select text and click Comment to send a question to your AI (Claude, in the default setup) — or click Note to keep a private thought to yourself. You can also use the Chat panel."},{id:"edit",title:"Make an edit",text:"Click in the document and type something. All changes sync in real-time."},{id:"cowork",title:"Claude Desktop Cowork detected",text:""},{id:"complete",title:"You're ready!",text:"You've learned the basics. Press ? anytime to see keyboard shortcuts."}],r=Lt(),i=EC(),o=F(()=>r&&SC(e.coworkStatus,i)),s=F(()=>n.filter(m=>m.id!=="cowork"||d(o))),a=F(()=>d(s).length-1),l=F(()=>d(s)[e.currentStep]),u=F(()=>e.currentStep>=d(a)),c=F(()=>{var m;return((m=d(l))==null?void 0:m.id)==="cowork"});var f=kt(),h=Se(f);{var p=m=>{var v=g8(),g=w(v);{var b=E=>{var D=h8();Je(D,20,()=>Array.from({length:d(a)},(P,R)=>R),P=>P,(P,R)=>{var H=f8();q(()=>xe(H,`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;`)),C(P,H)}),C(E,D)};G(g,E=>{d(u)||E(b)})}var x=k(g,2);{var _=E=>{d8(E,{get status(){return e.coworkStatus},get onAdvance(){return e.onNext}})},T=E=>{var D=p8(),P=Se(D),R=w(P),H=k(P,2),Q=w(H);q(()=>{ee(R,d(l).title),xe(H,`font-size: var(--tandem-text-base); line-height: 1.5; color: var(--tandem-fg-muted); margin-bottom: ${d(u)?0:14}px;`),ee(Q,d(l).text)}),C(E,D)};G(x,E=>{d(c)&&e.coworkStatus!==null?E(_):E(T,-1)})}var S=k(x,2);{var z=E=>{var D=m8(),P=w(D),R=w(P),H=k(P,2),Q=w(H),Z=k(Q,2),$=w(Z);q(()=>{ee(R,`Step ${e.currentStep+1} of ${d(a)??""}`),ee($,e.currentStep===d(a)-1?"Done":"Next")}),N("click",Q,function(...W){var te;(te=e.onDismiss)==null||te.apply(this,W)}),N("click",Z,function(...W){var te;(te=e.onNext)==null||te.apply(this,W)}),C(E,D)};G(S,E=>{!d(u)&&!d(c)&&E(z)})}C(m,v)};G(h,m=>{d(l)&&m(p)})}C(t,f),Be()}We(["click"]);const ii=()=>new Map,T0=t=>{const e=ii();return t.forEach((n,r)=>{e.set(r,n)}),e},ro=(t,e,n)=>{let r=t.get(e);return r===void 0&&t.set(e,r=n()),r},b8=(t,e)=>{const n=[];for(const[r,i]of t)n.push(e(i,r));return n},y8=(t,e)=>{for(const[n,r]of t)if(e(r,n))return!0;return!1},ga=()=>new Set,zm=t=>t[t.length-1],w8=(t,e)=>{for(let n=0;n<e.length;n++)t.push(e[n])},xs=Array.from,lb=(t,e)=>{for(let n=0;n<t.length;n++)if(!e(t[n],n,t))return!1;return!0},ub=(t,e)=>{for(let n=0;n<t.length;n++)if(e(t[n],n,t))return!0;return!1},k8=(t,e)=>{const n=new Array(t);for(let r=0;r<t;r++)n[r]=e(r,n);return n},Rl=Array.isArray;class BC{constructor(){this._observers=ii()}on(e,n){return ro(this._observers,e,ga).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 xs((this._observers.get(e)||ii()).values()).forEach(r=>r(...n))}destroy(){this._observers=ii()}}const ki=Math.floor,_f=Math.abs,So=(t,e)=>t<e?t:e,xi=(t,e)=>t>e?t:e,HC=t=>t!==0?t<0:1/t<0,rw=1,iw=2,Bm=4,Hm=8,hc=32,Eo=64,ur=128,x8=1<<29,Mp=31,M0=63,oa=127,_8=2147483647,rh=Number.MAX_SAFE_INTEGER,ow=Number.MIN_SAFE_INTEGER,C8=Number.isInteger||(t=>typeof t=="number"&&isFinite(t)&&ki(t)===t),VC=String.fromCharCode,S8=t=>t.toLowerCase(),E8=/^\s*/g,A8=t=>t.replace(E8,""),T8=/([A-Z])/g,sw=(t,e)=>A8(t.replace(T8,n=>`${e}${S8(n)}`)),M8=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},pc=typeof TextEncoder<"u"?new TextEncoder:null,D8=t=>pc.encode(t),O8=pc?D8:M8;let Fu=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});Fu&&Fu.decode(new Uint8Array).length===1&&(Fu=null);const I8=(t,e)=>k8(e,()=>t).join("");let od=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}};const sd=()=>new od,R8=t=>{const e=sd();return t(e),yi(e)},N8=t=>{let e=t.cpos;for(let n=0;n<t.bufs.length;n++)e+=t.bufs[n].length;return e},yi=t=>{const e=new Uint8Array(N8(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},P8=(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(xi(n,e)*2),t.cpos=0)},xn=(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},D0=xn,_t=(t,e)=>{for(;e>oa;)xn(t,ur|oa&e),e=ki(e/128);xn(t,oa&e)},cb=(t,e)=>{const n=HC(e);for(n&&(e=-e),xn(t,(e>M0?ur:0)|(n?Eo:0)|M0&e),e=ki(e/64);e>0;)xn(t,(e>oa?ur:0)|oa&e),e=ki(e/128)},O0=new Uint8Array(3e4),L8=O0.length/3,F8=(t,e)=>{if(e.length<L8){const n=pc.encodeInto(e,O0).written||0;_t(t,n);for(let r=0;r<n;r++)xn(t,O0[r])}else Mr(t,O8(e))},z8=(t,e)=>{const n=unescape(encodeURIComponent(e)),r=n.length;_t(t,r);for(let i=0;i<r;i++)xn(t,n.codePointAt(i))},el=pc&&pc.encodeInto?F8:z8,Dp=(t,e)=>{const n=t.cbuf.length,r=t.cpos,i=So(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(xi(n*2,o)),t.cbuf.set(e.subarray(i)),t.cpos=o)},Mr=(t,e)=>{_t(t,e.byteLength),Dp(t,e)},db=(t,e)=>{P8(t,e);const n=new DataView(t.cbuf.buffer,t.cpos,e);return t.cpos+=e,n},B8=(t,e)=>db(t,4).setFloat32(0,e,!1),H8=(t,e)=>db(t,8).setFloat64(0,e,!1),V8=(t,e)=>db(t,8).setBigInt64(0,e,!1),aw=new DataView(new ArrayBuffer(4)),U8=t=>(aw.setFloat32(0,t),aw.getFloat32(0)===t),Nl=(t,e)=>{switch(typeof e){case"string":xn(t,119),el(t,e);break;case"number":C8(e)&&_f(e)<=_8?(xn(t,125),cb(t,e)):U8(e)?(xn(t,124),B8(t,e)):(xn(t,123),H8(t,e));break;case"bigint":xn(t,122),V8(t,e);break;case"object":if(e===null)xn(t,126);else if(Rl(e)){xn(t,117),_t(t,e.length);for(let n=0;n<e.length;n++)Nl(t,e[n])}else if(e instanceof Uint8Array)xn(t,116),Mr(t,e);else{xn(t,118);const n=Object.keys(e);_t(t,n.length);for(let r=0;r<n.length;r++){const i=n[r];el(t,i),Nl(t,e[i])}}break;case"boolean":xn(t,e?120:121);break;default:xn(t,127)}};class lw extends od{constructor(e){super(),this.w=e,this.s=null,this.count=0}write(e){this.s===e?this.count++:(this.count>0&&_t(this,this.count-1),this.count=1,this.w(this,e),this.s=e)}}const uw=t=>{t.count>0&&(cb(t.encoder,t.count===1?t.s:-t.s),t.count>1&&_t(t.encoder,t.count-2))};class Cf{constructor(){this.encoder=new od,this.s=0,this.count=0}write(e){this.s===e?this.count++:(uw(this),this.count=1,this.s=e)}toUint8Array(){return uw(this),yi(this.encoder)}}const cw=t=>{if(t.count>0){const e=t.diff*2+(t.count===1?0:1);cb(t.encoder,e),t.count>1&&_t(t.encoder,t.count-2)}};class Vm{constructor(){this.encoder=new od,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(cw(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return cw(this),yi(this.encoder)}}class j8{constructor(){this.sarr=[],this.s="",this.lensE=new Cf}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 od;return this.sarr.push(this.s),this.s="",el(e,this.sarr.join("")),Dp(e,this.lensE.toUint8Array()),yi(e)}}const Xi=t=>new Error(t),oi=()=>{throw Xi("Method unimplemented")},Jn=()=>{throw Xi("Unexpected case")},UC=Xi("Unexpected end of array"),jC=Xi("Integer out of Range");let Op=class{constructor(e){this.arr=e,this.pos=0}};const Xl=t=>new Op(t),q8=t=>t.pos!==t.arr.length,W8=(t,e)=>{const n=new Uint8Array(t.arr.buffer,t.pos+t.arr.byteOffset,e);return t.pos+=e,n},Dr=t=>W8(t,gt(t)),Pl=t=>t.arr[t.pos++],gt=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&oa)*n,n*=128,i<ur)return e;if(e>rh)throw jC}throw UC},fb=t=>{let e=t.arr[t.pos++],n=e&M0,r=64;const i=(e&Eo)>0?-1:1;if((e&ur)===0)return i*n;const o=t.arr.length;for(;t.pos<o;){if(e=t.arr[t.pos++],n=n+(e&oa)*r,r*=128,e<ur)return i*n;if(n>rh)throw jC}throw UC},K8=t=>{let e=gt(t);if(e===0)return"";{let n=String.fromCodePoint(Pl(t));if(--e<100)for(;e--;)n+=String.fromCodePoint(Pl(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))}},G8=t=>Fu.decode(Dr(t)),tl=Fu?G8:K8,hb=(t,e)=>{const n=new DataView(t.arr.buffer,t.arr.byteOffset+t.pos,e);return t.pos+=e,n},Z8=t=>hb(t,4).getFloat32(0,!1),J8=t=>hb(t,8).getFloat64(0,!1),Y8=t=>hb(t,8).getBigInt64(0,!1),X8=[t=>{},t=>null,fb,Z8,J8,Y8,t=>!1,t=>!0,tl,t=>{const e=gt(t),n={};for(let r=0;r<e;r++){const i=tl(t);n[i]=mc(t)}return n},t=>{const e=gt(t),n=[];for(let r=0;r<e;r++)n.push(mc(t));return n},Dr],mc=t=>X8[127-Pl(t)](t);class dw extends Op{constructor(e,n){super(e),this.reader=n,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),q8(this)?this.count=gt(this)+1:this.count=-1),this.count--,this.s}}class Sf extends Op{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=fb(this);const e=HC(this.s);this.count=1,e&&(this.s=-this.s,this.count=gt(this)+2)}return this.count--,this.s}}class Um extends Op{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){const e=fb(this),n=e&1;this.diff=ki(e/2),this.count=1,n&&(this.count=gt(this)+2)}return this.s+=this.diff,this.count--,this.s}}class Q8{constructor(e){this.decoder=new Sf(e),this.str=tl(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 $8=crypto.getRandomValues.bind(crypto),eI=Math.random,qC=()=>$8(new Uint32Array(1))[0],tI=t=>t[ki(eI()*t.length)],nI="10000000-1000-4000-8000"+-1e11,rI=()=>nI.replace(/[018]/g,t=>(t^qC()&15>>t/4).toString(16)),iI=Date.now,fw=t=>new Promise(t);Promise.all.bind(Promise);const hw=t=>t===void 0?null:t;class oI{constructor(){this.map=new Map}setItem(e,n){this.map.set(e,n)}getItem(e){return this.map.get(e)}}let WC=new oI,sI=!0;try{typeof localStorage<"u"&&localStorage&&(WC=localStorage,sI=!1)}catch{}const aI=WC,gc=Symbol("Equality"),KC=(t,e)=>{var n;return t===e||!!((n=t==null?void 0:t[gc])!=null&&n.call(t,e))||!1},lI=t=>typeof t=="object",uI=Object.assign,GC=Object.keys,cI=(t,e)=>{for(const n in t)e(t[n],n)},ih=t=>GC(t).length,dI=t=>{for(const e in t)return!1;return!0},Ql=(t,e)=>{for(const n in t)if(!e(t[n],n))return!1;return!0},pb=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),fI=(t,e)=>t===e||ih(t)===ih(e)&&Ql(t,(n,r)=>(n!==void 0||pb(e,r))&&KC(e[r],n)),hI=Object.freeze,ZC=t=>{for(const e in t){const n=t[e];(typeof n=="object"||typeof n=="function")&&ZC(t[e])}return hI(t)},mb=(t,e,n=0)=>{try{for(;n<t.length;n++)t[n](...e)}finally{n<t.length&&mb(t,e,n+1)}},pI=t=>t,Ef=(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[gc]!=null)return t[gc](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)||!Ef(t.get(n),e.get(n)))return!1;break}case void 0:case Object:if(ih(t)!==ih(e))return!1;for(const n in t)if(!pb(t,n)||!Ef(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(!Ef(t[n],e[n]))return!1;break;default:return!1}return!0},mI=(t,e)=>e.includes(t);var JC={};const Ll=typeof process<"u"&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]",YC=typeof window<"u"&&typeof document<"u"&&!Ll;let Oi;const gI=()=>{if(Oi===void 0)if(Ll){Oi=ii();const t=process.argv;let e=null;for(let n=0;n<t.length;n++){const r=t[n];r[0]==="-"?(e!==null&&Oi.set(e,""),e=r):e!==null&&(Oi.set(e,r),e=null)}e!==null&&Oi.set(e,"")}else typeof location=="object"?(Oi=ii(),(location.search||"?").slice(1).split("&").forEach(t=>{if(t.length!==0){const[e,n]=t.split("=");Oi.set(`--${sw(e,"-")}`,n),Oi.set(`-${sw(e,"-")}`,n)}})):Oi=ii();return Oi},I0=t=>gI().has(t),oh=t=>hw(Ll?JC[t.toUpperCase().replaceAll("-","_")]:aI.getItem(t)),XC=t=>I0("--"+t)||oh(t)!==null,vI=XC("production"),bI=Ll&&mI(JC.FORCE_COLOR,["true","1","2"]),yI=bI||!I0("--no-colors")&&!XC("no-color")&&(!Ll||process.stdout.isTTY)&&(!Ll||I0("--color")||oh("COLORTERM")!==null||(oh("TERM")||"").includes("color")),wI=t=>new Uint8Array(t),kI=t=>{let e="";for(let n=0;n<t.byteLength;n++)e+=VC(t[n]);return btoa(e)},xI=t=>Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("base64"),_I=YC?kI:xI,CI=t=>{const e=wI(t.byteLength);return e.set(t),e},SI=t=>R8(e=>Nl(e,t));class EI{constructor(e,n){this.left=e,this.right=n}}const uo=(t,e)=>new EI(t,e),pw=t=>t.next()>=.5,jm=(t,e,n)=>ki(t.next()*(n+1-e)+e),QC=(t,e,n)=>ki(t.next()*(n+1-e)+e),gb=(t,e,n)=>QC(t,e,n),AI=t=>VC(gb(t,97,122)),TI=(t,e=0,n=20)=>{const r=gb(t,e,n);let i="";for(let o=0;o<r;o++)i+=AI(t);return i},qm=(t,e)=>e[gb(t,0,e.length-1)],MI=Symbol("0schema");class DI{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(I8(" ",(this._rerrs.length-n)*2)+`${r.path!=null?`[${r.path}] `:""}${r.has} doesn't match ${r.expected}. ${r.message}`)}return e.join(`
|
|
56
|
+
`)}}const R0=(t,e)=>t===e?!0:t==null||e==null||t.constructor!==e.constructor?!1:t[gc]?KC(t,e):Rl(t)?lb(t,n=>ub(e,r=>R0(n,r))):lI(t)?Ql(t,(n,r)=>R0(n,e[r])):!1;class $n{extends(e){let[n,r]=[this.shape,e.shape];return this.constructor._dilutes&&([r,n]=[n,r]),R0(n,r)}equals(e){return this.constructor===e.constructor&&Ef(this.shape,e.shape)}[MI](){return!0}[gc](e){return this.equals(e)}validate(e){return this.check(e)}check(e,n){oi()}get nullable(){return $l(this,Lp)}get optional(){return new tS(this)}cast(e){return mw(e,this),e}expect(e){return mw(e,this),e}}wn($n,"_dilutes",!1);class vb extends $n{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 mn=(t,e=null)=>new vb(t,e);mn(vb);class bb extends $n{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 On=t=>new bb(t);mn(bb);class Ip extends $n{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 Rp=(...t)=>new Ip(t),$C=mn(Ip),OI=RegExp.escape||(t=>t.replace(/[().|&,$^[\]]/g,e=>"\\"+e)),eS=t=>{if(Fl.check(t))return[OI(t)];if($C.check(t))return t.shape.map(e=>e+"");if(cS.check(t))return["[+-]?\\d+.?\\d*"];if(dS.check(t))return[".*"];if(ah.check(t))return t.shape.map(eS).flat(1);Jn()};class II extends $n{constructor(e){super(),this.shape=e,this._r=new RegExp("^"+e.map(eS).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}}mn(II);const RI=Symbol("optional");class tS extends $n{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[RI](){return!0}}const NI=mn(tS);class PI extends $n{check(e,n){return n==null||n.extend(null,"never",typeof e),!1}}mn(PI);const pp=class pp extends $n{constructor(e,n=!1){super(),this.shape=e,this._isPartial=n}get partial(){return new pp(this.shape,!0)}check(e,n){return e==null?(n==null||n.extend(null,"object","null"),!1):Ql(this.shape,(r,i)=>{const o=this._isPartial&&!pb(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})}};wn(pp,"_dilutes",!0);let sh=pp;const LI=t=>new sh(t),FI=mn(sh),zI=On(t=>t!=null&&(t.constructor===Object||t.constructor==null));class nS extends $n{constructor(e,n){super(),this.shape={keys:e,values:n}}check(e,n){return e!=null&&Ql(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 rS=(t,e)=>new nS(t,e),BI=mn(nS);class iS extends $n{constructor(e){super(),this.shape=e}check(e,n){return e!=null&&Ql(this.shape,(r,i)=>{const o=r.check(e[i],n);return!o&&(n==null||n.extend(i.toString(),"Tuple",typeof r)),o})}}const HI=(...t)=>new iS(t);mn(iS);class oS extends $n{constructor(e){super(),this.shape=e.length===1?e[0]:new Np(e)}check(e,n){const r=Rl(e)&&lb(e,i=>this.shape.check(i));return!r&&(n==null||n.extend(null,"Array","")),r}}const sS=(...t)=>new oS(t),VI=mn(oS),UI=On(t=>Rl(t));class aS extends $n{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 jI=(t,e=null)=>new aS(t,e);mn(aS);const qI=jI($n);class WI extends $n{constructor(e){super(),this.len=e.length-1,this.args=HI(...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 KI=mn(WI),GI=On(t=>typeof t=="function");class ZI extends $n{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}}mn(ZI,t=>t.shape.length>0);class Np extends $n{constructor(e){super(),this.shape=e}check(e,n){const r=ub(this.shape,i=>i.check(e,n));return n==null||n.extend(null,"Union",typeof e),r}}wn(Np,"_dilutes",!0);const $l=(...t)=>t.findIndex(e=>ah.check(e))>=0?$l(...t.map(e=>vc(e)).map(e=>ah.check(e)?e.shape:[e]).flat(1)):t.length===1?t[0]:new Np(t),ah=mn(Np),lS=()=>!0,lh=On(lS),JI=mn(bb,t=>t.shape===lS),yb=On(t=>typeof t=="bigint"),YI=On(t=>t===yb),uS=On(t=>typeof t=="symbol");On(t=>t===uS);const nl=On(t=>typeof t=="number"),cS=On(t=>t===nl),Fl=On(t=>typeof t=="string"),dS=On(t=>t===Fl),Pp=On(t=>typeof t=="boolean"),XI=On(t=>t===Pp),fS=Rp(void 0);mn(Ip,t=>t.shape.length===1&&t.shape[0]===void 0);Rp(void 0);const Lp=Rp(null),QI=mn(Ip,t=>t.shape.length===1&&t.shape[0]===null);mn(Uint8Array);mn(vb,t=>t.shape===Uint8Array);const $I=$l(nl,Fl,Lp,fS,yb,Pp,uS);(()=>{const t=sS(lh),e=rS(Fl,lh),n=$l(nl,Fl,Lp,Pp,t,e);return t.shape=n,e.shape.values=n,n})();const vc=t=>{if(qI.check(t))return t;if(zI.check(t)){const e={};for(const n in t)e[n]=vc(t[n]);return LI(e)}else{if(UI.check(t))return $l(...t.map(vc));if($I.check(t))return Rp(t);if(GI.check(t))return mn(t)}Jn()},mw=vI?()=>{}:(t,e)=>{const n=new DI;if(!e.check(t,n))throw Xi(`Expected value to be of type ${e.constructor.name}.
|
|
57
|
+
${n.toString()}`)};class eR{constructor(e){this.patterns=[],this.$state=e}if(e,n){return this.patterns.push({if:vc(e),h:n}),this}else(e){return this.if(lh,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 Xi("Unhandled pattern")}}}const tR=t=>new eR(t),hS=tR(lh).if(cS,(t,e)=>jm(e,ow,rh)).if(dS,(t,e)=>TI(e)).if(XI,(t,e)=>pw(e)).if(YI,(t,e)=>BigInt(jm(e,ow,rh))).if(ah,(t,e)=>Pa(e,qm(e,t.shape))).if(FI,(t,e)=>{const n={};for(const r in t.shape){let i=t.shape[r];if(NI.check(i)){if(pw(e))continue;i=i.shape}n[r]=hS(i,e)}return n}).if(VI,(t,e)=>{const n=[],r=QC(e,0,42);for(let i=0;i<r;i++)n.push(Pa(e,t.shape));return n}).if($C,(t,e)=>qm(e,t.shape)).if(QI,(t,e)=>null).if(KI,(t,e)=>{const n=Pa(e,t.res);return()=>n}).if(JI,(t,e)=>Pa(e,qm(e,[nl,Fl,Lp,fS,yb,Pp,sS(nl),rS($l("a","b","c"),nl)]))).if(BI,(t,e)=>{const n={},r=jm(e,0,3);for(let i=0;i<r;i++){const o=Pa(e,t.shape.keys),s=Pa(e,t.shape.values);n[o]=s}return n}).done(),Pa=(t,e)=>hS(vc(e),t),ad=typeof document<"u"?document:{};On(t=>t.nodeType===sR);typeof DOMParser<"u"&&new DOMParser;On(t=>t.nodeType===rR);On(t=>t.nodeType===iR);const nR=t=>b8(t,(e,n)=>`${n}:${e};`).join(""),rR=ad.ELEMENT_NODE,iR=ad.TEXT_NODE,oR=ad.DOCUMENT_NODE,sR=ad.DOCUMENT_FRAGMENT_NODE;On(t=>t.nodeType===oR);const aR=t=>class{constructor(n){this._=n}destroy(){t(this._)}},lR=aR(clearTimeout),wb=(t,e)=>new lR(setTimeout(e,t)),Lo=Symbol,pS=Lo(),mS=Lo(),uR=Lo(),cR=Lo(),dR=Lo(),gS=Lo(),fR=Lo(),kb=Lo(),hR=Lo(),pR=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},mR={[pS]:uo("font-weight","bold"),[mS]:uo("font-weight","normal"),[uR]:uo("color","blue"),[dR]:uo("color","green"),[cR]:uo("color","grey"),[gS]:uo("color","red"),[fR]:uo("color","purple"),[kb]:uo("color","orange"),[hR]:uo("color","black")},gR=t=>{var s;t.length===1&&((s=t[0])==null?void 0:s.constructor)===Function&&(t=t[0]());const e=[],n=[],r=ii();let i=[],o=0;for(;o<t.length;o++){const a=t[o],l=mR[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 u=nR(r);o>0||u.length>0?(e.push("%c"+a),n.push(u)):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},vS=yI?gR:pR,vR=(...t)=>{console.log(...vS(t)),yS.forEach(e=>e.print(t))},bS=(...t)=>{console.warn(...vS(t)),t.unshift(kb),yS.forEach(e=>e.print(t))},yS=ga(),wS=t=>({[Symbol.iterator](){return this},next:t}),bR=(t,e)=>wS(()=>{let n;do n=t.next();while(!n.done&&!e(n.value));return n}),Wm=(t,e)=>wS(()=>{const{done:n,value:r}=t.next();return{done:n,value:n?void 0:e(r)}});class Fp{constructor(e,n){this.clock=e,this.len=n}}class eu{constructor(){this.clients=new Map}}const _s=(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,u=r[l];l<r.length&&u.clock<a;u=r[++l])NS(t,o,u.clock,u.len,n)}}),yR=(t,e)=>{let n=0,r=t.length-1;for(;n<=r;){const i=ki((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},tu=(t,e)=>{const n=t.clients.get(e.client);return n!==void 0&&yR(n,e.clock)!==null},xb=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 Fp(i.clock,xi(i.len,o.clock+o.len-i.clock)):(r<n&&(e[r]=o),r++)}e.length=r})},N0=t=>{const e=new eu;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++)w8(o,t[s].clients.get(i)||[]);e.clients.set(i,o)}});return xb(e),e},bc=(t,e,n,r)=>{ro(t.clients,e,()=>[]).push(new Fp(n,r))},kS=()=>new eu,xS=t=>{const e=kS();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 u=n[o+1];o+1<n.length&&u.deleted;u=n[++o+1])l+=u.length;i.push(new Fp(a,l))}}i.length>0&&e.clients.set(r,i)}),e},nu=(t,e)=>{_t(t.restEncoder,e.clients.size),xs(e.clients.entries()).sort((n,r)=>r[0]-n[0]).forEach(([n,r])=>{t.resetDsCurVal(),_t(t.restEncoder,n);const i=r.length;_t(t.restEncoder,i);for(let o=0;o<i;o++){const s=r[o];t.writeDsClock(s.clock),t.writeDsLen(s.len)}})},_b=t=>{const e=new eu,n=gt(t.restDecoder);for(let r=0;r<n;r++){t.resetDsCurVal();const i=gt(t.restDecoder),o=gt(t.restDecoder);if(o>0){const s=ro(e.clients,i,()=>[]);for(let a=0;a<o;a++)s.push(new Fp(t.readDsClock(),t.readDsLen()))}}return e},gw=(t,e,n)=>{const r=new eu,i=gt(t.restDecoder);for(let o=0;o<i;o++){t.resetDsCurVal();const s=gt(t.restDecoder),a=gt(t.restDecoder),l=n.clients.get(s)||[],u=cn(n,s);for(let c=0;c<a;c++){const f=t.readDsClock(),h=f+t.readDsLen();if(f<u){u<h&&bc(r,s,u,h-u);let p=_i(l,f),m=l[p];for(!m.deleted&&m.id.clock<f&&(l.splice(p+1,0,mh(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,mh(e,m,h-m.id.clock)),m.delete(e))}else bc(r,s,f,h-f)}}if(r.clients.size>0){const o=new va;return _t(o.restEncoder,0),nu(o,r),o.toUint8Array()}return null},_S=qC;class Qi extends BC{constructor({guid:e=rI(),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=_S(),this.guid=e,this.collectionid=n,this.share=new Map,this.store=new IS,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=fw(u=>{this.on("load",()=>{this.isLoaded=!0,u(this)})});const l=()=>fw(u=>{const c=f=>{(f===void 0||f===!0)&&(this.off("sync",c),u())};this.on("sync",c)});this.on("sync",u=>{u===!1&&this.isSynced&&(this.whenSynced=l()),this.isSynced=u===void 0||u===!0,this.isSynced&&!this.isLoaded&&this.emit("load",[this])}),this.whenSynced=l()}load(){const e=this._item;e!==null&&!this.shouldLoad&&Bt(e.parent.doc,n=>{n.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(xs(this.subdocs).map(e=>e.guid))}transact(e,n=null){return Bt(this,e,n)}get(e,n=An){const r=ro(this.share,e,()=>{const o=new n;return o._integrate(this,null),o}),i=r.constructor;if(n!==An&&i!==n)if(i===An){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,ol)}getText(e=""){return this.get(e,Cs)}getMap(e=""){return this.get(e,Bl)}getXmlElement(e=""){return this.get(e,Qt)}getXmlFragment(e=""){return this.get(e,ba)}toJSON(){const e={};return this.share.forEach((n,r)=>{e[r]=n.toJSON()}),e}destroy(){this.isDestroyed=!0,xs(this.subdocs).forEach(n=>n.destroy());const e=this._item;if(e!==null){this._item=null;const n=e.content;n.doc=new Qi({guid:this.guid,...n.opts,shouldLoad:!1}),n.doc._item=e,Bt(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 CS{constructor(e){this.restDecoder=e}resetDsCurVal(){}readDsClock(){return gt(this.restDecoder)}readDsLen(){return gt(this.restDecoder)}}class SS extends CS{readLeftID(){return lt(gt(this.restDecoder),gt(this.restDecoder))}readRightID(){return lt(gt(this.restDecoder),gt(this.restDecoder))}readClient(){return gt(this.restDecoder)}readInfo(){return Pl(this.restDecoder)}readString(){return tl(this.restDecoder)}readParentInfo(){return gt(this.restDecoder)===1}readTypeRef(){return gt(this.restDecoder)}readLen(){return gt(this.restDecoder)}readAny(){return mc(this.restDecoder)}readBuf(){return CI(Dr(this.restDecoder))}readJSON(){return JSON.parse(tl(this.restDecoder))}readKey(){return tl(this.restDecoder)}}class wR{constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=gt(this.restDecoder),this.dsCurrVal}readDsLen(){const e=gt(this.restDecoder)+1;return this.dsCurrVal+=e,e}}class zl extends wR{constructor(e){super(e),this.keys=[],gt(e),this.keyClockDecoder=new Um(Dr(e)),this.clientDecoder=new Sf(Dr(e)),this.leftClockDecoder=new Um(Dr(e)),this.rightClockDecoder=new Um(Dr(e)),this.infoDecoder=new dw(Dr(e),Pl),this.stringDecoder=new Q8(Dr(e)),this.parentInfoDecoder=new dw(Dr(e),Pl),this.typeRefDecoder=new Sf(Dr(e)),this.lenDecoder=new Sf(Dr(e))}readLeftID(){return new rl(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new rl(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 mc(this.restDecoder)}readBuf(){return Dr(this.restDecoder)}readJSON(){return mc(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 ES{constructor(){this.restEncoder=sd()}toUint8Array(){return yi(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){_t(this.restEncoder,e)}writeDsLen(e){_t(this.restEncoder,e)}}class ld extends ES{writeLeftID(e){_t(this.restEncoder,e.client),_t(this.restEncoder,e.clock)}writeRightID(e){_t(this.restEncoder,e.client),_t(this.restEncoder,e.clock)}writeClient(e){_t(this.restEncoder,e)}writeInfo(e){D0(this.restEncoder,e)}writeString(e){el(this.restEncoder,e)}writeParentInfo(e){_t(this.restEncoder,e?1:0)}writeTypeRef(e){_t(this.restEncoder,e)}writeLen(e){_t(this.restEncoder,e)}writeAny(e){Nl(this.restEncoder,e)}writeBuf(e){Mr(this.restEncoder,e)}writeJSON(e){el(this.restEncoder,JSON.stringify(e))}writeKey(e){el(this.restEncoder,e)}}class AS{constructor(){this.restEncoder=sd(),this.dsCurrVal=0}toUint8Array(){return yi(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){const n=e-this.dsCurrVal;this.dsCurrVal=e,_t(this.restEncoder,n)}writeDsLen(e){e===0&&Jn(),_t(this.restEncoder,e-1),this.dsCurrVal+=e}}class va extends AS{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new Vm,this.clientEncoder=new Cf,this.leftClockEncoder=new Vm,this.rightClockEncoder=new Vm,this.infoEncoder=new lw(D0),this.stringEncoder=new j8,this.parentInfoEncoder=new lw(D0),this.typeRefEncoder=new Cf,this.lenEncoder=new Cf}toUint8Array(){const e=sd();return _t(e,0),Mr(e,this.keyClockEncoder.toUint8Array()),Mr(e,this.clientEncoder.toUint8Array()),Mr(e,this.leftClockEncoder.toUint8Array()),Mr(e,this.rightClockEncoder.toUint8Array()),Mr(e,yi(this.infoEncoder)),Mr(e,this.stringEncoder.toUint8Array()),Mr(e,yi(this.parentInfoEncoder)),Mr(e,this.typeRefEncoder.toUint8Array()),Mr(e,this.lenEncoder.toUint8Array()),Dp(e,yi(this.restEncoder)),yi(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){Nl(this.restEncoder,e)}writeBuf(e){Mr(this.restEncoder,e)}writeJSON(e){Nl(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 kR=(t,e,n,r)=>{r=xi(r,e[0].id.clock);const i=_i(e,r);_t(t.restEncoder,e.length-i),t.writeClient(n),_t(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)},Cb=(t,e,n)=>{const r=new Map;n.forEach((i,o)=>{cn(e,o)>i&&r.set(o,i)}),ud(e).forEach((i,o)=>{n.has(o)||r.set(o,0)}),_t(t.restEncoder,r.size),xs(r.entries()).sort((i,o)=>o[0]-i[0]).forEach(([i,o])=>{kR(t,e.clients.get(i),i,o)})},xR=(t,e)=>{const n=ii(),r=gt(t.restDecoder);for(let i=0;i<r;i++){const o=gt(t.restDecoder),s=new Array(o),a=t.readClient();let l=gt(t.restDecoder);n.set(a,{i:0,refs:s});for(let u=0;u<o;u++){const c=t.readInfo();switch(Mp&c){case 0:{const f=t.readLen();s[u]=new Qr(lt(a,l),f),l+=f;break}case 10:{const f=gt(t.restDecoder);s[u]=new $r(lt(a,l),f),l+=f;break}default:{const f=(c&(Eo|ur))===0,h=new jt(lt(a,l),null,(c&ur)===ur?t.readLeftID():null,null,(c&Eo)===Eo?t.readRightID():null,f?t.readParentInfo()?e.get(t.readString()):t.readLeftID():null,f&&(c&hc)===hc?t.readString():null,n3(t,c));s[u]=h,l+=h.length}}}}return n},_R=(t,e,n)=>{const r=[];let i=xs(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 IS,l=new Map,u=(p,m)=>{const v=l.get(p);(v==null||v>m)&&l.set(p,m)};let c=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(c.constructor!==$r){const m=ro(f,c.id.client,()=>cn(e,c.id.client))-c.id.clock;if(m<0)r.push(c),u(c.id.client,c.id.clock-1),h();else{const v=c.getMissing(t,e);if(v!==null){r.push(c);const g=n.get(v)||{refs:[],i:0};if(g.refs.length===g.i)u(v,cn(e,v)),h();else{c=g.refs[g.i++];continue}}else(m===0||m<c.length)&&(c.integrate(t,m),f.set(c.id.client,c.id.clock+c.length))}}if(r.length>0)c=r.pop();else if(s!==null&&s.i<s.refs.length)c=s.refs[s.i++];else{if(s=o(),s===null)break;c=s.refs[s.i++]}}if(a.clients.size>0){const p=new va;return Cb(p,a,new Map),_t(p.restEncoder,0),{missing:l,update:p.toUint8Array()}}return null},CR=(t,e)=>Cb(t,e.doc.store,e.beforeState),SR=(t,e,n,r=new zl(t))=>Bt(e,i=>{i.local=!1;let o=!1;const s=i.doc,a=s.store,l=xR(r,s),u=_R(i,a,l),c=a.pendingStructs;if(c){for(const[h,p]of c.missing)if(p<cn(a,h)){o=!0;break}if(u){for(const[h,p]of u.missing){const m=c.missing.get(h);(m==null||m>p)&&c.missing.set(h,p)}c.update=ch([c.update,u.update])}}else a.pendingStructs=u;const f=gw(r,i,a);if(a.pendingDs){const h=new zl(Xl(a.pendingDs));gt(h.restDecoder);const p=gw(h,i,a);f&&p?a.pendingDs=ch([f,p]):a.pendingDs=f||p}else a.pendingDs=f;if(o){const h=a.pendingStructs.update;a.pendingStructs=null,uh(i.doc,h)}},n,!1),uh=(t,e,n,r=zl)=>{const i=Xl(e);SR(i,t,n,new r(i))},ER=(t,e,n)=>uh(t,e,n,SS),AR=(t,e,n=new Map)=>{Cb(t,e.store,n),nu(t,xS(e.store))},TR=(t,e=new Uint8Array([0]),n=new va)=>{const r=TS(e);AR(n,t,r);const i=[n.toUint8Array()];if(t.store.pendingDs&&i.push(t.store.pendingDs),t.store.pendingStructs&&i.push(GR(t.store.pendingStructs.update,e)),i.length>1){if(n.constructor===ld)return WR(i.map((o,s)=>s===0?o:JR(o)));if(n.constructor===va)return ch(i)}return i[0]},MR=(t,e)=>TR(t,e,new ld),DR=t=>{const e=new Map,n=gt(t.restDecoder);for(let r=0;r<n;r++){const i=gt(t.restDecoder),o=gt(t.restDecoder);e.set(i,o)}return e},TS=t=>DR(new CS(Xl(t))),MS=(t,e)=>(_t(t.restEncoder,e.size),xs(e.entries()).sort((n,r)=>r[0]-n[0]).forEach(([n,r])=>{_t(t.restEncoder,n),_t(t.restEncoder,r)}),t),OR=(t,e)=>MS(t,ud(e.store)),IR=(t,e=new AS)=>(t instanceof Map?MS(e,t):OR(e,t),e.toUint8Array()),RR=t=>IR(t,new ES);class NR{constructor(){this.l=[]}}const vw=()=>new NR,bw=(t,e)=>t.l.push(e),yw=(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.")},DS=(t,e,n)=>mb(t.l,[e,n]);class rl{constructor(e,n){this.client=e,this.clock=n}}const Ja=(t,e)=>t===e||t!==null&&e!==null&&t.client===e.client&&t.clock===e.clock,lt=(t,e)=>new rl(t,e),yc=t=>{for(const[e,n]of t.doc.share.entries())if(n===t)return e;throw Jn()},wc=(t,e)=>{for(;e!==null;){if(e.parent===t)return!0;e=e.parent._item}return!1};class kc{constructor(e,n,r,i=0){this.type=e,this.tname=n,this.item=r,this.assoc=i}}const sa=t=>new kc(t.type==null?null:lt(t.type.client,t.type.clock),t.tname??null,t.item==null?null:lt(t.item.client,t.item.clock),t.assoc==null?0:t.assoc);class PR{constructor(e,n,r=0){this.type=e,this.index=n,this.assoc=r}}const LR=(t,e,n=0)=>new PR(t,e,n),Nd=(t,e,n)=>{let r=null,i=null;return t._item===null?i=yc(t):r=lt(t._item.id.client,t._item.id.clock),new kc(r,i,e,n)},Km=(t,e,n=0)=>{let r=t._start;if(n<0){if(e===0)return Nd(t,null,n);e--}for(;r!==null;){if(!r.deleted&&r.countable){if(r.length>e)return Nd(t,lt(r.id.client,r.id.clock+e),n);e-=r.length}if(r.right===null&&n<0)return Nd(t,r.lastId,n);r=r.right}return Nd(t,null,n)},FR=(t,e)=>{const n=il(t,e),r=e.clock-n.id.clock;return{item:n,diff:r}},P0=(t,e,n=!0)=>{const r=e.store,i=t.item,o=t.type,s=t.tname,a=t.assoc;let l=null,u=0;if(i!==null){if(cn(r,i.client)<=i.clock)return null;const c=n?B0(r,i):FR(r,i),f=c.item;if(!(f instanceof jt))return null;if(l=f.parent,l._item===null||!l._item.deleted){u=f.deleted||!f.countable?0:c.diff+(a>=0?0:1);let h=f.left;for(;h!==null;)!h.deleted&&h.countable&&(u+=h.length),h=h.left}}else{if(s!==null)l=e.get(s);else if(o!==null){if(cn(r,o.client)<=o.clock)return null;const{item:c}=n?B0(r,o):{item:il(r,o)};if(c instanceof jt&&c.content instanceof Si)l=c.content.type;else return null}else throw Jn();a>=0?u=l._length:u=0}return LR(l,u,t.assoc)},ww=(t,e)=>t===e||t!==null&&e!==null&&t.tname===e.tname&&Ja(t.item,e.item)&&Ja(t.type,e.type)&&t.assoc===e.assoc;class Sb{constructor(e,n){this.ds=e,this.sv=n}}const OS=(t,e)=>new Sb(t,e),Gm=t=>OS(xS(t.store),ud(t.store)),Fs=(t,e)=>e===void 0?!t.deleted:e.sv.has(t.id.client)&&(e.sv.get(t.id.client)||0)>t.id.clock&&!tu(e.ds,t.id),L0=(t,e)=>{const n=ro(t.meta,L0,ga),r=t.doc.store;n.has(e)||(e.sv.forEach((i,o)=>{i<cn(r,o)&&kr(t,lt(o,i))}),_s(t,e.ds,i=>{}),n.add(e))};class IS{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}}const ud=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},cn=(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},RS=(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 Jn()}n.push(e)},_i=(t,e)=>{let n=0,r=t.length-1,i=t[r],o=i.id.clock;if(o===e)return r;let s=ki(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=ki((n+r)/2)}throw Jn()},zR=(t,e)=>{const n=t.clients.get(e.client);return n[_i(n,e.clock)]},il=zR,F0=(t,e,n)=>{const r=_i(e,n),i=e[r];return i.id.clock<n&&i instanceof jt?(e.splice(r+1,0,mh(t,i,n-i.id.clock)),r+1):r},kr=(t,e)=>{const n=t.doc.store.clients.get(e.client);return n[F0(t,n,e.clock)]},kw=(t,e,n)=>{const r=e.clients.get(n.client),i=_i(r,n.clock),o=r[i];return n.clock!==o.id.clock+o.length-1&&o.constructor!==Qr&&r.splice(i+1,0,mh(t,o,n.clock-o.id.clock+1)),o},BR=(t,e,n)=>{const r=t.clients.get(e.id.client);r[_i(r,e.id.clock)]=n},NS=(t,e,n,r,i)=>{if(r===0)return;const o=n+r;let s=F0(t,e,n),a;do a=e[s++],o<a.id.clock+a.length&&F0(t,e,o),i(a);while(s<e.length&&e[s].id.clock<o)};class HR{constructor(e,n,r){this.doc=e,this.deleteSet=new eu,this.beforeState=ud(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&&!y8(e.afterState,(n,r)=>e.beforeState.get(r)!==n)?!1:(xb(e.deleteSet),CR(t,e),nu(t,e.deleteSet),!0),_w=(t,e,n)=>{const r=e._item;(r===null||r.id.clock<(t.beforeState.get(r.id.client)||0)&&!r.deleted)&&ro(t.changed,e,ga).add(n)},Af=(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 jt&&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},VR=(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 u=_i(o,a.clock),c=o[u];u<o.length&&c.id.clock<l;c=o[++u]){const f=o[u];if(a.clock+a.len<=f.id.clock)break;f instanceof jt&&f.deleted&&!f.keep&&n(f)&&f.gc(e,!1)}}}},UR=(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=So(i.length-1,1+_i(i,s.clock+s.len-1));for(let l=a,u=i[l];l>0&&u.id.clock>=s.clock;u=i[l])l-=1+Af(i,l)}})},PS=(t,e)=>{if(e<t.length){const n=t[e],r=n.doc,i=r.store,o=n.deleteSet,s=n._mergeStructs;try{xb(o),n.afterState=ud(n.doc.store),r.emit("beforeObserverCalls",[n,r]);const a=[];n.changed.forEach((l,u)=>a.push(()=>{(u._item===null||!u._item.deleted)&&u._callObserver(n,l)})),a.push(()=>{n.changedParentTypes.forEach((l,u)=>{u._dEH.l.length>0&&(u._item===null||!u._item.deleted)&&(l=l.filter(c=>c.target._item===null||!c.target._item.deleted),l.forEach(c=>{c.currentTarget=u,c._path=null}),l.sort((c,f)=>c.path.length-f.path.length),a.push(()=>{DS(u._dEH,l,n)}))}),a.push(()=>r.emit("afterTransaction",[n,r])),a.push(()=>{n._needFormattingCleanup&&uN(n)})}),mb(a,[])}finally{r.gc&&VR(o,i,r.gcFilter),UR(o,i),n.afterState.forEach((c,f)=>{const h=n.beforeState.get(f)||0;if(h!==c){const p=i.clients.get(f),m=xi(_i(p,h),1);for(let v=p.length-1;v>=m;)v-=1+Af(p,v)}});for(let c=s.length-1;c>=0;c--){const{client:f,clock:h}=s[c].id,p=i.clients.get(f),m=_i(p,h);m+1<p.length&&Af(p,m+1)>1||m>0&&Af(p,m)}if(!n.local&&n.afterState.get(r.clientID)!==n.beforeState.get(r.clientID)&&(vR(kb,pS,"[yjs] ",mS,gS,"Changed the client-id because another client seems to be using it."),r.clientID=_S()),r.emit("afterTransactionCleanup",[n,r]),r._observers.has("update")){const c=new ld;xw(c,n)&&r.emit("update",[c.toUint8Array(),n.origin,r,n])}if(r._observers.has("updateV2")){const c=new va;xw(c,n)&&r.emit("updateV2",[c.toUint8Array(),n.origin,r,n])}const{subdocsAdded:a,subdocsLoaded:l,subdocsRemoved:u}=n;(a.size>0||u.size>0||l.size>0)&&(a.forEach(c=>{c.clientID=r.clientID,c.collectionid==null&&(c.collectionid=r.collectionid),r.subdocs.add(c)}),u.forEach(c=>r.subdocs.delete(c)),r.emit("subdocs",[{loaded:l,added:a,removed:u},r,n]),u.forEach(c=>c.destroy())),t.length<=e+1?(r._transactionCleanups=[],r.emit("afterAllTransactions",[r,t])):PS(t,e+1)}}},Bt=(t,e,n=null,r=!0)=>{const i=t._transactionCleanups;let o=!1,s=null;t._transaction===null&&(o=!0,t._transaction=new HR(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&&PS(i,0)}}return s};class jR{constructor(e,n){this.insertions=n,this.deletions=e,this.meta=new Map}}const Cw=(t,e,n)=>{_s(t,n.deletions,r=>{r instanceof jt&&e.scope.some(i=>i===t.doc||wc(i,r))&&Rb(r,!1)})},Sw=(t,e,n)=>{let r=null;const i=t.doc,o=t.scope;Bt(i,a=>{for(;e.length>0&&t.currStackItem===null;){const l=i.store,u=e.pop(),c=new Set,f=[];let h=!1;_s(a,u.insertions,p=>{if(p instanceof jt){if(p.redone!==null){let{item:m,diff:v}=B0(l,p.id);v>0&&(m=kr(a,lt(m.id.client,m.id.clock+v))),p=m}!p.deleted&&o.some(m=>m===a.doc||wc(m,p))&&f.push(p)}}),_s(a,u.deletions,p=>{p instanceof jt&&o.some(m=>m===a.doc||wc(m,p))&&!tu(u.insertions,p.id)&&c.add(p)}),c.forEach(p=>{h=t3(a,p,c,u.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?u:null}a.changed.forEach((l,u)=>{l.has(null)&&u._searchMarker&&(u._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 LS extends BC{constructor(e,{captureTimeout:n=500,captureTransaction:r=l=>!0,deleteFilter:i=()=>!0,trackedOrigins:o=new Set([null]),ignoreRemoteMapChanges:s=!1,doc:a=Rl(e)?e[0].doc:e instanceof Qi?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 u=this.undoing,c=this.redoing,f=u?this.redoStack:this.undoStack;u?this.stopCapturing():c||this.clear(!1,!0);const h=new eu;l.afterState.forEach((g,b)=>{const x=l.beforeState.get(b)||0,_=g-x;_>0&&bc(h,b,x,_)});const p=iI();let m=!1;if(this.lastChange>0&&p-this.lastChange<this.captureTimeout&&f.length>0&&!u&&!c){const g=f[f.length-1];g.deletions=N0([g.deletions,l.deleteSet]),g.insertions=N0([g.insertions,h])}else f.push(new jR(l.deleteSet,h)),m=!0;!u&&!c&&(this.lastChange=p),_s(l,l.deleteSet,g=>{g instanceof jt&&this.scope.some(b=>b===l.doc||wc(b,g))&&Rb(g,!0)});const v=[{stackItem:f[f.length-1],origin:l.origin,type:u?"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=Rl(e)?e:[e],e.forEach(r=>{n.has(r)||(n.add(r),(r instanceof An?r.doc!==this.doc:r!==this.doc)&&bS("[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=>Cw(r,this,i)),this.undoStack=[]),n&&(this.redoStack.forEach(i=>Cw(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=Sw(this,this.undoStack,"undo")}finally{this.undoing=!1}return e}redo(){this.redoing=!0;let e;try{e=Sw(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*qR(t){const e=gt(t.restDecoder);for(let n=0;n<e;n++){const r=gt(t.restDecoder),i=t.readClient();let o=gt(t.restDecoder);for(let s=0;s<r;s++){const a=t.readInfo();if(a===10){const l=gt(t.restDecoder);yield new $r(lt(i,o),l),o+=l}else if((Mp&a)!==0){const l=(a&(Eo|ur))===0,u=new jt(lt(i,o),null,(a&ur)===ur?t.readLeftID():null,null,(a&Eo)===Eo?t.readRightID():null,l?t.readParentInfo()?t.readString():t.readLeftID():null,l&&(a&hc)===hc?t.readString():null,n3(t,a));yield u,o+=u.length}else{const l=t.readLen();yield new Qr(lt(i,o),l),o+=l}}}}class Eb{constructor(e,n){this.gen=qR(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===$r);return this.curr}}class Ab{constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}}const WR=t=>ch(t,SS,ld),KR=(t,e)=>{if(t.constructor===Qr){const{client:n,clock:r}=t.id;return new Qr(lt(n,r+e),t.length-e)}else if(t.constructor===$r){const{client:n,clock:r}=t.id;return new $r(lt(n,r+e),t.length-e)}else{const n=t,{client:r,clock:i}=n.id;return new jt(lt(r,i+e),null,lt(r,i+e-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(e))}},ch=(t,e=zl,n=va)=>{if(t.length===1)return t[0];const r=t.map(c=>new e(Xl(c)));let i=r.map(c=>new Eb(c,!0)),o=null;const s=new n,a=new Ab(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===$r?1:-1:m}else return p.curr.id.client-h.curr.id.client}),i.length!==0;){const c=i[0],f=c.curr.id.client;if(o!==null){let h=c.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=c.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)Zo(a,o.struct,o.offset),o={struct:h,offset:0},c.next();else if(o.struct.id.clock+o.struct.length<h.id.clock)if(o.struct.constructor===$r)o.struct.length=h.id.clock+h.length-o.struct.id.clock;else{Zo(a,o.struct,o.offset);const m=h.id.clock-o.struct.id.clock-o.struct.length;o={struct:new $r(lt(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===$r?o.struct.length-=m:h=KR(h,m)),o.struct.mergeWith(h)||(Zo(a,o.struct,o.offset),o={struct:h,offset:0},c.next())}}else o={struct:c.curr,offset:0},c.next();for(let h=c.curr;h!==null&&h.id.client===f&&h.id.clock===o.struct.id.clock+o.struct.length&&h.constructor!==$r;h=c.next())Zo(a,o.struct,o.offset),o={struct:h,offset:0}}o!==null&&(Zo(a,o.struct,o.offset),o=null),Tb(a);const l=r.map(c=>_b(c)),u=N0(l);return nu(s,u),s.toUint8Array()},GR=(t,e,n=zl,r=va)=>{const i=TS(e),o=new r,s=new Ab(o),a=new n(Xl(t)),l=new Eb(a,!1);for(;l.curr;){const c=l.curr,f=c.id.client,h=i.get(f)||0;if(l.curr.constructor===$r){l.next();continue}if(c.id.clock+c.length>h)for(Zo(s,c,xi(h-c.id.clock,0)),l.next();l.curr&&l.curr.id.client===f;)Zo(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()}Tb(s);const u=_b(a);return nu(o,u),o.toUint8Array()},FS=t=>{t.written>0&&(t.clientStructs.push({written:t.written,restEncoder:yi(t.encoder.restEncoder)}),t.encoder.restEncoder=sd(),t.written=0)},Zo=(t,e,n)=>{t.written>0&&t.currClient!==e.id.client&&FS(t),t.written===0&&(t.currClient=e.id.client,t.encoder.writeClient(e.id.client),_t(t.encoder.restEncoder,e.id.clock+n)),e.write(t.encoder,n),t.written++},Tb=t=>{FS(t);const e=t.encoder.restEncoder;_t(e,t.clientStructs.length);for(let n=0;n<t.clientStructs.length;n++){const r=t.clientStructs[n];_t(e,r.written),Dp(e,r.restEncoder)}},ZR=(t,e,n,r)=>{const i=new n(Xl(t)),o=new Eb(i,!1),s=new r,a=new Ab(s);for(let u=o.curr;u!==null;u=o.next())Zo(a,e(u),0);Tb(a);const l=_b(i);return nu(s,l),s.toUint8Array()},JR=t=>ZR(t,pI,zl,ld),Ew="You must not compute changes after the event-handler fired.";class zp{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=YR(this.currentTarget,this.target))}deletes(e){return tu(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw Xi(Ew);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=zm(l.content.getContent());else return;else l!==null&&this.deletes(l)?(s="update",a=zm(l.content.getContent())):(s="add",a=void 0)}else if(this.deletes(o))s="delete",a=zm(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 Xi(Ew);const n=this.target,r=ga(),i=ga(),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 u=n._start;u!==null;u=u.right)u.deleted?this.deletes(u)&&!this.adds(u)&&((a===null||a.delete===void 0)&&(l(),a={delete:0}),a.delete+=u.length,i.add(u)):this.adds(u)?((a===null||a.insert===void 0)&&(l(),a={insert:[]}),a.insert=a.insert.concat(u.content.getContent()),r.add(u)):((a===null||a.retain===void 0)&&(l(),a={retain:0}),a.retain+=u.length);a!==null&&a.retain===void 0&&l()}this._changes=e}return e}}const YR=(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},Gn=()=>{bS("Invalid access: Add Yjs type to a document before reading data.")},zS=80;let Mb=0;class XR{constructor(e,n){e.marker=!0,this.p=e,this.index=n,this.timestamp=Mb++}}const QR=t=>{t.timestamp=Mb++},BS=(t,e,n)=>{t.p.marker=!1,t.p=e,e.marker=!0,t.index=n,t.timestamp=Mb++},$R=(t,e,n)=>{if(t.length>=zS){const r=t.reduce((i,o)=>i.timestamp<o.timestamp?i:o);return BS(r,e,n),r}else{const r=new XR(e,n);return t.push(r),r}},Bp=(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)=>_f(e-o.index)<_f(e-s.index)?o:s);let r=t._start,i=0;for(n!==null&&(r=n.p,i=n.index,QR(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&&_f(n.index-i)<r.parent.length/zS?(BS(n,r,i),n):$R(t._searchMarker,r,i)},xc=(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=xi(e,i.index+n))}},Hp=(t,e,n)=>{const r=t,i=e.changedParentTypes;for(;ro(i,t,()=>[]).push(n),t._item!==null;)t=t._item.parent;DS(r._eH,n,e)};class An{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=vw(),this._dEH=vw(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,n){this.doc=e,this._item=n}_copy(){throw oi()}clone(){throw oi()}_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){bw(this._eH,e)}observeDeep(e){bw(this._dEH,e)}unobserve(e){yw(this._eH,e)}unobserveDeep(e){yw(this._dEH,e)}toJSON(){}}const HS=(t,e,n)=>{t.doc??Gn(),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},VS=t=>{t.doc??Gn();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},US=(t,e)=>{const n=[];let r=t._start;for(;r!==null;){if(r.countable&&Fs(r,e)){const i=r.content.getContent();for(let o=0;o<i.length;o++)n.push(i[o])}r=r.right}return n},_c=(t,e)=>{let n=0,r=t._start;for(t.doc??Gn();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}},jS=(t,e)=>{const n=[];return _c(t,(r,i)=>{n.push(e(r,i,t))}),n},eN=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}}}},qS=(t,e)=>{t.doc??Gn();const n=Bp(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}},dh=(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 u=[];const c=()=>{u.length>0&&(i=new jt(lt(s,cn(a,s)),i,i&&i.lastId,l,l&&l.id,e,null,new ya(u)),i.integrate(t,0),u=[])};r.forEach(f=>{if(f===null)u.push(f);else switch(f.constructor){case Number:case Object:case Boolean:case Array:case String:u.push(f);break;default:switch(c(),f.constructor){case Uint8Array:case ArrayBuffer:i=new jt(lt(s,cn(a,s)),i,i&&i.lastId,l,l&&l.id,e,null,new cd(new Uint8Array(f))),i.integrate(t,0);break;case Qi:i=new jt(lt(s,cn(a,s)),i,i&&i.lastId,l,l&&l.id,e,null,new dd(f)),i.integrate(t,0);break;default:if(f instanceof An)i=new jt(lt(s,cn(a,s)),i,i&&i.lastId,l,l&&l.id,e,null,new Si(f)),i.integrate(t,0);else throw new Error("Unexpected content type in insert operation")}}}),c()},WS=()=>Xi("Length exceeded!"),KS=(t,e,n,r)=>{if(n>e._length)throw WS();if(n===0)return e._searchMarker&&xc(e._searchMarker,n,r.length),dh(t,e,null,r);const i=n,o=Bp(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&&kr(t,lt(s.id.client,s.id.clock+n));break}n-=s.length}return e._searchMarker&&xc(e._searchMarker,i,r.length),dh(t,e,s,r)},tN=(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 dh(t,e,i,n)},GS=(t,e,n,r)=>{if(r===0)return;const i=n,o=r,s=Bp(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&&kr(t,lt(a.id.client,a.id.clock+n)),n-=a.length);for(;r>0&&a!==null;)a.deleted||(r<a.length&&kr(t,lt(a.id.client,a.id.clock+r)),a.delete(t),r-=a.length),a=a.right;if(r>0)throw WS();e._searchMarker&&xc(e._searchMarker,i,-o+r)},fh=(t,e,n)=>{const r=e._map.get(n);r!==void 0&&r.delete(t)},Db=(t,e,n,r)=>{const i=e._map.get(n)||null,o=t.doc,s=o.clientID;let a;if(r==null)a=new ya([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:a=new ya([r]);break;case Uint8Array:a=new cd(r);break;case Qi:a=new dd(r);break;default:if(r instanceof An)a=new Si(r);else throw new Error("Unexpected content type")}new jt(lt(s,cn(o.store,s)),i,i&&i.lastId,null,null,e,n,a).integrate(t,0)},Ob=(t,e)=>{t.doc??Gn();const n=t._map.get(e);return n!==void 0&&!n.deleted?n.content.getContent()[n.length-1]:void 0},ZS=t=>{const e={};return t.doc??Gn(),t._map.forEach((n,r)=>{n.deleted||(e[r]=n.content.getContent()[n.length-1])}),e},JS=(t,e)=>{t.doc??Gn();const n=t._map.get(e);return n!==void 0&&!n.deleted},nN=(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&&Fs(o,e)&&(n[i]=o.content.getContent()[o.length-1])}),n},Pd=t=>(t.doc??Gn(),bR(t._map.entries(),e=>!e[1].deleted));class rN extends zp{}class ol extends An{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(e){const n=new ol;return n.push(e),n}_integrate(e,n){super._integrate(e,n),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new ol}clone(){const e=new ol;return e.insert(0,this.toArray().map(n=>n instanceof An?n.clone():n)),e}get length(){return this.doc??Gn(),this._length}_callObserver(e,n){super._callObserver(e,n),Hp(this,e,new rN(this,e))}insert(e,n){this.doc!==null?Bt(this.doc,r=>{KS(r,this,e,n)}):this._prelimContent.splice(e,0,...n)}push(e){this.doc!==null?Bt(this.doc,n=>{tN(n,this,e)}):this._prelimContent.push(...e)}unshift(e){this.insert(0,e)}delete(e,n=1){this.doc!==null?Bt(this.doc,r=>{GS(r,this,e,n)}):this._prelimContent.splice(e,n)}get(e){return qS(this,e)}toArray(){return VS(this)}slice(e=0,n=this.length){return HS(this,e,n)}toJSON(){return this.map(e=>e instanceof An?e.toJSON():e)}map(e){return jS(this,e)}forEach(e){_c(this,e)}[Symbol.iterator](){return eN(this)}_write(e){e.writeTypeRef(TN)}}const iN=t=>new ol;class oN extends zp{constructor(e,n,r){super(e,n),this.keysChanged=r}}class Bl extends An{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 Bl}clone(){const e=new Bl;return this.forEach((n,r)=>{e.set(r,n instanceof An?n.clone():n)}),e}_callObserver(e,n){Hp(this,e,new oN(this,e,n))}toJSON(){this.doc??Gn();const e={};return this._map.forEach((n,r)=>{if(!n.deleted){const i=n.content.getContent()[n.length-1];e[r]=i instanceof An?i.toJSON():i}}),e}get size(){return[...Pd(this)].length}keys(){return Wm(Pd(this),e=>e[0])}values(){return Wm(Pd(this),e=>e[1].content.getContent()[e[1].length-1])}entries(){return Wm(Pd(this),e=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){this.doc??Gn(),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?Bt(this.doc,n=>{fh(n,this,e)}):this._prelimContent.delete(e)}set(e,n){return this.doc!==null?Bt(this.doc,r=>{Db(r,this,e,n)}):this._prelimContent.set(e,n),n}get(e){return Ob(this,e)}has(e){return JS(this,e)}clear(){this.doc!==null?Bt(this.doc,e=>{this.forEach(function(n,r,i){fh(e,i,r)})}):this._prelimContent.clear()}_write(e){e.writeTypeRef(MN)}}const sN=t=>new Bl,as=(t,e)=>t===e||typeof t=="object"&&typeof e=="object"&&t&&e&&fI(t,e);class z0{constructor(e,n,r,i){this.left=e,this.right=n,this.index=r,this.currentAttributes=i}forward(){switch(this.right===null&&Jn(),this.right.content.constructor){case pn:this.right.deleted||ru(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 Aw=(t,e,n)=>{for(;e.right!==null&&n>0;){switch(e.right.content.constructor){case pn:e.right.deleted||ru(e.currentAttributes,e.right.content);break;default:e.right.deleted||(n<e.right.length&&kr(t,lt(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},Ld=(t,e,n,r)=>{const i=new Map,o=r?Bp(e,n):null;if(o){const s=new z0(o.p.left,o.p,o.index,i);return Aw(t,s,n-o.index)}else{const s=new z0(null,e._start,0,i);return Aw(t,s,n)}},YS=(t,e,n,r)=>{for(;n.right!==null&&(n.right.deleted===!0||n.right.content.constructor===pn&&as(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,u=n.right,c=new jt(lt(o,cn(i.store,o)),l,l&&l.lastId,u,u&&u.id,e,null,new pn(a,s));c.integrate(t,0),n.right=c,n.forward()})},ru=(t,e)=>{const{key:n,value:r}=e;r===null?t.delete(n):t.set(n,r)},XS=(t,e)=>{for(;t.right!==null;){if(!(t.right.deleted||t.right.content.constructor===pn&&as(e[t.right.content.key]??null,t.right.content.value)))break;t.forward()}},QS=(t,e,n,r)=>{const i=t.doc,o=i.clientID,s=new Map;for(const a in r){const l=r[a],u=n.currentAttributes.get(a)??null;if(!as(u,l)){s.set(a,u);const{left:c,right:f}=n;n.right=new jt(lt(o,cn(i.store,o)),c,c&&c.lastId,f,f&&f.id,e,null,new pn(a,l)),n.right.integrate(t,0),n.forward()}}return s},Zm=(t,e,n,r,i)=>{n.currentAttributes.forEach((h,p)=>{i[p]===void 0&&(i[p]=null)});const o=t.doc,s=o.clientID;XS(n,i);const a=QS(t,e,n,i),l=r.constructor===String?new Ci(r):r instanceof An?new Si(r):new Oa(r);let{left:u,right:c,index:f}=n;e._searchMarker&&xc(e._searchMarker,n.index,l.getLength()),c=new jt(lt(s,cn(o.store,s)),u,u&&u.lastId,c,c&&c.id,e,null,l),c.integrate(t,0),n.right=c,n.index=f,n.forward(),YS(t,e,n,a)},Tw=(t,e,n,r,i)=>{const o=t.doc,s=o.clientID;XS(n,i);const a=QS(t,e,n,i);e:for(;n.right!==null&&(r>0||a.size>0&&(n.right.deleted||n.right.content.constructor===pn));){if(!n.right.deleted)switch(n.right.content.constructor){case pn:{const{key:l,value:u}=n.right.content,c=i[l];if(c!==void 0){if(as(c,u))a.delete(l);else{if(r===0)break e;a.set(l,u)}n.right.delete(t)}else n.currentAttributes.set(l,u);break}default:r<n.right.length&&kr(t,lt(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 jt(lt(s,cn(o.store,s)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,e,null,new Ci(l)),n.right.integrate(t,0),n.forward()}YS(t,e,n,a)},$S=(t,e,n,r,i)=>{let o=e;const s=ii();for(;o&&(!o.countable||o.deleted);){if(!o.deleted&&o.content.constructor===pn){const u=o.content;s.set(u.key,u)}o=o.right}let a=0,l=!1;for(;e!==o;){if(n===e&&(l=!0),!e.deleted){const u=e.content;switch(u.constructor){case pn:{const{key:c,value:f}=u,h=r.get(c)??null;(s.get(c)!==u||h===f)&&(e.delete(t),a++,!l&&(i.get(c)??null)===f&&h!==f&&(h===null?i.delete(c):i.set(c,h))),!l&&!e.deleted&&ru(i,u);break}}}e=e.right}return a},aN=(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===pn){const r=e.content.key;n.has(r)?e.delete(t):n.add(r)}e=e.left}},lN=t=>{let e=0;return Bt(t.doc,n=>{let r=t._start,i=t._start,o=ii();const s=T0(o);for(;i;){if(i.deleted===!1)switch(i.content.constructor){case pn:ru(s,i.content);break;default:e+=$S(n,r,i,o,s),o=T0(s),r=i;break}i=i.right}}),e},uN=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&&NS(t,n.store.clients.get(r),o,i,s=>{!s.deleted&&s.content.constructor===pn&&s.constructor!==Qr&&e.add(s.parent)})}Bt(n,r=>{_s(t,t.deleteSet,i=>{if(i instanceof Qr||!i.parent._hasFormatting||e.has(i.parent))return;const o=i.parent;i.content.constructor===pn?e.add(o):aN(r,i)});for(const i of e)lN(i)})},Mw=(t,e,n)=>{const r=n,i=T0(e.currentAttributes),o=e.right;for(;n>0&&e.right!==null;){if(e.right.deleted===!1)switch(e.right.content.constructor){case Si:case Oa:case Ci:n<e.right.length&&kr(t,lt(e.right.id.client,e.right.id.clock+n)),n-=e.right.length,e.right.delete(t);break}e.forward()}o&&$S(t,o,e.right,i,e.currentAttributes);const s=(e.left||e.right).parent;return s._searchMarker&&xc(s._searchMarker,e.index,-r+n),e};class cN extends zp{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=[];Bt(e,r=>{const i=new Map,o=new Map;let s=this.target._start,a=null;const l={};let u="",c=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 u=="object"||u.length>0)&&(p={insert:u},i.size>0&&(p.attributes={},i.forEach((m,v)=>{m!==null&&(p.attributes[v]=m)}))),u="";break;case"retain":c>0&&(p={retain:c},dI(l)||(p.attributes=uI({},l))),c=0;break}p&&n.push(p),a=null}};for(;s!==null;){switch(s.content.constructor){case Si:case Oa:this.adds(s)?this.deletes(s)||(h(),a="insert",u=s.content.getContent()[0],h()):this.deletes(s)?(a!=="delete"&&(h(),a="delete"),f+=1):s.deleted||(a!=="retain"&&(h(),a="retain"),c+=1);break;case Ci:this.adds(s)?this.deletes(s)||(a!=="insert"&&(h(),a="insert"),u+=s.content.str):this.deletes(s)?(a!=="delete"&&(h(),a="delete"),f+=s.length):s.deleted||(a!=="retain"&&(h(),a="retain"),c+=s.length);break;case pn:{const{key:p,value:m}=s.content;if(this.adds(s)){if(!this.deletes(s)){const v=i.get(p)??null;as(v,m)?m!==null&&s.delete(r):(a==="retain"&&h(),as(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;as(v,m)||(a==="retain"&&h(),l[p]=v)}else if(!s.deleted){o.set(p,m);const v=l[p];v!==void 0&&(as(v,m)?v!==null&&s.delete(r):(a==="retain"&&h(),m===null?delete l[p]:l[p]=m))}s.deleted||(a==="insert"&&h(),ru(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 Cs extends An{constructor(e){super(),this._pending=e!==void 0?[()=>this.insert(0,e)]:[],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??Gn(),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 Cs}clone(){const e=new Cs;return e.applyDelta(this.toDelta()),e}_callObserver(e,n){super._callObserver(e,n);const r=new cN(this,e,n);Hp(this,e,r),!e.local&&this._hasFormatting&&(e._needFormattingCleanup=!0)}toString(){this.doc??Gn();let e="",n=this._start;for(;n!==null;)!n.deleted&&n.countable&&n.content.constructor===Ci&&(e+=n.content.str),n=n.right;return e}toJSON(){return this.toString()}applyDelta(e,{sanitize:n=!0}={}){this.doc!==null?Bt(this.doc,r=>{const i=new z0(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)&&Zm(r,this,i,a,s.attributes||{})}else s.retain!==void 0?Tw(r,this,i,s.retain,s.attributes||{}):s.delete!==void 0&&Mw(r,i,s.delete)}}):this._pending.push(()=>this.applyDelta(e))}toDelta(e,n,r){this.doc??Gn();const i=[],o=new Map,s=this.doc;let a="",l=this._start;function u(){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 c=()=>{for(;l!==null;){if(Fs(l,e)||n!==void 0&&Fs(l,n))switch(l.content.constructor){case Ci:{const f=o.get("ychange");e!==void 0&&!Fs(l,e)?(f===void 0||f.user!==l.id.client||f.type!=="removed")&&(u(),o.set("ychange",r?r("removed",l.id):{type:"removed"})):n!==void 0&&!Fs(l,n)?(f===void 0||f.user!==l.id.client||f.type!=="added")&&(u(),o.set("ychange",r?r("added",l.id):{type:"added"})):f!==void 0&&(u(),o.delete("ychange")),a+=l.content.str;break}case Si:case Oa:{u();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 pn:Fs(l,e)&&(u(),ru(o,l.content));break}l=l.right}u()};return e||n?Bt(s,f=>{e&&L0(f,e),n&&L0(f,n),c()},"cleanup"):c(),i}insert(e,n,r){if(n.length<=0)return;const i=this.doc;i!==null?Bt(i,o=>{const s=Ld(o,this,e,!r);r||(r={},s.currentAttributes.forEach((a,l)=>{r[l]=a})),Zm(o,this,s,n,r)}):this._pending.push(()=>this.insert(e,n,r))}insertEmbed(e,n,r){const i=this.doc;i!==null?Bt(i,o=>{const s=Ld(o,this,e,!r);Zm(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?Bt(r,i=>{Mw(i,Ld(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?Bt(i,o=>{const s=Ld(o,this,e,!1);s.right!==null&&Tw(o,this,s,n,r)}):this._pending.push(()=>this.format(e,n,r))}removeAttribute(e){this.doc!==null?Bt(this.doc,n=>{fh(n,this,e)}):this._pending.push(()=>this.removeAttribute(e))}setAttribute(e,n){this.doc!==null?Bt(this.doc,r=>{Db(r,this,e,n)}):this._pending.push(()=>this.setAttribute(e,n))}getAttribute(e){return Ob(this,e)}getAttributes(){return ZS(this)}_write(e){e.writeTypeRef(DN)}}const dN=t=>new Cs;class Jm{constructor(e,n=()=>!0){this._filter=n,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??Gn()}[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===Qt||n.constructor===ba)&&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 ba extends An{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 ba}clone(){const e=new ba;return e.insert(0,this.toArray().map(n=>n instanceof An?n.clone():n)),e}get length(){return this.doc??Gn(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new Jm(this,e)}querySelector(e){e=e.toUpperCase();const r=new Jm(this,i=>i.nodeName&&i.nodeName.toUpperCase()===e).next();return r.done?null:r.value}querySelectorAll(e){return e=e.toUpperCase(),xs(new Jm(this,n=>n.nodeName&&n.nodeName.toUpperCase()===e))}_callObserver(e,n){Hp(this,e,new pN(this,n,e))}toString(){return jS(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),_c(this,o=>{i.insertBefore(o.toDOM(e,n,r),null)}),i}insert(e,n){this.doc!==null?Bt(this.doc,r=>{KS(r,this,e,n)}):this._prelimContent.splice(e,0,...n)}insertAfter(e,n){if(this.doc!==null)Bt(this.doc,r=>{const i=e&&e instanceof An?e._item:e;dh(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 Xi("Reference item not found");r.splice(i,0,...n)}}delete(e,n=1){this.doc!==null?Bt(this.doc,r=>{GS(r,this,e,n)}):this._prelimContent.splice(e,n)}toArray(){return VS(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return qS(this,e)}slice(e=0,n=this.length){return HS(this,e,n)}forEach(e){_c(this,e)}_write(e){e.writeTypeRef(IN)}}const fN=t=>new ba;class Qt extends ba{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 Qt(this.nodeName)}clone(){const e=new Qt(this.nodeName),n=this.getAttributes();return cI(n,(r,i)=>{e.setAttribute(i,r)}),e.insert(0,this.toArray().map(r=>r instanceof An?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?Bt(this.doc,n=>{fh(n,this,e)}):this._prelimAttrs.delete(e)}setAttribute(e,n){this.doc!==null?Bt(this.doc,r=>{Db(r,this,e,n)}):this._prelimAttrs.set(e,n)}getAttribute(e){return Ob(this,e)}hasAttribute(e){return JS(this,e)}getAttributes(e){return e?nN(this,e):ZS(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 _c(this,s=>{i.appendChild(s.toDOM(e,n,r))}),r!==void 0&&r._createAssociation(i,this),i}_write(e){e.writeTypeRef(ON),e.writeKey(this.nodeName)}}const hN=t=>new Qt(t.readKey());class pN extends zp{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 hh extends Bl{constructor(e){super(),this.hookName=e}_copy(){return new hh(this.hookName)}clone(){const e=new hh(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(RN),e.writeKey(this.hookName)}}const mN=t=>new hh(t.readKey());class hn extends Cs{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 hn}clone(){const e=new hn;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(NN)}}const gN=t=>new hn;class Ib{constructor(e,n){this.id=e,this.length=n}get deleted(){throw oi()}mergeWith(e){return!1}write(e,n,r){throw oi()}integrate(e,n){throw oi()}}const vN=0;class Qr extends Ib{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),RS(e.doc.store,this)}write(e,n){e.writeInfo(vN),e.writeLen(this.length-n)}getMissing(e,n){return null}}class cd{constructor(e){this.content=e}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new cd(this.content)}splice(e){throw oi()}mergeWith(e){return!1}integrate(e,n){}delete(e){}gc(e){}write(e,n){e.writeBuf(this.content)}getRef(){return 3}}const bN=t=>new cd(t.readBuf());class Cc{constructor(e){this.len=e}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new Cc(this.len)}splice(e){const n=new Cc(this.len-e);return this.len=e,n}mergeWith(e){return this.len+=e.len,!0}integrate(e,n){bc(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 yN=t=>new Cc(t.readLen()),e3=(t,e)=>new Qi({guid:t,...e,shouldLoad:e.shouldLoad||e.autoLoad||!1});class dd{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 dd(e3(this.doc.guid,this.opts))}splice(e){throw oi()}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 wN=t=>new dd(e3(t.readString(),t.readAny()));class Oa{constructor(e){this.embed=e}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new Oa(this.embed)}splice(e){throw oi()}mergeWith(e){return!1}integrate(e,n){}delete(e){}gc(e){}write(e,n){e.writeJSON(this.embed)}getRef(){return 5}}const kN=t=>new Oa(t.readJSON());class pn{constructor(e,n){this.key=e,this.value=n}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new pn(this.key,this.value)}splice(e){throw oi()}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 xN=t=>new pn(t.readKey(),t.readJSON());class ph{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new ph(this.arr)}splice(e){const n=new ph(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 _N=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 ph(n)},CN=oh("node_env")==="development";class ya{constructor(e){this.arr=e,CN&&ZC(e)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new ya(this.arr)}splice(e){const n=new ya(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 SN=t=>{const e=t.readLen(),n=[];for(let r=0;r<e;r++)n.push(t.readAny());return new ya(n)};class Ci{constructor(e){this.str=e}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new Ci(this.str)}splice(e){const n=new Ci(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 EN=t=>new Ci(t.readString()),AN=[iN,sN,dN,hN,fN,mN,gN],TN=0,MN=1,DN=2,ON=3,IN=4,RN=5,NN=6;class Si{constructor(e){this.type=e}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new Si(this.type._copy())}splice(e){throw oi()}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 PN=t=>new Si(AN[t.readTypeRef()](t)),B0=(t,e)=>{let n=e,r=0,i;do r>0&&(n=lt(n.client,n.clock+r)),i=il(t,n),r=n.clock-i.id.clock,n=i.redone;while(n!==null&&i instanceof jt);return{item:i,diff:r}},Rb=(t,e)=>{for(;t!==null&&t.keep!==e;)t.keep=e,t=t.parent._item},mh=(t,e,n)=>{const{client:r,clock:i}=e.id,o=new jt(lt(r,i+n),e,lt(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=lt(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},Dw=(t,e)=>ub(t,n=>tu(n.deletions,e)),t3=(t,e,n,r,i,o)=>{const s=t.doc,a=s.store,l=s.clientID,u=e.redone;if(u!==null)return kr(t,u);let c=e.parent._item,f=null,h;if(c!==null&&c.deleted===!0){if(c.redone===null&&(!n.has(c)||t3(t,c,n,r,i,o)===null))return null;for(;c.redone!==null;)c=kr(t,c.redone)}const p=c===null?e.parent:c.content.type;if(e.parentSub===null){for(f=e.left,h=e;f!==null;){let b=f;for(;b!==null&&b.parent._item!==c;)b=b.redone===null?null:kr(t,b.redone);if(b!==null&&b.parent._item===c){f=b;break}f=f.left}for(;h!==null;){let b=h;for(;b!==null&&b.parent._item!==c;)b=b.redone===null?null:kr(t,b.redone);if(b!==null&&b.parent._item===c){h=b;break}h=h.right}}else if(h=null,e.right&&!i){for(f=e;f!==null&&f.right!==null&&(f.right.redone||tu(r,f.right.id)||Dw(o.undoStack,f.right.id)||Dw(o.redoStack,f.right.id));)for(f=f.right;f.redone;)f=kr(t,f.redone);if(f&&f.right!==null)return null}else f=p._map.get(e.parentSub)||null;const m=cn(a,l),v=lt(l,m),g=new jt(v,f,f&&f.lastId,h,h&&h.id,p,e.parentSub,e.content.copy());return e.redone=v,Rb(g,!0),g.integrate(t,0),g};let jt=class H0 extends Ib{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()?iw:0}set marker(e){(this.info&Hm)>0!==e&&(this.info^=Hm)}get marker(){return(this.info&Hm)>0}get keep(){return(this.info&rw)>0}set keep(e){this.keep!==e&&(this.info^=rw)}get countable(){return(this.info&iw)>0}get deleted(){return(this.info&Bm)>0}set deleted(e){this.deleted!==e&&(this.info^=Bm)}markDeleted(){this.info|=Bm}getMissing(e,n){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=cn(n,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=cn(n,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===rl&&this.id.client!==this.parent.client&&this.parent.clock>=cn(n,this.parent.client))return this.parent.client;if(this.origin&&(this.left=kw(e,n,this.origin),this.origin=this.left.lastId),this.rightOrigin&&(this.right=kr(e,this.rightOrigin),this.rightOrigin=this.right.id),this.left&&this.left.constructor===Qr||this.right&&this.right.constructor===Qr)this.parent=null;else if(!this.parent)this.left&&this.left.constructor===H0?(this.parent=this.left.parent,this.parentSub=this.left.parentSub):this.right&&this.right.constructor===H0&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===rl){const r=il(n,this.parent);r.constructor===Qr?this.parent=null:this.parent=r.content.type}return null}integrate(e,n){if(n>0&&(this.id.clock+=n,this.left=kw(e,e.doc.store,lt(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),Ja(this.origin,i.origin)){if(i.id.client<this.id.client)r=i,o.clear();else if(Ja(this.rightOrigin,i.rightOrigin))break}else if(i.origin!==null&&s.has(il(e.doc.store,i.origin)))o.has(il(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),RS(e.doc.store,this),this.content.integrate(e,this),_w(e,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(e)}else new Qr(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:lt(this.id.client,this.id.clock+this.length-1)}mergeWith(e){if(this.constructor===e.constructor&&Ja(e.origin,this.lastId)&&this.right===e&&Ja(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(),bc(e.deleteSet,this.id.client,this.id.clock,this.length),_w(e,n,this.parentSub),this.content.delete(e)}}gc(e,n){if(!this.deleted)throw Jn();this.content.gc(e),n?BR(e,this,new Qr(this.id,this.length)):this.content=new Cc(this.length)}write(e,n){const r=n>0?lt(this.id.client,this.id.clock+n-1):this.origin,i=this.rightOrigin,o=this.parentSub,s=this.content.getRef()&Mp|(r===null?0:ur)|(i===null?0:Eo)|(o===null?0:hc);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 u=yc(a);e.writeParentInfo(!0),e.writeString(u)}else e.writeParentInfo(!1),e.writeLeftID(l.id)}else a.constructor===String?(e.writeParentInfo(!0),e.writeString(a)):a.constructor===rl?(e.writeParentInfo(!1),e.writeLeftID(a)):Jn();o!==null&&e.writeString(o)}this.content.write(e,n)}};const n3=(t,e)=>LN[e&Mp](t),LN=[()=>{Jn()},yN,_N,bN,EN,kN,xN,PN,SN,wN,()=>{Jn()}],FN=10;class $r extends Ib{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,n){Jn()}write(e,n){e.writeInfo(FN),_t(e.restEncoder,this.length-n)}getMissing(e,n){return null}}const r3=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},i3="__ $YJS$ __";r3[i3]===!0&&console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438");r3[i3]=!0;function o3(t){return t?t+1:0}function Vp(t){let e=0;return t.forEach(n=>{n.isText?e+=n.text.length:n.type.name==="hardBreak"&&(e+=1)}),e}function fd(t){if(t.isTextblock)return Vp(t);let e=0;for(let n=0;n<t.childCount;n++)n>0&&(e+=1),e+=fd(t.child(n));return e}function s3(t,e,n){if(t.isTextblock)return Hn(n+Math.min(e,Vp(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=fd(s);if(r+l>e)return s3(s,e-r,a);r+=l,i+=s.nodeSize}return Hn(n+t.content.size)}function Ss(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"?o3(s.attrs.level||1):0,u=fd(s),c=l+u;if(n+c>e){const f=e-n,h=Math.max(0,f-l);return s3(s,h,a)}if(n+=c,r+=s.nodeSize,o<i-1&&(n+=1,n>e))return Hn(a+s.content.size)}return Hn(t.content.size)}function a3(t,e,n){if(t.isTextblock)return Math.min(e-n,Vp(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+a3(s,e,a);r+=fd(s),i+=s.nodeSize}return r}function Vi(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"?o3(s.attrs.level||1):0,u=fd(s),c=r+s.nodeSize;if(e<c)return e<=a?vf(n+l):vf(n+l+a3(s,e,a));n+=l+u,r+=s.nodeSize,o<i-1&&(n+=1)}return vf(n)}function l3(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 hn){if(l===r.type)return Hn(n+Math.min(s+r.index,Vp(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),u=i+1;if(a instanceof Qt){const c=l3(a,l,u,r);if(c!==null)return c}i+=l.nodeSize}return null}function Ow(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 Qt){const u=l3(s,a,l,n);if(u!==null)return u}r+=a.nodeSize}return null}function u3(t,e,n){let r,i;try{const l=sa(n.fromRel),u=sa(n.toRel);r=P0(l,t),i=P0(u,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=Ow(e,o,r),a=Ow(e,o,i);return s===null||a===null?null:{from:s,to:a}}function Sc(t,e,n){if(t.relRange&&n){const r=u3(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:Ss(e,t.range.from),to:Ss(e,t.range.to),method:"flat"}:null}function c3(t,e){return{from:Vi(t,e.from),to:Vi(t,e.to)}}function zN(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function BN(t){const e=zN(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 HN=M('<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>'),VN=M('<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>'),UN=M('<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>'),jN=M('<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>'),qN=M('<button type="button" class="chat-anchor-quote" title="Click to scroll to this text"> </button>'),WN=M('<div class="chat-markdown svelte-15oag3v"></div>'),KN=M('<div style="white-space: pre-wrap; word-break: break-word;"> </div>'),GN=M('<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>'),ZN=M("<span></span>"),JN=M('<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>'),YN=M('<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>'),XN=M('<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 Iw(t,e){ze(e,!0);const n=[0,.2,.4];let r=je(e,"inputEl",15,null);const i=F(()=>e.reduceMotion?"auto":"smooth");let o=B(Ge([])),s=B(""),a=B(void 0),l=B(void 0);me(()=>{r(d(l)??null)}),me(()=>{if(!e.ctrlYdoc)return;const I=e.ctrlYdoc.getMap(_y),O=()=>{const A=[];I.forEach(V=>{A.push(V)}),A.sort((V,L)=>V.timestamp-L.timestamp||V.id.localeCompare(L.id)),y(o,A,!0)};return I.observe(O),O(),()=>I.unobserve(O)});let u=!1;me(()=>{var A;d(o);const I=!!e.claudeActive,O=St(()=>d(i));if(!I&&u){u=!1;return}u=I,(A=d(a))==null||A.scrollIntoView({behavior:O})}),me(()=>{var A;const I=e.visible,O=St(()=>d(i));I&&((A=d(a))==null||A.scrollIntoView({behavior:O}))});const c=F(()=>d(o).filter(I=>I.author==="claude"&&!I.read).length);function f(){if(!e.ctrlYdoc||!d(s).trim())return;const I=e.ctrlYdoc.getMap(_y),O={id:Z6(),author:"user",text:d(s).trim(),timestamp:Date.now(),...e.activeDocId?{documentId:e.activeDocId}:{},...e.capturedAnchor?{anchor:e.capturedAnchor}:{},read:!1};I.set(O.id,O),y(s,""),e.onCapturedAnchorChange(null)}function h(I){I.key==="Enter"&&!I.shiftKey&&(I.preventDefault(),f())}function p(I,O){if(!(!e.editor||O&&O!==e.activeDocId))try{const A=Ss(e.editor.state.doc,I.from),V=Ss(e.editor.state.doc,I.to);e.editor.chain().focus().setTextSelection({from:A,to:V}).scrollIntoView().run()}catch(A){console.warn("[ChatPanel] Could not scroll to anchor:",A instanceof Error?A.message:A)}}function m(I){if(!I)return null;const O=e.openDocs.find(A=>A.id===I);return(O==null?void 0:O.fileName)??null}async function v(){try{await fetch(`http://127.0.0.1:${Jl}${iM}`,{method:"DELETE"})}catch(I){console.warn("[ChatPanel] Failed to clear chat:",I)}}let g=B(Ge(new Set));function b(I){const O=new Set(d(g));O.has(I)?O.delete(I):O.add(I),y(g,O,!0)}var x=XN(),_=w(x),T=k(w(_)),S=w(T);{var z=I=>{var O=HN(),A=w(O);q(()=>ee(A,d(c))),C(I,O)};G(S,I=>{d(c)>0&&I(z)})}var E=k(S,2);{var D=I=>{var O=VN();N("click",O,v),C(I,O)};G(E,I=>{d(o).length>0&&I(D)})}var P=k(_,2),R=w(P);{var H=I=>{var O=UN();C(I,O)};G(R,I=>{d(o).length===0&&I(H)})}var Q=k(R,2);Je(Q,17,()=>d(o),I=>I.id,(I,O)=>{var A=GN(),V=w(A),L=w(V),J=w(L),K=k(L,2);{var ne=X=>{var le=jN(),he=w(le);q(De=>ee(he,De),[()=>m(d(O).documentId)??d(O).documentId]),C(X,le)};G(K,X=>{d(O).documentId&&X(ne)})}var ye=k(K,2),ce=w(ye),ve=k(V,2);{var _e=X=>{var le=qN(),he=w(le);q(De=>{xe(le,`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: ${De??""}; overflow: hidden; transition: max-height 0.3s ease;`),ee(he,d(O).anchor.textSnapshot)},[()=>d(g).has(d(O).id)?"500px":"60px"]),N("click",le,()=>p(d(O).anchor,d(O).documentId)),rn("mouseenter",le,()=>b(d(O).id)),rn("mouseleave",le,()=>b(d(O).id)),C(X,le)};G(ve,X=>{d(O).anchor&&X(_e)})}var Y=k(ve,2);{var we=X=>{var le=WN();t6(le,()=>BN(d(O).text),!0),C(X,le)},se=X=>{var le=KN(),he=w(le);q(()=>ee(he,d(O).text)),C(X,le)};G(Y,X=>{d(O).author==="claude"?X(we):X(se,-1)})}q(X=>{xe(A,`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);`),xe(L,`font-weight: 600; font-size: 11px; color: ${d(O).author==="claude"?"var(--tandem-accent)":"var(--tandem-fg-muted)"}; text-transform: uppercase;`),ee(J,d(O).author),ee(ce,X)},[()=>new Date(d(O).timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})]),C(I,A)});var Z=k(Q,2);{var $=I=>{var O=JN(),A=w(O);Je(A,20,()=>n,J=>J,(J,K)=>{var ne=ZN();q(()=>xe(ne,`width: 5px; height: 5px; border-radius: 50%; background: var(--tandem-author-claude); animation: tandem-typing-bounce 1.2s ease-in-out ${K??""}s infinite;`)),C(J,ne)});var V=k(A,2),L=w(V);q(()=>ee(L,e.claudeStatus??"Your AI is thinking...")),C(I,O)};G(Z,I=>{e.claudeActive&&I($)})}var W=k(Z,2);xt(W,I=>y(a,I),()=>d(a)),cr(P,(I,O)=>Ht==null?void 0:Ht(I,O),()=>"y");var te=k(P,2);{var ae=I=>{var O=YN(),A=w(O),V=w(A),L=k(A,2);q(J=>ee(V,`with selection: “${J??""}${e.capturedAnchor.textSnapshot.length>40?"...":""}”`),[()=>e.capturedAnchor.textSnapshot.slice(0,40)]),N("click",L,()=>e.onCapturedAnchorChange(null)),C(I,O)};G(te,I=>{e.capturedAnchor&&I(ae)})}var re=k(te,2),ue=w(re),oe=w(ue);U(oe,"rows",2),xt(oe,I=>y(l,I),()=>d(l));var fe=k(oe,2);q((I,O)=>{xr(oe,d(s)),fe.disabled=I,At(fe,1,O,"svelte-15oag3v")},[()=>!d(s).trim(),()=>"chat-composer-send"+(d(s).trim()?" on":"")]),N("input",oe,I=>y(s,I.target.value,!0)),N("keydown",oe,h),N("click",fe,f),C(t,x),Be()}We(["click","input","keydown"]);var QN=M('<button type="button" data-testid="apply-changes-btn"> </button>');function $N(t,e){ze(e,!0);let n=B(!1);const r=F(()=>e.annotations.filter(c=>c.status==="accepted")),i=F(()=>e.annotations.filter(c=>c.status==="pending")),o=F(()=>d(r).length===0||d(n));async function s(){if(d(o)||!e.documentId)return;let c=`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&&(c+=`
|
|
64
|
+
|
|
65
|
+
⚠ ${d(i).length} annotation(s) are still pending review and will not be applied.`),!!confirm(c)){y(n,!0);try{const f=await fetch(`${qn}${tM}`,{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=kt(),l=Se(a);{var u=c=>{var f=QN();let h;var p=w(f);q(()=>{h=At(f,1,"acb-btn svelte-hdlegv",null,h,{"is-disabled":d(o),"is-applying":d(n)}),f.disabled=d(o),U(f,"title",d(r).length===0?"No accepted suggestions to apply":void 0),ee(p,d(n)?"Applying…":`Apply as Tracked Changes (${d(r).length})`)}),N("click",f,s),C(c,f)};G(l,c=>{e.activeDocFormat==="docx"&&c(u)})}C(t,a),Be()}We(["click"]);const Fd={background:"var(--tandem-warning-bg)",border:"var(--tandem-warning-border)",color:"var(--tandem-warning-fg-strong)"};function Up(t,e){return t.type!=="comment"?[]:e??[]}var e9=M('<button class="aca-btn aca-btn--accept svelte-1u9ox5p">Accept</button>'),t9=M('<button class="aca-btn aca-btn--reject svelte-1u9ox5p">Reject</button>'),n9=M('<div class="aca-row svelte-1u9ox5p"><!> <!></div>'),r9=M('<button class="aca-btn aca-btn--ghost svelte-1u9ox5p">Archive</button>'),i9=M('<button class="aca-btn aca-btn--send svelte-1u9ox5p">Send to Claude</button>'),o9=M('<div class="aca-row svelte-1u9ox5p"><!> <!></div>'),s9=M('<button class="aca-btn aca-btn--ghost aca-standalone svelte-1u9ox5p">Remove</button>'),a9=M(`<div class="aca-undo-error svelte-1u9ox5p">Can't undo — text has changed.</div>`),l9=M('<div class="aca-undo-row svelte-1u9ox5p"><button data-testid="undo-btn" class="aca-undo svelte-1u9ox5p">Undo</button> <!></div>');function u9(t,e){ze(e,!0);let n=B(!1),r=null;function i(){r&&(clearTimeout(r),r=null)}function o(h){if(h.stopPropagation(),!e.onUndo)return;const p=e.onUndo(e.annotationId);if(p){i(),y(n,!1);return}p||(y(n,!0),i(),r=setTimeout(()=>{y(n,!1),r=null},3e3))}lr(i);var s=kt(),a=Se(s);{var l=h=>{var p=n9(),m=w(p);{var v=x=>{var _=e9();q(()=>U(_,"data-testid",`accept-btn-${e.annotationId??""}`)),N("click",_,T=>{T.stopPropagation(),e.onAccept(e.annotationId)}),C(x,_)};G(m,x=>{e.onAccept&&x(v)})}var g=k(m,2);{var b=x=>{var _=t9();q(()=>U(_,"data-testid",`dismiss-btn-${e.annotationId??""}`)),N("click",_,T=>{T.stopPropagation(),e.onDismiss(e.annotationId)}),C(x,_)};G(g,x=>{e.onDismiss&&x(b)})}C(h,p)},u=h=>{var p=o9(),m=w(p);{var v=x=>{var _=r9();q(()=>U(_,"data-testid",`archive-btn-${e.annotationId??""}`)),N("click",_,T=>{T.stopPropagation(),e.onRemove(e.annotationId)}),C(x,_)};G(m,x=>{e.onRemove&&x(v)})}var g=k(m,2);{var b=x=>{var _=i9();q(()=>U(_,"data-testid",`send-to-claude-btn-${e.annotationId??""}`)),N("click",_,T=>{T.stopPropagation(),e.onSendToClaude(e.annotationId)}),C(x,_)};G(g,x=>{e.onSendToClaude&&x(b)})}C(h,p)},c=h=>{var p=s9();q(()=>U(p,"data-testid",`remove-btn-${e.annotationId??""}`)),N("click",p,m=>{m.stopPropagation(),e.onRemove(e.annotationId)}),C(h,p)},f=h=>{var p=l9(),m=w(p),v=k(m,2);{var g=b=>{var x=a9();C(b,x)};G(v,b=>{d(n)&&b(g)})}N("click",m,o),C(h,p)};G(a,h=>{e.isPending&&!e.isEditing&&(e.onAccept||e.onDismiss)?h(l):e.isPending&&!e.isEditing&&e.annotationType==="note"?h(u,1):e.isPending&&!e.isEditing&&e.onRemove?h(c,2):!e.isPending&&e.undoable&&e.onUndo&&h(f,3)})}C(t,s),Be()}We(["click"]);const zu="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);",Rw="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 c9=M('<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),d9=M("<textarea></textarea>"),f9=M('<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 h9(t,e){ze(e,!0);let n=B(null);me(()=>{var c;(c=d(n))==null||c.focus()});var r=f9(),i=w(r);{var o=c=>{var f=c9(),h=Se(f),p=k(h,2);xt(p,g=>y(n,g),()=>d(n));var m=k(p,2),v=k(m,2);q(()=>{U(h,"for",`edit-newtext-${e.annotationId??""}`),U(p,"id",`edit-newtext-${e.annotationId??""}`),U(p,"data-testid",`edit-newtext-${e.annotationId??""}`),xr(p,e.editNewText),xe(p,zu),U(m,"for",`edit-reason-${e.annotationId??""}`),U(v,"id",`edit-reason-${e.annotationId??""}`),U(v,"data-testid",`edit-reason-${e.annotationId??""}`),xr(v,e.editReason),xe(v,zu)}),N("input",p,g=>e.onChangeEditNewText(g.target.value)),N("keydown",p,function(...g){var b;(b=e.onKeyDown)==null||b.apply(this,g)}),N("input",v,g=>e.onChangeEditReason(g.target.value)),N("keydown",v,function(...g){var b;(b=e.onKeyDown)==null||b.apply(this,g)}),C(c,f)},s=c=>{var f=d9();xt(f,h=>y(n,h),()=>d(n)),q(()=>{U(f,"data-testid",`edit-text-${e.annotationId??""}`),xr(f,e.editText),xe(f,zu)}),N("input",f,h=>e.onChangeEditText(h.target.value)),N("keydown",f,function(...h){var p;(p=e.onKeyDown)==null||p.apply(this,h)}),C(c,f)};G(i,c=>{e.hasSuggestedText?c(o):c(s,-1)})}var a=k(i,2),l=w(a),u=k(l,2);q(()=>{U(l,"data-testid",`edit-save-btn-${e.annotationId??""}`),U(u,"data-testid",`edit-cancel-btn-${e.annotationId??""}`)}),N("click",r,c=>c.stopPropagation()),N("keydown",r,c=>c.stopPropagation()),N("click",l,c=>{c.stopPropagation(),e.onSave()}),N("click",u,c=>{c.stopPropagation(),e.onCancel()}),C(t,r),Be()}We(["click","keydown","input"]);function p9(t){return t==="claude"?"Claude":t==="import"?"Imported":"You"}function d3(t){return t.suggestedText!==void 0?"replacement":t.type}function m9(t,e){return t?t.length>e?t.slice(0,e-3)+"...":t:""}function g9(t){const e=d3(t),n=m9(t.content,60);return`${t.type==="note"?"private ":""}${e} annotation${n?": "+n:""}, ${t.status}`}function v9(t){return t.type==="highlight"&&t.color?sc[b_(t.color)]:"var(--tandem-author-user)"}var b9=M("<span> </span>"),y9=M(`<button class="ach-edit-btn svelte-d1dbnh" title="Edit this annotation's content">✎ Edit</button>`),w9=M('<span class="ach-edited svelte-d1dbnh">(edited)</span>'),k9=M('<span class="ach-dot svelte-d1dbnh" aria-hidden="true"></span>'),x9=M('<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 hd(t,e){ze(e,!0);const n=F(()=>d3(e.annotation)),r=F(()=>p9(e.annotation.author)),i=F(()=>e.annotation.author==="claude"?"var(--tandem-author-claude)":"var(--tandem-author-user)");var o=x9(),s=w(o),a=w(s),l=w(a),u=k(a,2);{var c=S=>{var z=kt(),E=Se(z);rd(E,()=>e.extraPill),C(S,z)};G(u,S=>{e.extraPill&&S(c)})}var f=k(u,2);{var h=S=>{var z=b9();let E;var D=w(z);q(()=>{E=At(z,1,"ach-status svelte-d1dbnh",null,E,{"is-accepted":e.annotation.status==="accepted","is-rejected":e.annotation.status!=="accepted"}),ee(D,e.annotation.status)}),C(S,z)};G(f,S=>{e.isPending||S(h)})}var p=k(f,2);{var m=S=>{var z=y9();q(()=>U(z,"data-testid",`edit-btn-${e.annotation.id??""}`)),N("click",z,E=>{E.stopPropagation(),e.onEnterEdit()}),C(S,z)};G(p,S=>{e.isPending&&e.canEdit&&!e.isReviewTarget&&!e.isEditing&&S(m)})}var v=k(s,2),g=w(v);{var b=S=>{var z=w9();C(S,z)};G(g,S=>{e.annotation.editedAt&&S(b)})}var x=k(g,2);{var _=S=>{var z=k9();q(()=>xe(z,`background: ${d(i)??""};`)),C(S,z)};G(x,S=>{e.annotation.author!=="import"&&S(_)})}var T=k(x);q(()=>{xe(a,`background: ${e.badgeBg??""}; color: ${e.badgeFg??""};`),ee(l,d(n)),ee(T,` ${d(r)??""}`)}),C(t,o),Be()}We(["click"]);var _9=M('<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 pd(t,e){ze(e,!0);const n=F(()=>e.text?e.text.length>80?e.text.slice(0,77)+"...":e.text:"");var r=kt(),i=Se(r);{var o=s=>{var a=_9(),l=w(a);q(()=>{U(a,"data-testid",`annotation-snippet-${e.annotationId??""}`),ee(l,d(n))}),C(s,a)};G(i,s=>{e.text&&s(o)})}C(t,r),Be()}var C9=M('<div class="aca-body" style="margin: 0; color: var(--tandem-fg); line-height: 1.45;"><p style="margin: 0;"> </p></div>'),S9=M("<!> <!> <!>",1);function E9(t,e){ze(e,!0);var n=S9(),r=Se(n);hd(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=k(r,2);pd(i,{get annotationId(){return e.annotation.id},get text(){return e.annotation.textSnapshot}});var o=k(i,2);{var s=a=>{var l=C9(),u=w(l),c=w(u);q(()=>ee(c,e.annotation.content||"(no note)")),C(a,l)};G(o,a=>{e.isEditing||a(s)})}C(t,n),Be()}var A9=M('<div class="aca-body" style="margin: 0; color: var(--tandem-fg); line-height: 1.45;"><p style="margin: 0;"> </p></div>'),T9=M("<!> <!> <!>",1);function M9(t,e){ze(e,!0);var n=T9(),r=Se(n);hd(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=k(r,2);pd(i,{get annotationId(){return e.annotation.id},get text(){return e.annotation.textSnapshot}});var o=k(i,2);{var s=a=>{var l=A9(),u=w(l),c=w(u);q(()=>ee(c,e.annotation.content||"(no note)")),C(a,l)};G(o,a=>{e.isEditing||a(s)})}C(t,n),Be()}var D9=M('<input type="checkbox" style="margin-top: 4px; flex-shrink: 0; cursor: pointer;"/>'),O9=M('<div style="font-size: var(--tandem-text-2xs); color: var(--tandem-fg-subtle); margin-bottom: 4px;">From: <span style="font-weight: 500;"> </span></div>'),I9=M('<div class="aca-body" style="margin: 0; color: var(--tandem-fg); line-height: 1.45;"><p style="margin: 0;"> </p></div>'),R9=M('<div style="display: flex; align-items: flex-start; gap: var(--tandem-space-2);"><!> <div style="flex: 1; min-width: 0;"><!> <!> <!> <!></div></div>');function N9(t,e){ze(e,!0);let n=je(e,"selected",3,!1);var r=R9(),i=w(r);{var o=p=>{var m=D9();q(()=>{var v;U(m,"data-testid",`annotation-select-checkbox-${e.annotation.id??""}`),Un(m,n()),U(m,"aria-label",`Select ${((v=e.annotation.importSource)==null?void 0:v.author)??"import"} comment for batch promote`)}),N("click",m,v=>v.stopPropagation()),N("change",m,()=>{var v;return(v=e.onToggleSelect)==null?void 0:v.call(e,e.annotation.id)}),C(p,m)};G(i,p=>{e.onToggleSelect&&p(o)})}var s=k(i,2),a=w(s);hd(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=k(a,2);{var u=p=>{var m=O9(),v=k(w(m)),g=w(v);q(()=>{U(m,"data-testid",`annotation-import-byline-${e.annotation.id??""}`),ee(g,e.annotation.importSource.author)}),C(p,m)};G(l,p=>{var m;(m=e.annotation.importSource)!=null&&m.author&&p(u)})}var c=k(l,2);pd(c,{get annotationId(){return e.annotation.id},get text(){return e.annotation.textSnapshot}});var f=k(c,2);{var h=p=>{var m=I9(),v=w(m),g=w(v);q(()=>ee(g,e.annotation.content||"(no note)")),C(p,m)};G(f,p=>{e.isEditing||p(h)})}C(t,r),Be()}We(["click","change"]);var P9=M('<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>'),L9=M('<div class="aca-body" style="margin: 0; color: var(--tandem-fg); line-height: 1.45;"><p style="margin: 0;"> </p></div>'),F9=M("<!> <!> <!>",1);function z9(t,e){ze(e,!0);var n=F9(),r=Se(n);hd(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 u=P9();C(l,u)},$$slots:{extraPill:!0}});var i=k(r,2);pd(i,{get annotationId(){return e.annotation.id},get text(){return e.annotation.textSnapshot}});var o=k(i,2);{var s=a=>{var l=L9(),u=w(l),c=w(u);q(()=>ee(c,e.annotation.content||"(no note)")),C(a,l)};G(o,a=>{e.isEditing||a(s)})}C(t,n),Be()}var B9=M('<span class="ct-author-dot ct-author-dot--claude svelte-4l0b78" aria-hidden="true"></span> Claude',1),H9=M('<span class="ct-author-dot ct-author-dot--user svelte-4l0b78" aria-hidden="true"></span> You',1),V9=M('<span class="ct-edited svelte-4l0b78">(edited)</span>'),U9=M('<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>'),j9=M('<div class="ct-root svelte-4l0b78" data-testid="comment-thread"></div>');function f3(t,e){ze(e,!0);function n(s){const a=new Date(s),u=new Date().getTime()-a.getTime(),c=Math.floor(u/6e4);if(c<1)return"just now";if(c<60)return`${c}m ago`;const f=Math.floor(c/60);return f<24?`${f}h ago`:a.toLocaleDateString()}var r=kt(),i=Se(r);{var o=s=>{var a=j9();Je(a,21,()=>e.replies,l=>l.id,(l,u)=>{var c=U9(),f=w(c),h=w(f);let p;var m=w(h);{var v=E=>{var D=B9();C(E,D)},g=E=>{var D=H9();C(E,D)};G(m,E=>{d(u).author==="claude"?E(v):E(g,-1)})}var b=k(h,2),x=w(b);{var _=E=>{var D=V9();C(E,D)};G(x,E=>{d(u).editedAt&&E(_)})}var T=k(x),S=k(f,2),z=w(S);q(E=>{U(c,"data-testid",`reply-${d(u).id??""}`),p=At(h,1,"ct-author svelte-4l0b78",null,p,{"is-claude":d(u).author==="claude","is-user":d(u).author!=="claude"}),ee(T,` ${E??""}`),ee(z,d(u).text)},[()=>n(d(u).timestamp)]),C(l,c)}),C(s,a)};G(i,s=>{e.replies.length>0&&s(o)})}C(t,r),Be()}var q9=M('<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>'),W9=M('<button style="padding: 1px 4px; font-size: var(--tandem-text-xs); border: none; background: none; color: var(--tandem-fg-subtle); cursor: pointer;"> </button>'),K9=M('<div style="margin-top: 6px;"><!></div>'),G9=M('<div style="margin-top: 4px; font-size: var(--tandem-text-xs); color: var(--tandem-fg-subtle);"> </div>'),Z9=M('<div class="art-root svelte-155xn9n"><!> <!> <!></div>');function J9(t,e){ze(e,!0);const n=F(()=>Up(e.annotation,e.replies)),r=F(()=>e.annotation.id);let i=B(!1),o=B(""),s=B(!1),a=B(null);const l=F(()=>!!d(o).trim());me(()=>{var b;d(i)&&((b=d(a))==null||b.focus())});function u(b){b.key==="Escape"&&(b.stopPropagation(),y(i,!1),y(o,""))}async function c(){var x;const b=d(o).trim();if(!(!b||d(s))){y(s,!0);try{await((x=e.onReply)==null?void 0:x.call(e,d(r),b))!==!1&&(y(o,""),y(i,!1))}finally{y(s,!1)}}}var f=Z9(),h=w(f);f3(h,{get replies(){return d(n)}});var p=k(h,2);{var m=b=>{var x=K9(),_=w(x);{var T=z=>{var E=q9(),D=w(E);xt(D,Q=>y(a,Q),()=>d(a));var P=k(D,2),R=w(P),H=k(R,2);q(()=>{U(D,"data-testid",`reply-input-${d(r)??""}`),xr(D,d(o)),xe(D,zu),U(R,"data-testid",`reply-send-btn-${d(r)??""}`),R.disabled=!d(l)||d(s),xe(R,`padding: 2px 8px; font-size: var(--tandem-text-xs); border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-1); background: ${d(l)?"var(--tandem-accent-bg)":"var(--tandem-surface-muted)"}; color: ${d(l)?"var(--tandem-accent-fg-strong)":"var(--tandem-fg-subtle)"}; cursor: ${d(l)?"pointer":"default"};`),U(H,"data-testid",`reply-cancel-btn-${d(r)??""}`)}),N("input",D,Q=>y(o,Q.target.value,!0)),N("keydown",D,u),N("click",R,c),N("click",H,()=>{y(i,!1),y(o,"")}),C(z,E)},S=z=>{var E=W9(),D=w(E);q(()=>{U(E,"data-testid",`reply-btn-${d(r)??""}`),ee(D,`Reply${d(n).length>0?` (${d(n).length})`:""}`)}),N("click",E,()=>y(i,!0)),C(z,E)};G(_,z=>{d(i)?z(T):z(S,-1)})}N("click",x,z=>z.stopPropagation()),N("keydown",x,z=>z.stopPropagation()),C(b,x)};G(p,b=>{e.isPending&&e.onReply&&!e.isEditing&&b(m)})}var v=k(p,2);{var g=b=>{var x=G9(),_=w(x);q(()=>ee(_,`${d(n).length??""}
|
|
68
|
+
${d(n).length===1?"reply":"replies"}`)),C(b,x)};G(v,b=>{!e.isPending&&d(n).length>0&&!e.onReply&&b(g)})}C(t,f),Be()}We(["click","keydown","input"]);function sl(t){return document.body.appendChild(t),{destroy(){t.remove()}}}var Y9=M('<p style="margin: 0; font-size: var(--tandem-text-sm); color: var(--tandem-fg-subtle);">No replies yet.</p>'),X9=M('<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),Q9=M('<button type="button" data-testid="reply-thread-overlay-reply">Reply</button>'),$9=M('<div style="border-top: 1px solid var(--tandem-border); padding-top: var(--tandem-space-3);"><!></div>'),eP=M('<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 tP(t,e){ze(e,!0);const n=F(()=>Up(e.annotation,e.replies));let r=B(null),i=B(null),o=null,s=B(!1),a=B(""),l=B(!1);const u=F(()=>!!d(a).trim());me(()=>{if(!e.open)return;const g=St(()=>d(r));if(!g)return;o=document.activeElement,g.focus();const b=x=>{g&&!g.contains(x.target)&&g.focus()};return document.addEventListener("focusin",b),()=>{document.removeEventListener("focusin",b),o instanceof HTMLElement&&document.contains(o)&&o.focus()}}),me(()=>{e.open||(y(s,!1),y(a,""),y(l,!1))}),me(()=>{var g;d(s)&&((g=d(i))==null||g.focus())});function c(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(T=>!T.closest("[hidden]"));if(b.length===0){g.preventDefault();return}const x=b[0],_=b[b.length-1];g.shiftKey&&document.activeElement===x?(g.preventDefault(),_.focus()):!g.shiftKey&&document.activeElement===_&&(g.preventDefault(),x.focus())}var p=kt(),m=Se(p);{var v=g=>{var b=eP(),x=w(b),_=w(x),T=w(_),S=k(w(T)),z=w(S),E=k(T,2),D=k(_,2),P=w(D),R=k(D,2);{var H=W=>{var te=Y9();C(W,te)},Q=W=>{f3(W,{get replies(){return d(n)}})};G(R,W=>{d(n).length===0?W(H):W(Q,-1)})}var Z=k(R,2);{var $=W=>{var te=$9(),ae=w(te);{var re=oe=>{var fe=X9(),I=Se(fe);xt(I,L=>y(i,L),()=>d(i));var O=k(I,2),A=w(O),V=k(A,2);q(()=>{xe(I,zu),A.disabled=!d(u)||d(l),xe(A,`padding: 4px 10px; font-size: var(--tandem-text-xs); border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-1); background: ${d(u)?"var(--tandem-accent-bg)":"var(--tandem-surface-muted)"}; color: ${d(u)?"var(--tandem-accent-fg-strong)":"var(--tandem-fg-subtle)"}; cursor: ${d(u)&&!d(l)?"pointer":"default"};`),xe(V,Rw)}),N("keydown",I,c),Bn(I,()=>d(a),L=>y(a,L)),N("click",A,f),N("click",V,()=>{y(s,!1),y(a,"")}),C(oe,fe)},ue=oe=>{var fe=Q9();q(()=>xe(fe,Rw)),N("click",fe,()=>y(s,!0)),C(oe,fe)};G(ae,oe=>{d(s)?oe(re):oe(ue,-1)})}C(W,te)};G(Z,W=>{e.onReply&&W($)})}xt(x,W=>y(r,W),()=>d(r)),cr(b,W=>sl==null?void 0:sl(W)),q(()=>{ee(z,`(${d(n).length??""}
|
|
69
|
+
${d(n).length===1?"reply":"replies"})`),ee(P,e.annotation.content)}),N("click",b,function(...W){var te;(te=e.onClose)==null||te.apply(this,W)}),N("keydown",b,()=>{}),N("click",x,W=>W.stopPropagation()),N("keydown",x,h),N("click",E,function(...W){var te;(te=e.onClose)==null||te.apply(this,W)}),C(g,b)};G(m,g=>{e.open&&g(v)})}C(t,p),Be()}We(["click","keydown"]);var nP=M('<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),rP=M('<p style="margin: 0; font-size: 12px; color: var(--tandem-fg-muted);"> </p>'),iP=M('<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>'),oP=M("<!> <!> <!>",1);function sP(t,e){ze(e,!0);var n=oP(),r=Se(n);hd(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=k(r,2);pd(i,{get annotationId(){return e.annotation.id},get text(){return e.annotation.textSnapshot}});var o=k(i,2);{var s=a=>{var l=iP(),u=w(l),c=w(u);{var f=g=>{var b=nP(),x=Se(b),_=w(x),T=k(x);T.nodeValue=" → ",q(()=>ee(_,e.annotation.textSnapshot)),C(g,b)};G(c,g=>{e.annotation.textSnapshot&&g(f)})}var h=k(c,2),p=w(h),m=k(u,2);{var v=g=>{var b=rP(),x=w(b);q(()=>ee(x,e.annotation.content)),C(g,b)};G(m,g=>{e.annotation.content&&g(v)})}q(()=>{U(u,"data-testid",`suggestion-diff-${e.annotation.id??""}`),xe(u,`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;`),ee(p,e.annotation.suggestedText)}),C(a,l)};G(o,a=>{e.isEditing||a(s)})}C(t,n),Be()}var aP=M('<div class="tandem-claude-typing svelte-3ascys" role="status" aria-live="polite" aria-label="Claude is working on this annotation" title="Claude is working on this annotation"><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>'),lP=M('<button type="button" class="tandem-expand-thread svelte-3ascys">Expand thread</button>'),uP=M('<div role="listitem"><!> <!> <!> <!> <!> <!></div> <!>',1);function V0(t,e){ze(e,!0);let n=je(e,"replies",19,()=>[]),r=je(e,"claudeTyping",3,!1),i=je(e,"selected",3,!1),o=je(e,"density",3,"full"),s=B(!1),a=B(""),l=B(""),u=B("");const c=F(()=>e.annotation.status==="pending"),f=F(()=>e.annotation.suggestedText!==void 0),h=F(()=>e.onEdit!==void 0),p=F(()=>g9(e.annotation)),m=F(()=>Up(e.annotation,n())),v=F(()=>d(m).length>=1);let g=B(!1);const b=F(()=>o()==="stub"?"stub":d(s)?"full":o());let x=St(()=>d(b));me(()=>{d(b)!==x&&(x=d(b),d(b)==="stub"&&y(g,!1))});const _=F(()=>e.annotation.author==="import"?"var(--tandem-surface-muted)":e.annotation.type==="highlight"?`color-mix(in srgb, ${v9(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)"),T=F(()=>e.isReviewTarget?"var(--tandem-accent-bg)":d(_));function S(){d(f)?(y(l,e.annotation.suggestedText??"",!0),y(u,e.annotation.content,!0)):y(a,e.annotation.content,!0),y(s,!0)}function z(){var ne;const K=d(f)?JSON.stringify({suggestedText:d(l),content:d(u)}):d(a);(ne=e.onEdit)==null||ne.call(e,e.annotation.id,K),y(s,!1)}function E(){y(s,!1)}function D(K){K.key==="Escape"&&(K.stopPropagation(),E())}var P=uP(),R=Se(P);let H;var Q=w(R);{var Z=K=>{var ne=aP();q(()=>U(ne,"data-testid",`claude-typing-indicator-${e.annotation.id??""}`)),C(K,ne)};G(Q,K=>{r()&&K(Z)})}var $=k(Q,2);{var W=K=>{N9(K,{get annotation(){return e.annotation},get isPending(){return d(c)},get isReviewTarget(){return e.isReviewTarget},get isEditing(){return d(s)},get canEdit(){return d(h)},onEnterEdit:S,get selected(){return i()},get onToggleSelect(){return e.onToggleSelect}})},te=K=>{M9(K,{get annotation(){return e.annotation},get isPending(){return d(c)},get isReviewTarget(){return e.isReviewTarget},get isEditing(){return d(s)},get canEdit(){return d(h)},onEnterEdit:S})},ae=K=>{z9(K,{get annotation(){return e.annotation},get isPending(){return d(c)},get isReviewTarget(){return e.isReviewTarget},get isEditing(){return d(s)},get canEdit(){return d(h)},onEnterEdit:S})},re=K=>{sP(K,{get annotation(){return e.annotation},get isPending(){return d(c)},get isReviewTarget(){return e.isReviewTarget},get isEditing(){return d(s)},get canEdit(){return d(h)},onEnterEdit:S})},ue=K=>{E9(K,{get annotation(){return e.annotation},get isPending(){return d(c)},get isReviewTarget(){return e.isReviewTarget},get isEditing(){return d(s)},get canEdit(){return d(h)},onEnterEdit:S})};G($,K=>{e.annotation.author==="import"?K(W):e.annotation.type==="highlight"?K(te,1):e.annotation.type==="note"?K(ae,2):e.annotation.suggestedText!==void 0?K(re,3):K(ue,-1)})}var oe=k($,2);{var fe=K=>{h9(K,{get annotationId(){return e.annotation.id},get hasSuggestedText(){return d(f)},get editText(){return d(a)},get editNewText(){return d(l)},get editReason(){return d(u)},onChangeEditText:ne=>y(a,ne,!0),onChangeEditNewText:ne=>y(l,ne,!0),onChangeEditReason:ne=>y(u,ne,!0),onKeyDown:D,onSave:z,onCancel:E})};G(oe,K=>{d(s)&&K(fe)})}var I=k(oe,2);u9(I,{get annotationId(){return e.annotation.id},get annotationType(){return e.annotation.type},get isPending(){return d(c)},get isEditing(){return d(s)},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 O=k(I,2);J9(O,{get annotation(){return e.annotation},get replies(){return d(m)},get isPending(){return d(c)},get isEditing(){return d(s)},get onReply(){return e.onReply}});var A=k(O,2);{var V=K=>{var ne=lP();q(()=>U(ne,"data-testid",`reply-thread-expand-${e.annotation.id??""}`)),N("click",ne,ye=>{ye.stopPropagation(),y(g,!0)}),C(K,ne)};G(A,K=>{d(v)&&K(V)})}var L=k(R,2);{var J=K=>{tP(K,{get open(){return d(g)},get annotation(){return e.annotation},get replies(){return d(m)},get onReply(){return e.onReply},onClose:()=>y(g,!1)})};G(L,K=>{(d(v)||d(g))&&K(J)})}q(()=>{H=At(R,1,"tandem-annotation-card svelte-3ascys",null,H,{"is-review-target":e.isReviewTarget,"is-density-clamped":d(b)==="clamped","is-density-stub":d(b)==="stub"}),U(R,"data-testid",`annotation-card-${e.annotation.id??""}`),U(R,"data-annotation-type",e.annotation.type),U(R,"data-density",d(b)),U(R,"data-claude-typing",r()?"true":void 0),U(R,"aria-label",d(p)),U(R,"aria-current",e.isReviewTarget?"true":void 0),xe(R,`background: ${d(T)??""}; opacity: ${d(c)?1:.6}; cursor: ${e.onClick?"pointer":"default"};`)}),N("click",R,function(...K){var ne;(ne=e.onClick)==null||ne.apply(this,K)}),C(t,P),Be()}We(["click"]);const cP="browser";function dP(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 ps(t,e){return dP(t,e,cP)}function wa(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 Nb=t=>{console.warn("[sanitize]",t)};function h3(t,e,n){if(!t)return;const r=t.getMap(Ro),i=r.get(e);if(!i)return;const o=wa(i,Nb);ps(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 p3(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 m3(t,e){if(!t)return;const n=t.getMap(Ro),r=n.get(e);if(!r)return;const i=wa(r,Nb);i.type==="note"&&ps(t,()=>{n.set(e,p3(i))})}function fP(t,e){if(!t||e.length===0)return 0;const n=t.getMap(Ro);let r=0;return ps(t,()=>{for(const i of e){const o=n.get(i);if(!o)continue;const s=wa(o,Nb);s.type==="note"&&(n.set(i,p3(s)),r++)}}),r}async function g3(t,e){try{const n=await fetch(`${qn}${rM}`,{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 v3(t,e,n){try{const r=await fetch(`${qn}${nM}`,{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}}var hP=M('<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 pP(t,e){var n=kt(),r=Se(n);{var i=o=>{var s=hP(),a=w(s),l=w(a),u=k(a,2),c=k(u,2),f=w(c);q(()=>{ee(l,`${e.selectedCount??""} selected`),ee(f,`Send ${e.selectedCount??""} to Claude`)}),N("click",u,function(...h){var p;(p=e.onClear)==null||p.apply(this,h)}),N("click",c,function(...h){var p;(p=e.onPromote)==null||p.apply(this,h)}),C(o,s)};G(r,o=>{e.selectedCount>0&&o(i)})}C(t,n)}We(["click"]);var mP=M('<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),gP=M('<button data-testid="bulk-accept-btn"> </button> <button data-testid="bulk-dismiss-btn">Reject All</button>',1),vP=M('<div style="padding: 6px var(--tandem-space-4); border-bottom: 1px solid var(--tandem-border); display: flex; gap: 4px; align-items: center;"><!></div>');function bP(t,e){ze(e,!0);let n=je(e,"confirmRef",15,null);const r=F(()=>e.bulkConfirm==="accept"),i=F(()=>e.pendingCount===e.allPendingCount?`${e.pendingCount} annotations?`:`${e.pendingCount} of ${e.allPendingCount} pending?`);var o=kt(),s=Se(o);{var a=l=>{var u=vP(),c=w(u);{var f=p=>{var m=mP(),v=Se(m),g=w(v),b=k(v,2);xt(b,_=>n(_),()=>n());var x=k(b,2);xe(x,"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);"),q(()=>{ee(g,`${d(r)?"Accept":"Reject"}
|
|
70
|
+
${d(i)??""}`),xe(b,`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(r)?"var(--tandem-success-bg)":"var(--tandem-error-bg)"}; color: ${d(r)?"var(--tandem-success-fg-strong)":"var(--tandem-error-fg-strong)"}; font-weight: 600;`)}),N("click",b,function(..._){var T;(T=d(r)?e.onConfirmAccept:e.onConfirmDismiss)==null||T.apply(this,_)}),N("click",x,function(..._){var T;(T=e.onCancel)==null||T.apply(this,_)}),C(p,m)},h=p=>{var m=gP(),v=Se(m);xe(v,"padding: 2px 8px; font-size: var(--tandem-text-xs); border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-1); cursor: pointer; background: var(--tandem-success-bg); color: var(--tandem-success-fg-strong);");var g=w(v),b=k(v,2);xe(b,"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);"),q(()=>ee(g,`Accept All (${e.pendingCount??""})`)),N("click",v,function(...x){var _;(_=e.onRequestAccept)==null||_.apply(this,x)}),N("click",b,function(...x){var _;(_=e.onRequestDismiss)==null||_.apply(this,x)}),C(p,m)};G(c,p=>{e.bulkConfirm?p(f):p(h,-1)})}C(l,u)};G(s,l=>{e.pendingCount>1&&l(a)})}C(t,o),Be()}We(["click"]);var yP=M("<option> </option>"),wP=M('<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 Ym(t,e){ze(e,!0);var n=wP();Je(n,21,()=>e.options,i=>i.value,(i,o)=>{var s=yP(),a=w(s),l={};q(()=>{ee(a,d(o).label),l!==(l=d(o).value)&&(s.value=(s.__value=d(o).value)??"")}),C(i,s)});var r;Wv(n),q(()=>{U(n,"data-testid",e.testId),U(n,"aria-label",e.ariaLabel),r!==(r=e.value)&&(n.value=(n.__value=e.value)??"",wp(n,e.value))}),N("change",n,i=>e.onChange(i.target.value)),C(t,n),Be()}We(["change"]);var kP=M('<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>'),xP=M('<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 _P(t,e){ze(e,!0);var n=kt(),r=Se(n);{var i=o=>{var s=xP(),a=w(s);Ym(a,{testId:"filter-type",ariaLabel:"Filter by type",get value(){return e.filterType},onChange:p=>e.onSetFilterType(p),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 l=k(a,2);Ym(l,{testId:"filter-author",ariaLabel:"Filter by author",get value(){return e.filterAuthor},onChange:p=>e.onSetFilterAuthor(p),options:[{value:"all",label:"Anyone"},{value:"claude",label:"Claude"},{value:"user",label:"You"},{value:"import",label:"Imported"}]});var u=k(l,2);Ym(u,{testId:"filter-status",ariaLabel:"Filter by status",get value(){return e.filterStatus},onChange:p=>e.onSetFilterStatus(p),options:[{value:"all",label:"Any status"},{value:"pending",label:"Pending"},{value:"accepted",label:"Accepted"},{value:"dismissed",label:"Dismissed"}]});var c=k(u,2);{var f=p=>{var m=kP();N("click",m,function(...v){var g;(g=e.onClearFilters)==null||g.apply(this,v)}),C(p,m)};G(c,p=>{e.hasFilters&&p(f)})}var h=k(c,2);N("click",h,function(...p){var m;(m=e.onToggleOpen)==null||m.apply(this,p)}),C(o,s)};G(r,o=>{e.open&&o(i)})}C(t,n),Be()}We(["click"]);var CP=M(`<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>`),SP=M('<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>'),EP=M('<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>'),AP=M('<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>'),TP=M('<div style="padding: var(--tandem-space-3); flex: 1;" role="list" aria-label="Annotations" class="svelte-l26r3u"><!> <!></div>'),MP=M('<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 Nw(t,e){ze(e,!0);let n=je(e,"storeReadOnly",3,!1),r=je(e,"claudeWorkingAnnotationId",3,null);const i=F(()=>e.reduceMotion?"auto":"smooth"),o="tandem:storeReadOnlyBannerDismissed";function s(){try{return localStorage.getItem(o)==="true"}catch{return!1}}let a=B(Ge(s()));me(()=>{if(!n()){y(a,!1);try{localStorage.removeItem(o)}catch{}}});function l(){try{localStorage.setItem(o,"true")}catch{}y(a,!0)}let u=B("all"),c=B("all"),f=B("all"),h=B(!1),p=B(null),m=B(void 0),v=B(null);me(()=>{var se;d(p)&&((se=d(v))==null||se.focus())}),me(()=>{d(u),d(c),d(f),y(p,null)}),me(()=>{var se;(se=e.onFilterChange)==null||se.call(e,d(u),d(c),d(f))});let g=B(Ge(new Map));me(()=>{if(!e.ydoc){y(g,new Map,!0);return}const se=e.ydoc.getMap(__);function X(){const le=new Map;se.forEach(he=>{const De=he;if(De&&typeof De=="object"&&De.annotationId){const Oe=le.get(De.annotationId)??[];Oe.push(De),le.set(De.annotationId,Oe)}});for(const he of le.values())he.sort((De,Oe)=>De.timestamp-Oe.timestamp);y(g,le,!0)}return X(),se.observe(X),()=>se.unobserve(X)});const b=F(()=>{const se=[],X=[];for(const be of e.annotations){be.status==="pending"&&X.push(be);let Ne;d(u)==="all"?Ne=!0:d(u)==="with-replacement"?Ne=be.suggestedText!==void 0:Ne=be.type===d(u);const Qe=d(c)==="all"||be.author===d(c),Ae=d(f)==="all"||be.status===d(f);Ne&&Qe&&Ae&&se.push(be)}const le=se.filter(be=>be.status==="pending"),he=se.filter(Gf),De=se.filter(be=>be.status!=="pending"),Oe=e.annotations.filter(Gf);return{filtered:se,pending:le,reviewPending:he,resolved:De,allPending:X,reviewAllPending:Oe}}),x=F(()=>d(u)!=="all"||d(c)!=="all"||d(f)!=="all"),_=F(()=>{if(!d(x))return"All";const se=[];if(d(u)!=="all"){const X={all:"All",highlight:"Highlights",comment:"Comments",note:"Notes","with-replacement":"With replacement"};se.push(X[d(u)])}if(d(c)!=="all"){const X={all:"Anyone",claude:"Claude",user:"You",import:"Imported"};se.push(X[d(c)])}if(d(f)!=="all"){const X={all:"Any status",pending:"Pending",accepted:"Accepted",dismissed:"Dismissed"};se.push(X[d(f)])}return se.join(" · ")||"All"});let T=!1;me(()=>{if(d(u),d(c),d(f),!T){T=!0;return}St(()=>{var se;if(e.activeAnnotationId){const X=document.querySelector(`[data-testid="annotation-card-${e.activeAnnotationId}"]`);if(X){X.scrollIntoView({block:"center"});return}console.warn(`[tandem] SidePanel: active annotation ${e.activeAnnotationId} not found on filter change; scrolling to top`)}(se=d(m))==null||se.scrollTo({top:0})})}),me(()=>{const se=e.activeAnnotationId;if(!se)return;const X=d(i),le=setTimeout(()=>{const he=document.querySelector(`[data-testid="annotation-card-${se}"]`);if(he){he.scrollIntoView({behavior:X,block:"nearest"}),he.classList.add("tandem-annotation-flash");const De=()=>he.classList.remove("tandem-annotation-flash");he.addEventListener("animationend",De,{once:!0})}else console.warn(`[tandem] SidePanel: active annotation ${se} not found after 50ms delay; scroll-to-card skipped`)},50);return()=>clearTimeout(le)});const S=(se,X)=>h3(e.ydoc,se,X),z=se=>m3(e.ydoc,se),E=se=>g3(se,e.documentId),D=(se,X)=>v3(se,X,e.documentId);function P(se){for(const X of d(b).reviewPending)e.review.resolveAnnotation(X.id,se);y(p,null)}let R=B(Ge(new Set));me(()=>{const se=new Set(d(b).pending.filter(X=>X.author==="import"&&X.type==="note").map(X=>X.id));St(()=>{const X=new Set([...d(R)].filter(le=>se.has(le)));X.size!==d(R).size&&y(R,X,!0)})});function H(se){const X=new Set(d(R));X.has(se)?X.delete(se):X.add(se),y(R,X,!0)}function Q(){const se=Array.from(d(R));fP(e.ydoc,se),y(R,new Set,!0)}function Z(){y(R,new Set,!0)}function $(se){se.target===se.currentTarget&&e.onActiveAnnotationChange(null)}var W=MP(),te=w(W);{var ae=se=>{var X=CP(),le=k(w(X),2);q(()=>{xe(X,`padding: 10px 14px; margin: 10px 14px 0; background: ${Fd.background}; border: 1px solid ${Fd.border}; border-radius: var(--tandem-r-4); font-size: var(--tandem-text-xs); color: ${Fd.color}; display: flex; justify-content: space-between; align-items: flex-start; gap: 10px;`),xe(le,`flex-shrink: 0; font-size: var(--tandem-text-xs); padding: 2px 8px; border: none; border-radius: var(--tandem-r-2); background: none; color: ${Fd.color}; cursor: pointer; font-weight: 500;`)}),N("click",le,l),C(se,X)};G(te,se=>{n()&&!d(a)&&se(ae)})}var re=k(te,2),ue=w(re),oe=w(ue),fe=k(w(oe));{var I=se=>{var X=SP(),le=w(X);q(()=>ee(le,d(b).allPending.length)),C(se,X)};G(fe,se=>{d(b).allPending.length>0&&se(I)})}var O=k(oe,2),A=w(O),V=k(O,2),L=w(V),J=w(L),K=k(re,2);_P(K,{get filterType(){return d(u)},get filterAuthor(){return d(c)},get filterStatus(){return d(f)},get hasFilters(){return d(x)},get open(){return d(h)},onToggleOpen:()=>y(h,!d(h)),onSetFilterType:se=>{y(u,se,!0)},onSetFilterAuthor:se=>{y(c,se,!0)},onSetFilterStatus:se=>{y(f,se,!0)},onClearFilters:()=>{y(u,"all"),y(c,"all"),y(f,"all")}});var ne=k(K,2),ye=w(ne);$N(ye,{get annotations(){return e.annotations},get activeDocFormat(){return e.activeDocFormat},get documentId(){return e.documentId}});var ce=k(ne,2);pP(ce,{get selectedCount(){return d(R).size},onPromote:Q,onClear:Z});var ve=k(ce,2);bP(ve,{get bulkConfirm(){return d(p)},get pendingCount(){return d(b).reviewPending.length},get allPendingCount(){return d(b).reviewAllPending.length},onConfirmAccept:()=>P("accepted"),onConfirmDismiss:()=>P("dismissed"),onCancel:()=>y(p,null),onRequestAccept:()=>y(p,"accept"),onRequestDismiss:()=>y(p,"dismiss"),get confirmRef(){return d(v)},set confirmRef(se){y(v,se,!0)}});var _e=k(ve,2);{var Y=se=>{var X=EP(),le=w(X),he=w(le);q(()=>ee(he,d(x)?"No annotations match filters.":"No annotations yet. Open a document to get started.")),N("click",X,$),C(se,X)},we=se=>{var X=TP(),le=w(X);Je(le,17,()=>d(b).pending,Oe=>Oe.id,(Oe,be)=>{const Ne=F(()=>e.activeAnnotationId===d(be).id);{let Qe=F(()=>d(g).get(d(be).id)??[]),Ae=F(()=>r()===d(be).id),Me=F(()=>d(be).author!=="user"?e.review.handleAccept:void 0),Ze=F(()=>d(be).author!=="user"?e.review.handleDismiss:void 0),ut=F(()=>d(be).author==="user"?E:void 0),it=F(()=>d(be).type==="note"?z:void 0),pe=F(()=>d(R).has(d(be).id)),Ie=F(()=>d(be).author==="import"&&d(be).type==="note"?H:void 0);V0(Oe,{get annotation(){return d(be)},get replies(){return d(Qe)},get isReviewTarget(){return d(Ne)},get claudeTyping(){return d(Ae)},get onAccept(){return d(Me)},get onDismiss(){return d(Ze)},get onRemove(){return d(ut)},get onSendToClaude(){return d(it)},onEdit:S,onReply:D,onClick:()=>e.review.scrollToAnnotation(d(be)),get selected(){return d(pe)},get onToggleSelect(){return d(Ie)}})}});var he=k(le,2);{var De=Oe=>{var be=AP(),Ne=w(be),Qe=w(Ne),Ae=k(Ne,2);Je(Ae,21,()=>d(b).resolved,Me=>Me.id,(Me,Ze)=>{{let ut=F(()=>d(g).get(d(Ze).id)??[]),it=F(()=>e.review.getRecentlyResolved().has(d(Ze).id));V0(Me,{get annotation(){return d(Ze)},get replies(){return d(ut)},get onUndo(){return e.review.undoResolveAnnotation},get undoable(){return d(it)},onClick:()=>e.review.scrollToAnnotation(d(Ze))})}}),q(()=>ee(Qe,`${d(b).resolved.length??""} resolved`)),C(Oe,be)};G(he,Oe=>{d(b).resolved.length>0&&Oe(De)})}N("click",X,$),C(se,X)};G(_e,se=>{d(b).filtered.length===0?se(Y):se(we,-1)})}xt(W,se=>y(m,se),()=>d(m)),cr(W,(se,X)=>Ht==null?void 0:Ht(se,X),()=>"y"),q(()=>{ee(A,`${d(b).allPending.length??""} pending annotation${d(b).allPending.length!==1?"s":""}`),ee(J,`${d(_)??""} ${d(b).filtered.length??""}`)}),N("click",V,()=>y(h,!d(h))),C(t,W),Be()}We(["click"]);var DP=M('<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>'),OP=M(`<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>`),IP=M('<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>'),RP=M('<ul style="list-style: none; margin: 0; padding: 0;"></ul>'),NP=M('<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 Pw(t,e){ze(e,!0);let n=je(e,"annotations",19,()=>[]),r=je(e,"focusTrigger",3,0),i=je(e,"activeFilterType",3,"all"),o=je(e,"activeFilterAuthor",3,"all"),s=je(e,"activeFilterStatus",3,"all"),a=B(Ge([])),l=B(-1),u=B(Ge([])),c=B(""),f=B(null),h=B(-1);me(()=>{const R=e.editor;if(!R||R.isDestroyed){y(a,[],!0);return}y(a,E0(R),!0),St(()=>{y(u,d(u).slice(0,d(a).length),!0),d(l)>=d(a).length&&y(l,Math.max(0,d(a).length-1),!0)});const H=()=>{y(a,E0(R),!0),y(u,d(u).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",H),()=>{R.isDestroyed||R.off("update",H),y(a,[],!0)}}),me(()=>{var R,H;r()>0&&((R=d(f))==null||R.focus(),(H=d(f))==null||H.select())}),me(()=>{const R=e.editor;if(!R||R.isDestroyed)return;const H=R.view.dom.closest(".editor-scroll")??R.view.dom.parentElement;function Q(){if(!R||R.isDestroyed||d(a).length===0){y(h,-1);return}const $=((H==null?void 0:H.getBoundingClientRect().top)??0)+48;let W=-1;for(let te=0;te<d(a).length;te++)try{R.view.coordsAtPos(d(a)[te].pos+1).top<=$&&(W=te)}catch{}y(h,W,!0)}return Q(),H==null||H.addEventListener("scroll",Q),()=>H==null?void 0:H.removeEventListener("scroll",Q)});function p(){const R=e.editor;!R||R.isDestroyed||(d(c)?R.commands.find({query:d(c),caseSensitive:!1,wholeWord:!1,regexMode:!1}):R.commands.findClose())}function m(R){var H,Q,Z,$;R.key==="Enter"?(R.preventDefault(),R.shiftKey?(H=e.editor)==null||H.commands.findPrev():(Q=e.editor)==null||Q.commands.findNext()):R.key==="Escape"&&(R.preventDefault(),y(c,""),(Z=e.editor)==null||Z.commands.findClose(),($=d(f))==null||$.blur())}const v=F(()=>{const R=e.editor;if(!R||R.isDestroyed||d(a).length===0)return[];const H=R.state.doc.content.size,Q=[];for(const Z of n()){if(i()!=="all"){if(i()==="with-replacement"){if(!Z.suggestedText)continue}else if(Z.type!==i())continue}if(!(o()!=="all"&&Z.author!==o())&&!(s()!=="all"&&Z.status!==s()))try{Q.push(Ss(R.state.doc,Z.range.from))}catch{}}return d(a).map((Z,$)=>{const W=$+1<d(a).length?d(a)[$+1].pos:H;return Q.filter(te=>te>=Z.pos&&te<W).length})});function g(R,H){const Q=e.editor;if(!Q||Q.isDestroyed)return;const{state:Z}=Q;try{const $=Z.doc.resolve(R.pos+1),W=qe.near($);Q.view.dispatch(Z.tr.setSelection(W)),Q.view.focus();const{node:te}=Q.view.domAtPos(R.pos+1),ae=te instanceof Element?te:te.parentElement,re=Q.view.dom.closest(".editor-scroll")??Q.view.dom.parentElement;if(ae&&re){const ue=ae.getBoundingClientRect().top,oe=re.getBoundingClientRect().top;re.scrollTop+=ue-oe-re.clientHeight*.05}}catch{}y(l,H,!0)}function b(R){var H,Q,Z,$;if(d(a).length!==0)if(R.key==="ArrowDown"){R.preventDefault();const W=(d(l)+1)%d(a).length;y(l,W),(H=d(u)[W])==null||H.focus()}else if(R.key==="ArrowUp"){R.preventDefault();const W=(d(l)-1+d(a).length)%d(a).length;y(l,W),(Q=d(u)[W])==null||Q.focus()}else R.key==="Home"?(R.preventDefault(),y(l,0),(Z=d(u)[0])==null||Z.focus()):R.key==="End"&&(R.preventDefault(),y(l,d(a).length-1),($=d(u)[d(a).length-1])==null||$.focus())}var x=NP(),_=k(w(x),2),T=w(_),S=k(w(T),2);xt(S,R=>y(f,R),()=>d(f));var z=k(_,2),E=w(z);{var D=R=>{var H=DP();C(R,H)},P=R=>{var H=RP();Je(H,21,()=>d(a),Sl,(Q,Z,$)=>{const W=F(()=>d(h)===$),te=F(()=>d(v)[$]??0);var ae=IP(),re=w(ae),ue=w(re),oe=k(ue,2),fe=w(oe),I=k(oe,2);{var O=A=>{var V=OP(),L=w(V);q(()=>{U(V,"title",`${d(te)??""} annotation${d(te)!==1?"s":""}`),ee(L,d(te))}),C(A,V)};G(I,A=>{d(te)>0&&A(O)})}xt(re,(A,V)=>d(u)[V]=A,A=>{var V;return(V=d(u))==null?void 0:V[A]},()=>[$]),q(()=>{U(re,"data-testid",`outline-heading-${d(Z).level}-${$}`),U(re,"tabindex",d(l)===$||d(l)===-1&&$===0?0:-1),xe(re,`
|
|
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(Z).level-1)*12}px);
|
|
87
|
+
font-size: ${d(Z).level===1?"var(--tandem-text-sm)":"var(--tandem-text-xs)"};
|
|
88
|
+
font-weight: ${d(Z).level===1?600:d(Z).level===2?500:400};
|
|
89
|
+
color: ${d(W)?"var(--tandem-accent)":d(Z).level===1?"var(--tandem-fg)":d(Z).level===2?"var(--tandem-fg-subtle)":"var(--tandem-fg-muted)"};
|
|
90
|
+
background: ${d(W)?"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
|
+
`),U(re,"title",d(Z).text),xe(ue,d(W)?"background-color: var(--tandem-accent); opacity: 1;":""),ee(fe,d(Z).text||"(untitled)")}),N("click",re,()=>g(d(Z),$)),rn("focus",re,()=>y(l,$,!0)),rn("mouseenter",re,A=>{d(W)||(A.currentTarget.style.background="var(--tandem-surface-hover, var(--tandem-surface-muted))")}),rn("mouseleave",re,A=>{d(W)||(A.currentTarget.style.background="none")}),C(Q,ae)}),C(R,H)};G(E,R=>{d(a).length===0?R(D):R(P,-1)})}cr(z,(R,H)=>Ht==null?void 0:Ht(R,H),()=>"y"),N("keydown",x,b),N("input",S,p),N("keydown",S,m),Bn(S,()=>d(c),R=>y(c,R)),C(t,x),Be()}We(["keydown","input","click"]);var PP=M("<div><!></div>");function Xm(t,e){ze(e,!0);let n=h6(e,["$$slots","$$events","$$legacy","kind","visible"]);const r=F(()=>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=kt(),o=Se(i);{var s=c=>{var f=PP(),h=w(f);{var p=g=>{Iw(g,_u(()=>n,{get visible(){return e.visible}}))},m=g=>{Pw(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=>{Nw(g,_u(()=>n))};G(h,g=>{e.kind==="chat"?g(p):e.kind==="outline"?g(m,1):g(v,-1)})}q(()=>xe(f,d(r))),C(c,f)},a=c=>{Iw(c,_u(()=>n))},l=c=>{Pw(c,{get editor(){return e.editor},get annotations(){return e.annotations},get focusTrigger(){return e.focusTrigger},get activeFilterType(){return e.activeFilterType}})},u=c=>{Nw(c,_u(()=>n))};G(o,c=>{d(r)?c(s):e.kind==="chat"?c(a,1):e.kind==="outline"?c(l,2):c(u,-1)})}C(t,i),Be()}var LP=M('<span style="color: var(--tandem-error-fg-strong); font-size: var(--tandem-text-xs); max-width: 200px;"> </span>'),FP=M('<button type="button" class="tandem-banner__cta" data-testid="convert-to-markdown-btn"> </button>'),zP=M(`<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 BP(t,e){ze(e,!0);const n="tandem:reviewOnlyBannerDismissed";function r(){try{return localStorage.getItem(n)==="true"}catch{return!1}}let i=B(Ge(r())),o=B(!1),s=B(null);async function a(){if(!(!e.documentId||d(o))){y(o,!0),y(s,null);try{const h=await fetch(`${qn}${eM}`,{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 u=kt(),c=Se(u);{var f=h=>{var p=zP(),m=k(w(p),2);{var v=_=>{var T=LP(),S=w(T);q(()=>ee(S,d(s))),C(_,T)};G(m,_=>{d(s)&&_(v)})}var g=k(m,2);{var b=_=>{var T=FP(),S=w(T);q(()=>{T.disabled=d(o),ee(S,d(o)?"Converting…":"Convert to Markdown")}),N("click",T,a),C(_,T)};G(g,_=>{e.documentId&&_(b)})}var x=k(g,2);N("click",x,l),C(h,p)};G(c,h=>{e.visible&&!d(i)&&h(f)})}C(t,u),Be()}We(["click"]);let Qm=null;async function HP(t){if(Qm!==null)return Qm;const e=await fetch(`${qn}${wy}`,{signal:t});if(!e.ok)throw new Error(`${wy} responded ${e.status} ${e.statusText}`);const n=await e.json();return Qm=n,n}function jp(t){let e=B(null),n=B(!1);return me(()=>{if(!t())return;let r=!1;const i=new AbortController,o=setTimeout(()=>i.abort(),3e3);return y(n,!0),HP(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 VP=M('<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 b3(t,e){ze(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=VP(),i=Se(r),o=w(i);xe(o,n);var s=k(o,2),a=w(s),l=k(i,2),u=w(l);xe(u,n);var c=k(u,2),f=w(c);q(()=>{Un(a,e.settings.highContrast),Un(f,e.settings.annotationPatterns)}),N("change",a,h=>e.onUpdate({highContrast:h.target.checked})),N("change",f,h=>e.onUpdate({annotationPatterns:h.target.checked})),C(t,r),Be()}We(["change"]);function Ps(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 u=t(),c=l.indexOf(u),f=l.length-1;let h;a==="Home"?h=0:a==="End"?h=f:a==="ArrowLeft"||a==="ArrowUp"?h=c<=0?f:c-1:h=c>=f?0:c+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 UP=M('<button role="radio"> </button>'),jP=M('<button role="radio"> </button>'),qP=M('<button role="radio"> </button>'),WP=M('<button role="radio"> </button>'),KP=M('<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>'),GP=M('<button role="radio"> </button>'),ZP=M('<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>'),JP=M(`<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>`,1);function y3(t,e){ze(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(X){var le;return((le=e.settings.fontByExtension)==null?void 0:le[X])??e.settings.editorFont}function o(X,le){e.onUpdate({fontByExtension:{...e.settings.fontByExtension,[X]:le}})}function s(){e.onUpdate({fontByExtension:{}})}const a=F(()=>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;",u=[["showAuthorship","appearance-show-authorship","Authorship colors"],["showComments","appearance-show-comments","Comments"],["showHighlights","appearance-show-highlights","Highlights"],["showNotes","appearance-show-notes","Notes (private)"]];function c(X,le){return["flex: 1;","padding: var(--tandem-space-2);","min-height: 24px;",`border: 2px solid ${X?"var(--tandem-accent)":"var(--tandem-border)"};`,"border-radius: var(--tandem-r-3);",`background: ${X?"var(--tandem-accent-bg)":"var(--tandem-surface)"};`,"cursor: pointer;","text-align: center;","font-size: 11px;",`color: ${X?"var(--tandem-accent-fg-strong)":"var(--tandem-fg-muted)"};`,`font-weight: ${X?600:400};`,"opacity: 1;","transition: border-color 0.15s, background 0.15s;"].join(" ")}const f=Ps(()=>e.settings.theme,["light","warm","dark","system"],X=>e.onUpdate({theme:X})),h=Ps(()=>e.settings.primaryTab,["chat","annotations"],X=>e.onUpdate({primaryTab:X})),p=Ps(()=>e.settings.textSize,["s","m","l"],X=>e.onUpdate({textSize:X})),m=Ps(()=>e.settings.editorFont,["sans","serif","mono"],X=>e.onUpdate({editorFont:X})),v=Ps(()=>e.settings.density,["compact","cozy","spacious"],X=>e.onUpdate({density:X})),g={};for(const X of n)g[X.format]=Ps(()=>i(X.format),["sans","serif","mono"],le=>o(X.format,le));var b=JP(),x=Se(b),_=w(x);xe(_,l);var T=k(_,2);Je(T,20,()=>["light","warm","dark","system"],X=>X,(X,le)=>{var he=UP(),De=w(he);q((Oe,be)=>{U(he,"data-testid",`theme-${le}-btn`),U(he,"aria-checked",e.settings.theme===le),U(he,"tabindex",Oe),xe(he,be),ee(De,le==="light"?"Light":le==="warm"?"Warm":le==="dark"?"Dark":"System")},[()=>f.tabIndexFor(le),()=>c(e.settings.theme===le)]),N("click",he,()=>e.onUpdate({theme:le})),C(X,he)});var S=k(x,2),z=w(S);xe(z,l);var E=k(z,2),D=w(E),P=k(D,2),R=k(S,2),H=w(R);xe(H,l);var Q=k(H,2);Je(Q,20,()=>["s","m","l"],X=>X,(X,le)=>{var he=jP(),De=w(he);q((Oe,be)=>{U(he,"data-testid",`text-size-${le}-btn`),U(he,"aria-checked",e.settings.textSize===le),U(he,"tabindex",Oe),xe(he,be),ee(De,le==="s"?"Small":le==="m"?"Medium":"Large")},[()=>p.tabIndexFor(le),()=>c(e.settings.textSize===le)]),N("click",he,()=>e.onUpdate({textSize:le})),C(X,he)});var Z=k(R,2),$=w(Z);xe($,l);var W=k($,2),te=k(w(W),2),ae=k(Z,2),re=w(ae);xe(re,l);var ue=k(re,2);Je(ue,20,()=>[["sans","Sans-serif"],["serif","Serif (Source Serif 4)"],["mono","Monospace"]],([X,le])=>X,(X,le)=>{var he=F(()=>Sd(le,2));let De=()=>d(he)[0],Oe=()=>d(he)[1];var be=qP(),Ne=w(be);q((Qe,Ae)=>{U(be,"data-testid",`editor-font-${De()}-btn`),U(be,"aria-checked",e.settings.editorFont===De()),U(be,"tabindex",Qe),xe(be,Ae),ee(Ne,Oe())},[()=>m.tabIndexFor(De()),()=>c(e.settings.editorFont===De())]),N("click",be,()=>e.onUpdate({editorFont:De()})),C(X,be)});var oe=k(ae,2),fe=w(oe),I=w(fe);xe(I,`${l} margin-bottom: 0;`);var O=k(I,2),A=k(fe,2);Je(A,21,()=>n,X=>X.format,(X,le)=>{var he=KP(),De=w(he),Oe=w(De),be=k(De,2);Je(be,21,()=>r,([Ne,Qe])=>Ne,(Ne,Qe)=>{var Ae=F(()=>Sd(d(Qe),2));let Me=()=>d(Ae)[0],Ze=()=>d(Ae)[1];var ut=WP(),it=w(ut);q((pe,Ie,pt)=>{U(ut,"data-testid",`font-by-extension-${d(le).format}-${Me()}`),U(ut,"aria-checked",pe),U(ut,"tabindex",Ie),xe(ut,pt),ee(it,Ze())},[()=>i(d(le).format)===Me(),()=>g[d(le).format].tabIndexFor(Me()),()=>c(i(d(le).format)===Me())]),N("click",ut,()=>o(d(le).format,Me())),C(Ne,ut)}),q(()=>{U(he,"data-testid",`font-by-extension-row-${d(le).format}`),ee(Oe,d(le).label),U(be,"aria-label",`Default font for ${d(le).label}`)}),N("keydown",be,function(...Ne){var Qe;(Qe=g[d(le).format].handleKeyDown)==null||Qe.apply(this,Ne)}),C(X,he)});var V=k(oe,2),L=w(V);xe(L,l);var J=k(L,2);Je(J,20,()=>[["compact","Compact"],["cozy","Cozy"],["spacious","Spacious"]],([X,le])=>X,(X,le)=>{var he=F(()=>Sd(le,2));let De=()=>d(he)[0],Oe=()=>d(he)[1];var be=GP(),Ne=w(be);q((Qe,Ae)=>{U(be,"data-testid",`density-${De()}-btn`),U(be,"aria-checked",e.settings.density===De()),U(be,"tabindex",Qe),xe(be,Ae),ee(Ne,Oe())},[()=>v.tabIndexFor(De()),()=>c(e.settings.density===De())]),N("click",be,()=>e.onUpdate({density:De()})),C(X,be)});var K=k(V,2),ne=w(K);xe(ne,l);var ye=k(ne,2);Je(ye,17,()=>u,([X,le,he])=>X,(X,le)=>{var he=F(()=>Sd(d(le),3));let De=()=>d(he)[0],Oe=()=>d(he)[1],be=()=>d(he)[2];var Ne=ZP(),Qe=w(Ne),Ae=k(Qe,2),Me=w(Ae);q(()=>{U(Ne,"data-testid",Oe()),Un(Qe,e.settings[De()]),ee(Me,be())}),N("change",Qe,Ze=>e.onUpdate({[De()]:Ze.target.checked,...e.settings.decorationsMuted?{decorationsMuted:!1}:{}})),C(X,Ne)});var ce=k(K,2),ve=w(ce),_e=w(ve),Y=k(ce,2),we=w(Y),se=w(we);q((X,le,he,De)=>{U(D,"aria-checked",e.settings.primaryTab==="chat"),U(D,"tabindex",X),xe(D,le),U(P,"aria-checked",e.settings.primaryTab==="annotations"),U(P,"tabindex",he),xe(P,De),xr(te,e.settings.accentHue),O.disabled=!d(a),xe(O,`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"};`),Un(_e,e.settings.reduceMotion),Un(se,e.settings.formattingBarVisible)},[()=>h.tabIndexFor("chat"),()=>c(e.settings.primaryTab==="chat"),()=>h.tabIndexFor("annotations"),()=>c(e.settings.primaryTab==="annotations")]),N("keydown",T,function(...X){var le;(le=f.handleKeyDown)==null||le.apply(this,X)}),N("keydown",E,function(...X){var le;(le=h.handleKeyDown)==null||le.apply(this,X)}),N("click",D,()=>e.onUpdate({primaryTab:"chat"})),N("click",P,()=>e.onUpdate({primaryTab:"annotations"})),N("keydown",Q,function(...X){var le;(le=p.handleKeyDown)==null||le.apply(this,X)}),N("input",te,X=>e.onUpdate({accentHue:Number(X.target.value)})),N("keydown",ue,function(...X){var le;(le=m.handleKeyDown)==null||le.apply(this,X)}),N("click",O,s),N("keydown",J,function(...X){var le;(le=v.handleKeyDown)==null||le.apply(this,X)}),N("change",_e,X=>e.onUpdate({reduceMotion:X.target.checked})),N("change",se,X=>e.onUpdate({formattingBarVisible:X.target.checked})),C(t,b),Be()}We(["keydown","click","input","change"]);var YP=M('<button type="button" role="radio"> </button>'),XP=M(`<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
|
|
98
|
+
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 w3(t,e){ze(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=Ps(()=>e.settings.editorMeasure,r.map(f=>f.value),f=>e.onUpdate({editorMeasure:f})),o=F(()=>{var f;return((f=r.find(h=>h.value===e.settings.editorMeasure))==null?void 0:f.hint)??""});var s=XP(),a=w(s);xe(a,n);var l=k(a,4);Je(l,21,()=>r,f=>f.value,(f,h)=>{const p=F(()=>e.settings.editorMeasure===d(h).value);var m=YP(),v=w(m);q(g=>{U(m,"aria-checked",d(p)),U(m,"tabindex",g),U(m,"data-testid",`editor-measure-${d(h).value}`),xe(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)"};`),ee(v,d(h).label)},[()=>i.tabIndexFor(d(h).value)]),N("click",m,()=>e.onUpdate({editorMeasure:d(h).value})),C(f,m)});var u=k(l,2),c=w(u);q(()=>ee(c,d(o))),N("keydown",l,function(...f){var h;(h=i.handleKeyDown)==null||h.apply(this,f)}),C(t,s),Be()}We(["keydown","click"]);var QP=M('<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 k3(t,e){const n=je(e,"defaultOpen",3,!1);var r=QP(),i=w(r),o=k(w(i)),s=k(i,2),a=w(s);rd(a,()=>e.children),q(()=>{U(r,"data-testid",e.testid),r.open=n(),U(i,"data-testid",e.testid?`${e.testid}-toggle`:void 0),ee(o,` ${e.label??""}`)}),C(t,r)}var $P=M('<span style="color: var(--tandem-fg-subtle);"> </span>'),e7=M('<button type="button" data-testid="network-restart-sidecar"> </button>'),t7=M('<span style="font-size: 10px; color: var(--tandem-fg-subtle);">Run <code>tandem stop && tandem start</code> to restart</span>'),n7=M('<div style="font-size: 10px; color: var(--tandem-error-fg); margin-top: var(--tandem-space-1);"> </div>'),r7=M("<span><strong>Host:</strong> </span>"),i7=M('<div><div>Loopback Port</div> <div style="padding: var(--tandem-space-2) var(--tandem-space-3); border: 1px solid var(--tandem-border); border-radius: var(--tandem-r-3); background: var(--tandem-surface-muted); font-size: 13px; color: var(--tandem-fg-subtle); display: inline-block;"> </div> <div>Port used when transport is HTTP. To change, run <code>tandem start --port <N></code>.</div></div>'),o7=M("<option> </option>"),s7=M('<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>'),a7=M('<!> <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),l7=M('<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 x3(t,e){ze(e,!0);const n=jp(()=>e.open),r=Lt();let i=B(null),o=B(!1);async function s(){if(r){y(o,!0),y(i,null);try{const{invoke:I}=await Mn(async()=>{const{invoke:O}=await import("./core-DhEqZVGG.js");return{invoke:O}},[]);await I("restart_sidecar")}catch(I){y(i,I instanceof Error?I.message:String(I),!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;",u="display: flex; align-items: center; gap: var(--tandem-space-2); cursor: pointer; font-size: 12px; color: var(--tandem-fg); min-height: 24px;",c="font-size: 10px; color: var(--tandem-fg-subtle); margin-top: var(--tandem-space-1);",f=F(()=>{var I;return(I=n.info)==null?void 0:I.transport}),h=F(()=>{var I;return(I=n.info)==null?void 0:I.bindHost}),p=F(()=>{var I;return(I=n.info)==null?void 0:I.bindPort}),m=F(()=>d(f)==="http"),v=F(()=>{var I;return(I=n.info)==null?void 0:I.tokenRotatedAt});var g=l7(),b=Se(g),x=w(b);xe(x,l);var _=k(x,2),T=w(_),S=k(T,2),z=w(S),E=k(z);{var D=I=>{var O=$P(),A=w(O);q(()=>ee(A,`· ${e.reconnectAttempts??""} retry attempt${e.reconnectAttempts===1?"":"s"}`)),C(I,O)};G(E,I=>{e.reconnectAttempts>0&&I(D)})}var P=k(S,2);{var R=I=>{var O=e7(),A=w(O);q(()=>{O.disabled=d(o),xe(O,`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};`),ee(A,d(o)?"Restarting…":"Restart sidecar")}),N("click",O,s),C(I,O)},H=I=>{var O=t7();C(I,O)};G(P,I=>{r?I(R):I(H,-1)})}var Q=k(_,2);{var Z=I=>{var O=n7(),A=w(O);q(()=>ee(A,d(i))),C(I,O)};G(Q,I=>{d(i)&&I(Z)})}var $=k(b,2),W=w($);xe(W,l);var te=k(W,2),ae=w(te),re=k(w(ae)),ue=k(ae,2);{var oe=I=>{var O=r7(),A=k(w(O));q(()=>ee(A,` ${d(h)??""}`)),C(I,O)};G(ue,I=>{d(h)&&I(oe)})}var fe=k($,2);k3(fe,{label:"Advanced",testid:"network-advanced",children:(I,O)=>{var A=a7(),V=Se(A);{var L=Oe=>{var be=i7(),Ne=w(be);xe(Ne,l);var Qe=k(Ne,2),Ae=w(Qe),Me=k(Qe,2);xe(Me,c),q(()=>ee(Ae,d(p)??"—")),C(Oe,be)};G(V,Oe=>{d(m)&&Oe(L)})}var J=k(V,2),K=w(J);xe(K,l);var ne=k(w(K)),ye=w(ne),ce=k(K,2),ve=k(J,2),_e=w(ve);xe(_e,l);var Y=k(_e,2);Je(Y,21,()=>a,Oe=>Oe.value,(Oe,be)=>{var Ne=o7(),Qe=w(Ne),Ae={};q(()=>{ee(Qe,d(be).label),Ae!==(Ae=d(be).value)&&(Ne.value=(Ne.__value=d(be).value)??"")}),C(Oe,Ne)});var we;Wv(Y);var se=k(ve,2);xe(se,u);var X=w(se),le=k(se,2);xe(le,c);var he=k(le,2);{var De=Oe=>{var be=s7(),Ne=w(be);xe(Ne,l);var Qe=k(Ne,2),Ae=w(Qe),Me=k(Qe,2);xe(Me,c),q(Ze=>ee(Ae,Ze),[()=>d(v)===null?"Auth token not yet created":`Last rotated: ${new Date(d(v)).toLocaleString()}`]),C(Oe,be)};G(he,Oe=>{d(v)!==void 0&&Oe(De)})}q(()=>{ee(ye,`${e.settings.degradedBannerDelayMs/1e3}s`),xr(ce,e.settings.degradedBannerDelayMs),we!==(we=e.settings.sidecarRetryStrategy)&&(Y.value=(Y.__value=e.settings.sidecarRetryStrategy)??"",wp(Y,e.settings.sidecarRetryStrategy)),Un(X,e.settings.holdAnnotationsWhileOffline)}),N("input",ce,Oe=>e.onUpdate({degradedBannerDelayMs:Number(Oe.target.value)})),N("change",Y,Oe=>e.onUpdate({sidecarRetryStrategy:Oe.target.value})),N("change",X,Oe=>e.onUpdate({holdAnnotationsWhileOffline:Oe.target.checked})),C(I,A)},$$slots:{default:!0}}),q(I=>{xe(T,`width: 8px; height: 8px; border-radius: var(--tandem-r-circle); background: ${e.connected?"var(--tandem-success)":"var(--tandem-error)"}; flex-shrink: 0;`),ee(z,`${e.connected?"Connected to Tandem server":"Disconnected"} `),ee(re,` ${I??""}`)},[()=>d(f)?d(f).toUpperCase():"—"]),C(t,g),Be()}We(["click","input","change"]);const u7="INVALID_BODY",c7="PATH_REJECTED",d7="LAUNCHER_IN_PROGRESS",f7="LAUNCHER_NOT_AVAILABLE",h7="NO_CLAUDE_INTEGRATION";var p7=M('<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>'),m7=M('<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>'),g7=M('<div role="alert" style="font-size: 11px; color: var(--tandem-error-fg);"> </div>'),v7=M('<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>'),b7=M('<div data-testid="settings-modal-cowork-suspense-fallback" style="font-size: 12px; color: var(--tandem-fg-subtle);">Loading Cowork integration...</div>'),y7=M(`<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
|
|
99
|
+
Claude Desktop) is the default integration — auto-configured, tested, and the only client whose
|
|
100
|
+
channel-push, cowork, and auto-launch extras are validated today. Other clients can connect
|
|
101
|
+
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 w7(t,e){ze(e,!0);function n(O){switch(O){case c7:return"Working directory must be a folder inside your home directory.";case u7:return"Working directory path is invalid.";case d7:return"Another working-directory update is in progress. Try again.";case h7:return"No Claude Code integration is configured.";case f7: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=B(null),o=B(!1),s=B(null),a=B(!1),l=B(!1),u=B(null),c=!0;lr(()=>{c=!1});async function f(){var O;try{const A=await fetch(`${qn}/api/integrations`);if(!c)return;if(!A.ok){y(u,`Failed to load integrations (HTTP ${A.status}).`);return}const V=await A.json();if(!c)return;const L=(O=V.integrations)==null?void 0:O.find(J=>J.kind==="claude-code");L&&(y(l,!0),y(i,L.workingDirectory??null,!0))}catch(A){if(!c)return;console.warn("[Settings] Failed to load workingDirectory:",A),y(u,"Couldn't load Claude working directory.")}finally{c&&y(a,!0)}}f();async function h(O){y(o,!0),y(s,null);try{const A=await fetch(`${qn}${uM}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workingDirectory:O})});if(!c)return;if(!A.ok){const L=await A.json().catch(()=>({}));if(!c)return;y(s,n(L.code),!0);return}const V=await A.json();if(!c)return;y(i,V.workingDirectory??null,!0),e.notify("info","Working directory saved.")}catch(A){if(!c)return;console.warn("[Settings] Failed to save workingDirectory:",A),y(s,"Couldn't save working directory.")}finally{c&&y(o,!1)}}async function p(){let O;try{({open:O}=await Mn(()=>import("./index-Dm_QtxGQ.js"),__vite__mapDeps([0,1])))}catch(A){console.warn("[Settings] Folder picker import failed:",A),e.notify("error","Folder picker plugin unavailable");return}try{const A=await O({directory:!0,multiple:!1,title:"Choose Claude working directory"});typeof A=="string"&&h(A)}catch(A){console.warn("[Settings] Folder picker open() failed:",A),e.notify("error","Folder picker permission denied or IPC error")}}function m(O){O.preventDefault();const A=O.target.elements.namedItem("wd"),V=A==null?void 0:A.value.trim();h(V||null)}function v(){h(null)}var g=y7(),b=k(Se(g),2),x=w(b),_=k(w(x)),T=w(_),S=k(x,4);U(S,"step",100);var z=k(S,2),E=w(z),D=w(E),P=k(E,2),R=w(P),H=k(b,2),Q=w(H),Z=k(H,2),$=w(Z),W=k(Z,4);{var te=O=>{var A=p7(),V=w(A);q(()=>ee(V,d(u))),C(O,A)};G(W,O=>{d(a)&&!d(l)&&d(u)&&O(te)})}var ae=k(W,2);{var re=O=>{var A=v7(),V=k(w(A),4),L=w(V);U(L,"placeholder","(default: home)");var J=k(L,2),K=k(V,2),ne=w(K);{var ye=we=>{var se=m7();q(()=>se.disabled=d(o)),N("click",se,p),C(we,se)},ce=F(()=>Lt());G(ne,we=>{d(ce)&&we(ye)})}var ve=k(ne,2),_e=k(K,2);{var Y=we=>{var se=g7(),X=w(se);q(()=>ee(X,d(s))),C(we,se)};G(_e,we=>{d(s)&&we(Y)})}q(()=>{xr(L,d(i)??""),L.disabled=d(o),J.disabled=d(o),ve.disabled=d(o)||d(i)===null}),rn("submit",V,m),N("click",ve,v),C(O,A)};G(ae,O=>{d(a)&&d(l)&&O(re)})}var ue=k(ae,2),oe=k(ue,2);{var fe=O=>{var A=kt(),V=Se(A);s_(V,()=>Mn(()=>import("./CoworkSettings-BEvEpByR.js"),__vite__mapDeps([2,3])),L=>{var J=b7();C(L,J)},(L,J)=>{const K=F(()=>d(J).default);var ne=kt(),ye=Se(ne);qv(ye,()=>d(K),(ce,ve)=>{ve(ce,{})}),C(L,ne)}),C(O,A)},I=F(()=>Lt());G(oe,O=>{d(I)&&O(fe)})}q((O,A,V)=>{ee(T,`${O??""}s`),U(S,"min",Dl),U(S,"max",Ol),xr(S,e.settings.selectionDwellMs),ee(D,`${A??""}s`),ee(R,`${V??""}s`),Un(Q,e.settings.selectionToolbar),Un($,e.settings.marginView)},[()=>(e.settings.selectionDwellMs/1e3).toFixed(1),()=>(Dl/1e3).toFixed(1),()=>(Ol/1e3).toFixed(1)]),N("input",S,O=>e.onUpdate({selectionDwellMs:Number(O.target.value)})),N("change",Q,O=>e.onUpdate({selectionToolbar:O.target.checked})),N("change",$,O=>e.onUpdate({marginView:O.target.checked})),N("click",ue,r),C(t,g),Be()}We(["input","change","click"]);function Pb(t){const e=t==null?void 0:t.trim();return e?e.slice(0,xp):E_}function Lb(){try{return Pb(localStorage.getItem(Xv))}catch{return E_}}function k7(t){const e=Pb(t);try{localStorage.setItem(Xv,e)}catch{}return typeof window<"u"&&window.dispatchEvent(new Event(f0)),e}function _3(t){const e=()=>t(Lb()),n=r=>{r.key===Xv&&t(Pb(r.newValue))};return window.addEventListener(f0,e),window.addEventListener("storage",n),()=>{window.removeEventListener(f0,e),window.removeEventListener("storage",n)}}function Fb(){let t=B(Ge(Lb()));const e=_3(r=>{y(t,r,!0)});return lr(e),{get userName(){return d(t)},setUserName:r=>{const i=k7(r);y(t,i,!0)}}}var x7=M(`<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
|
|
102
|
+
restores when you return to Tandem.</div>`,1);function _7(t,e){ze(e,!0);const n=Fb();let r=B(Ge(n.userName)),i=B(void 0);me(()=>{const m=n.userName;d(r)!==m&&document.activeElement!==d(i)&&y(r,m,!0)});var o=x7(),s=Se(o),a=k(w(s),2);xt(a,m=>y(i,m),()=>d(i));var l=k(s,2),u=k(w(l),2),c=w(u),f=k(c,2),h=k(l,2),p=w(h);q(()=>{xr(a,d(r)),U(a,"maxlength",xp),U(c,"aria-checked",e.settings.defaultMode==="tandem"),U(f,"aria-checked",e.settings.defaultMode==="solo"),Un(p,e.settings.soloRailHidden)}),N("input",a,m=>{y(r,m.target.value,!0)}),rn("blur",a,()=>n.setUserName(d(r))),N("keydown",a,m=>{m.key==="Enter"&&m.currentTarget.blur(),m.key==="Escape"&&(y(r,n.userName,!0),m.currentTarget.blur())}),N("click",c,()=>e.onUpdate({defaultMode:"tandem"})),N("click",f,()=>e.onUpdate({defaultMode:"solo"})),N("change",p,m=>e.onUpdate({soloRailHidden:m.target.checked})),C(t,o),Be()}We(["input","keydown","click","change"]);var C7=M("<option> </option>"),S7=M('<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>'),E7=M('<input data-testid="model-edit-apikey" class="mem-input mem-input--mono svelte-1pwv6ag" type="password" autocomplete="off"/>'),A7=M('<label class="mem-field svelte-1pwv6ag"><span class="mem-label svelte-1pwv6ag">API key</span> <!></label>'),T7=M('<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>'),M7=M('<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>'),D7=M('<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 O7(t,e){ze(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=St(()=>e.entry);let i=B(Ge((r==null?void 0:r.provider)??"anthropic")),o=B(Ge((r==null?void 0:r.displayName)??"")),s=B(Ge((r==null?void 0:r.modelId)??"")),a=B(Ge((r==null?void 0:r.endpoint)??"")),l=B(Ge((r==null?void 0:r.enabled)??!0)),u=B("");const c=r!==void 0&&!!r.apiKeyRef;let f=B(Ge(r===void 0||!c));const h=r!==void 0,p=F(()=>d(i)==="anthropic"||d(i)==="openai"||d(i)==="gemini"),m=F(()=>d(i).startsWith("local-")),v=r!=null&&r.apiKeyRef?r.apiKeyRef.slice(-4):"",g=F(()=>d(o).trim().length>0&&d(s).trim().length>0&&(!d(p)||!d(f)||d(u).trim().length>0));function b(L){if(L.preventDefault(),!d(g))return;const J={provider:d(i),displayName:d(o).trim(),modelId:d(s).trim(),enabled:d(l)};d(p)&&d(f)&&d(u).trim()&&(J.plaintextApiKey=d(u).trim()),d(m)&&d(a).trim()&&(J.endpoint=d(a).trim()),e.onSave(J)}function x(){y(f,!0),y(u,"")}var _=D7();U(_,"tabindex",-1);var T=w(_),S=w(T),z=w(S),E=w(z),D=k(z,2),P=k(S,2),R=k(w(P),2);Je(R,21,()=>n,L=>L.value,(L,J)=>{var K=C7(),ne=w(K),ye={};q(()=>{ee(ne,d(J).label),ye!==(ye=d(J).value)&&(K.value=(K.__value=d(J).value)??"")}),C(L,K)});var H=k(P,2),Q=k(w(H),2),Z=k(H,2),$=k(w(Z),2),W=k(Z,2);{var te=L=>{var J=A7(),K=k(w(J),2);{var ne=ce=>{var ve=S7(),_e=w(ve),Y=w(_e),we=k(_e,2);q(()=>ee(Y,`••••••••${v??""}`)),N("click",we,x),C(ce,ve)},ye=ce=>{var ve=E7();q(()=>U(ve,"placeholder",h?"Enter new key":"Paste your API key")),Bn(ve,()=>d(u),_e=>y(u,_e)),C(ce,ve)};G(K,ce=>{h&&(r!=null&&r.apiKeyRef)&&!d(f)?ce(ne):ce(ye,-1)})}C(L,J)};G(W,L=>{d(p)&&L(te)})}var ae=k(W,2);{var re=L=>{var J=T7(),K=k(w(J),2);Bn(K,()=>d(a),ne=>y(a,ne)),C(L,J)};G(ae,L=>{d(m)&&L(re)})}var ue=k(ae,2),oe=w(ue),fe=k(ue,2);k3(fe,{label:"Advanced parameters",testid:"model-edit-advanced",children:(L,J)=>{var K=M7();C(L,K)},$$slots:{default:!0}});var I=k(fe,2),O=w(I),A=k(O,2),V=w(A);q(()=>{U(_,"aria-label",h?"Edit model":"Add model"),ee(E,h?"Edit model":"Add model"),A.disabled=!d(g),ee(V,h?"Save changes":"Add model")}),N("click",_,L=>{L.target===L.currentTarget&&e.onCancel()}),N("keydown",_,L=>{L.key==="Escape"&&e.onCancel()}),rn("submit",T,b),N("click",D,function(...L){var J;(J=e.onCancel)==null||J.apply(this,L)}),o6(R,()=>d(i),L=>y(i,L)),Bn(Q,()=>d(o),L=>y(o,L)),Bn($,()=>d(s),L=>y(s,L)),gf(oe,()=>d(l),L=>y(l,L)),N("click",O,function(...L){var J;(J=e.onCancel)==null||J.apply(this,L)}),C(t,_),Be()}We(["click","keydown"]);var I7=M('<span data-testid="models-legacy-migration-status"> </span>'),R7=M(`<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
|
|
103
|
+
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>`),N7=M('<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>'),P7=M('<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),L7=M('<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>'),F7=M('<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>'),z7=M('<div><div class="settings-section-label"> </div> <div style="display: flex; flex-direction: column; gap: 4px;"></div></div>'),B7=M('<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),H7=M('<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>'),V7=M('<div style="display: flex; flex-direction: column; gap: var(--tandem-space-3);"><!> <!></div> <!> <!>',1);function U7(t,e){ze(e,!0);const n=ab(),r=zC(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=F(()=>{const Z=new Map;for(const $ of o)Z.set($,[]);for(const $ of r.models){const W=Z.get($.provider);W&&W.push($)}return Z});let a=B(void 0),l=B(!1),u=B(null),c=B(null),f=B(!1),h=B(null);function p(){y(a,void 0),y(c,null),y(l,!0)}function m(Z){y(a,Z,!0),y(c,null),y(l,!0)}async function v(Z){const{plaintextApiKey:$,...W}=Z;try{d(a)?await r.updateModel(d(a).id,W,$):await r.addModel(W,$),y(l,!1),y(a,void 0),y(c,null)}catch(te){y(c,te instanceof Error?te.message:"Failed to save",!0)}}async function g(Z){await r.deleteModel(Z),y(u,null)}async function b(){y(f,!0),y(h,null);try{const Z=await r.migrateLegacyKeys();Z.failed>0?y(h,`Migrated ${Z.migrated}; ${Z.failed} failed. Retry?`):Z.migrated>0&&y(h,`Migrated ${Z.migrated} ${Z.migrated===1?"key":"keys"} to OS keychain.`)}finally{y(f,!1)}}var x=V7(),_=Se(x),T=w(_);{var S=Z=>{var $=R7(),W=k(w($),2),te=w(W),ae=w(te),re=k(te,2);{var ue=oe=>{var fe=I7(),I=w(fe);q(()=>ee(I,d(h))),C(oe,fe)};G(re,oe=>{d(h)&&oe(ue)})}q(()=>{te.disabled=d(f),xe(te,`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"};`),ee(ae,d(f)?"Migrating…":"Migrate keys")}),N("click",te,b),C(Z,$)};G(T,Z=>{r.hasLegacyKeys&&Z(S)})}var z=k(T,2);{var E=Z=>{var $=N7(),W=k(w($),2);N("click",W,p),C(Z,$)},D=Z=>{var $=B7(),W=Se($);Je(W,20,()=>o,ae=>ae,(ae,re)=>{const ue=F(()=>d(s).get(re)??[]);var oe=kt(),fe=Se(oe);{var I=O=>{var A=z7(),V=w(A),L=w(V),J=k(V,2);Je(J,21,()=>d(ue),K=>K.id,(K,ne)=>{var ye=F7(),ce=w(ye),ve=w(ce),_e=w(ve),Y=k(ve,2),we=w(Y),se=k(ce,2),X=w(se),le=k(se,2),he=w(le),De=k(he,2),Oe=w(De),be=k(le,2),Ne=k(be,2);{var Qe=Me=>{var Ze=P7(),ut=Se(Ze),it=k(ut,2);q(()=>U(ut,"data-testid",`model-delete-confirm-${d(ne).id}`)),N("click",ut,()=>g(d(ne).id)),N("click",it,()=>y(u,null)),C(Me,Ze)},Ae=Me=>{var Ze=L7();q(()=>U(Ze,"data-testid",`model-delete-btn-${d(ne).id}`)),N("click",Ze,()=>y(u,d(ne).id,!0)),C(Me,Ze)};G(Ne,Me=>{d(u)===d(ne).id?Me(Qe):Me(Ae,-1)})}q(()=>{U(ye,"data-testid",`model-row-${d(ne).id}`),ee(_e,d(ne).displayName),ee(we,d(ne).modelId),U(X,"data-testid",`model-default-${d(ne).id}`),Un(X,r.defaultModelId===d(ne).id),U(he,"data-testid",`model-toggle-${d(ne).id}`),Un(he,d(ne).enabled),ee(Oe,d(ne).enabled?"On":"Off"),U(be,"data-testid",`model-edit-btn-${d(ne).id}`)}),N("change",X,()=>r.setDefault(d(ne).id)),N("change",he,()=>r.toggleEnabled(d(ne).id)),N("click",be,()=>m(d(ne))),C(K,ye)}),q(()=>ee(L,i[re])),C(O,A)};G(fe,O=>{d(ue).length>0&&O(I)})}C(ae,oe)});var te=k(W,2);N("click",te,p),C(Z,$)};G(z,Z=>{r.models.length===0?Z(E):Z(D,-1)})}var P=k(_,2);{var R=Z=>{var $=H7(),W=w($);q(()=>ee(W,d(c))),C(Z,$)};G(P,Z=>{d(c)&&Z(R)})}var H=k(P,2);{var Q=Z=>{O7(Z,{get entry(){return d(a)},onCancel:()=>{y(l,!1),y(a,void 0),y(c,null)},onSave:v})};G(H,Z=>{d(l)&&Z(Q)})}C(t,x),Be()}We(["click","change"]);var j7=M('<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>'),q7=M('<span style="justify-self: start; font-size: 11px; color: var(--tandem-accent-fg-strong); font-style: italic;">Press keys… (Esc to cancel)</span>'),W7=M("<kbd> </kbd>"),K7=M('<button type="button">Reset</button>'),G7=M('<div style="grid-column: 1 / -1; font-size: 11px; color: var(--tandem-error-fg);"> </div>'),Z7=M('<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>'),J7=M('<kbd> </kbd> <span style="font-size: 13px; color: var(--tandem-fg-muted);"> </span>',1),Y7=M('<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>'),X7=M('<kbd> </kbd> <span style="font-size: 13px; color: var(--tandem-fg-muted);"> </span>',1),Q7=M('<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 C3(t,e){ze(e,!0);let n=je(e,"notify",3,()=>{}),r=B(null),i=B(null);const o=F(()=>e.settings._readOnly===!0),s=F(()=>U_(e.settings.customShortcuts));me(()=>{if(d(r)===null)return;const E=d(r),D=P=>{if(P.preventDefault(),P.stopPropagation(),P.key==="Escape"){y(r,null),y(i,null);return}const R=qM(P);if(!R)return;const H=$M(R,d(s),E);if(H){y(i,{id:E,message:`Already used by ${H}`},!0);return}y(r,null),y(i,null),e.onUpdate({customShortcuts:{...e.settings.customShortcuts,[E]:R}}),n()("info",`${v0[E]} set to ${b0(R)}`)};return window.addEventListener("keydown",D,{capture:!0}),()=>window.removeEventListener("keydown",D,{capture:!0})});function a(E){d(o)||(y(i,null),y(r,E,!0))}function l(E){var R;if(d(o))return;const{[E]:D,...P}=e.settings.customShortcuts;e.onUpdate({customShortcuts:P}),d(r)===E&&y(r,null),((R=d(i))==null?void 0:R.id)===E&&y(i,null)}function u(){d(o)||(e.onUpdate({customShortcuts:{}}),y(r,null),y(i,null))}const c=F(()=>ha.some(E=>d(s).has(E))),f=F(()=>{const E=Zf(),D=new Map;for(const P of E.values()){if(!P.shortcut||z_[P.id])continue;const R=D.get(P.group)??[];R.push({keys:P.shortcut,description:P.label}),D.set(P.group,R)}return I_.map(P=>({title:P.charAt(0).toUpperCase()+P.slice(1),rows:D.get(P)??[]})).filter(P=>P.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=Q7(),m=w(p),v=w(m),g=k(w(v),2),b=k(v,2);{var x=E=>{var D=j7();C(E,D)};G(b,E=>{d(o)&&E(x)})}var _=k(b,2);Je(_,20,()=>ha,E=>E,(E,D)=>{const P=F(()=>d(r)===D),R=F(()=>d(s).has(D)),H=F(()=>b0(Qv(D,d(s))));var Q=Z7(),Z=w(Q),$=w(Z),W=k(Z,2);{var te=V=>{var L=q7();q(()=>U(L,"data-testid",`shortcut-recording-${D}`)),C(V,L)},ae=V=>{var L=W7();xe(L,h);var J=w(L);q(()=>ee(J,d(H))),C(V,L)};G(W,V=>{d(P)?V(te):V(ae,-1)})}var re=k(W,2),ue=w(re),oe=w(ue),fe=k(ue,2);{var I=V=>{var L=K7();q(()=>{U(L,"data-testid",`shortcut-reset-${D}`),L.disabled=d(o),xe(L,`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};`)}),N("click",L,()=>l(D)),C(V,L)};G(fe,V=>{d(R)&&V(I)})}var O=k(re,2);{var A=V=>{var L=G7(),J=w(L);q(()=>{U(L,"data-testid",`shortcut-conflict-${D}`),ee(J,d(i).message)}),C(V,L)};G(O,V=>{d(i)&&d(i).id===D&&V(A)})}q(()=>{U(Q,"data-testid",`shortcut-row-${D}`),ee($,v0[D]),U(ue,"data-testid",`shortcut-edit-${D}`),ue.disabled=d(o),xe(ue,`font-size: 11px; padding: 2px 8px; border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-2); background: ${d(P)?"var(--tandem-accent-bg)":"var(--tandem-surface)"}; color: var(--tandem-fg); cursor: ${d(o)?"not-allowed":"pointer"}; opacity: ${d(o)?.5:1};`),ee(oe,d(P)?"Recording…":"Change")}),N("click",ue,()=>a(D)),C(E,Q)});var T=k(m,2);Je(T,17,()=>d(f),E=>E.title,(E,D)=>{var P=Y7(),R=w(P),H=w(R),Q=k(R,2);Je(Q,21,()=>d(D).rows,Z=>Z.keys+Z.description,(Z,$)=>{var W=J7(),te=Se(W);xe(te,h);var ae=w(te),re=k(te,2),ue=w(re);q(()=>{ee(ae,d($).keys),ee(ue,d($).description)}),C(Z,W)}),q(()=>ee(H,`${d(D).title??""} (fixed)`)),C(E,P)});var S=k(T,2),z=k(w(S),2);Je(z,21,()=>nh,E=>E.keys+E.description,(E,D)=>{var P=X7(),R=Se(P);xe(R,h);var H=w(R),Q=k(R,2),Z=w(Q);q(()=>{ee(H,d(D).keys),ee(Z,d(D).description)}),C(E,P)}),q(()=>{g.disabled=d(o)||!d(c),xe(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(c)?"not-allowed":"pointer"}; opacity: ${d(o)||!d(c)?.5:1};`)}),N("click",g,u),C(t,p),Be()}We(["click"]);var $7=M('<div data-testid="settings-modal-shortcuts-list"><!></div>');function eL(t,e){var n=$7(),r=w(n);C3(r,{get settings(){return e.settings},get onUpdate(){return e.onUpdate},get notify(){return e.notify}}),C(t,n)}var tL=M('<div style="margin-top: 6px; font-size: 11px; color: var(--tandem-error-fg);"> </div>'),nL=M('<div style="font-size: 11px; color: var(--tandem-fg-subtle);">Loading...</div>'),rL=M('<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),iL=M('<dl style="display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 5px 14px; margin: 0; font-size: 11px;"></dl>'),oL=M('<div style="font-size: 11px; color: var(--tandem-fg-subtle);">App info unavailable.</div>'),sL=M('<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 aL(t,e){ze(e,!0);const n=jp(()=>e.open);let r=B(!1),i=B(null);async function o(){var T;const x=(T=n.info)==null?void 0:T.workflowsPath;if(!x){y(i,"Documentation file not found.");return}y(r,!0),y(i,null);const _=await Po(x,{readOnly:!0,notFoundMessage:"Documentation file not found.",failureMessage:"Failed to open documentation."});y(r,!1),_.ok||y(i,_.error,!0)}const s=F(()=>{var T;const x=n.info;if(!x)return[];const _=[{label:"Version",value:`Tandem v${x.version}`},{label:"Tools",value:x.toolCount===null?"Tool count unavailable":`${x.toolCount} tools available`},{label:"MCP SDK",value:`MCP SDK ${x.mcpSdkVersion}`},{label:"Transport",value:((T=x.transport)==null?void 0:T.toUpperCase())??"—"}];return x.storagePath&&_.push({label:"Storage",value:x.storagePath}),x.tokenRotatedAt!==void 0&&_.push({label:"Token",value:x.tokenRotatedAt===null?"Token not created":`Token rotated ${new Date(x.tokenRotatedAt).toLocaleString()}`}),x.changelogPath&&_.push({label:"Changelog",value:x.changelogPath}),_});var a=sL(),l=Se(a),u=w(l),c=w(u),f=k(u,2);{var h=x=>{var _=tL(),T=w(_);q(()=>ee(T,d(i))),C(x,_)};G(f,x=>{d(i)&&x(h)})}var p=k(l,2),m=k(w(p),2);{var v=x=>{var _=nL();C(x,_)},g=x=>{var _=iL();Je(_,21,()=>d(s),T=>T.label,(T,S)=>{var z=rL(),E=Se(z),D=w(E),P=k(E,2),R=w(P);q(()=>{ee(D,d(S).label),ee(R,d(S).value)}),C(T,z)}),C(x,_)},b=x=>{var _=oL();C(x,_)};G(m,x=>{n.loading?x(v):n.info?x(g,1):x(b,-1)})}q(()=>{u.disabled=d(r)||n.loading,xe(u,`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};`),ee(c,d(r)?"Opening…":"View Documentation")}),N("click",u,()=>void o()),C(t,a),Be()}We(["click"]);const lL={models:"models"};var uL=M('<span class="settings-modal-version-chip svelte-bbu5nk" data-testid="settings-modal-sidebar-version"> </span>'),cL=M('<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>'),dL=M('<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>'),fL=M('<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 hL(t,e){ze(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:y3},{id:"editor",label:"Editor",icon:"M4 4h11M4 9h16M4 14h11M4 19h16",component:w3},{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:x3},{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:b3},{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:w7},{id:"models",label:"Models",icon:"M4 4h16v16H4V4Zm5-3v3M15 1v3M9 20v3M15 20v3M1 9h3M1 15h3M20 9h3M20 15h3M8 8h8v8H8V8Z",component:U7},{id:"shortcuts",label:"Shortcuts",icon:"M3 7h2v2H3V7Zm0 4h2v2H3v-2Zm0 4h2v2H3v-2Zm4-8h2v2H7V7Zm0 4h2v2H7v-2Zm0 4h10v2H7v-2Zm4-8h10v2H11V7Zm0 4h6v2h-6v-2Zm8 0h2v2h-2v-2Z",component:eL},{id:"about",label:"About",icon:"M12 3a9 9 0 1 0 0 18 9 9 0 0 0 0-18Zm0 4v6m0 4h.01",component:aL}];let o=je(e,"returnFocusEl",3,null),s=je(e,"triggerEl",3,null),a=je(e,"connected",3,!1),l=je(e,"reconnectAttempts",3,0),u=je(e,"tabs",3,i),c=je(e,"initialTabId",3,null),f=je(e,"notify",3,()=>{}),h=B(void 0);const p=jp(()=>e.open);let m=B(!1),v=B(null),g=B(!1);me(()=>{e.open&&y(g,!1)});let b=!1;me(()=>{if(e.open&&!b&&c()){const Z=d(_).find($=>$.id===c());Z&&y(T,Z.id,!0)}b=e.open});let x=B(!1);me(()=>{if(typeof window>"u"||!window.matchMedia)return;const Z=window.matchMedia("(max-width: 860px)");y(x,Z.matches,!0);const $=W=>{y(x,W.matches,!0)};return Z.addEventListener("change",$),()=>Z.removeEventListener("change",$)});const _=F(()=>u().length>0?u():i);let T=B(Ge(i[0].id));const S=F(()=>d(_).find(Z=>Z.id===d(T))??d(_)[0]),z=F(()=>d(S).label),E=F(()=>({open:e.open,settings:e.settings,onUpdate:e.onUpdate,connected:a(),reconnectAttempts:l(),notify:f()}));me(()=>{d(S)&&d(S).id!==d(T)&&y(T,d(S).id,!0)}),me(()=>{if(e.open)return St(()=>{var Z;return(Z=d(h))==null?void 0:Z.focus()}),()=>{var Z;(Z=o())==null||Z.focus()}}),me(()=>{if(!e.open)return;const Z=W=>{var ae;const te=W.target;te&&((ae=s())!=null&&ae.contains(te)||d(h)&&!d(h).contains(te)&&e.onClose())},$=setTimeout(()=>document.addEventListener("pointerdown",Z),0);return()=>{clearTimeout($),document.removeEventListener("pointerdown",Z)}}),Zl(()=>{const Z=$=>{if($.key!=="Escape"||!e.open)return;const W=$.target;if(!(!d(h)||!W||!d(h).contains(W))){if($.stopPropagation(),d(x)&&d(g)){y(g,!1);return}e.onClose()}};return document.addEventListener("keydown",Z),()=>document.removeEventListener("keydown",Z)}),me(()=>{if(!e.open)return;const Z=$=>{if($.key!=="Tab"||!d(h))return;const W=d(h).querySelectorAll(r);if(W.length===0)return;const te=W[0],ae=W[W.length-1],re=document.activeElement;if(!d(h).contains(re)){$.preventDefault(),te.focus();return}$.shiftKey&&re===te?($.preventDefault(),ae.focus()):!$.shiftKey&&re===ae&&($.preventDefault(),te.focus())};return window.addEventListener("keydown",Z),()=>window.removeEventListener("keydown",Z)}),me(()=>{d(T),y(v,null)});async function D(){var W;const Z=(W=p.info)==null?void 0:W.changelogPath;if(!Z){y(v,"Changelog file not found.");return}y(m,!0),y(v,null);const $=await Po(Z,{readOnly:!0,notFoundMessage:"Changelog file not found.",failureMessage:"Failed to open changelog."});y(m,!1),$.ok?e.onClose():y(v,$.error,!0)}var P={DEFAULT_SETTINGS_TABS:i},R=kt(),H=Se(R);{var Q=Z=>{var $=fL(),W=Se($),te=k(W,2);U(te,"aria-labelledby",n),U(te,"tabindex",-1);var ae=w(te),re=w(ae),ue=w(re);U(ue,"id",n);var oe=k(ue,2);{var fe=Ae=>{var Me=uL(),Ze=w(Me);q(()=>ee(Ze,`v${p.info.version??""}`)),C(Ae,Me)};G(oe,Ae=>{p.info&&Ae(fe)})}var I=k(re,2);Je(I,21,()=>d(_),Ae=>Ae.id,(Ae,Me)=>{var Ze=cL(),ut=w(Ze),it=w(ut),pe=k(ut,2),Ie=w(pe);q(()=>{U(Ze,"aria-current",d(T)===d(Me).id?"page":void 0),U(Ze,"data-active",d(T)===d(Me).id?"true":"false"),U(Ze,"data-testid",`settings-modal-tab-${d(Me).id}`),U(it,"d",d(Me).icon),ee(Ie,d(Me).label)}),N("click",Ze,()=>{y(T,d(Me).id,!0),y(g,!1)}),C(Ae,Ze)});var O=k(I,2),A=w(O),V=w(A),L=k(A,2);{var J=Ae=>{var Me=dL(),Ze=w(Me);q(()=>ee(Ze,d(v))),C(Ae,Me)};G(L,Ae=>{d(v)&&Ae(J)})}var K=k(L,2),ne=k(K,2),ye=w(ne),ce=k(ye,2),ve=w(ce);{var _e=Ae=>{var Me=or("MCP connected");C(Ae,Me)},Y=Ae=>{var Me=or("Reconnecting…");C(Ae,Me)},we=Ae=>{var Me=or("MCP offline");C(Ae,Me)};G(ve,Ae=>{a()?Ae(_e):l()>0?Ae(Y,1):Ae(we,-1)})}cr(ae,(Ae,Me)=>Ht==null?void 0:Ht(Ae,Me),()=>"y");var se=k(ae,2),X=w(se),le=w(X),he=k(le,2),De=w(he),Oe=k(he,2),be=k(X,2),Ne=w(be),Qe=w(Ne);Vf(Qe,()=>d(S).id,Ae=>{var Me=kt(),Ze=Se(Me);qv(Ze,()=>d(S).component,(ut,it)=>{it(ut,_u(()=>d(E)))}),C(Ae,Me)}),cr(be,(Ae,Me)=>Ht==null?void 0:Ht(Ae,Me),()=>"y"),xt(te,Ae=>y(h,Ae),()=>d(h)),q(()=>{U(te,"data-narrow-sidebar-open",d(g)?"true":"false"),ae.inert=d(x)&&!d(g),A.disabled=d(m)||p.loading,ee(V,d(m)?"Opening…":"Changelog"),U(K,"href",g_),U(ye,"data-state",a()?"connected":l()>0?"reconnecting":"disconnected"),U(le,"aria-label",d(g)?"Hide sections":"Show sections"),U(le,"aria-expanded",d(g)),ee(De,d(z))}),N("click",W,function(...Ae){var Me;(Me=e.onClose)==null||Me.apply(this,Ae)}),N("keydown",W,Ae=>{(Ae.key==="Enter"||Ae.key===" ")&&(Ae.preventDefault(),e.onClose())}),N("click",A,()=>void D()),N("click",le,()=>{y(g,!d(g))}),N("click",Oe,function(...Ae){var Me;(Me=e.onClose)==null||Me.apply(this,Ae)}),C(Z,$)};G(H,Z=>{e.open&&Z(Q)})}return C(t,R),Be(P)}We(["click","keydown"]);var pL=M('<span class="settings-version-chip svelte-fsutp8" data-testid="settings-sidebar-version"> </span>'),mL=M('<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>'),gL=M('<div role="alert" data-testid="changelog-error" style="font-size: 11px; color: var(--tandem-error-fg); padding: 0 var(--tandem-space-2);"> </div>'),vL=M(`<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
|
|
104
|
+
restores when you return to Tandem.</div>`,1),bL=M('<div data-testid="cowork-settings-suspense-fallback" style="font-size: 12px; color: var(--tandem-fg-subtle);">Loading Cowork integration...</div>'),yL=M('<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),wL=M('<div data-testid="settings-shortcuts-list"><!></div>'),kL=M('<div style="margin-top: 6px; font-size: 11px; color: var(--tandem-error-fg);"> </div>'),xL=M('<div style="font-size: 11px; color: var(--tandem-fg-subtle);">Loading...</div>'),_L=M('<dt style="color: var(--tandem-fg-subtle);"> </dt> <dd style="margin: 0; color: var(--tandem-fg-muted); overflow-wrap: anywhere;"> </dd>',1),CL=M('<dl style="display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 5px 12px; margin: 0; font-size: 11px;"></dl>'),SL=M('<div style="font-size: 11px; color: var(--tandem-fg-subtle);">App info unavailable.</div>'),EL=M('<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),AL=M('<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 TL(t,e){ze(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=je(e,"connected",3,!1),s=je(e,"reconnectAttempts",3,0),a=B(void 0),l=B(void 0);const u=Fb();let c=B(Ge(u.userName));const f=jp(()=>e.open);let h=B(!1),p=B(null),m=B(!1),v=B(null),g=B("appearance");me(()=>{d(g),y(p,null),y(v,null)}),me(()=>{const H=u.userName;d(c)!==H&&document.activeElement!==d(l)&&y(c,H,!0)}),me(()=>{var H;if(e.open)return(H=d(a))==null||H.focus(),()=>{var Q;(Q=e.returnFocusEl)==null||Q.focus()}}),me(()=>{if(!e.open)return;const H=Z=>{var W;const $=Z.target;(W=e.anchorEl)!=null&&W.contains($)||d(a)&&!d(a).contains($)&&e.onClose()},Q=setTimeout(()=>document.addEventListener("pointerdown",H),0);return()=>{clearTimeout(Q),document.removeEventListener("pointerdown",H)}}),me(()=>{if(!e.open)return;const H=Q=>{if(Q.key==="Escape"){Q.preventDefault(),Q.stopPropagation(),e.onClose();return}if(Q.key!=="Tab"||!d(a))return;const Z=d(a).querySelectorAll(r);if(Z.length===0)return;const $=Z[0],W=Z[Z.length-1],te=document.activeElement;if(!d(a).contains(te)){Q.preventDefault(),$.focus();return}Q.shiftKey&&te===$?(Q.preventDefault(),W.focus()):!Q.shiftKey&&te===W&&(Q.preventDefault(),$.focus())};return window.addEventListener("keydown",H,{capture:!0}),()=>window.removeEventListener("keydown",H,{capture:!0})});async function b(H,Q,Z,$){if(!H){Z($.notFound);return}Q(!0),Z(null);try{const W=await Po(H,{readOnly:!0,notFoundMessage:$.notFound,failureMessage:$.failed});if(!W.ok){Z(W.error);return}e.onClose()}finally{Q(!1)}}function x(){var H;return b((H=f.info)==null?void 0:H.workflowsPath,Q=>y(m,Q,!0),Q=>y(v,Q,!0),{notFound:"Documentation file not found.",failed:"Failed to open documentation."})}function _(){var H;return b((H=f.info)==null?void 0:H.changelogPath,Q=>y(h,Q,!0),Q=>y(p,Q,!0),{notFound:"Changelog file not found.",failed:"Failed to open changelog."})}const T="font-size: 11px; font-weight: 600; color: var(--tandem-fg); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px;",S=()=>{};function z(H){var Q;return((Q=i.find(Z=>Z.id===H))==null?void 0:Q.label)??"Settings"}function E(){var Z;const H=f.info;if(!H)return[];const Q=[{label:"Version",value:`Tandem v${H.version}`},{label:"Tools",value:H.toolCount===null?"Tool count unavailable":`${H.toolCount} tools available`},{label:"MCP SDK",value:`MCP SDK ${H.mcpSdkVersion}`},{label:"Transport",value:((Z=H.transport)==null?void 0:Z.toUpperCase())??"—"}];return H.storagePath&&Q.push({label:"Storage",value:H.storagePath}),H.tokenRotatedAt!==void 0&&Q.push({label:"Token",value:H.tokenRotatedAt===null?"Token not created":`Token rotated ${new Date(H.tokenRotatedAt).toLocaleString()}`}),H.changelogPath&&Q.push({label:"Changelog",value:H.changelogPath}),Q}var D=kt(),P=Se(D);{var R=H=>{var Q=AL(),Z=Se(Q),$=k(Z,2);U($,"aria-labelledby",n),U($,"tabindex",-1);var W=w($),te=w(W),ae=w(te);U(ae,"id",n);var re=k(ae,2);{var ue=pe=>{var Ie=pL(),pt=w(Ie);q(()=>ee(pt,`v${f.info.version??""}`)),C(pe,Ie)};G(re,pe=>{f.info&&pe(ue)})}var oe=k(te,2);Je(oe,21,()=>i,pe=>pe.id,(pe,Ie)=>{var pt=mL(),Pt=w(pt),Gt=w(Pt),Ke=k(Pt,2),Ve=w(Ke);q(()=>{U(pt,"aria-current",d(g)===d(Ie).id?"page":void 0),U(pt,"data-active",d(g)===d(Ie).id?"true":"false"),U(Gt,"d",d(Ie).icon),ee(Ve,d(Ie).label)}),N("click",pt,()=>y(g,d(Ie).id,!0)),C(pe,pt)});var fe=k(oe,2),I=w(fe),O=w(I),A=k(I,2);{var V=pe=>{var Ie=gL(),pt=w(Ie);q(()=>ee(pt,d(p))),C(pe,Ie)};G(A,pe=>{d(p)&&pe(V)})}var L=k(A,2),J=k(L,2),K=w(J),ne=k(K,2),ye=w(ne);{var ce=pe=>{var Ie=or("MCP connected");C(pe,Ie)},ve=pe=>{var Ie=or("Reconnecting…");C(pe,Ie)},_e=pe=>{var Ie=or("MCP offline");C(pe,Ie)};G(ye,pe=>{o()?pe(ce):s()>0?pe(ve,1):pe(_e,-1)})}var Y=k(W,2),we=w(Y),se=w(we),X=w(se),le=k(se,2),he=k(we,2),De=w(he),Oe=w(De);{var be=pe=>{var Ie=vL(),pt=Se(Ie),Pt=w(pt);xe(Pt,T);var Gt=k(Pt,2);xt(Gt,ot=>y(l,ot),()=>d(l));var Ke=k(pt,2),Ve=w(Ke);xe(Ve,T);var ct=k(Ve,2),ht=w(ct),$e=k(ht,2),mt=k(Ke,2),un=w(mt);q(()=>{xr(Gt,d(c)),U(Gt,"maxlength",xp),U(ht,"aria-checked",e.settings.defaultMode==="tandem"),xe(ht,`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;`),U($e,"aria-checked",e.settings.defaultMode==="solo"),xe($e,`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;`),Un(un,e.settings.soloRailHidden)}),N("input",Gt,ot=>{y(c,ot.target.value,!0)}),rn("blur",Gt,()=>u.setUserName(d(c))),N("keydown",Gt,ot=>{ot.key==="Enter"&&ot.currentTarget.blur(),ot.key==="Escape"&&(y(c,u.userName,!0),ot.currentTarget.blur())}),N("click",ht,()=>e.onUpdate({defaultMode:"tandem"})),N("click",$e,()=>e.onUpdate({defaultMode:"solo"})),N("change",un,ot=>e.onUpdate({soloRailHidden:ot.target.checked})),C(pe,Ie)},Ne=pe=>{y3(pe,{get open(){return e.open},get settings(){return e.settings},get onUpdate(){return e.onUpdate},get connected(){return o()},get reconnectAttempts(){return s()},notify:S})},Qe=pe=>{w3(pe,{get open(){return e.open},get settings(){return e.settings},get onUpdate(){return e.onUpdate},get connected(){return o()},get reconnectAttempts(){return s()},notify:S})},Ae=pe=>{x3(pe,{get open(){return e.open},get settings(){return e.settings},get onUpdate(){return e.onUpdate},get connected(){return o()},get reconnectAttempts(){return s()},notify:S})},Me=pe=>{b3(pe,{get open(){return e.open},get settings(){return e.settings},get onUpdate(){return e.onUpdate},get connected(){return o()},get reconnectAttempts(){return s()},notify:S})},Ze=pe=>{var Ie=yL(),pt=Se(Ie),Pt=w(pt);xe(Pt,T);var Gt=k(w(Pt)),Ke=w(Gt),Ve=k(Pt,4);U(Ve,"step",100);var ct=k(Ve,2),ht=w(ct),$e=w(ht),mt=k(ht,2),un=w(mt),ot=k(pt,2),yt=w(ot),$t=k(ot,2),Hr=w($t),di=k($t,4);{var Vr=gn=>{var Mi=kt(),Is=Se(Mi);s_(Is,()=>Mn(()=>import("./CoworkSettings-BEvEpByR.js"),__vite__mapDeps([2,3])),su=>{var j=bL();C(su,j)},(su,j)=>{const de=F(()=>d(j).default);var ke=kt(),Pe=Se(ke);qv(Pe,()=>d(de),(wt,Ft)=>{Ft(wt,{})}),C(su,ke)}),C(gn,Mi)},Ti=F(()=>Lt());G(di,gn=>{d(Ti)&&gn(Vr)})}q((gn,Mi,Is)=>{ee(Ke,`${gn??""}s`),U(Ve,"min",Dl),U(Ve,"max",Ol),xr(Ve,e.settings.selectionDwellMs),ee($e,`${Mi??""}s`),ee(un,`${Is??""}s`),Un(yt,e.settings.selectionToolbar),Un(Hr,e.settings.marginView)},[()=>(e.settings.selectionDwellMs/1e3).toFixed(1),()=>(Dl/1e3).toFixed(1),()=>(Ol/1e3).toFixed(1)]),N("input",Ve,gn=>e.onUpdate({selectionDwellMs:Number(gn.target.value)})),N("change",yt,gn=>e.onUpdate({selectionToolbar:gn.target.checked})),N("change",Hr,gn=>e.onUpdate({marginView:gn.target.checked})),C(pe,Ie)},ut=pe=>{var Ie=wL(),pt=w(Ie);C3(pt,{get settings(){return e.settings},get onUpdate(){return e.onUpdate},notify:S}),C(pe,Ie)},it=pe=>{var Ie=EL(),pt=Se(Ie),Pt=w(pt),Gt=w(Pt),Ke=k(Pt,2);{var Ve=yt=>{var $t=kL(),Hr=w($t);q(()=>ee(Hr,d(v))),C(yt,$t)};G(Ke,yt=>{d(v)&&yt(Ve)})}var ct=k(pt,2),ht=w(ct);xe(ht,T);var $e=k(ht,2);{var mt=yt=>{var $t=xL();C(yt,$t)},un=yt=>{var $t=CL();Je($t,21,E,Hr=>Hr.label,(Hr,di)=>{var Vr=_L(),Ti=Se(Vr),gn=w(Ti),Mi=k(Ti,2),Is=w(Mi);q(()=>{ee(gn,d(di).label),ee(Is,d(di).value)}),C(Hr,Vr)}),C(yt,$t)},ot=yt=>{var $t=SL();C(yt,$t)};G($e,yt=>{f.loading?yt(mt):f.info?yt(un,1):yt(ot,-1)})}q(()=>{Pt.disabled=d(m)||f.loading,xe(Pt,`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};`),ee(Gt,d(m)?"Opening…":"View Documentation")}),N("click",Pt,()=>void x()),C(pe,Ie)};G(Oe,pe=>{d(g)==="collaboration"?pe(be):d(g)==="appearance"?pe(Ne,1):d(g)==="editor"?pe(Qe,2):d(g)==="network"?pe(Ae,3):d(g)==="accessibility"?pe(Me,4):d(g)==="claude-code"?pe(Ze,5):d(g)==="shortcuts"?pe(ut,6):pe(it,-1)})}xt($,pe=>y(a,pe),()=>d(a)),q(pe=>{I.disabled=d(h)||f.loading,ee(O,d(h)?"Opening…":"Changelog"),U(L,"href",g_),U(K,"data-state",o()?"connected":s()>0?"reconnecting":"disconnected"),ee(X,pe)},[()=>z(d(g))]),N("click",Z,function(...pe){var Ie;(Ie=e.onClose)==null||Ie.apply(this,pe)}),N("click",I,()=>void _()),N("click",le,function(...pe){var Ie;(Ie=e.onClose)==null||Ie.apply(this,pe)}),C(H,Q)};G(P,H=>{e.open&&H(R)})}C(t,D),Be()}We(["click","input","keydown","change"]);var ML=Er("<path></path>"),DL=M('<span class="badge svelte-nsu1aw"> </span>'),OL=M('<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>'),IL=M('<div data-testid="toast-container" class="toast-stack svelte-nsu1aw"></div>');function RL(t,e){ze(e,!0);var n=kt(),r=Se(n);{var i=o=>{var s=IL();Je(s,21,()=>e.toasts,a=>a.id,(a,l)=>{var u=OL(),c=w(u),f=w(c);Je(f,20,()=>q_[d(l).severity],x=>x,(x,_)=>{var T=ML();q(()=>U(T,"d",_)),C(x,T)});var h=k(c,2),p=w(h),m=w(p),v=k(p,2);{var g=x=>{var _=DL(),T=w(_);q(()=>{U(_,"data-testid",`toast-count-${d(l).id}`),ee(T,`×${d(l).count??""}`)}),C(x,_)};G(v,x=>{d(l).count>1&&x(g)})}var b=k(h,2);q(()=>{U(u,"role",d(l).severity==="info"?"status":"alert"),U(u,"data-testid",`toast-${d(l).id}`),At(u,1,`toast-card ${d(l).severity??""}`,"svelte-nsu1aw"),ee(m,d(l).message),U(b,"data-testid",`toast-dismiss-${d(l).id}`)}),N("click",b,()=>e.onDismiss(d(l).id)),C(a,u)}),C(o,s)};G(r,o=>{e.toasts.length>0&&o(i)})}C(t,n),Be()}We(["click"]);var NL=M('<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 PL(t,e){const n=F(()=>e.installing?"Installing…":"Restart to install");var r=NL(),i=k(w(r),2),o=w(i),s=k(i,2),a=w(s),l=k(s,2);q(()=>{ee(o,`Tandem v${e.version??""} is available.`),s.disabled=e.installing,ee(a,d(n))}),N("click",s,function(...u){var c;(c=e.onInstall)==null||c.apply(this,u)}),N("click",l,function(...u){var c;(c=e.onDismiss)==null||c.apply(this,u)}),C(t,r)}We(["click"]);const LL=Math.floor,FL=(t,e)=>t<e?t:e,zL=(t,e)=>t>e?t:e,S3=128,Tf=127,BL=Number.MAX_SAFE_INTEGER,HL=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},Ec=typeof TextEncoder<"u"?new TextEncoder:null,VL=t=>Ec.encode(t),UL=Ec?VL:HL;let Bu=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});Bu&&Bu.decode(new Uint8Array).length===1&&(Bu=null);const gh=(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},qp=(t,e)=>{for(;e>Tf;)gh(t,S3|Tf&e),e=LL(e/128);gh(t,Tf&e)},U0=new Uint8Array(3e4),jL=U0.length/3,qL=(t,e)=>{if(e.length<jL){const n=Ec.encodeInto(e,U0).written||0;qp(t,n);for(let r=0;r<n;r++)gh(t,U0[r])}else ZL(t,UL(e))},WL=(t,e)=>{const n=unescape(encodeURIComponent(e)),r=n.length;qp(t,r);for(let i=0;i<r;i++)gh(t,n.codePointAt(i))},KL=Ec&&Ec.encodeInto?qL:WL,GL=(t,e)=>{const n=t.cbuf.length,r=t.cpos,i=FL(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(zL(n*2,o)),t.cbuf.set(e.subarray(i)),t.cpos=o)},ZL=(t,e)=>{qp(t,e.byteLength),GL(t,e)},E3=t=>new Error(t),JL=E3("Unexpected end of array"),YL=E3("Integer out of Range"),XL=(t,e)=>{const n=new Uint8Array(t.arr.buffer,t.pos+t.arr.byteOffset,e);return t.pos+=e,n},QL=t=>XL(t,zb(t)),Lw=t=>t.arr[t.pos++],zb=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&Tf)*n,n*=128,i<S3)return e;if(e>BL)throw YL}throw JL},$L=t=>{let e=zb(t);if(e===0)return"";{let n=String.fromCodePoint(Lw(t));if(--e<100)for(;e--;)n+=String.fromCodePoint(Lw(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))}},eF=t=>Bu.decode(QL(t)),Fw=Bu?eF:$L;var al;(function(t){t[t.Token=0]="Token",t[t.PermissionDenied=1]="PermissionDenied",t[t.Authenticated=2]="Authenticated"})(al||(al={}));const tF=(t,e)=>{qp(t,al.Token),KL(t,e)},nF=(t,e,n,r)=>{switch(zb(t)){case al.Token:{e();break}case al.PermissionDenied:{n(Fw(t));break}case al.Authenticated:{r(Fw(t));break}}},zw=t=>Array.from(t.entries()).map(([e,n])=>({clientId:e,...n}));var j0;(function(t){t[t.Connecting=0]="Connecting",t[t.Open=1]="Open",t[t.Closing=2]="Closing",t[t.Closed=3]="Closed"})(j0||(j0={}));function rF(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 $m(t){return new Promise(e=>setTimeout(e,t))}function iF(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 oF(t,e){const n=rF(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||iF;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 u=i(r,n);return u&&await $m(u),o()};return r.attemptsRemaining>0&&r.attemptsRemaining--,n.timeout?new Promise((l,u)=>{const c=setTimeout(()=>{if(n.handleTimeout)try{l(n.handleTimeout(r,n))}catch(f){u(f)}else{const f=new Error(`Retry timeout (attemptNum: ${r.attemptNum}, timeout: ${n.timeout})`);f.code="ATTEMPT_TIMEOUT",u(f)}},n.timeout);t(r,n).then(f=>{clearTimeout(c),l(f)}).catch(f=>{clearTimeout(c),a(f).then(l).catch(u)})}):t(r,n).catch(a)}const s=n.calculateDelay?n.calculateDelay(r,n):n.initialDelay;if(s&&await $m(s),r.attemptNum<1&&n.initialJitter){const a=i(r,n);a&&await $m(a)}return o()}const A3=Math.floor,sF=(t,e)=>t<e?t:e,aF=(t,e)=>t>e?t:e,lF=64,vh=128,uF=63,Hu=127,T3=Number.MAX_SAFE_INTEGER,cF=()=>new Set,dF=Array.from,fF=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},Ac=typeof TextEncoder<"u"?new TextEncoder:null,hF=t=>Ac.encode(t),pF=Ac?hF:fF;let Vu=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});Vu&&Vu.decode(new Uint8Array).length===1&&(Vu=null);class mF{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}const Bb=()=>new mF,M3=t=>{let e=t.cpos;for(let n=0;n<t.bufs.length;n++)e+=t.bufs[n].length;return e},Hb=t=>{const e=new Uint8Array(M3(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},bh=(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},Zn=(t,e)=>{for(;e>Hu;)bh(t,vh|Hu&e),e=A3(e/128);bh(t,Hu&e)},q0=new Uint8Array(3e4),gF=q0.length/3,vF=(t,e)=>{if(e.length<gF){const n=Ac.encodeInto(e,q0).written||0;Zn(t,n);for(let r=0;r<n;r++)bh(t,q0[r])}else iu(t,pF(e))},bF=(t,e)=>{const n=unescape(encodeURIComponent(e)),r=n.length;Zn(t,r);for(let i=0;i<r;i++)bh(t,n.codePointAt(i))},No=Ac&&Ac.encodeInto?vF:bF,yF=(t,e)=>{const n=t.cbuf.length,r=t.cpos,i=sF(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(aF(n*2,o)),t.cbuf.set(e.subarray(i)),t.cpos=o)},iu=(t,e)=>{Zn(t,e.byteLength),yF(t,e)},D3=t=>new Error(t),O3=D3("Unexpected end of array"),I3=D3("Integer out of Range");class wF{constructor(e){this.arr=e,this.pos=0}}const R3=t=>new wF(t),kF=(t,e)=>{const n=new Uint8Array(t.arr.buffer,t.pos+t.arr.byteOffset,e);return t.pos+=e,n},Wp=t=>kF(t,aa(t)),Bw=t=>t.arr[t.pos++],aa=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&Hu)*n,n*=128,i<vh)return e;if(e>T3)throw I3}throw O3},xF=t=>{let e=t.arr[t.pos++],n=e&uF,r=64;const i=(e&lF)>0?-1:1;if((e&vh)===0)return i*n;const o=t.arr.length;for(;t.pos<o;){if(e=t.arr[t.pos++],n=n+(e&Hu)*r,r*=128,e<vh)return i*n;if(n>T3)throw I3}throw O3},_F=t=>{let e=aa(t);if(e===0)return"";{let n=String.fromCodePoint(Bw(t));if(--e<100)for(;e--;)n+=String.fromCodePoint(Bw(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))}},CF=t=>Vu.decode(Wp(t)),Tc=Vu?CF:_F,SF=t=>{const e=t.pos,n=Tc(t);return t.pos=e,n},Hl=Date.now,eg=()=>new Map,EF=(t,e,n)=>{let r=t.get(e);return r===void 0&&t.set(e,r=n()),r};class AF{constructor(){this._observers=eg()}on(e,n){EF(this._observers,e,cF).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 dF((this._observers.get(e)||eg()).values()).forEach(r=>r(...n))}destroy(){this._observers=eg()}}const TF=Object.keys,Hw=t=>TF(t).length,MF=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),DF=(t,e)=>t===e,Uu=(t,e)=>{if(t==null||e==null)return DF(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)||!Uu(t.get(n),e.get(n)))return!1;break}case Object:if(Hw(t)!==Hw(e))return!1;for(const n in t)if(!MF(t,n)||!Uu(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(!Uu(t[n],e[n]))return!1;break;default:return!1}return!0},tg=3e4;class OF extends AF{constructor(e){super(),this.doc=e,this.clientID=e.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval(()=>{const n=Hl();this.getLocalState()!==null&&tg/2<=n-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());const r=[];this.meta.forEach((i,o)=>{o!==this.clientID&&tg<=n-i.lastUpdated&&this.states.has(o)&&r.push(o)}),r.length>0&&Mf(this,r,"timeout")},A3(tg/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:Hl()});const s=[],a=[],l=[],u=[];e===null?u.push(n):o==null?e!=null&&s.push(n):(a.push(n),Uu(o,e)||l.push(n)),(s.length>0||l.length>0||u.length>0)&&this.emit("change",[{added:s,updated:l,removed:u},"local"]),this.emit("update",[{added:s,updated:a,removed:u},"local"])}setLocalStateField(e,n){const r=this.getLocalState();r!==null&&this.setLocalState({...r,[e]:n})}getStates(){return this.states}}const Mf=(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:Hl()})}r.push(o)}}r.length>0&&(t.emit("change",[{added:[],updated:[],removed:r},n]),t.emit("update",[{added:[],updated:[],removed:r},n]))},W0=(t,e,n=t.states)=>{const r=e.length,i=Bb();Zn(i,r);for(let o=0;o<r;o++){const s=e[o],a=n.get(s)||null,l=t.meta.get(s).clock;Zn(i,s),Zn(i,l),No(i,JSON.stringify(a))}return Hb(i)},IF=(t,e,n)=>{const r=R3(e),i=Hl(),o=[],s=[],a=[],l=[],u=aa(r);for(let c=0;c<u;c++){const f=aa(r);let h=aa(r);const p=JSON.parse(Tc(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&&(Uu(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 N3=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 K0{constructor(e){this.data=e,this.encoder=Bb(),this.decoder=R3(new Uint8Array(this.data))}peekVarString(){return SF(this.decoder)}readVarUint(){return aa(this.decoder)}readVarString(){return Tc(this.decoder)}readVarUint8Array(){return Wp(this.decoder)}writeVarUint(e){return Zn(this.encoder,e)}writeVarString(e){return No(this.encoder,e)}writeVarUint8Array(e){return iu(this.encoder,e)}length(){return M3(this.encoder)}}var Pn;(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"})(Pn||(Pn={}));var rr;(function(t){t.Connecting="connecting",t.Connected="connected",t.Disconnected="disconnected"})(rr||(rr={}));class Ia{constructor(){this.encoder=Bb()}get(e){return e.encoder}toUint8Array(){return Hb(this.encoder)}}class RF extends Ia{constructor(){super(...arguments),this.type=Pn.CLOSE,this.description="Ask the server to close the connection"}get(e){return No(this.encoder,e.documentName),Zn(this.encoder,this.type),this.encoder}}class NF extends N3{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=rr.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=rr.Connected,this.emit("status",{status:rr.Connected}),this.cancelWebsocketRetry=void 0,this.receivedOnOpenPayload=e}attach(e){this.configuration.providerMap.set(e.configuration.name,e),this.status===rr.Disconnected&&this.shouldConnect&&this.connect(),this.receivedOnOpenPayload&&this.status===rr.Connected&&e.onOpen(this.receivedOnOpenPayload)}detach(e){this.configuration.providerMap.has(e.configuration.name)&&(e.send(RF,{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===rr.Connected)return;this.cancelWebsocketRetry&&(this.cancelWebsocketRetry(),this.cancelWebsocketRetry=void 0),this.receivedOnOpenPayload=void 0,this.shouldConnect=!0;const e=()=>{let i=!1;return{retryPromise:oF(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=u=>this.emit("message",u),o=u=>this.emit("close",{event:u}),s=u=>this.emit("open",u),a=u=>{n(u)};this.webSocketHandlers[r]={message:i,close:o,open:s,error:a};const l=this.webSocketHandlers[e.identifier];Object.keys(l).forEach(u=>{e.addEventListener(u,l[u])})}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=rr.Connecting,this.emit("status",{status:rr.Connecting}),this.connectionAttempt={resolve:e,reject:n}})}onMessage(e){var n;this.resolveConnectionAttempt(),this.lastMessageReceived=Hl();const i=new K0(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=rr.Connected,this.emit("status",{status:rr.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===rr.Connected&&this.lastMessageReceived&&(this.configuration.messageReconnectTimeout>=Hl()-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)===j0.Open?this.webSocket.send(e):this.messageQueue.push(e)}onClose({event:e}){this.closeTries=0,this.cleanupWebSocket(),this.connectionAttempt&&this.rejectConnectionAttempt(),this.status=rr.Disconnected,this.emit("status",{status:rr.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 P3=0,Vb=1,L3=2,PF=(t,e)=>{Zn(t,P3);const n=RR(e);iu(t,n)},LF=(t,e,n)=>{Zn(t,Vb),iu(t,MR(e,n))},FF=(t,e,n)=>LF(e,n,Wp(t)),F3=(t,e,n)=>{try{ER(e,Wp(t),n)}catch(r){console.error("Caught error while handling a Yjs update",r)}},zF=(t,e)=>{Zn(t,L3),iu(t,e)},BF=F3,HF=(t,e,n,r)=>{const i=aa(t);switch(i){case P3:FF(t,e,n);break;case Vb:F3(t,n,r);break;case L3:BF(t,n,r);break;default:throw new Error("Unknown message type")}return i};class VF{constructor(e){this.message=e}apply(e,n){const{message:r}=this,i=r.readVarUint(),o=r.length();switch(i){case Pn.Sync:this.applySyncMessage(e,n);break;case Pn.Awareness:this.applyAwarenessMessage(e);break;case Pn.Auth:this.applyAuthMessage(e);break;case Pn.QueryAwareness:this.applyQueryAwarenessMessage(e);break;case Pn.Stateless:e.receiveStateless(Tc(r.decoder));break;case Pn.SyncStatus:this.applySyncStatusMessage(e,xF(r.decoder)===1);break;case Pn.CLOSE:const s={code:1e3,reason:Tc(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(Ia,{encoder:r.encoder})}applySyncMessage(e,n){const{message:r}=this;r.writeVarUint(Pn.Sync);const i=HF(r.decoder,r.encoder,e.document,e);n&&i===Vb&&(e.synced=!0)}applySyncStatusMessage(e,n){n&&e.decrementUnsyncedChanges()}applyAwarenessMessage(e){if(!e.awareness)return;const{message:n}=this;IF(e.awareness,n.readVarUint8Array(),e)}applyAuthMessage(e){const{message:n}=this;nF(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(Pn.Awareness),n.writeVarUint8Array(W0(e.awareness,Array.from(e.awareness.getStates().keys())))}}class UF{constructor(e,n={}){this.message=new e,this.encoder=this.message.get(n)}create(){return Hb(this.encoder)}send(e){e==null||e.send(this.create())}}class jF extends Ia{constructor(){super(...arguments),this.type=Pn.Auth,this.description="Authentication"}get(e){if(typeof e.token>"u")throw new Error("The authentication message requires `token` as an argument.");return No(this.encoder,e.documentName),Zn(this.encoder,this.type),tF(this.encoder,e.token),this.encoder}}class Vw extends Ia{constructor(){super(...arguments),this.type=Pn.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");No(this.encoder,e.documentName),Zn(this.encoder,this.type);let n;return e.states===void 0?n=W0(e.awareness,e.clients):n=W0(e.awareness,e.clients,e.states),iu(this.encoder,n),this.encoder}}class qF extends Ia{constructor(){super(...arguments),this.type=Pn.Stateless,this.description="A stateless message"}get(e){var n;return No(this.encoder,e.documentName),Zn(this.encoder,this.type),No(this.encoder,(n=e.payload)!==null&&n!==void 0?n:""),this.encoder}}class Uw extends Ia{constructor(){super(...arguments),this.type=Pn.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 No(this.encoder,e.documentName),Zn(this.encoder,this.type),PF(this.encoder,e.document),this.encoder}}class WF extends Ia{constructor(){super(...arguments),this.type=Pn.Sync,this.description="A document update"}get(e){return No(this.encoder,e.documentName),Zn(this.encoder,this.type),zF(this.encoder,e.update),this.encoder}}class KF extends Error{constructor(){super(...arguments),this.code=1001}}class jw extends N3{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 Qi,this.configuration.awareness=e.awareness!==void 0?e.awareness:new OF(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:zw(this.awareness.getStates())})}),(r=this.awareness)===null||r===void 0||r.on("change",()=>{this.emit("awarenessChange",{states:zw(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 NF(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(Uw,{document:this.document,documentName:this.configuration.name})}pageHide(){this.awareness&&Mf(this.awareness,[this.document.clientID],"page hide")}registerEventListeners(){typeof window>"u"||!("addEventListener"in window)||window.addEventListener("pagehide",this.boundPageHide)}sendStateless(e){this.send(qF,{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(jF,{token:e??"",documentName:this.configuration.name})}documentUpdateHandler(e,n){n!==this&&(this.incrementUnsyncedChanges(),this.send(WF,{update:e,documentName:this.configuration.name}))}awarenessUpdateHandler({added:e,updated:n,removed:r},i){const o=e.concat(n).concat(r);this.send(Vw,{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(Uw,{document:this.document,documentName:this.configuration.name}),this.awareness&&this.awareness.getLocalState()!==null&&this.send(Vw,{awareness:this.awareness,clients:[this.document.clientID],documentName:this.configuration.name})}send(e,n){if(!this._isAttached)return;const r=new UF(e,n);this.emit("outgoingMessage",{message:r.message}),r.send(this.configuration.websocketProvider)}onMessage(e){const n=new K0(e.data),r=n.readVarString();n.writeVarString(r),this.emit("message",{event:e,message:new K0(e.data)}),new VF(n).apply(this,!0)}onClose(){this.isAuthenticated=!1,this.synced=!1,this.awareness&&Mf(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&&(Mf(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 KF(`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 Fn=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},Vl=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let G0=null;const vo=function(t,e,n){let r=G0||(G0=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},GF=function(){G0=null},ka=function(t,e,n,r){return n&&(qw(t,e,n,r,-1)||qw(t,e,n,r,1))},ZF=/^(img|br|input|textarea|hr)$/i;function qw(t,e,n,r,i){for(var o;;){if(t==n&&e==r)return!0;if(e==(i<0?0:ei(t))){let s=t.parentNode;if(!s||s.nodeType!=1||md(t)||ZF.test(t.nodeName)||t.contentEditable=="false")return!1;e=Fn(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?ei(t):0}else return!1}}function ei(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function JF(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=ei(t)}else if(t.parentNode&&!md(t))e=Fn(t),t=t.parentNode;else return null}}function YF(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&&!md(t))e=Fn(t)+1,t=t.parentNode;else return null}}function XF(t,e,n){for(let r=e==0,i=e==ei(t);r||i;){if(t==n)return!0;let o=Fn(t);if(t=t.parentNode,!t)return!1;r=r&&o==0,i=i&&o==ei(t)}}function md(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 Kp=function(t){return t.focusNode&&ka(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function zs(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function QF(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function $F(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:Math.min(ei(r.offsetNode),r.offset)}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:Math.min(ei(r.startContainer),r.startOffset)}}}const $i=typeof navigator<"u"?navigator:null,Ww=typeof document<"u"?document:null,Ds=$i&&$i.userAgent||"",Z0=/Edge\/(\d+)/.exec(Ds),z3=/MSIE \d/.exec(Ds),J0=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Ds),Cr=!!(z3||J0||Z0),ms=z3?document.documentMode:J0?+J0[1]:Z0?+Z0[1]:0,si=!Cr&&/gecko\/(\d+)/i.test(Ds);si&&+(/Firefox\/(\d+)/.exec(Ds)||[0,0])[1];const Y0=!Cr&&/Chrome\/(\d+)/.exec(Ds),Vn=!!Y0,B3=Y0?+Y0[1]:0,Yn=!Cr&&!!$i&&/Apple Computer/.test($i.vendor),Ul=Yn&&(/Mobile\/\w+/.test(Ds)||!!$i&&$i.maxTouchPoints>2),Yr=Ul||($i?/Mac/.test($i.platform):!1),H3=$i?/Win/.test($i.platform):!1,ko=/Android \d/.test(Ds),gd=!!Ww&&"webkitFontSmoothing"in Ww.documentElement.style,ez=gd?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function tz(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 co(t,e){return typeof t=="number"?t:t[e]}function nz(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 Kw(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=Vl(s);continue}let a=s,l=a==o.body,u=l?tz(o):nz(a),c=0,f=0;if(e.top<u.top+co(r,"top")?f=-(u.top-e.top+co(i,"top")):e.bottom>u.bottom-co(r,"bottom")&&(f=e.bottom-e.top>u.bottom-u.top?e.top+co(i,"top")-u.top:e.bottom-u.bottom+co(i,"bottom")),e.left<u.left+co(r,"left")?c=-(u.left-e.left+co(i,"left")):e.right>u.right-co(r,"right")&&(c=e.right-u.right+co(i,"right")),c||f)if(l)o.defaultView.scrollBy(c,f);else{let p=a.scrollLeft,m=a.scrollTop;f&&(a.scrollTop+=f),c&&(a.scrollLeft+=c);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:Vl(s)}}function rz(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:V3(t.dom)}}function V3(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=Vl(r));return e}function iz({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;U3(n,r==0?0:r-e)}function U3(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 La=null;function oz(t){if(t.setActive)return t.setActive();if(La)return t.focus(La);let e=V3(t);t.focus(La==null?{get preventScroll(){return La={preventScroll:!0},!0}}:void 0),La||(La=!1,U3(e,0))}function j3(t,e){let n,r=2e8,i,o=0,s=e.top,a=e.top,l,u;for(let c=t.firstChild,f=0;c;c=c.nextSibling,f++){let h;if(c.nodeType==1)h=c.getClientRects();else if(c.nodeType==3)h=vo(c).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=c,r=v,i=v&&n.nodeType==3?{left:m.right<e.left?m.right:m.left,top:e.top}:e,c.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=c,u={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=u,r=0),n&&n.nodeType==3?sz(n,i):!n||r&&n.nodeType==1?{node:t,offset:o}:j3(n,i)}function sz(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=Uo(r,1);if(s.top!=s.bottom&&Ub(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 Ub(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function az(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function lz(t,e,n){let{node:r,offset:i}=j3(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 uz(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 q3(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 u=a[l];if(Ub(e,u))return q3(s,e,u)}}if((o=(o+1)%r)==i)break}return t}function cz(t,e){let n=t.dom.ownerDocument,r,i=0,o=$F(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 u=t.dom.getBoundingClientRect();if(!Ub(e,u)||(s=q3(t.dom,e,u),!s))return null}if(Yn)for(let u=s;r&&u;u=Vl(u))u.draggable&&(r=void 0);if(s=az(s,e),r){if(si&&r.nodeType==1&&(i=Math.min(i,r.childNodes.length),i<r.childNodes.length)){let c=r.childNodes[i],f;c.nodeName=="IMG"&&(f=c.getBoundingClientRect()).right<=e.left&&f.bottom>e.top&&i++}let u;gd&&i&&r.nodeType==1&&(u=r.childNodes[i-1]).nodeType==1&&u.contentEditable=="false"&&u.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=uz(t,r,i,e))}a==null&&(a=lz(t,s,e));let l=t.docView.nearestDesc(s,!0);return{pos:a,inside:l?l.posAtStart-l.border:-1}}function Gw(t){return t.top<t.bottom||t.left<t.right}function Uo(t,e){let n=t.getClientRects();if(n.length){let r=n[e<0?0:n.length-1];if(Gw(r))return r}return Array.prototype.find.call(n,Gw)||t.getBoundingClientRect()}const dz=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function W3(t,e,n){let{node:r,offset:i,atom:o}=t.docView.domFromPos(e,n<0?-1:1),s=gd||si;if(r.nodeType==3)if(s&&(dz.test(r.nodeValue)||(n<0?!i:i==r.nodeValue.length))){let l=Uo(vo(r,i,i),n);if(si&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let u=Uo(vo(r,i-1,i-1),-1);if(u.top==l.top){let c=Uo(vo(r,i,i+1),-1);if(c.top!=l.top)return mu(c,c.left<u.left)}}return l}else{let l=i,u=i,c=n<0?1:-1;return n<0&&!i?(u++,c=-1):n>=0&&i==r.nodeValue.length?(l--,c=1):n<0?l--:u++,mu(Uo(vo(r,l,u),c),c<0)}if(!t.state.doc.resolve(e-(o||0)).parent.inlineContent){if(o==null&&i&&(n<0||i==ei(r))){let l=r.childNodes[i-1];if(l.nodeType==1)return ng(l.getBoundingClientRect(),!1)}if(o==null&&i<ei(r)){let l=r.childNodes[i];if(l.nodeType==1)return ng(l.getBoundingClientRect(),!0)}return ng(r.getBoundingClientRect(),n>=0)}if(o==null&&i&&(n<0||i==ei(r))){let l=r.childNodes[i-1],u=l.nodeType==3?vo(l,ei(l)-(s?0:1)):l.nodeType==1&&(l.nodeName!="BR"||!l.nextSibling)?l:null;if(u)return mu(Uo(u,1),!1)}if(o==null&&i<ei(r)){let l=r.childNodes[i];for(;l.pmViewDesc&&l.pmViewDesc.ignoreForCoords;)l=l.nextSibling;let u=l?l.nodeType==3?vo(l,0,s?0:1):l.nodeType==1?l:null:null;if(u)return mu(Uo(u,-1),!0)}return mu(Uo(r.nodeType==3?vo(r):r,-n),n>=0)}function mu(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 ng(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 K3(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 fz(t,e,n){let r=e.selection,i=n=="up"?r.$from:r.$to;return K3(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=W3(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=vo(a,0,a.nodeValue.length).getClientRects();else continue;for(let u=0;u<l.length;u++){let c=l[u];if(c.bottom>c.top+1&&(n=="up"?s.top-c.top>(c.bottom-s.top)*2:c.bottom-s.bottom>(s.bottom-c.top)*2))return!1}}return!0})}const hz=/[\u0590-\u08ac]/;function pz(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?!hz.test(r.parent.textContent)||!a.modify?n=="left"||n=="backward"?o:s:K3(t,e,()=>{let{focusNode:l,focusOffset:u,anchorNode:c,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&&u==v;try{a.collapse(c,f),l&&(l!=c||u!=f)&&a.extend&&a.extend(l,u)}catch{}return h!=null&&(a.caretBidiLevel=h),g}):r.pos==r.start()||r.pos==r.end()}let Zw=null,Jw=null,Yw=!1;function mz(t,e,n){return Zw==e&&Jw==n?Yw:(Zw=e,Jw=n,Yw=n=="up"||n=="down"?fz(t,e,n):pz(t,e,n))}const ai=0,Xw=1,qs=2,eo=3;class vd{constructor(e,n,r,i){this.parent=e,this.children=n,this.dom=r,this.contentDOM=i,this.dirty=ai,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>Fn(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 Z3){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 G3&&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?Fn(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?Fn(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],u=s+l.size;if(i==-1&&e<=u){let c=s+l.border;if(e>=c&&n<=u-l.border&&l.node&&l.contentDOM&&this.contentDOM.contains(l.contentDOM))return l.parseRange(e,n,c);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=Fn(h.dom)+1;break}e-=h.size}i==-1&&(i=0)}if(i>-1&&(u>n||a==this.children.length-1)){n=u;for(let c=a+1;c<this.children.length;c++){let f=this.children[c];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(-1)){o=Fn(f.dom);break}n+=f.size}o==-1&&(o=this.contentDOM.childNodes.length);break}s=u}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),u=r.root.getSelection(),c=r.domSelectionRange(),f=!1;if((si||Yn)&&e==n){let{node:p,offset:m}=a;if(p.nodeType==3){if(f=!!(m&&p.nodeValue[m-1]==`
|
|
105
|
+
`),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:Fn(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(si&&c.focusNode&&c.focusNode!=l.node&&c.focusNode.nodeType==1){let p=c.focusNode.childNodes[c.focusOffset];p&&p.contentEditable=="false"&&(i=!0)}if(!(i||f&&Yn)&&ka(a.node,a.offset,c.anchorNode,c.anchorOffset)&&ka(l.node,l.offset,c.focusNode,c.focusOffset))return;let h=!1;if((u.extend||e==n)&&!(f&&si)){u.collapse(a.node,a.offset);try{e!=n&&u.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),u.removeAllRanges(),u.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?qs:Xw,e==a&&n==l&&(o.contentLost||o.dom.parentNode!=this.contentDOM)?o.dirty=eo:o.markDirty(e-a,n-a);return}else o.dirty=o.dom==o.contentDOM&&o.dom.parentNode==this.contentDOM&&!o.children.length?qs:eo}r=s}this.dirty=qs}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?qs:Xw;n.dirty<r&&(n.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class G3 extends vd{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==ai&&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 gz extends vd{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 xa extends vd{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=Da.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new xa(e,n,s.dom,s.contentDOM||s.dom,s)}parseRule(){return this.dirty&eo||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=eo&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=ai){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=ai}}slice(e,n,r){let i=xa.create(this.parent,this.mark,!0,r),o=this.children,s=this.size;n<s&&(o=Q0(o,n,s,r)),e>0&&(o=Q0(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 gs extends vd{constructor(e,n,r,i,o,s,a,l,u){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,u=a&&a(n,o,()=>{if(!l)return s;if(l.parent)return l.parent.posBeforeChild(l)},r,i),c=u&&u.dom,f=u&&u.contentDOM;if(n.isText){if(!c)c=document.createTextNode(n.text);else if(c.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else c||({dom:c,contentDOM:f}=Da.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!f&&!n.isText&&c.nodeName!="BR"&&(c.hasAttribute("contenteditable")||(c.contentEditable="false"),n.type.spec.draggable&&(c.draggable=!0));let h=c;return c=X3(c,r,n),u?l=new vz(e,n,r,i,c,f||null,h,u,o,s+1):n.isText?new Gp(e,n,r,i,c,h,o):new gs(e,n,r,i,c,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=()=>ge.empty)}return e}matchesNode(e,n,r){return this.dirty==ai&&e.eq(this.node)&&yh(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 yz(this,s&&s.node,e);xz(this.node,this.innerDeco,(u,c,f)=>{u.spec.marks?l.syncToMarks(u.spec.marks,r,e,c):u.type.side>=0&&!f&&l.syncToMarks(c==this.node.childCount?It.none:this.node.child(c).marks,r,e,c),l.placeWidget(u,e,i)},(u,c,f,h)=>{l.syncToMarks(u.marks,r,e,h);let p;l.findNodeMatch(u,c,f,h)||a&&e.state.selection.from>i&&e.state.selection.to<i+u.nodeSize&&(p=l.findIndexWithChild(o.node))>-1&&l.updateNodeAt(u,c,f,p,e)||l.updateNextNode(u,c,f,e,h,i)||l.addNode(u,c,f,e,i),i+=u.nodeSize}),l.syncToMarks([],r,e,0),this.node.isTextblock&&l.addTextblockHacks(),l.destroyRest(),(l.changed||this.dirty==qs)&&(s&&this.protectLocalComposition(e,s),J3(this.contentDOM,this.children,e),Ul&&_z(this.dom))}localCompositionInfo(e,n){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof qe)||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=Cz(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 gz(this,o,n,i);e.input.compositionNodes.push(s),this.children=Q0(this.children,r,r+i.length,e,s)}update(e,n,r,i){return this.dirty==eo||!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=ai}updateOuterDeco(e){if(yh(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=Y3(this.dom,this.nodeDOM,X0(this.outerDeco,this.node,n),X0(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 Qw(t,e,n,r,i){X3(r,e,t);let o=new gs(void 0,t,e,n,r,r,r,i,0);return o.contentDOM&&o.updateChildren(i,0),o}class Gp extends gs{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==eo||this.dirty!=ai&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=ai||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=ai,!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 Gp(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=eo)}get domAtom(){return!1}isText(e){return this.node.text==e}}class Z3 extends vd{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==ai&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class vz extends gs{constructor(e,n,r,i,o,s,a,l,u,c){super(e,n,r,i,o,s,a,u,c),this.spec=l}update(e,n,r,i){if(this.dirty==eo)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 J3(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=$w(r),i=!0;r=r.nextSibling}else i=!0,t.insertBefore(a,r);if(s instanceof xa){let l=r?r.previousSibling:t.lastChild;J3(s.contentDOM,s.children,n),r=l?l.nextSibling:t.firstChild}}for(;r;)r=$w(r),i=!0;i&&n.trackWrites==t&&(n.trackWrites=null)}const ju=function(t){t&&(this.nodeName=t)};ju.prototype=Object.create(null);const Ws=[new ju];function X0(t,e,n){if(t.length==0)return Ws;let r=n?Ws[0]:new ju,i=[r];for(let o=0;o<t.length;o++){let s=t[o].type.attrs;if(s){s.nodeName&&i.push(r=new ju(s.nodeName));for(let a in s){let l=s[a];l!=null&&(n&&i.length==1&&i.push(r=new ju(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 Y3(t,e,n,r){if(n==Ws&&r==Ws)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=Ws[0]),i=l}bz(i,a||Ws[0],s)}return i}function bz(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 X3(t,e,n){return Y3(t,t,Ws,X0(e,n,t.nodeType!=1))}function yh(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 $w(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class yz{constructor(e,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=wz(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=ai,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,u=this.top.children.length;i<this.preMatch.index&&(u=Math.min(this.index+3,u));for(let c=this.index;c<u;c++){let f=this.top.children[c];if(f.matchesMark(e[s])&&!this.isLocked(f.dom)){l=c;break}}if(l>-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let c=xa.create(this.top,e[s],n,r);this.top.children.splice(this.index,0,c),this.top=c,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 u=this.top.children[a];if(u.matchesNode(e,n,r)&&!this.preMatch.matched.has(u)){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==eo&&s.dom==s.contentDOM&&(s.dirty=qs),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 gs){let u=this.preMatch.matched.get(l);if(u!=null&&u!=o)return!1;let c=l.dom,f,h=this.isLocked(c)&&!(e.isText&&l.node&&l.node.isText&&l.nodeDOM.nodeValue==e.text&&l.dirty!=eo&&yh(n,l.outerDeco));if(!h&&l.update(e,n,r,i))return this.destroyBetween(this.index,a),l.dom!=c&&(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=qs,f.updateChildren(i,s+1),f.dirty=ai),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)||!yh(r,e.outerDeco)||!i.eq(e.innerDeco))return null;let a=gs.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=gs.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 G3(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 xa;)n=e,e=n.children[n.children.length-1];(!e||!(e instanceof Gp)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((Yn||Vn)&&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 Z3(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 wz(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 u=n.children[r-1];if(u instanceof xa)n=u,r=u.children.length;else{a=u,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 kz(t,e){return t.type.side-e.type.side}function xz(t,e,n,r){let i=e.locals(t),o=0;if(i.length==0){for(let u=0;u<t.childCount;u++){let c=t.child(u);r(c,i,e.forChild(o,c),u),o+=c.nodeSize}return}let s=0,a=[],l=null;for(let u=0;;){let c,f;for(;s<i.length&&i[s].to==o;){let g=i[s++];g.widget&&(c?(f||(f=[c])).push(g):c=g)}if(c)if(f){f.sort(kz);for(let g=0;g<f.length;g++)n(f[g],u,!!l)}else n(c,u,!!l);let h,p;if(l)p=-1,h=l,l=null;else if(u<t.childCount)p=u,h=t.child(u++);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 _z(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 Cz(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 u=t.child(i++);if(o+=u.nodeSize,!u.isText)break;l+=u.text}if(o>=n){if(o>=r&&l.slice(r-e.length-a,r-a)==e)return r-e.length;let u=a<r?l.lastIndexOf(e,r-a-1):-1;if(u>=0&&u+e.length+a>=n)return a+u;if(n==r&&l.length>=r+e.length-a&&l.slice(r-a,r-a+e.length)==e)return r}}return-1}function Q0(t,e,n,r,i){let o=[];for(let s=0,a=0;s<t.length;s++){let l=t[s],u=a,c=a+=l.size;u>=n||c<=e?o.push(l):(u<e&&o.push(l.slice(0,e-u,r)),i&&(o.push(i),i=void 0),c>n&&o.push(l.slice(n-u,l.size,r)))}return o}function jb(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,u;if(Kp(n)){for(l=s;i&&!i.node;)i=i.parent;let f=i.node;if(i&&f.isAtom&&Ye.isSelectable(f)&&i.parent&&!(f.isInline&&XF(n.focusNode,n.focusOffset,i.dom))){let h=i.posBefore;u=new Ye(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 c=r.resolve(l);if(!u){let f=e=="pointer"||t.state.selection.head<a.pos&&!o?1:-1;u=qb(t,c,a,f)}return u}function Q3(t){return t.editable?t.hasFocus():eE(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function Ao(t,e=!1){let n=t.state.selection;if($3(t,n),!!Q3(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&Vn){let r=t.domSelectionRange(),i=t.domObserver.currentSelection;if(r.anchorNode&&i.anchorNode&&ka(r.anchorNode,r.anchorOffset,i.anchorNode,i.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)Ez(t);else{let{anchor:r,head:i}=n,o,s;e2&&!(n instanceof qe)&&(n.$from.parent.inlineContent||(o=t2(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(s=t2(t,n.to))),t.docView.setSelection(r,i,t,e),e2&&(o&&n2(o),s&&n2(s)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&Sz(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const e2=Yn||Vn&&B3<63;function t2(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(Yn&&i&&i.contentEditable=="false")return rg(i);if((!i||i.contentEditable=="false")&&(!o||o.contentEditable=="false")){if(i)return rg(i);if(o)return rg(o)}}function rg(t){return t.contentEditable="true",Yn&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function n2(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function Sz(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(()=>{(!Q3(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function Ez(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,Fn(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&Cr&&ms<=11&&(n.disabled=!0,n.disabled=!1)}function $3(t,e){if(e instanceof Ye){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(r2(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else r2(t)}function r2(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function qb(t,e,n,r){return t.someProp("createSelectionBetween",i=>i(t,e,n))||qe.between(e,n,r)}function i2(t){return t.editable&&!t.hasFocus()?!1:eE(t)}function eE(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 Az(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return ka(e.node,e.offset,n.anchorNode,n.anchorOffset)}function $0(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&&et.findFrom(o,e)}function qo(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function o2(t,e,n){let r=t.state.selection;if(r instanceof qe)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 qo(t,new qe(r.$anchor,s))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let i=$0(t.state,e);return i&&i instanceof Ye?qo(t,i):!1}else if(!(Yr&&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?Ye.isSelectable(o)?qo(t,new Ye(e<0?t.state.doc.resolve(i.pos-o.nodeSize):i)):gd?qo(t,new qe(t.state.doc.resolve(e<0?a:a+o.nodeSize))):!1:!1}}else return!1;else{if(r instanceof Ye&&r.node.isInline)return qo(t,new qe(e>0?r.$to:r.$from));{let i=$0(t.state,e);return i?qo(t,i):!1}}}function wh(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function qu(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function Fa(t,e){return e<0?Tz(t):Mz(t)}function Tz(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i,o,s=!1;for(si&&n.nodeType==1&&r<wh(n)&&qu(n.childNodes[r],-1)&&(s=!0);;)if(r>0){if(n.nodeType!=1)break;{let a=n.childNodes[r-1];if(qu(a,-1))i=n,o=--r;else if(a.nodeType==3)n=a,r=n.nodeValue.length;else break}}else{if(tE(n))break;{let a=n.previousSibling;for(;a&&qu(a,-1);)i=n.parentNode,o=Fn(a),a=a.previousSibling;if(a)n=a,r=wh(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}s?ev(t,n,r):i&&ev(t,i,o)}function Mz(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i=wh(n),o,s;for(;;)if(r<i){if(n.nodeType!=1)break;let a=n.childNodes[r];if(qu(a,1))o=n,s=++r;else break}else{if(tE(n))break;{let a=n.nextSibling;for(;a&&qu(a,1);)o=a.parentNode,s=Fn(a)+1,a=a.nextSibling;if(a)n=a,r=0,i=wh(n);else{if(n=n.parentNode,n==t.dom)break;r=i=0}}}o&&ev(t,o,s)}function tE(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function Dz(t,e){for(;t&&e==t.childNodes.length&&!md(t);)e=Fn(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 Oz(t,e){for(;t&&!e&&!md(t);)e=Fn(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 ev(t,e,n){if(e.nodeType!=3){let o,s;(s=Dz(e,n))?(e=s,n=0):(o=Oz(e,n))&&(e=o,n=o.nodeValue.length)}let r=t.domSelection();if(!r)return;if(Kp(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&&Ao(t)},50)}function s2(t,e){let n=t.state.doc.resolve(e);if(!(Vn||H3)&&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 a2(t,e,n){let r=t.state.selection;if(r instanceof qe&&!r.empty||n.indexOf("s")>-1||Yr&&n.indexOf("m")>-1)return!1;let{$from:i,$to:o}=r;if(!i.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let s=$0(t.state,e);if(s&&s instanceof Ye)return qo(t,s)}if(!i.parent.inlineContent){let s=e<0?i:o,a=r instanceof _r?et.near(s,e):et.findFrom(s,e);return a?qo(t,a):!1}return!1}function l2(t,e){if(!(t.state.selection instanceof qe))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 u2(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function Iz(t){if(!Yn||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;u2(t,r,"true"),setTimeout(()=>u2(t,r,"false"),20)}return!1}function Rz(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function Nz(t,e){let n=e.keyCode,r=Rz(e);if(n==8||Yr&&n==72&&r=="c")return l2(t,-1)||Fa(t,-1);if(n==46&&!e.shiftKey||Yr&&n==68&&r=="c")return l2(t,1)||Fa(t,1);if(n==13||n==27)return!0;if(n==37||Yr&&n==66&&r=="c"){let i=n==37?s2(t,t.state.selection.from)=="ltr"?-1:1:-1;return o2(t,i,r)||Fa(t,i)}else if(n==39||Yr&&n==70&&r=="c"){let i=n==39?s2(t,t.state.selection.from)=="ltr"?1:-1:1;return o2(t,i,r)||Fa(t,i)}else{if(n==38||Yr&&n==80&&r=="c")return a2(t,-1,r)||Fa(t,-1);if(n==40||Yr&&n==78&&r=="c")return Iz(t)||a2(t,1,r)||Fa(t,1);if(r==(Yr?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function Wb(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")||Da.fromSchema(t.state.schema),a=aE(),l=a.createElement("div");l.appendChild(s.serializeFragment(r,{document:a}));let u=l.firstChild,c,f=0;for(;u&&u.nodeType==1&&(c=sE[u.nodeName.toLowerCase()]);){for(let p=c.length-1;p>=0;p--){let m=a.createElement(c[p]);for(;l.firstChild;)m.appendChild(l.firstChild);l.appendChild(m),f++}u=l.firstChild}u&&u.nodeType==1&&u.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,`
|
|
106
|
+
|
|
107
|
+
`);return{dom:l,text:h,slice:e}}function nE(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 Te(ge.from(t.state.schema.text(e.replace(/\r\n?/g,`
|
|
108
|
+
`))),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=Da.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=zz(n),gd&&Bz(s);let u=s&&s.querySelector("[data-pm-slice]"),c=u&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(u.getAttribute("data-pm-slice")||"");if(c&&c[3])for(let f=+c[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")||Pu.fromSchema(t.state.schema)).parseSlice(s,{preserveWhitespace:!!(l||c),context:i,ruleFromNode(h){return h.nodeName=="BR"&&!h.nextSibling&&h.parentNode&&!Pz.test(h.parentNode.nodeName)?{ignore:!0}:null}})),c)a=Hz(c2(a,+c[1],+c[2]),c[4]);else if(a=Te.maxOpen(Lz(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=c2(a,f,h)}return t.someProp("transformPasted",f=>{a=f(a,t,l)}),a}const Pz=/^(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 Lz(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),u;if(!l)return s=null;if(u=s.length&&o.length&&iE(l,o,a,s[s.length-1],0))s[s.length-1]=u;else{s.length&&(s[s.length-1]=oE(s[s.length-1],o.length));let c=rE(a,l);s.push(c),i=i.matchType(c.type),o=l}}),s)return ge.from(s)}return t}function rE(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,ge.from(t));return t}function iE(t,e,n,r,i){if(i<t.length&&i<e.length&&t[i]==e[i]){let o=iE(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(ge.from(rE(n,t,i+1))))}}function oE(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,oE(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(ge.empty,!0);return t.copy(n.append(r))}function tv(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=tv(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(ge.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,s.copy(a))}function c2(t,e,n){return e<t.openStart&&(t=new Te(tv(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new Te(tv(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const sE={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 d2=null;function aE(){return d2||(d2=document.implementation.createHTMLDocument("title"))}let ig=null;function Fz(t){let e=window.trustedTypes;return e?(ig||(ig=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),ig.createHTML(t)):t}function zz(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=aE().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),i;if((i=r&&sE[r[1].toLowerCase()])&&(t=i.map(o=>"<"+o+">").join("")+t+i.map(o=>"</"+o+">").reverse().join("")),n.innerHTML=Fz(t),i)for(let o=0;o<i.length;o++)n=n.querySelector(i[o])||n;return n}function Bz(t){let e=t.querySelectorAll(Vn?"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 Hz(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=ge.from(l.create(r[a+1],i)),o++,s++}return new Te(i,o,s)}const dr={},fr={},Vz={touchstart:!0,touchmove:!0};class Uz{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 jz(t){for(let e in dr){let n=dr[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{Wz(t,r)&&!Kb(t,r)&&(t.editable||!(r.type in fr))&&n(t,r)},Vz[e]?{passive:!0}:void 0)}Yn&&t.dom.addEventListener("input",()=>null),nv(t)}function ls(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function qz(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 nv(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>Kb(t,r))})}function Kb(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function Wz(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 Kz(t,e){!Kb(t,e)&&dr[e.type]&&(t.editable||!(e.type in fr))&&dr[e.type](t,e)}fr.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!uE(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(ko&&Vn&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),Ul&&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,zs(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||Nz(t,n)?n.preventDefault():ls(t,"key")};fr.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};fr.keypress=(t,e)=>{let n=e;if(uE(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||Yr&&n.metaKey)return;if(t.someProp("handleKeyPress",i=>i(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof qe)||!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 Zp(t){return{left:t.clientX,top:t.clientY}}function Gz(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function Gb(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 ll(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 Zz(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&Ye.isSelectable(r)?(ll(t,new Ye(n)),!0):!1}function Jz(t,e){if(e==-1)return!1;let n=t.state.selection,r,i;n instanceof Ye&&(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(Ye.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?(ll(t,Ye.create(t.state.doc,i)),!0):!1}function Yz(t,e,n,r,i){return Gb(t,"handleClickOn",e,n,r)||t.someProp("handleClick",o=>o(t,e,r))||(i?Jz(t,n):Zz(t,n))}function Xz(t,e,n,r){return Gb(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",i=>i(t,e,r))}function Qz(t,e,n,r){return Gb(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",i=>i(t,e,r))||$z(t,n,r)}function $z(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(ll(t,qe.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)ll(t,qe.create(r,a+1,a+1+s.content.size));else if(Ye.isSelectable(s))ll(t,Ye.create(r,a));else continue;return!0}}function Zb(t){return kh(t)}const lE=Yr?"metaKey":"ctrlKey";dr.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=Zb(t),i=Date.now(),o="singleClick";i-t.input.lastClick.time<500&&Gz(n,t.input.lastClick)&&!n[lE]&&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(Zp(n));s&&(o=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new eB(t,s,n,!!r)):(o=="doubleClick"?Xz:Qz)(t,s.pos,s.inside,n)?n.preventDefault():ls(t,"pointer"))};class eB{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[lE],this.allowDefault=r.shiftKey;let o,s;if(n.inside>-1)o=e.state.doc.nodeAt(n.inside),s=n.inside;else{let c=e.state.doc.resolve(n.pos);o=c.parent,s=c.depth?c.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:u}=e.state;(r.button==0&&o.type.spec.draggable&&o.type.spec.selectable!==!1||u instanceof Ye&&u.from<=s&&u.to>s)&&(this.mightDrag={node:o,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&si&&!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)),ls(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(()=>Ao(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(Zp(e))),this.updateAllowDefault(e),this.allowDefault||!n?ls(this.view,"pointer"):Yz(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Yn&&this.mightDrag&&!this.mightDrag.node.isAtom||Vn&&!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)?(ll(this.view,et.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):ls(this.view,"pointer")}move(e){this.updateAllowDefault(e),ls(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)}}dr.touchstart=t=>{t.input.lastTouch=Date.now(),Zb(t),ls(t,"pointer")};dr.touchmove=t=>{t.input.lastTouch=Date.now(),ls(t,"pointer")};dr.contextmenu=t=>Zb(t);function uE(t,e){return t.composing?!0:Yn&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const tB=ko?5e3:-1;fr.compositionstart=fr.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof qe&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||Vn&&H3&&nB(t)))t.markCursor=t.state.storedMarks||n.marks(),kh(t,!0),t.markCursor=null;else if(kh(t,!e.selection.empty),si&&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}cE(t,tB)};function nB(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"}fr.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++,cE(t,20))};function cE(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>kh(t),e))}function dE(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=iB());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function rB(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=JF(e.focusNode,e.focusOffset),r=YF(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 iB(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function kh(t,e=!1){if(!(ko&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),dE(t),e||t.docView&&t.docView.dirty){let n=jb(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 oB(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 Mc=Cr&&ms<15||Ul&&ez<604;dr.copy=fr.cut=(t,e)=>{let n=e,r=t.state.selection,i=n.type=="cut";if(r.empty)return;let o=Mc?null:n.clipboardData,s=r.content(),{dom:a,text:l}=Wb(t,s);o?(n.preventDefault(),o.clearData(),o.setData("text/html",a.innerHTML),o.setData("text/plain",l)):oB(t,a),i&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function sB(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function aB(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?Dc(t,r.value,null,i,e):Dc(t,r.textContent,r.innerHTML,i,e)},50)}function Dc(t,e,n,r,i){let o=nE(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",l=>l(t,i,o||Te.empty)))return!0;if(!o)return!1;let s=sB(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 fE(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," "):""}fr.paste=(t,e)=>{let n=e;if(t.composing&&!ko)return;let r=Mc?null:n.clipboardData,i=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&Dc(t,fE(r),r.getData("text/html"),i,n)?n.preventDefault():aB(t,n)};class hE{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const lB=Yr?"altKey":"ctrlKey";function pE(t,e){let n=t.someProp("dragCopies",r=>!r(e));return n??!e[lB]}dr.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(Zp(n)),s;if(!(o&&o.pos>=i.from&&o.pos<=(i instanceof Ye?i.to-1:i.to))){if(r&&r.mightDrag)s=Ye.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=Ye.create(t.state.doc,f.posBefore))}}let a=(s||t.state.selection).content(),{dom:l,text:u,slice:c}=Wb(t,a);(!n.dataTransfer.files.length||!Vn||B3>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(Mc?"Text":"text/html",l.innerHTML),n.dataTransfer.effectAllowed="copyMove",Mc||n.dataTransfer.setData("text/plain",u),t.dragging=new hE(c,pE(t,n),s)};dr.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};fr.dragover=fr.dragenter=(t,e)=>e.preventDefault();fr.drop=(t,e)=>{try{uB(t,e,t.dragging)}finally{t.dragging=null}};function uB(t,e,n){if(!e.dataTransfer)return;let r=t.posAtCoords(Zp(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=nE(t,fE(e.dataTransfer),Mc?null:e.dataTransfer.getData("text/html"),!1,i);let s=!!(n&&pE(t,e));if(t.someProp("handleDrop",p=>p(t,e,o||Te.empty,s))){e.preventDefault();return}if(!o)return;e.preventDefault();let a=o?gC(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 u=l.mapping.map(a),c=o.openStart==0&&o.openEnd==0&&o.content.childCount==1,f=l.doc;if(c?l.replaceRangeWith(u,u,o.content.firstChild):l.replaceRange(u,u,o),l.doc.eq(f))return;let h=l.doc.resolve(u);if(c&&Ye.isSelectable(o.content.firstChild)&&h.nodeAfter&&h.nodeAfter.sameMarkup(o.content.firstChild))l.setSelection(new Ye(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(qb(t,h,l.doc.resolve(p)))}t.focus(),t.dispatch(l.setMeta("uiEvent","drop"))}dr.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())&&Ao(t)},20))};dr.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)};dr.beforeinput=(t,e)=>{if(Vn&&ko&&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,zs(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 fr)dr[t]=fr[t];function Oc(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 xh{constructor(e,n){this.toDOM=e,this.spec=n||la,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 Vt(o-r,o-r,this)}valid(){return!0}eq(e){return this==e||e instanceof xh&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Oc(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class vs{constructor(e,n){this.attrs=e,this.spec=n||la}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 Vt(o,s,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof vs&&Oc(this.attrs,e.attrs)&&Oc(this.spec,e.spec)}static is(e){return e.type instanceof vs}destroy(){}}class Jb{constructor(e,n){this.attrs=e,this.spec=n||la}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 Vt(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 Jb&&Oc(this.attrs,e.attrs)&&Oc(this.spec,e.spec)}destroy(){}}class Vt{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new Vt(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 Vt(e,e,new xh(n,r))}static inline(e,n,r,i){return new Vt(e,n,new vs(r,i))}static node(e,n,r,i){return new Vt(e,n,new Jb(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof vs}get widget(){return this.type instanceof xh}}const ja=[],la={};class nt{constructor(e,n){this.local=e.length?e:ja,this.children=n.length?n:ja}static create(e,n){return n.length?_h(n,e,0,la):Kn}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==Kn||e.maps.length==0?this:this.mapInner(e,n,0,0,r||la)}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?cB(this.children,s||[],e,n,r,i,o):s?new nt(s.sort(ua),ja):Kn}add(e,n){return n.length?this==Kn?nt.create(e,n):this.addInner(e,n,0):this}addInner(e,n,r){let i,o=0;e.forEach((a,l)=>{let u=l+r,c;if(c=gE(n,a,u)){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,c,u+1):i.splice(o,0,l,l+a.nodeSize,_h(c,a,u+1,la)),o+=3}});let s=mE(o?vE(n):n,-r);for(let a=0;a<s.length;a++)s[a].type.valid(e,s[a])||s.splice(a--,1);return new nt(s.length?this.local.concat(s).sort(ua):this.local,i||this.children)}remove(e){return e.length==0||this==Kn?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 c=0,f;c<e.length;c++)(f=e[c])&&f.from>a&&f.to<l&&(e[c]=null,(s||(s=[])).push(f));if(!s)continue;r==this.children&&(r=this.children.slice());let u=r[o+2].removeInner(s,a+1);u!=Kn?r[o+2]=u:(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 nt(i,r):Kn}forChild(e,n){if(this==Kn)return this;if(n.isLeaf)return nt.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 vs){let u=Math.max(o,l.from)-o,c=Math.min(s,l.to)-o;u<c&&(i||(i=[])).push(l.copy(u,c))}}if(i){let a=new nt(i.sort(ua),ja);return r?new Jo([a,r]):a}return r||Kn}eq(e){if(this==e)return!0;if(!(e instanceof nt)||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 Yb(this.localsInner(e))}localsInner(e){if(this==Kn)return ja;if(e.inlineContent||!this.local.some(vs.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof vs||n.push(this.local[r]);return n}forEachSet(e){e(this)}}nt.empty=new nt([],[]);nt.removeOverlap=Yb;const Kn=nt.empty;class Jo{constructor(e){this.members=e}map(e,n){const r=this.members.map(i=>i.map(e,n,la));return Jo.from(r)}forChild(e,n){if(n.isLeaf)return nt.empty;let r=[];for(let i=0;i<this.members.length;i++){let o=this.members[i].forChild(e,n);o!=Kn&&(o instanceof Jo?r=r.concat(o.members):r.push(o))}return Jo.from(r)}eq(e){if(!(e instanceof Jo)||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?Yb(r?n:n.sort(ua)):ja}static from(e){switch(e.length){case 0:return Kn;case 1:return e[0];default:return new Jo(e.every(n=>n instanceof nt)?e:e.reduce((n,r)=>n.concat(r instanceof nt?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}}function cB(t,e,n,r,i,o,s){let a=t.slice();for(let u=0,c=o;u<n.maps.length;u++){let f=0;n.maps[u].forEach((h,p,m,v)=>{let g=v-m-(p-h);for(let b=0;b<a.length;b+=3){let x=a[b+1];if(x<0||h>x+c-f)continue;let _=a[b]+c-f;p>=_?a[b+1]=h<=_?-2:-1:h>=c&&g&&(a[b]+=g,a[b+1]+=g)}f+=g}),c=n.maps[u].map(c,-1)}let l=!1;for(let u=0;u<a.length;u+=3)if(a[u+1]<0){if(a[u+1]==-2){l=!0,a[u+1]=-1;continue}let c=n.map(t[u]+o),f=c-i;if(f<0||f>=r.content.size){l=!0;continue}let h=n.map(t[u+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[u+2].mapInner(n,g,c+1,t[u]+o+1,s);b!=Kn?(a[u]=f,a[u+1]=p,a[u+2]=b):(a[u+1]=-2,l=!0)}else l=!0}if(l){let u=dB(a,t,e,n,i,o,s),c=_h(u,r,0,s);e=c.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<c.children.length;f+=3){let p=c.children[f];for(;h<a.length&&a[h]<p;)h+=3;a.splice(h,0,c.children[f],c.children[f+1],c.children[f+2])}}return new nt(e.sort(ua),a)}function mE(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 Vt(i.from+e,i.to+e,i.type))}return n}function dB(t,e,n,r,i,o,s){function a(l,u){for(let c=0;c<l.local.length;c++){let f=l.local[c].map(r,i,u);f?n.push(f):s.onRemove&&s.onRemove(l.local[c].spec)}for(let c=0;c<l.children.length;c+=3)a(l.children[c+2],l.children[c]+u+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 gE(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 vE(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function _h(t,e,n,r){let i=[],o=!1;e.forEach((a,l)=>{let u=gE(t,a,l+n);if(u){o=!0;let c=_h(u,a,n+l+1,r);c!=Kn&&i.push(l,l+a.nodeSize,c)}});let s=mE(o?vE(t):t,-n).sort(ua);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 nt(s,i):Kn}function ua(t,e){return t.from-e.from||t.to-e.to}function Yb(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),f2(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),f2(e,i,r.copy(o.from,r.to)));break}}}return e}function f2(t,e,n){for(;e<t.length&&ua(n,t[e])>0;)e++;t.splice(e,0,n)}function og(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=Kn&&e.push(r)}),t.cursorWrapper&&e.push(nt.create(t.state.doc,[t.cursorWrapper.deco])),Jo.from(e)}const fB={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},hB=Cr&&ms<=11;class pB{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 mB{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new pB,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]);Cr&&ms<=11&&r.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():Yn&&e.composing&&r.some(i=>i.type=="childList"&&i.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),hB&&(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,fB)),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(i2(this.view)){if(this.suppressingSelectionUpdates)return Ao(this.view);if(Cr&&ms<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&ka(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=Vl(o))n.add(o);for(let o=e.anchorNode;o;o=Vl(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)&&i2(e)&&!this.ignoreSelectionChange(r),o=-1,s=-1,a=!1,l=[];if(e.editable)for(let c=0;c<n.length;c++){let f=this.registerMutation(n[c],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(c=>c.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46)){for(let c of l)if(c.nodeName=="BR"&&c.parentNode){let f=c.nextSibling;for(;f&&f.nodeType==1;){if(f.contentEditable=="false"){c.parentNode.removeChild(c);break}f=f.firstChild}}}else if(si&&l.length){let c=l.filter(f=>f.nodeName=="BR");if(c.length==2){let[f,h]=c;f.parentNode&&f.parentNode.parentNode==h.parentNode?h.remove():f.remove()}else{let{focusNode:f}=this.currentSelection;for(let h of c){let p=h.parentNode;p&&p.nodeName=="LI"&&(!f||bB(e,f)!=p)&&h.remove()}}}let u=null;o<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Kp(r)&&(u=jb(e))&&u.eq(et.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Ao(e),this.currentSelection.set(r),e.scrollToSelection()):(o>-1||i)&&(o>-1&&(e.docView.markDirty(o,s),gB(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,yB(e,l)),this.handleDOMChange(o,s,a,l),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||Ao(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 c=0;c<e.addedNodes.length;c++){let f=e.addedNodes[c];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(Cr&&ms<=11&&e.addedNodes.length)for(let c=0;c<e.addedNodes.length;c++){let{previousSibling:f,nextSibling:h}=e.addedNodes[c];(!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?Fn(i)+1:0,a=r.localPosFromDOM(e.target,s,-1),l=o&&o.parentNode==e.target?Fn(o):e.target.childNodes.length,u=r.localPosFromDOM(e.target,l,1);return{from:a,to:u}}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 h2=new WeakMap,p2=!1;function gB(t){if(!h2.has(t)&&(h2.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=si,p2)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."),p2=!0}}function m2(t,e){let n=e.startContainer,r=e.startOffset,i=e.endContainer,o=e.endOffset,s=t.domAtPos(t.state.selection.anchor);return ka(s.node,s.offset,i,o)&&([n,r,i,o]=[i,o,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:o}}function vB(t,e){if(e.getComposedRanges){let i=e.getComposedRanges(t.root)[0];if(i)return m2(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?m2(t,n):null}function bB(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 yB(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 wB(t,e,n){let{node:r,fromOffset:i,toOffset:o,from:s,to:a}=t.docView.parseRange(e,n),l=t.domSelectionRange(),u,c=l.anchorNode;if(c&&t.dom.contains(c.nodeType==1?c:c.parentNode)&&(u=[{node:c,offset:l.anchorOffset}],Kp(l)||u.push({node:l.focusNode,offset:l.focusOffset})),Vn&&t.input.lastKeyCode===8)for(let g=o;g>i;g--){let b=r.childNodes[g-1],x=b.pmViewDesc;if(b.nodeName=="BR"&&!x){o=g;break}if(!x||x.size)break}let f=t.state.doc,h=t.someProp("domParser")||Pu.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:u,ruleFromNode:kB,context:p});if(u&&u[0].pos!=null){let g=u[0].pos,b=u[1]&&u[1].pos;b==null&&(b=g),m={anchor:g+s,head:b+s}}return{doc:v,sel:m,from:s,to:a}}function kB(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(Yn&&/^(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||Yn&&/^(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 xB=/^(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 _B(t,e,n,r,i){let o=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let E=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,D=jb(t,E);if(D&&!t.state.selection.eq(D)){if(Vn&&ko&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",R=>R(t,zs(13,"Enter"))))return;let P=t.state.tr.setSelection(D);E=="pointer"?P.setMeta("pointer",!0):E=="key"&&P.scrollIntoView(),o&&P.setMeta("composition",o),t.dispatch(P)}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,u=wB(t,e,n),c=t.state.doc,f=c.slice(u.from,u.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=EB(f.content,u.doc.content,u.from,h,p);if(m&&t.input.domChangeCount++,(Ul&&t.input.lastIOSEnter>Date.now()-225||ko)&&i.some(E=>E.nodeType==1&&!xB.test(E.nodeName))&&(!m||m.endA>=m.endB)&&t.someProp("handleKeyDown",E=>E(t,zs(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!m)if(r&&l instanceof qe&&!l.empty&&l.$head.sameParent(l.$anchor)&&!t.composing&&!(u.sel&&u.sel.anchor!=u.sel.head))m={start:l.from,endA:l.to,endB:l.to};else{if(u.sel){let E=g2(t,t.state.doc,u.sel);if(E&&!E.eq(t.state.selection)){let D=t.state.tr.setSelection(E);o&&D.setMeta("composition",o),t.dispatch(D)}}return}t.state.selection.from<t.state.selection.to&&m.start==m.endB&&t.state.selection instanceof qe&&(m.start>t.state.selection.from&&m.start<=t.state.selection.from+2&&t.state.selection.from>=u.from?m.start=t.state.selection.from:m.endA<t.state.selection.to&&m.endA>=t.state.selection.to-2&&t.state.selection.to<=u.to&&(m.endB+=t.state.selection.to-m.endA,m.endA=t.state.selection.to)),Cr&&ms<=11&&m.endB==m.start+1&&m.endA==m.start&&m.start>u.from&&u.doc.textBetween(m.start-u.from-1,m.start-u.from+1)==" "&&(m.start--,m.endA--,m.endB--);let v=u.doc.resolveNoCache(m.start-u.from),g=u.doc.resolveNoCache(m.endB-u.from),b=c.resolve(m.start),x=v.sameParent(g)&&v.parent.inlineContent&&b.end()>=m.endA;if((Ul&&t.input.lastIOSEnter>Date.now()-225&&(!x||i.some(E=>E.nodeName=="DIV"||E.nodeName=="P"))||!x&&v.pos<u.doc.content.size&&(!v.sameParent(g)||!v.parent.inlineContent)&&v.pos<g.pos&&!/\S/.test(u.doc.textBetween(v.pos,g.pos,"","")))&&t.someProp("handleKeyDown",E=>E(t,zs(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>m.start&&SB(c,m.start,m.endA,v,g)&&t.someProp("handleKeyDown",E=>E(t,zs(8,"Backspace")))){ko&&Vn&&t.domObserver.suppressSelectionUpdates();return}Vn&&m.endB==m.start&&(t.input.lastChromeDelete=Date.now()),ko&&!x&&v.start()!=g.start()&&g.parentOffset==0&&v.depth==g.depth&&u.sel&&u.sel.anchor==u.sel.head&&u.sel.head==m.endA&&(m.endB-=2,g=u.doc.resolveNoCache(m.endB-u.from),setTimeout(()=>{t.someProp("handleKeyDown",function(E){return E(t,zs(13,"Enter"))})},20));let _=m.start,T=m.endA,S=E=>{let D=E||t.state.tr.replace(_,T,u.doc.slice(m.start-u.from,m.endB-u.from));if(u.sel){let P=g2(t,D.doc,u.sel);P&&!(Vn&&t.composing&&P.empty&&(m.start!=m.endB||t.input.lastChromeDelete<Date.now()-100)&&(P.head==_||P.head==D.mapping.map(T)-1)||Cr&&P.empty&&P.head==_)&&D.setSelection(P)}return o&&D.setMeta("composition",o),D.scrollIntoView()},z;if(x)if(v.pos==g.pos){Cr&&ms<=11&&v.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>Ao(t),20));let E=S(t.state.tr.delete(_,T)),D=c.resolve(m.start).marksAcross(c.resolve(m.endA));D&&E.ensureMarks(D),t.dispatch(E)}else if(m.endA==m.endB&&(z=CB(v.parent.content.cut(v.parentOffset,g.parentOffset),b.parent.content.cut(b.parentOffset,m.endA-b.start())))){let E=S(t.state.tr);z.type=="add"?E.addMark(_,T,z.mark):E.removeMark(_,T,z.mark),t.dispatch(E)}else if(v.parent.child(v.index()).isText&&v.index()==g.index()-(g.textOffset?0:1)){let E=v.parent.textBetween(v.parentOffset,g.parentOffset),D=()=>S(t.state.tr.insertText(E,_,T));t.someProp("handleTextInput",P=>P(t,_,T,E,D))||t.dispatch(D())}else t.dispatch(S());else t.dispatch(S())}function g2(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:qb(t,e.resolve(n.anchor),e.resolve(n.head))}function CB(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,i=n,o=r,s,a,l;for(let c=0;c<r.length;c++)i=r[c].removeFromSet(i);for(let c=0;c<n.length;c++)o=n[c].removeFromSet(o);if(i.length==1&&o.length==0)a=i[0],s="add",l=c=>c.mark(a.addToSet(c.marks));else if(i.length==0&&o.length==1)a=o[0],s="remove",l=c=>c.mark(a.removeFromSet(c.marks));else return null;let u=[];for(let c=0;c<e.childCount;c++)u.push(l(e.child(c)));if(ge.from(u).eq(t))return{mark:a,type:s}}function SB(t,e,n,r,i){if(n-e<=i.pos-r.pos||sg(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(sg(o,!0,!0));return!s.parent.isTextblock||s.pos>n||sg(s,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(s.parent.content)}function sg(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 EB(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&&v2(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&&v2(t.textBetween(o-1,o+1))&&(o+=l?1:-1),s=o+(s-a),a=o}return{start:o,endA:s,endB:a}}function v2(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 bE{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 Uz,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(x2),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=w2(this),y2(this),this.nodeViews=k2(this),this.docView=Qw(this.state.doc,b2(this),og(this),this.dom,this),this.domObserver=new mB(this,(r,i,o,s)=>_B(this,r,i,o,s)),this.domObserver.start(),jz(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&&nv(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(x2),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&&(dE(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=k2(this);TB(p,this.nodeViews)&&(this.nodeViews=p,o=!0)}(a||n.handleDOMEvents!=this._props.handleDOMEvents)&&nv(this),this.editable=w2(this),y2(this);let l=og(this),u=b2(this),c=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",f=o||!this.docView.matchesNode(e.doc,u,l);(f||!e.selection.eq(i.selection))&&(s=!0);let h=c=="preserve"&&s&&this.dom.style.overflowAnchor==null&&rz(this);if(s){this.domObserver.stop();let p=f&&(Cr||Vn)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&AB(i.selection,e.selection);if(f){let m=Vn?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=rB(this)),(o||!this.docView.update(e.doc,u,l,this))&&(this.docView.updateOuterDeco(u),this.docView.destroy(),this.docView=Qw(e.doc,u,l,this.dom,this)),m&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(p=!0)}p||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Az(this))?Ao(this,p):($3(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),c=="reset"?this.dom.scrollTop=0:c=="to selection"?this.scrollToSelection():h&&iz(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 Ye){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&Kw(this,n.getBoundingClientRect(),e)}else Kw(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 hE(e.slice,e.move,i<0?void 0:Ye.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(Cr){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&&oz(this.dom),Ao(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 cz(this,e)}coordsAtPos(e,n=1){return W3(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 mz(this,n||this.state,e)}pasteHTML(e,n){return Dc(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return Dc(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return Wb(this,e)}destroy(){this.docView&&(qz(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],og(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,GF())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Kz(this,e)}domSelectionRange(){let e=this.domSelection();return e?Yn&&this.root.nodeType===11&&QF(this.dom.ownerDocument)==this.dom&&vB(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}bE.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function b2(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"),[Vt.node(0,t.state.doc.content.size,e)]}function y2(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:Vt.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function w2(t){return!t.someProp("editable",e=>e(t.state)===!1)}function AB(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 k2(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 TB(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 x2(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 Es={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:"'"},Ch={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},MB=typeof navigator<"u"&&/Mac/.test(navigator.platform),DB=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var zn=0;zn<10;zn++)Es[48+zn]=Es[96+zn]=String(zn);for(var zn=1;zn<=24;zn++)Es[zn+111]="F"+zn;for(var zn=65;zn<=90;zn++)Es[zn]=String.fromCharCode(zn+32),Ch[zn]=String.fromCharCode(zn);for(var ag in Es)Ch.hasOwnProperty(ag)||(Ch[ag]=Es[ag]);function OB(t){var e=MB&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||DB&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?Ch:Es)[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 IB=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),RB=typeof navigator<"u"&&/Win/.test(navigator.platform);function NB(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))IB?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 PB(t){let e=Object.create(null);for(let n in t)e[NB(n)]=t[n];return e}function lg(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 LB(t){return new Dt({props:{handleKeyDown:Xb(t)}})}function Xb(t){let e=PB(t);return function(n,r){let i=OB(r),o,s=e[lg(i,r)];if(s&&s(n.state,n.dispatch,n))return!0;if(i.length==1&&i!=" "){if(r.shiftKey){let a=e[lg(i,r,!1)];if(a&&a(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(RB&&r.ctrlKey&&r.altKey)&&(o=Es[r.keyCode])&&o!=i){let a=e[lg(o,r)];if(a&&a(n.state,n.dispatch,n))return!0}}return!1}}const Qb=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function yE(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const wE=(t,e,n)=>{let r=yE(t,n);if(!r)return!1;let i=$b(r);if(!i){let s=r.blockRange(),a=s&&Yl(s);return a==null?!1:(e&&e(t.tr.lift(s,a).scrollIntoView()),!0)}let o=i.nodeBefore;if(ME(t,i,e,-1))return!0;if(r.parent.content.size==0&&(jl(o,"end")||Ye.isSelectable(o)))for(let s=r.depth;;s--){let a=Sp(t.doc,r.before(s),r.after(s),Te.empty);if(a&&a.slice.size<a.to-a.from){if(e){let l=t.tr.step(a);l.setSelection(jl(o,"end")?et.findFrom(l.doc.resolve(l.mapping.map(i.pos,-1)),-1):Ye.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},FB=(t,e,n)=>{let r=yE(t,n);if(!r)return!1;let i=$b(r);return i?kE(t,i,e):!1},zB=(t,e,n)=>{let r=_E(t,n);if(!r)return!1;let i=e1(r);return i?kE(t,i,e):!1};function kE(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 c=i.lastChild;if(!c)return!1;i=c}let s=e.nodeAfter,a=s,l=e.pos+1;for(;!a.isTextblock;l++){if(a.type.spec.isolating)return!1;let c=a.firstChild;if(!c)return!1;a=c}let u=Sp(t.doc,o,l,Te.empty);if(!u||u.from!=o||u instanceof _n&&u.slice.size>=l-o)return!1;if(n){let c=t.tr.step(u);c.setSelection(qe.create(c.doc,o)),n(c.scrollIntoView())}return!0}function jl(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 xE=(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=$b(r)}let s=o&&o.nodeBefore;return!s||!Ye.isSelectable(s)?!1:(e&&e(t.tr.setSelection(Ye.create(t.doc,o.pos-s.nodeSize)).scrollIntoView()),!0)};function $b(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 _E(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const CE=(t,e,n)=>{let r=_E(t,n);if(!r)return!1;let i=e1(r);if(!i)return!1;let o=i.nodeAfter;if(ME(t,i,e,1))return!0;if(r.parent.content.size==0&&(jl(o,"start")||Ye.isSelectable(o))){let s=Sp(t.doc,r.before(),r.after(),Te.empty);if(s&&s.slice.size<s.to-s.from){if(e){let a=t.tr.step(s);a.setSelection(jl(o,"start")?et.findFrom(a.doc.resolve(a.mapping.map(i.pos)),1):Ye.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},SE=(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=e1(r)}let s=o&&o.nodeAfter;return!s||!Ye.isSelectable(s)?!1:(e&&e(t.tr.setSelection(Ye.create(t.doc,o.pos)).scrollIntoView()),!0)};function e1(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 BB=(t,e)=>{let n=t.selection,r=n instanceof Ye,i;if(r){if(n.node.isTextblock||!Ms(t.doc,n.from))return!1;i=n.from}else if(i=Cp(t.doc,n.from,-1),i==null)return!1;if(e){let o=t.tr.join(i);r&&o.setSelection(Ye.create(o.doc,i-t.doc.resolve(i).nodeBefore.nodeSize)),e(o.scrollIntoView())}return!0},HB=(t,e)=>{let n=t.selection,r;if(n instanceof Ye){if(n.node.isTextblock||!Ms(t.doc,n.to))return!1;r=n.to}else if(r=Cp(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},VB=(t,e)=>{let{$from:n,$to:r}=t.selection,i=n.blockRange(r),o=i&&Yl(i);return o==null?!1:(e&&e(t.tr.lift(i,o).scrollIntoView()),!0)},EE=(t,e)=>{let{$head:n,$anchor:r}=t.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(e&&e(t.tr.insertText(`
|
|
109
|
+
`).scrollIntoView()),!0)};function t1(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 UB=(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=t1(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(et.near(l.doc.resolve(a),1)),e(l.scrollIntoView())}return!0},AE=(t,e)=>{let n=t.selection,{$from:r,$to:i}=n;if(n instanceof _r||r.parent.inlineContent||i.parent.inlineContent)return!1;let o=t1(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(qe.create(a.doc,s+1)),e(a.scrollIntoView())}return!0},TE=(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(Co(t.doc,o))return e&&e(t.tr.split(o).scrollIntoView()),!0}let r=n.blockRange(),i=r&&Yl(r);return i==null?!1:(e&&e(t.tr.lift(r,i).scrollIntoView()),!0)};function jB(t){return(e,n)=>{let{$from:r,$to:i}=e.selection;if(e.selection instanceof Ye&&e.selection.node.isBlock)return!r.parentOffset||!Co(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,u=!1;for(let p=r.depth;;p--)if(r.node(p).isBlock){l=r.end(p)==r.pos+(r.depth-p),u=r.start(p)==r.pos-(r.depth-p),a=t1(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 c=e.tr;(e.selection instanceof qe||e.selection instanceof _r)&&c.deleteSelection();let f=c.mapping.map(r.pos),h=Co(c.doc,f,o.length,o);if(h||(o[0]=a?{type:a}:null,h=Co(c.doc,f,o.length,o)),!h)return!1;if(c.split(f,o.length,o),!l&&u&&r.node(s).type!=a){let p=c.mapping.map(r.before(s)),m=c.doc.resolve(p);a&&r.node(s-1).canReplaceWith(m.index(),m.index()+1,a)&&c.setNodeMarkup(c.mapping.map(r.before(s)),a)}return n&&n(c.scrollIntoView()),!0}}const qB=jB(),WB=(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(Ye.create(t.doc,i))),!0)};function KB(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||Ms(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function ME(t,e,n,r){let i=e.nodeBefore,o=e.nodeAfter,s,a,l=i.type.spec.isolating||o.type.spec.isolating;if(!l&&KB(t,e,n))return!0;let u=!l&&e.parent.canReplace(e.index(),e.index()+1);if(u&&(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=ge.empty;for(let b=s.length-1;b>=0;b--)m=ge.from(s[b].create(null,m));m=ge.from(i.copy(m));let v=t.tr.step(new En(e.pos-1,p,e.pos,p,new Te(m,1,0),s.length,!0)),g=v.doc.resolve(p+2*s.length);g.nodeAfter&&g.nodeAfter.type==i.type&&Ms(v.doc,g.pos)&&v.join(g.pos),n(v.scrollIntoView())}return!0}let c=o.type.spec.isolating||r>0&&l?null:et.findFrom(e,1),f=c&&c.$from.blockRange(c.$to),h=f&&Yl(f);if(h!=null&&h>=e.depth)return n&&n(t.tr.lift(f,h).scrollIntoView()),!0;if(u&&jl(o,"start",!0)&&jl(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=ge.empty;for(let _=m.length-1;_>=0;_--)b=ge.from(m[_].copy(b));let x=t.tr.step(new En(e.pos-m.length,e.pos+o.nodeSize,e.pos+g,e.pos+o.nodeSize-g,new Te(b,m.length,0),0,!0));n(x.scrollIntoView())}return!0}}return!1}function DE(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(qe.create(e.doc,t<0?i.start(o):i.end(o)))),!0):!1}}const GB=DE(-1),ZB=DE(1);function JB(t,e=null){return function(n,r){let{$from:i,$to:o}=n.selection,s=i.blockRange(o),a=s&&rb(s,t,e);return a?(r&&r(n.tr.wrap(s,a).scrollIntoView()),!0):!1}}function _2(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,u)=>{if(i)return!1;if(!(!l.isTextblock||l.hasMarkup(t,e)))if(l.type==t)i=!0;else{let c=n.doc.resolve(u),f=c.index();i=c.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 n1(...t){return function(e,n,r){for(let i=0;i<t.length;i++)if(t[i](e,n,r))return!0;return!1}}n1(Qb,wE,xE);n1(Qb,CE,SE);n1(EE,AE,TE,qB);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function YB(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 XB(a,s,t,e)?(r&&r(a.scrollIntoView()),!0):!1}}function XB(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 eh(l,l,e.depth),e.endIndex<e.parent.childCount&&(e=new eh(e.$from,s.resolve(e.$to.end(e.depth)),e.depth)),i=!0}let a=rb(o,n,r,e);return a?(t&&QB(t,e,a,i,n),!0):!1}function QB(t,e,n,r,i){let o=ge.empty;for(let c=n.length-1;c>=0;c--)o=ge.from(n[c].type.create(n[c].attrs,o));t.step(new En(e.start-(r?2:0),e.end,e.start,e.end,new Te(o,0,0),n.length,!0));let s=0;for(let c=0;c<n.length;c++)n[c].type==i&&(s=c+1);let a=n.length-s,l=e.start+n.length-(r?2:0),u=e.parent;for(let c=e.startIndex,f=e.endIndex,h=!0;c<f;c++,h=!1)!h&&Co(t.doc,l,a)&&(t.split(l,a),l+=2*a),l+=u.child(c).nodeSize;return t}function $B(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?eH(e,n,t,o):tH(e,n,o):!0:!1}}function eH(t,e,n,r){let i=t.tr,o=r.end,s=r.$to.end(r.depth);o<s&&(i.step(new En(o-1,s,o,s,new Te(ge.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new eh(i.doc.resolve(r.$from.pos),i.doc.resolve(s),r.depth));const a=Yl(r);if(a==null)return!1;i.lift(r,a);let l=i.doc.resolve(i.mapping.map(o,-1)-1);return Ms(i.doc,l.pos)&&l.nodeBefore.type==l.nodeAfter.type&&i.join(l.pos),e(i.scrollIntoView()),!0}function tH(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,u=o.node(-1),c=o.index(-1);if(!u.canReplace(c+(a?0:1),c+1,s.content.append(l?ge.empty:ge.from(i))))return!1;let f=o.pos,h=f+s.nodeSize;return r.step(new En(f-(a?1:0),h+(l?1:0),f+1,h-1,new Te((a?ge.empty:ge.from(i.copy(ge.empty))).append(l?ge.empty:ge.from(i.copy(ge.empty))),a?0:1,l?0:1),a?0:1)),e(r.scrollIntoView()),!0}function nH(t){return function(e,n){let{$from:r,$to:i}=e.selection,o=r.blockRange(i,u=>u.childCount>0&&u.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 u=l.lastChild&&l.lastChild.type==a.type,c=ge.from(u?t.create():null),f=new Te(ge.from(t.create(null,ge.from(a.type.create(null,c)))),u?3:1,0),h=o.start,p=o.end;n(e.tr.step(new En(h-(u?3:1),p,h,p,f,1,!0)).scrollIntoView())}return!0}}function Jp(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 Yp{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,(...c)=>{const f=l(...c)(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,u=e||o.tr,c=()=>(!l&&n&&!u.getMeta("preventDispatch")&&!this.hasCustomState&&s.dispatch(u),a.every(h=>h===!0)),f={...Object.fromEntries(Object.entries(r).map(([h,p])=>[h,(...v)=>{const g=this.buildProps(u,n),b=p(...v)(g);return a.push(b),f}])),run:c};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,u])=>[l,(...c)=>u(...c)({...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:Jp({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,u])=>[l,(...c)=>u(...c)(a)]))}};return a}}class rH{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 Fe(t,e,n){return t.config[e]===void 0&&t.parent?Fe(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?Fe(t.parent,e,n):null}):t.config[e]}function Xp(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 OE(t){const e=[],{nodeExtensions:n,markExtensions:r}=Xp(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=Fe(s,"addGlobalAttributes",a);if(!l)return;l().forEach(c=>{c.types.forEach(f=>{Object.entries(c.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=Fe(s,"addAttributes",a);if(!l)return;const u=l();Object.entries(u).forEach(([c,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:c,attribute:h})})}),e}function Dn(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 ln(...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(" "):[],u=a.filter(c=>!l.includes(c));r[i]=[...l,...u].join(" ")}else if(i==="style"){const a=o?o.split(";").map(c=>c.trim()).filter(Boolean):[],l=r[i]?r[i].split(";").map(c=>c.trim()).filter(Boolean):[],u=new Map;l.forEach(c=>{const[f,h]=c.split(":").map(p=>p.trim());u.set(f,h)}),a.forEach(c=>{const[f,h]=c.split(":").map(p=>p.trim());u.set(f,h)}),r[i]=Array.from(u.entries()).map(([c,f])=>`${c}: ${f}`).join("; ")}else r[i]=o}),r},{})}function rv(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)=>ln(n,r),{})}function IE(t){return typeof t=="function"}function ft(t,e=void 0,...n){return IE(t)?e?t.bind(e)(...n):t(...n):t}function iH(t={}){return Object.keys(t).length===0&&t.constructor===Object}function oH(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function C2(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):oH(n.getAttribute(s.name));return a==null?o:{...o,[s.name]:a}},{});return{...r,...i}}}}function S2(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&iH(n)?!1:n!=null))}function sH(t,e){var n;const r=OE(t),{nodeExtensions:i,markExtensions:o}=Xp(t),s=(n=i.find(u=>Fe(u,"topNode")))===null||n===void 0?void 0:n.name,a=Object.fromEntries(i.map(u=>{const c=r.filter(b=>b.type===u.name),f={name:u.name,options:u.options,storage:u.storage,editor:e},h=t.reduce((b,x)=>{const _=Fe(x,"extendNodeSchema",f);return{...b,..._?_(u):{}}},{}),p=S2({...h,content:ft(Fe(u,"content",f)),marks:ft(Fe(u,"marks",f)),group:ft(Fe(u,"group",f)),inline:ft(Fe(u,"inline",f)),atom:ft(Fe(u,"atom",f)),selectable:ft(Fe(u,"selectable",f)),draggable:ft(Fe(u,"draggable",f)),code:ft(Fe(u,"code",f)),whitespace:ft(Fe(u,"whitespace",f)),linebreakReplacement:ft(Fe(u,"linebreakReplacement",f)),defining:ft(Fe(u,"defining",f)),isolating:ft(Fe(u,"isolating",f)),attrs:Object.fromEntries(c.map(b=>{var x;return[b.name,{default:(x=b==null?void 0:b.attribute)===null||x===void 0?void 0:x.default}]}))}),m=ft(Fe(u,"parseHTML",f));m&&(p.parseDOM=m.map(b=>C2(b,c)));const v=Fe(u,"renderHTML",f);v&&(p.toDOM=b=>v({node:b,HTMLAttributes:rv(b,c)}));const g=Fe(u,"renderText",f);return g&&(p.toText=g),[u.name,p]})),l=Object.fromEntries(o.map(u=>{const c=r.filter(g=>g.type===u.name),f={name:u.name,options:u.options,storage:u.storage,editor:e},h=t.reduce((g,b)=>{const x=Fe(b,"extendMarkSchema",f);return{...g,...x?x(u):{}}},{}),p=S2({...h,inclusive:ft(Fe(u,"inclusive",f)),excludes:ft(Fe(u,"excludes",f)),group:ft(Fe(u,"group",f)),spanning:ft(Fe(u,"spanning",f)),code:ft(Fe(u,"code",f)),attrs:Object.fromEntries(c.map(g=>{var b;return[g.name,{default:(b=g==null?void 0:g.attribute)===null||b===void 0?void 0:b.default}]}))}),m=ft(Fe(u,"parseHTML",f));m&&(p.parseDOM=m.map(g=>C2(g,c)));const v=Fe(u,"renderHTML",f);return v&&(p.toDOM=g=>v({mark:g,HTMLAttributes:rv(g,c)})),[u.name,p]}));return new eb({topNode:s,nodes:a,marks:l})}function ug(t,e){return e.nodes[t]||e.marks[t]||null}function E2(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function r1(t,e){const n=Da.fromSchema(e).serializeFragment(t),i=document.implementation.createHTMLDocument().createElement("div");return i.appendChild(n),i.innerHTML}const aH=(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,u;const c=((u=(l=i.type.spec).toText)===null||u===void 0?void 0:u.call(l,{node:i,pos:o,parent:s,index:a}))||i.textContent||"%leaf%";n+=i.isAtom&&!i.isText?c:c.slice(0,Math.max(0,r-o))}),n};function i1(t){return Object.prototype.toString.call(t)==="[object RegExp]"}class Qp{constructor(e){this.find=e.find,this.handler=e.handler}}const lH=(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 zd(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 u=l.state.doc.resolve(r);if(u.parent.type.spec.code||!((e=u.nodeBefore||u.nodeAfter)===null||e===void 0)&&e.marks.find(h=>h.type.spec.code))return!1;let c=!1;const f=aH(u)+o;return s.forEach(h=>{if(c)return;const p=lH(f,h.find);if(!p)return;const m=l.state.tr,v=Jp({state:l.state,transaction:m}),g={from:r-(p[0].length-o.length),to:i},{commands:b,chain:x,can:_}=new Yp({editor:n,state:v});h.handler({state:v,range:g,match:p,commands:b,chain:x,can:_})===null||!m.steps.length||(m.setMeta(a,{transform:m,from:r,to:i,text:o}),l.dispatch(m),c=!0)}),c}function uH(t){const{editor:e,rules:n}=t,r=new Dt({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:c}=l;typeof c=="string"?c=c:c=r1(ge.from(c),s.schema);const{from:f}=l,h=f+c.length;zd({editor:e,from:f,to:h,text:c,rules:n,plugin:r})}),i.selectionSet||i.docChanged?null:o}},props:{handleTextInput(i,o,s,a){return zd({editor:e,from:o,to:s,text:a,rules:n,plugin:r})},handleDOMEvents:{compositionend:i=>(setTimeout(()=>{const{$cursor:o}=i.state.selection;o&&zd({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?zd({editor:e,from:s.pos,to:s.pos,text:`
|
|
110
|
+
`,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function cH(t){return Object.prototype.toString.call(t).slice(8,-1)}function Bd(t){return cH(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function $p(t,e){const n={...t};return Bd(t)&&Bd(e)&&Object.keys(e).forEach(r=>{Bd(e[r])&&Bd(t[r])?n[r]=$p(t[r],e[r]):n[r]=e[r]}),n}class to{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=ft(Fe(this,"addOptions",{name:this.name}))),this.storage=ft(Fe(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new to(e)}configure(e={}){const n=this.extend({...this.config,addOptions:()=>$p(this.options,e)});return n.name=this.name,n.parent=this.parent,n}extend(e={}){const n=new to(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=ft(Fe(n,"addOptions",{name:n.name})),n.storage=ft(Fe(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(u=>(u==null?void 0:u.type.name)===n.name))return!1;const l=s.find(u=>(u==null?void 0:u.type.name)===n.name);return l&&r.removeStoredMark(l),r.insertText(" ",i.pos),e.view.dispatch(r),!0}return!1}}function dH(t){return typeof t=="number"}class fH{constructor(e){this.find=e.find,this.handler=e.handler}}const hH=(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 pH(t){const{editor:e,state:n,from:r,to:i,rule:o,pasteEvent:s,dropEvent:a}=t,{commands:l,chain:u,can:c}=new Yp({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,"");hH(b,o.find,s).forEach(_=>{if(_.index===void 0)return;const T=v+_.index+1,S=T+_[0].length,z={from:n.tr.mapping.map(T),to:n.tr.mapping.map(S)},E=o.handler({state:n,range:z,match:_,commands:l,chain:u,can:c,pasteEvent:s,dropEvent:a});f.push(E)})}),f.every(p=>p!==null)}let Hd=null;const mH=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 gH(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:c,from:f,to:h,rule:p,pasteEvt:m})=>{const v=c.tr,g=Jp({state:c,transaction:v});if(!(!pH({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(c=>new Dt({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&&(Hd=e)},p=()=>{Hd&&(Hd=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=Hd;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"),x=!!b;if(!v&&!g&&!x)return;if(x){let{text:S}=b;typeof S=="string"?S=S:S=r1(ge.from(S),p.schema);const{from:z}=b,E=z+S.length,D=mH(S);return l({rule:c,state:p,from:z,to:{b:E},pasteEvt:D})}const _=h.doc.content.findDiffStart(p.doc.content),T=h.doc.content.findDiffEnd(p.doc.content);if(!(!dH(_)||!T||_===T.b))return l({rule:c,state:p,from:_,to:T,pasteEvt:s})}}))}function vH(t){const e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}class Ya{constructor(e,n){this.splittableMarks=[],this.editor=n,this.extensions=Ya.resolve(e),this.schema=sH(this.extensions,n),this.setupExtensions()}static resolve(e){const n=Ya.sort(Ya.flatten(e)),r=vH(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=Fe(n,"addExtensions",r);return i?[n,...this.flatten(i())]:n}).flat(10)}static sort(e){return e.sort((r,i)=>{const o=Fe(r,"priority")||100,s=Fe(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:ug(n.name,this.schema)},i=Fe(n,"addCommands",r);return i?{...e,...i()}:e},{})}get plugins(){const{editor:e}=this,n=Ya.sort([...this.extensions].reverse()),r=[],i=[],o=n.map(s=>{const a={name:s.name,options:s.options,storage:s.storage,editor:e,type:ug(s.name,this.schema)},l=[],u=Fe(s,"addKeyboardShortcuts",a);let c={};if(s.type==="mark"&&Fe(s,"exitable",a)&&(c.ArrowRight=()=>to.handleExit({editor:e,mark:s})),u){const v=Object.fromEntries(Object.entries(u()).map(([g,b])=>[g,()=>b({editor:e})]));c={...c,...v}}const f=LB(c);l.push(f);const h=Fe(s,"addInputRules",a);E2(s,e.options.enableInputRules)&&h&&r.push(...h());const p=Fe(s,"addPasteRules",a);E2(s,e.options.enablePasteRules)&&p&&i.push(...p());const m=Fe(s,"addProseMirrorPlugins",a);if(m){const v=m();l.push(...v)}return l}).flat();return[uH({editor:e,rules:r}),...gH({editor:e,rules:i}),...o]}get attributes(){return OE(this.extensions)}get nodeViews(){const{editor:e}=this,{nodeExtensions:n}=Xp(this.extensions);return Object.fromEntries(n.filter(r=>!!Fe(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:Dn(r.name,this.schema)},s=Fe(r,"addNodeView",o);if(!s)return[];const a=(l,u,c,f,h)=>{const p=rv(l,i);return s()({node:l,view:u,getPos:c,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:ug(e.name,this.schema)};e.type==="mark"&&(!((n=ft(Fe(e,"keepOnSplit",r)))!==null&&n!==void 0)||n)&&this.splittableMarks.push(e.name);const i=Fe(e,"onBeforeCreate",r),o=Fe(e,"onCreate",r),s=Fe(e,"onUpdate",r),a=Fe(e,"onSelectionUpdate",r),l=Fe(e,"onTransaction",r),u=Fe(e,"onFocus",r),c=Fe(e,"onBlur",r),f=Fe(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),u&&this.editor.on("focus",u),c&&this.editor.on("blur",c),f&&this.editor.on("destroy",f)})}}class Kt{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=ft(Fe(this,"addOptions",{name:this.name}))),this.storage=ft(Fe(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new Kt(e)}configure(e={}){const n=this.extend({...this.config,addOptions:()=>$p(this.options,e)});return n.name=this.name,n.parent=this.parent,n}extend(e={}){const n=new Kt({...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=ft(Fe(n,"addOptions",{name:n.name})),n.storage=ft(Fe(n,"addStorage",{name:n.name,options:n.options})),n}}function RE(t,e,n){const{from:r,to:i}=e,{blockSeparator:o=`
|
|
111
|
+
|
|
112
|
+
`,textSerializers:s={}}=n||{};let a="";return t.nodesBetween(r,i,(l,u,c,f)=>{var h;l.isBlock&&u>r&&(a+=o);const p=s==null?void 0:s[l.type.name];if(p)return c&&(a+=p({node:l,pos:u,parent:c,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,u)-u,i-u))}),a}function NE(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}const bH=Kt.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new Dt({key:new Nt("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(c=>c.$from.pos)),a=Math.max(...o.map(c=>c.$to.pos)),l=NE(n);return RE(r,{from:s,to:a},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:l})}}})]}}),yH=()=>({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),wH=(t=!1)=>({commands:e})=>e.setContent("",t),kH=()=>({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:u,mapping:c}=e,f=u.resolve(c.map(l)),h=u.resolve(c.map(l+a.nodeSize)),p=f.blockRange(h);if(!p)return;const m=Yl(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},xH=t=>e=>t(e),_H=()=>({state:t,dispatch:e})=>AE(t,e),CH=(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 qe(r.doc.resolve(Math.max(s-1,0)))),!0},SH=()=>({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},EH=t=>({tr:e,state:n,dispatch:r})=>{const i=Dn(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),u=o.after(s);e.delete(l,u).scrollIntoView()}return!0}return!1},AH=t=>({tr:e,dispatch:n})=>{const{from:r,to:i}=t;return n&&e.delete(r,i),!0},TH=()=>({state:t,dispatch:e})=>Qb(t,e),MH=()=>({commands:t})=>t.keyboardShortcut("Enter"),DH=()=>({state:t,dispatch:e})=>UB(t,e);function Sh(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 PE(t,e,n={}){return t.find(r=>r.type===e&&Sh(Object.fromEntries(Object.keys(n).map(i=>[i,r.attrs[i]])),n))}function A2(t,e,n={}){return!!PE(t,e,n)}function o1(t,e,n){var r;if(!t||!e)return;let i=t.parent.childAfter(t.parentOffset);if((!i.node||!i.node.marks.some(c=>c.type===e))&&(i=t.parent.childBefore(t.parentOffset)),!i.node||!i.node.marks.some(c=>c.type===e)||(n=n||((r=i.node.marks[0])===null||r===void 0?void 0:r.attrs),!PE([...i.node.marks],e,n)))return;let s=i.index,a=t.start()+i.offset,l=s+1,u=a+i.node.nodeSize;for(;s>0&&A2([...t.parent.child(s-1).marks],e,n);)s-=1,a-=t.parent.child(s).nodeSize;for(;l<t.parent.childCount&&A2([...t.parent.child(l).marks],e,n);)u+=t.parent.child(l).nodeSize,l+=1;return{from:a,to:u}}function Os(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 OH=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const o=Os(t,r.schema),{doc:s,selection:a}=n,{$from:l,from:u,to:c}=a;if(i){const f=o1(l,o,e);if(f&&f.from<=u&&f.to>=c){const h=qe.create(s,f.from,f.to);n.setSelection(h)}}return!0},IH=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 LE(t){return t instanceof qe}function Ks(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function FE(t,e=null){if(!e)return null;const n=et.atStart(t),r=et.atEnd(t);if(e==="start"||e===!0)return n;if(e==="end")return r;const i=n.from,o=r.to;return e==="all"?qe.create(t,Ks(0,i,o),Ks(t.content.size,i,o)):qe.create(t,Ks(e,i,o),Ks(e,i,o))}function T2(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function Eh(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function RH(){return typeof navigator<"u"?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}const NH=(t=null,e={})=>({editor:n,view:r,tr:i,dispatch:o})=>{e={scrollIntoView:!0,...e};const s=()=>{(Eh()||T2())&&r.dom.focus(),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),RH()&&!Eh()&&!T2()&&r.dom.focus({preventScroll:!0}))})};if(r.hasFocus()&&t===null||t===!1)return!0;if(o&&t===null&&!LE(n.state.selection))return s(),!0;const a=FE(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},PH=(t,e)=>n=>t.every((r,i)=>e(r,{...n,index:i})),LH=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),zE=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&&zE(r)}return t};function Vd(t){const e=`<body>${t}</body>`,n=new window.DOMParser().parseFromString(e,"text/html").body;return zE(n)}function Ic(t,e,n){if(t instanceof hs||t instanceof ge)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 ge.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),Ic("",e,n)}if(i){if(n.errorOnInvalidContent){let s=!1,a="";const l=new eb({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:u=>(s=!0,a=typeof u=="string"?u:u.outerHTML,null)}]}})});if(n.slice?Pu.fromSchema(l).parseSlice(Vd(t),n.parseOptions):Pu.fromSchema(l).parse(Vd(t),n.parseOptions),n.errorOnInvalidContent&&s)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${a}`)})}const o=Pu.fromSchema(e);return n.slice?o.parseSlice(Vd(t),n.parseOptions).content:o.parse(Vd(t),n.parseOptions)}return Ic("",e,n)}function FH(t,e,n){const r=t.steps.length-1;if(r<e)return;const i=t.steps[r];if(!(i instanceof _n||i instanceof En))return;const o=t.mapping.maps[r];let s=0;o.forEach((a,l,u,c)=>{s===0&&(s=c)}),t.setSelection(et.near(t.doc.resolve(s),n))}const zH=t=>!("type"in t),BH=(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)}})},u={preserveWhitespace:"full",...n.parseOptions};if(!n.errorOnInvalidContent&&!o.options.enableContentCheck&&o.options.emitContentError)try{Ic(e,o.schema,{parseOptions:u,errorOnInvalidContent:!0})}catch(g){l(g)}try{a=Ic(e,o.schema,{parseOptions:u,errorOnInvalidContent:(s=n.errorOnInvalidContent)!==null&&s!==void 0?s:o.options.enableContentCheck})}catch(g){return l(g),!1}let{from:c,to:f}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},h=!0,p=!0;if((zH(a)?a:[a]).forEach(g=>{g.check(),h=h?g.isText&&g.marks.length===0:!1,p=p?g.isBlock:!1}),c===f&&p){const{parent:g}=r.doc.resolve(c);g.isTextblock&&!g.type.spec.code&&!g.childCount&&(c-=1,f+=1)}let v;if(h){if(Array.isArray(e))v=e.map(g=>g.text||"").join("");else if(e instanceof ge){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,c,f)}else v=a,r.replaceWith(c,f,v);n.updateSelection&&FH(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:c,text:v}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:c,text:v})}return!0},HH=()=>({state:t,dispatch:e})=>BB(t,e),VH=()=>({state:t,dispatch:e})=>HB(t,e),UH=()=>({state:t,dispatch:e})=>wE(t,e),jH=()=>({state:t,dispatch:e})=>CE(t,e),qH=()=>({state:t,dispatch:e,tr:n})=>{try{const r=Cp(t.doc,t.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},WH=()=>({state:t,dispatch:e,tr:n})=>{try{const r=Cp(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},KH=()=>({state:t,dispatch:e})=>FB(t,e),GH=()=>({state:t,dispatch:e})=>zB(t,e);function BE(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function ZH(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))Eh()||BE()?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 JH=t=>({editor:e,view:n,tr:r,dispatch:i})=>{const o=ZH(t).split(/-(?!$)/),s=o.find(u=>!["Alt","Ctrl","Meta","Shift"].includes(u)),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",u=>u(n,a))});return l==null||l.steps.forEach(u=>{const c=u.map(r.mapping);c&&i&&r.maybeStep(c)}),!0};function Rc(t,e,n={}){const{from:r,to:i,empty:o}=t.selection,s=e?Dn(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,u=a.filter(f=>s?s.name===f.node.type.name:!0).filter(f=>Sh(f.node.attrs,n,{strict:!1}));return o?!!u.length:u.reduce((f,h)=>f+h.to-h.from,0)>=l}const YH=(t,e={})=>({state:n,dispatch:r})=>{const i=Dn(t,n.schema);return Rc(n,i,e)?VB(n,r):!1},XH=()=>({state:t,dispatch:e})=>TE(t,e),QH=t=>({state:e,dispatch:n})=>{const r=Dn(t,e.schema);return $B(r)(e,n)},$H=()=>({state:t,dispatch:e})=>EE(t,e);function em(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function M2(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 eV=(t,e)=>({tr:n,state:r,dispatch:i})=>{let o=null,s=null;const a=em(typeof t=="string"?t:t.name,r.schema);return a?(a==="node"&&(o=Dn(t,r.schema)),a==="mark"&&(s=Os(t,r.schema)),i&&n.selection.ranges.forEach(l=>{r.doc.nodesBetween(l.$from.pos,l.$to.pos,(u,c)=>{o&&o===u.type&&n.setNodeMarkup(c,void 0,M2(u.attrs,e)),s&&u.marks.length&&u.marks.forEach(f=>{s===f.type&&n.addMark(c,c+u.nodeSize,s.create(M2(f.attrs,e)))})})}),!0):!1},tV=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),nV=()=>({tr:t,dispatch:e})=>{if(e){const n=new _r(t.doc);t.setSelection(n)}return!0},rV=()=>({state:t,dispatch:e})=>xE(t,e),iV=()=>({state:t,dispatch:e})=>SE(t,e),oV=()=>({state:t,dispatch:e})=>WB(t,e),sV=()=>({state:t,dispatch:e})=>ZB(t,e),aV=()=>({state:t,dispatch:e})=>GB(t,e);function iv(t,e,n={},r={}){return Ic(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}const lV=(t,e=!1,n={},r={})=>({editor:i,tr:o,dispatch:s,commands:a})=>{var l,u;const{doc:c}=o;if(n.preserveWhitespace!=="full"){const f=iv(t,i.schema,n,{errorOnInvalidContent:(l=r.errorOnInvalidContent)!==null&&l!==void 0?l:i.options.enableContentCheck});return s&&o.replaceWith(0,c.content.size,f).setMeta("preventUpdate",!e),!0}return s&&o.setMeta("preventUpdate",!e),a.insertContentAt({from:0,to:c.content.size},t,{parseOptions:n,errorOnInvalidContent:(u=r.errorOnInvalidContent)!==null&&u!==void 0?u:i.options.enableContentCheck})};function HE(t,e){const n=Os(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 uV(t,e){const n=new ib(t);return e.forEach(r=>{r.steps.forEach(i=>{n.step(i)})}),n}function cV(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 dV(t,e,n){const r=[];return t.nodesBetween(e.from,e.to,(i,o)=>{n(i)&&r.push({node:i,pos:o})}),r}function VE(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 s1(t){return e=>VE(e.$from,t)}function fV(t,e){const n={from:0,to:t.content.size};return RE(t,n,e)}function hV(t,e){const n=Dn(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 UE(t,e){const n=em(typeof e=="string"?e:e.name,t.schema);return n==="node"?hV(t,e):n==="mark"?HE(t,e):{}}function pV(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 mV(t){const e=pV(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 gV(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 u=e.slice(o).map(a,-1),c=e.slice(o).map(l),f=e.invert().map(u,-1),h=e.invert().map(c);r.push({oldRange:{from:f,to:h},newRange:{from:u,to:c}})})}),mV(r)}function a1(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(i=>{const o=n.resolve(t),s=o1(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 Df(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 ov(t,e,n={}){const{empty:r,ranges:i}=t.selection,o=e?Os(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(f=>o?o.name===f.type.name:!0).find(f=>Sh(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),x=Math.min(m,g+v.nodeSize),_=x-b;s+=_,a.push(...v.marks.map(T=>({mark:T,from:b,to:x})))})}),s===0)return!1;const l=a.filter(f=>o?o.name===f.mark.type.name:!0).filter(f=>Sh(f.mark.attrs,n,{strict:!1})).reduce((f,h)=>f+h.to-h.from,0),u=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+u:l)>=s}function vV(t,e,n={}){if(!e)return Rc(t,null,n)||ov(t,null,n);const r=em(e,t.schema);return r==="node"?Rc(t,e,n):r==="mark"?ov(t,e,n):!1}function D2(t,e){const{nodeExtensions:n}=Xp(e),r=n.find(s=>s.name===t);if(!r)return!1;const i={name:r.name,options:r.options,storage:r.storage},o=ft(Fe(r,"group",i));return typeof o!="string"?!1:o.split(" ").includes("list")}function tm(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&&(tm(o,{ignoreWhitespace:n,checkChildren:e})||(i=!1))}),i}return!1}function bV(t){return t instanceof Ye}function yV(t,e,n){var r;const{selection:i}=e;let o=null;if(LE(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 u=a.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(n):!1;return t.doc.nodesBetween(a.pos,l.pos,(c,f,h)=>{if(u)return!1;if(c.isInline){const p=!h||h.type.allowsMarkType(n),m=!!n.isInSet(c.marks)||!c.marks.some(v=>v.type.excludes(n));u=p&&m}return!u}),u})}const wV=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const{selection:o}=n,{empty:s,ranges:a}=o,l=Os(t,r.schema);if(i)if(s){const u=HE(r,l);n.addStoredMark(l.create({...u,...e}))}else a.forEach(u=>{const c=u.$from.pos,f=u.$to.pos;r.doc.nodesBetween(c,f,(h,p)=>{const m=Math.max(p,c),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 yV(r,n,l)},kV=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),xV=(t,e={})=>({state:n,dispatch:r,chain:i})=>{const o=Dn(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})=>_2(o,{...s,...e})(n)?!0:a.clearNodes()).command(({state:a})=>_2(o,{...s,...e})(a,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},_V=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,i=Ks(t,0,r.content.size),o=Ye.create(r,i);e.setSelection(o)}return!0},CV=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:i,to:o}=typeof t=="number"?{from:t,to:t}:t,s=qe.atStart(r).from,a=qe.atEnd(r).to,l=Ks(i,s,a),u=Ks(o,s,a),c=qe.create(r,l,u);e.setSelection(c)}return!0},SV=t=>({state:e,dispatch:n})=>{const r=Dn(t,e.schema);return nH(r)(e,n)};function O2(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 EV=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:i})=>{const{selection:o,doc:s}=e,{$from:a,$to:l}=o,u=i.extensionManager.attributes,c=Df(u,a.node().type.name,a.node().attrs);if(o instanceof Ye&&o.node.isBlock)return!a.parentOffset||!Co(s,a.pos)?!1:(r&&(t&&O2(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:cV(a.node(-1).contentMatchAt(a.indexAfter(-1)));let p=f&&h?[{type:h,attrs:c}]:void 0,m=Co(e.doc,e.mapping.map(a.pos),1,p);if(!p&&!m&&Co(e.doc,e.mapping.map(a.pos),1,h?[{type:h}]:void 0)&&(m=!0,p=h?[{type:h,attrs:c}]:void 0),r){if(m&&(o instanceof qe&&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&&O2(n,i.extensionManager.splittableMarks),e.scrollIntoView()}return m},AV=(t,e={})=>({tr:n,state:r,dispatch:i,editor:o})=>{var s;const a=Dn(t,r.schema),{$from:l,$to:u}=r.selection,c=r.selection.node;if(c&&c.isBlock||l.depth<2||!l.sameParent(u))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=ge.empty;const x=l.index(-1)?1:l.index(-2)?2:3;for(let D=l.depth-x;D>=l.depth-3;D-=1)b=ge.from(l.node(D).copy(b));const _=l.indexAfter(-1)<l.node(-2).childCount?1:l.indexAfter(-2)<l.node(-3).childCount?2:3,T={...Df(h,l.node().type.name,l.node().attrs),...e},S=((s=a.contentMatch.defaultType)===null||s===void 0?void 0:s.createAndFill(T))||void 0;b=b.append(ge.from(a.createAndFill(null,S)||void 0));const z=l.before(l.depth-(x-1));n.replace(z,l.after(-_),new Te(b,4-x,0));let E=-1;n.doc.nodesBetween(z,n.doc.content.size,(D,P)=>{if(E>-1)return!1;D.isTextblock&&D.content.size===0&&(E=P+1)}),E>-1&&n.setSelection(qe.near(n.doc.resolve(E))),n.scrollIntoView()}return!0}const p=u.pos===l.end()?f.contentMatchAt(0).defaultType:null,m={...Df(h,f.type.name,f.attrs),...e},v={...Df(h,l.node().type.name,l.node().attrs),...e};n.delete(l.pos,u.pos);const g=p?[{type:a,attrs:m},{type:p,attrs:v}]:[{type:a,attrs:m}];if(!Co(n.doc,l.pos,2))return!1;if(i){const{selection:b,storedMarks:x}=r,{splittableMarks:_}=o.extensionManager,T=x||b.$to.parentOffset&&b.$from.marks();if(n.split(l.pos,2,g).scrollIntoView(),!T||!i)return!0;const S=T.filter(z=>_.includes(z.type.name));n.ensureMarks(S)}return!0},cg=(t,e)=>{const n=s1(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)&&Ms(t.doc,n.pos)&&t.join(n.pos),!0},dg=(t,e)=>{const n=s1(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)&&Ms(t.doc,r)&&t.join(r),!0},TV=(t,e,n,r={})=>({editor:i,tr:o,state:s,dispatch:a,chain:l,commands:u,can:c})=>{const{extensions:f,splittableMarks:h}=i.extensionManager,p=Dn(t,s.schema),m=Dn(e,s.schema),{selection:v,storedMarks:g}=s,{$from:b,$to:x}=v,_=b.blockRange(x),T=g||v.$to.parentOffset&&v.$from.marks();if(!_)return!1;const S=s1(z=>D2(z.type.name,f))(v);if(_.depth>=1&&S&&_.depth-S.depth<=1){if(S.node.type===p)return u.liftListItem(m);if(D2(S.node.type.name,f)&&p.validContent(S.node.content)&&a)return l().command(()=>(o.setNodeMarkup(S.pos,p),!0)).command(()=>cg(o,p)).command(()=>dg(o,p)).run()}return!n||!T||!a?l().command(()=>c().wrapInList(p,r)?!0:u.clearNodes()).wrapInList(p,r).command(()=>cg(o,p)).command(()=>dg(o,p)).run():l().command(()=>{const z=c().wrapInList(p,r),E=T.filter(D=>h.includes(D.type.name));return o.ensureMarks(E),z?!0:u.clearNodes()}).wrapInList(p,r).command(()=>cg(o,p)).command(()=>dg(o,p)).run()},MV=(t,e={},n={})=>({state:r,commands:i})=>{const{extendEmptyMarkRange:o=!1}=n,s=Os(t,r.schema);return ov(r,s,e)?i.unsetMark(s,{extendEmptyMarkRange:o}):i.setMark(s,e)},DV=(t,e,n={})=>({state:r,commands:i})=>{const o=Dn(t,r.schema),s=Dn(e,r.schema),a=Rc(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})},OV=(t,e={})=>({state:n,commands:r})=>{const i=Dn(t,n.schema);return Rc(n,i,e)?r.lift(i):r.wrapIn(i,e)},IV=()=>({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},RV=()=>({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},NV=(t,e={})=>({tr:n,state:r,dispatch:i})=>{var o;const{extendEmptyMarkRange:s=!1}=e,{selection:a}=n,l=Os(t,r.schema),{$from:u,empty:c,ranges:f}=a;if(!i)return!0;if(c&&s){let{from:h,to:p}=a;const m=(o=u.marks().find(g=>g.type===l))===null||o===void 0?void 0:o.attrs,v=o1(u,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},PV=(t,e={})=>({tr:n,state:r,dispatch:i})=>{let o=null,s=null;const a=em(typeof t=="string"?t:t.name,r.schema);return a?(a==="node"&&(o=Dn(t,r.schema)),a==="mark"&&(s=Os(t,r.schema)),i&&n.selection.ranges.forEach(l=>{const u=l.$from.pos,c=l.$to.pos;let f,h,p,m;n.selection.empty?r.doc.nodesBetween(u,c,(v,g)=>{o&&o===v.type&&(p=Math.max(g,u),m=Math.min(g+v.nodeSize,c),f=g,h=v)}):r.doc.nodesBetween(u,c,(v,g)=>{g<u&&o&&o===v.type&&(p=Math.max(g,u),m=Math.min(g+v.nodeSize,c),f=g,h=v),g>=u&&g<=c&&(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 x=Math.max(g,u),_=Math.min(g+v.nodeSize,c);n.addMark(x,_,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},LV=(t,e={})=>({state:n,dispatch:r})=>{const i=Dn(t,n.schema);return JB(i,e)(n,r)},FV=(t,e={})=>({state:n,dispatch:r})=>{const i=Dn(t,n.schema);return YB(i,e)(n,r)};var zV=Object.freeze({__proto__:null,blur:yH,clearContent:wH,clearNodes:kH,command:xH,createParagraphNear:_H,cut:CH,deleteCurrentNode:SH,deleteNode:EH,deleteRange:AH,deleteSelection:TH,enter:MH,exitCode:DH,extendMarkRange:OH,first:IH,focus:NH,forEach:PH,insertContent:LH,insertContentAt:BH,joinBackward:UH,joinDown:VH,joinForward:jH,joinItemBackward:qH,joinItemForward:WH,joinTextblockBackward:KH,joinTextblockForward:GH,joinUp:HH,keyboardShortcut:JH,lift:YH,liftEmptyBlock:XH,liftListItem:QH,newlineInCode:$H,resetAttributes:eV,scrollIntoView:tV,selectAll:nV,selectNodeBackward:rV,selectNodeForward:iV,selectParentNode:oV,selectTextblockEnd:sV,selectTextblockStart:aV,setContent:lV,setMark:wV,setMeta:kV,setNode:xV,setNodeSelection:_V,setTextSelection:CV,sinkListItem:SV,splitBlock:EV,splitListItem:AV,toggleList:TV,toggleMark:MV,toggleNode:DV,toggleWrap:OV,undoInputRule:IV,unsetAllMarks:RV,unsetMark:NV,updateAttributes:PV,wrapIn:LV,wrapInList:FV});const BV=Kt.create({name:"commands",addCommands(){return{...zV}}}),HV=Kt.create({name:"drop",addProseMirrorPlugins(){return[new Dt({key:new Nt("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),VV=Kt.create({name:"editable",addProseMirrorPlugins(){return[new Dt({key:new Nt("editable"),props:{editable:()=>this.editor.options.editable}})]}}),UV=new Nt("focusEvents"),jV=Kt.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new Dt({key:UV,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}}}})]}}),qV=Kt.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first(({commands:s})=>[()=>s.undoInputRule(),()=>s.command(({tr:a})=>{const{selection:l,doc:u}=a,{empty:c,$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:et.atStart(u).from===h;return!c||!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 Eh()||BE()?o:i},addProseMirrorPlugins(){return[new Dt({key:new Nt("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=et.atStart(e.doc).from,u=et.atEnd(e.doc).to;if(o||!(s===l&&a===u)||!tm(n.doc))return;const h=n.tr,p=Jp({state:n,transaction:h}),{commands:m}=new Yp({editor:this.editor,state:p});if(m.clearNodes(),!!h.steps.length)return h}})]}}),WV=Kt.create({name:"paste",addProseMirrorPlugins(){return[new Dt({key:new Nt("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),KV=Kt.create({name:"tabindex",addProseMirrorPlugins(){return[new Dt({key:new Nt("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}});class Bs{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 Bs(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 Bs(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 Bs(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 Bs(a,this.editor,i,i?n:null);i&&(l.actualDepth=this.depth+1),e.push(new Bs(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 GV=`.ProseMirror {
|
|
113
|
+
position: relative;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.ProseMirror {
|
|
117
|
+
word-wrap: break-word;
|
|
118
|
+
white-space: pre-wrap;
|
|
119
|
+
white-space: break-spaces;
|
|
120
|
+
-webkit-font-variant-ligatures: none;
|
|
121
|
+
font-variant-ligatures: none;
|
|
122
|
+
font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.ProseMirror [contenteditable="false"] {
|
|
126
|
+
white-space: normal;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.ProseMirror [contenteditable="false"] [contenteditable="true"] {
|
|
130
|
+
white-space: pre-wrap;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
.ProseMirror pre {
|
|
134
|
+
white-space: pre-wrap;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
img.ProseMirror-separator {
|
|
138
|
+
display: inline !important;
|
|
139
|
+
border: none !important;
|
|
140
|
+
margin: 0 !important;
|
|
141
|
+
width: 0 !important;
|
|
142
|
+
height: 0 !important;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
.ProseMirror-gapcursor {
|
|
146
|
+
display: none;
|
|
147
|
+
pointer-events: none;
|
|
148
|
+
position: absolute;
|
|
149
|
+
margin: 0;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
.ProseMirror-gapcursor:after {
|
|
153
|
+
content: "";
|
|
154
|
+
display: block;
|
|
155
|
+
position: absolute;
|
|
156
|
+
top: -2px;
|
|
157
|
+
width: 20px;
|
|
158
|
+
border-top: 1px solid black;
|
|
159
|
+
animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
@keyframes ProseMirror-cursor-blink {
|
|
163
|
+
to {
|
|
164
|
+
visibility: hidden;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
.ProseMirror-hideselection *::selection {
|
|
169
|
+
background: transparent;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
.ProseMirror-hideselection *::-moz-selection {
|
|
173
|
+
background: transparent;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
.ProseMirror-hideselection * {
|
|
177
|
+
caret-color: transparent;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
.ProseMirror-focused .ProseMirror-gapcursor {
|
|
181
|
+
display: block;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
.tippy-box[data-animation=fade][data-state=hidden] {
|
|
185
|
+
opacity: 0
|
|
186
|
+
}`;function ZV(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 JV=class extends rH{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=ZV(GV,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=IE(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?[VV,bH.configure({blockSeparator:(n=(e=this.options.coreExtensionOptions)===null||e===void 0?void 0:e.clipboardTextSerializer)===null||n===void 0?void 0:n.blockSeparator}),BV,jV,qV,KV,HV,WV].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 Ya(i,this)}createCommandManager(){this.commandManager=new Yp({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createView(){var e;let n;try{n=iv(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=iv(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}const r=FE(n,this.options.autofocus);this.view=new bE(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:Za.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 UE(this.state,e)}isActive(e,n){const r=typeof e=="string"?e:null,i=typeof e=="string"?n:e;return vV(this.state,r,i)}getJSON(){return this.state.doc.toJSON()}getHTML(){return r1(this.state.doc.content,this.schema)}getText(e){const{blockSeparator:n=`
|
|
187
|
+
|
|
188
|
+
`,textSerializers:r={}}=e||{};return fV(this.state.doc,{blockSeparator:n,textSerializers:{...NE(this.schema),...r}})}get isEmpty(){return tm(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 Bs(n,this)}get $doc(){return this.$pos(0)}};function _a(t){return new Qp({find:t.find,handler:({state:e,range:n,match:r})=>{const i=ft(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/),u=n.from+a.indexOf(s),c=u+s.length;if(a1(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>u).length)return null;c<n.to&&o.delete(c,n.to),u>n.from&&o.delete(n.from+l,u);const h=n.from+l+s.length;o.addMark(n.from+l,h,t.type.create(i||{})),o.removeStoredMark(t.type)}}})}function YV(t){return new Qp({find:t.find,handler:({state:e,range:n,match:r})=>{const i=ft(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 u=r[0].lastIndexOf(r[1]);let c=s+u;c>a?c=a:a=c+r[1].length;const f=r[0][r[0].length-1];o.insertText(f,s+r[0].length-1),o.replaceWith(c,a,l)}else if(r[0]){const u=t.type.isInline?s:s-1;o.insert(u,t.type.create(i)).delete(o.mapping.map(s),o.mapping.map(a))}o.scrollIntoView()}})}function sv(t){return new Qp({find:t.find,handler:({state:e,range:n,match:r})=>{const i=e.doc.resolve(n.from),o=ft(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 Nc(t){return new Qp({find:t.find,handler:({state:e,range:n,match:r,chain:i})=>{const o=ft(t.getAttributes,void 0,r)||{},s=e.tr.delete(n.from,n.to),l=s.doc.resolve(n.from).blockRange(),u=l&&rb(l,t.type,o);if(!u)return null;if(s.wrap(l,u),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 c=s.doc.resolve(n.from-1).nodeBefore;c&&c.type===t.type&&Ms(s.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,c))&&s.join(n.from-1)}})}let hr=class av{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=ft(Fe(this,"addOptions",{name:this.name}))),this.storage=ft(Fe(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new av(e)}configure(e={}){const n=this.extend({...this.config,addOptions:()=>$p(this.options,e)});return n.name=this.name,n.parent=this.parent,n}extend(e={}){const n=new av(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=ft(Fe(n,"addOptions",{name:n.name})),n.storage=ft(Fe(n,"addStorage",{name:n.name,options:n.options})),n}};function As(t){return new fH({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:i})=>{const o=ft(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 u=n.to;if(a){const c=l.search(/\S/),f=n.from+l.indexOf(a),h=f+a.length;if(a1(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+c,f),u=n.from+c+a.length,s.addMark(n.from+c,u,t.type.create(o||{})),s.removeStoredMark(t.type)}}})}function XV(t,e){const{selection:n}=t,{$from:r}=n;if(n instanceof Ye){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 QV=()=>{let t=!0;return(e,n)=>{if(t){t=!1;try{e()}finally{t=!0}}else n!==void 0&&n()}},$V=/[\uD800-\uDBFF]/,eU=/[\uDC00-\uDFFF]/,tU=(t,e)=>{let n=0,r=0;for(;n<t.length&&n<e.length&&t[n]===e[n];)n++;for(n>0&&$V.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&&eU.test(t[t.length-r])&&r--,{index:n,remove:t.length-n-r,insert:e.slice(n,e.length-r)}},nU=tU,Xt=new Nt("y-sync"),Gi=new Nt("y-undo"),Ud=new Nt("yjs-cursor"),Zi=(t,e)=>t>>>e|t<<32-e,rU=t=>Zi(t,2)^Zi(t,13)^Zi(t,22),iU=t=>Zi(t,6)^Zi(t,11)^Zi(t,25),oU=t=>Zi(t,7)^Zi(t,18)^t>>>3,sU=t=>Zi(t,17)^Zi(t,19)^t>>>10,aU=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]),lU=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);class uU{constructor(){const e=new ArrayBuffer(320);this._H=new Uint32Array(e,0,8),this._H.set(lU),this._W=new Uint32Array(e,64,64)}_updateHash(){const e=this._H,n=this._W;for(let f=16;f<64;f++)n[f]=sU(n[f-2])+n[f-7]+oU(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],u=e[6],c=e[7];for(let f=0,h,p;f<64;f++)h=c+iU(a)+(a&l^~a&u)+aU[f]+n[f]>>>0,p=rU(r)+(r&i^r&o^i&o)>>>0,c=u,u=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]+=u,e[7]+=c}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]|=ur<<(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)]|=ur<<(3-n%4)*8),this._W[14]=e.byteLength/x8,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 cU=t=>new uU().digest(t),dU=t=>{for(let n=6;n<t.length;n++)t[n%6]=t[n%6]^t[n];return t.slice(0,6)},fU=t=>_I(dU(cU(SI(t)))),Ah=(t,e)=>e===void 0?!t.deleted:e.sv.has(t.id.client)&&e.sv.get(t.id.client)>t.id.clock&&!tu(e.ds,t.id),hU=[{light:"#ecd44433",dark:"#ecd444"}],pU=(t,e,n)=>{if(!t.has(n)){if(t.size<e.length){const r=ga();t.forEach(i=>r.add(i)),e=e.filter(i=>!r.has(i))}t.set(n,tI(e))}return t.get(n)},mU=(t,{colors:e=hU,colorMapping:n=new Map,permanentUserData:r=null,onFirstRender:i=()=>{},mapping:o}={})=>{let s=!1;const a=new vU(t,o),l=new Dt({props:{editable:u=>{const c=Xt.getState(u);return c.snapshot==null&&c.prevSnapshot==null}},key:Xt,state:{init:(u,c)=>({type:t,doc:t.doc,binding:a,snapshot:null,prevSnapshot:null,isChangeOrigin:!1,isUndoRedoOperation:!1,addToHistory:!0,colors:e,colorMapping:n,permanentUserData:r}),apply:(u,c)=>{const f=u.getMeta(Xt);if(f!==void 0){c=Object.assign({},c);for(const h in f)c[h]=f[h]}return c.addToHistory=u.getMeta("addToHistory")!==!1,c.isChangeOrigin=f!==void 0&&!!f.isChangeOrigin,c.isUndoRedoOperation=f!==void 0&&!!f.isChangeOrigin&&!!f.isUndoRedoOperation,a.prosemirrorView!==null&&f!==void 0&&(f.snapshot!=null||f.prevSnapshot!=null)&&wb(0,()=>{a.prosemirrorView!=null&&(f.restore==null?a._renderSnapshot(f.snapshot,f.prevSnapshot,c):(a._renderSnapshot(f.snapshot,f.snapshot,c),delete c.restore,delete c.snapshot,delete c.prevSnapshot,a.mux(()=>{a._prosemirrorChanged(a.prosemirrorView.state.doc)})))}),c}},view:u=>(a.initView(u),o==null&&a._forceRerender(),i(),{update:()=>{const c=l.getState(u.state);if(c.snapshot==null&&c.prevSnapshot==null&&(s||u.state.doc.content.findDiffStart(u.state.doc.type.createAndFill().content)!==null)){if(s=!0,c.addToHistory===!1&&!c.isChangeOrigin){const f=Gi.getState(u.state),h=f&&f.undoManager;h&&h.stopCapturing()}a.mux(()=>{c.doc.transact(f=>{f.meta.set("addToHistory",c.addToHistory),a._prosemirrorChanged(u.state.doc)},Xt)})}},destroy:()=>{a.destroy()}})});return l},gU=(t,e,n)=>{if(e!==null&&e.anchor!==null&&e.head!==null)if(e.type==="all")t.setSelection(new _r(t.doc));else if(e.type==="node"){const r=ul(n.doc,n.type,e.anchor,n.mapping);t.setSelection(Ye.create(t.doc,r))}else{const r=ul(n.doc,n.type,e.anchor,n.mapping),i=ul(n.doc,n.type,e.head,n.mapping);if(r!==null&&i!==null){const o=qe.between(t.doc.resolve(r),t.doc.resolve(i));t.setSelection(o)}}},lv=(t,e)=>({type:e.selection.jsonID,anchor:Mh(e.selection.anchor,t.type,t.mapping),head:Mh(e.selection.head,t.type,t.mapping)});class vU{constructor(e,n=new Map){this.type=e,this.prosemirrorView=null,this.mux=QV(),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=lv(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()?(YC&&this._domSelectionInView===null&&(wb(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=ad.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=OS(kS(),new Map)),this.prosemirrorView.dispatch(this._tr.setMeta(Xt,{snapshot:e,prevSnapshot:n}))}unrenderSnapshot(){this.mapping.clear(),this.mux(()=>{const e=this.type.toArray().map(r=>Of(r,this.prosemirrorView.state.schema,this)).filter(r=>r!==null),n=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new Te(ge.from(e),0,0));n.setMeta(Xt,{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=>Of(i,this.prosemirrorView.state.schema,this)).filter(i=>i!==null),r=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new Te(ge.from(n),0,0));if(e){const i=So(xi(e.anchor,0),r.doc.content.size),o=So(xi(e.head,0),r.doc.content.size);r.setSelection(qe.create(r.doc,i,o))}this.prosemirrorView.dispatch(r.setMeta(Xt,{isChangeOrigin:!0,binding:this}))})}_renderSnapshot(e,n,r){let i=this.doc,o=this.type;if(e||(e=Gm(this.doc)),e instanceof Uint8Array||n instanceof Uint8Array)if((!(e instanceof Uint8Array)||!(n instanceof Uint8Array))&&Jn(),i=new Qi({gc:!1}),uh(i,n),n=Gm(i),uh(i,e),e=Gm(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=_i(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=>{_s(s,f,h=>{})});const l=(f,h)=>{const p=f==="added"?a.getUserByClientId(h.client):a.getUserByDeletedId(h);return{user:p,type:f,color:pU(r.colorMapping,r.colors,p)}},u=US(o,new Sb(n.ds,e.sv)).map(f=>!f._item.deleted||Ah(f._item,e)||Ah(f._item,n)?Of(f,this.prosemirrorView.state.schema,{mapping:new Map,isOMark:new Map},e,n,l):null).filter(f=>f!==null),c=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new Te(ge.from(u),0,0));this.prosemirrorView.dispatch(c.setMeta(Xt,{isChangeOrigin:!0}))},Xt)})}_typeChanged(e,n){if(this.prosemirrorView==null)return;const r=Xt.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);_s(n,n.deleteSet,a=>{if(a.constructor===jt){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=>jE(a,this.prosemirrorView.state.schema,this)).filter(a=>a!==null);let s=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new Te(ge.from(o),0,0));gU(s,this.beforeTransactionSelection,this),s=s.setMeta(Xt,{isChangeOrigin:!0,isUndoRedoOperation:n.origin instanceof LS}),this.beforeTransactionSelection!==null&&this._isLocalCursorInView()&&s.scrollIntoView(),this.prosemirrorView.dispatch(s)})}_prosemirrorChanged(e){this.doc.transact(()=>{cv(this.doc,this.type,e,this),this.beforeTransactionSelection=lv(this,this.prosemirrorView.state)},Xt)}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 jE=(t,e,n,r,i,o)=>{const s=n.mapping.get(t);if(s===void 0){if(t instanceof Qt)return Of(t,e,n,r,i,o);throw oi()}return s},Of=(t,e,n,r,i,o)=>{const s=[],a=l=>{var u,c;if(l instanceof Qt){const f=jE(l,e,n,r,i,o);f!==null&&s.push(f)}else{const f=(c=(u=l._item.right)==null?void 0:u.content)==null?void 0:c.type;f instanceof Cs&&!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=bU(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):US(t,new Sb(i.ds,r.sv)).forEach(a);try{const l=t.getAttributes(r);r!==void 0&&(Ah(t._item,r)?Ah(t._item,i)||(l.ychange=o?o("added",t._item.id):{type:"added"}):l.ychange=o?o("removed",t._item.id):{type:"removed"});const u=e.node(t.nodeName,l,s);return n.mapping.set(t,u),u}catch{return t.doc.transact(u=>{t._item.delete(u)},Xt),n.mapping.delete(t),null}},bU=(t,e,n,r,i,o)=>{const s=[],a=t.toDelta(r,i,o);try{for(let l=0;l<a.length;l++){const u=a[l];s.push(e.text(u.insert,CU(u.attributes,e)))}}catch{return t.doc.transact(u=>{t._item.delete(u)},Xt),null}return s},yU=(t,e)=>{const n=new hn,r=t.map(i=>({insert:i.text,attributes:WE(i.marks,e)}));return n.applyDelta(r),e.mapping.set(n,t),n},wU=(t,e)=>{const n=new Qt(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,nm(t).map(r=>uv(r,e))),e.mapping.set(n,t),n},uv=(t,e)=>t instanceof Array?yU(t,e):wU(t,e),I2=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||I2(s)&&I2(a)&&l1(s,a)}return r},nm=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},qE=(t,e)=>{const n=t.toDelta();return n.length===e.length&&n.every((r,i)=>r.insert===e[i].text&&GC(r.attributes||{}).length===e[i].marks.length&&Ql(r.attributes,(o,s)=>{var u;const a=u1(s),l=e[i].marks;return l1(o,(u=l.find(c=>c.type.name===a))==null?void 0:u.attrs)}))},Pc=(t,e)=>{if(t instanceof Qt&&!(e instanceof Array)&&dv(t,e)){const n=nm(e);return t._length===n.length&&l1(t.getAttributes(),e.attrs)&&t.toArray().every((r,i)=>Pc(r,n[i]))}return t instanceof hn&&e instanceof Array&&qE(t,e)},Th=(t,e)=>t===e||t instanceof Array&&e instanceof Array&&t.length===e.length&&t.every((n,r)=>e[r]===n),R2=(t,e,n)=>{const r=t.toArray(),i=nm(e),o=i.length,s=r.length,a=So(s,o);let l=0,u=0,c=!1;for(;l<a;l++){const f=r[l],h=i[l];if(Th(n.mapping.get(f),h))c=!0;else if(!Pc(f,h))break}for(;l+u<a;u++){const f=r[s-u-1],h=i[o-u-1];if(Th(n.mapping.get(f),h))c=!0;else if(!Pc(f,h))break}return{equalityFactor:l+u,foundMappedChild:c}},kU=t=>{let e="",n=t._start;const r={};for(;n!==null;)n.deleted||(n.countable&&n.content instanceof Ci?e+=n.content.str:n.content instanceof pn&&(r[n.content.key]=null)),n=n.right;return{str:e,nAttrs:r}},xU=(t,e,n)=>{n.mapping.set(t,e);const{nAttrs:r,str:i}=kU(t),o=e.map(u=>({insert:u.text,attributes:Object.assign({},r,WE(u.marks,n))})),{insert:s,remove:a,index:l}=nU(i,o.map(u=>u.insert).join(""));t.delete(l,a),t.insert(l,s),t.applyDelta(o.map(u=>({retain:u.insert.length,attributes:u.attributes})))},_U=/(.*)(--[a-zA-Z0-9+/=]{8})$/,u1=t=>{var e;return((e=_U.exec(t))==null?void 0:e[1])??t},CU=(t,e)=>{const n=[];for(const r in t)n.push(e.mark(u1(r),t[r]));return n},WE=(t,e)=>{const n={};return t.forEach(r=>{if(r.type.name!=="ychange"){const i=ro(e.isOMark,r.type,()=>!r.type.excludes(r.type));n[i?`${r.type.name}--${fU(r.toJSON())}`:r.type.name]=r.attrs}}),n},cv=(t,e,n,r)=>{if(e instanceof Qt&&e.nodeName!==n.type.name)throw new Error("node name mismatch!");if(r.mapping.set(e,n),e instanceof Qt){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=nm(n),o=i.length,s=e.toArray(),a=s.length,l=So(o,a);let u=0,c=0;for(;u<l;u++){const f=s[u],h=i[u];if(!Th(r.mapping.get(f),h))if(Pc(f,h))r.mapping.set(f,h);else break}for(;c+u<l;c++){const f=s[a-c-1],h=i[o-c-1];if(!Th(r.mapping.get(f),h))if(Pc(f,h))r.mapping.set(f,h);else break}t.transact(()=>{for(;a-u-c>0&&o-u-c>0;){const h=s[u],p=i[u],m=s[a-c-1],v=i[o-c-1];if(h instanceof hn&&p instanceof Array)qE(h,p)||xU(h,p,r),u+=1;else{let g=h instanceof Qt&&dv(h,p),b=m instanceof Qt&&dv(m,v);if(g&&b){const x=R2(h,p,r),_=R2(m,v,r);x.foundMappedChild&&!_.foundMappedChild?b=!1:!x.foundMappedChild&&_.foundMappedChild||x.equalityFactor<_.equalityFactor?g=!1:b=!1}g?(cv(t,h,p,r),u+=1):b?(cv(t,m,v,r),c+=1):(r.mapping.delete(e.get(u)),e.delete(u,1),e.insert(u,[uv(p,r)]),u+=1)}}const f=a-u-c;if(a===1&&o===0&&s[0]instanceof hn?(r.mapping.delete(s[0]),s[0].delete(0,s[0].length)):f>0&&(e.slice(u,u+f).forEach(h=>r.mapping.delete(h)),e.delete(u,f)),u+c<o){const h=[];for(let p=u;p<o-c;p++)h.push(uv(i[p],r));e.insert(u,h)}},Xt)},dv=(t,e)=>!(e instanceof Array)&&t.nodeName===e.type.name;let Wu=null;const SU=()=>{const t=Wu;Wu=null,t.forEach((e,n)=>{const r=n.state.tr,i=Xt.getState(n.state);i&&i.binding&&!i.binding.isDestroyed&&(e.forEach((o,s)=>{r.setMeta(s,o)}),n.dispatch(r))})},EU=(t,e,n)=>{Wu||(Wu=new Map,wb(0,SU)),ro(Wu,t,ii).set(e,n)},Mh=(t,e,n)=>{if(t===0)return Km(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 hn){if(r._length>=t)return Km(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 kc(r._item===null?null:r._item.id,r._item===null?yc(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 kc(r._item===null?null:r._item.id,r._item===null?yc(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 Jn();if(t===0&&r.constructor!==hn&&r!==e)return AU(r._item.parent,r._item)}return Km(e,e._length,e.length===0?-1:0)},AU=(t,e)=>{let n=null,r=null;return t._item===null?r=yc(t):n=lt(t._item.id.client,t._item.id.clock),new kc(n,r,e.id)},ul=(t,e,n,r)=>{const i=P0(n,t);if(i===null||i.type!==e&&!wc(e,i.type._item))return null;let o=i.type,s=0;if(o.constructor===hn)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 u=a.content.type;l++,u instanceof hn?s+=u._length:s+=r.get(u).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 u=l.content.type;if(u===o)break;l.deleted||(u instanceof hn?s+=u._length:s+=r.get(u).nodeSize),l=l.right}}o=a}return s-1};function TU(t){const e=t.toArray(),n=r=>{let i;if(r instanceof hn)i=r.toDelta().map(s=>{const a={type:"text",text:s.insert};return s.attributes&&(a.marks=Object.keys(s.attributes).map(l=>{const u=s.attributes[l],f={type:u1(l)};return Object.keys(u)&&(f.attrs=u),f})),a});else if(r instanceof Qt){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 Jn();return i};return{type:"doc",content:e.map(n)}}const MU=(t,e,n)=>t!==e,DU=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},KE=t=>({style:`background-color: ${t.color}70`,class:"ProseMirror-yjs-selection"}),OU=/^#[0-9a-fA-F]{6}$/,N2=(t,e,n,r,i)=>{const o=Xt.getState(t),s=o.doc,a=[];return o.snapshot!=null||o.prevSnapshot!=null||o.binding.mapping.size===0?nt.create(t.doc,[]):(e.getStates().forEach((l,u)=>{if(n(s.clientID,u,l)&&l.cursor!=null){const c=l.user||{};c.color==null?c.color="#ffa500":OU.test(c.color)||console.warn("A user uses an unsupported color format",c),c.name==null&&(c.name=`User: ${u}`);let f=ul(s,o.type,sa(l.cursor.anchor),o.binding.mapping),h=ul(s,o.type,sa(l.cursor.head),o.binding.mapping);if(f!==null&&h!==null){const p=xi(t.doc.content.size-1,0);f=So(f,p),h=So(h,p),a.push(Vt.widget(h,()=>r(c,u),{key:u+"",side:10}));const m=So(f,h),v=xi(f,h);a.push(Vt.inline(m,v,i(c,u),{inclusiveEnd:!0,inclusiveStart:!1}))}}}),nt.create(t.doc,a))},IU=(t,{awarenessStateFilter:e=MU,cursorBuilder:n=DU,selectionBuilder:r=KE,getSelection:i=s=>s.selection}={},o="cursor")=>new Dt({key:Ud,state:{init(s,a){return N2(a,t,e,n,r)},apply(s,a,l,u){const c=Xt.getState(u),f=s.getMeta(Ud);return c&&c.isChangeOrigin||f&&f.awarenessUpdated?N2(u,t,e,n,r):a.map(s.mapping,s.doc)}},props:{decorations:s=>Ud.getState(s)},view:s=>{const a=()=>{s.docView&&EU(s,Ud,{awarenessUpdated:!0})},l=()=>{const u=Xt.getState(s.state),c=t.getLocalState()||{};if(s.hasFocus()){const f=i(s.state),h=Mh(f.anchor,u.type,u.binding.mapping),p=Mh(f.head,u.type,u.binding.mapping);(c.cursor==null||!ww(sa(c.cursor.anchor),h)||!ww(sa(c.cursor.head),p))&&t.setLocalStateField(o,{anchor:h,head:p})}else c.cursor!=null&&ul(u.doc,u.type,sa(c.cursor.anchor),u.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)}}}}),RU=t=>{var e,n;return((n=(e=Gi.getState(t))==null?void 0:e.undoManager)==null?void 0:n.undo())!=null},NU=t=>{var e,n;return((n=(e=Gi.getState(t))==null?void 0:e.undoManager)==null?void 0:n.redo())!=null},PU=new Set(["paragraph"]),LU=(t,e)=>!(t instanceof jt)||!(t.content instanceof Si)||!(t.content.type instanceof Cs||t.content.type instanceof Qt&&e.has(t.content.type.nodeName))||t.content.type._length===0,FU=({protectedNodes:t=PU,trackedOrigins:e=[],undoManager:n=null}={})=>new Dt({key:Gi,state:{init:(r,i)=>{const o=Xt.getState(i),s=n||new LS(o.type,{trackedOrigins:new Set([Xt].concat(e)),deleteFilter:a=>LU(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=Xt.getState(s).binding,l=i.undoManager,u=l.undoStack.length>0,c=l.redoStack.length>0;return a?{undoManager:l,prevSel:lv(a,o),hasUndoOps:u,hasRedoOps:c}:u!==i.hasUndoOps||c!==i.hasRedoOps?Object.assign({},i,{hasUndoOps:l.undoStack.length>0,hasRedoOps:l.redoStack.length>0}):i}},view:r=>{const i=Xt.getState(r.state),o=Gi.getState(r.state).undoManager;return o.on("stack-item-added",({stackItem:s})=>{const a=i.binding;a&&s.meta.set(a,Gi.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()}}}}),zU=Kt.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),Gi.getState(e).undoManager.undoStack.length===0?!1:n?RU(e):!0),redo:()=>({tr:t,state:e,dispatch:n})=>(t.setMeta("preventDispatch",!0),Gi.getState(e).undoManager.redoStack.length===0?!1:n?NU(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=FU(this.options.yUndoOptions),r=n.spec.view;n.spec.view=s=>{const{undoManager:a}=Gi.getState(s.state);a.restore&&(a.restore(),a.restore=()=>{});const l=r?r(s):void 0;return{destroy:()=>{const u=a.trackedOrigins.has(a),c=a._observers;a.restore=()=>{u&&a.trackedOrigins.add(a),a.doc.on("afterTransaction",a.afterTransactionHandler),a._observers=c},l!=null&&l.destroy&&l.destroy()}}};const i={...this.options.ySyncOptions,onFirstRender:this.options.onFirstRender},o=mU(e,i);return this.editor.options.enableContentCheck&&((t=e.doc)===null||t===void 0||t.on("beforeTransaction",()=>{try{const s=TU(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 Dt({key:new Nt("filterInvalidContent"),filterTransaction:()=>{var s;return this.storage.isDisabled&&((s=e.doc)===null||s===void 0||s.destroy()),!0}})].filter(Boolean)}}),P2=t=>Array.from(t.entries()).map(([e,n])=>({clientId:e,...n.user})),L2=()=>null,BU=Kt.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:KE,onUpdate:L2}},onCreate(){if(this.options.onUpdate!==L2&&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[IU((this.options.provider.awareness.setLocalStateField("user",this.options.user),this.storage.users=P2(this.options.provider.awareness.states),this.options.provider.awareness.on("update",()=>{this.storage.users=P2(this.options.provider.awareness.states)}),this.options.provider.awareness),{cursorBuilder:this.options.render,selectionBuilder:this.options.selectionRender})]}}),HU=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,VU=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,UU=to.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",ln(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[_a({find:HU,type:this.type})]},addPasteRules(){return[As({find:VU,type:this.type})]}}),jU="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",qU="ελ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",fv="numeric",hv="ascii",pv="alpha",Ku="asciinumeric",Mu="alphanumeric",mv="domain",GE="emoji",WU="scheme",KU="slashscheme",fg="whitespace";function GU(t,e){return t in e||(e[t]=[]),e[t]}function Gs(t,e,n){e[fv]&&(e[Ku]=!0,e[Mu]=!0),e[hv]&&(e[Ku]=!0,e[pv]=!0),e[Ku]&&(e[Mu]=!0),e[pv]&&(e[Mu]=!0),e[Mu]&&(e[mv]=!0),e[GE]&&(e[mv]=!0);for(const r in e){const i=GU(r,n);i.indexOf(t)<0&&i.push(t)}}function ZU(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function wr(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}wr.groups={};wr.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||wr.groups;let i;return e&&e.j?i=e:(i=new wr(e),n&&r&&Gs(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||wr.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 wr,Object.assign(s.j,a.j),s.jr.push.apply(s.jr,a.jr),s.jd=a.jd,s.t=a.t):s=new wr,o){if(r)if(s.t&&typeof s.t=="string"){const l=Object.assign(ZU(s.t,r),n);Gs(o,l,r)}else n&&Gs(o,n,r);s.t=o}return i.j[t]=s,s}};const dt=(t,e,n,r,i)=>t.ta(e,n,r,i),en=(t,e,n,r,i)=>t.tr(e,n,r,i),F2=(t,e,n,r,i)=>t.ts(e,n,r,i),Ce=(t,e,n,r,i)=>t.tt(e,n,r,i),po="WORD",gv="UWORD",ZE="ASCIINUMERICAL",JE="ALPHANUMERICAL",Lc="LOCALHOST",vv="TLD",bv="UTLD",If="SCHEME",qa="SLASH_SCHEME",c1="NUM",yv="WS",d1="NL",Gu="OPENBRACE",Zu="CLOSEBRACE",Dh="OPENBRACKET",Oh="CLOSEBRACKET",Ih="OPENPAREN",Rh="CLOSEPAREN",Nh="OPENANGLEBRACKET",Ph="CLOSEANGLEBRACKET",Lh="FULLWIDTHLEFTPAREN",Fh="FULLWIDTHRIGHTPAREN",zh="LEFTCORNERBRACKET",Bh="RIGHTCORNERBRACKET",Hh="LEFTWHITECORNERBRACKET",Vh="RIGHTWHITECORNERBRACKET",Uh="FULLWIDTHLESSTHAN",jh="FULLWIDTHGREATERTHAN",qh="AMPERSAND",Wh="APOSTROPHE",Kh="ASTERISK",Wo="AT",Gh="BACKSLASH",Zh="BACKTICK",Jh="CARET",Yo="COLON",f1="COMMA",Yh="DOLLAR",Ii="DOT",Xh="EQUALS",h1="EXCLAMATION",qr="HYPHEN",Ju="PERCENT",Qh="PIPE",$h="PLUS",ep="POUND",Yu="QUERY",p1="QUOTE",YE="FULLWIDTHMIDDLEDOT",m1="SEMI",Ri="SLASH",Xu="TILDE",tp="UNDERSCORE",XE="EMOJI",np="SYM";var QE=Object.freeze({__proto__:null,ALPHANUMERICAL:JE,AMPERSAND:qh,APOSTROPHE:Wh,ASCIINUMERICAL:ZE,ASTERISK:Kh,AT:Wo,BACKSLASH:Gh,BACKTICK:Zh,CARET:Jh,CLOSEANGLEBRACKET:Ph,CLOSEBRACE:Zu,CLOSEBRACKET:Oh,CLOSEPAREN:Rh,COLON:Yo,COMMA:f1,DOLLAR:Yh,DOT:Ii,EMOJI:XE,EQUALS:Xh,EXCLAMATION:h1,FULLWIDTHGREATERTHAN:jh,FULLWIDTHLEFTPAREN:Lh,FULLWIDTHLESSTHAN:Uh,FULLWIDTHMIDDLEDOT:YE,FULLWIDTHRIGHTPAREN:Fh,HYPHEN:qr,LEFTCORNERBRACKET:zh,LEFTWHITECORNERBRACKET:Hh,LOCALHOST:Lc,NL:d1,NUM:c1,OPENANGLEBRACKET:Nh,OPENBRACE:Gu,OPENBRACKET:Dh,OPENPAREN:Ih,PERCENT:Ju,PIPE:Qh,PLUS:$h,POUND:ep,QUERY:Yu,QUOTE:p1,RIGHTCORNERBRACKET:Bh,RIGHTWHITECORNERBRACKET:Vh,SCHEME:If,SEMI:m1,SLASH:Ri,SLASH_SCHEME:qa,SYM:np,TILDE:Xu,TLD:vv,UNDERSCORE:tp,UTLD:bv,UWORD:gv,WORD:po,WS:yv});const fo=/[a-z]/,gu=new RegExp("\\p{L}","u"),hg=new RegExp("\\p{Emoji}","u"),ho=/\d/,pg=/\s/,z2="\r",mg=`
|
|
189
|
+
`,JU="️",YU="",gg="";let jd=null,qd=null;function XU(t=[]){const e={};wr.groups=e;const n=new wr;jd==null&&(jd=B2(jU)),qd==null&&(qd=B2(qU)),Ce(n,"'",Wh),Ce(n,"{",Gu),Ce(n,"}",Zu),Ce(n,"[",Dh),Ce(n,"]",Oh),Ce(n,"(",Ih),Ce(n,")",Rh),Ce(n,"<",Nh),Ce(n,">",Ph),Ce(n,"(",Lh),Ce(n,")",Fh),Ce(n,"「",zh),Ce(n,"」",Bh),Ce(n,"『",Hh),Ce(n,"』",Vh),Ce(n,"<",Uh),Ce(n,">",jh),Ce(n,"&",qh),Ce(n,"*",Kh),Ce(n,"@",Wo),Ce(n,"`",Zh),Ce(n,"^",Jh),Ce(n,":",Yo),Ce(n,",",f1),Ce(n,"$",Yh),Ce(n,".",Ii),Ce(n,"=",Xh),Ce(n,"!",h1),Ce(n,"-",qr),Ce(n,"%",Ju),Ce(n,"|",Qh),Ce(n,"+",$h),Ce(n,"#",ep),Ce(n,"?",Yu),Ce(n,'"',p1),Ce(n,"/",Ri),Ce(n,";",m1),Ce(n,"~",Xu),Ce(n,"_",tp),Ce(n,"\\",Gh),Ce(n,"・",YE);const r=en(n,ho,c1,{[fv]:!0});en(r,ho,r);const i=en(r,fo,ZE,{[Ku]:!0}),o=en(r,gu,JE,{[Mu]:!0}),s=en(n,fo,po,{[hv]:!0});en(s,ho,i),en(s,fo,s),en(i,ho,i),en(i,fo,i);const a=en(n,gu,gv,{[pv]:!0});en(a,fo),en(a,ho,o),en(a,gu,a),en(o,ho,o),en(o,fo),en(o,gu,o);const l=Ce(n,mg,d1,{[fg]:!0}),u=Ce(n,z2,yv,{[fg]:!0}),c=en(n,pg,yv,{[fg]:!0});Ce(n,gg,c),Ce(u,mg,l),Ce(u,gg,c),en(u,pg,c),Ce(c,z2),Ce(c,mg),en(c,pg,c),Ce(c,gg,c);const f=en(n,hg,XE,{[GE]:!0});Ce(f,"#"),en(f,hg,f),Ce(f,JU,f);const h=Ce(f,YU);Ce(h,"#"),en(h,hg,f);const p=[[fo,s],[ho,i]],m=[[fo,null],[gu,a],[ho,o]];for(let v=0;v<jd.length;v++)Ho(n,jd[v],vv,po,p);for(let v=0;v<qd.length;v++)Ho(n,qd[v],bv,gv,m);Gs(vv,{tld:!0,ascii:!0},e),Gs(bv,{utld:!0,alpha:!0},e),Ho(n,"file",If,po,p),Ho(n,"mailto",If,po,p),Ho(n,"http",qa,po,p),Ho(n,"https",qa,po,p),Ho(n,"ftp",qa,po,p),Ho(n,"ftps",qa,po,p),Gs(If,{scheme:!0,ascii:!0},e),Gs(qa,{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],x=t[v][1]?{[WU]:!0}:{[KU]:!0};g.indexOf("-")>=0?x[mv]=!0:fo.test(g)?ho.test(g)?x[Ku]=!0:x[hv]=!0:x[fv]=!0,F2(n,g,g,x)}return F2(n,"localhost",Lc,{ascii:!0}),n.jd=new wr(np),{start:n,tokens:Object.assign({groups:e},QE)}}function $E(t,e){const n=QU(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,u=0,c=null,f=-1,h=-1;for(;s<r&&(l=a.go(n[s]));)a=l,a.accepts()?(f=0,h=0,c=a):f>=0&&(f+=n[s].length,h++),u+=n[s].length,o+=n[s].length,s++;o-=f,s-=h,u-=f,i.push({t:c.t,v:e.slice(o-u,o),s:o-u,e:o})}return i}function QU(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 Ho(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 wr(r),o.jr=i.slice(),t.j[l]=o),t=o}return o=new wr(n),o.jr=i.slice(),t.j[e[s-1]]=o,o}function B2(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 Fc={defaultProtocol:"http",events:null,format:H2,formatHref:H2,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function g1(t,e=null){let n=Object.assign({},Fc);t&&(n=Object.assign(n,t instanceof g1?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}g1.prototype={o:Fc,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]:Fc[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 H2(t){return t}function eA(t,e){this.t="token",this.v=t,this.tk=e}eA.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=Fc.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),u=t.get("rel",n,e),c=t.getObj("attributes",n,e),f=t.getObj("events",n,e);return s.href=r,a&&(s.class=a),l&&(s.target=l),u&&(s.rel=u),c&&Object.assign(s,c),{tagName:i,attributes:s,content:o,eventListeners:f}}};function rm(t,e){class n extends eA{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 V2=rm("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),U2=rm("text"),$U=rm("nl"),Wd=rm("url",{isLink:!0,toHref(t=Fc.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==Lc&&t[1].t===Yo}}),Ur=t=>new wr(t);function ej({groups:t}){const e=t.domain.concat([qh,Kh,Wo,Gh,Zh,Jh,Yh,Xh,qr,c1,Ju,Qh,$h,ep,Ri,np,Xu,tp]),n=[Wh,Yo,f1,Ii,h1,Ju,Yu,p1,m1,Nh,Ph,Gu,Zu,Oh,Dh,Ih,Rh,Lh,Fh,zh,Bh,Hh,Vh,Uh,jh],r=[qh,Wh,Kh,Gh,Zh,Jh,Yh,Xh,qr,Gu,Zu,Ju,Qh,$h,ep,Yu,Ri,np,Xu,tp],i=Ur(),o=Ce(i,Xu);dt(o,r,o),dt(o,t.domain,o);const s=Ur(),a=Ur(),l=Ur();dt(i,t.domain,s),dt(i,t.scheme,a),dt(i,t.slashscheme,l),dt(s,r,o),dt(s,t.domain,s);const u=Ce(s,Wo);Ce(o,Wo,u),Ce(a,Wo,u),Ce(l,Wo,u);const c=Ce(o,Ii);dt(c,r,o),dt(c,t.domain,o);const f=Ur();dt(u,t.domain,f),dt(f,t.domain,f);const h=Ce(f,Ii);dt(h,t.domain,f);const p=Ur(V2);dt(h,t.tld,p),dt(h,t.utld,p),Ce(u,Lc,p);const m=Ce(f,qr);Ce(m,qr,m),dt(m,t.domain,f),dt(p,t.domain,f),Ce(p,Ii,h),Ce(p,qr,m);const v=Ce(p,Yo);dt(v,t.numeric,V2);const g=Ce(s,qr),b=Ce(s,Ii);Ce(g,qr,g),dt(g,t.domain,s),dt(b,r,o),dt(b,t.domain,s);const x=Ur(Wd);dt(b,t.tld,x),dt(b,t.utld,x),dt(x,t.domain,s),dt(x,r,o),Ce(x,Ii,b),Ce(x,qr,g),Ce(x,Wo,u);const _=Ce(x,Yo),T=Ur(Wd);dt(_,t.numeric,T);const S=Ur(Wd),z=Ur();dt(S,e,S),dt(S,n,z),dt(z,e,S),dt(z,n,z),Ce(x,Ri,S),Ce(T,Ri,S);const E=Ce(a,Yo),D=Ce(l,Yo),P=Ce(D,Ri),R=Ce(P,Ri);dt(a,t.domain,s),Ce(a,Ii,b),Ce(a,qr,g),dt(l,t.domain,s),Ce(l,Ii,b),Ce(l,qr,g),dt(E,t.domain,S),Ce(E,Ri,S),Ce(E,Yu,S),dt(R,t.domain,S),dt(R,e,S),Ce(R,Ri,S);const H=[[Gu,Zu],[Dh,Oh],[Ih,Rh],[Nh,Ph],[Lh,Fh],[zh,Bh],[Hh,Vh],[Uh,jh]];for(let Q=0;Q<H.length;Q++){const[Z,$]=H[Q],W=Ce(S,Z);Ce(z,Z,W),Ce(W,$,S);const te=Ur(Wd);dt(W,e,te);const ae=Ur();dt(W,n),dt(te,e,te),dt(te,n,ae),dt(ae,e,te),dt(ae,n,ae),Ce(te,$,S),Ce(ae,$,S)}return Ce(i,Lc,x),Ce(i,d1,$U),{start:i,tokens:QE}}function tj(t,e,n){let r=n.length,i=0,o=[],s=[];for(;i<r;){let a=t,l=null,u=null,c=0,f=null,h=-1;for(;i<r&&!(l=a.go(n[i].t));)s.push(n[i++]);for(;i<r&&(u=l||a.go(n[i].t));)l=null,a=u,a.accepts()?(h=0,f=a):h>=0&&h++,i++,c++;if(h<0)i-=c,i<r&&(s.push(n[i]),i++);else{s.length>0&&(o.push(vg(U2,e,s)),s=[]),i-=h,c-=h;const p=f.t,m=n.slice(i-c,i);o.push(vg(p,e,m))}}return s.length>0&&o.push(vg(U2,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 nj=typeof console<"u"&&console&&console.warn||(()=>{}),rj="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",Zt={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function ij(){return wr.groups={},Zt.scanner=null,Zt.parser=null,Zt.tokenQueue=[],Zt.pluginQueue=[],Zt.customSchemes=[],Zt.initialized=!1,Zt}function j2(t,e=!1){if(Zt.initialized&&nj(`linkifyjs: already initialized - will not register custom scheme "${t}" ${rj}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(t))throw new Error(`linkifyjs: incorrect scheme format.
|
|
190
|
+
1. Must only contain digits, lowercase ASCII letters or "-"
|
|
191
|
+
2. Cannot start or end with "-"
|
|
192
|
+
3. "-" cannot repeat`);Zt.customSchemes.push([t,e])}function oj(){Zt.scanner=XU(Zt.customSchemes);for(let t=0;t<Zt.tokenQueue.length;t++)Zt.tokenQueue[t][1]({scanner:Zt.scanner});Zt.parser=ej(Zt.scanner.tokens);for(let t=0;t<Zt.pluginQueue.length;t++)Zt.pluginQueue[t][1]({scanner:Zt.scanner,parser:Zt.parser});return Zt.initialized=!0,Zt}function v1(t){return Zt.initialized||oj(),tj(Zt.parser.start,t,$E(Zt.scanner.start,t))}v1.scan=$E;function tA(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 g1(n),i=v1(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 b1="[\0- -\u2029 ]",sj=new RegExp(b1),aj=new RegExp(`${b1}$`),lj=new RegExp(b1,"g");function uj(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function cj(t){return new Dt({key:new Nt("autolink"),appendTransaction:(e,n,r)=>{const i=e.some(u=>u.docChanged)&&!n.doc.eq(r.doc),o=e.some(u=>u.getMeta("preventAutolink"));if(!i||o)return;const{tr:s}=r,a=uV(n.doc,[...e]);if(gV(a).forEach(({newRange:u})=>{const c=dV(r.doc,u,p=>p.isTextblock);let f,h;if(c.length>1)f=c[0],h=r.doc.textBetween(f.pos,f.pos+f.node.nodeSize,void 0," ");else if(c.length){const p=r.doc.textBetween(u.from,u.to," "," ");if(!aj.test(p))return;f=c[0],h=r.doc.textBetween(f.pos,u.to,void 0," ")}if(f&&h){const p=h.split(sj).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=v1(m).map(b=>b.toObject(t.defaultProtocol));if(!uj(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=>{a1(b.from,b.to,r.doc).some(x=>x.mark.type===t.type)||s.addMark(b.from,b.to,t.type.create({href:b.href}))})}}),!!s.steps.length)return s}})}function dj(t){return new Dt({key:new Nt("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=UE(e.state,t.type.name),u=r.target,c=(i=u==null?void 0:u.href)!==null&&i!==void 0?i:l.href,f=(o=u==null?void 0:u.target)!==null&&o!==void 0?o:l.target;return u&&c?(window.open(c,f),!0):!1}}})}function fj(t){return new Dt({key:new Nt("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(u=>{a+=u.textContent});const l=tA(a,{defaultProtocol:t.defaultProtocol}).find(u=>u.isLink&&u.value===a);return!a||!l?!1:t.editor.commands.setMark(t.type,{href:l.href})}}})}function Rs(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(lj,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}const hj=to.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"){j2(t);return}j2(t.scheme,t.optionalSlashes)})},onDestroy(){ij()},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)=>!!Rs(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=>!!Rs(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=>!!Rs(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",ln(this.options.HTMLAttributes,t),0]:["a",ln(this.options.HTMLAttributes,{...t,href:""}),0]},addCommands(){return{setLink:t=>({chain:e})=>{const{href:n}=t;return this.options.isAllowedUri(n,{defaultValidate:r=>!!Rs(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=>!!Rs(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[As({find:t=>{const e=[];if(t){const{protocols:n,defaultProtocol:r}=this.options,i=tA(t).filter(o=>o.isLink&&this.options.isAllowedUri(o.value,{defaultValidate:s=>!!Rs(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(cj({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:i=>!!Rs(i,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),this.options.openOnClick===!0&&t.push(dj({type:this.type})),this.options.linkOnPaste&&t.push(fj({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type})),t}}),pj=Kt.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new Dt({key:new Nt("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,u=!s.isLeaf&&tm(s);if((l||!this.options.showOnlyCurrent)&&u){const c=[this.options.emptyNodeClass];o&&c.push(this.options.emptyEditorClass);const f=Vt.node(a,a+s.nodeSize,{class:c.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}),nt.create(t,i)}}})]}});let wv,kv;if(typeof WeakMap<"u"){let t=new WeakMap;wv=e=>t.get(e),kv=(e,n)=>(t.set(e,n),n)}else{const t=[];let n=0;wv=r=>{for(let i=0;i<t.length;i+=2)if(t[i]==r)return t[i+1]},kv=(r,i)=>(n==10&&(n=0),t[n++]=r,t[n++]=i)}var on=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:u}=this.findCell(e);return{left:Math.min(n,s),top:Math.min(i,l),right:Math.max(r,a),bottom:Math.max(o,u)}}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 wv(t)||kv(t,mj(t))}};function mj(t){if(t.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+t.type.name);const e=gj(t),n=t.childCount,r=[];let i=0,o=null;const s=[];for(let u=0,c=e*n;u<c;u++)r[u]=0;for(let u=0,c=0;u<n;u++){const f=t.child(u);c++;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:x}=v.attrs;for(let _=0;_<b;_++){if(_+u>=n){(o||(o=[])).push({type:"overlong_rowspan",pos:c,n:b-_});break}const T=i+_*e;for(let S=0;S<g;S++){r[T+S]==0?r[T+S]=c:(o||(o=[])).push({type:"collision",row:u,pos:c,n:g-S});const z=x&&x[S];if(z){const E=(T+S)%e*2,D=s[E];D==null||D!=z&&s[E+1]==1?(s[E]=z,s[E+1]=1):D==z&&s[E+1]++}}}i+=g,c+=v.nodeSize}const h=(u+1)*e;let p=0;for(;i<h;)r[i++]==0&&p++;p&&(o||(o=[])).push({type:"missing",row:u,n:p}),c++}(e===0||n===0)&&(o||(o=[])).push({type:"zero_sized"});const a=new on(e,n,r,o);let l=!1;for(let u=0;!l&&u<s.length;u+=2)s[u]!=null&&s[u+1]<n&&(l=!0);return l&&vj(a,s,t),a}function gj(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 u=a.child(l);s+u.attrs.rowspan>r&&(o+=u.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 vj(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 u=0;u<l.colspan;u++){const c=e[(i+u)%t.width*2];c!=null&&(!l.colwidth||l.colwidth[u]!=c)&&((a||(a=bj(l)))[u]=c)}a&&t.problems.unshift({type:"colwidth mismatch",pos:o,colwidth:a})}}function bj(t){if(t.colwidth)return t.colwidth.slice();const e=[];for(let n=0;n<t.colspan;n++)e.push(0);return e}function Xn(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 Xo=new Nt("selectingCells");function Ca(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 yj(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 Ei(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 im(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=Ca(e.$head)||wj(e.$head);if(n)return n;throw new RangeError(`No cell found around position ${e.head}`)}function wj(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 kj(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function y1(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function nA(t,e,n){const r=t.node(-1),i=on.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 Sa(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 rA(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 xj(t,e,n){const r=Xn(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 Wt=class mo extends et{constructor(e,n=e){const r=e.node(-1),i=on.get(r),o=e.start(-1),s=i.rectBetween(e.pos-o,n.pos-o),a=e.node(0),l=i.cellsInRect(s).filter(c=>c!=n.pos-o);l.unshift(n.pos-o);const u=l.map(c=>{const f=r.nodeAt(c);if(!f)throw new RangeError(`No cell with offset ${c} found`);const h=o+c+1;return new kC(a.resolve(h),a.resolve(h+f.content.size))});super(u[0].$from,u[0].$to,u),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)&&y1(r,i)){const o=this.$anchorCell.node(-1)!=r.node(-1);return o&&this.isRowSelection()?mo.rowSelection(r,i):o&&this.isColSelection()?mo.colSelection(r,i):new mo(r,i)}return qe.between(r,i)}content(){const e=this.$anchorCell.node(-1),n=on.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 u=[];for(let c=l*n.width+i.left,f=i.left;f<i.right;f++,c++){const h=n.map[c];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=Sa(b,0,v)),g>0&&(b=Sa(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)}u.push(m)}s.push(e.child(l).copy(ge.from(u)))}const a=this.isColSelection()&&this.isRowSelection()?e:s;return new Te(ge.from(a),1,1)}replace(e,n=Te.empty){const r=e.steps.length,i=this.ranges;for(let s=0;s<i.length;s++){const{$from:a,$to:l}=i[s],u=e.mapping.slice(r);e.replace(u.map(a.pos),u.map(l.pos),s?Te.empty:n)}const o=et.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);o&&e.setSelection(o)}replaceWith(e,n){this.replace(e,new Te(ge.from(n),0,0))}forEachCell(e){const n=this.$anchorCell.node(-1),r=on.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=on.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 mo(e,n)}isRowSelection(){const e=this.$anchorCell.node(-1),n=on.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 mo&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,n=e){const r=e.node(-1),i=on.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 mo(e,n)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,n){return new mo(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){return new mo(e.resolve(n),e.resolve(r))}getBookmark(){return new _j(this.$anchorCell.pos,this.$headCell.pos)}};Wt.prototype.visible=!1;et.jsonID("cell",Wt);var _j=class iA{constructor(e,n){this.anchor=e,this.head=n}map(e){return new iA(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&&y1(n,r)?new Wt(n,r):et.near(r,1)}};function Cj(t){if(!(t.selection instanceof Wt))return null;const e=[];return t.selection.forEachCell((n,r)=>{e.push(Vt.node(r,r+n.nodeSize,{class:"selectedCell"}))}),nt.create(t.doc,e)}function Sj({$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 Ej({$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 Aj(t,e,n){const r=(e||t).selection,i=(e||t).doc;let o,s;if(r instanceof Ye&&(s=r.node.type.spec.tableRole)){if(s=="cell"||s=="header_cell")o=Wt.create(i,r.from);else if(s=="row"){const a=i.resolve(r.from+1);o=Wt.rowSelection(a,a)}else if(!n){const a=on.get(r.node),l=r.from+1,u=l+a.map[a.width*a.height-1];o=Wt.create(i,l+1,u)}}else r instanceof qe&&Sj(r)?o=qe.create(i,r.from):r instanceof qe&&Ej(r)&&(o=qe.create(i,r.$from.start(),r.$from.end()));return o&&(e||(e=t.tr)).setSelection(o),e}const Tj=new Nt("fix-tables");function oA(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 u=a,c=Math.min(i,s+3);u<c;u++)if(t.child(u)==l){a=u+1,n+=l.nodeSize;continue e}r(l,n),a<i&&t.child(a).sameMarkup(l)?oA(t.child(a),l,n+1,r):l.nodesBetween(0,l.content.size,r,n+1),n+=l.nodeSize}}function sA(t,e){let n;const r=(i,o)=>{i.type.spec.tableRole=="table"&&(n=Mj(t,i,o,n))};return e?e.doc!=t.doc&&oA(e.doc,t.doc,0,r):t.doc.descendants(r),n}function Mj(t,e,n,r){const i=on.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 u=i.problems[l];if(u.type=="collision"){const c=e.nodeAt(u.pos);if(!c)continue;const f=c.attrs;for(let h=0;h<f.rowspan;h++)o[u.row+h]+=u.n;r.setNodeMarkup(r.mapping.map(n+1+u.pos),null,Sa(f,f.colspan-u.n,u.n))}else if(u.type=="missing")o[u.row]+=u.n;else if(u.type=="overlong_rowspan"){const c=e.nodeAt(u.pos);if(!c)continue;r.setNodeMarkup(r.mapping.map(n+1+u.pos),null,{...c.attrs,rowspan:c.attrs.rowspan-u.n})}else if(u.type=="colwidth mismatch"){const c=e.nodeAt(u.pos);if(!c)continue;r.setNodeMarkup(r.mapping.map(n+1+u.pos),null,{...c.attrs,colwidth:u.colwidth})}else if(u.type=="zero_sized"){const c=r.mapping.map(n);r.delete(c,c+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,u=n+1;l<i.height;l++){const c=e.child(l),f=u+c.nodeSize,h=o[l];if(h>0){let p="cell";c.firstChild&&(p=c.firstChild.type.spec.tableRole);const m=[];for(let g=0;g<h;g++){const b=Xn(t.schema)[p].createAndFill();b&&m.push(b)}const v=(l==0||s==l-1)&&a==l?u+1:f-1;r.insert(r.mapping.map(v),m)}u=f}return r.setMeta(Tj,{fixTables:!0})}function io(t){const e=t.selection,n=im(t),r=n.node(-1),i=n.start(-1),o=on.get(r);return{...e instanceof Wt?o.rectBetween(e.$anchorCell.pos-i,e.$headCell.pos-i):o.findCell(n.pos-i),tableStart:i,map:o,table:r}}function aA(t,{map:e,tableStart:n,table:r},i){let o=i>0?-1:0;xj(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],u=r.nodeAt(l);t.setNodeMarkup(t.mapping.map(n+l),null,rA(u.attrs,i-e.colCount(l))),s+=u.attrs.rowspan-1}else{const l=o==null?Xn(r.type.schema).cell:r.nodeAt(e.map[a+o]).type,u=e.positionAt(s,i,r);t.insert(t.mapping.map(n+u),l.createAndFill())}}return t}function Dj(t,e){if(!Ei(t))return!1;if(e){const n=io(t);e(aA(t.tr,n,n.left))}return!0}function Oj(t,e){if(!Ei(t))return!1;if(e){const n=io(t);e(aA(t.tr,n,n.right))}return!0}function Ij(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],u=n.nodeAt(l),c=u.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,Sa(c,i-e.colCount(l)));else{const f=t.mapping.slice(o).map(r+l);t.delete(f,f+u.nodeSize)}s+=c.rowspan}}function Rj(t,e){if(!Ei(t))return!1;if(e){const n=io(t),r=t.tr;if(n.left==0&&n.right==n.map.width)return!1;for(let i=n.right-1;Ij(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=on.get(o)}e(r)}return!0}function Nj(t,e,n){var r;const i=Xn(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 lA(t,{map:e,tableStart:n,table:r},i){let o=n;for(let u=0;u<i;u++)o+=r.child(u).nodeSize;const s=[];let a=i>0?-1:0;Nj(e,r,i+a)&&(a=i==0||i==e.height?null:0);for(let u=0,c=e.width*i;u<e.width;u++,c++)if(i>0&&i<e.height&&e.map[c]==e.map[c-e.width]){const f=e.map[c],h=r.nodeAt(f).attrs;t.setNodeMarkup(n+f,null,{...h,rowspan:h.rowspan+1}),u+=h.colspan-1}else{var l;const f=a==null?Xn(r.type.schema).cell:(l=r.nodeAt(e.map[c+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,Xn(r.type.schema).row.create(null,s)),t}function Pj(t,e){if(!Ei(t))return!1;if(e){const n=io(t);e(lA(t.tr,n,n.top))}return!0}function Lj(t,e){if(!Ei(t))return!1;if(e){const n=io(t);e(lA(t.tr,n,n.bottom))}return!0}function Fj(t,{map:e,table:n,tableStart:r},i){let o=0;for(let u=0;u<i;u++)o+=n.child(u).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 u=0,c=i*e.width;u<e.width;u++,c++){const f=e.map[c];if(!l.has(f)){if(l.add(f),i>0&&f==e.map[c-e.width]){const h=n.nodeAt(f).attrs;t.setNodeMarkup(t.mapping.slice(a).map(f+r),null,{...h,rowspan:h.rowspan-1}),u+=h.colspan-1}else if(i<e.height&&f==e.map[c+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,u,n);t.insert(t.mapping.slice(a).map(r+v),m),u+=p.colspan-1}}}}function zj(t,e){if(!Ei(t))return!1;if(e){const n=io(t),r=t.tr;if(n.top==0&&n.bottom==n.map.height)return!1;for(let i=n.bottom-1;Fj(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=on.get(n.table)}e(r)}return!0}function q2(t){const e=t.content;return e.childCount==1&&e.child(0).isTextblock&&e.child(0).childCount==0}function Bj({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 W2(t,e){const n=t.selection;if(!(n instanceof Wt)||n.$anchorCell.pos==n.$headCell.pos)return!1;const r=io(t),{map:i}=r;if(Bj(i,r))return!1;if(e){const o=t.tr,s={};let a=ge.empty,l,u;for(let c=r.top;c<r.bottom;c++)for(let f=r.left;f<r.right;f++){const h=i.map[c*i.width+f],p=r.table.nodeAt(h);if(!(s[h]||!p))if(s[h]=!0,l==null)l=h,u=p;else{q2(p)||(a=a.append(p.content));const m=o.mapping.map(h+r.tableStart);o.delete(m,m+p.nodeSize)}}if(l==null||u==null)return!0;if(o.setNodeMarkup(l+r.tableStart,null,{...rA(u.attrs,u.attrs.colspan,r.right-r.left-u.attrs.colspan),rowspan:r.bottom-r.top}),a.size>0){const c=l+1+u.content.size,f=q2(u)?l+1:c;o.replaceWith(f+r.tableStart,c+r.tableStart,a)}o.setSelection(new Wt(o.doc.resolve(l+r.tableStart))),e(o)}return!0}function K2(t,e){const n=Xn(t.schema);return Hj(({node:r})=>n[r.type.spec.tableRole])(t,e)}function Hj(t){return(e,n)=>{const r=e.selection;let i,o;if(r instanceof Wt){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;i=r.$anchorCell.nodeAfter,o=r.$anchorCell.pos}else{var s;if(i=yj(r.$from),!i)return!1;o=(s=Ca(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=[],u=a.colwidth;a.rowspan>1&&(a={...a,rowspan:1}),a.colspan>1&&(a={...a,colspan:1});const c=io(e),f=e.tr;for(let p=0;p<c.right-c.left;p++)l.push(u?{...a,colwidth:u&&u[p]?[u[p]]:null}:a);let h;for(let p=c.top;p<c.bottom;p++){let m=c.map.positionAt(p,c.left,c.table);p==c.top&&(m+=i.nodeSize);for(let v=c.left,g=0;v<c.right;v++,g++)v==c.left&&p==c.top||f.insert(h=f.mapping.map(m+c.tableStart,1),t({node:i,row:p,col:v}).createAndFill(l[g]))}f.setNodeMarkup(o,t({node:i,row:c.top,col:c.left}),l[0]),r instanceof Wt&&f.setSelection(new Wt(f.doc.resolve(r.$anchorCell.pos),h?f.doc.resolve(h):void 0)),n(f)}return!0}}function Vj(t,e){return function(n,r){if(!Ei(n))return!1;const i=im(n);if(i.nodeAfter.attrs[t]===e)return!1;if(r){const o=n.tr;n.selection instanceof Wt?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 Uj(t){return function(e,n){if(!Ei(e))return!1;if(n){const r=Xn(e.schema),i=io(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 G2(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 zc(t,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?Uj(t):function(n,r){if(!Ei(n))return!1;if(r){const i=Xn(n.schema),o=io(n),s=n.tr,a=G2("row",o,i),l=G2("column",o,i),u=(t==="column"?a:t==="row"&&l)?1:0,c=t=="column"?{left:0,top:u,right:1,bottom:o.map.height}:t=="row"?{left:u,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(c).forEach(h=>{const p=h+o.tableStart,m=s.doc.nodeAt(p);m&&s.setNodeMarkup(p,f,m.attrs)}),r(s)}return!0}}zc("row",{useDeprecatedLogic:!0});zc("column",{useDeprecatedLogic:!0});const jj=zc("cell",{useDeprecatedLogic:!0});function qj(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 Z2(t){return function(e,n){if(!Ei(e))return!1;const r=qj(im(e),t);if(r==null)return!1;if(n){const i=e.doc.resolve(r);n(e.tr.setSelection(qe.between(i,kj(i))).scrollIntoView())}return!0}}function Wj(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 Kd(t,e){const n=t.selection;if(!(n instanceof Wt))return!1;if(e){const r=t.tr,i=Xn(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 Te(i,0,0))}),r.docChanged&&e(r)}return!0}function Kj(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 u=e.child(l).content;const c=l?0:Math.max(0,n-1),f=l<e.childCount-1?0:Math.max(0,r-1);(c||f)&&(u=_v(Xn(s).row,new Te(u,c,f)).content),a.push(u)}else if(o=="cell"||o=="header_cell")a.push(n||r?_v(Xn(s).row,new Te(e,n,r)).content:e);else return null;return Gj(s,a)}function Gj(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 u=i;u<i+a;u++)n[u]=(n[u]||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(ge.empty),n[i]<r){const o=Xn(t).cell.createAndFill(),s=[];for(let a=n[i];a<r;a++)s.push(o);e[i]=e[i].append(ge.from(s))}return{height:e.length,width:r,rows:e}}function _v(t,e){const n=t.createAndFill();return new ib(n).replace(0,n.content.size,e).doc}function Zj({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],u=[];for(let c=o[a]||0,f=0;c<r;f++){let h=l.child(f%l.childCount);c+h.attrs.colspan>r&&(h=h.type.createChecked(Sa(h.attrs,h.attrs.colspan,c+h.attrs.colspan-r),h.content)),u.push(h),c+=h.attrs.colspan;for(let p=1;p<h.attrs.rowspan;p++)o[a+p]=(o[a+p]||0)+h.attrs.colspan}s.push(ge.from(u))}n=s,t=r}if(e!=i){const o=[];for(let s=0,a=0;s<i;s++,a++){const l=[],u=n[a%e];for(let c=0;c<u.childCount;c++){let f=u.child(c);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(ge.from(l))}n=o,e=i}return{width:t,height:e,rows:n}}function Jj(t,e,n,r,i,o,s){const a=t.doc.type.schema,l=Xn(a);let u,c;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=u||(u=l.cell.createAndFill()):v=c||(c=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?c||(c=l.header_cell.createAndFill()):u||(u=l.cell.createAndFill()))}const h=l.row.create(null,ge.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!!(u||c)}function J2(t,e,n,r,i,o,s,a){if(s==0||s==e.height)return!1;let l=!1;for(let u=i;u<o;u++){const c=s*e.width+u,f=e.map[c];if(e.map[c-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})),u+=h.attrs.colspan-1}}return l}function Y2(t,e,n,r,i,o,s,a){if(s==0||s==e.width)return!1;let l=!1;for(let u=i;u<o;u++){const c=u*e.width+s,f=e.map[c];if(e.map[c-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,Sa(h.attrs,s-p,h.attrs.colspan-(s-p))),t.insert(m+h.nodeSize,h.type.createAndFill(Sa(h.attrs,0,s-p))),u+=h.attrs.rowspan-1}}return l}function X2(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=on.get(o);const{top:a,left:l}=r,u=l+i.width,c=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=on.get(o),h=f.mapping.maps.length}Jj(f,s,o,n,u,c,h)&&p(),J2(f,s,o,n,l,u,a,h)&&p(),J2(f,s,o,n,l,u,c,h)&&p(),Y2(f,s,o,n,a,c,l,h)&&p(),Y2(f,s,o,n,a,c,u,h)&&p();for(let m=a;m<c;m++){const v=s.positionAt(m,l,o),g=s.positionAt(m,u,o);f.replace(f.mapping.slice(h).map(v+n),f.mapping.slice(h).map(g+n),new Te(i.rows[m-a],0,0))}p(),f.setSelection(new Wt(f.doc.resolve(n+s.positionAt(a,l,o)),f.doc.resolve(n+s.positionAt(c-1,u-1,o)))),e(f)}const Yj=Xb({ArrowLeft:Gd("horiz",-1),ArrowRight:Gd("horiz",1),ArrowUp:Gd("vert",-1),ArrowDown:Gd("vert",1),"Shift-ArrowLeft":Zd("horiz",-1),"Shift-ArrowRight":Zd("horiz",1),"Shift-ArrowUp":Zd("vert",-1),"Shift-ArrowDown":Zd("vert",1),Backspace:Kd,"Mod-Backspace":Kd,Delete:Kd,"Mod-Delete":Kd});function Rf(t,e,n){return n.eq(t.selection)?!1:(e&&e(t.tr.setSelection(n).scrollIntoView()),!0)}function Gd(t,e){return(n,r,i)=>{if(!i)return!1;const o=n.selection;if(o instanceof Wt)return Rf(n,r,et.near(o.$headCell,e));if(t!="horiz"&&!o.empty)return!1;const s=uA(i,t,e);if(s==null)return!1;if(t=="horiz")return Rf(n,r,et.near(n.doc.resolve(o.head+e),e));{const a=n.doc.resolve(s),l=nA(a,t,e);let u;return l?u=et.near(l,1):e<0?u=et.near(n.doc.resolve(a.before(-1)),-1):u=et.near(n.doc.resolve(a.after(-1)),1),Rf(n,r,u)}}}function Zd(t,e){return(n,r,i)=>{if(!i)return!1;const o=n.selection;let s;if(o instanceof Wt)s=o;else{const l=uA(i,t,e);if(l==null)return!1;s=new Wt(n.doc.resolve(l))}const a=nA(s.$headCell,t,e);return a?Rf(n,r,new Wt(s.$anchorCell,a)):!1}}function Xj(t,e){const n=t.state.doc,r=Ca(n.resolve(e));return r?(t.dispatch(t.state.tr.setSelection(new Wt(r))),!0):!1}function Qj(t,e,n){if(!Ei(t.state))return!1;let r=Kj(n);const i=t.state.selection;if(i instanceof Wt){r||(r={width:1,height:1,rows:[ge.from(_v(Xn(t.state.schema).cell,n))]});const o=i.$anchorCell.node(-1),s=i.$anchorCell.start(-1),a=on.get(o).rectBetween(i.$anchorCell.pos-s,i.$headCell.pos-s);return r=Zj(r,a.right-a.left,a.bottom-a.top),X2(t.state,t.dispatch,s,a,r),!0}else if(r){const o=im(t.state),s=o.start(-1);return X2(t.state,t.dispatch,s,on.get(o.node(-1)).findCell(o.pos-s),r),!0}else return!1}function $j(t,e){var n;if(e.button!=0||e.ctrlKey||e.metaKey)return;const r=Q2(t,e.target);let i;if(e.shiftKey&&t.state.selection instanceof Wt)o(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(i=Ca(t.state.selection.$anchor))!=null&&((n=bg(t,e))===null||n===void 0?void 0:n.pos)!=i.pos)o(i,e),e.preventDefault();else if(!r)return;function o(l,u){let c=bg(t,u);const f=Xo.getState(t.state)==null;if(!c||!y1(l,c))if(f)c=l;else return;const h=new Wt(l,c);if(f||!t.state.selection.eq(h)){const p=t.state.tr.setSelection(h);f&&p.setMeta(Xo,l.pos),t.dispatch(p)}}function s(){t.root.removeEventListener("mouseup",s),t.root.removeEventListener("dragstart",s),t.root.removeEventListener("mousemove",a),Xo.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta(Xo,-1))}function a(l){const u=l,c=Xo.getState(t.state);let f;if(c!=null)f=t.state.doc.resolve(c);else if(Q2(t,u.target)!=r&&(f=bg(t,e),!f))return s();f&&o(f,u)}t.root.addEventListener("mouseup",s),t.root.addEventListener("dragstart",s),t.root.addEventListener("mousemove",a)}function uA(t,e,n){if(!(t.state.selection instanceof qe))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 Q2(t,e){for(;e&&e!=t.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function bg(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&&Ca(t.state.doc.resolve(r))||Ca(t.state.doc.resolve(i))}var eq=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")),Cv(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,Cv(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function Cv(t,e,n,r,i,o){let s=0,a=!0,l=e.firstChild;const u=t.firstChild;if(u){for(let f=0,h=0;f<u.childCount;f++){const{colspan:p,colwidth:m}=u.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 x=document.createElement("col");x.style.width=b,e.appendChild(x)}}}for(;l;){var c;const f=l.nextSibling;(c=l.parentNode)===null||c===void 0||c.removeChild(l),l=f}a?(n.style.width=s+"px",n.style.minWidth=""):(n.style.width="",n.style.minWidth=s+"px")}}const Lr=new Nt("tableColumnResizing");function tq({handleWidth:t=5,cellMinWidth:e=25,defaultCellMinWidth:n=100,View:r=eq,lastColumnResizable:i=!0}={}){const o=new Dt({key:Lr,state:{init(s,a){var l;const u=(l=o.spec)===null||l===void 0||(l=l.props)===null||l===void 0?void 0:l.nodeViews,c=Xn(a.schema).table.name;return r&&u&&(u[c]=(f,h)=>new r(f,n,h)),new nq(-1,!1)},apply(s,a){return a.apply(s)}},props:{attributes:s=>{const a=Lr.getState(s);return a&&a.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(s,a)=>{rq(s,a,t,i)},mouseleave:s=>{iq(s)},mousedown:(s,a)=>{oq(s,a,e,n)}},decorations:s=>{const a=Lr.getState(s);if(a&&a.activeHandle>-1)return cq(s,a.activeHandle)},nodeViews:{}}});return o}var nq=class Nf{constructor(e,n){this.activeHandle=e,this.dragging=n}apply(e){const n=this,r=e.getMeta(Lr);if(r&&r.setHandle!=null)return new Nf(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new Nf(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 Nf(i,n.dragging)}return n}};function rq(t,e,n,r){if(!t.editable)return;const i=Lr.getState(t.state);if(i&&!i.dragging){const o=aq(e.target);let s=-1;if(o){const{left:a,right:l}=o.getBoundingClientRect();e.clientX-a<=n?s=$2(t,e,"left",n):l-e.clientX<=n&&(s=$2(t,e,"right",n))}if(s!=i.activeHandle){if(!r&&s!==-1){const a=t.state.doc.resolve(s),l=a.node(-1),u=on.get(l),c=a.start(-1);if(u.colCount(a.pos-c)+a.nodeAfter.attrs.colspan-1==u.width-1)return}cA(t,s)}}}function iq(t){if(!t.editable)return;const e=Lr.getState(t.state);e&&e.activeHandle>-1&&!e.dragging&&cA(t,-1)}function oq(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=Lr.getState(t.state);if(!s||s.activeHandle==-1||s.dragging)return!1;const a=t.state.doc.nodeAt(s.activeHandle),l=sq(t,s.activeHandle,a.attrs);t.dispatch(t.state.tr.setMeta(Lr,{setDragging:{startX:e.clientX,startWidth:l}}));function u(f){o.removeEventListener("mouseup",u),o.removeEventListener("mousemove",c);const h=Lr.getState(t.state);h!=null&&h.dragging&&(lq(t,h.activeHandle,ek(h.dragging,f,n)),t.dispatch(t.state.tr.setMeta(Lr,{setDragging:null})))}function c(f){if(!f.which)return u(f);const h=Lr.getState(t.state);if(h&&h.dragging){const p=ek(h.dragging,f,n);tk(t,h.activeHandle,p,r)}}return tk(t,s.activeHandle,l,r),o.addEventListener("mouseup",u),o.addEventListener("mousemove",c),e.preventDefault(),!0}function sq(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 aq(t){for(;t&&t.nodeName!="TD"&&t.nodeName!="TH";)t=t.classList&&t.classList.contains("ProseMirror")?null:t.parentNode;return t}function $2(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=Ca(t.state.doc.resolve(s));if(!a)return-1;if(n=="right")return a.pos;const l=on.get(a.node(-1)),u=a.start(-1),c=l.map.indexOf(a.pos-u);return c%l.width==0?-1:u+l.map[c-1]}function ek(t,e,n){const r=e.clientX-t.startX;return Math.max(n,t.startWidth+r)}function cA(t,e){t.dispatch(t.state.tr.setMeta(Lr,{setHandle:e}))}function lq(t,e,n){const r=t.state.doc.resolve(e),i=r.node(-1),o=on.get(i),s=r.start(-1),a=o.colCount(r.pos-s)+r.nodeAfter.attrs.colspan-1,l=t.state.tr;for(let u=0;u<o.height;u++){const c=u*o.width+a;if(u&&o.map[c]==o.map[c-o.width])continue;const f=o.map[c],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():uq(h.colspan);m[p]=n,l.setNodeMarkup(s+f,null,{...h,colwidth:m})}l.docChanged&&t.dispatch(l)}function tk(t,e,n,r){const i=t.state.doc.resolve(e),o=i.node(-1),s=i.start(-1),a=on.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&&Cv(o,l.firstChild,l,r,a,n)}function uq(t){return Array(t).fill(0)}function cq(t,e){const n=[],r=t.doc.resolve(e),i=r.node(-1);if(!i)return nt.empty;const o=on.get(i),s=r.start(-1),a=o.colCount(r.pos-s)+r.nodeAfter.attrs.colspan-1;for(let u=0;u<o.height;u++){const c=a+u*o.width;if((a==o.width-1||o.map[c]!=o.map[c+1])&&(u==0||o.map[c]!=o.map[c-o.width])){var l;const f=o.map[c],h=s+f+i.nodeAt(f).nodeSize-1,p=document.createElement("div");p.className="column-resize-handle",!((l=Lr.getState(t))===null||l===void 0)&&l.dragging&&n.push(Vt.node(s+f,s+f+i.nodeAt(f).nodeSize,{class:"column-resize-dragging"})),n.push(Vt.widget(h,p))}}return nt.create(t.doc,n)}function dq({allowTableNodeSelection:t=!1}={}){return new Dt({key:Xo,state:{init(){return null},apply(e,n){const r=e.getMeta(Xo);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:Cj,handleDOMEvents:{mousedown:$j},createSelectionBetween(e){return Xo.getState(e.state)!=null?e.state.selection:null},handleTripleClick:Xj,handleKeyDown:Yj,handlePaste:Qj},appendTransaction(e,n,r){return Aj(r,sA(r,n),t)}})}function Sv(t,e){return e?["width",`${Math.max(e,t)}px`]:["min-width",`${t}px`]}function nk(t,e,n,r,i,o){var s;let a=0,l=!0,u=e.firstChild;const c=t.firstChild;if(c!==null)for(let f=0,h=0;f<c.childCount;f+=1){const{colspan:p,colwidth:m}=c.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),u){if(u.style.width!==b){const[x,_]=Sv(r,g);u.style.setProperty(x,_)}u=u.nextSibling}else{const x=document.createElement("col"),[_,T]=Sv(r,g);x.style.setProperty(_,T),e.appendChild(x)}}}for(;u;){const f=u.nextSibling;(s=u.parentNode)===null||s===void 0||s.removeChild(u),u=f}l?(n.style.width=`${a}px`,n.style.minWidth=""):(n.style.width="",n.style.minWidth=`${a}px`)}class fq{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")),nk(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,nk(e,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(e){return e.type==="attributes"&&(e.target===this.table||this.colgroup.contains(e.target))}}function hq(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,x]=Sv(e,g);s.push(["col",{style:`${b}: ${x}`}])}}const l=o?`${i}px`:"",u=o?"":`${i}px`;return{colgroup:["colgroup",{},...s],tableWidth:l,tableMinWidth:u}}function rk(t,e){return t.createAndFill()}function pq(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 mq(t,e,n,r,i){const o=pq(t),s=[],a=[];for(let u=0;u<n;u+=1){const c=rk(o.cell);if(c&&a.push(c),r){const f=rk(o.header_cell);f&&s.push(f)}}const l=[];for(let u=0;u<e;u+=1)l.push(o.row.createChecked(null,r&&u===0?s:a));return o.table.createChecked(null,l)}function gq(t){return t instanceof Wt}const Jd=({editor:t})=>{const{selection:e}=t.state;if(!gq(e))return!1;let n=0;const r=VE(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},vq=hr.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:fq,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}=hq(t,this.options.cellMinWidth),o=["table",ln(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=mq(o.schema,t,e,n);if(i){const a=r.selection.from+1;r.replaceSelectionWith(s).scrollIntoView().setSelection(qe.near(r.doc.resolve(a)))}return!0},addColumnBefore:()=>({state:t,dispatch:e})=>Dj(t,e),addColumnAfter:()=>({state:t,dispatch:e})=>Oj(t,e),deleteColumn:()=>({state:t,dispatch:e})=>Rj(t,e),addRowBefore:()=>({state:t,dispatch:e})=>Pj(t,e),addRowAfter:()=>({state:t,dispatch:e})=>Lj(t,e),deleteRow:()=>({state:t,dispatch:e})=>zj(t,e),deleteTable:()=>({state:t,dispatch:e})=>Wj(t,e),mergeCells:()=>({state:t,dispatch:e})=>W2(t,e),splitCell:()=>({state:t,dispatch:e})=>K2(t,e),toggleHeaderColumn:()=>({state:t,dispatch:e})=>zc("column")(t,e),toggleHeaderRow:()=>({state:t,dispatch:e})=>zc("row")(t,e),toggleHeaderCell:()=>({state:t,dispatch:e})=>jj(t,e),mergeOrSplit:()=>({state:t,dispatch:e})=>W2(t,e)?!0:K2(t,e),setCellAttribute:(t,e)=>({state:n,dispatch:r})=>Vj(t,e)(n,r),goToNextCell:()=>({state:t,dispatch:e})=>Z2(1)(t,e),goToPreviousCell:()=>({state:t,dispatch:e})=>Z2(-1)(t,e),fixTables:()=>({state:t,dispatch:e})=>(e&&sA(t),!0),setCellSelection:t=>({tr:e,dispatch:n})=>{if(n){const r=Wt.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:Jd,"Mod-Backspace":Jd,Delete:Jd,"Mod-Delete":Jd}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[tq({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],dq({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(t){const e={name:t.name,options:t.options,storage:t.storage};return{tableRole:ft(Fe(t,"tableRole",e))}}}),bq=hr.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",ln(this.options.HTMLAttributes,t),0]}}),yq=hr.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",ln(this.options.HTMLAttributes,t),0]}}),wq=hr.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:t}){return["tr",ln(this.options.HTMLAttributes,t),0]}}),kq=/^\s*>\s$/,xq=hr.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return["blockquote",ln(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[Nc({find:kq,type:this.type})]}}),_q=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,Cq=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,Sq=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,Eq=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,Aq=to.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",ln(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[_a({find:_q,type:this.type}),_a({find:Sq,type:this.type})]},addPasteRules(){return[As({find:Cq,type:this.type}),As({find:Eq,type:this.type})]}}),Tq="listItem",ik="textStyle",ok=/^\s*([-+*])\s$/,Mq=hr.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",ln(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(Tq,this.editor.getAttributes(ik)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=Nc({find:ok,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Nc({find:ok,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(ik),editor:this.editor})),[t]}}),Dq=/(^|[^`])`([^`]+)`(?!`)/,Oq=/(^|[^`])`([^`]+)`(?!`)/g,Iq=to.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",ln(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[_a({find:Dq,type:this.type})]},addPasteRules(){return[As({find:Oq,type:this.type})]}}),Rq=/^```([a-z]+)?[\s\n]$/,Nq=/^~~~([a-z]+)?[\s\n]$/,Pq=hr.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",ln(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(`
|
|
193
|
+
|
|
194
|
+
`);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:u})=>(u.setSelection(et.near(r.resolve(a))),!0)):t.commands.exitCode()}}},addInputRules(){return[sv({find:Rq,type:this.type,getAttributes:t=>({language:t[1]})}),sv({find:Nq,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new Dt({key:new Nt("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,`
|
|
195
|
+
`));return s.replaceSelectionWith(this.type.create({language:o},l)),s.selection.$from.parent.type!==this.type&&s.setSelection(qe.near(s.doc.resolve(Math.max(0,s.selection.from-2)))),s.setMeta("paste",!0),t.dispatch(s),!0}}})]}}),Lq=hr.create({name:"doc",topNode:!0,content:"block+"});function Fq(t={}){return new Dt({view(e){return new zq(e,t)}})}class zq{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 u,c;if(!l||l==document.body&&getComputedStyle(l).position=="static")u=-pageXOffset,c=-pageYOffset;else{let f=l.getBoundingClientRect(),h=f.width/l.offsetWidth,p=f.height/l.offsetHeight;u=f.left-l.scrollLeft*h,c=f.top-l.scrollTop*p}this.element.style.left=(r.left-u)/s+"px",this.element.style.top=(r.top-c)/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=gC(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 Bq=Kt.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[Fq(this.options)]}});class tn extends et{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return tn.valid(r)?new tn(r):et.near(r)}content(){return Te.empty}eq(e){return e instanceof tn&&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 tn(e.resolve(n.pos))}getBookmark(){return new w1(this.anchor)}static valid(e){let n=e.parent;if(n.inlineContent||!Hq(e)||!Vq(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&&tn.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(tn.valid(l))return l}for(;;){let s=n>0?o.firstChild:o.lastChild;if(!s){if(o.isAtom&&!o.isText&&!Ye.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(tn.valid(a))return a}return null}}}tn.prototype.visible=!1;tn.findFrom=tn.findGapCursorFrom;et.jsonID("gapcursor",tn);class w1{constructor(e){this.pos=e}map(e){return new w1(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return tn.valid(n)?new tn(n):et.near(n)}}function dA(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function Hq(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||dA(i.type))return!0;if(i.inlineContent)return!1}}return!0}function Vq(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||dA(i.type))return!0;if(i.inlineContent)return!1}}return!0}function Uq(){return new Dt({props:{decorations:Kq,createSelectionBetween(t,e,n){return e.pos==n.pos&&tn.valid(n)?new tn(n):null},handleClick:qq,handleKeyDown:jq,handleDOMEvents:{beforeinput:Wq}}})}const jq=Xb({ArrowLeft:Yd("horiz",-1),ArrowRight:Yd("horiz",1),ArrowUp:Yd("vert",-1),ArrowDown:Yd("vert",1)});function Yd(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 qe){if(!o.endOfTextblock(n)||a.depth==0)return!1;l=!1,a=r.doc.resolve(e>0?a.after():a.before())}let u=tn.findGapCursorFrom(a,e,l);return u?(i&&i(r.tr.setSelection(new tn(u))),!0):!1}}function qq(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!tn.valid(r))return!1;let i=t.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&Ye.isSelectable(t.state.doc.nodeAt(i.inside))?!1:(t.dispatch(t.state.tr.setSelection(new tn(r))),!0)}function Wq(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof tn))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=ge.empty;for(let s=r.length-1;s>=0;s--)i=ge.from(r[s].createAndFill(null,i));let o=t.state.tr.replace(n.pos,n.pos,new Te(i,0,0));return o.setSelection(qe.near(o.doc.resolve(n.pos+1))),t.dispatch(o),!1}function Kq(t){if(!(t.selection instanceof tn))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",nt.create(t.doc,[Vt.widget(t.selection.head,e,{key:"gapcursor"})])}const Gq=Kt.create({name:"gapCursor",addProseMirrorPlugins(){return[Uq()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=ft(Fe(t,"allowGapCursor",n)))!==null&&e!==void 0?e:null}}}),Zq=hr.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",ln(this.options.HTMLAttributes,t)]},renderText(){return`
|
|
196
|
+
`},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:u,dispatch:c})=>{if(c&&l&&s){const f=l.filter(h=>a.includes(h.type.name));u.ensureMarks(f)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),Jq=hr.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]}`,ln(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=>sv({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}});var rp=200,Tn=function(){};Tn.prototype.append=function(e){return e.length?(e=Tn.from(e),!this.length&&e||e.length<rp&&this.leafAppend(e)||this.length<rp&&e.leafPrepend(this)||this.appendInner(e)):this};Tn.prototype.prepend=function(e){return e.length?Tn.from(e).append(this):this};Tn.prototype.appendInner=function(e){return new Yq(this,e)};Tn.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?Tn.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};Tn.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};Tn.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)};Tn.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};Tn.from=function(e){return e instanceof Tn?e:e&&e.length?new fA(e):Tn.empty};var fA=(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<=rp)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=rp)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})(Tn);Tn.empty=new fA([]);var Yq=(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})(Tn);const Xq=500;class gi{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,u=[],c=[];return this.items.forEach((f,h)=>{if(!f.step){i||(i=this.remapping(r,h+1),o=i.maps.length),o--,c.push(f);return}if(i){c.push(new Ni(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],u.push(new Ni(m,void 0,void 0,u.length+c.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 gi(this.items.slice(0,r).append(c.reverse().concat(u)),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 c=0;c<e.steps.length;c++){let f=e.steps[c].invert(e.docs[c]),h=new Ni(e.mapping.maps[c],f,n),p;(p=l&&l.merge(h))&&(h=p,c?o.pop():a=a.slice(0,a.length-1)),o.push(h),n&&(s++,n=void 0),i||(l=h)}let u=s-r.depth;return u>$q&&(a=Qq(a,u),s-=u),new gi(a.append(o),s)}remapping(e,n){let r=new cc;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 gi(this.items.append(e.map(n=>new Ni(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 Ni(m,v,g))}else r.push(new Ni(m))},i);let u=[];for(let h=n;h<s;h++)u.push(new Ni(o.maps[h]));let c=this.items.slice(0,i).append(u).append(r),f=new gi(c,a);return f.emptyItemCount()>Xq&&(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)),u=l&&l.getMap();if(r--,u&&n.appendMap(u,r),l){let c=s.selection&&s.selection.map(n.slice(r));c&&o++;let f=new Ni(u.invert(),l,c),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 gi(Tn.from(i.reverse()),o)}}gi.empty=new gi(Tn.empty,0);function Qq(t,e){let n;return t.forEach((r,i)=>{if(r.selection&&e--==0)return n=i,!1}),t.slice(n)}class Ni{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 Ni(n.getMap().invert(),n,this.selection)}}}class Ko{constructor(e,n,r,i,o){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=i,this.prevComposition=o}}const $q=20;function eW(t,e,n,r){let i=n.getMeta(ca),o;if(i)return i.historyState;n.getMeta(rW)&&(t=new Ko(t.done,t.undone,null,0,-1));let s=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(s&&s.getMeta(ca))return s.getMeta(ca).redo?new Ko(t.done.addTransform(n,void 0,r,Pf(e)),t.undone,sk(n.mapping.maps),t.prevTime,t.prevComposition):new Ko(t.done,t.undone.addTransform(n,void 0,r,Pf(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||!tW(n,t.prevRanges)),u=s?yg(t.prevRanges,n.mapping):sk(n.mapping.maps);return new Ko(t.done.addTransform(n,l?e.selection.getBookmark():void 0,r,Pf(e)),gi.empty,u,n.time,a??t.prevComposition)}else return(o=n.getMeta("rebased"))?new Ko(t.done.rebased(n,o),t.undone.rebased(n,o),yg(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new Ko(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),yg(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function tW(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 sk(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 yg(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 nW(t,e,n){let r=Pf(e),i=ca.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 Ko(n?a:o.remaining,n?o.remaining:a,null,0,-1);return o.transform.setSelection(s).setMeta(ca,{redo:n,historyState:l})}let wg=!1,ak=null;function Pf(t){let e=t.plugins;if(ak!=e){wg=!1,ak=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){wg=!0;break}}return wg}const ca=new Nt("history"),rW=new Nt("closeHistory");function iW(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new Dt({key:ca,state:{init(){return new Ko(gi.empty,gi.empty,null,0,-1)},apply(e,n,r){return eW(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,i=r=="historyUndo"?pA:r=="historyRedo"?mA:null;return!i||!e.editable?!1:(n.preventDefault(),i(e.state,e.dispatch))}}}})}function hA(t,e){return(n,r)=>{let i=ca.getState(n);if(!i||(t?i.undone:i.done).eventCount==0)return!1;if(r){let o=nW(i,n,t);o&&r(e?o.scrollIntoView():o)}return!0}}const pA=hA(!1,!0),mA=hA(!0,!0),oW=Kt.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>pA(t,e),redo:()=>({state:t,dispatch:e})=>mA(t,e)}},addProseMirrorPlugins(){return[iW(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()}}}),sW=hr.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",ln(this.options.HTMLAttributes,t)]},addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!XV(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}):bV(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:u}=s.selection,c=u.end();if(u.nodeAfter)u.nodeAfter.isTextblock?s.setSelection(qe.create(s.doc,u.pos+1)):u.nodeAfter.isBlock?s.setSelection(Ye.create(s.doc,u.pos)):s.setSelection(qe.create(s.doc,u.pos));else{const f=(l=u.parent.type.contentMatch.defaultType)===null||l===void 0?void 0:l.create();f&&(s.insert(c,f),s.setSelection(qe.create(s.doc,c+1)))}s.scrollIntoView()}return!0}).run()}}},addInputRules(){return[YV({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),aW=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,lW=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,uW=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,cW=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,dW=to.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",ln(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[_a({find:aW,type:this.type}),_a({find:uW,type:this.type})]},addPasteRules(){return[As({find:lW,type:this.type}),As({find:cW,type:this.type})]}}),fW=hr.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",ln(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)}}}),hW="listItem",lk="textStyle",uk=/^(\d+)\.\s$/,pW=hr.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",ln(this.options.HTMLAttributes,n),0]:["ol",ln(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(hW,this.editor.getAttributes(lk)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=Nc({find:uk,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=Nc({find:uk,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(lk)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),mW=hr.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",ln(this.options.HTMLAttributes,t),0]},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),gW=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,vW=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,bW=to.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",ln(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[_a({find:gW,type:this.type})]},addPasteRules(){return[As({find:vW,type:this.type})]}}),yW=hr.create({name:"text",group:"inline"}),wW=Kt.create({name:"starterKit",addExtensions(){const t=[];return this.options.bold!==!1&&t.push(Aq.configure(this.options.bold)),this.options.blockquote!==!1&&t.push(xq.configure(this.options.blockquote)),this.options.bulletList!==!1&&t.push(Mq.configure(this.options.bulletList)),this.options.code!==!1&&t.push(Iq.configure(this.options.code)),this.options.codeBlock!==!1&&t.push(Pq.configure(this.options.codeBlock)),this.options.document!==!1&&t.push(Lq.configure(this.options.document)),this.options.dropcursor!==!1&&t.push(Bq.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&t.push(Gq.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&t.push(Zq.configure(this.options.hardBreak)),this.options.heading!==!1&&t.push(Jq.configure(this.options.heading)),this.options.history!==!1&&t.push(oW.configure(this.options.history)),this.options.horizontalRule!==!1&&t.push(sW.configure(this.options.horizontalRule)),this.options.italic!==!1&&t.push(dW.configure(this.options.italic)),this.options.listItem!==!1&&t.push(fW.configure(this.options.listItem)),this.options.orderedList!==!1&&t.push(pW.configure(this.options.orderedList)),this.options.paragraph!==!1&&t.push(mW.configure(this.options.paragraph)),this.options.strike!==!1&&t.push(bW.configure(this.options.strike)),this.options.text!==!1&&t.push(yW.configure(this.options.text)),t}}),Du=new Nt("tandemAnnotations"),ck={comment:!0,highlight:!0,note:!0};function kW(){try{const t=localStorage.getItem(S_);if(!t)return{...ck};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),{...ck}}}function xW(t){return t==="highlight"?"highlight":t==="note"||t==="flag"?"note":"comment"}function kg(t,e,n,r){const i=[],o=t.content.size;return e.forEach(s=>{const a=wa(s,h=>{console.warn("[sanitize]",h)});if(a.status!=="pending"||!r[a.type]||!a.range&&!a.relRange)return;const l=Sc(a,t,n);if(!l)return;a.relRange&&l.method==="flat"&&console.warn("[annotation] relRange-equipped annotation %s fell back to flat offsets",a.id);const{from:u,to:c}=l;if(u>=c||u<0||c>o)return;let f={};switch(a.type){case"highlight":{const h=b_(a.color),p=sc[h];f={class:`tandem-highlight tandem-highlight--${h}`,style:`background: ${p}; border-radius: var(--tandem-r-1); padding: 1px 0;`,"data-annotation-id":a.id,"data-annotation-type":a.type,"data-annotation-author":a.author,"aria-label":`Highlight annotation (${h})`};break}case"comment":a.suggestedText!==void 0?f={class:"tandem-suggestion",style:"background: var(--tandem-suggestion-bg); text-decoration: underline wavy var(--tandem-suggestion); text-underline-offset: 3px;","data-annotation-id":a.id,"data-annotation-type":a.type,"data-annotation-author":a.author,"aria-label":"Replacement annotation"}:a.author==="claude"?f={class:"tandem-comment tandem-comment--claude",style:"border-bottom: 2px solid var(--tandem-author-claude); padding-bottom: 1px;","data-annotation-id":a.id,"data-annotation-type":a.type,"data-annotation-author":a.author,"aria-label":"Claude comment annotation"}:f={class:"tandem-comment",style:"border-bottom: 2px dashed var(--tandem-author-user); padding-bottom: 1px;","data-annotation-id":a.id,"data-annotation-type":a.type,"data-annotation-author":a.author,"aria-label":"Comment annotation"};break;case"note":f={class:"tandem-note",style:"border-bottom: 2px dotted var(--tandem-fg-muted); padding-bottom: 1px;","data-annotation-id":a.id,"data-annotation-type":a.type,"data-annotation-author":a.author,"aria-label":"Note annotation"};break;default:{console.warn("[annotation] Unhandled annotation type in buildDecorations, skipping");return}}try{i.push(Vt.inline(u,c,f))}catch(h){if(!(h instanceof RangeError))throw h;console.debug("[annotation] RangeError for %s (from=%d, to=%d), skipping",a.id,u,c)}}),nt.create(t,i)}const _W=Kt.create({name:"tandemAnnotations",addOptions(){return{ydoc:null}},addProseMirrorPlugins(){const t=this.options.ydoc;if(!t)return[];const e=t.getMap(Ro);let n=kW();function r(){for(const s of e.values()){const a=s;if(a&&a.status==="pending"&&n[xW(a.type)])return!0}return!1}let i=r(),o=!1;return[new Dt({key:Du,state:{init(s,a){return i?kg(a.doc,e,t,n):nt.empty},apply(s,a,l,u){const c=s.getMeta(Du);if(c&&typeof c=="object"&&c.type==="toggle-decorations"&&(n=c.visible,i=r(),o=!1),c)return i?kg(u.doc,e,t,n):nt.empty;if(!i)return nt.empty;if(s.docChanged){if(!o&&a===nt.empty&&i){const f=kg(u.doc,e,t,n);return f!==nt.empty&&(o=!0),f}return a.map(s.mapping,s.doc)}return a}},props:{decorations(s){return Du.getState(s)}},view(s){let a=null,l=!1;function u(){a===null&&(a=requestAnimationFrame(()=>{a=null,l=!0;const h=s.state.tr.setMeta(Du,!0);s.dispatch(h)}))}const c=()=>{i=r(),o=!1,u()};e.observe(c);const f=setTimeout(()=>{!l&&a===null&&e.size>0&&c()},500);return{destroy(){clearTimeout(f),a!==null&&cancelAnimationFrame(a),e.unobserve(c)}}}})]}}),Wa=new Nt("tandemAuthorship"),CW=new Set(["paragraph","heading"]);function SW(t,e,n){if(t.relRange){const r=u3(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=Ss(e,t.range.from),i=Ss(e,t.range.to);if(r<i)return{from:r,to:i}}return null}function xg(t,e,n,r){if(!r)return nt.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 u=SW(l,t,n);if(!u)return;const{from:c,to:f}=u;if(!(c>=f||c<0||f>o)){try{i.push(Vt.inline(c,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:c,to:f})}}),t.descendants((a,l)=>{if(!CW.has(a.type.name))return;const u=l,c=l+a.nodeSize;let f=0,h=0;for(const m of s){const v=Math.max(m.from,u),g=Math.min(m.to,c);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(Vt.node(u,c,{"data-tandem-author-block":p}))}catch(m){if(!(m instanceof RangeError))throw m;console.warn("[authorship] node Decoration RangeError at offset",l,m)}}),nt.create(t,i)}const EW=Kt.create({name:"tandemAuthorship",addOptions(){return{ydoc:null}},addProseMirrorPlugins(){const t=this.options.ydoc;if(!t)return[];const e=t.getMap(Sy);let n=!1;try{n=localStorage.getItem(C_)==="true"}catch(r){console.warn("[authorship] localStorage unavailable",r)}return[new Dt({key:Wa,state:{init(r,i){return{visible:n,decorations:xg(i.doc,e,t,n)}},apply(r,i,o,s){const a=r.getMeta(Wa);if((a==null?void 0:a.type)==="toggle"){const l=a.visible;return{visible:l,decorations:xg(s.doc,e,t,l)}}return(a==null?void 0:a.type)==="rebuild"?{visible:i.visible,decorations:xg(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=Wa.getState(r))==null?void 0:i.decorations)??nt.empty}},view(r){const i=()=>{const s=r.state.tr.setMeta(Wa,{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(Wa)||!t.docChanged)return;const n=e.getMap(Sy),r=t.doc;t.steps.forEach(i=>{i.getMap().forEach((s,a,l,u)=>{if(u-l-(a-s)>0)try{const f=Vi(r,Hn(l)),h=Vi(r,Hn(u));if(h<=f)return;const p=J6("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)}})})}}),Xd=new Nt("tandemAwareness");function dk(t,e){if(!e)return nt.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(Vt.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=Ss(t,vf(i)),a=o===!1?" tandem-claude-cursor-idle":"";n.push(Vt.widget(s,()=>{const l=document.createElement("span");l.className=`tandem-claude-cursor${a}`,l.setAttribute("aria-hidden","true");const u=document.createElement("span");return u.className="tandem-claude-cursor-label",u.textContent="AI",l.appendChild(u),l}))}catch(s){console.warn("[awareness] cursor decoration failed, falling back to gutter-only:",s)}return n.length===0?nt.empty:nt.create(t,n)}const AW=Kt.create({name:"tandemAwareness",addOptions(){return{ydoc:null}},addProseMirrorPlugins(){const t=this.options.ydoc;if(!t)return[];const e=t.getMap(x_),n=t.getMap(c0);return[new Dt({key:Xd,state:{init(r,i){const o=e.get(d0);return dk(i.doc,o??null)},apply(r,i,o,s){if(r.getMeta(Xd)){const a=e.get(d0);return dk(s.doc,a??null)}return r.docChanged?i.map(r.mapping,r.doc):i}},props:{decorations(r){return Xd.getState(r)}},view(r){const i=()=>{const o=r.state.tr.setMeta(Xd,!0);r.dispatch(o)};return e.observe(i),{destroy(){e.unobserve(i)}}}}),new Dt({key:new Nt("tandemUserAwareness"),view(){let r=null,i=null,o=null,s=!1,a=-1;return{update(l,u){const{state:c}=l;if(!c.selection.eq(u.selection)){const f=c3(c.doc,{from:Hn(c.selection.from),to:Hn(c.selection.to)});if(c.selection.from===c.selection.to)o&&(clearTimeout(o),o=null),n.set(Ey,{...f,timestamp:Date.now()});else{const h=c.doc.textBetween(c.selection.from,c.selection.to,`
|
|
197
|
+
`),p=h.length>200?h.slice(0,197)+"...":h;o&&clearTimeout(o),o=setTimeout(()=>{o=null,n.set(Ey,{...f,selectedText:p,timestamp:Date.now()})},150)}}c.doc!==u.doc&&(a=c.selection.from,s=!0,i||(i=setTimeout(()=>{i=null,s&&n.set(Ay,{isTyping:!0,cursor:a,lastEdit:Date.now()})},200)),r&&clearTimeout(r),r=setTimeout(()=>{s=!1,n.set(Ay,{isTyping:!1,cursor:l.state.selection.from,lastEdit:Date.now()})},cM))},destroy(){r&&clearTimeout(r),i&&clearTimeout(i),o&&clearTimeout(o)}}}})]}}),Pi=new Nt("tandemFindReplace"),gA={query:"",caseSensitive:!1,wholeWord:!1,regexMode:!1,matches:[],activeIndex:-1,decoSet:nt.empty};function TW(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function MW(t){if(!t.query)return null;try{const e=t.regexMode?t.query:TW(t.query),n=t.caseSensitive?"g":"gi",r=t.wholeWord?`\\b${e}\\b`:e;return new RegExp(r,n)}catch{return null}}function vA(t,e){const n=MW(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 Qu(t,e,n){if(e.length===0)return nt.empty;const r=[];for(let i=0;i<e.length;i++){const{from:o,to:s}=e[i];try{r.push(Vt.inline(o,s,{class:i===n?"tandem-find-active":"tandem-find-match"}))}catch{}}return nt.create(t,r)}function Ev(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 DW(t,e,n){if(t.type==="close")return gA;if(t.type==="find"){const i=t.opts,o=vA(n.doc,i),s=n.selection.from,a=Ev(o,s);return{...i,matches:o,activeIndex:a,decoSet:Qu(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:Qu(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:Qu(n.doc,e.matches,i)}}return t}const OW=Kt.create({name:"tandemFindReplace",addProseMirrorPlugins(){return[new Dt({key:Pi,state:{init:()=>gA,apply(t,e,n,r){const i=t.getMeta(Pi);if(i)return DW(i,e,r);if(!e.query)return e;if(t.docChanged){const a=vA(r.doc,e),l=r.selection.from,u=Ev(a,l);return{...e,matches:a,activeIndex:u,decoSet:Qu(r.doc,a,u)}}const o=r.selection.from,s=Ev(e.matches,o);return s===e.activeIndex?e:{...e,activeIndex:s,decoSet:Qu(r.doc,e.matches,s)}}},props:{decorations(t){var e;return((e=Pi.getState(t))==null?void 0:e.decoSet)??nt.empty}}})]},addCommands(){return{find:t=>({dispatch:e,tr:n})=>(e&&e(n.setMeta(Pi,{type:"find",opts:t})),!0),findNext:()=>({dispatch:t,tr:e})=>(t&&t(e.setMeta(Pi,{type:"next"})),!0),findPrev:()=>({dispatch:t,tr:e})=>(t&&t(e.setMeta(Pi,{type:"prev"})),!0),findClose:()=>({dispatch:t,tr:e})=>(t&&t(e.setMeta(Pi,{type:"close"})),!0)}},addKeyboardShortcuts(){return{Escape:({editor:t})=>{const e=Pi.getState(t.state);return e!=null&&e.query?(t.commands.findClose(),!0):!1}}}});function cl(t){return Pi.getState(t)}function IW(t,e){const n=cl(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(Pi,{type:"next"});return t.dispatch(o),!0}async function RW(t,e,n){let i=0,o=!1;for(let s=0;s<50;s++){const a=cl(t.state);if(!(a!=null&&a.query)||a.matches.length===0)break;const l=a.matches.slice(0,100);try{let u=t.state.tr;for(let c=l.length-1;c>=0;c--){const{from:f,to:h}=l[c];u=u.insertText(e,f,h)}t.dispatch(u),i+=l.length,n==null||n(i,i+(a.matches.length-l.length))}catch(u){o=!0,console.warn("[find-replace] replaceAll chunk failed at pass",s,u);break}if(l.length<100)break;await new Promise(u=>setTimeout(u,0))}return{replaced:i,partial:o}}const Ls=new Nt("tandemHeadingCollapse"),NW="tandem:headingCollapse:";function bA(t){return!t||t.startsWith("upload://")?null:NW+t}function fk(t){const e=bA(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 ip(t,e){const n=bA(t);if(n)try{e.size===0?window.localStorage.removeItem(n):window.localStorage.setItem(n,JSON.stringify(Array.from(e)))}catch{}}function PW(t){return t.trim().toLowerCase().replace(/\s+/g," ")}function _g(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=PW(r.textContent),l=`${s}::${a}`,u=n.get(l)??0;n.set(l,u+1);const c=`${l}::${u}`;return e.push({pos:i,level:s,hash:c}),!1}),e}function LW(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],u=t[l].hash,c=e[l].hash;if(!n.has(u))return n;const f=new Set(n);return f.delete(u),f.add(c),ip(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?(ip(r,s),s):n}function FW(t,e,n){return Vt.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(Ls,{type:"toggle",hash:e});r.dispatch(s)}),i},{side:-1,ignoreSelection:!0,stopEvent:()=>!0,key:`chevron:${e}:${n?"c":"e"}`})}function zW(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,u=a+s.nodeSize;o.push(Vt.node(l,u,{class:"tandem-heading-collapsed-hidden",style:"display: none;"}))}}),o}function Qd(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(FW(o.pos,o.hash,s)),s&&r.push(...zW(t,e,i))}catch{}}return r.length===0?nt.empty:nt.create(t,r)}const BW=Kt.create({name:"tandemHeadingCollapse",addOptions(){return{filePath:null}},addProseMirrorPlugins(){const t=this.options.filePath;return[new Dt({key:Ls,state:{init(e,n){const r=fk(t),i=_g(n.doc);return{collapsed:r,headings:i,decoSet:Qd(n.doc,i,r),hasSeenContent:i.length>0}},apply(e,n,r,i){const o=e.getMeta(Ls);if((o==null?void 0:o.type)==="toggle"){const u=new Set(n.collapsed);return u.has(o.hash)?u.delete(o.hash):u.add(o.hash),ip(t,u),{collapsed:u,headings:n.headings,decoSet:Qd(i.doc,n.headings,u),hasSeenContent:n.hasSeenContent}}if((o==null?void 0:o.type)==="rehydrate"){const u=_g(i.doc),c=fk(t),f=new Set(u.map(p=>p.hash)),h=new Set;for(const p of c)f.has(p)&&h.add(p);return h.size!==c.size&&ip(t,h),{collapsed:h,headings:u,decoSet:Qd(i.doc,u,h),hasSeenContent:!0}}if(!e.docChanged)return n;const s=_g(i.doc),a=n.hasSeenContent||s.length>0;let l=n.collapsed;return n.hasSeenContent&&(l=LW(n.headings,s,n.collapsed,t)),{collapsed:l,headings:s,decoSet:Qd(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=Ls.getState(e.state);if(!o||o.headings.length===0)return;n=!0;const s=e.state.tr.setMeta(Ls,{type:"rehydrate"}).setMeta("addToHistory",!1);e.dispatch(s)}))}return i(),{update(o){if(n)return;const s=Ls.getState(o.state);!s||s.headings.length===0||i()},destroy(){r!==null&&cancelAnimationFrame(r)}}},props:{decorations(e){var n;return((n=Ls.getState(e))==null?void 0:n.decoSet)??nt.empty}}})]}}),HW=Kt.create({name:"markdownHtml",addGlobalAttributes(){return[{types:["paragraph"],attributes:{markdownHtml:{default:null,parseHTML:()=>null,renderHTML:()=>({})}}}]}}),VW=new Nt("tandemSelectionDecoration"),UW=Kt.create({name:"tandemSelectionDecoration",addProseMirrorPlugins(){return[new Dt({key:VW,props:{decorations(t){const{selection:e}=t;if(!(e instanceof qe))return nt.empty;const{from:n,to:r}=e;return n===r?nt.empty:nt.create(t.doc,[Vt.inline(n,r,{class:"tandem-selection-blurred"})])}}})]}});function Vo(t){return t.chain().focus()}const hk={tag:"path",attrs:{d:"M6 4.5h7M6 8h7M6 11.5h7"}},pk=[{id:"heading-1",label:"Heading 1",keywords:["h1","heading","title"],hint:"h1",icon:{kind:"glyph",glyph:"H¹"},run:t=>Vo(t).toggleHeading({level:1}).run()},{id:"heading-2",label:"Heading 2",keywords:["h2","heading","subtitle"],hint:"h2",icon:{kind:"glyph",glyph:"H²"},run:t=>Vo(t).toggleHeading({level:2}).run()},{id:"heading-3",label:"Heading 3",keywords:["h3","heading","subheading"],hint:"h3",icon:{kind:"glyph",glyph:"H³"},run:t=>Vo(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"}},hk]},run:t=>Vo(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"}},hk]},run:t=>Vo(t).toggleOrderedList().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=>Vo(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=>Vo(t).toggleCodeBlock().run()},{id:"horizontal-rule",label:"Horizontal rule",keywords:["hr","divider","rule","separator"],hint:"hr",icon:{kind:"glyph",glyph:"—"},run:t=>Vo(t).setHorizontalRule().run()}];function jW(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 om(t){const e=t.trim().toLowerCase();return e?pk.filter(n=>[n.label,...n.keywords].join(" ").toLowerCase().includes(e)):pk}const qW=["popup-annotation-input","popup-note-submit","popup-comment-submit","popup-highlight-yellow","popup-highlight-green","popup-highlight-blue","popup-highlight-pink"];function WW(t){const e=document.querySelector(`[data-testid="${t}"]`);return e?document.activeElement===e:!1}function KW(t){for(const e of t)if(document.querySelector(`[data-testid="${e}"]`))return!0;return!1}function GW(){return typeof document>"u"?!1:!!(WW("find-input")||document.querySelector('[data-testid="command-palette"]')||KW(qW))}const mk="http://www.w3.org/2000/svg",go=new Nt("tandemSlashCommand");function yA(t){return`${t.from}:${t.to}:${t.query}`}function gk(t,e=0){if(GW())return null;const{selection:n}=t;if(!n.empty)return null;const r=n.$from,i=r.parent.textBetween(0,r.parentOffset,`
|
|
198
|
+
`,`
|
|
199
|
+
`),o=jW(i);if(!o)return null;const s=r.start()+o.fromOffset,a=r.pos,l=om(o.query);return l.length===0?null:{from:s,to:a,query:o.query,selectedIndex:Math.min(e,l.length-1)}}function ZW(t,e){const n=t.getMeta(go);return n?n.type==="close"?{active:null,dismissedKey:e.active?yA(e.active):e.dismissedKey}:n.type==="select"&&e.active?{...e,active:{...e.active,selectedIndex:n.selectedIndex??e.active.selectedIndex}}:e:null}function wA(t){for(;t.firstChild;)t.removeChild(t.firstChild)}function JW(){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 YW(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(mk,"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(mk,r.tag);for(const[o,s]of Object.entries(r.attrs))i.setAttribute(o,s);n.appendChild(i)}return e.appendChild(n),e}function XW(t,e,n,r,i){const o=om(e.query);wA(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,u)=>{const c=document.createElement("button");c.type="button",c.role="option",c.id=`slash-command-${l.id}`,c.className="tandem-slash-menu__item",c.setAttribute("aria-selected",String(u===e.selectedIndex)),c.setAttribute("aria-label",l.label),c.dataset.commandId=l.id,c.appendChild(YW(l.icon));const f=document.createElement("span");f.className="tandem-slash-menu__label",f.textContent=l.label,c.appendChild(f);const h=document.createElement("span");h.className="tandem-slash-menu__shortcut",h.setAttribute("aria-hidden","true"),h.textContent=l.hint,c.appendChild(h),c.addEventListener("mouseenter",()=>r(u)),c.addEventListener("mousedown",p=>{p.preventDefault(),i(l)}),s.appendChild(c)}),t.appendChild(s),t.appendChild(JW());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 QW(t,e){const n=om(e.query)[e.selectedIndex];return n?(t.chain().focus().deleteRange({from:e.from,to:e.to}).run(),n.run(t),!0):!1}const $W=Kt.create({name:"slashCommand",addOptions(){return{onOpenChange:void 0}},addProseMirrorPlugins(){const t=this.editor,e=this.options.onOpenChange;return[new Dt({key:go,state:{init:(n,r)=>({active:gk(r),dismissedKey:null}),apply(n,r,i,o){var l;const s=ZW(n,r);if(s)return s;const a=gk(o,((l=r.active)==null?void 0:l.selectedIndex)??0);return a&&yA(a)===r.dismissedKey?{active:null,dismissedKey:r.dismissedKey}:{active:a,dismissedKey:a?null:r.dismissedKey}}},props:{handleKeyDown(n,r){const i=go.getState(n.state),o=i==null?void 0:i.active;if(!o)return!1;const s=om(o.query);if(r.key==="ArrowDown"){r.preventDefault();const a=(o.selectedIndex+1)%s.length;return n.dispatch(n.state.tr.setMeta(go,{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(go,{type:"select",selectedIndex:a})),!0}return r.key==="Enter"?(r.preventDefault(),QW(t,o)):r.key==="Escape"?(r.preventDefault(),n.dispatch(n.state.tr.setMeta(go,{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",wA(r),o(!1)},a=()=>{var u;const l=(u=go.getState(n.state))==null?void 0:u.active;if(!l){s();return}XW(r,l,t,c=>{n.dispatch(n.state.tr.setMeta(go,{type:"select",selectedIndex:c}))},c=>{t.chain().focus().deleteRange({from:l.from,to:l.to}).run(),c.run(t),s(),n.dispatch(n.state.tr.setMeta(go,{type:"close"}))}),o(!0)};return a(),{update:a,destroy(){o(!1),r.remove()}}}})]}}),vk={};function eK(t){let e=vk[t];if(e)return e;e=vk[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 ql(t,e){typeof e!="string"&&(e=ql.defaultChars);const n=eK(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 u=a<<6&1984|l&63;u<128?i+="��":i+=String.fromCharCode(u),o+=3;continue}}if((a&240)===224&&o+6<s){const l=parseInt(r.slice(o+4,o+6),16),u=parseInt(r.slice(o+7,o+9),16);if((l&192)===128&&(u&192)===128){const c=a<<12&61440|l<<6&4032|u&63;c<2048||c>=55296&&c<=57343?i+="���":i+=String.fromCharCode(c),o+=6;continue}}if((a&248)===240&&o+9<s){const l=parseInt(r.slice(o+4,o+6),16),u=parseInt(r.slice(o+7,o+9),16),c=parseInt(r.slice(o+10,o+12),16);if((l&192)===128&&(u&192)===128&&(c&192)===128){let f=a<<18&1835008|l<<12&258048|u<<6&4032|c&63;f<65536||f>1114111?i+="����":(f-=65536,i+=String.fromCharCode(55296+(f>>10),56320+(f&1023))),o+=9;continue}}i+="�"}return i})}ql.defaultChars=";/?:@&=+$,#";ql.componentChars="";const bk={};function tK(t){let e=bk[t];if(e)return e;e=bk[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 bd(t,e,n){typeof e!="string"&&(n=e,e=bd.defaultChars),typeof n>"u"&&(n=!0);const r=tK(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}bd.defaultChars=";/?:@&=+$,-_.!~*'()#";bd.componentChars="-_.!~*'()";function k1(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 op(){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 nK=/^([a-z0-9.+-]+:)/i,rK=/:[0-9]*$/,iK=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,oK=["<",">",'"',"`"," ","\r",`
|
|
200
|
+
`," "],sK=["{","}","|","\\","^","`"].concat(oK),aK=["'"].concat(sK),yk=["%","/","?",";","#"].concat(aK),wk=["/","?","#"],lK=255,kk=/^[+a-z0-9A-Z_-]{0,63}$/,uK=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,xk={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 x1(t,e){if(t&&t instanceof op)return t;const n=new op;return n.parse(t,e),n}op.prototype.parse=function(t,e){let n,r,i,o=t;if(o=o.trim(),!e&&t.split("#").length===1){const u=iK.exec(o);if(u)return this.pathname=u[1],u[2]&&(this.search=u[2]),this}let s=nK.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&&xk[s])&&(o=o.substr(2),this.slashes=!0)),!xk[s]&&(i||s&&!_k[s])){let u=-1;for(let m=0;m<wk.length;m++)r=o.indexOf(wk[m]),r!==-1&&(u===-1||r<u)&&(u=r);let c,f;u===-1?f=o.lastIndexOf("@"):f=o.lastIndexOf("@",u),f!==-1&&(c=o.slice(0,f),o=o.slice(f+1),this.auth=c),u=-1;for(let m=0;m<yk.length;m++)r=o.indexOf(yk[m]),r!==-1&&(u===-1||r<u)&&(u=r);u===-1&&(u=o.length),o[u-1]===":"&&u--;const h=o.slice(0,u);o=o.slice(u),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(kk)){let x="";for(let _=0,T=b.length;_<T;_++)b.charCodeAt(_)>127?x+="x":x+=b[_];if(!x.match(kk)){const _=m.slice(0,v),T=m.slice(v+1),S=b.match(uK);S&&(_.push(S[1]),T.unshift(S[2])),T.length&&(o=T.join(".")+o),this.hostname=_.join(".");break}}}}this.hostname.length>lK&&(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};op.prototype.parseHost=function(t){let e=rK.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 cK=Object.freeze(Object.defineProperty({__proto__:null,decode:ql,encode:bd,format:k1,parse:x1},Symbol.toStringTag,{value:"Module"})),kA=/[\0-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,xA=/[\0-\x1F\x7F-\x9F]/,dK=/[\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]/,_1=/[!-#%-\*,-\/:;\?@\[-\]_\{\}\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]/,_A=/[\$\+<->\^`\|~\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]/,CA=/[ \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]/,fK=Object.freeze(Object.defineProperty({__proto__:null,Any:kA,Cc:xA,Cf:dK,P:_1,S:_A,Z:CA},Symbol.toStringTag,{value:"Module"})),hK=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୕ୖ୪௫ఄ಄ದൡඅ櫬Āoungruent;扢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;怳Ādpuct;戏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ǣጓ\0y;䐎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Ā;tbrk;掶Āoyᜁᝁ;䐱quo;怞ʀcmprtᝓᝡᝤᝨausĀ;eĊĉptyv;榰séᜌnoõēƀahwᝯᝳ;䎲;愶een;扬r;쀀𝔟gcostuvwឍឝឳេ៕៛ƀ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Ā;elƀ;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\0aĀ;t䀬;䁀ƀ;fl戁îᅠeĀmxent»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ↄⅪ←ٖ↛ǰ↉\0proø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;䅓Ācrir;榿;쀀𝔬ͯ\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\0m;櫳;櫽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))),pK=new Uint16Array("Ȁaglq \x1Bɭ\0\0p;䀦os;䀧t;䀾t;䀼uot;䀢".split("").map(t=>t.charCodeAt(0)));var Cg;const mK=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]]),gK=(Cg=String.fromCodePoint)!==null&&Cg!==void 0?Cg: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 vK(t){var e;return t>=55296&&t<=57343||t>1114111?65533:(e=mK.get(t))!==null&&e!==void 0?e:t}var Cn;(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"})(Cn||(Cn={}));const bK=32;var us;(function(t){t[t.VALUE_LENGTH=49152]="VALUE_LENGTH",t[t.BRANCH_LENGTH=16256]="BRANCH_LENGTH",t[t.JUMP_TABLE=127]="JUMP_TABLE"})(us||(us={}));function Av(t){return t>=Cn.ZERO&&t<=Cn.NINE}function yK(t){return t>=Cn.UPPER_A&&t<=Cn.UPPER_F||t>=Cn.LOWER_A&&t<=Cn.LOWER_F}function wK(t){return t>=Cn.UPPER_A&&t<=Cn.UPPER_Z||t>=Cn.LOWER_A&&t<=Cn.LOWER_Z||Av(t)}function kK(t){return t===Cn.EQUALS||wK(t)}var kn;(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"})(kn||(kn={}));var Qo;(function(t){t[t.Legacy=0]="Legacy",t[t.Strict=1]="Strict",t[t.Attribute=2]="Attribute"})(Qo||(Qo={}));class xK{constructor(e,n,r){this.decodeTree=e,this.emitCodePoint=n,this.errors=r,this.state=kn.EntityStart,this.consumed=1,this.result=0,this.treeIndex=0,this.excess=1,this.decodeMode=Qo.Strict}startEntity(e){this.decodeMode=e,this.state=kn.EntityStart,this.result=0,this.treeIndex=0,this.excess=1,this.consumed=1}write(e,n){switch(this.state){case kn.EntityStart:return e.charCodeAt(n)===Cn.NUM?(this.state=kn.NumericStart,this.consumed+=1,this.stateNumericStart(e,n+1)):(this.state=kn.NamedEntity,this.stateNamedEntity(e,n));case kn.NumericStart:return this.stateNumericStart(e,n);case kn.NumericDecimal:return this.stateNumericDecimal(e,n);case kn.NumericHex:return this.stateNumericHex(e,n);case kn.NamedEntity:return this.stateNamedEntity(e,n)}}stateNumericStart(e,n){return n>=e.length?-1:(e.charCodeAt(n)|bK)===Cn.LOWER_X?(this.state=kn.NumericHex,this.consumed+=1,this.stateNumericHex(e,n+1)):(this.state=kn.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(Av(i)||yK(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(Av(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===Cn.SEMI)this.consumed+=1;else if(this.decodeMode===Qo.Strict)return 0;return this.emitCodePoint(vK(this.result),this.consumed),this.errors&&(e!==Cn.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&us.VALUE_LENGTH)>>14;for(;n<e.length;n++,this.excess++){const s=e.charCodeAt(n);if(this.treeIndex=_K(r,i,this.treeIndex+Math.max(1,o),s),this.treeIndex<0)return this.result===0||this.decodeMode===Qo.Attribute&&(o===0||kK(s))?0:this.emitNotTerminatedNamedEntity();if(i=r[this.treeIndex],o=(i&us.VALUE_LENGTH)>>14,o!==0){if(s===Cn.SEMI)return this.emitNamedEntityData(this.treeIndex,o,this.consumed+this.excess);this.decodeMode!==Qo.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]&us.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]&~us.VALUE_LENGTH:i[e+1],r),n===3&&this.emitCodePoint(i[e+2],r),r}end(){var e;switch(this.state){case kn.NamedEntity:return this.result!==0&&(this.decodeMode!==Qo.Attribute||this.result===this.treeIndex)?this.emitNotTerminatedNamedEntity():0;case kn.NumericDecimal:return this.emitNumericEntity(0,2);case kn.NumericHex:return this.emitNumericEntity(0,3);case kn.NumericStart:return(e=this.errors)===null||e===void 0||e.absenceOfDigitsInNumericCharacterReference(this.consumed),0;case kn.EntityStart:return 0}}}function SA(t){let e="";const n=new xK(t,r=>e+=gK(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 u=n.write(i,a+1);if(u<0){s=a+n.end();break}s=a+u,a=u===0?s+1:s}const l=e+i.slice(s);return e="",l}}function _K(t,e,n,r){const i=(e&us.BRANCH_LENGTH)>>7,o=e&us.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,u=t[l];if(u<r)s=l+1;else if(u>r)a=l-1;else return t[l+i]}return-1}const CK=SA(hK);SA(pK);function EA(t,e=Qo.Legacy){return CK(t,e)}function SK(t){return Object.prototype.toString.call(t)}function C1(t){return SK(t)==="[object String]"}const EK=Object.prototype.hasOwnProperty;function AK(t,e){return EK.call(t,e)}function sm(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 AA(t,e,n){return[].concat(t.slice(0,e),n,t.slice(e+1))}function S1(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 sp(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 TA=/\\([!"#$%&'()*+,\-./:;<=>?@[\\\]^_`{|}~])/g,TK=/&([a-z#][a-z0-9]{1,31});/gi,MK=new RegExp(TA.source+"|"+TK.source,"gi"),DK=/^#((?:x[a-f0-9]{1,8}|[0-9]{1,8}))$/i;function OK(t,e){if(e.charCodeAt(0)===35&&DK.test(e)){const r=e[1].toLowerCase()==="x"?parseInt(e.slice(2),16):parseInt(e.slice(1),10);return S1(r)?sp(r):t}const n=EA(t);return n!==t?n:t}function IK(t){return t.indexOf("\\")<0?t:t.replace(TA,"$1")}function Wl(t){return t.indexOf("\\")<0&&t.indexOf("&")<0?t:t.replace(MK,function(e,n,r){return n||OK(e,r)})}const RK=/[&<>"]/,NK=/[&<>"]/g,PK={"&":"&","<":"<",">":">",'"':"""};function LK(t){return PK[t]}function Ts(t){return RK.test(t)?t.replace(NK,LK):t}const FK=/[.?*+^$[\]\\(){}|-]/g;function zK(t){return t.replace(FK,"\\$&")}function qt(t){switch(t){case 9:case 32:return!0}return!1}function Bc(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 Hc(t){return _1.test(t)||_A.test(t)}function Vc(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 am(t){return t=t.trim().replace(/\s+/g," "),"ẞ".toLowerCase()==="Ṿ"&&(t=t.replace(/ẞ/g,"ß")),t.toLowerCase().toUpperCase()}const BK={mdurl:cK,ucmicro:fK},HK=Object.freeze(Object.defineProperty({__proto__:null,arrayReplaceAt:AA,assign:sm,escapeHtml:Ts,escapeRE:zK,fromCodePoint:sp,has:AK,isMdAsciiPunct:Vc,isPunctChar:Hc,isSpace:qt,isString:C1,isValidEntityCode:S1,isWhiteSpace:Bc,lib:BK,normalizeReference:am,unescapeAll:Wl,unescapeMd:IK},Symbol.toStringTag,{value:"Module"}));function VK(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 u=-1;return i&&(u=t.pos),t.pos=l,u}function UK(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=Wl(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=Wl(t.slice(e,i)),o.pos=i,o.ok=!0),o}function jK(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+=Wl(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+=Wl(t.slice(e,o)),s}const qK=Object.freeze(Object.defineProperty({__proto__:null,parseLinkDestination:UK,parseLinkLabel:VK,parseLinkTitle:jK},Symbol.toStringTag,{value:"Module"})),oo={};oo.code_inline=function(t,e,n,r,i){const o=t[e];return"<code"+i.renderAttrs(o)+">"+Ts(o.content)+"</code>"};oo.code_block=function(t,e,n,r,i){const o=t[e];return"<pre"+i.renderAttrs(o)+"><code>"+Ts(t[e].content)+`</code></pre>
|
|
201
|
+
`};oo.fence=function(t,e,n,r,i){const o=t[e],s=o.info?Wl(o.info).trim():"";let a="",l="";if(s){const c=s.split(/(\s+)/g);a=c[0],l=c.slice(2).join("")}let u;if(n.highlight?u=n.highlight(o.content,a,l)||Ts(o.content):u=Ts(o.content),u.indexOf("<pre")===0)return u+`
|
|
202
|
+
`;if(s){const c=o.attrIndex("class"),f=o.attrs?o.attrs.slice():[];c<0?f.push(["class",n.langPrefix+a]):(f[c]=f[c].slice(),f[c][1]+=" "+n.langPrefix+a);const h={attrs:f};return`<pre><code${i.renderAttrs(h)}>${u}</code></pre>
|
|
203
|
+
`}return`<pre><code${i.renderAttrs(o)}>${u}</code></pre>
|
|
204
|
+
`};oo.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)};oo.hardbreak=function(t,e,n){return n.xhtmlOut?`<br />
|
|
205
|
+
`:`<br>
|
|
206
|
+
`};oo.softbreak=function(t,e,n){return n.breaks?n.xhtmlOut?`<br />
|
|
207
|
+
`:`<br>
|
|
208
|
+
`:`
|
|
209
|
+
`};oo.text=function(t,e){return Ts(t[e].content)};oo.html_block=function(t,e){return t[e].content};oo.html_inline=function(t,e){return t[e].content};function ou(){this.rules=sm({},oo)}ou.prototype.renderAttrs=function(e){let n,r,i;if(!e.attrs)return"";for(i="",n=0,r=e.attrs.length;n<r;n++)i+=" "+Ts(e.attrs[n][0])+'="'+Ts(e.attrs[n][1])+'"';return i};ou.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+=`
|
|
210
|
+
`),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?`>
|
|
211
|
+
`:">",o};ou.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};ou.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+=`
|
|
212
|
+
`;break}return r};ou.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 Sr(){this.__rules__=[],this.__cache__=null}Sr.prototype.__find__=function(t){for(let e=0;e<this.__rules__.length;e++)if(this.__rules__[e].name===t)return e;return-1};Sr.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))})})};Sr.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};Sr.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};Sr.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};Sr.prototype.push=function(t,e,n){const r=n||{};this.__rules__.push({name:t,enabled:!0,fn:e,alt:r.alt||[]}),this.__cache__=null};Sr.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};Sr.prototype.enableOnly=function(t,e){Array.isArray(t)||(t=[t]),this.__rules__.forEach(function(n){n.enabled=!1}),this.enable(t,e)};Sr.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};Sr.prototype.getRules=function(t){return this.__cache__===null&&this.__compile__(),this.__cache__[t]||[]};function Ai(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}Ai.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};Ai.prototype.attrPush=function(e){this.attrs?this.attrs.push(e):this.attrs=[e]};Ai.prototype.attrSet=function(e,n){const r=this.attrIndex(e),i=[e,n];r<0?this.attrPush(i):this.attrs[r]=i};Ai.prototype.attrGet=function(e){const n=this.attrIndex(e);let r=null;return n>=0&&(r=this.attrs[n][1]),r};Ai.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 MA(t,e,n){this.src=t,this.env=n,this.tokens=[],this.inlineMode=!1,this.md=e}MA.prototype.Token=Ai;const WK=/\r\n?|\n/g,KK=/\0/g;function GK(t){let e;e=t.src.replace(WK,`
|
|
213
|
+
`),e=e.replace(KK,"�"),t.src=e}function ZK(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 JK(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 YK(t){return/^<a[>\s]/i.test(t)}function XK(t){return/^<\/a\s*>/i.test(t)}function QK(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"&&(YK(a.content)&&o>0&&o--,XK(a.content)&&o++),!(o>0)&&a.type==="text"&&t.md.linkify.test(a.content)){const l=a.content;let u=t.md.linkify.match(l);const c=[];let f=a.level,h=0;u.length>0&&u[0].index===0&&s>0&&i[s-1].type==="text_special"&&(u=u.slice(1));for(let p=0;p<u.length;p++){const m=u[p].url,v=t.md.normalizeLink(m);if(!t.md.validateLink(v))continue;let g=u[p].text;u[p].schema?u[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=u[p].index;if(b>h){const S=new t.Token("text","",0);S.content=l.slice(h,b),S.level=f,c.push(S)}const x=new t.Token("link_open","a",1);x.attrs=[["href",v]],x.level=f++,x.markup="linkify",x.info="auto",c.push(x);const _=new t.Token("text","",0);_.content=g,_.level=f,c.push(_);const T=new t.Token("link_close","a",-1);T.level=--f,T.markup="linkify",T.info="auto",c.push(T),h=u[p].lastIndex}if(h<l.length){const p=new t.Token("text","",0);p.content=l.slice(h),p.level=f,c.push(p)}e[n].children=i=AA(i,s,c)}}}}const DA=/\+-|\.\.|\?\?\?\?|!!!!|,,|--/,$K=/\((c|tm|r)\)/i,eG=/\((c|tm|r)\)/ig,tG={c:"©",r:"®",tm:"™"};function nG(t,e){return tG[e.toLowerCase()]}function rG(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(eG,nG)),r.type==="link_open"&&r.info==="auto"&&e--,r.type==="link_close"&&r.info==="auto"&&e++}}function iG(t){let e=0;for(let n=t.length-1;n>=0;n--){const r=t[n];r.type==="text"&&!e&&DA.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 oG(t){let e;if(t.md.options.typographer)for(e=t.tokens.length-1;e>=0;e--)t.tokens[e].type==="inline"&&($K.test(t.tokens[e].content)&&rG(t.tokens[e].children),DA.test(t.tokens[e].content)&&iG(t.tokens[e].children))}const sG=/['"]/,Ck=/['"]/g,Sk="’";function $d(t,e,n){return t.slice(0,e)+n+t.slice(e+1)}function aG(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,u=a.length;e:for(;l<u;){Ck.lastIndex=l;const c=Ck.exec(a);if(!c)break;let f=!0,h=!0;l=c.index+1;const p=c[0]==="'";let m=32;if(c.index-1>=0)m=a.charCodeAt(c.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<u)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=Vc(m)||Hc(String.fromCharCode(m)),b=Vc(v)||Hc(String.fromCharCode(v)),x=Bc(m),_=Bc(v);if(_?f=!1:b&&(x||g||(f=!1)),x?h=!1:g&&(_||b||(h=!1)),v===34&&c[0]==='"'&&m>=48&&m<=57&&(h=f=!1),f&&h&&(f=g,h=b),!f&&!h){p&&(o.content=$d(o.content,c.index,Sk));continue}if(h)for(n=r.length-1;n>=0;n--){let T=r[n];if(r[n].level<s)break;if(T.single===p&&r[n].level===s){T=r[n];let S,z;p?(S=e.md.options.quotes[2],z=e.md.options.quotes[3]):(S=e.md.options.quotes[0],z=e.md.options.quotes[1]),o.content=$d(o.content,c.index,z),t[T.token].content=$d(t[T.token].content,T.pos,S),l+=z.length-1,T.token===i&&(l+=S.length-1),a=o.content,u=a.length,r.length=n;continue e}}f?r.push({token:i,pos:c.index,single:p,level:s}):h&&p&&(o.content=$d(o.content,c.index,Sk))}}}function lG(t){if(t.md.options.typographer)for(let e=t.tokens.length-1;e>=0;e--)t.tokens[e].type!=="inline"||!sG.test(t.tokens[e].content)||aG(t.tokens[e].children,t)}function uG(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 Sg=[["normalize",GK],["block",ZK],["inline",JK],["linkify",QK],["replacements",oG],["smartquotes",lG],["text_join",uG]];function E1(){this.ruler=new Sr;for(let t=0;t<Sg.length;t++)this.ruler.push(Sg[t][0],Sg[t][1])}E1.prototype.process=function(t){const e=this.ruler.getRules("");for(let n=0,r=e.length;n<r;n++)e[n](t)};E1.prototype.State=MA;function so(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,u=i.length,c=!1;s<u;s++){const f=i.charCodeAt(s);if(!c)if(qt(f)){a++,f===9?l+=4-l%4:l++;continue}else c=!0;(f===10||s===u-1)&&(f!==10&&s++,this.bMarks.push(o),this.eMarks.push(s),this.tShift.push(a),this.sCount.push(l),this.bsCount.push(0),c=!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}so.prototype.push=function(t,e,n){const r=new Ai(t,e,n);return r.block=!0,n<0&&this.level--,r.level=this.level,n>0&&this.level++,this.tokens.push(r),r};so.prototype.isEmpty=function(e){return this.bMarks[e]+this.tShift[e]>=this.eMarks[e]};so.prototype.skipEmptyLines=function(e){for(let n=this.lineMax;e<n&&!(this.bMarks[e]+this.tShift[e]<this.eMarks[e]);e++);return e};so.prototype.skipSpaces=function(e){for(let n=this.src.length;e<n;e++){const r=this.src.charCodeAt(e);if(!qt(r))break}return e};so.prototype.skipSpacesBack=function(e,n){if(e<=n)return e;for(;e>n;)if(!qt(this.src.charCodeAt(--e)))return e+1;return e};so.prototype.skipChars=function(e,n){for(let r=this.src.length;e<r&&this.src.charCodeAt(e)===n;e++);return e};so.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};so.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 u=this.bMarks[a];let c=u,f;for(a+1<n||i?f=this.eMarks[a]+1:f=this.eMarks[a];c<f&&l<r;){const h=this.src.charCodeAt(c);if(qt(h))h===9?l+=4-(l+this.bsCount[a])%4:l++;else if(c-u<this.tShift[a])l++;else break;c++}l>r?o[s]=new Array(l-r+1).join(" ")+this.src.slice(c,f):o[s]=this.src.slice(c,f)}return o.join("")};so.prototype.Token=Ai;const cG=65536;function Eg(t,e){const n=t.bMarks[e]+t.tShift[e],r=t.eMarks[e];return t.src.slice(n,r)}function Ek(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 dG(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&&!qt(a)||s===45&&qt(a))return!1;for(;o<t.eMarks[i];){const T=t.src.charCodeAt(o);if(T!==124&&T!==45&&T!==58&&!qt(T))return!1;o++}let l=Eg(t,e+1),u=l.split("|");const c=[];for(let T=0;T<u.length;T++){const S=u[T].trim();if(!S){if(T===0||T===u.length-1)continue;return!1}if(!/^:?-+:?$/.test(S))return!1;S.charCodeAt(S.length-1)===58?c.push(S.charCodeAt(0)===58?"center":"right"):S.charCodeAt(0)===58?c.push("left"):c.push("")}if(l=Eg(t,e).trim(),l.indexOf("|")===-1||t.sCount[e]-t.blkIndent>=4)return!1;u=Ek(l),u.length&&u[0]===""&&u.shift(),u.length&&u[u.length-1]===""&&u.pop();const f=u.length;if(f===0||f!==c.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 T=0;T<u.length;T++){const S=t.push("th_open","th",1);c[T]&&(S.attrs=[["style","text-align:"+c[T]]]);const z=t.push("inline","",0);z.content=u[T].trim(),z.children=[],t.push("th_close","th",-1)}t.push("tr_close","tr",-1),t.push("thead_close","thead",-1);let x,_=0;for(i=e+2;i<n&&!(t.sCount[i]<t.blkIndent);i++){let T=!1;for(let z=0,E=p.length;z<E;z++)if(p[z](t,i,n,!0)){T=!0;break}if(T||(l=Eg(t,i).trim(),!l)||t.sCount[i]-t.blkIndent>=4||(u=Ek(l),u.length&&u[0]===""&&u.shift(),u.length&&u[u.length-1]===""&&u.pop(),_+=f-u.length,_>cG))break;if(i===e+2){const z=t.push("tbody_open","tbody",1);z.map=x=[e+2,0]}const S=t.push("tr_open","tr",1);S.map=[i,i+1];for(let z=0;z<f;z++){const E=t.push("td_open","td",1);c[z]&&(E.attrs=[["style","text-align:"+c[z]]]);const D=t.push("inline","",0);D.content=u[z]?u[z].trim():"",D.children=[],t.push("td_close","td",-1)}t.push("tr_close","tr",-1)}return x&&(t.push("tbody_close","tbody",-1),x[1]=i),t.push("table_close","table",-1),v[1]=i,t.parentType=h,t.line=i,!0}function fG(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)+`
|
|
214
|
+
`,o.map=[e,t.line],!0}function hG(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 u=t.src.slice(a,i),c=t.src.slice(i,o);if(s===96&&c.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=c,p.content=t.getLines(e+1,f,l,!0),p.markup=u,p.map=[e,t.line],!0}function pG(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=[],u=[],c=[],f=t.md.block.ruler.getRules("blockquote"),h=t.parentType;t.parentType="blockquote";let p=!1,m;for(m=e;m<n;m++){const _=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&&!_){let S=t.sCount[m]+1,z,E;t.src.charCodeAt(i)===32?(i++,S++,E=!1,z=!0):t.src.charCodeAt(i)===9?(z=!0,(t.bsCount[m]+S)%4===3?(i++,S++,E=!1):E=!0):z=!1;let D=S;for(a.push(t.bMarks[m]),t.bMarks[m]=i;i<o;){const P=t.src.charCodeAt(i);if(qt(P))P===9?D+=4-(D+t.bsCount[m]+(E?1:0))%4:D++;else break;i++}p=i>=o,l.push(t.bsCount[m]),t.bsCount[m]=t.sCount[m]+1+(z?1:0),u.push(t.sCount[m]),t.sCount[m]=D-S,c.push(t.tShift[m]),t.tShift[m]=i-t.bMarks[m];continue}if(p)break;let T=!1;for(let S=0,z=f.length;S<z;S++)if(f[S](t,m,n,!0)){T=!0;break}if(T){t.lineMax=m,t.blkIndent!==0&&(a.push(t.bMarks[m]),l.push(t.bsCount[m]),c.push(t.tShift[m]),u.push(t.sCount[m]),t.sCount[m]-=t.blkIndent);break}a.push(t.bMarks[m]),l.push(t.bsCount[m]),c.push(t.tShift[m]),u.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 x=t.push("blockquote_close","blockquote",-1);x.markup=">",t.lineMax=s,t.parentType=h,b[1]=t.line;for(let _=0;_<c.length;_++)t.bMarks[_+e]=a[_],t.tShift[_+e]=c[_],t.sCount[_+e]=u[_],t.bsCount[_+e]=l[_];return t.blkIndent=v,!0}function mG(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 u=t.src.charCodeAt(o++);if(u!==s&&!qt(u))return!1;u===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 Ak(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(!qt(o))return-1}return r}function Tk(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),!qt(o))?-1:i}function gG(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 vG(t,e,n,r){let i,o,s,a,l=e,u=!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 c=!1;r&&t.parentType==="paragraph"&&t.sCount[l]>=t.blkIndent&&(c=!0);let f,h,p;if((p=Tk(t,l))>=0){if(f=!0,s=t.bMarks[l]+t.tShift[l],h=Number(t.src.slice(s,p-1)),c&&h!==1)return!1}else if((p=Ak(t,l))>=0)f=!1;else return!1;if(c&&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 x=t.md.block.ruler.getRules("list"),_=t.parentType;for(t.parentType="list";l<n;){o=p,i=t.eMarks[l];const T=t.sCount[l]+p-(t.bMarks[l]+t.tShift[l]);let S=T;for(;o<i;){const W=t.src.charCodeAt(o);if(W===9)S+=4-(S+t.bsCount[l])%4;else if(W===32)S++;else break;o++}const z=o;let E;z>=i?E=1:E=S-T,E>4&&(E=1);const D=T+E;a=t.push("list_item_open","li",1),a.markup=String.fromCharCode(m);const P=[l,0];a.map=P,f&&(a.info=t.src.slice(s,p-1));const R=t.tight,H=t.tShift[l],Q=t.sCount[l],Z=t.listIndent;if(t.listIndent=t.blkIndent,t.blkIndent=D,t.tight=!0,t.tShift[l]=z-t.bMarks[l],t.sCount[l]=S,z>=i&&t.isEmpty(l+1)?t.line=Math.min(t.line+2,n):t.md.block.tokenize(t,l,n,!0),(!t.tight||b)&&(u=!1),b=t.line-l>1&&t.isEmpty(t.line-1),t.blkIndent=t.listIndent,t.listIndent=Z,t.tShift[l]=H,t.sCount[l]=Q,t.tight=R,a=t.push("list_item_close","li",-1),a.markup=String.fromCharCode(m),l=t.line,P[1]=l,l>=n||t.sCount[l]<t.blkIndent||t.sCount[l]-t.blkIndent>=4)break;let $=!1;for(let W=0,te=x.length;W<te;W++)if(x[W](t,l,n,!0)){$=!0;break}if($)break;if(f){if(p=Tk(t,l),p<0)break;s=t.bMarks[l]+t.tShift[l]}else if(p=Ak(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=_,u&&gG(t,v),!0}function bG(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(x){const _=t.lineMax;if(x>=_||t.isEmpty(x))return null;let T=!1;if(t.sCount[x]-t.blkIndent>3&&(T=!0),t.sCount[x]<0&&(T=!0),!T){const E=t.md.block.ruler.getRules("reference"),D=t.parentType;t.parentType="reference";let P=!1;for(let R=0,H=E.length;R<H;R++)if(E[R](t,x,_,!0)){P=!0;break}if(t.parentType=D,P)return null}const S=t.bMarks[x]+t.tShift[x],z=t.eMarks[x];return t.src.slice(S,z+1)}let l=t.src.slice(i,o+1);o=l.length;let u=-1;for(i=1;i<o;i++){const x=l.charCodeAt(i);if(x===91)return!1;if(x===93){u=i;break}else if(x===10){const _=a(s);_!==null&&(l+=_,o=l.length,s++)}else if(x===92&&(i++,i<o&&l.charCodeAt(i)===10)){const _=a(s);_!==null&&(l+=_,o=l.length,s++)}}if(u<0||l.charCodeAt(u+1)!==58)return!1;for(i=u+2;i<o;i++){const x=l.charCodeAt(i);if(x===10){const _=a(s);_!==null&&(l+=_,o=l.length,s++)}else if(!qt(x))break}const c=t.md.helpers.parseLinkDestination(l,i,o);if(!c.ok)return!1;const f=t.md.normalizeLink(c.str);if(!t.md.validateLink(f))return!1;i=c.pos;const h=i,p=s,m=i;for(;i<o;i++){const x=l.charCodeAt(i);if(x===10){const _=a(s);_!==null&&(l+=_,o=l.length,s++)}else if(!qt(x))break}let v=t.md.helpers.parseLinkTitle(l,i,o);for(;v.can_continue;){const x=a(s);if(x===null)break;l+=x,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 x=l.charCodeAt(i);if(!qt(x))break;i++}if(i<o&&l.charCodeAt(i)!==10&&g)for(g="",i=h,s=p;i<o;){const x=l.charCodeAt(i);if(!qt(x))break;i++}if(i<o&&l.charCodeAt(i)!==10)return!1;const b=am(l.slice(1,u));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 yG=["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"],wG="[a-zA-Z_:][a-zA-Z0-9:._-]*",kG="[^\"'=<>`\\x00-\\x20]+",xG="'[^']*'",_G='"[^"]*"',CG="(?:"+kG+"|"+xG+"|"+_G+")",SG="(?:\\s+"+wG+"(?:\\s*=\\s*"+CG+")?)",OA="<[A-Za-z][A-Za-z0-9\\-]*"+SG+"*\\s*\\/?>",IA="<\\/[A-Za-z][A-Za-z0-9\\-]*\\s*>",EG="<!---?>|<!--(?:[^-]|-[^-]|--[^>])*-->",AG="<[?][\\s\\S]*?[?]>",TG="<![A-Za-z][^>]*>",MG="<!\\[CDATA\\[[\\s\\S]*?\\]\\]>",DG=new RegExp("^(?:"+OA+"|"+IA+"|"+EG+"|"+AG+"|"+TG+"|"+MG+")"),OG=new RegExp("^(?:"+OA+"|"+IA+")"),za=[[/^<(script|pre|style|textarea)(?=(\s|>|$))/i,/<\/(script|pre|style|textarea)>/i,!0],[/^<!--/,/-->/,!0],[/^<\?/,/\?>/,!0],[/^<![A-Z]/,/>/,!0],[/^<!\[CDATA\[/,/\]\]>/,!0],[new RegExp("^</?("+yG.join("|")+")(?=(\\s|/?>|$))","i"),/^$/,!0],[new RegExp(OG.source+"\\s*$"),/^$/,!1]];function IG(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<za.length&&!za[a][0].test(s);a++);if(a===za.length)return!1;if(r)return za[a][2];let l=e+1;if(!za[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),za[a][1].test(s)){s.length!==0&&l++;break}}t.line=l;const u=t.push("html_block","",0);return u.map=[e,l],u.content=t.getLines(e,l,t.blkIndent,!0),!0}function RG(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&&!qt(s))return!1;if(r)return!0;o=t.skipSpacesBack(o,i);const l=t.skipCharsBack(o,35,i);l>i&&qt(t.src.charCodeAt(l-1))&&(o=l),t.line=e+1;const u=t.push("heading_open","h"+String(a),1);u.markup="########".slice(0,a),u.map=[e,t.line];const c=t.push("inline","",0);c.content=t.src.slice(i,o).trim(),c.map=[e,t.line],c.children=[];const f=t.push("heading_close","h"+String(a),-1);return f.markup="########".slice(0,a),!0}function NG(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 u=t.push("heading_open","h"+String(o),1);u.markup=String.fromCharCode(s),u.map=[e,t.line];const c=t.push("inline","",0);c.content=l,c.map=[e,t.line-1],c.children=[];const f=t.push("heading_close","h"+String(o),-1);return f.markup=String.fromCharCode(s),t.parentType=i,!0}function PG(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 u=!1;for(let c=0,f=r.length;c<f;c++)if(r[c](t,o,n,!0)){u=!0;break}if(u)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 ef=[["table",dG,["paragraph","reference"]],["code",fG],["fence",hG,["paragraph","reference","blockquote","list"]],["blockquote",pG,["paragraph","reference","blockquote","list"]],["hr",mG,["paragraph","reference","blockquote","list"]],["list",vG,["paragraph","reference","blockquote"]],["reference",bG],["html_block",IG,["paragraph","reference","blockquote"]],["heading",RG,["paragraph","reference","blockquote"]],["lheading",NG],["paragraph",PG]];function lm(){this.ruler=new Sr;for(let t=0;t<ef.length;t++)this.ruler.push(ef[t][0],ef[t][1],{alt:(ef[t][2]||[]).slice()})}lm.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 u=!1;for(let c=0;c<i;c++)if(u=r[c](t,s,n,!1),u){if(l>=t.line)throw new Error("block rule didn't increment state.line");break}if(!u)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)}};lm.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)};lm.prototype.State=so;function yd(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}yd.prototype.pushPending=function(){const t=new Ai("text","",0);return t.content=this.pending,t.level=this.pendingLevel,this.tokens.push(t),this.pending="",t};yd.prototype.push=function(t,e,n){this.pending&&this.pushPending();const r=new Ai(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};yd.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=Vc(i)||Hc(String.fromCharCode(i)),u=Vc(a)||Hc(String.fromCharCode(a)),c=Bc(i),f=Bc(a),h=!f&&(!u||c||l),p=!c&&(!l||f||u);return{can_open:h&&(e||!p||l),can_close:p&&(e||!h||u),length:s}};yd.prototype.Token=Ai;function LG(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 FG(t,e){let n=t.pos;for(;n<t.posMax&&!LG(t.src.charCodeAt(n));)n++;return n===t.pos?!1:(e||(t.pending+=t.src.slice(t.pos,n)),t.pos=n,!0)}const zG=/(?:^|[^a-z0-9.+-])([a-z][a-z0-9.+-]*)$/i;function BG(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(zG);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 u=t.md.normalizeLink(a);if(!t.md.validateLink(u))return!1;if(!e){t.pending=t.pending.slice(0,-o.length);const c=t.push("link_open","a",1);c.attrs=[["href",u]],c.markup="linkify",c.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 HG(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&&qt(t.src.charCodeAt(n));)n++;return t.pos=n,!0}const A1=[];for(let t=0;t<256;t++)A1.push(0);"\\!\"#$%&'()*+,./:;<=>?@[]^_`{|}~-".split("").forEach(function(t){A1[t.charCodeAt(0)]=1});function VG(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),!!qt(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&&A1[i]!==0?a.content=o:a.content=s,a.markup=s,a.info="escape"}return t.pos=n+1,!0}function UG(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,u;for(;(u=t.src.indexOf("`",l))!==-1;){for(l=u+1;l<o&&t.src.charCodeAt(l)===96;)l++;const c=l-u;if(c===a){if(!e){const f=t.push("code_inline","code",0);f.markup=s,f.content=t.src.slice(n,u).replace(/\n/g," ").replace(/^ (.+) $/,"$1")}return t.pos=l,!0}t.backticks[c]=u}return t.backticksScanned=!0,e||(t.pending+=s),t.pos+=a,!0}function jG(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 Mk(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 qG(t){const e=t.tokens_meta,n=t.tokens_meta.length;Mk(t,t.delimiters);for(let r=0;r<n;r++)e[r]&&e[r].delimiters&&Mk(t,e[r].delimiters)}const RA={tokenize:jG,postProcess:qG};function WG(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 Dk(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 u=t.tokens[o.token];u.type=s?"strong_close":"em_close",u.tag=s?"strong":"em",u.nesting=-1,u.markup=s?a+a:a,u.content="",s&&(t.tokens[e[r-1].token].content="",t.tokens[e[i.end+1].token].content="",r--)}}function KG(t){const e=t.tokens_meta,n=t.tokens_meta.length;Dk(t,t.delimiters);for(let r=0;r<n;r++)e[r]&&e[r].delimiters&&Dk(t,e[r].delimiters)}const NA={tokenize:WG,postProcess:KG};function GG(t,e){let n,r,i,o,s="",a="",l=t.pos,u=!0;if(t.src.charCodeAt(t.pos)!==91)return!1;const c=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(u=!1,m++;m<f&&(n=t.src.charCodeAt(m),!(!qt(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),!(!qt(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),!(!qt(n)&&n!==10));m++);}(m>=f||t.src.charCodeAt(m)!==41)&&(u=!0),m++}if(u){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[am(r)],!o)return t.pos=c,!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 ZG(t,e){let n,r,i,o,s,a,l,u,c="";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),!(!qt(n)&&n!==10));o++);if(o>=h)return!1;for(u=o,a=t.md.helpers.parseLinkDestination(t.src,o,t.posMax),a.ok&&(c=t.md.normalizeLink(a.str),t.md.validateLink(c)?o=a.pos:c=""),u=o;o<h&&(n=t.src.charCodeAt(o),!(!qt(n)&&n!==10));o++);if(a=t.md.helpers.parseLinkTitle(t.src,o,t.posMax),o<h&&u!==o&&a.ok)for(l=a.str,o=a.pos;o<h&&(n=t.src.charCodeAt(o),!(!qt(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?(u=o+1,o=t.md.helpers.parseLinkLabel(t,o),o>=0?i=t.src.slice(u,o++):o=m+1):o=m+1,i||(i=t.src.slice(p,m)),s=t.env.references[am(i)],!s)return t.pos=f,!1;c=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",c],["alt",""]];g.attrs=b,g.children=v,g.content=r,l&&b.push(["title",l])}return t.pos=o,t.posMax=h,!0}const JG=/^([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])?)*)$/,YG=/^([a-zA-Z][a-zA-Z0-9+.-]{1,31}):([^<>\x00-\x20]*)$/;function XG(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(YG.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 u=t.push("link_close","a",-1);u.markup="autolink",u.info="auto"}return t.pos+=o.length+2,!0}if(JG.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 u=t.push("link_close","a",-1);u.markup="autolink",u.info="auto"}return t.pos+=o.length+2,!0}return!1}function QG(t){return/^<a[>\s]/i.test(t)}function $G(t){return/^<\/a\s*>/i.test(t)}function eZ(t){const e=t|32;return e>=97&&e<=122}function tZ(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&&!eZ(i))return!1;const o=t.src.slice(r).match(DG);if(!o)return!1;if(!e){const s=t.push("html_inline","",0);s.content=o[0],QG(s.content)&&t.linkLevel++,$G(s.content)&&t.linkLevel--}return t.pos+=o[0].length,!0}const nZ=/^&#((?:x[a-f0-9]{1,6}|[0-9]{1,7}));/i,rZ=/^&([a-z][a-z0-9]{1,31});/i;function iZ(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(nZ);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=S1(s)?sp(s):sp(65533),a.markup=o[0],a.info="entity"}return t.pos+=o[0].length,!0}}else{const o=t.src.slice(n).match(rZ);if(o){const s=EA(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 Ok(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 u=r-o[r]-1,c=u;for(;u>l;u-=o[u]+1){const f=t[u];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=u>0&&!t[u-1].open?o[u-1]+1:0;o[s]=s-u+p,o[u]=p,a.open=!1,f.end=s,f.close=!1,c=-1,i=-2;break}}}c!==-1&&(e[a.marker][(a.open?3:0)+(a.length||0)%3]=c)}}function oZ(t){const e=t.tokens_meta,n=t.tokens_meta.length;Ok(t.delimiters);for(let r=0;r<n;r++)e[r]&&e[r].delimiters&&Ok(e[r].delimiters)}function sZ(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 Ag=[["text",FG],["linkify",BG],["newline",HG],["escape",VG],["backticks",UG],["strikethrough",RA.tokenize],["emphasis",NA.tokenize],["link",GG],["image",ZG],["autolink",XG],["html_inline",tZ],["entity",iZ]],Tg=[["balance_pairs",oZ],["strikethrough",RA.postProcess],["emphasis",NA.postProcess],["fragments_join",sZ]];function wd(){this.ruler=new Sr;for(let t=0;t<Ag.length;t++)this.ruler.push(Ag[t][0],Ag[t][1]);this.ruler2=new Sr;for(let t=0;t<Tg.length;t++)this.ruler2.push(Tg[t][0],Tg[t][1])}wd.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};wd.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()};wd.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)};wd.prototype.State=yd;function aZ(t){const e={};t=t||{},e.src_Any=kA.source,e.src_Cc=xA.source,e.src_Z=CA.source,e.src_P=_1.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 Tv(t){return Array.prototype.slice.call(arguments,1).forEach(function(n){n&&Object.keys(n).forEach(function(r){t[r]=n[r]})}),t}function um(t){return Object.prototype.toString.call(t)}function lZ(t){return um(t)==="[object String]"}function uZ(t){return um(t)==="[object Object]"}function cZ(t){return um(t)==="[object RegExp]"}function Ik(t){return um(t)==="[object Function]"}function dZ(t){return t.replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}const PA={fuzzyLink:!0,fuzzyEmail:!0,fuzzyIP:!1};function fZ(t){return Object.keys(t||{}).reduce(function(e,n){return e||PA.hasOwnProperty(n)},!1)}const hZ={"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}}},pZ="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]",mZ="biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|рф".split("|");function gZ(t){t.__index__=-1,t.__text_cache__=""}function vZ(t){return function(e,n){const r=e.slice(n);return t.test(r)?r.match(t)[0].length:0}}function Rk(){return function(t,e){e.normalize(t)}}function ap(t){const e=t.re=aZ(t.__opts__),n=t.__tlds__.slice();t.onCompile(),t.__tlds_replaced__||n.push(pZ),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 u={validate:null,link:null};if(t.__compiled__[a]=u,uZ(l)){cZ(l.validate)?u.validate=vZ(l.validate):Ik(l.validate)?u.validate=l.validate:o(a,l),Ik(l.normalize)?u.normalize=l.normalize:l.normalize?o(a,l):u.normalize=Rk();return}if(lZ(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:Rk()};const s=Object.keys(t.__compiled__).filter(function(a){return a.length>0&&t.__compiled__[a]}).map(dZ).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"),gZ(t)}function bZ(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 Mv(t,e){const n=new bZ(t,e);return t.__compiled__[n.schema].normalize(n,t),n}function zr(t,e){if(!(this instanceof zr))return new zr(t,e);e||fZ(t)&&(e=t,t={}),this.__opts__=Tv({},PA,e),this.__index__=-1,this.__last_index__=-1,this.__schema__="",this.__text_cache__="",this.__schemas__=Tv({},hZ,t),this.__compiled__={},this.__tlds__=mZ,this.__tlds_replaced__=!1,this.re={},ap(this)}zr.prototype.add=function(e,n){return this.__schemas__[e]=n,ap(this),this};zr.prototype.set=function(e){return this.__opts__=Tv(this.__opts__,e),this};zr.prototype.test=function(e){if(this.__text_cache__=e,this.__index__=-1,!e.length)return!1;let n,r,i,o,s,a,l,u,c;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:"]&&(u=e.search(this.re.host_fuzzy_test),u>=0&&(this.__index__<0||u<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:"]&&(c=e.indexOf("@"),c>=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};zr.prototype.pretest=function(e){return this.re.pretest.test(e)};zr.prototype.testSchemaAt=function(e,n,r){return this.__compiled__[n.toLowerCase()]?this.__compiled__[n.toLowerCase()].validate(e,r,this):0};zr.prototype.match=function(e){const n=[];let r=0;this.__index__>=0&&this.__text_cache__===e&&(n.push(Mv(this,r)),r=this.__last_index__);let i=r?e.slice(r):e;for(;this.test(i);)n.push(Mv(this,r)),i=i.slice(this.__last_index__),r+=this.__last_index__;return n.length?n:null};zr.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,Mv(this,0)):null};zr.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)};zr.prototype.normalize=function(e){e.schema||(e.url="http://"+e.url),e.schema==="mailto:"&&!/^mailto:/i.test(e.url)&&(e.url="mailto:"+e.url)};zr.prototype.onCompile=function(){};const dl=2147483647,Ui=36,T1=1,Uc=26,yZ=38,wZ=700,LA=72,FA=128,zA="-",kZ=/^xn--/,xZ=/[^\0-\x7F]/,_Z=/[\x2E\u3002\uFF0E\uFF61]/g,CZ={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},Mg=Ui-T1,ji=Math.floor,Dg=String.fromCharCode;function Go(t){throw new RangeError(CZ[t])}function SZ(t,e){const n=[];let r=t.length;for(;r--;)n[r]=e(t[r]);return n}function BA(t,e){const n=t.split("@");let r="";n.length>1&&(r=n[0]+"@",t=n[1]),t=t.replace(_Z,".");const i=t.split("."),o=SZ(i,e).join(".");return r+o}function HA(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 EZ=t=>String.fromCodePoint(...t),AZ=function(t){return t>=48&&t<58?26+(t-48):t>=65&&t<91?t-65:t>=97&&t<123?t-97:Ui},Nk=function(t,e){return t+22+75*(t<26)-((e!=0)<<5)},VA=function(t,e,n){let r=0;for(t=n?ji(t/wZ):t>>1,t+=ji(t/e);t>Mg*Uc>>1;r+=Ui)t=ji(t/Mg);return ji(r+(Mg+1)*t/(t+yZ))},UA=function(t){const e=[],n=t.length;let r=0,i=FA,o=LA,s=t.lastIndexOf(zA);s<0&&(s=0);for(let a=0;a<s;++a)t.charCodeAt(a)>=128&&Go("not-basic"),e.push(t.charCodeAt(a));for(let a=s>0?s+1:0;a<n;){const l=r;for(let c=1,f=Ui;;f+=Ui){a>=n&&Go("invalid-input");const h=AZ(t.charCodeAt(a++));h>=Ui&&Go("invalid-input"),h>ji((dl-r)/c)&&Go("overflow"),r+=h*c;const p=f<=o?T1:f>=o+Uc?Uc:f-o;if(h<p)break;const m=Ui-p;c>ji(dl/m)&&Go("overflow"),c*=m}const u=e.length+1;o=VA(r-l,u,l==0),ji(r/u)>dl-i&&Go("overflow"),i+=ji(r/u),r%=u,e.splice(r++,0,i)}return String.fromCodePoint(...e)},jA=function(t){const e=[];t=HA(t);const n=t.length;let r=FA,i=0,o=LA;for(const l of t)l<128&&e.push(Dg(l));const s=e.length;let a=s;for(s&&e.push(zA);a<n;){let l=dl;for(const c of t)c>=r&&c<l&&(l=c);const u=a+1;l-r>ji((dl-i)/u)&&Go("overflow"),i+=(l-r)*u,r=l;for(const c of t)if(c<r&&++i>dl&&Go("overflow"),c===r){let f=i;for(let h=Ui;;h+=Ui){const p=h<=o?T1:h>=o+Uc?Uc:h-o;if(f<p)break;const m=f-p,v=Ui-p;e.push(Dg(Nk(p+m%v,0))),f=ji(m/v)}e.push(Dg(Nk(f,0))),o=VA(i,u,a===s),i=0,++a}++i,++r}return e.join("")},TZ=function(t){return BA(t,function(e){return kZ.test(e)?UA(e.slice(4).toLowerCase()):e})},MZ=function(t){return BA(t,function(e){return xZ.test(e)?"xn--"+jA(e):e})},qA={version:"2.3.1",ucs2:{decode:HA,encode:EZ},decode:UA,encode:jA,toASCII:MZ,toUnicode:TZ},DZ={options:{html:!1,xhtmlOut:!1,breaks:!1,langPrefix:"language-",linkify:!1,typographer:!1,quotes:"“”‘’",highlight:null,maxNesting:100},components:{core:{},block:{},inline:{}}},OZ={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"]}}},IZ={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"]}}},RZ={default:DZ,zero:OZ,commonmark:IZ},NZ=/^(vbscript|javascript|file|data):/,PZ=/^data:image\/(gif|png|jpeg|webp);/;function LZ(t){const e=t.trim().toLowerCase();return NZ.test(e)?PZ.test(e):!0}const WA=["http:","https:","mailto:"];function FZ(t){const e=x1(t,!0);if(e.hostname&&(!e.protocol||WA.indexOf(e.protocol)>=0))try{e.hostname=qA.toASCII(e.hostname)}catch{}return bd(k1(e))}function zZ(t){const e=x1(t,!0);if(e.hostname&&(!e.protocol||WA.indexOf(e.protocol)>=0))try{e.hostname=qA.toUnicode(e.hostname)}catch{}return ql(k1(e),ql.defaultChars+"%")}function Br(t,e){if(!(this instanceof Br))return new Br(t,e);e||C1(t)||(e=t||{},t="default"),this.inline=new wd,this.block=new lm,this.core=new E1,this.renderer=new ou,this.linkify=new zr,this.validateLink=LZ,this.normalizeLink=FZ,this.normalizeLinkText=zZ,this.utils=HK,this.helpers=sm({},qK),this.options={},this.configure(t),e&&this.set(e)}Br.prototype.set=function(t){return sm(this.options,t),this};Br.prototype.configure=function(t){const e=this;if(C1(t)){const n=t;if(t=RZ[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};Br.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};Br.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};Br.prototype.use=function(t){const e=[this].concat(Array.prototype.slice.call(arguments,1));return t.apply(t,e),this};Br.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};Br.prototype.render=function(t,e){return e=e||{},this.renderer.render(this.parse(t,e),this.options,e)};Br.prototype.parseInline=function(t,e){const n=new this.core.State(t,this,e);return n.inlineMode=!0,this.core.process(n),n.tokens};Br.prototype.renderInline=function(t,e){return e=e||{},this.renderer.render(this.parseInline(t,e),this.options,e)};const BZ=new eb({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 HZ(t,e){if(t.isText&&e.isText&&It.sameSet(t.marks,e.marks))return t.withText(t.text+e.text)}class VZ{constructor(e,n){this.schema=e,this.tokenHandlers=n,this.stack=[{type:e.topNodeType,attrs:null,content:[],marks:It.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=HZ(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:It.none})}closeNode(){let e=this.stack.pop();return this.addNode(e.type,e.attrs,e.content)}}function vu(t,e,n,r){return t.getAttrs?t.getAttrs(e,n,r):t.attrs instanceof Function?t.attrs(e):t.attrs}function Og(t,e){return t.noCloseToken||e=="code_inline"||e=="code_block"||e=="fence"}function Pk(t){return t[t.length-1]==`
|
|
215
|
+
`?t.slice(0,t.length-1):t}function Ig(){}function UZ(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);Og(i,r)?n[r]=(s,a,l,u)=>{s.openNode(o,vu(i,a,l,u)),s.addText(Pk(a.content)),s.closeNode()}:(n[r+"_open"]=(s,a,l,u)=>s.openNode(o,vu(i,a,l,u)),n[r+"_close"]=s=>s.closeNode())}else if(i.node){let o=t.nodeType(i.node);n[r]=(s,a,l,u)=>s.addNode(o,vu(i,a,l,u))}else if(i.mark){let o=t.marks[i.mark];Og(i,r)?n[r]=(s,a,l,u)=>{s.openMark(o.create(vu(i,a,l,u))),s.addText(Pk(a.content)),s.closeMark(o)}:(n[r+"_open"]=(s,a,l,u)=>s.openMark(o.create(vu(i,a,l,u))),n[r+"_close"]=s=>s.closeMark(o))}else if(i.ignore)Og(i,r)?n[r]=Ig:(n[r+"_open"]=Ig,n[r+"_close"]=Ig);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 KA{constructor(e,n,r){this.schema=e,this.tokenizer=n,this.tokens=r,this.tokenHandlers=UZ(e,r)}parse(e,n={}){let r=new VZ(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 Lk(t,e){for(;++e<t.length;)if(t[e].type!="list_item_open")return t[e].hidden;return!1}new KA(BZ,Br("commonmark",{html:!1}),{blockquote:{block:"blockquote"},paragraph:{block:"paragraph"},list_item:{block:"list_item"},bullet_list:{block:"bullet_list",getAttrs:(t,e,n)=>({tight:Lk(e,n)})},ordered_list:{block:"ordered_list",getAttrs:(t,e,n)=>({order:+t.attrGet("start")||1,tight:Lk(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}});const jZ=["http://","https://","mailto:","ftp://","//"];function GA(t){const e=t.toLowerCase();return jZ.some(n=>e.startsWith(n))}function qZ(t){if(!t)return null;const e=t.trim();if(!e)return null;if(GA(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 WZ(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:qZ(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 KZ(t){const e=Br("commonmark",{html:!1}).enable(["strikethrough","linkify"]);return new KA(t,e,WZ(t))}function GZ(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 ZZ(t,e){if(!GZ(t))return null;let n;try{const i=KZ(e).parse(t);if(!i)return null;n=i}catch{return null}return n.childCount===0?null:Te.maxOpen(n.content)}var JZ=M('<div role="presentation" data-testid="editor-root"></div>');function YZ(t,e){ze(e,!0);const n=new Set([...id].filter(f=>f!==".docx"));function r(f,h){const p=h.includes("\\")?"\\":"/",m=f.indexOf("#"),v=m>=0?f.slice(0,m):f;if(!v)return null;const g=v.match(/\.[^./\\]+$/),b=g?g[0].toLowerCase():"";if(!n.has(b))return null;const x=h.split(p);x.pop();const T=v.replace(/\//g,p).split(p),S=[...x];for(const z of T)z===".."?S.length>0&&S.pop():z!=="."&&S.push(z);return S.join(p)}let i=B(null),o=null;const s=F(()=>e.format==="docx");me(()=>{if(e.ydoc,e.provider,!o)return;const f=new JV({element:o,extensions:[wW.configure({history:!1}),UU.configure({multicolor:!0}),hj.configure({openOnClick:!1,HTMLAttributes:{rel:"noopener noreferrer",target:"_blank"}}),pj.configure({placeholder:"Start typing…"}),vq.configure({resizable:!0}),wq,bq,yq,HW,zU.configure({document:e.ydoc}),BU.configure({provider:e.provider,user:{name:Lb(),color:"var(--tandem-warning)"}}),_W.configure({ydoc:e.ydoc}),BW.configure({filePath:St(()=>e.currentFilePath??null)}),EW.configure({ydoc:e.ydoc}),AW.configure({ydoc:e.ydoc}),$W.configure({onOpenChange:e.onSlashCommandMenuChange}),OW,UW],editorProps:{attributes:{class:"tandem-editor",style:"outline: none; font-size: var(--tandem-editor-font-size, 16px); line-height: 1.6;"},clipboardTextParser:(h,p,m,v)=>{if(!m){const _=ZZ(h,v.state.schema);if(_)return _}const g=v.state.schema,b=p.marks(),x=h.split(/(?:\r\n?|\n)+/).map(_=>g.nodes.paragraph.create(null,_?g.text(_,b):void 0));return Te.maxOpen(ge.fromArray(x))}},editable:St(()=>!e.readOnly),autofocus:St(()=>!e.readOnly)});return y(i,f,!0),St(()=>{var h;return(h=e.onEditorReady)==null?void 0:h.call(e,f)}),()=>{St(()=>{var h;return(h=e.onEditorReady)==null?void 0:h.call(e,null)}),f.destroy(),d(i)===f&&y(i,null)}});let a;me(()=>{const f=d(i);if(!f)return;const h=e.readOnly;a!==h&&(a=h,f.setEditable(!h))}),me(()=>{const f=d(i);if(f)return _3(h=>f.commands.updateUser({name:h}))}),me(()=>{const f=d(i);if(!f)return;const h=f.view.dom;h.querySelectorAll(".tandem-annotation-active").forEach(p=>{p.classList.remove("tandem-annotation-active")}),e.activeAnnotationId&&h.querySelectorAll(`[data-annotation-id="${CSS.escape(e.activeAnnotationId)}"]`).forEach(p=>{p.classList.add("tandem-annotation-active")})});async function l(f){var b;const h=f.target.closest("a[href]");if(h){const x=h.getAttribute("href")??"";if(!x||x.startsWith("#"))return;if(f.preventDefault(),GA(x)){window.open(x,"_blank","noopener,noreferrer");return}if(e.currentFilePath){const _=r(x,e.currentFilePath);if(_){const T=await Po(_);T.ok||console.warn(`[tandem] Could not open linked file "${_}": ${T.error}`)}}return}const p={highlight:2,comment:1,note:0};let m=f.target.closest("[data-annotation-id]"),v=null,g=Number.NEGATIVE_INFINITY;for(;m;){const x=m.getAttribute("data-annotation-id");if(x){const T=m.getAttribute("data-annotation-type")??"",S=p[T]??-1;S>g&&(g=S,v=x)}const _=m.parentElement;m=_?_.closest("[data-annotation-id]"):null}v&&e.onAnnotationClick?e.onAnnotationClick(v):v||(b=e.onClearAnnotation)==null||b.call(e)}var u=JZ();let c;xt(u,f=>o=f,()=>o),q(()=>c=At(u,1,"",null,c,{"tandem-paged":d(s)})),N("click",u,l),C(t,u),Be()}We(["click"]);var XZ=M('<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>'),QZ=M('<div class="fr-error svelte-1q9bff2" role="alert"> </div>'),$Z=M('<div class="fr-warning svelte-1q9bff2" role="status"> </div>'),eJ=M('<div class="fr-xdoc-status svelte-1q9bff2">Searching…</div>'),tJ=M('<div class="fr-xdoc-status svelte-1q9bff2">No matches in open tabs</div>'),nJ=M('<div class="fr-xdoc-snip svelte-1q9bff2"> </div>'),rJ=M('<div class="fr-xdoc-row svelte-1q9bff2"><div class="fr-xdoc-name svelte-1q9bff2"> <span class="fr-xdoc-count svelte-1q9bff2"> </span></div> <!></div>'),iJ=M('<div data-testid="find-cross-doc-results" class="fr-xdoc svelte-1q9bff2"><!></div>'),oJ=M('<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 sJ(t,e){ze(e,!0);let n=je(e,"tabs",19,()=>[]),r=B("doc"),i=B(Ge([])),o=B(!1);me(()=>{n().length<=1&&d(r)==="tabs"&&(y(r,"doc"),y(i,[],!0),y(o,!1))});function s(ae){const re=ae.getXmlFragment("default"),ue=[];function oe(fe){if(fe instanceof hn)ue.push(fe.toString());else{for(let I=0;I<fe.length;I++){const O=fe.get(I);(O instanceof hn||O instanceof Qt)&&oe(O)}fe instanceof Qt&&fe.nodeName!=="text"&&ue.push(" ")}}return oe(re),ue.join("")}function a(ae,re,ue){const oe=s(ae),fe=ue?re:re.toLowerCase(),I=ue?oe:oe.toLowerCase(),O=[];let A=0,V=0;for(;(V=I.indexOf(fe,V))!==-1;){if(A++,O.length<3){const L=Math.max(0,V-30),J=Math.min(oe.length,V+fe.length+30),K=oe.slice(L,J).replace(/\s+/g," ").trim();O.push((L>0?"…":"")+K+(J<oe.length?"…":""))}V+=fe.length}return{count:A,snippets:O}}let l;lr(()=>clearTimeout(l));function u(ae,re){if(clearTimeout(l),!ae){y(i,[],!0),y(o,!1);return}y(o,!0),l=setTimeout(()=>{const ue=[];for(const oe of n()){if(!oe.ydoc)continue;const{count:fe,snippets:I}=a(oe.ydoc,ae,re);fe>0&&ue.push({tabId:oe.id,fileName:oe.fileName,count:fe,snippets:I})}y(i,ue,!0),y(o,!1)},300)}let c=B(""),f=B(""),h=B(!1),p=B(!1),m=B(!1),v=B(null),g=B(!1),b=B(null),x=B(null),_=B(0);const T=F(()=>(d(_),e.editor?cl(e.editor.state):void 0)),S=F(()=>{var ae;return((ae=d(T))==null?void 0:ae.matches.length)??0}),z=F(()=>{var ae;return((ae=d(T))==null?void 0:ae.activeIndex)??-1});let E=B(null);me(()=>{var ae;e.open&&((ae=d(E))==null||ae.focus())});let D=!1;me(()=>{const ae=e.open&&!D;D=e.open,!(!ae||!e.forceScope)&&(e.forceScope==="tabs"&&n().length>1?(y(r,"tabs"),u(d(c),d(h))):y(r,"doc"))}),me(()=>{const ae=e.editor;if(!ae||ae.isDestroyed)return;const re=()=>tc(_);return ae.on("update",re),ae.on("selectionUpdate",re),()=>{ae.isDestroyed||(ae.off("update",re),ae.off("selectionUpdate",re))}});function P(){if(d(r)==="tabs"){u(d(c),d(h));return}const ae=e.editor;if(!ae||!d(c)){y(v,null),ae==null||ae.commands.findClose();return}if(d(m))try{new RegExp(d(c)),y(v,null)}catch(ue){y(v,ue instanceof Error?ue.message:"Invalid regex",!0);return}else y(v,null);const re={query:d(c),caseSensitive:d(h),wholeWord:d(p),regexMode:d(m)};ae.commands.find(re)}function R(ae){var re;y(r,ae,!0),ae==="tabs"?((re=e.editor)==null||re.commands.findClose(),u(d(c),d(h))):(y(i,[],!0),clearTimeout(l),P())}function H(ae){var re,ue;if(ae.key==="Enter"){ae.preventDefault(),ae.shiftKey?(re=e.editor)==null||re.commands.findPrev():(ue=e.editor)==null||ue.commands.findNext();return}ae.key==="Escape"&&Q()}function Q(){var ae;(ae=e.editor)==null||ae.commands.findClose(),e.onClose()}async function Z(){const ae=e.editor;if(!ae||!d(c)||d(g))return;const re=d(S);if(re>500&&!window.confirm(`Replace all ${re} occurrences? This cannot be undone as a single action.`))return;y(g,!0),y(x,null),y(b,{replaced:0,total:re},!0);const{replaced:ue,partial:oe}=await RW(ae.view,d(f),(fe,I)=>{y(b,{replaced:fe,total:I},!0)});y(b,null),y(g,!1),oe&&y(x,`Replaced ${ue} of ${re}; re-run to continue`)}var $=kt(),W=Se($);{var te=ae=>{var re=oJ(),ue=w(re);{var oe=pe=>{var Ie=XZ(),pt=w(Ie);let Pt;var Gt=k(pt,2);let Ke;q(()=>{Pt=At(pt,1,"fr-scope-pill svelte-1q9bff2",null,Pt,{on:d(r)==="doc"}),U(pt,"aria-pressed",d(r)==="doc"),Ke=At(Gt,1,"fr-scope-pill svelte-1q9bff2",null,Ke,{on:d(r)==="tabs"}),U(Gt,"aria-pressed",d(r)==="tabs")}),N("click",pt,()=>R("doc")),N("click",Gt,()=>R("tabs")),C(pe,Ie)};G(ue,pe=>{n().length>1&&pe(oe)})}var fe=k(ue,2),I=w(fe);let O;xt(I,pe=>y(E,pe),()=>d(E));var A=k(I,2),V=w(A);{var L=pe=>{var Ie=or();q(()=>ee(Ie,d(S)===0?"No matches":`${d(z)+1} / ${d(S)}`)),C(pe,Ie)};G(V,pe=>{d(c)&&pe(L)})}var J=k(A,2),K=k(J,2),ne=k(K,2),ye=k(fe,2);{var ce=pe=>{var Ie=QZ(),pt=w(Ie);q(()=>ee(pt,d(v))),C(pe,Ie)};G(ye,pe=>{d(v)&&pe(ce)})}var ve=k(ye,2),_e=w(ve),Y=w(_e),we=k(_e,2),se=w(we),X=k(we,2),le=w(X),he=k(ve,2),De=w(he),Oe=k(De,2),be=k(Oe,2),Ne=w(be);{var Qe=pe=>{var Ie=or();q(()=>ee(Ie,`${d(b).replaced??""}/${d(b).total??""}`)),C(pe,Ie)},Ae=pe=>{var Ie=or("All");C(pe,Ie)};G(Ne,pe=>{d(g)&&d(b)?pe(Qe):pe(Ae,-1)})}var Me=k(he,2);{var Ze=pe=>{var Ie=$Z(),pt=w(Ie);q(()=>ee(pt,d(x))),C(pe,Ie)};G(Me,pe=>{d(x)&&pe(Ze)})}var ut=k(Me,2);{var it=pe=>{var Ie=iJ(),pt=w(Ie);{var Pt=Ve=>{var ct=eJ();C(Ve,ct)},Gt=Ve=>{var ct=tJ();C(Ve,ct)},Ke=Ve=>{var ct=kt(),ht=Se(ct);Je(ht,17,()=>d(i),Sl,($e,mt)=>{var un=rJ(),ot=w(un),yt=w(ot),$t=k(yt),Hr=w($t),di=k(ot,2);Je(di,17,()=>d(mt).snippets,Sl,(Vr,Ti)=>{var gn=nJ(),Mi=w(gn);q(()=>ee(Mi,d(Ti))),C(Vr,gn)}),q(()=>{ee(yt,`${d(mt).fileName??""} `),ee(Hr,`(${d(mt).count??""} ${d(mt).count===1?"match":"matches"})`)}),C($e,un)}),C(Ve,ct)};G(pt,Ve=>{d(o)?Ve(Pt):d(c)&&d(i).length===0?Ve(Gt,1):Ve(Ke,-1)})}C(pe,Ie)};G(ut,pe=>{d(r)==="tabs"&&pe(it)})}q(()=>{O=At(I,1,"fr-input svelte-1q9bff2",null,O,{"has-error":!!d(v)}),J.disabled=d(S)===0,K.disabled=d(S)===0,Oe.disabled=d(S)===0||d(g)||d(r)==="tabs",U(Oe,"title",d(r)==="tabs"?"Replace is not available in Open tabs mode":void 0),be.disabled=d(S)===0||d(g)||d(r)==="tabs",U(be,"title",d(r)==="tabs"?"Replace All is not available in Open tabs mode":void 0)}),N("keydown",re,H),N("input",I,P),Bn(I,()=>d(c),pe=>y(c,pe)),N("click",J,()=>{var pe;return(pe=e.editor)==null?void 0:pe.commands.findPrev()}),N("click",K,()=>{var pe;return(pe=e.editor)==null?void 0:pe.commands.findNext()}),N("click",ne,Q),N("change",Y,P),gf(Y,()=>d(h),pe=>y(h,pe)),N("change",se,P),gf(se,()=>d(p),pe=>y(p,pe)),N("change",le,P),gf(le,()=>d(m),pe=>y(m,pe)),Bn(De,()=>d(f),pe=>y(f,pe)),N("click",Oe,()=>{e.editor&&(IW(e.editor.view,d(f)),tc(_))}),N("click",be,Z),C(ae,re)};G(W,ae=>{e.open&&ae(te)})}C(t,$),Be()}We(["keydown","click","input","change"]);function Xr(t,e){function n(r){t.contains(r.target)||e(r)}return document.addEventListener("mousedown",n),{destroy(){document.removeEventListener("mousedown",n)}}}var aJ=M('<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),lJ=M('<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>'),uJ=M('<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 ZA(t,e){ze(e,!0);let n=B(!1),r=B(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 u=uJ();let c;var f=w(u);let h;var p=k(f,4);xt(p,g=>y(r,g),()=>d(r));var m=k(p,2);{var v=g=>{var b=lJ(),x=k(w(b),2);let _;var T=k(x,2);let S;var z=k(T,2);let E;var D=k(z,2);let P;var R=k(D,2);{var H=Q=>{var Z=aJ(),$=k(Se(Z),2);N("click",$,l),C(Q,Z)};G(R,Q=>{e.onOpenSettings&&Q(H)})}q(()=>{_=At(x,1,"mi svelte-94a7fq",null,_,{on:e.showAuthorship}),U(x,"aria-checked",e.showAuthorship),S=At(T,1,"mi svelte-94a7fq",null,S,{on:e.showComments}),U(T,"aria-checked",e.showComments),E=At(z,1,"mi svelte-94a7fq",null,E,{on:e.showHighlights}),U(z,"aria-checked",e.showHighlights),P=At(D,1,"mi svelte-94a7fq",null,P,{on:e.showNotes}),U(D,"aria-checked",e.showNotes)}),N("click",x,()=>o("showAuthorship",e.showAuthorship)),N("click",T,()=>o("showComments",e.showComments)),N("click",z,()=>o("showHighlights",e.showHighlights)),N("click",D,()=>o("showNotes",e.showNotes)),C(g,b)};G(m,g=>{d(n)&&g(v)})}cr(u,(g,b)=>Xr==null?void 0:Xr(g,b),()=>()=>y(n,!1)),q(()=>{c=At(u,1,"split menu-wrap svelte-94a7fq",null,c,{open:d(n)}),h=At(f,1,"ib half-main svelte-94a7fq",null,h,{on:!e.decorationsMuted}),U(f,"aria-pressed",!e.decorationsMuted),U(f,"title",e.decorationsMuted?"Restore decorations":"Mute decorations"),U(f,"aria-label",e.decorationsMuted?"Restore decorations":"Mute decorations"),U(p,"aria-expanded",d(n))}),N("keydown",u,a),N("click",f,i),N("click",p,()=>y(n,!d(n))),C(t,u),Be()}We(["keydown","click"]);function M1(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 JA(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 hi(t){return e=>{e.preventDefault(),t()}}function cJ(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 dJ(t,e){const n=e.trim();n?t.chain().focus().setLink({href:n}).run():t.isActive("link")&&t.chain().focus().unsetLink().run()}var fJ=M('<button type="button"><!></button>');function gr(t,e){const n=je(e,"disabled",3,!1),r=je(e,"active",3,!1),i=je(e,"style",3,""),o=F(()=>e.ariaLabel??(typeof e.label=="string"?e.label:void 0)),s=F(()=>d(o)??""),a=F(()=>n()&&e.disabledTitle?e.disabledTitle:e.shortcut?`${d(s)} (${e.shortcut})`:d(s));var l=fJ();let u;var c=w(l);{var f=p=>{var m=kt(),v=Se(m);rd(v,()=>e.children),C(p,m)},h=p=>{var m=or();q(()=>ee(m,e.label)),C(p,m)};G(c,p=>{e.children?p(f):p(h,-1)})}q(()=>{u=At(l,1,"toolbar-btn svelte-xw5pw0",null,u,{"is-active":r()}),U(l,"data-testid",e.testId),l.disabled=n(),U(l,"title",d(a)),U(l,"aria-label",d(o)),U(l,"aria-pressed",e.ariaPressed),U(l,"aria-haspopup",e.ariaHasPopup),U(l,"aria-expanded",e.ariaExpanded),xe(l,i())}),N("mousedown",l,function(...p){var m;(m=e.onMouseDown)==null||m.apply(this,p)}),N("click",l,function(...p){var m;(m=e.onClick)==null||m.apply(this,p)}),C(t,l)}We(["mousedown","click"]);var hJ=Er('<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>'),pJ=Er('<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>'),mJ=M('<!> <!> <div style="width: 1px; height: 16px; background: var(--tandem-border); margin: 0 2px;"></div>',1),gJ=M('<button type="button" role="menuitemradio"> </button>'),vJ=M(`<div role="menu" aria-label="Heading level" style="position: absolute; top: 100%; left: 0; margin-top: 4px;
|
|
216
|
+
background: var(--tandem-surface); border: 1px solid var(--tandem-border);
|
|
217
|
+
border-radius: var(--tandem-r-3); padding: 4px; display: flex; flex-direction: column;
|
|
218
|
+
gap: 2px; z-index: var(--tandem-z-dropdown); box-shadow: var(--tandem-shadow-1);"></div>`),bJ=Er('<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>'),yJ=Er('<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>'),wJ=Er('<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>'),kJ=Er('<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>'),xJ=M(`<div role="dialog" aria-label="Insert link" style="position: absolute; top: 100%; left: 0; margin-top: 4px;
|
|
219
|
+
background: var(--tandem-surface); border: 1px solid var(--tandem-border);
|
|
220
|
+
border-radius: var(--tandem-r-3); padding: 6px;
|
|
221
|
+
display: flex; align-items: center; gap: 4px;
|
|
222
|
+
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;
|
|
223
|
+
border: 1px solid var(--tandem-border); border-radius: var(--tandem-r-2);
|
|
224
|
+
background: var(--tandem-surface); color: var(--tandem-fg);
|
|
225
|
+
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;
|
|
226
|
+
border: 1px solid var(--tandem-accent-border); background: transparent;
|
|
227
|
+
color: var(--tandem-accent); border-radius: var(--tandem-r-2); cursor: pointer;
|
|
228
|
+
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;
|
|
229
|
+
border: 1px solid var(--tandem-border); background: transparent;
|
|
230
|
+
color: var(--tandem-fg-muted); border-radius: var(--tandem-r-2); cursor: pointer;">Cancel</button></div>`),_J=Er('<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>'),CJ=M('<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="width: 1px; height: 16px; background: var(--tandem-border); margin: 0 2px;"></div> <div style="position: relative;" role="presentation"><!> <!></div> <!> <!></div>');function YA(t,e){ze(e,!0);const n=je(e,"disabled",3,!1),r=je(e,"variant",3,"bar"),i=F(()=>r()==="bar"),o=[1,2,3],s={1:700,2:600,3:500};let a=B(0),l=B(!1),u=B(!1),c=B(""),f=B(null);me(()=>{const Y=e.editor;if(!Y||Y.isDestroyed)return;const we=()=>{Y.isDestroyed||tc(a)};return Y.on("transaction",we),()=>{Y.isDestroyed||Y.off("transaction",we)}}),me(()=>{var Y,we;d(u)&&((Y=d(f))==null||Y.focus(),(we=d(f))==null||we.select())});function h(Y){for(const we of o)if(Y.isActive("heading",{level:we}))return we;return null}const p=F(()=>e.editor?e.editor.isEditable:!1),m=F(()=>!d(p)||!!n()),v=F(()=>(d(a),e.editor?Gi.getState(e.editor.state):null)),g=F(()=>{var Y,we;return!d(m)&&(((we=(Y=d(v))==null?void 0:Y.undoManager)==null?void 0:we.undoStack.length)??0)>0}),b=F(()=>{var Y,we;return!d(m)&&(((we=(Y=d(v))==null?void 0:Y.undoManager)==null?void 0:we.redoStack.length)??0)>0}),x=F(()=>(d(a),e.editor?h(e.editor):null)),_=F(()=>{var Y;return d(a),!!((Y=e.editor)!=null&&Y.isActive("bold"))}),T=F(()=>{var Y;return d(a),!!((Y=e.editor)!=null&&Y.isActive("italic"))}),S=F(()=>{var Y;return d(a),!!((Y=e.editor)!=null&&Y.isActive("strike"))}),z=F(()=>{var Y;return d(a),!!((Y=e.editor)!=null&&Y.isActive("code"))}),E=F(()=>{var Y;return d(a),!!((Y=e.editor)!=null&&Y.isActive("bulletList"))}),D=F(()=>{var Y;return d(a),!!((Y=e.editor)!=null&&Y.isActive("orderedList"))}),P=F(()=>{var Y;return d(a),!!((Y=e.editor)!=null&&Y.isActive("blockquote"))}),R=F(()=>{var Y;return d(a),!!((Y=e.editor)!=null&&Y.isActive("codeBlock"))}),H=F(()=>{var Y;return d(a),!!((Y=e.editor)!=null&&Y.isActive("link"))}),Q=F(()=>(d(a),e.editor?d(m)||!e.editor.isActive("link")&&e.editor.state.selection.from===e.editor.state.selection.to:!0)),Z=F(()=>d(x)?`H${d(x)}`:"H"),$=F(()=>hi(()=>{var Y;return(Y=e.editor)==null?void 0:Y.commands.undo()})),W=F(()=>hi(()=>{var Y;return(Y=e.editor)==null?void 0:Y.commands.redo()})),te=F(()=>hi(()=>{var Y;return(Y=e.editor)==null?void 0:Y.chain().focus().toggleBold().run()})),ae=F(()=>hi(()=>{var Y;return(Y=e.editor)==null?void 0:Y.chain().focus().toggleItalic().run()})),re=F(()=>hi(()=>{var Y;return(Y=e.editor)==null?void 0:Y.chain().focus().toggleStrike().run()})),ue=F(()=>hi(()=>{var Y;return(Y=e.editor)==null?void 0:Y.chain().focus().toggleCode().run()})),oe=F(()=>hi(()=>{var Y;return(Y=e.editor)==null?void 0:Y.chain().focus().toggleBulletList().run()})),fe=F(()=>hi(()=>{var Y;return(Y=e.editor)==null?void 0:Y.chain().focus().toggleOrderedList().run()})),I=F(()=>hi(()=>{var Y;return(Y=e.editor)==null?void 0:Y.chain().focus().toggleBlockquote().run()})),O=F(()=>hi(()=>{var Y;return(Y=e.editor)==null?void 0:Y.chain().focus().setHorizontalRule().run()})),A=F(()=>hi(()=>{var Y;return(Y=e.editor)==null?void 0:Y.chain().focus().toggleCodeBlock().run()}));function V(Y){return we=>{we.detail===0&&Y(we)}}function L(Y){return we=>{we.preventDefault(),!(!e.editor||e.editor.isDestroyed)&&(e.editor.chain().focus().toggleHeading({level:Y}).run(),y(l,!1))}}function J(Y){Y.preventDefault(),e.editor&&(y(c,cJ(e.editor),!0),y(u,!0))}function K(){e.editor&&(dJ(e.editor,d(c)),ne())}function ne(){y(u,!1),y(c,"")}function ye(Y){Y.key==="Enter"?(Y.preventDefault(),Y.stopPropagation(),K()):Y.key==="Escape"&&(Y.preventDefault(),Y.stopPropagation(),ne())}var ce=kt(),ve=Se(ce);{var _e=Y=>{var we=CJ(),se=w(we);{var X=Ke=>{var Ve=mJ(),ct=Se(Ve);{const $e=ot=>{var yt=hJ();C(ot,yt)};let mt=F(()=>!d(g)),un=F(()=>V(d($)));gr(ct,{ariaLabel:"Undo",shortcut:"Ctrl+Z",get disabled(){return d(mt)},get onMouseDown(){return d($)},get onClick(){return d(un)},children:$e,$$slots:{default:!0}})}var ht=k(ct,2);{const $e=ot=>{var yt=pJ();C(ot,yt)};let mt=F(()=>!d(b)),un=F(()=>V(d(W)));gr(ht,{ariaLabel:"Redo",shortcut:"Ctrl+Shift+Z",get disabled(){return d(mt)},get onMouseDown(){return d(W)},get onClick(){return d(un)},children:$e,$$slots:{default:!0}})}C(Ke,Ve)};G(se,Ke=>{d(i)&&Ke(X)})}var le=k(se,2);{let Ke=F(()=>V(d(te)));gr(le,{label:"B",shortcut:"Ctrl+B",get disabled(){return d(m)},get active(){return d(_)},get onMouseDown(){return d(te)},get onClick(){return d(Ke)},style:"font-weight: 700;"})}var he=k(le,2);{let Ke=F(()=>V(d(ae)));gr(he,{label:"I",shortcut:"Ctrl+I",get disabled(){return d(m)},get active(){return d(T)},get onMouseDown(){return d(ae)},get onClick(){return d(Ke)},style:"font-style: italic;"})}var De=k(he,2);{let Ke=F(()=>V(d(re)));gr(De,{label:"S",shortcut:"Ctrl+Shift+X",get disabled(){return d(m)},get active(){return d(S)},get onMouseDown(){return d(re)},get onClick(){return d(Ke)},style:"text-decoration: line-through;"})}var Oe=k(De,2);{let Ke=F(()=>V(d(ue)));gr(Oe,{label:"<>",shortcut:"Ctrl+E",get disabled(){return d(m)},get active(){return d(z)},get onMouseDown(){return d(ue)},get onClick(){return d(Ke)},style:"font-family: monospace;"})}var be=k(Oe,2),Ne=w(be);{let Ke=F(()=>d(x)!==null),Ve=F(()=>V(ct=>{ct.preventDefault(),y(l,!d(l))}));gr(Ne,{get label(){return d(Z)},get disabled(){return d(m)},get active(){return d(Ke)},ariaHasPopup:"menu",get ariaExpanded(){return d(l)},onMouseDown:ct=>{ct.preventDefault(),y(l,!d(l))},get onClick(){return d(Ve)}})}var Qe=k(Ne,2);{var Ae=Ke=>{var Ve=vJ();Je(Ve,20,()=>o,ct=>ct,(ct,ht)=>{const $e=F(()=>L(ht));var mt=gJ(),un=F(()=>V(d($e))),ot=w(mt);q(()=>{U(mt,"aria-checked",d(x)===ht),xe(mt,`padding: 4px 12px; font-size: 13px; border: none;
|
|
231
|
+
border-radius: var(--tandem-r-2);
|
|
232
|
+
background: ${d(x)===ht?"var(--tandem-accent-bg)":"transparent"};
|
|
233
|
+
color: ${d(x)===ht?"var(--tandem-accent)":"var(--tandem-fg)"};
|
|
234
|
+
cursor: pointer; text-align: left;
|
|
235
|
+
font-weight: ${s[ht]??""}; white-space: nowrap;`),ee(ot,`Heading ${ht??""}`)}),N("mousedown",mt,function(...yt){var $t;($t=d($e))==null||$t.apply(this,yt)}),N("click",mt,function(...yt){var $t;($t=d(un))==null||$t.apply(this,yt)}),C(ct,mt)}),C(Ke,Ve)};G(Qe,Ke=>{d(l)&&Ke(Ae)})}cr(be,(Ke,Ve)=>Xr==null?void 0:Xr(Ke,Ve),()=>()=>y(l,!1));var Me=k(be,4);{const Ke=ct=>{var ht=bJ();C(ct,ht)};let Ve=F(()=>V(d(oe)));gr(Me,{ariaLabel:"Bullet list",shortcut:"Ctrl+Shift+8",get disabled(){return d(m)},get active(){return d(E)},get onMouseDown(){return d(oe)},get onClick(){return d(Ve)},children:Ke,$$slots:{default:!0}})}var Ze=k(Me,2);{const Ke=ct=>{var ht=yJ();C(ct,ht)};let Ve=F(()=>V(d(fe)));gr(Ze,{ariaLabel:"Ordered list",shortcut:"Ctrl+Shift+7",get disabled(){return d(m)},get active(){return d(D)},get onMouseDown(){return d(fe)},get onClick(){return d(Ve)},children:Ke,$$slots:{default:!0}})}var ut=k(Ze,2);{const Ke=ct=>{var ht=wJ();C(ct,ht)};let Ve=F(()=>V(d(I)));gr(ut,{ariaLabel:"Blockquote",shortcut:"Ctrl+Shift+B",get disabled(){return d(m)},get active(){return d(P)},get onMouseDown(){return d(I)},get onClick(){return d(Ve)},children:Ke,$$slots:{default:!0}})}var it=k(ut,4),pe=w(it);{const Ke=ht=>{var $e=kJ();C(ht,$e)};let Ve=F(()=>d(H)||d(u)),ct=F(()=>V(J));gr(pe,{ariaLabel:"Link",shortcut:"Ctrl+K",get disabled(){return d(Q)},get active(){return d(Ve)},ariaHasPopup:"dialog",get ariaExpanded(){return d(u)},onMouseDown:J,get onClick(){return d(ct)},children:Ke,$$slots:{default:!0}})}var Ie=k(pe,2);{var pt=Ke=>{var Ve=xJ(),ct=w(Ve);xt(ct,ot=>y(f,ot),()=>d(f));var ht=k(ct,2),$e=F(()=>V(ot=>{ot.preventDefault(),K()})),mt=k(ht,2),un=F(()=>V(ot=>{ot.preventDefault(),ne()}));N("keydown",ct,ye),Bn(ct,()=>d(c),ot=>y(c,ot)),N("mousedown",ht,ot=>{ot.preventDefault(),K()}),N("click",ht,function(...ot){var yt;(yt=d($e))==null||yt.apply(this,ot)}),N("mousedown",mt,ot=>{ot.preventDefault(),ne()}),N("click",mt,function(...ot){var yt;(yt=d(un))==null||yt.apply(this,ot)}),C(Ke,Ve)};G(Ie,Ke=>{d(u)&&Ke(pt)})}cr(it,(Ke,Ve)=>Xr==null?void 0:Xr(Ke,Ve),()=>ne);var Pt=k(it,2);{let Ke=F(()=>V(d(O)));gr(Pt,{label:"—",ariaLabel:"Horizontal rule",get disabled(){return d(m)},get onMouseDown(){return d(O)},get onClick(){return d(Ke)}})}var Gt=k(Pt,2);{const Ke=ct=>{var ht=_J();C(ct,ht)};let Ve=F(()=>V(d(A)));gr(Gt,{ariaLabel:"Code block",get disabled(){return d(m)},get active(){return d(R)},get onMouseDown(){return d(A)},get onClick(){return d(Ve)},children:Ke,$$slots:{default:!0}})}N("keydown",be,Ke=>{Ke.key==="Escape"&&y(l,!1)}),N("keydown",it,Ke=>{Ke.key==="Escape"&&ne()}),C(Y,we)};G(ve,Y=>{e.editor&&Y(_e)})}C(t,ce),Be()}We(["keydown","mousedown","click"]);function XA(t,e,n){const r=t.getMap(Ro);let i=null,o;for(const[l,u]of r.entries())if(u.type==="highlight"&&u.range.from===e.from&&u.range.to===e.to&&u.author==="user"&&u.status==="pending"&&u.content===""){i=l,o=u.color;break}if(i===null){const l=u0(),u={id:l,author:"user",type:"highlight",audience:"private",range:{from:e.from,to:e.to},content:"",status:"pending",timestamp:Date.now(),color:n};return ps(t,()=>r.set(l,u)),"added"}if(o===n)return ps(t,()=>r.delete(i)),"removed";const s=u0(),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 ps(t,()=>{r.delete(i),r.set(s,a)}),"recolored"}const tf=48,nf=8,Fk=10,zk=4;function SJ({start:t,end:e,toolbarHeight:n,toolbarWidth:r,viewportHeight:i,viewportWidth:o,previousPlacement:s}){const a=(t.left+e.right)/2,l=r/2,u=nf+l,c=Math.max(u,o-nf-l),f=Math.min(t.top,e.top),h=Math.max(t.bottom,e.bottom),p=f-Fk-n,m=h+Fk,v=m+n,g=tf+zk,b=tf-zk,_=p>=(s==="above"?b:g),T=v<=i-nf,S=Math.max(tf,i-n-nf);let z,E;return _?(z=p,E="above"):T?(z=m,E="below"):(z=S,E="below"),{left:Math.min(Math.max(a,u),c),top:Math.min(Math.max(z,tf),S),placement:E}}function EJ(t,e){return t.on("selectionUpdate",e),()=>t.off("selectionUpdate",e)}var AJ=M('<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),TJ=M('<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" aria-label="Show formatting bar" title="Show formatting bar" 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 d="m6 9 6 6 6-6"></path></svg></button>',1),MJ=M('<button type="button"></button>'),DJ=M('<div style="display: flex; align-items: center; gap: 1px; padding: 4px 4px 2px;"><!> <!> <!></div> <div style="height: 1px; background: var(--tandem-border); margin: 0 6px;"></div> <div style="display: flex; align-items: center; gap: 1px; padding: 2px 4px 4px;"><div style="display: inline-flex; gap: 3px; padding: 0 4px;" aria-label="Highlight colors"></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;">Annotate</button></div>',1),OJ=M('<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)" title="Note to self — private, not sent to Claude (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" aria-label="Send to Claude (Ctrl+Enter)" title="Send to Claude — outbound comment (Ctrl/Cmd+Enter)" 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;">Send to Claude <kbd style="font-family: var(--tandem-font-mono); font-size: 10px; color: var(--tandem-author-user);">⌘⏎</kbd></button></div></div>'),IJ=M('<div role="toolbar" aria-label="Selection tools" class="tandem-floating-pill"><!></div>');function RJ(t,e){ze(e,!0);let n=je(e,"selectionToolbar",3,!0),r=je(e,"suppressSelectionToolbar",3,!1),i=je(e,"requestCommentFocus",3,0),o=je(e,"showAuthorship",3,!0),s=je(e,"showComments",3,!0),a=je(e,"showHighlights",3,!0),l=je(e,"showNotes",3,!0),u=je(e,"decorationsMuted",3,!1),c=je(e,"formattingBarVisible",3,!0),f=B(!1),h=B(null),p=B(null),m=B(""),v=B(null),g=B(null),b=B(!1),x=B(0),_=B(0),T=B(Ge(window.innerHeight)),S=B(Ge(window.innerWidth));const z=Object.keys(v_),E=F(()=>!!e.editor&&!!e.ydoc&&d(f)),D=F(()=>n()&&!r()&&d(E)&&d(h)!==null),P=F(()=>d(m).trim());let R,H=0,Q=0;const Z=3;function $(K){const{from:ne,to:ye}=K.state.selection,ce=ne!==ye;if(y(f,ce),!ce){y(h,null),R=void 0,Q=0;return}try{const ve=K.view.coordsAtPos(ne),_e=K.view.coordsAtPos(ye),Y=SJ({start:ve,end:_e,toolbarHeight:d(x),toolbarWidth:d(_),viewportHeight:d(T),viewportWidth:d(S),previousPlacement:R});if(R=Y.placement,Q=0,d(h)&&d(h).left===Y.left&&d(h).top===Y.top)return;y(h,{left:Y.left,top:Y.top},!0)}catch{if(Q>=Z){Q=0,y(h,null),R=void 0;return}Q+=1,cancelAnimationFrame(H),H=requestAnimationFrame(()=>{K.isDestroyed||$(K)})}}me(()=>{if(!e.editor)return;const K=e.editor;function ne(){$(K)}const ye=EJ(K,ne);return ne(),()=>{cancelAnimationFrame(H),H=0,ye()}}),me(()=>{if(!e.editor||!d(h))return;const K=e.editor;let ne=0;function ye(){cancelAnimationFrame(ne),ne=requestAnimationFrame(()=>{y(T,window.innerHeight,!0),y(S,window.innerWidth,!0),$(K)})}window.addEventListener("resize",ye);let ce=!1;requestAnimationFrame(()=>{ce=!0});const ve=M1(()=>d(p),["scroll"],()=>{ce&&document.activeElement!==d(g)&&oe()});return()=>{cancelAnimationFrame(ne),window.removeEventListener("resize",ye),ve()}}),me(()=>{const K=e.editor,ne=d(p);if(!K||!ne||!d(h))return;const ye=()=>{if(document.activeElement===d(g))return;const ve=ne.getBoundingClientRect();y(x,ve.height,!0),y(_,ve.width,!0),$(K)};ye();const ce=new ResizeObserver(ye);return ce.observe(ne),()=>ce.disconnect()}),me(()=>{d(D)&&!d(v)&&ae(),d(D)||(y(v,null),document.activeElement!==d(g)&&y(m,""))});let W=0;me(()=>{if(i()===W||(W=i(),i()===0||!e.editor))return;const{from:K,to:ne}=e.editor.state.selection;K!==ne&&(St(()=>ae()),y(b,!0),requestAnimationFrame(()=>{var ye;return(ye=d(g))==null?void 0:ye.focus()}))}),me(()=>{if(!e.editor||!d(D))return;const K=e.editor,ne=()=>{document.activeElement!==d(g)&&ae()};return K.on("selectionUpdate",ne),()=>{K.isDestroyed||K.off("selectionUpdate",ne)}}),me(()=>{if(!d(D))return;function K(ne){ne.key==="Escape"&&(ne.preventDefault(),ne.stopPropagation(),oe())}return window.addEventListener("keydown",K,{capture:!0}),()=>window.removeEventListener("keydown",K,{capture:!0})});function te(K,ne,ye){if(!e.editor||!e.ydoc||K!=="highlight"&&!ne.trim())return;const ce=d(v)??e.editor.state.selection,{from:ve,to:_e}=ce;if(ve===_e)return;const Y=Vi(e.editor.state.doc,Hn(ve)),we=Vi(e.editor.state.doc,Hn(_e)),se=u0(),le={id:se,author:"user",type:K,audience:K==="highlight"||K==="note"?"private":"outbound",range:{from:Y,to:we},content:ne,status:"pending",timestamp:Date.now()};ps(e.ydoc,()=>e.ydoc.getMap(Ro).set(se,le)),y(v,null)}function ae(){if(!e.editor)return;const{from:K,to:ne}=e.editor.state.selection;y(v,{from:K,to:ne},!0)}function re(K){if(!e.editor||!e.ydoc)return;const ne=d(v)??e.editor.state.selection,{from:ye,to:ce}=ne;if(ye===ce)return;const ve=Vi(e.editor.state.doc,Hn(ye)),_e=Vi(e.editor.state.doc,Hn(ce));XA(e.ydoc,{from:ve,to:_e},K),y(v,null),e.editor.chain().setTextSelection(ce).run()}function ue(K){return ne=>{ne.detail===0&&K(ne)}}function oe(){var K;y(f,!1),y(h,null),y(v,null),y(m,""),y(b,!1),(K=e.editor)==null||K.chain().focus().run()}function fe(){y(b,!0),requestAnimationFrame(()=>{var K;return(K=d(g))==null?void 0:K.focus()})}function I(){d(P)&&(te("comment",d(P)),oe())}function O(){d(P)&&(te("note",d(P)),oe())}function A(K){K.key==="Enter"&&K.altKey?(K.preventDefault(),O()):K.key==="Enter"&&(K.metaKey||K.ctrlKey)?(K.preventDefault(),I()):K.key==="Escape"&&(K.preventDefault(),oe())}var V=kt(),L=Se(V);{var J=K=>{var ne=IJ(),ye=w(ne);{var ce=_e=>{var Y=DJ(),we=Se(Y),se=w(we);YA(se,{get editor(){return e.editor},variant:"popup"});var X=k(se,2);{var le=Ae=>{var Me=AJ(),Ze=k(Se(Me),2),ut=w(Ze);ZA(ut,{get showAuthorship(){return o()},get showComments(){return s()},get showHighlights(){return a()},get showNotes(){return l()},get decorationsMuted(){return u()},get onUpdate(){return e.onUpdateDecorations},get onOpenSettings(){return e.onOpenSettings}}),N("mousedown",Ze,it=>it.preventDefault()),C(Ae,Me)};G(X,Ae=>{e.onUpdateDecorations&&Ae(le)})}var he=k(X,2);{var De=Ae=>{var Me=TJ(),Ze=k(Se(Me),2),ut=F(()=>ue(()=>{var it;return(it=e.onShowFormattingBar)==null?void 0:it.call(e)}));N("mousedown",Ze,it=>{var pe;it.preventDefault(),(pe=e.onShowFormattingBar)==null||pe.call(e)}),N("click",Ze,function(...it){var pe;(pe=d(ut))==null||pe.apply(this,it)}),C(Ae,Me)};G(he,Ae=>{!c()&&e.onShowFormattingBar&&Ae(De)})}var Oe=k(we,4),be=w(Oe);Je(be,21,()=>z,Sl,(Ae,Me)=>{var Ze=MJ(),ut=F(()=>ue(()=>{var it;re(d(Me)),(it=e.editor)==null||it.chain().focus().run()}));q(()=>{U(Ze,"data-testid",`popup-highlight-${d(Me)}`),U(Ze,"aria-label",`Highlight ${d(Me)}`),U(Ze,"title",`Highlight ${d(Me)}`),xe(Ze,`width: 16px; height: 16px; border-radius: var(--tandem-r-2); border: 1px solid var(--tandem-border); background: ${sc[d(Me)]}; cursor: pointer; padding: 0;`)}),N("mousedown",Ze,it=>{var pe;it.preventDefault(),re(d(Me)),(pe=e.editor)==null||pe.chain().focus().run()}),N("click",Ze,function(...it){var pe;(pe=d(ut))==null||pe.apply(this,it)}),C(Ae,Ze)});var Ne=k(be,4),Qe=F(()=>ue(()=>fe()));N("mousedown",Ne,Ae=>{Ae.preventDefault(),fe()}),N("click",Ne,function(...Ae){var Me;(Me=d(Qe))==null||Me.apply(this,Ae)}),C(_e,Y)},ve=_e=>{var Y=OJ(),we=w(Y);U(we,"rows",1),xt(we,he=>y(g,he),()=>d(g));var se=k(we,2),X=w(se),le=k(X,2);q(()=>{X.disabled=!d(P),le.disabled=!d(P)}),N("keydown",we,A),Bn(we,()=>d(m),he=>y(m,he)),N("click",X,O),N("click",le,I),C(_e,Y)};G(ye,_e=>{d(b)?_e(ve,-1):_e(ce)})}xt(ne,_e=>y(p,_e),()=>d(p)),q(()=>xe(ne,`position: fixed; left: ${d(h).left}px; top: ${d(h).top}px; transform: translateX(-50%); display: flex; flex-direction: column; border-radius: var(--tandem-r-3); z-index: var(--tandem-z-modal); -webkit-app-region: no-drag;`)),C(K,ne)};G(L,K=>{d(D)&&d(h)&&K(J)})}C(t,V),Be()}We(["mousedown","click","keydown"]);function NJ(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 PJ(t){me(()=>NJ(t()))}function rf(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 QA(t,e){if(!e)return-1;for(let n=0;n<t.length;n++)if(t[n].id===e)return n;return-1}function Bk(t,e){if(t.length===0)return null;const n=QA(t,e);return n===-1?t[0].id:t[(n+1)%t.length].id}function Hk(t,e){if(t.length===0)return null;const n=QA(t,e);return n===-1?t[t.length-1].id:t[(n-1+t.length)%t.length].id}function LJ(t,e=document.documentElement){return t?e.setAttribute("data-annotation-patterns","true"):e.removeAttribute("data-annotation-patterns"),()=>e.removeAttribute("data-annotation-patterns")}function FJ(t){me(()=>LJ(t()))}function zJ(t){let e=B(Ge(new Map));return me(()=>{const n=t.getYdoc();if(!n){d(e).size>0&&y(e,new Map,!0);return}const r=n.getMap(__),i=()=>{y(e,BJ(r),!0)};return i(),r.observe(i),()=>r.unobserve(i)}),{get byId(){return d(e)}}}function BJ(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 HJ=25;function VJ(t=HJ){const e=Ge([]);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 UJ(t,e=()=>fM){let n=B(!1),r=B(!1);return me(()=>{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 jJ(t,e=document.documentElement){return e.setAttribute("data-density",t),()=>e.removeAttribute("data-density")}function qJ(t){me(()=>jJ(t()))}const fl=200,jc=600,WJ=300;function Vk(t){const e=w_[t];try{const n=localStorage.getItem(e);if(n){const r=parseInt(n,10);if(Number.isFinite(r))return Math.max(fl,Math.min(jc,r));console.warn(`[tandem] ignoring non-numeric panel width for ${e}: ${n}`)}}catch(n){console.warn(`[tandem] localStorage unavailable reading ${e}:`,n)}return WJ}function Uk(t){const{side:e}=t,n=w_[e];let r=B(Ge(t.initialWidth)),i=null;return me(()=>{!t.getVisible()&&i&&(document.removeEventListener("mousemove",i.move),document.removeEventListener("mouseup",i.up),i=null,document.body.style.userSelect="",document.body.style.cursor="")}),me(()=>()=>{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,u=d(r);let c=u;document.body.style.userSelect="none",document.body.style.cursor="col-resize";const f=p=>{const m=p.clientX-l,v=e==="left"?u+m:u-m;c=Math.max(fl,Math.min(jc,v)),y(r,c,!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(c))}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(fl,Math.min(jc,d(r)+a));if(y(r,l,!0),t.getVisible())try{localStorage.setItem(n,String(l))}catch(u){console.warn(`[tandem] failed to persist ${n}:`,u)}}}}const KJ={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 GJ(t){const e=document.documentElement;return e.style.setProperty("--tandem-editor-font-family",KJ[t]),()=>e.style.removeProperty("--tandem-editor-font-family")}function ZJ(t){me(()=>GJ(t()))}function JJ(){let t=B(!1);return{get fileDragOver(){return d(t)},handleEditorDragOver:i=>{var o;Lt()||(o=i.dataTransfer)!=null&&o.types.includes("Files")&&(i.preventDefault(),y(t,!0))},handleEditorDragLeave:i=>{Lt()||(i.currentTarget===i.target||!i.currentTarget.contains(i.relatedTarget))&&y(t,!1)},handleEditorDrop:async i=>{var a;if(Lt()||(y(t,!1),!((a=i.dataTransfer)!=null&&a.files.length)))return;i.preventDefault();const o=i.dataTransfer.files[0],s=await O_(o);try{const l=await fetch(`${qn}${p_}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({fileName:o.name,content:s})});if(!l.ok){const u=await l.json().catch(()=>({message:"Upload failed"}));console.error("[useFileDrop] Upload failed:",l.status,u.message??u.error)}}catch{console.error("[useFileDrop] Server unreachable — file drop ignored")}}}}function Rg(t){return!!(t!=null&&t.query)}function YJ(){let t=B(null),e=B(null),n=B(null),r=B(!1),i=0;async function o(){const s=++i;try{const a=await fetch($O,{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 XJ(t,e=document.documentElement){return t?e.setAttribute("data-high-contrast","true"):e.removeAttribute("data-high-contrast"),()=>e.removeAttribute("data-high-contrast")}function QJ(t){me(()=>XJ(t()))}function $J(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 u=n(l.from);if(!Number.isFinite(u.top))continue;i.set(a.id,u.top-r())}catch{s++}}}return{positions:i,attempted:o,thrown:s}}function eY(t){let e=null;return{schedule(){e===null&&(e=requestAnimationFrame(()=>{e=null,t()}))},cancel(){e!==null&&(cancelAnimationFrame(e),e=null)}}}function tY(t){let e=B(Ge(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:u,thrown:c}=$J(a,f=>Sc(f,i.state.doc,s),f=>i.view.coordsAtPos(f),()=>o.getBoundingClientRect().top);u>0&&c===u&&console.warn(`[margin] coordsAtPos threw for all ${u} annotations — view may be detached`),!nY(d(e),l)&&y(e,l,!0)}const r=eY(n);return me(()=>{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()}}),me(()=>{t.getAnnotations(),r.schedule()}),{get byId(){return d(e)}}}function nY(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 $A=h0.info,rY=250;function iY(t,e){return t.severity==="info"&&e-t.timestamp>=$A}function oY(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=>!iY(o,r)).slice(-A_)}catch(e){return console.warn("[useNotifications] failed to load activity history:",e),[]}}function sY(t={}){const e=t.persist??!0,n=t.storageKey??wM;let r=B(Ge([])),i=B(Ge(e?oY(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{}}},u=()=>{e&&(a&&clearTimeout(a),a=setTimeout(l,rY))},c=E=>{const D=o.get(E);D&&(clearTimeout(D),o.delete(E))},f=(E,D)=>{c(E);const P=h0[D]??h0.info;o.set(E,setTimeout(()=>{y(r,d(r).filter(R=>R.id!==E),!0),o.delete(E)},P))},h=E=>{if(E.dedupKey){const R=d(r).findIndex(H=>H.dedupKey===E.dedupKey);if(R!==-1){const H=d(r)[R];c(H.id);const Q={...E,count:H.count+1},Z=[...d(r)];Z[R]=Q,y(r,Z,!0),f(Q.id,Q.severity);return}}const D={...E,count:1},P=[...d(r),D];for(;P.length>yM;){const R=P.shift();c(R.id)}y(r,P,!0),f(D.id,D.severity)},p=E=>{const D=s.get(E);D&&(clearTimeout(D),s.delete(E))},m=(E,D)=>{p(E);const P=Math.max(0,$A-(Date.now()-D));s.set(E,setTimeout(()=>{s.delete(E),d(i).some(R=>R.id===E)&&(y(i,d(i).filter(R=>R.id!==E),!0),y(r,d(r).filter(R=>R.id!==E),!0),u())},P))},v=E=>{if(E.dedupKey){const R=d(i).findIndex(H=>H.dedupKey===E.dedupKey);if(R!==-1){const H=d(i)[R],Q={...E,id:H.id,count:H.count+1},Z=[...d(i)];Z[R]=Q,y(i,Z,!0),Q.severity==="info"?m(Q.id,Q.timestamp):p(Q.id),u();return}}const D={...E,count:1},P=[...d(i),D];for(;P.length>A_;)P.shift();y(i,P,!0),D.severity==="info"&&m(D.id,D.timestamp),u()},g=(E,D)=>{v(E),(E.severity!=="info"||D)&&h(E)},b=E=>{y(r,d(r).filter(D=>D.id!==E),!0),c(E)},x=E=>{y(i,d(i).filter(D=>D.id!==E),!0),p(E),u()},_=()=>{y(i,[],!0);for(const E of s.values())clearTimeout(E);s.clear(),u()};for(const E of d(i))E.severity==="info"&&m(E.id,E.timestamp);const T=E=>g(E,!0),S=`http://127.0.0.1:${Jl}${Y6}`,z=new EventSource(S);return z.onmessage=E=>{let D;try{D=JSON.parse(E.data)}catch{console.warn("[useNotifications] Malformed SSE data:",E.data);return}g(D,!1)},z.onerror=()=>{z.readyState===EventSource.CLOSED&&console.warn("[useNotifications] EventSource permanently closed. Notifications will not be delivered. Is the server running?")},lr(()=>{z.close();for(const E of o.values())clearTimeout(E);o.clear();for(const E of s.values())clearTimeout(E);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:x,clearActivity:_,push:T}}function jk(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 Ba(t){return`tandem:scratchpad:${t}`}const Ns="tandem:scratchpad:latest",qk=500;function Wk(t){const e=[],n=r=>{if(r instanceof hn)return r.toString();if(r instanceof Qt){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 Qt||i instanceof hn)&&e.push(n(i))}return e.join(`
|
|
236
|
+
`).replace(/\n+$/,"")}function bu(t){try{return localStorage.getItem(t)}catch{return null}}function of(t,e){try{localStorage.setItem(t,e)}catch{}}function yu(t){try{localStorage.removeItem(t)}catch{}}function aY(t){const e=new Map,n=Ge({}),r=()=>Object.values(n).some(Boolean),i=c=>{const f=c.ydoc.getXmlFragment("default"),h=Wk(f),p=Ba(c.uuid);if(h.length===0){yu(p),bu(Ns)===c.uuid&&yu(Ns),n[c.uuid]=!1;return}of(p,h),of(Ns,c.uuid),n[c.uuid]=!0},o=(c,f,h)=>{if(e.has(c))return;const p={uuid:c,ydoc:f,provider:h,updateHandler:()=>{},syncedHandler:null,persist:jk(()=>{},qk)};if(p.persist=jk(()=>i(p),qk),p.updateHandler=()=>p.persist(),f.on("update",p.updateHandler),e.set(c,p),h.synced)s(p);else{const m=()=>{p.syncedHandler=null,h.off("synced",m),e.get(c)===p&&s(p)};p.syncedHandler=m,h.on("synced",m)}},s=c=>{const f=c.ydoc.getXmlFragment("default");if(Wk(f).length>0)return;let h=c.uuid,p=bu(Ba(h));if(p===null&&e.size===1){const g=bu(Ns);g&&g!==c.uuid&&(p=bu(Ba(g)),h=g)}if(p===null||p.length===0)return;const v=p.split(`
|
|
237
|
+
`).map(g=>{const b=new Qt("paragraph");return g.length>0&&b.insert(0,[new hn(g)]),b});ps(c.ydoc,()=>{f.length>0&&f.delete(0,f.length),f.insert(0,v)}),of(Ba(c.uuid),p),of(Ns,c.uuid),h!==c.uuid&&yu(Ba(h)),n[c.uuid]=!0},a=c=>{const f=e.get(c);f&&(f.persist.flush(),f.ydoc.off("update",f.updateHandler),f.syncedHandler&&f.provider.off("synced",f.syncedHandler),e.delete(c))},l=c=>{var f;yu(Ba(c)),bu(Ns)===c&&yu(Ns),(f=e.get(c))==null||f.persist.cancel(),n[c]=!1},u=Wx(()=>{me(()=>{const c=t(),f=new Set;for(const h of c){if(!Gv(h.filePath))continue;const p=c_(h.filePath);p&&(f.add(p),o(p,h.ydoc,h.provider))}for(const h of[...e.keys()])f.has(h)||a(h)}),me(()=>{const c=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",c),()=>window.removeEventListener("beforeunload",c)})});return{hasUnsavedContent:c=>n[c]===!0,clearUnsaved:l,destroy:()=>{u();for(const c of[...e.keys()])a(c)}}}function lY(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 uY(t,e,n){let r=null;Zl(()=>{r=i=>{if(!i.ctrlKey&&!i.metaKey||i.key!=="Tab")return;const o=lY(t(),e(),i.shiftKey);o&&(i.preventDefault(),n(o))},window.addEventListener("keydown",r)}),lr(()=>{r&&window.removeEventListener("keydown",r)})}function cY(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 jr(t){if(t.isComposing)return!0;const e=t.target;return e?e.tagName==="INPUT"||e.tagName==="TEXTAREA":!1}function Kk(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 dY(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 u=l.indexOf(n),c=i==="right"?u+1:u;return l.splice(c,0,e),l}function fY(t){let e=B(Ge([]));me(()=>{const o=t().map(a=>a.id),s=Kk(d(e),o);(d(e).length!==s.length||d(e).some((a,l)=>a!==s[l]))&&y(e,s,!0)});const n=F(()=>{const i=t(),o=new Map(i.map(l=>[l.id,l])),s=i.map(l=>l.id);return Kk(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(u=>u.id));y(e,dY(d(e),i,o,l,s),!0)}}}function hY(t,e){let n=B(Ge((()=>{try{const r=localStorage.getItem(Md),i=K6.safeParse(r);return i.success?i.data:xy}catch(r){return console.warn(`[tandem] localStorage unavailable reading ${Md}:`,r),xy}})()));return me(()=>{const r=d(n);try{localStorage.setItem(Md,r)}catch(i){console.warn(`[tandem] failed to persist ${Md}:`,i)}}),me(()=>{const r=t(),i=d(n);if(r)try{r.getMap(c0).set(gM,i)}catch(o){console.warn("[tandem] failed to broadcast tandem mode to Y.Map:",o)}}),me(()=>{const r=t(),i=e();if(r)try{r.getMap(c0).set(vM,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 Lf=B(!1),Ng=!1,eT=()=>{};const Pg={get fileDragOver(){return d(Lf)}};function pY(t){const e=t.split(/[/\\]/).at(-1)??"",n=e.lastIndexOf(".");return n<=0?!1:id.has(e.slice(n).toLowerCase())}const mY=(()=>{const t=Array.from(id).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 sf(t,e,n){eT({id:`tauri-drop-${n}-${Date.now()}`,type:"general-error",severity:e,message:t,dedupKey:n,timestamp:Date.now()})}function gY(t){eT=t,!Ng&&Lt()&&(Ng=!0,Mn(()=>import("./webview-KiZyy_pC.js"),__vite__mapDeps([4,5,1,6])).then(async({getCurrentWebview:e})=>{await e().onDragDropEvent(n=>{try{const r=n.payload;switch(r.type){case"enter":y(Lf,!0);return;case"drop":y(Lf,!1);for(const i of r.paths)if(pY(i)){(async()=>{const o=await Po(i);o.ok||sf(`Couldn't open ${i}: ${o.error}`,"error","tauri-drop-open-failed")})();return}sf(`Tandem can only open ${mY} files`,"warning","tauri-drop-unsupported");return;case"leave":y(Lf,!1);return;default:console.warn("[useTauriFileDrop] unknown payload type:",r)}}catch(r){console.error("[useTauriFileDrop] callback threw:",r),sf("Drag-and-drop encountered an error — try the Open File dialog","error","tauri-drop-callback-error")}})}).catch(e=>{Ng=!1,console.error("[useTauriFileDrop] Failed to attach onDragDropEvent:",e),sf("Drag-and-drop unavailable — use the Open File dialog instead","warning","tauri-drop-unavailable")}))}var Qc;class vY{constructor(){tt(this,Qc,B(Ge(Lt()?window.__TANDEM_INITIAL_THEME__??null:null)))}get current(){return d(ie(this,Qc))}set current(e){y(ie(this,Qc),e,!0)}}Qc=new WeakMap;const cm=new vY;let Gk=!1;function Lg(t){cm.current=t,typeof window<"u"&&(window.__TANDEM_INITIAL_THEME__=t)}function bY(){if(Gk||!Lt())return;Gk=!0;let t=null;Mn(async()=>{const{invoke:i}=await import("./core-DhEqZVGG.js");return{invoke:i}},[]).then(({invoke:i})=>{t=i,i("get_app_theme").then(o=>{Lg(o==="dark"?"dark":"light")}).catch(o=>{console.warn("[useTauriTheme] get_app_theme failed:",o)})}).catch(i=>{console.warn("[useTauriTheme] Tauri API import failed:",i)}),Mn(async()=>{const{getCurrentWindow:i}=await import("./window-DePn7tLG.js").then(o=>o.w);return{getCurrentWindow:i}},__vite__mapDeps([5,1,6])).then(({getCurrentWindow:i})=>{i().onThemeChanged(({payload:o})=>{Lg(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";cm.current!==o&&(Lg(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 tT(){try{if(typeof window>"u")return"light";if(Lt()){const t=cm.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 yY(t){return t==="system"?tT():t}function Zk(t){try{const e=document.querySelector('meta[name="theme-color"]');e&&(e.content=t==="dark"?"#1c1c24":t==="warm"?"#f1ead9":"#fafaf9")}catch{}}function wY(t){const e=document.documentElement,n=yY(t);if(e.setAttribute("data-theme",n),Zk(n),t!=="system")return()=>e.removeAttribute("data-theme");if(Lt())return()=>e.removeAttribute("data-theme");const r=window.matchMedia("(prefers-color-scheme: dark)"),i=()=>{const o=tT();e.setAttribute("data-theme",o),Zk(o)};return r.addEventListener("change",i),()=>{r.removeEventListener("change",i),e.removeAttribute("data-theme")}}function kY(t){bY(),me(()=>{const e=t();return cm.current,wY(e)})}function xY(){try{return localStorage.getItem(T_)==="true"}catch{return!1}}function _Y(t){return t.author==="user"&&!t.id.startsWith(M_)}function Jk(){try{localStorage.setItem(T_,"true")}catch{}}function CY(t,e,n){let r=B(Ge(xY())),i=B(0),o=0;const s=EC(),a=F(()=>n()==="welcome.md"),l=F(()=>!d(r)&&d(a)),u=Lt(),c=MC(()=>u&&d(l)),f=F(()=>!u||c.status!==null||c.error!==null),h=F(()=>u&&SC(c.status,s)),p=F(()=>d(f)?d(h)?4:3:1/0);return me(()=>{if(!d(l)||d(i)!==0)return;const b=t().filter(_=>_.id.startsWith(M_));if(b.length===0)return;b.some(_=>_.status!=="pending")&&(o=Date.now(),y(i,1))}),me(()=>{if(!d(l)||d(i)!==1)return;t().some(_Y)&&(o=Date.now(),y(i,2))}),me(()=>{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)}}),me(()=>{if(!d(l)||!isFinite(d(p))||d(i)!==d(p))return;const g=setTimeout(()=>{Jk(),y(r,!0)},3e3);return()=>clearTimeout(g)}),me(()=>{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 c.status},dismissTutorial:()=>{Jk(),y(r,!0)},nextStep:()=>{o=Date.now(),y(i,Math.min(d(i)+1,d(p)),!0)}}}const SY="tandem://update-available",EY="tandem:updater-dismissed-v";function nT(t){return`${EY}${t}`}function rT(t){try{return window.localStorage.getItem(nT(t))==="1"}catch{return!1}}function AY(t){try{window.localStorage.setItem(nT(t),"1")}catch{}}let iT=B(null),lp=B(null),Ka=0,Fg=null,af=!1,zg=0;function Yk(){return Ka}function Zs(){return d(iT)}function oT(){return d(lp)}function sT(t){t&&(AY(t),y(lp,t,!0))}function aT(){if(Ka+=1,Ka===1&&Lt()){af=!1;const e=++zg;(async()=>{try{const{listen:n}=await Mn(async()=>{const{listen:i}=await import("./event-CNdo2oXa.js");return{listen:i}},__vite__mapDeps([6,1]));if(af||e!==zg||Yk()===0)return;const r=await n(SY,i=>{var s;const o=((s=i.payload)==null?void 0:s.version)??null;o&&(y(iT,o,!0),d(lp)!==o&&y(lp,null))});if(af||e!==zg||Yk()===0){r();return}Fg=r}catch(n){console.warn("[useUpdaterChannel] listen() failed:",n)}})()}let t=!1;return()=>{if(!t&&(t=!0,Ka=Math.max(0,Ka-1),Ka===0)){af=!0;const e=Fg;if(Fg=null,e)try{e()}catch(n){console.warn("[useUpdaterChannel] unlisten threw:",n)}}}}function TY(){return me(()=>aT()),{get availableVersion(){return Zs()},get showDot(){const t=Zs();return!(!t||oT()===t||rT(t))},acknowledge(){sT(Zs())}}}const Xk=3e4;function MY(){let t=B(!1),e=null;function n(){e!==null&&(clearTimeout(e),e=null)}me(()=>{const i=aT();return()=>{n(),i()}});async function r(){if(!(!Zs()||d(t))){y(t,!0),n(),e=setTimeout(()=>{e=null,y(t,!1),console.warn(`[useUpdaterBanner] install_update did not tear down WebView within ${Xk}ms; re-arming CTA`)},Xk);try{const{invoke:o}=await Mn(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 Zs()},get installing(){return d(t)},get showBanner(){const i=Zs();return!(!i||oT()===i||rT(i))},dismiss(){sT(Zs())},install:r}}function DY(){let t=B(Ge(window.innerWidth));return me(()=>{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 OY(){let t=null;Zl(()=>{let e=!1,n;Mn(async()=>{const{getCurrentWebview:r}=await import("./webview-KiZyy_pC.js");return{getCurrentWebview:r}},__vite__mapDeps([4,5,1,6])).then(({getCurrentWebview:r})=>{if(e)return;const i=r();let o=pu;try{const c=localStorage.getItem(Ty);if(c!==null){const f=Number(c);Number.isFinite(f)?o=Math.max(My,Math.min(Dy,f)):console.warn(`[tandem] ignoring invalid stored zoom: ${c}`)}}catch{}o!==pu&&i.setZoom(o).catch(c=>{console.warn("[tandem] failed to restore zoom level:",c)});function s(c){try{localStorage.setItem(Ty,String(c))}catch{}}const a=c=>{!(c.metaKey||c.ctrlKey)||c.key!=="0"||(c.preventDefault(),c.stopPropagation(),o=pu,i.setZoom(pu).catch(h=>{console.warn("[tandem] failed to reset zoom:",h)}),s(pu))},l=.1,u=c=>{if(!(c.metaKey||c.ctrlKey))return;const h=c.key==="+"||c.key==="=",p=c.key==="-"||c.key==="_";if(!h&&!p)return;const m=h?o+l:o-l;o=Math.max(My,Math.min(Dy,Math.round(m*100)/100)),s(o)};window.addEventListener("keydown",a,{capture:!0}),window.addEventListener("keydown",u,{capture:!0}),n=()=>{window.removeEventListener("keydown",a,{capture:!0}),window.removeEventListener("keydown",u,{capture:!0})}}).catch(()=>{}),t=()=>{e=!0,n==null||n()}}),lr(()=>{t==null||t()})}function IY(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 RY(t,e,n){return t.filter(r=>!e.has(r.id)&&!n.has(r.id))}function NY(){let t=B(Ge([])),e=B(null),n=B(!1),r=B("connecting"),i=B(0),o=B(null),s=B(Ge([])),a=B(null),l=B(!1),u=B(null),c=B(!1),f=B(!1),h=B(!1),p=B(!1),m=B(null),v=null,g=!1,b=null,x=null;const _=new Set,T=new Map,S=new Map,z=new Map;let E=!1;const D=re=>{const{ydoc:ue}=re,oe=ue.getMap(Ro),fe=()=>{const ve=[];oe.forEach(_e=>{ve.push(wa(_e,Y=>{console.warn("[sanitize]",Y)}))}),y(s,ve,!0)};oe.observe(fe),fe();const I=ue.getMap(x_);let O=null,A=!1,V=null;const L=ve=>ve?`${ve.tool} ${ve.annotationId??""} ${ve.token??ve.startedAt}`:null,J=()=>{const ve=I.get(d0),_e=(ve==null?void 0:ve.status)??null,Y=(ve==null?void 0:ve.active)??!1,we=(ve==null?void 0:ve.working)??null;_e!==O&&(O=_e,y(a,_e,!0)),Y!==A&&(A=Y,y(l,Y,!0));const se=L(we);se!==V&&(V=se,y(u,we,!0))};I.observe(J),J();const K=ue.getMap(bf);let ne=!1;const ye=ve=>{if(!ve.keysChanged.has(_m))return;const _e=K.get(_m)===!0;_e!==ne&&(ne=_e,y(c,_e))};K.observe(ye);const ce=K.get(_m)===!0;return ce!==ne&&(ne=ce,y(c,ce)),()=>{oe.unobserve(fe),I.unobserve(J),K.unobserve(ye)}},P=(re,ue,oe)=>{var ne,ye;const fe=d(t),I=new Set(fe.map(ce=>ce.id)),O=new Set(re.map(ce=>ce.id));for(const ce of fe)_.delete(ce.id),T.delete(ce.id);for(const[ce,ve]of T)O.has(ce)||((ne=z.get(ce))==null||ne(),z.delete(ce),ve.provider.destroy(),ve.ydoc.destroy(),T.delete(ce),_.delete(ce));const A=RY(re,I,_),V=[];for(const ce of A){_.add(ce.id);const ve=new Qi,_e=new jw({url:`ws://127.0.0.1:${ky}`,name:ce.id,document:ve});T.set(ce.id,{ydoc:ve,provider:_e});const Y=ve.getMap(bf),we=se=>{if(!se.keysChanged.has(du)&&!se.keysChanged.has(fu)&&!se.keysChanged.has(hu))return;const X=Y.get(du),le=Y.get(fu),he=Y.get(hu);X&&P(X,le??null,he??null)};Y.observe(we),z.set(ce.id,()=>Y.unobserve(we)),V.push({...ce,ydoc:ve,provider:_e})}const L=fe.filter(ce=>!O.has(ce.id));for(const ce of L){const ve=S.get(ce.id);ve&&(ve.cleanup(),S.delete(ce.id)),(ye=z.get(ce.id))==null||ye(),z.delete(ce.id),_.delete(ce.id),T.delete(ce.id),ce.provider.destroy(),ce.ydoc.destroy()}const J=new Map(re.map(ce=>[ce.id,ce])),K=fe.filter(ce=>O.has(ce.id)).map(ce=>{const ve=J.get(ce.id);return!ve||ve.fileName===ce.fileName&&ve.filePath===ce.filePath&&ve.format===ce.format&&ve.readOnly===ce.readOnly?ce:{...ce,fileName:ve.fileName,filePath:ve.filePath,format:ve.format,readOnly:ve.readOnly}});y(t,[...K,...V],!0),ue!==null&&(y(e,IY({prev:d(e),serverActiveId:ue,serverIds:O,removedCount:L.length,serverEpoch:oe,lastAppliedEpoch:x}),!0),x=oe)};let R=null,H=null;{const re=new Qi,ue=new jw({url:`ws://127.0.0.1:${ky}`,name:mM,document:re});y(m,re,!0),H=ue,ue.on("status",({status:L})=>{y(n,L==="connected"),y(r,["connected","connecting","disconnected"].includes(L)?L:"connecting",!0),L==="connected"?(g=!0,y(i,0),y(o,null)):L==="disconnected"?d(o)===null&&y(o,Date.now(),!0):L==="connecting"&&(g&&y(i,d(i)+1),d(o)===null&&y(o,Date.now(),!0))});const oe=re.getMap(bf),fe=L=>{if(L.keysChanged.has(xm)){const J=oe.get(xm);J&&b&&J!==b&&(console.warn("[Tandem] Server restarted — refreshing documents"),y(p,!0),x=null,v&&clearTimeout(v),v=setTimeout(()=>{y(p,!1)},5e3)),J&&(b=J)}if(L.keysChanged.has(du)||L.keysChanged.has(fu)||L.keysChanged.has(hu)){const J=oe.get(du),K=oe.get(fu),ne=oe.get(hu);J&&P(J,K??null,ne??null)}L.keysChanged.has(Cm)&&y(f,oe.get(Cm)===!0)};oe.observe(fe);const I=oe.get(xm);I&&(b=I);const O=oe.get(du),A=oe.get(fu),V=oe.get(hu);O&&P(O,A??null,V??null),y(f,oe.get(Cm)===!0),R=()=>{oe.unobserve(fe),v&&(clearTimeout(v),v=null),ue.destroy(),re.destroy(),y(m,null),H=null},y(h,!0)}const Q=F(()=>d(t).find(re=>re.id===d(e))??null),Z=F(()=>{var re;return((re=d(Q))==null?void 0:re.ydoc)??null}),$=Wx(()=>{me(()=>{d(Z);const re=d(Q);for(const ue of S.values())ue.cleanup();if(S.clear(),re){const ue=D(re);S.set(re.id,{cleanup:ue})}else y(s,[],!0),y(a,null),y(l,!1),y(u,null),y(c,!1)})});return{get tabs(){return d(t)},get activeTabId(){return d(e)},setActiveTabId:re=>{y(e,re,!0)},handleTabClose:re=>{if(d(e)===re){const ue=d(t),oe=ue.findIndex(I=>I.id===re),fe=ue.filter(I=>I.id!==re);fe.length===0?y(e,null):y(e,fe[Math.min(oe,fe.length-1)].id,!0)}fetch(`http://127.0.0.1:${Jl}${Q6}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({documentId:re})}).then(ue=>{ue.ok||console.warn("[Tandem] Server rejected close:",ue.status)}).catch(ue=>{console.warn("[Tandem] Failed to close document on server:",ue)})},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(u)},get readOnly(){return d(c)},get storeReadOnly(){return d(f)},get bootstrapYdoc(){return d(m)},get ready(){return d(h)},get serverRestarted(){return d(p)},destroy:()=>{if(!E){E=!0,$();for(const re of S.values())re.cleanup();S.clear();for(const re of z.values())re();z.clear();for(const re of T.values())re.provider.destroy(),re.ydoc.destroy();T.clear(),_.clear();for(const re of d(t))re.provider.destroy(),re.ydoc.destroy();R==null||R(),y(t,[],!0),y(s,[],!0),y(e,null),y(h,!1)}},reconnect(){H==null||H.connect();for(const re of d(t))re.provider.connect()}}}const Kl={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 qc(t){return t.column+t.inset+t.gap}Kl.full.column;const PY=qc(Kl.full),lT=480,LY=32;function FY(t){return 2*PY+t+lT}function zY(t){const e=t+lT;return{t1:FY(t),t2:2*qc(Kl.narrow)+e,t3:2*qc(Kl.stub)+e}}const lf={off:0,stub:1,narrow:2,full:3};function BY(t,e,n,r){const{t1:i,t2:o,t3:s}=n,a=e,l=r,u=a<s?"off":a<o?"stub":a<i?"narrow":"full",c=a>i+l?"full":a>o+l?"narrow":a>s+l?"stub":"off";return lf[t]>lf[u]?u:lf[t]<lf[c]?c:t}function HY(t,e,n){return t?e&&n==="full"?"full":"off":e?n:"off"}function Qk(t,e,n){return!e&&!n?"off":t}function VY(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 UY(t){const e=F(()=>(t.getLeftRailVisible()?t.leftRailWidthPx:0)+(t.getRightRailVisible()?t.rightRailWidthPx:0)),n=F(()=>zY(d(e)));let r=B("full");me(()=>{const v=t.getViewportWidth(),g=d(n),b=St(()=>d(r)),x=BY(b,v,g,LY);x!==b&&y(r,x,!0)});const i=F(()=>t.getFormat()==="docx"),o=F(()=>HY(d(i),t.getMarginView(),d(r))),s=F(()=>Qk(d(o),d(i),t.getLeftHasPending())),a=F(()=>Qk(d(o),d(i),t.getRightHasPending())),l=F(()=>d(s)!=="off"),u=F(()=>d(a)!=="off"),c=F(()=>d(l)||d(u)),f=F(()=>Kl[d(s)]),h=F(()=>Kl[d(a)]),p=new Set,m=F(()=>VY({isDocx:d(i),effectivelyOn:d(c),leftReservePx:qc(d(f)),rightReservePx:qc(d(h)),measure:(()=>{const v=t.getEditorMeasure(),g=$y[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??$y.comfortable})()}));return{get effectivelyOn(){return d(c)},get leftVisible(){return d(l)},get rightVisible(){return d(u)},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 jY(t,e){const n=F(()=>t.settings.leftPanelVisible),r=F(()=>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 qY(t){return t.mode==="stub"?"stub":t.isActive?"full":t.mode==="narrow"?"clamped":"full"}const WY=6;function KY(t,e={}){const n=e.gap??WY,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 GY(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}function ZY(t){const e=t.side==="right"?1:-1,n=t.startX+10*e,r=t.endX-8*e;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 JY(t){throw new Error(`unhandled annotation author: ${String(t)}`)}function YY(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 JY(t)}}var XY=Er('<path stroke-linecap="round" fill="none"></path><circle data-testid="margin-anchor-dot"></circle>',1),QY=M('<div class="margin-bubble svelte-lzz9jv"><!></div>'),$Y=M('<svg aria-hidden="true"></svg> <div></div>',1);function eX(t,e){ze(e,!0);const n=12,r=F(()=>e.side==="right"?0:e.gap),i=F(()=>e.side==="right"?e.gap:0),o=F(()=>`position: absolute; top: 0; bottom: 0; ${e.side}: ${e.edgeInset+e.width}px; width: ${e.gap}px; pointer-events: none;`),s=F(()=>e.annotations.filter(m=>e.positions.has(m.id)&&m.status==="pending"));let a=B(Ge(new Map));const l=F(()=>new Map(d(s).map(m=>[m.id,qY({mode:e.mode,isActive:m.id===e.activeAnnotationId})]))),u=F(()=>{const m=d(s).map(v=>({id:v.id,top:e.positions.get(v.id)??0,height:d(l).get(v.id)==="stub"?void 0:d(a).get(v.id)}));return KY(m)});me(()=>{const m=new Set(d(s).map(v=>v.id));St(()=>{GY(d(a),m)>0&&y(a,new Map(d(a)),!0)})});function c(m,v){if(!Number.isFinite(v)||v<=0)return;const g=d(a).get(m);if(g!==void 0&&Math.abs(g-v)<.5)return;const b=new Map(d(a));b.set(m,v),y(a,b,!0)}var f=$Y(),h=Se(f);Je(h,21,()=>d(s),m=>m.id,(m,v)=>{const g=F(()=>e.positions.get(d(v).id)),b=F(()=>d(u).get(d(v).id));var x=kt(),_=Se(x);{var T=S=>{const z=F(()=>d(v).id===e.activeAnnotationId),E=F(()=>d(b)??d(g)),D=F(()=>d(E)+n),P=F(()=>YY(d(v).author)),R=F(()=>ZY({startX:d(r),startY:d(g),endX:d(i),endY:d(D),side:e.side}));var H=XY(),Q=Se(H),Z=k(Q);q(()=>{U(Q,"data-annotation-id",d(v).id),U(Q,"data-tandem-author",d(v).author),U(Q,"d",d(R)),U(Q,"stroke",d(P)),U(Q,"stroke-width",d(z)?1.8:1.1),U(Q,"stroke-opacity",d(z)?.82:.38),U(Z,"data-annotation-id",d(v).id),U(Z,"data-tandem-author",d(v).author),U(Z,"cx",d(r)),U(Z,"cy",d(g)),U(Z,"r",d(z)?3:2),U(Z,"fill",d(P)),U(Z,"fill-opacity",d(z)?.72:.42)}),C(S,H)};G(_,S=>{d(g)!==void 0&&S(T)})}C(m,x)});var p=k(h,2);Je(p,21,()=>d(s),m=>m.id,(m,v)=>{const g=F(()=>d(u).get(d(v).id)??e.positions.get(d(v).id)??0),b=F(()=>Up(d(v),e.repliesById.get(d(v).id))),x=F(()=>d(l).get(d(v).id)??"full");var _=QY(),T=w(_);{let S=F(()=>d(v).id===e.activeAnnotationId),z=F(()=>d(v).author!=="user"?e.onAccept:void 0),E=F(()=>d(v).author!=="user"?e.onDismiss:void 0),D=F(()=>d(v).author==="user"?e.onRemove:void 0),P=F(()=>d(v).type==="note"?e.onSendToClaude:void 0);V0(T,{get annotation(){return d(v)},get replies(){return d(b)},get isReviewTarget(){return d(S)},get density(){return d(x)},onClick:()=>e.onClick(d(v)),get onAccept(){return d(z)},get onDismiss(){return d(E)},get onRemove(){return d(D)},get onSendToClaude(){return d(P)},get onEdit(){return e.onEdit},get onReply(){return e.onReply}})}q(()=>{U(_,"data-testid",`margin-bubble-${d(v).id??""}`),U(_,"data-margin-bubble-reply-count",d(b).length),xe(_,`position: absolute; top: ${d(g)??""}px; ${e.side??""}: 0; width: ${e.width??""}px; pointer-events: auto;`)}),d6(_,"clientHeight",S=>c(d(v).id,S)),C(m,_)}),q(()=>{U(h,"data-testid",`margin-leaders-${e.side??""}`),xe(h,d(o)),U(p,"data-testid",`margin-column-${e.side??""}`),U(p,"aria-label",e.side==="left"?"Note bubbles":"Comment bubbles"),xe(p,`position: absolute; top: 0; ${e.side??""}: ${e.edgeInset??""}px; width: ${e.width??""}px; pointer-events: none;`)}),C(t,f),Be()}function $k(t){return t.type==="note"}function ex(t){return t.author==="import"||t.type==="comment"}var tX=M('<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),nX=M("<span></span>"),rX=M('<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 tx(t,e){ze(e,!0);const n=je(e,"annotations",19,()=>[]),r=F(()=>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=rX(),a=w(s),l=w(a),u=k(a,2),c=w(u);{var f=v=>{var g=tX();C(v,g)},h=v=>{var g=kt(),b=Se(g);Je(b,17,n,x=>x.id,(x,_)=>{var T=nX();q(S=>At(T,1,`peek-dot ${S??""}`,"svelte-1mwvi22"),[()=>i(d(_))]),C(x,T)}),C(v,g)};G(c,v=>{e.kind==="outline"?v(f):v(h,-1)})}var p=k(u,2),m=w(p);q(()=>{At(s,1,`peek-strip peek-strip-${e.side??""}`,"svelte-1mwvi22"),U(s,"data-testid",`peek-strip-${e.side}`),U(s,"aria-label",e.side==="left"?"Show left panel":"Show right panel"),U(s,"aria-expanded",!e.collapsed),xe(s,e.collapsed?"":"display: none;"),ee(l,e.side==="left"?"›":"‹"),ee(m,d(r))}),N("click",s,function(...v){var g;(g=e.onActivate)==null||g.apply(this,v)}),N("keydown",s,o),C(t,s),Be()}We(["click","keydown"]);const nx=t=>{console.warn("[sanitize]",t)};function iX(t,e,n){if(t.suggestedText===void 0)return!1;const r=t.suggestedText,i=Sc(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 oX({getYdoc:t,getEditor:e,getAnnotations:n,onActiveAnnotationChange:r,getScrollBehavior:i,getActiveAnnotationId:o}){let s=B(0),a=B(Ge(new Set));const l=new Map;lr(()=>{for(const b of l.values())clearTimeout(b);l.clear()});function u(){return n().filter(Gf)}function c(b,x){const _=t();if(!_)return;const T=_.getMap(Ro),S=T.get(b);if(!S||S.status!=="pending")return;const z=wa(S,nx);if(T.set(b,{...z,status:x}),x==="accepted"&&z.suggestedText!==void 0){const E=e();if(E&&!iX(z,E,_)){T.set(b,{...z,status:"pending"});return}}y(a,new Set(d(a)).add(b),!0)}function f(b){const x=l.get(b);x&&clearTimeout(x),l.set(b,setTimeout(()=>{l.delete(b);const _=new Set(d(a));_.delete(b),y(a,_,!0)},3e3))}function h(b){const x=l.get(b);x&&(clearTimeout(x),l.delete(b));const _=new Set(d(a));_.delete(b),y(a,_,!0)}function p(b){const x=t();if(!x)return!1;const _=x.getMap(Ro),T=_.get(b);if(!T||T.status==="pending")return h(b),!1;const S=wa(T,nx),z=e();if(S.status==="accepted"&&S.suggestedText!==void 0&&z)try{const E=S.suggestedText,D=S.textSnapshot;if(typeof E=="string"&&typeof D=="string"){const P=Sc(S,z.state.doc,x);if(!P)return console.warn(`[undo] Cannot resolve range for annotation ${b}, skipping`),f(b),!1;if(z.state.doc.textBetween(P.from,P.to)!==E)return console.warn(`[undo] Text changed since accept for annotation ${b}, skipping`),f(b),!1;z.chain().focus().deleteRange({from:P.from,to:P.to}).insertContentAt(P.from,D).run()}}catch(E){return console.warn(`[undo] Failed to revert text for annotation ${b}:`,E),f(b),!1}return _.set(b,{...S,status:"pending"}),h(b),!0}function m(b){c(b,"accepted")}function v(b){c(b,"dismissed")}function g(b){const x=e();if(!x)return;const _=Sc(b,x.state.doc,t());if(!_)return;x.chain().focus().setTextSelection({from:_.from,to:_.to}).run();const T=x.view.domAtPos(_.from),S=T.node instanceof HTMLElement?T.node:T.node.parentElement;S==null||S.scrollIntoView({behavior:i(),block:"center"})}return me(()=>{var _;const b=(o==null?void 0:o())??null;if(b===null)return;if(!n().some(T=>T.id===b&&T.status==="pending")){const T=u();r(((_=T[d(s)])==null?void 0:_.id)??null)}}),me(()=>{const b=u();d(s)>=b.length&&y(s,Math.max(0,b.length-1),!0)}),{resolveAnnotation:c,undoResolveAnnotation:p,handleAccept:m,handleDismiss:v,scrollToAnnotation:g,getRecentlyResolved:()=>d(a),getReviewIndex:()=>d(s),getReviewTargets:u}}var sX=M('<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>'),aX=M('<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>'),lX=M('<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 uX(t,e){ze(e,!0);const n=[{value:"yellow",label:"Yellow"},{value:"green",label:"Green"},{value:"blue",label:"Blue"},{value:"pink",label:"Pink"}],r=je(e,"disabled",3,!1);let i=B("yellow"),o=B(!1),s=B(null);me(()=>{if(d(o))return M1(()=>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 u(g){y(i,g,!0),y(o,!1)}var c=lX(),f=w(c);gr(f,{label:"Highlight",testId:"toolbar-highlight-btn",get disabled(){return r()},disabledTitle:"Select text first",onMouseDown:a});var h=k(f,2),p=w(h),m=k(h,2);{var v=g=>{var b=aX(),x=w(b);Je(x,17,()=>n,({value:T,label:S})=>T,(T,S)=>{let z=()=>d(S).value,E=()=>d(S).label;var D=sX();let P;var R=w(D);q(()=>{U(D,"data-testid",`toolbar-highlight-color-${z()}`),U(D,"title",E()),U(D,"aria-label",E()),P=At(D,1,"highlight-picker-swatch svelte-1d240y8",null,P,{"is-selected":z()===d(i)}),xe(R,`background: ${sc[z()]??""};`)}),N("click",D,()=>u(z())),C(T,D)});var _=k(x,2);xt(b,T=>y(s,T),()=>d(s)),N("click",_,()=>y(o,!1)),C(g,b)};G(m,g=>{d(o)&&g(v)})}q(()=>{h.disabled=r(),xe(p,`background: ${sc[d(i)]??""};`)}),N("mousedown",h,l),C(t,c),Be()}We(["mousedown","click"]);var cX=M('<div class="fmtbar-divider svelte-1lcxsnm"></div> <!>',1),dX=M('<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),fX=M('<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 hX(t,e){ze(e,!0);const n=je(e,"showAuthorship",3,!0),r=je(e,"showComments",3,!0),i=je(e,"showHighlights",3,!0),o=je(e,"showNotes",3,!0),s=je(e,"decorationsMuted",3,!1);let a=B(0);me(()=>{const _=e.editor;if(!_||_.isDestroyed)return;const T=()=>{_.isDestroyed||tc(a)};return _.on("selectionUpdate",T),_.on("transaction",T),()=>{_.off("selectionUpdate",T),_.off("transaction",T)}});const l=F(()=>(d(a),!e.editor||e.editor.isDestroyed||!e.ydoc?!1:!e.editor.state.selection.empty));function u(_){if(!e.editor||!e.ydoc||e.editor.isDestroyed)return;const{state:T}=e.editor,{from:S,to:z}=T.selection;if(S===z)return;const E=Vi(T.doc,Hn(S)),D=Vi(T.doc,Hn(z));if(E===null||D===null){console.warn("[FormattingBar] pmPosToFlatOffset returned null — CRDT position may be degraded",{from:S,to:z});return}XA(e.ydoc,{from:E,to:D},_)}var c=fX(),f=w(c),h=w(f),p=w(h);YA(p,{get editor(){return e.editor}});var m=k(p,4);{let _=F(()=>!d(l));uX(m,{get disabled(){return d(_)},onHighlight:u})}var v=k(h,2);{var g=_=>{var T=cX(),S=k(Se(T),2);ZA(S,{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}}),C(_,T)};G(v,_=>{e.onUpdateDecorations&&_(g)})}var b=k(v,2);{var x=_=>{var T=dX(),S=k(Se(T),2);N("click",S,function(...z){var E;(E=e.onHide)==null||E.apply(this,z)}),C(_,T)};G(b,_=>{e.onHide&&_(x)})}C(t,c),Be()}We(["click"]);var pX=M('<div data-testid="mode-toggle" data-tauri-drag-region="false" class="mode-toggle svelte-14q5edy" role="group" aria-label="AI collaboration mode"><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 mX(t,e){ze(e,!0);var n=pX(),r=w(n),i=k(r,2);q(()=>{At(r,1,n0(e.tandemMode==="solo"?"on":""),"svelte-14q5edy"),U(r,"aria-pressed",e.tandemMode==="solo"),At(i,1,n0(e.tandemMode==="tandem"?"on":""),"svelte-14q5edy"),U(i,"aria-pressed",e.tandemMode==="tandem")}),N("click",r,()=>e.onModeChange("solo")),N("click",i,()=>e.onModeChange("tandem")),C(t,n),Be()}We(["click"]);const gX=[{value:"system",label:"Match system"},{value:"light",label:"Light"},{value:"dark",label:"Dark"},{value:"warm",label:"Warm"}];var vX=M('<span class="titlebar-settings-dot svelte-12l7ydf" data-testid="titlebar-update-available-dot" aria-hidden="true"></span>'),bX=M('<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>'),yX=M('<div class="brand-menu-divider svelte-12l7ydf" role="separator"></div>'),wX=M('<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),kX=M('<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>'),xX=M('<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>'),_X=M('<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>'),CX=M('<div class="title-bar-center svelte-12l7ydf" data-tauri-drag-region="false"><!></div>'),SX=M('<span class="status-dot svelte-12l7ydf" data-tauri-drag-region="false" title="AI assistant is connected" aria-label="AI assistant is connected"></span>'),EX=M('<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>'),AX=Er('<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>'),TX=Er('<svg width="10" height="10" viewBox="0 0 10 10" aria-hidden="true" focusable="false"><path d="M0 0H10V10H0V0ZM1 2V9H9V2H1Z" fill="currentColor"></path></svg>'),MX=M('<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),DX=M('<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 OX(t,e){ze(e,!0);let n=je(e,"claudeActive",3,!1),r=je(e,"theme",3,"system"),i=je(e,"settingsBtn",15,null),o=je(e,"updateAvailable",3,!1),s=je(e,"defaultModelLabel",3,null),a=B(null),l=B(!1),u=[],c=!0;Zl(async()=>{if(Lt())try{const[{invoke:L},{getCurrentWindow:J}]=await Promise.all([Mn(()=>import("./core-DhEqZVGG.js"),[]),Mn(()=>import("./window-DePn7tLG.js").then(ce=>ce.w),__vite__mapDeps([5,1,6]))]);if(!c||(await L("setup_overlay_titlebar").catch(ce=>{console.error("[TitleBar] setup_overlay_titlebar failed:",ce)}),!c))return;const K=J();if(y(a,K,!0),y(l,await K.isMaximized(),!0),!c)return;const ne=await K.onResized(async()=>{try{y(l,await K.isMaximized(),!0)}catch(ce){console.warn("[TitleBar] isMaximized check failed on resize:",ce)}});if(!c){ne();return}u.push(ne);const ye=await K.onMoved(async()=>{try{y(l,await K.isMaximized(),!0)}catch(ce){console.warn("[TitleBar] isMaximized check failed on move:",ce)}});if(!c){ye();return}u.push(ye)}catch(L){console.error("[TitleBar] Window API initialization failed:",L)}}),lr(()=>{c=!1,u.forEach(L=>L())});async function f(){var L;try{await((L=d(a))==null?void 0:L.minimize())}catch(J){console.error("[TitleBar] minimize failed:",J)}}async function h(){var L;try{await((L=d(a))==null?void 0:L.toggleMaximize())}catch(J){console.error("[TitleBar] toggleMaximize failed:",J)}}async function p(){var L;try{await((L=d(a))==null?void 0:L.close())}catch(J){console.error("[TitleBar] close failed:",J)}}let m=B(!1),v=B(null);me(()=>{if(d(m))return M1(()=>d(v)??i(),["mousedown"],()=>{y(m,!1)})});function g(){y(m,!d(m))}function b(){var L;y(m,!1),(L=i())==null||L.focus()}function x(L){L.key==="Escape"&&(L.stopPropagation(),b())}function _(L){var J;(J=e.onSetTheme)==null||J.call(e,L),b()}function T(){var L;(L=e.onOpenSettings)==null||L.call(e),y(m,!1)}function S(){var L;(L=e.onOpenHelp)==null||L.call(e),y(m,!1)}var z=DX(),E=w(z),D=w(E),P=k(w(D),2);{var R=L=>{var J=vX();C(L,J)},H=F(()=>Lt()&&o());G(P,L=>{d(H)&&L(R)})}xt(D,L=>i(L),()=>i());var Q=k(D,2);{var Z=L=>{var J=_X(),K=w(J);{var ne=Y=>{var we=wX(),se=k(Se(we),2);Je(se,21,()=>gX,he=>he.value,(he,De)=>{var Oe=bX();let be;var Ne=k(w(Oe),2),Qe=w(Ne);q(()=>{be=At(Oe,1,"brand-theme-sw svelte-12l7ydf",null,be,{on:r()===d(De).value}),U(Oe,"data-testid",`brand-menu-theme-${d(De).value??""}`),U(Oe,"data-theme-swatch",d(De).value),U(Oe,"aria-checked",r()===d(De).value),ee(Qe,d(De).label)}),N("click",Oe,()=>_(d(De).value)),C(he,Oe)});var X=k(se,2);{var le=he=>{var De=yX();C(he,De)};G(X,he=>{(e.onOpenSettings||e.onOpenHelp)&&he(le)})}C(Y,we)};G(K,Y=>{e.onSetTheme&&Y(ne)})}var ye=k(K,2);{var ce=Y=>{var we=kX();N("click",we,T),C(Y,we)};G(ye,Y=>{e.onOpenSettings&&Y(ce)})}var ve=k(ye,2);{var _e=Y=>{var we=xX();N("click",we,S),C(Y,we)};G(ve,Y=>{e.onOpenHelp&&Y(_e)})}xt(J,Y=>y(v,Y),()=>d(v)),N("keydown",J,x),C(L,J)};G(Q,L=>{d(m)&&L(Z)})}var $=k(E,4);{var W=L=>{var J=CX(),K=w(J);rd(K,()=>e.center),C(L,J)};G($,L=>{e.center&&L(W)})}var te=k($,4),ae=w(te);{var re=L=>{mX(L,{get tandemMode(){return e.tandemMode},get onModeChange(){return e.onModeChange}})};G(ae,L=>{e.tandemMode&&e.onModeChange&&L(re)})}var ue=k(ae,2);{var oe=L=>{var J=SX();C(L,J)};G(ue,L=>{n()&&L(oe)})}var fe=k(ue,2);{var I=L=>{var J=EX(),K=k(w(J),2),ne=w(K);q(()=>{U(J,"aria-label",`Default model: ${s()}. Open Settings → Models.`),U(J,"title",`Default model: ${s()}`),ee(ne,s())}),N("click",J,function(...ye){var ce;(ce=e.onOpenModelsSettings)==null||ce.apply(this,ye)}),C(L,J)};G(fe,L=>{s()&&e.onOpenModelsSettings&&L(I)})}var O=k(te,2);{var A=L=>{var J=MX(),K=k(Se(J),2),ne=w(K),ye=k(ne,2),ce=w(ye);{var ve=we=>{var se=AX();C(we,se)},_e=we=>{var se=TX();C(we,se)};G(ce,we=>{d(l)?we(ve):we(_e,-1)})}var Y=k(ye,2);q(()=>{ne.disabled=d(a)===null,U(ye,"aria-label",d(l)?"Restore":"Maximize"),ye.disabled=d(a)===null,Y.disabled=d(a)===null}),N("click",ne,f),N("click",ye,h),N("click",Y,p),C(L,J)},V=F(()=>Lt());G(O,L=>{d(V)&&L(A)})}q(()=>U(D,"aria-expanded",d(m))),N("click",D,g),C(t,z),Be()}We(["click","keydown"]);const uT="tandem-status-count-mode",Ff=["words","characters","sentences","paragraphs","pages"],IX={words:"words",characters:"chars",sentences:"sentences",paragraphs:"paragraphs",pages:"pages"},RX=250;function rx(t){const e=t.trim();return e?e.split(/\s+/).length:0}function ix(t){const e=Ff.indexOf(t);return Ff[(e+1)%Ff.length]??"words"}function Bg(t){return IX[t]}function NX(){try{const t=localStorage.getItem(uT);if(t&&Ff.includes(t))return t}catch{}return"words"}function PX(t){try{localStorage.setItem(uT,t)}catch{}}function LX(t,e){if(!t||t.isDestroyed)return 0;const n=t.state.doc.textContent;switch(e){case"characters":return n.length;case"words":return rx(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(rx(n)/RX)}}var FX=M('<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>'),zX=M('<span data-testid="save-indicator" style="color: var(--tandem-accent);" class="svelte-1esxubl">Saving...</span>'),BX=M('<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>'),HX=M('<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>'),VX=M('<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 UX(t,e){ze(e,!0);let n=je(e,"claudeWorkingTool",3,null),r=je(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=Fb();let a=B(Ge(s.userName)),l=B(void 0);me(()=>{const O=s.userName;d(a)!==O&&document.activeElement!==d(l)&&y(a,O,!0)});let u=B(!1),c=B(0),f=St(()=>e.connected);me(()=>{const O=f;if(f=e.connected,e.connected&&!O){y(u,!0);const A=setTimeout(()=>{y(u,!1)},o);return()=>clearTimeout(A)}}),me(()=>{if(e.disconnectedSince==null){y(c,0);return}y(c,Math.floor((Date.now()-e.disconnectedSince)/1e3),!0);const O=setInterval(()=>{y(c,Math.floor((Date.now()-(e.disconnectedSince??0))/1e3),!0)},1e3);return()=>clearInterval(O)});const h=F(()=>e.connectionStatus==="connecting"),p=F(()=>e.connected?"var(--tandem-success)":d(h)?"var(--tandem-warning)":"var(--tandem-error)"),m=F(()=>d(u)?"Reconnected":e.connectionStatus==="connected"?"Connected":e.connectionStatus==="connecting"?(()=>{const O=["Reconnecting…"];if(e.reconnectAttempts>0||d(c)>0){const A=[];e.reconnectAttempts>0&&A.push(`attempt ${e.reconnectAttempts}`),d(c)>0&&A.push(`${d(c)}s`),O.push(`(${A.join(", ")})`)}return O.join(" ")})():"Disconnected — check that the server is running");function v(){s.setUserName(d(a))}let g=B(Ge(NX())),b=B(0);me(()=>{const O=e.editor;if(!O||O.isDestroyed)return;const A=()=>{O.isDestroyed||tc(b)};return O.on("update",A),O.on("transaction",A),()=>{O.off("update",A),O.off("transaction",A)}});const x=F(()=>(d(b),LX(e.editor??null,d(g))));function _(){const O=ix(d(g));y(g,O,!0),PX(O)}var T=VX(),S=w(T),z=w(S),E=k(z,2),D=w(E),P=k(E,2);{var R=O=>{var A=FX(),V=w(A);q((L,J,K,ne)=>{U(A,"title",L),U(A,"aria-label",J),ee(V,`${K??""} ${ne??""}`)},[()=>`Click to cycle: ${Bg(ix(d(g)))}`,()=>`${d(x)} ${Bg(d(g))} (click to change unit)`,()=>d(x).toLocaleString(),()=>Bg(d(g))]),N("click",A,_),C(O,A)};G(P,O=>{e.editor&&O(R)})}var H=k(P,2);{var Q=O=>{var A=zX();C(O,A)};G(H,O=>{r()&&O(Q)})}var Z=k(S,2),$=k(w(Z),2);xt($,O=>y(l,O),()=>d(l));var W=k(Z,2);{var te=O=>{var A=BX();C(O,A)};G(W,O=>{e.readOnly&&O(te)})}var ae=k(W,2),re=w(ae),ue=k(re,2),oe=w(ue),fe=k(ue,2);{var I=O=>{var A=HX(),V=k(w(A),6),L=w(V);q(J=>ee(L,`Claude is ${J??""}…`),[()=>i(n())]),C(O,A)};G(fe,O=>{n()&&O(I)})}q(()=>{xe(z,`width: 7px; height: 7px; border-radius: 50%; background: ${d(p)??""}; display: inline-block; animation: ${d(h)?"tandem-reconnect-pulse 1.2s ease-in-out infinite":"none"};`),ee(D,d(m)),xr($,d(a)),U($,"maxlength",xp),xe(re,`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"};`),xe(ue,`transition: color 0.3s ease; color: ${e.claudeActive?"var(--tandem-fg)":"var(--tandem-fg-subtle)"};`),ee(oe,e.claudeStatus?`Claude · ${e.claudeStatus}`:"Claude · idle")}),N("input",$,O=>{y(a,O.target.value,!0)}),rn("blur",$,v),N("keydown",$,O=>{O.key==="Enter"&&O.currentTarget.blur(),O.key==="Escape"&&(y(a,s.userName,!0),O.currentTarget.blur())}),C(t,T),Be()}We(["click","input","keydown"]);const jX={md:"md",markdown:"md",docx:"docx",doc:"docx",txt:"txt",text:"txt",html:"html",htm:"html"};function qX(t){const e=t.lastIndexOf(".");return e<=0||e===t.length-1?"other":jX[t.slice(e+1).toLowerCase()]??"other"}function WX(t){const e=t.split(/[/\\]/);return{name:e.at(-1)??t,dir:e.slice(0,-1).join("/")}}function KX(t,e=Date.now()){const{dir:n,name:r}=WX(t.path);return{path:t.path,name:r,dir:n,when:FO(t.openedAt,e),pip:qX(r)}}function GX(t,e){const n=e.trim().toLowerCase();return n?t.name.toLowerCase().includes(n)||t.dir.toLowerCase().includes(n):!0}function ZX(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 JX=Er("<path></path>"),YX=Er('<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"></svg>'),XX=M('<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>'),QX=M('<span class="ntl-count svelte-7c4il0" aria-hidden="true"> </span>'),$X=M(`<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>`),eQ=M('<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>'),tQ=M('<mark class="svelte-7c4il0"> </mark>'),nQ=M('<span class="ntl-path svelte-7c4il0"> </span>'),rQ=M('<span class="ntl-when svelte-7c4il0"> </span>'),iQ=M('<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>'),oQ=M('<div class="ntl-recents svelte-7c4il0"></div>'),sQ=M('<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>'),aQ=M('<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 lQ(t,e){ze(e,!0);const n=(A,V=yr,L=yr,J=yr)=>{var K=YX();Je(K,21,()=>c[V()]??[],Sl,(ne,ye)=>{var ce=JX();q(()=>U(ce,"d",d(ye))),C(ne,ce)}),q(()=>{U(K,"width",L()),U(K,"height",L()),U(K,"stroke-width",J())}),C(A,K)};let r=B(""),i=B(null),o=B(null);const s=F(()=>e.recentFiles.map(A=>KX(A))),a=F(()=>d(s).filter(A=>GX(A,d(r)))),l=F(()=>d(s).length>0),u=F(()=>d(r).trim().length>0),c={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 A;return Array.from(((A=d(i))==null?void 0:A.querySelectorAll("[data-nav-item]"))??[])}function h(A){var J,K;const V=f();if(V.length===0)return;const L=V.indexOf(document.activeElement);if(L===-1){(J=A>0?V[0]:V[V.length-1])==null||J.focus();return}(K=V[(L+A+V.length)%V.length])==null||K.focus()}function p(A){A.key==="Escape"?(A.preventDefault(),e.onClose()):A.key==="ArrowDown"?(A.preventDefault(),h(1)):A.key==="ArrowUp"&&(A.preventDefault(),h(-1))}function m(A){var L;const V=A.target;V&&((L=e.anchorEl)!=null&&L.contains(V)||JA(V)||e.onClose())}function v(){if(!d(i))return;if(!e.anchorEl){d(i).style.top="8px",d(i).style.left="8px",d(i).style.right="auto";return}const A=e.anchorEl.getBoundingClientRect(),V=d(i).offsetWidth,L=window.innerWidth;A.left+V>L-8?(d(i).style.right="8px",d(i).style.left="auto"):(d(i).style.left=`${A.left}px`,d(i).style.right="auto"),d(i).style.top=`${A.bottom+4}px`}me(()=>{var A;d(i)&&(v(),(A=d(o))==null||A.focus())});var g=aQ(),b=w(g),x=w(b),_=w(x);n(_,()=>"search",()=>13,()=>1.7);var T=k(x,2);xt(T,A=>y(o,A),()=>d(o));var S=k(T,2);{var z=A=>{var V=XX();N("click",V,()=>y(r,"")),C(A,V)};G(S,A=>{d(u)&&A(z)})}var E=k(S,2);{var D=A=>{var V=QX(),L=w(V);q(()=>ee(L,`${d(a).length??""} of ${d(s).length??""}`)),C(A,V)};G(E,A=>{d(l)&&A(D)})}var P=k(b,2),R=w(P),H=w(R);{var Q=A=>{var V=$X(),L=w(V),J=w(L);n(J,()=>"inbox",()=>16,()=>1.6),C(A,V)},Z=A=>{var V=eQ(),L=w(V);q(J=>ee(L,`No matches for “${J??""}”. `),[()=>d(r).trim()]),C(A,V)},$=A=>{var V=oQ();Je(V,23,()=>d(a),L=>L.path,(L,J,K)=>{var ne=iQ(),ye=w(ne),ce=k(ye,2),ve=w(ce);Je(ve,21,()=>ZX(d(J).name,d(r)),Sl,(X,le)=>{var he=kt(),De=Se(he);{var Oe=Ne=>{var Qe=tQ(),Ae=w(Qe);q(()=>ee(Ae,d(le).text)),C(Ne,Qe)},be=Ne=>{var Qe=or();q(()=>ee(Qe,d(le).text)),C(Ne,Qe)};G(De,Ne=>{d(le).match?Ne(Oe):Ne(be,-1)})}C(X,he)});var _e=k(ve,2);{var Y=X=>{var le=nQ(),he=w(le);q(()=>ee(he,d(J).dir)),C(X,le)};G(_e,X=>{d(J).dir&&X(Y)})}var we=k(ce,2);{var se=X=>{var le=rQ(),he=w(le);q(()=>ee(he,d(J).when)),C(X,le)};G(we,X=>{d(J).when&&X(se)})}q(()=>{U(ne,"data-testid",`new-tab-recent-${d(K)}`),U(ne,"title",d(J).path),At(ye,1,`ntl-pip ntl-pip-${d(J).pip??""}`,"svelte-7c4il0")}),N("click",ne,()=>e.onOpen(d(J).path)),C(L,ne)}),C(A,V)};G(H,A=>{d(l)?d(a).length===0?A(Z,1):A($,-1):A(Q)})}var W=k(R,2),te=k(w(W),2),ae=w(te),re=w(ae);n(re,()=>"plus",()=>14,()=>1.9);var ue=k(te,4),oe=w(ue),fe=w(oe);n(fe,()=>"folder",()=>13,()=>1.7);var I=k(ue,2);{var O=A=>{var V=sQ(),L=w(V),J=w(L);n(J,()=>"undo",()=>13,()=>1.7),q(()=>U(V,"title",e.closedTabTop.filePath)),N("click",V,function(...K){var ne;(ne=e.onReopenClosed)==null||ne.apply(this,K)}),C(A,V)};G(I,A=>{e.closedTabTop&&A(O)})}cr(g,A=>sl==null?void 0:sl(A)),cr(g,(A,V)=>Xr==null?void 0:Xr(A,V),()=>m),xt(g,A=>y(i,A),()=>d(i)),N("keydown",g,p),Bn(T,()=>d(r),A=>y(r,A)),N("click",te,function(...A){var V;(V=e.onNewScratchpad)==null||V.apply(this,A)}),N("click",ue,function(...A){var V;(V=e.onBrowse)==null||V.apply(this,A)}),C(t,g),Be()}We(["keydown","click"]);var uQ=M('<span class="tab-ro-badge svelte-1btt0ja" aria-label="Read-only">RO</span>'),cQ=M('<div role="tab"><span>●</span> <span> </span> <!> <button style="background: none; border: none; cursor: pointer; font-size: var(--tandem-text-md); line-height: 1; color: var(--tandem-fg-muted); padding: 0 2px; border-radius: var(--tandem-r-1);" title="Close document">×</button></div>');function dQ(t,e){ze(e,!0);let n=B(!1),r=null;me(()=>{const{ydoc:v,readOnly:g}=e.tab;if(g){y(n,!1);return}const b=v.getXmlFragment("default"),x=v.getMap(bf);let _=!1;const T=setTimeout(()=>{_=!0,r=x.get(Cy)??0,y(n,!1)},500),S=()=>{_&&y(n,!0)};b.observeDeep(S);const z=()=>{if(!_)return;const E=x.get(Cy);E!==void 0&&E!==r&&(r=E,y(n,!1))};return x.observe(z),()=>{clearTimeout(T),b.unobserveDeep(S),x.unobserve(z)}});const i=F(()=>["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 o=B(void 0);function s(){d(o)&&(d(o).style.color="var(--tandem-error)")}function a(){d(o)&&(d(o).style.color="var(--tandem-fg-muted)")}var l=cQ();U(l,"tabindex",0);var u=w(l),c=k(u,2),f=w(c),h=k(c,2);{var p=v=>{var g=uQ();C(v,g)};G(h,v=>{e.tab.readOnly&&v(p)})}var m=k(h,2);xt(m,v=>y(o,v),()=>d(o)),q(()=>{U(l,"data-testid",`tab-${e.tab.id}`),U(l,"data-active",e.isActive),U(l,"aria-selected",e.isActive),U(l,"aria-label",e.tab.fileName),xe(l,d(i)),U(u,"data-testid",`unsaved-indicator-${e.tab.id}`),xe(u,`color: var(--tandem-warning); font-size: 10px; visibility: ${d(n)?"visible":"hidden"};`),U(u,"aria-hidden",!d(n)),U(c,"data-testid",`tab-name-${e.tab.id}`),U(c,"title",e.tab.filePath),xe(c,`font-weight: ${e.isActive?500:400}; min-width: 80px; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;`),ee(f,e.tab.fileName),U(m,"aria-label",`Close ${e.tab.fileName}`)}),N("click",l,()=>e.onswitch(e.tab.id)),N("pointerdown",l,v=>e.onpointerdown(v,e.tab.id)),N("keydown",l,v=>e.onkeydown(v,e.tab.id)),N("click",m,v=>{v.stopPropagation(),e.onclose(e.tab.id)}),N("pointerdown",m,v=>v.stopPropagation()),rn("mouseenter",m,s),rn("mouseleave",m,a),C(t,l),Be()}We(["click","pointerdown","keydown"]);var fQ=M('<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> <button data-testid="open-file-btn" class="tandem-floating-pill tab-add-pill svelte-urrc8n" title="Open file" aria-label="Open file">+</button> <!></div>');function hQ(t,e){ze(e,!0);const n=je(e,"reduceMotion",3,!1),r=je(e,"closedTabTop",3,null),i=F(()=>n()?"auto":"smooth");let o=B(!1),s=B(Ge([])),a=B(null),l=new Set;me(()=>{const I=new Set(e.tabs.map(O=>O.id));for(const O of l)I.has(O)||l.delete(O)});function u(I){l.has(I)||(l.add(I),e.onTabClose(I))}let c=B(void 0),f=B(!1),h=B(!1),p=B(null),m=B(null),v=null,g=0,b=0,x=!1,_=null;const T=5;function S(I){Z(I)}function z(I){$(I)}function E(I){v!==null&&I.pointerId===v&&P()}function D(I){I.key==="Escape"&&P()}function P(){if(_&&v!==null)try{_.releasePointerCapture(v)}catch{}window.removeEventListener("pointermove",S),window.removeEventListener("pointerup",z),window.removeEventListener("pointercancel",E),window.removeEventListener("keydown",D),y(p,null),y(m,null),v=null,x=!1,_=null}lr(P),me(()=>{if(!d(p)&&!d(m))return;const I=new Set(e.tabs.map(O=>O.id));d(p)&&!I.has(d(p))&&y(p,null),d(m)&&!I.has(d(m).id)&&y(m,null)});function R(){const I=d(c);I&&(y(f,I.scrollLeft>0),y(h,I.scrollLeft+I.clientWidth<I.scrollWidth-1))}me(()=>{const I=d(c);if(!I)return;R(),I.addEventListener("scroll",R,{passive:!0});const O=new ResizeObserver(R);return O.observe(I),()=>{I.removeEventListener("scroll",R),O.disconnect()}}),me(()=>{e.tabs.length,R()}),me(()=>{if(!e.activeTabId||!d(c))return;const I=d(c).querySelector(`[data-testid="tab-${e.activeTabId}"]`);I&&I.scrollIntoView({inline:"nearest",block:"nearest",behavior:d(i)})});function H(I,O){if(!(I.button!==0||d(te))){v=I.pointerId,g=I.clientX,b=I.clientY,x=!1,y(p,O,!0),_=I.currentTarget;try{_.setPointerCapture(I.pointerId)}catch{}window.addEventListener("pointermove",S),window.addEventListener("pointerup",z),window.addEventListener("pointercancel",E),window.addEventListener("keydown",D)}}function Q(I,O){var V;return((V=document.elementFromPoint(I,O))==null?void 0:V.closest('[data-testid^="tab-"][role="tab"]'))??null}function Z(I){var K;if(v===null||I.pointerId!==v||!d(p))return;if(!x){const ne=I.clientX-g,ye=I.clientY-b;if(Math.hypot(ne,ye)<T)return;x=!0}I.preventDefault();const O=Q(I.clientX,I.clientY),A=((K=O==null?void 0:O.getAttribute("data-testid"))==null?void 0:K.slice(4))??null;if(!O||!A||A===d(p)){y(m,null);return}const V=O.getBoundingClientRect(),L=V.left+V.width/2,J=I.clientX<L?"left":"right";y(m,{id:A,side:J},!0)}function $(I){if(v===null||I.pointerId!==v)return;const O=x;if(O&&d(p)&&d(m)&&d(m).id!==d(p)&&e.reorder&&e.tabs.some(A=>A.id===d(p))&&e.reorder(d(p),d(m).id,d(m).side),O){let A;const V=L=>{L.stopPropagation(),L.preventDefault(),window.removeEventListener("click",V,!0),clearTimeout(A)};window.addEventListener("click",V,!0),A=setTimeout(()=>window.removeEventListener("click",V,!0),0)}P()}function W(I,O){if(!I.altKey||!e.reorder||I.key!=="ArrowLeft"&&I.key!=="ArrowRight")return;I.preventDefault();const A=e.tabs.findIndex(V=>V.id===O);A!==-1&&(I.key==="ArrowLeft"&&A>0?e.reorder(O,e.tabs[A-1].id):I.key==="ArrowRight"&&A<e.tabs.length-1&&e.reorder(e.tabs[A+1].id,O))}const te=F(()=>e.tabs.length<=1);me(()=>{if(!d(o))return;function I(O){var V,L;const A=O.target;A&&((V=d(a))!=null&&V.contains(A)||(L=A.closest)!=null&&L.call(A,".new-tab-menu")||JA(A)||y(o,!1))}return window.addEventListener("pointerdown",I,!0),()=>window.removeEventListener("pointerdown",I,!0)});var ae=fQ(),re=w(ae);Je(re,21,()=>e.tabs,I=>I.id,(I,O)=>{{let A=F(()=>d(O).id===e.activeTabId),V=F(()=>{var L;return((L=d(m))==null?void 0:L.id)===d(O).id?d(m).side:null});dQ(I,{get tab(){return d(O)},get isActive(){return d(A)},get onswitch(){return e.onTabSwitch},onclose:u,onpointerdown:H,get dropIndicator(){return d(V)},onkeydown:W})}}),xt(re,I=>y(c,I),()=>d(c));var ue=k(re,2);xt(ue,I=>y(a,I),()=>d(a));var oe=k(ue,2);{var fe=I=>{lQ(I,{get recentFiles(){return d(s)},get closedTabTop(){return r()},get anchorEl(){return d(a)},onOpen:async O=>{y(o,!1);const A=await Po(O);A.ok?Tp(Ap(Qy(),O)):console.warn("[tandem] failed to open recent file:",A.error)},onNewScratchpad:()=>{y(o,!1),Jf()},onBrowse:()=>{var O;y(o,!1),(O=e.onRequestOpenDialog)==null||O.call(e)},onReopenClosed:()=>{var O;y(o,!1),(O=e.onReopenClosed)==null||O.call(e)},onClose:()=>y(o,!1)})};G(oe,I=>{d(o)&&I(fe)})}q(()=>At(re,1,n0(["tab-scroll-hide","tab-scroll-mask",d(f)&&d(h)&&"has-overflow",d(f)&&!d(h)&&"overflow-left",!d(f)&&d(h)&&"overflow-right"]))),N("click",ue,()=>{y(s,Qy(),!0),y(o,!d(o))}),C(t,ae),Be()}We(["click"]);const ox=(t,e=yr,n=yr)=>{var r=mQ();q(()=>{At(r,1,`panel-edge-collapse panel-edge-collapse-${e()}`,"svelte-y74n0s"),U(r,"data-testid",`panel-edge-collapse-${e()}`),U(r,"aria-label",e()==="left"?"Hide left panel":"Hide right panel")}),N("click",r,function(...i){var o;(o=n())==null||o.apply(this,i)}),C(t,r)};var pQ=M('<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>'),mQ=M('<div role="button" tabindex="-1"></div>'),gQ=M("<!> <!> <!>",1),vQ=M('<div class="margin-track svelte-y74n0s" style="grid-column: 2; grid-row: 1;"><!></div>'),bQ=M('<div class="margin-track svelte-y74n0s" style="grid-column: 4; grid-row: 1;"><!></div>'),yQ=M('<div class="editor-content-track svelte-y74n0s" style="grid-column: 3; grid-row: 1;"><!></div> <!> <!>',1),wQ=M('<div class="editor-end-marker svelte-y74n0s" aria-hidden="true"><span class="editor-end-pill svelte-y74n0s">End of document</span></div>'),kQ=M('<div class="editor-scroll tandem-scroll-fade-y" role="region" aria-label="Document editor"><!> <div data-testid="editor-stage"><!></div> <!> <!></div>'),xQ=M('<div style="display: flex; flex: 1; align-items: center; justify-content: center; color: var(--tandem-fg-subtle);">Connecting...</div>'),_Q=M('<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>'),CQ=M('<span class="rail-tab-badge svelte-y74n0s"> </span>'),SQ=M('<!> <!> <!> <!> <!> <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),EQ=M('<div style="display: flex; flex-direction: column; height: 100vh; background: var(--tandem-bg); color: var(--tandem-fg);"><!> <!></div>');function AQ(t,e){ze(e,!0);const n=j=>{hQ(j,{get tabs(){return f.orderedTabs},get activeTabId(){return o.activeTabId},get onTabSwitch(){return o.setActiveTabId},onTabClose:u,get reorder(){return f.reorder},get reduceMotion(){return h.settings.reduceMotion},onRequestOpenDialog:()=>void O(),get closedTabTop(){return a.top},onReopenClosed:c})},r=(j,de=yr,ke=yr,Pe=yr,wt=yr)=>{var Ft=pQ();U(Ft,"aria-valuemin",0),U(Ft,"aria-valuemax",100),q(Ut=>{U(Ft,"data-testid",Pe()??`${de()}-panel-resize-handle`),U(Ft,"aria-label",de()==="left"?"Resize left panel":"Resize right panel"),U(Ft,"aria-valuenow",Ut)},[()=>wt()!==void 0?Math.round((wt()-fl)/(jc-fl)*100):50]),N("mousedown",Ft,function(...Ut){var ao;(ao=ke())==null||ao.apply(this,Ut)}),N("keydown",Ft,Ut=>{let pr=null;Ut.key==="ArrowRight"||Ut.key==="ArrowUp"?pr=16:Ut.key==="ArrowLeft"||Ut.key==="ArrowDown"?pr=-16:Ut.key==="PageUp"?pr=80:Ut.key==="PageDown"?pr=-80:Ut.key==="Home"?pr=fl-(de()==="left"?ut.width:it.width):Ut.key==="End"&&(pr=jc-(de()==="left"?ut.width:it.width)),pr!==null&&(Ut.preventDefault(),Ut.stopPropagation(),de()==="left"?ut.handleResizeStep(pr):it.handleResizeStep(pr))}),N("keyup",Ft,()=>{}),rn("mouseenter",Ft,Ut=>{Ut.currentTarget.style.background="var(--tandem-border-strong)"}),rn("mouseleave",Ft,Ut=>{Ut.currentTarget.style.background="transparent"}),C(j,Ft)},i=j=>{var de=kQ();{const fi=Jt=>{YZ(Jt,{get ydoc(){return d($e).ydoc},get provider(){return d($e).provider},get readOnly(){return o.readOnly},get currentFilePath(){return d($e).filePath},get format(){return d($e).format},get activeAnnotationId(){return d(se)},onEditorReady:Rt=>y(he,Rt,!0),onAnnotationClick:Rt=>{y(Y,"annotations"),y(se,Rt,!0)},onClearAnnotation:()=>{y(se,null)},onSlashCommandMenuChange:Rt=>y(Oe,Rt,!0)})},er=(Jt,Rt=yr,Wn=yr)=>{const tr=F(()=>Rt()==="left"?Ve.leftGeometry:Ve.rightGeometry),Fo=F(()=>Rt()==="left"?Ve.leftMode:Ve.rightMode);eX(Jt,{get side(){return Rt()},get annotations(){return Wn()},get positions(){return $t.byId},get width(){return d(tr).column},get edgeInset(){return d(tr).inset},get gap(){return d(tr).gap},get mode(){return d(Fo)},get activeAnnotationId(){return d(se)},get repliesById(){return Hr.byId},onClick:zo=>{y(se,zo.id,!0),mt.scrollToAnnotation(zo)},get onAccept(){return mt.handleAccept},get onDismiss(){return mt.handleDismiss},get onRemove(){return d(di).onRemove},get onEdit(){return d(di).onEdit},get onReply(){return d(di).onReply},get onSendToClaude(){return d(di).onSendToClaude}})};var ke=w(de);{let Jt=F(()=>{var Wn,tr;return((Wn=d($e))==null?void 0:Wn.readOnly)===!0&&((tr=d($e))==null?void 0:tr.format)==="docx"}),Rt=F(()=>{var Wn;return(Wn=d($e))==null?void 0:Wn.id});BP(ke,{get visible(){return d(Jt)},get documentId(){return d(Rt)}})}var Pe=k(ke,2),wt=w(Pe);{var Ft=Jt=>{var Rt=gQ(),Wn=Se(Rt);Vf(Wn,()=>d($e).id,mr=>{fi(mr)});var tr=k(Wn,2);{var Fo=mr=>{er(mr,()=>"left",()=>d(ot))};G(tr,mr=>{Ve.leftVisible&&d($e)&&mr(Fo)})}var zo=k(tr,2);{var Ra=mr=>{er(mr,()=>"right",()=>d(yt))};G(zo,mr=>{Ve.rightVisible&&d($e)&&mr(Ra)})}C(Jt,Rt)},Ut=Jt=>{var Rt=yQ(),Wn=Se(Rt),tr=w(Wn);{var Fo=In=>{var Di=kt(),lo=Se(Di);Vf(lo,()=>d($e).id,_d=>{fi(_d)}),C(In,Di)},zo=In=>{LO(In,{get connected(){return o.connected},get claudeActive(){return o.claudeActive},onOpenFile:()=>y(I,!0),onRetry:()=>o.reconnect(),onOpenSettings:L})};G(tr,In=>{d($e)?In(Fo):In(zo,-1)})}var Ra=k(Wn,2);{var mr=In=>{var Di=vQ(),lo=w(Di);er(lo,()=>"left",()=>d(ot)),C(In,Di)};G(Ra,In=>{Ve.leftVisible&&d($e)&&In(mr)})}var dm=k(Ra,2);{var xd=In=>{var Di=bQ(),lo=w(Di);er(lo,()=>"right",()=>d(yt)),C(In,Di)};G(dm,In=>{Ve.rightVisible&&d($e)&&In(xd)})}C(Jt,Rt)};G(wt,Jt=>{var Rt;((Rt=d($e))==null?void 0:Rt.format)==="docx"?Jt(Ft):Jt(Ut,-1)})}xt(Pe,Jt=>y(De,Jt),()=>d(De));var ao=k(Pe,2);{var kd=Jt=>{var Rt=wQ();C(Jt,Rt)};G(ao,Jt=>{d($e)&&Jt(kd)})}var pr=k(ao,2);sJ(pr,{get editor(){return d(he)},get open(){return d(be)},onClose:()=>y(be,!1),get tabs(){return o.tabs},get forceScope(){return d(Ne)}}),cr(de,(Jt,Rt)=>Ht==null?void 0:Ht(Jt,Rt),()=>"y"),q(()=>xe(Pe,Ve.layerStyle))}q(()=>xe(de,`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: ${E.fileDragOver||Pg.fileDragOver?"2px dashed var(--tandem-accent)":"2px solid transparent"}; background: ${E.fileDragOver||Pg.fileDragOver?"var(--tandem-accent-bg)":"var(--tandem-bg)"}; transition: border-color 0.15s, background 0.15s; border-radius: ${E.fileDragOver||Pg.fileDragOver?"var(--tandem-r-5)":"0"};`)),rn("dragover",de,function(...fi){var er;(er=E.handleEditorDragOver)==null||er.apply(this,fi)}),rn("dragleave",de,function(...fi){var er;(er=E.handleEditorDragLeave)==null||er.apply(this,fi)}),rn("drop",de,function(...fi){var er;(er=E.handleEditorDrop)==null||er.apply(this,fi)}),C(j,de)},o=NY();lr(()=>o.destroy());const s=aY(()=>o.tabs);lr(()=>s.destroy());const a=VJ(),l=new Set;function u(j){const de=o.tabs.find(ke=>ke.id===j);if(de&&Gv(de.filePath)){const ke=c_(de.filePath);if(ke&&s.hasUnsavedContent(ke)){if(!window.confirm("This scratchpad has unsaved content that will be lost. Close it anyway?"))return;s.clearUnsaved(ke)}}de&&!uu(de.filePath)&&a.push({filePath:de.filePath,closedAt:Date.now()}),o.handleTabClose(j)}async function c(){const j=a.pop();if(!j)return;const de=o.tabs.find(Pe=>Pe.filePath===j.filePath);if(de){o.setActiveTabId(de.id);return}if(l.has(j.filePath))return;l.add(j.filePath);const ke=Pe=>{a.push(j);const wt=j.filePath.split(/[\\/]/).pop()||j.filePath;S.push({id:`reopen-failed-${Date.now()}`,type:"general-error",severity:"error",message:`Couldn't reopen ${wt}: ${Pe}`,dedupKey:`reopen-failed:${j.filePath}`,timestamp:Date.now()})};try{const Pe=await Po(j.filePath);Pe.ok||ke(Pe.error)}finally{l.delete(j.filePath)}}const f=fY(()=>o.tabs);uY(()=>f.orderedTabs,()=>o.activeTabId,j=>o.setActiveTabId(j)),me(()=>{const j=o.tabs;if(j.length!==0)try{const de=fc();let ke=de;for(const Pe of j)uu(Pe.filePath)||(ke=Ap(ke,Pe.filePath));(ke.length!==de.length||ke.some((Pe,wt)=>Pe!==de[wt]))&&Tp(ke)}catch(de){console.warn("[tandem] failed to sync recent files:",de)}});const h=ab(),p=hY(()=>o.bootstrapYdoc,()=>h.settings.selectionDwellMs),m=jY(h,p),v=F(()=>U_(h.settings.customShortcuts)),g=F(()=>JM(d(v))),b=F(()=>o.annotations),x=UJ(()=>o.disconnectedSince,()=>h.settings.degradedBannerDelayMs),_=MY();OY();const T=F(()=>o.tabs.map(j=>({id:j.id,fileName:j.fileName}))),S=sY();let z=B(!1);const E=JJ();if(gY(S.push),Lt()){let j=null,de=!1;Mn(async()=>{const{listen:ke}=await import("./event-CNdo2oXa.js");return{listen:ke}},__vite__mapDeps([6,1])).then(({listen:ke})=>ke("sidecar-restart-failed",()=>{S.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(ke=>{de?ke():j=ke}).catch(ke=>{console.warn("[App] Failed to wire sidecar-restart-failed listener:",ke)}),lr(()=>{de=!0,j==null||j()})}let D=B(!1),P=B(!1);const R=YJ(),H="tandem:wizard-dismissed";let Q=B(Ge($())),Z=B(!1);function $(){try{return localStorage.getItem(H)}catch{return null}}const W=F(()=>R.needed===!0&&R.serverVersion!==null&&d(Q)!==R.serverVersion),te=F(()=>d(Z)||d(W));let ae=B(!1);const re=F(()=>d(W)&&h.settings.models.length===0&&!d(ae));function ue(){if(d(W)&&R.serverVersion!==null)try{localStorage.setItem(H,R.serverVersion),y(Q,R.serverVersion,!0)}catch{}y(Z,!1),y(ae,!1)}me(()=>{const j=de=>{de.key===H&&y(Q,de.newValue,!0)};return window.addEventListener("storage",j),()=>window.removeEventListener("storage",j)}),me(()=>{const j=()=>{y(Z,!0),y(P,!1),R.refetch()};return window.addEventListener("tandem:open-integration-wizard",j),()=>window.removeEventListener("tandem:open-integration-wizard",j)});let oe=B(null),fe=B(!1),I=B(!1);function O(){return UO({isTauri:Lt(),openModal:()=>{y(I,!0)},onError:j=>S.push({id:cu(),type:"general-error",severity:"error",message:j,timestamp:Date.now()})})}const A=TY();function V(){d(D)||A.acknowledge(),y(D,!d(D))}function L(){A.acknowledge(),y(P,!0)}const J=F(()=>{const j=h.settings.defaultModelId;if(j===null)return null;const de=h.settings.models.find(ke=>ke.id===j);return de?de.displayName:null});let K=B(null);function ne(){d(P)||y(K,lL.models,!0),L()}function ye(){A.acknowledge(),y(D,!0)}SM({getActiveTabId:()=>o.activeTabId,getActiveDocumentPath:()=>{const j=o.tabs.find(de=>de.id===o.activeTabId);return j&&!uu(j.filePath)?j.filePath:null},notify:(j,de)=>{S.push({id:`launcher-${Date.now()}`,type:"launcher",severity:j,message:de,timestamp:Date.now()})},openSettings:ye,openSettingsModal:L,toggleSoloMode:()=>p.setTandemMode(p.tandemMode==="solo"?"tandem":"solo"),openFindBar:()=>{y(Ne,"doc"),y(be,!0)},openFindBarTabs:()=>{y(Ne,"tabs"),y(be,!0)},findNext:()=>{const j=d(he),de=j?cl(j.state):void 0;j&&Rg(de)?j.commands.findNext():(y(Ne,"doc"),y(be,!0))},findPrev:()=>{const j=d(he),de=j?cl(j.state):void 0;j&&Rg(de)?j.commands.findPrev():(y(Ne,"doc"),y(be,!0))},closeActiveTab:()=>{const j=o.activeTabId;j&&u(j)},openFileDialog:()=>void O(),toggleLeftPanel:()=>Pt(),toggleRightPanel:()=>Gt(),reopenClosedTab:()=>void c(),annotationNext:()=>{const j=rf(d(b)),de=Bk(j,d(se));if(de){y(se,de,!0);const ke=j.find(Pe=>Pe.id===de);ke&&mt.scrollToAnnotation(ke)}},annotationPrev:()=>{const j=rf(d(b)),de=Hk(j,d(se));if(de){y(se,de,!0);const ke=j.find(Pe=>Pe.id===de);ke&&mt.scrollToAnnotation(ke)}},annotationAccept:()=>{const j=un();j&&j.author!=="user"&&mt.handleAccept(j.id)},annotationDismiss:()=>{const j=un();j&&j.author!=="user"&&mt.handleDismiss(j.id)},selectBlock:()=>{var j;return(j=d(he))==null?void 0:j.chain().focus().selectParentNode().run()},toggleAuthorship:()=>ce(!h.settings.showAuthorship),toggleFormattingBar:()=>h.updateSettings({formattingBarVisible:!h.settings.formattingBarVisible}),saveAs:async()=>{const j=o.tabs.find(Pe=>Pe.id===o.activeTabId);if(!j||!uu(j.filePath)){S.push({id:cu(),type:"launcher",severity:"info",message:"Save As is only available for scratchpads; this document is already on disk.",timestamp:Date.now()});return}const de=Math.max(j.filePath.lastIndexOf("/"),j.filePath.lastIndexOf("\\")),ke=j.filePath.slice(de+1);await Oy({activeDocId:o.activeTabId,defaultName:ke,sourceFormat:j.format,notify:(Pe,wt)=>S.push({id:cu(),type:"launcher",severity:Pe,message:wt,timestamp:Date.now()})})}});function ce(j){h.updateSettings({showAuthorship:j,...h.settings.decorationsMuted?{decorationsMuted:!1}:{}})}let ve=null;me(()=>{const j=d(he);if(!j)return;const de=h.settings,ke=!de.decorationsMuted&&de.showAuthorship;if(ve===ke)return;const Pe=ve===null;ve=ke,!Pe&&St(()=>{const wt=j.state.tr.setMeta(Wa,{type:"toggle",visible:ke});j.view.dispatch(wt)})});let _e=null;me(()=>{const j=d(he);if(!j)return;const de=h.settings,ke=de.decorationsMuted,Pe={comment:!ke&&de.showComments,highlight:!ke&&de.showHighlights,note:!ke&&de.showNotes},wt=`${Pe.comment?1:0}${Pe.highlight?1:0}${Pe.note?1:0}`;if(_e===wt)return;const Ft=_e===null;_e=wt,!Ft&&St(()=>{const Ut=j.state.tr.setMeta(Du,{type:"toggle-decorations",visible:Pe});j.view.dispatch(Ut)})}),me(()=>(document.body.classList.toggle("tandem-reduce-motion",h.settings.reduceMotion),()=>document.body.classList.remove("tandem-reduce-motion"))),kY(()=>h.settings.theme),PJ(()=>h.settings.accentHue),ZJ(()=>{var j;return w5(h.settings,(j=d($e))==null?void 0:j.format)}),qJ(()=>h.settings.density),QJ(()=>h.settings.highContrast),FJ(()=>h.settings.annotationPatterns),me(()=>{const j=p5[h.settings.textSize];return document.documentElement.style.setProperty("--tandem-editor-font-size",`${j}px`),()=>document.documentElement.style.removeProperty("--tandem-editor-font-size")});let Y=B(Ge(h.settings.primaryTab==="chat"?"chat":"annotations"));const we=F(()=>d(Y)==="annotations"?0:d(b).filter(Gf).length);let se=B(null),X=B(!1),le=B(null),he=B(null),De=B(null),Oe=B(!1),be=B(!1),Ne=B("doc"),Qe=B(0),Ae=B(0);const Me=Vk("left"),Ze=Vk("right"),ut=Uk({side:"left",initialWidth:Me,getVisible:()=>d(pe)}),it=Uk({side:"right",initialWidth:Ze,getVisible:()=>d(Ie)}),pe=F(()=>m.leftVisible),Ie=F(()=>m.rightVisible);function pt(j,de){queueMicrotask(()=>{const ke=de?`panel-edge-collapse-${j}`:`peek-strip-${j}`,Pe=document.querySelector(`[data-testid="${ke}"]`);Pe?Pe.focus():console.warn(`[tandem] focusToggleTarget: ${ke} not mounted; focus dropped to body`)})}const Pt=()=>{const j=!m.leftVisible;m.toggleLeft(),pt("left",j)},Gt=()=>{const j=!m.rightVisible;m.toggleRight(),pt("right",j)},Ke=DY(),Ve=UY({getFormat:()=>{var j;return(j=d($e))==null?void 0:j.format},getMarginView:()=>h.settings.marginView,getEditorMeasure:()=>h.settings.editorMeasure,getLeftRailVisible:()=>d(pe),getRightRailVisible:()=>d(Ie),getViewportWidth:()=>Ke.width,getLeftHasPending:()=>d(b).some(j=>j.status==="pending"&&$k(j)),getRightHasPending:()=>d(b).some(j=>j.status==="pending"&&ex(j)),leftRailWidthPx:Me,rightRailWidthPx:Ze});function ct(){if(d(Y)==="chat"||!d(he))return;const{from:j,to:de}=d(he).state.selection;if(j===de)return;const ke=c3(d(he).state.doc,{from:Hn(j),to:Hn(de)}),Pe=d(he).state.doc.textBetween(j,de,`
|
|
238
|
+
`);y(le,{...ke,textSnapshot:Pe.length>200?Pe.slice(0,197)+"...":Pe},!0)}const ht={"toggle-help":j=>{const de=j.target;de&&(de.tagName==="INPUT"||de.tagName==="TEXTAREA"||de.isContentEditable)||(j.preventDefault(),y(X,St(()=>!d(X)),!0))},"select-all":j=>{var ke,Pe;const de=document.activeElement;de instanceof HTMLInputElement||de instanceof HTMLTextAreaElement||(ke=de==null?void 0:de.closest)!=null&&ke.call(de,".ProseMirror")||(j.preventDefault(),(Pe=d(he))==null||Pe.commands.selectAll())},save:j=>{j.preventDefault(),g0(o.activeTabId)},"save-as":j=>{const de=j.target;if(de&&(de.tagName==="INPUT"||de.tagName==="TEXTAREA"||de.isContentEditable))return;j.preventDefault();const ke=o.tabs.find(Ft=>Ft.id===o.activeTabId);if(!ke||!uu(ke.filePath)){S.push({id:cu(),type:"launcher",severity:"info",message:"Save As is only available for scratchpads; this document is already on disk.",timestamp:Date.now()});return}const Pe=Math.max(ke.filePath.lastIndexOf("/"),ke.filePath.lastIndexOf("\\")),wt=ke.filePath.slice(Pe+1);Oy({activeDocId:o.activeTabId,defaultName:wt,sourceFormat:ke.format,notify:(Ft,Ut)=>S.push({id:cu(),type:"launcher",severity:Ft,message:Ut,timestamp:Date.now()})})},"settings-modal":j=>{j.preventDefault(),L()},settings:j=>{j.preventDefault(),ye()},"toggle-palette":j=>{j.preventDefault(),y(fe,!St(()=>d(fe)))},"new-scratchpad":j=>{const de=j.target;de&&(de.tagName==="INPUT"||de.tagName==="TEXTAREA")||(j.preventDefault(),Jf())},"close-tab":j=>{if(jr(j))return;j.preventDefault();const de=o.activeTabId;de&&u(de)},"open-file":j=>{jr(j)||(j.preventDefault(),O())},"pick-tab":(j,de)=>{if(jr(j))return;const ke=de==null?void 0:de.tabIndex;if(ke===void 0)return;const Pe=cY(o.tabs,ke);Pe&&(j.preventDefault(),o.setActiveTabId(Pe))},"toggle-mode":j=>{jr(j)||(j.preventDefault(),p.setTandemMode(p.tandemMode==="solo"?"tandem":"solo"))},"reopen-closed-tab":j=>{jr(j)||(j.preventDefault(),c())},find:(j,de)=>{if(j.preventDefault(),de!=null&&de.shift){y(Ne,"tabs"),y(be,!0);return}d(pe)?y(Qe,d(Qe)+1):(y(Ne,"doc"),y(be,!0))},"find-nav":(j,de)=>{if(jr(j))return;j.preventDefault();const ke=d(he),Pe=ke?cl(ke.state):void 0;ke&&Rg(Pe)?de!=null&&de.shift?ke.commands.findPrev():ke.commands.findNext():(y(Ne,"doc"),y(be,!0))},"annotation-accept-or-dismiss":(j,de)=>{if(jr(j))return;j.preventDefault();const ke=un();ke&&ke.author!=="user"&&(de!=null&&de.shift?mt.handleDismiss(ke.id):mt.handleAccept(ke.id))},"comment-on-selection":j=>{var wt;j.preventDefault();const de=!!d(he)&&d(he).state.selection.from!==d(he).state.selection.to,ke=((wt=d($e))==null?void 0:wt.readOnly)===!0;if(!(d(Oe)||d(be)||d(fe))){if(!de){S.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(ke){S.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(!h.settings.selectionToolbar){S.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(Ae,d(Ae)+1)}},"toggle-authorship":j=>{j.preventDefault(),ce(!h.settings.showAuthorship)},"toggle-left-panel":j=>{jr(j)||(j.preventDefault(),Pt())},"toggle-right-panel":j=>{jr(j)||(j.preventDefault(),Gt())},"annotation-next":j=>{if(jr(j))return;j.preventDefault();const de=rf(d(b)),ke=Bk(de,d(se));if(ke){y(se,ke,!0);const Pe=de.find(wt=>wt.id===ke);Pe&&mt.scrollToAnnotation(Pe)}},"annotation-prev":j=>{if(jr(j))return;j.preventDefault();const de=rf(d(b)),ke=Hk(de,d(se));if(ke){y(se,ke,!0);const Pe=de.find(wt=>wt.id===ke);Pe&&mt.scrollToAnnotation(Pe)}},"select-block":j=>{jr(j)||(j.preventDefault(),d(he)&&d(he).chain().focus().selectParentNode().run())}};me(()=>{function j(de){var Pe;const ke=H_(de,St(()=>d(v)));ke&&((Pe=ht[ke.id])==null||Pe.call(ht,de,ke.context))}return window.addEventListener("keydown",j),()=>window.removeEventListener("keydown",j)}),me(()=>{function j(de){if(de.key!=="Escape"||de.defaultPrevented||d(se)===null||d(be))return;const ke=document.activeElement;ke instanceof HTMLInputElement||ke instanceof HTMLTextAreaElement||!(!ke||ke===document.body||ke.closest('.ProseMirror, [data-testid="editor-root"], [data-testid="annotation-list-scroll-container"]'))||(de.preventDefault(),y(se,null))}return window.addEventListener("keydown",j),()=>window.removeEventListener("keydown",j)});const $e=F(()=>o.tabs.find(j=>j.id===o.activeTabId));me(()=>{if(!TM({connected:o.connected,tabCount:o.tabs.length,activeTabId:o.activeTabId}))return;const j=setTimeout(()=>{Jf()},AM);return()=>clearTimeout(j)});const mt=oX({getYdoc:()=>{var j;return((j=d($e))==null?void 0:j.ydoc)??null},getEditor:()=>d(he),getAnnotations:()=>d(b),onActiveAnnotationChange:j=>{y(se,j,!0)},getScrollBehavior:()=>h.settings.reduceMotion?"auto":"smooth",getActiveAnnotationId:()=>d(se)});function un(){return d(se)?d(b).find(j=>j.id===d(se)):mt.getReviewTargets()[0]}const ot=F(()=>Ve.effectivelyOn?d(b).filter($k):[]),yt=F(()=>Ve.effectivelyOn?d(b).filter(ex):[]),$t=tY({getEditor:()=>d(he),getYdoc:()=>{var j;return((j=d($e))==null?void 0:j.ydoc)??null},getAnnotations:()=>[...d(ot),...d(yt)],getLayerEl:()=>d(De),getEnabled:()=>Ve.effectivelyOn}),Hr=zJ({getYdoc:()=>{var j;return((j=d($e))==null?void 0:j.ydoc)??null}}),di=F(()=>{var ke,Pe;const j=((ke=d($e))==null?void 0:ke.ydoc)??null,de=(Pe=d($e))==null?void 0:Pe.id;return{ydoc:j,docId:de,onEdit:(wt,Ft)=>h3(j,wt,Ft),onReply:(wt,Ft)=>v3(wt,Ft,de),onRemove:wt=>g3(wt,de),onSendToClaude:wt=>m3(j,wt)}}),Vr=CY(()=>d(b),()=>d(he),()=>{var j;return(j=d($e))==null?void 0:j.fileName});var Ti=EQ(),gn=w(Ti);OX(gn,{get tandemMode(){return p.tandemMode},get onModeChange(){return p.setTandemMode},get claudeActive(){return o.claudeActive},get theme(){return h.settings.theme},onSetTheme:j=>h.updateSettings({theme:j}),onOpenHelp:()=>y(X,!0),onOpenSettings:V,onOpenSettingsModal:L,get updateAvailable(){return A.showDot},get defaultModelLabel(){return d(J)},onOpenModelsSettings:ne,get center(){return n},get settingsBtn(){return d(oe)},set settingsBtn(j){y(oe,j,!0)}});var Mi=k(gn,2);{var Is=j=>{var de=xQ();C(j,de)},su=j=>{var de=SQ(),ke=Se(de);{var Pe=Le=>{var zt=_Q();C(Le,zt)};G(ke,Le=>{o.serverRestarted&&Le(Pe)})}var wt=k(ke,2);{var Ft=Le=>{PL(Le,{get version(){return _.availableVersion},get installing(){return _.installing},onInstall:()=>{_.install()},get onDismiss(){return _.dismiss}})},Ut=F(()=>Lt()&&_.showBanner&&_.availableVersion);G(wt,Le=>{d(Ut)&&Le(Ft)})}var ao=k(wt,2);{var kd=Le=>{wO(Le,{get onDismiss(){return x.dismiss},onRetry:()=>{o.reconnect()}})};G(ao,Le=>{x.showBanner&&Le(kd)})}var pr=k(ao,2);{let Le=F(()=>{var nr;return((nr=d($e))==null?void 0:nr.ydoc)??null}),zt=F(()=>d(Oe)||d(be)||d(fe));RJ(pr,{get editor(){return d(he)},get ydoc(){return d(Le)},get selectionToolbar(){return h.settings.selectionToolbar},get suppressSelectionToolbar(){return d(zt)},get requestCommentFocus(){return d(Ae)},get showAuthorship(){return h.settings.showAuthorship},get showComments(){return h.settings.showComments},get showHighlights(){return h.settings.showHighlights},get showNotes(){return h.settings.showNotes},get decorationsMuted(){return h.settings.decorationsMuted},onUpdateDecorations:nr=>h.updateSettings(nr),onOpenSettings:V,get formattingBarVisible(){return h.settings.formattingBarVisible},onShowFormattingBar:()=>h.updateSettings({formattingBarVisible:!0})})}var fi=k(pr,2);{var er=Le=>{{let zt=F(()=>{var nr;return((nr=d($e))==null?void 0:nr.ydoc)??null});hX(Le,{get editor(){return d(he)},get ydoc(){return d(zt)},get showAuthorship(){return h.settings.showAuthorship},get showComments(){return h.settings.showComments},get showHighlights(){return h.settings.showHighlights},get showNotes(){return h.settings.showNotes},get decorationsMuted(){return h.settings.decorationsMuted},onUpdateDecorations:nr=>h.updateSettings(nr),onOpenSettings:V,onHide:()=>h.updateSettings({formattingBarVisible:!1})})}};G(fi,Le=>{h.settings.formattingBarVisible&&Le(er)})}var Jt=k(fi,2),Rt=w(Jt);let Wn;var tr=w(Rt),Fo=w(tr);Xm(Fo,{kind:"outline",get focusTrigger(){return d(Qe)},get editor(){return d(he)},visible:!0});var zo=k(Fo,2);ox(zo,()=>"left",()=>Pt);var Ra=k(tr,2);{let Le=F(()=>!d(pe));tx(Ra,{side:"left",get collapsed(){return d(Le)},kind:"outline",onActivate:Pt})}var mr=k(Rt,2);{var dm=Le=>{r(Le,()=>"left",()=>zt=>ut.handleResizeStart(zt),()=>{},()=>ut.width)};G(mr,Le=>{d(pe)&&Le(dm)})}var xd=k(mr,2);i(xd);var In=k(xd,2);{var Di=Le=>{r(Le,()=>"right",()=>zt=>it.handleResizeStart(zt),()=>"panel-resize-handle",()=>it.width)};G(In,Le=>{d(Ie)&&Le(Di)})}var lo=k(In,2);let _d;var fm=w(lo),D1=w(fm);ox(D1,()=>"right",()=>Gt);var O1=k(D1,2),cT=w(O1),Cd=w(cT),dT=k(w(Cd));{var fT=Le=>{var zt=CQ(),nr=w(zt);q(()=>ee(nr,d(we)>9?"9+":d(we))),C(Le,zt)};G(dT,Le=>{d(Y)!=="annotations"&&d(we)>0&&Le(fT)})}var hm=k(Cd,2),I1=k(O1,2);{let Le=F(()=>d(Y)==="chat");Xm(I1,{kind:"chat",get ctrlYdoc(){return o.bootstrapYdoc},get editor(){return d(he)},get activeDocId(){return o.activeTabId},get openDocs(){return d(T)},get claudeActive(){return o.claudeActive},get claudeStatus(){return o.claudeStatus},get capturedAnchor(){return d(le)},onCapturedAnchorChange:zt=>y(le,zt,!0),get reduceMotion(){return h.settings.reduceMotion},get visible(){return d(Le)}})}var hT=k(I1,2);{let Le=F(()=>{var Ar;return((Ar=d($e))==null?void 0:Ar.ydoc)??null}),zt=F(()=>{var Ar;return(Ar=d($e))==null?void 0:Ar.format}),nr=F(()=>{var Ar;return(Ar=d($e))==null?void 0:Ar.id}),xT=F(()=>{var Ar;return((Ar=o.claudeWorking)==null?void 0:Ar.annotationId)??null}),_T=F(()=>d(Y)==="annotations");Xm(hT,{kind:"side",get annotations(){return d(b)},get editor(){return d(he)},get ydoc(){return d(Le)},get activeDocFormat(){return d(zt)},get documentId(){return d(nr)},get activeAnnotationId(){return d(se)},onActiveAnnotationChange:Ar=>y(se,Ar,!0),get reduceMotion(){return h.settings.reduceMotion},get storeReadOnly(){return o.storeReadOnly},get claudeWorkingAnnotationId(){return d(xT)},get review(){return mt},get visible(){return d(_T)}})}var pT=k(fm,2);{let Le=F(()=>!d(Ie));tx(pT,{side:"right",get collapsed(){return d(Le)},kind:"annotations",get annotations(){return d(b)},onActivate:Gt})}var R1=k(Jt,2);{let Le=F(()=>{var zt;return((zt=o.claudeWorking)==null?void 0:zt.tool)??null});UX(R1,{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(Le)},get readOnly(){return o.readOnly},get saving(){return EM.saving},get editor(){return d(he)}})}var N1=k(R1,2);TL(N1,{get open(){return d(D)},onClose:()=>y(D,!1),get settings(){return h.settings},get onUpdate(){return h.updateSettings},get returnFocusEl(){return d(oe)},get anchorEl(){return d(oe)},get connected(){return o.connected},get reconnectAttempts(){return o.reconnectAttempts}});var P1=k(N1,2);hL(P1,{get open(){return d(P)},onClose:()=>{y(P,!1),y(K,null)},get settings(){return h.settings},get onUpdate(){return h.updateSettings},get returnFocusEl(){return d(oe)},get triggerEl(){return d(oe)},get connected(){return o.connected},get reconnectAttempts(){return o.reconnectAttempts},get initialTabId(){return d(K)},notify:(Le,zt)=>S.push({id:`settings-${Date.now()}`,type:"launcher",severity:Le,message:zt,timestamp:Date.now()})});var L1=k(P1,2);I5(L1,{get open(){return d(X)},onClose:()=>y(X,!1),get effectiveShortcutLabels(){return d(g)}});var F1=k(L1,2);{var mT=Le=>{A5(Le,{onComplete:()=>y(ae,!0)})},gT=Le=>{r8(Le,{open:!0,onClose:ue})};G(F1,Le=>{d(re)?Le(mT):d(te)&&Le(gT,1)})}var z1=k(F1,2);{var vT=Le=>{JO(Le,{onClose:()=>y(I,!1)})};G(z1,Le=>{d(I)&&Le(vT)})}var B1=k(z1,2);bO(B1,{get open(){return d(fe)},onClose:()=>y(fe,!1),get editor(){return d(he)},get annotations(){return d(b)},onFocusAnnotation:Le=>{y(se,Le,!0)}});var H1=k(B1,2);RL(H1,{get toasts(){return S.toasts},get onDismiss(){return S.dismiss}});var V1=k(H1,2);hD(V1,{get items(){return S.activity},get open(){return d(z)},onToggle:()=>y(z,!d(z)),get onDismiss(){return S.dismissActivity},get onClear(){return S.clearActivity},onAction:Le=>{const zt=j_(Le);zt&&(o.tabs.some(nr=>nr.id===zt.documentId)?g0(zt.documentId):S.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 U1=k(V1,2);{var bT=Le=>{OO(Le,{})},yT=F(()=>Lt());G(U1,Le=>{d(yT)&&Le(bT)})}var wT=k(U1,2);{var kT=Le=>{v8(Le,{get currentStep(){return Vr.currentStep},get onNext(){return Vr.nextStep},get onDismiss(){return Vr.dismissTutorial},get coworkStatus(){return Vr.coworkStatus}})};G(wT,Le=>{Vr.tutorialActive&&Le(kT)})}q(()=>{Wn=At(Rt,1,"rail-shell rail-shell-left svelte-y74n0s",null,Wn,{collapsed:!d(pe)}),xe(Rt,d(pe)?`width: ${ut.width}px;`:""),xe(tr,`width: ${ut.width}px;`),_d=At(lo,1,"rail-shell rail-shell-right svelte-y74n0s",null,_d,{collapsed:!d(Ie)}),xe(lo,d(Ie)?`width: ${it.width}px;`:""),xe(fm,`width: ${it.width}px;`),At(Cd,1,"rail-tab"+(d(Y)==="annotations"?" on":""),"svelte-y74n0s"),At(hm,1,"rail-tab"+(d(Y)==="chat"?" on":""),"svelte-y74n0s")}),rn("scroll",Jt,Le=>{Le.currentTarget.scrollLeft=0}),N("click",Cd,()=>{y(Y,"annotations")}),N("mousedown",hm,ct),N("click",hm,()=>{y(Y,"chat")}),C(j,de)};G(Mi,j=>{o.ready?j(su,-1):j(Is)})}q(()=>U(Ti,"data-tandem-mode",p.tandemMode)),C(t,Ti),Be()}We(["mousedown","keydown","keyup","click"]);const sx=3,TQ="error-boundary-recover-btn",MQ="error-boundary-reload-btn";function DQ(t,e){ze(e,!0),me(()=>{e.onSuccess()}),Be()}var OQ=M('<button class="btn btn-primary svelte-1bcl6yi">Try to recover</button>'),IQ=M('<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>'),RQ=M("<!> <!>",1);function NQ(t,e){let n=B(0),r=B(0);var i=kt(),o=Se(i);Ix(o,{onerror:()=>{y(r,d(r)+1)},failed:(a,l=yr,u=yr)=>{var c=kt(),f=Se(c);Vf(f,()=>d(r),h=>{var p=IQ(),m=k(w(p),2),v=w(m),g=k(m,2),b=w(g),x=k(g,2);{var _=S=>{var z=OQ();q(()=>U(z,"data-testid",TQ)),N("click",z,()=>{y(n,d(n)+1),u()()}),C(S,z)};G(x,S=>{d(n)<sx&&S(_)})}var T=k(x,2);q(S=>{ee(v,d(n)>=sx?"Recovery attempts exhausted. Reload the page to continue.":"The editor encountered an unexpected error."),ee(b,S),U(T,"data-testid",MQ)},[()=>l()instanceof Error?l().message:String(l())]),N("click",T,()=>window.location.reload()),C(h,p)}),C(a,c)}},a=>{var l=RQ(),u=Se(l);rd(u,()=>e.children);var c=k(u,2);DQ(c,{onSuccess:()=>{y(n,0)}}),C(a,l)}),C(t,i)}We(["click"]);function PQ(t){NQ(t,{children:(e,n)=>{AQ(e,{})}})}K4(PQ,{target:document.getElementById("root")});export{Je as A,xe as B,zQ as C,qQ as D,UQ as E,We as F,GQ as G,jQ as H,m_ as T,w as a,C as b,MC as c,Be as d,B as e,VQ as f,d as g,U as h,G as i,Se as j,At as k,Un as l,WQ as m,ee as n,lr as o,ze as p,N as q,y as r,k as s,q as t,F as u,M as v,sb as w,CC as x,TC as y,KQ as z};
|