tandem-editor 0.14.3 → 0.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,270 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/path-49-uTKly.js","assets/core-SwWLTXZB.js","assets/dist-js-BWAGOggB.js","assets/event-wL_2RBc7.js","assets/CoworkSettings-B4LapjhG.js","assets/CoworkSettings-C0m1IhNy.css","assets/dist-CJtsfiU2.js","assets/prod-p35ShryZ.js","assets/webview-C-97RVRf.js","assets/window-CR0qpD8C.js"])))=>i.map(i=>d[i]);
2
+ var e=Object.defineProperty,t=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n||e(r,Symbol.toStringTag,{value:`Module`}),r};(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var n=Array.isArray,r=Array.prototype.indexOf,i=Array.prototype.includes,a=Array.from,o=Object.defineProperty,s=Object.getOwnPropertyDescriptor,c=Object.getOwnPropertyDescriptors,l=Object.prototype,u=Array.prototype,d=Object.getPrototypeOf,f=Object.isExtensible;function p(e){return typeof e==`function`}var m=()=>{};function h(e){return typeof e?.then==`function`}function g(e){for(var t=0;t<e.length;t++)e[t]()}function _(){var e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}function v(e,t){if(Array.isArray(e))return e;if(t===void 0||!(Symbol.iterator in e))return Array.from(e);let n=[];for(let r of e)if(n.push(r),n.length===t)break;return n}var y=1024,b=2048,x=4096,S=8192,C=16384,w=32768,ee=1<<25,T=65536,E=1<<19,te=1<<20,ne=1<<25,D=65536,re=1<<21,ie=1<<22,ae=1<<23,oe=Symbol(`$state`),se=Symbol(`legacy props`),ce=Symbol(``),le=Symbol(`attributes`),ue=Symbol(`class`),de=Symbol(`style`),fe=Symbol(`text`),pe=Symbol(`form reset`),me=new class extends Error{name=`StaleReactionError`;message="The reaction that called `getAbortSignal()` was re-run or destroyed"},he=!!globalThis.document?.contentType&&globalThis.document.contentType.includes(`xml`);function ge(e){throw Error(`https://svelte.dev/e/lifecycle_outside_component`)}function _e(){throw Error(`https://svelte.dev/e/async_derived_orphan`)}function ve(e,t,n){throw Error(`https://svelte.dev/e/each_key_duplicate`)}function ye(e){throw Error(`https://svelte.dev/e/effect_in_teardown`)}function be(){throw Error(`https://svelte.dev/e/effect_in_unowned_derived`)}function xe(e){throw Error(`https://svelte.dev/e/effect_orphan`)}function Se(){throw Error(`https://svelte.dev/e/effect_update_depth_exceeded`)}function Ce(e){throw Error(`https://svelte.dev/e/props_invalid_value`)}function we(){throw Error(`https://svelte.dev/e/state_descriptors_fixed`)}function Te(){throw Error(`https://svelte.dev/e/state_prototype_fixed`)}function Ee(){throw Error(`https://svelte.dev/e/state_unsafe_mutation`)}function De(){throw Error(`https://svelte.dev/e/svelte_boundary_reset_onerror`)}var Oe={},ke=Symbol(),Ae=`http://www.w3.org/1999/xhtml`,je=`http://www.w3.org/2000/svg`,Me=`http://www.w3.org/1998/Math/MathML`;function Ne(){console.warn(`https://svelte.dev/e/derived_inert`)}function Pe(e){console.warn(`https://svelte.dev/e/hydration_mismatch`)}function Fe(){console.warn(`https://svelte.dev/e/select_multiple_invalid_value`)}function Ie(){console.warn(`https://svelte.dev/e/svelte_boundary_reset_noop`)}var Le=!1;function Re(e){Le=e}var ze;function Be(e){if(e===null)throw Pe(),Oe;return ze=e}function Ve(){return Be(yn(ze))}function O(e){if(Le){if(yn(ze)!==null)throw Pe(),Oe;ze=e}}function k(e=1){if(Le){for(var t=e,n=ze;t--;)n=yn(n);ze=n}}function He(e=!0){for(var t=0,n=ze;;){if(n.nodeType===8){var r=n.data;if(r===`]`){if(t===0)return n;--t}else (r===`[`||r===`[!`||r[0]===`[`&&!isNaN(Number(r.slice(1))))&&(t+=1)}var i=yn(n);e&&n.remove(),n=i}}function Ue(e){if(!e||e.nodeType!==8)throw Pe(),Oe;return e.data}function We(e){return e===this.v}function Ge(e,t){return e==e?e!==t||typeof e==`object`&&!!e||typeof e==`function`:t==t}function Ke(e){return!Ge(e,this.v)}var qe=!1,Je=!1;function Ye(){Je=!0}var Xe=null;function Ze(e){Xe=e}function A(e,t=!1,n){Xe={p:Xe,i:!1,c:null,e:null,s:e,x:null,r:sr,l:Je&&!t?{s:null,u:null,$:[]}:null}}function j(e){var t=Xe,n=t.e;if(n!==null){t.e=null;for(var r of n)Fn(r)}return e!==void 0&&(t.x=e),t.i=!0,Xe=t.p,e??{}}function Qe(){return!Je||Xe!==null&&Xe.l===null}var $e=[];function et(){var e=$e;$e=[],g(e)}function tt(e){if($e.length===0&&!yt){var t=$e;queueMicrotask(()=>{t===$e&&et()})}$e.push(e)}function nt(){for(;$e.length>0;)et()}function rt(e){var t=sr;if(t===null)return ir.f|=ae,e;if(!(t.f&32768)&&!(t.f&4))throw e;it(e,t)}function it(e,t){for(;t!==null;){if(t.f&128){if(!(t.f&32768))throw e;try{t.b.error(e);return}catch(t){e=t}}t=t.parent}throw e}var at=~(b|x|y);function ot(e,t){e.f=e.f&at|t}function st(e){e.f&512||e.deps===null?ot(e,y):ot(e,x)}function ct(e){if(e!==null)for(let t of e)!(t.f&2)||!(t.f&65536)||(t.f^=D,ct(t.deps))}function lt(e,t,n){e.f&2048?t.add(e):e.f&4096&&n.add(e),ct(e.deps),ot(e,y)}var ut=!1,dt=!1;function ft(e){var t=dt;try{return dt=!1,[e(),dt]}finally{dt=t}}var pt=null,mt=null,ht=null,gt=null,_t=null,vt=null,yt=!1,bt=!1,xt=null,St=null,Ct=0,wt=1,Tt=class e{id=wt++;#e=!1;linked=!0;#t=null;#n=null;async_deriveds=new Map;current=new Map;previous=new Map;unblocked=new Set;#r=new Set;#i=new Set;#a=new Set;#o=0;#s=new Map;#c=null;#l=[];#u=[];#d=new Set;#f=new Set;#p=new Map;#m=new Set;is_fork=!1;#h=!1;#g(){if(this.is_fork)return!0;for(let n of this.#s.keys()){for(var e=n,t=!1;e.parent!==null;){if(this.#p.has(e)){t=!0;break}e=e.parent}if(!t)return!0}return!1}skip_effect(e){this.#p.has(e)||this.#p.set(e,{d:[],m:[]}),this.#m.delete(e)}unskip_effect(e,t=e=>this.schedule(e)){var n=this.#p.get(e);if(n){this.#p.delete(e);for(var r of n.d)ot(r,b),t(r);for(r of n.m)ot(r,x),t(r)}this.#m.add(e)}#_(){if(this.#e=!0,Ct++>1e3&&(this.#w(),Dt()),!this.#g()){for(let e of this.#d)this.#f.delete(e),ot(e,b),this.schedule(e);for(let e of this.#f)ot(e,x),this.schedule(e)}let t=this.#l;this.#l=[],this.apply();var n=xt=[],r=[],i=St=[];for(let e of t)try{this.#v(e,n,r)}catch(t){throw Pt(e),t}if(ht=null,i.length>0){var a=e.ensure();for(let e of i)a.schedule(e)}if(xt=null,St=null,this.#g()){this.#x(r),this.#x(n);for(let[e,t]of this.#p)Nt(e,t);i.length>0&&ht.#_();return}let o=this.#y();if(o){o.#b(this);return}this.#d.clear(),this.#f.clear();for(let e of this.#r)e(this);this.#r.clear(),gt=this,kt(r),kt(n),gt=null,this.#c?.resolve();var s=ht;if(this.linked&&this.#o===0&&this.#w(),qe&&!this.linked&&(this.#S(),ht=s),this.#l.length>0){s===null&&(s=this,this.#C());let e=s;e.#l.push(...this.#l.filter(t=>!e.#l.includes(t)))}s!==null&&s.#_()}#v(e,t,n){e.f^=y;for(var r=e.first;r!==null;){var i=r.f,a=(i&96)!=0;if(!(a&&i&1024||i&8192||this.#p.has(r))&&r.fn!==null){a?r.f^=y:i&4?t.push(r):qe&&i&16777224?n.push(r):br(r)&&(i&16&&this.#f.add(r),Tr(r));var o=r.first;if(o!==null){r=o;continue}}for(;r!==null;){var s=r.next;if(s!==null){r=s;break}r=r.parent}}}#y(){for(var e=this.#t;e!==null;){if(!e.is_fork){for(let[t,[,n]]of this.current)if(e.current.has(t)&&!n)return e}e=e.#t}return null}#b(e){for(let[t,n]of e.current)!this.previous.has(t)&&e.previous.has(t)&&this.previous.set(t,e.previous.get(t)),this.current.set(t,n);for(let[t,n]of e.async_deriveds){let e=this.async_deriveds.get(t);e&&n.promise.then(e.resolve)}let t=e=>{var n=e.reactions;if(n!==null)for(let e of n){var r=e.f;if(r&2)t(e);else{var i=e;r&4194320&&!this.async_deriveds.has(i)&&(this.#f.delete(i),ot(i,b),this.schedule(i))}}};for(let e of this.current.keys())t(e);this.oncommit(()=>e.discard()),e.#w(),ht=this,this.#_()}#x(e){for(var t=0;t<e.length;t+=1)lt(e[t],this.#d,this.#f)}capture(e,t,n=!1){e.v!==ke&&!this.previous.has(e)&&this.previous.set(e,e.v),e.f&8388608||(this.current.set(e,[t,n]),_t?.set(e,t)),this.is_fork||(e.v=t)}activate(){ht=this}deactivate(){ht=null,_t=null}flush(){try{bt=!0,ht=this,this.#_()}finally{Ct=0,vt=null,xt=null,St=null,bt=!1,ht=null,_t=null,$t.clear()}}discard(){for(let e of this.#i)e(this);this.#i.clear(),this.#a.clear(),this.#w()}register_created_effect(e){this.#u.push(e)}#S(){this.#w();for(let l=pt;l!==null;l=l.#n){var e=l.id<this.id,t=[];for(let[r,[i,a]]of this.current){if(l.current.has(r)){var n=l.current.get(r)[0];if(e&&i!==n)l.current.set(r,[i,a]);else continue}t.push(r)}if(e)for(let[e,t]of this.async_deriveds){let n=l.async_deriveds.get(e);n&&t.promise.then(n.resolve)}if(l.#e){var r=[...l.current.keys()].filter(e=>!this.current.has(e));if(r.length===0)e&&l.discard();else if(t.length>0){if(e)for(let e of this.#m)l.unskip_effect(e,e=>{e.f&4194320?l.schedule(e):l.#x([e])});l.activate();var i=new Set,a=new Map;for(var o of t)At(o,r,i,a);a=new Map;var s=[...l.current.keys()].filter(e=>this.current.has(e)?this.current.get(e)[0]!==e.v:!0);if(s.length>0)for(let e of this.#u)!(e.f&155648)&&jt(e,s,a)&&(e.f&4194320?(ot(e,b),l.schedule(e)):l.#d.add(e));if(l.#l.length>0){l.apply();for(var c of l.#l)l.#v(c,[],[]);l.#l=[]}l.deactivate()}}}}increment(e,t){if(this.#o+=1,e){let e=this.#s.get(t)??0;this.#s.set(t,e+1)}}decrement(e,t){if(--this.#o,e){let e=this.#s.get(t)??0;e===1?this.#s.delete(t):this.#s.set(t,e-1)}this.#h||(this.#h=!0,tt(()=>{this.#h=!1,this.linked&&this.flush()}))}transfer_effects(e,t){for(let t of e)this.#d.add(t);for(let e of t)this.#f.add(e);e.clear(),t.clear()}oncommit(e){this.#r.add(e)}ondiscard(e){this.#i.add(e)}on_fork_commit(e){this.#a.add(e)}run_fork_commit_callbacks(){for(let e of this.#a)e(this);this.#a.clear()}settled(){return(this.#c??=_()).promise}static ensure(){if(ht===null){let t=ht=new e;t.#C(),!bt&&!yt&&tt(()=>{t.#e||t.flush()})}return ht}apply(){if(!qe||!this.is_fork&&this.#t===null&&this.#n===null){_t=null;return}_t=new Map;for(let[e,[t]]of this.current)_t.set(e,t);for(let t=pt;t!==null;t=t.#n)if(!(t===this||t.is_fork)){var e=!1;if(t.id<this.id){for(let[n,[,r]]of t.current)if(!r&&this.current.has(n)){e=!0;break}}if(!e)for(let[e,n]of t.previous)_t.has(e)||_t.set(e,n)}}schedule(e){if(vt=e,e.b?.is_pending&&e.f&16777228&&!(e.f&32768)){e.b.defer_effect(e);return}for(var t=e;t.parent!==null;){t=t.parent;var n=t.f;if(xt!==null&&t===sr&&(qe||(ir===null||!(ir.f&2))&&!ut))return;if(n&96){if(!(n&1024))return;t.f^=y}}this.#l.push(t)}#C(){mt===null?pt=mt=this:(mt.#n=this,this.#t=mt),mt=this}#w(){var e=this.#t,t=this.#n;e===null?pt=t:e.#n=t,t===null?mt=e:t.#t=e,this.linked=!1}};function Et(e){var t=yt;yt=!0;try{var n;for(e&&(ht!==null&&!ht.is_fork&&ht.flush(),n=e());;){if(nt(),ht===null)return n;ht.flush()}}finally{yt=t}}function Dt(){try{Se()}catch(e){it(e,vt)}}var Ot=null;function kt(e){var t=e.length;if(t!==0){for(var n=0;n<t;){var r=e[n++];if(!(r.f&24576)&&br(r)&&(Ot=new Set,Tr(r),r.deps===null&&r.first===null&&r.nodes===null&&r.teardown===null&&r.ac===null&&Jn(r),Ot?.size>0)){$t.clear();for(let e of Ot){if(e.f&24576)continue;let t=[e],n=e.parent;for(;n!==null;)Ot.has(n)&&(Ot.delete(n),t.push(n)),n=n.parent;for(let e=t.length-1;e>=0;e--){let n=t[e];n.f&24576||Tr(n)}}Ot.clear()}}Ot=null}}function At(e,t,n,r){if(!n.has(e)&&(n.add(e),e.reactions!==null))for(let i of e.reactions){let e=i.f;e&2?At(i,t,n,r):e&4194320&&!(e&2048)&&jt(i,t,r)&&(ot(i,b),Mt(i))}}function jt(e,t,n){let r=n.get(e);if(r!==void 0)return r;if(e.deps!==null)for(let r of e.deps){if(i.call(t,r))return!0;if(r.f&2&&jt(r,t,n))return n.set(r,!0),!0}return n.set(e,!1),!1}function Mt(e){ht.schedule(e)}function Nt(e,t){if(!(e.f&32&&e.f&1024)){e.f&2048?t.d.push(e):e.f&4096&&t.m.push(e),ot(e,y);for(var n=e.first;n!==null;)Nt(n,t),n=n.next}}function Pt(e){ot(e,y);for(var t=e.first;t!==null;)Pt(t),t=t.next}function Ft(e){let t=0,n=tn(0),r;return()=>{Nn()&&(B(n),Bn(()=>(t===0&&(r=kr(()=>e(()=>sn(n)))),t+=1,()=>{tt(()=>{--t,t===0&&(r?.(),r=void 0,sn(n))})})))}}var It=T|E;function Lt(e,t,n,r){new Rt(e,t,n,r)}var Rt=class{parent;is_pending=!1;transform_error;#e;#t=Le?ze:null;#n;#r;#i;#a=null;#o=null;#s=null;#c=null;#l=0;#u=0;#d=!1;#f=new Set;#p=new Set;#m=null;#h=Ft(()=>(this.#m=tn(this.#l),()=>{this.#m=null}));constructor(e,t,n,r){this.#e=e,this.#n=t,this.#r=e=>{var t=sr;t.b=this,t.f|=128,n(e)},this.parent=sr.b,this.transform_error=r??this.parent?.transform_error??(e=>e),this.#i=Vn(()=>{if(Le){let e=this.#t;Ve();let t=e.data===`[!`;if(e.data.startsWith(`[?`)){let t=JSON.parse(e.data.slice(2));this.#_(t)}else t?this.#v():this.#g()}else this.#y()},It),Le&&(this.#e=ze)}#g(){try{this.#a=Hn(()=>this.#r(this.#e))}catch(e){this.error(e)}}#_(e){let t=this.#n.failed;t&&(this.#s=Hn(()=>{t(this.#e,()=>e,()=>()=>{})}))}#v(){let e=this.#n.pending;e&&(this.is_pending=!0,this.#o=Hn(()=>e(this.#e)),tt(()=>{var e=this.#c=document.createDocumentFragment(),t=_n();e.append(t),this.#a=this.#x(()=>Hn(()=>this.#r(t))),this.#u===0&&(this.#e.before(e),this.#c=null,Yn(this.#o,()=>{this.#o=null}),this.#b(ht))}))}#y(){try{if(this.is_pending=this.has_pending_snippet(),this.#u=0,this.#l=0,this.#a=Hn(()=>{this.#r(this.#e)}),this.#u>0){var e=this.#c=document.createDocumentFragment();$n(this.#a,e);let t=this.#n.pending;this.#o=Hn(()=>t(this.#e))}else this.#b(ht)}catch(e){this.error(e)}}#b(e){this.is_pending=!1,e.transfer_effects(this.#f,this.#p)}defer_effect(e){lt(e,this.#f,this.#p)}is_rendered(){return!this.is_pending&&(!this.parent||this.parent.is_rendered())}has_pending_snippet(){return!!this.#n.pending}#x(e){var t=sr,n=ir,r=Xe;cr(this.#i),or(this.#i),Ze(this.#i.ctx);try{return Tt.ensure(),e()}catch(e){return rt(e),null}finally{cr(t),or(n),Ze(r)}}#S(e,t){if(!this.has_pending_snippet()){this.parent&&this.parent.#S(e,t);return}this.#u+=e,this.#u===0&&(this.#b(t),this.#o&&Yn(this.#o,()=>{this.#o=null}),this.#c&&=(this.#e.before(this.#c),null))}update_pending_count(e,t){this.#S(e,t),this.#l+=e,!(!this.#m||this.#d)&&(this.#d=!0,tt(()=>{this.#d=!1,this.#m&&rn(this.#m,this.#l)}))}get_effect_pending(){return this.#h(),B(this.#m)}error(e){if(!this.#n.onerror&&!this.#n.failed)throw e;ht?.is_fork?(this.#a&&ht.skip_effect(this.#a),this.#o&&ht.skip_effect(this.#o),this.#s&&ht.skip_effect(this.#s),ht.on_fork_commit(()=>{this.#C(e)})):this.#C(e)}#C(e){this.#a&&=(Kn(this.#a),null),this.#o&&=(Kn(this.#o),null),this.#s&&=(Kn(this.#s),null),Le&&(Be(this.#t),k(),Be(He()));var t=this.#n.onerror;let n=this.#n.failed;var r=!1,i=!1;let a=()=>{if(r){Ie();return}r=!0,i&&De(),this.#s!==null&&Yn(this.#s,()=>{this.#s=null}),this.#x(()=>{this.#y()})},o=e=>{try{i=!0,t?.(e,a),i=!1}catch(e){it(e,this.#i&&this.#i.parent)}n&&(this.#s=this.#x(()=>{try{return Hn(()=>{var t=sr;t.b=this,t.f|=128,n(this.#e,()=>e,()=>a)})}catch(e){return it(e,this.#i.parent),null}}))};tt(()=>{var t;try{t=this.transform_error(e)}catch(e){it(e,this.#i&&this.#i.parent);return}typeof t==`object`&&t&&typeof t.then==`function`?t.then(o,e=>it(e,this.#i&&this.#i.parent)):o(t)})}};function zt(e,t,n,r){let i=Qe()?Ut:Kt;var a=e.filter(e=>!e.settled);if(n.length===0&&a.length===0){r(t.map(i));return}var o=sr,s=Bt(),c=a.length===1?a[0].promise:a.length>1?Promise.all(a.map(e=>e.promise)):null;function l(e){if(!(o.f&16384)){s();try{r(e)}catch(e){it(e,o)}Vt()}}var u=Ht();if(n.length===0){c.then(()=>l(t.map(i))).finally(u);return}function d(){Promise.all(n.map(e=>Gt(e))).then(e=>l([...t.map(i),...e])).catch(e=>it(e,o)).finally(u)}c?c.then(()=>{s(),d(),Vt()}):d()}function Bt(){var e=sr,t=ir,n=Xe,r=ht;return function(i=!0){cr(e),or(t),Ze(n),i&&!(e.f&16384)&&(r?.activate(),r?.apply())}}function Vt(e=!0){cr(null),or(null),Ze(null),e&&ht?.deactivate()}function Ht(){var e=sr,t=e.b,n=ht,r=t.is_rendered();return t.update_pending_count(1,n),n.increment(r,e),()=>{t.update_pending_count(-1,n),n.decrement(r,e)}}function Ut(e){var t=2|b;return sr!==null&&(sr.f|=E),{ctx:Xe,deps:null,effects:null,equals:We,f:t,fn:e,reactions:null,rv:0,v:ke,wv:0,parent:sr,ac:null}}var Wt=Symbol(`obsolete`);function Gt(e,t,n){let r=sr;r===null&&_e();var i=void 0,a=tn(ke),o=!ir,s=new Set;return zn(()=>{var t=sr,n=_();i=n.promise;try{Promise.resolve(e()).then(n.resolve,e=>{e!==me&&n.reject(e)}).finally(Vt)}catch(e){n.reject(e),Vt()}var c=ht;if(o){if(t.f&32768)var l=Ht();if(r.b.is_rendered())c.async_deriveds.get(t)?.reject(Wt);else for(let e of s.values())e.reject(Wt);s.add(n),c.async_deriveds.set(t,n)}let u=(e,t=void 0)=>{l?.(),s.delete(n),t!==Wt&&(c.activate(),t?(a.f|=ae,rn(a,t)):(a.f&8388608&&(a.f^=ae),rn(a,e)),c.deactivate())};n.promise.then(u,e=>u(null,e||`unknown`))}),Pn(()=>{for(let e of s)e.reject(Wt)}),new Promise(e=>{function t(n){function r(){n===i?e(a):t(i)}n.then(r,r)}t(i)})}function M(e){let t=Ut(e);return qe||ur(t),t}function Kt(e){let t=Ut(e);return t.equals=Ke,t}function qt(e){var t=e.effects;if(t!==null){e.effects=null;for(var n=0;n<t.length;n+=1)Kn(t[n])}}function Jt(e){var t,n=sr,r=e.parent;if(!nr&&r!==null&&r.f&24576)return Ne(),e.v;cr(r);try{e.f&=~D,qt(e),t=Sr(e)}finally{cr(n)}return t}function Yt(e){var t=Jt(e);if(!e.equals(t)&&(e.wv=yr(),(!ht?.is_fork||e.deps===null)&&(ht===null?e.v=t:(ht.capture(e,t,!0),gt?.capture(e,t,!0)),e.deps===null))){ot(e,y);return}nr||(_t===null?st(e):(Nn()||ht?.is_fork)&&_t.set(e,t))}function Xt(e){if(e.effects!==null)for(let t of e.effects)(t.teardown||t.ac)&&(t.teardown?.(),t.ac?.abort(me),t.teardown=m,t.ac=null,wr(t,0),Wn(t))}function Zt(e){if(e.effects!==null)for(let t of e.effects)t.teardown&&Tr(t)}var Qt=new Set,$t=new Map,en=!1;function tn(e,t){return{f:0,v:e,reactions:null,equals:We,rv:0,wv:0}}function N(e,t){let n=tn(e,t);return ur(n),n}function nn(e,t=!1,n=!0){let r=tn(e);return t||(r.equals=Ke),Je&&n&&Xe!==null&&Xe.l!==null&&(Xe.l.s??=[]).push(r),r}function P(e,t,n=!1){return ir!==null&&(!ar||ir.f&131072)&&Qe()&&ir.f&4325394&&(lr===null||!i.call(lr,e))&&Ee(),rn(e,n?ln(t):t,St)}function rn(e,t,n=null){if(!e.equals(t)){$t.set(e,nr?t:e.v);var r=Tt.ensure();if(r.capture(e,t),e.f&2){let t=e;e.f&2048&&Jt(t),_t===null&&st(t)}e.wv=yr(),cn(e,b,n),Qe()&&sr!==null&&sr.f&1024&&!(sr.f&96)&&(pr===null?mr([e]):pr.push(e)),!r.is_fork&&Qt.size>0&&!en&&an()}return t}function an(){en=!1;for(let e of Qt){e.f&1024&&ot(e,x);let t;try{t=br(e)}catch{t=!0}t&&Tr(e)}Qt.clear()}function on(e,t=1){var n=B(e),r=t===1?n++:n--;return P(e,n),r}function sn(e){P(e,e.v+1)}function cn(e,t,n){var r=e.reactions;if(r!==null)for(var i=Qe(),a=r.length,o=0;o<a;o++){var s=r[o],c=s.f;if(!(!i&&s===sr)){var l=(c&b)===0;if(l&&ot(s,t),c&131072)Qt.add(s);else if(c&2){var u=s;_t?.delete(u),c&65536||(c&512&&(sr===null||!(sr.f&2097152))&&(s.f|=D),cn(u,x,n))}else if(l){var d=s;c&16&&Ot!==null&&Ot.add(d),n===null?Mt(d):n.push(d)}}}}function ln(e){if(typeof e!=`object`||!e||oe in e)return e;let t=d(e);if(t!==l&&t!==u)return e;var r=new Map,i=n(e),a=N(0),o=null,c=_r,f=e=>{if(_r===c)return e();var t=ir,n=_r;or(null),vr(c);var r=e();return or(t),vr(n),r};return i&&r.set(`length`,N(e.length,o)),new Proxy(e,{defineProperty(e,t,n){(!(`value`in n)||n.configurable===!1||n.enumerable===!1||n.writable===!1)&&we();var i=r.get(t);return i===void 0?f(()=>{var e=N(n.value,o);return r.set(t,e),e}):P(i,n.value,!0),!0},deleteProperty(e,t){var n=r.get(t);if(n===void 0){if(t in e){let e=f(()=>N(ke,o));r.set(t,e),sn(a)}}else P(n,ke),sn(a);return!0},get(t,n,i){if(n===oe)return e;var a=r.get(n),c=n in t;if(a===void 0&&(!c||s(t,n)?.writable)&&(a=f(()=>N(ln(c?t[n]:ke),o)),r.set(n,a)),a!==void 0){var l=B(a);return l===ke?void 0:l}return Reflect.get(t,n,i)},getOwnPropertyDescriptor(e,t){var n=Reflect.getOwnPropertyDescriptor(e,t);if(n&&`value`in n){var i=r.get(t);i&&(n.value=B(i))}else if(n===void 0){var a=r.get(t),o=a?.v;if(a!==void 0&&o!==ke)return{enumerable:!0,configurable:!0,value:o,writable:!0}}return n},has(e,t){if(t===oe)return!0;var n=r.get(t),i=n!==void 0&&n.v!==ke||Reflect.has(e,t);return(n!==void 0||sr!==null&&(!i||s(e,t)?.writable))&&(n===void 0&&(n=f(()=>N(i?ln(e[t]):ke,o)),r.set(t,n)),B(n)===ke)?!1:i},set(e,t,n,c){var l=r.get(t),u=t in e;if(i&&t===`length`)for(var d=n;d<l.v;d+=1){var p=r.get(d+``);p===void 0?d in e&&(p=f(()=>N(ke,o)),r.set(d+``,p)):P(p,ke)}if(l===void 0)(!u||s(e,t)?.writable)&&(l=f(()=>N(void 0,o)),P(l,ln(n)),r.set(t,l));else{u=l.v!==ke;var m=f(()=>ln(n));P(l,m)}var h=Reflect.getOwnPropertyDescriptor(e,t);if(h?.set&&h.set.call(c,n),!u){if(i&&typeof t==`string`){var g=r.get(`length`),_=Number(t);Number.isInteger(_)&&_>=g.v&&P(g,_+1)}sn(a)}return!0},ownKeys(e){B(a);var t=Reflect.ownKeys(e).filter(e=>{var t=r.get(e);return t===void 0||t.v!==ke});for(var[n,i]of r)i.v!==ke&&!(n in e)&&t.push(n);return t},setPrototypeOf(){Te()}})}function un(e){try{if(typeof e==`object`&&e&&oe in e)return e[oe]}catch{}return e}function dn(e,t){return Object.is(un(e),un(t))}new Set([`copyWithin`,`fill`,`pop`,`push`,`reverse`,`shift`,`sort`,`splice`,`unshift`]);var fn,pn,mn,hn;function gn(){if(fn===void 0){fn=window,pn=/Firefox/.test(navigator.userAgent);var e=Element.prototype,t=Node.prototype,n=Text.prototype;mn=s(t,`firstChild`).get,hn=s(t,`nextSibling`).get,f(e)&&(e[ue]=void 0,e[le]=null,e[de]=void 0,e.__e=void 0),f(n)&&(n[fe]=void 0)}}function _n(e=``){return document.createTextNode(e)}function vn(e){return mn.call(e)}function yn(e){return hn.call(e)}function F(e,t){if(!Le)return vn(e);var n=vn(ze);if(n===null)n=ze.appendChild(_n());else if(t&&n.nodeType!==3){var r=_n();return n?.before(r),Be(r),r}return t&&Cn(n),Be(n),n}function I(e,t=!1){if(!Le){var n=vn(e);return n instanceof Comment&&n.data===``?yn(n):n}if(t){if(ze?.nodeType!==3){var r=_n();return ze?.before(r),Be(r),r}Cn(ze)}return ze}function L(e,t=1,n=!1){let r=Le?ze:e;for(var i;t--;)i=r,r=yn(r);if(!Le)return r;if(n){if(r?.nodeType!==3){var a=_n();return r===null?i?.after(a):r.before(a),Be(a),a}Cn(r)}return Be(r),r}function bn(e){e.textContent=``}function xn(){return!qe||Ot!==null?!1:(sr.f&w)!==0}function Sn(e,t,n){let r=n?{is:n}:void 0;return document.createElementNS(t??`http://www.w3.org/1999/xhtml`,e,r)}function Cn(e){if(e.nodeValue.length<65536)return;let t=e.nextSibling;for(;t!==null&&t.nodeType===3;)t.remove(),e.nodeValue+=t.nodeValue,t=e.nextSibling}function wn(e,t){if(t){let t=document.body;e.autofocus=!0,tt(()=>{document.activeElement===t&&e.focus()})}}function Tn(e){Le&&vn(e)!==null&&bn(e)}var En=!1;function Dn(){En||(En=!0,document.addEventListener(`reset`,e=>{Promise.resolve().then(()=>{if(!e.defaultPrevented)for(let t of e.target.elements)t[pe]?.()})},{capture:!0}))}function On(e){var t=ir,n=sr;or(null),cr(null);try{return e()}finally{or(t),cr(n)}}function kn(e,t,n,r=n){e.addEventListener(t,()=>On(n));let i=e[pe];i?e[pe]=()=>{i(),r(!0)}:e[pe]=()=>r(!0),Dn()}function An(e){sr===null&&(ir===null&&xe(e),be()),nr&&ye(e)}function jn(e,t){var n=t.last;n===null?t.last=t.first=e:(n.next=e,e.prev=n,t.last=e)}function Mn(e,t){var n=sr;n!==null&&n.f&8192&&(e|=S);var r={ctx:Xe,deps:null,nodes:null,f:e|b|512,first:null,fn:t,last:null,next:null,parent:n,b:n&&n.b,prev:null,teardown:null,wv:0,ac:null};ht?.register_created_effect(r);var i=r;if(e&4)xt===null?Tt.ensure().schedule(r):xt.push(r);else if(t!==null){try{Tr(r)}catch(e){throw Kn(r),e}i.deps===null&&i.teardown===null&&i.nodes===null&&i.first===i.last&&!(i.f&524288)&&(i=i.first,e&16&&e&65536&&i!==null&&(i.f|=T))}if(i!==null&&(i.parent=n,n!==null&&jn(i,n),ir!==null&&ir.f&2&&!(e&64))){var a=ir;(a.effects??=[]).push(i)}return r}function Nn(){return ir!==null&&!ar}function Pn(e){let t=Mn(8,null);return ot(t,y),t.teardown=e,t}function R(e){An(`$effect`);var t=sr.f;if(!ir&&t&32&&!(t&32768)){var n=Xe;(n.e??=[]).push(e)}else return Fn(e)}function Fn(e){return Mn(4|te,e)}function In(e){Tt.ensure();let t=Mn(64|E,e);return()=>{Kn(t)}}function Ln(e){Tt.ensure();let t=Mn(64|E,e);return(e={})=>new Promise(n=>{e.outro?Yn(t,()=>{Kn(t),n(void 0)}):(Kn(t),n(void 0))})}function Rn(e){return Mn(4,e)}function zn(e){return Mn(ie|E,e)}function Bn(e,t=0){return Mn(8|t,e)}function z(e,t=[],n=[],r=[]){zt(r,t,n,t=>{Mn(8,()=>e(...t.map(B)))})}function Vn(e,t=0){return Mn(16|t,e)}function Hn(e){return Mn(32|E,e)}function Un(e){var t=e.teardown;if(t!==null){let e=nr,n=ir;rr(!0),or(null);try{t.call(null)}finally{rr(e),or(n)}}}function Wn(e,t=!1){var n=e.first;for(e.first=e.last=null;n!==null;){let e=n.ac;e!==null&&On(()=>{e.abort(me)});var r=n.next;n.f&64?n.parent=null:Kn(n,t),n=r}}function Gn(e){for(var t=e.first;t!==null;){var n=t.next;t.f&32||Kn(t),t=n}}function Kn(e,t=!0){var n=!1;(t||e.f&262144)&&e.nodes!==null&&e.nodes.end!==null&&(qn(e.nodes.start,e.nodes.end),n=!0),ot(e,ee),Wn(e,t&&!n),wr(e,0);var r=e.nodes&&e.nodes.t;if(r!==null)for(let e of r)e.stop();Un(e),e.f^=ee,e.f|=C;var i=e.parent;i!==null&&i.first!==null&&Jn(e),e.next=e.prev=e.teardown=e.ctx=e.deps=e.fn=e.nodes=e.ac=e.b=null}function qn(e,t){for(;e!==null;){var n=e===t?null:yn(e);e.remove(),e=n}}function Jn(e){var t=e.parent,n=e.prev,r=e.next;n!==null&&(n.next=r),r!==null&&(r.prev=n),t!==null&&(t.first===e&&(t.first=r),t.last===e&&(t.last=n))}function Yn(e,t,n=!0){var r=[];Xn(e,r,!0);var i=()=>{n&&Kn(e),t&&t()},a=r.length;if(a>0){var o=()=>--a||i();for(var s of r)s.out(o)}else i()}function Xn(e,t,n){if(!(e.f&8192)){e.f^=S;var r=e.nodes&&e.nodes.t;if(r!==null)for(let e of r)(e.is_global||n)&&t.push(e);for(var i=e.first;i!==null;){var a=i.next;if(!(i.f&64)){var o=(i.f&65536)!=0||(i.f&32)!=0&&(e.f&16)!=0;Xn(i,t,o?n:!1)}i=a}}}function Zn(e){Qn(e,!0)}function Qn(e,t){if(e.f&8192){e.f^=S,e.f&1024||(ot(e,b),Tt.ensure().schedule(e));for(var n=e.first;n!==null;){var r=n.next,i=(n.f&65536)!=0||(n.f&32)!=0;Qn(n,i?t:!1),n=r}var a=e.nodes&&e.nodes.t;if(a!==null)for(let e of a)(e.is_global||t)&&e.in()}}function $n(e,t){if(e.nodes)for(var n=e.nodes.start,r=e.nodes.end;n!==null;){var i=n===r?null:yn(n);t.append(n),n=i}}var er=null,tr=!1,nr=!1;function rr(e){nr=e}var ir=null,ar=!1;function or(e){ir=e}var sr=null;function cr(e){sr=e}var lr=null;function ur(e){ir!==null&&(!qe||ir.f&2)&&(lr===null?lr=[e]:lr.push(e))}var dr=null,fr=0,pr=null;function mr(e){pr=e}var hr=1,gr=0,_r=gr;function vr(e){_r=e}function yr(){return++hr}function br(e){var t=e.f;if(t&2048)return!0;if(t&2&&(e.f&=~D),t&4096){for(var n=e.deps,r=n.length,i=0;i<r;i++){var a=n[i];if(br(a)&&Yt(a),a.wv>e.wv)return!0}t&512&&_t===null&&ot(e,y)}return!1}function xr(e,t,n=!0){var r=e.reactions;if(r!==null&&!(!qe&&lr!==null&&i.call(lr,e)))for(var a=0;a<r.length;a++){var o=r[a];o.f&2?xr(o,t,!1):t===o&&(n?ot(o,b):o.f&1024&&ot(o,x),Mt(o))}}function Sr(e){var t=dr,n=fr,r=pr,i=ir,a=lr,o=Xe,s=ar,c=_r,l=e.f;dr=null,fr=0,pr=null,ir=l&96?null:e,lr=null,Ze(e.ctx),ar=!1,_r=++gr,e.ac!==null&&(On(()=>{e.ac.abort(me)}),e.ac=null);try{e.f|=re;var u=e.fn,d=u();e.f|=w;var f=e.deps,p=ht?.is_fork;if(dr!==null){var m;if(p||wr(e,fr),f!==null&&fr>0)for(f.length=fr+dr.length,m=0;m<dr.length;m++)f[fr+m]=dr[m];else e.deps=f=dr;if(Nn()&&e.f&512)for(m=fr;m<f.length;m++)(f[m].reactions??=[]).push(e)}else !p&&f!==null&&fr<f.length&&(wr(e,fr),f.length=fr);if(Qe()&&pr!==null&&!ar&&f!==null&&!(e.f&6146))for(m=0;m<pr.length;m++)xr(pr[m],e);if(i!==null&&i!==e){if(gr++,i.deps!==null)for(let e=0;e<n;e+=1)i.deps[e].rv=gr;if(t!==null)for(let e of t)e.rv=gr;pr!==null&&(r===null?r=pr:r.push(...pr))}return e.f&8388608&&(e.f^=ae),d}catch(e){return rt(e)}finally{e.f^=re,dr=t,fr=n,pr=r,ir=i,lr=a,Ze(o),ar=s,_r=c}}function Cr(e,t){let n=t.reactions;if(n!==null){var a=r.call(n,e);if(a!==-1){var o=n.length-1;o===0?n=t.reactions=null:(n[a]=n[o],n.pop())}}if(n===null&&t.f&2&&(dr===null||!i.call(dr,t))){var s=t;s.f&512&&(s.f^=512,s.f&=~D),s.v!==ke&&st(s),Xt(s),wr(s,0)}}function wr(e,t){var n=e.deps;if(n!==null)for(var r=t;r<n.length;r++)Cr(e,n[r])}function Tr(e){var t=e.f;if(!(t&16384)){ot(e,y);var n=sr,r=tr;sr=e,tr=!0;try{t&16777232?Gn(e):Wn(e),Un(e);var i=Sr(e);e.teardown=typeof i==`function`?i:null,e.wv=hr}finally{tr=r,sr=n}}}async function Er(){if(qe)return new Promise(e=>{requestAnimationFrame(()=>e()),setTimeout(()=>e())});await Promise.resolve(),Et()}function B(e){var t=(e.f&2)!=0;if(er?.add(e),ir!==null&&!ar&&!(sr!==null&&sr.f&16384)&&(lr===null||!i.call(lr,e))){var n=ir.deps;if(ir.f&2097152)e.rv<gr&&(e.rv=gr,dr===null&&n!==null&&n[fr]===e?fr++:dr===null?dr=[e]:dr.push(e));else{(ir.deps??=[]).push(e);var r=e.reactions;r===null?e.reactions=[ir]:i.call(r,ir)||r.push(ir)}}if(nr&&$t.has(e))return $t.get(e);if(t){var a=e;if(nr){var o=a.v;return(!(a.f&1024)&&a.reactions!==null||Or(a))&&(o=Jt(a)),$t.set(a,o),o}var s=(a.f&512)==0&&!ar&&ir!==null&&(tr||(ir.f&512)!=0),c=(a.f&w)===0;br(a)&&(s&&(a.f|=512),Yt(a)),s&&!c&&(Zt(a),Dr(a))}if(_t?.has(e))return _t.get(e);if(e.f&8388608)throw e.v;return e.v}function Dr(e){if(e.f|=512,e.deps!==null)for(let t of e.deps)(t.reactions??=[]).push(e),t.f&2&&!(t.f&512)&&(Zt(t),Dr(t))}function Or(e){if(e.v===ke)return!0;if(e.deps===null)return!1;for(let t of e.deps)if($t.has(t)||t.f&2&&Or(t))return!0;return!1}function kr(e){var t=ar;try{return ar=!0,e()}finally{ar=t}}function Ar(e){if(!(typeof e!=`object`||!e||e instanceof EventTarget)){if(oe in e)jr(e);else if(!Array.isArray(e))for(let t in e){let n=e[t];typeof n==`object`&&n&&oe in n&&jr(n)}}}function jr(e,t=new Set){if(typeof e==`object`&&e&&!(e instanceof EventTarget)&&!t.has(e)){t.add(e),e instanceof Date&&e.getTime();for(let n in e)try{jr(e[n],t)}catch{}let n=d(e);if(n!==Object.prototype&&n!==Array.prototype&&n!==Map.prototype&&n!==Set.prototype&&n!==Date.prototype){let t=c(n);for(let n in t){let r=t[n].get;if(r)try{r.call(e)}catch{}}}}}[...`allowfullscreen.async.autofocus.autoplay.checked.controls.default.disabled.formnovalidate.indeterminate.inert.ismap.loop.multiple.muted.nomodule.novalidate.open.playsinline.readonly.required.reversed.seamless.selected.webkitdirectory.defer.disablepictureinpicture.disableremoteplayback`.split(`.`)];var Mr=[`touchstart`,`touchmove`];function Nr(e){return Mr.includes(e)}var Pr=Symbol(`events`),Fr=new Set,Ir=new Set;function Lr(e,t,n,r={}){function i(e){if(r.capture||Vr.call(t,e),!e.cancelBubble)return On(()=>n?.call(this,e))}return e.startsWith(`pointer`)||e.startsWith(`touch`)||e===`wheel`?tt(()=>{t.addEventListener(e,i,r)}):t.addEventListener(e,i,r),i}function Rr(e,t,n,r,i){var a={capture:r,passive:i},o=Lr(e,t,n,a);(t===document.body||t===window||t===document||t instanceof HTMLMediaElement)&&Pn(()=>{t.removeEventListener(e,o,a)})}function V(e,t,n){(t[Pr]??={})[e]=n}function zr(e){for(var t=0;t<e.length;t++)Fr.add(e[t]);for(var n of Ir)n(e)}var Br=null;function Vr(e){var t=this,n=t.ownerDocument,r=e.type,i=e.composedPath?.()||[],a=i[0]||e.target;Br=e;var s=0,c=Br===e&&e[Pr];if(c){var l=i.indexOf(c);if(l!==-1&&(t===document||t===window)){e[Pr]=t;return}var u=i.indexOf(t);if(u===-1)return;l<=u&&(s=l)}if(a=i[s]||e.target,a!==t){o(e,`currentTarget`,{configurable:!0,get(){return a||n}});var d=ir,f=sr;or(null),cr(null);try{for(var p,m=[];a!==null;){var h=a.assignedSlot||a.parentNode||a.host||null;try{var g=a[Pr]?.[r];g!=null&&(!a.disabled||e.target===a)&&g.call(a,e)}catch(e){p?m.push(e):p=e}if(e.cancelBubble||h===t||h===null)break;a=h}if(p){for(let e of m)queueMicrotask(()=>{throw e});throw p}}finally{e[Pr]=t,delete e.currentTarget,or(d),cr(f)}}}var Hr=globalThis?.window?.trustedTypes&&globalThis.window.trustedTypes.createPolicy(`svelte-trusted-html`,{createHTML:e=>e});function Ur(e){return Hr?.createHTML(e)??e}function Wr(e){var t=Sn(`template`);return t.innerHTML=Ur(e.replaceAll(`<!>`,`<!---->`)),t.content}function Gr(e,t){var n=sr;n.nodes===null&&(n.nodes={start:e,end:t,a:null,t:null})}function H(e,t){var n=(t&1)!=0,r=(t&2)!=0,i,a=!e.startsWith(`<!>`);return()=>{if(Le)return Gr(ze,null),ze;i===void 0&&(i=Wr(a?e:`<!>`+e),n||(i=vn(i)));var t=r||pn?document.importNode(i,!0):i.cloneNode(!0);if(n){var o=vn(t),s=t.lastChild;Gr(o,s)}else Gr(t,t);return t}}function Kr(e,t,n=`svg`){var r=!e.startsWith(`<!>`),i=(t&1)!=0,a=`<${n}>${r?e:`<!>`+e}</${n}>`,o;return()=>{if(Le)return Gr(ze,null),ze;if(!o){var e=vn(Wr(a));if(i)for(o=document.createDocumentFragment();vn(e);)o.appendChild(vn(e));else o=vn(e)}var t=o.cloneNode(!0);if(i){var n=vn(t),r=t.lastChild;Gr(n,r)}else Gr(t,t);return t}}function qr(e,t){return Kr(e,t,`svg`)}function Jr(e=``){if(!Le){var t=_n(e+``);return Gr(t,t),t}var n=ze;return n.nodeType===3?Cn(n):(n.before(n=_n()),Be(n)),Gr(n,n),n}function Yr(){if(Le)return Gr(ze,null),ze;var e=document.createDocumentFragment(),t=document.createComment(``),n=_n();return e.append(t,n),Gr(t,n),e}function U(e,t){if(Le){var n=sr;(!(n.f&32768)||n.nodes.end===null)&&(n.nodes.end=ze),Ve();return}e!==null&&e.before(t)}var Xr=!0;function W(e,t){var n=t==null?``:typeof t==`object`?`${t}`:t;n!==(e[fe]??=e.nodeValue)&&(e[fe]=n,e.nodeValue=`${n}`)}function Zr(e,t){return $r(e,t)}var Qr=new Map;function $r(e,{target:t,anchor:n,props:r={},events:i,context:o,intro:s=!0,transformError:c}){gn();var l=void 0,u=Ln(()=>{var u=n??t.appendChild(_n());Lt(u,{pending:()=>{}},t=>{A({});var n=Xe;if(o&&(n.c=o),i&&(r.$$events=i),Le&&Gr(t,null),Xr=s,l=e(t,r)||{},Xr=!0,Le&&(sr.nodes.end=ze,ze===null||ze.nodeType!==8||ze.data!==`]`))throw Pe(),Oe;j()},c);var d=new Set,f=e=>{for(var n=0;n<e.length;n++){var r=e[n];if(!d.has(r)){d.add(r);var i=Nr(r);for(let e of[t,document]){var a=Qr.get(e);a===void 0&&(a=new Map,Qr.set(e,a));var o=a.get(r);o===void 0?(e.addEventListener(r,Vr,{passive:i}),a.set(r,1)):a.set(r,o+1)}}}};return f(a(Fr)),Ir.add(f),()=>{for(var e of d)for(let n of[t,document]){var r=Qr.get(n),i=r.get(e);--i==0?(n.removeEventListener(e,Vr),r.delete(e),r.size===0&&Qr.delete(n)):r.set(e,i)}Ir.delete(f),u!==n&&u.parentNode?.removeChild(u)}});return ei.set(l,u),l}var ei=new WeakMap,ti=class{anchor;#e=new Map;#t=new Map;#n=new Map;#r=new Set;#i=!0;constructor(e,t=!0){this.anchor=e,this.#i=t}#a=e=>{if(this.#e.has(e)){var t=this.#e.get(e),n=this.#t.get(t);if(n)Zn(n),this.#r.delete(t);else{var r=this.#n.get(t);r&&(this.#t.set(t,r.effect),this.#n.delete(t),r.fragment.lastChild.remove(),this.anchor.before(r.fragment),n=r.effect)}for(let[t,n]of this.#e){if(this.#e.delete(t),t===e)break;let r=this.#n.get(n);r&&(Kn(r.effect),this.#n.delete(n))}for(let[e,r]of this.#t){if(e===t||this.#r.has(e))continue;let i=()=>{if(Array.from(this.#e.values()).includes(e)){var t=document.createDocumentFragment();$n(r,t),t.append(_n()),this.#n.set(e,{effect:r,fragment:t})}else Kn(r);this.#r.delete(e),this.#t.delete(e)};this.#i||!n?(this.#r.add(e),Yn(r,i,!1)):i()}}};#o=e=>{this.#e.delete(e);let t=Array.from(this.#e.values());for(let[e,n]of this.#n)t.includes(e)||(Kn(n.effect),this.#n.delete(e))};ensure(e,t){var n=ht,r=xn();if(t&&!this.#t.has(e)&&!this.#n.has(e))if(r){var i=document.createDocumentFragment(),a=_n();i.append(a),this.#n.set(e,{effect:Hn(()=>t(a)),fragment:i})}else this.#t.set(e,Hn(()=>t(this.anchor)));if(this.#e.set(n,e),r){for(let[t,r]of this.#t)t===e?n.unskip_effect(r):n.skip_effect(r);for(let[t,r]of this.#n)t===e?n.unskip_effect(r.effect):n.skip_effect(r.effect);n.oncommit(this.#a),n.ondiscard(this.#o)}else Le&&(this.anchor=ze),this.#a(n)}},ni=0,ri=1,ii=2;function ai(e,t,n,r,i){Le&&Ve();var a=Qe(),o=ke,s=a?tn(o):nn(o,!1,!1),c=a?tn(o):nn(o,!1,!1),l=new ti(e);Vn(()=>{var a=ht;a.deactivate();var o=t();a.activate();var u=!1;let d=Le&&h(o)===(e.data===`[!`);if(d&&(Be(He()),Re(!1)),h(o)){var f=Bt(),p=!1;let e=e=>{if(!u){p=!0,f(!1),Tt.ensure(),Le&&Re(!1);try{e()}finally{Vt(!1),yt||Et()}}};o.then(t=>{e(()=>{rn(s,t),l.ensure(ri,r&&(e=>r(e,s)))})},t=>{e(()=>{if(rn(c,t),l.ensure(ii,i&&(e=>i(e,c))),!i)throw c.v})}),Le?l.ensure(ni,n):tt(()=>{p||e(()=>{l.ensure(ni,n)})})}else rn(s,o),l.ensure(ri,r&&(e=>r(e,s)));return d&&Re(!0),()=>{u=!0}})}function G(e,t,n=!1){var r;Le&&(r=ze,Ve());var i=new ti(e),a=n?T:0;function o(e,t){if(Le){var n=Ue(r);if(e!==parseInt(n.substring(1))){var a=He();Be(a),i.anchor=a,Re(!1),i.ensure(e,t),Re(!0);return}}i.ensure(e,t)}Vn(()=>{var e=!1;t((t,n=0)=>{e=!0,o(n,t)}),e||o(-1,null)},a)}var oi=Symbol(`NaN`);function si(e,t,n){Le&&Ve();var r=new ti(e),i=!Qe();Vn(()=>{var e=t();e!==e&&(e=oi),i&&typeof e==`object`&&e&&(e={}),r.ensure(e,n)})}function ci(e,t){return t}function li(e,t,n){for(var r=[],i=t.length,o,s=t.length,c=0;c<i;c++){let n=t[c];Yn(n,()=>{if(o){if(o.pending.delete(n),o.done.add(n),o.pending.size===0){var t=e.outrogroups;ui(e,a(o.done)),t.delete(o),t.size===0&&(e.outrogroups=null)}}else --s},!1)}if(s===0){var l=r.length===0&&n!==null;if(l){var u=n,d=u.parentNode;bn(d),d.append(u),e.items.clear()}ui(e,t,!l)}else o={pending:new Set(t),done:new Set},(e.outrogroups??=new Set).add(o)}function ui(e,t,n=!0){var r;if(e.pending.size>0){r=new Set;for(let t of e.pending.values())for(let n of t)r.add(e.items.get(n).e)}for(var i=0;i<t.length;i++){var a=t[i];r?.has(a)?(a.f|=ne,$n(a,document.createDocumentFragment())):Kn(t[i],n)}}var di;function fi(e,t,r,i,o,s=null){var c=e,l=new Map;if(t&4){var u=e;c=Le?Be(vn(u)):u.appendChild(_n())}Le&&Ve();var d=null,f=Kt(()=>{var e=r();return n(e)?e:e==null?[]:a(e)}),p,m=new Map,h=!0;function g(e){v.effect.f&16384||(v.pending.delete(e),v.fallback=d,mi(v,p,c,t,i),d!==null&&(p.length===0?d.f&33554432?(d.f^=ne,gi(d,null,c)):Zn(d):Yn(d,()=>{d=null})))}function _(e){v.pending.delete(e)}var v={effect:Vn(()=>{p=B(f);var e=p.length;let n=!1;Le&&Ue(c)===`[!`!=(e===0)&&(c=He(),Be(c),Re(!1),n=!0);for(var a=new Set,u=ht,v=xn(),y=0;y<e;y+=1){Le&&ze.nodeType===8&&ze.data===`]`&&(c=ze,n=!0,Re(!1));var b=p[y],x=i(b,y),S=h?null:l.get(x);S?(S.v&&rn(S.v,b),S.i&&rn(S.i,y),v&&u.unskip_effect(S.e)):(S=hi(l,h?c:di??=_n(),b,x,y,o,t,r),h||(S.e.f|=ne),l.set(x,S)),a.add(x)}if(e===0&&s&&!d&&(h?d=Hn(()=>s(c)):(d=Hn(()=>s(di??=_n())),d.f|=ne)),e>a.size&&ve(``,``,``),Le&&e>0&&Be(He()),!h)if(m.set(u,a),v){for(let[e,t]of l)a.has(e)||u.skip_effect(t.e);u.oncommit(g),u.ondiscard(_)}else g(u);n&&Re(!0),B(f)}),flags:t,items:l,pending:m,outrogroups:null,fallback:d};h=!1,Le&&(c=ze)}function pi(e){for(;e!==null&&!(e.f&32);)e=e.next;return e}function mi(e,t,n,r,i){var o=(r&8)!=0,s=t.length,c=e.items,l=pi(e.effect.first),u,d=null,f,p=[],m=[],h,g,_,v;if(o)for(v=0;v<s;v+=1)h=t[v],g=i(h,v),_=c.get(g).e,_.f&33554432||(_.nodes?.a?.measure(),(f??=new Set).add(_));for(v=0;v<s;v+=1){if(h=t[v],g=i(h,v),_=c.get(g).e,e.outrogroups!==null)for(let t of e.outrogroups)t.pending.delete(_),t.done.delete(_);if(_.f&8192&&(Zn(_),o&&(_.nodes?.a?.unfix(),(f??=new Set).delete(_))),_.f&33554432)if(_.f^=ne,_===l)gi(_,null,n);else{var y=d?d.next:l;_===e.effect.last&&(e.effect.last=_.prev),_.prev&&(_.prev.next=_.next),_.next&&(_.next.prev=_.prev),_i(e,d,_),_i(e,_,y),gi(_,y,n),d=_,p=[],m=[],l=pi(d.next);continue}if(_!==l){if(u!==void 0&&u.has(_)){if(p.length<m.length){var b=m[0],x;d=b.prev;var S=p[0],C=p[p.length-1];for(x=0;x<p.length;x+=1)gi(p[x],b,n);for(x=0;x<m.length;x+=1)u.delete(m[x]);_i(e,S.prev,C.next),_i(e,d,S),_i(e,C,b),l=b,d=C,--v,p=[],m=[]}else u.delete(_),gi(_,l,n),_i(e,_.prev,_.next),_i(e,_,d===null?e.effect.first:d.next),_i(e,d,_),d=_;continue}for(p=[],m=[];l!==null&&l!==_;)(u??=new Set).add(l),m.push(l),l=pi(l.next);if(l===null)continue}_.f&33554432||p.push(_),d=_,l=pi(_.next)}if(e.outrogroups!==null){for(let t of e.outrogroups)t.pending.size===0&&(ui(e,a(t.done)),e.outrogroups?.delete(t));e.outrogroups.size===0&&(e.outrogroups=null)}if(l!==null||u!==void 0){var w=[];if(u!==void 0)for(_ of u)_.f&8192||w.push(_);for(;l!==null;)!(l.f&8192)&&l!==e.fallback&&w.push(l),l=pi(l.next);var ee=w.length;if(ee>0){var T=r&4&&s===0?n:null;if(o){for(v=0;v<ee;v+=1)w[v].nodes?.a?.measure();for(v=0;v<ee;v+=1)w[v].nodes?.a?.fix()}li(e,w,T)}}o&&tt(()=>{if(f!==void 0)for(_ of f)_.nodes?.a?.apply()})}function hi(e,t,n,r,i,a,o,s){var c=o&1?o&16?tn(n):nn(n,!1,!1):null,l=o&2?tn(i):null;return{v:c,i:l,e:Hn(()=>(a(t,c??n,l??i,s),()=>{e.delete(r)}))}}function gi(e,t,n){if(e.nodes)for(var r=e.nodes.start,i=e.nodes.end,a=t&&!(t.f&33554432)?t.nodes.start:n;r!==null;){var o=yn(r);if(a.before(r),r===i)return;r=o}}function _i(e,t,n){t===null?e.effect.first=n:t.next=n,n===null?e.effect.last=t:n.prev=t}function vi(e,t,n=!1,r=!1,i=!1,a=!1){var o=e,s=``;if(n){var c=e;Le&&(o=Be(vn(c)))}z(()=>{var e=sr;if(s===(s=t()??``)){Le&&Ve();return}if(n&&!Le){e.nodes=null,c.innerHTML=s,s!==``&&Gr(vn(c),c.lastChild);return}if(e.nodes!==null&&(qn(e.nodes.start,e.nodes.end),e.nodes=null),s!==``){if(Le){for(var a=ze.data,l=Ve(),u=l;l!==null&&(l.nodeType!==8||l.data!==``);)u=l,l=yn(l);if(l===null)throw Pe(),Oe;Gr(ze,u),o=Be(l);return}var d=Sn(r?`svg`:i?`math`:`template`,r?je:i?Me:void 0);d.innerHTML=s;var f=r||i?d:d.content;if(Gr(vn(f),f.lastChild),r||i)for(;vn(f);)o.before(vn(f));else o.before(f)}})}function yi(e,t,...n){var r=new ti(e);Vn(()=>{let e=t()??null;r.ensure(e,e&&(t=>e(t,...n)))},T)}function bi(e,t,n){var r;Le&&(r=ze,Ve());var i=new ti(e);Vn(()=>{var e=t()??null;if(Le&&Ue(r)===`[`!=(e!==null)){var a=He();Be(a),i.anchor=a,Re(!1),i.ensure(e,e&&(t=>n(t,e))),Re(!0);return}i.ensure(e,e&&(t=>n(t,e)))},T)}var xi=()=>performance.now(),Si={tick:e=>requestAnimationFrame(e),now:()=>xi(),tasks:new Set};function Ci(){let e=Si.now();Si.tasks.forEach(t=>{t.c(e)||(Si.tasks.delete(t),t.f())}),Si.tasks.size!==0&&Si.tick(Ci)}function wi(e){let t;return Si.tasks.size===0&&Si.tick(Ci),{promise:new Promise(n=>{Si.tasks.add(t={c:e,f:n})}),abort(){Si.tasks.delete(t)}}}function Ti(e,t){On(()=>{e.dispatchEvent(new CustomEvent(t))})}function Ei(e){if(e===`float`)return`cssFloat`;if(e===`offset`)return`cssOffset`;if(e.startsWith(`--`))return e;let t=e.split(`-`);return t.length===1?t[0]:t[0]+t.slice(1).map(e=>e[0].toUpperCase()+e.slice(1)).join(``)}function Di(e){let t={},n=e.split(`;`);for(let e of n){let[n,r]=e.split(`:`);if(!n||r===void 0)break;let i=Ei(n.trim());t[i]=r.trim()}return t}var Oi=e=>e,ki=null;function Ai(e,t,n){var r=(ki??sr).nodes,i,a,o,s=null;r.a??={element:e,measure(){i=this.element.getBoundingClientRect()},apply(){if(o?.abort(),a=this.element.getBoundingClientRect(),i.left!==a.left||i.right!==a.right||i.top!==a.top||i.bottom!==a.bottom){let e=t()(this.element,{from:i,to:a},n?.());o=Mi(this.element,e,void 0,1,()=>{},()=>{o?.abort(),o=void 0})}},fix(){if(!e.getAnimations().length){var{position:t,width:n,height:r}=getComputedStyle(e);if(t!==`absolute`&&t!==`fixed`){var a=e.style;s={position:a.position,width:a.width,height:a.height,transform:a.transform},a.position=`absolute`,a.width=n,a.height=r;var o=e.getBoundingClientRect();if(i.left!==o.left||i.top!==o.top){var c=`translate(${i.left-o.left}px, ${i.top-o.top}px)`;a.transform=a.transform?`${a.transform} ${c}`:c}}}},unfix(){if(s){var t=e.style;t.position=s.position,t.width=s.width,t.height=s.height,t.transform=s.transform}}},r.a.element=e}function ji(e,t,n,r){var i=(e&1)!=0,a=(e&2)!=0,o=i&&a,s=(e&4)!=0,c=o?`both`:i?`in`:`out`,l,u=t.inert,d=t.style.overflow,f,p;function m(){return On(()=>l??=n()(t,r?.()??{},{direction:c}))}var h={is_global:s,in(){if(t.inert=u,!i){p?.abort(),p?.reset?.();return}a||f?.abort(),f=Mi(t,m(),p,1,()=>{Ti(t,`introstart`)},()=>{Ti(t,`introend`),f?.abort(),f=l=void 0,t.style.overflow=d})},out(e){if(!a){e?.(),l=void 0;return}t.inert=!0,p=Mi(t,m(),f,0,()=>{Ti(t,`outrostart`)},()=>{Ti(t,`outroend`),e?.()})},stop:()=>{f?.abort(),p?.abort()}},g=sr;if((g.nodes.t??=[]).push(h),i&&Xr){var _=s;if(!_){for(var v=g.parent;v&&v.f&65536;)for(;(v=v.parent)&&!(v.f&16););_=!v||(v.f&32768)!=0}_&&Rn(()=>{kr(()=>h.in())})}}function Mi(e,t,n,r,i,a){var o=r===1;if(p(t)){var s,c=!1;return tt(()=>{c||(s=Mi(e,t({direction:o?`in`:`out`}),n,r,i,a))}),{abort:()=>{c=!0,s?.abort()},deactivate:()=>s.deactivate(),reset:()=>s.reset(),t:()=>s.t()}}if(n?.deactivate(),!t?.duration&&!t?.delay)return i(),a(),{abort:m,deactivate:m,reset:m,t:()=>r};let{delay:l=0,css:u,tick:d,easing:f=Oi}=t;var h=[];if(o&&n===void 0&&(d&&d(0,1),u)){var g=Di(u(0,1));h.push(g,g)}var _=()=>1-r,v=e.animate(h,{duration:l,fill:`forwards`});return v.onfinish=()=>{v.cancel(),i();var o=n?.t()??1-r;n?.abort();var s=r-o,c=t.duration*Math.abs(s),l=[];if(c>0){var p=!1;if(u)for(var m=Math.ceil(c/(1e3/60)),h=0;h<=m;h+=1){var g=o+s*f(h/m),y=Di(u(g,1-g));l.push(y),p||=y.overflow===`hidden`}p&&(e.style.overflow=`hidden`),_=()=>{var e=v.currentTime;return o+s*f(e/c)},d&&wi(()=>{if(v.playState!==`running`)return!1;var e=_();return d(e,1-e),!0})}v=e.animate(l,{duration:c,fill:`forwards`}),v.onfinish=()=>{_=()=>r,d?.(r,1-r),a()}},{abort:()=>{v&&(v.cancel(),v.effect=null,v.onfinish=m)},deactivate:()=>{a=m},reset:()=>{r===0&&d?.(1,0)},t:()=>_()}}function Ni(e,t,n){Rn(()=>{var r=kr(()=>t(e,n?.())||{});if(n&&r?.update){var i=!1,a={};Bn(()=>{var e=n();Ar(e),i&&Ge(a,e)&&(a=e,r.update(e))}),i=!0}if(r?.destroy)return()=>r.destroy()})}function Pi(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`)if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=Pi(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n);return r}function Fi(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=Pi(e))&&(r&&(r+=` `),r+=t);return r}function Ii(e){return typeof e==`object`?Fi(e):e??``}var Li=[...`
3
+ \r\f\xA0\v`];function Ri(e,t,n){var r=e==null?``:``+e;if(t&&(r=r?r+` `+t:t),n){for(var i of Object.keys(n))if(n[i])r=r?r+` `+i:i;else if(r.length)for(var a=i.length,o=0;(o=r.indexOf(i,o))>=0;){var s=o+a;(o===0||Li.includes(r[o-1]))&&(s===r.length||Li.includes(r[s]))?r=(o===0?``:r.substring(0,o))+r.substring(s+1):o=s}}return r===``?null:r}function zi(e,t=!1){var n=t?` !important;`:`;`,r=``;for(var i of Object.keys(e)){var a=e[i];a!=null&&a!==``&&(r+=` `+i+`: `+a+n)}return r}function Bi(e){return e[0]!==`-`||e[1]!==`-`?e.toLowerCase():e}function Vi(e,t){if(t){var n=``,r,i;if(Array.isArray(t)?(r=t[0],i=t[1]):r=t,e){e=String(e).replaceAll(/\s*\/\*.*?\*\/\s*/g,``).trim();var a=!1,o=0,s=!1,c=[];r&&c.push(...Object.keys(r).map(Bi)),i&&c.push(...Object.keys(i).map(Bi));var l=0,u=-1;let t=e.length;for(var d=0;d<t;d++){var f=e[d];if(s?f===`/`&&e[d-1]===`*`&&(s=!1):a?a===f&&(a=!1):f===`/`&&e[d+1]===`*`?s=!0:f===`"`||f===`'`?a=f:f===`(`?o++:f===`)`&&o--,!s&&a===!1&&o===0){if(f===`:`&&u===-1)u=d;else if(f===`;`||d===t-1){if(u!==-1){var p=Bi(e.substring(l,u).trim());if(!c.includes(p)){f!==`;`&&d++;var m=e.substring(l,d).trim();n+=` `+m+`;`}}l=d+1,u=-1}}}}return r&&(n+=zi(r)),i&&(n+=zi(i,!0)),n=n.trim(),n===``?null:n}return e==null?null:String(e)}function Hi(e,t,n,r,i,a){var o=e[ue];if(Le||o!==n||o===void 0){var s=Ri(n,r,a);(!Le||s!==e.getAttribute(`class`))&&(s==null?e.removeAttribute(`class`):t?e.className=s:e.setAttribute(`class`,s)),e[ue]=n}else if(a&&i!==a)for(var c in a){var l=!!a[c];(i==null||l!==!!i[c])&&e.classList.toggle(c,l)}return a}function Ui(e,t={},n,r){for(var i in n){var a=n[i];t[i]!==a&&(n[i]==null?e.style.removeProperty(i):e.style.setProperty(i,a,r))}}function K(e,t,n,r){var i=e[de];if(Le||i!==t){var a=Vi(t,r);(!Le||a!==e.getAttribute(`style`))&&(a==null?e.removeAttribute(`style`):e.style.cssText=a),e[de]=t}else r&&(Array.isArray(r)?(Ui(e,n?.[0],r[0]),Ui(e,n?.[1],r[1],`important`)):Ui(e,n,r));return r}function Wi(e,t,r=!1){if(e.multiple){if(t==null)return;if(!n(t))return Fe();for(var i of e.options)i.selected=t.includes(qi(i));return}for(i of e.options)if(dn(qi(i),t)){i.selected=!0;return}(!r||t!==void 0)&&(e.selectedIndex=-1)}function Gi(e){var t=new MutationObserver(()=>{Wi(e,e.__value)});t.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`value`]}),Pn(()=>{t.disconnect()})}function Ki(e,t,n=t){var r=new WeakSet,i=!0;kn(e,`change`,t=>{var i=t?`[selected]`:`:checked`,a;if(e.multiple)a=[].map.call(e.querySelectorAll(i),qi);else{var o=e.querySelector(i)??e.querySelector(`option:not([disabled])`);a=o&&qi(o)}n(a),e.__value=a,ht!==null&&r.add(ht)}),Rn(()=>{var a=t();if(e===document.activeElement){var o=qe?gt:ht;if(r.has(o))return}if(Wi(e,a,i),i&&a===void 0){var s=e.querySelector(`:checked`);s!==null&&(a=qi(s),n(a))}e.__value=a,i=!1}),Gi(e)}function qi(e){return`__value`in e?e.__value:e.value}var Ji=Symbol(`is custom element`),Yi=Symbol(`is html`),Xi=he?`link`:`LINK`,Zi=he?`progress`:`PROGRESS`;function Qi(e){if(Le){var t=!1,n=()=>{if(!t){if(t=!0,e.hasAttribute(`value`)){var n=e.value;q(e,`value`,null),e.value=n}if(e.hasAttribute(`checked`)){var r=e.checked;q(e,`checked`,null),e.checked=r}}};e[pe]=n,tt(n),Dn()}}function $i(e,t){var n=ta(e);n.value===(n.value=t??void 0)||e.value===t&&(t!==0||e.nodeName!==Zi)||(e.value=t??``)}function ea(e,t){var n=ta(e);n.checked!==(n.checked=t??void 0)&&(e.checked=t)}function q(e,t,n,r){var i=ta(e);Le&&(i[t]=e.getAttribute(t),t===`src`||t===`srcset`||t===`href`&&e.nodeName===Xi)||i[t]!==(i[t]=n)&&(t===`loading`&&(e[ce]=n),n==null?e.removeAttribute(t):typeof n!=`string`&&ra(e).includes(t)?e[t]=n:e.setAttribute(t,n))}function ta(e){return e[le]??={[Ji]:e.nodeName.includes(`-`),[Yi]:e.namespaceURI===Ae}}var na=new Map;function ra(e){var t=e.getAttribute(`is`)||e.nodeName,n=na.get(t);if(n)return n;na.set(t,n=[]);for(var r,i=e,a=Element.prototype;a!==i;){for(var o in r=c(i),r)r[o].set&&o!==`innerHTML`&&o!==`textContent`&&o!==`innerText`&&n.push(o);i=d(i)}return n}function ia(e,t,n=t){var r=new WeakSet;kn(e,`input`,async i=>{var a=i?e.defaultValue:e.value;if(a=oa(e)?sa(a):a,n(a),ht!==null&&r.add(ht),await Er(),a!==(a=t())){var o=e.selectionStart,s=e.selectionEnd,c=e.value.length;if(e.value=a??``,s!==null){var l=e.value.length;o===s&&s===c&&l>c?(e.selectionStart=l,e.selectionEnd=l):(e.selectionStart=o,e.selectionEnd=Math.min(s,l))}}}),(Le&&e.defaultValue!==e.value||kr(t)==null&&e.value)&&(n(oa(e)?sa(e.value):e.value),ht!==null&&r.add(ht)),Bn(()=>{var n=t();if(e===document.activeElement){var i=qe?gt:ht;if(r.has(i))return}oa(e)&&n===sa(e.value)||e.type===`date`&&!n&&!e.value||n!==e.value&&(e.value=n??``)})}function aa(e,t,n=t){kn(e,`change`,t=>{n(t?e.defaultChecked:e.checked)}),(Le&&e.defaultChecked!==e.checked||kr(t)==null)&&n(e.checked),Bn(()=>{e.checked=!!t()})}function oa(e){var t=e.type;return t===`number`||t===`range`}function sa(e){return e===``?null:+e}var ca=new class e{#e=new WeakMap;#t;#n;static entries=new WeakMap;constructor(e){this.#n=e}observe(e,t){var n=this.#e.get(e)||new Set;return n.add(t),this.#e.set(e,n),this.#r().observe(e,this.#n),()=>{var n=this.#e.get(e);n.delete(t),n.size===0&&(this.#e.delete(e),this.#t.unobserve(e))}}#r(){return this.#t??=new ResizeObserver(t=>{for(var n of t){e.entries.set(n.target,n);for(var r of this.#e.get(n.target)||[])r(n)}})}}({box:`border-box`});function la(e,t,n){var r=ca.observe(e,()=>n(e[t]));Rn(()=>(kr(()=>n(e[t])),r))}function ua(e,t){return e===t||e?.[oe]===t}function da(e={},t,n,r){var i=Xe.r,a=sr;return Rn(()=>{var o,s;return Bn(()=>{o=s,s=r?.()||[],kr(()=>{ua(n(...s),e)||(t(e,...s),o&&ua(n(...o),e)&&t(null,...o))})}),()=>{let r=a;for(;r!==i&&r.parent!==null&&r.parent.f&33554432;)r=r.parent;let o=()=>{s&&ua(n(...s),e)&&t(null,...s)},c=r.teardown;r.teardown=()=>{o(),c?.()}}}),e}var fa={get(e,t){if(!e.exclude.includes(t))return e.props[t]},set(e,t){return!1},getOwnPropertyDescriptor(e,t){if(!e.exclude.includes(t)&&t in e.props)return{enumerable:!0,configurable:!0,value:e.props[t]}},has(e,t){return e.exclude.includes(t)?!1:t in e.props},ownKeys(e){return Reflect.ownKeys(e.props).filter(t=>!e.exclude.includes(t))}};function pa(e,t,n){return new Proxy({props:e,exclude:t},fa)}var ma={get(e,t){let n=e.props.length;for(;n--;){let r=e.props[n];if(p(r)&&(r=r()),typeof r==`object`&&r&&t in r)return r[t]}},set(e,t,n){let r=e.props.length;for(;r--;){let i=e.props[r];p(i)&&(i=i());let a=s(i,t);if(a&&a.set)return a.set(n),!0}return!1},getOwnPropertyDescriptor(e,t){let n=e.props.length;for(;n--;){let r=e.props[n];if(p(r)&&(r=r()),typeof r==`object`&&r&&t in r){let e=s(r,t);return e&&!e.configurable&&(e.configurable=!0),e}}},has(e,t){if(t===oe||t===se)return!1;for(let n of e.props)if(p(n)&&(n=n()),n!=null&&t in n)return!0;return!1},ownKeys(e){let t=[];for(let n of e.props)if(p(n)&&(n=n()),n){for(let e in n)t.includes(e)||t.push(e);for(let e of Object.getOwnPropertySymbols(n))t.includes(e)||t.push(e)}return t}};function ha(...e){return new Proxy({props:e},ma)}function J(e,t,n,r){var i=!Je||(n&2)!=0,a=(n&8)!=0,o=(n&16)!=0,c=r,l=!0,u=void 0,d=()=>o&&i?(u??=Ut(r),B(u)):(l&&(l=!1,c=o?kr(r):r),c);let f;if(a){var p=oe in e||se in e;f=s(e,t)?.set??(p&&t in e?n=>e[t]=n:void 0)}var m,h=!1;a?[m,h]=ft(()=>e[t]):m=e[t],m===void 0&&r!==void 0&&(m=d(),f&&(i&&Ce(t),f(m)));var g=i?()=>{var n=e[t];return n===void 0?d():(l=!0,n)}:()=>{var n=e[t];return n!==void 0&&(c=void 0),n===void 0?c:n};if(i&&!(n&4))return g;if(f){var _=e.$$legacy;return(function(e,t){return arguments.length>0?((!i||!t||_||h)&&f(t?g():e),e):g()})}var v=!1,y=(n&1?Ut:Kt)(()=>(v=!1,g()));a&&B(y);var b=sr;return(function(e,t){if(arguments.length>0){let n=t?B(y):i&&a?ln(e):e;return P(y,n),v=!0,c!==void 0&&(c=n),e}return nr&&v||b.f&16384?y.v:B(y)})}function ga(e){Xe===null&&ge(`onMount`),Je&&Xe.l!==null?va(Xe).m.push(e):R(()=>{let t=kr(e);if(typeof t==`function`)return t})}function _a(e){Xe===null&&ge(`onDestroy`),ga(()=>()=>kr(e))}function va(e){var t=e.l;return t.u??={a:[],b:[],m:[]}}typeof window<`u`&&((window.__svelte??={}).v??=new Set).add(`5`),Ye();var ya=3478,ba=3479,xa=`https://github.com/bloknayrb/tandem`,Sa=`${xa}/issues/new`,Ca=new Set([`.md`,`.txt`,`.html`,`.htm`,`.docx`]),wa=3e3,Ta=3e3,Ea=3e4,Da={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)`},Oa={yellow:`var(--tandem-highlight-yellow)`,green:`var(--tandem-highlight-green)`,blue:`var(--tandem-highlight-blue)`,pink:`var(--tandem-highlight-pink)`};function ka(e){return e&&e in Da?e:`yellow`}var Aa=`tandem`,ja=`tandem:mode`,Ma=`tandem:settings`,Na={left:`tandem-left-panel-width`,right:`tandem-panel-width`},Pa=1e3,Fa=3e3,Ia=`__tandem_ctrl__`,La=`annotations`,Ra=`awareness`,za=`userAwareness`,Ba=`mode`,Va=`selectionDwellMs`,Ha=`chat`,Ua=`documentMeta`,Wa=`annotationReplies`,Ga=`savedAtVersion`,Ka=`authorship`,qa=`selection`,Ja=`activity`,Ya=`claude`,Xa=`openDocuments`,Za=`activeDocumentId`,Qa=`activeDocumentEpoch`,$a=`storeReadOnly`,eo=`fidelityReport`,to=`tandem:showAuthorship`,no=`tandem:decorationVisibility`,ro=`tandem:recentFiles`,io=`tandem:userName`,ao=`tandem:user-name-changed`,oo={error:8e3,warning:6e3,info:4e3},so=5*6e4,co=`tandem:tutorialCompleted`,lo=`tutorial-`,uo=`tandem:coworkOnboardingSkipped`,fo=3e4,po=2e3,mo=`tandem:zoomLevel`,ho=.5,go=`upload://`,_o=`upload://scratchpad/`;function vo(e){return e.startsWith(go)}function yo(e){return e.startsWith(_o)}function bo(e){if(!yo(e))return null;let t=e.slice(20).split(`/`)[0];return t.length>0?t:null}var xo=e=>e,So=e=>e,Co;(function(e){e.assertEqual=e=>{};function t(e){}e.assertIs=t;function n(e){throw Error()}e.assertNever=n,e.arrayToEnum=e=>{let t={};for(let n of e)t[n]=n;return t},e.getValidEnumValues=t=>{let n=e.objectKeys(t).filter(e=>typeof t[t[e]]!=`number`),r={};for(let e of n)r[e]=t[e];return e.objectValues(r)},e.objectValues=t=>e.objectKeys(t).map(function(e){return t[e]}),e.objectKeys=typeof Object.keys==`function`?e=>Object.keys(e):e=>{let t=[];for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return t},e.find=(e,t)=>{for(let n of e)if(t(n))return n},e.isInteger=typeof Number.isInteger==`function`?e=>Number.isInteger(e):e=>typeof e==`number`&&Number.isFinite(e)&&Math.floor(e)===e;function r(e,t=` | `){return e.map(e=>typeof e==`string`?`'${e}'`:e).join(t)}e.joinValues=r,e.jsonStringifyReplacer=(e,t)=>typeof t==`bigint`?t.toString():t})(Co||={});var wo;(function(e){e.mergeShapes=(e,t)=>({...e,...t})})(wo||={});var To=Co.arrayToEnum([`string`,`nan`,`number`,`integer`,`float`,`boolean`,`date`,`bigint`,`symbol`,`function`,`undefined`,`null`,`array`,`object`,`unknown`,`promise`,`void`,`never`,`map`,`set`]),Eo=e=>{switch(typeof e){case`undefined`:return To.undefined;case`string`:return To.string;case`number`:return Number.isNaN(e)?To.nan:To.number;case`boolean`:return To.boolean;case`function`:return To.function;case`bigint`:return To.bigint;case`symbol`:return To.symbol;case`object`:return Array.isArray(e)?To.array:e===null?To.null:e.then&&typeof e.then==`function`&&e.catch&&typeof e.catch==`function`?To.promise:typeof Map<`u`&&e instanceof Map?To.map:typeof Set<`u`&&e instanceof Set?To.set:typeof Date<`u`&&e instanceof Date?To.date:To.object;default:return To.unknown}},Y=Co.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`]),Do=class e extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};let t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name=`ZodError`,this.issues=e}format(e){let t=e||function(e){return e.message},n={_errors:[]},r=e=>{for(let i of e.issues)if(i.code===`invalid_union`)i.unionErrors.map(r);else if(i.code===`invalid_return_type`)r(i.returnTypeError);else if(i.code===`invalid_arguments`)r(i.argumentsError);else if(i.path.length===0)n._errors.push(t(i));else{let e=n,r=0;for(;r<i.path.length;){let n=i.path[r];r===i.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(i))):e[n]=e[n]||{_errors:[]},e=e[n],r++}}};return r(this),n}static assert(t){if(!(t instanceof e))throw Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Co.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=e=>e.message){let t={},n=[];for(let r of this.issues)if(r.path.length>0){let n=r.path[0];t[n]=t[n]||[],t[n].push(e(r))}else n.push(e(r));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}};Do.create=e=>new Do(e);var Oo=(e,t)=>{let n;switch(e.code){case Y.invalid_type:n=e.received===To.undefined?`Required`:`Expected ${e.expected}, received ${e.received}`;break;case Y.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,Co.jsonStringifyReplacer)}`;break;case Y.unrecognized_keys:n=`Unrecognized key(s) in object: ${Co.joinValues(e.keys,`, `)}`;break;case Y.invalid_union:n=`Invalid input`;break;case Y.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${Co.joinValues(e.options)}`;break;case Y.invalid_enum_value:n=`Invalid enum value. Expected ${Co.joinValues(e.options)}, received '${e.received}'`;break;case Y.invalid_arguments:n=`Invalid function arguments`;break;case Y.invalid_return_type:n=`Invalid function return type`;break;case Y.invalid_date:n=`Invalid date`;break;case Y.invalid_string:typeof e.validation==`object`?`includes`in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position==`number`&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):`startsWith`in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:`endsWith`in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:Co.assertNever(e.validation):n=e.validation===`regex`?`Invalid`:`Invalid ${e.validation}`;break;case Y.too_small:n=e.type===`array`?`Array must contain ${e.exact?`exactly`:e.inclusive?`at least`:`more than`} ${e.minimum} element(s)`:e.type===`string`?`String must contain ${e.exact?`exactly`:e.inclusive?`at least`:`over`} ${e.minimum} character(s)`:e.type===`number`||e.type===`bigint`?`Number must be ${e.exact?`exactly equal to `:e.inclusive?`greater than or equal to `:`greater than `}${e.minimum}`:e.type===`date`?`Date must be ${e.exact?`exactly equal to `:e.inclusive?`greater than or equal to `:`greater than `}${new Date(Number(e.minimum))}`:`Invalid input`;break;case Y.too_big:n=e.type===`array`?`Array must contain ${e.exact?`exactly`:e.inclusive?`at most`:`less than`} ${e.maximum} element(s)`:e.type===`string`?`String must contain ${e.exact?`exactly`:e.inclusive?`at most`:`under`} ${e.maximum} character(s)`:e.type===`number`?`Number must be ${e.exact?`exactly`:e.inclusive?`less than or equal to`:`less than`} ${e.maximum}`:e.type===`bigint`?`BigInt must be ${e.exact?`exactly`:e.inclusive?`less than or equal to`:`less than`} ${e.maximum}`:e.type===`date`?`Date must be ${e.exact?`exactly`:e.inclusive?`smaller than or equal to`:`smaller than`} ${new Date(Number(e.maximum))}`:`Invalid input`;break;case Y.custom:n=`Invalid input`;break;case Y.invalid_intersection_types:n=`Intersection results could not be merged`;break;case Y.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case Y.not_finite:n=`Number must be finite`;break;default:n=t.defaultError,Co.assertNever(e)}return{message:n}},ko=Oo;function Ao(){return ko}var jo=e=>{let{data:t,path:n,errorMaps:r,issueData:i}=e,a=[...n,...i.path||[]],o={...i,path:a};if(i.message!==void 0)return{...i,path:a,message:i.message};let s=``,c=r.filter(e=>!!e).slice().reverse();for(let e of c)s=e(o,{data:t,defaultError:s}).message;return{...i,path:a,message:s}};function X(e,t){let n=Ao(),r=jo({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===Oo?void 0:Oo].filter(e=>!!e)});e.common.issues.push(r)}var Mo=class e{constructor(){this.value=`valid`}dirty(){this.value===`valid`&&(this.value=`dirty`)}abort(){this.value!==`aborted`&&(this.value=`aborted`)}static mergeArray(e,t){let n=[];for(let r of t){if(r.status===`aborted`)return No;r.status===`dirty`&&e.dirty(),n.push(r.value)}return{status:e.value,value:n}}static async mergeObjectAsync(t,n){let r=[];for(let e of n){let t=await e.key,n=await e.value;r.push({key:t,value:n})}return e.mergeObjectSync(t,r)}static mergeObjectSync(e,t){let n={};for(let r of t){let{key:t,value:i}=r;if(t.status===`aborted`||i.status===`aborted`)return No;t.status===`dirty`&&e.dirty(),i.status===`dirty`&&e.dirty(),t.value!==`__proto__`&&(i.value!==void 0||r.alwaysSet)&&(n[t.value]=i.value)}return{status:e.value,value:n}}},No=Object.freeze({status:`aborted`}),Po=e=>({status:`dirty`,value:e}),Fo=e=>({status:`valid`,value:e}),Io=e=>e.status===`aborted`,Lo=e=>e.status===`dirty`,Ro=e=>e.status===`valid`,zo=e=>typeof Promise<`u`&&e instanceof Promise,Bo;(function(e){e.errToObj=e=>typeof e==`string`?{message:e}:e||{},e.toString=e=>typeof e==`string`?e:e?.message})(Bo||={});var Vo=class{constructor(e,t,n,r){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=r}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}},Ho=(e,t)=>{if(Ro(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw Error(`Validation failed but no issues detected.`);return{success:!1,get error(){if(this._error)return this._error;let t=new Do(e.common.issues);return this._error=t,this._error}}};function Uo(e){if(!e)return{};let{errorMap:t,invalid_type_error:n,required_error:r,description:i}=e;if(t&&(n||r))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:i}:{errorMap:(t,i)=>{let{message:a}=e;return t.code===`invalid_enum_value`?{message:a??i.defaultError}:i.data===void 0?{message:a??r??i.defaultError}:t.code===`invalid_type`?{message:a??n??i.defaultError}:{message:i.defaultError}},description:i}}var Wo=class{get description(){return this._def.description}_getType(e){return Eo(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Eo(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Mo,ctx:{common:e.parent.common,data:e.data,parsedType:Eo(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(zo(t))throw Error(`Synchronous parse encountered promise.`);return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){let n={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Eo(e)};return Ho(n,this._parseSync({data:e,path:n.path,parent:n}))}"~validate"(e){let t={common:{issues:[],async:!!this[`~standard`].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Eo(e)};if(!this[`~standard`].async)try{let n=this._parseSync({data:e,path:[],parent:t});return Ro(n)?{value:n.value}:{issues:t.common.issues}}catch(e){e?.message?.toLowerCase()?.includes(`encountered`)&&(this[`~standard`].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(e=>Ro(e)?{value:e.value}:{issues:t.common.issues})}async parseAsync(e,t){let n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){let n={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Eo(e)},r=this._parse({data:e,path:n.path,parent:n});return Ho(n,await(zo(r)?r:Promise.resolve(r)))}refine(e,t){let n=e=>typeof t==`string`||t===void 0?{message:t}:typeof t==`function`?t(e):t;return this._refinement((t,r)=>{let i=e(t),a=()=>r.addIssue({code:Y.custom,...n(t)});return typeof Promise<`u`&&i instanceof Promise?i.then(e=>e?!0:(a(),!1)):i?!0:(a(),!1)})}refinement(e,t){return this._refinement((n,r)=>e(n)?!0:(r.addIssue(typeof t==`function`?t(n,r):t),!1))}_refinement(e){return new Js({schema:this,typeName:rc.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:e=>this[`~validate`](e)}}optional(){return Ys.create(this,this._def)}nullable(){return Xs.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ks.create(this)}promise(){return qs.create(this,this._def)}or(e){return Ms.create([this,e],this._def)}and(e){return Is.create(this,e,this._def)}transform(e){return new Js({...Uo(this._def),schema:this,typeName:rc.ZodEffects,effect:{type:`transform`,transform:e}})}default(e){let t=typeof e==`function`?e:()=>e;return new Zs({...Uo(this._def),innerType:this,defaultValue:t,typeName:rc.ZodDefault})}brand(){return new ec({typeName:rc.ZodBranded,type:this,...Uo(this._def)})}catch(e){let t=typeof e==`function`?e:()=>e;return new Qs({...Uo(this._def),innerType:this,catchValue:t,typeName:rc.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return tc.create(this,e)}readonly(){return nc.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},Go=/^c[^\s-]{8,}$/i,Ko=/^[0-9a-z]+$/,qo=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Jo=/^[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,Yo=/^[a-z0-9_-]{21}$/i,Xo=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Zo=/^[-+]?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)?)??$/,Qo=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,$o=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,es,ts=/^(?:(?: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])$/,ns=/^(?:(?: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])$/,rs=/^(([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]))$/,is=/^(([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])$/,as=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,ss=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,cs=`((\\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])))`,ls=RegExp(`^${cs}$`);function us(e){let t=`[0-5]\\d`;e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision??(t=`${t}(\\.\\d+)?`);let n=e.precision?`+`:`?`;return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${n}`}function ds(e){return RegExp(`^${us(e)}$`)}function fs(e){let t=`${cs}T${us(e)}`,n=[];return n.push(e.local?`Z?`:`Z`),e.offset&&n.push(`([+-]\\d{2}:?\\d{2})`),t=`${t}(${n.join(`|`)})`,RegExp(`^${t}$`)}function ps(e,t){return!!((t===`v4`||!t)&&ts.test(e)||(t===`v6`||!t)&&rs.test(e))}function ms(e,t){if(!Xo.test(e))return!1;try{let[n]=e.split(`.`);if(!n)return!1;let r=n.replace(/-/g,`+`).replace(/_/g,`/`).padEnd(n.length+(4-n.length%4)%4,`=`),i=JSON.parse(atob(r));return!(typeof i!=`object`||!i||`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&i.alg!==t)}catch{return!1}}function hs(e,t){return!!((t===`v4`||!t)&&ns.test(e)||(t===`v6`||!t)&&is.test(e))}var gs=class e extends Wo{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==To.string){let t=this._getOrReturnCtx(e);return X(t,{code:Y.invalid_type,expected:To.string,received:t.parsedType}),No}let t=new Mo,n;for(let r of this._def.checks)if(r.kind===`min`)e.data.length<r.value&&(n=this._getOrReturnCtx(e,n),X(n,{code:Y.too_small,minimum:r.value,type:`string`,inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind===`max`)e.data.length>r.value&&(n=this._getOrReturnCtx(e,n),X(n,{code:Y.too_big,maximum:r.value,type:`string`,inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind===`length`){let i=e.data.length>r.value,a=e.data.length<r.value;(i||a)&&(n=this._getOrReturnCtx(e,n),i?X(n,{code:Y.too_big,maximum:r.value,type:`string`,inclusive:!0,exact:!0,message:r.message}):a&&X(n,{code:Y.too_small,minimum:r.value,type:`string`,inclusive:!0,exact:!0,message:r.message}),t.dirty())}else if(r.kind===`email`)Qo.test(e.data)||(n=this._getOrReturnCtx(e,n),X(n,{validation:`email`,code:Y.invalid_string,message:r.message}),t.dirty());else if(r.kind===`emoji`)es||=new RegExp($o,`u`),es.test(e.data)||(n=this._getOrReturnCtx(e,n),X(n,{validation:`emoji`,code:Y.invalid_string,message:r.message}),t.dirty());else if(r.kind===`uuid`)Jo.test(e.data)||(n=this._getOrReturnCtx(e,n),X(n,{validation:`uuid`,code:Y.invalid_string,message:r.message}),t.dirty());else if(r.kind===`nanoid`)Yo.test(e.data)||(n=this._getOrReturnCtx(e,n),X(n,{validation:`nanoid`,code:Y.invalid_string,message:r.message}),t.dirty());else if(r.kind===`cuid`)Go.test(e.data)||(n=this._getOrReturnCtx(e,n),X(n,{validation:`cuid`,code:Y.invalid_string,message:r.message}),t.dirty());else if(r.kind===`cuid2`)Ko.test(e.data)||(n=this._getOrReturnCtx(e,n),X(n,{validation:`cuid2`,code:Y.invalid_string,message:r.message}),t.dirty());else if(r.kind===`ulid`)qo.test(e.data)||(n=this._getOrReturnCtx(e,n),X(n,{validation:`ulid`,code:Y.invalid_string,message:r.message}),t.dirty());else if(r.kind===`url`)try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),X(n,{validation:`url`,code:Y.invalid_string,message:r.message}),t.dirty()}else r.kind===`regex`?(r.regex.lastIndex=0,r.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),X(n,{validation:`regex`,code:Y.invalid_string,message:r.message}),t.dirty())):r.kind===`trim`?e.data=e.data.trim():r.kind===`includes`?e.data.includes(r.value,r.position)||(n=this._getOrReturnCtx(e,n),X(n,{code:Y.invalid_string,validation:{includes:r.value,position:r.position},message:r.message}),t.dirty()):r.kind===`toLowerCase`?e.data=e.data.toLowerCase():r.kind===`toUpperCase`?e.data=e.data.toUpperCase():r.kind===`startsWith`?e.data.startsWith(r.value)||(n=this._getOrReturnCtx(e,n),X(n,{code:Y.invalid_string,validation:{startsWith:r.value},message:r.message}),t.dirty()):r.kind===`endsWith`?e.data.endsWith(r.value)||(n=this._getOrReturnCtx(e,n),X(n,{code:Y.invalid_string,validation:{endsWith:r.value},message:r.message}),t.dirty()):r.kind===`datetime`?fs(r).test(e.data)||(n=this._getOrReturnCtx(e,n),X(n,{code:Y.invalid_string,validation:`datetime`,message:r.message}),t.dirty()):r.kind===`date`?ls.test(e.data)||(n=this._getOrReturnCtx(e,n),X(n,{code:Y.invalid_string,validation:`date`,message:r.message}),t.dirty()):r.kind===`time`?ds(r).test(e.data)||(n=this._getOrReturnCtx(e,n),X(n,{code:Y.invalid_string,validation:`time`,message:r.message}),t.dirty()):r.kind===`duration`?Zo.test(e.data)||(n=this._getOrReturnCtx(e,n),X(n,{validation:`duration`,code:Y.invalid_string,message:r.message}),t.dirty()):r.kind===`ip`?ps(e.data,r.version)||(n=this._getOrReturnCtx(e,n),X(n,{validation:`ip`,code:Y.invalid_string,message:r.message}),t.dirty()):r.kind===`jwt`?ms(e.data,r.alg)||(n=this._getOrReturnCtx(e,n),X(n,{validation:`jwt`,code:Y.invalid_string,message:r.message}),t.dirty()):r.kind===`cidr`?hs(e.data,r.version)||(n=this._getOrReturnCtx(e,n),X(n,{validation:`cidr`,code:Y.invalid_string,message:r.message}),t.dirty()):r.kind===`base64`?as.test(e.data)||(n=this._getOrReturnCtx(e,n),X(n,{validation:`base64`,code:Y.invalid_string,message:r.message}),t.dirty()):r.kind===`base64url`?ss.test(e.data)||(n=this._getOrReturnCtx(e,n),X(n,{validation:`base64url`,code:Y.invalid_string,message:r.message}),t.dirty()):Co.assertNever(r);return{status:t.value,value:e.data}}_regex(e,t,n){return this.refinement(t=>e.test(t),{validation:t,code:Y.invalid_string,...Bo.errToObj(n)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(e){return this._addCheck({kind:`email`,...Bo.errToObj(e)})}url(e){return this._addCheck({kind:`url`,...Bo.errToObj(e)})}emoji(e){return this._addCheck({kind:`emoji`,...Bo.errToObj(e)})}uuid(e){return this._addCheck({kind:`uuid`,...Bo.errToObj(e)})}nanoid(e){return this._addCheck({kind:`nanoid`,...Bo.errToObj(e)})}cuid(e){return this._addCheck({kind:`cuid`,...Bo.errToObj(e)})}cuid2(e){return this._addCheck({kind:`cuid2`,...Bo.errToObj(e)})}ulid(e){return this._addCheck({kind:`ulid`,...Bo.errToObj(e)})}base64(e){return this._addCheck({kind:`base64`,...Bo.errToObj(e)})}base64url(e){return this._addCheck({kind:`base64url`,...Bo.errToObj(e)})}jwt(e){return this._addCheck({kind:`jwt`,...Bo.errToObj(e)})}ip(e){return this._addCheck({kind:`ip`,...Bo.errToObj(e)})}cidr(e){return this._addCheck({kind:`cidr`,...Bo.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:e?.precision===void 0?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...Bo.errToObj(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:e?.precision===void 0?null:e?.precision,...Bo.errToObj(e?.message)})}duration(e){return this._addCheck({kind:`duration`,...Bo.errToObj(e)})}regex(e,t){return this._addCheck({kind:`regex`,regex:e,...Bo.errToObj(t)})}includes(e,t){return this._addCheck({kind:`includes`,value:e,position:t?.position,...Bo.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:`startsWith`,value:e,...Bo.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:`endsWith`,value:e,...Bo.errToObj(t)})}min(e,t){return this._addCheck({kind:`min`,value:e,...Bo.errToObj(t)})}max(e,t){return this._addCheck({kind:`max`,value:e,...Bo.errToObj(t)})}length(e,t){return this._addCheck({kind:`length`,value:e,...Bo.errToObj(t)})}nonempty(e){return this.min(1,Bo.errToObj(e))}trim(){return new e({...this._def,checks:[...this._def.checks,{kind:`trim`}]})}toLowerCase(){return new e({...this._def,checks:[...this._def.checks,{kind:`toLowerCase`}]})}toUpperCase(){return new e({...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(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}};gs.create=e=>new gs({checks:[],typeName:rc.ZodString,coerce:e?.coerce??!1,...Uo(e)});function _s(e,t){let n=(e.toString().split(`.`)[1]||``).length,r=(t.toString().split(`.`)[1]||``).length,i=n>r?n:r;return Number.parseInt(e.toFixed(i).replace(`.`,``))%Number.parseInt(t.toFixed(i).replace(`.`,``))/10**i}var vs=class e extends Wo{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)!==To.number){let t=this._getOrReturnCtx(e);return X(t,{code:Y.invalid_type,expected:To.number,received:t.parsedType}),No}let t,n=new Mo;for(let r of this._def.checks)r.kind===`int`?Co.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),X(t,{code:Y.invalid_type,expected:`integer`,received:`float`,message:r.message}),n.dirty()):r.kind===`min`?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),X(t,{code:Y.too_small,minimum:r.value,type:`number`,inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):r.kind===`max`?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),X(t,{code:Y.too_big,maximum:r.value,type:`number`,inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):r.kind===`multipleOf`?_s(e.data,r.value)!==0&&(t=this._getOrReturnCtx(e,t),X(t,{code:Y.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):r.kind===`finite`?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),X(t,{code:Y.not_finite,message:r.message}),n.dirty()):Co.assertNever(r);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit(`min`,e,!0,Bo.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,Bo.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,Bo.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,Bo.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:Bo.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(e){return this._addCheck({kind:`int`,message:Bo.toString(e)})}positive(e){return this._addCheck({kind:`min`,value:0,inclusive:!1,message:Bo.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:0,inclusive:!1,message:Bo.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:0,inclusive:!0,message:Bo.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:0,inclusive:!0,message:Bo.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:Bo.toString(t)})}finite(e){return this._addCheck({kind:`finite`,message:Bo.toString(e)})}safe(e){return this._addCheck({kind:`min`,inclusive:!0,value:-(2**53-1),message:Bo.toString(e)})._addCheck({kind:`max`,inclusive:!0,value:2**53-1,message:Bo.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind===`int`||e.kind===`multipleOf`&&Co.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let n of this._def.checks)if(n.kind===`finite`||n.kind===`int`||n.kind===`multipleOf`)return!0;else n.kind===`min`?(t===null||n.value>t)&&(t=n.value):n.kind===`max`&&(e===null||n.value<e)&&(e=n.value);return Number.isFinite(t)&&Number.isFinite(e)}};vs.create=e=>new vs({checks:[],typeName:rc.ZodNumber,coerce:e?.coerce||!1,...Uo(e)});var ys=class e extends Wo{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)!==To.bigint)return this._getInvalidInput(e);let t,n=new Mo;for(let r of this._def.checks)r.kind===`min`?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),X(t,{code:Y.too_small,type:`bigint`,minimum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty()):r.kind===`max`?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),X(t,{code:Y.too_big,type:`bigint`,maximum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty()):r.kind===`multipleOf`?e.data%r.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),X(t,{code:Y.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):Co.assertNever(r);return{status:n.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return X(t,{code:Y.invalid_type,expected:To.bigint,received:t.parsedType}),No}gte(e,t){return this.setLimit(`min`,e,!0,Bo.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,Bo.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,Bo.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,Bo.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:Bo.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}positive(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!1,message:Bo.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!1,message:Bo.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!0,message:Bo.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!0,message:Bo.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:Bo.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}};ys.create=e=>new ys({checks:[],typeName:rc.ZodBigInt,coerce:e?.coerce??!1,...Uo(e)});var bs=class extends Wo{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==To.boolean){let t=this._getOrReturnCtx(e);return X(t,{code:Y.invalid_type,expected:To.boolean,received:t.parsedType}),No}return Fo(e.data)}};bs.create=e=>new bs({typeName:rc.ZodBoolean,coerce:e?.coerce||!1,...Uo(e)});var xs=class e extends Wo{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==To.date){let t=this._getOrReturnCtx(e);return X(t,{code:Y.invalid_type,expected:To.date,received:t.parsedType}),No}if(Number.isNaN(e.data.getTime()))return X(this._getOrReturnCtx(e),{code:Y.invalid_date}),No;let t=new Mo,n;for(let r of this._def.checks)r.kind===`min`?e.data.getTime()<r.value&&(n=this._getOrReturnCtx(e,n),X(n,{code:Y.too_small,message:r.message,inclusive:!0,exact:!1,minimum:r.value,type:`date`}),t.dirty()):r.kind===`max`?e.data.getTime()>r.value&&(n=this._getOrReturnCtx(e,n),X(n,{code:Y.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:`date`}),t.dirty()):Co.assertNever(r);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}min(e,t){return this._addCheck({kind:`min`,value:e.getTime(),message:Bo.toString(t)})}max(e,t){return this._addCheck({kind:`max`,value:e.getTime(),message:Bo.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e==null?null:new Date(e)}get maxDate(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e==null?null:new Date(e)}};xs.create=e=>new xs({checks:[],coerce:e?.coerce||!1,typeName:rc.ZodDate,...Uo(e)});var Ss=class extends Wo{_parse(e){if(this._getType(e)!==To.symbol){let t=this._getOrReturnCtx(e);return X(t,{code:Y.invalid_type,expected:To.symbol,received:t.parsedType}),No}return Fo(e.data)}};Ss.create=e=>new Ss({typeName:rc.ZodSymbol,...Uo(e)});var Cs=class extends Wo{_parse(e){if(this._getType(e)!==To.undefined){let t=this._getOrReturnCtx(e);return X(t,{code:Y.invalid_type,expected:To.undefined,received:t.parsedType}),No}return Fo(e.data)}};Cs.create=e=>new Cs({typeName:rc.ZodUndefined,...Uo(e)});var ws=class extends Wo{_parse(e){if(this._getType(e)!==To.null){let t=this._getOrReturnCtx(e);return X(t,{code:Y.invalid_type,expected:To.null,received:t.parsedType}),No}return Fo(e.data)}};ws.create=e=>new ws({typeName:rc.ZodNull,...Uo(e)});var Ts=class extends Wo{constructor(){super(...arguments),this._any=!0}_parse(e){return Fo(e.data)}};Ts.create=e=>new Ts({typeName:rc.ZodAny,...Uo(e)});var Es=class extends Wo{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Fo(e.data)}};Es.create=e=>new Es({typeName:rc.ZodUnknown,...Uo(e)});var Ds=class extends Wo{_parse(e){let t=this._getOrReturnCtx(e);return X(t,{code:Y.invalid_type,expected:To.never,received:t.parsedType}),No}};Ds.create=e=>new Ds({typeName:rc.ZodNever,...Uo(e)});var Os=class extends Wo{_parse(e){if(this._getType(e)!==To.undefined){let t=this._getOrReturnCtx(e);return X(t,{code:Y.invalid_type,expected:To.void,received:t.parsedType}),No}return Fo(e.data)}};Os.create=e=>new Os({typeName:rc.ZodVoid,...Uo(e)});var ks=class e extends Wo{_parse(e){let{ctx:t,status:n}=this._processInputParams(e),r=this._def;if(t.parsedType!==To.array)return X(t,{code:Y.invalid_type,expected:To.array,received:t.parsedType}),No;if(r.exactLength!==null){let e=t.data.length>r.exactLength.value,i=t.data.length<r.exactLength.value;(e||i)&&(X(t,{code:e?Y.too_big:Y.too_small,minimum:i?r.exactLength.value:void 0,maximum:e?r.exactLength.value:void 0,type:`array`,inclusive:!0,exact:!0,message:r.exactLength.message}),n.dirty())}if(r.minLength!==null&&t.data.length<r.minLength.value&&(X(t,{code:Y.too_small,minimum:r.minLength.value,type:`array`,inclusive:!0,exact:!1,message:r.minLength.message}),n.dirty()),r.maxLength!==null&&t.data.length>r.maxLength.value&&(X(t,{code:Y.too_big,maximum:r.maxLength.value,type:`array`,inclusive:!0,exact:!1,message:r.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((e,n)=>r.type._parseAsync(new Vo(t,e,t.path,n)))).then(e=>Mo.mergeArray(n,e));let i=[...t.data].map((e,n)=>r.type._parseSync(new Vo(t,e,t.path,n)));return Mo.mergeArray(n,i)}get element(){return this._def.type}min(t,n){return new e({...this._def,minLength:{value:t,message:Bo.toString(n)}})}max(t,n){return new e({...this._def,maxLength:{value:t,message:Bo.toString(n)}})}length(t,n){return new e({...this._def,exactLength:{value:t,message:Bo.toString(n)}})}nonempty(e){return this.min(1,e)}};ks.create=(e,t)=>new ks({type:e,minLength:null,maxLength:null,exactLength:null,typeName:rc.ZodArray,...Uo(t)});function As(e){if(e instanceof js){let t={};for(let n in e.shape){let r=e.shape[n];t[n]=Ys.create(As(r))}return new js({...e._def,shape:()=>t})}else if(e instanceof ks)return new ks({...e._def,type:As(e.element)});else if(e instanceof Ys)return Ys.create(As(e.unwrap()));else if(e instanceof Xs)return Xs.create(As(e.unwrap()));else if(e instanceof Ls)return Ls.create(e.items.map(e=>As(e)));else return e}var js=class e extends Wo{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),t=Co.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==To.object){let t=this._getOrReturnCtx(e);return X(t,{code:Y.invalid_type,expected:To.object,received:t.parsedType}),No}let{status:t,ctx:n}=this._processInputParams(e),{shape:r,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof Ds&&this._def.unknownKeys===`strip`))for(let e in n.data)i.includes(e)||a.push(e);let o=[];for(let e of i){let t=r[e],i=n.data[e];o.push({key:{status:`valid`,value:e},value:t._parse(new Vo(n,i,n.path,e)),alwaysSet:e in n.data})}if(this._def.catchall instanceof Ds){let e=this._def.unknownKeys;if(e===`passthrough`)for(let e of a)o.push({key:{status:`valid`,value:e},value:{status:`valid`,value:n.data[e]}});else if(e===`strict`)a.length>0&&(X(n,{code:Y.unrecognized_keys,keys:a}),t.dirty());else if(e!==`strip`)throw Error(`Internal ZodObject error: invalid unknownKeys value.`)}else{let e=this._def.catchall;for(let t of a){let r=n.data[t];o.push({key:{status:`valid`,value:t},value:e._parse(new Vo(n,r,n.path,t)),alwaysSet:t in n.data})}}return n.common.async?Promise.resolve().then(async()=>{let e=[];for(let t of o){let n=await t.key,r=await t.value;e.push({key:n,value:r,alwaysSet:t.alwaysSet})}return e}).then(e=>Mo.mergeObjectSync(t,e)):Mo.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(t){return Bo.errToObj,new e({...this._def,unknownKeys:`strict`,...t===void 0?{}:{errorMap:(e,n)=>{let r=this._def.errorMap?.(e,n).message??n.defaultError;return e.code===`unrecognized_keys`?{message:Bo.errToObj(t).message??r}:{message:r}}}})}strip(){return new e({...this._def,unknownKeys:`strip`})}passthrough(){return new e({...this._def,unknownKeys:`passthrough`})}extend(t){return new e({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new e({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:rc.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(t){return new e({...this._def,catchall:t})}pick(t){let n={};for(let e of Co.objectKeys(t))t[e]&&this.shape[e]&&(n[e]=this.shape[e]);return new e({...this._def,shape:()=>n})}omit(t){let n={};for(let e of Co.objectKeys(this.shape))t[e]||(n[e]=this.shape[e]);return new e({...this._def,shape:()=>n})}deepPartial(){return As(this)}partial(t){let n={};for(let e of Co.objectKeys(this.shape)){let r=this.shape[e];t&&!t[e]?n[e]=r:n[e]=r.optional()}return new e({...this._def,shape:()=>n})}required(t){let n={};for(let e of Co.objectKeys(this.shape))if(t&&!t[e])n[e]=this.shape[e];else{let t=this.shape[e];for(;t instanceof Ys;)t=t._def.innerType;n[e]=t}return new e({...this._def,shape:()=>n})}keyof(){return Ws(Co.objectKeys(this.shape))}};js.create=(e,t)=>new js({shape:()=>e,unknownKeys:`strip`,catchall:Ds.create(),typeName:rc.ZodObject,...Uo(t)}),js.strictCreate=(e,t)=>new js({shape:()=>e,unknownKeys:`strict`,catchall:Ds.create(),typeName:rc.ZodObject,...Uo(t)}),js.lazycreate=(e,t)=>new js({shape:e,unknownKeys:`strip`,catchall:Ds.create(),typeName:rc.ZodObject,...Uo(t)});var Ms=class extends Wo{_parse(e){let{ctx:t}=this._processInputParams(e),n=this._def.options;function r(e){for(let t of e)if(t.result.status===`valid`)return t.result;for(let n of e)if(n.result.status===`dirty`)return t.common.issues.push(...n.ctx.common.issues),n.result;let n=e.map(e=>new Do(e.ctx.common.issues));return X(t,{code:Y.invalid_union,unionErrors:n}),No}if(t.common.async)return Promise.all(n.map(async e=>{let n={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:n}),ctx:n}})).then(r);{let e,r=[];for(let i of n){let n={...t,common:{...t.common,issues:[]},parent:null},a=i._parseSync({data:t.data,path:t.path,parent:n});if(a.status===`valid`)return a;a.status===`dirty`&&!e&&(e={result:a,ctx:n}),n.common.issues.length&&r.push(n.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;let i=r.map(e=>new Do(e));return X(t,{code:Y.invalid_union,unionErrors:i}),No}}get options(){return this._def.options}};Ms.create=(e,t)=>new Ms({options:e,typeName:rc.ZodUnion,...Uo(t)});var Ns=e=>e instanceof Hs?Ns(e.schema):e instanceof Js?Ns(e.innerType()):e instanceof Us?[e.value]:e instanceof Gs?e.options:e instanceof Ks?Co.objectValues(e.enum):e instanceof Zs?Ns(e._def.innerType):e instanceof Cs?[void 0]:e instanceof ws?[null]:e instanceof Ys?[void 0,...Ns(e.unwrap())]:e instanceof Xs?[null,...Ns(e.unwrap())]:e instanceof ec||e instanceof nc?Ns(e.unwrap()):e instanceof Qs?Ns(e._def.innerType):[],Ps=class e extends Wo{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==To.object)return X(t,{code:Y.invalid_type,expected:To.object,received:t.parsedType}),No;let n=this.discriminator,r=t.data[n],i=this.optionsMap.get(r);return i?t.common.async?i._parseAsync({data:t.data,path:t.path,parent:t}):i._parseSync({data:t.data,path:t.path,parent:t}):(X(t,{code:Y.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),No)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,n,r){let i=new Map;for(let e of n){let n=Ns(e.shape[t]);if(!n.length)throw Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let r of n){if(i.has(r))throw Error(`Discriminator property ${String(t)} has duplicate value ${String(r)}`);i.set(r,e)}}return new e({typeName:rc.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:i,...Uo(r)})}};function Fs(e,t){let n=Eo(e),r=Eo(t);if(e===t)return{valid:!0,data:e};if(n===To.object&&r===To.object){let n=Co.objectKeys(t),r=Co.objectKeys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=Fs(e[n],t[n]);if(!r.valid)return{valid:!1};i[n]=r.data}return{valid:!0,data:i}}else if(n===To.array&&r===To.array){if(e.length!==t.length)return{valid:!1};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=Fs(i,a);if(!o.valid)return{valid:!1};n.push(o.data)}return{valid:!0,data:n}}else if(n===To.date&&r===To.date&&+e==+t)return{valid:!0,data:e};else return{valid:!1}}var Is=class extends Wo{_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=(e,r)=>{if(Io(e)||Io(r))return No;let i=Fs(e.value,r.value);return i.valid?((Lo(e)||Lo(r))&&t.dirty(),{status:t.value,value:i.data}):(X(n,{code:Y.invalid_intersection_types}),No)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([e,t])=>r(e,t)):r(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};Is.create=(e,t,n)=>new Is({left:e,right:t,typeName:rc.ZodIntersection,...Uo(n)});var Ls=class e extends Wo{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==To.array)return X(n,{code:Y.invalid_type,expected:To.array,received:n.parsedType}),No;if(n.data.length<this._def.items.length)return X(n,{code:Y.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),No;!this._def.rest&&n.data.length>this._def.items.length&&(X(n,{code:Y.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),t.dirty());let r=[...n.data].map((e,t)=>{let r=this._def.items[t]||this._def.rest;return r?r._parse(new Vo(n,e,n.path,t)):null}).filter(e=>!!e);return n.common.async?Promise.all(r).then(e=>Mo.mergeArray(t,e)):Mo.mergeArray(t,r)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};Ls.create=(e,t)=>{if(!Array.isArray(e))throw Error(`You must pass an array of schemas to z.tuple([ ... ])`);return new Ls({items:e,typeName:rc.ZodTuple,rest:null,...Uo(t)})};var Rs=class e extends Wo{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==To.object)return X(n,{code:Y.invalid_type,expected:To.object,received:n.parsedType}),No;let r=[],i=this._def.keyType,a=this._def.valueType;for(let e in n.data)r.push({key:i._parse(new Vo(n,e,n.path,e)),value:a._parse(new Vo(n,n.data[e],n.path,e)),alwaysSet:e in n.data});return n.common.async?Mo.mergeObjectAsync(t,r):Mo.mergeObjectSync(t,r)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof Wo?new e({keyType:t,valueType:n,typeName:rc.ZodRecord,...Uo(r)}):new e({keyType:gs.create(),valueType:t,typeName:rc.ZodRecord,...Uo(n)})}},zs=class extends Wo{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==To.map)return X(n,{code:Y.invalid_type,expected:To.map,received:n.parsedType}),No;let r=this._def.keyType,i=this._def.valueType,a=[...n.data.entries()].map(([e,t],a)=>({key:r._parse(new Vo(n,e,n.path,[a,`key`])),value:i._parse(new Vo(n,t,n.path,[a,`value`]))}));if(n.common.async){let e=new Map;return Promise.resolve().then(async()=>{for(let n of a){let r=await n.key,i=await n.value;if(r.status===`aborted`||i.status===`aborted`)return No;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}})}else{let e=new Map;for(let n of a){let r=n.key,i=n.value;if(r.status===`aborted`||i.status===`aborted`)return No;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}}}};zs.create=(e,t,n)=>new zs({valueType:t,keyType:e,typeName:rc.ZodMap,...Uo(n)});var Bs=class e extends Wo{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==To.set)return X(n,{code:Y.invalid_type,expected:To.set,received:n.parsedType}),No;let r=this._def;r.minSize!==null&&n.data.size<r.minSize.value&&(X(n,{code:Y.too_small,minimum:r.minSize.value,type:`set`,inclusive:!0,exact:!1,message:r.minSize.message}),t.dirty()),r.maxSize!==null&&n.data.size>r.maxSize.value&&(X(n,{code:Y.too_big,maximum:r.maxSize.value,type:`set`,inclusive:!0,exact:!1,message:r.maxSize.message}),t.dirty());let i=this._def.valueType;function a(e){let n=new Set;for(let r of e){if(r.status===`aborted`)return No;r.status===`dirty`&&t.dirty(),n.add(r.value)}return{status:t.value,value:n}}let o=[...n.data.values()].map((e,t)=>i._parse(new Vo(n,e,n.path,t)));return n.common.async?Promise.all(o).then(e=>a(e)):a(o)}min(t,n){return new e({...this._def,minSize:{value:t,message:Bo.toString(n)}})}max(t,n){return new e({...this._def,maxSize:{value:t,message:Bo.toString(n)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};Bs.create=(e,t)=>new Bs({valueType:e,minSize:null,maxSize:null,typeName:rc.ZodSet,...Uo(t)});var Vs=class e extends Wo{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==To.function)return X(t,{code:Y.invalid_type,expected:To.function,received:t.parsedType}),No;function n(e,n){return jo({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Ao(),Oo].filter(e=>!!e),issueData:{code:Y.invalid_arguments,argumentsError:n}})}function r(e,n){return jo({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Ao(),Oo].filter(e=>!!e),issueData:{code:Y.invalid_return_type,returnTypeError:n}})}let i={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof qs){let e=this;return Fo(async function(...t){let o=new Do([]),s=await e._def.args.parseAsync(t,i).catch(e=>{throw o.addIssue(n(t,e)),o}),c=await Reflect.apply(a,this,s);return await e._def.returns._def.type.parseAsync(c,i).catch(e=>{throw o.addIssue(r(c,e)),o})})}else{let e=this;return Fo(function(...t){let o=e._def.args.safeParse(t,i);if(!o.success)throw new Do([n(t,o.error)]);let s=Reflect.apply(a,this,o.data),c=e._def.returns.safeParse(s,i);if(!c.success)throw new Do([r(s,c.error)]);return c.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new e({...this._def,args:Ls.create(t).rest(Es.create())})}returns(t){return new e({...this._def,returns:t})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(t,n,r){return new e({args:t||Ls.create([]).rest(Es.create()),returns:n||Es.create(),typeName:rc.ZodFunction,...Uo(r)})}},Hs=class extends Wo{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};Hs.create=(e,t)=>new Hs({getter:e,typeName:rc.ZodLazy,...Uo(t)});var Us=class extends Wo{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return X(t,{received:t.data,code:Y.invalid_literal,expected:this._def.value}),No}return{status:`valid`,value:e.data}}get value(){return this._def.value}};Us.create=(e,t)=>new Us({value:e,typeName:rc.ZodLiteral,...Uo(t)});function Ws(e,t){return new Gs({values:e,typeName:rc.ZodEnum,...Uo(t)})}var Gs=class e extends Wo{_parse(e){if(typeof e.data!=`string`){let t=this._getOrReturnCtx(e),n=this._def.values;return X(t,{expected:Co.joinValues(n),received:t.parsedType,code:Y.invalid_type}),No}if(this._cache||=new Set(this._def.values),!this._cache.has(e.data)){let t=this._getOrReturnCtx(e),n=this._def.values;return X(t,{received:t.data,code:Y.invalid_enum_value,options:n}),No}return Fo(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(t,n=this._def){return e.create(t,{...this._def,...n})}exclude(t,n=this._def){return e.create(this.options.filter(e=>!t.includes(e)),{...this._def,...n})}};Gs.create=Ws;var Ks=class extends Wo{_parse(e){let t=Co.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==To.string&&n.parsedType!==To.number){let e=Co.objectValues(t);return X(n,{expected:Co.joinValues(e),received:n.parsedType,code:Y.invalid_type}),No}if(this._cache||=new Set(Co.getValidEnumValues(this._def.values)),!this._cache.has(e.data)){let e=Co.objectValues(t);return X(n,{received:n.data,code:Y.invalid_enum_value,options:e}),No}return Fo(e.data)}get enum(){return this._def.values}};Ks.create=(e,t)=>new Ks({values:e,typeName:rc.ZodNativeEnum,...Uo(t)});var qs=class extends Wo{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);return t.parsedType!==To.promise&&t.common.async===!1?(X(t,{code:Y.invalid_type,expected:To.promise,received:t.parsedType}),No):Fo((t.parsedType===To.promise?t.data:Promise.resolve(t.data)).then(e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap})))}};qs.create=(e,t)=>new qs({type:e,typeName:rc.ZodPromise,...Uo(t)});var Js=class extends Wo{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===rc.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=this._def.effect||null,i={addIssue:e=>{X(n,e),e.fatal?t.abort():t.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),r.type===`preprocess`){let e=r.transform(n.data,i);if(n.common.async)return Promise.resolve(e).then(async e=>{if(t.value===`aborted`)return No;let r=await this._def.schema._parseAsync({data:e,path:n.path,parent:n});return r.status===`aborted`?No:r.status===`dirty`||t.value===`dirty`?Po(r.value):r});{if(t.value===`aborted`)return No;let r=this._def.schema._parseSync({data:e,path:n.path,parent:n});return r.status===`aborted`?No:r.status===`dirty`||t.value===`dirty`?Po(r.value):r}}if(r.type===`refinement`){let e=e=>{let t=r.refinement(e,i);if(n.common.async)return Promise.resolve(t);if(t instanceof Promise)throw Error(`Async refinement encountered during synchronous parse operation. Use .parseAsync instead.`);return e};if(n.common.async===!1){let r=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return r.status===`aborted`?No:(r.status===`dirty`&&t.dirty(),e(r.value),{status:t.value,value:r.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(n=>n.status===`aborted`?No:(n.status===`dirty`&&t.dirty(),e(n.value).then(()=>({status:t.value,value:n.value}))))}if(r.type===`transform`)if(n.common.async===!1){let e=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!Ro(e))return No;let a=r.transform(e.value,i);if(a instanceof Promise)throw Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);return{status:t.value,value:a}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(e=>Ro(e)?Promise.resolve(r.transform(e.value,i)).then(e=>({status:t.value,value:e})):No);Co.assertNever(r)}};Js.create=(e,t,n)=>new Js({schema:e,typeName:rc.ZodEffects,effect:t,...Uo(n)}),Js.createWithPreprocess=(e,t,n)=>new Js({schema:t,effect:{type:`preprocess`,transform:e},typeName:rc.ZodEffects,...Uo(n)});var Ys=class extends Wo{_parse(e){return this._getType(e)===To.undefined?Fo(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Ys.create=(e,t)=>new Ys({innerType:e,typeName:rc.ZodOptional,...Uo(t)});var Xs=class extends Wo{_parse(e){return this._getType(e)===To.null?Fo(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Xs.create=(e,t)=>new Xs({innerType:e,typeName:rc.ZodNullable,...Uo(t)});var Zs=class extends Wo{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return t.parsedType===To.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};Zs.create=(e,t)=>new Zs({innerType:e,typeName:rc.ZodDefault,defaultValue:typeof t.default==`function`?t.default:()=>t.default,...Uo(t)});var Qs=class extends Wo{_parse(e){let{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},r=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return zo(r)?r.then(e=>({status:`valid`,value:e.status===`valid`?e.value:this._def.catchValue({get error(){return new Do(n.common.issues)},input:n.data})})):{status:`valid`,value:r.status===`valid`?r.value:this._def.catchValue({get error(){return new Do(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};Qs.create=(e,t)=>new Qs({innerType:e,typeName:rc.ZodCatch,catchValue:typeof t.catch==`function`?t.catch:()=>t.catch,...Uo(t)});var $s=class extends Wo{_parse(e){if(this._getType(e)!==To.nan){let t=this._getOrReturnCtx(e);return X(t,{code:Y.invalid_type,expected:To.nan,received:t.parsedType}),No}return{status:`valid`,value:e.data}}};$s.create=e=>new $s({typeName:rc.ZodNaN,...Uo(e)});var ec=class extends Wo{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}},tc=class e extends Wo{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let e=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?No:e.status===`dirty`?(t.dirty(),Po(e.value)):this._def.out._parseAsync({data:e.value,path:n.path,parent:n})})();{let e=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?No:e.status===`dirty`?(t.dirty(),{status:`dirty`,value:e.value}):this._def.out._parseSync({data:e.value,path:n.path,parent:n})}}static create(t,n){return new e({in:t,out:n,typeName:rc.ZodPipeline})}},nc=class extends Wo{_parse(e){let t=this._def.innerType._parse(e),n=e=>(Ro(e)&&(e.value=Object.freeze(e.value)),e);return zo(t)?t.then(e=>n(e)):n(t)}unwrap(){return this._def.innerType}};nc.create=(e,t)=>new nc({innerType:e,typeName:rc.ZodReadonly,...Uo(t)}),js.lazycreate;var rc;(function(e){e.ZodString=`ZodString`,e.ZodNumber=`ZodNumber`,e.ZodNaN=`ZodNaN`,e.ZodBigInt=`ZodBigInt`,e.ZodBoolean=`ZodBoolean`,e.ZodDate=`ZodDate`,e.ZodSymbol=`ZodSymbol`,e.ZodUndefined=`ZodUndefined`,e.ZodNull=`ZodNull`,e.ZodAny=`ZodAny`,e.ZodUnknown=`ZodUnknown`,e.ZodNever=`ZodNever`,e.ZodVoid=`ZodVoid`,e.ZodArray=`ZodArray`,e.ZodObject=`ZodObject`,e.ZodUnion=`ZodUnion`,e.ZodDiscriminatedUnion=`ZodDiscriminatedUnion`,e.ZodIntersection=`ZodIntersection`,e.ZodTuple=`ZodTuple`,e.ZodRecord=`ZodRecord`,e.ZodMap=`ZodMap`,e.ZodSet=`ZodSet`,e.ZodFunction=`ZodFunction`,e.ZodLazy=`ZodLazy`,e.ZodLiteral=`ZodLiteral`,e.ZodEnum=`ZodEnum`,e.ZodEffects=`ZodEffects`,e.ZodNativeEnum=`ZodNativeEnum`,e.ZodOptional=`ZodOptional`,e.ZodNullable=`ZodNullable`,e.ZodDefault=`ZodDefault`,e.ZodCatch=`ZodCatch`,e.ZodPromise=`ZodPromise`,e.ZodBranded=`ZodBranded`,e.ZodPipeline=`ZodPipeline`,e.ZodReadonly=`ZodReadonly`})(rc||={}),gs.create,vs.create,$s.create,ys.create,bs.create,xs.create,Ss.create,Cs.create,ws.create,Ts.create,Es.create,Ds.create,Os.create,ks.create,js.create,js.strictCreate,Ms.create,Ps.create,Is.create,Ls.create,Rs.create,zs.create,Bs.create,Vs.create,Hs.create,Us.create;var ic=Gs.create;Ks.create,qs.create,Js.create,Ys.create,Xs.create,Js.createWithPreprocess,tc.create,ic([`highlight`,`note`,`comment`]),ic([`pending`,`accepted`,`dismissed`]),ic([`yellow`,`green`,`blue`,`pink`]),ic([`info`,`warning`,`error`,`success`]);var ac=ic([`solo`,`tandem`]);ic([`user`,`claude`,`import`]),ic([`user`,`claude`,`import`]),ic([`accept`,`dismiss`]),ic([`markdown`,`json`]),ic([`md`,`txt`,`html`,`docx`]),ic([`RANGE_GONE`,`RANGE_MOVED`,`FILE_LOCKED`,`FILE_NOT_FOUND`,`NO_DOCUMENT`,`INVALID_RANGE`,`INVALID_ARGUMENT`,`NOT_FOUND`,`ANNOTATION_RESOLVED`,`FORMAT_ERROR`,`PERMISSION_DENIED`]),ic([`CHANNEL_CONNECT_FAILED`,`MONITOR_CONNECT_FAILED`]);function oc(e){return e.author!==`user`}function sc(e){return e.status===`pending`&&oc(e)}function cc(e){return`${e}_${Date.now()}_${Math.random().toString(36).slice(2,8)}`}function lc(){return cc(`ann`)}function uc(){return cc(`msg`)}function dc(){return cc(`ntf`)}function fc(e){return cc(e)}var pc=`/api/notify-stream`,mc=`/api/info`,hc=`/api/diagnostics`,gc=`/health`,_c=`/api/open`,vc=`/api/close`,yc=`/api/save`,bc=`/api/rename`,xc=`/api/upload`,Sc=`/api/scratchpad`,Cc=`/api/convert`,wc=`/api/apply-changes`,Tc=`/api/document/raw`,Ec=`/api/document/reload`,Dc=`/api/backups`,Oc=`/api/backups/restore`,kc=`/api/docx-conflict/resolve`,Ac=`/api/annotation-reply`,jc=`/api/remove-annotation`,Mc=`/api/store/reclaim-lock`,Nc=`/api/chat`,Pc=`/api/sessions`,Fc=`/api/sessions/delete`,Ic=`/api/sessions/clear`,Lc=`/api/license/status`,Rc=`/api/license/activate`,zc=`/api/launcher/status`,Bc=`/api/launcher/nonce`,Vc=`/api/launcher/relaunch`,Hc=`/api/launcher/start-fresh`,Uc=`/api/launcher/working-directory`,Wc=[`save`,`save-as`,`settings`,`settings-modal`,`toggle-palette`,`new-scratchpad`,`close-tab`,`open-file`,`toggle-mode`,`reopen-closed-tab`,`comment-on-selection`,`toggle-authorship`,`toggle-left-panel`,`toggle-right-panel`,`annotation-next`,`annotation-prev`,`select-block`,`new-tab-menu`],Gc=new Set(Wc);function Kc(e){return Gc.has(e)}var qc={save:`Save document`,"save-as":`Save As…`,settings:`Open settings`,"settings-modal":`Open settings (new)`,"toggle-palette":`Toggle command palette`,"new-scratchpad":`New Scratchpad`,"close-tab":`Close active tab`,"open-file":`Open file…`,"toggle-mode":`Toggle Solo / Tandem mode`,"reopen-closed-tab":`Reopen closed tab`,"comment-on-selection":`Comment on selection`,"toggle-authorship":`Toggle authorship colors`,"toggle-left-panel":`Toggle left panel`,"toggle-right-panel":`Toggle right panel`,"annotation-next":`Next annotation`,"annotation-prev":`Previous annotation`,"select-block":`Select containing block`,"new-tab-menu":`New tab menu`},Jc={save:{ctrlOrMeta:!0,alt:!1,shift:!1,code:`KeyS`},"save-as":{ctrlOrMeta:!0,alt:!1,shift:!0,code:`KeyS`},settings:{ctrlOrMeta:!0,alt:!1,shift:!1,code:`Comma`},"settings-modal":{ctrlOrMeta:!0,alt:!1,shift:!0,code:`Comma`},"toggle-palette":{ctrlOrMeta:!0,alt:!1,shift:!0,code:`KeyP`},"new-scratchpad":{ctrlOrMeta:!0,alt:!1,shift:!1,code:`KeyN`},"close-tab":{ctrlOrMeta:!0,alt:!1,shift:!1,code:`KeyW`},"open-file":{ctrlOrMeta:!0,alt:!1,shift:!1,code:`KeyO`},"toggle-mode":{ctrlOrMeta:!0,alt:!1,shift:!0,code:`KeyM`},"reopen-closed-tab":{ctrlOrMeta:!0,alt:!0,shift:!1,code:`KeyT`},"comment-on-selection":{ctrlOrMeta:!0,alt:!0,shift:!1,code:`KeyM`},"toggle-authorship":{ctrlOrMeta:!0,alt:!0,shift:!1,code:`KeyA`},"toggle-left-panel":{ctrlOrMeta:!1,alt:!0,shift:!0,code:`ArrowLeft`},"toggle-right-panel":{ctrlOrMeta:!1,alt:!0,shift:!0,code:`ArrowRight`},"annotation-next":{ctrlOrMeta:!1,alt:!0,shift:!1,code:`BracketRight`},"annotation-prev":{ctrlOrMeta:!1,alt:!0,shift:!1,code:`BracketLeft`},"select-block":{ctrlOrMeta:!1,alt:!0,shift:!1,code:`KeyL`},"new-tab-menu":{ctrlOrMeta:!0,alt:!1,shift:!1,code:`KeyT`}},Yc=[{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`}],Xc={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`},Zc=/^(Control|Shift|Alt|Meta|OS)/,Qc=new Set([`Tab`,`Escape`,`Enter`,`NumpadEnter`,`NumLock`,`CapsLock`,`ContextMenu`,`Insert`]);function $c(e){return Zc.test(e.code)||e.code.startsWith(`Numpad`)||Qc.has(e.code)?!1:e.ctrlOrMeta||e.alt}function el(e){if(!e.code||e.key===`Dead`)return null;let t={ctrlOrMeta:e.ctrlKey||e.metaKey,alt:e.altKey,shift:e.shiftKey,code:e.code};return $c(t)?t:null}function tl(e,t){return e.ctrlOrMeta===(t.ctrlKey||t.metaKey)&&e.alt===t.altKey&&e.shift===t.shiftKey&&e.code===t.code}function nl(e,t){return e.ctrlOrMeta===t.ctrlOrMeta&&e.alt===t.alt&&e.shift===t.shift&&e.code===t.code}function rl(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.ctrlOrMeta==`boolean`&&typeof t.alt==`boolean`&&typeof t.shift==`boolean`&&typeof t.code==`string`&&t.code.length>0&&t.code.length<=32}function il(){try{if(typeof navigator>`u`)return!1;let e=navigator.userAgentData?.platform??navigator.platform;return/Mac|iPhone|iPad|iPod/i.test(e??``)}catch{return!1}}function al(e){return e.startsWith(`Key`)?e.slice(3):e.startsWith(`Digit`)?e.slice(5):{Comma:`,`,Period:`.`,Slash:`/`,Backslash:`\\`,Semicolon:`;`,Quote:`'`,BracketLeft:`[`,BracketRight:`]`,Backquote:"`",Minus:`-`,Equal:`=`,Space:`Space`,Tab:`Tab`,Enter:`Enter`,ArrowLeft:`←`,ArrowRight:`→`,ArrowUp:`↑`,ArrowDown:`↓`}[e]??e}function ol(e){let t=il(),n=[];return e.ctrlOrMeta&&n.push(t?`⌘`:`Ctrl`),e.alt&&n.push(t?`⌥`:`Alt`),e.shift&&n.push(t?`⇧`:`Shift`),n.push(al(e.code)),t?n.join(``):n.join(`+`)}function sl(e,t){return t.get(e)??Jc[e]}function cl(e){let t=new Map;for(let n of Wc)t.set(n,ol(sl(n,e)));return t}function ll(e,t){return t?t.has(e):!1}function ul(e,t){if(e.isComposing)return null;if(t&&t.size>0)for(let n of Wc){let r=t.get(n);if(r&&tl(r,e))return{id:n}}let n=e.ctrlKey||e.metaKey;if(e.key===`?`)return{id:`toggle-help`};if(n){if(e.shiftKey&&e.code===`Comma`&&!ll(`settings-modal`,t))return{id:`settings-modal`};if(!e.shiftKey&&e.code===`Comma`&&!ll(`settings`,t))return{id:`settings`};if(e.key===`/`)return{id:`toggle-help`};if(!e.altKey&&!e.shiftKey&&e.code===`KeyA`)return{id:`select-all`};if(e.shiftKey&&!e.altKey&&e.code===`KeyS`&&!ll(`save-as`,t))return{id:`save-as`};if(e.code===`KeyS`&&!ll(`save`,t))return{id:`save`};if(e.shiftKey&&e.code===`KeyP`&&!ll(`toggle-palette`,t))return{id:`toggle-palette`};if(e.code===`KeyN`&&!ll(`new-scratchpad`,t))return{id:`new-scratchpad`};if(e.code===`KeyW`&&!ll(`close-tab`,t))return{id:`close-tab`};if(e.code===`KeyO`&&!ll(`open-file`,t))return{id:`open-file`};if(/^Digit[1-9]$/.test(e.code))return{id:`pick-tab`,context:{tabIndex:Number(e.code.slice(5))}};if(e.shiftKey&&!e.altKey&&e.code===`KeyM`&&!ll(`toggle-mode`,t))return{id:`toggle-mode`};if(e.altKey&&e.code===`KeyT`&&!ll(`reopen-closed-tab`,t))return{id:`reopen-closed-tab`};if(!e.altKey&&!e.shiftKey&&e.code===`KeyT`&&!ll(`new-tab-menu`,t))return{id:`new-tab-menu`};if(e.code===`KeyF`)return{id:`find`,context:{shift:e.shiftKey}};if(e.code===`KeyG`)return{id:`find-nav`,context:{shift:e.shiftKey}};if(e.key===`Enter`)return{id:`annotation-accept-or-dismiss`,context:{shift:e.shiftKey}};if(e.altKey&&e.code===`KeyM`&&!ll(`comment-on-selection`,t))return{id:`comment-on-selection`};if(e.altKey&&e.code===`KeyA`&&!ll(`toggle-authorship`,t))return{id:`toggle-authorship`}}if(e.altKey&&!e.ctrlKey&&!e.metaKey){if(e.shiftKey){if(e.code===`ArrowLeft`&&!ll(`toggle-left-panel`,t))return{id:`toggle-left-panel`};if(e.code===`ArrowRight`&&!ll(`toggle-right-panel`,t))return{id:`toggle-right-panel`}}if(!e.shiftKey){if(e.code===`BracketRight`&&!ll(`annotation-next`,t))return{id:`annotation-next`};if(e.code===`BracketLeft`&&!ll(`annotation-prev`,t))return{id:`annotation-prev`}}if(!e.shiftKey&&e.code===`KeyL`&&!ll(`select-block`,t))return{id:`select-block`}}return null}function dl(e){return e.code===`Slash`?e.shift?`?`:`/`:e.code===`Enter`||e.code===`NumpadEnter`?`Enter`:``}function fl(e){return{key:dl(e),code:e.code,ctrlKey:e.ctrlOrMeta,metaKey:!1,altKey:e.alt,shiftKey:e.shift,isComposing:!1}}function pl(e,t){switch(e){case`toggle-help`:return`Show keyboard shortcuts`;case`select-all`:return`Select all`;case`find`:return t?.shift?`Find in open tabs`:`Find / Replace`;case`find-nav`:return t?.shift?`Find previous`:`Find next`;case`annotation-accept-or-dismiss`:return t?.shift?`Dismiss annotation`:`Accept annotation`;case`pick-tab`:return t?.tabIndex?`Jump to tab ${t.tabIndex}`:`Jump to tab`;default:return``}}function ml(e){let t=ul(fl(e));return!t||Kc(t.id)?null:pl(t.id,t.context)||null}function hl(e,t,n){for(let r of Wc)if(r!==n&&nl(sl(r,t),e))return qc[r];let r=ml(e);if(r)return r;for(let t of Yc)if(nl(t.chord,e))return t.label;return null}function gl(e){return Yc.some(t=>nl(t.chord,e))}function _l(e){if(!e||typeof e!=`object`||Array.isArray(e))return{};let t={};for(let[n,r]of Object.entries(e))Kc(n)&&rl(r)&&$c(r)&&(gl(r)||ml(r)||(t[n]=r));let n={},r=[];for(let e of Wc){let i=t[e];i&&(r.some(e=>nl(e,i))||(r.push(i),n[e]=i))}return n}function vl(e){let t=new Map;for(let[n,r]of Object.entries(_l(e)))t.set(n,r);return t}var yl=[`narrow`,`comfortable`,`wide`,`full`],bl={narrow:`58ch`,comfortable:`68ch`,wide:`82ch`,full:`100%`};function xl(e){return typeof e==`string`&&yl.includes(e)}var Sl=[`anthropic`,`openai`,`gemini`,`local-ollama`,`local-llamacpp`],Cl=50,wl={s:14,m:16,l:18};function Tl(){try{return typeof window>`u`?!1:window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}catch{return!1}}var El={leftPanelVisible:!1,rightPanelVisible:!0,schemaVersion:17,primaryTab:`annotations`,panelOrder:`chat-editor-annotations`,editorMeasure:`comfortable`,selectionDwellMs:Pa,showAuthorship:!0,reduceMotion:!1,textSize:`m`,theme:`system`,systemLightVariant:`light`,accentHue:275,editorFont:`sans`,fontByExtension:{},defaultSaveDirectory:null,density:`cozy`,defaultMode:`tandem`,highContrast:!1,annotationPatterns:!1,selectionToolbar:!0,formattingBarVisible:!0,railHoverReveal:!0,soloRailHidden:!0,degradedBannerDelayMs:3e4,sidecarRetryStrategy:`exponential`,marginView:!1,showComments:!0,showHighlights:!0,showNotes:!0,showRawMarkdown:!0,decorationsMuted:!1,models:[],defaultModelId:null,customShortcuts:{},smartTypography:!1,spellcheck:!0},Dl=64,Ol=512;function kl(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(t.length>=Cl)break;if(!n||typeof n!=`object`)continue;let e=n;if(typeof e.id!=`string`||e.id.length===0||e.id.length>64||typeof e.provider!=`string`||!Sl.includes(e.provider)||typeof e.displayName!=`string`||e.displayName.length>256||typeof e.modelId!=`string`||e.modelId.length===0||e.modelId.length>256||typeof e.enabled!=`boolean`)continue;let r={id:e.id,provider:e.provider,displayName:e.displayName,modelId:e.modelId,enabled:e.enabled};if(typeof e.apiKeyRef==`string`&&e.apiKeyRef.length>0&&e.apiKeyRef.length<=Dl&&/^[A-Za-z0-9_-]+$/.test(e.apiKeyRef)?r.apiKeyRef=e.apiKeyRef:typeof e.apiKey==`string`&&e.apiKey.length<=Ol&&(r._legacyApiKey=e.apiKey),typeof e.endpoint==`string`&&e.endpoint.length<=2048&&(r.endpoint=e.endpoint),e.params&&typeof e.params==`object`&&!Array.isArray(e.params)){let t={};for(let[n,r]of Object.entries(e.params))(typeof r==`number`||typeof r==`string`||typeof r==`boolean`)&&(t[n]=r);r.params=t}t.push(r)}return t}var Al=[`serif`,`sans`,`mono`];function jl(e){if(!e||typeof e!=`object`||Array.isArray(e))return{};let t={};for(let[n,r]of Object.entries(e))n===`__proto__`||n===`constructor`||n===`prototype`||typeof n!=`string`||n.length===0||n.length>32||typeof r==`string`&&Al.includes(r)&&(t[n]=r);return t}function Ml(e){return{leftPanelVisible:e.leftPanelVisible===!0,rightPanelVisible:e.rightPanelVisible!==!1,schemaVersion:17,primaryTab:e.primaryTab===`annotations`?`annotations`:`chat`,panelOrder:e.panelOrder===`annotations-editor-chat`?`annotations-editor-chat`:`chat-editor-annotations`,editorMeasure:xl(e.editorMeasure)?e.editorMeasure:El.editorMeasure,selectionDwellMs:Math.max(500,Math.min(Fa,Number(e.selectionDwellMs)||1e3)),showAuthorship:e.showAuthorship===!1?!1:El.showAuthorship,reduceMotion:typeof e.reduceMotion==`boolean`?e.reduceMotion:Tl(),textSize:e.textSize===`s`||e.textSize===`m`||e.textSize===`l`?e.textSize:El.textSize,theme:e.theme===`light`||e.theme===`dark`||e.theme===`warm`||e.theme===`system`?e.theme:El.theme,systemLightVariant:e.systemLightVariant===`warm`?`warm`:El.systemLightVariant,accentHue:typeof e.accentHue==`number`&&e.accentHue>=0&&e.accentHue<=360?e.accentHue:El.accentHue,editorFont:e.editorFont===`serif`||e.editorFont===`sans`||e.editorFont===`mono`?e.editorFont:El.editorFont,fontByExtension:jl(e.fontByExtension),defaultSaveDirectory:typeof e.defaultSaveDirectory==`string`&&e.defaultSaveDirectory.trim()?e.defaultSaveDirectory.trim():null,density:e.density===`compact`||e.density===`cozy`||e.density===`spacious`?e.density:El.density,defaultMode:e.defaultMode===`solo`||e.defaultMode===`tandem`?e.defaultMode:El.defaultMode,highContrast:e.highContrast===!0,annotationPatterns:e.annotationPatterns===!0,selectionToolbar:e.selectionToolbar===!1?!1:El.selectionToolbar,formattingBarVisible:e.formattingBarVisible===!1?!1:El.formattingBarVisible,railHoverReveal:e.railHoverReveal===!1?!1:El.railHoverReveal,soloRailHidden:e.soloRailHidden===!1?!1:El.soloRailHidden,degradedBannerDelayMs:typeof e.degradedBannerDelayMs==`number`&&e.degradedBannerDelayMs>=5e3&&e.degradedBannerDelayMs<=12e4?e.degradedBannerDelayMs:El.degradedBannerDelayMs,sidecarRetryStrategy:e.sidecarRetryStrategy===`exponential`||e.sidecarRetryStrategy===`constant-2s`?e.sidecarRetryStrategy:El.sidecarRetryStrategy,marginView:e.marginView===!0,showComments:e.showComments===!1?!1:El.showComments,showHighlights:e.showHighlights===!1?!1:El.showHighlights,showNotes:e.showNotes===!1?!1:El.showNotes,showRawMarkdown:e.showRawMarkdown===!1?!1:El.showRawMarkdown,decorationsMuted:e.decorationsMuted===!0,models:kl(e.models),defaultModelId:typeof e.defaultModelId==`string`&&e.defaultModelId.length>0?e.defaultModelId:null,customShortcuts:_l(e.customShortcuts),smartTypography:e.smartTypography===!0,spellcheck:e.spellcheck===!1?!1:El.spellcheck}}function Nl(){let e;try{e=localStorage.getItem(Ma)}catch{e=null}if(e)try{let t=JSON.parse(e);if((!t||typeof t!=`object`||Array.isArray(t))&&(t={leftPanelVisible:!1,rightPanelVisible:!0,schemaVersion:1}),(typeof t.schemaVersion==`number`?t.schemaVersion:1)===1){let e=t.panelHidden===!0,n=!1,r=!0;e?(n=!1,r=!1):t.layout===`three-panel`?(n=!0,r=!0):t.layout===`tabbed-left`&&(n=!0,r=!1),t={...t,leftPanelVisible:n,rightPanelVisible:r,schemaVersion:2},delete t.layout,delete t.panelHidden}if(t.schemaVersion===2&&(t={...t,models:[],schemaVersion:3}),t.schemaVersion===3&&(t={...t,schemaVersion:4}),t.schemaVersion===4){let e={...t,schemaVersion:5};delete e.leftRailTabs,delete e.rightRailTabs,t=e}if(t.schemaVersion===5){let e={...t,schemaVersion:6};delete e.showIntegrationWizard,t=e}if(t.schemaVersion===6){let e=(Array.isArray(t.models)?t.models:[]).find(e=>typeof e?.id==`string`&&e.enabled===!0);t={...t,schemaVersion:7,defaultModelId:e&&typeof e.id==`string`?e.id:null}}if(t.schemaVersion===7&&(t={...t,schemaVersion:8}),t.schemaVersion===8){let e=t.showAnnotationDecorations===!1,n={...t,showComments:!e,showHighlights:!e,showNotes:!e,decorationsMuted:!1,schemaVersion:9};delete n.showAnnotationDecorations,t=n}if(t.schemaVersion===9&&(t={...t,schemaVersion:10}),t.schemaVersion===10&&(t={...t,schemaVersion:11}),t.schemaVersion===11){let e={...t,schemaVersion:12};if(e.editorMeasure===void 0){let n=t.editorWidthPercent;e.editorMeasure=n===void 0||n===100?`full`:`comfortable`}delete e.editorWidthPercent,t=e}if(t.showAnnotationDecorations===!1&&t.showComments===void 0&&(t={...t,showComments:!1,showHighlights:!1,showNotes:!1}),t.schemaVersion===12&&(t={...t,schemaVersion:13}),t.schemaVersion===13&&(t={...t,schemaVersion:14}),t.schemaVersion===14&&(t={...t,schemaVersion:15}),t.schemaVersion===15){let e={...t,schemaVersion:16};delete e.holdAnnotationsWhileOffline,e.sidecarRetryStrategy===`manual`&&(e.sidecarRetryStrategy=`exponential`),t=e}if(t.schemaVersion===16&&(t={...t,schemaVersion:17}),typeof t.schemaVersion==`number`&&t.schemaVersion>17){console.warn(`[tandem] settings schemaVersion=${t.schemaVersion} is newer than v17; loading defensively without writing.`);let e=t.editorMeasure,n=Ml(t);typeof e==`string`&&e!==n.editorMeasure&&console.warn(`[tandem] editorMeasure=${JSON.stringify(e)} from newer client is unknown to v17; displaying as ${JSON.stringify(n.editorMeasure)} (your setting is preserved on-disk).`);let r=new Set(Object.keys(n)),i=new Set([`leftRailTabs`,`rightRailTabs`,`showIntegrationWizard`,`showAnnotationDecorations`,`editorWidthPercent`,`holdAnnotationsWhileOffline`]),a={};for(let[e,n]of Object.entries(t))!r.has(e)&&e!==`_readOnly`&&!i.has(e)&&(a[e]=n);return{...n,...a,_readOnly:!0}}return Ml(t)}catch(e){console.warn(`[tandem] settings JSON is corrupt, resetting to defaults:`,e)}return{...El,reduceMotion:Tl()}}function Pl(e,t){let n={...e,...t},r=kl(n.models);return{...n,customShortcuts:_l(n.customShortcuts),fontByExtension:jl(n.fontByExtension),defaultSaveDirectory:typeof n.defaultSaveDirectory==`string`&&n.defaultSaveDirectory.trim()?n.defaultSaveDirectory.trim():null,selectionDwellMs:Math.max(500,Math.min(Fa,n.selectionDwellMs)),accentHue:Number.isFinite(n.accentHue)?Math.max(0,Math.min(360,n.accentHue)):El.accentHue,editorMeasure:xl(n.editorMeasure)?n.editorMeasure:El.editorMeasure,degradedBannerDelayMs:Math.max(5e3,Math.min(12e4,n.degradedBannerDelayMs)),models:r,defaultModelId:typeof n.defaultModelId==`string`&&r.some(e=>e.id===n.defaultModelId)?n.defaultModelId:null}}function Fl(e,t){if(t){let n=e.fontByExtension?.[t];if(n)return n}return e.editorFont}var Il=`http://127.0.0.1:${ba}`;function Ll(e){let t=new Uint8Array(e),n=``;for(let e=0;e<t.length;e++)n+=String.fromCharCode(t[e]);return btoa(n)}function Rl(e){return e.toLowerCase().endsWith(`.docx`)}async function zl(e){return Rl(e.name)?Ll(await e.arrayBuffer()):e.text()}var Bl=`modulepreload`,Vl=function(e){return`/`+e},Hl={},Ul=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}r=o(t.map(t=>{if(t=Vl(t,n),t in Hl)return;Hl[t]=!0;let r=t.endsWith(`.css`),i=r?`[rel="stylesheet"]`:``;if(n)for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}else if(document.querySelector(`link[href="${t}"]${i}`))return;let o=document.createElement(`link`);if(o.rel=r?`stylesheet`:Bl,r||(o.as=`script`),o.crossOrigin=``,o.href=t,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),r)return new Promise((e,n)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})};function Wl(){try{return Nl().defaultSaveDirectory}catch{return null}}async function Gl(){let e=new AbortController,t=setTimeout(()=>e.abort(),250);try{let t=await fetch(`${Il}/api/integrations`,{signal:e.signal});if(!t.ok)return null;let n=(await t.json()).integrations?.find(e=>e.kind===`claude-code`)?.workingDirectory;return typeof n==`string`&&n.trim()?n.trim():null}catch{return null}finally{clearTimeout(t)}}async function Kl(){try{let{homeDir:e}=await Ul(async()=>{let{homeDir:e}=await import(`./path-49-uTKly.js`);return{homeDir:e}},__vite__mapDeps([0,1])),t=await e();return typeof t==`string`&&t.trim()?t:null}catch{return null}}async function ql(){return Wl()||await Gl()||await Kl()}function Jl(e,t,n=Date.now(),r=20){return[e.find(e=>e.path===t)??{path:t,openedAt:n},...e.filter(e=>e.path!==t)].slice(0,r)}function Yl(e){return e.map(e=>e.path)}function Xl(e,t=Date.now()){if(!e)return``;let n=t-e;if(n<6e4)return`just now`;let r=Math.floor(n/6e4);if(r<60)return`${r}m`;let i=Math.floor(r/60);return i<24?`${i}h`:`${Math.floor(i/24)}d`}function Zl(){try{let e=localStorage.getItem(ro);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.map(e=>{if(typeof e==`string`)return{path:e,openedAt:0};if(typeof e==`object`&&e&&typeof e.path==`string`){let t=e;return{path:t.path,openedAt:typeof t.openedAt==`number`?t.openedAt:0}}return null}).filter(e=>e!==null):[]}catch(e){return console.warn(`[tandem] failed to load recent files:`,e),[]}}function Ql(e){try{localStorage.setItem(ro,JSON.stringify(e)),ru()}catch(e){console.warn(`[tandem] failed to save recent files:`,e)}}function $l(){try{localStorage.removeItem(ro),ru()}catch(e){console.warn(`[tandem] failed to clear recent files:`,e)}}var eu=3e4,tu=null;function nu(){let e=Date.now();if(tu&&e-tu.ts<eu)return tu.files;let t=Zl();return tu={files:t,ts:e},t}function ru(){tu=null}var iu=[`editor`,`navigation`,`view`,`document`,`annotations`,`claude`],au=N(ln(new Map));function ou(e,t={}){if(B(au).has(e.id)&&!t.replace){let t=`[actions] id collision: "${e.id}" — existing action silently replaced. Pass { replace: true } to suppress this warning.`;console.warn(t)}return P(au,new Map(B(au)).set(e.id,e),!0),!0}function su(){return B(au)}var cu=null;function lu(e){cu=e}function uu(e,t){if(!cu){console.warn(`[actions] "${e}" invoked before App mounted — deps not wired yet`);return}t(cu)}var du=N(!1),fu=N(!1),pu={get saving(){return B(du)},get lastSaveOk(){return B(fu)}},mu=!1,hu=!1;function gu(e){return e.connected&&e.tabCount===0&&e.activeTabId===null}async function _u(){if(!hu){hu=!0;try{let e=await fetch(`${Il}${Sc}`,{method:`POST`});if(!e.ok){let t=await e.json().catch(()=>({}));console.warn(`[Tandem] New Scratchpad failed:`,t.message??e.statusText)}}catch(e){console.warn(`[Tandem] New Scratchpad request failed:`,e)}finally{hu=!1}}}function vu(){try{return typeof window<`u`&&`__TAURI_INTERNALS__`in window}catch{return!1}}var yu=!1;async function bu(e){let t=await ql();if(!t)return e;try{let{join:n}=await Ul(async()=>{let{join:e}=await import(`./path-49-uTKly.js`);return{join:e}},__vite__mapDeps([0,1]));return await n(t,e)}catch{return e}}function xu(e,t){let n=`.${t}`,r=Math.max(e.lastIndexOf(`/`),e.lastIndexOf(`\\`));return e.slice(r+1).includes(`.`)?e.slice(e.lastIndexOf(`.`)).toLowerCase()===n?e:`${e.slice(0,e.lastIndexOf(`.`))}${n}`:`${e}${n}`}function Su(e,t,n){let r=new Blob([e],{type:n}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=t,document.body.appendChild(a),a.click(),document.body.removeChild(a),setTimeout(()=>URL.revokeObjectURL(i),0)}async function Cu(e){if(yu)return;let{activeDocId:t,notify:n,defaultName:r,sourceFormat:i}=e;if(!t){n(`warning`,`No active document to save.`);return}yu=!0;try{vu()?await wu(t,n,r??`Scratchpad.md`):await Tu(t,n,i)}finally{yu=!1}}async function wu(e,t,n){let r;try{let{save:e}=await Ul(async()=>{let{save:e}=await import(`./dist-js-BWAGOggB.js`);return{save:e}},__vite__mapDeps([2,1]));r=await e({defaultPath:await bu(n),filters:[{name:`Markdown`,extensions:[`md`]},{name:`Plain Text`,extensions:[`txt`]}]})}catch(e){t(`error`,`Save As dialog unavailable: ${e instanceof Error?e.message:e}`);return}if(typeof r!=`string`||r.length===0)return;let i=r.toLowerCase().endsWith(`.txt`)?`txt`:`md`,a=xu(r,i);a!==r&&t(`info`,`Saving as ${i.toUpperCase()} — only .md and .txt are supported.`);try{let n=await fetch(`${Il}${yc}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({documentId:e,targetPath:a,format:i})});if(!n.ok){t(`error`,`Save As failed: ${(await n.json().catch(()=>({}))).message??n.statusText}`);return}let r=await n.json().catch(()=>null),o=r?.data?.fileName??a,s=r?.data?.targetPath??a;Ql(Jl(Zl(),s)),t(`info`,`Saved to ${o}.`)}catch(e){t(`error`,`Save As request failed: ${e instanceof Error?e.message:e}`)}}async function Tu(e,t,n){let r=n===`txt`?`txt`:`md`;try{let n=await fetch(`${Il}${yc}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({documentId:e,serialize:!0,format:r})});if(!n.ok){t(`error`,`Save As failed: ${(await n.json().catch(()=>({}))).message??n.statusText}`);return}let i=await n.json().catch(()=>null),a=i?.data?.content,o=i?.data?.fileName??`Scratchpad.${r}`;if(typeof a!=`string`){t(`error`,`Save As returned no content.`);return}Su(a,o,r===`md`?`text/markdown`:`text/plain`),t(`info`,`Downloaded; scratchpad remains in-session.`)}catch(e){t(`error`,`Save As request failed: ${e instanceof Error?e.message:e}`)}}async function Eu(e){if(!e||mu)return;mu=!0,P(du,!0);let t=!1;try{let n=await fetch(`${Il}${yc}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({documentId:e})});if(n.ok){t=!0;let e=await n.json().catch(()=>null);(e?.data?.integrityWarnings?.length??0)>0&&cu?.notify(`error`,`Saved, but some content may not have been preserved — your original is backed up. See the document notice, or run "Restore a backup of this document…" from the command palette.`);let r=e?.data?.fidelityWarnings?.length??0;r>0&&cu?.notify(`warning`,`Saved — ${r} Word feature${r===1?``:`s`} were simplified on export; see the document notice for details.`)}else{let e=(await n.json().catch(()=>({}))).message??n.statusText;console.warn(`[Tandem] Save failed:`,e),cu?.notify(`error`,`Save failed: ${e}`)}}catch(e){console.warn(`[Tandem] Save request failed:`,e),cu?.notify(`error`,`Save failed — check your connection and try again.`)}finally{mu=!1,P(du,!1),P(fu,t,!0)}}var Du=!1;async function Ou(){let e;try{e=await fetch(`${Il}${zc}`)}catch(e){return{ok:!1,kind:`network`,detail:e instanceof Error?e.message:String(e)}}return e.status===404?{ok:!1,kind:`not-built`}:e.ok?{ok:!0,value:await e.json()}:{ok:!1,kind:`server-error`,detail:`HTTP ${e.status}`}}async function ku(){let e;try{e=await fetch(`${Il}${Bc}`,{method:`GET`})}catch(e){return{ok:!1,kind:`network`,detail:e instanceof Error?e.message:String(e)}}if(e.status===404)return{ok:!1,kind:`not-built`};if(!e.ok)return{ok:!1,kind:`server-error`,detail:`HTTP ${e.status}`};let t=await e.json();return typeof t.nonce==`string`?{ok:!0,value:t.nonce}:{ok:!1,kind:`server-error`,detail:`malformed nonce response`}}function Au(e){if(!e||/^[a-z]+:\/\//.test(e))return null;let t=Math.max(e.lastIndexOf(`/`),e.lastIndexOf(`\\`));return t>0?e.slice(0,t):null}async function ju(e,t,n,r){let i=await ku();if(!i.ok){e.notify(`error`,`Failed to acquire launcher nonce: ${i.kind}${i.detail?` (${i.detail})`:``}.`);return}let a=i.value;try{let i=await fetch(`${Il}${t}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({...n,nonce:a})});if(!i.ok){let t=await i.json().catch(()=>({}));e.notify(`error`,`${r.failPrefix}: ${t.message??i.statusText}`);return}e.notify(`info`,r.successMessage)}catch(t){e.notify(`error`,`${r.requestFailPrefix}: ${t instanceof Error?t.message:t}`)}}async function Mu(e){if(Du)return!1;let t=await Ou();if(!t.ok)return t.kind===`not-built`?e.notify(`warning`,`Claude launcher not active in this Tandem build.`):t.kind===`network`?e.notify(`error`,`Cannot reach Tandem server${t.detail?`: ${t.detail}`:``}.`):e.notify(`error`,`Launcher status check failed${t.detail?`: ${t.detail}`:``}.`),!1;let n=t.value;return n.available?(`skillRefresh`in n&&n.skillRefresh&&e.notify(`warning`,`Bundled skill refresh failed: ${n.skillRefresh.message}. Run \`tandem setup\` to retry.`),!0):(e.notify(`warning`,`Claude launcher not active in this Tandem build.`),!1)}async function Nu(e){if(!await Mu(e))return;let t=Au(e.getActiveDocumentPath());if(!t){e.notify(`warning`,`Active document isn't saved to a folder. Set a working directory in Settings → Claude Code.`);return}if(confirm(`Restart Claude in:\n${t}\n\nYour current task may be interrupted.`)){Du=!0;try{await ju(e,Vc,{cwd:t},{failPrefix:`Relaunch failed`,requestFailPrefix:`Relaunch request failed`,successMessage:`Claude restarting in ${t}.`})}finally{Du=!1}}}function Pu(){uu(`launcher-relaunch-here`,e=>void Nu(e))}async function Fu(e){if(await Mu(e)&&confirm(`Drop Claude's saved conversation and restart fresh. This cannot be undone.`)){Du=!0;try{await ju(e,Hc,{},{failPrefix:`Start fresh failed`,requestFailPrefix:`Start-fresh request failed`,successMessage:`Claude restarting with a fresh conversation.`})}finally{Du=!1}}}var Iu=!1;function Lu(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString()}async function Ru(e){if(Iu)return;let t=e.getActiveTabId();if(!t){e.notify(`warning`,`No active document.`);return}Iu=!0;try{let n=await fetch(`${Il}${Dc}?documentId=${encodeURIComponent(t)}`);if(!n.ok){let t=await n.json().catch(()=>({}));e.notify(`error`,`Couldn't list backups: ${t.message??n.statusText}`);return}let r=(await n.json().catch(()=>null))?.data?.backups??[];if(r.length===0){e.notify(`info`,`No backups exist for this document yet. Tandem snapshots the on-disk file before its first overwrite each session.`);return}let i=r[0],a=r.map((e,t)=>` ${t+1}. ${Lu(e.timestamp)}`).join(`
4
+ `);if(!confirm(`Available backups (newest first):\n${a}\n\nRestore the most recent backup (${Lu(i.timestamp)})? The document reloads with the backup's content; annotations are preserved.
5
+
6
+ Older backups can be restored by asking Claude (tandem_restoreBackup).`))return;let o=await fetch(`${Il}${Oc}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({documentId:t,backup:i.name})});if(!o.ok){let t=await o.json().catch(()=>({}));e.notify(`error`,`Restore failed: ${t.message??o.statusText}`);return}e.notify(`info`,`Restored backup from ${Lu(i.timestamp)}.`)}catch(t){e.notify(`error`,`Restore request failed: ${t instanceof Error?t.message:t}`)}finally{Iu=!1}}async function zu(e){let t=e.getActiveDocumentPath();if(!t){e.notify(`warning`,`This document isn't saved to a file yet.`);return}try{let{invoke:e}=await Ul(async()=>{let{invoke:e}=await import(`./core-SwWLTXZB.js`);return{invoke:e}},[]);await e(`show_in_file_manager`,{path:t})}catch(t){e.notify(`error`,`Couldn't reveal in file manager: ${t instanceof Error?t.message:String(t)}`)}}var Bu=[{id:`save`,label:`Save document`,group:`document`,shortcut:`Ctrl+S`,run(){uu(`save`,e=>void Eu(e.getActiveTabId()))}},{id:`settings`,label:`Open settings`,group:`view`,shortcut:`Ctrl+,`,run(){uu(`settings`,e=>e.openSettings())}},{id:`settings-modal`,label:`Open settings (new)`,group:`view`,shortcut:`Ctrl+Shift+,`,run(){uu(`settings-modal`,e=>e.openSettingsModal())}},{id:`toggle-mode`,label:`Toggle Solo / Tandem mode`,group:`document`,shortcut:`Ctrl+Shift+M`,run(){uu(`toggle-mode`,e=>e.toggleSoloMode())}},{id:`new-scratchpad`,label:`New Scratchpad`,group:`document`,shortcut:`Ctrl+N`,run(){_u()}},{id:`save-as`,label:`Save As…`,group:`document`,shortcut:`Ctrl+Shift+S`,run(){uu(`save-as`,e=>void e.saveAs())}},{id:`close-tab`,label:`Close active tab`,group:`document`,shortcut:`Ctrl+W`,run(){uu(`close-tab`,e=>e.closeActiveTab())}},{id:`open-file`,label:`Open file…`,group:`document`,shortcut:`Ctrl+O`,run(){uu(`open-file`,e=>e.openFileDialog())}},{id:`find`,label:`Find / Replace`,group:`navigation`,shortcut:`Ctrl+F`,run(){uu(`find`,e=>e.openFindBar())}},{id:`find-in-tabs`,label:`Find in open tabs`,group:`navigation`,shortcut:`Ctrl+Shift+F`,run(){uu(`find-in-tabs`,e=>e.openFindBarTabs())}},{id:`find-next`,label:`Find next match`,group:`navigation`,shortcut:`Ctrl+G`,run(){uu(`find-next`,e=>e.findNext())}},{id:`find-previous`,label:`Find previous match`,group:`navigation`,shortcut:`Ctrl+Shift+G`,run(){uu(`find-previous`,e=>e.findPrev())}},{id:`toggle-left-panel`,label:`Toggle left panel`,group:`view`,shortcut:`Alt+Shift+Left`,run(){uu(`toggle-left-panel`,e=>e.toggleLeftPanel())}},{id:`toggle-right-panel`,label:`Toggle right panel`,group:`view`,shortcut:`Alt+Shift+Right`,run(){uu(`toggle-right-panel`,e=>e.toggleRightPanel())}},{id:`reopen-closed-tab`,label:`Reopen closed tab (this session)`,group:`document`,shortcut:`Ctrl+Alt+T`,run(){uu(`reopen-closed-tab`,e=>e.reopenClosedTab())}},{id:`annotation-next`,label:`Next annotation`,group:`annotations`,shortcut:`Alt+]`,run(){uu(`annotation-next`,e=>e.annotationNext())}},{id:`annotation-previous`,label:`Previous annotation`,group:`annotations`,shortcut:`Alt+[`,run(){uu(`annotation-previous`,e=>e.annotationPrev())}},{id:`annotation-accept`,label:`Accept focused annotation`,group:`annotations`,shortcut:`Ctrl+Enter`,run(){uu(`annotation-accept`,e=>e.annotationAccept())}},{id:`annotation-dismiss`,label:`Dismiss focused annotation`,group:`annotations`,shortcut:`Ctrl+Shift+Enter`,run(){uu(`annotation-dismiss`,e=>e.annotationDismiss())}},{id:`select-block`,label:`Select containing block`,group:`editor`,shortcut:`Alt+L`,run(){uu(`select-block`,e=>e.selectBlock())}},{id:`toggle-authorship`,label:`Toggle authorship colors`,group:`view`,shortcut:`Ctrl+Alt+A`,run(){uu(`toggle-authorship`,e=>e.toggleAuthorship())}},{id:`toggle-formatting-bar`,label:`Toggle formatting bar`,group:`view`,run(){uu(`toggle-formatting-bar`,e=>e.toggleFormattingBar())}},{id:`toggle-source-view`,label:`Toggle markdown source view`,group:`view`,run(){uu(`toggle-source-view`,e=>e.toggleSourceView())}},{id:`restore-backup`,label:`Restore a backup of this document…`,group:`document`,run(){uu(`restore-backup`,e=>void Ru(e))}},{id:`launcher-relaunch-here`,label:`Relaunch Claude in this folder`,group:`claude`,run(){uu(`launcher-relaunch-here`,e=>void Nu(e))}},{id:`launcher-start-fresh`,label:`Start fresh Claude conversation`,group:`claude`,run(){uu(`launcher-start-fresh`,e=>void Fu(e))}},...vu()?[{id:`show-in-file-explorer`,label:`Show in file explorer`,group:`document`,run(){uu(`show-in-file-explorer`,e=>void zu(e))}}]:[]];for(let e of Bu)ou(e);function Vu(e,t=`y`){function n(){if(e.isConnected){if(t===`y`||t===`both`){let t=e.scrollTop>0,n=e.scrollTop+e.clientHeight<e.scrollHeight-1;r(`data-overflow-top`,t),r(`data-overflow-bottom`,n)}if(t===`x`||t===`both`){let t=e.scrollLeft>0,n=e.scrollLeft+e.clientWidth<e.scrollWidth-1;r(`data-overflow-left`,t),r(`data-overflow-right`,n)}}}function r(t,n){n?e.setAttribute(t,`true`):e.removeAttribute(t)}n(),e.addEventListener(`scroll`,n,{passive:!0});let i=null;try{i=new ResizeObserver(n),i.observe(e)}catch(e){console.warn(`[tandem:scrollFade] ResizeObserver init failed`,e)}return{destroy(){e.removeEventListener(`scroll`,n),i?.disconnect()}}}function Hu(e){return e.type===`save-error`&&e.documentId?{label:`Retry`,documentId:e.documentId}:null}var Uu={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 Wu(e,t=Date.now()){let n=Math.max(0,Math.floor((t-e)/1e3));if(n<5)return`now`;if(n<60)return`${n}s`;let r=Math.floor(n/60);if(r<60)return`${r}m`;let i=Math.floor(r/60);return i<24?`${i}h`:`${Math.floor(i/24)}d`}var Gu=H(`<button type="button" data-testid="activity-clear-all" class="svelte-bf7dij">Clear all</button>`),Ku=H(`<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>`),qu=qr(`<path class="svelte-bf7dij"></path>`),Ju=H(`<span class="badge svelte-bf7dij"> </span>`),Yu=H(`<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" class="svelte-bf7dij"><path d="M21 12a9 9 0 1 1-3-7" class="svelte-bf7dij"></path><path d="M21 4v5h-5" class="svelte-bf7dij"></path></svg> </button>`),Xu=H(`<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" class="svelte-bf7dij"></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" class="svelte-bf7dij"><path d="M6 6l12 12" class="svelte-bf7dij"></path><path d="M6 18L18 6" class="svelte-bf7dij"></path></svg></button></div>`),Zu=H(`<div></div>`),Qu=H(`<div class="tray-inner 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>`),$u=H(`<span class="svelte-bf7dij">No activity</span>`),ed=H(`<span class="svelte-bf7dij">Activity</span> <span class="count svelte-bf7dij"> </span>`,1),td=H(`<div class="activity-anchor svelte-bf7dij"><div><div class="tray-wrap svelte-bf7dij"><!></div> <button type="button" class="pill-row svelte-bf7dij" data-testid="activity-pill"><span class="led svelte-bf7dij"></span> <!> <span class="spacer 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" class="svelte-bf7dij"><path d="M6 9l6 6 6-6" class="svelte-bf7dij"></path></svg></span></button></div></div>`);function nd(e,t){A(t,!0);let n=M(()=>t.items.length),r=M(()=>t.items.some(e=>e.severity===`error`)?`has-error`:t.items.some(e=>e.severity===`warning`)?`has-warning`:t.items.some(e=>e.severity===`info`)?`has-info`:`idle`),i=N(ln(Date.now())),a=setInterval(()=>{P(i,Date.now(),!0)},3e4),o=N(!1),s=!1,c;R(()=>{t.open&&!s?(P(o,!0),c&&clearTimeout(c),c=setTimeout(()=>{P(o,!1)},1800)):!t.open&&s&&(P(o,!1),c&&=(clearTimeout(c),void 0)),s=t.open}),_a(()=>{clearInterval(a),c&&clearTimeout(c)});var l=td(),u=F(l);let d;var f=F(u),p=F(f),m=e=>{var r=Qu(),a=F(r),s=L(F(a),2),c=F(s,!0);O(s);var l=L(s,4),u=e=>{var n=Gu();V(`click`,n,function(...e){t.onClear?.apply(this,e)}),U(e,n)};G(l,e=>{B(n)>0&&e(u)}),O(a);var d=L(a,2),f=e=>{U(e,Ku())},p=e=>{var n=Zu();let r;fi(n,21,()=>t.items,e=>e.id,(e,n)=>{let r=M(()=>Hu(B(n)));var a=Xu(),o=F(a),s=F(o);fi(s,20,()=>Uu[B(n).severity],e=>e,(e,t)=>{var n=qu();z(()=>q(n,`d`,t)),U(e,n)}),O(s),O(o);var c=L(o,2),l=F(c),u=F(l),d=F(u,!0);O(u);var f=L(u,2),p=e=>{var t=Ju(),r=F(t);O(t),z(()=>W(r,`×${B(n).count??``}`)),U(e,t)};G(f,e=>{B(n).count>1&&e(p)});var m=L(f,2),h=F(m,!0);O(m),O(l);var g=L(l,2),_=e=>{var i=Yu(),a=L(F(i));O(i),z(()=>{q(i,`data-testid`,`activity-action-${B(n).id}`),W(a,` ${B(r).label??``}`)}),V(`click`,i,()=>t.onAction(B(n))),U(e,i)};G(g,e=>{B(r)&&e(_)}),O(c);var v=L(c,2);O(a),z(e=>{Hi(a,1,`toast-row ${B(n).severity??``}`,`svelte-bf7dij`),q(a,`data-testid`,`activity-row-${B(n).id}`),W(d,B(n).message),W(h,e),q(v,`data-testid`,`activity-dismiss-${B(n).id}`)},[()=>Wu(B(n).timestamp,B(i))]),V(`click`,v,()=>t.onDismiss(B(n).id)),U(e,a)}),O(n),z(()=>r=Hi(n,1,`tray-list svelte-bf7dij`,null,r,{cascade:B(o)})),U(e,n)};G(d,e=>{B(n)===0?e(f):e(p,-1)}),O(r),z(()=>W(c,B(n)===0?`No events`:`${B(n)} event${B(n)===1?``:`s`}`)),U(e,r)};G(p,e=>{t.open&&e(m)}),O(f);var h=L(f,2),g=L(F(h),2),_=e=>{U(e,$u())},v=e=>{var t=ed(),r=L(I(t),2),i=F(r,!0);O(r),z(()=>W(i,B(n))),U(e,t)};G(g,e=>{B(n)===0?e(_):e(v,-1)}),k(4),O(h),O(u),O(l),z(()=>{d=Hi(u,1,`activity-shell ${B(r)??``}`,`svelte-bf7dij`,d,{open:t.open}),q(h,`aria-expanded`,t.open),q(h,`aria-controls`,t.open?`activity-tray`:void 0)}),V(`click`,h,function(...e){t.onToggle?.apply(this,e)}),U(e,l),j()}zr([`click`]);function rd(e){this.content=e}rd.prototype={constructor:rd,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return-1},get:function(e){var t=this.find(e);return t==-1?void 0:this.content[t+1]},update:function(e,t,n){var r=n&&n!=e?this.remove(n):this,i=r.find(e),a=r.content.slice();return i==-1?a.push(n||e,t):(a[i+1]=t,n&&(a[i]=n)),new rd(a)},remove:function(e){var t=this.find(e);if(t==-1)return this;var n=this.content.slice();return n.splice(t,2),new rd(n)},addToStart:function(e,t){return new rd([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new rd(n)},addBefore:function(e,t,n){var r=this.remove(t),i=r.content.slice(),a=r.find(e);return i.splice(a==-1?i.length:a,0,t,n),new rd(i)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){return e=rd.from(e),e.size?new rd(e.content.concat(this.subtract(e).content)):this},append:function(e){return e=rd.from(e),e.size?new rd(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=rd.from(e);for(var n=0;n<e.content.length;n+=2)t=t.remove(e.content[n]);return t},toObject:function(){var e={};return this.forEach(function(t,n){e[t]=n}),e},get size(){return this.content.length>>1}},rd.from=function(e){if(e instanceof rd)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new rd(t)};function id(e,t,n){for(let r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:n;let i=e.child(r),a=t.child(r);if(i==a){n+=i.nodeSize;continue}if(!i.sameMarkup(a))return n;if(i.isText&&i.text!=a.text){for(let e=0;i.text[e]==a.text[e];e++)n++;return n}if(i.content.size||a.content.size){let e=id(i.content,a.content,n+1);if(e!=null)return e}n+=i.nodeSize}}function ad(e,t,n,r){for(let i=e.childCount,a=t.childCount;;){if(i==0||a==0)return i==a?null:{a:n,b:r};let o=e.child(--i),s=t.child(--a),c=o.nodeSize;if(o==s){n-=c,r-=c;continue}if(!o.sameMarkup(s))return{a:n,b:r};if(o.isText&&o.text!=s.text){let e=0,t=Math.min(o.text.length,s.text.length);for(;e<t&&o.text[o.text.length-e-1]==s.text[s.text.length-e-1];)e++,n--,r--;return{a:n,b:r}}if(o.content.size||s.content.size){let e=ad(o.content,s.content,n-1,r-1);if(e)return e}n-=c,r-=c}}var Z=class e{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let t=0;t<e.length;t++)this.size+=e[t].nodeSize}nodesBetween(e,t,n,r=0,i){for(let a=0,o=0;o<t;a++){let s=this.content[a],c=o+s.nodeSize;if(c>e&&n(s,r+o,i||null,a)!==!1&&s.content.size){let i=o+1;s.nodesBetween(Math.max(0,e-i),Math.min(s.content.size,t-i),n,r+i)}o=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,r){let i=``,a=!0;return this.nodesBetween(e,t,(o,s)=>{let c=o.isText?o.text.slice(Math.max(e,s)-s,t-s):o.isLeaf?r?typeof r==`function`?r(o):r:o.type.spec.leafText?o.type.spec.leafText(o):``:``;o.isBlock&&(o.isLeaf&&c||o.isTextblock)&&n&&(a?a=!1:i+=n),i+=c},0),i}append(t){if(!t.size)return this;if(!this.size)return t;let n=this.lastChild,r=t.firstChild,i=this.content.slice(),a=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),a=1);a<t.content.length;a++)i.push(t.content[a]);return new e(i,this.size+t.size)}cut(t,n=this.size){if(t==0&&n==this.size)return this;let r=[],i=0;if(n>t)for(let e=0,a=0;a<n;e++){let o=this.content[e],s=a+o.nodeSize;s>t&&((a<t||s>n)&&(o=o.isText?o.cut(Math.max(0,t-a),Math.min(o.text.length,n-a)):o.cut(Math.max(0,t-a-1),Math.min(o.content.size,n-a-1))),r.push(o),i+=o.nodeSize),a=s}return new e(r,i)}cutByIndex(t,n){return t==n?e.empty:t==0&&n==this.content.length?this:new e(this.content.slice(t,n))}replaceChild(t,n){let r=this.content[t];if(r==n)return this;let i=this.content.slice(),a=this.size+n.nodeSize-r.nodeSize;return i[t]=n,new e(i,a)}addToStart(t){return new e([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new e(this.content.concat(t),this.size+t.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw RangeError(`Index `+e+` out of range for `+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,n=0;t<this.content.length;t++){let r=this.content[t];e(r,n,t),n+=r.nodeSize}}findDiffStart(e,t=0){return id(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return ad(this,e,t,n)}findIndex(e){if(e==0)return sd(0,e);if(e==this.size)return sd(this.content.length,e);if(e>this.size||e<0)throw RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,n=0;;t++){let r=this.child(t),i=n+r.nodeSize;if(i>=e)return i==e?sd(t+1,i):sd(t,n);n=i}}toString(){return`<`+this.toStringInner()+`>`}toStringInner(){return this.content.join(`, `)}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(t,n){if(!n)return e.empty;if(!Array.isArray(n))throw RangeError(`Invalid input for Fragment.fromJSON`);return new e(n.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return e.empty;let n,r=0;for(let e=0;e<t.length;e++){let i=t[e];r+=i.nodeSize,e&&i.isText&&t[e-1].sameMarkup(i)?(n||=t.slice(0,e),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new e(n||t,r)}static from(t){if(!t)return e.empty;if(t instanceof e)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new e([t],t.nodeSize);throw RangeError(`Can not convert `+t+` to a Fragment`+(t.nodesBetween?` (looks like multiple versions of prosemirror-model were loaded)`:``))}};Z.empty=new Z([],0);var od={index:0,offset:0};function sd(e,t){return od.index=e,od.offset=t,od}function cd(e,t){if(e===t)return!0;if(!(e&&typeof e==`object`)||!(t&&typeof t==`object`))return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!cd(e[n],t[n]))return!1}else{for(let n in e)if(!(n in t)||!cd(e[n],t[n]))return!1;for(let n in t)if(!(n in e))return!1}return!0}var ld=class e{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(this.eq(i))return e;if(this.type.excludes(i.type))t||=e.slice(0,r);else if(i.type.excludes(this.type))return e;else !n&&i.type.rank>this.type.rank&&(t||=e.slice(0,r),t.push(this),n=!0),t&&t.push(i)}return t||=e.slice(),n||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&cd(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Mark.fromJSON`);let n=e.marks[t.type];if(!n)throw RangeError(`There is no mark type ${t.type} in this schema`);let r=n.create(t.attrs);return n.checkAttrs(r.attrs),r}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}static setFrom(t){if(!t||Array.isArray(t)&&t.length==0)return e.none;if(t instanceof e)return[t];let n=t.slice();return n.sort((e,t)=>e.type.rank-t.type.rank),n}};ld.none=[];var ud=class extends Error{},Q=class e{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,n){let r=fd(this.content,t+this.openStart,n);return r&&new e(r,this.openStart,this.openEnd)}removeBetween(t,n){return new e(dd(this.content,t+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(t,n){if(!n)return e.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!=`number`||typeof i!=`number`)throw RangeError(`Invalid input for Slice.fromJSON`);return new e(Z.fromJSON(t,n.content),r,i)}static maxOpen(t,n=!0){let r=0,i=0;for(let e=t.firstChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.firstChild)r++;for(let e=t.lastChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.lastChild)i++;return new e(t,r,i)}};Q.empty=new Q(Z.empty,0,0);function dd(e,t,n){let{index:r,offset:i}=e.findIndex(t),a=e.maybeChild(r),{index:o,offset:s}=e.findIndex(n);if(i==t||a.isText){if(s!=n&&!e.child(o).isText)throw RangeError(`Removing non-flat range`);return e.cut(0,t).append(e.cut(n))}if(r!=o)throw RangeError(`Removing non-flat range`);return e.replaceChild(r,a.copy(dd(a.content,t-i-1,n-i-1)))}function fd(e,t,n,r){let{index:i,offset:a}=e.findIndex(t),o=e.maybeChild(i);if(a==t||o.isText)return r&&!r.canReplace(i,i,n)?null:e.cut(0,t).append(n).append(e.cut(t));let s=fd(o.content,t-a-1,n,o);return s&&e.replaceChild(i,o.copy(s))}function pd(e,t,n){if(n.openStart>e.depth)throw new ud(`Inserted content deeper than insertion position`);if(e.depth-n.openStart!=t.depth-n.openEnd)throw new ud(`Inconsistent open depths`);return md(e,t,n,0)}function md(e,t,n,r){let i=e.index(r),a=e.node(r);if(i==t.index(r)&&r<e.depth-n.openStart){let o=md(e,t,n,r+1);return a.copy(a.content.replaceChild(i,o))}else if(!n.content.size)return yd(a,xd(e,t,r));else if(!n.openStart&&!n.openEnd&&e.depth==r&&t.depth==r){let r=e.parent,i=r.content;return yd(r,i.cut(0,e.parentOffset).append(n.content).append(i.cut(t.parentOffset)))}else{let{start:i,end:o}=Sd(n,e);return yd(a,bd(e,i,o,t,r))}}function hd(e,t){if(!t.type.compatibleContent(e.type))throw new ud(`Cannot join `+t.type.name+` onto `+e.type.name)}function gd(e,t,n){let r=e.node(n);return hd(r,t.node(n)),r}function _d(e,t){let n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function vd(e,t,n,r){let i=(t||e).node(n),a=0,o=t?t.index(n):i.childCount;e&&(a=e.index(n),e.depth>n?a++:e.textOffset&&(_d(e.nodeAfter,r),a++));for(let e=a;e<o;e++)_d(i.child(e),r);t&&t.depth==n&&t.textOffset&&_d(t.nodeBefore,r)}function yd(e,t){return e.type.checkContent(t),e.copy(t)}function bd(e,t,n,r,i){let a=e.depth>i&&gd(e,t,i+1),o=r.depth>i&&gd(n,r,i+1),s=[];return vd(null,e,i,s),a&&o&&t.index(i)==n.index(i)?(hd(a,o),_d(yd(a,bd(e,t,n,r,i+1)),s)):(a&&_d(yd(a,xd(e,t,i+1)),s),vd(t,n,i,s),o&&_d(yd(o,xd(n,r,i+1)),s)),vd(r,null,i,s),new Z(s)}function xd(e,t,n){let r=[];return vd(null,e,n,r),e.depth>n&&_d(yd(gd(e,t,n+1),xd(e,t,n+1)),r),vd(t,null,n,r),new Z(r)}function Sd(e,t){let n=t.depth-e.openStart,r=t.node(n).copy(e.content);for(let e=n-1;e>=0;e--)r=t.node(e).copy(Z.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}var Cd=class e{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw 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 RangeError(`There is no position after the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],r=e.child(t);return n?e.child(t).cut(n):r}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[t*3],r=t==0?0:this.path[t*3-1]+1;for(let t=0;t<e;t++)r+=n.child(t).nodeSize;return r}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return ld.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),r=e.maybeChild(t);if(!n){let e=n;n=r,r=e}let i=n.marks;for(var a=0;a<i.length;a++)i[a].type.spec.inclusive===!1&&(!r||!i[a].isInSet(r.marks))&&(i=i[a--].removeFromSet(i));return i}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,r=e.parent.maybeChild(e.index());for(var i=0;i<n.length;i++)n[i].type.spec.inclusive===!1&&(!r||!n[i].isInSet(r.marks))&&(n=n[i--].removeFromSet(n));return n}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new Dd(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e=``;for(let t=1;t<=this.depth;t++)e+=(e?`/`:``)+this.node(t).type.name+`_`+this.index(t-1);return e+`:`+this.parentOffset}static resolve(t,n){if(!(n>=0&&n<=t.content.size))throw RangeError(`Position `+n+` out of range`);let r=[],i=0,a=n;for(let e=t;;){let{index:t,offset:n}=e.content.findIndex(a),o=a-n;if(r.push(e,t,i+n),!o||(e=e.child(t),e.isText))break;a=o-1,i+=n+1}return new e(n,r,a)}static resolveCached(t,n){let r=Ed.get(t);if(r)for(let e=0;e<r.elts.length;e++){let t=r.elts[e];if(t.pos==n)return t}else Ed.set(t,r=new wd);let i=r.elts[r.i]=e.resolve(t,n);return r.i=(r.i+1)%Td,i}},wd=class{constructor(){this.elts=[],this.i=0}},Td=12,Ed=new WeakMap,Dd=class{constructor(e,t,n){this.$from=e,this.$to=t,this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}},Od=Object.create(null),kd=class e{constructor(e,t,n,r=ld.none){this.type=e,this.attrs=t,this.marks=r,this.content=n||Z.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,n,r=0){this.content.nodesBetween(e,t,n,r,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,``)}textBetween(e,t,n,r){return this.content.textBetween(e,t,n,r)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,n){return this.type==e&&cd(this.attrs,t||e.defaultAttrs||Od)&&ld.sameSet(this.marks,n||ld.none)}copy(t=null){return t==this.content?this:new e(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.content,t)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,n=!1){if(e==t)return Q.empty;let r=this.resolve(e),i=this.resolve(t),a=n?0:r.sharedDepth(t),o=r.start(a);return new Q(r.node(a).content.cut(r.pos-o,i.pos-o),r.depth-a,i.depth-a)}replace(e,t,n){return pd(this.resolve(e),this.resolve(t),n)}nodeAt(e){for(let t=this;;){let{index:n,offset:r}=t.content.findIndex(e);if(t=t.maybeChild(n),!t)return null;if(r==e||t.isText)return t;e-=r+1}}childAfter(e){let{index:t,offset:n}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:n}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:n}=this.content.findIndex(e);if(n<e)return{node:this.content.child(t),index:t,offset:n};let r=this.content.child(t-1);return{node:r,index:t-1,offset:n-r.nodeSize}}resolve(e){return Cd.resolveCached(this,e)}resolveNoCache(e){return Cd.resolve(this,e)}rangeHasMark(e,t,n){let r=!1;return t>e&&this.nodesBetween(e,t,e=>(n.isInSet(e.marks)&&(r=!0),!r)),r}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+=`(`+this.content.toStringInner()+`)`),jd(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw Error(`Called contentMatchAt on a node with invalid content`);return t}canReplace(e,t,n=Z.empty,r=0,i=n.childCount){let a=this.contentMatchAt(e).matchFragment(n,r,i),o=a&&a.matchFragment(this.content,t);if(!o||!o.validEnd)return!1;for(let e=r;e<i;e++)if(!this.type.allowsMarks(n.child(e).marks))return!1;return!0}canReplaceWith(e,t,n,r){if(r&&!this.type.allowsMarks(r))return!1;let i=this.contentMatchAt(e).matchType(n),a=i&&i.matchFragment(this.content,t);return a?a.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=ld.none;for(let t=0;t<this.marks.length;t++){let n=this.marks[t];n.type.checkAttrs(n.attrs),e=n.addToSet(e)}if(!ld.sameSet(e,this.marks))throw RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(e=>e.type.name)}`);this.content.forEach(e=>e.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(e=>e.toJSON())),e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Node.fromJSON`);let n;if(t.marks){if(!Array.isArray(t.marks))throw RangeError(`Invalid mark data for Node.fromJSON`);n=t.marks.map(e.markFromJSON)}if(t.type==`text`){if(typeof t.text!=`string`)throw RangeError(`Invalid text node in JSON`);return e.text(t.text,n)}let r=Z.fromJSON(e,t.content),i=e.nodeType(t.type).create(t.attrs,r,n);return i.type.checkAttrs(i.attrs),i}};kd.prototype.text=void 0;var Ad=class e extends kd{constructor(e,t,n,r){if(super(e,t,null,r),!n)throw RangeError(`Empty text nodes are not allowed`);this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):jd(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new e(this.type,this.attrs,t,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}};function jd(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+`(`+t+`)`;return t}var Md=class e{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(t,n){let r=new Nd(t,n);if(r.next==null)return e.empty;let i=Pd(r);r.next&&r.err(`Unexpected trailing text`);let a=Wd(Vd(i));return Gd(a,r),a}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,n=e.childCount){let r=this;for(let i=t;r&&i<n;i++)r=r.matchType(e.child(i).type);return r}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}fillBefore(e,t=!1,n=0){let r=[this];function i(a,o){let s=a.matchFragment(e,n);if(s&&(!t||s.validEnd))return Z.from(o.map(e=>e.createAndFill()));for(let e=0;e<a.next.length;e++){let{type:t,next:n}=a.next[e];if(!(t.isText||t.hasRequiredAttrs())&&r.indexOf(n)==-1){r.push(n);let e=i(n,o.concat(t));if(e)return e}}return null}return i(this,[])}findWrapping(e){for(let t=0;t<this.wrapCache.length;t+=2)if(this.wrapCache[t]==e)return this.wrapCache[t+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let r=n.shift(),i=r.match;if(i.matchType(e)){let e=[];for(let t=r;t.type;t=t.via)e.push(t.type);return e.reverse()}for(let e=0;e<i.next.length;e++){let{type:a,next:o}=i.next[e];!a.isLeaf&&!a.hasRequiredAttrs()&&!(a.name in t)&&(!r.type||o.validEnd)&&(n.push({match:a.contentMatch,type:a,via:r}),t[a.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(n){e.push(n);for(let r=0;r<n.next.length;r++)e.indexOf(n.next[r].next)==-1&&t(n.next[r].next)}return t(this),e.map((t,n)=>{let r=n+(t.validEnd?`*`:` `)+` `;for(let n=0;n<t.next.length;n++)r+=(n?`, `:``)+t.next[n].type.name+`->`+e.indexOf(t.next[n].next);return r}).join(`
7
+ `)}};Md.empty=new Md(!0);var Nd=class{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==``&&this.tokens.pop(),this.tokens[0]==``&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw SyntaxError(e+` (in content expression '`+this.string+`')`)}};function Pd(e){let t=[];do t.push(Fd(e));while(e.eat(`|`));return t.length==1?t[0]:{type:`choice`,exprs:t}}function Fd(e){let t=[];do t.push(Id(e));while(e.next&&e.next!=`)`&&e.next!=`|`);return t.length==1?t[0]:{type:`seq`,exprs:t}}function Id(e){let t=Bd(e);for(;;)if(e.eat(`+`))t={type:`plus`,expr:t};else if(e.eat(`*`))t={type:`star`,expr:t};else if(e.eat(`?`))t={type:`opt`,expr:t};else if(e.eat(`{`))t=Rd(e,t);else break;return t}function Ld(e){/\D/.test(e.next)&&e.err(`Expected number, got '`+e.next+`'`);let t=Number(e.next);return e.pos++,t}function Rd(e,t){let n=Ld(e),r=n;return e.eat(`,`)&&(r=e.next==`}`?-1:Ld(e)),e.eat(`}`)||e.err(`Unclosed braced range`),{type:`range`,min:n,max:r,expr:t}}function zd(e,t){let n=e.nodeTypes,r=n[t];if(r)return[r];let i=[];for(let e in n){let r=n[e];r.isInGroup(t)&&i.push(r)}return i.length==0&&e.err(`No node type or group '`+t+`' found`),i}function Bd(e){if(e.eat(`(`)){let t=Pd(e);return e.eat(`)`)||e.err(`Missing closing paren`),t}else if(/\W/.test(e.next))e.err(`Unexpected token '`+e.next+`'`);else{let t=zd(e,e.next).map(t=>(e.inline==null?e.inline=t.isInline:e.inline!=t.isInline&&e.err(`Mixing inline and block content`),{type:`name`,value:t}));return e.pos++,t.length==1?t[0]:{type:`choice`,exprs:t}}}function Vd(e){let t=[[]];return i(a(e,0),n()),t;function n(){return t.push([])-1}function r(e,n,r){let i={term:r,to:n};return t[e].push(i),i}function i(e,t){e.forEach(e=>e.to=t)}function a(e,t){if(e.type==`choice`)return e.exprs.reduce((e,n)=>e.concat(a(n,t)),[]);if(e.type==`seq`)for(let r=0;;r++){let o=a(e.exprs[r],t);if(r==e.exprs.length-1)return o;i(o,t=n())}else if(e.type==`star`){let o=n();return r(t,o),i(a(e.expr,o),o),[r(o)]}else if(e.type==`plus`){let o=n();return i(a(e.expr,t),o),i(a(e.expr,o),o),[r(o)]}else if(e.type==`opt`)return[r(t)].concat(a(e.expr,t));else if(e.type==`range`){let o=t;for(let t=0;t<e.min;t++){let t=n();i(a(e.expr,o),t),o=t}if(e.max==-1)i(a(e.expr,o),o);else for(let t=e.min;t<e.max;t++){let t=n();r(o,t),i(a(e.expr,o),t),o=t}return[r(o)]}else if(e.type==`name`)return[r(t,void 0,e.value)];else throw Error(`Unknown expr type`)}}function Hd(e,t){return t-e}function Ud(e,t){let n=[];return r(t),n.sort(Hd);function r(t){let i=e[t];if(i.length==1&&!i[0].term)return r(i[0].to);n.push(t);for(let e=0;e<i.length;e++){let{term:t,to:a}=i[e];!t&&n.indexOf(a)==-1&&r(a)}}}function Wd(e){let t=Object.create(null);return n(Ud(e,0));function n(r){let i=[];r.forEach(t=>{e[t].forEach(({term:t,to:n})=>{if(!t)return;let r;for(let e=0;e<i.length;e++)i[e][0]==t&&(r=i[e][1]);Ud(e,n).forEach(e=>{r||i.push([t,r=[]]),r.indexOf(e)==-1&&r.push(e)})})});let a=t[r.join(`,`)]=new Md(r.indexOf(e.length-1)>-1);for(let e=0;e<i.length;e++){let r=i[e][1].sort(Hd);a.next.push({type:i[e][0],next:t[r.join(`,`)]||n(r)})}return a}}function Gd(e,t){for(let n=0,r=[e];n<r.length;n++){let e=r[n],i=!e.validEnd,a=[];for(let t=0;t<e.next.length;t++){let{type:n,next:o}=e.next[t];a.push(n.name),i&&!(n.isText||n.hasRequiredAttrs())&&(i=!1),r.indexOf(o)==-1&&r.push(o)}i&&t.err(`Only non-generatable nodes (`+a.join(`, `)+`) in a required position (see https://prosemirror.net/docs/guide/#generatable)`)}}function Kd(e){let t=Object.create(null);for(let n in e){let r=e[n];if(!r.hasDefault)return null;t[n]=r.default}return t}function qd(e,t){let n=Object.create(null);for(let r in e){let i=t&&t[r];if(i===void 0){let t=e[r];if(t.hasDefault)i=t.default;else throw RangeError(`No value supplied for attribute `+r)}n[r]=i}return n}function Jd(e,t,n,r){for(let r in t)if(!(r in e))throw RangeError(`Unsupported attribute ${r} for ${n} of type ${r}`);for(let n in e){let r=e[n];r.validate&&r.validate(t[n])}}function Yd(e,t){let n=Object.create(null);if(t)for(let r in t)n[r]=new Qd(e,r,t[r]);return n}var Xd=class e{constructor(e,t,n){this.name=e,this.schema=t,this.spec=n,this.markSet=null,this.groups=n.group?n.group.split(` `):[],this.attrs=Yd(e,n.attrs),this.defaultAttrs=Kd(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(n.inline||e==`text`),this.isText=e==`text`}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==Md.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:qd(this.attrs,e)}create(e=null,t,n){if(this.isText)throw Error(`NodeType.create can't construct text nodes`);return new kd(this,this.computeAttrs(e),Z.from(t),ld.setFrom(n))}createChecked(e=null,t,n){return t=Z.from(t),this.checkContent(t),new kd(this,this.computeAttrs(e),t,ld.setFrom(n))}createAndFill(e=null,t,n){if(e=this.computeAttrs(e),t=Z.from(t),t.size){let e=this.contentMatch.fillBefore(t);if(!e)return null;t=e.append(t)}let r=this.contentMatch.matchFragment(t),i=r&&r.fillBefore(Z.empty,!0);return i?new kd(this,e,t.append(i),ld.setFrom(n)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let t=0;t<e.childCount;t++)if(!this.allowsMarks(e.child(t).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){Jd(this.attrs,e,`node`,this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let n=0;n<e.length;n++)this.allowsMarkType(e[n].type)?t&&t.push(e[n]):t||=e.slice(0,n);return t?t.length?t:ld.none:e}static compile(t,n){let r=Object.create(null);t.forEach((t,i)=>r[t]=new e(t,n,i));let i=n.spec.topNode||`doc`;if(!r[i])throw RangeError(`Schema is missing its top node type ('`+i+`')`);if(!r.text)throw RangeError(`Every schema needs a 'text' type`);for(let e in r.text.attrs)throw RangeError(`The text node type should not have attributes`);return r}};function Zd(e,t,n){let r=n.split(`|`);return n=>{let i=n===null?`null`:typeof n;if(r.indexOf(i)<0)throw RangeError(`Expected value of type ${r} for attribute ${t} on type ${e}, got ${i}`)}}var Qd=class{constructor(e,t,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,`default`),this.default=n.default,this.validate=typeof n.validate==`string`?Zd(e,t,n.validate):n.validate}get isRequired(){return!this.hasDefault}},$d=class e{constructor(e,t,n,r){this.name=e,this.rank=t,this.schema=n,this.spec=r,this.attrs=Yd(e,r.attrs),this.excluded=null;let i=Kd(this.attrs);this.instance=i?new ld(this,i):null}create(e=null){return!e&&this.instance?this.instance:new ld(this,qd(this.attrs,e))}static compile(t,n){let r=Object.create(null),i=0;return t.forEach((t,a)=>r[t]=new e(t,i++,n,a)),r}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){Jd(this.attrs,e,`mark`,this.name)}excludes(e){return this.excluded.indexOf(e)>-1}},ef=class{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let n in e)t[n]=e[n];t.nodes=rd.from(e.nodes),t.marks=rd.from(e.marks||{}),this.nodes=Xd.compile(this.spec.nodes,this),this.marks=$d.compile(this.spec.marks,this);let n=Object.create(null);for(let e in this.nodes){if(e in this.marks)throw RangeError(e+` can not be both a node and a mark`);let t=this.nodes[e],r=t.spec.content||``,i=t.spec.marks;if(t.contentMatch=n[r]||(n[r]=Md.parse(r,this.nodes)),t.inlineContent=t.contentMatch.inlineContent,t.spec.linebreakReplacement){if(this.linebreakReplacement)throw RangeError(`Multiple linebreak nodes defined`);if(!t.isInline||!t.isLeaf)throw RangeError(`Linebreak replacement nodes must be inline leaf nodes`);this.linebreakReplacement=t}t.markSet=i==`_`?null:i?tf(this,i.split(` `)):i==``||!t.inlineContent?[]:null}for(let e in this.marks){let t=this.marks[e],n=t.spec.excludes;t.excluded=n==null?[t]:n==``?[]:tf(this,n.split(` `))}this.nodeFromJSON=e=>kd.fromJSON(this,e),this.markFromJSON=e=>ld.fromJSON(this,e),this.topNodeType=this.nodes[this.spec.topNode||`doc`],this.cached.wrappings=Object.create(null)}node(e,t=null,n,r){if(typeof e==`string`)e=this.nodeType(e);else if(!(e instanceof Xd))throw RangeError(`Invalid node type: `+e);else if(e.schema!=this)throw RangeError(`Node type from different schema used (`+e.name+`)`);return e.createChecked(t,n,r)}text(e,t){let n=this.nodes.text;return new Ad(n,n.defaultAttrs,e,ld.setFrom(t))}mark(e,t){return typeof e==`string`&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw RangeError(`Unknown node type: `+e);return t}};function tf(e,t){let n=[];for(let r=0;r<t.length;r++){let i=t[r],a=e.marks[i],o=a;if(a)n.push(a);else for(let t in e.marks){let r=e.marks[t];(i==`_`||r.spec.group&&r.spec.group.split(` `).indexOf(i)>-1)&&n.push(o=r)}if(!o)throw SyntaxError(`Unknown mark type: '`+t[r]+`'`)}return n}function nf(e){return e.tag!=null}function rf(e){return e.style!=null}var af=class e{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let n=this.matchedStyles=[];t.forEach(e=>{if(nf(e))this.tags.push(e);else if(rf(e)){let t=/[^=]*/.exec(e.style)[0];n.indexOf(t)<0&&n.push(t),this.styles.push(e)}}),this.normalizeLists=!this.tags.some(t=>{if(!/^(ul|ol)\b/.test(t.tag)||!t.node)return!1;let n=e.nodes[t.node];return n.contentMatch.matchType(n)})}parse(e,t={}){let n=new mf(this,t,!1);return n.addAll(e,ld.none,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new mf(this,t,!0);return n.addAll(e,ld.none,t.from,t.to),Q.maxOpen(n.finish())}matchTag(e,t,n){for(let r=n?this.tags.indexOf(n)+1:0;r<this.tags.length;r++){let n=this.tags[r];if(gf(e,n.tag)&&(n.namespace===void 0||e.namespaceURI==n.namespace)&&(!n.context||t.matchesContext(n.context))){if(n.getAttrs){let t=n.getAttrs(e);if(t===!1)continue;n.attrs=t||void 0}return n}}}matchStyle(e,t,n,r){for(let i=r?this.styles.indexOf(r)+1:0;i<this.styles.length;i++){let r=this.styles[i],a=r.style;if(!(a.indexOf(e)!=0||r.context&&!n.matchesContext(r.context)||a.length>e.length&&(a.charCodeAt(e.length)!=61||a.slice(e.length+1)!=t))){if(r.getAttrs){let e=r.getAttrs(t);if(e===!1)continue;r.attrs=e||void 0}return r}}}static schemaRules(e){let t=[];function n(e){let n=e.priority==null?50:e.priority,r=0;for(;r<t.length;r++){let e=t[r];if((e.priority==null?50:e.priority)<n)break}t.splice(r,0,e)}for(let t in e.marks){let r=e.marks[t].spec.parseDOM;r&&r.forEach(e=>{n(e=_f(e)),e.mark||e.ignore||e.clearMark||(e.mark=t)})}for(let t in e.nodes){let r=e.nodes[t].spec.parseDOM;r&&r.forEach(e=>{n(e=_f(e)),e.node||e.ignore||e.mark||(e.node=t)})}return t}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new e(t,e.schemaRules(t)))}},of={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},sf={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},cf={ol:!0,ul:!0},lf=1,uf=2,df=4;function ff(e,t,n){return t==null?e&&e.whitespace==`pre`?3:n&-5:(t?lf:0)|(t===`full`?uf:0)}var pf=class{constructor(e,t,n,r,i,a){this.type=e,this.attrs=t,this.marks=n,this.solid=r,this.options=a,this.content=[],this.activeMarks=ld.none,this.match=i||(a&df?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(Z.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let t=this.type.contentMatch,n;return(n=t.findWrapping(e.type))?(this.match=t,n):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&lf)){let e=this.content[this.content.length-1],t;if(e&&e.isText&&(t=/[ \t\r\n\u000c]+$/.exec(e.text))){let n=e;e.text.length==t[0].length?this.content.pop():this.content[this.content.length-1]=n.withText(n.text.slice(0,n.text.length-t[0].length))}}let t=Z.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(Z.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!of.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}},mf=class{constructor(e,t,n){this.parser=e,this.options=t,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let r=t.topNode,i,a=ff(null,t.preserveWhitespace,0)|(n?df:0);i=r?new pf(r.type,r.attrs,ld.none,!0,t.topMatch||r.type.contentMatch,a):n?new pf(null,null,ld.none,!0,null,a):new pf(e.schema.topNodeType,null,ld.none,!0,null,a),this.nodes=[i],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let n=e.nodeValue,r=this.top,i=r.options&uf?`full`:this.localPreserveWS||(r.options&lf)>0,{schema:a}=this.parser;if(i===`full`||r.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(!i){if(n=n.replace(/[ \t\r\n\u000c]+/g,` `),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let t=r.content[r.content.length-1],i=e.previousSibling;(!t||i&&i.nodeName==`BR`||t.isText&&/[ \t\r\n\u000c]$/.test(t.text))&&(n=n.slice(1))}}else if(i===`full`)n=n.replace(/\r\n?/g,`
8
+ `);else if(a.linebreakReplacement&&/[\r\n]/.test(n)&&this.top.findWrapping(a.linebreakReplacement.create())){let e=n.split(/\r?\n|\r/);for(let n=0;n<e.length;n++)n&&this.insertNode(a.linebreakReplacement.create(),t,!0),e[n]&&this.insertNode(a.text(e[n]),t,!/\S/.test(e[n]));n=``}else n=n.replace(/\r?\n|\r/g,` `);n&&this.insertNode(a.text(n),t,!/\S/.test(n)),this.findInText(e)}else this.findInside(e)}addElement(e,t,n){let r=this.localPreserveWS,i=this.top;(e.tagName==`PRE`||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let a=e.nodeName.toLowerCase(),o;cf.hasOwnProperty(a)&&this.parser.normalizeLists&&hf(e);let s=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(o=this.parser.matchTag(e,this,n));out:if(s?s.ignore:sf.hasOwnProperty(a))this.findInside(e),this.ignoreFallback(e,t);else if(!s||s.skip||s.closeParent){s&&s.closeParent?this.open=Math.max(0,this.open-1):s&&s.skip.nodeType&&(e=s.skip);let n,r=this.needsBlock;if(of.hasOwnProperty(a))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),n=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break out}let o=s&&s.skip?t:this.readStyles(e,t);o&&this.addAll(e,o),n&&this.sync(i),this.needsBlock=r}else{let n=this.readStyles(e,t);n&&this.addElementByRule(e,s,n,s.consuming===!1?o:void 0)}this.localPreserveWS=r}leafFallback(e,t){e.nodeName==`BR`&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
9
+ `),t)}ignoreFallback(e,t){e.nodeName==`BR`&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text(`-`),t,!0)}readStyles(e,t){let n=e.style;if(n&&n.length)for(let e=0;e<this.parser.matchedStyles.length;e++){let r=this.parser.matchedStyles[e],i=n.getPropertyValue(r);if(i)for(let e;;){let n=this.parser.matchStyle(r,i,this,e);if(!n)break;if(n.ignore)return null;if(t=n.clearMark?t.filter(e=>!n.clearMark(e)):t.concat(this.parser.schema.marks[n.mark].create(n.attrs)),n.consuming===!1)e=n;else break}}return t}addElementByRule(e,t,n,r){let i,a;if(t.node)if(a=this.parser.schema.nodes[t.node],a.isLeaf)this.insertNode(a.create(t.attrs),n,e.nodeName==`BR`)||this.leafFallback(e,n);else{let e=this.enter(a,t.attrs||null,n,t.preserveWhitespace);e&&(i=!0,n=e)}else{let e=this.parser.schema.marks[t.mark];n=n.concat(e.create(t.attrs))}let o=this.top;if(a&&a.isLeaf)this.findInside(e);else if(r)this.addElement(e,n,r);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(e=>this.insertNode(e,n,!1));else{let r=e;typeof t.contentElement==`string`?r=e.querySelector(t.contentElement):typeof t.contentElement==`function`?r=t.contentElement(e):t.contentElement&&(r=t.contentElement),this.findAround(e,r,!0),this.addAll(r,n),this.findAround(e,r,!1)}i&&this.sync(o)&&this.open--}addAll(e,t,n,r){let i=n||0;for(let a=n?e.childNodes[n]:e.firstChild,o=r==null?null:e.childNodes[r];a!=o;a=a.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(a,t);this.findAtPoint(e,i)}findPlace(e,t,n){let r,i;for(let t=this.open,a=0;t>=0;t--){let o=this.nodes[t],s=o.findWrapping(e);if(s&&(!r||r.length>s.length+a)&&(r=s,i=o,!s.length))break;if(o.solid){if(n)break;a+=2}}if(!r)return null;this.sync(i);for(let e=0;e<r.length;e++)t=this.enterInner(r[e],null,t,!1);return t}insertNode(e,t,n){if(e.isInline&&this.needsBlock&&!this.top.type){let e=this.textblockFromContext();e&&(t=this.enterInner(e,null,t))}let r=this.findPlace(e,t,n);if(r){this.closeExtra();let t=this.top;t.match&&=t.match.matchType(e.type);let n=ld.none;for(let i of r.concat(e.marks))(t.type?t.type.allowsMarkType(i.type):vf(i.type,e.type))&&(n=i.addToSet(n));return t.content.push(e.mark(n)),!0}return!1}enter(e,t,n,r){let i=this.findPlace(e.create(t),n,!1);return i&&=this.enterInner(e,t,n,!0,r),i}enterInner(e,t,n,r=!1,i){this.closeExtra();let a=this.top;a.match=a.match&&a.match.matchType(e);let o=ff(e,i,a.options);a.options&df&&a.content.length==0&&(o|=df);let s=ld.none;return n=n.filter(t=>(a.type?a.type.allowsMarkType(t.type):vf(t.type,e))?(s=t.addToSet(s),!1):!0),this.nodes.push(new pf(e,t,s,r,null,o)),this.open++,n}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--)if(this.nodes[t]==e)return this.open=t,!0;else this.localPreserveWS&&(this.nodes[t].options|=lf);return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let n=this.nodes[t].content;for(let t=n.length-1;t>=0;t--)e+=n[t].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&this.find[n].offset==t&&(this.find[n].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,n){if(e!=t&&this.find)for(let r=0;r<this.find.length;r++)this.find[r].pos==null&&e.nodeType==1&&e.contains(this.find[r].node)&&t.compareDocumentPosition(this.find[r].node)&(n?2:4)&&(this.find[r].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf(`|`)>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split(`/`),n=this.options.context,r=!this.isOpen&&(!n||n.parent.type==this.nodes[0].type),i=-(n?n.depth+1:0)+ +!r,a=(e,o)=>{for(;e>=0;e--){let s=t[e];if(s==``){if(e==t.length-1||e==0)continue;for(;o>=i;o--)if(a(e-1,o))return!0;return!1}else{let e=o>0||o==0&&r?this.nodes[o].type:n&&o>=i?n.node(o-i).type:null;if(!e||e.name!=s&&!e.isInGroup(s))return!1;o--}}return!0};return a(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let n=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let e in this.parser.schema.nodes){let t=this.parser.schema.nodes[e];if(t.isTextblock&&t.defaultAttrs)return t}}};function hf(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let e=t.nodeType==1?t.nodeName.toLowerCase():null;e&&cf.hasOwnProperty(e)&&n?(n.appendChild(t),t=n):e==`li`?n=t:e&&(n=null)}}function gf(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function _f(e){let t={};for(let n in e)t[n]=e[n];return t}function vf(e,t){let n=t.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(e))continue;let a=[],o=e=>{a.push(e);for(let n=0;n<e.edgeCount;n++){let{type:r,next:i}=e.edge(n);if(r==t||a.indexOf(i)<0&&o(i))return!0}};if(o(i.contentMatch))return!0}}var yf=class e{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){n||=xf(t).createDocumentFragment();let r=n,i=[];return e.forEach(e=>{if(i.length||e.marks.length){let n=0,a=0;for(;n<i.length&&a<e.marks.length;){let t=e.marks[a];if(!this.marks[t.type.name]){a++;continue}if(!t.eq(i[n][0])||t.type.spec.spanning===!1)break;n++,a++}for(;n<i.length;)r=i.pop()[1];for(;a<e.marks.length;){let n=e.marks[a++],o=this.serializeMark(n,e.isInline,t);o&&(i.push([n,r]),r.appendChild(o.dom),r=o.contentDOM||o.dom)}}r.appendChild(this.serializeNodeInner(e,t))}),n}serializeNodeInner(e,t){let{dom:n,contentDOM:r}=Tf(xf(t),this.nodes[e.type.name](e),null,e.attrs);if(r){if(e.isLeaf)throw RangeError(`Content hole not allowed in a leaf node spec`);this.serializeFragment(e.content,t,r)}return n}serializeNode(e,t={}){let n=this.serializeNodeInner(e,t);for(let r=e.marks.length-1;r>=0;r--){let i=this.serializeMark(e.marks[r],e.isInline,t);i&&((i.contentDOM||i.dom).appendChild(n),n=i.dom)}return n}serializeMark(e,t,n={}){let r=this.marks[e.type.name];return r&&Tf(xf(n),r(e,t),null,e.attrs)}static renderSpec(e,t,n=null,r){return Tf(e,t,n,r)}static fromSchema(t){return t.cached.domSerializer||(t.cached.domSerializer=new e(this.nodesFromSchema(t),this.marksFromSchema(t)))}static nodesFromSchema(e){let t=bf(e.nodes);return t.text||=e=>e.text,t}static marksFromSchema(e){return bf(e.marks)}};function bf(e){let t={};for(let n in e){let r=e[n].spec.toDOM;r&&(t[n]=r)}return t}function xf(e){return e.document||window.document}var Sf=new WeakMap;function Cf(e){let t=Sf.get(e);return t===void 0&&Sf.set(e,t=wf(e)),t}function wf(e){let t=null;function n(e){if(e&&typeof e==`object`)if(Array.isArray(e))if(typeof e[0]==`string`)t||=[],t.push(e);else for(let t=0;t<e.length;t++)n(e[t]);else for(let t in e)n(e[t])}return n(e),t}function Tf(e,t,n,r){if(typeof t==`string`)return{dom:e.createTextNode(t)};if(t.nodeType!=null)return{dom:t};if(t.dom&&t.dom.nodeType!=null)return t;let i=t[0],a;if(typeof i!=`string`)throw RangeError(`Invalid array passed to renderSpec`);if(r&&(a=Cf(r))&&a.indexOf(t)>-1)throw RangeError(`Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.`);let o=i.indexOf(` `);o>0&&(n=i.slice(0,o),i=i.slice(o+1));let s,c=n?e.createElementNS(n,i):e.createElement(i),l=t[1],u=1;if(l&&typeof l==`object`&&l.nodeType==null&&!Array.isArray(l)){u=2;for(let e in l)if(l[e]!=null){let t=e.indexOf(` `);t>0?c.setAttributeNS(e.slice(0,t),e.slice(t+1),l[e]):e==`style`&&c.style?c.style.cssText=l[e]:c.setAttribute(e,l[e])}}for(let i=u;i<t.length;i++){let a=t[i];if(a===0){if(i<t.length-1||i>u)throw RangeError(`Content hole must be the only child of its parent node`);return{dom:c,contentDOM:c}}else{let{dom:t,contentDOM:i}=Tf(e,a,n,r);if(c.appendChild(t),i){if(s)throw RangeError(`Multiple content holes`);s=i}}}return{dom:c,contentDOM:s}}var Ef=65535,Df=2**16;function Of(e,t){return e+t*Df}function kf(e){return e&Ef}function Af(e){return(e-(e&Ef))/Df}var jf=1,Mf=2,Nf=4,Pf=8,Ff=class{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(this.delInfo&Pf)>0}get deletedBefore(){return(this.delInfo&5)>0}get deletedAfter(){return(this.delInfo&6)>0}get deletedAcross(){return(this.delInfo&Nf)>0}},If=class e{constructor(t,n=!1){if(this.ranges=t,this.inverted=n,!t.length&&e.empty)return e.empty}recover(e){let t=0,n=kf(e);if(!this.inverted)for(let e=0;e<n;e++)t+=this.ranges[e*3+2]-this.ranges[e*3+1];return this.ranges[n*3]+t+Af(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,n){let r=0,i=this.inverted?2:1,a=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let s=this.ranges[o]-(this.inverted?r:0);if(s>e)break;let c=this.ranges[o+i],l=this.ranges[o+a],u=s+c;if(e<=u){let i=c?e==s?-1:e==u?1:t:t,a=s+r+(i<0?0:l);if(n)return a;let d=e==(t<0?s:u)?null:Of(o/3,e-s),f=e==s?Mf:e==u?jf:Nf;return(t<0?e!=s:e!=u)&&(f|=Pf),new Ff(a,f,d)}r+=l-c}return n?e+r:new Ff(e+r,0,null)}touches(e,t){let n=0,r=kf(t),i=this.inverted?2:1,a=this.inverted?1:2;for(let t=0;t<this.ranges.length;t+=3){let o=this.ranges[t]-(this.inverted?n:0);if(o>e)break;let s=this.ranges[t+i];if(e<=o+s&&t==r*3)return!0;n+=this.ranges[t+a]-s}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let r=0,i=0;r<this.ranges.length;r+=3){let a=this.ranges[r],o=a-(this.inverted?i:0),s=a+(this.inverted?0:i),c=this.ranges[r+t],l=this.ranges[r+n];e(o,o+c,s,s+l),i+=l-c}}invert(){return new e(this.ranges,!this.inverted)}toString(){return(this.inverted?`-`:``)+JSON.stringify(this.ranges)}static offset(t){return t==0?e.empty:new e(t<0?[0,-t,0]:[0,0,t])}};If.empty=new If([]);var Lf=class e{constructor(e,t,n=0,r=e?e.length:0){this.mirror=t,this.from=n,this.to=r,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(t=0,n=this.maps.length){return new e(this._maps,this.mirror,t,n)}appendMap(e,t){this.ownData||=(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),!0),this.to=this._maps.push(e),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,n=this._maps.length;t<e._maps.length;t++){let r=e.getMirror(t);this.appendMap(e._maps[t],r!=null&&r<t?n+r:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||=[],this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,n=this._maps.length+e._maps.length;t>=0;t--){let r=e.getMirror(t);this.appendMap(e._maps[t].invert(),r!=null&&r>t?n-r-1:void 0)}}invert(){let t=new e;return t.appendMappingInverted(this),t}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let n=this.from;n<this.to;n++)e=this._maps[n].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,n){let r=0;for(let n=this.from;n<this.to;n++){let i=this._maps[n].mapResult(e,t);if(i.recover!=null){let t=this.getMirror(n);if(t!=null&&t>n&&t<this.to){n=t,e=this._maps[t].recover(i.recover);continue}}r|=i.delInfo,e=i.pos}return n?e:new Ff(e,r,null)}},Rf=Object.create(null),zf=class{getMap(){return If.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw RangeError(`Invalid input for Step.fromJSON`);let n=Rf[t.stepType];if(!n)throw RangeError(`No step type ${t.stepType} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in Rf)throw RangeError(`Duplicate use of step JSON ID `+e);return Rf[e]=t,t.prototype.jsonID=e,t}},Bf=class e{constructor(e,t){this.doc=e,this.failed=t}static ok(t){return new e(t,null)}static fail(t){return new e(null,t)}static fromReplace(t,n,r,i){try{return e.ok(t.replace(n,r,i))}catch(t){if(t instanceof ud)return e.fail(t.message);throw t}}};function Vf(e,t,n){let r=[];for(let i=0;i<e.childCount;i++){let a=e.child(i);a.content.size&&(a=a.copy(Vf(a.content,t,a))),a.isInline&&(a=t(a,n,i)),r.push(a)}return Z.fromArray(r)}var Hf=class e extends zf{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=e.resolve(this.from),r=n.node(n.sharedDepth(this.to)),i=new Q(Vf(t.content,(e,t)=>!e.isAtom||!t.type.allowsMarkType(this.mark.type)?e:e.mark(this.mark.addToSet(e.marks)),r),t.openStart,t.openEnd);return Bf.fromReplace(e,this.from,this.to,i)}invert(){return new Uf(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new e(n.pos,r.pos,this.mark)}merge(t){return t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:`addMark`,mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for AddMarkStep.fromJSON`);return new e(n.from,n.to,t.markFromJSON(n.mark))}};zf.jsonID(`addMark`,Hf);var Uf=class e extends zf{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=new Q(Vf(t.content,e=>e.mark(this.mark.removeFromSet(e.marks)),e),t.openStart,t.openEnd);return Bf.fromReplace(e,this.from,this.to,n)}invert(){return new Hf(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new e(n.pos,r.pos,this.mark)}merge(t){return t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:`removeMark`,mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for RemoveMarkStep.fromJSON`);return new e(n.from,n.to,t.markFromJSON(n.mark))}};zf.jsonID(`removeMark`,Uf);var Wf=class e extends zf{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return Bf.fail(`No node at mark step's position`);let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return Bf.fromReplace(e,this.pos,this.pos+1,new Q(Z.from(n),0,+!t.isLeaf))}invert(t){let n=t.nodeAt(this.pos);if(n){let t=this.mark.addToSet(n.marks);if(t.length==n.marks.length){for(let r=0;r<n.marks.length;r++)if(!n.marks[r].isInSet(t))return new e(this.pos,n.marks[r]);return new e(this.pos,this.mark)}}return new Gf(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.mark)}toJSON(){return{stepType:`addNodeMark`,pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for AddNodeMarkStep.fromJSON`);return new e(n.pos,t.markFromJSON(n.mark))}};zf.jsonID(`addNodeMark`,Wf);var Gf=class e extends zf{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return Bf.fail(`No node at mark step's position`);let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return Bf.fromReplace(e,this.pos,this.pos+1,new Q(Z.from(n),0,+!t.isLeaf))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new Wf(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.mark)}toJSON(){return{stepType:`removeNodeMark`,pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for RemoveNodeMarkStep.fromJSON`);return new e(n.pos,t.markFromJSON(n.mark))}};zf.jsonID(`removeNodeMark`,Gf);var Kf=class e extends zf{constructor(e,t,n,r=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=r}apply(e){return this.structure&&Jf(e,this.from,this.to)?Bf.fail(`Structure replace would overwrite content`):Bf.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new If([this.from,this.to-this.from,this.slice.size])}invert(t){return new e(this.from,this.from+this.slice.size,t.slice(this.from,this.to))}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deletedAcross&&r.deletedAcross?null:new e(n.pos,Math.max(n.pos,r.pos),this.slice,this.structure)}merge(t){if(!(t instanceof e)||t.structure||this.structure)return null;if(this.from+this.slice.size==t.from&&!this.slice.openEnd&&!t.slice.openStart){let n=this.slice.size+t.slice.size==0?Q.empty:new Q(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new e(this.from,this.to+(t.to-t.from),n,this.structure)}else if(t.to==this.from&&!this.slice.openStart&&!t.slice.openEnd){let n=this.slice.size+t.slice.size==0?Q.empty:new Q(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new e(t.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(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for ReplaceStep.fromJSON`);return new e(n.from,n.to,Q.fromJSON(t,n.slice),!!n.structure)}};zf.jsonID(`replace`,Kf);var qf=class e extends zf{constructor(e,t,n,r,i,a,o=!1){super(),this.from=e,this.to=t,this.gapFrom=n,this.gapTo=r,this.slice=i,this.insert=a,this.structure=o}apply(e){if(this.structure&&(Jf(e,this.from,this.gapFrom)||Jf(e,this.gapTo,this.to)))return Bf.fail(`Structure gap-replace would overwrite content`);let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return Bf.fail(`Gap is not a flat range`);let n=this.slice.insertAt(this.insert,t.content);return n?Bf.fromReplace(e,this.from,this.to,n):Bf.fail(`Content does not fit in gap`)}getMap(){return new If([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(t){let n=this.gapTo-this.gapFrom;return new e(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,t.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1),i=this.from==this.gapFrom?n.pos:t.map(this.gapFrom,-1),a=this.to==this.gapTo?r.pos:t.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||i<n.pos||a>r.pos?null:new e(n.pos,r.pos,i,a,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(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`||typeof n.gapFrom!=`number`||typeof n.gapTo!=`number`||typeof n.insert!=`number`)throw RangeError(`Invalid input for ReplaceAroundStep.fromJSON`);return new e(n.from,n.to,n.gapFrom,n.gapTo,Q.fromJSON(t,n.slice),n.insert,!!n.structure)}};zf.jsonID(`replaceAround`,qf);function Jf(e,t,n){let r=e.resolve(t),i=n-t,a=r.depth;for(;i>0&&a>0&&r.indexAfter(a)==r.node(a).childCount;)a--,i--;if(i>0){let e=r.node(a).maybeChild(r.indexAfter(a));for(;i>0;){if(!e||e.isLeaf)return!0;e=e.firstChild,i--}}return!1}function Yf(e,t,n,r){let i=[],a=[],o,s;e.doc.nodesBetween(t,n,(e,c,l)=>{if(!e.isInline)return;let u=e.marks;if(!r.isInSet(u)&&l.type.allowsMarkType(r.type)){let l=Math.max(c,t),d=Math.min(c+e.nodeSize,n),f=r.addToSet(u);for(let e=0;e<u.length;e++)u[e].isInSet(f)||(o&&o.to==l&&o.mark.eq(u[e])?o.to=d:i.push(o=new Uf(l,d,u[e])));s&&s.to==l?s.to=d:a.push(s=new Hf(l,d,r))}}),i.forEach(t=>e.step(t)),a.forEach(t=>e.step(t))}function Xf(e,t,n,r){let i=[],a=0;e.doc.nodesBetween(t,n,(e,o)=>{if(!e.isInline)return;a++;let s=null;if(r instanceof $d){let t=e.marks,n;for(;n=r.isInSet(t);)(s||=[]).push(n),t=n.removeFromSet(t)}else r?r.isInSet(e.marks)&&(s=[r]):s=e.marks;if(s&&s.length){let r=Math.min(o+e.nodeSize,n);for(let e=0;e<s.length;e++){let n=s[e],c;for(let e=0;e<i.length;e++){let t=i[e];t.step==a-1&&n.eq(i[e].style)&&(c=t)}c?(c.to=r,c.step=a):i.push({style:n,from:Math.max(o,t),to:r,step:a})}}}),i.forEach(t=>e.step(new Uf(t.from,t.to,t.style)))}function Zf(e,t,n,r=n.contentMatch,i=!0){let a=e.doc.nodeAt(t),o=[],s=t+1;for(let t=0;t<a.childCount;t++){let c=a.child(t),l=s+c.nodeSize,u=r.matchType(c.type);if(!u)o.push(new Kf(s,l,Q.empty));else{r=u;for(let t=0;t<c.marks.length;t++)n.allowsMarkType(c.marks[t].type)||e.step(new Uf(s,l,c.marks[t]));if(i&&c.isText&&n.whitespace!=`pre`){let e,t=/\r?\n|\r/g,r;for(;e=t.exec(c.text);)r||=new Q(Z.from(n.schema.text(` `,n.allowedMarks(c.marks))),0,0),o.push(new Kf(s+e.index,s+e.index+e[0].length,r))}}s=l}if(!r.validEnd){let t=r.fillBefore(Z.empty,!0);e.replace(s,s,new Q(t,0,0))}for(let t=o.length-1;t>=0;t--)e.step(o[t])}function Qf(e,t,n){return(t==0||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function $f(e){let t=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let n=e.depth,r=0,i=0;;--n){let a=e.$from.node(n),o=e.$from.index(n)+r,s=e.$to.indexAfter(n)-i;if(n<e.depth&&a.canReplace(o,s,t))return n;if(n==0||a.type.spec.isolating||!Qf(a,o,s))break;o&&(r=1),s<a.childCount&&(i=1)}return null}function ep(e,t,n){let{$from:r,$to:i,depth:a}=t,o=r.before(a+1),s=i.after(a+1),c=o,l=s,u=Z.empty,d=0;for(let e=a,t=!1;e>n;e--)t||r.index(e)>0?(t=!0,u=Z.from(r.node(e).copy(u)),d++):c--;let f=Z.empty,p=0;for(let e=a,t=!1;e>n;e--)t||i.after(e+1)<i.end(e)?(t=!0,f=Z.from(i.node(e).copy(f)),p++):l++;e.step(new qf(c,l,o,s,new Q(u.append(f),d,p),u.size-d,!0))}function tp(e,t,n=null,r=e){let i=rp(e,t),a=i&&ip(r,t);return a?i.map(np).concat({type:t,attrs:n}).concat(a.map(np)):null}function np(e){return{type:e,attrs:null}}function rp(e,t){let{parent:n,startIndex:r,endIndex:i}=e,a=n.contentMatchAt(r).findWrapping(t);if(!a)return null;let o=a.length?a[0]:t;return n.canReplaceWith(r,i,o)?a:null}function ip(e,t){let{parent:n,startIndex:r,endIndex:i}=e,a=n.child(r),o=t.contentMatch.findWrapping(a.type);if(!o)return null;let s=(o.length?o[o.length-1]:t).contentMatch;for(let e=r;s&&e<i;e++)s=s.matchType(n.child(e).type);return!s||!s.validEnd?null:o}function ap(e,t,n){let r=Z.empty;for(let e=n.length-1;e>=0;e--){if(r.size){let t=n[e].type.contentMatch.matchFragment(r);if(!t||!t.validEnd)throw RangeError(`Wrapper type given to Transform.wrap does not form valid content of its parent wrapper`)}r=Z.from(n[e].type.create(n[e].attrs,r))}let i=t.start,a=t.end;e.step(new qf(i,a,i,a,new Q(r,0,0),n.length,!0))}function op(e,t,n,r,i){if(!r.isTextblock)throw RangeError(`Type given to setBlockType should be a textblock`);let a=e.steps.length;e.doc.nodesBetween(t,n,(t,n)=>{let o=typeof i==`function`?i(t):i;if(t.isTextblock&&!t.hasMarkup(r,o)&&lp(e.doc,e.mapping.slice(a).map(n),r)){let i=null;if(r.schema.linebreakReplacement){let e=r.whitespace==`pre`,t=!!r.contentMatch.matchType(r.schema.linebreakReplacement);e&&!t?i=!1:!e&&t&&(i=!0)}i===!1&&cp(e,t,n,a),Zf(e,e.mapping.slice(a).map(n,1),r,void 0,i===null);let s=e.mapping.slice(a),c=s.map(n,1),l=s.map(n+t.nodeSize,1);return e.step(new qf(c,l,c+1,l-1,new Q(Z.from(r.create(o,null,t.marks)),0,0),1,!0)),i===!0&&sp(e,t,n,a),!1}})}function sp(e,t,n,r){t.forEach((i,a)=>{if(i.isText){let o,s=/\r?\n|\r/g;for(;o=s.exec(i.text);){let i=e.mapping.slice(r).map(n+1+a+o.index);e.replaceWith(i,i+1,t.type.schema.linebreakReplacement.create())}}})}function cp(e,t,n,r){t.forEach((i,a)=>{if(i.type==i.type.schema.linebreakReplacement){let i=e.mapping.slice(r).map(n+1+a);e.replaceWith(i,i+1,t.type.schema.text(`
10
+ `))}})}function lp(e,t,n){let r=e.resolve(t),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function up(e,t,n,r,i){let a=e.doc.nodeAt(t);if(!a)throw RangeError(`No node at given position`);n||=a.type;let o=n.create(r,null,i||a.marks);if(a.isLeaf)return e.replaceWith(t,t+a.nodeSize,o);if(!n.validContent(a.content))throw RangeError(`Invalid content for node type `+n.name);e.step(new qf(t,t+a.nodeSize,t+1,t+a.nodeSize-1,new Q(Z.from(o),0,0),1,!0))}function dp(e,t,n=1,r){let i=e.resolve(t),a=i.depth-n,o=r&&r[r.length-1]||i.parent;if(a<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!o.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let e=i.depth-1,t=n-2;e>a;e--,t--){let n=i.node(e),a=i.index(e);if(n.type.spec.isolating)return!1;let o=n.content.cutByIndex(a,n.childCount),s=r&&r[t+1];s&&(o=o.replaceChild(0,s.type.create(s.attrs)));let c=r&&r[t]||n;if(!n.canReplace(a+1,n.childCount)||!c.type.validContent(o))return!1}let s=i.indexAfter(a),c=r&&r[0];return i.node(a).canReplaceWith(s,s,c?c.type:i.node(a+1).type)}function fp(e,t,n=1,r){let i=e.doc.resolve(t),a=Z.empty,o=Z.empty;for(let e=i.depth,t=i.depth-n,s=n-1;e>t;e--,s--){a=Z.from(i.node(e).copy(a));let t=r&&r[s];o=Z.from(t?t.type.create(t.attrs,o):i.node(e).copy(o))}e.step(new Kf(t,t,new Q(a.append(o),n,n),!0))}function pp(e,t){let n=e.resolve(t),r=n.index();return hp(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function mp(e,t){t.content.size||e.type.compatibleContent(t.type);let n=e.contentMatchAt(e.childCount),{linebreakReplacement:r}=e.type.schema;for(let i=0;i<t.childCount;i++){let a=t.child(i),o=a.type==r?e.type.schema.nodes.text:a.type;if(n=n.matchType(o),!n||!e.type.allowsMarks(a.marks))return!1}return n.validEnd}function hp(e,t){return!!(e&&t&&!e.isLeaf&&mp(e,t))}function gp(e,t,n=-1){let r=e.resolve(t);for(let e=r.depth;;e--){let i,a,o=r.index(e);if(e==r.depth?(i=r.nodeBefore,a=r.nodeAfter):n>0?(i=r.node(e+1),o++,a=r.node(e).maybeChild(o)):(i=r.node(e).maybeChild(o-1),a=r.node(e+1)),i&&!i.isTextblock&&hp(i,a)&&r.node(e).canReplace(o,o+1))return t;if(e==0)break;t=n<0?r.before(e):r.after(e)}}function _p(e,t,n){let r=null,{linebreakReplacement:i}=e.doc.type.schema,a=e.doc.resolve(t-n),o=a.node().type;if(i&&o.inlineContent){let e=o.whitespace==`pre`,t=!!o.contentMatch.matchType(i);e&&!t?r=!1:!e&&t&&(r=!0)}let s=e.steps.length;if(r===!1){let r=e.doc.resolve(t+n);cp(e,r.node(),r.before(),s)}o.inlineContent&&Zf(e,t+n-1,o,a.node().contentMatchAt(a.index()),r==null);let c=e.mapping.slice(s),l=c.map(t-n);if(e.step(new Kf(l,c.map(t+n,-1),Q.empty,!0)),r===!0){let t=e.doc.resolve(l);sp(e,t.node(),t.before(),e.steps.length)}return e}function vp(e,t,n){let r=e.resolve(t);if(r.parent.canReplaceWith(r.index(),r.index(),n))return t;if(r.parentOffset==0)for(let e=r.depth-1;e>=0;e--){let t=r.index(e);if(r.node(e).canReplaceWith(t,t,n))return r.before(e+1);if(t>0)return null}if(r.parentOffset==r.parent.content.size)for(let e=r.depth-1;e>=0;e--){let t=r.indexAfter(e);if(r.node(e).canReplaceWith(t,t,n))return r.after(e+1);if(t<r.node(e).childCount)return null}return null}function yp(e,t,n){let r=e.resolve(t);if(!n.content.size)return t;let i=n.content;for(let e=0;e<n.openStart;e++)i=i.firstChild.content;for(let e=1;e<=(n.openStart==0&&n.size?2:1);e++)for(let t=r.depth;t>=0;t--){let n=t==r.depth?0:r.pos<=(r.start(t+1)+r.end(t+1))/2?-1:1,a=r.index(t)+ +(n>0),o=r.node(t),s=!1;if(e==1)s=o.canReplace(a,a,i);else{let e=o.contentMatchAt(a).findWrapping(i.firstChild.type);s=e&&o.canReplaceWith(a,a,e[0])}if(s)return n==0?r.pos:n<0?r.before(t+1):r.after(t+1)}return null}function bp(e,t,n=t,r=Q.empty){if(t==n&&!r.size)return null;let i=e.resolve(t),a=e.resolve(n);return xp(i,a,r)?new Kf(t,n,r):new Sp(i,a,r).fit()}function xp(e,t,n){return!n.openStart&&!n.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),n.content)}var Sp=class{constructor(e,t,n){this.$from=e,this.$to=t,this.unplaced=n,this.frontier=[],this.placed=Z.empty;for(let t=0;t<=e.depth;t++){let n=e.node(t);this.frontier.push({type:n.type,match:n.contentMatchAt(e.indexAfter(t))})}for(let t=e.depth;t>0;t--)this.placed=Z.from(e.node(t).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let e=this.findFittable();e?this.placeNodes(e):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,n=this.$from,r=this.close(e<0?this.$to:n.doc.resolve(e));if(!r)return null;let i=this.placed,a=n.depth,o=r.depth;for(;a&&o&&i.childCount==1;)i=i.firstChild.content,a--,o--;let s=new Q(i,a,o);return e>-1?new qf(n.pos,e,this.$to.pos,this.$to.end(),s,t):s.size||n.pos!=this.$to.pos?new Kf(n.pos,r.pos,s):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,n=0,r=this.unplaced.openEnd;n<e;n++){let i=t.firstChild;if(t.childCount>1&&(r=0),i.type.spec.isolating&&r<=n){e=n;break}t=i.content}for(let t=1;t<=2;t++)for(let n=t==1?e:this.unplaced.openStart;n>=0;n--){let e,r=null;n?(r=Tp(this.unplaced.content,n-1).firstChild,e=r.content):e=this.unplaced.content;let i=e.firstChild;for(let e=this.depth;e>=0;e--){let{type:a,match:o}=this.frontier[e],s,c=null;if(t==1&&(i?o.matchType(i.type)||(c=o.fillBefore(Z.from(i),!1)):r&&a.compatibleContent(r.type)))return{sliceDepth:n,frontierDepth:e,parent:r,inject:c};if(t==2&&i&&(s=o.findWrapping(i.type)))return{sliceDepth:n,frontierDepth:e,parent:r,wrap:s};if(r&&o.matchType(r.type))break}}}openMore(){let{content:e,openStart:t,openEnd:n}=this.unplaced,r=Tp(e,t);return!r.childCount||r.firstChild.isLeaf?!1:(this.unplaced=new Q(e,t+1,Math.max(n,r.size+t>=e.size-n?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:n}=this.unplaced,r=Tp(e,t);if(r.childCount<=1&&t>0){let i=e.size-t<=t+r.size;this.unplaced=new Q(Cp(e,t-1,1),t-1,i?t-1:n)}else this.unplaced=new Q(Cp(e,t,1),t,n)}placeNodes({sliceDepth:e,frontierDepth:t,parent:n,inject:r,wrap:i}){for(;this.depth>t;)this.closeFrontierNode();if(i)for(let e=0;e<i.length;e++)this.openFrontierNode(i[e]);let a=this.unplaced,o=n?n.content:a.content,s=a.openStart-e,c=0,l=[],{match:u,type:d}=this.frontier[t];if(r){for(let e=0;e<r.childCount;e++)l.push(r.child(e));u=u.matchFragment(r)}let f=o.size+e-(a.content.size-a.openEnd);for(;c<o.childCount;){let e=o.child(c),t=u.matchType(e.type);if(!t)break;c++,(c>1||s==0||e.content.size)&&(u=t,l.push(Ep(e.mark(d.allowedMarks(e.marks)),c==1?s:0,c==o.childCount?f:-1)))}let p=c==o.childCount;p||(f=-1),this.placed=wp(this.placed,t,Z.from(l)),this.frontier[t].match=u,p&&f<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let e=0,t=o;e<f;e++){let e=t.lastChild;this.frontier.push({type:e.type,match:e.contentMatchAt(e.childCount)}),t=e.content}this.unplaced=p?e==0?Q.empty:new Q(Cp(a.content,e-1,1),e-1,f<0?a.openEnd:e-1):new Q(Cp(a.content,e,c),a.openStart,a.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!Dp(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;let{depth:n}=this.$to,r=this.$to.after(n);for(;n>1&&r==this.$to.end(--n);)++r;return r}findCloseLevel(e){scan:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:n,type:r}=this.frontier[t],i=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),a=Dp(e,t,r,n,i);if(a){for(let n=t-1;n>=0;n--){let{match:t,type:r}=this.frontier[n],i=Dp(e,n,r,t,!0);if(!i||i.childCount)continue scan}return{depth:t,fit:a,move:i?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=wp(this.placed,t.depth,t.fit)),e=t.move;for(let n=t.depth+1;n<=e.depth;n++){let t=e.node(n),r=t.type.contentMatch.fillBefore(t.content,!0,e.index(n));this.openFrontierNode(t.type,t.attrs,r)}return e}openFrontierNode(e,t=null,n){let r=this.frontier[this.depth];r.match=r.match.matchType(e),this.placed=wp(this.placed,this.depth,Z.from(e.create(t,n))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let e=this.frontier.pop().match.fillBefore(Z.empty,!0);e.childCount&&(this.placed=wp(this.placed,this.frontier.length,e))}};function Cp(e,t,n){return t==0?e.cutByIndex(n,e.childCount):e.replaceChild(0,e.firstChild.copy(Cp(e.firstChild.content,t-1,n)))}function wp(e,t,n){return t==0?e.append(n):e.replaceChild(e.childCount-1,e.lastChild.copy(wp(e.lastChild.content,t-1,n)))}function Tp(e,t){for(let n=0;n<t;n++)e=e.firstChild.content;return e}function Ep(e,t,n){if(t<=0)return e;let r=e.content;return t>1&&(r=r.replaceChild(0,Ep(r.firstChild,t-1,r.childCount==1?n-1:0))),t>0&&(r=e.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(e.type.contentMatch.matchFragment(r).fillBefore(Z.empty,!0)))),e.copy(r)}function Dp(e,t,n,r,i){let a=e.node(t),o=i?e.indexAfter(t):e.index(t);if(o==a.childCount&&!n.compatibleContent(a.type))return null;let s=r.fillBefore(a.content,!0,o);return s&&!Op(n,a.content,o)?s:null}function Op(e,t,n){for(let r=n;r<t.childCount;r++)if(!e.allowsMarks(t.child(r).marks))return!0;return!1}function kp(e){return e.spec.defining||e.spec.definingForContent}function Ap(e,t,n,r){if(!r.size)return e.deleteRange(t,n);let i=e.doc.resolve(t),a=e.doc.resolve(n);if(xp(i,a,r))return e.step(new Kf(t,n,r));let o=Pp(i,a);o[o.length-1]==0&&o.pop();let s=-(i.depth+1);o.unshift(s);for(let e=i.depth,t=i.pos-1;e>0;e--,t--){let n=i.node(e).type.spec;if(n.defining||n.definingAsContext||n.isolating)break;o.indexOf(e)>-1?s=e:i.before(e)==t&&o.splice(1,0,-e)}let c=o.indexOf(s),l=[],u=r.openStart;for(let e=r.content,t=0;;t++){let n=e.firstChild;if(l.push(n),t==r.openStart)break;e=n.content}for(let e=u-1;e>=0;e--){let t=l[e],n=kp(t.type);if(n&&!t.sameMarkup(i.node(Math.abs(s)-1)))u=e;else if(n||!t.type.isTextblock)break}for(let t=r.openStart;t>=0;t--){let s=(t+u+1)%(r.openStart+1),d=l[s];if(d)for(let t=0;t<o.length;t++){let l=o[(t+c)%o.length],u=!0;l<0&&(u=!1,l=-l);let f=i.node(l-1),p=i.index(l-1);if(f.canReplaceWith(p,p,d.type,d.marks))return e.replace(i.before(l),u?a.after(l):n,new Q(jp(r.content,0,r.openStart,s),s,r.openEnd))}}let d=e.steps.length;for(let s=o.length-1;s>=0&&(e.replace(t,n,r),!(e.steps.length>d));s--){let e=o[s];e<0||(t=i.before(e),n=a.after(e))}}function jp(e,t,n,r,i){if(t<n){let i=e.firstChild;e=e.replaceChild(0,i.copy(jp(i.content,t+1,n,r,i)))}if(t>r){let t=i.contentMatchAt(0),n=t.fillBefore(e).append(e);e=n.append(t.matchFragment(n).fillBefore(Z.empty,!0))}return e}function Mp(e,t,n,r){if(!r.isInline&&t==n&&e.doc.resolve(t).parent.content.size){let i=vp(e.doc,t,r.type);i!=null&&(t=n=i)}e.replaceRange(t,n,new Q(Z.from(r),0,0))}function Np(e,t,n){let r=e.doc.resolve(t),i=e.doc.resolve(n),a=Pp(r,i);for(let t=0;t<a.length;t++){let n=a[t],o=t==a.length-1;if(o&&n==0||r.node(n).type.contentMatch.validEnd)return e.delete(r.start(n),i.end(n));if(n>0&&(o||r.node(n-1).canReplace(r.index(n-1),i.indexAfter(n-1))))return e.delete(r.before(n),i.after(n))}for(let a=1;a<=r.depth&&a<=i.depth;a++)if(t-r.start(a)==r.depth-a&&n>r.end(a)&&i.end(a)-n!=i.depth-a&&r.start(a-1)==i.start(a-1)&&r.node(a-1).canReplace(r.index(a-1),i.index(a-1)))return e.delete(r.before(a),n);e.delete(t,n)}function Pp(e,t){let n=[],r=Math.min(e.depth,t.depth);for(let i=r;i>=0;i--){let r=e.start(i);if(r<e.pos-(e.depth-i)||t.end(i)>t.pos+(t.depth-i)||e.node(i).type.spec.isolating||t.node(i).type.spec.isolating)break;(r==t.start(i)||i==e.depth&&i==t.depth&&e.parent.inlineContent&&t.parent.inlineContent&&i&&t.start(i-1)==r-1)&&n.push(i)}return n}var Fp=class e extends zf{constructor(e,t,n){super(),this.pos=e,this.attr=t,this.value=n}apply(e){let t=e.nodeAt(this.pos);if(!t)return Bf.fail(`No node at attribute step's position`);let n=Object.create(null);for(let e in t.attrs)n[e]=t.attrs[e];n[this.attr]=this.value;let r=t.type.create(n,null,t.marks);return Bf.fromReplace(e,this.pos,this.pos+1,new Q(Z.from(r),0,+!t.isLeaf))}getMap(){return If.empty}invert(t){return new e(this.pos,this.attr,t.nodeAt(this.pos).attrs[this.attr])}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.attr,this.value)}toJSON(){return{stepType:`attr`,pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(t,n){if(typeof n.pos!=`number`||typeof n.attr!=`string`)throw RangeError(`Invalid input for AttrStep.fromJSON`);return new e(n.pos,n.attr,n.value)}};zf.jsonID(`attr`,Fp);var Ip=class e extends zf{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let n in e.attrs)t[n]=e.attrs[n];t[this.attr]=this.value;let n=e.type.create(t,e.content,e.marks);return Bf.ok(n)}getMap(){return If.empty}invert(t){return new e(this.attr,t.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:`docAttr`,attr:this.attr,value:this.value}}static fromJSON(t,n){if(typeof n.attr!=`string`)throw RangeError(`Invalid input for DocAttrStep.fromJSON`);return new e(n.attr,n.value)}};zf.jsonID(`docAttr`,Ip);var Lp=class extends Error{};Lp=function e(t){let n=Error.call(this,t);return n.__proto__=e.prototype,n},Lp.prototype=Object.create(Error.prototype),Lp.prototype.constructor=Lp,Lp.prototype.name=`TransformError`;var Rp=class{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Lf}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new Lp(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,t=-1e9;for(let n=0;n<this.mapping.maps.length;n++){let r=this.mapping.maps[n];n&&(e=r.map(e,1),t=r.map(t,-1)),r.forEach((n,r,i,a)=>{e=Math.min(e,i),t=Math.max(t,a)})}return e==1e9?null:{from:e,to:t}}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,n=Q.empty){let r=bp(this.doc,e,t,n);return r&&this.step(r),this}replaceWith(e,t,n){return this.replace(e,t,new Q(Z.from(n),0,0))}delete(e,t){return this.replace(e,t,Q.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,n){return Ap(this,e,t,n),this}replaceRangeWith(e,t,n){return Mp(this,e,t,n),this}deleteRange(e,t){return Np(this,e,t),this}lift(e,t){return ep(this,e,t),this}join(e,t=1){return _p(this,e,t),this}wrap(e,t){return ap(this,e,t),this}setBlockType(e,t=e,n,r=null){return op(this,e,t,n,r),this}setNodeMarkup(e,t,n=null,r){return up(this,e,t,n,r),this}setNodeAttribute(e,t,n){return this.step(new Fp(e,t,n)),this}setDocAttribute(e,t){return this.step(new Ip(e,t)),this}addNodeMark(e,t){return this.step(new Wf(e,t)),this}removeNodeMark(e,t){let n=this.doc.nodeAt(e);if(!n)throw RangeError(`No node at position `+e);if(t instanceof ld)t.isInSet(n.marks)&&this.step(new Gf(e,t));else{let r=n.marks,i,a=[];for(;i=t.isInSet(r);)a.push(new Gf(e,i)),r=i.removeFromSet(r);for(let e=a.length-1;e>=0;e--)this.step(a[e])}return this}split(e,t=1,n){return fp(this,e,t,n),this}addMark(e,t,n){return Yf(this,e,t,n),this}removeMark(e,t,n){return Xf(this,e,t,n),this}clearIncompatible(e,t,n){return Zf(this,e,t,n),this}},zp=Object.create(null),Bp=class{constructor(e,t,n){this.$anchor=e,this.$head=t,this.ranges=n||[new Vp(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=Q.empty){let n=t.content.lastChild,r=null;for(let e=0;e<t.openEnd;e++)r=n,n=n.lastChild;let i=e.steps.length,a=this.ranges;for(let o=0;o<a.length;o++){let{$from:s,$to:c}=a[o],l=e.mapping.slice(i);e.replaceRange(l.map(s.pos),l.map(c.pos),o?Q.empty:t),o==0&&Zp(e,i,(n?n.isInline:r&&r.isTextblock)?-1:1)}}replaceWith(e,t){let n=e.steps.length,r=this.ranges;for(let i=0;i<r.length;i++){let{$from:a,$to:o}=r[i],s=e.mapping.slice(n),c=s.map(a.pos),l=s.map(o.pos);i?e.deleteRange(c,l):(e.replaceRangeWith(c,l,t),Zp(e,n,t.isInline?-1:1))}}static findFrom(e,t,n=!1){let r=e.parent.inlineContent?new Wp(e):Xp(e.node(0),e.parent,e.pos,e.index(),t,n);if(r)return r;for(let r=e.depth-1;r>=0;r--){let i=t<0?Xp(e.node(0),e.node(r),e.before(r+1),e.index(r),t,n):Xp(e.node(0),e.node(r),e.after(r+1),e.index(r)+1,t,n);if(i)return i}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new Jp(e.node(0))}static atStart(e){return Xp(e,e,0,0,1)||new Jp(e)}static atEnd(e){return Xp(e,e,e.content.size,e.childCount,-1)||new Jp(e)}static fromJSON(e,t){if(!t||!t.type)throw RangeError(`Invalid input for Selection.fromJSON`);let n=zp[t.type];if(!n)throw RangeError(`No selection type ${t.type} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in zp)throw RangeError(`Duplicate use of selection JSON ID `+e);return zp[e]=t,t.prototype.jsonID=e,t}getBookmark(){return Wp.between(this.$anchor,this.$head).getBookmark()}};Bp.prototype.visible=!0;var Vp=class{constructor(e,t){this.$from=e,this.$to=t}},Hp=!1;function Up(e){!Hp&&!e.parent.inlineContent&&(Hp=!0,console.warn(`TextSelection endpoint not pointing into a node with inline content (`+e.parent.type.name+`)`))}var Wp=class e extends Bp{constructor(e,t=e){Up(e),Up(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(t,n){let r=t.resolve(n.map(this.head));if(!r.parent.inlineContent)return Bp.near(r);let i=t.resolve(n.map(this.anchor));return new e(i.parent.inlineContent?i:r,r)}replace(e,t=Q.empty){if(super.replace(e,t),t==Q.empty){let t=this.$from.marksAcross(this.$to);t&&e.ensureMarks(t)}}eq(t){return t instanceof e&&t.anchor==this.anchor&&t.head==this.head}getBookmark(){return new Gp(this.anchor,this.head)}toJSON(){return{type:`text`,anchor:this.anchor,head:this.head}}static fromJSON(t,n){if(typeof n.anchor!=`number`||typeof n.head!=`number`)throw RangeError(`Invalid input for TextSelection.fromJSON`);return new e(t.resolve(n.anchor),t.resolve(n.head))}static create(e,t,n=t){let r=e.resolve(t);return new this(r,n==t?r:e.resolve(n))}static between(t,n,r){let i=t.pos-n.pos;if((!r||i)&&(r=i>=0?1:-1),!n.parent.inlineContent){let e=Bp.findFrom(n,r,!0)||Bp.findFrom(n,-r,!0);if(e)n=e.$head;else return Bp.near(n,r)}return t.parent.inlineContent||(i==0?t=n:(t=(Bp.findFrom(t,-r,!0)||Bp.findFrom(t,r,!0)).$anchor,t.pos<n.pos!=i<0&&(t=n))),new e(t,n)}};Bp.jsonID(`text`,Wp);var Gp=class e{constructor(e,t){this.anchor=e,this.head=t}map(t){return new e(t.map(this.anchor),t.map(this.head))}resolve(e){return Wp.between(e.resolve(this.anchor),e.resolve(this.head))}},Kp=class e extends Bp{constructor(e){let t=e.nodeAfter,n=e.node(0).resolve(e.pos+t.nodeSize);super(e,n),this.node=t}map(t,n){let{deleted:r,pos:i}=n.mapResult(this.anchor),a=t.resolve(i);return r?Bp.near(a):new e(a)}content(){return new Q(Z.from(this.node),0,0)}eq(t){return t instanceof e&&t.anchor==this.anchor}toJSON(){return{type:`node`,anchor:this.anchor}}getBookmark(){return new qp(this.anchor)}static fromJSON(t,n){if(typeof n.anchor!=`number`)throw RangeError(`Invalid input for NodeSelection.fromJSON`);return new e(t.resolve(n.anchor))}static create(t,n){return new e(t.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}};Kp.prototype.visible=!1,Bp.jsonID(`node`,Kp);var qp=class e{constructor(e){this.anchor=e}map(t){let{deleted:n,pos:r}=t.mapResult(this.anchor);return n?new Gp(r,r):new e(r)}resolve(e){let t=e.resolve(this.anchor),n=t.nodeAfter;return n&&Kp.isSelectable(n)?new Kp(t):Bp.near(t)}},Jp=class e extends Bp{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=Q.empty){if(t==Q.empty){e.delete(0,e.doc.content.size);let t=Bp.atStart(e.doc);t.eq(e.selection)||e.setSelection(t)}else super.replace(e,t)}toJSON(){return{type:`all`}}static fromJSON(t){return new e(t)}map(t){return new e(t)}eq(t){return t instanceof e}getBookmark(){return Yp}};Bp.jsonID(`all`,Jp);var Yp={map(){return this},resolve(e){return new Jp(e)}};function Xp(e,t,n,r,i,a=!1){if(t.inlineContent)return Wp.create(e,n);for(let o=r-(i>0?0:1);i>0?o<t.childCount:o>=0;o+=i){let r=t.child(o);if(!r.isAtom){let t=Xp(e,r,n+i,i<0?r.childCount:0,i,a);if(t)return t}else if(!a&&Kp.isSelectable(r))return Kp.create(e,n-(i<0?r.nodeSize:0));n+=r.nodeSize*i}return null}function Zp(e,t,n){let r=e.steps.length-1;if(r<t)return;let i=e.steps[r];if(!(i instanceof Kf||i instanceof qf))return;let a=e.mapping.maps[r],o;a.forEach((e,t,n,r)=>{o??=r}),e.setSelection(Bp.near(e.doc.resolve(o),n))}var Qp=1,$p=2,em=4,tm=class extends Rp{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw RangeError(`Selection passed to setSelection must point at the current document`);return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|Qp)&-3,this.storedMarks=null,this}get selectionSet(){return(this.updated&Qp)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=$p,this}ensureMarks(e){return ld.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&$p)>0}addStep(e,t){super.addStep(e,t),this.updated&=-3,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let n=this.selection;return t&&(e=e.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||ld.none))),n.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,n){let r=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(r.text(e),!0):this.deleteSelection();{if(n??=t,!e)return this.deleteRange(t,n);let i=this.storedMarks;if(!i){let e=this.doc.resolve(t);i=n==t?e.marks():e.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(t,n,r.text(e,i)),!this.selection.empty&&this.selection.to==t+e.length&&this.setSelection(Bp.near(this.selection.$to)),this}}setMeta(e,t){return this.meta[typeof e==`string`?e:e.key]=t,this}getMeta(e){return this.meta[typeof e==`string`?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=em,this}get scrolledIntoView(){return(this.updated&em)>0}};function nm(e,t){return!t||!e?e:e.bind(t)}var rm=class{constructor(e,t,n){this.name=e,this.init=nm(t.init,n),this.apply=nm(t.apply,n)}},im=[new rm(`doc`,{init(e){return e.doc||e.schema.topNodeType.createAndFill()},apply(e){return e.doc}}),new rm(`selection`,{init(e,t){return e.selection||Bp.atStart(t.doc)},apply(e){return e.selection}}),new rm(`storedMarks`,{init(e){return e.storedMarks||null},apply(e,t,n,r){return r.selection.$cursor?e.storedMarks:null}}),new rm(`scrollToSelection`,{init(){return 0},apply(e,t){return e.scrolledIntoView?t+1:t}})],am=class{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=im.slice(),t&&t.forEach(e=>{if(this.pluginsByKey[e.key])throw RangeError(`Adding different instances of a keyed plugin (`+e.key+`)`);this.plugins.push(e),this.pluginsByKey[e.key]=e,e.spec.state&&this.fields.push(new rm(e.key,e.spec.state,e))})}},om=class e{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let n=0;n<this.config.plugins.length;n++)if(n!=t){let t=this.config.plugins[n];if(t.spec.filterTransaction&&!t.spec.filterTransaction.call(t,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],n=this.applyInner(e),r=null;for(;;){let i=!1;for(let a=0;a<this.config.plugins.length;a++){let o=this.config.plugins[a];if(o.spec.appendTransaction){let s=r?r[a].n:0,c=r?r[a].state:this,l=s<t.length&&o.spec.appendTransaction.call(o,s?t.slice(s):t,c,n);if(l&&n.filterTransaction(l,a)){if(l.setMeta(`appendedTransaction`,e),!r){r=[];for(let e=0;e<this.config.plugins.length;e++)r.push(e<a?{state:n,n:t.length}:{state:this,n:0})}t.push(l),n=n.applyInner(l),i=!0}r&&(r[a]={state:n,n:t.length})}}if(!i)return{state:n,transactions:t}}}applyInner(t){if(!t.before.eq(this.doc))throw RangeError(`Applying a mismatched transaction`);let n=new e(this.config),r=this.config.fields;for(let e=0;e<r.length;e++){let i=r[e];n[i.name]=i.apply(t,this[i.name],this,n)}return n}get tr(){return new tm(this)}static create(t){let n=new am(t.doc?t.doc.type.schema:t.schema,t.plugins),r=new e(n);for(let e=0;e<n.fields.length;e++)r[n.fields[e].name]=n.fields[e].init(t,r);return r}reconfigure(t){let n=new am(this.schema,t.plugins),r=n.fields,i=new e(n);for(let e=0;e<r.length;e++){let n=r[e].name;i[n]=this.hasOwnProperty(n)?this[n]:r[e].init(t,i)}return i}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(e=>e.toJSON())),e&&typeof e==`object`)for(let n in e){if(n==`doc`||n==`selection`)throw RangeError("The JSON fields `doc` and `selection` are reserved");let r=e[n],i=r.spec.state;i&&i.toJSON&&(t[n]=i.toJSON.call(r,this[r.key]))}return t}static fromJSON(t,n,r){if(!n)throw RangeError(`Invalid input for EditorState.fromJSON`);if(!t.schema)throw RangeError(`Required config field 'schema' missing`);let i=new am(t.schema,t.plugins),a=new e(i);return i.fields.forEach(e=>{if(e.name==`doc`)a.doc=kd.fromJSON(t.schema,n.doc);else if(e.name==`selection`)a.selection=Bp.fromJSON(a.doc,n.selection);else if(e.name==`storedMarks`)n.storedMarks&&(a.storedMarks=n.storedMarks.map(t.schema.markFromJSON));else{if(r)for(let i in r){let o=r[i],s=o.spec.state;if(o.key==e.name&&s&&s.fromJSON&&Object.prototype.hasOwnProperty.call(n,i)){a[e.name]=s.fromJSON.call(o,t,n[i],a);return}}a[e.name]=e.init(t,a)}}),a}};function sm(e,t,n){for(let r in e){let i=e[r];i instanceof Function?i=i.bind(t):r==`handleDOMEvents`&&(i=sm(i,t,{})),n[r]=i}return n}var cm=class{constructor(e){this.spec=e,this.props={},e.props&&sm(e.props,this,this.props),this.key=e.key?e.key.key:um(`plugin`)}getState(e){return e[this.key]}},lm=Object.create(null);function um(e){return e in lm?e+`$`+ ++lm[e]:(lm[e]=0,e+`$`)}var dm=class{constructor(e=`key`){this.key=um(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}},fm=[{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`}],pm=500,mm=1e4,hm=500,gm=250,_m=16,vm=8,ym=12,bm=1,xm=9e3;function Sm(e,t){if(t===0)return!0;let n=e[t-1],r=e[t];return!!(!/[a-zA-Z0-9]/.test(n)||/[a-z]/.test(n)&&/[A-Z]/.test(r))}function Cm(e,t){if(!e)return null;let n=t.toLowerCase(),r=n.length===t.length,i=e.toLowerCase(),a=n.indexOf(i);if(a!==-1){let e=mm-Math.min(a,pm-1);a===0?e+=hm:Sm(t,a)&&(e+=gm);let n=[];for(let e=0;e<i.length;e++)n.push(a+e);return{score:e,indices:r?n:[]}}let o=t.length>pm?t.slice(0,pm):t,s=o.toLowerCase(),c=[],l=0,u=0,d=-1;for(let e=0;e<i.length;e++){let t=i[e],n;if(n=u<s.length&&s[u]===t?u:s.indexOf(t,u),n===-1)return null;d!==-1&&(n===d+1?l+=_m:l-=(n-d-1)*bm),Sm(o,n)&&(l+=vm),e===0&&n===0&&(l+=ym),c.push(n),d=n,u=n+1}return{score:Math.min(l,xm),indices:r?c:[]}}function wm(e,t,...n){let r=Cm(e,t),i=[];r&&i.push(r.score);for(let t of n){if(!t)continue;let n=Cm(e,t);n&&i.push(n.score*.75)}return i.length===0?null:{score:Math.max(...i),indices:r?r.indices:[]}}function Tm(e,t){if(e.length===0)return[];let n=new Set(t),r=[],i=0;for(;i<e.length;){let t=n.has(i),a=i;for(;i<e.length&&n.has(i)===t;)i++;r.push({text:e.slice(a,i),match:t})}return r}function Em(e){let t=[];return e.state.doc.descendants((e,n)=>{e.type.name===`heading`&&e.attrs.level<=3&&t.push({text:e.textContent,level:e.attrs.level,pos:n})}),t}var Dm=(e,t=m,n=m)=>{var r=Yr(),i=I(r),a=e=>{var r=Yr();fi(I(r),17,()=>Tm(t(),n()),ci,(e,t)=>{var n=Yr(),r=I(n),i=e=>{var n=Om(),r=F(n,!0);O(n),z(()=>W(r,B(t).text)),U(e,n)},a=e=>{var n=Jr();z(()=>W(n,B(t).text)),U(e,n)};G(r,e=>{B(t).match?e(i):e(a,-1)}),U(e,n)}),U(e,r)},o=e=>{var n=Jr();z(()=>W(n,t())),U(e,n)};G(i,e=>{n()?e(a):e(o,-1)}),U(e,r)},Om=H(`<span class="palette-match svelte-gunx66"> </span>`),km=H(`<div style="font-size: var(--tandem-text-xs); color: var(--tandem-fg-subtle); margin-top: var(--tandem-space-1);"><!> <!> <!> <!></div>`),Am=H(`<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>`),jm=H(`<span style="font-size: var(--tandem-text-xs); color: var(--tandem-fg-faint); font-family: var(--tandem-font-mono);"> </span>`),Mm=H(`<span style="font-size: var(--tandem-text-sm);"><!></span> <!>`,1),Nm=H(`<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>`),Pm=H(`<span style="font-size: var(--tandem-text-xs); color: var(--tandem-fg-subtle); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;"> </span>`),Fm=H(`<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),Im=H(`<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),Lm=H(`<li role="option"><!></li>`),Rm=H(`<div role="presentation" class="palette-scrim svelte-gunx66" style="
16
+ position: fixed; inset: 0;
17
+ background: rgba(0,0,0,0.4);
18
+ backdrop-filter: blur(2px);
19
+ z-index: var(--tandem-z-above-titlebar);
20
+ display: flex; align-items: flex-start; justify-content: center;
21
+ padding-top: 15vh;
22
+ "><div data-testid="command-palette" role="dialog" tabindex="-1" aria-modal="true" aria-label="Command palette" class="palette-modal svelte-gunx66" style="
23
+ width: 640px; max-width: 92vw;
24
+ background: var(--tandem-surface);
25
+ border: 1px solid var(--tandem-border);
26
+ border-radius: var(--tandem-r-5);
27
+ box-shadow: var(--tandem-shadow-4);
28
+ overflow: hidden;
29
+ display: flex; flex-direction: column;
30
+ "><div style="padding: var(--tandem-space-3) var(--tandem-space-4); border-bottom: 1px solid var(--tandem-border);"><div style="display: flex; align-items: center; gap: var(--tandem-space-2);"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="var(--tandem-fg-faint)" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" style="flex-shrink: 0;"><circle cx="11" cy="11" r="7"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line></svg> <input data-testid="palette-input" type="text" aria-label="Search commands" aria-controls="palette-results" style="
31
+ flex: 1; min-width: 0; padding: 6px 0;
32
+ font-size: var(--tandem-text-md); color: var(--tandem-fg);
33
+ background: transparent; border: none; outline: none;
34
+ "/> <span class="palette-kbd svelte-gunx66" aria-hidden="true">Esc</span></div> <!></div> <ul id="palette-results" role="listbox" aria-label="Results" class="tandem-scroll-fade-y" style="max-height: 400px; overflow-y: auto; padding: var(--tandem-space-1); list-style: none; margin: 0;"><!></ul> <div style="
35
+ padding: var(--tandem-space-2) var(--tandem-space-4);
36
+ border-top: 1px solid var(--tandem-border);
37
+ background: var(--tandem-surface-muted);
38
+ display: flex; align-items: center; gap: var(--tandem-space-3);
39
+ font-size: var(--tandem-text-xs); color: var(--tandem-fg-subtle);
40
+ "><span><kbd class="palette-kbd svelte-gunx66">#</kbd> headings</span> <span><kbd class="palette-kbd svelte-gunx66">@</kbd> annotations</span> <span><kbd class="palette-kbd svelte-gunx66">?</kbd> shortcuts</span> <span><kbd class="palette-kbd svelte-gunx66">&gt;</kbd> commands</span></div></div></div>`);function zm(e,t){A(t,!0);let n=J(t,`editor`,3,null),r=J(t,`annotations`,19,()=>[]),i=N(``),a=N(0),o=N(null),s=[`#`,`@`,`?`,`>`],c=M(()=>s.find(e=>B(i).startsWith(e))??null),l=M(()=>(B(c)?B(i).slice(1):B(i)).trim().toLowerCase());function u(e){return e.sort((e,t)=>t.score-e.score||e.origIndex-t.origIndex),e.map(e=>e.result)}let d=M(()=>{if(B(c)!==null&&B(c)!==`>`)return[];let e=su(),t=B(l);if(!t)return Array.from(e.values(),e=>({kind:`action`,id:e.id,action:e}));let n=[],r=0;for(let i of e.values()){let e=wm(t,i.label,i.group,i.shortcut);e&&n.push({result:{kind:`action`,id:i.id,action:i,matchIndices:e.indices},score:e.score,origIndex:r}),r++}return u(n)}),f=M(()=>{if(B(c)!==`#`)return[];let e=n();if(!e||e.isDestroyed)return[];let t=B(l),r=Em(e);if(!t)return r.map((e,t)=>({kind:`heading`,id:`heading-${t}`,...e}));let i=[];return r.forEach((e,n)=>{let r=wm(t,e.text);r&&i.push({result:{kind:`heading`,id:`heading-${n}`,...e,matchIndices:r.indices},score:r.score,origIndex:n})}),u(i)}),p=M(()=>{if(B(c)!==`@`)return[];let e=B(l),t=e=>({kind:`annotation`,id:`annotation-${e.id}`,label:e.content?e.content.slice(0,60):`(no content)`,snippet:e.textSnapshot??``,annotationType:e.type});if(!e)return r().slice(0,50).map(t);let n=[];return r().forEach((r,i)=>{let a=wm(e,r.content,r.textSnapshot);a&&n.push({result:t(r),score:a.score,origIndex:i})}),u(n).slice(0,50)}),m=M(()=>{if(B(c)!==`?`)return[];let e=B(l),t=su(),n=[];for(let e of t.values())e.shortcut&&n.push({id:`shortcut-registry-${e.id}`,keys:e.shortcut,description:e.label,group:e.group});for(let e=0;e<fm.length;e++){let t=fm[e];n.push({id:`shortcut-static-${e}`,keys:t.keys,description:t.description,group:`other`})}let r=e=>({kind:`shortcut`,id:e.id,keys:e.keys,description:e.description,group:e.group});if(!e)return n.map(r);let i=[];return n.forEach((t,n)=>{let a=wm(e,t.description,t.keys);a&&i.push({result:r(t),score:a.score,origIndex:n})}),u(i)}),h=M(()=>[...B(d),...B(f),...B(p),...B(m)]);R(()=>{B(h),P(a,0)}),R(()=>{t.open&&(P(i,``),P(a,0),Promise.resolve().then(()=>B(o)?.focus()))}),ga(()=>{let e=e=>{e.key!==`Escape`||!t.open||(e.preventDefault(),e.stopPropagation(),v())};return window.addEventListener(`keydown`,e,{capture:!0}),()=>window.removeEventListener(`keydown`,e,{capture:!0})});let g={"#":`Search headings…`,"@":`Search annotations…`,"?":`Search shortcuts…`,">":`Search commands…`},_=M(()=>B(c)?g[B(c)]:`Type a command, # headings, @ annotations, ? shortcuts…`);function v(){t.onClose()}function y(e){if(e.kind===`action`)v(),e.action.run();else if(e.kind===`heading`){v();let t=n();if(!t||t.isDestroyed)return;let r=e.pos;try{let e=t.state.doc.resolve(r+1),n=Wp.near(e);t.view.dispatch(t.state.tr.setSelection(n).scrollIntoView()),t.view.focus()}catch{}}else e.kind===`annotation`&&(v(),t.onFocusAnnotation?.(e.id.replace(`annotation-`,``)))}function b(e){let t=B(h).length;if(e.key===`ArrowDown`)e.preventDefault(),P(a,(B(a)+1)%Math.max(1,t));else if(e.key===`ArrowUp`)e.preventDefault(),P(a,(B(a)-1+Math.max(1,t))%Math.max(1,t));else if(e.key===`Enter`){e.preventDefault();let t=B(h)[B(a)];t&&y(t)}else e.key===`Escape`&&(e.preventDefault(),v())}function x(e){e.target===e.currentTarget&&v()}var S=Yr(),C=I(S),w=e=>{var t=Rm(),n=F(t),r=F(n),s=F(r),l=L(F(s),2);Qi(l),da(l,e=>P(o,e),()=>B(o)),k(2),O(s);var u=L(s,2),d=e=>{var t=km(),n=F(t),r=e=>{U(e,Jr(`Searching document headings`))};G(n,e=>{B(c)===`#`&&e(r)});var i=L(n,2),a=e=>{U(e,Jr(`Searching annotations`))};G(i,e=>{B(c)===`@`&&e(a)});var o=L(i,2),s=e=>{U(e,Jr(`Showing keyboard shortcuts`))};G(o,e=>{B(c)===`?`&&e(s)});var l=L(o,2),u=e=>{U(e,Jr(`Filtering commands`))};G(l,e=>{B(c)===`>`&&e(u)}),O(t),U(e,t)};G(u,e=>{B(c)&&e(d)}),O(r);var f=L(r,2),p=F(f),m=e=>{var t=Am(),n=F(t,!0);O(t),z(()=>W(n,B(c)===`#`?`No headings found`:B(c)===`@`?`No annotations found`:B(c)===`?`?`No shortcuts found`:`No commands match`)),U(e,t)},g=e=>{var t=Yr();fi(I(t),19,()=>B(h),e=>e.id,(e,t,n)=>{let r=M(()=>B(n)===B(a));var i=Lm(),o=F(i),s=e=>{var n=Mm(),r=I(n);Dm(F(r),()=>B(t).action.label,()=>B(t).matchIndices),O(r);var i=L(r,2),a=e=>{var n=jm(),r=F(n,!0);O(n),z(()=>W(r,B(t).action.shortcut)),U(e,n)};G(i,e=>{B(t).action.shortcut&&e(a)}),U(e,n)},c=e=>{var n=Nm(),r=F(n),i=F(r);O(r);var a=L(r,2);Dm(F(a),()=>B(t).text,()=>B(t).matchIndices),O(a),O(n),z(()=>{W(i,`H${B(t).level??``}`),K(a,`font-size: var(--tandem-text-sm); padding-left: calc(${B(t).level-1} * var(--tandem-space-2));`)}),U(e,n)},l=e=>{var n=Fm(),r=I(n),i=F(r),a=F(i,!0);O(i);var o=L(i,2),s=e=>{var n=Pm(),r=F(n);O(n),z(()=>W(r,`"${B(t).snippet??``}"`)),U(e,n)};G(o,e=>{B(t).snippet&&e(s)}),O(r);var c=L(r,2),l=F(c,!0);O(c),z(e=>{W(a,B(t).label),W(l,e)},[()=>B(t).annotationType.charAt(0).toUpperCase()+B(t).annotationType.slice(1)]),U(e,n)},u=e=>{var n=Im(),r=I(n),i=F(r,!0);O(r);var a=L(r,2),o=F(a,!0);O(a),z(()=>{W(i,B(t).description),W(o,B(t).keys)}),U(e,n)};G(o,e=>{B(t).kind===`action`?e(s):B(t).kind===`heading`?e(c,1):B(t).kind===`annotation`?e(l,2):B(t).kind===`shortcut`&&e(u,3)}),O(i),z(()=>{q(i,`id`,`palette-item-${B(t).id}`),q(i,`data-testid`,`palette-item-${B(t).id}`),q(i,`aria-selected`,B(r)),K(i,`
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: ${B(t).kind===`shortcut`?`default`:`pointer`};
46
+ background: ${B(r)?`var(--tandem-accent-bg)`:`transparent`};
47
+ color: ${B(r)?`var(--tandem-accent-fg-strong)`:`var(--tandem-fg)`};
48
+ `)}),V(`click`,i,()=>y(B(t))),Rr(`mouseenter`,i,()=>P(a,B(n),!0)),U(e,i)}),U(e,t)};G(p,e=>{B(h).length===0?e(m):e(g,-1)}),O(f),Ni(f,(e,t)=>Vu?.(e,t),()=>`y`),k(2),O(n),O(t),z(()=>{q(l,`placeholder`,B(_)),q(l,`aria-activedescendant`,B(h)[B(a)]?`palette-item-${B(h)[B(a)].id}`:void 0)}),V(`click`,t,x),V(`keydown`,t,e=>{e.key===`Escape`&&v()}),V(`keydown`,n,b),ia(l,()=>B(i),e=>P(i,e)),U(e,t)};G(C,e=>{t.open&&e(w)}),U(e,S),j()}zr([`click`,`keydown`]);var Bm=H(`<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">We've lost the connection to the Tandem server. Please check that it's still 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 Vm(e,t){var n=Bm(),r=L(F(n),4),i=L(r,2);O(n),V(`click`,r,function(...e){t.onRetry?.apply(this,e)}),V(`click`,i,function(...e){t.onDismiss?.apply(this,e)}),U(e,n)}zr([`click`]);function Hm(e){return e?e.osSupported?e.coworkDetected?`normal`:`undetected`:`unsupported`:`loading`}function Um(e){return e.claudeDesktopDetected??!1?(e.workspacesBlocked??0)>0?`blocked`:`noWorkspacesYet`:`noClaude`}function Wm(e){switch(e.kind){case`adminDeclined`:return`Tandem couldn't update Windows Firewall — that needs administrator rights, and Tandem doesn't run as admin. Nothing was changed, and your documents stay on this computer (the server is only reachable locally).`;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 ${e.exitCode}). Details: ${Gm(e.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 (${e.kind}). Please restart Tandem.`}}function Gm(e){let t=e.trim();return t.length===0?`(no output)`:t.length<=200?t:`${t.slice(0,197)}...`}function Km(e){try{let t=JSON.parse(e);if(typeof t==`object`&&t&&`kind`in t&&typeof t.kind==`string`)try{return Wm(t)}catch(n){return console.error(`[cowork] firewallErrorHint failed for:`,t,n),e}return e}catch{return e}}function qm(e){switch(e){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`;case`notConfigured`:return`Not configured`}}function Jm(e){switch(e){case`ok`:case`alreadyPresent`:return`success`;case`locked`:return`warning`;case`schemaDrift`:case`insecureAcl`:case`failed`:return`error`;case`notConfigured`:return`neutral`}}function Ym(e){let t=[`failed`,`schemaDrift`,`insecureAcl`,`locked`,`notConfigured`,`alreadyPresent`,`ok`],n=[e.installedPlugins,e.knownMarketplaces,e.coworkSettings];for(let e of t)if(n.includes(e))return e;return`ok`}function Xm(e){let t=e=>e===`ok`||e===`alreadyPresent`;return t(e.installedPlugins)&&t(e.knownMarketplaces)&&t(e.coworkSettings)}function Zm(e){if(!e||!e.enabled)return`not-applicable`;let t=e.workspaces??[];return t.some(Xm)?`reachable`:t.some(e=>Jm(Ym(e))===`error`)?`unreachable`:`pending`}function Qm(e){switch(e){case`reachable`:return{title:`Tandem is reachable from Cowork`,detail:`At least one Cowork workspace has the Tandem plugin installed — a Cowork session can find and load it.`,family:`success`};case`unreachable`:return{title:`Tandem isn't reachable yet`,detail:`Cowork is enabled, but a workspace install didn't complete. Re-scan workspaces, or restart Claude Desktop and re-enable.`,family:`error`};case`pending`:return{title:`Waiting for a Cowork session`,detail:`Cowork is enabled. The Tandem plugin installs into a workspace the first time you open a Cowork session.`,family:`warning`};case`not-applicable`:return{title:``,detail:``,family:`neutral`}}}function $m(e,t){return!(!e||t||!e.osSupported||!e.coworkDetected||e.enabled)}function eh(){try{return localStorage.getItem(uo)===`true`}catch{return!1}}function th(){try{localStorage.setItem(uo,`true`)}catch{}}function nh(){try{return typeof window<`u`&&`__TAURI_INTERNALS__`in window}catch{return!1}}function rh(e){let t=null;return{schedule(n){t!==null&&clearTimeout(t),t=setTimeout(()=>{t=null,n()},e)},cancel(){t!==null&&(clearTimeout(t),t=null)}}}var ih=`Tauri runtime not available`;async function ah(){try{return(await Ul(()=>import(`./core-SwWLTXZB.js`),[])).invoke}catch(e){return nh()&&console.error(`[cowork] Failed to load @tauri-apps/api/core:`,e),(()=>Promise.reject(Error(ih)))}}function oh(e){return e(`cowork_get_status`)}function sh(e,t){return e(`cowork_toggle_integration`,{enabled:t})}function ch(e){return e(`cowork_rescan`)}function lh(e,t){return e(`cowork_set_lan_ip_override`,{enabled:t})}function uh(e){return e(`cowork_retry_admin_elevation`)}var dh=N(!1),fh=null;function ph(){return B(dh)}function mh(){P(dh,!0)}function hh(e){e!==fh&&(fh=e,e!==null&&P(dh,!1))}function gh(e){let t=N(null),n=N(!1),r=N(null),i=null,a=!1,o=!0,s=null;_a(()=>{o=!1,s!==null&&(clearInterval(s),s=null)});let c=async()=>{if(a){o&&P(n,!1);return}let e=i;if(e)try{let n=await oh(e);if(!o)return;P(t,n,!0),P(r,null)}catch(e){if(!o)return;let t=e instanceof Error?e.message:String(e);if(t===`Tauri runtime not available`){a=!0,s!==null&&(clearInterval(s),s=null),P(n,!1);return}P(r,t,!0)}finally{o&&P(n,!1)}};return R(()=>{if(!e()){P(n,!1);return}let t=!1;return ah().then(e=>{if(!t)return i=e,P(n,!0),c()}).catch(e=>{t||(P(r,e instanceof Error?e.message:String(e),!0),P(n,!1))}),s=setInterval(()=>{t||a||c()},fo),()=>{t=!0,s!==null&&(clearInterval(s),s=null)}}),{get status(){return B(t)},get loading(){return B(n)},get error(){return B(r)},refetch:c}}var _h=H(`<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>`),vh=H(`<div class="cad-error svelte-cbdwov" data-testid="cowork-admin-declined-error" role="alert"> </div>`),yh=H(`<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">Cowork will be turned off. Any firewall rule a past admin run added is left in
50
+ place (it's harmless — the server only listens on this computer). You can
51
+ 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>`),bh=H(`<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>`),xh=H(`<div class="cad-backdrop svelte-cbdwov" data-testid="cowork-admin-declined-backdrop" role="button" tabindex="-1" aria-label="Dismiss admin permission notice"><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 needs Windows admin permission to add the firewall rule that lets
52
+ Claude inside the Cowork VM reach Tandem. Without it, that rule wasn't added, so Cowork
53
+ can't connect. Nothing was exposed — Tandem's server only listens on this computer
54
+ (127.0.0.1). You can dismiss this for now, or turn Cowork off below.</div> <a class="cad-link svelte-cbdwov" data-testid="cowork-admin-declined-learn-more-link" target="_blank" rel="noreferrer">Learn more</a> <!> <!></div></div>`);function Sh(e,t){A(t,!0);let n=gh(()=>!0),r=M(()=>n.status?.uacDeclined===!0),i=M(()=>B(r)&&!ph()),a=N(void 0),o=N(!1),s=N(!1),c=N(null);R(()=>{hh(n.status?.uacDeclinedAt??null)}),R(()=>{if(!B(i))return;let e=typeof document<`u`?document.title:null;return typeof document<`u`&&!document.title.startsWith(`⚠`)&&(document.title=`⚠ ${document.title}`),()=>{typeof document<`u`&&e!==null&&(document.title=e)}}),R(()=>{if(!B(i))return;let e=e=>{if(e.key===`Escape`){if(B(s))return;mh();return}if(e.key!==`Tab`||!B(a))return;let t=B(a).querySelectorAll(`button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])`);if(t.length===0)return;let n=t[0],r=t[t.length-1],i=document.activeElement;if(!B(a).contains(i)){e.preventDefault(),n.focus();return}e.shiftKey&&i===n?(e.preventDefault(),r.focus()):!e.shiftKey&&i===r&&(e.preventDefault(),n.focus())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)}),R(()=>{B(i)&&B(a)?.focus()});async function l(e,t){P(s,!0),P(c,null);try{await e(await ah())}catch(e){P(c,`${t}: ${Km(e instanceof Error?e.message:String(e))}`)}finally{P(s,!1)}}async function u(){await l(async e=>{await uh(e),await n.refetch()},`Retry failed`)}async function d(){await l(async e=>{await sh(e,!1),await n.refetch()},`Failed to disable Cowork`),B(c)||P(o,!1)}var f=Yr(),p=I(f),m=e=>{U(e,_h())},h=e=>{var t=xh(),n=F(t);q(n,`tabindex`,-1);var r=L(F(n),4),i=L(r,2),l=e=>{var t=vh(),n=F(t,!0);O(t),z(()=>W(n,B(c))),U(e,t)};G(i,e=>{B(c)&&e(l)});var f=L(i,2),p=e=>{var t=yh(),n=L(F(t),4),r=F(n),i=L(r,2);O(n),O(t),z(()=>{r.disabled=B(s),i.disabled=B(s)}),V(`click`,r,()=>void d()),V(`click`,i,()=>{P(o,!1)}),U(e,t)},m=e=>{var t=bh(),n=F(t),r=L(n,2);O(t),z(()=>{n.disabled=B(s),r.disabled=B(s)}),V(`click`,n,()=>{P(o,!0)}),V(`click`,r,()=>void u()),U(e,t)};G(f,e=>{B(o)?e(p):e(m,-1)}),O(n),da(n,e=>P(a,e),()=>B(a)),O(t),z(()=>q(r,`href`,`${xa}#cowork`)),V(`click`,t,e=>{!B(s)&&e.target===e.currentTarget&&mh()}),V(`keydown`,t,e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),B(s)||mh())}),U(e,t)};G(p,e=>{n.error&&!n.status?e(m):B(i)&&e(h,1)}),U(e,f),j()}zr([`click`,`keydown`]);var Ch=H(`<span style="color: var(--tandem-error-fg-strong); font-size: var(--tandem-text-xs); max-width: 200px;"> </span>`),wh=H(`<div class="tandem-banner tandem-banner--warning" role="status" aria-live="polite" data-testid="docx-conflict-banner"><span class="tandem-banner__message"> </span> <!> <button type="button" class="tandem-banner__cta" data-testid="docx-conflict-keep-btn"> </button> <button type="button" class="tandem-banner__cta" data-testid="docx-conflict-reload-btn"> </button></div>`);function Th(e,t){A(t,!0);let n=N(null),r=N(null),i=N(null);R(()=>{let e=t.ydoc.getMap(Ua),a=()=>{P(n,e.get(`externalConflict`)??null,!0)};a();let o=e=>{e.keysChanged.has(`externalConflict`)&&a()};return e.observe(o),()=>{e.unobserve(o),P(n,null),P(i,null),P(r,null)}});let a=M(()=>B(n)?B(n).kind===`external-edit`?`${t.fileName} changed on disk while you have unsaved edits. Keeping your edits means your next save overwrites the disk changes; reloading discards your unsaved edits.`:B(n).diskChanged?`Unsaved edits for ${t.fileName} were restored from your last session, but the file also changed on disk. Keep your restored edits, or reload the file from disk (discards them)?`:`Unsaved edits for ${t.fileName} were restored from your last session. Keep them, or reload fresh from the file on disk (discards them)?`:``);async function o(e){if(!B(r)){P(r,e,!0),P(i,null);try{let n=await fetch(`${Il}${kc}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({documentId:t.documentId,choice:e})});n.ok||P(i,(await n.json().catch(()=>null))?.message??`Request failed (HTTP ${n.status}).`,!0)}catch{P(i,`Could not reach the server.`)}finally{P(r,null)}}}var s=Yr(),c=I(s),l=e=>{var t=wh(),n=F(t),s=F(n,!0);O(n);var c=L(n,2),l=e=>{var t=Ch(),n=F(t,!0);O(t),z(()=>W(n,B(i))),U(e,t)};G(c,e=>{B(i)&&e(l)});var u=L(c,2),d=F(u,!0);O(u);var f=L(u,2),p=F(f,!0);O(f),O(t),z(()=>{W(s,B(a)),u.disabled=B(r)!==null,W(d,B(r)===`keep`?`Keeping…`:`Keep my edits`),f.disabled=B(r)!==null,W(p,B(r)===`reload`?`Reloading…`:`Reload from file`)}),V(`click`,u,()=>o(`keep`)),V(`click`,f,()=>o(`reload`)),U(e,t)};G(c,e=>{B(n)&&e(l)}),U(e,s),j()}zr([`click`]);var Eh=H(`<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),Dh=H(`<p class="empty-sub empty-sub-secondary svelte-16uow3k">No AI is connected yet.</p> <div class="empty-actions svelte-16uow3k"><button class="empty-cta svelte-16uow3k" data-testid="empty-state-connect-ai" data-ai-chip="connect">Connect AI</button></div>`,1),Oh=H(`<p class="empty-sub empty-sub-secondary svelte-16uow3k">Claude Code has stopped.</p> <div class="empty-actions svelte-16uow3k"><button class="empty-cta svelte-16uow3k" data-testid="empty-state-connect-ai" data-ai-chip="restart">Restart Claude Code</button></div>`,1),kh=H(`<p class="empty-sub empty-sub-secondary svelte-16uow3k">Tandem works alongside Claude (the default integration) or any MCP-capable AI client.</p>`),Ah=H(`<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),jh=H(`<div class="empty-state svelte-16uow3k"><!></div>`);function Mh(e,t){A(t,!0);let n=J(t,`aiChip`,3,null),r=N(!1);R(()=>{if(t.connected){P(r,!1);return}let e=setTimeout(()=>{P(r,!0)},Ta);return()=>clearTimeout(e)});var i=jh(),a=F(i),o=e=>{var n=Eh(),r=L(I(n),6),i=F(r),a=L(i,2);O(r),V(`click`,i,function(...e){t.onRetry?.apply(this,e)}),V(`click`,a,function(...e){t.onOpenSettings?.apply(this,e)}),U(e,n)},s=e=>{var r=Ah(),i=L(I(r),6),a=F(i);O(i);var o=L(i,2),s=e=>{var n=Dh(),r=L(I(n),2),i=F(r);O(r),V(`click`,i,function(...e){t.onConnectAi?.apply(this,e)}),U(e,n)},c=e=>{var n=Oh(),r=L(I(n),2),i=F(r);O(r),V(`click`,i,function(...e){t.onRestartClaude?.apply(this,e)}),U(e,n)},l=e=>{U(e,kh())};G(o,e=>{t.connected&&n()===`connect`?e(s):t.connected&&n()===`restart`?e(c,1):t.connected&&e(l,2)}),V(`click`,a,function(...e){t.onOpenFile?.apply(this,e)}),U(e,r)};G(a,e=>{B(r)?e(o):e(s,-1)}),O(i),U(e,i),j()}zr([`click`]);var Nh=H(`<li> </li>`),Ph=H(`<section data-testid="fidelity-report-integrity-warnings"><h4 class="svelte-coexzc">This save may not have preserved everything</h4> <ul class="svelte-coexzc"></ul> <p class="fidelity-report-restore-hint svelte-coexzc">To recover, run "Restore a backup of this document…" from the command palette.</p></section>`),Fh=H(`<li> </li>`),Ih=H(`<section data-testid="fidelity-report-import-losses"><h4 class="svelte-coexzc">Not imported — lost if you save over the original</h4> <ul class="svelte-coexzc"></ul></section>`),Lh=H(`<li> </li>`),Rh=H(`<section data-testid="fidelity-report-export-downgrades"><h4 class="svelte-coexzc">Simplified on the last save</h4> <ul class="svelte-coexzc"></ul></section>`),zh=H(`<div data-testid="fidelity-report-details"><!> <!> <!></div>`),Bh=H(`<div data-testid="fidelity-report-banner"><span class="tandem-banner__message"><!></span> <button type="button" class="tandem-banner__cta" data-testid="fidelity-report-details-toggle"> </button></div> <!>`,1);function Vh(e,t){A(t,!0);let n=N(null),r=N(!1);R(()=>{let e=t.ydoc.getMap(Ua),i=()=>{let t=e.get(eo);P(n,t?{importLosses:Array.isArray(t.importLosses)?t.importLosses:[],exportDowngrades:Array.isArray(t.exportDowngrades)?t.exportDowngrades:[],integrityWarnings:Array.isArray(t.integrityWarnings)?t.integrityWarnings:[],updatedAt:typeof t.updatedAt==`number`?t.updatedAt:0}:null,!0)};i();let a=e=>{e.keysChanged.has(`fidelityReport`)&&i()};return e.observe(a),()=>{e.unobserve(a),P(n,null),P(r,!1)}});let i=M(()=>B(n)?.integrityWarnings??[]),a=M(()=>B(i).length>0),o=M(()=>!!B(n)&&(B(n).importLosses.length>0||B(n).exportDowngrades.length>0||B(a)));var s=Yr(),c=I(s),l=e=>{var o=Bh(),s=I(o),c=F(s),l=F(c),u=e=>{var n=Jr();z(()=>W(n,`This save of ${t.fileName??``} may have changed more than expected — your original is backed up and
55
+ can be restored.`)),U(e,n)},d=e=>{var n=Jr();z(()=>W(n,`Some Word features in ${t.fileName??``} aren't fully supported. Tandem imported the text and
56
+ structure, but the items below won't survive a save back to .docx.`)),U(e,n)};G(l,e=>{B(a)?e(u):e(d,-1)}),O(c);var f=L(c,2),p=F(f,!0);O(f),O(s);var m=L(s,2),h=e=>{var t=zh(),r=F(t),o=e=>{var t=Ph(),n=L(F(t),2);fi(n,21,()=>B(i),ci,(e,t)=>{var n=Nh(),r=F(n,!0);O(n),z(()=>W(r,B(t))),U(e,n)}),O(n),k(2),O(t),U(e,t)};G(r,e=>{B(a)&&e(o)});var s=L(r,2),c=e=>{var t=Ih(),r=L(F(t),2);fi(r,21,()=>B(n).importLosses,ci,(e,t)=>{var n=Fh(),r=F(n,!0);O(n),z(()=>W(r,B(t))),U(e,n)}),O(r),O(t),U(e,t)};G(s,e=>{B(n).importLosses.length>0&&e(c)});var l=L(s,2),u=e=>{var t=Rh(),r=L(F(t),2);fi(r,21,()=>B(n).exportDowngrades,ci,(e,t)=>{var n=Lh(),r=F(n,!0);O(n),z(()=>W(r,B(t))),U(e,n)}),O(r),O(t),U(e,t)};G(l,e=>{B(n).exportDowngrades.length>0&&e(u)}),O(t),z(()=>Hi(t,1,`fidelity-report-details ${B(a)?`fidelity-report-details--warning`:``}`,`svelte-coexzc`)),U(e,t)};G(m,e=>{B(r)&&e(h)}),z(()=>{Hi(s,1,`tandem-banner ${B(a)?`tandem-banner--warning`:`tandem-banner--info`}`),q(s,`role`,B(a)?`alert`:`status`),q(s,`aria-live`,B(a)?`assertive`:`polite`),q(f,`aria-expanded`,B(r)),W(p,B(r)?`Hide details`:`Details`)}),V(`click`,f,()=>P(r,!B(r))),U(e,o)};G(c,e=>{B(o)&&B(n)&&e(l)}),U(e,s),j()}zr([`click`]);async function Hh(e,t={}){let{readOnly:n=!1,notFoundMessage:r=`File not found.`,failureMessage:i=`Failed to open file.`}=t;try{let t=await fetch(`${Il}${_c}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({filePath:e,readOnly:n})});if(!t.ok){let e=i;try{let n=await t.json();n.message&&(e=n.message)}catch{}return t.status===404&&(e=r),{ok:!1,error:e}}return{ok:!0}}catch(e){return console.warn(`[tandem] openServerPath failed:`,e),{ok:!1,error:`Server unavailable.`}}}var Uh=Array.from(Ca).sort().map(e=>e.replace(/^\./,``));async function Wh(){let{open:e}=await Ul(async()=>{let{open:e}=await import(`./dist-js-BWAGOggB.js`);return{open:e}},__vite__mapDeps([2,1])),t=await e({multiple:!1,directory:!1,title:`Open file in Tandem`,defaultPath:await ql()??void 0,filters:[{name:`Documents`,extensions:Uh}]});return typeof t==`string`?t:null}async function Gh(e={}){let t;try{t=await Wh()}catch(t){console.error(`[tandem] native file picker unavailable:`,t),e.onError?.(`File picker unavailable: ${t instanceof Error?t.message:t}`);return}if(!t)return;let n=await Hh(t);if(!n.ok){e.onError?.(n.error);return}Ql(Jl(Zl(),t))}async function Kh(e){e.isTauri?await Gh({onError:e.onError}):e.openModal()}async function qh(e,t){try{let n=await fetch(`${Il}${e}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)}),r=await n.json().catch(()=>({}));return n.ok?{ok:!0,data:r.data??{}}:{ok:!1,error:r.message??`Request failed.`}}catch(e){return console.warn(`[tandem] sessions request failed:`,e),{ok:!1,error:`Server unavailable.`}}}async function Jh(){try{let e=await fetch(`${Il}${Pc}`),t=await e.json().catch(()=>({}));return e.ok?{ok:!0,data:t.data?.sessions??[]}:{ok:!1,error:t.message??`Failed to load sessions.`}}catch(e){return console.warn(`[tandem] fetchSessions failed:`,e),{ok:!1,error:`Server unavailable.`}}}async function Yh(e){return qh(Fc,{filePath:e})}async function Xh(){return qh(Ic,{})}var Zh=H(`<input type="file" style="display: none;"/>`),Qh=H(`<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>`),$h=H(`<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>`),eg=H(`<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>`),tg=H(`<p data-testid="sessions-loading" style="margin: 8px 0 0; font-size: 12px; color: var(--tandem-fg-subtle);">Loading…</p>`),ng=H(`<p data-testid="sessions-empty" style="margin: 8px 0 0; font-size: 12px; color: var(--tandem-fg-subtle);">No saved sessions.</p>`),rg=H(`<div data-testid="session-row" style="display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-radius: var(--tandem-r-2);"><button type="button" data-testid="session-reopen" style="flex: 1; min-width: 0; background: none; border: none; padding: 0; cursor: pointer; text-align: left; display: flex; flex-direction: column; gap: 1px;"><span style="font-size: 13px; color: var(--tandem-fg);"> </span> <span style="font-size: 11px; color: var(--tandem-fg-subtle); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;"> </span> <span style="font-size: 11px; color: var(--tandem-fg-subtle);"> </span></button> <button type="button" data-testid="session-delete" style="background: none; border: none; color: var(--tandem-fg-subtle); font-size: 14px; cursor: pointer; padding: 4px; line-height: 1;">×</button></div>`),ig=H(`<div style="display: flex; justify-content: flex-end; margin: 6px 0;"><button data-testid="sessions-clear-all" type="button" style="background: none; border: none; color: var(--tandem-fg-subtle); font-size: 11px; cursor: pointer; padding: 0; text-decoration: underline;">Clear all</button></div> <div class="tandem-scroll-fade-y" style="max-height: 200px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px;"></div>`,1),ag=H(`<div data-testid="sessions-error" style="margin-top: 8px; padding: 8px 10px; font-size: 12px; color: var(--tandem-error-fg-strong); background: var(--tandem-error-bg); border-radius: var(--tandem-r-2); border: 1px solid var(--tandem-error-border);"> </div>`),og=H(`<!> <!>`,1),sg=H(`<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>`),cg=H(`<div role="dialog" aria-modal="true" aria-label="Open File" style="position: fixed; inset: 0; z-index: var(--tandem-z-above-titlebar); display: flex; align-items: flex-start; justify-content: center; padding-top: 80px; background: color-mix(in srgb, var(--tandem-bg) 70%, transparent);"><div style="background: var(--tandem-surface); border: 1px solid var(--tandem-border); border-radius: var(--tandem-r-5); box-shadow: var(--tandem-shadow-3); width: 440px; padding: 20px;" data-testid="file-open-dialog"><div style="display: flex; justify-content: space-between; margin-bottom: 16px;"><h3 style="margin: 0; font-size: 15px; font-weight: 600; color: var(--tandem-fg);">Open File</h3> <button class="modal-close svelte-ik1xhg" aria-label="Close">×</button></div> <button type="button" data-testid="file-open-browse"> </button> <!> <!> <!> <div data-testid="sessions-section" style="margin-top: 16px;"><button type="button" data-testid="sessions-toggle" style="width: 100%; background: none; border: none; padding: 0; cursor: pointer; display: flex; justify-content: space-between; align-items: center; color: var(--tandem-fg-subtle);"><span style="font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em;">Saved sessions</span> <span style="font-size: 11px;"> </span></button> <!></div> <!></div></div>`);function lg(e,t){A(t,!0);let n=N(null),r=N(!1),i=N(void 0),a=N(ln(Yl(Zl()))),o=N(ln([])),s=N(!1),c=N(!1),l=N(!1),u=N(null);async function d(){P(c,!0),P(u,null);let e=await Jh();e.ok?(P(o,e.data,!0),P(l,!0)):P(u,e.error,!0),P(c,!1)}function f(){P(s,!B(s)),B(s)&&!B(l)&&!B(c)&&d()}async function p(e){P(u,null);let t=await Yh(e);t.ok?P(o,B(o).filter(t=>t.filePath!==e),!0):P(u,t.error,!0)}async function m(){P(u,null);let e=await Xh();e.ok?P(o,[],!0):P(u,e.error,!0)}function h(e){if(!e)return`unknown`;let t=Date.now()-e,n=Math.floor(t/6e4);if(n<1)return`just now`;if(n<60)return`${n}m ago`;let r=Math.floor(n/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}let g=Array.from(Ca).sort().join(`,`);function _(e){let t=Jl(Zl(),e);Ql(t),P(a,Yl(t),!0)}function v(){$l(),P(a,[],!0)}async function y(e){if(!B(r)){P(n,null),P(r,!0);try{let r=await Hh(e);if(!r.ok){P(n,r.error,!0);return}_(e),t.onClose()}finally{P(r,!1)}}}async function b(){if(!B(r))try{let e=await Wh();e&&await y(e)}catch(e){P(n,`File picker unavailable: ${e instanceof Error?e.message:e}`)}}async function x(e){if(!B(r)){P(n,null),P(r,!0);try{let r=await zl(e),i=await fetch(`${Il}${xc}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({fileName:e.name,content:r})}),a=await i.json();if(!i.ok){P(n,a.message??`Failed to open file`,!0);return}t.onClose()}catch(e){console.error(`FileOpenDialog: upload failed`,e),e instanceof SyntaxError?P(n,`Server returned an unexpected response`):e instanceof TypeError?P(n,`Unexpected response format`):P(n,`Cannot reach server. Is it running?`)}finally{P(r,!1)}}}function S(e){let t=e.target.files?.[0];t&&x(t)}function C(){nh()?b():B(i)?.click()}var w=cg();q(w,`tabindex`,-1);var ee=F(w),T=F(ee),E=L(F(T),2);O(T);var te=L(T,2);wn(te,!0);var ne=F(te,!0);O(te);var D=L(te,2),re=e=>{var t=Zh();da(t,e=>P(i,e),()=>B(i)),z(()=>q(t,`accept`,g)),V(`change`,t,S),U(e,t)},ie=M(()=>!nh());G(D,e=>{B(ie)&&e(re)});var ae=L(D,2),oe=e=>{U(e,Qh())},se=M(()=>nh());G(ae,e=>{B(se)&&e(oe)});var ce=L(ae,2),le=e=>{var t=eg(),n=F(t),r=L(F(n),2);O(n);var i=L(n,2);fi(i,22,()=>B(a),e=>e,(e,t,n)=>{let r=M(()=>t.split(/[/\\]/)),i=M(()=>B(r).at(-1)??t),a=M(()=>B(r).slice(0,-1).join(`/`)||`/`);var o=$h(),s=F(o),c=F(s,!0);O(s);var l=L(s,2),u=F(l,!0);O(l),O(o),z(()=>{q(o,`data-testid`,`recent-file-${B(n)}`),W(c,B(i)),W(u,B(a))}),V(`click`,o,()=>y(t)),Rr(`mouseenter`,o,e=>{e.currentTarget.style.background=`var(--tandem-surface-muted)`}),Rr(`mouseleave`,o,e=>{e.currentTarget.style.background=`transparent`}),U(e,o)}),O(i),Ni(i,(e,t)=>Vu?.(e,t),()=>`y`),O(t),V(`click`,r,v),U(e,t)};G(ce,e=>{B(a).length>0&&e(le)});var ue=L(ce,2),de=F(ue),fe=L(F(de),2),pe=F(fe,!0);O(fe),O(de);var me=L(de,2),he=e=>{var t=og(),n=I(t),r=e=>{U(e,tg())},i=e=>{U(e,ng())},a=e=>{var t=ig(),n=I(t),r=F(n);O(n);var i=L(n,2);fi(i,21,()=>B(o),e=>e.filePath,(e,t)=>{let n=M(()=>B(t).filePath.split(/[/\\]/)),r=M(()=>B(n).at(-1)??B(t).filePath),i=M(()=>B(n).slice(0,-1).join(`/`)||`/`);var a=rg(),o=F(a),s=F(o),c=F(s,!0);O(s);var l=L(s,2),u=F(l,!0);O(l);var d=L(l,2),f=F(d);O(d),O(o);var m=L(o,2);O(a),z(e=>{q(o,`title`,B(t).filePath),W(c,B(r)),W(u,B(i)),W(f,`${e??``} · ${B(t).annotationCount??``} annotation${B(t).annotationCount===1?``:`s`}`),q(m,`aria-label`,`Delete session for ${B(r)}`)},[()=>h(B(t).lastAccessed)]),V(`click`,o,()=>y(B(t).filePath)),V(`click`,m,()=>p(B(t).filePath)),U(e,a)}),O(i),Ni(i,(e,t)=>Vu?.(e,t),()=>`y`),V(`click`,r,m),U(e,t)};G(n,e=>{B(c)?e(r):B(o).length===0?e(i,1):e(a,-1)});var s=L(n,2),l=e=>{var t=ag(),n=F(t,!0);O(t),z(()=>W(n,B(u))),U(e,t)};G(s,e=>{B(u)&&e(l)}),U(e,t)};G(me,e=>{B(s)&&e(he)}),O(ue);var ge=L(ue,2),_e=e=>{var t=sg(),r=F(t,!0);O(t),z(()=>W(r,B(n))),U(e,t)};G(ge,e=>{B(n)&&e(_e)}),O(ee),O(w),z(()=>{te.disabled=B(r),K(te,`width: 100%; padding: 12px; font-size: 14px; font-weight: 500; border: none; border-radius: var(--tandem-r-2); cursor: ${B(r)?`wait`:`pointer`}; background: ${B(r)?`var(--tandem-fg-subtle)`:`var(--tandem-accent)`}; color: var(--tandem-accent-fg);`),W(ne,B(r)?`Opening…`:`Browse…`),q(de,`aria-expanded`,B(s)),W(pe,B(s)?`▾`:`▸`)}),V(`click`,w,e=>{e.target===e.currentTarget&&t.onClose()}),V(`keydown`,w,e=>{e.key===`Escape`&&t.onClose()}),V(`click`,E,function(...e){t.onClose?.apply(this,e)}),V(`click`,te,C),V(`click`,de,f),U(e,w),j()}zr([`click`,`keydown`,`change`]);var ug=H(`<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),dg=H(`<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>`),fg=H(`<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),pg=H(`<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>,
57
+ 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 mg(e,t){A(t,!0);let n=M(()=>{let e=su(),n=t.effectiveShortcutLabels,r=new Map;for(let t of e.values()){if(!t.shortcut)continue;let e=Xc[t.id],i=e&&n?.get(e)||t.shortcut,a=r.get(t.group)??[];a.push({keys:i,description:t.label}),r.set(t.group,a)}return iu.map(e=>({title:e.charAt(0).toUpperCase()+e.slice(1),rows:r.get(e)??[]})).filter(e=>e.rows.length>0)}),r=N(null),i=null;R(()=>{if(!t.open)return;let e=kr(()=>B(r));if(!e)return;i=document.activeElement,e.focus();let n=t=>{e&&!e.contains(t.target)&&e.focus()};return document.addEventListener(`focusin`,n),()=>{document.removeEventListener(`focusin`,n),i instanceof HTMLElement&&document.contains(i)&&i.focus()}}),R(()=>{if(!t.open)return;let e=e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),t.onClose())};return window.addEventListener(`keydown`,e,{capture:!0}),()=>window.removeEventListener(`keydown`,e,{capture:!0})});var a=Yr(),o=I(a),s=e=>{var i=pg(),a=F(i),o=F(a),s=L(F(o),2);O(o);var c=L(o,2);fi(c,17,()=>B(n),e=>e.title,(e,t)=>{var n=dg(),r=F(n),i=F(r,!0);O(r);var a=L(r,2);fi(a,21,()=>B(t).rows,e=>e.description,(e,t)=>{var n=ug(),r=I(n),i=F(r),a=F(i,!0);O(i),O(r);var o=L(r,2),s=F(o,!0);O(o),z(()=>{W(a,B(t).keys),W(s,B(t).description)}),U(e,n)}),O(a),O(n),z(()=>W(i,B(t).title)),U(e,n)});var l=L(c,2),u=L(F(l),2);fi(u,21,()=>fm,e=>e.description,(e,t)=>{var n=fg(),r=I(n),i=F(r),a=F(i,!0);O(i),O(r);var o=L(r,2),s=F(o,!0);O(o),z(()=>{W(a,B(t).keys),W(s,B(t).description)}),U(e,n)}),O(u),O(l),k(2),O(a),da(a,e=>P(r,e),()=>B(r)),Ni(a,(e,t)=>Vu?.(e,t),()=>`y`),O(i),V(`click`,i,function(...e){t.onClose?.apply(this,e)}),V(`click`,a,e=>e.stopPropagation()),V(`keydown`,a,e=>{if(e.key===`Escape`){t.onClose();return}if(e.stopPropagation(),e.key===`Tab`&&B(r)){let t=Array.from(B(r).querySelectorAll(`button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])`)).filter(e=>!e.closest(`[hidden]`));if(t.length===0){e.preventDefault();return}let n=t[0],i=t[t.length-1];e.shiftKey&&document.activeElement===n?(e.preventDefault(),i.focus()):!e.shiftKey&&document.activeElement===i&&(e.preventDefault(),n.focus())}}),V(`click`,s,function(...e){t.onClose?.apply(this,e)}),U(e,i)};G(o,e=>{t.open&&e(s)}),U(e,a),j()}zr([`click`,`keydown`]);var hg=`/api/integrations/existing`,gg=`/api/integrations`,_g=`/api/integrations/apply`,vg=`/api/integrations/first-run-needed`;function yg(e){return`/api/integrations/secrets/${encodeURIComponent(e)}`}function bg(e){return`/api/models/secrets/${encodeURIComponent(e)}`}var xg=`/api/integrations/claude-cli-status`,Sg=`/api/integrations/install-claude-code`;function Cg(e,t=``,n=globalThis.fetch.bind(globalThis)){let r=N(null),i=N(!1),a=N(null),o=N(!1),s=N(null),c=!0;_a(()=>{c=!1});let l=async e=>{try{let i=await n(`${t}${xg}`);if(!c||e())return;if(!i.ok){P(a,`Could not check for Claude (status ${i.status}).`);return}let o=await i.json();if(!c||e())return;P(r,o.presence,!0),P(a,null)}catch(t){if(!c||e())return;P(a,t instanceof Error?t.message:String(t),!0)}finally{c&&!e()&&P(i,!1)}};return R(()=>{if(!e()){P(i,!1);return}let t=!1;return P(i,!0),l(()=>t),()=>{t=!0}}),{get presence(){return B(r)},get loading(){return B(i)},get error(){return B(a)},get installing(){return B(o)},get installError(){return B(s)},install:async()=>{if(!c)return null;P(o,!0),P(s,null);try{let e=await n(`${t}${Sg}`,{method:`POST`});if(!c)return null;if(!e.ok){let t=await e.json().catch(()=>null);return c&&P(s,wg(e.status,t),!0),null}let i=await e.json();return c?(P(r,i.presence,!0),i.presence===`NOT_INSTALLED`&&P(s,`The installer finished but Claude wasn't detected yet. Open a new terminal and click "Check again", or install Claude Code manually.`),i.presence):null}catch(e){return c&&P(s,e instanceof Error?e.message:String(e),!0),null}finally{c&&P(o,!1)}},refetch:async()=>{c&&(P(i,!0),P(s,null),await l(()=>!1))}}}function wg(e,t){let n=t??null;if(n?.code===`UNSUPPORTED_PLATFORM`)return`Automatic install isn't available on this operating system. Install Claude Code manually, then check again.`;if(n?.code===`INSTALL_IN_PROGRESS`)return`An install is already in progress.`;let r=n?.stderrTail?.trim();return r?`Install failed (exit ${typeof n?.exitCode==`number`?n.exitCode:`?`}). ${r}`:n?.message??`Install failed (status ${e}).`}var Tg=`Tauri runtime not available`;async function Eg(){try{return(await Ul(()=>import(`./core-SwWLTXZB.js`),[])).invoke}catch(e){return nh()&&console.error(`[keychain] Failed to load @tauri-apps/api/core:`,e),(()=>Promise.reject(Error(Tg)))}}function Dg(e,t,n){return e(`keychain_set`,{account:t,secret:n})}function Og(e,t){return e(`keychain_delete`,{account:t})}function kg(e={}){let t=e.fetchFn??((...e)=>globalThis.fetch(...e)),n=e.baseUrl??``,r=e.pathFor??yg;return{async set(e,i){try{let a=await t(`${n}${r(e)}`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({secret:i})});return a.status===503&&(await a.json().catch(()=>null))?.code===`KEYCHAIN_UNAVAILABLE`?{status:`unavailable`}:a.ok?{status:`ok`}:{status:`error`,message:`HTTP ${a.status}`}}catch(e){return{status:`error`,message:e instanceof Error?e.message:String(e)}}},async delete(e){await t(`${n}${r(e)}`,{method:`DELETE`}).catch(()=>{})}}}var Ag=[`keychain-init`,`Platform secure storage failure`,`Couldn't access platform secure storage`];function jg(e){return Ag.some(t=>e.includes(t))}function Mg(e={}){let t=()=>e.invoke?Promise.resolve(e.invoke):Eg();return{async set(e,n){try{return await Dg(await t(),e,n),{status:`ok`}}catch(e){let t=e instanceof Error?e.message:String(e);return jg(t)?{status:`unavailable`}:{status:`error`,message:t}}},async delete(e){try{await Og(await t(),e)}catch{}}}}function Ng(e={}){return e.force===`tauri`||e.force!==`http`&&nh()?Mg({invoke:e.invoke}):kg({fetchFn:e.fetchFn,baseUrl:e.baseUrl,pathFor:e.pathFor})}function Pg(e){return e.tandemValidation!==void 0&&e.tandemValidation.status!==`valid`}function Fg(e){return(e.status===`ok`||e.status===`missing`)&&!Pg(e)}function Ig(e){return`${e}-${crypto.randomUUID().replace(/-/g,``).slice(0,12)}`}function Lg(e){return`${e}-${crypto.randomUUID().slice(0,8)}`}function Rg(e){if(e.target.kind===`claude-code`){let t=e.tandemEntry?.url??`http://127.0.0.1:3479`,n=Lg(`claude-code`);return{id:n,config:{kind:`claude-code`,id:n,label:e.target.label,configPath:e.target.configPath,transport:`http`,url:t},hasStoredSecret:!1,keychainUnavailable:!1}}if(e.target.kind===`claude-desktop`){let t=Lg(`claude-desktop`);return{id:t,config:{kind:`claude-desktop`,id:t,label:e.target.label,configPath:e.target.configPath,transport:`stdio`},hasStoredSecret:!1,keychainUnavailable:!1}}return null}function zg(e={}){let t=e.fetchFn??globalThis.fetch.bind(globalThis),n=e.baseUrl??``,r=e.keychainBackend??Ng({fetchFn:t,baseUrl:n}),i=N(`connect`),a=N(!0),o=N(ln([])),s=N(ln([])),c=N(null),l=N(ln([])),u=N(!1),d=0,f=e=>{P(c,e,!0),P(i,`error`),P(a,!1)},p=async()=>{let e=++d;P(a,!0),P(i,`connect`),P(c,null);try{let r=await t(`${n}${hg}`);if(e!==d)return;if(!r.ok){f(`Could not load existing entries (HTTP ${r.status}).`);return}let i=await r.json();if(e!==d)return;P(o,i.installs,!0),P(s,i.installs.filter(Fg).map(Rg).filter(e=>e!==null),!0)}catch(t){if(e!==d)return;if(t instanceof TypeError&&/fetch|load failed|network/i.test(t.message)){f(`Could not reach the Tandem server. Make sure Tandem is running, then try again.`);return}f(t instanceof Error?t.message:String(t))}finally{e===d&&P(a,!1)}},m=e=>{let t=B(s).filter(t=>t.config.tokenSecretRef&&!e.some(e=>e.id===t.id));P(s,e,!0);for(let e of t){let t=e.config.tokenSecretRef;t&&r.delete(t)}},h=async(e,t)=>{let n=Ig(e.id),i=await r.set(n,t);if(i.status===`unavailable`){P(u,!0),P(s,B(s).map(t=>t.id===e.id?{...t,keychainUnavailable:!0}:t),!0);return}if(i.status===`error`){r.delete(n),f(`Could not store secret: ${i.message}`);return}P(s,B(s).map(t=>t.id===e.id?{...t,config:{...t.config,tokenSecretRef:n},hasStoredSecret:!0,keychainUnavailable:!1}:t),!0)},g=async()=>{let e=B(s).map(e=>e.config.tokenSecretRef).filter(e=>typeof e==`string`&&e.length>0);await Promise.all(e.map(e=>r.delete(e)))};return{get step(){return B(i)},get detecting(){return B(a)},get existing(){return B(o)},get picked(){return B(s)},get errorMessage(){return B(c)},get applyResults(){return B(l)},get keychainUnavailable(){return B(u)},begin:p,setPicked:m,submitSecret:h,save:async()=>{P(i,`applying`);let e={schemaVersion:3,integrations:B(s).map(e=>{if(e.config.kind===`other-mcp`)return{...e.config,apply:`skip`};let t=e.config.configPath,n=B(o).find(e=>e.target.configPath===t),r=n!==void 0&&Pg(n);return{...e.config,apply:r?`skip`:`create`}})},r=!1;try{let a=await t(`${n}${gg}`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(e)});if(!a.ok){let e=await a.json().catch(()=>null);await g(),f(e?.message??`Could not save (HTTP ${a.status}).`);return}r=!0;let o=await a.json(),s=await t(`${n}${_g}`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({ids:o.ids,confirmationNonce:o.confirmationNonce})});if(!s.ok){f((await s.json().catch(()=>null))?.message??`Could not apply (HTTP ${s.status}).`);return}P(l,(await s.json()).results,!0),P(i,`done`)}catch(e){r||await g(),f(e instanceof Error?e.message:String(e))}},reset:()=>{P(i,`connect`),P(a,!1),P(o,[],!0),P(s,[],!0),P(c,null),P(l,[],!0),P(u,!1)},cleanupUnsavedSecrets:async()=>{B(i)===`connect`&&await g()}}}var Bg=3e3,Vg=1500,Hg=2e4;function Ug(e,t,n=``,r=globalThis.fetch.bind(globalThis),i={}){let a=i.verifyTimeoutMs??Bg,o=i.pollIntervalMs??Vg,s=i.pollDeadlineMs??Hg,c=N(`idle`),l=N(null),u=N(!1),d=N(ln([])),f=!0,p=null,m=0;function h(){p!==null&&(clearInterval(p),p=null)}_a(()=>{f=!1,h(),m++});async function g(e){let t=++m,i;try{i=await r(`${n}${gc}`,e?{signal:e}:void 0)}catch{return{ok:!1,hasSession:null}}if(!i.ok)return{ok:!1,hasSession:null};let a=null;try{a=await i.json()}catch{a=null}let o=a&&typeof a.hasSession==`boolean`?a.hasSession:null;return o===!0&&t===m&&f&&P(u,!0),{ok:!0,hasSession:o}}return R(()=>{if(!t()){P(c,`idle`),h();return}let n=!1,r=kr(()=>e()).map(e=>({...e})),i=r.some(e=>e.transport===`http`);if(P(u,!1),P(l,null),P(d,r.map(e=>({id:e.id,status:e.transport===`http`?`verifying`:`not-applicable`})),!0),!i)return P(c,`done`),()=>{n=!0,h()};P(c,`verifying`);let m=new AbortController,_=setTimeout(()=>m.abort(),a);return(async()=>{let{ok:e,hasSession:t}=await g(m.signal);if(clearTimeout(_),n||!f||(P(l,e,!0),P(d,r.map(t=>({id:t.id,status:t.transport===`http`?e?`reachable`:`unreachable`:`not-applicable`})),!0),P(c,`done`),!e||t===!0))return;let i=Date.now()+s;p=setInterval(()=>{if(n||!f||B(u)||Date.now()>=i){h();return}g().then(()=>{B(u)&&h()})},o)})(),()=>{n=!0,clearTimeout(_),m.abort(),h()}}),{get phase(){return B(c)},get serverUp(){return B(l)},get claudeConnected(){return B(u)},get results(){return B(d)}}}var Wg=qr(`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" class="svelte-q7klwd"><path d="M4 5h16a1 1 0 0 1 1 1v12a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1Z"></path><path d="M7 9l3 3-3 3"></path><path d="M13 15h4"></path></svg>`),Gg=qr(`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" class="svelte-q7klwd"><path d="M3 5h18a1 1 0 0 1 1 1v12a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1Z"></path><path d="M2 9h20"></path></svg>`),Kg=qr(`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="svelte-q7klwd"><path d="M5 13l4 4L19 7"></path></svg>`),qg=H(`<span class="itc-check-empty svelte-q7klwd"></span>`),Jg=H(`<label><input type="checkbox" class="itc-checkbox svelte-q7klwd"/> <span class="itc-icon svelte-q7klwd" aria-hidden="true"><!></span> <span class="itc-text svelte-q7klwd"><span class="itc-name svelte-q7klwd"> </span> <span> </span> <span class="itc-path svelte-q7klwd"> </span></span> <span class="itc-check svelte-q7klwd" aria-hidden="true"><!></span></label>`);function Yg(e,t){A(t,!0);let n=M(()=>Fg(t.install)),r=M(()=>t.install.target.configPath.replace(/[^a-zA-Z0-9]+/g,`-`).replace(/^-+|-+$/g,``).toLowerCase()),i=M(()=>t.install.status===`error`?{text:t.install.errorMessage?`Couldn't check this one — ${t.install.errorMessage}`:`Couldn't check this one`,family:`error`}:t.install.status===`malformed`?{text:`Settings file couldn't be read — we'll leave it alone`,family:`warning`}:t.install.tandemEntry===void 0?t.install.status===`missing`?{text:`Ready to connect (settings file will be created)`,family:null}:{text:`Ready to connect`,family:null}:Pg(t.install)?{text:`Has a custom setup — we won't touch it`,family:`warning`}:{text:`Already connected — we'll refresh it`,family:`success`});var a=Jg();let o;var s=F(a);Qi(s);var c=L(s,2),l=F(c),u=e=>{U(e,Wg())},d=e=>{U(e,Gg())};G(l,e=>{t.install.target.kind===`claude-code`?e(u):e(d,-1)}),O(c);var f=L(c,2),p=F(f),m=F(p,!0);O(p);var h=L(p,2),g=F(h,!0);O(h);var _=L(h,2),v=F(_,!0);O(_),O(f);var y=L(f,2),b=F(y),x=e=>{var n=Yr(),r=I(n),i=e=>{U(e,Kg())},a=e=>{U(e,qg())};G(r,e=>{t.selected?e(i):e(a,-1)}),U(e,n)};G(b,e=>{B(n)&&e(x)}),O(y),O(a),z(()=>{o=Hi(a,1,`itc-card svelte-q7klwd`,null,o,{"is-selected":t.selected,"is-locked":!B(n)}),q(a,`data-testid`,`integration-wizard-card-${B(r)??``}`),ea(s,t.selected),s.disabled=!B(n),q(s,`data-testid`,`integration-wizard-pick-${B(r)??``}`),W(m,t.install.target.label),Hi(h,1,`itc-status itc-status-${B(i).family??`neutral`??``}`,`svelte-q7klwd`),W(g,B(i).text),W(v,t.install.target.configPath)}),V(`change`,s,function(...e){t.onToggle?.apply(this,e)}),U(e,a),j()}zr([`change`]);var Xg=(e,t=m)=>{var n=e_();z(()=>Hi(n,0,Ii(t()),`svelte-bt94ms`)),U(e,n)},Zg=e=>{U(e,t_())},Qg=e=>{U(e,n_())},$g=(e,t=m)=>{var n=r_(),r=L(F(n));O(n),z(()=>W(r,` ${t()??``}`)),U(e,n)},e_=qr(`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 3l9 16H3z" class="svelte-bt94ms"></path><path d="M12 9v4" class="svelte-bt94ms"></path><path d="M12 17h.01" class="svelte-bt94ms"></path></svg>`),t_=qr(`<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-bt94ms"><path d="M5 13l4 4L19 7" class="svelte-bt94ms"></path></svg>`),n_=qr(`<svg class="iw-chevron svelte-bt94ms" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M9 6l6 6-6 6" class="svelte-bt94ms"></path></svg>`),r_=H(`<div class="iw-loading svelte-bt94ms" aria-live="polite"><span class="iw-dots svelte-bt94ms" aria-hidden="true"><span class="iw-dot svelte-bt94ms"></span><span class="iw-dot svelte-bt94ms"></span><span class="iw-dot svelte-bt94ms"></span></span> </div>`),i_=H(`<span><!></span>`),a_=H(`<p class="iw-subtitle svelte-bt94ms">Connect your AI assistant.</p>`),o_=H(`<p class="iw-subtitle svelte-bt94ms">Let a teammate's Claude join from the Cowork VM.</p>`),s_=H(`<div class="iw-whats-next svelte-bt94ms"><!> <span class="svelte-bt94ms">Cowork is enabled. Manage workspaces in Settings&nbsp;→&nbsp;Network.</span></div>`),c_=H(`<p class="iw-hint-text svelte-bt94ms" data-testid="cowork-vethernet-cidr">Detected Cowork environment: <code class="iw-code-inline svelte-bt94ms"> </code></p>`),l_=H(`<p class="iw-hint-text svelte-bt94ms">A previous attempt couldn't update Windows Firewall (that needs administrator
58
+ rights). Enabling writes the workspace plugin entries either way.</p>`),u_=H(`<div class="iw-banner-warning svelte-bt94ms"><!> <span class="svelte-bt94ms">Tandem registers itself as a plugin in every detected Cowork workspace so Claude
59
+ in Cowork can reach your open documents. This adds a Windows firewall rule so the
60
+ Cowork VM can connect back — admin is required once.</span></div> <!> <!> <details class="iw-advanced svelte-bt94ms" data-testid="integration-wizard-cowork-explainer"><summary class="svelte-bt94ms"><!> What this does &amp; how to verify</summary> <div class="iw-advanced-body svelte-bt94ms"><p class="iw-hint-text svelte-bt94ms">You don't add a marketplace or run any commands inside Cowork — Tandem writes
61
+ the plugin entry for you. After enabling, open a Cowork session and ask Claude
62
+ to open or list your documents; Tandem's tools should appear. If they don't,
63
+ re-run “Enable Cowork”.</p> <p class="iw-hint-text svelte-bt94ms">Live updates (annotations and chat as they happen) need the Tandem desktop app
64
+ running; the Cowork connection itself is request-and-response.</p></div></details>`,1),d_=H(`<div class="iw-banner-warning svelte-bt94ms" role="alert" data-testid="integration-wizard-cowork-error"><!> <span class="svelte-bt94ms"> </span></div>`),f_=H(`<section class="iw-step svelte-bt94ms" data-testid="integration-wizard-cowork-step"><!> <!></section>`),p_=H(`<div class="iw-banner-warning svelte-bt94ms" role="alert" data-testid="integration-wizard-install-error"><!> <span class="svelte-bt94ms"> </span></div>`),m_=H(`<p class="iw-hint-text svelte-bt94ms">Don't have Claude Code yet? Install it now — a small, signed download
65
+ straight from Anthropic.</p> <button type="button" class="iw-btn iw-btn-primary svelte-bt94ms" data-testid="integration-wizard-install-claude"> </button> <!>`,1),h_=H(`<div class="iw-whats-next svelte-bt94ms" data-testid="integration-wizard-install-success"><!> <span class="svelte-bt94ms">Claude Code is installed. Open a new terminal and run <code class="svelte-bt94ms">claude</code> once, then choose “Check again”.</span></div>`),g_=H(`<div class="iw-empty svelte-bt94ms" data-testid="integration-wizard-empty"><p class="iw-empty-title svelte-bt94ms">We couldn't find Claude on this computer.</p> <!> <p class="iw-hint-text svelte-bt94ms">If you use Claude Code or Claude Desktop, open it once, then check again. To
66
+ connect a different MCP-compatible app manually, point it at:</p> <code class="iw-code svelte-bt94ms"> </code></div>`),__=H(`<div class="iw-banner-warning svelte-bt94ms" data-testid="integration-wizard-keychain-fallback"><!> <span class="svelte-bt94ms">Your operating system's secure storage isn't reachable from this Tandem
67
+ build, so tokens entered here can't be saved. Set the environment
68
+ variable <code class="iw-code-inline svelte-bt94ms">TANDEM_INTEGRATION_&lt;id&gt;_TOKEN</code> instead, or add the token in your AI client's own configuration.</span></div>`),v_=H(`<span class="iw-secret-stored svelte-bt94ms"><!> Token saved</span>`),y_=H(`<span class="iw-secret-skipped svelte-bt94ms">Skipped (secure storage unavailable)</span>`),b_=H(`<div class="iw-secret-input svelte-bt94ms"><input type="password" placeholder="Paste access token" class="svelte-bt94ms"/> <button type="button" class="iw-btn iw-btn-secondary svelte-bt94ms">Save token</button></div>`),x_=H(`<div class="iw-secret-row svelte-bt94ms"><span class="iw-secret-label svelte-bt94ms"> </span> <!></div>`),S_=H(`<details class="iw-advanced svelte-bt94ms" data-testid="integration-wizard-advanced"><summary class="svelte-bt94ms"><!> Advanced — set an access token</summary> <div class="iw-advanced-body svelte-bt94ms"><p class="iw-hint-text svelte-bt94ms">Only needed if you've changed Tandem to listen on your network instead of
69
+ just this computer. Most people can skip this. Tokens are stored in your
70
+ operating system's secure storage.</p> <!> <!></div></details>`),C_=H(`<p class="iw-intro svelte-bt94ms">We'll add a small entry to Claude's settings file so Claude can read and edit the
71
+ documents you have open in Tandem. Nothing else is touched, and you can undo this
72
+ any time.</p> <div class="iw-cards svelte-bt94ms"></div> <!>`,1),w_=H(`<section class="iw-step svelte-bt94ms" data-testid="integration-wizard-step-detect"><!> <p class="iw-hint-text iw-reopen-hint svelte-bt94ms" data-testid="integration-wizard-reopen-hint">Not now? You can reopen this wizard anytime from Settings → AI Assistant.</p></section>`),T_=H(`<section class="iw-step iw-center svelte-bt94ms" data-testid="integration-wizard-step-applying"><!> <p class="iw-hint-text svelte-bt94ms">Updating Claude's settings file. This takes a second.</p></section>`),E_=H(`<div class="iw-verifying svelte-bt94ms" data-testid="integration-wizard-step-verifying"><!></div>`),D_=H(`<span class="iw-result-detail svelte-bt94ms">Connected</span> <!>`,1),O_=H(`<span class="iw-result-detail svelte-bt94ms">Left unchanged (already set up, or couldn't be safely edited)</span>`),k_=H(`<span class="iw-result-detail svelte-bt94ms"> </span>`),A_=H(`<div><span class="iw-result-mark svelte-bt94ms" aria-hidden="true"><!></span> <span class="iw-result-text svelte-bt94ms"><span class="iw-result-name svelte-bt94ms"> </span> <!></span></div>`),j_=H(`<div class="iw-results svelte-bt94ms"></div>`),M_=H(`Tandem doesn't seem to be running. Start Tandem, then restart Claude and run <code class="iw-code-inline svelte-bt94ms">/mcp</code>.`,1),N_=H(`Restart Claude Code, then type <code class="iw-code-inline svelte-bt94ms">/mcp</code> to verify —
73
+ or just ask Claude to open a document.`,1),P_=H(`<section class="iw-step svelte-bt94ms" data-testid="integration-wizard-step-done"><div class="iw-done-header svelte-bt94ms"><svg class="iw-done-check svelte-bt94ms" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path class="iw-check-path svelte-bt94ms" d="M4 13l5 5L20 7"></path></svg> <h3 class="iw-done-title svelte-bt94ms"> </h3></div> <!> <!> <div class="iw-whats-next svelte-bt94ms" data-testid="integration-wizard-whats-next"><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-bt94ms"><circle cx="12" cy="12" r="9" class="svelte-bt94ms"></circle><path d="M12 11v5" class="svelte-bt94ms"></path><path d="M12 8h.01" class="svelte-bt94ms"></path></svg> <span class="svelte-bt94ms"><!></span></div></section>`),F_=H(`<p class="iw-hint-text svelte-bt94ms"> </p>`),I_=H(`<details class="iw-tech-details svelte-bt94ms"><summary class="svelte-bt94ms"><!> Technical details</summary> <pre class="iw-tech-text svelte-bt94ms"> </pre></details>`),L_=H(`<section class="iw-step iw-center svelte-bt94ms" data-testid="integration-wizard-step-error"><!> <h3 class="iw-error-title svelte-bt94ms">Something went wrong while connecting</h3> <!> <!></section>`),R_=H(`<span class="iw-more-badge svelte-bt94ms"><!> Enabled</span>`),z_=H(`<button type="button" class="iw-btn iw-btn-secondary iw-more-btn svelte-bt94ms" aria-label="Set up Cowork" data-testid="integration-wizard-cowork-setup">Set up</button>`),B_=H(`<div class="iw-more-row svelte-bt94ms"><div class="iw-more-row-text svelte-bt94ms"><span class="iw-more-row-name svelte-bt94ms">Cowork</span> <span class="iw-more-row-detail svelte-bt94ms"> </span></div> <!></div>`),V_=H(`<div class="iw-more-row iw-more-row-disabled svelte-bt94ms"><div class="iw-more-row-text svelte-bt94ms"><span class="iw-more-row-name svelte-bt94ms">AI models</span> <span class="iw-more-row-detail svelte-bt94ms">Bring your own model — coming soon</span></div></div>`),H_=H(`<section class="iw-more svelte-bt94ms" data-testid="integration-wizard-more"><div class="iw-more-label svelte-bt94ms">More integrations</div> <!> <!></section>`),U_=H(`<!> <!>`,1),W_=H(`<button type="button" class="iw-btn iw-btn-primary svelte-bt94ms">Done</button>`),G_=H(`<button type="button" class="iw-btn iw-btn-primary svelte-bt94ms" data-testid="cowork-enable-confirm-btn"> </button>`),K_=H(`<button type="button" class="iw-btn iw-btn-secondary svelte-bt94ms" data-testid="integration-wizard-cowork-back">Back</button> <!>`,1),q_=H(`<button type="button" class="iw-btn iw-btn-secondary svelte-bt94ms">Cancel</button>`),J_=H(`<button type="button" class="iw-btn iw-btn-secondary svelte-bt94ms">Close</button> <button type="button" class="iw-btn iw-btn-primary svelte-bt94ms" data-testid="integration-wizard-check-again">Check again</button>`,1),Y_=H(`<button type="button" class="iw-btn iw-btn-secondary svelte-bt94ms">Not now</button> <button type="button" class="iw-btn iw-btn-primary svelte-bt94ms" data-testid="integration-wizard-connect-btn"> </button>`,1),X_=H(`<button type="button" class="iw-btn iw-btn-secondary svelte-bt94ms" disabled="">Connecting…</button>`),Z_=H(`<button type="button" class="iw-btn iw-btn-secondary svelte-bt94ms" data-testid="integration-wizard-done-retry">Try again</button>`),Q_=H(`<!> <button type="button" class="iw-btn iw-btn-primary svelte-bt94ms" data-testid="integration-wizard-done-close">Done</button>`,1),$_=H(`<button type="button" class="iw-btn iw-btn-secondary svelte-bt94ms">Close</button> <button type="button" class="iw-btn iw-btn-primary svelte-bt94ms" data-testid="integration-wizard-error-retry">Try again</button>`,1),ev=H(`<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"><div class="iw-header-text svelte-bt94ms"><h2 class="iw-title svelte-bt94ms"> </h2> <!></div> <button type="button" class="iw-close svelte-bt94ms" aria-label="Close wizard" data-testid="integration-wizard-close">×</button></header> <div class="iw-body svelte-bt94ms"><!></div> <footer class="iw-footer svelte-bt94ms"><!></footer></div></div>`);function tv(e,t){A(t,!0);let n=(e,t=m)=>{let n=M(()=>d(t()));var r=Yr(),i=I(r),a=e=>{var r=i_(),i=F(r),a=e=>{U(e,Jr(`Checking Tandem is reachable…`))},o=e=>{var t=Jr();z(()=>W(t,u.claudeConnected?`Claude connected just now`:`Tandem is responding`)),U(e,t)},s=e=>{U(e,Jr(`Config written, but the Tandem MCP server isn't responding — start Tandem, then restart
74
+ Claude.`))},c=e=>{U(e,Jr(`Tandem starts when Claude Desktop opens`))};G(i,e=>{B(n)===`verifying`?e(a):B(n)===`reachable`?e(o,1):B(n)===`unreachable`?e(s,2):e(c,-1)}),O(r),z(()=>{Hi(r,1,`iw-reachability iw-reachability-${B(n)??``}`,`svelte-bt94ms`),q(r,`data-testid`,`integration-wizard-reachability-${t()??``}`),q(r,`data-reachability-status`,B(n))}),U(e,r)};G(i,e=>{B(n)&&e(a)}),U(e,r)},r=zg({baseUrl:`http://127.0.0.1:${ba}`}),i=gh(()=>nh()),a=M(()=>Hm(i.status)),o=Cg(()=>t.open&&r.step===`connect`,`http://127.0.0.1:${ba}`),s=M(()=>o.presence===`NOT_INSTALLED`),c=M(()=>o.presence===`INSTALLED_NOT_ON_PATH`),l=M(()=>r.applyResults.filter(e=>e.status===`applied`).map(e=>({id:e.id,transport:r.picked.find(t=>t.id===e.id)?.config.transport})).filter(e=>e.transport===`http`||e.transport===`stdio`)),u=Ug(()=>B(l),()=>t.open&&r.step===`done`,`http://127.0.0.1:${ba}`);function d(e){return u.results.find(t=>t.id===e)?.status??null}let f=M(()=>{let e=u.results;return!e.some(e=>e.status===`reachable`||e.status===`unreachable`||e.status===`verifying`)&&e.length>0?`stdio-only`:e.some(e=>e.status===`unreachable`)?`unreachable`:u.claudeConnected?`connected`:`default`}),p=N(`main`),h=N(!1),g=N(null),_=N(null),v=null,y=N(ln({}));R(()=>{if(!t.open)return;let e=kr(()=>B(_));if(e)return v=document.activeElement,e.focus(),()=>{v instanceof HTMLElement&&document.contains(v)&&v.focus()}}),R(()=>{t.open&&(P(p,`main`),r.begin())});async function b(){P(h,!0),P(g,null);try{await sh(await ah(),!0),await i.refetch(),P(p,`main`)}catch(e){P(g,Km(e instanceof Error?e.message:String(e)),!0)}finally{P(h,!1)}}let x=M(()=>{if(B(a)===`loading`)return`Checking…`;if(B(a)===`unsupported`)return`Coming soon to macOS & Linux`;if(B(a)===`undetected`){let e=i.status,t=e?Um(e):`noClaude`;return t===`blocked`?`Found in a network-redirected or synced location Tandem can't safely configure`:t===`noWorkspacesYet`?`Claude Desktop detected — run a Cowork session once, then set up here`:`Not detected on this computer`}let e=i.status;return e?.enabled?`Connected — token provisioned`:e?.uacDeclined?`Setup didn't complete last time — try again from here`:`Let a teammate's Claude join from the Cowork VM`});R(()=>{if(!t.open)return;let e=e=>{e.key===`Escape`&&S()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)});function S(){r.cleanupUnsavedSecrets().catch(()=>{}),r.reset(),P(y,{},!0),t.onClose()}function C(){r.reset(),P(y,{},!0),r.begin(),o.refetch(),i.refetch()}async function w(){let e=await o.install();e&&e!==`NOT_INSTALLED`&&r.begin()}function ee(e){if(e.key!==`Tab`||!B(_))return;let t=Array.from(B(_).querySelectorAll(`button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), summary, [tabindex]:not([tabindex="-1"])`)).filter(e=>e.offsetParent!==null);if(t.length===0)return;let n=t[0],r=t[t.length-1],i=document.activeElement;e.shiftKey&&(i===n||i===B(_))?(e.preventDefault(),r.focus()):!e.shiftKey&&i===r&&(e.preventDefault(),n.focus())}function T(e){let t=r.picked.findIndex(t=>t.config.configPath===e.target.configPath);if(t>=0){r.setPicked(r.picked.filter((e,n)=>n!==t));return}let n=Rg(e);n&&r.setPicked([...r.picked,n])}function E(e){return r.picked.some(t=>t.config.configPath===e.target.configPath)}async function te(e){let t=B(y)[e.id]??``;t.length!==0&&(await r.submitSecret(e,t),B(y)[e.id]=``)}let ne=/HTTP 5\d\d/,D=/HTTP 4\d\d/,re=/fetch|network|Failed to/i,ie=M(()=>r.picked.length===1?`Connect ${r.picked[0].config.label}`:`Connect selected`);function ae(e){return r.picked.find(t=>t.id===e.id)?.config.label??`Unknown`}function oe(e){switch(e.code){case`WRITE_FAILED`:return`Couldn't write the settings file — check it isn't open in another program, then try again.`;case`SECRET_MISSING`:return`The access token wasn't found — re-enter it under Advanced and try again.`;case`TARGET_NOT_DETECTED`:return`This assistant's settings file couldn't be found anymore — it may have moved.`;case`PATH_REJECTED`:return`The settings file is in an unexpected location, so Tandem left it alone for safety.`;case`OTHER_MCP_NOT_APPLICABLE`:return`Tandem can't auto-configure this app — connect it manually from that app's settings.`;default:return e.message??`Something went wrong applying this one.`}}let se=M(()=>{let e=r.errorMessage??``;return ne.test(e)?`Tandem's helper isn't responding. Make sure Tandem is running, then try again.`:D.test(e)?`Tandem couldn't save the connection. Try again in a moment.`:re.test(e)?`Couldn't reach Tandem — is it still running?`:null}),ce=M(()=>r.applyResults.some(e=>e.status===`error`));var le=Yr(),ue=I(le),de=e=>{var t=ev(),l=F(t),d=F(l),m=F(d),v=F(m),ne=F(v,!0);O(v);var D=L(v,2),re=e=>{U(e,a_())},le=e=>{U(e,o_())};G(D,e=>{B(p)===`main`&&r.step===`connect`?e(re):B(p)===`cowork`&&e(le,1)}),O(m);var ue=L(m,2);O(d);var de=L(d,2),fe=F(de),pe=e=>{var t=f_(),n=F(t),r=e=>{var t=s_();Zg(F(t)),k(2),O(t),U(e,t)},a=e=>{var t=u_(),n=I(t);Xg(F(n)),k(2),O(n);var r=L(n,2),a=e=>{var t=c_(),n=L(F(t)),r=F(n,!0);O(n),O(t),z(()=>W(r,i.status.vethernetCidr)),U(e,t)};G(r,e=>{i.status?.vethernetCidr&&e(a)});var o=L(r,2),s=e=>{U(e,l_())};G(o,e=>{i.status?.uacDeclined&&e(s)});var c=L(o,2),l=F(c);Qg(F(l)),k(),O(l),k(2),O(c),U(e,t)};G(n,e=>{i.status?.enabled?e(r):e(a,-1)});var o=L(n,2),s=e=>{var t=d_(),n=F(t);Xg(n);var r=L(n,2),i=F(r,!0);O(r),O(t),z(()=>W(i,B(g))),U(e,t)};G(o,e=>{B(g)&&e(s)}),O(t),U(e,t)},me=e=>{var t=U_(),l=I(t),d=e=>{var t=w_(),n=F(t),i=e=>{$g(e,()=>`Looking for Claude on your computer…`)},a=e=>{var t=g_(),n=L(F(t),2),r=e=>{var t=m_(),n=L(I(t),2),r=F(n,!0);O(n);var i=L(n,2),a=e=>{var t=p_(),n=F(t);Xg(n);var r=L(n,2),i=F(r,!0);O(r),O(t),z(()=>W(i,o.installError)),U(e,t)};G(i,e=>{o.installError&&e(a)}),z(()=>{n.disabled=o.installing,W(r,o.installing?`Installing…`:`Install Claude Code`)}),V(`click`,n,w),U(e,t)},i=e=>{var t=h_();Zg(F(t)),k(2),O(t),U(e,t)};G(n,e=>{B(s)?e(r):B(c)&&e(i,1)});var a=L(n,4),l=F(a);O(a),O(t),z(()=>W(l,`http://127.0.0.1:3479/mcp`)),U(e,t)},l=e=>{var t=C_(),n=L(I(t),2);fi(n,21,()=>r.existing,e=>e.target.configPath,(e,t)=>{{let n=M(()=>E(B(t)));Yg(e,{get install(){return B(t)},get selected(){return B(n)},onToggle:()=>T(B(t))})}}),O(n);var i=L(n,2),a=e=>{var t=S_(),n=F(t);Qg(F(n)),k(),O(n);var i=L(n,2),a=L(F(i),2),o=e=>{var t=__();Xg(F(t)),k(2),O(t),U(e,t)};G(a,e=>{r.keychainUnavailable&&e(o)}),fi(L(a,2),17,()=>r.picked,e=>e.id,(e,t)=>{var n=x_(),r=F(n),i=F(r,!0);O(r);var a=L(r,2),o=e=>{var t=v_();Zg(F(t)),k(),O(t),U(e,t)},s=e=>{U(e,y_())},c=e=>{var n=b_(),r=F(n);Qi(r);var i=L(r,2);O(n),z(()=>{q(r,`data-testid`,`integration-wizard-secret-input-${B(t).id??``}`),i.disabled=!B(y)[B(t).id],q(i,`data-testid`,`integration-wizard-secret-submit-${B(t).id??``}`)}),ia(r,()=>B(y)[B(t).id],e=>B(y)[B(t).id]=e),V(`click`,i,()=>te(B(t))),U(e,n)};G(a,e=>{B(t).hasStoredSecret?e(o):B(t).keychainUnavailable?e(s,1):e(c,-1)}),O(n),z(()=>W(i,B(t).config.label)),U(e,n)}),O(i),O(t),U(e,t)};G(i,e=>{r.picked.length>0&&e(a)}),U(e,t)};G(n,e=>{r.detecting?e(i):r.existing.length===0?e(a,1):e(l,-1)}),k(2),O(t),U(e,t)},m=e=>{var t=T_();$g(F(t),()=>`Connecting Claude…`),k(2),O(t),U(e,t)},_=e=>{var t=P_(),i=F(t),a=L(F(i),2),o=F(a,!0);O(a),O(i);var s=L(i,2),c=e=>{var t=E_();$g(F(t),()=>`Verifying Claude can reach Tandem…`),O(t),U(e,t)};G(s,e=>{u.phase===`verifying`&&e(c)});var l=L(s,2),d=e=>{var t=j_();fi(t,21,()=>r.applyResults,e=>e.id,(e,t)=>{var r=A_(),i=F(r),a=F(i),o=e=>{Zg(e)},s=e=>{U(e,Jr(`—`))},c=e=>{Xg(e)};G(a,e=>{B(t).status===`applied`?e(o):B(t).status===`skipped`?e(s,1):e(c,-1)}),O(i);var l=L(i,2),u=F(l),d=F(u,!0);O(u);var f=L(u,2),p=e=>{var r=D_();n(L(I(r),2),()=>B(t).id),U(e,r)},m=e=>{U(e,O_())},h=e=>{var n=k_(),r=F(n,!0);O(n),z(e=>W(r,e),[()=>oe(B(t))]),U(e,n)};G(f,e=>{B(t).status===`applied`?e(p):B(t).status===`skipped`?e(m,1):e(h,-1)}),O(l),O(r),z(e=>{Hi(r,1,`iw-result iw-result-${B(t).status??``}`,`svelte-bt94ms`),q(r,`data-testid`,`integration-wizard-apply-result-${B(t).id??``}`),W(d,e)},[()=>ae(B(t))]),U(e,r)}),O(t),U(e,t)};G(l,e=>{r.applyResults.length>0&&e(d)});var p=L(l,2),m=L(F(p),2),h=F(m),g=e=>{U(e,Jr(`Claude is connected and talking to Tandem. Ask it to open a document.`))},_=e=>{var t=M_();k(2),U(e,t)},v=e=>{U(e,Jr(`Open Claude Desktop to start using Tandem.`))},y=e=>{var t=N_();k(2),U(e,t)};G(h,e=>{B(f)===`connected`?e(g):B(f)===`unreachable`?e(_,1):B(f)===`stdio-only`?e(v,2):e(y,-1)}),O(m),O(p),O(t),z(()=>W(o,B(ce)?`Partly connected`:`Claude is connected to Tandem`)),U(e,t)},v=e=>{var t=L_(),n=F(t);Xg(n,()=>`iw-error-icon`);var i=L(n,4),a=e=>{var t=F_(),n=F(t,!0);O(t),z(()=>W(n,B(se))),U(e,t)};G(i,e=>{B(se)&&e(a)});var o=L(i,2),s=e=>{var t=I_(),n=F(t);Qg(F(n)),k(),O(n);var i=L(n,2),a=F(i,!0);O(i),O(t),z(()=>W(a,r.errorMessage)),U(e,t)};G(o,e=>{r.errorMessage&&e(s)}),O(t),U(e,t)};G(l,e=>{r.step===`connect`?e(d):r.step===`applying`?e(m,1):r.step===`done`?e(_,2):r.step===`error`&&e(v,3)});var b=L(l,2),S=e=>{var t=H_(),n=L(F(t),2),r=e=>{var t=B_(),n=F(t),r=L(F(n),2),o=F(r,!0);O(r),O(n);var s=L(n,2),c=e=>{var t=R_();Zg(F(t)),k(),O(t),U(e,t)},l=e=>{var t=z_();V(`click`,t,()=>{P(g,null),P(h,!1),P(p,`cowork`)}),U(e,t)};G(s,e=>{i.status?.enabled?e(c):B(a)===`normal`&&e(l,1)}),O(t),z(()=>W(o,B(x))),U(e,t)},o=M(()=>nh());G(n,e=>{B(o)&&e(r)});var s=L(n,2),c=e=>{U(e,V_())};G(s,e=>{e(c)}),O(t),U(e,t)};G(b,e=>{(r.step===`connect`||r.step===`done`)&&e(S)}),U(e,t)};G(fe,e=>{B(p)===`cowork`?e(pe):e(me,-1)}),O(de);var he=L(de,2),ge=F(he),_e=e=>{var t=K_(),n=I(t),r=L(n,2),a=e=>{var t=W_();V(`click`,t,()=>P(p,`main`)),U(e,t)},o=e=>{var t=G_(),n=F(t,!0);O(t),z(()=>{t.disabled=B(h),W(n,B(h)?`Enabling…`:`Enable Cowork`)}),V(`click`,t,b),U(e,t)};G(r,e=>{i.status?.enabled?e(a):e(o,-1)}),z(()=>n.disabled=B(h)),V(`click`,n,()=>P(p,`main`)),U(e,t)},ve=e=>{var t=Yr(),n=I(t),i=e=>{var t=q_();V(`click`,t,S),U(e,t)},a=e=>{var t=J_(),n=I(t),r=L(n,2);V(`click`,n,S),V(`click`,r,C),U(e,t)},o=e=>{var t=Y_(),n=I(t),i=L(n,2),a=F(i,!0);O(i),z(()=>{i.disabled=r.picked.length===0,W(a,B(ie))}),V(`click`,n,S),V(`click`,i,()=>r.save()),U(e,t)};G(n,e=>{r.detecting?e(i):r.existing.length===0?e(a,1):e(o,-1)}),U(e,t)},ye=e=>{U(e,X_())},be=e=>{var t=Q_(),n=I(t),r=e=>{var t=Z_();V(`click`,t,C),U(e,t)};G(n,e=>{B(ce)&&e(r)}),V(`click`,L(n,2),S),U(e,t)},xe=e=>{var t=$_(),n=I(t),r=L(n,2);V(`click`,n,S),V(`click`,r,C),U(e,t)};G(ge,e=>{B(p)===`cowork`?e(_e):r.step===`connect`?e(ve,1):r.step===`applying`?e(ye,2):r.step===`done`?e(be,3):r.step===`error`&&e(xe,4)}),O(he),O(l),da(l,e=>P(_,e),()=>B(_)),O(t),z(()=>W(ne,B(p)===`cowork`?`Set up Cowork`:`Connect Claude to Tandem`)),V(`click`,t,e=>{e.target===e.currentTarget&&S()}),V(`keydown`,l,e=>{if(e.key===`Escape`){e.stopPropagation(),S();return}if(e.key===`Tab`){ee(e);return}e.stopPropagation()}),V(`click`,ue,S),U(e,t)};G(ue,e=>{t.open&&e(de)}),U(e,le),j()}zr([`click`,`keydown`]);function nv(e){return e.trial?.daysRemaining??e.daysRemaining??null}function rv(e){if(!e||!e.gateActive)return{editable:!0,showWall:!1,showTrialBanner:!1,trialDaysRemaining:null,statusLabel:``};if(e.status===`restricted`)return{editable:!1,showWall:!0,showTrialBanner:!1,trialDaysRemaining:null,statusLabel:`Trial ended`};if(e.status===`trial`){let t=nv(e);return{editable:!0,showWall:!1,showTrialBanner:!0,trialDaysRemaining:t,statusLabel:t==null?`Trial`:`Trial — ${t} day${t===1?``:`s`} left`}}return{editable:!0,showWall:!1,showTrialBanner:!1,trialDaysRemaining:null,statusLabel:e.license?.name?`Licensed to ${e.license.name}`:`Licensed`}}async function iv(e){let t=await fetch(`${Il}${Lc}`,{signal:e});if(!t.ok)throw Error(`${Lc} responded ${t.status} ${t.statusText}`);return await t.json()}async function av(e){try{let t=await fetch(`${Il}${Rc}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({license:e})}),n=await t.json().catch(()=>({}));return t.ok?{ok:!0,state:n}:{ok:!1,error:n.message??`Activation failed.`}}catch{return{ok:!1,error:`Server unavailable.`}}}var ov=6e4;function sv(){let e=N(null),t=M(()=>rv(B(e))),n=!1,r=null,i=null,a=null;function o(e){return e.gateActive&&e.status===`restricted`}function s(e){a!==null&&e!==a&&i?.(),a=e}function c(){r&&=(clearInterval(r),null),n=!1,i=null,a=null}async function l(){try{let t=await iv();P(e,t,!0),s(o(t)),t.gateActive||c()}catch{}}return{get status(){return B(e)},get ui(){return B(t)},start(e){n||(n=!0,i=e?.onTransition??null,l(),r=setInterval(()=>void l(),ov))},stop:c,refresh(){return l()},set(t){P(e,t,!0),s(o(t))}}}var cv=sv(),lv=H(`<strong data-testid="license-trial-days" class="svelte-ae26fd"> </strong> `,1),uv=H(`<div class="license-trial-banner svelte-ae26fd" role="status" aria-live="polite" data-testid="license-trial-banner"><span class="license-trial-banner__text svelte-ae26fd"><!> Activate a license in Settings → License to keep editing when it ends.</span></div>`);function dv(e,t){A(t,!0);let n=M(()=>cv.ui);var r=Yr(),i=I(r),a=e=>{var t=uv(),r=F(t),i=F(r),a=e=>{var t=lv(),r=I(t),i=F(r,!0);O(r);var a=L(r);z(()=>{W(i,B(n).trialDaysRemaining),W(a,` ${B(n).trialDaysRemaining===1?`day`:`days`} left in your Tandem trial.`)}),U(e,t)},o=e=>{U(e,Jr(`You're trying Tandem.`))};G(i,e=>{B(n).trialDaysRemaining==null?e(o,-1):e(a)}),k(),O(r),O(t),U(e,t)};G(i,e=>{B(n).showTrialBanner&&e(a)}),U(e,r),j()}var fv=H(`<div class="license-activate__error svelte-1yvc9ue" data-testid="license-activate-error" role="alert"> </div>`),pv=H(`<div class="license-activate svelte-1yvc9ue"><textarea data-testid="license-activate-input" class="license-activate__input svelte-1yvc9ue" placeholder="Paste your license key" spellcheck="false"></textarea> <!> <button type="button" class="license-activate__submit svelte-1yvc9ue" data-testid="license-activate-submit"> </button></div>`);function mv(e,t){A(t,!0);let n=N(``),r=N(null),i=N(!1);async function a(){let e=B(n).trim();if(!e){P(r,`Paste your license key first.`);return}P(i,!0),P(r,null);let a=await av(e);P(i,!1),a.ok?(cv.set(a.state),P(n,``),t.onActivated?.()):P(r,a.error,!0)}var o=pv(),s=F(o);Tn(s),q(s,`rows`,4);var c=L(s,2),l=e=>{var t=fv(),n=F(t,!0);O(t),z(()=>W(n,B(r))),U(e,t)};G(c,e=>{B(r)&&e(l)});var u=L(c,2),d=F(u,!0);O(u),O(o),z(()=>{s.disabled=B(i),u.disabled=B(i),W(d,B(i)?`Activating…`:`Activate license`)}),ia(s,()=>B(n),e=>P(n,e)),V(`click`,u,()=>void a()),U(e,o),j()}zr([`click`]);var hv=H(`<div class="license-wall-backdrop svelte-1or3b6b" data-testid="license-wall" role="dialog" aria-modal="true" aria-labelledby="license-wall-heading"><div class="license-wall-dialog svelte-1or3b6b"><h2 class="license-wall-heading svelte-1or3b6b" id="license-wall-heading">Your trial has ended</h2> <p class="license-wall-body svelte-1or3b6b">Activate a license to keep editing. Your documents stay open — you can still read and
75
+ export them, and chat with Claude.</p> <!></div></div>`);function gv(e,t){A(t,!0);let n=M(()=>cv.ui);var r=Yr(),i=I(r),a=e=>{var t=hv(),n=F(t);mv(L(F(n),4),{}),O(n),O(t),U(e,t)};G(i,e=>{B(n).showWall&&e(a)}),U(e,r),j()}var _v=e=>e;function vv(e,{delay:t=0,duration:n=400,easing:r=_v}={}){let i=+getComputedStyle(e).opacity;return{delay:t,duration:n,easing:r,css:e=>`opacity: ${e*i}`}}var yv=null;function bv(e){let t=e.decorationsMuted;try{localStorage.setItem(to,String(!t&&e.showAuthorship)),localStorage.setItem(no,JSON.stringify({comment:!t&&e.showComments,highlight:!t&&e.showHighlights,note:!t&&e.showNotes}))}catch{}}function xv(){if(yv)return yv;let e=Nl(),t=N(ln(e));return bv(e),yv={get settings(){return B(t)},updateSettings:e=>{if(B(t)._readOnly)return;let n=Pl(B(t),e);try{localStorage.setItem(Ma,JSON.stringify(n))}catch{}bv(n),P(t,n,!0)}},yv}function Sv(e,t,n,r){let i=3*e,a=3*(n-e)-i,o=1-i-a,s=3*t,c=3*(r-t)-s,l=1-s-c,u=e=>((o*e+a)*e+i)*e,d=e=>((l*e+c)*e+s)*e,f=e=>(3*o*e+2*a)*e+i,p=e=>{let t=e;for(let n=0;n<8;n++){let n=u(t)-e;if(Math.abs(n)<1e-5)return t;let r=f(t);if(Math.abs(r)<1e-6)break;t-=n/r}let n=0,r=1;t=e;for(let i=0;i<20;i++){let i=u(t)-e;if(Math.abs(i)<1e-5)break;i>0?r=t:n=t,t=(n+r)/2}return t};return e=>e<=0?0:e>=1?1:d(p(e))}var Cv=Sv(.2,.8,.2,1),wv=Sv(.4,0,.2,1),Tv=260,Ev=260,Dv=280;function Ov(e){return e?!0:typeof matchMedia<`u`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches}function kv(e){return{h:e.offsetHeight,mb:Number.parseFloat(getComputedStyle(e).marginBottom)||0}}function Av(e,{enabled:t,reduceMotion:n}){if(!t||Ov(n))return{duration:0};let{h:r,mb:i}=kv(e);return{duration:Tv,easing:Cv,css:(e,t)=>`opacity:${e}; transform:translateY(${-6*t}px); height:${e*r}px; margin-bottom:${e*i}px; overflow:clip; box-sizing:border-box;`}}function jv(e,{enabled:t,reduceMotion:n,id:r,modes:i}){let a=i?.get(r);if(i?.delete(r),!t||Ov(n))return{duration:0};let{h:o,mb:s}=kv(e),c=e=>a===`accept`?`translateY(${-8*e}px)`:a===`dismiss`?`translateX(${40*e}px) scale(${1-.04*e})`:`none`;return{duration:Ev,easing:Cv,css:(e,t)=>`opacity:${e}; height:${e*o}px; margin-bottom:${e*s}px; transform:${c(t)}; overflow:clip; box-sizing:border-box;`}}function Mv(e,{reduceMotion:t}){if(Ov(t))return{duration:0};let{h:n,mb:r}=kv(e);return{duration:Dv,easing:Cv,css:(e,t)=>`opacity:${e}; transform:translateY(${-8*t}px); height:${e*n}px; margin-bottom:${e*r}px; overflow:clip; box-sizing:border-box;`}}function Nv(e,{reduceMotion:t,exitMs:n=200}){if(Ov(t))return{duration:0};let{h:r,mb:i}=kv(e);return{duration:n,easing:wv,css:(e,t)=>`opacity:${e}; transform:translateY(${-8*t}px); height:${e*r}px; margin-bottom:${e*i}px; overflow:clip; box-sizing:border-box;`}}var Pv=new Map,Fv=480,Iv=1e3;function Lv(e,t){Pv.set(e,t),setTimeout(()=>Pv.delete(e),Iv)}function Rv(e,{id:t,reduceMotion:n}){let r=Pv.get(t);if(Pv.delete(t),!r||Ov(n))return{duration:0};let i=e.getBoundingClientRect(),a=r.left-i.left,o=r.top-i.top;return{duration:Fv,easing:Cv,css:(e,t)=>`transform:translate(${a*t}px, ${o*t}px); opacity:${.2+.8*e};`}}var zv=200;function Bv(e,{reduceMotion:t}){if(Ov(t))return{duration:0};let n=e.offsetWidth;return{duration:zv,easing:Cv,css:e=>`opacity:${e}; width:${e*n}px; min-width:0; overflow:clip; box-sizing:border-box; pointer-events:none;`}}var Vv=220;function Hv(e,{reduceMotion:t}){if(Ov(t))return{duration:0};let n=e.offsetWidth;return{duration:Vv,easing:Cv,css:e=>`opacity:${e}; width:${e*n}px; min-width:0; overflow:clip; box-sizing:border-box;`}}function Uv(e,{reduceMotion:t}){if(Ov(t))return{duration:0};let n=e.offsetWidth,r=e.offsetHeight;return{duration:440,easing:Cv,css:e=>`opacity:${e}; width:${e*n}px; height:${e*r}px; overflow:clip; box-sizing:border-box;`}}var Wv=380;function Gv(e,{reduceMotion:t}){if(Ov(t))return{duration:0};let{h:n,mb:r}=kv(e);return{duration:Wv,easing:Cv,css:e=>`opacity:${e}; height:${e*n}px; margin-bottom:${e*r}px; overflow:clip; box-sizing:border-box;`}}var Kv=H(`Detected VM subnet: <code> </code>.`,1),qv=H(`<div class="cos-error svelte-1h0desi" data-testid="cowork-onboarding-error" role="alert"> </div>`),Jv=H(`<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">Tandem will register itself as a plugin in every detected Cowork workspace so Claude in
76
+ Cowork can reach your open documents. This adds a Windows firewall rule so the Cowork VM
77
+ can connect back — admin is required once. To check it worked afterward, ask Claude in a
78
+ Cowork session to open or list your documents.</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>`),Yv=H(`<button data-testid="cowork-onboarding-learn-more-btn" class="cos-btn cos-btn--ghost svelte-1h0desi" type="button">Learn more</button>`),Xv=H(`<a class="cos-learn-more-link svelte-1h0desi" data-testid="cowork-onboarding-learn-more-link" target="_blank" rel="noreferrer">Learn more</a>`),Zv=H(`<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>`),Qv=H(`<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 $v(e,t){A(t,!0);let n=N(!1),r=N(!1),i=N(null);async function a(e,t){P(r,!0),P(i,null);try{return await e(await ah()),!0}catch(e){return P(i,`${t}: ${Km(e instanceof Error?e.message:String(e))}`),!1}finally{P(r,!1)}}async function o(){await a(async e=>{await sh(e,!0)},`Failed to enable Cowork`)&&t.onAdvance()}function s(){th(),t.onAdvance()}var c=Qv(),l=L(F(c),2),u=L(F(l)),d=e=>{var n=Kv(),r=L(I(n)),i=F(r,!0);O(r),k(),z(()=>W(i,t.status.vethernetCidr)),U(e,n)};G(u,e=>{t.status.vethernetCidr!==null&&e(d)}),O(l);var f=L(l,2),p=e=>{var t=qv(),n=F(t,!0);O(t),z(()=>W(n,B(i))),U(e,t)};G(f,e=>{B(i)&&e(p)});var m=L(f,2),h=e=>{var t=Jv(),i=L(F(t),4),a=F(i),s=L(a,2);O(i),O(t),z(()=>{a.disabled=B(r),s.disabled=B(r)}),V(`click`,a,()=>void o()),V(`click`,s,()=>{P(n,!1)}),U(e,t)},g=e=>{var i=Zv(),a=F(i),o=L(a,2),c=L(o,2),l=e=>{var n=Yv();z(()=>n.disabled=B(r)),V(`click`,n,function(...e){t.onLearnMore?.apply(this,e)}),U(e,n)},u=e=>{var t=Xv();z(()=>q(t,`href`,`${xa}#cowork`)),U(e,t)};G(c,e=>{t.onLearnMore?e(l):e(u,-1)}),O(i),z(()=>{a.disabled=B(r),o.disabled=B(r)}),V(`click`,a,()=>{P(n,!0)}),V(`click`,o,s),U(e,i)};G(m,e=>{B(n)?e(h):e(g,-1)}),O(c),U(e,c),j()}zr([`click`]);var ey=H(`<div></div>`),ty=H(`<div style="display: flex; gap: var(--tandem-space-1); margin-bottom: var(--tandem-space-3);" class="svelte-1us4jmd"></div>`),ny=H(`<div style="font-size: var(--tandem-text-sm); font-weight: 600; color: var(--tandem-fg); margin-bottom: var(--tandem-space-1);" class="svelte-1us4jmd"> </div> <div class="svelte-1us4jmd"> </div>`,1),ry=H(`<div class="svelte-1us4jmd"><!></div>`),iy=H(`<div style="display: flex; justify-content: space-between; align-items: center;" class="svelte-1us4jmd"><span style="font-size: var(--tandem-text-xs); color: var(--tandem-fg-subtle);" class="svelte-1us4jmd"> </span> <div style="display: flex; gap: 12px; align-items: center;" class="svelte-1us4jmd"><button data-testid="tutorial-dismiss-btn" style="background: none; border: none; cursor: pointer; font-size: var(--tandem-text-xs); color: var(--tandem-fg-subtle); padding: 0; text-decoration: underline;" class="svelte-1us4jmd">Dismiss tutorial</button> <button data-testid="tutorial-next-btn" style="padding: var(--tandem-space-1) var(--tandem-space-3); font-size: var(--tandem-text-xs); border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-pill); background: var(--tandem-surface); color: var(--tandem-fg-muted); cursor: pointer; font-weight: 500;" class="svelte-1us4jmd"> </button></div></div>`),ay=H(`<div data-testid="onboarding-tutorial" style="position: fixed; bottom: 48px; left: 24px; z-index: var(--tandem-z-overlay); max-width: 340px; background: var(--tandem-surface); border-left: 4px solid var(--tandem-accent); border-radius: var(--tandem-r-4); box-shadow: var(--tandem-shadow-2); padding: var(--tandem-space-4) var(--tandem-space-5); font-family: inherit;" class="svelte-1us4jmd"><!> <!> <!></div>`);function oy(e,t){A(t,!0);let n=xv(),r=M(()=>Ov(n.settings.reduceMotion)?0:220),i=[{id:`review`,title:`Review an annotation`,text:`Open the side panel and accept or dismiss one of the highlighted annotations — or turn on the margin view to see them beside the text. Ctrl+Enter accepts the selected annotation; Ctrl+Shift+Enter dismisses it.`},{id:`question`,title:`Ask a question`,text:`Select text and click Annotate, then send it to your AI assistant — or keep it as a private note to yourself. You can also use the Chat panel.`},{id:`edit`,title:`Make an edit`,text:`Click in the document and type something. All changes sync in real-time. Open a tab or scratchpad with Ctrl+N, and jump anywhere with the command palette (Ctrl+Shift+P).`},{id:`cowork`,title:`Claude Desktop Cowork detected`,text:``},{id:`complete`,title:`You're ready!`,text:`You've learned the basics. Press ? anytime for keyboard shortcuts, or Ctrl+Shift+, to customize them.`}],a=nh(),o=eh(),s=M(()=>a&&$m(t.coworkStatus,o)),c=M(()=>i.filter(e=>e.id!==`cowork`||B(s))),l=M(()=>B(c).length-1),u=M(()=>B(c)[t.currentStep]),d=M(()=>t.currentStep>=B(l)),f=M(()=>B(u)?.id===`cowork`);var p=Yr(),m=I(p),h=e=>{var n=ay(),i=F(n),a=e=>{var n=ty();fi(n,20,()=>Array.from({length:B(l)},(e,t)=>t),e=>e,(e,n)=>{var r=ey();let i;z(()=>{i=Hi(r,1,`tut-dot svelte-1us4jmd`,null,i,{"is-current":n===t.currentStep}),K(r,`width: var(--tandem-space-2); height: var(--tandem-space-2); border-radius: var(--tandem-r-circle); background: ${n<=t.currentStep?`var(--tandem-accent)`:`var(--tandem-border)`}; transition: background 0.2s;`)}),U(e,r)}),O(n),U(e,n)};G(i,e=>{B(d)||e(a)});var o=L(i,2);si(o,()=>B(u).id,e=>{var n=ry(),i=F(n),a=e=>{$v(e,{get status(){return t.coworkStatus},get onAdvance(){return t.onNext}})},o=e=>{var t=ny(),n=I(t),r=F(n,!0);O(n);var i=L(n,2),a=F(i,!0);O(i),z(()=>{W(r,B(u).title),K(i,`font-size: var(--tandem-text-base); line-height: 1.5; color: var(--tandem-fg-muted); margin-bottom: ${B(d)?0:14}px;`),W(a,B(u).text)}),U(e,t)};G(i,e=>{B(f)&&t.coworkStatus!==null?e(a):e(o,-1)}),O(n),ji(1,n,()=>vv,()=>({duration:B(r)})),U(e,n)});var s=L(o,2),c=e=>{var n=iy(),r=F(n),i=F(r);O(r);var a=L(r,2),o=F(a),s=L(o,2),c=F(s,!0);O(s),O(a),O(n),z(()=>{W(i,`Step ${t.currentStep+1} of ${B(l)??``}`),W(c,t.currentStep===B(l)-1?`Done`:`Next`)}),V(`click`,o,function(...e){t.onDismiss?.apply(this,e)}),V(`click`,s,function(...e){t.onNext?.apply(this,e)}),U(e,n)};G(s,e=>{!B(d)&&!B(f)&&e(c)}),O(n),U(e,n)};G(m,e=>{B(u)&&e(h)}),U(e,p),j()}zr([`click`]);var sy=()=>new Map,cy=e=>{let t=sy();return e.forEach((e,n)=>{t.set(n,e)}),t},ly=(e,t,n)=>{let r=e.get(t);return r===void 0&&e.set(t,r=n()),r},uy=(e,t)=>{let n=[];for(let[r,i]of e)n.push(t(i,r));return n},dy=(e,t)=>{for(let[n,r]of e)if(t(r,n))return!0;return!1},fy=()=>new Set,py=e=>e[e.length-1],my=(e,t)=>{for(let n=0;n<t.length;n++)e.push(t[n])},hy=Array.from,gy=(e,t)=>{for(let n=0;n<e.length;n++)if(!t(e[n],n,e))return!1;return!0},_y=(e,t)=>{for(let n=0;n<e.length;n++)if(t(e[n],n,e))return!0;return!1},vy=(e,t)=>{let n=Array(e);for(let r=0;r<e;r++)n[r]=t(r,n);return n},yy=Array.isArray,by=class{constructor(){this._observers=sy()}on(e,t){return ly(this._observers,e,fy).add(t),t}once(e,t){let n=(...r)=>{this.off(e,n),t(...r)};this.on(e,n)}off(e,t){let n=this._observers.get(e);n!==void 0&&(n.delete(t),n.size===0&&this._observers.delete(e))}emit(e,t){return hy((this._observers.get(e)||sy()).values()).forEach(e=>e(...t))}destroy(){this._observers=sy()}},xy=Math.floor,Sy=Math.abs,Cy=(e,t)=>e<t?e:t,wy=(e,t)=>e>t?e:t;Number.isNaN;var Ty=e=>e===0?1/e<0:e<0,Ey=1<<17,Dy=1<<18,Oy=1<<19,ky=1<<20,Ay=1<<21,jy=1<<22,My=1<<23,Ny=1<<24,Py=1<<25,Fy=1<<26,Iy=1<<27,Ly=1<<28,Ry=1<<29;Ey-1,Dy-1,Oy-1,ky-1,Ay-1,jy-1,My-1,Ny-1,Py-1,Fy-1,Iy-1,Ly-1,Ry-1;var zy=2**53-1,By=-(2**53-1),Vy=Number.isInteger||(e=>typeof e==`number`&&isFinite(e)&&xy(e)===e);Number.isNaN,Number.parseInt;var Hy=String.fromCharCode;String.fromCodePoint,Hy(65535);var Uy=e=>e.toLowerCase(),Wy=/^\s*/g,Gy=e=>e.replace(Wy,``),Ky=/([A-Z])/g,qy=(e,t)=>Gy(e.replace(Ky,e=>`${t}${Uy(e)}`)),Jy=e=>{let t=unescape(encodeURIComponent(e)),n=t.length,r=new Uint8Array(n);for(let e=0;e<n;e++)r[e]=t.codePointAt(e);return r},Yy=typeof TextEncoder<`u`?new TextEncoder:null,Xy=Yy?e=>Yy.encode(e):Jy,Zy=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});Zy&&Zy.decode(new Uint8Array).length===1&&(Zy=null);var Qy=(e,t)=>vy(t,()=>e).join(``),$y=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}},eb=()=>new $y,tb=e=>{let t=eb();return e(t),rb(t)},nb=e=>{let t=e.cpos;for(let n=0;n<e.bufs.length;n++)t+=e.bufs[n].length;return t},rb=e=>{let t=new Uint8Array(nb(e)),n=0;for(let r=0;r<e.bufs.length;r++){let i=e.bufs[r];t.set(i,n),n+=i.length}return t.set(new Uint8Array(e.cbuf.buffer,0,e.cpos),n),t},ib=(e,t)=>{let n=e.cbuf.length;n-e.cpos<t&&(e.bufs.push(new Uint8Array(e.cbuf.buffer,0,e.cpos)),e.cbuf=new Uint8Array(wy(n,t)*2),e.cpos=0)},ab=(e,t)=>{let n=e.cbuf.length;e.cpos===n&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(n*2),e.cpos=0),e.cbuf[e.cpos++]=t},ob=ab,sb=(e,t)=>{for(;t>127;)ab(e,128|127&t),t=xy(t/128);ab(e,127&t)},cb=(e,t)=>{let n=Ty(t);for(n&&(t=-t),ab(e,(t>63?128:0)|(n?64:0)|63&t),t=xy(t/64);t>0;)ab(e,(t>127?128:0)|127&t),t=xy(t/128)},lb=new Uint8Array(3e4),ub=lb.length/3,db=Yy&&Yy.encodeInto?(e,t)=>{if(t.length<ub){let n=Yy.encodeInto(t,lb).written||0;sb(e,n);for(let t=0;t<n;t++)ab(e,lb[t])}else pb(e,Xy(t))}:(e,t)=>{let n=unescape(encodeURIComponent(t)),r=n.length;sb(e,r);for(let t=0;t<r;t++)ab(e,n.codePointAt(t))},fb=(e,t)=>{let n=e.cbuf.length,r=e.cpos,i=Cy(n-r,t.length),a=t.length-i;e.cbuf.set(t.subarray(0,i),r),e.cpos+=i,a>0&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(wy(n*2,a)),e.cbuf.set(t.subarray(i)),e.cpos=a)},pb=(e,t)=>{sb(e,t.byteLength),fb(e,t)},mb=(e,t)=>{ib(e,t);let n=new DataView(e.cbuf.buffer,e.cpos,t);return e.cpos+=t,n},hb=(e,t)=>mb(e,4).setFloat32(0,t,!1),gb=(e,t)=>mb(e,8).setFloat64(0,t,!1),_b=(e,t)=>mb(e,8).setBigInt64(0,t,!1),vb=new DataView(new ArrayBuffer(4)),yb=e=>(vb.setFloat32(0,e),vb.getFloat32(0)===e),bb=(e,t)=>{switch(typeof t){case`string`:ab(e,119),db(e,t);break;case`number`:Vy(t)&&Sy(t)<=2147483647?(ab(e,125),cb(e,t)):yb(t)?(ab(e,124),hb(e,t)):(ab(e,123),gb(e,t));break;case`bigint`:ab(e,122),_b(e,t);break;case`object`:if(t===null)ab(e,126);else if(yy(t)){ab(e,117),sb(e,t.length);for(let n=0;n<t.length;n++)bb(e,t[n])}else if(t instanceof Uint8Array)ab(e,116),pb(e,t);else{ab(e,118);let n=Object.keys(t);sb(e,n.length);for(let r=0;r<n.length;r++){let i=n[r];db(e,i),bb(e,t[i])}}break;case`boolean`:ab(e,t?120:121);break;default:ab(e,127)}},xb=class extends $y{constructor(e){super(),this.w=e,this.s=null,this.count=0}write(e){this.s===e?this.count++:(this.count>0&&sb(this,this.count-1),this.count=1,this.w(this,e),this.s=e)}},Sb=e=>{e.count>0&&(cb(e.encoder,e.count===1?e.s:-e.s),e.count>1&&sb(e.encoder,e.count-2))},Cb=class{constructor(){this.encoder=new $y,this.s=0,this.count=0}write(e){this.s===e?this.count++:(Sb(this),this.count=1,this.s=e)}toUint8Array(){return Sb(this),rb(this.encoder)}},wb=e=>{if(e.count>0){let t=e.diff*2+(e.count===1?0:1);cb(e.encoder,t),e.count>1&&sb(e.encoder,e.count-2)}},Tb=class{constructor(){this.encoder=new $y,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(wb(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return wb(this),rb(this.encoder)}},Eb=class{constructor(){this.sarr=[],this.s=``,this.lensE=new Cb}write(e){this.s+=e,this.s.length>19&&(this.sarr.push(this.s),this.s=``),this.lensE.write(e.length)}toUint8Array(){let e=new $y;return this.sarr.push(this.s),this.s=``,db(e,this.sarr.join(``)),fb(e,this.lensE.toUint8Array()),rb(e)}},Db=e=>Error(e),Ob=()=>{throw Db(`Method unimplemented`)},kb=()=>{throw Db(`Unexpected case`)},Ab=Db(`Unexpected end of array`),jb=Db(`Integer out of Range`),Mb=class{constructor(e){this.arr=e,this.pos=0}},Nb=e=>new Mb(e),Pb=e=>e.pos!==e.arr.length,Fb=(e,t)=>{let n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n},Ib=e=>Fb(e,Rb(e)),Lb=e=>e.arr[e.pos++],Rb=e=>{let t=0,n=1,r=e.arr.length;for(;e.pos<r;){let r=e.arr[e.pos++];if(t+=(r&127)*n,n*=128,r<128)return t;if(t>zy)throw jb}throw Ab},zb=e=>{let t=e.arr[e.pos++],n=t&63,r=64,i=(t&64)>0?-1:1;if(!(t&128))return i*n;let a=e.arr.length;for(;e.pos<a;){if(t=e.arr[e.pos++],n+=(t&127)*r,r*=128,t<128)return i*n;if(n>zy)throw jb}throw Ab},Bb=Zy?e=>Zy.decode(Ib(e)):e=>{let t=Rb(e);if(t===0)return``;{let n=String.fromCodePoint(Lb(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(Lb(e));else for(;t>0;){let r=t<1e4?t:1e4,i=e.arr.subarray(e.pos,e.pos+r);e.pos+=r,n+=String.fromCodePoint.apply(null,i),t-=r}return decodeURIComponent(escape(n))}},Vb=(e,t)=>{let n=new DataView(e.arr.buffer,e.arr.byteOffset+e.pos,t);return e.pos+=t,n},Hb=[e=>void 0,e=>null,zb,e=>Vb(e,4).getFloat32(0,!1),e=>Vb(e,8).getFloat64(0,!1),e=>Vb(e,8).getBigInt64(0,!1),e=>!1,e=>!0,Bb,e=>{let t=Rb(e),n={};for(let r=0;r<t;r++){let t=Bb(e);n[t]=Ub(e)}return n},e=>{let t=Rb(e),n=[];for(let r=0;r<t;r++)n.push(Ub(e));return n},Ib],Ub=e=>Hb[127-Lb(e)](e),Wb=class extends Mb{constructor(e,t){super(e),this.reader=t,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),Pb(this)?this.count=Rb(this)+1:this.count=-1),this.count--,this.s}},Gb=class extends Mb{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=zb(this);let e=Ty(this.s);this.count=1,e&&(this.s=-this.s,this.count=Rb(this)+2)}return this.count--,this.s}},Kb=class extends Mb{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){let e=zb(this),t=e&1;this.diff=xy(e/2),this.count=1,t&&(this.count=Rb(this)+2)}return this.s+=this.diff,this.count--,this.s}},qb=class{constructor(e){this.decoder=new Gb(e),this.str=Bb(this.decoder),this.spos=0}read(){let e=this.spos+this.decoder.read(),t=this.str.slice(this.spos,e);return this.spos=e,t}};crypto.subtle;var Jb=crypto.getRandomValues.bind(crypto),Yb=Math.random,Xb=()=>Jb(new Uint32Array(1))[0],Zb=e=>e[xy(Yb()*e.length)],Qb=`10000000-1000-4000-8000-100000000000`,$b=()=>Qb.replace(/[018]/g,e=>(e^Xb()&15>>e/4).toString(16)),ex=Date.now,tx=e=>new Promise(e);Promise.all.bind(Promise);var nx=e=>e===void 0?null:e,rx=new class{constructor(){this.map=new Map}setItem(e,t){this.map.set(e,t)}getItem(e){return this.map.get(e)}};try{typeof localStorage<`u`&&localStorage&&(rx=localStorage)}catch{}var ix=rx,ax=Symbol(`Equality`),ox=(e,t)=>e===t||!!e?.[ax]?.(t)||!1,sx=e=>typeof e==`object`,cx=Object.assign,lx=Object.keys,ux=(e,t)=>{for(let n in e)t(e[n],n)},dx=e=>lx(e).length,fx=e=>{for(let t in e)return!1;return!0},px=(e,t)=>{for(let n in e)if(!t(e[n],n))return!1;return!0},mx=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),hx=(e,t)=>e===t||dx(e)===dx(t)&&px(e,(e,n)=>(e!==void 0||mx(t,n))&&ox(t[n],e)),gx=Object.freeze,_x=e=>{for(let t in e){let n=e[t];(typeof n==`object`||typeof n==`function`)&&_x(e[t])}return gx(e)},vx=(e,t,n=0)=>{try{for(;n<e.length;n++)e[n](...t)}finally{n<e.length&&vx(e,t,n+1)}},yx=e=>e,bx=(e,t)=>{if(e===t)return!0;if(e==null||t==null||e.constructor!==t.constructor&&(e.constructor||Object)!==(t.constructor||Object))return!1;if(e[ax]!=null)return e[ax](t);switch(e.constructor){case ArrayBuffer:e=new Uint8Array(e),t=new Uint8Array(t);case Uint8Array:if(e.byteLength!==t.byteLength)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;break;case Set:if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;break;case Map:if(e.size!==t.size)return!1;for(let n of e.keys())if(!t.has(n)||!bx(e.get(n),t.get(n)))return!1;break;case void 0:case Object:if(dx(e)!==dx(t))return!1;for(let n in e)if(!mx(e,n)||!bx(e[n],t[n]))return!1;break;case Array:if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!bx(e[n],t[n]))return!1;break;default:return!1}return!0},xx=(e,t)=>t.includes(e),Sx=typeof process<`u`&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<`u`?process:0)===`[object process]`,Cx=typeof window<`u`&&typeof document<`u`&&!Sx;typeof navigator<`u`&&/Mac/.test(navigator.platform);var wx,Tx=[],Ex=()=>{if(wx===void 0)if(Sx){wx=sy();let e=process.argv,t=null;for(let n=0;n<e.length;n++){let r=e[n];r[0]===`-`?(t!==null&&wx.set(t,``),t=r):t===null?Tx.push(r):(wx.set(t,r),t=null)}t!==null&&wx.set(t,``)}else typeof location==`object`?(wx=sy(),(location.search||`?`).slice(1).split(`&`).forEach(e=>{if(e.length!==0){let[t,n]=e.split(`=`);wx.set(`--${qy(t,`-`)}`,n),wx.set(`-${qy(t,`-`)}`,n)}})):wx=sy();return wx},Dx=e=>Ex().has(e),Ox=e=>nx(Sx?{}[e.toUpperCase().replaceAll(`-`,`_`)]:ix.getItem(e)),kx=e=>Dx(`--`+e)||Ox(e)!==null,Ax=kx(`production`),jx=Sx&&xx({}.FORCE_COLOR,[`true`,`1`,`2`])||!Dx(`--no-colors`)&&!kx(`no-color`)&&(!Sx||process.stdout.isTTY)&&(!Sx||Dx(`--color`)||Ox(`COLORTERM`)!==null||(Ox(`TERM`)||``).includes(`color`)),Mx=e=>new Uint8Array(e),Nx=Cx?e=>{let t=``;for(let n=0;n<e.byteLength;n++)t+=Hy(e[n]);return btoa(t)}:e=>Buffer.from(e.buffer,e.byteOffset,e.byteLength).toString(`base64`),Px=e=>{let t=Mx(e.byteLength);return t.set(e),t},Fx=e=>tb(t=>bb(t,e)),Ix=class{constructor(e,t){this.left=e,this.right=t}},Lx=(e,t)=>new Ix(e,t),Rx=e=>e.next()>=.5,zx=(e,t,n)=>xy(e.next()*(n+1-t)+t),Bx=(e,t,n)=>xy(e.next()*(n+1-t)+t),Vx=(e,t,n)=>Bx(e,t,n),Hx=e=>Hy(Vx(e,97,122)),Ux=(e,t=0,n=20)=>{let r=Vx(e,t,n),i=``;for(let t=0;t<r;t++)i+=Hx(e);return i},Wx=(e,t)=>t[Vx(e,0,t.length-1)],Gx=Symbol(`0schema`),Kx=class{constructor(){this._rerrs=[]}extend(e,t,n,r=null){this._rerrs.push({path:e,expected:t,has:n,message:r})}toString(){let e=[];for(let t=this._rerrs.length-1;t>0;t--){let n=this._rerrs[t];e.push(Qy(` `,(this._rerrs.length-t)*2)+`${n.path==null?``:`[${n.path}] `}${n.has} doesn't match ${n.expected}. ${n.message}`)}return e.join(`
79
+ `)}},qx=(e,t)=>e===t?!0:e==null||t==null||e.constructor!==t.constructor?!1:e[ax]?ox(e,t):yy(e)?gy(e,e=>_y(t,t=>qx(e,t))):sx(e)?px(e,(e,n)=>qx(e,t[n])):!1,Jx=class{static _dilutes=!1;extends(e){let[t,n]=[this.shape,e.shape];return this.constructor._dilutes&&([n,t]=[t,n]),qx(t,n)}equals(e){return this.constructor===e.constructor&&bx(this.shape,e.shape)}[Gx](){return!0}[ax](e){return this.equals(e)}validate(e){return this.check(e)}check(e,t){Ob()}get nullable(){return DS(this,HS)}get optional(){return new aS(this)}cast(e){return KS(e,this),e}expect(e){return KS(e,this),e}},Yx=class extends Jx{constructor(e,t){super(),this.shape=e,this._c=t}check(e,t=void 0){let n=e?.constructor===this.shape&&(this._c==null||this._c(e));return!n&&t?.extend(null,this.shape.name,e?.constructor.name,e?.constructor===this.shape?`Check failed`:`Constructor match failed`),n}},Xx=(e,t=null)=>new Yx(e,t);Xx(Yx);var Zx=class extends Jx{constructor(e){super(),this.shape=e}check(e,t){let n=this.shape(e);return!n&&t?.extend(null,`custom prop`,e?.constructor.name,`failed to check custom prop`),n}},Qx=e=>new Zx(e);Xx(Zx);var $x=class extends Jx{constructor(e){super(),this.shape=e}check(e,t){let n=this.shape.some(t=>t===e);return!n&&t?.extend(null,this.shape.join(` | `),e.toString()),n}},eS=(...e)=>new $x(e),tS=Xx($x),nS=RegExp.escape||(e=>e.replace(/[().|&,$^[\]]/g,e=>`\\`+e)),rS=e=>{if(LS.check(e))return[nS(e)];if(tS.check(e))return e.shape.map(e=>e+``);if(IS.check(e))return[`[+-]?\\d+.?\\d*`];if(RS.check(e))return[`.*`];if(OS.check(e))return e.shape.map(rS).flat(1);kb()};Xx(class extends Jx{constructor(e){super(),this.shape=e,this._r=RegExp(`^`+e.map(rS).map(e=>`(${e.join(`|`)})`).join(``)+`$`)}check(e,t){let n=this._r.exec(e)!=null;return!n&&t?.extend(null,this._r.toString(),e.toString(),`String doesn't match string template.`),n}});var iS=Symbol(`optional`),aS=class extends Jx{constructor(e){super(),this.shape=e}check(e,t){let n=e===void 0||this.shape.check(e);return!n&&t?.extend(null,`undefined (optional)`,`()`),n}get[iS](){return!0}},oS=Xx(aS),sS=class extends Jx{check(e,t){return t?.extend(null,`never`,typeof e),!1}};new sS,Xx(sS);var cS=class e extends Jx{constructor(e,t=!1){super(),this.shape=e,this._isPartial=t}static _dilutes=!0;get partial(){return new e(this.shape,!0)}check(e,t){return e==null?(t?.extend(null,`object`,`null`),!1):px(this.shape,(n,r)=>{let i=this._isPartial&&!mx(e,r)||n.check(e[r],t);return!i&&t?.extend(r.toString(),n.toString(),typeof e[r],`Object property does not match`),i})}},lS=e=>new cS(e),uS=Xx(cS),dS=Qx(e=>e!=null&&(e.constructor===Object||e.constructor==null)),fS=class extends Jx{constructor(e,t){super(),this.shape={keys:e,values:t}}check(e,t){return e!=null&&px(e,(n,r)=>{let i=this.shape.keys.check(r,t);return!i&&t?.extend(r+``,`Record`,typeof e,i?`Key doesn't match schema`:`Value doesn't match value`),i&&this.shape.values.check(n,t)})}},pS=(e,t)=>new fS(e,t),mS=Xx(fS),hS=class extends Jx{constructor(e){super(),this.shape=e}check(e,t){return e!=null&&px(this.shape,(n,r)=>{let i=n.check(e[r],t);return!i&&t?.extend(r.toString(),`Tuple`,typeof n),i})}},gS=(...e)=>new hS(e);Xx(hS);var _S=class extends Jx{constructor(e){super(),this.shape=e.length===1?e[0]:new ES(e)}check(e,t){let n=yy(e)&&gy(e,e=>this.shape.check(e));return!n&&t?.extend(null,`Array`,``),n}},vS=(...e)=>new _S(e),yS=Xx(_S),bS=Qx(e=>yy(e)),xS=class extends Jx{constructor(e,t){super(),this.shape=e,this._c=t}check(e,t){let n=e instanceof this.shape&&(this._c==null||this._c(e));return!n&&t?.extend(null,this.shape.name,e?.constructor.name),n}},SS=(e,t=null)=>new xS(e,t);Xx(xS);var CS=SS(Jx),wS=Xx(class extends Jx{constructor(e){super(),this.len=e.length-1,this.args=gS(...e.slice(-1)),this.res=e[this.len]}check(e,t){let n=e.constructor===Function&&e.length<=this.len;return!n&&t?.extend(null,`function`,typeof e),n}}),TS=Qx(e=>typeof e==`function`);Xx(class extends Jx{constructor(e){super(),this.shape=e}check(e,t){let n=gy(this.shape,n=>n.check(e,t));return!n&&t?.extend(null,`Intersectinon`,typeof e),n}},e=>e.shape.length>0);var ES=class extends Jx{static _dilutes=!0;constructor(e){super(),this.shape=e}check(e,t){let n=_y(this.shape,n=>n.check(e,t));return t?.extend(null,`Union`,typeof e),n}},DS=(...e)=>e.findIndex(e=>OS.check(e))>=0?DS(...e.map(e=>GS(e)).map(e=>OS.check(e)?e.shape:[e]).flat(1)):e.length===1?e[0]:new ES(e),OS=Xx(ES),kS=()=>!0,AS=Qx(kS),jS=Xx(Zx,e=>e.shape===kS),MS=Qx(e=>typeof e==`bigint`),NS=Qx(e=>e===MS),PS=Qx(e=>typeof e==`symbol`);Qx(e=>e===PS);var FS=Qx(e=>typeof e==`number`),IS=Qx(e=>e===FS),LS=Qx(e=>typeof e==`string`),RS=Qx(e=>e===LS),zS=Qx(e=>typeof e==`boolean`),BS=Qx(e=>e===zS),VS=eS(void 0);Xx($x,e=>e.shape.length===1&&e.shape[0]===void 0),eS(void 0);var HS=eS(null),US=Xx($x,e=>e.shape.length===1&&e.shape[0]===null);Xx(Uint8Array),Xx(Yx,e=>e.shape===Uint8Array);var WS=DS(FS,LS,HS,VS,MS,zS,PS);(()=>{let e=vS(AS),t=pS(LS,AS),n=DS(FS,LS,HS,zS,e,t);return e.shape=n,t.shape.values=n,n})();var GS=e=>{if(CS.check(e))return e;if(dS.check(e)){let t={};for(let n in e)t[n]=GS(e[n]);return lS(t)}else if(bS.check(e))return DS(...e.map(GS));else if(WS.check(e))return eS(e);else if(TS.check(e))return Xx(e);kb()},KS=Ax?()=>{}:(e,t)=>{let n=new Kx;if(!t.check(e,n))throw Db(`Expected value to be of type ${t.constructor.name}.\n${n.toString()}`)},qS=class{constructor(e){this.patterns=[],this.$state=e}if(e,t){return this.patterns.push({if:GS(e),h:t}),this}else(e){return this.if(AS,e)}done(){return(e,t)=>{for(let n=0;n<this.patterns.length;n++){let r=this.patterns[n];if(r.if.check(e))return r.h(e,t)}throw Db(`Unhandled pattern`)}}},JS=(e=>new qS(e))(AS).if(IS,(e,t)=>zx(t,By,zy)).if(RS,(e,t)=>Ux(t)).if(BS,(e,t)=>Rx(t)).if(NS,(e,t)=>BigInt(zx(t,By,zy))).if(OS,(e,t)=>YS(t,Wx(t,e.shape))).if(uS,(e,t)=>{let n={};for(let r in e.shape){let i=e.shape[r];if(oS.check(i)){if(Rx(t))continue;i=i.shape}n[r]=JS(i,t)}return n}).if(yS,(e,t)=>{let n=[],r=Bx(t,0,42);for(let i=0;i<r;i++)n.push(YS(t,e.shape));return n}).if(tS,(e,t)=>Wx(t,e.shape)).if(US,(e,t)=>null).if(wS,(e,t)=>{let n=YS(t,e.res);return()=>n}).if(jS,(e,t)=>YS(t,Wx(t,[FS,LS,HS,VS,MS,zS,vS(FS),pS(DS(`a`,`b`,`c`),FS)]))).if(mS,(e,t)=>{let n={},r=zx(t,0,3);for(let i=0;i<r;i++){let r=YS(t,e.shape.keys);n[r]=YS(t,e.shape.values)}return n}).done(),YS=(e,t)=>JS(GS(t),e),XS=typeof document<`u`?document:{};Qx(e=>e.nodeType===tC),typeof DOMParser<`u`&&new DOMParser,Qx(e=>e.nodeType===QS),Qx(e=>e.nodeType===$S);var ZS=e=>uy(e,(e,t)=>`${t}:${e};`).join(``),QS=XS.ELEMENT_NODE,$S=XS.TEXT_NODE;XS.CDATA_SECTION_NODE,XS.COMMENT_NODE;var eC=XS.DOCUMENT_NODE;XS.DOCUMENT_TYPE_NODE;var tC=XS.DOCUMENT_FRAGMENT_NODE;Qx(e=>e.nodeType===eC);var nC=(e=>class{constructor(e){this._=e}destroy(){e(this._)}})(clearTimeout),rC=(e,t)=>new nC(setTimeout(t,e)),iC=Symbol,aC=iC(),oC=iC(),sC=iC(),cC=iC(),lC=iC(),uC=iC(),dC=iC(),fC=iC(),pC=iC(),mC=e=>{e.length===1&&e[0]?.constructor===Function&&(e=e[0]());let t=[],n=[],r=0;for(;r<e.length;r++){let n=e[r];if(n===void 0)break;if(n.constructor===String||n.constructor===Number)t.push(n);else if(n.constructor===Object)break}for(r>0&&n.push(t.join(``));r<e.length;r++){let t=e[r];t instanceof Symbol||n.push(t)}return n};ex();var hC={[aC]:Lx(`font-weight`,`bold`),[oC]:Lx(`font-weight`,`normal`),[sC]:Lx(`color`,`blue`),[lC]:Lx(`color`,`green`),[cC]:Lx(`color`,`grey`),[uC]:Lx(`color`,`red`),[dC]:Lx(`color`,`purple`),[fC]:Lx(`color`,`orange`),[pC]:Lx(`color`,`black`)},gC=jx?e=>{e.length===1&&e[0]?.constructor===Function&&(e=e[0]());let t=[],n=[],r=sy(),i=[],a=0;for(;a<e.length;a++){let i=e[a],o=hC[i];if(o!==void 0)r.set(o.left,o.right);else{if(i===void 0)break;if(i.constructor===String||i.constructor===Number){let e=ZS(r);a>0||e.length>0?(t.push(`%c`+i),n.push(e)):t.push(i)}else break}}for(a>0&&(i=n,i.unshift(t.join(``)));a<e.length;a++){let t=e[a];t instanceof Symbol||i.push(t)}return i}:mC,_C=(...e)=>{console.log(...gC(e)),yC.forEach(t=>t.print(e))},vC=(...e)=>{console.warn(...gC(e)),e.unshift(fC),yC.forEach(t=>t.print(e))},yC=fy(),bC=e=>({[Symbol.iterator](){return this},next:e}),xC=(e,t)=>bC(()=>{let n;do n=e.next();while(!n.done&&!t(n.value));return n}),SC=(e,t)=>bC(()=>{let{done:n,value:r}=e.next();return{done:n,value:n?void 0:t(r)}}),CC=class{constructor(e,t){this.clock=e,this.len=t}},wC=class{constructor(){this.clients=new Map}},TC=(e,t,n)=>t.clients.forEach((t,r)=>{let i=e.doc.store.clients.get(r);if(i!=null){let r=i[i.length-1],a=r.id.clock+r.length;for(let r=0,o=t[r];r<t.length&&o.clock<a;o=t[++r])Uw(e,i,o.clock,o.len,n)}}),EC=(e,t)=>{let n=0,r=e.length-1;for(;n<=r;){let i=xy((n+r)/2),a=e[i],o=a.clock;if(o<=t){if(t<o+a.len)return i;n=i+1}else r=i-1}return null},DC=(e,t)=>{let n=e.clients.get(t.client);return n!==void 0&&EC(n,t.clock)!==null},OC=e=>{e.clients.forEach(e=>{e.sort((e,t)=>e.clock-t.clock);let t,n;for(t=1,n=1;t<e.length;t++){let r=e[n-1],i=e[t];r.clock+r.len>=i.clock?e[n-1]=new CC(r.clock,wy(r.len,i.clock+i.len-r.clock)):(n<t&&(e[n]=i),n++)}e.length=n})},kC=e=>{let t=new wC;for(let n=0;n<e.length;n++)e[n].clients.forEach((r,i)=>{if(!t.clients.has(i)){let a=r.slice();for(let t=n+1;t<e.length;t++)my(a,e[t].clients.get(i)||[]);t.clients.set(i,a)}});return OC(t),t},AC=(e,t,n,r)=>{ly(e.clients,t,()=>[]).push(new CC(n,r))},jC=()=>new wC,MC=e=>{let t=jC();return e.clients.forEach((e,n)=>{let r=[];for(let t=0;t<e.length;t++){let n=e[t];if(n.deleted){let i=n.id.clock,a=n.length;if(t+1<e.length)for(let n=e[t+1];t+1<e.length&&n.deleted;n=e[++t+1])a+=n.length;r.push(new CC(i,a))}}r.length>0&&t.clients.set(n,r)}),t},NC=(e,t)=>{sb(e.restEncoder,t.clients.size),hy(t.clients.entries()).sort((e,t)=>t[0]-e[0]).forEach(([t,n])=>{e.resetDsCurVal(),sb(e.restEncoder,t);let r=n.length;sb(e.restEncoder,r);for(let t=0;t<r;t++){let r=n[t];e.writeDsClock(r.clock),e.writeDsLen(r.len)}})},PC=e=>{let t=new wC,n=Rb(e.restDecoder);for(let r=0;r<n;r++){e.resetDsCurVal();let n=Rb(e.restDecoder),r=Rb(e.restDecoder);if(r>0){let i=ly(t.clients,n,()=>[]);for(let t=0;t<r;t++)i.push(new CC(e.readDsClock(),e.readDsLen()))}}return t},FC=(e,t,n)=>{let r=new wC,i=Rb(e.restDecoder);for(let a=0;a<i;a++){e.resetDsCurVal();let i=Rb(e.restDecoder),a=Rb(e.restDecoder),o=n.clients.get(i)||[],s=Fw(n,i);for(let n=0;n<a;n++){let n=e.readDsClock(),a=n+e.readDsLen();if(n<s){s<a&&AC(r,i,s,a-s);let e=Lw(o,n),c=o[e];for(!c.deleted&&c.id.clock<n&&(o.splice(e+1,0,oD(t,c,n-c.id.clock)),e++);e<o.length&&(c=o[e++],c.id.clock<a);)c.deleted||(a<c.id.clock+c.length&&o.splice(e,0,oD(t,c,a-c.id.clock)),c.delete(t))}else AC(r,i,n,a-n)}}if(r.clients.size>0){let e=new GC;return sb(e.restEncoder,0),NC(e,r),e.toUint8Array()}return null},IC=Xb,LC=class e extends by{constructor({guid:e=$b(),collectionid:t=null,gc:n=!0,gcFilter:r=()=>!0,meta:i=null,autoLoad:a=!1,shouldLoad:o=!0}={}){super(),this.gc=n,this.gcFilter=r,this.clientID=IC(),this.guid=e,this.collectionid=t,this.share=new Map,this.store=new Nw,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=o,this.autoLoad=a,this.meta=i,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=tx(e=>{this.on(`load`,()=>{this.isLoaded=!0,e(this)})});let s=()=>tx(e=>{let t=n=>{(n===void 0||n===!0)&&(this.off(`sync`,t),e())};this.on(`sync`,t)});this.on(`sync`,e=>{e===!1&&this.isSynced&&(this.whenSynced=s()),this.isSynced=e===void 0||e===!0,this.isSynced&&!this.isLoaded&&this.emit(`load`,[this])}),this.whenSynced=s()}load(){let e=this._item;e!==null&&!this.shouldLoad&&Zw(e.parent.doc,e=>{e.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(hy(this.subdocs).map(e=>e.guid))}transact(e,t=null){return Zw(this,e,t)}get(e,t=DT){let n=ly(this.share,e,()=>{let e=new t;return e._integrate(this,null),e}),r=n.constructor;if(t!==DT&&r!==t)if(r===DT){let r=new t;r._map=n._map,n._map.forEach(e=>{for(;e!==null;e=e.left)e.parent=r}),r._start=n._start;for(let e=r._start;e!==null;e=e.right)e.parent=r;return r._length=n._length,this.share.set(e,r),r._integrate(this,null),r}else throw Error(`Type with the name ${e} has already been defined with a different constructor`);return n}getArray(e=``){return this.get(e,JT)}getText(e=``){return this.get(e,hE)}getMap(e=``){return this.get(e,ZT)}getXmlElement(e=``){return this.get(e,bE)}getXmlFragment(e=``){return this.get(e,vE)}toJSON(){let e={};return this.share.forEach((t,n)=>{e[n]=t.toJSON()}),e}destroy(){this.isDestroyed=!0,hy(this.subdocs).forEach(e=>e.destroy());let t=this._item;if(t!==null){this._item=null;let n=t.content;n.doc=new e({guid:this.guid,...n.opts,shouldLoad:!1}),n.doc._item=t,Zw(t.parent.doc,e=>{let r=n.doc;t.deleted||e.subdocsAdded.add(r),e.subdocsRemoved.add(this)},null,!0)}this.emit(`destroyed`,[!0]),this.emit(`destroy`,[this]),super.destroy()}},RC=class{constructor(e){this.restDecoder=e}resetDsCurVal(){}readDsClock(){return Rb(this.restDecoder)}readDsLen(){return Rb(this.restDecoder)}},zC=class extends RC{readLeftID(){return gw(Rb(this.restDecoder),Rb(this.restDecoder))}readRightID(){return gw(Rb(this.restDecoder),Rb(this.restDecoder))}readClient(){return Rb(this.restDecoder)}readInfo(){return Lb(this.restDecoder)}readString(){return Bb(this.restDecoder)}readParentInfo(){return Rb(this.restDecoder)===1}readTypeRef(){return Rb(this.restDecoder)}readLen(){return Rb(this.restDecoder)}readAny(){return Ub(this.restDecoder)}readBuf(){return Px(Ib(this.restDecoder))}readJSON(){return JSON.parse(Bb(this.restDecoder))}readKey(){return Bb(this.restDecoder)}},BC=class{constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=Rb(this.restDecoder),this.dsCurrVal}readDsLen(){let e=Rb(this.restDecoder)+1;return this.dsCurrVal+=e,e}},VC=class extends BC{constructor(e){super(e),this.keys=[],Rb(e),this.keyClockDecoder=new Kb(Ib(e)),this.clientDecoder=new Gb(Ib(e)),this.leftClockDecoder=new Kb(Ib(e)),this.rightClockDecoder=new Kb(Ib(e)),this.infoDecoder=new Wb(Ib(e),Lb),this.stringDecoder=new qb(Ib(e)),this.parentInfoDecoder=new Wb(Ib(e),Lb),this.typeRefDecoder=new Gb(Ib(e)),this.lenDecoder=new Gb(Ib(e))}readLeftID(){return new mw(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new mw(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 Ub(this.restDecoder)}readBuf(){return Ib(this.restDecoder)}readJSON(){return Ub(this.restDecoder)}readKey(){let e=this.keyClockDecoder.read();if(e<this.keys.length)return this.keys[e];{let e=this.stringDecoder.read();return this.keys.push(e),e}}},HC=class{constructor(){this.restEncoder=eb()}toUint8Array(){return rb(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){sb(this.restEncoder,e)}writeDsLen(e){sb(this.restEncoder,e)}},UC=class extends HC{writeLeftID(e){sb(this.restEncoder,e.client),sb(this.restEncoder,e.clock)}writeRightID(e){sb(this.restEncoder,e.client),sb(this.restEncoder,e.clock)}writeClient(e){sb(this.restEncoder,e)}writeInfo(e){ob(this.restEncoder,e)}writeString(e){db(this.restEncoder,e)}writeParentInfo(e){sb(this.restEncoder,+!!e)}writeTypeRef(e){sb(this.restEncoder,e)}writeLen(e){sb(this.restEncoder,e)}writeAny(e){bb(this.restEncoder,e)}writeBuf(e){pb(this.restEncoder,e)}writeJSON(e){db(this.restEncoder,JSON.stringify(e))}writeKey(e){db(this.restEncoder,e)}},WC=class{constructor(){this.restEncoder=eb(),this.dsCurrVal=0}toUint8Array(){return rb(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){let t=e-this.dsCurrVal;this.dsCurrVal=e,sb(this.restEncoder,t)}writeDsLen(e){e===0&&kb(),sb(this.restEncoder,e-1),this.dsCurrVal+=e}},GC=class extends WC{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new Tb,this.clientEncoder=new Cb,this.leftClockEncoder=new Tb,this.rightClockEncoder=new Tb,this.infoEncoder=new xb(ob),this.stringEncoder=new Eb,this.parentInfoEncoder=new xb(ob),this.typeRefEncoder=new Cb,this.lenEncoder=new Cb}toUint8Array(){let e=eb();return sb(e,0),pb(e,this.keyClockEncoder.toUint8Array()),pb(e,this.clientEncoder.toUint8Array()),pb(e,this.leftClockEncoder.toUint8Array()),pb(e,this.rightClockEncoder.toUint8Array()),pb(e,rb(this.infoEncoder)),pb(e,this.stringEncoder.toUint8Array()),pb(e,rb(this.parentInfoEncoder)),pb(e,this.typeRefEncoder.toUint8Array()),pb(e,this.lenEncoder.toUint8Array()),fb(e,rb(this.restEncoder)),rb(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)}writeTypeRef(e){this.typeRefEncoder.write(e)}writeLen(e){this.lenEncoder.write(e)}writeAny(e){bb(this.restEncoder,e)}writeBuf(e){pb(this.restEncoder,e)}writeJSON(e){bb(this.restEncoder,e)}writeKey(e){let t=this.keyMap.get(e);t===void 0?(this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(e)):this.keyClockEncoder.write(t)}},KC=(e,t,n,r)=>{r=wy(r,t[0].id.clock);let i=Lw(t,r);sb(e.restEncoder,t.length-i),e.writeClient(n),sb(e.restEncoder,r);let a=t[i];a.write(e,r-a.id.clock);for(let n=i+1;n<t.length;n++)t[n].write(e,0)},qC=(e,t,n)=>{let r=new Map;n.forEach((e,n)=>{Fw(t,n)>e&&r.set(n,e)}),Pw(t).forEach((e,t)=>{n.has(t)||r.set(t,0)}),sb(e.restEncoder,r.size),hy(r.entries()).sort((e,t)=>t[0]-e[0]).forEach(([n,r])=>{KC(e,t.clients.get(n),n,r)})},JC=(e,t)=>{let n=sy(),r=Rb(e.restDecoder);for(let i=0;i<r;i++){let r=Rb(e.restDecoder),i=Array(r),a=e.readClient(),o=Rb(e.restDecoder);n.set(a,{i:0,refs:i});for(let n=0;n<r;n++){let r=e.readInfo();switch(31&r){case 0:{let t=e.readLen();i[n]=new kE(gw(a,o),t),o+=t;break}case 10:{let t=Rb(e.restDecoder);i[n]=new pD(gw(a,o),t),o+=t;break}default:{let s=(r&192)==0,c=new lD(gw(a,o),null,(r&128)==128?e.readLeftID():null,null,(r&64)==64?e.readRightID():null,s?e.readParentInfo()?t.get(e.readString()):e.readLeftID():null,s&&(r&32)==32?e.readString():null,uD(e,r));i[n]=c,o+=c.length}}}}return n},YC=(e,t,n)=>{let r=[],i=hy(n.keys()).sort((e,t)=>e-t);if(i.length===0)return null;let a=()=>{if(i.length===0)return null;let e=n.get(i[i.length-1]);for(;e.refs.length===e.i;)if(i.pop(),i.length>0)e=n.get(i[i.length-1]);else return null;return e},o=a();if(o===null)return null;let s=new Nw,c=new Map,l=(e,t)=>{let n=c.get(e);(n==null||n>t)&&c.set(e,t)},u=o.refs[o.i++],d=new Map,f=()=>{for(let e of r){let t=e.id.client,r=n.get(t);r?(r.i--,s.clients.set(t,r.refs.slice(r.i)),n.delete(t),r.i=0,r.refs=[]):s.clients.set(t,[e]),i=i.filter(e=>e!==t)}r.length=0};for(;;){if(u.constructor!==pD){let i=ly(d,u.id.client,()=>Fw(t,u.id.client))-u.id.clock;if(i<0)r.push(u),l(u.id.client,u.id.clock-1),f();else{let a=u.getMissing(e,t);if(a!==null){r.push(u);let e=n.get(a)||{refs:[],i:0};if(e.refs.length===e.i)l(a,Fw(t,a)),f();else{u=e.refs[e.i++];continue}}else (i===0||i<u.length)&&(u.integrate(e,i),d.set(u.id.client,u.id.clock+u.length))}}if(r.length>0)u=r.pop();else if(o!==null&&o.i<o.refs.length)u=o.refs[o.i++];else{if(o=a(),o===null)break;u=o.refs[o.i++]}}if(s.clients.size>0){let e=new GC;return qC(e,s,new Map),sb(e.restEncoder,0),{missing:c,update:e.toUint8Array()}}return null},XC=(e,t)=>qC(e,t.doc.store,t.beforeState),ZC=(e,t,n,r=new VC(e))=>Zw(t,e=>{e.local=!1;let t=!1,n=e.doc,i=n.store,a=YC(e,i,JC(r,n)),o=i.pendingStructs;if(o){for(let[e,n]of o.missing)if(n<Fw(i,e)){t=!0;break}if(a){for(let[e,t]of a.missing){let n=o.missing.get(e);(n==null||n>t)&&o.missing.set(e,t)}o.update=sT([o.update,a.update])}}else i.pendingStructs=a;let s=FC(r,e,i);if(i.pendingDs){let t=new VC(Nb(i.pendingDs));Rb(t.restDecoder);let n=FC(t,e,i);s&&n?i.pendingDs=sT([s,n]):i.pendingDs=s||n}else i.pendingDs=s;if(t){let t=i.pendingStructs.update;i.pendingStructs=null,QC(e.doc,t)}},n,!1),QC=(e,t,n,r=VC)=>{let i=Nb(t);ZC(i,e,n,new r(i))},$C=(e,t,n)=>QC(e,t,n,zC),ew=(e,t,n=new Map)=>{qC(e,t.store,n),NC(e,MC(t.store))},tw=(e,t=new Uint8Array([0]),n=new GC)=>{ew(n,e,iw(t));let r=[n.toUint8Array()];if(e.store.pendingDs&&r.push(e.store.pendingDs),e.store.pendingStructs&&r.push(cT(e.store.pendingStructs.update,t)),r.length>1){if(n.constructor===UC)return aT(r.map((e,t)=>t===0?e:pT(e)));if(n.constructor===GC)return sT(r)}return r[0]},nw=(e,t)=>tw(e,t,new UC),rw=e=>{let t=new Map,n=Rb(e.restDecoder);for(let r=0;r<n;r++){let n=Rb(e.restDecoder),r=Rb(e.restDecoder);t.set(n,r)}return t},iw=e=>rw(new RC(Nb(e))),aw=(e,t)=>(sb(e.restEncoder,t.size),hy(t.entries()).sort((e,t)=>t[0]-e[0]).forEach(([t,n])=>{sb(e.restEncoder,t),sb(e.restEncoder,n)}),e),ow=(e,t)=>aw(e,Pw(t.store)),sw=(e,t=new WC)=>(e instanceof Map?aw(t,e):ow(t,e),t.toUint8Array()),cw=e=>sw(e,new HC),lw=class{constructor(){this.l=[]}},uw=()=>new lw,dw=(e,t)=>e.l.push(t),fw=(e,t)=>{let n=e.l,r=n.length;e.l=n.filter(e=>t!==e),r===e.l.length&&console.error(`[yjs] Tried to remove event handler that doesn't exist.`)},pw=(e,t,n)=>vx(e.l,[t,n]),mw=class{constructor(e,t){this.client=e,this.clock=t}},hw=(e,t)=>e===t||e!==null&&t!==null&&e.client===t.client&&e.clock===t.clock,gw=(e,t)=>new mw(e,t),_w=e=>{for(let[t,n]of e.doc.share.entries())if(n===e)return t;throw kb()},vw=(e,t)=>{for(;t!==null;){if(t.parent===e)return!0;t=t.parent._item}return!1},yw=class{constructor(e,t,n,r=0){this.type=e,this.tname=t,this.item=n,this.assoc=r}},bw=e=>new yw(e.type==null?null:gw(e.type.client,e.type.clock),e.tname??null,e.item==null?null:gw(e.item.client,e.item.clock),e.assoc==null?0:e.assoc),xw=class{constructor(e,t,n=0){this.type=e,this.index=t,this.assoc=n}},Sw=(e,t,n=0)=>new xw(e,t,n),Cw=(e,t,n)=>{let r=null,i=null;return e._item===null?i=_w(e):r=gw(e._item.id.client,e._item.id.clock),new yw(r,i,t,n)},ww=(e,t,n=0)=>{let r=e._start;if(n<0){if(t===0)return Cw(e,null,n);t--}for(;r!==null;){if(!r.deleted&&r.countable){if(r.length>t)return Cw(e,gw(r.id.client,r.id.clock+t),n);t-=r.length}if(r.right===null&&n<0)return Cw(e,r.lastId,n);r=r.right}return Cw(e,null,n)},Tw=(e,t)=>{let n=Rw(e,t);return{item:n,diff:t.clock-n.id.clock}},Ew=(e,t,n=!0)=>{let r=t.store,i=e.item,a=e.type,o=e.tname,s=e.assoc,c=null,l=0;if(i!==null){if(Fw(r,i.client)<=i.clock)return null;let e=n?iD(r,i):Tw(r,i),t=e.item;if(!(t instanceof lD))return null;if(c=t.parent,c._item===null||!c._item.deleted){l=t.deleted||!t.countable?0:e.diff+(s>=0?0:1);let n=t.left;for(;n!==null;)!n.deleted&&n.countable&&(l+=n.length),n=n.left}}else{if(o!==null)c=t.get(o);else if(a!==null){if(Fw(r,a.client)<=a.clock)return null;let{item:e}=n?iD(r,a):{item:Rw(r,a)};if(e instanceof lD&&e.content instanceof nD)c=e.content.type;else return null}else throw kb();l=s>=0?c._length:0}return Sw(c,l,e.assoc)},Dw=(e,t)=>e===t||e!==null&&t!==null&&e.tname===t.tname&&hw(e.item,t.item)&&hw(e.type,t.type)&&e.assoc===t.assoc,Ow=class{constructor(e,t){this.ds=e,this.sv=t}},kw=(e,t)=>new Ow(e,t);kw(jC(),new Map);var Aw=e=>kw(MC(e.store),Pw(e.store)),jw=(e,t)=>t===void 0?!e.deleted:t.sv.has(e.id.client)&&(t.sv.get(e.id.client)||0)>e.id.clock&&!DC(t.ds,e.id),Mw=(e,t)=>{let n=ly(e.meta,Mw,fy),r=e.doc.store;n.has(t)||(t.sv.forEach((t,n)=>{t<Fw(r,n)&&Bw(e,gw(n,t))}),TC(e,t.ds,e=>{}),n.add(t))},Nw=class{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}},Pw=e=>{let t=new Map;return e.clients.forEach((e,n)=>{let r=e[e.length-1];t.set(n,r.id.clock+r.length)}),t},Fw=(e,t)=>{let n=e.clients.get(t);if(n===void 0)return 0;let r=n[n.length-1];return r.id.clock+r.length},Iw=(e,t)=>{let n=e.clients.get(t.id.client);if(n===void 0)n=[],e.clients.set(t.id.client,n);else{let e=n[n.length-1];if(e.id.clock+e.length!==t.id.clock)throw kb()}n.push(t)},Lw=(e,t)=>{let n=0,r=e.length-1,i=e[r],a=i.id.clock;if(a===t)return r;let o=xy(t/(a+i.length-1)*r);for(;n<=r;){if(i=e[o],a=i.id.clock,a<=t){if(t<a+i.length)return o;n=o+1}else r=o-1;o=xy((n+r)/2)}throw kb()},Rw=(e,t)=>{let n=e.clients.get(t.client);return n[Lw(n,t.clock)]},zw=(e,t,n)=>{let r=Lw(t,n),i=t[r];return i.id.clock<n&&i instanceof lD?(t.splice(r+1,0,oD(e,i,n-i.id.clock)),r+1):r},Bw=(e,t)=>{let n=e.doc.store.clients.get(t.client);return n[zw(e,n,t.clock)]},Vw=(e,t,n)=>{let r=t.clients.get(n.client),i=Lw(r,n.clock),a=r[i];return n.clock!==a.id.clock+a.length-1&&a.constructor!==kE&&r.splice(i+1,0,oD(e,a,n.clock-a.id.clock+1)),a},Hw=(e,t,n)=>{let r=e.clients.get(t.id.client);r[Lw(r,t.id.clock)]=n},Uw=(e,t,n,r,i)=>{if(r===0)return;let a=n+r,o=zw(e,t,n),s;do s=t[o++],a<s.id.clock+s.length&&zw(e,t,a),i(s);while(o<t.length&&t[o].id.clock<a)},Ww=class{constructor(e,t,n){this.doc=e,this.deleteSet=new wC,this.beforeState=Pw(e.store),this.afterState=new Map,this.changed=new Map,this.changedParentTypes=new Map,this._mergeStructs=[],this.origin=t,this.meta=new Map,this.local=n,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}},Gw=(e,t)=>t.deleteSet.clients.size===0&&!dy(t.afterState,(e,n)=>t.beforeState.get(n)!==e)?!1:(OC(t.deleteSet),XC(e,t),NC(e,t.deleteSet),!0),Kw=(e,t,n)=>{let r=t._item;(r===null||r.id.clock<(e.beforeState.get(r.id.client)||0)&&!r.deleted)&&ly(e.changed,t,fy).add(n)},qw=(e,t)=>{let n=e[t],r=e[t-1],i=t;for(;i>0;n=r,r=e[--i-1]){if(r.deleted===n.deleted&&r.constructor===n.constructor&&r.mergeWith(n)){n instanceof lD&&n.parentSub!==null&&n.parent._map.get(n.parentSub)===n&&n.parent._map.set(n.parentSub,r);continue}break}let a=t-i;return a&&e.splice(t+1-a,a),a},Jw=(e,t,n)=>{for(let[r,i]of e.clients.entries()){let e=t.clients.get(r);for(let r=i.length-1;r>=0;r--){let a=i[r],o=a.clock+a.len;for(let r=Lw(e,a.clock),i=e[r];r<e.length&&i.id.clock<o;i=e[++r]){let i=e[r];if(a.clock+a.len<=i.id.clock)break;i instanceof lD&&i.deleted&&!i.keep&&n(i)&&i.gc(t,!1)}}}},Yw=(e,t)=>{e.clients.forEach((e,n)=>{let r=t.clients.get(n);for(let t=e.length-1;t>=0;t--){let n=e[t],i=Cy(r.length-1,1+Lw(r,n.clock+n.len-1));for(let e=i,t=r[e];e>0&&t.id.clock>=n.clock;t=r[e])e-=1+qw(r,e)}})},Xw=(e,t)=>{if(t<e.length){let n=e[t],r=n.doc,i=r.store,a=n.deleteSet,o=n._mergeStructs;try{OC(a),n.afterState=Pw(n.doc.store),r.emit(`beforeObserverCalls`,[n,r]);let e=[];n.changed.forEach((t,r)=>e.push(()=>{(r._item===null||!r._item.deleted)&&r._callObserver(n,t)})),e.push(()=>{n.changedParentTypes.forEach((t,r)=>{r._dEH.l.length>0&&(r._item===null||!r._item.deleted)&&(t=t.filter(e=>e.target._item===null||!e.target._item.deleted),t.forEach(e=>{e.currentTarget=r,e._path=null}),t.sort((e,t)=>e.path.length-t.path.length),e.push(()=>{pw(r._dEH,t,n)}))}),e.push(()=>r.emit(`afterTransaction`,[n,r])),e.push(()=>{n._needFormattingCleanup&&fE(n)})}),vx(e,[])}finally{r.gc&&Jw(a,i,r.gcFilter),Yw(a,i),n.afterState.forEach((e,t)=>{let r=n.beforeState.get(t)||0;if(r!==e){let e=i.clients.get(t),n=wy(Lw(e,r),1);for(let t=e.length-1;t>=n;)t-=1+qw(e,t)}});for(let e=o.length-1;e>=0;e--){let{client:t,clock:n}=o[e].id,r=i.clients.get(t),a=Lw(r,n);a+1<r.length&&qw(r,a+1)>1||a>0&&qw(r,a)}if(!n.local&&n.afterState.get(r.clientID)!==n.beforeState.get(r.clientID)&&(_C(fC,aC,`[yjs] `,oC,uC,`Changed the client-id because another client seems to be using it.`),r.clientID=IC()),r.emit(`afterTransactionCleanup`,[n,r]),r._observers.has(`update`)){let e=new UC;Gw(e,n)&&r.emit(`update`,[e.toUint8Array(),n.origin,r,n])}if(r._observers.has(`updateV2`)){let e=new GC;Gw(e,n)&&r.emit(`updateV2`,[e.toUint8Array(),n.origin,r,n])}let{subdocsAdded:s,subdocsLoaded:c,subdocsRemoved:l}=n;(s.size>0||l.size>0||c.size>0)&&(s.forEach(e=>{e.clientID=r.clientID,e.collectionid??=r.collectionid,r.subdocs.add(e)}),l.forEach(e=>r.subdocs.delete(e)),r.emit(`subdocs`,[{loaded:c,added:s,removed:l},r,n]),l.forEach(e=>e.destroy())),e.length<=t+1?(r._transactionCleanups=[],r.emit(`afterAllTransactions`,[r,e])):Xw(e,t+1)}}},Zw=(e,t,n=null,r=!0)=>{let i=e._transactionCleanups,a=!1,o=null;e._transaction===null&&(a=!0,e._transaction=new Ww(e,n,r),i.push(e._transaction),i.length===1&&e.emit(`beforeAllTransactions`,[e]),e.emit(`beforeTransaction`,[e._transaction,e]));try{o=t(e._transaction)}finally{if(a){let t=e._transaction===i[0];e._transaction=null,t&&Xw(i,0)}}return o},Qw=class{constructor(e,t){this.insertions=t,this.deletions=e,this.meta=new Map}},$w=(e,t,n)=>{TC(e,n.deletions,n=>{n instanceof lD&&t.scope.some(t=>t===e.doc||vw(t,n))&&aD(n,!1)})},eT=(e,t,n)=>{let r=null,i=e.doc,a=e.scope;Zw(i,n=>{for(;t.length>0&&e.currStackItem===null;){let r=i.store,o=t.pop(),s=new Set,c=[],l=!1;TC(n,o.insertions,e=>{if(e instanceof lD){if(e.redone!==null){let{item:t,diff:i}=iD(r,e.id);i>0&&(t=Bw(n,gw(t.id.client,t.id.clock+i))),e=t}!e.deleted&&a.some(t=>t===n.doc||vw(t,e))&&c.push(e)}}),TC(n,o.deletions,e=>{e instanceof lD&&a.some(t=>t===n.doc||vw(t,e))&&!DC(o.insertions,e.id)&&s.add(e)}),s.forEach(t=>{l=cD(n,t,s,o.insertions,e.ignoreRemoteMapChanges,e)!==null||l});for(let t=c.length-1;t>=0;t--){let r=c[t];e.deleteFilter(r)&&(r.delete(n),l=!0)}e.currStackItem=l?o:null}n.changed.forEach((e,t)=>{e.has(null)&&t._searchMarker&&(t._searchMarker.length=0)}),r=n},e);let o=e.currStackItem;if(o!=null){let t=r.changedParentTypes;e.emit(`stack-item-popped`,[{stackItem:o,type:n,changedParentTypes:t,origin:e},e]),e.currStackItem=null}return o},tT=class extends by{constructor(e,{captureTimeout:t=500,captureTransaction:n=e=>!0,deleteFilter:r=()=>!0,trackedOrigins:i=new Set([null]),ignoreRemoteMapChanges:a=!1,doc:o=yy(e)?e[0].doc:e instanceof LC?e:e.doc}={}){super(),this.scope=[],this.doc=o,this.addToScope(e),this.deleteFilter=r,i.add(this),this.trackedOrigins=i,this.captureTransaction=n,this.undoStack=[],this.redoStack=[],this.undoing=!1,this.redoing=!1,this.currStackItem=null,this.lastChange=0,this.ignoreRemoteMapChanges=a,this.captureTimeout=t,this.afterTransactionHandler=e=>{if(!this.captureTransaction(e)||!this.scope.some(t=>e.changedParentTypes.has(t)||t===this.doc)||!this.trackedOrigins.has(e.origin)&&(!e.origin||!this.trackedOrigins.has(e.origin.constructor)))return;let t=this.undoing,n=this.redoing,r=t?this.redoStack:this.undoStack;t?this.stopCapturing():n||this.clear(!1,!0);let i=new wC;e.afterState.forEach((t,n)=>{let r=e.beforeState.get(n)||0,a=t-r;a>0&&AC(i,n,r,a)});let a=ex(),o=!1;if(this.lastChange>0&&a-this.lastChange<this.captureTimeout&&r.length>0&&!t&&!n){let t=r[r.length-1];t.deletions=kC([t.deletions,e.deleteSet]),t.insertions=kC([t.insertions,i])}else r.push(new Qw(e.deleteSet,i)),o=!0;!t&&!n&&(this.lastChange=a),TC(e,e.deleteSet,t=>{t instanceof lD&&this.scope.some(n=>n===e.doc||vw(n,t))&&aD(t,!0)});let s=[{stackItem:r[r.length-1],origin:e.origin,type:t?`redo`:`undo`,changedParentTypes:e.changedParentTypes},this];o?this.emit(`stack-item-added`,s):this.emit(`stack-item-updated`,s)},this.doc.on(`afterTransaction`,this.afterTransactionHandler),this.doc.on(`destroy`,()=>{this.destroy()})}addToScope(e){let t=new Set(this.scope);e=yy(e)?e:[e],e.forEach(e=>{t.has(e)||(t.add(e),(e instanceof DT?e.doc!==this.doc:e!==this.doc)&&vC(`[yjs#509] Not same Y.Doc`),this.scope.push(e))})}addTrackedOrigin(e){this.trackedOrigins.add(e)}removeTrackedOrigin(e){this.trackedOrigins.delete(e)}clear(e=!0,t=!0){(e&&this.canUndo()||t&&this.canRedo())&&this.doc.transact(n=>{e&&(this.undoStack.forEach(e=>$w(n,this,e)),this.undoStack=[]),t&&(this.redoStack.forEach(e=>$w(n,this,e)),this.redoStack=[]),this.emit(`stack-cleared`,[{undoStackCleared:e,redoStackCleared:t}])})}stopCapturing(){this.lastChange=0}undo(){this.undoing=!0;let e;try{e=eT(this,this.undoStack,`undo`)}finally{this.undoing=!1}return e}redo(){this.redoing=!0;let e;try{e=eT(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*nT(e){let t=Rb(e.restDecoder);for(let n=0;n<t;n++){let t=Rb(e.restDecoder),n=e.readClient(),r=Rb(e.restDecoder);for(let i=0;i<t;i++){let t=e.readInfo();if(t===10){let t=Rb(e.restDecoder);yield new pD(gw(n,r),t),r+=t}else if(31&t){let i=(t&192)==0,a=new lD(gw(n,r),null,(t&128)==128?e.readLeftID():null,null,(t&64)==64?e.readRightID():null,i?e.readParentInfo()?e.readString():e.readLeftID():null,i&&(t&32)==32?e.readString():null,uD(e,t));yield a,r+=a.length}else{let t=e.readLen();yield new kE(gw(n,r),t),r+=t}}}}var rT=class{constructor(e,t){this.gen=nT(e),this.curr=null,this.done=!1,this.filterSkips=t,this.next()}next(){do this.curr=this.gen.next().value||null;while(this.filterSkips&&this.curr!==null&&this.curr.constructor===pD);return this.curr}},iT=class{constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}},aT=e=>sT(e,zC,UC),oT=(e,t)=>{if(e.constructor===kE){let{client:n,clock:r}=e.id;return new kE(gw(n,r+t),e.length-t)}else if(e.constructor===pD){let{client:n,clock:r}=e.id;return new pD(gw(n,r+t),e.length-t)}else{let n=e,{client:r,clock:i}=n.id;return new lD(gw(r,i+t),null,gw(r,i+t-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(t))}},sT=(e,t=VC,n=GC)=>{if(e.length===1)return e[0];let r=e.map(e=>new t(Nb(e))),i=r.map(e=>new rT(e,!0)),a=null,o=new n,s=new iT(o);for(;i=i.filter(e=>e.curr!==null),i.sort((e,t)=>{if(e.curr.id.client===t.curr.id.client){let n=e.curr.id.clock-t.curr.id.clock;return n===0?e.curr.constructor===t.curr.constructor?0:e.curr.constructor===pD?1:-1:n}else return t.curr.id.client-e.curr.id.client}),i.length!==0;){let e=i[0],t=e.curr.id.client;if(a!==null){let n=e.curr,r=!1;for(;n!==null&&n.id.clock+n.length<=a.struct.id.clock+a.struct.length&&n.id.client>=a.struct.id.client;)n=e.next(),r=!0;if(n===null||n.id.client!==t||r&&n.id.clock>a.struct.id.clock+a.struct.length)continue;if(t!==a.struct.id.client)uT(s,a.struct,a.offset),a={struct:n,offset:0},e.next();else if(a.struct.id.clock+a.struct.length<n.id.clock)if(a.struct.constructor===pD)a.struct.length=n.id.clock+n.length-a.struct.id.clock;else{uT(s,a.struct,a.offset);let e=n.id.clock-a.struct.id.clock-a.struct.length;a={struct:new pD(gw(t,a.struct.id.clock+a.struct.length),e),offset:0}}else{let t=a.struct.id.clock+a.struct.length-n.id.clock;t>0&&(a.struct.constructor===pD?a.struct.length-=t:n=oT(n,t)),a.struct.mergeWith(n)||(uT(s,a.struct,a.offset),a={struct:n,offset:0},e.next())}}else a={struct:e.curr,offset:0},e.next();for(let n=e.curr;n!==null&&n.id.client===t&&n.id.clock===a.struct.id.clock+a.struct.length&&n.constructor!==pD;n=e.next())uT(s,a.struct,a.offset),a={struct:n,offset:0}}return a!==null&&(uT(s,a.struct,a.offset),a=null),dT(s),NC(o,kC(r.map(e=>PC(e)))),o.toUint8Array()},cT=(e,t,n=VC,r=GC)=>{let i=iw(t),a=new r,o=new iT(a),s=new n(Nb(e)),c=new rT(s,!1);for(;c.curr;){let e=c.curr,t=e.id.client,n=i.get(t)||0;if(c.curr.constructor===pD){c.next();continue}if(e.id.clock+e.length>n)for(uT(o,e,wy(n-e.id.clock,0)),c.next();c.curr&&c.curr.id.client===t;)uT(o,c.curr,0),c.next();else for(;c.curr&&c.curr.id.client===t&&c.curr.id.clock+c.curr.length<=n;)c.next()}return dT(o),NC(a,PC(s)),a.toUint8Array()},lT=e=>{e.written>0&&(e.clientStructs.push({written:e.written,restEncoder:rb(e.encoder.restEncoder)}),e.encoder.restEncoder=eb(),e.written=0)},uT=(e,t,n)=>{e.written>0&&e.currClient!==t.id.client&&lT(e),e.written===0&&(e.currClient=t.id.client,e.encoder.writeClient(t.id.client),sb(e.encoder.restEncoder,t.id.clock+n)),t.write(e.encoder,n),e.written++},dT=e=>{lT(e);let t=e.encoder.restEncoder;sb(t,e.clientStructs.length);for(let n=0;n<e.clientStructs.length;n++){let r=e.clientStructs[n];sb(t,r.written),fb(t,r.restEncoder)}},fT=(e,t,n,r)=>{let i=new n(Nb(e)),a=new rT(i,!1),o=new r,s=new iT(o);for(let e=a.curr;e!==null;e=a.next())uT(s,t(e),0);return dT(s),NC(o,PC(i)),o.toUint8Array()},pT=e=>fT(e,yx,VC,UC),mT=`You must not compute changes after the event-handler fired.`,hT=class{constructor(e,t){this.target=e,this.currentTarget=e,this.transaction=t,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||=gT(this.currentTarget,this.target)}deletes(e){return DC(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw Db(mT);let e=new Map,t=this.target;this.transaction.changed.get(t).forEach(n=>{if(n!==null){let r=t._map.get(n),i,a;if(this.adds(r)){let e=r.left;for(;e!==null&&this.adds(e);)e=e.left;if(this.deletes(r))if(e!==null&&this.deletes(e))i=`delete`,a=py(e.content.getContent());else return;else e!==null&&this.deletes(e)?(i=`update`,a=py(e.content.getContent())):(i=`add`,a=void 0)}else if(this.deletes(r))i=`delete`,a=py(r.content.getContent());else return;e.set(n,{action:i,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 Db(mT);let t=this.target,n=fy(),r=fy(),i=[];if(e={added:n,deleted:r,delta:i,keys:this.keys},this.transaction.changed.get(t).has(null)){let e=null,a=()=>{e&&i.push(e)};for(let i=t._start;i!==null;i=i.right)i.deleted?this.deletes(i)&&!this.adds(i)&&((e===null||e.delete===void 0)&&(a(),e={delete:0}),e.delete+=i.length,r.add(i)):this.adds(i)?((e===null||e.insert===void 0)&&(a(),e={insert:[]}),e.insert=e.insert.concat(i.content.getContent()),n.add(i)):((e===null||e.retain===void 0)&&(a(),e={retain:0}),e.retain+=i.length);e!==null&&e.retain===void 0&&a()}this._changes=e}return e}},gT=(e,t)=>{let n=[];for(;t._item!==null&&t!==e;){if(t._item.parentSub!==null)n.unshift(t._item.parentSub);else{let e=0,r=t._item.parent._start;for(;r!==t._item&&r!==null;)!r.deleted&&r.countable&&(e+=r.length),r=r.right;n.unshift(e)}t=t._item.parent}return n},_T=()=>{vC(`Invalid access: Add Yjs type to a document before reading data.`)},vT=80,yT=0,bT=class{constructor(e,t){e.marker=!0,this.p=e,this.index=t,this.timestamp=yT++}},xT=e=>{e.timestamp=yT++},ST=(e,t,n)=>{e.p.marker=!1,e.p=t,t.marker=!0,e.index=n,e.timestamp=yT++},CT=(e,t,n)=>{if(e.length>=vT){let r=e.reduce((e,t)=>e.timestamp<t.timestamp?e:t);return ST(r,t,n),r}else{let r=new bT(t,n);return e.push(r),r}},wT=(e,t)=>{if(e._start===null||t===0||e._searchMarker===null)return null;let n=e._searchMarker.length===0?null:e._searchMarker.reduce((e,n)=>Sy(t-e.index)<Sy(t-n.index)?e:n),r=e._start,i=0;for(n!==null&&(r=n.p,i=n.index,xT(n));r.right!==null&&i<t;){if(!r.deleted&&r.countable){if(t<i+r.length)break;i+=r.length}r=r.right}for(;r.left!==null&&i>t;)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&&Sy(n.index-i)<r.parent.length/vT?(ST(n,r,i),n):CT(e._searchMarker,r,i)},TT=(e,t,n)=>{for(let r=e.length-1;r>=0;r--){let i=e[r];if(n>0){let t=i.p;for(t.marker=!1;t&&(t.deleted||!t.countable);)t=t.left,t&&!t.deleted&&t.countable&&(i.index-=t.length);if(t===null||t.marker===!0){e.splice(r,1);continue}i.p=t,t.marker=!0}(t<i.index||n>0&&t===i.index)&&(i.index=wy(t,i.index+n))}},ET=(e,t,n)=>{let r=e,i=t.changedParentTypes;for(;ly(i,e,()=>[]).push(n),e._item!==null;)e=e._item.parent;pw(r._eH,n,t)},DT=class{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=uw(),this._dEH=uw(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,t){this.doc=e,this._item=t}_copy(){throw Ob()}clone(){throw Ob()}_write(e){}get _first(){let e=this._start;for(;e!==null&&e.deleted;)e=e.right;return e}_callObserver(e,t){!e.local&&this._searchMarker&&(this._searchMarker.length=0)}observe(e){dw(this._eH,e)}observeDeep(e){dw(this._dEH,e)}unobserve(e){fw(this._eH,e)}unobserveDeep(e){fw(this._dEH,e)}toJSON(){}},OT=(e,t,n)=>{e.doc??_T(),t<0&&(t=e._length+t),n<0&&(n=e._length+n);let r=n-t,i=[],a=e._start;for(;a!==null&&r>0;){if(a.countable&&!a.deleted){let e=a.content.getContent();if(e.length<=t)t-=e.length;else{for(let n=t;n<e.length&&r>0;n++)i.push(e[n]),r--;t=0}}a=a.right}return i},kT=e=>{e.doc??_T();let t=[],n=e._start;for(;n!==null;){if(n.countable&&!n.deleted){let e=n.content.getContent();for(let n=0;n<e.length;n++)t.push(e[n])}n=n.right}return t},AT=(e,t)=>{let n=[],r=e._start;for(;r!==null;){if(r.countable&&jw(r,t)){let e=r.content.getContent();for(let t=0;t<e.length;t++)n.push(e[t])}r=r.right}return n},jT=(e,t)=>{let n=0,r=e._start;for(e.doc??_T();r!==null;){if(r.countable&&!r.deleted){let i=r.content.getContent();for(let r=0;r<i.length;r++)t(i[r],n++,e)}r=r.right}},MT=(e,t)=>{let n=[];return jT(e,(r,i)=>{n.push(t(r,i,e))}),n},NT=e=>{let t=e._start,n=null,r=0;return{[Symbol.iterator](){return this},next:()=>{if(n===null){for(;t!==null&&t.deleted;)t=t.right;if(t===null)return{done:!0,value:void 0};n=t.content.getContent(),r=0,t=t.right}let e=n[r++];return n.length<=r&&(n=null),{done:!1,value:e}}}},PT=(e,t)=>{e.doc??_T();let n=wT(e,t),r=e._start;for(n!==null&&(r=n.p,t-=n.index);r!==null;r=r.right)if(!r.deleted&&r.countable){if(t<r.length)return r.content.getContent()[t];t-=r.length}},FT=(e,t,n,r)=>{let i=n,a=e.doc,o=a.clientID,s=a.store,c=n===null?t._start:n.right,l=[],u=()=>{l.length>0&&(i=new lD(gw(o,Fw(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new WE(l)),i.integrate(e,0),l=[])};r.forEach(n=>{if(n===null)l.push(n);else switch(n.constructor){case Number:case Object:case Boolean:case Array:case String:l.push(n);break;default:switch(u(),n.constructor){case Uint8Array:case ArrayBuffer:i=new lD(gw(o,Fw(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new AE(new Uint8Array(n))),i.integrate(e,0);break;case LC:i=new lD(gw(o,Fw(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new FE(n)),i.integrate(e,0);break;default:if(n instanceof DT)i=new lD(gw(o,Fw(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new nD(n)),i.integrate(e,0);else throw Error(`Unexpected content type in insert operation`)}}}),u()},IT=()=>Db(`Length exceeded!`),LT=(e,t,n,r)=>{if(n>t._length)throw IT();if(n===0)return t._searchMarker&&TT(t._searchMarker,n,r.length),FT(e,t,null,r);let i=n,a=wT(t,n),o=t._start;for(a!==null&&(o=a.p,n-=a.index,n===0&&(o=o.prev,n+=o&&o.countable&&!o.deleted?o.length:0));o!==null;o=o.right)if(!o.deleted&&o.countable){if(n<=o.length){n<o.length&&Bw(e,gw(o.id.client,o.id.clock+n));break}n-=o.length}return t._searchMarker&&TT(t._searchMarker,i,r.length),FT(e,t,o,r)},RT=(e,t,n)=>{let r=(t._searchMarker||[]).reduce((e,t)=>t.index>e.index?t:e,{index:0,p:t._start}).p;if(r)for(;r.right;)r=r.right;return FT(e,t,r,n)},zT=(e,t,n,r)=>{if(r===0)return;let i=n,a=r,o=wT(t,n),s=t._start;for(o!==null&&(s=o.p,n-=o.index);s!==null&&n>0;s=s.right)!s.deleted&&s.countable&&(n<s.length&&Bw(e,gw(s.id.client,s.id.clock+n)),n-=s.length);for(;r>0&&s!==null;)s.deleted||(r<s.length&&Bw(e,gw(s.id.client,s.id.clock+r)),s.delete(e),r-=s.length),s=s.right;if(r>0)throw IT();t._searchMarker&&TT(t._searchMarker,i,-a+r)},BT=(e,t,n)=>{let r=t._map.get(n);r!==void 0&&r.delete(e)},VT=(e,t,n,r)=>{let i=t._map.get(n)||null,a=e.doc,o=a.clientID,s;if(r==null)s=new WE([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:s=new WE([r]);break;case Uint8Array:s=new AE(r);break;case LC:s=new FE(r);break;default:if(r instanceof DT)s=new nD(r);else throw Error(`Unexpected content type`)}new lD(gw(o,Fw(a.store,o)),i,i&&i.lastId,null,null,t,n,s).integrate(e,0)},HT=(e,t)=>{e.doc??_T();let n=e._map.get(t);return n!==void 0&&!n.deleted?n.content.getContent()[n.length-1]:void 0},UT=e=>{let t={};return e.doc??_T(),e._map.forEach((e,n)=>{e.deleted||(t[n]=e.content.getContent()[e.length-1])}),t},WT=(e,t)=>{e.doc??_T();let n=e._map.get(t);return n!==void 0&&!n.deleted},GT=(e,t)=>{let n={};return e._map.forEach((e,r)=>{let i=e;for(;i!==null&&(!t.sv.has(i.id.client)||i.id.clock>=(t.sv.get(i.id.client)||0));)i=i.left;i!==null&&jw(i,t)&&(n[r]=i.content.getContent()[i.length-1])}),n},KT=e=>(e.doc??_T(),xC(e._map.entries(),e=>!e[1].deleted)),qT=class extends hT{},JT=class e extends DT{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(t){let n=new e;return n.push(t),n}_integrate(e,t){super._integrate(e,t),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new e}clone(){let t=new e;return t.insert(0,this.toArray().map(e=>e instanceof DT?e.clone():e)),t}get length(){return this.doc??_T(),this._length}_callObserver(e,t){super._callObserver(e,t),ET(this,e,new qT(this,e))}insert(e,t){this.doc===null?this._prelimContent.splice(e,0,...t):Zw(this.doc,n=>{LT(n,this,e,t)})}push(e){this.doc===null?this._prelimContent.push(...e):Zw(this.doc,t=>{RT(t,this,e)})}unshift(e){this.insert(0,e)}delete(e,t=1){this.doc===null?this._prelimContent.splice(e,t):Zw(this.doc,n=>{zT(n,this,e,t)})}get(e){return PT(this,e)}toArray(){return kT(this)}slice(e=0,t=this.length){return OT(this,e,t)}toJSON(){return this.map(e=>e instanceof DT?e.toJSON():e)}map(e){return MT(this,e)}forEach(e){jT(this,e)}[Symbol.iterator](){return NT(this)}_write(e){e.writeTypeRef(YE)}},YT=e=>new JT,XT=class extends hT{constructor(e,t,n){super(e,t),this.keysChanged=n}},ZT=class e extends DT{constructor(e){super(),this._prelimContent=null,e===void 0?this._prelimContent=new Map:this._prelimContent=new Map(e)}_integrate(e,t){super._integrate(e,t),this._prelimContent.forEach((e,t)=>{this.set(t,e)}),this._prelimContent=null}_copy(){return new e}clone(){let t=new e;return this.forEach((e,n)=>{t.set(n,e instanceof DT?e.clone():e)}),t}_callObserver(e,t){ET(this,e,new XT(this,e,t))}toJSON(){this.doc??_T();let e={};return this._map.forEach((t,n)=>{if(!t.deleted){let r=t.content.getContent()[t.length-1];e[n]=r instanceof DT?r.toJSON():r}}),e}get size(){return[...KT(this)].length}keys(){return SC(KT(this),e=>e[0])}values(){return SC(KT(this),e=>e[1].content.getContent()[e[1].length-1])}entries(){return SC(KT(this),e=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){this.doc??_T(),this._map.forEach((t,n)=>{t.deleted||e(t.content.getContent()[t.length-1],n,this)})}[Symbol.iterator](){return this.entries()}delete(e){this.doc===null?this._prelimContent.delete(e):Zw(this.doc,t=>{BT(t,this,e)})}set(e,t){return this.doc===null?this._prelimContent.set(e,t):Zw(this.doc,n=>{VT(n,this,e,t)}),t}get(e){return HT(this,e)}has(e){return WT(this,e)}clear(){this.doc===null?this._prelimContent.clear():Zw(this.doc,e=>{this.forEach(function(t,n,r){BT(e,r,n)})})}_write(e){e.writeTypeRef(XE)}},QT=e=>new ZT,$T=(e,t)=>e===t||typeof e==`object`&&typeof t==`object`&&e&&t&&hx(e,t),eE=class{constructor(e,t,n,r){this.left=e,this.right=t,this.index=n,this.currentAttributes=r}forward(){switch(this.right===null&&kb(),this.right.content.constructor){case zE:this.right.deleted||iE(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}},tE=(e,t,n)=>{for(;t.right!==null&&n>0;){switch(t.right.content.constructor){case zE:t.right.deleted||iE(t.currentAttributes,t.right.content);break;default:t.right.deleted||(n<t.right.length&&Bw(e,gw(t.right.id.client,t.right.id.clock+n)),t.index+=t.right.length,n-=t.right.length);break}t.left=t.right,t.right=t.right.right}return t},nE=(e,t,n,r)=>{let i=new Map,a=r?wT(t,n):null;return a?tE(e,new eE(a.p.left,a.p,a.index,i),n-a.index):tE(e,new eE(null,t._start,0,i),n)},rE=(e,t,n,r)=>{for(;n.right!==null&&(n.right.deleted===!0||n.right.content.constructor===zE&&$T(r.get(n.right.content.key),n.right.content.value));)n.right.deleted||r.delete(n.right.content.key),n.forward();let i=e.doc,a=i.clientID;r.forEach((r,o)=>{let s=n.left,c=n.right,l=new lD(gw(a,Fw(i.store,a)),s,s&&s.lastId,c,c&&c.id,t,null,new zE(o,r));l.integrate(e,0),n.right=l,n.forward()})},iE=(e,t)=>{let{key:n,value:r}=t;r===null?e.delete(n):e.set(n,r)},aE=(e,t)=>{for(;e.right!==null&&(e.right.deleted||e.right.content.constructor===zE&&$T(t[e.right.content.key]??null,e.right.content.value));)e.forward()},oE=(e,t,n,r)=>{let i=e.doc,a=i.clientID,o=new Map;for(let s in r){let c=r[s],l=n.currentAttributes.get(s)??null;if(!$T(l,c)){o.set(s,l);let{left:r,right:u}=n;n.right=new lD(gw(a,Fw(i.store,a)),r,r&&r.lastId,u,u&&u.id,t,null,new zE(s,c)),n.right.integrate(e,0),n.forward()}}return o},sE=(e,t,n,r,i)=>{n.currentAttributes.forEach((e,t)=>{i[t]===void 0&&(i[t]=null)});let a=e.doc,o=a.clientID;aE(n,i);let s=oE(e,t,n,i),c=r.constructor===String?new KE(r):r instanceof DT?new nD(r):new LE(r),{left:l,right:u,index:d}=n;t._searchMarker&&TT(t._searchMarker,n.index,c.getLength()),u=new lD(gw(o,Fw(a.store,o)),l,l&&l.lastId,u,u&&u.id,t,null,c),u.integrate(e,0),n.right=u,n.index=d,n.forward(),rE(e,t,n,s)},cE=(e,t,n,r,i)=>{let a=e.doc,o=a.clientID;aE(n,i);let s=oE(e,t,n,i);iterationLoop:for(;n.right!==null&&(r>0||s.size>0&&(n.right.deleted||n.right.content.constructor===zE));){if(!n.right.deleted)switch(n.right.content.constructor){case zE:{let{key:t,value:a}=n.right.content,o=i[t];if(o!==void 0){if($T(o,a))s.delete(t);else{if(r===0)break iterationLoop;s.set(t,a)}n.right.delete(e)}else n.currentAttributes.set(t,a);break}default:r<n.right.length&&Bw(e,gw(n.right.id.client,n.right.id.clock+r)),r-=n.right.length;break}n.forward()}if(r>0){let i=``;for(;r>0;r--)i+=`
80
+ `;n.right=new lD(gw(o,Fw(a.store,o)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,t,null,new KE(i)),n.right.integrate(e,0),n.forward()}rE(e,t,n,s)},lE=(e,t,n,r,i)=>{let a=t,o=sy();for(;a&&(!a.countable||a.deleted);){if(!a.deleted&&a.content.constructor===zE){let e=a.content;o.set(e.key,e)}a=a.right}let s=0,c=!1;for(;t!==a;){if(n===t&&(c=!0),!t.deleted){let n=t.content;switch(n.constructor){case zE:{let{key:a,value:l}=n,u=r.get(a)??null;(o.get(a)!==n||u===l)&&(t.delete(e),s++,!c&&(i.get(a)??null)===l&&u!==l&&(u===null?i.delete(a):i.set(a,u))),!c&&!t.deleted&&iE(i,n);break}}}t=t.right}return s},uE=(e,t)=>{for(;t&&t.right&&(t.right.deleted||!t.right.countable);)t=t.right;let n=new Set;for(;t&&(t.deleted||!t.countable);){if(!t.deleted&&t.content.constructor===zE){let r=t.content.key;n.has(r)?t.delete(e):n.add(r)}t=t.left}},dE=e=>{let t=0;return Zw(e.doc,n=>{let r=e._start,i=e._start,a=sy(),o=cy(a);for(;i;){if(i.deleted===!1)switch(i.content.constructor){case zE:iE(o,i.content);break;default:t+=lE(n,r,i,a,o),a=cy(o),r=i;break}i=i.right}}),t},fE=e=>{let t=new Set,n=e.doc;for(let[r,i]of e.afterState.entries()){let a=e.beforeState.get(r)||0;i!==a&&Uw(e,n.store.clients.get(r),a,i,e=>{!e.deleted&&e.content.constructor===zE&&e.constructor!==kE&&t.add(e.parent)})}Zw(n,n=>{TC(e,e.deleteSet,e=>{if(e instanceof kE||!e.parent._hasFormatting||t.has(e.parent))return;let r=e.parent;e.content.constructor===zE?t.add(r):uE(n,e)});for(let e of t)dE(e)})},pE=(e,t,n)=>{let r=n,i=cy(t.currentAttributes),a=t.right;for(;n>0&&t.right!==null;){if(t.right.deleted===!1)switch(t.right.content.constructor){case nD:case LE:case KE:n<t.right.length&&Bw(e,gw(t.right.id.client,t.right.id.clock+n)),n-=t.right.length,t.right.delete(e);break}t.forward()}a&&lE(e,a,t.right,i,t.currentAttributes);let o=(t.left||t.right).parent;return o._searchMarker&&TT(o._searchMarker,t.index,-r+n),t},mE=class extends hT{constructor(e,t,n){super(e,t),this.childListChanged=!1,this.keysChanged=new Set,n.forEach(e=>{e===null?this.childListChanged=!0:this.keysChanged.add(e)})}get changes(){if(this._changes===null){let 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){let e=this.target.doc,t=[];Zw(e,e=>{let n=new Map,r=new Map,i=this.target._start,a=null,o={},s=``,c=0,l=0,u=()=>{if(a!==null){let e=null;switch(a){case`delete`:l>0&&(e={delete:l}),l=0;break;case`insert`:(typeof s==`object`||s.length>0)&&(e={insert:s},n.size>0&&(e.attributes={},n.forEach((t,n)=>{t!==null&&(e.attributes[n]=t)}))),s=``;break;case`retain`:c>0&&(e={retain:c},fx(o)||(e.attributes=cx({},o))),c=0;break}e&&t.push(e),a=null}};for(;i!==null;){switch(i.content.constructor){case nD:case LE:this.adds(i)?this.deletes(i)||(u(),a=`insert`,s=i.content.getContent()[0],u()):this.deletes(i)?(a!==`delete`&&(u(),a=`delete`),l+=1):i.deleted||(a!==`retain`&&(u(),a=`retain`),c+=1);break;case KE:this.adds(i)?this.deletes(i)||(a!==`insert`&&(u(),a=`insert`),s+=i.content.str):this.deletes(i)?(a!==`delete`&&(u(),a=`delete`),l+=i.length):i.deleted||(a!==`retain`&&(u(),a=`retain`),c+=i.length);break;case zE:{let{key:t,value:s}=i.content;if(this.adds(i))this.deletes(i)||($T(n.get(t)??null,s)?s!==null&&i.delete(e):(a===`retain`&&u(),$T(s,r.get(t)??null)?delete o[t]:o[t]=s));else if(this.deletes(i)){r.set(t,s);let e=n.get(t)??null;$T(e,s)||(a===`retain`&&u(),o[t]=e)}else if(!i.deleted){r.set(t,s);let n=o[t];n!==void 0&&($T(n,s)?n!==null&&i.delete(e):(a===`retain`&&u(),s===null?delete o[t]:o[t]=s))}i.deleted||(a===`insert`&&u(),iE(n,i.content));break}}i=i.right}for(u();t.length>0;){let e=t[t.length-1];if(e.retain!==void 0&&e.attributes===void 0)t.pop();else break}}),this._delta=t}return this._delta}},hE=class e extends DT{constructor(e){super(),this._pending=e===void 0?[]:[()=>this.insert(0,e)],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??_T(),this._length}_integrate(e,t){super._integrate(e,t);try{this._pending.forEach(e=>e())}catch(e){console.error(e)}this._pending=null}_copy(){return new e}clone(){let t=new e;return t.applyDelta(this.toDelta()),t}_callObserver(e,t){super._callObserver(e,t);let n=new mE(this,e,t);ET(this,e,n),!e.local&&this._hasFormatting&&(e._needFormattingCleanup=!0)}toString(){this.doc??_T();let e=``,t=this._start;for(;t!==null;)!t.deleted&&t.countable&&t.content.constructor===KE&&(e+=t.content.str),t=t.right;return e}toJSON(){return this.toString()}applyDelta(e,{sanitize:t=!0}={}){this.doc===null?this._pending.push(()=>this.applyDelta(e)):Zw(this.doc,n=>{let r=new eE(null,this._start,0,new Map);for(let i=0;i<e.length;i++){let a=e[i];if(a.insert!==void 0){let o=!t&&typeof a.insert==`string`&&i===e.length-1&&r.right===null&&a.insert.slice(-1)===`
81
+ `?a.insert.slice(0,-1):a.insert;(typeof o!=`string`||o.length>0)&&sE(n,this,r,o,a.attributes||{})}else a.retain===void 0?a.delete!==void 0&&pE(n,r,a.delete):cE(n,this,r,a.retain,a.attributes||{})}})}toDelta(e,t,n){this.doc??_T();let r=[],i=new Map,a=this.doc,o=``,s=this._start;function c(){if(o.length>0){let e={},t=!1;i.forEach((n,r)=>{t=!0,e[r]=n});let n={insert:o};t&&(n.attributes=e),r.push(n),o=``}}let l=()=>{for(;s!==null;){if(jw(s,e)||t!==void 0&&jw(s,t))switch(s.content.constructor){case KE:{let r=i.get(`ychange`);e!==void 0&&!jw(s,e)?(r===void 0||r.user!==s.id.client||r.type!==`removed`)&&(c(),i.set(`ychange`,n?n(`removed`,s.id):{type:`removed`})):t!==void 0&&!jw(s,t)?(r===void 0||r.user!==s.id.client||r.type!==`added`)&&(c(),i.set(`ychange`,n?n(`added`,s.id):{type:`added`})):r!==void 0&&(c(),i.delete(`ychange`)),o+=s.content.str;break}case nD:case LE:{c();let e={insert:s.content.getContent()[0]};if(i.size>0){let t={};e.attributes=t,i.forEach((e,n)=>{t[n]=e})}r.push(e);break}case zE:jw(s,e)&&(c(),iE(i,s.content));break}s=s.right}c()};return e||t?Zw(a,n=>{e&&Mw(n,e),t&&Mw(n,t),l()},`cleanup`):l(),r}insert(e,t,n){if(t.length<=0)return;let r=this.doc;r===null?this._pending.push(()=>this.insert(e,t,n)):Zw(r,r=>{let i=nE(r,this,e,!n);n||(n={},i.currentAttributes.forEach((e,t)=>{n[t]=e})),sE(r,this,i,t,n)})}insertEmbed(e,t,n){let r=this.doc;r===null?this._pending.push(()=>this.insertEmbed(e,t,n||{})):Zw(r,r=>{let i=nE(r,this,e,!n);sE(r,this,i,t,n||{})})}delete(e,t){if(t===0)return;let n=this.doc;n===null?this._pending.push(()=>this.delete(e,t)):Zw(n,n=>{pE(n,nE(n,this,e,!0),t)})}format(e,t,n){if(t===0)return;let r=this.doc;r===null?this._pending.push(()=>this.format(e,t,n)):Zw(r,r=>{let i=nE(r,this,e,!1);i.right!==null&&cE(r,this,i,t,n)})}removeAttribute(e){this.doc===null?this._pending.push(()=>this.removeAttribute(e)):Zw(this.doc,t=>{BT(t,this,e)})}setAttribute(e,t){this.doc===null?this._pending.push(()=>this.setAttribute(e,t)):Zw(this.doc,n=>{VT(n,this,e,t)})}getAttribute(e){return HT(this,e)}getAttributes(){return UT(this)}_write(e){e.writeTypeRef(ZE)}},gE=e=>new hE,_E=class{constructor(e,t=()=>!0){this._filter=t,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??_T()}[Symbol.iterator](){return this}next(){let e=this._currentNode,t=e&&e.content&&e.content.type;if(e!==null&&(!this._firstCall||e.deleted||!this._filter(t)))do if(t=e.content.type,!e.deleted&&(t.constructor===bE||t.constructor===vE)&&t._start!==null)e=t._start;else for(;e!==null;){let t=e.next;if(t!==null){e=t;break}else e=e.parent===this._root?null: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})}},vE=class e extends DT{constructor(){super(),this._prelimContent=[]}get firstChild(){let e=this._first;return e?e.content.getContent()[0]:null}_integrate(e,t){super._integrate(e,t),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new e}clone(){let t=new e;return t.insert(0,this.toArray().map(e=>e instanceof DT?e.clone():e)),t}get length(){return this.doc??_T(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new _E(this,e)}querySelector(e){e=e.toUpperCase();let t=new _E(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e).next();return t.done?null:t.value}querySelectorAll(e){return e=e.toUpperCase(),hy(new _E(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e))}_callObserver(e,t){ET(this,e,new SE(this,t,e))}toString(){return MT(this,e=>e.toString()).join(``)}toJSON(){return this.toString()}toDOM(e=document,t={},n){let r=e.createDocumentFragment();return n!==void 0&&n._createAssociation(r,this),jT(this,i=>{r.insertBefore(i.toDOM(e,t,n),null)}),r}insert(e,t){this.doc===null?this._prelimContent.splice(e,0,...t):Zw(this.doc,n=>{LT(n,this,e,t)})}insertAfter(e,t){if(this.doc!==null)Zw(this.doc,n=>{let r=e&&e instanceof DT?e._item:e;FT(n,this,r,t)});else{let n=this._prelimContent,r=e===null?0:n.findIndex(t=>t===e)+1;if(r===0&&e!==null)throw Db(`Reference item not found`);n.splice(r,0,...t)}}delete(e,t=1){this.doc===null?this._prelimContent.splice(e,t):Zw(this.doc,n=>{zT(n,this,e,t)})}toArray(){return kT(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return PT(this,e)}slice(e=0,t=this.length){return OT(this,e,t)}forEach(e){jT(this,e)}_write(e){e.writeTypeRef($E)}},yE=e=>new vE,bE=class e extends vE{constructor(e=`UNDEFINED`){super(),this.nodeName=e,this._prelimAttrs=new Map}get nextSibling(){let e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){let e=this._item?this._item.prev:null;return e?e.content.type:null}_integrate(e,t){super._integrate(e,t),this._prelimAttrs.forEach((e,t)=>{this.setAttribute(t,e)}),this._prelimAttrs=null}_copy(){return new e(this.nodeName)}clone(){let t=new e(this.nodeName);return ux(this.getAttributes(),(e,n)=>{t.setAttribute(n,e)}),t.insert(0,this.toArray().map(e=>e instanceof DT?e.clone():e)),t}toString(){let e=this.getAttributes(),t=[],n=[];for(let t in e)n.push(t);n.sort();let r=n.length;for(let i=0;i<r;i++){let r=n[i];t.push(r+`="`+e[r]+`"`)}let i=this.nodeName.toLocaleLowerCase();return`<${i}${t.length>0?` `+t.join(` `):``}>${super.toString()}</${i}>`}removeAttribute(e){this.doc===null?this._prelimAttrs.delete(e):Zw(this.doc,t=>{BT(t,this,e)})}setAttribute(e,t){this.doc===null?this._prelimAttrs.set(e,t):Zw(this.doc,n=>{VT(n,this,e,t)})}getAttribute(e){return HT(this,e)}hasAttribute(e){return WT(this,e)}getAttributes(e){return e?GT(this,e):UT(this)}toDOM(e=document,t={},n){let r=e.createElement(this.nodeName),i=this.getAttributes();for(let e in i){let t=i[e];typeof t==`string`&&r.setAttribute(e,t)}return jT(this,i=>{r.appendChild(i.toDOM(e,t,n))}),n!==void 0&&n._createAssociation(r,this),r}_write(e){e.writeTypeRef(QE),e.writeKey(this.nodeName)}},xE=e=>new bE(e.readKey()),SE=class extends hT{constructor(e,t,n){super(e,n),this.childListChanged=!1,this.attributesChanged=new Set,t.forEach(e=>{e===null?this.childListChanged=!0:this.attributesChanged.add(e)})}},CE=class e extends ZT{constructor(e){super(),this.hookName=e}_copy(){return new e(this.hookName)}clone(){let t=new e(this.hookName);return this.forEach((e,n)=>{t.set(n,e)}),t}toDOM(e=document,t={},n){let r=t[this.hookName],i;return i=r===void 0?document.createElement(this.hookName):r.createDom(this),i.setAttribute(`data-yjs-hook`,this.hookName),n!==void 0&&n._createAssociation(i,this),i}_write(e){e.writeTypeRef(eD),e.writeKey(this.hookName)}},wE=e=>new CE(e.readKey()),TE=class e extends hE{get nextSibling(){let e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){let e=this._item?this._item.prev:null;return e?e.content.type:null}_copy(){return new e}clone(){let t=new e;return t.applyDelta(this.toDelta()),t}toDOM(e=document,t,n){let r=e.createTextNode(this.toString());return n!==void 0&&n._createAssociation(r,this),r}toString(){return this.toDelta().map(e=>{let t=[];for(let n in e.attributes){let r=[];for(let t in e.attributes[n])r.push({key:t,value:e.attributes[n][t]});r.sort((e,t)=>e.key<t.key?-1:1),t.push({nodeName:n,attrs:r})}t.sort((e,t)=>e.nodeName<t.nodeName?-1:1);let n=``;for(let e=0;e<t.length;e++){let r=t[e];n+=`<${r.nodeName}`;for(let e=0;e<r.attrs.length;e++){let t=r.attrs[e];n+=` ${t.key}="${t.value}"`}n+=`>`}n+=e.insert;for(let e=t.length-1;e>=0;e--)n+=`</${t[e].nodeName}>`;return n}).join(``)}toJSON(){return this.toString()}_write(e){e.writeTypeRef(tD)}},EE=e=>new TE,DE=class{constructor(e,t){this.id=e,this.length=t}get deleted(){throw Ob()}mergeWith(e){return!1}write(e,t,n){throw Ob()}integrate(e,t){throw Ob()}},OE=0,kE=class extends DE{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor===e.constructor?(this.length+=e.length,!0):!1}integrate(e,t){t>0&&(this.id.clock+=t,this.length-=t),Iw(e.doc.store,this)}write(e,t){e.writeInfo(OE),e.writeLen(this.length-t)}getMissing(e,t){return null}},AE=class e{constructor(e){this.content=e}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new e(this.content)}splice(e){throw Ob()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeBuf(this.content)}getRef(){return 3}},jE=e=>new AE(e.readBuf()),ME=class e{constructor(e){this.len=e}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new e(this.len)}splice(t){let n=new e(this.len-t);return this.len=t,n}mergeWith(e){return this.len+=e.len,!0}integrate(e,t){AC(e.deleteSet,t.id.client,t.id.clock,this.len),t.markDeleted()}delete(e){}gc(e){}write(e,t){e.writeLen(this.len-t)}getRef(){return 1}},NE=e=>new ME(e.readLen()),PE=(e,t)=>new LC({guid:e,...t,shouldLoad:t.shouldLoad||t.autoLoad||!1}),FE=class e{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;let t={};this.opts=t,e.gc||(t.gc=!1),e.autoLoad&&(t.autoLoad=!0),e.meta!==null&&(t.meta=e.meta)}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new e(PE(this.doc.guid,this.opts))}splice(e){throw Ob()}mergeWith(e){return!1}integrate(e,t){this.doc._item=t,e.subdocsAdded.add(this.doc),this.doc.shouldLoad&&e.subdocsLoaded.add(this.doc)}delete(e){e.subdocsAdded.has(this.doc)?e.subdocsAdded.delete(this.doc):e.subdocsRemoved.add(this.doc)}gc(e){}write(e,t){e.writeString(this.doc.guid),e.writeAny(this.opts)}getRef(){return 9}},IE=e=>new FE(PE(e.readString(),e.readAny())),LE=class e{constructor(e){this.embed=e}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new e(this.embed)}splice(e){throw Ob()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeJSON(this.embed)}getRef(){return 5}},RE=e=>new LE(e.readJSON()),zE=class e{constructor(e,t){this.key=e,this.value=t}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new e(this.key,this.value)}splice(e){throw Ob()}mergeWith(e){return!1}integrate(e,t){let n=t.parent;n._searchMarker=null,n._hasFormatting=!0}delete(e){}gc(e){}write(e,t){e.writeKey(this.key),e.writeJSON(this.value)}getRef(){return 6}},BE=e=>new zE(e.readKey(),e.readJSON()),VE=class e{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new e(this.arr)}splice(t){let n=new e(this.arr.slice(t));return this.arr=this.arr.slice(0,t),n}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){let n=this.arr.length;e.writeLen(n-t);for(let r=t;r<n;r++){let t=this.arr[r];e.writeString(t===void 0?`undefined`:JSON.stringify(t))}}getRef(){return 2}},HE=e=>{let t=e.readLen(),n=[];for(let r=0;r<t;r++){let t=e.readString();t===`undefined`?n.push(void 0):n.push(JSON.parse(t))}return new VE(n)},UE=Ox(`node_env`)===`development`,WE=class e{constructor(e){this.arr=e,UE&&_x(e)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new e(this.arr)}splice(t){let n=new e(this.arr.slice(t));return this.arr=this.arr.slice(0,t),n}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){let n=this.arr.length;e.writeLen(n-t);for(let r=t;r<n;r++){let t=this.arr[r];e.writeAny(t)}}getRef(){return 8}},GE=e=>{let t=e.readLen(),n=[];for(let r=0;r<t;r++)n.push(e.readAny());return new WE(n)},KE=class e{constructor(e){this.str=e}getLength(){return this.str.length}getContent(){return this.str.split(``)}isCountable(){return!0}copy(){return new e(this.str)}splice(t){let n=new e(this.str.slice(t));this.str=this.str.slice(0,t);let r=this.str.charCodeAt(t-1);return r>=55296&&r<=56319&&(this.str=this.str.slice(0,t-1)+`�`,n.str=`�`+n.str.slice(1)),n}mergeWith(e){return this.str+=e.str,!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeString(t===0?this.str:this.str.slice(t))}getRef(){return 4}},qE=e=>new KE(e.readString()),JE=[YT,QT,gE,xE,yE,wE,EE],YE=0,XE=1,ZE=2,QE=3,$E=4,eD=5,tD=6,nD=class e{constructor(e){this.type=e}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new e(this.type._copy())}splice(e){throw Ob()}mergeWith(e){return!1}integrate(e,t){this.type._integrate(e.doc,t)}delete(e){let t=this.type._start;for(;t!==null;)t.deleted?t.id.clock<(e.beforeState.get(t.id.client)||0)&&e._mergeStructs.push(t):t.delete(e),t=t.right;this.type._map.forEach(t=>{t.deleted?t.id.clock<(e.beforeState.get(t.id.client)||0)&&e._mergeStructs.push(t):t.delete(e)}),e.changed.delete(this.type)}gc(e){let t=this.type._start;for(;t!==null;)t.gc(e,!0),t=t.right;this.type._start=null,this.type._map.forEach(t=>{for(;t!==null;)t.gc(e,!0),t=t.left}),this.type._map=new Map}write(e,t){this.type._write(e)}getRef(){return 7}},rD=e=>new nD(JE[e.readTypeRef()](e)),iD=(e,t)=>{let n=t,r=0,i;do r>0&&(n=gw(n.client,n.clock+r)),i=Rw(e,n),r=n.clock-i.id.clock,n=i.redone;while(n!==null&&i instanceof lD);return{item:i,diff:r}},aD=(e,t)=>{for(;e!==null&&e.keep!==t;)e.keep=t,e=e.parent._item},oD=(e,t,n)=>{let{client:r,clock:i}=t.id,a=new lD(gw(r,i+n),t,gw(r,i+n-1),t.right,t.rightOrigin,t.parent,t.parentSub,t.content.splice(n));return t.deleted&&a.markDeleted(),t.keep&&(a.keep=!0),t.redone!==null&&(a.redone=gw(t.redone.client,t.redone.clock+n)),t.right=a,a.right!==null&&(a.right.left=a),e._mergeStructs.push(a),a.parentSub!==null&&a.right===null&&a.parent._map.set(a.parentSub,a),t.length=n,a},sD=(e,t)=>_y(e,e=>DC(e.deletions,t)),cD=(e,t,n,r,i,a)=>{let o=e.doc,s=o.store,c=o.clientID,l=t.redone;if(l!==null)return Bw(e,l);let u=t.parent._item,d=null,f;if(u!==null&&u.deleted===!0){if(u.redone===null&&(!n.has(u)||cD(e,u,n,r,i,a)===null))return null;for(;u.redone!==null;)u=Bw(e,u.redone)}let p=u===null?t.parent:u.content.type;if(t.parentSub===null){for(d=t.left,f=t;d!==null;){let t=d;for(;t!==null&&t.parent._item!==u;)t=t.redone===null?null:Bw(e,t.redone);if(t!==null&&t.parent._item===u){d=t;break}d=d.left}for(;f!==null;){let t=f;for(;t!==null&&t.parent._item!==u;)t=t.redone===null?null:Bw(e,t.redone);if(t!==null&&t.parent._item===u){f=t;break}f=f.right}}else if(f=null,t.right&&!i){for(d=t;d!==null&&d.right!==null&&(d.right.redone||DC(r,d.right.id)||sD(a.undoStack,d.right.id)||sD(a.redoStack,d.right.id));)for(d=d.right;d.redone;)d=Bw(e,d.redone);if(d&&d.right!==null)return null}else d=p._map.get(t.parentSub)||null;let m=gw(c,Fw(s,c)),h=new lD(m,d,d&&d.lastId,f,f&&f.id,p,t.parentSub,t.content.copy());return t.redone=m,aD(h,!0),h.integrate(e,0),h},lD=class e extends DE{constructor(e,t,n,r,i,a,o,s){super(e,s.getLength()),this.origin=n,this.left=t,this.right=r,this.rightOrigin=i,this.parent=a,this.parentSub=o,this.redone=null,this.content=s,this.info=this.content.isCountable()?2:0}set marker(e){(this.info&8)>0!==e&&(this.info^=8)}get marker(){return(this.info&8)>0}get keep(){return(this.info&1)>0}set keep(e){this.keep!==e&&(this.info^=1)}get countable(){return(this.info&2)>0}get deleted(){return(this.info&4)>0}set deleted(e){this.deleted!==e&&(this.info^=4)}markDeleted(){this.info|=4}getMissing(t,n){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=Fw(n,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=Fw(n,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===mw&&this.id.client!==this.parent.client&&this.parent.clock>=Fw(n,this.parent.client))return this.parent.client;if(this.origin&&=(this.left=Vw(t,n,this.origin),this.left.lastId),this.rightOrigin&&=(this.right=Bw(t,this.rightOrigin),this.right.id),this.left&&this.left.constructor===kE||this.right&&this.right.constructor===kE)this.parent=null;else if(!this.parent)this.left&&this.left.constructor===e?(this.parent=this.left.parent,this.parentSub=this.left.parentSub):this.right&&this.right.constructor===e&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===mw){let e=Rw(n,this.parent);e.constructor===kE?this.parent=null:this.parent=e.content.type}return null}integrate(e,t){if(t>0&&(this.id.clock+=t,this.left=Vw(e,e.doc.store,gw(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(t),this.length-=t),this.parent){if(!this.left&&(!this.right||this.right.left!==null)||this.left&&this.left.right!==this.right){let t=this.left,n;if(t!==null)n=t.right;else if(this.parentSub!==null)for(n=this.parent._map.get(this.parentSub)||null;n!==null&&n.left!==null;)n=n.left;else n=this.parent._start;let r=new Set,i=new Set;for(;n!==null&&n!==this.right;){if(i.add(n),r.add(n),hw(this.origin,n.origin)){if(n.id.client<this.id.client)t=n,r.clear();else if(hw(this.rightOrigin,n.rightOrigin))break}else if(n.origin!==null&&i.has(Rw(e.doc.store,n.origin)))r.has(Rw(e.doc.store,n.origin))||(t=n,r.clear());else break;n=n.right}this.left=t}if(this.left!==null){let e=this.left.right;this.right=e,this.left.right=this}else{let e;if(this.parentSub!==null)for(e=this.parent._map.get(this.parentSub)||null;e!==null&&e.left!==null;)e=e.left;else e=this.parent._start,this.parent._start=this;this.right=e}this.right===null?this.parentSub!==null&&(this.parent._map.set(this.parentSub,this),this.left!==null&&this.left.delete(e)):this.right.left=this,this.parentSub===null&&this.countable&&!this.deleted&&(this.parent._length+=this.length),Iw(e.doc.store,this),this.content.integrate(e,this),Kw(e,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(e)}else new kE(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:gw(this.id.client,this.id.clock+this.length-1)}mergeWith(e){if(this.constructor===e.constructor&&hw(e.origin,this.lastId)&&this.right===e&&hw(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)){let t=this.parent._searchMarker;return t&&t.forEach(t=>{t.p===e&&(t.p=this,!this.deleted&&this.countable&&(t.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){let t=this.parent;this.countable&&this.parentSub===null&&(t._length-=this.length),this.markDeleted(),AC(e.deleteSet,this.id.client,this.id.clock,this.length),Kw(e,t,this.parentSub),this.content.delete(e)}}gc(e,t){if(!this.deleted)throw kb();this.content.gc(e),t?Hw(e,this,new kE(this.id,this.length)):this.content=new ME(this.length)}write(e,t){let n=t>0?gw(this.id.client,this.id.clock+t-1):this.origin,r=this.rightOrigin,i=this.parentSub,a=this.content.getRef()&31|(n===null?0:128)|(r===null?0:64)|(i===null?0:32);if(e.writeInfo(a),n!==null&&e.writeLeftID(n),r!==null&&e.writeRightID(r),n===null&&r===null){let t=this.parent;if(t._item!==void 0){let n=t._item;if(n===null){let n=_w(t);e.writeParentInfo(!0),e.writeString(n)}else e.writeParentInfo(!1),e.writeLeftID(n.id)}else t.constructor===String?(e.writeParentInfo(!0),e.writeString(t)):t.constructor===mw?(e.writeParentInfo(!1),e.writeLeftID(t)):kb();i!==null&&e.writeString(i)}this.content.write(e,t)}},uD=(e,t)=>dD[t&31](e),dD=[()=>{kb()},NE,HE,jE,qE,RE,BE,rD,GE,IE,()=>{kb()}],fD=10,pD=class extends DE{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor===e.constructor?(this.length+=e.length,!0):!1}integrate(e,t){kb()}write(e,t){e.writeInfo(fD),sb(e.restEncoder,this.length-t)}getMissing(e,t){return null}},mD=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:{},hD=`__ $YJS$ __`;mD[hD]===!0&&console.error(`Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438`),mD[hD]=!0;var gD={anthropic:`Claude`,openai:`GPT`,gemini:`Gemini`,"local-ollama":`Local model`,"local-llamacpp":`Local model`},_D=`Assistant`;function vD(e){return(e.defaultModelId?e.models.find(t=>t.id===e.defaultModelId):void 0)||(e.models.length===1?e.models[0]:void 0)}function yD(e,t){let n=vD(e);if(!n)return _D;let r=gD[n.provider]||`Assistant`;return t===`family`?r:n.displayName||n.modelId||r}function bD(e){let t=M(()=>yD(e.settings,`family`)),n=M(()=>yD(e.settings,`model`));return{get family(){return B(t)},get specific(){return B(n)}}}function xD(e){return e?e+1:0}function SD(e){let t=0;return e.forEach(e=>{e.isText?t+=e.text.length:e.type.name===`hardBreak`&&(t+=1)}),t}function CD(e){if(e.isTextblock)return SD(e);let t=0;for(let n=0;n<e.childCount;n++)n>0&&(t+=1),t+=CD(e.child(n));return t}function wD(e,t,n){if(e.isTextblock)return So(n+Math.min(t,SD(e)));let r=0,i=n;for(let n=0;n<e.childCount;n++){let a=e.child(n),o=i+1;n>0&&(r+=1);let s=CD(a);if(r+s>t)return wD(a,t-r,o);r+=s,i+=a.nodeSize}return So(n+e.content.size)}function TD(e,t){let n=0,r=0,i=e.childCount;for(let a=0;a<i;a++){let o=e.child(a),s=r+1,c=o.type.name===`heading`?xD(o.attrs.level||1):0,l=c+CD(o);if(n+l>t){let e=t-n;return wD(o,Math.max(0,e-c),s)}if(n+=l,r+=o.nodeSize,a<i-1&&(n+=1,n>t))return So(s+o.content.size)}return So(e.content.size)}function ED(e,t,n){if(e.isTextblock)return Math.min(t-n,SD(e));let r=0,i=n;for(let n=0;n<e.childCount;n++){let a=e.child(n),o=i+1;if(n>0&&(r+=1),t<i+a.nodeSize)return t<=o?r:r+ED(a,t,o);r+=CD(a),i+=a.nodeSize}return r}function DD(e,t){let n=0,r=0,i=e.childCount;for(let a=0;a<i;a++){let o=e.child(a),s=r+1,c=o.type.name===`heading`?xD(o.attrs.level||1):0,l=CD(o);if(t<r+o.nodeSize)return xo(t<=s?n+c:n+c+ED(o,t,s));n+=c+l,r+=o.nodeSize,a<i-1&&(n+=1)}return xo(n)}function OD(e,t,n,r){if(t.isTextblock){let i=0;for(let a=0;a<e.length;a++){let o=e.get(a);if(o instanceof TE){if(o===r.type)return So(n+Math.min(i+r.index,SD(t)));i+=o.length}}return null}let i=n;e.length!==t.childCount&&console.warn(`[positions] Y.js/PM child count mismatch: yEl(${e.nodeName}).length=${e.length} vs pmNode(${t.type.name}).childCount=${t.childCount}`);let a=Math.min(e.length,t.childCount);for(let n=0;n<a;n++){let a=e.get(n),o=t.child(n),s=i+1;if(a instanceof bE){let e=OD(a,o,s,r);if(e!==null)return e}i+=o.nodeSize}return null}function kD(e,t,n){let r=0,i=Math.min(e.childCount,t.length);for(let a=0;a<i;a++){let i=t.get(a),o=e.child(a),s=r+1;if(i instanceof bE){let e=OD(i,o,s,n);if(e!==null)return e}r+=o.nodeSize}return null}function AD(e,t,n){let r,i;try{let t=bw(n.fromRel),a=bw(n.toRel);r=Ew(t,e),i=Ew(a,e)}catch(e){return console.warn(`[positions] relRangeToPmPositions: failed to resolve relRange:`,e),null}if(!r||!i)return null;let a=e.getXmlFragment(`default`),o=kD(t,a,r),s=kD(t,a,i);return o===null||s===null?null:{from:o,to:s}}function jD(e,t,n){if(e.relRange&&n){let r=AD(n,t,e.relRange);if(r&&r.from<=r.to)return{...r,method:`rel`};console.warn(r?`[positions] annotationToPmRange: inverted rel range for ${e.id}, falling back to flat`:`[positions] annotationToPmRange: relRange resolved to null for ${e.id}, falling back to flat`)}return e.range?{from:TD(t,e.range.from),to:TD(t,e.range.to),method:`flat`}:null}function MD(e,t){return{from:DD(e,t.from),to:DD(e,t.to)}}function ND(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`)}function PD(e){let t=ND(e),n=[],r=t.replace(/```(\w*)\n?([\s\S]*?)```/g,(e,t,r)=>{let i=n.length,a=t?` class="language-${t}"`:``;return n.push(`<pre><code${a}>${r.trimEnd()}</code></pre>`),`\x00BLOCK${i}\x00`});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,(e,t,n)=>{let r=n.trim();return/^(https?:\/\/|mailto:|#)/i.test(r)?`<a href="${r}" target="_blank" rel="noopener noreferrer">${t}</a>`:t}).replace(/^[*-] (.+)$/gm,`<li>$1</li>`).replace(/\n\n/g,`</p><p>`).replace(/\n/g,`<br>`);for(let e=0;e<n.length;e++)r=r.replace(`\x00BLOCK${e}\x00`,n[e]);return r}var FD=H(`<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>`),ID=H(`<button title="Clear chat history" data-testid="clear-chat-btn" style="background: none; border: none; cursor: pointer; color: var(--tandem-fg-subtle); font-size: 13px; padding: 2px 4px; line-height: 1;">Clear</button>`),LD=H(`<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>`),RD=H(`<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>`),zD=H(`<button type="button" class="chat-anchor-quote svelte-15oag3v" style="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;" title="Click to scroll to this text"> </button>`),BD=H(`<div class="chat-markdown svelte-15oag3v"></div>`),VD=H(`<div style="white-space: pre-wrap; word-break: break-word;"> </div>`),HD=H(`<div><div style="display: flex; gap: 6px; align-items: center; margin-bottom: 4px;"><span> </span> <!> <span style="font-size: 10px; color: var(--tandem-fg-subtle); margin-left: auto;"> </span></div> <!> <!></div>`),UD=H(`<span></span>`),WD=H(`<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>`),GD=H(`<div style="padding: var(--tandem-space-1) var(--tandem-space-3); background: var(--tandem-accent-bg); border-top: 1px solid var(--tandem-accent-border); font-size: 11px; color: var(--tandem-accent-fg-strong); display: flex; justify-content: space-between; align-items: center;"><span> </span> <button style="background: none; border: none; cursor: pointer; color: var(--tandem-fg-muted); font-size: 14px;">x</button></div>`),KD=H(`<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-input-area svelte-15oag3v"><textarea placeholder="Message your AI…" class="chat-textarea svelte-15oag3v"></textarea> <button class="chat-send-btn svelte-15oag3v" aria-label="Send message" title="Send · Enter" data-testid="chat-send-btn"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" style="display:block" aria-hidden="true"><path d="M14 2L2 8l4 2 2 4 2-4 4-8z"></path></svg></button></div></div>`);function qD(e,t){A(t,!0);let n=[0,.2,.4],r=bD(xv()),i=J(t,`inputEl`,15,null),a=M(()=>t.reduceMotion?`auto`:`smooth`),o=N(ln([])),s=N(``),c=N(void 0),l=N(void 0);R(()=>{i(B(l)??null)}),R(()=>{if(!t.ctrlYdoc)return;let e=t.ctrlYdoc.getMap(Ha),n=()=>{let t=[];e.forEach(e=>{t.push(e)}),t.sort((e,t)=>e.timestamp-t.timestamp||e.id.localeCompare(t.id)),P(o,t,!0)};return e.observe(n),n(),()=>e.unobserve(n)});let u=!1;R(()=>{B(o);let e=!!t.claudeActive,n=kr(()=>B(a));if(!e&&u){u=!1;return}u=e,B(c)?.scrollIntoView({behavior:n})}),R(()=>{let e=t.visible,n=kr(()=>B(a));e&&B(c)?.scrollIntoView({behavior:n})});let d=M(()=>B(o).filter(e=>e.author===`claude`&&!e.read).length);function f(){if(!t.ctrlYdoc||!B(s).trim())return;let e=t.ctrlYdoc.getMap(Ha),n={id:uc(),author:`user`,text:B(s).trim(),timestamp:Date.now(),...t.activeDocId?{documentId:t.activeDocId}:{},...t.capturedAnchor?{anchor:t.capturedAnchor}:{},read:!1};e.set(n.id,n),P(s,``),t.onCapturedAnchorChange(null),window.dispatchEvent(new CustomEvent(`tandem:addressed-ai`,{detail:{via:`chat`}}))}function p(e){e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),f())}function m(e,n){if(!(!t.editor||n&&n!==t.activeDocId))try{let n=TD(t.editor.state.doc,e.from),r=TD(t.editor.state.doc,e.to);t.editor.chain().focus().setTextSelection({from:n,to:r}).scrollIntoView().run()}catch(e){console.warn(`[ChatPanel] Could not scroll to anchor:`,e instanceof Error?e.message:e)}}function h(e){return e?t.openDocs.find(t=>t.id===e)?.fileName??null:null}async function g(){try{await fetch(`http://127.0.0.1:${ba}${Nc}`,{method:`DELETE`})}catch(e){console.warn(`[ChatPanel] Failed to clear chat:`,e)}}var _=KD(),v=F(_),y=L(F(v)),b=F(y),x=e=>{var t=FD(),n=F(t,!0);O(t),z(()=>W(n,B(d))),U(e,t)};G(b,e=>{B(d)>0&&e(x)});var S=L(b,2),C=e=>{var t=ID();V(`click`,t,g),U(e,t)};G(S,e=>{B(o).length>0&&e(C)}),O(y),O(v);var w=L(v,2),ee=F(w),T=e=>{U(e,LD())};G(ee,e=>{B(o).length===0&&e(T)});var E=L(ee,2);fi(E,17,()=>B(o),e=>e.id,(e,t)=>{var n=HD(),i=F(n),a=F(i),o=F(a,!0);O(a);var s=L(a,2),c=e=>{var n=RD(),r=F(n,!0);O(n),z(e=>W(r,e),[()=>h(B(t).documentId)??B(t).documentId]),U(e,n)};G(s,e=>{B(t).documentId&&e(c)});var l=L(s,2),u=F(l,!0);O(l),O(i);var d=L(i,2),f=e=>{var n=zD(),r=F(n,!0);O(n),z(()=>{q(n,`data-testid`,`chat-anchor-quote-${B(t).id??``}`),W(r,B(t).anchor.textSnapshot)}),V(`click`,n,()=>m(B(t).anchor,B(t).documentId)),U(e,n)};G(d,e=>{B(t).anchor&&e(f)});var p=L(d,2),g=e=>{var n=BD();vi(n,()=>PD(B(t).text),!0),O(n),U(e,n)},_=e=>{var n=VD(),r=F(n,!0);O(n),z(()=>W(r,B(t).text)),U(e,n)};G(p,e=>{B(t).author===`claude`?e(g):e(_,-1)}),O(n),z(e=>{K(n,`margin-bottom: var(--tandem-space-3); padding: var(--tandem-space-2) var(--tandem-space-3); border-radius: var(--tandem-r-4); background: ${B(t).author===`user`?`var(--tandem-accent-bg)`:`var(--tandem-surface)`}; border: 1px solid ${B(t).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);`),K(a,`font-weight: 600; font-size: 11px; color: ${B(t).author===`claude`?`var(--tandem-accent)`:`var(--tandem-fg-muted)`}; text-transform: uppercase;`),W(o,B(t).author===`claude`?r.family:`You`),W(u,e)},[()=>new Date(B(t).timestamp).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})]),U(e,n)});var te=L(E,2),ne=e=>{var r=WD(),i=F(r);fi(i,20,()=>n,e=>e,(e,t)=>{var n=UD();z(()=>K(n,`width: 5px; height: 5px; border-radius: 50%; background: var(--tandem-author-claude); animation: tandem-typing-bounce 1.2s ease-in-out ${t??``}s infinite;`)),U(e,n)}),O(i);var a=L(i,2),o=F(a,!0);O(a),O(r),z(()=>W(o,t.claudeStatus??`Your AI is thinking...`)),U(e,r)};G(te,e=>{t.claudeActive&&e(ne)}),da(L(te,2),e=>P(c,e),()=>B(c)),O(w),Ni(w,(e,t)=>Vu?.(e,t),()=>`y`);var D=L(w,2),re=e=>{var n=GD(),r=F(n),i=F(r);O(r);var a=L(r,2);O(n),z(e=>W(i,`with selection: “${e??``}${t.capturedAnchor.textSnapshot.length>40?`...`:``}”`),[()=>t.capturedAnchor.textSnapshot.slice(0,40)]),V(`click`,a,()=>t.onCapturedAnchorChange(null)),U(e,n)};G(D,e=>{t.capturedAnchor&&e(re)});var ie=L(D,2),ae=F(ie);Tn(ae),q(ae,`rows`,1),da(ae,e=>P(l,e),()=>B(l));var oe=L(ae,2);O(ie),O(_),z(e=>{$i(ae,B(s)),oe.disabled=e},[()=>!B(s).trim()]),V(`input`,ae,e=>P(s,e.target.value,!0)),V(`keydown`,ae,p),V(`click`,oe,f),U(e,_),j()}zr([`click`,`input`,`keydown`]);var JD=H(`<button type="button" data-testid="apply-changes-btn"> </button>`);function YD(e,t){A(t,!0);let n=N(!1),r=M(()=>t.annotations.filter(e=>e.status===`accepted`)),i=M(()=>t.annotations.filter(e=>e.status===`pending`)),a=M(()=>B(r).length===0||B(n));async function o(){if(B(a)||!t.documentId)return;let e=`Apply ${B(r).length} change(s) as tracked revisions?\n\nThe changes will appear as tracked revisions in Word — you can Accept or Reject each one individually.\n\nYour original file will be backed up.`;if(B(i).length>0&&(e+=`\n\n⚠ ${B(i).length} annotation(s) are still pending review and will not be applied.`),confirm(e)){P(n,!0);try{let e=await fetch(`${Il}${wc}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({documentId:t.documentId})}),n=await e.json().catch(e=>(console.error(`[ApplyChanges] Failed to parse response JSON:`,e),null));if(!e.ok){alert(n?.message??`Apply failed (HTTP ${e.status}).`);return}let r=n?.data;if(r){let e=[`Applied ${r.applied??0} tracked change(s).`];r.rejected>0&&e.push(`${r.rejected} could not be applied.`),r.backupPath&&e.push(`\nBackup saved to:\n${r.backupPath}`),alert(e.join(` `))}else alert(`Changes applied successfully.`)}catch(e){console.error(`[ApplyChanges] Request failed:`,e),alert(e instanceof TypeError?`Could not reach the server.`:`Apply failed: ${e instanceof Error?e.message:String(e)}`)}finally{P(n,!1)}}}var s=Yr(),c=I(s),l=e=>{var t=JD();let i;var s=F(t,!0);O(t),z(()=>{i=Hi(t,1,`acb-btn svelte-hdlegv`,null,i,{"is-disabled":B(a),"is-applying":B(n)}),t.disabled=B(a),q(t,`title`,B(r).length===0?`No accepted suggestions to apply`:void 0),W(s,B(n)?`Applying…`:`Apply as Tracked Changes (${B(r).length})`)}),V(`click`,t,o),U(e,t)};G(c,e=>{t.activeDocFormat===`docx`&&e(l)}),U(e,s),j()}zr([`click`]);function XD(e,t){return e.id<t.id?-1:+(e.id>t.id)}function ZD(e){return[...e].sort((e,t)=>{let n=Number.isFinite(e.range?.from)?e.range.from:1/0,r=Number.isFinite(t.range?.from)?t.range.from:1/0;return n===r?XD(e,t):n<r?-1:1})}function QD(e){return[...e].sort((e,t)=>{let n=(Number.isFinite(e.timestamp)?e.timestamp:0)-(Number.isFinite(t.timestamp)?t.timestamp:0);return n===0?XD(e,t):n})}function $D(e,t){return t===`chronological`?QD(e):ZD(e)}function eO(e,t){if(!t)return-1;for(let n=0;n<e.length;n++)if(e[n].id===t)return n;return-1}function tO(e,t){if(e.length===0)return null;let n=eO(e,t);return n===-1?e[0].id:e[(n+1)%e.length].id}function nO(e,t){if(e.length===0)return null;let n=eO(e,t);return n===-1?e[e.length-1].id:e[(n-1+e.length)%e.length].id}var rO={background:`var(--tandem-warning-bg)`,border:`var(--tandem-warning-border)`,color:`var(--tandem-warning-fg-strong)`};function iO(e,t){return e.type===`highlight`?[]:t??[]}var aO=H(`<button class="aca-btn aca-btn--accept svelte-1u9ox5p">Accept</button>`),oO=H(`<button class="aca-btn aca-btn--reject svelte-1u9ox5p">Reject</button>`),sO=H(`<div class="aca-row svelte-1u9ox5p"><!> <!></div>`),cO=H(`<button class="aca-btn aca-btn--ghost svelte-1u9ox5p">Archive</button>`),lO=H(`<button class="aca-btn aca-btn--send svelte-1u9ox5p"> </button>`),uO=H(`<div class="aca-row svelte-1u9ox5p"><!> <!></div>`),dO=H(`<button class="aca-btn aca-btn--ghost aca-standalone svelte-1u9ox5p">Remove</button>`),fO=H(`<div class="aca-undo-error svelte-1u9ox5p">Can't undo — text has changed.</div>`),pO=H(`<div class="aca-undo-row svelte-1u9ox5p"><button data-testid="undo-btn" class="aca-undo svelte-1u9ox5p">Undo</button> <!></div>`);function mO(e,t){A(t,!0);let n=bD(xv()),r=N(!1),i=null;function a(){i&&=(clearTimeout(i),null)}function o(e){if(e.stopPropagation(),!t.onUndo)return;let n=t.onUndo(t.annotationId);if(n){a(),P(r,!1);return}n||(P(r,!0),a(),i=setTimeout(()=>{P(r,!1),i=null},3e3))}_a(a);var s=Yr(),c=I(s),l=e=>{var n=sO(),r=F(n),i=e=>{var n=aO();z(()=>q(n,`data-testid`,`accept-btn-${t.annotationId??``}`)),V(`click`,n,e=>{e.stopPropagation(),t.onAccept(t.annotationId)}),U(e,n)};G(r,e=>{t.onAccept&&e(i)});var a=L(r,2),o=e=>{var n=oO();z(()=>q(n,`data-testid`,`dismiss-btn-${t.annotationId??``}`)),V(`click`,n,e=>{e.stopPropagation(),t.onDismiss(t.annotationId)}),U(e,n)};G(a,e=>{t.onDismiss&&e(o)}),O(n),U(e,n)},u=e=>{var r=uO(),i=F(r),a=e=>{var n=cO();z(()=>q(n,`data-testid`,`archive-btn-${t.annotationId??``}`)),V(`click`,n,e=>{e.stopPropagation(),t.onRemove(t.annotationId)}),U(e,n)};G(i,e=>{t.onRemove&&e(a)});var o=L(i,2),s=e=>{var r=lO(),i=F(r);O(r),z(()=>{q(r,`data-testid`,`send-to-claude-btn-${t.annotationId??``}`),W(i,`Send to ${n.family??``}`)}),V(`click`,r,e=>{e.stopPropagation(),t.onSendToClaude(t.annotationId)}),U(e,r)};G(o,e=>{t.onSendToClaude&&e(s)}),O(r),U(e,r)},d=e=>{var n=dO();z(()=>q(n,`data-testid`,`remove-btn-${t.annotationId??``}`)),V(`click`,n,e=>{e.stopPropagation(),t.onRemove(t.annotationId)}),U(e,n)},f=e=>{var t=pO(),n=F(t),i=L(n,2),a=e=>{U(e,fO())};G(i,e=>{B(r)&&e(a)}),O(t),V(`click`,n,o),U(e,t)};G(c,e=>{t.isPending&&!t.isEditing&&(t.onAccept||t.onDismiss)?e(l):t.isPending&&!t.isEditing&&t.annotationType===`note`?e(u,1):t.isPending&&!t.isEditing&&t.onRemove?e(d,2):!t.isPending&&t.undoable&&t.onUndo&&e(f,3)}),U(e,s),j()}zr([`click`]);var hO=`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);`,gO=H(`<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),_O=H(`<textarea></textarea>`),vO=H(`<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 yO(e,t){A(t,!0);let n=N(null);R(()=>{B(n)?.focus()});var r=vO(),i=F(r),a=e=>{var r=gO(),i=I(r),a=L(i,2);Tn(a),da(a,e=>P(n,e),()=>B(n));var o=L(a,2),s=L(o,2);Tn(s),z(()=>{q(i,`for`,`edit-newtext-${t.annotationId??``}`),q(a,`id`,`edit-newtext-${t.annotationId??``}`),q(a,`data-testid`,`edit-newtext-${t.annotationId??``}`),$i(a,t.editNewText),K(a,hO),q(o,`for`,`edit-reason-${t.annotationId??``}`),q(s,`id`,`edit-reason-${t.annotationId??``}`),q(s,`data-testid`,`edit-reason-${t.annotationId??``}`),$i(s,t.editReason),K(s,hO)}),V(`input`,a,e=>t.onChangeEditNewText(e.target.value)),V(`keydown`,a,function(...e){t.onKeyDown?.apply(this,e)}),V(`input`,s,e=>t.onChangeEditReason(e.target.value)),V(`keydown`,s,function(...e){t.onKeyDown?.apply(this,e)}),U(e,r)},o=e=>{var r=_O();Tn(r),da(r,e=>P(n,e),()=>B(n)),z(()=>{q(r,`data-testid`,`edit-text-${t.annotationId??``}`),$i(r,t.editText),K(r,hO)}),V(`input`,r,e=>t.onChangeEditText(e.target.value)),V(`keydown`,r,function(...e){t.onKeyDown?.apply(this,e)}),U(e,r)};G(i,e=>{t.hasSuggestedText?e(a):e(o,-1)});var s=L(i,2),c=F(s),l=L(c,2);O(s),O(r),z(()=>{q(c,`data-testid`,`edit-save-btn-${t.annotationId??``}`),q(l,`data-testid`,`edit-cancel-btn-${t.annotationId??``}`)}),V(`click`,r,e=>e.stopPropagation()),V(`keydown`,r,e=>e.stopPropagation()),V(`click`,c,e=>{e.stopPropagation(),t.onSave()}),V(`click`,l,e=>{e.stopPropagation(),t.onCancel()}),U(e,r),j()}zr([`click`,`keydown`,`input`]);function bO(e,t){return e===`claude`?t??`Assistant`:e===`import`?`Imported`:`You`}function xO(e){let t=Math.floor((Date.now()-e)/6e4);if(t<1)return`just now`;if(t<60)return`${t}m ago`;let n=Math.floor(t/60);return n<24?`${n}h ago`:new Date(e).toLocaleDateString()}function SO(e){return e.suggestedText===void 0?e.type:`replacement`}function CO(e,t){return e?e.length>t?e.slice(0,t-3)+`...`:e:``}function wO(e){let t=SO(e),n=CO(e.content,60);return`${e.type===`note`?`private `:``}${t} annotation${n?`: `+n:``}, ${e.status}`}function TO(e){return e.type===`highlight`&&e.color?Oa[ka(e.color)]:`var(--tandem-author-user)`}var EO=H(`<span> </span>`),DO=H(`<button class="ach-edit-btn svelte-d1dbnh" title="Edit this annotation's content">✎ Edit</button>`),OO=H(`<span class="ach-edited svelte-d1dbnh">(edited)</span>`),kO=H(`<span class="ach-dot svelte-d1dbnh" aria-hidden="true"></span>`),AO=H(`<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 class="ach-time svelte-d1dbnh"> </span></span></div>`);function jO(e,t){A(t,!0);let n=bD(xv()),r=M(()=>SO(t.annotation)),i=M(()=>bO(t.annotation.author,n.family)),a=M(()=>t.annotation.author===`claude`?`var(--tandem-author-claude)`:`var(--tandem-author-user)`);var o=AO(),s=F(o),c=F(s),l=F(c,!0);O(c);var u=L(c,2),d=e=>{var n=Yr();yi(I(n),()=>t.extraPill),U(e,n)};G(u,e=>{t.extraPill&&e(d)});var f=L(u,2),p=e=>{var n=EO();let r;var i=F(n,!0);O(n),z(()=>{r=Hi(n,1,`ach-status svelte-d1dbnh`,null,r,{"is-accepted":t.annotation.status===`accepted`,"is-rejected":t.annotation.status!==`accepted`}),W(i,t.annotation.status)}),U(e,n)};G(f,e=>{t.isPending||e(p)});var m=L(f,2),h=e=>{var n=DO();z(()=>q(n,`data-testid`,`edit-btn-${t.annotation.id??``}`)),V(`click`,n,e=>{e.stopPropagation(),t.onEnterEdit()}),U(e,n)};G(m,e=>{t.isPending&&t.canEdit&&!t.isReviewTarget&&!t.isEditing&&e(h)}),O(s);var g=L(s,2),_=F(g),v=e=>{U(e,OO())};G(_,e=>{t.annotation.editedAt&&e(v)});var y=L(_,2),b=e=>{var t=kO();z(()=>K(t,`background: ${B(a)??``};`)),U(e,t)};G(y,e=>{t.annotation.author!==`import`&&e(b)});var x=L(y),S=L(x),C=F(S,!0);O(S),O(g),O(o),z((e,n)=>{K(c,`background: ${t.badgeBg??``}; color: ${t.badgeFg??``};`),W(l,B(r)),W(x,` ${B(i)??``} `),q(S,`title`,e),W(C,n)},[()=>new Date(t.annotation.timestamp).toLocaleString(),()=>xO(t.annotation.timestamp)]),U(e,o),j()}zr([`click`]);var MO=H(`<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 NO(e,t){A(t,!0);let n=M(()=>t.text?t.text.length>80?t.text.slice(0,77)+`...`:t.text:``);var r=Yr(),i=I(r),a=e=>{var r=MO(),i=F(r,!0);O(r),z(()=>{q(r,`data-testid`,`annotation-snippet-${t.annotationId??``}`),W(i,B(n))}),U(e,r)};G(i,e=>{t.text&&e(a)}),U(e,r),j()}var PO=H(`<div class="aca-body" style="margin: 0; color: var(--tandem-fg); line-height: 1.45;"><p style="margin: 0;"> </p></div>`),FO=H(`<!> <!> <!>`,1);function IO(e,t){A(t,!0);var n=FO(),r=I(n);jO(r,{get annotation(){return t.annotation},get isPending(){return t.isPending},get isReviewTarget(){return t.isReviewTarget},get isEditing(){return t.isEditing},get canEdit(){return t.canEdit},badgeBg:`var(--tandem-surface-sunk)`,badgeFg:`var(--tandem-fg-muted)`,get onEnterEdit(){return t.onEnterEdit}});var i=L(r,2);NO(i,{get annotationId(){return t.annotation.id},get text(){return t.annotation.textSnapshot}});var a=L(i,2),o=e=>{var n=PO(),r=F(n),i=F(r,!0);O(r),O(n),z(()=>W(i,t.annotation.content||`(no note)`)),U(e,n)};G(a,e=>{t.isEditing||e(o)}),U(e,n),j()}var LO=H(`<div class="aca-body" style="margin: 0; color: var(--tandem-fg); line-height: 1.45;"><p style="margin: 0;"> </p></div>`),RO=H(`<!> <!> <!>`,1);function zO(e,t){A(t,!0);var n=RO(),r=I(n);jO(r,{get annotation(){return t.annotation},get isPending(){return t.isPending},get isReviewTarget(){return t.isReviewTarget},get isEditing(){return t.isEditing},get canEdit(){return t.canEdit},badgeBg:`var(--tandem-surface-sunk)`,badgeFg:`var(--tandem-fg-muted)`,get onEnterEdit(){return t.onEnterEdit}});var i=L(r,2);NO(i,{get annotationId(){return t.annotation.id},get text(){return t.annotation.textSnapshot}});var a=L(i,2),o=e=>{var n=LO(),r=F(n),i=F(r,!0);O(r),O(n),z(()=>W(i,t.annotation.content||`(no note)`)),U(e,n)};G(a,e=>{t.isEditing||e(o)}),U(e,n),j()}var BO=H(`<input type="checkbox" style="margin-top: 4px; flex-shrink: 0; cursor: pointer;"/>`),VO=H(`<div style="font-size: var(--tandem-text-2xs); color: var(--tandem-fg-subtle); margin-bottom: 4px;">From: <span style="font-weight: 500;"> </span></div>`),HO=H(`<div class="aca-body" style="margin: 0; color: var(--tandem-fg); line-height: 1.45;"><p style="margin: 0;"> </p></div>`),UO=H(`<div style="display: flex; align-items: flex-start; gap: var(--tandem-space-2);"><!> <div style="flex: 1; min-width: 0;"><!> <!> <!> <!></div></div>`);function WO(e,t){A(t,!0);let n=J(t,`selected`,3,!1);var r=UO(),i=F(r),a=e=>{var r=BO();Qi(r),z(()=>{q(r,`data-testid`,`annotation-select-checkbox-${t.annotation.id??``}`),ea(r,n()),q(r,`aria-label`,`Select ${t.annotation.importSource?.author??`import`} comment for batch promote`)}),V(`click`,r,e=>e.stopPropagation()),V(`change`,r,()=>t.onToggleSelect?.(t.annotation.id)),U(e,r)};G(i,e=>{t.onToggleSelect&&e(a)});var o=L(i,2),s=F(o);jO(s,{get annotation(){return t.annotation},get isPending(){return t.isPending},get isReviewTarget(){return t.isReviewTarget},get isEditing(){return t.isEditing},get canEdit(){return t.canEdit},badgeBg:`var(--tandem-surface-sunk)`,badgeFg:`var(--tandem-fg-muted)`,get onEnterEdit(){return t.onEnterEdit}});var c=L(s,2),l=e=>{var n=VO(),r=L(F(n)),i=F(r,!0);O(r),O(n),z(()=>{q(n,`data-testid`,`annotation-import-byline-${t.annotation.id??``}`),W(i,t.annotation.importSource.author)}),U(e,n)};G(c,e=>{t.annotation.importSource?.author&&e(l)});var u=L(c,2);NO(u,{get annotationId(){return t.annotation.id},get text(){return t.annotation.textSnapshot}});var d=L(u,2),f=e=>{var n=HO(),r=F(n),i=F(r,!0);O(r),O(n),z(()=>W(i,t.annotation.content||`(no note)`)),U(e,n)};G(d,e=>{t.isEditing||e(f)}),O(o),O(r),U(e,r),j()}zr([`click`,`change`]);var GO=H(`<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>`),KO=H(`<div class="aca-body" style="margin: 0; color: var(--tandem-fg); line-height: 1.45;"><p style="margin: 0;"> </p></div>`),qO=H(`<!> <!> <!>`,1);function JO(e,t){A(t,!0);var n=qO(),r=I(n);jO(r,{get annotation(){return t.annotation},get isPending(){return t.isPending},get isReviewTarget(){return t.isReviewTarget},get isEditing(){return t.isEditing},get canEdit(){return t.canEdit},badgeBg:`var(--tandem-warning-bg)`,badgeFg:`var(--tandem-warning-fg-strong)`,get onEnterEdit(){return t.onEnterEdit},extraPill:e=>{U(e,GO())},$$slots:{extraPill:!0}});var i=L(r,2);NO(i,{get annotationId(){return t.annotation.id},get text(){return t.annotation.textSnapshot}});var a=L(i,2),o=e=>{var n=KO(),r=F(n),i=F(r,!0);O(r),O(n),z(()=>W(i,t.annotation.content||`(no note)`)),U(e,n)};G(a,e=>{t.isEditing||e(o)}),U(e,n),j()}var YO=H(`<span class="ct-author-dot ct-author-dot--claude svelte-4l0b78" aria-hidden="true"></span> `,1),XO=H(`<span> </span>`),ZO=H(`<span class="ct-author-dot ct-author-dot--user svelte-4l0b78" aria-hidden="true"></span> You`,1),QO=H(`<span class="ct-edited svelte-4l0b78">(edited)</span>`),$O=H(`<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>`),ek=H(`<div class="ct-root svelte-4l0b78" data-testid="comment-thread"></div>`);function tk(e,t){A(t,!0);let n=bD(xv());var r=Yr(),i=I(r),a=e=>{var r=ek();fi(r,21,()=>t.replies,e=>e.id,(e,t)=>{let r=M(()=>B(t).author===`claude`?`claude`:B(t).author===`import`?`import`:`user`);var i=$O(),a=F(i),o=F(a);let s;var c=F(o),l=e=>{var t=YO(),r=L(I(t));z(()=>W(r,` ${n.family??``}`)),U(e,t)},u=e=>{var n=XO(),r=F(n,!0);O(n),z(()=>{q(n,`data-testid`,`reply-import-byline-${B(t).id??``}`),W(r,B(t).importAuthor??`Imported`)}),U(e,n)},d=e=>{var t=ZO();k(),U(e,t)};G(c,e=>{B(r)===`claude`?e(l):B(r)===`import`?e(u,1):e(d,-1)}),O(o);var f=L(o,2),p=F(f),m=e=>{U(e,QO())};G(p,e=>{B(t).editedAt&&e(m)});var h=L(p);O(f),O(a);var g=L(a,2),_=F(g,!0);O(g),O(i),z(e=>{q(i,`data-testid`,`reply-${B(t).id??``}`),s=Hi(o,1,`ct-author svelte-4l0b78`,null,s,{"is-claude":B(r)===`claude`,"is-import":B(r)===`import`,"is-user":B(r)===`user`}),W(h,` ${e??``}`),W(_,B(t).text)},[()=>xO(B(t).timestamp)]),U(e,i)}),O(r),U(e,r)};G(i,e=>{t.replies.length>0&&e(a)}),U(e,r),j()}var nk=H(`<div class="art-replies svelte-155xn9n"><!></div>`),rk=H(`<button type="button"><span class="art-arrow svelte-155xn9n" aria-hidden="true">›</span> </button> <!>`,1),ik=H(`<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>`),ak=H(`<button style="padding: 1px 4px; font-size: var(--tandem-text-xs); border: none; background: none; color: var(--tandem-fg-subtle); cursor: pointer;">Reply</button>`),ok=H(`<div style="margin-top: 6px;"><!></div>`),sk=H(`<div class="art-root svelte-155xn9n"><!> <!></div>`);function ck(e,t){A(t,!0);let n=J(t,`reduceMotion`,3,!1),r=J(t,`openNonce`,3,0),i=M(()=>iO(t.annotation,t.replies)),a=M(()=>t.annotation.id),o=N(!1),s=N(!1),c=N(``),l=N(!1),u=N(null),d=M(()=>!!B(c).trim());R(()=>{B(s)&&B(u)?.focus()});let f=kr(()=>r());R(()=>{r()!==f&&(f=r(),P(s,!0))});function p(e){e.key===`Escape`&&(e.stopPropagation(),P(s,!1),P(c,``))}async function m(){let e=B(c).trim();if(!(!e||B(l))){P(l,!0);try{await t.onReply?.(B(a),e)!==!1&&(P(c,``),P(s,!1))}finally{P(l,!1)}}}var h=sk(),g=F(h),_=e=>{var t=rk(),r=I(t);let s;var c=L(F(r));O(r);var l=L(r,2),u=e=>{var t=nk();tk(F(t),{get replies(){return B(i)}}),O(t),ji(3,t,()=>Gv,()=>({reduceMotion:n()})),U(e,t)};G(l,e=>{B(o)&&e(u)}),z(()=>{q(r,`data-testid`,`reply-toggle-${B(a)??``}`),s=Hi(r,1,`art-toggle svelte-155xn9n`,null,s,{open:B(o)}),q(r,`aria-expanded`,B(o)),W(c,` ${B(i).length===1?`1 reply`:`${B(i).length} replies`}`)}),V(`click`,r,e=>{e.stopPropagation(),P(o,!B(o))}),U(e,t)};G(g,e=>{B(i).length>0&&e(_)});var v=L(g,2),y=e=>{var t=ok(),n=F(t),r=e=>{var t=ik(),n=F(t);Tn(n),da(n,e=>P(u,e),()=>B(u));var r=L(n,2),i=F(r),o=L(i,2);O(r),O(t),z(()=>{q(n,`data-testid`,`reply-input-${B(a)??``}`),$i(n,B(c)),K(n,hO),q(i,`data-testid`,`reply-send-btn-${B(a)??``}`),i.disabled=!B(d)||B(l),K(i,`padding: 2px 8px; font-size: var(--tandem-text-xs); border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-1); background: ${B(d)?`var(--tandem-accent-bg)`:`var(--tandem-surface-muted)`}; color: ${B(d)?`var(--tandem-accent-fg-strong)`:`var(--tandem-fg-subtle)`}; cursor: ${B(d)?`pointer`:`default`};`),q(o,`data-testid`,`reply-cancel-btn-${B(a)??``}`)}),V(`input`,n,e=>P(c,e.target.value,!0)),V(`keydown`,n,p),V(`click`,i,m),V(`click`,o,()=>{P(s,!1),P(c,``)}),U(e,t)},i=e=>{var t=ak();z(()=>q(t,`data-testid`,`reply-btn-${B(a)??``}`)),V(`click`,t,()=>P(s,!0)),U(e,t)};G(n,e=>{B(s)?e(r):e(i,-1)}),O(t),V(`click`,t,e=>e.stopPropagation()),V(`keydown`,t,e=>e.stopPropagation()),U(e,t)};G(v,e=>{t.isPending&&t.onReply&&!t.isEditing&&e(y)}),O(h),U(e,h),j()}zr([`click`,`keydown`,`input`]);function lk(e){return e.split(/(\s+)/).filter(Boolean)}var uk=4e4,dk=6e3;function fk(e,t){if(e.length+t.length>dk)return null;let n=lk(e),r=lk(t);if(n.length*r.length>uk)return null;let i=n.length,a=r.length,o=Array(i+1);for(let e=0;e<=i;e++)o[e]=new Uint32Array(a+1);for(let e=1;e<=i;e++)for(let t=1;t<=a;t++)n[e-1]===r[t-1]?o[e][t]=o[e-1][t-1]+1:o[e][t]=Math.max(o[e-1][t],o[e][t-1]);let s=[],c=i,l=a;for(;c>0&&l>0;)n[c-1]===r[l-1]?(s.push({type:`equal`,text:n[c-1]}),c--,l--):o[c-1][l]>o[c][l-1]?(s.push({type:`del`,text:n[c-1]}),c--):(s.push({type:`ins`,text:r[l-1]}),l--);for(;c>0;)s.push({type:`del`,text:n[c-1]}),c--;for(;l>0;)s.push({type:`ins`,text:r[l-1]}),l--;s.reverse();let u=[];for(let e of s){let t=u[u.length-1];t&&t.type===e.type?t.text+=e.text:u.push({type:e.type,text:e.text})}return u}var pk=H(`<span> </span>`),mk=H(`<span style="text-decoration: line-through; color: var(--tandem-error); background-color: var(--tandem-error-bg); border-radius: var(--tandem-r-1);"> </span>`),hk=H(`<span style="color: var(--tandem-success-fg-strong); background-color: var(--tandem-success-bg); border-radius: var(--tandem-r-1);"> </span>`),gk=H(`<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),_k=H(`<!> <span style="color: var(--tandem-success-fg-strong); background-color: var(--tandem-success-bg); padding: 0 2px; border-radius: var(--tandem-r-1);"> </span>`,1),vk=H(`<p style="margin: 0; font-size: 12px; color: var(--tandem-fg-muted);"> </p>`),yk=H(`<div class="aca-body" style="margin: 0; color: var(--tandem-fg); line-height: 1.45;"><div><!></div> <!></div>`),bk=H(`<!> <!> <!>`,1);function xk(e,t){A(t,!0);let n=M(()=>t.annotation.textSnapshot?fk(t.annotation.textSnapshot,t.annotation.suggestedText):null);var r=bk(),i=I(r);jO(i,{get annotation(){return t.annotation},get isPending(){return t.isPending},get isReviewTarget(){return t.isReviewTarget},get isEditing(){return t.isEditing},get canEdit(){return t.canEdit},badgeBg:`var(--tandem-suggestion-bg)`,badgeFg:`var(--tandem-suggestion-fg-strong)`,get onEnterEdit(){return t.onEnterEdit}});var a=L(i,2);NO(a,{get annotationId(){return t.annotation.id},get text(){return t.annotation.textSnapshot}});var o=L(a,2),s=e=>{var r=yk(),i=F(r),a=F(i),o=e=>{var t=Yr();fi(I(t),17,()=>B(n),ci,(e,t)=>{var n=Yr(),r=I(n),i=e=>{var n=pk(),r=F(n,!0);O(n),z(()=>W(r,B(t).text)),U(e,n)},a=e=>{var n=mk(),r=F(n,!0);O(n),z(()=>W(r,B(t).text)),U(e,n)},o=e=>{var n=hk(),r=F(n,!0);O(n),z(()=>W(r,B(t).text)),U(e,n)};G(r,e=>{B(t).type===`equal`?e(i):B(t).type===`del`?e(a,1):e(o,-1)}),U(e,n)}),U(e,t)},s=e=>{var n=_k(),r=I(n),i=e=>{var n=gk(),r=I(n),i=F(r,!0);O(r);var a=L(r);a.nodeValue=` → `,z(()=>W(i,t.annotation.textSnapshot)),U(e,n)};G(r,e=>{t.annotation.textSnapshot&&e(i)});var a=L(r,2),o=F(a,!0);O(a),z(()=>W(o,t.annotation.suggestedText)),U(e,n)};G(a,e=>{B(n)?e(o):e(s,-1)}),O(i);var c=L(i,2),l=e=>{var n=vk(),r=F(n,!0);O(n),z(()=>W(r,t.annotation.content)),U(e,n)};G(c,e=>{t.annotation.content&&e(l)}),O(r),z(()=>{q(i,`data-testid`,`suggestion-diff-${t.annotation.id??``}`),K(i,`padding: 4px 8px; margin-bottom: ${t.annotation.content?`4px`:`0`}; background-color: var(--tandem-surface-muted); border-radius: var(--tandem-r-2); font-size: 12px; line-height: 1.5; white-space: pre-wrap;`)}),U(e,r)};G(o,e=>{t.isEditing||e(s)}),U(e,r),j()}var Sk=H(`<div class="tandem-claude-typing svelte-3ascys" role="status" aria-live="polite"><span class="tandem-claude-typing-dot svelte-3ascys"></span> <span class="tandem-claude-typing-dot svelte-3ascys"></span> <span class="tandem-claude-typing-dot svelte-3ascys"></span></div>`),Ck=H(`<div role="listitem"><!> <!> <!> <!> <!></div>`);function wk(e,t){A(t,!0);let n=J(t,`replies`,19,()=>[]),r=J(t,`claudeTyping`,3,!1),i=J(t,`selected`,3,!1),a=J(t,`density`,3,`full`),o=J(t,`lifecycleMotion`,3,!1),s=J(t,`reduceMotion`,3,!1),c=J(t,`openRequest`,3,null),l=bD(xv()),u=N(!1),d=N(``),f=N(``),p=N(``),m=M(()=>t.annotation.status===`pending`),h=M(()=>t.annotation.suggestedText!==void 0),g=M(()=>t.onEdit!==void 0),_=M(()=>wO(t.annotation)),v=M(()=>iO(t.annotation,n())),y=M(()=>a()===`stub`?`stub`:B(u)?`full`:a()),b=-1,x=-1,S=N(0);R(()=>{let e=c();if(e)if(e.kind===`edit`){if(e.nonce===b)return;b=e.nonce,t.onEdit&&ee()}else{if(e.nonce===x)return;x=e.nonce,P(S,e.nonce,!0)}});let C=M(()=>t.annotation.author===`import`?`var(--tandem-surface-muted)`:t.annotation.type===`highlight`?`color-mix(in srgb, ${TO(t.annotation)} 18%, var(--tandem-surface))`:t.annotation.type===`note`?`var(--tandem-warning-bg)`:t.annotation.suggestedText===void 0?t.annotation.author===`claude`?`var(--tandem-author-claude-bg)`:`var(--tandem-author-user-bg)`:`var(--tandem-suggestion-bg)`),w=M(()=>t.isReviewTarget?`var(--tandem-accent-bg)`:B(C));function ee(){B(h)?(P(f,t.annotation.suggestedText??``,!0),P(p,t.annotation.content,!0)):P(d,t.annotation.content,!0),P(u,!0)}function T(){let e=B(h)?JSON.stringify({suggestedText:B(f),content:B(p)}):B(d);t.onEdit?.(t.annotation.id,e),P(u,!1)}function E(){P(u,!1)}function te(e){e.key===`Escape`&&(e.stopPropagation(),E())}function ne(e){e.target===e.currentTarget&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),t.onClick?.())}var D=Ck();let re;var ie=F(D),ae=e=>{var n=Sk();z(()=>{q(n,`data-testid`,`claude-typing-indicator-${t.annotation.id??``}`),q(n,`aria-label`,`${l.family??``} is working on this annotation`),q(n,`title`,`${l.family??``} is working on this annotation`)}),U(e,n)};G(ie,e=>{r()&&e(ae)});var oe=L(ie,2),se=e=>{WO(e,{get annotation(){return t.annotation},get isPending(){return B(m)},get isReviewTarget(){return t.isReviewTarget},get isEditing(){return B(u)},get canEdit(){return B(g)},onEnterEdit:ee,get selected(){return i()},get onToggleSelect(){return t.onToggleSelect}})},ce=e=>{zO(e,{get annotation(){return t.annotation},get isPending(){return B(m)},get isReviewTarget(){return t.isReviewTarget},get isEditing(){return B(u)},get canEdit(){return B(g)},onEnterEdit:ee})},le=e=>{JO(e,{get annotation(){return t.annotation},get isPending(){return B(m)},get isReviewTarget(){return t.isReviewTarget},get isEditing(){return B(u)},get canEdit(){return B(g)},onEnterEdit:ee})},ue=e=>{xk(e,{get annotation(){return t.annotation},get isPending(){return B(m)},get isReviewTarget(){return t.isReviewTarget},get isEditing(){return B(u)},get canEdit(){return B(g)},onEnterEdit:ee})},de=e=>{IO(e,{get annotation(){return t.annotation},get isPending(){return B(m)},get isReviewTarget(){return t.isReviewTarget},get isEditing(){return B(u)},get canEdit(){return B(g)},onEnterEdit:ee})};G(oe,e=>{t.annotation.author===`import`?e(se):t.annotation.type===`highlight`?e(ce,1):t.annotation.type===`note`?e(le,2):t.annotation.suggestedText===void 0?e(de,-1):e(ue,3)});var fe=L(oe,2),pe=e=>{yO(e,{get annotationId(){return t.annotation.id},get hasSuggestedText(){return B(h)},get editText(){return B(d)},get editNewText(){return B(f)},get editReason(){return B(p)},onChangeEditText:e=>P(d,e,!0),onChangeEditNewText:e=>P(f,e,!0),onChangeEditReason:e=>P(p,e,!0),onKeyDown:te,onSave:T,onCancel:E})};G(fe,e=>{B(u)&&e(pe)});var me=L(fe,2);mO(me,{get annotationId(){return t.annotation.id},get annotationType(){return t.annotation.type},get isPending(){return B(m)},get isEditing(){return B(u)},get undoable(){return t.undoable},get onAccept(){return t.onAccept},get onDismiss(){return t.onDismiss},get onUndo(){return t.onUndo},get onRemove(){return t.onRemove},get onSendToClaude(){return t.onSendToClaude}}),ck(L(me,2),{get annotation(){return t.annotation},get replies(){return B(v)},get isPending(){return B(m)},get isEditing(){return B(u)},get onReply(){return t.onReply},get reduceMotion(){return s()},get openNonce(){return B(S)}}),O(D),z(()=>{re=Hi(D,1,`tandem-annotation-card svelte-3ascys`,null,re,{"is-review-target":t.isReviewTarget,"is-density-clamped":B(y)===`clamped`,"is-density-stub":B(y)===`stub`}),q(D,`tabindex`,t.onClick?0:void 0),q(D,`data-testid`,`annotation-card-${t.annotation.id??``}`),q(D,`data-annotation-id`,t.annotation.id),q(D,`data-annotation-type`,t.annotation.type),q(D,`data-density`,B(y)),q(D,`data-claude-typing`,r()?`true`:void 0),q(D,`aria-label`,B(_)),q(D,`aria-current`,t.isReviewTarget?`true`:void 0),K(D,`background: ${B(w)??``}; opacity: ${B(m)?1:.6}; cursor: ${t.onClick?`pointer`:`default`};`)}),V(`click`,D,function(...e){t.onClick?.apply(this,e)}),V(`keydown`,D,ne),ji(1,D,()=>Av,()=>({enabled:o(),reduceMotion:s()})),ji(2,D,()=>jv,()=>({enabled:o(),reduceMotion:s(),id:t.annotation.id,modes:t.exitModes})),U(e,D),j()}zr([`click`,`keydown`]);var Tk=`browser`;function Ek(e,t,n){let r,i=!1;if(e.transact(()=>{r=t(),i=!0},n),!i)throw Error(`origins: transact callback did not run (origin=${n})`);return r}function Dk(e,t){return Ek(e,t,Tk)}function Ok(e,t){let n=e,r=e=>{try{t(e)}catch(t){console.warn(`[sanitizeAnnotation] onLossy threw for ${e.kind}:`,t)}},i=n.audience===`private`||n.audience===`outbound`?n.audience:n.author===`import`||n.type===`highlight`||n.type===`note`||n.type===`flag`?`private`:`outbound`,a={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(a.audience===`outbound`&&n.author===`user`&&(n.type===`note`||n.type===`highlight`||n.type===`flag`)&&(a.audience=`private`,r({kind:`audience-conflict-resolved`,id:n.id})),n.type===`suggestion`){let e,t;try{let r=JSON.parse(n.content);e=r.newText,t=r.reason??``}catch{r({kind:`malformed-suggestion-json`,id:n.id}),t=n.content}return{...a,type:`comment`,content:t,suggestedText:e}}return n.type===`question`?(r({kind:`question-to-comment`,id:n.id}),{...a,type:`comment`}):n.type===`highlight`?{...a,type:`highlight`,color:n.color}:n.type===`flag`||n.type===`note`?(n.type===`flag`&&r({kind:`flag-to-note`,id:n.id}),{...a,type:`note`}):n.type===`comment`?{...a,type:`comment`,...n.suggestedText===void 0?{}:{suggestedText:n.suggestedText}}:(r({kind:`unknown-type`,id:n.id,rawType:n.type}),{...a,type:`comment`})}var kk=e=>{console.warn(`[sanitize]`,e)};function Ak(e,t,n){if(!e)return;let r=e.getMap(La),i=r.get(t);if(!i)return;let a=Ok(i,kk);Dk(e,()=>{if(a.suggestedText!==void 0){try{let e=JSON.parse(n);r.set(t,{...a,suggestedText:e.suggestedText,content:e.content,editedAt:Date.now(),rev:(a.rev??0)+1})}catch{console.warn(`[annotation-actions] Failed to parse edit payload for annotation ${t}`)}return}r.set(t,{...a,content:n,editedAt:Date.now(),rev:(a.rev??0)+1})})}function jk(e){let{color:t,suggestedText:n,...r}=e;return{...r,type:`comment`,author:e.author===`import`?`user`:e.author,audience:`outbound`,promotedFrom:`note`,rev:(e.rev??0)+1}}function Mk(e,t){if(!e)return;let n=e.getMap(La),r=n.get(t);if(!r)return;let i=Ok(r,kk);i.type===`note`&&Dk(e,()=>{n.set(t,jk(i))})}function Nk(e,t){if(!e||t.length===0)return 0;let n=e.getMap(La),r=0;return Dk(e,()=>{for(let e of t){let t=n.get(e);if(!t)continue;let i=Ok(t,kk);i.type===`note`&&(n.set(e,jk(i)),r++)}}),r}async function Pk(e,t){try{let n=await fetch(`${Il}${jc}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({annotationId:e,documentId:t})});if(!n.ok){let e=await n.json().catch(()=>({message:`Unknown error`}));console.error(`[Tandem] Remove annotation failed:`,e)}}catch(e){console.error(`[Tandem] Remove annotation failed:`,e)}}async function Fk(e,t,n){try{let r=await fetch(`${Il}${Ac}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({annotationId:e,text:t,documentId:n})});if(!r.ok){let e=await r.json().catch(()=>({}));return console.warn(`[annotation-actions] Reply failed (${r.status}): ${e.message??`unknown error`}`),!1}return!0}catch(e){return console.error(`[annotation-actions] Reply request failed:`,e),!1}}var Ik=new Set([`ctx:annotation:accept`,`ctx:annotation:dismiss`,`ctx:annotation:reply`,`ctx:annotation:edit`,`ctx:annotation:sendToClaude`,`ctx:annotation:copy`,`ctx:annotation:remove`]);function Lk(e){return typeof e==`string`&&Ik.has(e)}var Rk=e=>e.status===`pending`,zk=e=>e.author!==`user`&&Rk(e),Bk=e=>e.author!==`user`&&Rk(e),Vk=e=>(e.type===`note`||e.type===`comment`)&&Rk(e),Hk=e=>e.author===`user`&&Rk(e),Uk=e=>e.author===`user`&&e.type===`note`&&Rk(e),Wk=e=>e.author===`user`&&Rk(e),Gk=e=>!0;function Kk(e){return{canAccept:zk(e),canDismiss:Bk(e),canReply:Vk(e),canEdit:Hk(e),canSendToClaude:Uk(e),canCopy:Gk(e),canRemove:Wk(e),isNote:e.type===`note`}}function qk(e){return e.content?.trim()?e.content:e.textSnapshot??``}var Jk=null;function Yk(e){Jk=e}function Xk(e,t,n){switch(e){case`ctx:annotation:accept`:zk(t)&&n.accept?.(t.id);return;case`ctx:annotation:dismiss`:Bk(t)&&n.dismiss?.(t.id);return;case`ctx:annotation:sendToClaude`:Uk(t)&&n.sendToClaude?.(t.id);return;case`ctx:annotation:remove`:Wk(t)&&n.remove?.(t.id);return;case`ctx:annotation:edit`:Hk(t)&&n.openEdit?.(t.id);return;case`ctx:annotation:reply`:Vk(t)&&n.openReply?.(t.id);return;case`ctx:annotation:copy`:if(Gk(t)){let e=qk(t);e&&navigator.clipboard.writeText(e).catch(()=>{})}return}}async function Zk(e,t){Yk({run:t});try{await(await ah())(`show_annotation_context_menu`,{req:Kk(e)})}catch{}}var Qk=0,$k=null;function eA(){if(!nh())return()=>{};Qk++,Qk===1&&($k=Ul(async()=>{let{listen:e}=await import(`./event-wL_2RBc7.js`);return{listen:e}},__vite__mapDeps([3,1])).then(({listen:e})=>e(`context-menu-action`,e=>{let t=e.payload?.id;Lk(t)&&Jk?.run(t)})),$k.catch(()=>{}));let e=!1;return()=>{if(!e&&(e=!0,Qk--,Qk===0)){let e=$k;$k=null,e?.then(e=>e()).catch(()=>{})}}}var tA=H(`<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 nA(e,t){A(t,!0);let n=J(t,`reduceMotion`,3,!1),r=bD(xv());var i=Yr(),a=I(i),o=e=>{var i=tA(),a=F(i),o=F(a);O(a);var s=L(a,2),c=L(s,2),l=F(c);O(c),O(i),z(()=>{W(o,`${t.selectedCount??``} selected`),W(l,`Send ${t.selectedCount??``} to ${r.family??``}`)}),V(`click`,s,function(...e){t.onClear?.apply(this,e)}),V(`click`,c,function(...e){t.onPromote?.apply(this,e)}),ji(1,i,()=>Mv,()=>({reduceMotion:n()})),ji(2,i,()=>Nv,()=>({reduceMotion:n(),exitMs:200})),U(e,i)};G(a,e=>{t.selectedCount>0&&e(o)}),U(e,i),j()}zr([`click`]);var rA=H(`<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),iA=H(`<button data-testid="bulk-accept-btn"> </button> <button data-testid="bulk-dismiss-btn">Reject All</button>`,1),aA=H(`<div style="padding: 6px var(--tandem-space-4); border-bottom: 1px solid var(--tandem-border); display: flex; gap: 4px; align-items: center;"><!></div>`);function oA(e,t){A(t,!0);let n=J(t,`confirmRef`,15,null),r=J(t,`reduceMotion`,3,!1),i=M(()=>t.bulkConfirm===`accept`),a=M(()=>t.pendingCount===t.allPendingCount?`${t.pendingCount} annotations?`:`${t.pendingCount} of ${t.allPendingCount} pending?`);var o=Yr(),s=I(o),c=e=>{var o=aA(),s=F(o),c=e=>{var r=rA(),o=I(r),s=F(o);O(o);var c=L(o,2);da(c,e=>n(e),()=>n());var l=L(c,2);K(l,`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);`),z(()=>{W(s,`${B(i)?`Accept`:`Reject`}
82
+ ${B(a)??``}`),K(c,`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: ${B(i)?`var(--tandem-success-bg)`:`var(--tandem-error-bg)`}; color: ${B(i)?`var(--tandem-success-fg-strong)`:`var(--tandem-error-fg-strong)`}; font-weight: 600;`)}),V(`click`,c,function(...e){(B(i)?t.onConfirmAccept:t.onConfirmDismiss)?.apply(this,e)}),V(`click`,l,function(...e){t.onCancel?.apply(this,e)}),U(e,r)},l=e=>{var n=iA(),r=I(n);K(r,`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 i=F(r);O(r);var a=L(r,2);K(a,`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);`),z(()=>W(i,`Accept All (${t.pendingCount??``})`)),V(`click`,r,function(...e){t.onRequestAccept?.apply(this,e)}),V(`click`,a,function(...e){t.onRequestDismiss?.apply(this,e)}),U(e,n)};G(s,e=>{t.bulkConfirm?e(c):e(l,-1)}),O(o),ji(1,o,()=>Mv,()=>({reduceMotion:r()})),ji(2,o,()=>Nv,()=>({reduceMotion:r(),exitMs:180})),U(e,o)};G(s,e=>{t.pendingCount>1&&e(c)}),U(e,o),j()}zr([`click`]);function sA(e,t,n,r){return{handleKeyDown:i=>{let{key:a}=i;if(a!==`ArrowLeft`&&a!==`ArrowRight`&&a!==`ArrowUp`&&a!==`ArrowDown`&&a!==`Home`&&a!==`End`)return;let o=r?t.filter(e=>!r(e)):t;if(o.length===0)return;i.preventDefault();let s=e(),c=o.indexOf(s),l=o.length-1,u;u=a===`Home`?0:a===`End`?l:a===`ArrowLeft`||a===`ArrowUp`?c<=0?l:c-1:c>=l?0:c+1;let d=o[u];n(d);let f=i.currentTarget?.querySelectorAll(`[role="radio"]`),p=t.indexOf(d);f?.[p]?.focus()},tabIndexFor:n=>{if(r?.(n))return-1;let i=e(),a=r?t.filter(e=>!r(e)):t;return n===(r?.(i)?a[0]:i)?0:-1}}}var cA=(e,t=m)=>{var n=Yr(),r=I(n),i=e=>{U(e,lA())},a=e=>{U(e,uA())},o=e=>{U(e,dA())},s=e=>{U(e,fA())},c=e=>{U(e,pA())},l=e=>{U(e,mA())},u=e=>{U(e,hA())};G(r,e=>{t()===`highlight`?e(i):t()===`comment`?e(a,1):t()===`lock`?e(o,2):t()===`sparkle`?e(s,3):t()===`pending`?e(c,4):t()===`check`?e(l,5):t()===`dismiss`&&e(u,6)}),U(e,n)},lA=qr(`<svg width="14" height="14" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" class="svelte-v4eg2o"><path d="M3 13h10"></path><path d="M5 11l3 1 5-5-2-2-5 5z"></path><path d="M9 4l2 2"></path></svg>`),uA=qr(`<svg width="14" height="14" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" class="svelte-v4eg2o"><path d="M2.5 3h11v8h-7l-3 2.5V11H2.5z"></path></svg>`),dA=qr(`<svg width="14" height="14" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" class="svelte-v4eg2o"><rect x="3" y="7" width="10" height="6" rx="1"></rect><path d="M5 7V5a3 3 0 0 1 6 0v2"></path></svg>`),fA=qr(`<svg class="g-suggestion svelte-v4eg2o" width="14" height="14" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><path d="M8 2v4"></path><path d="M8 10v4"></path><path d="M2 8h4"></path><path d="M10 8h4"></path><path d="M4 4l1.5 1.5"></path><path d="M10.5 10.5L12 12"></path><path d="M12 4l-1.5 1.5"></path><path d="M5.5 10.5L4 12"></path></svg>`),pA=qr(`<svg width="14" height="14" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.6" class="svelte-v4eg2o"><circle cx="8" cy="8" r="5"></circle></svg>`),mA=qr(`<svg class="g-success svelte-v4eg2o" width="14" height="14" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M3 8l3 3 7-7"></path></svg>`),hA=qr(`<svg class="g-error svelte-v4eg2o" width="14" height="14" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M4 4l8 8M12 4l-8 8"></path></svg>`),gA=H(`<span class="chip-text"> </span>`),_A=H(`<span></span>`),vA=H(`<button type="button" role="radio"><!></button>`),yA=H(`<div class="chip-bar svelte-v4eg2o" role="radiogroup" tabindex="-1"><span aria-hidden="true"></span> <!></div>`);function bA(e,t){A(t,!0);let n=J(t,`value`,3,``),r=J(t,`options`,19,()=>[]),i=J(t,`onSet`,3,()=>{}),a=J(t,`groupAriaLabel`,3,``),o=J(t,`groupTestId`,3,``),s=sA(()=>n(),kr(()=>r().map(e=>e.value)),e=>i()(e)),c=N(null),l=N(ln({left:0,width:0,ready:!1}));function u(){if(!B(c))return;let e=B(c).querySelector(`[aria-checked="true"]`);if(!e)return;let t=e.offsetLeft,n=e.offsetWidth;B(l).ready?P(l,{left:t,width:n,ready:!0},!0):(P(l,{left:t,width:n,ready:!1},!0),requestAnimationFrame(()=>{P(l,{left:t,width:n,ready:!0},!0)}))}R(()=>{if(n(),!B(c))return;let e=!1;return Er().then(()=>{e||requestAnimationFrame(()=>{e||u()})}),()=>{e=!0}}),R(()=>{if(!B(c))return;let e=new ResizeObserver(()=>u());return e.observe(B(c)),()=>e.disconnect()});var d=yA(),f=F(d);let p;fi(L(f,2),17,r,e=>e.value,(e,t)=>{let r=M(()=>B(t).value===n());var a=vA();let c;var l=F(a),u=e=>{var n=gA(),r=F(n,!0);O(n),z(()=>W(r,B(t).label)),U(e,n)},d=e=>{var n=_A();z(()=>Hi(n,1,`pip pip-${B(t).pip??``}`,`svelte-v4eg2o`)),U(e,n)},f=e=>{cA(e,()=>B(t).icon)};G(l,e=>{B(t).kind===`text`?e(u):B(t).kind===`pip`?e(d,1):B(t).kind===`icon`&&e(f,2)}),O(a),z(e=>{c=Hi(a,1,`chip svelte-v4eg2o`,null,c,{"is-checked":B(r)}),q(a,`aria-checked`,B(r)),q(a,`aria-label`,B(t).label),q(a,`title`,B(t).label),q(a,`tabindex`,e),q(a,`data-testid`,`${o()??``}-${B(t).value??``}`)},[()=>s.tabIndexFor(B(t).value)]),V(`click`,a,()=>i()(B(t).value)),U(e,a)}),O(d),da(d,e=>P(c,e),()=>B(c)),z(()=>{q(d,`aria-label`,a()),q(d,`data-testid`,o()),p=Hi(f,1,`chip-thumb svelte-v4eg2o`,null,p,{ready:B(l).ready}),K(f,`left: ${B(l).left??``}px; width: ${B(l).width??``}px;`)}),V(`keydown`,d,function(...e){s.handleKeyDown?.apply(this,e)}),U(e,d),j()}zr([`keydown`,`click`]);var xA=H(`<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>`),SA=H(`<div style="padding: 8px 16px; border-bottom: 1px solid var(--tandem-border); display: flex; gap: 8px; 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 CA(e,t){A(t,!0);let n=bD(xv()),r=[{value:`all`,label:`All types`,kind:`text`},{value:`highlight`,label:`Highlights`,kind:`icon`,icon:`highlight`},{value:`comment`,label:`Comments`,kind:`icon`,icon:`comment`},{value:`note`,label:`Notes`,kind:`icon`,icon:`lock`},{value:`with-replacement`,label:`With replacement`,kind:`icon`,icon:`sparkle`}],i=M(()=>[{value:`all`,label:`Anyone`,kind:`text`},{value:`claude`,label:n.family,kind:`pip`,pip:`claude`},{value:`user`,label:`You`,kind:`pip`,pip:`user`},{value:`import`,label:`Imported`,kind:`pip`,pip:`import`}]),a=[{value:`all`,label:`Any status`,kind:`text`},{value:`pending`,label:`Pending`,kind:`icon`,icon:`pending`},{value:`accepted`,label:`Accepted`,kind:`icon`,icon:`check`},{value:`dismissed`,label:`Dismissed`,kind:`icon`,icon:`dismiss`}];var o=Yr(),s=I(o),c=e=>{var n=SA(),o=F(n);bA(o,{groupTestId:`filter-type`,groupAriaLabel:`Filter by type`,get value(){return t.filterType},get options(){return r},onSet:e=>t.onSetFilterType(e)});var s=L(o,2);bA(s,{groupTestId:`filter-author`,groupAriaLabel:`Filter by author`,get value(){return t.filterAuthor},get options(){return B(i)},onSet:e=>t.onSetFilterAuthor(e)});var c=L(s,2);bA(c,{groupTestId:`filter-status`,groupAriaLabel:`Filter by status`,get value(){return t.filterStatus},get options(){return a},onSet:e=>t.onSetFilterStatus(e)});var l=L(c,2),u=e=>{var n=xA();V(`click`,n,function(...e){t.onClearFilters?.apply(this,e)}),U(e,n)};G(l,e=>{t.hasFilters&&e(u)});var d=L(l,2);O(n),V(`click`,d,function(...e){t.onToggleOpen?.apply(this,e)}),U(e,n)};G(s,e=>{t.open&&e(c)}),U(e,o),j()}zr([`click`]);var wA=H(`<div data-testid="store-readonly-reclaim-error" role="alert" style="font-size: var(--tandem-text-2xs); color: var(--tandem-error-fg);" class="svelte-l26r3u"> </div>`),TA=H(`<div data-testid="store-readonly-banner" class="svelte-l26r3u"><div style="display: flex; justify-content: space-between; align-items: flex-start; gap: 10px;" class="svelte-l26r3u"><span class="svelte-l26r3u">Annotation store is read-only — another Tandem instance holds the lock. Annotations
83
+ won't be saved. Close the other instance, or reclaim the lock if no other instance is
84
+ running.</span> <div style="display: flex; flex-shrink: 0; gap: var(--tandem-space-1);" class="svelte-l26r3u"><button data-testid="store-readonly-reclaim" class="svelte-l26r3u"> </button> <button data-testid="store-readonly-dismiss" class="svelte-l26r3u">Dismiss</button></div></div> <!></div>`),EA=H(`<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>`),DA=H(`<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>`),OA=H(`<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>`),kA=H(`<div style="padding: var(--tandem-space-3); flex: 1;" role="list" aria-label="Annotations" class="svelte-l26r3u"><!> <!></div>`),AA=H(`<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> <div style="display: flex; align-items: center; gap: var(--tandem-space-2);" class="svelte-l26r3u"><button data-testid="annotation-sort-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 style="font-size: 9px; opacity: 0.7;" aria-hidden="true" class="svelte-l26r3u">⇅</span> <span class="svelte-l26r3u"> </span></button> <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> <!> <div style="padding: var(--tandem-space-1) var(--tandem-space-4) 0;" class="svelte-l26r3u"><!></div> <!> <!> <!></div>`);function jA(e,t){A(t,!0);let n=J(t,`storeReadOnly`,3,!1),r=J(t,`claudeWorkingAnnotationId`,3,null),i=M(()=>t.reduceMotion?`auto`:`smooth`),a=`tandem:storeReadOnlyBannerDismissed`;function o(){try{return localStorage.getItem(a)===`true`}catch{return!1}}let s=N(ln(o()));R(()=>{if(!n()){P(s,!1),P(m,null);try{localStorage.removeItem(a)}catch{}}});function c(){try{localStorage.setItem(a,`true`)}catch{}P(s,!0)}let l=`tandem:annotationSortMode`;function u(){try{return localStorage.getItem(l)===`chronological`?`chronological`:`position`}catch{return`position`}}let d=N(ln(u()));function f(){P(d,B(d)===`position`?`chronological`:`position`,!0);try{localStorage.setItem(l,B(d))}catch{}}let p=N(!1),m=N(null);async function h(){if(!B(p)){P(p,!0),P(m,null);try{let e=await fetch(`${Il}${Mc}`,{method:`POST`});if(!e.ok){let t=`Could not reclaim the annotation store lock.`;try{let n=await e.json();typeof n?.message==`string`&&n.message&&(t=n.message)}catch{}P(m,t,!0)}}catch{P(m,`Could not reach the Tandem server.`)}finally{P(p,!1)}}}let g=N(`all`),_=N(`all`),v=N(`all`),y=N(!1),b=N(null),x=N(void 0),S=N(null);R(()=>{B(b)&&B(S)?.focus()}),R(()=>{B(g),B(_),B(v),P(b,null)}),R(()=>{t.onFilterChange?.(B(g),B(_),B(v))});let C=N(ln(new Map));R(()=>{if(!t.ydoc){P(C,new Map,!0);return}let e=t.ydoc.getMap(Wa);function n(){let t=new Map;e.forEach(e=>{let n=e;if(n&&typeof n==`object`&&n.annotationId){let e=t.get(n.annotationId)??[];e.push(n),t.set(n.annotationId,e)}});for(let e of t.values())e.sort((e,t)=>e.timestamp-t.timestamp);P(C,t,!0)}return n(),e.observe(n),()=>e.unobserve(n)});let w=M(()=>{let e=[],n=[];for(let r of t.annotations){r.status===`pending`&&n.push(r);let t;t=B(g)===`all`?!0:B(g)===`with-replacement`?r.suggestedText!==void 0:r.type===B(g);let i=B(_)===`all`||r.author===B(_),a=B(v)===`all`||r.status===B(v);t&&i&&a&&e.push(r)}return{filtered:e,pending:$D(e.filter(e=>e.status===`pending`),B(d)),reviewPending:e.filter(sc),resolved:$D(e.filter(e=>e.status!==`pending`),B(d)),allPending:n,reviewAllPending:t.annotations.filter(sc)}}),ee=bD(xv()),T=M(()=>B(g)!==`all`||B(_)!==`all`||B(v)!==`all`),E=M(()=>{if(!B(T))return`All`;let e=[];if(B(g)!==`all`&&e.push({all:`All`,highlight:`Highlights`,comment:`Comments`,note:`Notes`,"with-replacement":`With replacement`}[B(g)]),B(_)!==`all`){let t={all:`Anyone`,claude:ee.family,user:`You`,import:`Imported`};e.push(t[B(_)])}return B(v)!==`all`&&e.push({all:`Any status`,pending:`Pending`,accepted:`Accepted`,dismissed:`Dismissed`}[B(v)]),e.join(` · `)||`All`}),te=!1;R(()=>{if(B(g),B(_),B(v),!te){te=!0;return}kr(()=>{if(t.activeAnnotationId){let e=document.querySelector(`[data-testid="annotation-card-${t.activeAnnotationId}"]`);if(e){e.scrollIntoView({block:`center`});return}console.warn(`[tandem] SidePanel: active annotation ${t.activeAnnotationId} not found on filter change; scrolling to top`)}B(x)?.scrollTo({top:0})})}),R(()=>{let e=t.activeAnnotationId;if(!e)return;let n=B(i),r=t.reduceMotion||typeof matchMedia<`u`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches,a=setTimeout(()=>{let t=document.querySelector(`[data-testid="annotation-card-${e}"]`);if(!t){console.warn(`[tandem] SidePanel: active annotation ${e} not found after 50ms delay; scroll-to-card skipped`);return}if(t.scrollIntoView({behavior:n,block:`nearest`}),r)return;t.classList.add(`tandem-annotation-flash`);let i=e=>{e.animationName.includes(`tandem-annotation-flash`)&&(t.classList.remove(`tandem-annotation-flash`),t.removeEventListener(`animationend`,i))};t.addEventListener(`animationend`,i)},50);return()=>clearTimeout(a)});let ne=(e,n)=>Ak(t.ydoc,e,n),D=e=>Mk(t.ydoc,e),re=e=>Pk(e,t.documentId),ie=(e,n)=>Fk(e,n,t.documentId),ae=new Map;function oe(e){ae.set(e,`accept`),t.review.handleAccept(e)}function se(e){ae.set(e,`dismiss`),t.review.handleDismiss(e)}let ce=N(void 0),le=N(null),ue=0;function de(e){return t.annotations.find(t=>t.id===e)}function fe(e){return t=>{let n=de(e);n&&Xk(t,n,{accept:oe,dismiss:se,sendToClaude:D,remove:re,openEdit:e=>P(le,{id:e,kind:`edit`,nonce:++ue},!0),openReply:e=>P(le,{id:e,kind:`reply`,nonce:++ue},!0)})}}async function pe(e){if(!nh())return;let t=(e.target?.closest(`[data-annotation-id]`))?.getAttribute(`data-annotation-id`);if(!t)return;let n=de(t);n&&(e.preventDefault(),e.stopPropagation(),await Zk(n,fe(t)))}R(()=>{let e=B(ce);if(e)return e.addEventListener(`contextmenu`,pe),()=>e.removeEventListener(`contextmenu`,pe)}),R(()=>eA());function me(e){for(let n of B(w).reviewPending)t.review.resolveAnnotation(n.id,e);P(b,null)}let he=N(ln(new Set));R(()=>{let e=new Set(B(w).pending.filter(e=>e.author===`import`&&e.type===`note`).map(e=>e.id));kr(()=>{let t=new Set([...B(he)].filter(t=>e.has(t)));t.size!==B(he).size&&P(he,t,!0)})});function ge(e){let t=new Set(B(he));t.has(e)?t.delete(e):t.add(e),P(he,t,!0)}function _e(){let e=Array.from(B(he));Nk(t.ydoc,e),P(he,new Set,!0)}function ve(){P(he,new Set,!0)}function ye(e){e.target===e.currentTarget&&t.onActiveAnnotationChange(null)}var be=AA(),xe=F(be),Se=e=>{var t=TA(),n=F(t),r=L(F(n),2),i=F(r),a=F(i,!0);O(i);var o=L(i,2);O(r),O(n);var s=L(n,2),l=e=>{var t=wA(),n=F(t,!0);O(t),z(()=>W(n,B(m))),U(e,t)};G(s,e=>{B(m)&&e(l)}),O(t),z(()=>{K(t,`padding: 10px 14px; margin: 10px 14px 0; background: ${rO.background??``}; border: 1px solid ${rO.border??``}; border-radius: var(--tandem-r-4); font-size: var(--tandem-text-xs); color: ${rO.color??``}; display: flex; flex-direction: column; gap: var(--tandem-space-2);`),i.disabled=B(p),K(i,`flex-shrink: 0; font-size: var(--tandem-text-xs); padding: 2px 8px; border: 1px solid ${rO.border??``}; border-radius: var(--tandem-r-2); background: none; color: ${rO.color??``}; cursor: ${B(p)?`wait`:`pointer`}; font-weight: 500;`),W(a,B(p)?`Reclaiming…`:`Reclaim`),K(o,`flex-shrink: 0; font-size: var(--tandem-text-xs); padding: 2px 8px; border: none; border-radius: var(--tandem-r-2); background: none; color: ${rO.color??``}; cursor: pointer; font-weight: 500;`)}),V(`click`,i,h),V(`click`,o,c),U(e,t)};G(xe,e=>{n()&&!B(s)&&e(Se)});var Ce=L(xe,2),we=F(Ce),Te=F(we),Ee=L(F(Te)),De=e=>{var t=EA(),n=F(t,!0);O(t),z(()=>W(n,B(w).allPending.length)),U(e,t)};G(Ee,e=>{B(w).allPending.length>0&&e(De)}),O(Te);var Oe=L(Te,2),ke=F(Oe);O(Oe);var Ae=L(Oe,2),je=F(Ae),Me=L(F(je),2),Ne=F(Me,!0);O(Me),O(je);var Pe=L(je,2),Fe=F(Pe),Ie=F(Fe);O(Fe),k(4),O(Pe),O(Ae),O(we),O(Ce);var Le=L(Ce,2);CA(Le,{get filterType(){return B(g)},get filterAuthor(){return B(_)},get filterStatus(){return B(v)},get hasFilters(){return B(T)},get open(){return B(y)},onToggleOpen:()=>P(y,!B(y)),onSetFilterType:e=>{P(g,e,!0)},onSetFilterAuthor:e=>{P(_,e,!0)},onSetFilterStatus:e=>{P(v,e,!0)},onClearFilters:()=>{P(g,`all`),P(_,`all`),P(v,`all`)}});var Re=L(Le,2);YD(F(Re),{get annotations(){return t.annotations},get activeDocFormat(){return t.activeDocFormat},get documentId(){return t.documentId}}),O(Re);var ze=L(Re,2);nA(ze,{get selectedCount(){return B(he).size},onPromote:_e,onClear:ve,get reduceMotion(){return t.reduceMotion}});var Be=L(ze,2);oA(Be,{get bulkConfirm(){return B(b)},get pendingCount(){return B(w).reviewPending.length},get allPendingCount(){return B(w).reviewAllPending.length},onConfirmAccept:()=>me(`accepted`),onConfirmDismiss:()=>me(`dismissed`),onCancel:()=>P(b,null),onRequestAccept:()=>P(b,`accept`),onRequestDismiss:()=>P(b,`dismiss`),get reduceMotion(){return t.reduceMotion},get confirmRef(){return B(S)},set confirmRef(e){P(S,e,!0)}});var Ve=L(Be,2),He=e=>{var t=DA(),n=F(t),r=F(n,!0);O(n),O(t),z(()=>W(r,B(T)?`No annotations match filters.`:`No annotations yet. Open a document to get started.`)),V(`click`,t,ye),U(e,t)},Ue=e=>{var n=kA(),i=F(n);fi(i,17,()=>B(w).pending,e=>e.id,(e,n)=>{let i=M(()=>t.activeAnnotationId===B(n).id);{let a=M(()=>B(C).get(B(n).id)??[]),o=M(()=>r()===B(n).id),s=M(()=>zk(B(n))?oe:void 0),c=M(()=>Bk(B(n))?se:void 0),l=M(()=>Wk(B(n))?re:void 0),u=M(()=>Uk(B(n))?D:void 0),d=M(()=>Hk(B(n))?ne:void 0),f=M(()=>Vk(B(n))?ie:void 0),p=M(()=>B(le)?.id===B(n).id?B(le):null),m=M(()=>B(he).has(B(n).id)),h=M(()=>B(n).author===`import`&&B(n).type===`note`?ge:void 0);wk(e,{get annotation(){return B(n)},get replies(){return B(a)},get isReviewTarget(){return B(i)},get claudeTyping(){return B(o)},lifecycleMotion:!0,get reduceMotion(){return t.reduceMotion},get exitModes(){return ae},get onAccept(){return B(s)},get onDismiss(){return B(c)},get onRemove(){return B(l)},get onSendToClaude(){return B(u)},get onEdit(){return B(d)},get onReply(){return B(f)},get openRequest(){return B(p)},onClick:()=>t.review.scrollToAnnotation(B(n)),get selected(){return B(m)},get onToggleSelect(){return B(h)}})}});var a=L(i,2),o=e=>{var n=OA(),r=F(n),i=F(r);O(r);var a=L(r,2);fi(a,21,()=>B(w).resolved,e=>e.id,(e,n)=>{{let r=M(()=>B(C).get(B(n).id)??[]),i=M(()=>t.review.getRecentlyResolved().has(B(n).id));wk(e,{get annotation(){return B(n)},get replies(){return B(r)},get reduceMotion(){return t.reduceMotion},get onUndo(){return t.review.undoResolveAnnotation},get undoable(){return B(i)},onClick:()=>t.review.scrollToAnnotation(B(n))})}}),O(a),O(n),z(()=>W(i,`${B(w).resolved.length??``} resolved`)),U(e,n)};G(a,e=>{B(w).resolved.length>0&&e(o)}),O(n),da(n,e=>P(ce,e),()=>B(ce)),V(`click`,n,ye),U(e,n)};G(Ve,e=>{B(w).filtered.length===0?e(He):e(Ue,-1)}),O(be),da(be,e=>P(x,e),()=>B(x)),Ni(be,(e,t)=>Vu?.(e,t),()=>`y`),z(()=>{W(ke,`${B(w).allPending.length??``} pending annotation${B(w).allPending.length===1?``:`s`}`),q(je,`title`,B(d)===`position`?`Sorted by position in document. Click to sort oldest first.`:`Sorted oldest first. Click to sort by position in document.`),q(je,`aria-label`,B(d)===`position`?`Annotations sorted by position in document. Switch to oldest first.`:`Annotations sorted oldest first. Switch to position in document.`),W(Ne,B(d)===`position`?`Position`:`Oldest`),W(Ie,`${B(E)??``} ${B(w).filtered.length??``}`)}),V(`click`,je,f),V(`click`,Pe,()=>P(y,!B(y))),U(e,be),j()}zr([`click`]);var MA=H(`<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>`),NA=H(`<span style="
85
+ flex-shrink: 0;
86
+ font-family: var(--tandem-font-mono);
87
+ font-size: var(--tandem-text-2xs, 10px);
88
+ font-weight: 500;
89
+ color: var(--tandem-fg-subtle);
90
+ background: var(--tandem-surface-muted);
91
+ border-radius: var(--tandem-r-pill);
92
+ padding: 0 var(--tandem-space-1);
93
+ min-width: 16px;
94
+ text-align: center;
95
+ line-height: 16px;
96
+ "> </span>`),PA=H(`<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>`),FA=H(`<ul style="list-style: none; margin: 0; padding: 0;"></ul>`),IA=H(`<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 LA(e,t){A(t,!0);let n=J(t,`annotations`,19,()=>[]),r=J(t,`focusTrigger`,3,0),i=J(t,`activeFilterType`,3,`all`),a=J(t,`activeFilterAuthor`,3,`all`),o=J(t,`activeFilterStatus`,3,`all`),s=N(ln([])),c=N(-1),l=N(ln([])),u=N(``),d=N(null),f=N(-1);R(()=>{let e=t.editor;if(!e||e.isDestroyed){P(s,[],!0);return}P(s,Em(e),!0),kr(()=>{P(l,B(l).slice(0,B(s).length),!0),B(c)>=B(s).length&&P(c,Math.max(0,B(s).length-1),!0)});let n=()=>{P(s,Em(e),!0),P(l,B(l).slice(0,B(s).length),!0),B(c)>=B(s).length&&P(c,Math.max(0,B(s).length-1),!0)};return e.on(`update`,n),()=>{e.isDestroyed||e.off(`update`,n),P(s,[],!0)}}),R(()=>{r()>0&&(B(d)?.focus(),B(d)?.select())}),R(()=>{let e=t.editor;if(!e||e.isDestroyed)return;let n=e.view.dom.closest(`.editor-scroll`)??e.view.dom.parentElement;function r(){if(!e||e.isDestroyed||B(s).length===0){P(f,-1);return}let t=(n?.getBoundingClientRect().top??0)+48,r=-1;for(let n=0;n<B(s).length;n++)try{e.view.coordsAtPos(B(s)[n].pos+1).top<=t&&(r=n)}catch{}P(f,r,!0)}return r(),n?.addEventListener(`scroll`,r),()=>n?.removeEventListener(`scroll`,r)});function p(){let e=t.editor;!e||e.isDestroyed||(B(u)?e.commands.find({query:B(u),caseSensitive:!1,wholeWord:!1,regexMode:!1}):e.commands.findClose())}function m(e){e.key===`Enter`?(e.preventDefault(),e.shiftKey?t.editor?.commands.findPrev():t.editor?.commands.findNext()):e.key===`Escape`&&(e.preventDefault(),P(u,``),t.editor?.commands.findClose(),B(d)?.blur())}let h=M(()=>{let e=t.editor;if(!e||e.isDestroyed||B(s).length===0)return[];let r=e.state.doc.content.size,c=[];for(let t of n()){if(i()!==`all`){if(i()===`with-replacement`){if(!t.suggestedText)continue}else if(t.type!==i())continue}if(!(a()!==`all`&&t.author!==a())&&!(o()!==`all`&&t.status!==o()))try{c.push(TD(e.state.doc,t.range.from))}catch{}}return B(s).map((e,t)=>{let n=t+1<B(s).length?B(s)[t+1].pos:r;return c.filter(t=>t>=e.pos&&t<n).length})});function g(e,n){let r=t.editor;if(!r||r.isDestroyed)return;let{state:i}=r;try{let t=i.doc.resolve(e.pos+1),n=Wp.near(t);r.view.dispatch(i.tr.setSelection(n)),r.view.focus();let{node:a}=r.view.domAtPos(e.pos+1),o=a instanceof Element?a:a.parentElement,s=r.view.dom.closest(`.editor-scroll`)??r.view.dom.parentElement;if(o&&s){let e=o.getBoundingClientRect().top,t=s.getBoundingClientRect().top;s.scrollTop+=e-t-s.clientHeight*.05}}catch{}P(c,n,!0)}function _(e){if(B(s).length!==0)if(e.key===`ArrowDown`){e.preventDefault();let t=(B(c)+1)%B(s).length;P(c,t),B(l)[t]?.focus()}else if(e.key===`ArrowUp`){e.preventDefault();let t=(B(c)-1+B(s).length)%B(s).length;P(c,t),B(l)[t]?.focus()}else e.key===`Home`?(e.preventDefault(),P(c,0),B(l)[0]?.focus()):e.key===`End`&&(e.preventDefault(),P(c,B(s).length-1),B(l)[B(s).length-1]?.focus())}var v=IA(),y=L(F(v),2),b=F(y),x=L(F(b),2);Qi(x),da(x,e=>P(d,e),()=>B(d)),O(b),O(y);var S=L(y,2),C=F(S),w=e=>{U(e,MA())},ee=e=>{var t=FA();fi(t,21,()=>B(s),ci,(e,t,n)=>{let r=M(()=>B(f)===n),i=M(()=>B(h)[n]??0);var a=PA(),o=F(a),s=F(o),u=L(s,2),d=F(u,!0);O(u);var p=L(u,2),m=e=>{var t=NA(),n=F(t,!0);O(t),z(()=>{q(t,`title`,`${B(i)??``} annotation${B(i)===1?``:`s`}`),W(n,B(i))}),U(e,t)};G(p,e=>{B(i)>0&&e(m)}),O(o),da(o,(e,t)=>B(l)[t]=e,e=>B(l)?.[e],()=>[n]),O(a),z(()=>{q(o,`data-testid`,`outline-heading-${B(t).level}-${n}`),q(o,`tabindex`,B(c)===n||B(c)===-1&&n===0?0:-1),K(o,`
97
+ display: flex; align-items: center; width: 100%; text-align: left;
98
+ padding: var(--tandem-space-1) var(--tandem-space-3);
99
+ padding-left: calc(var(--tandem-space-1) + ${(B(t).level-1)*12}px);
100
+ font-size: ${B(t).level===1?`var(--tandem-text-sm)`:`var(--tandem-text-xs)`};
101
+ font-weight: ${B(t).level===1?600:B(t).level===2?500:400};
102
+ color: ${B(r)?`var(--tandem-accent)`:B(t).level===1?`var(--tandem-fg)`:B(t).level===2?`var(--tandem-fg-subtle)`:`var(--tandem-fg-muted)`};
103
+ background: ${B(r)?`var(--tandem-accent-bg)`:`none`};
104
+ border: none; cursor: pointer; line-height: 1.5;
105
+ transition: color 0.1s, background 0.1s;
106
+ gap: var(--tandem-space-2);
107
+ `),q(o,`title`,B(t).text),K(s,B(r)?`background-color: var(--tandem-accent); opacity: 1;`:``),W(d,B(t).text||`(untitled)`)}),V(`click`,o,()=>g(B(t),n)),Rr(`focus`,o,()=>P(c,n,!0)),Rr(`mouseenter`,o,e=>{B(r)||(e.currentTarget.style.background=`var(--tandem-surface-hover, var(--tandem-surface-muted))`)}),Rr(`mouseleave`,o,e=>{B(r)||(e.currentTarget.style.background=`none`)}),U(e,a)}),O(t),U(e,t)};G(C,e=>{B(s).length===0?e(w):e(ee,-1)}),O(S),Ni(S,(e,t)=>Vu?.(e,t),()=>`y`),O(v),V(`keydown`,v,_),V(`input`,x,p),V(`keydown`,x,m),ia(x,()=>B(u),e=>P(u,e)),U(e,v),j()}zr([`keydown`,`input`,`click`]);var RA=H(`<div><!></div>`);function zA(e,t){A(t,!0);let n=pa(t,[`$$slots`,`$$events`,`$$legacy`,`kind`,`visible`]),r=M(()=>t.visible===void 0?void 0:`display: ${t.visible?`flex`:`none`}; flex-direction: column; flex: 1; min-height: 0;${t.kind===`outline`?` padding-bottom: var(--tandem-status-clearance-total, 88px);`:``}`);var i=Yr(),a=I(i),o=e=>{var i=RA(),a=F(i),o=e=>{qD(e,ha(()=>n,{get visible(){return t.visible}}))},s=e=>{LA(e,{get editor(){return t.editor},get annotations(){return t.annotations},get focusTrigger(){return t.focusTrigger},get activeFilterType(){return t.activeFilterType},get activeFilterAuthor(){return t.activeFilterAuthor},get activeFilterStatus(){return t.activeFilterStatus}})},c=e=>{jA(e,ha(()=>n))};G(a,e=>{t.kind===`chat`?e(o):t.kind===`outline`?e(s,1):e(c,-1)}),O(i),z(()=>K(i,B(r))),U(e,i)},s=e=>{qD(e,ha(()=>n))},c=e=>{LA(e,{get editor(){return t.editor},get annotations(){return t.annotations},get focusTrigger(){return t.focusTrigger},get activeFilterType(){return t.activeFilterType}})},l=e=>{jA(e,ha(()=>n))};G(a,e=>{B(r)?e(o):t.kind===`chat`?e(s,1):t.kind===`outline`?e(c,2):e(l,-1)}),U(e,i),j()}var BA=H(`<span style="color: var(--tandem-error-fg-strong); font-size: var(--tandem-text-xs); max-width: 200px;"> </span>`),VA=H(`<button type="button" class="tandem-banner__cta" data-testid="convert-to-markdown-btn"> </button>`),HA=H(`<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
108
+ 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 UA(e,t){A(t,!0);let n=`tandem:reviewOnlyBannerDismissed`;function r(){try{return localStorage.getItem(n)===`true`}catch{return!1}}let i=N(ln(r())),a=N(!1),o=N(null);async function s(){if(!(!t.documentId||B(a))){P(a,!0),P(o,null);try{let e=await fetch(`${Il}${Cc}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({documentId:t.documentId})});e.ok||P(o,(await e.json().catch(()=>null))?.message??`Conversion failed (HTTP ${e.status}).`,!0)}catch{P(o,`Could not reach the server.`)}finally{P(a,!1)}}}function c(){try{localStorage.setItem(n,`true`)}catch{}P(i,!0)}var l=Yr(),u=I(l),d=e=>{var n=HA(),r=L(F(n),2),i=e=>{var t=BA(),n=F(t,!0);O(t),z(()=>W(n,B(o))),U(e,t)};G(r,e=>{B(o)&&e(i)});var l=L(r,2),u=e=>{var t=VA(),n=F(t,!0);O(t),z(()=>{t.disabled=B(a),W(n,B(a)?`Converting…`:`Convert to Markdown`)}),V(`click`,t,s),U(e,t)};G(l,e=>{t.documentId&&e(u)});var d=L(l,2);O(n),V(`click`,d,c),U(e,n)};G(u,e=>{t.visible&&!B(i)&&e(d)}),U(e,l),j()}zr([`click`]);var WA=null;async function GA(e){if(WA!==null)return WA;let t=await fetch(`${Il}${mc}`,{signal:e});if(!t.ok)throw Error(`${mc} responded ${t.status} ${t.statusText}`);let n=await t.json();return WA=n,n}function KA(e){let t=N(null),n=N(!1);return R(()=>{if(!e())return;let r=!1,i=new AbortController,a=setTimeout(()=>i.abort(),3e3);return P(n,!0),GA(i.signal).then(e=>{r||P(t,e,!0)}).catch(e=>{e instanceof Error&&e.name!==`AbortError`&&console.warn(`[useAppInfo] failed to load /api/info:`,e)}).finally(()=>{clearTimeout(a),r||P(n,!1)}),()=>{r=!0,clearTimeout(a),i.abort()}}),{get info(){return B(t)},get loading(){return B(n)}}}var qA=H(`<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 JA(e,t){A(t,!0);let n=`font-size: 11px; font-weight: 600; color: var(--tandem-fg); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px;`;var r=qA(),i=I(r),a=F(i);K(a,n);var o=L(a,2),s=F(o);Qi(s),k(2),O(o),k(2),O(i);var c=L(i,2),l=F(c);K(l,n);var u=L(l,2),d=F(u);Qi(d),k(2),O(u),k(2),O(c),z(()=>{ea(s,t.settings.highContrast),ea(d,t.settings.annotationPatterns)}),V(`change`,s,e=>t.onUpdate({highContrast:e.target.checked})),V(`change`,d,e=>t.onUpdate({annotationPatterns:e.target.checked})),U(e,r),j()}zr([`change`]);var YA=H(`<button role="radio"> </button>`),XA=H(`<label data-testid="appearance-system-light-warm" 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); margin-top: var(--tandem-space-2);"><input type="checkbox" style="accent-color: var(--tandem-accent);"/> <span>Use Warm when system is light</span></label> <div style="font-size: var(--tandem-text-2xs); color: var(--tandem-fg-subtle); margin-top: var(--tandem-space-1);">When your OS reports a light appearance, use the paper-tone Warm theme instead of
109
+ neutral Light. A dark OS appearance still resolves to Dark.</div>`,1),ZA=H(`<button role="radio"> </button>`),QA=H(`<button role="radio"> </button>`),$A=H(`<button role="radio"> </button>`),ej=H(`<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>`),tj=H(`<button role="radio"> </button>`),nj=H(`<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>`),rj=H(`<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
110
+ 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
111
+ in the selection popup, and Ctrl+Z / Ctrl+Y still undo and redo.</div></div> <div><label data-testid="appearance-show-raw-markdown" style="display: flex; align-items: center; gap: var(--tandem-space-2); cursor: pointer; font-size: var(--tandem-text-sm); color: var(--tandem-fg); min-height: var(--tandem-space-5);"><input type="checkbox" style="accent-color: var(--tandem-accent);"/> <span>Show raw markdown</span></label> <div style="font-size: var(--tandem-text-2xs); color: var(--tandem-fg-subtle); margin-top: var(--tandem-space-1);">Footnotes, reference-style links, and inline HTML that Tandem keeps as raw source.
112
+ When hidden they stay in the file and always save — only the on-screen markers are
113
+ hidden.</div></div> <div><label data-testid="appearance-rail-hover-reveal" 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>Reveal rails on hover</span></label> <div style="font-size: var(--tandem-text-2xs); color: var(--tandem-fg-subtle); margin-top: var(--tandem-space-1);">Hover a closed outline or annotations rail to float it over the document without
114
+ resizing it; click its edge to pin it open. When off, rails reveal only on click.</div></div>`,1);function ij(e,t){A(t,!0);let 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(e){return t.settings.fontByExtension?.[e]??t.settings.editorFont}function a(e,n){t.onUpdate({fontByExtension:{...t.settings.fontByExtension,[e]:n}})}function o(){t.onUpdate({fontByExtension:{}})}let s=M(()=>Object.keys(t.settings.fontByExtension??{}).length>0),c=`font-size: 11px; font-weight: 600; color: var(--tandem-fg); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px;`,l=[[`showAuthorship`,`appearance-show-authorship`,`Authorship colors`],[`showComments`,`appearance-show-comments`,`Comments`],[`showHighlights`,`appearance-show-highlights`,`Highlights`],[`showNotes`,`appearance-show-notes`,`Notes (private)`]];function u(e,t){return[`flex: 1;`,`padding: var(--tandem-space-2);`,`min-height: 24px;`,`border: 2px solid ${e?`var(--tandem-accent)`:`var(--tandem-border)`};`,`border-radius: var(--tandem-r-3);`,`background: ${t?`var(--tandem-surface-muted)`:e?`var(--tandem-accent-bg)`:`var(--tandem-surface)`};`,`cursor: ${t?`not-allowed`:`pointer`};`,`text-align: center;`,`font-size: 11px;`,`color: ${t?`var(--tandem-fg-subtle)`:e?`var(--tandem-accent-fg-strong)`:`var(--tandem-fg-muted)`};`,`font-weight: ${e?600:400};`,`opacity: ${t?.6:1};`,`transition: border-color 0.15s, background 0.15s;`].join(` `)}let d=sA(()=>t.settings.theme,[`light`,`warm`,`dark`,`system`],e=>t.onUpdate({theme:e})),f=sA(()=>t.settings.primaryTab,[`chat`,`annotations`],e=>t.onUpdate({primaryTab:e})),p=sA(()=>t.settings.textSize,[`s`,`m`,`l`],e=>t.onUpdate({textSize:e})),m=sA(()=>t.settings.editorFont,[`sans`,`serif`,`mono`],e=>t.onUpdate({editorFont:e})),h=sA(()=>t.settings.density,[`compact`,`cozy`,`spacious`],e=>t.onUpdate({density:e})),g={};for(let e of n)g[e.format]=sA(()=>i(e.format),[`sans`,`serif`,`mono`],t=>a(e.format,t));var _=rj(),y=I(_),b=F(y);K(b,c);var x=L(b,2);fi(x,20,()=>[`light`,`warm`,`dark`,`system`],e=>e,(e,n)=>{var r=YA(),i=F(r,!0);O(r),z((e,a)=>{q(r,`data-testid`,`theme-${n}-btn`),q(r,`aria-checked`,t.settings.theme===n),q(r,`tabindex`,e),K(r,a),W(i,n===`light`?`Light`:n===`warm`?`Warm`:n===`dark`?`Dark`:`System`)},[()=>d.tabIndexFor(n),()=>u(t.settings.theme===n)]),V(`click`,r,()=>t.onUpdate({theme:n})),U(e,r)}),O(x);var S=L(x,2),C=e=>{var n=XA(),r=I(n),i=F(r);Qi(i),k(2),O(r),k(2),z(()=>ea(i,t.settings.systemLightVariant===`warm`)),V(`change`,i,e=>t.onUpdate({systemLightVariant:e.target.checked?`warm`:`light`})),U(e,n)};G(S,e=>{t.settings.theme===`system`&&e(C)}),O(y);var w=L(y,2),ee=F(w);K(ee,c);var T=L(ee,2),E=F(T),te=L(E,2);O(T),O(w);var ne=L(w,2),D=F(ne);K(D,c);var re=L(D,2);fi(re,20,()=>[`s`,`m`,`l`],e=>e,(e,n)=>{var r=ZA(),i=F(r,!0);O(r),z((e,a)=>{q(r,`data-testid`,`text-size-${n}-btn`),q(r,`aria-checked`,t.settings.textSize===n),q(r,`tabindex`,e),K(r,a),W(i,n===`s`?`Small`:n===`m`?`Medium`:`Large`)},[()=>p.tabIndexFor(n),()=>u(t.settings.textSize===n)]),V(`click`,r,()=>t.onUpdate({textSize:n})),U(e,r)}),O(re),k(2),O(ne);var ie=L(ne,2),ae=F(ie);K(ae,c);var oe=L(ae,2),se=L(F(oe),2);Qi(se),O(oe),O(ie);var ce=L(ie,2),le=F(ce);K(le,c);var ue=L(le,2);fi(ue,20,()=>[[`sans`,`Sans-serif`],[`serif`,`Serif (Source Serif 4)`],[`mono`,`Monospace`]],([e,t])=>e,(e,n)=>{var r=M(()=>v(n,2));let i=()=>B(r)[0],a=()=>B(r)[1];var o=QA(),s=F(o,!0);O(o),z((e,n)=>{q(o,`data-testid`,`editor-font-${i()}-btn`),q(o,`aria-checked`,t.settings.editorFont===i()),q(o,`tabindex`,e),K(o,n),W(s,a())},[()=>m.tabIndexFor(i()),()=>u(t.settings.editorFont===i())]),V(`click`,o,()=>t.onUpdate({editorFont:i()})),U(e,o)}),O(ue),O(ce);var de=L(ce,2),fe=F(de),pe=F(fe);K(pe,`${c} margin-bottom: 0;`);var me=L(pe,2);O(fe);var he=L(fe,2);fi(he,21,()=>n,e=>e.format,(e,t)=>{var n=ej(),o=F(n),s=F(o,!0);O(o);var c=L(o,2);fi(c,21,()=>r,([e,t])=>e,(e,n)=>{var r=M(()=>v(B(n),2));let o=()=>B(r)[0],s=()=>B(r)[1];var c=$A(),l=F(c,!0);O(c),z((e,n,r)=>{q(c,`data-testid`,`font-by-extension-${B(t).format}-${o()}`),q(c,`aria-checked`,e),q(c,`tabindex`,n),K(c,r),W(l,s())},[()=>i(B(t).format)===o(),()=>g[B(t).format].tabIndexFor(o()),()=>u(i(B(t).format)===o())]),V(`click`,c,()=>a(B(t).format,o())),U(e,c)}),O(c),O(n),z(()=>{q(n,`data-testid`,`font-by-extension-row-${B(t).format}`),W(s,B(t).label),q(c,`aria-label`,`Default font for ${B(t).label}`)}),V(`keydown`,c,function(...e){g[B(t).format].handleKeyDown?.apply(this,e)}),U(e,n)}),O(he),k(2),O(de);var ge=L(de,2),_e=F(ge);K(_e,c);var ve=L(_e,2);fi(ve,20,()=>[[`compact`,`Compact`],[`cozy`,`Cozy`],[`spacious`,`Spacious`]],([e,t])=>e,(e,n)=>{var r=M(()=>v(n,2));let i=()=>B(r)[0],a=()=>B(r)[1];var o=tj(),s=F(o,!0);O(o),z((e,n)=>{q(o,`data-testid`,`density-${i()}-btn`),q(o,`aria-checked`,t.settings.density===i()),q(o,`tabindex`,e),K(o,n),W(s,a())},[()=>h.tabIndexFor(i()),()=>u(t.settings.density===i())]),V(`click`,o,()=>t.onUpdate({density:i()})),U(e,o)}),O(ve),O(ge);var ye=L(ge,2),be=F(ye);K(be,c),fi(L(be,2),17,()=>l,([e,t,n])=>e,(e,n)=>{var r=M(()=>v(B(n),3));let i=()=>B(r)[0],a=()=>B(r)[1],o=()=>B(r)[2];var s=nj(),c=F(s);Qi(c);var l=L(c,2),u=F(l,!0);O(l),O(s),z(()=>{q(s,`data-testid`,a()),ea(c,t.settings[i()]),W(u,o())}),V(`change`,c,e=>t.onUpdate({[i()]:e.target.checked,...t.settings.decorationsMuted?{decorationsMuted:!1}:{}})),U(e,s)}),k(2),O(ye);var xe=L(ye,2),Se=F(xe),Ce=F(Se);Qi(Ce),k(2),O(Se),k(2),O(xe);var we=L(xe,2),Te=F(we),Ee=F(Te);Qi(Ee),k(2),O(Te),k(2),O(we);var De=L(we,2),Oe=F(De),ke=F(Oe);Qi(ke),k(2),O(Oe),k(2),O(De);var Ae=L(De,2),je=F(Ae),Me=F(je);Qi(Me),k(2),O(je),k(2),O(Ae),z((e,n,r,i)=>{q(E,`aria-checked`,t.settings.primaryTab===`chat`),q(E,`tabindex`,e),K(E,n),q(te,`aria-checked`,t.settings.primaryTab===`annotations`),q(te,`tabindex`,r),K(te,i),$i(se,t.settings.accentHue),me.disabled=!B(s),K(me,`background: none; border: none; padding: 0; font-size: var(--tandem-text-2xs); color: ${B(s)?`var(--tandem-accent-fg-strong)`:`var(--tandem-fg-subtle)`}; cursor: ${B(s)?`pointer`:`default`}; text-decoration: ${B(s)?`underline`:`none`};`),ea(Ce,t.settings.reduceMotion),ea(Ee,t.settings.formattingBarVisible),ea(ke,t.settings.showRawMarkdown),ea(Me,t.settings.railHoverReveal)},[()=>f.tabIndexFor(`chat`),()=>u(t.settings.primaryTab===`chat`),()=>f.tabIndexFor(`annotations`),()=>u(t.settings.primaryTab===`annotations`)]),V(`keydown`,x,function(...e){d.handleKeyDown?.apply(this,e)}),V(`keydown`,T,function(...e){f.handleKeyDown?.apply(this,e)}),V(`click`,E,()=>t.onUpdate({primaryTab:`chat`})),V(`click`,te,()=>t.onUpdate({primaryTab:`annotations`})),V(`keydown`,re,function(...e){p.handleKeyDown?.apply(this,e)}),V(`input`,se,e=>t.onUpdate({accentHue:Number(e.target.value)})),V(`keydown`,ue,function(...e){m.handleKeyDown?.apply(this,e)}),V(`click`,me,o),V(`keydown`,ve,function(...e){h.handleKeyDown?.apply(this,e)}),V(`change`,Ce,e=>t.onUpdate({reduceMotion:e.target.checked})),V(`change`,Ee,e=>t.onUpdate({formattingBarVisible:e.target.checked})),V(`change`,ke,e=>t.onUpdate({showRawMarkdown:e.target.checked})),V(`change`,Me,e=>t.onUpdate({railHoverReveal:e.target.checked})),U(e,_),j()}zr([`keydown`,`click`,`change`,`input`]);var aj=H(`<button type="button" role="radio"> </button>`),oj=H(`<button type="button" data-testid="settings-default-save-folder-pick" style="padding: 6px 10px; font-size: 11px; white-space: nowrap; border: 1px solid var(--tandem-border); border-radius: var(--tandem-r-1); background: var(--tandem-surface); color: var(--tandem-fg); cursor: pointer;">Choose…</button>`),sj=H(`<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
115
+ 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 data-testid="settings-default-save-folder" style="margin-top: var(--tandem-space-5);"><div>Default Save Folder</div> <div style="font-size: 10px; color: var(--tandem-fg-subtle); margin-bottom: 8px;">Where new files go when you use <strong>Save As</strong> in the desktop app.
116
+ Leave empty to fall back to your AI's working directory, then your home
117
+ folder.</div> <form style="display: flex; gap: var(--tandem-space-1); align-items: center;"><input type="text" name="default-save-dir" data-testid="settings-default-save-folder-input" placeholder="(default: AI working directory, then home)" aria-label="Default save folder path" style="flex: 1; min-width: 0; padding: 6px 8px; font-size: 11px; border: 1px solid var(--tandem-border); border-radius: var(--tandem-r-1); background: var(--tandem-surface); color: var(--tandem-fg);"/> <!> <button type="button" data-testid="settings-default-save-folder-reset">Reset</button></form></div> <div style="margin-top: var(--tandem-space-5);"><label data-testid="editor-smart-typography" 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>Smart typography</span></label> <div style="font-size: var(--tandem-text-2xs); color: var(--tandem-fg-subtle); margin-top: var(--tandem-space-1);">Convert straight quotes, dashes, and ... to typographic characters as you type.</div></div> <div style="margin-top: var(--tandem-space-5);"><label data-testid="editor-spellcheck-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>Spellcheck</span></label> <div style="font-size: var(--tandem-text-2xs); color: var(--tandem-fg-subtle); margin-top: var(--tandem-space-1);">Show the browser's spelling underlines while you type.</div></div></div>`);function cj(e,t){A(t,!0);let n=`font-size: 11px; font-weight: 600; color: var(--tandem-fg); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px;`,r=nh();function i(e){let n=e?.trim();t.onUpdate({defaultSaveDirectory:n||null})}function a(e){e.preventDefault(),i(e.target.elements.namedItem(`default-save-dir`)?.value??null)}async function o(){let e;try{({open:e}=await Ul(()=>import(`./dist-js-BWAGOggB.js`),__vite__mapDeps([2,1])))}catch(e){console.warn(`[Settings] Folder picker import failed:`,e),t.notify(`error`,`Folder picker plugin unavailable`);return}try{let t=await e({directory:!0,multiple:!1,title:`Choose default save folder`});typeof t==`string`&&i(t)}catch(e){console.warn(`[Settings] Folder picker open() failed:`,e),t.notify(`error`,`Folder picker permission denied or IPC error`)}}let s=[{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`}],c=sA(()=>t.settings.editorMeasure,s.map(e=>e.value),e=>t.onUpdate({editorMeasure:e})),l=M(()=>s.find(e=>e.value===t.settings.editorMeasure)?.hint??``);var u=sj(),d=F(u);K(d,n);var f=L(d,4);fi(f,21,()=>s,e=>e.value,(e,n)=>{let r=M(()=>t.settings.editorMeasure===B(n).value);var i=aj(),a=F(i,!0);O(i),z(e=>{q(i,`aria-checked`,B(r)),q(i,`tabindex`,e),q(i,`data-testid`,`editor-measure-${B(n).value}`),K(i,`flex: 1; padding: 6px 4px; border: none; border-radius: var(--tandem-r-1); cursor: pointer; font-size: 11px; font-weight: ${B(r)?600:400}; background: ${B(r)?`var(--tandem-accent)`:`transparent`}; color: ${B(r)?`var(--tandem-accent-fg)`:`var(--tandem-fg)`};`),W(a,B(n).label)},[()=>c.tabIndexFor(B(n).value)]),V(`click`,i,()=>t.onUpdate({editorMeasure:B(n).value})),U(e,i)}),O(f);var p=L(f,2),m=F(p,!0);O(p);var h=L(p,2),g=F(h);K(g,n);var _=L(g,4),v=F(_);Qi(v);var y=L(v,2),b=e=>{var t=oj();V(`click`,t,o),U(e,t)};G(y,e=>{r&&e(b)});var x=L(y,2);O(_),O(h);var S=L(h,2),C=F(S),w=F(C);Qi(w),k(2),O(C),k(2),O(S);var ee=L(S,2),T=F(ee),E=F(T);Qi(E),k(2),O(T),k(2),O(ee),O(u),z(()=>{W(m,B(l)),$i(v,t.settings.defaultSaveDirectory??``),x.disabled=!t.settings.defaultSaveDirectory,K(x,`padding: 6px 10px; font-size: 11px; white-space: nowrap; border: 1px solid var(--tandem-border); border-radius: var(--tandem-r-1); background: transparent; color: var(--tandem-fg-muted); cursor: ${t.settings.defaultSaveDirectory?`pointer`:`default`}; opacity: ${t.settings.defaultSaveDirectory?1:.5};`),ea(w,t.settings.smartTypography),ea(E,t.settings.spellcheck)}),V(`keydown`,f,function(...e){c.handleKeyDown?.apply(this,e)}),Rr(`submit`,_,a),Rr(`blur`,v,e=>i(e.currentTarget.value)),V(`click`,x,()=>i(null)),V(`change`,w,e=>t.onUpdate({smartTypography:e.target.checked})),V(`change`,E,e=>t.onUpdate({spellcheck:e.target.checked})),U(e,u),j()}zr([`keydown`,`click`,`change`]);var lj=H(`<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 uj(e,t){let n=J(t,`defaultOpen`,3,!1);var r=lj(),i=F(r),a=L(F(i));O(i);var o=L(i,2);yi(F(o),()=>t.children),O(o),O(r),z(()=>{q(r,`data-testid`,t.testid),r.open=n(),q(i,`data-testid`,t.testid?`${t.testid}-toggle`:void 0),W(a,` ${t.label??``}`)}),U(e,r)}var dj=H(`<span style="color: var(--tandem-fg-subtle);"> </span>`),fj=H(`<button type="button" data-testid="network-restart-sidecar"> </button>`),pj=H(`<span style="font-size: 10px; color: var(--tandem-fg-subtle);">Run <code>tandem stop &amp;&amp; tandem start</code> to restart</span>`),mj=H(`<div style="font-size: 10px; color: var(--tandem-error-fg); margin-top: var(--tandem-space-1);"> </div>`),hj=H(`<span><strong>Host:</strong> </span>`),gj=H(`<div><div>Loopback Port</div> <div style="padding: var(--tandem-space-2) var(--tandem-space-3); border: 1px solid var(--tandem-border); border-radius: var(--tandem-r-3); background: var(--tandem-surface-muted); font-size: 13px; color: var(--tandem-fg-subtle); display: inline-block;"> </div> <div>Port used when transport is HTTP. To change, run <code>tandem start --port &lt;N&gt;</code>.</div></div>`),_j=H(`<option> </option>`),vj=H(`<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>`),yj=H(`<!> <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</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> <!>`,1),bj=H(`<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 xj(e,t){A(t,!0);let n=KA(()=>t.open),r=nh(),i=N(null),a=N(!1);async function o(){if(r){P(a,!0),P(i,null);try{let{invoke:e}=await Ul(async()=>{let{invoke:e}=await import(`./core-SwWLTXZB.js`);return{invoke:e}},[]);await e(`restart_sidecar`)}catch(e){P(i,e instanceof Error?e.message:String(e),!0)}finally{P(a,!1)}}}let s=[{value:`exponential`,label:`Exponential backoff`},{value:`constant-2s`,label:`Constant (2s)`}],c=`font-size: 11px; font-weight: 600; color: var(--tandem-fg); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px;`,l=`font-size: 10px; color: var(--tandem-fg-subtle); margin-top: var(--tandem-space-1);`,u=M(()=>n.info?.transport),d=M(()=>n.info?.bindHost),f=M(()=>n.info?.bindPort),p=M(()=>B(u)===`http`),m=M(()=>n.info?.tokenRotatedAt);var h=bj(),g=I(h),_=F(g);K(_,c);var v=L(_,2),y=F(v),b=L(y,2),x=F(b),S=L(x),C=e=>{var n=dj(),r=F(n);O(n),z(()=>W(r,`· ${t.reconnectAttempts??``} retry attempt${t.reconnectAttempts===1?``:`s`}`)),U(e,n)};G(S,e=>{t.reconnectAttempts>0&&e(C)}),O(b);var w=L(b,2),ee=e=>{var t=fj(),n=F(t,!0);O(t),z(()=>{t.disabled=B(a),K(t,`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: ${B(a)?.5:1};`),W(n,B(a)?`Restarting…`:`Restart sidecar`)}),V(`click`,t,o),U(e,t)},T=e=>{U(e,pj())};G(w,e=>{r?e(ee):e(T,-1)}),O(v);var E=L(v,2),te=e=>{var t=mj(),n=F(t,!0);O(t),z(()=>W(n,B(i))),U(e,t)};G(E,e=>{B(i)&&e(te)}),O(g);var ne=L(g,2),D=F(ne);K(D,c);var re=L(D,2),ie=F(re),ae=L(F(ie));O(ie);var oe=L(ie,2),se=e=>{var t=hj(),n=L(F(t));O(t),z(()=>W(n,` ${B(d)??``}`)),U(e,t)};G(oe,e=>{B(d)&&e(se)}),O(re),O(ne),uj(L(ne,2),{label:`Advanced`,testid:`network-advanced`,children:(e,n)=>{var r=yj(),i=I(r),a=e=>{var t=gj(),n=F(t);K(n,c);var r=L(n,2),i=F(r,!0);O(r),K(L(r,2),l),O(t),z(()=>W(i,B(f)??`—`)),U(e,t)};G(i,e=>{B(p)&&e(a)});var o=L(i,2),u=F(o);K(u,c);var d=L(F(u)),h=F(d);O(d),O(u);var g=L(u,2);Qi(g),k(2),O(o);var _=L(o,2),v=F(_);K(v,c);var y=L(v,2);fi(y,21,()=>s,e=>e.value,(e,t)=>{var n=_j(),r=F(n,!0);O(n);var i={};z(()=>{W(r,B(t).label),i!==(i=B(t).value)&&(n.value=(n.__value=B(t).value)??``)}),U(e,n)}),O(y);var b;Gi(y),O(_);var x=L(_,2),S=e=>{var t=vj(),n=F(t);K(n,c);var r=L(n,2),i=F(r,!0);O(r),K(L(r,2),l),O(t),z(e=>W(i,e),[()=>B(m)===null?`Auth token not yet created`:`Last rotated: ${new Date(B(m)).toLocaleString()}`]),U(e,t)};G(x,e=>{B(m)!==void 0&&e(S)}),z(()=>{W(h,`${t.settings.degradedBannerDelayMs/1e3}s`),$i(g,t.settings.degradedBannerDelayMs),b!==(b=t.settings.sidecarRetryStrategy)&&(y.value=(y.__value=t.settings.sidecarRetryStrategy)??``,Wi(y,t.settings.sidecarRetryStrategy))}),V(`input`,g,e=>t.onUpdate({degradedBannerDelayMs:Number(e.target.value)})),V(`change`,y,e=>t.onUpdate({sidecarRetryStrategy:e.target.value})),U(e,r)},$$slots:{default:!0}}),z(e=>{K(y,`width: 8px; height: 8px; border-radius: var(--tandem-r-circle); background: ${t.connected?`var(--tandem-success)`:`var(--tandem-error)`}; flex-shrink: 0;`),W(x,`${t.connected?`Connected to Tandem server`:`Disconnected`} `),W(ae,` ${e??``}`)},[()=>B(u)?B(u).toUpperCase():`—`]),U(e,h),j()}zr([`click`,`input`,`change`]);var Sj=`INVALID_BODY`,Cj=`PATH_REJECTED`,wj=`LAUNCHER_IN_PROGRESS`,Tj=`LAUNCHER_NOT_AVAILABLE`,Ej=`NO_CLAUDE_INTEGRATION`,Dj=H(`<div data-testid="settings-modal-connect-ai-callout" style="display: flex; flex-direction: column; align-items: flex-start; gap: var(--tandem-space-2); padding: var(--tandem-space-3); background: var(--tandem-info-bg); border: 1px solid var(--tandem-info-border); border-radius: var(--tandem-r-3); margin-bottom: var(--tandem-space-3);"><div style="font-size: 13px; font-weight: 600; color: var(--tandem-info-fg-strong);">No AI connected yet</div> <div style="font-size: 12px; line-height: 1.5; color: var(--tandem-info-fg);">Tandem's AI works through Claude Code or Claude Desktop using your existing Claude
118
+ sign-in — no API key needed. The setup wizard connects it in one step.</div> <button type="button" data-testid="settings-modal-connect-ai-btn" style="font-size: 12px; font-weight: 500; padding: var(--tandem-space-2) var(--tandem-space-3); border-radius: var(--tandem-r-2); border: 1px solid var(--tandem-accent); background: var(--tandem-accent); color: var(--tandem-accent-fg); cursor: pointer;">Connect AI…</button></div>`),Oj=H(`<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>`),kj=H(`<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-muted); color: var(--tandem-fg); cursor: pointer;">Choose folder…</button>`),Aj=H(`<div role="alert" style="font-size: 11px; color: var(--tandem-error-fg);"> </div>`),jj=H(`<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-muted); 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>`),Mj=H(`<div data-testid="settings-modal-cowork-suspense-fallback" style="font-size: 12px; color: var(--tandem-fg-subtle);">Loading Cowork integration...</div>`),Nj=H(`<!> <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
119
+ Claude Desktop) is the default integration — auto-configured, tested, and the only client whose
120
+ channel-push, cowork, and auto-launch extras are validated today. Other clients can connect
121
+ 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-muted); color: var(--tandem-fg); cursor: pointer; align-self: flex-start;"> </button> <!>`,1);function Pj(e,t){A(t,!0);function n(e){switch(e){case Cj:return`Working directory must be a folder inside your home directory.`;case Sj:return`Working directory path is invalid.`;case wj:return`Another working-directory update is in progress. Try again.`;case Ej:return`No Claude Code integration is configured.`;case Tj: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=N(null),a=N(!1),o=N(null),s=N(!1),c=N(!1),l=N(null),u=M(()=>B(s)&&!B(c)&&!B(l)),d=!0;_a(()=>{d=!1});async function f(){try{let e=await fetch(`${Il}/api/integrations`);if(!d)return;if(!e.ok){P(l,`Failed to load integrations (HTTP ${e.status}).`);return}let t=await e.json();if(!d)return;let n=t.integrations?.find(e=>e.kind===`claude-code`);n&&(P(c,!0),P(i,n.workingDirectory??null,!0))}catch(e){if(!d)return;console.warn(`[Settings] Failed to load workingDirectory:`,e),P(l,`Couldn't load Claude working directory.`)}finally{d&&P(s,!0)}}f();async function p(e){P(a,!0),P(o,null);try{let r=await fetch(`${Il}${Uc}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({workingDirectory:e})});if(!d)return;if(!r.ok){let e=await r.json().catch(()=>({}));if(!d)return;P(o,n(e.code),!0);return}let a=await r.json();if(!d)return;P(i,a.workingDirectory??null,!0),t.notify(`info`,`Working directory saved.`)}catch(e){if(!d)return;console.warn(`[Settings] Failed to save workingDirectory:`,e),P(o,`Couldn't save working directory.`)}finally{d&&P(a,!1)}}async function m(){let e;try{({open:e}=await Ul(()=>import(`./dist-js-BWAGOggB.js`),__vite__mapDeps([2,1])))}catch(e){console.warn(`[Settings] Folder picker import failed:`,e),t.notify(`error`,`Folder picker plugin unavailable`);return}try{let t=await e({directory:!0,multiple:!1,title:`Choose Claude working directory`});typeof t==`string`&&p(t)}catch(e){console.warn(`[Settings] Folder picker open() failed:`,e),t.notify(`error`,`Folder picker permission denied or IPC error`)}}function h(e){e.preventDefault();let t=e.target.elements.namedItem(`wd`)?.value.trim();p(t||null)}function g(){p(null)}var _=Nj(),v=I(_),y=e=>{var t=Dj(),n=L(F(t),4);O(t),V(`click`,n,r),U(e,t)};G(v,e=>{B(u)&&e(y)});var b=L(v,4),x=F(b),S=L(F(x)),C=F(S);O(S),O(x);var w=L(x,4);Qi(w),q(w,`step`,100);var ee=L(w,2),T=F(ee),E=F(T);O(T);var te=L(T,2),ne=F(te);O(te),O(ee),O(b);var D=L(b,2),re=F(D);Qi(re),k(2),O(D);var ie=L(D,2),ae=F(ie);Qi(ae),k(2),O(ie);var oe=L(ie,4),se=e=>{var t=Oj(),n=F(t,!0);O(t),z(()=>W(n,B(l))),U(e,t)};G(oe,e=>{B(s)&&!B(c)&&B(l)&&e(se)});var ce=L(oe,2),le=e=>{var t=jj(),n=L(F(t),4),r=F(n);Qi(r),q(r,`placeholder`,`(default: home)`);var s=L(r,2);O(n);var c=L(n,2),l=F(c),u=e=>{var t=kj();z(()=>t.disabled=B(a)),V(`click`,t,m),U(e,t)},d=M(()=>nh());G(l,e=>{B(d)&&e(u)});var f=L(l,2);O(c);var p=L(c,2),_=e=>{var t=Aj(),n=F(t,!0);O(t),z(()=>W(n,B(o))),U(e,t)};G(p,e=>{B(o)&&e(_)}),O(t),z(()=>{$i(r,B(i)??``),r.disabled=B(a),s.disabled=B(a),f.disabled=B(a)||B(i)===null}),Rr(`submit`,n,h),V(`click`,f,g),U(e,t)};G(ce,e=>{B(s)&&B(c)&&e(le)});var ue=L(ce,2),de=F(ue,!0);O(ue);var fe=L(ue,2),pe=e=>{var t=Yr();ai(I(t),()=>Ul(()=>import(`./CoworkSettings-B4LapjhG.js`),__vite__mapDeps([4,5])),e=>{U(e,Mj())},(e,t)=>{let n=M(()=>B(t).default);var r=Yr();bi(I(r),()=>B(n),(e,t)=>{t(e,{})}),U(e,r)}),U(e,t)},me=M(()=>nh());G(fe,e=>{B(me)&&e(pe)}),z((e,n,r)=>{W(C,`${e??``}s`),q(w,`min`,500),q(w,`max`,Fa),$i(w,t.settings.selectionDwellMs),W(E,`${n??``}s`),W(ne,`${r??``}s`),ea(re,t.settings.selectionToolbar),ea(ae,t.settings.marginView),W(de,B(u)?`Open integration wizard…`:`Reopen integration wizard…`)},[()=>(t.settings.selectionDwellMs/1e3).toFixed(1),()=>(500/1e3).toFixed(1),()=>(Fa/1e3).toFixed(1)]),V(`input`,w,e=>t.onUpdate({selectionDwellMs:Number(e.target.value)})),V(`change`,re,e=>t.onUpdate({selectionToolbar:e.target.checked})),V(`change`,ae,e=>t.onUpdate({marginView:e.target.checked})),V(`click`,ue,r),U(e,_),j()}zr([`click`,`input`,`change`]);function Fj(e){let t=e?.trim();return t?t.slice(0,40):`You`}function Ij(){try{return Fj(localStorage.getItem(io))}catch{return`You`}}function Lj(e){let t=Fj(e);try{localStorage.setItem(io,t)}catch{}return typeof window<`u`&&window.dispatchEvent(new Event(ao)),t}function Rj(e){let t=()=>e(Ij()),n=t=>{t.key===`tandem:userName`&&e(Fj(t.newValue))};return window.addEventListener(ao,t),window.addEventListener(`storage`,n),()=>{window.removeEventListener(ao,t),window.removeEventListener(`storage`,n)}}function zj(){let e=N(ln(Ij()));return _a(Rj(t=>{P(e,t,!0)})),{get userName(){return B(e)},setUserName:t=>{P(e,Lj(t),!0)}}}var Bj=H(`<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
122
+ restores when you return to Tandem.</div>`,1);function Vj(e,t){A(t,!0);let n=zj(),r=N(ln(n.userName)),i=N(void 0);R(()=>{let e=n.userName;B(r)!==e&&document.activeElement!==B(i)&&P(r,e,!0)});var a=Bj(),o=I(a),s=L(F(o),2);Qi(s),da(s,e=>P(i,e),()=>B(i)),O(o);var c=L(o,2),l=L(F(c),2),u=F(l),d=L(u,2);O(l),k(2),O(c);var f=L(c,2),p=F(f);Qi(p),k(2),O(f),k(2),z(()=>{$i(s,B(r)),q(s,`maxlength`,40),q(u,`aria-checked`,t.settings.defaultMode===`tandem`),q(d,`aria-checked`,t.settings.defaultMode===`solo`),ea(p,t.settings.soloRailHidden)}),V(`input`,s,e=>{P(r,e.target.value,!0)}),Rr(`blur`,s,()=>n.setUserName(B(r))),V(`keydown`,s,e=>{e.key===`Enter`&&e.currentTarget.blur(),e.key===`Escape`&&(P(r,n.userName,!0),e.currentTarget.blur())}),V(`click`,u,()=>t.onUpdate({defaultMode:`tandem`})),V(`click`,d,()=>t.onUpdate({defaultMode:`solo`})),V(`change`,p,e=>t.onUpdate({soloRailHidden:e.target.checked})),U(e,a),j()}zr([`input`,`keydown`,`click`,`change`]);var Hj=Ng({baseUrl:`http://127.0.0.1:${ba}`,pathFor:bg});function Uj(){let e=new Uint8Array(16);crypto.getRandomValues(e);let t=``;for(let n of e)t+=String.fromCharCode(n);return btoa(t).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)}function Wj(){return crypto.randomUUID()}function Gj(e){if(e.provider!==void 0&&!Sl.includes(e.provider))throw Error(`Invalid model provider: ${String(e.provider)}`)}async function Kj(e,t){let n=await Hj.set(e,t);if(n.status===`ok`)return;let r=n.status===`unavailable`?`KEYCHAIN_UNAVAILABLE`:`STORE_FAILED`;throw Error(`Failed to store model key (${r})`)}function qj(e){return{get models(){return e.settings.models},get defaultModelId(){return e.settings.defaultModelId},get hasLegacyKeys(){return e.settings.models.some(e=>typeof e._legacyApiKey==`string`)},async addModel(t,n){Gj(t);let r=Wj(),i;n&&n.length>0&&(i=Uj(),await Kj(i,n));let a={...t,id:r,...i?{apiKeyRef:i}:{}};return e.updateSettings({models:[...e.settings.models,a]}),r},async updateModel(t,n,r){Gj(n);let i=e.settings.models.find(e=>e.id===t);if(!i)return;let a;r!==void 0&&r.length>0&&(a=Uj(),await Promise.all([Kj(a,r),i.apiKeyRef?Hj.delete(i.apiKeyRef):Promise.resolve()])),e.updateSettings({models:e.settings.models.map(e=>e.id===t?{...e,...n,...a?{apiKeyRef:a}:{}}:e)})},async deleteModel(t){let n=e.settings.models.find(e=>e.id===t);n?.apiKeyRef&&await Hj.delete(n.apiKeyRef),e.updateSettings({models:e.settings.models.filter(e=>e.id!==t),defaultModelId:e.settings.defaultModelId===t?null:e.settings.defaultModelId})},toggleEnabled(t){e.updateSettings({models:e.settings.models.map(e=>e.id===t?{...e,enabled:!e.enabled}:e)})},setDefault(t){e.updateSettings({defaultModelId:t})},async migrateLegacyKeys(){let t=e.settings.models,n=t.map((e,t)=>typeof e._legacyApiKey==`string`?t:-1).filter(e=>e>=0);if(n.length===0)return{migrated:0,failed:0};let r=n.map(()=>Uj()),i=await Promise.allSettled(n.map((e,n)=>Kj(r[n],t[e]._legacyApiKey))),a=t.slice(),o=0,s=0;return i.forEach((e,i)=>{let c=n[i];if(e.status===`fulfilled`){let e={...t[c],apiKeyRef:r[i]};delete e._legacyApiKey,a[c]=e,o++}else s++}),o>0&&e.updateSettings({models:a}),{migrated:o,failed:s}}}}var Jj=H(`<option> </option>`),Yj=H(`<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>`),Xj=H(`<input data-testid="model-edit-apikey" class="mem-input mem-input--mono svelte-1pwv6ag" type="password" autocomplete="off"/>`),Zj=H(`<label class="mem-field svelte-1pwv6ag"><span class="mem-label svelte-1pwv6ag">API key</span> <!></label>`),Qj=H(`<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>`),$j=H(`<p class="mem-advanced-help svelte-1pwv6ag">Per-model parameter overrides (temperature, max tokens, etc.) are not editable in
123
+ this preview. The data model accepts a \`params\` map for forward-compat with
124
+ Wave 6 surfaces.</p>`),eM=H(`<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 tM(e,t){A(t,!0);let 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=kr(()=>t.entry),i=N(ln(r?.provider??`anthropic`)),a=N(ln(r?.displayName??``)),o=N(ln(r?.modelId??``)),s=N(ln(r?.endpoint??``)),c=N(ln(r?.enabled??!0)),l=N(``),u=r!==void 0&&!!r.apiKeyRef,d=N(ln(r===void 0||!u)),f=r!==void 0,p=M(()=>B(i)===`anthropic`||B(i)===`openai`||B(i)===`gemini`),m=M(()=>B(i).startsWith(`local-`)),h=r?.apiKeyRef?r.apiKeyRef.slice(-4):``,g=M(()=>B(a).trim().length>0&&B(o).trim().length>0&&(!B(p)||!B(d)||B(l).trim().length>0));function _(e){if(e.preventDefault(),!B(g))return;let n={provider:B(i),displayName:B(a).trim(),modelId:B(o).trim(),enabled:B(c)};B(p)&&B(d)&&B(l).trim()&&(n.plaintextApiKey=B(l).trim()),B(m)&&B(s).trim()&&(n.endpoint=B(s).trim()),t.onSave(n)}function v(){P(d,!0),P(l,``)}var y=eM();q(y,`tabindex`,-1);var b=F(y),x=F(b),S=F(x),C=F(S,!0);O(S);var w=L(S,2);O(x);var ee=L(x,2),T=L(F(ee),2);fi(T,21,()=>n,e=>e.value,(e,t)=>{var n=Jj(),r=F(n,!0);O(n);var i={};z(()=>{W(r,B(t).label),i!==(i=B(t).value)&&(n.value=(n.__value=B(t).value)??``)}),U(e,n)}),O(T),O(ee);var E=L(ee,2),te=L(F(E),2);Qi(te),O(E);var ne=L(E,2),D=L(F(ne),2);Qi(D),O(ne);var re=L(ne,2),ie=e=>{var t=Zj(),n=L(F(t),2),i=e=>{var t=Yj(),n=F(t),r=F(n);O(n);var i=L(n,2);O(t),z(()=>W(r,`••••••••${h??``}`)),V(`click`,i,v),U(e,t)},a=e=>{var t=Xj();Qi(t),z(()=>q(t,`placeholder`,f?`Enter new key`:`Paste your API key`)),ia(t,()=>B(l),e=>P(l,e)),U(e,t)};G(n,e=>{f&&r?.apiKeyRef&&!B(d)?e(i):e(a,-1)}),O(t),U(e,t)};G(re,e=>{B(p)&&e(ie)});var ae=L(re,2),oe=e=>{var t=Qj(),n=L(F(t),2);Qi(n),O(t),ia(n,()=>B(s),e=>P(s,e)),U(e,t)};G(ae,e=>{B(m)&&e(oe)});var se=L(ae,2),ce=F(se);Qi(ce),k(2),O(se);var le=L(se,2);uj(le,{label:`Advanced parameters`,testid:`model-edit-advanced`,children:(e,t)=>{U(e,$j())},$$slots:{default:!0}});var ue=L(le,2),de=F(ue),fe=L(de,2),pe=F(fe,!0);O(fe),O(ue),O(b),O(y),z(()=>{q(y,`aria-label`,f?`Edit model`:`Add model`),W(C,f?`Edit model`:`Add model`),fe.disabled=!B(g),W(pe,f?`Save changes`:`Add model`)}),V(`click`,y,e=>{e.target===e.currentTarget&&t.onCancel()}),V(`keydown`,y,e=>{e.key===`Escape`&&t.onCancel()}),Rr(`submit`,b,_),V(`click`,w,function(...e){t.onCancel?.apply(this,e)}),Ki(T,()=>B(i),e=>P(i,e)),ia(te,()=>B(a),e=>P(a,e)),ia(D,()=>B(o),e=>P(o,e)),aa(ce,()=>B(c),e=>P(c,e)),V(`click`,de,function(...e){t.onCancel?.apply(this,e)}),U(e,y),j()}zr([`click`,`keydown`]);var nM=H(`<span data-testid="models-legacy-migration-status"> </span>`),rM=H(`<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
125
+ 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>`),iM=H(`<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>`),aM=H(`<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),oM=H(`<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>`),sM=H(`<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>`),cM=H(`<div><div class="settings-section-label"> </div> <div style="display: flex; flex-direction: column; gap: 4px;"></div></div>`),lM=H(`<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),uM=H(`<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>`),dM=H(`<div style="display: flex; flex-direction: column; gap: var(--tandem-space-3);"><!> <!></div> <!> <!>`,1);function fM(e,t){A(t,!0);let n=qj(xv()),r={anthropic:`Anthropic`,openai:`OpenAI`,gemini:`Gemini`,"local-ollama":`Ollama (local)`,"local-llamacpp":`llama.cpp (local)`},i=[`anthropic`,`openai`,`gemini`,`local-ollama`,`local-llamacpp`],a=M(()=>{let e=new Map;for(let t of i)e.set(t,[]);for(let t of n.models){let n=e.get(t.provider);n&&n.push(t)}return e}),o=N(void 0),s=N(!1),c=N(null),l=N(null),u=N(!1),d=N(null);function f(){P(o,void 0),P(l,null),P(s,!0)}function p(e){P(o,e,!0),P(l,null),P(s,!0)}async function m(e){let{plaintextApiKey:t,...r}=e;try{B(o)?await n.updateModel(B(o).id,r,t):await n.addModel(r,t),P(s,!1),P(o,void 0),P(l,null)}catch(e){P(l,e instanceof Error?e.message:`Failed to save`,!0)}}async function h(e){await n.deleteModel(e),P(c,null)}async function g(){P(u,!0),P(d,null);try{let e=await n.migrateLegacyKeys();e.failed>0?P(d,`Migrated ${e.migrated}; ${e.failed} failed. Retry?`):e.migrated>0&&P(d,`Migrated ${e.migrated} ${e.migrated===1?`key`:`keys`} to OS keychain.`)}finally{P(u,!1)}}var _=dM(),v=I(_),y=F(v),b=e=>{var t=rM(),n=L(F(t),2),r=F(n),i=F(r,!0);O(r);var a=L(r,2),o=e=>{var t=nM(),n=F(t,!0);O(t),z(()=>W(n,B(d))),U(e,t)};G(a,e=>{B(d)&&e(o)}),O(n),O(t),z(()=>{r.disabled=B(u),K(r,`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: ${B(u)?`wait`:`pointer`};`),W(i,B(u)?`Migrating…`:`Migrate keys`)}),V(`click`,r,g),U(e,t)};G(y,e=>{n.hasLegacyKeys&&e(b)});var x=L(y,2),S=e=>{var t=iM(),n=L(F(t),2);O(t),V(`click`,n,f),U(e,t)},C=e=>{var t=lM(),o=I(t);fi(o,20,()=>i,e=>e,(e,t)=>{let i=M(()=>B(a).get(t)??[]);var o=Yr(),s=I(o),l=e=>{var a=cM(),o=F(a),s=F(o,!0);O(o);var l=L(o,2);fi(l,21,()=>B(i),e=>e.id,(e,t)=>{var r=sM(),i=F(r),a=F(i),o=F(a,!0);O(a);var s=L(a,2),l=F(s,!0);O(s),O(i);var u=L(i,2),d=F(u);Qi(d),k(2),O(u);var f=L(u,2),m=F(f);Qi(m);var g=L(m,2),_=F(g,!0);O(g),O(f);var v=L(f,2),y=L(v,2),b=e=>{var n=aM(),r=I(n),i=L(r,2);z(()=>q(r,`data-testid`,`model-delete-confirm-${B(t).id}`)),V(`click`,r,()=>h(B(t).id)),V(`click`,i,()=>P(c,null)),U(e,n)},x=e=>{var n=oM();z(()=>q(n,`data-testid`,`model-delete-btn-${B(t).id}`)),V(`click`,n,()=>P(c,B(t).id,!0)),U(e,n)};G(y,e=>{B(c)===B(t).id?e(b):e(x,-1)}),O(r),z(()=>{q(r,`data-testid`,`model-row-${B(t).id}`),W(o,B(t).displayName),W(l,B(t).modelId),q(d,`data-testid`,`model-default-${B(t).id}`),ea(d,n.defaultModelId===B(t).id),q(m,`data-testid`,`model-toggle-${B(t).id}`),ea(m,B(t).enabled),W(_,B(t).enabled?`On`:`Off`),q(v,`data-testid`,`model-edit-btn-${B(t).id}`)}),V(`change`,d,()=>n.setDefault(B(t).id)),V(`change`,m,()=>n.toggleEnabled(B(t).id)),V(`click`,v,()=>p(B(t))),U(e,r)}),O(l),O(a),z(()=>W(s,r[t])),U(e,a)};G(s,e=>{B(i).length>0&&e(l)}),U(e,o)}),O(o),V(`click`,L(o,2),f),U(e,t)};G(x,e=>{n.models.length===0?e(S):e(C,-1)}),O(v);var w=L(v,2),ee=e=>{var t=uM(),n=F(t,!0);O(t),z(()=>W(n,B(l))),U(e,t)};G(w,e=>{B(l)&&e(ee)});var T=L(w,2),E=e=>{tM(e,{get entry(){return B(o)},onCancel:()=>{P(s,!1),P(o,void 0),P(l,null)},onSave:m})};G(T,e=>{B(s)&&e(E)}),U(e,_),j()}zr([`click`,`change`]);var pM=H(`<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>`),mM=H(`<span style="justify-self: start; font-size: 11px; color: var(--tandem-accent-fg-strong); font-style: italic;">Press keys… (Esc to cancel)</span>`),hM=H(`<kbd> </kbd>`),gM=H(`<button type="button">Reset</button>`),_M=H(`<div style="grid-column: 1 / -1; font-size: 11px; color: var(--tandem-error-fg);"> </div>`),vM=H(`<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>`),yM=H(`<kbd> </kbd> <span style="font-size: 13px; color: var(--tandem-fg-muted);"> </span>`,1),bM=H(`<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>`),xM=H(`<kbd> </kbd> <span style="font-size: 13px; color: var(--tandem-fg-muted);"> </span>`,1),SM=H(`<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 CM(e,t){A(t,!0);let n=J(t,`notify`,3,()=>{}),r=N(null),i=N(null),a=M(()=>t.settings._readOnly===!0),o=M(()=>vl(t.settings.customShortcuts));R(()=>{if(B(r)===null)return;let e=B(r),a=a=>{if(a.preventDefault(),a.stopPropagation(),a.key===`Escape`){P(r,null),P(i,null);return}let s=el(a);if(!s)return;let c=hl(s,B(o),e);if(c){P(i,{id:e,message:`Already used by ${c}`},!0);return}P(r,null),P(i,null),t.onUpdate({customShortcuts:{...t.settings.customShortcuts,[e]:s}}),n()(`info`,`${qc[e]} set to ${ol(s)}`)};return window.addEventListener(`keydown`,a,{capture:!0}),()=>window.removeEventListener(`keydown`,a,{capture:!0})});function s(e){B(a)||(P(i,null),P(r,e,!0))}function c(e){if(B(a))return;let{[e]:n,...o}=t.settings.customShortcuts;t.onUpdate({customShortcuts:o}),B(r)===e&&P(r,null),B(i)?.id===e&&P(i,null)}function l(){B(a)||(t.onUpdate({customShortcuts:{}}),P(r,null),P(i,null))}let u=M(()=>Wc.some(e=>B(o).has(e))),d=M(()=>{let e=su(),t=new Map;for(let n of e.values()){if(!n.shortcut||Xc[n.id])continue;let e=t.get(n.group)??[];e.push({keys:n.shortcut,description:n.label}),t.set(n.group,e)}return iu.map(e=>({title:e.charAt(0).toUpperCase()+e.slice(1),rows:t.get(e)??[]})).filter(e=>e.rows.length>0)}),f=`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=SM(),m=F(p),h=F(m),g=L(F(h),2);O(h);var _=L(h,2),v=e=>{U(e,pM())};G(_,e=>{B(a)&&e(v)});var y=L(_,2);fi(y,20,()=>Wc,e=>e,(e,t)=>{let n=M(()=>B(r)===t),l=M(()=>B(o).has(t)),u=M(()=>ol(sl(t,B(o))));var d=vM(),p=F(d),m=F(p,!0);O(p);var h=L(p,2),g=e=>{var n=mM();z(()=>q(n,`data-testid`,`shortcut-recording-${t}`)),U(e,n)},_=e=>{var t=hM();K(t,f);var n=F(t,!0);O(t),z(()=>W(n,B(u))),U(e,t)};G(h,e=>{B(n)?e(g):e(_,-1)});var v=L(h,2),y=F(v),b=F(y,!0);O(y);var x=L(y,2),S=e=>{var n=gM();z(()=>{q(n,`data-testid`,`shortcut-reset-${t}`),n.disabled=B(a),K(n,`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: ${B(a)?`not-allowed`:`pointer`}; opacity: ${B(a)?.5:1};`)}),V(`click`,n,()=>c(t)),U(e,n)};G(x,e=>{B(l)&&e(S)}),O(v);var C=L(v,2),w=e=>{var n=_M(),r=F(n,!0);O(n),z(()=>{q(n,`data-testid`,`shortcut-conflict-${t}`),W(r,B(i).message)}),U(e,n)};G(C,e=>{B(i)&&B(i).id===t&&e(w)}),O(d),z(()=>{q(d,`data-testid`,`shortcut-row-${t}`),W(m,qc[t]),q(y,`data-testid`,`shortcut-edit-${t}`),y.disabled=B(a),K(y,`font-size: 11px; padding: 2px 8px; border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-2); background: ${B(n)?`var(--tandem-accent-bg)`:`var(--tandem-surface)`}; color: var(--tandem-fg); cursor: ${B(a)?`not-allowed`:`pointer`}; opacity: ${B(a)?.5:1};`),W(b,B(n)?`Recording…`:`Change`)}),V(`click`,y,()=>s(t)),U(e,d)}),O(y),O(m);var b=L(m,2);fi(b,17,()=>B(d),e=>e.title,(e,t)=>{var n=bM(),r=F(n),i=F(r);O(r);var a=L(r,2);fi(a,21,()=>B(t).rows,e=>e.keys+e.description,(e,t)=>{var n=yM(),r=I(n);K(r,f);var i=F(r,!0);O(r);var a=L(r,2),o=F(a,!0);O(a),z(()=>{W(i,B(t).keys),W(o,B(t).description)}),U(e,n)}),O(a),O(n),z(()=>W(i,`${B(t).title??``} (fixed)`)),U(e,n)});var x=L(b,2),S=L(F(x),2);fi(S,21,()=>fm,e=>e.keys+e.description,(e,t)=>{var n=xM(),r=I(n);K(r,f);var i=F(r,!0);O(r);var a=L(r,2),o=F(a,!0);O(a),z(()=>{W(i,B(t).keys),W(o,B(t).description)}),U(e,n)}),O(S),O(x),O(p),z(()=>{g.disabled=B(a)||!B(u),K(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: ${B(a)||!B(u)?`not-allowed`:`pointer`}; opacity: ${B(a)||!B(u)?.5:1};`)}),V(`click`,g,l),U(e,p),j()}zr([`click`]);var wM=H(`<div data-testid="settings-modal-shortcuts-list"><!></div>`);function TM(e,t){var n=wM();CM(F(n),{get settings(){return t.settings},get onUpdate(){return t.onUpdate},get notify(){return t.notify}}),O(n),U(e,n)}var EM=H(`<div data-testid="license-settings-section"><div class="settings-section-label">License status</div> <div class="license-pill svelte-ezrf0s" data-testid="license-status-pill"> </div> <div class="settings-section-label" style="margin-top: var(--tandem-space-4);">Activate a license</div> <!> <div class="settings-hint" style="margin-top: var(--tandem-space-1);">Paste a license key you received by email, or run <code>tandem activate &lt;file&gt;</code> from
126
+ the command line. A valid license unlocks editing and runs forever.</div></div>`);function DM(e,t){A(t,!0);let n=M(()=>cv.ui),r=M(()=>B(n).statusLabel||`No license required`);function i(){t.notify(`info`,`License activated.`)}var a=EM(),o=L(F(a),2),s=F(o,!0);O(o),mv(L(o,4),{onActivated:i}),k(2),O(a),z(()=>W(s,B(r))),U(e,a),j()}var OM=null;function kM(){return typeof window<`u`&&`__TAURI_INTERNALS__`in window}function AM(e){return e.replace(/sk-ant-[A-Za-z0-9_-]{8,}/g,`sk-ant-[redacted]`).replace(/sk-[A-Za-z0-9_-]{16,}/g,`sk-[redacted]`).replace(/\bBearer\s+[A-Za-z0-9._~+/-]{12,}=*/gi,`Bearer [redacted]`)}function jM(e){return e.replace(/(\/Users\/)[^/\\]+/g,`$1[user]`).replace(/(\/home\/)[^/\\]+/g,`$1[user]`).replace(/([A-Za-z]:\\Users\\)[^\\]+/g,`$1[user]`)}function MM(e){return jM(AM(e))}async function NM(){if(kM())try{let{invoke:e}=await Ul(async()=>{let{invoke:e}=await import(`./core-SwWLTXZB.js`);return{invoke:e}},[]);if(!await e(`sentry_enabled`).catch(()=>!1))return;let t=await Ul(()=>import(`./prod-p35ShryZ.js`),[]),{defaultOptions:n}=await Ul(async()=>{let{defaultOptions:e}=await import(`./dist-CJtsfiU2.js`);return{defaultOptions:e}},__vite__mapDeps([6,7]));t.init({...n,sendDefaultPii:!1,beforeSend:e=>{e.message&&=MM(e.message);for(let t of e.exception?.values??[])t.value&&=MM(t.value);return e.request&&(e.request.data=void 0,e.request.url&&(e.request.url=MM(e.request.url))),e},beforeBreadcrumb:e=>(e.message&&=MM(e.message),(e.category===`fetch`||e.category===`xhr`)&&(e.data=void 0),e)}),OM=t,window.addEventListener(`error`,e=>{FM(e.error??e.message,{source:`window.onerror`})}),window.addEventListener(`unhandledrejection`,e=>{FM(e.reason,{source:`unhandledrejection`})}),console.info(`[sentry] client crash reporting initialised`)}catch(e){console.warn(`[sentry] client init failed (non-fatal):`,e)}}function PM(){return OM!==null}function FM(e,t){if(OM)try{OM.captureException(e,t?{extra:t}:void 0)}catch{}}var IM={pass:`[ok] `,warn:`[warn]`,fail:`[fail]`};function LM(e){return e.replace(/[\x00-\x08\x0b-\x1f\x7f]/g,``)}function RM(e){let t=[`Tandem v${e.version} (${e.transport}${e.tauriSidecar?`, desktop`:``})`,`${e.platform}/${e.arch}, Node ${e.nodeVersion}`,``];for(let n of e.report.results)t.push(`${IM[n.status]} ${n.check} — ${LM(n.message)}`),n.status!==`pass`&&n.fix&&t.push(` fix: ${LM(n.fix)}`);return t.push(``,LM(e.report.summary)),t.join(`
127
+ `)}var zM=H(`<div style="margin-top: 6px; font-size: 11px; color: var(--tandem-error-fg);"> </div>`),BM=H(`<button type="button" data-testid="settings-modal-open-log-folder-btn">Open Log Folder</button>`),VM=H(`<div style="font-size: 11px; color: var(--tandem-fg-subtle);">Loading...</div>`),HM=H(`<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),UM=H(`<dl style="display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 5px 14px; margin: 0; font-size: 11px;"></dl>`),WM=H(`<div style="font-size: 11px; color: var(--tandem-fg-subtle);">App info unavailable.</div>`),GM=H(`<div><button type="button" data-testid="settings-modal-view-documentation-btn"> </button> <!></div> <div style="display: flex; gap: var(--tandem-space-2);"><button type="button" data-testid="settings-modal-copy-diagnostics-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 KM(e,t){A(t,!0);let n=KA(()=>t.open),r=N(!1),i=N(null),a=N(!1);async function o(){P(a,!0);let e;try{let n;try{n=await fetch(`${Il}${hc}`)}catch{t.notify(`error`,`Couldn't reach the server — is it running?`);return}if(!n.ok){t.notify(`error`,"Diagnostics failed on the server — try `tandem doctor` in a terminal");return}e=RM(await n.json())}catch{t.notify(`error`,"Diagnostics failed on the server — try `tandem doctor` in a terminal");return}finally{P(a,!1)}try{await navigator.clipboard.writeText(e),t.notify(`info`,`Diagnostics copied to clipboard`)}catch{t.notify(`error`,"Couldn't access the clipboard — run `tandem doctor` in a terminal instead")}}async function s(){try{let[{appLogDir:e},t]=await Promise.all([Ul(()=>import(`./path-49-uTKly.js`),__vite__mapDeps([0,1])),ah()]);await t(`show_in_file_manager`,{path:await e()})}catch{t.notify(`error`,`Couldn't open the log folder`)}}async function c(){let e=n.info?.workflowsPath;if(!e){P(i,`Documentation file not found.`);return}P(r,!0),P(i,null);let t=await Hh(e,{readOnly:!0,notFoundMessage:`Documentation file not found.`,failureMessage:`Failed to open documentation.`});P(r,!1),t.ok||P(i,t.error,!0)}let l=M(()=>{let e=n.info;if(!e)return[];let t=[{label:`Version`,value:`Tandem v${e.version}`},{label:`Tools`,value:e.toolCount===null?`Tool count unavailable`:`${e.toolCount} tools available`},{label:`MCP SDK`,value:`MCP SDK ${e.mcpSdkVersion}`},{label:`Transport`,value:e.transport?.toUpperCase()??`—`}];return e.storagePath&&t.push({label:`Storage`,value:e.storagePath}),e.tokenRotatedAt!==void 0&&t.push({label:`Token`,value:e.tokenRotatedAt===null?`Token not created`:`Token rotated ${new Date(e.tokenRotatedAt).toLocaleString()}`}),e.changelogPath&&t.push({label:`Changelog`,value:e.changelogPath}),t.push({label:`Crash reports`,value:PM()?`On (TANDEM_SENTRY_DSN set)`:`Off — opt in with TANDEM_SENTRY_DSN`}),t});var u=GM(),d=I(u),f=F(d),p=F(f,!0);O(f);var m=L(f,2),h=e=>{var t=zM(),n=F(t,!0);O(t),z(()=>W(n,B(i))),U(e,t)};G(m,e=>{B(i)&&e(h)}),O(d);var g=L(d,2),_=F(g),v=F(_,!0);O(_);var y=L(_,2),b=e=>{var t=BM();K(t,`flex: 1; padding: var(--tandem-space-2); font-size: 13px; font-weight: 500; border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-2); background: var(--tandem-surface-muted); color: var(--tandem-fg); cursor: pointer;`),V(`click`,t,()=>void s()),U(e,t)},x=M(()=>nh());G(y,e=>{B(x)&&e(b)}),O(g);var S=L(g,2),C=L(F(S),2),w=e=>{U(e,VM())},ee=e=>{var t=UM();fi(t,21,()=>B(l),e=>e.label,(e,t)=>{var n=HM(),r=I(n),i=F(r,!0);O(r);var a=L(r,2),o=F(a,!0);O(a),z(()=>{W(i,B(t).label),W(o,B(t).value)}),U(e,n)}),O(t),U(e,t)},T=e=>{U(e,WM())};G(C,e=>{n.loading?e(w):n.info?e(ee,1):e(T,-1)}),O(S),z(()=>{f.disabled=B(r)||n.loading,K(f,`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: ${B(r)||n.loading?`not-allowed`:`pointer`}; background: var(--tandem-surface-muted); color: var(--tandem-fg); opacity: ${B(r)||n.loading?.6:1};`),W(p,B(r)?`Opening…`:`View Documentation`),_.disabled=B(a),K(_,`flex: 1; padding: var(--tandem-space-2); font-size: 13px; font-weight: 500; border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-2); background: var(--tandem-surface-muted); color: var(--tandem-fg); cursor: ${B(a)?`not-allowed`:`pointer`}; opacity: ${B(a)?.6:1};`),W(v,B(a)?`Collecting…`:`Copy Diagnostics`)}),V(`click`,f,()=>void c()),V(`click`,_,()=>void o()),U(e,u),j()}zr([`click`]);var qM={appearance:`appearance`,editor:`editor`,network:`network`,accessibility:`accessibility`,collaboration:`collaboration`,claudeCode:`claude-code`,models:`models`,shortcuts:`shortcuts`,license:`license`,about:`about`},JM=H(`<span class="settings-modal-version-chip svelte-bbu5nk" data-testid="settings-modal-sidebar-version"> </span>`),YM=H(`<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>`),XM=H(`<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>`),ZM=H(`<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 QM(e,t){A(t,!0);let n=`tandem-settings-modal-heading`,r=[{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:ij},{id:`editor`,label:`Editor`,icon:`M4 4h11M4 9h16M4 14h11M4 19h16`,component:cj},{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:xj},{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:JA},{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:Vj},{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:Pj},{id:`models`,label:`Models`,icon:`M4 4h16v16H4V4Zm5-3v3M15 1v3M9 20v3M15 20v3M1 9h3M1 15h3M20 9h3M20 15h3M8 8h8v8H8V8Z`,component:fM},{id:`shortcuts`,label:`Shortcuts`,icon:`M3 7h2v2H3V7Zm0 4h2v2H3v-2Zm0 4h2v2H3v-2Zm4-8h2v2H7V7Zm0 4h2v2H7v-2Zm0 4h10v2H7v-2Zm4-8h10v2H11V7Zm0 4h6v2h-6v-2Zm8 0h2v2h-2v-2Z`,component:TM},{id:`license`,label:`License`,icon:`M6 10h12v10H6V10Zm2 0V7a4 4 0 0 1 8 0v3`,component:DM},{id:`about`,label:`About`,icon:`M12 3a9 9 0 1 0 0 18 9 9 0 0 0 0-18Zm0 4v6m0 4h.01`,component:KM}].filter(e=>e.id!==qM.models||!1),i=J(t,`returnFocusEl`,3,null),a=J(t,`triggerEl`,3,null),o=J(t,`connected`,3,!1),s=J(t,`reconnectAttempts`,3,0),c=J(t,`tabs`,3,r),l=J(t,`initialTabId`,3,null),u=J(t,`notify`,3,()=>{}),d=N(void 0),f=KA(()=>t.open),p=N(!1),m=N(null),h=N(!1);R(()=>{t.open&&P(h,!1)});let g=!1;R(()=>{if(t.open&&!g&&l()){let e=B(v).find(e=>e.id===l());e&&P(y,e.id,!0)}g=t.open});let _=N(!1);R(()=>{if(typeof window>`u`||!window.matchMedia)return;let e=window.matchMedia(`(max-width: 860px)`);P(_,e.matches,!0);let t=e=>{P(_,e.matches,!0)};return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)});let v=M(()=>c().length>0?c():r),y=N(ln(r[0].id)),b=M(()=>B(v).find(e=>e.id===B(y))??B(v)[0]),x=M(()=>B(b).label),S=M(()=>({open:t.open,settings:t.settings,onUpdate:t.onUpdate,connected:o(),reconnectAttempts:s(),notify:u()}));R(()=>{B(b)&&B(b).id!==B(y)&&P(y,B(b).id,!0)}),R(()=>{if(t.open)return kr(()=>B(d)?.focus()),()=>{i()?.focus()}}),R(()=>{if(!t.open)return;let e=e=>{let n=e.target;n&&(a()?.contains(n)||B(d)&&!B(d).contains(n)&&t.onClose())},n=setTimeout(()=>document.addEventListener(`pointerdown`,e),0);return()=>{clearTimeout(n),document.removeEventListener(`pointerdown`,e)}}),ga(()=>{let e=e=>{if(e.key!==`Escape`||!t.open)return;let n=e.target;if(!(!B(d)||!n||!B(d).contains(n))){if(e.stopPropagation(),B(_)&&B(h)){P(h,!1);return}t.onClose()}};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)}),R(()=>{if(!t.open)return;let e=e=>{if(e.key!==`Tab`||!B(d))return;let t=B(d).querySelectorAll(`button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])`);if(t.length===0)return;let n=t[0],r=t[t.length-1],i=document.activeElement;if(!B(d).contains(i)){e.preventDefault(),n.focus();return}e.shiftKey&&i===n?(e.preventDefault(),r.focus()):!e.shiftKey&&i===r&&(e.preventDefault(),n.focus())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)}),R(()=>{B(y),P(m,null)});async function C(){let e=f.info?.changelogPath;if(!e){P(m,`Changelog file not found.`);return}P(p,!0),P(m,null);let n=await Hh(e,{readOnly:!0,notFoundMessage:`Changelog file not found.`,failureMessage:`Failed to open changelog.`});P(p,!1),n.ok?t.onClose():P(m,n.error,!0)}var w={DEFAULT_SETTINGS_TABS:r},ee=Yr(),T=I(ee),E=e=>{var r=ZM(),i=I(r),a=L(i,2);q(a,`aria-labelledby`,n),q(a,`tabindex`,-1);var c=F(a),l=F(c),u=F(l);q(u,`id`,n);var g=L(u,2),w=e=>{var t=JM(),n=F(t);O(t),z(()=>W(n,`v${f.info.version??``}`)),U(e,t)};G(g,e=>{f.info&&e(w)}),O(l);var ee=L(l,2);fi(ee,21,()=>B(v),e=>e.id,(e,t)=>{var n=YM(),r=F(n),i=F(r);O(r);var a=L(r,2),o=F(a,!0);O(a),O(n),z(()=>{q(n,`aria-current`,B(y)===B(t).id?`page`:void 0),q(n,`data-active`,B(y)===B(t).id?`true`:`false`),q(n,`data-testid`,`settings-modal-tab-${B(t).id}`),q(i,`d`,B(t).icon),W(o,B(t).label)}),V(`click`,n,()=>{P(y,B(t).id,!0),P(h,!1)}),U(e,n)}),O(ee);var T=L(ee,2),E=F(T),te=F(E,!0);O(E);var ne=L(E,2),D=e=>{var t=XM(),n=F(t,!0);O(t),z(()=>W(n,B(m))),U(e,t)};G(ne,e=>{B(m)&&e(D)});var re=L(ne,2),ie=L(re,2),ae=F(ie),oe=L(ae,2),se=F(oe),ce=e=>{U(e,Jr(`MCP connected`))},le=e=>{U(e,Jr(`Reconnecting…`))},ue=e=>{U(e,Jr(`MCP offline`))};G(se,e=>{o()?e(ce):s()>0?e(le,1):e(ue,-1)}),O(oe),O(ie),O(T),O(c),Ni(c,(e,t)=>Vu?.(e,t),()=>`y`);var de=L(c,2),fe=F(de),pe=F(fe),me=L(pe,2),he=F(me,!0);O(me);var ge=L(me,2);O(fe);var _e=L(fe,2),ve=F(_e);si(F(ve),()=>B(b).id,e=>{var t=Yr();bi(I(t),()=>B(b).component,(e,t)=>{t(e,ha(()=>B(S)))}),U(e,t)}),O(ve),O(_e),Ni(_e,(e,t)=>Vu?.(e,t),()=>`y`),O(de),O(a),da(a,e=>P(d,e),()=>B(d)),z(()=>{q(a,`data-narrow-sidebar-open`,B(h)?`true`:`false`),c.inert=B(_)&&!B(h),E.disabled=B(p)||f.loading,W(te,B(p)?`Opening…`:`Changelog`),q(re,`href`,Sa),q(ae,`data-state`,o()?`connected`:s()>0?`reconnecting`:`disconnected`),q(pe,`aria-label`,B(h)?`Hide sections`:`Show sections`),q(pe,`aria-expanded`,B(h)),W(he,B(x))}),V(`click`,i,function(...e){t.onClose?.apply(this,e)}),V(`keydown`,i,e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),t.onClose())}),V(`click`,E,()=>void C()),V(`click`,pe,()=>{P(h,!B(h))}),V(`click`,ge,function(...e){t.onClose?.apply(this,e)}),U(e,r)};return G(T,e=>{t.open&&e(E)}),U(e,ee),j(w)}zr([`click`,`keydown`]);var $M=H(`<span class="settings-version-chip svelte-fsutp8" data-testid="settings-sidebar-version"> </span>`),eN=H(`<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>`),tN=H(`<div role="alert" data-testid="changelog-error" style="font-size: 11px; color: var(--tandem-error-fg); padding: 0 var(--tandem-space-2);"> </div>`),nN=H(`<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
128
+ restores when you return to Tandem.</div>`,1),rN=H(`<div data-testid="cowork-settings-suspense-fallback" style="font-size: 12px; color: var(--tandem-fg-subtle);">Loading Cowork integration...</div>`),iN=H(`<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),aN=H(`<div data-testid="settings-shortcuts-list"><!></div>`),oN=H(`<div style="margin-top: 6px; font-size: 11px; color: var(--tandem-error-fg);"> </div>`),sN=H(`<div style="font-size: 11px; color: var(--tandem-fg-subtle);">Loading...</div>`),cN=H(`<dt style="color: var(--tandem-fg-subtle);"> </dt> <dd style="margin: 0; color: var(--tandem-fg-muted); overflow-wrap: anywhere;"> </dd>`,1),lN=H(`<dl style="display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 5px 12px; margin: 0; font-size: 11px;"></dl>`),uN=H(`<div style="font-size: 11px; color: var(--tandem-fg-subtle);">App info unavailable.</div>`),dN=H(`<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),fN=H(`<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 pN(e,t){A(t,!0);let n=`tandem-settings-heading`,r=[{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`}],i=J(t,`connected`,3,!1),a=J(t,`reconnectAttempts`,3,0),o=N(void 0),s=N(void 0),c=zj(),l=N(ln(c.userName)),u=KA(()=>t.open),d=N(!1),f=N(null),p=N(!1),m=N(null),h=N(`appearance`);R(()=>{B(h),P(f,null),P(m,null)}),R(()=>{let e=c.userName;B(l)!==e&&document.activeElement!==B(s)&&P(l,e,!0)}),R(()=>{if(t.open)return B(o)?.focus(),()=>{t.returnFocusEl?.focus()}}),R(()=>{if(!t.open)return;let e=e=>{let n=e.target;t.anchorEl?.contains(n)||B(o)&&!B(o).contains(n)&&t.onClose()},n=setTimeout(()=>document.addEventListener(`pointerdown`,e),0);return()=>{clearTimeout(n),document.removeEventListener(`pointerdown`,e)}}),R(()=>{if(!t.open)return;let e=e=>{if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),t.onClose();return}if(e.key!==`Tab`||!B(o))return;let n=B(o).querySelectorAll(`button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])`);if(n.length===0)return;let r=n[0],i=n[n.length-1],a=document.activeElement;if(!B(o).contains(a)){e.preventDefault(),r.focus();return}e.shiftKey&&a===r?(e.preventDefault(),i.focus()):!e.shiftKey&&a===i&&(e.preventDefault(),r.focus())};return window.addEventListener(`keydown`,e,{capture:!0}),()=>window.removeEventListener(`keydown`,e,{capture:!0})});async function g(e,n,r,i){if(!e){r(i.notFound);return}n(!0),r(null);try{let n=await Hh(e,{readOnly:!0,notFoundMessage:i.notFound,failureMessage:i.failed});if(!n.ok){r(n.error);return}t.onClose()}finally{n(!1)}}function _(){return g(u.info?.workflowsPath,e=>P(p,e,!0),e=>P(m,e,!0),{notFound:`Documentation file not found.`,failed:`Failed to open documentation.`})}function v(){return g(u.info?.changelogPath,e=>P(d,e,!0),e=>P(f,e,!0),{notFound:`Changelog file not found.`,failed:`Failed to open changelog.`})}let y=`font-size: 11px; font-weight: 600; color: var(--tandem-fg); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px;`,b=()=>{};function x(e){return r.find(t=>t.id===e)?.label??`Settings`}function S(){let e=u.info;if(!e)return[];let t=[{label:`Version`,value:`Tandem v${e.version}`},{label:`Tools`,value:e.toolCount===null?`Tool count unavailable`:`${e.toolCount} tools available`},{label:`MCP SDK`,value:`MCP SDK ${e.mcpSdkVersion}`},{label:`Transport`,value:e.transport?.toUpperCase()??`—`}];return e.storagePath&&t.push({label:`Storage`,value:e.storagePath}),e.tokenRotatedAt!==void 0&&t.push({label:`Token`,value:e.tokenRotatedAt===null?`Token not created`:`Token rotated ${new Date(e.tokenRotatedAt).toLocaleString()}`}),e.changelogPath&&t.push({label:`Changelog`,value:e.changelogPath}),t}var C=Yr(),w=I(C),ee=e=>{var g=fN(),C=I(g),w=L(C,2);q(w,`aria-labelledby`,n),q(w,`tabindex`,-1);var ee=F(w),T=F(ee),E=F(T);q(E,`id`,n);var te=L(E,2),ne=e=>{var t=$M(),n=F(t);O(t),z(()=>W(n,`v${u.info.version??``}`)),U(e,t)};G(te,e=>{u.info&&e(ne)}),O(T);var D=L(T,2);fi(D,21,()=>r,e=>e.id,(e,t)=>{var n=eN(),r=F(n),i=F(r);O(r);var a=L(r,2),o=F(a,!0);O(a),O(n),z(()=>{q(n,`aria-current`,B(h)===B(t).id?`page`:void 0),q(n,`data-active`,B(h)===B(t).id?`true`:`false`),q(i,`d`,B(t).icon),W(o,B(t).label)}),V(`click`,n,()=>P(h,B(t).id,!0)),U(e,n)}),O(D);var re=L(D,2),ie=F(re),ae=F(ie,!0);O(ie);var oe=L(ie,2),se=e=>{var t=tN(),n=F(t,!0);O(t),z(()=>W(n,B(f))),U(e,t)};G(oe,e=>{B(f)&&e(se)});var ce=L(oe,2),le=L(ce,2),ue=F(le),de=L(ue,2),fe=F(de),pe=e=>{U(e,Jr(`MCP connected`))},me=e=>{U(e,Jr(`Reconnecting…`))},he=e=>{U(e,Jr(`MCP offline`))};G(fe,e=>{i()?e(pe):a()>0?e(me,1):e(he,-1)}),O(de),O(le),O(re),O(ee);var ge=L(ee,2),_e=F(ge),ve=F(_e),ye=F(ve,!0);O(ve);var be=L(ve,2);O(_e);var xe=L(_e,2),Se=F(xe),Ce=F(Se),we=e=>{var n=nN(),r=I(n),i=F(r);K(i,y);var a=L(i,2);Qi(a),da(a,e=>P(s,e),()=>B(s)),O(r);var o=L(r,2),u=F(o);K(u,y);var d=L(u,2),f=F(d),p=L(f,2);O(d),k(2),O(o);var m=L(o,2),h=F(m);Qi(h),k(2),O(m),k(2),z(()=>{$i(a,B(l)),q(a,`maxlength`,40),q(f,`aria-checked`,t.settings.defaultMode===`tandem`),K(f,`flex: 1; padding: var(--tandem-space-2); min-height: 30px; border: 2px solid ${t.settings.defaultMode===`tandem`?`var(--tandem-accent)`:`var(--tandem-border)`}; border-radius: var(--tandem-r-3); background: ${t.settings.defaultMode===`tandem`?`var(--tandem-accent-bg)`:`var(--tandem-surface)`}; color: ${t.settings.defaultMode===`tandem`?`var(--tandem-accent-fg-strong)`:`var(--tandem-fg-muted)`}; font-size: 12px; font-weight: ${t.settings.defaultMode===`tandem`?600:400}; cursor: pointer;`),q(p,`aria-checked`,t.settings.defaultMode===`solo`),K(p,`flex: 1; padding: var(--tandem-space-2); min-height: 30px; border: 2px solid ${t.settings.defaultMode===`solo`?`var(--tandem-accent)`:`var(--tandem-border)`}; border-radius: var(--tandem-r-3); background: ${t.settings.defaultMode===`solo`?`var(--tandem-accent-bg)`:`var(--tandem-surface)`}; color: ${t.settings.defaultMode===`solo`?`var(--tandem-accent-fg-strong)`:`var(--tandem-fg-muted)`}; font-size: 12px; font-weight: ${t.settings.defaultMode===`solo`?600:400}; cursor: pointer;`),ea(h,t.settings.soloRailHidden)}),V(`input`,a,e=>{P(l,e.target.value,!0)}),Rr(`blur`,a,()=>c.setUserName(B(l))),V(`keydown`,a,e=>{e.key===`Enter`&&e.currentTarget.blur(),e.key===`Escape`&&(P(l,c.userName,!0),e.currentTarget.blur())}),V(`click`,f,()=>t.onUpdate({defaultMode:`tandem`})),V(`click`,p,()=>t.onUpdate({defaultMode:`solo`})),V(`change`,h,e=>t.onUpdate({soloRailHidden:e.target.checked})),U(e,n)},Te=e=>{ij(e,{get open(){return t.open},get settings(){return t.settings},get onUpdate(){return t.onUpdate},get connected(){return i()},get reconnectAttempts(){return a()},notify:b})},Ee=e=>{cj(e,{get open(){return t.open},get settings(){return t.settings},get onUpdate(){return t.onUpdate},get connected(){return i()},get reconnectAttempts(){return a()},notify:b})},De=e=>{xj(e,{get open(){return t.open},get settings(){return t.settings},get onUpdate(){return t.onUpdate},get connected(){return i()},get reconnectAttempts(){return a()},notify:b})},Oe=e=>{JA(e,{get open(){return t.open},get settings(){return t.settings},get onUpdate(){return t.onUpdate},get connected(){return i()},get reconnectAttempts(){return a()},notify:b})},ke=e=>{var n=iN(),r=I(n),i=F(r);K(i,y);var a=L(F(i)),o=F(a);O(a),O(i);var s=L(i,4);Qi(s),q(s,`step`,100);var c=L(s,2),l=F(c),u=F(l);O(l);var d=L(l,2),f=F(d);O(d),O(c),O(r);var p=L(r,2),m=F(p);Qi(m),k(2),O(p);var h=L(p,2),g=F(h);Qi(g),k(2),O(h);var _=L(h,4),v=e=>{var t=Yr();ai(I(t),()=>Ul(()=>import(`./CoworkSettings-B4LapjhG.js`),__vite__mapDeps([4,5])),e=>{U(e,rN())},(e,t)=>{let n=M(()=>B(t).default);var r=Yr();bi(I(r),()=>B(n),(e,t)=>{t(e,{})}),U(e,r)}),U(e,t)},b=M(()=>nh());G(_,e=>{B(b)&&e(v)}),z((e,n,r)=>{W(o,`${e??``}s`),q(s,`min`,500),q(s,`max`,Fa),$i(s,t.settings.selectionDwellMs),W(u,`${n??``}s`),W(f,`${r??``}s`),ea(m,t.settings.selectionToolbar),ea(g,t.settings.marginView)},[()=>(t.settings.selectionDwellMs/1e3).toFixed(1),()=>(500/1e3).toFixed(1),()=>(Fa/1e3).toFixed(1)]),V(`input`,s,e=>t.onUpdate({selectionDwellMs:Number(e.target.value)})),V(`change`,m,e=>t.onUpdate({selectionToolbar:e.target.checked})),V(`change`,g,e=>t.onUpdate({marginView:e.target.checked})),U(e,n)},Ae=e=>{var n=aN();CM(F(n),{get settings(){return t.settings},get onUpdate(){return t.onUpdate},notify:b}),O(n),U(e,n)},je=e=>{var t=dN(),n=I(t),r=F(n),i=F(r,!0);O(r);var a=L(r,2),o=e=>{var t=oN(),n=F(t,!0);O(t),z(()=>W(n,B(m))),U(e,t)};G(a,e=>{B(m)&&e(o)}),O(n);var s=L(n,2),c=F(s);K(c,y);var l=L(c,2),d=e=>{U(e,sN())},f=e=>{var t=lN();fi(t,21,S,e=>e.label,(e,t)=>{var n=cN(),r=I(n),i=F(r,!0);O(r);var a=L(r,2),o=F(a,!0);O(a),z(()=>{W(i,B(t).label),W(o,B(t).value)}),U(e,n)}),O(t),U(e,t)},h=e=>{U(e,uN())};G(l,e=>{u.loading?e(d):u.info?e(f,1):e(h,-1)}),O(s),z(()=>{r.disabled=B(p)||u.loading,K(r,`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: ${B(p)||u.loading?`not-allowed`:`pointer`}; background: var(--tandem-surface-muted); color: var(--tandem-fg); opacity: ${B(p)||u.loading?.6:1};`),W(i,B(p)?`Opening…`:`View Documentation`)}),V(`click`,r,()=>void _()),U(e,t)};G(Ce,e=>{B(h)===`collaboration`?e(we):B(h)===`appearance`?e(Te,1):B(h)===`editor`?e(Ee,2):B(h)===`network`?e(De,3):B(h)===`accessibility`?e(Oe,4):B(h)===`claude-code`?e(ke,5):B(h)===`shortcuts`?e(Ae,6):e(je,-1)}),O(Se),O(xe),O(ge),O(w),da(w,e=>P(o,e),()=>B(o)),z(e=>{ie.disabled=B(d)||u.loading,W(ae,B(d)?`Opening…`:`Changelog`),q(ce,`href`,Sa),q(ue,`data-state`,i()?`connected`:a()>0?`reconnecting`:`disconnected`),W(ye,e)},[()=>x(B(h))]),V(`click`,C,function(...e){t.onClose?.apply(this,e)}),V(`click`,ie,()=>void v()),V(`click`,be,function(...e){t.onClose?.apply(this,e)}),U(e,g)};G(w,e=>{t.open&&e(ee)}),U(e,C),j()}zr([`click`,`input`,`keydown`,`change`]);var mN=qr(`<path></path>`),hN=H(`<span class="badge svelte-nsu1aw"> </span>`),gN=H(`<button type="button" class="action svelte-nsu1aw"> </button>`),_N=H(`<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>`),vN=H(`<div data-testid="toast-container" class="toast-stack svelte-nsu1aw"></div>`);function yN(e,t){A(t,!0);var n=Yr(),r=I(n),i=e=>{var n=vN();fi(n,21,()=>t.toasts,e=>e.id,(e,n)=>{var r=_N(),i=F(r),a=F(i);fi(a,20,()=>Uu[B(n).severity],e=>e,(e,t)=>{var n=mN();z(()=>q(n,`d`,t)),U(e,n)}),O(a),O(i);var o=L(i,2),s=F(o),c=F(s,!0);O(s);var l=L(s,2),u=e=>{var t=hN(),r=F(t);O(t),z(()=>{q(t,`data-testid`,`toast-count-${B(n).id}`),W(r,`×${B(n).count??``}`)}),U(e,t)};G(l,e=>{B(n).count>1&&e(u)});var d=L(l,2),f=e=>{var r=gN(),i=F(r,!0);O(r),z(()=>{q(r,`data-testid`,`toast-action-${B(n).id}`),W(i,B(n).action.label)}),V(`click`,r,()=>{B(n).action?.onClick(),t.onDismiss(B(n).id)}),U(e,r)};G(d,e=>{B(n).action&&e(f)}),O(o);var p=L(o,2);O(r),z(()=>{q(r,`role`,B(n).severity===`info`?`status`:`alert`),q(r,`data-testid`,`toast-${B(n).id}`),Hi(r,1,`toast-card ${B(n).severity??``}`,`svelte-nsu1aw`),W(c,B(n).message),q(p,`data-testid`,`toast-dismiss-${B(n).id}`)}),V(`click`,p,()=>t.onDismiss(B(n).id)),U(e,r)}),O(n),U(e,n)};G(r,e=>{t.toasts.length>0&&e(i)}),U(e,n),j()}zr([`click`]);var bN=H(`<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 xN(e,t){let n=M(()=>t.installing?`Installing…`:`Restart to install`);var r=bN(),i=L(F(r),2),a=F(i);O(i);var o=L(i,2),s=F(o,!0);O(o);var c=L(o,2);O(r),z(()=>{W(a,`Tandem v${t.version??``} is available.`),o.disabled=t.installing,W(s,B(n))}),V(`click`,o,function(...e){t.onInstall?.apply(this,e)}),V(`click`,c,function(...e){t.onDismiss?.apply(this,e)}),U(e,r)}zr([`click`]);var SN=Math.floor,CN=(e,t)=>e<t?e:t,wN=(e,t)=>e>t?e:t,TN=128,EN=127,DN=2**53-1,ON=e=>{let t=unescape(encodeURIComponent(e)),n=t.length,r=new Uint8Array(n);for(let e=0;e<n;e++)r[e]=t.codePointAt(e);return r},kN=typeof TextEncoder<`u`?new TextEncoder:null,AN=kN?e=>kN.encode(e):ON,jN=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});jN&&jN.decode(new Uint8Array).length===1&&(jN=null);var MN=(e,t)=>{let n=e.cbuf.length;e.cpos===n&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(n*2),e.cpos=0),e.cbuf[e.cpos++]=t},NN=(e,t)=>{for(;t>EN;)MN(e,TN|EN&t),t=SN(t/128);MN(e,EN&t)},PN=new Uint8Array(3e4),FN=PN.length/3,IN=kN&&kN.encodeInto?(e,t)=>{if(t.length<FN){let n=kN.encodeInto(t,PN).written||0;NN(e,n);for(let t=0;t<n;t++)MN(e,PN[t])}else RN(e,AN(t))}:(e,t)=>{let n=unescape(encodeURIComponent(t)),r=n.length;NN(e,r);for(let t=0;t<r;t++)MN(e,n.codePointAt(t))},LN=(e,t)=>{let n=e.cbuf.length,r=e.cpos,i=CN(n-r,t.length),a=t.length-i;e.cbuf.set(t.subarray(0,i),r),e.cpos+=i,a>0&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(wN(n*2,a)),e.cbuf.set(t.subarray(i)),e.cpos=a)},RN=(e,t)=>{NN(e,t.byteLength),LN(e,t)},zN=e=>Error(e),BN=zN(`Unexpected end of array`),VN=zN(`Integer out of Range`),HN=(e,t)=>{let n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n},UN=e=>HN(e,GN(e)),WN=e=>e.arr[e.pos++],GN=e=>{let t=0,n=1,r=e.arr.length;for(;e.pos<r;){let r=e.arr[e.pos++];if(t+=(r&EN)*n,n*=128,r<TN)return t;if(t>DN)throw VN}throw BN},KN=jN?e=>jN.decode(UN(e)):e=>{let t=GN(e);if(t===0)return``;{let n=String.fromCodePoint(WN(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(WN(e));else for(;t>0;){let r=t<1e4?t:1e4,i=e.arr.subarray(e.pos,e.pos+r);e.pos+=r,n+=String.fromCodePoint.apply(null,i),t-=r}return decodeURIComponent(escape(n))}},qN;(function(e){e[e.Token=0]=`Token`,e[e.PermissionDenied=1]=`PermissionDenied`,e[e.Authenticated=2]=`Authenticated`})(qN||={});var JN=(e,t)=>{NN(e,qN.Token),IN(e,t)},YN=(e,t,n,r)=>{switch(GN(e)){case qN.Token:t();break;case qN.PermissionDenied:n(KN(e));break;case qN.Authenticated:r(KN(e));break}},XN=e=>Array.from(e.entries()).map(([e,t])=>({clientId:e,...t})),ZN;(function(e){e[e.Connecting=0]=`Connecting`,e[e.Open=1]=`Open`,e[e.Closing=2]=`Closing`,e[e.Closed=3]=`Closed`})(ZN||={});function QN(e){return e||={},{delay:e.delay===void 0?200:e.delay,initialDelay:e.initialDelay===void 0?0:e.initialDelay,minDelay:e.minDelay===void 0?0:e.minDelay,maxDelay:e.maxDelay===void 0?0:e.maxDelay,factor:e.factor===void 0?0:e.factor,maxAttempts:e.maxAttempts===void 0?3:e.maxAttempts,timeout:e.timeout===void 0?0:e.timeout,jitter:e.jitter===!0,initialJitter:e.initialJitter===!0,handleError:e.handleError===void 0?null:e.handleError,handleTimeout:e.handleTimeout===void 0?null:e.handleTimeout,beforeAttempt:e.beforeAttempt===void 0?null:e.beforeAttempt,calculateDelay:e.calculateDelay===void 0?null:e.calculateDelay}}async function $N(e){return new Promise(t=>setTimeout(t,e))}function eP(e,t){let n=t.delay;if(n===0)return 0;if(t.factor&&(n*=t.factor**(e.attemptNum-1),t.maxDelay!==0&&(n=Math.min(n,t.maxDelay))),t.jitter){let e=Math.ceil(t.minDelay);n=Math.floor(Math.random()*(Math.floor(n)-e+1))+e}return Math.round(n)}async function tP(e,t){let n=QN(t);for(let e of[`delay`,`initialDelay`,`minDelay`,`maxDelay`,`maxAttempts`,`timeout`]){let t=n[e];if(!Number.isInteger(t)||t<0)throw Error(`Value for ${e} must be an integer greater than or equal to 0`)}if(n.factor.constructor!==Number||n.factor<0)throw Error(`Value for factor must be a number greater than or equal to 0`);if(n.delay<n.minDelay)throw Error(`delay cannot be less than minDelay (delay: ${n.delay}, minDelay: ${n.minDelay}`);let r={attemptNum:0,attemptsRemaining:n.maxAttempts?n.maxAttempts:-1,aborted:!1,abort(){r.aborted=!0}},i=n.calculateDelay||eP;async function a(){if(n.beforeAttempt&&n.beforeAttempt(r,n),r.aborted){let e=Error(`Attempt aborted`);throw e.code=`ATTEMPT_ABORTED`,e}let t=async e=>{if(n.handleError&&await n.handleError(e,r,n),r.aborted||r.attemptsRemaining===0)throw e;r.attemptNum++;let t=i(r,n);return t&&await $N(t),a()};return r.attemptsRemaining>0&&r.attemptsRemaining--,n.timeout?new Promise((i,a)=>{let o=setTimeout(()=>{if(n.handleTimeout)try{i(n.handleTimeout(r,n))}catch(e){a(e)}else{let e=Error(`Retry timeout (attemptNum: ${r.attemptNum}, timeout: ${n.timeout})`);e.code=`ATTEMPT_TIMEOUT`,a(e)}},n.timeout);e(r,n).then(e=>{clearTimeout(o),i(e)}).catch(e=>{clearTimeout(o),t(e).then(i).catch(a)})}):e(r,n).catch(t)}let o=n.calculateDelay?n.calculateDelay(r,n):n.initialDelay;if(o&&await $N(o),r.attemptNum<1&&n.initialJitter){let e=i(r,n);e&&await $N(e)}return a()}var nP=Math.floor,rP=(e,t)=>e<t?e:t,iP=(e,t)=>e>t?e:t,aP=64,oP=128,sP=63,cP=127,lP=2**53-1,uP=()=>new Set,dP=Array.from,fP=e=>{let t=unescape(encodeURIComponent(e)),n=t.length,r=new Uint8Array(n);for(let e=0;e<n;e++)r[e]=t.codePointAt(e);return r},pP=typeof TextEncoder<`u`?new TextEncoder:null,mP=pP?e=>pP.encode(e):fP,hP=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});hP&&hP.decode(new Uint8Array).length===1&&(hP=null);var gP=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}},_P=()=>new gP,vP=e=>{let t=e.cpos;for(let n=0;n<e.bufs.length;n++)t+=e.bufs[n].length;return t},yP=e=>{let t=new Uint8Array(vP(e)),n=0;for(let r=0;r<e.bufs.length;r++){let i=e.bufs[r];t.set(i,n),n+=i.length}return t.set(new Uint8Array(e.cbuf.buffer,0,e.cpos),n),t},bP=(e,t)=>{let n=e.cbuf.length;e.cpos===n&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(n*2),e.cpos=0),e.cbuf[e.cpos++]=t},xP=(e,t)=>{for(;t>cP;)bP(e,oP|cP&t),t=nP(t/128);bP(e,cP&t)},SP=new Uint8Array(3e4),CP=SP.length/3,wP=pP&&pP.encodeInto?(e,t)=>{if(t.length<CP){let n=pP.encodeInto(t,SP).written||0;xP(e,n);for(let t=0;t<n;t++)bP(e,SP[t])}else EP(e,mP(t))}:(e,t)=>{let n=unescape(encodeURIComponent(t)),r=n.length;xP(e,r);for(let t=0;t<r;t++)bP(e,n.codePointAt(t))},TP=(e,t)=>{let n=e.cbuf.length,r=e.cpos,i=rP(n-r,t.length),a=t.length-i;e.cbuf.set(t.subarray(0,i),r),e.cpos+=i,a>0&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(iP(n*2,a)),e.cbuf.set(t.subarray(i)),e.cpos=a)},EP=(e,t)=>{xP(e,t.byteLength),TP(e,t)},DP=e=>Error(e),OP=DP(`Unexpected end of array`),kP=DP(`Integer out of Range`),AP=class{constructor(e){this.arr=e,this.pos=0}},jP=e=>new AP(e),MP=(e,t)=>{let n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n},NP=e=>MP(e,FP(e)),PP=e=>e.arr[e.pos++],FP=e=>{let t=0,n=1,r=e.arr.length;for(;e.pos<r;){let r=e.arr[e.pos++];if(t+=(r&cP)*n,n*=128,r<oP)return t;if(t>lP)throw kP}throw OP},IP=e=>{let t=e.arr[e.pos++],n=t&sP,r=64,i=(t&aP)>0?-1:1;if((t&oP)===0)return i*n;let a=e.arr.length;for(;e.pos<a;){if(t=e.arr[e.pos++],n+=(t&cP)*r,r*=128,t<oP)return i*n;if(n>lP)throw kP}throw OP},LP=hP?e=>hP.decode(NP(e)):e=>{let t=FP(e);if(t===0)return``;{let n=String.fromCodePoint(PP(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(PP(e));else for(;t>0;){let r=t<1e4?t:1e4,i=e.arr.subarray(e.pos,e.pos+r);e.pos+=r,n+=String.fromCodePoint.apply(null,i),t-=r}return decodeURIComponent(escape(n))}},RP=e=>{let t=e.pos,n=LP(e);return e.pos=t,n},zP=Date.now,BP=()=>new Map,VP=(e,t,n)=>{let r=e.get(t);return r===void 0&&e.set(t,r=n()),r},HP=class{constructor(){this._observers=BP()}on(e,t){VP(this._observers,e,uP).add(t)}once(e,t){let n=(...r)=>{this.off(e,n),t(...r)};this.on(e,n)}off(e,t){let n=this._observers.get(e);n!==void 0&&(n.delete(t),n.size===0&&this._observers.delete(e))}emit(e,t){return dP((this._observers.get(e)||BP()).values()).forEach(e=>e(...t))}destroy(){this._observers=BP()}},UP=Object.keys,WP=e=>UP(e).length,GP=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),KP=(e,t)=>e===t,qP=(e,t)=>{if(e==null||t==null)return KP(e,t);if(e.constructor!==t.constructor)return!1;if(e===t)return!0;switch(e.constructor){case ArrayBuffer:e=new Uint8Array(e),t=new Uint8Array(t);case Uint8Array:if(e.byteLength!==t.byteLength)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;break;case Set:if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;break;case Map:if(e.size!==t.size)return!1;for(let n of e.keys())if(!t.has(n)||!qP(e.get(n),t.get(n)))return!1;break;case Object:if(WP(e)!==WP(t))return!1;for(let n in e)if(!GP(e,n)||!qP(e[n],t[n]))return!1;break;case Array:if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!qP(e[n],t[n]))return!1;break;default:return!1}return!0},JP=3e4,YP=class extends HP{constructor(e){super(),this.doc=e,this.clientID=e.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval(()=>{let e=zP();this.getLocalState()!==null&&JP/2<=e-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());let t=[];this.meta.forEach((n,r)=>{r!==this.clientID&&JP<=e-n.lastUpdated&&this.states.has(r)&&t.push(r)}),t.length>0&&XP(this,t,`timeout`)},nP(JP/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){let t=this.clientID,n=this.meta.get(t),r=n===void 0?0:n.clock+1,i=this.states.get(t);e===null?this.states.delete(t):this.states.set(t,e),this.meta.set(t,{clock:r,lastUpdated:zP()});let a=[],o=[],s=[],c=[];e===null?c.push(t):i==null?e!=null&&a.push(t):(o.push(t),qP(i,e)||s.push(t)),(a.length>0||s.length>0||c.length>0)&&this.emit(`change`,[{added:a,updated:s,removed:c},`local`]),this.emit(`update`,[{added:a,updated:o,removed:c},`local`])}setLocalStateField(e,t){let n=this.getLocalState();n!==null&&this.setLocalState({...n,[e]:t})}getStates(){return this.states}},XP=(e,t,n)=>{let r=[];for(let n=0;n<t.length;n++){let i=t[n];if(e.states.has(i)){if(e.states.delete(i),i===e.clientID){let t=e.meta.get(i);e.meta.set(i,{clock:t.clock+1,lastUpdated:zP()})}r.push(i)}}r.length>0&&(e.emit(`change`,[{added:[],updated:[],removed:r},n]),e.emit(`update`,[{added:[],updated:[],removed:r},n]))},ZP=(e,t,n=e.states)=>{let r=t.length,i=_P();xP(i,r);for(let a=0;a<r;a++){let r=t[a],o=n.get(r)||null,s=e.meta.get(r).clock;xP(i,r),xP(i,s),wP(i,JSON.stringify(o))}return yP(i)},QP=(e,t,n)=>{let r=jP(t),i=zP(),a=[],o=[],s=[],c=[],l=FP(r);for(let t=0;t<l;t++){let t=FP(r),n=FP(r),l=JSON.parse(LP(r)),u=e.meta.get(t),d=e.states.get(t),f=u===void 0?0:u.clock;(f<n||f===n&&l===null&&e.states.has(t))&&(l===null?t===e.clientID&&e.getLocalState()!=null?n++:e.states.delete(t):e.states.set(t,l),e.meta.set(t,{clock:n,lastUpdated:i}),u===void 0&&l!==null?a.push(t):u!==void 0&&l===null?c.push(t):l!==null&&(qP(l,d)||s.push(t),o.push(t)))}(a.length>0||s.length>0||c.length>0)&&e.emit(`change`,[{added:a,updated:s,removed:c},n]),(a.length>0||o.length>0||c.length>0)&&e.emit(`update`,[{added:a,updated:o,removed:c},n])},$P=class{constructor(){this.callbacks={}}on(e,t){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),this}emit(e,...t){let n=this.callbacks[e];return n&&n.forEach(e=>e.apply(this,t)),this}off(e,t){let n=this.callbacks[e];return n&&(t?this.callbacks[e]=n.filter(e=>e!==t):delete this.callbacks[e]),this}removeAllListeners(){this.callbacks={}}},eF=class{constructor(e){this.data=e,this.encoder=_P(),this.decoder=jP(new Uint8Array(this.data))}peekVarString(){return RP(this.decoder)}readVarUint(){return FP(this.decoder)}readVarString(){return LP(this.decoder)}readVarUint8Array(){return NP(this.decoder)}writeVarUint(e){return xP(this.encoder,e)}writeVarString(e){return wP(this.encoder,e)}writeVarUint8Array(e){return EP(this.encoder,e)}length(){return vP(this.encoder)}},tF;(function(e){e[e.Sync=0]=`Sync`,e[e.Awareness=1]=`Awareness`,e[e.Auth=2]=`Auth`,e[e.QueryAwareness=3]=`QueryAwareness`,e[e.Stateless=5]=`Stateless`,e[e.CLOSE=7]=`CLOSE`,e[e.SyncStatus=8]=`SyncStatus`})(tF||={});var nF;(function(e){e.Connecting=`connecting`,e.Connected=`connected`,e.Disconnected=`disconnected`})(nF||={});var rF=class{constructor(){this.encoder=_P()}get(e){return e.encoder}toUint8Array(){return yP(this.encoder)}},iF=class extends rF{constructor(){super(...arguments),this.type=tF.CLOSE,this.description=`Ask the server to close the connection`}get(e){return wP(this.encoder,e.documentName),xP(this.encoder,this.type),this.encoder}},aF=class extends $P{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=nF.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=nF.Connected,this.emit(`status`,{status:nF.Connected}),this.cancelWebsocketRetry=void 0,this.receivedOnOpenPayload=e}attach(e){this.configuration.providerMap.set(e.configuration.name,e),this.status===nF.Disconnected&&this.shouldConnect&&this.connect(),this.receivedOnOpenPayload&&this.status===nF.Connected&&e.onOpen(this.receivedOnOpenPayload)}detach(e){this.configuration.providerMap.has(e.configuration.name)&&(e.send(iF,{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===nF.Connected)return;this.cancelWebsocketRetry&&=(this.cancelWebsocketRetry(),void 0),this.receivedOnOpenPayload=void 0,this.shouldConnect=!0;let{retryPromise:e,cancelFunc:t}=(()=>{let e=!1;return{retryPromise:tP(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:t=>{(!this.shouldConnect||e)&&t.abort()}}).catch(e=>{if(e&&e.code!==`ATTEMPT_ABORTED`)throw e}),cancelFunc:()=>{e=!0}}})();return this.cancelWebsocketRetry=t,e}attachWebSocketListeners(e,t){let{identifier:n}=e,r=e=>this.emit(`message`,e),i=e=>this.emit(`close`,{event:e}),a=e=>this.emit(`open`,e),o=e=>{t(e)};this.webSocketHandlers[n]={message:r,close:i,open:a,error:o};let s=this.webSocketHandlers[e.identifier];Object.keys(s).forEach(t=>{e.addEventListener(t,s[t])})}cleanupWebSocket(){if(!this.webSocket)return;let{identifier:e}=this.webSocket,t=this.webSocketHandlers[e];Object.keys(t).forEach(n=>{var r;(r=this.webSocket)==null||r.removeEventListener(n,t[n]),delete this.webSocketHandlers[e]}),this.webSocket.close(),this.webSocket=null}createWebSocketConnection(){return new Promise((e,t)=>{this.webSocket&&(this.messageQueue=[],this.cleanupWebSocket()),this.lastMessageReceived=0,this.identifier+=1;let n=new this.configuration.WebSocketPolyfill(this.url);n.binaryType=`arraybuffer`,n.identifier=this.identifier,this.attachWebSocketListeners(n,t),this.webSocket=n,this.status=nF.Connecting,this.emit(`status`,{status:nF.Connecting}),this.connectionAttempt={resolve:e,reject:t}})}onMessage(e){var t;this.resolveConnectionAttempt(),this.lastMessageReceived=zP();let n=new eF(e.data).peekVarString();(t=this.configuration.providerMap.get(n))==null||t.onMessage(e)}resolveConnectionAttempt(){this.connectionAttempt&&(this.connectionAttempt.resolve(),this.connectionAttempt=null,this.status=nF.Connected,this.emit(`status`,{status:nF.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.reject(),this.connectionAttempt=null}checkConnection(){var e;this.status===nF.Connected&&this.lastMessageReceived&&(this.configuration.messageReconnectTimeout>=zP()-this.lastMessageReceived||(this.closeTries+=1,this.closeTries>2?(this.onClose({event:{code:4408,reason:`forced`}}),this.closeTries=0):((e=this.webSocket)==null||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){this.webSocket?.readyState===ZN.Open?this.webSocket.send(e):this.messageQueue.push(e)}onClose({event:e}){this.closeTries=0,this.cleanupWebSocket(),this.connectionAttempt&&this.rejectConnectionAttempt(),this.status=nF.Disconnected,this.emit(`status`,{status:nF.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()}},oF=0,sF=1,cF=2,lF=(e,t)=>{xP(e,oF),EP(e,cw(t))},uF=(e,t,n)=>{xP(e,sF),EP(e,nw(t,n))},dF=(e,t,n)=>uF(t,n,NP(e)),fF=(e,t,n)=>{try{$C(t,NP(e),n)}catch(e){console.error(`Caught error while handling a Yjs update`,e)}},pF=(e,t)=>{xP(e,cF),EP(e,t)},mF=fF,hF=(e,t,n,r)=>{let i=FP(e);switch(i){case oF:dF(e,t,n);break;case sF:fF(e,n,r);break;case cF:mF(e,n,r);break;default:throw Error(`Unknown message type`)}return i},gF=class{constructor(e){this.message=e}apply(e,t){let{message:n}=this,r=n.readVarUint(),i=n.length();switch(r){case tF.Sync:this.applySyncMessage(e,t);break;case tF.Awareness:this.applyAwarenessMessage(e);break;case tF.Auth:this.applyAuthMessage(e);break;case tF.QueryAwareness:this.applyQueryAwarenessMessage(e);break;case tF.Stateless:e.receiveStateless(LP(n.decoder));break;case tF.SyncStatus:this.applySyncStatusMessage(e,IP(n.decoder)===1);break;case tF.CLOSE:let i={code:1e3,reason:LP(n.decoder),target:e.configuration.websocketProvider.webSocket,type:`close`};e.onClose(),e.configuration.onClose({event:i}),e.forwardClose({event:i});break;default:throw Error(`Can’t apply message of unknown type: ${r}`)}n.length()>i+1&&e.send(rF,{encoder:n.encoder})}applySyncMessage(e,t){let{message:n}=this;n.writeVarUint(tF.Sync);let r=hF(n.decoder,n.encoder,e.document,e);t&&r===sF&&(e.synced=!0)}applySyncStatusMessage(e,t){t&&e.decrementUnsyncedChanges()}applyAwarenessMessage(e){if(!e.awareness)return;let{message:t}=this;QP(e.awareness,t.readVarUint8Array(),e)}applyAuthMessage(e){let{message:t}=this;YN(t.decoder,e.sendToken.bind(e),e.permissionDeniedHandler.bind(e),e.authenticatedHandler.bind(e))}applyQueryAwarenessMessage(e){if(!e.awareness)return;let{message:t}=this;t.writeVarUint(tF.Awareness),t.writeVarUint8Array(ZP(e.awareness,Array.from(e.awareness.getStates().keys())))}},_F=class{constructor(e,t={}){this.message=new e,this.encoder=this.message.get(t)}create(){return yP(this.encoder)}send(e){e?.send(this.create())}},vF=class extends rF{constructor(){super(...arguments),this.type=tF.Auth,this.description=`Authentication`}get(e){if(e.token===void 0)throw Error("The authentication message requires `token` as an argument.");return wP(this.encoder,e.documentName),xP(this.encoder,this.type),JN(this.encoder,e.token),this.encoder}},yF=class extends rF{constructor(){super(...arguments),this.type=tF.Awareness,this.description=`Awareness states update`}get(e){if(e.awareness===void 0)throw Error(`The awareness message requires awareness as an argument`);if(e.clients===void 0)throw Error(`The awareness message requires clients as an argument`);wP(this.encoder,e.documentName),xP(this.encoder,this.type);let t;return t=e.states===void 0?ZP(e.awareness,e.clients):ZP(e.awareness,e.clients,e.states),EP(this.encoder,t),this.encoder}},bF=class extends rF{constructor(){super(...arguments),this.type=tF.Stateless,this.description=`A stateless message`}get(e){return wP(this.encoder,e.documentName),xP(this.encoder,this.type),wP(this.encoder,e.payload??``),this.encoder}},xF=class extends rF{constructor(){super(...arguments),this.type=tF.Sync,this.description=`First sync step`}get(e){if(e.document===void 0)throw Error(`The sync step one message requires document as an argument`);return wP(this.encoder,e.documentName),xP(this.encoder,this.type),lF(this.encoder,e.document),this.encoder}},SF=class extends rF{constructor(){super(...arguments),this.type=tF.Sync,this.description=`A document update`}get(e){return wP(this.encoder,e.documentName),xP(this.encoder,this.type),pF(this.encoder,e.update),this.encoder}},CF=class extends Error{constructor(){super(...arguments),this.code=1001}},wF=class extends $P{constructor(e){var t,n,r;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=e=>this.emit(`status`,e),this.forwardClose=e=>this.emit(`close`,e),this.forwardDisconnect=e=>this.emit(`disconnect`,e),this.forwardDestroy=()=>this.emit(`destroy`),this.setConfiguration(e),this.configuration.document=e.document?e.document:new LC,this.configuration.awareness=e.awareness===void 0?new YP(this.document):e.awareness,this.on(`open`,this.configuration.onOpen),this.on(`message`,this.configuration.onMessage),this.on(`outgoingMessage`,this.configuration.onOutgoingMessage),this.on(`synced`,this.configuration.onSynced),this.on(`destroy`,this.configuration.onDestroy),this.on(`awarenessUpdate`,this.configuration.onAwarenessUpdate),this.on(`awarenessChange`,this.configuration.onAwarenessChange),this.on(`stateless`,this.configuration.onStateless),this.on(`unsyncedChanges`,this.configuration.onUnsyncedChanges),this.on(`authenticated`,this.configuration.onAuthenticated),this.on(`authenticationFailed`,this.configuration.onAuthenticationFailed),(t=this.awareness)==null||t.on(`update`,()=>{this.emit(`awarenessUpdate`,{states:XN(this.awareness.getStates())})}),(n=this.awareness)==null||n.on(`change`,()=>{this.emit(`awarenessChange`,{states:XN(this.awareness.getStates())})}),this.document.on(`update`,this.boundDocumentUpdateHandler),(r=this.awareness)==null||r.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 aF(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,this.unsyncedChanges===0&&(this.synced=!0),this.emit(`unsyncedChanges`,{number:this.unsyncedChanges})}forceSync(){this.resetUnsyncedChanges(),this.send(xF,{document:this.document,documentName:this.configuration.name})}pageHide(){this.awareness&&XP(this.awareness,[this.document.clientID],`page hide`)}registerEventListeners(){typeof window>`u`||!(`addEventListener`in window)||window.addEventListener(`pagehide`,this.boundPageHide)}sendStateless(e){this.send(bF,{documentName:this.configuration.name,payload:e})}async sendToken(){let e;try{e=await this.getToken()}catch(e){this.permissionDeniedHandler(`Failed to get token during sendToken(): ${e}`);return}this.send(vF,{token:e??``,documentName:this.configuration.name})}documentUpdateHandler(e,t){t!==this&&(this.incrementUnsyncedChanges(),this.send(SF,{update:e,documentName:this.configuration.name}))}awarenessUpdateHandler({added:e,updated:t,removed:n},r){let i=e.concat(t).concat(n);this.send(yF,{awareness:this.awareness,clients:i,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(xF,{document:this.document,documentName:this.configuration.name}),this.awareness&&this.awareness.getLocalState()!==null&&this.send(yF,{awareness:this.awareness,clients:[this.document.clientID],documentName:this.configuration.name})}send(e,t){if(!this._isAttached)return;let n=new _F(e,t);this.emit(`outgoingMessage`,{message:n.message}),n.send(this.configuration.websocketProvider)}onMessage(e){let t=new eF(e.data),n=t.readVarString();t.writeVarString(n),this.emit(`message`,{event:e,message:new eF(e.data)}),new gF(t).apply(this,!0)}onClose(){this.isAuthenticated=!1,this.synced=!1,this.awareness&&XP(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&&(XP(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),!0)}permissionDeniedHandler(e){this.emit(`authenticationFailed`,{reason:e}),this.isAuthenticated=!1}authenticatedHandler(e){this.isAuthenticated=!0,this.authorizedScope=e,this.emit(`authenticated`,{scope:e})}setAwarenessField(e,t){if(!this.awareness)throw new CF(`Cannot set awareness field "${e}" to ${JSON.stringify(t)}. You have disabled Awareness for this provider by explicitly passing awareness: null in the provider configuration.`);this.awareness.setLocalStateField(e,t)}},TF=function(e){for(var t=0;;t++)if(e=e.previousSibling,!e)return t},EF=function(e){let t=e.assignedSlot||e.parentNode;return t&&t.nodeType==11?t.host:t},DF=null,OF=function(e,t,n){let r=DF||=document.createRange();return r.setEnd(e,n??e.nodeValue.length),r.setStart(e,t||0),r},kF=function(){DF=null},AF=function(e,t,n,r){return n&&(MF(e,t,n,r,-1)||MF(e,t,n,r,1))},jF=/^(img|br|input|textarea|hr)$/i;function MF(e,t,n,r,i){for(;;){if(e==n&&t==r)return!0;if(t==(i<0?0:NF(e))){let n=e.parentNode;if(!n||n.nodeType!=1||LF(e)||jF.test(e.nodeName)||e.contentEditable==`false`)return!1;t=TF(e)+(i<0?0:1),e=n}else if(e.nodeType==1){let n=e.childNodes[t+(i<0?-1:0)];if(n.nodeType==1&&n.contentEditable==`false`)if(n.pmViewDesc?.ignoreForSelection)t+=i;else return!1;else e=n,t=i<0?NF(e):0}else return!1}}function NF(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function PF(e,t){for(;;){if(e.nodeType==3&&t)return e;if(e.nodeType==1&&t>0){if(e.contentEditable==`false`)return null;e=e.childNodes[t-1],t=NF(e)}else if(e.parentNode&&!LF(e))t=TF(e),e=e.parentNode;else return null}}function FF(e,t){for(;;){if(e.nodeType==3&&t<e.nodeValue.length)return e;if(e.nodeType==1&&t<e.childNodes.length){if(e.contentEditable==`false`)return null;e=e.childNodes[t],t=0}else if(e.parentNode&&!LF(e))t=TF(e)+1,e=e.parentNode;else return null}}function IF(e,t,n){for(let r=t==0,i=t==NF(e);r||i;){if(e==n)return!0;let t=TF(e);if(e=e.parentNode,!e)return!1;r&&=t==0,i&&=t==NF(e)}}function LF(e){let t;for(let n=e;n&&!(t=n.pmViewDesc);n=n.parentNode);return t&&t.node&&t.node.isBlock&&(t.dom==e||t.contentDOM==e)}var RF=function(e){return e.focusNode&&AF(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)};function zF(e,t){let n=document.createEvent(`Event`);return n.initEvent(`keydown`,!0,!0),n.keyCode=e,n.key=n.code=t,n}function BF(e){let t=e.activeElement;for(;t&&t.shadowRoot;)t=t.shadowRoot.activeElement;return t}function VF(e,t,n){if(e.caretPositionFromPoint)try{let r=e.caretPositionFromPoint(t,n);if(r)return{node:r.offsetNode,offset:Math.min(NF(r.offsetNode),r.offset)}}catch{}if(e.caretRangeFromPoint){let r=e.caretRangeFromPoint(t,n);if(r)return{node:r.startContainer,offset:Math.min(NF(r.startContainer),r.startOffset)}}}var HF=typeof navigator<`u`?navigator:null,UF=typeof document<`u`?document:null,WF=HF&&HF.userAgent||``,GF=/Edge\/(\d+)/.exec(WF),KF=/MSIE \d/.exec(WF),qF=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(WF),JF=!!(KF||qF||GF),YF=KF?document.documentMode:qF?+qF[1]:GF?+GF[1]:0,XF=!JF&&/gecko\/(\d+)/i.test(WF);XF&&+(/Firefox\/(\d+)/.exec(WF)||[0,0])[1];var ZF=!JF&&/Chrome\/(\d+)/.exec(WF),QF=!!ZF,$F=ZF?+ZF[1]:0,eI=!JF&&!!HF&&/Apple Computer/.test(HF.vendor),tI=eI&&(/Mobile\/\w+/.test(WF)||!!HF&&HF.maxTouchPoints>2),nI=tI||(HF?/Mac/.test(HF.platform):!1),rI=HF?/Win/.test(HF.platform):!1,iI=/Android \d/.test(WF),aI=!!UF&&`webkitFontSmoothing`in UF.documentElement.style,oI=aI?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function sI(e){let t=e.defaultView&&e.defaultView.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.documentElement.clientWidth,top:0,bottom:e.documentElement.clientHeight}}function cI(e,t){return typeof e==`number`?e:e[t]}function lI(e){let t=e.getBoundingClientRect(),n=t.width/e.offsetWidth||1,r=t.height/e.offsetHeight||1;return{left:t.left,right:t.left+e.clientWidth*n,top:t.top,bottom:t.top+e.clientHeight*r}}function uI(e,t,n){let r=e.someProp(`scrollThreshold`)||0,i=e.someProp(`scrollMargin`)||5,a=e.dom.ownerDocument;for(let o=n||e.dom;o;){if(o.nodeType!=1){o=EF(o);continue}let e=o,n=e==a.body,s=n?sI(a):lI(e),c=0,l=0;if(t.top<s.top+cI(r,`top`)?l=-(s.top-t.top+cI(i,`top`)):t.bottom>s.bottom-cI(r,`bottom`)&&(l=t.bottom-t.top>s.bottom-s.top?t.top+cI(i,`top`)-s.top:t.bottom-s.bottom+cI(i,`bottom`)),t.left<s.left+cI(r,`left`)?c=-(s.left-t.left+cI(i,`left`)):t.right>s.right-cI(r,`right`)&&(c=t.right-s.right+cI(i,`right`)),c||l)if(n)a.defaultView.scrollBy(c,l);else{let n=e.scrollLeft,r=e.scrollTop;l&&(e.scrollTop+=l),c&&(e.scrollLeft+=c);let i=e.scrollLeft-n,a=e.scrollTop-r;t={left:t.left-i,top:t.top-a,right:t.right-i,bottom:t.bottom-a}}let u=n?`fixed`:getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(u))break;o=u==`absolute`?o.offsetParent:EF(o)}}function dI(e){let t=e.dom.getBoundingClientRect(),n=Math.max(0,t.top),r,i;for(let a=(t.left+t.right)/2,o=n+1;o<Math.min(innerHeight,t.bottom);o+=5){let t=e.root.elementFromPoint(a,o);if(!t||t==e.dom||!e.dom.contains(t))continue;let s=t.getBoundingClientRect();if(s.top>=n-20){r=t,i=s.top;break}}return{refDOM:r,refTop:i,stack:fI(e.dom)}}function fI(e){let t=[],n=e.ownerDocument;for(let r=e;r&&(t.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),e!=n);r=EF(r));return t}function pI({refDOM:e,refTop:t,stack:n}){let r=e?e.getBoundingClientRect().top:0;mI(n,r==0?0:r-t)}function mI(e,t){for(let n=0;n<e.length;n++){let{dom:r,top:i,left:a}=e[n];r.scrollTop!=i+t&&(r.scrollTop=i+t),r.scrollLeft!=a&&(r.scrollLeft=a)}}var hI=null;function gI(e){if(e.setActive)return e.setActive();if(hI)return e.focus(hI);let t=fI(e);e.focus(hI==null?{get preventScroll(){return hI={preventScroll:!0},!0}}:void 0),hI||(hI=!1,mI(t,0))}function _I(e,t){let n,r=2e8,i,a=0,o=t.top,s=t.top,c,l;for(let u=e.firstChild,d=0;u;u=u.nextSibling,d++){let e;if(u.nodeType==1)e=u.getClientRects();else if(u.nodeType==3)e=OF(u).getClientRects();else continue;for(let f=0;f<e.length;f++){let p=e[f];if(p.top<=o&&p.bottom>=s){o=Math.max(p.bottom,o),s=Math.min(p.top,s);let e=p.left>t.left?p.left-t.left:p.right<t.left?t.left-p.right:0;if(e<r){n=u,r=e,i=e&&n.nodeType==3?{left:p.right<t.left?p.right:p.left,top:t.top}:t,u.nodeType==1&&e&&(a=d+ +(t.left>=(p.left+p.right)/2));continue}}else p.top>t.top&&!c&&p.left<=t.left&&p.right>=t.left&&(c=u,l={left:Math.max(p.left,Math.min(p.right,t.left)),top:p.top});!n&&(t.left>=p.right&&t.top>=p.top||t.left>=p.left&&t.top>=p.bottom)&&(a=d+1)}}return!n&&c&&(n=c,i=l,r=0),n&&n.nodeType==3?vI(n,i):!n||r&&n.nodeType==1?{node:e,offset:a}:_I(n,i)}function vI(e,t){let n=e.nodeValue.length,r=document.createRange(),i;for(let a=0;a<n;a++){r.setEnd(e,a+1),r.setStart(e,a);let n=EI(r,1);if(n.top!=n.bottom&&yI(t,n)){i={node:e,offset:a+ +(t.left>=(n.left+n.right)/2)};break}}return r.detach(),i||{node:e,offset:0}}function yI(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function bI(e,t){let n=e.parentNode;return n&&/^li$/i.test(n.nodeName)&&t.left<e.getBoundingClientRect().left?n:e}function xI(e,t,n){let{node:r,offset:i}=_I(t,n),a=-1;if(r.nodeType==1&&!r.firstChild){let e=r.getBoundingClientRect();a=e.left!=e.right&&n.left>(e.left+e.right)/2?1:-1}return e.docView.posFromDOM(r,i,a)}function SI(e,t,n,r){let i=-1;for(let n=t,a=!1;n!=e.dom;){let t=e.docView.nearestDesc(n,!0),o;if(!t)return null;if(t.dom.nodeType==1&&(t.node.isBlock&&t.parent||!t.contentDOM)&&((o=t.dom.getBoundingClientRect()).width||o.height)&&(t.node.isBlock&&t.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(t.dom.nodeName)&&(!a&&o.left>r.left||o.top>r.top?i=t.posBefore:(!a&&o.right<r.left||o.bottom<r.top)&&(i=t.posAfter),a=!0),!t.contentDOM&&i<0&&!t.node.isText))return(t.node.isBlock?r.top<(o.top+o.bottom)/2:r.left<(o.left+o.right)/2)?t.posBefore:t.posAfter;n=t.dom.parentNode}return i>-1?i:e.docView.posFromDOM(t,n,-1)}function CI(e,t,n){let r=e.childNodes.length;if(r&&n.top<n.bottom)for(let i=Math.max(0,Math.min(r-1,Math.floor(r*(t.top-n.top)/(n.bottom-n.top))-2)),a=i;;){let n=e.childNodes[a];if(n.nodeType==1){let e=n.getClientRects();for(let r=0;r<e.length;r++){let i=e[r];if(yI(t,i))return CI(n,t,i)}}if((a=(a+1)%r)==i)break}return e}function wI(e,t){let n=e.dom.ownerDocument,r,i=0,a=VF(n,t.left,t.top);a&&({node:r,offset:i}=a);let o=(e.root.elementFromPoint?e.root:n).elementFromPoint(t.left,t.top),s;if(!o||!e.dom.contains(o.nodeType==1?o:o.parentNode)){let n=e.dom.getBoundingClientRect();if(!yI(t,n)||(o=CI(e.dom,t,n),!o))return null}if(eI)for(let e=o;r&&e;e=EF(e))e.draggable&&(r=void 0);if(o=bI(o,t),r){if(XF&&r.nodeType==1&&(i=Math.min(i,r.childNodes.length),i<r.childNodes.length)){let e=r.childNodes[i],n;e.nodeName==`IMG`&&(n=e.getBoundingClientRect()).right<=t.left&&n.bottom>t.top&&i++}let n;aI&&i&&r.nodeType==1&&(n=r.childNodes[i-1]).nodeType==1&&n.contentEditable==`false`&&n.getBoundingClientRect().top>=t.top&&i--,r==e.dom&&i==r.childNodes.length-1&&r.lastChild.nodeType==1&&t.top>r.lastChild.getBoundingClientRect().bottom?s=e.state.doc.content.size:(i==0||r.nodeType!=1||r.childNodes[i-1].nodeName!=`BR`)&&(s=SI(e,r,i,t))}s??=xI(e,o,t);let c=e.docView.nearestDesc(o,!0);return{pos:s,inside:c?c.posAtStart-c.border:-1}}function TI(e){return e.top<e.bottom||e.left<e.right}function EI(e,t){let n=e.getClientRects();if(n.length){let e=n[t<0?0:n.length-1];if(TI(e))return e}return Array.prototype.find.call(n,TI)||e.getBoundingClientRect()}var DI=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function OI(e,t,n){let{node:r,offset:i,atom:a}=e.docView.domFromPos(t,n<0?-1:1),o=aI||XF;if(r.nodeType==3)if(o&&(DI.test(r.nodeValue)||(n<0?!i:i==r.nodeValue.length))){let e=EI(OF(r,i,i),n);if(XF&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let t=EI(OF(r,i-1,i-1),-1);if(t.top==e.top){let n=EI(OF(r,i,i+1),-1);if(n.top!=e.top)return kI(n,n.left<t.left)}}return e}else{let e=i,t=i,a=n<0?1:-1;return n<0&&!i?(t++,a=-1):n>=0&&i==r.nodeValue.length?(e--,a=1):n<0?e--:t++,kI(EI(OF(r,e,t),a),a<0)}if(!e.state.doc.resolve(t-(a||0)).parent.inlineContent){if(a==null&&i&&(n<0||i==NF(r))){let e=r.childNodes[i-1];if(e.nodeType==1)return AI(e.getBoundingClientRect(),!1)}if(a==null&&i<NF(r)){let e=r.childNodes[i];if(e.nodeType==1)return AI(e.getBoundingClientRect(),!0)}return AI(r.getBoundingClientRect(),n>=0)}if(a==null&&i&&(n<0||i==NF(r))){let e=r.childNodes[i-1],t=e.nodeType==3?OF(e,NF(e)-+!o):e.nodeType==1&&(e.nodeName!=`BR`||!e.nextSibling)?e:null;if(t)return kI(EI(t,1),!1)}if(a==null&&i<NF(r)){let e=r.childNodes[i];for(;e.pmViewDesc&&e.pmViewDesc.ignoreForCoords;)e=e.nextSibling;let t=e?e.nodeType==3?OF(e,0,+!o):e.nodeType==1?e:null:null;if(t)return kI(EI(t,-1),!0)}return kI(EI(r.nodeType==3?OF(r):r,-n),n>=0)}function kI(e,t){if(e.width==0)return e;let n=t?e.left:e.right;return{top:e.top,bottom:e.bottom,left:n,right:n}}function AI(e,t){if(e.height==0)return e;let n=t?e.top:e.bottom;return{top:n,bottom:n,left:e.left,right:e.right}}function jI(e,t,n){let r=e.state,i=e.root.activeElement;r!=t&&e.updateState(t),i!=e.dom&&e.focus();try{return n()}finally{r!=t&&e.updateState(r),i!=e.dom&&i&&i.focus()}}function MI(e,t,n){let r=t.selection,i=n==`up`?r.$from:r.$to;return jI(e,t,()=>{let{node:t}=e.docView.domFromPos(i.pos,n==`up`?-1:1);for(;;){let n=e.docView.nearestDesc(t,!0);if(!n)break;if(n.node.isBlock){t=n.contentDOM||n.dom;break}t=n.dom.parentNode}let r=OI(e,i.pos,1);for(let e=t.firstChild;e;e=e.nextSibling){let t;if(e.nodeType==1)t=e.getClientRects();else if(e.nodeType==3)t=OF(e,0,e.nodeValue.length).getClientRects();else continue;for(let e=0;e<t.length;e++){let i=t[e];if(i.bottom>i.top+1&&(n==`up`?r.top-i.top>(i.bottom-r.top)*2:i.bottom-r.bottom>(r.bottom-i.top)*2))return!1}}return!0})}var NI=/[\u0590-\u08ac]/;function PI(e,t,n){let{$head:r}=t.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,a=!i,o=i==r.parent.content.size,s=e.domSelection();return s?!NI.test(r.parent.textContent)||!s.modify?n==`left`||n==`backward`?a:o:jI(e,t,()=>{let{focusNode:t,focusOffset:i,anchorNode:a,anchorOffset:o}=e.domSelectionRange(),c=s.caretBidiLevel;s.modify(`move`,n,`character`);let l=r.depth?e.docView.domAfterPos(r.before()):e.dom,{focusNode:u,focusOffset:d}=e.domSelectionRange(),f=u&&!l.contains(u.nodeType==1?u:u.parentNode)||t==u&&i==d;try{s.collapse(a,o),t&&(t!=a||i!=o)&&s.extend&&s.extend(t,i)}catch{}return c!=null&&(s.caretBidiLevel=c),f}):r.pos==r.start()||r.pos==r.end()}var FI=null,II=null,LI=!1;function RI(e,t,n){return FI==t&&II==n?LI:(FI=t,II=n,LI=n==`up`||n==`down`?MI(e,t,n):PI(e,t,n))}var zI=0,BI=1,VI=2,HI=3,UI=class{constructor(e,t,n,r){this.parent=e,this.children=t,this.dom=n,this.contentDOM=r,this.dirty=zI,n.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,n){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,n=this.posAtStart;;t++){let r=this.children[t];if(r==e)return n;n+=r.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,n){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(n<0){let n,r;if(e==this.contentDOM)n=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.previousSibling}for(;n&&!((r=n.pmViewDesc)&&r.parent==this);)n=n.previousSibling;return n?this.posBeforeChild(r)+r.size:this.posAtStart}else{let n,r;if(e==this.contentDOM)n=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.nextSibling}for(;n&&!((r=n.pmViewDesc)&&r.parent==this);)n=n.nextSibling;return n?this.posBeforeChild(r):this.posAtEnd}let r;if(e==this.dom&&this.contentDOM)r=t>TF(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))r=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let t=e;;t=t.parentNode){if(t==this.dom){r=!1;break}if(t.previousSibling)break}if(r==null&&t==e.childNodes.length)for(let t=e;;t=t.parentNode){if(t==this.dom){r=!0;break}if(t.nextSibling)break}}return r??n>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let n=!0,r=e;r;r=r.parentNode){let i=this.getDesc(r),a;if(i&&(!t||i.node))if(n&&(a=i.nodeDOM)&&!(a.nodeType==1?a.contains(e.nodeType==1?e:e.parentNode):a==e))n=!1;else return i}}getDesc(e){let t=e.pmViewDesc;for(let e=t;e;e=e.parent)if(e==this)return t}posFromDOM(e,t,n){for(let r=e;r;r=r.parentNode){let i=this.getDesc(r);if(i)return i.localPosFromDOM(e,t,n)}return-1}descAt(e){for(let t=0,n=0;t<this.children.length;t++){let r=this.children[t],i=n+r.size;if(n==e&&i!=n){for(;!r.border&&r.children.length;)for(let e=0;e<r.children.length;e++){let t=r.children[e];if(t.size){r=t;break}}return r}if(e<i)return r.descAt(e-n-r.border);n=i}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let n=0,r=0;for(let t=0;n<this.children.length;n++){let i=this.children[n],a=t+i.size;if(a>e||i instanceof XI){r=e-t;break}t=a}if(r)return this.children[n].domFromPos(r-this.children[n].border,t);for(let e;n&&!(e=this.children[n-1]).size&&e instanceof WI&&e.side>=0;n--);if(t<=0){let e,r=!0;for(;e=n?this.children[n-1]:null,!(!e||e.dom.parentNode==this.contentDOM);n--,r=!1);return e&&t&&r&&!e.border&&!e.domAtom?e.domFromPos(e.size,t):{node:this.contentDOM,offset:e?TF(e.dom)+1:0}}else{let e,r=!0;for(;e=n<this.children.length?this.children[n]:null,!(!e||e.dom.parentNode==this.contentDOM);n++,r=!1);return e&&r&&!e.border&&!e.domAtom?e.domFromPos(0,t):{node:this.contentDOM,offset:e?TF(e.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,n=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let r=-1,i=-1;for(let a=n,o=0;;o++){let n=this.children[o],s=a+n.size;if(r==-1&&e<=s){let i=a+n.border;if(e>=i&&t<=s-n.border&&n.node&&n.contentDOM&&this.contentDOM.contains(n.contentDOM))return n.parseRange(e,t,i);e=a;for(let t=o;t>0;t--){let n=this.children[t-1];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(1)){r=TF(n.dom)+1;break}e-=n.size}r==-1&&(r=0)}if(r>-1&&(s>t||o==this.children.length-1)){t=s;for(let e=o+1;e<this.children.length;e++){let n=this.children[e];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(-1)){i=TF(n.dom);break}t+=n.size}i==-1&&(i=this.contentDOM.childNodes.length);break}a=s}return{node:this.contentDOM,from:e,to:t,fromOffset:r,toOffset:i}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return t.size==0||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:n}=this.domFromPos(e,0);if(t.nodeType!=1||n==t.childNodes.length)throw RangeError(`No node after pos `+e);return t.childNodes[n]}setSelection(e,t,n,r=!1){let i=Math.min(e,t),a=Math.max(e,t);for(let o=0,s=0;o<this.children.length;o++){let c=this.children[o],l=s+c.size;if(i>s&&a<l)return c.setSelection(e-s-c.border,t-s-c.border,n,r);s=l}let o=this.domFromPos(e,e?-1:1),s=t==e?o:this.domFromPos(t,t?-1:1),c=n.root.getSelection(),l=n.domSelectionRange(),u=!1;if((XF||eI)&&e==t){let{node:e,offset:t}=o;if(e.nodeType==3){if(u=!!(t&&e.nodeValue[t-1]==`
129
+ `),u&&t==e.nodeValue.length)for(let t=e,n;t;t=t.parentNode){if(n=t.nextSibling){n.nodeName==`BR`&&(o=s={node:n.parentNode,offset:TF(n)+1});break}let e=t.pmViewDesc;if(e&&e.node&&e.node.isBlock)break}}else{let n=e.childNodes[t-1];u=n&&(n.nodeName==`BR`||n.contentEditable==`false`)}}if(XF&&l.focusNode&&l.focusNode!=s.node&&l.focusNode.nodeType==1){let e=l.focusNode.childNodes[l.focusOffset];e&&e.contentEditable==`false`&&(r=!0)}if(!(r||u&&eI)&&AF(o.node,o.offset,l.anchorNode,l.anchorOffset)&&AF(s.node,s.offset,l.focusNode,l.focusOffset))return;let d=!1;if((c.extend||e==t)&&!(u&&XF)){c.collapse(o.node,o.offset);try{e!=t&&c.extend(s.node,s.offset),d=!0}catch{}}if(!d){if(e>t){let e=o;o=s,s=e}let n=document.createRange();n.setEnd(s.node,s.offset),n.setStart(o.node,o.offset),c.removeAllRanges(),c.addRange(n)}}ignoreMutation(e){return!this.contentDOM&&e.type!=`selection`}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let n=0,r=0;r<this.children.length;r++){let i=this.children[r],a=n+i.size;if(n==a?e<=a&&t>=n:e<a&&t>n){let r=n+i.border,o=a-i.border;if(e>=r&&t<=o){this.dirty=e==n||t==a?VI:BI,e==r&&t==o&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=HI:i.markDirty(e-r,t-r);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?VI:HI}n=a}this.dirty=VI}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let n=e==1?VI:BI;t.dirty<n&&(t.dirty=n)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}},WI=class extends UI{constructor(e,t,n,r){let i,a=t.type.toDOM;if(typeof a==`function`&&(a=a(n,()=>{if(!i)return r;if(i.parent)return i.parent.posBeforeChild(i)})),!t.type.spec.raw){if(a.nodeType!=1){let e=document.createElement(`span`);e.appendChild(a),a=e}a.contentEditable=`false`,a.classList.add(`ProseMirror-widget`)}super(e,[],a,null),this.widget=t,this.widget=t,i=this}matchesWidget(e){return this.dirty==zI&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!=`selection`||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}},GI=class extends UI{constructor(e,t,n,r){super(e,[],t,null),this.textDOM=n,this.text=r}get size(){return this.text.length}localPosFromDOM(e,t){return e==this.textDOM?this.posAtStart+t:this.posAtStart+(t?this.size:0)}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type===`characterData`&&e.target.nodeValue==e.oldValue}},KI=class e extends UI{constructor(e,t,n,r,i){super(e,[],n,r),this.mark=t,this.spec=i}static create(t,n,r,i){let a=i.nodeViews[n.type.name],o=a&&a(n,i,r);return(!o||!o.dom)&&(o=yf.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new e(t,n,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&HI||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=HI&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=zI){let e=this.parent;for(;!e.node;)e=e.parent;e.dirty<this.dirty&&(e.dirty=this.dirty),this.dirty=zI}}slice(t,n,r){let i=e.create(this.parent,this.mark,!0,r),a=this.children,o=this.size;n<o&&(a=pL(a,n,o,r)),t>0&&(a=pL(a,0,t,r));for(let e=0;e<a.length;e++)a[e].parent=i;return i.children=a,i}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}},qI=class e extends UI{constructor(e,t,n,r,i,a,o,s,c){super(e,[],i,a),this.node=t,this.outerDeco=n,this.innerDeco=r,this.nodeDOM=o}static create(t,n,r,i,a,o){let s=a.nodeViews[n.type.name],c,l=s&&s(n,a,()=>{if(!c)return o;if(c.parent)return c.parent.posBeforeChild(c)},r,i),u=l&&l.dom,d=l&&l.contentDOM;if(n.isText){if(!u)u=document.createTextNode(n.text);else if(u.nodeType!=3)throw RangeError(`Text must be rendered as a DOM text node`)}else if(!u){let e=yf.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs);({dom:u,contentDOM:d}=e)}!d&&!n.isText&&u.nodeName!=`BR`&&(u.hasAttribute(`contenteditable`)||(u.contentEditable=`false`),n.type.spec.draggable&&(u.draggable=!0));let f=u;return u=iL(u,r,n),l?c=new ZI(t,n,r,i,u,d||null,f,l,a,o+1):n.isText?new YI(t,n,r,i,u,f,a):new e(t,n,r,i,u,d||null,f,a,o+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace==`pre`&&(e.preserveWhitespace=`full`),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let t=this.children.length-1;t>=0;t--){let n=this.children[t];if(this.dom.contains(n.dom.parentNode)){e.contentElement=n.dom.parentNode;break}}e.contentElement||(e.getContent=()=>Z.empty)}return e}matchesNode(e,t,n){return this.dirty==zI&&e.eq(this.node)&&aL(t,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return+!this.node.isLeaf}updateChildren(e,t){let n=this.node.inlineContent,r=t,i=e.composing?this.localCompositionInfo(e,t):null,a=i&&i.pos>-1?i:null,o=i&&i.pos<0,s=new sL(this,a&&a.node,e);uL(this.node,this.innerDeco,(t,i,a)=>{t.spec.marks?s.syncToMarks(t.spec.marks,n,e,i):t.type.side>=0&&!a&&s.syncToMarks(i==this.node.childCount?ld.none:this.node.child(i).marks,n,e,i),s.placeWidget(t,e,r)},(t,a,c,l)=>{s.syncToMarks(t.marks,n,e,l);let u;s.findNodeMatch(t,a,c,l)||o&&e.state.selection.from>r&&e.state.selection.to<r+t.nodeSize&&(u=s.findIndexWithChild(i.node))>-1&&s.updateNodeAt(t,a,c,u,e)||s.updateNextNode(t,a,c,e,l,r)||s.addNode(t,a,c,e,r),r+=t.nodeSize}),s.syncToMarks([],n,e,0),this.node.isTextblock&&s.addTextblockHacks(),s.destroyRest(),(s.changed||this.dirty==VI)&&(a&&this.protectLocalComposition(e,a),QI(this.contentDOM,this.children,e),tI&&dL(this.dom))}localCompositionInfo(e,t){let{from:n,to:r}=e.state.selection;if(!(e.state.selection instanceof Wp)||n<t||r>t+this.node.content.size)return null;let i=e.input.compositionNode;if(!i||!this.dom.contains(i.parentNode))return null;if(this.node.inlineContent){let e=i.nodeValue,a=fL(this.node.content,e,n-t,r-t);return a<0?null:{node:i,pos:a,text:e}}else return{node:i,pos:-1,text:``}}protectLocalComposition(e,{node:t,pos:n,text:r}){if(this.getDesc(t))return;let i=t;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&=void 0}let a=new GI(this,i,t,r);e.input.compositionNodes.push(a),this.children=pL(this.children,n,n+r.length,e,a)}update(e,t,n,r){return this.dirty==HI||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,n,r),!0)}updateInner(e,t,n,r){this.updateOuterDeco(t),this.node=e,this.innerDeco=n,this.contentDOM&&this.updateChildren(r,this.posAtStart),this.dirty=zI}updateOuterDeco(e){if(aL(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,n=this.dom;this.dom=nL(this.dom,this.nodeDOM,tL(this.outerDeco,this.node,t),tL(e,this.node,t)),this.dom!=n&&(n.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 JI(e,t,n,r,i){iL(r,t,e);let a=new qI(void 0,e,t,n,r,r,r,i,0);return a.contentDOM&&a.updateChildren(i,0),a}var YI=class e extends qI{constructor(e,t,n,r,i,a,o){super(e,t,n,r,i,null,a,o,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,n,r){return this.dirty==HI||this.dirty!=zI&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=zI||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,r.trackWrites==this.nodeDOM&&(r.trackWrites=null)),this.node=e,this.dirty=zI,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,n){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,n)}ignoreMutation(e){return e.type!=`characterData`&&e.type!=`selection`}slice(t,n,r){let i=this.node.cut(t,n),a=document.createTextNode(i.text);return new e(this.parent,i,this.outerDeco,this.innerDeco,a,a,r)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=HI)}get domAtom(){return!1}isText(e){return this.node.text==e}},XI=class extends UI{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==zI&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName==`IMG`}},ZI=class extends qI{constructor(e,t,n,r,i,a,o,s,c,l){super(e,t,n,r,i,a,o,c,l),this.spec=s}update(e,t,n,r){if(this.dirty==HI)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let i=this.spec.update(e,t,n);return i&&this.updateInner(e,t,n,r),i}else if(!this.contentDOM&&!e.isLeaf)return!1;else return super.update(e,t,n,r)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,n,r){this.spec.setSelection?this.spec.setSelection(e,t,n.root):super.setSelection(e,t,n,r)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}};function QI(e,t,n){let r=e.firstChild,i=!1;for(let a=0;a<t.length;a++){let o=t[a],s=o.dom;if(s.parentNode==e){for(;s!=r;)r=oL(r),i=!0;r=r.nextSibling}else i=!0,e.insertBefore(s,r);if(o instanceof KI){let t=r?r.previousSibling:e.lastChild;QI(o.contentDOM,o.children,n),r=t?t.nextSibling:e.firstChild}}for(;r;)r=oL(r),i=!0;i&&n.trackWrites==e&&(n.trackWrites=null)}var $I=function(e){e&&(this.nodeName=e)};$I.prototype=Object.create(null);var eL=[new $I];function tL(e,t,n){if(e.length==0)return eL;let r=n?eL[0]:new $I,i=[r];for(let a=0;a<e.length;a++){let o=e[a].type.attrs;if(o){o.nodeName&&i.push(r=new $I(o.nodeName));for(let e in o){let a=o[e];a!=null&&(n&&i.length==1&&i.push(r=new $I(t.isInline?`span`:`div`)),e==`class`?r.class=(r.class?r.class+` `:``)+a:e==`style`?r.style=(r.style?r.style+`;`:``)+a:e!=`nodeName`&&(r[e]=a))}}}return i}function nL(e,t,n,r){if(n==eL&&r==eL)return t;let i=t;for(let t=0;t<r.length;t++){let a=r[t],o=n[t];if(t){let t;o&&o.nodeName==a.nodeName&&i!=e&&(t=i.parentNode)&&t.nodeName.toLowerCase()==a.nodeName?i=t:(t=document.createElement(a.nodeName),t.pmIsDeco=!0,t.appendChild(i),o=eL[0],i=t)}rL(i,o||eL[0],a)}return i}function rL(e,t,n){for(let r in t)r!=`class`&&r!=`style`&&r!=`nodeName`&&!(r in n)&&e.removeAttribute(r);for(let r in n)r!=`class`&&r!=`style`&&r!=`nodeName`&&n[r]!=t[r]&&e.setAttribute(r,n[r]);if(t.class!=n.class){let r=t.class?t.class.split(` `).filter(Boolean):[],i=n.class?n.class.split(` `).filter(Boolean):[];for(let t=0;t<r.length;t++)i.indexOf(r[t])==-1&&e.classList.remove(r[t]);for(let t=0;t<i.length;t++)r.indexOf(i[t])==-1&&e.classList.add(i[t]);e.classList.length==0&&e.removeAttribute(`class`)}if(t.style!=n.style){if(t.style){let n=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,r;for(;r=n.exec(t.style);)e.style.removeProperty(r[1])}n.style&&(e.style.cssText+=n.style)}}function iL(e,t,n){return nL(e,e,eL,tL(t,n,e.nodeType!=1))}function aL(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].type.eq(t[n].type))return!1;return!0}function oL(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}var sL=class{constructor(e,t,n){this.lock=t,this.view=n,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=cL(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let n=e;n<t;n++)this.top.children[n].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,n,r){let i=0,a=this.stack.length>>1,o=Math.min(a,e.length);for(;i<o&&(i==a-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&e[i].type.spec.spanning!==!1;)i++;for(;i<a;)this.destroyRest(),this.top.dirty=zI,this.index=this.stack.pop(),this.top=this.stack.pop(),a--;for(;a<e.length;){this.stack.push(this.top,this.index+1);let i=-1,o=this.top.children.length;r<this.preMatch.index&&(o=Math.min(this.index+3,o));for(let t=this.index;t<o;t++){let n=this.top.children[t];if(n.matchesMark(e[a])&&!this.isLocked(n.dom)){i=t;break}}if(i>-1)i>this.index&&(this.changed=!0,this.destroyBetween(this.index,i)),this.top=this.top.children[this.index];else{let r=KI.create(this.top,e[a],t,n);this.top.children.splice(this.index,0,r),this.top=r,this.changed=!0}this.index=0,a++}}findNodeMatch(e,t,n,r){let i=-1,a;if(r>=this.preMatch.index&&(a=this.preMatch.matches[r-this.preMatch.index]).parent==this.top&&a.matchesNode(e,t,n))i=this.top.children.indexOf(a,this.index);else for(let r=this.index,a=Math.min(this.top.children.length,r+5);r<a;r++){let a=this.top.children[r];if(a.matchesNode(e,t,n)&&!this.preMatch.matched.has(a)){i=r;break}}return i<0?!1:(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(e,t,n,r,i){let a=this.top.children[r];return a.dirty==HI&&a.dom==a.contentDOM&&(a.dirty=VI),a.update(e,t,n,i)?(this.destroyBetween(this.index,r),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let t=e.pmViewDesc;if(t){for(let e=this.index;e<this.top.children.length;e++)if(this.top.children[e]==t)return e}return-1}e=t}}updateNextNode(e,t,n,r,i,a){for(let o=this.index;o<this.top.children.length;o++){let s=this.top.children[o];if(s instanceof qI){let c=this.preMatch.matched.get(s);if(c!=null&&c!=i)return!1;let l=s.dom,u,d=this.isLocked(l)&&!(e.isText&&s.node&&s.node.isText&&s.nodeDOM.nodeValue==e.text&&s.dirty!=HI&&aL(t,s.outerDeco));if(!d&&s.update(e,t,n,r))return this.destroyBetween(this.index,o),s.dom!=l&&(this.changed=!0),this.index++,!0;if(!d&&(u=this.recreateWrapper(s,e,t,n,r,a)))return this.destroyBetween(this.index,o),this.top.children[this.index]=u,u.contentDOM&&(u.dirty=VI,u.updateChildren(r,a+1),u.dirty=zI),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,n,r,i,a){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!aL(n,e.outerDeco)||!r.eq(e.innerDeco))return null;let o=qI.create(this.top,t,n,r,i,a);if(o.contentDOM){o.children=e.children,e.children=[];for(let e of o.children)e.parent=o}return e.destroy(),o}addNode(e,t,n,r,i){let a=qI.create(this.top,e,t,n,r,i);a.contentDOM&&a.updateChildren(r,i+1),this.top.children.splice(this.index++,0,a),this.changed=!0}placeWidget(e,t,n){let r=this.index<this.top.children.length?this.top.children[this.index]:null;if(r&&r.matchesWidget(e)&&(e==r.widget||!r.widget.type.toDOM.parentNode))this.index++;else{let r=new WI(this.top,e,t,n);this.top.children.splice(this.index++,0,r),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof KI;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof YI)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((eI||QF)&&e&&e.dom.contentEditable==`false`&&this.addHackNode(`IMG`,t),this.addHackNode(`BR`,this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let n=document.createElement(e);e==`IMG`&&(n.className=`ProseMirror-separator`,n.alt=``),e==`BR`&&(n.className=`ProseMirror-trailingBreak`);let r=new XI(this.top,[],n,null);t==this.top?t.children.splice(this.index++,0,r):t.children.push(r),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}};function cL(e,t){let n=t,r=n.children.length,i=e.childCount,a=new Map,o=[];outer:for(;i>0;){let s;for(;;)if(r){let e=n.children[r-1];if(e instanceof KI)n=e,r=e.children.length;else{s=e,r--;break}}else if(n==t)break outer;else r=n.parent.children.indexOf(n),n=n.parent;let c=s.node;if(c){if(c!=e.child(i-1))break;--i,a.set(s,i),o.push(s)}}return{index:i,matched:a,matches:o.reverse()}}function lL(e,t){return e.type.side-t.type.side}function uL(e,t,n,r){let i=t.locals(e),a=0;if(i.length==0){for(let n=0;n<e.childCount;n++){let o=e.child(n);r(o,i,t.forChild(a,o),n),a+=o.nodeSize}return}let o=0,s=[],c=null;for(let l=0;;){let u,d;for(;o<i.length&&i[o].to==a;){let e=i[o++];e.widget&&(u?(d||=[u]).push(e):u=e)}if(u)if(d){d.sort(lL);for(let e=0;e<d.length;e++)n(d[e],l,!!c)}else n(u,l,!!c);let f,p;if(c)p=-1,f=c,c=null;else if(l<e.childCount)p=l,f=e.child(l++);else break;for(let e=0;e<s.length;e++)s[e].to<=a&&s.splice(e--,1);for(;o<i.length&&i[o].from<=a&&i[o].to>a;)s.push(i[o++]);let m=a+f.nodeSize;if(f.isText){let e=m;o<i.length&&i[o].from<e&&(e=i[o].from);for(let t=0;t<s.length;t++)s[t].to<e&&(e=s[t].to);e<m&&(c=f.cut(e-a),f=f.cut(0,e-a),m=e,p=-1)}else for(;o<i.length&&i[o].to<m;)o++;let h=f.isInline&&!f.isLeaf?s.filter(e=>!e.inline):s.slice();r(f,h,t.forChild(a,f),p),a=m}}function dL(e){if(e.nodeName==`UL`||e.nodeName==`OL`){let t=e.style.cssText;e.style.cssText=t+`; list-style: square !important`,window.getComputedStyle(e).listStyle,e.style.cssText=t}}function fL(e,t,n,r){for(let i=0,a=0;i<e.childCount&&a<=r;){let o=e.child(i++),s=a;if(a+=o.nodeSize,!o.isText)continue;let c=o.text;for(;i<e.childCount;){let t=e.child(i++);if(a+=t.nodeSize,!t.isText)break;c+=t.text}if(a>=n){if(a>=r&&c.slice(r-t.length-s,r-s)==t)return r-t.length;let e=s<r?c.lastIndexOf(t,r-s-1):-1;if(e>=0&&e+t.length+s>=n)return s+e;if(n==r&&c.length>=r+t.length-s&&c.slice(r-s,r-s+t.length)==t)return r}}return-1}function pL(e,t,n,r,i){let a=[];for(let o=0,s=0;o<e.length;o++){let c=e[o],l=s,u=s+=c.size;l>=n||u<=t?a.push(c):(l<t&&a.push(c.slice(0,t-l,r)),i&&=(a.push(i),void 0),u>n&&a.push(c.slice(n-l,c.size,r)))}return a}function mL(e,t=null){let n=e.domSelectionRange(),r=e.state.doc;if(!n.focusNode)return null;let i=e.docView.nearestDesc(n.focusNode),a=i&&i.size==0,o=e.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(o<0)return null;let s=r.resolve(o),c,l;if(RF(n)){for(c=o;i&&!i.node;)i=i.parent;let e=i.node;if(i&&e.isAtom&&Kp.isSelectable(e)&&i.parent&&!(e.isInline&&IF(n.focusNode,n.focusOffset,i.dom))){let e=i.posBefore;l=new Kp(o==e?s:r.resolve(e))}}else{if(n instanceof e.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let t=o,i=o;for(let r=0;r<n.rangeCount;r++){let a=n.getRangeAt(r);t=Math.min(t,e.docView.posFromDOM(a.startContainer,a.startOffset,1)),i=Math.max(i,e.docView.posFromDOM(a.endContainer,a.endOffset,-1))}if(t<0)return null;[c,o]=i==e.state.selection.anchor?[i,t]:[t,i],s=r.resolve(o)}else c=e.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(c<0)return null}let u=r.resolve(c);if(!l){let n=t==`pointer`||e.state.selection.head<s.pos&&!a?1:-1;l=TL(e,u,s,n)}return l}function hL(e){return e.editable?e.hasFocus():DL(e)&&document.activeElement&&document.activeElement.contains(e.dom)}function gL(e,t=!1){let n=e.state.selection;if(CL(e,n),hL(e)){if(!t&&e.input.mouseDown&&e.input.mouseDown.allowDefault&&QF){let t=e.domSelectionRange(),n=e.domObserver.currentSelection;if(t.anchorNode&&n.anchorNode&&AF(t.anchorNode,t.anchorOffset,n.anchorNode,n.anchorOffset)){e.input.mouseDown.delayedSelectionSync=!0,e.domObserver.setCurSelection();return}}if(e.domObserver.disconnectSelection(),e.cursorWrapper)SL(e);else{let{anchor:r,head:i}=n,a,o;_L&&!(n instanceof Wp)&&(n.$from.parent.inlineContent||(a=vL(e,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(o=vL(e,n.to))),e.docView.setSelection(r,i,e,t),_L&&(a&&bL(a),o&&bL(o)),n.visible?e.dom.classList.remove(`ProseMirror-hideselection`):(e.dom.classList.add(`ProseMirror-hideselection`),`onselectionchange`in document&&xL(e))}e.domObserver.setCurSelection(),e.domObserver.connectSelection()}}var _L=eI||QF&&$F<63;function vL(e,t){let{node:n,offset:r}=e.docView.domFromPos(t,0),i=r<n.childNodes.length?n.childNodes[r]:null,a=r?n.childNodes[r-1]:null;if(eI&&i&&i.contentEditable==`false`)return yL(i);if((!i||i.contentEditable==`false`)&&(!a||a.contentEditable==`false`)){if(i)return yL(i);if(a)return yL(a)}}function yL(e){return e.contentEditable=`true`,eI&&e.draggable&&(e.draggable=!1,e.wasDraggable=!0),e}function bL(e){e.contentEditable=`false`,e.wasDraggable&&=(e.draggable=!0,null)}function xL(e){let t=e.dom.ownerDocument;t.removeEventListener(`selectionchange`,e.input.hideSelectionGuard);let n=e.domSelectionRange(),r=n.anchorNode,i=n.anchorOffset;t.addEventListener(`selectionchange`,e.input.hideSelectionGuard=()=>{(n.anchorNode!=r||n.anchorOffset!=i)&&(t.removeEventListener(`selectionchange`,e.input.hideSelectionGuard),setTimeout(()=>{(!hL(e)||e.state.selection.visible)&&e.dom.classList.remove(`ProseMirror-hideselection`)},20))})}function SL(e){let t=e.domSelection();if(!t)return;let n=e.cursorWrapper.dom,r=n.nodeName==`IMG`;r?t.collapse(n.parentNode,TF(n)+1):t.collapse(n,0),!r&&!e.state.selection.visible&&JF&&YF<=11&&(n.disabled=!0,n.disabled=!1)}function CL(e,t){if(t instanceof Kp){let n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&(wL(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else wL(e)}function wL(e){e.lastSelectedViewDesc&&=(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),void 0)}function TL(e,t,n,r){return e.someProp(`createSelectionBetween`,r=>r(e,t,n))||Wp.between(t,n,r)}function EL(e){return e.editable&&!e.hasFocus()?!1:DL(e)}function DL(e){let t=e.domSelectionRange();if(!t.anchorNode)return!1;try{return e.dom.contains(t.anchorNode.nodeType==3?t.anchorNode.parentNode:t.anchorNode)&&(e.editable||e.dom.contains(t.focusNode.nodeType==3?t.focusNode.parentNode:t.focusNode))}catch{return!1}}function OL(e){let t=e.docView.domFromPos(e.state.selection.anchor,0),n=e.domSelectionRange();return AF(t.node,t.offset,n.anchorNode,n.anchorOffset)}function kL(e,t){let{$anchor:n,$head:r}=e.selection,i=t>0?n.max(r):n.min(r),a=i.parent.inlineContent?i.depth?e.doc.resolve(t>0?i.after():i.before()):null:i;return a&&Bp.findFrom(a,t)}function AL(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function jL(e,t,n){let r=e.state.selection;if(r instanceof Wp){if(n.indexOf(`s`)>-1){let{$head:n}=r,i=n.textOffset?null:t<0?n.nodeBefore:n.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let a=e.state.doc.resolve(n.pos+i.nodeSize*(t<0?-1:1));return AL(e,new Wp(r.$anchor,a))}else if(!r.empty)return!1;else if(e.endOfTextblock(t>0?`forward`:`backward`)){let n=kL(e.state,t);return n&&n instanceof Kp?AL(e,n):!1}else if(!(nI&&n.indexOf(`m`)>-1)){let n=r.$head,i=n.textOffset?null:t<0?n.nodeBefore:n.nodeAfter,a;if(!i||i.isText)return!1;let o=t<0?n.pos-i.nodeSize:n.pos;return i.isAtom||(a=e.docView.descAt(o))&&!a.contentDOM?Kp.isSelectable(i)?AL(e,new Kp(t<0?e.state.doc.resolve(n.pos-i.nodeSize):n)):aI?AL(e,new Wp(e.state.doc.resolve(t<0?o:o+i.nodeSize))):!1:!1}}else if(r instanceof Kp&&r.node.isInline)return AL(e,new Wp(t>0?r.$to:r.$from));else{let n=kL(e.state,t);return n?AL(e,n):!1}}function ML(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function NL(e,t){let n=e.pmViewDesc;return n&&n.size==0&&(t<0||e.nextSibling||e.nodeName!=`BR`)}function PL(e,t){return t<0?FL(e):IL(e)}function FL(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let i,a,o=!1;for(XF&&n.nodeType==1&&r<ML(n)&&NL(n.childNodes[r],-1)&&(o=!0);;)if(r>0){if(n.nodeType!=1)break;{let e=n.childNodes[r-1];if(NL(e,-1))i=n,a=--r;else if(e.nodeType==3)n=e,r=n.nodeValue.length;else break}}else if(LL(n))break;else{let t=n.previousSibling;for(;t&&NL(t,-1);)i=n.parentNode,a=TF(t),t=t.previousSibling;if(t)n=t,r=ML(n);else{if(n=n.parentNode,n==e.dom)break;r=0}}o?BL(e,n,r):i&&BL(e,i,a)}function IL(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let i=ML(n),a,o;for(;;)if(r<i){if(n.nodeType!=1)break;let e=n.childNodes[r];if(NL(e,1))a=n,o=++r;else break}else if(LL(n))break;else{let t=n.nextSibling;for(;t&&NL(t,1);)a=t.parentNode,o=TF(t)+1,t=t.nextSibling;if(t)n=t,r=0,i=ML(n);else{if(n=n.parentNode,n==e.dom)break;r=i=0}}a&&BL(e,a,o)}function LL(e){let t=e.pmViewDesc;return t&&t.node&&t.node.isBlock}function RL(e,t){for(;e&&t==e.childNodes.length&&!LF(e);)t=TF(e)+1,e=e.parentNode;for(;e&&t<e.childNodes.length;){let n=e.childNodes[t];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable==`false`)break;e=n,t=0}}function zL(e,t){for(;e&&!t&&!LF(e);)t=TF(e),e=e.parentNode;for(;e&&t;){let n=e.childNodes[t-1];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable==`false`)break;e=n,t=e.childNodes.length}}function BL(e,t,n){if(t.nodeType!=3){let e,r;(r=RL(t,n))?(t=r,n=0):(e=zL(t,n))&&(t=e,n=e.nodeValue.length)}let r=e.domSelection();if(!r)return;if(RF(r)){let e=document.createRange();e.setEnd(t,n),e.setStart(t,n),r.removeAllRanges(),r.addRange(e)}else r.extend&&r.extend(t,n);e.domObserver.setCurSelection();let{state:i}=e;setTimeout(()=>{e.state==i&&gL(e)},50)}function VL(e,t){let n=e.state.doc.resolve(t);if(!(QF||rI)&&n.parent.inlineContent){let r=e.coordsAtPos(t);if(t>n.start()){let n=e.coordsAtPos(t-1),i=(n.top+n.bottom)/2;if(i>r.top&&i<r.bottom&&Math.abs(n.left-r.left)>1)return n.left<r.left?`ltr`:`rtl`}if(t<n.end()){let n=e.coordsAtPos(t+1),i=(n.top+n.bottom)/2;if(i>r.top&&i<r.bottom&&Math.abs(n.left-r.left)>1)return n.left>r.left?`ltr`:`rtl`}}return getComputedStyle(e.dom).direction==`rtl`?`rtl`:`ltr`}function HL(e,t,n){let r=e.state.selection;if(r instanceof Wp&&!r.empty||n.indexOf(`s`)>-1||nI&&n.indexOf(`m`)>-1)return!1;let{$from:i,$to:a}=r;if(!i.parent.inlineContent||e.endOfTextblock(t<0?`up`:`down`)){let n=kL(e.state,t);if(n&&n instanceof Kp)return AL(e,n)}if(!i.parent.inlineContent){let n=t<0?i:a,o=r instanceof Jp?Bp.near(n,t):Bp.findFrom(n,t);return o?AL(e,o):!1}return!1}function UL(e,t){if(!(e.state.selection instanceof Wp))return!0;let{$head:n,$anchor:r,empty:i}=e.state.selection;if(!n.sameParent(r))return!0;if(!i)return!1;if(e.endOfTextblock(t>0?`forward`:`backward`))return!0;let a=!n.textOffset&&(t<0?n.nodeBefore:n.nodeAfter);if(a&&!a.isText){let r=e.state.tr;return t<0?r.delete(n.pos-a.nodeSize,n.pos):r.delete(n.pos,n.pos+a.nodeSize),e.dispatch(r),!0}return!1}function WL(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function GL(e){if(!eI||e.state.selection.$head.parentOffset>0)return!1;let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(t&&t.nodeType==1&&n==0&&t.firstChild&&t.firstChild.contentEditable==`false`){let n=t.firstChild;WL(e,n,`true`),setTimeout(()=>WL(e,n,`false`),20)}return!1}function KL(e){let t=``;return e.ctrlKey&&(t+=`c`),e.metaKey&&(t+=`m`),e.altKey&&(t+=`a`),e.shiftKey&&(t+=`s`),t}function qL(e,t){let n=t.keyCode,r=KL(t);if(n==8||nI&&n==72&&r==`c`)return UL(e,-1)||PL(e,-1);if(n==46&&!t.shiftKey||nI&&n==68&&r==`c`)return UL(e,1)||PL(e,1);if(n==13||n==27)return!0;if(n==37||nI&&n==66&&r==`c`){let t=n==37?VL(e,e.state.selection.from)==`ltr`?-1:1:-1;return jL(e,t,r)||PL(e,t)}else if(n==39||nI&&n==70&&r==`c`){let t=n==39?VL(e,e.state.selection.from)==`ltr`?1:-1:1;return jL(e,t,r)||PL(e,t)}else if(n==38||nI&&n==80&&r==`c`)return HL(e,-1,r)||PL(e,-1);else if(n==40||nI&&n==78&&r==`c`)return GL(e)||HL(e,1,r)||PL(e,1);else if(r==(nI?`m`:`c`)&&(n==66||n==73||n==89||n==90))return!0;return!1}function JL(e,t){e.someProp(`transformCopied`,n=>{t=n(t,e)});let n=[],{content:r,openStart:i,openEnd:a}=t;for(;i>1&&a>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,a--;let e=r.firstChild;n.push(e.type.name,e.attrs==e.type.defaultAttrs?null:e.attrs),r=e.content}let o=e.someProp(`clipboardSerializer`)||yf.fromSchema(e.state.schema),s=aR(),c=s.createElement(`div`);c.appendChild(o.serializeFragment(r,{document:s}));let l=c.firstChild,u,d=0;for(;l&&l.nodeType==1&&(u=rR[l.nodeName.toLowerCase()]);){for(let e=u.length-1;e>=0;e--){let t=s.createElement(u[e]);for(;c.firstChild;)t.appendChild(c.firstChild);c.appendChild(t),d++}l=c.firstChild}return l&&l.nodeType==1&&l.setAttribute(`data-pm-slice`,`${i} ${a}${d?` -${d}`:``} ${JSON.stringify(n)}`),{dom:c,text:e.someProp(`clipboardTextSerializer`,n=>n(t,e))||t.content.textBetween(0,t.content.size,`
130
+
131
+ `),slice:t}}function YL(e,t,n,r,i){let a=i.parent.type.spec.code,o,s;if(!n&&!t)return null;let c=!!t&&(r||a||!n);if(c){if(e.someProp(`transformPastedText`,n=>{t=n(t,a||r,e)}),a)return s=new Q(Z.from(e.state.schema.text(t.replace(/\r\n?/g,`
132
+ `))),0,0),e.someProp(`transformPasted`,t=>{s=t(s,e,!0)}),s;let n=e.someProp(`clipboardTextParser`,n=>n(t,i,r,e));if(n)s=n;else{let n=i.marks(),{schema:r}=e.state,a=yf.fromSchema(r);o=document.createElement(`div`),t.split(/(?:\r\n?|\n)+/).forEach(e=>{let t=o.appendChild(document.createElement(`p`));e&&t.appendChild(a.serializeNode(r.text(e,n)))})}}else e.someProp(`transformPastedHTML`,t=>{n=t(n,e)}),o=cR(n),aI&&lR(o);let l=o&&o.querySelector(`[data-pm-slice]`),u=l&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(l.getAttribute(`data-pm-slice`)||``);if(u&&u[3])for(let e=+u[3];e>0;e--){let e=o.firstChild;for(;e&&e.nodeType!=1;)e=e.nextSibling;if(!e)break;o=e}if(s||=(e.someProp(`clipboardParser`)||e.someProp(`domParser`)||af.fromSchema(e.state.schema)).parseSlice(o,{preserveWhitespace:!!(c||u),context:i,ruleFromNode(e){return e.nodeName==`BR`&&!e.nextSibling&&e.parentNode&&!XL.test(e.parentNode.nodeName)?{ignore:!0}:null}}),u)s=uR(nR(s,+u[1],+u[2]),u[4]);else if(s=Q.maxOpen(ZL(s.content,i),!0),s.openStart||s.openEnd){let e=0,t=0;for(let t=s.content.firstChild;e<s.openStart&&!t.type.spec.isolating;e++,t=t.firstChild);for(let e=s.content.lastChild;t<s.openEnd&&!e.type.spec.isolating;t++,e=e.lastChild);s=nR(s,e,t)}return e.someProp(`transformPasted`,t=>{s=t(s,e,c)}),s}var XL=/^(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 ZL(e,t){if(e.childCount<2)return e;for(let n=t.depth;n>=0;n--){let r=t.node(n).contentMatchAt(t.index(n)),i,a=[];if(e.forEach(e=>{if(!a)return;let t=r.findWrapping(e.type),n;if(!t)return a=null;if(n=a.length&&i.length&&$L(t,i,e,a[a.length-1],0))a[a.length-1]=n;else{a.length&&(a[a.length-1]=eR(a[a.length-1],i.length));let n=QL(e,t);a.push(n),r=r.matchType(n.type),i=t}}),a)return Z.from(a)}return e}function QL(e,t,n=0){for(let r=t.length-1;r>=n;r--)e=t[r].create(null,Z.from(e));return e}function $L(e,t,n,r,i){if(i<e.length&&i<t.length&&e[i]==t[i]){let a=$L(e,t,n,r.lastChild,i+1);if(a)return r.copy(r.content.replaceChild(r.childCount-1,a));if(r.contentMatchAt(r.childCount).matchType(i==e.length-1?n.type:e[i+1]))return r.copy(r.content.append(Z.from(QL(n,e,i+1))))}}function eR(e,t){if(t==0)return e;let n=e.content.replaceChild(e.childCount-1,eR(e.lastChild,t-1)),r=e.contentMatchAt(e.childCount).fillBefore(Z.empty,!0);return e.copy(n.append(r))}function tR(e,t,n,r,i,a){let o=t<0?e.firstChild:e.lastChild,s=o.content;return e.childCount>1&&(a=0),i<r-1&&(s=tR(s,t,n,r,i+1,a)),i>=n&&(s=t<0?o.contentMatchAt(0).fillBefore(s,a<=i).append(s):s.append(o.contentMatchAt(o.childCount).fillBefore(Z.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,o.copy(s))}function nR(e,t,n){return t<e.openStart&&(e=new Q(tR(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),n<e.openEnd&&(e=new Q(tR(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}var rR={thead:[`table`],tbody:[`table`],tfoot:[`table`],caption:[`table`],colgroup:[`table`],col:[`table`,`colgroup`],tr:[`table`,`tbody`],td:[`table`,`tbody`,`tr`],th:[`table`,`tbody`,`tr`]},iR=null;function aR(){return iR||=document.implementation.createHTMLDocument(`title`)}var oR=null;function sR(e){let t=window.trustedTypes;return t?(oR||=t.defaultPolicy||t.createPolicy(`ProseMirrorClipboard`,{createHTML:e=>e}),oR.createHTML(e)):e}function cR(e){let t=/^(\s*<meta [^>]*>)*/.exec(e);t&&(e=e.slice(t[0].length));let n=aR().createElement(`div`),r=/<([a-z][^>\s]+)/i.exec(e),i;if((i=r&&rR[r[1].toLowerCase()])&&(e=i.map(e=>`<`+e+`>`).join(``)+e+i.map(e=>`</`+e+`>`).reverse().join(``)),n.innerHTML=sR(e),i)for(let e=0;e<i.length;e++)n=n.querySelector(i[e])||n;return n}function lR(e){let t=e.querySelectorAll(QF?`span:not([class]):not([style])`:`span.Apple-converted-space`);for(let n=0;n<t.length;n++){let r=t[n];r.childNodes.length==1&&r.textContent==`\xA0`&&r.parentNode&&r.parentNode.replaceChild(e.ownerDocument.createTextNode(` `),r)}}function uR(e,t){if(!e.size)return e;let n=e.content.firstChild.type.schema,r;try{r=JSON.parse(t)}catch{return e}let{content:i,openStart:a,openEnd:o}=e;for(let e=r.length-2;e>=0;e-=2){let t=n.nodes[r[e]];if(!t||t.hasRequiredAttrs())break;i=Z.from(t.create(r[e+1],i)),a++,o++}return new Q(i,a,o)}var dR={},fR={},pR={touchstart:!0,touchmove:!0},mR=class{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 hR(e){for(let t in dR){let n=dR[t];e.dom.addEventListener(t,e.input.eventHandlers[t]=t=>{bR(e,t)&&!yR(e,t)&&(e.editable||!(t.type in fR))&&n(e,t)},pR[t]?{passive:!0}:void 0)}eI&&e.dom.addEventListener(`input`,()=>null),vR(e)}function gR(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function _R(e){e.domObserver.stop();for(let t in e.input.eventHandlers)e.dom.removeEventListener(t,e.input.eventHandlers[t]);clearTimeout(e.input.composingTimeout),clearTimeout(e.input.lastIOSEnterFallbackTimeout)}function vR(e){e.someProp(`handleDOMEvents`,t=>{for(let n in t)e.input.eventHandlers[n]||e.dom.addEventListener(n,e.input.eventHandlers[n]=t=>yR(e,t))})}function yR(e,t){return e.someProp(`handleDOMEvents`,n=>{let r=n[t.type];return r?r(e,t)||t.defaultPrevented:!1})}function bR(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n=t.target;n!=e.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(t))return!1;return!0}function xR(e,t){!yR(e,t)&&dR[t.type]&&(e.editable||!(t.type in fR))&&dR[t.type](e,t)}fR.keydown=(e,t)=>{let n=t;if(e.input.shiftKey=n.keyCode==16||n.shiftKey,!FR(e,n)&&(e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),!(iI&&QF&&n.keyCode==13)))if(n.keyCode!=229&&e.domObserver.forceFlush(),tI&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let t=Date.now();e.input.lastIOSEnter=t,e.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{e.input.lastIOSEnter==t&&(e.someProp(`handleKeyDown`,t=>t(e,zF(13,`Enter`))),e.input.lastIOSEnter=0)},200)}else e.someProp(`handleKeyDown`,t=>t(e,n))||qL(e,n)?n.preventDefault():gR(e,`key`)},fR.keyup=(e,t)=>{t.keyCode==16&&(e.input.shiftKey=!1)},fR.keypress=(e,t)=>{let n=t;if(FR(e,n)||!n.charCode||n.ctrlKey&&!n.altKey||nI&&n.metaKey)return;if(e.someProp(`handleKeyPress`,t=>t(e,n))){n.preventDefault();return}let r=e.state.selection;if(!(r instanceof Wp)||!r.$from.sameParent(r.$to)){let t=String.fromCharCode(n.charCode),i=()=>e.state.tr.insertText(t).scrollIntoView();!/[\r\n]/.test(t)&&!e.someProp(`handleTextInput`,n=>n(e,r.$from.pos,r.$to.pos,t,i))&&e.dispatch(i()),n.preventDefault()}};function SR(e){return{left:e.clientX,top:e.clientY}}function CR(e,t){let n=t.x-e.clientX,r=t.y-e.clientY;return n*n+r*r<100}function wR(e,t,n,r,i){if(r==-1)return!1;let a=e.state.doc.resolve(r);for(let r=a.depth+1;r>0;r--)if(e.someProp(t,t=>r>a.depth?t(e,n,a.nodeAfter,a.before(r),i,!0):t(e,n,a.node(r),a.before(r),i,!1)))return!0;return!1}function TR(e,t,n){if(e.focused||e.focus(),e.state.selection.eq(t))return;let r=e.state.tr.setSelection(t);n==`pointer`&&r.setMeta(`pointer`,!0),e.dispatch(r)}function ER(e,t){if(t==-1)return!1;let n=e.state.doc.resolve(t),r=n.nodeAfter;return r&&r.isAtom&&Kp.isSelectable(r)?(TR(e,new Kp(n),`pointer`),!0):!1}function DR(e,t){if(t==-1)return!1;let n=e.state.selection,r,i;n instanceof Kp&&(r=n.node);let a=e.state.doc.resolve(t);for(let e=a.depth+1;e>0;e--){let t=e>a.depth?a.nodeAfter:a.node(e);if(Kp.isSelectable(t)){i=r&&n.$from.depth>0&&e>=n.$from.depth&&a.before(n.$from.depth+1)==n.$from.pos?a.before(n.$from.depth):a.before(e);break}}return i==null?!1:(TR(e,Kp.create(e.state.doc,i),`pointer`),!0)}function OR(e,t,n,r,i){return wR(e,`handleClickOn`,t,n,r)||e.someProp(`handleClick`,n=>n(e,t,r))||(i?DR(e,n):ER(e,n))}function kR(e,t,n,r){return wR(e,`handleDoubleClickOn`,t,n,r)||e.someProp(`handleDoubleClick`,n=>n(e,t,r))}function AR(e,t,n,r){return wR(e,`handleTripleClickOn`,t,n,r)||e.someProp(`handleTripleClick`,n=>n(e,t,r))||jR(e,n,r)}function jR(e,t,n){if(n.button!=0)return!1;let r=e.state.doc;if(t==-1)return r.inlineContent?(TR(e,Wp.create(r,0,r.content.size),`pointer`),!0):!1;let i=r.resolve(t);for(let t=i.depth+1;t>0;t--){let n=t>i.depth?i.nodeAfter:i.node(t),a=i.before(t);if(n.inlineContent)TR(e,Wp.create(r,a+1,a+1+n.content.size),`pointer`);else if(Kp.isSelectable(n))TR(e,Kp.create(r,a),`pointer`);else continue;return!0}}function MR(e){return HR(e)}var NR=nI?`metaKey`:`ctrlKey`;dR.mousedown=(e,t)=>{let n=t;e.input.shiftKey=n.shiftKey;let r=MR(e),i=Date.now(),a=`singleClick`;i-e.input.lastClick.time<500&&CR(n,e.input.lastClick)&&!n[NR]&&e.input.lastClick.button==n.button&&(e.input.lastClick.type==`singleClick`?a=`doubleClick`:e.input.lastClick.type==`doubleClick`&&(a=`tripleClick`)),e.input.lastClick={time:i,x:n.clientX,y:n.clientY,type:a,button:n.button};let o=e.posAtCoords(SR(n));o&&(a==`singleClick`?(e.input.mouseDown&&e.input.mouseDown.done(),e.input.mouseDown=new PR(e,o,n,!!r)):(a==`doubleClick`?kR:AR)(e,o.pos,o.inside,n)?n.preventDefault():gR(e,`pointer`))};var PR=class{constructor(e,t,n,r){this.view=e,this.pos=t,this.event=n,this.flushed=r,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!n[NR],this.allowDefault=n.shiftKey;let i,a;if(t.inside>-1)i=e.state.doc.nodeAt(t.inside),a=t.inside;else{let n=e.state.doc.resolve(t.pos);i=n.parent,a=n.depth?n.before():0}let o=r?null:n.target,s=o?e.docView.nearestDesc(o,!0):null;this.target=s&&s.nodeDOM.nodeType==1?s.nodeDOM:null;let{selection:c}=e.state;(n.button==0&&i.type.spec.draggable&&i.type.spec.selectable!==!1||c instanceof Kp&&c.from<=a&&c.to>a)&&(this.mightDrag={node:i,pos:a,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&XF&&!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)),gR(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(()=>gL(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(SR(e))),this.updateAllowDefault(e),this.allowDefault||!t?gR(this.view,`pointer`):OR(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||eI&&this.mightDrag&&!this.mightDrag.node.isAtom||QF&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(TR(this.view,Bp.near(this.view.state.doc.resolve(t.pos)),`pointer`),e.preventDefault()):gR(this.view,`pointer`)}move(e){this.updateAllowDefault(e),gR(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=e=>{e.input.lastTouch=Date.now(),MR(e),gR(e,`pointer`)},dR.touchmove=e=>{e.input.lastTouch=Date.now(),gR(e,`pointer`)},dR.contextmenu=e=>MR(e);function FR(e,t){return e.composing?!0:eI&&Math.abs(t.timeStamp-e.input.compositionEndedAt)<500?(e.input.compositionEndedAt=-2e8,!0):!1}var IR=iI?5e3:-1;fR.compositionstart=fR.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,n=t.selection.$to;if(t.selection instanceof Wp&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(e=>e.type.spec.inclusive===!1)||QF&&rI&&LR(e)))e.markCursor=e.state.storedMarks||n.marks(),HR(e,!0),e.markCursor=null;else if(HR(e,!t.selection.empty),XF&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let t=e.domSelectionRange();for(let n=t.focusNode,r=t.focusOffset;n&&n.nodeType==1&&r!=0;){let t=r<0?n.lastChild:n.childNodes[r-1];if(!t)break;if(t.nodeType==3){let n=e.domSelection();n&&n.collapse(t,t.nodeValue.length);break}else n=t,r=-1}}e.input.composing=!0}RR(e,IR)};function LR(e){let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(!t||t.nodeType!=1||n>=t.childNodes.length)return!1;let r=t.childNodes[n];return r.nodeType==1&&r.contentEditable==`false`}fR.compositionend=(e,t)=>{e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=t.timeStamp,e.input.compositionPendingChanges=e.domObserver.pendingRecords().length?e.input.compositionID:0,e.input.compositionNode=null,e.input.badSafariComposition?e.domObserver.forceFlush():e.input.compositionPendingChanges&&Promise.resolve().then(()=>e.domObserver.flush()),e.input.compositionID++,RR(e,20))};function RR(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout(()=>HR(e),t))}function zR(e){for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=VR());e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function BR(e){let t=e.domSelectionRange();if(!t.focusNode)return null;let n=PF(t.focusNode,t.focusOffset),r=FF(t.focusNode,t.focusOffset);if(n&&r&&n!=r){let t=r.pmViewDesc,i=e.domObserver.lastChangedTextNode;if(n==i||r==i)return i;if(!t||!t.isText(r.nodeValue))return r;if(e.input.compositionNode==r){let e=n.pmViewDesc;if(!(!e||!e.isText(n.nodeValue)))return r}}return n||r}function VR(){let e=document.createEvent(`Event`);return e.initEvent(`event`,!0,!0),e.timeStamp}function HR(e,t=!1){if(!(iI&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),zR(e),t||e.docView&&e.docView.dirty){let n=mL(e),r=e.state.selection;return n&&!n.eq(r)?e.dispatch(e.state.tr.setSelection(n)):(e.markCursor||t)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?e.dispatch(e.state.tr.deleteSelection()):e.updateState(e.state),!0}return!1}}function UR(e,t){if(!e.dom.parentNode)return;let n=e.dom.parentNode.appendChild(document.createElement(`div`));n.appendChild(t),n.style.cssText=`position: fixed; left: -10000px; top: 10px`;let r=getSelection(),i=document.createRange();i.selectNodeContents(t),e.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),e.focus()},50)}var WR=JF&&YF<15||tI&&oI<604;dR.copy=fR.cut=(e,t)=>{let n=t,r=e.state.selection,i=n.type==`cut`;if(r.empty)return;let a=WR?null:n.clipboardData,{dom:o,text:s}=JL(e,r.content());a?(n.preventDefault(),a.clearData(),a.setData(`text/html`,o.innerHTML),a.setData(`text/plain`,s)):UR(e,o),i&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta(`uiEvent`,`cut`))};function GR(e){return e.openStart==0&&e.openEnd==0&&e.content.childCount==1?e.content.firstChild:null}function KR(e,t){if(!e.dom.parentNode)return;let n=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,r=e.dom.parentNode.appendChild(document.createElement(n?`textarea`:`div`));n||(r.contentEditable=`true`),r.style.cssText=`position: fixed; left: -10000px; top: 10px`,r.focus();let i=e.input.shiftKey&&e.input.lastKeyCode!=45;setTimeout(()=>{e.focus(),r.parentNode&&r.parentNode.removeChild(r),n?qR(e,r.value,null,i,t):qR(e,r.textContent,r.innerHTML,i,t)},50)}function qR(e,t,n,r,i){let a=YL(e,t,n,r,e.state.selection.$from);if(e.someProp(`handlePaste`,t=>t(e,i,a||Q.empty)))return!0;if(!a)return!1;let o=GR(a),s=o?e.state.tr.replaceSelectionWith(o,r):e.state.tr.replaceSelection(a);return e.dispatch(s.scrollIntoView().setMeta(`paste`,!0).setMeta(`uiEvent`,`paste`)),!0}function JR(e){let t=e.getData(`text/plain`)||e.getData(`Text`);if(t)return t;let n=e.getData(`text/uri-list`);return n?n.replace(/\r?\n/g,` `):``}fR.paste=(e,t)=>{let n=t;if(e.composing&&!iI)return;let r=WR?null:n.clipboardData,i=e.input.shiftKey&&e.input.lastKeyCode!=45;r&&qR(e,JR(r),r.getData(`text/html`),i,n)?n.preventDefault():KR(e,n)};var YR=class{constructor(e,t,n){this.slice=e,this.move=t,this.node=n}},XR=nI?`altKey`:`ctrlKey`;function ZR(e,t){return e.someProp(`dragCopies`,e=>!e(t))??!t[XR]}dR.dragstart=(e,t)=>{let n=t,r=e.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let i=e.state.selection,a=i.empty?null:e.posAtCoords(SR(n)),o;if(!(a&&a.pos>=i.from&&a.pos<=(i instanceof Kp?i.to-1:i.to))){if(r&&r.mightDrag)o=Kp.create(e.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let t=e.docView.nearestDesc(n.target,!0);t&&t.node.type.spec.draggable&&t!=e.docView&&(o=Kp.create(e.state.doc,t.posBefore))}}let{dom:s,text:c,slice:l}=JL(e,(o||e.state.selection).content());(!n.dataTransfer.files.length||!QF||$F>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(WR?`Text`:`text/html`,s.innerHTML),n.dataTransfer.effectAllowed=`copyMove`,WR||n.dataTransfer.setData(`text/plain`,c),e.dragging=new YR(l,ZR(e,n),o)},dR.dragend=e=>{let t=e.dragging;window.setTimeout(()=>{e.dragging==t&&(e.dragging=null)},50)},fR.dragover=fR.dragenter=(e,t)=>t.preventDefault(),fR.drop=(e,t)=>{try{QR(e,t,e.dragging)}finally{e.dragging=null}};function QR(e,t,n){if(!t.dataTransfer)return;let r=e.posAtCoords(SR(t));if(!r)return;let i=e.state.doc.resolve(r.pos),a=n&&n.slice;a?e.someProp(`transformPasted`,t=>{a=t(a,e,!1)}):a=YL(e,JR(t.dataTransfer),WR?null:t.dataTransfer.getData(`text/html`),!1,i);let o=!!(n&&ZR(e,t));if(e.someProp(`handleDrop`,n=>n(e,t,a||Q.empty,o))){t.preventDefault();return}if(!a)return;t.preventDefault();let s=a?yp(e.state.doc,i.pos,a):i.pos;s??=i.pos;let c=e.state.tr;if(o){let{node:e}=n;e?e.replace(c):c.deleteSelection()}let l=c.mapping.map(s),u=a.openStart==0&&a.openEnd==0&&a.content.childCount==1,d=c.doc;if(u?c.replaceRangeWith(l,l,a.content.firstChild):c.replaceRange(l,l,a),c.doc.eq(d))return;let f=c.doc.resolve(l);if(u&&Kp.isSelectable(a.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(a.content.firstChild))c.setSelection(new Kp(f));else{let t=c.mapping.map(s);c.mapping.maps[c.mapping.maps.length-1].forEach((e,n,r,i)=>t=i),c.setSelection(TL(e,f,c.doc.resolve(t)))}e.focus(),e.dispatch(c.setMeta(`uiEvent`,`drop`))}dR.focus=e=>{e.input.lastFocus=Date.now(),e.focused||(e.domObserver.stop(),e.dom.classList.add(`ProseMirror-focused`),e.domObserver.start(),e.focused=!0,setTimeout(()=>{e.docView&&e.hasFocus()&&!e.domObserver.currentSelection.eq(e.domSelectionRange())&&gL(e)},20))},dR.blur=(e,t)=>{let n=t;e.focused&&=(e.domObserver.stop(),e.dom.classList.remove(`ProseMirror-focused`),e.domObserver.start(),n.relatedTarget&&e.dom.contains(n.relatedTarget)&&e.domObserver.currentSelection.clear(),!1)},dR.beforeinput=(e,t)=>{if(QF&&iI&&t.inputType==`deleteContentBackward`){e.domObserver.flushSoon();let{domChangeCount:t}=e.input;setTimeout(()=>{if(e.input.domChangeCount!=t||(e.dom.blur(),e.focus(),e.someProp(`handleKeyDown`,t=>t(e,zF(8,`Backspace`)))))return;let{$cursor:n}=e.state.selection;n&&n.pos>0&&e.dispatch(e.state.tr.delete(n.pos-1,n.pos).scrollIntoView())},50)}};for(let e in fR)dR[e]=fR[e];function $R(e,t){if(e==t)return!0;for(let n in e)if(e[n]!==t[n])return!1;for(let n in t)if(!(n in e))return!1;return!0}var ez=class e{constructor(e,t){this.toDOM=e,this.spec=t||az,this.side=this.spec.side||0}map(e,t,n,r){let{pos:i,deleted:a}=e.mapResult(t.from+r,this.side<0?-1:1);return a?null:new rz(i-n,i-n,this)}valid(){return!0}eq(t){return this==t||t instanceof e&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&$R(this.spec,t.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}},tz=class e{constructor(e,t){this.attrs=e,this.spec=t||az}map(e,t,n,r){let i=e.map(t.from+r,this.spec.inclusiveStart?-1:1)-n,a=e.map(t.to+r,this.spec.inclusiveEnd?1:-1)-n;return i>=a?null:new rz(i,a,this)}valid(e,t){return t.from<t.to}eq(t){return this==t||t instanceof e&&$R(this.attrs,t.attrs)&&$R(this.spec,t.spec)}static is(t){return t.type instanceof e}destroy(){}},nz=class e{constructor(e,t){this.attrs=e,this.spec=t||az}map(e,t,n,r){let i=e.mapResult(t.from+r,1);if(i.deleted)return null;let a=e.mapResult(t.to+r,-1);return a.deleted||a.pos<=i.pos?null:new rz(i.pos-n,a.pos-n,this)}valid(e,t){let{index:n,offset:r}=e.content.findIndex(t.from),i;return r==t.from&&!(i=e.child(n)).isText&&r+i.nodeSize==t.to}eq(t){return this==t||t instanceof e&&$R(this.attrs,t.attrs)&&$R(this.spec,t.spec)}destroy(){}},rz=class e{constructor(e,t,n){this.from=e,this.to=t,this.type=n}copy(t,n){return new e(t,n,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,n){return this.type.map(e,this,t,n)}static widget(t,n,r){return new e(t,t,new ez(n,r))}static inline(t,n,r,i){return new e(t,n,new tz(r,i))}static node(t,n,r,i){return new e(t,n,new nz(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof tz}get widget(){return this.type instanceof ez}},iz=[],az={},oz=class e{constructor(e,t){this.local=e.length?e:iz,this.children=t.length?t:iz}static create(e,t){return t.length?mz(t,e,0,az):sz}find(e,t,n){let r=[];return this.findInner(e??0,t??1e9,r,0,n),r}findInner(e,t,n,r,i){for(let a=0;a<this.local.length;a++){let o=this.local[a];o.from<=t&&o.to>=e&&(!i||i(o.spec))&&n.push(o.copy(o.from+r,o.to+r))}for(let a=0;a<this.children.length;a+=3)if(this.children[a]<t&&this.children[a+1]>e){let o=this.children[a]+1;this.children[a+2].findInner(e-o,t-o,n,r+o,i)}}map(e,t,n){return this==sz||e.maps.length==0?this:this.mapInner(e,t,0,0,n||az)}mapInner(t,n,r,i,a){let o;for(let e=0;e<this.local.length;e++){let s=this.local[e].map(t,r,i);s&&s.type.valid(n,s)?(o||=[]).push(s):a.onRemove&&a.onRemove(this.local[e].spec)}return this.children.length?lz(this.children,o||[],t,n,r,i,a):o?new e(o.sort(hz),iz):sz}add(t,n){return n.length?this==sz?e.create(t,n):this.addInner(t,n,0):this}addInner(t,n,r){let i,a=0;t.forEach((e,t)=>{let o=t+r,s;if(s=fz(n,e,o)){for(i||=this.children.slice();a<i.length&&i[a]<t;)a+=3;i[a]==t?i[a+2]=i[a+2].addInner(e,s,o+1):i.splice(a,0,t,t+e.nodeSize,mz(s,e,o+1,az)),a+=3}});let o=uz(a?pz(n):n,-r);for(let e=0;e<o.length;e++)o[e].type.valid(t,o[e])||o.splice(e--,1);return new e(o.length?this.local.concat(o).sort(hz):this.local,i||this.children)}remove(e){return e.length==0||this==sz?this:this.removeInner(e,0)}removeInner(t,n){let r=this.children,i=this.local;for(let e=0;e<r.length;e+=3){let i,a=r[e]+n,o=r[e+1]+n;for(let e=0,n;e<t.length;e++)(n=t[e])&&n.from>a&&n.to<o&&(t[e]=null,(i||=[]).push(n));if(!i)continue;r==this.children&&(r=this.children.slice());let s=r[e+2].removeInner(i,a+1);s==sz?(r.splice(e,3),e-=3):r[e+2]=s}if(i.length){for(let e=0,r;e<t.length;e++)if(r=t[e])for(let e=0;e<i.length;e++)i[e].eq(r,n)&&(i==this.local&&(i=this.local.slice()),i.splice(e--,1))}return r==this.children&&i==this.local?this:i.length||r.length?new e(i,r):sz}forChild(t,n){if(this==sz)return this;if(n.isLeaf)return e.empty;let r,i;for(let e=0;e<this.children.length;e+=3)if(this.children[e]>=t){this.children[e]==t&&(r=this.children[e+2]);break}let a=t+1,o=a+n.content.size;for(let e=0;e<this.local.length;e++){let t=this.local[e];if(t.from<o&&t.to>a&&t.type instanceof tz){let e=Math.max(a,t.from)-a,n=Math.min(o,t.to)-a;e<n&&(i||=[]).push(t.copy(e,n))}}if(i){let t=new e(i.sort(hz),iz);return r?new cz([t,r]):t}return r||sz}eq(t){if(this==t)return!0;if(!(t instanceof e)||this.local.length!=t.local.length||this.children.length!=t.children.length)return!1;for(let e=0;e<this.local.length;e++)if(!this.local[e].eq(t.local[e]))return!1;for(let e=0;e<this.children.length;e+=3)if(this.children[e]!=t.children[e]||this.children[e+1]!=t.children[e+1]||!this.children[e+2].eq(t.children[e+2]))return!1;return!0}locals(e){return gz(this.localsInner(e))}localsInner(e){if(this==sz)return iz;if(e.inlineContent||!this.local.some(tz.is))return this.local;let t=[];for(let e=0;e<this.local.length;e++)this.local[e].type instanceof tz||t.push(this.local[e]);return t}forEachSet(e){e(this)}};oz.empty=new oz([],[]),oz.removeOverlap=gz;var sz=oz.empty,cz=class e{constructor(e){this.members=e}map(t,n){let r=this.members.map(e=>e.map(t,n,az));return e.from(r)}forChild(t,n){if(n.isLeaf)return oz.empty;let r=[];for(let i=0;i<this.members.length;i++){let a=this.members[i].forChild(t,n);a!=sz&&(a instanceof e?r=r.concat(a.members):r.push(a))}return e.from(r)}eq(t){if(!(t instanceof e)||t.members.length!=this.members.length)return!1;for(let e=0;e<this.members.length;e++)if(!this.members[e].eq(t.members[e]))return!1;return!0}locals(e){let t,n=!0;for(let r=0;r<this.members.length;r++){let i=this.members[r].localsInner(e);if(i.length)if(!t)t=i;else{n&&=(t=t.slice(),!1);for(let e=0;e<i.length;e++)t.push(i[e])}}return t?gz(n?t:t.sort(hz)):iz}static from(t){switch(t.length){case 0:return sz;case 1:return t[0];default:return new e(t.every(e=>e instanceof oz)?t:t.reduce((e,t)=>e.concat(t instanceof oz?t:t.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}};function lz(e,t,n,r,i,a,o){let s=e.slice();for(let e=0,t=a;e<n.maps.length;e++){let r=0;n.maps[e].forEach((e,n,i,a)=>{let o=a-i-(n-e);for(let i=0;i<s.length;i+=3){let a=s[i+1];if(a<0||e>a+t-r)continue;let c=s[i]+t-r;n>=c?s[i+1]=e<=c?-2:-1:e>=t&&o&&(s[i]+=o,s[i+1]+=o)}r+=o}),t=n.maps[e].map(t,-1)}let c=!1;for(let t=0;t<s.length;t+=3)if(s[t+1]<0){if(s[t+1]==-2){c=!0,s[t+1]=-1;continue}let l=n.map(e[t]+a),u=l-i;if(u<0||u>=r.content.size){c=!0;continue}let d=n.map(e[t+1]+a,-1)-i,{index:f,offset:p}=r.content.findIndex(u),m=r.maybeChild(f);if(m&&p==u&&p+m.nodeSize==d){let r=s[t+2].mapInner(n,m,l+1,e[t]+a+1,o);r==sz?(s[t+1]=-2,c=!0):(s[t]=u,s[t+1]=d,s[t+2]=r)}else c=!0}if(c){let c=mz(dz(s,e,t,n,i,a,o),r,0,o);t=c.local;for(let e=0;e<s.length;e+=3)s[e+1]<0&&(s.splice(e,3),e-=3);for(let e=0,t=0;e<c.children.length;e+=3){let n=c.children[e];for(;t<s.length&&s[t]<n;)t+=3;s.splice(t,0,c.children[e],c.children[e+1],c.children[e+2])}}return new oz(t.sort(hz),s)}function uz(e,t){if(!t||!e.length)return e;let n=[];for(let r=0;r<e.length;r++){let i=e[r];n.push(new rz(i.from+t,i.to+t,i.type))}return n}function dz(e,t,n,r,i,a,o){function s(e,t){for(let a=0;a<e.local.length;a++){let s=e.local[a].map(r,i,t);s?n.push(s):o.onRemove&&o.onRemove(e.local[a].spec)}for(let n=0;n<e.children.length;n+=3)s(e.children[n+2],e.children[n]+t+1)}for(let n=0;n<e.length;n+=3)e[n+1]==-1&&s(e[n+2],t[n]+a+1);return n}function fz(e,t,n){if(t.isLeaf)return null;let r=n+t.nodeSize,i=null;for(let t=0,a;t<e.length;t++)(a=e[t])&&a.from>n&&a.to<r&&((i||=[]).push(a),e[t]=null);return i}function pz(e){let t=[];for(let n=0;n<e.length;n++)e[n]!=null&&t.push(e[n]);return t}function mz(e,t,n,r){let i=[],a=!1;t.forEach((t,o)=>{let s=fz(e,t,o+n);if(s){a=!0;let e=mz(s,t,n+o+1,r);e!=sz&&i.push(o,o+t.nodeSize,e)}});let o=uz(a?pz(e):e,-n).sort(hz);for(let e=0;e<o.length;e++)o[e].type.valid(t,o[e])||(r.onRemove&&r.onRemove(o[e].spec),o.splice(e--,1));return o.length||i.length?new oz(o,i):sz}function hz(e,t){return e.from-t.from||e.to-t.to}function gz(e){let t=e;for(let n=0;n<t.length-1;n++){let r=t[n];if(r.from!=r.to)for(let i=n+1;i<t.length;i++){let a=t[i];if(a.from==r.from){a.to!=r.to&&(t==e&&(t=e.slice()),t[i]=a.copy(a.from,r.to),_z(t,i+1,a.copy(r.to,a.to)));continue}else{a.from<r.to&&(t==e&&(t=e.slice()),t[n]=r.copy(r.from,a.from),_z(t,i,r.copy(a.from,r.to)));break}}}return t}function _z(e,t,n){for(;t<e.length&&hz(n,e[t])>0;)t++;e.splice(t,0,n)}function vz(e){let t=[];return e.someProp(`decorations`,n=>{let r=n(e.state);r&&r!=sz&&t.push(r)}),e.cursorWrapper&&t.push(oz.create(e.state.doc,[e.cursorWrapper.deco])),cz.from(t)}var yz={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},bz=JF&&YF<=11,xz=class{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}},Sz=class{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new xz,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(t=>{for(let e=0;e<t.length;e++)this.queue.push(t[e]);JF&&YF<=11&&t.some(e=>e.type==`childList`&&e.removedNodes.length||e.type==`characterData`&&e.oldValue.length>e.target.nodeValue.length)?this.flushSoon():eI&&e.composing&&t.some(e=>e.type==`childList`&&e.target.nodeName==`TR`)?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),bz&&(this.onCharData=e=>{this.queue.push({target:e.target,type:`characterData`,oldValue:e.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,yz)),this.onCharData&&this.view.dom.addEventListener(`DOMCharacterDataModified`,this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;t<e.length;t++)this.queue.push(e[t]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener(`DOMCharacterDataModified`,this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener(`selectionchange`,this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener(`selectionchange`,this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(EL(this.view)){if(this.suppressingSelectionUpdates)return gL(this.view);if(JF&&YF<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&AF(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,n;for(let n=e.focusNode;n;n=EF(n))t.add(n);for(let r=e.anchorNode;r;r=EF(r))if(t.has(r)){n=r;break}let r=n&&this.view.docView.nearestDesc(n);if(r&&r.ignoreMutation({type:`selection`,target:n.nodeType==3?n.parentNode:n}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let n=e.domSelectionRange(),r=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&EL(e)&&!this.ignoreSelectionChange(n),i=-1,a=-1,o=!1,s=[];if(e.editable)for(let e=0;e<t.length;e++){let n=this.registerMutation(t[e],s);n&&(i=i<0?n.from:Math.min(n.from,i),a=a<0?n.to:Math.max(n.to,a),n.typeOver&&(o=!0))}if(s.some(e=>e.nodeName==`BR`)&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46)){for(let e of s)if(e.nodeName==`BR`&&e.parentNode){let t=e.nextSibling;for(;t&&t.nodeType==1;){if(t.contentEditable==`false`){e.parentNode.removeChild(e);break}t=t.firstChild}}}else if(XF&&s.length){let t=s.filter(e=>e.nodeName==`BR`);if(t.length==2){let[e,n]=t;e.parentNode&&e.parentNode.parentNode==n.parentNode?n.remove():e.remove()}else{let{focusNode:n}=this.currentSelection;for(let r of t){let t=r.parentNode;t&&t.nodeName==`LI`&&(!n||Oz(e,n)!=t)&&r.remove()}}}let c=null;i<0&&r&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&RF(n)&&(c=mL(e))&&c.eq(Bp.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,gL(e),this.currentSelection.set(n),e.scrollToSelection()):(i>-1||r)&&(i>-1&&(e.docView.markDirty(i,a),Tz(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,kz(e,s)),this.handleDOMChange(i,a,o,s),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(n)||gL(e),this.currentSelection.set(n))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let n=this.view.docView.nearestDesc(e.target);if(e.type==`attributes`&&(n==this.view.docView||e.attributeName==`contenteditable`||e.attributeName==`style`&&!e.oldValue&&!e.target.getAttribute(`style`))||!n||n.ignoreMutation(e))return null;if(e.type==`childList`){for(let n=0;n<e.addedNodes.length;n++){let r=e.addedNodes[n];t.push(r),r.nodeType==3&&(this.lastChangedTextNode=r)}if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(e.target))return{from:n.posBefore,to:n.posAfter};let r=e.previousSibling,i=e.nextSibling;if(JF&&YF<=11&&e.addedNodes.length)for(let t=0;t<e.addedNodes.length;t++){let{previousSibling:n,nextSibling:a}=e.addedNodes[t];(!n||Array.prototype.indexOf.call(e.addedNodes,n)<0)&&(r=n),(!a||Array.prototype.indexOf.call(e.addedNodes,a)<0)&&(i=a)}let a=r&&r.parentNode==e.target?TF(r)+1:0,o=n.localPosFromDOM(e.target,a,-1),s=i&&i.parentNode==e.target?TF(i):e.target.childNodes.length;return{from:o,to:n.localPosFromDOM(e.target,s,1)}}else if(e.type==`attributes`)return{from:n.posAtStart-n.border,to:n.posAtEnd+n.border};else return this.lastChangedTextNode=e.target,{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}}},Cz=new WeakMap,wz=!1;function Tz(e){if(!Cz.has(e)&&(Cz.set(e,null),[`normal`,`nowrap`,`pre-line`].indexOf(getComputedStyle(e.dom).whiteSpace)!==-1)){if(e.requiresGeckoHackNode=XF,wz)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.`),wz=!0}}function Ez(e,t){let n=t.startContainer,r=t.startOffset,i=t.endContainer,a=t.endOffset,o=e.domAtPos(e.state.selection.anchor);return AF(o.node,o.offset,i,a)&&([n,r,i,a]=[i,a,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:a}}function Dz(e,t){if(t.getComposedRanges){let n=t.getComposedRanges(e.root)[0];if(n)return Ez(e,n)}let n;function r(e){e.preventDefault(),e.stopImmediatePropagation(),n=e.getTargetRanges()[0]}return e.dom.addEventListener(`beforeinput`,r,!0),document.execCommand(`indent`),e.dom.removeEventListener(`beforeinput`,r,!0),n?Ez(e,n):null}function Oz(e,t){for(let n=t.parentNode;n&&n!=e.dom;n=n.parentNode){let t=e.docView.nearestDesc(n,!0);if(t&&t.node.isBlock)return n}return null}function kz(e,t){let{focusNode:n,focusOffset:r}=e.domSelectionRange();for(let i of t)if(i.parentNode?.nodeName==`TR`){let t=i.nextSibling;for(;t&&t.nodeName!=`TD`&&t.nodeName!=`TH`;)t=t.nextSibling;if(t){let a=t;for(;;){let e=a.firstChild;if(!e||e.nodeType!=1||e.contentEditable==`false`||/^(BR|IMG)$/.test(e.nodeName))break;a=e}a.insertBefore(i,a.firstChild),n==i&&e.domSelection().collapse(i,r)}else i.parentNode.removeChild(i)}}function Az(e,t,n){let{node:r,fromOffset:i,toOffset:a,from:o,to:s}=e.docView.parseRange(t,n),c=e.domSelectionRange(),l,u=c.anchorNode;if(u&&e.dom.contains(u.nodeType==1?u:u.parentNode)&&(l=[{node:u,offset:c.anchorOffset}],RF(c)||l.push({node:c.focusNode,offset:c.focusOffset})),QF&&e.input.lastKeyCode===8)for(let e=a;e>i;e--){let t=r.childNodes[e-1],n=t.pmViewDesc;if(t.nodeName==`BR`&&!n){a=e;break}if(!n||n.size)break}let d=e.state.doc,f=e.someProp(`domParser`)||af.fromSchema(e.state.schema),p=d.resolve(o),m=null,h=f.parse(r,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:i,to:a,preserveWhitespace:p.parent.type.whitespace==`pre`?`full`:!0,findPositions:l,ruleFromNode:jz,context:p});if(l&&l[0].pos!=null){let e=l[0].pos,t=l[1]&&l[1].pos;t??=e,m={anchor:e+o,head:t+o}}return{doc:h,sel:m,from:o,to:s}}function jz(e){let t=e.pmViewDesc;if(t)return t.parseRule();if(e.nodeName==`BR`&&e.parentNode){if(eI&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let e=document.createElement(`div`);return e.appendChild(document.createElement(`li`)),{skip:e}}else if(e.parentNode.lastChild==e||eI&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if(e.nodeName==`IMG`&&e.getAttribute(`mark-placeholder`))return{ignore:!0};return null}var Mz=/^(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 Nz(e,t,n,r,i){let a=e.input.compositionPendingChanges||(e.composing?e.input.compositionID:0);if(e.input.compositionPendingChanges=0,t<0){let t=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,n=mL(e,t);if(n&&!e.state.selection.eq(n)){if(QF&&iI&&e.input.lastKeyCode===13&&Date.now()-100<e.input.lastKeyCodeTime&&e.someProp(`handleKeyDown`,t=>t(e,zF(13,`Enter`))))return;let r=e.state.tr.setSelection(n);t==`pointer`?r.setMeta(`pointer`,!0):t==`key`&&r.scrollIntoView(),a&&r.setMeta(`composition`,a),e.dispatch(r)}return}let o=e.state.doc.resolve(t),s=o.sharedDepth(n);t=o.before(s+1),n=e.state.doc.resolve(n).after(s+1);let c=e.state.selection,l=Az(e,t,n),u=e.state.doc,d=u.slice(l.from,l.to),f,p;e.input.lastKeyCode===8&&Date.now()-100<e.input.lastKeyCodeTime?(f=e.state.selection.to,p=`end`):(f=e.state.selection.from,p=`start`),e.input.lastKeyCode=null;let m=Rz(d.content,l.doc.content,l.from,f,p);if(m&&e.input.domChangeCount++,(tI&&e.input.lastIOSEnter>Date.now()-225||iI)&&i.some(e=>e.nodeType==1&&!Mz.test(e.nodeName))&&(!m||m.endA>=m.endB)&&e.someProp(`handleKeyDown`,t=>t(e,zF(13,`Enter`)))){e.input.lastIOSEnter=0;return}if(!m)if(r&&c instanceof Wp&&!c.empty&&c.$head.sameParent(c.$anchor)&&!e.composing&&!(l.sel&&l.sel.anchor!=l.sel.head))m={start:c.from,endA:c.to,endB:c.to};else{if(l.sel){let t=Pz(e,e.state.doc,l.sel);if(t&&!t.eq(e.state.selection)){let n=e.state.tr.setSelection(t);a&&n.setMeta(`composition`,a),e.dispatch(n)}}return}e.state.selection.from<e.state.selection.to&&m.start==m.endB&&e.state.selection instanceof Wp&&(m.start>e.state.selection.from&&m.start<=e.state.selection.from+2&&e.state.selection.from>=l.from?m.start=e.state.selection.from:m.endA<e.state.selection.to&&m.endA>=e.state.selection.to-2&&e.state.selection.to<=l.to&&(m.endB+=e.state.selection.to-m.endA,m.endA=e.state.selection.to)),JF&&YF<=11&&m.endB==m.start+1&&m.endA==m.start&&m.start>l.from&&l.doc.textBetween(m.start-l.from-1,m.start-l.from+1)==` \xA0`&&(m.start--,m.endA--,m.endB--);let h=l.doc.resolveNoCache(m.start-l.from),g=l.doc.resolveNoCache(m.endB-l.from),_=u.resolve(m.start),v=h.sameParent(g)&&h.parent.inlineContent&&_.end()>=m.endA;if((tI&&e.input.lastIOSEnter>Date.now()-225&&(!v||i.some(e=>e.nodeName==`DIV`||e.nodeName==`P`))||!v&&h.pos<l.doc.content.size&&(!h.sameParent(g)||!h.parent.inlineContent)&&h.pos<g.pos&&!/\S/.test(l.doc.textBetween(h.pos,g.pos,``,``)))&&e.someProp(`handleKeyDown`,t=>t(e,zF(13,`Enter`)))){e.input.lastIOSEnter=0;return}if(e.state.selection.anchor>m.start&&Iz(u,m.start,m.endA,h,g)&&e.someProp(`handleKeyDown`,t=>t(e,zF(8,`Backspace`)))){iI&&QF&&e.domObserver.suppressSelectionUpdates();return}QF&&m.endB==m.start&&(e.input.lastChromeDelete=Date.now()),iI&&!v&&h.start()!=g.start()&&g.parentOffset==0&&h.depth==g.depth&&l.sel&&l.sel.anchor==l.sel.head&&l.sel.head==m.endA&&(m.endB-=2,g=l.doc.resolveNoCache(m.endB-l.from),setTimeout(()=>{e.someProp(`handleKeyDown`,function(t){return t(e,zF(13,`Enter`))})},20));let y=m.start,b=m.endA,x=t=>{let n=t||e.state.tr.replace(y,b,l.doc.slice(m.start-l.from,m.endB-l.from));if(l.sel){let t=Pz(e,n.doc,l.sel);t&&!(QF&&e.composing&&t.empty&&(m.start!=m.endB||e.input.lastChromeDelete<Date.now()-100)&&(t.head==y||t.head==n.mapping.map(b)-1)||JF&&t.empty&&t.head==y)&&n.setSelection(t)}return a&&n.setMeta(`composition`,a),n.scrollIntoView()},S;if(v)if(h.pos==g.pos){JF&&YF<=11&&h.parentOffset==0&&(e.domObserver.suppressSelectionUpdates(),setTimeout(()=>gL(e),20));let t=x(e.state.tr.delete(y,b)),n=u.resolve(m.start).marksAcross(u.resolve(m.endA));n&&t.ensureMarks(n),e.dispatch(t)}else if(m.endA==m.endB&&(S=Fz(h.parent.content.cut(h.parentOffset,g.parentOffset),_.parent.content.cut(_.parentOffset,m.endA-_.start())))){let t=x(e.state.tr);S.type==`add`?t.addMark(y,b,S.mark):t.removeMark(y,b,S.mark),e.dispatch(t)}else if(h.parent.child(h.index()).isText&&h.index()==g.index()-+!g.textOffset){let t=h.parent.textBetween(h.parentOffset,g.parentOffset),n=()=>x(e.state.tr.insertText(t,y,b));e.someProp(`handleTextInput`,r=>r(e,y,b,t,n))||e.dispatch(n())}else e.dispatch(x());else e.dispatch(x())}function Pz(e,t,n){return Math.max(n.anchor,n.head)>t.content.size?null:TL(e,t.resolve(n.anchor),t.resolve(n.head))}function Fz(e,t){let n=e.firstChild.marks,r=t.firstChild.marks,i=n,a=r,o,s,c;for(let e=0;e<r.length;e++)i=r[e].removeFromSet(i);for(let e=0;e<n.length;e++)a=n[e].removeFromSet(a);if(i.length==1&&a.length==0)s=i[0],o=`add`,c=e=>e.mark(s.addToSet(e.marks));else if(i.length==0&&a.length==1)s=a[0],o=`remove`,c=e=>e.mark(s.removeFromSet(e.marks));else return null;let l=[];for(let e=0;e<t.childCount;e++)l.push(c(t.child(e)));if(Z.from(l).eq(e))return{mark:s,type:o}}function Iz(e,t,n,r,i){if(n-t<=i.pos-r.pos||Lz(r,!0,!1)<i.pos)return!1;let a=e.resolve(t);if(!r.parent.isTextblock){let e=a.nodeAfter;return e!=null&&n==t+e.nodeSize}if(a.parentOffset<a.parent.content.size||!a.parent.isTextblock)return!1;let o=e.resolve(Lz(a,!0,!0));return!o.parent.isTextblock||o.pos>n||Lz(o,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function Lz(e,t,n){let r=e.depth,i=t?e.end():e.pos;for(;r>0&&(t||e.indexAfter(r)==e.node(r).childCount);)r--,i++,t=!1;if(n){let t=e.node(r).maybeChild(e.indexAfter(r));for(;t&&!t.isLeaf;)t=t.firstChild,i++}return i}function Rz(e,t,n,r,i){let a=e.findDiffStart(t,n);if(a==null)return null;let{a:o,b:s}=e.findDiffEnd(t,n+e.size,n+t.size);if(i==`end`){let e=Math.max(0,a-Math.min(o,s));r-=o+e-a}if(o<a&&e.size<t.size){let e=r<=a&&r>=o?a-r:0;a-=e,a&&a<t.size&&zz(t.textBetween(a-1,a+1))&&(a+=e?1:-1),s=a+(s-o),o=a}else if(s<a){let t=r<=a&&r>=s?a-r:0;a-=t,a&&a<e.size&&zz(e.textBetween(a-1,a+1))&&(a+=t?1:-1),o=a+(o-s),s=a}return{start:a,endA:o,endB:s}}function zz(e){if(e.length!=2)return!1;let t=e.charCodeAt(0),n=e.charCodeAt(1);return t>=56320&&t<=57343&&n>=55296&&n<=56319}var Bz=class{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new mR,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(qz),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=Uz(this),Hz(this),this.nodeViews=Gz(this),this.docView=JI(this.state.doc,Vz(this),vz(this),this.dom,this),this.domObserver=new Sz(this,(e,t,n,r)=>Nz(this,e,t,n,r)),this.domObserver.start(),hR(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&vR(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(qz),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let e in this._props)t[e]=this._props[e];t.state=this.state;for(let n in e)t[n]=e[n];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){let n=this.state,r=!1,i=!1;e.storedMarks&&this.composing&&(zR(this),i=!0),this.state=e;let a=n.plugins!=e.plugins||this._props.plugins!=t.plugins;if(a||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let e=Gz(this);Kz(e,this.nodeViews)&&(this.nodeViews=e,r=!0)}(a||t.handleDOMEvents!=this._props.handleDOMEvents)&&vR(this),this.editable=Uz(this),Hz(this);let o=vz(this),s=Vz(this),c=n.plugins!=e.plugins&&!n.doc.eq(e.doc)?`reset`:e.scrollToSelection>n.scrollToSelection?`to selection`:`preserve`,l=r||!this.docView.matchesNode(e.doc,s,o);(l||!e.selection.eq(n.selection))&&(i=!0);let u=c==`preserve`&&i&&this.dom.style.overflowAnchor==null&&dI(this);if(i){this.domObserver.stop();let t=l&&(JF||QF)&&!this.composing&&!n.selection.empty&&!e.selection.empty&&Wz(n.selection,e.selection);if(l){let n=QF?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=BR(this)),(r||!this.docView.update(e.doc,s,o,this))&&(this.docView.updateOuterDeco(s),this.docView.destroy(),this.docView=JI(e.doc,s,o,this.dom,this)),n&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(t=!0)}t||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&OL(this))?gL(this,t):(CL(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(n),this.dragging?.node&&!n.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,n),c==`reset`?this.dom.scrollTop=0:c==`to selection`?this.scrollToSelection():u&&pI(u)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))&&!this.someProp(`handleScrollToSelection`,e=>e(this)))if(this.state.selection instanceof Kp){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&uI(this,t.getBoundingClientRect(),e)}else uI(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 e=0;e<this.directPlugins.length;e++){let t=this.directPlugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}for(let e=0;e<this.state.plugins.length;e++){let t=this.state.plugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let n=this.pluginViews[t];n.update&&n.update(this,e)}}updateDraggedNode(e,t){let n=e.node,r=-1;if(n.from<this.state.doc.content.size&&this.state.doc.nodeAt(n.from)==n.node)r=n.from;else{let e=n.from+(this.state.doc.content.size-t.doc.content.size);(e>0&&e<this.state.doc.content.size&&this.state.doc.nodeAt(e))==n.node&&(r=e)}this.dragging=new YR(e.slice,e.move,r<0?void 0:Kp.create(this.state.doc,r))}someProp(e,t){let n=this._props&&this._props[e],r;if(n!=null&&(r=t?t(n):n))return r;for(let n=0;n<this.directPlugins.length;n++){let i=this.directPlugins[n].props[e];if(i!=null&&(r=t?t(i):i))return r}let i=this.state.plugins;if(i)for(let n=0;n<i.length;n++){let a=i[n].props[e];if(a!=null&&(r=t?t(a):a))return r}}hasFocus(){if(JF){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&&gI(this.dom),gL(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let e=this.dom.parentNode;e;e=e.parentNode)if(e.nodeType==9||e.nodeType==11&&e.host)return e.getSelection||(Object.getPrototypeOf(e).getSelection=()=>e.ownerDocument.getSelection()),this._root=e}return e||document}updateRoot(){this._root=null}posAtCoords(e){return wI(this,e)}coordsAtPos(e,t=1){return OI(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,n=-1){let r=this.docView.posFromDOM(e,t,n);if(r==null)throw RangeError(`DOM position not inside the editor`);return r}endOfTextblock(e,t){return RI(this,t||this.state,e)}pasteHTML(e,t){return qR(this,``,e,!1,t||new ClipboardEvent(`paste`))}pasteText(e,t){return qR(this,e,null,!0,t||new ClipboardEvent(`paste`))}serializeForClipboard(e){return JL(this,e)}destroy(){this.docView&&(_R(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],vz(this),this),this.dom.textContent=``):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,kF())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return xR(this,e)}domSelectionRange(){let e=this.domSelection();return e?eI&&this.root.nodeType===11&&BF(this.dom.ownerDocument)==this.dom&&Dz(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}};Bz.prototype.dispatch=function(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))};function Vz(e){let t=Object.create(null);return t.class=`ProseMirror`,t.contenteditable=String(e.editable),e.someProp(`attributes`,n=>{if(typeof n==`function`&&(n=n(e.state)),n)for(let e in n)e==`class`?t.class+=` `+n[e]:e==`style`?t.style=(t.style?t.style+`;`:``)+n[e]:!t[e]&&e!=`contenteditable`&&e!=`nodeName`&&(t[e]=String(n[e]))}),t.translate||=`no`,[rz.node(0,e.state.doc.content.size,t)]}function Hz(e){if(e.markCursor){let t=document.createElement(`img`);t.className=`ProseMirror-separator`,t.setAttribute(`mark-placeholder`,`true`),t.setAttribute(`alt`,``),e.cursorWrapper={dom:t,deco:rz.widget(e.state.selection.from,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function Uz(e){return!e.someProp(`editable`,t=>t(e.state)===!1)}function Wz(e,t){let n=Math.min(e.$anchor.sharedDepth(e.head),t.$anchor.sharedDepth(t.head));return e.$anchor.start(n)!=t.$anchor.start(n)}function Gz(e){let t=Object.create(null);function n(e){for(let n in e)Object.prototype.hasOwnProperty.call(t,n)||(t[n]=e[n])}return e.someProp(`nodeViews`,n),e.someProp(`markViews`,n),t}function Kz(e,t){let n=0,r=0;for(let r in e){if(e[r]!=t[r])return!0;n++}for(let e in t)r++;return n!=r}function qz(e){if(e.spec.state||e.spec.filterTransaction||e.spec.appendTransaction)throw RangeError(`Plugins passed directly to the view must not have a state component`)}for(var Jz={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:`'`},Yz={48:`)`,49:`!`,50:`@`,51:`#`,52:`$`,53:`%`,54:`^`,55:`&`,56:`*`,57:`(`,59:`:`,61:`+`,173:`_`,186:`:`,187:`+`,188:`<`,189:`_`,190:`>`,191:`?`,192:`~`,219:`{`,220:`|`,221:`}`,222:`"`},Xz=typeof navigator<`u`&&/Mac/.test(navigator.platform),Zz=typeof navigator<`u`&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),Qz=0;Qz<10;Qz++)Jz[48+Qz]=Jz[96+Qz]=String(Qz);for(var Qz=1;Qz<=24;Qz++)Jz[Qz+111]=`F`+Qz;for(var Qz=65;Qz<=90;Qz++)Jz[Qz]=String.fromCharCode(Qz+32),Yz[Qz]=String.fromCharCode(Qz);for(var $z in Jz)Yz.hasOwnProperty($z)||(Yz[$z]=Jz[$z]);function eB(e){var t=!(Xz&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||Zz&&e.shiftKey&&e.key&&e.key.length==1||e.key==`Unidentified`)&&e.key||(e.shiftKey?Yz:Jz)[e.keyCode]||e.key||`Unidentified`;return t==`Esc`&&(t=`Escape`),t==`Del`&&(t=`Delete`),t==`Left`&&(t=`ArrowLeft`),t==`Up`&&(t=`ArrowUp`),t==`Right`&&(t=`ArrowRight`),t==`Down`&&(t=`ArrowDown`),t}var tB=typeof navigator<`u`&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),nB=typeof navigator<`u`&&/Win/.test(navigator.platform);function rB(e){let t=e.split(/-(?!$)/),n=t[t.length-1];n==`Space`&&(n=` `);let r,i,a,o;for(let e=0;e<t.length-1;e++){let n=t[e];if(/^(cmd|meta|m)$/i.test(n))o=!0;else if(/^a(lt)?$/i.test(n))r=!0;else if(/^(c|ctrl|control)$/i.test(n))i=!0;else if(/^s(hift)?$/i.test(n))a=!0;else if(/^mod$/i.test(n))tB?o=!0:i=!0;else throw Error(`Unrecognized modifier name: `+n)}return r&&(n=`Alt-`+n),i&&(n=`Ctrl-`+n),o&&(n=`Meta-`+n),a&&(n=`Shift-`+n),n}function iB(e){let t=Object.create(null);for(let n in e)t[rB(n)]=e[n];return t}function aB(e,t,n=!0){return t.altKey&&(e=`Alt-`+e),t.ctrlKey&&(e=`Ctrl-`+e),t.metaKey&&(e=`Meta-`+e),n&&t.shiftKey&&(e=`Shift-`+e),e}function oB(e){return new cm({props:{handleKeyDown:sB(e)}})}function sB(e){let t=iB(e);return function(e,n){let r=eB(n),i,a=t[aB(r,n)];if(a&&a(e.state,e.dispatch,e))return!0;if(r.length==1&&r!=` `){if(n.shiftKey){let i=t[aB(r,n,!1)];if(i&&i(e.state,e.dispatch,e))return!0}if((n.altKey||n.metaKey||n.ctrlKey)&&!(nB&&n.ctrlKey&&n.altKey)&&(i=Jz[n.keyCode])&&i!=r){let r=t[aB(i,n)];if(r&&r(e.state,e.dispatch,e))return!0}}return!1}}var cB=(e,t)=>e.selection.empty?!1:(t&&t(e.tr.deleteSelection().scrollIntoView()),!0);function lB(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock(`backward`,e):n.parentOffset>0)?null:n}var uB=(e,t,n)=>{let r=lB(e,n);if(!r)return!1;let i=gB(r);if(!i){let n=r.blockRange(),i=n&&$f(n);return i==null?!1:(t&&t(e.tr.lift(n,i).scrollIntoView()),!0)}let a=i.nodeBefore;if(PB(e,i,t,-1))return!0;if(r.parent.content.size==0&&(mB(a,`end`)||Kp.isSelectable(a)))for(let n=r.depth;;n--){let o=bp(e.doc,r.before(n),r.after(n),Q.empty);if(o&&o.slice.size<o.to-o.from){if(t){let n=e.tr.step(o);n.setSelection(mB(a,`end`)?Bp.findFrom(n.doc.resolve(n.mapping.map(i.pos,-1)),-1):Kp.create(n.doc,i.pos-a.nodeSize)),t(n.scrollIntoView())}return!0}if(n==1||r.node(n-1).childCount>1)break}return a.isAtom&&i.depth==r.depth-1?(t&&t(e.tr.delete(i.pos-a.nodeSize,i.pos).scrollIntoView()),!0):!1},dB=(e,t,n)=>{let r=lB(e,n);if(!r)return!1;let i=gB(r);return i?pB(e,i,t):!1},fB=(e,t,n)=>{let r=_B(e,n);if(!r)return!1;let i=bB(r);return i?pB(e,i,t):!1};function pB(e,t,n){let r=t.nodeBefore,i=t.pos-1;for(;!r.isTextblock;i--){if(r.type.spec.isolating)return!1;let e=r.lastChild;if(!e)return!1;r=e}let a=t.nodeAfter,o=t.pos+1;for(;!a.isTextblock;o++){if(a.type.spec.isolating)return!1;let e=a.firstChild;if(!e)return!1;a=e}let s=bp(e.doc,i,o,Q.empty);if(!s||s.from!=i||s instanceof Kf&&s.slice.size>=o-i)return!1;if(n){let t=e.tr.step(s);t.setSelection(Wp.create(t.doc,i)),n(t.scrollIntoView())}return!0}function mB(e,t,n=!1){for(let r=e;r;r=t==`start`?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&r.childCount!=1)return!1}return!1}var hB=(e,t,n)=>{let{$head:r,empty:i}=e.selection,a=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock(`backward`,e):r.parentOffset>0)return!1;a=gB(r)}let o=a&&a.nodeBefore;return!o||!Kp.isSelectable(o)?!1:(t&&t(e.tr.setSelection(Kp.create(e.doc,a.pos-o.nodeSize)).scrollIntoView()),!0)};function gB(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){if(e.index(t)>0)return e.doc.resolve(e.before(t+1));if(e.node(t).type.spec.isolating)break}return null}function _B(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock(`forward`,e):n.parentOffset<n.parent.content.size)?null:n}var vB=(e,t,n)=>{let r=_B(e,n);if(!r)return!1;let i=bB(r);if(!i)return!1;let a=i.nodeAfter;if(PB(e,i,t,1))return!0;if(r.parent.content.size==0&&(mB(a,`start`)||Kp.isSelectable(a))){let n=bp(e.doc,r.before(),r.after(),Q.empty);if(n&&n.slice.size<n.to-n.from){if(t){let r=e.tr.step(n);r.setSelection(mB(a,`start`)?Bp.findFrom(r.doc.resolve(r.mapping.map(i.pos)),1):Kp.create(r.doc,r.mapping.map(i.pos))),t(r.scrollIntoView())}return!0}}return a.isAtom&&i.depth==r.depth-1?(t&&t(e.tr.delete(i.pos,i.pos+a.nodeSize).scrollIntoView()),!0):!1},yB=(e,t,n)=>{let{$head:r,empty:i}=e.selection,a=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock(`forward`,e):r.parentOffset<r.parent.content.size)return!1;a=bB(r)}let o=a&&a.nodeAfter;return!o||!Kp.isSelectable(o)?!1:(t&&t(e.tr.setSelection(Kp.create(e.doc,a.pos)).scrollIntoView()),!0)};function bB(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){let n=e.node(t);if(e.index(t)+1<n.childCount)return e.doc.resolve(e.after(t+1));if(n.type.spec.isolating)break}return null}var xB=(e,t)=>{let n=e.selection,r=n instanceof Kp,i;if(r){if(n.node.isTextblock||!pp(e.doc,n.from))return!1;i=n.from}else if(i=gp(e.doc,n.from,-1),i==null)return!1;if(t){let n=e.tr.join(i);r&&n.setSelection(Kp.create(n.doc,i-e.doc.resolve(i).nodeBefore.nodeSize)),t(n.scrollIntoView())}return!0},SB=(e,t)=>{let n=e.selection,r;if(n instanceof Kp){if(n.node.isTextblock||!pp(e.doc,n.to))return!1;r=n.to}else if(r=gp(e.doc,n.to,1),r==null)return!1;return t&&t(e.tr.join(r).scrollIntoView()),!0},CB=(e,t)=>{let{$from:n,$to:r}=e.selection,i=n.blockRange(r),a=i&&$f(i);return a==null?!1:(t&&t(e.tr.lift(i,a).scrollIntoView()),!0)},wB=(e,t)=>{let{$head:n,$anchor:r}=e.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(t&&t(e.tr.insertText(`
133
+ `).scrollIntoView()),!0)};function TB(e){for(let t=0;t<e.edgeCount;t++){let{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}var EB=(e,t)=>{let{$head:n,$anchor:r}=e.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let i=n.node(-1),a=n.indexAfter(-1),o=TB(i.contentMatchAt(a));if(!o||!i.canReplaceWith(a,a,o))return!1;if(t){let r=n.after(),i=e.tr.replaceWith(r,r,o.createAndFill());i.setSelection(Bp.near(i.doc.resolve(r),1)),t(i.scrollIntoView())}return!0},DB=(e,t)=>{let n=e.selection,{$from:r,$to:i}=n;if(n instanceof Jp||r.parent.inlineContent||i.parent.inlineContent)return!1;let a=TB(i.parent.contentMatchAt(i.indexAfter()));if(!a||!a.isTextblock)return!1;if(t){let n=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,o=e.tr.insert(n,a.createAndFill());o.setSelection(Wp.create(o.doc,n+1)),t(o.scrollIntoView())}return!0},OB=(e,t)=>{let{$cursor:n}=e.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let r=n.before();if(dp(e.doc,r))return t&&t(e.tr.split(r).scrollIntoView()),!0}let r=n.blockRange(),i=r&&$f(r);return i==null?!1:(t&&t(e.tr.lift(r,i).scrollIntoView()),!0)};function kB(e){return(t,n)=>{let{$from:r,$to:i}=t.selection;if(t.selection instanceof Kp&&t.selection.node.isBlock)return!r.parentOffset||!dp(t.doc,r.pos)?!1:(n&&n(t.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let a=[],o,s,c=!1,l=!1;for(let t=r.depth;;t--)if(r.node(t).isBlock){c=r.end(t)==r.pos+(r.depth-t),l=r.start(t)==r.pos-(r.depth-t),s=TB(r.node(t-1).contentMatchAt(r.indexAfter(t-1)));let n=e&&e(i.parent,c,r);a.unshift(n||(c&&s?{type:s}:null)),o=t;break}else{if(t==1)return!1;a.unshift(null)}let u=t.tr;(t.selection instanceof Wp||t.selection instanceof Jp)&&u.deleteSelection();let d=u.mapping.map(r.pos),f=dp(u.doc,d,a.length,a);if(f||=(a[0]=s?{type:s}:null,dp(u.doc,d,a.length,a)),!f)return!1;if(u.split(d,a.length,a),!c&&l&&r.node(o).type!=s){let e=u.mapping.map(r.before(o)),t=u.doc.resolve(e);s&&r.node(o-1).canReplaceWith(t.index(),t.index()+1,s)&&u.setNodeMarkup(u.mapping.map(r.before(o)),s)}return n&&n(u.scrollIntoView()),!0}}var AB=kB(),jB=(e,t)=>{let{$from:n,to:r}=e.selection,i,a=n.sharedDepth(r);return a==0?!1:(i=n.before(a),t&&t(e.tr.setSelection(Kp.create(e.doc,i))),!0)},MB=(e,t)=>(t&&t(e.tr.setSelection(new Jp(e.doc))),!0);function NB(e,t,n){let r=t.nodeBefore,i=t.nodeAfter,a=t.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&t.parent.canReplace(a-1,a)?(n&&n(e.tr.delete(t.pos-r.nodeSize,t.pos).scrollIntoView()),!0):!t.parent.canReplace(a,a+1)||!(i.isTextblock||pp(e.doc,t.pos))?!1:(n&&n(e.tr.join(t.pos).scrollIntoView()),!0)}function PB(e,t,n,r){let i=t.nodeBefore,a=t.nodeAfter,o,s,c=i.type.spec.isolating||a.type.spec.isolating;if(!c&&NB(e,t,n))return!0;let l=!c&&t.parent.canReplace(t.index(),t.index()+1);if(l&&(o=(s=i.contentMatchAt(i.childCount)).findWrapping(a.type))&&s.matchType(o[0]||a.type).validEnd){if(n){let r=t.pos+a.nodeSize,s=Z.empty;for(let e=o.length-1;e>=0;e--)s=Z.from(o[e].create(null,s));s=Z.from(i.copy(s));let c=e.tr.step(new qf(t.pos-1,r,t.pos,r,new Q(s,1,0),o.length,!0)),l=c.doc.resolve(r+2*o.length);l.nodeAfter&&l.nodeAfter.type==i.type&&pp(c.doc,l.pos)&&c.join(l.pos),n(c.scrollIntoView())}return!0}let u=a.type.spec.isolating||r>0&&c?null:Bp.findFrom(t,1),d=u&&u.$from.blockRange(u.$to),f=d&&$f(d);if(f!=null&&f>=t.depth)return n&&n(e.tr.lift(d,f).scrollIntoView()),!0;if(l&&mB(a,`start`,!0)&&mB(i,`end`)){let r=i,o=[];for(;o.push(r),!r.isTextblock;)r=r.lastChild;let s=a,c=1;for(;!s.isTextblock;s=s.firstChild)c++;if(r.canReplace(r.childCount,r.childCount,s.content)){if(n){let r=Z.empty;for(let e=o.length-1;e>=0;e--)r=Z.from(o[e].copy(r));n(e.tr.step(new qf(t.pos-o.length,t.pos+a.nodeSize,t.pos+c,t.pos+a.nodeSize-c,new Q(r,o.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function FB(e){return function(t,n){let r=t.selection,i=e<0?r.$from:r.$to,a=i.depth;for(;i.node(a).isInline;){if(!a)return!1;a--}return i.node(a).isTextblock?(n&&n(t.tr.setSelection(Wp.create(t.doc,e<0?i.start(a):i.end(a)))),!0):!1}}var IB=FB(-1),LB=FB(1);function RB(e,t=null){return function(n,r){let{$from:i,$to:a}=n.selection,o=i.blockRange(a),s=o&&tp(o,e,t);return s?(r&&r(n.tr.wrap(o,s).scrollIntoView()),!0):!1}}function zB(e,t=null){return function(n,r){let i=!1;for(let r=0;r<n.selection.ranges.length&&!i;r++){let{$from:{pos:a},$to:{pos:o}}=n.selection.ranges[r];n.doc.nodesBetween(a,o,(r,a)=>{if(i)return!1;if(!(!r.isTextblock||r.hasMarkup(e,t)))if(r.type==e)i=!0;else{let t=n.doc.resolve(a),r=t.index();i=t.parent.canReplaceWith(r,r+1,e)}})}if(!i)return!1;if(r){let i=n.tr;for(let r=0;r<n.selection.ranges.length;r++){let{$from:{pos:a},$to:{pos:o}}=n.selection.ranges[r];i.setBlockType(a,o,e,t)}r(i.scrollIntoView())}return!0}}function BB(...e){return function(t,n,r){for(let i=0;i<e.length;i++)if(e[i](t,n,r))return!0;return!1}}var VB=BB(cB,uB,hB),HB=BB(cB,vB,yB),UB={Enter:BB(wB,DB,OB,AB),"Mod-Enter":EB,Backspace:VB,"Mod-Backspace":VB,"Shift-Backspace":VB,Delete:HB,"Mod-Delete":HB,"Mod-a":MB},WB={"Ctrl-h":UB.Backspace,"Alt-Backspace":UB[`Mod-Backspace`],"Ctrl-d":UB.Delete,"Ctrl-Alt-Backspace":UB[`Mod-Delete`],"Alt-Delete":UB[`Mod-Delete`],"Alt-d":UB[`Mod-Delete`],"Ctrl-a":IB,"Ctrl-e":LB};for(let e in UB)WB[e]=UB[e];typeof navigator<`u`?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<`u`&&os.platform&&os.platform();function GB(e,t=null){return function(n,r){let{$from:i,$to:a}=n.selection,o=i.blockRange(a);if(!o)return!1;let s=r?n.tr:null;return KB(s,o,e,t)?(r&&r(s.scrollIntoView()),!0):!1}}function KB(e,t,n,r=null){let i=!1,a=t,o=t.$from.doc;if(t.depth>=2&&t.$from.node(t.depth-1).type.compatibleContent(n)&&t.startIndex==0){if(t.$from.index(t.depth-1)==0)return!1;let e=o.resolve(t.start-2);a=new Dd(e,e,t.depth),t.endIndex<t.parent.childCount&&(t=new Dd(t.$from,o.resolve(t.$to.end(t.depth)),t.depth)),i=!0}let s=tp(a,n,r,t);return s?(e&&qB(e,t,s,i,n),!0):!1}function qB(e,t,n,r,i){let a=Z.empty;for(let e=n.length-1;e>=0;e--)a=Z.from(n[e].type.create(n[e].attrs,a));e.step(new qf(t.start-(r?2:0),t.end,t.start,t.end,new Q(a,0,0),n.length,!0));let o=0;for(let e=0;e<n.length;e++)n[e].type==i&&(o=e+1);let s=n.length-o,c=t.start+n.length-(r?2:0),l=t.parent;for(let n=t.startIndex,r=t.endIndex,i=!0;n<r;n++,i=!1)!i&&dp(e.doc,c,s)&&(e.split(c,s),c+=2*s),c+=l.child(n).nodeSize;return e}function JB(e){return function(t,n){let{$from:r,$to:i}=t.selection,a=r.blockRange(i,t=>t.childCount>0&&t.firstChild.type==e);return a?n?r.node(a.depth-1).type==e?YB(t,n,e,a):XB(t,n,a):!0:!1}}function YB(e,t,n,r){let i=e.tr,a=r.end,o=r.$to.end(r.depth);a<o&&(i.step(new qf(a-1,o,a,o,new Q(Z.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new Dd(i.doc.resolve(r.$from.pos),i.doc.resolve(o),r.depth));let s=$f(r);if(s==null)return!1;i.lift(r,s);let c=i.doc.resolve(i.mapping.map(a,-1)-1);return pp(i.doc,c.pos)&&c.nodeBefore.type==c.nodeAfter.type&&i.join(c.pos),t(i.scrollIntoView()),!0}function XB(e,t,n){let r=e.tr,i=n.parent;for(let e=n.end,t=n.endIndex-1,a=n.startIndex;t>a;t--)e-=i.child(t).nodeSize,r.delete(e-1,e+1);let a=r.doc.resolve(n.start),o=a.nodeAfter;if(r.mapping.map(n.end)!=n.start+a.nodeAfter.nodeSize)return!1;let s=n.startIndex==0,c=n.endIndex==i.childCount,l=a.node(-1),u=a.index(-1);if(!l.canReplace(u+ +!s,u+1,o.content.append(c?Z.empty:Z.from(i))))return!1;let d=a.pos,f=d+o.nodeSize;return r.step(new qf(d-+!!s,f+ +!!c,d+1,f-1,new Q((s?Z.empty:Z.from(i.copy(Z.empty))).append(c?Z.empty:Z.from(i.copy(Z.empty))),+!s,+!c),+!s)),t(r.scrollIntoView()),!0}function ZB(e){return function(t,n){let{$from:r,$to:i}=t.selection,a=r.blockRange(i,t=>t.childCount>0&&t.firstChild.type==e);if(!a)return!1;let o=a.startIndex;if(o==0)return!1;let s=a.parent,c=s.child(o-1);if(c.type!=e)return!1;if(n){let r=c.lastChild&&c.lastChild.type==s.type,i=Z.from(r?e.create():null),o=new Q(Z.from(e.create(null,Z.from(s.type.create(null,i)))),r?3:1,0),l=a.start,u=a.end;n(t.tr.step(new qf(l-(r?3:1),u,l,u,o,1,!0)).scrollIntoView())}return!0}}function QB(e){let{state:t,transaction:n}=e,{selection:r}=n,{doc:i}=n,{storedMarks:a}=n;return{...t,apply:t.apply.bind(t),applyTransaction:t.applyTransaction.bind(t),plugins:t.plugins,schema:t.schema,reconfigure:t.reconfigure.bind(t),toJSON:t.toJSON.bind(t),get storedMarks(){return a},get selection(){return r},get doc(){return i},get tr(){return r=n.selection,i=n.doc,a=n.storedMarks,n}}}var $B=class{constructor(e){this.editor=e.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=e.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){let{rawCommands:e,editor:t,state:n}=this,{view:r}=t,{tr:i}=n,a=this.buildProps(i);return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,(...e)=>{let n=t(...e)(a);return!i.getMeta(`preventDispatch`)&&!this.hasCustomState&&r.dispatch(i),n}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(e,t=!0){let{rawCommands:n,editor:r,state:i}=this,{view:a}=r,o=[],s=!!e,c=e||i.tr,l=()=>(!s&&t&&!c.getMeta(`preventDispatch`)&&!this.hasCustomState&&a.dispatch(c),o.every(e=>e===!0)),u={...Object.fromEntries(Object.entries(n).map(([e,n])=>[e,(...e)=>{let r=this.buildProps(c,t),i=n(...e)(r);return o.push(i),u}])),run:l};return u}createCan(e){let{rawCommands:t,state:n}=this,r=e||n.tr,i=this.buildProps(r,!1);return{...Object.fromEntries(Object.entries(t).map(([e,t])=>[e,(...e)=>t(...e)({...i,dispatch:void 0})])),chain:()=>this.createChain(r,!1)}}buildProps(e,t=!0){let{rawCommands:n,editor:r,state:i}=this,{view:a}=r,o={tr:e,editor:r,view:a,state:QB({state:i,transaction:e}),dispatch:t?()=>void 0:void 0,chain:()=>this.createChain(e,t),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(n).map(([e,t])=>[e,(...e)=>t(...e)(o)]))}};return o}},eV=class{constructor(){this.callbacks={}}on(e,t){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),this}emit(e,...t){let n=this.callbacks[e];return n&&n.forEach(e=>e.apply(this,t)),this}off(e,t){let n=this.callbacks[e];return n&&(t?this.callbacks[e]=n.filter(e=>e!==t):delete this.callbacks[e]),this}once(e,t){let n=(...r)=>{this.off(e,n),t.apply(this,r)};return this.on(e,n)}removeAllListeners(){this.callbacks={}}};function tV(e,t,n){return e.config[t]===void 0&&e.parent?tV(e.parent,t,n):typeof e.config[t]==`function`?e.config[t].bind({...n,parent:e.parent?tV(e.parent,t,n):null}):e.config[t]}function nV(e){return{baseExtensions:e.filter(e=>e.type===`extension`),nodeExtensions:e.filter(e=>e.type===`node`),markExtensions:e.filter(e=>e.type===`mark`)}}function rV(e){let t=[],{nodeExtensions:n,markExtensions:r}=nV(e),i=[...n,...r],a={default:null,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return e.forEach(e=>{let n=tV(e,`addGlobalAttributes`,{name:e.name,options:e.options,storage:e.storage,extensions:i});n&&n().forEach(e=>{e.types.forEach(n=>{Object.entries(e.attributes).forEach(([e,r])=>{t.push({type:n,name:e,attribute:{...a,...r}})})})})}),i.forEach(e=>{let n=tV(e,`addAttributes`,{name:e.name,options:e.options,storage:e.storage});if(!n)return;let r=n();Object.entries(r).forEach(([n,r])=>{let i={...a,...r};typeof i?.default==`function`&&(i.default=i.default()),i?.isRequired&&i?.default===void 0&&delete i.default,t.push({type:e.name,name:n,attribute:i})})}),t}function iV(e,t){if(typeof e==`string`){if(!t.nodes[e])throw Error(`There is no node type named '${e}'. Maybe you forgot to add the extension?`);return t.nodes[e]}return e}function aV(...e){return e.filter(e=>!!e).reduce((e,t)=>{let n={...e};return Object.entries(t).forEach(([e,t])=>{if(!n[e]){n[e]=t;return}if(e===`class`){let r=t?String(t).split(` `):[],i=n[e]?n[e].split(` `):[],a=r.filter(e=>!i.includes(e));n[e]=[...i,...a].join(` `)}else if(e===`style`){let r=t?t.split(`;`).map(e=>e.trim()).filter(Boolean):[],i=n[e]?n[e].split(`;`).map(e=>e.trim()).filter(Boolean):[],a=new Map;i.forEach(e=>{let[t,n]=e.split(`:`).map(e=>e.trim());a.set(t,n)}),r.forEach(e=>{let[t,n]=e.split(`:`).map(e=>e.trim());a.set(t,n)}),n[e]=Array.from(a.entries()).map(([e,t])=>`${e}: ${t}`).join(`; `)}else n[e]=t}),n},{})}function oV(e,t){return t.filter(t=>t.type===e.type.name).filter(e=>e.attribute.rendered).map(t=>t.attribute.renderHTML?t.attribute.renderHTML(e.attrs)||{}:{[t.name]:e.attrs[t.name]}).reduce((e,t)=>aV(e,t),{})}function sV(e){return typeof e==`function`}function cV(e,t=void 0,...n){return sV(e)?t?e.bind(t)(...n):e(...n):e}function lV(e={}){return Object.keys(e).length===0&&e.constructor===Object}function uV(e){return typeof e==`string`?e.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(e):e===`true`?!0:e===`false`?!1:e:e}function dV(e,t){return`style`in e?e:{...e,getAttrs:n=>{let r=e.getAttrs?e.getAttrs(n):e.attrs;if(r===!1)return!1;let i=t.reduce((e,t)=>{let r=t.attribute.parseHTML?t.attribute.parseHTML(n):uV(n.getAttribute(t.name));return r==null?e:{...e,[t.name]:r}},{});return{...r,...i}}}}function fV(e){return Object.fromEntries(Object.entries(e).filter(([e,t])=>e===`attrs`&&lV(t)?!1:t!=null))}function pV(e,t){let n=rV(e),{nodeExtensions:r,markExtensions:i}=nV(e);return new ef({topNode:r.find(e=>tV(e,`topNode`))?.name,nodes:Object.fromEntries(r.map(r=>{let i=n.filter(e=>e.type===r.name),a={name:r.name,options:r.options,storage:r.storage,editor:t},o=fV({...e.reduce((e,t)=>{let n=tV(t,`extendNodeSchema`,a);return{...e,...n?n(r):{}}},{}),content:cV(tV(r,`content`,a)),marks:cV(tV(r,`marks`,a)),group:cV(tV(r,`group`,a)),inline:cV(tV(r,`inline`,a)),atom:cV(tV(r,`atom`,a)),selectable:cV(tV(r,`selectable`,a)),draggable:cV(tV(r,`draggable`,a)),code:cV(tV(r,`code`,a)),whitespace:cV(tV(r,`whitespace`,a)),linebreakReplacement:cV(tV(r,`linebreakReplacement`,a)),defining:cV(tV(r,`defining`,a)),isolating:cV(tV(r,`isolating`,a)),attrs:Object.fromEntries(i.map(e=>[e.name,{default:e?.attribute?.default}]))}),s=cV(tV(r,`parseHTML`,a));s&&(o.parseDOM=s.map(e=>dV(e,i)));let c=tV(r,`renderHTML`,a);c&&(o.toDOM=e=>c({node:e,HTMLAttributes:oV(e,i)}));let l=tV(r,`renderText`,a);return l&&(o.toText=l),[r.name,o]})),marks:Object.fromEntries(i.map(r=>{let i=n.filter(e=>e.type===r.name),a={name:r.name,options:r.options,storage:r.storage,editor:t},o=fV({...e.reduce((e,t)=>{let n=tV(t,`extendMarkSchema`,a);return{...e,...n?n(r):{}}},{}),inclusive:cV(tV(r,`inclusive`,a)),excludes:cV(tV(r,`excludes`,a)),group:cV(tV(r,`group`,a)),spanning:cV(tV(r,`spanning`,a)),code:cV(tV(r,`code`,a)),attrs:Object.fromEntries(i.map(e=>[e.name,{default:e?.attribute?.default}]))}),s=cV(tV(r,`parseHTML`,a));s&&(o.parseDOM=s.map(e=>dV(e,i)));let c=tV(r,`renderHTML`,a);return c&&(o.toDOM=e=>c({mark:e,HTMLAttributes:oV(e,i)})),[r.name,o]}))})}function mV(e,t){return t.nodes[e]||t.marks[e]||null}function hV(e,t){return Array.isArray(t)?t.some(t=>(typeof t==`string`?t:t.name)===e.name):t}function gV(e,t){let n=yf.fromSchema(t).serializeFragment(e),r=document.implementation.createHTMLDocument().createElement(`div`);return r.appendChild(n),r.innerHTML}var _V=(e,t=500)=>{let n=``,r=e.parentOffset;return e.parent.nodesBetween(Math.max(0,r-t),r,(e,t,i,a)=>{var o;let s=(o=e.type.spec).toText?.call(o,{node:e,pos:t,parent:i,index:a})||e.textContent||`%leaf%`;n+=e.isAtom&&!e.isText?s:s.slice(0,Math.max(0,r-t))}),n};function vV(e){return Object.prototype.toString.call(e)===`[object RegExp]`}var yV=class{constructor(e){this.find=e.find,this.handler=e.handler}},bV=(e,t)=>{if(vV(t))return t.exec(e);let n=t(e);if(!n)return null;let r=[n.text];return r.index=n.index,r.input=e,r.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn(`[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".`),r.push(n.replaceWith)),r};function xV(e){let{editor:t,from:n,to:r,text:i,rules:a,plugin:o}=e,{view:s}=t;if(s.composing)return!1;let c=s.state.doc.resolve(n);if(c.parent.type.spec.code||(c.nodeBefore||c.nodeAfter)?.marks.find(e=>e.type.spec.code))return!1;let l=!1,u=_V(c)+i;return a.forEach(e=>{if(l)return;let a=bV(u,e.find);if(!a)return;let c=s.state.tr,d=QB({state:s.state,transaction:c}),f={from:n-(a[0].length-i.length),to:r},{commands:p,chain:m,can:h}=new $B({editor:t,state:d});e.handler({state:d,range:f,match:a,commands:p,chain:m,can:h})===null||!c.steps.length||(c.setMeta(o,{transform:c,from:n,to:r,text:i}),s.dispatch(c),l=!0)}),l}function SV(e){let{editor:t,rules:n}=e,r=new cm({state:{init(){return null},apply(e,i,a){let o=e.getMeta(r);if(o)return o;let s=e.getMeta(`applyInputRules`);return s&&setTimeout(()=>{let{text:e}=s;e=typeof e==`string`?e:gV(Z.from(e),a.schema);let{from:i}=s;xV({editor:t,from:i,to:i+e.length,text:e,rules:n,plugin:r})}),e.selectionSet||e.docChanged?null:i}},props:{handleTextInput(e,i,a,o){return xV({editor:t,from:i,to:a,text:o,rules:n,plugin:r})},handleDOMEvents:{compositionend:e=>(setTimeout(()=>{let{$cursor:i}=e.state.selection;i&&xV({editor:t,from:i.pos,to:i.pos,text:``,rules:n,plugin:r})}),!1)},handleKeyDown(e,i){if(i.key!==`Enter`)return!1;let{$cursor:a}=e.state.selection;return a?xV({editor:t,from:a.pos,to:a.pos,text:`
134
+ `,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function CV(e){return Object.prototype.toString.call(e).slice(8,-1)}function wV(e){return CV(e)===`Object`?e.constructor===Object&&Object.getPrototypeOf(e)===Object.prototype:!1}function TV(e,t){let n={...e};return wV(e)&&wV(t)&&Object.keys(t).forEach(r=>{wV(t[r])&&wV(e[r])?n[r]=TV(e[r],t[r]):n[r]=t[r]}),n}var EV=class e{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=cV(tV(this,`addOptions`,{name:this.name}))),this.storage=cV(tV(this,`addStorage`,{name:this.name,options:this.options}))||{}}static create(t={}){return new e(t)}configure(e={}){let t=this.extend({...this.config,addOptions:()=>TV(this.options,e)});return t.name=this.name,t.parent=this.parent,t}extend(t={}){let n=new e(t);return n.parent=this,this.child=n,n.name=t.name?t.name:n.parent.name,t.defaultOptions&&Object.keys(t.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${n.name}".`),n.options=cV(tV(n,`addOptions`,{name:n.name})),n.storage=cV(tV(n,`addStorage`,{name:n.name,options:n.options})),n}static handleExit({editor:e,mark:t}){let{tr:n}=e.state,r=e.state.selection.$from;if(r.pos===r.end()){let i=r.marks();if(!i.find(e=>e?.type.name===t.name))return!1;let a=i.find(e=>e?.type.name===t.name);return a&&n.removeStoredMark(a),n.insertText(` `,r.pos),e.view.dispatch(n),!0}return!1}};function DV(e){return typeof e==`number`}var OV=class{constructor(e){this.find=e.find,this.handler=e.handler}},kV=(e,t,n)=>{if(vV(t))return[...e.matchAll(t)];let r=t(e,n);return r?r.map(t=>{let n=[t.text];return n.index=t.index,n.input=e,n.data=t.data,t.replaceWith&&(t.text.includes(t.replaceWith)||console.warn(`[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".`),n.push(t.replaceWith)),n}):[]};function AV(e){let{editor:t,state:n,from:r,to:i,rule:a,pasteEvent:o,dropEvent:s}=e,{commands:c,chain:l,can:u}=new $B({editor:t,state:n}),d=[];return n.doc.nodesBetween(r,i,(e,t)=>{if(!e.isTextblock||e.type.spec.code)return;let f=Math.max(r,t),p=Math.min(i,t+e.content.size);kV(e.textBetween(f-t,p-t,void 0,``),a.find,o).forEach(e=>{if(e.index===void 0)return;let t=f+e.index+1,r=t+e[0].length,i={from:n.tr.mapping.map(t),to:n.tr.mapping.map(r)},p=a.handler({state:n,range:i,match:e,commands:c,chain:l,can:u,pasteEvent:o,dropEvent:s});d.push(p)})}),d.every(e=>e!==null)}var jV=null,MV=e=>{var t;let n=new ClipboardEvent(`paste`,{clipboardData:new DataTransfer});return(t=n.clipboardData)==null||t.setData(`text/html`,e),n};function NV(e){let{editor:t,rules:n}=e,r=null,i=!1,a=!1,o=typeof ClipboardEvent<`u`?new ClipboardEvent(`paste`):null,s;try{s=typeof DragEvent<`u`?new DragEvent(`drop`):null}catch{s=null}let c=({state:e,from:n,to:r,rule:i,pasteEvt:a})=>{let c=e.tr;if(!(!AV({editor:t,state:QB({state:e,transaction:c}),from:Math.max(n-1,0),to:r.b-1,rule:i,pasteEvent:a,dropEvent:s})||!c.steps.length)){try{s=typeof DragEvent<`u`?new DragEvent(`drop`):null}catch{s=null}return o=typeof ClipboardEvent<`u`?new ClipboardEvent(`paste`):null,c}};return n.map(e=>new cm({view(e){let n=n=>{r=e.dom.parentElement?.contains(n.target)?e.dom.parentElement:null,r&&(jV=t)},i=()=>{jV&&=null};return window.addEventListener(`dragstart`,n),window.addEventListener(`dragend`,i),{destroy(){window.removeEventListener(`dragstart`,n),window.removeEventListener(`dragend`,i)}}},props:{handleDOMEvents:{drop:(e,t)=>{if(a=r===e.dom.parentElement,s=t,!a){let e=jV;e?.isEditable&&setTimeout(()=>{let t=e.state.selection;t&&e.commands.deleteRange({from:t.from,to:t.to})},10)}return!1},paste:(e,t)=>{let n=t.clipboardData?.getData(`text/html`);return o=t,i=!!n?.includes(`data-pm-slice`),!1}}},appendTransaction:(t,n,r)=>{let s=t[0],l=s.getMeta(`uiEvent`)===`paste`&&!i,u=s.getMeta(`uiEvent`)===`drop`&&!a,d=s.getMeta(`applyPasteRules`),f=!!d;if(!l&&!u&&!f)return;if(f){let{text:t}=d;t=typeof t==`string`?t:gV(Z.from(t),r.schema);let{from:n}=d,i=n+t.length,a=MV(t);return c({rule:e,state:r,from:n,to:{b:i},pasteEvt:a})}let p=n.doc.content.findDiffStart(r.doc.content),m=n.doc.content.findDiffEnd(r.doc.content);if(!(!DV(p)||!m||p===m.b))return c({rule:e,state:r,from:p,to:m,pasteEvt:o})}}))}function PV(e){let t=e.filter((t,n)=>e.indexOf(t)!==n);return Array.from(new Set(t))}var FV=class e{constructor(t,n){this.splittableMarks=[],this.editor=n,this.extensions=e.resolve(t),this.schema=pV(this.extensions,n),this.setupExtensions()}static resolve(t){let n=e.sort(e.flatten(t)),r=PV(n.map(e=>e.name));return r.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${r.map(e=>`'${e}'`).join(`, `)}]. This can lead to issues.`),n}static flatten(e){return e.map(e=>{let t=tV(e,`addExtensions`,{name:e.name,options:e.options,storage:e.storage});return t?[e,...this.flatten(t())]:e}).flat(10)}static sort(e){return e.sort((e,t)=>{let n=tV(e,`priority`)||100,r=tV(t,`priority`)||100;return n>r?-1:+(n<r)})}get commands(){return this.extensions.reduce((e,t)=>{let n=tV(t,`addCommands`,{name:t.name,options:t.options,storage:t.storage,editor:this.editor,type:mV(t.name,this.schema)});return n?{...e,...n()}:e},{})}get plugins(){let{editor:t}=this,n=e.sort([...this.extensions].reverse()),r=[],i=[],a=n.map(e=>{let n={name:e.name,options:e.options,storage:e.storage,editor:t,type:mV(e.name,this.schema)},a=[],o=tV(e,`addKeyboardShortcuts`,n),s={};if(e.type===`mark`&&tV(e,`exitable`,n)&&(s.ArrowRight=()=>EV.handleExit({editor:t,mark:e})),o){let e=Object.fromEntries(Object.entries(o()).map(([e,n])=>[e,()=>n({editor:t})]));s={...s,...e}}let c=oB(s);a.push(c);let l=tV(e,`addInputRules`,n);hV(e,t.options.enableInputRules)&&l&&r.push(...l());let u=tV(e,`addPasteRules`,n);hV(e,t.options.enablePasteRules)&&u&&i.push(...u());let d=tV(e,`addProseMirrorPlugins`,n);if(d){let e=d();a.push(...e)}return a}).flat();return[SV({editor:t,rules:r}),...NV({editor:t,rules:i}),...a]}get attributes(){return rV(this.extensions)}get nodeViews(){let{editor:e}=this,{nodeExtensions:t}=nV(this.extensions);return Object.fromEntries(t.filter(e=>!!tV(e,`addNodeView`)).map(t=>{let n=this.attributes.filter(e=>e.type===t.name),r=tV(t,`addNodeView`,{name:t.name,options:t.options,storage:t.storage,editor:e,type:iV(t.name,this.schema)});return r?[t.name,(i,a,o,s,c)=>{let l=oV(i,n);return r()({node:i,view:a,getPos:o,decorations:s,innerDecorations:c,editor:e,extension:t,HTMLAttributes:l})}]:[]}))}setupExtensions(){this.extensions.forEach(e=>{this.editor.extensionStorage[e.name]=e.storage;let t={name:e.name,options:e.options,storage:e.storage,editor:this.editor,type:mV(e.name,this.schema)};e.type===`mark`&&(cV(tV(e,`keepOnSplit`,t))??!0)&&this.splittableMarks.push(e.name);let n=tV(e,`onBeforeCreate`,t),r=tV(e,`onCreate`,t),i=tV(e,`onUpdate`,t),a=tV(e,`onSelectionUpdate`,t),o=tV(e,`onTransaction`,t),s=tV(e,`onFocus`,t),c=tV(e,`onBlur`,t),l=tV(e,`onDestroy`,t);n&&this.editor.on(`beforeCreate`,n),r&&this.editor.on(`create`,r),i&&this.editor.on(`update`,i),a&&this.editor.on(`selectionUpdate`,a),o&&this.editor.on(`transaction`,o),s&&this.editor.on(`focus`,s),c&&this.editor.on(`blur`,c),l&&this.editor.on(`destroy`,l)})}},IV=class e{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=cV(tV(this,`addOptions`,{name:this.name}))),this.storage=cV(tV(this,`addStorage`,{name:this.name,options:this.options}))||{}}static create(t={}){return new e(t)}configure(e={}){let t=this.extend({...this.config,addOptions:()=>TV(this.options,e)});return t.name=this.name,t.parent=this.parent,t}extend(t={}){let n=new e({...this.config,...t});return n.parent=this,this.child=n,n.name=t.name?t.name:n.parent.name,t.defaultOptions&&Object.keys(t.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${n.name}".`),n.options=cV(tV(n,`addOptions`,{name:n.name})),n.storage=cV(tV(n,`addStorage`,{name:n.name,options:n.options})),n}};function LV(e,t,n){let{from:r,to:i}=t,{blockSeparator:a=`
135
+
136
+ `,textSerializers:o={}}=n||{},s=``;return e.nodesBetween(r,i,(e,n,c,l)=>{e.isBlock&&n>r&&(s+=a);let u=o?.[e.type.name];if(u)return c&&(s+=u({node:e,pos:n,parent:c,index:l,range:t})),!1;e.isText&&(s+=(e?.text)?.slice(Math.max(r,n)-n,i-n))}),s}function RV(e){return Object.fromEntries(Object.entries(e.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}var zV=IV.create({name:`clipboardTextSerializer`,addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new cm({key:new dm(`clipboardTextSerializer`),props:{clipboardTextSerializer:()=>{let{editor:e}=this,{state:t,schema:n}=e,{doc:r,selection:i}=t,{ranges:a}=i,o=Math.min(...a.map(e=>e.$from.pos)),s=Math.max(...a.map(e=>e.$to.pos)),c=RV(n);return LV(r,{from:o,to:s},{...this.options.blockSeparator===void 0?{}:{blockSeparator:this.options.blockSeparator},textSerializers:c})}}})]}}),BV=()=>({editor:e,view:t})=>(requestAnimationFrame(()=>{var n;e.isDestroyed||(t.dom.blur(),(n=window==null?void 0:window.getSelection())==null||n.removeAllRanges())}),!0),VV=(e=!1)=>({commands:t})=>t.setContent(``,e),HV=()=>({state:e,tr:t,dispatch:n})=>{let{selection:r}=t,{ranges:i}=r;return n&&i.forEach(({$from:n,$to:r})=>{e.doc.nodesBetween(n.pos,r.pos,(e,n)=>{if(e.type.isText)return;let{doc:r,mapping:i}=t,a=r.resolve(i.map(n)),o=r.resolve(i.map(n+e.nodeSize)),s=a.blockRange(o);if(!s)return;let c=$f(s);if(e.type.isTextblock){let{defaultType:e}=a.parent.contentMatchAt(a.index());t.setNodeMarkup(s.start,e)}(c||c===0)&&t.lift(s,c)})}),!0},UV=e=>t=>e(t),WV=()=>({state:e,dispatch:t})=>DB(e,t),GV=(e,t)=>({editor:n,tr:r})=>{let{state:i}=n,a=i.doc.slice(e.from,e.to);r.deleteRange(e.from,e.to);let o=r.mapping.map(t);return r.insert(o,a.content),r.setSelection(new Wp(r.doc.resolve(Math.max(o-1,0)))),!0},KV=()=>({tr:e,dispatch:t})=>{let{selection:n}=e,r=n.$anchor.node();if(r.content.size>0)return!1;let i=e.selection.$anchor;for(let n=i.depth;n>0;--n)if(i.node(n).type===r.type){if(t){let t=i.before(n),r=i.after(n);e.delete(t,r).scrollIntoView()}return!0}return!1},qV=e=>({tr:t,state:n,dispatch:r})=>{let i=iV(e,n.schema),a=t.selection.$anchor;for(let e=a.depth;e>0;--e)if(a.node(e).type===i){if(r){let n=a.before(e),r=a.after(e);t.delete(n,r).scrollIntoView()}return!0}return!1},JV=e=>({tr:t,dispatch:n})=>{let{from:r,to:i}=e;return n&&t.delete(r,i),!0},YV=()=>({state:e,dispatch:t})=>cB(e,t),XV=()=>({commands:e})=>e.keyboardShortcut(`Enter`),ZV=()=>({state:e,dispatch:t})=>EB(e,t);function QV(e,t,n={strict:!0}){let r=Object.keys(t);return r.length?r.every(r=>n.strict?t[r]===e[r]:vV(t[r])?t[r].test(e[r]):t[r]===e[r]):!0}function $V(e,t,n={}){return e.find(e=>e.type===t&&QV(Object.fromEntries(Object.keys(n).map(t=>[t,e.attrs[t]])),n))}function eH(e,t,n={}){return!!$V(e,t,n)}function tH(e,t,n){if(!e||!t)return;let r=e.parent.childAfter(e.parentOffset);if((!r.node||!r.node.marks.some(e=>e.type===t))&&(r=e.parent.childBefore(e.parentOffset)),!r.node||!r.node.marks.some(e=>e.type===t)||(n||=r.node.marks[0]?.attrs,!$V([...r.node.marks],t,n)))return;let i=r.index,a=e.start()+r.offset,o=i+1,s=a+r.node.nodeSize;for(;i>0&&eH([...e.parent.child(i-1).marks],t,n);)--i,a-=e.parent.child(i).nodeSize;for(;o<e.parent.childCount&&eH([...e.parent.child(o).marks],t,n);)s+=e.parent.child(o).nodeSize,o+=1;return{from:a,to:s}}function nH(e,t){if(typeof e==`string`){if(!t.marks[e])throw Error(`There is no mark type named '${e}'. Maybe you forgot to add the extension?`);return t.marks[e]}return e}var rH=(e,t={})=>({tr:n,state:r,dispatch:i})=>{let a=nH(e,r.schema),{doc:o,selection:s}=n,{$from:c,from:l,to:u}=s;if(i){let e=tH(c,a,t);if(e&&e.from<=l&&e.to>=u){let t=Wp.create(o,e.from,e.to);n.setSelection(t)}}return!0},iH=e=>t=>{let n=typeof e==`function`?e(t):e;for(let e=0;e<n.length;e+=1)if(n[e](t))return!0;return!1};function aH(e){return e instanceof Wp}function oH(e=0,t=0,n=0){return Math.min(Math.max(e,t),n)}function sH(e,t=null){if(!t)return null;let n=Bp.atStart(e),r=Bp.atEnd(e);if(t===`start`||t===!0)return n;if(t===`end`)return r;let i=n.from,a=r.to;return t===`all`?Wp.create(e,oH(0,i,a),oH(e.content.size,i,a)):Wp.create(e,oH(t,i,a),oH(t,i,a))}function cH(){return navigator.platform===`Android`||/android/i.test(navigator.userAgent)}function lH(){return[`iPad Simulator`,`iPhone Simulator`,`iPod Simulator`,`iPad`,`iPhone`,`iPod`].includes(navigator.platform)||navigator.userAgent.includes(`Mac`)&&`ontouchend`in document}function uH(){return typeof navigator<`u`?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}var dH=(e=null,t={})=>({editor:n,view:r,tr:i,dispatch:a})=>{t={scrollIntoView:!0,...t};let o=()=>{(lH()||cH())&&r.dom.focus(),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),uH()&&!lH()&&!cH()&&r.dom.focus({preventScroll:!0}))})};if(r.hasFocus()&&e===null||e===!1)return!0;if(a&&e===null&&!aH(n.state.selection))return o(),!0;let s=sH(i.doc,e)||n.state.selection,c=n.state.selection.eq(s);return a&&(c||i.setSelection(s),c&&i.storedMarks&&i.setStoredMarks(i.storedMarks),o()),!0},fH=(e,t)=>n=>e.every((e,r)=>t(e,{...n,index:r})),pH=(e,t)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},e,t),mH=e=>{let t=e.childNodes;for(let n=t.length-1;n>=0;--n){let r=t[n];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?e.removeChild(r):r.nodeType===1&&mH(r)}return e};function hH(e){let t=`<body>${e}</body>`,n=new window.DOMParser().parseFromString(t,`text/html`).body;return mH(n)}function gH(e,t,n){if(e instanceof kd||e instanceof Z)return e;n={slice:!0,parseOptions:{},...n};let r=typeof e==`object`&&!!e,i=typeof e==`string`;if(r)try{if(Array.isArray(e)&&e.length>0)return Z.fromArray(e.map(e=>t.nodeFromJSON(e)));let r=t.nodeFromJSON(e);return n.errorOnInvalidContent&&r.check(),r}catch(r){if(n.errorOnInvalidContent)throw Error(`[tiptap error]: Invalid JSON content`,{cause:r});return console.warn(`[tiptap warn]: Invalid content.`,`Passed value:`,e,`Error:`,r),gH(``,t,n)}if(i){if(n.errorOnInvalidContent){let r=!1,i=``,a=new ef({topNode:t.spec.topNode,marks:t.spec.marks,nodes:t.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:`inline*`,group:`block`,parseDOM:[{tag:`*`,getAttrs:e=>(r=!0,i=typeof e==`string`?e:e.outerHTML,null)}]}})});if(n.slice?af.fromSchema(a).parseSlice(hH(e),n.parseOptions):af.fromSchema(a).parse(hH(e),n.parseOptions),n.errorOnInvalidContent&&r)throw Error(`[tiptap error]: Invalid HTML content`,{cause:Error(`Invalid element found: ${i}`)})}let r=af.fromSchema(t);return n.slice?r.parseSlice(hH(e),n.parseOptions).content:r.parse(hH(e),n.parseOptions)}return gH(``,t,n)}function _H(e,t,n){let r=e.steps.length-1;if(r<t)return;let i=e.steps[r];if(!(i instanceof Kf||i instanceof qf))return;let a=e.mapping.maps[r],o=0;a.forEach((e,t,n,r)=>{o===0&&(o=r)}),e.setSelection(Bp.near(e.doc.resolve(o),n))}var vH=e=>!(`type`in e),yH=(e,t,n)=>({tr:r,dispatch:i,editor:a})=>{if(i){n={parseOptions:a.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let i,o=e=>{a.emit(`contentError`,{editor:a,error:e,disableCollaboration:()=>{a.storage.collaboration&&(a.storage.collaboration.isDisabled=!0)}})},s={preserveWhitespace:`full`,...n.parseOptions};if(!n.errorOnInvalidContent&&!a.options.enableContentCheck&&a.options.emitContentError)try{gH(t,a.schema,{parseOptions:s,errorOnInvalidContent:!0})}catch(e){o(e)}try{i=gH(t,a.schema,{parseOptions:s,errorOnInvalidContent:n.errorOnInvalidContent??a.options.enableContentCheck})}catch(e){return o(e),!1}let{from:c,to:l}=typeof e==`number`?{from:e,to:e}:{from:e.from,to:e.to},u=!0,d=!0;if((vH(i)?i:[i]).forEach(e=>{e.check(),u=u?e.isText&&e.marks.length===0:!1,d=d?e.isBlock:!1}),c===l&&d){let{parent:e}=r.doc.resolve(c);e.isTextblock&&!e.type.spec.code&&!e.childCount&&(--c,l+=1)}let f;if(u){if(Array.isArray(t))f=t.map(e=>e.text||``).join(``);else if(t instanceof Z){let e=``;t.forEach(t=>{t.text&&(e+=t.text)}),f=e}else f=typeof t==`object`&&t&&t.text?t.text:t;r.insertText(f,c,l)}else f=i,r.replaceWith(c,l,f);n.updateSelection&&_H(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta(`applyInputRules`,{from:c,text:f}),n.applyPasteRules&&r.setMeta(`applyPasteRules`,{from:c,text:f})}return!0},bH=()=>({state:e,dispatch:t})=>xB(e,t),xH=()=>({state:e,dispatch:t})=>SB(e,t),SH=()=>({state:e,dispatch:t})=>uB(e,t),CH=()=>({state:e,dispatch:t})=>vB(e,t),wH=()=>({state:e,dispatch:t,tr:n})=>{try{let r=gp(e.doc,e.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),t&&t(n),!0)}catch{return!1}},TH=()=>({state:e,dispatch:t,tr:n})=>{try{let r=gp(e.doc,e.selection.$from.pos,1);return r==null?!1:(n.join(r,2),t&&t(n),!0)}catch{return!1}},EH=()=>({state:e,dispatch:t})=>dB(e,t),DH=()=>({state:e,dispatch:t})=>fB(e,t);function OH(){return typeof navigator<`u`?/Mac/.test(navigator.platform):!1}function kH(e){let t=e.split(/-(?!$)/),n=t[t.length-1];n===`Space`&&(n=` `);let r,i,a,o;for(let e=0;e<t.length-1;e+=1){let n=t[e];if(/^(cmd|meta|m)$/i.test(n))o=!0;else if(/^a(lt)?$/i.test(n))r=!0;else if(/^(c|ctrl|control)$/i.test(n))i=!0;else if(/^s(hift)?$/i.test(n))a=!0;else if(/^mod$/i.test(n))lH()||OH()?o=!0:i=!0;else throw Error(`Unrecognized modifier name: ${n}`)}return r&&(n=`Alt-${n}`),i&&(n=`Ctrl-${n}`),o&&(n=`Meta-${n}`),a&&(n=`Shift-${n}`),n}var AH=e=>({editor:t,view:n,tr:r,dispatch:i})=>{let a=kH(e).split(/-(?!$)/),o=a.find(e=>![`Alt`,`Ctrl`,`Meta`,`Shift`].includes(e)),s=new KeyboardEvent(`keydown`,{key:o===`Space`?` `:o,altKey:a.includes(`Alt`),ctrlKey:a.includes(`Ctrl`),metaKey:a.includes(`Meta`),shiftKey:a.includes(`Shift`),bubbles:!0,cancelable:!0});return t.captureTransaction(()=>{n.someProp(`handleKeyDown`,e=>e(n,s))})?.steps.forEach(e=>{let t=e.map(r.mapping);t&&i&&r.maybeStep(t)}),!0};function jH(e,t,n={}){let{from:r,to:i,empty:a}=e.selection,o=t?iV(t,e.schema):null,s=[];e.doc.nodesBetween(r,i,(e,t)=>{if(e.isText)return;let n=Math.max(r,t),a=Math.min(i,t+e.nodeSize);s.push({node:e,from:n,to:a})});let c=i-r,l=s.filter(e=>o?o.name===e.node.type.name:!0).filter(e=>QV(e.node.attrs,n,{strict:!1}));return a?!!l.length:l.reduce((e,t)=>e+t.to-t.from,0)>=c}var MH=(e,t={})=>({state:n,dispatch:r})=>jH(n,iV(e,n.schema),t)?CB(n,r):!1,NH=()=>({state:e,dispatch:t})=>OB(e,t),PH=e=>({state:t,dispatch:n})=>JB(iV(e,t.schema))(t,n),FH=()=>({state:e,dispatch:t})=>wB(e,t);function IH(e,t){return t.nodes[e]?`node`:t.marks[e]?`mark`:null}function LH(e,t){let n=typeof t==`string`?[t]:t;return Object.keys(e).reduce((t,r)=>(n.includes(r)||(t[r]=e[r]),t),{})}var RH=(e,t)=>({tr:n,state:r,dispatch:i})=>{let a=null,o=null,s=IH(typeof e==`string`?e:e.name,r.schema);return s?(s===`node`&&(a=iV(e,r.schema)),s===`mark`&&(o=nH(e,r.schema)),i&&n.selection.ranges.forEach(e=>{r.doc.nodesBetween(e.$from.pos,e.$to.pos,(e,r)=>{a&&a===e.type&&n.setNodeMarkup(r,void 0,LH(e.attrs,t)),o&&e.marks.length&&e.marks.forEach(i=>{o===i.type&&n.addMark(r,r+e.nodeSize,o.create(LH(i.attrs,t)))})})}),!0):!1},zH=()=>({tr:e,dispatch:t})=>(t&&e.scrollIntoView(),!0),BH=()=>({tr:e,dispatch:t})=>{if(t){let t=new Jp(e.doc);e.setSelection(t)}return!0},VH=()=>({state:e,dispatch:t})=>hB(e,t),HH=()=>({state:e,dispatch:t})=>yB(e,t),UH=()=>({state:e,dispatch:t})=>jB(e,t),WH=()=>({state:e,dispatch:t})=>LB(e,t),GH=()=>({state:e,dispatch:t})=>IB(e,t);function KH(e,t,n={},r={}){return gH(e,t,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var qH=(e,t=!1,n={},r={})=>({editor:i,tr:a,dispatch:o,commands:s})=>{let{doc:c}=a;if(n.preserveWhitespace!==`full`){let s=KH(e,i.schema,n,{errorOnInvalidContent:r.errorOnInvalidContent??i.options.enableContentCheck});return o&&a.replaceWith(0,c.content.size,s).setMeta(`preventUpdate`,!t),!0}return o&&a.setMeta(`preventUpdate`,!t),s.insertContentAt({from:0,to:c.content.size},e,{parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent??i.options.enableContentCheck})};function JH(e,t){let n=nH(t,e.schema),{from:r,to:i,empty:a}=e.selection,o=[];a?(e.storedMarks&&o.push(...e.storedMarks),o.push(...e.selection.$head.marks())):e.doc.nodesBetween(r,i,e=>{o.push(...e.marks)});let s=o.find(e=>e.type.name===n.name);return s?{...s.attrs}:{}}function YH(e,t){let n=new Rp(e);return t.forEach(e=>{e.steps.forEach(e=>{n.step(e)})}),n}function XH(e){for(let t=0;t<e.edgeCount;t+=1){let{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}function ZH(e,t,n){let r=[];return e.nodesBetween(t.from,t.to,(e,t)=>{n(e)&&r.push({node:e,pos:t})}),r}function QH(e,t){for(let n=e.depth;n>0;--n){let r=e.node(n);if(t(r))return{pos:n>0?e.before(n):0,start:e.start(n),depth:n,node:r}}}function $H(e){return t=>QH(t.$from,e)}function eU(e,t){return LV(e,{from:0,to:e.content.size},t)}function tU(e,t){let n=iV(t,e.schema),{from:r,to:i}=e.selection,a=[];e.doc.nodesBetween(r,i,e=>{a.push(e)});let o=a.reverse().find(e=>e.type.name===n.name);return o?{...o.attrs}:{}}function nU(e,t){let n=IH(typeof t==`string`?t:t.name,e.schema);return n===`node`?tU(e,t):n===`mark`?JH(e,t):{}}function rU(e,t=JSON.stringify){let n={};return e.filter(e=>{let r=t(e);return Object.prototype.hasOwnProperty.call(n,r)?!1:n[r]=!0})}function iU(e){let t=rU(e);return t.length===1?t:t.filter((e,n)=>!t.filter((e,t)=>t!==n).some(t=>e.oldRange.from>=t.oldRange.from&&e.oldRange.to<=t.oldRange.to&&e.newRange.from>=t.newRange.from&&e.newRange.to<=t.newRange.to))}function aU(e){let{mapping:t,steps:n}=e,r=[];return t.maps.forEach((e,i)=>{let a=[];if(e.ranges.length)e.forEach((e,t)=>{a.push({from:e,to:t})});else{let{from:e,to:t}=n[i];if(e===void 0||t===void 0)return;a.push({from:e,to:t})}a.forEach(({from:e,to:n})=>{let a=t.slice(i).map(e,-1),o=t.slice(i).map(n),s=t.invert().map(a,-1),c=t.invert().map(o);r.push({oldRange:{from:s,to:c},newRange:{from:a,to:o}})})}),iU(r)}function oU(e,t,n){let r=[];return e===t?n.resolve(e).marks().forEach(t=>{let i=tH(n.resolve(e),t.type);i&&r.push({mark:t,...i})}):n.nodesBetween(e,t,(e,t)=>{!e||e?.nodeSize===void 0||r.push(...e.marks.map(n=>({from:t,to:t+e.nodeSize,mark:n})))}),r}function sU(e,t,n){return Object.fromEntries(Object.entries(n).filter(([n])=>{let r=e.find(e=>e.type===t&&e.name===n);return r?r.attribute.keepOnSplit:!1}))}function cU(e,t,n={}){let{empty:r,ranges:i}=e.selection,a=t?nH(t,e.schema):null;if(r)return!!(e.storedMarks||e.selection.$from.marks()).filter(e=>a?a.name===e.type.name:!0).find(e=>QV(e.attrs,n,{strict:!1}));let o=0,s=[];if(i.forEach(({$from:t,$to:n})=>{let r=t.pos,i=n.pos;e.doc.nodesBetween(r,i,(e,t)=>{if(!e.isText&&!e.marks.length)return;let n=Math.max(r,t),a=Math.min(i,t+e.nodeSize),c=a-n;o+=c,s.push(...e.marks.map(e=>({mark:e,from:n,to:a})))})}),o===0)return!1;let c=s.filter(e=>a?a.name===e.mark.type.name:!0).filter(e=>QV(e.mark.attrs,n,{strict:!1})).reduce((e,t)=>e+t.to-t.from,0),l=s.filter(e=>a?e.mark.type!==a&&e.mark.type.excludes(a):!0).reduce((e,t)=>e+t.to-t.from,0);return(c>0?c+l:c)>=o}function lU(e,t,n={}){if(!t)return jH(e,null,n)||cU(e,null,n);let r=IH(t,e.schema);return r===`node`?jH(e,t,n):r===`mark`?cU(e,t,n):!1}function uU(e,t){let{nodeExtensions:n}=nV(t),r=n.find(t=>t.name===e);if(!r)return!1;let i=cV(tV(r,`group`,{name:r.name,options:r.options,storage:r.storage}));return typeof i==`string`?i.split(` `).includes(`list`):!1}function dU(e,{checkChildren:t=!0,ignoreWhitespace:n=!1}={}){if(n){if(e.type.name===`hardBreak`)return!0;if(e.isText)return/^\s*$/m.test(e.text??``)}if(e.isText)return!e.text;if(e.isAtom||e.isLeaf)return!1;if(e.content.childCount===0)return!0;if(t){let r=!0;return e.content.forEach(e=>{r!==!1&&(dU(e,{ignoreWhitespace:n,checkChildren:t})||(r=!1))}),r}return!1}function fU(e){return e instanceof Kp}function pU(e,t,n){let{selection:r}=t,i=null;if(aH(r)&&(i=r.$cursor),i){let t=e.storedMarks??i.marks();return!!n.isInSet(t)||!t.some(e=>e.type.excludes(n))}let{ranges:a}=r;return a.some(({$from:t,$to:r})=>{let i=t.depth===0?e.doc.inlineContent&&e.doc.type.allowsMarkType(n):!1;return e.doc.nodesBetween(t.pos,r.pos,(e,t,r)=>{if(i)return!1;if(e.isInline){let t=!r||r.type.allowsMarkType(n),a=!!n.isInSet(e.marks)||!e.marks.some(e=>e.type.excludes(n));i=t&&a}return!i}),i})}var mU=(e,t={})=>({tr:n,state:r,dispatch:i})=>{let{selection:a}=n,{empty:o,ranges:s}=a,c=nH(e,r.schema);if(i)if(o){let e=JH(r,c);n.addStoredMark(c.create({...e,...t}))}else s.forEach(e=>{let i=e.$from.pos,a=e.$to.pos;r.doc.nodesBetween(i,a,(e,r)=>{let o=Math.max(r,i),s=Math.min(r+e.nodeSize,a);e.marks.find(e=>e.type===c)?e.marks.forEach(e=>{c===e.type&&n.addMark(o,s,c.create({...e.attrs,...t}))}):n.addMark(o,s,c.create(t))})});return pU(r,n,c)},hU=(e,t)=>({tr:n})=>(n.setMeta(e,t),!0),gU=(e,t={})=>({state:n,dispatch:r,chain:i})=>{let a=iV(e,n.schema),o;return n.selection.$anchor.sameParent(n.selection.$head)&&(o=n.selection.$anchor.parent.attrs),a.isTextblock?i().command(({commands:e})=>zB(a,{...o,...t})(n)?!0:e.clearNodes()).command(({state:e})=>zB(a,{...o,...t})(e,r)).run():(console.warn(`[tiptap warn]: Currently "setNode()" only supports text block nodes.`),!1)},_U=e=>({tr:t,dispatch:n})=>{if(n){let{doc:n}=t,r=oH(e,0,n.content.size),i=Kp.create(n,r);t.setSelection(i)}return!0},vU=e=>({tr:t,dispatch:n})=>{if(n){let{doc:n}=t,{from:r,to:i}=typeof e==`number`?{from:e,to:e}:e,a=Wp.atStart(n).from,o=Wp.atEnd(n).to,s=oH(r,a,o),c=oH(i,a,o),l=Wp.create(n,s,c);t.setSelection(l)}return!0},yU=e=>({state:t,dispatch:n})=>ZB(iV(e,t.schema))(t,n);function bU(e,t){let n=e.storedMarks||e.selection.$to.parentOffset&&e.selection.$from.marks();if(n){let r=n.filter(e=>t?.includes(e.type.name));e.tr.ensureMarks(r)}}var xU=({keepMarks:e=!0}={})=>({tr:t,state:n,dispatch:r,editor:i})=>{let{selection:a,doc:o}=t,{$from:s,$to:c}=a,l=i.extensionManager.attributes,u=sU(l,s.node().type.name,s.node().attrs);if(a instanceof Kp&&a.node.isBlock)return!s.parentOffset||!dp(o,s.pos)?!1:(r&&(e&&bU(n,i.extensionManager.splittableMarks),t.split(s.pos).scrollIntoView()),!0);if(!s.parent.isBlock)return!1;let d=c.parentOffset===c.parent.content.size,f=s.depth===0?void 0:XH(s.node(-1).contentMatchAt(s.indexAfter(-1))),p=d&&f?[{type:f,attrs:u}]:void 0,m=dp(t.doc,t.mapping.map(s.pos),1,p);if(!p&&!m&&dp(t.doc,t.mapping.map(s.pos),1,f?[{type:f}]:void 0)&&(m=!0,p=f?[{type:f,attrs:u}]:void 0),r){if(m&&(a instanceof Wp&&t.deleteSelection(),t.split(t.mapping.map(s.pos),1,p),f&&!d&&!s.parentOffset&&s.parent.type!==f)){let e=t.mapping.map(s.before()),n=t.doc.resolve(e);s.node(-1).canReplaceWith(n.index(),n.index()+1,f)&&t.setNodeMarkup(t.mapping.map(s.before()),f)}e&&bU(n,i.extensionManager.splittableMarks),t.scrollIntoView()}return m},SU=(e,t={})=>({tr:n,state:r,dispatch:i,editor:a})=>{let o=iV(e,r.schema),{$from:s,$to:c}=r.selection,l=r.selection.node;if(l&&l.isBlock||s.depth<2||!s.sameParent(c))return!1;let u=s.node(-1);if(u.type!==o)return!1;let d=a.extensionManager.attributes;if(s.parent.content.size===0&&s.node(-1).childCount===s.indexAfter(-1)){if(s.depth===2||s.node(-3).type!==o||s.index(-2)!==s.node(-2).childCount-1)return!1;if(i){let e=Z.empty,r=s.index(-1)?1:s.index(-2)?2:3;for(let t=s.depth-r;t>=s.depth-3;--t)e=Z.from(s.node(t).copy(e));let i=s.indexAfter(-1)<s.node(-2).childCount?1:s.indexAfter(-2)<s.node(-3).childCount?2:3,a={...sU(d,s.node().type.name,s.node().attrs),...t},c=o.contentMatch.defaultType?.createAndFill(a)||void 0;e=e.append(Z.from(o.createAndFill(null,c)||void 0));let l=s.before(s.depth-(r-1));n.replace(l,s.after(-i),new Q(e,4-r,0));let u=-1;n.doc.nodesBetween(l,n.doc.content.size,(e,t)=>{if(u>-1)return!1;e.isTextblock&&e.content.size===0&&(u=t+1)}),u>-1&&n.setSelection(Wp.near(n.doc.resolve(u))),n.scrollIntoView()}return!0}let f=c.pos===s.end()?u.contentMatchAt(0).defaultType:null,p={...sU(d,u.type.name,u.attrs),...t},m={...sU(d,s.node().type.name,s.node().attrs),...t};n.delete(s.pos,c.pos);let h=f?[{type:o,attrs:p},{type:f,attrs:m}]:[{type:o,attrs:p}];if(!dp(n.doc,s.pos,2))return!1;if(i){let{selection:e,storedMarks:t}=r,{splittableMarks:o}=a.extensionManager,c=t||e.$to.parentOffset&&e.$from.marks();if(n.split(s.pos,2,h).scrollIntoView(),!c||!i)return!0;let l=c.filter(e=>o.includes(e.type.name));n.ensureMarks(l)}return!0},CU=(e,t)=>{let n=$H(e=>e.type===t)(e.selection);if(!n)return!0;let r=e.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(r===void 0)return!0;let i=e.doc.nodeAt(r);return n.node.type===i?.type&&pp(e.doc,n.pos)&&e.join(n.pos),!0},wU=(e,t)=>{let n=$H(e=>e.type===t)(e.selection);if(!n)return!0;let r=e.doc.resolve(n.start).after(n.depth);if(r===void 0)return!0;let i=e.doc.nodeAt(r);return n.node.type===i?.type&&pp(e.doc,r)&&e.join(r),!0},TU=Object.freeze({__proto__:null,blur:BV,clearContent:VV,clearNodes:HV,command:UV,createParagraphNear:WV,cut:GV,deleteCurrentNode:KV,deleteNode:qV,deleteRange:JV,deleteSelection:YV,enter:XV,exitCode:ZV,extendMarkRange:rH,first:iH,focus:dH,forEach:fH,insertContent:pH,insertContentAt:yH,joinBackward:SH,joinDown:xH,joinForward:CH,joinItemBackward:wH,joinItemForward:TH,joinTextblockBackward:EH,joinTextblockForward:DH,joinUp:bH,keyboardShortcut:AH,lift:MH,liftEmptyBlock:NH,liftListItem:PH,newlineInCode:FH,resetAttributes:RH,scrollIntoView:zH,selectAll:BH,selectNodeBackward:VH,selectNodeForward:HH,selectParentNode:UH,selectTextblockEnd:WH,selectTextblockStart:GH,setContent:qH,setMark:mU,setMeta:hU,setNode:gU,setNodeSelection:_U,setTextSelection:vU,sinkListItem:yU,splitBlock:xU,splitListItem:SU,toggleList:(e,t,n,r={})=>({editor:i,tr:a,state:o,dispatch:s,chain:c,commands:l,can:u})=>{let{extensions:d,splittableMarks:f}=i.extensionManager,p=iV(e,o.schema),m=iV(t,o.schema),{selection:h,storedMarks:g}=o,{$from:_,$to:v}=h,y=_.blockRange(v),b=g||h.$to.parentOffset&&h.$from.marks();if(!y)return!1;let x=$H(e=>uU(e.type.name,d))(h);if(y.depth>=1&&x&&y.depth-x.depth<=1){if(x.node.type===p)return l.liftListItem(m);if(uU(x.node.type.name,d)&&p.validContent(x.node.content)&&s)return c().command(()=>(a.setNodeMarkup(x.pos,p),!0)).command(()=>CU(a,p)).command(()=>wU(a,p)).run()}return!n||!b||!s?c().command(()=>u().wrapInList(p,r)?!0:l.clearNodes()).wrapInList(p,r).command(()=>CU(a,p)).command(()=>wU(a,p)).run():c().command(()=>{let e=u().wrapInList(p,r),t=b.filter(e=>f.includes(e.type.name));return a.ensureMarks(t),e?!0:l.clearNodes()}).wrapInList(p,r).command(()=>CU(a,p)).command(()=>wU(a,p)).run()},toggleMark:(e,t={},n={})=>({state:r,commands:i})=>{let{extendEmptyMarkRange:a=!1}=n,o=nH(e,r.schema);return cU(r,o,t)?i.unsetMark(o,{extendEmptyMarkRange:a}):i.setMark(o,t)},toggleNode:(e,t,n={})=>({state:r,commands:i})=>{let a=iV(e,r.schema),o=iV(t,r.schema),s=jH(r,a,n),c;return r.selection.$anchor.sameParent(r.selection.$head)&&(c=r.selection.$anchor.parent.attrs),s?i.setNode(o,c):i.setNode(a,{...c,...n})},toggleWrap:(e,t={})=>({state:n,commands:r})=>{let i=iV(e,n.schema);return jH(n,i,t)?r.lift(i):r.wrapIn(i,t)},undoInputRule:()=>({state:e,dispatch:t})=>{let n=e.plugins;for(let r=0;r<n.length;r+=1){let i=n[r],a;if(i.spec.isInputRules&&(a=i.getState(e))){if(t){let t=e.tr,n=a.transform;for(let e=n.steps.length-1;e>=0;--e)t.step(n.steps[e].invert(n.docs[e]));if(a.text){let n=t.doc.resolve(a.from).marks();t.replaceWith(a.from,a.to,e.schema.text(a.text,n))}else t.delete(a.from,a.to)}return!0}}return!1},unsetAllMarks:()=>({tr:e,dispatch:t})=>{let{selection:n}=e,{empty:r,ranges:i}=n;return r||t&&i.forEach(t=>{e.removeMark(t.$from.pos,t.$to.pos)}),!0},unsetMark:(e,t={})=>({tr:n,state:r,dispatch:i})=>{let{extendEmptyMarkRange:a=!1}=t,{selection:o}=n,s=nH(e,r.schema),{$from:c,empty:l,ranges:u}=o;if(!i)return!0;if(l&&a){let{from:e,to:t}=o,r=tH(c,s,c.marks().find(e=>e.type===s)?.attrs);r&&(e=r.from,t=r.to),n.removeMark(e,t,s)}else u.forEach(e=>{n.removeMark(e.$from.pos,e.$to.pos,s)});return n.removeStoredMark(s),!0},updateAttributes:(e,t={})=>({tr:n,state:r,dispatch:i})=>{let a=null,o=null,s=IH(typeof e==`string`?e:e.name,r.schema);return s?(s===`node`&&(a=iV(e,r.schema)),s===`mark`&&(o=nH(e,r.schema)),i&&n.selection.ranges.forEach(e=>{let i=e.$from.pos,s=e.$to.pos,c,l,u,d;n.selection.empty?r.doc.nodesBetween(i,s,(e,t)=>{a&&a===e.type&&(u=Math.max(t,i),d=Math.min(t+e.nodeSize,s),c=t,l=e)}):r.doc.nodesBetween(i,s,(e,r)=>{r<i&&a&&a===e.type&&(u=Math.max(r,i),d=Math.min(r+e.nodeSize,s),c=r,l=e),r>=i&&r<=s&&(a&&a===e.type&&n.setNodeMarkup(r,void 0,{...e.attrs,...t}),o&&e.marks.length&&e.marks.forEach(a=>{if(o===a.type){let c=Math.max(r,i),l=Math.min(r+e.nodeSize,s);n.addMark(c,l,o.create({...a.attrs,...t}))}}))}),l&&(c!==void 0&&n.setNodeMarkup(c,void 0,{...l.attrs,...t}),o&&l.marks.length&&l.marks.forEach(e=>{o===e.type&&n.addMark(u,d,o.create({...e.attrs,...t}))}))}),!0):!1},wrapIn:(e,t={})=>({state:n,dispatch:r})=>RB(iV(e,n.schema),t)(n,r),wrapInList:(e,t={})=>({state:n,dispatch:r})=>GB(iV(e,n.schema),t)(n,r)}),EU=IV.create({name:`commands`,addCommands(){return{...TU}}}),DU=IV.create({name:`drop`,addProseMirrorPlugins(){return[new cm({key:new dm(`tiptapDrop`),props:{handleDrop:(e,t,n,r)=>{this.editor.emit(`drop`,{editor:this.editor,event:t,slice:n,moved:r})}}})]}}),OU=IV.create({name:`editable`,addProseMirrorPlugins(){return[new cm({key:new dm(`editable`),props:{editable:()=>this.editor.options.editable}})]}}),kU=new dm(`focusEvents`),AU=IV.create({name:`focusEvents`,addProseMirrorPlugins(){let{editor:e}=this;return[new cm({key:kU,props:{handleDOMEvents:{focus:(t,n)=>{e.isFocused=!0;let r=e.state.tr.setMeta(`focus`,{event:n}).setMeta(`addToHistory`,!1);return t.dispatch(r),!1},blur:(t,n)=>{e.isFocused=!1;let r=e.state.tr.setMeta(`blur`,{event:n}).setMeta(`addToHistory`,!1);return t.dispatch(r),!1}}}})]}}),jU=IV.create({name:`keymap`,addKeyboardShortcuts(){let e=()=>this.editor.commands.first(({commands:e})=>[()=>e.undoInputRule(),()=>e.command(({tr:t})=>{let{selection:n,doc:r}=t,{empty:i,$anchor:a}=n,{pos:o,parent:s}=a,c=a.parent.isTextblock&&o>0?t.doc.resolve(o-1):a,l=c.parent.type.spec.isolating,u=a.pos-a.parentOffset,d=l&&c.parent.childCount===1?u===a.pos:Bp.atStart(r).from===o;return!i||!s.type.isTextblock||s.textContent.length||!d||d&&a.parent.type.name===`paragraph`?!1:e.clearNodes()}),()=>e.deleteSelection(),()=>e.joinBackward(),()=>e.selectNodeBackward()]),t=()=>this.editor.commands.first(({commands:e})=>[()=>e.deleteSelection(),()=>e.deleteCurrentNode(),()=>e.joinForward(),()=>e.selectNodeForward()]),n={Enter:()=>this.editor.commands.first(({commands:e})=>[()=>e.newlineInCode(),()=>e.createParagraphNear(),()=>e.liftEmptyBlock(),()=>e.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:e,"Mod-Backspace":e,"Shift-Backspace":e,Delete:t,"Mod-Delete":t,"Mod-a":()=>this.editor.commands.selectAll()},r={...n},i={...n,"Ctrl-h":e,"Alt-Backspace":e,"Ctrl-d":t,"Ctrl-Alt-Backspace":t,"Alt-Delete":t,"Alt-d":t,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return lH()||OH()?i:r},addProseMirrorPlugins(){return[new cm({key:new dm(`clearDocument`),appendTransaction:(e,t,n)=>{if(e.some(e=>e.getMeta(`composition`)))return;let r=e.some(e=>e.docChanged)&&!t.doc.eq(n.doc),i=e.some(e=>e.getMeta(`preventClearDocument`));if(!r||i)return;let{empty:a,from:o,to:s}=t.selection,c=Bp.atStart(t.doc).from,l=Bp.atEnd(t.doc).to;if(a||!(o===c&&s===l)||!dU(n.doc))return;let u=n.tr,d=QB({state:n,transaction:u}),{commands:f}=new $B({editor:this.editor,state:d});if(f.clearNodes(),u.steps.length)return u}})]}}),MU=IV.create({name:`paste`,addProseMirrorPlugins(){return[new cm({key:new dm(`tiptapPaste`),props:{handlePaste:(e,t,n)=>{this.editor.emit(`paste`,{editor:this.editor,event:t,slice:n})}}})]}}),NU=IV.create({name:`tabindex`,addProseMirrorPlugins(){return[new cm({key:new dm(`tabindex`),props:{attributes:()=>this.editor.isEditable?{tabindex:`0`}:{}}})]}}),PU=class e{get name(){return this.node.type.name}constructor(e,t,n=!1,r=null){this.currentNode=null,this.actualDepth=null,this.isBlock=n,this.resolvedPos=e,this.editor=t,this.currentNode=r}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){return this.actualDepth??this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let t=this.from,n=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}t=this.from+1,n=this.to-1}this.editor.commands.insertContentAt({from:t,to:n},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+ +!this.node.isText}get parent(){if(this.depth===0)return null;let t=this.resolvedPos.start(this.resolvedPos.depth-1);return new e(this.resolvedPos.doc.resolve(t),this.editor)}get before(){let t=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return t.depth!==this.depth&&(t=this.resolvedPos.doc.resolve(this.from-3)),new e(t,this.editor)}get after(){let t=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return t.depth!==this.depth&&(t=this.resolvedPos.doc.resolve(this.to+3)),new e(t,this.editor)}get children(){let t=[];return this.node.content.forEach((n,r)=>{let i=n.isBlock&&!n.isTextblock,a=n.isAtom&&!n.isText,o=this.pos+r+ +!a;if(o<0||o>this.resolvedPos.doc.nodeSize-2)return;let s=this.resolvedPos.doc.resolve(o);if(!i&&s.depth<=this.depth)return;let c=new e(s,this.editor,i,i?n:null);i&&(c.actualDepth=this.depth+1),t.push(new e(s,this.editor,i,i?n:null))}),t}get firstChild(){return this.children[0]||null}get lastChild(){let e=this.children;return e[e.length-1]||null}closest(e,t={}){let n=null,r=this.parent;for(;r&&!n;){if(r.node.type.name===e)if(Object.keys(t).length>0){let e=r.node.attrs,n=Object.keys(t);for(let r=0;r<n.length;r+=1){let i=n[r];if(e[i]!==t[i])break}}else n=r;r=r.parent}return n}querySelector(e,t={}){return this.querySelectorAll(e,t,!0)[0]||null}querySelectorAll(e,t={},n=!1){let r=[];if(!this.children||this.children.length===0)return r;let i=Object.keys(t);return this.children.forEach(a=>{n&&r.length>0||(a.node.type.name===e&&i.every(e=>t[e]===a.node.attrs[e])&&r.push(a),!(n&&r.length>0)&&(r=r.concat(a.querySelectorAll(e,t,n))))}),r}setAttribute(e){let{tr:t}=this.editor.state;t.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(t)}},FU=`.ProseMirror {
137
+ position: relative;
138
+ }
139
+
140
+ .ProseMirror {
141
+ word-wrap: break-word;
142
+ white-space: pre-wrap;
143
+ white-space: break-spaces;
144
+ -webkit-font-variant-ligatures: none;
145
+ font-variant-ligatures: none;
146
+ font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */
147
+ }
148
+
149
+ .ProseMirror [contenteditable="false"] {
150
+ white-space: normal;
151
+ }
152
+
153
+ .ProseMirror [contenteditable="false"] [contenteditable="true"] {
154
+ white-space: pre-wrap;
155
+ }
156
+
157
+ .ProseMirror pre {
158
+ white-space: pre-wrap;
159
+ }
160
+
161
+ img.ProseMirror-separator {
162
+ display: inline !important;
163
+ border: none !important;
164
+ margin: 0 !important;
165
+ width: 0 !important;
166
+ height: 0 !important;
167
+ }
168
+
169
+ .ProseMirror-gapcursor {
170
+ display: none;
171
+ pointer-events: none;
172
+ position: absolute;
173
+ margin: 0;
174
+ }
175
+
176
+ .ProseMirror-gapcursor:after {
177
+ content: "";
178
+ display: block;
179
+ position: absolute;
180
+ top: -2px;
181
+ width: 20px;
182
+ border-top: 1px solid black;
183
+ animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
184
+ }
185
+
186
+ @keyframes ProseMirror-cursor-blink {
187
+ to {
188
+ visibility: hidden;
189
+ }
190
+ }
191
+
192
+ .ProseMirror-hideselection *::selection {
193
+ background: transparent;
194
+ }
195
+
196
+ .ProseMirror-hideselection *::-moz-selection {
197
+ background: transparent;
198
+ }
199
+
200
+ .ProseMirror-hideselection * {
201
+ caret-color: transparent;
202
+ }
203
+
204
+ .ProseMirror-focused .ProseMirror-gapcursor {
205
+ display: block;
206
+ }
207
+
208
+ .tippy-box[data-animation=fade][data-state=hidden] {
209
+ opacity: 0
210
+ }`;function IU(e,t,n){let r=document.querySelector(`style[data-tiptap-style${n?`-${n}`:``}]`);if(r!==null)return r;let i=document.createElement(`style`);return t&&i.setAttribute(`nonce`,t),i.setAttribute(`data-tiptap-style${n?`-${n}`:``}`,``),i.innerHTML=e,document.getElementsByTagName(`head`)[0].appendChild(i),i}var LU=class extends eV{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:e})=>{throw e},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:e,slice:t,moved:n})=>this.options.onDrop(e,t,n)),this.on(`paste`,({event:e,slice:t})=>this.options.onPaste(e,t)),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=IU(FU,this.options.injectNonce))}setOptions(e={}){this.options={...this.options,...e},!(!this.view||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(e,t=!0){this.setOptions({editable:e}),t&&this.emit(`update`,{editor:this,transaction:this.state.tr})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get state(){return this.view.state}registerPlugin(e,t){let n=sV(t)?t(e,[...this.state.plugins]):[...this.state.plugins,e],r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}unregisterPlugin(e){if(this.isDestroyed)return;let t=this.state.plugins,n=t;if([].concat(e).forEach(e=>{let t=typeof e==`string`?`${e}$`:e.key;n=n.filter(e=>!e.key.startsWith(t))}),t.length===n.length)return;let r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}createExtensionManager(){let e=[...this.options.enableCoreExtensions?[OU,zV.configure({blockSeparator:this.options.coreExtensionOptions?.clipboardTextSerializer?.blockSeparator}),EU,AU,jU,NU,DU,MU].filter(e=>typeof this.options.enableCoreExtensions==`object`?this.options.enableCoreExtensions[e.name]!==!1:!0):[],...this.options.extensions].filter(e=>[`extension`,`node`,`mark`].includes(e?.type));this.extensionManager=new FV(e,this)}createCommandManager(){this.commandManager=new $B({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createView(){let e;try{e=KH(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(t){if(!(t instanceof Error)||![`[tiptap error]: Invalid JSON content`,`[tiptap error]: Invalid HTML content`].includes(t.message))throw t;this.emit(`contentError`,{editor:this,error:t,disableCollaboration:()=>{this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(e=>e.name!==`collaboration`),this.createExtensionManager()}}),e=KH(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}let t=sH(e,this.options.autofocus);this.view=new Bz(this.options.element,{...this.options.editorProps,attributes:{role:`textbox`,...this.options.editorProps?.attributes},dispatchTransaction:this.dispatchTransaction.bind(this),state:om.create({doc:e,selection:t||void 0})});let n=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(n),this.createNodeViews(),this.prependClass();let r=this.view.dom;r.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;let t=this.capturedTransaction;return this.capturedTransaction=null,t}dispatchTransaction(e){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=e;return}e.steps.forEach(e=>this.capturedTransaction?.step(e));return}let t=this.state.apply(e),n=!this.state.selection.eq(t.selection);this.emit(`beforeTransaction`,{editor:this,transaction:e,nextState:t}),this.view.updateState(t),this.emit(`transaction`,{editor:this,transaction:e}),n&&this.emit(`selectionUpdate`,{editor:this,transaction:e});let r=e.getMeta(`focus`),i=e.getMeta(`blur`);r&&this.emit(`focus`,{editor:this,event:r.event,transaction:e}),i&&this.emit(`blur`,{editor:this,event:i.event,transaction:e}),!(!e.docChanged||e.getMeta(`preventUpdate`))&&this.emit(`update`,{editor:this,transaction:e})}getAttributes(e){return nU(this.state,e)}isActive(e,t){let n=typeof e==`string`?e:null,r=typeof e==`string`?t:e;return lU(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return gV(this.state.doc.content,this.schema)}getText(e){let{blockSeparator:t=`
211
+
212
+ `,textSerializers:n={}}=e||{};return eU(this.state.doc,{blockSeparator:t,textSerializers:{...RV(this.schema),...n}})}get isEmpty(){return dU(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){let e=this.view.dom;e&&e.editor&&delete e.editor,this.view.destroy()}this.removeAllListeners()}get isDestroyed(){return!this.view?.docView}$node(e,t){return this.$doc?.querySelector(e,t)||null}$nodes(e,t){return this.$doc?.querySelectorAll(e,t)||null}$pos(e){return new PU(this.state.doc.resolve(e),this)}get $doc(){return this.$pos(0)}};function RU(e){return new yV({find:e.find,handler:({state:t,range:n,match:r})=>{let i=cV(e.getAttributes,void 0,r);if(i===!1||i===null)return null;let{tr:a}=t,o=r[r.length-1],s=r[0];if(o){let r=s.search(/\S/),c=n.from+s.indexOf(o),l=c+o.length;if(oU(n.from,n.to,t.doc).filter(t=>t.mark.type.excluded.find(n=>n===e.type&&n!==t.mark.type)).filter(e=>e.to>c).length)return null;l<n.to&&a.delete(l,n.to),c>n.from&&a.delete(n.from+r,c);let u=n.from+r+o.length;a.addMark(n.from+r,u,e.type.create(i||{})),a.removeStoredMark(e.type)}}})}function zU(e){return new yV({find:e.find,handler:({state:t,range:n,match:r})=>{let i=cV(e.getAttributes,void 0,r)||{},{tr:a}=t,o=n.from,s=n.to,c=e.type.create(i);if(r[1]){let e=o+r[0].lastIndexOf(r[1]);e>s?e=s:s=e+r[1].length;let t=r[0][r[0].length-1];a.insertText(t,o+r[0].length-1),a.replaceWith(e,s,c)}else if(r[0]){let t=e.type.isInline?o:o-1;a.insert(t,e.type.create(i)).delete(a.mapping.map(o),a.mapping.map(s))}a.scrollIntoView()}})}function BU(e){return new yV({find:e.find,handler:({state:t,range:n,match:r})=>{let i=t.doc.resolve(n.from),a=cV(e.getAttributes,void 0,r)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),e.type))return null;t.tr.delete(n.from,n.to).setBlockType(n.from,n.from,e.type,a)}})}function VU(e){return new yV({find:e.find,handler:({state:t,range:n,match:r})=>{let i=e.replace,a=n.from,o=n.to;if(r[1]){let e=r[0].lastIndexOf(r[1]);i+=r[0].slice(e+r[1].length),a+=e;let t=a-o;t>0&&(i=r[0].slice(e-t,e)+i,a=o)}t.tr.insertText(i,a,o)}})}function HU(e){return new yV({find:e.find,handler:({state:t,range:n,match:r,chain:i})=>{let a=cV(e.getAttributes,void 0,r)||{},o=t.tr.delete(n.from,n.to),s=o.doc.resolve(n.from).blockRange(),c=s&&tp(s,e.type,a);if(!c)return null;if(o.wrap(s,c),e.keepMarks&&e.editor){let{selection:n,storedMarks:r}=t,{splittableMarks:i}=e.editor.extensionManager,a=r||n.$to.parentOffset&&n.$from.marks();if(a){let e=a.filter(e=>i.includes(e.type.name));o.ensureMarks(e)}}if(e.keepAttributes){let t=e.type.name===`bulletList`||e.type.name===`orderedList`?`listItem`:`taskList`;i().updateAttributes(t,a).run()}let l=o.doc.resolve(n.from-1).nodeBefore;l&&l.type===e.type&&pp(o.doc,n.from-1)&&(!e.joinPredicate||e.joinPredicate(r,l))&&o.join(n.from-1)}})}var UU=class e{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=cV(tV(this,`addOptions`,{name:this.name}))),this.storage=cV(tV(this,`addStorage`,{name:this.name,options:this.options}))||{}}static create(t={}){return new e(t)}configure(e={}){let t=this.extend({...this.config,addOptions:()=>TV(this.options,e)});return t.name=this.name,t.parent=this.parent,t}extend(t={}){let n=new e(t);return n.parent=this,this.child=n,n.name=t.name?t.name:n.parent.name,t.defaultOptions&&Object.keys(t.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${n.name}".`),n.options=cV(tV(n,`addOptions`,{name:n.name})),n.storage=cV(tV(n,`addStorage`,{name:n.name,options:n.options})),n}};function WU(e){return new OV({find:e.find,handler:({state:t,range:n,match:r,pasteEvent:i})=>{let a=cV(e.getAttributes,void 0,r,i);if(a===!1||a===null)return null;let{tr:o}=t,s=r[r.length-1],c=r[0],l=n.to;if(s){let r=c.search(/\S/),i=n.from+c.indexOf(s),u=i+s.length;if(oU(n.from,n.to,t.doc).filter(t=>t.mark.type.excluded.find(n=>n===e.type&&n!==t.mark.type)).filter(e=>e.to>i).length)return null;u<n.to&&o.delete(u,n.to),i>n.from&&o.delete(n.from+r,i),l=n.from+r+s.length,o.addMark(n.from+r,l,e.type.create(a||{})),o.removeStoredMark(e.type)}}})}function GU(e,t){let{selection:n}=e,{$from:r}=n;if(n instanceof Kp){let e=r.index();return r.parent.canReplaceWith(e,e+1,t)}let i=r.depth;for(;i>=0;){let e=r.index(i);if(r.node(i).contentMatchAt(e).matchType(t))return!0;--i}return!1}var KU=()=>{let e=!0;return(t,n)=>{if(e){e=!1;try{t()}finally{e=!0}}else n!==void 0&&n()}},qU=/[\uD800-\uDBFF]/,JU=/[\uDC00-\uDFFF]/,YU=(e,t)=>{let n=0,r=0;for(;n<e.length&&n<t.length&&e[n]===t[n];)n++;for(n>0&&qU.test(e[n-1])&&n--;r+n<e.length&&r+n<t.length&&e[e.length-r-1]===t[t.length-r-1];)r++;return r>0&&JU.test(e[e.length-r])&&r--,{index:n,remove:e.length-n-r,insert:t.slice(n,t.length-r)}},XU=new dm(`y-sync`),ZU=new dm(`y-undo`),QU=new dm(`yjs-cursor`),$U=(e,t)=>e>>>t|e<<32-t,eW=e=>$U(e,2)^$U(e,13)^$U(e,22),tW=e=>$U(e,6)^$U(e,11)^$U(e,25),nW=e=>$U(e,7)^$U(e,18)^e>>>3,rW=e=>$U(e,17)^$U(e,19)^e>>>10,iW=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]),aW=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),oW=class{constructor(){let e=new ArrayBuffer(320);this._H=new Uint32Array(e,0,8),this._H.set(aW),this._W=new Uint32Array(e,64,64)}_updateHash(){let e=this._H,t=this._W;for(let e=16;e<64;e++)t[e]=rW(t[e-2])+t[e-7]+nW(t[e-15])+t[e-16];let n=e[0],r=e[1],i=e[2],a=e[3],o=e[4],s=e[5],c=e[6],l=e[7];for(let e=0,u,d;e<64;e++)u=l+tW(o)+(o&s^~o&c)+iW[e]+t[e]>>>0,d=eW(n)+(n&r^n&i^r&i)>>>0,l=c,c=s,s=o,o=a+u>>>0,a=i,i=r,r=n,n=u+d>>>0;e[0]+=n,e[1]+=r,e[2]+=i,e[3]+=a,e[4]+=o,e[5]+=s,e[6]+=c,e[7]+=l}digest(e){let t=0;for(;t+56<=e.length;){let n=0;for(;n<16&&t+3<e.length;n++)this._W[n]=e[t++]<<24|e[t++]<<16|e[t++]<<8|e[t++];if(t%64!=0){for(this._W.fill(0,n,16);t<e.length;)this._W[n]|=e[t]<<(3-t%4)*8,t++;this._W[n]|=128<<(3-t%4)*8}this._updateHash()}let n=t%64!=0;this._W.fill(0,0,16);let r=0;for(;t<e.length;r++)for(let n=3;n>=0&&t<e.length;n--)this._W[r]|=e[t++]<<n*8;n||(this._W[r-(t%4==0?0:1)]|=128<<(3-t%4)*8),this._W[14]=e.byteLength/Ry,this._W[15]=e.byteLength*8,this._updateHash();let i=new Uint8Array(32);for(let e=0;e<this._H.length;e++)for(let t=0;t<4;t++)i[e*4+t]=this._H[e]>>>(3-t)*8;return i}},sW=e=>new oW().digest(e),cW=e=>{for(let t=6;t<e.length;t++)e[t%6]=e[t%6]^e[t];return e.slice(0,6)},lW=e=>Nx(cW(sW(Fx(e)))),uW=(e,t)=>t===void 0?!e.deleted:t.sv.has(e.id.client)&&t.sv.get(e.id.client)>e.id.clock&&!DC(t.ds,e.id),dW=[{light:`#ecd44433`,dark:`#ecd444`}],fW=(e,t,n)=>{if(!e.has(n)){if(e.size<t.length){let n=fy();e.forEach(e=>n.add(e)),t=t.filter(e=>!n.has(e))}e.set(n,Zb(t))}return e.get(n)},pW=(e,{colors:t=dW,colorMapping:n=new Map,permanentUserData:r=null,onFirstRender:i=()=>{},mapping:a}={})=>{let o=!1,s=new gW(e,a),c=new cm({props:{editable:e=>{let t=XU.getState(e);return t.snapshot==null&&t.prevSnapshot==null}},key:XU,state:{init:(i,a)=>({type:e,doc:e.doc,binding:s,snapshot:null,prevSnapshot:null,isChangeOrigin:!1,isUndoRedoOperation:!1,addToHistory:!0,colors:t,colorMapping:n,permanentUserData:r}),apply:(e,t)=>{let n=e.getMeta(XU);if(n!==void 0){t=Object.assign({},t);for(let e in n)t[e]=n[e]}return t.addToHistory=e.getMeta(`addToHistory`)!==!1,t.isChangeOrigin=n!==void 0&&!!n.isChangeOrigin,t.isUndoRedoOperation=n!==void 0&&!!n.isChangeOrigin&&!!n.isUndoRedoOperation,s.prosemirrorView!==null&&n!==void 0&&(n.snapshot!=null||n.prevSnapshot!=null)&&rC(0,()=>{s.prosemirrorView!=null&&(n.restore==null?s._renderSnapshot(n.snapshot,n.prevSnapshot,t):(s._renderSnapshot(n.snapshot,n.snapshot,t),delete t.restore,delete t.snapshot,delete t.prevSnapshot,s.mux(()=>{s._prosemirrorChanged(s.prosemirrorView.state.doc)})))}),t}},view:e=>(s.initView(e),a??s._forceRerender(),i(),{update:()=>{let t=c.getState(e.state);if(t.snapshot==null&&t.prevSnapshot==null&&(o||e.state.doc.content.findDiffStart(e.state.doc.type.createAndFill().content)!==null)){if(o=!0,t.addToHistory===!1&&!t.isChangeOrigin){let t=ZU.getState(e.state),n=t&&t.undoManager;n&&n.stopCapturing()}s.mux(()=>{t.doc.transact(n=>{n.meta.set(`addToHistory`,t.addToHistory),s._prosemirrorChanged(e.state.doc)},XU)})}},destroy:()=>{s.destroy()}})});return c},mW=(e,t,n)=>{if(t!==null&&t.anchor!==null&&t.head!==null)if(t.type===`all`)e.setSelection(new Jp(e.doc));else if(t.type===`node`){let r=UW(n.doc,n.type,t.anchor,n.mapping);e.setSelection(Kp.create(e.doc,r))}else{let r=UW(n.doc,n.type,t.anchor,n.mapping),i=UW(n.doc,n.type,t.head,n.mapping);if(r!==null&&i!==null){let t=Wp.between(e.doc.resolve(r),e.doc.resolve(i));e.setSelection(t)}}},hW=(e,t)=>({type:t.selection.jsonID,anchor:VW(t.selection.anchor,e.type,e.mapping),head:VW(t.selection.head,e.type,e.mapping)}),gW=class{constructor(e,t=new Map){this.type=e,this.prosemirrorView=null,this.mux=KU(),this.mapping=t,this.isOMark=new Map,this._observeFunction=this._typeChanged.bind(this),this.doc=e.doc,this.beforeTransactionSelection=null,this.beforeAllTransactions=()=>{this.beforeTransactionSelection===null&&this.prosemirrorView!=null&&(this.beforeTransactionSelection=hW(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()?(Cx&&this._domSelectionInView===null&&(rC(0,()=>{this._domSelectionInView=null}),this._domSelectionInView=this._isDomSelectionInView()),this._domSelectionInView):!1}_isDomSelectionInView(){let e=this.prosemirrorView._root.getSelection();if(e==null||e.anchorNode==null)return!1;let t=this.prosemirrorView._root.createRange();t.setStart(e.anchorNode,e.anchorOffset),t.setEnd(e.focusNode,e.focusOffset),t.getClientRects().length===0&&t.startContainer&&t.collapsed&&t.selectNodeContents(t.startContainer);let n=t.getBoundingClientRect(),r=XS.documentElement;return n.bottom>=0&&n.right>=0&&n.left<=(window.innerWidth||r.clientWidth||0)&&n.top<=(window.innerHeight||r.clientHeight||0)}renderSnapshot(e,t){t||=kw(jC(),new Map),this.prosemirrorView.dispatch(this._tr.setMeta(XU,{snapshot:e,prevSnapshot:t}))}unrenderSnapshot(){this.mapping.clear(),this.mux(()=>{let e=this.type.toArray().map(e=>vW(e,this.prosemirrorView.state.schema,this)).filter(e=>e!==null),t=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new Q(Z.from(e),0,0));t.setMeta(XU,{snapshot:null,prevSnapshot:null}),this.prosemirrorView.dispatch(t)})}_forceRerender(){this.mapping.clear(),this.mux(()=>{let e=this.beforeTransactionSelection===null?this.prosemirrorView.state.selection:null,t=this.type.toArray().map(e=>vW(e,this.prosemirrorView.state.schema,this)).filter(e=>e!==null),n=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new Q(Z.from(t),0,0));if(e){let t=Cy(wy(e.anchor,0),n.doc.content.size),r=Cy(wy(e.head,0),n.doc.content.size);n.setSelection(Wp.create(n.doc,t,r))}this.prosemirrorView.dispatch(n.setMeta(XU,{isChangeOrigin:!0,binding:this}))})}_renderSnapshot(e,t,n){let r=this.doc,i=this.type;if(e||=Aw(this.doc),e instanceof Uint8Array||t instanceof Uint8Array)if((!(e instanceof Uint8Array)||!(t instanceof Uint8Array))&&kb(),r=new LC({gc:!1}),QC(r,t),t=Aw(r),QC(r,e),e=Aw(r),i._item===null){let e=Array.from(this.doc.share.keys()).find(e=>this.doc.share.get(e)===this.type);i=r.getXmlFragment(e)}else{let e=r.store.clients.get(i._item.id.client)??[];i=e[Lw(e,i._item.id.clock)].content.type}this.mapping.clear(),this.mux(()=>{r.transact(r=>{let a=n.permanentUserData;a&&a.dss.forEach(e=>{TC(r,e,e=>{})});let o=(e,t)=>{let r=e===`added`?a.getUserByClientId(t.client):a.getUserByDeletedId(t);return{user:r,type:e,color:fW(n.colorMapping,n.colors,r)}},s=AT(i,new Ow(t.ds,e.sv)).map(n=>!n._item.deleted||uW(n._item,e)||uW(n._item,t)?vW(n,this.prosemirrorView.state.schema,{mapping:new Map,isOMark:new Map},e,t,o):null).filter(e=>e!==null),c=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new Q(Z.from(s),0,0));this.prosemirrorView.dispatch(c.setMeta(XU,{isChangeOrigin:!0}))},XU)})}_typeChanged(e,t){if(this.prosemirrorView==null)return;let n=XU.getState(this.prosemirrorView.state);if(e.length===0||n.snapshot!=null||n.prevSnapshot!=null){this.renderSnapshot(n.snapshot,n.prevSnapshot);return}this.mux(()=>{let e=(e,t)=>this.mapping.delete(t);TC(t,t.deleteSet,e=>{if(e.constructor===lD){let t=e.content.type;t&&this.mapping.delete(t)}}),t.changed.forEach(e),t.changedParentTypes.forEach(e);let n=this.type.toArray().map(e=>_W(e,this.prosemirrorView.state.schema,this)).filter(e=>e!==null),r=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new Q(Z.from(n),0,0));mW(r,this.beforeTransactionSelection,this),r=r.setMeta(XU,{isChangeOrigin:!0,isUndoRedoOperation:t.origin instanceof tT}),this.beforeTransactionSelection!==null&&this._isLocalCursorInView()&&r.scrollIntoView(),this.prosemirrorView.dispatch(r)})}_prosemirrorChanged(e){this.doc.transact(()=>{IW(this.doc,this.type,e,this),this.beforeTransactionSelection=hW(this,this.prosemirrorView.state)},XU)}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))}},_W=(e,t,n,r,i,a)=>{let o=n.mapping.get(e);if(o===void 0){if(e instanceof bE)return vW(e,t,n,r,i,a);throw Ob()}return o},vW=(e,t,n,r,i,a)=>{let o=[],s=e=>{if(e instanceof bE){let s=_W(e,t,n,r,i,a);s!==null&&o.push(s)}else{let s=e._item.right?.content?.type;s instanceof hE&&!s._item.deleted&&s._item.id.client===s.doc.clientID&&(e.applyDelta([{retain:e.length},...s.toDelta()]),s.doc.transact(e=>{s._item.delete(e)}));let c=yW(e,t,n,r,i,a);c!==null&&c.forEach(e=>{e!==null&&o.push(e)})}};r===void 0||i===void 0?e.toArray().forEach(s):AT(e,new Ow(i.ds,r.sv)).forEach(s);try{let s=e.getAttributes(r);r!==void 0&&(uW(e._item,r)?uW(e._item,i)||(s.ychange=a?a(`added`,e._item.id):{type:`added`}):s.ychange=a?a(`removed`,e._item.id):{type:`removed`});let c=t.node(e.nodeName,s,o);return n.mapping.set(e,c),c}catch{return e.doc.transact(t=>{e._item.delete(t)},XU),n.mapping.delete(e),null}},yW=(e,t,n,r,i,a)=>{let o=[],s=e.toDelta(r,i,a);try{for(let e=0;e<s.length;e++){let n=s[e];o.push(t.text(n.insert,PW(n.attributes,t)))}}catch{return e.doc.transact(t=>{e._item.delete(t)},XU),null}return o},bW=(e,t)=>{let n=new TE,r=e.map(e=>({insert:e.text,attributes:FW(e.marks,t)}));return n.applyDelta(r),t.mapping.set(n,e),n},xW=(e,t)=>{let n=new bE(e.type.name);for(let t in e.attrs){let r=e.attrs[t];r!==null&&t!==`ychange`&&n.setAttribute(t,r)}return n.insert(0,TW(e).map(e=>SW(e,t))),t.mapping.set(n,e),n},SW=(e,t)=>e instanceof Array?bW(e,t):xW(e,t),CW=e=>typeof e==`object`&&!!e,wW=(e,t)=>{let n=Object.keys(e).filter(t=>e[t]!==null),r=n.length===(t==null?0:Object.keys(t).filter(e=>t[e]!==null).length);for(let i=0;i<n.length&&r;i++){let a=n[i],o=e[a],s=t[a];r=a===`ychange`||o===s||CW(o)&&CW(s)&&wW(o,s)}return r},TW=e=>{let t=e.content.content,n=[];for(let e=0;e<t.length;e++){let r=t[e];if(r.isText){let r=[];for(let n=t[e];e<t.length&&n.isText;n=t[++e])r.push(n);e--,n.push(r)}else n.push(r)}return n},EW=(e,t)=>{let n=e.toDelta();return n.length===t.length&&n.every((e,n)=>e.insert===t[n].text&&lx(e.attributes||{}).length===t[n].marks.length&&px(e.attributes,(e,r)=>{let i=NW(r),a=t[n].marks;return wW(e,a.find(e=>e.type.name===i)?.attrs)}))},DW=(e,t)=>{if(e instanceof bE&&!(t instanceof Array)&&LW(e,t)){let n=TW(t);return e._length===n.length&&wW(e.getAttributes(),t.attrs)&&e.toArray().every((e,t)=>DW(e,n[t]))}return e instanceof TE&&t instanceof Array&&EW(e,t)},OW=(e,t)=>e===t||e instanceof Array&&t instanceof Array&&e.length===t.length&&e.every((e,n)=>t[n]===e),kW=(e,t,n)=>{let r=e.toArray(),i=TW(t),a=i.length,o=r.length,s=Cy(o,a),c=0,l=0,u=!1;for(;c<s;c++){let e=r[c],t=i[c];if(OW(n.mapping.get(e),t))u=!0;else if(!DW(e,t))break}for(;c+l<s;l++){let e=r[o-l-1],t=i[a-l-1];if(OW(n.mapping.get(e),t))u=!0;else if(!DW(e,t))break}return{equalityFactor:c+l,foundMappedChild:u}},AW=e=>{let t=``,n=e._start,r={};for(;n!==null;)n.deleted||(n.countable&&n.content instanceof KE?t+=n.content.str:n.content instanceof zE&&(r[n.content.key]=null)),n=n.right;return{str:t,nAttrs:r}},jW=(e,t,n)=>{n.mapping.set(e,t);let{nAttrs:r,str:i}=AW(e),a=t.map(e=>({insert:e.text,attributes:Object.assign({},r,FW(e.marks,n))})),{insert:o,remove:s,index:c}=YU(i,a.map(e=>e.insert).join(``));e.delete(c,s),e.insert(c,o),e.applyDelta(a.map(e=>({retain:e.insert.length,attributes:e.attributes})))},MW=/(.*)(--[a-zA-Z0-9+/=]{8})$/,NW=e=>MW.exec(e)?.[1]??e,PW=(e,t)=>{let n=[];for(let r in e)n.push(t.mark(NW(r),e[r]));return n},FW=(e,t)=>{let n={};return e.forEach(e=>{if(e.type.name!==`ychange`){let r=ly(t.isOMark,e.type,()=>!e.type.excludes(e.type));n[r?`${e.type.name}--${lW(e.toJSON())}`:e.type.name]=e.attrs}}),n},IW=(e,t,n,r)=>{if(t instanceof bE&&t.nodeName!==n.type.name)throw Error(`node name mismatch!`);if(r.mapping.set(t,n),t instanceof bE){let e=t.getAttributes(),r=n.attrs;for(let n in r)r[n]===null?t.removeAttribute(n):e[n]!==r[n]&&n!==`ychange`&&t.setAttribute(n,r[n]);for(let n in e)r[n]===void 0&&t.removeAttribute(n)}let i=TW(n),a=i.length,o=t.toArray(),s=o.length,c=Cy(a,s),l=0,u=0;for(;l<c;l++){let e=o[l],t=i[l];if(!OW(r.mapping.get(e),t))if(DW(e,t))r.mapping.set(e,t);else break}for(;u+l<c;u++){let e=o[s-u-1],t=i[a-u-1];if(!OW(r.mapping.get(e),t))if(DW(e,t))r.mapping.set(e,t);else break}e.transact(()=>{for(;s-l-u>0&&a-l-u>0;){let n=o[l],c=i[l],d=o[s-u-1],f=i[a-u-1];if(n instanceof TE&&c instanceof Array)EW(n,c)||jW(n,c,r),l+=1;else{let i=n instanceof bE&&LW(n,c),a=d instanceof bE&&LW(d,f);if(i&&a){let e=kW(n,c,r),t=kW(d,f,r);e.foundMappedChild&&!t.foundMappedChild?a=!1:!e.foundMappedChild&&t.foundMappedChild||e.equalityFactor<t.equalityFactor?i=!1:a=!1}i?(IW(e,n,c,r),l+=1):a?(IW(e,d,f,r),u+=1):(r.mapping.delete(t.get(l)),t.delete(l,1),t.insert(l,[SW(c,r)]),l+=1)}}let n=s-l-u;if(s===1&&a===0&&o[0]instanceof TE?(r.mapping.delete(o[0]),o[0].delete(0,o[0].length)):n>0&&(t.slice(l,l+n).forEach(e=>r.mapping.delete(e)),t.delete(l,n)),l+u<a){let e=[];for(let t=l;t<a-u;t++)e.push(SW(i[t],r));t.insert(l,e)}},XU)},LW=(e,t)=>!(t instanceof Array)&&e.nodeName===t.type.name,RW=null,zW=()=>{let e=RW;RW=null,e.forEach((e,t)=>{let n=t.state.tr,r=XU.getState(t.state);r&&r.binding&&!r.binding.isDestroyed&&(e.forEach((e,t)=>{n.setMeta(t,e)}),t.dispatch(n))})},BW=(e,t,n)=>{RW||(RW=new Map,rC(0,zW)),ly(RW,e,sy).set(t,n)},VW=(e,t,n)=>{if(e===0)return ww(t,0,t.length===0?-1:0);let r=t._first===null?null:t._first.content.type;for(;r!==null&&t!==r;){if(r instanceof TE){if(r._length>=e)return ww(r,e,t.length===0?-1:0);if(e-=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,e--;while(r!==t&&r!==null&&r._item!==null&&r._item.next===null);r!==null&&r!==t&&(r=r._item===null?null:r._item.next.content.type)}}else{let i=(n.get(r)||{nodeSize:0}).nodeSize;if(r._first!==null&&e<i)r=r._first.content.type,e--;else{if(e===1&&r._length===0&&i>1)return new yw(r._item===null?null:r._item.id,r._item===null?_w(r):null,null);if(e-=i,r._item!==null&&r._item.next!==null)r=r._item.next.content.type;else{if(e===0)return r=r._item===null?r:r._item.parent,new yw(r._item===null?null:r._item.id,r._item===null?_w(r):null,null);do r=r._item.parent,e--;while(r!==t&&r._item.next===null);r!==t&&(r=r._item.next.content.type)}}}if(r===null)throw kb();if(e===0&&r.constructor!==TE&&r!==t)return HW(r._item.parent,r._item)}return ww(t,t._length,t.length===0?-1:0)},HW=(e,t)=>{let n=null,r=null;return e._item===null?r=_w(e):n=gw(e._item.id.client,e._item.id.clock),new yw(n,r,t.id)},UW=(e,t,n,r)=>{let i=Ew(n,e);if(i===null||i.type!==t&&!vw(t,i.type._item))return null;let a=i.type,o=0;if(a.constructor===TE)o=i.index;else if(a._item===null||!a._item.deleted){let e=a._first,t=0;for(;t<a._length&&t<i.index&&e!==null;){if(!e.deleted){let n=e.content.type;t++,n instanceof TE?o+=n._length:o+=r.get(n).nodeSize}e=e.right}o+=1}for(;a!==t&&a._item!==null;){let e=a._item.parent;if(e._item===null||!e._item.deleted){o+=1;let t=e._first;for(;t!==null;){let e=t.content.type;if(e===a)break;t.deleted||(e instanceof TE?o+=e._length:o+=r.get(e).nodeSize),t=t.right}}a=e}return o-1};function WW(e){let t=e.toArray(),n=e=>{let t;if(e instanceof TE)t=e.toDelta().map(e=>{let t={type:`text`,text:e.insert};return e.attributes&&(t.marks=Object.keys(e.attributes).map(t=>{let n=e.attributes[t],r={type:NW(t)};return Object.keys(n)&&(r.attrs=n),r})),t});else if(e instanceof bE){t={type:e.nodeName};let r=e.getAttributes();Object.keys(r).length&&(t.attrs=r);let i=e.toArray();i.length&&(t.content=i.map(n).flat())}else kb();return t};return{type:`doc`,content:t.map(n)}}var GW=(e,t,n)=>e!==t,KW=e=>{let t=document.createElement(`span`);t.classList.add(`ProseMirror-yjs-cursor`),t.setAttribute(`style`,`border-color: ${e.color}`);let n=document.createElement(`div`);n.setAttribute(`style`,`background-color: ${e.color}`),n.insertBefore(document.createTextNode(e.name),null);let r=document.createTextNode(`⁠`),i=document.createTextNode(`⁠`);return t.insertBefore(r,null),t.insertBefore(n,null),t.insertBefore(i,null),t},qW=e=>({style:`background-color: ${e.color}70`,class:`ProseMirror-yjs-selection`}),JW=/^#[0-9a-fA-F]{6}$/,YW=(e,t,n,r,i)=>{let a=XU.getState(e),o=a.doc,s=[];return a.snapshot!=null||a.prevSnapshot!=null||a.binding.mapping.size===0?oz.create(e.doc,[]):(t.getStates().forEach((t,c)=>{if(n(o.clientID,c,t)&&t.cursor!=null){let n=t.user||{};n.color==null?n.color=`#ffa500`:JW.test(n.color)||console.warn(`A user uses an unsupported color format`,n),n.name??=`User: ${c}`;let l=UW(o,a.type,bw(t.cursor.anchor),a.binding.mapping),u=UW(o,a.type,bw(t.cursor.head),a.binding.mapping);if(l!==null&&u!==null){let t=wy(e.doc.content.size-1,0);l=Cy(l,t),u=Cy(u,t),s.push(rz.widget(u,()=>r(n,c),{key:c+``,side:10}));let a=Cy(l,u),o=wy(l,u);s.push(rz.inline(a,o,i(n,c),{inclusiveEnd:!0,inclusiveStart:!1}))}}}),oz.create(e.doc,s))},XW=(e,{awarenessStateFilter:t=GW,cursorBuilder:n=KW,selectionBuilder:r=qW,getSelection:i=e=>e.selection}={},a=`cursor`)=>new cm({key:QU,state:{init(i,a){return YW(a,e,t,n,r)},apply(i,a,o,s){let c=XU.getState(s),l=i.getMeta(QU);return c&&c.isChangeOrigin||l&&l.awarenessUpdated?YW(s,e,t,n,r):a.map(i.mapping,i.doc)}},props:{decorations:e=>QU.getState(e)},view:t=>{let n=()=>{t.docView&&BW(t,QU,{awarenessUpdated:!0})},r=()=>{let n=XU.getState(t.state),r=e.getLocalState()||{};if(t.hasFocus()){let o=i(t.state),s=VW(o.anchor,n.type,n.binding.mapping),c=VW(o.head,n.type,n.binding.mapping);(r.cursor==null||!Dw(bw(r.cursor.anchor),s)||!Dw(bw(r.cursor.head),c))&&e.setLocalStateField(a,{anchor:s,head:c})}else r.cursor!=null&&UW(n.doc,n.type,bw(r.cursor.anchor),n.binding.mapping)!==null&&e.setLocalStateField(a,null)};return e.on(`change`,n),t.dom.addEventListener(`focusin`,r),t.dom.addEventListener(`focusout`,r),{update:r,destroy:()=>{t.dom.removeEventListener(`focusin`,r),t.dom.removeEventListener(`focusout`,r),e.off(`change`,n),e.setLocalStateField(a,null)}}}}),ZW=e=>ZU.getState(e)?.undoManager?.undo()!=null,QW=e=>ZU.getState(e)?.undoManager?.redo()!=null,$W=new Set([`paragraph`]),eG=(e,t)=>!(e instanceof lD)||!(e.content instanceof nD)||!(e.content.type instanceof hE||e.content.type instanceof bE&&t.has(e.content.type.nodeName))||e.content.type._length===0,tG=({protectedNodes:e=$W,trackedOrigins:t=[],undoManager:n=null}={})=>new cm({key:ZU,state:{init:(r,i)=>{let a=XU.getState(i),o=n||new tT(a.type,{trackedOrigins:new Set([XU].concat(t)),deleteFilter:t=>eG(t,e),captureTransaction:e=>e.meta.get(`addToHistory`)!==!1});return{undoManager:o,prevSel:null,hasUndoOps:o.undoStack.length>0,hasRedoOps:o.redoStack.length>0}},apply:(e,t,n,r)=>{let i=XU.getState(r).binding,a=t.undoManager,o=a.undoStack.length>0,s=a.redoStack.length>0;return i?{undoManager:a,prevSel:hW(i,n),hasUndoOps:o,hasRedoOps:s}:o!==t.hasUndoOps||s!==t.hasRedoOps?Object.assign({},t,{hasUndoOps:a.undoStack.length>0,hasRedoOps:a.redoStack.length>0}):t}},view:e=>{let t=XU.getState(e.state),n=ZU.getState(e.state).undoManager;return n.on(`stack-item-added`,({stackItem:n})=>{let r=t.binding;r&&n.meta.set(r,ZU.getState(e.state).prevSel)}),n.on(`stack-item-popped`,({stackItem:e})=>{let n=t.binding;n&&(n.beforeTransactionSelection=e.meta.get(n)||n.beforeTransactionSelection)}),{destroy:()=>{n.destroy()}}}}),nG=IV.create({name:`collaboration`,priority:1e3,addOptions(){return{document:null,field:`default`,fragment:null}},addStorage(){return{isDisabled:!1}},onCreate(){this.editor.extensionManager.extensions.find(e=>e.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:e,state:t,dispatch:n})=>(e.setMeta(`preventDispatch`,!0),ZU.getState(t).undoManager.undoStack.length===0?!1:n?ZW(t):!0),redo:()=>({tr:e,state:t,dispatch:n})=>(e.setMeta(`preventDispatch`,!0),ZU.getState(t).undoManager.redoStack.length===0?!1:n?QW(t):!0)}},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Mod-y":()=>this.editor.commands.redo(),"Shift-Mod-z":()=>this.editor.commands.redo()}},addProseMirrorPlugins(){var e;let t=this.options.fragment?this.options.fragment:this.options.document.getXmlFragment(this.options.field),n=tG(this.options.yUndoOptions),r=n.spec.view;n.spec.view=e=>{let{undoManager:t}=ZU.getState(e.state);t.restore&&=(t.restore(),()=>{});let n=r?r(e):void 0;return{destroy:()=>{let e=t.trackedOrigins.has(t),r=t._observers;t.restore=()=>{e&&t.trackedOrigins.add(t),t.doc.on(`afterTransaction`,t.afterTransactionHandler),t._observers=r},n?.destroy&&n.destroy()}}};let i=pW(t,{...this.options.ySyncOptions,onFirstRender:this.options.onFirstRender});return this.editor.options.enableContentCheck&&((e=t.doc)==null||e.on(`beforeTransaction`,()=>{try{let e=WW(t);if(e.content.length===0)return;this.editor.schema.nodeFromJSON(e).check()}catch(e){return this.editor.emit(`contentError`,{error:e,editor:this.editor,disableCollaboration:()=>{var e;(e=t.doc)==null||e.destroy(),this.storage.isDisabled=!0}}),!1}})),[i,n,this.editor.options.enableContentCheck&&new cm({key:new dm(`filterInvalidContent`),filterTransaction:()=>{var e;return this.storage.isDisabled&&((e=t.doc)==null||e.destroy()),!0}})].filter(Boolean)}}),rG=e=>Array.from(e.entries()).map(([e,t])=>({clientId:e,...t.user})),iG=()=>null,aG=IV.create({name:`collaborationCursor`,priority:999,addOptions(){return{provider:null,user:{name:null,color:null},render:e=>{let t=document.createElement(`span`);t.classList.add(`collaboration-cursor__caret`),t.setAttribute(`style`,`border-color: ${e.color}`);let n=document.createElement(`div`);return n.classList.add(`collaboration-cursor__label`),n.setAttribute(`style`,`background-color: ${e.color}`),n.insertBefore(document.createTextNode(e.name),null),t.insertBefore(n,null),t},selectionRender:qW,onUpdate:iG}},onCreate(){if(this.options.onUpdate!==iG&&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 Error(`The "provider" option is required for the CollaborationCursor extension`)},addStorage(){return{users:[]}},addCommands(){return{updateUser:e=>()=>(this.options.user=e,this.options.provider.awareness.setLocalStateField(`user`,this.options.user),!0),user:e=>({editor:t})=>(console.warn(`[tiptap warn]: DEPRECATED: The "user" command is deprecated. Please use "updateUser" instead. Read more: https://tiptap.dev/api/extensions/collaboration-cursor`),t.commands.updateUser(e))}},addProseMirrorPlugins(){return[XW((this.options.provider.awareness.setLocalStateField(`user`,this.options.user),this.storage.users=rG(this.options.provider.awareness.states),this.options.provider.awareness.on(`update`,()=>{this.storage.users=rG(this.options.provider.awareness.states)}),this.options.provider.awareness),{cursorBuilder:this.options.render,selectionBuilder:this.options.selectionRender})]}}),oG=e=>VU({find:/--$/,replace:e??`—`}),sG=e=>VU({find:/\.\.\.$/,replace:e??`…`}),cG=e=>VU({find:/(?:^|[\s{[(<'"\u2018\u201C])(")$/,replace:e??`“`}),lG=e=>VU({find:/"$/,replace:e??`”`}),uG=e=>VU({find:/(?:^|[\s{[(<'"\u2018\u201C])(')$/,replace:e??`‘`}),dG=e=>VU({find:/'$/,replace:e??`’`}),fG=e=>VU({find:/<-$/,replace:e??`←`}),pG=e=>VU({find:/->$/,replace:e??`→`}),mG=e=>VU({find:/\(c\)$/,replace:e??`©`}),hG=e=>VU({find:/\(tm\)$/,replace:e??`™`}),gG=e=>VU({find:/\(sm\)$/,replace:e??`℠`}),_G=e=>VU({find:/\(r\)$/,replace:e??`®`}),vG=e=>VU({find:/(?:^|\s)(1\/2)\s$/,replace:e??`½`}),yG=e=>VU({find:/\+\/-$/,replace:e??`±`}),bG=e=>VU({find:/!=$/,replace:e??`≠`}),xG=e=>VU({find:/<<$/,replace:e??`«`}),SG=e=>VU({find:/>>$/,replace:e??`»`}),CG=e=>VU({find:/\d+\s?([*x])\s?\d+$/,replace:e??`×`}),wG=e=>VU({find:/\^2$/,replace:e??`²`}),TG=e=>VU({find:/\^3$/,replace:e??`³`}),EG=e=>VU({find:/(?:^|\s)(1\/4)\s$/,replace:e??`¼`}),DG=e=>VU({find:/(?:^|\s)(3\/4)\s$/,replace:e??`¾`}),OG=IV.create({name:`typography`,addOptions(){return{closeDoubleQuote:`”`,closeSingleQuote:`’`,copyright:`©`,ellipsis:`…`,emDash:`—`,laquo:`«`,leftArrow:`←`,multiplication:`×`,notEqual:`≠`,oneHalf:`½`,oneQuarter:`¼`,openDoubleQuote:`“`,openSingleQuote:`‘`,plusMinus:`±`,raquo:`»`,registeredTrademark:`®`,rightArrow:`→`,servicemark:`℠`,superscriptThree:`³`,superscriptTwo:`²`,threeQuarters:`¾`,trademark:`™`}},addInputRules(){let e=[];return this.options.emDash!==!1&&e.push(oG(this.options.emDash)),this.options.ellipsis!==!1&&e.push(sG(this.options.ellipsis)),this.options.openDoubleQuote!==!1&&e.push(cG(this.options.openDoubleQuote)),this.options.closeDoubleQuote!==!1&&e.push(lG(this.options.closeDoubleQuote)),this.options.openSingleQuote!==!1&&e.push(uG(this.options.openSingleQuote)),this.options.closeSingleQuote!==!1&&e.push(dG(this.options.closeSingleQuote)),this.options.leftArrow!==!1&&e.push(fG(this.options.leftArrow)),this.options.rightArrow!==!1&&e.push(pG(this.options.rightArrow)),this.options.copyright!==!1&&e.push(mG(this.options.copyright)),this.options.trademark!==!1&&e.push(hG(this.options.trademark)),this.options.servicemark!==!1&&e.push(gG(this.options.servicemark)),this.options.registeredTrademark!==!1&&e.push(_G(this.options.registeredTrademark)),this.options.oneHalf!==!1&&e.push(vG(this.options.oneHalf)),this.options.plusMinus!==!1&&e.push(yG(this.options.plusMinus)),this.options.notEqual!==!1&&e.push(bG(this.options.notEqual)),this.options.laquo!==!1&&e.push(xG(this.options.laquo)),this.options.raquo!==!1&&e.push(SG(this.options.raquo)),this.options.multiplication!==!1&&e.push(CG(this.options.multiplication)),this.options.superscriptTwo!==!1&&e.push(wG(this.options.superscriptTwo)),this.options.superscriptThree!==!1&&e.push(TG(this.options.superscriptThree)),this.options.oneQuarter!==!1&&e.push(EG(this.options.oneQuarter)),this.options.threeQuarters!==!1&&e.push(DG(this.options.threeQuarters)),e}});function kG(e){let{targetEl:t,platform:n,hasSelection:r,isEditable:i}=e,a=t.closest(`a[href]`)!=null,o=t.closest(`td, th`)!=null,s={hasSelection:r,isEditable:i,overLink:a,canMergeCells:!1,canSplitCell:!1};return a?{kind:`link`,...s}:o?{kind:`tableCell`,...s}:n===`macos`?null:{kind:`editorText`,...s}}function AG(e){let t=e.toLowerCase();return t.includes(`mac`)||t===`darwin`?`macos`:t.includes(`win`)?`windows`:`linux`}function jG(e,t,n){let r=e.split(/(?:\r\n?|\n)+/).map(e=>t.nodes.paragraph.create(null,e?t.text(e,n):void 0));return Q.maxOpen(Z.fromArray(r))}var MG=[`http://`,`https://`,`mailto:`,`ftp://`,`//`];function NG(e){let t=e.toLowerCase();return MG.some(e=>t.startsWith(e))}function PG(e){let t=e.indexOf(`:`);if(t===-1)return!1;let n=[`/`,`#`,`?`].map(t=>e.indexOf(t)).filter(e=>e!==-1);return(n.length?Math.min(...n):1/0)>=t}function FG(e){if(!e)return null;let t=e.trim();return t&&(NG(t)||t.startsWith(`#`)||!PG(t))?t:null}var IG=[`http://`,`https://`,`ftp://`,`//`],LG=/^data:image\/(?:png|jpeg|jpg|gif|webp);base64,/i,RG=7e6;function zG(e){if(!e)return null;let t=e.trim();if(!t)return null;if(LG.test(t))return t.length<=RG?t:null;let n=t.toLowerCase();return IG.some(e=>n.startsWith(e))||t.startsWith(`#`)||!PG(t)?t:null}function BG(e){return e.chain().focus()}async function VG(e,t){let{editor:n}=t;switch(e){case`ctx:undo`:BG(n).undo().run();return;case`ctx:redo`:BG(n).redo().run();return;case`ctx:pastePlain`:{let e=await t.readClipboardText();if(!e)return;let{state:r,view:i}=n,a=jG(e,r.schema,r.selection.$from.marks());i.dispatch(r.tr.replaceSelection(a).scrollIntoView()),i.focus();return}case`ctx:table:insertRowAbove`:BG(n).addRowBefore().run();return;case`ctx:table:insertRowBelow`:BG(n).addRowAfter().run();return;case`ctx:table:insertColLeft`:BG(n).addColumnBefore().run();return;case`ctx:table:insertColRight`:BG(n).addColumnAfter().run();return;case`ctx:table:deleteRow`:BG(n).deleteRow().run();return;case`ctx:table:deleteCol`:BG(n).deleteColumn().run();return;case`ctx:table:mergeCells`:BG(n).mergeCells().run();return;case`ctx:table:splitCell`:BG(n).splitCell().run();return;case`ctx:table:deleteTable`:BG(n).deleteTable().run();return;case`ctx:link:open`:{let e=t.getLinkHref();e&&t.openHref(e);return}case`ctx:link:copy`:{let e=t.getLinkHref();if(!e)return;let n=FG(e);n&&await t.writeClipboardText(n);return}case`ctx:link:remove`:BG(n).extendMarkRange(`link`).unsetLink().run();return;default:return}}var HG=new Set([`ctx:undo`,`ctx:redo`,`ctx:pastePlain`,`ctx:table:insertRowAbove`,`ctx:table:insertRowBelow`,`ctx:table:insertColLeft`,`ctx:table:insertColRight`,`ctx:table:deleteRow`,`ctx:table:deleteCol`,`ctx:table:mergeCells`,`ctx:table:splitCell`,`ctx:table:deleteTable`,`ctx:link:open`,`ctx:link:copy`,`ctx:link:remove`]);function UG(e){return typeof e==`string`&&HG.has(e)}async function WG(){try{return await navigator.clipboard.readText()}catch{return null}}async function GG(e){try{await navigator.clipboard.writeText(e)}catch{}}function KG(e,t){if(!nh())return()=>{};let n=e.view.dom,r=t.platform??AG(typeof navigator<`u`?navigator.platform||navigator.userAgent:``),i=null,a=async t=>{let n=t.target;if(!n)return;let a=kG({targetEl:n,platform:r,hasSelection:!1,isEditable:e.isEditable});if(!a)return;t.preventDefault();let o=e.view.posAtCoords({left:t.clientX,top:t.clientY});if(o){let{from:t,to:n}=e.state.selection;(o.pos<t||o.pos>n)&&e.commands.setTextSelection(o.pos)}if(a.hasSelection=!e.state.selection.empty,i=n.closest(`a[href]`)?.getAttribute(`href`)??null,a.kind===`tableCell`){let t=e.can();a.canMergeCells=t.mergeCells(),a.canSplitCell=t.splitCell()}e.view.focus();try{await(await ah())(`show_context_menu`,{req:a})}catch{}};n.addEventListener(`contextmenu`,a);let o=Ul(async()=>{let{listen:e}=await import(`./event-wL_2RBc7.js`);return{listen:e}},__vite__mapDeps([3,1])).then(({listen:n})=>n(`context-menu-action`,n=>{let r=n.payload?.id;UG(r)&&VG(r,{editor:e,openHref:t.openHref,getLinkHref:()=>i,readClipboardText:WG,writeClipboardText:GG})}));return o.catch(()=>{}),()=>{n.removeEventListener(`contextmenu`,a),o.then(e=>e()).catch(()=>{})}}var qG=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,JG=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,YG=EV.create({name:`highlight`,addOptions(){return{multicolor:!1,HTMLAttributes:{}}},addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:e=>e.getAttribute(`data-color`)||e.style.backgroundColor,renderHTML:e=>e.color?{"data-color":e.color,style:`background-color: ${e.color}; color: inherit`}:{}}}:{}},parseHTML(){return[{tag:`mark`}]},renderHTML({HTMLAttributes:e}){return[`mark`,aV(this.options.HTMLAttributes,e),0]},addCommands(){return{setHighlight:e=>({commands:t})=>t.setMark(this.name,e),toggleHighlight:e=>({commands:t})=>t.toggleMark(this.name,e),unsetHighlight:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}},addInputRules(){return[RU({find:qG,type:this.type})]},addPasteRules(){return[WU({find:JG,type:this.type})]}}),XG=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,ZG=UU.create({name:`image`,addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{}}},inline(){return this.options.inline},group(){return this.options.inline?`inline`:`block`},draggable:!0,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null}}},parseHTML(){return[{tag:this.options.allowBase64?`img[src]`:`img[src]:not([src^="data:"])`}]},renderHTML({HTMLAttributes:e}){return[`img`,aV(this.options.HTMLAttributes,e)]},addCommands(){return{setImage:e=>({commands:t})=>t.insertContent({type:this.name,attrs:e})}},addInputRules(){return[zU({find:XG,type:this.type,getAttributes:e=>{let[,,t,n,r]=e;return{src:n,alt:t,title:r}}})]}}),QG=`aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2`,$G=`ελ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`,eK=`numeric`,tK=`ascii`,nK=`alpha`,rK=`asciinumeric`,iK=`alphanumeric`,aK=`domain`,oK=`emoji`,sK=`scheme`,cK=`slashscheme`,lK=`whitespace`;function uK(e,t){return e in t||(t[e]=[]),t[e]}function dK(e,t,n){t[eK]&&(t[rK]=!0,t[iK]=!0),t[tK]&&(t[rK]=!0,t[nK]=!0),t[rK]&&(t[iK]=!0),t[nK]&&(t[iK]=!0),t[iK]&&(t[aK]=!0),t[oK]&&(t[aK]=!0);for(let r in t){let t=uK(r,n);t.indexOf(e)<0&&t.push(e)}}function fK(e,t){let n={};for(let r in t)t[r].indexOf(e)>=0&&(n[r]=!0);return n}function pK(e=null){this.j={},this.jr=[],this.jd=null,this.t=e}pK.groups={},pK.prototype={accepts(){return!!this.t},go(e){let t=this,n=t.j[e];if(n)return n;for(let n=0;n<t.jr.length;n++){let r=t.jr[n][0],i=t.jr[n][1];if(i&&r.test(e))return i}return t.jd},has(e,t=!1){return t?e in this.j:!!this.go(e)},ta(e,t,n,r){for(let i=0;i<e.length;i++)this.tt(e[i],t,n,r)},tr(e,t,n,r){r||=pK.groups;let i;return t&&t.j?i=t:(i=new pK(t),n&&r&&dK(t,n,r)),this.jr.push([e,i]),i},ts(e,t,n,r){let i=this,a=e.length;if(!a)return i;for(let t=0;t<a-1;t++)i=i.tt(e[t]);return i.tt(e[a-1],t,n,r)},tt(e,t,n,r){r||=pK.groups;let i=this;if(t&&t.j)return i.j[e]=t,t;let a=t,o,s=i.go(e);return s?(o=new pK,Object.assign(o.j,s.j),o.jr.push.apply(o.jr,s.jr),o.jd=s.jd,o.t=s.t):o=new pK,a&&(r&&(o.t&&typeof o.t==`string`?dK(a,Object.assign(fK(o.t,r),n),r):n&&dK(a,n,r)),o.t=a),i.j[e]=o,o}};var mK=(e,t,n,r,i)=>e.ta(t,n,r,i),hK=(e,t,n,r,i)=>e.tr(t,n,r,i),gK=(e,t,n,r,i)=>e.ts(t,n,r,i),$=(e,t,n,r,i)=>e.tt(t,n,r,i),_K=`WORD`,vK=`UWORD`,yK=`ASCIINUMERICAL`,bK=`ALPHANUMERICAL`,xK=`LOCALHOST`,SK=`TLD`,CK=`UTLD`,wK=`SCHEME`,TK=`SLASH_SCHEME`,EK=`NUM`,DK=`WS`,OK=`NL`,kK=`OPENBRACE`,AK=`CLOSEBRACE`,jK=`OPENBRACKET`,MK=`CLOSEBRACKET`,NK=`OPENPAREN`,PK=`CLOSEPAREN`,FK=`OPENANGLEBRACKET`,IK=`CLOSEANGLEBRACKET`,LK=`FULLWIDTHLEFTPAREN`,RK=`FULLWIDTHRIGHTPAREN`,zK=`LEFTCORNERBRACKET`,BK=`RIGHTCORNERBRACKET`,VK=`LEFTWHITECORNERBRACKET`,HK=`RIGHTWHITECORNERBRACKET`,UK=`FULLWIDTHLESSTHAN`,WK=`FULLWIDTHGREATERTHAN`,GK=`AMPERSAND`,KK=`APOSTROPHE`,qK=`ASTERISK`,JK=`AT`,YK=`BACKSLASH`,XK=`BACKTICK`,ZK=`CARET`,QK=`COLON`,$K=`COMMA`,eq=`DOLLAR`,tq=`DOT`,nq=`EQUALS`,rq=`EXCLAMATION`,iq=`HYPHEN`,aq=`PERCENT`,oq=`PIPE`,sq=`PLUS`,cq=`POUND`,lq=`QUERY`,uq=`QUOTE`,dq=`FULLWIDTHMIDDLEDOT`,fq=`SEMI`,pq=`SLASH`,mq=`TILDE`,hq=`UNDERSCORE`,gq=`EMOJI`,_q=`SYM`,vq=Object.freeze({__proto__:null,ALPHANUMERICAL:bK,AMPERSAND:GK,APOSTROPHE:KK,ASCIINUMERICAL:yK,ASTERISK:qK,AT:JK,BACKSLASH:YK,BACKTICK:XK,CARET:ZK,CLOSEANGLEBRACKET:IK,CLOSEBRACE:AK,CLOSEBRACKET:MK,CLOSEPAREN:PK,COLON:QK,COMMA:$K,DOLLAR:eq,DOT:tq,EMOJI:gq,EQUALS:nq,EXCLAMATION:rq,FULLWIDTHGREATERTHAN:WK,FULLWIDTHLEFTPAREN:LK,FULLWIDTHLESSTHAN:UK,FULLWIDTHMIDDLEDOT:dq,FULLWIDTHRIGHTPAREN:RK,HYPHEN:iq,LEFTCORNERBRACKET:zK,LEFTWHITECORNERBRACKET:VK,LOCALHOST:xK,NL:OK,NUM:EK,OPENANGLEBRACKET:FK,OPENBRACE:kK,OPENBRACKET:jK,OPENPAREN:NK,PERCENT:aq,PIPE:oq,PLUS:sq,POUND:cq,QUERY:lq,QUOTE:uq,RIGHTCORNERBRACKET:BK,RIGHTWHITECORNERBRACKET:HK,SCHEME:wK,SEMI:fq,SLASH:pq,SLASH_SCHEME:TK,SYM:_q,TILDE:mq,TLD:SK,UNDERSCORE:hq,UTLD:CK,UWORD:vK,WORD:_K,WS:DK}),yq=/[a-z]/,bq=/\p{L}/u,xq=/\p{Emoji}/u,Sq=/\d/,Cq=/\s/,wq=`\r`,Tq=`
213
+ `,Eq=`️`,Dq=`‍`,Oq=``,kq=null,Aq=null;function jq(e=[]){let t={};pK.groups=t;let n=new pK;kq??=Fq(QG),Aq??=Fq($G),$(n,`'`,KK),$(n,`{`,kK),$(n,`}`,AK),$(n,`[`,jK),$(n,`]`,MK),$(n,`(`,NK),$(n,`)`,PK),$(n,`<`,FK),$(n,`>`,IK),$(n,`(`,LK),$(n,`)`,RK),$(n,`「`,zK),$(n,`」`,BK),$(n,`『`,VK),$(n,`』`,HK),$(n,`<`,UK),$(n,`>`,WK),$(n,`&`,GK),$(n,`*`,qK),$(n,`@`,JK),$(n,"`",XK),$(n,`^`,ZK),$(n,`:`,QK),$(n,`,`,$K),$(n,`$`,eq),$(n,`.`,tq),$(n,`=`,nq),$(n,`!`,rq),$(n,`-`,iq),$(n,`%`,aq),$(n,`|`,oq),$(n,`+`,sq),$(n,`#`,cq),$(n,`?`,lq),$(n,`"`,uq),$(n,`/`,pq),$(n,`;`,fq),$(n,`~`,mq),$(n,`_`,hq),$(n,`\\`,YK),$(n,`・`,dq);let r=hK(n,Sq,EK,{[eK]:!0});hK(r,Sq,r);let i=hK(r,yq,yK,{[rK]:!0}),a=hK(r,bq,bK,{[iK]:!0}),o=hK(n,yq,_K,{[tK]:!0});hK(o,Sq,i),hK(o,yq,o),hK(i,Sq,i),hK(i,yq,i);let s=hK(n,bq,vK,{[nK]:!0});hK(s,yq),hK(s,Sq,a),hK(s,bq,s),hK(a,Sq,a),hK(a,yq),hK(a,bq,a);let c=$(n,Tq,OK,{[lK]:!0}),l=$(n,wq,DK,{[lK]:!0}),u=hK(n,Cq,DK,{[lK]:!0});$(n,Oq,u),$(l,Tq,c),$(l,Oq,u),hK(l,Cq,u),$(u,wq),$(u,Tq),hK(u,Cq,u),$(u,Oq,u);let d=hK(n,xq,gq,{[oK]:!0});$(d,`#`),hK(d,xq,d),$(d,Eq,d);let f=$(d,Dq);$(f,`#`),hK(f,xq,d);let p=[[yq,o],[Sq,i]],m=[[yq,null],[bq,s],[Sq,a]];for(let e=0;e<kq.length;e++)Pq(n,kq[e],SK,_K,p);for(let e=0;e<Aq.length;e++)Pq(n,Aq[e],CK,vK,m);dK(SK,{tld:!0,ascii:!0},t),dK(CK,{utld:!0,alpha:!0},t),Pq(n,`file`,wK,_K,p),Pq(n,`mailto`,wK,_K,p),Pq(n,`http`,TK,_K,p),Pq(n,`https`,TK,_K,p),Pq(n,`ftp`,TK,_K,p),Pq(n,`ftps`,TK,_K,p),dK(wK,{scheme:!0,ascii:!0},t),dK(TK,{slashscheme:!0,ascii:!0},t),e=e.sort((e,t)=>e[0]>t[0]?1:-1);for(let t=0;t<e.length;t++){let r=e[t][0],i=e[t][1]?{[sK]:!0}:{[cK]:!0};r.indexOf(`-`)>=0?i[aK]=!0:yq.test(r)?Sq.test(r)?i[rK]=!0:i[tK]=!0:i[eK]=!0,gK(n,r,r,i)}return gK(n,`localhost`,xK,{ascii:!0}),n.jd=new pK(_q),{start:n,tokens:Object.assign({groups:t},vq)}}function Mq(e,t){let n=Nq(t.replace(/[A-Z]/g,e=>e.toLowerCase())),r=n.length,i=[],a=0,o=0;for(;o<r;){let s=e,c=null,l=0,u=null,d=-1,f=-1;for(;o<r&&(c=s.go(n[o]));)s=c,s.accepts()?(d=0,f=0,u=s):d>=0&&(d+=n[o].length,f++),l+=n[o].length,a+=n[o].length,o++;a-=d,o-=f,l-=d,i.push({t:u.t,v:t.slice(a-l,a),s:a-l,e:a})}return i}function Nq(e){let t=[],n=e.length,r=0;for(;r<n;){let i=e.charCodeAt(r),a,o=i<55296||i>56319||r+1===n||(a=e.charCodeAt(r+1))<56320||a>57343?e[r]:e.slice(r,r+2);t.push(o),r+=o.length}return t}function Pq(e,t,n,r,i){let a,o=t.length;for(let n=0;n<o-1;n++){let o=t[n];e.j[o]?a=e.j[o]:(a=new pK(r),a.jr=i.slice(),e.j[o]=a),e=a}return a=new pK(n),a.jr=i.slice(),e.j[t[o-1]]=a,a}function Fq(e){let t=[],n=[],r=0;for(;r<e.length;){let i=0;for(;`0123456789`.indexOf(e[r+i])>=0;)i++;if(i>0){t.push(n.join(``));for(let t=parseInt(e.substring(r,r+i),10);t>0;t--)n.pop();r+=i}else n.push(e[r]),r++}return t}var Iq={defaultProtocol:`http`,events:null,format:Rq,formatHref:Rq,nl2br:!1,tagName:`a`,target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function Lq(e,t=null){let n=Object.assign({},Iq);e&&(n=Object.assign(n,e instanceof Lq?e.o:e));let r=n.ignoreTags,i=[];for(let e=0;e<r.length;e++)i.push(r[e].toUpperCase());this.o=n,t&&(this.defaultRender=t),this.ignoreTags=i}Lq.prototype={o:Iq,ignoreTags:[],defaultRender(e){return e},check(e){return this.get(`validate`,e.toString(),e)},get(e,t,n){let r=t!=null,i=this.o[e];return i&&(typeof i==`object`?(i=n.t in i?i[n.t]:Iq[e],typeof i==`function`&&r&&(i=i(t,n))):typeof i==`function`&&r&&(i=i(t,n.t,n)),i)},getObj(e,t,n){let r=this.o[e];return typeof r==`function`&&t!=null&&(r=r(t,n.t,n)),r},render(e){let t=e.render(this);return(this.get(`render`,null,e)||this.defaultRender)(t,e.t,e)}};function Rq(e){return e}function zq(e,t){this.t=`token`,this.v=e,this.tk=t}zq.prototype={isLink:!1,toString(){return this.v},toHref(e){return this.toString()},toFormattedString(e){let t=this.toString(),n=e.get(`truncate`,t,this),r=e.get(`format`,t,this);return n&&r.length>n?r.substring(0,n)+`…`:r},toFormattedHref(e){return e.get(`formatHref`,this.toHref(e.get(`defaultProtocol`)),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(e=Iq.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(e),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(e){return{type:this.t,value:this.toFormattedString(e),isLink:this.isLink,href:this.toFormattedHref(e),start:this.startIndex(),end:this.endIndex()}},validate(e){return e.get(`validate`,this.toString(),this)},render(e){let t=this,n=this.toHref(e.get(`defaultProtocol`)),r=e.get(`formatHref`,n,this),i=e.get(`tagName`,n,t),a=this.toFormattedString(e),o={},s=e.get(`className`,n,t),c=e.get(`target`,n,t),l=e.get(`rel`,n,t),u=e.getObj(`attributes`,n,t),d=e.getObj(`events`,n,t);return o.href=r,s&&(o.class=s),c&&(o.target=c),l&&(o.rel=l),u&&Object.assign(o,u),{tagName:i,attributes:o,content:a,eventListeners:d}}};function Bq(e,t){class n extends zq{constructor(t,n){super(t,n),this.t=e}}for(let e in t)n.prototype[e]=t[e];return n.t=e,n}var Vq=Bq(`email`,{isLink:!0,toHref(){return`mailto:`+this.toString()}}),Hq=Bq(`text`),Uq=Bq(`nl`),Wq=Bq(`url`,{isLink:!0,toHref(e=Iq.defaultProtocol){return this.hasProtocol()?this.v:`${e}://${this.v}`},hasProtocol(){let e=this.tk;return e.length>=2&&e[0].t!==xK&&e[1].t===QK}}),Gq=e=>new pK(e);function Kq({groups:e}){let t=e.domain.concat([GK,qK,JK,YK,XK,ZK,eq,nq,iq,EK,aq,oq,sq,cq,pq,_q,mq,hq]),n=[KK,QK,$K,tq,rq,aq,lq,uq,fq,FK,IK,kK,AK,MK,jK,NK,PK,LK,RK,zK,BK,VK,HK,UK,WK],r=[GK,KK,qK,YK,XK,ZK,eq,nq,iq,kK,AK,aq,oq,sq,cq,lq,pq,_q,mq,hq],i=Gq(),a=$(i,mq);mK(a,r,a),mK(a,e.domain,a);let o=Gq(),s=Gq(),c=Gq();mK(i,e.domain,o),mK(i,e.scheme,s),mK(i,e.slashscheme,c),mK(o,r,a),mK(o,e.domain,o);let l=$(o,JK);$(a,JK,l),$(s,JK,l),$(c,JK,l);let u=$(a,tq);mK(u,r,a),mK(u,e.domain,a);let d=Gq();mK(l,e.domain,d),mK(d,e.domain,d);let f=$(d,tq);mK(f,e.domain,d);let p=Gq(Vq);mK(f,e.tld,p),mK(f,e.utld,p),$(l,xK,p);let m=$(d,iq);$(m,iq,m),mK(m,e.domain,d),mK(p,e.domain,d),$(p,tq,f),$(p,iq,m),mK($(p,QK),e.numeric,Vq);let h=$(o,iq),g=$(o,tq);$(h,iq,h),mK(h,e.domain,o),mK(g,r,a),mK(g,e.domain,o);let _=Gq(Wq);mK(g,e.tld,_),mK(g,e.utld,_),mK(_,e.domain,o),mK(_,r,a),$(_,tq,g),$(_,iq,h),$(_,JK,l);let v=$(_,QK),y=Gq(Wq);mK(v,e.numeric,y);let b=Gq(Wq),x=Gq();mK(b,t,b),mK(b,n,x),mK(x,t,b),mK(x,n,x),$(_,pq,b),$(y,pq,b);let S=$(s,QK),C=$($($(c,QK),pq),pq);mK(s,e.domain,o),$(s,tq,g),$(s,iq,h),mK(c,e.domain,o),$(c,tq,g),$(c,iq,h),mK(S,e.domain,b),$(S,pq,b),$(S,lq,b),mK(C,e.domain,b),mK(C,t,b),$(C,pq,b);let w=[[kK,AK],[jK,MK],[NK,PK],[FK,IK],[LK,RK],[zK,BK],[VK,HK],[UK,WK]];for(let e=0;e<w.length;e++){let[r,i]=w[e],a=$(b,r);$(x,r,a),$(a,i,b);let o=Gq(Wq);mK(a,t,o);let s=Gq();mK(a,n),mK(o,t,o),mK(o,n,s),mK(s,t,o),mK(s,n,s),$(o,i,b),$(s,i,b)}return $(i,xK,_),$(i,OK,Uq),{start:i,tokens:vq}}function qq(e,t,n){let r=n.length,i=0,a=[],o=[];for(;i<r;){let s=e,c=null,l=null,u=0,d=null,f=-1;for(;i<r&&!(c=s.go(n[i].t));)o.push(n[i++]);for(;i<r&&(l=c||s.go(n[i].t));)c=null,s=l,s.accepts()?(f=0,d=s):f>=0&&f++,i++,u++;if(f<0)i-=u,i<r&&(o.push(n[i]),i++);else{o.length>0&&(a.push(Jq(Hq,t,o)),o=[]),i-=f,u-=f;let e=d.t,r=n.slice(i-u,i);a.push(Jq(e,t,r))}}return o.length>0&&a.push(Jq(Hq,t,o)),a}function Jq(e,t,n){let r=n[0].s,i=n[n.length-1].e;return new e(t.slice(r,i),n)}var Yq=typeof console<`u`&&console&&console.warn||(()=>{}),Xq=`until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.`,Zq={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function Qq(){return pK.groups={},Zq.scanner=null,Zq.parser=null,Zq.tokenQueue=[],Zq.pluginQueue=[],Zq.customSchemes=[],Zq.initialized=!1,Zq}function $q(e,t=!1){if(Zq.initialized&&Yq(`linkifyjs: already initialized - will not register custom scheme "${e}" ${Xq}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(e))throw Error(`linkifyjs: incorrect scheme format.
214
+ 1. Must only contain digits, lowercase ASCII letters or "-"
215
+ 2. Cannot start or end with "-"
216
+ 3. "-" cannot repeat`);Zq.customSchemes.push([e,t])}function eJ(){Zq.scanner=jq(Zq.customSchemes);for(let e=0;e<Zq.tokenQueue.length;e++)Zq.tokenQueue[e][1]({scanner:Zq.scanner});Zq.parser=Kq(Zq.scanner.tokens);for(let e=0;e<Zq.pluginQueue.length;e++)Zq.pluginQueue[e][1]({scanner:Zq.scanner,parser:Zq.parser});return Zq.initialized=!0,Zq}function tJ(e){return Zq.initialized||eJ(),qq(Zq.parser.start,e,Mq(Zq.scanner.start,e))}tJ.scan=Mq;function nJ(e,t=null,n=null){if(t&&typeof t==`object`){if(n)throw Error(`linkifyjs: Invalid link type ${t}; must be a string`);n=t,t=null}let r=new Lq(n),i=tJ(e),a=[];for(let e=0;e<i.length;e++){let n=i[e];n.isLink&&(!t||n.t===t)&&r.check(n)&&a.push(n.toFormattedObject(r))}return a}var rJ=`[\0- \xA0 ᠎ -\u2029  ]`,iJ=new RegExp(rJ),aJ=RegExp(`${rJ}$`),oJ=new RegExp(rJ,`g`);function sJ(e){return e.length===1?e[0].isLink:e.length===3&&e[1].isLink?[`()`,`[]`].includes(e[0].value+e[2].value):!1}function cJ(e){return new cm({key:new dm(`autolink`),appendTransaction:(t,n,r)=>{let i=t.some(e=>e.docChanged)&&!n.doc.eq(r.doc),a=t.some(e=>e.getMeta(`preventAutolink`));if(!i||a)return;let{tr:o}=r;if(aU(YH(n.doc,[...t])).forEach(({newRange:t})=>{let n=ZH(r.doc,t,e=>e.isTextblock),i,a;if(n.length>1)i=n[0],a=r.doc.textBetween(i.pos,i.pos+i.node.nodeSize,void 0,` `);else if(n.length){let e=r.doc.textBetween(t.from,t.to,` `,` `);if(!aJ.test(e))return;i=n[0],a=r.doc.textBetween(i.pos,t.to,void 0,` `)}if(i&&a){let t=a.split(iJ).filter(Boolean);if(t.length<=0)return!1;let n=t[t.length-1],s=i.pos+a.lastIndexOf(n);if(!n)return!1;let c=tJ(n).map(t=>t.toObject(e.defaultProtocol));if(!sJ(c))return!1;c.filter(e=>e.isLink).map(e=>({...e,from:s+e.start+1,to:s+e.end+1})).filter(e=>r.schema.marks.code?!r.doc.rangeHasMark(e.from,e.to,r.schema.marks.code):!0).filter(t=>e.validate(t.value)).filter(t=>e.shouldAutoLink(t.value)).forEach(t=>{oU(t.from,t.to,r.doc).some(t=>t.mark.type===e.type)||o.addMark(t.from,t.to,e.type.create({href:t.href}))})}}),o.steps.length)return o}})}function lJ(e){return new cm({key:new dm(`handleClickLink`),props:{handleClick:(t,n,r)=>{if(r.button!==0||!t.editable)return!1;let i=r.target,a=[];for(;i.nodeName!==`DIV`;)a.push(i),i=i.parentNode;if(!a.find(e=>e.nodeName===`A`))return!1;let o=nU(t.state,e.type.name),s=r.target,c=s?.href??o.href,l=s?.target??o.target;return s&&c?(window.open(c,l),!0):!1}}})}function uJ(e){return new cm({key:new dm(`handlePasteLink`),props:{handlePaste:(t,n,r)=>{let{state:i}=t,{selection:a}=i,{empty:o}=a;if(o)return!1;let s=``;r.content.forEach(e=>{s+=e.textContent});let c=nJ(s,{defaultProtocol:e.defaultProtocol}).find(e=>e.isLink&&e.value===s);return!s||!c?!1:e.editor.commands.setMark(e.type,{href:c.href})}}})}function dJ(e,t){let n=[`http`,`https`,`ftp`,`ftps`,`mailto`,`tel`,`callto`,`sms`,`cid`,`xmpp`];return t&&t.forEach(e=>{let t=typeof e==`string`?e:e.scheme;t&&n.push(t)}),!e||e.replace(oJ,``).match(RegExp(`^(?:(?:${n.join(`|`)}):|[^a-z]|[a-z0-9+.\-]+(?:[^a-z+.\-:]|$))`,`i`))}var fJ=EV.create({name:`link`,priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(e=>{if(typeof e==`string`){$q(e);return}$q(e.scheme,e.optionalSlashes)})},onDestroy(){Qq()},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:(e,t)=>!!dJ(e,t.protocols),validate:e=>!!e,shouldAutoLink:e=>!!e}},addAttributes(){return{href:{default:null,parseHTML(e){return e.getAttribute(`href`)}},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class}}},parseHTML(){return[{tag:`a[href]`,getAttrs:e=>{let t=e.getAttribute(`href`);return!t||!this.options.isAllowedUri(t,{defaultValidate:e=>!!dJ(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:e}){return this.options.isAllowedUri(e.href,{defaultValidate:e=>!!dJ(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?[`a`,aV(this.options.HTMLAttributes,e),0]:[`a`,aV(this.options.HTMLAttributes,{...e,href:``}),0]},addCommands(){return{setLink:e=>({chain:t})=>{let{href:n}=e;return this.options.isAllowedUri(n,{defaultValidate:e=>!!dJ(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?t().setMark(this.name,e).setMeta(`preventAutolink`,!0).run():!1},toggleLink:e=>({chain:t})=>{let{href:n}=e;return this.options.isAllowedUri(n,{defaultValidate:e=>!!dJ(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?t().toggleMark(this.name,e,{extendEmptyMarkRange:!0}).setMeta(`preventAutolink`,!0).run():!1},unsetLink:()=>({chain:e})=>e().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta(`preventAutolink`,!0).run()}},addPasteRules(){return[WU({find:e=>{let t=[];if(e){let{protocols:n,defaultProtocol:r}=this.options,i=nJ(e).filter(e=>e.isLink&&this.options.isAllowedUri(e.value,{defaultValidate:e=>!!dJ(e,n),protocols:n,defaultProtocol:r}));i.length&&i.forEach(e=>t.push({text:e.value,data:{href:e.href},index:e.start}))}return t},type:this.type,getAttributes:e=>({href:e.data?.href})})]},addProseMirrorPlugins(){let e=[],{protocols:t,defaultProtocol:n}=this.options;return this.options.autolink&&e.push(cJ({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:e=>this.options.isAllowedUri(e,{defaultValidate:e=>!!dJ(e,t),protocols:t,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),this.options.openOnClick===!0&&e.push(lJ({type:this.type})),this.options.linkOnPaste&&e.push(uJ({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type})),e}}),pJ=IV.create({name:`placeholder`,addOptions(){return{emptyEditorClass:`is-editor-empty`,emptyNodeClass:`is-empty`,placeholder:`Write something …`,showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new cm({key:new dm(`placeholder`),props:{decorations:({doc:e,selection:t})=>{let n=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:r}=t,i=[];if(!n)return null;let a=this.editor.isEmpty;return e.descendants((e,t)=>{let n=r>=t&&r<=t+e.nodeSize,o=!e.isLeaf&&dU(e);if((n||!this.options.showOnlyCurrent)&&o){let r=[this.options.emptyNodeClass];a&&r.push(this.options.emptyEditorClass);let o=rz.node(t,t+e.nodeSize,{class:r.join(` `),"data-placeholder":typeof this.options.placeholder==`function`?this.options.placeholder({editor:this.editor,node:e,pos:t,hasAnchor:n}):this.options.placeholder});i.push(o)}return this.options.includeChildren}),oz.create(e,i)}}})]}}),mJ=EV.create({name:`subscript`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`sub`},{style:`vertical-align`,getAttrs(e){return e===`sub`?null:!1}}]},renderHTML({HTMLAttributes:e}){return[`sub`,aV(this.options.HTMLAttributes,e),0]},addCommands(){return{setSubscript:()=>({commands:e})=>e.setMark(this.name),toggleSubscript:()=>({commands:e})=>e.toggleMark(this.name),unsetSubscript:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-,":()=>this.editor.commands.toggleSubscript()}}}),hJ=EV.create({name:`superscript`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`sup`},{style:`vertical-align`,getAttrs(e){return e===`super`?null:!1}}]},renderHTML({HTMLAttributes:e}){return[`sup`,aV(this.options.HTMLAttributes,e),0]},addCommands(){return{setSuperscript:()=>({commands:e})=>e.setMark(this.name),toggleSuperscript:()=>({commands:e})=>e.toggleMark(this.name),unsetSuperscript:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-.":()=>this.editor.commands.toggleSuperscript()}}}),gJ,_J;if(typeof WeakMap<`u`){let e=new WeakMap;gJ=t=>e.get(t),_J=(t,n)=>(e.set(t,n),n)}else{let e=[],t=0;gJ=t=>{for(let n=0;n<e.length;n+=2)if(e[n]==t)return e[n+1]},_J=(n,r)=>(t==10&&(t=0),e[t++]=n,e[t++]=r)}var vJ=class{constructor(e,t,n,r){this.width=e,this.height=t,this.map=n,this.problems=r}findCell(e){for(let t=0;t<this.map.length;t++){let n=this.map[t];if(n!=e)continue;let r=t%this.width,i=t/this.width|0,a=r+1,o=i+1;for(let e=1;a<this.width&&this.map[t+e]==n;e++)a++;for(let e=1;o<this.height&&this.map[t+this.width*e]==n;e++)o++;return{left:r,top:i,right:a,bottom:o}}throw RangeError(`No cell with offset ${e} found`)}colCount(e){for(let t=0;t<this.map.length;t++)if(this.map[t]==e)return t%this.width;throw RangeError(`No cell with offset ${e} found`)}nextCell(e,t,n){let{left:r,right:i,top:a,bottom:o}=this.findCell(e);return t==`horiz`?(n<0?r==0:i==this.width)?null:this.map[a*this.width+(n<0?r-1:i)]:(n<0?a==0:o==this.height)?null:this.map[r+this.width*(n<0?a-1:o)]}rectBetween(e,t){let{left:n,right:r,top:i,bottom:a}=this.findCell(e),{left:o,right:s,top:c,bottom:l}=this.findCell(t);return{left:Math.min(n,o),top:Math.min(i,c),right:Math.max(r,s),bottom:Math.max(a,l)}}cellsInRect(e){let t=[],n={};for(let r=e.top;r<e.bottom;r++)for(let i=e.left;i<e.right;i++){let a=r*this.width+i,o=this.map[a];n[o]||(n[o]=!0,!(i==e.left&&i&&this.map[a-1]==o||r==e.top&&r&&this.map[a-this.width]==o)&&t.push(o))}return t}positionAt(e,t,n){for(let r=0,i=0;;r++){let a=i+n.child(r).nodeSize;if(r==e){let n=t+e*this.width,r=(e+1)*this.width;for(;n<r&&this.map[n]<i;)n++;return n==r?a-1:this.map[n]}i=a}}static get(e){return gJ(e)||_J(e,yJ(e))}};function yJ(e){if(e.type.spec.tableRole!=`table`)throw RangeError(`Not a table node: `+e.type.name);let t=bJ(e),n=e.childCount,r=[],i=0,a=null,o=[];for(let e=0,i=t*n;e<i;e++)r[e]=0;for(let s=0,c=0;s<n;s++){let l=e.child(s);c++;for(let e=0;;e++){for(;i<r.length&&r[i]!=0;)i++;if(e==l.childCount)break;let u=l.child(e),{colspan:d,rowspan:f,colwidth:p}=u.attrs;for(let e=0;e<f;e++){if(e+s>=n){(a||=[]).push({type:`overlong_rowspan`,pos:c,n:f-e});break}let l=i+e*t;for(let e=0;e<d;e++){r[l+e]==0?r[l+e]=c:(a||=[]).push({type:`collision`,row:s,pos:c,n:d-e});let n=p&&p[e];if(n){let r=(l+e)%t*2,i=o[r];i==null||i!=n&&o[r+1]==1?(o[r]=n,o[r+1]=1):i==n&&o[r+1]++}}}i+=d,c+=u.nodeSize}let u=(s+1)*t,d=0;for(;i<u;)r[i++]==0&&d++;d&&(a||=[]).push({type:`missing`,row:s,n:d}),c++}(t===0||n===0)&&(a||=[]).push({type:`zero_sized`});let s=new vJ(t,n,r,a),c=!1;for(let e=0;!c&&e<o.length;e+=2)o[e]!=null&&o[e+1]<n&&(c=!0);return c&&xJ(s,o,e),s}function bJ(e){let t=-1,n=!1;for(let r=0;r<e.childCount;r++){let i=e.child(r),a=0;if(n)for(let t=0;t<r;t++){let n=e.child(t);for(let e=0;e<n.childCount;e++){let i=n.child(e);t+i.attrs.rowspan>r&&(a+=i.attrs.colspan)}}for(let e=0;e<i.childCount;e++){let t=i.child(e);a+=t.attrs.colspan,t.attrs.rowspan>1&&(n=!0)}t==-1?t=a:t!=a&&(t=Math.max(t,a))}return t}function xJ(e,t,n){e.problems||=[];let r={};for(let i=0;i<e.map.length;i++){let a=e.map[i];if(r[a])continue;r[a]=!0;let o=n.nodeAt(a);if(!o)throw RangeError(`No cell with offset ${a} found`);let s=null,c=o.attrs;for(let n=0;n<c.colspan;n++){let r=t[(i+n)%e.width*2];r!=null&&(!c.colwidth||c.colwidth[n]!=r)&&((s||=SJ(c))[n]=r)}s&&e.problems.unshift({type:`colwidth mismatch`,pos:a,colwidth:s})}}function SJ(e){if(e.colwidth)return e.colwidth.slice();let t=[];for(let n=0;n<e.colspan;n++)t.push(0);return t}function CJ(e){let t=e.cached.tableNodeTypes;if(!t){t=e.cached.tableNodeTypes={};for(let n in e.nodes){let r=e.nodes[n],i=r.spec.tableRole;i&&(t[i]=r)}}return t}var wJ=new dm(`selectingCells`);function TJ(e){for(let t=e.depth-1;t>0;t--)if(e.node(t).type.spec.tableRole==`row`)return e.node(0).resolve(e.before(t+1));return null}function EJ(e){for(let t=e.depth;t>0;t--){let n=e.node(t).type.spec.tableRole;if(n===`cell`||n===`header_cell`)return e.node(t)}return null}function DJ(e){let t=e.selection.$head;for(let e=t.depth;e>0;e--)if(t.node(e).type.spec.tableRole==`row`)return!0;return!1}function OJ(e){let t=e.selection;if(`$anchorCell`in t&&t.$anchorCell)return t.$anchorCell.pos>t.$headCell.pos?t.$anchorCell:t.$headCell;if(`node`in t&&t.node&&t.node.type.spec.tableRole==`cell`)return t.$anchor;let n=TJ(t.$head)||kJ(t.$head);if(n)return n;throw RangeError(`No cell found around position ${t.head}`)}function kJ(e){for(let t=e.nodeAfter,n=e.pos;t;t=t.firstChild,n++){let r=t.type.spec.tableRole;if(r==`cell`||r==`header_cell`)return e.doc.resolve(n)}for(let t=e.nodeBefore,n=e.pos;t;t=t.lastChild,n--){let r=t.type.spec.tableRole;if(r==`cell`||r==`header_cell`)return e.doc.resolve(n-t.nodeSize)}}function AJ(e){return e.parent.type.spec.tableRole==`row`&&!!e.nodeAfter}function jJ(e){return e.node(0).resolve(e.pos+e.nodeAfter.nodeSize)}function MJ(e,t){return e.depth==t.depth&&e.pos>=t.start(-1)&&e.pos<=t.end(-1)}function NJ(e,t,n){let r=e.node(-1),i=vJ.get(r),a=e.start(-1),o=i.nextCell(e.pos-a,t,n);return o==null?null:e.node(0).resolve(a+o)}function PJ(e,t,n=1){let r={...e,colspan:e.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(t,n),r.colwidth.some(e=>e>0)||(r.colwidth=null)),r}function FJ(e,t,n=1){let r={...e,colspan:e.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let e=0;e<n;e++)r.colwidth.splice(t,0,0)}return r}function IJ(e,t,n){let r=CJ(t.type.schema).header_cell;for(let i=0;i<e.height;i++)if(t.nodeAt(e.map[n+i*e.width]).type!=r)return!1;return!0}var LJ=class e extends Bp{constructor(e,t=e){let n=e.node(-1),r=vJ.get(n),i=e.start(-1),a=r.rectBetween(e.pos-i,t.pos-i),o=e.node(0),s=r.cellsInRect(a).filter(e=>e!=t.pos-i);s.unshift(t.pos-i);let c=s.map(e=>{let t=n.nodeAt(e);if(!t)throw RangeError(`No cell with offset ${e} found`);let r=i+e+1;return new Vp(o.resolve(r),o.resolve(r+t.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=t}map(t,n){let r=t.resolve(n.map(this.$anchorCell.pos)),i=t.resolve(n.map(this.$headCell.pos));if(AJ(r)&&AJ(i)&&MJ(r,i)){let t=this.$anchorCell.node(-1)!=r.node(-1);return t&&this.isRowSelection()?e.rowSelection(r,i):t&&this.isColSelection()?e.colSelection(r,i):new e(r,i)}return Wp.between(r,i)}content(){let e=this.$anchorCell.node(-1),t=vJ.get(e),n=this.$anchorCell.start(-1),r=t.rectBetween(this.$anchorCell.pos-n,this.$headCell.pos-n),i={},a=[];for(let n=r.top;n<r.bottom;n++){let o=[];for(let a=n*t.width+r.left,s=r.left;s<r.right;s++,a++){let n=t.map[a];if(i[n])continue;i[n]=!0;let s=t.findCell(n),c=e.nodeAt(n);if(!c)throw RangeError(`No cell with offset ${n} found`);let l=r.left-s.left,u=s.right-r.right;if(l>0||u>0){let e=c.attrs;if(l>0&&(e=PJ(e,0,l)),u>0&&(e=PJ(e,e.colspan-u,u)),s.left<r.left){if(c=c.type.createAndFill(e),!c)throw RangeError(`Could not create cell with attrs ${JSON.stringify(e)}`)}else c=c.type.create(e,c.content)}if(s.top<r.top||s.bottom>r.bottom){let e={...c.attrs,rowspan:Math.min(s.bottom,r.bottom)-Math.max(s.top,r.top)};c=s.top<r.top?c.type.createAndFill(e):c.type.create(e,c.content)}o.push(c)}a.push(e.child(n).copy(Z.from(o)))}let o=this.isColSelection()&&this.isRowSelection()?e:a;return new Q(Z.from(o),1,1)}replace(e,t=Q.empty){let n=e.steps.length,r=this.ranges;for(let i=0;i<r.length;i++){let{$from:a,$to:o}=r[i],s=e.mapping.slice(n);e.replace(s.map(a.pos),s.map(o.pos),i?Q.empty:t)}let i=Bp.findFrom(e.doc.resolve(e.mapping.slice(n).map(this.to)),-1);i&&e.setSelection(i)}replaceWith(e,t){this.replace(e,new Q(Z.from(t),0,0))}forEachCell(e){let t=this.$anchorCell.node(-1),n=vJ.get(t),r=this.$anchorCell.start(-1),i=n.cellsInRect(n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r));for(let n=0;n<i.length;n++)e(t.nodeAt(i[n]),r+i[n])}isColSelection(){let e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;let n=e+this.$anchorCell.nodeAfter.attrs.rowspan,r=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(n,r)==this.$headCell.node(-1).childCount}static colSelection(t,n=t){let r=t.node(-1),i=vJ.get(r),a=t.start(-1),o=i.findCell(t.pos-a),s=i.findCell(n.pos-a),c=t.node(0);return o.top<=s.top?(o.top>0&&(t=c.resolve(a+i.map[o.left])),s.bottom<i.height&&(n=c.resolve(a+i.map[i.width*(i.height-1)+s.right-1]))):(s.top>0&&(n=c.resolve(a+i.map[s.left])),o.bottom<i.height&&(t=c.resolve(a+i.map[i.width*(i.height-1)+o.right-1]))),new e(t,n)}isRowSelection(){let e=this.$anchorCell.node(-1),t=vJ.get(e),n=this.$anchorCell.start(-1),r=t.colCount(this.$anchorCell.pos-n),i=t.colCount(this.$headCell.pos-n);if(Math.min(r,i)>0)return!1;let a=r+this.$anchorCell.nodeAfter.attrs.colspan,o=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(a,o)==t.width}eq(t){return t instanceof e&&t.$anchorCell.pos==this.$anchorCell.pos&&t.$headCell.pos==this.$headCell.pos}static rowSelection(t,n=t){let r=t.node(-1),i=vJ.get(r),a=t.start(-1),o=i.findCell(t.pos-a),s=i.findCell(n.pos-a),c=t.node(0);return o.left<=s.left?(o.left>0&&(t=c.resolve(a+i.map[o.top*i.width])),s.right<i.width&&(n=c.resolve(a+i.map[i.width*(s.top+1)-1]))):(s.left>0&&(n=c.resolve(a+i.map[s.top*i.width])),o.right<i.width&&(t=c.resolve(a+i.map[i.width*(o.top+1)-1]))),new e(t,n)}toJSON(){return{type:`cell`,anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(t,n){return new e(t.resolve(n.anchor),t.resolve(n.head))}static create(t,n,r=n){return new e(t.resolve(n),t.resolve(r))}getBookmark(){return new RJ(this.$anchorCell.pos,this.$headCell.pos)}};LJ.prototype.visible=!1,Bp.jsonID(`cell`,LJ);var RJ=class e{constructor(e,t){this.anchor=e,this.head=t}map(t){return new e(t.map(this.anchor),t.map(this.head))}resolve(e){let t=e.resolve(this.anchor),n=e.resolve(this.head);return t.parent.type.spec.tableRole==`row`&&n.parent.type.spec.tableRole==`row`&&t.index()<t.parent.childCount&&n.index()<n.parent.childCount&&MJ(t,n)?new LJ(t,n):Bp.near(n,1)}};function zJ(e){if(!(e.selection instanceof LJ))return null;let t=[];return e.selection.forEachCell((e,n)=>{t.push(rz.node(n,n+e.nodeSize,{class:`selectedCell`}))}),oz.create(e.doc,t)}function BJ({$from:e,$to:t}){if(e.pos==t.pos||e.pos<t.pos-6)return!1;let n=e.pos,r=t.pos,i=e.depth;for(;i>=0&&!(e.after(i+1)<e.end(i));i--,n++);for(let e=t.depth;e>=0&&!(t.before(e+1)>t.start(e));e--,r--);return n==r&&/row|table/.test(e.node(i).type.spec.tableRole)}function VJ({$from:e,$to:t}){let n,r;for(let t=e.depth;t>0;t--){let r=e.node(t);if(r.type.spec.tableRole===`cell`||r.type.spec.tableRole===`header_cell`){n=r;break}}for(let e=t.depth;e>0;e--){let n=t.node(e);if(n.type.spec.tableRole===`cell`||n.type.spec.tableRole===`header_cell`){r=n;break}}return n!==r&&t.parentOffset===0}function HJ(e,t,n){let r=(t||e).selection,i=(t||e).doc,a,o;if(r instanceof Kp&&(o=r.node.type.spec.tableRole)){if(o==`cell`||o==`header_cell`)a=LJ.create(i,r.from);else if(o==`row`){let e=i.resolve(r.from+1);a=LJ.rowSelection(e,e)}else if(!n){let e=vJ.get(r.node),t=r.from+1,n=t+e.map[e.width*e.height-1];a=LJ.create(i,t+1,n)}}else r instanceof Wp&&BJ(r)?a=Wp.create(i,r.from):r instanceof Wp&&VJ(r)&&(a=Wp.create(i,r.$from.start(),r.$from.end()));return a&&(t||=e.tr).setSelection(a),t}var UJ=new dm(`fix-tables`);function WJ(e,t,n,r){let i=e.childCount,a=t.childCount;outer:for(let o=0,s=0;o<a;o++){let a=t.child(o);for(let t=s,r=Math.min(i,o+3);t<r;t++)if(e.child(t)==a){s=t+1,n+=a.nodeSize;continue outer}r(a,n),s<i&&e.child(s).sameMarkup(a)?WJ(e.child(s),a,n+1,r):a.nodesBetween(0,a.content.size,r,n+1),n+=a.nodeSize}}function GJ(e,t){let n,r=(t,r)=>{t.type.spec.tableRole==`table`&&(n=KJ(e,t,r,n))};return t?t.doc!=e.doc&&WJ(t.doc,e.doc,0,r):e.doc.descendants(r),n}function KJ(e,t,n,r){let i=vJ.get(t);if(!i.problems)return r;r||=e.tr;let a=[];for(let e=0;e<i.height;e++)a.push(0);for(let e=0;e<i.problems.length;e++){let o=i.problems[e];if(o.type==`collision`){let e=t.nodeAt(o.pos);if(!e)continue;let i=e.attrs;for(let e=0;e<i.rowspan;e++)a[o.row+e]+=o.n;r.setNodeMarkup(r.mapping.map(n+1+o.pos),null,PJ(i,i.colspan-o.n,o.n))}else if(o.type==`missing`)a[o.row]+=o.n;else if(o.type==`overlong_rowspan`){let e=t.nodeAt(o.pos);if(!e)continue;r.setNodeMarkup(r.mapping.map(n+1+o.pos),null,{...e.attrs,rowspan:e.attrs.rowspan-o.n})}else if(o.type==`colwidth mismatch`){let e=t.nodeAt(o.pos);if(!e)continue;r.setNodeMarkup(r.mapping.map(n+1+o.pos),null,{...e.attrs,colwidth:o.colwidth})}else if(o.type==`zero_sized`){let e=r.mapping.map(n);r.delete(e,e+t.nodeSize)}}let o,s;for(let e=0;e<a.length;e++)a[e]&&(o??=e,s=e);for(let c=0,l=n+1;c<i.height;c++){let n=t.child(c),i=l+n.nodeSize,u=a[c];if(u>0){let t=`cell`;n.firstChild&&(t=n.firstChild.type.spec.tableRole);let a=[];for(let n=0;n<u;n++){let n=CJ(e.schema)[t].createAndFill();n&&a.push(n)}let d=(c==0||o==c-1)&&s==c?l+1:i-1;r.insert(r.mapping.map(d),a)}l=i}return r.setMeta(UJ,{fixTables:!0})}function qJ(e){let t=e.selection,n=OJ(e),r=n.node(-1),i=n.start(-1),a=vJ.get(r);return{...t instanceof LJ?a.rectBetween(t.$anchorCell.pos-i,t.$headCell.pos-i):a.findCell(n.pos-i),tableStart:i,map:a,table:r}}function JJ(e,{map:t,tableStart:n,table:r},i){let a=i>0?-1:0;IJ(t,r,i+a)&&(a=i==0||i==t.width?null:0);for(let o=0;o<t.height;o++){let s=o*t.width+i;if(i>0&&i<t.width&&t.map[s-1]==t.map[s]){let a=t.map[s],c=r.nodeAt(a);e.setNodeMarkup(e.mapping.map(n+a),null,FJ(c.attrs,i-t.colCount(a))),o+=c.attrs.rowspan-1}else{let c=a==null?CJ(r.type.schema).cell:r.nodeAt(t.map[s+a]).type,l=t.positionAt(o,i,r);e.insert(e.mapping.map(n+l),c.createAndFill())}}return e}function YJ(e,t){if(!DJ(e))return!1;if(t){let n=qJ(e);t(JJ(e.tr,n,n.left))}return!0}function XJ(e,t){if(!DJ(e))return!1;if(t){let n=qJ(e);t(JJ(e.tr,n,n.right))}return!0}function ZJ(e,{map:t,table:n,tableStart:r},i){let a=e.mapping.maps.length;for(let o=0;o<t.height;){let s=o*t.width+i,c=t.map[s],l=n.nodeAt(c),u=l.attrs;if(i>0&&t.map[s-1]==c||i<t.width-1&&t.map[s+1]==c)e.setNodeMarkup(e.mapping.slice(a).map(r+c),null,PJ(u,i-t.colCount(c)));else{let t=e.mapping.slice(a).map(r+c);e.delete(t,t+l.nodeSize)}o+=u.rowspan}}function QJ(e,t){if(!DJ(e))return!1;if(t){let n=qJ(e),r=e.tr;if(n.left==0&&n.right==n.map.width)return!1;for(let e=n.right-1;ZJ(r,n,e),e!=n.left;e--){let e=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!e)throw RangeError(`No table found`);n.table=e,n.map=vJ.get(e)}t(r)}return!0}function $J(e,t,n){let r=CJ(t.type.schema).header_cell;for(let i=0;i<e.width;i++)if(t.nodeAt(e.map[i+n*e.width])?.type!=r)return!1;return!0}function eY(e,{map:t,tableStart:n,table:r},i){let a=n;for(let e=0;e<i;e++)a+=r.child(e).nodeSize;let o=[],s=i>0?-1:0;$J(t,r,i+s)&&(s=i==0||i==t.height?null:0);for(let a=0,c=t.width*i;a<t.width;a++,c++)if(i>0&&i<t.height&&t.map[c]==t.map[c-t.width]){let i=t.map[c],o=r.nodeAt(i).attrs;e.setNodeMarkup(n+i,null,{...o,rowspan:o.rowspan+1}),a+=o.colspan-1}else{let e=(s==null?CJ(r.type.schema).cell:r.nodeAt(t.map[c+s*t.width])?.type)?.createAndFill();e&&o.push(e)}return e.insert(a,CJ(r.type.schema).row.create(null,o)),e}function tY(e,t){if(!DJ(e))return!1;if(t){let n=qJ(e);t(eY(e.tr,n,n.top))}return!0}function nY(e,t){if(!DJ(e))return!1;if(t){let n=qJ(e);t(eY(e.tr,n,n.bottom))}return!0}function rY(e,{map:t,table:n,tableStart:r},i){let a=0;for(let e=0;e<i;e++)a+=n.child(e).nodeSize;let o=a+n.child(i).nodeSize,s=e.mapping.maps.length;e.delete(a+r,o+r);let c=new Set;for(let a=0,o=i*t.width;a<t.width;a++,o++){let l=t.map[o];if(!c.has(l)){if(c.add(l),i>0&&l==t.map[o-t.width]){let t=n.nodeAt(l).attrs;e.setNodeMarkup(e.mapping.slice(s).map(l+r),null,{...t,rowspan:t.rowspan-1}),a+=t.colspan-1}else if(i<t.height&&l==t.map[o+t.width]){let o=n.nodeAt(l),c=o.attrs,u=o.type.create({...c,rowspan:o.attrs.rowspan-1},o.content),d=t.positionAt(i+1,a,n);e.insert(e.mapping.slice(s).map(r+d),u),a+=c.colspan-1}}}}function iY(e,t){if(!DJ(e))return!1;if(t){let n=qJ(e),r=e.tr;if(n.top==0&&n.bottom==n.map.height)return!1;for(let e=n.bottom-1;rY(r,n,e),e!=n.top;e--){let e=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!e)throw RangeError(`No table found`);n.table=e,n.map=vJ.get(n.table)}t(r)}return!0}function aY(e){let t=e.content;return t.childCount==1&&t.child(0).isTextblock&&t.child(0).childCount==0}function oY({width:e,height:t,map:n},r){let i=r.top*e+r.left,a=i,o=(r.bottom-1)*e+r.left,s=i+(r.right-r.left-1);for(let t=r.top;t<r.bottom;t++){if(r.left>0&&n[a]==n[a-1]||r.right<e&&n[s]==n[s+1])return!0;a+=e,s+=e}for(let a=r.left;a<r.right;a++){if(r.top>0&&n[i]==n[i-e]||r.bottom<t&&n[o]==n[o+e])return!0;i++,o++}return!1}function sY(e,t){let n=e.selection;if(!(n instanceof LJ)||n.$anchorCell.pos==n.$headCell.pos)return!1;let r=qJ(e),{map:i}=r;if(oY(i,r))return!1;if(t){let n=e.tr,a={},o=Z.empty,s,c;for(let e=r.top;e<r.bottom;e++)for(let t=r.left;t<r.right;t++){let l=i.map[e*i.width+t],u=r.table.nodeAt(l);if(!(a[l]||!u))if(a[l]=!0,s==null)s=l,c=u;else{aY(u)||(o=o.append(u.content));let e=n.mapping.map(l+r.tableStart);n.delete(e,e+u.nodeSize)}}if(s==null||c==null)return!0;if(n.setNodeMarkup(s+r.tableStart,null,{...FJ(c.attrs,c.attrs.colspan,r.right-r.left-c.attrs.colspan),rowspan:r.bottom-r.top}),o.size>0){let e=s+1+c.content.size,t=aY(c)?s+1:e;n.replaceWith(t+r.tableStart,e+r.tableStart,o)}n.setSelection(new LJ(n.doc.resolve(s+r.tableStart))),t(n)}return!0}function cY(e,t){let n=CJ(e.schema);return lY(({node:e})=>n[e.type.spec.tableRole])(e,t)}function lY(e){return(t,n)=>{let r=t.selection,i,a;if(r instanceof LJ){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;i=r.$anchorCell.nodeAfter,a=r.$anchorCell.pos}else{if(i=EJ(r.$from),!i)return!1;a=TJ(r.$from)?.pos}if(i==null||a==null||i.attrs.colspan==1&&i.attrs.rowspan==1)return!1;if(n){let o=i.attrs,s=[],c=o.colwidth;o.rowspan>1&&(o={...o,rowspan:1}),o.colspan>1&&(o={...o,colspan:1});let l=qJ(t),u=t.tr;for(let e=0;e<l.right-l.left;e++)s.push(c?{...o,colwidth:c&&c[e]?[c[e]]:null}:o);let d;for(let t=l.top;t<l.bottom;t++){let n=l.map.positionAt(t,l.left,l.table);t==l.top&&(n+=i.nodeSize);for(let r=l.left,a=0;r<l.right;r++,a++)r==l.left&&t==l.top||u.insert(d=u.mapping.map(n+l.tableStart,1),e({node:i,row:t,col:r}).createAndFill(s[a]))}u.setNodeMarkup(a,e({node:i,row:l.top,col:l.left}),s[0]),r instanceof LJ&&u.setSelection(new LJ(u.doc.resolve(r.$anchorCell.pos),d?u.doc.resolve(d):void 0)),n(u)}return!0}}function uY(e,t){return function(n,r){if(!DJ(n))return!1;let i=OJ(n);if(i.nodeAfter.attrs[e]===t)return!1;if(r){let a=n.tr;n.selection instanceof LJ?n.selection.forEachCell((n,r)=>{n.attrs[e]!==t&&a.setNodeMarkup(r,null,{...n.attrs,[e]:t})}):a.setNodeMarkup(i.pos,null,{...i.nodeAfter.attrs,[e]:t}),r(a)}return!0}}function dY(e){return function(t,n){if(!DJ(t))return!1;if(n){let r=CJ(t.schema),i=qJ(t),a=t.tr,o=i.map.cellsInRect(e==`column`?{left:i.left,top:0,right:i.right,bottom:i.map.height}:e==`row`?{left:0,top:i.top,right:i.map.width,bottom:i.bottom}:i),s=o.map(e=>i.table.nodeAt(e));for(let e=0;e<o.length;e++)s[e].type==r.header_cell&&a.setNodeMarkup(i.tableStart+o[e],r.cell,s[e].attrs);if(a.steps.length===0)for(let e=0;e<o.length;e++)a.setNodeMarkup(i.tableStart+o[e],r.header_cell,s[e].attrs);n(a)}return!0}}function fY(e,t,n){let r=t.map.cellsInRect({left:0,top:0,right:e==`row`?t.map.width:1,bottom:e==`column`?t.map.height:1});for(let e=0;e<r.length;e++){let i=t.table.nodeAt(r[e]);if(i&&i.type!==n.header_cell)return!1}return!0}function pY(e,t){return t||={useDeprecatedLogic:!1},t.useDeprecatedLogic?dY(e):function(t,n){if(!DJ(t))return!1;if(n){let r=CJ(t.schema),i=qJ(t),a=t.tr,o=fY(`row`,i,r),s=fY(`column`,i,r),c=(e===`column`?o:e===`row`&&s)?1:0,l=e==`column`?{left:0,top:c,right:1,bottom:i.map.height}:e==`row`?{left:c,top:0,right:i.map.width,bottom:1}:i,u=e==`column`?s?r.cell:r.header_cell:e==`row`?o?r.cell:r.header_cell:r.cell;i.map.cellsInRect(l).forEach(e=>{let t=e+i.tableStart,n=a.doc.nodeAt(t);n&&a.setNodeMarkup(t,u,n.attrs)}),n(a)}return!0}}pY(`row`,{useDeprecatedLogic:!0}),pY(`column`,{useDeprecatedLogic:!0});var mY=pY(`cell`,{useDeprecatedLogic:!0});function hY(e,t){if(t<0){let t=e.nodeBefore;if(t)return e.pos-t.nodeSize;for(let t=e.index(-1)-1,n=e.before();t>=0;t--){let r=e.node(-1).child(t),i=r.lastChild;if(i)return n-1-i.nodeSize;n-=r.nodeSize}}else{if(e.index()<e.parent.childCount-1)return e.pos+e.nodeAfter.nodeSize;let t=e.node(-1);for(let n=e.indexAfter(-1),r=e.after();n<t.childCount;n++){let e=t.child(n);if(e.childCount)return r+1;r+=e.nodeSize}}return null}function gY(e){return function(t,n){if(!DJ(t))return!1;let r=hY(OJ(t),e);if(r==null)return!1;if(n){let e=t.doc.resolve(r);n(t.tr.setSelection(Wp.between(e,jJ(e))).scrollIntoView())}return!0}}function _Y(e,t){let n=e.selection.$anchor;for(let r=n.depth;r>0;r--)if(n.node(r).type.spec.tableRole==`table`)return t&&t(e.tr.delete(n.before(r),n.after(r)).scrollIntoView()),!0;return!1}function vY(e,t){let n=e.selection;if(!(n instanceof LJ))return!1;if(t){let r=e.tr,i=CJ(e.schema).cell.createAndFill().content;n.forEachCell((e,t)=>{e.content.eq(i)||r.replace(r.mapping.map(t+1),r.mapping.map(t+e.nodeSize-1),new Q(i,0,0))}),r.docChanged&&t(r)}return!0}function yY(e){if(e.size===0)return null;let{content:t,openStart:n,openEnd:r}=e;for(;t.childCount==1&&(n>0&&r>0||t.child(0).type.spec.tableRole==`table`);)n--,r--,t=t.child(0).content;let i=t.child(0),a=i.type.spec.tableRole,o=i.type.schema,s=[];if(a==`row`)for(let e=0;e<t.childCount;e++){let i=t.child(e).content,a=e?0:Math.max(0,n-1),c=e<t.childCount-1?0:Math.max(0,r-1);(a||c)&&(i=xY(CJ(o).row,new Q(i,a,c)).content),s.push(i)}else if(a==`cell`||a==`header_cell`)s.push(n||r?xY(CJ(o).row,new Q(t,n,r)).content:t);else return null;return bY(o,s)}function bY(e,t){let n=[];for(let e=0;e<t.length;e++){let r=t[e];for(let t=r.childCount-1;t>=0;t--){let{rowspan:i,colspan:a}=r.child(t).attrs;for(let t=e;t<e+i;t++)n[t]=(n[t]||0)+a}}let r=0;for(let e=0;e<n.length;e++)r=Math.max(r,n[e]);for(let i=0;i<n.length;i++)if(i>=t.length&&t.push(Z.empty),n[i]<r){let a=CJ(e).cell.createAndFill(),o=[];for(let e=n[i];e<r;e++)o.push(a);t[i]=t[i].append(Z.from(o))}return{height:t.length,width:r,rows:t}}function xY(e,t){let n=e.createAndFill();return new Rp(n).replace(0,n.content.size,t).doc}function SY({width:e,height:t,rows:n},r,i){if(e!=r){let t=[],i=[];for(let e=0;e<n.length;e++){let a=n[e],o=[];for(let n=t[e]||0,i=0;n<r;i++){let s=a.child(i%a.childCount);n+s.attrs.colspan>r&&(s=s.type.createChecked(PJ(s.attrs,s.attrs.colspan,n+s.attrs.colspan-r),s.content)),o.push(s),n+=s.attrs.colspan;for(let n=1;n<s.attrs.rowspan;n++)t[e+n]=(t[e+n]||0)+s.attrs.colspan}i.push(Z.from(o))}n=i,e=r}if(t!=i){let e=[];for(let r=0,a=0;r<i;r++,a++){let o=[],s=n[a%t];for(let e=0;e<s.childCount;e++){let t=s.child(e);r+t.attrs.rowspan>i&&(t=t.type.create({...t.attrs,rowspan:Math.max(1,i-t.attrs.rowspan)},t.content)),o.push(t)}e.push(Z.from(o))}n=e,t=i}return{width:e,height:t,rows:n}}function CY(e,t,n,r,i,a,o){let s=e.doc.type.schema,c=CJ(s),l,u;if(i>t.width)for(let a=0,s=0;a<t.height;a++){let d=n.child(a);s+=d.nodeSize;let f=[],p;p=d.lastChild==null||d.lastChild.type==c.cell?l||=c.cell.createAndFill():u||=c.header_cell.createAndFill();for(let e=t.width;e<i;e++)f.push(p);e.insert(e.mapping.slice(o).map(s-1+r),f)}if(a>t.height){let s=[];for(let e=0,r=(t.height-1)*t.width;e<Math.max(t.width,i);e++){let i=e>=t.width?!1:n.nodeAt(t.map[r+e]).type==c.header_cell;s.push(i?u||=c.header_cell.createAndFill():l||=c.cell.createAndFill())}let d=c.row.create(null,Z.from(s)),f=[];for(let e=t.height;e<a;e++)f.push(d);e.insert(e.mapping.slice(o).map(r+n.nodeSize-2),f)}return!!(l||u)}function wY(e,t,n,r,i,a,o,s){if(o==0||o==t.height)return!1;let c=!1;for(let l=i;l<a;l++){let i=o*t.width+l,a=t.map[i];if(t.map[i-t.width]==a){c=!0;let i=n.nodeAt(a),{top:u,left:d}=t.findCell(a);e.setNodeMarkup(e.mapping.slice(s).map(a+r),null,{...i.attrs,rowspan:o-u}),e.insert(e.mapping.slice(s).map(t.positionAt(o,d,n)),i.type.createAndFill({...i.attrs,rowspan:u+i.attrs.rowspan-o})),l+=i.attrs.colspan-1}}return c}function TY(e,t,n,r,i,a,o,s){if(o==0||o==t.width)return!1;let c=!1;for(let l=i;l<a;l++){let i=l*t.width+o,a=t.map[i];if(t.map[i-1]==a){c=!0;let i=n.nodeAt(a),u=t.colCount(a),d=e.mapping.slice(s).map(a+r);e.setNodeMarkup(d,null,PJ(i.attrs,o-u,i.attrs.colspan-(o-u))),e.insert(d+i.nodeSize,i.type.createAndFill(PJ(i.attrs,0,o-u))),l+=i.attrs.rowspan-1}}return c}function EY(e,t,n,r,i){let a=n?e.doc.nodeAt(n-1):e.doc;if(!a)throw Error(`No table found`);let o=vJ.get(a),{top:s,left:c}=r,l=c+i.width,u=s+i.height,d=e.tr,f=0;function p(){if(a=n?d.doc.nodeAt(n-1):d.doc,!a)throw Error(`No table found`);o=vJ.get(a),f=d.mapping.maps.length}CY(d,o,a,n,l,u,f)&&p(),wY(d,o,a,n,c,l,s,f)&&p(),wY(d,o,a,n,c,l,u,f)&&p(),TY(d,o,a,n,s,u,c,f)&&p(),TY(d,o,a,n,s,u,l,f)&&p();for(let e=s;e<u;e++){let t=o.positionAt(e,c,a),r=o.positionAt(e,l,a);d.replace(d.mapping.slice(f).map(t+n),d.mapping.slice(f).map(r+n),new Q(i.rows[e-s],0,0))}p(),d.setSelection(new LJ(d.doc.resolve(n+o.positionAt(s,c,a)),d.doc.resolve(n+o.positionAt(u-1,l-1,a)))),t(d)}var DY=sB({ArrowLeft:kY(`horiz`,-1),ArrowRight:kY(`horiz`,1),ArrowUp:kY(`vert`,-1),ArrowDown:kY(`vert`,1),"Shift-ArrowLeft":AY(`horiz`,-1),"Shift-ArrowRight":AY(`horiz`,1),"Shift-ArrowUp":AY(`vert`,-1),"Shift-ArrowDown":AY(`vert`,1),Backspace:vY,"Mod-Backspace":vY,Delete:vY,"Mod-Delete":vY});function OY(e,t,n){return n.eq(e.selection)?!1:(t&&t(e.tr.setSelection(n).scrollIntoView()),!0)}function kY(e,t){return(n,r,i)=>{if(!i)return!1;let a=n.selection;if(a instanceof LJ)return OY(n,r,Bp.near(a.$headCell,t));if(e!=`horiz`&&!a.empty)return!1;let o=PY(i,e,t);if(o==null)return!1;if(e==`horiz`)return OY(n,r,Bp.near(n.doc.resolve(a.head+t),t));{let i=n.doc.resolve(o),a=NJ(i,e,t),s;return s=a?Bp.near(a,1):t<0?Bp.near(n.doc.resolve(i.before(-1)),-1):Bp.near(n.doc.resolve(i.after(-1)),1),OY(n,r,s)}}}function AY(e,t){return(n,r,i)=>{if(!i)return!1;let a=n.selection,o;if(a instanceof LJ)o=a;else{let r=PY(i,e,t);if(r==null)return!1;o=new LJ(n.doc.resolve(r))}let s=NJ(o.$headCell,e,t);return s?OY(n,r,new LJ(o.$anchorCell,s)):!1}}function jY(e,t){let n=e.state.doc,r=TJ(n.resolve(t));return r?(e.dispatch(e.state.tr.setSelection(new LJ(r))),!0):!1}function MY(e,t,n){if(!DJ(e.state))return!1;let r=yY(n),i=e.state.selection;if(i instanceof LJ){r||={width:1,height:1,rows:[Z.from(xY(CJ(e.state.schema).cell,n))]};let t=i.$anchorCell.node(-1),a=i.$anchorCell.start(-1),o=vJ.get(t).rectBetween(i.$anchorCell.pos-a,i.$headCell.pos-a);return r=SY(r,o.right-o.left,o.bottom-o.top),EY(e.state,e.dispatch,a,o,r),!0}else if(r){let t=OJ(e.state),n=t.start(-1);return EY(e.state,e.dispatch,n,vJ.get(t.node(-1)).findCell(t.pos-n),r),!0}else return!1}function NY(e,t){if(t.button!=0||t.ctrlKey||t.metaKey)return;let n=FY(e,t.target),r;if(t.shiftKey&&e.state.selection instanceof LJ)i(e.state.selection.$anchorCell,t),t.preventDefault();else if(t.shiftKey&&n&&(r=TJ(e.state.selection.$anchor))!=null&&IY(e,t)?.pos!=r.pos)i(r,t),t.preventDefault();else if(!n)return;function i(t,n){let r=IY(e,n),i=wJ.getState(e.state)==null;if(!r||!MJ(t,r))if(i)r=t;else return;let a=new LJ(t,r);if(i||!e.state.selection.eq(a)){let n=e.state.tr.setSelection(a);i&&n.setMeta(wJ,t.pos),e.dispatch(n)}}function a(){e.root.removeEventListener(`mouseup`,a),e.root.removeEventListener(`dragstart`,a),e.root.removeEventListener(`mousemove`,o),wJ.getState(e.state)!=null&&e.dispatch(e.state.tr.setMeta(wJ,-1))}function o(r){let o=r,s=wJ.getState(e.state),c;if(s!=null)c=e.state.doc.resolve(s);else if(FY(e,o.target)!=n&&(c=IY(e,t),!c))return a();c&&i(c,o)}e.root.addEventListener(`mouseup`,a),e.root.addEventListener(`dragstart`,a),e.root.addEventListener(`mousemove`,o)}function PY(e,t,n){if(!(e.state.selection instanceof Wp))return null;let{$head:r}=e.state.selection;for(let i=r.depth-1;i>=0;i--){let a=r.node(i);if((n<0?r.index(i):r.indexAfter(i))!=(n<0?0:a.childCount))return null;if(a.type.spec.tableRole==`cell`||a.type.spec.tableRole==`header_cell`){let a=r.before(i),o=t==`vert`?n>0?`down`:`up`:n>0?`right`:`left`;return e.endOfTextblock(o)?a:null}}return null}function FY(e,t){for(;t&&t!=e.dom;t=t.parentNode)if(t.nodeName==`TD`||t.nodeName==`TH`)return t;return null}function IY(e,t){let n=e.posAtCoords({left:t.clientX,top:t.clientY});if(!n)return null;let{inside:r,pos:i}=n;return r>=0&&TJ(e.state.doc.resolve(r))||TJ(e.state.doc.resolve(i))}var LY=class{constructor(e,t){this.node=e,this.defaultCellMinWidth=t,this.dom=document.createElement(`div`),this.dom.className=`tableWrapper`,this.table=this.dom.appendChild(document.createElement(`table`)),this.table.style.setProperty(`--default-cell-min-width`,`${t}px`),this.colgroup=this.table.appendChild(document.createElement(`colgroup`)),RY(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement(`tbody`))}update(e){return e.type==this.node.type?(this.node=e,RY(e,this.colgroup,this.table,this.defaultCellMinWidth),!0):!1}ignoreMutation(e){return e.type==`attributes`&&(e.target==this.table||this.colgroup.contains(e.target))}};function RY(e,t,n,r,i,a){let o=0,s=!0,c=t.firstChild,l=e.firstChild;if(l){for(let e=0,n=0;e<l.childCount;e++){let{colspan:u,colwidth:d}=l.child(e).attrs;for(let e=0;e<u;e++,n++){let l=i==n?a:d&&d[e],u=l?l+`px`:``;if(o+=l||r,l||(s=!1),c)c.style.width!=u&&(c.style.width=u),c=c.nextSibling;else{let e=document.createElement(`col`);e.style.width=u,t.appendChild(e)}}}for(;c;){var u;let e=c.nextSibling;(u=c.parentNode)==null||u.removeChild(c),c=e}s?(n.style.width=o+`px`,n.style.minWidth=``):(n.style.width=``,n.style.minWidth=o+`px`)}}var zY=new dm(`tableColumnResizing`);function BY({handleWidth:e=5,cellMinWidth:t=25,defaultCellMinWidth:n=100,View:r=LY,lastColumnResizable:i=!0}={}){let a=new cm({key:zY,state:{init(e,t){var i;let o=(i=a.spec)==null||(i=i.props)==null?void 0:i.nodeViews,s=CJ(t.schema).table.name;return r&&o&&(o[s]=(e,t)=>new r(e,n,t)),new VY(-1,!1)},apply(e,t){return t.apply(e)}},props:{attributes:e=>{let t=zY.getState(e);return t&&t.activeHandle>-1?{class:`resize-cursor`}:{}},handleDOMEvents:{mousemove:(t,n)=>{HY(t,n,e,i)},mouseleave:e=>{UY(e)},mousedown:(e,r)=>{WY(e,r,t,n)}},decorations:e=>{let t=zY.getState(e);if(t&&t.activeHandle>-1)return $Y(e,t.activeHandle)},nodeViews:{}}});return a}var VY=class e{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(t){let n=this,r=t.getMeta(zY);if(r&&r.setHandle!=null)return new e(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new e(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&t.docChanged){let r=t.mapping.map(n.activeHandle,-1);return AJ(t.doc.resolve(r))||(r=-1),new e(r,n.dragging)}return n}};function HY(e,t,n,r){if(!e.editable)return;let i=zY.getState(e.state);if(i&&!i.dragging){let a=KY(t.target),o=-1;if(a){let{left:r,right:i}=a.getBoundingClientRect();t.clientX-r<=n?o=qY(e,t,`left`,n):i-t.clientX<=n&&(o=qY(e,t,`right`,n))}if(o!=i.activeHandle){if(!r&&o!==-1){let t=e.state.doc.resolve(o),n=t.node(-1),r=vJ.get(n),i=t.start(-1);if(r.colCount(t.pos-i)+t.nodeAfter.attrs.colspan-1==r.width-1)return}YY(e,o)}}}function UY(e){if(!e.editable)return;let t=zY.getState(e.state);t&&t.activeHandle>-1&&!t.dragging&&YY(e,-1)}function WY(e,t,n,r){if(!e.editable)return!1;let i=e.dom.ownerDocument.defaultView??window,a=zY.getState(e.state);if(!a||a.activeHandle==-1||a.dragging)return!1;let o=e.state.doc.nodeAt(a.activeHandle),s=GY(e,a.activeHandle,o.attrs);e.dispatch(e.state.tr.setMeta(zY,{setDragging:{startX:t.clientX,startWidth:s}}));function c(t){i.removeEventListener(`mouseup`,c),i.removeEventListener(`mousemove`,l);let r=zY.getState(e.state);r?.dragging&&(XY(e,r.activeHandle,JY(r.dragging,t,n)),e.dispatch(e.state.tr.setMeta(zY,{setDragging:null})))}function l(t){if(!t.which)return c(t);let i=zY.getState(e.state);if(i&&i.dragging){let a=JY(i.dragging,t,n);ZY(e,i.activeHandle,a,r)}}return ZY(e,a.activeHandle,s,r),i.addEventListener(`mouseup`,c),i.addEventListener(`mousemove`,l),t.preventDefault(),!0}function GY(e,t,{colspan:n,colwidth:r}){let i=r&&r[r.length-1];if(i)return i;let a=e.domAtPos(t),o=a.node.childNodes[a.offset].offsetWidth,s=n;if(r)for(let e=0;e<n;e++)r[e]&&(o-=r[e],s--);return o/s}function KY(e){for(;e&&e.nodeName!=`TD`&&e.nodeName!=`TH`;)e=e.classList&&e.classList.contains(`ProseMirror`)?null:e.parentNode;return e}function qY(e,t,n,r){let i=n==`right`?-r:r,a=e.posAtCoords({left:t.clientX+i,top:t.clientY});if(!a)return-1;let{pos:o}=a,s=TJ(e.state.doc.resolve(o));if(!s)return-1;if(n==`right`)return s.pos;let c=vJ.get(s.node(-1)),l=s.start(-1),u=c.map.indexOf(s.pos-l);return u%c.width==0?-1:l+c.map[u-1]}function JY(e,t,n){let r=t.clientX-e.startX;return Math.max(n,e.startWidth+r)}function YY(e,t){e.dispatch(e.state.tr.setMeta(zY,{setHandle:t}))}function XY(e,t,n){let r=e.state.doc.resolve(t),i=r.node(-1),a=vJ.get(i),o=r.start(-1),s=a.colCount(r.pos-o)+r.nodeAfter.attrs.colspan-1,c=e.state.tr;for(let e=0;e<a.height;e++){let t=e*a.width+s;if(e&&a.map[t]==a.map[t-a.width])continue;let r=a.map[t],l=i.nodeAt(r).attrs,u=l.colspan==1?0:s-a.colCount(r);if(l.colwidth&&l.colwidth[u]==n)continue;let d=l.colwidth?l.colwidth.slice():QY(l.colspan);d[u]=n,c.setNodeMarkup(o+r,null,{...l,colwidth:d})}c.docChanged&&e.dispatch(c)}function ZY(e,t,n,r){let i=e.state.doc.resolve(t),a=i.node(-1),o=i.start(-1),s=vJ.get(a).colCount(i.pos-o)+i.nodeAfter.attrs.colspan-1,c=e.domAtPos(i.start(-1)).node;for(;c&&c.nodeName!=`TABLE`;)c=c.parentNode;c&&RY(a,c.firstChild,c,r,s,n)}function QY(e){return Array(e).fill(0)}function $Y(e,t){let n=[],r=e.doc.resolve(t),i=r.node(-1);if(!i)return oz.empty;let a=vJ.get(i),o=r.start(-1),s=a.colCount(r.pos-o)+r.nodeAfter.attrs.colspan-1;for(let t=0;t<a.height;t++){let r=s+t*a.width;if((s==a.width-1||a.map[r]!=a.map[r+1])&&(t==0||a.map[r]!=a.map[r-a.width])){let t=a.map[r],s=o+t+i.nodeAt(t).nodeSize-1,c=document.createElement(`div`);c.className=`column-resize-handle`,zY.getState(e)?.dragging&&n.push(rz.node(o+t,o+t+i.nodeAt(t).nodeSize,{class:`column-resize-dragging`})),n.push(rz.widget(s,c))}}return oz.create(e.doc,n)}function eX({allowTableNodeSelection:e=!1}={}){return new cm({key:wJ,state:{init(){return null},apply(e,t){let n=e.getMeta(wJ);if(n!=null)return n==-1?null:n;if(t==null||!e.docChanged)return t;let{deleted:r,pos:i}=e.mapping.mapResult(t);return r?null:i}},props:{decorations:zJ,handleDOMEvents:{mousedown:NY},createSelectionBetween(e){return wJ.getState(e.state)==null?null:e.state.selection},handleTripleClick:jY,handleKeyDown:DY,handlePaste:MY},appendTransaction(t,n,r){return HJ(r,GJ(r,n),e)}})}function tX(e,t){return t?[`width`,`${Math.max(t,e)}px`]:[`min-width`,`${e}px`]}function nX(e,t,n,r,i,a){var o;let s=0,c=!0,l=t.firstChild,u=e.firstChild;if(u!==null)for(let e=0,n=0;e<u.childCount;e+=1){let{colspan:o,colwidth:d}=u.child(e).attrs;for(let e=0;e<o;e+=1,n+=1){let o=i===n?a:d&&d[e],u=o?`${o}px`:``;if(s+=o||r,o||(c=!1),l){if(l.style.width!==u){let[e,t]=tX(r,o);l.style.setProperty(e,t)}l=l.nextSibling}else{let e=document.createElement(`col`),[n,i]=tX(r,o);e.style.setProperty(n,i),t.appendChild(e)}}}for(;l;){let e=l.nextSibling;(o=l.parentNode)==null||o.removeChild(l),l=e}c?(n.style.width=`${s}px`,n.style.minWidth=``):(n.style.width=``,n.style.minWidth=`${s}px`)}var rX=class{constructor(e,t){this.node=e,this.cellMinWidth=t,this.dom=document.createElement(`div`),this.dom.className=`tableWrapper`,this.table=this.dom.appendChild(document.createElement(`table`)),this.colgroup=this.table.appendChild(document.createElement(`colgroup`)),nX(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement(`tbody`))}update(e){return e.type===this.node.type?(this.node=e,nX(e,this.colgroup,this.table,this.cellMinWidth),!0):!1}ignoreMutation(e){return e.type===`attributes`&&(e.target===this.table||this.colgroup.contains(e.target))}};function iX(e,t,n,r){let i=0,a=!0,o=[],s=e.firstChild;if(!s)return{};for(let e=0,c=0;e<s.childCount;e+=1){let{colspan:l,colwidth:u}=s.child(e).attrs;for(let e=0;e<l;e+=1,c+=1){let s=n===c?r:u&&u[e];i+=s||t,s||(a=!1);let[l,d]=tX(t,s);o.push([`col`,{style:`${l}: ${d}`}])}}let c=a?`${i}px`:``,l=a?``:`${i}px`;return{colgroup:[`colgroup`,{},...o],tableWidth:c,tableMinWidth:l}}function aX(e,t){return t?e.createChecked(null,t):e.createAndFill()}function oX(e){if(e.cached.tableNodeTypes)return e.cached.tableNodeTypes;let t={};return Object.keys(e.nodes).forEach(n=>{let r=e.nodes[n];r.spec.tableRole&&(t[r.spec.tableRole]=r)}),e.cached.tableNodeTypes=t,t}function sX(e,t,n,r,i){let a=oX(e),o=[],s=[];for(let e=0;e<n;e+=1){let e=aX(a.cell,i);if(e&&s.push(e),r){let e=aX(a.header_cell,i);e&&o.push(e)}}let c=[];for(let e=0;e<t;e+=1)c.push(a.row.createChecked(null,r&&e===0?o:s));return a.table.createChecked(null,c)}function cX(e){return e instanceof LJ}var lX=({editor:e})=>{let{selection:t}=e.state;if(!cX(t))return!1;let n=0;return QH(t.ranges[0].$from,e=>e.type.name===`table`)?.node.descendants(e=>{if(e.type.name===`table`)return!1;[`tableCell`,`tableHeader`].includes(e.type.name)&&(n+=1)}),n===t.ranges.length?(e.commands.deleteTable(),!0):!1},uX=UU.create({name:`table`,addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:rX,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:`tableRow+`,tableRole:`table`,isolating:!0,group:`block`,parseHTML(){return[{tag:`table`}]},renderHTML({node:e,HTMLAttributes:t}){let{colgroup:n,tableWidth:r,tableMinWidth:i}=iX(e,this.options.cellMinWidth),a=[`table`,aV(this.options.HTMLAttributes,t,{style:r?`width: ${r}`:`min-width: ${i}`}),n,[`tbody`,0]];return this.options.renderWrapper?[`div`,{class:`tableWrapper`},a]:a},addCommands(){return{insertTable:({rows:e=3,cols:t=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:i,editor:a})=>{let o=sX(a.schema,e,t,n);if(i){let e=r.selection.from+1;r.replaceSelectionWith(o).scrollIntoView().setSelection(Wp.near(r.doc.resolve(e)))}return!0},addColumnBefore:()=>({state:e,dispatch:t})=>YJ(e,t),addColumnAfter:()=>({state:e,dispatch:t})=>XJ(e,t),deleteColumn:()=>({state:e,dispatch:t})=>QJ(e,t),addRowBefore:()=>({state:e,dispatch:t})=>tY(e,t),addRowAfter:()=>({state:e,dispatch:t})=>nY(e,t),deleteRow:()=>({state:e,dispatch:t})=>iY(e,t),deleteTable:()=>({state:e,dispatch:t})=>_Y(e,t),mergeCells:()=>({state:e,dispatch:t})=>sY(e,t),splitCell:()=>({state:e,dispatch:t})=>cY(e,t),toggleHeaderColumn:()=>({state:e,dispatch:t})=>pY(`column`)(e,t),toggleHeaderRow:()=>({state:e,dispatch:t})=>pY(`row`)(e,t),toggleHeaderCell:()=>({state:e,dispatch:t})=>mY(e,t),mergeOrSplit:()=>({state:e,dispatch:t})=>sY(e,t)?!0:cY(e,t),setCellAttribute:(e,t)=>({state:n,dispatch:r})=>uY(e,t)(n,r),goToNextCell:()=>({state:e,dispatch:t})=>gY(1)(e,t),goToPreviousCell:()=>({state:e,dispatch:t})=>gY(-1)(e,t),fixTables:()=>({state:e,dispatch:t})=>(t&&GJ(e),!0),setCellSelection:e=>({tr:t,dispatch:n})=>{if(n){let n=LJ.create(t.doc,e.anchorCell,e.headCell);t.setSelection(n)}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:lX,"Mod-Backspace":lX,Delete:lX,"Mod-Delete":lX}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[BY({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],eX({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(e){return{tableRole:cV(tV(e,`tableRole`,{name:e.name,options:e.options,storage:e.storage}))}}}),dX=UU.create({name:`tableCell`,addOptions(){return{HTMLAttributes:{}}},content:`block+`,addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:e=>{let t=e.getAttribute(`colwidth`);return t?t.split(`,`).map(e=>parseInt(e,10)):null}}}},tableRole:`cell`,isolating:!0,parseHTML(){return[{tag:`td`}]},renderHTML({HTMLAttributes:e}){return[`td`,aV(this.options.HTMLAttributes,e),0]}}),fX=UU.create({name:`tableHeader`,addOptions(){return{HTMLAttributes:{}}},content:`block+`,addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:e=>{let t=e.getAttribute(`colwidth`);return t?t.split(`,`).map(e=>parseInt(e,10)):null}}}},tableRole:`header_cell`,isolating:!0,parseHTML(){return[{tag:`th`}]},renderHTML({HTMLAttributes:e}){return[`th`,aV(this.options.HTMLAttributes,e),0]}}),pX=UU.create({name:`tableRow`,addOptions(){return{HTMLAttributes:{}}},content:`(tableCell | tableHeader)*`,tableRole:`row`,parseHTML(){return[{tag:`tr`}]},renderHTML({HTMLAttributes:e}){return[`tr`,aV(this.options.HTMLAttributes,e),0]}}),mX=EV.create({name:`underline`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`u`},{style:`text-decoration`,consuming:!1,getAttrs:e=>e.includes(`underline`)?{}:!1}]},renderHTML({HTMLAttributes:e}){return[`u`,aV(this.options.HTMLAttributes,e),0]},addCommands(){return{setUnderline:()=>({commands:e})=>e.setMark(this.name),toggleUnderline:()=>({commands:e})=>e.toggleMark(this.name),unsetUnderline:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),hX=/^\s*>\s$/,gX=UU.create({name:`blockquote`,addOptions(){return{HTMLAttributes:{}}},content:`block+`,group:`block`,defining:!0,parseHTML(){return[{tag:`blockquote`}]},renderHTML({HTMLAttributes:e}){return[`blockquote`,aV(this.options.HTMLAttributes,e),0]},addCommands(){return{setBlockquote:()=>({commands:e})=>e.wrapIn(this.name),toggleBlockquote:()=>({commands:e})=>e.toggleWrap(this.name),unsetBlockquote:()=>({commands:e})=>e.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[HU({find:hX,type:this.type})]}}),_X=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,vX=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,yX=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,bX=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,xX=EV.create({name:`bold`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`strong`},{tag:`b`,getAttrs:e=>e.style.fontWeight!==`normal`&&null},{style:`font-weight=400`,clearMark:e=>e.type.name===this.name},{style:`font-weight`,getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}]},renderHTML({HTMLAttributes:e}){return[`strong`,aV(this.options.HTMLAttributes,e),0]},addCommands(){return{setBold:()=>({commands:e})=>e.setMark(this.name),toggleBold:()=>({commands:e})=>e.toggleMark(this.name),unsetBold:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[RU({find:_X,type:this.type}),RU({find:yX,type:this.type})]},addPasteRules(){return[WU({find:vX,type:this.type}),WU({find:bX,type:this.type})]}}),SX=`listItem`,CX=`textStyle`,wX=/^\s*([-+*])\s$/,TX=UU.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:e}){return[`ul`,aV(this.options.HTMLAttributes,e),0]},addCommands(){return{toggleBulletList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(SX,this.editor.getAttributes(CX)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let e=HU({find:wX,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(e=HU({find:wX,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(CX),editor:this.editor})),[e]}}),EX=/(^|[^`])`([^`]+)`(?!`)/,DX=/(^|[^`])`([^`]+)`(?!`)/g,OX=EV.create({name:`code`,addOptions(){return{HTMLAttributes:{}}},excludes:`_`,code:!0,exitable:!0,parseHTML(){return[{tag:`code`}]},renderHTML({HTMLAttributes:e}){return[`code`,aV(this.options.HTMLAttributes,e),0]},addCommands(){return{setCode:()=>({commands:e})=>e.setMark(this.name),toggleCode:()=>({commands:e})=>e.toggleMark(this.name),unsetCode:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[RU({find:EX,type:this.type})]},addPasteRules(){return[WU({find:DX,type:this.type})]}}),kX=/^```([a-z]+)?[\s\n]$/,AX=/^~~~([a-z]+)?[\s\n]$/,jX=UU.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:e=>{let{languageClassPrefix:t}=this.options;return[...e.firstElementChild?.classList||[]].filter(e=>e.startsWith(t)).map(e=>e.replace(t,``))[0]||null},rendered:!1}}},parseHTML(){return[{tag:`pre`,preserveWhitespace:`full`}]},renderHTML({node:e,HTMLAttributes:t}){return[`pre`,aV(this.options.HTMLAttributes,t),[`code`,{class:e.attrs.language?this.options.languageClassPrefix+e.attrs.language:null},0]]},addCommands(){return{setCodeBlock:e=>({commands:t})=>t.setNode(this.name,e),toggleCodeBlock:e=>({commands:t})=>t.toggleNode(this.name,`paragraph`,e)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{let{empty:e,$anchor:t}=this.editor.state.selection,n=t.pos===1;return!e||t.parent.type.name!==this.name?!1:n||!t.parent.textContent.length?this.editor.commands.clearNodes():!1},Enter:({editor:e})=>{if(!this.options.exitOnTripleEnter)return!1;let{state:t}=e,{selection:n}=t,{$from:r,empty:i}=n;if(!i||r.parent.type!==this.type)return!1;let a=r.parentOffset===r.parent.nodeSize-2,o=r.parent.textContent.endsWith(`
217
+
218
+ `);return!a||!o?!1:e.chain().command(({tr:e})=>(e.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:e})=>{if(!this.options.exitOnArrowDown)return!1;let{state:t}=e,{selection:n,doc:r}=t,{$from:i,empty:a}=n;if(!a||i.parent.type!==this.type||i.parentOffset!==i.parent.nodeSize-2)return!1;let o=i.after();return o===void 0?!1:r.nodeAt(o)?e.commands.command(({tr:e})=>(e.setSelection(Bp.near(r.resolve(o))),!0)):e.commands.exitCode()}}},addInputRules(){return[BU({find:kX,type:this.type,getAttributes:e=>({language:e[1]})}),BU({find:AX,type:this.type,getAttributes:e=>({language:e[1]})})]},addProseMirrorPlugins(){return[new cm({key:new dm(`codeBlockVSCodeHandler`),props:{handlePaste:(e,t)=>{if(!t.clipboardData||this.editor.isActive(this.type.name))return!1;let n=t.clipboardData.getData(`text/plain`),r=t.clipboardData.getData(`vscode-editor-data`),i=(r?JSON.parse(r):void 0)?.mode;if(!n||!i)return!1;let{tr:a,schema:o}=e.state,s=o.text(n.replace(/\r\n?/g,`
219
+ `));return a.replaceSelectionWith(this.type.create({language:i},s)),a.selection.$from.parent.type!==this.type&&a.setSelection(Wp.near(a.doc.resolve(Math.max(0,a.selection.from-2)))),a.setMeta(`paste`,!0),e.dispatch(a),!0}}})]}}),MX=UU.create({name:`doc`,topNode:!0,content:`block+`});function NX(e={}){return new cm({view(t){return new PX(t,e)}})}var PX=class{constructor(e,t){this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=t.width??1,this.color=t.color===!1?void 0:t.color||`black`,this.class=t.class,this.handlers=[`dragover`,`dragend`,`drop`,`dragleave`].map(t=>{let n=e=>{this[t](e)};return e.dom.addEventListener(t,n),{name:t,handler:n}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){this.cursorPos!=null&&t.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,n,r=this.editorView.dom,i=r.getBoundingClientRect(),a=i.width/r.offsetWidth,o=i.height/r.offsetHeight;if(t){let t=e.nodeBefore,r=e.nodeAfter;if(t||r){let e=this.editorView.nodeDOM(this.cursorPos-(t?t.nodeSize:0));if(e){let i=e.getBoundingClientRect(),a=t?i.bottom:i.top;t&&r&&(a=(a+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let s=this.width/2*o;n={left:i.left,right:i.right,top:a-s,bottom:a+s}}}}if(!n){let e=this.editorView.coordsAtPos(this.cursorPos),t=this.width/2*a;n={left:e.left-t,right:e.left+t,top:e.top,bottom:e.bottom}}let s=this.editorView.dom.offsetParent;this.element||(this.element=s.appendChild(document.createElement(`div`)),this.class&&(this.element.className=this.class),this.element.style.cssText=`position: absolute; z-index: 50; pointer-events: none;`,this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle(`prosemirror-dropcursor-block`,t),this.element.classList.toggle(`prosemirror-dropcursor-inline`,!t);let c,l;if(!s||s==document.body&&getComputedStyle(s).position==`static`)c=-pageXOffset,l=-pageYOffset;else{let e=s.getBoundingClientRect(),t=e.width/s.offsetWidth,n=e.height/s.offsetHeight;c=e.left-s.scrollLeft*t,l=e.top-s.scrollTop*n}this.element.style.left=(n.left-c)/a+`px`,this.element.style.top=(n.top-l)/o+`px`,this.element.style.width=(n.right-n.left)/a+`px`,this.element.style.height=(n.bottom-n.top)/o+`px`}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),n=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),r=n&&n.type.spec.disableDropCursor,i=typeof r==`function`?r(this.editorView,t,e):r;if(t&&!i){let e=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let t=yp(this.editorView.state.doc,e,this.editorView.dragging.slice);t!=null&&(e=t)}this.setCursor(e),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}},FX=IV.create({name:`dropCursor`,addOptions(){return{color:`currentColor`,width:1,class:void 0}},addProseMirrorPlugins(){return[NX(this.options)]}}),IX=class e extends Bp{constructor(e){super(e,e)}map(t,n){let r=t.resolve(n.map(this.head));return e.valid(r)?new e(r):Bp.near(r)}content(){return Q.empty}eq(t){return t instanceof e&&t.head==this.head}toJSON(){return{type:`gapcursor`,pos:this.head}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for GapCursor.fromJSON`);return new e(t.resolve(n.pos))}getBookmark(){return new LX(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!zX(e)||!BX(e))return!1;let n=t.type.spec.allowGapCursor;if(n!=null)return n;let r=t.contentMatchAt(e.index()).defaultType;return r&&r.isTextblock}static findGapCursorFrom(t,n,r=!1){search:for(;;){if(!r&&e.valid(t))return t;let i=t.pos,a=null;for(let r=t.depth;;r--){let o=t.node(r);if(n>0?t.indexAfter(r)<o.childCount:t.index(r)>0){a=o.child(n>0?t.indexAfter(r):t.index(r)-1);break}else if(r==0)return null;i+=n;let s=t.doc.resolve(i);if(e.valid(s))return s}for(;;){let o=n>0?a.firstChild:a.lastChild;if(!o){if(a.isAtom&&!a.isText&&!Kp.isSelectable(a)){t=t.doc.resolve(i+a.nodeSize*n),r=!1;continue search}break}a=o,i+=n;let s=t.doc.resolve(i);if(e.valid(s))return s}return null}}};IX.prototype.visible=!1,IX.findFrom=IX.findGapCursorFrom,Bp.jsonID(`gapcursor`,IX);var LX=class e{constructor(e){this.pos=e}map(t){return new e(t.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return IX.valid(t)?new IX(t):Bp.near(t)}};function RX(e){return e.isAtom||e.spec.isolating||e.spec.createGapCursor}function zX(e){for(let t=e.depth;t>=0;t--){let n=e.index(t),r=e.node(t);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let e=r.child(n-1);;e=e.lastChild){if(e.childCount==0&&!e.inlineContent||RX(e.type))return!0;if(e.inlineContent)return!1}}return!0}function BX(e){for(let t=e.depth;t>=0;t--){let n=e.indexAfter(t),r=e.node(t);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let e=r.child(n);;e=e.firstChild){if(e.childCount==0&&!e.inlineContent||RX(e.type))return!0;if(e.inlineContent)return!1}}return!0}function VX(){return new cm({props:{decorations:KX,createSelectionBetween(e,t,n){return t.pos==n.pos&&IX.valid(n)?new IX(n):null},handleClick:WX,handleKeyDown:HX,handleDOMEvents:{beforeinput:GX}}})}var HX=sB({ArrowLeft:UX(`horiz`,-1),ArrowRight:UX(`horiz`,1),ArrowUp:UX(`vert`,-1),ArrowDown:UX(`vert`,1)});function UX(e,t){let n=e==`vert`?t>0?`down`:`up`:t>0?`right`:`left`;return function(e,r,i){let a=e.selection,o=t>0?a.$to:a.$from,s=a.empty;if(a instanceof Wp){if(!i.endOfTextblock(n)||o.depth==0)return!1;s=!1,o=e.doc.resolve(t>0?o.after():o.before())}let c=IX.findGapCursorFrom(o,t,s);return c?(r&&r(e.tr.setSelection(new IX(c))),!0):!1}}function WX(e,t,n){if(!e||!e.editable)return!1;let r=e.state.doc.resolve(t);if(!IX.valid(r))return!1;let i=e.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&Kp.isSelectable(e.state.doc.nodeAt(i.inside))?!1:(e.dispatch(e.state.tr.setSelection(new IX(r))),!0)}function GX(e,t){if(t.inputType!=`insertCompositionText`||!(e.state.selection instanceof IX))return!1;let{$from:n}=e.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(e.state.schema.nodes.text);if(!r)return!1;let i=Z.empty;for(let e=r.length-1;e>=0;e--)i=Z.from(r[e].createAndFill(null,i));let a=e.state.tr.replace(n.pos,n.pos,new Q(i,0,0));return a.setSelection(Wp.near(a.doc.resolve(n.pos+1))),e.dispatch(a),!1}function KX(e){if(!(e.selection instanceof IX))return null;let t=document.createElement(`div`);return t.className=`ProseMirror-gapcursor`,oz.create(e.doc,[rz.widget(e.selection.head,t,{key:`gapcursor`})])}var qX=IV.create({name:`gapCursor`,addProseMirrorPlugins(){return[VX()]},extendNodeSchema(e){return{allowGapCursor:cV(tV(e,`allowGapCursor`,{name:e.name,options:e.options,storage:e.storage}))??null}}}),JX=UU.create({name:`hardBreak`,addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:`inline`,selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:`br`}]},renderHTML({HTMLAttributes:e}){return[`br`,aV(this.options.HTMLAttributes,e)]},renderText(){return`
220
+ `},addCommands(){return{setHardBreak:()=>({commands:e,chain:t,state:n,editor:r})=>e.first([()=>e.exitCode(),()=>e.command(()=>{let{selection:e,storedMarks:i}=n;if(e.$from.parent.type.spec.isolating)return!1;let{keepMarks:a}=this.options,{splittableMarks:o}=r.extensionManager,s=i||e.$to.parentOffset&&e.$from.marks();return t().insertContent({type:this.name}).command(({tr:e,dispatch:t})=>{if(t&&s&&a){let t=s.filter(e=>o.includes(e.type.name));e.ensureMarks(t)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),YX=UU.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(e=>({tag:`h${e}`,attrs:{level:e}}))},renderHTML({node:e,HTMLAttributes:t}){return[`h${this.options.levels.includes(e.attrs.level)?e.attrs.level:this.options.levels[0]}`,aV(this.options.HTMLAttributes,t),0]},addCommands(){return{setHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.setNode(this.name,e):!1,toggleHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.toggleNode(this.name,`paragraph`,e):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((e,t)=>({...e,[`Mod-Alt-${t}`]:()=>this.editor.commands.toggleHeading({level:t})}),{})},addInputRules(){return this.options.levels.map(e=>BU({find:RegExp(`^(#{${Math.min(...this.options.levels)},${e}})\\s$`),type:this.type,getAttributes:{level:e}}))}}),XX=200,ZX=function(){};ZX.prototype.append=function(e){return e.length?(e=ZX.from(e),!this.length&&e||e.length<XX&&this.leafAppend(e)||this.length<XX&&e.leafPrepend(this)||this.appendInner(e)):this},ZX.prototype.prepend=function(e){return e.length?ZX.from(e).append(this):this},ZX.prototype.appendInner=function(e){return new $X(this,e)},ZX.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?ZX.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},ZX.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},ZX.prototype.forEach=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)},ZX.prototype.map=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length);var r=[];return this.forEach(function(t,n){return r.push(e(t,n))},t,n),r},ZX.from=function(e){return e instanceof ZX?e:e&&e.length?new QX(e):ZX.empty};var QX=function(e){function t(t){e.call(this),this.values=t}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(e,n){return e==0&&n==this.length?this:new t(this.values.slice(e,n))},t.prototype.getInner=function(e){return this.values[e]},t.prototype.forEachInner=function(e,t,n,r){for(var i=t;i<n;i++)if(e(this.values[i],r+i)===!1)return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){for(var i=t-1;i>=n;i--)if(e(this.values[i],r+i)===!1)return!1},t.prototype.leafAppend=function(e){if(this.length+e.length<=XX)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=XX)return new t(e.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(t.prototype,n),t}(ZX);ZX.empty=new QX([]);var $X=function(e){function t(t,n){e.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(e){return e<this.left.length?this.left.get(e):this.right.get(e-this.left.length)},t.prototype.forEachInner=function(e,t,n,r){var i=this.left.length;if(t<i&&this.left.forEachInner(e,t,Math.min(n,i),r)===!1||n>i&&this.right.forEachInner(e,Math.max(t-i,0),Math.min(this.length,n)-i,r+i)===!1)return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){var i=this.left.length;if(t>i&&this.right.forEachInvertedInner(e,t-i,Math.max(n,i)-i,r+i)===!1||n<i&&this.left.forEachInvertedInner(e,Math.min(t,i),n,r)===!1)return!1},t.prototype.sliceInner=function(e,t){if(e==0&&t==this.length)return this;var n=this.left.length;return t<=n?this.left.slice(e,t):e>=n?this.right.slice(e-n,t-n):this.left.slice(e,n).append(this.right.slice(0,t-n))},t.prototype.leafAppend=function(e){var n=this.right.leafAppend(e);if(n)return new t(this.left,n)},t.prototype.leafPrepend=function(e){var n=this.left.leafPrepend(e);if(n)return new t(n,this.right)},t.prototype.appendInner=function(e){return this.left.depth>=Math.max(this.right.depth,e.depth)+1?new t(this.left,new t(this.right,e)):new t(this,e)},t}(ZX),eZ=500,tZ=class e{constructor(e,t){this.items=e,this.eventCount=t}popEvent(t,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,a;n&&(i=this.remapping(r,this.items.length),a=i.maps.length);let o=t.tr,s,c,l=[],u=[];return this.items.forEach((t,n)=>{if(!t.step){i||(i=this.remapping(r,n+1),a=i.maps.length),a--,u.push(t);return}if(i){u.push(new rZ(t.map));let e=t.step.map(i.slice(a)),n;e&&o.maybeStep(e).doc&&(n=o.mapping.maps[o.mapping.maps.length-1],l.push(new rZ(n,void 0,void 0,l.length+u.length))),a--,n&&i.appendMap(n,a)}else o.maybeStep(t.step);if(t.selection)return s=i?t.selection.map(i.slice(a)):t.selection,c=new e(this.items.slice(0,r).append(u.reverse().concat(l)),this.eventCount-1),!1},this.items.length,0),{remaining:c,transform:o,selection:s}}addTransform(t,n,r,i){let a=[],o=this.eventCount,s=this.items,c=!i&&s.length?s.get(s.length-1):null;for(let e=0;e<t.steps.length;e++){let r=t.steps[e].invert(t.docs[e]),l=new rZ(t.mapping.maps[e],r,n),u;(u=c&&c.merge(l))&&(l=u,e?a.pop():s=s.slice(0,s.length-1)),a.push(l),n&&=(o++,void 0),i||(c=l)}let l=o-r.depth;return l>aZ&&(s=nZ(s,l),o-=l),new e(s.append(a),o)}remapping(e,t){let n=new Lf;return this.items.forEach((t,r)=>{let i=t.mirrorOffset!=null&&r-t.mirrorOffset>=e?n.maps.length-t.mirrorOffset:void 0;n.appendMap(t.map,i)},e,t),n}addMaps(t){return this.eventCount==0?this:new e(this.items.append(t.map(e=>new rZ(e))),this.eventCount)}rebased(t,n){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-n),a=t.mapping,o=t.steps.length,s=this.eventCount;this.items.forEach(e=>{e.selection&&s--},i);let c=n;this.items.forEach(e=>{let n=a.getMirror(--c);if(n==null)return;o=Math.min(o,n);let i=a.maps[n];if(e.step){let o=t.steps[n].invert(t.docs[n]),l=e.selection&&e.selection.map(a.slice(c+1,n));l&&s++,r.push(new rZ(i,o,l))}else r.push(new rZ(i))},i);let l=[];for(let e=n;e<o;e++)l.push(new rZ(a.maps[e]));let u=new e(this.items.slice(0,i).append(l).append(r),s);return u.emptyItemCount()>eZ&&(u=u.compress(this.items.length-r.length)),u}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(t=this.items.length){let n=this.remapping(0,t),r=n.maps.length,i=[],a=0;return this.items.forEach((e,o)=>{if(o>=t)i.push(e),e.selection&&a++;else if(e.step){let t=e.step.map(n.slice(r)),o=t&&t.getMap();if(r--,o&&n.appendMap(o,r),t){let s=e.selection&&e.selection.map(n.slice(r));s&&a++;let c=new rZ(o.invert(),t,s),l,u=i.length-1;(l=i.length&&i[u].merge(c))?i[u]=l:i.push(c)}}else e.map&&r--},this.items.length,0),new e(ZX.from(i.reverse()),a)}};tZ.empty=new tZ(ZX.empty,0);function nZ(e,t){let n;return e.forEach((e,r)=>{if(e.selection&&t--==0)return n=r,!1}),e.slice(n)}var rZ=class e{constructor(e,t,n,r){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=r}merge(t){if(this.step&&t.step&&!t.selection){let n=t.step.merge(this.step);if(n)return new e(n.getMap().invert(),n,this.selection)}}},iZ=class{constructor(e,t,n,r,i){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=r,this.prevComposition=i}},aZ=20;function oZ(e,t,n,r){let i=n.getMeta(mZ),a;if(i)return i.historyState;n.getMeta(hZ)&&(e=new iZ(e.done,e.undone,null,0,-1));let o=n.getMeta(`appendedTransaction`);if(n.steps.length==0)return e;if(o&&o.getMeta(mZ))return o.getMeta(mZ).redo?new iZ(e.done.addTransform(n,void 0,r,pZ(t)),e.undone,cZ(n.mapping.maps),e.prevTime,e.prevComposition):new iZ(e.done,e.undone.addTransform(n,void 0,r,pZ(t)),null,e.prevTime,e.prevComposition);if(n.getMeta(`addToHistory`)!==!1&&!(o&&o.getMeta(`addToHistory`)===!1)){let i=n.getMeta(`composition`),a=e.prevTime==0||!o&&e.prevComposition!=i&&(e.prevTime<(n.time||0)-r.newGroupDelay||!sZ(n,e.prevRanges)),s=o?lZ(e.prevRanges,n.mapping):cZ(n.mapping.maps);return new iZ(e.done.addTransform(n,a?t.selection.getBookmark():void 0,r,pZ(t)),tZ.empty,s,n.time,i??e.prevComposition)}else if(a=n.getMeta(`rebased`))return new iZ(e.done.rebased(n,a),e.undone.rebased(n,a),lZ(e.prevRanges,n.mapping),e.prevTime,e.prevComposition);else return new iZ(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),lZ(e.prevRanges,n.mapping),e.prevTime,e.prevComposition)}function sZ(e,t){if(!t)return!1;if(!e.docChanged)return!0;let n=!1;return e.mapping.maps[0].forEach((e,r)=>{for(let i=0;i<t.length;i+=2)e<=t[i+1]&&r>=t[i]&&(n=!0)}),n}function cZ(e){let t=[];for(let n=e.length-1;n>=0&&t.length==0;n--)e[n].forEach((e,n,r,i)=>t.push(r,i));return t}function lZ(e,t){if(!e)return null;let n=[];for(let r=0;r<e.length;r+=2){let i=t.map(e[r],1),a=t.map(e[r+1],-1);i<=a&&n.push(i,a)}return n}function uZ(e,t,n){let r=pZ(t),i=mZ.get(t).spec.config,a=(n?e.undone:e.done).popEvent(t,r);if(!a)return null;let o=a.selection.resolve(a.transform.doc),s=(n?e.done:e.undone).addTransform(a.transform,t.selection.getBookmark(),i,r),c=new iZ(n?s:a.remaining,n?a.remaining:s,null,0,-1);return a.transform.setSelection(o).setMeta(mZ,{redo:n,historyState:c})}var dZ=!1,fZ=null;function pZ(e){let t=e.plugins;if(fZ!=t){dZ=!1,fZ=t;for(let e=0;e<t.length;e++)if(t[e].spec.historyPreserveItems){dZ=!0;break}}return dZ}var mZ=new dm(`history`),hZ=new dm(`closeHistory`);function gZ(e={}){return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new cm({key:mZ,state:{init(){return new iZ(tZ.empty,tZ.empty,null,0,-1)},apply(t,n,r){return oZ(n,r,t,e)}},config:e,props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,r=n==`historyUndo`?vZ:n==`historyRedo`?yZ:null;return!r||!e.editable?!1:(t.preventDefault(),r(e.state,e.dispatch))}}}})}function _Z(e,t){return(n,r)=>{let i=mZ.getState(n);if(!i||(e?i.undone:i.done).eventCount==0)return!1;if(r){let a=uZ(i,n,e);a&&r(t?a.scrollIntoView():a)}return!0}}var vZ=_Z(!1,!0),yZ=_Z(!0,!0),bZ=IV.create({name:`history`,addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:e,dispatch:t})=>vZ(e,t),redo:()=>({state:e,dispatch:t})=>yZ(e,t)}},addProseMirrorPlugins(){return[gZ(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()}}}),xZ=UU.create({name:`horizontalRule`,addOptions(){return{HTMLAttributes:{}}},group:`block`,parseHTML(){return[{tag:`hr`}]},renderHTML({HTMLAttributes:e}){return[`hr`,aV(this.options.HTMLAttributes,e)]},addCommands(){return{setHorizontalRule:()=>({chain:e,state:t})=>{if(!GU(t,t.schema.nodes[this.name]))return!1;let{selection:n}=t,{$from:r,$to:i}=n,a=e();return r.parentOffset===0?a.insertContentAt({from:Math.max(r.pos-1,0),to:i.pos},{type:this.name}):fU(n)?a.insertContentAt(i.pos,{type:this.name}):a.insertContent({type:this.name}),a.command(({tr:e,dispatch:t})=>{if(t){let{$to:t}=e.selection,n=t.end();if(t.nodeAfter)t.nodeAfter.isTextblock?e.setSelection(Wp.create(e.doc,t.pos+1)):t.nodeAfter.isBlock?e.setSelection(Kp.create(e.doc,t.pos)):e.setSelection(Wp.create(e.doc,t.pos));else{let r=t.parent.type.contentMatch.defaultType?.create();r&&(e.insert(n,r),e.setSelection(Wp.create(e.doc,n+1)))}e.scrollIntoView()}return!0}).run()}}},addInputRules(){return[zU({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),SZ=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,CZ=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,wZ=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,TZ=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,EZ=EV.create({name:`italic`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`em`},{tag:`i`,getAttrs:e=>e.style.fontStyle!==`normal`&&null},{style:`font-style=normal`,clearMark:e=>e.type.name===this.name},{style:`font-style=italic`}]},renderHTML({HTMLAttributes:e}){return[`em`,aV(this.options.HTMLAttributes,e),0]},addCommands(){return{setItalic:()=>({commands:e})=>e.setMark(this.name),toggleItalic:()=>({commands:e})=>e.toggleMark(this.name),unsetItalic:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[RU({find:SZ,type:this.type}),RU({find:wZ,type:this.type})]},addPasteRules(){return[WU({find:CZ,type:this.type}),WU({find:TZ,type:this.type})]}}),DZ=UU.create({name:`listItem`,addOptions(){return{HTMLAttributes:{},bulletListTypeName:`bulletList`,orderedListTypeName:`orderedList`}},content:`paragraph block*`,defining:!0,parseHTML(){return[{tag:`li`}]},renderHTML({HTMLAttributes:e}){return[`li`,aV(this.options.HTMLAttributes,e),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),OZ=`listItem`,kZ=`textStyle`,AZ=/^(\d+)\.\s$/,jZ=UU.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:e=>e.hasAttribute(`start`)?parseInt(e.getAttribute(`start`)||``,10):1},type:{default:null,parseHTML:e=>e.getAttribute(`type`)}}},parseHTML(){return[{tag:`ol`}]},renderHTML({HTMLAttributes:e}){let{start:t,...n}=e;return t===1?[`ol`,aV(this.options.HTMLAttributes,n),0]:[`ol`,aV(this.options.HTMLAttributes,e),0]},addCommands(){return{toggleOrderedList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(OZ,this.editor.getAttributes(kZ)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let e=HU({find:AZ,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(e=HU({find:AZ,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(kZ)}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1],editor:this.editor})),[e]}}),MZ=UU.create({name:`paragraph`,priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:`block`,content:`inline*`,parseHTML(){return[{tag:`p`}]},renderHTML({HTMLAttributes:e}){return[`p`,aV(this.options.HTMLAttributes,e),0]},addCommands(){return{setParagraph:()=>({commands:e})=>e.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),NZ=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,PZ=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,FZ=EV.create({name:`strike`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`s`},{tag:`del`},{tag:`strike`},{style:`text-decoration`,consuming:!1,getAttrs:e=>e.includes(`line-through`)?{}:!1}]},renderHTML({HTMLAttributes:e}){return[`s`,aV(this.options.HTMLAttributes,e),0]},addCommands(){return{setStrike:()=>({commands:e})=>e.setMark(this.name),toggleStrike:()=>({commands:e})=>e.toggleMark(this.name),unsetStrike:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[RU({find:NZ,type:this.type})]},addPasteRules(){return[WU({find:PZ,type:this.type})]}}),IZ=UU.create({name:`text`,group:`inline`}),LZ=IV.create({name:`starterKit`,addExtensions(){let e=[];return this.options.bold!==!1&&e.push(xX.configure(this.options.bold)),this.options.blockquote!==!1&&e.push(gX.configure(this.options.blockquote)),this.options.bulletList!==!1&&e.push(TX.configure(this.options.bulletList)),this.options.code!==!1&&e.push(OX.configure(this.options.code)),this.options.codeBlock!==!1&&e.push(jX.configure(this.options.codeBlock)),this.options.document!==!1&&e.push(MX.configure(this.options.document)),this.options.dropcursor!==!1&&e.push(FX.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&e.push(qX.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&e.push(JX.configure(this.options.hardBreak)),this.options.heading!==!1&&e.push(YX.configure(this.options.heading)),this.options.history!==!1&&e.push(bZ.configure(this.options.history)),this.options.horizontalRule!==!1&&e.push(xZ.configure(this.options.horizontalRule)),this.options.italic!==!1&&e.push(EZ.configure(this.options.italic)),this.options.listItem!==!1&&e.push(DZ.configure(this.options.listItem)),this.options.orderedList!==!1&&e.push(jZ.configure(this.options.orderedList)),this.options.paragraph!==!1&&e.push(MZ.configure(this.options.paragraph)),this.options.strike!==!1&&e.push(FZ.configure(this.options.strike)),this.options.text!==!1&&e.push(IZ.configure(this.options.text)),e}}),RZ=EV.create({name:`footnote-ref`,inclusive:!1,addAttributes(){return{id:{default:null,parseHTML:()=>null,renderHTML:e=>e.id==null?{}:{"data-footnote-id":String(e.id)}},kind:{default:`footnote`,parseHTML:()=>null,renderHTML:()=>({})}}},parseHTML(){return[]},renderHTML({HTMLAttributes:e}){return[`sup`,aV({class:`tandem-footnote-ref`},e),0]}}),zZ=new dm(`listItemCheckbox`),BZ=/^\[([ xX])\]\s$/,VZ=DZ.extend({addAttributes(){return{...this.parent?.(),checked:{default:null,keepOnSplit:!1,parseHTML:e=>{let t=e.getAttribute(`data-checked`);return t===`true`?!0:t===`false`?!1:null},renderHTML:e=>e.checked===null||e.checked===void 0?{}:{"data-checked":String(e.checked)}}}},addInputRules(){let e=this.type;return[new yV({find:BZ,handler:({state:t,range:n,match:r})=>{let i=r[1]!==` `,a=t.doc.resolve(n.from),o=-1,s={};for(let t=a.depth;t>0;t--){let n=a.node(t);if(n.type===e){o=a.before(t),s=n.attrs;break}}if(o<0)return null;let c=t.tr;c.delete(n.from,n.to),c.setNodeMarkup(o,void 0,{...s,checked:i})}})]},addKeyboardShortcuts(){let e=this.type;return{...this.parent?.(),Enter:()=>{let{$from:t}=this.editor.state.selection,n;for(let r=t.depth;r>0;r--){let i=t.node(r);if(i.type===e){n=i.attrs.checked;break}}return n==null?this.editor.commands.splitListItem(this.name):this.editor.commands.splitListItem(this.name,{checked:!1})}}},addProseMirrorPlugins(){let e=this.type;return[...this.parent?.()??[],new cm({key:zZ,props:{decorations:t=>{let n=[];return t.doc.descendants((t,r)=>{if(t.type!==e||t.attrs.checked===null||t.attrs.checked===void 0)return;let i=t.attrs.checked===!0;n.push(rz.widget(r+1,(t,n)=>HZ(t,n,i,e),{side:-1,key:`tandem-checkbox-${r}:${i}`,stopEvent:()=>!0,ignoreSelection:!0}))}),oz.create(t.doc,n)}}})]}});function HZ(e,t,n,r){let i=document.createElement(`label`);i.className=`tandem-list-checkbox`,i.contentEditable=`false`;let a=document.createElement(`input`);return a.type=`checkbox`,a.checked=n,a.setAttribute(`aria-label`,n?`Checked task`:`Unchecked task`),a.addEventListener(`mousedown`,e=>e.preventDefault()),a.addEventListener(`change`,()=>{if(!e.editable){a.checked=n;return}let i=t();if(i==null)return;let o=i-1,s=e.state.doc.resolve(o).nodeAfter;!s||s.type!==r||e.dispatch(e.state.tr.setNodeMarkup(o,void 0,{...s.attrs,checked:!s.attrs.checked}))}),i.appendChild(a),i}var UZ=IV.create({name:`markdownHtml`,addGlobalAttributes(){return[{types:[`paragraph`],attributes:{markdownHtml:{default:null,parseHTML:()=>null,renderHTML:()=>({})},markdownRaw:{default:null,parseHTML:()=>null,renderHTML:e=>e.markdownRaw?{"data-markdown-raw":``}:{}}}}]}}),WZ=EV.create({name:`rawMarkdown`,parseHTML(){return[]},renderHTML(){return[`span`,{class:`tandem-raw-md`},0]}}),GZ=fJ.extend({renderHTML(e){let t=this.parent?.(e)??[`a`,aV(this.options.HTMLAttributes,e.HTMLAttributes),0];if(Array.isArray(t)&&t.length>=2&&t[1]&&typeof t[1]==`object`){let e=t[1],n=e.href;typeof n==`string`&&n.length>0&&e.title==null&&(t[1]={...e,title:n})}return t}});function KZ(){return[LZ.configure({history:!1,listItem:!1}),VZ,mX,hJ,mJ,RZ,YG.configure({multicolor:!0}),GZ.configure({openOnClick:!1,HTMLAttributes:{rel:`noopener noreferrer`,target:`_blank`}}),ZG.configure({allowBase64:!0}),pJ.configure({placeholder:`Start typing…`}),uX.configure({resizable:!0}),pX,dX,fX,UZ,WZ]}var qZ={};function JZ(e){let t=qZ[e];if(t)return t;t=qZ[e]=[];for(let e=0;e<128;e++){let n=String.fromCharCode(e);t.push(n)}for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);t[r]=`%`+(`0`+r.toString(16).toUpperCase()).slice(-2)}return t}function YZ(e,t){typeof t!=`string`&&(t=YZ.defaultChars);let n=JZ(t);return e.replace(/(%[a-f0-9]{2})+/gi,function(e){let t=``;for(let r=0,i=e.length;r<i;r+=3){let a=parseInt(e.slice(r+1,r+3),16);if(a<128){t+=n[a];continue}if((a&224)==192&&r+3<i){let n=parseInt(e.slice(r+4,r+6),16);if((n&192)==128){let e=a<<6&1984|n&63;e<128?t+=`��`:t+=String.fromCharCode(e),r+=3;continue}}if((a&240)==224&&r+6<i){let n=parseInt(e.slice(r+4,r+6),16),i=parseInt(e.slice(r+7,r+9),16);if((n&192)==128&&(i&192)==128){let e=a<<12&61440|n<<6&4032|i&63;e<2048||e>=55296&&e<=57343?t+=`���`:t+=String.fromCharCode(e),r+=6;continue}}if((a&248)==240&&r+9<i){let n=parseInt(e.slice(r+4,r+6),16),i=parseInt(e.slice(r+7,r+9),16),o=parseInt(e.slice(r+10,r+12),16);if((n&192)==128&&(i&192)==128&&(o&192)==128){let e=a<<18&1835008|n<<12&258048|i<<6&4032|o&63;e<65536||e>1114111?t+=`����`:(e-=65536,t+=String.fromCharCode(55296+(e>>10),56320+(e&1023))),r+=9;continue}}t+=`�`}return t})}YZ.defaultChars=`;/?:@&=+$,#`,YZ.componentChars=``;var XZ={};function ZZ(e){let t=XZ[e];if(t)return t;t=XZ[e]=[];for(let e=0;e<128;e++){let n=String.fromCharCode(e);/^[0-9a-z]$/i.test(n)?t.push(n):t.push(`%`+(`0`+e.toString(16).toUpperCase()).slice(-2))}for(let n=0;n<e.length;n++)t[e.charCodeAt(n)]=e[n];return t}function QZ(e,t,n){typeof t!=`string`&&(n=t,t=QZ.defaultChars),n===void 0&&(n=!0);let r=ZZ(t),i=``;for(let t=0,a=e.length;t<a;t++){let o=e.charCodeAt(t);if(n&&o===37&&t+2<a&&/^[0-9a-f]{2}$/i.test(e.slice(t+1,t+3))){i+=e.slice(t,t+3),t+=2;continue}if(o<128){i+=r[o];continue}if(o>=55296&&o<=57343){if(o>=55296&&o<=56319&&t+1<a){let n=e.charCodeAt(t+1);if(n>=56320&&n<=57343){i+=encodeURIComponent(e[t]+e[t+1]),t++;continue}}i+=`%EF%BF%BD`;continue}i+=encodeURIComponent(e[t])}return i}QZ.defaultChars=`;/?:@&=+$,-_.!~*'()#`,QZ.componentChars=`-_.!~*'()`;function $Z(e){let t=``;return t+=e.protocol||``,t+=e.slashes?`//`:``,t+=e.auth?e.auth+`@`:``,e.hostname&&e.hostname.indexOf(`:`)!==-1?t+=`[`+e.hostname+`]`:t+=e.hostname||``,t+=e.port?`:`+e.port:``,t+=e.pathname||``,t+=e.search||``,t+=e.hash||``,t}function eQ(){this.protocol=null,this.slashes=null,this.auth=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.pathname=null}var tQ=/^([a-z0-9.+-]+:)/i,nQ=/:[0-9]*$/,rQ=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,iQ=[`%`,`/`,`?`,`;`,`#`,`'`,`{`,`}`,`|`,`\\`,`^`,"`",`<`,`>`,`"`,"`",` `,`\r`,`
221
+ `,` `],aQ=[`/`,`?`,`#`],oQ=255,sQ=/^[+a-z0-9A-Z_-]{0,63}$/,cQ=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,lQ={javascript:!0,"javascript:":!0},uQ={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0};function dQ(e,t){if(e&&e instanceof eQ)return e;let n=new eQ;return n.parse(e,t),n}eQ.prototype.parse=function(e,t){let n,r,i,a=e;if(a=a.trim(),!t&&e.split(`#`).length===1){let e=rQ.exec(a);if(e)return this.pathname=e[1],e[2]&&(this.search=e[2]),this}let o=tQ.exec(a);if(o&&(o=o[0],n=o.toLowerCase(),this.protocol=o,a=a.substr(o.length)),(t||o||a.match(/^\/\/[^@\/]+@[^@\/]+/))&&(i=a.substr(0,2)===`//`,i&&!(o&&lQ[o])&&(a=a.substr(2),this.slashes=!0)),!lQ[o]&&(i||o&&!uQ[o])){let e=-1;for(let t=0;t<aQ.length;t++)r=a.indexOf(aQ[t]),r!==-1&&(e===-1||r<e)&&(e=r);let t,n;n=e===-1?a.lastIndexOf(`@`):a.lastIndexOf(`@`,e),n!==-1&&(t=a.slice(0,n),a=a.slice(n+1),this.auth=t),e=-1;for(let t=0;t<iQ.length;t++)r=a.indexOf(iQ[t]),r!==-1&&(e===-1||r<e)&&(e=r);e===-1&&(e=a.length),a[e-1]===`:`&&e--;let i=a.slice(0,e);a=a.slice(e),this.parseHost(i),this.hostname=this.hostname||``;let o=this.hostname[0]===`[`&&this.hostname[this.hostname.length-1]===`]`;if(!o){let e=this.hostname.split(/\./);for(let t=0,n=e.length;t<n;t++){let n=e[t];if(n&&!n.match(sQ)){let r=``;for(let e=0,t=n.length;e<t;e++)n.charCodeAt(e)>127?r+=`x`:r+=n[e];if(!r.match(sQ)){let r=e.slice(0,t),i=e.slice(t+1),o=n.match(cQ);o&&(r.push(o[1]),i.unshift(o[2])),i.length&&(a=i.join(`.`)+a),this.hostname=r.join(`.`);break}}}}this.hostname.length>oQ&&(this.hostname=``),o&&(this.hostname=this.hostname.substr(1,this.hostname.length-2))}let s=a.indexOf(`#`);s!==-1&&(this.hash=a.substr(s),a=a.slice(0,s));let c=a.indexOf(`?`);return c!==-1&&(this.search=a.substr(c),a=a.slice(0,c)),a&&(this.pathname=a),uQ[n]&&this.hostname&&!this.pathname&&(this.pathname=``),this},eQ.prototype.parseHost=function(e){let t=nQ.exec(e);t&&(t=t[0],t!==`:`&&(this.port=t.substr(1)),e=e.substr(0,e.length-t.length)),e&&(this.hostname=e)};var fQ=t({decode:()=>YZ,encode:()=>QZ,format:()=>$Z,parse:()=>dQ}),pQ=/[\0-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,mQ=/[\0-\x1F\x7F-\x9F]/,hQ=/[\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]/,gQ=/[!-#%-\*,-\/:;\?@\[-\]_\{\}\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]/,_Q=/[\$\+<->\^`\|~\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]/,vQ=/[ \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]/,yQ=t({Any:()=>pQ,Cc:()=>mQ,Cf:()=>hQ,P:()=>gQ,S:()=>_Q,Z:()=>vQ}),bQ=new Uint16Array(`ᵁ<Õıʊҝջאٵ۞ޢߖࠏ੊ઑඡ๭༉༦჊ረዡᐕᒝᓃᓟᔥ\0\0\0\0\0\0ᕫᛍᦍᰒᷝ὾⁠↰⊍⏀⏻⑂⠤⤒ⴈ⹈⿎〖㊺㘹㞬㣾㨨㩱㫠㬮ࠀEMabcfglmnoprstu\\bfms„‹•˜¦³¹ÈÏlig耻Æ䃆P耻&䀦cute耻Á䃁reve;䄂Āiyx}rc耻Â䃂;䐐r;쀀𝔄rave耻À䃀pha;䎑acr;䄀d;橓Āgp¡on;䄄f;쀀𝔸plyFunction;恡ing耻Å䃅Ācs¾Ãr;쀀𝒜ign;扔ilde耻Ã䃃ml耻Ä䃄ЀaceforsuåûþėĜĢħĪĀcrêòkslash;或Ŷöø;櫧ed;挆y;䐑ƀcrtąċĔause;戵noullis;愬a;䎒r;쀀𝔅pf;쀀𝔹eve;䋘còēmpeq;扎܀HOacdefhilorsuōőŖƀƞƢƵƷƺǜȕɳɸɾcy;䐧PY耻©䂩ƀcpyŝŢźute;䄆Ā;iŧŨ拒talDifferentialD;慅leys;愭ȀaeioƉƎƔƘron;䄌dil耻Ç䃇rc;䄈nint;戰ot;䄊ĀdnƧƭilla;䂸terDot;䂷òſi;䎧rcleȀDMPTLJNjǑǖot;抙inus;抖lus;投imes;抗oĀcsǢǸkwiseContourIntegral;戲eCurlyĀDQȃȏoubleQuote;思uote;怙ȀlnpuȞȨɇɕonĀ;eȥȦ户;橴ƀgitȯȶȺruent;扡nt;戯ourIntegral;戮ĀfrɌɎ;愂oduct;成nterClockwiseContourIntegral;戳oss;樯cr;쀀𝒞pĀ;Cʄʅ拓ap;才րDJSZacefiosʠʬʰʴʸˋ˗ˡ˦̳ҍĀ;oŹʥtrahd;椑cy;䐂cy;䐅cy;䐏ƀgrsʿ˄ˇger;怡r;憡hv;櫤Āayː˕ron;䄎;䐔lĀ;t˝˞戇a;䎔r;쀀𝔇Āaf˫̧Ācm˰̢riticalȀADGT̖̜̀̆cute;䂴oŴ̋̍;䋙bleAcute;䋝rave;䁠ilde;䋜ond;拄ferentialD;慆Ѱ̽\0\0\0͔͂\0Ѕf;쀀𝔻ƀ;DE͈͉͍䂨ot;惜qual;扐blèCDLRUVͣͲ΂ϏϢϸontourIntegraìȹoɴ͹\0\0ͻ»͉nArrow;懓Āeo·ΤftƀARTΐΖΡrrow;懐ightArrow;懔eåˊngĀLRΫτeftĀARγιrrow;柸ightArrow;柺ightArrow;柹ightĀATϘϞrrow;懒ee;抨pɁϩ\0\0ϯrrow;懑ownArrow;懕erticalBar;戥ǹABLRTaВЪаўѿͼrrowƀ;BUНОТ憓ar;椓pArrow;懵reve;䌑eft˒к\0ц\0ѐightVector;楐eeVector;楞ectorĀ;Bљњ憽ar;楖ightǔѧ\0ѱeeVector;楟ectorĀ;BѺѻ懁ar;楗eeĀ;A҆҇护rrow;憧ĀctҒҗr;쀀𝒟rok;䄐ࠀNTacdfglmopqstuxҽӀӄӋӞӢӧӮӵԡԯԶՒ՝ՠեG;䅊H耻Ð䃐cute耻É䃉ƀaiyӒӗӜron;䄚rc耻Ê䃊;䐭ot;䄖r;쀀𝔈rave耻È䃈ement;戈ĀapӺӾcr;䄒tyɓԆ\0\0ԒmallSquare;旻erySmallSquare;斫ĀgpԦԪon;䄘f;쀀𝔼silon;䎕uĀaiԼՉlĀ;TՂՃ橵ilde;扂librium;懌Āci՗՚r;愰m;橳a;䎗ml耻Ë䃋Āipժկsts;戃onentialE;慇ʀcfiosօֈ֍ֲ׌y;䐤r;쀀𝔉lledɓ֗\0\0֣mallSquare;旼erySmallSquare;斪Ͱֺ\0ֿ\0\0ׄf;쀀𝔽All;戀riertrf;愱cò׋؀JTabcdfgorstר׬ׯ׺؀ؒؖ؛؝أ٬ٲcy;䐃耻>䀾mmaĀ;d׷׸䎓;䏜reve;䄞ƀeiy؇،ؐdil;䄢rc;䄜;䐓ot;䄠r;쀀𝔊;拙pf;쀀𝔾eater̀EFGLSTصلَٖٛ٦qualĀ;Lؾؿ扥ess;招ullEqual;执reater;檢ess;扷lantEqual;橾ilde;扳cr;쀀𝒢;扫ЀAacfiosuڅڋږڛڞڪھۊRDcy;䐪Āctڐڔek;䋇;䁞irc;䄤r;愌lbertSpace;愋ǰگ\0ڲf;愍izontalLine;攀Āctۃۅòکrok;䄦mpńېۘownHumðįqual;扏܀EJOacdfgmnostuۺ۾܃܇܎ܚܞܡܨ݄ݸދޏޕcy;䐕lig;䄲cy;䐁cute耻Í䃍Āiyܓܘrc耻Î䃎;䐘ot;䄰r;愑rave耻Ì䃌ƀ;apܠܯܿĀcgܴܷr;䄪inaryI;慈lieóϝǴ݉\0ݢĀ;eݍݎ戬Āgrݓݘral;戫section;拂isibleĀCTݬݲomma;恣imes;恢ƀgptݿރވon;䄮f;쀀𝕀a;䎙cr;愐ilde;䄨ǫޚ\0ޞcy;䐆l耻Ï䃏ʀcfosuެ޷޼߂ߐĀiyޱ޵rc;䄴;䐙r;쀀𝔍pf;쀀𝕁ǣ߇\0ߌr;쀀𝒥rcy;䐈kcy;䐄΀HJacfosߤߨ߽߬߱ࠂࠈcy;䐥cy;䐌ppa;䎚Āey߶߻dil;䄶;䐚r;쀀𝔎pf;쀀𝕂cr;쀀𝒦րJTaceflmostࠥࠩࠬࡐࡣ঳সে্਷ੇcy;䐉耻<䀼ʀcmnpr࠷࠼ࡁࡄࡍute;䄹bda;䎛g;柪lacetrf;愒r;憞ƀaeyࡗ࡜ࡡron;䄽dil;䄻;䐛Āfsࡨ॰tԀACDFRTUVarࡾࢩࢱࣦ࣠ࣼयज़ΐ४Ānrࢃ࢏gleBracket;柨rowƀ;BR࢙࢚࢞憐ar;懤ightArrow;懆eiling;挈oǵࢷ\0ࣃbleBracket;柦nǔࣈ\0࣒eeVector;楡ectorĀ;Bࣛࣜ懃ar;楙loor;挊ightĀAV࣯ࣵrrow;憔ector;楎Āerँगeƀ;AVउऊऐ抣rrow;憤ector;楚iangleƀ;BEतथऩ抲ar;槏qual;抴pƀDTVषूौownVector;楑eeVector;楠ectorĀ;Bॖॗ憿ar;楘ectorĀ;B॥०憼ar;楒ightáΜs̀EFGLSTॾঋকঝঢভqualGreater;拚ullEqual;扦reater;扶ess;檡lantEqual;橽ilde;扲r;쀀𝔏Ā;eঽা拘ftarrow;懚idot;䄿ƀnpw৔ਖਛgȀLRlr৞৷ਂਐeftĀAR০৬rrow;柵ightArrow;柷ightArrow;柶eftĀarγਊightáοightáϊf;쀀𝕃erĀLRਢਬeftArrow;憙ightArrow;憘ƀchtਾੀੂòࡌ;憰rok;䅁;扪Ѐacefiosuਗ਼੝੠੷੼અઋ઎p;椅y;䐜Ādl੥੯iumSpace;恟lintrf;愳r;쀀𝔐nusPlus;戓pf;쀀𝕄cò੶;䎜ҀJacefostuણધભીଔଙඑ඗ඞcy;䐊cute;䅃ƀaey઴હાron;䅇dil;䅅;䐝ƀgswે૰଎ativeƀMTV૓૟૨ediumSpace;怋hiĀcn૦૘ë૙eryThiî૙tedĀGL૸ଆreaterGreateòٳessLesóੈLine;䀊r;쀀𝔑ȀBnptଢନଷ଺reak;恠BreakingSpace;䂠f;愕ڀ;CDEGHLNPRSTV୕ୖ୪୼஡௫ఄ౞಄ದ೘ൡඅ櫬Āou୛୤ngruent;扢pCap;扭oubleVerticalBar;戦ƀlqxஃஊ஛ement;戉ualĀ;Tஒஓ扠ilde;쀀≂̸ists;戄reater΀;EFGLSTஶஷ஽௉௓௘௥扯qual;扱ullEqual;쀀≧̸reater;쀀≫̸ess;批lantEqual;쀀⩾̸ilde;扵umpń௲௽ownHump;쀀≎̸qual;쀀≏̸eĀfsఊధtTriangleƀ;BEచఛడ拪ar;쀀⧏̸qual;括s̀;EGLSTవశ఼ౄోౘ扮qual;扰reater;扸ess;쀀≪̸lantEqual;쀀⩽̸ilde;扴estedĀGL౨౹reaterGreater;쀀⪢̸essLess;쀀⪡̸recedesƀ;ESಒಓಛ技qual;쀀⪯̸lantEqual;拠ĀeiಫಹverseElement;戌ghtTriangleƀ;BEೋೌ೒拫ar;쀀⧐̸qual;拭ĀquೝഌuareSuĀbp೨೹setĀ;E೰ೳ쀀⊏̸qual;拢ersetĀ;Eഃആ쀀⊐̸qual;拣ƀbcpഓതൎsetĀ;Eഛഞ쀀⊂⃒qual;抈ceedsȀ;ESTലള഻െ抁qual;쀀⪰̸lantEqual;拡ilde;쀀≿̸ersetĀ;E൘൛쀀⊃⃒qual;抉ildeȀ;EFT൮൯൵ൿ扁qual;扄ullEqual;扇ilde;扉erticalBar;戤cr;쀀𝒩ilde耻Ñ䃑;䎝܀Eacdfgmoprstuvලෂ෉෕ෛ෠෧෼ขภยา฿ไlig;䅒cute耻Ó䃓Āiy෎ීrc耻Ô䃔;䐞blac;䅐r;쀀𝔒rave耻Ò䃒ƀaei෮ෲ෶cr;䅌ga;䎩cron;䎟pf;쀀𝕆enCurlyĀDQฎบoubleQuote;怜uote;怘;橔Āclวฬr;쀀𝒪ash耻Ø䃘iŬื฼de耻Õ䃕es;樷ml耻Ö䃖erĀBP๋๠Āar๐๓r;怾acĀek๚๜;揞et;掴arenthesis;揜Ҁacfhilors๿ງຊຏຒດຝະ໼rtialD;戂y;䐟r;쀀𝔓i;䎦;䎠usMinus;䂱Āipຢອncareplanåڝf;愙Ȁ;eio຺ູ໠໤檻cedesȀ;EST່້໏໚扺qual;檯lantEqual;扼ilde;找me;怳Ādp໩໮uct;戏ortionĀ;aȥ໹l;戝Āci༁༆r;쀀𝒫;䎨ȀUfos༑༖༛༟OT耻"䀢r;쀀𝔔pf;愚cr;쀀𝒬؀BEacefhiorsu༾གྷཇའཱིྦྷྪྭ႖ႩႴႾarr;椐G耻®䂮ƀcnrཎནབute;䅔g;柫rĀ;tཛྷཝ憠l;椖ƀaeyཧཬཱron;䅘dil;䅖;䐠Ā;vླྀཹ愜erseĀEUྂྙĀlq྇ྎement;戋uilibrium;懋pEquilibrium;楯r»ཹo;䎡ghtЀACDFTUVa࿁࿫࿳ဢဨၛႇϘĀnr࿆࿒gleBracket;柩rowƀ;BL࿜࿝࿡憒ar;懥eftArrow;懄eiling;按oǵ࿹\0စbleBracket;柧nǔည\0နeeVector;楝ectorĀ;Bဝသ懂ar;楕loor;挋Āerိ၃eƀ;AVဵံြ抢rrow;憦ector;楛iangleƀ;BEၐၑၕ抳ar;槐qual;抵pƀDTVၣၮၸownVector;楏eeVector;楜ectorĀ;Bႂႃ憾ar;楔ectorĀ;B႑႒懀ar;楓Āpuႛ႞f;愝ndImplies;楰ightarrow;懛ĀchႹႼr;愛;憱leDelayed;槴ڀHOacfhimoqstuფჱჷჽᄙᄞᅑᅖᅡᅧᆵᆻᆿĀCcჩხHcy;䐩y;䐨FTcy;䐬cute;䅚ʀ;aeiyᄈᄉᄎᄓᄗ檼ron;䅠dil;䅞rc;䅜;䐡r;쀀𝔖ortȀDLRUᄪᄴᄾᅉownArrow»ОeftArrow»࢚ightArrow»࿝pArrow;憑gma;䎣allCircle;战pf;쀀𝕊ɲᅭ\0\0ᅰt;戚areȀ;ISUᅻᅼᆉᆯ斡ntersection;抓uĀbpᆏᆞsetĀ;Eᆗᆘ抏qual;抑ersetĀ;Eᆨᆩ抐qual;抒nion;抔cr;쀀𝒮ar;拆ȀbcmpᇈᇛሉላĀ;sᇍᇎ拐etĀ;Eᇍᇕqual;抆ĀchᇠህeedsȀ;ESTᇭᇮᇴᇿ扻qual;檰lantEqual;扽ilde;承Tháྌ;我ƀ;esሒሓሣ拑rsetĀ;Eሜም抃qual;抇et»ሓրHRSacfhiorsሾቄ቉ቕ቞ቱቶኟዂወዑORN耻Þ䃞ADE;愢ĀHc቎ቒcy;䐋y;䐦Ābuቚቜ;䀉;䎤ƀaeyብቪቯron;䅤dil;䅢;䐢r;쀀𝔗Āeiቻ኉Dzኀ\0ኇefore;戴a;䎘Ācn኎ኘkSpace;쀀  Space;怉ldeȀ;EFTካኬኲኼ戼qual;扃ullEqual;扅ilde;扈pf;쀀𝕋ipleDot;惛Āctዖዛr;쀀𝒯rok;䅦ૡዷጎጚጦ\0ጬጱ\0\0\0\0\0ጸጽ፷ᎅ\0᏿ᐄᐊᐐĀcrዻጁute耻Ú䃚rĀ;oጇገ憟cir;楉rǣጓ\0጖y;䐎ve;䅬Āiyጞጣrc耻Û䃛;䐣blac;䅰r;쀀𝔘rave耻Ù䃙acr;䅪Ādiፁ፩erĀBPፈ፝Āarፍፐr;䁟acĀekፗፙ;揟et;掵arenthesis;揝onĀ;P፰፱拃lus;抎Āgp፻፿on;䅲f;쀀𝕌ЀADETadps᎕ᎮᎸᏄϨᏒᏗᏳrrowƀ;BDᅐᎠᎤar;椒ownArrow;懅ownArrow;憕quilibrium;楮eeĀ;AᏋᏌ报rrow;憥ownáϳerĀLRᏞᏨeftArrow;憖ightArrow;憗iĀ;lᏹᏺ䏒on;䎥ing;䅮cr;쀀𝒰ilde;䅨ml耻Ü䃜ҀDbcdefosvᐧᐬᐰᐳᐾᒅᒊᒐᒖash;披ar;櫫y;䐒ashĀ;lᐻᐼ抩;櫦Āerᑃᑅ;拁ƀbtyᑌᑐᑺar;怖Ā;iᑏᑕcalȀBLSTᑡᑥᑪᑴar;戣ine;䁼eparator;杘ilde;所ThinSpace;怊r;쀀𝔙pf;쀀𝕍cr;쀀𝒱dash;抪ʀcefosᒧᒬᒱᒶᒼirc;䅴dge;拀r;쀀𝔚pf;쀀𝕎cr;쀀𝒲Ȁfiosᓋᓐᓒᓘr;쀀𝔛;䎞pf;쀀𝕏cr;쀀𝒳ҀAIUacfosuᓱᓵᓹᓽᔄᔏᔔᔚᔠcy;䐯cy;䐇cy;䐮cute耻Ý䃝Āiyᔉᔍrc;䅶;䐫r;쀀𝔜pf;쀀𝕐cr;쀀𝒴ml;䅸ЀHacdefosᔵᔹᔿᕋᕏᕝᕠᕤcy;䐖cute;䅹Āayᕄᕉron;䅽;䐗ot;䅻Dzᕔ\0ᕛoWidtè૙a;䎖r;愨pf;愤cr;쀀𝒵௡ᖃᖊᖐ\0ᖰᖶᖿ\0\0\0\0ᗆᗛᗫᙟ᙭\0ᚕ᚛ᚲᚹ\0ᚾcute耻á䃡reve;䄃̀;Ediuyᖜᖝᖡᖣᖨᖭ戾;쀀∾̳;房rc耻â䃢te肻´̆;䐰lig耻æ䃦Ā;r²ᖺ;쀀𝔞rave耻à䃠ĀepᗊᗖĀfpᗏᗔsym;愵èᗓha;䎱ĀapᗟcĀclᗤᗧr;䄁g;樿ɤᗰ\0\0ᘊʀ;adsvᗺᗻᗿᘁᘇ戧nd;橕;橜lope;橘;橚΀;elmrszᘘᘙᘛᘞᘿᙏᙙ戠;榤e»ᘙsdĀ;aᘥᘦ戡ѡᘰᘲᘴᘶᘸᘺᘼᘾ;榨;榩;榪;榫;榬;榭;榮;榯tĀ;vᙅᙆ戟bĀ;dᙌᙍ抾;榝Āptᙔᙗh;戢»¹arr;捼Āgpᙣᙧon;䄅f;쀀𝕒΀;Eaeiop዁ᙻᙽᚂᚄᚇᚊ;橰cir;橯;扊d;手s;䀧roxĀ;e዁ᚒñᚃing耻å䃥ƀctyᚡᚦᚨr;쀀𝒶;䀪mpĀ;e዁ᚯñʈilde耻ã䃣ml耻ä䃤Āciᛂᛈoninôɲnt;樑ࠀNabcdefiklnoprsu᛭ᛱᜰ᜼ᝃᝈ᝸᝽០៦ᠹᡐᜍ᤽᥈ᥰot;櫭Ācrᛶ᜞kȀcepsᜀᜅᜍᜓong;扌psilon;䏶rime;怵imĀ;e᜚᜛戽q;拍Ŷᜢᜦee;抽edĀ;gᜬᜭ挅e»ᜭrkĀ;t፜᜷brk;掶Āoyᜁᝁ;䐱quo;怞ʀcmprtᝓ᝛ᝡᝤᝨausĀ;eĊĉptyv;榰séᜌnoõēƀahwᝯ᝱ᝳ;䎲;愶een;扬r;쀀𝔟g΀costuvwឍឝឳេ៕៛៞ƀaiuបពរðݠrc;旯p»፱ƀdptឤឨឭot;樀lus;樁imes;樂ɱឹ\0\0ើcup;樆ar;昅riangleĀdu៍្own;施p;斳plus;樄eåᑄåᒭarow;植ƀako៭ᠦᠵĀcn៲ᠣkƀlst៺֫᠂ozenge;槫riangleȀ;dlr᠒᠓᠘᠝斴own;斾eft;旂ight;斸k;搣Ʊᠫ\0ᠳƲᠯ\0ᠱ;斒;斑4;斓ck;斈ĀeoᠾᡍĀ;qᡃᡆ쀀=⃥uiv;쀀≡⃥t;挐Ȁptwxᡙᡞᡧᡬf;쀀𝕓Ā;tᏋᡣom»Ꮜtie;拈؀DHUVbdhmptuvᢅᢖᢪᢻᣗᣛᣬ᣿ᤅᤊᤐᤡȀLRlrᢎᢐᢒᢔ;敗;敔;敖;敓ʀ;DUduᢡᢢᢤᢦᢨ敐;敦;敩;敤;敧ȀLRlrᢳᢵᢷᢹ;敝;敚;敜;教΀;HLRhlrᣊᣋᣍᣏᣑᣓᣕ救;敬;散;敠;敫;敢;敟ox;槉ȀLRlrᣤᣦᣨᣪ;敕;敒;攐;攌ʀ;DUduڽ᣷᣹᣻᣽;敥;敨;攬;攴inus;抟lus;択imes;抠ȀLRlrᤙᤛᤝ᤟;敛;敘;攘;攔΀;HLRhlrᤰᤱᤳᤵᤷ᤻᤹攂;敪;敡;敞;攼;攤;攜Āevģ᥂bar耻¦䂦Ȁceioᥑᥖᥚᥠr;쀀𝒷mi;恏mĀ;e᜚᜜lƀ;bhᥨᥩᥫ䁜;槅sub;柈Ŭᥴ᥾lĀ;e᥹᥺怢t»᥺pƀ;Eeįᦅᦇ;檮Ā;qۜۛೡᦧ\0᧨ᨑᨕᨲ\0ᨷᩐ\0\0᪴\0\0᫁\0\0ᬡᬮ᭍᭒\0᯽\0ᰌƀcpr᦭ᦲ᧝ute;䄇̀;abcdsᦿᧀᧄ᧊᧕᧙戩nd;橄rcup;橉Āau᧏᧒p;橋p;橇ot;橀;쀀∩︀Āeo᧢᧥t;恁îړȀaeiu᧰᧻ᨁᨅǰ᧵\0᧸s;橍on;䄍dil耻ç䃧rc;䄉psĀ;sᨌᨍ橌m;橐ot;䄋ƀdmnᨛᨠᨦil肻¸ƭptyv;榲t脀¢;eᨭᨮ䂢räƲr;쀀𝔠ƀceiᨽᩀᩍy;䑇ckĀ;mᩇᩈ朓ark»ᩈ;䏇r΀;Ecefms᩟᩠ᩢᩫ᪤᪪᪮旋;槃ƀ;elᩩᩪᩭ䋆q;扗eɡᩴ\0\0᪈rrowĀlr᩼᪁eft;憺ight;憻ʀRSacd᪒᪔᪖᪚᪟»ཇ;擈st;抛irc;抚ash;抝nint;樐id;櫯cir;槂ubsĀ;u᪻᪼晣it»᪼ˬ᫇᫔᫺\0ᬊonĀ;eᫍᫎ䀺Ā;qÇÆɭ᫙\0\0᫢aĀ;t᫞᫟䀬;䁀ƀ;fl᫨᫩᫫戁îᅠeĀmx᫱᫶ent»᫩eóɍǧ᫾\0ᬇĀ;dኻᬂot;橭nôɆƀfryᬐᬔᬗ;쀀𝕔oäɔ脀©;sŕᬝr;愗Āaoᬥᬩrr;憵ss;朗Ācuᬲᬷr;쀀𝒸Ābpᬼ᭄Ā;eᭁᭂ櫏;櫑Ā;eᭉᭊ櫐;櫒dot;拯΀delprvw᭠᭬᭷ᮂᮬᯔ᯹arrĀlr᭨᭪;椸;椵ɰ᭲\0\0᭵r;拞c;拟arrĀ;p᭿ᮀ憶;椽̀;bcdosᮏᮐᮖᮡᮥᮨ截rcap;橈Āauᮛᮞp;橆p;橊ot;抍r;橅;쀀∪︀Ȁalrv᮵ᮿᯞᯣrrĀ;mᮼᮽ憷;椼yƀevwᯇᯔᯘqɰᯎ\0\0ᯒreã᭳uã᭵ee;拎edge;拏en耻¤䂤earrowĀlrᯮ᯳eft»ᮀight»ᮽeäᯝĀciᰁᰇoninôǷnt;戱lcty;挭ঀAHabcdefhijlorstuwz᰸᰻᰿ᱝᱩᱵᲊᲞᲬᲷ᳻᳿ᴍᵻᶑᶫᶻ᷆᷍rò΁ar;楥Ȁglrs᱈ᱍ᱒᱔ger;怠eth;愸òᄳhĀ;vᱚᱛ怐»ऊūᱡᱧarow;椏aã̕Āayᱮᱳron;䄏;䐴ƀ;ao̲ᱼᲄĀgrʿᲁr;懊tseq;橷ƀglmᲑᲔᲘ耻°䂰ta;䎴ptyv;榱ĀirᲣᲨsht;楿;쀀𝔡arĀlrᲳᲵ»ࣜ»သʀaegsv᳂͸᳖᳜᳠mƀ;oș᳊᳔ndĀ;ș᳑uit;晦amma;䏝in;拲ƀ;io᳧᳨᳸䃷de脀÷;o᳧ᳰntimes;拇nø᳷cy;䑒cɯᴆ\0\0ᴊrn;挞op;挍ʀlptuwᴘᴝᴢᵉᵕlar;䀤f;쀀𝕕ʀ;emps̋ᴭᴷᴽᵂqĀ;d͒ᴳot;扑inus;戸lus;戔quare;抡blebarwedgåúnƀadhᄮᵝᵧownarrowóᲃarpoonĀlrᵲᵶefôᲴighôᲶŢᵿᶅkaro÷གɯᶊ\0\0ᶎrn;挟op;挌ƀcotᶘᶣᶦĀryᶝᶡ;쀀𝒹;䑕l;槶rok;䄑Ādrᶰᶴot;拱iĀ;fᶺ᠖斿Āah᷀᷃ròЩaòྦangle;榦Āci᷒ᷕy;䑟grarr;柿ऀDacdefglmnopqrstuxḁḉḙḸոḼṉṡṾấắẽỡἪἷὄ὎὚ĀDoḆᴴoôᲉĀcsḎḔute耻é䃩ter;橮ȀaioyḢḧḱḶron;䄛rĀ;cḭḮ扖耻ê䃪lon;払;䑍ot;䄗ĀDrṁṅot;扒;쀀𝔢ƀ;rsṐṑṗ檚ave耻è䃨Ā;dṜṝ檖ot;檘Ȁ;ilsṪṫṲṴ檙nters;揧;愓Ā;dṹṺ檕ot;檗ƀapsẅẉẗcr;䄓tyƀ;svẒẓẕ戅et»ẓpĀ1;ẝẤijạả;怄;怅怃ĀgsẪẬ;䅋p;怂ĀgpẴẸon;䄙f;쀀𝕖ƀalsỄỎỒrĀ;sỊị拕l;槣us;橱iƀ;lvỚớở䎵on»ớ;䏵ȀcsuvỪỳἋἣĀioữḱrc»Ḯɩỹ\0\0ỻíՈantĀglἂἆtr»ṝess»Ṻƀaeiἒ἖Ἒls;䀽st;扟vĀ;DȵἠD;橸parsl;槥ĀDaἯἳot;打rr;楱ƀcdiἾὁỸr;愯oô͒ĀahὉὋ;䎷耻ð䃰Āmrὓὗl耻ë䃫o;悬ƀcipὡὤὧl;䀡sôծĀeoὬὴctatioîՙnentialåչৡᾒ\0ᾞ\0ᾡᾧ\0\0ῆῌ\0ΐ\0ῦῪ \0 ⁚llingdotseñṄy;䑄male;晀ƀilrᾭᾳ῁lig;耀ffiɩᾹ\0\0᾽g;耀ffig;耀ffl;쀀𝔣lig;耀filig;쀀fjƀaltῙ῜ῡt;晭ig;耀flns;斱of;䆒ǰ΅\0ῳf;쀀𝕗ĀakֿῷĀ;vῼ´拔;櫙artint;樍Āao‌⁕Ācs‑⁒ႉ‸⁅⁈\0⁐β•‥‧‪‬\0‮耻½䂽;慓耻¼䂼;慕;慙;慛Ƴ‴\0‶;慔;慖ʴ‾⁁\0\0⁃耻¾䂾;慗;慜5;慘ƶ⁌\0⁎;慚;慝8;慞l;恄wn;挢cr;쀀𝒻ࢀEabcdefgijlnorstv₂₉₟₥₰₴⃰⃵⃺⃿℃ℒℸ̗ℾ⅒↞Ā;lٍ₇;檌ƀcmpₐₕ₝ute;䇵maĀ;dₜ᳚䎳;檆reve;䄟Āiy₪₮rc;䄝;䐳ot;䄡Ȁ;lqsؾق₽⃉ƀ;qsؾٌ⃄lanô٥Ȁ;cdl٥⃒⃥⃕c;檩otĀ;o⃜⃝檀Ā;l⃢⃣檂;檄Ā;e⃪⃭쀀⋛︀s;檔r;쀀𝔤Ā;gٳ؛mel;愷cy;䑓Ȁ;Eajٚℌℎℐ;檒;檥;檤ȀEaesℛℝ℩ℴ;扩pĀ;p℣ℤ檊rox»ℤĀ;q℮ℯ檈Ā;q℮ℛim;拧pf;쀀𝕘Āci⅃ⅆr;愊mƀ;el٫ⅎ⅐;檎;檐茀>;cdlqr׮ⅠⅪⅮⅳⅹĀciⅥⅧ;檧r;橺ot;拗Par;榕uest;橼ʀadelsↄⅪ←ٖ↛ǰ↉\0↎proø₞r;楸qĀlqؿ↖lesó₈ií٫Āen↣↭rtneqq;쀀≩︀Å↪ԀAabcefkosy⇄⇇⇱⇵⇺∘∝∯≨≽ròΠȀilmr⇐⇔⇗⇛rsðᒄf»․ilôکĀdr⇠⇤cy;䑊ƀ;cwࣴ⇫⇯ir;楈;憭ar;意irc;䄥ƀalr∁∎∓rtsĀ;u∉∊晥it»∊lip;怦con;抹r;쀀𝔥sĀew∣∩arow;椥arow;椦ʀamopr∺∾≃≞≣rr;懿tht;戻kĀlr≉≓eftarrow;憩ightarrow;憪f;쀀𝕙bar;怕ƀclt≯≴≸r;쀀𝒽asè⇴rok;䄧Ābp⊂⊇ull;恃hen»ᱛૡ⊣\0⊪\0⊸⋅⋎\0⋕⋳\0\0⋸⌢⍧⍢⍿\0⎆⎪⎴cute耻í䃭ƀ;iyݱ⊰⊵rc耻î䃮;䐸Ācx⊼⊿y;䐵cl耻¡䂡ĀfrΟ⋉;쀀𝔦rave耻ì䃬Ȁ;inoܾ⋝⋩⋮Āin⋢⋦nt;樌t;戭fin;槜ta;愩lig;䄳ƀaop⋾⌚⌝ƀcgt⌅⌈⌗r;䄫ƀelpܟ⌏⌓inåގarôܠh;䄱f;抷ed;䆵ʀ;cfotӴ⌬⌱⌽⍁are;愅inĀ;t⌸⌹戞ie;槝doô⌙ʀ;celpݗ⍌⍐⍛⍡al;抺Āgr⍕⍙eróᕣã⍍arhk;樗rod;樼Ȁcgpt⍯⍲⍶⍻y;䑑on;䄯f;쀀𝕚a;䎹uest耻¿䂿Āci⎊⎏r;쀀𝒾nʀ;EdsvӴ⎛⎝⎡ӳ;拹ot;拵Ā;v⎦⎧拴;拳Ā;iݷ⎮lde;䄩ǫ⎸\0⎼cy;䑖l耻ï䃯̀cfmosu⏌⏗⏜⏡⏧⏵Āiy⏑⏕rc;䄵;䐹r;쀀𝔧ath;䈷pf;쀀𝕛ǣ⏬\0⏱r;쀀𝒿rcy;䑘kcy;䑔Ѐacfghjos␋␖␢␧␭␱␵␻ppaĀ;v␓␔䎺;䏰Āey␛␠dil;䄷;䐺r;쀀𝔨reen;䄸cy;䑅cy;䑜pf;쀀𝕜cr;쀀𝓀஀ABEHabcdefghjlmnoprstuv⑰⒁⒆⒍⒑┎┽╚▀♎♞♥♹♽⚚⚲⛘❝❨➋⟀⠁⠒ƀart⑷⑺⑼rò৆òΕail;椛arr;椎Ā;gঔ⒋;檋ar;楢ॣ⒥\0⒪\0⒱\0\0\0\0\0⒵Ⓔ\0ⓆⓈⓍ\0⓹ute;䄺mptyv;榴raîࡌbda;䎻gƀ;dlࢎⓁⓃ;榑åࢎ;檅uo耻«䂫rЀ;bfhlpst࢙ⓞⓦⓩ⓫⓮⓱⓵Ā;f࢝ⓣs;椟s;椝ë≒p;憫l;椹im;楳l;憢ƀ;ae⓿─┄檫il;椙Ā;s┉┊檭;쀀⪭︀ƀabr┕┙┝rr;椌rk;杲Āak┢┬cĀek┨┪;䁻;䁛Āes┱┳;榋lĀdu┹┻;榏;榍Ȁaeuy╆╋╖╘ron;䄾Ādi═╔il;䄼ìࢰâ┩;䐻Ȁcqrs╣╦╭╽a;椶uoĀ;rนᝆĀdu╲╷har;楧shar;楋h;憲ʀ;fgqs▋▌উ◳◿扤tʀahlrt▘▤▷◂◨rrowĀ;t࢙□aé⓶arpoonĀdu▯▴own»њp»०eftarrows;懇ightƀahs◍◖◞rrowĀ;sࣴࢧarpoonó྘quigarro÷⇰hreetimes;拋ƀ;qs▋ও◺lanôবʀ;cdgsব☊☍☝☨c;檨otĀ;o☔☕橿Ā;r☚☛檁;檃Ā;e☢☥쀀⋚︀s;檓ʀadegs☳☹☽♉♋pproøⓆot;拖qĀgq♃♅ôউgtò⒌ôছiíলƀilr♕࣡♚sht;楼;쀀𝔩Ā;Eজ♣;檑š♩♶rĀdu▲♮Ā;l॥♳;楪lk;斄cy;䑙ʀ;achtੈ⚈⚋⚑⚖rò◁orneòᴈard;楫ri;旺Āio⚟⚤dot;䅀ustĀ;a⚬⚭掰che»⚭ȀEaes⚻⚽⛉⛔;扨pĀ;p⛃⛄檉rox»⛄Ā;q⛎⛏檇Ā;q⛎⚻im;拦Ѐabnoptwz⛩⛴⛷✚✯❁❇❐Ānr⛮⛱g;柬r;懽rëࣁgƀlmr⛿✍✔eftĀar০✇ightá৲apsto;柼ightá৽parrowĀlr✥✩efô⓭ight;憬ƀafl✶✹✽r;榅;쀀𝕝us;樭imes;樴š❋❏st;戗áፎƀ;ef❗❘᠀旊nge»❘arĀ;l❤❥䀨t;榓ʀachmt❳❶❼➅➇ròࢨorneòᶌarĀ;d྘➃;業;怎ri;抿̀achiqt➘➝ੀ➢➮➻quo;怹r;쀀𝓁mƀ;egল➪➬;檍;檏Ābu┪➳oĀ;rฟ➹;怚rok;䅂萀<;cdhilqrࠫ⟒☹⟜⟠⟥⟪⟰Āci⟗⟙;檦r;橹reå◲mes;拉arr;楶uest;橻ĀPi⟵⟹ar;榖ƀ;ef⠀भ᠛旃rĀdu⠇⠍shar;楊har;楦Āen⠗⠡rtneqq;쀀≨︀Å⠞܀Dacdefhilnopsu⡀⡅⢂⢎⢓⢠⢥⢨⣚⣢⣤ઃ⣳⤂Dot;戺Ȁclpr⡎⡒⡣⡽r耻¯䂯Āet⡗⡙;時Ā;e⡞⡟朠se»⡟Ā;sျ⡨toȀ;dluျ⡳⡷⡻owîҌefôएðᏑker;斮Āoy⢇⢌mma;権;䐼ash;怔asuredangle»ᘦr;쀀𝔪o;愧ƀcdn⢯⢴⣉ro耻µ䂵Ȁ;acdᑤ⢽⣀⣄sôᚧir;櫰ot肻·Ƶusƀ;bd⣒ᤃ⣓戒Ā;uᴼ⣘;横ţ⣞⣡p;櫛ò−ðઁĀdp⣩⣮els;抧f;쀀𝕞Āct⣸⣽r;쀀𝓂pos»ᖝƀ;lm⤉⤊⤍䎼timap;抸ఀGLRVabcdefghijlmoprstuvw⥂⥓⥾⦉⦘⧚⧩⨕⨚⩘⩝⪃⪕⪤⪨⬄⬇⭄⭿⮮ⰴⱧⱼ⳩Āgt⥇⥋;쀀⋙̸Ā;v⥐௏쀀≫⃒ƀelt⥚⥲⥶ftĀar⥡⥧rrow;懍ightarrow;懎;쀀⋘̸Ā;v⥻ే쀀≪⃒ightarrow;懏ĀDd⦎⦓ash;抯ash;抮ʀbcnpt⦣⦧⦬⦱⧌la»˞ute;䅄g;쀀∠⃒ʀ;Eiop඄⦼⧀⧅⧈;쀀⩰̸d;쀀≋̸s;䅉roø඄urĀ;a⧓⧔普lĀ;s⧓ସdz⧟\0⧣p肻\xA0ଷmpĀ;e௹ఀʀaeouy⧴⧾⨃⨐⨓ǰ⧹\0⧻;橃on;䅈dil;䅆ngĀ;dൾ⨊ot;쀀⩭̸p;橂;䐽ash;怓΀;Aadqsxஒ⨩⨭⨻⩁⩅⩐rr;懗rĀhr⨳⨶k;椤Ā;oᏲᏰot;쀀≐̸uiöୣĀei⩊⩎ar;椨í஘istĀ;s஠டr;쀀𝔫ȀEest௅⩦⩹⩼ƀ;qs஼⩭௡ƀ;qs஼௅⩴lanô௢ií௪Ā;rஶ⪁»ஷƀAap⪊⪍⪑rò⥱rr;憮ar;櫲ƀ;svྍ⪜ྌĀ;d⪡⪢拼;拺cy;䑚΀AEadest⪷⪺⪾⫂⫅⫶⫹rò⥦;쀀≦̸rr;憚r;急Ȁ;fqs఻⫎⫣⫯tĀar⫔⫙rro÷⫁ightarro÷⪐ƀ;qs఻⪺⫪lanôౕĀ;sౕ⫴»శiíౝĀ;rవ⫾iĀ;eచథiäඐĀpt⬌⬑f;쀀𝕟膀¬;in⬙⬚⬶䂬nȀ;Edvஉ⬤⬨⬮;쀀⋹̸ot;쀀⋵̸ǡஉ⬳⬵;拷;拶iĀ;vಸ⬼ǡಸ⭁⭃;拾;拽ƀaor⭋⭣⭩rȀ;ast୻⭕⭚⭟lleì୻l;쀀⫽⃥;쀀∂̸lint;樔ƀ;ceಒ⭰⭳uåಥĀ;cಘ⭸Ā;eಒ⭽ñಘȀAait⮈⮋⮝⮧rò⦈rrƀ;cw⮔⮕⮙憛;쀀⤳̸;쀀↝̸ghtarrow»⮕riĀ;eೋೖ΀chimpqu⮽⯍⯙⬄୸⯤⯯Ȁ;cerല⯆ഷ⯉uå൅;쀀𝓃ortɭ⬅\0\0⯖ará⭖mĀ;e൮⯟Ā;q൴൳suĀbp⯫⯭å೸åഋƀbcp⯶ⰑⰙȀ;Ees⯿ⰀഢⰄ抄;쀀⫅̸etĀ;eഛⰋqĀ;qണⰀcĀ;eലⰗñസȀ;EesⰢⰣൟⰧ抅;쀀⫆̸etĀ;e൘ⰮqĀ;qൠⰣȀgilrⰽⰿⱅⱇìௗlde耻ñ䃱çృiangleĀlrⱒⱜeftĀ;eచⱚñదightĀ;eೋⱥñ೗Ā;mⱬⱭ䎽ƀ;esⱴⱵⱹ䀣ro;愖p;怇ҀDHadgilrsⲏⲔⲙⲞⲣⲰⲶⳓⳣash;抭arr;椄p;쀀≍⃒ash;抬ĀetⲨⲬ;쀀≥⃒;쀀>⃒nfin;槞ƀAetⲽⳁⳅrr;椂;쀀≤⃒Ā;rⳊⳍ쀀<⃒ie;쀀⊴⃒ĀAtⳘⳜrr;椃rie;쀀⊵⃒im;쀀∼⃒ƀAan⳰⳴ⴂrr;懖rĀhr⳺⳽k;椣Ā;oᏧᏥear;椧ቓ᪕\0\0\0\0\0\0\0\0\0\0\0\0\0ⴭ\0ⴸⵈⵠⵥ⵲ⶄᬇ\0\0ⶍⶫ\0ⷈⷎ\0ⷜ⸙⸫⸾⹃Ācsⴱ᪗ute耻ó䃳ĀiyⴼⵅrĀ;c᪞ⵂ耻ô䃴;䐾ʀabios᪠ⵒⵗLjⵚlac;䅑v;樸old;榼lig;䅓Ācr⵩⵭ir;榿;쀀𝔬ͯ⵹\0\0⵼\0ⶂn;䋛ave耻ò䃲;槁Ābmⶈ෴ar;榵Ȁacitⶕ⶘ⶥⶨrò᪀Āir⶝ⶠr;榾oss;榻nå๒;槀ƀaeiⶱⶵⶹcr;䅍ga;䏉ƀcdnⷀⷅǍron;䎿;榶pf;쀀𝕠ƀaelⷔ⷗ǒr;榷rp;榹΀;adiosvⷪⷫⷮ⸈⸍⸐⸖戨rò᪆Ȁ;efmⷷⷸ⸂⸅橝rĀ;oⷾⷿ愴f»ⷿ耻ª䂪耻º䂺gof;抶r;橖lope;橗;橛ƀclo⸟⸡⸧ò⸁ash耻ø䃸l;折iŬⸯ⸴de耻õ䃵esĀ;aǛ⸺s;樶ml耻ö䃶bar;挽ૡ⹞\0⹽\0⺀⺝\0⺢⺹\0\0⻋ຜ\0⼓\0\0⼫⾼\0⿈rȀ;astЃ⹧⹲຅脀¶;l⹭⹮䂶leìЃɩ⹸\0\0⹻m;櫳;櫽y;䐿rʀcimpt⺋⺏⺓ᡥ⺗nt;䀥od;䀮il;怰enk;怱r;쀀𝔭ƀimo⺨⺰⺴Ā;v⺭⺮䏆;䏕maô੶ne;明ƀ;tv⺿⻀⻈䏀chfork»´;䏖Āau⻏⻟nĀck⻕⻝kĀ;h⇴⻛;愎ö⇴sҀ;abcdemst⻳⻴ᤈ⻹⻽⼄⼆⼊⼎䀫cir;樣ir;樢Āouᵀ⼂;樥;橲n肻±ຝim;樦wo;樧ƀipu⼙⼠⼥ntint;樕f;쀀𝕡nd耻£䂣Ԁ;Eaceinosu່⼿⽁⽄⽇⾁⾉⾒⽾⾶;檳p;檷uå໙Ā;c໎⽌̀;acens່⽙⽟⽦⽨⽾pproø⽃urlyeñ໙ñ໎ƀaes⽯⽶⽺pprox;檹qq;檵im;拨iíໟmeĀ;s⾈ຮ怲ƀEas⽸⾐⽺ð⽵ƀdfp໬⾙⾯ƀals⾠⾥⾪lar;挮ine;挒urf;挓Ā;t໻⾴ï໻rel;抰Āci⿀⿅r;쀀𝓅;䏈ncsp;怈̀fiopsu⿚⋢⿟⿥⿫⿱r;쀀𝔮pf;쀀𝕢rime;恗cr;쀀𝓆ƀaeo⿸〉〓tĀei⿾々rnionóڰnt;樖stĀ;e【】䀿ñἙô༔઀ABHabcdefhilmnoprstux぀けさすムㄎㄫㅇㅢㅲㆎ㈆㈕㈤㈩㉘㉮㉲㊐㊰㊷ƀartぇおがròႳòϝail;検aròᱥar;楤΀cdenqrtとふへみわゔヌĀeuねぱ;쀀∽̱te;䅕iãᅮmptyv;榳gȀ;del࿑らるろ;榒;榥å࿑uo耻»䂻rր;abcfhlpstw࿜ガクシスゼゾダッデナp;極Ā;f࿠ゴs;椠;椳s;椞ë≝ð✮l;楅im;楴l;憣;憝Āaiパフil;椚oĀ;nホボ戶aló༞ƀabrョリヮrò៥rk;杳ĀakンヽcĀekヹ・;䁽;䁝Āes㄂㄄;榌lĀduㄊㄌ;榎;榐Ȁaeuyㄗㄜㄧㄩron;䅙Ādiㄡㄥil;䅗ì࿲âヺ;䑀Ȁclqsㄴㄷㄽㅄa;椷dhar;楩uoĀ;rȎȍh;憳ƀacgㅎㅟངlȀ;ipsླྀㅘㅛႜnåႻarôྩt;断ƀilrㅩဣㅮsht;楽;쀀𝔯ĀaoㅷㆆrĀduㅽㅿ»ѻĀ;l႑ㆄ;楬Ā;vㆋㆌ䏁;䏱ƀgns㆕ㇹㇼht̀ahlrstㆤㆰ㇂㇘㇤㇮rrowĀ;t࿜ㆭaéトarpoonĀduㆻㆿowîㅾp»႒eftĀah㇊㇐rrowó࿪arpoonóՑightarrows;應quigarro÷ニhreetimes;拌g;䋚ingdotseñἲƀahm㈍㈐㈓rò࿪aòՑ;怏oustĀ;a㈞㈟掱che»㈟mid;櫮Ȁabpt㈲㈽㉀㉒Ānr㈷㈺g;柭r;懾rëဃƀafl㉇㉊㉎r;榆;쀀𝕣us;樮imes;樵Āap㉝㉧rĀ;g㉣㉤䀩t;榔olint;樒arò㇣Ȁachq㉻㊀Ⴜ㊅quo;怺r;쀀𝓇Ābu・㊊oĀ;rȔȓƀhir㊗㊛㊠reåㇸmes;拊iȀ;efl㊪ၙᠡ㊫方tri;槎luhar;楨;愞ൡ㋕㋛㋟㌬㌸㍱\0㍺㎤\0\0㏬㏰\0㐨㑈㑚㒭㒱㓊㓱\0㘖\0\0㘳cute;䅛quï➺Ԁ;Eaceinpsyᇭ㋳㋵㋿㌂㌋㌏㌟㌦㌩;檴ǰ㋺\0㋼;檸on;䅡uåᇾĀ;dᇳ㌇il;䅟rc;䅝ƀEas㌖㌘㌛;檶p;檺im;择olint;樓iíሄ;䑁otƀ;be㌴ᵇ㌵担;橦΀Aacmstx㍆㍊㍗㍛㍞㍣㍭rr;懘rĀhr㍐㍒ë∨Ā;oਸ਼਴t耻§䂧i;䀻war;椩mĀin㍩ðnuóñt;朶rĀ;o㍶⁕쀀𝔰Ȁacoy㎂㎆㎑㎠rp;景Āhy㎋㎏cy;䑉;䑈rtɭ㎙\0\0㎜iäᑤaraì⹯耻­䂭Āgm㎨㎴maƀ;fv㎱㎲㎲䏃;䏂Ѐ;deglnprካ㏅㏉㏎㏖㏞㏡㏦ot;橪Ā;q኱ኰĀ;E㏓㏔檞;檠Ā;E㏛㏜檝;檟e;扆lus;樤arr;楲aròᄽȀaeit㏸㐈㐏㐗Āls㏽㐄lsetmé㍪hp;樳parsl;槤Ādlᑣ㐔e;挣Ā;e㐜㐝檪Ā;s㐢㐣檬;쀀⪬︀ƀflp㐮㐳㑂tcy;䑌Ā;b㐸㐹䀯Ā;a㐾㐿槄r;挿f;쀀𝕤aĀdr㑍ЂesĀ;u㑔㑕晠it»㑕ƀcsu㑠㑹㒟Āau㑥㑯pĀ;sᆈ㑫;쀀⊓︀pĀ;sᆴ㑵;쀀⊔︀uĀbp㑿㒏ƀ;esᆗᆜ㒆etĀ;eᆗ㒍ñᆝƀ;esᆨᆭ㒖etĀ;eᆨ㒝ñᆮƀ;afᅻ㒦ְrť㒫ֱ»ᅼaròᅈȀcemt㒹㒾㓂㓅r;쀀𝓈tmîñiì㐕aræᆾĀar㓎㓕rĀ;f㓔ឿ昆Āan㓚㓭ightĀep㓣㓪psiloîỠhé⺯s»⡒ʀbcmnp㓻㕞ሉ㖋㖎Ҁ;Edemnprs㔎㔏㔑㔕㔞㔣㔬㔱㔶抂;櫅ot;檽Ā;dᇚ㔚ot;櫃ult;櫁ĀEe㔨㔪;櫋;把lus;檿arr;楹ƀeiu㔽㕒㕕tƀ;en㔎㕅㕋qĀ;qᇚ㔏eqĀ;q㔫㔨m;櫇Ābp㕚㕜;櫕;櫓c̀;acensᇭ㕬㕲㕹㕻㌦pproø㋺urlyeñᇾñᇳƀaes㖂㖈㌛pproø㌚qñ㌗g;晪ڀ123;Edehlmnps㖩㖬㖯ሜ㖲㖴㗀㗉㗕㗚㗟㗨㗭耻¹䂹耻²䂲耻³䂳;櫆Āos㖹㖼t;檾ub;櫘Ā;dሢ㗅ot;櫄sĀou㗏㗒l;柉b;櫗arr;楻ult;櫂ĀEe㗤㗦;櫌;抋lus;櫀ƀeiu㗴㘉㘌tƀ;enሜ㗼㘂qĀ;qሢ㖲eqĀ;q㗧㗤m;櫈Ābp㘑㘓;櫔;櫖ƀAan㘜㘠㘭rr;懙rĀhr㘦㘨ë∮Ā;oਫ਩war;椪lig耻ß䃟௡㙑㙝㙠ዎ㙳㙹\0㙾㛂\0\0\0\0\0㛛㜃\0㜉㝬\0\0\0㞇ɲ㙖\0\0㙛get;挖;䏄rë๟ƀaey㙦㙫㙰ron;䅥dil;䅣;䑂lrec;挕r;쀀𝔱Ȁeiko㚆㚝㚵㚼Dz㚋\0㚑eĀ4fኄኁaƀ;sv㚘㚙㚛䎸ym;䏑Ācn㚢㚲kĀas㚨㚮pproø዁im»ኬsðኞĀas㚺㚮ð዁rn耻þ䃾Ǭ̟㛆⋧es膀×;bd㛏㛐㛘䃗Ā;aᤏ㛕r;樱;樰ƀeps㛡㛣㜀á⩍Ȁ;bcf҆㛬㛰㛴ot;挶ir;櫱Ā;o㛹㛼쀀𝕥rk;櫚á㍢rime;怴ƀaip㜏㜒㝤dåቈ΀adempst㜡㝍㝀㝑㝗㝜㝟ngleʀ;dlqr㜰㜱㜶㝀㝂斵own»ᶻeftĀ;e⠀㜾ñम;扜ightĀ;e㊪㝋ñၚot;旬inus;樺lus;樹b;槍ime;樻ezium;揢ƀcht㝲㝽㞁Āry㝷㝻;쀀𝓉;䑆cy;䑛rok;䅧Āio㞋㞎xô᝷headĀlr㞗㞠eftarro÷ࡏightarrow»ཝऀAHabcdfghlmoprstuw㟐㟓㟗㟤㟰㟼㠎㠜㠣㠴㡑㡝㡫㢩㣌㣒㣪㣶ròϭar;楣Ācr㟜㟢ute耻ú䃺òᅐrǣ㟪\0㟭y;䑞ve;䅭Āiy㟵㟺rc耻û䃻;䑃ƀabh㠃㠆㠋ròᎭlac;䅱aòᏃĀir㠓㠘sht;楾;쀀𝔲rave耻ù䃹š㠧㠱rĀlr㠬㠮»ॗ»ႃlk;斀Āct㠹㡍ɯ㠿\0\0㡊rnĀ;e㡅㡆挜r»㡆op;挏ri;旸Āal㡖㡚cr;䅫肻¨͉Āgp㡢㡦on;䅳f;쀀𝕦̀adhlsuᅋ㡸㡽፲㢑㢠ownáᎳarpoonĀlr㢈㢌efô㠭ighô㠯iƀ;hl㢙㢚㢜䏅»ᏺon»㢚parrows;懈ƀcit㢰㣄㣈ɯ㢶\0\0㣁rnĀ;e㢼㢽挝r»㢽op;挎ng;䅯ri;旹cr;쀀𝓊ƀdir㣙㣝㣢ot;拰lde;䅩iĀ;f㜰㣨»᠓Āam㣯㣲rò㢨l耻ü䃼angle;榧ހABDacdeflnoprsz㤜㤟㤩㤭㦵㦸㦽㧟㧤㧨㧳㧹㧽㨁㨠ròϷarĀ;v㤦㤧櫨;櫩asèϡĀnr㤲㤷grt;榜΀eknprst㓣㥆㥋㥒㥝㥤㦖appá␕othinçẖƀhir㓫⻈㥙opô⾵Ā;hᎷ㥢ïㆍĀiu㥩㥭gmá㎳Ābp㥲㦄setneqĀ;q㥽㦀쀀⊊︀;쀀⫋︀setneqĀ;q㦏㦒쀀⊋︀;쀀⫌︀Āhr㦛㦟etá㚜iangleĀlr㦪㦯eft»थight»ၑy;䐲ash»ံƀelr㧄㧒㧗ƀ;beⷪ㧋㧏ar;抻q;扚lip;拮Ābt㧜ᑨaòᑩr;쀀𝔳tré㦮suĀbp㧯㧱»ജ»൙pf;쀀𝕧roð໻tré㦴Ācu㨆㨋r;쀀𝓋Ābp㨐㨘nĀEe㦀㨖»㥾nĀEe㦒㨞»㦐igzag;榚΀cefoprs㨶㨻㩖㩛㩔㩡㩪irc;䅵Ādi㩀㩑Ābg㩅㩉ar;機eĀ;qᗺ㩏;扙erp;愘r;쀀𝔴pf;쀀𝕨Ā;eᑹ㩦atèᑹcr;쀀𝓌ૣណ㪇\0㪋\0㪐㪛\0\0㪝㪨㪫㪯\0\0㫃㫎\0㫘ៜ៟tré៑r;쀀𝔵ĀAa㪔㪗ròσrò৶;䎾ĀAa㪡㪤ròθrò৫að✓is;拻ƀdptឤ㪵㪾Āfl㪺ឩ;쀀𝕩imåឲĀAa㫇㫊ròώròਁĀcq㫒ីr;쀀𝓍Āpt៖㫜ré។Ѐacefiosu㫰㫽㬈㬌㬑㬕㬛㬡cĀuy㫶㫻te耻ý䃽;䑏Āiy㬂㬆rc;䅷;䑋n耻¥䂥r;쀀𝔶cy;䑗pf;쀀𝕪cr;쀀𝓎Ācm㬦㬩y;䑎l耻ÿ䃿Ԁacdefhiosw㭂㭈㭔㭘㭤㭩㭭㭴㭺㮀cute;䅺Āay㭍㭒ron;䅾;䐷ot;䅼Āet㭝㭡træᕟa;䎶r;쀀𝔷cy;䐶grarr;懝pf;쀀𝕫cr;쀀𝓏Ājn㮅㮇;怍j;怌`.split(``).map(e=>e.charCodeAt(0))),xQ=new Uint16Array(`Ȁaglq \x1Bɭ\0\0p;䀦os;䀧t;䀾t;䀼uot;䀢`.split(``).map(e=>e.charCodeAt(0))),SQ=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]]),CQ=String.fromCodePoint??function(e){let t=``;return e>65535&&(e-=65536,t+=String.fromCharCode(e>>>10&1023|55296),e=56320|e&1023),t+=String.fromCharCode(e),t};function wQ(e){return e>=55296&&e<=57343||e>1114111?65533:SQ.get(e)??e}var TQ;(function(e){e[e.NUM=35]=`NUM`,e[e.SEMI=59]=`SEMI`,e[e.EQUALS=61]=`EQUALS`,e[e.ZERO=48]=`ZERO`,e[e.NINE=57]=`NINE`,e[e.LOWER_A=97]=`LOWER_A`,e[e.LOWER_F=102]=`LOWER_F`,e[e.LOWER_X=120]=`LOWER_X`,e[e.LOWER_Z=122]=`LOWER_Z`,e[e.UPPER_A=65]=`UPPER_A`,e[e.UPPER_F=70]=`UPPER_F`,e[e.UPPER_Z=90]=`UPPER_Z`})(TQ||={});var EQ=32,DQ;(function(e){e[e.VALUE_LENGTH=49152]=`VALUE_LENGTH`,e[e.BRANCH_LENGTH=16256]=`BRANCH_LENGTH`,e[e.JUMP_TABLE=127]=`JUMP_TABLE`})(DQ||={});function OQ(e){return e>=TQ.ZERO&&e<=TQ.NINE}function kQ(e){return e>=TQ.UPPER_A&&e<=TQ.UPPER_F||e>=TQ.LOWER_A&&e<=TQ.LOWER_F}function AQ(e){return e>=TQ.UPPER_A&&e<=TQ.UPPER_Z||e>=TQ.LOWER_A&&e<=TQ.LOWER_Z||OQ(e)}function jQ(e){return e===TQ.EQUALS||AQ(e)}var MQ;(function(e){e[e.EntityStart=0]=`EntityStart`,e[e.NumericStart=1]=`NumericStart`,e[e.NumericDecimal=2]=`NumericDecimal`,e[e.NumericHex=3]=`NumericHex`,e[e.NamedEntity=4]=`NamedEntity`})(MQ||={});var NQ;(function(e){e[e.Legacy=0]=`Legacy`,e[e.Strict=1]=`Strict`,e[e.Attribute=2]=`Attribute`})(NQ||={});var PQ=class{constructor(e,t,n){this.decodeTree=e,this.emitCodePoint=t,this.errors=n,this.state=MQ.EntityStart,this.consumed=1,this.result=0,this.treeIndex=0,this.excess=1,this.decodeMode=NQ.Strict}startEntity(e){this.decodeMode=e,this.state=MQ.EntityStart,this.result=0,this.treeIndex=0,this.excess=1,this.consumed=1}write(e,t){switch(this.state){case MQ.EntityStart:return e.charCodeAt(t)===TQ.NUM?(this.state=MQ.NumericStart,this.consumed+=1,this.stateNumericStart(e,t+1)):(this.state=MQ.NamedEntity,this.stateNamedEntity(e,t));case MQ.NumericStart:return this.stateNumericStart(e,t);case MQ.NumericDecimal:return this.stateNumericDecimal(e,t);case MQ.NumericHex:return this.stateNumericHex(e,t);case MQ.NamedEntity:return this.stateNamedEntity(e,t)}}stateNumericStart(e,t){return t>=e.length?-1:(e.charCodeAt(t)|EQ)===TQ.LOWER_X?(this.state=MQ.NumericHex,this.consumed+=1,this.stateNumericHex(e,t+1)):(this.state=MQ.NumericDecimal,this.stateNumericDecimal(e,t))}addToNumericResult(e,t,n,r){if(t!==n){let i=n-t;this.result=this.result*r**+i+parseInt(e.substr(t,i),r),this.consumed+=i}}stateNumericHex(e,t){let n=t;for(;t<e.length;){let r=e.charCodeAt(t);if(OQ(r)||kQ(r))t+=1;else return this.addToNumericResult(e,n,t,16),this.emitNumericEntity(r,3)}return this.addToNumericResult(e,n,t,16),-1}stateNumericDecimal(e,t){let n=t;for(;t<e.length;){let r=e.charCodeAt(t);if(OQ(r))t+=1;else return this.addToNumericResult(e,n,t,10),this.emitNumericEntity(r,2)}return this.addToNumericResult(e,n,t,10),-1}emitNumericEntity(e,t){var n;if(this.consumed<=t)return(n=this.errors)==null||n.absenceOfDigitsInNumericCharacterReference(this.consumed),0;if(e===TQ.SEMI)this.consumed+=1;else if(this.decodeMode===NQ.Strict)return 0;return this.emitCodePoint(wQ(this.result),this.consumed),this.errors&&(e!==TQ.SEMI&&this.errors.missingSemicolonAfterCharacterReference(),this.errors.validateNumericCharacterReference(this.result)),this.consumed}stateNamedEntity(e,t){let{decodeTree:n}=this,r=n[this.treeIndex],i=(r&DQ.VALUE_LENGTH)>>14;for(;t<e.length;t++,this.excess++){let a=e.charCodeAt(t);if(this.treeIndex=IQ(n,r,this.treeIndex+Math.max(1,i),a),this.treeIndex<0)return this.result===0||this.decodeMode===NQ.Attribute&&(i===0||jQ(a))?0:this.emitNotTerminatedNamedEntity();if(r=n[this.treeIndex],i=(r&DQ.VALUE_LENGTH)>>14,i!==0){if(a===TQ.SEMI)return this.emitNamedEntityData(this.treeIndex,i,this.consumed+this.excess);this.decodeMode!==NQ.Strict&&(this.result=this.treeIndex,this.consumed+=this.excess,this.excess=0)}}return-1}emitNotTerminatedNamedEntity(){var e;let{result:t,decodeTree:n}=this,r=(n[t]&DQ.VALUE_LENGTH)>>14;return this.emitNamedEntityData(t,r,this.consumed),(e=this.errors)==null||e.missingSemicolonAfterCharacterReference(),this.consumed}emitNamedEntityData(e,t,n){let{decodeTree:r}=this;return this.emitCodePoint(t===1?r[e]&~DQ.VALUE_LENGTH:r[e+1],n),t===3&&this.emitCodePoint(r[e+2],n),n}end(){var e;switch(this.state){case MQ.NamedEntity:return this.result!==0&&(this.decodeMode!==NQ.Attribute||this.result===this.treeIndex)?this.emitNotTerminatedNamedEntity():0;case MQ.NumericDecimal:return this.emitNumericEntity(0,2);case MQ.NumericHex:return this.emitNumericEntity(0,3);case MQ.NumericStart:return(e=this.errors)==null||e.absenceOfDigitsInNumericCharacterReference(this.consumed),0;case MQ.EntityStart:return 0}}};function FQ(e){let t=``,n=new PQ(e,e=>t+=CQ(e));return function(e,r){let i=0,a=0;for(;(a=e.indexOf(`&`,a))>=0;){t+=e.slice(i,a),n.startEntity(r);let o=n.write(e,a+1);if(o<0){i=a+n.end();break}i=a+o,a=o===0?i+1:i}let o=t+e.slice(i);return t=``,o}}function IQ(e,t,n,r){let i=(t&DQ.BRANCH_LENGTH)>>7,a=t&DQ.JUMP_TABLE;if(i===0)return a!==0&&r===a?n:-1;if(a){let t=r-a;return t<0||t>=i?-1:e[n+t]-1}let o=n,s=o+i-1;for(;o<=s;){let t=o+s>>>1,n=e[t];if(n<r)o=t+1;else if(n>r)s=t-1;else return e[t+i]}return-1}var LQ=FQ(bQ);FQ(xQ);function RQ(e,t=NQ.Legacy){return LQ(e,t)}function zQ(e){return LQ(e,NQ.Strict)}var BQ=t({arrayReplaceAt:()=>KQ,asciiTrim:()=>h$,assign:()=>GQ,escapeHtml:()=>a$,escapeRE:()=>s$,fromCodePoint:()=>JQ,has:()=>WQ,isMdAsciiPunct:()=>f$,isPunctChar:()=>u$,isPunctCharCode:()=>d$,isSpace:()=>c$,isString:()=>HQ,isValidEntityCode:()=>qQ,isWhiteSpace:()=>l$,lib:()=>g$,normalizeReference:()=>p$,unescapeAll:()=>e$,unescapeMd:()=>$Q});function VQ(e){return Object.prototype.toString.call(e)}function HQ(e){return VQ(e)===`[object String]`}var UQ=Object.prototype.hasOwnProperty;function WQ(e,t){return UQ.call(e,t)}function GQ(e){return Array.prototype.slice.call(arguments,1).forEach(function(t){if(t){if(typeof t!=`object`)throw TypeError(t+`must be object`);Object.keys(t).forEach(function(n){e[n]=t[n]})}}),e}function KQ(e,t,n){return[].concat(e.slice(0,t),n,e.slice(t+1))}function qQ(e){return!(e>=55296&&e<=57343||e>=64976&&e<=65007||(e&65535)==65535||(e&65535)==65534||e>=0&&e<=8||e===11||e>=14&&e<=31||e>=127&&e<=159||e>1114111)}function JQ(e){if(e>65535){e-=65536;let t=55296+(e>>10),n=56320+(e&1023);return String.fromCharCode(t,n)}return String.fromCharCode(e)}var YQ=/\\([!"#$%&'()*+,\-./:;<=>?@[\\\]^_`{|}~])/g,XQ=RegExp(YQ.source+`|&([a-z#][a-z0-9]{1,31});`,`gi`),ZQ=/^#((?:x[a-f0-9]{1,8}|[0-9]{1,8}))$/i;function QQ(e,t){if(t.charCodeAt(0)===35&&ZQ.test(t)){let n=t[1].toLowerCase()===`x`?parseInt(t.slice(2),16):parseInt(t.slice(1),10);return qQ(n)?JQ(n):e}let n=RQ(e);return n===e?e:n}function $Q(e){return e.indexOf(`\\`)<0?e:e.replace(YQ,`$1`)}function e$(e){return e.indexOf(`\\`)<0&&e.indexOf(`&`)<0?e:e.replace(XQ,function(e,t,n){return t||QQ(e,n)})}var t$=/[&<>"]/,n$=/[&<>"]/g,r$={"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`};function i$(e){return r$[e]}function a$(e){return t$.test(e)?e.replace(n$,i$):e}var o$=/[.?*+^$[\]\\(){}|-]/g;function s$(e){return e.replace(o$,`\\$&`)}function c$(e){switch(e){case 9:case 32:return!0}return!1}function l$(e){if(e>=8192&&e<=8202)return!0;switch(e){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 u$(e){return gQ.test(e)||_Q.test(e)}function d$(e){return u$(JQ(e))}function f$(e){switch(e){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 p$(e){return e=e.trim().replace(/\s+/g,` `),e.toLowerCase().toUpperCase()}function m$(e){return e===32||e===9||e===10||e===13}function h$(e){let t=0;for(;t<e.length&&m$(e.charCodeAt(t));t++);let n=e.length-1;for(;n>=t&&m$(e.charCodeAt(n));n--);return e.slice(t,n+1)}var g$={mdurl:fQ,ucmicro:yQ};function _$(e,t,n){let r,i,a,o,s=e.posMax,c=e.pos;for(e.pos=t+1,r=1;e.pos<s;){if(a=e.src.charCodeAt(e.pos),a===93&&(r--,r===0)){i=!0;break}if(o=e.pos,e.md.inline.skipToken(e),a===91){if(o===e.pos-1)r++;else if(n)return e.pos=c,-1}}let l=-1;return i&&(l=e.pos),e.pos=c,l}function v$(e,t,n){let r,i=t,a={ok:!1,pos:0,str:``};if(e.charCodeAt(i)===60){for(i++;i<n;){if(r=e.charCodeAt(i),r===10||r===60)return a;if(r===62)return a.pos=i+1,a.str=e$(e.slice(t+1,i)),a.ok=!0,a;if(r===92&&i+1<n){i+=2;continue}i++}return a}let o=0;for(;i<n&&(r=e.charCodeAt(i),!(r===32||r<32||r===127));){if(r===92&&i+1<n){if(e.charCodeAt(i+1)===32)break;i+=2;continue}if(r===40&&(o++,o>32))return a;if(r===41){if(o===0)break;o--}i++}return t===i||o!==0?a:(a.str=e$(e.slice(t,i)),a.pos=i,a.ok=!0,a)}function y$(e,t,n,r){let i,a=t,o={ok:!1,can_continue:!1,pos:0,str:``,marker:0};if(r)o.str=r.str,o.marker=r.marker;else{if(a>=n)return o;let r=e.charCodeAt(a);if(r!==34&&r!==39&&r!==40)return o;t++,a++,r===40&&(r=41),o.marker=r}for(;a<n;){if(i=e.charCodeAt(a),i===o.marker)return o.pos=a+1,o.str+=e$(e.slice(t,a)),o.ok=!0,o;if(i===40&&o.marker===41)return o;i===92&&a+1<n&&a++,a++}return o.can_continue=!0,o.str+=e$(e.slice(t,a)),o}var b$=t({parseLinkDestination:()=>v$,parseLinkLabel:()=>_$,parseLinkTitle:()=>y$}),x$={};x$.code_inline=function(e,t,n,r,i){let a=e[t];return`<code`+i.renderAttrs(a)+`>`+a$(a.content)+`</code>`},x$.code_block=function(e,t,n,r,i){let a=e[t];return`<pre`+i.renderAttrs(a)+`><code>`+a$(e[t].content)+`</code></pre>
222
+ `},x$.fence=function(e,t,n,r,i){let a=e[t],o=a.info?e$(a.info).trim():``,s=``,c=``;if(o){let e=o.split(/(\s+)/g);s=e[0],c=e.slice(2).join(``)}let l;if(l=n.highlight&&n.highlight(a.content,s,c)||a$(a.content),l.indexOf(`<pre`)===0)return l+`
223
+ `;if(o){let e=a.attrIndex(`class`),t=a.attrs?a.attrs.slice():[];e<0?t.push([`class`,n.langPrefix+s]):(t[e]=t[e].slice(),t[e][1]+=` `+n.langPrefix+s);let r={attrs:t};return`<pre><code${i.renderAttrs(r)}>${l}</code></pre>\n`}return`<pre><code${i.renderAttrs(a)}>${l}</code></pre>\n`},x$.image=function(e,t,n,r,i){let a=e[t];return a.attrs[a.attrIndex(`alt`)][1]=i.renderInlineAsText(a.children,n,r),i.renderToken(e,t,n)},x$.hardbreak=function(e,t,n){return n.xhtmlOut?`<br />
224
+ `:`<br>
225
+ `},x$.softbreak=function(e,t,n){return n.breaks?n.xhtmlOut?`<br />
226
+ `:`<br>
227
+ `:`
228
+ `},x$.text=function(e,t){return a$(e[t].content)},x$.html_block=function(e,t){return e[t].content},x$.html_inline=function(e,t){return e[t].content};function S$(){this.rules=GQ({},x$)}S$.prototype.renderAttrs=function(e){let t,n,r;if(!e.attrs)return``;for(r=``,t=0,n=e.attrs.length;t<n;t++)r+=` `+a$(e.attrs[t][0])+`="`+a$(e.attrs[t][1])+`"`;return r},S$.prototype.renderToken=function(e,t,n){let r=e[t],i=``;if(r.hidden)return``;r.block&&r.nesting!==-1&&t&&e[t-1].hidden&&(i+=`
229
+ `),i+=(r.nesting===-1?`</`:`<`)+r.tag,i+=this.renderAttrs(r),r.nesting===0&&n.xhtmlOut&&(i+=` /`);let a=!1;if(r.block&&(a=!0,r.nesting===1&&t+1<e.length)){let n=e[t+1];(n.type===`inline`||n.hidden||n.nesting===-1&&n.tag===r.tag)&&(a=!1)}return i+=a?`>
230
+ `:`>`,i},S$.prototype.renderInline=function(e,t,n){let r=``,i=this.rules;for(let a=0,o=e.length;a<o;a++){let o=e[a].type;i[o]===void 0?r+=this.renderToken(e,a,t):r+=i[o](e,a,t,n,this)}return r},S$.prototype.renderInlineAsText=function(e,t,n){let r=``;for(let i=0,a=e.length;i<a;i++)switch(e[i].type){case`text`:r+=e[i].content;break;case`image`:r+=this.renderInlineAsText(e[i].children,t,n);break;case`html_inline`:case`html_block`:r+=e[i].content;break;case`softbreak`:case`hardbreak`:r+=`
231
+ `;break;default:}return r},S$.prototype.render=function(e,t,n){let r=``,i=this.rules;for(let a=0,o=e.length;a<o;a++){let o=e[a].type;o===`inline`?r+=this.renderInline(e[a].children,t,n):i[o]===void 0?r+=this.renderToken(e,a,t,n):r+=i[o](e,a,t,n,this)}return r};function C$(){this.__rules__=[],this.__cache__=null}C$.prototype.__find__=function(e){for(let t=0;t<this.__rules__.length;t++)if(this.__rules__[t].name===e)return t;return-1},C$.prototype.__compile__=function(){let e=this,t=[``];e.__rules__.forEach(function(e){e.enabled&&e.alt.forEach(function(e){t.indexOf(e)<0&&t.push(e)})}),e.__cache__={},t.forEach(function(t){e.__cache__[t]=[],e.__rules__.forEach(function(n){n.enabled&&(t&&n.alt.indexOf(t)<0||e.__cache__[t].push(n.fn))})})},C$.prototype.at=function(e,t,n){let r=this.__find__(e),i=n||{};if(r===-1)throw Error(`Parser rule not found: `+e);this.__rules__[r].fn=t,this.__rules__[r].alt=i.alt||[],this.__cache__=null},C$.prototype.before=function(e,t,n,r){let i=this.__find__(e),a=r||{};if(i===-1)throw Error(`Parser rule not found: `+e);this.__rules__.splice(i,0,{name:t,enabled:!0,fn:n,alt:a.alt||[]}),this.__cache__=null},C$.prototype.after=function(e,t,n,r){let i=this.__find__(e),a=r||{};if(i===-1)throw Error(`Parser rule not found: `+e);this.__rules__.splice(i+1,0,{name:t,enabled:!0,fn:n,alt:a.alt||[]}),this.__cache__=null},C$.prototype.push=function(e,t,n){let r=n||{};this.__rules__.push({name:e,enabled:!0,fn:t,alt:r.alt||[]}),this.__cache__=null},C$.prototype.enable=function(e,t){Array.isArray(e)||(e=[e]);let n=[];return e.forEach(function(e){let r=this.__find__(e);if(r<0){if(t)return;throw Error(`Rules manager: invalid rule name `+e)}this.__rules__[r].enabled=!0,n.push(e)},this),this.__cache__=null,n},C$.prototype.enableOnly=function(e,t){Array.isArray(e)||(e=[e]),this.__rules__.forEach(function(e){e.enabled=!1}),this.enable(e,t)},C$.prototype.disable=function(e,t){Array.isArray(e)||(e=[e]);let n=[];return e.forEach(function(e){let r=this.__find__(e);if(r<0){if(t)return;throw Error(`Rules manager: invalid rule name `+e)}this.__rules__[r].enabled=!1,n.push(e)},this),this.__cache__=null,n},C$.prototype.getRules=function(e){return this.__cache__===null&&this.__compile__(),this.__cache__[e]||[]};function w$(e,t,n){this.type=e,this.tag=t,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}w$.prototype.attrIndex=function(e){if(!this.attrs)return-1;let t=this.attrs;for(let n=0,r=t.length;n<r;n++)if(t[n][0]===e)return n;return-1},w$.prototype.attrPush=function(e){this.attrs?this.attrs.push(e):this.attrs=[e]},w$.prototype.attrSet=function(e,t){let n=this.attrIndex(e),r=[e,t];n<0?this.attrPush(r):this.attrs[n]=r},w$.prototype.attrGet=function(e){let t=this.attrIndex(e),n=null;return t>=0&&(n=this.attrs[t][1]),n},w$.prototype.attrJoin=function(e,t){let n=this.attrIndex(e);n<0?this.attrPush([e,t]):this.attrs[n][1]=this.attrs[n][1]+` `+t};function T$(e,t,n){this.src=e,this.env=n,this.tokens=[],this.inlineMode=!1,this.md=t}T$.prototype.Token=w$;var E$=/\r\n?|\n/g,D$=/\0/g;function O$(e){let t;t=e.src.replace(E$,`
232
+ `),t=t.replace(D$,`�`),e.src=t}function k$(e){let t;e.inlineMode?(t=new e.Token(`inline`,``,0),t.content=e.src,t.map=[0,1],t.children=[],e.tokens.push(t)):e.md.block.parse(e.src,e.md,e.env,e.tokens)}function A$(e){let t=e.tokens;for(let n=0,r=t.length;n<r;n++){let r=t[n];r.type===`inline`&&e.md.inline.parse(r.content,e.md,e.env,r.children)}}function j$(e){return/^<a[>\s]/i.test(e)}function M$(e){return/^<\/a\s*>/i.test(e)}function N$(e){let t=e.tokens;if(e.md.options.linkify)for(let n=0,r=t.length;n<r;n++){if(t[n].type!==`inline`||!e.md.linkify.pretest(t[n].content))continue;let r=t[n].children,i=0;for(let a=r.length-1;a>=0;a--){let o=r[a];if(o.type===`link_close`){for(a--;r[a].level!==o.level&&r[a].type!==`link_open`;)a--;continue}if(o.type===`html_inline`&&(j$(o.content)&&i>0&&i--,M$(o.content)&&i++),!(i>0)&&o.type===`text`&&e.md.linkify.test(o.content)){let i=o.content,s=e.md.linkify.match(i),c=[],l=o.level,u=0;s.length>0&&s[0].index===0&&a>0&&r[a-1].type===`text_special`&&(s=s.slice(1));for(let t=0;t<s.length;t++){let n=s[t].url,r=e.md.normalizeLink(n);if(!e.md.validateLink(r))continue;let a=s[t].text;a=s[t].schema?s[t].schema===`mailto:`&&!/^mailto:/i.test(a)?e.md.normalizeLinkText(`mailto:`+a).replace(/^mailto:/,``):e.md.normalizeLinkText(a):e.md.normalizeLinkText(`http://`+a).replace(/^http:\/\//,``);let o=s[t].index;if(o>u){let t=new e.Token(`text`,``,0);t.content=i.slice(u,o),t.level=l,c.push(t)}let d=new e.Token(`link_open`,`a`,1);d.attrs=[[`href`,r]],d.level=l++,d.markup=`linkify`,d.info=`auto`,c.push(d);let f=new e.Token(`text`,``,0);f.content=a,f.level=l,c.push(f);let p=new e.Token(`link_close`,`a`,-1);p.level=--l,p.markup=`linkify`,p.info=`auto`,c.push(p),u=s[t].lastIndex}if(u<i.length){let t=new e.Token(`text`,``,0);t.content=i.slice(u),t.level=l,c.push(t)}t[n].children=r=KQ(r,a,c)}}}}var P$=/\+-|\.\.|\?\?\?\?|!!!!|,,|--/,F$=/\((c|tm|r)\)/i,I$=/\((c|tm|r)\)/gi,L$={c:`©`,r:`®`,tm:`™`};function R$(e,t){return L$[t.toLowerCase()]}function z$(e){let t=0;for(let n=e.length-1;n>=0;n--){let r=e[n];r.type===`text`&&!t&&(r.content=r.content.replace(I$,R$)),r.type===`link_open`&&r.info===`auto`&&t--,r.type===`link_close`&&r.info===`auto`&&t++}}function B$(e){let t=0;for(let n=e.length-1;n>=0;n--){let r=e[n];r.type===`text`&&!t&&P$.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(/(^|[^-])---(?=[^-]|$)/gm,`$1—`).replace(/(^|\s)--(?=\s|$)/gm,`$1–`).replace(/(^|[^-\s])--(?=[^-\s]|$)/gm,`$1–`)),r.type===`link_open`&&r.info===`auto`&&t--,r.type===`link_close`&&r.info===`auto`&&t++}}function V$(e){let t;if(e.md.options.typographer)for(t=e.tokens.length-1;t>=0;t--)e.tokens[t].type===`inline`&&(F$.test(e.tokens[t].content)&&z$(e.tokens[t].children),P$.test(e.tokens[t].content)&&B$(e.tokens[t].children))}var H$=/['"]/,U$=/['"]/g,W$=`’`;function G$(e,t,n,r){e[t]||(e[t]=[]),e[t].push({pos:n,ch:r})}function K$(e,t){let n=``,r=0;t.sort((e,t)=>e.pos-t.pos);for(let i=0;i<t.length;i++){let a=t[i];n+=e.slice(r,a.pos)+a.ch,r=a.pos+1}return n+e.slice(r)}function q$(e,t){let n,r=[],i={};for(let a=0;a<e.length;a++){let o=e[a],s=e[a].level;for(n=r.length-1;n>=0&&!(r[n].level<=s);n--);if(r.length=n+1,o.type!==`text`)continue;let c=o.content,l=0,u=c.length;OUTER:for(;l<u;){U$.lastIndex=l;let o=U$.exec(c);if(!o)break;let d=!0,f=!0;l=o.index+1;let p=o[0]===`'`,m=32;if(o.index-1>=0)m=c.charCodeAt(o.index-1);else for(n=a-1;n>=0&&!(e[n].type===`softbreak`||e[n].type===`hardbreak`);n--)if(e[n].content){m=e[n].content.charCodeAt(e[n].content.length-1);break}let h=32;if(l<u)h=c.charCodeAt(l);else for(n=a+1;n<e.length&&!(e[n].type===`softbreak`||e[n].type===`hardbreak`);n++)if(e[n].content){h=e[n].content.charCodeAt(0);break}let g=f$(m)||d$(m),_=f$(h)||d$(h),v=l$(m),y=l$(h);if(y?d=!1:_&&(v||g||(d=!1)),v?f=!1:g&&(y||_||(f=!1)),h===34&&o[0]===`"`&&m>=48&&m<=57&&(f=d=!1),d&&f&&(d=g,f=_),!d&&!f){p&&G$(i,a,o.index,W$);continue}if(f)for(n=r.length-1;n>=0;n--){let e=r[n];if(r[n].level<s)break;if(e.single===p&&r[n].level===s){e=r[n];let s,c;p?(s=t.md.options.quotes[2],c=t.md.options.quotes[3]):(s=t.md.options.quotes[0],c=t.md.options.quotes[1]),G$(i,a,o.index,c),G$(i,e.token,e.pos,s),r.length=n;continue OUTER}}d?r.push({token:a,pos:o.index,single:p,level:s}):f&&p&&G$(i,a,o.index,W$)}}Object.keys(i).forEach(function(t){e[t].content=K$(e[t].content,i[t])})}function J$(e){if(e.md.options.typographer)for(let t=e.tokens.length-1;t>=0;t--)e.tokens[t].type!==`inline`||!H$.test(e.tokens[t].content)||q$(e.tokens[t].children,e)}function Y$(e){let t,n,r=e.tokens,i=r.length;for(let e=0;e<i;e++){if(r[e].type!==`inline`)continue;let i=r[e].children,a=i.length;for(t=0;t<a;t++)i[t].type===`text_special`&&(i[t].type=`text`);for(t=n=0;t<a;t++)i[t].type===`text`&&t+1<a&&i[t+1].type===`text`?i[t+1].content=i[t].content+i[t+1].content:(t!==n&&(i[n]=i[t]),n++);t!==n&&(i.length=n)}}var X$=[[`normalize`,O$],[`block`,k$],[`inline`,A$],[`linkify`,N$],[`replacements`,V$],[`smartquotes`,J$],[`text_join`,Y$]];function Z$(){this.ruler=new C$;for(let e=0;e<X$.length;e++)this.ruler.push(X$[e][0],X$[e][1])}Z$.prototype.process=function(e){let t=this.ruler.getRules(``);for(let n=0,r=t.length;n<r;n++)t[n](e)},Z$.prototype.State=T$;function Q$(e,t,n,r){this.src=e,this.md=t,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;let i=this.src;for(let e=0,t=0,n=0,r=0,a=i.length,o=!1;t<a;t++){let s=i.charCodeAt(t);if(!o)if(c$(s)){n++,s===9?r+=4-r%4:r++;continue}else o=!0;(s===10||t===a-1)&&(s!==10&&t++,this.bMarks.push(e),this.eMarks.push(t),this.tShift.push(n),this.sCount.push(r),this.bsCount.push(0),o=!1,n=0,r=0,e=t+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}Q$.prototype.push=function(e,t,n){let r=new w$(e,t,n);return r.block=!0,n<0&&this.level--,r.level=this.level,n>0&&this.level++,this.tokens.push(r),r},Q$.prototype.isEmpty=function(e){return this.bMarks[e]+this.tShift[e]>=this.eMarks[e]},Q$.prototype.skipEmptyLines=function(e){for(let t=this.lineMax;e<t&&!(this.bMarks[e]+this.tShift[e]<this.eMarks[e]);e++);return e},Q$.prototype.skipSpaces=function(e){for(let t=this.src.length;e<t&&c$(this.src.charCodeAt(e));e++);return e},Q$.prototype.skipSpacesBack=function(e,t){if(e<=t)return e;for(;e>t;)if(!c$(this.src.charCodeAt(--e)))return e+1;return e},Q$.prototype.skipChars=function(e,t){for(let n=this.src.length;e<n&&this.src.charCodeAt(e)===t;e++);return e},Q$.prototype.skipCharsBack=function(e,t,n){if(e<=n)return e;for(;e>n;)if(t!==this.src.charCodeAt(--e))return e+1;return e},Q$.prototype.getLines=function(e,t,n,r){if(e>=t)return``;let i=Array(t-e);for(let a=0,o=e;o<t;o++,a++){let e=0,s=this.bMarks[o],c=s,l;for(l=o+1<t||r?this.eMarks[o]+1:this.eMarks[o];c<l&&e<n;){let t=this.src.charCodeAt(c);if(c$(t))t===9?e+=4-(e+this.bsCount[o])%4:e++;else if(c-s<this.tShift[o])e++;else break;c++}e>n?i[a]=Array(e-n+1).join(` `)+this.src.slice(c,l):i[a]=this.src.slice(c,l)}return i.join(``)},Q$.prototype.Token=w$;var $$=65536;function e1(e,t){let n=e.bMarks[t]+e.tShift[t],r=e.eMarks[t];return e.src.slice(n,r)}function t1(e){let t=[],n=e.length,r=0,i=e.charCodeAt(r),a=!1,o=0,s=``;for(;r<n;)i===124&&(a?(s+=e.substring(o,r-1),o=r):(t.push(s+e.substring(o,r)),s=``,o=r+1)),a=i===92,r++,i=e.charCodeAt(r);return t.push(s+e.substring(o)),t}function n1(e,t,n,r){if(t+2>n)return!1;let i=t+1;if(e.sCount[i]<e.blkIndent||e.sCount[i]-e.blkIndent>=4)return!1;let a=e.bMarks[i]+e.tShift[i];if(a>=e.eMarks[i])return!1;let o=e.src.charCodeAt(a++);if(o!==124&&o!==45&&o!==58||a>=e.eMarks[i])return!1;let s=e.src.charCodeAt(a++);if(s!==124&&s!==45&&s!==58&&!c$(s)||o===45&&c$(s))return!1;for(;a<e.eMarks[i];){let t=e.src.charCodeAt(a);if(t!==124&&t!==45&&t!==58&&!c$(t))return!1;a++}let c=e1(e,t+1),l=c.split(`|`),u=[];for(let e=0;e<l.length;e++){let t=l[e].trim();if(!t){if(e===0||e===l.length-1)continue;return!1}if(!/^:?-+:?$/.test(t))return!1;t.charCodeAt(t.length-1)===58?u.push(t.charCodeAt(0)===58?`center`:`right`):t.charCodeAt(0)===58?u.push(`left`):u.push(``)}if(c=e1(e,t).trim(),c.indexOf(`|`)===-1||e.sCount[t]-e.blkIndent>=4)return!1;l=t1(c),l.length&&l[0]===``&&l.shift(),l.length&&l[l.length-1]===``&&l.pop();let d=l.length;if(d===0||d!==u.length)return!1;if(r)return!0;let f=e.parentType;e.parentType=`table`;let p=e.md.block.ruler.getRules(`blockquote`),m=e.push(`table_open`,`table`,1),h=[t,0];m.map=h;let g=e.push(`thead_open`,`thead`,1);g.map=[t,t+1];let _=e.push(`tr_open`,`tr`,1);_.map=[t,t+1];for(let t=0;t<l.length;t++){let n=e.push(`th_open`,`th`,1);u[t]&&(n.attrs=[[`style`,`text-align:`+u[t]]]);let r=e.push(`inline`,``,0);r.content=l[t].trim(),r.children=[],e.push(`th_close`,`th`,-1)}e.push(`tr_close`,`tr`,-1),e.push(`thead_close`,`thead`,-1);let v,y=0;for(i=t+2;i<n&&!(e.sCount[i]<e.blkIndent);i++){let r=!1;for(let t=0,a=p.length;t<a;t++)if(p[t](e,i,n,!0)){r=!0;break}if(r||(c=e1(e,i).trim(),!c)||e.sCount[i]-e.blkIndent>=4||(l=t1(c),l.length&&l[0]===``&&l.shift(),l.length&&l[l.length-1]===``&&l.pop(),y+=d-l.length,y>$$))break;if(i===t+2){let n=e.push(`tbody_open`,`tbody`,1);n.map=v=[t+2,0]}let a=e.push(`tr_open`,`tr`,1);a.map=[i,i+1];for(let t=0;t<d;t++){let n=e.push(`td_open`,`td`,1);u[t]&&(n.attrs=[[`style`,`text-align:`+u[t]]]);let r=e.push(`inline`,``,0);r.content=l[t]?l[t].trim():``,r.children=[],e.push(`td_close`,`td`,-1)}e.push(`tr_close`,`tr`,-1)}return v&&(e.push(`tbody_close`,`tbody`,-1),v[1]=i),e.push(`table_close`,`table`,-1),h[1]=i,e.parentType=f,e.line=i,!0}function r1(e,t,n){if(e.sCount[t]-e.blkIndent<4)return!1;let r=t+1,i=r;for(;r<n;){if(e.isEmpty(r)){r++;continue}if(e.sCount[r]-e.blkIndent>=4){r++,i=r;continue}break}e.line=i;let a=e.push(`code_block`,`code`,0);return a.content=e.getLines(t,i,4+e.blkIndent,!1)+`
233
+ `,a.map=[t,e.line],!0}function i1(e,t,n,r){let i=e.bMarks[t]+e.tShift[t],a=e.eMarks[t];if(e.sCount[t]-e.blkIndent>=4||i+3>a)return!1;let o=e.src.charCodeAt(i);if(o!==126&&o!==96)return!1;let s=i;i=e.skipChars(i,o);let c=i-s;if(c<3)return!1;let l=e.src.slice(s,i),u=e.src.slice(i,a);if(o===96&&u.indexOf(String.fromCharCode(o))>=0)return!1;if(r)return!0;let d=t,f=!1;for(;d++,!(d>=n||(i=s=e.bMarks[d]+e.tShift[d],a=e.eMarks[d],i<a&&e.sCount[d]<e.blkIndent));)if(e.src.charCodeAt(i)===o&&!(e.sCount[d]-e.blkIndent>=4)&&(i=e.skipChars(i,o),!(i-s<c)&&(i=e.skipSpaces(i),!(i<a)))){f=!0;break}c=e.sCount[t],e.line=d+ +!!f;let p=e.push(`fence`,`code`,0);return p.info=u,p.content=e.getLines(t+1,d,c,!0),p.markup=l,p.map=[t,e.line],!0}function a1(e,t,n,r){let i=e.bMarks[t]+e.tShift[t],a=e.eMarks[t],o=e.lineMax;if(e.sCount[t]-e.blkIndent>=4||e.src.charCodeAt(i)!==62)return!1;if(r)return!0;let s=[],c=[],l=[],u=[],d=e.md.block.ruler.getRules(`blockquote`),f=e.parentType;e.parentType=`blockquote`;let p=!1,m;for(m=t;m<n;m++){let t=e.sCount[m]<e.blkIndent;if(i=e.bMarks[m]+e.tShift[m],a=e.eMarks[m],i>=a)break;if(e.src.charCodeAt(i++)===62&&!t){let t=e.sCount[m]+1,n,r;e.src.charCodeAt(i)===32?(i++,t++,r=!1,n=!0):e.src.charCodeAt(i)===9?(n=!0,(e.bsCount[m]+t)%4==3?(i++,t++,r=!1):r=!0):n=!1;let o=t;for(s.push(e.bMarks[m]),e.bMarks[m]=i;i<a;){let t=e.src.charCodeAt(i);if(c$(t))t===9?o+=4-(o+e.bsCount[m]+ +!!r)%4:o++;else break;i++}p=i>=a,c.push(e.bsCount[m]),e.bsCount[m]=e.sCount[m]+1+ +!!n,l.push(e.sCount[m]),e.sCount[m]=o-t,u.push(e.tShift[m]),e.tShift[m]=i-e.bMarks[m];continue}if(p)break;let r=!1;for(let t=0,i=d.length;t<i;t++)if(d[t](e,m,n,!0)){r=!0;break}if(r){e.lineMax=m,e.blkIndent!==0&&(s.push(e.bMarks[m]),c.push(e.bsCount[m]),u.push(e.tShift[m]),l.push(e.sCount[m]),e.sCount[m]-=e.blkIndent);break}s.push(e.bMarks[m]),c.push(e.bsCount[m]),u.push(e.tShift[m]),l.push(e.sCount[m]),e.sCount[m]=-1}let h=e.blkIndent;e.blkIndent=0;let g=e.push(`blockquote_open`,`blockquote`,1);g.markup=`>`;let _=[t,0];g.map=_,e.md.block.tokenize(e,t,m);let v=e.push(`blockquote_close`,`blockquote`,-1);v.markup=`>`,e.lineMax=o,e.parentType=f,_[1]=e.line;for(let n=0;n<u.length;n++)e.bMarks[n+t]=s[n],e.tShift[n+t]=u[n],e.sCount[n+t]=l[n],e.bsCount[n+t]=c[n];return e.blkIndent=h,!0}function o1(e,t,n,r){let i=e.eMarks[t];if(e.sCount[t]-e.blkIndent>=4)return!1;let a=e.bMarks[t]+e.tShift[t],o=e.src.charCodeAt(a++);if(o!==42&&o!==45&&o!==95)return!1;let s=1;for(;a<i;){let t=e.src.charCodeAt(a++);if(t!==o&&!c$(t))return!1;t===o&&s++}if(s<3)return!1;if(r)return!0;e.line=t+1;let c=e.push(`hr`,`hr`,0);return c.map=[t,e.line],c.markup=Array(s+1).join(String.fromCharCode(o)),!0}function s1(e,t){let n=e.eMarks[t],r=e.bMarks[t]+e.tShift[t],i=e.src.charCodeAt(r++);return i!==42&&i!==45&&i!==43||r<n&&!c$(e.src.charCodeAt(r))?-1:r}function c1(e,t){let n=e.bMarks[t]+e.tShift[t],r=e.eMarks[t],i=n;if(i+1>=r)return-1;let a=e.src.charCodeAt(i++);if(a<48||a>57)return-1;for(;;){if(i>=r)return-1;if(a=e.src.charCodeAt(i++),a>=48&&a<=57){if(i-n>=10)return-1;continue}if(a===41||a===46)break;return-1}return i<r&&(a=e.src.charCodeAt(i),!c$(a))?-1:i}function l1(e,t){let n=e.level+2;for(let r=t+2,i=e.tokens.length-2;r<i;r++)e.tokens[r].level===n&&e.tokens[r].type===`paragraph_open`&&(e.tokens[r+2].hidden=!0,e.tokens[r].hidden=!0,r+=2)}function u1(e,t,n,r){let i,a,o,s,c=t,l=!0;if(e.sCount[c]-e.blkIndent>=4||e.listIndent>=0&&e.sCount[c]-e.listIndent>=4&&e.sCount[c]<e.blkIndent)return!1;let u=!1;r&&e.parentType===`paragraph`&&e.sCount[c]>=e.blkIndent&&(u=!0);let d,f,p;if((p=c1(e,c))>=0){if(d=!0,o=e.bMarks[c]+e.tShift[c],f=Number(e.src.slice(o,p-1)),u&&f!==1)return!1}else if((p=s1(e,c))>=0)d=!1;else return!1;if(u&&e.skipSpaces(p)>=e.eMarks[c])return!1;if(r)return!0;let m=e.src.charCodeAt(p-1),h=e.tokens.length;d?(s=e.push(`ordered_list_open`,`ol`,1),f!==1&&(s.attrs=[[`start`,f]])):s=e.push(`bullet_list_open`,`ul`,1);let g=[c,0];s.map=g,s.markup=String.fromCharCode(m);let _=!1,v=e.md.block.ruler.getRules(`list`),y=e.parentType;for(e.parentType=`list`;c<n;){a=p,i=e.eMarks[c];let t=e.sCount[c]+p-(e.bMarks[c]+e.tShift[c]),r=t;for(;a<i;){let t=e.src.charCodeAt(a);if(t===9)r+=4-(r+e.bsCount[c])%4;else if(t===32)r++;else break;a++}let u=a,f;f=u>=i?1:r-t,f>4&&(f=1);let h=t+f;s=e.push(`list_item_open`,`li`,1),s.markup=String.fromCharCode(m);let g=[c,0];s.map=g,d&&(s.info=e.src.slice(o,p-1));let y=e.tight,b=e.tShift[c],x=e.sCount[c],S=e.listIndent;if(e.listIndent=e.blkIndent,e.blkIndent=h,e.tight=!0,e.tShift[c]=u-e.bMarks[c],e.sCount[c]=r,u>=i&&e.isEmpty(c+1)?e.line=Math.min(e.line+2,n):e.md.block.tokenize(e,c,n,!0),(!e.tight||_)&&(l=!1),_=e.line-c>1&&e.isEmpty(e.line-1),e.blkIndent=e.listIndent,e.listIndent=S,e.tShift[c]=b,e.sCount[c]=x,e.tight=y,s=e.push(`list_item_close`,`li`,-1),s.markup=String.fromCharCode(m),c=e.line,g[1]=c,c>=n||e.sCount[c]<e.blkIndent||e.sCount[c]-e.blkIndent>=4)break;let C=!1;for(let t=0,r=v.length;t<r;t++)if(v[t](e,c,n,!0)){C=!0;break}if(C)break;if(d){if(p=c1(e,c),p<0)break;o=e.bMarks[c]+e.tShift[c]}else if(p=s1(e,c),p<0)break;if(m!==e.src.charCodeAt(p-1))break}return s=d?e.push(`ordered_list_close`,`ol`,-1):e.push(`bullet_list_close`,`ul`,-1),s.markup=String.fromCharCode(m),g[1]=c,e.line=c,e.parentType=y,l&&l1(e,h),!0}function d1(e,t,n,r){let i=e.bMarks[t]+e.tShift[t],a=e.eMarks[t],o=t+1;if(e.sCount[t]-e.blkIndent>=4||e.src.charCodeAt(i)!==91)return!1;function s(t){let n=e.lineMax;if(t>=n||e.isEmpty(t))return null;let r=!1;if(e.sCount[t]-e.blkIndent>3&&(r=!0),e.sCount[t]<0&&(r=!0),!r){let r=e.md.block.ruler.getRules(`reference`),i=e.parentType;e.parentType=`reference`;let a=!1;for(let i=0,o=r.length;i<o;i++)if(r[i](e,t,n,!0)){a=!0;break}if(e.parentType=i,a)return null}let i=e.bMarks[t]+e.tShift[t],a=e.eMarks[t];return e.src.slice(i,a+1)}let c=e.src.slice(i,a+1);a=c.length;let l=-1;for(i=1;i<a;i++){let e=c.charCodeAt(i);if(e===91)return!1;if(e===93){l=i;break}else if(e===10){let e=s(o);e!==null&&(c+=e,a=c.length,o++)}else if(e===92&&(i++,i<a&&c.charCodeAt(i)===10)){let e=s(o);e!==null&&(c+=e,a=c.length,o++)}}if(l<0||c.charCodeAt(l+1)!==58)return!1;for(i=l+2;i<a;i++){let e=c.charCodeAt(i);if(e===10){let e=s(o);e!==null&&(c+=e,a=c.length,o++)}else if(!c$(e))break}let u=e.md.helpers.parseLinkDestination(c,i,a);if(!u.ok)return!1;let d=e.md.normalizeLink(u.str);if(!e.md.validateLink(d))return!1;i=u.pos;let f=i,p=o,m=i;for(;i<a;i++){let e=c.charCodeAt(i);if(e===10){let e=s(o);e!==null&&(c+=e,a=c.length,o++)}else if(!c$(e))break}let h=e.md.helpers.parseLinkTitle(c,i,a);for(;h.can_continue;){let t=s(o);if(t===null)break;c+=t,i=a,a=c.length,o++,h=e.md.helpers.parseLinkTitle(c,i,a,h)}let g;for(i<a&&m!==i&&h.ok?(g=h.str,i=h.pos):(g=``,i=f,o=p);i<a&&c$(c.charCodeAt(i));)i++;if(i<a&&c.charCodeAt(i)!==10&&g)for(g=``,i=f,o=p;i<a&&c$(c.charCodeAt(i));)i++;if(i<a&&c.charCodeAt(i)!==10)return!1;let _=p$(c.slice(1,l));return _?r?!0:(e.env.references===void 0&&(e.env.references={}),e.env.references[_]===void 0&&(e.env.references[_]={title:g,href:d}),e.line=o,!0):!1}var f1=`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`.split(`.`),p1=RegExp(`^(?:<[A-Za-z][A-Za-z0-9\\-]*(?:\\s+[a-zA-Z_:][a-zA-Z0-9:._-]*(?:\\s*=\\s*(?:[^"'=<>\`\\x00-\\x20]+|'[^']*'|"[^"]*"))?)*\\s*\\/?>|<\\/[A-Za-z][A-Za-z0-9\\-]*\\s*>|<!---?>|<!--(?:[^-]|-[^-]|--[^>])*-->|<[?][\\s\\S]*?[?]>|<![A-Za-z][^>]*>|<!\\[CDATA\\[[\\s\\S]*?\\]\\]>)`),m1=RegExp(`^(?:<[A-Za-z][A-Za-z0-9\\-]*(?:\\s+[a-zA-Z_:][a-zA-Z0-9:._-]*(?:\\s*=\\s*(?:[^"'=<>\`\\x00-\\x20]+|'[^']*'|"[^"]*"))?)*\\s*\\/?>|<\\/[A-Za-z][A-Za-z0-9\\-]*\\s*>)`),h1=[[/^<(script|pre|style|textarea)(?=(\s|>|$))/i,/<\/(script|pre|style|textarea)>/i,!0],[/^<!--/,/-->/,!0],[/^<\?/,/\?>/,!0],[/^<![A-Z]/,/>/,!0],[/^<!\[CDATA\[/,/\]\]>/,!0],[RegExp(`^</?(`+f1.join(`|`)+`)(?=(\\s|/?>|$))`,`i`),/^$/,!0],[RegExp(m1.source+`\\s*$`),/^$/,!1]];function g1(e,t,n,r){let i=e.bMarks[t]+e.tShift[t],a=e.eMarks[t];if(e.sCount[t]-e.blkIndent>=4||!e.md.options.html||e.src.charCodeAt(i)!==60)return!1;let o=e.src.slice(i,a),s=0;for(;s<h1.length&&!h1[s][0].test(o);s++);if(s===h1.length)return!1;if(r)return h1[s][2];let c=t+1,l=h1[s][1].test(``);if(!h1[s][1].test(o)){for(;c<n&&!(e.sCount[c]<e.blkIndent&&(l||!e.isEmpty(c)));c++)if(i=e.bMarks[c]+e.tShift[c],a=e.eMarks[c],o=e.src.slice(i,a),h1[s][1].test(o)){o.length!==0&&c++;break}}e.line=c;let u=e.push(`html_block`,``,0);return u.map=[t,c],u.content=e.getLines(t,c,e.blkIndent,!0),!0}function _1(e,t,n,r){let i=e.bMarks[t]+e.tShift[t],a=e.eMarks[t];if(e.sCount[t]-e.blkIndent>=4)return!1;let o=e.src.charCodeAt(i);if(o!==35||i>=a)return!1;let s=1;for(o=e.src.charCodeAt(++i);o===35&&i<a&&s<=6;)s++,o=e.src.charCodeAt(++i);if(s>6||i<a&&!c$(o))return!1;if(r)return!0;a=e.skipSpacesBack(a,i);let c=e.skipCharsBack(a,35,i);c>i&&c$(e.src.charCodeAt(c-1))&&(a=c),e.line=t+1;let l=e.push(`heading_open`,`h`+String(s),1);l.markup=`########`.slice(0,s),l.map=[t,e.line];let u=e.push(`inline`,``,0);u.content=h$(e.src.slice(i,a)),u.map=[t,e.line],u.children=[];let d=e.push(`heading_close`,`h`+String(s),-1);return d.markup=`########`.slice(0,s),!0}function v1(e,t,n){let r=e.md.block.ruler.getRules(`paragraph`);if(e.sCount[t]-e.blkIndent>=4)return!1;let i=e.parentType;e.parentType=`paragraph`;let a=0,o,s=t+1;for(;s<n&&!e.isEmpty(s);s++){if(e.sCount[s]-e.blkIndent>3)continue;if(e.sCount[s]>=e.blkIndent){let t=e.bMarks[s]+e.tShift[s],n=e.eMarks[s];if(t<n&&(o=e.src.charCodeAt(t),(o===45||o===61)&&(t=e.skipChars(t,o),t=e.skipSpaces(t),t>=n))){a=o===61?1:2;break}}if(e.sCount[s]<0)continue;let t=!1;for(let i=0,a=r.length;i<a;i++)if(r[i](e,s,n,!0)){t=!0;break}if(t)break}if(!a)return e.parentType=i,!1;let c=h$(e.getLines(t,s,e.blkIndent,!1));e.line=s+1;let l=e.push(`heading_open`,`h`+String(a),1);l.markup=String.fromCharCode(o),l.map=[t,e.line];let u=e.push(`inline`,``,0);u.content=c,u.map=[t,e.line-1],u.children=[];let d=e.push(`heading_close`,`h`+String(a),-1);return d.markup=String.fromCharCode(o),e.parentType=i,!0}function y1(e,t,n){let r=e.md.block.ruler.getRules(`paragraph`),i=e.parentType,a=t+1;for(e.parentType=`paragraph`;a<n&&!e.isEmpty(a);a++){if(e.sCount[a]-e.blkIndent>3||e.sCount[a]<0)continue;let t=!1;for(let i=0,o=r.length;i<o;i++)if(r[i](e,a,n,!0)){t=!0;break}if(t)break}let o=h$(e.getLines(t,a,e.blkIndent,!1));e.line=a;let s=e.push(`paragraph_open`,`p`,1);s.map=[t,e.line];let c=e.push(`inline`,``,0);return c.content=o,c.map=[t,e.line],c.children=[],e.push(`paragraph_close`,`p`,-1),e.parentType=i,!0}var b1=[[`table`,n1,[`paragraph`,`reference`]],[`code`,r1],[`fence`,i1,[`paragraph`,`reference`,`blockquote`,`list`]],[`blockquote`,a1,[`paragraph`,`reference`,`blockquote`,`list`]],[`hr`,o1,[`paragraph`,`reference`,`blockquote`,`list`]],[`list`,u1,[`paragraph`,`reference`,`blockquote`]],[`reference`,d1],[`html_block`,g1,[`paragraph`,`reference`,`blockquote`]],[`heading`,_1,[`paragraph`,`reference`,`blockquote`]],[`lheading`,v1],[`paragraph`,y1]];function x1(){this.ruler=new C$;for(let e=0;e<b1.length;e++)this.ruler.push(b1[e][0],b1[e][1],{alt:(b1[e][2]||[]).slice()})}x1.prototype.tokenize=function(e,t,n){let r=this.ruler.getRules(``),i=r.length,a=e.md.options.maxNesting,o=t,s=!1;for(;o<n&&(e.line=o=e.skipEmptyLines(o),!(o>=n||e.sCount[o]<e.blkIndent));){if(e.level>=a){e.line=n;break}let t=e.line,c=!1;for(let a=0;a<i;a++)if(c=r[a](e,o,n,!1),c){if(t>=e.line)throw Error(`block rule didn't increment state.line`);break}if(!c)throw Error(`none of the block rules matched`);e.tight=!s,e.isEmpty(e.line-1)&&(s=!0),o=e.line,o<n&&e.isEmpty(o)&&(s=!0,o++,e.line=o)}},x1.prototype.parse=function(e,t,n,r){if(!e)return;let i=new this.State(e,t,n,r);this.tokenize(i,i.line,i.lineMax)},x1.prototype.State=Q$;function S1(e,t,n,r){this.src=e,this.env=n,this.md=t,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}S1.prototype.pushPending=function(){let e=new w$(`text`,``,0);return e.content=this.pending,e.level=this.pendingLevel,this.tokens.push(e),this.pending=``,e},S1.prototype.push=function(e,t,n){this.pending&&this.pushPending();let r=new w$(e,t,n),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},S1.prototype.scanDelims=function(e,t){let n=this.posMax,r=this.src.charCodeAt(e),i;if(e===0)i=32;else if(e===1)i=this.src.charCodeAt(0),(i&63488)==55296&&(i=65533);else if(i=this.src.charCodeAt(e-1),(i&64512)==56320){let t=this.src.charCodeAt(e-2);i=(t&64512)==55296?65536+(t-55296<<10)+(i-56320):65533}else (i&64512)==55296&&(i=65533);let a=e;for(;a<n&&this.src.charCodeAt(a)===r;)a++;let o=a-e,s=a<n?this.src.charCodeAt(a):32;if((s&64512)==55296){let e=this.src.charCodeAt(a+1);s=(e&64512)==56320?65536+(s-55296<<10)+(e-56320):65533}else (s&64512)==56320&&(s=65533);let c=f$(i)||d$(i),l=f$(s)||d$(s),u=l$(i),d=l$(s),f=!d&&(!l||u||c),p=!u&&(!c||d||l);return{can_open:f&&(t||!p||c),can_close:p&&(t||!f||l),length:o}},S1.prototype.Token=w$;function C1(e){switch(e){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 w1(e,t){let n=e.pos;for(;n<e.posMax&&!C1(e.src.charCodeAt(n));)n++;return n===e.pos?!1:(t||(e.pending+=e.src.slice(e.pos,n)),e.pos=n,!0)}var T1=/(?:^|[^a-z0-9.+-])([a-z][a-z0-9.+-]*)$/i;function E1(e,t){if(!e.md.options.linkify||e.linkLevel>0)return!1;let n=e.pos,r=e.posMax;if(n+3>r||e.src.charCodeAt(n)!==58||e.src.charCodeAt(n+1)!==47||e.src.charCodeAt(n+2)!==47)return!1;let i=e.pending.match(T1);if(!i)return!1;let a=i[1],o=e.md.linkify.matchAtStart(e.src.slice(n-a.length));if(!o)return!1;let s=o.url;if(s.length<=a.length)return!1;let c=s.length;for(;c>0&&s.charCodeAt(c-1)===42;)c--;c!==s.length&&(s=s.slice(0,c));let l=e.md.normalizeLink(s);if(!e.md.validateLink(l))return!1;if(!t){e.pending=e.pending.slice(0,-a.length);let t=e.push(`link_open`,`a`,1);t.attrs=[[`href`,l]],t.markup=`linkify`,t.info=`auto`;let n=e.push(`text`,``,0);n.content=e.md.normalizeLinkText(s);let r=e.push(`link_close`,`a`,-1);r.markup=`linkify`,r.info=`auto`}return e.pos+=s.length-a.length,!0}function D1(e,t){let n=e.pos;if(e.src.charCodeAt(n)!==10)return!1;let r=e.pending.length-1,i=e.posMax;if(!t)if(r>=0&&e.pending.charCodeAt(r)===32)if(r>=1&&e.pending.charCodeAt(r-1)===32){let t=r-1;for(;t>=1&&e.pending.charCodeAt(t-1)===32;)t--;e.pending=e.pending.slice(0,t),e.push(`hardbreak`,`br`,0)}else e.pending=e.pending.slice(0,-1),e.push(`softbreak`,`br`,0);else e.push(`softbreak`,`br`,0);for(n++;n<i&&c$(e.src.charCodeAt(n));)n++;return e.pos=n,!0}var O1=[];for(let e=0;e<256;e++)O1.push(0);`\\!"#$%&'()*+,./:;<=>?@[]^_\`{|}~-`.split(``).forEach(function(e){O1[e.charCodeAt(0)]=1});function k1(e,t){let n=e.pos,r=e.posMax;if(e.src.charCodeAt(n)!==92||(n++,n>=r))return!1;let i=e.src.charCodeAt(n);if(i===10){for(t||e.push(`hardbreak`,`br`,0),n++;n<r&&(i=e.src.charCodeAt(n),c$(i));)n++;return e.pos=n,!0}let a=e.src[n];if(i>=55296&&i<=56319&&n+1<r){let t=e.src.charCodeAt(n+1);t>=56320&&t<=57343&&(a+=e.src[n+1],n++)}let o=`\\`+a;if(!t){let t=e.push(`text_special`,``,0);i<256&&O1[i]!==0?t.content=a:t.content=o,t.markup=o,t.info=`escape`}return e.pos=n+1,!0}function A1(e,t){let n=e.pos;if(e.src.charCodeAt(n)!==96)return!1;let r=n;n++;let i=e.posMax;for(;n<i&&e.src.charCodeAt(n)===96;)n++;let a=e.src.slice(r,n),o=a.length;if(e.backticksScanned&&(e.backticks[o]||0)<=r)return t||(e.pending+=a),e.pos+=o,!0;let s=n,c;for(;(c=e.src.indexOf("`",s))!==-1;){for(s=c+1;s<i&&e.src.charCodeAt(s)===96;)s++;let r=s-c;if(r===o){if(!t){let t=e.push(`code_inline`,`code`,0);t.markup=a,t.content=e.src.slice(n,c).replace(/\n/g,` `).replace(/^ (.+) $/,`$1`)}return e.pos=s,!0}e.backticks[r]=c}return e.backticksScanned=!0,t||(e.pending+=a),e.pos+=o,!0}function j1(e,t){let n=e.pos,r=e.src.charCodeAt(n);if(t||r!==126)return!1;let i=e.scanDelims(e.pos,!0),a=i.length,o=String.fromCharCode(r);if(a<2)return!1;let s;a%2&&(s=e.push(`text`,``,0),s.content=o,a--);for(let t=0;t<a;t+=2)s=e.push(`text`,``,0),s.content=o+o,e.delimiters.push({marker:r,length:0,token:e.tokens.length-1,end:-1,open:i.can_open,close:i.can_close});return e.pos+=i.length,!0}function M1(e,t){let n,r=[],i=t.length;for(let a=0;a<i;a++){let i=t[a];if(i.marker!==126||i.end===-1)continue;let o=t[i.end];n=e.tokens[i.token],n.type=`s_open`,n.tag=`s`,n.nesting=1,n.markup=`~~`,n.content=``,n=e.tokens[o.token],n.type=`s_close`,n.tag=`s`,n.nesting=-1,n.markup=`~~`,n.content=``,e.tokens[o.token-1].type===`text`&&e.tokens[o.token-1].content===`~`&&r.push(o.token-1)}for(;r.length;){let t=r.pop(),i=t+1;for(;i<e.tokens.length&&e.tokens[i].type===`s_close`;)i++;i--,t!==i&&(n=e.tokens[i],e.tokens[i]=e.tokens[t],e.tokens[t]=n)}}function N1(e){let t=e.tokens_meta,n=e.tokens_meta.length;M1(e,e.delimiters);for(let r=0;r<n;r++)t[r]&&t[r].delimiters&&M1(e,t[r].delimiters)}var P1={tokenize:j1,postProcess:N1};function F1(e,t){let n=e.pos,r=e.src.charCodeAt(n);if(t||r!==95&&r!==42)return!1;let i=e.scanDelims(e.pos,r===42);for(let t=0;t<i.length;t++){let t=e.push(`text`,``,0);t.content=String.fromCharCode(r),e.delimiters.push({marker:r,length:i.length,token:e.tokens.length-1,end:-1,open:i.can_open,close:i.can_close})}return e.pos+=i.length,!0}function I1(e,t){let n=t.length;for(let r=n-1;r>=0;r--){let n=t[r];if(n.marker!==95&&n.marker!==42||n.end===-1)continue;let i=t[n.end],a=r>0&&t[r-1].end===n.end+1&&t[r-1].marker===n.marker&&t[r-1].token===n.token-1&&t[n.end+1].token===i.token+1,o=String.fromCharCode(n.marker),s=e.tokens[n.token];s.type=a?`strong_open`:`em_open`,s.tag=a?`strong`:`em`,s.nesting=1,s.markup=a?o+o:o,s.content=``;let c=e.tokens[i.token];c.type=a?`strong_close`:`em_close`,c.tag=a?`strong`:`em`,c.nesting=-1,c.markup=a?o+o:o,c.content=``,a&&(e.tokens[t[r-1].token].content=``,e.tokens[t[n.end+1].token].content=``,r--)}}function L1(e){let t=e.tokens_meta,n=e.tokens_meta.length;I1(e,e.delimiters);for(let r=0;r<n;r++)t[r]&&t[r].delimiters&&I1(e,t[r].delimiters)}var R1={tokenize:F1,postProcess:L1};function z1(e,t){let n,r,i,a,o=``,s=``,c=e.pos,l=!0;if(e.src.charCodeAt(e.pos)!==91)return!1;let u=e.pos,d=e.posMax,f=e.pos+1,p=e.md.helpers.parseLinkLabel(e,e.pos,!0);if(p<0)return!1;let m=p+1;if(m<d&&e.src.charCodeAt(m)===40){for(l=!1,m++;m<d&&(n=e.src.charCodeAt(m),!(!c$(n)&&n!==10));m++);if(m>=d)return!1;if(c=m,i=e.md.helpers.parseLinkDestination(e.src,m,e.posMax),i.ok){for(o=e.md.normalizeLink(i.str),e.md.validateLink(o)?m=i.pos:o=``,c=m;m<d&&(n=e.src.charCodeAt(m),!(!c$(n)&&n!==10));m++);if(i=e.md.helpers.parseLinkTitle(e.src,m,e.posMax),m<d&&c!==m&&i.ok)for(s=i.str,m=i.pos;m<d&&(n=e.src.charCodeAt(m),!(!c$(n)&&n!==10));m++);}(m>=d||e.src.charCodeAt(m)!==41)&&(l=!0),m++}if(l){if(e.env.references===void 0)return!1;if(m<d&&e.src.charCodeAt(m)===91?(c=m+1,m=e.md.helpers.parseLinkLabel(e,m),m>=0?r=e.src.slice(c,m++):m=p+1):m=p+1,r||=e.src.slice(f,p),a=e.env.references[p$(r)],!a)return e.pos=u,!1;o=a.href,s=a.title}if(!t){e.pos=f,e.posMax=p;let t=e.push(`link_open`,`a`,1),n=[[`href`,o]];t.attrs=n,s&&n.push([`title`,s]),e.linkLevel++,e.md.inline.tokenize(e),e.linkLevel--,e.push(`link_close`,`a`,-1)}return e.pos=m,e.posMax=d,!0}function B1(e,t){let n,r,i,a,o,s,c,l,u=``,d=e.pos,f=e.posMax;if(e.src.charCodeAt(e.pos)!==33||e.src.charCodeAt(e.pos+1)!==91)return!1;let p=e.pos+2,m=e.md.helpers.parseLinkLabel(e,e.pos+1,!1);if(m<0)return!1;if(a=m+1,a<f&&e.src.charCodeAt(a)===40){for(a++;a<f&&(n=e.src.charCodeAt(a),!(!c$(n)&&n!==10));a++);if(a>=f)return!1;for(l=a,s=e.md.helpers.parseLinkDestination(e.src,a,e.posMax),s.ok&&(u=e.md.normalizeLink(s.str),e.md.validateLink(u)?a=s.pos:u=``),l=a;a<f&&(n=e.src.charCodeAt(a),!(!c$(n)&&n!==10));a++);if(s=e.md.helpers.parseLinkTitle(e.src,a,e.posMax),a<f&&l!==a&&s.ok)for(c=s.str,a=s.pos;a<f&&(n=e.src.charCodeAt(a),!(!c$(n)&&n!==10));a++);else c=``;if(a>=f||e.src.charCodeAt(a)!==41)return e.pos=d,!1;a++}else{if(e.env.references===void 0)return!1;if(a<f&&e.src.charCodeAt(a)===91?(l=a+1,a=e.md.helpers.parseLinkLabel(e,a),a>=0?i=e.src.slice(l,a++):a=m+1):a=m+1,i||=e.src.slice(p,m),o=e.env.references[p$(i)],!o)return e.pos=d,!1;u=o.href,c=o.title}if(!t){r=e.src.slice(p,m);let t=[];e.md.inline.parse(r,e.md,e.env,t);let n=e.push(`image`,`img`,0),i=[[`src`,u],[`alt`,``]];n.attrs=i,n.children=t,n.content=r,c&&i.push([`title`,c])}return e.pos=a,e.posMax=f,!0}var V1=/^([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])?)*)$/,H1=/^([a-zA-Z][a-zA-Z0-9+.-]{1,31}):([^<>\x00-\x20]*)$/;function U1(e,t){let n=e.pos;if(e.src.charCodeAt(n)!==60)return!1;let r=e.pos,i=e.posMax;for(;;){if(++n>=i)return!1;let t=e.src.charCodeAt(n);if(t===60)return!1;if(t===62)break}let a=e.src.slice(r+1,n);if(H1.test(a)){let n=e.md.normalizeLink(a);if(!e.md.validateLink(n))return!1;if(!t){let t=e.push(`link_open`,`a`,1);t.attrs=[[`href`,n]],t.markup=`autolink`,t.info=`auto`;let r=e.push(`text`,``,0);r.content=e.md.normalizeLinkText(a);let i=e.push(`link_close`,`a`,-1);i.markup=`autolink`,i.info=`auto`}return e.pos+=a.length+2,!0}if(V1.test(a)){let n=e.md.normalizeLink(`mailto:`+a);if(!e.md.validateLink(n))return!1;if(!t){let t=e.push(`link_open`,`a`,1);t.attrs=[[`href`,n]],t.markup=`autolink`,t.info=`auto`;let r=e.push(`text`,``,0);r.content=e.md.normalizeLinkText(a);let i=e.push(`link_close`,`a`,-1);i.markup=`autolink`,i.info=`auto`}return e.pos+=a.length+2,!0}return!1}function W1(e){return/^<a[>\s]/i.test(e)}function G1(e){return/^<\/a\s*>/i.test(e)}function K1(e){let t=e|32;return t>=97&&t<=122}function q1(e,t){if(!e.md.options.html)return!1;let n=e.posMax,r=e.pos;if(e.src.charCodeAt(r)!==60||r+2>=n)return!1;let i=e.src.charCodeAt(r+1);if(i!==33&&i!==63&&i!==47&&!K1(i))return!1;let a=e.src.slice(r).match(p1);if(!a)return!1;if(!t){let t=e.push(`html_inline`,``,0);t.content=a[0],W1(t.content)&&e.linkLevel++,G1(t.content)&&e.linkLevel--}return e.pos+=a[0].length,!0}var J1=/^&#((?:x[a-f0-9]{1,6}|[0-9]{1,7}));/i,Y1=/^&([a-z][a-z0-9]{1,31});/i;function X1(e,t){let n=e.pos,r=e.posMax;if(e.src.charCodeAt(n)!==38||n+1>=r)return!1;if(e.src.charCodeAt(n+1)===35){let r=e.src.slice(n).match(J1);if(r){if(!t){let t=r[1][0].toLowerCase()===`x`?parseInt(r[1].slice(1),16):parseInt(r[1],10),n=e.push(`text_special`,``,0);n.content=qQ(t)?JQ(t):JQ(65533),n.markup=r[0],n.info=`entity`}return e.pos+=r[0].length,!0}}else{let r=e.src.slice(n).match(Y1);if(r){let n=zQ(r[0]);if(n!==r[0]){if(!t){let t=e.push(`text_special`,``,0);t.content=n,t.markup=r[0],t.info=`entity`}return e.pos+=r[0].length,!0}}}return!1}function Z1(e){let t={},n=e.length;if(!n)return;let r=0,i=-2,a=[];for(let o=0;o<n;o++){let n=e[o];if(a.push(0),(e[r].marker!==n.marker||i!==n.token-1)&&(r=o),i=n.token,n.length=n.length||0,!n.close)continue;t.hasOwnProperty(n.marker)||(t[n.marker]=[-1,-1,-1,-1,-1,-1]);let s=t[n.marker][(n.open?3:0)+n.length%3],c=r-a[r]-1,l=c;for(;c>s;c-=a[c]+1){let t=e[c];if(t.marker===n.marker&&t.open&&t.end<0){let r=!1;if((t.close||n.open)&&(t.length+n.length)%3==0&&(t.length%3!=0||n.length%3!=0)&&(r=!0),!r){let r=c>0&&!e[c-1].open?a[c-1]+1:0;a[o]=o-c+r,a[c]=r,n.open=!1,t.end=o,t.close=!1,l=-1,i=-2;break}}}l!==-1&&(t[n.marker][(n.open?3:0)+(n.length||0)%3]=l)}}function Q1(e){let t=e.tokens_meta,n=e.tokens_meta.length;Z1(e.delimiters);for(let e=0;e<n;e++)t[e]&&t[e].delimiters&&Z1(t[e].delimiters)}function $1(e){let t,n,r=0,i=e.tokens,a=e.tokens.length;for(t=n=0;t<a;t++)i[t].nesting<0&&r--,i[t].level=r,i[t].nesting>0&&r++,i[t].type===`text`&&t+1<a&&i[t+1].type===`text`?i[t+1].content=i[t].content+i[t+1].content:(t!==n&&(i[n]=i[t]),n++);t!==n&&(i.length=n)}var e0=[[`text`,w1],[`linkify`,E1],[`newline`,D1],[`escape`,k1],[`backticks`,A1],[`strikethrough`,P1.tokenize],[`emphasis`,R1.tokenize],[`link`,z1],[`image`,B1],[`autolink`,U1],[`html_inline`,q1],[`entity`,X1]],t0=[[`balance_pairs`,Q1],[`strikethrough`,P1.postProcess],[`emphasis`,R1.postProcess],[`fragments_join`,$1]];function n0(){this.ruler=new C$;for(let e=0;e<e0.length;e++)this.ruler.push(e0[e][0],e0[e][1]);this.ruler2=new C$;for(let e=0;e<t0.length;e++)this.ruler2.push(t0[e][0],t0[e][1])}n0.prototype.skipToken=function(e){let t=e.pos,n=this.ruler.getRules(``),r=n.length,i=e.md.options.maxNesting,a=e.cache;if(a[t]!==void 0){e.pos=a[t];return}let o=!1;if(e.level<i){for(let i=0;i<r;i++)if(e.level++,o=n[i](e,!0),e.level--,o){if(t>=e.pos)throw Error(`inline rule didn't increment state.pos`);break}}else e.pos=e.posMax;o||e.pos++,a[t]=e.pos},n0.prototype.tokenize=function(e){let t=this.ruler.getRules(``),n=t.length,r=e.posMax,i=e.md.options.maxNesting;for(;e.pos<r;){let a=e.pos,o=!1;if(e.level<i){for(let r=0;r<n;r++)if(o=t[r](e,!1),o){if(a>=e.pos)throw Error(`inline rule didn't increment state.pos`);break}}if(o){if(e.pos>=r)break;continue}e.pending+=e.src[e.pos++]}e.pending&&e.pushPending()},n0.prototype.parse=function(e,t,n,r){let i=new this.State(e,t,n,r);this.tokenize(i);let a=this.ruler2.getRules(``),o=a.length;for(let e=0;e<o;e++)a[e](i)},n0.prototype.State=S1;function r0(e){let t={};return e||={},t.src_Any=pQ.source,t.src_Cc=mQ.source,t.src_Z=vQ.source,t.src_P=gQ.source,t.src_ZPCc=[t.src_Z,t.src_P,t.src_Cc].join(`|`),t.src_ZCc=[t.src_Z,t.src_Cc].join(`|`),t.src_pseudo_letter=`(?:(?![><|]|`+t.src_ZPCc+`)`+t.src_Any+`)`,t.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]?)`,t.src_auth=`(?:(?:(?!`+t.src_ZCc+`|[@/\\[\\]()]).)+@)?`,t.src_port=`(?::(?:6(?:[0-4]\\d{3}|5(?:[0-4]\\d{2}|5(?:[0-2]\\d|3[0-5])))|[1-5]?\\d{1,4}))?`,t.src_host_terminator=`(?=$|[><|]|`+t.src_ZPCc+`)(?!`+(e[`---`]?`-(?!--)|`:`-|`)+`_|:\\d|\\.-|\\.(?!$|`+t.src_ZPCc+`))`,t.src_path=`(?:[/?#](?:(?!`+t.src_ZCc+`|[><|]|[()[\\]{}.,"'?!\\-;]).|\\[(?:(?!`+t.src_ZCc+`|\\]).)*\\]|\\((?:(?!`+t.src_ZCc+`|[)]).)*\\)|\\{(?:(?!`+t.src_ZCc+`|[}]).)*\\}|\\"(?:(?!`+t.src_ZCc+`|["]).)+\\"|\\'(?:(?!`+t.src_ZCc+`|[']).)+\\'|\\'(?=`+t.src_pseudo_letter+`|[-])|\\.{2,}[a-zA-Z0-9%/&]|\\.(?!`+t.src_ZCc+`|[.]|$)|`+(e[`---`]?`\\-(?!--(?:[^-]|$))(?:-*)|`:`\\-+|`)+`,(?!`+t.src_ZCc+`|$)|;(?!`+t.src_ZCc+`|$)|\\!+(?!`+t.src_ZCc+`|[!]|$)|\\?(?!`+t.src_ZCc+`|[?]|$))+|\\/)?`,t.src_email_name=`[\\-;:&=\\+\\$,\\.a-zA-Z0-9_][\\-;:&=\\+\\$,\\"\\.a-zA-Z0-9_]*`,t.src_xn=`xn--[a-z0-9\\-]{1,59}`,t.src_domain_root=`(?:`+t.src_xn+`|`+t.src_pseudo_letter+`{1,63})`,t.src_domain=`(?:`+t.src_xn+`|(?:`+t.src_pseudo_letter+`)|(?:`+t.src_pseudo_letter+`(?:-|`+t.src_pseudo_letter+`){0,61}`+t.src_pseudo_letter+`))`,t.src_host=`(?:(?:(?:(?:`+t.src_domain+`)\\.)*`+t.src_domain+`))`,t.tpl_host_fuzzy=`(?:`+t.src_ip4+`|(?:(?:(?:`+t.src_domain+`)\\.)+(?:%TLDS%)))`,t.tpl_host_no_ip_fuzzy=`(?:(?:(?:`+t.src_domain+`)\\.)+(?:%TLDS%))`,t.src_host_strict=t.src_host+t.src_host_terminator,t.tpl_host_fuzzy_strict=t.tpl_host_fuzzy+t.src_host_terminator,t.src_host_port_strict=t.src_host+t.src_port+t.src_host_terminator,t.tpl_host_port_fuzzy_strict=t.tpl_host_fuzzy+t.src_port+t.src_host_terminator,t.tpl_host_port_no_ip_fuzzy_strict=t.tpl_host_no_ip_fuzzy+t.src_port+t.src_host_terminator,t.tpl_host_fuzzy_test=`localhost|www\\.|\\.\\d{1,3}\\.|(?:\\.(?:%TLDS%)(?:`+t.src_ZPCc+`|>|$))`,t.tpl_email_fuzzy=`(^|[><|]|"|\\(|`+t.src_ZCc+`)(`+t.src_email_name+`@`+t.tpl_host_fuzzy_strict+`)`,t.tpl_link_fuzzy="(^|(?![.:/\\-_@])(?:[$+<=>^`||]|"+t.src_ZPCc+"))((?![$+<=>^`||])"+t.tpl_host_port_fuzzy_strict+t.src_path+`)`,t.tpl_link_no_ip_fuzzy="(^|(?![.:/\\-_@])(?:[$+<=>^`||]|"+t.src_ZPCc+"))((?![$+<=>^`||])"+t.tpl_host_port_no_ip_fuzzy_strict+t.src_path+`)`,t}function i0(e){return Array.prototype.slice.call(arguments,1).forEach(function(t){t&&Object.keys(t).forEach(function(n){e[n]=t[n]})}),e}function a0(e){return Object.prototype.toString.call(e)}function o0(e){return a0(e)===`[object String]`}function s0(e){return a0(e)===`[object Object]`}function c0(e){return a0(e)===`[object RegExp]`}function l0(e){return a0(e)===`[object Function]`}function u0(e){return e.replace(/[.?*+^$[\]\\(){}|-]/g,`\\$&`)}var d0={fuzzyLink:!0,fuzzyEmail:!0,fuzzyIP:!1};function f0(e){return Object.keys(e||{}).reduce(function(e,t){return e||d0.hasOwnProperty(t)},!1)}var p0={"http:":{validate:function(e,t,n){let r=e.slice(t);return n.re.http||(n.re.http=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(e,t,n){let r=e.slice(t);return n.re.no_http||(n.re.no_http=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)?t>=3&&e[t-3]===`:`||t>=3&&e[t-3]===`/`?0:r.match(n.re.no_http)[0].length:0}},"mailto:":{validate:function(e,t,n){let r=e.slice(t);return n.re.mailto||(n.re.mailto=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}}},m0=`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]`,h0=`biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|рф`.split(`|`);function g0(e){return function(t,n){let r=t.slice(n);return e.test(r)?r.match(e)[0].length:0}}function _0(){return function(e,t){t.normalize(e)}}function v0(e){let t=e.re=r0(e.__opts__),n=e.__tlds__.slice();e.onCompile(),e.__tlds_replaced__||n.push(m0),n.push(t.src_xn),t.src_tlds=n.join(`|`);function r(e){return e.replace(`%TLDS%`,t.src_tlds)}t.email_fuzzy=RegExp(r(t.tpl_email_fuzzy),`i`),t.email_fuzzy_global=RegExp(r(t.tpl_email_fuzzy),`ig`),t.link_fuzzy=RegExp(r(t.tpl_link_fuzzy),`i`),t.link_fuzzy_global=RegExp(r(t.tpl_link_fuzzy),`ig`),t.link_no_ip_fuzzy=RegExp(r(t.tpl_link_no_ip_fuzzy),`i`),t.link_no_ip_fuzzy_global=RegExp(r(t.tpl_link_no_ip_fuzzy),`ig`),t.host_fuzzy_test=RegExp(r(t.tpl_host_fuzzy_test),`i`);let i=[];e.__compiled__={};function a(e,t){throw Error(`(LinkifyIt) Invalid schema "`+e+`": `+t)}Object.keys(e.__schemas__).forEach(function(t){let n=e.__schemas__[t];if(n===null)return;let r={validate:null,link:null};if(e.__compiled__[t]=r,s0(n)){c0(n.validate)?r.validate=g0(n.validate):l0(n.validate)?r.validate=n.validate:a(t,n),l0(n.normalize)?r.normalize=n.normalize:n.normalize?a(t,n):r.normalize=_0();return}if(o0(n)){i.push(t);return}a(t,n)}),i.forEach(function(t){e.__compiled__[e.__schemas__[t]]&&(e.__compiled__[t].validate=e.__compiled__[e.__schemas__[t]].validate,e.__compiled__[t].normalize=e.__compiled__[e.__schemas__[t]].normalize)}),e.__compiled__[``]={validate:null,normalize:_0()};let o=Object.keys(e.__compiled__).filter(function(t){return t.length>0&&e.__compiled__[t]}).map(u0).join(`|`);e.re.schema_test=RegExp(`(^|(?!_)(?:[><|]|`+t.src_ZPCc+`))(`+o+`)`,`i`),e.re.schema_search=RegExp(`(^|(?!_)(?:[><|]|`+t.src_ZPCc+`))(`+o+`)`,`ig`),e.re.schema_at_start=RegExp(`^`+e.re.schema_search.source,`i`),e.re.pretest=RegExp(`(`+e.re.schema_test.source+`)|(`+e.re.host_fuzzy_test.source+`)|@`,`i`)}function y0(e,t,n,r){let i=e.slice(n,r);this.schema=t.toLowerCase(),this.index=n,this.lastIndex=r,this.raw=i,this.text=i,this.url=i}function b0(e,t){if(!(this instanceof b0))return new b0(e,t);t||f0(e)&&(t=e,e={}),this.__opts__=i0({},d0,t),this.__schemas__=i0({},p0,e),this.__compiled__={},this.__tlds__=h0,this.__tlds_replaced__=!1,this.re={},v0(this)}b0.prototype.add=function(e,t){return this.__schemas__[e]=t,v0(this),this},b0.prototype.set=function(e){return this.__opts__=i0(this.__opts__,e),this},b0.prototype.test=function(e){if(!e.length)return!1;let t,n;if(this.re.schema_test.test(e)){for(n=this.re.schema_search,n.lastIndex=0;(t=n.exec(e))!==null;)if(this.testSchemaAt(e,t[2],n.lastIndex))return!0}return!!(this.__opts__.fuzzyLink&&this.__compiled__[`http:`]&&e.search(this.re.host_fuzzy_test)>=0&&e.match(this.__opts__.fuzzyIP?this.re.link_fuzzy:this.re.link_no_ip_fuzzy)!==null||this.__opts__.fuzzyEmail&&this.__compiled__[`mailto:`]&&e.indexOf(`@`)>=0&&e.match(this.re.email_fuzzy)!==null)},b0.prototype.pretest=function(e){return this.re.pretest.test(e)},b0.prototype.testSchemaAt=function(e,t,n){return this.__compiled__[t.toLowerCase()]?this.__compiled__[t.toLowerCase()].validate(e,n,this):0},b0.prototype.match=function(e){let t=[],n=[],r=[],i=[],a,o,s;function c(e,t){return e?t?e.index===t.index?e.lastIndex>=t.lastIndex?e:t:e.index<t.index?e:t:e:t}if(!e.length)return null;if(this.re.schema_test.test(e))for(s=this.re.schema_search,s.lastIndex=0;(a=s.exec(e))!==null;)o=this.testSchemaAt(e,a[2],s.lastIndex),o&&n.push({schema:a[2],index:a.index+a[1].length,lastIndex:a.index+a[0].length+o});if(this.__opts__.fuzzyLink&&this.__compiled__[`http:`])for(s=this.__opts__.fuzzyIP?this.re.link_fuzzy_global:this.re.link_no_ip_fuzzy_global,s.lastIndex=0;(a=s.exec(e))!==null;)r.push({schema:``,index:a.index+a[1].length,lastIndex:a.index+a[0].length});if(this.__opts__.fuzzyEmail&&this.__compiled__[`mailto:`])for(s=this.re.email_fuzzy_global,s.lastIndex=0;(a=s.exec(e))!==null;)i.push({schema:`mailto:`,index:a.index+a[1].length,lastIndex:a.index+a[0].length});let l=[0,0,0],u=0;for(;;){let a=[n[l[0]],i[l[1]],r[l[2]]],o=c(c(a[0],a[1]),a[2]);if(!o)break;if(o===a[0]?l[0]++:o===a[1]?l[1]++:l[2]++,o.index<u)continue;let s=new y0(e,o.schema,o.index,o.lastIndex);this.__compiled__[s.schema].normalize(s,this),t.push(s),u=o.lastIndex}return t.length?t:null},b0.prototype.matchAtStart=function(e){if(!e.length)return null;let t=this.re.schema_at_start.exec(e);if(!t)return null;let n=this.testSchemaAt(e,t[2],t[0].length);if(!n)return null;let r=new y0(e,t[2],t.index+t[1].length,t.index+t[0].length+n);return this.__compiled__[r.schema].normalize(r,this),r},b0.prototype.tlds=function(e,t){return e=Array.isArray(e)?e:[e],t?(this.__tlds__=this.__tlds__.concat(e).sort().filter(function(e,t,n){return e!==n[t-1]}).reverse(),v0(this),this):(this.__tlds__=e.slice(),this.__tlds_replaced__=!0,v0(this),this)},b0.prototype.normalize=function(e){e.schema||(e.url=`http://`+e.url),e.schema===`mailto:`&&!/^mailto:/i.test(e.url)&&(e.url=`mailto:`+e.url)},b0.prototype.onCompile=function(){};var x0=2147483647,S0=36,C0=1,w0=26,T0=38,E0=700,D0=72,O0=128,k0=`-`,A0=/^xn--/,j0=/[^\0-\x7F]/,M0=/[\x2E\u3002\uFF0E\uFF61]/g,N0={overflow:`Overflow: input needs wider integers to process`,"not-basic":`Illegal input >= 0x80 (not a basic code point)`,"invalid-input":`Invalid input`},P0=S0-C0,F0=Math.floor,I0=String.fromCharCode;function L0(e){throw RangeError(N0[e])}function R0(e,t){let n=[],r=e.length;for(;r--;)n[r]=t(e[r]);return n}function z0(e,t){let n=e.split(`@`),r=``;n.length>1&&(r=n[0]+`@`,e=n[1]),e=e.replace(M0,`.`);let i=R0(e.split(`.`),t).join(`.`);return r+i}function B0(e){let t=[],n=0,r=e.length;for(;n<r;){let i=e.charCodeAt(n++);if(i>=55296&&i<=56319&&n<r){let r=e.charCodeAt(n++);(r&64512)==56320?t.push(((i&1023)<<10)+(r&1023)+65536):(t.push(i),n--)}else t.push(i)}return t}var V0=e=>String.fromCodePoint(...e),H0=function(e){return e>=48&&e<58?26+(e-48):e>=65&&e<91?e-65:e>=97&&e<123?e-97:S0},U0=function(e,t){return e+22+75*(e<26)-((t!=0)<<5)},W0=function(e,t,n){let r=0;for(e=n?F0(e/E0):e>>1,e+=F0(e/t);e>455;r+=S0)e=F0(e/P0);return F0(r+36*e/(e+T0))},G0=function(e){let t=[],n=e.length,r=0,i=O0,a=D0,o=e.lastIndexOf(k0);o<0&&(o=0);for(let n=0;n<o;++n)e.charCodeAt(n)>=128&&L0(`not-basic`),t.push(e.charCodeAt(n));for(let s=o>0?o+1:0;s<n;){let o=r;for(let t=1,i=S0;;i+=S0){s>=n&&L0(`invalid-input`);let o=H0(e.charCodeAt(s++));o>=S0&&L0(`invalid-input`),o>F0((x0-r)/t)&&L0(`overflow`),r+=o*t;let c=i<=a?C0:i>=a+w0?w0:i-a;if(o<c)break;let l=S0-c;t>F0(x0/l)&&L0(`overflow`),t*=l}let c=t.length+1;a=W0(r-o,c,o==0),F0(r/c)>x0-i&&L0(`overflow`),i+=F0(r/c),r%=c,t.splice(r++,0,i)}return String.fromCodePoint(...t)},K0=function(e){let t=[];e=B0(e);let n=e.length,r=O0,i=0,a=D0;for(let n of e)n<128&&t.push(I0(n));let o=t.length,s=o;for(o&&t.push(k0);s<n;){let n=x0;for(let t of e)t>=r&&t<n&&(n=t);let c=s+1;n-r>F0((x0-i)/c)&&L0(`overflow`),i+=(n-r)*c,r=n;for(let n of e)if(n<r&&++i>x0&&L0(`overflow`),n===r){let e=i;for(let n=S0;;n+=S0){let r=n<=a?C0:n>=a+w0?w0:n-a;if(e<r)break;let i=e-r,o=S0-r;t.push(I0(U0(r+i%o,0))),e=F0(i/o)}t.push(I0(U0(e,0))),a=W0(i,c,s===o),i=0,++s}++i,++r}return t.join(``)},q0={version:`2.3.1`,ucs2:{decode:B0,encode:V0},decode:G0,encode:K0,toASCII:function(e){return z0(e,function(e){return j0.test(e)?`xn--`+K0(e):e})},toUnicode:function(e){return z0(e,function(e){return A0.test(e)?G0(e.slice(4).toLowerCase()):e})}},J0={default:{options:{html:!1,xhtmlOut:!1,breaks:!1,langPrefix:`language-`,linkify:!1,typographer:!1,quotes:`“”‘’`,highlight:null,maxNesting:100},components:{core:{},block:{},inline:{}}},zero:{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`]}}},commonmark:{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`]}}}},Y0=/^(vbscript|javascript|file|data):/,X0=/^data:image\/(gif|png|jpeg|webp);/;function Z0(e){let t=e.trim().toLowerCase();return Y0.test(t)?X0.test(t):!0}var Q0=[`http:`,`https:`,`mailto:`];function $0(e){let t=dQ(e,!0);if(t.hostname&&(!t.protocol||Q0.indexOf(t.protocol)>=0))try{t.hostname=q0.toASCII(t.hostname)}catch{}return QZ($Z(t))}function e2(e){let t=dQ(e,!0);if(t.hostname&&(!t.protocol||Q0.indexOf(t.protocol)>=0))try{t.hostname=q0.toUnicode(t.hostname)}catch{}return YZ($Z(t),YZ.defaultChars+`%`)}function t2(e,t){if(!(this instanceof t2))return new t2(e,t);t||HQ(e)||(t=e||{},e=`default`),this.inline=new n0,this.block=new x1,this.core=new Z$,this.renderer=new S$,this.linkify=new b0,this.validateLink=Z0,this.normalizeLink=$0,this.normalizeLinkText=e2,this.utils=BQ,this.helpers=GQ({},b$),this.options={},this.configure(e),t&&this.set(t)}t2.prototype.set=function(e){return GQ(this.options,e),this},t2.prototype.configure=function(e){let t=this;if(HQ(e)){let t=e;if(e=J0[t],!e)throw Error('Wrong `markdown-it` preset "'+t+`", check name`)}if(!e)throw Error("Wrong `markdown-it` preset, can't be empty");return e.options&&t.set(e.options),e.components&&Object.keys(e.components).forEach(function(n){e.components[n].rules&&t[n].ruler.enableOnly(e.components[n].rules),e.components[n].rules2&&t[n].ruler2.enableOnly(e.components[n].rules2)}),this},t2.prototype.enable=function(e,t){let n=[];Array.isArray(e)||(e=[e]),[`core`,`block`,`inline`].forEach(function(t){n=n.concat(this[t].ruler.enable(e,!0))},this),n=n.concat(this.inline.ruler2.enable(e,!0));let r=e.filter(function(e){return n.indexOf(e)<0});if(r.length&&!t)throw Error(`MarkdownIt. Failed to enable unknown rule(s): `+r);return this},t2.prototype.disable=function(e,t){let n=[];Array.isArray(e)||(e=[e]),[`core`,`block`,`inline`].forEach(function(t){n=n.concat(this[t].ruler.disable(e,!0))},this),n=n.concat(this.inline.ruler2.disable(e,!0));let r=e.filter(function(e){return n.indexOf(e)<0});if(r.length&&!t)throw Error(`MarkdownIt. Failed to disable unknown rule(s): `+r);return this},t2.prototype.use=function(e){let t=[this].concat(Array.prototype.slice.call(arguments,1));return e.apply(e,t),this},t2.prototype.parse=function(e,t){if(typeof e!=`string`)throw Error(`Input data should be a String`);let n=new this.core.State(e,this,t);return this.core.process(n),n.tokens},t2.prototype.render=function(e,t){return t||={},this.renderer.render(this.parse(e,t),this.options,t)},t2.prototype.parseInline=function(e,t){let n=new this.core.State(e,this,t);return n.inlineMode=!0,this.core.process(n),n.tokens},t2.prototype.renderInline=function(e,t){return t||={},this.renderer.render(this.parseInline(e,t),this.options,t)};var n2=new ef({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(e){return[`h`+e.attrs.level,0]}},code_block:{content:`text*`,group:`block`,code:!0,defining:!0,marks:``,attrs:{params:{default:``}},parseDOM:[{tag:`pre`,preserveWhitespace:`full`,getAttrs:e=>({params:e.getAttribute(`data-params`)||``})}],toDOM(e){return[`pre`,e.attrs.params?{"data-params":e.attrs.params}:{},[`code`,0]]}},ordered_list:{content:`list_item+`,group:`block`,attrs:{order:{default:1},tight:{default:!1}},parseDOM:[{tag:`ol`,getAttrs(e){return{order:e.hasAttribute(`start`)?+e.getAttribute(`start`):1,tight:e.hasAttribute(`data-tight`)}}}],toDOM(e){return[`ol`,{start:e.attrs.order==1?null:e.attrs.order,"data-tight":e.attrs.tight?`true`:null},0]}},bullet_list:{content:`list_item+`,group:`block`,attrs:{tight:{default:!1}},parseDOM:[{tag:`ul`,getAttrs:e=>({tight:e.hasAttribute(`data-tight`)})}],toDOM(e){return[`ul`,{"data-tight":e.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(e){return{src:e.getAttribute(`src`),title:e.getAttribute(`title`),alt:e.getAttribute(`alt`)}}}],toDOM(e){return[`img`,e.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:e=>e.type.name==`em`}],toDOM(){return[`em`]}},strong:{parseDOM:[{tag:`strong`},{tag:`b`,getAttrs:e=>e.style.fontWeight!=`normal`&&null},{style:`font-weight=400`,clearMark:e=>e.type.name==`strong`},{style:`font-weight`,getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}],toDOM(){return[`strong`]}},link:{attrs:{href:{},title:{default:null}},inclusive:!1,parseDOM:[{tag:`a[href]`,getAttrs(e){return{href:e.getAttribute(`href`),title:e.getAttribute(`title`)}}}],toDOM(e){return[`a`,e.attrs]}},code:{code:!0,parseDOM:[{tag:`code`}],toDOM(){return[`code`]}}}});function r2(e,t){if(e.isText&&t.isText&&ld.sameSet(e.marks,t.marks))return e.withText(e.text+t.text)}var i2=class{constructor(e,t){this.schema=e,this.tokenHandlers=t,this.stack=[{type:e.topNodeType,attrs:null,content:[],marks:ld.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 t=this.top(),n=t.content,r=n[n.length-1],i=this.schema.text(e,t.marks),a;r&&(a=r2(r,i))?n[n.length-1]=a:n.push(i)}openMark(e){let t=this.top();t.marks=e.addToSet(t.marks)}closeMark(e){let t=this.top();t.marks=e.removeFromSet(t.marks)}parseTokens(e){for(let t=0;t<e.length;t++){let n=e[t],r=this.tokenHandlers[n.type];if(!r)throw Error("Token type `"+n.type+"` not supported by Markdown parser");r(this,n,e,t)}}addNode(e,t,n){let r=this.top(),i=e.createAndFill(t,n,r?r.marks:[]);return i?(this.push(i),i):null}openNode(e,t){this.stack.push({type:e,attrs:t,content:[],marks:ld.none})}closeNode(){let e=this.stack.pop();return this.addNode(e.type,e.attrs,e.content)}};function a2(e,t,n,r){return e.getAttrs?e.getAttrs(t,n,r):e.attrs instanceof Function?e.attrs(t):e.attrs}function o2(e,t){return e.noCloseToken||t==`code_inline`||t==`code_block`||t==`fence`}function s2(e){return e[e.length-1]==`
234
+ `?e.slice(0,e.length-1):e}function c2(){}function l2(e,t){let n=Object.create(null);for(let r in t){let i=t[r];if(i.block){let t=e.nodeType(i.block);o2(i,r)?n[r]=(e,n,r,a)=>{e.openNode(t,a2(i,n,r,a)),e.addText(s2(n.content)),e.closeNode()}:(n[r+`_open`]=(e,n,r,a)=>e.openNode(t,a2(i,n,r,a)),n[r+`_close`]=e=>e.closeNode())}else if(i.node){let t=e.nodeType(i.node);n[r]=(e,n,r,a)=>e.addNode(t,a2(i,n,r,a))}else if(i.mark){let t=e.marks[i.mark];o2(i,r)?n[r]=(e,n,r,a)=>{e.openMark(t.create(a2(i,n,r,a))),e.addText(s2(n.content)),e.closeMark(t)}:(n[r+`_open`]=(e,n,r,a)=>e.openMark(t.create(a2(i,n,r,a))),n[r+`_close`]=e=>e.closeMark(t))}else if(i.ignore)o2(i,r)?n[r]=c2:(n[r+`_open`]=c2,n[r+`_close`]=c2);else throw RangeError(`Unrecognized parsing spec `+JSON.stringify(i))}return n.text=(e,t)=>e.addText(t.content),n.inline=(e,t)=>e.parseTokens(t.children),n.softbreak=n.softbreak||(e=>e.addText(` `)),n}var u2=class{constructor(e,t,n){this.schema=e,this.tokenizer=t,this.tokens=n,this.tokenHandlers=l2(e,n)}parse(e,t={}){let n=new i2(this.schema,this.tokenHandlers),r;n.parseTokens(this.tokenizer.parse(e,t));do r=n.closeNode();while(n.stack.length);return r||this.schema.topNodeType.createAndFill()}};function d2(e,t){for(;++t<e.length;)if(e[t].type!=`list_item_open`)return e[t].hidden;return!1}new u2(n2,t2(`commonmark`,{html:!1}),{blockquote:{block:`blockquote`},paragraph:{block:`paragraph`},list_item:{block:`list_item`},bullet_list:{block:`bullet_list`,getAttrs:(e,t,n)=>({tight:d2(t,n)})},ordered_list:{block:`ordered_list`,getAttrs:(e,t,n)=>({order:+e.attrGet(`start`)||1,tight:d2(t,n)})},heading:{block:`heading`,getAttrs:e=>({level:+e.tag.slice(1)})},code_block:{block:`code_block`,noCloseToken:!0},fence:{block:`code_block`,getAttrs:e=>({params:e.info||``}),noCloseToken:!0},hr:{node:`horizontal_rule`},image:{node:`image`,getAttrs:e=>({src:e.attrGet(`src`),title:e.attrGet(`title`)||null,alt:e.children[0]&&e.children[0].content||null})},hardbreak:{node:`hard_break`},em:{mark:`em`},strong:{mark:`strong`},link:{mark:`link`,getAttrs:e=>({href:e.attrGet(`href`),title:e.attrGet(`title`)||null})},code_inline:{mark:`code`,noCloseToken:!0}});var f2={open:``,close:``,mixable:!0};new class{constructor(e,t,n={}){this.nodes=e,this.marks=t,this.options=n}serialize(e,t={}){t=Object.assign({},this.options,t);let n=new h2(this.nodes,this.marks,t);return n.renderContent(e),n.out}}({blockquote(e,t){e.wrapBlock(`> `,null,t,()=>e.renderContent(t))},code_block(e,t){let n=t.textContent.match(/`{3,}/gm),r=n?n.sort().slice(-1)[0]+"`":"```";e.write(r+(t.attrs.params||``)+`
235
+ `),e.text(t.textContent,!1),e.write(`
236
+ `),e.write(r),e.closeBlock(t)},heading(e,t){e.write(e.repeat(`#`,t.attrs.level)+` `),e.renderInline(t,!1),e.closeBlock(t)},horizontal_rule(e,t){e.write(t.attrs.markup||`---`),e.closeBlock(t)},bullet_list(e,t){e.renderList(t,` `,()=>(t.attrs.bullet||`*`)+` `)},ordered_list(e,t){let n=t.attrs.order||1,r=String(n+t.childCount-1).length,i=e.repeat(` `,r+2);e.renderList(t,i,t=>{let i=String(n+t);return e.repeat(` `,r-i.length)+i+`. `})},list_item(e,t){e.renderContent(t)},paragraph(e,t){e.renderInline(t),e.closeBlock(t)},image(e,t){e.write(`![`+e.esc(t.attrs.alt||``)+`](`+t.attrs.src.replace(/[\(\)]/g,`\\$&`)+(t.attrs.title?` "`+t.attrs.title.replace(/"/g,`\\"`)+`"`:``)+`)`)},hard_break(e,t,n,r){for(let i=r+1;i<n.childCount;i++)if(n.child(i).type!=t.type){e.write(`\\
237
+ `);return}},text(e,t){e.text(t.text,!e.inAutolink)}},{em:{open:`*`,close:`*`,mixable:!0,expelEnclosingWhitespace:!0},strong:{open:`**`,close:`**`,mixable:!0,expelEnclosingWhitespace:!0},link:{open(e,t,n,r){return e.inAutolink=m2(t,n,r),e.inAutolink?`<`:`[`},close(e,t,n,r){let{inAutolink:i}=e;return e.inAutolink=void 0,i?`>`:`](`+t.attrs.href.replace(/[\(\)"]/g,`\\$&`)+(t.attrs.title?` "${t.attrs.title.replace(/"/g,`\\"`)}"`:``)+`)`},mixable:!0},code:{open(e,t,n,r){return p2(n.child(r),-1)},close(e,t,n,r){return p2(n.child(r-1),1)},escape:!1}});function p2(e,t){let n=/`+/g,r,i=0;if(e.isText)for(;r=n.exec(e.text);)i=Math.max(i,r[0].length);let a=i>0&&t>0?" `":"`";for(let e=0;e<i;e++)a+="`";return i>0&&t<0&&(a+=` `),a}function m2(e,t,n){if(e.attrs.title||!/^\w+:/.test(e.attrs.href))return!1;let r=t.child(n);return!r.isText||r.text!=e.attrs.href||r.marks[r.marks.length-1]!=e?!1:n==t.childCount-1||!e.isInSet(t.child(n+1).marks)}var h2=class{constructor(e,t,n){this.nodes=e,this.marks=t,this.options=n,this.delim=``,this.out=``,this.closed=null,this.inAutolink=void 0,this.atBlockStart=!1,this.inTightList=!1,this.options.tightLists===void 0&&(this.options.tightLists=!1),this.options.hardBreakNodeName===void 0&&(this.options.hardBreakNodeName=`hard_break`)}flushClose(e=2){if(this.closed){if(this.atBlank()||(this.out+=`
238
+ `),e>1){let t=this.delim,n=/\s+$/.exec(t);n&&(t=t.slice(0,t.length-n[0].length));for(let n=1;n<e;n++)this.out+=t+`
239
+ `}this.closed=null}}getMark(e){let t=this.marks[e];if(!t){if(this.options.strict!==!1)throw Error(`Mark type \`${e}\` not supported by Markdown renderer`);t=f2}return t}wrapBlock(e,t,n,r){let i=this.delim;this.write(t??e),this.delim+=e,r(),this.delim=i,this.closeBlock(n)}atBlank(){return/(^|\n)$/.test(this.out)}ensureNewLine(){this.atBlank()||(this.out+=`
240
+ `)}write(e){this.flushClose(),this.delim&&this.atBlank()&&(this.out+=this.delim),e&&(this.out+=e)}closeBlock(e){this.closed=e}text(e,t=!0){let n=e.split(`
241
+ `);for(let e=0;e<n.length;e++)this.write(),!t&&n[e][0]==`[`&&/(^|[^\\])\!$/.test(this.out)&&(this.out=this.out.slice(0,this.out.length-1)+`\\!`),this.out+=t?this.esc(n[e],this.atBlockStart):n[e],e!=n.length-1&&(this.out+=`
242
+ `)}render(e,t,n){if(this.nodes[e.type.name])this.nodes[e.type.name](this,e,t,n);else if(this.options.strict!==!1)throw Error("Token type `"+e.type.name+"` not supported by Markdown renderer");else e.type.isLeaf||(e.type.inlineContent?this.renderInline(e):this.renderContent(e),e.isBlock&&this.closeBlock(e))}renderContent(e){e.forEach((t,n,r)=>this.render(t,e,r))}renderInline(e,t=!0){this.atBlockStart=t;let n=[],r=``,i=(t,i,a)=>{let o=t?t.marks:[];t&&t.type.name===this.options.hardBreakNodeName&&(o=o.filter(t=>{if(a+1==e.childCount)return!1;let n=e.child(a+1);return t.isInSet(n.marks)&&(!n.isText||/\S/.test(n.text))}));let s=r;if(r=``,t&&t.isText&&o.some(e=>{let t=this.getMark(e.type.name);return t&&t.expelEnclosingWhitespace&&!e.isInSet(n)})){let[e,r,i]=/^(\s*)(.*)$/m.exec(t.text);r&&(s+=r,t=i?t.withText(i):null,t||(o=n))}if(t&&t.isText&&o.some(t=>{let n=this.getMark(t.type.name);return n&&n.expelEnclosingWhitespace&&!this.isMarkAhead(e,a+1,t)})){let[e,i,a]=/^(.*?)(\s*)$/m.exec(t.text);a&&(r=a,t=i?t.withText(i):null,t||(o=n))}let c=o.length?o[o.length-1]:null,l=c&&this.getMark(c.type.name).escape===!1,u=o.length-+!!l;outer:for(let e=0;e<u;e++){let t=o[e];if(!this.getMark(t.type.name).mixable)break;for(let r=0;r<n.length;r++){let i=n[r];if(!this.getMark(i.type.name).mixable)break;if(t.eq(i)){e>r?o=o.slice(0,r).concat(t).concat(o.slice(r,e)).concat(o.slice(e+1,u)):r>e&&(o=o.slice(0,e).concat(o.slice(e+1,r)).concat(t).concat(o.slice(r,u)));continue outer}}}let d=0;for(;d<Math.min(n.length,u)&&o[d].eq(n[d]);)++d;for(;d<n.length;)this.text(this.markString(n.pop(),!1,e,a),!1);if(s&&this.text(s),t){for(;n.length<u;){let t=o[n.length];n.push(t),this.text(this.markString(t,!0,e,a),!1),this.atBlockStart=!1}l&&t.isText?this.text(this.markString(c,!0,e,a)+t.text+this.markString(c,!1,e,a+1),!1):this.render(t,e,a),this.atBlockStart=!1}t?.isText&&t.nodeSize>0&&(this.atBlockStart=!1)};e.forEach(i),i(null,0,e.childCount),this.atBlockStart=!1}renderList(e,t,n){this.closed&&this.closed.type==e.type?this.flushClose(3):this.inTightList&&this.flushClose(1);let r=e.attrs.tight===void 0?this.options.tightLists:e.attrs.tight,i=this.inTightList;this.inTightList=r,e.forEach((i,a,o)=>{o&&r&&this.flushClose(1),this.wrapBlock(t,n(o),e,()=>this.render(i,e,o))}),this.inTightList=i}esc(e,t=!1){return e=e.replace(/[`*\\~\[\]_]/g,(t,n)=>t==`_`&&n>0&&n+1<e.length&&e[n-1].match(/\w/)&&e[n+1].match(/\w/)?t:`\\`+t),t&&(e=e.replace(/^(\+[ ]|[\-*>])/,`\\$&`).replace(/^(\s*)(#{1,6})(\s|$)/,`$1\\$2$3`).replace(/^(\s*\d+)\.\s/,`$1\\. `)),this.options.escapeExtraCharacters&&(e=e.replace(this.options.escapeExtraCharacters,`\\$&`)),e}quote(e){let t=e.indexOf(`"`)==-1?`""`:e.indexOf(`'`)==-1?`''`:`()`;return t[0]+e+t[1]}repeat(e,t){let n=``;for(let r=0;r<t;r++)n+=e;return n}markString(e,t,n,r){let i=this.getMark(e.type.name),a=t?i.open:i.close;return typeof a==`string`?a:a(this,e,n,r)}getEnclosingWhitespace(e){return{leading:(e.match(/^(\s+)/)||[void 0])[0],trailing:(e.match(/(\s+)$/)||[void 0])[0]}}isMarkAhead(e,t,n){for(;;t++){if(t>=e.childCount)return!1;let r=e.child(t);if(r.type.name!=this.options.hardBreakNodeName)return n.isInSet(r.marks);t++}}};function g2(e){let t=e.tokens,n=[];for(let r=0;r<t.length;r++){let i=t[r];if(n.push(i),(i.type===`th_open`||i.type===`td_open`)&&t[r+1]?.type===`inline`){let i=new e.Token(`paragraph_open`,`p`,1),a=new e.Token(`paragraph_close`,`p`,-1);n.push(i,t[r+1],a),r+=1}}e.tokens=n}function _2(e){return zG(e.attrGet(`src`))!=null}function v2(e,t){let n=new e.Token(`text`,``,0);return n.content=t.content||t.attrGet(`alt`)||``,n}function y2(e){let t=e.tokens,n=[],r=0;for(let i=0;i<t.length;i++){let a=t[i];if(a.type===`th_open`||a.type===`td_open`?r++:(a.type===`th_close`||a.type===`td_close`)&&r--,a.type===`paragraph_open`&&r===0){let e=t[i+1],r=t[i+2];if(e?.type===`inline`&&r?.type===`paragraph_close`){let t=e.children??[];if(t.length===1&&t[0].type===`image`&&_2(t[0])){n.push(t[0]),i+=2;continue}}}if(a.type===`inline`&&a.children)for(let t=0;t<a.children.length;t++)a.children[t].type===`image`&&(a.children[t]=v2(e,a.children[t]));n.push(a)}e.tokens=n}function b2(e){let t={blockquote:{block:`blockquote`},paragraph:{block:`paragraph`},list_item:{block:`listItem`},bullet_list:{block:`bulletList`},ordered_list:{block:`orderedList`,getAttrs:e=>({start:+(e.attrGet(`start`)??1)||1})},heading:{block:`heading`,getAttrs:e=>({level:+e.tag.slice(1)})},code_block:{block:`codeBlock`,noCloseToken:!0,getAttrs:e=>({language:e.info?.trim()||null})},fence:{block:`codeBlock`,noCloseToken:!0,getAttrs:e=>({language:e.info?.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},table:{block:`table`},thead:{ignore:!0},tbody:{ignore:!0},tr:{block:`tableRow`},th:{block:`tableHeader`},td:{block:`tableCell`},image:{node:`image`,noCloseToken:!0,getAttrs:e=>({src:e.attrGet(`src`),alt:e.content||null,title:e.attrGet(`title`)||null})},em:{mark:`italic`},strong:{mark:`bold`},s:{mark:`strike`},code_inline:{mark:`code`,noCloseToken:!0},link:{mark:`link`,getAttrs:e=>({href:FG(e.attrGet(`href`)),title:e.attrGet(`title`)||null})}},n={};for(let[r,i]of Object.entries(t))i.node&&!e.nodes[i.node]||i.block&&!e.nodes[i.block]||i.mark&&!e.marks[i.mark]||(n[r]=i);return n}function x2(e){let t=t2(`commonmark`,{html:!1}).enable([`strikethrough`,`linkify`,`table`]);return t.core.ruler.push(`tandem-wrap-cell-paragraphs`,g2),t.core.ruler.push(`tandem-normalize-images`,y2),new u2(e,t,b2(e))}function S2(e){let t=e.trim(),n=[],r=``;for(let e=0;e<t.length;e++){let i=t[e];if(i===`|`&&t[e-1]!==`\\`){n.push(r),r=``;continue}r+=i}return n.push(r),n.length>1&&n[0]===``&&n.shift(),n.length>1&&n[n.length-1]===``&&n.pop(),n}function C2(e){let t=e.trim();if(!t)return!1;let n=S2(t);return n.length===0?!1:n.every(e=>/^:?-+:?$/.test(e.trim()))&&n.some(e=>e.trim().length>0)}function w2(e){let t=e.split(/\r\n|\r|\n/);for(let e=0;e<t.length-1;e++){if(!t[e].includes(`|`)||!C2(t[e+1]))continue;let n=S2(t[e]),r=S2(t[e+1]);if(n.length>0&&n.length===r.length)return!0}return!1}var T2=2e3,E2=RegExp(`(\\*\\*\\S(?:[^*\\n]{0,${T2}}\\S)?\\*\\*|__\\S(?:[^_\\n]{0,${T2}}\\S)?__|\\*\\S(?:[^*\\n]{0,${T2}}\\S)?\\*|\`[^\`\\n]{1,${T2}}\`|~~\\S(?:[^~\\n]{0,${T2}}\\S)?~~|!?\\[[^\\]\\n]{0,${T2}}\\]\\([^)\\n]{1,${T2}}\\))`);function D2(e){return e?!!(/^\s{0,3}(#{1,6}\s|[-*+]\s|\d+[.)]\s|>\s|```|~~~|-{3,}\s*$|\*{3,}\s*$|_{3,}\s*$)/m.test(e)||E2.test(e)||w2(e)):!1}function O2(e,t){if(!D2(e))return null;let n;try{let r=x2(t).parse(e);if(!r)return null;n=r}catch{return null}return n.childCount===0?null:Q.maxOpen(n.content,!1)}function k2(e){return{attributes:{class:`tandem-editor`,style:`outline: none; font-size: var(--tandem-editor-font-size, 16px); line-height: 1.6;`,spellcheck:String(e)},clipboardTextParser:(e,t,n,r)=>{if(!n){let t=O2(e,r.state.schema);if(t)return t}return jG(e,r.state.schema,t.marks())},handlePaste:(e,t)=>{let n=t.clipboardData?.getData(`text/plain`)?.trim();if(!n||/\s/.test(n)||!NG(n))return!1;let{selection:r}=e.state;if(r.empty||!(r instanceof Wp))return!1;let i=e.state.schema.marks.link;if(!i)return!1;let a=e.state.tr.addMark(r.from,r.to,i.create({href:n}));return a.steps.length===0?!1:(e.dispatch(a),!0)}}}var A2=new dm(`tandemAnnotations`),j2={comment:!0,highlight:!0,note:!0};function M2(){try{let e=localStorage.getItem(no);if(!e)return{...j2};let t=JSON.parse(e);return{comment:t.comment!==!1,highlight:t.highlight!==!1,note:t.note!==!1}}catch(e){return console.warn(`[annotation] localStorage unavailable`,e),{...j2}}}function N2(){return yD(Nl(),`family`)}function P2(e){return e===`highlight`?`highlight`:e===`note`||e===`flag`?`note`:`comment`}function F2(e,t,n,r,i){let a=[],o=e.content.size;return t.forEach(t=>{let s=Ok(t,e=>{console.warn(`[sanitize]`,e)});if(s.status!==`pending`||!r[s.type]||!s.range&&!s.relRange)return;let c=jD(s,e,n);if(!c)return;s.relRange&&c.method===`flat`&&console.warn(`[annotation] relRange-equipped annotation %s fell back to flat offsets`,s.id);let{from:l,to:u}=c;if(l>=u||l<0||u>o)return;let d={};switch(s.type){case`highlight`:{let e=ka(s.color),t=Oa[e];d={class:`tandem-highlight tandem-highlight--${e}`,style:`background: ${t}; border-radius: var(--tandem-r-1); padding: 1px 0;`,"data-annotation-id":s.id,"data-annotation-type":s.type,"data-annotation-author":s.author,"aria-label":`Highlight annotation (${e})`};break}case`comment`:d=s.suggestedText===void 0?s.author===`claude`?{class:`tandem-comment tandem-comment--claude`,style:`border-bottom: 2px solid var(--tandem-author-claude); padding-bottom: 1px;`,"data-annotation-id":s.id,"data-annotation-type":s.type,"data-annotation-author":s.author,"aria-label":`${i} comment annotation`}:{class:`tandem-comment`,style:`border-bottom: 2px dashed var(--tandem-author-user); padding-bottom: 1px;`,"data-annotation-id":s.id,"data-annotation-type":s.type,"data-annotation-author":s.author,"aria-label":`Comment annotation`}:{class:`tandem-suggestion`,style:`background: var(--tandem-suggestion-bg); text-decoration: underline wavy var(--tandem-suggestion); text-underline-offset: 3px;`,"data-annotation-id":s.id,"data-annotation-type":s.type,"data-annotation-author":s.author,"aria-label":`Replacement annotation`};break;case`note`:d={class:`tandem-note`,style:`border-bottom: 2px dotted var(--tandem-fg-muted); padding-bottom: 1px;`,"data-annotation-id":s.id,"data-annotation-type":s.type,"data-annotation-author":s.author,"aria-label":`Note annotation`};break;default:console.warn(`[annotation] Unhandled annotation type in buildDecorations, skipping`);return}try{a.push(rz.inline(l,u,d))}catch(e){if(!(e instanceof RangeError))throw e;console.debug(`[annotation] RangeError for %s (from=%d, to=%d), skipping`,s.id,l,u)}}),oz.create(e,a)}var I2=IV.create({name:`tandemAnnotations`,addOptions(){return{ydoc:null}},addProseMirrorPlugins(){let e=this.options.ydoc;if(!e)return[];let t=e.getMap(La),n=M2(),r=N2();function i(){for(let e of t.values()){let t=e;if(t&&t.status===`pending`&&n[P2(t.type)])return!0}return!1}let a=i(),o=!1;return[new cm({key:A2,state:{init(i,o){return a?F2(o.doc,t,e,n,r):oz.empty},apply(s,c,l,u){let d=s.getMeta(A2);if(d&&typeof d==`object`&&d.type===`toggle-decorations`&&(n=d.visible,a=i(),o=!1),d)return r=N2(),a?F2(u.doc,t,e,n,r):oz.empty;if(!a)return oz.empty;if(s.docChanged){if(!o&&c===oz.empty&&a){let i=F2(u.doc,t,e,n,r);return i!==oz.empty&&(o=!0),i}return c.map(s.mapping,s.doc)}return c}},props:{decorations(e){return A2.getState(e)}},view(e){let n=null,r=!1;function s(){n===null&&(n=requestAnimationFrame(()=>{n=null,r=!0;let t=e.state.tr.setMeta(A2,!0);e.dispatch(t)}))}let c=()=>{a=i(),o=!1,s()};t.observe(c);let l=setTimeout(()=>{!r&&n===null&&t.size>0&&c()},500);return{destroy(){clearTimeout(l),n!==null&&cancelAnimationFrame(n),t.unobserve(c)}}}})]}}),L2=new dm(`tandemAnnotationPing`),R2=700,z2=500,B2=`tandem-annotation-ping`;function V2(e,t){return!(!t.isLive||t.alreadySeen||!e||e.status!==`pending`||!t.visible[P2(e.type)])}function H2(){try{if(Nl().reduceMotion)return!0}catch{}return typeof matchMedia<`u`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches}var U2=IV.create({name:`tandemAnnotationPing`,addOptions(){return{ydoc:null}},addProseMirrorPlugins(){let e=this.options.ydoc;if(!e)return[];let t=e.getMap(La),n=new Set,r=!1;return[new cm({key:L2,state:{init:()=>oz.empty,apply(e,t){let n=t.map(e.mapping,e.doc),r=e.getMeta(L2);if(r?.type===`add`)n=n.add(e.doc,[r.deco]);else if(r?.type===`remove`){let e=n.find(void 0,void 0,e=>e.pingId===r.id);e.length&&(n=n.remove(e))}return n}},props:{decorations(e){return L2.getState(e)}},view(i){let a=new Map,o=!1;function s(t,n){if(H2())return;let r=jD(n,i.state.doc,e);if(r)try{let e=i.state.doc.resolve(r.from),n=e.depth;if(n<1)return;let s=e.before(n),c=e.after(n),l=rz.node(s,c,{class:B2},{pingId:t});i.dispatch(i.state.tr.setMeta(L2,{type:`add`,deco:l}));let u=setTimeout(()=>{a.delete(t),!o&&i.dispatch(i.state.tr.setMeta(L2,{type:`remove`,id:t}))},R2);a.set(t,u)}catch(e){if(!(e instanceof RangeError))throw e}}let c,l=()=>{for(let e of t.keys())n.add(e);r=!0},u=()=>{clearTimeout(c),c=setTimeout(l,z2)},d=e=>{r||u();let i=M2();for(let a of e.keysChanged){let e=t.get(a),o=V2(e,{isLive:r,alreadySeen:n.has(a),visible:i});n.add(a),o&&e&&s(a,e)}};return t.observe(d),u(),{destroy(){o=!0,clearTimeout(c);for(let e of a.values())clearTimeout(e);a.clear(),t.unobserve(d)}}}})]}}),W2=new dm(`tandemAuthorship`),G2=new Set([`paragraph`,`heading`]);function K2(e,t,n){if(e.relRange){let r=AD(n,t,e.relRange);if(r&&r.from<r.to)return r}if(e.range){console.warn(`[authorship] Falling back to flat offsets for range`,e.id);let n=TD(t,e.range.from),r=TD(t,e.range.to);if(n<r)return{from:n,to:r}}return null}function q2(e,t,n,r){if(!r)return oz.empty;let i=[],a=e.content.size,o=[];return t.forEach(t=>{let r=t;if(!r.author||!r.range||r.author!==`user`&&r.author!==`claude`)return;let s=K2(r,e,n);if(!s)return;let{from:c,to:l}=s;if(!(c>=l||c<0||l>a)){try{i.push(rz.inline(c,l,{"data-tandem-author":r.author}))}catch(e){if(!(e instanceof RangeError))throw e;console.warn(`[authorship] Decoration RangeError for entry`,r.id,e)}o.push({author:r.author,from:c,to:l})}}),e.descendants((e,t)=>{if(!G2.has(e.type.name))return;let n=t,r=t+e.nodeSize,a=0,s=0;for(let e of o){let t=Math.max(e.from,n),i=Math.min(e.to,r);if(i<=t)continue;let o=i-t;e.author===`user`?a+=o:s+=o}if(a===0&&s===0||e.content.size===0)return;let c=a>=s?`user`:`claude`;try{i.push(rz.node(n,r,{"data-tandem-author-block":c}))}catch(e){if(!(e instanceof RangeError))throw e;console.warn(`[authorship] node Decoration RangeError at offset`,t,e)}}),oz.create(e,i)}var J2=IV.create({name:`tandemAuthorship`,addOptions(){return{ydoc:null}},addProseMirrorPlugins(){let e=this.options.ydoc;if(!e)return[];let t=e.getMap(Ka),n=!1;try{n=localStorage.getItem(to)===`true`}catch(e){console.warn(`[authorship] localStorage unavailable`,e)}return[new cm({key:W2,state:{init(r,i){return{visible:n,decorations:q2(i.doc,t,e,n)}},apply(n,r,i,a){let o=n.getMeta(W2);if(o?.type===`toggle`){let n=o.visible;return{visible:n,decorations:q2(a.doc,t,e,n)}}return o?.type===`rebuild`?{visible:r.visible,decorations:q2(a.doc,t,e,r.visible)}:n.docChanged&&r.visible?{visible:r.visible,decorations:r.decorations.map(n.mapping,n.doc)}:r}},props:{decorations(e){return W2.getState(e)?.decorations??oz.empty}},view(e){let n=()=>{let t=e.state.tr.setMeta(W2,{type:`rebuild`});e.dispatch(t)};t.observe(n);let r=setTimeout(()=>{t.size>0&&n()},500);return{destroy(){clearTimeout(r),t.unobserve(n)}}}})]},onTransaction({transaction:e}){let t=this.options.ydoc;if(!t||e.getMeta(`y-sync$`)||e.getMeta(W2)||!e.docChanged)return;let n=t.getMap(Ka),r=e.doc;e.steps.forEach(e=>{e.getMap().forEach((e,t,i,a)=>{if(a-i-(t-e)>0)try{let e=DD(r,So(i)),t=DD(r,So(a));if(t<=e)return;let o=fc(`user`),s={id:o,author:`user`,range:{from:e,to:t},timestamp:Date.now()};n.set(o,s)}catch(e){console.warn(`[authorship] Position conversion failed during user attribution`,e)}})})}}),Y2=new dm(`tandemAwareness`);function X2(e,t){if(!t)return oz.empty;let n=[],{focusParagraph:r,focusOffset:i,active:a}=t;if(r!==null&&r>=0){let t=0;e.forEach((e,i)=>{t===r&&n.push(rz.node(i,i+e.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;`})),t++})}if(i!==null&&i>=0)try{let t=TD(e,xo(i)),r=a===!1?` tandem-claude-cursor-idle`:``;n.push(rz.widget(t,()=>{let e=document.createElement(`span`);e.className=`tandem-claude-cursor${r}`,e.setAttribute(`aria-hidden`,`true`);let t=document.createElement(`span`);return t.className=`tandem-claude-cursor-label`,t.textContent=`AI`,e.appendChild(t),e}))}catch(e){console.warn(`[awareness] cursor decoration failed, falling back to gutter-only:`,e)}return n.length===0?oz.empty:oz.create(e,n)}var Z2=IV.create({name:`tandemAwareness`,addOptions(){return{ydoc:null}},addProseMirrorPlugins(){let e=this.options.ydoc;if(!e)return[];let t=e.getMap(Ra),n=e.getMap(za);return[new cm({key:Y2,state:{init(e,n){let r=t.get(Ya);return X2(n.doc,r??null)},apply(e,n,r,i){if(e.getMeta(Y2)){let e=t.get(Ya);return X2(i.doc,e??null)}return e.docChanged?n.map(e.mapping,e.doc):n}},props:{decorations(e){return Y2.getState(e)}},view(e){let n=()=>{let t=e.state.tr.setMeta(Y2,!0);e.dispatch(t)};return t.observe(n),{destroy(){t.unobserve(n)}}}}),new cm({key:new dm(`tandemUserAwareness`),view(){let e=null,t=null,r=null,i=!1,a=-1;return{update(o,s){let{state:c}=o;if(!c.selection.eq(s.selection)){let e=MD(c.doc,{from:So(c.selection.from),to:So(c.selection.to)});if(c.selection.from===c.selection.to)r&&=(clearTimeout(r),null),n.set(qa,{...e,timestamp:Date.now()});else{let t=c.doc.textBetween(c.selection.from,c.selection.to,`
243
+ `),i=t.length>200?t.slice(0,197)+`...`:t;r&&clearTimeout(r),r=setTimeout(()=>{r=null,n.set(qa,{...e,selectedText:i,timestamp:Date.now()})},150)}}c.doc!==s.doc&&(a=c.selection.from,i=!0,t||=setTimeout(()=>{t=null,i&&n.set(Ja,{isTyping:!0,cursor:a,lastEdit:Date.now()})},200),e&&clearTimeout(e),e=setTimeout(()=>{i=!1,n.set(Ja,{isTyping:!1,cursor:o.state.selection.from,lastEdit:Date.now()})},wa))},destroy(){e&&clearTimeout(e),t&&clearTimeout(t),r&&clearTimeout(r)}}}})]}}),Q2=new dm(`tandemFindReplace`),$2={query:``,caseSensitive:!1,wholeWord:!1,regexMode:!1,matches:[],activeIndex:-1,decoSet:oz.empty};function e4(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function t4(e){if(!e.query)return null;try{let t=e.regexMode?e.query:e4(e.query),n=e.caseSensitive?`g`:`gi`,r=e.wholeWord?`\\b${t}\\b`:t;return new RegExp(r,n)}catch{return null}}function n4(e,t){let n=t4(t);if(!n)return[];let r=[];return e.descendants((e,t)=>{if(!e.isTextblock)return;let i=e.textContent;for(let e of i.matchAll(n)){let n=e.index??0;r.push({from:t+1+n,to:t+1+n+e[0].length})}}),r}function r4(e,t,n){if(t.length===0)return oz.empty;let r=[];for(let e=0;e<t.length;e++){let{from:i,to:a}=t[e];try{r.push(rz.inline(i,a,{class:e===n?`tandem-find-active`:`tandem-find-match`}))}catch{}}return oz.create(e,r)}function i4(e,t){if(e.length===0)return-1;for(let n=0;n<e.length;n++)if(e[n].from<=t&&t<=e[n].to)return n;for(let n=0;n<e.length;n++)if(e[n].from>t)return n;return 0}function a4(e,t,n){if(e.type===`close`)return $2;if(e.type===`find`){let t=e.opts,r=n4(n.doc,t),i=n.selection.from,a=i4(r,i);return{...t,matches:r,activeIndex:a,decoSet:r4(n.doc,r,a)}}if(e.type===`next`){let e=t.matches.length===0?-1:(t.activeIndex+1)%t.matches.length;return{...t,activeIndex:e,decoSet:r4(n.doc,t.matches,e)}}if(e.type===`prev`){let e=t.matches.length===0?-1:(t.activeIndex-1+t.matches.length)%t.matches.length;return{...t,activeIndex:e,decoSet:r4(n.doc,t.matches,e)}}return e}var o4=IV.create({name:`tandemFindReplace`,addProseMirrorPlugins(){return[new cm({key:Q2,state:{init:()=>$2,apply(e,t,n,r){let i=e.getMeta(Q2);if(i)return a4(i,t,r);if(!t.query)return t;if(e.docChanged){let e=n4(r.doc,t),n=r.selection.from,i=i4(e,n);return{...t,matches:e,activeIndex:i,decoSet:r4(r.doc,e,i)}}let a=r.selection.from,o=i4(t.matches,a);return o===t.activeIndex?t:{...t,activeIndex:o,decoSet:r4(r.doc,t.matches,o)}}},props:{decorations(e){return Q2.getState(e)?.decoSet??oz.empty}}})]},addCommands(){return{find:e=>({dispatch:t,tr:n})=>(t&&t(n.setMeta(Q2,{type:`find`,opts:e})),!0),findNext:()=>({dispatch:e,tr:t})=>(e&&e(t.setMeta(Q2,{type:`next`})),!0),findPrev:()=>({dispatch:e,tr:t})=>(e&&e(t.setMeta(Q2,{type:`prev`})),!0),findClose:()=>({dispatch:e,tr:t})=>(e&&e(t.setMeta(Q2,{type:`close`})),!0)}},addKeyboardShortcuts(){return{Escape:({editor:e})=>Q2.getState(e.state)?.query?(e.commands.findClose(),!0):!1}}});function s4(e){return Q2.getState(e)}function c4(e,t){let n=s4(e.state);if(!n||n.activeIndex<0||n.matches.length===0)return!1;let{from:r,to:i}=n.matches[n.activeIndex],a=e.state.tr.insertText(t,r,i).setMeta(Q2,{type:`next`});return e.dispatch(a),!0}async function l4(e,t,n){let r=0,i=!1;for(let a=0;a<50;a++){let o=s4(e.state);if(!o?.query||o.matches.length===0)break;let s=o.matches.slice(0,100);try{let i=e.state.tr;for(let e=s.length-1;e>=0;e--){let{from:n,to:r}=s[e];i=i.insertText(t,n,r)}e.dispatch(i),r+=s.length,n?.(r,r+(o.matches.length-s.length))}catch(e){i=!0,console.warn(`[find-replace] replaceAll chunk failed at pass`,a,e);break}if(s.length<100)break;await new Promise(e=>setTimeout(e,0))}return{replaced:r,partial:i}}var u4=new dm(`tandemHeadingCollapse`),d4=`tandem:headingCollapse:`;function f4(e){return!e||e.startsWith(`upload://`)?null:d4+e}function p4(e){let t=f4(e);if(!t)return new Set;try{let e=window.localStorage.getItem(t);if(!e)return new Set;let n=JSON.parse(e);return Array.isArray(n)?new Set(n.filter(e=>typeof e==`string`)):new Set}catch{return new Set}}function m4(e,t){let n=f4(e);if(n)try{t.size===0?window.localStorage.removeItem(n):window.localStorage.setItem(n,JSON.stringify(Array.from(t)))}catch{}}function h4(e){return e.trim().toLowerCase().replace(/\s+/g,` `)}function g4(e){let t=[],n=new Map;return e.descendants((r,i,a)=>{if(r.type.name!==`heading`)return!0;if(a!==e)return!1;let o=r.attrs.level??1,s=`${o}::${h4(r.textContent)}`,c=n.get(s)??0;n.set(s,c+1);let l=`${s}::${c}`;return t.push({pos:i,level:o,hash:l}),!1}),t}function _4(e,t,n,r){if(n.size===0)return n;let i=new Set(t.map(e=>e.hash));if(e.length===t.length){let i=[];for(let n=0;n<e.length;n++)e[n].hash!==t[n].hash&&i.push(n);if(i.length!==1)return n;let a=i[0],o=e[a].hash,s=t[a].hash;if(!n.has(o))return n;let c=new Set(n);return c.delete(o),c.add(s),m4(r,c),c}if(t.length>e.length||t.length===0)return n;let a=!1,o=new Set;for(let e of n)i.has(e)?o.add(e):a=!0;return a?(m4(r,o),o):n}function v4(e,t,n){return rz.widget(e+1,e=>{let r=document.createElement(`button`);return r.type=`button`,r.className=`tandem-heading-chevron`,r.dataset.testid=`heading-chevron`,r.dataset.headingHash=t,r.dataset.collapsed=String(n),r.setAttribute(`aria-label`,n?`Expand section`:`Collapse section`),r.setAttribute(`aria-expanded`,String(!n)),r.contentEditable=`false`,r.textContent=n?`▶`:`▼`,r.addEventListener(`mousedown`,e=>{e.preventDefault()}),r.addEventListener(`click`,n=>{n.stopPropagation(),n.preventDefault();let r=e.state.tr.setMeta(u4,{type:`toggle`,hash:t});e.dispatch(r)}),r},{side:-1,ignoreSelection:!0,stopEvent:()=>!0,key:`chevron:${t}:${n?`c`:`e`}`})}function y4(e,t,n){let r=t[n],i=e.content.size;for(let e=n+1;e<t.length;e++)if(t[e].level<=r.level){i=t[e].pos;break}let a=[];return e.forEach((e,t)=>{if(t>r.pos&&t<i){let n=t,r=t+e.nodeSize;a.push(rz.node(n,r,{class:`tandem-heading-collapsed-hidden`,style:`display: none;`}))}}),a}function b4(e,t,n){let r=[];for(let i=0;i<t.length;i++){let a=t[i],o=n.has(a.hash);try{r.push(v4(a.pos,a.hash,o)),o&&r.push(...y4(e,t,i))}catch{}}return r.length===0?oz.empty:oz.create(e,r)}var x4=IV.create({name:`tandemHeadingCollapse`,addOptions(){return{filePath:null}},addProseMirrorPlugins(){let e=this.options.filePath;return[new cm({key:u4,state:{init(t,n){let r=p4(e),i=g4(n.doc);return{collapsed:r,headings:i,decoSet:b4(n.doc,i,r),hasSeenContent:i.length>0}},apply(t,n,r,i){let a=t.getMeta(u4);if(a?.type===`toggle`){let t=new Set(n.collapsed);return t.has(a.hash)?t.delete(a.hash):t.add(a.hash),m4(e,t),{collapsed:t,headings:n.headings,decoSet:b4(i.doc,n.headings,t),hasSeenContent:n.hasSeenContent}}if(a?.type===`rehydrate`){let t=g4(i.doc),n=p4(e),r=new Set(t.map(e=>e.hash)),a=new Set;for(let e of n)r.has(e)&&a.add(e);return a.size!==n.size&&m4(e,a),{collapsed:a,headings:t,decoSet:b4(i.doc,t,a),hasSeenContent:!0}}if(!t.docChanged)return n;let o=g4(i.doc),s=n.hasSeenContent||o.length>0,c=n.collapsed;return n.hasSeenContent&&(c=_4(n.headings,o,n.collapsed,e)),{collapsed:c,headings:o,decoSet:b4(i.doc,o,c),hasSeenContent:s}}},view(e){let t=!1,n=null;function r(){t||n!==null||(n=requestAnimationFrame(()=>{if(n=null,t)return;let r=u4.getState(e.state);if(!r||r.headings.length===0)return;t=!0;let i=e.state.tr.setMeta(u4,{type:`rehydrate`}).setMeta(`addToHistory`,!1);e.dispatch(i)}))}return r(),{update(e){if(t)return;let n=u4.getState(e.state);!n||n.headings.length===0||r()},destroy(){n!==null&&cancelAnimationFrame(n)}}},props:{decorations(e){return u4.getState(e)?.decoSet??oz.empty}}})]}}),S4=new dm(`tandemSelectionDecoration`),C4=IV.create({name:`tandemSelectionDecoration`,addProseMirrorPlugins(){return[new cm({key:S4,props:{decorations(e){let{selection:t}=e;if(!(t instanceof Wp))return oz.empty;let{from:n,to:r}=t;return n===r?oz.empty:oz.create(e.doc,[rz.inline(n,r,{class:`tandem-selection-blurred`})])}}})]}});function w4(e){return e.chain().focus()}var T4={tag:`path`,attrs:{d:`M6 4.5h7M6 8h7M6 11.5h7`}},E4=[{id:`heading-1`,label:`Heading 1`,keywords:[`h1`,`heading`,`title`],hint:`h1`,icon:{kind:`glyph`,glyph:`H¹`},run:e=>w4(e).toggleHeading({level:1}).run()},{id:`heading-2`,label:`Heading 2`,keywords:[`h2`,`heading`,`subtitle`],hint:`h2`,icon:{kind:`glyph`,glyph:`H²`},run:e=>w4(e).toggleHeading({level:2}).run()},{id:`heading-3`,label:`Heading 3`,keywords:[`h3`,`heading`,`subheading`],hint:`h3`,icon:{kind:`glyph`,glyph:`H³`},run:e=>w4(e).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`}},T4]},run:e=>w4(e).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`}},T4]},run:e=>w4(e).toggleOrderedList().run()},{id:`task-list`,label:`Task list`,keywords:[`task`,`todo`,`checkbox`,`check`,`checklist`],hint:`todo`,icon:{kind:`svg`,els:[{tag:`path`,attrs:{d:`M3 3h10v10H3z`}},{tag:`path`,attrs:{d:`M5.5 8l2 2 3.5-4`}}]},run:e=>w4(e).toggleBulletList().updateAttributes(`listItem`,{checked:!1}).run()},{id:`quote`,label:`Quote`,keywords:[`blockquote`,`quote`],hint:`q`,icon:{kind:`svg`,els:[{tag:`path`,attrs:{d:`M3 6c0-1.5 1-2.5 2-2.5`}},{tag:`path`,attrs:{d:`M3 6v3h3V6z`}},{tag:`path`,attrs:{d:`M9 6c0-1.5 1-2.5 2-2.5`}},{tag:`path`,attrs:{d:`M9 6v3h3V6z`}}]},run:e=>w4(e).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:e=>w4(e).toggleCodeBlock().run()},{id:`horizontal-rule`,label:`Horizontal rule`,keywords:[`hr`,`divider`,`rule`,`separator`],hint:`hr`,icon:{kind:`glyph`,glyph:`—`},run:e=>w4(e).setHorizontalRule().run()}];function D4(e){let t=/(?:^|\s)\/([A-Za-z0-9 -]*)$/.exec(e);if(!t)return null;let n=t[1]??``;return{fromOffset:e.length-n.length-1,query:n}}function O4(e){let t=e.trim().toLowerCase();return t?E4.filter(e=>[e.label,...e.keywords].join(` `).toLowerCase().includes(t)):E4}var k4=[`popup-annotation-input`,`popup-note-submit`,`popup-comment-submit`,`popup-highlight-yellow`,`popup-highlight-green`,`popup-highlight-blue`,`popup-highlight-pink`];function A4(e){let t=document.querySelector(`[data-testid="${e}"]`);return t?document.activeElement===t:!1}function j4(e){for(let t of e)if(document.querySelector(`[data-testid="${t}"]`))return!0;return!1}function M4(){return typeof document>`u`?!1:!!(A4(`find-input`)||document.querySelector(`[data-testid="command-palette"]`)||j4(k4))}var N4=`http://www.w3.org/2000/svg`,P4=new dm(`tandemSlashCommand`);function F4(e){return`${e.from}:${e.to}:${e.query}`}function I4(e){if(!e.docChanged||e.getMeta(`y-sync$`))return!1;let t=e.getMeta(`uiEvent`);if(t===`paste`||t===`drop`||e.getMeta(`paste`))return!1;let n=e.selection.from,r=!1;return e.mapping.maps.forEach((t,i)=>{t.forEach((t,a,o,s)=>{s<=o||e.mapping.slice(i+1).map(s,-1)===n&&(r=!0)})}),r}function L4(e,t=0){if(M4())return null;let{selection:n}=e;if(!n.empty)return null;let r=n.$from,i=D4(r.parent.textBetween(0,r.parentOffset,`
244
+ `,`
245
+ `));if(!i)return null;let a=r.start()+i.fromOffset,o=r.pos,s=O4(i.query);return s.length===0?null:{from:a,to:o,query:i.query,selectedIndex:Math.min(t,s.length-1)}}function R4(e,t){let n=e.getMeta(P4);return n?n.type===`close`?{active:null,dismissedKey:t.active?F4(t.active):t.dismissedKey}:n.type===`select`&&t.active?{...t,active:{...t.active,selectedIndex:n.selectedIndex??t.active.selectedIndex}}:t:null}function z4(e){for(;e.firstChild;)e.removeChild(e.firstChild)}function B4(){let e=document.createElement(`div`);e.className=`tandem-slash-menu__hint`;for(let[t,n]of[[`↑↓`,`navigate`],[`↵`,`insert`],[`esc`,`close`]]){let r=document.createElement(`span`),i=document.createElement(`kbd`);i.textContent=t,r.appendChild(i),r.appendChild(document.createTextNode(` ${n}`)),e.appendChild(r)}return e}function V4(e){let t=document.createElement(`span`);if(t.className=`tandem-slash-menu__icon`,t.setAttribute(`aria-hidden`,`true`),e.kind===`glyph`)return t.textContent=e.glyph,t;let n=document.createElementNS(N4,`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(let t of e.els){let e=document.createElementNS(N4,t.tag);for(let[n,r]of Object.entries(t.attrs))e.setAttribute(n,r);n.appendChild(e)}return t.appendChild(n),t}function H4(e,t,n,r,i){let a=O4(t.query);z4(e),e.className=`tandem-floating-pill tandem-slash-menu`;let o=document.createElement(`div`);o.setAttribute(`role`,`listbox`),o.setAttribute(`aria-label`,`Slash commands`),a.forEach((e,n)=>{let a=document.createElement(`button`);a.type=`button`,a.role=`option`,a.id=`slash-command-${e.id}`,a.className=`tandem-slash-menu__item`,a.setAttribute(`aria-selected`,String(n===t.selectedIndex)),a.setAttribute(`aria-label`,e.label),a.dataset.commandId=e.id,a.appendChild(V4(e.icon));let s=document.createElement(`span`);s.className=`tandem-slash-menu__label`,s.textContent=e.label,a.appendChild(s);let c=document.createElement(`span`);c.className=`tandem-slash-menu__shortcut`,c.setAttribute(`aria-hidden`,`true`),c.textContent=e.hint,a.appendChild(c),a.addEventListener(`mouseenter`,()=>r(n)),a.addEventListener(`mousedown`,t=>{t.preventDefault(),i(e)}),o.appendChild(a)}),e.appendChild(o),e.appendChild(B4());let s=n.view.coordsAtPos(t.from);e.style.display=`block`,e.style.position=`fixed`,e.style.left=`${Math.max(8,s.left)}px`,e.style.top=`${s.bottom+8}px`}function U4(e,t){let n=O4(t.query)[t.selectedIndex];return n?(e.chain().focus().deleteRange({from:t.from,to:t.to}).run(),n.run(e),!0):!1}var W4=IV.create({name:`slashCommand`,addOptions(){return{onOpenChange:void 0}},addProseMirrorPlugins(){let e=this.editor,t=this.options.onOpenChange;return[new cm({key:P4,state:{init:()=>({active:null,dismissedKey:null}),apply(e,t,n,r){let i=R4(e,t);if(i)return i;let a=L4(r,t.active?.selectedIndex??0);return a&&!t.active&&!I4(e)||a&&F4(a)===t.dismissedKey?{active:null,dismissedKey:t.dismissedKey}:{active:a,dismissedKey:a?null:t.dismissedKey}}},props:{handleKeyDown(t,n){let r=P4.getState(t.state)?.active;if(!r)return!1;let i=O4(r.query);if(n.key===`ArrowDown`){n.preventDefault();let e=(r.selectedIndex+1)%i.length;return t.dispatch(t.state.tr.setMeta(P4,{type:`select`,selectedIndex:e})),!0}if(n.key===`ArrowUp`){n.preventDefault();let e=(r.selectedIndex-1+i.length)%i.length;return t.dispatch(t.state.tr.setMeta(P4,{type:`select`,selectedIndex:e})),!0}return n.key===`Enter`?(n.preventDefault(),U4(e,r)):n.key===`Escape`?(n.preventDefault(),t.dispatch(t.state.tr.setMeta(P4,{type:`close`})),!0):!1}},view(n){let r=document.createElement(`div`);r.dataset.testid=`slash-command-menu`,r.style.display=`none`,document.body.appendChild(r);let i=!1,a=e=>{e!==i&&(i=e,t?.(e))},o=()=>{r.style.display=`none`,z4(r),a(!1)},s=()=>{let t=P4.getState(n.state)?.active;if(!t){o();return}H4(r,t,e,e=>{n.dispatch(n.state.tr.setMeta(P4,{type:`select`,selectedIndex:e}))},r=>{e.chain().focus().deleteRange({from:t.from,to:t.to}).run(),r.run(e),o(),n.dispatch(n.state.tr.setMeta(P4,{type:`close`}))}),a(!0)};return s(),{update:s,destroy(){a(!1),r.remove()}}}})]}}),G4=H(`<div role="presentation" data-testid="editor-root"></div>`);function K4(e,t){A(t,!0);let n=new Set([...Ca].filter(e=>e!==`.docx`));function r(e,t){let r=t.includes(`\\`)?`\\`:`/`,i=e.indexOf(`#`),a=i>=0?e.slice(0,i):e;if(!a)return null;let o=a.match(/\.[^./\\]+$/),s=o?o[0].toLowerCase():``;if(!n.has(s))return null;let c=t.split(r);c.pop();let l=a.replace(/\//g,r).split(r),u=[...c];for(let e of l)e===`..`?u.length>0&&u.pop():e!==`.`&&u.push(e);return u.join(r)}let i=N(null),a=null,o=M(()=>t.format===`docx`),s=xv(),c=M(()=>s.settings.smartTypography),l=M(()=>s.settings.spellcheck);R(()=>{t.ydoc,t.provider;let e=B(c);if(!a)return;let n=new LU({element:a,extensions:[...KZ(),nG.configure({document:t.ydoc}),aG.configure({provider:t.provider,user:{name:Ij(),color:`var(--tandem-warning)`}}),I2.configure({ydoc:t.ydoc}),U2.configure({ydoc:t.ydoc}),x4.configure({filePath:kr(()=>t.currentFilePath??null)}),J2.configure({ydoc:t.ydoc}),Z2.configure({ydoc:t.ydoc}),W4.configure({onOpenChange:t.onSlashCommandMenuChange}),o4,C4,...e?[OG]:[]],editorProps:k2(kr(()=>B(l))),editable:kr(()=>!t.readOnly),autofocus:kr(()=>!t.readOnly)});P(i,n,!0),kr(()=>t.onEditorReady?.(n));let r=KG(n,{openHref:e=>{d(e)}});return()=>{kr(()=>t.onEditorReady?.(null)),r(),n.destroy(),B(i)===n&&P(i,null)}});let u;R(()=>{let e=B(i);if(!e)return;let n=t.readOnly;u!==n&&(u=n,e.setEditable(!n))}),R(()=>{let e=B(i);e&&e.setOptions({editorProps:k2(B(l))})}),R(()=>{let e=B(i);if(e)return Rj(t=>e.commands.updateUser({name:t}))}),R(()=>{let e=B(i);if(!e)return;let n=e.view.dom;n.querySelectorAll(`.tandem-annotation-active`).forEach(e=>{e.classList.remove(`tandem-annotation-active`)}),t.activeAnnotationId&&n.querySelectorAll(`[data-annotation-id="${CSS.escape(t.activeAnnotationId)}"]`).forEach(e=>{e.classList.add(`tandem-annotation-active`)})});async function d(e){if(!(!e||e.startsWith(`#`))){if(NG(e)){window.open(e,`_blank`,`noopener,noreferrer`);return}if(t.currentFilePath){let n=r(e,t.currentFilePath);if(n){let e=await Hh(n);e.ok||console.warn(`[tandem] Could not open linked file "${n}": ${e.error}`)}}}}async function f(e){let n=e.target.closest(`a[href]`);if(n){let t=n.getAttribute(`href`)??``;if(!t||t.startsWith(`#`))return;e.preventDefault(),await d(t);return}let r={highlight:2,comment:1,note:0},i=e.target.closest(`[data-annotation-id]`),a=null,o=-1/0;for(;i;){let e=i.getAttribute(`data-annotation-id`);if(e){let t=r[i.getAttribute(`data-annotation-type`)??``]??-1;t>o&&(o=t,a=e)}let t=i.parentElement;i=t?t.closest(`[data-annotation-id]`):null}a&&t.onAnnotationClick?t.onAnnotationClick(a):a||t.onClearAnnotation?.()}var p=G4();let m;da(p,e=>a=e,()=>a),z(()=>m=Hi(p,1,``,null,m,{"tandem-paged":B(o)})),V(`click`,p,f),U(e,p),j()}zr([`click`]);var q4=H(`<div data-testid="find-scope-pills" class="fr-scope svelte-1q9bff2"><span class="label svelte-1q9bff2">Scope</span> <button data-testid="find-scope-doc">This document</button> <button data-testid="find-scope-tabs">Open tabs</button></div>`),J4=H(`<div class="fr-msg error svelte-1q9bff2" role="alert"><span class="msg-ic svelte-1q9bff2" aria-hidden="true"><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"><path d="M12 9v4"></path><path d="M12 17h.01"></path><path d="M10.29 3.86l-8.16 14.14A2 2 0 0 0 3.84 21h16.32a2 2 0 0 0 1.71-3l-8.16-14.14a2 2 0 0 0-3.42 0z"></path></svg></span> <span> </span></div>`),Y4=H(`<div class="fr-msg warning svelte-1q9bff2" role="status"> </div>`),X4=H(`<div class="fr-xdoc-status svelte-1q9bff2">Searching…</div>`),Z4=H(`<div class="fr-xdoc-status svelte-1q9bff2">No matches in open tabs</div>`),Q4=H(`<div class="fr-xdoc-snip svelte-1q9bff2"> </div>`),$4=H(`<div class="fr-xdoc-row svelte-1q9bff2"><div class="fr-xdoc-name svelte-1q9bff2"> <span class="fr-xdoc-count svelte-1q9bff2"> </span></div> <!></div>`),e3=H(`<div data-testid="find-cross-doc-results" class="fr-xdoc svelte-1q9bff2"><!></div>`),t3=H(`<div class="fr-anchor svelte-1q9bff2"><div data-testid="find-replace-bar" role="dialog" tabindex="-1" aria-modal="false" aria-label="Find and replace"><div class="fr-find svelte-1q9bff2"><span class="ic svelte-1q9bff2" aria-hidden="true"><svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="7"></circle><path d="m20 20-3.5-3.5"></path></svg></span> <input data-testid="find-input" type="text" placeholder="Find in document…" aria-label="Find in document" autocomplete="off" class="svelte-1q9bff2"/> <span data-testid="find-match-count"> </span> <span class="esc svelte-1q9bff2" aria-hidden="true">Esc</span></div> <div class="fr-controls svelte-1q9bff2"><div class="nav-group svelte-1q9bff2"><button data-testid="find-prev-btn" class="fr-nav svelte-1q9bff2" title="Previous match (⇧↵)" aria-label="Previous match"><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="M18 15l-6-6-6 6"></path></svg></button> <button data-testid="find-next-btn" class="fr-nav svelte-1q9bff2" title="Next match (↵)" aria-label="Next match"><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 9l6 6 6-6"></path></svg></button></div> <div class="toggles svelte-1q9bff2"><button data-testid="find-case-toggle" title="Case sensitive">Aa</button> <button data-testid="find-word-toggle" title="Whole word">\\b</button> <button data-testid="find-regex-toggle" title="Regular expression">.*</button></div> <span class="spacer svelte-1q9bff2"></span> <button data-testid="find-replace-expand-btn" aria-label="Toggle replace row" title="Toggle replace"><svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true" class="svelte-1q9bff2"><path d="M6 9l6 6 6-6"></path></svg></button> <button data-testid="find-close-btn" class="fr-close svelte-1q9bff2" title="Close (Esc)" aria-label="Close find bar"><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></div> <div class="fr-replace svelte-1q9bff2"><span class="ic svelte-1q9bff2" aria-hidden="true"><svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path><path d="M14 2v6h6"></path><path d="M9 15l3 3 3-3"></path><path d="M12 12v6"></path></svg></span> <input data-testid="replace-input" type="text" placeholder="Replace with…" aria-label="Replace with" autocomplete="off" class="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 primary svelte-1q9bff2"><!></button></div> <!> <!> <!> <!> <div class="fr-footer svelte-1q9bff2"><span class="kgrp svelte-1q9bff2"><span class="key svelte-1q9bff2">↵</span>next</span> <span class="kgrp svelte-1q9bff2"><span class="key svelte-1q9bff2">⇧</span><span class="key svelte-1q9bff2">↵</span>prev</span> <span class="spacer svelte-1q9bff2"></span> <span class="kgrp svelte-1q9bff2">Esc to close</span></div></div></div>`);function n3(e,t){A(t,!0);let n=J(t,`tabs`,19,()=>[]),r=N(`doc`),i=N(ln([])),a=N(!1);R(()=>{n().length<=1&&B(r)===`tabs`&&(P(r,`doc`),P(i,[],!0),P(a,!1))});function o(e){let t=e.getXmlFragment(`default`),n=[];function r(e){if(e instanceof TE)n.push(e.toString());else{for(let t=0;t<e.length;t++){let n=e.get(t);(n instanceof TE||n instanceof bE)&&r(n)}e instanceof bE&&e.nodeName!==`text`&&n.push(` `)}}return r(t),n.join(``)}function s(e,t,n){let r=o(e),i=n?t:t.toLowerCase(),a=n?r:r.toLowerCase(),s=[],c=0,l=0;for(;(l=a.indexOf(i,l))!==-1;){if(c++,s.length<3){let e=Math.max(0,l-30),t=Math.min(r.length,l+i.length+30),n=r.slice(e,t).replace(/\s+/g,` `).trim();s.push((e>0?`…`:``)+n+(t<r.length?`…`:``))}l+=i.length}return{count:c,snippets:s}}let c;_a(()=>clearTimeout(c));function l(e,t){if(clearTimeout(c),!e){P(i,[],!0),P(a,!1);return}P(a,!0),c=setTimeout(()=>{let r=[];for(let i of n()){if(!i.ydoc)continue;let{count:n,snippets:a}=s(i.ydoc,e,t);n>0&&r.push({tabId:i.id,fileName:i.fileName,count:n,snippets:a})}P(i,r,!0),P(a,!1)},300)}let u=N(``),d=N(``),f=N(!1),p=N(!1),m=N(!1),h=N(null),g=N(!1),_=N(null),v=N(null),y=N(!1),b=N(0),x=M(()=>(B(b),t.editor?s4(t.editor.state):void 0)),S=M(()=>B(x)?.matches.length??0),C=M(()=>B(x)?.activeIndex??-1),w=M(()=>B(r)===`doc`&&!!B(u)&&B(S)===0&&!B(h)),ee=M(()=>B(r)!==`doc`||!B(u)?``:B(h)?`error`:B(S)===0?`0 matches`:`${B(C)+1} / ${B(S)}`),T=N(null),E=N(null);R(()=>{t.open&&B(T)?.focus()});let te=!1;R(()=>{let e=t.open&&!te;te=t.open,!(!e||!t.forceScope)&&(t.forceScope===`tabs`&&n().length>1?(P(r,`tabs`),l(B(u),B(f))):P(r,`doc`))}),R(()=>{if(!t.open)return;let e=t.editor;if(!e||e.isDestroyed)return;let n=()=>on(b);return e.on(`transaction`,n),()=>{e.isDestroyed||e.off(`transaction`,n)}});function ne(){if(B(r)===`tabs`){l(B(u),B(f));return}let e=t.editor;if(!e||!B(u)){P(h,null),e?.commands.findClose();return}if(B(m))try{new RegExp(B(u)),P(h,null)}catch(e){P(h,e instanceof Error?e.message:`Invalid regex`,!0);return}else P(h,null);let n={query:B(u),caseSensitive:B(f),wholeWord:B(p),regexMode:B(m)};e.commands.find(n)}function D(e){P(r,e,!0),e===`tabs`?(t.editor?.commands.findClose(),l(B(u),B(f))):(P(i,[],!0),clearTimeout(c),ne())}function re(){P(y,!B(y)),B(y)&&requestAnimationFrame(()=>B(E)?.focus())}function ie(e){if(e.key===`Enter`){e.preventDefault(),e.shiftKey?t.editor?.commands.findPrev():t.editor?.commands.findNext();return}if(e.key===`Escape`){if(e.preventDefault(),e.stopPropagation(),B(y)){P(y,!1),B(T)?.focus();return}ae()}}function ae(){P(y,!1),t.editor?.commands.findClose(),t.onClose()}async function oe(){let e=t.editor;if(!e||!B(u)||B(g))return;let n=B(S);if(n>500&&!window.confirm(`Replace all ${n} occurrences? This cannot be undone as a single action.`))return;P(g,!0),P(v,null),P(_,{replaced:0,total:n},!0);let{replaced:r,partial:i}=await l4(e.view,B(d),(e,t)=>{P(_,{replaced:e,total:t},!0)});P(_,null),P(g,!1),i&&P(v,`Replaced ${r} of ${n}; re-run to continue`)}var se=Yr(),ce=I(se),le=e=>{var o=t3(),s=F(o);let c;var l=F(s),x=L(F(l),2);Qi(x),da(x,e=>P(T,e),()=>B(T));var C=L(x,2);let te;var se=F(C,!0);O(C),k(2),O(l);var ce=L(l,2),le=F(ce),ue=F(le),de=L(ue,2);O(le);var fe=L(le,2),pe=F(fe);let me;var he=L(pe,2);let ge;var _e=L(he,2);let ve;O(fe);var ye=L(fe,4);let be;var xe=L(ye,2);O(ce);var Se=L(ce,2),Ce=L(F(Se),2);Qi(Ce),da(Ce,e=>P(E,e),()=>B(E));var we=L(Ce,2),Te=L(we,2),Ee=F(Te),De=e=>{var t=Jr();z(()=>W(t,`${B(_).replaced??``}/${B(_).total??``}`)),U(e,t)},Oe=e=>{U(e,Jr(`All`))};G(Ee,e=>{B(g)&&B(_)?e(De):e(Oe,-1)}),O(Te),O(Se);var ke=L(Se,2),Ae=e=>{var t=q4(),n=L(F(t),2);let i;var a=L(n,2);let o;O(t),z(()=>{i=Hi(n,1,`fr-scope-pill svelte-1q9bff2`,null,i,{on:B(r)===`doc`}),q(n,`aria-pressed`,B(r)===`doc`),o=Hi(a,1,`fr-scope-pill svelte-1q9bff2`,null,o,{on:B(r)===`tabs`}),q(a,`aria-pressed`,B(r)===`tabs`)}),V(`click`,n,()=>D(`doc`)),V(`click`,a,()=>D(`tabs`)),U(e,t)};G(ke,e=>{n().length>1&&e(Ae)});var je=L(ke,2),Me=e=>{var t=J4(),n=L(F(t),2),r=F(n,!0);O(n),O(t),z(()=>W(r,B(h))),U(e,t)};G(je,e=>{B(h)&&e(Me)});var Ne=L(je,2),Pe=e=>{var t=Y4(),n=F(t,!0);O(t),z(()=>W(n,B(v))),U(e,t)};G(Ne,e=>{B(v)&&e(Pe)});var Fe=L(Ne,2),Ie=e=>{var t=e3(),n=F(t),r=e=>{U(e,X4())},o=e=>{U(e,Z4())},s=e=>{var t=Yr();fi(I(t),17,()=>B(i),ci,(e,t)=>{var n=$4(),r=F(n),i=F(r),a=L(i),o=F(a);O(a),O(r),fi(L(r,2),17,()=>B(t).snippets,ci,(e,t)=>{var n=Q4(),r=F(n,!0);O(n),z(()=>W(r,B(t))),U(e,n)}),O(n),z(()=>{W(i,`${B(t).fileName??``} `),W(o,`(${B(t).count??``} ${B(t).count===1?`match`:`matches`})`)}),U(e,n)}),U(e,t)};G(n,e=>{B(a)?e(r):B(u)&&B(i).length===0?e(o,1):e(s,-1)}),O(t),U(e,t)};G(Fe,e=>{B(r)===`tabs`&&e(Ie)}),k(2),O(s),O(o),z(()=>{c=Hi(s,1,`fr svelte-1q9bff2`,null,c,{"no-match":B(w)}),te=Hi(C,1,`count svelte-1q9bff2`,null,te,{"no-match":B(w),err:!!B(h)}),W(se,B(ee)),ue.disabled=B(S)===0,de.disabled=B(S)===0,me=Hi(pe,1,`fr-toggle svelte-1q9bff2`,null,me,{on:B(f)}),q(pe,`aria-pressed`,B(f)),ge=Hi(he,1,`fr-toggle svelte-1q9bff2`,null,ge,{on:B(p)}),q(he,`aria-pressed`,B(p)),ve=Hi(_e,1,`fr-toggle svelte-1q9bff2`,null,ve,{on:B(m)}),q(_e,`aria-pressed`,B(m)),be=Hi(ye,1,`fr-expand svelte-1q9bff2`,null,be,{on:B(y)}),q(ye,`aria-expanded`,B(y)),q(Se,`hidden`,!B(y)),we.disabled=B(S)===0||B(g)||B(r)===`tabs`,q(we,`title`,B(r)===`tabs`?`Replace is not available in Open tabs mode`:void 0),Te.disabled=B(S)===0||B(g)||B(r)===`tabs`,q(Te,`title`,B(r)===`tabs`?`Replace All is not available in Open tabs mode`:void 0)}),V(`keydown`,s,ie),V(`input`,x,ne),ia(x,()=>B(u),e=>P(u,e)),V(`click`,ue,()=>t.editor?.commands.findPrev()),V(`click`,de,()=>t.editor?.commands.findNext()),V(`click`,pe,()=>{P(f,!B(f)),ne()}),V(`click`,he,()=>{P(p,!B(p)),ne()}),V(`click`,_e,()=>{P(m,!B(m)),ne()}),V(`click`,ye,re),V(`click`,xe,ae),ia(Ce,()=>B(d),e=>P(d,e)),V(`click`,we,()=>{t.editor&&(c4(t.editor.view,B(d)),on(b))}),V(`click`,Te,oe),U(e,o)};G(ce,e=>{t.open&&e(le)}),U(e,se),j()}zr([`keydown`,`input`,`click`]);var r3=H(`<div class="source-view-warning svelte-fwjuih" data-testid="source-view-annotation-warning" role="status"> </div>`),i3=H(`<div class="source-view-error svelte-fwjuih" data-testid="source-view-error" role="alert"> </div>`),a3=H(`<div class="source-view-loading svelte-fwjuih">Loading source…</div>`),o3=H(`<textarea class="source-view-textarea svelte-fwjuih" data-testid="source-view-textarea" spellcheck="false" autocomplete="off" autocapitalize="off" aria-label="Markdown source"></textarea>`),s3=H(`<div class="source-view svelte-fwjuih" data-testid="source-view-container"><div class="source-view-toolbar svelte-fwjuih"><button type="button" class="source-view-btn source-view-exit svelte-fwjuih" data-testid="source-view-exit-btn">← WYSIWYG</button> <span class="source-view-title svelte-fwjuih">Markdown source</span> <button type="button" class="source-view-btn svelte-fwjuih" data-testid="source-view-copy-btn">Copy</button></div> <!> <!> <!></div>`);function c3(e,t){A(t,!0);let n=kr(()=>t.initialDraft),r=N(``),i=N(``),a=N(!0),o=N(!1),s=N(null),c=M(()=>!B(a)&&B(i)!==B(r)),l=N(0);R(()=>{let e=t.ydoc.getMap(La),n=()=>{P(l,e.size,!0)};return n(),e.observe(n),()=>e.unobserve(n)}),R(()=>{let e=t.documentId,o=!1;return P(a,!0),P(s,null),(async()=>{try{let t=await fetch(`${Il}${Tc}?documentId=${encodeURIComponent(e)}`);if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.message??t.statusText)}let a=await t.json();if(o)return;P(r,a.markdown??``,!0),P(i,n??B(r),!0)}catch(e){if(o)return;P(s,e instanceof Error?e.message:`Failed to load markdown source.`,!0)}finally{o||P(a,!1)}})(),()=>{o=!0}});async function u(){P(o,!0),P(s,null);try{let e=await fetch(`${Il}${Ec}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({documentId:t.documentId,markdown:B(i)})});if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t.message??e.statusText)}return P(r,B(i),!0),t.onDraftChange(B(i),!1),!0}catch(e){return P(s,e instanceof Error?e.message:`Failed to apply markdown changes.`,!0),!1}finally{P(o,!1)}}function d(e){let n=e.target.value;t.onDraftChange(n,n!==B(r))}async function f(){B(c)&&!await u()||t.onExit()}async function p(e){(e.ctrlKey||e.metaKey)&&e.key.toLowerCase()===`s`&&(e.preventDefault(),e.stopPropagation(),B(c)&&!B(o)&&await u())}async function m(){try{await navigator.clipboard.writeText(B(i))}catch{}}var h=s3(),g=F(h),_=F(g),v=L(_,4);O(g);var y=L(g,2),b=e=>{var t=r3(),n=F(t);O(t),z(()=>W(n,`Editing the source clears this document's ${B(l)??``} annotation${B(l)===1?``:`s`} when you return to the editor.`)),U(e,t)};G(y,e=>{B(l)>0&&e(b)});var x=L(y,2),S=e=>{var t=i3(),n=F(t,!0);O(t),z(()=>W(n,B(s))),U(e,t)};G(x,e=>{B(s)&&e(S)});var C=L(x,2),w=e=>{U(e,a3())},ee=e=>{var t=o3();Tn(t),V(`input`,t,d),V(`keydown`,t,p),ia(t,()=>B(i),e=>P(i,e)),U(e,t)};G(C,e=>{B(a)?e(w):e(ee,-1)}),O(h),z(()=>{_.disabled=B(o),v.disabled=B(a)}),V(`click`,_,f),V(`click`,v,m),U(e,h),j()}zr([`click`,`input`,`keydown`]);function l3(e,t){function n(n){e.contains(n.target)||t(n)}return document.addEventListener(`mousedown`,n),{destroy(){document.removeEventListener(`mousedown`,n)}}}var u3=H(`<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),d3=H(`<div class="menu svelte-94a7fq" role="menu" aria-label="Decorations"><div class="menu-head svelte-94a7fq">Decorations</div> <p class="menu-help svelte-94a7fq">Inline editor overlays — author colors, comment, highlight, and note
246
+ marks. Toggle a type to hide its marks in the document; side-panel cards
247
+ stay.</p> <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>`),f3=H(`<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 p3(e,t){A(t,!0);let n=N(!1),r=N(null);function i(){t.onUpdate({decorationsMuted:!t.decorationsMuted})}function a(e,n){t.onUpdate({[e]:!n,...t.decorationsMuted?{decorationsMuted:!1}:{}})}function o(){P(n,!1),B(r)?.focus()}function s(e){e.key===`Escape`&&B(n)&&(e.stopPropagation(),o())}function c(){t.onOpenSettings?.(),P(n,!1)}var l=f3();let u;var d=F(l);let f;var p=L(d,4);da(p,e=>P(r,e),()=>B(r));var m=L(p,2),h=e=>{var n=d3(),r=L(F(n),4);let i;var o=L(r,2);let s;var l=L(o,2);let u;var d=L(l,2);let f;var p=L(d,2),m=e=>{var t=u3();V(`click`,L(I(t),2),c),U(e,t)};G(p,e=>{t.onOpenSettings&&e(m)}),O(n),z(()=>{i=Hi(r,1,`mi svelte-94a7fq`,null,i,{on:t.showAuthorship}),q(r,`aria-checked`,t.showAuthorship),s=Hi(o,1,`mi svelte-94a7fq`,null,s,{on:t.showComments}),q(o,`aria-checked`,t.showComments),u=Hi(l,1,`mi svelte-94a7fq`,null,u,{on:t.showHighlights}),q(l,`aria-checked`,t.showHighlights),f=Hi(d,1,`mi svelte-94a7fq`,null,f,{on:t.showNotes}),q(d,`aria-checked`,t.showNotes)}),V(`click`,r,()=>a(`showAuthorship`,t.showAuthorship)),V(`click`,o,()=>a(`showComments`,t.showComments)),V(`click`,l,()=>a(`showHighlights`,t.showHighlights)),V(`click`,d,()=>a(`showNotes`,t.showNotes)),U(e,n)};G(m,e=>{B(n)&&e(h)}),O(l),Ni(l,(e,t)=>l3?.(e,t),()=>()=>P(n,!1)),z(()=>{u=Hi(l,1,`split menu-wrap svelte-94a7fq`,null,u,{open:B(n)}),f=Hi(d,1,`ib half-main svelte-94a7fq`,null,f,{on:!t.decorationsMuted}),q(d,`aria-pressed`,!t.decorationsMuted),q(d,`title`,t.decorationsMuted?`Restore decorations`:`Mute decorations`),q(d,`aria-label`,t.decorationsMuted?`Restore decorations`:`Mute decorations`),q(p,`aria-expanded`,B(n))}),V(`keydown`,l,s),V(`click`,d,i),V(`click`,p,()=>P(n,!B(n))),U(e,l),j()}zr([`keydown`,`click`]);function m3(e,t,n,r={}){let{capture:i=!0}=r;function a(t){let r=e();r&&(t.target instanceof Node&&r.contains(t.target)||n(t))}for(let e of t)document.addEventListener(e,a,i);return()=>{for(let e of t)document.removeEventListener(e,a,i)}}function h3(e){let t=e.closest?.(`[data-tauri-drag-region]`);return!!t&&t.getAttribute(`data-tauri-drag-region`)!==`false`}function g3(e){return t=>{t.preventDefault(),e()}}function _3(e){let t=e.getAttributes(`link`).href;return t===void 0?``:typeof t==`string`?t:(console.warn(`[tandem] getInitialLinkHref: non-string href attribute`,{href:t}),``)}function v3(e,t){let n=t.trim();n?e.chain().focus().setLink({href:n}).run():e.isActive(`link`)&&e.chain().focus().unsetLink().run()}var y3=H(`<button type="button"><!></button>`);function b3(e,t){let n=J(t,`disabled`,3,!1),r=J(t,`active`,3,!1),i=J(t,`style`,3,``),a=M(()=>t.ariaLabel??(typeof t.label==`string`?t.label:void 0)),o=M(()=>B(a)??``),s=M(()=>n()&&t.disabledTitle?t.disabledTitle:t.shortcut?`${B(o)} (${t.shortcut})`:B(o));var c=y3();let l;var u=F(c),d=e=>{var n=Yr();yi(I(n),()=>t.children),U(e,n)},f=e=>{var n=Jr();z(()=>W(n,t.label)),U(e,n)};G(u,e=>{t.children?e(d):e(f,-1)}),O(c),z(()=>{l=Hi(c,1,`toolbar-btn svelte-xw5pw0`,null,l,{"is-active":r()}),q(c,`data-testid`,t.testId),c.disabled=n(),q(c,`title`,B(s)),q(c,`aria-label`,B(a)),q(c,`aria-pressed`,t.ariaPressed),q(c,`aria-haspopup`,t.ariaHasPopup),q(c,`aria-expanded`,t.ariaExpanded),K(c,i())}),V(`mousedown`,c,function(...e){t.onMouseDown?.apply(this,e)}),V(`click`,c,function(...e){t.onClick?.apply(this,e)}),U(e,c)}zr([`mousedown`,`click`]);var x3=qr(`<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>`),S3=qr(`<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>`),C3=H(`<!> <!> <div style="width: 1px; height: 16px; background: var(--tandem-border); margin: 0 2px;"></div>`,1),w3=qr(`<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>`),T3=H(`<div role="dialog" aria-label="Insert link" style="position: absolute; top: 100%; left: 0; margin-top: 4px;
248
+ background: var(--tandem-surface); border: 1px solid var(--tandem-border);
249
+ border-radius: var(--tandem-r-3); padding: 6px;
250
+ display: flex; align-items: center; gap: 4px;
251
+ 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;
252
+ border: 1px solid var(--tandem-border); border-radius: var(--tandem-r-2);
253
+ background: var(--tandem-surface); color: var(--tandem-fg);
254
+ 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;
255
+ border: 1px solid var(--tandem-accent-border); background: transparent;
256
+ color: var(--tandem-accent); border-radius: var(--tandem-r-2); cursor: pointer;
257
+ 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;
258
+ border: 1px solid var(--tandem-border); background: transparent;
259
+ color: var(--tandem-fg-muted); border-radius: var(--tandem-r-2); cursor: pointer;">Cancel</button></div>`),E3=H(`<span style="font-family: var(--tandem-font-serif); font-weight: 600; font-size: 13.5px; line-height: 1;"> </span> <span aria-hidden="true" style="color: var(--tandem-fg-faint); font-size: 10px; line-height: 1;">▾</span>`,1),D3=H(`<button type="button" role="menuitemradio"> </button>`),O3=H(`<div role="menu" aria-label="Heading level" style="position: absolute; top: 100%; left: 0; margin-top: 4px;
260
+ background: var(--tandem-surface); border: 1px solid var(--tandem-border);
261
+ border-radius: var(--tandem-r-3); padding: 4px; display: flex; flex-direction: column;
262
+ gap: 2px; z-index: var(--tandem-z-dropdown); box-shadow: var(--tandem-shadow-1);"></div>`),k3=qr(`<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>`),A3=qr(`<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>`),j3=qr(`<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>`),M3=qr(`<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>`),N3=H(`<div style="display: flex; align-items: center; gap: 1px;"><!> <!> <!> <!> <!> <div style="position: relative;" role="presentation"><!> <!></div> <div style="width: 1px; height: 16px; background: var(--tandem-border); margin: 0 2px;"></div> <div style="position: relative;" role="presentation"><!> <!></div> <!> <!> <!> <!> <!></div>`);function P3(e,t){A(t,!0);let n=J(t,`disabled`,3,!1),r=J(t,`variant`,3,`bar`),i=M(()=>r()===`bar`),a=M(()=>r()===`bar`),o=[1,2,3],s={1:700,2:600,3:500},c=N(0),l=N(!1),u=N(!1),d=N(``),f=N(null);R(()=>{let e=t.editor;if(!e||e.isDestroyed)return;let n=()=>{e.isDestroyed||on(c)};return e.on(`transaction`,n),()=>{e.isDestroyed||e.off(`transaction`,n)}}),R(()=>{B(u)&&(B(f)?.focus(),B(f)?.select())});function p(e){for(let t of o)if(e.isActive(`heading`,{level:t}))return t;return null}let m=M(()=>t.editor?t.editor.isEditable:!1),h=M(()=>!B(m)||!!n()),g=M(()=>(B(c),t.editor?ZU.getState(t.editor.state):null)),_=M(()=>!B(h)&&(B(g)?.undoManager?.undoStack.length??0)>0),v=M(()=>!B(h)&&(B(g)?.undoManager?.redoStack.length??0)>0),y=M(()=>(B(c),t.editor?p(t.editor):null)),b=M(()=>(B(c),!!t.editor?.isActive(`bold`))),x=M(()=>(B(c),!!t.editor?.isActive(`italic`))),S=M(()=>(B(c),!!t.editor?.isActive(`strike`))),C=M(()=>(B(c),!!t.editor?.isActive(`code`))),w=M(()=>(B(c),!!t.editor?.isActive(`bulletList`))),ee=M(()=>(B(c),!!t.editor?.isActive(`orderedList`))),T=M(()=>(B(c),!!t.editor?.isActive(`blockquote`))),E=M(()=>(B(c),!!t.editor?.isActive(`codeBlock`))),te=M(()=>(B(c),!!t.editor?.isActive(`link`))),ne=M(()=>(B(c),t.editor?B(h)||!t.editor.isActive(`link`)&&t.editor.state.selection.from===t.editor.state.selection.to:!0)),D=M(()=>B(y)?`H${B(y)}`:`H`),re=M(()=>g3(()=>t.editor?.commands.undo())),ie=M(()=>g3(()=>t.editor?.commands.redo())),ae=M(()=>g3(()=>t.editor?.chain().focus().toggleBold().run())),oe=M(()=>g3(()=>t.editor?.chain().focus().toggleItalic().run())),se=M(()=>g3(()=>t.editor?.chain().focus().toggleStrike().run())),ce=M(()=>g3(()=>t.editor?.chain().focus().toggleCode().run())),le=M(()=>g3(()=>t.editor?.chain().focus().toggleBulletList().run())),ue=M(()=>g3(()=>t.editor?.chain().focus().toggleOrderedList().run())),de=M(()=>g3(()=>t.editor?.chain().focus().toggleBlockquote().run())),fe=M(()=>g3(()=>t.editor?.chain().focus().setHorizontalRule().run())),pe=M(()=>g3(()=>t.editor?.chain().focus().toggleCodeBlock().run()));function me(e){return t=>{t.detail===0&&e(t)}}function he(e){return n=>{n.preventDefault(),!(!t.editor||t.editor.isDestroyed)&&(t.editor.chain().focus().toggleHeading({level:e}).run(),P(l,!1))}}function ge(e){e.preventDefault(),t.editor&&(P(d,_3(t.editor),!0),P(u,!0))}function _e(){t.editor&&(v3(t.editor,B(d)),ve())}function ve(){P(u,!1),P(d,``)}function ye(e){e.key===`Enter`?(e.preventDefault(),e.stopPropagation(),_e()):e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),ve())}var be=Yr(),xe=I(be),Se=e=>{var t=N3(),n=F(t),r=e=>{var t=C3(),n=I(t);{let e=e=>{U(e,x3())},t=M(()=>!B(_)),r=M(()=>me(B(re)));b3(n,{ariaLabel:`Undo`,shortcut:`Ctrl+Z`,get disabled(){return B(t)},get onMouseDown(){return B(re)},get onClick(){return B(r)},children:e,$$slots:{default:!0}})}var r=L(n,2);{let e=e=>{U(e,S3())},t=M(()=>!B(v)),n=M(()=>me(B(ie)));b3(r,{ariaLabel:`Redo`,shortcut:`Ctrl+Shift+Z`,get disabled(){return B(t)},get onMouseDown(){return B(ie)},get onClick(){return B(n)},children:e,$$slots:{default:!0}})}k(2),U(e,t)};G(n,e=>{B(i)&&e(r)});var c=L(n,2);{let e=M(()=>me(B(ae)));b3(c,{label:`B`,shortcut:`Ctrl+B`,get disabled(){return B(h)},get active(){return B(b)},get onMouseDown(){return B(ae)},get onClick(){return B(e)},style:`font-weight: 700;`})}var p=L(c,2);{let e=M(()=>me(B(oe)));b3(p,{label:`I`,shortcut:`Ctrl+I`,get disabled(){return B(h)},get active(){return B(x)},get onMouseDown(){return B(oe)},get onClick(){return B(e)},style:`font-style: italic;`})}var m=L(p,2);{let e=M(()=>me(B(se)));b3(m,{label:`S`,shortcut:`Ctrl+Shift+X`,get disabled(){return B(h)},get active(){return B(S)},get onMouseDown(){return B(se)},get onClick(){return B(e)},style:`text-decoration: line-through;`})}var g=L(m,2);{let e=M(()=>me(B(ce)));b3(g,{label:`<>`,shortcut:`Ctrl+E`,get disabled(){return B(h)},get active(){return B(C)},get onMouseDown(){return B(ce)},get onClick(){return B(e)},style:`font-family: monospace;`})}var be=L(g,2),xe=F(be);{let e=e=>{U(e,w3())},t=M(()=>B(te)||B(u)),n=M(()=>me(ge));b3(xe,{ariaLabel:`Link`,shortcut:`Ctrl+K`,get disabled(){return B(ne)},get active(){return B(t)},ariaHasPopup:`dialog`,get ariaExpanded(){return B(u)},onMouseDown:ge,get onClick(){return B(n)},children:e,$$slots:{default:!0}})}var Se=L(xe,2),Ce=e=>{var t=T3(),n=F(t);Qi(n),da(n,e=>P(f,e),()=>B(f));var r=L(n,2),i=M(()=>me(e=>{e.preventDefault(),_e()})),a=L(r,2),o=M(()=>me(e=>{e.preventDefault(),ve()}));O(t),V(`keydown`,n,ye),ia(n,()=>B(d),e=>P(d,e)),V(`mousedown`,r,e=>{e.preventDefault(),_e()}),V(`click`,r,function(...e){B(i)?.apply(this,e)}),V(`mousedown`,a,e=>{e.preventDefault(),ve()}),V(`click`,a,function(...e){B(o)?.apply(this,e)}),U(e,t)};G(Se,e=>{B(u)&&e(Ce)}),O(be),Ni(be,(e,t)=>l3?.(e,t),()=>ve);var we=L(be,4),Te=F(we);{let e=e=>{var t=E3(),n=I(t),r=F(n,!0);O(n),k(2),z(()=>W(r,B(D))),U(e,t)},t=M(()=>B(y)?`Heading ${B(y)}`:`Heading`),n=M(()=>B(y)!==null),r=M(()=>me(e=>{e.preventDefault(),P(l,!B(l))}));b3(Te,{get ariaLabel(){return B(t)},get disabled(){return B(h)},get active(){return B(n)},ariaHasPopup:`menu`,get ariaExpanded(){return B(l)},style:`gap: 2px; padding-right: 4px;`,onMouseDown:e=>{e.preventDefault(),P(l,!B(l))},get onClick(){return B(r)},children:e,$$slots:{default:!0}})}var Ee=L(Te,2),De=e=>{var t=O3();fi(t,20,()=>o,e=>e,(e,t)=>{let n=M(()=>he(t));var r=D3(),i=M(()=>me(B(n))),a=F(r);O(r),z(()=>{q(r,`aria-checked`,B(y)===t),K(r,`padding: 4px 12px; font-size: 13px; border: none;
263
+ border-radius: var(--tandem-r-2);
264
+ background: ${B(y)===t?`var(--tandem-accent-bg)`:`transparent`};
265
+ color: ${B(y)===t?`var(--tandem-accent)`:`var(--tandem-fg)`};
266
+ cursor: pointer; text-align: left;
267
+ font-weight: ${s[t]??``}; white-space: nowrap;`),W(a,`Heading ${t??``}`)}),V(`mousedown`,r,function(...e){B(n)?.apply(this,e)}),V(`click`,r,function(...e){B(i)?.apply(this,e)}),U(e,r)}),O(t),U(e,t)};G(Ee,e=>{B(l)&&e(De)}),O(we),Ni(we,(e,t)=>l3?.(e,t),()=>()=>P(l,!1));var Oe=L(we,2);{let e=e=>{U(e,k3())},t=M(()=>me(B(le)));b3(Oe,{ariaLabel:`Bullet list`,shortcut:`Ctrl+Shift+8`,get disabled(){return B(h)},get active(){return B(w)},get onMouseDown(){return B(le)},get onClick(){return B(t)},children:e,$$slots:{default:!0}})}var ke=L(Oe,2);{let e=e=>{U(e,A3())},t=M(()=>me(B(ue)));b3(ke,{ariaLabel:`Ordered list`,shortcut:`Ctrl+Shift+7`,get disabled(){return B(h)},get active(){return B(ee)},get onMouseDown(){return B(ue)},get onClick(){return B(t)},children:e,$$slots:{default:!0}})}var Ae=L(ke,2);{let e=e=>{U(e,j3())},t=M(()=>me(B(de)));b3(Ae,{ariaLabel:`Blockquote`,shortcut:`Ctrl+Shift+B`,get disabled(){return B(h)},get active(){return B(T)},get onMouseDown(){return B(de)},get onClick(){return B(t)},children:e,$$slots:{default:!0}})}var je=L(Ae,2),Me=e=>{{let t=M(()=>me(B(fe)));b3(e,{label:`—`,ariaLabel:`Horizontal rule`,get disabled(){return B(h)},get onMouseDown(){return B(fe)},get onClick(){return B(t)}})}};G(je,e=>{B(a)&&e(Me)});var Ne=L(je,2);{let e=e=>{U(e,M3())},t=M(()=>me(B(pe)));b3(Ne,{ariaLabel:`Code block`,get disabled(){return B(h)},get active(){return B(E)},get onMouseDown(){return B(pe)},get onClick(){return B(t)},children:e,$$slots:{default:!0}})}O(t),V(`keydown`,be,e=>{e.key===`Escape`&&ve()}),V(`keydown`,we,e=>{e.key===`Escape`&&P(l,!1)}),U(e,t)};G(xe,e=>{t.editor&&e(Se)}),U(e,be),j()}zr([`keydown`,`mousedown`,`click`]);function F3(e,t,n){let r=e.getMap(La),i=null,a;for(let[e,n]of r.entries())if(n.type===`highlight`&&n.range.from===t.from&&n.range.to===t.to&&n.author===`user`&&n.status===`pending`&&n.content===``){i=e,a=n.color;break}if(i===null){let i=lc(),a={id:i,author:`user`,type:`highlight`,audience:`private`,range:{from:t.from,to:t.to},content:``,status:`pending`,timestamp:Date.now(),color:n};return Dk(e,()=>r.set(i,a)),`added`}if(a===n)return Dk(e,()=>r.delete(i)),`removed`;let o=lc(),s={id:o,author:`user`,type:`highlight`,audience:`private`,range:{from:t.from,to:t.to},content:``,status:`pending`,timestamp:Date.now(),color:n};return Dk(e,()=>{r.delete(i),r.set(o,s)}),`recolored`}function I3(e,t){let n=e.getMap(La),r=[];for(let[e,i]of n.entries())i.type===`highlight`&&i.range.from===t.from&&i.range.to===t.to&&i.author===`user`&&i.status===`pending`&&i.content===``&&r.push(e);return r.length===0?`noop`:(Dk(e,()=>{for(let e of r)n.delete(e)}),`removed`)}function L3({anchorX:e,anchorY:t,toolbarHeight:n,toolbarWidth:r,viewportHeight:i,viewportWidth:a,previousPlacement:o}){let s=Math.max(8,a-8-r),c=t+6,l=c+n,u=t-6-n,d=i-8,f=l<=(o===`below`?d+4:d-4),p=u>=48,m=Math.max(48,i-n-8),h,g;f?(h=c,g=`below`):p?(h=u,g=`above`):(h=m,g=`below`);let _=i-(t-6);return{left:Math.min(Math.max(e,8),s),top:Math.min(Math.max(h,48),m),bottom:_,placement:g}}function R3(e,t){return e.on(`selectionUpdate`,t),()=>e.off(`selectionUpdate`,t)}var z3=H(`<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),B3=H(`<div style="width: 1px; height: 18px; background: var(--tandem-border); margin: 0 3px; flex-shrink: 0;"></div> <button type="button" data-testid="popup-show-formatbar-btn" style="height: 26px; min-width: 26px; padding: 0 6px; border: 1px solid transparent; background: transparent; color: var(--tandem-fg-muted); border-radius: var(--tandem-r-pill); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0;"><svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path></path></svg></button>`,1),V3=H(`<button type="button"></button>`),H3=H(`<div role="toolbar" aria-label="Selection tools"><div><div class="morph-block-inner svelte-1tvmluw"><div class="popup-format-col svelte-1tvmluw" role="presentation"><div class="pill-row tandem-floating-pill svelte-1tvmluw" data-testid="popup-format-row"><!> <!> <!></div> <div class="pill-row tandem-floating-pill svelte-1tvmluw" data-testid="popup-annotate-row"><div style="display: inline-flex; gap: 3px; padding: 0 4px;" aria-label="Highlight colors"><button type="button" data-testid="popup-highlight-none" aria-label="No highlight" title="No highlight" style="width: 16px; height: 16px; border-radius: var(--tandem-r-2); border: 1px solid var(--tandem-border); background: var(--tandem-surface); cursor: pointer; padding: 0; display: inline-flex; align-items: center; justify-content: center;"><svg viewBox="0 0 16 16" width="12" height="12" aria-hidden="true"><line x1="3.5" y1="12.5" x2="12.5" y2="3.5" stroke="var(--tandem-fg-muted)" stroke-width="1.5" stroke-linecap="round"></line></svg></button> <!></div> <div style="width: 1px; height: 18px; background: var(--tandem-border); margin: 0 3px;"></div> <button type="button" data-testid="popup-annotate-btn" aria-label="Annotate" style="height: 24px; padding: 0 12px; border: 1px solid var(--tandem-author-user); background: transparent; color: var(--tandem-author-user); border-radius: var(--tandem-r-pill); font-size: 12px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 5px;"><svg viewBox="0 0 24 24" width="12" height="12" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 20h9"></path><path d="M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4z"></path></svg> Annotate</button></div></div></div></div> <div><div class="morph-block-inner svelte-1tvmluw"><div class="composer-card svelte-1tvmluw"><textarea data-testid="popup-annotation-input" aria-label="Annotation text" placeholder="Write a note or instruction..." class="composer-input svelte-1tvmluw"></textarea> <div class="composer-actions svelte-1tvmluw"><button type="button" class="composer-btn composer-btn-note svelte-1tvmluw" data-testid="popup-note-submit" aria-label="Note to self (Alt+Enter)">Note to self <kbd class="composer-kbd svelte-1tvmluw"> </kbd></button> <button type="button" class="composer-btn composer-btn-send svelte-1tvmluw" data-testid="popup-comment-submit"> <kbd class="composer-kbd svelte-1tvmluw"> </kbd></button></div></div></div></div></div>`);function U3(e,t){A(t,!0);let n=J(t,`selectionToolbar`,3,!0),r=J(t,`suppressSelectionToolbar`,3,!1),i=J(t,`requestCommentFocus`,3,0),a=J(t,`showAuthorship`,3,!0),o=J(t,`showComments`,3,!0),s=J(t,`showHighlights`,3,!0),c=J(t,`showNotes`,3,!0),l=J(t,`decorationsMuted`,3,!1),u=J(t,`formattingBarVisible`,3,!0),d=J(t,`reduceMotion`,3,!1),f=bD(xv()),p=N(!1),m=N(null),h=N(null),g=N(``),_=N(null),v=N(null),y=N(!1),b=N(!1),x=N(!1),S,C,w=-1,ee=-1,T=!1,E=0,te=0,ne=0,D=0,re=null,ie=null,ae=!1;function oe(){re=T?E:ne,ie=T?te:D,!Ov(d())&&(P(x,!0),clearTimeout(C),C=setTimeout(()=>{P(x,!1)},440))}function se(){clearTimeout(S),clearTimeout(C),P(b,!1),P(x,!1),w=-1,ee=-1,re=null,ie=null,T=!1}function ce(e,t,n){w=e,ee=t,T=n,clearTimeout(S),S=setTimeout(()=>{oe(),P(b,!0)},100)}let le=il(),ue=le?`⌥⏎`:`Alt+⏎`,de=le?`⌘⏎`:`Ctrl+⏎`,fe=M(()=>{let e=B(m);if(!e)return``;let t=e.placement===`above`?`bottom: ${e.bottom}px; top: auto;`:`top: ${e.top}px; bottom: auto;`;return`left: ${e.left}px; ${t}`}),pe=N(0),me=N(ln(window.innerHeight)),he=N(ln(window.innerWidth)),ge=Object.keys(Da),_e=M(()=>!!t.editor&&!!t.ydoc&&B(p)),ve=M(()=>n()&&!r()&&B(_e)&&B(m)!==null&&B(b)),ye=M(()=>B(g).trim()),be,xe=0,Se=0;function Ce(e){let{from:t,to:n}=e.state.selection,r=t!==n;if(P(p,r),!r){P(m,null),be=void 0,Se=0,se(),document.activeElement!==B(v)&&P(y,!1);return}!B(b)&&!ae&&(t!==w||n!==ee)&&ce(t,n,!1);try{let t=e.view.coordsAtPos(e.state.selection.head);ne=t.left,D=t.bottom;let n=L3({anchorX:re??ne,anchorY:ie??D,toolbarHeight:200,toolbarWidth:B(pe),viewportHeight:B(me),viewportWidth:B(he),previousPlacement:be});if(be=n.placement,Se=0,B(m)&&B(m).left===n.left&&B(m).top===n.top&&B(m).bottom===n.bottom&&B(m).placement===n.placement)return;P(m,{left:n.left,top:n.top,bottom:n.bottom,placement:n.placement},!0)}catch{if(Se>=3){Se=0,P(m,null),be=void 0;return}Se+=1,cancelAnimationFrame(xe),xe=requestAnimationFrame(()=>{e.isDestroyed||Ce(e)})}}R(()=>{if(!t.editor)return;let e=t.editor;function n(){Ce(e)}let r=e.view.dom,i=r.ownerDocument;function a(e){e.button!==0||!e.isPrimary||(ae=!0)}function o(t){if(!ae)return;ae=!1,E=t.clientX,te=t.clientY;let{from:n,to:r}=e.state.selection;n!==r&&!B(b)&&ce(n,r,!0)}function s(){ae=!1}r.addEventListener(`pointerdown`,a),i.addEventListener(`pointerup`,o),i.addEventListener(`pointercancel`,s);let c=R3(e,n);return n(),()=>{r.removeEventListener(`pointerdown`,a),i.removeEventListener(`pointerup`,o),i.removeEventListener(`pointercancel`,s),cancelAnimationFrame(xe),xe=0,clearTimeout(S),clearTimeout(C),c()}}),R(()=>{if(!t.editor||!B(m))return;let e=t.editor,n=0;function r(){cancelAnimationFrame(n),n=requestAnimationFrame(()=>{P(me,window.innerHeight,!0),P(he,window.innerWidth,!0),Ce(e)})}window.addEventListener(`resize`,r);let i=!1;requestAnimationFrame(()=>{i=!0});let a=m3(()=>B(h),[`scroll`],()=>{i&&document.activeElement!==B(v)&&Ae()});return()=>{cancelAnimationFrame(n),window.removeEventListener(`resize`,r),a()}}),R(()=>{let e=t.editor,n=B(h);if(!e||!n||!B(m))return;let r=B(x),i=()=>{if(document.activeElement!==B(v)){if(B(x)){B(pe)===0&&(P(pe,n.scrollWidth,!0),Ce(e));return}P(pe,n.getBoundingClientRect().width,!0),Ce(e)}};r||i();let a=new ResizeObserver(i);return a.observe(n),()=>a.disconnect()}),R(()=>{B(ve)&&!B(_)&&Ee(),B(ve)||(P(_,null),document.activeElement!==B(v)&&P(g,``))});let we=0;R(()=>{if(i()===we||(we=i(),i()===0||!t.editor))return;let{from:e,to:n}=t.editor.state.selection;e!==n&&(kr(()=>Ee()),P(y,!0),P(b,!0),oe(),requestAnimationFrame(()=>B(v)?.focus()))}),R(()=>{if(!t.editor||!B(ve))return;let e=t.editor,n=()=>{document.activeElement!==B(v)&&Ee()};return e.on(`selectionUpdate`,n),()=>{e.isDestroyed||e.off(`selectionUpdate`,n)}}),R(()=>{if(!B(ve))return;function e(e){e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),Ae())}return window.addEventListener(`keydown`,e,{capture:!0}),()=>window.removeEventListener(`keydown`,e,{capture:!0})});function Te(e,n,r){if(!t.editor||!t.ydoc||e!==`highlight`&&!n.trim())return;let{from:i,to:a}=B(_)??t.editor.state.selection;if(i===a)return;let o=DD(t.editor.state.doc,So(i)),s=DD(t.editor.state.doc,So(a)),c=lc(),l={id:c,author:`user`,type:e,audience:e===`highlight`||e===`note`?`private`:`outbound`,range:{from:o,to:s},content:n,status:`pending`,timestamp:Date.now(),...r?.color?{color:r.color}:{}};return Dk(t.ydoc,()=>t.ydoc.getMap(La).set(c,l)),P(_,null),c}function Ee(){if(!t.editor)return;let{from:e,to:n}=t.editor.state.selection;P(_,{from:e,to:n},!0)}function De(e){if(!t.editor||!t.ydoc)return;let{from:n,to:r}=B(_)??t.editor.state.selection;if(n===r)return;let i=DD(t.editor.state.doc,So(n)),a=DD(t.editor.state.doc,So(r));F3(t.ydoc,{from:i,to:a},e),P(_,null),t.editor.chain().setTextSelection(r).run()}function Oe(){if(!t.editor||!t.ydoc)return;let{from:e,to:n}=B(_)??t.editor.state.selection;if(e===n)return;let r=DD(t.editor.state.doc,So(e)),i=DD(t.editor.state.doc,So(n));I3(t.ydoc,{from:r,to:i}),P(_,null),t.editor.chain().setTextSelection(n).run()}function ke(e){return t=>{t.detail===0&&e(t)}}function Ae(){P(p,!1),P(m,null),P(_,null),P(g,``),P(y,!1),se(),t.editor?.chain().focus().run()}function je(){P(y,!0),requestAnimationFrame(()=>B(v)?.focus())}function Me(){if(!B(ye))return;let e=B(h)?.getBoundingClientRect(),t=Te(`comment`,B(ye));t&&e&&Lv(t,e),window.dispatchEvent(new CustomEvent(`tandem:addressed-ai`,{detail:{via:`comment`}})),Ae()}function Ne(){if(!B(ye))return;let e=B(h)?.getBoundingClientRect(),t=Te(`note`,B(ye));t&&e&&Lv(t,e),Ae()}function Pe(e){e.key===`Enter`&&e.altKey?(e.preventDefault(),Ne()):e.key===`Enter`&&(e.metaKey||e.ctrlKey)?(e.preventDefault(),Me()):e.key===`Escape`&&(e.preventDefault(),Ae())}var Fe=Yr(),Ie=I(Fe),Le=e=>{var n=H3();let r;var i=F(n);let p;var _=F(i),b=F(_),x=F(b),S=F(x);P3(S,{get editor(){return t.editor},variant:`popup`});var C=L(S,2),w=e=>{var n=z3(),r=L(I(n),2);p3(F(r),{get showAuthorship(){return a()},get showComments(){return o()},get showHighlights(){return s()},get showNotes(){return c()},get decorationsMuted(){return l()},get onUpdate(){return t.onUpdateDecorations},get onOpenSettings(){return t.onOpenSettings}}),O(r),V(`mousedown`,r,e=>e.preventDefault()),U(e,n)};G(C,e=>{t.onUpdateDecorations&&e(w)});var ee=L(C,2),T=e=>{var n=B3(),r=L(I(n),2),i=M(()=>ke(()=>t.onToggleFormattingBar?.())),a=F(r),o=F(a);O(a),O(r),z(()=>{q(r,`aria-label`,u()?`Hide formatting bar`:`Show formatting bar`),q(r,`title`,u()?`Hide formatting bar`:`Show formatting bar`),q(o,`d`,u()?`m18 15-6-6-6 6`:`m6 9 6 6 6-6`)}),V(`mousedown`,r,e=>{e.preventDefault(),t.onToggleFormattingBar?.()}),V(`click`,r,function(...e){B(i)?.apply(this,e)}),U(e,n)};G(ee,e=>{t.onToggleFormattingBar&&e(T)}),O(x);var E=L(x,2),te=F(E),ne=F(te),D=M(()=>ke(()=>{Oe(),t.editor?.chain().focus().run()}));fi(L(ne,2),17,()=>ge,ci,(e,n)=>{var r=V3(),i=M(()=>ke(()=>{De(B(n)),t.editor?.chain().focus().run()}));z(()=>{q(r,`data-testid`,`popup-highlight-${B(n)}`),q(r,`aria-label`,`Highlight ${B(n)}`),q(r,`title`,`Highlight ${B(n)}`),K(r,`width: 16px; height: 16px; border-radius: var(--tandem-r-2); border: 1px solid var(--tandem-border); background: ${Oa[B(n)]}; cursor: pointer; padding: 0;`)}),V(`mousedown`,r,e=>{e.preventDefault(),De(B(n)),t.editor?.chain().focus().run()}),V(`click`,r,function(...e){B(i)?.apply(this,e)}),U(e,r)}),O(te);var re=L(te,4),ie=M(()=>ke(()=>je()));O(E),O(b),O(_),O(i);var ae=L(i,2);let oe;var se=F(ae),ce=F(se),le=F(ce);Tn(le),q(le,`rows`,1),da(le,e=>P(v,e),()=>B(v));var pe=L(le,2),me=F(pe),he=L(F(me)),_e=F(he,!0);O(he),O(me);var ve=L(me,2),be=F(ve),xe=L(be),Se=F(xe,!0);O(xe),O(ve),O(pe),O(ce),O(se),O(ae),O(n),da(n,e=>P(h,e),()=>B(h)),z(()=>{r=Hi(n,1,`tandem-floating-pill selection-popup svelte-1tvmluw`,null,r,{"is-annotate":B(y),"is-below":B(m).placement===`below`}),K(n,B(fe)),p=Hi(i,1,`morph-block morph-format svelte-1tvmluw`,null,p,{"is-active":!B(y)}),i.inert=B(y),oe=Hi(ae,1,`morph-block morph-annotate svelte-1tvmluw`,null,oe,{"is-active":B(y)}),ae.inert=!B(y),q(me,`title`,`Note to self — private, not sent to ${f.family??``} (Alt+Enter)`),me.disabled=!B(ye),W(_e,ue),q(ve,`aria-label`,`Send to ${f.family??``} (Ctrl+Enter)`),q(ve,`title`,`Send to ${f.family??``} — outbound comment (Ctrl/Cmd+Enter)`),ve.disabled=!B(ye),W(be,`Send to ${f.family??``} `),W(Se,de)}),V(`mousedown`,b,e=>e.preventDefault()),V(`mousedown`,ne,e=>{e.preventDefault(),Oe(),t.editor?.chain().focus().run()}),V(`click`,ne,function(...e){B(D)?.apply(this,e)}),V(`mousedown`,re,e=>{e.preventDefault(),je()}),V(`click`,re,function(...e){B(ie)?.apply(this,e)}),V(`keydown`,le,Pe),ia(le,()=>B(g),e=>P(g,e)),V(`click`,me,Ne),V(`click`,ve,Me),ji(1,n,()=>Uv,()=>({reduceMotion:d()})),U(e,n)};G(Ie,e=>{B(ve)&&B(m)&&e(Le)}),U(e,Fe),j()}zr([`mousedown`,`click`,`keydown`]);function W3(e,t=document.documentElement){let n=Math.max(0,Math.min(360,Math.round(e)));return t.style.setProperty(`--tandem-accent-h`,`${n}deg`),()=>t.style.removeProperty(`--tandem-accent-h`)}function G3(e){R(()=>W3(e()))}var K3=8e3;function q3(e){let t=N(null),n=N(!1),r=N(!1),i=0,a=0,o=!1;async function s(e){let n;try{n=await fetch(`${Il}${zc}`)}catch{return}if(e===i&&n.ok)try{P(t,await n.json(),!0),P(r,!0)}catch{}}async function c(){let e;try{e=await fetch(`${Il}${gc}`)}catch{return null}if(!e.ok)return null;try{let t=await e.json();return typeof t.hasSession==`boolean`?t.hasSession:null}catch{return null}}async function l(){let e=++a,t=await c();return t!==null&&e===a&&!o&&P(n,t,!0),t}async function u(){return await l()??B(n)}function d(){s(++i),l()}d();let f=setInterval(()=>d(),K3);_a(()=>{i++,o=!0,clearInterval(f)});let p=M(()=>!e.firstRunSettled()||!e.connected()||!B(r)||B(t)===null?`booting`:B(n)?`ready`:B(t).available===!1?`unconfigured`:B(t).running===!0?`ready`:`stopped`),m=M(()=>e.soloMode()?null:B(p)===`unconfigured`?`connect`:B(p)===`stopped`?`restart`:null);return{get state(){return B(p)},get chip(){return B(m)},refresh:()=>d(),probeSession:u}}function J3(e,t=document.documentElement){return e?t.setAttribute(`data-annotation-patterns`,`true`):t.removeAttribute(`data-annotation-patterns`),()=>t.removeAttribute(`data-annotation-patterns`)}function Y3(e){R(()=>J3(e()))}function X3(e){let t=N(ln(new Map));return R(()=>{let n=e.getYdoc();if(!n){B(t).size>0&&P(t,new Map,!0);return}let r=n.getMap(Wa),i=()=>{P(t,Z3(r),!0)};return i(),r.observe(i),()=>r.unobserve(i)}),{get byId(){return B(t)}}}function Z3(e){let t=new Map;e.forEach(e=>{let n=e;if(!n||typeof n!=`object`||!n.annotationId)return;let r=t.get(n.annotationId)??[];r.push(n),t.set(n.annotationId,r)});for(let e of t.values())e.sort((e,t)=>e.timestamp-t.timestamp);return t}var Q3=25;function $3(e=Q3){let t=ln([]);return{push(n){if(!(t.length&&t[t.length-1].filePath===n.filePath))for(t.push(n);t.length>e;)t.shift()},pop(){return t.pop()??null},peek(){return t.length?t[t.length-1]:null},get top(){return t.length?t[t.length-1]:null},size(){return t.length},clear(){t.length=0}}}function e6(e,t=()=>Ea){let n=N(!1),r=N(!1);return R(()=>{let i=e();if(i==null){P(n,!1),P(r,!1);return}let a=Date.now()-i,o=t()-a;if(o<=0){P(n,!0);return}let s=setTimeout(()=>{P(n,!0)},o);return()=>clearTimeout(s)}),{get showBanner(){return B(n)&&!B(r)},dismiss(){P(r,!0)}}}function t6(e,t=document.documentElement){return t.setAttribute(`data-density`,e),()=>t.removeAttribute(`data-density`)}function n6(e){R(()=>t6(e()))}function r6(e){let t=Na[e];try{let e=localStorage.getItem(t);if(e){let n=parseInt(e,10);if(Number.isFinite(n))return Math.max(200,Math.min(600,n));console.warn(`[tandem] ignoring non-numeric panel width for ${t}: ${e}`)}}catch(e){console.warn(`[tandem] localStorage unavailable reading ${t}:`,e)}return 300}function i6(e){let{side:t}=e,n=Na[t],r=N(ln(e.initialWidth)),i=null;return R(()=>{!e.getVisible()&&i&&(document.removeEventListener(`mousemove`,i.move),document.removeEventListener(`mouseup`,i.up),i=null,document.body.style.userSelect=``,document.body.style.cursor=``)}),R(()=>()=>{i&&=(document.removeEventListener(`mousemove`,i.move),document.removeEventListener(`mouseup`,i.up),document.body.style.userSelect=``,document.body.style.cursor=``,null)}),{get width(){return B(r)},handleResizeStart:a=>{a.preventDefault();let o=a.clientX,s=B(r),c=s;document.body.style.userSelect=`none`,document.body.style.cursor=`col-resize`;let l=e=>{let n=e.clientX-o,i=t===`left`?s+n:s-n;c=Math.max(200,Math.min(600,i)),P(r,c,!0)},u=()=>{if(document.removeEventListener(`mousemove`,l),document.removeEventListener(`mouseup`,u),i=null,document.body.style.userSelect=``,document.body.style.cursor=``,e.getVisible())try{localStorage.setItem(n,String(c))}catch(e){console.warn(`[tandem] failed to persist ${n}:`,e)}};i={move:l,up:u},document.addEventListener(`mousemove`,l),document.addEventListener(`mouseup`,u)},handleResizeStep:t=>{let i=Math.max(200,Math.min(600,B(r)+t));if(P(r,i,!0),e.getVisible())try{localStorage.setItem(n,String(i))}catch(e){console.warn(`[tandem] failed to persist ${n}:`,e)}}}}var a6={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 o6(e){let t=document.documentElement;return t.style.setProperty(`--tandem-editor-font-family`,a6[e]),()=>t.style.removeProperty(`--tandem-editor-font-family`)}function s6(e){R(()=>o6(e()))}function c6(){let e=N(!1);return{get fileDragOver(){return B(e)},handleEditorDragOver:t=>{nh()||t.dataTransfer?.types.includes(`Files`)&&(t.preventDefault(),P(e,!0))},handleEditorDragLeave:t=>{nh()||(t.currentTarget===t.target||!t.currentTarget.contains(t.relatedTarget))&&P(e,!1)},handleEditorDrop:async t=>{if(nh()||(P(e,!1),!t.dataTransfer?.files.length))return;t.preventDefault();let n=t.dataTransfer.files[0],r=await zl(n);try{let e=await fetch(`${Il}${xc}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({fileName:n.name,content:r})});if(!e.ok){let t=await e.json().catch(()=>({message:`Upload failed`}));console.error(`[useFileDrop] Upload failed:`,e.status,t.message??t.error)}}catch{console.error(`[useFileDrop] Server unreachable — file drop ignored`)}}}}function l6(e){return!!e?.query}function u6(){let e=N(null),t=N(null),n=N(null),r=N(!1),i=0;async function a(){let a=++i;try{let o=await fetch(`${Il}${vg}`);if(!o.ok)return a===i?(P(e,!1),P(t,null),P(n,null),P(r,!0),!1):!1;let s=await o.json();return a===i?(P(e,s.needed===!0),P(t,typeof s.serverVersion==`string`?s.serverVersion:null,!0),P(n,typeof s.confirmationNonce==`string`?s.confirmationNonce:null,!0),P(r,!0),!0):!1}catch{return a===i?(P(e,!1),P(t,null),P(n,null),P(r,!0),!1):!1}}return a(),{get needed(){return B(e)},get serverVersion(){return B(t)},get confirmationNonce(){return B(n)},get settled(){return B(r)},refetch:a}}function d6(e,t=document.documentElement){return e?t.setAttribute(`data-high-contrast`,`true`):t.removeAttribute(`data-high-contrast`),()=>t.removeAttribute(`data-high-contrast`)}function f6(e){R(()=>d6(e()))}function p6(e,t,n,r){let i=new Map,a=0,o=0;for(let s of e){let e=t(s);if(e){a++;try{let t=n(e.from);if(!Number.isFinite(t.top))continue;i.set(s.id,t.top-r())}catch{o++}}}return{positions:i,attempted:a,thrown:o}}function m6(e){let t=null;return{schedule(){t===null&&(t=requestAnimationFrame(()=>{t=null,e()}))},cancel(){t!==null&&(cancelAnimationFrame(t),t=null)}}}function h6(e){let t=N(ln(new Map));function n(){if(!e.getEnabled()){B(t).size>0&&P(t,new Map,!0);return}let n=e.getEditor(),r=e.getLayerEl(),i=e.getYdoc();if(!n||!r||!i){B(t).size>0&&P(t,new Map,!0);return}let{positions:a,attempted:o,thrown:s}=p6(e.getAnnotations(),e=>jD(e,n.state.doc,i),e=>n.view.coordsAtPos(e),()=>r.getBoundingClientRect().top);o>0&&s===o&&console.warn(`[margin] coordsAtPos threw for all ${o} annotations — view may be detached`),!g6(B(t),a)&&P(t,a,!0)}let r=m6(n);return R(()=>{if(!e.getEnabled())return;let t=e.getEditor(),n=e.getLayerEl();if(!t||!n)return;let i=()=>r.schedule();t.on(`transaction`,i);let a=new ResizeObserver(()=>r.schedule());return a.observe(n),r.schedule(),()=>{t.off(`transaction`,i),a.disconnect(),r.cancel()}}),R(()=>{e.getAnnotations(),r.schedule()}),{get byId(){return B(t)}}}function g6(e,t){if(e.size!==t.size)return!1;for(let[n,r]of e){let e=t.get(n);if(e===void 0||Math.abs(e-r)>.5)return!1}return!0}var _6=so,v6=250;function y6(e,t){return e.severity===`info`&&t-e.timestamp>=_6}function b6(e){try{let t=localStorage.getItem(e);if(!t)return[];let n=JSON.parse(t);if(!Array.isArray(n))return[];let r=Date.now();return n.filter(e=>typeof e==`object`&&!!e&&typeof e.id==`string`&&typeof e.message==`string`&&typeof e.timestamp==`number`&&[`info`,`warning`,`error`].includes(e.severity)).filter(e=>!y6(e,r)).slice(-50)}catch(e){return console.warn(`[useNotifications] failed to load activity history:`,e),[]}}function x6(e={}){let t=e.persist??!0,n=e.storageKey??`tandem:activityHistory`,r=N(ln([])),i=N(ln(t?b6(n):[])),a=new Map,o=new Map,s=null,c=()=>{if(t){s=null;try{localStorage.setItem(n,JSON.stringify(B(i)))}catch{}}},l=()=>{t&&(s&&clearTimeout(s),s=setTimeout(c,v6))},u=e=>{let t=a.get(e);t&&(clearTimeout(t),a.delete(e))},d=(e,t)=>{u(e);let n=oo[t]??oo.info;a.set(e,setTimeout(()=>{P(r,B(r).filter(t=>t.id!==e),!0),a.delete(e)},n))},f=(e,t)=>{if(e.dedupKey){let n=B(r).findIndex(t=>t.dedupKey===e.dedupKey);if(n!==-1){let i=B(r)[n];u(i.id);let a={...e,count:i.count+1,action:t},o=[...B(r)];o[n]=a,P(r,o,!0),d(a.id,a.severity);return}}let n={...e,count:1,action:t},i=[...B(r),n];for(;i.length>5;)u(i.shift().id);P(r,i,!0),d(n.id,n.severity)},p=e=>{let t=o.get(e);t&&(clearTimeout(t),o.delete(e))},m=(e,t)=>{p(e);let n=Math.max(0,_6-(Date.now()-t));o.set(e,setTimeout(()=>{o.delete(e),B(i).some(t=>t.id===e)&&(P(i,B(i).filter(t=>t.id!==e),!0),P(r,B(r).filter(t=>t.id!==e),!0),l())},n))},h=e=>{if(e.dedupKey){let t=B(i).findIndex(t=>t.dedupKey===e.dedupKey);if(t!==-1){let n=B(i)[t],r={...e,id:n.id,count:n.count+1},a=[...B(i)];a[t]=r,P(i,a,!0),r.severity===`info`?m(r.id,r.timestamp):p(r.id),l();return}}let t={...e,count:1},n=[...B(i),t];for(;n.length>50;)n.shift();P(i,n,!0),t.severity===`info`&&m(t.id,t.timestamp),l()},g=(e,t,n)=>{h(e),(e.severity!==`info`||t)&&f(e,n)},_=e=>{P(r,B(r).filter(t=>t.id!==e),!0),u(e)},v=e=>{P(i,B(i).filter(t=>t.id!==e),!0),p(e),l()},y=()=>{P(i,[],!0);for(let e of o.values())clearTimeout(e);o.clear(),l()};for(let e of B(i))e.severity===`info`&&m(e.id,e.timestamp);let b=(e,t)=>g(e,!0,t),x=`http://127.0.0.1:${ba}${pc}`,S=new EventSource(x);return S.onmessage=e=>{let t;try{t=JSON.parse(e.data)}catch{console.warn(`[useNotifications] Malformed SSE data:`,e.data);return}g(t,!1)},S.onerror=()=>{S.readyState===EventSource.CLOSED&&console.warn(`[useNotifications] EventSource permanently closed. Notifications will not be delivered. Is the server running?`)},_a(()=>{S.close();for(let e of a.values())clearTimeout(e);a.clear();for(let e of o.values())clearTimeout(e);o.clear(),s&&(clearTimeout(s),c())}),{get toasts(){return B(r)},get activity(){return B(i)},get total(){return B(i).length},dismiss:_,dismissActivity:v,clearActivity:y,push:b}}function S6(e,t){let n=null,r=null,i=(...i)=>{r=i,n!==null&&clearTimeout(n),n=setTimeout(()=>{n=null;let t=r;r=null,t&&e(...t)},t)};return i.cancel=()=>{n!==null&&(clearTimeout(n),n=null),r=null},i.flush=()=>{n!==null&&(clearTimeout(n),n=null);let t=r;r=null,t&&e(...t)},i}function C6(e){return`tandem:scratchpad:${e}`}var w6=`tandem:scratchpad:latest`,T6=500;function E6(e){let t=[],n=e=>{if(e instanceof TE)return e.toString();if(e instanceof bE){let t=``;for(let r=0;r<e.length;r++)t+=n(e.get(r));return t}return``};for(let r=0;r<e.length;r++){let i=e.get(r);(i instanceof bE||i instanceof TE)&&t.push(n(i))}return t.join(`
268
+ `).replace(/\n+$/,``)}function D6(e){try{return localStorage.getItem(e)}catch{return null}}function O6(e,t){try{localStorage.setItem(e,t)}catch{}}function k6(e){try{localStorage.removeItem(e)}catch{}}function A6(e){let t=new Map,n=ln({}),r=()=>Object.values(n).some(Boolean),i=e=>{let t=E6(e.ydoc.getXmlFragment(`default`)),r=C6(e.uuid);if(t.length===0){k6(r),D6(w6)===e.uuid&&k6(w6),n[e.uuid]=!1;return}O6(r,t),O6(w6,e.uuid),n[e.uuid]=!0},a=(e,n,r)=>{if(t.has(e))return;let a={uuid:e,ydoc:n,provider:r,updateHandler:()=>{},syncedHandler:null,persist:S6(()=>{},T6)};if(a.persist=S6(()=>i(a),T6),a.updateHandler=()=>a.persist(),n.on(`update`,a.updateHandler),t.set(e,a),r.synced)o(a);else{let n=()=>{a.syncedHandler=null,r.off(`synced`,n),t.get(e)===a&&o(a)};a.syncedHandler=n,r.on(`synced`,n)}},o=e=>{let r=e.ydoc.getXmlFragment(`default`);if(E6(r).length>0)return;let i=e.uuid,a=D6(C6(i));if(a===null&&t.size===1){let t=D6(w6);t&&t!==e.uuid&&(a=D6(C6(t)),i=t)}if(a===null||a.length===0)return;let o=a.split(`
269
+ `).map(e=>{let t=new bE(`paragraph`);return e.length>0&&t.insert(0,[new TE(e)]),t});Dk(e.ydoc,()=>{r.length>0&&r.delete(0,r.length),r.insert(0,o)}),O6(C6(e.uuid),a),O6(w6,e.uuid),i!==e.uuid&&k6(C6(i)),n[e.uuid]=!0},s=e=>{let n=t.get(e);n&&(n.persist.flush(),n.ydoc.off(`update`,n.updateHandler),n.syncedHandler&&n.provider.off(`synced`,n.syncedHandler),t.delete(e))},c=e=>{k6(C6(e)),D6(w6)===e&&k6(w6),t.get(e)?.persist.cancel(),n[e]=!1},l=In(()=>{R(()=>{let n=e(),r=new Set;for(let e of n){if(!yo(e.filePath))continue;let t=bo(e.filePath);t&&(r.add(t),a(t,e.ydoc,e.provider))}for(let e of[...t.keys()])r.has(e)||s(e)}),R(()=>{let e=e=>{if(r()){for(let e of t.values())e.persist.flush();return e.preventDefault(),e.returnValue=`You have unsaved scratchpad content.`,`You have unsaved scratchpad content.`}};return window.addEventListener(`beforeunload`,e),()=>window.removeEventListener(`beforeunload`,e)})});return{hasUnsavedContent:e=>n[e]===!0,clearUnsaved:c,destroy:()=>{l();for(let e of[...t.keys()])s(e)}}}function j6(e,t,n){return e.length<2?null:e[(e.findIndex(e=>e.id===t)+(n?-1:1)+e.length)%e.length].id}function M6(e,t,n){let r=null;ga(()=>{r=r=>{if(!r.ctrlKey&&!r.metaKey||r.key!==`Tab`)return;let i=j6(e(),t(),r.shiftKey);i&&(r.preventDefault(),n(i))},window.addEventListener(`keydown`,r)}),_a(()=>{r&&window.removeEventListener(`keydown`,r)})}function N6(e,t){return e.length===0||t<1||t>9?null:e[Math.min(t-1,e.length-1)].id}function P6(e){if(e.isComposing)return!0;let t=e.target;return t?t.tagName===`INPUT`||t.tagName===`TEXTAREA`:!1}function F6(e,t){let n=new Set(t),r=e.filter(e=>n.has(e)),i=new Set(r),a=t.filter(e=>!i.has(e));return[...r,...a]}function I6(e,t,n,r,i=`left`){let a=e.filter(e=>r.has(e)),o=a.indexOf(t),s=a.indexOf(n);if(o===-1||s===-1)return a;let c=[...a];c.splice(o,1);let l=c.indexOf(n),u=i===`right`?l+1:l;return c.splice(u,0,t),c}function L6(e){let t=N(ln([]));R(()=>{let n=e().map(e=>e.id),r=F6(B(t),n);(B(t).length!==r.length||B(t).some((e,t)=>e!==r[t]))&&P(t,r,!0)});let n=M(()=>{let n=e(),r=new Map(n.map(e=>[e.id,e])),i=n.map(e=>e.id);return F6(B(t),i).map(e=>r.get(e)).filter(Boolean)});return{get orderedTabs(){return B(n)},reorder:(n,r,i=`left`)=>{if(n===r)return;let a=e(),o=new Set(a.map(e=>e.id));P(t,I6(B(t),n,r,o,i),!0)}}}function R6(e,t){let n=N(ln((()=>{try{let e=localStorage.getItem(ja),t=ac.safeParse(e);return t.success?t.data:Aa}catch(e){return console.warn(`[tandem] localStorage unavailable reading ${ja}:`,e),Aa}})()));return R(()=>{let e=B(n);try{localStorage.setItem(ja,e)}catch(e){console.warn(`[tandem] failed to persist ${ja}:`,e)}}),R(()=>{let t=e(),r=B(n);if(t)try{t.getMap(za).set(Ba,r)}catch(e){console.warn(`[tandem] failed to broadcast tandem mode to Y.Map:`,e)}}),R(()=>{let n=e(),r=t();if(n)try{n.getMap(za).set(Va,r)}catch(e){console.warn(`[tandem] failed to broadcast dwell ms to Y.Map:`,e)}}),{get tandemMode(){return B(n)},setTandemMode(e){P(n,e,!0)}}}var z6=N(!1),B6=!1,V6=()=>{},H6={get fileDragOver(){return B(z6)}};function U6(e){let t=e.split(/[/\\]/).at(-1)??``,n=t.lastIndexOf(`.`);return n<=0?!1:Ca.has(t.slice(n).toLowerCase())}var W6=(()=>{let e=Array.from(Ca).sort();return e.length<=1?e[0]??``:e.length===2?`${e[0]} or ${e[1]}`:`${e.slice(0,-1).join(`, `)}, or ${e.at(-1)}`})();function G6(e,t,n){V6({id:`tauri-drop-${n}-${Date.now()}`,type:`general-error`,severity:t,message:e,dedupKey:n,timestamp:Date.now()})}function K6(e){V6=e,!B6&&nh()&&(B6=!0,Ul(async()=>{let{getCurrentWebview:e}=await import(`./webview-C-97RVRf.js`);return{getCurrentWebview:e}},__vite__mapDeps([8,1,9,3])).then(async({getCurrentWebview:e})=>{await e().onDragDropEvent(e=>{try{let t=e.payload;switch(t.type){case`enter`:P(z6,!0);return;case`drop`:P(z6,!1);for(let e of t.paths)if(U6(e)){(async()=>{let t=await Hh(e);t.ok||G6(`Couldn't open ${e}: ${t.error}`,`error`,`tauri-drop-open-failed`)})();return}G6(`Tandem can only open ${W6} files`,`warning`,`tauri-drop-unsupported`);return;case`leave`:P(z6,!1);return;default:console.warn(`[useTauriFileDrop] unknown payload type:`,t)}}catch(e){console.error(`[useTauriFileDrop] callback threw:`,e),G6(`Drag-and-drop encountered an error — try the Open File dialog`,`error`,`tauri-drop-callback-error`)}})}).catch(e=>{B6=!1,console.error(`[useTauriFileDrop] Failed to attach onDragDropEvent:`,e),G6(`Drag-and-drop unavailable — use the Open File dialog instead`,`warning`,`tauri-drop-unavailable`)}))}var q6=new class{#e=N(ln(nh()?window.__TANDEM_INITIAL_THEME__??null:null));get current(){return B(this.#e)}set current(e){P(this.#e,e,!0)}},J6=!1;function Y6(e){q6.current=e,typeof window<`u`&&(window.__TANDEM_INITIAL_THEME__=e)}function X6(){if(J6||!nh())return;J6=!0;let e=null;Ul(async()=>{let{invoke:e}=await import(`./core-SwWLTXZB.js`);return{invoke:e}},[]).then(({invoke:t})=>{e=t,t(`get_app_theme`).then(e=>{Y6(e===`dark`?`dark`:`light`)}).catch(e=>{console.warn(`[useTauriTheme] get_app_theme failed:`,e)})}).catch(e=>{console.warn(`[useTauriTheme] Tauri API import failed:`,e)}),Ul(async()=>{let{getCurrentWindow:e}=await import(`./window-CR0qpD8C.js`);return{getCurrentWindow:e}},__vite__mapDeps([9,1,3])).then(({getCurrentWindow:e})=>{e().onThemeChanged(({payload:e})=>{Y6(e===`dark`?`dark`:`light`)}).catch(e=>{console.warn(`[useTauriTheme] onThemeChanged subscribe failed:`,e)})}).catch(e=>{console.warn(`[useTauriTheme] Tauri window API import failed:`,e)});let t=!1,n=setInterval(()=>{!document.hasFocus()||!e||e(`get_app_theme`).then(e=>{let n=e===`dark`?`dark`:`light`;q6.current!==n&&(Y6(n),t=!1)}).catch(e=>{t||=(console.warn(`[useTauriTheme] theme poll failed (further errors suppressed):`,e),!0)})},3e3);window.addEventListener(`pagehide`,()=>clearInterval(n),{once:!0})}function Z6(e=`light`){let t=e===`warm`?`warm`:`light`;try{if(typeof window>`u`)return t;if(nh()){let e=q6.current;if(e===`dark`)return`dark`;if(e===`light`)return t;let n=window.__TANDEM_INITIAL_THEME__;if(n===`dark`)return`dark`;if(n===`light`)return t}return window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:t}catch(e){return console.warn(`[Tandem] Theme detection failed, defaulting to light:`,e),t}}function Q6(e,t=`light`){return e===`system`?Z6(t):e}function $6(e){try{let t=document.querySelector(`meta[name="theme-color"]`);t&&(t.content=e===`dark`?`#1c1c24`:e===`warm`?`#f1ead9`:`#fafaf9`)}catch{}}function e8(e,t=`light`){let n=document.documentElement,r=Q6(e,t);if(n.setAttribute(`data-theme`,r),$6(r),e!==`system`||nh())return()=>n.removeAttribute(`data-theme`);let i=window.matchMedia(`(prefers-color-scheme: dark)`),a=()=>{let e=Z6(t);n.setAttribute(`data-theme`,e),$6(e)};return i.addEventListener(`change`,a),()=>{i.removeEventListener(`change`,a),n.removeAttribute(`data-theme`)}}function t8(e,t=()=>`light`){X6(),R(()=>{let n=e(),r=t();return q6.current,e8(n,r)})}function n8(){try{return localStorage.getItem(co)===`true`}catch{return!1}}function r8(e){return e.author===`user`&&!e.id.startsWith(`tutorial-`)}function i8(){try{localStorage.setItem(co,`true`)}catch{}}function a8(e,t,n){let r=N(ln(n8())),i=N(0),a=0,o=eh(),s=M(()=>n()===`welcome.md`),c=M(()=>!B(r)&&B(s)),l=nh(),u=gh(()=>l&&B(c)),d=M(()=>!l||u.status!==null||u.error!==null),f=M(()=>l&&$m(u.status,o)),p=M(()=>B(d)?B(f)?4:3:1/0);return R(()=>{if(!B(c)||B(i)!==0)return;let t=e().filter(e=>e.id.startsWith(lo));t.length!==0&&t.some(e=>e.status!==`pending`)&&(a=Date.now(),P(i,1))}),R(()=>{!B(c)||B(i)!==1||e().some(r8)&&(a=Date.now(),P(i,2))}),R(()=>{if(!B(c)||B(i)!==2||!isFinite(B(p)))return;let e=t();if(!e)return;let n=()=>{Date.now()-a<2e3||e.isFocused&&(a=Date.now(),P(i,3))};return e.on(`update`,n),()=>{e.off(`update`,n)}}),R(()=>{if(!B(c)||!isFinite(B(p))||B(i)!==B(p))return;let e=setTimeout(()=>{i8(),P(r,!0)},3e3);return()=>clearTimeout(e)}),R(()=>{isFinite(B(p))&&B(i)>B(p)&&P(i,B(p),!0)}),{get tutorialActive(){return B(c)},get currentStep(){return B(i)},get coworkStatus(){return u.status},dismissTutorial:()=>{i8(),P(r,!0)},nextStep:()=>{a=Date.now(),P(i,Math.min(B(i)+1,B(p)),!0)}}}var o8=`tandem://update-available`,s8=`tandem:updater-dismissed-v`;function c8(e){return`${s8}${e}`}function l8(e){try{return window.localStorage.getItem(c8(e))===`1`}catch{return!1}}function u8(e){try{window.localStorage.setItem(c8(e),`1`)}catch{}}var d8=N(null),f8=N(null),p8=0,m8=null,h8=!1,g8=0;function _8(){return p8}function v8(){return B(d8)}function y8(){return B(f8)}function b8(e){e&&(u8(e),P(f8,e,!0))}function x8(){if(p8+=1,p8===1&&nh()){h8=!1;let e=++g8;(async()=>{try{let{listen:t}=await Ul(async()=>{let{listen:e}=await import(`./event-wL_2RBc7.js`);return{listen:e}},__vite__mapDeps([3,1]));if(h8||e!==g8||_8()===0)return;let n=await t(o8,e=>{let t=e.payload?.version??null;t&&(P(d8,t,!0),B(f8)!==t&&P(f8,null))});if(h8||e!==g8||_8()===0){n();return}m8=n}catch(e){console.warn(`[useUpdaterChannel] listen() failed:`,e)}})()}let e=!1;return()=>{if(!e&&(e=!0,p8=Math.max(0,p8-1),p8===0)){h8=!0;let e=m8;if(m8=null,e)try{e()}catch(e){console.warn(`[useUpdaterChannel] unlisten threw:`,e)}}}}function S8(){return R(()=>x8()),{get availableVersion(){return v8()},get showDot(){let e=v8();return!(!e||y8()===e||l8(e))},acknowledge(){b8(v8())}}}var C8=3e4;function w8(){let e=N(!1),t=null;function n(){t!==null&&(clearTimeout(t),t=null)}R(()=>{let e=x8();return()=>{n(),e()}});async function r(){if(!(!v8()||B(e))){P(e,!0),n(),t=setTimeout(()=>{t=null,P(e,!1),console.warn(`[useUpdaterBanner] install_update did not tear down WebView within ${C8}ms; re-arming CTA`)},C8);try{let{invoke:t}=await Ul(async()=>{let{invoke:e}=await import(`./core-SwWLTXZB.js`);return{invoke:e}},[]);await t(`install_update`),n(),P(e,!1)}catch(t){console.warn(`[useUpdaterBanner] install_update failed:`,t),n(),P(e,!1)}}}return{get availableVersion(){return v8()},get installing(){return B(e)},get showBanner(){let e=v8();return!(!e||y8()===e||l8(e))},dismiss(){b8(v8())},install:r}}function T8(){let e=N(ln(window.innerWidth));return R(()=>{let t=null,n=()=>{t===null&&(t=requestAnimationFrame(()=>{P(e,window.innerWidth,!0),t=null}))};return window.addEventListener(`resize`,n),()=>{window.removeEventListener(`resize`,n),t!==null&&cancelAnimationFrame(t)}}),{get width(){return B(e)}}}function E8(){let e=null;ga(()=>{let t=!1,n;Ul(async()=>{let{getCurrentWebview:e}=await import(`./webview-C-97RVRf.js`);return{getCurrentWebview:e}},__vite__mapDeps([8,1,9,3])).then(({getCurrentWebview:e})=>{if(t)return;let r=e(),i=1;try{let e=localStorage.getItem(mo);if(e!==null){let t=Number(e);Number.isFinite(t)?i=Math.max(ho,Math.min(2,t)):console.warn(`[tandem] ignoring invalid stored zoom: ${e}`)}}catch{}i!==1&&r.setZoom(i).catch(e=>{console.warn(`[tandem] failed to restore zoom level:`,e)});function a(e){try{localStorage.setItem(mo,String(e))}catch{}}let o=e=>{!(e.metaKey||e.ctrlKey)||e.key!==`0`||(e.preventDefault(),e.stopPropagation(),i=1,r.setZoom(1).catch(e=>{console.warn(`[tandem] failed to reset zoom:`,e)}),a(1))},s=.1,c=e=>{if(!(e.metaKey||e.ctrlKey))return;let t=e.key===`+`||e.key===`=`,n=e.key===`-`||e.key===`_`;if(!t&&!n)return;let r=t?i+s:i-s;i=Math.max(ho,Math.min(2,Math.round(r*100)/100)),a(i)};window.addEventListener(`keydown`,o,{capture:!0}),window.addEventListener(`keydown`,c,{capture:!0}),n=()=>{window.removeEventListener(`keydown`,o,{capture:!0}),window.removeEventListener(`keydown`,c,{capture:!0})}}).catch(()=>{}),e=()=>{t=!0,n?.()}}),_a(()=>{e?.()})}var D8=1e3;function O8(e){let t=!1;return function(){e.isDestroyed()||t||(t=!0,queueMicrotask(async()=>{try{for(;!e.isDestroyed();){let t=await e.fetchGenerationId();if(e.isDestroyed())return;if(t&&t===e.getPinnedGeneration()){e.onGenerationUnchanged();return}if(t){e.rebuild(t);return}await e.sleep(D8)}}finally{t=!1}}))}}function k8(e){let{prev:t,serverActiveId:n,serverIds:r,removedCount:i,serverEpoch:a,lastAppliedEpoch:o}=e;return t===null||!r.has(t)?n:i>0&&n===t||a===o?t:n}function A8(e,t,n){return e.filter(e=>!t.has(e.id)&&!n.has(e.id))}function j8(e){return e===`constant-2s`?{delay:2e3,factor:1,maxAttempts:0,minDelay:2e3,maxDelay:2e3,jitter:!1}:{delay:1e3,factor:2,maxAttempts:0,minDelay:1e3,maxDelay:3e4,jitter:!0}}function M8(e){let t=t=>({...t,...j8(e?.getRetryStrategy?.()??`exponential`)}),n=N(ln([])),r=N(null),i=N(!1),a=N(`connecting`),o=N(0),s=N(null),c=N(ln([])),l=N(null),u=N(!1),d=N(null),f=N(!1),p=N(!1),m=N(!1),h=N(null),g=null,_=!1,v=null,y=null,b=new Set,x=new Map,S=new Map,C=new Map,w=!1,ee=e=>{let{ydoc:t}=e,n=t.getMap(La),r=()=>{let e=[];n.forEach(t=>{e.push(Ok(t,e=>{console.warn(`[sanitize]`,e)}))}),P(c,e,!0)};n.observe(r),r();let i=t.getMap(Ra),a=null,o=!1,s=null,f=e=>e?`${e.tool} ${e.annotationId??``} ${e.token??e.startedAt}`:null,p=()=>{let e=i.get(Ya),t=e?.status??null,n=e?.active??!1,r=e?.working??null;t!==a&&(a=t,P(l,t,!0)),n!==o&&(o=n,P(u,n,!0));let c=f(r);c!==s&&(s=c,P(d,r,!0))};return i.observe(p),p(),()=>{n.unobserve(r),i.unobserve(p)}},T=e=>new Promise(t=>setTimeout(t,e)),E=async()=>{try{let e=await fetch(`http://127.0.0.1:${ba}${mc}`,{signal:AbortSignal.timeout(5e3)});return e.ok?(await e.json()).generationId??null:null}catch{return null}},te=()=>{for(let e of S.values())e.cleanup();S.clear();for(let e of C.values())e();C.clear();for(let e of x.values())e.provider.destroy(),e.ydoc.destroy();x.clear(),b.clear();for(let e of B(n))e.provider.destroy(),e.ydoc.destroy();P(n,[],!0)},ne=O8({isDestroyed:()=>w,fetchGenerationId:E,getPinnedGeneration:()=>v,onGenerationUnchanged:()=>{console.warn(`[Tandem] Provider auth failed without a generation change`)},rebuild:e=>{console.warn(`[Tandem] Server restarted — resyncing documents`),te(),re?.(),P(m,!0),y=null,g=setTimeout(()=>{P(m,!1)},5e3),ae(e)},sleep:T}),D=(e,i,a)=>{let o=B(n),s=new Set(o.map(e=>e.id)),c=new Set(e.map(e=>e.id));for(let e of o)b.delete(e.id),x.delete(e.id);for(let[e,t]of x)c.has(e)||(C.get(e)?.(),C.delete(e),t.provider.destroy(),t.ydoc.destroy(),x.delete(e),b.delete(e));let l=A8(e,s,b),u=[];for(let e of l){b.add(e.id);let n=new LC,r=new wF(t({url:`ws://127.0.0.1:${ya}`,name:e.id,document:n,token:v}));r.on(`authenticationFailed`,ne),x.set(e.id,{ydoc:n,provider:r});let i=n.getMap(Ua),a=e=>{if(!e.keysChanged.has(`openDocuments`)&&!e.keysChanged.has(`activeDocumentId`)&&!e.keysChanged.has(`activeDocumentEpoch`))return;let t=i.get(Xa),n=i.get(Za),r=i.get(Qa);t&&D(t,n??null,r??null)};i.observe(a),C.set(e.id,()=>i.unobserve(a)),u.push({...e,ydoc:n,provider:r})}let d=o.filter(e=>!c.has(e.id));for(let e of d){let t=S.get(e.id);t&&(t.cleanup(),S.delete(e.id)),C.get(e.id)?.(),C.delete(e.id),b.delete(e.id),x.delete(e.id),e.provider.destroy(),e.ydoc.destroy()}let f=new Map(e.map(e=>[e.id,e]));P(n,[...o.filter(e=>c.has(e.id)).map(e=>{let t=f.get(e.id);return!t||t.fileName===e.fileName&&t.filePath===e.filePath&&t.format===e.format&&t.readOnly===e.readOnly&&t.source===e.source?e:{...e,fileName:t.fileName,filePath:t.filePath,format:t.format,readOnly:t.readOnly,source:t.source}}),...u],!0),i!==null&&(P(r,k8({prev:B(r),serverActiveId:i,serverIds:c,removedCount:d.length,serverEpoch:a,lastAppliedEpoch:y}),!0),y=a)},re=null,ie=null;function ae(e){v=e;let n=new LC,r=new wF(t({url:`ws://127.0.0.1:${ya}`,name:Ia,document:n,token:e}));P(h,n,!0),ie=r,r.on(`authenticationFailed`,ne),r.on(`status`,({status:e})=>{P(i,e===`connected`),P(a,[`connected`,`connecting`,`disconnected`].includes(e)?e:`connecting`,!0),e===`connected`?(_=!0,P(o,0),P(s,null)):e===`disconnected`?B(s)===null&&P(s,Date.now(),!0):e===`connecting`&&(_&&P(o,B(o)+1),B(s)===null&&P(s,Date.now(),!0))});let c=n.getMap(Ua),l=e=>{if(e.keysChanged.has(`openDocuments`)||e.keysChanged.has(`activeDocumentId`)||e.keysChanged.has(`activeDocumentEpoch`)){let e=c.get(Xa),t=c.get(Za),n=c.get(Qa);e&&D(e,t??null,n??null)}e.keysChanged.has(`storeReadOnly`)&&P(f,c.get($a)===!0)};c.observe(l);let u=c.get(Xa),d=c.get(Za),m=c.get(Qa);u&&D(u,d??null,m??null),P(f,c.get($a)===!0),re=()=>{c.unobserve(l),g&&=(clearTimeout(g),null),r.destroy(),n.destroy(),P(h,null),ie=null,re=null},P(p,!0)}(async()=>{for(;!w;){let e=await E();if(w)return;if(e){ae(e);return}P(p,!0),P(a,`disconnected`),P(i,!1),B(s)===null&&P(s,Date.now(),!0),await T(1e3)}})();let oe=M(()=>B(n).find(e=>e.id===B(r))??null),se=M(()=>B(oe)?.ydoc??null),ce=In(()=>{R(()=>{B(se);let e=B(oe);for(let e of S.values())e.cleanup();if(S.clear(),e){let t=ee(e);S.set(e.id,{cleanup:t})}else P(c,[],!0),P(l,null),P(u,!1),P(d,null)})});return{get tabs(){return B(n)},get activeTabId(){return B(r)},setActiveTabId:e=>{P(r,e,!0)},handleTabClose:e=>{if(B(r)===e){let t=B(n),i=t.findIndex(t=>t.id===e),a=t.filter(t=>t.id!==e);a.length===0?P(r,null):P(r,a[Math.min(i,a.length-1)].id,!0)}fetch(`http://127.0.0.1:${ba}${vc}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({documentId:e})}).then(e=>{e.ok||console.warn(`[Tandem] Server rejected close:`,e.status)}).catch(e=>{console.warn(`[Tandem] Failed to close document on server:`,e)})},handleTabRename:(e,t,r)=>{let i=B(n).find(t=>t.id===e);if(!i)return;let a=i.fileName,o=t=>B(n).map(n=>n.id===e?{...n,fileName:t}:n);P(n,o(t),!0);let s=e=>{P(n,o(a),!0),r?.(e)};fetch(`http://127.0.0.1:${ba}${bc}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({documentId:e,newName:t})}).then(async e=>{if(e.ok)return;let t=`Rename failed (${e.status}).`;try{let n=await e.json();n?.message&&(t=n.message)}catch{}console.warn(`[Tandem] Server rejected rename:`,e.status,t),s(t)}).catch(e=>{console.warn(`[Tandem] Failed to rename document on server:`,e),s(`Rename failed: could not reach the server.`)})},get connected(){return B(i)},get connectionStatus(){return B(a)},get reconnectAttempts(){return B(o)},get disconnectedSince(){return B(s)},get annotations(){return B(c)},get claudeStatus(){return B(l)},get claudeActive(){return B(u)},get claudeWorking(){return B(d)},get storeReadOnly(){return B(f)},get bootstrapYdoc(){return B(h)},get ready(){return B(p)},get serverRestarted(){return B(m)},destroy:()=>{w||(w=!0,ce(),te(),re?.(),P(c,[],!0),P(r,null),P(p,!1))},reconnect(){ie?.connect();for(let e of B(n))e.provider.connect()},rebuildForLicenseChange(){if(w)return;let e=v;e!==null&&(te(),re?.(),y=null,ae(e))}}}var N8={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 P8(e){return e.column+e.inset+e.gap}N8.full.column;var F8=P8(N8.full);function I8(e){return 2*F8+e+480}function L8(e){let t=e+480;return{t1:I8(e),t2:2*P8(N8.narrow)+t,t3:2*P8(N8.stub)+t}}var R8={off:0,stub:1,narrow:2,full:3};function z8(e,t,n,r){let{t1:i,t2:a,t3:o}=n,s=t,c=r,l=s<o?`off`:s<a?`stub`:s<i?`narrow`:`full`,u=s>i+c?`full`:s>a+c?`narrow`:s>o+c?`stub`:`off`;return R8[e]>R8[l]?l:R8[e]<R8[u]?u:e}function B8(e,t,n){return e?t&&n===`full`?`full`:`off`:t?n:`off`}function V8(e,t,n){return!t&&!n?`off`:e}function H8(e){return e.isDocx?e.effectivelyOn?`position: relative;`:`display: contents;`:`--editor-measure: ${e.measure}; --margin-left-track: ${e.leftReservePx}px; --margin-right-track: ${e.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 U8(e){let t=M(()=>(e.getLeftRailVisible()?e.leftRailWidthPx:0)+(e.getRightRailVisible()?e.rightRailWidthPx:0)),n=M(()=>L8(B(t))),r=N(`full`);R(()=>{let t=e.getViewportWidth(),i=B(n),a=kr(()=>B(r)),o=z8(a,t,i,32);o!==a&&P(r,o,!0)});let i=M(()=>e.getFormat()===`docx`),a=M(()=>B8(B(i),e.getMarginView(),B(r))),o=M(()=>V8(B(a),B(i),e.getLeftHasPending())),s=M(()=>V8(B(a),B(i),e.getRightHasPending())),c=M(()=>B(o)!==`off`),l=M(()=>B(s)!==`off`),u=M(()=>B(c)||B(l)),d=M(()=>N8[B(o)]),f=M(()=>N8[B(s)]),p=new Set,m=M(()=>H8({isDocx:B(i),effectivelyOn:B(u),leftReservePx:P8(B(d)),rightReservePx:P8(B(f)),measure:(()=>{let t=e.getEditorMeasure(),n=bl[t];return n===void 0&&!p.has(t)&&(p.add(t),console.warn(`[tandem] editorMeasure=${JSON.stringify(t)} not in EDITOR_MEASURE_CH; falling back to comfortable. Both useTandemSettings validators should have coerced this upstream — a TS-violating cast slipped past them.`)),n??bl.comfortable})()}));return{get effectivelyOn(){return B(u)},get leftVisible(){return B(c)},get rightVisible(){return B(l)},get leftMode(){return B(o)},get rightMode(){return B(s)},get leftGeometry(){return B(d)},get rightGeometry(){return B(f)},get layerStyle(){return B(m)}}}function W8(e,t){let n=M(()=>e.settings.leftPanelVisible),r=M(()=>e.settings.rightPanelVisible&&!(t.tandemMode===`solo`&&e.settings.soloRailHidden));function i(){e.updateSettings({leftPanelVisible:!e.settings.leftPanelVisible})}function a(){if(B(r)){e.updateSettings({rightPanelVisible:!1});return}e.updateSettings({rightPanelVisible:!0,...t.tandemMode===`solo`?{soloRailHidden:!1}:{}})}return{get leftVisible(){return B(n)},get rightVisible(){return B(r)},toggleLeft:i,toggleRight:a}}function G8(e){return e.mode===`stub`?`stub`:e.isEditing||e.isActive?`full`:e.mode===`narrow`?`clamped`:`full`}var K8=6;function q8(e,t={}){let n=t.gap??K8,r=new Map;if(e.length===0)return r;let i=e.map((e,t)=>({...e,idx:t})).sort((e,t)=>e.top-t.top||e.idx-t.idx),a=-1/0;for(let e of i){if(!Number.isFinite(e.top))continue;let t=Math.max(e.top,a);r.set(e.id,t),typeof e.height==`number`&&Number.isFinite(e.height)&&e.height>0&&(a=t+e.height+n)}return r}function J8(e,t){let n=[];for(let r of e.keys())t.has(r)||n.push(r);for(let t of n)e.delete(t);return n.length}var Y8=.62;function X8(e){let t=e.endX-e.startX,n=e.startX+t*Y8,r=e.endX-t*Y8;return`M ${e.startX.toFixed(1)},${e.startY.toFixed(1)} C ${n.toFixed(1)},${e.startY.toFixed(1)} ${r.toFixed(1)},${e.endY.toFixed(1)} ${e.endX.toFixed(1)},${e.endY.toFixed(1)}`}function Z8(e){throw Error(`unhandled annotation author: ${String(e)}`)}function Q8(e){switch(e){case`claude`:return`var(--tandem-author-claude)`;case`user`:return`var(--tandem-author-user)`;case`import`:return`var(--tandem-fg-subtle)`;default:return Z8(e)}}var $8=qr(`<path stroke-linecap="round" fill="none"></path><circle data-testid="margin-anchor-dot"></circle>`,1),e5=H(`<div class="margin-bubble svelte-lzz9jv"><!></div>`),t5=H(`<svg aria-hidden="true"></svg> <div></div>`,1);function n5(e,t){A(t,!0);let n=J(t,`reduceMotion`,3,!1),r=M(()=>t.side===`right`?0:t.gap),i=M(()=>t.side===`right`?t.gap:0),a=M(()=>`position: absolute; top: 0; bottom: 0; ${t.side}: ${t.edgeInset+t.width}px; width: ${t.gap}px; pointer-events: none;`),o=M(()=>t.annotations.filter(e=>t.positions.has(e.id)&&e.status===`pending`)),s=N(ln(new Map)),c=M(()=>new Map(B(o).map(e=>[e.id,G8({mode:t.mode,isActive:e.id===t.activeAnnotationId,isEditing:!1})]))),l=M(()=>q8(B(o).map(e=>({id:e.id,top:t.positions.get(e.id)??0,height:B(c).get(e.id)===`stub`?void 0:B(s).get(e.id)}))));R(()=>{let e=new Set(B(o).map(e=>e.id));kr(()=>{J8(B(s),e)>0&&P(s,new Map(B(s)),!0)})});function u(e,t){if(!Number.isFinite(t)||t<=0)return;let n=B(s).get(e);if(n!==void 0&&Math.abs(n-t)<.5)return;let r=new Map(B(s));r.set(e,t),P(s,r,!0)}let d=N(void 0),f=N(null),p=0;function m(e){return t.annotations.find(t=>t.id===e)}function h(e){return n=>{let r=m(e);r&&Xk(n,r,{accept:t.onAccept,dismiss:t.onDismiss,sendToClaude:t.onSendToClaude,remove:t.onRemove,openEdit:e=>P(f,{id:e,kind:`edit`,nonce:++p},!0),openReply:e=>P(f,{id:e,kind:`reply`,nonce:++p},!0)})}}async function g(e){if(!nh())return;let t=(e.target?.closest(`[data-annotation-id]`))?.getAttribute(`data-annotation-id`);if(!t)return;let n=m(t);n&&(e.preventDefault(),e.stopPropagation(),await Zk(n,h(t)))}R(()=>{let e=B(d);if(e)return e.addEventListener(`contextmenu`,g),()=>e.removeEventListener(`contextmenu`,g)}),R(()=>eA());var _=t5(),v=I(_);fi(v,21,()=>B(o),e=>e.id,(e,n)=>{let a=M(()=>t.positions.get(B(n).id)),o=M(()=>B(l).get(B(n).id));var s=Yr(),c=I(s),u=e=>{let s=M(()=>B(n).id===t.activeAnnotationId),c=M(()=>B(o)??B(a)),l=M(()=>B(c)+12),u=M(()=>Q8(B(n).author)),d=M(()=>X8({startX:B(r),startY:B(a),endX:B(i),endY:B(l)}));var f=$8(),p=I(f),m=L(p);z(()=>{q(p,`data-annotation-id`,B(n).id),q(p,`data-tandem-author`,B(n).author),q(p,`d`,B(d)),q(p,`stroke`,B(u)),q(p,`stroke-width`,B(s)?1.8:1.1),q(p,`stroke-opacity`,B(s)?.82:.38),q(m,`data-annotation-id`,B(n).id),q(m,`data-tandem-author`,B(n).author),q(m,`cx`,B(r)),q(m,`cy`,B(a)),q(m,`r`,B(s)?3:2),q(m,`fill`,B(u)),q(m,`fill-opacity`,B(s)?.72:.42)}),U(e,f)};G(c,e=>{B(a)!==void 0&&e(u)}),U(e,s)}),O(v);var y=L(v,2);fi(y,21,()=>B(o),e=>e.id,(e,r)=>{let i=M(()=>B(l).get(B(r).id)??t.positions.get(B(r).id)??0),a=M(()=>iO(B(r),t.repliesById.get(B(r).id))),o=M(()=>B(c).get(B(r).id)??`full`);var s=e5(),d=F(s);{let e=M(()=>B(r).id===t.activeAnnotationId),i=M(()=>zk(B(r))?t.onAccept:void 0),s=M(()=>Bk(B(r))?t.onDismiss:void 0),c=M(()=>Wk(B(r))?t.onRemove:void 0),l=M(()=>Uk(B(r))?t.onSendToClaude:void 0),u=M(()=>Hk(B(r))?t.onEdit:void 0),p=M(()=>Vk(B(r))?t.onReply:void 0),m=M(()=>B(f)?.id===B(r).id?B(f):null);wk(d,{get annotation(){return B(r)},get replies(){return B(a)},get isReviewTarget(){return B(e)},get density(){return B(o)},get reduceMotion(){return n()},onClick:()=>t.onClick(B(r)),get onAccept(){return B(i)},get onDismiss(){return B(s)},get onRemove(){return B(c)},get onSendToClaude(){return B(l)},get onEdit(){return B(u)},get onReply(){return B(p)},get openRequest(){return B(m)}})}O(s),z(()=>{q(s,`data-testid`,`margin-bubble-${B(r).id??``}`),q(s,`data-margin-bubble-reply-count`,B(a).length),K(s,`position: absolute; top: ${B(i)??``}px; ${t.side??``}: 0; width: ${t.width??``}px; pointer-events: auto;`)}),ji(1,s,()=>Rv,()=>({id:B(r).id,reduceMotion:n()})),la(s,`clientHeight`,e=>u(B(r).id,e)),U(e,s)}),O(y),da(y,e=>P(d,e),()=>B(d)),z(()=>{q(v,`data-testid`,`margin-leaders-${t.side??``}`),K(v,B(a)),q(y,`data-testid`,`margin-column-${t.side??``}`),q(y,`aria-label`,t.side===`left`?`Note bubbles`:`Comment bubbles`),K(y,`position: absolute; top: 0; ${t.side??``}: ${t.edgeInset??``}px; width: ${t.width??``}px; pointer-events: none;`)}),U(e,_),j()}function r5(e){return e.type===`note`}function i5(e){return e.author===`import`||e.type===`comment`}var a5=H(`<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),o5=H(`<span></span>`),s5=H(`<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 c5(e,t){A(t,!0);let n=J(t,`annotations`,19,()=>[]),r=M(()=>t.side===`left`?`Outline`:`Annotations`);function i(e){return e.type===`highlight`?`hl`:e.type===`comment`&&e.suggestedText!=null?`suggest`:e.author===`claude`?`claude`:e.author===`import`?`import`:`user`}function a(e){(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),t.onActivate())}var o=s5(),s=F(o),c=F(s,!0);O(s);var l=L(s,2),u=F(l),d=e=>{var t=a5();k(8),U(e,t)},f=e=>{var t=Yr();fi(I(t),17,n,e=>e.id,(e,t)=>{var n=o5();z(e=>Hi(n,1,`peek-dot ${e??``}`,`svelte-1mwvi22`),[()=>i(B(t))]),U(e,n)}),U(e,t)};G(u,e=>{t.kind===`outline`?e(d):e(f,-1)}),O(l);var p=L(l,2),m=F(p,!0);O(p),O(o),z(()=>{Hi(o,1,`peek-strip peek-strip-${t.side??``}`,`svelte-1mwvi22`),q(o,`data-testid`,`peek-strip-${t.side}`),q(o,`aria-label`,t.side===`left`?`Show left panel`:`Show right panel`),q(o,`aria-expanded`,!t.collapsed),K(o,t.collapsed?``:`display: none;`),W(c,t.side===`left`?`›`:`‹`),W(m,B(r))}),V(`click`,o,function(...e){t.onActivate?.apply(this,e)}),V(`keydown`,o,a),U(e,o),j()}zr([`click`,`keydown`]);var l5=e=>{console.warn(`[sanitize]`,e)};function u5(e,t,n){if(e.suggestedText===void 0)return!1;let r=e.suggestedText,i=jD(e,t.state.doc,n);if(!i)return console.warn(`[SidePanel] Could not resolve range for suggestion`,e.id),!1;try{t.chain().focus().deleteRange({from:i.from,to:i.to}).insertContentAt(i.from,r).run()}catch(t){return console.error(`[SidePanel] Editor mutation failed for suggestion`,e.id,t),!1}return!0}function d5({getYdoc:e,getEditor:t,getAnnotations:n,onActiveAnnotationChange:r,getScrollBehavior:i,getActiveAnnotationId:a,onApplyFailed:o}){let s=N(0),c=N(ln(new Set)),l=new Map,u=null;_a(()=>{for(let e of l.values())clearTimeout(e);l.clear()});function d(){return n().filter(sc)}function f(n,r){let i=e();if(!i)return;let a=i.getMap(La),s=a.get(n);if(!s||s.status!==`pending`)return;let l=Ok(s,l5);if(a.set(n,{...l,status:r}),r===`accepted`&&l.suggestedText!==void 0){let e=t();if(e&&!u5(l,e,i)){a.set(n,{...l,status:`pending`}),o?.(l);return}}u=n,P(c,new Set(B(c)).add(n),!0)}function p(e){let t=l.get(e);t&&clearTimeout(t),l.set(e,setTimeout(()=>{l.delete(e);let t=new Set(B(c));t.delete(e),P(c,t,!0)},3e3))}function m(e){let t=l.get(e);t&&(clearTimeout(t),l.delete(e));let n=new Set(B(c));n.delete(e),P(c,n,!0)}function h(n){let r=e();if(!r)return!1;let i=r.getMap(La),a=i.get(n);if(!a||a.status===`pending`)return m(n),!1;let o=Ok(a,l5),s=t();if(o.status===`accepted`&&o.suggestedText!==void 0&&s)try{let e=o.suggestedText,t=o.textSnapshot;if(typeof e==`string`&&typeof t==`string`){let i=jD(o,s.state.doc,r);if(!i)return console.warn(`[undo] Cannot resolve range for annotation ${n}, skipping`),p(n),!1;if(s.state.doc.textBetween(i.from,i.to)!==e)return console.warn(`[undo] Text changed since accept for annotation ${n}, skipping`),p(n),!1;s.chain().focus().deleteRange({from:i.from,to:i.to}).insertContentAt(i.from,t).run()}}catch(e){return console.warn(`[undo] Failed to revert text for annotation ${n}:`,e),p(n),!1}return i.set(n,{...o,status:`pending`}),m(n),u===n&&(u=null),!0}function g(e){f(e,`accepted`)}function _(e){f(e,`dismissed`)}function v(n){let r=t();if(!r)return;let a=jD(n,r.state.doc,e());if(!a)return;r.chain().focus().setTextSelection({from:a.from,to:a.to}).run();let o=r.view.domAtPos(a.from);(o.node instanceof HTMLElement?o.node:o.node.parentElement)?.scrollIntoView({behavior:i(),block:`center`})}return R(()=>{let e=a?.()??null;e!==null&&(n().some(t=>t.id===e&&t.status===`pending`)||r(d()[B(s)]?.id??null))}),R(()=>{let e=d();B(s)>=e.length&&P(s,Math.max(0,e.length-1),!0)}),{resolveAnnotation:f,undoResolveAnnotation:h,handleAccept:g,handleDismiss:_,scrollToAnnotation:v,getRecentlyResolved:()=>B(c),getReviewIndex:()=>B(s),getReviewTargets:d}}var f5=H(`<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>`),p5=H(`<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>`),m5=H(`<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 h5(e,t){A(t,!0);let n=[{value:`yellow`,label:`Yellow`},{value:`green`,label:`Green`},{value:`blue`,label:`Blue`},{value:`pink`,label:`Pink`}],r=J(t,`disabled`,3,!1),i=N(`yellow`),a=N(!1),o=N(null);R(()=>{t.onOpenChange?.(B(a))}),R(()=>{if(B(a))return m3(()=>B(o),[`mousedown`],()=>{P(a,!1)},{capture:!1})});function s(e){e.preventDefault(),t.onHighlight(B(i))}function c(e){e.preventDefault(),P(a,!B(a))}function l(e){P(i,e,!0),P(a,!1)}var u=m5(),d=F(u);b3(d,{label:`Highlight`,testId:`toolbar-highlight-btn`,get disabled(){return r()},disabledTitle:`Select text first`,onMouseDown:s});var f=L(d,2),p=F(f);O(f);var m=L(f,2),h=e=>{var t=p5(),r=F(t);fi(r,17,()=>n,({value:e,label:t})=>e,(e,t)=>{let n=()=>B(t).value,r=()=>B(t).label;var a=f5();let o;var s=F(a);k(2),O(a),z(()=>{q(a,`data-testid`,`toolbar-highlight-color-${n()}`),q(a,`title`,r()),q(a,`aria-label`,r()),o=Hi(a,1,`highlight-picker-swatch svelte-1d240y8`,null,o,{"is-selected":n()===B(i)}),K(s,`background: ${Oa[n()]??``};`)}),V(`click`,a,()=>l(n())),U(e,a)});var s=L(r,2);O(t),da(t,e=>P(o,e),()=>B(o)),V(`click`,s,()=>P(a,!1)),U(e,t)};G(m,e=>{B(a)&&e(h)}),O(u),z(()=>{f.disabled=r(),K(p,`background: ${Oa[B(i)]??``};`)}),V(`mousedown`,f,c),U(e,u),j()}zr([`mousedown`,`click`]);var g5=H(`<div class="fmtbar-divider svelte-1lcxsnm"></div> <!>`,1),_5=H(`<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),v5=H(`<div class="tandem-fmtbar-wrap"><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 y5(e,t){A(t,!0);let n=J(t,`showAuthorship`,3,!0),r=J(t,`showComments`,3,!0),i=J(t,`showHighlights`,3,!0),a=J(t,`showNotes`,3,!0),o=J(t,`decorationsMuted`,3,!1),s=N(0);R(()=>{let e=t.editor;if(!e||e.isDestroyed)return;let n=()=>{e.isDestroyed||on(s)};return e.on(`selectionUpdate`,n),e.on(`transaction`,n),()=>{e.off(`selectionUpdate`,n),e.off(`transaction`,n)}});let c=M(()=>(B(s),!t.editor||t.editor.isDestroyed||!t.ydoc?!1:!t.editor.state.selection.empty)),l=N(!1);function u(e){if(!t.editor||!t.ydoc||t.editor.isDestroyed)return;let{state:n}=t.editor,{from:r,to:i}=n.selection;if(r===i)return;let a=DD(n.doc,So(r)),o=DD(n.doc,So(i));if(a===null||o===null){console.warn(`[FormattingBar] pmPosToFlatOffset returned null — CRDT position may be degraded`,{from:r,to:i});return}F3(t.ydoc,{from:a,to:o},e)}var d=v5(),f=F(d),p=F(f),m=F(p);P3(m,{get editor(){return t.editor}});var h=L(m,4);{let e=M(()=>!B(c));h5(h,{get disabled(){return B(e)},onHighlight:u,onOpenChange:e=>P(l,e,!0)})}O(p);var g=L(p,2),_=e=>{var s=g5();p3(L(I(s),2),{get showAuthorship(){return n()},get showComments(){return r()},get showHighlights(){return i()},get showNotes(){return a()},get decorationsMuted(){return o()},get onUpdate(){return t.onUpdateDecorations},get onOpenSettings(){return t.onOpenSettings}}),U(e,s)};G(g,e=>{t.onUpdateDecorations&&e(_)});var v=L(g,2),y=e=>{var n=_5();V(`click`,L(I(n),2),function(...e){t.onHide?.apply(this,e)}),U(e,n)};G(v,e=>{t.onHide&&e(y)}),O(f),O(d),z(()=>K(d,`position: fixed; top: var(--tandem-fmtbar-top, 52px); left: 0; right: 0; display: flex; justify-content: center; pointer-events: none; z-index: ${B(l)?`var(--tandem-z-toast)`:`var(--tandem-z-sticky)`};`)),U(e,d),j()}zr([`click`]);var b5=H(`<div data-testid="mode-toggle" data-tauri-drag-region="false" class="mode-toggle svelte-14q5edy" role="group" aria-label="AI collaboration mode"><span aria-hidden="true"></span> <button data-testid="mode-solo-btn" title="Write undisturbed — your AI only responds when you message">Solo</button> <button data-testid="mode-tandem-btn" title="Full collaboration — your AI reacts to selections and document changes">Tandem</button></div>`);function x5(e,t){A(t,!0);var n=b5(),r=F(n);let i;var a=L(r,2),o=L(a,2);O(n),z(()=>{i=Hi(r,1,`thumb svelte-14q5edy`,null,i,{tandem:t.tandemMode===`tandem`}),Hi(a,1,Ii(t.tandemMode===`solo`?`on`:``),`svelte-14q5edy`),q(a,`aria-pressed`,t.tandemMode===`solo`),Hi(o,1,Ii(t.tandemMode===`tandem`?`on`:``),`svelte-14q5edy`),q(o,`aria-pressed`,t.tandemMode===`tandem`)}),V(`click`,a,()=>t.onModeChange(`solo`)),V(`click`,o,()=>t.onModeChange(`tandem`)),U(e,n),j()}zr([`click`]);var S5=[{value:`system`,label:`Match system`},{value:`light`,label:`Light`},{value:`dark`,label:`Dark`},{value:`warm`,label:`Warm`}],C5=H(`<span class="titlebar-settings-dot svelte-12l7ydf" data-testid="titlebar-update-available-dot" aria-hidden="true"></span>`),w5=H(`<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>`),T5=H(`<div class="brand-menu-divider svelte-12l7ydf" role="separator"></div>`),E5=H(`<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),D5=H(`<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>`),O5=H(`<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>`),k5=H(`<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>`),A5=H(`<div class="title-bar-center svelte-12l7ydf" data-tauri-drag-region="false"><!></div>`),j5=H(`<button type="button" data-testid="titlebar-source-toggle" data-tauri-drag-region="false"><span aria-hidden="true">&lt;/&gt;</span></button>`),M5=H(`<span class="status-dot svelte-12l7ydf" data-tauri-drag-region="false" title="AI assistant is connected" aria-label="AI assistant is connected"></span>`),N5=H(`<button type="button" class="model-chip ai-chip ai-chip-connect svelte-12l7ydf" data-testid="titlebar-connect-ai" data-ai-chip="connect" aria-label="AI isn't set up. Connect Claude Code." title="AI isn't set up — click to connect Claude Code"><span class="model-chip-dot svelte-12l7ydf" aria-hidden="true"></span> <span class="model-chip-label svelte-12l7ydf">Connect AI</span></button>`),P5=H(`<button type="button" class="model-chip ai-chip ai-chip-restart svelte-12l7ydf" data-testid="titlebar-connect-ai" data-ai-chip="restart" aria-label="Claude Code has stopped. Restart it." title="Claude Code stopped — click to restart"><span class="model-chip-dot svelte-12l7ydf" aria-hidden="true"></span> <span class="model-chip-label svelte-12l7ydf">Restart Claude Code</span></button>`),F5=H(`<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>`),I5=qr(`<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>`),L5=qr(`<svg width="10" height="10" viewBox="0 0 10 10" aria-hidden="true" focusable="false"><path d="M0 0H10V10H0V0ZM1 2V9H9V2H1Z" fill="currentColor"></path></svg>`),R5=H(`<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),z5=H(`<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 B5(e,t){A(t,!0);let n=J(t,`claudeActive`,3,!1),r=J(t,`theme`,3,`system`),i=J(t,`settingsBtn`,15,null),a=J(t,`updateAvailable`,3,!1),o=J(t,`defaultModelLabel`,3,null),s=J(t,`aiChip`,3,null),c=J(t,`sourceViewActive`,3,!1),l=J(t,`onToggleSourceView`,3,null),u=N(null),d=N(!1),f=[],p=!0;ga(async()=>{if(nh())try{let[{invoke:e},{getCurrentWindow:t}]=await Promise.all([Ul(()=>import(`./core-SwWLTXZB.js`),[]),Ul(()=>import(`./window-CR0qpD8C.js`),__vite__mapDeps([9,1,3]))]);if(!p||(await e(`setup_overlay_titlebar`).catch(e=>{console.error(`[TitleBar] setup_overlay_titlebar failed:`,e)}),!p))return;let n=t();if(P(u,n,!0),P(d,await n.isMaximized(),!0),!p)return;let r=await n.onResized(async()=>{try{P(d,await n.isMaximized(),!0)}catch(e){console.warn(`[TitleBar] isMaximized check failed on resize:`,e)}});if(!p){r();return}f.push(r);let i=await n.onMoved(async()=>{try{P(d,await n.isMaximized(),!0)}catch(e){console.warn(`[TitleBar] isMaximized check failed on move:`,e)}});if(!p){i();return}f.push(i)}catch(e){console.error(`[TitleBar] Window API initialization failed:`,e)}}),_a(()=>{p=!1,f.forEach(e=>e())});async function m(){try{await B(u)?.minimize()}catch(e){console.error(`[TitleBar] minimize failed:`,e)}}async function h(){try{await B(u)?.toggleMaximize()}catch(e){console.error(`[TitleBar] toggleMaximize failed:`,e)}}async function g(){try{await B(u)?.close()}catch(e){console.error(`[TitleBar] close failed:`,e)}}let _=N(!1),v=N(null);R(()=>{if(B(_))return m3(()=>B(v)??i(),[`mousedown`],()=>{P(_,!1)})});function y(){P(_,!B(_))}function b(){P(_,!1),i()?.focus()}function x(e){e.key===`Escape`&&(e.stopPropagation(),b())}function S(e){t.onSetTheme?.(e),b()}function C(){t.onOpenSettings?.(),P(_,!1)}function w(){t.onOpenHelp?.(),P(_,!1)}var ee=z5(),T=F(ee),E=F(T),te=L(F(E),2),ne=e=>{U(e,C5())},D=M(()=>nh()&&a());G(te,e=>{B(D)&&e(ne)}),O(E),da(E,e=>i(e),()=>i());var re=L(E,2),ie=e=>{var n=k5(),i=F(n),a=e=>{var n=E5(),i=L(I(n),2);fi(i,21,()=>S5,e=>e.value,(e,t)=>{var n=w5();let i;var a=L(F(n),2),o=F(a,!0);O(a),O(n),z(()=>{i=Hi(n,1,`brand-theme-sw svelte-12l7ydf`,null,i,{on:r()===B(t).value}),q(n,`data-testid`,`brand-menu-theme-${B(t).value??``}`),q(n,`data-theme-swatch`,B(t).value),q(n,`aria-checked`,r()===B(t).value),W(o,B(t).label)}),V(`click`,n,()=>S(B(t).value)),U(e,n)}),O(i);var a=L(i,2),o=e=>{U(e,T5())};G(a,e=>{(t.onOpenSettings||t.onOpenHelp)&&e(o)}),U(e,n)};G(i,e=>{t.onSetTheme&&e(a)});var o=L(i,2),s=e=>{var t=D5();V(`click`,t,C),U(e,t)};G(o,e=>{t.onOpenSettings&&e(s)});var c=L(o,2),l=e=>{var t=O5();V(`click`,t,w),U(e,t)};G(c,e=>{t.onOpenHelp&&e(l)}),O(n),da(n,e=>P(v,e),()=>B(v)),V(`keydown`,n,x),U(e,n)};G(re,e=>{B(_)&&e(ie)}),O(T);var ae=L(T,4),oe=e=>{var n=A5();yi(F(n),()=>t.center),O(n),U(e,n)};G(ae,e=>{t.center&&e(oe)});var se=L(ae,4),ce=F(se),le=e=>{var t=j5();let n;z(()=>{n=Hi(t,1,`source-toggle-btn svelte-12l7ydf`,null,n,{on:c()}),q(t,`aria-label`,c()?`Switch to formatted editor`:`View markdown source`),q(t,`aria-pressed`,c()),q(t,`title`,c()?`Switch to formatted editor`:`View markdown source`)}),V(`click`,t,function(...e){l()?.apply(this,e)}),U(e,t)};G(ce,e=>{l()&&e(le)});var ue=L(ce,2),de=e=>{x5(e,{get tandemMode(){return t.tandemMode},get onModeChange(){return t.onModeChange}})};G(ue,e=>{t.tandemMode&&t.onModeChange&&e(de)});var fe=L(ue,2),pe=e=>{U(e,M5())};G(fe,e=>{n()&&e(pe)});var me=L(fe,2),he=e=>{var n=N5();V(`click`,n,function(...e){t.onConnectAi?.apply(this,e)}),U(e,n)},ge=e=>{var n=P5();V(`click`,n,function(...e){t.onRestartClaude?.apply(this,e)}),U(e,n)},_e=e=>{var n=F5(),r=L(F(n),2),i=F(r,!0);O(r),O(n),z(()=>{q(n,`aria-label`,`Default model: ${o()}. Open Settings → Models.`),q(n,`title`,`Default model: ${o()}`),W(i,o())}),V(`click`,n,function(...e){t.onOpenModelsSettings?.apply(this,e)}),U(e,n)};G(me,e=>{s()===`connect`?e(he):s()===`restart`?e(ge,1):o()&&t.onOpenModelsSettings&&e(_e,2)}),O(se);var ve=L(se,2),ye=e=>{var t=R5(),n=L(I(t),2),r=F(n),i=L(r,2),a=F(i),o=e=>{U(e,I5())},s=e=>{U(e,L5())};G(a,e=>{B(d)?e(o):e(s,-1)}),O(i);var c=L(i,2);O(n),z(()=>{r.disabled=B(u)===null,q(i,`aria-label`,B(d)?`Restore`:`Maximize`),i.disabled=B(u)===null,c.disabled=B(u)===null}),V(`click`,r,m),V(`click`,i,h),V(`click`,c,g),U(e,t)},be=M(()=>nh());G(ve,e=>{B(be)&&e(ye)}),O(ee),z(()=>q(E,`aria-expanded`,B(_))),V(`click`,E,y),U(e,ee),j()}zr([`click`,`keydown`]);var V5=`tandem-status-count-mode`,H5=[`words`,`characters`,`sentences`,`paragraphs`,`pages`,`reading`],U5={words:`words`,characters:`chars`,sentences:`sentences`,paragraphs:`paragraphs`,pages:`pages`,reading:`min read`},W5=250,G5=200;function K5(e){let t=e.trim();return t?t.split(/\s+/).length:0}function q5(e){return H5[(H5.indexOf(e)+1)%H5.length]??`words`}function J5(e){return U5[e]}function Y5(){try{let e=localStorage.getItem(V5);if(e&&H5.includes(e))return e}catch{}return`words`}function X5(e){try{localStorage.setItem(V5,e)}catch{}}function Z5(e,t){if(!e||e.isDestroyed)return 0;let n=e.state.doc.textContent;switch(t){case`characters`:return n.length;case`words`:return K5(n);case`sentences`:return n.match(/[^.!?]+[.!?]+(?:\s|$)/g)?.length??+!!n.trim();case`paragraphs`:{let t=0;return e.state.doc.forEach(e=>{e.type.name===`paragraph`&&e.textContent.trim()&&t++}),t}case`pages`:return Math.ceil(K5(n)/W5);case`reading`:{let e=K5(n);return e===0?0:Math.max(1,Math.round(e/G5))}}}var Q5=H(`<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>`),$5=H(`<span data-testid="save-indicator" style="color: var(--tandem-accent);" class="svelte-1esxubl">Saving...</span>`),e7=H(`<span data-testid="saved-indicator" style="color: var(--tandem-success-fg-strong);" class="svelte-1esxubl"> </span>`),t7=H(`<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>`),n7=H(`<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>`),r7=H(`<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-2);" class="svelte-1esxubl"><span class="claude-dot svelte-1esxubl"></span> <span class="svelte-1esxubl"> </span> <!></div></div>`);function i7(e,t){A(t,!0);let n=J(t,`claudeWorkingTool`,3,null),r=J(t,`saving`,3,!1),i=J(t,`lastSaveOk`,3,!1);function a(e){return{tandem_edit:`editing`,tandem_comment:`commenting`,tandem_reply:`replying`,tandem_annotationReply:`replying`}[e]??e.replace(/^tandem_/,``)}let o=bD(xv()),s=N(!1),c=N(0),l=kr(()=>t.connected);R(()=>{let e=l;if(l=t.connected,t.connected&&!e){P(s,!0);let e=setTimeout(()=>{P(s,!1)},2e3);return()=>clearTimeout(e)}});let u=N(null),d=kr(()=>r());R(()=>{let e=d;if(d=r(),e&&!r()&&i()){P(u,`Saved ${new Date().toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}`);let e=setTimeout(()=>{P(u,null)},4e3);return()=>clearTimeout(e)}}),R(()=>{if(t.disconnectedSince==null){P(c,0);return}P(c,Math.floor((Date.now()-t.disconnectedSince)/1e3),!0);let e=setInterval(()=>{P(c,Math.floor((Date.now()-(t.disconnectedSince??0))/1e3),!0)},1e3);return()=>clearInterval(e)});let f=M(()=>t.connectionStatus===`connecting`),p=M(()=>t.connected?`var(--tandem-success)`:B(f)?`var(--tandem-warning)`:`var(--tandem-error)`),m=M(()=>B(s)?`Reconnected`:t.connectionStatus===`connected`?`Synced`:t.connectionStatus===`connecting`?(()=>{let e=[`Reconnecting…`];if(t.reconnectAttempts>0||B(c)>0){let n=[];t.reconnectAttempts>0&&n.push(`attempt ${t.reconnectAttempts}`),B(c)>0&&n.push(`${B(c)}s`),e.push(`(${n.join(`, `)})`)}return e.join(` `)})():`Disconnected — check that the server is running`),h=M(()=>B(s)?`var(--tandem-success-fg-strong)`:t.connectionStatus===`connected`?`var(--tandem-fg-muted)`:t.connectionStatus===`connecting`?`var(--tandem-warning-fg-strong)`:`var(--tandem-error-fg-strong)`),g=N(ln(Y5())),_=N(0);R(()=>{let e=t.editor;if(!e||e.isDestroyed)return;let n=()=>{e.isDestroyed||on(_)};return e.on(`update`,n),e.on(`transaction`,n),()=>{e.off(`update`,n),e.off(`transaction`,n)}});let v=M(()=>(B(_),Z5(t.editor??null,B(g))));function y(){let e=q5(B(g));P(g,e,!0),X5(e)}var b=r7(),x=F(b),S=F(x),C=L(S,2),w=F(C,!0);O(C);var ee=L(C,2),T=e=>{var t=Q5(),n=F(t);O(t),z((e,r,i,a)=>{q(t,`title`,e),q(t,`aria-label`,r),W(n,`${i??``} ${a??``}`)},[()=>`Click to cycle: ${J5(q5(B(g)))}`,()=>`${B(v)} ${J5(B(g))} (click to change unit)`,()=>B(v).toLocaleString(),()=>J5(B(g))]),V(`click`,t,y),U(e,t)};G(ee,e=>{t.editor&&e(T)});var E=L(ee,2),te=e=>{U(e,$5())},ne=e=>{var t=e7(),n=F(t,!0);O(t),z(()=>W(n,B(u))),U(e,t)};G(E,e=>{r()?e(te):B(u)&&e(ne,1)}),O(x);var D=L(x,2),re=e=>{U(e,t7())};G(D,e=>{t.readOnly&&e(re)});var ie=L(D,2),ae=F(ie),oe=L(ae,2),se=F(oe,!0);O(oe);var ce=L(oe,2),le=e=>{var t=n7(),r=L(F(t),6),i=F(r);O(r),O(t),z(e=>W(i,`${o.specific??``} is ${e??``}…`),[()=>a(n())]),U(e,t)};G(ce,e=>{n()&&e(le)}),O(ie),O(b),z(()=>{K(S,`width: 7px; height: 7px; border-radius: 50%; background: ${B(p)??``}; display: inline-block; animation: ${t.connected&&B(s)?`tandem-conn-bloom 500ms var(--tandem-ease-out)`:B(f)?`tandem-conn-pulse 900ms ease-in-out infinite`:`none`};`),K(C,`color: ${B(h)??``}; transition: color 0.3s ease;`),W(w,B(m)),K(ae,`width: 7px; height: 7px; border-radius: 50%; background: var(--tandem-author-claude); opacity: ${t.claudeActive?1:.4}; display: inline-block; transition: opacity 0.3s ease; animation: ${t.claudeActive?`tandem-status-pulse 1.5s ease-in-out infinite`:`none`};`),K(oe,`transition: color 0.3s ease; color: ${t.claudeActive?`var(--tandem-fg)`:`var(--tandem-fg-subtle)`};`),W(se,t.claudeStatus?`${o.specific} · ${t.claudeStatus}`:`${o.specific} · idle`)}),U(e,b),j()}zr([`click`]);function a7(e){let t=e-1;return t*t*t+1}function o7(e,{from:t,to:n},r={}){var{delay:i=0,duration:a=e=>Math.sqrt(e)*120,easing:o=a7}=r,s=getComputedStyle(e),c=s.transform===`none`?``:s.transform,[l,u]=s.transformOrigin.split(` `).map(parseFloat);l/=e.clientWidth,u/=e.clientHeight;var d=s7(e),f=e.clientWidth/n.width/d,p=e.clientHeight/n.height/d,m=t.left+t.width*l,h=t.top+t.height*u,g=n.left+n.width*l,_=n.top+n.height*u,v=(m-g)*f,y=(h-_)*p,b=t.width/n.width,x=t.height/n.height;return{delay:i,duration:typeof a==`function`?a(Math.sqrt(v*v+y*y)):a,easing:o,css:(e,t)=>`transform: ${c} translate(${t*v}px, ${t*y}px) scale(${e+t*b}, ${e+t*x});`}}function s7(e){if(`currentCSSZoom`in e)return e.currentCSSZoom;for(var t=e,n=1;t!==null;)n*=+getComputedStyle(t).zoom,t=t.parentElement;return n}function c7(e){return e.source===`file`&&!e.readOnly}var l7={md:`md`,markdown:`md`,docx:`docx`,doc:`docx`,txt:`txt`,text:`txt`,html:`html`,htm:`html`};function u7(e){let t=e.lastIndexOf(`.`);return t<=0||t===e.length-1?`other`:l7[e.slice(t+1).toLowerCase()]??`other`}function d7(e){let t=e.split(/[/\\]/);return{name:t.at(-1)??e,dir:t.slice(0,-1).join(`/`)}}function f7(e,t=Date.now()){let{dir:n,name:r}=d7(e.path);return{path:e.path,name:r,dir:n,when:Xl(e.openedAt,t),pip:u7(r)}}function p7(e,t){let n=t.trim().toLowerCase();return n?e.name.toLowerCase().includes(n)||e.dir.toLowerCase().includes(n):!0}function m7(e,t){let n=t.trim();if(!n)return[{text:e,match:!1}];let r=e.toLowerCase(),i=n.toLowerCase(),a=[],o=0;for(;o<e.length;){let t=r.indexOf(i,o);if(t===-1){a.push({text:e.slice(o),match:!1});break}t>o&&a.push({text:e.slice(o,t),match:!1}),a.push({text:e.slice(t,t+i.length),match:!0}),o=t+i.length}return a}var h7=qr(`<path></path>`),g7=qr(`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"></svg>`),_7=H(`<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>`),v7=H(`<span class="ntl-count svelte-7c4il0" aria-hidden="true"> </span>`),y7=H(`<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>`),b7=H(`<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>`),x7=H(`<mark class="svelte-7c4il0"> </mark>`),S7=H(`<span class="ntl-path svelte-7c4il0"> </span>`),C7=H(`<span class="ntl-when svelte-7c4il0"> </span>`),w7=H(`<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>`),T7=H(`<div class="ntl-recents svelte-7c4il0"></div>`),E7=H(`<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>`),D7=H(`<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 O7(e,t){A(t,!0);let n=(e,t=m,n=m,r=m)=>{var i=g7();fi(i,21,()=>u[t()]??[],ci,(e,t)=>{var n=h7();z(()=>q(n,`d`,B(t))),U(e,n)}),O(i),z(()=>{q(i,`width`,n()),q(i,`height`,n()),q(i,`stroke-width`,r())}),U(e,i)},r=N(``),i=N(null),a=N(null),o=M(()=>t.recentFiles.map(e=>f7(e))),s=M(()=>B(o).filter(e=>p7(e,B(r)))),c=M(()=>B(o).length>0),l=M(()=>B(r).trim().length>0),u={plus:[`M12 5v14`,`M5 12h14`],folder:[`M14 3H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z`,`M14 3v6h6`],undo:[`M3 7v6h6`,`M3 13a9 9 0 1 0 3-7`],search:[`M11 4a7 7 0 1 0 0 14 7 7 0 0 0 0-14z`,`m20 20-3.5-3.5`],inbox:[`M3 7l9 6 9-6`,`M3 7v10a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V7l-9-4-9 4z`]};function d(){return Array.from(B(i)?.querySelectorAll(`[data-nav-item]`)??[])}function f(e){let t=d();if(t.length===0)return;let n=t.indexOf(document.activeElement);if(n===-1){(e>0?t[0]:t[t.length-1])?.focus();return}t[(n+e+t.length)%t.length]?.focus()}function p(e){e.key===`Escape`?(e.preventDefault(),t.onClose()):e.key===`ArrowDown`?(e.preventDefault(),f(1)):e.key===`ArrowUp`&&(e.preventDefault(),f(-1))}R(()=>{B(i)&&B(a)?.focus({preventScroll:!0})});var h=D7(),g=F(h),_=F(g);n(F(_),()=>`search`,()=>13,()=>1.7),O(_);var v=L(_,2);Qi(v),da(v,e=>P(a,e),()=>B(a));var y=L(v,2),b=e=>{var t=_7();V(`click`,t,()=>P(r,``)),U(e,t)};G(y,e=>{B(l)&&e(b)});var x=L(y,2),S=e=>{var t=v7(),n=F(t);O(t),z(()=>W(n,`${B(s).length??``} of ${B(o).length??``}`)),U(e,t)};G(x,e=>{B(c)&&e(S)}),k(2),O(g);var C=L(g,2),w=F(C),ee=F(w),T=e=>{var t=y7(),r=F(t);n(F(r),()=>`inbox`,()=>16,()=>1.6),O(r),k(2),O(t),U(e,t)},E=e=>{var t=b7(),n=F(t);k(),O(t),z(e=>W(n,`No matches for “${e??``}”. `),[()=>B(r).trim()]),U(e,t)},te=e=>{var n=T7();fi(n,23,()=>B(s),e=>e.path,(e,n,i)=>{var a=w7(),o=F(a),s=L(o,2),c=F(s);fi(c,21,()=>m7(B(n).name,B(r)),ci,(e,t)=>{var n=Yr(),r=I(n),i=e=>{var n=x7(),r=F(n,!0);O(n),z(()=>W(r,B(t).text)),U(e,n)},a=e=>{var n=Jr();z(()=>W(n,B(t).text)),U(e,n)};G(r,e=>{B(t).match?e(i):e(a,-1)}),U(e,n)}),O(c);var l=L(c,2),u=e=>{var t=S7(),r=F(t,!0);O(t),z(()=>W(r,B(n).dir)),U(e,t)};G(l,e=>{B(n).dir&&e(u)}),O(s);var d=L(s,2),f=e=>{var t=C7(),r=F(t,!0);O(t),z(()=>W(r,B(n).when)),U(e,t)};G(d,e=>{B(n).when&&e(f)}),O(a),z(()=>{q(a,`data-testid`,`new-tab-recent-${B(i)}`),q(a,`title`,B(n).path),Hi(o,1,`ntl-pip ntl-pip-${B(n).pip??``}`,`svelte-7c4il0`)}),V(`click`,a,()=>t.onOpen(B(n).path)),U(e,a)}),O(n),U(e,n)};G(ee,e=>{B(c)?B(s).length===0?e(E,1):e(te,-1):e(T)}),O(w);var ne=L(w,2),D=L(F(ne),2),re=F(D);n(F(re),()=>`plus`,()=>14,()=>1.9),O(re),k(4),O(D);var ie=L(D,4),ae=F(ie);n(F(ae),()=>`folder`,()=>13,()=>1.7),O(ae),k(4),O(ie);var oe=L(ie,2),se=e=>{var r=E7(),i=F(r);n(F(i),()=>`undo`,()=>13,()=>1.7),O(i),k(4),O(r),z(()=>q(r,`title`,t.closedTabTop.filePath)),V(`click`,r,function(...e){t.onReopenClosed?.apply(this,e)}),U(e,r)};G(oe,e=>{t.closedTabTop&&e(se)}),O(ne),O(C),k(2),O(h),da(h,e=>P(i,e),()=>B(i)),V(`keydown`,h,p),ia(v,()=>B(r),e=>P(r,e)),V(`click`,D,function(...e){t.onNewScratchpad?.apply(this,e)}),V(`click`,ie,function(...e){t.onBrowse?.apply(this,e)}),U(e,h),j()}zr([`keydown`,`click`]);var k7=H(`<input type="text" spellcheck="false" autocomplete="off" aria-label="Rename file" style="min-width: 80px; max-width: 160px; font-size: var(--tandem-text-sm); padding: 0 4px; height: 20px; border: 1px solid var(--tandem-accent); border-radius: var(--tandem-r-1); background: var(--tandem-bg); color: var(--tandem-fg); outline: none;"/>`);function A7(e,t){A(t,!0);let n=N(ln(kr(()=>t.initial))),r=!1;function i(e){if(r)return;r=!0;let i=B(n).trim();e&&i.length>0&&i!==t.initial?t.oncommit(i):t.oncancel()}function a(e){e.focus();let n=t.initial.lastIndexOf(`.`);e.setSelectionRange(0,n>0?n:t.initial.length)}function o(e){e.stopPropagation(),e.key===`Enter`?(e.preventDefault(),i(!0)):e.key===`Escape`&&(e.preventDefault(),i(!1))}var s=k7();Qi(s),Rn(()=>ia(s,()=>B(n),e=>P(n,e))),Ni(s,e=>a?.(e)),z(()=>q(s,`data-testid`,t.testId)),V(`keydown`,s,o),Rr(`blur`,s,()=>i(!1)),V(`pointerdown`,s,e=>e.stopPropagation()),V(`click`,s,e=>e.stopPropagation()),V(`dblclick`,s,e=>e.stopPropagation()),U(e,s),j()}zr([`keydown`,`pointerdown`,`click`,`dblclick`]);var j7=H(`<span class="dot svelte-1btt0ja" aria-hidden="true">●</span>`),M7=H(`<span class="saved-check svelte-1btt0ja" aria-hidden="true">✓</span>`),N7=H(`<span class="svelte-1btt0ja"> </span>`),P7=H(`<span class="tab-ro-badge svelte-1btt0ja" aria-label="Read-only">RO</span>`),F7=H(`<div role="tab" class="svelte-1btt0ja"><span class="save-indicator svelte-1btt0ja"><!></span> <!> <!> <button style="background: none; border: none; cursor: pointer; font-size: var(--tandem-text-md); line-height: 1; color: var(--tandem-fg-muted); padding: 0 2px; border-radius: var(--tandem-r-1);" title="Close document" class="svelte-1btt0ja">×</button></div>`);function I7(e,t){A(t,!0);let n=J(t,`reduceMotion`,3,!1),r=J(t,`isRenaming`,3,!1),i=M(()=>c7(t.tab)),a=N(!1),o=0,s=null;R(()=>{let{ydoc:e,readOnly:n}=t.tab;if(n){P(a,!1);return}let r=e.getXmlFragment(`default`),i=e.getMap(Ua),c=!1,l=setTimeout(()=>{c=!0,s=i.get(`savedAtVersion`)??0,o=0,P(a,!1)},500),u=()=>{c&&(o++,P(a,!0))};r.observeDeep(u);let d=()=>{if(!c)return;let e=i.get(Ga);e!==void 0&&e!==s&&(s=e,o=0,P(a,!1))};return i.observe(d),()=>{clearTimeout(l),r.unobserveDeep(u),i.unobserve(d)}});let c=N(!1),l=!1;R(()=>{let e=l;if(l=B(a),!B(a)&&e){P(c,!0);let e=setTimeout(()=>{P(c,!1)},600);return()=>clearTimeout(e)}P(c,!1)});let u=M(()=>[`display: flex`,`align-items: center`,`gap: 6px`,`padding: 0 10px 0 12px`,`height: 26px`,`font-size: var(--tandem-text-sm)`,`cursor: pointer`,`background: ${t.isActive?`var(--tandem-surface)`:`transparent`}`,`color: ${t.isActive?`var(--tandem-fg)`:`var(--tandem-fg-subtle)`}`,`border: 1px solid ${t.isActive?`var(--tandem-border)`:`transparent`}`,`border-left: ${t.dropIndicator===`left`?`2px solid var(--tandem-accent)`:t.isActive?`1px solid var(--tandem-border)`:`2px solid transparent`}`,`border-right: ${t.dropIndicator===`right`?`2px solid var(--tandem-accent)`:t.isActive?`1px solid var(--tandem-border)`:`2px solid transparent`}`,`border-radius: var(--tandem-r-pill)`,`box-shadow: ${t.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(`; `)),d=N(void 0);function f(){B(d)&&(B(d).style.color=`var(--tandem-error)`)}function p(){B(d)&&(B(d).style.color=`var(--tandem-fg-muted)`)}var m=F7();q(m,`tabindex`,0);var h=F(m),g=F(h),_=e=>{U(e,j7())},v=e=>{U(e,M7())};G(g,e=>{B(a)?e(_):B(c)&&e(v,1)}),O(h);var y=L(h,2),b=e=>{{let n=M(()=>`tab-rename-input-${t.tab.id}`);A7(e,{get initial(){return t.tab.fileName},get testId(){return B(n)},oncommit:e=>t.onrename?.(t.tab.id,e),oncancel:()=>t.onrenamecancel?.()})}},x=e=>{var n=N7(),r=F(n,!0);O(n),z(()=>{q(n,`data-testid`,`tab-name-${t.tab.id}`),q(n,`title`,B(i)?`${t.tab.filePath} — double-click or F2 to rename`:t.tab.filePath),K(n,`font-weight: ${t.isActive?500:400}; min-width: 80px; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;`),W(r,t.tab.fileName)}),V(`dblclick`,n,e=>{B(i)&&(e.stopPropagation(),t.onstartrename?.(t.tab.id))}),U(e,n)};G(y,e=>{r()?e(b):e(x,-1)});var S=L(y,2),C=e=>{U(e,P7())};G(S,e=>{t.tab.readOnly&&e(C)});var w=L(S,2);da(w,e=>P(d,e),()=>B(d)),O(m),z(()=>{q(m,`data-testid`,`tab-${t.tab.id}`),q(m,`data-active`,t.isActive),q(m,`aria-selected`,t.isActive),q(m,`aria-label`,t.tab.fileName),K(m,B(u)),q(h,`data-testid`,`unsaved-indicator-${t.tab.id}`),q(h,`aria-hidden`,!B(a)),q(w,`aria-label`,`Close ${t.tab.fileName}`)}),V(`click`,m,()=>t.onswitch(t.tab.id)),V(`pointerdown`,m,e=>t.onpointerdown(e,t.tab.id)),V(`keydown`,m,e=>t.onkeydown(e,t.tab.id)),V(`click`,w,e=>{e.stopPropagation(),t.onclose(t.tab.id)}),V(`pointerdown`,w,e=>e.stopPropagation()),Rr(`mouseenter`,w,f),Rr(`mouseleave`,w,p),ji(1,m,()=>Hv,()=>({reduceMotion:n()})),ji(2,m,()=>Bv,()=>({reduceMotion:n()})),U(e,m),j()}zr([`click`,`pointerdown`,`keydown`,`dblclick`]);var L7=new Set([`ctx:tab:close`,`ctx:tab:closeOthers`,`ctx:tab:closeRight`,`ctx:tab:copyPath`,`ctx:tab:reveal`]);function R7(e){return typeof e==`string`&&L7.has(e)}function z7(e){return!yo(e)&&!vo(e)}function B7(e,t){let n=e.findIndex(e=>e.id===t),r=n>=0?e[n]:void 0;return{canCloseOthers:e.length>1,canCloseRight:n>=0&&n<e.length-1,hasPath:!!r&&z7(r.filePath)}}function V7(e,t){return e.some(e=>e.id===t)?e.filter(e=>e.id!==t).map(e=>e.id):[]}function H7(e,t){let n=e.findIndex(e=>e.id===t);return n<0?[]:e.slice(n+1).map(e=>e.id)}var U7=H(`<div class="tab-flip svelte-urrc8n" role="presentation"><!></div>`),W7=H(`<div style="position: relative; display: flex; align-items: center; background: transparent; min-height: 32px; z-index: var(--tandem-z-base); width: 100%; min-width: 0;"><div data-testid="tab-scroll-container" role="tablist" aria-label="Open documents" style="display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0; overflow-x: auto; overflow-y: hidden; padding: 6px 8px;"></div> <div class="nt-wrap svelte-urrc8n"><div><button data-testid="open-file-btn" class="tandem-floating-pill tab-add-pill svelte-urrc8n" title="Open file" aria-label="Open file" aria-haspopup="dialog">+</button> <div class="nt-grid svelte-urrc8n"><div class="nt-cell svelte-urrc8n"><!></div></div></div></div></div>`);function G7(e,t){A(t,!0);let n=J(t,`reduceMotion`,3,!1),r=J(t,`openMenuTrigger`,3,0),i=J(t,`renameTrigger`,3,0),a=J(t,`closedTabTop`,3,null),o=N(null);function s(e){P(o,e,!0)}function c(e,n){P(o,null),t.onTabRename?.(e,n)}function l(){P(o,null)}let u=M(()=>n()?`auto`:`smooth`),d=N(!1),f=N(ln([])),p=N(null),m=N(!1),h=N(!1),g=N(null),_=new Set;R(()=>{let e=new Set(t.tabs.map(e=>e.id));for(let t of _)e.has(t)||_.delete(t)});function v(e){_.has(e)||(_.add(e),t.onTabClose(e))}let y=null,b=null;async function x(e){if(!nh())return;let n=e.target?.closest(`[data-testid^="tab-"][role="tab"]`),r=pe(n);if(!r)return;let i=t.tabs.find(e=>e.id===r);if(i){y=r,b=i.filePath,e.preventDefault();try{await(await ah())(`show_tab_context_menu`,{req:B7(t.tabs,r)})}catch{}}}async function S(e){let n=y,r=b;if(n)switch(e){case`ctx:tab:close`:v(n);return;case`ctx:tab:closeOthers`:t.onCloseOthers?.(n);return;case`ctx:tab:closeRight`:t.onCloseToRight?.(n);return;case`ctx:tab:copyPath`:if(r&&z7(r))try{await navigator.clipboard.writeText(r)}catch{}return;case`ctx:tab:reveal`:if(r&&z7(r))try{await(await ah())(`show_in_file_manager`,{path:r})}catch{}return}}let C=N(void 0),w=N(!1),ee=N(!1),T=N(null),E=N(null),te=null,ne=0,D=0,re=!1,ie=null;function ae(e){me(e)}function oe(e){he(e)}function se(e){te!==null&&e.pointerId===te&&le()}function ce(e){e.key===`Escape`&&le()}function le(){if(ie&&te!==null)try{ie.releasePointerCapture(te)}catch{}window.removeEventListener(`pointermove`,ae),window.removeEventListener(`pointerup`,oe),window.removeEventListener(`pointercancel`,se),window.removeEventListener(`keydown`,ce),P(T,null),P(E,null),te=null,re=!1,ie=null}_a(le),R(()=>{if(!B(T)&&!B(E))return;let e=new Set(t.tabs.map(e=>e.id));B(T)&&!e.has(B(T))&&P(T,null),B(E)&&!e.has(B(E).id)&&P(E,null)});function ue(){let e=B(C);e&&(P(w,e.scrollLeft>0),P(ee,e.scrollLeft+e.clientWidth<e.scrollWidth-1))}R(()=>{let e=B(C);if(!e)return;ue(),e.addEventListener(`scroll`,ue,{passive:!0});let t=new ResizeObserver(ue);return t.observe(e),()=>{e.removeEventListener(`scroll`,ue),t.disconnect()}}),R(()=>{let e=B(C);if(e)return e.addEventListener(`contextmenu`,x),()=>e.removeEventListener(`contextmenu`,x)}),R(()=>{if(!nh())return;let e=Ul(async()=>{let{listen:e}=await import(`./event-wL_2RBc7.js`);return{listen:e}},__vite__mapDeps([3,1])).then(({listen:e})=>e(`context-menu-action`,e=>{let t=e.payload?.id;R7(t)&&S(t)}));return e.catch(()=>{}),()=>{e.then(e=>e()).catch(()=>{})}}),R(()=>{t.tabs.length,ue()}),R(()=>{if(!t.activeTabId||!B(C))return;let e=B(C).querySelector(`[data-testid="tab-${t.activeTabId}"]`);e&&e.scrollIntoView({inline:`nearest`,block:`nearest`,behavior:B(u)})});function de(e,t){if(!(e.button!==0||B(_e))){te=e.pointerId,ne=e.clientX,D=e.clientY,re=!1,P(T,t,!0),ie=e.currentTarget;try{ie.setPointerCapture(e.pointerId)}catch{}window.addEventListener(`pointermove`,ae),window.addEventListener(`pointerup`,oe),window.addEventListener(`pointercancel`,se),window.addEventListener(`keydown`,ce)}}function fe(e,t){return document.elementFromPoint(e,t)?.closest(`[data-testid^="tab-"][role="tab"]`)??null}function pe(e){return e?.getAttribute(`data-testid`)?.slice(4)??null}function me(e){if(te===null||e.pointerId!==te||!B(T))return;if(!re){let t=e.clientX-ne,n=e.clientY-D;if(Math.hypot(t,n)<5)return;re=!0}e.preventDefault();let t=fe(e.clientX,e.clientY),n=pe(t);if(!t||!n||n===B(T)){P(E,null);return}let r=t.getBoundingClientRect(),i=r.left+r.width/2;P(E,{id:n,side:e.clientX<i?`left`:`right`},!0)}function he(e){if(te===null||e.pointerId!==te)return;let n=re,r=B(E);if(n&&B(T)&&r&&r.id!==B(T)&&t.reorder&&t.tabs.some(e=>e.id===B(T))&&t.tabs.some(e=>e.id===r.id)&&t.reorder(B(T),r.id,r.side),n){let e,t=n=>{n.stopPropagation(),n.preventDefault(),window.removeEventListener(`click`,t,!0),clearTimeout(e)};window.addEventListener(`click`,t,!0),e=setTimeout(()=>window.removeEventListener(`click`,t,!0),0)}le()}function ge(e,n){if(!e.altKey||!t.reorder||e.key!==`ArrowLeft`&&e.key!==`ArrowRight`)return;e.preventDefault();let r=t.tabs.findIndex(e=>e.id===n);r!==-1&&(e.key===`ArrowLeft`&&r>0?t.reorder(n,t.tabs[r-1].id):e.key===`ArrowRight`&&r<t.tabs.length-1&&t.reorder(t.tabs[r+1].id,n))}let _e=M(()=>t.tabs.length<=1);function ve(){let e=!B(d);if(e)P(f,nu(),!0),Te=document.activeElement,P(m,be(),!0);else{ye();return}P(d,e)}function ye(){let e=document.activeElement;e&&B(g)?.contains(e)&&e.blur(),P(d,!1)}function be(){if(!B(p))return!1;let e=B(p).getBoundingClientRect(),t=window.innerWidth,n=Math.min(460,t-16);return e.right-n>=8?!1:e.left+n<=t-8?!0:t-e.left>e.right}let xe=null;function Se(e){if(!B(g))return NaN;let t=getComputedStyle(B(g)).getPropertyValue(e).trim();return t.endsWith(`ms`)?parseFloat(t):t.endsWith(`s`)?parseFloat(t)*1e3:parseFloat(t)}function Ce(){if(!B(g))return 0;let e=Se(`--morph-p1`)+Se(`--morph-p2`);return Number.isFinite(e)&&e>0?e+40:0}R(()=>{if(B(d)){xe&&=(clearTimeout(xe),null),P(h,!0);return}if(!kr(()=>B(h)))return;xe&&clearTimeout(xe);let e=Ce();if(e<=0){P(h,!1);return}xe=setTimeout(()=>{P(h,!1),xe=null},e)}),_a(()=>{xe&&clearTimeout(xe)});let we=!1,Te=null;R(()=>{if(!B(d))return;function e(e){let t=e.target;t&&(B(p)?.contains(t)||t.closest?.(`.new-tab-menu`)||h3(t)||(we=!0,ye()))}return window.addEventListener(`pointerdown`,e,!0),()=>window.removeEventListener(`pointerdown`,e,!0)});let Ee=!1;R(()=>{if(B(d)){Ee=!0;return}if(!Ee)return;Ee=!1;let e=Te;if(Te=null,we){we=!1;return}e&&e.isConnected&&e!==B(p)&&!B(g)?.contains(e)&&e.focus({preventScroll:!0})}),R(()=>{r()>0&&kr(ve)}),R(()=>{i()>0&&kr(()=>{let e=t.tabs.find(e=>e.id===t.activeTabId);e&&c7(e)&&P(o,e.id,!0)})});var De=W7(),Oe=F(De);fi(Oe,29,()=>t.tabs,e=>e.id,(e,r)=>{var i=U7(),a=F(i);{let e=M(()=>B(r).id===t.activeTabId),i=M(()=>B(E)?.id===B(r).id?B(E).side:null),u=M(()=>B(o)===B(r).id);I7(a,{get tab(){return B(r)},get isActive(){return B(e)},get onswitch(){return t.onTabSwitch},onclose:v,onpointerdown:de,get dropIndicator(){return B(i)},onkeydown:ge,get reduceMotion(){return n()},get isRenaming(){return B(u)},onstartrename:s,onrename:c,onrenamecancel:l})}O(i),Ai(i,()=>o7,()=>({duration:Ov(n())?0:200})),U(e,i)}),O(Oe),da(Oe,e=>P(C,e),()=>B(C));var ke=L(Oe,2),Ae=F(ke);let je;var Me=F(Ae);da(Me,e=>P(p,e),()=>B(p));var Ne=L(Me,2),Pe=F(Ne),Fe=F(Pe),Ie=e=>{O7(e,{get recentFiles(){return B(f)},get closedTabTop(){return a()},onOpen:async e=>{ye();let t=await Hh(e);t.ok?Ql(Jl(nu(),e)):console.warn(`[tandem] failed to open recent file:`,t.error)},onNewScratchpad:()=>{ye(),_u()},onBrowse:()=>{ye(),t.onRequestOpenDialog?.()},onReopenClosed:()=>{ye(),t.onReopenClosed?.()},onClose:ye})};G(Fe,e=>{B(h)&&e(Ie)}),O(Pe),O(Ne),O(Ae),da(Ae,e=>P(g,e),()=>B(g)),O(ke),O(De),z(()=>{Hi(Oe,1,Ii([`tab-scroll-hide`,`tab-scroll-mask`,B(w)&&B(ee)&&`has-overflow`,B(w)&&!B(ee)&&`overflow-left`,!B(w)&&B(ee)&&`overflow-right`])),je=Hi(Ae,1,`nt-morph svelte-urrc8n`,null,je,{open:B(d),filled:B(d)||B(h),"grow-right":B(m)}),q(Me,`aria-expanded`,B(d)),Pe.inert=!B(d)}),V(`click`,Me,ve),U(e,De),j()}zr([`click`]);var K7=(e,t=m,n=m)=>{var r=J7();z(()=>{Hi(r,1,`panel-edge-collapse panel-edge-collapse-${t()}`,`svelte-y74n0s`),q(r,`data-testid`,`panel-edge-collapse-${t()}`),q(r,`aria-label`,t()===`left`?`Hide left panel`:`Hide right panel`)}),V(`click`,r,function(...e){n()?.apply(this,e)}),U(e,r)},q7=H(`<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>`),J7=H(`<div role="button" tabindex="-1"></div>`),Y7=H(`<!> <!>`,1),X7=H(`<!> <!> <!>`,1),Z7=H(`<div class="margin-track svelte-y74n0s" style="grid-column: 2; grid-row: 1;"><!></div>`),Q7=H(`<div class="margin-track svelte-y74n0s" style="grid-column: 4; grid-row: 1;"><!></div>`),$7=H(`<div class="editor-content-track svelte-y74n0s" style="grid-column: 3; grid-row: 1;"><!></div> <!> <!>`,1),e9=H(`<div class="editor-end-marker svelte-y74n0s" aria-hidden="true"><span class="editor-end-pill svelte-y74n0s">End of document</span></div>`),t9=H(`<div data-testid="editor-stage"><!></div> <!>`,1),n9=H(`<div class="editor-column-wrap svelte-y74n0s"><div data-testid="editor-scroll-container" role="region" aria-label="Document editor"><!> <!> <!></div> <!></div>`),r9=H(`<div style="display: flex; flex: 1; align-items: center; justify-content: center; color: var(--tandem-fg-subtle);">Connecting...</div>`),i9=H(`<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>`),a9=H(`<div class="rail-float-shadow rail-float-shadow-left svelte-y74n0s" aria-hidden="true"></div>`),o9=H(`<div class="rail-float-shadow rail-float-shadow-right svelte-y74n0s" aria-hidden="true"></div>`),s9=H(`<span class="rail-tab-badge svelte-y74n0s"> </span>`),c9=H(`<!> <!> <!> <!> <!> <!> <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),l9=H(`<div style="display: flex; flex-direction: column; height: 100vh; background: var(--tandem-bg); color: var(--tandem-fg);"><!> <!></div>`);function u9(e,t){A(t,!0);let n=e=>{G7(e,{get tabs(){return p.orderedTabs},get activeTabId(){return a.activeTabId},get onTabSwitch(){return a.setActiveTabId},onTabClose:l,onCloseOthers:u,onCloseToRight:d,get reorder(){return p.reorder},get reduceMotion(){return h.settings.reduceMotion},onRequestOpenDialog:()=>void ge(),get openMenuTrigger(){return B(He)},onTabRename:(e,t)=>a.handleTabRename(e,t,e=>w.push({id:dc(),type:`launcher`,severity:`error`,message:e,timestamp:Date.now()})),get renameTrigger(){return B(Ue)},get closedTabTop(){return s.top},onReopenClosed:f})},r=(e,t=m,n=m,r=m,i=m)=>{var a=q7();q(a,`aria-valuemin`,0),q(a,`aria-valuemax`,100),z(e=>{q(a,`data-testid`,r()??`${t()}-panel-resize-handle`),q(a,`aria-label`,t()===`left`?`Resize left panel`:`Resize right panel`),q(a,`aria-valuenow`,e)},[()=>i()===void 0?50:Math.round((i()-200)/400*100)]),V(`mousedown`,a,function(...e){n()?.apply(this,e)}),V(`keydown`,a,e=>{let n=null;e.key===`ArrowRight`||e.key===`ArrowUp`?n=16:e.key===`ArrowLeft`||e.key===`ArrowDown`?n=-16:e.key===`PageUp`?n=80:e.key===`PageDown`?n=-80:e.key===`Home`?n=200-(t()===`left`?Ke.width:qe.width):e.key===`End`&&(n=600-(t()===`left`?Ke.width:qe.width)),n!==null&&(e.preventDefault(),e.stopPropagation(),t()===`left`?Ke.handleResizeStep(n):qe.handleResizeStep(n))}),V(`keyup`,a,()=>{}),Rr(`mouseenter`,a,e=>{e.currentTarget.style.background=`var(--tandem-border-strong)`}),Rr(`mouseleave`,a,e=>{e.currentTarget.style.background=`transparent`}),U(e,a)},i=e=>{var t=n9(),n=F(t);let r;{let e=e=>{K4(e,{get ydoc(){return B(St).ydoc},get provider(){return B(St).provider},get readOnly(){return B(Dt)},get currentFilePath(){return B(St).filePath},get format(){return B(St).format},get activeAnnotationId(){return B(Oe)},onEditorReady:e=>P(je,e,!0),onAnnotationClick:e=>{P(Ee,`annotations`),P(Oe,e,!0)},onClearAnnotation:()=>{P(Oe,null)},onSlashCommandMenuChange:e=>P(Ne,e,!0)})},t=(e,t=m,n=m)=>{let r=M(()=>t()===`left`?yt.leftGeometry:yt.rightGeometry),i=M(()=>t()===`left`?yt.leftMode:yt.rightMode);n5(e,{get side(){return t()},get annotations(){return n()},get positions(){return It.byId},get width(){return B(r).column},get edgeInset(){return B(r).inset},get gap(){return B(r).gap},get mode(){return B(i)},get activeAnnotationId(){return B(Oe)},get repliesById(){return Lt.byId},get reduceMotion(){return h.settings.reduceMotion},onClick:e=>{P(Oe,e.id,!0),Mt.scrollToAnnotation(e)},get onAccept(){return Mt.handleAccept},get onDismiss(){return Mt.handleDismiss},get onRemove(){return B(Rt).onRemove},get onEdit(){return B(Rt).onEdit},get onReply(){return B(Rt).onReply},get onSendToClaude(){return B(Rt).onSendToClaude}})};var i=F(n);{let e=M(()=>B(Et)&&B(St)?.format===`docx`),t=M(()=>B(St)?.id);UA(i,{get visible(){return B(e)},get documentId(){return B(t)}})}var o=L(i,2),s=e=>{var t=Y7(),n=I(t);Th(n,{get ydoc(){return B(St).ydoc},get documentId(){return B(St).id},get fileName(){return B(St).fileName}}),Vh(L(n,2),{get ydoc(){return B(St).ydoc},get documentId(){return B(St).id},get fileName(){return B(St).fileName}}),U(e,t)};G(o,e=>{B(St)&&B(St).format===`docx`&&e(s)});var c=L(o,2),l=e=>{var t=Yr();si(I(t),()=>B(St).id,e=>{{let t=M(()=>B(Le).get(B(St).id));c3(e,{get documentId(){return B(St).id},get ydoc(){return B(St).ydoc},get initialDraft(){return B(t)},onDraftChange:(e,t)=>ze(B(St).id,e,t),onExit:()=>jt(B(St).id)})}}),U(e,t)},u=n=>{var r=t9(),i=I(r),o=F(i),s=n=>{var r=X7(),i=I(r);si(i,()=>B(St).id,t=>{e(t)});var a=L(i,2),o=e=>{t(e,()=>`left`,()=>B(Pt))};G(a,e=>{yt.leftVisible&&B(St)&&e(o)});var s=L(a,2),c=e=>{t(e,()=>`right`,()=>B(Ft))};G(s,e=>{yt.rightVisible&&B(St)&&e(c)}),U(n,r)},c=n=>{var r=$7(),i=I(r),o=F(i),s=t=>{var n=Yr();si(I(n),()=>B(St).id,t=>{e(t)}),U(t,n)},c=e=>{Mh(e,{get connected(){return a.connected},get aiChip(){return D.chip},onOpenFile:()=>P(he,!0),onRetry:()=>a.reconnect(),onOpenSettings:ye,onConnectAi:ie,onRestartClaude:ae})};G(o,e=>{B(St)?e(s):e(c,-1)}),O(i);var l=L(i,2),u=e=>{var n=Z7();t(F(n),()=>`left`,()=>B(Pt)),O(n),U(e,n)};G(l,e=>{yt.leftVisible&&B(St)&&e(u)});var d=L(l,2),f=e=>{var n=Q7();t(F(n),()=>`right`,()=>B(Ft)),O(n),U(e,n)};G(d,e=>{yt.rightVisible&&B(St)&&e(f)}),U(n,r)};G(o,e=>{B(St)?.format===`docx`?e(s):e(c,-1)}),O(i),da(i,e=>P(Me,e),()=>B(Me));var l=L(i,2),u=e=>{U(e,e9())};G(l,e=>{B(St)&&e(u)}),z(()=>K(i,yt.layerStyle)),U(n,r)};G(c,e=>{B(kt)&&B(St)?e(l):e(u,-1)}),O(n),da(n,e=>P(Ct,e),()=>B(Ct)),Ni(n,(e,t)=>Vu?.(e,t),()=>`y`)}n3(L(n,2),{get editor(){return B(je)},get open(){return B(Pe)},onClose:()=>P(Pe,!1),get tabs(){return a.tabs},get forceScope(){return B(Fe)}}),O(t),z(()=>{r=Hi(n,1,`editor-scroll tandem-scroll-fade-y`,null,r,{"hide-raw-md":!h.settings.showRawMarkdown}),K(n,`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: ${T.fileDragOver||H6.fileDragOver?`2px dashed var(--tandem-accent)`:`2px solid transparent`}; background: ${T.fileDragOver||H6.fileDragOver?`var(--tandem-accent-bg)`:`var(--tandem-bg)`}; transition: border-color 0.15s, background 0.15s; border-radius: ${T.fileDragOver||H6.fileDragOver?`var(--tandem-r-5)`:`0`};`)}),Rr(`dragover`,n,function(...e){T.handleEditorDragOver?.apply(this,e)}),Rr(`dragleave`,n,function(...e){T.handleEditorDragLeave?.apply(this,e)}),Rr(`drop`,n,function(...e){T.handleEditorDrop?.apply(this,e)}),U(e,t)},a=M8({getRetryStrategy:()=>h.settings.sidecarRetryStrategy});_a(()=>a.destroy());let o=A6(()=>a.tabs);_a(()=>o.destroy()),cv.start({onTransition:()=>a.rebuildForLicenseChange()}),_a(()=>cv.stop());let s=$3(),c=new Set;function l(e){let t=a.tabs.find(t=>t.id===e);if(t&&yo(t.filePath)){let e=bo(t.filePath);if(e&&o.hasUnsavedContent(e)){if(!window.confirm(`This scratchpad has unsaved content that will be lost. Close it anyway?`))return;o.clearUnsaved(e)}}if(!(B(Re).has(e)&&!window.confirm(`This document has unsaved markdown-source edits that will be lost. Close it anyway?`))){if(t&&!vo(t.filePath)&&s.push({filePath:t.filePath,closedAt:Date.now()}),B(Ie).has(e)){let t=new Set(B(Ie));t.delete(e),P(Ie,t,!0)}Be(e),wt.delete(e),a.handleTabClose(e)}}function u(e){for(let t of V7(p.orderedTabs,e))l(t)}function d(e){for(let t of H7(p.orderedTabs,e))l(t)}async function f(){let e=s.pop();if(!e)return;let t=a.tabs.find(t=>t.filePath===e.filePath);if(t){a.setActiveTabId(t.id);return}if(c.has(e.filePath))return;c.add(e.filePath);let n=t=>{s.push(e);let n=e.filePath.split(/[\\/]/).pop()||e.filePath;w.push({id:`reopen-failed-${Date.now()}`,type:`general-error`,severity:`error`,message:`Couldn't reopen ${n}: ${t}`,dedupKey:`reopen-failed:${e.filePath}`,timestamp:Date.now()})};try{let t=await Hh(e.filePath);t.ok||n(t.error)}finally{c.delete(e.filePath)}}let p=L6(()=>a.tabs);M6(()=>p.orderedTabs,()=>a.activeTabId,e=>a.setActiveTabId(e)),R(()=>{let e=a.tabs;if(e.length!==0)try{let t=Zl(),n=t;for(let t of e)vo(t.filePath)||(n=Jl(n,t.filePath));(n.length!==t.length||n.some((e,n)=>e!==t[n]))&&Ql(n)}catch(e){console.warn(`[tandem] failed to sync recent files:`,e)}});let h=xv(),g=R6(()=>a.bootstrapYdoc,()=>h.settings.selectionDwellMs),_=W8(h,g),v=M(()=>vl(h.settings.customShortcuts)),y=M(()=>cl(B(v))),b=M(()=>a.annotations),x=e6(()=>a.disconnectedSince,()=>h.settings.degradedBannerDelayMs),S=w8();E8();let C=M(()=>a.tabs.map(e=>({id:e.id,fileName:e.fileName}))),w=x6(),ee=N(!1),T=c6();if(K6(w.push),nh()){let e=null,t=!1;Ul(async()=>{let{listen:e}=await import(`./event-wL_2RBc7.js`);return{listen:e}},__vite__mapDeps([3,1])).then(({listen:e})=>e(`sidecar-restart-failed`,()=>{w.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(n=>{t?n():e=n}).catch(e=>{console.warn(`[App] Failed to wire sidecar-restart-failed listener:`,e)}),_a(()=>{t=!0,e?.()})}if(nh()){let e=null,t=!1;Ul(async()=>{let{listen:e}=await import(`./event-wL_2RBc7.js`);return{listen:e}},__vite__mapDeps([3,1])).then(({listen:e})=>e(`open-integration-wizard`,()=>{window.dispatchEvent(new CustomEvent(`tandem:open-integration-wizard`))})).then(n=>{t?n():e=n}).catch(e=>{console.warn(`[App] Failed to wire open-integration-wizard listener:`,e),w.push({id:`open-wizard-listener-failed-${Date.now()}`,type:`launcher`,severity:`warning`,message:`Couldn't enable the Setup shortcut. Open Settings → Reopen wizard to configure integrations.`,dedupKey:`open-wizard-listener-failed`,timestamp:Date.now()})}),_a(()=>{t=!0,e?.()})}if(nh()){let e=e=>{switch(e){case`unsupported-extension`:return`That file type can't be opened in Tandem.`;case`not-a-file`:case`non-file-url`:return`That file couldn't be opened — it may have moved or been deleted.`;case`suspicious-path`:return`That file path was rejected for safety reasons.`;default:return`That file couldn't be opened in Tandem.`}},t=t=>{w.push({id:`startup-file-rejected-${Date.now()}`,type:`general-error`,severity:`warning`,message:e(t),dedupKey:`startup-file-rejected`,timestamp:Date.now(),errorCode:`STARTUP_FILE_REJECTED`})},n=null,r=!1;Ul(async()=>{let{listen:e}=await import(`./event-wL_2RBc7.js`);return{listen:e}},__vite__mapDeps([3,1])).then(({listen:e})=>e(`startup-file-rejected`,e=>{t(typeof e.payload==`string`?e.payload:``)})).then(e=>{r?e():n=e}).catch(e=>{console.warn(`[App] Failed to wire startup-file-rejected listener:`,e)}),Ul(async()=>{let{invoke:e}=await import(`./core-SwWLTXZB.js`);return{invoke:e}},[]).then(({invoke:e})=>e(`get_startup_rejection`)).then(e=>{e&&t(e)}).catch(e=>{console.warn(`[App] Failed to poll buffered startup rejection:`,e)}),_a(()=>{r=!0,n?.()})}let E=N(!1),te=N(!1),ne=u6(),D=q3({connected:()=>a.connected,firstRunSettled:()=>ne.settled,soloMode:()=>g.tandemMode===`solo`}),re=!1;R(()=>{a.connected&&!re&&ne.needed!==!0&&ne.refetch().then(e=>{e&&(re=!0)})});function ie(){window.dispatchEvent(new CustomEvent(`tandem:open-integration-wizard`))}function ae(){Pu(),setTimeout(()=>D.refresh(),2e3),setTimeout(()=>D.refresh(),5e3)}R(()=>{let e=async e=>{let t=e.detail?.via;if(D.chip===null||await D.probeSession())return;let n=D.chip;if(n===null)return;let r=t===`comment`?`Comment`:`Message`;w.push({id:`ai-not-ready-${t??`chat`}-${Date.now()}`,type:`launcher`,severity:`warning`,message:`${r} saved — no AI is connected yet. It'll be seen when AI connects.`,dedupKey:`ai-not-ready-${t??`chat`}`,timestamp:Date.now()},{label:n===`connect`?`Connect AI`:`Restart Claude Code`,onClick:n===`connect`?ie:ae})};return window.addEventListener(`tandem:addressed-ai`,e),()=>window.removeEventListener(`tandem:addressed-ai`,e)});let oe=`tandem:wizard-dismissed`,se=N(ln(le())),ce=N(!1);function le(){try{return localStorage.getItem(oe)}catch{return null}}let ue=M(()=>ne.needed===!0&&ne.serverVersion!==null&&B(se)!==ne.serverVersion),de=M(()=>B(ce)||B(ue));function fe(){if(B(ue)&&ne.serverVersion!==null)try{localStorage.setItem(oe,ne.serverVersion),P(se,ne.serverVersion,!0)}catch{}P(ce,!1)}R(()=>{let e=e=>{e.key===oe&&P(se,e.newValue,!0)};return window.addEventListener(`storage`,e),()=>window.removeEventListener(`storage`,e)}),R(()=>{let e=()=>{P(ce,!0),P(te,!1),ne.refetch()};return window.addEventListener(`tandem:open-integration-wizard`,e),()=>window.removeEventListener(`tandem:open-integration-wizard`,e)});let pe=N(null),me=N(!1),he=N(!1);function ge(){return Kh({isTauri:nh(),openModal:()=>{P(he,!0)},onError:e=>w.push({id:dc(),type:`general-error`,severity:`error`,message:e,timestamp:Date.now()})})}let _e=S8();function ve(){B(E)||_e.acknowledge(),P(E,!B(E))}function ye(){_e.acknowledge(),P(te,!0)}let be=N(null);function xe(){B(te)||P(be,qM.models,!0),ye()}function Se(){_e.acknowledge(),P(E,!0)}lu({getActiveTabId:()=>a.activeTabId,getActiveDocumentPath:()=>{let e=a.tabs.find(e=>e.id===a.activeTabId);return e&&!vo(e.filePath)?e.filePath:null},notify:(e,t)=>{w.push({id:`launcher-${Date.now()}`,type:`launcher`,severity:e,message:t,timestamp:Date.now()})},openSettings:Se,openSettingsModal:ye,toggleSoloMode:()=>g.setTandemMode(g.tandemMode===`solo`?`tandem`:`solo`),openFindBar:()=>{P(Fe,`doc`),P(Pe,!0)},openFindBarTabs:()=>{P(Fe,`tabs`),P(Pe,!0)},findNext:()=>{let e=B(je),t=e?s4(e.state):void 0;e&&l6(t)?e.commands.findNext():(P(Fe,`doc`),P(Pe,!0))},findPrev:()=>{let e=B(je),t=e?s4(e.state):void 0;e&&l6(t)?e.commands.findPrev():(P(Fe,`doc`),P(Pe,!0))},closeActiveTab:()=>{let e=a.activeTabId;e&&l(e)},openFileDialog:()=>void ge(),toggleLeftPanel:()=>Ze(),toggleRightPanel:()=>Qe(),reopenClosedTab:()=>void f(),annotationNext:()=>{let e=ZD(B(b)),t=tO(e,B(Oe));if(t){P(Oe,t,!0);let n=e.find(e=>e.id===t);n&&Mt.scrollToAnnotation(n)}},annotationPrev:()=>{let e=ZD(B(b)),t=nO(e,B(Oe));if(t){P(Oe,t,!0);let n=e.find(e=>e.id===t);n&&Mt.scrollToAnnotation(n)}},annotationAccept:()=>{let e=Nt();e&&e.author!==`user`&&Mt.handleAccept(e.id)},annotationDismiss:()=>{let e=Nt();e&&e.author!==`user`&&Mt.handleDismiss(e.id)},selectBlock:()=>B(je)?.chain().focus().selectParentNode().run(),toggleAuthorship:()=>Ce(!h.settings.showAuthorship),toggleFormattingBar:()=>h.updateSettings({formattingBarVisible:!h.settings.formattingBarVisible}),toggleSourceView:()=>At(),saveAs:async()=>{let e=a.tabs.find(e=>e.id===a.activeTabId);if(!e||!vo(e.filePath)){w.push({id:dc(),type:`launcher`,severity:`info`,message:`Save As is only available for scratchpads; this document is already on disk.`,timestamp:Date.now()});return}let t=Math.max(e.filePath.lastIndexOf(`/`),e.filePath.lastIndexOf(`\\`)),n=e.filePath.slice(t+1);await Cu({activeDocId:a.activeTabId,defaultName:n,sourceFormat:e.format,notify:(e,t)=>w.push({id:dc(),type:`launcher`,severity:e,message:t,timestamp:Date.now()})})}});function Ce(e){h.updateSettings({showAuthorship:e,...h.settings.decorationsMuted?{decorationsMuted:!1}:{}})}let we=null;R(()=>{let e=B(je);if(!e)return;let t=h.settings,n=!t.decorationsMuted&&t.showAuthorship;if(we===n)return;let r=we===null;we=n,!r&&kr(()=>{let t=e.state.tr.setMeta(W2,{type:`toggle`,visible:n});e.view.dispatch(t)})});let Te=null;R(()=>{let e=B(je);if(!e)return;let t=h.settings,n=t.decorationsMuted,r={comment:!n&&t.showComments,highlight:!n&&t.showHighlights,note:!n&&t.showNotes},i=`${+!!r.comment}${+!!r.highlight}${+!!r.note}`;if(Te===i)return;let a=Te===null;Te=i,!a&&kr(()=>{let t=e.state.tr.setMeta(A2,{type:`toggle-decorations`,visible:r});e.view.dispatch(t)})}),R(()=>(document.body.classList.toggle(`tandem-reduce-motion`,h.settings.reduceMotion),()=>document.body.classList.remove(`tandem-reduce-motion`))),R(()=>(document.body.classList.toggle(`tandem-rail-hover-reveal`,h.settings.railHoverReveal),()=>document.body.classList.remove(`tandem-rail-hover-reveal`))),t8(()=>h.settings.theme,()=>h.settings.systemLightVariant),G3(()=>h.settings.accentHue),s6(()=>Fl(h.settings,B(St)?.format)),n6(()=>h.settings.density),f6(()=>h.settings.highContrast),Y3(()=>h.settings.annotationPatterns),R(()=>{let e=wl[h.settings.textSize];return document.documentElement.style.setProperty(`--tandem-editor-font-size`,`${e}px`),()=>document.documentElement.style.removeProperty(`--tandem-editor-font-size`)});let Ee=N(ln(h.settings.primaryTab===`chat`?`chat`:`annotations`)),De=M(()=>B(Ee)===`annotations`?0:B(b).filter(sc).length),Oe=N(null),ke=N(!1),Ae=N(null),je=N(null),Me=N(null),Ne=N(!1),Pe=N(!1),Fe=N(`doc`),Ie=N(ln(new Set)),Le=N(ln(new Map)),Re=N(ln(new Set));function ze(e,t,n){let r=new Map(B(Le)),i=new Set(B(Re));n?(r.set(e,t),i.add(e)):(r.delete(e),i.delete(e)),P(Le,r,!0),P(Re,i,!0)}function Be(e){if(!B(Le).has(e)&&!B(Re).has(e))return;let t=new Map(B(Le)),n=new Set(B(Re));t.delete(e),n.delete(e),P(Le,t,!0),P(Re,n,!0)}let Ve=N(0),k=N(0),He=N(0),Ue=N(0),We=r6(`left`),Ge=r6(`right`),Ke=i6({side:`left`,initialWidth:We,getVisible:()=>B(Je)}),qe=i6({side:`right`,initialWidth:Ge,getVisible:()=>B(Ye)}),Je=M(()=>_.leftVisible),Ye=M(()=>_.rightVisible);function Xe(e,t){queueMicrotask(()=>{let n=t?`panel-edge-collapse-${e}`:`peek-strip-${e}`,r=document.querySelector(`[data-testid="${n}"]`);r?r.focus():console.warn(`[tandem] focusToggleTarget: ${n} not mounted; focus dropped to body`)})}let Ze=()=>{$e(`left`),tt.left=!1;let e=!_.leftVisible;_.toggleLeft(),Xe(`left`,e)},Qe=()=>{$e(`right`),tt.right=!1;let e=!_.rightVisible;_.toggleRight(),Xe(`right`,e)};function $e(e){tt[e]&&(nt[e]=!0,requestAnimationFrame(()=>{nt[e]=!1}))}let et=ln({left:!1,right:!1}),tt=ln({left:!1,right:!1}),nt=ln({left:!1,right:!1}),rt=ln({left:!1,right:!1}),it={left:void 0,right:void 0},at={left:void 0,right:void 0},ot={left:void 0,right:void 0},st={left:!1,right:!1},ct={left:!1,right:!1},lt=e=>B(e===`left`?Je:Ye);function ut(e){if(st[e]=!0,!(lt(e)||!h.settings.railHoverReveal)){if(clearTimeout(it[e]),rt[e]){clearTimeout(at[e]),rt[e]=!1,tt[e]=!0;return}it[e]=setTimeout(()=>{tt[e]=!0},120)}}function dt(e){if(!(st[e]||ct[e])&&tt[e]){if(tt[e]=!1,lt(e)||Ov(h.settings.reduceMotion)){rt[e]=!1;return}rt[e]=!0,clearTimeout(at[e]),at[e]=setTimeout(()=>{rt[e]=!1},300)}}function ft(e){st[e]=!1,clearTimeout(it[e]),it[e]=setTimeout(()=>dt(e),180)}function pt(e){ct[e]=!0}function mt(e,t){let n=t.currentTarget,r=t.relatedTarget;r&&n.contains(r)||(ct[e]=!1,dt(e))}function ht(e,t){t.propertyName!==`width`||t.target!==t.currentTarget||(et[e]=!1,clearTimeout(ot[e]))}let gt=kr(()=>({left:B(Je),right:B(Ye)}));R(()=>{let e=B(Je),t=B(Ye);kr(()=>{_t(`left`,e),_t(`right`,t)})});function _t(e,t){if(t===gt[e])return;let n=gt[e]&&!t;gt[e]=t,!(!n||h.settings.reduceMotion)&&(et[e]=!0,clearTimeout(ot[e]),ot[e]=setTimeout(()=>{et[e]=!1},400))}R(()=>()=>{clearTimeout(it.left),clearTimeout(it.right),clearTimeout(ot.left),clearTimeout(ot.right),clearTimeout(at.left),clearTimeout(at.right)});let vt=T8(),yt=U8({getFormat:()=>B(St)?.format,getMarginView:()=>h.settings.marginView,getEditorMeasure:()=>h.settings.editorMeasure,getLeftRailVisible:()=>B(Je),getRightRailVisible:()=>B(Ye),getViewportWidth:()=>vt.width,getLeftHasPending:()=>B(b).some(e=>e.status===`pending`&&r5(e)),getRightHasPending:()=>B(b).some(e=>e.status===`pending`&&i5(e)),leftRailWidthPx:We,rightRailWidthPx:Ge});function bt(){if(B(Ee)===`chat`||!B(je))return;let{from:e,to:t}=B(je).state.selection;if(e===t)return;let n=MD(B(je).state.doc,{from:So(e),to:So(t)}),r=B(je).state.doc.textBetween(e,t,`
270
+ `);P(Ae,{...n,textSnapshot:r.length>200?r.slice(0,197)+`...`:r},!0)}let xt={"toggle-help":e=>{let t=e.target;t&&(t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.isContentEditable)||(e.preventDefault(),P(ke,kr(()=>!B(ke)),!0))},"select-all":e=>{let t=document.activeElement;t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t?.closest?.(`.ProseMirror`)||(e.preventDefault(),B(je)?.commands.selectAll())},save:e=>{e.preventDefault(),!B(kt)&&Eu(a.activeTabId)},"save-as":e=>{let t=e.target;if(t&&(t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.isContentEditable))return;e.preventDefault();let n=a.tabs.find(e=>e.id===a.activeTabId);if(!n||!vo(n.filePath)){w.push({id:dc(),type:`launcher`,severity:`info`,message:`Save As is only available for scratchpads; this document is already on disk.`,timestamp:Date.now()});return}let r=Math.max(n.filePath.lastIndexOf(`/`),n.filePath.lastIndexOf(`\\`)),i=n.filePath.slice(r+1);Cu({activeDocId:a.activeTabId,defaultName:i,sourceFormat:n.format,notify:(e,t)=>w.push({id:dc(),type:`launcher`,severity:e,message:t,timestamp:Date.now()})})},"settings-modal":e=>{e.preventDefault(),ye()},settings:e=>{e.preventDefault(),Se()},"toggle-palette":e=>{e.preventDefault(),P(me,!kr(()=>B(me)))},"new-scratchpad":e=>{let t=e.target;t&&(t.tagName===`INPUT`||t.tagName===`TEXTAREA`)||(e.preventDefault(),_u())},"close-tab":e=>{if(P6(e))return;e.preventDefault();let t=a.activeTabId;t&&l(t)},"open-file":e=>{P6(e)||(e.preventDefault(),ge())},"pick-tab":(e,t)=>{if(P6(e))return;let n=t?.tabIndex;if(n===void 0)return;let r=N6(a.tabs,n);r&&(e.preventDefault(),a.setActiveTabId(r))},"toggle-mode":e=>{P6(e)||(e.preventDefault(),g.setTandemMode(g.tandemMode===`solo`?`tandem`:`solo`))},"reopen-closed-tab":e=>{P6(e)||(e.preventDefault(),f())},"new-tab-menu":e=>{P6(e)||(e.preventDefault(),P(He,B(He)+1))},find:(e,t)=>{if(e.preventDefault(),t?.shift){P(Fe,`tabs`),P(Pe,!0);return}B(Je)?P(Ve,B(Ve)+1):(P(Fe,`doc`),P(Pe,!0))},"find-nav":(e,t)=>{if(P6(e))return;e.preventDefault();let n=B(je),r=n?s4(n.state):void 0;n&&l6(r)?t?.shift?n.commands.findPrev():n.commands.findNext():(P(Fe,`doc`),P(Pe,!0))},"annotation-accept-or-dismiss":(e,t)=>{if(P6(e))return;e.preventDefault();let n=Nt();n&&n.author!==`user`&&(t?.shift?Mt.handleDismiss(n.id):Mt.handleAccept(n.id))},"comment-on-selection":e=>{e.preventDefault();let t=!!B(je)&&B(je).state.selection.from!==B(je).state.selection.to,n=B(Et);if(!(B(Ne)||B(Pe)||B(me))){if(!t){w.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(n){w.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){w.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}P(k,B(k)+1)}},"toggle-authorship":e=>{e.preventDefault(),Ce(!h.settings.showAuthorship)},"toggle-left-panel":e=>{P6(e)||(e.preventDefault(),Ze())},"toggle-right-panel":e=>{P6(e)||(e.preventDefault(),Qe())},"annotation-next":e=>{if(P6(e))return;e.preventDefault();let t=ZD(B(b)),n=tO(t,B(Oe));if(n){P(Oe,n,!0);let e=t.find(e=>e.id===n);e&&Mt.scrollToAnnotation(e)}},"annotation-prev":e=>{if(P6(e))return;e.preventDefault();let t=ZD(B(b)),n=nO(t,B(Oe));if(n){P(Oe,n,!0);let e=t.find(e=>e.id===n);e&&Mt.scrollToAnnotation(e)}},"select-block":e=>{P6(e)||(e.preventDefault(),B(je)&&B(je).chain().focus().selectParentNode().run())}};R(()=>{function e(e){if(e.key===`F2`&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&!e.shiftKey){if(P6(e))return;let t=a.tabs.find(e=>e.id===a.activeTabId);t&&c7(t)&&(e.preventDefault(),P(Ue,B(Ue)+1));return}let t=ul(e,kr(()=>B(v)));t&&xt[t.id]?.(e,t.context)}return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)}),R(()=>{function e(e){if(e.key!==`Escape`||e.defaultPrevented||B(Oe)===null||B(Pe))return;let t=document.activeElement;t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||(!t||t===document.body||t.closest(`.ProseMirror, [data-testid="editor-root"], [data-testid="annotation-list-scroll-container"]`))&&(e.preventDefault(),P(Oe,null))}return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)});let St=M(()=>a.tabs.find(e=>e.id===a.activeTabId)),Ct=N(null),wt=new Map,Tt;R(()=>{let e=B(Ct);if(!e)return;let t=()=>{Tt!==void 0&&wt.set(Tt,e.scrollTop)};return e.addEventListener(`scroll`,t,{passive:!0}),()=>e.removeEventListener(`scroll`,t)}),R(()=>{let e=B(Ct),t=B(St)?.id;if(!e||t===Tt||(Tt=t,t===void 0))return;let n=wt.get(t)??0,r=0,i=!1,a=()=>{i||Tt!==t||(e.scrollTop=n,e.scrollTop<n&&r<30&&(r+=1,requestAnimationFrame(a)))};return requestAnimationFrame(a),()=>{i=!0}});let Et=M(()=>B(St)?.readOnly===!0),Dt=M(()=>B(Et)||cv.ui.showWall),Ot=M(()=>!!B(St)&&B(St).format===`md`&&!B(Et)),kt=M(()=>!!B(St)&&B(Ie).has(B(St).id));function At(){if(!B(St))return;let e=B(St).id,t=new Set(B(Ie));if(t.has(e))t.delete(e);else{if(!B(Ot))return;t.add(e),P(Pe,!1),P(Ne,!1),P(me,!1)}P(Ie,t,!0)}function jt(e){if(!B(Ie).has(e))return;let t=new Set(B(Ie));t.delete(e),P(Ie,t,!0),Be(e)}R(()=>{let e=e=>{B(Re).size!==0&&(e.preventDefault(),e.returnValue=`You have unsaved markdown-source edits.`)};return window.addEventListener(`beforeunload`,e),()=>window.removeEventListener(`beforeunload`,e)}),R(()=>{if(!gu({connected:a.connected,tabCount:a.tabs.length,activeTabId:a.activeTabId}))return;let e=setTimeout(()=>{_u()},400);return()=>clearTimeout(e)});let Mt=d5({getYdoc:()=>B(St)?.ydoc??null,getEditor:()=>B(je),getAnnotations:()=>B(b),onActiveAnnotationChange:e=>{P(Oe,e,!0)},getScrollBehavior:()=>h.settings.reduceMotion?`auto`:`smooth`,getActiveAnnotationId:()=>B(Oe),onApplyFailed:e=>w.push({id:`suggestion-apply-failed-${e.id}`,type:`annotation-error`,severity:`warning`,message:`Couldn't apply the suggestion — the text has changed. The annotation is still pending.`,dedupKey:`suggestion-apply-failed:${e.id}`,timestamp:Date.now()})});function Nt(){return B(Oe)?B(b).find(e=>e.id===B(Oe)):Mt.getReviewTargets()[0]}let Pt=M(()=>yt.effectivelyOn?B(b).filter(r5):[]),Ft=M(()=>yt.effectivelyOn?B(b).filter(i5):[]),It=h6({getEditor:()=>B(je),getYdoc:()=>B(St)?.ydoc??null,getAnnotations:()=>[...B(Pt),...B(Ft)],getLayerEl:()=>B(Me),getEnabled:()=>yt.effectivelyOn}),Lt=X3({getYdoc:()=>B(St)?.ydoc??null}),Rt=M(()=>{let e=B(St)?.ydoc??null,t=B(St)?.id;return{ydoc:e,docId:t,onEdit:(t,n)=>Ak(e,t,n),onReply:(e,n)=>Fk(e,n,t),onRemove:e=>Pk(e,t),onSendToClaude:t=>Mk(e,t)}}),zt=a8(()=>B(b),()=>B(je),()=>B(St)?.fileName);var Bt=l9(),Vt=F(Bt);{let e=M(()=>null),t=M(()=>B(Ot)||B(kt)?At:null);B5(Vt,{get tandemMode(){return g.tandemMode},get onModeChange(){return g.setTandemMode},get claudeActive(){return a.claudeActive},get theme(){return h.settings.theme},onSetTheme:e=>h.updateSettings({theme:e}),onOpenHelp:()=>P(ke,!0),onOpenSettings:ve,onOpenSettingsModal:ye,get updateAvailable(){return _e.showDot},get defaultModelLabel(){return B(e)},onOpenModelsSettings:xe,get aiChip(){return D.chip},onConnectAi:ie,onRestartClaude:ae,get sourceViewActive(){return B(kt)},get onToggleSourceView(){return B(t)},get center(){return n},get settingsBtn(){return B(pe)},set settingsBtn(e){P(pe,e,!0)}})}var Ht=L(Vt,2),Ut=e=>{U(e,r9())},Wt=e=>{var t=c9(),n=I(t),o=e=>{U(e,i9())};G(n,e=>{a.serverRestarted&&e(o)});var s=L(n,2),c=e=>{xN(e,{get version(){return S.availableVersion},get installing(){return S.installing},onInstall:()=>{S.install()},get onDismiss(){return S.dismiss}})},l=M(()=>nh()&&S.showBanner&&S.availableVersion);G(s,e=>{B(l)&&e(c)});var u=L(s,2),d=e=>{Vm(e,{get onDismiss(){return x.dismiss},onRetry:()=>{a.reconnect()}})};G(u,e=>{x.showBanner&&e(d)});var f=L(u,2);dv(f,{});var p=L(f,2);{let e=M(()=>B(St)?.ydoc??null),t=M(()=>B(Ne)||B(Pe)||B(me));U3(p,{get editor(){return B(je)},get ydoc(){return B(e)},get selectionToolbar(){return h.settings.selectionToolbar},get suppressSelectionToolbar(){return B(t)},get requestCommentFocus(){return B(k)},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:e=>h.updateSettings(e),onOpenSettings:ve,get formattingBarVisible(){return h.settings.formattingBarVisible},onToggleFormattingBar:()=>h.updateSettings({formattingBarVisible:!h.settings.formattingBarVisible}),get reduceMotion(){return h.settings.reduceMotion}})}var m=L(p,2),g=e=>{{let t=M(()=>B(St)?.ydoc??null);y5(e,{get editor(){return B(je)},get ydoc(){return B(t)},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:e=>h.updateSettings(e),onOpenSettings:ve,onHide:()=>h.updateSettings({formattingBarVisible:!1})})}};G(m,e=>{h.settings.formattingBarVisible&&e(g)});var _=L(m,2),v=F(_);let T;var ne=F(v),D=e=>{var t=a9();z(()=>K(t,`width: ${Ke.width}px;`)),U(e,t)};G(ne,e=>{(tt.left||rt.left)&&e(D)});var re=L(ne,2),ie=F(re);zA(ie,{kind:`outline`,get focusTrigger(){return B(Ve)},get editor(){return B(je)},visible:!0}),K7(L(ie,2),()=>`left`,()=>Ze),O(re);var ae=L(re,2);{let e=M(()=>!B(Je));c5(ae,{side:`left`,get collapsed(){return B(e)},kind:`outline`,onActivate:Ze})}O(v);var oe=L(v,2),se=e=>{r(e,()=>`left`,()=>e=>Ke.handleResizeStart(e),()=>void 0,()=>Ke.width)};G(oe,e=>{B(Je)&&e(se)});var ce=L(oe,2);i(ce);var le=L(ce,2),ue=e=>{r(e,()=>`right`,()=>e=>qe.handleResizeStart(e),()=>`panel-resize-handle`,()=>qe.width)};G(le,e=>{B(Ye)&&e(ue)});var ge=L(le,2);let _e;var ye=F(ge),xe=e=>{var t=o9();z(()=>K(t,`width: ${qe.width}px;`)),U(e,t)};G(ye,e=>{(tt.right||rt.right)&&e(xe)});var Se=L(ye,2),Ce=F(Se);K7(Ce,()=>`right`,()=>Qe);var we=L(Ce,2),Te=F(we),Me=F(Te),Fe=L(F(Me)),Ie=e=>{var t=s9(),n=F(t,!0);O(t),z(()=>W(n,B(De)>9?`9+`:B(De))),U(e,t)};G(Fe,e=>{B(Ee)!==`annotations`&&B(De)>0&&e(Ie)}),O(Me);var Le=L(Me,2);O(Te),O(we);var Re=L(we,2);{let e=M(()=>B(Ee)===`chat`);zA(Re,{kind:`chat`,get ctrlYdoc(){return a.bootstrapYdoc},get editor(){return B(je)},get activeDocId(){return a.activeTabId},get openDocs(){return B(C)},get claudeActive(){return a.claudeActive},get claudeStatus(){return a.claudeStatus},get capturedAnchor(){return B(Ae)},onCapturedAnchorChange:e=>P(Ae,e,!0),get reduceMotion(){return h.settings.reduceMotion},get visible(){return B(e)}})}var ze=L(Re,2);{let e=M(()=>B(St)?.ydoc??null),t=M(()=>B(St)?.format),n=M(()=>B(St)?.id),r=M(()=>a.claudeWorking?.annotationId??null),i=M(()=>B(Ee)===`annotations`);zA(ze,{kind:`side`,get annotations(){return B(b)},get editor(){return B(je)},get ydoc(){return B(e)},get activeDocFormat(){return B(t)},get documentId(){return B(n)},get activeAnnotationId(){return B(Oe)},onActiveAnnotationChange:e=>P(Oe,e,!0),get reduceMotion(){return h.settings.reduceMotion},get storeReadOnly(){return a.storeReadOnly},get claudeWorkingAnnotationId(){return B(r)},get review(){return Mt},get visible(){return B(i)}})}O(Se);var Be=L(Se,2);{let e=M(()=>!B(Ye));c5(Be,{side:`right`,get collapsed(){return B(e)},kind:`annotations`,get annotations(){return B(b)},onActivate:Qe})}O(ge),O(_);var He=L(_,2);{let e=M(()=>a.claudeWorking?.tool??null);i7(He,{get connected(){return a.connected},get connectionStatus(){return a.connectionStatus},get reconnectAttempts(){return a.reconnectAttempts},get disconnectedSince(){return a.disconnectedSince},get claudeStatus(){return a.claudeStatus},get claudeActive(){return a.claudeActive},get claudeWorkingTool(){return B(e)},get readOnly(){return B(Et)},get saving(){return pu.saving},get lastSaveOk(){return pu.lastSaveOk},get editor(){return B(je)}})}var Ue=L(He,2);pN(Ue,{get open(){return B(E)},onClose:()=>P(E,!1),get settings(){return h.settings},get onUpdate(){return h.updateSettings},get returnFocusEl(){return B(pe)},get anchorEl(){return B(pe)},get connected(){return a.connected},get reconnectAttempts(){return a.reconnectAttempts}});var We=L(Ue,2);QM(We,{get open(){return B(te)},onClose:()=>{P(te,!1),P(be,null)},get settings(){return h.settings},get onUpdate(){return h.updateSettings},get returnFocusEl(){return B(pe)},get triggerEl(){return B(pe)},get connected(){return a.connected},get reconnectAttempts(){return a.reconnectAttempts},get initialTabId(){return B(be)},notify:(e,t)=>w.push({id:`settings-${Date.now()}`,type:`launcher`,severity:e,message:t,timestamp:Date.now()})});var Ge=L(We,2);gv(Ge,{});var Xe=L(Ge,2);mg(Xe,{get open(){return B(ke)},onClose:()=>P(ke,!1),get effectiveShortcutLabels(){return B(y)}});var A=L(Xe,2),j=e=>{tv(e,{open:!0,onClose:fe})};G(A,e=>{B(de)&&e(j)});var $e=L(A,2),it=e=>{lg(e,{onClose:()=>P(he,!1)})};G($e,e=>{B(he)&&e(it)});var at=L($e,2);zm(at,{get open(){return B(me)},onClose:()=>P(me,!1),get editor(){return B(je)},get annotations(){return B(b)},onFocusAnnotation:e=>{P(Oe,e,!0)}});var ot=L(at,2);yN(ot,{get toasts(){return w.toasts},get onDismiss(){return w.dismiss}});var st=L(ot,2);nd(st,{get items(){return w.activity},get open(){return B(ee)},onToggle:()=>P(ee,!B(ee)),get onDismiss(){return w.dismissActivity},get onClear(){return w.clearActivity},onAction:e=>{let t=Hu(e);t&&(a.tabs.some(e=>e.id===t.documentId)?Eu(t.documentId):w.push({id:`retry-unavailable-${t.documentId}`,type:`general-error`,severity:`warning`,message:`Reopen the document to retry the save.`,dedupKey:`retry-unavailable:${t.documentId}`,timestamp:Date.now()}))}});var ct=L(st,2),lt=e=>{Sh(e,{})},dt=M(()=>nh()&&!B(de));G(ct,e=>{B(dt)&&e(lt)});var gt=L(ct,2),_t=e=>{oy(e,{get currentStep(){return zt.currentStep},get onNext(){return zt.nextStep},get onDismiss(){return zt.dismissTutorial},get coworkStatus(){return zt.coworkStatus}})};G(gt,e=>{zt.tutorialActive&&e(_t)}),z(()=>{T=Hi(v,1,`rail-shell rail-shell-left svelte-y74n0s`,null,T,{collapsed:!B(Je),animating:et.left,"rail-floating-chrome":tt.left||rt.left,floating:tt.left,"float-closing":rt.left,"pin-snap":nt.left}),q(v,`data-testid`,tt.left?`rail-float-left`:void 0),K(v,B(Je)?`width: ${Ke.width}px;`:``),K(re,`width: ${Ke.width}px;`),_e=Hi(ge,1,`rail-shell rail-shell-right svelte-y74n0s`,null,_e,{collapsed:!B(Ye),animating:et.right,"rail-floating-chrome":tt.right||rt.right,floating:tt.right,"float-closing":rt.right,"pin-snap":nt.right}),q(ge,`data-testid`,tt.right?`rail-float-right`:void 0),K(ge,B(Ye)?`width: ${qe.width}px;`:``),K(Se,`width: ${qe.width}px;`),Hi(Me,1,`rail-tab`+(B(Ee)===`annotations`?` on`:``),`svelte-y74n0s`),Hi(Le,1,`rail-tab`+(B(Ee)===`chat`?` on`:``),`svelte-y74n0s`)}),Rr(`scroll`,_,e=>{e.currentTarget.scrollLeft=0}),Rr(`mouseenter`,v,()=>ut(`left`)),Rr(`mouseleave`,v,()=>ft(`left`)),V(`focusin`,v,()=>pt(`left`)),V(`focusout`,v,e=>mt(`left`,e)),Rr(`transitionend`,v,e=>ht(`left`,e)),Rr(`mouseenter`,ge,()=>ut(`right`)),Rr(`mouseleave`,ge,()=>ft(`right`)),V(`focusin`,ge,()=>pt(`right`)),V(`focusout`,ge,e=>mt(`right`,e)),Rr(`transitionend`,ge,e=>ht(`right`,e)),V(`click`,Me,()=>{P(Ee,`annotations`)}),V(`mousedown`,Le,bt),V(`click`,Le,()=>{P(Ee,`chat`)}),U(e,t)};G(Ht,e=>{a.ready?e(Wt,-1):e(Ut)}),O(Bt),z(()=>q(Bt,`data-tandem-mode`,g.tandemMode)),U(e,Bt),j()}zr([`mousedown`,`keydown`,`keyup`,`click`,`focusin`,`focusout`]);var d9=`error-boundary-recover-btn`,f9=`error-boundary-reload-btn`;function p9(e,t){A(t,!0),R(()=>{t.onSuccess()}),j()}var m9=H(`<button class="btn btn-primary svelte-1bcl6yi">Try to recover</button>`),h9=H(`<div role="alert" class="error-boundary svelte-1bcl6yi"><h2 class="svelte-1bcl6yi">Something didn't go as planned</h2> <p class="message svelte-1bcl6yi"> </p> <pre class="detail svelte-1bcl6yi"> </pre> <!> <button class="btn btn-secondary svelte-1bcl6yi">Reload</button></div>`),g9=H(`<!> <!>`,1);function _9(e,t){A(t,!0);let n=N(0),r=N(0);var i=Yr();Lt(I(i),{onerror:e=>{FM(e,{source:`ErrorBoundary`}),P(r,B(r)+1)},failed:(e,t=m,i=m)=>{var a=Yr();si(I(a),()=>B(r),e=>{var r=h9(),a=L(F(r),2),o=F(a,!0);O(a);var s=L(a,2),c=F(s,!0);O(s);var l=L(s,2),u=e=>{var t=m9();z(()=>q(t,`data-testid`,d9)),V(`click`,t,()=>{P(n,B(n)+1),i()()}),U(e,t)};G(l,e=>{B(n)<3&&e(u)});var d=L(l,2);O(r),z(e=>{W(o,B(n)>=3?`We weren't able to recover this time — reloading the page should get you going again.`:`The editor ran into an unexpected hiccup.`),W(c,e),q(d,`data-testid`,f9)},[()=>t()instanceof Error?t().message:String(t())]),V(`click`,d,()=>window.location.reload()),U(e,r)}),U(e,a)}},e=>{var r=g9(),i=I(r);yi(i,()=>t.children),p9(L(i,2),{onSuccess:()=>{P(n,0)}}),U(e,r)}),U(e,i),j()}zr([`click`]);function v9(e){_9(e,{children:(e,t)=>{u9(e,{})},$$slots:{default:!0}})}NM(),Zr(v9,{target:document.getElementById(`root`)});export{V as A,A as B,fi as C,H as D,U as E,L as F,O as H,P as I,N as L,z as M,F as N,Jr as O,I as P,M as R,Hi as S,W as T,t as U,k as V,_a as _,ah as a,ea as b,Qm as c,rh as d,Um as f,xa as g,po as h,sh as i,B as j,zr as k,Hm as l,qm as m,ch as n,Ym as o,Jm as p,lh as r,Zm as s,gh as t,Km as u,Qi as v,G as w,K as x,q as y,j as z};